Expose `get_proxy_address` to tangram_view 35/86535/1
authorVarun <tallytalwar@gmail.com>
Tue, 30 Aug 2016 20:31:54 +0000 (16:31 -0400)
committerVarun <tallytalwar@gmail.com>
Thu, 1 Sep 2016 21:56:01 +0000 (17:56 -0400)
- Gets the proxy address, and passes down to tangram curl handler for handling proxy addressed when fetching network
tiles

Change-Id: Ib972edd2df4f9f4d399009304b2ba1bea910fd56

lib/arm/libtangram.so
lib/i586/libtangram.so
src/mapzen/mapzen_api.cpp
src/mapzen/mapzen_restcurl.c
src/mapzen/mapzen_restcurl.h
src/mapzen/tangram/platform_tizen.h
src/mapzen/tangram_view.cpp
src/mapzen/tangram_view.hpp

index 5db23fe..3dd3742 100755 (executable)
Binary files a/lib/arm/libtangram.so and b/lib/arm/libtangram.so differ
index 70c1f55..f4ba918 100755 (executable)
Binary files a/lib/i586/libtangram.so and b/lib/i586/libtangram.so differ
index 1fe706f..7b6c594 100644 (file)
@@ -28,6 +28,7 @@ extern "C" {
 
 int mapzen_init()
 {
+       TangramView::initNetworkRequests();
        int ret = mapzen_init_queue();
 
        return ret;
@@ -35,6 +36,7 @@ int mapzen_init()
 
 int mapzen_shutdown()
 {
+       TangramView::deinitNetworkRequests();
        int ret = mapzen_deinit_queue();
 
        return ret;
index f69b708..87d8546 100644 (file)
@@ -156,18 +156,19 @@ static struct MultiCurlArg_List *__delete_from_list(CURL *handle)
 
 /*****************************************/
 
-mapzen_error_e __get_proxy_address()
+mapzen_error_e get_proxy_address(char **proxyAddress)
 {
+       *proxyAddress = NULL;
+
        mapzen_error_e err = MAPZEN_ERROR_NONE;
 
        connection_h con = NULL;
        int errorCode = CONNECTION_ERROR_NOT_SUPPORTED;
-       char *address = NULL;
 
        errorCode = connection_create(&con);
 
        if (errorCode == CONNECTION_ERROR_NONE)
-               errorCode = connection_get_proxy(con, CONNECTION_ADDRESS_FAMILY_IPV4, &address);
+               errorCode = connection_get_proxy(con, CONNECTION_ADDRESS_FAMILY_IPV4, proxyAddress);
 
        if (errorCode != CONNECTION_ERROR_NONE) {
                err = MAPZEN_ERROR_UNKNOWN;
@@ -244,18 +245,7 @@ mapzen_error_e __get_proxy_address()
        if (err != MAPZEN_ERROR_NONE)
                return err;
 
-       if (address) {
-               int len = strlen(address);
-               if (len > 0) {
-                       __proxy_address = (char *)g_malloc0(len+1);
-                       strncpy(__proxy_address, address, len);
-                       __proxy_address[len] = '\0';
-               }
-               g_free(address);
-               address = NULL;
-       }
-
-       MAP_DEBUG("Proxy = %s", (__proxy_address ? __proxy_address : "(null)"));
+       MAP_DEBUG("Proxy = %s", (*proxyAddress ? *proxyAddress : "(null)"));
 
        return MAPZEN_ERROR_NONE;
 }
@@ -382,7 +372,7 @@ int add_handle(const char *url, mapzen_req_type type, void *user_data)
 
        curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L);
 
-       curl_easy_setopt(curl_handle, CURLOPT_PROXY , __proxy_address);
+       curl_easy_setopt(curl_handle, CURLOPT_PROXY, __proxy_address);
 
        /* send all data to this function  */
        curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, __write_memory_callback);
@@ -545,7 +535,7 @@ int init_curl()
        head = NULL;
        curr = NULL;
 
-       __get_proxy_address();
+       get_proxy_address(&__proxy_address);
 
 #ifdef RESTCURL_USE_MULTI_CURL
        pthread_mutex_init(&__MultiCurlArgsLock, NULL);
index fd7e343..2f0ac62 100644 (file)
@@ -25,6 +25,8 @@ int init_curl();
 
 int deinit_curl();
 
+mapzen_error_e get_proxy_address(char** proxyAddress);
+
 int get_num_running_requests();
 
 int add_handle(const char *url, mapzen_req_type type, void *user_data);
index b70d781..f286cc4 100644 (file)
@@ -8,6 +8,7 @@ bool shouldRender();
 
 void setRenderCallbackFunction(std::function<void()> callback);
 
-void finishUrlRequests();
-void initUrlRequests();
+void initUrlRequests(const char* proxyAddress);
+void stopUrlRequests();
+
 void setEvasGlAPI(Evas_GL_API* glApi);
index 9e1d65e..4a93929 100644 (file)
@@ -18,6 +18,7 @@ extern "C" {
 #include "mapzen_queue.h"
 #include "mapzen_debug.h"
 #include "mapzen_util.h"
+#include "mapzen_restcurl.h"
 }
 
 #include "mapzen_plugin_internal.h"
@@ -28,6 +29,7 @@ extern "C" {
 #define NORMAL_SCENE_FILE_PATH "/usr/share/maps/mapzen/scenes/bubble-wrap/bubble-wrap.yaml"
 #define TERRAIN_SCENE_FILE_PATH "/usr/share/maps/mapzen/scenes/walkabout-style/walkabout-style.yaml"
 
+
 TangramView::TangramView()
 {
        // Nothing to do.
@@ -38,6 +40,19 @@ TangramView::~TangramView()
        // Nothing to do.
 }
 
+void TangramView::initNetworkRequests() {
+       char* proxyAddress = NULL;
+       get_proxy_address(&proxyAddress);
+
+       initUrlRequests(proxyAddress);
+
+       g_free(proxyAddress);
+}
+
+void TangramView::deinitNetworkRequests() {
+       stopUrlRequests();
+}
+
 mapzen_error_e TangramView::create(maps_view_h view, maps_plugin_map_view_ready_cb callback)
 {
        if (!view) {
@@ -101,8 +116,6 @@ mapzen_error_e TangramView::create(maps_view_h view, maps_plugin_map_view_ready_
        // TODO: What to do for multiple instances
        setEvasGlAPI(m_api);
 
-       initUrlRequests();
-
        // Set up the tangram map.
        m_map = new Tangram::Map();
        m_map->loadScene(NORMAL_SCENE_FILE_PATH);
@@ -197,6 +210,7 @@ mapzen_error_e TangramView::destroy(maps_view_h view)
                m_map = nullptr;
        }
 
+
        return MAPZEN_ERROR_NONE;
 }
 
index 424ec21..3dab34c 100644 (file)
@@ -49,6 +49,9 @@ public:
        mapzen_error_e onViewObject(maps_view_h view, const maps_view_object_h object, maps_view_object_operation_e operation);
        mapzen_error_e captureSnapshot(maps_view_h view, void **data, int *width, int *height, maps_view_colorspace_type_e *cs);
 
+       static void initNetworkRequests();
+       static void deinitNetworkRequests();
+
 private:
        mapzen_error_e setupOpenGlSurface(maps_view_h view);
        void setMapType(maps_view_h view);