upload tizen1.0 source
[pkgs/n/native-installer.git] / backend / inc / nativeinstaller.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
24
25
26
27 #ifndef NATIVEINSTALLER_H_
28 #define NATIVEINSTALLER_H_
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif                          /* __cplusplus */
33
34 #include "native_installer_util.h"
35 #include <stdbool.h>
36
37 #define PM_LIKELY(expr) __builtin_expect((expr), 1)
38 #define PM_UNLIKELY(expr) __builtin_expect((expr), 0)
39
40 /* backend state to be used for recovery */
41 typedef enum {
42         REQUEST_ACCEPTED = 1,
43         GOT_PACKAGE_INFO_SUCCESSFULLY,
44         DPKG_REQUEST_COMPLETED,
45         DPKG_REQUEST_PENDING,
46         REQUEST_COMPLETED,
47 } backend_state;
48
49 struct pkginfo_st {
50         char package_name[128]; /* 32: linux username limit */
51         char version[11];       /* ###.###.### */
52 };
53
54 typedef struct pkginfo_st pkginfo;
55
56 /**
57  * Install the package
58  * @in :pPkgFilePath : Package file path
59  * @in :bForceInstall: Whether we need to forceful overwrite. 
60  *      If package already installed then reinstall the application
61  * @in :installOptions: install options
62  */
63 int _pkgmgr_package_install(char *ppkgfilepath, bool bforceinstall,
64                                                    char *installoptions);
65
66 /**
67  * get the package information for the requested installed application
68  * return the package information
69  * @in :pkgName : package name for which information is requested
70  */
71 pkginfo *_pkgmgr_get_installed_pkg_info(char *pkgname);
72
73 /**
74  * Uninstall the Application
75  * @in :pkgName : application name to be uninstalled
76  */
77 int _pkgmgr_package_uninstall(char *pkgname);
78
79 pkginfo *_pkgmgr_get_pkg_info(char *pkgfilepath, int *errno,
80                                 bool *alreayinstalled);
81
82 /* Dbus related prototype */
83 int _broadcast_status_notification(char *pkgname, char *key, char *val);
84
85 /* DPKG operations prototype */
86 int _pkgmgr_dpkg_uninstall_pkg(char *pkgname);
87 int _pkgmgr_dpkg_install_pkg(char *pkgfilepath, char *installoptions);
88 int _pkgmgr_dpkg_upgrade_pkg(char *pkgfilepath, char *installoptions);
89 int _pkgmgr_clear_private_data(char *pkgname);
90 int _set_backend_state(int state);
91 int _get_backend_state();
92 int _get_backend_state_info();
93 int _set_backend_state_info(int state);
94 int _get_last_input_info(char **pkgname, int *preqcommand, int *poptions);
95 void _save_last_input_info(char *pkgname, int reqcommand, int options);
96 /* For third party apps*/
97 int _set_event_notification(int value);
98 int _unset_event_notification();
99 pkginfo *_pkgmgr_txt_parser_read_manifest(char *manifestfile);
100 void stat_cb(const char *pkg_name, const char *key, const char *val);
101
102 #ifdef __cplusplus
103 }
104 #endif                          /* __cplusplus */
105
106 #endif                          /* NATIVEINSTALLER_H_ */