Get default viewer and launch 38/131938/8
authorMyungki Lee <mk5004.lee@samsung.com>
Thu, 1 Jun 2017 09:09:37 +0000 (18:09 +0900)
committerMyungki Lee <mk5004.lee@samsung.com>
Mon, 5 Jun 2017 06:09:17 +0000 (15:09 +0900)
- from /usr/share/notification/notification.ini
- To launchaing application When notification posted or updated.

Change-Id: I601848e36f631d966ab5b1fe36f57ed68abb3858
Signed-off-by: Myungki Lee <mk5004.lee@samsung.com>
src/notification_service.c

index de7796e..edf1971 100755 (executable)
@@ -49,6 +49,8 @@ static int _update_noti(GVariant **reply_body, notification_h noti, uid_t uid);
 
 static GList *_dnd_alarm_id_list;
 
+static char *default_viewer;
+
 typedef struct _dnd_alarm_id {
        uid_t uid;
        alarm_id_t dnd_start_id;
@@ -426,6 +428,14 @@ static int _add_noti(GVariant **reply_body, notification_h noti, uid_t uid)
                return ret;
        }
 
+       if (default_viewer != NULL) {
+               ret = notification_launch_default_viewer(default_viewer, priv_id);
+               if (ret != NOTIFICATION_ERROR_NONE) {
+                       ErrPrint("failed to launch (app_control error : %d)", ret);
+                       return NOTIFICATION_ERROR_IO_ERROR;
+               }
+       }
+
        *reply_body = g_variant_new("(i)", priv_id);
        if (*reply_body == NULL) {
                ErrPrint("cannot make reply_body");
@@ -648,12 +658,17 @@ static int _update_noti(GVariant **reply_body, notification_h noti, uid_t uid)
        int priv_id = NOTIFICATION_PRIV_ID_NONE;
 
        print_noti(noti);
-       notification_get_id(noti, NULL, &priv_id);
-       DbgPrint("priv_id: [%d]", priv_id);
-
        ret = notification_noti_update(noti);
-       if (ret != NOTIFICATION_ERROR_NONE)
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               ErrPrint("failed to update a notification:%d\n", ret);
                return ret;
+       }
+
+       ret = notification_get_id(noti, NULL, &priv_id);
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               ErrPrint("failed to gets priv_id:%d\n", ret);
+               return ret;
+       }
 
        body = notification_ipc_make_gvariant_from_noti(noti, true);
        if (body == NULL) {
@@ -669,11 +684,20 @@ static int _update_noti(GVariant **reply_body, notification_h noti, uid_t uid)
                return ret;
        }
 
+       if (default_viewer != NULL) {
+               ret = notification_launch_default_viewer(default_viewer, priv_id);
+               if (ret != NOTIFICATION_ERROR_NONE) {
+                       ErrPrint("failed to launch (app_control error : %d)", ret);
+                       return NOTIFICATION_ERROR_IO_ERROR;
+               }
+       }
+
        *reply_body = g_variant_new("(i)", priv_id);
        if (*reply_body == NULL) {
                ErrPrint("cannot make reply_body");
                return NOTIFICATION_ERROR_OUT_OF_MEMORY;
        }
+
        DbgPrint("_update_noti done !!");
        return ret;
 }
@@ -2250,6 +2274,8 @@ out:
  */
 HAPI int notification_service_init(void)
 {
+#define DEFAULT_VIEWER_CONF_FILE "/usr/share/notification/notification.ini"
+
        int ret, i;
        int count = 0;
        uid_t *uids = NULL;
@@ -2267,6 +2293,8 @@ HAPI int notification_service_init(void)
                return NOTIFICATION_ERROR_IO_ERROR;
        }
 
+       notification_get_default_viewer(DEFAULT_VIEWER_CONF_FILE, &default_viewer);
+
        _notification_data_init();
        notification_system_setting_init_system_setting_table(tzplatform_getuid(TZ_SYS_DEFAULT_USER));