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";
private static Interop.NotificationEventListener.ChangedCallback callback;
+ [NativeStruct("notification_op", Include="notification_type.h", PkgConfig="notification")]
[StructLayout(LayoutKind.Sequential)]
private struct NotificationOperation
{
/// <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
/// <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
/// <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
/// <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;
/// <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;
/// <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);
- 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");
/// <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)
{
}
}
+ [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>
/// <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)
{
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;
+ }
}
}