From: Varun Date: Tue, 30 Aug 2016 20:31:54 +0000 (-0400) Subject: Expose `get_proxy_address` to tangram_view X-Git-Tag: submit/tizen_3.0/20161108.012559~33 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=09aadaa4c0f33427e9f032b9a6bd6dd3b20041f2;p=platform%2Fcore%2Flocation%2Fmaps-plugin-mapzen.git Expose `get_proxy_address` to tangram_view - Gets the proxy address, and passes down to tangram curl handler for handling proxy addressed when fetching network tiles Change-Id: Ib972edd2df4f9f4d399009304b2ba1bea910fd56 --- diff --git a/lib/arm/libtangram.so b/lib/arm/libtangram.so index 5db23fe..3dd3742 100755 Binary files a/lib/arm/libtangram.so and b/lib/arm/libtangram.so differ diff --git a/lib/i586/libtangram.so b/lib/i586/libtangram.so index 70c1f55..f4ba918 100755 Binary files a/lib/i586/libtangram.so and b/lib/i586/libtangram.so differ diff --git a/src/mapzen/mapzen_api.cpp b/src/mapzen/mapzen_api.cpp index 1fe706f..7b6c594 100644 --- a/src/mapzen/mapzen_api.cpp +++ b/src/mapzen/mapzen_api.cpp @@ -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; diff --git a/src/mapzen/mapzen_restcurl.c b/src/mapzen/mapzen_restcurl.c index f69b708..87d8546 100644 --- a/src/mapzen/mapzen_restcurl.c +++ b/src/mapzen/mapzen_restcurl.c @@ -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); diff --git a/src/mapzen/mapzen_restcurl.h b/src/mapzen/mapzen_restcurl.h index fd7e343..2f0ac62 100644 --- a/src/mapzen/mapzen_restcurl.h +++ b/src/mapzen/mapzen_restcurl.h @@ -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); diff --git a/src/mapzen/tangram/platform_tizen.h b/src/mapzen/tangram/platform_tizen.h index b70d781..f286cc4 100644 --- a/src/mapzen/tangram/platform_tizen.h +++ b/src/mapzen/tangram/platform_tizen.h @@ -8,6 +8,7 @@ bool shouldRender(); void setRenderCallbackFunction(std::function callback); -void finishUrlRequests(); -void initUrlRequests(); +void initUrlRequests(const char* proxyAddress); +void stopUrlRequests(); + void setEvasGlAPI(Evas_GL_API* glApi); diff --git a/src/mapzen/tangram_view.cpp b/src/mapzen/tangram_view.cpp index 9e1d65e..4a93929 100644 --- a/src/mapzen/tangram_view.cpp +++ b/src/mapzen/tangram_view.cpp @@ -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; } diff --git a/src/mapzen/tangram_view.hpp b/src/mapzen/tangram_view.hpp index 424ec21..3dab34c 100644 --- a/src/mapzen/tangram_view.hpp +++ b/src/mapzen/tangram_view.hpp @@ -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);