Fix comment build warning from WidgetControl
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.WidgetControl / Tizen.Applications / WidgetControl.cs
index 59da412..c4beb30 100755 (executable)
 using System;
 using System.Collections.Generic;
 using Tizen.Applications;
+using System.Runtime.InteropServices;
 
 namespace Tizen.Applications
 {
     /// <summary>
-    /// Class for receiving widget events and sending data to widget.
+    /// The class for receiving widget events and sending data to the widget.
     /// </summary>
     public class WidgetControl : IDisposable
     {
+        private const string LogTag = "Tizen.Applications.WidgetControl";
         /// <summary>
-        /// Class for widget instance.
+        /// Class for the widget instance.
         /// </summary>
         public class Instance
         {
             private string _widgetId;
 
-            /// <summary>
-            /// Constructor.
-            /// </summary>
-            /// <param name="widgetId">Widget ID</param>
-            public Instance(string widgetId)
+            internal Instance(string widgetId)
             {
                 _widgetId = widgetId;
             }
 
             /// <summary>
-            /// Widget ID.
+            /// The widget ID.
             /// </summary>
+            /// <since_tizen> 3 </since_tizen>
             public string Id { get; internal set; }
 
             /// <summary>
-            /// Gets widget content.
+            /// Gets the widget content.
             /// </summary>
-            /// <exception cref="InvalidOperationException">Thrown in case of failed conditions</exception>
+            /// <since_tizen> 3 </since_tizen>
+            /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
             public Bundle GetContent()
             {
                 IntPtr h;
@@ -71,11 +71,12 @@ namespace Tizen.Applications
             /// <summary>
             /// Changes the content for the widget instance.
             /// </summary>
-            /// <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>
-            /// <exception cref="ArgumentException">Thrown when failed because of invalid argument</exception>
-            /// <exception cref="InvalidOperationException">Thrown in case of failed conditions</exception>
-            /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access this method</exception>
+            /// <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>
+            /// <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>
             public void ChangeContent(Bundle content, bool force)
             {
                 Interop.WidgetService.ErrorCode err = Interop.WidgetService.UpdateContent(_widgetId, Id, content.SafeBundleHandle, force ? 1 : 0);
@@ -102,9 +103,10 @@ namespace Tizen.Applications
             /// <summary>
             /// Changes the update period for the widget instance.
             /// </summary>
-            /// <exception cref="ArgumentException">Thrown when failed because of invalid argument</exception>
-            /// <exception cref="InvalidOperationException">Thrown in case of failed conditions</exception>
-            /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access this method</exception>
+            /// <since_tizen> 3 </since_tizen>
+            /// <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>
             public void ChangePeriod(double period)
             {
                 Interop.WidgetService.ErrorCode err = Interop.WidgetService.ChangePeriod(_widgetId, Id, period);
@@ -127,13 +129,19 @@ namespace Tizen.Applications
         }
 
         /// <summary>
-        /// Class for widget size information.
+        /// The class for the widget size information.
         /// </summary>
         public class Scale
         {
+
+            internal Scale()
+            {
+            }
+
             /// <summary>
-            /// Enumeration for types of widget size
+            /// Enumeration for the types of widget size.
             /// </summary>
+            /// <since_tizen> 3 </since_tizen>
             public enum SizeType : int
             {
                 /// <summary>
@@ -206,21 +214,25 @@ namespace Tizen.Applications
             /// <summary>
             /// Widget width.
             /// </summary>
+            /// <since_tizen> 3 </since_tizen>
             public int Width { get; internal set; }
 
             /// <summary>
-            /// Widget height.
+            ///Widget height.
             /// </summary>
+            /// <since_tizen> 3 </since_tizen>
             public int Height { get; internal set; }
 
             /// <summary>
-            /// The path for widget preview image file.
+            /// The path for the widget preview image file.
             /// </summary>
+            /// <since_tizen> 3 </since_tizen>
             public string PreviewImagePath { get; internal set; }
 
             /// <summary>
             /// The size type of the widget.
             /// </summary>
+            /// <since_tizen> 3 </since_tizen>
             public SizeType Type { get; internal set; }
         }
 
@@ -233,14 +245,15 @@ namespace Tizen.Applications
         private static IList<WidgetControl> s_eventObjects = new List<WidgetControl>();
 
         /// <summary>
-        /// Factory method for WidgetControl.
-        /// It will create all objects of WidgetControl base on package ID.
+        /// Factory method for the WidgetControl.
+        /// It will create all the objects of WidgetControl based on the package ID.
         /// </summary>
-        /// <param name="pkgId">Parkage ID</param>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="pkgId">Package ID.</param>
         /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
-        /// <exception cref="ArgumentException">Thrown when failed because of invalid argument</exception>
-        /// <exception cref="InvalidOperationException">Thrown in case of failed conditions</exception>
-        /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access this method</exception>
+        /// <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>
         public static WidgetControl[] CreateAll(string pkgId)
         {
             List<WidgetControl> list = new List<WidgetControl>();
@@ -266,12 +279,13 @@ namespace Tizen.Applications
         }
 
         /// <summary>
-        /// Gets all widget IDs by package ID.
+        /// Gets all the widget IDs by the package ID.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
-        /// <exception cref="ArgumentException">Thrown when failed because of invalid argument</exception>
-        /// <exception cref="InvalidOperationException">Thrown in case of failed conditions</exception>
-        /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access this method</exception>
+        /// <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>
         public static string[] GetWidgetIds(string pkgId)
         {
             List<string> list = new List<string>();
@@ -297,13 +311,15 @@ namespace Tizen.Applications
         }
 
         /// <summary>
-        /// Widget ID.
+        /// The widget ID.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public string Id { get; internal set; }
 
         /// <summary>
-        /// The flag value for "nodisplay"
+        /// The flag value for "nodisplay".
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
         public bool IsNoDisplay
         {
@@ -317,10 +333,11 @@ namespace Tizen.Applications
         }
 
         /// <summary>
-        /// Event handler for created widget instance.
+        ///  The event handler for a created widget instance.
         /// </summary>
-        /// <exception cref="InvalidOperationException">Thrown in case of failed conditions</exception>
-        /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access this method</exception>
+        /// <since_tizen> 3 </since_tizen>
+        /// <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>
         public event EventHandler<WidgetLifecycleEventArgs> Created
         {
             add
@@ -336,10 +353,11 @@ namespace Tizen.Applications
         }
 
         /// <summary>
-        /// Event handler for resumed widget instance.
+        /// The event handler for a resumed widget instance.
         /// </summary>
-        /// <exception cref="InvalidOperationException">Thrown in case of failed conditions</exception>
-        /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access this method</exception>
+        /// <since_tizen> 3 </since_tizen>
+        /// <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>
         public event EventHandler<WidgetLifecycleEventArgs> Resumed
         {
             add
@@ -355,10 +373,11 @@ namespace Tizen.Applications
         }
 
         /// <summary>
-        /// Event handler for paused widget instance.
+        /// The event handler for a paused widget instance.
         /// </summary>
-        /// <exception cref="InvalidOperationException">Thrown in case of failed conditions</exception>
-        /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access this method</exception>
+        /// <since_tizen> 3 </since_tizen>
+        /// <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>
         public event EventHandler<WidgetLifecycleEventArgs> Paused
         {
             add
@@ -374,10 +393,11 @@ namespace Tizen.Applications
         }
 
         /// <summary>
-        /// Event handler for destroyed widget instance.
+        /// The event handler for a destroyed widget instance.
         /// </summary>
-        /// <exception cref="InvalidOperationException">Thrown in case of failed conditions</exception>
-        /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access this method</exception>
+        /// <since_tizen> 3 </since_tizen>
+        /// <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>
         public event EventHandler<WidgetLifecycleEventArgs> Destroyed
         {
             add
@@ -393,9 +413,10 @@ namespace Tizen.Applications
         }
 
         /// <summary>
-        /// A constructor of WidgetControl object
+        /// The constructor of the WidgetControl object.
         /// </summary>
-        /// <param name="widgetId">widget id.</param>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="widgetId">Widget ID.</param>
         public WidgetControl(string widgetId)
         {
             Id = widgetId;
@@ -410,11 +431,12 @@ namespace Tizen.Applications
         }
 
         /// <summary>
-        /// Gets objects for widget instance information.
+        /// Gets the objects for widget instance information.
         /// </summary>
-        /// <exception cref="InvalidOperationException">Thrown in case of failed conditions</exception>
-        /// <exception cref="NotSupportedException">Thrown when API is not supported in this device</exception>
-        /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access this method</exception>
+        /// <since_tizen> 3 </since_tizen>
+        /// <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>
         public IEnumerable<Instance> GetInstances()
         {
             IList<Instance> instances = new List<Instance>();
@@ -439,21 +461,30 @@ namespace Tizen.Applications
         }
 
         /// <summary>
-        /// Gets objects for widget scale information.
+        /// Gets the objects for widget scale information.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
-        /// <exception cref="InvalidOperationException">Thrown in case of failed conditions</exception>
-        /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access this method</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>
         public IEnumerable<Scale> GetScales()
         {
-            int[] w = new int[100];
-            int[] h = new int[100];
-            int[] types = new int[100];
+            IntPtr wPtr;
+            IntPtr hPtr;
+            IntPtr typesPtr;
+            int[] w;
+            int[] h;
+            int[] types;
             int cnt1 = 100;
             int cnt2 = 100;
             IList<Scale> scales = new List<Scale>();
+            Interop.WidgetService.ErrorCode err = Interop.WidgetService.GetSupportedSizes(Id, ref cnt1, out wPtr, out hPtr);
 
-            Interop.WidgetService.ErrorCode err = Interop.WidgetService.GetSupportedSizes(Id, ref cnt1, out w, out h);
+            if (cnt1 == 0)
+            {
+                Log.Error(LogTag, "No supported size :" + Id);
+                return null;
+            }
 
             switch (err)
             {
@@ -466,9 +497,15 @@ namespace Tizen.Applications
                 case Interop.WidgetService.ErrorCode.PermissionDenied:
                     throw new UnauthorizedAccessException();
             }
+            w = new int[cnt1];
+            Marshal.Copy(wPtr, w, 0, cnt1);
+            Interop.Libc.Free(wPtr);
 
-            err = Interop.WidgetService.GetSupportedSizeTypes(Id, ref cnt2, out types);
+            h = new int[cnt1];
+            Marshal.Copy(hPtr, h, 0, cnt1);
+            Interop.Libc.Free(hPtr);
 
+            err = Interop.WidgetService.GetSupportedSizeTypes(Id, ref cnt2, out typesPtr);
             switch (err)
             {
                 case Interop.WidgetService.ErrorCode.InvalidParameter:
@@ -482,7 +519,14 @@ namespace Tizen.Applications
             }
 
             if (cnt1 != cnt2)
+            {
+                Log.Error(LogTag, "Count not match cnt1 :" + cnt1 + ", cnt2 :" + cnt2);
                 return null;
+            }
+
+            types = new int[cnt2];
+            Marshal.Copy(typesPtr, types, 0, cnt2);
+            Interop.Libc.Free(typesPtr);
 
             for (int i = 0; i < cnt1; i++)
             {
@@ -500,11 +544,12 @@ namespace Tizen.Applications
         }
 
         /// <summary>
-        /// Gets widget name.
+        /// Gets the widget name.
         /// </summary>
-        /// <param name="lang">Language</param>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="lang">Language.</param>
         /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
-        /// <exception cref="ArgumentNullException">Thrown when argument is null</exception>
+        /// <exception cref="ArgumentNullException">Thrown when the argument is null.</exception>
         public string GetName(string lang)
         {
             if (lang == null)
@@ -514,11 +559,12 @@ namespace Tizen.Applications
         }
 
         /// <summary>
-        /// Gets widget icon path.
+        /// Gets the widget icon path.
         /// </summary>
-        /// <param name="lang">Language</param>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="lang">Language.</param>
         /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
-        /// <exception cref="ArgumentNullException">Thrown when argument is null</exception>
+        /// <exception cref="ArgumentNullException">Thrown when the argument is null.</exception>
         public string GetIconPath(string lang)
         {
             if (lang == null)
@@ -530,8 +576,9 @@ namespace Tizen.Applications
         }
 
         /// <summary>
-        /// Releases all resources used by the WidgetControl class.
+        /// Releases all the resources used by the WidgetControl class.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public void Dispose()
         {
             Dispose(true);