own name in alarmmgr_init to get alarm expired signal 83/67183/2 accepted/tizen/common/20160427.053821 accepted/tizen/ivi/20160426.234154 accepted/tizen/mobile/20160426.234117 accepted/tizen/tv/20160426.234128 accepted/tizen/wearable/20160426.234133 submit/tizen/20160426.062602
authorJiwoong Im <jiwoong.im@samsung.com>
Mon, 25 Apr 2016 12:46:17 +0000 (21:46 +0900)
committerJiwoong Im <jiwoong.im@samsung.com>
Tue, 26 Apr 2016 01:25:46 +0000 (10:25 +0900)
Change-Id: I7b1263ad893c3bedcf7e6e4915070f5b7aff3b5d
Signed-off-by: Jiwoong Im <jiwoong.im@samsung.com>
src/alarm-lib.c

index a1e65ff..4b4825b 100644 (file)
@@ -354,6 +354,7 @@ EXPORT_API int alarmmgr_init(const char *appid)
        char service_name_mod[MAX_SERVICE_NAME_LEN] = { 0 };
        int ret;
        int len = 0;
+       guint owner_id = 0;
        int i = 0;
        int j = 0;
 
@@ -373,18 +374,6 @@ EXPORT_API int alarmmgr_init(const char *appid)
        if (ret < 0)
                return ret;
 
-       alarm_context.sid = g_dbus_connection_signal_subscribe(
-                       alarm_context.connection,
-                       NULL,
-                       "org.tizen.alarm.manager",
-                       "alarm_expired",
-                       "/org/tizen/alarm/manager",
-                       NULL,
-                       G_DBUS_SIGNAL_FLAGS_NONE,
-                       __handle_expired_signal,
-                       NULL,
-                       NULL);
-
        memset(service_name_mod, 'a', MAX_SERVICE_NAME_LEN - 1);
 
        len = strlen("ALARM.");
@@ -400,6 +389,26 @@ EXPORT_API int alarmmgr_init(const char *appid)
                }
                j++;
        }
+
+       owner_id = g_bus_own_name_on_connection(alarm_context.connection, service_name_mod,
+                       G_BUS_NAME_OWNER_FLAGS_NONE, NULL, NULL, NULL, NULL);
+       if (owner_id == 0) {
+               ALARM_MGR_EXCEPTION_PRINT("Acquiring the own name is failed. %s", service_name_mod);
+               return ERR_ALARM_SYSTEM_FAIL;
+       }
+
+       alarm_context.sid = g_dbus_connection_signal_subscribe(
+                       alarm_context.connection,
+                       NULL,
+                       "org.tizen.alarm.manager",
+                       "alarm_expired",
+                       "/org/tizen/alarm/manager",
+                       NULL,
+                       G_DBUS_SIGNAL_FLAGS_NONE,
+                       __handle_expired_signal,
+                       NULL,
+                       NULL);
+
        alarm_context.quark_app_service_name = g_quark_from_string(service_name);
        alarm_context.quark_app_service_name_mod = g_quark_from_string(service_name_mod);