X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FTizen.Applications.NotificationEventListener%2FTizen.Applications.NotificationEventListener%2FNotificationListenerManager.cs;h=c42923f0bdad3d91cead53219c0d9ad594abd636;hb=55478d7ce098a2e01e8238ecce12d8c26e8464ba;hp=5f02395dff4915df35d040a18a97a6d062f24939;hpb=76e4a7b6344c660adfe92cc92b4f49680fc3e9c4;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationListenerManager.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationListenerManager.cs
index 5f02395..c42923f 100755
--- a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationListenerManager.cs
+++ b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationListenerManager.cs
@@ -25,8 +25,9 @@ namespace Tizen.Applications.NotificationEventListener
/// This class provides a way to register callback function for some notification events.
///
///
- /// The event listener can use this class to get a list of notification or to clear notifications.
+ /// The event listener can use this class to get a list of notifications or to clear notifications.
///
+ /// 4
public partial class NotificationListenerManager
{
private const string LogTag = "Tizen.Applications.NotificationEventListener";
@@ -61,13 +62,14 @@ namespace Tizen.Applications.NotificationEventListener
}
///
- /// Registers a callback for notification insert event.
+ /// Event handler for notification insert event.
///
- /// Thrown in case of Invalid parameter.
- /// Thrown in case of Permission deny.
+ /// Thrown in case of an invalid parameter.
+ /// Thrown in case of a permission is denied.
/// Thrown in case of any internal error.
/// http://tizen.org/privilege/notification
- public static event EventHandler NotificationAddEventHandler
+ /// 4
+ public static event EventHandler Added
{
add
{
@@ -107,13 +109,14 @@ namespace Tizen.Applications.NotificationEventListener
}
///
- /// Registers a callback for notification update event.
+ /// Event handler for notification update event.
///
- /// Thrown in case of Invalid parameter.
- /// Thrown in case of Permission deny.
+ /// Thrown in case of an invalid parameter.
+ /// Thrown in case of a permission is denied.
/// Thrown in case of any internal error.
/// http://tizen.org/privilege/notification
- public static event EventHandler NotificationUpdateEventHandler
+ /// 4
+ public static event EventHandler Updated
{
add
{
@@ -153,13 +156,14 @@ namespace Tizen.Applications.NotificationEventListener
}
///
- /// Registers a callback for notification delete event.
+ /// Event handler for notification delete event.
///
- /// Thrown in case of Invalid parameter.
- /// Thrown in case of Permission deny.
+ /// Thrown in case of an invalid parameter.
+ /// Thrown in case of a permission is denied.
/// Thrown in case of any internal error.
/// http://tizen.org/privilege/notification
- public static event EventHandler NotificationDeleteEventHandler
+ /// 4
+ public static event EventHandler Deleted
{
add
{
@@ -286,14 +290,15 @@ namespace Tizen.Applications.NotificationEventListener
}
///
- /// Deletes a Notification with appId and uniqueNumber.
+ /// Deletes a notification with appId and uniqueNumber.
///
/// The name of the application you want to delete.
/// The unique number of the notification.
- /// Thrown in case of Invalid parameter.
- /// Thrown in case of Permission deny.
+ /// Thrown in case of an invalid parameter.
+ /// Thrown in case of a permission is denied.
/// Thrown in case of any internal error.
/// http://tizen.org/privilege/notification
+ /// 4
public static void Delete(string appId, int uniqueNumber)
{
Interop.NotificationEventListener.ErrorCode err;
@@ -311,11 +316,12 @@ namespace Tizen.Applications.NotificationEventListener
}
///
- /// Deletes all Notification.
+ /// Deletes all notifications.
///
- /// Thrown in case of Permission deny.
+ /// Thrown in case of a permission is denied.
/// Thrown in case of any internal error.
/// http://tizen.org/privilege/notification
+ /// 4
public static void DeleteAll()
{
Interop.NotificationEventListener.ErrorCode err;
@@ -334,11 +340,12 @@ namespace Tizen.Applications.NotificationEventListener
}
///
- /// Returns the notification list handle.
+ /// Returns the notification list.
///
- /// Thrown in case of Permission deny.
+ /// Thrown in case of a permission is denied.
/// Thrown in case of any internal error.
/// http://tizen.org/privilege/notification
+ /// 4
public static IList GetList()
{
Interop.NotificationEventListener.ErrorCode err;
@@ -346,7 +353,7 @@ namespace Tizen.Applications.NotificationEventListener
IntPtr currentList = IntPtr.Zero;
IList list = new List();
- err = Interop.NotificationEventListener.GetList(NotificationType.Notification, -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");
@@ -370,48 +377,98 @@ namespace Tizen.Applications.NotificationEventListener
}
Interop.NotificationEventListener.NotificationListFree(notificationList);
- notificationList = IntPtr.Zero;
}
- err = Interop.NotificationEventListener.GetList(NotificationType.Ongoing, -1, out notificationList);
+ return list;
+ }
+
+ ///
+ /// Sends occured event from viewer application to the notification owner.
+ ///
+ /// The unique number of the notification.
+ /// Event type on notification.
+ /// Thrown in case of an invalid parameter.
+ /// Thrown in case of a permission is denied.
+ /// Thrown in case of any internal error.
+ /// http://tizen.org/privilege/notification
+ /// 4
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static void SendEvent(int uniqueNumber, UserEventType type)
+ {
+ Interop.NotificationEventListener.ErrorCode err;
+
+ err = Interop.NotificationEventListener.SendEvent(uniqueNumber, (int)type);
if (err != Interop.NotificationEventListener.ErrorCode.None)
{
- throw NotificationEventListenerErrorFactory.GetException(err, "unable to get notification list");
+ throw NotificationEventListenerErrorFactory.GetException(err, "failed to send event");
}
+ }
- if (notificationList != IntPtr.Zero)
+ ///
+ /// Returns NotificationEventArgs by UniqueNumber.
+ ///
+ /// The unique number of the Notification.
+ /// Thrown in case of an invalid parameter.
+ /// Thrown in case of a permission is denied.
+ /// Thrown in case of any internal error.
+ /// http://tizen.org/privilege/notification
+ /// 4
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static NotificationEventArgs GetNotificationEventArgs(int uniqueNumber)
+ {
+ if (uniqueNumber <= 0)
{
- 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);
+ throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "Invalid parameter");
+ }
- currentList = Interop.NotificationEventListener.GetNext(currentList);
+ 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");
}
-
- Interop.NotificationEventListener.NotificationListFree(notificationList);
}
- return list;
+ NotificationEventArgs eventArgs = new NotificationEventArgs();
+ eventArgs = NotificationEventArgsBinder.BindObject(notificationPtr, false);
+
+ return eventArgs;
}
+ ///
+ /// Gets the number of all notifications
+ ///
+ /// The number of all notifications
+ /// Thrown in case of a permission is denied.
+ /// Thrown in case of any internal error.
+ /// http://tizen.org/privilege/notification
+ /// 4
[EditorBrowsable(EditorBrowsableState.Never)]
- public static void SendEvent(int uniqueNumber, UserEventType type)
+ public static int GetAllCount()
{
- Interop.NotificationEventListener.ErrorCode err;
+ int count;
+ Interop.NotificationEventListener.ErrorCode error;
- err = Interop.NotificationEventListener.SendEvent(uniqueNumber, (int)type);
- if (err != Interop.NotificationEventListener.ErrorCode.None)
+ error = Interop.NotificationEventListener.GetAllCount(NotificationType.None, out count);
+ if (error != Interop.NotificationEventListener.ErrorCode.None)
{
- throw NotificationEventListenerErrorFactory.GetException(err, "failed to send event");
+ 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;
}
}
}