Update hello_sync & prepare_sync
authorSung-jae Park <nicesj.park@samsung.com>
Tue, 7 Apr 2015 01:21:05 +0000 (10:21 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Tue, 7 Apr 2015 02:14:58 +0000 (11:14 +0900)
Add sync timer, if the hello_sync comes more ealry than prepare_sync.

[model] Redwood,Kiran,B3(Wearable)
[binary_type] AP
[customer] Docomo/Orange/ATT/Open
[issue#] N/A
[problem]
[cause]
[solution]
[team] HomeTF
[request]
[horizontal_expansion]

Change-Id: Ia120f8c2236495174924b9297d95884418b7676a

pkgmgr_widget/src/widget_pkgmgr.c
src/server.c

index 0f22409..df992dd 100644 (file)
@@ -46,7 +46,7 @@
 #define WATCH_CATEGORY         "org.tizen.wmanager.WATCH_CLOCK"
 
 #if !defined(WIDGET_COUNT_OF_SIZE_TYPE)
-       #define WIDGET_COUNT_OF_SIZE_TYPE 13
+#define WIDGET_COUNT_OF_SIZE_TYPE 13
 #endif
 
 /*!
  * +----+---------+----------+-------+
  * | id | cluster | category | pkgid |
  * +----+---------+----------+-------+
- * |  - |    -    |    -     |   -   |
- * +----+---------+----------+-------|
- * 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) ))
- *
- * groupmap
- * +-------+----+----------+-----------+
- * | pkgid | id | ctx_item | option_id |
- * +-------+----+----------+-----------+
- * 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) )
- *
- *
- * option
- * +-------+-----------+-----+-------+
- * | pkgid | option_id | key | value |
- * +-------+-----------+-----+-------+
- * 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)  )
- */
+* |  - |    -    |    -     |   -   |
      * +----+---------+----------+-------|
+* 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) ))
      *
      * groupmap
      * +-------+----+----------+-----------+
      * | pkgid | id | ctx_item | option_id |
      * +-------+----+----------+-----------+
+* 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) )
      *
      *
      * option
      * +-------+-----------+-----+-------+
      * | pkgid | option_id | key | value |
      * +-------+-----------+-----+-------+
+* 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)  )
      */
 
 #if !defined(LIBXML_TREE_ENABLED)
-       #error "LIBXML is not supporting the tree"
+#error "LIBXML is not supporting the tree"
 #endif
 
 #if defined(LOG_TAG)
 
 #define LOG_TAG "PKGMGR_WIDGET2"
 
- int errno;
      int errno;
 
- struct i18n {
-     xmlChar *lang;
-     xmlChar *name;
-     xmlChar *icon;
- };
      struct i18n {
+               xmlChar *lang;
+               xmlChar *name;
+               xmlChar *icon;
      };
 
 struct widget {
-    xmlChar *pkgid;
-    int secured;
-    int network;
-    xmlChar *auto_launch;
-    xmlChar *abi;
-    xmlChar *name; /* Default name */
-    xmlChar *icon; /* Default icon */
-    xmlChar *libexec; /* Path of the SO file */
-    xmlChar *timeout; /* INTEGER, timeout */
-    xmlChar *period; /* DOUBLE, update period */
-    xmlChar *script; /* Script engine */
-    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 widget? */
-    int nodisplay;
-    int count; /* Max count of instances */
-    int direct_input; /* Use the input node to get the event directly */
-
-    int default_mouse_event; /* Mouse event processing option for widget */
-    int default_touch_effect;
-    int default_need_frame;
-
-    enum widget_widget_type widget_type;
-    xmlChar *widget_src;
-    xmlChar *widget_group;
-    int size_list; /* 1x1, 2x1, 2x2, 4x1, 4x2, 4x3, 4x4 */
-
-    xmlChar *preview[WIDGET_COUNT_OF_SIZE_TYPE];
-    int touch_effect[WIDGET_COUNT_OF_SIZE_TYPE]; /* Touch effect of a widget */
-    int need_frame[WIDGET_COUNT_OF_SIZE_TYPE]; /* Box needs frame which should be cared by viewer */
-    int mouse_event[WIDGET_COUNT_OF_SIZE_TYPE];
-
-    enum widget_gbar_type gbar_type;
-    xmlChar *gbar_src;
-    xmlChar *gbar_group;
-    xmlChar *gbar_size; /* Default PD size */
-    xmlChar *hw_acceleration;
-
-    struct dlist *i18n_list;
-    struct dlist *group_list;
+       xmlChar *pkgid;
+       int secured;
+       int network;
+       xmlChar *auto_launch;
+       xmlChar *abi;
+       xmlChar *name; /* Default name */
+       xmlChar *icon; /* Default icon */
+       xmlChar *libexec; /* Path of the SO file */
+       xmlChar *timeout; /* INTEGER, timeout */
+       xmlChar *period; /* DOUBLE, update period */
+       xmlChar *script; /* Script engine */
+       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 widget? */
+       int nodisplay;
+       int count; /* Max count of instances */
+       int direct_input; /* Use the input node to get the event directly */
+
+       int default_mouse_event; /* Mouse event processing option for widget */
+       int default_touch_effect;
+       int default_need_frame;
+
+       enum widget_widget_type widget_type;
+       xmlChar *widget_src;
+       xmlChar *widget_group;
+       int size_list; /* 1x1, 2x1, 2x2, 4x1, 4x2, 4x3, 4x4 */
+
+       xmlChar *preview[WIDGET_COUNT_OF_SIZE_TYPE];
+       int touch_effect[WIDGET_COUNT_OF_SIZE_TYPE]; /* Touch effect of a widget */
+       int need_frame[WIDGET_COUNT_OF_SIZE_TYPE]; /* Box needs frame which should be cared by viewer */
+       int mouse_event[WIDGET_COUNT_OF_SIZE_TYPE];
+
+       enum widget_gbar_type gbar_type;
+       xmlChar *gbar_src;
+       xmlChar *gbar_group;
+       xmlChar *gbar_size; /* Default PD size */
+       xmlChar *hw_acceleration;
+
+       struct dlist *i18n_list;
+       struct dlist *group_list;
 };
 
 struct group {
-    xmlChar *cluster;
-    xmlChar *category;
-    xmlChar *ctx_item;
-    struct dlist *option_list;
+       xmlChar *cluster;
+       xmlChar *category;
+       xmlChar *ctx_item;
+       struct dlist *option_list;
 };
 
 struct option {
-    xmlChar *key;
-    xmlChar *value;
+       xmlChar *key;
+       xmlChar *value;
 };
 
 static struct {
-    const char *dbfile;
-    sqlite3 *handle;
+       const char *dbfile;
+       sqlite3 *handle;
 } s_info = {
-    .dbfile = "/opt/dbspace/.widget.db",
-    .handle = NULL,
+       .dbfile = "/opt/dbspace/.widget.db",
+       .handle = NULL,
 };
 
 int begin_transaction(void)
 {
-    sqlite3_stmt *stmt;
-    int ret;
+       sqlite3_stmt *stmt;
+       int ret;
+
+       ret = sqlite3_prepare_v2(s_info.handle, "BEGIN TRANSACTION", -1, &stmt, NULL);
 
-    ret = sqlite3_prepare_v2(s_info.handle, "BEGIN TRANSACTION", -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
+               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               return EXIT_FAILURE;
+       }
 
-    if (ret != SQLITE_OK) {
-       DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
-       return EXIT_FAILURE;
-    }
+       if (sqlite3_step(stmt) != SQLITE_DONE) {
+               DbgPrint("Failed to do update (%s)\n",
+                               sqlite3_errmsg(s_info.handle));
+               sqlite3_finalize(stmt);
+               return EXIT_FAILURE;
+       }
 
-    if (sqlite3_step(stmt) != SQLITE_DONE) {
-       DbgPrint("Failed to do update (%s)\n",
-               sqlite3_errmsg(s_info.handle));
        sqlite3_finalize(stmt);
-       return EXIT_FAILURE;
-    }
-
-    sqlite3_finalize(stmt);
-    return EXIT_SUCCESS;
+       return EXIT_SUCCESS;
 }
 
 static inline int rollback_transaction(void)
 {
-    int ret;
-    sqlite3_stmt *stmt;
-
-    ret = sqlite3_prepare_v2(s_info.handle, "ROLLBACK TRANSACTION", -1, &stmt, NULL);
-    if (ret != SQLITE_OK) {
-       DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
-       return EXIT_FAILURE;
-    }
-
-    if (sqlite3_step(stmt) != SQLITE_DONE) {
-       DbgPrint("Failed to do update (%s)\n",
-               sqlite3_errmsg(s_info.handle));
-       sqlite3_finalize(stmt);
-       return EXIT_FAILURE;
-    }
+       int ret;
+       sqlite3_stmt *stmt;
 
-    sqlite3_finalize(stmt);
-    return EXIT_SUCCESS;
+       ret = sqlite3_prepare_v2(s_info.handle, "ROLLBACK TRANSACTION", -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
+               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               return EXIT_FAILURE;
+       }
+
+       if (sqlite3_step(stmt) != SQLITE_DONE) {
+               DbgPrint("Failed to do update (%s)\n",
+                               sqlite3_errmsg(s_info.handle));
+               sqlite3_finalize(stmt);
+               return EXIT_FAILURE;
+       }
+
+       sqlite3_finalize(stmt);
+       return EXIT_SUCCESS;
 }
 
 inline int commit_transaction(void)
 {
-    sqlite3_stmt *stmt;
-    int ret;
-
-    ret = sqlite3_prepare_v2(s_info.handle, "COMMIT TRANSACTION", -1, &stmt, NULL);
-    if (ret != SQLITE_OK) {
-       DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
-       return EXIT_FAILURE;
-    }
-
-    if (sqlite3_step(stmt) != SQLITE_DONE) {
-       DbgPrint("Failed to do update (%s)\n",
-               sqlite3_errmsg(s_info.handle));
-       sqlite3_finalize(stmt);
-       return EXIT_FAILURE;
-    }
+       sqlite3_stmt *stmt;
+       int ret;
+
+       ret = sqlite3_prepare_v2(s_info.handle, "COMMIT TRANSACTION", -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
+               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               return EXIT_FAILURE;
+       }
+
+       if (sqlite3_step(stmt) != SQLITE_DONE) {
+               DbgPrint("Failed to do update (%s)\n",
+                               sqlite3_errmsg(s_info.handle));
+               sqlite3_finalize(stmt);
+               return EXIT_FAILURE;
+       }
 
-    sqlite3_finalize(stmt);
-    return EXIT_SUCCESS;
+       sqlite3_finalize(stmt);
+       return EXIT_SUCCESS;
 }
 
 static void db_create_version(void)
 {
-    static const char *ddl = "CREATE TABLE version (version INTEGER)";
-    char *err;
+       static const char *ddl = "CREATE TABLE version (version INTEGER)";
+       char *err;
 
-    if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
-       ErrPrint("Failed to execute the DDL (%s)\n", err);
-       return;
-    }
+       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");
-    }
+       if (sqlite3_changes(s_info.handle) == 0) {
+               ErrPrint("No changes to DB\n");
+       }
 }
 
 static int set_version(int version)
 {
-    static const char *dml = "INSERT INTO version (version) VALUES (?)";
-    sqlite3_stmt *stmt;
-    int ret;
-
-    ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-    if (ret != SQLITE_OK) {
-       ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle));
-       return -EIO;
-    }
-
-    if (sqlite3_bind_int(stmt, 1, version) != SQLITE_OK) {
-       ErrPrint("Failed to bind a id(%s)\n", sqlite3_errmsg(s_info.handle));
-       ret = -EIO;
-       goto out;
-    }
+       static const char *dml = "INSERT INTO version (version) VALUES (?)";
+       sqlite3_stmt *stmt;
+       int ret;
 
-    ret = sqlite3_step(stmt);
-    if (ret != SQLITE_DONE) {
-       ErrPrint("Failed to execute the DML for version: %d\n", ret);
-       ret = -EIO;
-    } else {
-       ret = 0;
-    }
+       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
+               ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle));
+               return -EIO;
+       }
+
+       if (sqlite3_bind_int(stmt, 1, version) != SQLITE_OK) {
+               ErrPrint("Failed to bind a id(%s)\n", sqlite3_errmsg(s_info.handle));
+               ret = -EIO;
+               goto out;
+       }
+
+       ret = sqlite3_step(stmt);
+       if (ret != SQLITE_DONE) {
+               ErrPrint("Failed to execute the DML for version: %d\n", ret);
+               ret = -EIO;
+       } else {
+               ret = 0;
+       }
 
 out:
-    sqlite3_reset(stmt);
-    sqlite3_clear_bindings(stmt);
-    sqlite3_finalize(stmt);
-    return ret;
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+       sqlite3_finalize(stmt);
+       return ret;
 }
 
 static int update_version(int version)
 {
-    static const char *dml = "UPDATE version SET version = ?";
-    sqlite3_stmt *stmt;
-    int ret;
-
-    ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-    if (ret != SQLITE_OK) {
-       ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle));
-       return -EIO;
-    }
-
-    if (sqlite3_bind_int(stmt, 1, version) != SQLITE_OK) {
-       ErrPrint("Failed to bind a version: %s\n", sqlite3_errmsg(s_info.handle));
-       ret = -EIO;
-       goto out;
-    }
+       static const char *dml = "UPDATE version SET version = ?";
+       sqlite3_stmt *stmt;
+       int ret;
 
-    ret = sqlite3_step(stmt);
-    if (ret != SQLITE_DONE) {
-       ErrPrint("Failed to execute DML: %d\n", ret);
-       ret = -EIO;
-    } else {
-       ret = 0;
-    }
+       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
+               ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle));
+               return -EIO;
+       }
+
+       if (sqlite3_bind_int(stmt, 1, version) != SQLITE_OK) {
+               ErrPrint("Failed to bind a version: %s\n", sqlite3_errmsg(s_info.handle));
+               ret = -EIO;
+               goto out;
+       }
+
+       ret = sqlite3_step(stmt);
+       if (ret != SQLITE_DONE) {
+               ErrPrint("Failed to execute DML: %d\n", ret);
+               ret = -EIO;
+       } else {
+               ret = 0;
+       }
 
 out:
-    sqlite3_reset(stmt);
-    sqlite3_clear_bindings(stmt);
-    sqlite3_finalize(stmt);
-    return ret;
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+       sqlite3_finalize(stmt);
+       return ret;
 }
 
 static int get_version(void)
 {
-    static const char *dml = "SELECT version FROM version";
-    sqlite3_stmt *stmt;
-    int ret;
-
-    ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-    if (ret != SQLITE_OK) {
-       return -ENOSYS;
-    }
-
-    if (sqlite3_step(stmt) != SQLITE_ROW) {
-       ret = -ENOENT;
-    } else {
-       ret = sqlite3_column_int(stmt, 0);
-    }
+       static const char *dml = "SELECT version FROM version";
+       sqlite3_stmt *stmt;
+       int ret;
+
+       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
+               return -ENOSYS;
+       }
+
+       if (sqlite3_step(stmt) != SQLITE_ROW) {
+               ret = -ENOENT;
+       } else {
+               ret = sqlite3_column_int(stmt, 0);
+       }
 
-    sqlite3_reset(stmt);
-    sqlite3_clear_bindings(stmt);
-    sqlite3_finalize(stmt);
-    return ret;
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+       sqlite3_finalize(stmt);
+       return ret;
 }
 
 /*!
@@ -400,20 +400,20 @@ static int get_version(void)
  */
 static void upgrade_pkgmap_for_category(void)
 {
-    char *err;
-    static const char *ddl;
+       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;
-    }
+       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");
-    }
+       if (sqlite3_changes(s_info.handle) == 0) {
+               ErrPrint("No changes to DB\n");
+       }
 
-    return;
+       return;
 }
 
 /**
@@ -425,36 +425,36 @@ static void upgrade_pkgmap_for_category(void)
  */
 static void upgrade_to_version_5(void)
 {
-    char *err;
-    static const char *ddl;
-
-    /*
-     * Step 1
-     * Create a new column "direct_input" for provider table
-     */
-    ddl = "ALTER TABLE provider ADD COLUMN direct_input INTEGER DEFAULT 0";
-    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");
-    }
-
-    /*
-     * Step 2
-     * Create a new column "hw_acceleration" for provider table
-     */
-    ddl = "ALTER TABLE provider ADD COLUMN hw_acceleration TEXT DEFAULT 'none'";
-    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");
-    }
+       char *err;
+       static const char *ddl;
+
+       /*
+        * Step 1
+        * Create a new column "direct_input" for provider table
+        */
+       ddl = "ALTER TABLE provider ADD COLUMN direct_input INTEGER DEFAULT 0";
+       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");
+       }
+
+       /*
+        * Step 2
+        * Create a new column "hw_acceleration" for provider table
+        */
+       ddl = "ALTER TABLE provider ADD COLUMN hw_acceleration TEXT DEFAULT 'none'";
+       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");
+       }
 }
 
 /*!
@@ -466,22 +466,22 @@ static void upgrade_to_version_5(void)
  */
 static void upgrade_to_version_4(void)
 {
-    char *err;
-    static const char *ddl;
-
-    /*
-     * Step 1
-     * Create a new column for count to provider table.
-     */
-    ddl = "ALTER TABLE provider ADD COLUMN count INTEGER DEFAULT 0";
-    if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+       char *err;
+       static const char *ddl;
+
+       /*
+        * Step 1
+        * Create a new column for count to provider table.
+        */
+       ddl = "ALTER TABLE provider ADD COLUMN count INTEGER DEFAULT 0";
+       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");
-    }
+       if (sqlite3_changes(s_info.handle) == 0) {
+               ErrPrint("No changes to DB\n");
+       }
 }
 
 /*!
@@ -494,1368 +494,1368 @@ static void upgrade_to_version_4(void)
  */
 static void upgrade_to_version_3(void)
 {
-    char *err;
-    static const char *ddl;
-    static const char *dml;
-    sqlite3_stmt *select_stmt;
-    int ret;
-
-    /*
-     * Step 1
-     * Create a new column for mouse_event to box_size table.
-     */
-    ddl = "ALTER TABLE box_size ADD COLUMN mouse_event INTEGER DEFAULT 0";
-    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");
-    }
-
-    /*
-     * Step 2
-     * Copy mouse_event values from the client to the box_size table.
-     */
-    dml = "SELECT pkgid, mouse_event FROM client";
-    ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &select_stmt, NULL);
-    if (ret == SQLITE_OK) {
-       sqlite3_stmt *update_stmt;
-
-       dml = "UPDATE box_size SET mouse_event = ? WHERE pkgid = ?";
-       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &update_stmt, NULL);
+       char *err;
+       static const char *ddl;
+       static const char *dml;
+       sqlite3_stmt *select_stmt;
+       int ret;
+
+       /*
+        * Step 1
+        * Create a new column for mouse_event to box_size table.
+        */
+       ddl = "ALTER TABLE box_size ADD COLUMN mouse_event INTEGER DEFAULT 0";
+       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");
+       }
+
+       /*
+        * Step 2
+        * Copy mouse_event values from the client to the box_size table.
+        */
+       dml = "SELECT pkgid, mouse_event FROM client";
+       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &select_stmt, NULL);
        if (ret == SQLITE_OK) {
-           int mouse_event;
-           const char *pkgid;
+               sqlite3_stmt *update_stmt;
+
+               dml = "UPDATE box_size SET mouse_event = ? WHERE pkgid = ?";
+               ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &update_stmt, NULL);
+               if (ret == SQLITE_OK) {
+                       int mouse_event;
+                       const char *pkgid;
+
+                       while (sqlite3_step(select_stmt) == SQLITE_ROW) {
+                               pkgid = (const char *)sqlite3_column_text(select_stmt, 0);
+                               if (!pkgid) {
+                                       ErrPrint("Package Id is not valid\n");
+                                       continue;
+                               }
 
-           while (sqlite3_step(select_stmt) == SQLITE_ROW) {
-               pkgid = (const char *)sqlite3_column_text(select_stmt, 0);
-               if (!pkgid) {
-                   ErrPrint("Package Id is not valid\n");
-                   continue;
-               }
+                               mouse_event = sqlite3_column_int(select_stmt, 1);
 
-               mouse_event = sqlite3_column_int(select_stmt, 1);
+                               ret = sqlite3_bind_int(update_stmt, 1, mouse_event);
+                               if (ret != SQLITE_OK) {
+                                       ErrPrint("Failed to bind mouse_event [%s], [%d]\n", pkgid, mouse_event);
+                                       sqlite3_reset(update_stmt);
+                                       sqlite3_clear_bindings(update_stmt);
+                                       continue;
+                               }
 
-               ret = sqlite3_bind_int(update_stmt, 1, mouse_event);
-               if (ret != SQLITE_OK) {
-                   ErrPrint("Failed to bind mouse_event [%s], [%d]\n", pkgid, mouse_event);
-                   sqlite3_reset(update_stmt);
-                   sqlite3_clear_bindings(update_stmt);
-                   continue;
-               }
+                               ret = sqlite3_bind_text(update_stmt, 2, pkgid, -1, SQLITE_TRANSIENT);
+                               if (ret != SQLITE_OK) {
+                                       ErrPrint("Failed to bind pkgid [%s], [%d]\n", pkgid, mouse_event);
+                                       sqlite3_reset(update_stmt);
+                                       sqlite3_clear_bindings(update_stmt);
+                                       continue;
+                               }
 
-               ret = sqlite3_bind_text(update_stmt, 2, pkgid, -1, SQLITE_TRANSIENT);
-               if (ret != SQLITE_OK) {
-                   ErrPrint("Failed to bind pkgid [%s], [%d]\n", pkgid, mouse_event);
-                   sqlite3_reset(update_stmt);
-                   sqlite3_clear_bindings(update_stmt);
-                   continue;
-               }
+                               ret = sqlite3_step(update_stmt);
+                               if (ret != SQLITE_DONE) {
+                                       ErrPrint("Failed to execute DML: %d\n", ret);
+                                       sqlite3_reset(update_stmt);
+                                       sqlite3_clear_bindings(update_stmt);
+                                       continue;
+                               }
 
-               ret = sqlite3_step(update_stmt);
-               if (ret != SQLITE_DONE) {
-                   ErrPrint("Failed to execute DML: %d\n", ret);
-                   sqlite3_reset(update_stmt);
-                   sqlite3_clear_bindings(update_stmt);
-                   continue;
-               }
+                               sqlite3_reset(update_stmt);
+                               sqlite3_clear_bindings(update_stmt);
+                       }
 
-               sqlite3_reset(update_stmt);
-               sqlite3_clear_bindings(update_stmt);
-           }
+                       sqlite3_finalize(update_stmt);
+               } else {
+                       ErrPrint("Failed to execute DML\n");
+               }
 
-           sqlite3_finalize(update_stmt);
+               sqlite3_reset(select_stmt);
+               sqlite3_clear_bindings(select_stmt);
+               sqlite3_finalize(select_stmt);
        } else {
-           ErrPrint("Failed to execute DML\n");
-       }
-
-       sqlite3_reset(select_stmt);
-       sqlite3_clear_bindings(select_stmt);
-       sqlite3_finalize(select_stmt);
-    } else {
-       ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle));
-    }
-
-    /*
-     * Step 3
-     * Drop a column from the client table
-     */
-    ddl = "ALTER TABLE client DROP COLUMN mouse_event";
-    if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+               ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle));
+       }
+
+       /*
+        * Step 3
+        * Drop a column from the client table
+        */
+       ddl = "ALTER TABLE client DROP COLUMN mouse_event";
+       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");
-    }
+       if (sqlite3_changes(s_info.handle) == 0) {
+               ErrPrint("No changes to DB\n");
+       }
 
-    return;
+       return;
 }
 
 void db_upgrade_db_schema(void)
 {
-    int version;
-
-    version = get_version();
-
-    switch (version) {
-       case -ENOSYS:
-           db_create_version();
-           /* Need to create version table */
-       case -ENOENT:
-           if (set_version(CUR_VER) < 0) {
-               ErrPrint("Failed to set version\n");
-           }
-           /* Need to set version */
-       case 1:
-           upgrade_pkgmap_for_category();
-       case 2:
-           upgrade_to_version_3();
-       case 3:
-           upgrade_to_version_4();
-       case 4:
-           upgrade_to_version_5();
-       default:
-           /* Need to update version */
-           DbgPrint("Old version: %d\n", version);
-           if (update_version(CUR_VER) < 0) {
-               ErrPrint("Failed to update version\n");
-           }
-       case CUR_VER:
-           break;
-    }
+       int version;
+
+       version = get_version();
+
+       switch (version) {
+               case -ENOSYS:
+                       db_create_version();
+                       /* Need to create version table */
+               case -ENOENT:
+                       if (set_version(CUR_VER) < 0) {
+                               ErrPrint("Failed to set version\n");
+                       }
+                       /* Need to set version */
+               case 1:
+                       upgrade_pkgmap_for_category();
+               case 2:
+                       upgrade_to_version_3();
+               case 3:
+                       upgrade_to_version_4();
+               case 4:
+                       upgrade_to_version_5();
+               default:
+                       /* Need to update version */
+                       DbgPrint("Old version: %d\n", version);
+                       if (update_version(CUR_VER) < 0) {
+                               ErrPrint("Failed to update version\n");
+                       }
+               case CUR_VER:
+                       break;
+       }
 }
 
 static inline int db_create_pkgmap(void)
 {
-    char *err;
-    static const char *ddl;
+       char *err;
+       static const char *ddl;
 
-    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;
-    }
+       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;
+       }
 
-    if (sqlite3_changes(s_info.handle) == 0) {
-       ErrPrint("No changes to DB\n");
-    }
+       if (sqlite3_changes(s_info.handle) == 0) {
+               ErrPrint("No changes to DB\n");
+       }
 
-    return 0;
+       return 0;
 }
 
 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;
-    sqlite3_stmt *stmt;
-
-    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));
-       return -EIO;
-    }
-
-    ret = sqlite3_bind_text(stmt, 1, appid, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
-       DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
-       ret = -EIO;
-       goto out;
-    }
+       int ret;
+       static const char *dml;
+       sqlite3_stmt *stmt;
 
-    ret = sqlite3_bind_text(stmt, 2, pkgid, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
-       DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
-       ret = -EIO;
-       goto out;
-    }
+       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));
+               return -EIO;
+       }
 
-    ret = sqlite3_bind_text(stmt, 3, uiappid, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
-       DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
-       ret = -EIO;
-       goto out;
-    }
+       ret = sqlite3_bind_text(stmt, 1, appid, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
+               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ret = -EIO;
+               goto out;
+       }
 
-    ret = sqlite3_bind_int(stmt, 4, primary);
-    if (ret != SQLITE_OK) {
-       DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
-       ret = -EIO;
-       goto out;
-    }
+       ret = sqlite3_bind_text(stmt, 2, pkgid, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
+               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ret = -EIO;
+               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 = sqlite3_bind_text(stmt, 3, uiappid, -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) {
+       ret = sqlite3_bind_int(stmt, 4, primary);
+       if (ret != SQLITE_OK) {
                DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
-    }
+               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));
+               ret = -EIO;
+       }
 
 out:
-    sqlite3_reset(stmt);
-    sqlite3_clear_bindings(stmt);
-    sqlite3_finalize(stmt);
-    return ret;
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+       sqlite3_finalize(stmt);
+       return ret;
 }
 
 static inline int db_remove_pkgmap(const char *pkgid)
 {
-    int ret;
-    static const char *dml;
-    sqlite3_stmt *stmt;
+       int ret;
+       static const char *dml;
+       sqlite3_stmt *stmt;
 
-    dml = "DELETE FROM pkgmap WHERE pkgid = ?";
-    ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-    if (ret != SQLITE_OK) {
+       dml = "DELETE FROM pkgmap WHERE pkgid = ?";
+       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
                DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
-       DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+       ret = sqlite3_bind_text(stmt, 1, pkgid, -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));
-       ret = -EIO;
-    }
+       ret = 0;
+       if (sqlite3_step(stmt) != SQLITE_DONE) {
+               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ret = -EIO;
+       }
 
 out:
-    sqlite3_reset(stmt);
-    sqlite3_clear_bindings(stmt);
-    sqlite3_finalize(stmt);
-    return ret;
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+       sqlite3_finalize(stmt);
+       return ret;
 }
 
 static inline int db_create_provider(void)
 {
-    char *err;
-    static const char *ddl;
-
-    ddl = "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 INTEGER, " \
-          "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) ON DELETE CASCADE)";
-
-    if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+       char *err;
+       static const char *ddl;
+
+       ddl = "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 INTEGER, " \
+                  "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) ON DELETE CASCADE)";
+
+       if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
                ErrPrint("Failed to execute the DDL (%s)\n", err);
                return -EIO;
-    }
+       }
 
-    if (sqlite3_changes(s_info.handle) == 0) {
-       ErrPrint("No changes to DB\n");
-    }
+       if (sqlite3_changes(s_info.handle) == 0) {
+               ErrPrint("No changes to DB\n");
+       }
 
-    return 0;
+       return 0;
 }
 
 static inline int db_remove_provider(const char *pkgid)
 {
-    static const char *dml;
-    int ret;
-    sqlite3_stmt *stmt;
+       static const char *dml;
+       int ret;
+       sqlite3_stmt *stmt;
 
-    dml = "DELETE FROM provider WHERE pkgid = ?";
-    ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-    if (ret != SQLITE_OK) {
+       dml = "DELETE FROM provider WHERE pkgid = ?";
+       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
                DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 1, pkgid, -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) {
+       ret = 0;
+       if (sqlite3_step(stmt) != SQLITE_DONE) {
                DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
-    }
+       }
 
 out:
-    sqlite3_reset(stmt);
-    sqlite3_clear_bindings(stmt);
-    sqlite3_finalize(stmt);
-    return ret;
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+       sqlite3_finalize(stmt);
+       return ret;
 }
 static int db_insert_provider(struct widget *widget)
 {
-    static const char *dml;
-    int ret;
-    sqlite3_stmt *stmt;
-    char *abi = (char *)widget->abi;
-    char *box_src = (char *)widget->widget_src;
-    char *box_group = (char *)widget->widget_group;
-    char *gbar_src = (char *)widget->gbar_src;
-    char *gbar_group = (char *)widget->gbar_group;
-    char *libexec = (char *)widget->libexec;
-    char *timeout = (char *)widget->timeout;
-    char *period = (char *)widget->period;
-    char *script = (char *)widget->script;
-    char *hw_acceleration = (char *)widget->hw_acceleration;
-
-    if (!abi) {
-       abi = "c";
-    }
-
-    if (!timeout) {
-       timeout = "10";
-    }
-
-    if (!period) {
-       period = "0.0";
-    }
-
-    if (!script) {
-       script = "edje";
-    }
-
-    if (!hw_acceleration) {
-       hw_acceleration = "none";
-    }
-
-    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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
-    ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-    if (ret != SQLITE_OK) {
+       static const char *dml;
+       int ret;
+       sqlite3_stmt *stmt;
+       char *abi = (char *)widget->abi;
+       char *box_src = (char *)widget->widget_src;
+       char *box_group = (char *)widget->widget_group;
+       char *gbar_src = (char *)widget->gbar_src;
+       char *gbar_group = (char *)widget->gbar_group;
+       char *libexec = (char *)widget->libexec;
+       char *timeout = (char *)widget->timeout;
+       char *period = (char *)widget->period;
+       char *script = (char *)widget->script;
+       char *hw_acceleration = (char *)widget->hw_acceleration;
+
+       if (!abi) {
+               abi = "c";
+       }
+
+       if (!timeout) {
+               timeout = "10";
+       }
+
+       if (!period) {
+               period = "0.0";
+       }
+
+       if (!script) {
+               script = "edje";
+       }
+
+       if (!hw_acceleration) {
+               hw_acceleration = "none";
+       }
+
+       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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 1, (char *)widget->pkgid, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 1, (char *)widget->pkgid, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_int(stmt, 2, widget->network);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_int(stmt, 2, widget->network);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 3, abi, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 3, abi, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
-    ret = sqlite3_bind_int(stmt, 4, widget->secured);
-    if (ret != SQLITE_OK) {
+       }
+       ret = sqlite3_bind_int(stmt, 4, widget->secured);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_int(stmt, 5, widget->widget_type);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_int(stmt, 5, widget->widget_type);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 6, box_src, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 6, box_src, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 7, box_group, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 7, box_group, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_int(stmt, 8, widget->gbar_type);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_int(stmt, 8, widget->gbar_type);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 9, gbar_src, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 9, gbar_src, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 10, gbar_group, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 10, gbar_group, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 11, libexec, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 11, libexec, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_int(stmt, 12, atoi(timeout));
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_int(stmt, 12, atoi(timeout));
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 13, period, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 13, period, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 14, script, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 14, script, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_int(stmt, 15, widget->pinup);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_int(stmt, 15, widget->pinup);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_int(stmt, 16, widget->count);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_int(stmt, 16, widget->count);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_int(stmt, 17, widget->direct_input);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_int(stmt, 17, widget->direct_input);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 18, hw_acceleration, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 18, hw_acceleration, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = 0;
-    if (sqlite3_step(stmt) != SQLITE_DONE) {
+       ret = 0;
+       if (sqlite3_step(stmt) != SQLITE_DONE) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
-    }
+       }
 
 out:
-    sqlite3_reset(stmt);
-    sqlite3_clear_bindings(stmt);
-    sqlite3_finalize(stmt);
-    return ret;
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+       sqlite3_finalize(stmt);
+       return ret;
 }
 
 static inline int db_create_client(void)
 {
-    char *err;
-    static const char *ddl;
+       char *err;
+       static const char *ddl;
 
-    ddl = "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) ON DELETE CASCADE)";
-    if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+       ddl = "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) ON DELETE CASCADE)";
+       if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
                ErrPrint("Failed to execute the DDL (%s)\n", err);
                return -EIO;
-    }
+       }
 
-    if (sqlite3_changes(s_info.handle) == 0) {
-       ErrPrint("No changes to DB\n");
-    }
+       if (sqlite3_changes(s_info.handle) == 0) {
+               ErrPrint("No changes to DB\n");
+       }
 
-    return 0;
+       return 0;
 }
 
 static inline int db_insert_client(struct widget *widget)
 {
-    static const char *dml;
-    int ret;
-    sqlite3_stmt *stmt;
+       static const char *dml;
+       int ret;
+       sqlite3_stmt *stmt;
 
-    dml = "INSERT INTO client ( pkgid, icon, name, auto_launch, gbar_size, content, nodisplay, setup ) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
-    ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-    if (ret != SQLITE_OK) {
+       dml = "INSERT INTO client ( pkgid, icon, name, auto_launch, gbar_size, content, nodisplay, setup ) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
+       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 1, (char *)widget->pkgid, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 1, (char *)widget->pkgid, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 2, (char *)widget->icon, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 2, (char *)widget->icon, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 3, (char *)widget->name, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 3, (char *)widget->name, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 4, (char *)widget->auto_launch, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 4, (char *)widget->auto_launch, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 5, (char *)widget->gbar_size, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 5, (char *)widget->gbar_size, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 6, (char *)widget->content, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 6, (char *)widget->content, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_int(stmt, 7, widget->nodisplay);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_int(stmt, 7, widget->nodisplay);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 8, (char *)widget->setup, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 8, (char *)widget->setup, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = 0;
-    if (sqlite3_step(stmt) != SQLITE_DONE) {
+       ret = 0;
+       if (sqlite3_step(stmt) != SQLITE_DONE) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
-    }
+       }
 
 out:
-    sqlite3_reset(stmt);
-    sqlite3_clear_bindings(stmt);
-    sqlite3_finalize(stmt);
-    return ret;
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+       sqlite3_finalize(stmt);
+       return ret;
 }
 
 static inline int db_remove_client(const char *pkgid)
 {
-    static const char *dml;
-    int ret;
-    sqlite3_stmt *stmt;
+       static const char *dml;
+       int ret;
+       sqlite3_stmt *stmt;
 
-    dml = "DELETE FROM client WHERE pkgid = ?";
-    ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-    if (ret != SQLITE_OK) {
+       dml = "DELETE FROM client WHERE pkgid = ?";
+       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
                DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 1, pkgid, -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) {
+       ret = 0;
+       if (sqlite3_step(stmt) != SQLITE_DONE) {
                DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
-    }
+       }
 
 out:
-    sqlite3_reset(stmt);
-    sqlite3_clear_bindings(stmt);
-    sqlite3_finalize(stmt);
-    return ret;
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+       sqlite3_finalize(stmt);
+       return ret;
 }
 
 static inline int db_create_i18n(void)
 {
-    char *err;
-    static const char *ddl;
+       char *err;
+       static const char *ddl;
 
-    ddl = "CREATE TABLE i18n ( pkgid TEXT NOT NULL, lang TEXT COLLATE NOCASE, name TEXT, " \
-          "icon TEXT, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE)";
-    if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+       ddl = "CREATE TABLE i18n ( pkgid TEXT NOT NULL, lang TEXT COLLATE NOCASE, name TEXT, " \
+                  "icon TEXT, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE)";
+       if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
                ErrPrint("Failed to execute the DDL (%s)\n", err);
                return -EIO;
-    }
+       }
 
-    if (sqlite3_changes(s_info.handle) == 0) {
-       ErrPrint("No changes to DB\n");
-    }
+       if (sqlite3_changes(s_info.handle) == 0) {
+               ErrPrint("No changes to DB\n");
+       }
 
-    return 0;
+       return 0;
 }
 
 static inline int db_insert_i18n(const char *pkgid, const char *lang, const char *name, const char *icon)
 {
-    static const char *dml;
-    int ret;
-    sqlite3_stmt *stmt;
-
-    DbgPrint("%s - lang[%s] name[%s] icon[%s]\n", pkgid, lang, name, icon);
-    dml = "INSERT INTO i18n ( pkgid, lang, name, icon ) VALUES (?, ?, ?, ?)";
-    ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-    if (ret != SQLITE_OK) {
+       static const char *dml;
+       int ret;
+       sqlite3_stmt *stmt;
+
+       DbgPrint("%s - lang[%s] name[%s] icon[%s]\n", pkgid, lang, name, icon);
+       dml = "INSERT INTO i18n ( pkgid, lang, name, icon ) VALUES (?, ?, ?, ?)";
+       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 2, lang, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 2, lang, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 3, name, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 3, name, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 4, icon, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 4, icon, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = 0;
-    if (sqlite3_step(stmt) != SQLITE_DONE) {
+       ret = 0;
+       if (sqlite3_step(stmt) != SQLITE_DONE) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
-    }
+       }
 
 out:
-    sqlite3_reset(stmt);
-    sqlite3_clear_bindings(stmt);
-    sqlite3_finalize(stmt);
-    return ret;
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+       sqlite3_finalize(stmt);
+       return ret;
 }
 
 static inline int db_remove_i18n(const char *pkgid)
 {
-    static const char *dml;
-    int ret;
-    sqlite3_stmt *stmt;
+       static const char *dml;
+       int ret;
+       sqlite3_stmt *stmt;
 
-    dml = "DELETE FROM i18n WHERE pkgid = ?";
-    ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-    if (ret != SQLITE_OK) {
+       dml = "DELETE FROM i18n WHERE pkgid = ?";
+       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
                DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 1, pkgid, -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) {
+       ret = 0;
+       if (sqlite3_step(stmt) != SQLITE_DONE) {
                DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
-    }
+       }
 
-    if (sqlite3_changes(s_info.handle) == 0) {
-       DbgPrint("No changes\n");
-    }
+       if (sqlite3_changes(s_info.handle) == 0) {
+               DbgPrint("No changes\n");
+       }
 
 out:
-    sqlite3_reset(stmt);
-    sqlite3_clear_bindings(stmt);
-    sqlite3_finalize(stmt);
-    return ret;
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+       sqlite3_finalize(stmt);
+       return ret;
 }
 
 static inline int db_create_group(void)
 {
-    char *err;
-    static const char *ddl;
+       char *err;
+       static const char *ddl;
 
-    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)";
-    if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+       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)";
+       if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
                ErrPrint("Failed to execute the DDL (%s)\n", err);
                return -EIO;
-    }
+       }
 
-    if (sqlite3_changes(s_info.handle) == 0) {
-       ErrPrint("No changes to DB\n");
-    }
+       if (sqlite3_changes(s_info.handle) == 0) {
+               ErrPrint("No changes to DB\n");
+       }
 
-    return 0;
+       return 0;
 }
 
 static inline int db_insert_group(const char *pkgid, const char *cluster, const char *category)
 {
-    static const char *dml;
-    int ret;
-    sqlite3_stmt *stmt;
+       static const char *dml;
+       int ret;
+       sqlite3_stmt *stmt;
 
-    dml = "INSERT INTO groupinfo ( cluster, category, pkgid ) VALUES (?, ?, ?)";
-    ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-    if (ret != SQLITE_OK) {
+       dml = "INSERT INTO groupinfo ( cluster, category, pkgid ) VALUES (?, ?, ?)";
+       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 1, cluster, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 1, cluster, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 2, category, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 2, category, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 3, pkgid, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 3, pkgid, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = 0;
-    if (sqlite3_step(stmt) != SQLITE_DONE) {
+       ret = 0;
+       if (sqlite3_step(stmt) != SQLITE_DONE) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
-    }
+       }
 
 out:
-    sqlite3_reset(stmt);
-    sqlite3_clear_bindings(stmt);
-    sqlite3_finalize(stmt);
-    return ret;
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+       sqlite3_finalize(stmt);
+       return ret;
 }
 
 static int db_get_group_id(const char *cluster, const char *category)
 {
-    static const char *dml = "SELECT id FROM groupinfo WHERE cluster = ? AND category = ?";
-    sqlite3_stmt *stmt;
-    int ret;
+       static const char *dml = "SELECT id FROM groupinfo WHERE cluster = ? AND category = ?";
+       sqlite3_stmt *stmt;
+       int ret;
 
-    if (!cluster || !category) {
+       if (!cluster || !category) {
                ErrPrint("Invalid argument\n");
                return -EINVAL;
-    }
+       }
 
-    ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
                ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
-    }
+       }
 
-    ret = -EIO;
-    if (sqlite3_bind_text(stmt, 1, cluster, -1, SQLITE_TRANSIENT) != SQLITE_OK) {
+       ret = -EIO;
+       if (sqlite3_bind_text(stmt, 1, cluster, -1, SQLITE_TRANSIENT) != SQLITE_OK) {
                ErrPrint("Failed to bind a cluster(%s) - %s\n", cluster, sqlite3_errmsg(s_info.handle));
                goto out;
-    }
+       }
 
-    if (sqlite3_bind_text(stmt, 2, category, -1, SQLITE_TRANSIENT) != SQLITE_OK) {
+       if (sqlite3_bind_text(stmt, 2, category, -1, SQLITE_TRANSIENT) != SQLITE_OK) {
                ErrPrint("Failed to bind a category(%s) - %s\n", category, sqlite3_errmsg(s_info.handle));
                goto out;
-    }
+       }
 
-    if (sqlite3_step(stmt) != SQLITE_ROW) {
+       if (sqlite3_step(stmt) != SQLITE_ROW) {
                ErrPrint("Failed to execute the DML for %s - %s\n", cluster, category);
                goto out;
-    }
+       }
 
-    ret = sqlite3_column_int(stmt, 0);
+       ret = sqlite3_column_int(stmt, 0);
 
 out:
-    sqlite3_reset(stmt);
-    sqlite3_clear_bindings(stmt);
-    sqlite3_finalize(stmt);
-    return ret;
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+       sqlite3_finalize(stmt);
+       return ret;
 }
 
 static inline int db_remove_group(const char *pkgid)
 {
-    static const char *dml;
-    int ret;
-    sqlite3_stmt *stmt;
+       static const char *dml;
+       int ret;
+       sqlite3_stmt *stmt;
 
-    dml = "DELETE FROM groupinfo WHERE pkgid = ?";
-    ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-    if (ret != SQLITE_OK) {
+       dml = "DELETE FROM groupinfo WHERE pkgid = ?";
+       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
                DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 1, pkgid, -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) {
+       ret = 0;
+       if (sqlite3_step(stmt) != SQLITE_DONE) {
                DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
-    }
+       }
 
-    if (sqlite3_changes(s_info.handle) == 0) {
-       DbgPrint("No changes\n");
-    }
+       if (sqlite3_changes(s_info.handle) == 0) {
+               DbgPrint("No changes\n");
+       }
 
 out:
-    sqlite3_reset(stmt);
-    sqlite3_clear_bindings(stmt);
-    sqlite3_finalize(stmt);
-    return ret;
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+       sqlite3_finalize(stmt);
+       return ret;
 }
 
 static inline int db_create_groupmap(void)
 {
-    char *err;
-    static const char *ddl;
+       char *err;
+       static const char *ddl;
 
-    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)";
-    if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+       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)";
+       if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
                ErrPrint("Failed to execute the DDL (%s)\n", err);
                return -EIO;
-    }
+       }
 
-    if (sqlite3_changes(s_info.handle) == 0) {
-       ErrPrint("No changes to DB\n");
-    }
+       if (sqlite3_changes(s_info.handle) == 0) {
+               ErrPrint("No changes to DB\n");
+       }
 
-    return 0;
+       return 0;
 }
 
 static inline int db_get_option_id(int id, const char *pkgid, const char *ctx_item)
 {
-    static const char *dml;
-    int ret;
-    sqlite3_stmt *stmt;
+       static const char *dml;
+       int ret;
+       sqlite3_stmt *stmt;
 
-    dml = "SELECT option_id FROM groupmap WHERE id = ? AND pkgid = ? AND ctx_item = ?";
-    ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-    if (ret != SQLITE_OK) {
+       dml = "SELECT option_id FROM groupmap WHERE id = ? AND pkgid = ? AND ctx_item = ?";
+       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
                DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
-    }
+       }
 
-    ret = sqlite3_bind_int(stmt, 1, id);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_int(stmt, 1, id);
+       if (ret != SQLITE_OK) {
                DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 2, pkgid, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 2, pkgid, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 3, ctx_item, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 3, ctx_item, -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_ROW) {
+       ret = 0;
+       if (sqlite3_step(stmt) != SQLITE_ROW) {
                DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_column_int(stmt, 0);
+       ret = sqlite3_column_int(stmt, 0);
 
 out:
-    sqlite3_reset(stmt);
-    sqlite3_clear_bindings(stmt);
-    sqlite3_finalize(stmt);
-    return ret;
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+       sqlite3_finalize(stmt);
+       return ret;
 }
 
 static inline int db_insert_groupmap(int id, const char *pkgid, const char *ctx_item)
 {
-    static const char *dml;
-    int ret;
-    sqlite3_stmt *stmt;
+       static const char *dml;
+       int ret;
+       sqlite3_stmt *stmt;
 
-    DbgPrint("%d (%s) add to groupmap\n", id, pkgid);
+       DbgPrint("%d (%s) add to groupmap\n", id, pkgid);
 
-    dml = "INSERT INTO groupmap ( id, pkgid, ctx_item ) VALUES (?, ?, ?)";
-    ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-    if (ret != SQLITE_OK) {
+       dml = "INSERT INTO groupmap ( id, pkgid, ctx_item ) VALUES (?, ?, ?)";
+       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
-    }
+       }
 
-    ret = sqlite3_bind_int(stmt, 1, id);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_int(stmt, 1, id);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 2, pkgid, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 2, pkgid, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 3, ctx_item, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 3, ctx_item, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = 0;
-    if (sqlite3_step(stmt) != SQLITE_DONE) {
+       ret = 0;
+       if (sqlite3_step(stmt) != SQLITE_DONE) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
-    }
+       }
 
 out:
-    sqlite3_reset(stmt);
-    sqlite3_clear_bindings(stmt);
-    sqlite3_finalize(stmt);
-    return ret;
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+       sqlite3_finalize(stmt);
+       return ret;
 }
 
 static inline int db_remove_groupmap(const char *pkgid)
 {
-    static const char *dml;
-    int ret;
-    sqlite3_stmt *stmt;
+       static const char *dml;
+       int ret;
+       sqlite3_stmt *stmt;
 
-    dml = "DELETE FROM groupmap WHERE pkgid = ?";
-    ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-    if (ret != SQLITE_OK) {
+       dml = "DELETE FROM groupmap WHERE pkgid = ?";
+       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
                DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 1, pkgid, -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));
-       ret = -EIO;
-    }
+       ret = 0;
+       if (sqlite3_step(stmt) != SQLITE_DONE) {
+               DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+               ret = -EIO;
+       }
 
-    if (sqlite3_changes(s_info.handle) == 0) {
-       DbgPrint("No changes\n");
-    }
+       if (sqlite3_changes(s_info.handle) == 0) {
+               DbgPrint("No changes\n");
+       }
 
 out:
-    sqlite3_reset(stmt);
-    sqlite3_clear_bindings(stmt);
-    sqlite3_finalize(stmt);
-    return ret;
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+       sqlite3_finalize(stmt);
+       return ret;
 }
 
 static inline int db_create_option(void)
 {
-    char *err;
-    static const char *ddl;
+       char *err;
+       static const char *ddl;
 
-    ddl = "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)";
-    if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+       ddl = "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)";
+       if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
                ErrPrint("Failed to execute the DDL (%s)\n", err);
                return -EIO;
-    }
+       }
 
-    if (sqlite3_changes(s_info.handle) == 0) {
-       ErrPrint("No changes to DB\n");
-    }
+       if (sqlite3_changes(s_info.handle) == 0) {
+               ErrPrint("No changes to DB\n");
+       }
 
-    return 0;
+       return 0;
 }
 
 static inline int db_insert_option(const char *pkgid, int option_id, const char *key, const char *value)
 {
-    static const char *dml;
-    int ret;
-    sqlite3_stmt *stmt;
+       static const char *dml;
+       int ret;
+       sqlite3_stmt *stmt;
 
-    dml = "INSERT INTO option (pkgid, option_id, key, value) VALUES (?, ?, ?, ?)";
-    ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-    if (ret != SQLITE_OK) {
+       dml = "INSERT INTO option (pkgid, option_id, key, value) VALUES (?, ?, ?, ?)";
+       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_int(stmt, 2, option_id);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_int(stmt, 2, option_id);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 3, key, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 3, key, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 4, value, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 4, value, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = 0;
-    if (sqlite3_step(stmt) != SQLITE_DONE) {
+       ret = 0;
+       if (sqlite3_step(stmt) != SQLITE_DONE) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
-    }
+       }
 out:
-    sqlite3_reset(stmt);
-    sqlite3_clear_bindings(stmt);
-    sqlite3_finalize(stmt);
-    return ret;
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+       sqlite3_finalize(stmt);
+       return ret;
 }
 
 static inline int db_remove_option(const char *pkgid)
 {
-    static const char *dml;
-    int ret;
-    sqlite3_stmt *stmt;
+       static const char *dml;
+       int ret;
+       sqlite3_stmt *stmt;
 
-    dml = "DELETE FROM option WHERE pkgid = ?";
-    ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-    if (ret != SQLITE_OK) {
+       dml = "DELETE FROM option WHERE pkgid = ?";
+       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
                DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 1, pkgid, -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) {
+       ret = 0;
+       if (sqlite3_step(stmt) != SQLITE_DONE) {
                DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
-    }
+       }
 
-    if (sqlite3_changes(s_info.handle) == 0) {
-       DbgPrint("No changes\n");
-    }
+       if (sqlite3_changes(s_info.handle) == 0) {
+               DbgPrint("No changes\n");
+       }
 
 out:
-    sqlite3_reset(stmt);
-    sqlite3_clear_bindings(stmt);
-    sqlite3_finalize(stmt);
-    return ret;
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+       sqlite3_finalize(stmt);
+       return ret;
 }
 
 static inline int db_create_box_size(void)
 {
-    char *err;
-    static const char *ddl;
+       char *err;
+       static const char *ddl;
 
-    ddl = "CREATE TABLE box_size ( pkgid TEXT NOT NULL, size_type INTEGER, preview TEXT, touch_effect INTEGER, need_frame INTEGER, mouse_event INTEGER " \
-          "FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE)";
-    if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+       ddl = "CREATE TABLE box_size ( pkgid TEXT NOT NULL, size_type INTEGER, preview TEXT, touch_effect INTEGER, need_frame INTEGER, mouse_event INTEGER " \
+                  "FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE)";
+       if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
                ErrPrint("Failed to execute the DDL (%s)\n", err);
                return -EIO;
-    }
+       }
 
-    if (sqlite3_changes(s_info.handle) == 0) {
-       ErrPrint("No changes to DB\n");
-    }
+       if (sqlite3_changes(s_info.handle) == 0) {
+               ErrPrint("No changes to DB\n");
+       }
 
-    return 0;
+       return 0;
 }
 
 static int db_insert_box_size(const char *pkgid, int size_type, const char *preview, int touch_effect, int need_frame, int mouse_event)
 {
-    static const char *dml;
-    int ret;
-    sqlite3_stmt *stmt;
-
-    DbgPrint("box size: %s - %d (%s) is added\n", pkgid, size_type, preview);
-    dml = "INSERT INTO box_size ( pkgid, size_type, preview, touch_effect, need_frame, mouse_event ) VALUES (?, ?, ?, ?, ?, ?)";
-    ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-    if (ret != SQLITE_OK) {
+       static const char *dml;
+       int ret;
+       sqlite3_stmt *stmt;
+
+       DbgPrint("box size: %s - %d (%s) is added\n", pkgid, size_type, preview);
+       dml = "INSERT INTO box_size ( pkgid, size_type, preview, touch_effect, need_frame, mouse_event ) VALUES (?, ?, ?, ?, ?, ?)";
+       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_int(stmt, 2, size_type);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_int(stmt, 2, size_type);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 3, preview, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 3, preview, -1, SQLITE_TRANSIENT);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_int(stmt, 4, touch_effect);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_int(stmt, 4, touch_effect);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_int(stmt, 5, need_frame);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_int(stmt, 5, need_frame);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = sqlite3_bind_int(stmt, 6, mouse_event);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_int(stmt, 6, mouse_event);
+       if (ret != SQLITE_OK) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
                goto out;
-    }
+       }
 
-    ret = 0;
-    if (sqlite3_step(stmt) != SQLITE_DONE) {
+       ret = 0;
+       if (sqlite3_step(stmt) != SQLITE_DONE) {
                ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
-    }
+       }
 
 out:
-    sqlite3_reset(stmt);
-    sqlite3_clear_bindings(stmt);
-    sqlite3_finalize(stmt);
-    return ret;
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+       sqlite3_finalize(stmt);
+       return ret;
 }
 
 static inline int db_remove_box_size(const char *pkgid)
 {
-    static const char *dml;
-    int ret;
-    sqlite3_stmt *stmt;
+       static const char *dml;
+       int ret;
+       sqlite3_stmt *stmt;
 
-    dml = "DELETE FROM box_size WHERE pkgid = ?";
-    ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-    if (ret != SQLITE_OK) {
+       dml = "DELETE FROM box_size WHERE pkgid = ?";
+       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
                DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
-    }
+       }
 
-    ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_bind_text(stmt, 1, pkgid, -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) {
+       ret = 0;
+       if (sqlite3_step(stmt) != SQLITE_DONE) {
                DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
-    }
+       }
 
-    if (sqlite3_changes(s_info.handle) == 0) {
-       DbgPrint("No changes\n");
-    }
+       if (sqlite3_changes(s_info.handle) == 0) {
+               DbgPrint("No changes\n");
+       }
 
 out:
-    sqlite3_reset(stmt);
-    sqlite3_clear_bindings(stmt);
-    sqlite3_finalize(stmt);
-    return ret;
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+       sqlite3_finalize(stmt);
+       return ret;
 }
 
 static inline void db_create_table(void)
 {
-    int ret;
-    begin_transaction();
+       int ret;
+       begin_transaction();
 
-    ret = db_create_pkgmap();
-    if (ret < 0) {
+       ret = db_create_pkgmap();
+       if (ret < 0) {
                rollback_transaction();
                return;
-    }
+       }
 
-    ret = db_create_provider();
-    if (ret < 0) {
+       ret = db_create_provider();
+       if (ret < 0) {
                rollback_transaction();
                return;
-    }
+       }
 
-    ret = db_create_client();
-    if (ret < 0) {
+       ret = db_create_client();
+       if (ret < 0) {
                rollback_transaction();
                return;
-    }
+       }
 
-    ret = db_create_i18n();
-    if (ret < 0) {
+       ret = db_create_i18n();
+       if (ret < 0) {
                rollback_transaction();
                return;
-    }
+       }
 
-    ret = db_create_box_size();
-    if (ret < 0) {
+       ret = db_create_box_size();
+       if (ret < 0) {
                rollback_transaction();
                return;
-    }
+       }
 
-    ret = db_create_group();
-    if (ret < 0) {
+       ret = db_create_group();
+       if (ret < 0) {
                rollback_transaction();
                return;
-    }
+       }
 
-    ret = db_create_option();
-    if (ret < 0) {
+       ret = db_create_option();
+       if (ret < 0) {
                rollback_transaction();
                return;
-    }
+       }
 
-    ret = db_create_groupmap();
-    if (ret < 0) {
+       ret = db_create_groupmap();
+       if (ret < 0) {
                rollback_transaction();
                return;
-    }
+       }
 
-    commit_transaction();
+       commit_transaction();
 }
 
 int db_init(void)
 {
-    int ret;
-    struct stat stat;
+       int ret;
+       struct stat stat;
 
-    ret = db_util_open(s_info.dbfile, &s_info.handle, DB_UTIL_REGISTER_HOOK_METHOD);
-    if (ret != SQLITE_OK) {
+       ret = db_util_open(s_info.dbfile, &s_info.handle, DB_UTIL_REGISTER_HOOK_METHOD);
+       if (ret != SQLITE_OK) {
                ErrPrint("Failed to open a DB\n");
                return -EIO;
-    }
+       }
 
-    if (lstat(s_info.dbfile, &stat) < 0) {
+       if (lstat(s_info.dbfile, &stat) < 0) {
                ErrPrint("%s\n", strerror(errno));
                db_util_close(s_info.handle);
                s_info.handle = NULL;
                return -EIO;
-    }
+       }
 
-    if (!S_ISREG(stat.st_mode)) {
+       if (!S_ISREG(stat.st_mode)) {
                ErrPrint("Invalid file\n");
                db_util_close(s_info.handle);
                s_info.handle = NULL;
                return -EINVAL;
-    }
+       }
 
-    if (!stat.st_size) {
-       db_create_table();
-    }
+       if (!stat.st_size) {
+               db_create_table();
+       }
 
-    return 0;
+       return 0;
 }
 
 int db_fini(void)
 {
-    if (!s_info.handle) {
-       return 0;
-    }
+       if (!s_info.handle) {
+               return 0;
+       }
 
-    db_util_close(s_info.handle);
-    s_info.handle = NULL;
+       db_util_close(s_info.handle);
+       s_info.handle = NULL;
 
-    return 0;
+       return 0;
 }
 
 int db_check(void)
@@ -1870,60 +1870,60 @@ int db_check(void)
 
 static inline int validate_pkgid(const char *appid, const char *pkgid)
 {
-    /* Just return 1 Always */
-    return 1 || !strncmp(appid, pkgid, strlen(appid));
+       /* Just return 1 Always */
+       return 1 || !strncmp(appid, pkgid, strlen(appid));
 }
 
 static int widget_destroy(struct widget *widget)
 {
-    struct dlist *l;
-    struct dlist *n;
-    struct i18n *i18n;
-    struct group *group;
-    struct option *option;
-    struct dlist *il;
-    struct dlist *in;
-
-    xmlFree(widget->auto_launch);
-    xmlFree(widget->pkgid);
-    xmlFree(widget->abi);
-    xmlFree(widget->name);
-    xmlFree(widget->icon);
-    xmlFree(widget->widget_src);
-    xmlFree(widget->widget_group);
-    xmlFree(widget->gbar_src);
-    xmlFree(widget->gbar_group);
-    xmlFree(widget->gbar_size);
-    xmlFree(widget->libexec);
-    xmlFree(widget->script);
-    xmlFree(widget->period);
-    xmlFree(widget->content);
-    xmlFree(widget->setup);
-    xmlFree(widget->category);
-    xmlFree(widget->preview[0]); /* 1x1 */
-    xmlFree(widget->preview[1]); /* 2x1 */
-    xmlFree(widget->preview[2]); /* 2x2 */
-    xmlFree(widget->preview[3]); /* 4x1 */
-    xmlFree(widget->preview[4]); /* 4x2 */
-    xmlFree(widget->preview[5]); /* 4x3 */
-    xmlFree(widget->preview[6]); /* 4x4 */
-    xmlFree(widget->preview[7]); /* 4x5 */
-    xmlFree(widget->preview[8]); /* 4x6 */
-    xmlFree(widget->preview[9]); /* easy 1x1 */
-    xmlFree(widget->preview[10]); /* easy 3x1 */
-    xmlFree(widget->preview[11]); /* easy 3x3 */
-    xmlFree(widget->preview[12]); /* full */
-    xmlFree(widget->hw_acceleration);
-
-    dlist_foreach_safe(widget->i18n_list, l, n, i18n) {
+       struct dlist *l;
+       struct dlist *n;
+       struct i18n *i18n;
+       struct group *group;
+       struct option *option;
+       struct dlist *il;
+       struct dlist *in;
+
+       xmlFree(widget->auto_launch);
+       xmlFree(widget->pkgid);
+       xmlFree(widget->abi);
+       xmlFree(widget->name);
+       xmlFree(widget->icon);
+       xmlFree(widget->widget_src);
+       xmlFree(widget->widget_group);
+       xmlFree(widget->gbar_src);
+       xmlFree(widget->gbar_group);
+       xmlFree(widget->gbar_size);
+       xmlFree(widget->libexec);
+       xmlFree(widget->script);
+       xmlFree(widget->period);
+       xmlFree(widget->content);
+       xmlFree(widget->setup);
+       xmlFree(widget->category);
+       xmlFree(widget->preview[0]); /* 1x1 */
+       xmlFree(widget->preview[1]); /* 2x1 */
+       xmlFree(widget->preview[2]); /* 2x2 */
+       xmlFree(widget->preview[3]); /* 4x1 */
+       xmlFree(widget->preview[4]); /* 4x2 */
+       xmlFree(widget->preview[5]); /* 4x3 */
+       xmlFree(widget->preview[6]); /* 4x4 */
+       xmlFree(widget->preview[7]); /* 4x5 */
+       xmlFree(widget->preview[8]); /* 4x6 */
+       xmlFree(widget->preview[9]); /* easy 1x1 */
+       xmlFree(widget->preview[10]); /* easy 3x1 */
+       xmlFree(widget->preview[11]); /* easy 3x3 */
+       xmlFree(widget->preview[12]); /* full */
+       xmlFree(widget->hw_acceleration);
+
+       dlist_foreach_safe(widget->i18n_list, l, n, i18n) {
                widget->i18n_list = dlist_remove(widget->i18n_list, l);
                xmlFree(i18n->name);
                xmlFree(i18n->icon);
                xmlFree(i18n->lang);
                free(i18n);
-    }
+       }
 
-    dlist_foreach_safe(widget->group_list, l, n, group) {
+       dlist_foreach_safe(widget->group_list, l, n, group) {
                widget->group_list = dlist_remove(widget->group_list, l);
                DbgPrint("Release %s/%s\n", group->cluster, group->category);
 
@@ -1941,27 +1941,27 @@ static int widget_destroy(struct widget *widget)
                xmlFree(group->cluster);
                xmlFree(group->category);
                free(group);
-    }
+       }
 
-    free(widget);
-    return 0;
+       free(widget);
+       return 0;
 }
 
 static inline void update_i18n_name(struct widget *widget, xmlNodePtr node)
 {
-    struct i18n *i18n;
-    struct dlist *l;
-    xmlChar *lang;
-    xmlChar *name;
+       struct i18n *i18n;
+       struct dlist *l;
+       xmlChar *lang;
+       xmlChar *name;
 
-    name = xmlNodeGetContent(node);
-    if (!name) {
+       name = xmlNodeGetContent(node);
+       if (!name) {
                ErrPrint("Invalid tag\n");
                return;
-    }
+       }
 
-    lang = xmlNodeGetLang(node);
-    if (!lang) {
+       lang = xmlNodeGetLang(node);
+       if (!lang) {
                if (widget->name) {
                        DbgPrint("Override default name: %s\n", widget->name);
                        xmlFree(widget->name);
@@ -1969,9 +1969,9 @@ static inline void update_i18n_name(struct widget *widget, xmlNodePtr node)
 
                widget->name = name;
                return;
-    }
+       }
 
-    dlist_foreach(widget->i18n_list, l, i18n) {
+       dlist_foreach(widget->i18n_list, l, i18n) {
                if (!xmlStrcasecmp(i18n->lang, lang)) {
                        if (i18n->name) {
                                DbgPrint("Override name: %s\n", i18n->name);
@@ -1981,37 +1981,37 @@ static inline void update_i18n_name(struct widget *widget, xmlNodePtr node)
                        i18n->name = name;
                        return;
                }
-    }
+       }
 
-    i18n = calloc(1, sizeof(*i18n));
-    if (!i18n) {
+       i18n = calloc(1, sizeof(*i18n));
+       if (!i18n) {
                ErrPrint("Heap: %s\n", strerror(errno));
                xmlFree(name);
                xmlFree(lang);
                return;
-    }
+       }
 
-    i18n->name = name;
-    i18n->lang = lang;
-    DbgPrint("Label[%s] - [%s] added\n", i18n->lang, i18n->name);
-    widget->i18n_list = dlist_append(widget->i18n_list, i18n);
+       i18n->name = name;
+       i18n->lang = lang;
+       DbgPrint("Label[%s] - [%s] added\n", i18n->lang, i18n->name);
+       widget->i18n_list = dlist_append(widget->i18n_list, i18n);
 }
 
 static inline void update_i18n_icon(struct widget *widget, xmlNodePtr node)
 {
-    struct i18n *i18n;
-    struct dlist *l;
-    xmlChar *lang;
-    xmlChar *icon;
+       struct i18n *i18n;
+       struct dlist *l;
+       xmlChar *lang;
+       xmlChar *icon;
 
-    icon = xmlNodeGetContent(node);
-    if (!icon) {
+       icon = xmlNodeGetContent(node);
+       if (!icon) {
                ErrPrint("Invalid tag\n");
                return;
-    }
+       }
 
-    lang = xmlNodeGetLang(node);
-    if (!lang) {
+       lang = xmlNodeGetLang(node);
+       if (!lang) {
                if (widget->icon) {
                        DbgPrint("Override default icon: %s\n", widget->icon);
                        xmlFree(widget->icon);
@@ -2019,151 +2019,151 @@ static inline void update_i18n_icon(struct widget *widget, xmlNodePtr node)
 
                widget->icon = icon;
                return;
-    }
+       }
 
-    dlist_foreach(widget->i18n_list, l, i18n) {
-       if (!xmlStrcasecmp(i18n->lang, lang)) {
-           if (i18n->icon) {
-                       DbgPrint("Override icon %s for %s\n", i18n->icon, i18n->name);
-                       xmlFree(i18n->icon);
-           }
+       dlist_foreach(widget->i18n_list, l, i18n) {
+               if (!xmlStrcasecmp(i18n->lang, lang)) {
+                       if (i18n->icon) {
+                               DbgPrint("Override icon %s for %s\n", i18n->icon, i18n->name);
+                               xmlFree(i18n->icon);
+                       }
 
-           i18n->icon = icon;
-           return;
+                       i18n->icon = icon;
+                       return;
+               }
        }
-    }
 
-    i18n = calloc(1, sizeof(*i18n));
-    if (!i18n) {
+       i18n = calloc(1, sizeof(*i18n));
+       if (!i18n) {
                ErrPrint("Heap: %s\n", strerror(errno));
                xmlFree(icon);
                xmlFree(lang);
                return;
-    }
+       }
 
-    i18n->icon = icon;
-    i18n->lang = lang;
-    DbgPrint("Icon[%s] - [%s] added\n", i18n->lang, i18n->icon);
-    widget->i18n_list = dlist_append(widget->i18n_list, i18n);
+       i18n->icon = icon;
+       i18n->lang = lang;
+       DbgPrint("Icon[%s] - [%s] added\n", i18n->lang, i18n->icon);
+       widget->i18n_list = dlist_append(widget->i18n_list, i18n);
 }
 
 static inline void update_launch(struct widget *widget, xmlNodePtr node)
 {
-    xmlChar *launch;
+       xmlChar *launch;
 
-    launch = xmlNodeGetContent(node);
-    if (!launch) {
+       launch = xmlNodeGetContent(node);
+       if (!launch) {
                DbgPrint("Has no launch\n");
                return;
-    }
+       }
 
-    if (widget->auto_launch) {
-       xmlFree(widget->auto_launch);
-    }
+       if (widget->auto_launch) {
+               xmlFree(widget->auto_launch);
+       }
 
-    widget->auto_launch = xmlStrdup(launch);
-    if (!widget->auto_launch) {
+       widget->auto_launch = xmlStrdup(launch);
+       if (!widget->auto_launch) {
                ErrPrint("Failed to duplicate string: %s\n", (char *)launch);
                return;
-    }
+       }
 }
 
 static inline int update_category(struct widget *widget, xmlNodePtr node)
 {
-    xmlChar *category;
+       xmlChar *category;
 
-    category = xmlGetProp(node, (const xmlChar *)"name");
-    if (!category) {
+       category = xmlGetProp(node, (const xmlChar *)"name");
+       if (!category) {
                DbgPrint("Has no valid category\n");
                return 0;
-    }
+       }
 
        if (!xmlStrcasecmp(category, (const xmlChar *)WATCH_CATEGORY)) {
                ErrPrint("Widget tries to install WATCH: %s\n", widget->pkgid);
                return -EINVAL;
        }
 
-    if (widget->category) {
-       xmlFree(widget->category);
-    }
+       if (widget->category) {
+               xmlFree(widget->category);
+       }
 
-    widget->category = xmlStrdup(category);
-    if (!widget->category) {
+       widget->category = xmlStrdup(category);
+       if (!widget->category) {
                ErrPrint("Failed to duplicate string: %s\n", (char *)category);
                return -EINVAL;
-    }
+       }
 
        return 0;
 }
 
 static inline void update_ui_appid(struct widget *widget, xmlNodePtr node)
 {
-    xmlChar *uiapp;
-    uiapp = xmlNodeGetContent(node);
-    if (!uiapp) {
+       xmlChar *uiapp;
+       uiapp = xmlNodeGetContent(node);
+       if (!uiapp) {
                DbgPrint("Has no valid ui-appid\n");
                return;
-    }
+       }
 
-    if (widget->uiapp) {
-       xmlFree(widget->uiapp);
-    }
+       if (widget->uiapp) {
+               xmlFree(widget->uiapp);
+       }
 
-    widget->uiapp = xmlStrdup(uiapp);
-    if (!widget->uiapp) {
+       widget->uiapp = xmlStrdup(uiapp);
+       if (!widget->uiapp) {
                ErrPrint("Failed to duplicate string: %s\n", (char *)uiapp);
                return;
-    }
+       }
 }
 
 static inline void update_setup(struct widget *widget, xmlNodePtr node)
 {
-    xmlChar *setup;
-    setup = xmlNodeGetContent(node);
-    if (!setup) {
+       xmlChar *setup;
+       setup = xmlNodeGetContent(node);
+       if (!setup) {
                DbgPrint("Has no setup\n");
                return;
-    }
+       }
 
-    if (widget->setup) {
-       xmlFree(widget->setup);
-    }
+       if (widget->setup) {
+               xmlFree(widget->setup);
+       }
 
-    widget->setup = xmlStrdup(setup);
-    if (!widget->setup) {
+       widget->setup = xmlStrdup(setup);
+       if (!widget->setup) {
                ErrPrint("Failed to duplicate string: %s\n", (char *)setup);
                return;
-    }
+       }
 }
 
 static inline void update_content(struct widget *widget, xmlNodePtr node)
 {
-    xmlChar *content;
-    content = xmlNodeGetContent(node);
-    if (!content) {
+       xmlChar *content;
+       content = xmlNodeGetContent(node);
+       if (!content) {
                DbgPrint("Has no content\n");
                return;
-    }
+       }
 
-    if (widget->content) {
-       xmlFree(widget->content);
-    }
+       if (widget->content) {
+               xmlFree(widget->content);
+       }
 
-    widget->content = xmlStrdup(content);
-    if (!widget->content) {
+       widget->content = xmlStrdup(content);
+       if (!widget->content) {
                ErrPrint("Failed to duplicate string: %s\n", (char *)content);
                return;
-    }
+       }
 }
 
 static void update_size_info(struct widget *widget, int idx, xmlNodePtr node)
 {
-    if (xmlHasProp(node, (const xmlChar *)"preview")) {
-       widget->preview[idx] = xmlGetProp(node, (const xmlChar *)"preview");
-    }
+       if (xmlHasProp(node, (const xmlChar *)"preview")) {
+               widget->preview[idx] = xmlGetProp(node, (const xmlChar *)"preview");
+       }
 
-    if (xmlHasProp(node, (const xmlChar *)"need_frame")) {
-       xmlChar *need_frame;
+       if (xmlHasProp(node, (const xmlChar *)"need_frame")) {
+               xmlChar *need_frame;
 
                need_frame = xmlGetProp(node, (const xmlChar *)"need_frame");
                if (need_frame) {
@@ -2172,11 +2172,11 @@ static void update_size_info(struct widget *widget, int idx, xmlNodePtr node)
                } else {
                        widget->need_frame[idx] = widget->default_need_frame;
                }
-    } else {
-       widget->need_frame[idx] = widget->default_need_frame;
-    }
+       } else {
+               widget->need_frame[idx] = widget->default_need_frame;
+       }
 
-    if (xmlHasProp(node, (const xmlChar *)"touch_effect")) {
+       if (xmlHasProp(node, (const xmlChar *)"touch_effect")) {
                xmlChar *touch_effect;
 
                touch_effect = xmlGetProp(node, (const xmlChar *)"touch_effect");
@@ -2186,12 +2186,12 @@ static void update_size_info(struct widget *widget, int idx, xmlNodePtr node)
                } else {
                        widget->touch_effect[idx] = widget->default_touch_effect;
                }
-    } else {
-       widget->touch_effect[idx] = widget->default_touch_effect;
-    }
+       } else {
+               widget->touch_effect[idx] = widget->default_touch_effect;
+       }
 
-    if (xmlHasProp(node, (const xmlChar *)"mouse_event")) {
-       xmlChar *mouse_event;
+       if (xmlHasProp(node, (const xmlChar *)"mouse_event")) {
+               xmlChar *mouse_event;
 
                mouse_event = xmlGetProp(node, (const xmlChar *)"mouse_event");
                if (mouse_event) {
@@ -2200,16 +2200,16 @@ static void update_size_info(struct widget *widget, int idx, xmlNodePtr node)
                } else {
                        widget->mouse_event[idx] = widget->default_mouse_event;
                }
-    } else {
-       widget->mouse_event[idx] = widget->default_mouse_event;
-    }
+       } else {
+               widget->mouse_event[idx] = widget->default_mouse_event;
+       }
 }
 
 static void update_box(struct widget *widget, xmlNodePtr node)
 {
-    if (!xmlHasProp(node, (const xmlChar *)"type")) {
-       widget->widget_type = WIDGET_TYPE_FILE;
-    } else {
+       if (!xmlHasProp(node, (const xmlChar *)"type")) {
+               widget->widget_type = WIDGET_TYPE_FILE;
+       } else {
                xmlChar *type;
 
                type = xmlGetProp(node, (const xmlChar *)"type");
@@ -2231,12 +2231,12 @@ static void update_box(struct widget *widget, xmlNodePtr node)
 
                        xmlFree(type);
                }
-    }
+       }
 
-    if (!xmlHasProp(node, (const xmlChar *)"mouse_event")) {
-       widget->default_mouse_event = 0;
-    } else {
-       xmlChar *mouse_event;
+       if (!xmlHasProp(node, (const xmlChar *)"mouse_event")) {
+               widget->default_mouse_event = 0;
+       } else {
+               xmlChar *mouse_event;
 
                mouse_event = xmlGetProp(node, (const xmlChar *)"mouse_event");
                if (!mouse_event) {
@@ -2246,12 +2246,12 @@ static void update_box(struct widget *widget, xmlNodePtr node)
                        widget->default_mouse_event = !xmlStrcasecmp(mouse_event, (const xmlChar *)"true");
                        xmlFree(mouse_event);
                }
-    }
+       }
 
-    if (!xmlHasProp(node, (const xmlChar *)"touch_effect")) {
-       widget->default_touch_effect = 1;
-    } else {
-       xmlChar *touch_effect;
+       if (!xmlHasProp(node, (const xmlChar *)"touch_effect")) {
+               widget->default_touch_effect = 1;
+       } else {
+               xmlChar *touch_effect;
 
                touch_effect = xmlGetProp(node, (const xmlChar *)"touch_effect");
                if (!touch_effect) {
@@ -2261,12 +2261,12 @@ static void update_box(struct widget *widget, xmlNodePtr node)
                        widget->default_touch_effect = !xmlStrcasecmp(touch_effect, (const xmlChar *)"true");
                        xmlFree(touch_effect);
                }
-    }
+       }
 
-    if (!xmlHasProp(node, (const xmlChar *)"need_frame")) {
-       widget->default_need_frame = 0;
-    } else {
-       xmlChar *need_frame;
+       if (!xmlHasProp(node, (const xmlChar *)"need_frame")) {
+               widget->default_need_frame = 0;
+       } else {
+               xmlChar *need_frame;
 
                need_frame = xmlGetProp(node, (const xmlChar *)"need_frame");
                if (!need_frame) {
@@ -2276,9 +2276,9 @@ static void update_box(struct widget *widget, xmlNodePtr node)
                        widget->default_need_frame = !xmlStrcasecmp(need_frame, (const xmlChar *)"true");
                        xmlFree(need_frame);
                }
-    }
+       }
 
-    for (node = node->children; node; node = node->next) {
+       for (node = node->children; node; node = node->next) {
                if (!xmlStrcasecmp(node->name, (const xmlChar *)"size")) {
                        xmlChar *size;
                        int is_easy = 0;
@@ -2398,26 +2398,26 @@ static void update_box(struct widget *widget, xmlNodePtr node)
                                }
                        }
                }
-    }
+       }
 }
 
 static inline void update_group(struct widget *widget, xmlNodePtr node)
 {
-    xmlNodePtr cluster;
-    xmlNodePtr category;
-    xmlNodePtr option_item;
-    xmlChar *cluster_name;
-    xmlChar *category_name;
-    xmlChar *ctx_item;
+       xmlNodePtr cluster;
+       xmlNodePtr category;
+       xmlNodePtr option_item;
+       xmlChar *cluster_name;
+       xmlChar *category_name;
+       xmlChar *ctx_item;
 
-    xmlChar *key;
-    xmlChar *value;
+       xmlChar *key;
+       xmlChar *value;
 
-    struct group *group;
-    struct option *option;
+       struct group *group;
+       struct option *option;
 
-    cluster = node;
-    for (cluster = cluster->children; cluster; cluster = cluster->next) {
+       cluster = node;
+       for (cluster = cluster->children; cluster; cluster = cluster->next) {
                if (xmlStrcasecmp(cluster->name, (const xmlChar *)"cluster")) {
                        DbgPrint("Skip: %s\n", cluster->name);
                        continue;
@@ -2453,7 +2453,7 @@ static inline void update_group(struct widget *widget, xmlNodePtr node)
 
                        group = calloc(1, sizeof(*group));
                        if (!group) {
-                       ErrPrint("Heap: %s\n", strerror(errno));
+                               ErrPrint("Heap: %s\n", strerror(errno));
                                xmlFree(category_name);
                                continue;
                        }
@@ -2484,80 +2484,80 @@ static inline void update_group(struct widget *widget, xmlNodePtr node)
                        DbgPrint("Build group item: %s - %s - %s\n", group->cluster, group->category, group->ctx_item);
 
                        for (option_item = category->children; option_item; option_item = option_item->next) {
-                       if (xmlStrcasecmp(option_item->name, (const xmlChar *)"option")) {
-                               DbgPrint("Skip: %s\n", option_item->name);
-                               continue;
-                       }
+                               if (xmlStrcasecmp(option_item->name, (const xmlChar *)"option")) {
+                                       DbgPrint("Skip: %s\n", option_item->name);
+                                       continue;
+                               }
 
-                       if (!xmlHasProp(option_item, (const xmlChar *)"key")) {
-                               ErrPrint("Invalid option, has no key\n");
-                               continue;
-                       }
+                               if (!xmlHasProp(option_item, (const xmlChar *)"key")) {
+                                       ErrPrint("Invalid option, has no key\n");
+                                       continue;
+                               }
 
-                       if (!xmlHasProp(option_item, (const xmlChar *)"value")) {
-                               ErrPrint("Invalid option, has no value\n");
-                               continue;
-                       }
+                               if (!xmlHasProp(option_item, (const xmlChar *)"value")) {
+                                       ErrPrint("Invalid option, has no value\n");
+                                       continue;
+                               }
 
-                       key = xmlGetProp(option_item, (const xmlChar *)"key");
-                       if (!key) {
-                               ErrPrint("Invalid key. NIL\n");
-                               continue;
-                       }
+                               key = xmlGetProp(option_item, (const xmlChar *)"key");
+                               if (!key) {
+                                       ErrPrint("Invalid key. NIL\n");
+                                       continue;
+                               }
 
-                       value = xmlGetProp(option_item, (const xmlChar *)"value");
-                       if (!value) {
-                               ErrPrint("Invalid valid. NIL\n");
-                               xmlFree(key);
-                               continue;
-                       }
+                               value = xmlGetProp(option_item, (const xmlChar *)"value");
+                               if (!value) {
+                                       ErrPrint("Invalid valid. NIL\n");
+                                       xmlFree(key);
+                                       continue;
+                               }
 
-                       option = calloc(1, sizeof(*option));
-                       if (!option) {
-                               ErrPrint("Heap: %s\n", strerror(errno));
-                               xmlFree(key);
-                               xmlFree(value);
-                               continue;
-                       }
+                               option = calloc(1, sizeof(*option));
+                               if (!option) {
+                                       ErrPrint("Heap: %s\n", strerror(errno));
+                                       xmlFree(key);
+                                       xmlFree(value);
+                                       continue;
+                               }
 
-                       option->key = key;
-                       option->value = value;
+                               option->key = key;
+                               option->value = value;
 
-                       group->option_list = dlist_append(group->option_list, option);
+                               group->option_list = dlist_append(group->option_list, option);
                        }
                }
 
                xmlFree(cluster_name);
-    }
+       }
 }
 
 static inline void update_pd(struct widget *widget, xmlNodePtr node)
 {
-    if (!xmlHasProp(node, (const xmlChar *)"type")) {
-       widget->gbar_type = GBAR_TYPE_SCRIPT;
-    } else {
-       xmlChar *type;
-
-       type = xmlGetProp(node, (const xmlChar *)"type");
-       if (!type) {
-           ErrPrint("type is NIL\n");
-           return;
-       }
-
-       if (!xmlStrcasecmp(type, (const xmlChar *)"text")) {
-           widget->gbar_type = GBAR_TYPE_TEXT;
-       } else if (!xmlStrcasecmp(type, (const xmlChar *)"buffer")) {
-           widget->gbar_type = GBAR_TYPE_BUFFER;
-       } else if (!xmlStrcasecmp(type, (const xmlChar *)"elm")) {
-           widget->gbar_type = GBAR_TYPE_UIFW;
+       if (!xmlHasProp(node, (const xmlChar *)"type")) {
+               widget->gbar_type = GBAR_TYPE_SCRIPT;
        } else {
-           widget->gbar_type = GBAR_TYPE_SCRIPT;
-       }
+               xmlChar *type;
+
+               type = xmlGetProp(node, (const xmlChar *)"type");
+               if (!type) {
+                       ErrPrint("type is NIL\n");
+                       return;
+               }
+
+               if (!xmlStrcasecmp(type, (const xmlChar *)"text")) {
+                       widget->gbar_type = GBAR_TYPE_TEXT;
+               } else if (!xmlStrcasecmp(type, (const xmlChar *)"buffer")) {
+                       widget->gbar_type = GBAR_TYPE_BUFFER;
+               } else if (!xmlStrcasecmp(type, (const xmlChar *)"elm")) {
+                       widget->gbar_type = GBAR_TYPE_UIFW;
+               } else {
+                       widget->gbar_type = GBAR_TYPE_SCRIPT;
+               }
 
-       xmlFree(type);
-    }
+               xmlFree(type);
+       }
 
-    for (node = node->children; node; node = node->next) {
+       for (node = node->children; node; node = node->next) {
                if (!xmlStrcasecmp(node->name, (const xmlChar *)"size")) {
                        xmlChar *size;
 
@@ -2608,313 +2608,313 @@ static inline void update_pd(struct widget *widget, xmlNodePtr node)
                                }
                        }
                }
-    }
+       }
 }
 
 static int db_insert_widget(struct widget *widget, const char *appid)
 {
-    struct dlist *l;
-    struct dlist *il;
-    struct i18n *i18n;
-    struct group *group;
-    int ret;
-    int id;
-    struct option *option;
-
-    begin_transaction();
-    ret = db_insert_pkgmap(appid, (char *)widget->pkgid, (char *)widget->uiapp, widget->primary, (char *)widget->category);
-    if (ret < 0) {
-       goto errout;
-    }
-
-    ret = db_insert_provider(widget);
-    if (ret < 0) {
-       goto errout;
-    }
-
-    ret = db_insert_client(widget);
-    if (ret < 0) {
-       goto errout;
-    }
-
-    dlist_foreach(widget->i18n_list, l, i18n) {
-       ret = db_insert_i18n((char *)widget->pkgid, (char *)i18n->lang, (char *)i18n->name, (char *)i18n->icon);
+       struct dlist *l;
+       struct dlist *il;
+       struct i18n *i18n;
+       struct group *group;
+       int ret;
+       int id;
+       struct option *option;
+
+       begin_transaction();
+       ret = db_insert_pkgmap(appid, (char *)widget->pkgid, (char *)widget->uiapp, widget->primary, (char *)widget->category);
        if (ret < 0) {
-           goto errout;
+               goto errout;
        }
-    }
 
-    if (widget->size_list & WIDGET_SIZE_TYPE_1x1) {
-       ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_1x1, (char *)widget->preview[0], widget->touch_effect[0], widget->need_frame[0], widget->mouse_event[0]);
+       ret = db_insert_provider(widget);
        if (ret < 0) {
-           goto errout;
+               goto errout;
        }
-    }
 
-    if (widget->size_list & WIDGET_SIZE_TYPE_2x1) {
-       ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_2x1, (char *)widget->preview[1], widget->touch_effect[1], widget->need_frame[1], widget->mouse_event[1]);
+       ret = db_insert_client(widget);
        if (ret < 0) {
-           goto errout;
+               goto errout;
        }
-    }
 
-    if (widget->size_list & WIDGET_SIZE_TYPE_2x2) {
-       ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_2x2, (char *)widget->preview[2], widget->touch_effect[2], widget->need_frame[2], widget->mouse_event[2]);
-       if (ret < 0) {
-           goto errout;
+       dlist_foreach(widget->i18n_list, l, i18n) {
+               ret = db_insert_i18n((char *)widget->pkgid, (char *)i18n->lang, (char *)i18n->name, (char *)i18n->icon);
+               if (ret < 0) {
+                       goto errout;
+               }
        }
-    }
 
-    if (widget->size_list & WIDGET_SIZE_TYPE_4x1) {
-       ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_4x1, (char *)widget->preview[3], widget->touch_effect[3], widget->need_frame[3], widget->mouse_event[3]);
-       if (ret < 0) {
-           goto errout;
+       if (widget->size_list & WIDGET_SIZE_TYPE_1x1) {
+               ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_1x1, (char *)widget->preview[0], widget->touch_effect[0], widget->need_frame[0], widget->mouse_event[0]);
+               if (ret < 0) {
+                       goto errout;
+               }
        }
-    }
 
-    if (widget->size_list & WIDGET_SIZE_TYPE_4x2) {
-       ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_4x2, (char *)widget->preview[4], widget->touch_effect[4], widget->need_frame[4], widget->mouse_event[4]);
-       if (ret < 0) {
-           goto errout;
+       if (widget->size_list & WIDGET_SIZE_TYPE_2x1) {
+               ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_2x1, (char *)widget->preview[1], widget->touch_effect[1], widget->need_frame[1], widget->mouse_event[1]);
+               if (ret < 0) {
+                       goto errout;
+               }
        }
-    }
 
-    if (widget->size_list & WIDGET_SIZE_TYPE_4x3) {
-       ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_4x3, (char *)widget->preview[5], widget->touch_effect[5], widget->need_frame[5], widget->mouse_event[5]);
-       if (ret < 0) {
-           goto errout;
+       if (widget->size_list & WIDGET_SIZE_TYPE_2x2) {
+               ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_2x2, (char *)widget->preview[2], widget->touch_effect[2], widget->need_frame[2], widget->mouse_event[2]);
+               if (ret < 0) {
+                       goto errout;
+               }
        }
-    }
 
-    if (widget->size_list & WIDGET_SIZE_TYPE_4x4) {
-       ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_4x4, (char *)widget->preview[6], widget->touch_effect[6], widget->need_frame[6], widget->mouse_event[6]);
-       if (ret < 0) {
-           goto errout;
+       if (widget->size_list & WIDGET_SIZE_TYPE_4x1) {
+               ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_4x1, (char *)widget->preview[3], widget->touch_effect[3], widget->need_frame[3], widget->mouse_event[3]);
+               if (ret < 0) {
+                       goto errout;
+               }
        }
-    }
 
-    if (widget->size_list & WIDGET_SIZE_TYPE_4x5) {
-       ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_4x5, (char *)widget->preview[7], widget->touch_effect[7], widget->need_frame[7], widget->mouse_event[7]);
-       if (ret < 0) {
-           goto errout;
+       if (widget->size_list & WIDGET_SIZE_TYPE_4x2) {
+               ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_4x2, (char *)widget->preview[4], widget->touch_effect[4], widget->need_frame[4], widget->mouse_event[4]);
+               if (ret < 0) {
+                       goto errout;
+               }
        }
-    }
 
-    if (widget->size_list & WIDGET_SIZE_TYPE_4x6) {
-       ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_4x6, (char *)widget->preview[8], widget->touch_effect[8], widget->need_frame[8], widget->mouse_event[8]);
-       if (ret < 0) {
-           goto errout;
+       if (widget->size_list & WIDGET_SIZE_TYPE_4x3) {
+               ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_4x3, (char *)widget->preview[5], widget->touch_effect[5], widget->need_frame[5], widget->mouse_event[5]);
+               if (ret < 0) {
+                       goto errout;
+               }
        }
-    }
 
-    if (widget->size_list & WIDGET_SIZE_TYPE_EASY_1x1) {
-       ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_EASY_1x1, (char *)widget->preview[9], widget->touch_effect[9], widget->need_frame[9], widget->mouse_event[9]);
-       if (ret < 0) {
-           goto errout;
+       if (widget->size_list & WIDGET_SIZE_TYPE_4x4) {
+               ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_4x4, (char *)widget->preview[6], widget->touch_effect[6], widget->need_frame[6], widget->mouse_event[6]);
+               if (ret < 0) {
+                       goto errout;
+               }
        }
-    }
 
-    if (widget->size_list & WIDGET_SIZE_TYPE_EASY_3x1) {
-       ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_EASY_3x1, (char *)widget->preview[10], widget->touch_effect[10], widget->need_frame[10], widget->mouse_event[10]);
-       if (ret < 0) {
-           goto errout;
+       if (widget->size_list & WIDGET_SIZE_TYPE_4x5) {
+               ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_4x5, (char *)widget->preview[7], widget->touch_effect[7], widget->need_frame[7], widget->mouse_event[7]);
+               if (ret < 0) {
+                       goto errout;
+               }
        }
-    }
 
-    if (widget->size_list & WIDGET_SIZE_TYPE_EASY_3x3) {
-       ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_EASY_3x3, (char *)widget->preview[11], widget->touch_effect[11], widget->need_frame[11], widget->mouse_event[11]);
-       if (ret < 0) {
-           goto errout;
+       if (widget->size_list & WIDGET_SIZE_TYPE_4x6) {
+               ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_4x6, (char *)widget->preview[8], widget->touch_effect[8], widget->need_frame[8], widget->mouse_event[8]);
+               if (ret < 0) {
+                       goto errout;
+               }
        }
-    }
 
-    if (widget->size_list & WIDGET_SIZE_TYPE_FULL) {
-       ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_FULL, (char *)widget->preview[12], widget->touch_effect[12], widget->need_frame[12], widget->mouse_event[12]);
-       if (ret < 0) {
-           goto errout;
+       if (widget->size_list & WIDGET_SIZE_TYPE_EASY_1x1) {
+               ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_EASY_1x1, (char *)widget->preview[9], widget->touch_effect[9], widget->need_frame[9], widget->mouse_event[9]);
+               if (ret < 0) {
+                       goto errout;
+               }
        }
-    }
-
-    dlist_foreach(widget->group_list, l, group) {
-       /* group ID "id" */
-       id = db_get_group_id((char *)group->cluster, (char *)group->category);
-       if (id < 0) {
-           int ret;
 
-           ret = db_insert_group((char *)widget->pkgid, (char *)group->cluster, (char *)group->category);
-           if (ret < 0) {
-                       ErrPrint("[%s]-[%s] is not exists\n", group->cluster, group->category);
-                       continue;
-           }
-
-           DbgPrint("New group name is built - %s/%s\n", group->cluster, group->category);
-           id = db_get_group_id((char *)group->cluster, (char *)group->category);
-           if (id < 0) {
-                       ErrPrint("Failed to get group id for %s/%s\n", group->cluster, group->category);
-                       continue;
-           }
+       if (widget->size_list & WIDGET_SIZE_TYPE_EASY_3x1) {
+               ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_EASY_3x1, (char *)widget->preview[10], widget->touch_effect[10], widget->need_frame[10], widget->mouse_event[10]);
+               if (ret < 0) {
+                       goto errout;
+               }
        }
 
-       if (!group->ctx_item) {
-           DbgPrint("%s, %s - has no ctx info\n", group->cluster, group->category);
-           continue;
+       if (widget->size_list & WIDGET_SIZE_TYPE_EASY_3x3) {
+               ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_EASY_3x3, (char *)widget->preview[11], widget->touch_effect[11], widget->need_frame[11], widget->mouse_event[11]);
+               if (ret < 0) {
+                       goto errout;
+               }
        }
 
-       ret = db_insert_groupmap(id, (char *)widget->pkgid, (char *)group->ctx_item);
-       if (ret < 0) {
-           goto errout;
+       if (widget->size_list & WIDGET_SIZE_TYPE_FULL) {
+               ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_FULL, (char *)widget->preview[12], widget->touch_effect[12], widget->need_frame[12], widget->mouse_event[12]);
+               if (ret < 0) {
+                       goto errout;
+               }
        }
 
-       /* REUSE "id" from here , option ID */
-       id = db_get_option_id(id, (char *)widget->pkgid, (char *)group->ctx_item);
-       if (id < 0) {
-           goto errout;
-       }
+       dlist_foreach(widget->group_list, l, group) {
+               /* group ID "id" */
+               id = db_get_group_id((char *)group->cluster, (char *)group->category);
+               if (id < 0) {
+                       int ret;
+
+                       ret = db_insert_group((char *)widget->pkgid, (char *)group->cluster, (char *)group->category);
+                       if (ret < 0) {
+                               ErrPrint("[%s]-[%s] is not exists\n", group->cluster, group->category);
+                               continue;
+                       }
+
+                       DbgPrint("New group name is built - %s/%s\n", group->cluster, group->category);
+                       id = db_get_group_id((char *)group->cluster, (char *)group->category);
+                       if (id < 0) {
+                               ErrPrint("Failed to get group id for %s/%s\n", group->cluster, group->category);
+                               continue;
+                       }
+               }
+
+               if (!group->ctx_item) {
+                       DbgPrint("%s, %s - has no ctx info\n", group->cluster, group->category);
+                       continue;
+               }
+
+               ret = db_insert_groupmap(id, (char *)widget->pkgid, (char *)group->ctx_item);
+               if (ret < 0) {
+                       goto errout;
+               }
 
-       dlist_foreach(group->option_list, il, option) {
-           ret = db_insert_option((char *)widget->pkgid, id, (char *)option->key, (char *)option->value);
-           if (ret < 0) {
-               goto errout;
-           }
+               /* REUSE "id" from here , option ID */
+               id = db_get_option_id(id, (char *)widget->pkgid, (char *)group->ctx_item);
+               if (id < 0) {
+                       goto errout;
+               }
+
+               dlist_foreach(group->option_list, il, option) {
+                       ret = db_insert_option((char *)widget->pkgid, id, (char *)option->key, (char *)option->value);
+                       if (ret < 0) {
+                               goto errout;
+                       }
+               }
        }
-    }
 
-    commit_transaction();
-    widget_destroy(widget);
-    return 0;
+       commit_transaction();
+       widget_destroy(widget);
+       return 0;
 
 errout:
-    ErrPrint("ROLLBACK\n");
-    rollback_transaction();
-    widget_destroy(widget);
-    return ret;
+       ErrPrint("ROLLBACK\n");
+       rollback_transaction();
+       widget_destroy(widget);
+       return ret;
 }
 
 int db_install_widget(xmlNodePtr node, const char *appid)
 {
-    struct widget *widget;
-    xmlChar *pkgid;
-    xmlChar *tmp;
+       struct widget *widget;
+       xmlChar *pkgid;
+       xmlChar *tmp;
 
-    if (!xmlHasProp(node, (const xmlChar *)"appid")) {
+       if (!xmlHasProp(node, (const xmlChar *)"appid")) {
                ErrPrint("Missing appid\n");
                return -EINVAL;
-    }
+       }
 
-    pkgid = xmlGetProp(node, (const xmlChar *)"appid");
-    if (!pkgid || !validate_pkgid(appid, (char *)pkgid)) {
+       pkgid = xmlGetProp(node, (const xmlChar *)"appid");
+       if (!pkgid || !validate_pkgid(appid, (char *)pkgid)) {
                ErrPrint("Invalid appid\n");
                xmlFree(pkgid);
                return -EINVAL;
-    }
+       }
 
-    DbgPrint("appid: %s\n", (char *)pkgid);
+       DbgPrint("appid: %s\n", (char *)pkgid);
 
-    widget = calloc(1, sizeof(*widget));
-    if (!widget) {
+       widget = calloc(1, sizeof(*widget));
+       if (!widget) {
                ErrPrint("Heap: %s\n", strerror(errno));
                xmlFree(pkgid);
                return -ENOMEM;
-    }
+       }
 
-    widget->pkgid = pkgid;
+       widget->pkgid = pkgid;
 
-    if (xmlHasProp(node, (const xmlChar *)"count")) {
+       if (xmlHasProp(node, (const xmlChar *)"count")) {
                tmp = xmlGetProp(node, (const xmlChar *)"count");
                if (sscanf((const char *)tmp, "%d", &widget->count) != 1) {
                        ErrPrint("Invalid syntax: %s\n", (const char *)tmp);
                }
                xmlFree(tmp);
-    }
+       }
 
-    if (xmlHasProp(node, (const xmlChar *)"primary")) {
+       if (xmlHasProp(node, (const xmlChar *)"primary")) {
                tmp = xmlGetProp(node, (const xmlChar *)"primary");
                widget->primary = !xmlStrcasecmp(tmp, (const xmlChar *)"true");
                xmlFree(tmp);
-    }
+       }
 
-    if (xmlHasProp(node, (const xmlChar *)"script")) {
+       if (xmlHasProp(node, (const xmlChar *)"script")) {
                widget->script = xmlGetProp(node, (const xmlChar *)"script");
                if (!widget->script) {
                        ErrPrint("script is NIL\n");
                }
-    }
+       }
 
-    if (xmlHasProp(node, (const xmlChar *)"nodisplay")) {
+       if (xmlHasProp(node, (const xmlChar *)"nodisplay")) {
                tmp = xmlGetProp(node, (const xmlChar *)"nodisplay");
                widget->nodisplay = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true");
                xmlFree(tmp);
-    }
+       }
 
-    if (xmlHasProp(node, (const xmlChar *)"pinup")) {
+       if (xmlHasProp(node, (const xmlChar *)"pinup")) {
                tmp = xmlGetProp(node, (const xmlChar *)"pinup");
                widget->pinup = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true");
                xmlFree(tmp);
-    }
+       }
 
-    if (xmlHasProp(node, (const xmlChar *)"period")) {
+       if (xmlHasProp(node, (const xmlChar *)"period")) {
                widget->period = xmlGetProp(node, (const xmlChar *)"period");
                if (!widget->period) {
                        ErrPrint("Period is NIL\n");
                }
-    }
+       }
 
-    if (xmlHasProp(node, (const xmlChar *)"timeout")) {
+       if (xmlHasProp(node, (const xmlChar *)"timeout")) {
                widget->timeout = xmlGetProp(node, (const xmlChar *)"timeout");
                if (!widget->timeout) {
                        ErrPrint("Timeout is NIL\n");
                }
-    }
+       }
 
-    if (xmlHasProp(node, (const xmlChar *)"secured")) {
+       if (xmlHasProp(node, (const xmlChar *)"secured")) {
                tmp = xmlGetProp(node, (const xmlChar *)"secured");
                widget->secured = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true");
                xmlFree(tmp);
-    }
+       }
 
-    if (xmlHasProp(node, (const xmlChar *)"network")) {
+       if (xmlHasProp(node, (const xmlChar *)"network")) {
                tmp = xmlGetProp(node, (const xmlChar *)"network");
                widget->network = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true");
                xmlFree(tmp);
-    }
+       }
 
-    if (xmlHasProp(node, (const xmlChar *)"direct_input")) {
+       if (xmlHasProp(node, (const xmlChar *)"direct_input")) {
                tmp = xmlGetProp(node, (const xmlChar *)"direct_input");
                widget->direct_input = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true");
                xmlFree(tmp);
-    }
+       }
 
-    if (xmlHasProp(node, (const xmlChar *)"hw-acceleration")) {
+       if (xmlHasProp(node, (const xmlChar *)"hw-acceleration")) {
                widget->hw_acceleration = xmlGetProp(node, (const xmlChar *)"hw-acceleration");
                if (!widget->hw_acceleration) {
                        ErrPrint("hw-acceleration is NIL\n");
                }
-    }
+       }
 
-    if (xmlHasProp(node, (const xmlChar *)"abi")) {
+       if (xmlHasProp(node, (const xmlChar *)"abi")) {
                widget->abi = xmlGetProp(node, (const xmlChar *)"abi");
                if (!widget->abi) {
                        ErrPrint("ABI is NIL\n");
                        widget_destroy(widget);
                        return -EFAULT;
                }
-    } else {
+       } else {
                widget->abi = xmlStrdup((const xmlChar *)"c");
                if (!widget->abi) {
                        ErrPrint("Heap: %s\n", strerror(errno));
                        widget_destroy(widget);
                        return -ENOMEM;
                }
-    }
+       }
 
-    if (xmlHasProp(node, (const xmlChar *)"libexec")) {
+       if (xmlHasProp(node, (const xmlChar *)"libexec")) {
                widget->libexec = xmlGetProp(node, (const xmlChar *)"libexec");
                if (!widget->libexec) {
                        ErrPrint("libexec is NIL\n");
                        widget_destroy(widget);
                        return -EFAULT;
                }
-    } else if (!xmlStrcasecmp(widget->abi, (const xmlChar *)"c") || !xmlStrcasecmp(widget->abi, (const xmlChar *)"cpp")) {
+       } else if (!xmlStrcasecmp(widget->abi, (const xmlChar *)"c") || !xmlStrcasecmp(widget->abi, (const xmlChar *)"cpp")) {
                char *filename;
                int len;
 
@@ -2935,7 +2935,7 @@ int db_install_widget(xmlNodePtr node, const char *appid)
                        widget_destroy(widget);
                        return -ENOMEM;
                }
-    }
+       }
 
        for (node = node->children; node; node = node->next) {
                if (!xmlStrcmp(node->name, (const xmlChar *)"text")) {
@@ -2998,60 +2998,60 @@ int db_install_widget(xmlNodePtr node, const char *appid)
                }
        }
 
-    return db_insert_widget(widget, appid);
+       return db_insert_widget(widget, appid);
 }
 
 int db_install_watchapp(xmlNodePtr node, const char *appid)
 {
-    struct widget *widget;
-    xmlChar *pkgid;
+       struct widget *widget;
+       xmlChar *pkgid;
 
-    if (!xmlHasProp(node, (const xmlChar *)"appid")) {
+       if (!xmlHasProp(node, (const xmlChar *)"appid")) {
                ErrPrint("Missing appid\n");
                return -EINVAL;
-    }
+       }
 
-    pkgid = xmlGetProp(node, (const xmlChar *)"appid");
-    if (!pkgid || !validate_pkgid(appid, (char *)pkgid)) {
+       pkgid = xmlGetProp(node, (const xmlChar *)"appid");
+       if (!pkgid || !validate_pkgid(appid, (char *)pkgid)) {
                ErrPrint("Invalid appid\n");
                xmlFree(pkgid);
                return -EINVAL;
-    }
+       }
 
-    DbgPrint("appid: %s\n", (char *)pkgid);
+       DbgPrint("appid: %s\n", (char *)pkgid);
 
-    widget = calloc(1, sizeof(*widget));
-    if (!widget) {
+       widget = calloc(1, sizeof(*widget));
+       if (!widget) {
                ErrPrint("Heap: %s\n", strerror(errno));
                xmlFree(pkgid);
                return -ENOMEM;
-    }
-
-    widget->pkgid = pkgid;
-
-    widget->primary = 1;
-    widget->secured = 1;
-    widget->nodisplay = 1;
-    widget->hw_acceleration = xmlStrdup((const xmlChar *)"use-sw"); //use-gl
-    widget->abi = xmlStrdup((const xmlChar *)"app");
-    widget->category = xmlStrdup((const xmlChar *)WATCH_CATEGORY);
-
-    widget->widget_type = WIDGET_TYPE_BUFFER;
-    widget->default_mouse_event = 1;
-    widget->default_touch_effect = 0;
-    widget->default_need_frame = 0;
-    widget->size_list = WIDGET_SIZE_TYPE_2x2;
-
-    if (xmlHasProp(node, (const xmlChar *)"exec")) {
-               widget->libexec = xmlGetProp(node, (const xmlChar *)"exec");
-               if (!widget->libexec) {
-                       ErrPrint("libexec is NIL\n");
-                       widget_destroy(widget);
-                       return -EFAULT;
-               }
-    }
-
-    for (node = node->children; node; node = node->next) {
+       }
+
+       widget->pkgid = pkgid;
+
+       widget->primary = 1;
+       widget->secured = 1;
+       widget->nodisplay = 1;
+       widget->hw_acceleration = xmlStrdup((const xmlChar *)"use-sw"); //use-gl
+       widget->abi = xmlStrdup((const xmlChar *)"app");
+       widget->category = xmlStrdup((const xmlChar *)WATCH_CATEGORY);
+
+       widget->widget_type = WIDGET_TYPE_BUFFER;
+       widget->default_mouse_event = 1;
+       widget->default_touch_effect = 0;
+       widget->default_need_frame = 0;
+       widget->size_list = WIDGET_SIZE_TYPE_2x2;
+
+       if (xmlHasProp(node, (const xmlChar *)"exec")) {
+               widget->libexec = xmlGetProp(node, (const xmlChar *)"exec");
+               if (!widget->libexec) {
+                       ErrPrint("libexec is NIL\n");
+                       widget_destroy(widget);
+                       return -EFAULT;
+               }
+       }
+
+       for (node = node->children; node; node = node->next) {
                if (!xmlStrcmp(node->name, (const xmlChar *)"text")) {
                        continue;
                }
@@ -3066,115 +3066,115 @@ int db_install_watchapp(xmlNodePtr node, const char *appid)
                        update_i18n_icon(widget, node);
                        continue;
                }
-    }
+       }
 
-    return db_insert_widget(widget, appid);
+       return db_insert_widget(widget, appid);
 }
 
 int db_uninstall(xmlNodePtr node, const char *appid)
 {
-    xmlChar *pkgid;
-    int ret;
+       xmlChar *pkgid;
+       int ret;
 
-    if (!xmlHasProp(node, (const xmlChar *)"appid")) {
+       if (!xmlHasProp(node, (const xmlChar *)"appid")) {
                ErrPrint("Missing appid\n");
                return -EINVAL;
-    }
+       }
 
-    pkgid = xmlGetProp(node, (const xmlChar *)"appid");
-    if (!validate_pkgid(appid, (char *)pkgid)) {
+       pkgid = xmlGetProp(node, (const xmlChar *)"appid");
+       if (!validate_pkgid(appid, (char *)pkgid)) {
                ErrPrint("Invalid package\n");
                xmlFree(pkgid);
                return -EINVAL;
-    }
+       }
 
-    begin_transaction();
-    ret = db_remove_box_size((const char *)pkgid);
-    if (ret < 0) {
-       goto errout;
-    }
+       begin_transaction();
+       ret = db_remove_box_size((const char *)pkgid);
+       if (ret < 0) {
+               goto errout;
+       }
 
-    ret = db_remove_i18n((const char *)pkgid);
-    if (ret < 0) {
-       goto errout;
-    }
+       ret = db_remove_i18n((const char *)pkgid);
+       if (ret < 0) {
+               goto errout;
+       }
 
-    ret = db_remove_client((const char *)pkgid);
-    if (ret < 0) {
-       goto errout;
-    }
+       ret = db_remove_client((const char *)pkgid);
+       if (ret < 0) {
+               goto errout;
+       }
 
-    ret = db_remove_provider((const char *)pkgid);
-    if (ret < 0) {
-       goto errout;
-    }
+       ret = db_remove_provider((const char *)pkgid);
+       if (ret < 0) {
+               goto errout;
+       }
 
-    ret = db_remove_option((const char *)pkgid);
-    DbgPrint("Remove option: %d\n", ret);
+       ret = db_remove_option((const char *)pkgid);
+       DbgPrint("Remove option: %d\n", ret);
 
-    ret = db_remove_groupmap((const char *)pkgid);
-    DbgPrint("Remove groupmap: %d\n", ret);
+       ret = db_remove_groupmap((const char *)pkgid);
+       DbgPrint("Remove groupmap: %d\n", ret);
 
-    ret = db_remove_group((const char *)pkgid);
-    if (ret < 0) {
-       goto errout;
-    }
+       ret = db_remove_group((const char *)pkgid);
+       if (ret < 0) {
+               goto errout;
+       }
 
-    ret = db_remove_pkgmap((const char *)pkgid);
-    if (ret < 0) {
-       goto errout;
-    }
+       ret = db_remove_pkgmap((const char *)pkgid);
+       if (ret < 0) {
+               goto errout;
+       }
 
-    commit_transaction();
-    xmlFree(pkgid);
+       commit_transaction();
+       xmlFree(pkgid);
 
-    return 0;
+       return 0;
 
 errout:
-    rollback_transaction();
-    xmlFree(pkgid);
-    return ret;
+       rollback_transaction();
+       xmlFree(pkgid);
+       return ret;
 }
 
 int pkglist_get_via_callback(const char *appid, int is_watch_widget, void (*cb)(const char *appid, const char *pkgid, int prime, void *data), void *data)
 {
-    const char *dml;
-    int ret;
-    sqlite3_stmt *stmt;
-    const char *pkgid;
-    int prime;
-    int cnt = 0;
-
-    if (!cb || !appid || !strlen(appid)) {
-       return -EINVAL;
-    }
-
-    if (!s_info.handle) {
+       const char *dml;
+       int ret;
+       sqlite3_stmt *stmt;
+       const char *pkgid;
+       int prime;
+       int cnt = 0;
+
+       if (!cb || !appid || !strlen(appid)) {
+               return -EINVAL;
+       }
+
+       if (!s_info.handle) {
                if (db_init() < 0) {
                        ErrPrint("Failed to init DB\n");
                        return -EIO;
                }
-    }
+       }
 
-    if (is_watch_widget) { /* Watch */
+       if (is_watch_widget) { /* Watch */
                dml = "SELECT pkgid, prime FROM pkgmap WHERE appid = ? AND category = '" WATCH_CATEGORY "'";
-    } else { /* Widget */
+       } else { /* Widget */
                dml = "SELECT pkgid, prime FROM pkgmap WHERE appid = ? AND (category IS NULL OR category <> '" WATCH_CATEGORY "')";
-    }
+       }
 
-    ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-    if (ret != SQLITE_OK) {
+       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+       if (ret != SQLITE_OK) {
                ErrPrint("Failed to prepare the intial DML(%s)\n", sqlite3_errmsg(s_info.handle));
                return -EIO;
-    }
+       }
 
-    ret = -EIO;
-    if (sqlite3_bind_text(stmt, 1, appid, -1, SQLITE_TRANSIENT) != SQLITE_OK) {
+       ret = -EIO;
+       if (sqlite3_bind_text(stmt, 1, appid, -1, SQLITE_TRANSIENT) != SQLITE_OK) {
                ErrPrint("Failed to bind a cluster - %s\n", sqlite3_errmsg(s_info.handle));
                goto out;
-    }
+       }
 
-    while (sqlite3_step(stmt) == SQLITE_ROW) {
+       while (sqlite3_step(stmt) == SQLITE_ROW) {
                pkgid = (const char *)sqlite3_column_text(stmt, 0);
                if (!pkgid || !strlen(pkgid)) {
                        continue;
@@ -3183,60 +3183,60 @@ int pkglist_get_via_callback(const char *appid, int is_watch_widget, void (*cb)(
                prime = sqlite3_column_int(stmt, 1);
                cb(appid, pkgid, prime, data);
                cnt++;
-    }
+       }
 
 out:
-    sqlite3_reset(stmt);
-    sqlite3_clear_bindings(stmt);
-    sqlite3_finalize(stmt);
-    return cnt;
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+       sqlite3_finalize(stmt);
+       return cnt;
 }
 
 void delete_record_cb(const char *appid, const char *pkgid, int prime, void *data)
 {
-    int ret;
-
-    ErrPrintWithConsole("Remove old package info: appid(%s), pkgid(%s)\n", appid, pkgid);
-
-    ret = db_remove_box_size((char *)pkgid);
-    if (ret < 0) {
-       ErrPrint("Remove box size: %d\n", ret);
-    }
-
-    ret = db_remove_i18n((char *)pkgid);
-    if (ret < 0) {
-       ErrPrint("Remove i18n: %d\n", ret);
-    }
-
-    ret = db_remove_client((char *)pkgid);
-    if (ret < 0) {
-       ErrPrint("Remove client: %d\n", ret);
-    }
-
-    ret = db_remove_provider((char *)pkgid);
-    if (ret < 0) {
-       ErrPrint("Remove provider: %d\n", ret);
-    }
-
-    ret = db_remove_option((char *)pkgid);
-    if (ret < 0) {
-       ErrPrint("Remove option: %d\n", ret);
-    }
-
-    ret = db_remove_groupmap((char *)pkgid);
-    if (ret < 0) {
-       ErrPrint("Remove groupmap: %d\n", ret);
-    }
-
-    ret = db_remove_group((char *)pkgid);
-    if (ret < 0) {
-       ErrPrint("Remove group: %d\n", ret);
-    }
-
-    ret = db_remove_pkgmap((char *)pkgid);
-    if (ret < 0) {
-       ErrPrint("Remove pkgmap: %d\n", ret);
-    }
+       int ret;
+
+       ErrPrintWithConsole("Remove old package info: appid(%s), pkgid(%s)\n", appid, pkgid);
+
+       ret = db_remove_box_size((char *)pkgid);
+       if (ret < 0) {
+               ErrPrint("Remove box size: %d\n", ret);
+       }
+
+       ret = db_remove_i18n((char *)pkgid);
+       if (ret < 0) {
+               ErrPrint("Remove i18n: %d\n", ret);
+       }
+
+       ret = db_remove_client((char *)pkgid);
+       if (ret < 0) {
+               ErrPrint("Remove client: %d\n", ret);
+       }
+
+       ret = db_remove_provider((char *)pkgid);
+       if (ret < 0) {
+               ErrPrint("Remove provider: %d\n", ret);
+       }
+
+       ret = db_remove_option((char *)pkgid);
+       if (ret < 0) {
+               ErrPrint("Remove option: %d\n", ret);
+       }
+
+       ret = db_remove_groupmap((char *)pkgid);
+       if (ret < 0) {
+               ErrPrint("Remove groupmap: %d\n", ret);
+       }
+
+       ret = db_remove_group((char *)pkgid);
+       if (ret < 0) {
+               ErrPrint("Remove group: %d\n", ret);
+       }
+
+       ret = db_remove_pkgmap((char *)pkgid);
+       if (ret < 0) {
+               ErrPrint("Remove pkgmap: %d\n", ret);
+       }
 }
 
 /* End of a file */
index aab85a0..3c1aec4 100644 (file)
@@ -79,6 +79,7 @@ struct sync_ctx_item {
        int handle;
        char *pkgname;
        double timestamp;
+       Ecore_Timer *prepare_sync_wait_timer;
 };
 
 static struct info {
@@ -7910,47 +7911,106 @@ static struct packet *slave_hello_sync_prepare(pid_t pid, int handle, const stru
        char pkgname[pathconf("/", _PC_PATH_MAX)];
        int ret;
        struct sync_ctx_item *ctx;
+       double timestamp;
+       Eina_List *l;
+       Eina_List *n;
 
-       ctx = calloc(1, sizeof(*ctx));
-       if (!ctx) {
-               ErrPrint("calloc: %s\n", strerror(errno));
-               goto out;
-       }
-
-       ret = packet_get(packet, "d", &ctx->timestamp);
+       ret = packet_get(packet, "d", &timestamp);
        if (ret != 1) {
-               DbgFree(ctx);
                ErrPrint("Parameter is not matched\n");
                goto out;
        }
 
        if (aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname)) != AUL_R_OK) {
-               DbgFree(ctx);
                ErrPrint("pid[%d] is not authroized provider package, try to find it using its name\n", pid);
                goto out;
        }
 
-       ctx->pkgname = strdup(pkgname);
-       if (!ctx->pkgname) {
-               ErrPrint("strdup: %s\n", strerror(errno));
-               DbgFree(ctx);
-               goto out;
+       ctx = NULL;
+       EINA_LIST_FOREACH_SAFE(s_info.hello_sync_ctx_list, l, n, ctx) {
+               if (ctx->timestamp == timestamp) {
+                       if (strncmp(pkgname, ctx->pkgname)) {
+                               ErrPrint("timestamp is valid, but pkgname is not matched: %s <> %s\n", pkgname, ctx->pkgname);
+                               /* Go ahead */
+                       }
+
+                       break;
+               }
+               ctx = NULL;
        }
 
-       ctx->pid = pid;
-       ctx->handle = handle;
+       if (ctx) {
+               struct slave_node *slave;
+               /**
+                * @note
+                * This is only possible that the hello_sync comes first.
+                * In that case, we should activate the slave from here.
+                */
+               s_info.hello_sync_ctx_list  = eina_list_remove(s_info.hello_sync_ctx_list, ctx);
+               if (ctx->prepare_sync_wait_timer) {
+                       ecore_timer_del(ctx->prepare_sync_wait_timer);
+               }
+               DbgFree(ctx->pkgname);
+               DbgFree(ctx);
+
+               slave = slave_find_by_pid(pid);
+               if (!slave) {
+                       ErrPrint("Unable to activate slave %d\n", pid);
+                       goto out;
+               }
+
+               DbgPrint("Update handle for %s (%d)\n", pkgname, handle);
+               slave_rpc_update_handle(slave, handle, 1);
+       } else {
+               ctx = calloc(1, sizeof(*ctx));
+               if (!ctx) {
+                       ErrPrint("calloc: %s\n", strerror(errno));
+                       goto out;
+               }
 
-       DbgPrint("Sync context created: %s\n", pkgname);
-       s_info.hello_sync_ctx_list = eina_list_append(s_info.hello_sync_ctx_list, ctx);
+               ctx->timestamp = timestamp;
 
-       if (dead_callback_add(handle, delete_ctx_cb, ctx) < 0) {
-               ErrPrint("Failed to add dead callback\n");
+               ctx->pkgname = strdup(pkgname);
+               if (!ctx->pkgname) {
+                       ErrPrint("strdup: %s\n", strerror(errno));
+                       DbgFree(ctx);
+                       goto out;
+               }
+
+               ctx->pid = pid;
+               ctx->handle = handle;
+
+               DbgPrint("Sync context created: %s\n", pkgname);
+               s_info.hello_sync_ctx_list = eina_list_append(s_info.hello_sync_ctx_list, ctx);
+
+               if (dead_callback_add(handle, delete_ctx_cb, ctx) < 0) {
+                       ErrPrint("Failed to add dead callback\n");
+               }
        }
 
 out:
        return NULL;
 }
 
+static Eina_Bool prepare_sync_wait_cb(void *data)
+{
+       struct sync_ctx_item *item = data;
+
+       s_info.hello_sync_ctx_list = eina_list_remove(s_info.hello_sync_ctx_list, item);
+
+       ErrPrint("Sync timer(%lf) expired (%s), Terminate %d\n", WIDGET_CONF_SLAVE_ACTIVATE_TIME * 2.0f, item->pkgname, item->pid);
+
+       if (item->pid > 0) {
+               aul_terminate_pid_async(item->pid);
+       }
+
+       item->prepare_sync_wait_timer = NULL;
+       DbgFree(item->pkgname);
+       DbgFree(item);
+
+       return ECORE_CALLBACK_CANCEL;
+}
+
 static struct packet *slave_hello_sync(pid_t pid, int handle, const struct packet *packet) /* slave_name, ret */
 {
        struct packet *result = NULL;
@@ -8006,24 +8066,58 @@ static struct packet *slave_hello_sync(pid_t pid, int handle, const struct packe
                }
 
                if (!item) {
-                       ErrPrint("There is no such sync context (%d)\n", pid);
-                       goto out;
-               }
+                       ErrPrint("There is no such sync context (%d), Waiting prepare ctx\n", pid);
 
-               if (strcmp(item->pkgname, pkgname)) {
-                       ErrPrint("HELLO_SYNC is comes from different package: %s <> %s\n", item->pkgname, pkgname);
-               }
+                       item = calloc(1, sizeof(*item));
+                       if (!item) {
+                               ErrPrint("calloc: %s\n", strerror(errno));
+                               goto out;
+                       }
 
-               handle = item->handle;
+                       item->pkgname = strdup(pkgname);
+                       if (!item->pkgname) {
+                               ErrPrint("strdup: %s\n", strerror(errno));
+                               DbgFree(item);
+                               goto out;
+                       }
 
-               if (dead_callback_del(handle, delete_ctx_cb) != item) {
-                       ErrPrint("Dead callback is not valid\n");
-               }
+                       item->handle = -1;
+                       item->pid = pid;
+                       item->timestamp = timestamp;
+
+                       /**
+                        * @note
+                        * If the prepare sync doesn't come in ACTIVATE_TIME * 2.0f, there is a problem. we have to cancel it
+                        */
+                       item->prepare_sync_wait_timer = ecore_timer_add(WIDGET_CONF_SLAVE_ACTIVATE_TIME * 2.0f, prepare_sync_wait_cb, item);
+
+                       /**
+                        * @note
+                        * How can we delete this if there is no prepare context?
+                        */
+                       s_info.hello_sync_ctx_list = eina_list_append(s_info.hello_sync_ctx_list, item);
 
-               DbgFree(item->pkgname);
-               DbgFree(item);
+                       /**
+                        * @note
+                        * Reset the handle to prevent from updating RPC handle of SLAVE object
+                        */
+                       handle = -1;
+               } else {
+                       if (strcmp(item->pkgname, pkgname)) {
+                               ErrPrint("HELLO_SYNC is comes from different package: %s <> %s\n", item->pkgname, pkgname);
+                       }
 
-               DbgPrint("Hello sync context found: %s\n", pkgname);
+                       handle = item->handle;
+
+                       if (dead_callback_del(handle, delete_ctx_cb) != item) {
+                               ErrPrint("Dead callback is not valid\n");
+                       }
+
+                       DbgFree(item->pkgname);
+                       DbgFree(item);
+
+                       DbgPrint("Hello sync context found: %s\n", pkgname);
+               }
        }
 
        if (!slave) {
@@ -8110,7 +8204,11 @@ static struct packet *slave_hello_sync(pid_t pid, int handle, const struct packe
                         * In this case, there could not be exists any pended packets.
                         * But we tried to clear them for a case!
                         */
-                       slave_rpc_update_handle(slave, handle, 1);
+                       if (handle >= 0) {
+                               slave_rpc_update_handle(slave, handle, 1);
+                       } else {
+                               DbgPrint("Slave RPC should be updated soon (waiting prepare sync)\n");
+                       }
 
                        DbgPrint("Slave is activated by request: %d (%s)/(%s)\n", pid, pkgname, slavename);
 
@@ -8210,7 +8308,11 @@ static struct packet *slave_hello_sync(pid_t pid, int handle, const struct packe
                        package_del_instance_by_category(CATEGORY_WATCH_CLOCK, widget_id);
                }
 
-               slave_rpc_update_handle(slave, handle, 0);
+               if (handle >= 0) {
+                       slave_rpc_update_handle(slave, handle, 0);
+               } else {
+                       DbgPrint("Slave RPC should be updated soon (waiting prepare sync)\n");
+               }
 
                DbgPrint("Slave is activated by request: %d (%s)/(%s)\n", pid, pkgname, slavename);
                widget_size = package_size_list(info);