Config added for the cloud comunication
[apps/native/gear-racing-car.git] / src / cloud / cloud_request.c
index 90777d1..243b78f 100644 (file)
 #include <glib.h>
 #include <gio/gio.h>
 #include <string.h>
+#include <stdlib.h>
 #include "log.h"
 
-#define BASE_URL "http://son.tizen.online"
 #define PATH_API_RACING "/api/racing"
+#define CONFIG_CAR_API_KEY "car"
 
 typedef struct {
     char *ap_mac;
@@ -135,9 +136,15 @@ static void car_api_post_task_thread_cb(GTask *task, gpointer source_object, gpo
     car_api_post_request_response_t *response = g_new0(car_api_post_request_response_t, 1);
 
     char *json = car_info_serializer_serialize(context->car);
-    int retval = http_request_post(BASE_URL""PATH_API_RACING, json, &(response->response_msg), &(response->response_code));
+
+    char *url = http_request_get_url(PATH_API_RACING, CONFIG_CAR_API_KEY);
+
+    int retval = http_request_post(url, json, &(response->response_msg), &(response->response_code));
     g_free(json);
 
+    _D("URL FROM CONFIG (RACING POST): %s", url);
+    free(url);
+
     if (retval != 0) {
         GError *err = g_error_new(G_ERROR_DOMAIN, retval, "http_request_post failed!");
         g_task_return_error(task, err);
@@ -203,9 +210,15 @@ static void car_api_get_task_thread_cb(GTask *task, gpointer source_object, gpoi
     car_api_get_request_response_t *response = g_new0(car_api_get_request_response_t, 1);
     char *response_json = NULL;
 
-    GString *url = g_string_new(BASE_URL""PATH_API_RACING"?apMac=");
+    char *url_with_api = http_request_get_url(PATH_API_RACING, CONFIG_CAR_API_KEY);
+
+    GString *url = g_string_new(url_with_api);
+    g_string_append(url, "?apMac=");
     g_string_append(url, context->ap_mac);
 
+    free(url_with_api);
+    _D("URL FROM CONFIG (RACING GET): %s", url);
+
     int retval = http_request_get(url->str, &response_json, &(response->response_code));
     g_string_free(url, TRUE);