remove pending notifications from DB when starting notifications-display service 64/29164/2 accepted/tizen_3.0.2014.q3_common accepted/tizen_3.0.m14.3_ivi tizen_3.0.2014.q3_common tizen_3.0.m14.3_ivi accepted/tizen/3.0.2014.q3/common/20141027.152336 accepted/tizen/3.0.m14.3/ivi/20141027.134134 accepted/tizen/common/20141027.140229 accepted/tizen/ivi/20141107.061625 submit/tizen_3.0.2014.q3_common/20141027.134844 submit/tizen_3.0.m14.3_ivi/20141027.073643 submit/tizen_common/20141027.134820 submit/tizen_ivi/20141107.011402 tizen_3.0.2014.q3_common_release tizen_3.0.m14.3_ivi_release
authorCorentin Lecouvey <corentin.lecouvey@open.eurogiciel.org>
Tue, 21 Oct 2014 16:34:06 +0000 (18:34 +0200)
committerCorentin Lecouvey <corentin.lecouvey@open.eurogiciel.org>
Tue, 21 Oct 2014 16:47:54 +0000 (18:47 +0200)
If some notifications are present in notification.db when starting notifications-display
service, we remove them. Otherwise, wrong popups appears when starting the service.

Change-Id: Id8813a9dc420ef7b84ddcb4817484b61362a18fa
Signed-off-by: Corentin Lecouvey <corentin.lecouvey@open.eurogiciel.org>
notification_display_service.c

index 30211ac..e0d2fd8 100644 (file)
@@ -87,6 +87,23 @@ void display_notifications_cb (void *data, notification_type_e notif_type)
        }
 }
 
+void del_pending_notifications(void)
+{
+       notification_h noti = NULL;
+       notification_list_h notification_list = NULL;
+       notification_list_h get_list = NULL;
+
+       notification_get_list (NOTIFICATION_TYPE_NOTI, -1, &notification_list);
+       if (notification_list) {
+               get_list = notification_list_get_head (notification_list);
+               while (get_list) {
+                       noti = notification_list_get_data(get_list);
+                       notification_delete(noti);
+                       LOGD("remove pending notification: %p from DB", noti);
+                       get_list = notification_list_remove(get_list, noti);
+               }
+       }
+}
 
 int main (int argc, char **argv)
 {
@@ -110,6 +127,9 @@ retry_socket:
                goto retry_socket;
        }
 
+       /* remove all notifications stored in DB before handling new notifications */
+       del_pending_notifications();
+
 retry_service:
        LOGD("Checking if the notifications server is available...");
        error_n = notification_resister_changed_cb (display_notifications_cb, (*disp_fct));