Store nodisplay value to widget db 30/63530/2
authorDaehyeon Jung <darrenh.jung@samsung.com>
Thu, 24 Mar 2016 10:56:01 +0000 (19:56 +0900)
committerDaehyeon Jung <darrenh.jung@samsung.com>
Thu, 24 Mar 2016 12:25:52 +0000 (21:25 +0900)
Change-Id: I78a21a1426938a9015f9ee8c45b9e747e6d6c704

parser/widget.sql
parser/widget_plugin_parser.c
parser/widget_plugin_parser_db.c
parser/widget_plugin_parser_internal.h
src/widget_service.c

index d51fc9b..c1d9134 100644 (file)
@@ -10,6 +10,7 @@ CREATE TABLE widget_class (
   setup_appid   TEXT,
   appid         TEXT NOT NULL,
   pkgid         TEXT NOT NULL,
+  nodisplay     INTEGER DEFAULT 0,
   PRIMARY KEY(classid)
 );
 
index e68c0e4..710ee33 100644 (file)
@@ -257,6 +257,12 @@ static int _parse_widget_application(xmlNode *node, GList **list)
        if (val)
                wc->update_period = atoi(val);
 
+       val = _get_attribute(node, "nodisplay");
+       if (val && strncmp(val, "true", strlen("true")) == 0)
+               wc->nodisplay = 1;
+       else
+               wc->nodisplay = 0;
+
        wc->setup_appid = _get_attribute(node, "setup-appid");
 
        for (tmp = node->children; tmp; tmp = tmp->next) {
index 4d2c5c0..6c6c62e 100644 (file)
@@ -164,8 +164,8 @@ static int _insert_widget_class(sqlite3 *db, const char *pkgid, GList *wcs)
        int ret;
        static const char query[] =
                "INSERT INTO widget_class (classid, update_period, "
-               "setup_appid, appid, pkgid) "
-               "VALUES (?, ?, ?, ?, ?)";
+               "setup_appid, appid, pkgid, nodisplay) "
+               "VALUES (?, ?, ?, ?, ?, ?)";
        GList *tmp;
        struct widget_class *wc;
        sqlite3_stmt *stmt = NULL;
@@ -185,6 +185,7 @@ static int _insert_widget_class(sqlite3 *db, const char *pkgid, GList *wcs)
                _bind_text(stmt, idx++, wc->setup_appid);
                _bind_text(stmt, idx++, wc->appid);
                _bind_text(stmt, idx++, pkgid);
+               sqlite3_bind_int(stmt, idx++, wc->nodisplay);
 
                ret = sqlite3_step(stmt);
                if (ret != SQLITE_DONE) {
index 8f274de..44f0fdb 100644 (file)
@@ -39,6 +39,7 @@ struct widget_class {
        int update_period;
        char *setup_appid;
        char *appid;
+       int nodisplay;
        GList *support_size;
        GList *label;
        GList *icon;
index ff4343d..31b56d9 100644 (file)
@@ -692,21 +692,19 @@ EAPI char *widget_service_get_app_id_of_setup_app(const char *widget_id)
        return appid;
 }
 
-static bool _get_nodisplay(const char *widget_id, uid_t uid)
+static int _get_nodisplay(const char *widget_id, uid_t uid)
 {
        static const char query[] =
-               "SELECT appid FROM widget_class WHERE classid=?";
+               "SELECT nodisplay FROM widget_class WHERE classid=?";
        int ret;
        sqlite3 *db;
        sqlite3_stmt *stmt;
-       char *appid;
-       pkgmgrinfo_appinfo_h appinfo;
-       bool nodisplay;
+       int nodisplay = 0;
 
        db = _open_db(uid);
        if (db == NULL) {
                set_last_result(WIDGET_ERROR_IO_ERROR);
-               return false;
+               return 0;
        }
 
        ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
@@ -714,7 +712,7 @@ static bool _get_nodisplay(const char *widget_id, uid_t uid)
                _E("prepare error: %s", sqlite3_errmsg(db));
                sqlite3_close_v2(db);
                set_last_result(WIDGET_ERROR_FAULT);
-               return false;
+               return 0;
        }
 
        sqlite3_bind_text(stmt, 1, widget_id, -1, SQLITE_STATIC);
@@ -727,29 +725,14 @@ static bool _get_nodisplay(const char *widget_id, uid_t uid)
                /* TODO: which error should be set? */
                set_last_result(ret == SQLITE_DONE ? WIDGET_ERROR_NOT_EXIST :
                                WIDGET_ERROR_FAULT);
-               return false;
+               return 0;
        }
 
-       _get_column_str(stmt, 0, &appid);
+       _get_column_int(stmt, 0, &nodisplay);
 
        sqlite3_finalize(stmt);
        sqlite3_close_v2(db);
 
-       ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &appinfo);
-       free(appid);
-       if (ret != PMINFO_R_OK) {
-               set_last_result(WIDGET_ERROR_FAULT);
-               return false;
-       }
-
-       ret = pkgmgrinfo_appinfo_is_nodisplay(appinfo, &nodisplay);
-       pkgmgrinfo_appinfo_destroy_appinfo(appinfo);
-       if (ret != PMINFO_R_OK) {
-               _E("failed to get nodisplay of widget %s", widget_id);
-               set_last_result(WIDGET_ERROR_FAULT);
-               return false;
-       }
-
        set_last_result(WIDGET_ERROR_NONE);
 
        return nodisplay;
@@ -757,7 +740,7 @@ static bool _get_nodisplay(const char *widget_id, uid_t uid)
 
 EAPI int widget_service_get_nodisplay(const char *widget_id)
 {
-       bool nodisplay;
+       int nodisplay;
 
        if (!_is_widget_feature_enabled()) {
                _E("not supported");
@@ -775,7 +758,7 @@ EAPI int widget_service_get_nodisplay(const char *widget_id)
        if (get_last_result() == WIDGET_ERROR_NOT_EXIST)
                nodisplay = _get_nodisplay(widget_id, GLOBALAPP_USER);
 
-       return (int)nodisplay;
+       return nodisplay;
 }
 
 /* deprecated, always return need_of_frame as false */