[NotificationEventListener] Add method for get all count 69/163969/6 5.0.0-preview1-00417
authorSeungha Son <seungha.son@samsung.com>
Thu, 14 Dec 2017 08:57:51 +0000 (17:57 +0900)
committerSeungha Son <seungha.son@samsung.com>
Tue, 19 Dec 2017 06:04:02 +0000 (06:04 +0000)
related patch
 -data-provider-master : https://review.tizen.org/gerrit/#/c/163585/
 -notification : https://review.tizen.org/gerrit/#/c/163584/

Signed-off-by: Seungha Son <seungha.son@samsung.com>
Change-Id: Iba5d5cf81b12fa131104fa2371c97ac03f124871

src/Tizen.Applications.NotificationEventListener/Interop/Interop.NotificationEventListener.cs
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationListenerManager.cs

index 85fbc4b..255be6d 100755 (executable)
@@ -168,6 +168,9 @@ internal static partial class Interop
         [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_load")]
         internal static extern IntPtr LoadNotification(string appID, int uniqueID);
 
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_all_count")]
+        internal static extern ErrorCode GetAllCount(NotificationType type, out int count);
+
         internal static ErrorCode GetAppId(NotificationSafeHandle handle, out string appid)
         {
             ErrorCode err;
index d0c8382..c42923f 100755 (executable)
@@ -440,5 +440,35 @@ namespace Tizen.Applications.NotificationEventListener
 
             return eventArgs;
         }
+
+        /// <summary>
+        /// Gets the number of all notifications
+        /// </summary>
+        /// <returns>The number of all notifications</returns>
+        /// <exception cref="UnauthorizedAccessException"> Thrown in case of a permission is denied.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+        /// <privilege>http://tizen.org/privilege/notification</privilege>
+        /// <since_tizen> 4 </since_tizen>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static int GetAllCount()
+        {
+            int count;
+            Interop.NotificationEventListener.ErrorCode error;
+
+            error = Interop.NotificationEventListener.GetAllCount(NotificationType.None, out count);
+            if (error != Interop.NotificationEventListener.ErrorCode.None)
+            {
+                if (error == Interop.NotificationEventListener.ErrorCode.PermissionDenied)
+                {
+                    throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.PermissionDenied, "failed to get all count");
+                }
+                else
+                {
+                    throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidOperation, "failed to get all count");
+                }
+            }
+
+            return count;
+        }
     }
 }