Commit e3d7417b authored by Maik Qualmann's avatar Maik Qualmann

Merge branch 'master' of invent.kde.org:kde/digikam

parents c874860a f6cec96b
Pipeline #10656 failed with stage
in 60 minutes
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include <QWidget> #include <QWidget>
#include <QMutex> #include <QMutex>
#include <QQueue> #include <QQueue>
#include <QSharedPointer>
#include <QNetworkReply> #include <QNetworkReply>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QCryptographicHash> #include <QCryptographicHash>
...@@ -65,14 +64,14 @@ public: ...@@ -65,14 +64,14 @@ public:
{ {
} }
QQueue<RajceCommand*> commandQueue; QQueue<QSharedPointer<RajceCommand> > commandQueue;
QMutex queueAccess; QMutex queueAccess;
QString tmpDir; QString tmpDir;
QNetworkAccessManager* netMngr; QNetworkAccessManager* netMngr;
QNetworkReply* reply; QNetworkReply* reply;
RajceSession session; RajceSession session;
}; };
RajceTalker::RajceTalker(QWidget* const parent) RajceTalker::RajceTalker(QWidget* const parent)
...@@ -98,39 +97,39 @@ const RajceSession& RajceTalker::session() const ...@@ -98,39 +97,39 @@ const RajceSession& RajceTalker::session() const
return d->session; return d->session;
} }
void RajceTalker::startCommand(RajceCommand* const command) void RajceTalker::startCommand(const QSharedPointer<RajceCommand>& command)
{ {
qCDebug(DIGIKAM_WEBSERVICES_LOG) << "Sending command:\n" << command->getXml(); qCDebug(DIGIKAM_WEBSERVICES_LOG) << "Sending command:\n" << command->getXml();
QByteArray data = command->encode(); QByteArray data = command.get()->encode();
QNetworkRequest netRequest(RAJCE_URL); QNetworkRequest netRequest(RAJCE_URL);
netRequest.setHeader(QNetworkRequest::ContentTypeHeader, command->contentType()); netRequest.setHeader(QNetworkRequest::ContentTypeHeader, command.get()->contentType());
d->reply = d->netMngr->post(netRequest, data); d->reply = d->netMngr->post(netRequest, data);
connect(d->reply, SIGNAL(uploadProgress(qint64,qint64)), connect(d->reply, SIGNAL(uploadProgress(qint64,qint64)),
SLOT(slotUploadProgress(qint64,qint64))); SLOT(slotUploadProgress(qint64,qint64)));
emit signalBusyStarted(command->commandType()); emit signalBusyStarted(command.get()->commandType());
} }
void RajceTalker::login(const QString& username, const QString& password) void RajceTalker::login(const QString& username, const QString& password)
{ {
QSharedPointer<LoginCommand> command = QSharedPointer<LoginCommand>(new LoginCommand(username, password)); QSharedPointer<RajceCommand> command = QSharedPointer<LoginCommand>(new LoginCommand(username, password));
enqueueCommand(command.get()); enqueueCommand(command);
} }
void RajceTalker::loadAlbums() void RajceTalker::loadAlbums()
{ {
QSharedPointer<AlbumListCommand> command = QSharedPointer<AlbumListCommand>(new AlbumListCommand(d->session)); QSharedPointer<RajceCommand> command = QSharedPointer<AlbumListCommand>(new AlbumListCommand(d->session));
enqueueCommand(command.get()); enqueueCommand(command);
} }
void RajceTalker::createAlbum(const QString& name, const QString& description, bool visible) void RajceTalker::createAlbum(const QString& name, const QString& description, bool visible)
{ {
QSharedPointer<CreateAlbumCommand> command = QSharedPointer<CreateAlbumCommand>(new CreateAlbumCommand(name, description, visible, d->session)); QSharedPointer<RajceCommand> command = QSharedPointer<CreateAlbumCommand>(new CreateAlbumCommand(name, description, visible, d->session));
enqueueCommand(command.get()); enqueueCommand(command);
} }
void RajceTalker::slotFinished(QNetworkReply* reply) void RajceTalker::slotFinished(QNetworkReply* reply)
...@@ -146,14 +145,12 @@ void RajceTalker::slotFinished(QNetworkReply* reply) ...@@ -146,14 +145,12 @@ void RajceTalker::slotFinished(QNetworkReply* reply)
d->queueAccess.lock(); d->queueAccess.lock();
RajceCommand* const c = d->commandQueue.head(); QSharedPointer<RajceCommand> c = d->commandQueue.head();
d->reply = nullptr; d->reply = nullptr;
c->processResponse(response, d->session); c->processResponse(response, d->session);
RajceCommandType type = c->commandType(); RajceCommandType type = c.get()->commandType();
delete c;
qCDebug(DIGIKAM_WEBSERVICES_LOG) << "State after command: " << d->session; qCDebug(DIGIKAM_WEBSERVICES_LOG) << "State after command: " << d->session;
...@@ -190,16 +187,16 @@ void RajceTalker::logout() ...@@ -190,16 +187,16 @@ void RajceTalker::logout()
void RajceTalker::openAlbum(const RajceAlbum& album) void RajceTalker::openAlbum(const RajceAlbum& album)
{ {
QSharedPointer<OpenAlbumCommand> command = QSharedPointer<OpenAlbumCommand>(new OpenAlbumCommand(album.id, d->session)); QSharedPointer<RajceCommand> command = QSharedPointer<OpenAlbumCommand>(new OpenAlbumCommand(album.id, d->session));
enqueueCommand(command.get()); enqueueCommand(command);
} }
void RajceTalker::closeAlbum() void RajceTalker::closeAlbum()
{ {
if (!d->session.openAlbumToken().isEmpty()) if (!d->session.openAlbumToken().isEmpty())
{ {
QSharedPointer<CloseAlbumCommand> command = QSharedPointer<CloseAlbumCommand>(new CloseAlbumCommand(d->session)); QSharedPointer<RajceCommand> command = QSharedPointer<CloseAlbumCommand>(new CloseAlbumCommand(d->session));
enqueueCommand(command.get()); enqueueCommand(command);
} }
else else
{ {
...@@ -209,8 +206,8 @@ void RajceTalker::closeAlbum() ...@@ -209,8 +206,8 @@ void RajceTalker::closeAlbum()
void RajceTalker::uploadPhoto(const QString& path, unsigned dimension, int jpgQuality) void RajceTalker::uploadPhoto(const QString& path, unsigned dimension, int jpgQuality)
{ {
QSharedPointer<AddPhotoCommand> command = QSharedPointer<AddPhotoCommand>(new AddPhotoCommand(d->tmpDir, path, dimension, jpgQuality, d->session)); QSharedPointer<RajceCommand> command = QSharedPointer<AddPhotoCommand>(new AddPhotoCommand(d->tmpDir, path, dimension, jpgQuality, d->session));
enqueueCommand(command.get()); enqueueCommand(command);
} }
void RajceTalker::clearLastError() void RajceTalker::clearLastError()
...@@ -230,10 +227,11 @@ void RajceTalker::slotUploadProgress(qint64 bytesSent, qint64 bytesTotal) ...@@ -230,10 +227,11 @@ void RajceTalker::slotUploadProgress(qint64 bytesSent, qint64 bytesTotal)
qCDebug(DIGIKAM_WEBSERVICES_LOG) << "Percent signalled: " << percent; qCDebug(DIGIKAM_WEBSERVICES_LOG) << "Percent signalled: " << percent;
emit signalBusyProgress(d->commandQueue.head()->commandType(), percent); QSharedPointer<RajceCommand> c = d->commandQueue.head();
emit signalBusyProgress(c.get()->commandType(), percent);
} }
void RajceTalker::enqueueCommand(RajceCommand* const command) void RajceTalker::enqueueCommand(const QSharedPointer<RajceCommand>& command)
{ {
if (d->session.lastErrorCode() != 0) if (d->session.lastErrorCode() != 0)
{ {
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QSharedPointer>
// Local includes // Local includes
...@@ -80,8 +81,8 @@ private Q_SLOTS: ...@@ -80,8 +81,8 @@ private Q_SLOTS:
private: private:
void startCommand(RajceCommand* const); void startCommand(const QSharedPointer<RajceCommand>&);
void enqueueCommand(RajceCommand* const); void enqueueCommand(const QSharedPointer<RajceCommand>&);
private: private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment