- Gets the proxy address, and passes down to tangram curl handler for handling proxy addressed when fetching network
tiles
Change-Id: Ib972edd2df4f9f4d399009304b2ba1bea910fd56
int mapzen_init()
{
+ TangramView::initNetworkRequests();
int ret = mapzen_init_queue();
return ret;
int mapzen_shutdown()
{
+ TangramView::deinitNetworkRequests();
int ret = mapzen_deinit_queue();
return ret;
/*****************************************/
-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;
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;
}
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);
head = NULL;
curr = NULL;
- __get_proxy_address();
+ get_proxy_address(&__proxy_address);
#ifdef RESTCURL_USE_MULTI_CURL
pthread_mutex_init(&__MultiCurlArgsLock, NULL);
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);
void setRenderCallbackFunction(std::function<void()> callback);
-void finishUrlRequests();
-void initUrlRequests();
+void initUrlRequests(const char* proxyAddress);
+void stopUrlRequests();
+
void setEvasGlAPI(Evas_GL_API* glApi);
#include "mapzen_queue.h"
#include "mapzen_debug.h"
#include "mapzen_util.h"
+#include "mapzen_restcurl.h"
}
#include "mapzen_plugin_internal.h"
#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.
// 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) {
// 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);
m_map = nullptr;
}
+
return MAPZEN_ERROR_NONE;
}
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);