Add include for update info handle
[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 int pkgmgr_parser_create_and_initialize_db(uid_t uid);
335
336 /**
337  * @fn int pkgmgr_parser_register_pkg_update_info_in_usr_db(pkgmgrinfo_updateinfo_h handle, uid_t uid)
338  * @brief       This API registers update informations of given packages for user specified by uid
339  *
340  * @par         This API is only for internal usage
341  * @par Sync (or) Async : Synchronous API
342  *
343  * @param[in]   handle  update information handle
344  * @param[in]   uid     user ID
345  * @return      0 if success, error code(<0) if fail
346  * @pre None
347  * @post         None
348  * @code
349 static int register_pkg_update_info(pkgmgrinfo_updateinfo_h update_info, uid_t uid)
350 {
351         int ret = 0;
352         ret = pkgmgr_parser_register_pkg_update_info_in_usr_db(update_info, uid);
353         if (ret < 0)
354                 return -1;
355         return 0;
356 }
357  * @endcode
358  */
359 int pkgmgr_parser_register_pkg_update_info_in_usr_db(pkgmgrinfo_updateinfo_h handle, uid_t uid);
360
361 /**
362  * @fn int pkgmgr_parser_register_pkg_update_info_in_db(pkgmgrinfo_updateinfo_h update_info)
363  * @brief       This API registers update informations of given packages
364  *
365  * @par         This API is only for internal usage
366  * @par Sync (or) Async : Synchronous API
367  *
368  * @param[in]   update_info     update information handle
369  * @return      0 if success, error code(<0) if fail
370  * @pre None
371  * @post        None
372  * @code
373 static int register_pkg_update_info(pkgmgrinfo_updateinfo_h update_info)
374 {
375         int ret = 0;
376         ret = pkgmgr_parser_register_pkg_update_info_in_db(update_info);
377         if (ret < 0)
378                 return -1;
379         return 0;
380 }
381  * @endcode
382  */
383 int pkgmgr_parser_register_pkg_update_info_in_db(pkgmgrinfo_updateinfo_h update_info);
384
385 /**
386  * @fn int pkgmgr_parser_unregister_pkg_update_info_in_usr_db(const char *pkgid, uid_t uid)
387  * @brief       This API unregister update information of certain package for user specified by uid.
388  *
389  * @par         This API is only for internal usage
390  * @par Sync (or) Async : Synchronous API
391  *
392  * @param[in]   pkgid   package ID
393  * @param[in]   uid     user ID
394  * @return      0 if success, error code(<0) if fail
395  * @pre None
396  * @post        None
397  * @code
398 static int register_pkg_update_info(pkgmgrinfo_updateinfo_h update_info, uid_t uid)
399 {
400         int ret = 0;
401         ret = pkgmgr_parser_register_pkg_update_info_in_db(update_info, uid);
402         if (ret < 0)
403                 return -1;
404         return 0;
405 }
406  * @endcode
407  */
408 int pkgmgr_parser_unregister_pkg_update_info_in_usr_db(const char *pkgid, uid_t uid);
409
410 /**
411  * @fn int pkgmgr_parser_unregister_pkg_update_info_in_db(const char * pkgid)
412  * @brief       This API unregister update information of certain package
413  *
414  * @par         This API is only for internal usage
415  * @par Sync (or) Async : Synchronous API
416  *
417  * @param[in]   pkgid   package ID
418  * @return      0 if success, error code(<0) if fail
419  * @pre None
420  * @post        None
421  * @code
422 static int unregister_pkg_update_info(const char *pkgid)
423 {
424         int ret = 0;
425         ret = pkgmgr_parser_unregister_pkg_update_info_in_db(pkgid);
426         if (ret < 0)
427                 return -1;
428         return 0;
429 }
430  * @endcode
431  */
432 int pkgmgr_parser_unregister_pkg_update_info_in_db(const char *pkgid);
433
434 /**
435  * @fn int pkgmgr_parser_unregister_all_pkg_update_info_in_usr_db(uid_t uid)
436  * @brief       This API unregister update information of all packages
437  *
438  * @par         This API is only for internal usage
439  * @par Sync (or) Async : Synchronous API
440  *
441  * @param[in]   uid     user ID
442  * @return      0 if success, error code(<0) if fail
443  * @pre None
444  * @post        None
445  * @code
446 static int unregister_all_pkg_update_info(uid_t uid)
447 {
448         int ret = 0;
449         ret = pkgmgr_parser_unregister_all_pkg_update_info_in_usr_db(uid);
450         if (ret < 0)
451                 return -1;
452         return 0;
453 }
454  * @endcode
455  */
456 int pkgmgr_parser_unregister_all_pkg_update_info_in_usr_db(uid_t uid);
457
458 /**
459  * @fn int pkgmgr_parser_unregister_all_pkg_update_info_in_db()
460  * @brief       This API unregisters update information of all packages
461  *
462  * @par         This API is only for internal usage
463  * @par Sync (or) Async : Synchronous API
464  *
465  * @return      0 if success, error code(<0) if fail
466  * @pre None
467  * @post         None
468  * @code
469 static int unregister_all_pkg_update_info(void)
470 {
471         int ret = 0;
472         ret = pkgmgr_parser_unregister_all_pkg_update_info_in_db();
473         if (ret < 0)
474                 return -1;
475         return 0;
476 }
477  * @endcode
478  */
479 int pkgmgr_parser_unregister_all_pkg_update_info_in_db();
480
481
482 /** @} */
483 #ifdef __cplusplus
484 }
485 #endif
486 #endif                          /* __PKGMGR_PARSER_DB_H__ */
487 /**
488  * @}
489  * @}
490  */