summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyunho Kang <hhstark.kang@samsung.com>2017-01-06 17:36:02 +0900
committerHyunho Kang <hhstark.kang@samsung.com>2017-01-09 09:23:36 +0900
commitcbfe181bbf96e10ed191fb910bfd8e5504b89548 (patch)
treefca3f99e1ec4c800740ea9710335e40bf483c479
parentc7b9e8b8d75eae40fb5694247259885eae61c6a2 (diff)
downloadwidget-service-accepted/tizen_3.0.m2_wearable.tar.gz
widget-service-accepted/tizen_3.0.m2_wearable.tar.bz2
widget-service-accepted/tizen_3.0.m2_wearable.zip
Api should get icon info with pkgid Change-Id: I6de807bcdc57f4b71b8ec8c58292a03b5c1ecfe2 Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
-rw-r--r--src/widget_service.c62
1 files changed, 60 insertions, 2 deletions
diff --git a/src/widget_service.c b/src/widget_service.c
index 3354471..2b3600f 100644
--- a/src/widget_service.c
+++ b/src/widget_service.c
@@ -1196,6 +1196,59 @@ EAPI char *widget_service_get_preview_image_path(const char *widget_id,
return path;
}
+
+static char *_get_main_widget_id(const char *pkg_id, uid_t uid)
+{
+ static const char query[] =
+ "SELECT classid FROM widget_class "
+ "WHERE pkgid=? and prime=1 ";
+ int ret;
+ sqlite3 *db;
+ sqlite3_stmt *stmt;
+ char *widget_id;
+
+ db = _open_db(uid);
+ if (db == NULL) {
+ set_last_result(WIDGET_ERROR_IO_ERROR);
+ return NULL;
+ }
+
+ ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ /* LCOV_EXCL_START */
+ _E("prepare error: %s", sqlite3_errmsg(db));
+ sqlite3_close_v2(db);
+ set_last_result(WIDGET_ERROR_FAULT);
+ return NULL;
+ /* LCOV_EXCL_STOP */
+ }
+
+ sqlite3_bind_text(stmt, 1, pkg_id, -1, SQLITE_STATIC);
+
+ ret = sqlite3_step(stmt);
+ if (ret != SQLITE_ROW) {
+ if (ret == SQLITE_DONE)
+ _E("cannot find widget_id for pkg_id %s", pkg_id);
+ else
+ _E("step error: %s", sqlite3_errmsg(db));
+ sqlite3_finalize(stmt);
+ sqlite3_close_v2(db);
+ /* TODO: which error should be set? */
+ set_last_result(ret == SQLITE_DONE ? WIDGET_ERROR_NOT_EXIST :
+ WIDGET_ERROR_FAULT);
+ return NULL;
+ }
+
+ _get_column_str(stmt, 0, &widget_id);
+
+ sqlite3_finalize(stmt);
+ sqlite3_close_v2(db);
+
+ set_last_result(WIDGET_ERROR_NONE);
+
+ return widget_id;
+}
+
static char *_get_icon(const char *widget_id, const char *lang, uid_t uid)
{
static const char query[] =
@@ -1253,9 +1306,10 @@ static char *_get_icon(const char *widget_id, const char *lang, uid_t uid)
return icon;
}
-EAPI char *widget_service_get_icon(const char *widget_id, const char *lang)
+EAPI char *widget_service_get_icon(const char *pkgid, const char *lang)
{
char *icon;
+ char *widget_id;
if (!_is_widget_feature_enabled()) {
_E("not supported");
@@ -1263,7 +1317,7 @@ EAPI char *widget_service_get_icon(const char *widget_id, const char *lang)
return NULL;
}
- if (widget_id == NULL) {
+ if (pkgid == NULL) {
_E("invalid parameter");
set_last_result(WIDGET_ERROR_INVALID_PARAMETER);
return NULL;
@@ -1274,6 +1328,10 @@ EAPI char *widget_service_get_icon(const char *widget_id, const char *lang)
return NULL;
}
+ widget_id = _get_main_widget_id(pkgid, getuid());
+ if (widget_id == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST)
+ widget_id = _get_main_widget_id(pkgid, GLOBALAPP_USER);
+
icon = _get_icon(widget_id, lang, getuid());
if (icon == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST)
icon = _get_icon(widget_id, lang, GLOBALAPP_USER);