Name: data-provider-master
Summary: Master service provider for liveboxes
-Version: 0.33.8
+Version: 0.34.0
Release: 1
Group: HomeTF/Livebox
License: Flora
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);
CREATE TABLE i18n ( pkgid TEXT NOT NULL, lang TEXT COLLATE NOCASE, name TEXT, icon TEXT, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE);
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) ON DELETE CASCADE);
-CREATE TABLE pkgmap ( pkgid TEXT PRIMARY KEY NOT NULL, appid TEXT, uiapp TEXT, prime INTEGER );
+CREATE TABLE pkgmap ( pkgid TEXT PRIMARY KEY NOT NULL, appid TEXT, uiapp TEXT, prime INTEGER, category TEXT DEFAULT 'http://tizen.org/category/default' );
CREATE TABLE provider ( pkgid TEXT PRIMARY KEY NOT NULL, network INTEGER, abi TEXT, secured INTEGER, box_type INTEGER, box_src TEXT, box_group TEXT, pd_type INTEGER, pd_src TEXT, pd_group TEXT, libexec TEXT, timeout INTEGER, period TEXT, script TEXT, pinup INTEGER, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE);
EOF
fi
#define ErrPrint(format, arg...) SECURE_LOGE("[\e[32m%s/%s\e[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg)
#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)
#endif
-/* End of a file */
+
+#define CUR_VER 2
+#define DEFAULT_CATEGORY "http://tizen.org/category/default"
/*!
* \note
*
*
* pkgmap
- * +-------+-------+-------+-------+
- * | appid | pkgid | uiapp | prime |
- * +-------+-------+-------+-------+
- * | - | - | - | - |
- * +-------+-------+-------+-------+
- * CREATE TABLE pkgmap ( pkgid TEXT PRIMARY KEY NOT NULL, appid TEXT, uiapp TEXT, prime INTEGER )
+ * +-------+-------+-------+-------+-------------------+
+ * | appid | pkgid | uiapp | prime | categ(from ver 2) |
+ * +-------+-------+-------+-------+-------------------+
+ * | - | - | - | - | - |
+ * +-------+-------+-------+-------+-------------------+
+ * CREATE TABLE pkgmap ( pkgid TEXT PRIMARY KEY NOT NULL, appid TEXT, uiapp TEXT, prime INTEGER, category TEXT )
*
*
* provider
xmlChar *content; /* Content information */
xmlChar *setup;
xmlChar *uiapp; /* UI App Id */
+ xmlChar *category; /* Category of this box */
int pinup; /* Is this support the pinup feature? */
int primary; /* Is this primary livebox? */
return ret;
}
+/*!
+ * \note
+ * From version 1 to 2
+ */
+static void upgrade_pkgmap_for_category(void)
+{
+ char *err;
+ static const char *ddl;
+
+ ddl = "ALTER TABLE pkgmap ADD COLUMN category TEXT DEFAULT \"" DEFAULT_CATEGORY "\"";
+ if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+ ErrPrint("Failed to execute the DDL (%s)\n", err);
+ return;
+ }
+
+ if (sqlite3_changes(s_info.handle) == 0) {
+ ErrPrint("No changes to DB\n");
+ }
+
+ return;
+}
+
static void do_upgrade_db_schema(void)
{
int version;
db_create_version();
/* Need to create version table */
case -ENOENT:
- if (set_version(1) < 0) {
+ if (set_version(CUR_VER) < 0) {
ErrPrint("Failed to set version\n");
}
/* Need to set version */
- case 1:
+ case CUR_VER:
break;
+ case 1:
+ upgrade_pkgmap_for_category();
default:
/* Need to update version */
DbgPrint("Old version: %d\n", version);
- if (update_version(1) < 0) {
+ if (update_version(CUR_VER) < 0) {
ErrPrint("Failed to update version\n");
}
break;
char *err;
static const char *ddl;
- ddl = "CREATE TABLE pkgmap ( pkgid TEXT PRIMARY KEY NOT NULL, appid TEXT, uiapp TEXT, prime INTEGER )";
+ ddl = "CREATE TABLE pkgmap ( pkgid TEXT PRIMARY KEY NOT NULL, appid TEXT, uiapp TEXT, prime INTEGER, category TEXT )";
if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
ErrPrint("Failed to execute the DDL (%s)\n", err);
return -EIO;
return 0;
}
-static inline int db_insert_pkgmap(const char *appid, const char *pkgid, const char *uiappid, int primary)
+static inline int db_insert_pkgmap(const char *appid, const char *pkgid, const char *uiappid, int primary, const char *category)
{
int ret;
static const char *dml;
uiappid = ""; /*!< Could we replace this with Main AppId of this package? */
}
- dml = "INSERT INTO pkgmap ( appid, pkgid, uiapp, prime ) VALUES (? ,?, ?, ?)";
+ dml = "INSERT INTO pkgmap ( appid, pkgid, uiapp, prime, category ) VALUES (? ,?, ?, ?, ?)";
ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
if (ret != SQLITE_OK) {
DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
goto out;
}
+ ret = sqlite3_bind_text(stmt, 5, category, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
ret = 0;
if (sqlite3_step(stmt) != SQLITE_DONE) {
DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
xmlFree(livebox->period);
xmlFree(livebox->content);
xmlFree(livebox->setup);
+ xmlFree(livebox->category);
xmlFree(livebox->preview[0]); /* 1x1 */
xmlFree(livebox->preview[1]); /* 2x1 */
xmlFree(livebox->preview[2]); /* 2x2 */
static inline void update_launch(struct livebox *livebox, xmlNodePtr node)
{
xmlChar *launch;
+
launch = xmlNodeGetContent(node);
if (!launch) {
DbgPrint("Has no launch\n");
return;
}
+ if (livebox->auto_launch) {
+ xmlFree(livebox->auto_launch);
+ }
+
livebox->auto_launch = xmlStrdup(launch);
if (!livebox->auto_launch) {
ErrPrint("Failed to duplicate string: %s\n", (char *)launch);
}
}
+static inline void update_category(struct livebox *livebox, xmlNodePtr node)
+{
+ xmlChar *category;
+ category = xmlNodeGetContent(node);
+ if (!category) {
+ DbgPrint("Has no valid category\n");
+ return;
+ }
+
+ if (livebox->category) {
+ xmlFree(livebox->category);
+ }
+
+ livebox->category = xmlStrdup(category);
+ if (!livebox->category) {
+ ErrPrint("Failed to duplicate string: %s\n", (char *)category);
+ return;
+ }
+}
+
static inline void update_ui_appid(struct livebox *livebox, xmlNodePtr node)
{
xmlChar *uiapp;
return;
}
+ if (livebox->uiapp) {
+ xmlFree(livebox->uiapp);
+ }
+
livebox->uiapp = xmlStrdup(uiapp);
if (!livebox->uiapp) {
ErrPrint("Failed to duplicate string: %s\n", (char *)uiapp);
return;
}
+ if (livebox->setup) {
+ xmlFree(livebox->setup);
+ }
+
livebox->setup = xmlStrdup(setup);
if (!livebox->setup) {
ErrPrint("Failed to duplicate string: %s\n", (char *)setup);
return;
}
+ if (livebox->content) {
+ xmlFree(livebox->content);
+ }
+
livebox->content = xmlStrdup(content);
if (!livebox->content) {
ErrPrint("Failed to duplicate string: %s\n", (char *)content);
struct option *option;
begin_transaction();
- ret = db_insert_pkgmap(appid, (char *)livebox->pkgid, (char *)livebox->uiapp, livebox->primary);
+ ret = db_insert_pkgmap(appid, (char *)livebox->pkgid, (char *)livebox->uiapp, livebox->primary, (char *)livebox->category);
if (ret < 0) {
goto errout;
}
update_ui_appid(livebox, node);
continue;
}
+
+ if (!xmlStrcasecmp(node->name, (const xmlChar *)"category")) {
+ update_category(livebox, node);
+ continue;
+ }
}
return db_insert_livebox(livebox, appid);