modified to response error codes when failed to load a plugin module 96/84496/1
authorchanywa <cbible.kim@samsung.com>
Fri, 19 Aug 2016 04:30:51 +0000 (13:30 +0900)
committerchanywa <cbible.kim@samsung.com>
Fri, 19 Aug 2016 04:30:51 +0000 (13:30 +0900)
Change-Id: I52f8b7a665fb9fe583f27d88c830042c5e97478b

src/plugin/discovery.cpp
src/plugin/module.cpp

index 457ad73..e3c0d2e 100644 (file)
@@ -135,7 +135,16 @@ plugin::provider_info plugin::find_by_names(const string &provider)
 
 void plugin::split_provider_name(const char *original, char **provider, char **module)
 {
-       char *save;
-       *provider = strtok_r(g_strdup(original), "/", &save);
-       *module = g_strdup(strtok_r(NULL, "", &save));
-}
\ No newline at end of file
+       char *save, *_provider, *_module;
+       
+       _provider = strtok_r(g_strdup(original), "/", &save);
+       _module = g_strdup(strtok_r(NULL, "", &save));
+
+       if (provider)
+               *provider = g_strdup(_provider);
+       if (module)
+               *module = g_strdup(_module);
+
+       g_free(_provider);
+       g_free(_module);
+}
index 436dce3..1e5e00f 100644 (file)
@@ -79,14 +79,18 @@ maps_plugin_h plugin::binary_extractor::init(const provider_info &info,
                                             const char *module, int *init_error)
 {
        /* 1.Initialize plugin */
-       if (info.file.empty() || !init_error)
+       if (info.file.empty() || !init_error) {
+               if (init_error)
+                       *init_error = MAPS_ERROR_NOT_SUPPORTED;
                return NULL;
+       }
 
        *init_error = MAPS_ERROR_NONE;
 
        GMod *plugin = gmod_new(info.file, TRUE);
        if (!plugin) {
                MAPS_LOGE("Open Module Failed: %s", info.file.c_str());
+               *init_error = MAPS_ERROR_SERVICE_NOT_AVAILABLE;
                return NULL;
        }
 
@@ -96,8 +100,8 @@ maps_plugin_h plugin::binary_extractor::init(const provider_info &info,
        /* 2. Perform steps to completely initialize a plugin */
        do {
                if (!new_plugin) {
-                       MAPS_LOGE("OUT_OF_MEMORY(0x%08x)",
-                               MAPS_ERROR_OUT_OF_MEMORY);
+                       MAPS_LOGE("OUT_OF_MEMORY(0x%08x)", MAPS_ERROR_OUT_OF_MEMORY);
+                       *init_error = MAPS_ERROR_OUT_OF_MEMORY;
                        break;
                }
 
@@ -155,8 +159,8 @@ maps_plugin_h plugin::binary_extractor::init(const provider_info &info,
                        (maps_plugin_reverse_geocode_f) gmod_find_sym(plugin,
                        "maps_plugin_reverse_geocode");
                new_plugin->interface.maps_plugin_multi_reverse_geocode =
-                       (maps_plugin_multi_reverse_geocode_f)
-                       gmod_find_sym(plugin, "maps_plugin_multi_reverse_geocode");
+                       (maps_plugin_multi_reverse_geocode_f) gmod_find_sym(plugin,
+                       "maps_plugin_multi_reverse_geocode");
 
                /* Place */
                new_plugin->interface.maps_plugin_search_place =
@@ -180,8 +184,7 @@ maps_plugin_h plugin::binary_extractor::init(const provider_info &info,
                        (maps_plugin_search_route_f) gmod_find_sym(plugin,
                        "maps_plugin_search_route");
                new_plugin->interface.maps_plugin_search_route_waypoints =
-                       (maps_plugin_search_route_waypoints_f)
-                       gmod_find_sym(plugin,
+                       (maps_plugin_search_route_waypoints_f) gmod_find_sym(plugin,
                        "maps_plugin_search_route_waypoints");
 
                /* Cancel Request */
@@ -232,8 +235,8 @@ maps_plugin_h plugin::binary_extractor::init(const provider_info &info,
 
                /* 2.3 Check whether the plugin init function is valid */
                if (!new_plugin->interface.maps_plugin_init) {
-                       MAPS_LOGE(
-                       "ERROR! Plugin initialization function is invalid");
+                       MAPS_LOGE("ERROR! Plugin initialization function is invalid");
+                       *init_error = MAPS_ERROR_SERVICE_NOT_AVAILABLE;
                        break;
                }
 
@@ -246,37 +249,44 @@ maps_plugin_h plugin::binary_extractor::init(const provider_info &info,
                        ret = new_plugin->interface.maps_plugin_init_module((maps_plugin_h *) (&new_plugin), module);
 
                if (ret != MAPS_ERROR_NONE) {
-                       MAPS_LOGE("ERROR! Plugin initialization function ""failed: %d", ret);
+                       MAPS_LOGE("ERROR! Plugin initialization function failed: %d", ret);
+                       *init_error = ret;
                        break;
                }
 
                if (!new_plugin->interface.maps_plugin_set_provider_key) {
-                       MAPS_LOGE("ERROR! Plugin set_provider_key function is NULL: %d", ret);
+                       MAPS_LOGE("ERROR! Plugin set_provider_key function is NULL");
+                       *init_error = MAPS_ERROR_SERVICE_NOT_AVAILABLE;
                        break;
                }
 
                if (!new_plugin->interface.maps_plugin_get_provider_key) {
-                       MAPS_LOGE("ERROR! Plugin set_provider_key function is NULL: %d", ret);
+                       MAPS_LOGE("ERROR! Plugin set_provider_key function is NULL");
+                       *init_error = MAPS_ERROR_SERVICE_NOT_AVAILABLE;
                        break;
                }
 
                if (!new_plugin->interface.maps_plugin_set_preference) {
-                       MAPS_LOGE("ERROR! Plugin set_preference function is NULL: %d", ret);
+                       MAPS_LOGE("ERROR! Plugin set_preference function is NULL");
+                       *init_error = MAPS_ERROR_SERVICE_NOT_AVAILABLE;
                        break;
                }
 
                if (!new_plugin->interface.maps_plugin_get_preference) {
-                       MAPS_LOGE("ERROR! Plugin get_preference function is NULL: %d", ret);
+                       MAPS_LOGE("ERROR! Plugin get_preference function is NULL");
+                       *init_error = MAPS_ERROR_SERVICE_NOT_AVAILABLE;
                        break;
                }
 
                if (!new_plugin->interface.maps_plugin_is_data_supported) {
-                       MAPS_LOGE("ERROR! Plugin support_is_data_supported function is NULL: %d", ret);
+                       MAPS_LOGE("ERROR! Plugin support_is_data_supported function is NULL");
+                       *init_error = MAPS_ERROR_SERVICE_NOT_AVAILABLE;
                        break;
                }
 
                if (!new_plugin->interface.maps_plugin_is_service_supported) {
-                       MAPS_LOGE("ERROR! Plugin support_is_service_supported function is NULL: %d", ret);
+                       MAPS_LOGE("ERROR! Plugin support_is_service_supported function is NULL");
+                       *init_error = MAPS_ERROR_SERVICE_NOT_AVAILABLE;
                        break;
                }
 
@@ -290,6 +300,7 @@ maps_plugin_h plugin::binary_extractor::init(const provider_info &info,
                        session::command_handler::destroy);
                if (!new_plugin->pending_request_maps) {
                        MAPS_LOGE("OUT_OF_MEMORY(0x%08x)", MAPS_ERROR_OUT_OF_MEMORY);
+                       *init_error = MAPS_ERROR_OUT_OF_MEMORY;
                        break;
                }
                g_mutex_init(&new_plugin->pending_request_mutex);