[Applications.Common] Add missing application APIs (#547)
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.Common / Interop / Interop.AppControl.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
20 using Tizen.Applications;
21
22 internal static partial class Interop
23 {
24     internal static partial class AppControl
25     {
26         internal const int AppStartedStatus = 1;
27
28         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
29         internal delegate bool ExtraDataCallback(IntPtr handle, string key, IntPtr userData);
30
31         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
32         internal delegate bool AppMatchedCallback(IntPtr handle, string applicationId, IntPtr userData);
33
34         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
35         internal delegate void ReplyCallback(IntPtr request, IntPtr reply, int result, IntPtr userData);
36
37         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
38         internal delegate void ResultCallback(IntPtr request, int result, IntPtr userData);
39
40         internal enum ErrorCode
41         {
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,
54         }
55
56         [DllImport(Libraries.AppControl, EntryPoint = "app_control_create")]
57         internal static extern ErrorCode Create(out SafeAppControlHandle handle);
58
59         [DllImport(Libraries.AppControl, EntryPoint = "app_control_clone")]
60         internal static extern ErrorCode DangerousClone(out SafeAppControlHandle clone, IntPtr handle);
61
62         [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_app_id")]
63         internal static extern ErrorCode GetAppId(IntPtr app_control, out IntPtr app_id);
64
65         [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_operation")]
66         internal static extern ErrorCode GetOperation(SafeAppControlHandle handle, out string operation);
67
68         [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_operation")]
69         internal static extern ErrorCode SetOperation(SafeAppControlHandle handle, string operation);
70
71         [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_uri")]
72         internal static extern ErrorCode GetUri(SafeAppControlHandle handle, out string uri);
73
74         [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_uri")]
75         internal static extern ErrorCode SetUri(SafeAppControlHandle handle, string uri);
76
77         [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_mime")]
78         internal static extern ErrorCode GetMime(SafeAppControlHandle handle, out string mime);
79
80         [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_mime")]
81         internal static extern ErrorCode SetMime(SafeAppControlHandle handle, string mime);
82
83         [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_category")]
84         internal static extern ErrorCode GetCategory(SafeAppControlHandle handle, out string category);
85
86         [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_category")]
87         internal static extern ErrorCode SetCategory(SafeAppControlHandle handle, string category);
88
89         [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_app_id")]
90         internal static extern ErrorCode GetAppId(SafeAppControlHandle handle, out string appId);
91
92         [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_app_id")]
93         internal static extern ErrorCode SetAppId(SafeAppControlHandle handle, string appId);
94
95         [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_launch_mode")]
96         internal static extern ErrorCode SetLaunchMode(SafeAppControlHandle handle, int mode);
97
98         [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_launch_mode")]
99         internal static extern ErrorCode GetLaunchMode(SafeAppControlHandle handle, out int mode);
100
101         [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_caller")]
102         internal static extern ErrorCode GetCaller(SafeAppControlHandle handle, out string caller);
103
104         [DllImport(Libraries.AppControl, EntryPoint = "app_control_is_reply_requested")]
105         internal static extern ErrorCode IsReplyRequested(SafeAppControlHandle handle, out bool requested);
106
107         [DllImport(Libraries.AppControl, EntryPoint = "app_control_add_extra_data")]
108         internal static extern ErrorCode AddExtraData(SafeAppControlHandle handle, string key, string value);
109
110         [DllImport(Libraries.AppControl, EntryPoint = "app_control_remove_extra_data")]
111         internal static extern ErrorCode RemoveExtraData(SafeAppControlHandle handle, string key);
112
113         [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_extra_data")]
114         internal static extern ErrorCode GetExtraData(SafeAppControlHandle handle, string key, out string value);
115
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);
118
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);
121
122         [DllImport(Libraries.AppControl, EntryPoint = "app_control_is_extra_data_array")]
123         internal static extern ErrorCode IsExtraDataArray(SafeAppControlHandle handle, string key, out bool array);
124
125         [DllImport(Libraries.AppControl, EntryPoint = "app_control_destroy")]
126         internal static extern ErrorCode DangerousDestroy(IntPtr handle);
127
128         [DllImport(Libraries.AppControl, EntryPoint = "app_control_foreach_extra_data")]
129         internal static extern ErrorCode ForeachExtraData(SafeAppControlHandle handle, ExtraDataCallback callback, IntPtr userData);
130
131         [DllImport(Libraries.AppControl, EntryPoint = "app_control_foreach_app_matched")]
132         internal static extern ErrorCode ForeachAppMatched(SafeAppControlHandle handle, AppMatchedCallback callback, IntPtr userData);
133
134         [DllImport(Libraries.AppControl, EntryPoint = "app_control_send_launch_request")]
135         internal static extern ErrorCode SendLaunchRequest(SafeAppControlHandle handle, ReplyCallback callback, IntPtr userData);
136
137         [DllImport(Libraries.AppControl, EntryPoint = "app_control_send_terminate_request")]
138         internal static extern ErrorCode SendTerminateRequest(SafeAppControlHandle handle);
139
140         [DllImport(Libraries.AppControl, EntryPoint = "app_control_reply_to_launch_request")]
141         internal static extern ErrorCode ReplyToLaunchRequest(SafeAppControlHandle reply, SafeAppControlHandle request, int result);
142
143         [DllImport(Libraries.AppControl, EntryPoint = "app_control_enable_app_started_result_event")]
144         internal static extern ErrorCode EnableAppStartedResultEvent(SafeAppControlHandle handle);
145
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);
148     }
149 }