summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2016-10-14 08:31:29 +0900
committerHwankyu Jhun <h.jhun@samsung.com>2016-10-14 08:31:29 +0900
commitbfef5f808ea3c0473feb509eee99e1e9d68d73f6 (patch)
tree8f7c35290ebe331ccd94266c5e8e32042e17eae7
parentb27f94ecb6914c42cce6186027bfc793c076e89e (diff)
downloadwidget-service-bfef5f808ea3c0473feb509eee99e1e9d68d73f6.tar.gz
widget-service-bfef5f808ea3c0473feb509eee99e1e9d68d73f6.tar.bz2
widget-service-bfef5f808ea3c0473feb509eee99e1e9d68d73f6.zip
- Add prime column to widget_class table Change-Id: I691ae3b0b0d1dcec5c472aa573a91e7a242cb95e Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r--parser/widget.sql1
-rw-r--r--parser/widget_plugin_parser.c7
-rw-r--r--parser/widget_plugin_parser_db.c5
-rw-r--r--parser/widget_plugin_parser_internal.h1
-rw-r--r--src/widget_service.c101
5 files changed, 27 insertions, 88 deletions
diff --git a/parser/widget.sql b/parser/widget.sql
index fd105db..4a66966 100644
--- a/parser/widget.sql
+++ b/parser/widget.sql
@@ -12,6 +12,7 @@ CREATE TABLE widget_class (
pkgid TEXT NOT NULL,
nodisplay INTEGER DEFAULT 0,
max_instance INTEGER DEFAULT 0,
+ prime INTEGER DEFAULT 0,
PRIMARY KEY(classid)
);
diff --git a/parser/widget_plugin_parser.c b/parser/widget_plugin_parser.c
index e5c025d..a0d27a0 100644
--- a/parser/widget_plugin_parser.c
+++ b/parser/widget_plugin_parser.c
@@ -276,6 +276,13 @@ static int _parse_widget_application(xmlNode *node, GList **list)
wc->max_instance = atoi(val);
free(val);
+ val = _get_attribute(node, "main");
+ if (val && strcmp(val, "true") == 0)
+ wc->prime = 1;
+ else
+ wc->prime = 0;
+ free(val);
+
for (tmp = node->children; tmp; tmp = tmp->next) {
switch (_get_tag(tmp)) {
case TAG_SUPPORT_SIZE:
diff --git a/parser/widget_plugin_parser_db.c b/parser/widget_plugin_parser_db.c
index e186711..aa93edf 100644
--- a/parser/widget_plugin_parser_db.c
+++ b/parser/widget_plugin_parser_db.c
@@ -240,8 +240,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, nodisplay, max_instance) "
- "VALUES (?, ?, ?, ?, ?, ?, ?)";
+ "setup_appid, appid, pkgid, nodisplay, max_instance, prime) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
GList *tmp;
struct widget_class *wc;
sqlite3_stmt *stmt = NULL;
@@ -263,6 +263,7 @@ static int _insert_widget_class(sqlite3 *db, const char *pkgid, GList *wcs)
_bind_text(stmt, idx++, pkgid);
sqlite3_bind_int(stmt, idx++, wc->nodisplay);
sqlite3_bind_int(stmt, idx++, wc->max_instance);
+ sqlite3_bind_int(stmt, idx++, wc->prime);
ret = sqlite3_step(stmt);
if (ret != SQLITE_DONE) {
diff --git a/parser/widget_plugin_parser_internal.h b/parser/widget_plugin_parser_internal.h
index bf14b59..fd31c61 100644
--- a/parser/widget_plugin_parser_internal.h
+++ b/parser/widget_plugin_parser_internal.h
@@ -41,6 +41,7 @@ struct widget_class {
char *appid;
int max_instance;
int nodisplay;
+ int prime;
GList *support_size;
GList *label;
GList *icon;
diff --git a/src/widget_service.c b/src/widget_service.c
index 2f48eae..12bec2e 100644
--- a/src/widget_service.c
+++ b/src/widget_service.c
@@ -51,11 +51,6 @@
#define RESOLUTION_SECTION_NAME "resolution"
#define RESOLUTION_FORMAT "%dx%d"
-struct widget_info_s {
- char *appid;
- bool is_mainapp;
-};
-
struct widget_instance_info_s {
int period;
bool exists;
@@ -598,7 +593,7 @@ static void __free_widget_list(gpointer data)
static int _get_widget_list(const char *pkgid, uid_t uid, GList **list)
{
static const char query[] =
- "SELECT classid, pkgid FROM widget_class";
+ "SELECT classid, pkgid, prime FROM widget_class";
static const char query_where[] =
" WHERE pkgid = ?";
char query_buf[MAX_BUF_SIZE];
@@ -639,6 +634,7 @@ static int _get_widget_list(const char *pkgid, uid_t uid, GList **list)
_get_column_str(stmt, 0, &item->classid);
_get_column_str(stmt, 1, &item->pkgid);
+ _get_column_int(stmt, 2, &item->is_prime);
*list = g_list_append(*list, item);
}
@@ -1448,68 +1444,17 @@ static char *_get_widget_id(const char *appid, uid_t uid)
return classid;
}
-static int __foreach_appinfo_cb(const pkgmgrinfo_appinfo_h handle,
- void *user_data)
-{
- pkgmgrinfo_app_component comp = PMINFO_ALL_APP;
- char *appid = NULL;
- bool is_mainapp = false;
- struct widget_info_s *widget_info;
- GList **widget_list = (GList **)user_data;
- int ret;
-
- ret = pkgmgrinfo_appinfo_get_component(handle, &comp);
- if (ret != PMINFO_R_OK) {
- _E("Failed to get component");
- return 0;
- }
-
- if (comp != PMINFO_WIDGET_APP)
- return 0;
-
- ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
- if (ret != PMINFO_R_OK) {
- _E("Failed to get appid");
- return 0;
- }
-
- ret = pkgmgrinfo_appinfo_is_mainapp(handle, &is_mainapp);
- if (ret != PMINFO_R_OK)
- _E("Failed to get is_mainapp");
-
- widget_info = (struct widget_info_s *)malloc(
- sizeof(struct widget_info_s));
- if (widget_info == NULL) {
- _E("out of memory");
- return -1;
- }
-
- widget_info->appid = strdup(appid);
- if (widget_info->appid == NULL) {
- _E("out of memory");
- free(widget_info);
- return -1;
- }
-
- widget_info->is_mainapp = is_mainapp;
-
- *widget_list = g_list_append(*widget_list, widget_info);
-
- return 0;
-}
-
static char *__get_widget_main_appid_from_pkgid_or_appid(const char *id)
{
pkgmgrinfo_appinfo_h appinfo = NULL;
pkgmgrinfo_pkginfo_h pkginfo = NULL;
- pkgmgrinfo_appinfo_filter_h handle = NULL;
char *new_pkgid = NULL;
char *pkgid = NULL;
GList *widget_list = NULL;
GList *iter;
- struct widget_info_s *widget_info;
char *widget_id = NULL;
int ret;
+ struct widget_list_item *item;
ret = pkgmgrinfo_pkginfo_get_pkginfo(id, &pkginfo);
if (ret != PMINFO_R_OK) {
@@ -1542,52 +1487,36 @@ static char *__get_widget_main_appid_from_pkgid_or_appid(const char *id)
id = new_pkgid;
}
- ret = pkgmgrinfo_appinfo_filter_create(&handle);
- if (ret != PMINFO_R_OK) {
- _E("Failed to create pkginfo filter");
- goto end;
- }
-
- ret = pkgmgrinfo_appinfo_filter_add_string(handle,
- PMINFO_APPINFO_PROP_APP_PACKAGE, id);
- if (ret != PMINFO_R_OK) {
- _E("Failed to add filter string");
- goto end;
- }
-
- ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle,
- __foreach_appinfo_cb, &widget_list);
- if (ret != PMINFO_R_OK) {
- _E("Failed to retrieve appinfo");
- goto end;
- }
+ ret = _get_widget_list(id, getuid(), &widget_list);
+ if (ret != WIDGET_ERROR_NONE || widget_list == NULL)
+ ret = _get_widget_list(id, GLOBALAPP_USER, &widget_list);
if (widget_list == NULL)
goto end;
iter = g_list_first(widget_list);
while (iter) {
- widget_info = iter->data;
+ item = (struct widget_list_item *)iter->data;
iter = g_list_next(iter);
- if (widget_info) {
- widget_list = g_list_remove(widget_list, widget_info);
- if (widget_info->is_mainapp) {
+ if (item) {
+ widget_list = g_list_remove(widget_list, item);
+ if (item->is_prime) {
if (widget_id)
free(widget_id);
- widget_id = strdup(widget_info->appid);
+ widget_id = strdup(item->classid);
}
if (widget_id == NULL)
- widget_id = strdup(widget_info->appid);
+ widget_id = strdup(item->classid);
- free(widget_info->appid);
- free(widget_info);
+ free(item->classid);
+ free(item->pkgid);
+ free(item);
}
}
end:
pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo);
- pkgmgrinfo_appinfo_filter_destroy(handle);
if (new_pkgid)
free(new_pkgid);