diff options
author | Hyunho Kang <hhstark.kang@samsung.com> | 2017-01-06 17:36:02 +0900 |
---|---|---|
committer | Hyunho Kang <hhstark.kang@samsung.com> | 2017-01-09 09:23:36 +0900 |
commit | cbfe181bbf96e10ed191fb910bfd8e5504b89548 (patch) | |
tree | fca3f99e1ec4c800740ea9710335e40bf483c479 | |
parent | c7b9e8b8d75eae40fb5694247259885eae61c6a2 (diff) | |
download | widget-service-accepted/tizen/3.0.m2/tv/20170110.084104.tar.gz widget-service-accepted/tizen/3.0.m2/tv/20170110.084104.tar.bz2 widget-service-accepted/tizen/3.0.m2/tv/20170110.084104.zip |
Fix widget_service_get_icon bugsubmit/tizen_3.0/20170109.003313submit/tizen_3.0.m2/20170109.005227accepted/tizen/3.0/wearable/20170109.074226accepted/tizen/3.0/tv/20170109.074207accepted/tizen/3.0/mobile/20170109.074147accepted/tizen/3.0/ivi/20170109.074242accepted/tizen/3.0/common/20170109.200423accepted/tizen/3.0.m2/wearable/20170110.084115accepted/tizen/3.0.m2/tv/20170110.084104accepted/tizen/3.0.m2/mobile/20170110.084052accepted/tizen/3.0.m2/common/20170110.181743tizen_3.0.m2accepted/tizen_3.0.m2_wearableaccepted/tizen_3.0.m2_tvaccepted/tizen_3.0.m2_mobileaccepted/tizen_3.0.m2_common
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.c | 62 |
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); |