diff options
author | Alexander Tkachev | 2016-07-14 09:19:12 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | b4e9e35e07538a118588742aff6fd4a7a2b4d600 (patch) | |
tree | f332710318f4880baf8fc7f58902caca3314d77d | |
parent | 0b5bd18d8525e16749ad422913800b2120021240 (diff) | |
download | scummvm-rg350-b4e9e35e07538a118588742aff6fd4a7a2b4d600.tar.gz scummvm-rg350-b4e9e35e07538a118588742aff6fd4a7a2b4d600.tar.bz2 scummvm-rg350-b4e9e35e07538a118588742aff6fd4a7a2b4d600.zip |
CLOUD: Cleanup in Storages
-rw-r--r-- | backends/cloud/box/boxstorage.cpp | 33 | ||||
-rw-r--r-- | backends/cloud/box/boxstorage.h | 8 | ||||
-rw-r--r-- | backends/cloud/dropbox/dropboxstorage.cpp | 27 | ||||
-rw-r--r-- | backends/cloud/dropbox/dropboxstorage.h | 9 | ||||
-rw-r--r-- | backends/cloud/googledrive/googledrivestorage.cpp | 37 | ||||
-rw-r--r-- | backends/cloud/googledrive/googledrivestorage.h | 11 | ||||
-rw-r--r-- | backends/cloud/id/idstorage.cpp | 11 | ||||
-rw-r--r-- | backends/cloud/id/idstorage.h | 1 | ||||
-rw-r--r-- | backends/cloud/onedrive/onedrivestorage.cpp | 65 | ||||
-rw-r--r-- | backends/cloud/onedrive/onedrivestorage.h | 20 | ||||
-rw-r--r-- | backends/cloud/storage.h | 3 |
11 files changed, 0 insertions, 225 deletions
diff --git a/backends/cloud/box/boxstorage.cpp b/backends/cloud/box/boxstorage.cpp index 35e86409c3..9e036b1187 100644 --- a/backends/cloud/box/boxstorage.cpp +++ b/backends/cloud/box/boxstorage.cpp @@ -177,29 +177,6 @@ void BoxStorage::infoInnerCallback(StorageInfoCallback outerCallback, Networking delete json; } -void BoxStorage::fileInfoCallback(Networking::NetworkReadStreamCallback outerCallback, Networking::JsonResponse response) { - if (!response.value) { - warning("fileInfoCallback: NULL"); - if (outerCallback) (*outerCallback)(Networking::NetworkReadStreamResponse(response.request, 0)); - return; - } - - Common::JSONObject result = response.value->asObject(); - if (result.contains("@content.downloadUrl")) { - const char *url = result.getVal("@content.downloadUrl")->asString().c_str(); - if (outerCallback) - (*outerCallback)(Networking::NetworkReadStreamResponse( - response.request, - new Networking::NetworkReadStream(url, 0, "") - )); - } else { - warning("downloadUrl not found in passed JSON"); - debug("%s", response.value->stringify().c_str()); - if (outerCallback) (*outerCallback)(Networking::NetworkReadStreamResponse(response.request, 0)); - } - delete response.value; -} - Networking::Request *BoxStorage::listDirectoryById(Common::String id, ListDirectoryCallback callback, Networking::ErrorCallback errorCallback) { if (!errorCallback) errorCallback = getErrorPrintingCallback(); if (!callback) callback = getPrintFilesCallback(); @@ -275,11 +252,6 @@ Networking::Request *BoxStorage::streamFileById(Common::String id, Networking::N return nullptr; } -void BoxStorage::fileDownloaded(BoolResponse response) { - if (response.value) debug("file downloaded!"); - else debug("download failed!"); -} - Networking::Request *BoxStorage::info(StorageInfoCallback callback, Networking::ErrorCallback errorCallback) { Networking::JsonCallback innerCallback = new Common::CallbackBridge<BoxStorage, StorageInfoResponse, Networking::JsonResponse>(this, &BoxStorage::infoInnerCallback, callback); Networking::CurlJsonRequest *request = new BoxTokenRefresher(this, innerCallback, errorCallback, "https://api.box.com/2.0/users/me"); @@ -307,11 +279,6 @@ BoxStorage *BoxStorage::loadFromConfig(Common::String keyPrefix) { return new BoxStorage(accessToken, refreshToken); } -Common::String BoxStorage::getAuthLink() { - // now we only specify short "scummvm.org/c/bx" with actual redirect to the auth page - return ""; -} - Common::String BoxStorage::getRootDirectoryId() { return "0"; } diff --git a/backends/cloud/box/boxstorage.h b/backends/cloud/box/boxstorage.h index a737e9d4a1..51f2a9591c 100644 --- a/backends/cloud/box/boxstorage.h +++ b/backends/cloud/box/boxstorage.h @@ -46,9 +46,6 @@ class BoxStorage: public Id::IdStorage { /** Constructs StorageInfo based on JSON response from cloud. */ void infoInnerCallback(StorageInfoCallback outerCallback, Networking::JsonResponse json); - void fileDownloaded(BoolResponse response); - - void fileInfoCallback(Networking::NetworkReadStreamCallback outerCallback, Networking::JsonResponse response); void createDirectoryInnerCallback(BoolCallback outerCallback, Networking::JsonResponse response); public: /** This constructor uses OAuth code flow to get tokens. */ @@ -104,11 +101,6 @@ public: */ static BoxStorage *loadFromConfig(Common::String keyPrefix); - /** - * Returns Box auth link. - */ - static Common::String getAuthLink(); - virtual Common::String getRootDirectoryId(); /** diff --git a/backends/cloud/dropbox/dropboxstorage.cpp b/backends/cloud/dropbox/dropboxstorage.cpp index 6d73e52c43..8343b74aa0 100644 --- a/backends/cloud/dropbox/dropboxstorage.cpp +++ b/backends/cloud/dropbox/dropboxstorage.cpp @@ -105,24 +105,6 @@ Common::String DropboxStorage::name() const { return "Dropbox"; } -void DropboxStorage::printFiles(FileArrayResponse response) { - debug("files:"); - Common::Array<StorageFile> &files = response.value; - for (uint32 i = 0; i < files.size(); ++i) - debug("\t%s", files[i].name().c_str()); -} - -void DropboxStorage::printBool(BoolResponse response) { - debug("bool: %s", (response.value?"true":"false")); -} - -void DropboxStorage::printStorageFile(UploadResponse response) { - debug("\nuploaded file info:"); - debug("\tpath: %s", response.value.path().c_str()); - debug("\tsize: %u", response.value.size()); - debug("\ttimestamp: %u", response.value.timestamp()); -} - Networking::Request *DropboxStorage::listDirectory(Common::String path, ListDirectoryCallback outerCallback, Networking::ErrorCallback errorCallback, bool recursive) { return addRequest(new DropboxListDirectoryRequest(_token, path, outerCallback, errorCallback, recursive)); } @@ -218,14 +200,5 @@ DropboxStorage *DropboxStorage::loadFromConfig(Common::String keyPrefix) { return new DropboxStorage(accessToken, userId); } -Common::String DropboxStorage::getAuthLink() { - Common::String url = "https://www.dropbox.com/1/oauth2/authorize"; - url += "?response_type=code"; - url += "&redirect_uri=http://localhost:12345/"; //that's for copy-pasting - //url += "&redirect_uri=http%3A%2F%2Flocalhost%3A12345%2F"; //that's "http://localhost:12345/" for automatic opening - url += "&client_id="; url += KEY; - return url; -} - } // End of namespace Dropbox } // End of namespace Cloud diff --git a/backends/cloud/dropbox/dropboxstorage.h b/backends/cloud/dropbox/dropboxstorage.h index d256e0562b..b3dc64139c 100644 --- a/backends/cloud/dropbox/dropboxstorage.h +++ b/backends/cloud/dropbox/dropboxstorage.h @@ -46,10 +46,6 @@ class DropboxStorage: public Cloud::Storage { /** Constructs StorageInfo based on JSON response from cloud. */ void infoInnerCallback(StorageInfoCallback outerCallback, Networking::JsonResponse json); - void printFiles(FileArrayResponse response); - void printBool(BoolResponse response); - void printStorageFile(UploadResponse response); - public: /** This constructor uses OAuth code flow to get tokens. */ DropboxStorage(Common::String code); @@ -105,11 +101,6 @@ public: * @return pointer to the newly created DropboxStorage or 0 if some problem occured. */ static DropboxStorage *loadFromConfig(Common::String keyPrefix); - - /** - * Returns Dropbox auth link. - */ - static Common::String getAuthLink(); }; } // End of namespace Dropbox diff --git a/backends/cloud/googledrive/googledrivestorage.cpp b/backends/cloud/googledrive/googledrivestorage.cpp index eeae2f2ee3..2816301cac 100644 --- a/backends/cloud/googledrive/googledrivestorage.cpp +++ b/backends/cloud/googledrive/googledrivestorage.cpp @@ -216,11 +216,6 @@ Networking::Request *GoogleDriveStorage::streamFileById(Common::String id, Netwo return nullptr; } -void GoogleDriveStorage::fileDownloaded(BoolResponse response) { - if (response.value) debug("file downloaded!"); - else debug("download failed!"); -} - void GoogleDriveStorage::printInfo(StorageInfoResponse response) { debug("\nuser info:"); debug("\tname: %s", response.value.name().c_str()); @@ -279,41 +274,9 @@ GoogleDriveStorage *GoogleDriveStorage::loadFromConfig(Common::String keyPrefix) return new GoogleDriveStorage(accessToken, refreshToken); } -Common::String GoogleDriveStorage::getAuthLink() { - Common::String url = "https://accounts.google.com/o/oauth2/auth"; - url += "?response_type=code"; - url += "&redirect_uri=http://localhost"; //that's for copy-pasting - //url += "&redirect_uri=http%3A%2F%2Flocalhost"; //that's "http://localhost" for automatic opening - url += "&client_id="; url += KEY; - url += "&scope=https://www.googleapis.com/auth/drive"; //for copy-pasting - return url; -} - Common::String GoogleDriveStorage::getRootDirectoryId() { return "root"; } - -void GoogleDriveStorage::authThroughConsole() { - if (!ConfMan.hasKey("GOOGLE_DRIVE_KEY", ConfMan.kCloudDomain) || !ConfMan.hasKey("GOOGLE_DRIVE_SECRET", ConfMan.kCloudDomain)) { - warning("No Google Drive keys available, cannot do auth"); - return; - } - - loadKeyAndSecret(); - - if (ConfMan.hasKey("googledrive_code", ConfMan.kCloudDomain)) { - //phase 2: get access_token using specified code - new GoogleDriveStorage(ConfMan.get("googledrive_code", ConfMan.kCloudDomain)); - return; - } - - debug("Navigate to this URL and press \"Allow\":"); - debug("%s\n", getAuthLink().c_str()); - debug("Then, add googledrive_code key in [cloud] section of configuration file. You should copy the <code> value from URL and put it as value for that key.\n"); - debug("Navigate to this URL to get more information on ScummVM's configuration files:"); - debug("http://wiki.scummvm.org/index.php/User_Manual/Configuring_ScummVM#Using_the_configuration_file_to_configure_ScummVM\n"); -} - } // End of namespace GoogleDrive } // End of namespace Cloud diff --git a/backends/cloud/googledrive/googledrivestorage.h b/backends/cloud/googledrive/googledrivestorage.h index 435f9998a3..4a7dbab99f 100644 --- a/backends/cloud/googledrive/googledrivestorage.h +++ b/backends/cloud/googledrive/googledrivestorage.h @@ -49,7 +49,6 @@ class GoogleDriveStorage: public Id::IdStorage { /** Returns bool based on JSON response from cloud. */ void createDirectoryInnerCallback(BoolCallback outerCallback, Networking::JsonResponse json); - void fileDownloaded(BoolResponse response); void printInfo(StorageInfoResponse response); public: /** This constructor uses OAuth code flow to get tokens. */ @@ -104,19 +103,9 @@ public: */ static GoogleDriveStorage *loadFromConfig(Common::String keyPrefix); - /** - * Returns GoogleDrive auth link. - */ - static Common::String getAuthLink(); - virtual Common::String getRootDirectoryId(); /** - * Show message with GoogleDrive auth instructions. (Temporary) - */ - static void authThroughConsole(); - - /** * Gets new access_token. If <code> passed is "", refresh_token is used. * Use "" in order to refresh token and pass a callback, so you could * continue your work when new token is available. diff --git a/backends/cloud/id/idstorage.cpp b/backends/cloud/id/idstorage.cpp index 3aeb5146cd..28f880522e 100644 --- a/backends/cloud/id/idstorage.cpp +++ b/backends/cloud/id/idstorage.cpp @@ -35,17 +35,6 @@ namespace Id { IdStorage::~IdStorage() {} -void IdStorage::printJson(Networking::JsonResponse response) { - Common::JSONValue *json = response.value; - if (!json) { - warning("printJson: NULL"); - return; - } - - debug("%s", json->stringify().c_str()); - delete json; -} - void IdStorage::printFiles(FileArrayResponse response) { debug("files:"); Common::Array<StorageFile> &files = response.value; diff --git a/backends/cloud/id/idstorage.h b/backends/cloud/id/idstorage.h index 88853e4ad8..ccadc0e455 100644 --- a/backends/cloud/id/idstorage.h +++ b/backends/cloud/id/idstorage.h @@ -45,7 +45,6 @@ namespace Id { class IdStorage: public Cloud::Storage { protected: - void printJson(Networking::JsonResponse response); void printFiles(FileArrayResponse response); void printBool(BoolResponse response); void printFile(UploadResponse response); diff --git a/backends/cloud/onedrive/onedrivestorage.cpp b/backends/cloud/onedrive/onedrivestorage.cpp index 0d2f91c3a8..3c8ea5fe81 100644 --- a/backends/cloud/onedrive/onedrivestorage.cpp +++ b/backends/cloud/onedrive/onedrivestorage.cpp @@ -174,17 +174,6 @@ void OneDriveStorage::infoInnerCallback(StorageInfoCallback outerCallback, Netwo delete json; } -void OneDriveStorage::printJson(Networking::JsonResponse response) { - Common::JSONValue *json = response.value; - if (!json) { - warning("printJson: NULL"); - return; - } - - debug("%s", json->stringify().c_str()); - delete json; -} - void OneDriveStorage::fileInfoCallback(Networking::NetworkReadStreamCallback outerCallback, Networking::JsonResponse response) { if (!response.value) { warning("fileInfoCallback: NULL"); @@ -224,29 +213,6 @@ Networking::Request *OneDriveStorage::streamFileById(Common::String path, Networ return addRequest(request); } -void OneDriveStorage::fileDownloaded(BoolResponse response) { - if (response.value) debug("file downloaded!"); - else debug("download failed!"); -} - -void OneDriveStorage::printFiles(FileArrayResponse response) { - debug("files:"); - Common::Array<StorageFile> &files = response.value; - for (uint32 i = 0; i < files.size(); ++i) - debug("\t%s", files[i].path().c_str()); -} - -void OneDriveStorage::printBool(BoolResponse response) { - debug("bool: %s", response.value ? "true" : "false"); -} - -void OneDriveStorage::printFile(UploadResponse response) { - debug("\nuploaded file info:"); - debug("\tpath: %s", response.value.path().c_str()); - debug("\tsize: %u", response.value.size()); - debug("\ttimestamp: %u", response.value.timestamp()); -} - Networking::Request *OneDriveStorage::createDirectory(Common::String path, BoolCallback callback, Networking::ErrorCallback errorCallback) { if (!errorCallback) errorCallback = getErrorPrintingCallback(); return addRequest(new OneDriveCreateDirectoryRequest(this, path, callback, errorCallback)); @@ -285,36 +251,5 @@ OneDriveStorage *OneDriveStorage::loadFromConfig(Common::String keyPrefix) { return new OneDriveStorage(accessToken, userId, refreshToken); } -Common::String OneDriveStorage::getAuthLink() { - Common::String url = "https://login.live.com/oauth20_authorize.srf"; - url += "?response_type=code"; - url += "&redirect_uri=http://localhost:12345/"; //that's for copy-pasting - //url += "&redirect_uri=http%3A%2F%2Flocalhost%3A12345%2F"; //that's "http://localhost:12345/" for automatic opening - url += "&client_id="; url += KEY; - url += "&scope=onedrive.appfolder%20offline_access"; //TODO - return url; -} - -void OneDriveStorage::authThroughConsole() { - if (!ConfMan.hasKey("ONEDRIVE_KEY", ConfMan.kCloudDomain) || !ConfMan.hasKey("ONEDRIVE_SECRET", ConfMan.kCloudDomain)) { - warning("No OneDrive keys available, cannot do auth"); - return; - } - - loadKeyAndSecret(); - - if (ConfMan.hasKey("onedrive_code", ConfMan.kCloudDomain)) { - //phase 2: get access_token using specified code - new OneDriveStorage(ConfMan.get("onedrive_code", ConfMan.kCloudDomain)); - return; - } - - debug("Navigate to this URL and press \"Allow\":"); - debug("%s\n", getAuthLink().c_str()); - debug("Then, add onedrive_code key in [cloud] section of configuration file. You should copy the <code> value from URL and put it as value for that key.\n"); - debug("Navigate to this URL to get more information on ScummVM's configuration files:"); - debug("http://wiki.scummvm.org/index.php/User_Manual/Configuring_ScummVM#Using_the_configuration_file_to_configure_ScummVM\n"); -} - } // End of namespace OneDrive } // End of namespace Cloud diff --git a/backends/cloud/onedrive/onedrivestorage.h b/backends/cloud/onedrive/onedrivestorage.h index 061d0fa172..650c240aef 100644 --- a/backends/cloud/onedrive/onedrivestorage.h +++ b/backends/cloud/onedrive/onedrivestorage.h @@ -24,7 +24,6 @@ #define BACKENDS_CLOUD_ONEDRIVE_ONEDRIVESTORAGE_H #include "backends/cloud/storage.h" -#include "common/callback.h" #include "backends/networking/curl/curljsonrequest.h" namespace Cloud { @@ -46,12 +45,6 @@ class OneDriveStorage: public Cloud::Storage { /** Constructs StorageInfo based on JSON response from cloud. */ void infoInnerCallback(StorageInfoCallback outerCallback, Networking::JsonResponse json); - void printJson(Networking::JsonResponse response); - void fileDownloaded(BoolResponse response); - void printFiles(FileArrayResponse response); - void printBool(BoolResponse response); - void printFile(UploadResponse response); - void fileInfoCallback(Networking::NetworkReadStreamCallback outerCallback, Networking::JsonResponse response); public: /** This constructor uses OAuth code flow to get tokens. */ @@ -89,9 +82,6 @@ public: virtual Networking::Request *streamFileById(Common::String path, Networking::NetworkReadStreamCallback callback, Networking::ErrorCallback errorCallback); /** Calls the callback when finished. */ - virtual Networking::Request *remove(Common::String path, BoolCallback callback, Networking::ErrorCallback errorCallback) { return nullptr; } //TODO - - /** Calls the callback when finished. */ virtual Networking::Request *createDirectory(Common::String path, BoolCallback callback, Networking::ErrorCallback errorCallback); /** Returns the StorageInfo struct. */ @@ -107,16 +97,6 @@ public: static OneDriveStorage *loadFromConfig(Common::String keyPrefix); /** - * Returns OneDrive auth link. - */ - static Common::String getAuthLink(); - - /** - * Show message with OneDrive auth instructions. (Temporary) - */ - static void authThroughConsole(); - - /** * Gets new access_token. If <code> passed is "", refresh_token is used. * Use "" in order to refresh token and pass a callback, so you could * continue your work when new token is available. diff --git a/backends/cloud/storage.h b/backends/cloud/storage.h index 273b93c764..414a722c64 100644 --- a/backends/cloud/storage.h +++ b/backends/cloud/storage.h @@ -141,9 +141,6 @@ public: virtual Networking::Request *downloadFolder(Common::String remotePath, Common::String localPath, FileArrayCallback callback, Networking::ErrorCallback errorCallback, bool recursive = false); /** Calls the callback when finished. */ - virtual Networking::Request *remove(Common::String path, BoolCallback callback, Networking::ErrorCallback errorCallback) = 0; - - /** Calls the callback when finished. */ virtual SavesSyncRequest *syncSaves(BoolCallback callback, Networking::ErrorCallback errorCallback); /** Calls the callback when finished. */ |