/// 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 notification or to clear notifications.
+ /// 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";
}
/// <summary>
- /// Registers a callback for notification insert event.
+ /// Event handler for notification insert event.
/// </summary>
- /// <exception cref="ArgumentException">Thrown in case of Invalid parameter.</exception>
- /// <exception cref="UnauthorizedAccessException"> Thrown in case of Permission deny.</exception>
+ /// <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>
- public static event EventHandler<NotificationEventArgs> NotificationAddEventHandler
+ /// <since_tizen> 4 </since_tizen>
+ public static event EventHandler<NotificationEventArgs> Added
{
add
{
}
/// <summary>
- /// Registers a callback for notification update event.
+ /// Event handler for notification update event.
/// </summary>
- /// <exception cref="ArgumentException">Thrown in case of Invalid parameter.</exception>
- /// <exception cref="UnauthorizedAccessException"> Thrown in case of Permission deny.</exception>
+ /// <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>
- public static event EventHandler<NotificationEventArgs> NotificationUpdateEventHandler
+ /// <since_tizen> 4 </since_tizen>
+ public static event EventHandler<NotificationEventArgs> Updated
{
add
{
}
/// <summary>
- /// Registers a callback for notification delete event.
+ /// Event handler for notification delete event.
/// </summary>
- /// <exception cref="ArgumentException">Thrown in case of Invalid parameter.</exception>
- /// <exception cref="UnauthorizedAccessException"> Thrown in case of Permission deny.</exception>
+ /// <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>
- public static event EventHandler<NotificationDeleteEventArgs> NotificationDeleteEventHandler
+ /// <since_tizen> 4 </since_tizen>
+ public static event EventHandler<NotificationDeleteEventArgs> Deleted
{
add
{
}
/// <summary>
- /// Deletes a Notification with appId and uniqueNumber.
+ /// Deletes a notification with appId and uniqueNumber.
/// </summary>
/// <param name="appId">The name of the application you want to delete.</param>
/// <param name="uniqueNumber">The unique number of the notification.</param>
- /// <exception cref="ArgumentException">Thrown in case of Invalid parameter.</exception>
- /// <exception cref="UnauthorizedAccessException"> Thrown in case of Permission deny.</exception>
+ /// <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>
+ /// <since_tizen> 4 </since_tizen>
public static void Delete(string appId, int uniqueNumber)
{
Interop.NotificationEventListener.ErrorCode err;
}
/// <summary>
- /// Deletes all Notification.
+ /// Deletes all notifications.
/// </summary>
- /// <exception cref="UnauthorizedAccessException"> Thrown in case of Permission deny.</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>
+ /// <since_tizen> 4 </since_tizen>
public static void DeleteAll()
{
Interop.NotificationEventListener.ErrorCode err;
}
/// <summary>
- /// Returns the notification list handle.
+ /// Returns the notification list.
/// </summary>
- /// <exception cref="UnauthorizedAccessException"> Thrown in case of Permission deny.</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>
+ /// <since_tizen> 4 </since_tizen>
public static IList<NotificationEventArgs> GetList()
{
Interop.NotificationEventListener.ErrorCode err;
IntPtr currentList = IntPtr.Zero;
IList<NotificationEventArgs> list = new List<NotificationEventArgs>();
- 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");
}
Interop.NotificationEventListener.NotificationListFree(notificationList);
- notificationList = IntPtr.Zero;
}
- err = Interop.NotificationEventListener.GetList(NotificationType.Ongoing, -1, out notificationList);
+ return list;
+ }
+
+ /// <summary>
+ /// Sends occured event from viewer application to the notification owner.
+ /// </summary>
+ /// <param name="uniqueNumber">The unique number of the notification.</param>
+ /// <param name="type">Event type on 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>
+ /// <since_tizen> 4 </since_tizen>
+ [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)
+ /// <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>
+ /// <since_tizen> 4 </since_tizen>
+ [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;
}
+ /// <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 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;
}
}
}