diff options
author | Alexander Tkachev | 2016-06-09 18:49:17 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | e6242b0be8fc9f9abc4daf87f80675cca46df4d9 (patch) | |
tree | 9f775a11ed08c242d926c1135079e8f4ebcc05b9 /backends/cloud/googledrive | |
parent | beb168a3a5bac602a9bf1455e7fe93dda0b13a1c (diff) | |
download | scummvm-rg350-e6242b0be8fc9f9abc4daf87f80675cca46df4d9.tar.gz scummvm-rg350-e6242b0be8fc9f9abc4daf87f80675cca46df4d9.tar.bz2 scummvm-rg350-e6242b0be8fc9f9abc4daf87f80675cca46df4d9.zip |
GUI: Add Refresh button in Options Cloud tab
Commit changes CloudManager and Storages so they would automatically
refresh the fields when the could.
Diffstat (limited to 'backends/cloud/googledrive')
-rw-r--r-- | backends/cloud/googledrive/googledrivestorage.cpp | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/backends/cloud/googledrive/googledrivestorage.cpp b/backends/cloud/googledrive/googledrivestorage.cpp index 143b7ac52c..3196cbe041 100644 --- a/backends/cloud/googledrive/googledrivestorage.cpp +++ b/backends/cloud/googledrive/googledrivestorage.cpp @@ -156,33 +156,32 @@ void GoogleDriveStorage::infoInnerCallback(StorageInfoCallback outerCallback, Ne return; } - if (outerCallback) { - Common::JSONObject info = json->asObject(); - - Common::String uid, name, email; - uint64 quotaUsed = 0, quotaAllocated = 0; - - if (info.contains("user") && info.getVal("user")->isObject()) { - //"me":true, "kind":"drive#user","photoLink": "", - //"displayName":"Alexander Tkachev","emailAddress":"alexander@tkachov.ru","permissionId":"" - Common::JSONObject user = info.getVal("user")->asObject(); - uid = user.getVal("permissionId")->asString(); //not sure it's user's id, but who cares anyway? - name = user.getVal("displayName")->asString(); - email = user.getVal("emailAddress")->asString(); - } - - if (info.contains("storageQuota") && info.getVal("storageQuota")->isObject()) { - //"usageInDrive":"6332462","limit":"18253611008","usage":"6332462","usageInDriveTrash":"0" - Common::JSONObject storageQuota = info.getVal("storageQuota")->asObject(); - Common::String usage = storageQuota.getVal("usage")->asString(); - Common::String limit = storageQuota.getVal("limit")->asString(); - quotaUsed = atoull(usage); - quotaAllocated = atoull(limit); - } + Common::JSONObject info = json->asObject(); + + Common::String uid, name, email; + uint64 quotaUsed = 0, quotaAllocated = 0; + + if (info.contains("user") && info.getVal("user")->isObject()) { + //"me":true, "kind":"drive#user","photoLink": "", + //"displayName":"Alexander Tkachev","emailAddress":"alexander@tkachov.ru","permissionId":"" + Common::JSONObject user = info.getVal("user")->asObject(); + uid = user.getVal("permissionId")->asString(); //not sure it's user's id, but who cares anyway? + name = user.getVal("displayName")->asString(); + email = user.getVal("emailAddress")->asString(); + } - CloudMan.setStorageUsedSpace(kStorageGoogleDriveId, quotaUsed); //TODO that's not ScummVM's actually - CloudMan.setStorageUsername(kStorageGoogleDriveId, email); + if (info.contains("storageQuota") && info.getVal("storageQuota")->isObject()) { + //"usageInDrive":"6332462","limit":"18253611008","usage":"6332462","usageInDriveTrash":"0" + Common::JSONObject storageQuota = info.getVal("storageQuota")->asObject(); + Common::String usage = storageQuota.getVal("usage")->asString(); + Common::String limit = storageQuota.getVal("limit")->asString(); + quotaUsed = atoull(usage); + quotaAllocated = atoull(limit); + } + + CloudMan.setStorageUsername(kStorageGoogleDriveId, email); + if (outerCallback) { (*outerCallback)(StorageInfoResponse(nullptr, StorageInfo(uid, name, email, quotaUsed, quotaAllocated))); delete outerCallback; } |