2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Runtime.InteropServices;
20 using Tizen.Applications;
22 internal static partial class Interop
24 internal static partial class Widget
26 internal enum WidgetAppDestroyType
32 internal enum AppEventType
37 DeviceOrientationChanged,
42 internal enum ErrorCode : int
44 None = Tizen.Internals.Errors.ErrorCode.None,
45 InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
46 OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
47 ResourceBusy = Tizen.Internals.Errors.ErrorCode.ResourceBusy,
48 PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
49 Canceled = Tizen.Internals.Errors.ErrorCode.Canceled,
50 IoError = Tizen.Internals.Errors.ErrorCode.IoError,
51 TimedOut = Tizen.Internals.Errors.ErrorCode.TimedOut,
52 NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported,
53 FileNoSpaceOnDevice = Tizen.Internals.Errors.ErrorCode.FileNoSpaceOnDevice,
54 Fault = -0x02F40000 | 0x0001,
55 AlreadyExist = -0x02F40000 | 0x0002,
56 AlreadyStarted = -0x02F40000 | 0x0004,
57 NotExist = -0x02F40000 | 0x0008,
58 Disabled = -0x02F40000 | 0x0010,
59 MaxExceeded = -0x02F40000 | 0x0011,
62 internal delegate void AppEventCallback(IntPtr handle, IntPtr data);
64 internal delegate IntPtr WidgetAppCreateCallback(IntPtr userData);
66 internal delegate void WidgetAppTerminateCallback(IntPtr userData);
68 internal delegate int WidgetInstanceCreateCallback(IntPtr context, IntPtr content, int w, int h, IntPtr userData);
70 internal delegate int WidgetInstanceDestroyCallback(IntPtr context, WidgetAppDestroyType reason, IntPtr content, IntPtr userData);
72 internal delegate int WidgetInstancePauseCallback(IntPtr context, IntPtr userData);
74 internal delegate int WidgetInstanceResumeCallback(IntPtr context, IntPtr userData);
76 internal delegate int WidgetInstanceResizeCallback(IntPtr context, int w, int h, IntPtr userData);
78 internal delegate int WidgetInstanceUpdateCallback(IntPtr context, IntPtr content, int force, IntPtr userData);
80 [DllImport(Libraries.AppcoreWidget, EntryPoint = "widget_app_main")]
81 internal static extern ErrorCode Main(int argc, string[] argv, ref WidgetAppLifecycleCallbacks callback, IntPtr userData);
83 [DllImport(Libraries.AppcoreWidget, EntryPoint = "widget_app_exit")]
84 internal static extern void Exit();
86 [DllImport(Libraries.AppcoreWidget, EntryPoint = "widget_app_add_event_handler")]
87 internal static extern ErrorCode AddEventHandler(out IntPtr handle, AppEventType eventType, AppEventCallback callback, IntPtr data);
89 [DllImport(Libraries.AppcoreWidget, EntryPoint = "widget_app_remove_event_handler")]
90 internal static extern ErrorCode RemoveEventHandler(IntPtr handle);
92 [DllImport(Libraries.AppcoreWidget, EntryPoint = "widget_app_class_create")]
93 internal static extern IntPtr CreateClass(WidgetiInstanceLifecycleCallbacks callback, IntPtr userData);
95 [DllImport(Libraries.AppcoreWidget, EntryPoint = "widget_app_class_add")]
96 internal static extern IntPtr AddClass(IntPtr handle, string classId, WidgetiInstanceLifecycleCallbacks callback, IntPtr userData);
98 [DllImport(Libraries.AppcoreWidget, EntryPoint = "widget_app_terminate_context")]
99 internal static extern ErrorCode TerminateContext(IntPtr handle);
101 [DllImport(Libraries.AppcoreWidget, EntryPoint = "widget_app_context_set_content_info")]
102 internal static extern ErrorCode SetContent(IntPtr handle, SafeBundleHandle content);
104 [DllImport(Libraries.AppcoreWidget, EntryPoint = "widget_app_context_set_title")]
105 internal static extern ErrorCode SetTitle(IntPtr handle, string title);
107 [DllImport(Libraries.AppcoreWidget, EntryPoint = "widget_app_get_elm_win")]
108 internal static extern ErrorCode GetWin(IntPtr handle, out IntPtr win);
110 [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_low_memory_status")]
111 internal static extern Tizen.Internals.Errors.ErrorCode AppEventGetLowMemoryStatus(IntPtr handle, out LowMemoryStatus status);
113 [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_low_battery_status")]
114 internal static extern Tizen.Internals.Errors.ErrorCode AppEventGetLowBatteryStatus(IntPtr handle, out LowBatteryStatus status);
116 [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_language")]
117 internal static extern Tizen.Internals.Errors.ErrorCode AppEventGetLanguage(IntPtr handle, out string lang);
119 [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_region_format")]
120 internal static extern Tizen.Internals.Errors.ErrorCode AppEventGetRegionFormat(IntPtr handle, out string region);
122 [StructLayoutAttribute(LayoutKind.Sequential)]
123 internal struct WidgetAppLifecycleCallbacks
125 public WidgetAppCreateCallback OnCreate;
126 public WidgetAppTerminateCallback OnTerminate;
129 [StructLayoutAttribute(LayoutKind.Sequential)]
130 internal struct WidgetiInstanceLifecycleCallbacks
132 public WidgetInstanceCreateCallback OnCreate;
133 public WidgetInstanceDestroyCallback OnDestroy;
134 public WidgetInstancePauseCallback OnPause;
135 public WidgetInstanceResumeCallback OnResume;
136 public WidgetInstanceResizeCallback OnResize;
137 public WidgetInstanceUpdateCallback OnUpdate;