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