Release 4.0.0-preview1-00051
[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         internal delegate bool ExtraDataCallback(IntPtr handle, string key, IntPtr userData);
29         internal delegate bool AppMatchedCallback(IntPtr handle, string applicationId, IntPtr userData);
30         internal delegate void ReplyCallback(IntPtr request, IntPtr reply, int result, IntPtr userData);
31
32         internal enum ErrorCode
33         {
34             None = Tizen.Internals.Errors.ErrorCode.None,
35             InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
36             OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
37             AppNotFound = -0x01100000 | 0x21,
38             KeyNotFound = Tizen.Internals.Errors.ErrorCode.KeyNotAvailable,
39             KeyRejected = Tizen.Internals.Errors.ErrorCode.KeyRejected,
40             InvalidDataType = -0x01100000 | 0x22,
41             LaunchRejected = -0x01100000 | 0x23,
42             PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
43             LaunchFailed = -0x01100000 | 0x24,
44             IoError = Tizen.Internals.Errors.ErrorCode.IoError,
45             TimedOut = Tizen.Internals.Errors.ErrorCode.TimedOut,
46         }
47
48         [DllImport(Libraries.AppControl, EntryPoint = "app_control_create")]
49         internal static extern ErrorCode Create(out SafeAppControlHandle handle);
50
51         [DllImport(Libraries.AppControl, EntryPoint = "app_control_clone")]
52         internal static extern ErrorCode DangerousClone(out SafeAppControlHandle clone, IntPtr handle);
53
54         [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_app_id")]
55         internal static extern ErrorCode GetAppId(IntPtr app_control, out IntPtr app_id);
56
57         [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_operation")]
58         internal static extern ErrorCode GetOperation(SafeAppControlHandle handle, out string operation);
59
60         [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_operation")]
61         internal static extern ErrorCode SetOperation(SafeAppControlHandle handle, string operation);
62
63         [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_uri")]
64         internal static extern ErrorCode GetUri(SafeAppControlHandle handle, out string uri);
65
66         [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_uri")]
67         internal static extern ErrorCode SetUri(SafeAppControlHandle handle, string uri);
68
69         [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_mime")]
70         internal static extern ErrorCode GetMime(SafeAppControlHandle handle, out string mime);
71
72         [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_mime")]
73         internal static extern ErrorCode SetMime(SafeAppControlHandle handle, string mime);
74
75         [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_category")]
76         internal static extern ErrorCode GetCategory(SafeAppControlHandle handle, out string category);
77
78         [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_category")]
79         internal static extern ErrorCode SetCategory(SafeAppControlHandle handle, string category);
80
81         [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_app_id")]
82         internal static extern ErrorCode GetAppId(SafeAppControlHandle handle, out string appId);
83
84         [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_app_id")]
85         internal static extern ErrorCode SetAppId(SafeAppControlHandle handle, string appId);
86
87         [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_launch_mode")]
88         internal static extern ErrorCode SetLaunchMode(SafeAppControlHandle handle, int mode);
89
90         [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_launch_mode")]
91         internal static extern ErrorCode GetLaunchMode(SafeAppControlHandle handle, out int mode);
92
93         [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_caller")]
94         internal static extern ErrorCode GetCaller(SafeAppControlHandle handle, out string caller);
95
96         [DllImport(Libraries.AppControl, EntryPoint = "app_control_is_reply_requested")]
97         internal static extern ErrorCode IsReplyRequested(SafeAppControlHandle handle, out bool requested);
98
99         [DllImport(Libraries.AppControl, EntryPoint = "app_control_add_extra_data")]
100         internal static extern ErrorCode AddExtraData(SafeAppControlHandle handle, string key, string value);
101
102         [DllImport(Libraries.AppControl, EntryPoint = "app_control_remove_extra_data")]
103         internal static extern ErrorCode RemoveExtraData(SafeAppControlHandle handle, string key);
104
105         [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_extra_data")]
106         internal static extern ErrorCode GetExtraData(SafeAppControlHandle handle, string key, out string value);
107
108         [DllImport(Libraries.AppControl, EntryPoint = "app_control_add_extra_data_array")]
109         internal static extern ErrorCode AddExtraDataArray(SafeAppControlHandle handle, string key, string[] value, int length);
110
111         [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_extra_data_array")]
112         internal static extern ErrorCode GetExtraDataArray(SafeAppControlHandle handle, string key, out IntPtr value, out int length);
113
114         [DllImport(Libraries.AppControl, EntryPoint = "app_control_is_extra_data_array")]
115         internal static extern ErrorCode IsExtraDataArray(SafeAppControlHandle handle, string key, out bool array);
116
117         [DllImport(Libraries.AppControl, EntryPoint = "app_control_destroy")]
118         internal static extern ErrorCode DangerousDestroy(IntPtr handle);
119
120         [DllImport(Libraries.AppControl, EntryPoint = "app_control_foreach_extra_data")]
121         internal static extern ErrorCode ForeachExtraData(SafeAppControlHandle handle, ExtraDataCallback callback, IntPtr userData);
122
123         [DllImport(Libraries.AppControl, EntryPoint = "app_control_foreach_app_matched")]
124         internal static extern ErrorCode ForeachAppMatched(SafeAppControlHandle handle, AppMatchedCallback callback, IntPtr userData);
125
126         [DllImport(Libraries.AppControl, EntryPoint = "app_control_send_launch_request")]
127         internal static extern ErrorCode SendLaunchRequest(SafeAppControlHandle handle, ReplyCallback callback, IntPtr userData);
128
129         [DllImport(Libraries.AppControl, EntryPoint = "app_control_send_terminate_request")]
130         internal static extern ErrorCode SendTerminateRequest(SafeAppControlHandle handle);
131
132         [DllImport(Libraries.AppControl, EntryPoint = "app_control_reply_to_launch_request")]
133         internal static extern ErrorCode ReplyToLaunchRequest(SafeAppControlHandle reply, SafeAppControlHandle request, int result);
134
135         [DllImport(Libraries.AppControl, EntryPoint = "app_control_enable_app_started_result_event")]
136         internal static extern ErrorCode EnableAppStartedResultEvent(SafeAppControlHandle handle);
137     }
138 }