Update source from tizen 2.3
[platform/core/base/rpm-installer.git] / backend / src / coretpk / inc / coretpk-installer-type.h
1 /*
2  * coretpk-installer
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #ifndef __CORETPK_INSTALLER_TYPE_H_
23 #define __CORETPK_INSTALLER_TYPE_H_
24
25 /* For multi-user support */
26 #include <tzplatform_config.h>
27 #include <pkgmgr-info.h>
28 #include <unistd.h>
29
30 #include "rpm-installer-util.h"
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif                          /* __cplusplus */
35
36 #define CORETPK_INSTALL                                                                 "coretpk-install"
37 #define CORETPK_UNINSTALL                                                               "coretpk-uninstall"
38 #define CORETPK_DIRECTORY_INSTALL                               "coretpk-directory-install"
39 #define CORETPK_MOVE                                                                            "coretpk-move"
40 #define CORETPK_REINSTALL                                                               "coretpk-reinstall"
41 #define MAX_BUF_SIZE                                                    4096
42 #define BUF_SIZE                                                                1024
43 #define TEMP_DIR                                                                tzplatform_mkpath(TZ_USER_HOME, ".rpminstaller")
44 #define TEMP_XML_DIR                                                    "/tmp/rpminstaller"
45 #define CORETPK_XML                                                     "tizen-manifest.xml"
46 #define USR_APPS                                                                tzplatform_getenv(TZ_SYS_RO_APP)
47 #define OPT_USR_APPS                                                    tzplatform_getenv(TZ_USER_APP)
48 #define USR_SHARE_PACKAGES                                      tzplatform_getenv(TZ_SYS_RO_PACKAGES)
49 #define OPT_SHARE_PACKAGES                                      getUserManifestPath(getuid())
50 #define CORETPK_RO_XML_CONVERTER                        "/usr/bin/coretpk_ro_xml_converter.sh"
51 #define CORETPK_RW_XML_CONVERTER                        "/usr/bin/coretpk_rw_xml_converter.sh"
52 #define CORETPK_CATEGORY_CONVERTER              "/usr/bin/coretpk_category_converter.sh"
53
54 #define SIGNATURE1_XML                                          "signature1.xml"
55 #define AUTHOR_SIGNATURE_XML                            "author-signature.xml"
56 #define APP_OWNER_ID                                                    5000
57 #define APP_GROUP_ID                                                    5000
58 #define PERM_BASE                                                       (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) // 0644
59 #define PERM_EXECUTE                                                    (S_IXUSR | S_IXGRP | S_IXOTH)
60 #define PERM_WRITE                                                      (S_IWUSR | S_IWGRP | S_IWOTH)
61 #define CORETPK_CONFIG_PATH                                     "/usr/etc/coretpk-installer-config.ini"
62 #define INCLUDE_ABSOLUTE_PATH                           44
63 #define OPT_STORAGE_SDCARD                                      "/opt/storage/sdcard/"
64 #define OPT_STORAGE_SDCARD_APP_ROOT             "/opt/storage/sdcard/apps"
65 #define INI_VALUE_MAKE_EXT_DIRECTORY            "make-ext-directory"
66 #define INI_VALUE_SIGNATURE                                     "signature"
67 #define INI_VALUE_AUTHOR_SIGNATURE                      "author-signature"
68 #define RDS_DELTA_FILE                                          ".rds_delta"
69 #define RDS_DELTA_ADD                                           "#add"
70 #define RDS_DELTA_DELETE                                        "#delete"
71 #define RDS_DELTA_MODIFY                                        "#modify"
72
73 enum rds_state_type {
74         RDS_STATE_NONE,
75         RDS_STATE_DELETE,
76         RDS_STATE_ADD,
77         RDS_STATE_MODIFY,
78 };
79
80 enum request_type {
81         REQUEST_TYPE_INSTALL,
82         REQUEST_TYPE_UNINSTALL,
83         REQUEST_TYPE_UPGRADE,
84 };
85
86 #define _LOGL(message, error)    \
87         char exception[BUF_SIZE] = {'\0'}; \
88         char *ret = NULL; \
89         ret = strerror_r(error, exception, BUF_SIZE); \
90         if (ret) strcpy(exception, ret); \
91         _LOGP("@%s failed[%s]. func:[%s] line:[%d]\n", message, exception, __FUNCTION__, __LINE__)
92
93 #define ret_if(expr) do { \
94         if (expr) { \
95                 _LOGE("(%s) ", #expr); \
96                 return; \
97         } \
98 } while (0)
99
100 #define retm_if(expr, fmt, arg...) do { \
101          if (expr) { \
102                  _LOGE("(%s) "fmt, #expr, ##arg); \
103                  return; \
104          } \
105  } while (0)
106
107 #define retv_if(expr, val) do { \
108                 if (expr) { \
109                         _LOGE("(%s) ", #expr); \
110                         return (val); \
111                 } \
112         } while (0)
113
114 #define retvm_if(expr, val, fmt, arg...) do { \
115         if (expr) { \
116                 _LOGE("(%s) "fmt, #expr, ##arg); \
117                 return (val); \
118         } \
119 } while (0)
120
121 #define tryvm_if(expr, val, fmt, arg...) do { \
122         if (expr) { \
123                 _LOGE("(%s) "fmt, #expr, ##arg); \
124                 val; \
125                 goto catch; \
126         } \
127 } while (0)
128
129 #ifdef __cplusplus
130 }
131 #endif                          /* __cplusplus */
132 #endif                          /* __CORETPK_INSTALLER_TYPE_H_ */