From 51b432e318eba952ad7f0fd19ea2bb078eeee189 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Tue, 4 Aug 2015 19:23:43 +0900 Subject: Use dbus signal for sending expired noti to client In current implementation, each client register own dbus object to receive alarm expired signal from alarm-server. When an alarm expired, alarm-server finds service name(app or daemon) and calls directly using dbus method call. But using dbus signal is more reasonable, alarm-server can just emit dbus signal to notify alarm expired. Furthermore, in Tizen 3.0, if a service who doesn't have busconfig cannot own name and send method call on system bus. Change-Id: Ic6a3ea44046cc963ca3fc1b94c2433ff64e3e33a Signed-off-by: Sangyoon Jang --- alarm-manager.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'alarm-manager.c') diff --git a/alarm-manager.c b/alarm-manager.c index 5842bbb..41a7f6c 100644 --- a/alarm-manager.c +++ b/alarm-manager.c @@ -1086,6 +1086,8 @@ static bool __can_skip_expired_cb(alarm_id_t alarm_id) static void __alarm_send_noti_to_application(const char *app_service_name, alarm_id_t alarm_id) { char service_name[MAX_SERVICE_NAME_LEN] = {0,}; + gboolean ret; + GError *err = NULL; if (app_service_name == NULL || strlen(app_service_name) == 0) { ALARM_MGR_EXCEPTION_PRINT("This alarm destination is invalid."); @@ -1098,18 +1100,17 @@ static void __alarm_send_noti_to_application(const char *app_service_name, alarm memcpy(service_name, app_service_name, strlen(app_service_name)); SECURE_LOGI("[alarm server][send expired_alarm(alarm_id=%d) to app_service_name(%s)]", alarm_id, service_name); - g_dbus_connection_call(alarm_context.connection, - service_name, - "/org/tizen/alarm/client", - "org.tizen.alarm.client", - "alarm_expired", - g_variant_new("(is)", alarm_id, service_name), - NULL, - G_DBUS_CALL_FLAGS_NONE, - -1, - NULL, - NULL, - NULL); + ret = g_dbus_connection_emit_signal(alarm_context.connection, + NULL, + "/org/tizen/alarm/manager", + "org.tizen.alarm.manager", + "alarm_expired", + g_variant_new("(is)", alarm_id, service_name), + &err); + if (ret != TRUE) { + ALARM_MGR_EXCEPTION_PRINT("failed to send expired signal for %d, %s: %s", alarm_id, service_name, err->message); + g_error_free(err); + } } static uid_t __get_caller_uid(const char *name) @@ -1316,11 +1317,11 @@ static void __alarm_expired() if (strncmp(g_quark_to_string(__alarm_info->quark_dst_service_name), "null", 4) == 0) { SECURE_LOGD("[alarm-server]:destination is null, so we send expired alarm to %s(%u).", g_quark_to_string(__alarm_info->quark_app_service_name), __alarm_info->quark_app_service_name); - destination_app_service_name = g_quark_to_string(__alarm_info->quark_app_service_name_mod); + destination_app_service_name = g_quark_to_string(__alarm_info->quark_app_service_name); } else { SECURE_LOGD("[alarm-server]:destination :%s(%u)", g_quark_to_string(__alarm_info->quark_dst_service_name), __alarm_info->quark_dst_service_name); - destination_app_service_name = g_quark_to_string(__alarm_info->quark_dst_service_name_mod); + destination_app_service_name = g_quark_to_string(__alarm_info->quark_dst_service_name); } /* -- cgit v1.2.3