Revert "Revert "change functions to constructing queries from snprintf to sqlite3_snp...
[platform/core/appfw/pkgmgr-info.git] / parser / pkgmgr_parser_db.h
1 /*
2  * pkgmgr-info
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  * @file                pkgmgr_parser_db.h
26  * @author      Shobhit Srivastava <shobhit.s@samsung.com>
27  * @version     0.1
28  * @brief               This file declares API to store/retrieve manifest data in DB
29  *
30  * @addtogroup APPLICATION_FRAMEWORK
31  * @{
32  *
33   * @defgroup   PackageManagerParserDB
34  * @section     Header Header file to include:
35  * @code
36  * #include <pkgmgr_parser_db.h>
37  * @endcode
38  *
39  * @}
40  */
41
42 #ifndef __PKGMGR_PARSER_DB_H__
43 #define __PKGMGR_PARSER_DB_H__
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 #include "pkgmgr_parser.h"
49 /**
50  * @fn int pkgmgr_parser_insert_manifest_info_in_usr_db(manifest_x *mfx, uid_t uid)
51  * @fn int pkgmgr_parser_insert_manifest_info_in_db(manifest_x *mfx)
52  * @brief       This API inserts the parsed manifest info in db
53  *
54  * @par         This API is for package-manager installer backends
55  * @par Sync (or) Async : Synchronous API
56  *
57  * @param[in]   mfx     pointer to manifest info
58  * @param[in]   uid     the addressee user id of the instruction
59  * @return      0 if success, error code(<0) if fail
60  * @pre         None
61  * @post                None
62  * @see         pkgmgr_parser_update_manifest_info_in_db()
63  * @see         pkgmgr_parser_delete_manifest_info_from_db()
64  * @code
65 static int insert_manifest_data(manifest_x *mfx)
66 {
67         int ret = 0;
68         ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
69         if (ret < 0)
70                 return -1;
71         return 0;
72 }
73  * @endcode
74  */
75 int pkgmgr_parser_insert_manifest_info_in_db(manifest_x *mfx);
76 int pkgmgr_parser_insert_manifest_info_in_usr_db(manifest_x *mfx, uid_t uid);
77
78 /**
79  * @fn int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx)
80  * @fn int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx)
81  * @brief       This API updates the manifest info in db
82  *
83  * @par         This API is for package-manager installer backends
84  * @par Sync (or) Async : Synchronous API
85  *
86  * @param[in]   mfx     pointer to manifest info
87  * @param[in]   uid     the addressee user id of the instruction
88  * @return      0 if success, error code(<0) if fail
89  * @pre         None
90  * @post                None
91  * @see         pkgmgr_parser_insert_manifest_info_in_db()
92  * @see         pkgmgr_parser_delete_manifest_info_from_db()
93  * @code
94 static int update_manifest_data(manifest_x *mfx)
95 {
96         int ret = 0;
97         ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
98         if (ret < 0)
99                 return -1;
100         return 0;
101 }
102  * @endcode
103  */
104 int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx);
105 int pkgmgr_parser_update_manifest_info_in_usr_db(manifest_x *mfx, uid_t uid);
106
107 /**
108  * @fn int pkgmgr_parser_update_tep_info_in_db(const char * pkgid, const char * tep_path)
109  * @fn int pkgmgr_parser_update_tep_info_in_usr_db(const char * pkgid, const char * tep_path,uid_t uid)
110  * @brief       This API updates the tep info in db
111  *
112  * @par         This API is for package-manager installer backends
113  * @par Sync (or) Async : Synchronous API
114  *
115  * @param[in]   pkgid   pointer to pkgid
116  * @param[in]   tep_path        path of tep file
117  * @return      0 if success, error code(<0) if fail
118  * @pre         None
119  * @post                None
120  * @code
121 static int update_tep_data(const char *pkgid, *tep_path)
122 {
123         int ret = 0;
124         ret = pkgmgr_parser_update_tep_info_in_db(pkgid, tep_path);
125         if (ret < 0)
126                 return -1;
127         return 0;
128 }
129  * @endcode
130  */
131 int pkgmgr_parser_update_tep_info_in_db(const char *pkgid, const char *tep_path);
132 int pkgmgr_parser_update_tep_info_in_usr_db(const char *pkgid, const char *tep_path, uid_t uid);
133
134 /**
135  * @fn int pkgmgr_parser_delete_manifest_info_from_usr_db(manifest_x *mfx, uid_t uid)
136  * @fn int pkgmgr_parser_delete_manifest_info_from_db(manifest_x *mfx)
137  * @brief       This API deletes the parsed manifest info from db
138  *
139  * @par         This API is for package-manager installer backends
140  * @par Sync (or) Async : Synchronous API
141  *
142  * @param[in]   mfx     pointer to manifest info
143  * @param[in]   uid     the addressee user id of the instruction
144  * @return      0 if success, error code(<0) if fail
145  * @pre         None
146  * @post                None
147  * @see         pkgmgr_parser_update_manifest_info_in_db()
148  * @see         pkgmgr_parser_insert_manifest_info_in_db()
149  * @code
150 static int delete_manifest_data(manifest_x *mfx)
151 {
152         int ret = 0;
153         ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
154         if (ret < 0)
155                 return -1;
156         return 0;
157 }
158  * @endcode
159  */
160 int pkgmgr_parser_delete_manifest_info_from_db(manifest_x *mfx);
161 int pkgmgr_parser_delete_manifest_info_from_usr_db(manifest_x *mfx, uid_t uid);
162
163 /**
164  * @fn int pkgmgr_parser_update_global_app_disable_for_uid_info_in_db(const char *appid, uid_t uid, int is_disable)
165  * @brief       This API updates disable info about global app for user specified by uid
166  *
167  * @par         This API is for package-manager installer backends
168  * @par Sync (or) Async : Synchronous API
169  *
170  * @param[in]   appid   global application ID to be enabled or disabled
171  * @param[in]   uid     the addressee user id of the instruction
172  * @param[in]is_disable determine enable or disable of app
173  * @return      0 if success, error code(<0) if fail
174  * @pre         None
175  * @post                None
176  * @code
177 static int disable_global_app_for_uid(const char *appid, uid_t uid)
178 {
179         int ret = 0;
180         ret = pkgmgr_parser_update_global_app_disable_for_uid_info_in_db(appid, uid, 1);
181         if (ret < 0)
182                 return -1;
183         return 0;
184 }
185  * @endcode
186  */
187 int pkgmgr_parser_update_global_app_disable_for_uid_info_in_db(const char *appid, uid_t uid, int is_disable);
188
189 /**
190  * @fn int pkgmgr_parser_update_app_disable_info_in_db(const char *appid, int is_disable);
191  * @brief       This API updates disable info about app
192  *
193  * @par         This API is for package-manager installer backends
194  * @par Sync (or) Async : Synchronous API
195  *
196  * @param[in]   appid   application ID to be enabled or disabled
197  * @param[in]   is_disable      determine enable or disable of app
198  * @return      0 if success, error code(<0) if fail
199  * @pre         None
200  * @post                None
201  * @code
202 static int disable_app(const char *appid)
203 {
204         int ret = 0;
205         ret = pkgmgr_parser_update_app_disable_info_in_db(appid, 1);
206         if (ret < 0)
207                 return -1;
208         return 0;
209 }
210  * @endcode
211  */
212 int pkgmgr_parser_update_app_disable_info_in_db(const char *appid, int is_disable);
213 int pkgmgr_parser_update_app_disable_info_in_usr_db(const char *appid, uid_t uid, int is_disable);
214
215 /**
216  * @fn int pkgmgr_parser_update_global_app_splash_screen_display_info_in_usr_db(const char *appid, uid_t uid, int flag)
217  * @brief       This API updates splash screen display info about global app for user specified by uid
218  *
219  * @par         This API is for package-manager installer backends
220  * @par Sync (or) Async : Synchronous API
221  *
222  * @param[in]   appid   global application ID to be enabled or disabled
223  * @param[in]   uid     user ID
224  * @param[in]   flag    determine enable or disable of app
225  * @return      0 if success, error code(<0) if fail
226  * @pre         None
227  * @post                None
228  * @code
229 static int disable_global_app_splash_screen_for_uid(const char *appid, uid_t uid)
230 {
231         int ret = 0;
232         ret = pkgmgr_parser_update_global_app_splash_screen_info_in_usr_db(appid, uid, 1);
233         if (ret < 0)
234                 return -1;
235         return 0;
236 }
237  * @endcode
238  */
239 int pkgmgr_parser_update_global_app_splash_screen_display_info_in_usr_db(const char *appid, uid_t uid, int flag);
240
241 /**
242  * @fn int pkgmgr_parser_update_app_splash_screen_display_info_in_db(const char *appid, int flag)
243  * @brief       This API updates splash screen display info about app
244  *
245  * @par         This API is for package-manager installer backends
246  * @par Sync (or) Async : Synchronous API
247  *
248  * @param[in]   appid   application ID to be enabled or disabled
249  * @param[in]   flag    determine enable or disable of app
250  * @return      0 if success, error code(<0) if fail
251  * @pre         None
252  * @post                None
253  * @code
254 static int disable_app_splash_screen(const char *appid)
255 {
256         int ret = 0;
257         ret = pkgmgr_parser_update_app_splash_screen_info_in_db(appid, 1);
258         if (ret < 0)
259                 return -1;
260         return 0;
261 }
262  * @endcode
263  */
264 int pkgmgr_parser_update_app_splash_screen_display_info_in_db(const char *appid, int flag);
265
266 /**
267  * @fn int pkgmgr_parser_update_app_splash_screen_display_info_in_usr_db(const char *appid, uid_t uid, int flag)
268  * @brief       This API updates splash screen display info about app for user specified by uid
269  *
270  * @par         This API is for package-manager installer backends
271  * @par Sync (or) Async : Synchronous API
272  *
273  * @param[in]   appid   application ID to be enabled or disabled
274  * @param[in]   uid     user ID
275  * @param[in]   flag    determine enable or disable of app
276  * @return      0 if success, error code(<0) if fail
277  */
278 int pkgmgr_parser_update_app_splash_screen_display_info_in_usr_db(const char *appid, uid_t uid, int flag);
279
280 int pkgmgr_parser_create_and_initialize_db(uid_t uid);
281
282
283 /** @} */
284 #ifdef __cplusplus
285 }
286 #endif
287 #endif                          /* __PKGMGR_PARSER_DB_H__ */
288 /**
289  * @}
290  * @}
291  */