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;
19 using Tizen.Applications;
21 internal static partial class Interop
23 internal static partial class Watch
25 internal enum AppEventType
30 DeviceOrientationChanged,
35 internal enum ErrorCode
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
46 internal delegate void AppEventCallback(IntPtr handle, IntPtr data);
48 internal delegate bool WatchAppCreateCallback(int width, int height, IntPtr userData);
50 internal delegate void WatchAppPauseCallback(IntPtr userData);
52 internal delegate void WatchAppResumeCallback(IntPtr userData);
54 internal delegate void WatchAppTerminateCallback(IntPtr userData);
56 internal delegate void WatchAppControlCallback(IntPtr appControl, IntPtr userData);
58 internal delegate void WatchAppTimeTickCallback(IntPtr watchTime, IntPtr userData);
60 internal delegate void WatchAppAmbientTickCallback(IntPtr watchTime, IntPtr userData);
62 internal delegate void WatchAppAmbientChangedCallback(bool ambientMode, IntPtr userData);
64 [StructLayout(LayoutKind.Sequential)]
65 internal struct WatchAppLifecycleCallbacks
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;
77 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_main")]
78 internal static extern ErrorCode Main(int argc, string[] argv, ref WatchAppLifecycleCallbacks callback, IntPtr userData);
80 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_exit")]
81 internal static extern void Exit();
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);
86 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_remove_event_handler")]
87 internal static extern ErrorCode RemoveEventHandler(IntPtr handle);
90 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_set_time_tick_frequency")]
91 internal static extern ErrorCode SetTimeTickFrequency(int ticks, TimeTickResolution type);
94 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_get_time_tick_frequency")]
95 internal static extern ErrorCode GetTimeTickFrequency(out int ticks, out TimeTickResolution type);
97 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_set_ambient_tick_type")]
98 internal static extern ErrorCode SetAmbientTickType(AmbientTickType type);
100 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_get_ambient_tick_type")]
101 internal static extern ErrorCode GetAmbientTickType(out AmbientTickType type);
103 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_delete")]
104 internal static extern ErrorCode WatchTimeDelete(IntPtr watchTime);
106 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_year")]
107 internal static extern ErrorCode WatchTimeGetYear(SafeWatchTimeHandle handle, out int year);
109 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_month")]
110 internal static extern ErrorCode WatchTimeGetMonth(SafeWatchTimeHandle handle, out int month);
112 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_day")]
113 internal static extern ErrorCode WatchTimeGetDay(SafeWatchTimeHandle handle, out int day);
115 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_day_of_week")]
116 internal static extern ErrorCode WatchTimeGetDayOfWeek(SafeWatchTimeHandle handle, out int day_of_week);
118 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_hour")]
119 internal static extern ErrorCode WatchTimeGetHour(SafeWatchTimeHandle handle, out int hour);
121 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_hour24")]
122 internal static extern ErrorCode WatchTimeGetHour24(SafeWatchTimeHandle handle, out int hour24);
124 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_minute")]
125 internal static extern ErrorCode WatchTimeGetMinute(SafeWatchTimeHandle handle, out int minute);
127 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_second")]
128 internal static extern ErrorCode WatchTimeGetSecond(SafeWatchTimeHandle handle, out int second);
130 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_millisecond")]
131 internal static extern ErrorCode WatchTimeGetMillisecond(SafeWatchTimeHandle handle, out int millisecond);
133 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_get_elm_win")]
134 internal static extern ErrorCode GetWin(out IntPtr win);
136 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_utc_timestamp")]
137 internal static extern ErrorCode WatchTimeGetUtcTimestamp(SafeWatchTimeHandle handle, out long utc_timestamp);
139 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_time_zone")]
140 internal static extern ErrorCode WatchTimeGetTimeZone(SafeWatchTimeHandle handle, out string time_zone_id);
142 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_current_time")]
143 internal static extern ErrorCode WatchTimeGetCurrentTime(out SafeWatchTimeHandle handle);
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);
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);
152 [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_language")]
153 internal static extern Tizen.Internals.Errors.ErrorCode AppEventGetLanguage(IntPtr handle, out string lang);
155 [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_region_format")]
156 internal static extern Tizen.Internals.Errors.ErrorCode AppEventGetRegionFormat(IntPtr handle, out string region);