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;
20 using Tizen.Applications;
22 internal static partial class Interop
24 internal static partial class AppControl
26 internal const int AppStartedStatus = 1;
28 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
29 internal delegate bool ExtraDataCallback(IntPtr handle, string key, IntPtr userData);
31 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
32 internal delegate bool AppMatchedCallback(IntPtr handle, string applicationId, IntPtr userData);
34 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
35 internal delegate void ReplyCallback(IntPtr request, IntPtr reply, int result, IntPtr userData);
37 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
38 internal delegate void ResultCallback(IntPtr request, int result, IntPtr userData);
40 internal enum ErrorCode
42 None = Tizen.Internals.Errors.ErrorCode.None,
43 InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
44 OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
45 AppNotFound = -0x01100000 | 0x21,
46 KeyNotFound = Tizen.Internals.Errors.ErrorCode.KeyNotAvailable,
47 KeyRejected = Tizen.Internals.Errors.ErrorCode.KeyRejected,
48 InvalidDataType = -0x01100000 | 0x22,
49 LaunchRejected = -0x01100000 | 0x23,
50 PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
51 LaunchFailed = -0x01100000 | 0x24,
52 IoError = Tizen.Internals.Errors.ErrorCode.IoError,
53 TimedOut = Tizen.Internals.Errors.ErrorCode.TimedOut,
56 [DllImport(Libraries.AppControl, EntryPoint = "app_control_create")]
57 internal static extern ErrorCode Create(out SafeAppControlHandle handle);
59 [DllImport(Libraries.AppControl, EntryPoint = "app_control_clone")]
60 internal static extern ErrorCode DangerousClone(out SafeAppControlHandle clone, IntPtr handle);
62 [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_app_id")]
63 internal static extern ErrorCode GetAppId(IntPtr app_control, out IntPtr app_id);
65 [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_operation")]
66 internal static extern ErrorCode GetOperation(SafeAppControlHandle handle, out string operation);
68 [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_operation")]
69 internal static extern ErrorCode SetOperation(SafeAppControlHandle handle, string operation);
71 [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_uri")]
72 internal static extern ErrorCode GetUri(SafeAppControlHandle handle, out string uri);
74 [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_uri")]
75 internal static extern ErrorCode SetUri(SafeAppControlHandle handle, string uri);
77 [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_mime")]
78 internal static extern ErrorCode GetMime(SafeAppControlHandle handle, out string mime);
80 [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_mime")]
81 internal static extern ErrorCode SetMime(SafeAppControlHandle handle, string mime);
83 [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_category")]
84 internal static extern ErrorCode GetCategory(SafeAppControlHandle handle, out string category);
86 [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_category")]
87 internal static extern ErrorCode SetCategory(SafeAppControlHandle handle, string category);
89 [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_app_id")]
90 internal static extern ErrorCode GetAppId(SafeAppControlHandle handle, out string appId);
92 [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_app_id")]
93 internal static extern ErrorCode SetAppId(SafeAppControlHandle handle, string appId);
95 [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_launch_mode")]
96 internal static extern ErrorCode SetLaunchMode(SafeAppControlHandle handle, int mode);
98 [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_launch_mode")]
99 internal static extern ErrorCode GetLaunchMode(SafeAppControlHandle handle, out int mode);
101 [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_caller")]
102 internal static extern ErrorCode GetCaller(SafeAppControlHandle handle, out string caller);
104 [DllImport(Libraries.AppControl, EntryPoint = "app_control_is_reply_requested")]
105 internal static extern ErrorCode IsReplyRequested(SafeAppControlHandle handle, out bool requested);
107 [DllImport(Libraries.AppControl, EntryPoint = "app_control_add_extra_data")]
108 internal static extern ErrorCode AddExtraData(SafeAppControlHandle handle, string key, string value);
110 [DllImport(Libraries.AppControl, EntryPoint = "app_control_remove_extra_data")]
111 internal static extern ErrorCode RemoveExtraData(SafeAppControlHandle handle, string key);
113 [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_extra_data")]
114 internal static extern ErrorCode GetExtraData(SafeAppControlHandle handle, string key, out string value);
116 [DllImport(Libraries.AppControl, EntryPoint = "app_control_add_extra_data_array")]
117 internal static extern ErrorCode AddExtraDataArray(SafeAppControlHandle handle, string key, string[] value, int length);
119 [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_extra_data_array")]
120 internal static extern ErrorCode GetExtraDataArray(SafeAppControlHandle handle, string key, out IntPtr value, out int length);
122 [DllImport(Libraries.AppControl, EntryPoint = "app_control_is_extra_data_array")]
123 internal static extern ErrorCode IsExtraDataArray(SafeAppControlHandle handle, string key, out bool array);
125 [DllImport(Libraries.AppControl, EntryPoint = "app_control_destroy")]
126 internal static extern ErrorCode DangerousDestroy(IntPtr handle);
128 [DllImport(Libraries.AppControl, EntryPoint = "app_control_foreach_extra_data")]
129 internal static extern ErrorCode ForeachExtraData(SafeAppControlHandle handle, ExtraDataCallback callback, IntPtr userData);
131 [DllImport(Libraries.AppControl, EntryPoint = "app_control_foreach_app_matched")]
132 internal static extern ErrorCode ForeachAppMatched(SafeAppControlHandle handle, AppMatchedCallback callback, IntPtr userData);
134 [DllImport(Libraries.AppControl, EntryPoint = "app_control_send_launch_request")]
135 internal static extern ErrorCode SendLaunchRequest(SafeAppControlHandle handle, ReplyCallback callback, IntPtr userData);
137 [DllImport(Libraries.AppControl, EntryPoint = "app_control_send_terminate_request")]
138 internal static extern ErrorCode SendTerminateRequest(SafeAppControlHandle handle);
140 [DllImport(Libraries.AppControl, EntryPoint = "app_control_reply_to_launch_request")]
141 internal static extern ErrorCode ReplyToLaunchRequest(SafeAppControlHandle reply, SafeAppControlHandle request, int result);
143 [DllImport(Libraries.AppControl, EntryPoint = "app_control_enable_app_started_result_event")]
144 internal static extern ErrorCode EnableAppStartedResultEvent(SafeAppControlHandle handle);
146 [DllImport(Libraries.AppControl, EntryPoint = "app_control_send_launch_request_async")]
147 internal static extern ErrorCode SendLaunchRequestAsync(SafeAppControlHandle handle, ResultCallback resultCallback, ReplyCallback replyCallback, IntPtr userData);
149 [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_component_id")]
150 internal static extern ErrorCode SetComponentId(SafeAppControlHandle handle, string componentId);
152 [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_component_id")]
153 internal static extern ErrorCode GetComponentId(SafeAppControlHandle handle, out string componentId);
155 [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_auto_restart")]
156 internal static extern ErrorCode SetAutoRestart(SafeAppControlHandle handle);
158 [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_window_position")]
159 internal static extern ErrorCode SetWindowPosition(SafeAppControlHandle handle, int x, int y, int w, int h);
161 [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_window_position")]
162 internal static extern ErrorCode GetWindowPosition(SafeAppControlHandle handle, out int x, out int y, out int w, out int h);