298bd793fabaac6d42d486462a578d6df8c94239
[platform/core/appfw/pkgmgr-info.git] / parser / include / 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 #include "pkgmgrinfo_type.h"
50 /**
51  * @fn int pkgmgr_parser_insert_manifest_info_in_usr_db(manifest_x *mfx, uid_t uid)
52  * @fn int pkgmgr_parser_insert_manifest_info_in_db(manifest_x *mfx)
53  * @brief       This API inserts the parsed manifest info in db
54  *
55  * @par         This API is for package-manager installer backends
56  * @par Sync (or) Async : Synchronous API
57  *
58  * @param[in]   mfx     pointer to manifest info
59  * @param[in]   uid     the addressee user id of the instruction
60  * @return      0 if success, error code(<0) if fail
61  * @pre         None
62  * @post                None
63  * @see         pkgmgr_parser_update_manifest_info_in_db()
64  * @see         pkgmgr_parser_delete_manifest_info_from_db()
65  * @code
66 static int insert_manifest_data(manifest_x *mfx)
67 {
68         int ret = 0;
69         ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
70         if (ret < 0)
71                 return -1;
72         return 0;
73 }
74  * @endcode
75  */
76 int pkgmgr_parser_insert_manifest_info_in_db(manifest_x *mfx);
77 int pkgmgr_parser_insert_manifest_info_in_usr_db(manifest_x *mfx, uid_t uid);
78
79 /**
80  * @fn int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx)
81  * @fn int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx)
82  * @brief       This API updates the manifest info in db
83  *
84  * @par         This API is for package-manager installer backends
85  * @par Sync (or) Async : Synchronous API
86  *
87  * @param[in]   mfx     pointer to manifest info
88  * @param[in]   uid     the addressee user id of the instruction
89  * @return      0 if success, error code(<0) if fail
90  * @pre         None
91  * @post                None
92  * @see         pkgmgr_parser_insert_manifest_info_in_db()
93  * @see         pkgmgr_parser_delete_manifest_info_from_db()
94  * @code
95 static int update_manifest_data(manifest_x *mfx)
96 {
97         int ret = 0;
98         ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
99         if (ret < 0)
100                 return -1;
101         return 0;
102 }
103  * @endcode
104  */
105 int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx);
106 int pkgmgr_parser_update_manifest_info_in_usr_db(manifest_x *mfx, uid_t uid);
107
108 /**
109  * @fn int pkgmgr_parser_update_tep_info_in_db(const char * pkgid, const char * tep_path)
110  * @fn int pkgmgr_parser_update_tep_info_in_usr_db(const char * pkgid, const char * tep_path,uid_t uid)
111  * @brief       This API updates the tep info in db
112  *
113  * @par         This API is for package-manager installer backends
114  * @par Sync (or) Async : Synchronous API
115  *
116  * @param[in]   pkgid   pointer to pkgid
117  * @param[in]   tep_path        path of tep file
118  * @return      0 if success, error code(<0) if fail
119  * @pre         None
120  * @post                None
121  * @code
122 static int update_tep_data(const char *pkgid, *tep_path)
123 {
124         int ret = 0;
125         ret = pkgmgr_parser_update_tep_info_in_db(pkgid, tep_path);
126         if (ret < 0)
127                 return -1;
128         return 0;
129 }
130  * @endcode
131  */
132 int pkgmgr_parser_update_tep_info_in_db(const char *pkgid, const char *tep_path);
133 int pkgmgr_parser_update_tep_info_in_usr_db(const char *pkgid, const char *tep_path, uid_t uid);
134
135 /**
136  * @fn int pkgmgr_parser_delete_manifest_info_from_usr_db(manifest_x *mfx, uid_t uid)
137  * @fn int pkgmgr_parser_delete_manifest_info_from_db(manifest_x *mfx)
138  * @brief       This API deletes the parsed manifest info from db
139  *
140  * @par         This API is for package-manager installer backends
141  * @par Sync (or) Async : Synchronous API
142  *
143  * @param[in]   mfx     pointer to manifest info
144  * @param[in]   uid     the addressee user id of the instruction
145  * @return      0 if success, error code(<0) if fail
146  * @pre         None
147  * @post                None
148  * @see         pkgmgr_parser_update_manifest_info_in_db()
149  * @see         pkgmgr_parser_insert_manifest_info_in_db()
150  * @code
151 static int delete_manifest_data(manifest_x *mfx)
152 {
153         int ret = 0;
154         ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
155         if (ret < 0)
156                 return -1;
157         return 0;
158 }
159  * @endcode
160  */
161 int pkgmgr_parser_delete_manifest_info_from_db(manifest_x *mfx);
162 int pkgmgr_parser_delete_manifest_info_from_usr_db(manifest_x *mfx, uid_t uid);
163
164 /**
165  * @fn int pkgmgr_parser_update_global_app_disable_for_uid_info_in_db(const char *appid, uid_t uid, int is_disable)
166  * @brief       This API updates disable info about global app for user specified by uid
167  *
168  * @par         This API is for package-manager installer backends
169  * @par Sync (or) Async : Synchronous API
170  *
171  * @param[in]   appid   global application ID to be enabled or disabled
172  * @param[in]   uid     the addressee user id of the instruction
173  * @param[in]is_disable determine enable or disable of app
174  * @return      0 if success, error code(<0) if fail
175  * @pre         None
176  * @post                None
177  * @code
178 static int disable_global_app_for_uid(const char *appid, uid_t uid)
179 {
180         int ret = 0;
181         ret = pkgmgr_parser_update_global_app_disable_for_uid_info_in_db(appid, uid, 1);
182         if (ret < 0)
183                 return -1;
184         return 0;
185 }
186  * @endcode
187  */
188 int pkgmgr_parser_update_global_app_disable_for_uid_info_in_db(const char *appid, uid_t uid, int is_disable);
189
190 /**
191  * @fn int pkgmgr_parser_update_app_disable_info_in_db(const char *appid, int is_disable);
192  * @brief       This API updates disable info about app
193  *
194  * @par         This API is for package-manager installer backends
195  * @par Sync (or) Async : Synchronous API
196  *
197  * @param[in]   appid   application ID to be enabled or disabled
198  * @param[in]   is_disable      determine enable or disable of app
199  * @return      0 if success, error code(<0) if fail
200  * @pre         None
201  * @post                None
202  * @code
203 static int disable_app(const char *appid)
204 {
205         int ret = 0;
206         ret = pkgmgr_parser_update_app_disable_info_in_db(appid, 1);
207         if (ret < 0)
208                 return -1;
209         return 0;
210 }
211  * @endcode
212  */
213 int pkgmgr_parser_update_app_disable_info_in_db(const char *appid, int is_disable);
214 int pkgmgr_parser_update_app_disable_info_in_usr_db(const char *appid, uid_t uid, int is_disable);
215
216 /**
217  * @fn int pkgmgr_parser_update_pkg_disable_info_in_db(const char *pkgid, int is_disable);
218  * @brief       This API updates disable info about pkg
219  *
220  * @par         This API is for package-manager installer backends
221  * @par Sync (or) Async : Synchronous API
222  *
223  * @param[in]   pkgid   package ID to be enabled or disabled
224  * @param[in]   is_disable      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_pkg(const char *pkgid)
230 {
231         int ret = 0;
232         ret = pkgmgr_parser_update_pkg_disable_info_in_db(pkgid, 1);
233         if (ret < 0)
234                 return -1;
235         return 0;
236 }
237  * @endcode
238  */
239 int pkgmgr_parser_update_pkg_disable_info_in_db(const char *pkgid, int is_disable);
240 int pkgmgr_parser_update_pkg_disable_info_in_usr_db(const char *pkgid, uid_t uid, int is_disable);
241
242 /**
243  * @fn int pkgmgr_parser_update_global_app_splash_screen_display_info_in_usr_db(const char *appid, uid_t uid, int flag)
244  * @brief       This API updates splash screen display info about global app for user specified by uid
245  *
246  * @par         This API is for package-manager installer backends
247  * @par Sync (or) Async : Synchronous API
248  *
249  * @param[in]   appid   global application ID to be enabled or disabled
250  * @param[in]   uid     user ID
251  * @param[in]   flag    determine enable or disable of app
252  * @return      0 if success, error code(<0) if fail
253  * @pre         None
254  * @post                None
255  * @code
256 static int disable_global_app_splash_screen_for_uid(const char *appid, uid_t uid)
257 {
258         int ret = 0;
259         ret = pkgmgr_parser_update_global_app_splash_screen_info_in_usr_db(appid, uid, 1);
260         if (ret < 0)
261                 return -1;
262         return 0;
263 }
264  * @endcode
265  */
266 int pkgmgr_parser_update_global_app_splash_screen_display_info_in_usr_db(const char *appid, uid_t uid, int flag);
267
268 /**
269  * @fn int pkgmgr_parser_update_app_splash_screen_display_info_in_db(const char *appid, int flag)
270  * @brief       This API updates splash screen display info about app
271  *
272  * @par         This API is for package-manager installer backends
273  * @par Sync (or) Async : Synchronous API
274  *
275  * @param[in]   appid   application ID to be enabled or disabled
276  * @param[in]   flag    determine enable or disable of app
277  * @return      0 if success, error code(<0) if fail
278  * @pre         None
279  * @post                None
280  * @code
281 static int disable_app_splash_screen(const char *appid)
282 {
283         int ret = 0;
284         ret = pkgmgr_parser_update_app_splash_screen_info_in_db(appid, 1);
285         if (ret < 0)
286                 return -1;
287         return 0;
288 }
289  * @endcode
290  */
291 int pkgmgr_parser_update_app_splash_screen_display_info_in_db(const char *appid, int flag);
292
293 /**
294  * @fn int pkgmgr_parser_update_app_splash_screen_display_info_in_usr_db(const char *appid, uid_t uid, int flag)
295  * @brief       This API updates splash screen display info about app for user specified by uid
296  *
297  * @par         This API is for package-manager installer backends
298  * @par Sync (or) Async : Synchronous API
299  *
300  * @param[in]   appid   application ID to be enabled or disabled
301  * @param[in]   uid     user ID
302  * @param[in]   flag    determine enable or disable of app
303  * @return      0 if success, error code(<0) if fail
304  */
305 int pkgmgr_parser_update_app_splash_screen_display_info_in_usr_db(const char *appid, uid_t uid, int flag);
306
307 /**
308  * @fn int pkgmgr_parser_update_app_label_info_in_db(const char *appid, const char *label)
309  * @brief       This API updates label info of application
310  *
311  * @par         This API is only for internal usage
312  * @par Sync (or) Async : Synchronous API
313  *
314  * @param[in]   appid   application ID to change label
315  * @param[in]   label   label to change
316  * @return      0 if success, error code(<0) if fail
317  */
318 int pkgmgr_parser_update_app_label_info_in_db(const char *appid, const char *label);
319
320 /**
321  * @fn int pkgmgr_parser_update_app_label_info_in_usr_db(const char *appid, uid_t uid, const char *label)
322  * @brief       This API updates label info of application for user specified by uid
323  *
324  * @par         This API is only for internal usage
325  * @par Sync (or) Async : Synchronous API
326  *
327  * @param[in]   appid   application ID to change label
328  * @param[in]   uid     user ID
329  * @param[in]   label   label to change
330  * @return      0 if success, error code(<0) if fail
331  */
332 int pkgmgr_parser_update_app_label_info_in_usr_db(const char *appid, uid_t uid, const char *label);
333
334 /**
335  * @fn int pkgmgr_parser_register_pkg_update_info_in_usr_db(pkgmgrinfo_updateinfo_h handle, uid_t uid)
336  * @brief       This API registers update informations of given packages for user specified by uid
337  *
338  * @par         This API is only for internal usage
339  * @par Sync (or) Async : Synchronous API
340  *
341  * @param[in]   handle  update information handle
342  * @param[in]   uid     user ID
343  * @return      0 if success, error code(<0) if fail
344  * @pre None
345  * @post         None
346  * @code
347 static int register_pkg_update_info(pkgmgrinfo_updateinfo_h update_info, uid_t uid)
348 {
349         int ret = 0;
350         ret = pkgmgr_parser_register_pkg_update_info_in_usr_db(update_info, uid);
351         if (ret < 0)
352                 return -1;
353         return 0;
354 }
355  * @endcode
356  */
357 int pkgmgr_parser_register_pkg_update_info_in_usr_db(pkgmgrinfo_updateinfo_h handle, uid_t uid);
358
359 /**
360  * @fn int pkgmgr_parser_register_pkg_update_info_in_db(pkgmgrinfo_updateinfo_h update_info)
361  * @brief       This API registers update informations of given packages
362  *
363  * @par         This API is only for internal usage
364  * @par Sync (or) Async : Synchronous API
365  *
366  * @param[in]   update_info     update information handle
367  * @return      0 if success, error code(<0) if fail
368  * @pre None
369  * @post        None
370  * @code
371 static int register_pkg_update_info(pkgmgrinfo_updateinfo_h update_info)
372 {
373         int ret = 0;
374         ret = pkgmgr_parser_register_pkg_update_info_in_db(update_info);
375         if (ret < 0)
376                 return -1;
377         return 0;
378 }
379  * @endcode
380  */
381 int pkgmgr_parser_register_pkg_update_info_in_db(pkgmgrinfo_updateinfo_h update_info);
382
383 /**
384  * @fn int pkgmgr_parser_unregister_pkg_update_info_in_usr_db(const char *pkgid, uid_t uid)
385  * @brief       This API unregister update information of certain package for user specified by uid.
386  *
387  * @par         This API is only for internal usage
388  * @par Sync (or) Async : Synchronous API
389  *
390  * @param[in]   pkgid   package ID
391  * @param[in]   uid     user ID
392  * @return      0 if success, error code(<0) if fail
393  * @pre None
394  * @post        None
395  * @code
396 static int register_pkg_update_info(pkgmgrinfo_updateinfo_h update_info, uid_t uid)
397 {
398         int ret = 0;
399         ret = pkgmgr_parser_register_pkg_update_info_in_db(update_info, uid);
400         if (ret < 0)
401                 return -1;
402         return 0;
403 }
404  * @endcode
405  */
406 int pkgmgr_parser_unregister_pkg_update_info_in_usr_db(const char *pkgid, uid_t uid);
407
408 /**
409  * @fn int pkgmgr_parser_unregister_pkg_update_info_in_db(const char * pkgid)
410  * @brief       This API unregister update information of certain package
411  *
412  * @par         This API is only for internal usage
413  * @par Sync (or) Async : Synchronous API
414  *
415  * @param[in]   pkgid   package ID
416  * @return      0 if success, error code(<0) if fail
417  * @pre None
418  * @post        None
419  * @code
420 static int unregister_pkg_update_info(const char *pkgid)
421 {
422         int ret = 0;
423         ret = pkgmgr_parser_unregister_pkg_update_info_in_db(pkgid);
424         if (ret < 0)
425                 return -1;
426         return 0;
427 }
428  * @endcode
429  */
430 int pkgmgr_parser_unregister_pkg_update_info_in_db(const char *pkgid);
431
432 /**
433  * @fn int pkgmgr_parser_unregister_all_pkg_update_info_in_usr_db(uid_t uid)
434  * @brief       This API unregister update information of all packages
435  *
436  * @par         This API is only for internal usage
437  * @par Sync (or) Async : Synchronous API
438  *
439  * @param[in]   uid     user ID
440  * @return      0 if success, error code(<0) if fail
441  * @pre None
442  * @post        None
443  * @code
444 static int unregister_all_pkg_update_info(uid_t uid)
445 {
446         int ret = 0;
447         ret = pkgmgr_parser_unregister_all_pkg_update_info_in_usr_db(uid);
448         if (ret < 0)
449                 return -1;
450         return 0;
451 }
452  * @endcode
453  */
454 int pkgmgr_parser_unregister_all_pkg_update_info_in_usr_db(uid_t uid);
455
456 /**
457  * @fn int pkgmgr_parser_unregister_all_pkg_update_info_in_db(void)
458  * @brief       This API unregisters update information of all packages
459  *
460  * @par         This API is only for internal usage
461  * @par Sync (or) Async : Synchronous API
462  *
463  * @return      0 if success, error code(<0) if fail
464  * @pre None
465  * @post         None
466  * @code
467 static int unregister_all_pkg_update_info(void)
468 {
469         int ret = 0;
470         ret = pkgmgr_parser_unregister_all_pkg_update_info_in_db();
471         if (ret < 0)
472                 return -1;
473         return 0;
474 }
475  * @endcode
476  */
477 int pkgmgr_parser_unregister_all_pkg_update_info_in_db(void);
478
479 int pkgmgr_parser_create_and_initialize_db(uid_t uid);
480 int pkgmgr_parser_initialize_parser_db(uid_t uid);
481 int pkgmgr_parser_initialize_cert_db(void);
482
483 /** @} */
484 #ifdef __cplusplus
485 }
486 #endif
487 #endif                          /* __PKGMGR_PARSER_DB_H__ */
488 /**
489  * @}
490  * @}
491  */