aboutsummaryrefslogtreecommitdiff
path: root/backends/networking
diff options
context:
space:
mode:
authorAlexander Tkachev2016-07-26 14:53:44 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commitfc8e29d5832728a513cab0f10be218c6a632758a (patch)
treee581a31eaadd1dc40c4db9c49e58e471e18768aa /backends/networking
parentd34b9b91add07c8bed2d2cef6421fc1b93b2e09e (diff)
downloadscummvm-rg350-fc8e29d5832728a513cab0f10be218c6a632758a.tar.gz
scummvm-rg350-fc8e29d5832728a513cab0f10be218c6a632758a.tar.bz2
scummvm-rg350-fc8e29d5832728a513cab0f10be218c6a632758a.zip
CLOUD: Update OneDrive
Added JSON checks. New jsonContainsObject() method added to CurlJsonRequest.
Diffstat (limited to 'backends/networking')
-rw-r--r--backends/networking/curl/curljsonrequest.cpp17
-rw-r--r--backends/networking/curl/curljsonrequest.h1
2 files changed, 18 insertions, 0 deletions
diff --git a/backends/networking/curl/curljsonrequest.cpp b/backends/networking/curl/curljsonrequest.cpp
index aac89a1513..6ff35d7b3d 100644
--- a/backends/networking/curl/curljsonrequest.cpp
+++ b/backends/networking/curl/curljsonrequest.cpp
@@ -114,6 +114,23 @@ bool CurlJsonRequest::jsonIsObject(Common::JSONValue *item, const char *warningP
return false;
}
+bool CurlJsonRequest::jsonContainsObject(Common::JSONObject &item, const char *key, const char *warningPrefix, bool isOptional) {
+ if (!item.contains(key)) {
+ if (isOptional) {
+ return true;
+ }
+
+ warning("%s: passed item misses the \"%s\" attribute!", warningPrefix, key);
+ return false;
+ }
+
+ if (item.getVal(key)->isObject()) return true;
+
+ warning("%s: passed item's \"%s\" attribute is not an object!", warningPrefix, key);
+ debug(9, "%s", item.getVal(key)->stringify(true).c_str());
+ return false;
+}
+
bool CurlJsonRequest::jsonContainsString(Common::JSONObject &item, const char *key, const char *warningPrefix, bool isOptional) {
if (!item.contains(key)) {
if (isOptional) {
diff --git a/backends/networking/curl/curljsonrequest.h b/backends/networking/curl/curljsonrequest.h
index cab75bf4bc..edd523015a 100644
--- a/backends/networking/curl/curljsonrequest.h
+++ b/backends/networking/curl/curljsonrequest.h
@@ -54,6 +54,7 @@ public:
virtual void restart();
static bool jsonIsObject(Common::JSONValue *item, const char *warningPrefix);
+ static bool jsonContainsObject(Common::JSONObject &item, const char *key, const char *warningPrefix, bool isOptional = false);
static bool jsonContainsString(Common::JSONObject &item, const char *key, const char *warningPrefix, bool isOptional = false);
static bool jsonContainsIntegerNumber(Common::JSONObject &item, const char *key, const char *warningPrefix, bool isOptional = false);
static bool jsonContainsArray(Common::JSONObject &item, const char *key, const char *warningPrefix, bool isOptional = false);