diff options
author | Alexander Tkachev | 2016-05-23 12:00:12 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | a439bd4c33e6f8a47a856d7cb4a4db7c540a85ab (patch) | |
tree | b812ec0ad55f425c7e79633efc39305486ee4508 /backends/cloud/dropbox | |
parent | 41e65db7d0468b01f626c6ce21a1b8e6791f58fa (diff) | |
download | scummvm-rg350-a439bd4c33e6f8a47a856d7cb4a4db7c540a85ab.tar.gz scummvm-rg350-a439bd4c33e6f8a47a856d7cb4a4db7c540a85ab.tar.bz2 scummvm-rg350-a439bd4c33e6f8a47a856d7cb4a4db7c540a85ab.zip |
CLOUD: Make StorageInfo useful
It now contains a few useful methods to get name or quota usage.
DropboxStorage returns a finely filled StorageInfo.
Diffstat (limited to 'backends/cloud/dropbox')
-rw-r--r-- | backends/cloud/dropbox/dropboxstorage.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/backends/cloud/dropbox/dropboxstorage.cpp b/backends/cloud/dropbox/dropboxstorage.cpp index d32d86567a..5a881211e3 100644 --- a/backends/cloud/dropbox/dropboxstorage.cpp +++ b/backends/cloud/dropbox/dropboxstorage.cpp @@ -101,10 +101,17 @@ void DropboxStorage::infoInnerCallback(StorageInfoCallback outerCallback, void * return; } - if (outerCallback) { - //TODO: check that JSON doesn't contain some error message instead of an actual response - //TODO: use JSON fields to construct StorageInfo - (*outerCallback)(StorageInfo(json->stringify())); + if (outerCallback) { + //Dropbox documentation states there is no errors for this API method + Common::JSONObject info = json->asObject(); + Common::String uid = Common::String::format("%d", info.getVal("uid")->asNumber()); + Common::String name = info.getVal("display_name")->asString(); + Common::String email = info.getVal("email")->asString(); + Common::JSONObject quota = info.getVal("quota_info")->asObject(); + uint32 quotaNormal = quota.getVal("normal")->asNumber(); + uint32 quotaShared = quota.getVal("shared")->asNumber(); + uint32 quotaAllocated = quota.getVal("quota")->asNumber(); + (*outerCallback)(StorageInfo(uid, name, email, quotaNormal+quotaShared, quotaAllocated)); delete outerCallback; } @@ -112,7 +119,10 @@ void DropboxStorage::infoInnerCallback(StorageInfoCallback outerCallback, void * } void DropboxStorage::infoMethodCallback(StorageInfo storageInfo) { - debug("info: %s", storageInfo.info().c_str()); + debug("\nStorage info:"); + debug("User name: %s", storageInfo.name().c_str()); + debug("Email: %s", storageInfo.email().c_str()); + debug("Disk usage: %u/%u", storageInfo.used(), storageInfo.available()); } DropboxStorage *DropboxStorage::loadFromConfig(Common::String keyPrefix) { |