diff options
author | Eugene Sandulenko | 2016-07-22 15:38:24 +0300 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | d57fca4665e65bca1cf487fb109d020d1233e800 (patch) | |
tree | c5a8b0e88f4c55e0f2e2afb2f78a4cd1f89d66f3 /backends/cloud/id | |
parent | cccfe7c247fed9b00c100e64433439386d6ef077 (diff) | |
download | scummvm-rg350-d57fca4665e65bca1cf487fb109d020d1233e800.tar.gz scummvm-rg350-d57fca4665e65bca1cf487fb109d020d1233e800.tar.bz2 scummvm-rg350-d57fca4665e65bca1cf487fb109d020d1233e800.zip |
CLOUD: JANITORIAL: Fix code formatting
Diffstat (limited to 'backends/cloud/id')
-rw-r--r-- | backends/cloud/id/idcreatedirectoryrequest.cpp | 51 | ||||
-rw-r--r-- | backends/cloud/id/iddownloadrequest.cpp | 24 | ||||
-rw-r--r-- | backends/cloud/id/idlistdirectoryrequest.cpp | 36 | ||||
-rw-r--r-- | backends/cloud/id/idresolveidrequest.cpp | 33 | ||||
-rw-r--r-- | backends/cloud/id/idstorage.cpp | 18 | ||||
-rw-r--r-- | backends/cloud/id/idstreamfilerequest.cpp | 21 |
6 files changed, 122 insertions, 61 deletions
diff --git a/backends/cloud/id/idcreatedirectoryrequest.cpp b/backends/cloud/id/idcreatedirectoryrequest.cpp index 11f65033ae..37f417f806 100644 --- a/backends/cloud/id/idcreatedirectoryrequest.cpp +++ b/backends/cloud/id/idcreatedirectoryrequest.cpp @@ -36,20 +36,23 @@ IdCreateDirectoryRequest::IdCreateDirectoryRequest(IdStorage *storage, Common::S IdCreateDirectoryRequest::~IdCreateDirectoryRequest() { _ignoreCallback = true; - if (_workingRequest) _workingRequest->finish(); + if (_workingRequest) + _workingRequest->finish(); delete _boolCallback; } void IdCreateDirectoryRequest::start() { //cleanup _ignoreCallback = true; - if (_workingRequest) _workingRequest->finish(); + if (_workingRequest) + _workingRequest->finish(); _workingRequest = nullptr; _ignoreCallback = false; //the only exception when we create parent folder - is when it's ScummVM/ base folder Common::String prefix = _requestedParentPath; - if (prefix.size() > 7) prefix.erase(7); + if (prefix.size() > 7) + prefix.erase(7); if (prefix.equalsIgnoreCase("ScummVM")) { Storage::BoolCallback callback = new Common::Callback<IdCreateDirectoryRequest, Storage::BoolResponse>(this, &IdCreateDirectoryRequest::createdBaseDirectoryCallback); Networking::ErrorCallback failureCallback = new Common::Callback<IdCreateDirectoryRequest, Networking::ErrorResponse>(this, &IdCreateDirectoryRequest::createdBaseDirectoryErrorCallback); @@ -62,15 +65,19 @@ void IdCreateDirectoryRequest::start() { void IdCreateDirectoryRequest::createdBaseDirectoryCallback(Storage::BoolResponse response) { _workingRequest = nullptr; - if (_ignoreCallback) return; - if (response.request) _date = response.request->date(); + if (_ignoreCallback) + return; + if (response.request) + _date = response.request->date(); resolveId(); } void IdCreateDirectoryRequest::createdBaseDirectoryErrorCallback(Networking::ErrorResponse error) { _workingRequest = nullptr; - if (_ignoreCallback) return; - if (error.request) _date = error.request->date(); + if (_ignoreCallback) + return; + if (error.request) + _date = error.request->date(); finishError(error); } @@ -79,15 +86,18 @@ void IdCreateDirectoryRequest::resolveId() { Storage::UploadCallback innerCallback = new Common::Callback<IdCreateDirectoryRequest, Storage::UploadResponse>(this, &IdCreateDirectoryRequest::idResolvedCallback); Networking::ErrorCallback innerErrorCallback = new Common::Callback<IdCreateDirectoryRequest, Networking::ErrorResponse>(this, &IdCreateDirectoryRequest::idResolveFailedCallback); Common::String path = _requestedParentPath; - if (_requestedParentPath != "") path += "/"; + if (_requestedParentPath != "") + path += "/"; path += _requestedDirectoryName; _workingRequest = _storage->resolveFileId(path, innerCallback, innerErrorCallback); } void IdCreateDirectoryRequest::idResolvedCallback(Storage::UploadResponse response) { _workingRequest = nullptr; - if (_ignoreCallback) return; - if (response.request) _date = response.request->date(); + if (_ignoreCallback) + return; + if (response.request) + _date = response.request->date(); //resolved => folder already exists finishCreation(false); @@ -95,8 +105,10 @@ void IdCreateDirectoryRequest::idResolvedCallback(Storage::UploadResponse respon void IdCreateDirectoryRequest::idResolveFailedCallback(Networking::ErrorResponse error) { _workingRequest = nullptr; - if (_ignoreCallback) return; - if (error.request) _date = error.request->date(); + if (_ignoreCallback) + return; + if (error.request) + _date = error.request->date(); //not resolved => folder not exists if (error.response.contains("no such file found in its parent directory")) { @@ -119,15 +131,19 @@ void IdCreateDirectoryRequest::idResolveFailedCallback(Networking::ErrorResponse void IdCreateDirectoryRequest::createdDirectoryCallback(Storage::BoolResponse response) { _workingRequest = nullptr; - if (_ignoreCallback) return; - if (response.request) _date = response.request->date(); + if (_ignoreCallback) + return; + if (response.request) + _date = response.request->date(); finishCreation(response.value); } void IdCreateDirectoryRequest::createdDirectoryErrorCallback(Networking::ErrorResponse error) { _workingRequest = nullptr; - if (_ignoreCallback) return; - if (error.request) _date = error.request->date(); + if (_ignoreCallback) + return; + if (error.request) + _date = error.request->date(); finishError(error); } @@ -139,7 +155,8 @@ Common::String IdCreateDirectoryRequest::date() const { return _date; } void IdCreateDirectoryRequest::finishCreation(bool success) { Request::finishSuccess(); - if (_boolCallback) (*_boolCallback)(Storage::BoolResponse(this, success)); + if (_boolCallback) + (*_boolCallback)(Storage::BoolResponse(this, success)); } } // End of namespace Id diff --git a/backends/cloud/id/iddownloadrequest.cpp b/backends/cloud/id/iddownloadrequest.cpp index edd2d26ece..2532d611b8 100644 --- a/backends/cloud/id/iddownloadrequest.cpp +++ b/backends/cloud/id/iddownloadrequest.cpp @@ -35,14 +35,16 @@ IdDownloadRequest::IdDownloadRequest(IdStorage *storage, Common::String remotePa IdDownloadRequest::~IdDownloadRequest() { _ignoreCallback = true; - if (_workingRequest) _workingRequest->finish(); + if (_workingRequest) + _workingRequest->finish(); delete _boolCallback; } void IdDownloadRequest::start() { //cleanup _ignoreCallback = true; - if (_workingRequest) _workingRequest->finish(); + if (_workingRequest) + _workingRequest->finish(); _workingRequest = nullptr; _ignoreCallback = false; @@ -54,7 +56,8 @@ void IdDownloadRequest::start() { void IdDownloadRequest::idResolvedCallback(Storage::UploadResponse response) { _workingRequest = nullptr; - if (_ignoreCallback) return; + if (_ignoreCallback) + return; Storage::BoolCallback innerCallback = new Common::Callback<IdDownloadRequest, Storage::BoolResponse>(this, &IdDownloadRequest::downloadCallback); Networking::ErrorCallback innerErrorCallback = new Common::Callback<IdDownloadRequest, Networking::ErrorResponse>(this, &IdDownloadRequest::downloadErrorCallback); @@ -63,19 +66,22 @@ void IdDownloadRequest::idResolvedCallback(Storage::UploadResponse response) { void IdDownloadRequest::idResolveFailedCallback(Networking::ErrorResponse error) { _workingRequest = nullptr; - if (_ignoreCallback) return; + if (_ignoreCallback) + return; finishError(error); } void IdDownloadRequest::downloadCallback(Storage::BoolResponse response) { _workingRequest = nullptr; - if (_ignoreCallback) return; + if (_ignoreCallback) + return; finishDownload(response.value); } void IdDownloadRequest::downloadErrorCallback(Networking::ErrorResponse error) { _workingRequest = nullptr; - if (_ignoreCallback) return; + if (_ignoreCallback) + return; finishError(error); } @@ -85,12 +91,14 @@ void IdDownloadRequest::restart() { start(); } void IdDownloadRequest::finishDownload(bool success) { Request::finishSuccess(); - if (_boolCallback) (*_boolCallback)(Storage::BoolResponse(this, success)); + if (_boolCallback) + (*_boolCallback)(Storage::BoolResponse(this, success)); } double IdDownloadRequest::getProgress() const { DownloadRequest *downloadRequest = dynamic_cast<DownloadRequest *>(_workingRequest); - if (downloadRequest == nullptr) return 0; // resolving id still + if (downloadRequest == nullptr) + return 0; // resolving id still // id resolve is 10 % and download is the other 90 % return 0.1 + 0.9 * downloadRequest->getProgress(); // downloading diff --git a/backends/cloud/id/idlistdirectoryrequest.cpp b/backends/cloud/id/idlistdirectoryrequest.cpp index 6c70ed56a2..4e63709984 100644 --- a/backends/cloud/id/idlistdirectoryrequest.cpp +++ b/backends/cloud/id/idlistdirectoryrequest.cpp @@ -35,14 +35,16 @@ IdListDirectoryRequest::IdListDirectoryRequest(IdStorage *storage, Common::Strin IdListDirectoryRequest::~IdListDirectoryRequest() { _ignoreCallback = true; - if (_workingRequest) _workingRequest->finish(); + if (_workingRequest) + _workingRequest->finish(); delete _listDirectoryCallback; } void IdListDirectoryRequest::start() { //cleanup _ignoreCallback = true; - if (_workingRequest) _workingRequest->finish(); + if (_workingRequest) + _workingRequest->finish(); _workingRequest = nullptr; _files.clear(); _directoriesQueue.clear(); @@ -57,8 +59,10 @@ void IdListDirectoryRequest::start() { void IdListDirectoryRequest::idResolvedCallback(Storage::UploadResponse response) { _workingRequest = nullptr; - if (_ignoreCallback) return; - if (response.request) _date = response.request->date(); + if (_ignoreCallback) + return; + if (response.request) + _date = response.request->date(); StorageFile directory = response.value; directory.setPath(_requestedPath); @@ -68,8 +72,10 @@ void IdListDirectoryRequest::idResolvedCallback(Storage::UploadResponse response void IdListDirectoryRequest::idResolveErrorCallback(Networking::ErrorResponse error) { _workingRequest = nullptr; - if (_ignoreCallback) return; - if (error.request) _date = error.request->date(); + if (_ignoreCallback) + return; + if (error.request) + _date = error.request->date(); finishError(error); } @@ -89,13 +95,16 @@ void IdListDirectoryRequest::listNextDirectory() { void IdListDirectoryRequest::listedDirectoryCallback(Storage::FileArrayResponse response) { _workingRequest = nullptr; - if (_ignoreCallback) return; - if (response.request) _date = response.request->date(); + if (_ignoreCallback) + return; + if (response.request) + _date = response.request->date(); for (uint32 i = 0; i < response.value.size(); ++i) { StorageFile &file = response.value[i]; Common::String path = _currentDirectory.path(); - if (path.size() && path.lastChar() != '/' && path.lastChar() != '\\') path += '/'; + if (path.size() && path.lastChar() != '/' && path.lastChar() != '\\') + path += '/'; path += file.name(); file.setPath(path); _files.push_back(file); @@ -109,8 +118,10 @@ void IdListDirectoryRequest::listedDirectoryCallback(Storage::FileArrayResponse void IdListDirectoryRequest::listedDirectoryErrorCallback(Networking::ErrorResponse error) { _workingRequest = nullptr; - if (_ignoreCallback) return; - if (error.request) _date = error.request->date(); + if (_ignoreCallback) + return; + if (error.request) + _date = error.request->date(); finishError(error); } @@ -122,7 +133,8 @@ Common::String IdListDirectoryRequest::date() const { return _date; } void IdListDirectoryRequest::finishListing(Common::Array<StorageFile> &files) { Request::finishSuccess(); - if (_listDirectoryCallback) (*_listDirectoryCallback)(Storage::ListDirectoryResponse(this, files)); + if (_listDirectoryCallback) + (*_listDirectoryCallback)(Storage::ListDirectoryResponse(this, files)); } } // End of namespace Id diff --git a/backends/cloud/id/idresolveidrequest.cpp b/backends/cloud/id/idresolveidrequest.cpp index 38478fa149..6742a5890f 100644 --- a/backends/cloud/id/idresolveidrequest.cpp +++ b/backends/cloud/id/idresolveidrequest.cpp @@ -35,14 +35,16 @@ IdResolveIdRequest::IdResolveIdRequest(IdStorage *storage, Common::String path, IdResolveIdRequest::~IdResolveIdRequest() { _ignoreCallback = true; - if (_workingRequest) _workingRequest->finish(); + if (_workingRequest) + _workingRequest->finish(); delete _uploadCallback; } void IdResolveIdRequest::start() { //cleanup _ignoreCallback = true; - if (_workingRequest) _workingRequest->finish(); + if (_workingRequest) + _workingRequest->finish(); _workingRequest = nullptr; _currentDirectory = ""; _currentDirectoryId = _storage->getRootDirectoryId(); @@ -64,12 +66,15 @@ void IdResolveIdRequest::listNextDirectory(StorageFile fileToReturn) { void IdResolveIdRequest::listedDirectoryCallback(Storage::FileArrayResponse response) { _workingRequest = nullptr; - if (_ignoreCallback) return; + if (_ignoreCallback) + return; Common::String currentLevelName = _requestedPath; ///debug("'%s'", currentLevelName.c_str()); - if (_currentDirectory.size()) currentLevelName.erase(0, _currentDirectory.size()); - if (currentLevelName.size() && (currentLevelName[0] == '/' || currentLevelName[0] == '\\')) currentLevelName.erase(0, 1); + if (_currentDirectory.size()) + currentLevelName.erase(0, _currentDirectory.size()); + if (currentLevelName.size() && (currentLevelName[0] == '/' || currentLevelName[0] == '\\')) + currentLevelName.erase(0, 1); ///debug("'%s'", currentLevelName.c_str()); for (uint32 i = 0; i < currentLevelName.size(); ++i) { if (currentLevelName[i] == '/' || currentLevelName[i] == '\\') { @@ -80,7 +85,8 @@ void IdResolveIdRequest::listedDirectoryCallback(Storage::FileArrayResponse resp } Common::String path = _currentDirectory; - if (path != "") path += "/"; + if (path != "") + path += "/"; path += currentLevelName; bool lastLevel = (path.equalsIgnoreCase(_requestedPath)); @@ -90,7 +96,8 @@ void IdResolveIdRequest::listedDirectoryCallback(Storage::FileArrayResponse resp bool found = false; for (uint32 i = 0; i < files.size(); ++i) { if ((files[i].isDirectory() || lastLevel) && files[i].name().equalsIgnoreCase(currentLevelName)) { - if (_currentDirectory != "") _currentDirectory += "/"; + if (_currentDirectory != "") + _currentDirectory += "/"; _currentDirectory += files[i].name(); _currentDirectoryId = files[i].id(); ///debug("found it! new directory and its id: '%s', '%s'", _currentDirectory.c_str(), _currentDirectoryId.c_str()); @@ -101,14 +108,17 @@ void IdResolveIdRequest::listedDirectoryCallback(Storage::FileArrayResponse resp } if (!found) { - if (lastLevel) finishError(Networking::ErrorResponse(this, false, true, Common::String("no such file found in its parent directory\n") + _currentDirectoryId, 404)); - else finishError(Networking::ErrorResponse(this, false, true, "subdirectory not found", 400)); + if (lastLevel) + finishError(Networking::ErrorResponse(this, false, true, Common::String("no such file found in its parent directory\n") + _currentDirectoryId, 404)); + else + finishError(Networking::ErrorResponse(this, false, true, "subdirectory not found", 400)); } } void IdResolveIdRequest::listedDirectoryErrorCallback(Networking::ErrorResponse error) { _workingRequest = nullptr; - if (_ignoreCallback) return; + if (_ignoreCallback) + return; finishError(error); } @@ -118,7 +128,8 @@ void IdResolveIdRequest::restart() { start(); } void IdResolveIdRequest::finishFile(StorageFile file) { Request::finishSuccess(); - if (_uploadCallback) (*_uploadCallback)(Storage::UploadResponse(this, file)); + if (_uploadCallback) + (*_uploadCallback)(Storage::UploadResponse(this, file)); } } // End of namespace Id diff --git a/backends/cloud/id/idstorage.cpp b/backends/cloud/id/idstorage.cpp index 5b0f9db347..857e3fb379 100644 --- a/backends/cloud/id/idstorage.cpp +++ b/backends/cloud/id/idstorage.cpp @@ -63,20 +63,26 @@ Storage::ListDirectoryCallback IdStorage::getPrintFilesCallback() { } Networking::Request *IdStorage::resolveFileId(Common::String path, UploadCallback callback, Networking::ErrorCallback errorCallback) { - if (!errorCallback) errorCallback = getErrorPrintingCallback(); - if (!callback) callback = new Common::Callback<IdStorage, UploadResponse>(this, &IdStorage::printFile); + if (!errorCallback) + errorCallback = getErrorPrintingCallback(); + if (!callback) + callback = new Common::Callback<IdStorage, UploadResponse>(this, &IdStorage::printFile); return addRequest(new IdResolveIdRequest(this, path, callback, errorCallback)); } Networking::Request *IdStorage::listDirectory(Common::String path, ListDirectoryCallback callback, Networking::ErrorCallback errorCallback, bool recursive) { - if (!errorCallback) errorCallback = getErrorPrintingCallback(); - if (!callback) callback = new Common::Callback<IdStorage, FileArrayResponse>(this, &IdStorage::printFiles); + if (!errorCallback) + errorCallback = getErrorPrintingCallback(); + if (!callback) + callback = new Common::Callback<IdStorage, FileArrayResponse>(this, &IdStorage::printFiles); return addRequest(new IdListDirectoryRequest(this, path, callback, errorCallback, recursive)); } Networking::Request *IdStorage::createDirectory(Common::String path, BoolCallback callback, Networking::ErrorCallback errorCallback) { - if (!errorCallback) errorCallback = getErrorPrintingCallback(); - if (!callback) callback = new Common::Callback<IdStorage, BoolResponse>(this, &IdStorage::printBool); + if (!errorCallback) + errorCallback = getErrorPrintingCallback(); + if (!callback) + callback = new Common::Callback<IdStorage, BoolResponse>(this, &IdStorage::printBool); //find out the parent path and directory name Common::String parentPath = "", directoryName = path; diff --git a/backends/cloud/id/idstreamfilerequest.cpp b/backends/cloud/id/idstreamfilerequest.cpp index cc1ce2c54f..2e68b15412 100644 --- a/backends/cloud/id/idstreamfilerequest.cpp +++ b/backends/cloud/id/idstreamfilerequest.cpp @@ -34,14 +34,16 @@ IdStreamFileRequest::IdStreamFileRequest(IdStorage *storage, Common::String path IdStreamFileRequest::~IdStreamFileRequest() { _ignoreCallback = true; - if (_workingRequest) _workingRequest->finish(); + if (_workingRequest) + _workingRequest->finish(); delete _streamCallback; } void IdStreamFileRequest::start() { //cleanup _ignoreCallback = true; - if (_workingRequest) _workingRequest->finish(); + if (_workingRequest) + _workingRequest->finish(); _workingRequest = nullptr; _ignoreCallback = false; @@ -53,7 +55,8 @@ void IdStreamFileRequest::start() { void IdStreamFileRequest::idResolvedCallback(Storage::UploadResponse response) { _workingRequest = nullptr; - if (_ignoreCallback) return; + if (_ignoreCallback) + return; Networking::NetworkReadStreamCallback innerCallback = new Common::Callback<IdStreamFileRequest, Networking::NetworkReadStreamResponse>(this, &IdStreamFileRequest::streamFileCallback); Networking::ErrorCallback innerErrorCallback = new Common::Callback<IdStreamFileRequest, Networking::ErrorResponse>(this, &IdStreamFileRequest::streamFileErrorCallback); @@ -62,19 +65,22 @@ void IdStreamFileRequest::idResolvedCallback(Storage::UploadResponse response) { void IdStreamFileRequest::idResolveFailedCallback(Networking::ErrorResponse error) { _workingRequest = nullptr; - if (_ignoreCallback) return; + if (_ignoreCallback) + return; finishError(error); } void IdStreamFileRequest::streamFileCallback(Networking::NetworkReadStreamResponse response) { _workingRequest = nullptr; - if (_ignoreCallback) return; + if (_ignoreCallback) + return; finishStream(response.value); } void IdStreamFileRequest::streamFileErrorCallback(Networking::ErrorResponse error) { _workingRequest = nullptr; - if (_ignoreCallback) return; + if (_ignoreCallback) + return; finishError(error); } @@ -84,7 +90,8 @@ void IdStreamFileRequest::restart() { start(); } void IdStreamFileRequest::finishStream(Networking::NetworkReadStream *stream) { Request::finishSuccess(); - if (_streamCallback) (*_streamCallback)(Networking::NetworkReadStreamResponse(this, stream)); + if (_streamCallback) + (*_streamCallback)(Networking::NetworkReadStreamResponse(this, stream)); } } // End of namespace Id |