X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FTizen.Applications.WidgetControl%2FTizen.Applications%2FWidgetControl.cs;h=0daff7dcef385246ccb01b3cfd0d37060ac27802;hb=6feaf74ecc550599af95d1edf64d443117849ffb;hp=ff6906a48887d8cd823c3af1cb378103eac52e03;hpb=fe4fe91ad4fcec65ff35f6adfedd9f3e8506cb6f;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git
diff --git a/src/Tizen.Applications.WidgetControl/Tizen.Applications/WidgetControl.cs b/src/Tizen.Applications.WidgetControl/Tizen.Applications/WidgetControl.cs
index ff6906a..0daff7d 100755
--- a/src/Tizen.Applications.WidgetControl/Tizen.Applications/WidgetControl.cs
+++ b/src/Tizen.Applications.WidgetControl/Tizen.Applications/WidgetControl.cs
@@ -18,6 +18,7 @@ using System;
using System.Collections.Generic;
using Tizen.Applications;
using System.Runtime.InteropServices;
+using System.ComponentModel;
namespace Tizen.Applications
{
@@ -28,6 +29,7 @@ namespace Tizen.Applications
public class WidgetControl : IDisposable
{
private const string LogTag = "Tizen.Applications.WidgetControl";
+ private static Interop.WidgetService.LifecycleCallback _onLifecycleCallback;
///
/// Class for the widget instance.
///
@@ -50,8 +52,11 @@ namespace Tizen.Applications
///
/// Gets the widget content.
///
+ /// The bundle containing widget content.
/// 3
+ /// http://tizen.org/feature/shell.appwidget
/// Thrown in case of failed conditions.
+ /// Thrown when the required features are not supported.
public Bundle GetContent()
{
IntPtr h;
@@ -62,9 +67,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));
@@ -76,9 +82,11 @@ namespace Tizen.Applications
/// 3
/// Content to be changed.
/// True if you want to update your widget even if the provider is paused, otherwise false.
+ /// http://tizen.org/feature/shell.appwidget
/// Thrown when failed because of an invalid argument.
/// Thrown in case of failed conditions.
- /// Thrown when an application does not have the privilege to access this method.
+ /// Thrown when an application does not have the required privileges to access this method.
+ /// Thrown when the required features are not supported.
public void ChangeContent(Bundle content, bool force)
{
Interop.WidgetService.ErrorCode err = Interop.WidgetService.UpdateContent(_widgetId, Id, content.SafeBundleHandle, force ? 1 : 0);
@@ -99,6 +107,9 @@ namespace Tizen.Applications
case Interop.WidgetService.ErrorCode.PermissionDenied:
throw new UnauthorizedAccessException();
+
+ case Interop.WidgetService.ErrorCode.NotSupported:
+ throw new NotSupportedException("Not supported");
}
}
@@ -106,9 +117,12 @@ namespace Tizen.Applications
/// Changes the update period for the widget instance.
///
/// 3
+ /// The period to be changed.
+ /// http://tizen.org/feature/shell.appwidget
/// Thrown when failed because of an invalid argument.
/// Thrown in case of failed conditions.
- /// Thrown when an application does not have the privilege to access this method.
+ /// Thrown when an application does not have the required privileges to access this method.
+ /// Thrown when the required features are not supported.
public void ChangePeriod(double period)
{
Interop.WidgetService.ErrorCode err = Interop.WidgetService.ChangePeriod(_widgetId, Id, period);
@@ -126,6 +140,9 @@ namespace Tizen.Applications
case Interop.WidgetService.ErrorCode.PermissionDenied:
throw new UnauthorizedAccessException();
+
+ case Interop.WidgetService.ErrorCode.NotSupported:
+ throw new NotSupportedException("Not supported");
}
}
}
@@ -253,10 +270,13 @@ namespace Tizen.Applications
///
/// 3
/// Package ID.
+ /// The widget control array.
/// http://tizen.org/privilege/widget.viewer
+ /// http://tizen.org/feature/shell.appwidget
/// Thrown when failed because of an invalid argument.
/// Thrown in case of failed conditions.
- /// Thrown when an application does not have the privilege to access this method.
+ /// Thrown when an application does not have the required privileges to access this method.
+ /// Thrown when the required features are not supported.
public static WidgetControl[] CreateAll(string pkgId)
{
List list = new List();
@@ -264,6 +284,8 @@ namespace Tizen.Applications
Interop.WidgetService.ErrorCode err = Interop.WidgetService.GetWidgetListByPkgId(pkgId, (widgetId, isPrime, userData) =>
{
list.Add(new WidgetControl(widgetId));
+
+ return (int)Interop.WidgetService.ErrorCode.None;
}, IntPtr.Zero);
switch (err)
@@ -276,6 +298,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();
@@ -285,10 +310,14 @@ namespace Tizen.Applications
/// Gets all the widget IDs by the package ID.
///
/// 3
+ /// Package ID.
+ /// The widget id array.
/// http://tizen.org/privilege/widget.viewer
+ /// http://tizen.org/feature/shell.appwidget
/// Thrown when failed because of an invalid argument.
/// Thrown in case of failed conditions.
- /// Thrown when an application does not have the privilege to access this method.
+ /// Thrown when an application does not have the required privileges to access this method.
+ /// Thrown when the required features are not supported.
public static string[] GetWidgetIds(string pkgId)
{
List list = new List();
@@ -296,6 +325,8 @@ namespace Tizen.Applications
Interop.WidgetService.ErrorCode err = Interop.WidgetService.GetWidgetListByPkgId(pkgId, (widgetId, isPrime, userData) =>
{
list.Add(widgetId);
+
+ return (int)Interop.WidgetService.ErrorCode.None;
}, IntPtr.Zero);
switch (err)
@@ -308,12 +339,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();
}
///
+ /// Gets main appid of the widget.
+ ///
+ /// 6
+ /// http://tizen.org/privilege/widget.viewer
+ /// http://tizen.org/feature/shell.appwidget
+ /// Thrown when an application does not have the required privileges to access this method.
+ /// Thrown when the required features are not supported.
+ 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;
+ }
+ }
+
+ ///
+ /// Gets package ID of the widget.
+ ///
+ /// 6
+ /// http://tizen.org/privilege/widget.viewer
+ /// http://tizen.org/feature/shell.appwidget
+ /// Thrown when an application does not have the required privileges to access this method.
+ /// Thrown when the required features are not supported.
+ 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;
+ }
+ }
+
+ ///
/// The widget ID.
///
/// 3
@@ -324,11 +414,26 @@ namespace Tizen.Applications
///
/// 3
/// http://tizen.org/privilege/widget.viewer
+ /// http://tizen.org/feature/shell.appwidget
+ /// Thrown when an application does not have the required privileges to access this method.
+ /// Thrown when the required features are not supported.
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;
@@ -336,11 +441,95 @@ namespace Tizen.Applications
}
///
+ /// Gets setup app ID of the widget.
+ ///
+ /// 8
+ /// http://tizen.org/privilege/widget.viewer
+ /// http://tizen.org/feature/shell.appwidget
+ /// Thrown when an application does not have the required privileges to access this method.
+ /// Thrown when the required features are not supported.
+ /// Thrown in case of failed conditions.
+ 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;
+ }
+ }
+
+ ///
+ /// Gets widget max count
+ ///
+ /// 8
+ /// http://tizen.org/privilege/widget.viewer
+ /// http://tizen.org/feature/shell.appwidget
+ /// Thrown when the required features are not supported.
+ /// Thrown when an application does not have the required privileges to access this method.
+ /// Thrown in case of failed conditions.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int MaxCount
+ {
+ get
+ {
+ int ret = Interop.WidgetService.GetWidgetMaxCount(Id);
+
+ switch ((Interop.WidgetService.ErrorCode)ret)
+ {
+ case Interop.WidgetService.ErrorCode.NotSupported:
+ throw new NotSupportedException();
+
+ case Interop.WidgetService.ErrorCode.PermissionDenied:
+ throw new UnauthorizedAccessException();
+
+ case Interop.WidgetService.ErrorCode.InvalidParameter:
+ throw new InvalidOperationException("Invalid parameter");
+
+ case Interop.WidgetService.ErrorCode.IoError:
+ throw new InvalidOperationException("Failed to access DB");
+
+ case Interop.WidgetService.ErrorCode.Fault:
+ throw new InvalidOperationException("Failed to get information from DB");
+
+ case Interop.WidgetService.ErrorCode.NotExist:
+ throw new InvalidOperationException("The data does not exist");
+ }
+
+ return ret;
+ }
+ }
+
+ ///
/// The event handler for a created widget instance.
///
/// 3
+ /// http://tizen.org/feature/shell.appwidget
/// Thrown in case of failed conditions.
- /// Thrown when an application does not have the privilege to access this method.
+ /// Thrown when an application does not have the required privileges to access this method.
+ /// Thrown when the required features are not supported.
public event EventHandler Created
{
add
@@ -359,8 +548,10 @@ namespace Tizen.Applications
/// The event handler for a resumed widget instance.
///
/// 3
+ /// http://tizen.org/feature/shell.appwidget
/// Thrown in case of failed conditions.
- /// Thrown when an application does not have the privilege to access this method.
+ /// Thrown when an application does not have the required privileges to access this method.
+ /// Thrown when the required features are not supported.
public event EventHandler Resumed
{
add
@@ -379,8 +570,10 @@ namespace Tizen.Applications
/// The event handler for a paused widget instance.
///
/// 3
+ /// http://tizen.org/feature/shell.appwidget
/// Thrown in case of failed conditions.
- /// Thrown when an application does not have the privilege to access this method.
+ /// Thrown when an application does not have the required privileges to access this method.
+ /// Thrown when the required features are not supported.
public event EventHandler Paused
{
add
@@ -399,8 +592,10 @@ namespace Tizen.Applications
/// The event handler for a destroyed widget instance.
///
/// 3
+ /// http://tizen.org/feature/shell.appwidget
/// Thrown in case of failed conditions.
- /// Thrown when an application does not have the privilege to access this method.
+ /// Thrown when an application does not have the required privileges to access this method.
+ /// Thrown when the required features are not supported.
public event EventHandler Destroyed
{
add
@@ -436,16 +631,20 @@ namespace Tizen.Applications
///
/// Gets the objects for widget instance information.
///
+ /// The instances list.
/// 3
+ /// http://tizen.org/feature/shell.appwidget
/// Thrown in case of failed conditions.
/// Thrown when the API is not supported in this device.
- /// Thrown when an application does not have the privilege to access this method.
+ /// Thrown when an application does not have the required privileges to access this method.
public IEnumerable GetInstances()
{
IList instances = new List();
Interop.WidgetService.ErrorCode err = Interop.WidgetService.GetInstances(Id, (widgetId, instanceId, userData) =>
{
instances.Add(new Instance(widgetId) { Id = instanceId });
+
+ return (int)Interop.WidgetService.ErrorCode.None;
}, IntPtr.Zero);
switch (err)
@@ -466,10 +665,13 @@ namespace Tizen.Applications
///
/// Gets the objects for widget scale information.
///
+ /// The scales list.
/// 3
/// http://tizen.org/privilege/widget.viewer
+ /// http://tizen.org/feature/shell.appwidget
/// Thrown in case of failed conditions.
- /// Thrown when an application does not have the privilege to access this method.
+ /// Thrown when an application does not have the required privileges to access this method.
+ /// Thrown when the required features are not supported.
public IEnumerable GetScales()
{
IntPtr wPtr;
@@ -499,6 +701,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);
@@ -551,14 +756,31 @@ namespace Tizen.Applications
///
/// 3
/// Language.
+ /// The widget name.
/// http://tizen.org/privilege/widget.viewer
+ /// http://tizen.org/feature/shell.appwidget
/// Thrown when the argument is null.
+ /// Thrown when an application does not have the required privileges to access this method.
+ /// Thrown when the required features are not supported.
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;
}
///
@@ -566,22 +788,72 @@ namespace Tizen.Applications
///
/// 3
/// Language.
+ /// The widget icon path.
/// http://tizen.org/privilege/widget.viewer
+ /// http://tizen.org/feature/shell.appwidget
/// Thrown when the argument is null.
+ /// Thrown when an application does not have the required privileges to access this method.
+ /// Thrown when the required features are not supported.
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();
+
+ switch (err)
+ {
+ case Interop.WidgetService.ErrorCode.PermissionDenied:
+ throw new UnauthorizedAccessException();
- return Interop.WidgetService.GetIcon(pkgId, lang);
+ case Interop.WidgetService.ErrorCode.NotSupported:
+ throw new NotSupportedException();
+ }
+
+ return str;
+ }
+
+ ///
+ /// Gets widget instance count
+ ///
+ /// 8
+ /// The widget instance count.
+ /// http://tizen.org/privilege/widget.viewer
+ /// http://tizen.org/feature/shell.appwidget
+ /// Thrown when the required features are not supported.
+ /// Thrown when an application does not have the required privileges to access this method.
+ /// Thrown in case of failed conditions.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int GetInstanceCount()
+ {
+ int ret = Interop.WidgetService.GetWidgetInstanceCount(Id, null, null);
+
+ switch ((Interop.WidgetService.ErrorCode)ret)
+ {
+ case Interop.WidgetService.ErrorCode.NotSupported:
+ throw new NotSupportedException();
+
+ case Interop.WidgetService.ErrorCode.InvalidParameter:
+ throw new InvalidOperationException("Invalid parameter");
+
+ case Interop.WidgetService.ErrorCode.PermissionDenied:
+ throw new UnauthorizedAccessException();
+ }
+
+ return ret;
}
///
/// Releases all the resources used by the WidgetControl class.
///
/// 3
+ /// http://tizen.org/feature/shell.appwidget
+ /// Thrown in case of failed conditions.
+ /// Thrown when an application does not have the required privileges to access this method.
+ /// Thrown when the required features are not supported.
public void Dispose()
{
Dispose(true);
@@ -616,8 +888,10 @@ namespace Tizen.Applications
if (s_lifecycleEventRefCnt[Id] == 0)
{
- Interop.WidgetService.ErrorCode err = Interop.WidgetService.SetLifecycleEvent(Id, OnLifecycleEvent, IntPtr.Zero);
+ if (_onLifecycleCallback == null)
+ _onLifecycleCallback = new Interop.WidgetService.LifecycleCallback(OnLifecycleEvent);
+ Interop.WidgetService.ErrorCode err = Interop.WidgetService.SetLifecycleEvent(Id, _onLifecycleCallback, IntPtr.Zero);
switch (err)
{
case Interop.WidgetService.ErrorCode.InvalidParameter:
@@ -625,11 +899,15 @@ namespace Tizen.Applications
case Interop.WidgetService.ErrorCode.PermissionDenied:
throw new UnauthorizedAccessException();
+
+ case Interop.WidgetService.ErrorCode.NotSupported:
+ throw new NotSupportedException();
}
}
s_lifecycleEventRefCnt[Id]++;
s_eventObjects.Add(this);
+ Log.Debug(LogTag, "register lifecycle cb " + Id + " [" + s_lifecycleEventRefCnt[Id] + "]");
}
private void UnregisterLifecycleEvent()
@@ -657,15 +935,21 @@ 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;
}
s_eventObjects.Remove(this);
s_lifecycleEventRefCnt[Id]--;
+ Log.Debug(LogTag, "unregister lifecycle cb " + Id + " [" + s_lifecycleEventRefCnt[Id] + "]");
}
- private static void OnLifecycleEvent(string widgetId, Interop.WidgetService.LifecycleEvent e, string instanceId, IntPtr userData)
+ private static int OnLifecycleEvent(string widgetId, Interop.WidgetService.LifecycleEvent e, string instanceId, IntPtr userData)
{
+ Log.Debug(LogTag, "Lifecycle event : " + instanceId + " [" + e + "]");
switch (e)
{
case Interop.WidgetService.LifecycleEvent.Created:
@@ -727,7 +1011,11 @@ namespace Tizen.Applications
}
}
break;
+
+ default:
+ break;
}
+ return 0;
}
}