#include "mods.h"
#include "config.h"
#include "log.h"
+#include "main.h" // for g_settings
+#include "settings.h"
#if USE_CURL
#include <curl/curl.h>
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &liststring);
+ curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, g_settings->getS32("curl_timeout"));
+ curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, g_settings->getS32("curl_timeout"));
if (chunk != 0)
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
-
res = curl_easy_perform(curl);
if (res != CURLE_OK)
errorstream<<"Jsonreader: "<< url <<" not found (" << curl_easy_strerror(res) << ")" <<std::endl;
}
}
else {
+ errorstream << "readModStoreList: missing id" << std::endl;
toadd.valid = false;
}
toadd.title = modlist[i]["title"].asString();
}
else {
+ errorstream << "readModStoreList: missing title" << std::endl;
toadd.valid = false;
}
toadd.basename = modlist[i]["basename"].asString();
}
else {
+ errorstream << "readModStoreList: missing basename" << std::endl;
toadd.valid = false;
}
}
}
else {
+ errorstream << "readModStoreModDetails: missing version_set id" << std::endl;
retval.valid = false;
}
toadd.file = details["version_set"][i]["file"].asString();
}
else {
+ errorstream << "readModStoreModDetails: missing version_set file" << std::endl;
retval.valid = false;
}
}
if (retval.versions.size() < 1) {
+ errorstream << "readModStoreModDetails: not a single version specified!" << std::endl;
retval.valid = false;
}
}
}
else {
+ errorstream << "readModStoreModDetails: missing categories id" << std::endl;
retval.valid = false;
}
if (details["categories"][i]["title"].asString().size()) {
toadd.name = details["categories"][i]["title"].asString();
}
else {
+ errorstream << "readModStoreModDetails: missing categories title" << std::endl;
retval.valid = false;
}
retval.author.id = numbervalue;
}
else {
+ errorstream << "readModStoreModDetails: missing author id (convert)" << std::endl;
retval.valid = false;
}
}
else {
+ errorstream << "readModStoreModDetails: missing author id" << std::endl;
retval.valid = false;
}
retval.author.username = details["author"]["username"].asString();
}
else {
+ errorstream << "readModStoreModDetails: missing author username" << std::endl;
retval.valid = false;
}
}
else {
+ errorstream << "readModStoreModDetails: missing author" << std::endl;
retval.valid = false;
}
}
}
else {
+ errorstream << "readModStoreModDetails: missing license id" << std::endl;
retval.valid = false;
}
retval.license.shortinfo = details["license"]["short"].asString();
}
else {
+ errorstream << "readModStoreModDetails: missing license short" << std::endl;
retval.valid = false;
}
}
+ //titlepic
+ if (details["titlepic"].isObject()) {
+ if (details["titlepic"]["id"].asString().size()) {
+
+ const char* id_raw = details["titlepic"]["id"].asString().c_str();
+ char* endptr = 0;
+ int numbervalue = strtol(id_raw,&endptr,10);
+
+ if ((*id_raw != 0) && (*endptr == 0)) {
+ retval.titlepic.id = numbervalue;
+ }
+ }
+
+ if (details["titlepic"]["file"].asString().size()) {
+ retval.titlepic.file = details["titlepic"]["file"].asString();
+ }
+
+ if (details["titlepic"]["desc"].asString().size()) {
+ retval.titlepic.description = details["titlepic"]["desc"].asString();
+ }
+
+ if (details["titlepic"]["mod"].asString().size()) {
+
+ const char* mod_raw = details["titlepic"]["mod"].asString().c_str();
+ char* endptr = 0;
+ int numbervalue = strtol(mod_raw,&endptr,10);
+
+ if ((*mod_raw != 0) && (*endptr == 0)) {
+ retval.titlepic.mod = numbervalue;
+ }
+ }
+ }
+
//id
if (details["id"].asString().size()) {
}
}
else {
+ errorstream << "readModStoreModDetails: missing id" << std::endl;
retval.valid = false;
}
retval.title = details["title"].asString();
}
else {
+ errorstream << "readModStoreModDetails: missing title" << std::endl;
retval.valid = false;
}
retval.basename = details["basename"].asString();
}
else {
+ errorstream << "readModStoreModDetails: missing basename" << std::endl;
retval.valid = false;
}