Add method to get NotificationEventArgs by unique id 08/155708/4 preview1-00313
authorSeungha Son <seungha.son@samsung.com>
Mon, 16 Oct 2017 03:24:03 +0000 (12:24 +0900)
committerSemun Lee <semun.lee@samsung.com>
Wed, 18 Oct 2017 07:49:04 +0000 (07:49 +0000)
Change-Id: I217b699c12d50ef9ec496002cedbc11f537db2bc
Signed-off-by: Seungha Son <seungha.son@samsung.com>
src/Tizen.Applications.NotificationEventListener/Interop/Interop.NotificationEventListener.cs
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationListenerManager.cs

index 708a5ad..9e36242 100755 (executable)
@@ -165,6 +165,9 @@ internal static partial class Interop
         [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_extension_event_handler")]
         internal static extern ErrorCode GetExtensionAction(NotificationSafeHandle handle, UserEventType type, out SafeAppControlHandle appcontrol);
 
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_load")]
+        internal static extern IntPtr LoadNotification(string appID, int uniqueID);
+
         internal static ErrorCode GetAppId(NotificationSafeHandle handle, out string appid)
         {
             ErrorCode err;
index dd86791..f2c0517 100755 (executable)
@@ -422,5 +422,41 @@ namespace Tizen.Applications.NotificationEventListener
                 throw NotificationEventListenerErrorFactory.GetException(err, "failed to send event");
             }
         }
+
+        /// <summary>
+        /// Returns NotificationEventArgs by UniqueNumber.
+        /// </summary>
+        /// <param name="uniqueNumber">The unique number of the Notification.</param>
+        /// <exception cref="ArgumentException">Thrown in case of an invalid parameter.</exception>
+        /// <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>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static NotificationEventArgs GetNotificationEventArgs(int uniqueNumber)
+        {
+            if (uniqueNumber <= 0)
+            {
+                throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "Invalid parameter");
+            }
+
+            IntPtr notificationPtr = Interop.NotificationEventListener.LoadNotification(null, uniqueNumber);
+            if (notificationPtr == IntPtr.Zero)
+            {
+                int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult();
+                if (err.Equals((int)Interop.NotificationEventListener.ErrorCode.DbError))
+                {
+                    throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "Not exist");
+                }
+                else
+                {
+                    throw NotificationEventListenerErrorFactory.GetException((Interop.NotificationEventListener.ErrorCode)err, "failed to get NotificationEventArgs");
+                }
+            }
+
+            NotificationEventArgs eventArgs = new NotificationEventArgs();
+            eventArgs = NotificationEventArgsBinder.BindObject(notificationPtr, false);
+
+            return eventArgs;
+        }
     }
 }