e1618b040e9fcc541a2e5ab41ab97db2839c483d
[platform/core/appfw/slp-pkgmgr.git] / client / src / pkgmgr_client_internal.h
1 /*
2  * slp-pkgmgr
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 __PKGMGR_CLIENT_INTERNAL_H__
24 #define __PKGMGR_CLIENT_INTERNAL_H__
25
26 #include <unistd.h>
27 #include <ctype.h>
28
29 #include <glib.h>
30 #include <gio/gio.h>
31
32 #include "package-manager-plugin.h"
33 #include "package-manager.h"
34
35 #define BUFMAX 4096
36
37 struct cb_info {
38         int req_id;
39         char *req_key;
40         int status_type;
41         pkgmgr_handler event_cb;
42         pkgmgr_app_handler app_event_cb;
43         pkgmgr_pkg_size_info_receive_cb size_info_cb;
44         pkgmgr_res_copy_handler res_copy_event_cb;
45         void *data;
46         struct pkgmgr_client_t *client;
47         GList *sid_list;
48 };
49
50 struct pkgmgr_client_t {
51         pkgmgr_client_type pc_type;
52         int status_type;
53         GDBusConnection *conn;
54         GList *cb_info_list;
55         GVariantBuilder *res_copy_builder;
56         GVariantBuilder *res_remove_builder;
57         GVariantBuilder *res_create_dir_builder;
58         char *tep_path;
59         bool tep_move;
60         bool debug_mode;
61         bool skip_optimization;
62 };
63
64 struct manifest_and_type {
65         const char *manifest;
66         const char *type;
67 };
68
69 int pkgmgr_client_connection_connect(struct pkgmgr_client_t *pc);
70 void pkgmgr_client_connection_disconnect(struct pkgmgr_client_t *pc);
71 int pkgmgr_client_connection_set_callback(struct pkgmgr_client_t *pc,
72                 struct cb_info *cb_info);
73 void pkgmgr_client_connection_unset_callback(struct pkgmgr_client_t *pc,
74                 struct cb_info *cb_info);
75 int pkgmgr_client_connection_send_request(struct pkgmgr_client_t *pc,
76                 const char *method, GVariant *params, GVariant **result);
77
78
79 typedef package_manager_pkg_info_t package_manager_app_info_t;
80
81
82 package_manager_pkg_info_t *_pkg_malloc_appinfo(int num);
83
84 pkg_plugin_set *_pkg_plugin_load_library(const char *pkg_type,
85                                          const char *library_path);
86
87 int _pkg_plugin_get_library_path(const char *pkg_type, char *library_path);
88
89 pkg_plugin_set *_package_manager_load_library(const char *pkg_type);
90
91 char *_get_info_string(const char *key,
92                        const package_manager_pkg_detail_info_t *
93                        pkg_detail_info);
94
95 int _get_info_int(const char *key,
96                   const package_manager_pkg_detail_info_t *pkg_detail_info);
97
98 time_t _get_info_time(const char *key,
99                       const package_manager_pkg_detail_info_t *
100                       pkg_detail_info);
101
102
103 #define PKG_FRONTEND    "frontend:"
104 #define PKG_BACKEND             "backend:"
105 #define PKG_BACKENDLIB  "backendlib:"
106 #define PKG_PARSERLIB   "parserlib:"
107 #define PKG_CONF_PATH   "/etc/package-manager/pkg_path.conf"
108
109 #define PKG_STATUS              "STATUS"
110
111 #define PKG_STRING_LEN_MAX 1024
112 #define PKG_EXT_LEN_MAX          20
113 #define PKG_ARGC_MAX             16
114
115 void _app_str_trim(char *input);
116
117 int _get_mime_from_file(const char *filename, char *mimetype, int len);
118 int _get_mime_extension(const char *mimetype, char *ext, int len);
119
120 #endif                          /* __PKGMGR_CLIENT_INTERNAL_H__ */