internal delegate void InstanceCallback(string widgetId, string instanceId, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void LifecycleCallback(string widgetId, LifecycleEvent e, string instanceId, IntPtr userData);
+ internal delegate int LifecycleCallback(string widgetId, LifecycleEvent e, string instanceId, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void WidgetListCallback(string widgetId, int isPrime, IntPtr userData);
public class WidgetControl : IDisposable
{
private const string LogTag = "Tizen.Applications.WidgetControl";
+ private static Interop.WidgetService.LifecycleCallback _onLifecycleCallback;
/// <summary>
/// Class for the widget instance.
/// </summary>
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:
s_lifecycleEventRefCnt[Id]++;
s_eventObjects.Add(this);
+ Log.Debug(LogTag, "register lifecycle cb " + Id + " [" + s_lifecycleEventRefCnt[Id] + "]");
}
private void UnregisterLifecycleEvent()
case Interop.WidgetService.ErrorCode.NotExist:
throw new InvalidOperationException("Event handler is not exist");
}
+ _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:
}
break;
}
+ return 0;
}
}