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/onedrive | |
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/onedrive')
5 files changed, 68 insertions, 37 deletions
diff --git a/backends/cloud/onedrive/onedrivecreatedirectoryrequest.cpp b/backends/cloud/onedrive/onedrivecreatedirectoryrequest.cpp index c934f2e684..bd612d64a8 100644 --- a/backends/cloud/onedrive/onedrivecreatedirectoryrequest.cpp +++ b/backends/cloud/onedrive/onedrivecreatedirectoryrequest.cpp @@ -39,13 +39,15 @@ OneDriveCreateDirectoryRequest::OneDriveCreateDirectoryRequest(OneDriveStorage * OneDriveCreateDirectoryRequest::~OneDriveCreateDirectoryRequest() { _ignoreCallback = true; - if (_workingRequest) _workingRequest->finish(); + if (_workingRequest) + _workingRequest->finish(); delete _boolCallback; } void OneDriveCreateDirectoryRequest::start() { _ignoreCallback = true; - if (_workingRequest) _workingRequest->finish(); + if (_workingRequest) + _workingRequest->finish(); _ignoreCallback = false; Common::String name = _path, parent = _path; @@ -57,13 +59,15 @@ void OneDriveCreateDirectoryRequest::start() { name.erase(0, i + 1); break; } - if (i == 0) break; + if (i == 0) + break; --i; } } Common::String url = "https://api.onedrive.com/v1.0/drive/special/approot"; - if (parent != "") url += ":/" + ConnMan.urlEncode(parent) + ":"; + if (parent != "") + url += ":/" + ConnMan.urlEncode(parent) + ":"; url += "/children"; Networking::JsonCallback innerCallback = new Common::Callback<OneDriveCreateDirectoryRequest, Networking::JsonResponse>(this, &OneDriveCreateDirectoryRequest::responseCallback); Networking::ErrorCallback errorCallback = new Common::Callback<OneDriveCreateDirectoryRequest, Networking::ErrorResponse>(this, &OneDriveCreateDirectoryRequest::errorCallback); @@ -87,7 +91,8 @@ void OneDriveCreateDirectoryRequest::responseCallback(Networking::JsonResponse r delete json; return; } - if (response.request) _date = response.request->date(); + if (response.request) + _date = response.request->date(); Networking::ErrorResponse error(this); Networking::CurlJsonRequest *rq = (Networking::CurlJsonRequest *)response.request; @@ -101,8 +106,9 @@ void OneDriveCreateDirectoryRequest::responseCallback(Networking::JsonResponse r } Common::JSONObject info = json->asObject(); - if (info.contains("id")) finishCreation(true); - else { + if (info.contains("id")) { + finishCreation(true); + } else { error.response = json->stringify(true); finishError(error); } @@ -112,8 +118,10 @@ void OneDriveCreateDirectoryRequest::responseCallback(Networking::JsonResponse r void OneDriveCreateDirectoryRequest::errorCallback(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); } @@ -125,7 +133,8 @@ Common::String OneDriveCreateDirectoryRequest::date() const { return _date; } void OneDriveCreateDirectoryRequest::finishCreation(bool success) { Request::finishSuccess(); - if (_boolCallback) (*_boolCallback)(Storage::BoolResponse(this, success)); + if (_boolCallback) + (*_boolCallback)(Storage::BoolResponse(this, success)); } } // End of namespace OneDrive diff --git a/backends/cloud/onedrive/onedrivelistdirectoryrequest.cpp b/backends/cloud/onedrive/onedrivelistdirectoryrequest.cpp index d0b2714989..30a89a79d0 100644 --- a/backends/cloud/onedrive/onedrivelistdirectoryrequest.cpp +++ b/backends/cloud/onedrive/onedrivelistdirectoryrequest.cpp @@ -40,14 +40,16 @@ OneDriveListDirectoryRequest::OneDriveListDirectoryRequest(OneDriveStorage *stor OneDriveListDirectoryRequest::~OneDriveListDirectoryRequest() { _ignoreCallback = true; - if (_workingRequest) _workingRequest->finish(); + if (_workingRequest) + _workingRequest->finish(); delete _listDirectoryCallback; } void OneDriveListDirectoryRequest::start() { //cleanup _ignoreCallback = true; - if (_workingRequest) _workingRequest->finish(); + if (_workingRequest) + _workingRequest->finish(); _workingRequest = nullptr; _files.clear(); _directoriesQueue.clear(); @@ -94,7 +96,8 @@ void OneDriveListDirectoryRequest::listedDirectoryCallback(Networking::JsonRespo return; } - if (response.request) _date = response.request->date(); + if (response.request) + _date = response.request->date(); Networking::ErrorResponse error(this); Networking::CurlJsonRequest *rq = (Networking::CurlJsonRequest *)response.request; @@ -139,8 +142,10 @@ void OneDriveListDirectoryRequest::listedDirectoryCallback(Networking::JsonRespo void OneDriveListDirectoryRequest::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); } @@ -152,7 +157,8 @@ Common::String OneDriveListDirectoryRequest::date() const { return _date; } void OneDriveListDirectoryRequest::finishListing(Common::Array<StorageFile> &files) { Request::finishSuccess(); - if (_listDirectoryCallback) (*_listDirectoryCallback)(Storage::ListDirectoryResponse(this, files)); + if (_listDirectoryCallback) + (*_listDirectoryCallback)(Storage::ListDirectoryResponse(this, files)); } } // End of namespace OneDrive diff --git a/backends/cloud/onedrive/onedrivestorage.cpp b/backends/cloud/onedrive/onedrivestorage.cpp index a26dec37a4..5612cbfd16 100644 --- a/backends/cloud/onedrive/onedrivestorage.cpp +++ b/backends/cloud/onedrive/onedrivestorage.cpp @@ -58,26 +58,29 @@ OneDriveStorage::OneDriveStorage(Common::String accessToken, Common::String user OneDriveStorage::OneDriveStorage(Common::String code) { getAccessToken( - new Common::Callback<OneDriveStorage, BoolResponse>(this, &OneDriveStorage::codeFlowComplete), - new Common::Callback<OneDriveStorage, Networking::ErrorResponse>(this, &OneDriveStorage::codeFlowFailed), - code + new Common::Callback<OneDriveStorage, BoolResponse>(this, &OneDriveStorage::codeFlowComplete), + new Common::Callback<OneDriveStorage, Networking::ErrorResponse>(this, &OneDriveStorage::codeFlowFailed), + code ); } OneDriveStorage::~OneDriveStorage() {} void OneDriveStorage::getAccessToken(BoolCallback callback, Networking::ErrorCallback errorCallback, Common::String code) { - if (!KEY || !SECRET) loadKeyAndSecret(); + if (!KEY || !SECRET) + loadKeyAndSecret(); bool codeFlow = (code != ""); if (!codeFlow && _refreshToken == "") { warning("OneDriveStorage: no refresh token available to get new access token."); - if (callback) (*callback)(BoolResponse(nullptr, false)); + if (callback) + (*callback)(BoolResponse(nullptr, false)); return; } Networking::JsonCallback innerCallback = new Common::CallbackBridge<OneDriveStorage, BoolResponse, Networking::JsonResponse>(this, &OneDriveStorage::tokenRefreshed, callback); - if (errorCallback == nullptr) errorCallback = getErrorPrintingCallback(); + if (errorCallback == nullptr) + errorCallback = getErrorPrintingCallback(); Networking::CurlJsonRequest *request = new Networking::CurlJsonRequest(innerCallback, errorCallback, "https://login.live.com/oauth20_token.srf"); //TODO if (codeFlow) { request->addPostField("code=" + code); @@ -108,13 +111,15 @@ void OneDriveStorage::tokenRefreshed(BoolCallback callback, Networking::JsonResp if (!result.contains("access_token") || !result.contains("user_id") || !result.contains("refresh_token")) { warning("Bad response, no token or user_id passed"); debug("%s", json->stringify().c_str()); - if (callback) (*callback)(BoolResponse(nullptr, false)); + if (callback) + (*callback)(BoolResponse(nullptr, false)); } else { _token = result.getVal("access_token")->asString(); _uid = result.getVal("user_id")->asString(); _refreshToken = result.getVal("refresh_token")->asString(); CloudMan.save(); //ask CloudManager to save our new refreshToken - if (callback) (*callback)(BoolResponse(nullptr, true)); + if (callback) + (*callback)(BoolResponse(nullptr, true)); } delete json; } @@ -174,8 +179,10 @@ void OneDriveStorage::infoInnerCallback(StorageInfoCallback outerCallback, Netwo } Common::String username = email; - if (username == "") username = name; - if (username == "") username = uid; + if (username == "") + username = name; + if (username == "") + username = uid; CloudMan.setStorageUsername(kStorageOneDriveId, username); if (outerCallback) { @@ -189,7 +196,8 @@ void OneDriveStorage::infoInnerCallback(StorageInfoCallback outerCallback, Netwo void OneDriveStorage::fileInfoCallback(Networking::NetworkReadStreamCallback outerCallback, Networking::JsonResponse response) { if (!response.value) { warning("fileInfoCallback: NULL"); - if (outerCallback) (*outerCallback)(Networking::NetworkReadStreamResponse(response.request, nullptr)); + if (outerCallback) + (*outerCallback)(Networking::NetworkReadStreamResponse(response.request, nullptr)); return; } @@ -204,7 +212,8 @@ void OneDriveStorage::fileInfoCallback(Networking::NetworkReadStreamCallback out } else { warning("downloadUrl not found in passed JSON"); debug("%s", response.value->stringify().c_str()); - if (outerCallback) (*outerCallback)(Networking::NetworkReadStreamResponse(response.request, nullptr)); + if (outerCallback) + (*outerCallback)(Networking::NetworkReadStreamResponse(response.request, nullptr)); } delete response.value; } @@ -226,7 +235,8 @@ Networking::Request *OneDriveStorage::streamFileById(Common::String path, Networ } Networking::Request *OneDriveStorage::createDirectory(Common::String path, BoolCallback callback, Networking::ErrorCallback errorCallback) { - if (!errorCallback) errorCallback = getErrorPrintingCallback(); + if (!errorCallback) + errorCallback = getErrorPrintingCallback(); return addRequest(new OneDriveCreateDirectoryRequest(this, path, callback, errorCallback)); } diff --git a/backends/cloud/onedrive/onedrivetokenrefresher.cpp b/backends/cloud/onedrive/onedrivetokenrefresher.cpp index 3e429f1ef8..f7597599c7 100644 --- a/backends/cloud/onedrive/onedrivetokenrefresher.cpp +++ b/backends/cloud/onedrive/onedrivetokenrefresher.cpp @@ -92,7 +92,8 @@ void OneDriveTokenRefresher::finishJson(Common::JSONValue *json) { irrecoverable = false; } - if (code == "unauthenticated") irrecoverable = false; + if (code == "unauthenticated") + irrecoverable = false; if (irrecoverable) { finishError(Networking::ErrorResponse(this, false, true, json->stringify(true), httpResponseCode)); diff --git a/backends/cloud/onedrive/onedriveuploadrequest.cpp b/backends/cloud/onedrive/onedriveuploadrequest.cpp index a22dbf06a3..331800a381 100644 --- a/backends/cloud/onedrive/onedriveuploadrequest.cpp +++ b/backends/cloud/onedrive/onedriveuploadrequest.cpp @@ -41,14 +41,16 @@ OneDriveUploadRequest::OneDriveUploadRequest(OneDriveStorage *storage, Common::S OneDriveUploadRequest::~OneDriveUploadRequest() { _ignoreCallback = true; - if (_workingRequest) _workingRequest->finish(); + if (_workingRequest) + _workingRequest->finish(); delete _contentsStream; delete _uploadCallback; } void OneDriveUploadRequest::start() { _ignoreCallback = true; - if (_workingRequest) _workingRequest->finish(); + if (_workingRequest) + _workingRequest->finish(); if (_contentsStream == nullptr) { warning("OneDriveUploadRequest: cannot restart because no stream given"); finishError(Networking::ErrorResponse(this, false, true, "No stream given", -1)); @@ -97,9 +99,9 @@ void OneDriveUploadRequest::uploadNextPart() { uint32 size = _contentsStream->read(buffer, UPLOAD_PER_ONE_REQUEST); request->setBuffer(buffer, size); - if (_uploadUrl != "") + if (_uploadUrl != "") { request->addHeader(Common::String::format("Content-Range: bytes %u-%u/%u", oldPos, _contentsStream->pos() - 1, _contentsStream->size())); - else if (_contentsStream->size() == 0) { + } else if (_contentsStream->size() == 0) { warning("\"Sorry, OneDrive can't upload empty files\""); finishUpload(StorageFile(_savePath, 0, 0, false)); delete request; @@ -111,7 +113,8 @@ void OneDriveUploadRequest::uploadNextPart() { void OneDriveUploadRequest::partUploadedCallback(Networking::JsonResponse response) { _workingRequest = nullptr; - if (_ignoreCallback) return; + if (_ignoreCallback) + return; Networking::ErrorResponse error(this, false, true, "", -1); Networking::CurlJsonRequest *rq = (Networking::CurlJsonRequest *)response.request; @@ -164,7 +167,8 @@ void OneDriveUploadRequest::partUploadedCallback(Networking::JsonResponse respon void OneDriveUploadRequest::partUploadedErrorCallback(Networking::ErrorResponse error) { _workingRequest = nullptr; - if (_ignoreCallback) return; + if (_ignoreCallback) + return; finishError(error); } @@ -174,7 +178,8 @@ void OneDriveUploadRequest::restart() { start(); } void OneDriveUploadRequest::finishUpload(StorageFile file) { Request::finishSuccess(); - if (_uploadCallback) (*_uploadCallback)(Storage::UploadResponse(this, file)); + if (_uploadCallback) + (*_uploadCallback)(Storage::UploadResponse(this, file)); } } // End of namespace OneDrive |