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_parser_internal.h"
32 #include "pkgmgr_parser_db.h"
34 #define PKGMGR_PARSER_DB_FILE "/opt/dbspace/.pkgmgr_parser.db"
35 #define PKGMGR_CERT_DB_FILE "/opt/dbspace/.pkgmgr_cert.db"
36 #define MAX_QUERY_LEN 4096
37 sqlite3 *pkgmgr_parser_db;
38 sqlite3 *pkgmgr_cert_db;
39 GList *pkglocale = NULL;
40 GList *applocale = NULL;
41 GList *appicon = NULL;
44 #define QUERY_CREATE_TABLE_PACKAGE_INFO "create table if not exists package_info " \
45 "(package text primary key not null, " \
46 "package_type text DEFAULT 'rpm', " \
47 "package_version text, " \
48 "install_location text, " \
49 "package_size text, " \
50 "package_removable text DEFAULT 'true', " \
51 "package_preload text DEFAULT 'false', " \
52 "package_readonly text DEFAULT 'false', " \
53 "author_name text, " \
54 "author_email text, " \
56 "installed_time text," \
57 "storeclient_id text," \
61 #define QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO "create table if not exists package_localized_info " \
62 "(package text not null, " \
63 "package_locale text DEFAULT 'No Locale', " \
64 "package_label text, " \
65 "package_icon text, " \
66 "package_description text, " \
67 "package_license text, " \
69 "PRIMARY KEY(package, package_locale), " \
70 "FOREIGN KEY(package) " \
71 "REFERENCES package_info(package) " \
74 #define QUERY_CREATE_TABLE_PACKAGE_APP_INFO "create table if not exists package_app_info " \
75 "(app_id text primary key not null, " \
76 "app_component text, " \
78 "app_nodisplay text DEFAULT 'false', " \
80 "app_onboot text DEFAULT 'false', " \
81 "app_multiple text DEFAULT 'false', " \
82 "app_autorestart text DEFAULT 'false', " \
83 "app_taskmanage text DEFAULT 'false', " \
84 "app_hwacceleration text DEFAULT 'use-system-setting', " \
85 "app_mainapp text, " \
86 "app_recentimage text, " \
87 "package text not null, " \
88 "FOREIGN KEY(package) " \
89 "REFERENCES package_info(package) " \
92 #define QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO "create table if not exists package_app_localized_info " \
93 "(app_id text not null, " \
94 "app_locale text DEFAULT 'No Locale', " \
97 "PRIMARY KEY(app_id,app_locale) " \
98 "FOREIGN KEY(app_id) " \
99 "REFERENCES package_app_info(app_id) " \
102 #define QUERY_CREATE_TABLE_PACKAGE_APP_ICON_LOCALIZED_INFO "create table if not exists package_app_icon_localized_info " \
103 "(app_id text not null, " \
104 "app_locale text DEFAULT 'No Locale', " \
106 "app_icon_section text, " \
107 "app_icon_resolution text, " \
108 "PRIMARY KEY(app_id,app_locale,app_icon_section,app_icon_resolution) " \
109 "FOREIGN KEY(app_id) " \
110 "REFERENCES package_app_info(app_id) " \
113 #define QUERY_CREATE_TABLE_PACKAGE_APP_APP_CONTROL "create table if not exists package_app_app_control " \
114 "(app_id text not null, " \
115 "operation text not null, " \
116 "uri_scheme text, " \
118 "subapp_name text, " \
119 "PRIMARY KEY(app_id,operation,uri_scheme,mime_type,subapp_name) " \
120 "FOREIGN KEY(app_id) " \
121 "REFERENCES package_app_info(app_id) " \
124 #define QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC "create table if not exists package_app_app_svc " \
125 "(app_id text not null, " \
126 "operation text not null, " \
127 "uri_scheme text, " \
129 "subapp_name text, " \
130 "PRIMARY KEY(app_id,operation,uri_scheme,mime_type,subapp_name) " \
131 "FOREIGN KEY(app_id) " \
132 "REFERENCES package_app_info(app_id) " \
135 #define QUERY_CREATE_TABLE_PACKAGE_APP_APP_CATEGORY "create table if not exists package_app_app_category " \
136 "(app_id text not null, " \
137 "category text not null, " \
138 "PRIMARY KEY(app_id,category) " \
139 "FOREIGN KEY(app_id) " \
140 "REFERENCES package_app_info(app_id) " \
143 #define QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED "create table if not exists package_app_share_allowed " \
144 "(app_id text not null, " \
145 "data_share_path text not null, " \
146 "data_share_allowed text not null, " \
147 "PRIMARY KEY(app_id,data_share_path,data_share_allowed) " \
148 "FOREIGN KEY(app_id) " \
149 "REFERENCES package_app_info(app_id) " \
152 #define QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST "create table if not exists package_app_share_request " \
153 "(app_id text not null, " \
154 "data_share_request text not null, " \
155 "PRIMARY KEY(app_id,data_share_request) " \
156 "FOREIGN KEY(app_id) " \
157 "REFERENCES package_app_info(app_id) " \
160 #define QUERY_CREATE_TABLE_PACKAGE_CERT_INFO "create table if not exists package_cert_info " \
161 "(package text not null, " \
162 "author_root_cert text, " \
163 "author_im_cert text, " \
164 "author_signer_cert text, " \
165 "dist_root_cert text, " \
166 "dist_im_cert text, " \
167 "dist_signer_cert text, " \
168 "dist2_root_cert text, " \
169 "dist2_im_cert text, " \
170 "dist2_signer_cert text, " \
171 "PRIMARY KEY(package), " \
172 "FOREIGN KEY(package) " \
173 "REFERENCES package_info(package) " \
176 static int __insert_uiapplication_info(manifest_x *mfx);
177 static int __insert_serviceapplication_info(manifest_x *mfx);
178 static int __insert_uiapplication_appsvc_info(manifest_x *mfx);
179 static int __insert_serviceapplication_appsvc_info(manifest_x *mfx);
180 static int __insert_uiapplication_appcategory_info(manifest_x *mfx);
181 static int __insert_serviceapplication_appcategory_info(manifest_x *mfx);
182 static int __insert_uiapplication_appcontrol_info(manifest_x *mfx);
183 static int __insert_serviceapplication_appcontrol_info(manifest_x *mfx);
184 static int __insert_uiapplication_share_allowed_info(manifest_x *mfx);
185 static int __insert_serviceapplication_share_allowed_info(manifest_x *mfx);
186 static int __insert_uiapplication_share_request_info(manifest_x *mfx);
187 static int __insert_serviceapplication_share_request_info(manifest_x *mfx);
188 static void __insert_serviceapplication_locale_info(gpointer data, gpointer userdata);
189 static void __insert_uiapplication_locale_info(gpointer data, gpointer userdata);
190 static void __insert_pkglocale_info(gpointer data, gpointer userdata);
191 static int __insert_manifest_info_in_db(manifest_x *mfx);
192 static int __update_manifest_info_in_db(manifest_x *mfx);
193 static int __delete_cert_info_from_db(manifest_x *mfx);
194 static int __delete_manifest_info_from_db(manifest_x *mfx);
195 static int __initialize_package_info_db();
196 static int __initialize_package_localized_info_db();
197 static int __initialize_package_app_info_db();
198 static int __initialize_package_cert_info_db();
199 static int __initialize_package_app_localized_info_db();
200 static int __initialize_package_app_icon_localized_info_db();
201 static int __initialize_package_app_app_svc_db();
202 static int __initialize_package_app_app_category_db();
203 static int __initialize_package_app_app_control_db();
204 static int __initialize_package_app_share_allowed_db();
205 static int __initialize_package_app_share_request_db();
206 static int __exec_query(char *query);
207 static void __extract_data(gpointer data, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath,
208 char **label, char **license, char **icon, char **description, char **author);
210 static gint __comparefunc(gconstpointer a, gconstpointer b, gpointer userdata);
211 static void __trimfunc1(gpointer data, gpointer userdata);
212 static void __trimfunc2(gpointer data, gpointer userdata);
213 static GList *__create_locale_list(GList *locale, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath);
215 static int __initialize_package_info_db()
217 char *error_message = NULL;
219 sqlite3_exec(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_INFO,
220 NULL, NULL, &error_message)) {
221 DBG("Don't execute query = %s error message = %s\n",
222 QUERY_CREATE_TABLE_PACKAGE_INFO, error_message);
223 sqlite3_free(error_message);
226 sqlite3_free(error_message);
230 static int __pkgmgr_parser_cert_create_db()
233 if (access(PKGMGR_CERT_DB_FILE, F_OK) == 0) {
235 db_util_open(PKGMGR_CERT_DB_FILE, &pkgmgr_cert_db,
236 DB_UTIL_REGISTER_HOOK_METHOD);
237 if (ret != SQLITE_OK) {
238 DBG("connect db [%s] failed!\n",
239 PKGMGR_CERT_DB_FILE);
244 DBG("Pkgmgr DB does not exists. Create one!!\n");
247 db_util_open(PKGMGR_CERT_DB_FILE, &pkgmgr_cert_db,
248 DB_UTIL_REGISTER_HOOK_METHOD);
250 if (ret != SQLITE_OK) {
251 DBG("connect db [%s] failed!\n", PKGMGR_CERT_DB_FILE);
257 static int __initialize_package_cert_info_db()
259 char *error_message = NULL;
261 ret = __pkgmgr_parser_cert_create_db();
263 DBG("Failed to open DB\n");
268 sqlite3_exec(pkgmgr_cert_db, QUERY_CREATE_TABLE_PACKAGE_CERT_INFO,
269 NULL, NULL, &error_message)) {
270 DBG("Don't execute query = %s error message = %s\n",
271 QUERY_CREATE_TABLE_PACKAGE_CERT_INFO, error_message);
272 sqlite3_free(error_message);
273 sqlite3_close(pkgmgr_cert_db);
276 sqlite3_free(error_message);
277 sqlite3_close(pkgmgr_cert_db);
281 static int __initialize_package_localized_info_db()
283 char *error_message = NULL;
285 sqlite3_exec(pkgmgr_parser_db,
286 QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO, NULL, NULL,
288 DBG("Don't execute query = %s error message = %s\n",
289 QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO,
291 sqlite3_free(error_message);
294 sqlite3_free(error_message);
298 static int __initialize_package_app_info_db()
300 char *error_message = NULL;
302 sqlite3_exec(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_INFO,
303 NULL, NULL, &error_message)) {
304 DBG("Don't execute query = %s error message = %s\n",
305 QUERY_CREATE_TABLE_PACKAGE_APP_INFO, error_message);
306 sqlite3_free(error_message);
309 sqlite3_free(error_message);
313 static int __initialize_package_app_localized_info_db()
315 char *error_message = NULL;
317 sqlite3_exec(pkgmgr_parser_db,
318 QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO, NULL,
319 NULL, &error_message)) {
320 DBG("Don't execute query = %s error message = %s\n",
321 QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO,
323 sqlite3_free(error_message);
326 sqlite3_free(error_message);
330 static int __initialize_package_app_icon_localized_info_db()
332 char *error_message = NULL;
334 sqlite3_exec(pkgmgr_parser_db,
335 QUERY_CREATE_TABLE_PACKAGE_APP_ICON_LOCALIZED_INFO, NULL,
336 NULL, &error_message)) {
337 DBG("Don't execute query = %s error message = %s\n",
338 QUERY_CREATE_TABLE_PACKAGE_APP_ICON_LOCALIZED_INFO,
340 sqlite3_free(error_message);
343 sqlite3_free(error_message);
347 static int __initialize_package_app_app_control_db()
349 char *error_message = NULL;
351 sqlite3_exec(pkgmgr_parser_db,
352 QUERY_CREATE_TABLE_PACKAGE_APP_APP_CONTROL, NULL, NULL,
354 DBG("Don't execute query = %s error message = %s\n",
355 QUERY_CREATE_TABLE_PACKAGE_APP_APP_CONTROL, error_message);
356 sqlite3_free(error_message);
359 sqlite3_free(error_message);
363 static int __initialize_package_app_app_category_db()
365 char *error_message = NULL;
367 sqlite3_exec(pkgmgr_parser_db,
368 QUERY_CREATE_TABLE_PACKAGE_APP_APP_CATEGORY, NULL, NULL,
370 DBG("Don't execute query = %s error message = %s\n",
371 QUERY_CREATE_TABLE_PACKAGE_APP_APP_CATEGORY, error_message);
372 sqlite3_free(error_message);
375 sqlite3_free(error_message);
379 static int __initialize_package_app_app_svc_db()
381 char *error_message = NULL;
383 sqlite3_exec(pkgmgr_parser_db,
384 QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC, NULL, NULL,
386 DBG("Don't execute query = %s error message = %s\n",
387 QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC, error_message);
388 sqlite3_free(error_message);
391 sqlite3_free(error_message);
395 static int __initialize_package_app_share_allowed_db()
397 char *error_message = NULL;
399 sqlite3_exec(pkgmgr_parser_db,
400 QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED, NULL,
401 NULL, &error_message)) {
402 DBG("Don't execute query = %s error message = %s\n",
403 QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED,
405 sqlite3_free(error_message);
408 sqlite3_free(error_message);
412 static int __initialize_package_app_share_request_db()
414 char *error_message = NULL;
416 sqlite3_exec(pkgmgr_parser_db,
417 QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST, NULL,
418 NULL, &error_message)) {
419 DBG("Don't execute query = %s error message = %s\n",
420 QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST,
422 sqlite3_free(error_message);
425 sqlite3_free(error_message);
429 static int __exec_query(char *query)
431 char *error_message = NULL;
433 sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &error_message)) {
434 DBG("Don't execute query = %s error message = %s\n", query,
436 sqlite3_free(error_message);
439 sqlite3_free(error_message);
442 static GList *__create_locale_list(GList *locale, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath)
448 locale = g_list_insert_sorted_with_data(locale, (gpointer)lbl->lang, __comparefunc, NULL);
454 locale = g_list_insert_sorted_with_data(locale, (gpointer)lcn->lang, __comparefunc, NULL);
460 locale = g_list_insert_sorted_with_data(locale, (gpointer)icn->lang, __comparefunc, NULL);
466 locale = g_list_insert_sorted_with_data(locale, (gpointer)dcn->lang, __comparefunc, NULL);
472 locale = g_list_insert_sorted_with_data(locale, (gpointer)ath->lang, __comparefunc, NULL);
479 static GList *__create_icon_list(GList *locale, icon_x *icn)
484 locale = g_list_insert_sorted_with_data(locale, (gpointer)icn->section, __comparefunc, NULL);
490 static void __printfunc(gpointer data, gpointer userdata)
492 DBG("%s ", (char*)data);
495 static void __trimfunc1(gpointer data, gpointer userdata)
498 if (strcmp((char *)data, prev) == 0) {
499 pkglocale = g_list_remove(pkglocale, data);
507 static void __trimfunc2(gpointer data, gpointer userdata)
510 if (strcmp((char *)data, prev) == 0) {
511 applocale = g_list_remove(applocale, data);
519 static void __trimfunc3(gpointer data, gpointer userdata)
522 if (strcmp((char *)data, prev) == 0) {
523 appicon = g_list_remove(appicon, data);
531 static gint __comparefunc(gconstpointer a, gconstpointer b, gpointer userdata)
533 if (a == NULL || b == NULL)
535 if (strcmp((char*)a, (char*)b) == 0)
537 if (strcmp((char*)a, (char*)b) < 0)
539 if (strcmp((char*)a, (char*)b) > 0)
543 static void __extract_data(gpointer data, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath,
544 char **label, char **license, char **icon, char **description, char **author)
549 if (strcmp(lbl->lang, (char *)data) == 0) {
550 *label = (char*)lbl->text;
559 if (strcmp(lcn->lang, (char *)data) == 0) {
560 *license = (char*)lcn->text;
569 if (strcmp(icn->lang, (char *)data) == 0) {
570 *icon = (char*)icn->text;
579 if (strcmp(dcn->lang, (char *)data) == 0) {
580 *description = (char*)dcn->text;
589 if (strcmp(ath->lang, (char *)data) == 0) {
590 *author = (char*)ath->text;
599 static void __extract_icon_data(gpointer data, icon_x *icn, char **lang, char **icon, char **resolution)
604 if (strcmp(icn->section, (char *)data) == 0) {
605 *lang = (char*)icn->lang;
606 *icon = (char*)icn->text;
607 *resolution = (char*)icn->resolution;
615 static void __insert_pkglocale_info(gpointer data, gpointer userdata)
620 char *description = NULL;
621 char *license = NULL;
623 char query[MAX_QUERY_LEN] = {'\0'};
625 manifest_x *mfx = (manifest_x *)userdata;
626 label_x *lbl = mfx->label;
627 license_x *lcn = mfx->license;
628 icon_x *icn = mfx->icon;
629 description_x *dcn = mfx->description;
630 author_x *ath = mfx->author;
632 __extract_data(data, lbl, lcn, icn, dcn, ath, &label, &license, &icon, &description, &author);
633 if (!label && !description && !icon && !license && !author)
635 snprintf(query, MAX_QUERY_LEN, "insert into package_localized_info(package, package_locale, " \
636 "package_label, package_icon, package_description, package_license, package_author) values " \
637 "('%s', '%s', '%s', '%s', '%s', '%s', '%s')", mfx->package, (char*)data,
638 label, icon, description, license, author);
639 ret = __exec_query(query);
641 DBG("Package Localized Info DB Insert failed\n");
644 static void __insert_uiapplication_locale_info(gpointer data, gpointer userdata)
649 char query[MAX_QUERY_LEN] = {'\0'};
651 uiapplication_x *up = (uiapplication_x*)userdata;
652 label_x *lbl = up->label;
653 icon_x *icn = up->icon;
655 __extract_data(data, lbl, NULL, icn, NULL, NULL, &label, NULL, &icon, NULL, NULL);
658 sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_app_localized_info(app_id, app_locale, " \
659 "app_label, app_icon) values " \
660 "('%q', '%q', '%q', '%q')", up->appid, (char*)data,
662 ret = __exec_query(query);
664 DBG("Package UiApp Localized Info DB Insert failed\n");
668 static void __insert_uiapplication_icon_locale_info(gpointer data, gpointer userdata)
673 char *resolution = NULL;
674 char query[MAX_QUERY_LEN] = {'\0'};
676 uiapplication_x *up = (uiapplication_x*)userdata;
677 icon_x *icn = up->icon;
679 __extract_icon_data(data, icn, &lang, &icon, &resolution);
680 if (!lang && !icon && !resolution)
682 sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_app_icon_localized_info(app_id, app_locale, " \
683 "app_icon, app_icon_section, app_icon_resolution) values " \
684 "('%q', '%q', '%q', '%q', '%q')", up->appid, lang,
685 icon, (char*)data, resolution);
687 ret = __exec_query(query);
689 DBG("Package UiApp Localized Info DB Insert failed\n");
693 static void __insert_serviceapplication_locale_info(gpointer data, gpointer userdata)
698 char query[MAX_QUERY_LEN] = {'\0'};
700 serviceapplication_x *sp = (serviceapplication_x*)userdata;
701 label_x *lbl = sp->label;
702 icon_x *icn = sp->icon;
704 __extract_data(data, lbl, NULL, icn, NULL, NULL, &label, NULL, &icon, NULL, NULL);
707 sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_app_localized_info(app_id, app_locale, " \
708 "app_label, app_icon) values " \
709 "('%q', '%q', '%q', '%q')", sp->appid, (char*)data,
711 ret = __exec_query(query);
713 DBG("Package ServiceApp Localized Info DB Insert failed\n");
716 static int __insert_ui_mainapp_info(manifest_x *mfx)
718 uiapplication_x *up = mfx->uiapplication;
720 char query[MAX_QUERY_LEN] = {'\0'};
723 snprintf(query, MAX_QUERY_LEN,
724 "update package_app_info set app_mainapp='%s' where app_id='%s'", up->mainapp, up->appid);
726 ret = __exec_query(query);
728 DBG("Package UiApp Info DB Insert Failed\n");
731 if (strcasecmp(up->mainapp, "True")==0)
732 mfx->mainapp_id = strdup(up->appid);
735 memset(query, '\0', MAX_QUERY_LEN);
738 if (mfx->mainapp_id == NULL){
739 snprintf(query, MAX_QUERY_LEN,
740 "update package_app_info set app_mainapp='true' where app_id='%s'", mfx->uiapplication->appid);
741 ret = __exec_query(query);
743 DBG("Package UiApp Info DB Insert Failed\n");
746 mfx->mainapp_id = strdup(mfx->uiapplication->appid);
749 memset(query, '\0', MAX_QUERY_LEN);
750 snprintf(query, MAX_QUERY_LEN,
751 "update package_info set mainapp_id='%s' where package='%s'", mfx->mainapp_id, mfx->package);
752 ret = __exec_query(query);
754 DBG("Package Info DB update Failed\n");
761 static int __insert_uiapplication_info(manifest_x *mfx)
763 uiapplication_x *up = mfx->uiapplication;
765 char query[MAX_QUERY_LEN] = {'\0'};
768 snprintf(query, MAX_QUERY_LEN,
769 "insert into package_app_info(app_id, app_component, app_exec, app_nodisplay, app_type, app_onboot, " \
770 "app_multiple, app_autorestart, app_taskmanage, app_hwacceleration, app_mainapp , app_recentimage, package) " \
771 "values('%s', '%s', '%s', '%s', '%s', '%s','%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
772 up->appid, "uiapp", up->exec, up->nodisplay, up->type, "\0", up->multiple,
773 "\0", up->taskmanage, up->hwacceleration,up->mainapp, up->recentimage, mfx->package);
774 ret = __exec_query(query);
776 DBG("Package UiApp Info DB Insert Failed\n");
780 memset(query, '\0', MAX_QUERY_LEN);
785 static int __insert_uiapplication_appcategory_info(manifest_x *mfx)
787 uiapplication_x *up = mfx->uiapplication;
788 category_x *ct = NULL;
790 char query[MAX_QUERY_LEN] = {'\0'};
796 snprintf(query, MAX_QUERY_LEN,
797 "insert into package_app_app_category(app_id, category) " \
798 "values('%s','%s')",\
799 up->appid, ct->name);
800 ret = __exec_query(query);
802 DBG("Package UiApp Category Info DB Insert Failed\n");
806 memset(query, '\0', MAX_QUERY_LEN);
813 static int __insert_uiapplication_appcontrol_info(manifest_x *mfx)
815 uiapplication_x *up = mfx->uiapplication;
816 appcontrol_x *acontrol = NULL;
817 operation_x *op = NULL;
820 subapp_x *sub = NULL;
822 char query[MAX_QUERY_LEN] = {'\0'};
823 char *operation = NULL;
829 acontrol = up->appcontrol;
830 while(acontrol != NULL)
832 op = acontrol->operation;
836 operation = op->name;
843 sub = acontrol->subapp;
853 snprintf(query, MAX_QUERY_LEN,
854 "insert into package_app_app_control(app_id, operation, uri_scheme, mime_type, subapp_name) " \
855 "values('%s', '%s', '%s', '%s', '%s')",\
856 up->appid, operation, uri, mime, subapp);
858 ret = __exec_query(query);
860 DBG("Package UiApp AppSvc DB Insert Failed\n");
863 memset(query, '\0', MAX_QUERY_LEN);
880 acontrol = acontrol->next;
887 static int __insert_uiapplication_appsvc_info(manifest_x *mfx)
889 uiapplication_x *up = mfx->uiapplication;
890 appsvc_x *asvc = NULL;
891 operation_x *op = NULL;
894 subapp_x *sub = NULL;
896 char query[MAX_QUERY_LEN] = {'\0'};
897 char *operation = NULL;
906 op = asvc->operation;
910 operation = op->name;
927 snprintf(query, MAX_QUERY_LEN,
928 "insert into package_app_app_svc(app_id, operation, uri_scheme, mime_type, subapp_name) " \
929 "values('%s', '%s', '%s', '%s', '%s')",\
930 up->appid, operation, uri, mime, subapp);
932 ret = __exec_query(query);
934 DBG("Package UiApp AppSvc DB Insert Failed\n");
937 memset(query, '\0', MAX_QUERY_LEN);
961 static int __insert_uiapplication_share_request_info(manifest_x *mfx)
963 uiapplication_x *up = mfx->uiapplication;
964 datashare_x *ds = NULL;
965 request_x *rq = NULL;
967 char query[MAX_QUERY_LEN] = {'\0'};
976 snprintf(query, MAX_QUERY_LEN,
977 "insert into package_app_share_request(app_id, data_share_request) " \
978 "values('%s', '%s')",\
979 up->appid, rq->text);
980 ret = __exec_query(query);
982 DBG("Package UiApp Share Request DB Insert Failed\n");
985 memset(query, '\0', MAX_QUERY_LEN);
995 static int __insert_uiapplication_share_allowed_info(manifest_x *mfx)
997 uiapplication_x *up = mfx->uiapplication;
998 datashare_x *ds = NULL;
1000 allowed_x *al = NULL;
1002 char query[MAX_QUERY_LEN] = {'\0'};
1014 snprintf(query, MAX_QUERY_LEN,
1015 "insert into package_app_share_allowed(app_id, data_share_path, data_share_allowed) " \
1016 "values('%s', '%s', '%s')",\
1017 up->appid, df->path, al->text);
1018 ret = __exec_query(query);
1020 DBG("Package UiApp Share Allowed DB Insert Failed\n");
1023 memset(query, '\0', MAX_QUERY_LEN);
1035 static int __insert_serviceapplication_info(manifest_x *mfx)
1037 serviceapplication_x *sp = mfx->serviceapplication;
1039 char query[MAX_QUERY_LEN] = {'\0'};
1042 snprintf(query, MAX_QUERY_LEN,
1043 "insert into package_app_info(app_id, app_component, app_exec, app_nodisplay, app_type, app_onboot, " \
1044 "app_multiple, app_autorestart, package) " \
1045 "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
1046 sp->appid, "svcapp", sp->exec, "\0", sp->type, sp->onboot, "\0",
1047 sp->autorestart, mfx->package);
1048 ret = __exec_query(query);
1050 DBG("Package ServiceApp Info DB Insert Failed\n");
1054 memset(query, '\0', MAX_QUERY_LEN);
1059 static int __insert_serviceapplication_appcategory_info(manifest_x *mfx)
1061 serviceapplication_x *sp = mfx->serviceapplication;
1062 category_x *ct = NULL;
1064 char query[MAX_QUERY_LEN] = {'\0'};
1070 snprintf(query, MAX_QUERY_LEN,
1071 "insert into package_app_app_category(app_id, category) " \
1072 "values('%s','%s')",\
1073 sp->appid, ct->name);
1074 ret = __exec_query(query);
1076 DBG("Package ServiceApp Category Info DB Insert Failed\n");
1080 memset(query, '\0', MAX_QUERY_LEN);
1087 static int __insert_serviceapplication_appcontrol_info(manifest_x *mfx)
1089 serviceapplication_x *sp = mfx->serviceapplication;
1090 appcontrol_x *acontrol = NULL;
1092 char query[MAX_QUERY_LEN] = {'\0'};
1093 operation_x *op = NULL;
1096 subapp_x *sub = NULL;
1097 char *operation = NULL;
1100 char *subapp = NULL;
1103 acontrol = sp->appcontrol;
1104 while(acontrol != NULL)
1106 op = acontrol->operation;
1110 operation = op->name;
1111 mi = acontrol->mime;
1116 sub = acontrol->subapp;
1126 snprintf(query, MAX_QUERY_LEN,
1127 "insert into package_app_app_control(app_id, operation, uri_scheme, mime_type,subapp_name) " \
1128 "values('%s', '%s', '%s', '%s', '%s')",\
1129 sp->appid, operation, uri, mime, subapp);
1130 ret = __exec_query(query);
1132 DBG("Package UiApp AppSvc DB Insert Failed\n");
1135 memset(query, '\0', MAX_QUERY_LEN);
1139 } while(ui != NULL);
1143 }while(sub != NULL);
1152 acontrol = acontrol->next;
1159 static int __insert_serviceapplication_appsvc_info(manifest_x *mfx)
1161 serviceapplication_x *sp = mfx->serviceapplication;
1162 appsvc_x *asvc = NULL;
1164 char query[MAX_QUERY_LEN] = {'\0'};
1165 operation_x *op = NULL;
1168 subapp_x *sub = NULL;
1169 char *operation = NULL;
1172 char *subapp = NULL;
1178 op = asvc->operation;
1182 operation = op->name;
1198 snprintf(query, MAX_QUERY_LEN,
1199 "insert into package_app_app_svc(app_id, operation, uri_scheme, mime_type, subapp_name) " \
1200 "values('%s', '%s', '%s', '%s', '%s')",\
1201 sp->appid, operation, uri, mime, subapp);
1202 ret = __exec_query(query);
1204 DBG("Package UiApp AppSvc DB Insert Failed\n");
1207 memset(query, '\0', MAX_QUERY_LEN);
1211 } while(ui != NULL);
1215 }while(sub != NULL);
1233 static int __insert_serviceapplication_share_request_info(manifest_x *mfx)
1235 serviceapplication_x *sp = mfx->serviceapplication;
1236 datashare_x *ds = NULL;
1237 request_x *rq = NULL;
1239 char query[MAX_QUERY_LEN] = {'\0'};
1248 snprintf(query, MAX_QUERY_LEN,
1249 "insert into package_app_share_request(app_id, data_share_request) " \
1250 "values('%s', '%s')",\
1251 sp->appid, rq->text);
1252 ret = __exec_query(query);
1254 DBG("Package ServiceApp Share Request DB Insert Failed\n");
1257 memset(query, '\0', MAX_QUERY_LEN);
1269 static int __insert_serviceapplication_share_allowed_info(manifest_x *mfx)
1271 serviceapplication_x *sp = mfx->serviceapplication;
1272 datashare_x *ds = NULL;
1273 define_x *df = NULL;
1274 allowed_x *al = NULL;
1276 char query[MAX_QUERY_LEN] = {'\0'};
1288 snprintf(query, MAX_QUERY_LEN,
1289 "insert into package_app_share_allowed(app_id, data_share_path, data_share_allowed) " \
1290 "values('%s', '%s', '%s')",\
1291 sp->appid, df->path, al->text);
1292 ret = __exec_query(query);
1294 DBG("Package App Share Allowed DB Insert Failed\n");
1297 memset(query, '\0', MAX_QUERY_LEN);
1309 static int __insert_manifest_info_in_db(manifest_x *mfx)
1311 label_x *lbl = mfx->label;
1312 license_x *lcn = mfx->license;
1313 icon_x *icn = mfx->icon;
1314 description_x *dcn = mfx->description;
1315 author_x *ath = mfx->author;
1316 uiapplication_x *up = mfx->uiapplication;
1317 uiapplication_x *up_icn = mfx->uiapplication;
1318 serviceapplication_x *sp = mfx->serviceapplication;
1319 char query[MAX_QUERY_LEN] = { '\0' };
1322 char *auth_name = NULL;
1323 char *auth_email = NULL;
1324 char *auth_href = NULL;
1327 auth_name = ath->text;
1329 auth_email = ath->email;
1331 auth_href = ath->href;
1334 /*Insert in the package_info DB*/
1336 type = strdup(mfx->type);
1338 type = strdup("rpm");
1339 snprintf(query, MAX_QUERY_LEN,
1340 "insert into package_info(package, package_type, package_version, install_location, package_size, " \
1341 "package_removable, package_preload, package_readonly, author_name, author_email, author_href, installed_time, storeclient_id, mainapp_id, package_url) " \
1342 "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
1343 mfx->package, type, mfx->version, mfx->installlocation, mfx->package_size, mfx->removable, mfx->preload,
1344 mfx->readonly, auth_name, auth_email, auth_href, mfx->installed_time, mfx->storeclient_id, mfx->mainapp_id, mfx->package_url);
1345 ret = __exec_query(query);
1347 DBG("Package Info DB Insert Failed\n");
1358 /*Insert the package locale and app locale info */
1359 pkglocale = __create_locale_list(pkglocale, lbl, lcn, icn, dcn, ath);
1360 g_list_foreach(pkglocale, __trimfunc1, NULL);
1365 applocale = __create_locale_list(applocale, up->label, NULL, up->icon, NULL, NULL);
1370 applocale = __create_locale_list(applocale, sp->label, NULL, sp->icon, NULL, NULL);
1373 g_list_foreach(applocale, __trimfunc2, NULL);
1376 /*Insert the app icon info */
1377 while(up_icn != NULL)
1379 appicon = __create_icon_list(appicon, up_icn->icon);
1380 up_icn = up_icn->next;
1382 g_list_foreach(appicon, __trimfunc3, NULL);
1385 /*g_list_foreach(pkglocale, __printfunc, NULL);*/
1387 /*g_list_foreach(applocale, __printfunc, NULL);*/
1389 /*package locale info*/
1390 g_list_foreach(pkglocale, __insert_pkglocale_info, (gpointer)mfx);
1391 /*native app locale info*/
1392 up = mfx->uiapplication;
1395 g_list_foreach(applocale, __insert_uiapplication_locale_info, (gpointer)up);
1398 /*agent app locale info*/
1399 sp = mfx->serviceapplication;
1402 g_list_foreach(applocale, __insert_serviceapplication_locale_info, (gpointer)sp);
1406 /*app icon locale info*/
1407 up_icn = mfx->uiapplication;
1408 while(up_icn != NULL)
1410 g_list_foreach(appicon, __insert_uiapplication_icon_locale_info, (gpointer)up_icn);
1411 up_icn = up_icn->next;
1414 g_list_free(pkglocale);
1416 g_list_free(applocale);
1418 g_list_free(appicon);
1422 /*Insert in the package_app_info DB*/
1423 ret = __insert_uiapplication_info(mfx);
1426 ret = __insert_ui_mainapp_info(mfx);
1429 ret = __insert_serviceapplication_info(mfx);
1433 /*Insert in the package_app_app_control DB*/
1434 ret = __insert_uiapplication_appcontrol_info(mfx);
1437 ret = __insert_serviceapplication_appcontrol_info(mfx);
1441 /*Insert in the package_app_app_category DB*/
1442 ret = __insert_uiapplication_appcategory_info(mfx);
1445 ret = __insert_serviceapplication_appcategory_info(mfx);
1449 /*Insert in the package_app_app_svc DB*/
1450 ret = __insert_uiapplication_appsvc_info(mfx);
1453 ret = __insert_serviceapplication_appsvc_info(mfx);
1457 /*Insert in the package_app_share_allowed DB*/
1458 ret = __insert_uiapplication_share_allowed_info(mfx);
1461 ret = __insert_serviceapplication_share_allowed_info(mfx);
1465 /*Insert in the package_app_share_request DB*/
1466 ret = __insert_uiapplication_share_request_info(mfx);
1469 ret = __insert_serviceapplication_share_request_info(mfx);
1477 static int __delete_cert_info_from_db(manifest_x *mfx)
1479 char query[MAX_QUERY_LEN] = { '\0' };
1481 char *error_message = NULL;
1483 ret = __pkgmgr_parser_cert_create_db();
1485 DBG("Failed to open DB\n");
1489 /*Begin transaction*/
1490 ret = sqlite3_exec(pkgmgr_cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
1491 if (ret != SQLITE_OK) {
1492 DBG("Failed to begin transaction\n");
1493 sqlite3_close(pkgmgr_cert_db);
1496 DBG("Transaction Begin\n");
1497 snprintf(query, MAX_QUERY_LEN,
1498 "delete from package_cert_info where package='%s'", mfx->package);
1501 sqlite3_exec(pkgmgr_cert_db, query, NULL, NULL, &error_message)) {
1502 DBG("Don't execute query = %s error message = %s\n", query,
1506 sqlite3_free(error_message);
1509 DBG("Delete from DB failed. Rollback now\n");
1510 sqlite3_exec(pkgmgr_cert_db, "ROLLBACK", NULL, NULL, NULL);
1511 sqlite3_close(pkgmgr_cert_db);
1514 /*Commit transaction*/
1515 ret = sqlite3_exec(pkgmgr_cert_db, "COMMIT", NULL, NULL, NULL);
1516 if (ret != SQLITE_OK) {
1517 DBG("Failed to commit transaction, Rollback now\n");
1518 sqlite3_exec(pkgmgr_cert_db, "ROLLBACK", NULL, NULL, NULL);
1519 sqlite3_close(pkgmgr_cert_db);
1522 DBG("Transaction Commit and End\n");
1523 sqlite3_free(error_message);
1524 sqlite3_close(pkgmgr_cert_db);
1529 static int __delete_manifest_info_from_db(manifest_x *mfx)
1531 char query[MAX_QUERY_LEN] = { '\0' };
1533 uiapplication_x *up = mfx->uiapplication;
1534 serviceapplication_x *sp = mfx->serviceapplication;
1536 ret = __delete_cert_info_from_db(mfx);
1538 DBG("Package cert DB Delete Failed\n");
1542 /*Delete from Package Info DB*/
1543 snprintf(query, MAX_QUERY_LEN,
1544 "delete from package_info where package='%s'", mfx->package);
1545 ret = __exec_query(query);
1547 DBG("Package Info DB Delete Failed\n");
1550 memset(query, '\0', MAX_QUERY_LEN);
1552 /*Delete from Package Localized Info*/
1553 snprintf(query, MAX_QUERY_LEN,
1554 "delete from package_localized_info where package='%s'", mfx->package);
1555 ret = __exec_query(query);
1557 DBG("Package Localized Info DB Delete Failed\n");
1560 memset(query, '\0', MAX_QUERY_LEN);
1562 /*Delete from Package App Info*/
1565 snprintf(query, MAX_QUERY_LEN,
1566 "delete from package_app_info where app_id='%s'", up->appid);
1567 ret = __exec_query(query);
1569 DBG("Package App Info DB Delete Failed\n");
1572 memset(query, '\0', MAX_QUERY_LEN);
1577 snprintf(query, MAX_QUERY_LEN,
1578 "delete from package_app_info where app_id='%s'", sp->appid);
1579 ret = __exec_query(query);
1581 DBG("Package App Info DB Delete Failed\n");
1584 memset(query, '\0', MAX_QUERY_LEN);
1588 /*Delete from Package App Localized Info*/
1589 up = mfx->uiapplication;
1590 sp = mfx->serviceapplication;
1593 snprintf(query, MAX_QUERY_LEN,
1594 "delete from package_app_localized_info where app_id='%s'", up->appid);
1595 ret = __exec_query(query);
1597 DBG("Package App Localized Info DB Delete Failed\n");
1600 memset(query, '\0', MAX_QUERY_LEN);
1605 snprintf(query, MAX_QUERY_LEN,
1606 "delete from package_app_localized_info where app_id='%s'", sp->appid);
1607 ret = __exec_query(query);
1609 DBG("Package App Localized Info DB Delete Failed\n");
1612 memset(query, '\0', MAX_QUERY_LEN);
1616 /*Delete from Package App App-Svc*/
1617 up = mfx->uiapplication;
1618 sp = mfx->serviceapplication;
1621 snprintf(query, MAX_QUERY_LEN,
1622 "delete from package_app_app_svc where app_id='%s'", up->appid);
1623 ret = __exec_query(query);
1625 DBG("Package App App-Svc DB Delete Failed\n");
1628 memset(query, '\0', MAX_QUERY_LEN);
1633 snprintf(query, MAX_QUERY_LEN,
1634 "delete from package_app_app_svc where app_id='%s'", sp->appid);
1635 ret = __exec_query(query);
1637 DBG("Package App App-Svc DB Delete Failed\n");
1640 memset(query, '\0', MAX_QUERY_LEN);
1644 /*Delete from Package App App-Control*/
1645 up = mfx->uiapplication;
1646 sp = mfx->serviceapplication;
1649 snprintf(query, MAX_QUERY_LEN,
1650 "delete from package_app_app_control where app_id='%s'", up->appid);
1651 ret = __exec_query(query);
1653 DBG("Package App App-Control DB Delete Failed\n");
1656 memset(query, '\0', MAX_QUERY_LEN);
1661 snprintf(query, MAX_QUERY_LEN,
1662 "delete from package_app_app_control where app_id='%s'", sp->appid);
1663 ret = __exec_query(query);
1665 DBG("Package App App-Control DB Delete Failed\n");
1668 memset(query, '\0', MAX_QUERY_LEN);
1672 /*Delete from Package App App-Category*/
1673 up = mfx->uiapplication;
1674 sp = mfx->serviceapplication;
1677 snprintf(query, MAX_QUERY_LEN,
1678 "delete from package_app_app_category where app_id='%s'", up->appid);
1679 ret = __exec_query(query);
1681 DBG("Package App App-Category DB Delete Failed\n");
1684 memset(query, '\0', MAX_QUERY_LEN);
1689 snprintf(query, MAX_QUERY_LEN,
1690 "delete from package_app_app_category where app_id='%s'", sp->appid);
1691 ret = __exec_query(query);
1693 DBG("Package App App-Category DB Delete Failed\n");
1696 memset(query, '\0', MAX_QUERY_LEN);
1700 /*Delete from Package App Share Allowed*/
1701 up = mfx->uiapplication;
1702 sp = mfx->serviceapplication;
1705 snprintf(query, MAX_QUERY_LEN,
1706 "delete from package_app_share_allowed where app_id='%s'", up->appid);
1707 ret = __exec_query(query);
1709 DBG("Package App Share Allowed DB Delete Failed\n");
1712 memset(query, '\0', MAX_QUERY_LEN);
1717 snprintf(query, MAX_QUERY_LEN,
1718 "delete from package_app_share_allowed where app_id='%s'", sp->appid);
1719 ret = __exec_query(query);
1721 DBG("Package App Share Allowed DB Delete Failed\n");
1724 memset(query, '\0', MAX_QUERY_LEN);
1728 /*Delete from Package App Share Request*/
1729 up = mfx->uiapplication;
1730 sp = mfx->serviceapplication;
1733 snprintf(query, MAX_QUERY_LEN,
1734 "delete from package_app_share_request where app_id='%s'", up->appid);
1735 ret = __exec_query(query);
1737 DBG("Package App Share Request DB Delete Failed\n");
1740 memset(query, '\0', MAX_QUERY_LEN);
1745 snprintf(query, MAX_QUERY_LEN,
1746 "delete from package_app_share_request where app_id='%s'", sp->appid);
1747 ret = __exec_query(query);
1749 DBG("Package App Share Request DB Delete Failed\n");
1752 memset(query, '\0', MAX_QUERY_LEN);
1759 int pkgmgr_parser_initialize_db()
1762 ret = __initialize_package_info_db();
1764 DBG("package info DB initialization failed\n");
1767 ret = __initialize_package_localized_info_db();
1769 DBG("package localized info DB initialization failed\n");
1772 ret = __initialize_package_cert_info_db();
1774 DBG("package cert info DB initialization failed\n");
1777 ret = __initialize_package_app_info_db();
1779 DBG("package app info DB initialization failed\n");
1782 ret = __initialize_package_app_localized_info_db();
1784 DBG("package app localized info DB initialization failed\n");
1787 ret = __initialize_package_app_icon_localized_info_db();
1789 DBG("package app icon localized info DB initialization failed\n");
1792 ret = __initialize_package_app_app_control_db();
1794 DBG("package app app control DB initialization failed\n");
1797 ret = __initialize_package_app_app_category_db();
1799 DBG("package app app category DB initialization failed\n");
1802 ret = __initialize_package_app_app_svc_db();
1804 DBG("package app app svc DB initialization failed\n");
1807 ret = __initialize_package_app_share_allowed_db();
1809 DBG("package app share allowed DB initialization failed\n");
1812 ret = __initialize_package_app_share_request_db();
1814 DBG("package app share request DB initialization failed\n");
1820 int pkgmgr_parser_check_and_create_db()
1823 if (access(PKGMGR_PARSER_DB_FILE, F_OK) == 0) {
1825 db_util_open(PKGMGR_PARSER_DB_FILE, &pkgmgr_parser_db,
1826 DB_UTIL_REGISTER_HOOK_METHOD);
1827 if (ret != SQLITE_OK) {
1828 DBG("connect db [%s] failed!\n",
1829 PKGMGR_PARSER_DB_FILE);
1834 DBG("Pkgmgr DB does not exists. Create one!!\n");
1837 db_util_open(PKGMGR_PARSER_DB_FILE, &pkgmgr_parser_db,
1838 DB_UTIL_REGISTER_HOOK_METHOD);
1840 if (ret != SQLITE_OK) {
1841 DBG("connect db [%s] failed!\n", PKGMGR_PARSER_DB_FILE);
1847 API int pkgmgr_parser_insert_manifest_info_in_db(manifest_x *mfx)
1850 DBG("manifest pointer is NULL\n");
1854 ret = pkgmgr_parser_check_and_create_db();
1856 DBG("Failed to open DB\n");
1859 ret = pkgmgr_parser_initialize_db();
1862 /*Begin transaction*/
1863 ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
1864 if (ret != SQLITE_OK) {
1865 DBG("Failed to begin transaction\n");
1866 sqlite3_close(pkgmgr_parser_db);
1869 DBG("Transaction Begin\n");
1870 ret = __insert_manifest_info_in_db(mfx);
1872 DBG("Insert into DB failed. Rollback now\n");
1873 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
1874 sqlite3_close(pkgmgr_parser_db);
1877 /*Commit transaction*/
1878 ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
1879 if (ret != SQLITE_OK) {
1880 DBG("Failed to commit transaction. Rollback now\n");
1881 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
1882 sqlite3_close(pkgmgr_parser_db);
1885 DBG("Transaction Commit and End\n");
1886 sqlite3_close(pkgmgr_parser_db);
1890 API int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx)
1893 DBG("manifest pointer is NULL\n");
1897 ret = pkgmgr_parser_check_and_create_db();
1899 DBG("Failed to open DB\n");
1902 ret = pkgmgr_parser_initialize_db();
1906 /*Begin transaction*/
1907 ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
1908 if (ret != SQLITE_OK) {
1909 DBG("Failed to begin transaction\n");
1910 sqlite3_close(pkgmgr_parser_db);
1913 DBG("Transaction Begin\n");
1914 ret = __delete_manifest_info_from_db(mfx);
1916 DBG("Delete from DB failed. Rollback now\n");
1917 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
1918 sqlite3_close(pkgmgr_parser_db);
1921 ret = __insert_manifest_info_in_db(mfx);
1923 DBG("Insert into DB failed. Rollback now\n");
1924 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
1925 sqlite3_close(pkgmgr_parser_db);
1929 /*Commit transaction*/
1930 ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
1931 if (ret != SQLITE_OK) {
1932 DBG("Failed to commit transaction. Rollback now\n");
1933 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
1934 sqlite3_close(pkgmgr_parser_db);
1937 DBG("Transaction Commit and End\n");
1938 sqlite3_close(pkgmgr_parser_db);
1942 API int pkgmgr_parser_delete_manifest_info_from_db(manifest_x *mfx)
1945 DBG("manifest pointer is NULL\n");
1949 ret = pkgmgr_parser_check_and_create_db();
1951 DBG("Failed to open DB\n");
1954 /*Begin transaction*/
1955 ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
1956 if (ret != SQLITE_OK) {
1957 DBG("Failed to begin transaction\n");
1958 sqlite3_close(pkgmgr_parser_db);
1961 DBG("Transaction Begin\n");
1962 ret = __delete_manifest_info_from_db(mfx);
1964 DBG("Delete from DB failed. Rollback now\n");
1965 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
1966 sqlite3_close(pkgmgr_parser_db);
1969 /*Commit transaction*/
1970 ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
1971 if (ret != SQLITE_OK) {
1972 DBG("Failed to commit transaction, Rollback now\n");
1973 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
1974 sqlite3_close(pkgmgr_parser_db);
1977 DBG("Transaction Commit and End\n");
1978 sqlite3_close(pkgmgr_parser_db);