[Shortcut] Update add, delete func (#489)
authormk5004lee <37102375+mk5004lee@users.noreply.github.com>
Fri, 5 Oct 2018 00:58:57 +0000 (09:58 +0900)
committerWonYoung Choi <wy80.choi@samsung.com>
Fri, 5 Oct 2018 00:58:57 +0000 (09:58 +0900)
- use sync api

Signed-off-by: mk5004.lee <mk5004.lee@samsung.com>
src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/ShortcutManager.cs
src/Tizen.Applications.Shortcut/interop/Interop.Shortcut.cs

index 1ceb5ec..f847fd0 100755 (executable)
@@ -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;
-
         /// <summary>
         /// Adds a shortcut on the home-screen.
         /// </summary>
@@ -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;
-        }
-    }
+   }
 }
index 9fa759d..8a1f3ea 100755 (executable)
@@ -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);