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 AlreadyRunning = Tizen.Internals.Errors.ErrorCode.AlreadyInProgress
45 internal delegate void AppEventCallback(IntPtr handle, IntPtr data);
47 internal delegate bool WatchAppCreateCallback(int width, int height, IntPtr userData);
49 internal delegate void WatchAppPauseCallback(IntPtr userData);
51 internal delegate void WatchAppResumeCallback(IntPtr userData);
53 internal delegate void WatchAppTerminateCallback(IntPtr userData);
55 internal delegate void WatchAppControlCallback(IntPtr appControl, IntPtr userData);
57 internal delegate void WatchAppTimeTickCallback(IntPtr watchTime, IntPtr userData);
59 internal delegate void WatchAppAmbientTickCallback(IntPtr watchTime, IntPtr userData);
61 internal delegate void WatchAppAmbientChangedCallback(bool ambientMode, IntPtr userData);
63 [StructLayout(LayoutKind.Sequential)]
64 internal struct WatchAppLifecycleCallbacks
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;
76 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_main")]
77 internal static extern ErrorCode Main(int argc, string[] argv, ref WatchAppLifecycleCallbacks callback, IntPtr userData);
79 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_exit")]
80 internal static extern void Exit();
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);
85 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_remove_event_handler")]
86 internal static extern ErrorCode RemoveEventHandler(IntPtr handle);
89 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_set_time_tick_frequency")]
90 internal static extern ErrorCode SetTimeTickFrequency(int ticks, TimeTickResolution type);
93 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_get_time_tick_frequency")]
94 internal static extern ErrorCode GetTimeTickFrequency(out int ticks, out TimeTickResolution type);
96 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_set_ambient_tick_type")]
97 internal static extern ErrorCode SetAmbientTickType(AmbientTickType type);
99 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_get_ambient_tick_type")]
100 internal static extern ErrorCode GetAmbientTickType(out AmbientTickType type);
102 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_delete")]
103 internal static extern ErrorCode WatchTimeDelete(IntPtr watchTime);
105 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_year")]
106 internal static extern ErrorCode WatchTimeGetYear(SafeWatchTimeHandle handle, out int year);
108 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_month")]
109 internal static extern ErrorCode WatchTimeGetMonth(SafeWatchTimeHandle handle, out int month);
111 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_day")]
112 internal static extern ErrorCode WatchTimeGetDay(SafeWatchTimeHandle handle, out int day);
114 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_day_of_week")]
115 internal static extern ErrorCode WatchTimeGetDayOfWeek(SafeWatchTimeHandle handle, out int day_of_week);
117 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_hour")]
118 internal static extern ErrorCode WatchTimeGetHour(SafeWatchTimeHandle handle, out int hour);
120 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_hour24")]
121 internal static extern ErrorCode WatchTimeGetHour24(SafeWatchTimeHandle handle, out int hour24);
123 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_minute")]
124 internal static extern ErrorCode WatchTimeGetMinute(SafeWatchTimeHandle handle, out int minute);
126 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_second")]
127 internal static extern ErrorCode WatchTimeGetSecond(SafeWatchTimeHandle handle, out int second);
129 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_millisecond")]
130 internal static extern ErrorCode WatchTimeGetMillisecond(SafeWatchTimeHandle handle, out int millisecond);
132 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_get_elm_win")]
133 internal static extern ErrorCode GetWin(out IntPtr win);
135 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_utc_timestamp")]
136 internal static extern ErrorCode WatchTimeGetUtcTimestamp(SafeWatchTimeHandle handle, out long utc_timestamp);
138 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_time_zone")]
139 internal static extern ErrorCode WatchTimeGetTimeZone(SafeWatchTimeHandle handle, out string time_zone_id);
141 [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_current_time")]
142 internal static extern ErrorCode WatchTimeGetCurrentTime(out SafeWatchTimeHandle handle);
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);
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);
151 [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_language")]
152 internal static extern Tizen.Internals.Errors.ErrorCode AppEventGetLanguage(IntPtr handle, out string lang);
154 [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_region_format")]
155 internal static extern Tizen.Internals.Errors.ErrorCode AppEventGetRegionFormat(IntPtr handle, out string region);