Release 4.0.0-preview1-00249
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.WatchApplication / Interop / Interop.Watch.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 using Tizen.Applications;
20
21 internal static partial class Interop
22 {
23     internal static partial class Watch
24     {
25         internal enum AppEventType
26         {
27             LowMemory = 0,
28             LowBattery,
29             LanguageChanged,
30             DeviceOrientationChanged,
31             RegionFormatChanged,
32             SuspendedStateChanged
33         }
34
35         internal enum ErrorCode
36         {
37             None = Tizen.Internals.Errors.ErrorCode.None,
38             InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
39             OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
40             InvalidContext = -0x01100000 | 0x01,
41             NoSuchFile = Tizen.Internals.Errors.ErrorCode.NoSuchFile,
42             NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported,
43             AlreadyRunning = Tizen.Internals.Errors.ErrorCode.AlreadyInProgress
44         }
45
46         internal delegate void AppEventCallback(IntPtr handle, IntPtr data);
47
48         internal delegate bool WatchAppCreateCallback(int width, int height, IntPtr userData);
49
50         internal delegate void WatchAppPauseCallback(IntPtr userData);
51
52         internal delegate void WatchAppResumeCallback(IntPtr userData);
53
54         internal delegate void WatchAppTerminateCallback(IntPtr userData);
55
56         internal delegate void WatchAppControlCallback(IntPtr appControl, IntPtr userData);
57
58         internal delegate void WatchAppTimeTickCallback(IntPtr watchTime, IntPtr userData);
59
60         internal delegate void WatchAppAmbientTickCallback(IntPtr watchTime, IntPtr userData);
61
62         internal delegate void WatchAppAmbientChangedCallback(bool ambientMode, IntPtr userData);
63
64         [StructLayout(LayoutKind.Sequential)]
65         internal struct WatchAppLifecycleCallbacks
66         {
67             public WatchAppCreateCallback OnCreate;
68             public WatchAppControlCallback OnAppControl;
69             public WatchAppPauseCallback OnPause;
70             public WatchAppResumeCallback OnResume;
71             public WatchAppTerminateCallback OnTerminate;
72             public WatchAppTimeTickCallback OnTick;
73             public WatchAppAmbientTickCallback OnAmbientTick;
74             public WatchAppAmbientChangedCallback OnAmbientChanged;
75         }
76
77         [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_main")]
78         internal static extern ErrorCode Main(int argc, string[] argv, ref WatchAppLifecycleCallbacks callback, IntPtr userData);
79
80         [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_exit")]
81         internal static extern void Exit();
82
83         [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_add_event_handler")]
84         internal static extern ErrorCode AddEventHandler(out IntPtr handle, AppEventType eventType, AppEventCallback callback, IntPtr userData);
85
86         [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_remove_event_handler")]
87         internal static extern ErrorCode RemoveEventHandler(IntPtr handle);
88
89         // tizen 3.0
90         [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_set_time_tick_frequency")]
91         internal static extern ErrorCode SetTimeTickFrequency(int ticks, TimeTickResolution type);
92
93         // tizen 3.0
94         [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_get_time_tick_frequency")]
95         internal static extern ErrorCode GetTimeTickFrequency(out int ticks, out TimeTickResolution type);
96
97         [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_set_ambient_tick_type")]
98         internal static extern ErrorCode SetAmbientTickType(AmbientTickType type);
99
100         [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_get_ambient_tick_type")]
101         internal static extern ErrorCode GetAmbientTickType(out AmbientTickType type);
102
103         [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_delete")]
104         internal static extern ErrorCode WatchTimeDelete(IntPtr watchTime);
105
106         [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_year")]
107         internal static extern ErrorCode WatchTimeGetYear(SafeWatchTimeHandle handle, out int year);
108
109         [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_month")]
110         internal static extern ErrorCode WatchTimeGetMonth(SafeWatchTimeHandle handle, out int month);
111
112         [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_day")]
113         internal static extern ErrorCode WatchTimeGetDay(SafeWatchTimeHandle handle, out int day);
114
115         [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_day_of_week")]
116         internal static extern ErrorCode WatchTimeGetDayOfWeek(SafeWatchTimeHandle handle, out int day_of_week);
117
118         [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_hour")]
119         internal static extern ErrorCode WatchTimeGetHour(SafeWatchTimeHandle handle, out int hour);
120
121         [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_hour24")]
122         internal static extern ErrorCode WatchTimeGetHour24(SafeWatchTimeHandle handle, out int hour24);
123
124         [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_minute")]
125         internal static extern ErrorCode WatchTimeGetMinute(SafeWatchTimeHandle handle, out int minute);
126
127         [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_second")]
128         internal static extern ErrorCode WatchTimeGetSecond(SafeWatchTimeHandle handle, out int second);
129
130         [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_millisecond")]
131         internal static extern ErrorCode WatchTimeGetMillisecond(SafeWatchTimeHandle handle, out int millisecond);
132
133         [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_get_elm_win")]
134         internal static extern ErrorCode GetWin(out IntPtr win);
135
136         [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_utc_timestamp")]
137         internal static extern ErrorCode WatchTimeGetUtcTimestamp(SafeWatchTimeHandle handle, out long utc_timestamp);
138
139         [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_time_zone")]
140         internal static extern ErrorCode WatchTimeGetTimeZone(SafeWatchTimeHandle handle, out string time_zone_id);
141
142         [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_current_time")]
143         internal static extern ErrorCode WatchTimeGetCurrentTime(out SafeWatchTimeHandle handle);
144
145         // app common
146         [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_low_memory_status")]
147         internal static extern Tizen.Internals.Errors.ErrorCode AppEventGetLowMemoryStatus(IntPtr handle, out LowMemoryStatus status);
148
149         [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_low_battery_status")]
150         internal static extern Tizen.Internals.Errors.ErrorCode AppEventGetLowBatteryStatus(IntPtr handle, out LowBatteryStatus status);
151
152         [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_language")]
153         internal static extern Tizen.Internals.Errors.ErrorCode AppEventGetLanguage(IntPtr handle, out string lang);
154
155         [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_region_format")]
156         internal static extern Tizen.Internals.Errors.ErrorCode AppEventGetRegionFormat(IntPtr handle, out string region);
157     }
158 }