Update notification display service 05/45005/1 accepted/tizen/tv/20150731.005354 submit/tizen/20150730.133600
authorjinwoo.shin <jw0227.shin@samsung.com>
Thu, 30 Jul 2015 10:01:35 +0000 (19:01 +0900)
committerjinwoo.shin <jw0227.shin@samsung.com>
Thu, 30 Jul 2015 10:02:28 +0000 (19:02 +0900)
Change-Id: I38ca85154854a8a5f982e02b6324aebef4aafb3e
Signed-off-by: jinwoo.shin <jw0227.shin@samsung.com>
daemon/notification-display.service
daemon/notification_display_service.c

index 8dccc65..3907696 100644 (file)
@@ -1,6 +1,6 @@
 [Unit]
 Description=Notifications Display daemon
-Requires=notifications.service display-manager-run.service
+Requires=notifications.service display-manager-run.service tizen-system-env.service
 After=notifications.service display-manager-run.service
 
 [Service]
index fa6d773..09699b3 100644 (file)
@@ -14,9 +14,11 @@ SET_TAG(SERVICE_NAME)
 struct _priv {
        Evas_Object *win;
        Evas_Object *popup;
+
+       time_t last_time;
 };
 
-static void _timeout(void *data, Evas_Object *obj, void *event_info)
+static void _hide(void *data, Evas_Object *obj, void *event_info)
 {
        evas_object_hide(data);
 }
@@ -38,10 +40,13 @@ void _show_notification(struct _priv *priv, notification_h noti)
 void _notification_changed_cb(void *data, notification_type_e notif_type)
 {
        struct _priv *priv;
-
+       time_t latest_time;
        notification_h noti = NULL;
        notification_list_h noti_list = NULL;
 
+       if (notif_type != NOTIFICATION_TYPE_NOTI)
+               return;
+
        if (!data) {
                _ERR("failed to get data");
                return;
@@ -51,15 +56,60 @@ void _notification_changed_cb(void *data, notification_type_e notif_type)
        notification_get_list(NOTIFICATION_TYPE_NOTI, -1, &noti_list);
        if (noti_list) {
                noti = notification_list_get_data(noti_list);
-               if (noti)
-                       _show_notification(priv, noti);
+               if (noti) {
+                       notification_get_insert_time(noti, &latest_time);
+
+                       if (latest_time > priv->last_time) {
+                               _show_notification(priv, noti);
+                               priv->last_time = latest_time;
+                       }
+               }
+       }
+
+       notification_free_list(noti_list);
+}
+
+static void _clear_notification(void)
+{
+       notification_list_h noti_list = NULL;
+       notification_h noti;
+
+       notification_get_list(NOTIFICATION_TYPE_NOTI, -1, &noti_list);
+       if (!noti_list)
+               return;
+
+       while (noti_list != NULL) {
+               noti = notification_list_get_data(noti_list);
+               notification_delete(noti);
+
+               noti_list = notification_list_remove(noti_list, noti);
+               notification_free(noti);
+       }
+}
+
+time_t _get_last_time(void)
+{
+       time_t last_time = 0;
+       notification_h noti = NULL;
+       notification_list_h noti_list = NULL;
+
+       notification_get_list(NOTIFICATION_TYPE_NOTI, -1, &noti_list);
+       if (noti_list) {
+               noti = notification_list_get_data(noti_list);
+               if (noti) {
+                       notification_get_insert_time(noti, &last_time);
+               }
        }
 
        notification_free_list(noti_list);
+
+       return last_time;
 }
 
 int _create_popup(struct _priv *priv)
 {
+       Evas_Object *btn;
+
        priv->win = elm_win_add(NULL, "popup", ELM_WIN_BASIC);
        if (!priv->win) {
                _ERR("elm_win_add failed");
@@ -74,10 +124,12 @@ int _create_popup(struct _priv *priv)
                _ERR("elm_win_add failed");
                return -1;
        }
-       elm_popup_timeout_set(priv->popup, HIDE_TIME);
-       elm_popup_orient_set(priv->popup, ELM_POPUP_ORIENT_BOTTOM_RIGHT);
-       evas_object_smart_callback_add(priv->popup, "timeout",
-                       _timeout, priv->win);
+       elm_popup_orient_set(priv->popup, ELM_POPUP_ORIENT_BOTTOM_LEFT);
+
+       btn = elm_button_add(priv->popup);
+       elm_object_text_set(btn, "OK");
+       elm_object_part_content_set(priv->popup, "button1", btn);
+       evas_object_smart_callback_add(btn, "clicked", _hide, priv->win);
 
        return 0;
 }
@@ -107,6 +159,11 @@ int main(int argc, char **argv)
                return 0;
        }
 
+       /* NOTE: Odroid specific code to workaround time issue */
+       _clear_notification();
+
+       priv->last_time = _get_last_time();
+
        error_n = NOTIFICATION_ERROR_SERVICE_NOT_READY;
        while (error_n != NOTIFICATION_ERROR_NONE) {
                error_n = notification_resister_changed_cb(