From: mk5004lee <37102375+mk5004lee@users.noreply.github.com> Date: Fri, 5 Oct 2018 00:58:57 +0000 (+0900) Subject: [Shortcut] Update add, delete func (#489) X-Git-Tag: accepted/tizen/4.0/unified/20181008.135859~1^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cddfe6f50ab1b5325f144f1dd99579ea100c34c7;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [Shortcut] Update add, delete func (#489) - use sync api Signed-off-by: mk5004.lee --- diff --git a/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/ShortcutManager.cs b/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/ShortcutManager.cs index 1ceb5ec..f847fd0 100755 --- a/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/ShortcutManager.cs +++ b/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/ShortcutManager.cs @@ -26,12 +26,6 @@ namespace Tizen.Applications.Shortcut { private const string LogTag = "Tizen.Applications.Shortcut"; - private static Interop.Shortcut.ResultCallback shortcutAddResult = null; - - private static Interop.Shortcut.ResultCallback widgetAddResult = null; - - private static Interop.Shortcut.ResultCallback shortcutDeleteResult = null; - /// /// Adds a shortcut on the home-screen. /// @@ -61,12 +55,7 @@ namespace Tizen.Applications.Shortcut type = 1; } - if (shortcutAddResult == null) - { - shortcutAddResult = new Interop.Shortcut.ResultCallback(ShortcutAddResultCallback); - } - - err = Interop.Shortcut.AddToHome(shortcut.ShortcutName, type, shortcut.Uri, shortcut.IconPath, Convert.ToInt32(shortcut.IsAllowDuplicate), shortcutAddResult, IntPtr.Zero); + err = Interop.Shortcut.AddToHome(shortcut.ShortcutName, type, shortcut.Uri, shortcut.IconPath, Convert.ToInt32(shortcut.IsAllowDuplicate)); if (err != Interop.Shortcut.ErrorCode.None) { throw ShortcutErrorFactory.GetException(err, "unable to add shortcut"); @@ -101,12 +90,7 @@ namespace Tizen.Applications.Shortcut try { - if (widgetAddResult == null) - { - widgetAddResult = new Interop.Shortcut.ResultCallback(WidgetAddResultCallback); - } - - err = Interop.Shortcut.AddToWidget(shortcut.ShortcutName, shortcut.WidgetSize, shortcut.WidgetId, shortcut.IconPath, shortcut.Period, Convert.ToInt32(shortcut.IsAllowDuplicate), widgetAddResult, IntPtr.Zero); + err = Interop.Shortcut.AddToWidget(shortcut.ShortcutName, shortcut.WidgetSize, shortcut.WidgetId, shortcut.IconPath, shortcut.Period, Convert.ToInt32(shortcut.IsAllowDuplicate)); if (err != Interop.Shortcut.ErrorCode.None) { throw ShortcutErrorFactory.GetException(err, "unable to add widget"); @@ -141,12 +125,7 @@ namespace Tizen.Applications.Shortcut try { - if (shortcutDeleteResult == null) - { - shortcutDeleteResult = new Interop.Shortcut.ResultCallback(DeleteResultCallback); - } - - err = Interop.Shortcut.Delete(shortcutName, shortcutDeleteResult, IntPtr.Zero); + err = Interop.Shortcut.Delete(shortcutName); if (err != Interop.Shortcut.ErrorCode.None) { throw ShortcutErrorFactory.GetException(err, "unable to delete shortcut"); @@ -186,35 +165,5 @@ namespace Tizen.Applications.Shortcut throw ShortcutErrorFactory.GetException(Interop.Shortcut.ErrorCode.IoError, e.Message); } } - - private static int ShortcutAddResultCallback(int ret, IntPtr data) - { - if (ret != (int)Interop.Shortcut.ErrorCode.None) - { - throw ShortcutErrorFactory.GetException((Interop.Shortcut.ErrorCode)ret, "unable to add shortcut"); - } - - return 0; - } - - private static int WidgetAddResultCallback(int ret, IntPtr data) - { - if (ret != (int)Interop.Shortcut.ErrorCode.None) - { - throw ShortcutErrorFactory.GetException((Interop.Shortcut.ErrorCode)ret, "unable to add widget"); - } - - return 0; - } - - private static int DeleteResultCallback(int ret, IntPtr data) - { - if (ret != (int)Interop.Shortcut.ErrorCode.None) - { - throw ShortcutErrorFactory.GetException((Interop.Shortcut.ErrorCode)ret, "unable to delete shortcut"); - } - - return 0; - } - } + } } diff --git a/src/Tizen.Applications.Shortcut/interop/Interop.Shortcut.cs b/src/Tizen.Applications.Shortcut/interop/Interop.Shortcut.cs index 9fa759d..8a1f3ea 100755 --- a/src/Tizen.Applications.Shortcut/interop/Interop.Shortcut.cs +++ b/src/Tizen.Applications.Shortcut/interop/Interop.Shortcut.cs @@ -97,14 +97,14 @@ internal static partial class Interop COMM = -0x01160000 | 0x40 } - [DllImport(Libraries.Shortcut, EntryPoint = "shortcut_add_to_home")] - internal static extern ErrorCode AddToHome(string name, int type, string uri, string icon, int dubplicate, ResultCallback result, IntPtr data); + [DllImport(Libraries.Shortcut, EntryPoint = "shortcut_add_to_home_sync")] + internal static extern ErrorCode AddToHome(string name, int type, string uri, string icon, int dubplicate); - [DllImport(Libraries.Shortcut, EntryPoint = "shortcut_add_to_home_widget")] - internal static extern ErrorCode AddToWidget(string name, ShortcutWidgetSize size, string widgetId, string icon, double period, int dubplicate, ResultCallback result, IntPtr data); + [DllImport(Libraries.Shortcut, EntryPoint = "shortcut_add_to_home_widget_sync")] + internal static extern ErrorCode AddToWidget(string name, ShortcutWidgetSize size, string widgetId, string icon, double period, int dubplicate); - [DllImport(Libraries.Shortcut, EntryPoint = "shortcut_remove_from_home")] - internal static extern ErrorCode Delete(string name, ResultCallback result, IntPtr data); + [DllImport(Libraries.Shortcut, EntryPoint = "shortcut_remove_from_home_sync")] + internal static extern ErrorCode Delete(string name); [DllImport(Libraries.Shortcut, EntryPoint = "shortcut_get_list")] internal static extern ErrorCode GetList(string name, ListCallback list, IntPtr data);