4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
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>
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
26 #include <sys/types.h>
31 #include "pkgmgr-info.h"
32 #include "pkgmgr_parser_internal.h"
33 #include "pkgmgr_parser_db.h"
35 #define PKGMGR_PARSER_DB_FILE "/opt/dbspace/.pkgmgr_parser.db"
36 #define PKGMGR_CERT_DB_FILE "/opt/dbspace/.pkgmgr_cert.db"
37 #define MAX_QUERY_LEN 4096
38 sqlite3 *pkgmgr_parser_db;
39 sqlite3 *pkgmgr_cert_db;
40 GList *pkglocale = NULL;
41 GList *applocale = NULL;
42 GList *appicon = NULL;
43 GList *appimage = NULL;
46 #define QUERY_CREATE_TABLE_PACKAGE_INFO "create table if not exists package_info " \
47 "(package text primary key not null, " \
48 "package_type text DEFAULT 'rpm', " \
49 "package_version text, " \
50 "install_location text, " \
51 "package_size text, " \
52 "package_removable text DEFAULT 'true', " \
53 "package_preload text DEFAULT 'false', " \
54 "package_readonly text DEFAULT 'false', " \
55 "package_update text DEFAULT 'false', " \
56 "package_appsetting text DEFAULT 'false', " \
57 "package_nodisplay text DEFAULT 'false', " \
58 "author_name text, " \
59 "author_email text, " \
61 "installed_time text," \
62 "installed_storage text," \
63 "storeclient_id text," \
69 #define QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO "create table if not exists package_localized_info " \
70 "(package text not null, " \
71 "package_locale text DEFAULT 'No Locale', " \
72 "package_label text, " \
73 "package_icon text, " \
74 "package_description text, " \
75 "package_license text, " \
77 "PRIMARY KEY(package, package_locale), " \
78 "FOREIGN KEY(package) " \
79 "REFERENCES package_info(package) " \
82 #define QUERY_CREATE_TABLE_PACKAGE_PRIVILEGE_INFO "create table if not exists package_privilege_info " \
83 "(package text not null, " \
84 "privilege text not null, " \
85 "PRIMARY KEY(package, privilege) " \
86 "FOREIGN KEY(package) " \
87 "REFERENCES package_info(package) " \
90 #define QUERY_CREATE_TABLE_PACKAGE_APP_INFO "create table if not exists package_app_info " \
91 "(app_id text primary key not null, " \
92 "app_component text, " \
94 "app_nodisplay text DEFAULT 'false', " \
96 "app_onboot text DEFAULT 'false', " \
97 "app_multiple text DEFAULT 'false', " \
98 "app_autorestart text DEFAULT 'false', " \
99 "app_taskmanage text DEFAULT 'false', " \
100 "app_enabled text DEFAULT 'true', " \
101 "app_hwacceleration text DEFAULT 'use-system-setting', " \
102 "app_mainapp text, " \
103 "app_recentimage text, " \
104 "app_launchcondition text, " \
105 "app_indicatordisplay text DEFAULT 'true', " \
106 "app_portraitimg text, " \
107 "app_landscapeimg text, " \
108 "app_guestmodevisibility text DEFAULT 'true', " \
109 "app_permissiontype text DEFAULT 'normal', " \
110 "package text not null, " \
111 "FOREIGN KEY(package) " \
112 "REFERENCES package_info(package) " \
115 #define QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO "create table if not exists package_app_localized_info " \
116 "(app_id text not null, " \
117 "app_locale text DEFAULT 'No Locale', " \
120 "PRIMARY KEY(app_id,app_locale) " \
121 "FOREIGN KEY(app_id) " \
122 "REFERENCES package_app_info(app_id) " \
125 #define QUERY_CREATE_TABLE_PACKAGE_APP_ICON_SECTION_INFO "create table if not exists package_app_icon_section_info " \
126 "(app_id text not null, " \
128 "app_icon_section text, " \
129 "app_icon_resolution text, " \
130 "PRIMARY KEY(app_id,app_icon_section,app_icon_resolution) " \
131 "FOREIGN KEY(app_id) " \
132 "REFERENCES package_app_info(app_id) " \
135 #define QUERY_CREATE_TABLE_PACKAGE_APP_IMAGE_INFO "create table if not exists package_app_image_info " \
136 "(app_id text not null, " \
137 "app_locale text DEFAULT 'No Locale', " \
138 "app_image_section text, " \
140 "PRIMARY KEY(app_id,app_image_section) " \
141 "FOREIGN KEY(app_id) " \
142 "REFERENCES package_app_info(app_id) " \
145 #define QUERY_CREATE_TABLE_PACKAGE_APP_APP_CONTROL "create table if not exists package_app_app_control " \
146 "(app_id text not null, " \
147 "operation text not null, " \
148 "uri_scheme text, " \
150 "subapp_name text, " \
151 "PRIMARY KEY(app_id,operation,uri_scheme,mime_type,subapp_name) " \
152 "FOREIGN KEY(app_id) " \
153 "REFERENCES package_app_info(app_id) " \
156 #define QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC "create table if not exists package_app_app_svc " \
157 "(app_id text not null, " \
158 "operation text not null, " \
159 "uri_scheme text, " \
161 "subapp_name text, " \
162 "PRIMARY KEY(app_id,operation,uri_scheme,mime_type,subapp_name) " \
163 "FOREIGN KEY(app_id) " \
164 "REFERENCES package_app_info(app_id) " \
167 #define QUERY_CREATE_TABLE_PACKAGE_APP_APP_CATEGORY "create table if not exists package_app_app_category " \
168 "(app_id text not null, " \
169 "category text not null, " \
170 "PRIMARY KEY(app_id,category) " \
171 "FOREIGN KEY(app_id) " \
172 "REFERENCES package_app_info(app_id) " \
175 #define QUERY_CREATE_TABLE_PACKAGE_APP_APP_METADATA "create table if not exists package_app_app_metadata " \
176 "(app_id text not null, " \
177 "md_key text not null, " \
178 "md_value text not null, " \
179 "PRIMARY KEY(app_id, md_key, md_value) " \
180 "FOREIGN KEY(app_id) " \
181 "REFERENCES package_app_info(app_id) " \
184 #define QUERY_CREATE_TABLE_PACKAGE_APP_APP_PERMISSION "create table if not exists package_app_app_permission " \
185 "(app_id text not null, " \
186 "pm_type text not null, " \
187 "pm_value text not null, " \
188 "PRIMARY KEY(app_id, pm_type, pm_value) " \
189 "FOREIGN KEY(app_id) " \
190 "REFERENCES package_app_info(app_id) " \
193 #define QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED "create table if not exists package_app_share_allowed " \
194 "(app_id text not null, " \
195 "data_share_path text not null, " \
196 "data_share_allowed text not null, " \
197 "PRIMARY KEY(app_id,data_share_path,data_share_allowed) " \
198 "FOREIGN KEY(app_id) " \
199 "REFERENCES package_app_info(app_id) " \
202 #define QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST "create table if not exists package_app_share_request " \
203 "(app_id text not null, " \
204 "data_share_request text not null, " \
205 "PRIMARY KEY(app_id,data_share_request) " \
206 "FOREIGN KEY(app_id) " \
207 "REFERENCES package_app_info(app_id) " \
210 #define QUERY_CREATE_TABLE_PACKAGE_CERT_INDEX_INFO "create table if not exists package_cert_index_info " \
211 "(cert_info text not null, " \
212 "cert_id integer, " \
213 "cert_ref_count integer, " \
214 "PRIMARY KEY(cert_id)) "
216 #define QUERY_CREATE_TABLE_PACKAGE_CERT_INFO "create table if not exists package_cert_info " \
217 "(package text not null, " \
218 "author_root_cert integer, " \
219 "author_im_cert integer, " \
220 "author_signer_cert integer, " \
221 "dist_root_cert integer, " \
222 "dist_im_cert integer, " \
223 "dist_signer_cert integer, " \
224 "dist2_root_cert integer, " \
225 "dist2_im_cert integer, " \
226 "dist2_signer_cert integer, " \
227 "PRIMARY KEY(package)) "
229 static int __insert_uiapplication_info(manifest_x *mfx);
230 static int __insert_serviceapplication_info(manifest_x *mfx);
231 static int __insert_uiapplication_appsvc_info(manifest_x *mfx);
232 static int __insert_serviceapplication_appsvc_info(manifest_x *mfx);
233 static int __insert_uiapplication_appcategory_info(manifest_x *mfx);
234 static int __insert_serviceapplication_appcategory_info(manifest_x *mfx);
235 static int __insert_uiapplication_appcontrol_info(manifest_x *mfx);
236 static int __insert_serviceapplication_appmetadata_info(manifest_x *mfx);
237 static int __insert_uiapplication_appmetadata_info(manifest_x *mfx);
238 static int __insert_serviceapplication_appcontrol_info(manifest_x *mfx);
239 static int __insert_uiapplication_share_allowed_info(manifest_x *mfx);
240 static int __insert_serviceapplication_share_allowed_info(manifest_x *mfx);
241 static int __insert_uiapplication_share_request_info(manifest_x *mfx);
242 static int __insert_serviceapplication_share_request_info(manifest_x *mfx);
243 static void __insert_serviceapplication_locale_info(gpointer data, gpointer userdata);
244 static void __insert_uiapplication_locale_info(gpointer data, gpointer userdata);
245 static void __insert_pkglocale_info(gpointer data, gpointer userdata);
246 static int __insert_manifest_info_in_db(manifest_x *mfx);
247 static int __delete_manifest_info_from_db(manifest_x *mfx);
248 static int __delete_appinfo_from_db(char *db_table, const char *appid);
249 static int __initialize_db(sqlite3 *db_handle, const char *db_query);
250 static int __exec_query(char *query);
251 static void __extract_data(gpointer data, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath,
252 char **label, char **license, char **icon, char **description, char **author);
253 static gint __comparefunc(gconstpointer a, gconstpointer b, gpointer userdata);
254 static void __trimfunc1(gpointer data, gpointer userdata);
255 static void __trimfunc2(gpointer data, gpointer userdata);
256 static GList *__create_locale_list(GList *locale, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath);
257 static void __preserve_guestmode_visibility_value(manifest_x *mfx);
258 static int __guestmode_visibility_cb(void *data, int ncols, char **coltxt, char **colname);
259 static int __pkgmgr_parser_create_db(sqlite3 **db_handle, const char *db_path);
261 static int __pkgmgr_parser_create_db(sqlite3 **db_handle, const char *db_path)
265 if (access(db_path, F_OK) == 0) {
267 db_util_open(db_path, &handle,
268 DB_UTIL_REGISTER_HOOK_METHOD);
269 if (ret != SQLITE_OK) {
270 DBG("connect db [%s] failed!\n",
277 DBG("%s DB does not exists. Create one!!\n", db_path);
280 db_util_open(db_path, &handle,
281 DB_UTIL_REGISTER_HOOK_METHOD);
283 if (ret != SQLITE_OK) {
284 DBG("connect db [%s] failed!\n", db_path);
291 static int __guestmode_visibility_cb(void *data, int ncols, char **coltxt, char **colname)
293 manifest_x *mfx = (manifest_x *)data;
297 uiapplication_x *uiapp = NULL;
298 for(i = 0; i < ncols; i++)
300 uiapp = mfx->uiapplication;
301 if (strcmp(colname[i], "app_id") == 0) {
303 appid = strdup(coltxt[i]);
304 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0) {
306 status = strdup(coltxt[i]);
310 DBG("app id is NULL\n");
313 /*update guest mode visibility*/
314 for (; uiapp != NULL; uiapp = uiapp->next) {
315 if (strcmp(uiapp->appid, appid) == 0) {
316 free((void *)uiapp->guestmode_visibility);
317 uiapp->guestmode_visibility = strdup(status);
333 static void __preserve_guestmode_visibility_value(manifest_x *mfx)
335 char *error_message = NULL;
336 char query[MAX_QUERY_LEN] = {'\0'};
337 snprintf(query, MAX_QUERY_LEN - 1, "select app_id, app_guestmodevisibility from package_app_info where package='%s'", mfx->package);
339 sqlite3_exec(pkgmgr_parser_db, query,
340 __guestmode_visibility_cb, (void *)mfx, &error_message)) {
341 DBG("Don't execute query = %s error message = %s\n",
342 query, error_message);
343 sqlite3_free(error_message);
348 static int __initialize_db(sqlite3 *db_handle, const char *db_query)
350 char *error_message = NULL;
352 sqlite3_exec(db_handle, db_query,
353 NULL, NULL, &error_message)) {
354 DBG("Don't execute query = %s error message = %s\n",
355 db_query, error_message);
356 sqlite3_free(error_message);
359 sqlite3_free(error_message);
363 static int __exec_query(char *query)
365 char *error_message = NULL;
367 sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &error_message)) {
368 DBG("Don't execute query = %s error message = %s\n", query,
370 sqlite3_free(error_message);
373 sqlite3_free(error_message);
377 static int __exec_query_no_msg(char *query)
379 char *error_message = NULL;
381 sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &error_message)) {
382 sqlite3_free(error_message);
385 sqlite3_free(error_message);
389 static GList *__create_locale_list(GList *locale, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath)
395 locale = g_list_insert_sorted_with_data(locale, (gpointer)lbl->lang, __comparefunc, NULL);
401 locale = g_list_insert_sorted_with_data(locale, (gpointer)lcn->lang, __comparefunc, NULL);
407 locale = g_list_insert_sorted_with_data(locale, (gpointer)icn->lang, __comparefunc, NULL);
413 locale = g_list_insert_sorted_with_data(locale, (gpointer)dcn->lang, __comparefunc, NULL);
419 locale = g_list_insert_sorted_with_data(locale, (gpointer)ath->lang, __comparefunc, NULL);
426 static GList *__create_icon_list(GList *locale, icon_x *icn)
431 locale = g_list_insert_sorted_with_data(locale, (gpointer)icn->section, __comparefunc, NULL);
437 static GList *__create_image_list(GList *locale, image_x *image)
442 locale = g_list_insert_sorted_with_data(locale, (gpointer)image->section, __comparefunc, NULL);
448 static void __printfunc(gpointer data, gpointer userdata)
450 DBG("%s ", (char*)data);
453 static void __trimfunc1(gpointer data, gpointer userdata)
456 if (strcmp((char *)data, prev) == 0) {
457 pkglocale = g_list_remove(pkglocale, data);
465 static void __trimfunc2(gpointer data, gpointer userdata)
468 if (strcmp((char *)data, prev) == 0) {
469 applocale = g_list_remove(applocale, data);
477 static void __trimfunc3(gpointer data, gpointer userdata)
480 if (strcmp((char *)data, prev) == 0) {
481 appicon = g_list_remove(appicon, data);
489 static void __trimfunc4(gpointer data, gpointer userdata)
492 if (strcmp((char *)data, prev) == 0) {
493 appimage = g_list_remove(appimage, data);
501 static gint __comparefunc(gconstpointer a, gconstpointer b, gpointer userdata)
503 if (a == NULL || b == NULL)
505 if (strcmp((char*)a, (char*)b) == 0)
507 if (strcmp((char*)a, (char*)b) < 0)
509 if (strcmp((char*)a, (char*)b) > 0)
514 static void __extract_data(gpointer data, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath,
515 char **label, char **license, char **icon, char **description, char **author)
520 if (strcmp(lbl->lang, (char *)data) == 0) {
521 *label = (char*)lbl->text;
530 if (strcmp(lcn->lang, (char *)data) == 0) {
531 *license = (char*)lcn->text;
540 if (strcmp(icn->lang, (char *)data) == 0) {
541 *icon = (char*)icn->text;
550 if (strcmp(dcn->lang, (char *)data) == 0) {
551 *description = (char*)dcn->text;
560 if (strcmp(ath->lang, (char *)data) == 0) {
561 *author = (char*)ath->text;
570 static void __extract_icon_data(gpointer data, icon_x *icn, char **icon, char **resolution)
575 if (strcmp(icn->section, (char *)data) == 0) {
576 *icon = (char*)icn->text;
577 *resolution = (char*)icn->resolution;
585 static void __extract_image_data(gpointer data, image_x*image, char **lang, char **img)
589 if (image->section) {
590 if (strcmp(image->section, (char *)data) == 0) {
591 *lang = (char*)image->lang;
592 *img = (char*)image->text;
600 static void __insert_pkglocale_info(gpointer data, gpointer userdata)
605 char *description = NULL;
606 char *license = NULL;
608 char query[MAX_QUERY_LEN] = {'\0'};
610 manifest_x *mfx = (manifest_x *)userdata;
611 label_x *lbl = mfx->label;
612 license_x *lcn = mfx->license;
613 icon_x *icn = mfx->icon;
614 description_x *dcn = mfx->description;
615 author_x *ath = mfx->author;
617 __extract_data(data, lbl, lcn, icn, dcn, ath, &label, &license, &icon, &description, &author);
618 if (!label && !description && !icon && !license && !author)
620 sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_localized_info(package, package_locale, " \
621 "package_label, package_icon, package_description, package_license, package_author) values " \
622 "('%q', '%q', '%q', '%q', '%q', '%q', '%q')", mfx->package, (char*)data,
623 label, icon, description, license, author);
624 ret = __exec_query(query);
626 DBG("Package Localized Info DB Insert failed\n");
629 static void __insert_uiapplication_locale_info(gpointer data, gpointer userdata)
634 char query[MAX_QUERY_LEN] = {'\0'};
636 uiapplication_x *up = (uiapplication_x*)userdata;
637 label_x *lbl = up->label;
638 icon_x *icn = up->icon;
640 __extract_data(data, lbl, NULL, icn, NULL, NULL, &label, NULL, &icon, NULL, NULL);
643 sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_app_localized_info(app_id, app_locale, " \
644 "app_label, app_icon) values " \
645 "('%q', '%q', '%q', '%q')", up->appid, (char*)data,
647 ret = __exec_query(query);
649 DBG("Package UiApp Localized Info DB Insert failed\n");
651 /*insert ui app locale info to pkg locale to get mainapp data */
652 if (strcasecmp(up->mainapp, "true")==0) {
653 sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_localized_info(package, package_locale, " \
654 "package_label, package_icon, package_description, package_license, package_author) values " \
655 "('%q', '%q', '%q', '%q', '%q', '%q', '%q')", up->package, (char*)data,
656 label, icon, NULL, NULL, NULL);
657 ret = __exec_query_no_msg(query);
659 snprintf(query, MAX_QUERY_LEN,
660 "update package_localized_info set package_label='%s', package_icon='%s' where package='%s' and package_locale='%s'", label, icon, up->package, (char*)data);
661 __exec_query_no_msg(query);
666 static void __insert_uiapplication_icon_section_info(gpointer data, gpointer userdata)
670 char *resolution = NULL;
671 char query[MAX_QUERY_LEN] = {'\0'};
673 uiapplication_x *up = (uiapplication_x*)userdata;
674 icon_x *icn = up->icon;
676 __extract_icon_data(data, icn, &icon, &resolution);
677 if (!icon && !resolution)
679 sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_app_icon_section_info(app_id, " \
680 "app_icon, app_icon_section, app_icon_resolution) values " \
681 "('%q', '%q', '%q', '%q')", up->appid,
682 icon, (char*)data, resolution);
684 ret = __exec_query(query);
686 DBG("Package UiApp Localized Info DB Insert failed\n");
690 static void __insert_uiapplication_image_info(gpointer data, gpointer userdata)
695 char query[MAX_QUERY_LEN] = {'\0'};
697 uiapplication_x *up = (uiapplication_x*)userdata;
698 image_x *image = up->image;
700 __extract_image_data(data, image, &lang, &img);
703 sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_app_image_info(app_id, app_locale, " \
704 "app_image_section, app_image) values " \
705 "('%q', '%q', '%q', '%q')", up->appid, lang, (char*)data, img);
707 ret = __exec_query(query);
709 DBG("Package UiApp image Info DB Insert failed\n");
714 static void __insert_serviceapplication_locale_info(gpointer data, gpointer userdata)
719 char query[MAX_QUERY_LEN] = {'\0'};
721 serviceapplication_x *sp = (serviceapplication_x*)userdata;
722 label_x *lbl = sp->label;
723 icon_x *icn = sp->icon;
725 __extract_data(data, lbl, NULL, icn, NULL, NULL, &label, NULL, &icon, NULL, NULL);
728 sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_app_localized_info(app_id, app_locale, " \
729 "app_label, app_icon) values " \
730 "('%q', '%q', '%q', '%q')", sp->appid, (char*)data,
732 ret = __exec_query(query);
734 DBG("Package ServiceApp Localized Info DB Insert failed\n");
737 static int __insert_ui_mainapp_info(manifest_x *mfx)
739 uiapplication_x *up = mfx->uiapplication;
741 char query[MAX_QUERY_LEN] = {'\0'};
744 snprintf(query, MAX_QUERY_LEN,
745 "update package_app_info set app_mainapp='%s' where app_id='%s'", up->mainapp, up->appid);
747 ret = __exec_query(query);
749 DBG("Package UiApp Info DB Insert Failed\n");
752 if (strcasecmp(up->mainapp, "True")==0)
753 mfx->mainapp_id = strdup(up->appid);
756 memset(query, '\0', MAX_QUERY_LEN);
759 if (mfx->mainapp_id == NULL){
760 if (mfx->uiapplication && mfx->uiapplication->appid) {
761 snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_mainapp='true' where app_id='%s'", mfx->uiapplication->appid);
763 DBG("Not valid appid\n");
767 ret = __exec_query(query);
769 DBG("Package UiApp Info DB Insert Failed\n");
773 free((void *)mfx->uiapplication->mainapp);
774 mfx->uiapplication->mainapp= strdup("true");
775 mfx->mainapp_id = strdup(mfx->uiapplication->appid);
778 memset(query, '\0', MAX_QUERY_LEN);
779 snprintf(query, MAX_QUERY_LEN,
780 "update package_info set mainapp_id='%s' where package='%s'", mfx->mainapp_id, mfx->package);
781 ret = __exec_query(query);
783 DBG("Package Info DB update Failed\n");
789 /* _PRODUCT_LAUNCHING_ENHANCED_
790 * up->indicatordisplay, up->portraitimg, up->landscapeimg, up->guestmode_appstatus
792 static int __insert_uiapplication_info(manifest_x *mfx)
794 uiapplication_x *up = mfx->uiapplication;
796 char query[MAX_QUERY_LEN] = {'\0'};
799 snprintf(query, MAX_QUERY_LEN,
800 "insert into package_app_info(app_id, app_component, app_exec, app_nodisplay, app_type, app_onboot, " \
801 "app_multiple, app_autorestart, app_taskmanage, app_enabled, app_hwacceleration, app_mainapp , app_recentimage, " \
802 "app_launchcondition, app_indicatordisplay, app_portraitimg, app_landscapeimg, app_guestmodevisibility, app_permissiontype, package) " \
803 "values('%s', '%s', '%s', '%s', '%s', '%s','%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
804 up->appid, "uiapp", up->exec, up->nodisplay, up->type, "\0", up->multiple,
805 "\0", up->taskmanage, up->enabled, up->hwacceleration,up->mainapp, up->recentimage,
806 up->launchcondition, up->indicatordisplay, up->portraitimg, up->landscapeimg, up->guestmode_visibility, up->permission_type, mfx->package);
807 ret = __exec_query(query);
809 DBG("Package UiApp Info DB Insert Failed\n");
813 memset(query, '\0', MAX_QUERY_LEN);
818 static int __insert_uiapplication_appcategory_info(manifest_x *mfx)
820 uiapplication_x *up = mfx->uiapplication;
821 category_x *ct = NULL;
823 char query[MAX_QUERY_LEN] = {'\0'};
829 snprintf(query, MAX_QUERY_LEN,
830 "insert into package_app_app_category(app_id, category) " \
831 "values('%s','%s')",\
832 up->appid, ct->name);
833 ret = __exec_query(query);
835 DBG("Package UiApp Category Info DB Insert Failed\n");
839 memset(query, '\0', MAX_QUERY_LEN);
846 static int __insert_uiapplication_appmetadata_info(manifest_x *mfx)
848 uiapplication_x *up = mfx->uiapplication;
849 metadata_x *md = NULL;
851 char query[MAX_QUERY_LEN] = {'\0'};
858 snprintf(query, MAX_QUERY_LEN,
859 "insert into package_app_app_metadata(app_id, md_key, md_value) " \
860 "values('%s','%s', '%s')",\
861 up->appid, md->key, md->value);
862 ret = __exec_query(query);
864 DBG("Package UiApp Metadata Info DB Insert Failed\n");
869 memset(query, '\0', MAX_QUERY_LEN);
876 static int __insert_uiapplication_apppermission_info(manifest_x *mfx)
878 uiapplication_x *up = mfx->uiapplication;
879 permission_x *pm = NULL;
881 char query[MAX_QUERY_LEN] = {'\0'};
887 snprintf(query, MAX_QUERY_LEN,
888 "insert into package_app_app_permission(app_id, pm_type, pm_value) " \
889 "values('%s','%s', '%s')",\
890 up->appid, pm->type, pm->value);
891 ret = __exec_query(query);
893 DBG("Package UiApp permission Info DB Insert Failed\n");
897 memset(query, '\0', MAX_QUERY_LEN);
904 static int __insert_uiapplication_appcontrol_info(manifest_x *mfx)
906 uiapplication_x *up = mfx->uiapplication;
907 appcontrol_x *acontrol = NULL;
908 operation_x *op = NULL;
911 subapp_x *sub = NULL;
913 char query[MAX_QUERY_LEN] = {'\0'};
914 const char *operation = NULL;
915 const char *mime = NULL;
916 const char *uri = NULL;
917 const char *subapp = NULL;
920 acontrol = up->appcontrol;
921 while(acontrol != NULL)
923 op = acontrol->operation;
927 operation = op->name;
934 sub = acontrol->subapp;
944 snprintf(query, MAX_QUERY_LEN,
945 "insert into package_app_app_control(app_id, operation, uri_scheme, mime_type, subapp_name) " \
946 "values('%s', '%s', '%s', '%s', '%s')",\
947 up->appid, operation, uri, mime, subapp);
949 ret = __exec_query(query);
951 DBG("Package UiApp AppSvc DB Insert Failed\n");
954 memset(query, '\0', MAX_QUERY_LEN);
971 acontrol = acontrol->next;
978 static int __insert_uiapplication_appsvc_info(manifest_x *mfx)
980 uiapplication_x *up = mfx->uiapplication;
981 appsvc_x *asvc = NULL;
982 operation_x *op = NULL;
985 subapp_x *sub = NULL;
987 char query[MAX_QUERY_LEN] = {'\0'};
988 const char *operation = NULL;
989 const char *mime = NULL;
990 const char *uri = NULL;
991 const char *subapp = NULL;
997 op = asvc->operation;
1001 operation = op->name;
1018 snprintf(query, MAX_QUERY_LEN,
1019 "insert into package_app_app_svc(app_id, operation, uri_scheme, mime_type, subapp_name) " \
1020 "values('%s', '%s', '%s', '%s', '%s')",\
1021 up->appid, operation, uri, mime, subapp);
1023 ret = __exec_query(query);
1025 DBG("Package UiApp AppSvc DB Insert Failed\n");
1028 memset(query, '\0', MAX_QUERY_LEN);
1032 } while(ui != NULL);
1036 }while(sub != NULL);
1052 static int __insert_uiapplication_share_request_info(manifest_x *mfx)
1054 uiapplication_x *up = mfx->uiapplication;
1055 datashare_x *ds = NULL;
1056 request_x *rq = NULL;
1058 char query[MAX_QUERY_LEN] = {'\0'};
1067 snprintf(query, MAX_QUERY_LEN,
1068 "insert into package_app_share_request(app_id, data_share_request) " \
1069 "values('%s', '%s')",\
1070 up->appid, rq->text);
1071 ret = __exec_query(query);
1073 DBG("Package UiApp Share Request DB Insert Failed\n");
1076 memset(query, '\0', MAX_QUERY_LEN);
1086 static int __insert_uiapplication_share_allowed_info(manifest_x *mfx)
1088 uiapplication_x *up = mfx->uiapplication;
1089 datashare_x *ds = NULL;
1090 define_x *df = NULL;
1091 allowed_x *al = NULL;
1093 char query[MAX_QUERY_LEN] = {'\0'};
1105 snprintf(query, MAX_QUERY_LEN,
1106 "insert into package_app_share_allowed(app_id, data_share_path, data_share_allowed) " \
1107 "values('%s', '%s', '%s')",\
1108 up->appid, df->path, al->text);
1109 ret = __exec_query(query);
1111 DBG("Package UiApp Share Allowed DB Insert Failed\n");
1114 memset(query, '\0', MAX_QUERY_LEN);
1126 static int __insert_serviceapplication_info(manifest_x *mfx)
1128 serviceapplication_x *sp = mfx->serviceapplication;
1130 char query[MAX_QUERY_LEN] = {'\0'};
1133 snprintf(query, MAX_QUERY_LEN,
1134 "insert into package_app_info(app_id, app_component, app_exec, app_type, app_onboot, " \
1135 "app_multiple, app_autorestart, app_enabled, app_permissiontype, package) " \
1136 "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
1137 sp->appid, "svcapp", sp->exec, sp->type, sp->onboot, "\0",
1138 sp->autorestart, sp->enabled, sp->permission_type, mfx->package);
1139 ret = __exec_query(query);
1141 DBG("Package ServiceApp Info DB Insert Failed\n");
1145 memset(query, '\0', MAX_QUERY_LEN);
1150 static int __insert_serviceapplication_appcategory_info(manifest_x *mfx)
1152 serviceapplication_x *sp = mfx->serviceapplication;
1153 category_x *ct = NULL;
1155 char query[MAX_QUERY_LEN] = {'\0'};
1161 snprintf(query, MAX_QUERY_LEN,
1162 "insert into package_app_app_category(app_id, category) " \
1163 "values('%s','%s')",\
1164 sp->appid, ct->name);
1165 ret = __exec_query(query);
1167 DBG("Package ServiceApp Category Info DB Insert Failed\n");
1171 memset(query, '\0', MAX_QUERY_LEN);
1178 static int __insert_serviceapplication_appmetadata_info(manifest_x *mfx)
1180 serviceapplication_x *sp = mfx->serviceapplication;
1181 metadata_x *md = NULL;
1183 char query[MAX_QUERY_LEN] = {'\0'};
1190 snprintf(query, MAX_QUERY_LEN,
1191 "insert into package_app_app_metadata(app_id, md_key, md_value) " \
1192 "values('%s','%s', '%s')",\
1193 sp->appid, md->key, md->value);
1194 ret = __exec_query(query);
1196 DBG("Package ServiceApp Metadata Info DB Insert Failed\n");
1201 memset(query, '\0', MAX_QUERY_LEN);
1208 static int __insert_serviceapplication_apppermission_info(manifest_x *mfx)
1210 serviceapplication_x *sp = mfx->serviceapplication;
1211 permission_x *pm = NULL;
1213 char query[MAX_QUERY_LEN] = {'\0'};
1216 pm = sp->permission;
1219 snprintf(query, MAX_QUERY_LEN,
1220 "insert into package_app_app_permission(app_id, pm_type, pm_value) " \
1221 "values('%s','%s', '%s')",\
1222 sp->appid, pm->type, pm->value);
1223 ret = __exec_query(query);
1225 DBG("Package ServiceApp permission Info DB Insert Failed\n");
1229 memset(query, '\0', MAX_QUERY_LEN);
1236 static int __insert_serviceapplication_appcontrol_info(manifest_x *mfx)
1238 serviceapplication_x *sp = mfx->serviceapplication;
1239 appcontrol_x *acontrol = NULL;
1241 char query[MAX_QUERY_LEN] = {'\0'};
1242 operation_x *op = NULL;
1245 subapp_x *sub = NULL;
1246 const char *operation = NULL;
1247 const char *mime = NULL;
1248 const char *uri = NULL;
1249 const char *subapp = NULL;
1252 acontrol = sp->appcontrol;
1253 while(acontrol != NULL)
1255 op = acontrol->operation;
1259 operation = op->name;
1260 mi = acontrol->mime;
1265 sub = acontrol->subapp;
1275 snprintf(query, MAX_QUERY_LEN,
1276 "insert into package_app_app_control(app_id, operation, uri_scheme, mime_type,subapp_name) " \
1277 "values('%s', '%s', '%s', '%s', '%s')",\
1278 sp->appid, operation, uri, mime, subapp);
1279 ret = __exec_query(query);
1281 DBG("Package UiApp AppSvc DB Insert Failed\n");
1284 memset(query, '\0', MAX_QUERY_LEN);
1288 } while(ui != NULL);
1292 }while(sub != NULL);
1301 acontrol = acontrol->next;
1308 static int __insert_serviceapplication_appsvc_info(manifest_x *mfx)
1310 serviceapplication_x *sp = mfx->serviceapplication;
1311 appsvc_x *asvc = NULL;
1313 char query[MAX_QUERY_LEN] = {'\0'};
1314 operation_x *op = NULL;
1317 subapp_x *sub = NULL;
1318 const char *operation = NULL;
1319 const char *mime = NULL;
1320 const char *uri = NULL;
1321 const char *subapp = NULL;
1327 op = asvc->operation;
1331 operation = op->name;
1347 snprintf(query, MAX_QUERY_LEN,
1348 "insert into package_app_app_svc(app_id, operation, uri_scheme, mime_type, subapp_name) " \
1349 "values('%s', '%s', '%s', '%s', '%s')",\
1350 sp->appid, operation, uri, mime, subapp);
1351 ret = __exec_query(query);
1353 DBG("Package UiApp AppSvc DB Insert Failed\n");
1356 memset(query, '\0', MAX_QUERY_LEN);
1360 } while(ui != NULL);
1364 }while(sub != NULL);
1382 static int __insert_serviceapplication_share_request_info(manifest_x *mfx)
1384 serviceapplication_x *sp = mfx->serviceapplication;
1385 datashare_x *ds = NULL;
1386 request_x *rq = NULL;
1388 char query[MAX_QUERY_LEN] = {'\0'};
1397 snprintf(query, MAX_QUERY_LEN,
1398 "insert into package_app_share_request(app_id, data_share_request) " \
1399 "values('%s', '%s')",\
1400 sp->appid, rq->text);
1401 ret = __exec_query(query);
1403 DBG("Package ServiceApp Share Request DB Insert Failed\n");
1406 memset(query, '\0', MAX_QUERY_LEN);
1418 static int __insert_serviceapplication_share_allowed_info(manifest_x *mfx)
1420 serviceapplication_x *sp = mfx->serviceapplication;
1421 datashare_x *ds = NULL;
1422 define_x *df = NULL;
1423 allowed_x *al = NULL;
1425 char query[MAX_QUERY_LEN] = {'\0'};
1437 snprintf(query, MAX_QUERY_LEN,
1438 "insert into package_app_share_allowed(app_id, data_share_path, data_share_allowed) " \
1439 "values('%s', '%s', '%s')",\
1440 sp->appid, df->path, al->text);
1441 ret = __exec_query(query);
1443 DBG("Package App Share Allowed DB Insert Failed\n");
1446 memset(query, '\0', MAX_QUERY_LEN);
1458 static int __insert_manifest_info_in_db(manifest_x *mfx)
1460 label_x *lbl = mfx->label;
1461 license_x *lcn = mfx->license;
1462 icon_x *icn = mfx->icon;
1463 description_x *dcn = mfx->description;
1464 author_x *ath = mfx->author;
1465 uiapplication_x *up = mfx->uiapplication;
1466 uiapplication_x *up_icn = mfx->uiapplication;
1467 uiapplication_x *up_image = mfx->uiapplication;
1468 serviceapplication_x *sp = mfx->serviceapplication;
1469 privileges_x *pvs = NULL;
1470 privilege_x *pv = NULL;
1471 char query[MAX_QUERY_LEN] = { '\0' };
1472 char root[MAX_QUERY_LEN] = { '\0' };
1476 const char *auth_name = NULL;
1477 const char *auth_email = NULL;
1478 const char *auth_href = NULL;
1481 auth_name = ath->text;
1483 auth_email = ath->email;
1485 auth_href = ath->href;
1488 /*Insert in the package_info DB*/
1490 type = strdup(mfx->type);
1492 type = strdup("rpm");
1493 /*Insert in the package_info DB*/
1495 path = strdup(mfx->root_path);
1497 if (strcmp(type,"rpm")==0)
1498 snprintf(root, MAX_QUERY_LEN - 1, "/usr/apps/%s", mfx->package);
1500 snprintf(root, MAX_QUERY_LEN - 1, "/opt/usr/apps/%s", mfx->package);
1502 path = strdup(root);
1504 snprintf(query, MAX_QUERY_LEN,
1505 "insert into package_info(package, package_type, package_version, install_location, package_size, " \
1506 "package_removable, package_preload, package_readonly, package_update, package_appsetting, package_nodisplay, " \
1507 "author_name, author_email, author_href, installed_time, installed_storage, storeclient_id, mainapp_id, package_url, root_path, csc_path) " \
1508 "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
1509 mfx->package, type, mfx->version, mfx->installlocation, mfx->package_size, mfx->removable, mfx->preload,
1510 mfx->readonly, mfx->update, mfx->appsetting, mfx->nodisplay_setting,
1511 auth_name, auth_email, auth_href, mfx->installed_time, mfx->installed_storage, mfx->storeclient_id, mfx->mainapp_id, mfx->package_url, path, mfx->csc_path);
1512 ret = __exec_query(query);
1514 DBG("Package Info DB Insert Failed\n");
1534 /*Insert in the package_privilege_info DB*/
1535 pvs = mfx->privileges;
1536 while (pvs != NULL) {
1537 pv = pvs->privilege;
1538 while (pv != NULL) {
1539 memset(query, '\0', MAX_QUERY_LEN);
1540 snprintf(query, MAX_QUERY_LEN,
1541 "insert into package_privilege_info(package, privilege) " \
1542 "values('%s','%s')",\
1543 mfx->package, pv->text);
1544 ret = __exec_query(query);
1546 DBG("Package Privilege Info DB Insert Failed\n");
1554 ret = __insert_ui_mainapp_info(mfx);
1558 /*Insert the package locale and app locale info */
1559 pkglocale = __create_locale_list(pkglocale, lbl, lcn, icn, dcn, ath);
1560 g_list_foreach(pkglocale, __trimfunc1, NULL);
1565 applocale = __create_locale_list(applocale, up->label, NULL, up->icon, NULL, NULL);
1570 applocale = __create_locale_list(applocale, sp->label, NULL, sp->icon, NULL, NULL);
1573 g_list_foreach(applocale, __trimfunc2, NULL);
1576 /*Insert the app icon info */
1577 while(up_icn != NULL)
1579 appicon = __create_icon_list(appicon, up_icn->icon);
1580 up_icn = up_icn->next;
1582 g_list_foreach(appicon, __trimfunc3, NULL);
1585 /*Insert the image info */
1586 while(up_image != NULL)
1588 appimage = __create_image_list(appimage, up_image->image);
1589 up_image = up_image->next;
1591 g_list_foreach(appimage, __trimfunc4, NULL);
1594 /*g_list_foreach(pkglocale, __printfunc, NULL);*/
1596 /*g_list_foreach(applocale, __printfunc, NULL);*/
1598 /*package locale info*/
1599 g_list_foreach(pkglocale, __insert_pkglocale_info, (gpointer)mfx);
1600 /*native app locale info*/
1601 up = mfx->uiapplication;
1604 g_list_foreach(applocale, __insert_uiapplication_locale_info, (gpointer)up);
1607 /*agent app locale info*/
1608 sp = mfx->serviceapplication;
1611 g_list_foreach(applocale, __insert_serviceapplication_locale_info, (gpointer)sp);
1615 /*app icon locale info*/
1616 up_icn = mfx->uiapplication;
1617 while(up_icn != NULL)
1619 g_list_foreach(appicon, __insert_uiapplication_icon_section_info, (gpointer)up_icn);
1620 up_icn = up_icn->next;
1624 up_image = mfx->uiapplication;
1625 while(up_image != NULL)
1627 g_list_foreach(appimage, __insert_uiapplication_image_info, (gpointer)up_image);
1628 up_image = up_image->next;
1631 g_list_free(pkglocale);
1633 g_list_free(applocale);
1635 g_list_free(appicon);
1637 g_list_free(appimage);
1641 /*Insert in the package_app_info DB*/
1642 ret = __insert_uiapplication_info(mfx);
1645 ret = __insert_serviceapplication_info(mfx);
1649 /*Insert in the package_app_app_control DB*/
1650 ret = __insert_uiapplication_appcontrol_info(mfx);
1653 ret = __insert_serviceapplication_appcontrol_info(mfx);
1657 /*Insert in the package_app_app_category DB*/
1658 ret = __insert_uiapplication_appcategory_info(mfx);
1661 ret = __insert_serviceapplication_appcategory_info(mfx);
1665 /*Insert in the package_app_app_metadata DB*/
1666 ret = __insert_uiapplication_appmetadata_info(mfx);
1669 ret = __insert_serviceapplication_appmetadata_info(mfx);
1673 /*Insert in the package_app_app_permission DB*/
1674 ret = __insert_uiapplication_apppermission_info(mfx);
1677 ret = __insert_serviceapplication_apppermission_info(mfx);
1681 /*Insert in the package_app_app_svc DB*/
1682 ret = __insert_uiapplication_appsvc_info(mfx);
1685 ret = __insert_serviceapplication_appsvc_info(mfx);
1689 /*Insert in the package_app_share_allowed DB*/
1690 ret = __insert_uiapplication_share_allowed_info(mfx);
1693 ret = __insert_serviceapplication_share_allowed_info(mfx);
1697 /*Insert in the package_app_share_request DB*/
1698 ret = __insert_uiapplication_share_request_info(mfx);
1701 ret = __insert_serviceapplication_share_request_info(mfx);
1709 static int __delete_appinfo_from_db(char *db_table, const char *appid)
1711 char query[MAX_QUERY_LEN] = { '\0' };
1713 memset(query, '\0', MAX_QUERY_LEN);
1714 snprintf(query, MAX_QUERY_LEN,
1715 "delete from %s where app_id='%s'", db_table, appid);
1716 ret = __exec_query(query);
1718 DBG("DB Deletion from table (%s) Failed\n", db_table);
1724 static int __delete_manifest_info_from_db(manifest_x *mfx)
1726 char query[MAX_QUERY_LEN] = { '\0' };
1728 uiapplication_x *up = mfx->uiapplication;
1729 serviceapplication_x *sp = mfx->serviceapplication;
1730 /*Delete from cert table*/
1731 ret = pkgmgrinfo_delete_certinfo(mfx->package);
1733 DBG("Cert Info DB Delete Failed\n");
1737 /*Delete from Package Info DB*/
1738 snprintf(query, MAX_QUERY_LEN,
1739 "delete from package_info where package='%s'", mfx->package);
1740 ret = __exec_query(query);
1742 DBG("Package Info DB Delete Failed\n");
1745 memset(query, '\0', MAX_QUERY_LEN);
1747 /*Delete from Package Localized Info*/
1748 snprintf(query, MAX_QUERY_LEN,
1749 "delete from package_localized_info where package='%s'", mfx->package);
1750 ret = __exec_query(query);
1752 DBG("Package Localized Info DB Delete Failed\n");
1756 /*Delete from Package Privilege Info*/
1757 snprintf(query, MAX_QUERY_LEN,
1758 "delete from package_privilege_info where package='%s'", mfx->package);
1759 ret = __exec_query(query);
1761 DBG("Package Privilege Info DB Delete Failed\n");
1765 while (up != NULL) {
1766 ret = __delete_appinfo_from_db("package_app_info", up->appid);
1769 ret = __delete_appinfo_from_db("package_app_localized_info", up->appid);
1772 ret = __delete_appinfo_from_db("package_app_icon_section_info", up->appid);
1775 ret = __delete_appinfo_from_db("package_app_image_info", up->appid);
1778 ret = __delete_appinfo_from_db("package_app_app_svc", up->appid);
1781 ret = __delete_appinfo_from_db("package_app_app_control", up->appid);
1784 ret = __delete_appinfo_from_db("package_app_app_category", up->appid);
1787 ret = __delete_appinfo_from_db("package_app_app_metadata", up->appid);
1790 ret = __delete_appinfo_from_db("package_app_app_permission", up->appid);
1793 ret = __delete_appinfo_from_db("package_app_share_allowed", up->appid);
1796 ret = __delete_appinfo_from_db("package_app_share_request", up->appid);
1802 while (sp != NULL) {
1803 ret = __delete_appinfo_from_db("package_app_info", sp->appid);
1806 ret = __delete_appinfo_from_db("package_app_localized_info", sp->appid);
1809 ret = __delete_appinfo_from_db("package_app_icon_section_info", sp->appid);
1812 ret = __delete_appinfo_from_db("package_app_image_info", sp->appid);
1815 ret = __delete_appinfo_from_db("package_app_app_svc", sp->appid);
1818 ret = __delete_appinfo_from_db("package_app_app_control", sp->appid);
1821 ret = __delete_appinfo_from_db("package_app_app_category", sp->appid);
1824 ret = __delete_appinfo_from_db("package_app_app_metadata", sp->appid);
1827 ret = __delete_appinfo_from_db("package_app_app_permission", sp->appid);
1830 ret = __delete_appinfo_from_db("package_app_share_allowed", sp->appid);
1833 ret = __delete_appinfo_from_db("package_app_share_request", sp->appid);
1842 int pkgmgr_parser_initialize_db()
1846 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_INFO);
1848 DBG("package info DB initialization failed\n");
1851 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO);
1853 DBG("package localized info DB initialization failed\n");
1856 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_PRIVILEGE_INFO);
1858 DBG("package app app privilege DB initialization failed\n");
1861 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_INFO);
1863 DBG("package app info DB initialization failed\n");
1866 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO);
1868 DBG("package app localized info DB initialization failed\n");
1871 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_ICON_SECTION_INFO);
1873 DBG("package app icon localized info DB initialization failed\n");
1876 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_IMAGE_INFO);
1878 DBG("package app image info DB initialization failed\n");
1881 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_CONTROL);
1883 DBG("package app app control DB initialization failed\n");
1886 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_CATEGORY);
1888 DBG("package app app category DB initialization failed\n");
1891 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_METADATA);
1893 DBG("package app app category DB initialization failed\n");
1896 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_PERMISSION);
1898 DBG("package app app permission DB initialization failed\n");
1901 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC);
1903 DBG("package app app svc DB initialization failed\n");
1906 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED);
1908 DBG("package app share allowed DB initialization failed\n");
1911 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST);
1913 DBG("package app share request DB initialization failed\n");
1917 ret = __initialize_db(pkgmgr_cert_db, QUERY_CREATE_TABLE_PACKAGE_CERT_INFO);
1919 DBG("package cert info DB initialization failed\n");
1922 ret = __initialize_db(pkgmgr_cert_db, QUERY_CREATE_TABLE_PACKAGE_CERT_INDEX_INFO);
1924 DBG("package cert index info DB initialization failed\n");
1930 int pkgmgr_parser_check_and_create_db()
1934 ret = __pkgmgr_parser_create_db(&pkgmgr_parser_db, PKGMGR_PARSER_DB_FILE);
1936 DBG("Manifest DB creation Failed\n");
1940 ret = __pkgmgr_parser_create_db(&pkgmgr_cert_db, PKGMGR_CERT_DB_FILE);
1942 DBG("Cert DB creation Failed\n");
1948 API int pkgmgr_parser_insert_manifest_info_in_db(manifest_x *mfx)
1951 DBG("manifest pointer is NULL\n");
1955 ret = pkgmgr_parser_check_and_create_db();
1957 DBG("Failed to open DB\n");
1960 ret = pkgmgr_parser_initialize_db();
1963 /*Begin transaction*/
1964 ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
1965 if (ret != SQLITE_OK) {
1966 DBG("Failed to begin transaction\n");
1970 DBG("Transaction Begin\n");
1971 ret = __insert_manifest_info_in_db(mfx);
1973 DBG("Insert into DB failed. Rollback now\n");
1974 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
1977 /*Commit transaction*/
1978 ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
1979 if (ret != SQLITE_OK) {
1980 DBG("Failed to commit transaction. Rollback now\n");
1981 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
1985 DBG("Transaction Commit and End\n");
1987 sqlite3_close(pkgmgr_parser_db);
1988 sqlite3_close(pkgmgr_cert_db);
1992 API int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx)
1995 DBG("manifest pointer is NULL\n");
1999 ret = pkgmgr_parser_check_and_create_db();
2001 DBG("Failed to open DB\n");
2004 ret = pkgmgr_parser_initialize_db();
2007 /*Preserve guest mode visibility*/
2008 __preserve_guestmode_visibility_value( mfx);
2009 /*Begin transaction*/
2010 ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
2011 if (ret != SQLITE_OK) {
2012 DBG("Failed to begin transaction\n");
2016 DBG("Transaction Begin\n");
2017 ret = __delete_manifest_info_from_db(mfx);
2019 DBG("Delete from DB failed. Rollback now\n");
2020 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2023 ret = __insert_manifest_info_in_db(mfx);
2025 DBG("Insert into DB failed. Rollback now\n");
2026 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2030 /*Commit transaction*/
2031 ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
2032 if (ret != SQLITE_OK) {
2033 DBG("Failed to commit transaction. Rollback now\n");
2034 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2038 DBG("Transaction Commit and End\n");
2040 sqlite3_close(pkgmgr_parser_db);
2041 sqlite3_close(pkgmgr_cert_db);
2045 API int pkgmgr_parser_delete_manifest_info_from_db(manifest_x *mfx)
2048 DBG("manifest pointer is NULL\n");
2052 ret = pkgmgr_parser_check_and_create_db();
2054 DBG("Failed to open DB\n");
2057 /*Begin transaction*/
2058 ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
2059 if (ret != SQLITE_OK) {
2060 DBG("Failed to begin transaction\n");
2064 DBG("Transaction Begin\n");
2065 ret = __delete_manifest_info_from_db(mfx);
2067 DBG("Delete from DB failed. Rollback now\n");
2068 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2071 /*Commit transaction*/
2072 ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
2073 if (ret != SQLITE_OK) {
2074 DBG("Failed to commit transaction, Rollback now\n");
2075 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2079 DBG("Transaction Commit and End\n");
2080 sqlite3_close(pkgmgr_parser_db);
2082 sqlite3_close(pkgmgr_parser_db);
2083 sqlite3_close(pkgmgr_cert_db);