Add check box for notification (#5342)
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.NotificationEventListener / Tizen.Applications.NotificationEventListener / NotificationListenerManager.cs
index f2c0517..e6c1382 100755 (executable)
@@ -21,12 +21,15 @@ namespace Tizen.Applications.NotificationEventListener
     using System.ComponentModel;
     using System.Runtime.InteropServices;
 
+    using Tizen.Internals;
+
     /// <summary>
     /// This class provides a way to register callback function for some notification events.
     /// </summary>
     /// <remarks>
     /// The event listener can use this class to get a list of notifications or to clear notifications.
     /// </remarks>
+    /// <since_tizen> 4 </since_tizen>
     public partial class NotificationListenerManager
     {
         private const string LogTag = "Tizen.Applications.NotificationEventListener";
@@ -39,6 +42,7 @@ namespace Tizen.Applications.NotificationEventListener
 
         private static Interop.NotificationEventListener.ChangedCallback callback;
 
+        [NativeStruct("notification_op", Include="notification_type.h", PkgConfig="notification")]
         [StructLayout(LayoutKind.Sequential)]
         private struct NotificationOperation
         {
@@ -67,6 +71,7 @@ namespace Tizen.Applications.NotificationEventListener
         /// <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>
         public static event EventHandler<NotificationEventArgs> Added
         {
             add
@@ -113,6 +118,7 @@ namespace Tizen.Applications.NotificationEventListener
         /// <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>
         public static event EventHandler<NotificationEventArgs> Updated
         {
             add
@@ -159,6 +165,7 @@ namespace Tizen.Applications.NotificationEventListener
         /// <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>
         public static event EventHandler<NotificationDeleteEventArgs> Deleted
         {
             add
@@ -294,6 +301,7 @@ namespace Tizen.Applications.NotificationEventListener
         /// <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>
         public static void Delete(string appId, int uniqueNumber)
         {
             Interop.NotificationEventListener.ErrorCode err;
@@ -316,6 +324,7 @@ namespace Tizen.Applications.NotificationEventListener
         /// <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>
         public static void DeleteAll()
         {
             Interop.NotificationEventListener.ErrorCode err;
@@ -339,6 +348,7 @@ namespace Tizen.Applications.NotificationEventListener
         /// <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>
         public static IList<NotificationEventArgs> GetList()
         {
             Interop.NotificationEventListener.ErrorCode err;
@@ -346,34 +356,7 @@ namespace Tizen.Applications.NotificationEventListener
             IntPtr currentList = IntPtr.Zero;
             IList<NotificationEventArgs> list = new List<NotificationEventArgs>();
 
-            err = Interop.NotificationEventListener.GetList(NotificationType.Notification, -1, out notificationList);
-            if (err != Interop.NotificationEventListener.ErrorCode.None)
-            {
-                throw NotificationEventListenerErrorFactory.GetException(err, "unable to get notification list");
-            }
-
-            if (notificationList != IntPtr.Zero)
-            {
-                currentList = notificationList;
-                while (currentList != IntPtr.Zero)
-                {
-                    IntPtr notification;
-                    NotificationEventArgs eventargs = new NotificationEventArgs();
-
-                    notification = Interop.NotificationEventListener.GetData(currentList);
-
-                    eventargs = NotificationEventArgsBinder.BindObject(notification, false);
-
-                    list.Add(eventargs);
-
-                    currentList = Interop.NotificationEventListener.GetNext(currentList);
-                }
-
-                Interop.NotificationEventListener.NotificationListFree(notificationList);
-                notificationList = IntPtr.Zero;
-            }
-
-            err = Interop.NotificationEventListener.GetList(NotificationType.Ongoing, -1, out notificationList);
+            err = Interop.NotificationEventListener.GetList(NotificationType.None, -1, out notificationList);
             if (err != Interop.NotificationEventListener.ErrorCode.None)
             {
                 throw NotificationEventListenerErrorFactory.GetException(err, "unable to get notification list");
@@ -411,6 +394,7 @@ namespace Tizen.Applications.NotificationEventListener
         /// <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 void SendEvent(int uniqueNumber, UserEventType type)
         {
@@ -423,6 +407,30 @@ namespace Tizen.Applications.NotificationEventListener
             }
         }
 
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static void SetChecked(NotificationEventArgs eventargs, bool checkedValue)
+        {
+            Interop.NotificationEventListener.ErrorCode err;
+
+            err = Interop.NotificationEventListener.SetCheckedValue(eventargs.Handle, checkedValue);
+            if (err != Interop.NotificationEventListener.ErrorCode.None)
+            {
+                throw NotificationEventListenerErrorFactory.GetException(err, "failed to set checked");
+            }
+        }
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static void SendEventWithNotification(NotificationEventArgs eventargs, UserEventType type)
+        {
+            Interop.NotificationEventListener.ErrorCode err;
+
+            err = Interop.NotificationEventListener.SendEventWithNotification(eventargs.Handle, (int)type);
+            if (err != Interop.NotificationEventListener.ErrorCode.None)
+            {
+                throw NotificationEventListenerErrorFactory.GetException(err, "failed to send event");
+            }
+        }
+
         /// <summary>
         /// Returns NotificationEventArgs by UniqueNumber.
         /// </summary>
@@ -431,6 +439,7 @@ namespace Tizen.Applications.NotificationEventListener
         /// <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 NotificationEventArgs GetNotificationEventArgs(int uniqueNumber)
         {
@@ -458,5 +467,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;
+        }
     }
 }