Bug fix about heremaps-uc 34/76334/1 accepted/tizen/common/20160624.132404 submit/tizen/20160624.010517
authorjomui <jongmun.woo@samsung.com>
Thu, 23 Jun 2016 11:25:07 +0000 (20:25 +0900)
committerjomui <jongmun.woo@samsung.com>
Thu, 23 Jun 2016 11:25:32 +0000 (20:25 +0900)
Signed-off-by: jomui <jongmun.woo@samsung.com>
Change-Id: Ifae69e6b077054514687a96340c96838da06ac2a

CMakeLists.txt
heremaps-uc-launcher/CMakeLists.txt
heremaps-uc-launcher/src/heremaps-uc-launcher.c
inc/heremaps-uc-dbus.h
src/heremaps-uc-dbus.c

index d8d85b2..52f3618 100644 (file)
@@ -9,6 +9,8 @@ SET(LIBDIR ${LIBDIR})
 # Dependencies
 SET(dependents
        glib-2.0
+       gio-2.0
+       gio-unix-2.0
        gmodule-2.0
        libxml-2.0
        dlog
index a535b32..a93d297 100644 (file)
@@ -31,7 +31,7 @@ INSTALL(FILES config/heremaps-uc-launcher.conf DESTINATION ${SYSCONF_DIR}/dbus-1
 
 # Check external libraries
 INCLUDE(FindPkgConfig)
-pkg_check_modules(UC_LAUNCHER_EXT_LIBS REQUIRED glib-2.0 gthread-2.0 capi-appfw-application capi-system-info evas dlog ecore)
+pkg_check_modules(UC_LAUNCHER_EXT_LIBS REQUIRED glib-2.0 gio-2.0 gio-unix-2.0 gthread-2.0 capi-appfw-application capi-system-info evas dlog ecore)
 
 SET(EXTRA_CFLAGS "")
 FOREACH(flag ${${UC_LAUNCHER_EXT_LIBS}_CFLAGS})
index 8878ddf..ace4aa4 100644 (file)
  */
 
 #include "heremaps-uc-launcher.h"
+#include <gio/gio.h>
+
+#define UC_RECEIVER_NAME       "org.tizen.lbs.Providers.HereMapsUCLauncher"
+
+GMainLoop *loop = NULL;
+
+static void on_bus_acquired(GDBusConnection *conn, const gchar *name, gpointer user_data)
+{
+       LS_LOGD("HereMapsUCLauncher: Acquired the bus <%s>", name);
+
+       g_main_loop_quit(loop);
+       LS_LOGD("HereMapsUCLauncher: g_main_loop_quit");
+}
+
+static void on_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
+{
+       LS_LOGD("HereMapsUCLauncher: Acquired the name <%s> on the system bus", name);
+}
+
+static void on_name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data)
+{
+       LS_LOGD("HereMapsUCLauncher: Lost the name <%s> on the system bus", name);
+}
 
 static void launch_heremaps_uc()
 {
@@ -29,6 +52,26 @@ static void launch_heremaps_uc()
        app_control_send_launch_request(app_control, NULL, NULL);
        app_control_destroy(app_control);
 
+       gchar *service_name = g_strdup(UC_RECEIVER_NAME);
+       guint owner_id = g_bus_own_name(G_BUS_TYPE_SESSION, service_name, G_BUS_NAME_OWNER_FLAGS_NONE, on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL);
+       LS_LOGD("g_bus_own_name id=[%d]", owner_id);
+
+       loop =  g_main_loop_new(NULL, TRUE);
+
+       LS_LOGD("HereMapsUCLauncher: g_main_loop_quit");
+       g_main_loop_run(loop);
+
+       g_main_loop_unref(loop);
+       LS_LOGD("HereMapsUCLauncher: g_main_loop_unref");
+
+       g_bus_unown_name(owner_id);
+       LS_LOGD("g_bus_unown_name");
+
+       g_free(service_name);
+       LS_LOGD("g_free service_name");
+
+       loop = NULL;
+
        LS_FUNC_EXIT
 }
 
index 4c59621..229845f 100644 (file)
 extern "C" {
 #endif
 
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "HERE_PLUGIN"
+
 #define MAPS_LOGD(fmt,args...)  LOGD(fmt, ##args)
 #define MAPS_LOGW(fmt,args...)  LOGW(fmt, ##args)
 #define MAPS_LOGI(fmt,args...)  LOGI(fmt, ##args)
index 16abef7..d097ffb 100644 (file)
@@ -31,20 +31,13 @@ typedef struct _heremaps_uc_dbus_s {
        gchar *signal_path;
 } heremaps_uc_dbus_s;
 
-static void heremaps_uc_ready_cb(GObject *source_object, GAsyncResult *res, gpointer user_data)
-{
-       MAPS_FUNC_ENTER
-
-       GError *error = NULL;
-       g_dbus_proxy_new_finish(res, &error);
-}
-
 EXPORT_API int heremaps_uc_dbus_launch_receiver()
 {
        MAPS_FUNC_ENTER
 
        char *bus_addr = NULL;
        GError *error = NULL;
+       GDBusProxy *proxy = NULL;
 
 #if !GLIB_CHECK_VERSION(2, 35, 0)
        g_type_init();
@@ -84,7 +77,16 @@ EXPORT_API int heremaps_uc_dbus_launch_receiver()
        handle->signal_path = g_strdup_printf("%s/%s", handle->service_path, "SAMSUNG");
        MAPS_LOGD("Object Path [%s]", handle->signal_path);
 
-       g_dbus_proxy_new(handle->conn, G_DBUS_PROXY_FLAGS_NONE, NULL, handle->service_name, handle->signal_path, UC_INTERFACE_NAME, NULL, heremaps_uc_ready_cb, NULL);
+       proxy = g_dbus_proxy_new_sync(handle->conn, G_DBUS_PROXY_FLAGS_NONE, NULL, handle->service_name, handle->signal_path, UC_INTERFACE_NAME, NULL, NULL);
+       if (proxy) {
+               MAPS_LOGD("proxy: %p", proxy);
+               g_object_unref(proxy);
+       } else {
+               if (error) {
+                       MAPS_LOGD("Fail to get proxy Error[%s]", error->message);
+                       g_error_free(error);
+               }
+       }
 
        if (handle->conn) {
                g_object_unref(handle->conn);