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
{
}
/// <summary>
- /// Widget ID.
+ /// The widget ID.
/// </summary>
- /// <since_tizen>3</since_tizen>
+ /// <since_tizen> 3 </since_tizen>
public string Id { get; internal set; }
/// <summary>
- /// Gets widget content.
+ /// Gets the widget content.
/// </summary>
- /// <since_tizen>3</since_tizen>
- /// <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;
/// <summary>
/// Changes the content for the widget instance.
/// </summary>
- /// <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 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);
/// <summary>
/// Changes the update period for the widget instance.
/// </summary>
- /// <since_tizen>3</since_tizen>
- /// <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);
}
/// <summary>
- /// Class for widget size information.
+ /// The class for the widget size information.
/// </summary>
public class Scale
{
}
/// <summary>
- /// Enumeration for types of widget size
+ /// Enumeration for the types of widget size.
/// </summary>
- /// <since_tizen>3</since_tizen>
+ /// <since_tizen> 3 </since_tizen>
public enum SizeType : int
{
/// <summary>
/// <summary>
/// Widget width.
/// </summary>
- /// <since_tizen>3</since_tizen>
+ /// <since_tizen> 3 </since_tizen>
public int Width { get; internal set; }
/// <summary>
- /// Widget height.
+ ///Widget height.
/// </summary>
- /// <since_tizen>3</since_tizen>
+ /// <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>
+ /// <since_tizen> 3 </since_tizen>
public string PreviewImagePath { get; internal set; }
/// <summary>
/// The size type of the widget.
/// </summary>
- /// <since_tizen>3</since_tizen>
+ /// <since_tizen> 3 </since_tizen>
public SizeType Type { get; internal set; }
}
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>
- /// <since_tizen>3</since_tizen>
- /// <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>();
}
/// <summary>
- /// Gets all widget IDs by package ID.
+ /// Gets all the widget IDs by the package ID.
/// </summary>
- /// <since_tizen>3</since_tizen>
+ /// <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>();
}
/// <summary>
- /// Widget ID.
+ /// The widget ID.
/// </summary>
- /// <since_tizen>3</since_tizen>
+ /// <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>
+ /// <since_tizen> 3 </since_tizen>
/// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
public bool IsNoDisplay
{
}
/// <summary>
- /// Event handler for created widget instance.
+ /// The event handler for a created widget instance.
/// </summary>
- /// <since_tizen>3</since_tizen>
- /// <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
}
/// <summary>
- /// Event handler for resumed widget instance.
+ /// The event handler for a resumed widget instance.
/// </summary>
- /// <since_tizen>3</since_tizen>
- /// <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
}
/// <summary>
- /// Event handler for paused widget instance.
+ /// The event handler for a paused widget instance.
/// </summary>
- /// <since_tizen>3</since_tizen>
- /// <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
}
/// <summary>
- /// Event handler for destroyed widget instance.
+ /// The event handler for a destroyed widget instance.
/// </summary>
- /// <since_tizen>3</since_tizen>
- /// <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
}
/// <summary>
- /// A constructor of WidgetControl object
+ /// The constructor of the WidgetControl object.
/// </summary>
- /// <since_tizen>3</since_tizen>
- /// <param name="widgetId">widget id.</param>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="widgetId">Widget ID.</param>
public WidgetControl(string widgetId)
{
Id = widgetId;
}
/// <summary>
- /// Gets objects for widget instance information.
+ /// Gets the objects for widget instance information.
/// </summary>
- /// <since_tizen>3</since_tizen>
- /// <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>();
}
/// <summary>
- /// Gets objects for widget scale information.
+ /// Gets the objects for widget scale information.
/// </summary>
- /// <since_tizen>3</since_tizen>
+ /// <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)
{
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:
}
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++)
{
}
/// <summary>
- /// Gets widget name.
+ /// Gets the widget name.
/// </summary>
- /// <since_tizen>3</since_tizen>
- /// <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)
}
/// <summary>
- /// Gets widget icon path.
+ /// Gets the widget icon path.
/// </summary>
- /// <since_tizen>3</since_tizen>
- /// <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)
}
/// <summary>
- /// Releases all resources used by the WidgetControl class.
+ /// Releases all the resources used by the WidgetControl class.
/// </summary>
- /// <since_tizen>3</since_tizen>
+ /// <since_tizen> 3 </since_tizen>
public void Dispose()
{
Dispose(true);