X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FTizen.Applications.NotificationEventListener%2FTizen.Applications.NotificationEventListener%2FNotificationListenerManager.cs;h=e6c138221bd4cce75335d863de079fd226caf62e;hb=8446bec8072fccf008bf09828468d44fd11bfc54;hp=5f02395dff4915df35d040a18a97a6d062f24939;hpb=4aff8c662dca62825b196d3417a0c5859c8a6369;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..e6c1382 100755
--- a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationListenerManager.cs
+++ b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationListenerManager.cs
@@ -21,12 +21,15 @@ namespace Tizen.Applications.NotificationEventListener
using System.ComponentModel;
using System.Runtime.InteropServices;
+ using Tizen.Internals;
+
///
/// 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";
@@ -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
{
@@ -61,13 +65,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 +112,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 +159,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 +293,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 +319,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 +343,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 +356,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 +380,122 @@ 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)
+ [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)
{
- currentList = notificationList;
- while (currentList != IntPtr.Zero)
- {
- IntPtr notification;
- NotificationEventArgs eventargs = new NotificationEventArgs();
+ throw NotificationEventListenerErrorFactory.GetException(err, "failed to set checked");
+ }
+ }
- notification = Interop.NotificationEventListener.GetData(currentList);
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static void SendEventWithNotification(NotificationEventArgs eventargs, UserEventType type)
+ {
+ Interop.NotificationEventListener.ErrorCode err;
- eventargs = NotificationEventArgsBinder.BindObject(notification, false);
+ err = Interop.NotificationEventListener.SendEventWithNotification(eventargs.Handle, (int)type);
+ if (err != Interop.NotificationEventListener.ErrorCode.None)
+ {
+ throw NotificationEventListenerErrorFactory.GetException(err, "failed to send event");
+ }
+ }
- list.Add(eventargs);
+ ///
+ /// 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)
+ {
+ 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;
}
}
}