Update source from tizen 2.3
[platform/core/base/rpm-installer.git] / backend / inc / rpm-installer.h
1 /*
2  * rpm-installer
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7  * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22
23 #ifndef __RPM_INSTALLER_H_
24 #define __RPM_INSTALLER_H_
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif                          /* __cplusplus */
29
30 #include "rpm-installer-util.h"
31 #include <stdbool.h>
32 #include <glib.h>
33
34 #define PM_UNLIKELY(expr) __builtin_expect((expr), 0)
35 #define PM_LIKELY(expr) __builtin_expect((expr), 1)
36
37         enum backend_state {
38                 REQUEST_ACCEPTED = 1,
39                 GOT_PACKAGE_INFO_SUCCESSFULLY,
40                 REQUEST_PENDING,
41                 REQUEST_COMPLETED
42         };
43         typedef enum backend_state backend_state;
44
45         enum rpm_request_type {
46                 INSTALL_REQ,
47                 UNINSTALL_REQ,
48                 UPGRADE_REQ,
49         };
50         typedef enum rpm_request_type rpm_request_type;
51
52 #define MARGIN_FACTOR           12
53 #define RPM_SIZE_MARGIN(size)   ( (int)(size/MARGIN_FACTOR) + 1)
54
55 /**
56  * Install the package
57  * @in :pkgfilepath : Package file path
58  * @in :force_install: Whether we need to forceful overwrite.
59  *         If package already installed then reinstall the application
60  * @in :install_options: install options
61  */
62         int _rpm_installer_package_install(char *pkgfilepath,
63                                            bool force_install,
64                                            char *install_options,
65                                            char *clientid);
66
67 /**
68  * Install the package
69  * @in :pkgfilepath : Package file path
70  */
71         int _rpm_installer_package_install_with_dbpath(char *pkgfilepath, char *clientid);
72
73 /**
74  * Install the package manifest
75  * @in :pkgfilepath : Package manifest file path
76  */
77         int _rpm_installer_corexml_install(char *pkgfilepath);
78
79 /**
80  * get the package information from package name
81  * return the package information
82  * @in :pkgid : package id for which information is requested
83  */
84         pkginfo *_rpm_installer_get_pkgname_info(const char *pkgid);
85
86 /**
87  * get the package information from package file
88  * return the package information
89  * @in :pkgfile : package file for which information is requested
90  */
91         pkginfo *_rpm_installer_get_pkgfile_info(char *pkgfile);
92
93 /**
94  * Uninstall the Application
95  * @in :pkgid : package id to be uninstalled
96  */
97         int _rpm_installer_package_uninstall(char *pkgid);
98
99 /**
100  * Uninstall the Application
101  * @in :pkgid : package id to be uninstalled
102  */
103         int _rpm_installer_package_uninstall_with_dbpath(const char *pkgid);
104
105 /* Dbus related prototype */
106         void _ri_broadcast_status_notification(const char *pkgid, char *pkg_type, char *key, char *val);
107         int _rpm_backend_interface(char *keyid, char *pkgid, char *reqcommand, char *clientid);
108
109 /* RPM operations prototype */
110         int _rpm_uninstall_pkg(char *pkgid);
111
112         int _rpm_install_pkg_with_dbpath(char *pkgfilepath, char *pkgid, char *clientid);
113         int _rpm_upgrade_pkg_with_dbpath(char *pkgfilepath, char *pkgid);
114         int _rpm_uninstall_pkg_with_dbpath(const char *pkgid, bool is_system);
115
116         int _rpm_install_corexml(char *pkgfilepath, char *pkgid);
117         int _rpm_process_cscxml(char *xml_path);
118         int _rpm_process_csc_coretpk(char *xml_path);
119         int _rpm_process_fota(char *fota_script);
120         int _rpm_process_fota_for_rw(char *fota_script);
121
122         int _rpm_process_enable(char *pkgid);
123         int _rpm_process_disable(char *pkgid);
124
125         int _ri_set_backend_state(int state);
126         int _ri_get_backend_state();
127         int _ri_get_backend_state_info();
128         int _ri_set_backend_state_info(int state);
129         int _ri_get_last_input_info(char **pkgid, int *preqcommand,
130                                     int *poptions);
131         void _ri_save_last_input_info(char *pkgid, int reqcommand,
132                                       int options);
133         void _ri_package_downgrade_information(const char *message);
134         int _rpm_installer_clear_private_data(char *pkgid);
135         int _rpm_move_pkg(char *pkgid, int move_type);
136
137 /* libprivilege-control specific operations prototype*/
138         int _ri_privilege_register_package(const char *pkgid);
139         int _ri_privilege_unregister_package(const char *pkgid);
140         int _ri_privilege_revoke_permissions(const char *pkgid);
141         int _ri_privilege_enable_permissions(const char *pkgid, int apptype,
142                                                 const char **perms, int persistent);
143         int _ri_privilege_setup_path(const char *pkgid, const char *dirpath,
144                                                 int apppathtype, const char *groupid);
145         int _ri_privilege_add_friend(const char *pkgid1, const char *pkgid2);
146         int _ri_privilege_change_smack_label(const char *path, const char *label,
147                                                 int label_type);
148         void _ri_unregister_cert(const char *pkgid);
149         void _ri_register_cert(const char *pkgid);
150         void _ri_apply_smack(char *pkgname, int flag);
151         int _ri_apply_privilege(char *pkgid, int visibility);
152         void _ri_soft_reset(char *pkgid);
153
154         int _rpm_process_enabled_list(const char *enabled_list);
155         int _rpm_process_disabled_list(const char *disabled_list);
156
157         int __is_dir(char *dirname);
158         int __ri_change_dir(char *dirname);
159         void __rpm_apply_smack(char *pkgname, int flag);
160         int _rpm_xsystem(const char *argv[]);
161         int _ri_smack_reload(const char *pkgid, rpm_request_type request_type);
162         int _ri_smack_reload_all(void);
163         int _ri_verify_signatures(const char *root_path, const char *pkgid);
164         int __ri_check_running_app(const pkgmgrinfo_appinfo_h handle, void *user_data);
165         void __ri_remove_updated_dir(const char *pkgid);
166         int __ri_copy_smack_rule_file(int op_type, const char *pkgname, int is_system);
167         void __rpm_clear_dir_list(GList* dir_list);
168         GList * __rpm_populate_dir_list();
169         void __ri_make_directory(const char *pkgid);
170
171 #ifdef __cplusplus
172 }
173 #endif                          /* __cplusplus */
174 #endif                          /* __RPM_INSTALLER_H_ */