2 * Copyright 2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <sys/types.h>
27 #include <libxml/parser.h>
28 #include <libxml/tree.h>
31 #include <dynamicbox_service.h>
36 #define DbgPrint(format, arg...) SECURE_LOGD("[
\e[32m%s/%s
\e[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg)
37 #define ErrPrint(format, arg...) SECURE_LOGE("[
\e[32m%s/%s
\e[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg)
38 #define ErrPrintWithConsole(format, arg...) do { fprintf(stderr, "[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); SECURE_LOGE("[
\e[32m%s/%s
\e[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); } while (0)
42 #define DEFAULT_CATEGORY "http://tizen.org/category/default"
54 * CREATE TABLE version ( version INTEGER )
58 * +-------+-------+-------+-------+-------------------+
59 * | appid | pkgid | uiapp | prime | categ(from ver 2) |
60 * +-------+-------+-------+-------+-------------------+
61 * | - | - | - | - | - |
62 * +-------+-------+-------+-------+-------------------+
63 * CREATE TABLE pkgmap ( pkgid TEXT PRIMARY KEY NOT NULL, appid TEXT, uiapp TEXT, prime INTEGER, category TEXT )
67 * +-------+---------+-----+---------+----------+---------+-----------+---------+--------+----------+---------+---------+--------+--------+-------+-----------------------+
68 * | pkgid | network | abi | secured | box_type | box_src | box_group | gbar_type | gbar_src | gbar_group | libexec | timeout | period | script | pinup | count(from ver 4) | direct_input | hw_acceleration |
69 * +-------+---------+-----+---------+----------+---------+-----------+---------+--------+----------+---------+---------+--------+--------+-------+-----------------------+-------|---------------|
70 * | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
71 * +-------+---------+-----+---------+----------+---------+-----------+---------+--------+----------+---------+---------+--------+--------+-------+-----------------------+-------|---------------|
72 * CREATE TABLE provider ( pkgid TEXT PRIMARY KEY NOT NULL, network INTEGER, abi TEXT, secured INTEGER, box_type INTEGER, box_src TEXT, box_group TEXT, gbar_type TEXT, gbar_src TEXT, gbar_group TEXT, libexec TEXT, timeout INTEGER, period TEXT, script TEXT, pinup INTEGER, count INTEGER, direct_input INTEGER DEFAULT 0, hw_acceleration TEXT DEFAULT 'none', FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid))
74 * = box_type = { text | buffer | script | image }
75 * = gbar_type = { text | buffer | script }
76 * = network = { 1 | 0 }
77 * = secured = { 1 | 0 }
81 * +-------+------+---------+-------------+-----------+---------+-----------+-------+
82 * | pkgid | Icon | Name | auto_launch | gbar_size | content | nodisplay | setup |
83 * +-------+------+---------+-------------+-----------+---------+-----------+-------+
84 * | - | - | - | - | - | - | - | - |
85 * +-------+------+---------+-------------+-----------+---------+-----------+-------+
86 * CREATE TABLE client ( pkgid TEXT PRIMARY KEY NOT NULL, icon TEXT, name TEXT, auto_launch TEXT, gbar_size TEXT, content TEXT, nodisplay INTEGER, setup TEXT, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) )
88 * = auto_launch = UI-APPID
89 * = gbar_size = WIDTHxHEIGHT
93 * +-------+------+------+------+
94 * | fk | lang | name | icon |
95 * +-------+------+------+------+
96 * | pkgid | - | - | - |
97 * +-------+------+------+------+
98 * CREATE TABLE i18n ( pkgid TEXT NOT NULL, lang TEXT COLLATE NOCASE, name TEXT, icon TEXT, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) )
102 * +-------+-----------+---------+--------------+------------+-------------------------+
103 * | pkgid | size_type | preview | touch_effect | need_frame | mouse_event(from ver 3) |
104 * +-------+-----------+---------+--------------+------------+-------------------------+
105 * | - | - | - | - | - | - |
106 * +-------+-----------+---------+--------------+------------+-------------------------+
107 * CREATE TABLE box_size ( pkgid TEXT NOT NULL, size_type INTEGER, preview TEXT, INTEGER, touch_effect INTEGER, need_frame INTEGER, mouse_event INTEGER, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) )
109 * = box_size_list = { WIDTHxHEIGHT; WIDTHxHEIGHT; ... }
112 * +----+---------+----------+-------+
113 * | id | cluster | category | pkgid |
114 * +----+---------+----------+-------+
116 * +----+---------+----------+-------|
117 * CREATE TABLE groupinfo ( id INTEGER PRIMARY KEY AUTOINCREMENT, cluster TEXT NOT NULL, category TEXT NOT NULL, appid TEXT NOT NULL, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ))
120 * +-------+----+----------+-----------+
121 * | pkgid | id | ctx_item | option_id |
122 * +-------+----+----------+-----------+
123 * CREATE TABLE groupmap ( option_id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER, pkgid TEXT NOT NULL, ctx_item TEXT NOT NULL, FOREIGN KEY(id) REFERENCES groupinfo(id), FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) )
127 * +-------+-----------+-----+-------+
128 * | pkgid | option_id | key | value |
129 * +-------+-----------+-----+-------+
130 * CREATE TABLE option ( pkgid TEXT NOT NULL, option_id INTEGER, key TEXT NOT NULL, value TEXT NOT NULL, FOREIGN KEY(option_id) REFERENCES groupmap(option_id), FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) )
133 #if !defined(LIBXML_TREE_ENABLED)
134 #error "LIBXML is not supporting the tree"
141 #define LOG_TAG "PKGMGR_DYNAMICBOX"
155 xmlChar *auto_launch;
157 xmlChar *name; /* Default name */
158 xmlChar *icon; /* Default icon */
159 xmlChar *libexec; /* Path of the SO file */
160 xmlChar *timeout; /* INTEGER, timeout */
161 xmlChar *period; /* DOUBLE, update period */
162 xmlChar *script; /* Script engine */
163 xmlChar *content; /* Content information */
165 xmlChar *uiapp; /* UI App Id */
166 xmlChar *category; /* Category of this box */
168 int pinup; /* Is this support the pinup feature? */
169 int primary; /* Is this primary dynamicbox? */
171 int count; /* Max count of instances */
172 int direct_input; /* Use the input node to get the event directly */
174 int default_mouse_event; /* Mouse event processing option for dynamicbox */
175 int default_touch_effect;
176 int default_need_frame;
178 enum dynamicbox_dbox_type dbox_type;
181 int size_list; /* 1x1, 2x1, 2x2, 4x1, 4x2, 4x3, 4x4 */
183 xmlChar *preview[DBOX_NR_OF_SIZE_LIST];
184 int touch_effect[DBOX_NR_OF_SIZE_LIST]; /* Touch effect of a dynamicbox */
185 int need_frame[DBOX_NR_OF_SIZE_LIST]; /* Box needs frame which should be cared by viewer */
186 int mouse_event[DBOX_NR_OF_SIZE_LIST];
188 enum dynamicbox_gbar_type gbar_type;
191 xmlChar *gbar_size; /* Default PD size */
192 xmlChar *hw_acceleration;
194 struct dlist *i18n_list;
195 struct dlist *group_list;
202 struct dlist *option_list;
214 .dbfile = "/opt/dbspace/.dynamicbox.db",
218 static inline int begin_transaction(void)
223 ret = sqlite3_prepare_v2(s_info.handle, "BEGIN TRANSACTION", -1, &stmt, NULL);
225 if (ret != SQLITE_OK) {
226 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
230 if (sqlite3_step(stmt) != SQLITE_DONE) {
231 DbgPrint("Failed to do update (%s)\n",
232 sqlite3_errmsg(s_info.handle));
233 sqlite3_finalize(stmt);
237 sqlite3_finalize(stmt);
241 static inline int rollback_transaction(void)
246 ret = sqlite3_prepare_v2(s_info.handle, "ROLLBACK TRANSACTION", -1, &stmt, NULL);
247 if (ret != SQLITE_OK) {
248 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
252 if (sqlite3_step(stmt) != SQLITE_DONE) {
253 DbgPrint("Failed to do update (%s)\n",
254 sqlite3_errmsg(s_info.handle));
255 sqlite3_finalize(stmt);
259 sqlite3_finalize(stmt);
263 static inline int commit_transaction(void)
268 ret = sqlite3_prepare_v2(s_info.handle, "COMMIT TRANSACTION", -1, &stmt, NULL);
269 if (ret != SQLITE_OK) {
270 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
274 if (sqlite3_step(stmt) != SQLITE_DONE) {
275 DbgPrint("Failed to do update (%s)\n",
276 sqlite3_errmsg(s_info.handle));
277 sqlite3_finalize(stmt);
281 sqlite3_finalize(stmt);
285 static void db_create_version(void)
287 static const char *ddl = "CREATE TABLE version (version INTEGER)";
290 if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
291 ErrPrint("Failed to execute the DDL (%s)\n", err);
295 if (sqlite3_changes(s_info.handle) == 0) {
296 ErrPrint("No changes to DB\n");
300 static int set_version(int version)
302 static const char *dml = "INSERT INTO version (version) VALUES (?)";
306 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
307 if (ret != SQLITE_OK) {
308 ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle));
312 if (sqlite3_bind_int(stmt, 1, version) != SQLITE_OK) {
313 ErrPrint("Failed to bind a id(%s)\n", sqlite3_errmsg(s_info.handle));
318 ret = sqlite3_step(stmt);
319 if (ret != SQLITE_DONE) {
320 ErrPrint("Failed to execute the DML for version: %d\n", ret);
328 sqlite3_clear_bindings(stmt);
329 sqlite3_finalize(stmt);
333 static int update_version(int version)
335 static const char *dml = "UPDATE version SET version = ?";
339 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
340 if (ret != SQLITE_OK) {
341 ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle));
345 if (sqlite3_bind_int(stmt, 1, version) != SQLITE_OK) {
346 ErrPrint("Failed to bind a version: %s\n", sqlite3_errmsg(s_info.handle));
351 ret = sqlite3_step(stmt);
352 if (ret != SQLITE_DONE) {
353 ErrPrint("Failed to execute DML: %d\n", ret);
361 sqlite3_clear_bindings(stmt);
362 sqlite3_finalize(stmt);
366 static int get_version(void)
368 static const char *dml = "SELECT version FROM version";
372 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
373 if (ret != SQLITE_OK) {
377 if (sqlite3_step(stmt) != SQLITE_ROW) {
380 ret = sqlite3_column_int(stmt, 0);
384 sqlite3_clear_bindings(stmt);
385 sqlite3_finalize(stmt);
391 * From version 1 to 2
393 static void upgrade_pkgmap_for_category(void)
396 static const char *ddl;
398 ddl = "ALTER TABLE pkgmap ADD COLUMN category TEXT DEFAULT \"" DEFAULT_CATEGORY "\"";
399 if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
400 ErrPrint("Failed to execute the DDL (%s)\n", err);
404 if (sqlite3_changes(s_info.handle) == 0) {
405 ErrPrint("No changes to DB\n");
412 * From version 4 to 5
413 * "provider" table should have "direct_input" column.
414 * "direct_input" will be used for selecting input event path.
415 * if it is "true", the provider must has to get all events from device node directly.
416 * The file descriptor will be given by data-provider-master
418 static void upgrade_to_version_5(void)
421 static const char *ddl;
425 * Create a new column "direct_input" for provider table
427 ddl = "ALTER TABLE provider ADD COLUMN direct_input INTEGER DEFAULT 0";
428 if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
429 ErrPrint("Failed to execute the DDL (%s)\n", err);
433 if (sqlite3_changes(s_info.handle) == 0) {
434 ErrPrint("No changes to DB\n");
439 * Create a new column "hw_acceleration" for provider table
441 ddl = "ALTER TABLE provider ADD COLUMN hw_acceleration TEXT DEFAULT 'none'";
442 if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
443 ErrPrint("Failed to execute the DDL (%s)\n", err);
447 if (sqlite3_changes(s_info.handle) == 0) {
448 ErrPrint("No changes to DB\n");
454 * From version 3 to 4
455 * "provider" table should have "count" column.
456 * "count" will be used for limiting creatable count of instances for each dynamicbox.
457 * Every dynamicbox developer should describe their max count of creatable instances.
459 static void upgrade_to_version_4(void)
462 static const char *ddl;
466 * Create a new column for count to provider table.
468 ddl = "ALTER TABLE provider ADD COLUMN count INTEGER DEFAULT 0";
469 if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
470 ErrPrint("Failed to execute the DDL (%s)\n", err);
474 if (sqlite3_changes(s_info.handle) == 0) {
475 ErrPrint("No changes to DB\n");
481 * From version 2 to 3
482 * mouse_event is deleted from client table
483 * mouse_event is added to box_size table
485 * Every size has their own configuration for mouse_event flag.
487 static void upgrade_to_version_3(void)
490 static const char *ddl;
491 static const char *dml;
492 sqlite3_stmt *select_stmt;
497 * Create a new column for mouse_event to box_size table.
499 ddl = "ALTER TABLE box_size ADD COLUMN mouse_event INTEGER DEFAULT 0";
500 if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
501 ErrPrint("Failed to execute the DDL (%s)\n", err);
505 if (sqlite3_changes(s_info.handle) == 0) {
506 ErrPrint("No changes to DB\n");
511 * Copy mouse_event values from the client to the box_size table.
513 dml = "SELECT pkgid, mouse_event FROM client";
514 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &select_stmt, NULL);
515 if (ret == SQLITE_OK) {
516 sqlite3_stmt *update_stmt;
518 dml = "UPDATE box_size SET mouse_event = ? WHERE pkgid = ?";
519 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &update_stmt, NULL);
520 if (ret == SQLITE_OK) {
524 while (sqlite3_step(select_stmt) == SQLITE_ROW) {
525 pkgid = (const char *)sqlite3_column_text(select_stmt, 0);
527 ErrPrint("Package Id is not valid\n");
531 mouse_event = sqlite3_column_int(select_stmt, 1);
533 ret = sqlite3_bind_int(update_stmt, 1, mouse_event);
534 if (ret != SQLITE_OK) {
535 ErrPrint("Failed to bind mouse_event [%s], [%d]\n", pkgid, mouse_event);
536 sqlite3_reset(update_stmt);
537 sqlite3_clear_bindings(update_stmt);
541 ret = sqlite3_bind_text(update_stmt, 2, pkgid, -1, SQLITE_TRANSIENT);
542 if (ret != SQLITE_OK) {
543 ErrPrint("Failed to bind pkgid [%s], [%d]\n", pkgid, mouse_event);
544 sqlite3_reset(update_stmt);
545 sqlite3_clear_bindings(update_stmt);
549 ret = sqlite3_step(update_stmt);
550 if (ret != SQLITE_DONE) {
551 ErrPrint("Failed to execute DML: %d\n", ret);
552 sqlite3_reset(update_stmt);
553 sqlite3_clear_bindings(update_stmt);
557 sqlite3_reset(update_stmt);
558 sqlite3_clear_bindings(update_stmt);
561 sqlite3_finalize(update_stmt);
563 ErrPrint("Failed to execute DML\n");
566 sqlite3_reset(select_stmt);
567 sqlite3_clear_bindings(select_stmt);
568 sqlite3_finalize(select_stmt);
570 ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle));
575 * Drop a column from the client table
577 ddl = "ALTER TABLE client DROP COLUMN mouse_event";
578 if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
579 ErrPrint("Failed to execute the DDL (%s)\n", err);
583 if (sqlite3_changes(s_info.handle) == 0) {
584 ErrPrint("No changes to DB\n");
590 static void do_upgrade_db_schema(void)
594 version = get_version();
599 /* Need to create version table */
601 if (set_version(CUR_VER) < 0) {
602 ErrPrint("Failed to set version\n");
604 /* Need to set version */
606 upgrade_pkgmap_for_category();
608 upgrade_to_version_3();
610 upgrade_to_version_4();
612 upgrade_to_version_5();
614 /* Need to update version */
615 DbgPrint("Old version: %d\n", version);
616 if (update_version(CUR_VER) < 0) {
617 ErrPrint("Failed to update version\n");
624 static inline int db_create_pkgmap(void)
627 static const char *ddl;
629 ddl = "CREATE TABLE pkgmap ( pkgid TEXT PRIMARY KEY NOT NULL, appid TEXT, uiapp TEXT, prime INTEGER, category TEXT )";
630 if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
631 ErrPrint("Failed to execute the DDL (%s)\n", err);
635 if (sqlite3_changes(s_info.handle) == 0) {
636 ErrPrint("No changes to DB\n");
642 static inline int db_insert_pkgmap(const char *appid, const char *pkgid, const char *uiappid, int primary, const char *category)
645 static const char *dml;
648 dml = "INSERT INTO pkgmap ( appid, pkgid, uiapp, prime, category ) VALUES (? ,?, ?, ?, ?)";
649 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
650 if (ret != SQLITE_OK) {
651 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
655 ret = sqlite3_bind_text(stmt, 1, appid, -1, SQLITE_TRANSIENT);
656 if (ret != SQLITE_OK) {
657 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
662 ret = sqlite3_bind_text(stmt, 2, pkgid, -1, SQLITE_TRANSIENT);
663 if (ret != SQLITE_OK) {
664 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
669 ret = sqlite3_bind_text(stmt, 3, uiappid, -1, SQLITE_TRANSIENT);
670 if (ret != SQLITE_OK) {
671 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
676 ret = sqlite3_bind_int(stmt, 4, primary);
677 if (ret != SQLITE_OK) {
678 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
683 ret = sqlite3_bind_text(stmt, 5, category, -1, SQLITE_TRANSIENT);
684 if (ret != SQLITE_OK) {
685 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
691 if (sqlite3_step(stmt) != SQLITE_DONE) {
692 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
698 sqlite3_clear_bindings(stmt);
699 sqlite3_finalize(stmt);
703 static inline int db_remove_pkgmap(const char *pkgid)
706 static const char *dml;
709 dml = "DELETE FROM pkgmap WHERE pkgid = ?";
710 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
711 if (ret != SQLITE_OK) {
712 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
716 ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
717 if (ret != SQLITE_OK) {
718 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
724 if (sqlite3_step(stmt) != SQLITE_DONE) {
725 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
731 sqlite3_clear_bindings(stmt);
732 sqlite3_finalize(stmt);
736 static inline int db_create_provider(void)
739 static const char *ddl;
741 ddl = "CREATE TABLE provider (" \
742 "pkgid TEXT PRIMARY KEY NOT NULL, network INTEGER, " \
743 "abi TEXT, secured INTEGER, box_type INTEGER, " \
744 "box_src TEXT, box_group TEXT, gbar_type INTEGER, " \
745 "gbar_src TEXT, gbar_group TEXT, libexec TEXT, timeout INTEGER, period TEXT, script TEXT, pinup INTEGER, "\
746 "count INTEGER, direct_input INTEGER DEFAULT 0, hw_acceleration TEXT DEFAULT 'none', "\
747 "FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE)";
749 if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
750 ErrPrint("Failed to execute the DDL (%s)\n", err);
754 if (sqlite3_changes(s_info.handle) == 0) {
755 ErrPrint("No changes to DB\n");
761 static inline int db_remove_provider(const char *pkgid)
763 static const char *dml;
767 dml = "DELETE FROM provider WHERE pkgid = ?";
768 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
769 if (ret != SQLITE_OK) {
770 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
774 ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
775 if (ret != SQLITE_OK) {
776 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
782 if (sqlite3_step(stmt) != SQLITE_DONE) {
783 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
789 sqlite3_clear_bindings(stmt);
790 sqlite3_finalize(stmt);
793 static int db_insert_provider(struct dynamicbox *dynamicbox)
795 static const char *dml;
798 char *abi = (char *)dynamicbox->abi;
799 char *box_src = (char *)dynamicbox->dbox_src;
800 char *box_group = (char *)dynamicbox->dbox_group;
801 char *gbar_src = (char *)dynamicbox->gbar_src;
802 char *gbar_group = (char *)dynamicbox->gbar_group;
803 char *libexec = (char *)dynamicbox->libexec;
804 char *timeout = (char *)dynamicbox->timeout;
805 char *period = (char *)dynamicbox->period;
806 char *script = (char *)dynamicbox->script;
807 char *hw_acceleration = (char *)dynamicbox->hw_acceleration;
825 if (!hw_acceleration) {
826 hw_acceleration = "none";
829 dml = "INSERT INTO provider ( pkgid, network, abi, secured, box_type, box_src, box_group, gbar_type, gbar_src, gbar_group, libexec, timeout, period, script, pinup, count, direct_input, hw_acceleration) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
830 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
831 if (ret != SQLITE_OK) {
832 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
836 ret = sqlite3_bind_text(stmt, 1, (char *)dynamicbox->pkgid, -1, SQLITE_TRANSIENT);
837 if (ret != SQLITE_OK) {
838 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
843 ret = sqlite3_bind_int(stmt, 2, dynamicbox->network);
844 if (ret != SQLITE_OK) {
845 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
850 ret = sqlite3_bind_text(stmt, 3, abi, -1, SQLITE_TRANSIENT);
851 if (ret != SQLITE_OK) {
852 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
856 ret = sqlite3_bind_int(stmt, 4, dynamicbox->secured);
857 if (ret != SQLITE_OK) {
858 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
863 ret = sqlite3_bind_int(stmt, 5, dynamicbox->dbox_type);
864 if (ret != SQLITE_OK) {
865 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
870 ret = sqlite3_bind_text(stmt, 6, box_src, -1, SQLITE_TRANSIENT);
871 if (ret != SQLITE_OK) {
872 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
877 ret = sqlite3_bind_text(stmt, 7, box_group, -1, SQLITE_TRANSIENT);
878 if (ret != SQLITE_OK) {
879 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
884 ret = sqlite3_bind_int(stmt, 8, dynamicbox->gbar_type);
885 if (ret != SQLITE_OK) {
886 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
891 ret = sqlite3_bind_text(stmt, 9, gbar_src, -1, SQLITE_TRANSIENT);
892 if (ret != SQLITE_OK) {
893 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
898 ret = sqlite3_bind_text(stmt, 10, gbar_group, -1, SQLITE_TRANSIENT);
899 if (ret != SQLITE_OK) {
900 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
905 ret = sqlite3_bind_text(stmt, 11, libexec, -1, SQLITE_TRANSIENT);
906 if (ret != SQLITE_OK) {
907 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
912 ret = sqlite3_bind_int(stmt, 12, atoi(timeout));
913 if (ret != SQLITE_OK) {
914 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
919 ret = sqlite3_bind_text(stmt, 13, period, -1, SQLITE_TRANSIENT);
920 if (ret != SQLITE_OK) {
921 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
926 ret = sqlite3_bind_text(stmt, 14, script, -1, SQLITE_TRANSIENT);
927 if (ret != SQLITE_OK) {
928 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
933 ret = sqlite3_bind_int(stmt, 15, dynamicbox->pinup);
934 if (ret != SQLITE_OK) {
935 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
940 ret = sqlite3_bind_int(stmt, 16, dynamicbox->count);
941 if (ret != SQLITE_OK) {
942 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
947 ret = sqlite3_bind_int(stmt, 17, dynamicbox->direct_input);
948 if (ret != SQLITE_OK) {
949 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
954 ret = sqlite3_bind_text(stmt, 18, hw_acceleration, -1, SQLITE_TRANSIENT);
955 if (ret != SQLITE_OK) {
956 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
962 if (sqlite3_step(stmt) != SQLITE_DONE) {
963 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
969 sqlite3_clear_bindings(stmt);
970 sqlite3_finalize(stmt);
974 static inline int db_create_client(void)
977 static const char *ddl;
979 ddl = "CREATE TABLE client (" \
980 "pkgid TEXT PRIMARY KEY NOT NULL, icon TEXT, name TEXT, " \
981 "auto_launch TEXT, gbar_size TEXT, content TEXT, nodisplay INTEGER, setup TEXT, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE)";
982 if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
983 ErrPrint("Failed to execute the DDL (%s)\n", err);
987 if (sqlite3_changes(s_info.handle) == 0) {
988 ErrPrint("No changes to DB\n");
994 static inline int db_insert_client(struct dynamicbox *dynamicbox)
996 static const char *dml;
1000 dml = "INSERT INTO client ( pkgid, icon, name, auto_launch, gbar_size, content, nodisplay, setup ) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
1001 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
1002 if (ret != SQLITE_OK) {
1003 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1007 ret = sqlite3_bind_text(stmt, 1, (char *)dynamicbox->pkgid, -1, SQLITE_TRANSIENT);
1008 if (ret != SQLITE_OK) {
1009 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1014 ret = sqlite3_bind_text(stmt, 2, (char *)dynamicbox->icon, -1, SQLITE_TRANSIENT);
1015 if (ret != SQLITE_OK) {
1016 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1021 ret = sqlite3_bind_text(stmt, 3, (char *)dynamicbox->name, -1, SQLITE_TRANSIENT);
1022 if (ret != SQLITE_OK) {
1023 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1028 ret = sqlite3_bind_text(stmt, 4, (char *)dynamicbox->auto_launch, -1, SQLITE_TRANSIENT);
1029 if (ret != SQLITE_OK) {
1030 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1035 ret = sqlite3_bind_text(stmt, 5, (char *)dynamicbox->gbar_size, -1, SQLITE_TRANSIENT);
1036 if (ret != SQLITE_OK) {
1037 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1042 ret = sqlite3_bind_text(stmt, 6, (char *)dynamicbox->content, -1, SQLITE_TRANSIENT);
1043 if (ret != SQLITE_OK) {
1044 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1049 ret = sqlite3_bind_int(stmt, 7, dynamicbox->nodisplay);
1050 if (ret != SQLITE_OK) {
1051 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1056 ret = sqlite3_bind_text(stmt, 8, (char *)dynamicbox->setup, -1, SQLITE_TRANSIENT);
1057 if (ret != SQLITE_OK) {
1058 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1064 if (sqlite3_step(stmt) != SQLITE_DONE) {
1065 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1070 sqlite3_reset(stmt);
1071 sqlite3_clear_bindings(stmt);
1072 sqlite3_finalize(stmt);
1076 static inline int db_remove_client(const char *pkgid)
1078 static const char *dml;
1082 dml = "DELETE FROM client WHERE pkgid = ?";
1083 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
1084 if (ret != SQLITE_OK) {
1085 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
1089 ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
1090 if (ret != SQLITE_OK) {
1091 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
1097 if (sqlite3_step(stmt) != SQLITE_DONE) {
1098 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
1103 sqlite3_reset(stmt);
1104 sqlite3_clear_bindings(stmt);
1105 sqlite3_finalize(stmt);
1109 static inline int db_create_i18n(void)
1112 static const char *ddl;
1114 ddl = "CREATE TABLE i18n ( pkgid TEXT NOT NULL, lang TEXT COLLATE NOCASE, name TEXT, " \
1115 "icon TEXT, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE)";
1116 if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
1117 ErrPrint("Failed to execute the DDL (%s)\n", err);
1121 if (sqlite3_changes(s_info.handle) == 0) {
1122 ErrPrint("No changes to DB\n");
1128 static inline int db_insert_i18n(const char *pkgid, const char *lang, const char *name, const char *icon)
1130 static const char *dml;
1134 DbgPrint("%s - lang[%s] name[%s] icon[%s]\n", pkgid, lang, name, icon);
1135 dml = "INSERT INTO i18n ( pkgid, lang, name, icon ) VALUES (?, ?, ?, ?)";
1136 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
1137 if (ret != SQLITE_OK) {
1138 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1142 ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
1143 if (ret != SQLITE_OK) {
1144 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1149 ret = sqlite3_bind_text(stmt, 2, lang, -1, SQLITE_TRANSIENT);
1150 if (ret != SQLITE_OK) {
1151 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1156 ret = sqlite3_bind_text(stmt, 3, name, -1, SQLITE_TRANSIENT);
1157 if (ret != SQLITE_OK) {
1158 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1163 ret = sqlite3_bind_text(stmt, 4, icon, -1, SQLITE_TRANSIENT);
1164 if (ret != SQLITE_OK) {
1165 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1171 if (sqlite3_step(stmt) != SQLITE_DONE) {
1172 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1177 sqlite3_reset(stmt);
1178 sqlite3_clear_bindings(stmt);
1179 sqlite3_finalize(stmt);
1183 static inline int db_remove_i18n(const char *pkgid)
1185 static const char *dml;
1189 dml = "DELETE FROM i18n WHERE pkgid = ?";
1190 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
1191 if (ret != SQLITE_OK) {
1192 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
1196 ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
1197 if (ret != SQLITE_OK) {
1198 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
1204 if (sqlite3_step(stmt) != SQLITE_DONE) {
1205 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
1209 if (sqlite3_changes(s_info.handle) == 0) {
1210 DbgPrint("No changes\n");
1214 sqlite3_reset(stmt);
1215 sqlite3_clear_bindings(stmt);
1216 sqlite3_finalize(stmt);
1220 static inline int db_create_group(void)
1223 static const char *ddl;
1225 ddl = "CREATE TABLE groupinfo ( id INTEGER PRIMARY KEY AUTOINCREMENT, cluster TEXT NOT NULL, category TEXT NOT NULL, pkgid TEXT NOT NULL, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE)";
1226 if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
1227 ErrPrint("Failed to execute the DDL (%s)\n", err);
1231 if (sqlite3_changes(s_info.handle) == 0) {
1232 ErrPrint("No changes to DB\n");
1238 static inline int db_insert_group(const char *pkgid, const char *cluster, const char *category)
1240 static const char *dml;
1244 dml = "INSERT INTO groupinfo ( cluster, category, pkgid ) VALUES (?, ?, ?)";
1245 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
1246 if (ret != SQLITE_OK) {
1247 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1251 ret = sqlite3_bind_text(stmt, 1, cluster, -1, SQLITE_TRANSIENT);
1252 if (ret != SQLITE_OK) {
1253 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1258 ret = sqlite3_bind_text(stmt, 2, category, -1, SQLITE_TRANSIENT);
1259 if (ret != SQLITE_OK) {
1260 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1265 ret = sqlite3_bind_text(stmt, 3, pkgid, -1, SQLITE_TRANSIENT);
1266 if (ret != SQLITE_OK) {
1267 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1273 if (sqlite3_step(stmt) != SQLITE_DONE) {
1274 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1279 sqlite3_reset(stmt);
1280 sqlite3_clear_bindings(stmt);
1281 sqlite3_finalize(stmt);
1285 static int db_get_group_id(const char *cluster, const char *category)
1287 static const char *dml = "SELECT id FROM groupinfo WHERE cluster = ? AND category = ?";
1291 if (!cluster || !category) {
1292 ErrPrint("Invalid argument\n");
1296 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
1297 if (ret != SQLITE_OK) {
1298 ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle));
1303 if (sqlite3_bind_text(stmt, 1, cluster, -1, SQLITE_TRANSIENT) != SQLITE_OK) {
1304 ErrPrint("Failed to bind a cluster(%s) - %s\n", cluster, sqlite3_errmsg(s_info.handle));
1308 if (sqlite3_bind_text(stmt, 2, category, -1, SQLITE_TRANSIENT) != SQLITE_OK) {
1309 ErrPrint("Failed to bind a category(%s) - %s\n", category, sqlite3_errmsg(s_info.handle));
1313 if (sqlite3_step(stmt) != SQLITE_ROW) {
1314 ErrPrint("Failed to execute the DML for %s - %s\n", cluster, category);
1318 ret = sqlite3_column_int(stmt, 0);
1321 sqlite3_reset(stmt);
1322 sqlite3_clear_bindings(stmt);
1323 sqlite3_finalize(stmt);
1327 static inline int db_remove_group(const char *pkgid)
1329 static const char *dml;
1333 dml = "DELETE FROM groupinfo WHERE pkgid = ?";
1334 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
1335 if (ret != SQLITE_OK) {
1336 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
1340 ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
1341 if (ret != SQLITE_OK) {
1342 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
1348 if (sqlite3_step(stmt) != SQLITE_DONE) {
1349 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
1353 if (sqlite3_changes(s_info.handle) == 0) {
1354 DbgPrint("No changes\n");
1358 sqlite3_reset(stmt);
1359 sqlite3_clear_bindings(stmt);
1360 sqlite3_finalize(stmt);
1364 static inline int db_create_groupmap(void)
1367 static const char *ddl;
1369 ddl = "CREATE TABLE groupmap (option_id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER, pkgid TEXT NOT NULL, ctx_item TEXT NOT NULL, FOREIGN KEY(id) REFERENCES groupinfo(id), FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE)";
1370 if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
1371 ErrPrint("Failed to execute the DDL (%s)\n", err);
1375 if (sqlite3_changes(s_info.handle) == 0) {
1376 ErrPrint("No changes to DB\n");
1382 static inline int db_get_option_id(int id, const char *pkgid, const char *ctx_item)
1384 static const char *dml;
1388 dml = "SELECT option_id FROM groupmap WHERE id = ? AND pkgid = ? AND ctx_item = ?";
1389 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
1390 if (ret != SQLITE_OK) {
1391 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
1395 ret = sqlite3_bind_int(stmt, 1, id);
1396 if (ret != SQLITE_OK) {
1397 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
1402 ret = sqlite3_bind_text(stmt, 2, pkgid, -1, SQLITE_TRANSIENT);
1403 if (ret != SQLITE_OK) {
1404 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
1409 ret = sqlite3_bind_text(stmt, 3, ctx_item, -1, SQLITE_TRANSIENT);
1410 if (ret != SQLITE_OK) {
1411 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
1417 if (sqlite3_step(stmt) != SQLITE_ROW) {
1418 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
1423 ret = sqlite3_column_int(stmt, 0);
1426 sqlite3_reset(stmt);
1427 sqlite3_clear_bindings(stmt);
1428 sqlite3_finalize(stmt);
1432 static inline int db_insert_groupmap(int id, const char *pkgid, const char *ctx_item)
1434 static const char *dml;
1438 DbgPrint("%d (%s) add to groupmap\n", id, pkgid);
1440 dml = "INSERT INTO groupmap ( id, pkgid, ctx_item ) VALUES (?, ?, ?)";
1441 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
1442 if (ret != SQLITE_OK) {
1443 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1447 ret = sqlite3_bind_int(stmt, 1, id);
1448 if (ret != SQLITE_OK) {
1449 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1454 ret = sqlite3_bind_text(stmt, 2, pkgid, -1, SQLITE_TRANSIENT);
1455 if (ret != SQLITE_OK) {
1456 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1461 ret = sqlite3_bind_text(stmt, 3, ctx_item, -1, SQLITE_TRANSIENT);
1462 if (ret != SQLITE_OK) {
1463 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1469 if (sqlite3_step(stmt) != SQLITE_DONE) {
1470 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1475 sqlite3_reset(stmt);
1476 sqlite3_clear_bindings(stmt);
1477 sqlite3_finalize(stmt);
1481 static inline int db_remove_groupmap(const char *pkgid)
1483 static const char *dml;
1487 dml = "DELETE FROM groupmap WHERE pkgid = ?";
1488 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
1489 if (ret != SQLITE_OK) {
1490 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
1494 ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
1495 if (ret != SQLITE_OK) {
1496 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
1502 if (sqlite3_step(stmt) != SQLITE_DONE) {
1503 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
1507 if (sqlite3_changes(s_info.handle) == 0) {
1508 DbgPrint("No changes\n");
1512 sqlite3_reset(stmt);
1513 sqlite3_clear_bindings(stmt);
1514 sqlite3_finalize(stmt);
1518 static inline int db_create_option(void)
1521 static const char *ddl;
1523 ddl = "CREATE TABLE option ( pkgid TEXT NOT NULL, option_id INTEGER, key TEXT NOT NULL, value TEXT NOT NULL, " \
1524 "FOREIGN KEY(option_id) REFERENCES groupmap(option_id), " \
1525 "FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE)";
1526 if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
1527 ErrPrint("Failed to execute the DDL (%s)\n", err);
1531 if (sqlite3_changes(s_info.handle) == 0) {
1532 ErrPrint("No changes to DB\n");
1538 static inline int db_insert_option(const char *pkgid, int option_id, const char *key, const char *value)
1540 static const char *dml;
1544 dml = "INSERT INTO option (pkgid, option_id, key, value) VALUES (?, ?, ?, ?)";
1545 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
1546 if (ret != SQLITE_OK) {
1547 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1551 ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
1552 if (ret != SQLITE_OK) {
1553 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1558 ret = sqlite3_bind_int(stmt, 2, option_id);
1559 if (ret != SQLITE_OK) {
1560 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1565 ret = sqlite3_bind_text(stmt, 3, key, -1, SQLITE_TRANSIENT);
1566 if (ret != SQLITE_OK) {
1567 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1572 ret = sqlite3_bind_text(stmt, 4, value, -1, SQLITE_TRANSIENT);
1573 if (ret != SQLITE_OK) {
1574 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1580 if (sqlite3_step(stmt) != SQLITE_DONE) {
1581 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1585 sqlite3_reset(stmt);
1586 sqlite3_clear_bindings(stmt);
1587 sqlite3_finalize(stmt);
1591 static inline int db_remove_option(const char *pkgid)
1593 static const char *dml;
1597 dml = "DELETE FROM option WHERE pkgid = ?";
1598 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
1599 if (ret != SQLITE_OK) {
1600 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
1604 ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
1605 if (ret != SQLITE_OK) {
1606 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
1612 if (sqlite3_step(stmt) != SQLITE_DONE) {
1613 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
1617 if (sqlite3_changes(s_info.handle) == 0) {
1618 DbgPrint("No changes\n");
1622 sqlite3_reset(stmt);
1623 sqlite3_clear_bindings(stmt);
1624 sqlite3_finalize(stmt);
1628 static inline int db_create_box_size(void)
1631 static const char *ddl;
1633 ddl = "CREATE TABLE box_size ( pkgid TEXT NOT NULL, size_type INTEGER, preview TEXT, touch_effect INTEGER, need_frame INTEGER, mouse_event INTEGER " \
1634 "FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE)";
1635 if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
1636 ErrPrint("Failed to execute the DDL (%s)\n", err);
1640 if (sqlite3_changes(s_info.handle) == 0) {
1641 ErrPrint("No changes to DB\n");
1647 static int db_insert_box_size(const char *pkgid, int size_type, const char *preview, int touch_effect, int need_frame, int mouse_event)
1649 static const char *dml;
1653 DbgPrint("box size: %s - %d (%s) is added\n", pkgid, size_type, preview);
1654 dml = "INSERT INTO box_size ( pkgid, size_type, preview, touch_effect, need_frame, mouse_event ) VALUES (?, ?, ?, ?, ?, ?)";
1655 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
1656 if (ret != SQLITE_OK) {
1657 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1661 ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
1662 if (ret != SQLITE_OK) {
1663 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1668 ret = sqlite3_bind_int(stmt, 2, size_type);
1669 if (ret != SQLITE_OK) {
1670 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1675 ret = sqlite3_bind_text(stmt, 3, preview, -1, SQLITE_TRANSIENT);
1676 if (ret != SQLITE_OK) {
1677 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1682 ret = sqlite3_bind_int(stmt, 4, touch_effect);
1683 if (ret != SQLITE_OK) {
1684 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1689 ret = sqlite3_bind_int(stmt, 5, need_frame);
1690 if (ret != SQLITE_OK) {
1691 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1696 ret = sqlite3_bind_int(stmt, 6, mouse_event);
1697 if (ret != SQLITE_OK) {
1698 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1704 if (sqlite3_step(stmt) != SQLITE_DONE) {
1705 ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
1710 sqlite3_reset(stmt);
1711 sqlite3_clear_bindings(stmt);
1712 sqlite3_finalize(stmt);
1716 static inline int db_remove_box_size(const char *pkgid)
1718 static const char *dml;
1722 dml = "DELETE FROM box_size WHERE pkgid = ?";
1723 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
1724 if (ret != SQLITE_OK) {
1725 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
1729 ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
1730 if (ret != SQLITE_OK) {
1731 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
1737 if (sqlite3_step(stmt) != SQLITE_DONE) {
1738 DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
1742 if (sqlite3_changes(s_info.handle) == 0) {
1743 DbgPrint("No changes\n");
1747 sqlite3_reset(stmt);
1748 sqlite3_clear_bindings(stmt);
1749 sqlite3_finalize(stmt);
1753 static inline void db_create_table(void)
1756 begin_transaction();
1758 ret = db_create_pkgmap();
1760 rollback_transaction();
1764 ret = db_create_provider();
1766 rollback_transaction();
1770 ret = db_create_client();
1772 rollback_transaction();
1776 ret = db_create_i18n();
1778 rollback_transaction();
1782 ret = db_create_box_size();
1784 rollback_transaction();
1788 ret = db_create_group();
1790 rollback_transaction();
1794 ret = db_create_option();
1796 rollback_transaction();
1800 ret = db_create_groupmap();
1802 rollback_transaction();
1806 commit_transaction();
1809 static int db_init(void)
1814 ret = db_util_open(s_info.dbfile, &s_info.handle, DB_UTIL_REGISTER_HOOK_METHOD);
1815 if (ret != SQLITE_OK) {
1816 ErrPrint("Failed to open a DB\n");
1820 if (lstat(s_info.dbfile, &stat) < 0) {
1821 ErrPrint("%s\n", strerror(errno));
1822 db_util_close(s_info.handle);
1823 s_info.handle = NULL;
1827 if (!S_ISREG(stat.st_mode)) {
1828 ErrPrint("Invalid file\n");
1829 db_util_close(s_info.handle);
1830 s_info.handle = NULL;
1834 if (!stat.st_size) {
1841 static inline int db_fini(void)
1843 if (!s_info.handle) {
1847 db_util_close(s_info.handle);
1848 s_info.handle = NULL;
1853 static inline int validate_pkgid(const char *appid, const char *pkgid)
1855 /* Just return 1 Always */
1856 return 1 || !strncmp(appid, pkgid, strlen(appid));
1859 static int dynamicbox_destroy(struct dynamicbox *dynamicbox)
1864 struct group *group;
1865 struct option *option;
1869 xmlFree(dynamicbox->auto_launch);
1870 xmlFree(dynamicbox->pkgid);
1871 xmlFree(dynamicbox->abi);
1872 xmlFree(dynamicbox->name);
1873 xmlFree(dynamicbox->icon);
1874 xmlFree(dynamicbox->dbox_src);
1875 xmlFree(dynamicbox->dbox_group);
1876 xmlFree(dynamicbox->gbar_src);
1877 xmlFree(dynamicbox->gbar_group);
1878 xmlFree(dynamicbox->gbar_size);
1879 xmlFree(dynamicbox->libexec);
1880 xmlFree(dynamicbox->script);
1881 xmlFree(dynamicbox->period);
1882 xmlFree(dynamicbox->content);
1883 xmlFree(dynamicbox->setup);
1884 xmlFree(dynamicbox->category);
1885 xmlFree(dynamicbox->preview[0]); /* 1x1 */
1886 xmlFree(dynamicbox->preview[1]); /* 2x1 */
1887 xmlFree(dynamicbox->preview[2]); /* 2x2 */
1888 xmlFree(dynamicbox->preview[3]); /* 4x1 */
1889 xmlFree(dynamicbox->preview[4]); /* 4x2 */
1890 xmlFree(dynamicbox->preview[5]); /* 4x3 */
1891 xmlFree(dynamicbox->preview[6]); /* 4x4 */
1892 xmlFree(dynamicbox->preview[7]); /* 4x5 */
1893 xmlFree(dynamicbox->preview[8]); /* 4x6 */
1894 xmlFree(dynamicbox->preview[9]); /* easy 1x1 */
1895 xmlFree(dynamicbox->preview[10]); /* easy 3x1 */
1896 xmlFree(dynamicbox->preview[11]); /* easy 3x3 */
1897 xmlFree(dynamicbox->preview[12]); /* full */
1898 xmlFree(dynamicbox->hw_acceleration);
1900 dlist_foreach_safe(dynamicbox->i18n_list, l, n, i18n) {
1901 dynamicbox->i18n_list = dlist_remove(dynamicbox->i18n_list, l);
1902 xmlFree(i18n->name);
1903 xmlFree(i18n->icon);
1904 xmlFree(i18n->lang);
1908 dlist_foreach_safe(dynamicbox->group_list, l, n, group) {
1909 dynamicbox->group_list = dlist_remove(dynamicbox->group_list, l);
1910 DbgPrint("Release %s/%s\n", group->cluster, group->category);
1912 if (group->ctx_item) {
1913 dlist_foreach_safe(group->option_list, il, in, option) {
1914 group->option_list = dlist_remove(group->option_list, il);
1915 DbgPrint("Release option %s(%s)\n", option->key, option->value);
1916 xmlFree(option->key);
1917 xmlFree(option->value);
1920 xmlFree(group->ctx_item);
1923 xmlFree(group->cluster);
1924 xmlFree(group->category);
1932 static inline void update_i18n_name(struct dynamicbox *dynamicbox, xmlNodePtr node)
1939 name = xmlNodeGetContent(node);
1941 ErrPrint("Invalid tag\n");
1945 lang = xmlNodeGetLang(node);
1947 if (dynamicbox->name) {
1948 DbgPrint("Override default name: %s\n", dynamicbox->name);
1949 xmlFree(dynamicbox->name);
1952 dynamicbox->name = name;
1956 dlist_foreach(dynamicbox->i18n_list, l, i18n) {
1957 if (!xmlStrcasecmp(i18n->lang, lang)) {
1959 DbgPrint("Override name: %s\n", i18n->name);
1960 xmlFree(i18n->name);
1968 i18n = calloc(1, sizeof(*i18n));
1970 ErrPrint("Heap: %s\n", strerror(errno));
1978 DbgPrint("Label[%s] - [%s] added\n", i18n->lang, i18n->name);
1979 dynamicbox->i18n_list = dlist_append(dynamicbox->i18n_list, i18n);
1982 static inline void update_i18n_icon(struct dynamicbox *dynamicbox, xmlNodePtr node)
1989 icon = xmlNodeGetContent(node);
1991 ErrPrint("Invalid tag\n");
1995 lang = xmlNodeGetLang(node);
1997 if (dynamicbox->icon) {
1998 DbgPrint("Override default icon: %s\n", dynamicbox->icon);
1999 xmlFree(dynamicbox->icon);
2002 dynamicbox->icon = icon;
2006 dlist_foreach(dynamicbox->i18n_list, l, i18n) {
2007 if (!xmlStrcasecmp(i18n->lang, lang)) {
2009 DbgPrint("Override icon %s for %s\n", i18n->icon, i18n->name);
2010 xmlFree(i18n->icon);
2018 i18n = calloc(1, sizeof(*i18n));
2020 ErrPrint("Heap: %s\n", strerror(errno));
2028 DbgPrint("Icon[%s] - [%s] added\n", i18n->lang, i18n->icon);
2029 dynamicbox->i18n_list = dlist_append(dynamicbox->i18n_list, i18n);
2032 static inline void update_launch(struct dynamicbox *dynamicbox, xmlNodePtr node)
2036 launch = xmlNodeGetContent(node);
2038 DbgPrint("Has no launch\n");
2042 if (dynamicbox->auto_launch) {
2043 xmlFree(dynamicbox->auto_launch);
2046 dynamicbox->auto_launch = xmlStrdup(launch);
2047 if (!dynamicbox->auto_launch) {
2048 ErrPrint("Failed to duplicate string: %s\n", (char *)launch);
2053 static inline void update_category(struct dynamicbox *dynamicbox, xmlNodePtr node)
2057 category = xmlGetProp(node, (const xmlChar *)"name");
2059 DbgPrint("Has no valid category\n");
2063 if (dynamicbox->category) {
2064 xmlFree(dynamicbox->category);
2067 dynamicbox->category = xmlStrdup(category);
2068 if (!dynamicbox->category) {
2069 ErrPrint("Failed to duplicate string: %s\n", (char *)category);
2074 static inline void update_ui_appid(struct dynamicbox *dynamicbox, xmlNodePtr node)
2077 uiapp = xmlNodeGetContent(node);
2079 DbgPrint("Has no valid ui-appid\n");
2083 if (dynamicbox->uiapp) {
2084 xmlFree(dynamicbox->uiapp);
2087 dynamicbox->uiapp = xmlStrdup(uiapp);
2088 if (!dynamicbox->uiapp) {
2089 ErrPrint("Failed to duplicate string: %s\n", (char *)uiapp);
2094 static inline void update_setup(struct dynamicbox *dynamicbox, xmlNodePtr node)
2097 setup = xmlNodeGetContent(node);
2099 DbgPrint("Has no setup\n");
2103 if (dynamicbox->setup) {
2104 xmlFree(dynamicbox->setup);
2107 dynamicbox->setup = xmlStrdup(setup);
2108 if (!dynamicbox->setup) {
2109 ErrPrint("Failed to duplicate string: %s\n", (char *)setup);
2114 static inline void update_content(struct dynamicbox *dynamicbox, xmlNodePtr node)
2117 content = xmlNodeGetContent(node);
2119 DbgPrint("Has no content\n");
2123 if (dynamicbox->content) {
2124 xmlFree(dynamicbox->content);
2127 dynamicbox->content = xmlStrdup(content);
2128 if (!dynamicbox->content) {
2129 ErrPrint("Failed to duplicate string: %s\n", (char *)content);
2134 static void update_size_info(struct dynamicbox *dynamicbox, int idx, xmlNodePtr node)
2136 if (xmlHasProp(node, (const xmlChar *)"preview")) {
2137 dynamicbox->preview[idx] = xmlGetProp(node, (const xmlChar *)"preview");
2140 if (xmlHasProp(node, (const xmlChar *)"need_frame")) {
2141 xmlChar *need_frame;
2143 need_frame = xmlGetProp(node, (const xmlChar *)"need_frame");
2145 dynamicbox->need_frame[idx] = !xmlStrcasecmp(need_frame, (const xmlChar *)"true");
2146 xmlFree(need_frame);
2148 dynamicbox->need_frame[idx] = dynamicbox->default_need_frame;
2151 dynamicbox->need_frame[idx] = dynamicbox->default_need_frame;
2154 if (xmlHasProp(node, (const xmlChar *)"touch_effect")) {
2155 xmlChar *touch_effect;
2157 touch_effect = xmlGetProp(node, (const xmlChar *)"touch_effect");
2159 dynamicbox->touch_effect[idx] = !xmlStrcasecmp(touch_effect, (const xmlChar *)"true");
2160 xmlFree(touch_effect);
2162 dynamicbox->touch_effect[idx] = dynamicbox->default_touch_effect;
2165 dynamicbox->touch_effect[idx] = dynamicbox->default_touch_effect;
2168 if (xmlHasProp(node, (const xmlChar *)"mouse_event")) {
2169 xmlChar *mouse_event;
2171 mouse_event = xmlGetProp(node, (const xmlChar *)"mouse_event");
2173 dynamicbox->mouse_event[idx] = !xmlStrcasecmp(mouse_event, (const xmlChar *)"true");
2174 xmlFree(mouse_event);
2176 dynamicbox->mouse_event[idx] = dynamicbox->default_mouse_event;
2179 dynamicbox->mouse_event[idx] = dynamicbox->default_mouse_event;
2183 static void update_box(struct dynamicbox *dynamicbox, xmlNodePtr node)
2185 if (!xmlHasProp(node, (const xmlChar *)"type")) {
2186 dynamicbox->dbox_type = DBOX_TYPE_FILE;
2190 type = xmlGetProp(node, (const xmlChar *)"type");
2192 ErrPrint("Type is NIL\n");
2193 dynamicbox->dbox_type = DBOX_TYPE_FILE;
2195 if (!xmlStrcasecmp(type, (const xmlChar *)"text")) {
2196 dynamicbox->dbox_type = DBOX_TYPE_TEXT;
2197 } else if (!xmlStrcasecmp(type, (const xmlChar *)"buffer")) {
2198 dynamicbox->dbox_type = DBOX_TYPE_BUFFER;
2199 } else if (!xmlStrcasecmp(type, (const xmlChar *)"script")) {
2200 dynamicbox->dbox_type = DBOX_TYPE_SCRIPT;
2201 } else if (!xmlStrcasecmp(type, (const xmlChar *)"elm")) {
2202 dynamicbox->dbox_type = DBOX_TYPE_UIFW;
2203 } else { /* Default */
2204 dynamicbox->dbox_type = DBOX_TYPE_FILE;
2211 if (!xmlHasProp(node, (const xmlChar *)"mouse_event")) {
2212 dynamicbox->default_mouse_event = 0;
2214 xmlChar *mouse_event;
2216 mouse_event = xmlGetProp(node, (const xmlChar *)"mouse_event");
2218 ErrPrint("mouse_event is NIL\n");
2219 dynamicbox->default_mouse_event = 0;
2221 dynamicbox->default_mouse_event = !xmlStrcasecmp(mouse_event, (const xmlChar *)"true");
2222 xmlFree(mouse_event);
2226 if (!xmlHasProp(node, (const xmlChar *)"touch_effect")) {
2227 dynamicbox->default_touch_effect = 1;
2229 xmlChar *touch_effect;
2231 touch_effect = xmlGetProp(node, (const xmlChar *)"touch_effect");
2232 if (!touch_effect) {
2233 ErrPrint("default touch_effect is NIL\n");
2234 dynamicbox->default_touch_effect = 1;
2236 dynamicbox->default_touch_effect = !xmlStrcasecmp(touch_effect, (const xmlChar *)"true");
2237 xmlFree(touch_effect);
2241 if (!xmlHasProp(node, (const xmlChar *)"need_frame")) {
2242 dynamicbox->default_need_frame = 0;
2244 xmlChar *need_frame;
2246 need_frame = xmlGetProp(node, (const xmlChar *)"need_frame");
2248 ErrPrint("default need_frame is NIL\n");
2249 dynamicbox->default_need_frame = 0;
2251 dynamicbox->default_need_frame = !xmlStrcasecmp(need_frame, (const xmlChar *)"true");
2252 xmlFree(need_frame);
2256 for (node = node->children; node; node = node->next) {
2257 if (!xmlStrcasecmp(node->name, (const xmlChar *)"size")) {
2261 size = xmlNodeGetContent(node);
2263 ErrPrint("Invalid size tag\n");
2267 if (xmlHasProp(node, (const xmlChar *)"mode")) {
2269 mode = xmlGetProp(node, (const xmlChar *)"mode");
2271 DbgPrint("Easy mode: %s\n", mode);
2272 is_easy = !xmlStrcasecmp(mode, (const xmlChar *)"easy");
2277 if (!xmlStrcasecmp(size, (const xmlChar *)"1x1")) {
2279 dynamicbox->size_list |= DBOX_SIZE_TYPE_EASY_1x1;
2280 update_size_info(dynamicbox, 9, node);
2282 dynamicbox->size_list |= DBOX_SIZE_TYPE_1x1;
2283 update_size_info(dynamicbox, 0, node);
2285 } else if (!xmlStrcasecmp(size, (const xmlChar *)"3x1")) {
2287 dynamicbox->size_list |= DBOX_SIZE_TYPE_EASY_3x1;
2288 update_size_info(dynamicbox, 10, node);
2290 ErrPrint("Invalid size tag (%s)\n", size);
2292 } else if (!xmlStrcasecmp(size, (const xmlChar *)"3x3")) {
2294 dynamicbox->size_list |= DBOX_SIZE_TYPE_EASY_3x3;
2295 update_size_info(dynamicbox, 11, node);
2297 ErrPrint("Invalid size tag (%s)\n", size);
2299 } else if (!xmlStrcasecmp(size, (const xmlChar *)"2x1")) {
2300 dynamicbox->size_list |= DBOX_SIZE_TYPE_2x1;
2301 update_size_info(dynamicbox, 1, node);
2302 } else if (!xmlStrcasecmp(size, (const xmlChar *)"2x2")) {
2303 dynamicbox->size_list |= DBOX_SIZE_TYPE_2x2;
2304 update_size_info(dynamicbox, 2, node);
2305 } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x1")) {
2306 dynamicbox->size_list |= DBOX_SIZE_TYPE_4x1;
2307 update_size_info(dynamicbox, 3, node);
2308 } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x2")) {
2309 dynamicbox->size_list |= DBOX_SIZE_TYPE_4x2;
2310 update_size_info(dynamicbox, 4, node);
2311 } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x3")) {
2312 dynamicbox->size_list |= DBOX_SIZE_TYPE_4x3;
2313 update_size_info(dynamicbox, 5, node);
2314 } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x4")) {
2315 dynamicbox->size_list |= DBOX_SIZE_TYPE_4x4;
2316 update_size_info(dynamicbox, 6, node);
2317 } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x5")) {
2318 dynamicbox->size_list |= DBOX_SIZE_TYPE_4x5;
2319 update_size_info(dynamicbox, 7, node);
2320 } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x6")) {
2321 dynamicbox->size_list |= DBOX_SIZE_TYPE_4x6;
2322 update_size_info(dynamicbox, 8, node);
2323 } else if (!xmlStrcasecmp(size, (const xmlChar *)"21x21")) {
2324 dynamicbox->size_list |= DBOX_SIZE_TYPE_EASY_1x1;
2325 update_size_info(dynamicbox, 9, node);
2326 } else if (!xmlStrcasecmp(size, (const xmlChar *)"23x21")) {
2327 dynamicbox->size_list |= DBOX_SIZE_TYPE_EASY_3x1;
2328 update_size_info(dynamicbox, 10, node);
2329 } else if (!xmlStrcasecmp(size, (const xmlChar *)"23x23")) {
2330 dynamicbox->size_list |= DBOX_SIZE_TYPE_EASY_3x3;
2331 update_size_info(dynamicbox, 11, node);
2332 } else if (!xmlStrcasecmp(size, (const xmlChar *)"0x0")) {
2333 dynamicbox->size_list |= DBOX_SIZE_TYPE_0x0;
2334 update_size_info(dynamicbox, 12, node);
2336 ErrPrint("Invalid size tag (%s)\n", size);
2340 } else if (!xmlStrcasecmp(node->name, (const xmlChar *)"script")) {
2343 if (!xmlHasProp(node, (const xmlChar *)"src")) {
2344 ErrPrint("Invalid script tag. has no src\n");
2348 src = xmlGetProp(node, (const xmlChar *)"src");
2350 ErrPrint("Invalid script tag. src is NIL\n");
2354 if (dynamicbox->dbox_src) {
2355 DbgPrint("Override lb src: %s\n", dynamicbox->dbox_src);
2356 xmlFree(dynamicbox->dbox_src);
2359 dynamicbox->dbox_src = src;
2361 if (xmlHasProp(node, (const xmlChar *)"group")) {
2363 group = xmlGetProp(node, (const xmlChar *)"group");
2365 ErrPrint("Group is NIL\n");
2367 if (dynamicbox->dbox_group) {
2368 DbgPrint("Override lb group: %s\n", dynamicbox->dbox_group);
2369 xmlFree(dynamicbox->dbox_group);
2372 dynamicbox->dbox_group = group;
2379 static inline void update_group(struct dynamicbox *dynamicbox, xmlNodePtr node)
2382 xmlNodePtr category;
2383 xmlNodePtr option_item;
2384 xmlChar *cluster_name;
2385 xmlChar *category_name;
2391 struct group *group;
2392 struct option *option;
2395 for (cluster = cluster->children; cluster; cluster = cluster->next) {
2396 if (xmlStrcasecmp(cluster->name, (const xmlChar *)"cluster")) {
2397 DbgPrint("Skip: %s\n", cluster->name);
2401 if (!xmlHasProp(cluster, (const xmlChar *)"name")) {
2402 ErrPrint("Invalid cluster, has no name\n");
2406 cluster_name = xmlGetProp(cluster, (const xmlChar *)"name");
2407 if (!cluster_name) {
2408 ErrPrint("Invalid cluster name. NIL\n");
2412 for (category = cluster->children; category; category = category->next) {
2413 if (xmlStrcasecmp(category->name, (const xmlChar *)"category")) {
2414 DbgPrint("Skip: %s\n", category->name);
2418 if (!xmlHasProp(category, (const xmlChar *)"name")) {
2419 ErrPrint("Invalid category, has no name\n");
2423 category_name = xmlGetProp(category, (const xmlChar *)"name");
2424 if (!category_name) {
2425 ErrPrint("Invalid category name. NIL\n");
2429 group = calloc(1, sizeof(*group));
2431 ErrPrint("Heap: %s\n", strerror(errno));
2432 xmlFree(category_name);
2436 group->cluster = xmlStrdup(cluster_name);
2437 if (!group->cluster) {
2438 ErrPrint("Heap: %s\n", strerror(errno));
2439 xmlFree(category_name);
2444 group->category = category_name;
2445 dynamicbox->group_list = dlist_append(dynamicbox->group_list, group);
2447 if (!xmlHasProp(category, (const xmlChar *)"context")) {
2448 DbgPrint("%s, %s has no ctx info\n", group->cluster, group->category);
2452 ctx_item = xmlGetProp(category, (const xmlChar *)"context");
2454 ErrPrint("Failed to get context ID (%s, %s)\n", group->cluster, group->category);
2458 group->ctx_item = ctx_item;
2459 DbgPrint("Build group item: %s - %s - %s\n", group->cluster, group->category, group->ctx_item);
2461 for (option_item = category->children; option_item; option_item = option_item->next) {
2462 if (xmlStrcasecmp(option_item->name, (const xmlChar *)"option")) {
2463 DbgPrint("Skip: %s\n", option_item->name);
2467 if (!xmlHasProp(option_item, (const xmlChar *)"key")) {
2468 ErrPrint("Invalid option, has no key\n");
2472 if (!xmlHasProp(option_item, (const xmlChar *)"value")) {
2473 ErrPrint("Invalid option, has no value\n");
2477 key = xmlGetProp(option_item, (const xmlChar *)"key");
2479 ErrPrint("Invalid key. NIL\n");
2483 value = xmlGetProp(option_item, (const xmlChar *)"value");
2485 ErrPrint("Invalid valid. NIL\n");
2490 option = calloc(1, sizeof(*option));
2492 ErrPrint("Heap: %s\n", strerror(errno));
2499 option->value = value;
2501 group->option_list = dlist_append(group->option_list, option);
2505 xmlFree(cluster_name);
2509 static inline void update_pd(struct dynamicbox *dynamicbox, xmlNodePtr node)
2511 if (!xmlHasProp(node, (const xmlChar *)"type")) {
2512 dynamicbox->gbar_type = GBAR_TYPE_SCRIPT;
2516 type = xmlGetProp(node, (const xmlChar *)"type");
2518 ErrPrint("type is NIL\n");
2522 if (!xmlStrcasecmp(type, (const xmlChar *)"text")) {
2523 dynamicbox->gbar_type = GBAR_TYPE_TEXT;
2524 } else if (!xmlStrcasecmp(type, (const xmlChar *)"buffer")) {
2525 dynamicbox->gbar_type = GBAR_TYPE_BUFFER;
2526 } else if (!xmlStrcasecmp(type, (const xmlChar *)"elm")) {
2527 dynamicbox->gbar_type = GBAR_TYPE_UIFW;
2529 dynamicbox->gbar_type = GBAR_TYPE_SCRIPT;
2535 for (node = node->children; node; node = node->next) {
2536 if (!xmlStrcasecmp(node->name, (const xmlChar *)"size")) {
2539 size = xmlNodeGetContent(node);
2541 ErrPrint("Invalid size tag\n");
2545 if (dynamicbox->gbar_size) {
2546 DbgPrint("Override pd size: %s\n", dynamicbox->gbar_size);
2547 xmlFree(dynamicbox->gbar_size);
2549 dynamicbox->gbar_size = size;
2550 } else if (!xmlStrcasecmp(node->name, (const xmlChar *)"script")) {
2553 if (!xmlHasProp(node, (const xmlChar *)"src")) {
2554 ErrPrint("Invalid script tag, has no src\n");
2558 src = xmlGetProp(node, (const xmlChar *)"src");
2560 ErrPrint("src is NIL\n");
2564 if (dynamicbox->gbar_src) {
2565 DbgPrint("Overide PD src: %s\n", dynamicbox->gbar_src);
2566 xmlFree(dynamicbox->gbar_src);
2569 dynamicbox->gbar_src = src;
2571 if (xmlHasProp(node, (const xmlChar *)"group")) {
2573 group = xmlGetProp(node, (const xmlChar *)"group");
2575 ErrPrint("Group is NIL\n");
2577 if (dynamicbox->gbar_group) {
2578 DbgPrint("Override PD group : %s\n", dynamicbox->gbar_group);
2579 xmlFree(dynamicbox->gbar_group);
2582 dynamicbox->gbar_group = group;
2589 static int db_insert_dynamicbox(struct dynamicbox *dynamicbox, const char *appid)
2594 struct group *group;
2597 struct option *option;
2599 begin_transaction();
2600 ret = db_insert_pkgmap(appid, (char *)dynamicbox->pkgid, (char *)dynamicbox->uiapp, dynamicbox->primary, (char *)dynamicbox->category);
2605 ret = db_insert_provider(dynamicbox);
2610 ret = db_insert_client(dynamicbox);
2615 dlist_foreach(dynamicbox->i18n_list, l, i18n) {
2616 ret = db_insert_i18n((char *)dynamicbox->pkgid, (char *)i18n->lang, (char *)i18n->name, (char *)i18n->icon);
2622 if (dynamicbox->size_list & DBOX_SIZE_TYPE_1x1) {
2623 ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_1x1, (char *)dynamicbox->preview[0], dynamicbox->touch_effect[0], dynamicbox->need_frame[0], dynamicbox->mouse_event[0]);
2629 if (dynamicbox->size_list & DBOX_SIZE_TYPE_2x1) {
2630 ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_2x1, (char *)dynamicbox->preview[1], dynamicbox->touch_effect[1], dynamicbox->need_frame[1], dynamicbox->mouse_event[1]);
2636 if (dynamicbox->size_list & DBOX_SIZE_TYPE_2x2) {
2637 ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_2x2, (char *)dynamicbox->preview[2], dynamicbox->touch_effect[2], dynamicbox->need_frame[2], dynamicbox->mouse_event[2]);
2643 if (dynamicbox->size_list & DBOX_SIZE_TYPE_4x1) {
2644 ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_4x1, (char *)dynamicbox->preview[3], dynamicbox->touch_effect[3], dynamicbox->need_frame[3], dynamicbox->mouse_event[3]);
2650 if (dynamicbox->size_list & DBOX_SIZE_TYPE_4x2) {
2651 ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_4x2, (char *)dynamicbox->preview[4], dynamicbox->touch_effect[4], dynamicbox->need_frame[4], dynamicbox->mouse_event[4]);
2657 if (dynamicbox->size_list & DBOX_SIZE_TYPE_4x3) {
2658 ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_4x3, (char *)dynamicbox->preview[5], dynamicbox->touch_effect[5], dynamicbox->need_frame[5], dynamicbox->mouse_event[5]);
2664 if (dynamicbox->size_list & DBOX_SIZE_TYPE_4x4) {
2665 ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_4x4, (char *)dynamicbox->preview[6], dynamicbox->touch_effect[6], dynamicbox->need_frame[6], dynamicbox->mouse_event[6]);
2671 if (dynamicbox->size_list & DBOX_SIZE_TYPE_4x5) {
2672 ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_4x5, (char *)dynamicbox->preview[7], dynamicbox->touch_effect[7], dynamicbox->need_frame[7], dynamicbox->mouse_event[7]);
2678 if (dynamicbox->size_list & DBOX_SIZE_TYPE_4x6) {
2679 ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_4x6, (char *)dynamicbox->preview[8], dynamicbox->touch_effect[8], dynamicbox->need_frame[8], dynamicbox->mouse_event[8]);
2685 if (dynamicbox->size_list & DBOX_SIZE_TYPE_EASY_1x1) {
2686 ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_EASY_1x1, (char *)dynamicbox->preview[9], dynamicbox->touch_effect[9], dynamicbox->need_frame[9], dynamicbox->mouse_event[9]);
2692 if (dynamicbox->size_list & DBOX_SIZE_TYPE_EASY_3x1) {
2693 ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_EASY_3x1, (char *)dynamicbox->preview[10], dynamicbox->touch_effect[10], dynamicbox->need_frame[10], dynamicbox->mouse_event[10]);
2699 if (dynamicbox->size_list & DBOX_SIZE_TYPE_EASY_3x3) {
2700 ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_EASY_3x3, (char *)dynamicbox->preview[11], dynamicbox->touch_effect[11], dynamicbox->need_frame[11], dynamicbox->mouse_event[11]);
2706 if (dynamicbox->size_list & DBOX_SIZE_TYPE_0x0) {
2707 ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_0x0, (char *)dynamicbox->preview[12], dynamicbox->touch_effect[12], dynamicbox->need_frame[12], dynamicbox->mouse_event[12]);
2713 dlist_foreach(dynamicbox->group_list, l, group) {
2715 id = db_get_group_id((char *)group->cluster, (char *)group->category);
2719 ret = db_insert_group((char *)dynamicbox->pkgid, (char *)group->cluster, (char *)group->category);
2721 ErrPrint("[%s]-[%s] is not exists\n", group->cluster, group->category);
2725 DbgPrint("New group name is built - %s/%s\n", group->cluster, group->category);
2726 id = db_get_group_id((char *)group->cluster, (char *)group->category);
2728 ErrPrint("Failed to get group id for %s/%s\n", group->cluster, group->category);
2733 if (!group->ctx_item) {
2734 DbgPrint("%s, %s - has no ctx info\n", group->cluster, group->category);
2738 ret = db_insert_groupmap(id, (char *)dynamicbox->pkgid, (char *)group->ctx_item);
2743 /* REUSE "id" from here , option ID */
2744 id = db_get_option_id(id, (char *)dynamicbox->pkgid, (char *)group->ctx_item);
2749 dlist_foreach(group->option_list, il, option) {
2750 ret = db_insert_option((char *)dynamicbox->pkgid, id, (char *)option->key, (char *)option->value);
2757 commit_transaction();
2758 dynamicbox_destroy(dynamicbox);
2762 ErrPrint("ROLLBACK\n");
2763 rollback_transaction();
2764 dynamicbox_destroy(dynamicbox);
2768 static int do_install(xmlNodePtr node, const char *appid)
2770 struct dynamicbox *dynamicbox;
2774 if (!xmlHasProp(node, (const xmlChar *)"appid")) {
2775 ErrPrint("Missing appid\n");
2779 pkgid = xmlGetProp(node, (const xmlChar *)"appid");
2780 if (!pkgid || !validate_pkgid(appid, (char *)pkgid)) {
2781 ErrPrint("Invalid appid\n");
2786 DbgPrint("appid: %s\n", (char *)pkgid);
2788 dynamicbox = calloc(1, sizeof(*dynamicbox));
2790 ErrPrint("Heap: %s\n", strerror(errno));
2795 dynamicbox->pkgid = pkgid;
2797 if (xmlHasProp(node, (const xmlChar *)"count")) {
2798 tmp = xmlGetProp(node, (const xmlChar *)"count");
2799 if (sscanf((const char *)tmp, "%d", &dynamicbox->count) != 1) {
2800 ErrPrint("Invalid syntax: %s\n", (const char *)tmp);
2805 if (xmlHasProp(node, (const xmlChar *)"primary")) {
2806 tmp = xmlGetProp(node, (const xmlChar *)"primary");
2807 dynamicbox->primary = !xmlStrcasecmp(tmp, (const xmlChar *)"true");
2811 if (xmlHasProp(node, (const xmlChar *)"script")) {
2812 dynamicbox->script = xmlGetProp(node, (const xmlChar *)"script");
2813 if (!dynamicbox->script) {
2814 ErrPrint("script is NIL\n");
2818 if (xmlHasProp(node, (const xmlChar *)"nodisplay")) {
2819 tmp = xmlGetProp(node, (const xmlChar *)"nodisplay");
2820 dynamicbox->nodisplay = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true");
2824 if (xmlHasProp(node, (const xmlChar *)"pinup")) {
2825 tmp = xmlGetProp(node, (const xmlChar *)"pinup");
2826 dynamicbox->pinup = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true");
2830 if (xmlHasProp(node, (const xmlChar *)"period")) {
2831 dynamicbox->period = xmlGetProp(node, (const xmlChar *)"period");
2832 if (!dynamicbox->period) {
2833 ErrPrint("Period is NIL\n");
2837 if (xmlHasProp(node, (const xmlChar *)"timeout")) {
2838 dynamicbox->timeout = xmlGetProp(node, (const xmlChar *)"timeout");
2839 if (!dynamicbox->timeout) {
2840 ErrPrint("Timeout is NIL\n");
2844 if (xmlHasProp(node, (const xmlChar *)"secured")) {
2845 tmp = xmlGetProp(node, (const xmlChar *)"secured");
2846 dynamicbox->secured = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true");
2850 if (xmlHasProp(node, (const xmlChar *)"network")) {
2851 tmp = xmlGetProp(node, (const xmlChar *)"network");
2852 dynamicbox->network = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true");
2856 if (xmlHasProp(node, (const xmlChar *)"direct_input")) {
2857 tmp = xmlGetProp(node, (const xmlChar *)"direct_input");
2858 dynamicbox->direct_input = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true");
2862 if (xmlHasProp(node, (const xmlChar *)"hw-acceleration")) {
2863 dynamicbox->hw_acceleration = xmlGetProp(node, (const xmlChar *)"hw-acceleration");
2864 if (!dynamicbox->hw_acceleration) {
2865 ErrPrint("hw-acceleration is NIL\n");
2869 if (xmlHasProp(node, (const xmlChar *)"abi")) {
2870 dynamicbox->abi = xmlGetProp(node, (const xmlChar *)"abi");
2871 if (!dynamicbox->abi) {
2872 ErrPrint("ABI is NIL\n");
2873 dynamicbox_destroy(dynamicbox);
2877 dynamicbox->abi = xmlStrdup((const xmlChar *)"c");
2878 if (!dynamicbox->abi) {
2879 ErrPrint("Heap: %s\n", strerror(errno));
2880 dynamicbox_destroy(dynamicbox);
2885 if (xmlHasProp(node, (const xmlChar *)"libexec")) {
2886 dynamicbox->libexec = xmlGetProp(node, (const xmlChar *)"libexec");
2887 if (!dynamicbox->libexec) {
2888 ErrPrint("libexec is NIL\n");
2889 dynamicbox_destroy(dynamicbox);
2892 } else if (!xmlStrcasecmp(dynamicbox->abi, (const xmlChar *)"c") || !xmlStrcasecmp(dynamicbox->abi, (const xmlChar *)"cpp")) {
2896 len = strlen((char *)dynamicbox->pkgid) + strlen("/libexec/liblive-.so") + 1;
2898 filename = malloc(len);
2900 dynamicbox_destroy(dynamicbox);
2904 snprintf(filename, len, "/libexec/liblive-%s.so", dynamicbox->pkgid);
2905 dynamicbox->libexec = xmlStrdup((xmlChar *)filename);
2906 DbgPrint("Use the default libexec: %s\n", filename);
2909 if (!dynamicbox->libexec) {
2910 dynamicbox_destroy(dynamicbox);
2915 for (node = node->children; node; node = node->next) {
2916 if (!xmlStrcmp(node->name, (const xmlChar *)"text")) {
2920 DbgPrint("Nodename: %s\n", node->name);
2921 if (!xmlStrcasecmp(node->name, (const xmlChar *)"label")) {
2922 update_i18n_name(dynamicbox, node);
2926 if (!xmlStrcasecmp(node->name, (const xmlChar *)"icon")) {
2927 update_i18n_icon(dynamicbox, node);
2931 if (!xmlStrcasecmp(node->name, (const xmlChar *)"box")) {
2932 update_box(dynamicbox, node);
2936 if (!xmlStrcasecmp(node->name, (const xmlChar *)"glancebar")) {
2937 update_pd(dynamicbox, node);
2941 if (!xmlStrcasecmp(node->name, (const xmlChar *)"group")) {
2942 update_group(dynamicbox, node);
2946 if (!xmlStrcasecmp(node->name, (const xmlChar *)"content")) {
2947 update_content(dynamicbox, node);
2951 if (!xmlStrcasecmp(node->name, (const xmlChar *)"setup")) {
2952 update_setup(dynamicbox, node);
2956 if (!xmlStrcasecmp(node->name, (const xmlChar *)"launch")) {
2957 update_launch(dynamicbox, node);
2961 if (!xmlStrcasecmp(node->name, (const xmlChar *)"ui-appid")) {
2962 update_ui_appid(dynamicbox, node);
2966 if (!xmlStrcasecmp(node->name, (const xmlChar *)"category")) {
2967 update_category(dynamicbox, node);
2972 return db_insert_dynamicbox(dynamicbox, appid);
2975 static inline int do_uninstall(xmlNodePtr node, const char *appid)
2980 if (!xmlHasProp(node, (const xmlChar *)"appid")) {
2981 ErrPrint("Missing appid\n");
2985 pkgid = xmlGetProp(node, (const xmlChar *)"appid");
2986 if (!validate_pkgid(appid, (char *)pkgid)) {
2987 ErrPrint("Invalid package\n");
2992 begin_transaction();
2993 ret = db_remove_box_size((char *)pkgid);
2998 ret = db_remove_i18n((char *)pkgid);
3003 ret = db_remove_client((char *)pkgid);
3008 ret = db_remove_provider((char *)pkgid);
3013 ret = db_remove_option((char *)pkgid);
3014 DbgPrint("Remove option: %d\n", ret);
3016 ret = db_remove_groupmap((char *)pkgid);
3017 DbgPrint("Remove groupmap: %d\n", ret);
3019 ret = db_remove_group((char *)pkgid);
3024 ret = db_remove_pkgmap((char *)pkgid);
3029 commit_transaction();
3035 rollback_transaction();
3040 static int pkglist_get_via_callback(const char *appid, void (*cb)(const char *appid, const char *pkgid, int prime, void *data), void *data)
3042 const char *dml = "SELECT pkgid, prime FROM pkgmap WHERE appid = ?";
3049 if (!cb || !appid || !strlen(appid)) {
3053 if (!s_info.handle) {
3054 if (db_init() < 0) {
3055 ErrPrint("Failed to init DB\n");
3060 ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
3061 if (ret != SQLITE_OK) {
3062 ErrPrint("Failed to prepare the intial DML(%s)\n", sqlite3_errmsg(s_info.handle));
3067 if (sqlite3_bind_text(stmt, 1, appid, -1, SQLITE_TRANSIENT) != SQLITE_OK) {
3068 ErrPrint("Failed to bind a cluster - %s\n", sqlite3_errmsg(s_info.handle));
3072 while (sqlite3_step(stmt) == SQLITE_ROW) {
3073 pkgid = (const char *)sqlite3_column_text(stmt, 0);
3074 if (!pkgid || !strlen(pkgid)) {
3078 prime = sqlite3_column_int(stmt, 1);
3079 cb(appid, pkgid, prime, data);
3084 sqlite3_reset(stmt);
3085 sqlite3_clear_bindings(stmt);
3086 sqlite3_finalize(stmt);
3090 static void clear_all_pkg(const char *appid, const char *pkgid, int prime, void *data)
3094 ErrPrintWithConsole("Remove old package info: appid(%s), pkgid(%s)\n", appid, pkgid);
3096 ret = db_remove_box_size((char *)pkgid);
3098 ErrPrint("Remove box size: %d\n", ret);
3101 ret = db_remove_i18n((char *)pkgid);
3103 ErrPrint("Remove i18n: %d\n", ret);
3106 ret = db_remove_client((char *)pkgid);
3108 ErrPrint("Remove client: %d\n", ret);
3111 ret = db_remove_provider((char *)pkgid);
3113 ErrPrint("Remove provider: %d\n", ret);
3116 ret = db_remove_option((char *)pkgid);
3118 ErrPrint("Remove option: %d\n", ret);
3121 ret = db_remove_groupmap((char *)pkgid);
3123 ErrPrint("Remove groupmap: %d\n", ret);
3126 ret = db_remove_group((char *)pkgid);
3128 ErrPrint("Remove group: %d\n", ret);
3131 ret = db_remove_pkgmap((char *)pkgid);
3133 ErrPrint("Remove pkgmap: %d\n", ret);
3137 int PKGMGR_PARSER_PLUGIN_PRE_INSTALL(const char *appid)
3141 ErrPrintWithConsole("%s\n", appid);
3143 if (!s_info.handle) {
3144 if (db_init() < 0) {
3145 ErrPrintWithConsole("Failed to init DB\n");
3150 do_upgrade_db_schema();
3152 begin_transaction();
3153 cnt = pkglist_get_via_callback(appid, clear_all_pkg, NULL);
3154 commit_transaction();
3157 DbgPrint("Package[%s] is not deleted: %d\n", appid, cnt);
3162 int PKGMGR_PARSER_PLUGIN_POST_INSTALL(const char *appid)
3164 ErrPrintWithConsole("[%s]\n", appid);
3169 int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr docPtr, const char *appid)
3174 ErrPrintWithConsole("[%s]\n", appid);
3176 if (!s_info.handle) {
3177 ErrPrintWithConsole("Failed to init DB\n");
3181 node = xmlDocGetRootElement(docPtr);
3183 ErrPrintWithConsole("Invalid document\n");
3187 for (node = node->children; node; node = node->next) {
3188 DbgPrint("node->name: %s\n", node->name);
3189 if (!xmlStrcasecmp(node->name, (const xmlChar *)"dynamicbox")) {
3190 ret = do_install(node, appid);
3192 DbgPrint("Returns: %d\n", ret);
3200 int PKGMGR_PARSER_PLUGIN_PRE_UPGRADE(const char *appid)
3204 ErrPrintWithConsole("[%s]\n", appid);
3206 if (!s_info.handle) {
3207 if (db_init() < 0) {
3208 ErrPrint("Failed to init DB\n");
3213 do_upgrade_db_schema();
3215 begin_transaction();
3216 cnt = pkglist_get_via_callback(appid, clear_all_pkg, NULL);
3217 commit_transaction();
3220 DbgPrint("Package %s is deleted: %d\n", appid, cnt);
3225 int PKGMGR_PARSER_PLUGIN_POST_UPGRADE(const char *appid)
3227 ErrPrintWithConsole("[%s]\n", appid);
3232 int PKGMGR_PARSER_PLUGIN_UPGRADE(xmlDocPtr docPtr, const char *appid)
3237 ErrPrintWithConsole("[%s]\n", appid);
3239 if (!s_info.handle) {
3240 ErrPrint("Failed to init DB\n");
3244 node = xmlDocGetRootElement(docPtr);
3246 ErrPrint("Invalid document\n");
3250 for (node = node->children; node; node = node->next) {
3251 if (!xmlStrcasecmp(node->name, (const xmlChar *)"dynamicbox")) {
3252 ret = do_install(node, appid);
3254 DbgPrint("Returns: %d\n", ret);
3262 int PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL(const char *appid)
3264 ErrPrintWithConsole("[%s]\n", appid);
3266 if (!s_info.handle) {
3267 if (db_init() < 0) {
3268 ErrPrint("Failed to init DB\n");
3273 do_upgrade_db_schema();
3277 int PKGMGR_PARSER_PLUGIN_POST_UNINSTALL(const char *appid)
3281 ErrPrintWithConsole("[%s]\n", appid);
3283 if (!s_info.handle) {
3287 begin_transaction();
3288 cnt = pkglist_get_via_callback(appid, clear_all_pkg, NULL);
3289 commit_transaction();
3292 DbgPrint("Package %s is deleted: %d\n", appid, cnt);
3298 int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr docPtr, const char *appid)
3300 ErrPrintWithConsole("[%s]\n", appid);
3301 if (!s_info.handle) {
3304 /* Doesn't need to do anything from here, we already dealt it with this */