CLOUD: Add RequestIdPair struct

Can be used with Callback<T> (means it's still type safe). It's used to
pass not only Request id to user's callback, but also a value user
wanted.

void *data field is removed from RequestInfo.
This commit is contained in:
Alexander Tkachev 2016-05-26 19:02:55 +06:00
parent 62ccf1f902
commit f4547f44df
15 changed files with 81 additions and 65 deletions

View file

@ -57,7 +57,7 @@ bool DownloadRequest::handle() {
if (_localFile->write(buf, readBytes) != readBytes) {
warning("DownloadRequest: unable to write all received bytes into output file");
ConnMan.getRequestInfo(_id).state = Networking::FINISHED;
if (_boolCallback) (*_boolCallback)(false);
if (_boolCallback) (*_boolCallback)(Storage::RequestBoolPair(_id, false));
return true;
}
@ -68,7 +68,7 @@ bool DownloadRequest::handle() {
}
ConnMan.getRequestInfo(_id).state = Networking::FINISHED;
if (_boolCallback) (*_boolCallback)(_remoteFileStream->httpResponseCode() == 200);
if (_boolCallback) (*_boolCallback)(Storage::RequestBoolPair(_id, _remoteFileStream->httpResponseCode() == 200));
_localFile->close(); //yes, I know it's closed automatically in ~DumpFile()
return true;
@ -82,7 +82,7 @@ void DownloadRequest::restart() {
//thus, it can't restart it
warning("DownloadRequest: cannot be restarted");
ConnMan.getRequestInfo(_id).state = Networking::FINISHED;
if (_boolCallback) (*_boolCallback)(false);
if (_boolCallback) (*_boolCallback)(Storage::RequestBoolPair(_id, false));
//TODO: fix that
}