/// <summary> /// Registers a callback function to listen requests from the applications. /// </summary> /// <since_tizen> 4 </since_tizen> /// <param name="deletedEvent">The callback function pointer that is invoked when Delete() is requested.</param> /// <feature>http://tizen.org/feature/shortcut</feature> /// <privilege>http://tizen.org/privilege/shortcut</privilege> /// <remarks> /// Previous registered delegate function should be unregistered. /// </remarks> /// <exception cref="ArgumentException">Thrown when an argument is invalid.</exception> /// <exception cref="UnauthorizedAccessException">Thrown in case the permission is denied.</exception> /// <exception cref="NotSupportedException">Thrown when the shortcut is not supported.</exception> /// <exception cref="OutOfMemoryException">Thrown in case of out of memory.</exception> /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception> public static void RegisterEventHandler(ShortcutDeleted deletedEvent) { if (shortcutDeleteCallback == null) { shortcutDeleteCallback = new Interop.Shortcut.DeleteCallback(DeleteCallback); Interop.Shortcut.ErrorCode err = Interop.Shortcut.SetShortcutDeleteCallback(shortcutDeleteCallback, IntPtr.Zero); if (err != Interop.Shortcut.ErrorCode.None) { shortcutDeleteCallback = null; throw ShortcutErrorFactory.GetException(err, "unable to register callback"); } shortcutDeleted = deletedEvent; } else { throw ShortcutErrorFactory.GetException(Interop.Shortcut.ErrorCode.InvalidParameter, null); } }
/// <summary> /// Unregisters a callback for the shortcut request. /// </summary> /// <since_tizen> 4 </since_tizen> /// <param name="deletedEvent">The callback function pointer that is used for RegisterCallback.</param> /// <feature>http://tizen.org/feature/shortcut</feature> /// <privilege>http://tizen.org/privilege/shortcut</privilege> /// <exception cref="ArgumentException">Thrown when an argument is invalid.</exception> /// <exception cref="UnauthorizedAccessException">Thrown in case the permission is denied.</exception> /// <exception cref="NotSupportedException">Thrown when the shortcut is not supported.</exception> public static void UnregisterEventHandler(ShortcutDeleted deletedEvent) { if (shortcutDeleted != null && shortcutDeleted.Equals(deletedEvent)) { shortcutDeleted = null; if (shortcutDeleteCallback != null) { Interop.Shortcut.UnsetShortcutDeleteCallback(); shortcutDeleteCallback = null; int err = ErrorFacts.GetLastResult(); if (err != (int)Interop.Shortcut.ErrorCode.None) { throw ShortcutErrorFactory.GetException((Interop.Shortcut.ErrorCode)err, "unable to unregister callback"); } } } else { throw ShortcutErrorFactory.GetException(Interop.Shortcut.ErrorCode.InvalidParameter, null); } }