From 69392638f0ec57393c8995eae4d9b196b9bfba77 Mon Sep 17 00:00:00 2001 From: jomui Date: Thu, 23 Jun 2016 20:25:07 +0900 Subject: [PATCH] Bug fix about heremaps-uc Signed-off-by: jomui Change-Id: Ifae69e6b077054514687a96340c96838da06ac2a --- CMakeLists.txt | 2 ++ heremaps-uc-launcher/CMakeLists.txt | 2 +- heremaps-uc-launcher/src/heremaps-uc-launcher.c | 43 +++++++++++++++++++++++++ inc/heremaps-uc-dbus.h | 5 +++ src/heremaps-uc-dbus.c | 20 ++++++------ 5 files changed, 62 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d8d85b2..52f3618 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/heremaps-uc-launcher/CMakeLists.txt b/heremaps-uc-launcher/CMakeLists.txt index a535b32..a93d297 100644 --- a/heremaps-uc-launcher/CMakeLists.txt +++ b/heremaps-uc-launcher/CMakeLists.txt @@ -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}) diff --git a/heremaps-uc-launcher/src/heremaps-uc-launcher.c b/heremaps-uc-launcher/src/heremaps-uc-launcher.c index 8878ddf..ace4aa4 100644 --- a/heremaps-uc-launcher/src/heremaps-uc-launcher.c +++ b/heremaps-uc-launcher/src/heremaps-uc-launcher.c @@ -18,6 +18,29 @@ */ #include "heremaps-uc-launcher.h" +#include + +#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 } diff --git a/inc/heremaps-uc-dbus.h b/inc/heremaps-uc-dbus.h index 4c59621..229845f 100644 --- a/inc/heremaps-uc-dbus.h +++ b/inc/heremaps-uc-dbus.h @@ -28,6 +28,11 @@ 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) diff --git a/src/heremaps-uc-dbus.c b/src/heremaps-uc-dbus.c index 16abef7..d097ffb 100644 --- a/src/heremaps-uc-dbus.c +++ b/src/heremaps-uc-dbus.c @@ -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); -- 2.7.4