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 "app_preload text DEFAULT 'false', " \
111 "app_submode text DEFAULT 'false', " \
112 "app_submode_mainid text, " \
113 "component_type text, " \
114 "package text not null, " \
115 "FOREIGN KEY(package) " \
116 "REFERENCES package_info(package) " \
119 #define QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO "create table if not exists package_app_localized_info " \
120 "(app_id text not null, " \
121 "app_locale text DEFAULT 'No Locale', " \
124 "PRIMARY KEY(app_id,app_locale) " \
125 "FOREIGN KEY(app_id) " \
126 "REFERENCES package_app_info(app_id) " \
129 #define QUERY_CREATE_TABLE_PACKAGE_APP_ICON_SECTION_INFO "create table if not exists package_app_icon_section_info " \
130 "(app_id text not null, " \
132 "app_icon_section text, " \
133 "app_icon_resolution text, " \
134 "PRIMARY KEY(app_id,app_icon_section,app_icon_resolution) " \
135 "FOREIGN KEY(app_id) " \
136 "REFERENCES package_app_info(app_id) " \
139 #define QUERY_CREATE_TABLE_PACKAGE_APP_IMAGE_INFO "create table if not exists package_app_image_info " \
140 "(app_id text not null, " \
141 "app_locale text DEFAULT 'No Locale', " \
142 "app_image_section text, " \
144 "PRIMARY KEY(app_id,app_image_section) " \
145 "FOREIGN KEY(app_id) " \
146 "REFERENCES package_app_info(app_id) " \
149 #define QUERY_CREATE_TABLE_PACKAGE_APP_APP_CONTROL "create table if not exists package_app_app_control " \
150 "(app_id text not null, " \
151 "operation text not null, " \
152 "uri_scheme text, " \
154 "subapp_name text, " \
155 "PRIMARY KEY(app_id,operation,uri_scheme,mime_type,subapp_name) " \
156 "FOREIGN KEY(app_id) " \
157 "REFERENCES package_app_info(app_id) " \
160 #define QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC "create table if not exists package_app_app_svc " \
161 "(app_id text not null, " \
162 "operation text not null, " \
163 "uri_scheme text, " \
165 "subapp_name text, " \
166 "PRIMARY KEY(app_id,operation,uri_scheme,mime_type,subapp_name) " \
167 "FOREIGN KEY(app_id) " \
168 "REFERENCES package_app_info(app_id) " \
171 #define QUERY_CREATE_TABLE_PACKAGE_APP_APP_CATEGORY "create table if not exists package_app_app_category " \
172 "(app_id text not null, " \
173 "category text not null, " \
174 "PRIMARY KEY(app_id,category) " \
175 "FOREIGN KEY(app_id) " \
176 "REFERENCES package_app_info(app_id) " \
179 #define QUERY_CREATE_TABLE_PACKAGE_APP_APP_METADATA "create table if not exists package_app_app_metadata " \
180 "(app_id text not null, " \
181 "md_key text not null, " \
182 "md_value text not null, " \
183 "PRIMARY KEY(app_id, md_key, md_value) " \
184 "FOREIGN KEY(app_id) " \
185 "REFERENCES package_app_info(app_id) " \
188 #define QUERY_CREATE_TABLE_PACKAGE_APP_APP_PERMISSION "create table if not exists package_app_app_permission " \
189 "(app_id text not null, " \
190 "pm_type text not null, " \
191 "pm_value text not null, " \
192 "PRIMARY KEY(app_id, pm_type, pm_value) " \
193 "FOREIGN KEY(app_id) " \
194 "REFERENCES package_app_info(app_id) " \
197 #define QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED "create table if not exists package_app_share_allowed " \
198 "(app_id text not null, " \
199 "data_share_path text not null, " \
200 "data_share_allowed text not null, " \
201 "PRIMARY KEY(app_id,data_share_path,data_share_allowed) " \
202 "FOREIGN KEY(app_id) " \
203 "REFERENCES package_app_info(app_id) " \
206 #define QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST "create table if not exists package_app_share_request " \
207 "(app_id text not null, " \
208 "data_share_request text not null, " \
209 "PRIMARY KEY(app_id,data_share_request) " \
210 "FOREIGN KEY(app_id) " \
211 "REFERENCES package_app_info(app_id) " \
214 #define QUERY_CREATE_TABLE_PACKAGE_CERT_INDEX_INFO "create table if not exists package_cert_index_info " \
215 "(cert_info text not null, " \
216 "cert_id integer, " \
217 "cert_ref_count integer, " \
218 "PRIMARY KEY(cert_id)) "
220 #define QUERY_CREATE_TABLE_PACKAGE_CERT_INFO "create table if not exists package_cert_info " \
221 "(package text not null, " \
222 "author_root_cert integer, " \
223 "author_im_cert integer, " \
224 "author_signer_cert integer, " \
225 "dist_root_cert integer, " \
226 "dist_im_cert integer, " \
227 "dist_signer_cert integer, " \
228 "dist2_root_cert integer, " \
229 "dist2_im_cert integer, " \
230 "dist2_signer_cert integer, " \
231 "PRIMARY KEY(package)) "
233 static int __insert_uiapplication_info(manifest_x *mfx);
234 static int __insert_serviceapplication_info(manifest_x *mfx);
235 static int __insert_uiapplication_appsvc_info(manifest_x *mfx);
236 static int __insert_serviceapplication_appsvc_info(manifest_x *mfx);
237 static int __insert_uiapplication_appcategory_info(manifest_x *mfx);
238 static int __insert_serviceapplication_appcategory_info(manifest_x *mfx);
239 static int __insert_uiapplication_appcontrol_info(manifest_x *mfx);
240 static int __insert_serviceapplication_appmetadata_info(manifest_x *mfx);
241 static int __insert_uiapplication_appmetadata_info(manifest_x *mfx);
242 static int __insert_serviceapplication_appcontrol_info(manifest_x *mfx);
243 static int __insert_uiapplication_share_allowed_info(manifest_x *mfx);
244 static int __insert_serviceapplication_share_allowed_info(manifest_x *mfx);
245 static int __insert_uiapplication_share_request_info(manifest_x *mfx);
246 static int __insert_serviceapplication_share_request_info(manifest_x *mfx);
247 static void __insert_serviceapplication_locale_info(gpointer data, gpointer userdata);
248 static void __insert_uiapplication_locale_info(gpointer data, gpointer userdata);
249 static void __insert_pkglocale_info(gpointer data, gpointer userdata);
250 static int __insert_manifest_info_in_db(manifest_x *mfx);
251 static int __delete_manifest_info_from_db(manifest_x *mfx);
252 static int __delete_appinfo_from_db(char *db_table, const char *appid);
253 static int __initialize_db(sqlite3 *db_handle, const char *db_query);
254 static int __exec_query(char *query);
255 static void __extract_data(gpointer data, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath,
256 char **label, char **license, char **icon, char **description, char **author);
257 static gint __comparefunc(gconstpointer a, gconstpointer b, gpointer userdata);
258 static void __trimfunc1(gpointer data, gpointer userdata);
259 static void __trimfunc2(gpointer data, gpointer userdata);
260 static GList *__create_locale_list(GList *locale, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath);
261 static void __preserve_guestmode_visibility_value(manifest_x *mfx);
262 static int __guestmode_visibility_cb(void *data, int ncols, char **coltxt, char **colname);
263 static int __pkgmgr_parser_create_db(sqlite3 **db_handle, const char *db_path);
265 static int __pkgmgr_parser_create_db(sqlite3 **db_handle, const char *db_path)
269 if (access(db_path, F_OK) == 0) {
271 db_util_open(db_path, &handle,
272 DB_UTIL_REGISTER_HOOK_METHOD);
273 if (ret != SQLITE_OK) {
274 DBG("connect db [%s] failed!\n",
281 DBG("%s DB does not exists. Create one!!\n", db_path);
284 db_util_open(db_path, &handle,
285 DB_UTIL_REGISTER_HOOK_METHOD);
287 if (ret != SQLITE_OK) {
288 DBG("connect db [%s] failed!\n", db_path);
295 static int __guestmode_visibility_cb(void *data, int ncols, char **coltxt, char **colname)
297 manifest_x *mfx = (manifest_x *)data;
301 uiapplication_x *uiapp = NULL;
302 for(i = 0; i < ncols; i++)
304 uiapp = mfx->uiapplication;
305 if (strcmp(colname[i], "app_id") == 0) {
307 appid = strdup(coltxt[i]);
308 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0) {
310 status = strdup(coltxt[i]);
314 DBG("app id is NULL\n");
317 /*update guest mode visibility*/
318 for (; uiapp != NULL; uiapp = uiapp->next) {
319 if (strcmp(uiapp->appid, appid) == 0) {
320 free((void *)uiapp->guestmode_visibility);
321 uiapp->guestmode_visibility = strdup(status);
337 static void __preserve_guestmode_visibility_value(manifest_x *mfx)
339 char *error_message = NULL;
340 char query[MAX_QUERY_LEN] = {'\0'};
341 snprintf(query, MAX_QUERY_LEN - 1, "select app_id, app_guestmodevisibility from package_app_info where package='%s'", mfx->package);
343 sqlite3_exec(pkgmgr_parser_db, query,
344 __guestmode_visibility_cb, (void *)mfx, &error_message)) {
345 DBG("Don't execute query = %s error message = %s\n",
346 query, error_message);
347 sqlite3_free(error_message);
352 static int __initialize_db(sqlite3 *db_handle, const char *db_query)
354 char *error_message = NULL;
356 sqlite3_exec(db_handle, db_query,
357 NULL, NULL, &error_message)) {
358 DBG("Don't execute query = %s error message = %s\n",
359 db_query, error_message);
360 sqlite3_free(error_message);
363 sqlite3_free(error_message);
367 static int __exec_query(char *query)
369 char *error_message = NULL;
371 sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &error_message)) {
372 DBG("Don't execute query = %s error message = %s\n", query,
374 sqlite3_free(error_message);
377 sqlite3_free(error_message);
381 static int __exec_query_no_msg(char *query)
383 char *error_message = NULL;
385 sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &error_message)) {
386 sqlite3_free(error_message);
389 sqlite3_free(error_message);
393 static GList *__create_locale_list(GList *locale, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath)
399 locale = g_list_insert_sorted_with_data(locale, (gpointer)lbl->lang, __comparefunc, NULL);
405 locale = g_list_insert_sorted_with_data(locale, (gpointer)lcn->lang, __comparefunc, NULL);
411 locale = g_list_insert_sorted_with_data(locale, (gpointer)icn->lang, __comparefunc, NULL);
417 locale = g_list_insert_sorted_with_data(locale, (gpointer)dcn->lang, __comparefunc, NULL);
423 locale = g_list_insert_sorted_with_data(locale, (gpointer)ath->lang, __comparefunc, NULL);
430 static GList *__create_icon_list(GList *locale, icon_x *icn)
435 locale = g_list_insert_sorted_with_data(locale, (gpointer)icn->section, __comparefunc, NULL);
441 static GList *__create_image_list(GList *locale, image_x *image)
446 locale = g_list_insert_sorted_with_data(locale, (gpointer)image->section, __comparefunc, NULL);
452 static void __printfunc(gpointer data, gpointer userdata)
454 DBG("%s ", (char*)data);
457 static void __trimfunc1(gpointer data, gpointer userdata)
460 if (strcmp((char *)data, prev) == 0) {
461 pkglocale = g_list_remove(pkglocale, data);
469 static void __trimfunc2(gpointer data, gpointer userdata)
472 if (strcmp((char *)data, prev) == 0) {
473 applocale = g_list_remove(applocale, data);
481 static void __trimfunc3(gpointer data, gpointer userdata)
484 if (strcmp((char *)data, prev) == 0) {
485 appicon = g_list_remove(appicon, data);
493 static void __trimfunc4(gpointer data, gpointer userdata)
496 if (strcmp((char *)data, prev) == 0) {
497 appimage = g_list_remove(appimage, data);
505 static gint __comparefunc(gconstpointer a, gconstpointer b, gpointer userdata)
507 if (a == NULL || b == NULL)
509 if (strcmp((char*)a, (char*)b) == 0)
511 if (strcmp((char*)a, (char*)b) < 0)
513 if (strcmp((char*)a, (char*)b) > 0)
518 static void __extract_data(gpointer data, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath,
519 char **label, char **license, char **icon, char **description, char **author)
524 if (strcmp(lbl->lang, (char *)data) == 0) {
525 *label = (char*)lbl->text;
534 if (strcmp(lcn->lang, (char *)data) == 0) {
535 *license = (char*)lcn->text;
544 if (strcmp(icn->lang, (char *)data) == 0) {
545 *icon = (char*)icn->text;
554 if (strcmp(dcn->lang, (char *)data) == 0) {
555 *description = (char*)dcn->text;
564 if (strcmp(ath->lang, (char *)data) == 0) {
565 *author = (char*)ath->text;
574 static void __extract_icon_data(gpointer data, icon_x *icn, char **icon, char **resolution)
579 if (strcmp(icn->section, (char *)data) == 0) {
580 *icon = (char*)icn->text;
581 *resolution = (char*)icn->resolution;
589 static void __extract_image_data(gpointer data, image_x*image, char **lang, char **img)
593 if (image->section) {
594 if (strcmp(image->section, (char *)data) == 0) {
595 *lang = (char*)image->lang;
596 *img = (char*)image->text;
604 static void __insert_pkglocale_info(gpointer data, gpointer userdata)
609 char *description = NULL;
610 char *license = NULL;
612 char query[MAX_QUERY_LEN] = {'\0'};
614 manifest_x *mfx = (manifest_x *)userdata;
615 label_x *lbl = mfx->label;
616 license_x *lcn = mfx->license;
617 icon_x *icn = mfx->icon;
618 description_x *dcn = mfx->description;
619 author_x *ath = mfx->author;
621 __extract_data(data, lbl, lcn, icn, dcn, ath, &label, &license, &icon, &description, &author);
622 if (!label && !description && !icon && !license && !author)
624 sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_localized_info(package, package_locale, " \
625 "package_label, package_icon, package_description, package_license, package_author) values " \
626 "('%q', '%q', '%q', '%q', '%q', '%q', '%q')", mfx->package, (char*)data,
627 label, icon, description, license, author);
628 ret = __exec_query(query);
630 DBG("Package Localized Info DB Insert failed\n");
633 static void __insert_uiapplication_locale_info(gpointer data, gpointer userdata)
638 char query[MAX_QUERY_LEN] = {'\0'};
640 uiapplication_x *up = (uiapplication_x*)userdata;
641 label_x *lbl = up->label;
642 icon_x *icn = up->icon;
644 __extract_data(data, lbl, NULL, icn, NULL, NULL, &label, NULL, &icon, NULL, NULL);
647 sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_app_localized_info(app_id, app_locale, " \
648 "app_label, app_icon) values " \
649 "('%q', '%q', '%q', '%q')", up->appid, (char*)data,
651 ret = __exec_query(query);
653 DBG("Package UiApp Localized Info DB Insert failed\n");
655 /*insert ui app locale info to pkg locale to get mainapp data */
656 if (strcasecmp(up->mainapp, "true")==0) {
657 sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_localized_info(package, package_locale, " \
658 "package_label, package_icon, package_description, package_license, package_author) values " \
659 "('%q', '%q', '%q', '%q', '%q', '%q', '%q')", up->package, (char*)data,
660 label, icon, NULL, NULL, NULL);
661 ret = __exec_query_no_msg(query);
665 static void __insert_uiapplication_icon_section_info(gpointer data, gpointer userdata)
669 char *resolution = NULL;
670 char query[MAX_QUERY_LEN] = {'\0'};
672 uiapplication_x *up = (uiapplication_x*)userdata;
673 icon_x *icn = up->icon;
675 __extract_icon_data(data, icn, &icon, &resolution);
676 if (!icon && !resolution)
678 sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_app_icon_section_info(app_id, " \
679 "app_icon, app_icon_section, app_icon_resolution) values " \
680 "('%q', '%q', '%q', '%q')", up->appid,
681 icon, (char*)data, resolution);
683 ret = __exec_query(query);
685 DBG("Package UiApp Localized Info DB Insert failed\n");
689 static void __insert_uiapplication_image_info(gpointer data, gpointer userdata)
694 char query[MAX_QUERY_LEN] = {'\0'};
696 uiapplication_x *up = (uiapplication_x*)userdata;
697 image_x *image = up->image;
699 __extract_image_data(data, image, &lang, &img);
702 sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_app_image_info(app_id, app_locale, " \
703 "app_image_section, app_image) values " \
704 "('%q', '%q', '%q', '%q')", up->appid, lang, (char*)data, img);
706 ret = __exec_query(query);
708 DBG("Package UiApp image Info DB Insert failed\n");
713 static void __insert_serviceapplication_locale_info(gpointer data, gpointer userdata)
718 char query[MAX_QUERY_LEN] = {'\0'};
720 serviceapplication_x *sp = (serviceapplication_x*)userdata;
721 label_x *lbl = sp->label;
722 icon_x *icn = sp->icon;
724 __extract_data(data, lbl, NULL, icn, NULL, NULL, &label, NULL, &icon, NULL, NULL);
727 sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_app_localized_info(app_id, app_locale, " \
728 "app_label, app_icon) values " \
729 "('%q', '%q', '%q', '%q')", sp->appid, (char*)data,
731 ret = __exec_query(query);
733 DBG("Package ServiceApp Localized Info DB Insert failed\n");
736 static int __insert_ui_mainapp_info(manifest_x *mfx)
738 uiapplication_x *up = mfx->uiapplication;
740 char query[MAX_QUERY_LEN] = {'\0'};
743 snprintf(query, MAX_QUERY_LEN,
744 "update package_app_info set app_mainapp='%s' where app_id='%s'", up->mainapp, up->appid);
746 ret = __exec_query(query);
748 DBG("Package UiApp Info DB Insert Failed\n");
751 if (strcasecmp(up->mainapp, "True")==0)
752 mfx->mainapp_id = strdup(up->appid);
755 memset(query, '\0', MAX_QUERY_LEN);
758 if (mfx->mainapp_id == NULL){
759 if (mfx->uiapplication && mfx->uiapplication->appid) {
760 snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_mainapp='true' where app_id='%s'", mfx->uiapplication->appid);
762 DBG("Not valid appid\n");
766 ret = __exec_query(query);
768 DBG("Package UiApp Info DB Insert Failed\n");
772 free((void *)mfx->uiapplication->mainapp);
773 mfx->uiapplication->mainapp= strdup("true");
774 mfx->mainapp_id = strdup(mfx->uiapplication->appid);
777 memset(query, '\0', MAX_QUERY_LEN);
778 snprintf(query, MAX_QUERY_LEN,
779 "update package_info set mainapp_id='%s' where package='%s'", mfx->mainapp_id, mfx->package);
780 ret = __exec_query(query);
782 DBG("Package Info DB update Failed\n");
788 /* _PRODUCT_LAUNCHING_ENHANCED_
789 * up->indicatordisplay, up->portraitimg, up->landscapeimg, up->guestmode_appstatus
791 static int __insert_uiapplication_info(manifest_x *mfx)
793 uiapplication_x *up = mfx->uiapplication;
795 char query[MAX_QUERY_LEN] = {'\0'};
798 snprintf(query, MAX_QUERY_LEN,
799 "insert into package_app_info(app_id, app_component, app_exec, app_nodisplay, app_type, app_onboot, " \
800 "app_multiple, app_autorestart, app_taskmanage, app_enabled, app_hwacceleration, app_mainapp , app_recentimage, " \
801 "app_launchcondition, app_indicatordisplay, app_portraitimg, app_landscapeimg, app_guestmodevisibility, app_permissiontype, "\
802 "app_preload, app_submode, app_submode_mainid, component_type, package) " \
803 "values('%s', '%s', '%s', '%s', '%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,
807 mfx->preload, up->submode, up->submode_mainid, up->component_type, mfx->package);
808 ret = __exec_query(query);
810 DBG("Package UiApp Info DB Insert Failed\n");
814 memset(query, '\0', MAX_QUERY_LEN);
819 static int __insert_uiapplication_appcategory_info(manifest_x *mfx)
821 uiapplication_x *up = mfx->uiapplication;
822 category_x *ct = NULL;
824 char query[MAX_QUERY_LEN] = {'\0'};
830 snprintf(query, MAX_QUERY_LEN,
831 "insert into package_app_app_category(app_id, category) " \
832 "values('%s','%s')",\
833 up->appid, ct->name);
834 ret = __exec_query(query);
836 DBG("Package UiApp Category Info DB Insert Failed\n");
840 memset(query, '\0', MAX_QUERY_LEN);
847 static int __insert_uiapplication_appmetadata_info(manifest_x *mfx)
849 uiapplication_x *up = mfx->uiapplication;
850 metadata_x *md = NULL;
852 char query[MAX_QUERY_LEN] = {'\0'};
859 snprintf(query, MAX_QUERY_LEN,
860 "insert into package_app_app_metadata(app_id, md_key, md_value) " \
861 "values('%s','%s', '%s')",\
862 up->appid, md->key, md->value);
863 ret = __exec_query(query);
865 DBG("Package UiApp Metadata Info DB Insert Failed\n");
870 memset(query, '\0', MAX_QUERY_LEN);
877 static int __insert_uiapplication_apppermission_info(manifest_x *mfx)
879 uiapplication_x *up = mfx->uiapplication;
880 permission_x *pm = NULL;
882 char query[MAX_QUERY_LEN] = {'\0'};
888 snprintf(query, MAX_QUERY_LEN,
889 "insert into package_app_app_permission(app_id, pm_type, pm_value) " \
890 "values('%s','%s', '%s')",\
891 up->appid, pm->type, pm->value);
892 ret = __exec_query(query);
894 DBG("Package UiApp permission Info DB Insert Failed\n");
898 memset(query, '\0', MAX_QUERY_LEN);
905 static int __insert_uiapplication_appcontrol_info(manifest_x *mfx)
907 uiapplication_x *up = mfx->uiapplication;
908 appcontrol_x *acontrol = NULL;
909 operation_x *op = NULL;
912 subapp_x *sub = NULL;
914 char query[MAX_QUERY_LEN] = {'\0'};
915 const char *operation = NULL;
916 const char *mime = NULL;
917 const char *uri = NULL;
918 const char *subapp = NULL;
921 acontrol = up->appcontrol;
922 while(acontrol != NULL)
924 op = acontrol->operation;
928 operation = op->name;
935 sub = acontrol->subapp;
945 snprintf(query, MAX_QUERY_LEN,
946 "insert into package_app_app_control(app_id, operation, uri_scheme, mime_type, subapp_name) " \
947 "values('%s', '%s', '%s', '%s', '%s')",\
948 up->appid, operation, uri, mime, subapp);
950 ret = __exec_query(query);
952 DBG("Package UiApp AppSvc DB Insert Failed\n");
955 memset(query, '\0', MAX_QUERY_LEN);
972 acontrol = acontrol->next;
979 static int __insert_uiapplication_appsvc_info(manifest_x *mfx)
981 uiapplication_x *up = mfx->uiapplication;
982 appsvc_x *asvc = NULL;
983 operation_x *op = NULL;
986 subapp_x *sub = NULL;
988 char query[MAX_QUERY_LEN] = {'\0'};
989 const char *operation = NULL;
990 const char *mime = NULL;
991 const char *uri = NULL;
992 const char *subapp = NULL;
998 op = asvc->operation;
1002 operation = op->name;
1019 snprintf(query, MAX_QUERY_LEN,
1020 "insert into package_app_app_svc(app_id, operation, uri_scheme, mime_type, subapp_name) " \
1021 "values('%s', '%s', '%s', '%s', '%s')",\
1022 up->appid, operation, uri, mime, subapp);
1024 ret = __exec_query(query);
1026 DBG("Package UiApp AppSvc DB Insert Failed\n");
1029 memset(query, '\0', MAX_QUERY_LEN);
1033 } while(ui != NULL);
1037 }while(sub != NULL);
1053 static int __insert_uiapplication_share_request_info(manifest_x *mfx)
1055 uiapplication_x *up = mfx->uiapplication;
1056 datashare_x *ds = NULL;
1057 request_x *rq = NULL;
1059 char query[MAX_QUERY_LEN] = {'\0'};
1068 snprintf(query, MAX_QUERY_LEN,
1069 "insert into package_app_share_request(app_id, data_share_request) " \
1070 "values('%s', '%s')",\
1071 up->appid, rq->text);
1072 ret = __exec_query(query);
1074 DBG("Package UiApp Share Request DB Insert Failed\n");
1077 memset(query, '\0', MAX_QUERY_LEN);
1087 static int __insert_uiapplication_share_allowed_info(manifest_x *mfx)
1089 uiapplication_x *up = mfx->uiapplication;
1090 datashare_x *ds = NULL;
1091 define_x *df = NULL;
1092 allowed_x *al = NULL;
1094 char query[MAX_QUERY_LEN] = {'\0'};
1106 snprintf(query, MAX_QUERY_LEN,
1107 "insert into package_app_share_allowed(app_id, data_share_path, data_share_allowed) " \
1108 "values('%s', '%s', '%s')",\
1109 up->appid, df->path, al->text);
1110 ret = __exec_query(query);
1112 DBG("Package UiApp Share Allowed DB Insert Failed\n");
1115 memset(query, '\0', MAX_QUERY_LEN);
1127 static int __insert_serviceapplication_info(manifest_x *mfx)
1129 serviceapplication_x *sp = mfx->serviceapplication;
1131 char query[MAX_QUERY_LEN] = {'\0'};
1134 snprintf(query, MAX_QUERY_LEN,
1135 "insert into package_app_info(app_id, app_component, app_exec, app_type, app_onboot, " \
1136 "app_multiple, app_autorestart, app_enabled, app_permissiontype, package) " \
1137 "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
1138 sp->appid, "svcapp", sp->exec, sp->type, sp->onboot, "\0",
1139 sp->autorestart, sp->enabled, sp->permission_type, mfx->package);
1140 ret = __exec_query(query);
1142 DBG("Package ServiceApp Info DB Insert Failed\n");
1146 memset(query, '\0', MAX_QUERY_LEN);
1151 static int __insert_serviceapplication_appcategory_info(manifest_x *mfx)
1153 serviceapplication_x *sp = mfx->serviceapplication;
1154 category_x *ct = NULL;
1156 char query[MAX_QUERY_LEN] = {'\0'};
1162 snprintf(query, MAX_QUERY_LEN,
1163 "insert into package_app_app_category(app_id, category) " \
1164 "values('%s','%s')",\
1165 sp->appid, ct->name);
1166 ret = __exec_query(query);
1168 DBG("Package ServiceApp Category Info DB Insert Failed\n");
1172 memset(query, '\0', MAX_QUERY_LEN);
1179 static int __insert_serviceapplication_appmetadata_info(manifest_x *mfx)
1181 serviceapplication_x *sp = mfx->serviceapplication;
1182 metadata_x *md = NULL;
1184 char query[MAX_QUERY_LEN] = {'\0'};
1191 snprintf(query, MAX_QUERY_LEN,
1192 "insert into package_app_app_metadata(app_id, md_key, md_value) " \
1193 "values('%s','%s', '%s')",\
1194 sp->appid, md->key, md->value);
1195 ret = __exec_query(query);
1197 DBG("Package ServiceApp Metadata Info DB Insert Failed\n");
1202 memset(query, '\0', MAX_QUERY_LEN);
1209 static int __insert_serviceapplication_apppermission_info(manifest_x *mfx)
1211 serviceapplication_x *sp = mfx->serviceapplication;
1212 permission_x *pm = NULL;
1214 char query[MAX_QUERY_LEN] = {'\0'};
1217 pm = sp->permission;
1220 snprintf(query, MAX_QUERY_LEN,
1221 "insert into package_app_app_permission(app_id, pm_type, pm_value) " \
1222 "values('%s','%s', '%s')",\
1223 sp->appid, pm->type, pm->value);
1224 ret = __exec_query(query);
1226 DBG("Package ServiceApp permission Info DB Insert Failed\n");
1230 memset(query, '\0', MAX_QUERY_LEN);
1237 static int __insert_serviceapplication_appcontrol_info(manifest_x *mfx)
1239 serviceapplication_x *sp = mfx->serviceapplication;
1240 appcontrol_x *acontrol = NULL;
1242 char query[MAX_QUERY_LEN] = {'\0'};
1243 operation_x *op = NULL;
1246 subapp_x *sub = NULL;
1247 const char *operation = NULL;
1248 const char *mime = NULL;
1249 const char *uri = NULL;
1250 const char *subapp = NULL;
1253 acontrol = sp->appcontrol;
1254 while(acontrol != NULL)
1256 op = acontrol->operation;
1260 operation = op->name;
1261 mi = acontrol->mime;
1266 sub = acontrol->subapp;
1276 snprintf(query, MAX_QUERY_LEN,
1277 "insert into package_app_app_control(app_id, operation, uri_scheme, mime_type,subapp_name) " \
1278 "values('%s', '%s', '%s', '%s', '%s')",\
1279 sp->appid, operation, uri, mime, subapp);
1280 ret = __exec_query(query);
1282 DBG("Package UiApp AppSvc DB Insert Failed\n");
1285 memset(query, '\0', MAX_QUERY_LEN);
1289 } while(ui != NULL);
1293 }while(sub != NULL);
1302 acontrol = acontrol->next;
1309 static int __insert_serviceapplication_appsvc_info(manifest_x *mfx)
1311 serviceapplication_x *sp = mfx->serviceapplication;
1312 appsvc_x *asvc = NULL;
1314 char query[MAX_QUERY_LEN] = {'\0'};
1315 operation_x *op = NULL;
1318 subapp_x *sub = NULL;
1319 const char *operation = NULL;
1320 const char *mime = NULL;
1321 const char *uri = NULL;
1322 const char *subapp = NULL;
1328 op = asvc->operation;
1332 operation = op->name;
1348 snprintf(query, MAX_QUERY_LEN,
1349 "insert into package_app_app_svc(app_id, operation, uri_scheme, mime_type, subapp_name) " \
1350 "values('%s', '%s', '%s', '%s', '%s')",\
1351 sp->appid, operation, uri, mime, subapp);
1352 ret = __exec_query(query);
1354 DBG("Package UiApp AppSvc DB Insert Failed\n");
1357 memset(query, '\0', MAX_QUERY_LEN);
1361 } while(ui != NULL);
1365 }while(sub != NULL);
1383 static int __insert_serviceapplication_share_request_info(manifest_x *mfx)
1385 serviceapplication_x *sp = mfx->serviceapplication;
1386 datashare_x *ds = NULL;
1387 request_x *rq = NULL;
1389 char query[MAX_QUERY_LEN] = {'\0'};
1398 snprintf(query, MAX_QUERY_LEN,
1399 "insert into package_app_share_request(app_id, data_share_request) " \
1400 "values('%s', '%s')",\
1401 sp->appid, rq->text);
1402 ret = __exec_query(query);
1404 DBG("Package ServiceApp Share Request DB Insert Failed\n");
1407 memset(query, '\0', MAX_QUERY_LEN);
1419 static int __insert_serviceapplication_share_allowed_info(manifest_x *mfx)
1421 serviceapplication_x *sp = mfx->serviceapplication;
1422 datashare_x *ds = NULL;
1423 define_x *df = NULL;
1424 allowed_x *al = NULL;
1426 char query[MAX_QUERY_LEN] = {'\0'};
1438 snprintf(query, MAX_QUERY_LEN,
1439 "insert into package_app_share_allowed(app_id, data_share_path, data_share_allowed) " \
1440 "values('%s', '%s', '%s')",\
1441 sp->appid, df->path, al->text);
1442 ret = __exec_query(query);
1444 DBG("Package App Share Allowed DB Insert Failed\n");
1447 memset(query, '\0', MAX_QUERY_LEN);
1459 static int __insert_manifest_info_in_db(manifest_x *mfx)
1461 label_x *lbl = mfx->label;
1462 license_x *lcn = mfx->license;
1463 icon_x *icn = mfx->icon;
1464 description_x *dcn = mfx->description;
1465 author_x *ath = mfx->author;
1466 uiapplication_x *up = mfx->uiapplication;
1467 uiapplication_x *up_icn = mfx->uiapplication;
1468 uiapplication_x *up_image = mfx->uiapplication;
1469 serviceapplication_x *sp = mfx->serviceapplication;
1470 privileges_x *pvs = NULL;
1471 privilege_x *pv = NULL;
1472 char query[MAX_QUERY_LEN] = { '\0' };
1473 char root[MAX_QUERY_LEN] = { '\0' };
1477 const char *auth_name = NULL;
1478 const char *auth_email = NULL;
1479 const char *auth_href = NULL;
1482 auth_name = ath->text;
1484 auth_email = ath->email;
1486 auth_href = ath->href;
1489 /*Insert in the package_info DB*/
1491 type = strdup(mfx->type);
1493 type = strdup("rpm");
1494 /*Insert in the package_info DB*/
1496 path = strdup(mfx->root_path);
1498 if (strcmp(type,"rpm")==0)
1499 snprintf(root, MAX_QUERY_LEN - 1, "/usr/apps/%s", mfx->package);
1501 snprintf(root, MAX_QUERY_LEN - 1, "/opt/usr/apps/%s", mfx->package);
1503 path = strdup(root);
1505 snprintf(query, MAX_QUERY_LEN,
1506 "insert into package_info(package, package_type, package_version, install_location, package_size, " \
1507 "package_removable, package_preload, package_readonly, package_update, package_appsetting, package_nodisplay, " \
1508 "author_name, author_email, author_href, installed_time, installed_storage, storeclient_id, mainapp_id, package_url, root_path, csc_path) " \
1509 "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
1510 mfx->package, type, mfx->version, mfx->installlocation, mfx->package_size, mfx->removable, mfx->preload,
1511 mfx->readonly, mfx->update, mfx->appsetting, mfx->nodisplay_setting,
1512 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);
1513 ret = __exec_query(query);
1515 DBG("Package Info DB Insert Failed\n");
1535 /*Insert in the package_privilege_info DB*/
1536 pvs = mfx->privileges;
1537 while (pvs != NULL) {
1538 pv = pvs->privilege;
1539 while (pv != NULL) {
1540 memset(query, '\0', MAX_QUERY_LEN);
1541 snprintf(query, MAX_QUERY_LEN,
1542 "insert into package_privilege_info(package, privilege) " \
1543 "values('%s','%s')",\
1544 mfx->package, pv->text);
1545 ret = __exec_query(query);
1547 DBG("Package Privilege Info DB Insert Failed\n");
1555 ret = __insert_ui_mainapp_info(mfx);
1559 /*Insert the package locale and app locale info */
1560 pkglocale = __create_locale_list(pkglocale, lbl, lcn, icn, dcn, ath);
1561 g_list_foreach(pkglocale, __trimfunc1, NULL);
1566 applocale = __create_locale_list(applocale, up->label, NULL, up->icon, NULL, NULL);
1571 applocale = __create_locale_list(applocale, sp->label, NULL, sp->icon, NULL, NULL);
1574 g_list_foreach(applocale, __trimfunc2, NULL);
1577 /*Insert the app icon info */
1578 while(up_icn != NULL)
1580 appicon = __create_icon_list(appicon, up_icn->icon);
1581 up_icn = up_icn->next;
1583 g_list_foreach(appicon, __trimfunc3, NULL);
1586 /*Insert the image info */
1587 while(up_image != NULL)
1589 appimage = __create_image_list(appimage, up_image->image);
1590 up_image = up_image->next;
1592 g_list_foreach(appimage, __trimfunc4, NULL);
1595 /*g_list_foreach(pkglocale, __printfunc, NULL);*/
1597 /*g_list_foreach(applocale, __printfunc, NULL);*/
1599 /*package locale info*/
1600 g_list_foreach(pkglocale, __insert_pkglocale_info, (gpointer)mfx);
1601 /*native app locale info*/
1602 up = mfx->uiapplication;
1605 g_list_foreach(applocale, __insert_uiapplication_locale_info, (gpointer)up);
1608 /*agent app locale info*/
1609 sp = mfx->serviceapplication;
1612 g_list_foreach(applocale, __insert_serviceapplication_locale_info, (gpointer)sp);
1616 /*app icon locale info*/
1617 up_icn = mfx->uiapplication;
1618 while(up_icn != NULL)
1620 g_list_foreach(appicon, __insert_uiapplication_icon_section_info, (gpointer)up_icn);
1621 up_icn = up_icn->next;
1625 up_image = mfx->uiapplication;
1626 while(up_image != NULL)
1628 g_list_foreach(appimage, __insert_uiapplication_image_info, (gpointer)up_image);
1629 up_image = up_image->next;
1632 g_list_free(pkglocale);
1634 g_list_free(applocale);
1636 g_list_free(appicon);
1638 g_list_free(appimage);
1642 /*Insert in the package_app_info DB*/
1643 ret = __insert_uiapplication_info(mfx);
1646 ret = __insert_serviceapplication_info(mfx);
1650 /*Insert in the package_app_app_control DB*/
1651 ret = __insert_uiapplication_appcontrol_info(mfx);
1654 ret = __insert_serviceapplication_appcontrol_info(mfx);
1658 /*Insert in the package_app_app_category DB*/
1659 ret = __insert_uiapplication_appcategory_info(mfx);
1662 ret = __insert_serviceapplication_appcategory_info(mfx);
1666 /*Insert in the package_app_app_metadata DB*/
1667 ret = __insert_uiapplication_appmetadata_info(mfx);
1670 ret = __insert_serviceapplication_appmetadata_info(mfx);
1674 /*Insert in the package_app_app_permission DB*/
1675 ret = __insert_uiapplication_apppermission_info(mfx);
1678 ret = __insert_serviceapplication_apppermission_info(mfx);
1682 /*Insert in the package_app_app_svc DB*/
1683 ret = __insert_uiapplication_appsvc_info(mfx);
1686 ret = __insert_serviceapplication_appsvc_info(mfx);
1690 /*Insert in the package_app_share_allowed DB*/
1691 ret = __insert_uiapplication_share_allowed_info(mfx);
1694 ret = __insert_serviceapplication_share_allowed_info(mfx);
1698 /*Insert in the package_app_share_request DB*/
1699 ret = __insert_uiapplication_share_request_info(mfx);
1702 ret = __insert_serviceapplication_share_request_info(mfx);
1710 static int __delete_appinfo_from_db(char *db_table, const char *appid)
1712 char query[MAX_QUERY_LEN] = { '\0' };
1714 memset(query, '\0', MAX_QUERY_LEN);
1715 snprintf(query, MAX_QUERY_LEN,
1716 "delete from %s where app_id='%s'", db_table, appid);
1717 ret = __exec_query(query);
1719 DBG("DB Deletion from table (%s) Failed\n", db_table);
1725 static int __delete_manifest_info_from_db(manifest_x *mfx)
1727 char query[MAX_QUERY_LEN] = { '\0' };
1729 uiapplication_x *up = mfx->uiapplication;
1730 serviceapplication_x *sp = mfx->serviceapplication;
1731 /*Delete from cert table*/
1732 ret = pkgmgrinfo_delete_certinfo(mfx->package);
1734 DBG("Cert Info DB Delete Failed\n");
1738 /*Delete from Package Info DB*/
1739 snprintf(query, MAX_QUERY_LEN,
1740 "delete from package_info where package='%s'", mfx->package);
1741 ret = __exec_query(query);
1743 DBG("Package Info DB Delete Failed\n");
1746 memset(query, '\0', MAX_QUERY_LEN);
1748 /*Delete from Package Localized Info*/
1749 snprintf(query, MAX_QUERY_LEN,
1750 "delete from package_localized_info where package='%s'", mfx->package);
1751 ret = __exec_query(query);
1753 DBG("Package Localized Info DB Delete Failed\n");
1757 /*Delete from Package Privilege Info*/
1758 snprintf(query, MAX_QUERY_LEN,
1759 "delete from package_privilege_info where package='%s'", mfx->package);
1760 ret = __exec_query(query);
1762 DBG("Package Privilege Info DB Delete Failed\n");
1766 while (up != NULL) {
1767 ret = __delete_appinfo_from_db("package_app_info", up->appid);
1770 ret = __delete_appinfo_from_db("package_app_localized_info", up->appid);
1773 ret = __delete_appinfo_from_db("package_app_icon_section_info", up->appid);
1776 ret = __delete_appinfo_from_db("package_app_image_info", up->appid);
1779 ret = __delete_appinfo_from_db("package_app_app_svc", up->appid);
1782 ret = __delete_appinfo_from_db("package_app_app_control", up->appid);
1785 ret = __delete_appinfo_from_db("package_app_app_category", up->appid);
1788 ret = __delete_appinfo_from_db("package_app_app_metadata", up->appid);
1791 ret = __delete_appinfo_from_db("package_app_app_permission", up->appid);
1794 ret = __delete_appinfo_from_db("package_app_share_allowed", up->appid);
1797 ret = __delete_appinfo_from_db("package_app_share_request", up->appid);
1803 while (sp != NULL) {
1804 ret = __delete_appinfo_from_db("package_app_info", sp->appid);
1807 ret = __delete_appinfo_from_db("package_app_localized_info", sp->appid);
1810 ret = __delete_appinfo_from_db("package_app_icon_section_info", sp->appid);
1813 ret = __delete_appinfo_from_db("package_app_image_info", sp->appid);
1816 ret = __delete_appinfo_from_db("package_app_app_svc", sp->appid);
1819 ret = __delete_appinfo_from_db("package_app_app_control", sp->appid);
1822 ret = __delete_appinfo_from_db("package_app_app_category", sp->appid);
1825 ret = __delete_appinfo_from_db("package_app_app_metadata", sp->appid);
1828 ret = __delete_appinfo_from_db("package_app_app_permission", sp->appid);
1831 ret = __delete_appinfo_from_db("package_app_share_allowed", sp->appid);
1834 ret = __delete_appinfo_from_db("package_app_share_request", sp->appid);
1842 static int __update_preload_condition_in_db()
1845 char query[MAX_QUERY_LEN] = {'\0'};
1847 snprintf(query, MAX_QUERY_LEN, "update package_info set package_preload='true'");
1849 ret = __exec_query(query);
1851 DBG("Package preload_condition update failed\n");
1856 int pkgmgr_parser_initialize_db()
1860 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_INFO);
1862 DBG("package info DB initialization failed\n");
1865 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO);
1867 DBG("package localized info DB initialization failed\n");
1870 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_PRIVILEGE_INFO);
1872 DBG("package app app privilege DB initialization failed\n");
1875 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_INFO);
1877 DBG("package app info DB initialization failed\n");
1880 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO);
1882 DBG("package app localized info DB initialization failed\n");
1885 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_ICON_SECTION_INFO);
1887 DBG("package app icon localized info DB initialization failed\n");
1890 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_IMAGE_INFO);
1892 DBG("package app image info DB initialization failed\n");
1895 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_CONTROL);
1897 DBG("package app app control DB initialization failed\n");
1900 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_CATEGORY);
1902 DBG("package app app category DB initialization failed\n");
1905 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_METADATA);
1907 DBG("package app app category DB initialization failed\n");
1910 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_PERMISSION);
1912 DBG("package app app permission DB initialization failed\n");
1915 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC);
1917 DBG("package app app svc DB initialization failed\n");
1920 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED);
1922 DBG("package app share allowed DB initialization failed\n");
1925 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST);
1927 DBG("package app share request DB initialization failed\n");
1931 ret = __initialize_db(pkgmgr_cert_db, QUERY_CREATE_TABLE_PACKAGE_CERT_INFO);
1933 DBG("package cert info DB initialization failed\n");
1936 ret = __initialize_db(pkgmgr_cert_db, QUERY_CREATE_TABLE_PACKAGE_CERT_INDEX_INFO);
1938 DBG("package cert index info DB initialization failed\n");
1944 int pkgmgr_parser_check_and_create_db()
1948 ret = __pkgmgr_parser_create_db(&pkgmgr_parser_db, PKGMGR_PARSER_DB_FILE);
1950 DBG("Manifest DB creation Failed\n");
1954 ret = __pkgmgr_parser_create_db(&pkgmgr_cert_db, PKGMGR_CERT_DB_FILE);
1956 DBG("Cert DB creation Failed\n");
1962 int pkgmgr_parser_close_db()
1964 sqlite3_close(pkgmgr_parser_db);
1965 sqlite3_close(pkgmgr_cert_db);
1968 API int pkgmgr_parser_insert_manifest_info_in_db(manifest_x *mfx)
1971 DBG("manifest pointer is NULL\n");
1975 ret = pkgmgr_parser_check_and_create_db();
1977 DBG("Failed to open DB\n");
1980 ret = pkgmgr_parser_initialize_db();
1983 /*Begin transaction*/
1984 ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
1985 if (ret != SQLITE_OK) {
1986 DBG("Failed to begin transaction\n");
1990 DBG("Transaction Begin\n");
1991 ret = __insert_manifest_info_in_db(mfx);
1993 DBG("Insert into DB failed. Rollback now\n");
1994 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
1997 /*Commit transaction*/
1998 ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
1999 if (ret != SQLITE_OK) {
2000 DBG("Failed to commit transaction. Rollback now\n");
2001 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2005 DBG("Transaction Commit and End\n");
2007 pkgmgr_parser_close_db();
2011 API int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx)
2014 DBG("manifest pointer is NULL\n");
2018 ret = pkgmgr_parser_check_and_create_db();
2020 DBG("Failed to open DB\n");
2023 ret = pkgmgr_parser_initialize_db();
2026 /*Preserve guest mode visibility*/
2027 __preserve_guestmode_visibility_value( mfx);
2028 /*Begin transaction*/
2029 ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
2030 if (ret != SQLITE_OK) {
2031 DBG("Failed to begin transaction\n");
2035 DBG("Transaction Begin\n");
2036 ret = __delete_manifest_info_from_db(mfx);
2038 DBG("Delete from DB failed. Rollback now\n");
2039 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2042 ret = __insert_manifest_info_in_db(mfx);
2044 DBG("Insert into DB failed. Rollback now\n");
2045 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2049 /*Commit transaction*/
2050 ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
2051 if (ret != SQLITE_OK) {
2052 DBG("Failed to commit transaction. Rollback now\n");
2053 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2057 DBG("Transaction Commit and End\n");
2059 pkgmgr_parser_close_db();
2063 API int pkgmgr_parser_delete_manifest_info_from_db(manifest_x *mfx)
2066 DBG("manifest pointer is NULL\n");
2070 ret = pkgmgr_parser_check_and_create_db();
2072 DBG("Failed to open DB\n");
2075 /*Begin transaction*/
2076 ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
2077 if (ret != SQLITE_OK) {
2078 DBG("Failed to begin transaction\n");
2082 DBG("Transaction Begin\n");
2083 ret = __delete_manifest_info_from_db(mfx);
2085 DBG("Delete from DB failed. Rollback now\n");
2086 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2089 /*Commit transaction*/
2090 ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
2091 if (ret != SQLITE_OK) {
2092 DBG("Failed to commit transaction, Rollback now\n");
2093 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2097 DBG("Transaction Commit and End\n");
2099 pkgmgr_parser_close_db();
2103 API int pkgmgr_parser_update_preload_info_in_db()
2106 ret = pkgmgr_parser_check_and_create_db();
2108 DBG("Failed to open DB\n");
2111 /*Begin transaction*/
2112 ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
2113 if (ret != SQLITE_OK) {
2114 DBG("Failed to begin transaction\n");
2118 DBG("Transaction Begin\n");
2119 ret = __update_preload_condition_in_db();
2121 DBG("__update_preload_condition_in_db failed. Rollback now\n");
2122 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2125 /*Commit transaction*/
2126 ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
2127 if (ret != SQLITE_OK) {
2128 DBG("Failed to commit transaction, Rollback now\n");
2129 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2133 DBG("Transaction Commit and End\n");
2135 pkgmgr_parser_close_db();