Implement pkgmgr_parser_insert_manifest_info_in_usr_db
[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
49 #include <sqlite3.h>
50
51 #include "pkgmgr_parser.h"
52 #include "pkgmgrinfo_type.h"
53
54 // TODO: add descriptions
55 int pkgmgr_parser_insert_pkg_info(sqlite3 *db, manifest_x *mfx, uid_t uid);
56 int pkgmgr_parser_update_pkg_info(sqlite3 *db, manifest_x *mfx, uid_t uid);
57 int pkgmgr_parser_delete_pkg_info(sqlite3 *db, const char *package, uid_t uid);
58
59 /**
60  * @fn int pkgmgr_parser_insert_manifest_info_in_usr_db(manifest_x *mfx, uid_t uid)
61  * @fn int pkgmgr_parser_insert_manifest_info_in_db(manifest_x *mfx)
62  * @brief       This API inserts the parsed manifest info in db
63  *
64  * @par         This API is for package-manager installer backends
65  * @par Sync (or) Async : Synchronous API
66  *
67  * @param[in]   mfx     pointer to manifest info
68  * @param[in]   uid     the addressee user id of the instruction
69  * @return      0 if success, error code(<0) if fail
70  * @pre         None
71  * @post                None
72  * @see         pkgmgr_parser_update_manifest_info_in_db()
73  * @see         pkgmgr_parser_delete_manifest_info_from_db()
74  * @code
75 static int insert_manifest_data(manifest_x *mfx)
76 {
77         int ret = 0;
78         ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
79         if (ret < 0)
80                 return -1;
81         return 0;
82 }
83  * @endcode
84  */
85 int pkgmgr_parser_insert_manifest_info_in_db(manifest_x *mfx);
86 int pkgmgr_parser_insert_manifest_info_in_usr_db(manifest_x *mfx, uid_t uid);
87
88 /**
89  * @fn int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx)
90  * @fn int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx)
91  * @brief       This API updates the manifest info in db
92  *
93  * @par         This API is for package-manager installer backends
94  * @par Sync (or) Async : Synchronous API
95  *
96  * @param[in]   mfx     pointer to manifest info
97  * @param[in]   uid     the addressee user id of the instruction
98  * @return      0 if success, error code(<0) if fail
99  * @pre         None
100  * @post                None
101  * @see         pkgmgr_parser_insert_manifest_info_in_db()
102  * @see         pkgmgr_parser_delete_manifest_info_from_db()
103  * @code
104 static int update_manifest_data(manifest_x *mfx)
105 {
106         int ret = 0;
107         ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
108         if (ret < 0)
109                 return -1;
110         return 0;
111 }
112  * @endcode
113  */
114 int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx);
115 int pkgmgr_parser_update_manifest_info_in_usr_db(manifest_x *mfx, uid_t uid);
116
117 /**
118  * @fn int pkgmgr_parser_update_tep_info_in_db(const char * pkgid, const char * tep_path)
119  * @fn int pkgmgr_parser_update_tep_info_in_usr_db(const char * pkgid, const char * tep_path,uid_t uid)
120  * @brief       This API updates the tep info in db
121  *
122  * @par         This API is for package-manager installer backends
123  * @par Sync (or) Async : Synchronous API
124  *
125  * @param[in]   pkgid   pointer to pkgid
126  * @param[in]   tep_path        path of tep file
127  * @return      0 if success, error code(<0) if fail
128  * @pre         None
129  * @post                None
130  * @code
131 static int update_tep_data(const char *pkgid, *tep_path)
132 {
133         int ret = 0;
134         ret = pkgmgr_parser_update_tep_info_in_db(pkgid, tep_path);
135         if (ret < 0)
136                 return -1;
137         return 0;
138 }
139  * @endcode
140  */
141 int pkgmgr_parser_update_tep_info_in_db(const char *pkgid, const char *tep_path);
142 int pkgmgr_parser_update_tep_info_in_usr_db(const char *pkgid, const char *tep_path, uid_t uid);
143
144 /**
145  * @fn int pkgmgr_parser_delete_manifest_info_from_usr_db(manifest_x *mfx, uid_t uid)
146  * @fn int pkgmgr_parser_delete_manifest_info_from_db(manifest_x *mfx)
147  * @brief       This API deletes the parsed manifest info from db
148  *
149  * @par         This API is for package-manager installer backends
150  * @par Sync (or) Async : Synchronous API
151  *
152  * @param[in]   mfx     pointer to manifest info
153  * @param[in]   uid     the addressee user id of the instruction
154  * @return      0 if success, error code(<0) if fail
155  * @pre         None
156  * @post                None
157  * @see         pkgmgr_parser_update_manifest_info_in_db()
158  * @see         pkgmgr_parser_insert_manifest_info_in_db()
159  * @code
160 static int delete_manifest_data(manifest_x *mfx)
161 {
162         int ret = 0;
163         ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
164         if (ret < 0)
165                 return -1;
166         return 0;
167 }
168  * @endcode
169  */
170 int pkgmgr_parser_delete_manifest_info_from_db(manifest_x *mfx);
171 int pkgmgr_parser_delete_manifest_info_from_usr_db(manifest_x *mfx, uid_t uid);
172
173 /**
174  * @fn int pkgmgr_parser_update_global_app_disable_for_uid_info_in_db(const char *appid, uid_t uid, int is_disable)
175  * @brief       This API updates disable info about global app for user specified by uid
176  *
177  * @par         This API is for package-manager installer backends
178  * @par Sync (or) Async : Synchronous API
179  *
180  * @param[in]   appid   global application ID to be enabled or disabled
181  * @param[in]   uid     the addressee user id of the instruction
182  * @param[in]is_disable determine enable or disable of app
183  * @return      0 if success, error code(<0) if fail
184  * @pre         None
185  * @post                None
186  * @code
187 static int disable_global_app_for_uid(const char *appid, uid_t uid)
188 {
189         int ret = 0;
190         ret = pkgmgr_parser_update_global_app_disable_for_uid_info_in_db(appid, uid, 1);
191         if (ret < 0)
192                 return -1;
193         return 0;
194 }
195  * @endcode
196  */
197 int pkgmgr_parser_update_global_app_disable_for_uid_info_in_db(const char *appid, uid_t uid, int is_disable);
198
199 /**
200  * @fn int pkgmgr_parser_update_app_disable_info_in_db(const char *appid, int is_disable);
201  * @brief       This API updates disable info about app
202  *
203  * @par         This API is for package-manager installer backends
204  * @par Sync (or) Async : Synchronous API
205  *
206  * @param[in]   appid   application ID to be enabled or disabled
207  * @param[in]   is_disable      determine enable or disable of app
208  * @return      0 if success, error code(<0) if fail
209  * @pre         None
210  * @post                None
211  * @code
212 static int disable_app(const char *appid)
213 {
214         int ret = 0;
215         ret = pkgmgr_parser_update_app_disable_info_in_db(appid, 1);
216         if (ret < 0)
217                 return -1;
218         return 0;
219 }
220  * @endcode
221  */
222 int pkgmgr_parser_update_app_disable_info_in_db(const char *appid, int is_disable);
223 int pkgmgr_parser_update_app_disable_info_in_usr_db(const char *appid, uid_t uid, int is_disable);
224
225 /**
226  * @fn int pkgmgr_parser_update_pkg_disable_info_in_db(const char *pkgid, int is_disable);
227  * @brief       This API updates disable info about pkg
228  *
229  * @par         This API is for package-manager installer backends
230  * @par Sync (or) Async : Synchronous API
231  *
232  * @param[in]   pkgid   package ID to be enabled or disabled
233  * @param[in]   is_disable      determine enable or disable of app
234  * @return      0 if success, error code(<0) if fail
235  * @pre         None
236  * @post                None
237  * @code
238 static int disable_pkg(const char *pkgid)
239 {
240         int ret = 0;
241         ret = pkgmgr_parser_update_pkg_disable_info_in_db(pkgid, 1);
242         if (ret < 0)
243                 return -1;
244         return 0;
245 }
246  * @endcode
247  */
248 int pkgmgr_parser_update_pkg_disable_info_in_db(const char *pkgid, int is_disable);
249 int pkgmgr_parser_update_pkg_disable_info_in_usr_db(const char *pkgid, uid_t uid, int is_disable);
250
251 /**
252  * @fn int pkgmgr_parser_update_global_app_splash_screen_display_info_in_usr_db(const char *appid, uid_t uid, int flag)
253  * @brief       This API updates splash screen display info about global app for user specified by uid
254  *
255  * @par         This API is for package-manager installer backends
256  * @par Sync (or) Async : Synchronous API
257  *
258  * @param[in]   appid   global application ID to be enabled or disabled
259  * @param[in]   uid     user ID
260  * @param[in]   flag    determine enable or disable of app
261  * @return      0 if success, error code(<0) if fail
262  * @pre         None
263  * @post                None
264  * @code
265 static int disable_global_app_splash_screen_for_uid(const char *appid, uid_t uid)
266 {
267         int ret = 0;
268         ret = pkgmgr_parser_update_global_app_splash_screen_info_in_usr_db(appid, uid, 1);
269         if (ret < 0)
270                 return -1;
271         return 0;
272 }
273  * @endcode
274  */
275 int pkgmgr_parser_update_global_app_splash_screen_display_info_in_usr_db(const char *appid, uid_t uid, int flag);
276
277 /**
278  * @fn int pkgmgr_parser_update_app_splash_screen_display_info_in_db(const char *appid, int flag)
279  * @brief       This API updates splash screen display info about app
280  *
281  * @par         This API is for package-manager installer backends
282  * @par Sync (or) Async : Synchronous API
283  *
284  * @param[in]   appid   application ID to be enabled or disabled
285  * @param[in]   flag    determine enable or disable of app
286  * @return      0 if success, error code(<0) if fail
287  * @pre         None
288  * @post                None
289  * @code
290 static int disable_app_splash_screen(const char *appid)
291 {
292         int ret = 0;
293         ret = pkgmgr_parser_update_app_splash_screen_info_in_db(appid, 1);
294         if (ret < 0)
295                 return -1;
296         return 0;
297 }
298  * @endcode
299  */
300 int pkgmgr_parser_update_app_splash_screen_display_info_in_db(const char *appid, int flag);
301
302 /**
303  * @fn int pkgmgr_parser_update_app_splash_screen_display_info_in_usr_db(const char *appid, uid_t uid, int flag)
304  * @brief       This API updates splash screen display info about app for user specified by uid
305  *
306  * @par         This API is for package-manager installer backends
307  * @par Sync (or) Async : Synchronous API
308  *
309  * @param[in]   appid   application ID to be enabled or disabled
310  * @param[in]   uid     user ID
311  * @param[in]   flag    determine enable or disable of app
312  * @return      0 if success, error code(<0) if fail
313  */
314 int pkgmgr_parser_update_app_splash_screen_display_info_in_usr_db(const char *appid, uid_t uid, int flag);
315
316 /**
317  * @fn int pkgmgr_parser_update_app_label_info_in_db(const char *appid, const char *label)
318  * @brief       This API updates label info of application
319  *
320  * @par         This API is only for internal usage
321  * @par Sync (or) Async : Synchronous API
322  *
323  * @param[in]   appid   application ID to change label
324  * @param[in]   label   label to change
325  * @return      0 if success, error code(<0) if fail
326  */
327 int pkgmgr_parser_update_app_label_info_in_db(const char *appid, const char *label);
328
329 /**
330  * @fn int pkgmgr_parser_update_app_label_info_in_usr_db(const char *appid, uid_t uid, const char *label)
331  * @brief       This API updates label info of application for user specified by uid
332  *
333  * @par         This API is only for internal usage
334  * @par Sync (or) Async : Synchronous API
335  *
336  * @param[in]   appid   application ID to change label
337  * @param[in]   uid     user ID
338  * @param[in]   label   label to change
339  * @return      0 if success, error code(<0) if fail
340  */
341 int pkgmgr_parser_update_app_label_info_in_usr_db(const char *appid, uid_t uid, const char *label);
342
343 /**
344  * @fn int pkgmgr_parser_update_app_icon_info_in_db(const char *appid, const char *icon_path)
345  * @brief       This API updates icon info of application
346  *
347  * @par         This API is only for internal usage
348  * @par Sync (or) Async : Synchronous API
349  *
350  * @param[in]   appid           application ID to change label
351  * @param[in]   icon_path       icon path to change
352  * @return      0 if success, error code(<0) if fail
353  */
354 int pkgmgr_parser_update_app_icon_info_in_db(const char *appid, const char *icon_path);
355
356 /**
357  * @fn int pkgmgr_parser_update_app_icon_info_in_usr_db(const char *appid, uid_t uid, const char *icon_path)
358  * @brief       This API updates icon info of application for user specified by uid
359  *
360  * @par         This API is only for internal usage
361  * @par Sync (or) Async : Synchronous API
362  *
363  * @param[in]   appid           application ID to change label
364  * @param[in]   uid             user ID
365  * @param[in]   icon_path       icon path to change
366  * @return      0 if success, error code(<0) if fail
367  */
368 int pkgmgr_parser_update_app_icon_info_in_usr_db(const char *appid, uid_t uid, const char *icon_path);
369
370 /**
371  * @fn int pkgmgr_parser_register_pkg_update_info_in_usr_db(pkgmgrinfo_updateinfo_h handle, uid_t uid)
372  * @brief       This API registers update informations of given packages for user specified by uid
373  *
374  * @par         This API is only for internal usage
375  * @par Sync (or) Async : Synchronous API
376  *
377  * @param[in]   handle  update information handle
378  * @param[in]   uid     user ID
379  * @return      0 if success, error code(<0) if fail
380  * @pre None
381  * @post         None
382  * @code
383 static int register_pkg_update_info(pkgmgrinfo_updateinfo_h update_info, uid_t uid)
384 {
385         int ret = 0;
386         ret = pkgmgr_parser_register_pkg_update_info_in_usr_db(update_info, uid);
387         if (ret < 0)
388                 return -1;
389         return 0;
390 }
391  * @endcode
392  */
393 int pkgmgr_parser_register_pkg_update_info_in_usr_db(pkgmgrinfo_updateinfo_h handle, uid_t uid);
394
395 /**
396  * @fn int pkgmgr_parser_register_pkg_update_info_in_db(pkgmgrinfo_updateinfo_h update_info)
397  * @brief       This API registers update informations of given packages
398  *
399  * @par         This API is only for internal usage
400  * @par Sync (or) Async : Synchronous API
401  *
402  * @param[in]   update_info     update information handle
403  * @return      0 if success, error code(<0) if fail
404  * @pre None
405  * @post        None
406  * @code
407 static int register_pkg_update_info(pkgmgrinfo_updateinfo_h update_info)
408 {
409         int ret = 0;
410         ret = pkgmgr_parser_register_pkg_update_info_in_db(update_info);
411         if (ret < 0)
412                 return -1;
413         return 0;
414 }
415  * @endcode
416  */
417 int pkgmgr_parser_register_pkg_update_info_in_db(pkgmgrinfo_updateinfo_h update_info);
418
419 /**
420  * @fn int pkgmgr_parser_unregister_pkg_update_info_in_usr_db(const char *pkgid, uid_t uid)
421  * @brief       This API unregister update information of certain package for user specified by uid.
422  *
423  * @par         This API is only for internal usage
424  * @par Sync (or) Async : Synchronous API
425  *
426  * @param[in]   pkgid   package ID
427  * @param[in]   uid     user ID
428  * @return      0 if success, error code(<0) if fail
429  * @pre None
430  * @post        None
431  * @code
432 static int register_pkg_update_info(pkgmgrinfo_updateinfo_h update_info, uid_t uid)
433 {
434         int ret = 0;
435         ret = pkgmgr_parser_register_pkg_update_info_in_db(update_info, uid);
436         if (ret < 0)
437                 return -1;
438         return 0;
439 }
440  * @endcode
441  */
442 int pkgmgr_parser_unregister_pkg_update_info_in_usr_db(const char *pkgid, uid_t uid);
443
444 /**
445  * @fn int pkgmgr_parser_unregister_pkg_update_info_in_db(const char * pkgid)
446  * @brief       This API unregister update information of certain package
447  *
448  * @par         This API is only for internal usage
449  * @par Sync (or) Async : Synchronous API
450  *
451  * @param[in]   pkgid   package ID
452  * @return      0 if success, error code(<0) if fail
453  * @pre None
454  * @post        None
455  * @code
456 static int unregister_pkg_update_info(const char *pkgid)
457 {
458         int ret = 0;
459         ret = pkgmgr_parser_unregister_pkg_update_info_in_db(pkgid);
460         if (ret < 0)
461                 return -1;
462         return 0;
463 }
464  * @endcode
465  */
466 int pkgmgr_parser_unregister_pkg_update_info_in_db(const char *pkgid);
467
468 /**
469  * @fn int pkgmgr_parser_unregister_all_pkg_update_info_in_usr_db(uid_t uid)
470  * @brief       This API unregister update information of all packages
471  *
472  * @par         This API is only for internal usage
473  * @par Sync (or) Async : Synchronous API
474  *
475  * @param[in]   uid     user ID
476  * @return      0 if success, error code(<0) if fail
477  * @pre None
478  * @post        None
479  * @code
480 static int unregister_all_pkg_update_info(uid_t uid)
481 {
482         int ret = 0;
483         ret = pkgmgr_parser_unregister_all_pkg_update_info_in_usr_db(uid);
484         if (ret < 0)
485                 return -1;
486         return 0;
487 }
488  * @endcode
489  */
490 int pkgmgr_parser_unregister_all_pkg_update_info_in_usr_db(uid_t uid);
491
492 /**
493  * @fn int pkgmgr_parser_unregister_all_pkg_update_info_in_db(void)
494  * @brief       This API unregisters update information of all packages
495  *
496  * @par         This API is only for internal usage
497  * @par Sync (or) Async : Synchronous API
498  *
499  * @return      0 if success, error code(<0) if fail
500  * @pre None
501  * @post         None
502  * @code
503 static int unregister_all_pkg_update_info(void)
504 {
505         int ret = 0;
506         ret = pkgmgr_parser_unregister_all_pkg_update_info_in_db();
507         if (ret < 0)
508                 return -1;
509         return 0;
510 }
511  * @endcode
512  */
513 int pkgmgr_parser_unregister_all_pkg_update_info_in_db(void);
514
515 /**
516  * @fn int pkgmgr_parser_register_pkg_plugin_info_in_usr_db(manifest_x *mfx, uid_t uid)
517  * @brief       This API registers package plugin execution information
518  *
519  * @par         This API is only for internal usage
520  * @par Sync (or) Async : Synchronous API
521  *
522  * @param[in]   mfx     manifest structure pointer which contains plugin execution info
523  * @return      0 if success, error code(<0) if fail
524  * @pre None
525  * @post         None
526  * @code
527 static int register_pkg_plugin_info(manifest_x *mfx)
528 {
529         int ret = 0;
530         ret = pkgmgr_parser_register_pkg_plugin_info_in_db(mfx);
531         if (ret < 0)
532                 return -1;
533         return 0;
534 }
535  * @endcode
536  */
537 int pkgmgr_parser_register_pkg_plugin_info_in_db(manifest_x *mfx);
538 int pkgmgr_parser_register_pkg_plugin_info_in_usr_db(manifest_x *mfx, uid_t uid);
539
540 /**
541  * @fn int pkgmgr_parser_update_pkg_plugin_info_in_usr_db(manifest_x *mfx, uid_t uid)
542  * @brief       This API updates package plugin execution information
543  *
544  * @par         This API is only for internal usage
545  * @par Sync (or) Async : Synchronous API
546  *
547  * @param[in]   mfx     manifest structure pointer which contains plugin execution info
548  * @return      0 if success, error code(<0) if fail
549  * @pre None
550  * @post         None
551  * @code
552 static int update_pkg_plugin_info(manifest_x *mfx)
553 {
554         int ret = 0;
555         ret = pkgmgr_parser_update_pkg_plugin_info_in_db(mfx);
556         if (ret < 0)
557                 return -1;
558         return 0;
559 }
560  * @endcode
561  */
562 int pkgmgr_parser_update_pkg_plugin_info_in_db(manifest_x *mfx);
563 int pkgmgr_parser_update_pkg_plugin_info_in_usr_db(manifest_x *mfx, uid_t uid);
564
565 /**
566  * @fn int pkgmgr_parser_unregister_pkg_plugin_info_in_usr_db(const char *pkgid, uid_t uid)
567  * @brief       This API unregisters package plugin execution information
568  *
569  * @par         This API is only for internal usage
570  * @par Sync (or) Async : Synchronous API
571  *
572  * @param[in]   pkgid   package ID
573  * @return      0 if success, error code(<0) if fail
574  * @pre None
575  * @post         None
576  * @code
577 static int unregister_pkg_plugin_info(const char *pkgid)
578 {
579         int ret = 0;
580         ret = pkgmgr_parser_unregister_pkg_plugin_info_in_db(pkgid);
581         if (ret < 0)
582                 return -1;
583         return 0;
584 }
585  * @endcode
586  */
587 int pkgmgr_parser_unregister_pkg_plugin_info_in_db(const char *pkgid);
588 int pkgmgr_parser_unregister_pkg_plugin_info_in_usr_db(const char *pkgid, uid_t uid);
589
590 int pkgmgr_parser_create_and_initialize_db(uid_t uid);
591 int pkgmgr_parser_initialize_parser_db(uid_t uid);
592 int pkgmgr_parser_initialize_cert_db(void);
593
594 /** @} */
595 #ifdef __cplusplus
596 }
597 #endif
598 #endif                          /* __PKGMGR_PARSER_DB_H__ */
599 /**
600  * @}
601  * @}
602  */