| @@ -1 +1 @@ | |||||
| Subproject commit d9ab59efc781c392128a449361a381fcc93cf6f3 | |||||
| Subproject commit 7ba23eb03854dfe6ce36cc6d61cb913f76cad774 | |||||
| @@ -1 +1 @@ | |||||
| Subproject commit 25241c5a8f8451d41ab1b02ab2d865b01600d949 | |||||
| Subproject commit c1f6e209c16b18b46aa9f45d7e619acf42c29726 | |||||
| @@ -1 +1 @@ | |||||
| Subproject commit 1f9c8864fc556a1be4d4bf1d6bfe20cde25734b4 | |||||
| Subproject commit f4069e6a1ad5da430fb0a9c57476d5ddc2ff89b2 | |||||
| @@ -1 +1 @@ | |||||
| Subproject commit d27f257b4bc827e4152cdc4d69a2e22084204afd | |||||
| Subproject commit b9468aa6f82fdea1f3dc364f477e859b39f0bb2a | |||||
| @@ -12,10 +12,10 @@ namespace network { | |||||
| enum Method { | enum Method { | ||||
| GET, | |||||
| POST, | |||||
| PUT, | |||||
| DELETE, | |||||
| METHOD_GET, | |||||
| METHOD_POST, | |||||
| METHOD_PUT, | |||||
| METHOD_DELETE, | |||||
| }; | }; | ||||
| /** Requests a JSON API URL over HTTP(S), using the data as the query (GET) or the body (POST, etc) | /** Requests a JSON API URL over HTTP(S), using the data as the query (GET) or the body (POST, etc) | ||||
| @@ -170,7 +170,7 @@ void Scene::onPathDrop(const event::PathDrop &e) { | |||||
| void Scene::runCheckVersion() { | void Scene::runCheckVersion() { | ||||
| std::string versionUrl = app::API_URL; | std::string versionUrl = app::API_URL; | ||||
| versionUrl += "/version"; | versionUrl += "/version"; | ||||
| json_t *versionResJ = network::requestJson(network::GET, versionUrl, NULL); | |||||
| json_t *versionResJ = network::requestJson(network::METHOD_GET, versionUrl, NULL); | |||||
| if (versionResJ) { | if (versionResJ) { | ||||
| json_t *versionJ = json_object_get(versionResJ, "version"); | json_t *versionJ = json_object_get(versionResJ, "version"); | ||||
| @@ -24,7 +24,7 @@ json_t *requestJson(Method method, std::string url, json_t *dataJ) { | |||||
| // Process data | // Process data | ||||
| if (dataJ) { | if (dataJ) { | ||||
| if (method == GET) { | |||||
| if (method == METHOD_GET) { | |||||
| // Append ?key=value&... to url | // Append ?key=value&... to url | ||||
| url += "?"; | url += "?"; | ||||
| bool isFirst = true; | bool isFirst = true; | ||||
| @@ -54,16 +54,16 @@ json_t *requestJson(Method method, std::string url, json_t *dataJ) { | |||||
| // Set HTTP method | // Set HTTP method | ||||
| switch (method) { | switch (method) { | ||||
| case GET: | |||||
| case METHOD_GET: | |||||
| // This is CURL's default | // This is CURL's default | ||||
| break; | break; | ||||
| case POST: | |||||
| case METHOD_POST: | |||||
| curl_easy_setopt(curl, CURLOPT_POST, true); | curl_easy_setopt(curl, CURLOPT_POST, true); | ||||
| break; | break; | ||||
| case PUT: | |||||
| case METHOD_PUT: | |||||
| curl_easy_setopt(curl, CURLOPT_PUT, true); | curl_easy_setopt(curl, CURLOPT_PUT, true); | ||||
| break; | break; | ||||
| case DELETE: | |||||
| case METHOD_DELETE: | |||||
| curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE"); | curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE"); | ||||
| break; | break; | ||||
| } | } | ||||
| @@ -351,7 +351,7 @@ void logIn(const std::string &email, const std::string &password) { | |||||
| json_object_set(reqJ, "password", json_string(password.c_str())); | json_object_set(reqJ, "password", json_string(password.c_str())); | ||||
| std::string url = app::API_URL; | std::string url = app::API_URL; | ||||
| url += "/token"; | url += "/token"; | ||||
| json_t *resJ = network::requestJson(network::POST, url, reqJ); | |||||
| json_t *resJ = network::requestJson(network::METHOD_POST, url, reqJ); | |||||
| json_decref(reqJ); | json_decref(reqJ); | ||||
| if (!resJ) { | if (!resJ) { | ||||
| @@ -392,7 +392,7 @@ void queryUpdates() { | |||||
| json_object_set(pluginsReqJ, "token", json_string(settings::token.c_str())); | json_object_set(pluginsReqJ, "token", json_string(settings::token.c_str())); | ||||
| std::string pluginsUrl = app::API_URL; | std::string pluginsUrl = app::API_URL; | ||||
| pluginsUrl += "/plugins"; | pluginsUrl += "/plugins"; | ||||
| json_t *pluginsResJ = network::requestJson(network::GET, pluginsUrl, pluginsReqJ); | |||||
| json_t *pluginsResJ = network::requestJson(network::METHOD_GET, pluginsUrl, pluginsReqJ); | |||||
| json_decref(pluginsReqJ); | json_decref(pluginsReqJ); | ||||
| if (!pluginsResJ) { | if (!pluginsResJ) { | ||||
| WARN("Request for user's plugins failed"); | WARN("Request for user's plugins failed"); | ||||
| @@ -411,7 +411,7 @@ void queryUpdates() { | |||||
| // Get community manifests | // Get community manifests | ||||
| std::string manifestsUrl = app::API_URL; | std::string manifestsUrl = app::API_URL; | ||||
| manifestsUrl += "/community/manifests"; | manifestsUrl += "/community/manifests"; | ||||
| json_t *manifestsResJ = network::requestJson(network::GET, manifestsUrl, NULL); | |||||
| json_t *manifestsResJ = network::requestJson(network::METHOD_GET, manifestsUrl, NULL); | |||||
| if (!manifestsResJ) { | if (!manifestsResJ) { | ||||
| WARN("Request for community manifests failed"); | WARN("Request for community manifests failed"); | ||||
| return; | return; | ||||