Added upload progress tracking to AccountManager via JSON

This commit is contained in:
Atlante45 2014-04-07 13:45:30 -07:00
parent 72d09a5cbe
commit cec99caa47
2 changed files with 13 additions and 4 deletions

View file

@ -170,12 +170,18 @@ void AccountManager::invokedRequest(const QString& path, QNetworkAccessManager::
if (!callbackParams.isEmpty()) { if (!callbackParams.isEmpty()) {
// if we have information for a callback, insert the callbackParams into our local map // if we have information for a callback, insert the callbackParams into our local map
_pendingCallbackMap.insert(networkReply, callbackParams); _pendingCallbackMap.insert(networkReply, callbackParams);
if (callbackParams.updateReciever && !callbackParams.updateSlot.isEmpty()) {
callbackParams.updateReciever->connect(networkReply, SIGNAL(uploadProgress(qint64, qint64)),
callbackParams.updateSlot.toStdString().c_str());
}
} }
// if we ended up firing of a request, hook up to it now // if we ended up firing of a request, hook up to it now
connect(networkReply, SIGNAL(finished()), this, SLOT(passSuccessToCallback())); connect(networkReply, SIGNAL(finished()),
SLOT(passSuccessToCallback()));
connect(networkReply, SIGNAL(error(QNetworkReply::NetworkError)), connect(networkReply, SIGNAL(error(QNetworkReply::NetworkError)),
this, SLOT(passErrorToCallback(QNetworkReply::NetworkError))); SLOT(passErrorToCallback(QNetworkReply::NetworkError)));
} }
} }
} }
@ -194,7 +200,7 @@ void AccountManager::passSuccessToCallback() {
// remove the related reply-callback group from the map // remove the related reply-callback group from the map
_pendingCallbackMap.remove(requestReply); _pendingCallbackMap.remove(requestReply);
} else { } else {
if (VERBOSE_HTTP_REQUEST_DEBUGGING) { if (VERBOSE_HTTP_REQUEST_DEBUGGING) {
qDebug() << "Received JSON response from data-server that has no matching callback."; qDebug() << "Received JSON response from data-server that has no matching callback.";
qDebug() << jsonResponse; qDebug() << jsonResponse;

View file

@ -21,7 +21,8 @@ class JSONCallbackParameters {
public: public:
JSONCallbackParameters() : JSONCallbackParameters() :
jsonCallbackReceiver(NULL), jsonCallbackMethod(), jsonCallbackReceiver(NULL), jsonCallbackMethod(),
errorCallbackReceiver(NULL), errorCallbackMethod() {}; errorCallbackReceiver(NULL), errorCallbackMethod(),
updateReciever(NULL), updateSlot() {};
bool isEmpty() const { return !jsonCallbackReceiver && !errorCallbackReceiver; } bool isEmpty() const { return !jsonCallbackReceiver && !errorCallbackReceiver; }
@ -29,6 +30,8 @@ public:
QString jsonCallbackMethod; QString jsonCallbackMethod;
QObject* errorCallbackReceiver; QObject* errorCallbackReceiver;
QString errorCallbackMethod; QString errorCallbackMethod;
QObject* updateReciever;
QString updateSlot;
}; };
class AccountManager : public QObject { class AccountManager : public QObject {