aboutsummaryrefslogtreecommitdiff
path: root/backends/cloud/downloadrequest.cpp
diff options
context:
space:
mode:
authorAlexander Tkachev2016-05-26 17:56:13 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commit62ccf1f902100febfb1be02b67e84a6e4938ebbf (patch)
tree1f86b079605ac27d897ae9fc3f9e6cc84e8bf205 /backends/cloud/downloadrequest.cpp
parenteda575a660543884b1a4addd21b676a67d2c2a31 (diff)
downloadscummvm-rg350-62ccf1f902100febfb1be02b67e84a6e4938ebbf.tar.gz
scummvm-rg350-62ccf1f902100febfb1be02b67e84a6e4938ebbf.tar.bz2
scummvm-rg350-62ccf1f902100febfb1be02b67e84a6e4938ebbf.zip
CLOUD: Add RequestInfo struct
ConnectionManager upgrade: it now contains a special struct for each request, so you can access request status and data by request id.
Diffstat (limited to 'backends/cloud/downloadrequest.cpp')
-rw-r--r--backends/cloud/downloadrequest.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/backends/cloud/downloadrequest.cpp b/backends/cloud/downloadrequest.cpp
index e86b6552e9..a96c298fe8 100644
--- a/backends/cloud/downloadrequest.cpp
+++ b/backends/cloud/downloadrequest.cpp
@@ -21,6 +21,7 @@
*/
#include "backends/cloud/downloadrequest.h"
+#include "backends/networking/curl/connectionmanager.h"
#include "common/debug.h"
#include "common/textconsole.h"
@@ -32,16 +33,19 @@ DownloadRequest::DownloadRequest(Storage::BoolCallback callback, Networking::Net
bool DownloadRequest::handle() {
if (!_remoteFileStream) {
warning("DownloadRequest: no stream to read");
+ ConnMan.getRequestInfo(_id).state = Networking::FINISHED;
return true;
}
if (!_localFile) {
warning("DownloadRequest: no file to write");
+ ConnMan.getRequestInfo(_id).state = Networking::FINISHED;
return true;
}
if (!_localFile->isOpen()) {
warning("DownloadRequest: failed to open file to write");
+ ConnMan.getRequestInfo(_id).state = Networking::FINISHED;
return true;
}
@@ -52,7 +56,8 @@ bool DownloadRequest::handle() {
if (readBytes != 0)
if (_localFile->write(buf, readBytes) != readBytes) {
warning("DownloadRequest: unable to write all received bytes into output file");
- if (_boolCallback) (*_boolCallback)(false);
+ ConnMan.getRequestInfo(_id).state = Networking::FINISHED;
+ if (_boolCallback) (*_boolCallback)(false);
return true;
}
@@ -62,6 +67,7 @@ bool DownloadRequest::handle() {
//TODO: do something about it actually
}
+ ConnMan.getRequestInfo(_id).state = Networking::FINISHED;
if (_boolCallback) (*_boolCallback)(_remoteFileStream->httpResponseCode() == 200);
_localFile->close(); //yes, I know it's closed automatically in ~DumpFile()
@@ -71,4 +77,13 @@ bool DownloadRequest::handle() {
return false;
}
+void DownloadRequest::restart() {
+ //this request doesn't know anything about the _remoteFileStream it's reading
+ //thus, it can't restart it
+ warning("DownloadRequest: cannot be restarted");
+ ConnMan.getRequestInfo(_id).state = Networking::FINISHED;
+ if (_boolCallback) (*_boolCallback)(false);
+ //TODO: fix that
+}
+
} //end of namespace Cloud