manifest tags are checked for package privilege level.
[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=[20130611.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
59 #define FILE_EXT_INFO                           L"info"
60 #define VERSION_INFO_FILE                       L"/info/version.info"
61 #define COMPAT_INFO_FILE                        L"/info/compat.info"
62 #define VIRTUAL_ROOT_INFO_FILE          L"/info/virtualroot.info"
63 #define UISCALABILITY_INFO_FILE         L"/info/uiscalability.info"
64 #define WEBSERVICE_INFO_FILE            L"/info/webservice.info"
65 #define TYPE_INFO_FILE                          L"/info/type.info"
66 #define PACKAGE_XML_FILE                        L"/info/manifest.xml"
67
68 #define SIGNATURE1_XML_FILE                     L"/signature1.xml"
69 #define AUTHOR_SIGNATURE_XML_FILE       L"/author-signature.xml"
70
71 #define UISCALABILITY_INFO                      L"1 %ls %ls %ls"
72
73 #define CONFIG_PATH                                     L"/usr/etc/installer-config.ini"
74
75 #define UIAPP_LOADER_PATH                       "/usr/lib/osp/osp-ui-app-loader"                        // UiApp
76 #define SERVICEAPP_LOADER_PATH          "/usr/lib/osp/osp-service-app-loader"           // ServiceApp
77 #define SYSTEMSERIVCE_LOADER_PATH       "/usr/lib/osp/osp-system-service-loader"        // System Service
78 #define IME_PATH                                        "/opt/apps/scim/lib/scim-1.0/1.4.0/Helper"
79
80 #define SUB_MODE_APPCONTROL_NAME        L"_AppControl"
81
82 #define APP_OWNER_ID            5000
83 #define APP_GROUP_ID            5000
84
85 #define PACKAGE_ID_LENGTH       10
86 #define APP_DIR_LENGTH          20
87
88 #define TEST_ARG_COUNT          1
89 #define COMMAND_ARG_COUNT       3
90 #define TERMINATE_RETRY_COUNT   300
91
92 #define DIR_OSP_APPLICATIONS_TEMP                               L"/opt/usr/apps/__@@osp_tmp@@__"
93 #define DIR_INSTALL_LOGS                                                L"/opt/usr/apps/logs"
94
95 #define DIR_RO_PACKAGE_SYSTEM_MANIFEST                  L"/usr/share/packages/%ls.xml"
96 #define DIR_RW_PACKAGE_SYSTEM_MANIFEST                  L"/opt/share/packages/%ls.xml"
97
98 #define DIR_MEMORYCARD_OSP_APPLICATIONS                 L"/opt/storage/sdcard/apps"
99 #define DIR_MEMORYCARD_OSP_APPLICATIONS_TEMP    L"/opt/storage/sdcard/apps/__@@osp_tmp@@__"
100 #define DIR_MEMORYCARD_INSTALLATION                             L"/opt/storage/sdcard/installtosdcard"
101
102 #define PERM_BASE                                                               (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)         // 0644
103 #define PERM_EXECUTE                                                    (S_IXUSR | S_IXGRP | S_IXOTH)
104 #define PERM_WRITE                                                              (S_IWUSR | S_IWGRP | S_IWOTH)
105
106 #define PERM_OWNER_ROOT                                                 0
107 #define PERM_OWNER_APP                                                  1
108
109 #define PERM_SMACK_0                                                    0
110 #define PERM_SMACK_1                                                    1
111 #define PERM_SMACK_2                                                    2
112 #define PERM_SMACK_3                                                    3
113
114 #define TIZEN_PRIVILEGE_WEB_SERVICE                             "http://tizen.org/privilege/web.service"
115 #define TIZEN_CATEGORY_IME                                              "http://tizen.org/category/ime"
116 #define TIZEN_CATEGORY_HOMESCREEN                               "http://tizen.org/category/homescreen"
117 #define TIZEN_CATEGORY_LOCKSCREEN                               "http://tizen.org/category/lockscreen"
118 #define TIZEN_CATEGORY_MENUSCREEN                               "http://tizen.org/category/menuscreen"
119 #define TIZEN_CATEGORY_ANTIVIRUS                                "http://tizen.org/category/antivirus"
120
121 // custom metadata
122 #define METADATA_FONT                                                   L"http://developer.samsung.com/tizen/metadata/font"
123 #define METADATA_SPLASH                                                 L"http://developer.samsung.com/tizen/metadata/splash"
124 #define METADATA_SPLASH_INDICATOR_DISPLAY               L"http://developer.samsung.com/tizen/metadata/splash/indicatordisplay"
125 #define METADATA_SPLASH_PORTRAIT                                L"http://developer.samsung.com/tizen/metadata/splash/portrait"
126 #define METADATA_SPLASH_LANDSCAPE                               L"http://developer.samsung.com/tizen/metadata/splash/landscape"
127
128 #define DIR_APPLICATIONS_TMP                                    "/opt/usr/apps/tmp"
129
130 #define INSTALLER_RDS_FILE_NAME                                 ".rds_delta"
131 #define INSTALLER_RDS_DELETE_STR                                "delete"
132 #define INSTALLER_RDS_ADD_STR                                   "add"
133 #define INSTALLER_RDS_MODIFY_STR                                "modify"
134
135 static const int BLOCK_SIZE = 4096;
136 static const int SIGNATURE_FILE_NUMBER_DISTRIBUTOR = 1;
137 static const int SIGNATURE_FILE_NUMBER_DISTRIBUTOR2 = 2;
138
139 #define OSP_INSTALLER   "osp-installer"
140
141 #ifdef AppLog
142 #undef AppLog
143 #define AppLog(...)             AppLogTagInternal(OSP_INSTALLER, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__); \
144                                                 InstallerUtil::AppendLog(__PRETTY_FUNCTION__, __LINE__, false, __VA_ARGS__);
145 #endif
146
147 #ifdef TryCatch
148 #undef TryCatch
149 #define TryCatch(condition, expr, ...) \
150         if (!(condition)) { \
151                 AppLogExceptionTag(OSP_INSTALLER, __VA_ARGS__); \
152                 expr; \
153                 InstallerUtil::AppendLog(__PRETTY_FUNCTION__, __LINE__, true, __VA_ARGS__); \
154                 goto CATCH;     \
155         } \
156         else {;}
157 #endif
158
159 #ifdef TryReturn
160 #undef TryReturn
161 #define TryReturn(condition, returnValue, ...)  \
162         if (!(condition)) { \
163                 AppLogExceptionTag(OSP_INSTALLER, __VA_ARGS__); \
164                 InstallerUtil::AppendLog(__PRETTY_FUNCTION__, __LINE__, true, __VA_ARGS__); \
165                 return returnValue;     \
166         } \
167         else {;}
168 #endif
169
170 enum InstallationSetStep
171 {
172         INSTALLER_STEP_REMOVE,
173         INSTALLER_STEP_SET,
174
175 };
176
177 enum InstallationState
178 {
179         INSTALLER_STATE_READY,
180         INSTALLER_STATE_RUNNING,
181
182 };
183
184 enum InstallationStep
185 {
186         INSTALLER_STEP_NONE = 0,
187         INSTALLER_STEP_INIT,
188         INSTALLER_STEP_CHECK_PACKAGE,
189         INSTALLER_STEP_DRM,
190         INSTALLER_STEP_PARSE_MANIFEST,
191         INSTALLER_STEP_CHECK_SYSTEM,
192         INSTALLER_STEP_UNPACK,
193         INSTALLER_STEP_LICENSE,
194         INSTALLER_STEP_PARSE_SIGNATURE,
195
196         INSTALLER_STEP_INIT_UNINSTALL,
197         INSTALLER_STEP_UNINSTALL,
198         INSTALLER_STEP_END,
199
200         INSTALLER_STEP_RDS_INIT,
201         INSTALLER_STEP_RDS,
202
203         INSTALLER_STEP_MAX,
204
205 };
206
207 enum InstallerType
208 {
209         INSTALLER_TYPE_INSTALLER,
210         INSTALLER_TYPE_PACKAGE,
211         INSTALLER_TYPE_DIRECTORY,
212         INSTALLER_TYPE_GUEST,
213         INSTALLER_TYPE_PRELOADED,
214         INSTALLER_TYPE_IDE,
215         INSTALLER_TYPE_RESTORATION,
216
217 };
218
219 enum InstallerOption
220 {
221         INSTALLER_OPTION_NONE = 0,
222         INSTALLER_OPTION_NORMAL = 1,
223         INSTALLER_OPTION_IDE = 2,
224         INSTALLER_OPTION_PRELOADED = 4,
225         INSTALLER_OPTION_HYBRID = 8,
226         INSTALLER_OPTION_NO_INPUT = 16,
227         INSTALLER_OPTION_FILELOG_ON = 32,
228         INSTALLER_OPTION_UPDATE_STDOUT = 64,
229         INSTALLER_OPTION_CSC = 128,
230         INSTALLER_OPTION_RESET_PRELOADED = 256,
231
232 };
233
234 enum InstallerError
235 {
236         INSTALLER_ERROR_NONE = 0,
237         INSTALLER_ERROR_PACKAGE_NOT_FOUND = 1,
238         INSTALLER_ERROR_PACKAGE_INVALID = 2,
239         INSTALLER_ERROR_PACKAGE_LOWER_VERSION = 3,
240         INSTALLER_ERROR_EXECUTABLE_NOT_FOUND = 4,
241         INSTALLER_ERROR_MANIFEST_NOT_FOUND = 11,
242         INSTALLER_ERROR_MANIFEST_INVALID = 12,
243         INSTALLER_ERROR_SIGNATURE_NOT_FOUND = 21,
244         INSTALLER_ERROR_SIGNATURE_INVALID = 22,
245         INSTALLER_ERROR_SIGNATURE_VERIFICATION_FAILED = 23,
246         INSTALLER_ERROR_ROOT_CERTIFICATE_NOT_FOUND = 31,
247         INSTALLER_ERROR_CERTIFICATE_INVALID = 32,
248         INSTALLER_ERROR_CERTIFICATE_CHAIN_VERIFICATION_FAILED = 33,
249         INSTALLER_ERROR_CERTIFICATE_EXPIRED = 34,
250         INSTALLER_ERROR_PRIVILEGE_INVALID = 41,
251         INSTALLER_ERROR_MENU_ICON_NOT_FOUND = 51,
252         INSTALLER_ERROR_FATAL_ERROR = 61,
253         INSTALLER_ERROR_OUT_OF_STORAGE = 62,
254         INSTALLER_ERROR_OUT_OF_MEMORY = 63,
255
256         INSTALLER_ERROR_USER_CANCEL = 141,
257         INSTALLER_ERROR_UNMOUNT_FAILED = 142,
258         INSTALLER_ERROR_INTERNAL_STATE = 143,
259         INSTALLER_ERROR_DATABASE = 144,
260         INSTALLER_ERROR_DRM = 145,
261 };
262
263 enum InstallerOperation
264 {
265         INSTALLER_OPERATION_INSTALL,
266         INSTALLER_OPERATION_UNINSTALL,
267         INSTALLER_OPERATION_REINSTALL,
268
269 };
270
271 enum RootCertificateType
272 {
273         ROOT_CERTIFICATE_NONE = 0,
274         ROOT_CERTIFICATE_DEVELOPER,
275         ROOT_CERTIFICATE_PUBLIC,
276         ROOT_CERTIFICATE_PARTNER,
277         ROOT_CERTIFICATE_PARTNER_OPERATOR,
278         ROOT_CERTIFICATE_PARTNER_MANUFACTURER,
279
280         ROOT_CERTIFICATE_CERT_SVC_PUBLIC = (1 << 6),
281         ROOT_CERTIFICATE_CERT_SVC_PARTNER = (1 << 7),
282         ROOT_CERTIFICATE_CERT_SVC_PARTNER_OPERATOR = (1 << 8),
283         ROOT_CERTIFICATE_CERT_SVC_PARTNER_MANUFACTURER = (1 << 9),
284         ROOT_CERTIFICATE_CERT_SVC_PLATFORM = (1 << 10),
285
286 };
287
288 enum SignatureFileType
289 {
290         SIGNATURE_FILE_TYPE_NONE,
291         SIGNATURE_FILE_TYPE_AUTHOR,
292         SIGNATURE_FILE_TYPE_DISTRIBUTOR,
293         SIGNATURE_FILE_TYPE_DISTRIBUTOR2,
294
295 };
296
297 enum
298 {
299         INSTALLER_MODE_INSTALL = 1,
300         INSTALLER_MODE_UNINSTALL = 2,
301         INSTALLER_MODE_RECURSIVE_DIRECTORY_INSTALL = 3,
302         INSTALLER_MODE_REINSTALL = 4,
303         INSTALLER_MODE_PARSE_CSC_STRING = 5,
304 };
305
306 enum CategoryType
307 {
308         CATEGORY_TYPE_NONE,
309         CATEGORY_TYPE_IME,
310         CATEGORY_TYPE_HOME_SCREEN,
311         CATEGORY_TYPE_LOCK_SCREEN,
312
313 };
314
315 enum InstallationStorage
316 {
317         INSTALLATION_STORAGE_NONE,
318         INSTALLATION_STORAGE_INTERNAL,
319         INSTALLATION_STORAGE_EXTERNAL,
320
321 };
322
323 enum InstallerRdsState
324 {
325         INSTALLER_RDS_STATE_NONE,
326         INSTALLER_RDS_STATE_DELETE,
327         INSTALLER_RDS_STATE_ADD,
328         INSTALLER_RDS_STATE_MODIFY,
329
330 };
331
332 typedef struct
333 {
334         const char* pDir;
335         int dirType;
336         int ownerIndex;
337         int modeIndex;
338         int smackIndex;
339
340 } RdsPermssions;
341
342 enum PermDirType
343 {
344         PERM_DIR_RES = 0,
345         PERM_DIR_DATA = 1,
346         PERM_DIR_BIN = 2,
347         PERM_DIR_INFO = 3,
348         PERM_DIR_LIB = 4,
349         PERM_DIR_SETTING = 5,
350         PERM_DIR_SHARED_RES = 6,
351         PERM_DIR_SHARED_DATA = 7,
352         PERM_DIR_SHARED_TRUSTED = 8,
353         PERM_DIR_SHARED = 9,
354         PERM_DIR_ROOT = 10,
355 };
356
357 enum PrivilegeLevel
358 {
359         PRIVILEGE_LEVEL_PUBLIC,
360         PRIVILEGE_LEVEL_PARTNER,
361         PRIVILEGE_LEVEL_PLATFORM,
362
363 };
364
365 #endif // _INSTALLER_DEFS_H_