Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.WidgetApplication / Interop / Interop.Widget.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 using System;
18 using System.Runtime.InteropServices;
19
20 using Tizen.Applications;
21
22 internal static partial class Interop
23 {
24     internal static partial class Widget
25     {
26         internal enum WidgetAppDestroyType
27         {
28             Permanent = 0,
29             Temporary
30         }
31
32         internal enum AppEventType
33         {
34             LowMemory = 0,
35             LowBattery,
36             LanguageChanged,
37             DeviceOrientationChanged,
38             RegionFormatChanged,
39             SuspendedStateChanged
40         }
41
42         internal enum ErrorCode : int
43         {
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,
60         }
61
62         internal delegate void AppEventCallback(IntPtr handle, IntPtr data);
63
64         internal delegate IntPtr WidgetAppCreateCallback(IntPtr userData);
65
66         internal delegate void WidgetAppTerminateCallback(IntPtr userData);
67
68         internal delegate int WidgetInstanceCreateCallback(IntPtr context, IntPtr content, int w, int h, IntPtr userData);
69
70         internal delegate int WidgetInstanceDestroyCallback(IntPtr context, WidgetAppDestroyType reason, IntPtr content, IntPtr userData);
71
72         internal delegate int WidgetInstancePauseCallback(IntPtr context, IntPtr userData);
73
74         internal delegate int WidgetInstanceResumeCallback(IntPtr context, IntPtr userData);
75
76         internal delegate int WidgetInstanceResizeCallback(IntPtr context, int w, int h, IntPtr userData);
77
78         internal delegate int WidgetInstanceUpdateCallback(IntPtr context, IntPtr content, int force, IntPtr userData);
79
80         [DllImport(Libraries.AppcoreWidget, EntryPoint = "widget_app_main")]
81         internal static extern ErrorCode Main(int argc, string[] argv, ref WidgetAppLifecycleCallbacks callback, IntPtr userData);
82
83         [DllImport(Libraries.AppcoreWidget, EntryPoint = "widget_app_exit")]
84         internal static extern void Exit();
85
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);
88
89         [DllImport(Libraries.AppcoreWidget, EntryPoint = "widget_app_remove_event_handler")]
90         internal static extern ErrorCode RemoveEventHandler(IntPtr handle);
91
92         [DllImport(Libraries.AppcoreWidget, EntryPoint = "widget_app_class_create")]
93         internal static extern IntPtr CreateClass(WidgetiInstanceLifecycleCallbacks callback, IntPtr userData);
94
95         [DllImport(Libraries.AppcoreWidget, EntryPoint = "widget_app_class_add")]
96         internal static extern IntPtr AddClass(IntPtr handle, string classId, WidgetiInstanceLifecycleCallbacks callback, IntPtr userData);
97
98         [DllImport(Libraries.AppcoreWidget, EntryPoint = "widget_app_terminate_context")]
99         internal static extern ErrorCode TerminateContext(IntPtr handle);
100
101         [DllImport(Libraries.AppcoreWidget, EntryPoint = "widget_app_context_set_content_info")]
102         internal static extern ErrorCode SetContent(IntPtr handle, SafeBundleHandle content);
103
104         [DllImport(Libraries.AppcoreWidget, EntryPoint = "widget_app_context_set_title")]
105         internal static extern ErrorCode SetTitle(IntPtr handle, string title);
106
107         [DllImport(Libraries.AppcoreWidget, EntryPoint = "widget_app_get_elm_win")]
108         internal static extern ErrorCode GetWin(IntPtr handle, out IntPtr win);
109
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);
112
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);
115
116         [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_language")]
117         internal static extern Tizen.Internals.Errors.ErrorCode AppEventGetLanguage(IntPtr handle, out string lang);
118
119         [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_region_format")]
120         internal static extern Tizen.Internals.Errors.ErrorCode AppEventGetRegionFormat(IntPtr handle, out string region);
121
122         [StructLayoutAttribute(LayoutKind.Sequential)]
123         internal struct WidgetAppLifecycleCallbacks
124         {
125             public WidgetAppCreateCallback OnCreate;
126             public WidgetAppTerminateCallback OnTerminate;
127         }
128
129         [StructLayoutAttribute(LayoutKind.Sequential)]
130         internal struct WidgetiInstanceLifecycleCallbacks
131         {
132             public WidgetInstanceCreateCallback OnCreate;
133             public WidgetInstanceDestroyCallback OnDestroy;
134             public WidgetInstancePauseCallback OnPause;
135             public WidgetInstanceResumeCallback OnResume;
136             public WidgetInstanceResizeCallback OnResize;
137             public WidgetInstanceUpdateCallback OnUpdate;
138         }
139     }
140 }