display the count of unread notification 26/48026/2 accepted/tizen/tv/20150914.043132 submit/tizen/20150914.022353
authorSoohye Shin <soohye.shin@samsung.com>
Fri, 11 Sep 2015 08:11:44 +0000 (17:11 +0900)
committerSoohye Shin <soohye.shin@samsung.com>
Fri, 11 Sep 2015 08:19:44 +0000 (17:19 +0900)
Change-Id: I8197d97a819fa0f3bfaa7baf32664da8d989c2e6
Signed-off-by: Soohye Shin <soohye.shin@samsung.com>
src/data/data_home.c

index 636bfe7..452d06c 100644 (file)
@@ -24,6 +24,7 @@
 #include <notification_internal.h>
 #include <pwd.h>
 #include <gum/gum-user.h>
+#include <app_contents.h>
 
 #include "data_home.h"
 #include "datamgr.h"
@@ -78,13 +79,39 @@ static inline gboolean _read_boolean(JsonReader *reader, char *member)
 
 static inline void _get_notification_count(notification_type_e type, int *count)
 {
+       int basis_time, r;
+       time_t noti_time;
        notification_list_h list = NULL;
+       notification_h noti;
+
+       app_contents_get_basis_time(CONTENTS_NOTI, &basis_time);
+       if (basis_time < 0) {
+               _ERR("failed to get basis time");
+               return;
+       }
 
        notification_get_list(type, -1, &list);
        if (!list)
                return;
 
        while (list) {
+               noti = notification_list_get_data(list);
+               if (!noti) {
+                       _ERR("failed to get noti data");
+                       list = notification_list_get_next(list);
+                       continue;
+               }
+
+               r = notification_get_insert_time(noti, &noti_time);
+               if (r != NOTIFICATION_ERROR_NONE) {
+                       _ERR("failed to get time of notification");
+                       list = notification_list_get_next(list);
+                       continue;
+               }
+
+               if (noti_time < basis_time)
+                       break;
+
                (*count)++;
                list = notification_list_get_next(list);
        }