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 "author_name text, " \
58 "author_email text, " \
60 "installed_time text," \
61 "installed_storage text," \
62 "storeclient_id text," \
67 #define QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO "create table if not exists package_localized_info " \
68 "(package text not null, " \
69 "package_locale text DEFAULT 'No Locale', " \
70 "package_label text, " \
71 "package_icon text, " \
72 "package_description text, " \
73 "package_license text, " \
75 "PRIMARY KEY(package, package_locale), " \
76 "FOREIGN KEY(package) " \
77 "REFERENCES package_info(package) " \
80 #define QUERY_CREATE_TABLE_PACKAGE_PRIVILEGE_INFO "create table if not exists package_privilege_info " \
81 "(package text not null, " \
82 "privilege text not null, " \
83 "PRIMARY KEY(package, privilege) " \
84 "FOREIGN KEY(package) " \
85 "REFERENCES package_info(package) " \
88 #define QUERY_CREATE_TABLE_PACKAGE_APP_INFO "create table if not exists package_app_info " \
89 "(app_id text primary key not null, " \
90 "app_component text, " \
92 "app_nodisplay text DEFAULT 'false', " \
94 "app_onboot text DEFAULT 'false', " \
95 "app_multiple text DEFAULT 'false', " \
96 "app_autorestart text DEFAULT 'false', " \
97 "app_taskmanage text DEFAULT 'false', " \
98 "app_enabled text DEFAULT 'true', " \
99 "app_hwacceleration text DEFAULT 'use-system-setting', " \
100 "app_mainapp text, " \
101 "app_recentimage text, " \
102 "app_indicatordisplay text DEFAULT 'true', " \
103 "app_portraitimg text, " \
104 "app_landscapeimg text, " \
105 "app_guestmodevisibility text DEFAULT 'true', " \
106 "package text not null, " \
107 "FOREIGN KEY(package) " \
108 "REFERENCES package_info(package) " \
111 #define QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO "create table if not exists package_app_localized_info " \
112 "(app_id text not null, " \
113 "app_locale text DEFAULT 'No Locale', " \
116 "PRIMARY KEY(app_id,app_locale) " \
117 "FOREIGN KEY(app_id) " \
118 "REFERENCES package_app_info(app_id) " \
121 #define QUERY_CREATE_TABLE_PACKAGE_APP_ICON_SECTION_INFO "create table if not exists package_app_icon_section_info " \
122 "(app_id text not null, " \
124 "app_icon_section text, " \
125 "app_icon_resolution text, " \
126 "PRIMARY KEY(app_id,app_icon_section,app_icon_resolution) " \
127 "FOREIGN KEY(app_id) " \
128 "REFERENCES package_app_info(app_id) " \
131 #define QUERY_CREATE_TABLE_PACKAGE_APP_IMAGE_INFO "create table if not exists package_app_image_info " \
132 "(app_id text not null, " \
133 "app_locale text DEFAULT 'No Locale', " \
134 "app_image_section text, " \
136 "PRIMARY KEY(app_id,app_image_section) " \
137 "FOREIGN KEY(app_id) " \
138 "REFERENCES package_app_info(app_id) " \
141 #define QUERY_CREATE_TABLE_PACKAGE_APP_APP_CONTROL "create table if not exists package_app_app_control " \
142 "(app_id text not null, " \
143 "operation text not null, " \
144 "uri_scheme text, " \
146 "subapp_name text, " \
147 "PRIMARY KEY(app_id,operation,uri_scheme,mime_type,subapp_name) " \
148 "FOREIGN KEY(app_id) " \
149 "REFERENCES package_app_info(app_id) " \
152 #define QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC "create table if not exists package_app_app_svc " \
153 "(app_id text not null, " \
154 "operation text not null, " \
155 "uri_scheme text, " \
157 "subapp_name text, " \
158 "PRIMARY KEY(app_id,operation,uri_scheme,mime_type,subapp_name) " \
159 "FOREIGN KEY(app_id) " \
160 "REFERENCES package_app_info(app_id) " \
163 #define QUERY_CREATE_TABLE_PACKAGE_APP_APP_CATEGORY "create table if not exists package_app_app_category " \
164 "(app_id text not null, " \
165 "category text not null, " \
166 "PRIMARY KEY(app_id,category) " \
167 "FOREIGN KEY(app_id) " \
168 "REFERENCES package_app_info(app_id) " \
171 #define QUERY_CREATE_TABLE_PACKAGE_APP_APP_METADATA "create table if not exists package_app_app_metadata " \
172 "(app_id text not null, " \
173 "md_key text not null, " \
174 "md_value text not null, " \
175 "PRIMARY KEY(app_id, md_key, md_value) " \
176 "FOREIGN KEY(app_id) " \
177 "REFERENCES package_app_info(app_id) " \
180 #define QUERY_CREATE_TABLE_PACKAGE_APP_APP_PERMISSION "create table if not exists package_app_app_permission " \
181 "(app_id text not null, " \
182 "pm_type text not null, " \
183 "pm_value text not null, " \
184 "PRIMARY KEY(app_id) " \
185 "FOREIGN KEY(app_id) " \
186 "REFERENCES package_app_info(app_id) " \
189 #define QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED "create table if not exists package_app_share_allowed " \
190 "(app_id text not null, " \
191 "data_share_path text not null, " \
192 "data_share_allowed text not null, " \
193 "PRIMARY KEY(app_id,data_share_path,data_share_allowed) " \
194 "FOREIGN KEY(app_id) " \
195 "REFERENCES package_app_info(app_id) " \
198 #define QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST "create table if not exists package_app_share_request " \
199 "(app_id text not null, " \
200 "data_share_request text not null, " \
201 "PRIMARY KEY(app_id,data_share_request) " \
202 "FOREIGN KEY(app_id) " \
203 "REFERENCES package_app_info(app_id) " \
206 #define QUERY_CREATE_TABLE_PACKAGE_CERT_INDEX_INFO "create table if not exists package_cert_index_info " \
207 "(cert_info text not null, " \
208 "cert_id integer, " \
209 "cert_ref_count integer, " \
210 "PRIMARY KEY(cert_id)) "
212 #define QUERY_CREATE_TABLE_PACKAGE_CERT_INFO "create table if not exists package_cert_info " \
213 "(package text not null, " \
214 "author_root_cert integer, " \
215 "author_im_cert integer, " \
216 "author_signer_cert integer, " \
217 "dist_root_cert integer, " \
218 "dist_im_cert integer, " \
219 "dist_signer_cert integer, " \
220 "dist2_root_cert integer, " \
221 "dist2_im_cert integer, " \
222 "dist2_signer_cert integer, " \
223 "PRIMARY KEY(package)) "
225 static int __insert_uiapplication_info(manifest_x *mfx);
226 static int __insert_serviceapplication_info(manifest_x *mfx);
227 static int __insert_uiapplication_appsvc_info(manifest_x *mfx);
228 static int __insert_serviceapplication_appsvc_info(manifest_x *mfx);
229 static int __insert_uiapplication_appcategory_info(manifest_x *mfx);
230 static int __insert_serviceapplication_appcategory_info(manifest_x *mfx);
231 static int __insert_uiapplication_appcontrol_info(manifest_x *mfx);
232 static int __insert_serviceapplication_appmetadata_info(manifest_x *mfx);
233 static int __insert_uiapplication_appmetadata_info(manifest_x *mfx);
234 static int __insert_serviceapplication_appcontrol_info(manifest_x *mfx);
235 static int __insert_uiapplication_share_allowed_info(manifest_x *mfx);
236 static int __insert_serviceapplication_share_allowed_info(manifest_x *mfx);
237 static int __insert_uiapplication_share_request_info(manifest_x *mfx);
238 static int __insert_serviceapplication_share_request_info(manifest_x *mfx);
239 static void __insert_serviceapplication_locale_info(gpointer data, gpointer userdata);
240 static void __insert_uiapplication_locale_info(gpointer data, gpointer userdata);
241 static void __insert_pkglocale_info(gpointer data, gpointer userdata);
242 static int __insert_manifest_info_in_db(manifest_x *mfx);
243 static int __delete_manifest_info_from_db(manifest_x *mfx);
244 static int __delete_appinfo_from_db(char *db_table, const char *appid);
245 static int __initialize_db(sqlite3 *db_handle, const char *db_query);
246 static int __exec_query(char *query);
247 static void __extract_data(gpointer data, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath,
248 char **label, char **license, char **icon, char **description, char **author);
249 static gint __comparefunc(gconstpointer a, gconstpointer b, gpointer userdata);
250 static void __trimfunc1(gpointer data, gpointer userdata);
251 static void __trimfunc2(gpointer data, gpointer userdata);
252 static GList *__create_locale_list(GList *locale, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath);
253 static void __preserve_guestmode_visibility_value(manifest_x *mfx);
254 static int __guestmode_visibility_cb(void *data, int ncols, char **coltxt, char **colname);
255 static int __pkgmgr_parser_create_db(sqlite3 **db_handle, const char *db_path);
257 static int __pkgmgr_parser_create_db(sqlite3 **db_handle, const char *db_path)
261 if (access(db_path, F_OK) == 0) {
263 db_util_open(db_path, &handle,
264 DB_UTIL_REGISTER_HOOK_METHOD);
265 if (ret != SQLITE_OK) {
266 DBG("connect db [%s] failed!\n",
273 DBG("%s DB does not exists. Create one!!\n", db_path);
276 db_util_open(db_path, &handle,
277 DB_UTIL_REGISTER_HOOK_METHOD);
279 if (ret != SQLITE_OK) {
280 DBG("connect db [%s] failed!\n", db_path);
287 static int __guestmode_visibility_cb(void *data, int ncols, char **coltxt, char **colname)
289 manifest_x *mfx = (manifest_x *)data;
293 uiapplication_x *uiapp = NULL;
294 for(i = 0; i < ncols; i++)
296 uiapp = mfx->uiapplication;
297 if (strcmp(colname[i], "app_id") == 0) {
299 appid = strdup(coltxt[i]);
300 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0) {
302 status = strdup(coltxt[i]);
306 DBG("app id is NULL\n");
309 /*update guest mode visibility*/
310 for (; uiapp != NULL; uiapp = uiapp->next) {
311 if (strcmp(uiapp->appid, appid) == 0) {
312 free((void *)uiapp->guestmode_visibility);
313 uiapp->guestmode_visibility = strdup(status);
329 static void __preserve_guestmode_visibility_value(manifest_x *mfx)
331 char *error_message = NULL;
332 char query[MAX_QUERY_LEN] = {'\0'};
333 snprintf(query, MAX_QUERY_LEN - 1, "select app_id, app_guestmodevisibility from package_app_info where package='%s'", mfx->package);
335 sqlite3_exec(pkgmgr_parser_db, query,
336 __guestmode_visibility_cb, (void *)mfx, &error_message)) {
337 DBG("Don't execute query = %s error message = %s\n",
338 query, error_message);
339 sqlite3_free(error_message);
344 static int __initialize_db(sqlite3 *db_handle, const char *db_query)
346 char *error_message = NULL;
348 sqlite3_exec(db_handle, db_query,
349 NULL, NULL, &error_message)) {
350 DBG("Don't execute query = %s error message = %s\n",
351 db_query, error_message);
352 sqlite3_free(error_message);
355 sqlite3_free(error_message);
359 static int __exec_query(char *query)
361 char *error_message = NULL;
363 sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &error_message)) {
364 DBG("Don't execute query = %s error message = %s\n", query,
366 sqlite3_free(error_message);
369 sqlite3_free(error_message);
372 static GList *__create_locale_list(GList *locale, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath)
378 locale = g_list_insert_sorted_with_data(locale, (gpointer)lbl->lang, __comparefunc, NULL);
384 locale = g_list_insert_sorted_with_data(locale, (gpointer)lcn->lang, __comparefunc, NULL);
390 locale = g_list_insert_sorted_with_data(locale, (gpointer)icn->lang, __comparefunc, NULL);
396 locale = g_list_insert_sorted_with_data(locale, (gpointer)dcn->lang, __comparefunc, NULL);
402 locale = g_list_insert_sorted_with_data(locale, (gpointer)ath->lang, __comparefunc, NULL);
409 static GList *__create_icon_list(GList *locale, icon_x *icn)
414 locale = g_list_insert_sorted_with_data(locale, (gpointer)icn->section, __comparefunc, NULL);
420 static GList *__create_image_list(GList *locale, image_x *image)
425 locale = g_list_insert_sorted_with_data(locale, (gpointer)image->section, __comparefunc, NULL);
431 static void __printfunc(gpointer data, gpointer userdata)
433 DBG("%s ", (char*)data);
436 static void __trimfunc1(gpointer data, gpointer userdata)
439 if (strcmp((char *)data, prev) == 0) {
440 pkglocale = g_list_remove(pkglocale, data);
448 static void __trimfunc2(gpointer data, gpointer userdata)
451 if (strcmp((char *)data, prev) == 0) {
452 applocale = g_list_remove(applocale, data);
460 static void __trimfunc3(gpointer data, gpointer userdata)
463 if (strcmp((char *)data, prev) == 0) {
464 appicon = g_list_remove(appicon, data);
472 static void __trimfunc4(gpointer data, gpointer userdata)
475 if (strcmp((char *)data, prev) == 0) {
476 appimage = g_list_remove(appimage, data);
484 static gint __comparefunc(gconstpointer a, gconstpointer b, gpointer userdata)
486 if (a == NULL || b == NULL)
488 if (strcmp((char*)a, (char*)b) == 0)
490 if (strcmp((char*)a, (char*)b) < 0)
492 if (strcmp((char*)a, (char*)b) > 0)
497 static void __extract_data(gpointer data, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath,
498 char **label, char **license, char **icon, char **description, char **author)
503 if (strcmp(lbl->lang, (char *)data) == 0) {
504 *label = (char*)lbl->text;
513 if (strcmp(lcn->lang, (char *)data) == 0) {
514 *license = (char*)lcn->text;
523 if (strcmp(icn->lang, (char *)data) == 0) {
524 *icon = (char*)icn->text;
533 if (strcmp(dcn->lang, (char *)data) == 0) {
534 *description = (char*)dcn->text;
543 if (strcmp(ath->lang, (char *)data) == 0) {
544 *author = (char*)ath->text;
553 static void __extract_icon_data(gpointer data, icon_x *icn, char **icon, char **resolution)
558 if (strcmp(icn->section, (char *)data) == 0) {
559 *icon = (char*)icn->text;
560 *resolution = (char*)icn->resolution;
568 static void __extract_image_data(gpointer data, image_x*image, char **lang, char **img)
572 if (image->section) {
573 if (strcmp(image->section, (char *)data) == 0) {
574 *lang = (char*)image->lang;
575 *img = (char*)image->text;
583 static void __insert_pkglocale_info(gpointer data, gpointer userdata)
588 char *description = NULL;
589 char *license = NULL;
591 char query[MAX_QUERY_LEN] = {'\0'};
593 manifest_x *mfx = (manifest_x *)userdata;
594 label_x *lbl = mfx->label;
595 license_x *lcn = mfx->license;
596 icon_x *icn = mfx->icon;
597 description_x *dcn = mfx->description;
598 author_x *ath = mfx->author;
600 __extract_data(data, lbl, lcn, icn, dcn, ath, &label, &license, &icon, &description, &author);
601 if (!label && !description && !icon && !license && !author)
603 snprintf(query, MAX_QUERY_LEN, "insert into package_localized_info(package, package_locale, " \
604 "package_label, package_icon, package_description, package_license, package_author) values " \
605 "('%s', '%s', '%s', '%s', '%s', '%s', '%s')", mfx->package, (char*)data,
606 label, icon, description, license, author);
607 ret = __exec_query(query);
609 DBG("Package Localized Info DB Insert failed\n");
612 static void __insert_uiapplication_locale_info(gpointer data, gpointer userdata)
617 char query[MAX_QUERY_LEN] = {'\0'};
619 uiapplication_x *up = (uiapplication_x*)userdata;
620 label_x *lbl = up->label;
621 icon_x *icn = up->icon;
623 __extract_data(data, lbl, NULL, icn, NULL, NULL, &label, NULL, &icon, NULL, NULL);
626 sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_app_localized_info(app_id, app_locale, " \
627 "app_label, app_icon) values " \
628 "('%q', '%q', '%q', '%q')", up->appid, (char*)data,
630 ret = __exec_query(query);
632 DBG("Package UiApp Localized Info DB Insert failed\n");
636 static void __insert_uiapplication_icon_section_info(gpointer data, gpointer userdata)
640 char *resolution = NULL;
641 char query[MAX_QUERY_LEN] = {'\0'};
643 uiapplication_x *up = (uiapplication_x*)userdata;
644 icon_x *icn = up->icon;
646 __extract_icon_data(data, icn, &icon, &resolution);
647 if (!icon && !resolution)
649 sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_app_icon_section_info(app_id, " \
650 "app_icon, app_icon_section, app_icon_resolution) values " \
651 "('%q', '%q', '%q', '%q')", up->appid,
652 icon, (char*)data, resolution);
654 ret = __exec_query(query);
656 DBG("Package UiApp Localized Info DB Insert failed\n");
660 static void __insert_uiapplication_image_info(gpointer data, gpointer userdata)
665 char query[MAX_QUERY_LEN] = {'\0'};
667 uiapplication_x *up = (uiapplication_x*)userdata;
668 image_x *image = up->image;
670 __extract_image_data(data, image, &lang, &img);
673 sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_app_image_info(app_id, app_locale, " \
674 "app_image_section, app_image) values " \
675 "('%q', '%q', '%q', '%q')", up->appid, lang, (char*)data, img);
677 ret = __exec_query(query);
679 DBG("Package UiApp image Info DB Insert failed\n");
684 static void __insert_serviceapplication_locale_info(gpointer data, gpointer userdata)
689 char query[MAX_QUERY_LEN] = {'\0'};
691 serviceapplication_x *sp = (serviceapplication_x*)userdata;
692 label_x *lbl = sp->label;
693 icon_x *icn = sp->icon;
695 __extract_data(data, lbl, NULL, icn, NULL, NULL, &label, NULL, &icon, NULL, NULL);
698 sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_app_localized_info(app_id, app_locale, " \
699 "app_label, app_icon) values " \
700 "('%q', '%q', '%q', '%q')", sp->appid, (char*)data,
702 ret = __exec_query(query);
704 DBG("Package ServiceApp Localized Info DB Insert failed\n");
707 static int __insert_ui_mainapp_info(manifest_x *mfx)
709 uiapplication_x *up = mfx->uiapplication;
711 char query[MAX_QUERY_LEN] = {'\0'};
714 snprintf(query, MAX_QUERY_LEN,
715 "update package_app_info set app_mainapp='%s' where app_id='%s'", up->mainapp, up->appid);
717 ret = __exec_query(query);
719 DBG("Package UiApp Info DB Insert Failed\n");
722 if (strcasecmp(up->mainapp, "True")==0)
723 mfx->mainapp_id = strdup(up->appid);
726 memset(query, '\0', MAX_QUERY_LEN);
729 if (mfx->mainapp_id == NULL){
730 if (mfx->uiapplication
731 && mfx->uiapplication->appid) {
732 snprintf(query, MAX_QUERY_LEN,
733 "update package_app_info set app_mainapp='true' where app_id='%s'", mfx->uiapplication->appid);
734 } else if (mfx->serviceapplication
735 && mfx->serviceapplication->appid) {
736 snprintf(query, MAX_QUERY_LEN,
737 "update package_app_info set app_mainapp='true' where app_id='%s'", mfx->serviceapplication->appid);
739 DBG("Not valid appid\n");
743 ret = __exec_query(query);
745 DBG("Package UiApp Info DB Insert Failed\n");
748 if (mfx->uiapplication && mfx->uiapplication->appid)
749 mfx->mainapp_id = strdup(mfx->uiapplication->appid);
750 else if (mfx->serviceapplication && mfx->serviceapplication->appid)
751 mfx->mainapp_id = strdup(mfx->serviceapplication->appid);
755 memset(query, '\0', MAX_QUERY_LEN);
756 snprintf(query, MAX_QUERY_LEN,
757 "update package_info set mainapp_id='%s' where package='%s'", mfx->mainapp_id, mfx->package);
758 ret = __exec_query(query);
760 DBG("Package Info DB update Failed\n");
766 /* _PRODUCT_LAUNCHING_ENHANCED_
767 * up->indicatordisplay, up->portraitimg, up->landscapeimg, up->guestmode_appstatus
769 static int __insert_uiapplication_info(manifest_x *mfx)
771 uiapplication_x *up = mfx->uiapplication;
773 char query[MAX_QUERY_LEN] = {'\0'};
776 snprintf(query, MAX_QUERY_LEN,
777 "insert into package_app_info(app_id, app_component, app_exec, app_nodisplay, app_type, app_onboot, " \
778 "app_multiple, app_autorestart, app_taskmanage, app_enabled, app_hwacceleration, app_mainapp , app_recentimage, app_indicatordisplay, app_portraitimg, app_landscapeimg, app_guestmodevisibility, package) " \
779 "values('%s', '%s', '%s', '%s', '%s', '%s','%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
780 up->appid, "uiapp", up->exec, up->nodisplay, up->type, "\0", up->multiple,
781 "\0", up->taskmanage, up->enabled, up->hwacceleration,up->mainapp, up->recentimage, up->indicatordisplay, up->portraitimg, up->landscapeimg, up->guestmode_visibility, mfx->package);
782 ret = __exec_query(query);
784 DBG("Package UiApp Info DB Insert Failed\n");
788 memset(query, '\0', MAX_QUERY_LEN);
793 static int __insert_uiapplication_appcategory_info(manifest_x *mfx)
795 uiapplication_x *up = mfx->uiapplication;
796 category_x *ct = NULL;
798 char query[MAX_QUERY_LEN] = {'\0'};
804 snprintf(query, MAX_QUERY_LEN,
805 "insert into package_app_app_category(app_id, category) " \
806 "values('%s','%s')",\
807 up->appid, ct->name);
808 ret = __exec_query(query);
810 DBG("Package UiApp Category Info DB Insert Failed\n");
814 memset(query, '\0', MAX_QUERY_LEN);
821 static int __insert_uiapplication_appmetadata_info(manifest_x *mfx)
823 uiapplication_x *up = mfx->uiapplication;
824 metadata_x *md = NULL;
826 char query[MAX_QUERY_LEN] = {'\0'};
833 snprintf(query, MAX_QUERY_LEN,
834 "insert into package_app_app_metadata(app_id, md_key, md_value) " \
835 "values('%s','%s', '%s')",\
836 up->appid, md->key, md->value);
837 ret = __exec_query(query);
839 DBG("Package UiApp Metadata Info DB Insert Failed\n");
844 memset(query, '\0', MAX_QUERY_LEN);
851 static int __insert_uiapplication_apppermission_info(manifest_x *mfx)
853 uiapplication_x *up = mfx->uiapplication;
854 permission_x *pm = NULL;
856 char query[MAX_QUERY_LEN] = {'\0'};
862 snprintf(query, MAX_QUERY_LEN,
863 "insert into package_app_app_permission(app_id, pm_type, pm_value) " \
864 "values('%s','%s', '%s')",\
865 up->appid, pm->type, pm->value);
866 ret = __exec_query(query);
868 DBG("Package UiApp permission Info DB Insert Failed\n");
872 memset(query, '\0', MAX_QUERY_LEN);
879 static int __insert_uiapplication_appcontrol_info(manifest_x *mfx)
881 uiapplication_x *up = mfx->uiapplication;
882 appcontrol_x *acontrol = NULL;
883 operation_x *op = NULL;
886 subapp_x *sub = NULL;
888 char query[MAX_QUERY_LEN] = {'\0'};
889 const char *operation = NULL;
890 const char *mime = NULL;
891 const char *uri = NULL;
892 const char *subapp = NULL;
895 acontrol = up->appcontrol;
896 while(acontrol != NULL)
898 op = acontrol->operation;
902 operation = op->name;
909 sub = acontrol->subapp;
919 snprintf(query, MAX_QUERY_LEN,
920 "insert into package_app_app_control(app_id, operation, uri_scheme, mime_type, subapp_name) " \
921 "values('%s', '%s', '%s', '%s', '%s')",\
922 up->appid, operation, uri, mime, subapp);
924 ret = __exec_query(query);
926 DBG("Package UiApp AppSvc DB Insert Failed\n");
929 memset(query, '\0', MAX_QUERY_LEN);
946 acontrol = acontrol->next;
953 static int __insert_uiapplication_appsvc_info(manifest_x *mfx)
955 uiapplication_x *up = mfx->uiapplication;
956 appsvc_x *asvc = NULL;
957 operation_x *op = NULL;
960 subapp_x *sub = NULL;
962 char query[MAX_QUERY_LEN] = {'\0'};
963 const char *operation = NULL;
964 const char *mime = NULL;
965 const char *uri = NULL;
966 const char *subapp = NULL;
972 op = asvc->operation;
976 operation = op->name;
993 snprintf(query, MAX_QUERY_LEN,
994 "insert into package_app_app_svc(app_id, operation, uri_scheme, mime_type, subapp_name) " \
995 "values('%s', '%s', '%s', '%s', '%s')",\
996 up->appid, operation, uri, mime, subapp);
998 ret = __exec_query(query);
1000 DBG("Package UiApp AppSvc DB Insert Failed\n");
1003 memset(query, '\0', MAX_QUERY_LEN);
1007 } while(ui != NULL);
1011 }while(sub != NULL);
1027 static int __insert_uiapplication_share_request_info(manifest_x *mfx)
1029 uiapplication_x *up = mfx->uiapplication;
1030 datashare_x *ds = NULL;
1031 request_x *rq = NULL;
1033 char query[MAX_QUERY_LEN] = {'\0'};
1042 snprintf(query, MAX_QUERY_LEN,
1043 "insert into package_app_share_request(app_id, data_share_request) " \
1044 "values('%s', '%s')",\
1045 up->appid, rq->text);
1046 ret = __exec_query(query);
1048 DBG("Package UiApp Share Request DB Insert Failed\n");
1051 memset(query, '\0', MAX_QUERY_LEN);
1061 static int __insert_uiapplication_share_allowed_info(manifest_x *mfx)
1063 uiapplication_x *up = mfx->uiapplication;
1064 datashare_x *ds = NULL;
1065 define_x *df = NULL;
1066 allowed_x *al = NULL;
1068 char query[MAX_QUERY_LEN] = {'\0'};
1080 snprintf(query, MAX_QUERY_LEN,
1081 "insert into package_app_share_allowed(app_id, data_share_path, data_share_allowed) " \
1082 "values('%s', '%s', '%s')",\
1083 up->appid, df->path, al->text);
1084 ret = __exec_query(query);
1086 DBG("Package UiApp Share Allowed DB Insert Failed\n");
1089 memset(query, '\0', MAX_QUERY_LEN);
1101 static int __insert_serviceapplication_info(manifest_x *mfx)
1103 serviceapplication_x *sp = mfx->serviceapplication;
1105 char query[MAX_QUERY_LEN] = {'\0'};
1108 snprintf(query, MAX_QUERY_LEN,
1109 "insert into package_app_info(app_id, app_component, app_exec, app_type, app_onboot, " \
1110 "app_multiple, app_autorestart, app_enabled, package) " \
1111 "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
1112 sp->appid, "svcapp", sp->exec, sp->type, sp->onboot, "\0",
1113 sp->autorestart, sp->enabled, mfx->package);
1114 ret = __exec_query(query);
1116 DBG("Package ServiceApp Info DB Insert Failed\n");
1120 memset(query, '\0', MAX_QUERY_LEN);
1125 static int __insert_serviceapplication_appcategory_info(manifest_x *mfx)
1127 serviceapplication_x *sp = mfx->serviceapplication;
1128 category_x *ct = NULL;
1130 char query[MAX_QUERY_LEN] = {'\0'};
1136 snprintf(query, MAX_QUERY_LEN,
1137 "insert into package_app_app_category(app_id, category) " \
1138 "values('%s','%s')",\
1139 sp->appid, ct->name);
1140 ret = __exec_query(query);
1142 DBG("Package ServiceApp Category Info DB Insert Failed\n");
1146 memset(query, '\0', MAX_QUERY_LEN);
1153 static int __insert_serviceapplication_appmetadata_info(manifest_x *mfx)
1155 serviceapplication_x *sp = mfx->serviceapplication;
1156 metadata_x *md = NULL;
1158 char query[MAX_QUERY_LEN] = {'\0'};
1165 snprintf(query, MAX_QUERY_LEN,
1166 "insert into package_app_app_metadata(app_id, md_key, md_value) " \
1167 "values('%s','%s', '%s')",\
1168 sp->appid, md->key, md->value);
1169 ret = __exec_query(query);
1171 DBG("Package ServiceApp Metadata Info DB Insert Failed\n");
1176 memset(query, '\0', MAX_QUERY_LEN);
1183 static int __insert_serviceapplication_apppermission_info(manifest_x *mfx)
1185 serviceapplication_x *sp = mfx->serviceapplication;
1186 permission_x *pm = NULL;
1188 char query[MAX_QUERY_LEN] = {'\0'};
1191 pm = sp->permission;
1194 snprintf(query, MAX_QUERY_LEN,
1195 "insert into package_app_app_permission(app_id, pm_type, pm_value) " \
1196 "values('%s','%s', '%s')",\
1197 sp->appid, pm->type, pm->value);
1198 ret = __exec_query(query);
1200 DBG("Package ServiceApp permission Info DB Insert Failed\n");
1204 memset(query, '\0', MAX_QUERY_LEN);
1211 static int __insert_serviceapplication_appcontrol_info(manifest_x *mfx)
1213 serviceapplication_x *sp = mfx->serviceapplication;
1214 appcontrol_x *acontrol = NULL;
1216 char query[MAX_QUERY_LEN] = {'\0'};
1217 operation_x *op = NULL;
1220 subapp_x *sub = NULL;
1221 const char *operation = NULL;
1222 const char *mime = NULL;
1223 const char *uri = NULL;
1224 const char *subapp = NULL;
1227 acontrol = sp->appcontrol;
1228 while(acontrol != NULL)
1230 op = acontrol->operation;
1234 operation = op->name;
1235 mi = acontrol->mime;
1240 sub = acontrol->subapp;
1250 snprintf(query, MAX_QUERY_LEN,
1251 "insert into package_app_app_control(app_id, operation, uri_scheme, mime_type,subapp_name) " \
1252 "values('%s', '%s', '%s', '%s', '%s')",\
1253 sp->appid, operation, uri, mime, subapp);
1254 ret = __exec_query(query);
1256 DBG("Package UiApp AppSvc DB Insert Failed\n");
1259 memset(query, '\0', MAX_QUERY_LEN);
1263 } while(ui != NULL);
1267 }while(sub != NULL);
1276 acontrol = acontrol->next;
1283 static int __insert_serviceapplication_appsvc_info(manifest_x *mfx)
1285 serviceapplication_x *sp = mfx->serviceapplication;
1286 appsvc_x *asvc = NULL;
1288 char query[MAX_QUERY_LEN] = {'\0'};
1289 operation_x *op = NULL;
1292 subapp_x *sub = NULL;
1293 const char *operation = NULL;
1294 const char *mime = NULL;
1295 const char *uri = NULL;
1296 const char *subapp = NULL;
1302 op = asvc->operation;
1306 operation = op->name;
1322 snprintf(query, MAX_QUERY_LEN,
1323 "insert into package_app_app_svc(app_id, operation, uri_scheme, mime_type, subapp_name) " \
1324 "values('%s', '%s', '%s', '%s', '%s')",\
1325 sp->appid, operation, uri, mime, subapp);
1326 ret = __exec_query(query);
1328 DBG("Package UiApp AppSvc DB Insert Failed\n");
1331 memset(query, '\0', MAX_QUERY_LEN);
1335 } while(ui != NULL);
1339 }while(sub != NULL);
1357 static int __insert_serviceapplication_share_request_info(manifest_x *mfx)
1359 serviceapplication_x *sp = mfx->serviceapplication;
1360 datashare_x *ds = NULL;
1361 request_x *rq = NULL;
1363 char query[MAX_QUERY_LEN] = {'\0'};
1372 snprintf(query, MAX_QUERY_LEN,
1373 "insert into package_app_share_request(app_id, data_share_request) " \
1374 "values('%s', '%s')",\
1375 sp->appid, rq->text);
1376 ret = __exec_query(query);
1378 DBG("Package ServiceApp Share Request DB Insert Failed\n");
1381 memset(query, '\0', MAX_QUERY_LEN);
1393 static int __insert_serviceapplication_share_allowed_info(manifest_x *mfx)
1395 serviceapplication_x *sp = mfx->serviceapplication;
1396 datashare_x *ds = NULL;
1397 define_x *df = NULL;
1398 allowed_x *al = NULL;
1400 char query[MAX_QUERY_LEN] = {'\0'};
1412 snprintf(query, MAX_QUERY_LEN,
1413 "insert into package_app_share_allowed(app_id, data_share_path, data_share_allowed) " \
1414 "values('%s', '%s', '%s')",\
1415 sp->appid, df->path, al->text);
1416 ret = __exec_query(query);
1418 DBG("Package App Share Allowed DB Insert Failed\n");
1421 memset(query, '\0', MAX_QUERY_LEN);
1433 static int __insert_manifest_info_in_db(manifest_x *mfx)
1435 label_x *lbl = mfx->label;
1436 license_x *lcn = mfx->license;
1437 icon_x *icn = mfx->icon;
1438 description_x *dcn = mfx->description;
1439 author_x *ath = mfx->author;
1440 uiapplication_x *up = mfx->uiapplication;
1441 uiapplication_x *up_icn = mfx->uiapplication;
1442 uiapplication_x *up_image = mfx->uiapplication;
1443 serviceapplication_x *sp = mfx->serviceapplication;
1444 privileges_x *pvs = NULL;
1445 privilege_x *pv = NULL;
1446 char query[MAX_QUERY_LEN] = { '\0' };
1447 char root[MAX_QUERY_LEN] = { '\0' };
1451 const char *auth_name = NULL;
1452 const char *auth_email = NULL;
1453 const char *auth_href = NULL;
1456 auth_name = ath->text;
1458 auth_email = ath->email;
1460 auth_href = ath->href;
1463 /*Insert in the package_info DB*/
1465 type = strdup(mfx->type);
1467 type = strdup("rpm");
1468 /*Insert in the package_info DB*/
1470 path = strdup(mfx->root_path);
1472 if (strcmp(type,"rpm")==0)
1473 snprintf(root, MAX_QUERY_LEN - 1, "/usr/apps/%s", mfx->package);
1475 snprintf(root, MAX_QUERY_LEN - 1, "/opt/usr/apps/%s", mfx->package);
1477 path = strdup(root);
1479 snprintf(query, MAX_QUERY_LEN,
1480 "insert into package_info(package, package_type, package_version, install_location, package_size, " \
1481 "package_removable, package_preload, package_readonly, package_update, package_appsetting, author_name, author_email, author_href, installed_time, installed_storage, storeclient_id, mainapp_id, package_url, root_path) " \
1482 "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
1483 mfx->package, type, mfx->version, mfx->installlocation, mfx->package_size, mfx->removable, mfx->preload,
1484 mfx->readonly, mfx->update, mfx->appsetting, auth_name, auth_email, auth_href, mfx->installed_time, mfx->installed_storage, mfx->storeclient_id, mfx->mainapp_id, mfx->package_url, path);
1485 ret = __exec_query(query);
1487 DBG("Package Info DB Insert Failed\n");
1507 /*Insert in the package_privilege_info DB*/
1508 pvs = mfx->privileges;
1509 while (pvs != NULL) {
1510 pv = pvs->privilege;
1511 while (pv != NULL) {
1512 memset(query, '\0', MAX_QUERY_LEN);
1513 snprintf(query, MAX_QUERY_LEN,
1514 "insert into package_privilege_info(package, privilege) " \
1515 "values('%s','%s')",\
1516 mfx->package, pv->text);
1517 ret = __exec_query(query);
1519 DBG("Package Privilege Info DB Insert Failed\n");
1527 /*Insert the package locale and app locale info */
1528 pkglocale = __create_locale_list(pkglocale, lbl, lcn, icn, dcn, ath);
1529 g_list_foreach(pkglocale, __trimfunc1, NULL);
1534 applocale = __create_locale_list(applocale, up->label, NULL, up->icon, NULL, NULL);
1539 applocale = __create_locale_list(applocale, sp->label, NULL, sp->icon, NULL, NULL);
1542 g_list_foreach(applocale, __trimfunc2, NULL);
1545 /*Insert the app icon info */
1546 while(up_icn != NULL)
1548 appicon = __create_icon_list(appicon, up_icn->icon);
1549 up_icn = up_icn->next;
1551 g_list_foreach(appicon, __trimfunc3, NULL);
1554 /*Insert the image info */
1555 while(up_image != NULL)
1557 appimage = __create_image_list(appimage, up_image->image);
1558 up_image = up_image->next;
1560 g_list_foreach(appimage, __trimfunc4, NULL);
1563 /*g_list_foreach(pkglocale, __printfunc, NULL);*/
1565 /*g_list_foreach(applocale, __printfunc, NULL);*/
1567 /*package locale info*/
1568 g_list_foreach(pkglocale, __insert_pkglocale_info, (gpointer)mfx);
1569 /*native app locale info*/
1570 up = mfx->uiapplication;
1573 g_list_foreach(applocale, __insert_uiapplication_locale_info, (gpointer)up);
1576 /*agent app locale info*/
1577 sp = mfx->serviceapplication;
1580 g_list_foreach(applocale, __insert_serviceapplication_locale_info, (gpointer)sp);
1584 /*app icon locale info*/
1585 up_icn = mfx->uiapplication;
1586 while(up_icn != NULL)
1588 g_list_foreach(appicon, __insert_uiapplication_icon_section_info, (gpointer)up_icn);
1589 up_icn = up_icn->next;
1593 up_image = mfx->uiapplication;
1594 while(up_image != NULL)
1596 g_list_foreach(appimage, __insert_uiapplication_image_info, (gpointer)up_image);
1597 up_image = up_image->next;
1600 g_list_free(pkglocale);
1602 g_list_free(applocale);
1604 g_list_free(appicon);
1606 g_list_free(appimage);
1610 /*Insert in the package_app_info DB*/
1611 ret = __insert_uiapplication_info(mfx);
1614 ret = __insert_ui_mainapp_info(mfx);
1617 ret = __insert_serviceapplication_info(mfx);
1621 /*Insert in the package_app_app_control DB*/
1622 ret = __insert_uiapplication_appcontrol_info(mfx);
1625 ret = __insert_serviceapplication_appcontrol_info(mfx);
1629 /*Insert in the package_app_app_category DB*/
1630 ret = __insert_uiapplication_appcategory_info(mfx);
1633 ret = __insert_serviceapplication_appcategory_info(mfx);
1637 /*Insert in the package_app_app_metadata DB*/
1638 ret = __insert_uiapplication_appmetadata_info(mfx);
1641 ret = __insert_serviceapplication_appmetadata_info(mfx);
1645 /*Insert in the package_app_app_permission DB*/
1646 ret = __insert_uiapplication_apppermission_info(mfx);
1649 ret = __insert_serviceapplication_apppermission_info(mfx);
1653 /*Insert in the package_app_app_svc DB*/
1654 ret = __insert_uiapplication_appsvc_info(mfx);
1657 ret = __insert_serviceapplication_appsvc_info(mfx);
1661 /*Insert in the package_app_share_allowed DB*/
1662 ret = __insert_uiapplication_share_allowed_info(mfx);
1665 ret = __insert_serviceapplication_share_allowed_info(mfx);
1669 /*Insert in the package_app_share_request DB*/
1670 ret = __insert_uiapplication_share_request_info(mfx);
1673 ret = __insert_serviceapplication_share_request_info(mfx);
1681 static int __delete_appinfo_from_db(char *db_table, const char *appid)
1683 char query[MAX_QUERY_LEN] = { '\0' };
1685 memset(query, '\0', MAX_QUERY_LEN);
1686 snprintf(query, MAX_QUERY_LEN,
1687 "delete from %s where app_id='%s'", db_table, appid);
1688 ret = __exec_query(query);
1690 DBG("DB Deletion from table (%s) Failed\n", db_table);
1696 static int __delete_manifest_info_from_db(manifest_x *mfx)
1698 char query[MAX_QUERY_LEN] = { '\0' };
1700 uiapplication_x *up = mfx->uiapplication;
1701 serviceapplication_x *sp = mfx->serviceapplication;
1702 /*Delete from cert table*/
1703 ret = pkgmgrinfo_delete_certinfo(mfx->package);
1705 DBG("Cert Info DB Delete Failed\n");
1709 /*Delete from Package Info DB*/
1710 snprintf(query, MAX_QUERY_LEN,
1711 "delete from package_info where package='%s'", mfx->package);
1712 ret = __exec_query(query);
1714 DBG("Package Info DB Delete Failed\n");
1717 memset(query, '\0', MAX_QUERY_LEN);
1719 /*Delete from Package Localized Info*/
1720 snprintf(query, MAX_QUERY_LEN,
1721 "delete from package_localized_info where package='%s'", mfx->package);
1722 ret = __exec_query(query);
1724 DBG("Package Localized Info DB Delete Failed\n");
1728 /*Delete from Package Privilege Info*/
1729 snprintf(query, MAX_QUERY_LEN,
1730 "delete from package_privilege_info where package='%s'", mfx->package);
1731 ret = __exec_query(query);
1733 DBG("Package Privilege Info DB Delete Failed\n");
1737 while (up != NULL) {
1738 ret = __delete_appinfo_from_db("package_app_info", up->appid);
1741 ret = __delete_appinfo_from_db("package_app_localized_info", up->appid);
1744 ret = __delete_appinfo_from_db("package_app_icon_section_info", up->appid);
1747 ret = __delete_appinfo_from_db("package_app_image_info", up->appid);
1750 ret = __delete_appinfo_from_db("package_app_app_svc", up->appid);
1753 ret = __delete_appinfo_from_db("package_app_app_control", up->appid);
1756 ret = __delete_appinfo_from_db("package_app_app_category", up->appid);
1759 ret = __delete_appinfo_from_db("package_app_app_metadata", up->appid);
1762 ret = __delete_appinfo_from_db("package_app_app_permission", up->appid);
1765 ret = __delete_appinfo_from_db("package_app_share_allowed", up->appid);
1768 ret = __delete_appinfo_from_db("package_app_share_request", up->appid);
1774 while (sp != NULL) {
1775 ret = __delete_appinfo_from_db("package_app_info", sp->appid);
1778 ret = __delete_appinfo_from_db("package_app_localized_info", sp->appid);
1781 ret = __delete_appinfo_from_db("package_app_icon_section_info", sp->appid);
1784 ret = __delete_appinfo_from_db("package_app_image_info", sp->appid);
1787 ret = __delete_appinfo_from_db("package_app_app_svc", sp->appid);
1790 ret = __delete_appinfo_from_db("package_app_app_control", sp->appid);
1793 ret = __delete_appinfo_from_db("package_app_app_category", sp->appid);
1796 ret = __delete_appinfo_from_db("package_app_app_metadata", sp->appid);
1799 ret = __delete_appinfo_from_db("package_app_app_permission", sp->appid);
1802 ret = __delete_appinfo_from_db("package_app_share_allowed", sp->appid);
1805 ret = __delete_appinfo_from_db("package_app_share_request", sp->appid);
1814 int pkgmgr_parser_initialize_db()
1818 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_INFO);
1820 DBG("package info DB initialization failed\n");
1823 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO);
1825 DBG("package localized info DB initialization failed\n");
1828 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_PRIVILEGE_INFO);
1830 DBG("package app app privilege DB initialization failed\n");
1833 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_INFO);
1835 DBG("package app info DB initialization failed\n");
1838 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO);
1840 DBG("package app localized info DB initialization failed\n");
1843 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_ICON_SECTION_INFO);
1845 DBG("package app icon localized info DB initialization failed\n");
1848 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_IMAGE_INFO);
1850 DBG("package app image info DB initialization failed\n");
1853 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_CONTROL);
1855 DBG("package app app control DB initialization failed\n");
1858 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_CATEGORY);
1860 DBG("package app app category DB initialization failed\n");
1863 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_METADATA);
1865 DBG("package app app category DB initialization failed\n");
1868 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_PERMISSION);
1870 DBG("package app app permission DB initialization failed\n");
1873 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC);
1875 DBG("package app app svc DB initialization failed\n");
1878 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED);
1880 DBG("package app share allowed DB initialization failed\n");
1883 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST);
1885 DBG("package app share request DB initialization failed\n");
1889 ret = __initialize_db(pkgmgr_cert_db, QUERY_CREATE_TABLE_PACKAGE_CERT_INFO);
1891 DBG("package cert info DB initialization failed\n");
1894 ret = __initialize_db(pkgmgr_cert_db, QUERY_CREATE_TABLE_PACKAGE_CERT_INDEX_INFO);
1896 DBG("package cert index info DB initialization failed\n");
1902 int pkgmgr_parser_check_and_create_db()
1906 ret = __pkgmgr_parser_create_db(&pkgmgr_parser_db, PKGMGR_PARSER_DB_FILE);
1908 DBG("Manifest DB creation Failed\n");
1912 ret = __pkgmgr_parser_create_db(&pkgmgr_cert_db, PKGMGR_CERT_DB_FILE);
1914 DBG("Cert DB creation Failed\n");
1920 API int pkgmgr_parser_insert_manifest_info_in_db(manifest_x *mfx)
1923 DBG("manifest pointer is NULL\n");
1927 ret = pkgmgr_parser_check_and_create_db();
1929 DBG("Failed to open DB\n");
1932 ret = pkgmgr_parser_initialize_db();
1935 /*Begin transaction*/
1936 ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
1937 if (ret != SQLITE_OK) {
1938 DBG("Failed to begin transaction\n");
1942 DBG("Transaction Begin\n");
1943 ret = __insert_manifest_info_in_db(mfx);
1945 DBG("Insert into DB failed. Rollback now\n");
1946 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
1949 /*Commit transaction*/
1950 ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
1951 if (ret != SQLITE_OK) {
1952 DBG("Failed to commit transaction. Rollback now\n");
1953 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
1957 DBG("Transaction Commit and End\n");
1959 sqlite3_close(pkgmgr_parser_db);
1960 sqlite3_close(pkgmgr_cert_db);
1964 API int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx)
1967 DBG("manifest pointer is NULL\n");
1971 ret = pkgmgr_parser_check_and_create_db();
1973 DBG("Failed to open DB\n");
1976 ret = pkgmgr_parser_initialize_db();
1979 /*Preserve guest mode visibility*/
1980 __preserve_guestmode_visibility_value( mfx);
1981 /*Begin transaction*/
1982 ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
1983 if (ret != SQLITE_OK) {
1984 DBG("Failed to begin transaction\n");
1988 DBG("Transaction Begin\n");
1989 ret = __delete_manifest_info_from_db(mfx);
1991 DBG("Delete from DB failed. Rollback now\n");
1992 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
1995 ret = __insert_manifest_info_in_db(mfx);
1997 DBG("Insert into DB failed. Rollback now\n");
1998 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2002 /*Commit transaction*/
2003 ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
2004 if (ret != SQLITE_OK) {
2005 DBG("Failed to commit transaction. Rollback now\n");
2006 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2010 DBG("Transaction Commit and End\n");
2012 sqlite3_close(pkgmgr_parser_db);
2013 sqlite3_close(pkgmgr_cert_db);
2017 API int pkgmgr_parser_delete_manifest_info_from_db(manifest_x *mfx)
2020 DBG("manifest pointer is NULL\n");
2024 ret = pkgmgr_parser_check_and_create_db();
2026 DBG("Failed to open DB\n");
2029 /*Begin transaction*/
2030 ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
2031 if (ret != SQLITE_OK) {
2032 DBG("Failed to begin transaction\n");
2036 DBG("Transaction Begin\n");
2037 ret = __delete_manifest_info_from_db(mfx);
2039 DBG("Delete from DB failed. Rollback now\n");
2040 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2043 /*Commit transaction*/
2044 ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
2045 if (ret != SQLITE_OK) {
2046 DBG("Failed to commit transaction, Rollback now\n");
2047 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2051 DBG("Transaction Commit and End\n");
2052 sqlite3_close(pkgmgr_parser_db);
2054 sqlite3_close(pkgmgr_parser_db);
2055 sqlite3_close(pkgmgr_cert_db);