aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Tkachev2016-05-26 19:09:06 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commita7b28605a01b59de6f3acc9df4cd1cac707c39e7 (patch)
treec19b7bf5a72eccf8d01da549c1f3251d097107c1
parentf4547f44df32ce1f49a6a36df083e7703751adcd (diff)
downloadscummvm-rg350-a7b28605a01b59de6f3acc9df4cd1cac707c39e7.tar.gz
scummvm-rg350-a7b28605a01b59de6f3acc9df4cd1cac707c39e7.tar.bz2
scummvm-rg350-a7b28605a01b59de6f3acc9df4cd1cac707c39e7.zip
CLOUD: Change Request::handle()
With new ConnectionManager upgrade Requests indicate that they are finished with RequestInfo.state. No need to use handle() return value anymore.
-rw-r--r--backends/cloud/downloadrequest.cpp15
-rw-r--r--backends/cloud/downloadrequest.h2
-rw-r--r--backends/cloud/dropbox/dropboxlistdirectoryrequest.cpp6
-rw-r--r--backends/cloud/dropbox/dropboxlistdirectoryrequest.h2
-rw-r--r--backends/networking/curl/curljsonrequest.cpp5
-rw-r--r--backends/networking/curl/curljsonrequest.h2
-rw-r--r--backends/networking/curl/curlrequest.cpp7
-rw-r--r--backends/networking/curl/curlrequest.h2
-rw-r--r--backends/networking/curl/request.h4
9 files changed, 16 insertions, 29 deletions
diff --git a/backends/cloud/downloadrequest.cpp b/backends/cloud/downloadrequest.cpp
index 6f777b7cb1..756a904c74 100644
--- a/backends/cloud/downloadrequest.cpp
+++ b/backends/cloud/downloadrequest.cpp
@@ -30,23 +30,23 @@ namespace Cloud {
DownloadRequest::DownloadRequest(Storage::BoolCallback callback, Networking::NetworkReadStream *stream, Common::DumpFile *dumpFile):
Request(0), _boolCallback(callback), _remoteFileStream(stream), _localFile(dumpFile) {}
-bool DownloadRequest::handle() {
+void DownloadRequest::handle() {
if (!_remoteFileStream) {
warning("DownloadRequest: no stream to read");
ConnMan.getRequestInfo(_id).state = Networking::FINISHED;
- return true;
+ return;
}
if (!_localFile) {
warning("DownloadRequest: no file to write");
ConnMan.getRequestInfo(_id).state = Networking::FINISHED;
- return true;
+ return;
}
if (!_localFile->isOpen()) {
warning("DownloadRequest: failed to open file to write");
ConnMan.getRequestInfo(_id).state = Networking::FINISHED;
- return true;
+ return;
}
const int kBufSize = 640 * 1024; //640 KB is enough to everyone?..
@@ -58,7 +58,7 @@ bool DownloadRequest::handle() {
warning("DownloadRequest: unable to write all received bytes into output file");
ConnMan.getRequestInfo(_id).state = Networking::FINISHED;
if (_boolCallback) (*_boolCallback)(Storage::RequestBoolPair(_id, false));
- return true;
+ return;
}
if (_remoteFileStream->eos()) {
@@ -70,11 +70,8 @@ bool DownloadRequest::handle() {
ConnMan.getRequestInfo(_id).state = Networking::FINISHED;
if (_boolCallback) (*_boolCallback)(Storage::RequestBoolPair(_id, _remoteFileStream->httpResponseCode() == 200));
- _localFile->close(); //yes, I know it's closed automatically in ~DumpFile()
- return true;
+ _localFile->close(); //yes, I know it's closed automatically in ~DumpFile()
}
-
- return false;
}
void DownloadRequest::restart() {
diff --git a/backends/cloud/downloadrequest.h b/backends/cloud/downloadrequest.h
index c1564100c2..724cf19d89 100644
--- a/backends/cloud/downloadrequest.h
+++ b/backends/cloud/downloadrequest.h
@@ -39,7 +39,7 @@ public:
DownloadRequest(Storage::BoolCallback callback, Networking::NetworkReadStream *stream, Common::DumpFile *dumpFile);
virtual ~DownloadRequest() { delete _localFile; }
- virtual bool handle();
+ virtual void handle();
virtual void restart();
};
diff --git a/backends/cloud/dropbox/dropboxlistdirectoryrequest.cpp b/backends/cloud/dropbox/dropboxlistdirectoryrequest.cpp
index be9304081e..31f015a1cd 100644
--- a/backends/cloud/dropbox/dropboxlistdirectoryrequest.cpp
+++ b/backends/cloud/dropbox/dropboxlistdirectoryrequest.cpp
@@ -112,13 +112,11 @@ void DropboxListDirectoryRequest::responseCallback(Networking::RequestDataPair p
delete json;
}
-bool DropboxListDirectoryRequest::handle() {
- if (_complete && _filesCallback) {
+void DropboxListDirectoryRequest::handle() {
+ if (_complete) {
ConnMan.getRequestInfo(_id).state = Networking::FINISHED;
if (_filesCallback) (*_filesCallback)(Storage::RequestFileArrayPair(_id, _files));
}
-
- return _complete;
}
void DropboxListDirectoryRequest::restart() {
diff --git a/backends/cloud/dropbox/dropboxlistdirectoryrequest.h b/backends/cloud/dropbox/dropboxlistdirectoryrequest.h
index 58f3dc6113..afa544de69 100644
--- a/backends/cloud/dropbox/dropboxlistdirectoryrequest.h
+++ b/backends/cloud/dropbox/dropboxlistdirectoryrequest.h
@@ -47,7 +47,7 @@ public:
DropboxListDirectoryRequest(Common::String token, Common::String path, Storage::FileArrayCallback cb, bool recursive = false);
virtual ~DropboxListDirectoryRequest() { delete _filesCallback; }
- virtual bool handle();
+ virtual void handle();
virtual void restart();
};
diff --git a/backends/networking/curl/curljsonrequest.cpp b/backends/networking/curl/curljsonrequest.cpp
index 11eeb2904a..fd3d631ba9 100644
--- a/backends/networking/curl/curljsonrequest.cpp
+++ b/backends/networking/curl/curljsonrequest.cpp
@@ -54,7 +54,7 @@ char *CurlJsonRequest::getPreparedContents() {
return (char *)result;
}
-bool CurlJsonRequest::handle() {
+void CurlJsonRequest::handle() {
if (!_stream) _stream = new NetworkReadStream(_url, _headersList, _postFields);
if (_stream) {
@@ -77,11 +77,8 @@ bool CurlJsonRequest::handle() {
Common::JSONValue *json = Common::JSON::parse(contents);
(*_callback)(RequestDataPair(_id, json)); //potential memory leak, free it in your callbacks!
}
- return true;
}
}
-
- return false;
}
} //end of namespace Networking
diff --git a/backends/networking/curl/curljsonrequest.h b/backends/networking/curl/curljsonrequest.h
index 9b23cd79f4..3d5dd7858b 100644
--- a/backends/networking/curl/curljsonrequest.h
+++ b/backends/networking/curl/curljsonrequest.h
@@ -40,7 +40,7 @@ public:
CurlJsonRequest(DataCallback cb, const char *url); //TODO: use some Callback<JSON> already
virtual ~CurlJsonRequest();
- virtual bool handle();
+ virtual void handle();
};
} //end of namespace Networking
diff --git a/backends/networking/curl/curlrequest.cpp b/backends/networking/curl/curlrequest.cpp
index 6f5c612bdf..e30b7ce018 100644
--- a/backends/networking/curl/curlrequest.cpp
+++ b/backends/networking/curl/curlrequest.cpp
@@ -37,17 +37,14 @@ CurlRequest::~CurlRequest() {
if (_stream) delete _stream;
}
-bool CurlRequest::handle() {
+void CurlRequest::handle() {
if (!_stream) _stream = new NetworkReadStream(_url, _headersList, _postFields);
if (_stream && _stream->eos()) {
if (_stream->httpResponseCode() != 200)
warning("HTTP response code is not 200 OK (it's %ld)", _stream->httpResponseCode());
- ConnMan.getRequestInfo(_id).state = Networking::FINISHED;
- return true;
+ ConnMan.getRequestInfo(_id).state = Networking::FINISHED;
}
-
- return false;
}
void CurlRequest::restart() {
diff --git a/backends/networking/curl/curlrequest.h b/backends/networking/curl/curlrequest.h
index c7f07fcb18..1a644e4369 100644
--- a/backends/networking/curl/curlrequest.h
+++ b/backends/networking/curl/curlrequest.h
@@ -43,7 +43,7 @@ public:
CurlRequest(DataCallback cb, const char *url);
virtual ~CurlRequest();
- virtual bool handle();
+ virtual void handle();
virtual void restart();
void addHeader(Common::String header);
diff --git a/backends/networking/curl/request.h b/backends/networking/curl/request.h
index f2c2f1f247..d81fe903b8 100644
--- a/backends/networking/curl/request.h
+++ b/backends/networking/curl/request.h
@@ -55,11 +55,9 @@ public:
/**
* Method, which does actual work. Depends on what this Request is doing.
- *
- * @return true if request's work is complete and it may be removed from Storage's list
*/
- virtual bool handle() = 0;
+ virtual void handle() = 0;
virtual void restart() = 0;