From: Saurav Babu Date: Thu, 5 Apr 2018 12:13:17 +0000 (+0530) Subject: capi: Add ref count in comp-manager when initializing app X-Git-Tag: submit/tizen/20190131.065036~61 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5dca7ab9cc75612daf81fd85cfcfeefe718f7134;p=platform%2Fcore%2Fapi%2Fmulti-device-group.git capi: Add ref count in comp-manager when initializing app Signed-off-by: Saurav Babu --- diff --git a/capi/src/companion_dbus.c b/capi/src/companion_dbus.c index 9127a7b..0b0907a 100644 --- a/capi/src/companion_dbus.c +++ b/capi/src/companion_dbus.c @@ -257,8 +257,10 @@ static void __request_result_cb(Group *object, gchar *cmd, gchar *arg, gint ret, static int _enabler_proxy_init(comp_manager_s *handle) { - int ret = COMP_ERROR_NONE; GError *error = NULL; + const gchar *name; + int ret; + handle->enabler_proxy = enabler_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, COMP_DBUS_SERVICE, COMP_DBUS_ENABLER_PATH, NULL, &error); @@ -271,6 +273,30 @@ static int _enabler_proxy_init(comp_manager_s *handle) return COMP_ERROR_IO_ERROR; /* LCOV_EXCL_STOP */ } + + handle->system_bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); + if (NULL == handle->system_bus) { + /* LCOV_EXCL_START */ + if (error != NULL) { + _ERR("Failed to connect to system bus [%s]", error->message); + g_error_free(error); + } + return COMP_ERROR_IO_ERROR; + /* LCOV_EXCL_STOP */ + } + + name = g_dbus_connection_get_unique_name(handle->system_bus); + _DBG("Unique dbus name %s", name); + + enabler_call_add_ref_sync(handle->enabler_proxy, name, &ret, NULL, &error); + if (error) { + /* LCOV_EXCL_START */ + _ERR("Failed to add reference [%s]", error->message); + g_error_free(error); + return COMP_ERROR_IO_ERROR; + /* LCOV_EXCL_STOP */ + } + return ret; } @@ -358,9 +384,9 @@ static void _group_proxy_deinit(comp_manager_s *handle) static void _enabler_proxy_deinit(comp_manager_s *handle) { - int ret; + g_object_unref(handle->system_bus); + handle->system_bus = NULL; - enabler_call_disable_sync(handle->enabler_proxy, &ret, NULL, NULL); g_object_unref(handle->enabler_proxy); handle->enabler_proxy = NULL; } diff --git a/capi/src/companion_gdbus.xml b/capi/src/companion_gdbus.xml index 34705c4..f4ebd9a 100644 --- a/capi/src/companion_gdbus.xml +++ b/capi/src/companion_gdbus.xml @@ -6,7 +6,8 @@ - + + diff --git a/capi/src/companion_private.h b/capi/src/companion_private.h index 350a98c..37e2047 100644 --- a/capi/src/companion_private.h +++ b/capi/src/companion_private.h @@ -152,6 +152,7 @@ typedef struct _comp_manager_s { Group *group_proxy; /**< To receive signal from companion-manager */ Enabler *enabler_proxy; /**< Enbler proxy */ + GDBusConnection *system_bus; /**< GDBus System Bus */ group_found_cb_t group_found_cb; /**< When it called after finding a every single group */ group_find_finish_cb_t group_find_finish_cb; /**< When it called the group finging time is up */