Osp-Installer merge changes from tizen_2.2
[platform/framework/native/installer.git] / inc / InstallerDefs.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18  * @file        InstallerDefs.h
19  */
20
21 #ifndef _INSTALLER_DEFS_H_
22 #define _INSTALLER_DEFS_H_
23
24 #include "InstallerUtil.h"
25
26 #define OSP_INSTALLER_VERSION "version=[20131029.2]"
27
28 #define DIR_BIN                         L"/bin"
29 #define DIR_INFO                        L"/info"
30 #define DIR_RES                         L"/res"
31 #define DIR_DATA                        L"/data"
32 #define DIR_ICONS                       L"/icons"
33 #define DIR_SHARED                      L"/shared"
34 #define DIR_LIB                         L"/lib"
35 #define DIR_SETTING                     L"/setting"
36 #define DIR_CONTENTS            L"/contents"
37 #define DIR_SHARED_RES          L"/shared/res"
38 #define DIR_SHARED_DATA         L"/shared/data"
39 #define DIR_SHARED_TRUSTED      L"/shared/trusted"
40
41 #define SLP_DIR_BIN                     L"/bin"
42 #define SLP_DIR_RES                     L"/res"
43 #define SLP_DIR_DATA            L"/data"
44 #define SLP_APP_PATH            L"/opt/apps"
45
46 #define PATH_OPT_APPS           L"/opt/apps"
47 #define PATH_USR_APPS           L"/usr/apps"
48 #define PATH_OPT_USR            L"/opt/usr"
49 #define PATH_OPT_USR_APPS       L"/opt/usr/apps"
50
51 #define SLP_FONT_PATH           L"/opt/share/fonts"
52
53 #define DIR_DESKTOP                                     L"/opt/share/applications/%S.desktop"
54 #define PACKAGE_NAME_PREFIX_ORG         L"org.tizen."
55 #define PACKAGE_NAME_RULE_ORG           L"org.tizen.%ls#%s"
56
57 #define PACKAGE_NAME_RULE                       L"%ls.%s"
58 #define BACKUP_NAME_RULE                        L"_backup"
59
60 #define FILE_EXT_INFO                           L"info"
61 #define VERSION_INFO_FILE                       L"/info/version.info"
62 #define COMPAT_INFO_FILE                        L"/info/compat.info"
63 #define VIRTUAL_ROOT_INFO_FILE          L"/info/virtualroot.info"
64 #define UISCALABILITY_INFO_FILE         L"/uiscalability.info"
65 #define UITHEME_INFO_FILE                                       L"/uitheme.info"
66 #define DISABLE_SCREEN_READER_INFO_FILE                                 L"/disablescreenreader.info"
67 #define WEBSERVICE_INFO_FILE            L"/info/webservice.info"
68 #define TYPE_INFO_FILE                          L"/info/type.info"
69 #define PACKAGE_XML_FILE                        L"/info/manifest.xml"
70
71 #define SIGNATURE1_XML_FILE                     L"/signature1.xml"
72 #define AUTHOR_SIGNATURE_XML_FILE       L"/author-signature.xml"
73
74 #define UISCALABILITY_INFO                      L"1 %ls %ls %ls"
75 #define UITHEME_INFO                                            L"1 %ls %ls"
76
77 #define CONFIG_PATH                                     L"/usr/etc/installer-config.ini"
78
79 #define UIAPP_LOADER_PATH                       "/usr/lib/osp/osp-ui-app-loader"                        // UiApp
80 #define SERVICEAPP_LOADER_PATH          "/usr/lib/osp/osp-service-app-loader"           // ServiceApp
81 #define SYSTEMSERIVCE_LOADER_PATH       "/usr/lib/osp/osp-system-service-loader"        // System Service
82 #define EXEC_LOADER_PATH                                        "/usr/lib/osp/osp-exec-loader"  // Exec
83 #define IME_PATH                                        "/opt/apps/scim/lib/scim-1.0/1.4.0/Helper"
84
85 #define SUB_MODE_APPCONTROL_NAME        L"_AppControl"
86
87 #define APP_OWNER_ID            5000
88 #define APP_GROUP_ID            5000
89
90 #define PACKAGE_ID_LENGTH       10
91 #define APP_DIR_LENGTH          20
92
93 #define TEST_ARG_COUNT          1
94 #define COMMAND_ARG_COUNT       3
95 #define TERMINATE_RETRY_COUNT   300
96
97 #define DIR_OSP_APPLICATIONS_TEMP                               L"/opt/usr/apps/__@@osp_tmp@@__"
98 #define DIR_INSTALL_LOGS                                                L"/opt/usr/apps/logs"
99
100 #define DIR_RO_PACKAGE_SYSTEM_MANIFEST                  L"/usr/share/packages/%ls.xml"
101 #define DIR_RW_PACKAGE_SYSTEM_MANIFEST                  L"/opt/share/packages/%ls.xml"
102
103 #define DIR_MEMORYCARD_OSP_APPLICATIONS                 L"/opt/storage/sdcard/apps"
104 #define DIR_MEMORYCARD_OSP_APPLICATIONS_TEMP    L"/opt/storage/sdcard/apps/__@@osp_tmp@@__"
105
106 #define DIR_RECOVERY_TPK                                        L"/opt/share/packages/.recovery/tpk"
107
108 #define PERM_BASE                                                               (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)         // 0644
109 #define PERM_EXECUTE                                                    (S_IXUSR | S_IXGRP | S_IXOTH)
110 #define PERM_WRITE                                                              (S_IWUSR | S_IWGRP | S_IWOTH)
111
112 #define PERM_OWNER_ROOT                                                 0
113 #define PERM_OWNER_APP                                                  1
114
115 #define PERM_SMACK_0                                                    0
116 #define PERM_SMACK_1                                                    1
117 #define PERM_SMACK_2                                                    2
118 #define PERM_SMACK_3                                                    3
119
120 #define TIZEN_PRIVILEGE_WEB_SERVICE                             "http://tizen.org/privilege/web.service"
121 #define TIZEN_CATEGORY_IME                                              "http://tizen.org/category/ime"
122 #define TIZEN_CATEGORY_HOMESCREEN                               "http://tizen.org/category/homescreen"
123 #define TIZEN_CATEGORY_LOCKSCREEN                               "http://tizen.org/category/lockscreen"
124 #define TIZEN_CATEGORY_MENUSCREEN                               "http://tizen.org/category/menuscreen"
125 #define TIZEN_CATEGORY_ANTIVIRUS                                "http://tizen.org/category/antivirus"
126
127 // custom metadata
128 #define METADATA_FONT                                                   L"http://developer.samsung.com/tizen/metadata/font"
129 #define METADATA_SPLASH                                                 L"http://developer.samsung.com/tizen/metadata/splash"
130 #define METADATA_SPLASH_INDICATOR_DISPLAY               L"http://developer.samsung.com/tizen/metadata/splash/indicatordisplay"
131 #define METADATA_SPLASH_PORTRAIT                                L"http://developer.samsung.com/tizen/metadata/splash/portrait"
132 #define METADATA_SPLASH_LANDSCAPE                               L"http://developer.samsung.com/tizen/metadata/splash/landscape"
133 #define METADATA_DISABLE_SCREEN_READER  L"http://developer.samsung.com/tizen/metadata/disablescreenreader"
134 #define METADATA_COMPATIBLE_MEMORY_LAYOUT       L"http://developer.samsung.com/tizen/metadata/compatible_memory_layout"
135
136 #define DIR_APPLICATIONS_TMP                                    "/opt/usr/apps/tmp"
137
138 #define INSTALLER_RDS_FILE_NAME                                 ".rds_delta"
139 #define INSTALLER_RDS_DELETE_STR                                "delete"
140 #define INSTALLER_RDS_ADD_STR                                   "add"
141 #define INSTALLER_RDS_MODIFY_STR                                "modify"
142
143 static const int INSTALLER_BLOCK_SIZE = 4096;
144 static const int SIGNATURE_FILE_NUMBER_DISTRIBUTOR = 1;
145 static const int SIGNATURE_FILE_NUMBER_DISTRIBUTOR2 = 2;
146
147 #define OSP_INSTALLER   "osp-installer"
148
149 #ifdef AppLog
150 #undef AppLog
151 #define AppLog(...)             AppLogTagInternal(OSP_INSTALLER, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__); \
152                                                 InstallerUtil::AppendLog(__PRETTY_FUNCTION__, __LINE__, false, __VA_ARGS__);
153 #endif
154
155 #ifdef TryCatch
156 #undef TryCatch
157 #define TryCatch(condition, expr, ...) \
158         if (!(condition)) { \
159                 AppLogExceptionTag(OSP_INSTALLER, __VA_ARGS__); \
160                 expr; \
161                 InstallerUtil::AppendLog(__PRETTY_FUNCTION__, __LINE__, true, __VA_ARGS__); \
162                 goto CATCH;     \
163         } \
164         else {;}
165 #endif
166
167 #ifdef TryReturn
168 #undef TryReturn
169 #define TryReturn(condition, returnValue, ...)  \
170         if (!(condition)) { \
171                 AppLogExceptionTag(OSP_INSTALLER, __VA_ARGS__); \
172                 InstallerUtil::AppendLog(__PRETTY_FUNCTION__, __LINE__, true, __VA_ARGS__); \
173                 return returnValue;     \
174         } \
175         else {;}
176 #endif
177
178 enum InstallationSetStep
179 {
180         INSTALLER_STEP_REMOVE,
181         INSTALLER_STEP_SET,
182
183 };
184
185 enum InstallationState
186 {
187         INSTALLER_STATE_READY,
188         INSTALLER_STATE_RUNNING,
189
190 };
191
192 enum InstallationStep
193 {
194         INSTALLER_STEP_NONE = 0,
195         INSTALLER_STEP_INIT,
196         INSTALLER_STEP_CHECK_PACKAGE,
197         INSTALLER_STEP_DRM,
198         INSTALLER_STEP_PARSE_MANIFEST,
199         INSTALLER_STEP_CHECK_SYSTEM,
200         INSTALLER_STEP_UNPACK,
201         INSTALLER_STEP_LICENSE,
202         INSTALLER_STEP_PARSE_SIGNATURE,
203
204         INSTALLER_STEP_INIT_UNINSTALL,
205         INSTALLER_STEP_UNINSTALL,
206         INSTALLER_STEP_END,
207
208         INSTALLER_STEP_RDS_INIT,
209         INSTALLER_STEP_RDS,
210
211         INSTALLER_STEP_MAX,
212
213 };
214
215 enum InstallerType
216 {
217         INSTALLER_TYPE_INSTALLER,
218         INSTALLER_TYPE_PACKAGE,
219         INSTALLER_TYPE_DIRECTORY,
220         INSTALLER_TYPE_GUEST,
221         INSTALLER_TYPE_PRELOADED,
222         INSTALLER_TYPE_IDE,
223         INSTALLER_TYPE_RESTORATION,
224
225 };
226
227 enum InstallerOption
228 {
229         INSTALLER_OPTION_NONE = 0,
230         INSTALLER_OPTION_NORMAL = 1,
231         INSTALLER_OPTION_IDE = 2,
232         INSTALLER_OPTION_PRELOADED = 4,
233         INSTALLER_OPTION_HYBRID = 8,
234         INSTALLER_OPTION_NO_INPUT = 16,
235         INSTALLER_OPTION_FILELOG_ON = 32,
236         INSTALLER_OPTION_UPDATE_STDOUT = 64,
237         INSTALLER_OPTION_CSC = 128,
238         INSTALLER_OPTION_RESET_PRELOADED = 256,
239
240 };
241
242 enum InstallerError
243 {
244         INSTALLER_ERROR_NONE = 0,
245         INSTALLER_ERROR_PACKAGE_NOT_FOUND = 1,
246         INSTALLER_ERROR_PACKAGE_INVALID = 2,
247         INSTALLER_ERROR_PACKAGE_LOWER_VERSION = 3,
248         INSTALLER_ERROR_EXECUTABLE_NOT_FOUND = 4,
249         INSTALLER_ERROR_MANIFEST_NOT_FOUND = 11,
250         INSTALLER_ERROR_MANIFEST_INVALID = 12,
251         INSTALLER_ERROR_SIGNATURE_NOT_FOUND = 21,
252         INSTALLER_ERROR_SIGNATURE_INVALID = 22,
253         INSTALLER_ERROR_SIGNATURE_VERIFICATION_FAILED = 23,
254         INSTALLER_ERROR_ROOT_CERTIFICATE_NOT_FOUND = 31,
255         INSTALLER_ERROR_CERTIFICATE_INVALID = 32,
256         INSTALLER_ERROR_CERTIFICATE_CHAIN_VERIFICATION_FAILED = 33,
257         INSTALLER_ERROR_CERTIFICATE_EXPIRED = 34,
258         INSTALLER_ERROR_PRIVILEGE_INVALID = 41,
259         INSTALLER_ERROR_MENU_ICON_NOT_FOUND = 51,
260         INSTALLER_ERROR_FATAL_ERROR = 61,
261         INSTALLER_ERROR_OUT_OF_STORAGE = 62,
262         INSTALLER_ERROR_OUT_OF_MEMORY = 63,
263         INSTALLER_ERROR_DISABLED = 65,
264         INSTALLER_ERROR_PRIVILEGE_BLACKLIST = 66,
265         INSTALLER_ERROR_SIGNATURE_BLACKLIST = 67,
266
267         INSTALLER_ERROR_USER_CANCEL = 141,
268         INSTALLER_ERROR_UNMOUNT_FAILED = 142,
269         INSTALLER_ERROR_INTERNAL_STATE = 143,
270         INSTALLER_ERROR_DATABASE = 144,
271         INSTALLER_ERROR_DRM = 145,
272         INSTALLER_ERROR_BACKUP_FAILED = 146,
273 };
274
275 enum InstallerOperation
276 {
277         INSTALLER_OPERATION_INSTALL,
278         INSTALLER_OPERATION_UNINSTALL,
279         INSTALLER_OPERATION_REINSTALL,
280
281 };
282
283 enum RootCertificateType
284 {
285         ROOT_CERTIFICATE_NONE = 0,
286         ROOT_CERTIFICATE_DEVELOPER,
287         ROOT_CERTIFICATE_PUBLIC,
288         ROOT_CERTIFICATE_PARTNER,
289         ROOT_CERTIFICATE_PARTNER_OPERATOR,
290         ROOT_CERTIFICATE_PARTNER_MANUFACTURER,
291
292         ROOT_CERTIFICATE_CERT_SVC_PUBLIC = (1 << 6),
293         ROOT_CERTIFICATE_CERT_SVC_PARTNER = (1 << 7),
294         ROOT_CERTIFICATE_CERT_SVC_PARTNER_OPERATOR = (1 << 8),
295         ROOT_CERTIFICATE_CERT_SVC_PARTNER_MANUFACTURER = (1 << 9),
296         ROOT_CERTIFICATE_CERT_SVC_PLATFORM = (1 << 10),
297
298 };
299
300 enum SignatureFileType
301 {
302         SIGNATURE_FILE_TYPE_NONE,
303         SIGNATURE_FILE_TYPE_AUTHOR,
304         SIGNATURE_FILE_TYPE_DISTRIBUTOR,
305         SIGNATURE_FILE_TYPE_DISTRIBUTOR2,
306
307 };
308
309 enum
310 {
311         INSTALLER_MODE_INSTALL = 1,
312         INSTALLER_MODE_UNINSTALL = 2,
313         INSTALLER_MODE_RECURSIVE_DIRECTORY_INSTALL = 3,
314         INSTALLER_MODE_REINSTALL = 4,
315         INSTALLER_MODE_PARSE_CSC_STRING = 5,
316         INSTALLER_MODE_RECOVERY = 6,
317 };
318
319 enum CategoryType
320 {
321         CATEGORY_TYPE_NONE,
322         CATEGORY_TYPE_IME,
323         CATEGORY_TYPE_HOME_SCREEN,
324         CATEGORY_TYPE_LOCK_SCREEN,
325
326 };
327
328 enum InstallationStorage
329 {
330         INSTALLATION_STORAGE_NONE,
331         INSTALLATION_STORAGE_INTERNAL,
332         INSTALLATION_STORAGE_EXTERNAL,
333
334 };
335
336 enum InstallerRdsState
337 {
338         INSTALLER_RDS_STATE_NONE,
339         INSTALLER_RDS_STATE_DELETE,
340         INSTALLER_RDS_STATE_ADD,
341         INSTALLER_RDS_STATE_MODIFY,
342
343 };
344
345 typedef struct
346 {
347         const char* pDir;
348         int dirType;
349         int ownerIndex;
350         int modeIndex;
351         int smackIndex;
352
353 } RdsPermssions;
354
355 enum PermDirType
356 {
357         PERM_DIR_RES = 0,
358         PERM_DIR_DATA = 1,
359         PERM_DIR_BIN = 2,
360         PERM_DIR_INFO = 3,
361         PERM_DIR_LIB = 4,
362         PERM_DIR_SETTING = 5,
363         PERM_DIR_SHARED_RES = 6,
364         PERM_DIR_SHARED_DATA = 7,
365         PERM_DIR_SHARED_TRUSTED = 8,
366         PERM_DIR_SHARED = 9,
367         PERM_DIR_ROOT = 10,
368 };
369
370 enum PrivilegeLevel
371 {
372         PRIVILEGE_LEVEL_PUBLIC,
373         PRIVILEGE_LEVEL_PARTNER,
374         PRIVILEGE_LEVEL_PLATFORM,
375
376 };
377
378 enum ApiVisibility
379 {
380         API_VISIBILITY_PUBLIC = 1,
381         API_VISIBILITY_PARTNER,
382         API_VISIBILITY_PLATFORM,
383
384 };
385 #endif // _INSTALLER_DEFS_H_