[WidgetControl] Add property for setup app id (#1710)
authorsukhyungkang <35091460+sukhyungkang@users.noreply.github.com>
Fri, 26 Jun 2020 00:31:31 +0000 (09:31 +0900)
committerGitHub <noreply@github.com>
Fri, 26 Jun 2020 00:31:31 +0000 (09:31 +0900)
Signed-off-by: SukHyung, Kang <shine.kang@samsung.com>
src/Tizen.Applications.WidgetControl/Interop/Interop.WidgetService.cs
src/Tizen.Applications.WidgetControl/Tizen.Applications/WidgetControl.cs [changed mode: 0644->0755]

index c893a2382a7fd18ae2def71bfc1a50d82f6f6c52..10536d0831b5f2adc2a9f2cdaca1f2a02931d15d 100755 (executable)
@@ -108,5 +108,8 @@ internal static partial class Interop
 
         [DllImport(Libraries.WidgetService, EntryPoint = "widget_service_get_package_id")]
         internal static extern string GetWidgetPackageId(string widgetId);
+
+        [DllImport(Libraries.WidgetService, EntryPoint = "widget_service_get_app_id_of_setup_app")]
+        internal static extern string GetSetupAppId(string widgetId);
     }
 }
old mode 100644 (file)
new mode 100755 (executable)
index 220a4f8..423a787
@@ -435,6 +435,47 @@ namespace Tizen.Applications
             }
         }
 
+        /// <summary>
+        /// Gets setup app ID of the widget.
+        /// </summary>
+        /// <since_tizen> 8 </since_tizen>
+        /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
+        /// <feature>http://tizen.org/feature/shell.appwidget</feature>
+        /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the required privileges to access this method.</exception>
+        /// <exception cref="NotSupportedException">Thrown when the required features are not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
+        public string SetupAppId
+        {
+            get
+            {
+                string str = Interop.WidgetService.GetSetupAppId(Id);
+                Interop.WidgetService.ErrorCode err =
+                    (Interop.WidgetService.ErrorCode)Internals.Errors.ErrorFacts.GetLastResult();
+                switch (err)
+                {
+                    case Interop.WidgetService.ErrorCode.PermissionDenied:
+                        throw new UnauthorizedAccessException();
+
+                    case Interop.WidgetService.ErrorCode.NotSupported:
+                        throw new NotSupportedException("Not supported");
+
+                    case Interop.WidgetService.ErrorCode.InvalidParameter:
+                        throw new InvalidOperationException("Invalid parameter at unmanaged code");
+
+                    case Interop.WidgetService.ErrorCode.IoError:
+                        throw new InvalidOperationException("Failed to access DB");
+
+                    case Interop.WidgetService.ErrorCode.Fault:
+                        throw new InvalidOperationException("Failed to access DB");
+
+                    case Interop.WidgetService.ErrorCode.NotExist:
+                        throw new InvalidOperationException("Not exist in DB");
+                }
+
+                return str;
+            }
+        }
+
         /// <summary>
         ///  The event handler for a created widget instance.
         /// </summary>