Add new api to count the notification list 08/84008/2
authorMyungki Lee <mk5004.lee@samsung.com>
Tue, 16 Aug 2016 09:07:53 +0000 (18:07 +0900)
committerMyungki Lee <mk5004.lee@samsung.com>
Tue, 16 Aug 2016 09:07:53 +0000 (18:07 +0900)
Change-Id: Id345fe4847957044741dd0d1b39c2cc9893cf1d3
Signed-off-by: Myungki Lee <mk5004.lee@samsung.com>
include/notification_list.h
src/notification_list.c

index 6c9ef02a1e13eee992dc9ec723d61b60bb01eabd..447b893c636ccde367439812eb48fafaea83658f 100644 (file)
@@ -310,6 +310,36 @@ notification_list_h notification_list_get_next(notification_list_h list);
  */
 notification_h notification_list_get_data(notification_list_h list);
 
+
+/**
+ * @brief Gets a number of the notification list.
+ * @since_tizen 3.0
+ * @param[in] list Notification list handle
+ * @return A number of notification list handle on success, 0 on failure
+ * @exception #NOTIFICATION_ERROR_NONE Success
+ * @exception #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
+ * @see #notification_list_h
+ * @see #notification_h
+ * @par Sample code:
+ * @code
+include <notification.h>
+...
+{
+       int count = 0;
+       notification_list_h noti_list = NULL;
+       int noti_err = NOTIFICATION_ERROR_NONE;
+
+       noti_err = notification_get_detail_list(pkgname, group_id, priv_id, -1, &noti_list);
+       if(noti_err != NOTIFICATION_ERROR_NONE) {
+               return;
+       }
+
+       count = notification_list_get_count(noti_list);
+}
+ * @endcode
+ */
+int notification_list_get_count(notification_list_h list);
+
 /**
  * @brief Appends notification data to the notification list.
  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
index 3e0be520374960e6ff7caa08398fb482e984a334..5cd7ff1aa289e697a66bfe7874d5d25e121f544a 100755 (executable)
@@ -139,6 +139,28 @@ EXPORT_API notification_h notification_list_get_data(notification_list_h list)
        return cur_list->noti;
 }
 
+EXPORT_API int notification_list_get_count(notification_list_h list)
+{
+       int count = 0;
+       notification_list_h cur_list = NULL;
+
+       if (list == NULL) {
+               NOTIFICATION_ERR("INVALID DATA : list == NULL");
+               set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
+               return 0;
+       }
+
+       cur_list = notification_list_get_head(list);
+
+       while (cur_list != NULL) {
+               count++;
+               cur_list = cur_list->next;
+       }
+
+       set_last_result(NOTIFICATION_ERROR_NONE);
+       return count;
+}
+
 EXPORT_API notification_list_h notification_list_append(notification_list_h list,
                notification_h noti)
 {