Merge remote-tracking branch 'download/tizen'
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.PackageManager / Interop / Interop.PackageManager.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 using Tizen.Applications;
20
21 internal static partial class Interop
22 {
23     internal static partial class PackageManager
24     {
25         [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
26         internal delegate void PackageManagerEventCallback(string type, string packageId, EventType eventType, PackageEventState eventState, int progress, ErrorCode error, IntPtr userData);
27
28         [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
29         internal delegate bool PackageManagerPackageInfoCallback(IntPtr handle, IntPtr userData);
30
31         [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
32         internal delegate void PackageManagerSizeInfoCallback(string packageId, IntPtr sizeInfoHandle, IntPtr userData);
33
34         [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
35         internal delegate void PackageManagerTotalSizeInfoCallback(IntPtr sizeInfoHandle, IntPtr userData);
36
37         [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
38         internal delegate void PackageManagerRequestEventCallback(int requestId, string type, string packageId, EventType eventType, PackageEventState eventState, int progress, ErrorCode error, IntPtr userData);
39
40         // Any change here might require changes in Tizen.Applications.PackageManagerEventError enum
41         internal enum ErrorCode
42         {
43             None = Tizen.Internals.Errors.ErrorCode.None,
44             InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
45             OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
46             IoError = Tizen.Internals.Errors.ErrorCode.IoError,
47             NoSuchPackage = -0x01150000 | 0x71,
48             SystemError = -0x01150000 | 0x72,
49             PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied
50         }
51
52         // Any change here might require changes in Tizen.Applications.PackageEventState enum
53         internal enum PackageEventState
54         {
55             Started = 0,
56             Processing = 1,
57             Completed = 2,
58             Failed = 3
59         }
60
61         [Flags]
62         internal enum EventStatus
63         {
64             All = 0x00,
65             Install = 0x01,
66             Uninstall = 0x02,
67             Upgrade = 0x04,
68             Move = 0x08,
69             ClearData = 0x10,
70             Progress = 0x20,
71         }
72
73         internal enum EventType
74         {
75             Install = 0,
76             Uninstall = 1,
77             Update = 2,
78             Move = 3,
79             ClearData = 4
80         }
81
82         internal enum CertCompareResultType
83         {
84             Match = 0,
85             Mismatch,
86             LhsNoCert,
87             RhsNoCert,
88             BothNoCert
89         }
90
91         internal enum PackageManagerPermissionType
92         {
93             Normal = 0,
94             Signature,
95             Privilege
96         }
97
98         // Any change here might require changes in Tizen.Applications.StorageType enum
99         internal enum StorageType
100         {
101             Internal = 0,
102             External = 1
103         }
104
105         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_create")]
106         internal static extern ErrorCode PackageManagerCreate(out SafePackageManagerHandle managerHandle);
107
108         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_destroy")]
109         internal static extern ErrorCode PackageManagerDestroy(IntPtr managerHandle);
110
111         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_set_event_status")]
112         internal static extern ErrorCode PackageManagerSetEvenStatus(SafePackageManagerHandle managerHandle, EventStatus eventStatus);
113
114         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_set_event_cb")]
115         internal static extern ErrorCode PackageManagerSetEvent(SafePackageManagerHandle managerHandle, PackageManagerEventCallback callback, IntPtr userData);
116
117         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_unset_event_cb")]
118         internal static extern ErrorCode PackageManagerUnsetEvent(SafePackageManagerHandle managerHandle);
119
120         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_foreach_package_info")]
121         internal static extern ErrorCode PackageManagerForeachPackageInfo(PackageManagerPackageInfoCallback callback, IntPtr userData);
122
123         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_get_package_size_info")]
124         internal static extern ErrorCode PackageManagerGetSizeInfo(string packageId, PackageManagerSizeInfoCallback callback, IntPtr userData);
125
126         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_get_total_package_size_info")]
127         internal static extern ErrorCode PackageManagerGetTotalSizeInfo(PackageManagerTotalSizeInfoCallback callback, IntPtr userData);
128
129         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_get_package_id_by_app_id")]
130         internal static extern ErrorCode PackageManageGetPackageIdByAppId(string app_id, out string package_id);
131
132         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_get_package_info")]
133         internal static extern ErrorCode PackageManagerGetPackageInfo(string packageId, out IntPtr packageInfoHandle);
134
135         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_clear_cache_dir")]
136         internal static extern ErrorCode PackageManagerClearCacheDir(string packageId);
137
138         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_clear_all_cache_dir")]
139         internal static extern ErrorCode PackageManagerClearAllCacheDir();
140
141         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_clear_data_dir")]
142         internal static extern ErrorCode PackageManagerClearDataDir(string packageId);
143
144         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_filter_create")]
145         internal static extern ErrorCode PackageManagerFilterCreate(out IntPtr handle);
146
147         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_filter_destroy")]
148         internal static extern ErrorCode PackageManagerFilterDestroy(IntPtr handle);
149
150         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_filter_add_bool")]
151         internal static extern ErrorCode PackageManagerFilterAdd(IntPtr handle, string property, bool value);
152
153         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_filter_foreach_package_info")]
154         internal static extern ErrorCode PackageManagerFilterForeachPackageInfo(IntPtr handle, PackageManagerPackageInfoCallback callback, IntPtr userData);
155
156         [DllImport(Libraries.PackageManager, EntryPoint = "package_size_info_get_data_size")]
157         internal static extern ErrorCode PackageSizeInfoGetDataSize(IntPtr handle, out long dataSize);
158
159         [DllImport(Libraries.PackageManager, EntryPoint = "package_size_info_get_cache_size")]
160         internal static extern ErrorCode PackageSizeInfoGetCacheSize(IntPtr handle, out long cacheSize);
161
162         [DllImport(Libraries.PackageManager, EntryPoint = "package_size_info_get_app_size")]
163         internal static extern ErrorCode PackageSizeInfoGetAppSize(IntPtr handle, out long appSize);
164
165         [DllImport(Libraries.PackageManager, EntryPoint = "package_size_info_get_external_data_size")]
166         internal static extern ErrorCode PackageSizeInfoGetExtDataSize(IntPtr handle, out long extDataSize);
167
168         [DllImport(Libraries.PackageManager, EntryPoint = "package_size_info_get_external_cache_size")]
169         internal static extern ErrorCode PackageSizeInfoGetExtCacheSize(IntPtr handle, out long extCacheSize);
170
171         [DllImport(Libraries.PackageManager, EntryPoint = "package_size_info_get_external_app_size")]
172         internal static extern ErrorCode PackageSizeInfoGetExtAppSize(IntPtr handle, out long extAppSize);
173
174         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_create")]
175         internal static extern ErrorCode PackageManagerRequestCreate(out SafePackageManagerRequestHandle requestHandle);
176
177         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_destroy")]
178         internal static extern ErrorCode PackageManagerRequestDestroy(IntPtr requestHandle);
179
180         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_set_type")]
181         internal static extern ErrorCode PackageManagerRequestSetType(SafePackageManagerRequestHandle requestHandle, string type);
182
183         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_set_tep")]
184         internal static extern ErrorCode PackageManagerRequestSetTepPath(SafePackageManagerRequestHandle requestHandle, string tepPath);
185
186         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_install")]
187         internal static extern ErrorCode PackageManagerRequestInstall(SafePackageManagerRequestHandle requestHandle, string path, out int id);
188
189         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_mount_install")]
190         internal static extern ErrorCode PackageManagerRequestMountInstall(SafePackageManagerRequestHandle requestHandle, string path, out int id);
191
192         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_uninstall")]
193         internal static extern ErrorCode PackageManagerRequestUninstall(SafePackageManagerRequestHandle requestHandle, string name, out int id);
194
195         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_move")]
196         internal static extern ErrorCode PackageManagerRequestMove(SafePackageManagerRequestHandle requestHandle, string name, StorageType moveToStorageType);
197
198         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_compare_package_cert_info")]
199         internal static extern ErrorCode PackageManagerCompareCertInfo(string lhsPackageId, string rhsPackageId, out CertCompareResultType CompareResult);
200
201         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_compare_app_cert_info")]
202         internal static extern ErrorCode PackageManagerCompareCertInfoByApplicationId(string lhsPackageId, string rhsPackageId, out CertCompareResultType CompareResult);
203
204         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_is_preload_package_by_app_id")]
205         internal static extern ErrorCode PackageManagerIsPreloadPackageByApplicationId(string ApplicationId, out bool IsPreload);
206
207         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_get_permission_type")]
208         internal static extern ErrorCode PackageManagerGetPermissionType(string ApplicationId, out PackageManagerPermissionType PermissionType);
209
210         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_drm_generate_license_request")]
211         internal static extern ErrorCode PackageManagerDrmGenerateLicenseRequest(string responseData, out string requestData, out string licenseUrl);
212
213         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_drm_register_license")]
214         internal static extern ErrorCode PackageManagerDrmRegisterLicense(string responseData);
215
216         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_drm_decrypt_package")]
217         internal static extern ErrorCode PackageManagerDrmDecryptPackage(string drmFilePath, string decryptedFilePath);
218
219         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_install_with_cb")]
220         internal static extern ErrorCode PackageManagerRequestInstallWithCB(SafePackageManagerRequestHandle requestHandle, string path, PackageManagerRequestEventCallback callback, IntPtr userData, out int id);
221
222         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_mount_install_with_cb")]
223         internal static extern ErrorCode PackageManagerRequestMountInstallWithCB(SafePackageManagerRequestHandle requestHandle, string path, PackageManagerRequestEventCallback callback, IntPtr userData, out int id);
224
225         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_uninstall_with_cb")]
226         internal static extern ErrorCode PackageManagerRequestUninstallWithCB(SafePackageManagerRequestHandle requestHandle, string name, PackageManagerRequestEventCallback callback, IntPtr userData, out int id);
227
228         [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_request_move_with_cb")]
229         internal static extern ErrorCode PackageManagerRequestMoveWithCB(SafePackageManagerRequestHandle requestHandle, string name, StorageType moveToStorageType, PackageManagerRequestEventCallback callback, IntPtr userData, out int id);
230     }
231 }