[WidgetControl] Add MainAppId, PackageId properties and modify required feature ...
authorHyunho Kang <hhstark.kang@samsung.com>
Mon, 3 Dec 2018 05:56:26 +0000 (14:56 +0900)
committersemun-lee <35090067+semun-lee@users.noreply.github.com>
Mon, 3 Dec 2018 05:56:26 +0000 (14:56 +0900)
* Add get main appid/package id APIS

- (static)GetWidgetMainAppId
- (static)GetWidgetPackageId

Signed-off-by: hyunho <hhstark.kang@samsung.com>
* Fix since tizen for new APIs

5 -> 6

Signed-off-by: hyunho <hhstark.kang@samsung.com>
* Modify get widget main appid/pacakgeid to property

Signed-off-by: hyunho <hhstark.kang@samsung.com>
* Add feature documentation

Signed-off-by: hyunho <hhstark.kang@samsung.com>
* Add not supported exception for some memebers

Signed-off-by: hyunho <hhstark.kang@samsung.com>
src/Tizen.Applications.WidgetControl/Interop/Interop.WidgetService.cs
src/Tizen.Applications.WidgetControl/Tizen.Applications/WidgetControl.cs [changed mode: 0755->0644]

index 3be41ed..c893a23 100755 (executable)
@@ -102,5 +102,11 @@ internal static partial class Interop
 
         [DllImport(Libraries.WidgetService, EntryPoint = "widget_service_get_widget_list_by_pkgid")]
         internal static extern ErrorCode GetWidgetListByPkgId(string pkgId, WidgetListCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.WidgetService, EntryPoint = "widget_service_get_main_app_id")]
+        internal static extern string GetWidgetMainAppId(string widgetId);
+
+        [DllImport(Libraries.WidgetService, EntryPoint = "widget_service_get_package_id")]
+        internal static extern string GetWidgetPackageId(string widgetId);
     }
 }
old mode 100755 (executable)
new mode 100644 (file)
index fe4a3d5..21606bb
@@ -52,7 +52,9 @@ namespace Tizen.Applications
             /// Gets the widget content.
             /// </summary>
             /// <since_tizen> 3 </since_tizen>
+            /// <feature>http://tizen.org/feature/shell.appwidget</feature>
             /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
+            /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
             public Bundle GetContent()
             {
                 IntPtr h;
@@ -63,9 +65,10 @@ namespace Tizen.Applications
                 {
                     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.NotSupported:
+                        throw new NotSupportedException("Not supported");
                 }
 
                 return new Bundle(new SafeBundleHandle(h, true));
@@ -77,9 +80,11 @@ namespace Tizen.Applications
             /// <since_tizen> 3 </since_tizen>
             /// <param name="content">Content to be changed.</param>
             /// <param name="force"> True if you want to update your widget even if the provider is paused, otherwise false.</param>
+            /// <feature>http://tizen.org/feature/shell.appwidget</feature>
             /// <exception cref="ArgumentException">Thrown when failed because of an invalid argument.</exception>
             /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
             /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
+            /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
             public void ChangeContent(Bundle content, bool force)
             {
                 Interop.WidgetService.ErrorCode err = Interop.WidgetService.UpdateContent(_widgetId, Id, content.SafeBundleHandle, force ? 1 : 0);
@@ -100,6 +105,9 @@ namespace Tizen.Applications
 
                     case Interop.WidgetService.ErrorCode.PermissionDenied:
                         throw new UnauthorizedAccessException();
+
+                    case Interop.WidgetService.ErrorCode.NotSupported:
+                        throw new NotSupportedException("Not supported");
                 }
             }
 
@@ -107,9 +115,11 @@ namespace Tizen.Applications
             /// Changes the update period for the widget instance.
             /// </summary>
             /// <since_tizen> 3 </since_tizen>
+            /// <feature>http://tizen.org/feature/shell.appwidget</feature>
             /// <exception cref="ArgumentException">Thrown when failed because of an invalid argument.</exception>
             /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
             /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
+            /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
             public void ChangePeriod(double period)
             {
                 Interop.WidgetService.ErrorCode err = Interop.WidgetService.ChangePeriod(_widgetId, Id, period);
@@ -127,6 +137,9 @@ namespace Tizen.Applications
 
                     case Interop.WidgetService.ErrorCode.PermissionDenied:
                         throw new UnauthorizedAccessException();
+
+                    case Interop.WidgetService.ErrorCode.NotSupported:
+                        throw new NotSupportedException("Not supported");
                 }
             }
         }
@@ -255,9 +268,11 @@ namespace Tizen.Applications
         /// <since_tizen> 3 </since_tizen>
         /// <param name="pkgId">Package ID.</param>
         /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
+        /// <feature>http://tizen.org/feature/shell.appwidget</feature>
         /// <exception cref="ArgumentException">Thrown when failed because of an invalid argument.</exception>
         /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
         /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
+        /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
         public static WidgetControl[] CreateAll(string pkgId)
         {
             List<WidgetControl> list = new List<WidgetControl>();
@@ -277,6 +292,9 @@ namespace Tizen.Applications
 
                 case Interop.WidgetService.ErrorCode.PermissionDenied:
                     throw new UnauthorizedAccessException();
+
+                case Interop.WidgetService.ErrorCode.NotSupported:
+                    throw new NotSupportedException("Not supported");
             }
 
             return list.ToArray();
@@ -287,9 +305,11 @@ namespace Tizen.Applications
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
         /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
+        /// <feature>http://tizen.org/feature/shell.appwidget</feature>
         /// <exception cref="ArgumentException">Thrown when failed because of an invalid argument.</exception>
         /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
         /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
+        /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
         public static string[] GetWidgetIds(string pkgId)
         {
             List<string> list = new List<string>();
@@ -309,12 +329,71 @@ namespace Tizen.Applications
 
                 case Interop.WidgetService.ErrorCode.PermissionDenied:
                     throw new UnauthorizedAccessException();
+
+                case Interop.WidgetService.ErrorCode.NotSupported:
+                    throw new NotSupportedException("Not supported");
             }
 
             return list.ToArray();
         }
 
         /// <summary>
+        /// Gets main appid of the widget.
+        /// </summary>
+        /// <since_tizen> 6 </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 privilege to access this method.</exception>
+        /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
+        public string MainAppId
+        {
+            get
+            {
+                string str = Interop.WidgetService.GetWidgetMainAppId(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");
+                }
+
+                return str;
+            }
+        }
+
+        /// <summary>
+        /// Gets package ID of the widget.
+        /// </summary>
+        /// <since_tizen> 6 </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 privilege to access this method.</exception>
+        /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
+        public string PackageId
+        {
+            get
+            {
+                string str = Interop.WidgetService.GetWidgetPackageId(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");
+                }
+
+                return str;
+            }
+        }
+
+        /// <summary>
         /// The widget ID.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
@@ -325,11 +404,26 @@ namespace Tizen.Applications
         /// </summary>
         /// <since_tizen> 3 </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 privilege to access this method.</exception>
+        /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
         public bool IsNoDisplay
         {
             get
             {
-                if (Interop.WidgetService.GetNoDisplay(Id) != 0)
+                int ret = Interop.WidgetService.GetNoDisplay(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");
+                }
+
+                if (ret != 0)
                     return true;
 
                 return false;
@@ -340,8 +434,10 @@ namespace Tizen.Applications
         ///  The event handler for a created widget instance.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
+        /// <feature>http://tizen.org/feature/shell.appwidget</feature>
         /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
         /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
+        /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
         public event EventHandler<WidgetLifecycleEventArgs> Created
         {
             add
@@ -360,8 +456,10 @@ namespace Tizen.Applications
         /// The event handler for a resumed widget instance.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
+        /// <feature>http://tizen.org/feature/shell.appwidget</feature>
         /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
         /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
+        /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
         public event EventHandler<WidgetLifecycleEventArgs> Resumed
         {
             add
@@ -380,8 +478,10 @@ namespace Tizen.Applications
         /// The event handler for a paused widget instance.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
+        /// <feature>http://tizen.org/feature/shell.appwidget</feature>
         /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
         /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
+        /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
         public event EventHandler<WidgetLifecycleEventArgs> Paused
         {
             add
@@ -400,8 +500,10 @@ namespace Tizen.Applications
         /// The event handler for a destroyed widget instance.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
+        /// <feature>http://tizen.org/feature/shell.appwidget</feature>
         /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
         /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
+        /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
         public event EventHandler<WidgetLifecycleEventArgs> Destroyed
         {
             add
@@ -438,6 +540,7 @@ namespace Tizen.Applications
         /// Gets the objects for widget instance information.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
+        /// <feature>http://tizen.org/feature/shell.appwidget</feature>
         /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
         /// <exception cref="NotSupportedException">Thrown when the API is not supported in this device.</exception>
         /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
@@ -469,8 +572,10 @@ namespace Tizen.Applications
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
         /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
+        /// <feature>http://tizen.org/feature/shell.appwidget</feature>
         /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
         /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
+        /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
         public IEnumerable<Scale> GetScales()
         {
             IntPtr wPtr;
@@ -500,6 +605,9 @@ namespace Tizen.Applications
 
                 case Interop.WidgetService.ErrorCode.PermissionDenied:
                     throw new UnauthorizedAccessException();
+
+                case Interop.WidgetService.ErrorCode.NotSupported:
+                    throw new NotSupportedException();
             }
             w = new int[cnt1];
             Marshal.Copy(wPtr, w, 0, cnt1);
@@ -553,13 +661,29 @@ namespace Tizen.Applications
         /// <since_tizen> 3 </since_tizen>
         /// <param name="lang">Language.</param>
         /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
+        /// <feature>http://tizen.org/feature/shell.appwidget</feature>
         /// <exception cref="ArgumentNullException">Thrown when the argument is null.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
+        /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
         public string GetName(string lang)
         {
             if (lang == null)
                 throw new ArgumentNullException();
 
-            return Interop.WidgetService.GetName(Id, lang);
+            string str = Interop.WidgetService.GetName(Id, lang);
+            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();
+            }
+
+            return str;
         }
 
         /// <summary>
@@ -568,21 +692,40 @@ namespace Tizen.Applications
         /// <since_tizen> 3 </since_tizen>
         /// <param name="lang">Language.</param>
         /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
+        /// <feature>http://tizen.org/feature/shell.appwidget</feature>
         /// <exception cref="ArgumentNullException">Thrown when the argument is null.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
+        /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
         public string GetIconPath(string lang)
         {
             if (lang == null)
                 throw new ArgumentNullException();
 
             string pkgId = Interop.WidgetService.GetPkgId(Id);
+            string str = Interop.WidgetService.GetIcon(pkgId, lang);
+            Interop.WidgetService.ErrorCode err =
+                    (Interop.WidgetService.ErrorCode)Internals.Errors.ErrorFacts.GetLastResult();
 
-            return Interop.WidgetService.GetIcon(pkgId, lang);
+            switch (err)
+            {
+                case Interop.WidgetService.ErrorCode.PermissionDenied:
+                    throw new UnauthorizedAccessException();
+
+                case Interop.WidgetService.ErrorCode.NotSupported:
+                    throw new NotSupportedException();
+            }
+
+            return str;
         }
 
         /// <summary>
         /// Releases all the resources used by the WidgetControl class.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
+        /// <feature>http://tizen.org/feature/shell.appwidget</feature>
+        /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
+        /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
         public void Dispose()
         {
             Dispose(true);
@@ -628,6 +771,9 @@ namespace Tizen.Applications
 
                     case Interop.WidgetService.ErrorCode.PermissionDenied:
                         throw new UnauthorizedAccessException();
+
+                    case Interop.WidgetService.ErrorCode.NotSupported:
+                        throw new NotSupportedException();
                 }
             }
 
@@ -661,6 +807,9 @@ namespace Tizen.Applications
 
                     case Interop.WidgetService.ErrorCode.NotExist:
                         throw new InvalidOperationException("Event handler is not exist");
+
+                    case Interop.WidgetService.ErrorCode.NotSupported:
+                        throw new NotSupportedException();
                 }
                 _onLifecycleCallback = null;
             }