Config added for the cloud comunication
[apps/native/gear-racing-car.git] / src / cloud / cloud_lap_request.c
index 54ca712..524c2f3 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_LAP "/api/lap"
+#define CONFIG_LAP_API_KEY "lap"
 
 typedef struct {
        char *ap_mac;
@@ -130,7 +131,13 @@ static void lap_api_post_task_thread_cb(GTask *task, gpointer source_object, gpo
        lap_api_post_request_response_t *response = g_new0(lap_api_post_request_response_t, 1);
 
        char *json = lap_info_serializer_serialize(context->lap);
-       int retval = http_request_post(BASE_URL""PATH_API_LAP, json, &(response->response_msg), &(response->response_code));
+
+       char *url = http_request_get_url(PATH_API_LAP, CONFIG_LAP_API_KEY);
+
+       int retval = http_request_post(url, json, &(response->response_msg), &(response->response_code));
+
+       _D("URL FROM CONFIG (LAP POST): %s", url);
+       free(url);
        g_free(json);
 
        if (retval != 0) {
@@ -197,10 +204,15 @@ static void lap_api_get_task_thread_cb(GTask *task, gpointer source_object, gpoi
 
        lap_api_get_request_response_t *response = g_new0(lap_api_get_request_response_t, 1);
        char *response_json = NULL;
+       char *url_with_api = http_request_get_url(PATH_API_LAP, CONFIG_LAP_API_KEY);
 
-       GString *url = g_string_new(BASE_URL""PATH_API_LAP"?apMac=");
+       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 (LAP GET): %s", url);
+
        int retval = http_request_get(url->str, &response_json, &(response->response_code));
        g_string_free(url, TRUE);