[TBT][tizen_3.0_wearable][push][Fixed for curl proxy setting] 41/92941/2
authorYounho Park <younho.park@samsung.com>
Wed, 19 Oct 2016 12:00:37 +0000 (21:00 +0900)
committerYounho Park <younho.park@samsung.com>
Wed, 19 Oct 2016 12:01:54 +0000 (21:01 +0900)
Change-Id: Ica48f7ef3e088c1a0dc581bcbf52b21b369eb48b
Signed-off-by: Younho Park <younho.park@samsung.com>
tbtcoreapp/src/view/tbt-push-view.c

index 2b19055c521ec905d12cc64ef562681440ff8934..19ba02d1b9d81f674f55f9eaa091ceb0a1855d23 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <Elementary.h>
 #include <locations.h>
+#include <net_connection.h>
 
 #include "utils/logger.h"
 #include "utils/config.h"
@@ -444,6 +445,10 @@ static void send_push_data_to_server(void* user_data)
 {
        DBG("Inside send_push_data_to_server");
 
+       connection_h connection;
+       char *proxy_address = NULL;
+       int ret = 0;
+
        push_view *this = NULL;
        this = (push_view*)user_data;
        RETM_IF(NULL == this, "view is NULL");
@@ -489,12 +494,39 @@ static void send_push_data_to_server(void* user_data)
        char* server = push_service_get_server_address(this->reg_id);
        DBG("Server Address: %s", server);
 
-       curl_err = curl_easy_setopt(this->curl_handle, CURLOPT_URL, push_service_get_server_address(this->reg_id));
+       curl_err = curl_easy_setopt(this->curl_handle, CURLOPT_URL, server);
        RETM_IF(curl_err != CURLE_OK, "curl_easy_setopt - Adding CURLOPT_URL Failed %d", curl_err);
 
        curl_easy_setopt(this->curl_handle, CURLOPT_SSL_VERIFYPEER, 0L);
        curl_easy_setopt(this->curl_handle, CURLOPT_WRITEFUNCTION, _curl_response_cb);
        curl_easy_setopt(this->curl_handle, CURLOPT_WRITEDATA, user_data);
+       curl_easy_setopt(this->curl_handle, CURLOPT_CONNECTTIMEOUT_MS, 15000);
+       curl_easy_setopt(this->curl_handle, CURLOPT_PROXYPORT, 8090);
+
+       ret = connection_create(&connection);
+       if (CONNECTION_ERROR_NONE != ret) {
+               DBG("fail to create conn_handle[%d]", ret);
+               return;
+       }
+
+       ret = connection_get_proxy(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &proxy_address);
+       if (ret != CONNECTION_ERROR_NONE) {
+               DBG("Fail to get proxy[%d]", ret);
+               if (proxy_address) {
+                       free(proxy_address);
+                       proxy_address = NULL;
+               }
+       } else {
+               if (proxy_address != NULL && strlen(proxy_address) != 0) {
+                       DBG("Proxy Address : [%s]", proxy_address);
+                       curl_easy_setopt(this->curl_handle, CURLOPT_PROXY, proxy_address);
+               }
+       }
+
+       if (connection) {
+                connection_destroy(connection);
+                connection = NULL;
+       }
 
        // lets send curl http request
        curl_err = curl_easy_perform(this->curl_handle);
@@ -528,25 +560,25 @@ static char* push_service_get_server_address(char* reg_id)
        // Determine RQM server
        if (strncmp(reg_id, "00", 2) == 0) {
                server_address =
-                               "https://useast.push.samsungosp.com:8088/spp/pns/api/push";
+                               "https://useast.push.samsungosp.com:8090/spp/pns/api/push";
        } else if (strncmp(reg_id, "01", 2) == 0) {
                server_address =
-                               "https://uswest.push.samsungosp.com:8088/spp/pns/api/push";
+                               "https://uswest.push.samsungosp.com:8090/spp/pns/api/push";
        } else if (strncmp(reg_id, "02", 2) == 0) {
                server_address =
-                               "https://apsoutheast.push.samsungosp.com:8088/spp/pns/api/push";
+                               "https://apsoutheast.push.samsungosp.com:8090/spp/pns/api/push";
        } else if (strncmp(reg_id, "03", 2) == 0) {
                server_address =
-                               "https://euwest.push.samsungosp.com:8088/spp/pns/api/push";
+                               "https://euwest.push.samsungosp.com:8090/spp/pns/api/push";
        } else if (strncmp(reg_id, "04", 2) == 0) {
                server_address =
-                               "https://apnortheast.push.samsungosp.com:8088/spp/pns/api/push";
+                               "https://apnortheast.push.samsungosp.com:8090/spp/pns/api/push";
        } else if (strncmp(reg_id, "05", 2) == 0) {
                server_address =
-                               "https://apkorea.push.samsungosp.com:8088/spp/pns/api/push";
+                               "https://apkorea.push.samsungosp.com:8090/spp/pns/api/push";
        } else if (strncmp(reg_id, "06", 2) == 0) {
                server_address =
-                               "https://apchina.push.samsungosp.com.cn:8088/spp/pns/api/push";
+                               "https://apchina.push.samsungosp.com.cn:8090/spp/pns/api/push";
        } else {
                DBG("REG_ID has a wrong prefix");
        }