summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2017-09-18 10:12:52 +0900
committerHwankyu Jhun <h.jhun@samsung.com>2017-09-18 10:12:58 +0900
commit7fd661540a297c39426a486fe04e8768bc9991e0 (patch)
tree1977fa6144479ebc84b7ce57ac222c8f9dca82bb
parentb96ff5761fe31fd5ec86b114f2a2ae80ebe122ab (diff)
parent489c2da49da3328605515d4df35ed9c0aec48996 (diff)
downloadwidget-service-devel/tizen.tar.gz
widget-service-devel/tizen.tar.bz2
widget-service-devel/tizen.zip
Merge branch 'tizen_3.0' into devel/tizendevel/tizen
Change-Id: I13528a4381017c039978757f5c06beb2d28510fc Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r--include/widget_instance.h1
-rw-r--r--parser/widget_plugin_parser.c2
-rw-r--r--src/widget_instance.c86
-rw-r--r--src/widget_service.c170
4 files changed, 212 insertions, 47 deletions
diff --git a/include/widget_instance.h b/include/widget_instance.h
index f33ff5c..f3e7c29 100644
--- a/include/widget_instance.h
+++ b/include/widget_instance.h
@@ -62,6 +62,7 @@ int widget_instance_get_content(widget_instance_h instance, char **content);
int widget_instance_get_width(widget_instance_h instance, int *w);
int widget_instance_get_height(widget_instance_h instance, int *h);
int widget_instance_get_period(widget_instance_h instance, double *period);
+int widget_instance_get_error_code(widget_instance_h instance, int *err);
int widget_instance_create(const char *widget_id, char **instance_id);
int widget_instance_launch(const char *instance_id, char *content_info, int w, int h);
diff --git a/parser/widget_plugin_parser.c b/parser/widget_plugin_parser.c
index a0d27a0..bb63711 100644
--- a/parser/widget_plugin_parser.c
+++ b/parser/widget_plugin_parser.c
@@ -115,12 +115,14 @@ static int _parse_support_size(xmlNode *node, GList **sizes)
tok = strtok_r(val, "xX", &ptr);
if (tok == NULL) {
free(size);
+ free(val);
return -1;
}
size->width = atoi(tok);
tok = strtok_r(NULL, "xX", &ptr);
if (tok == NULL) {
free(size);
+ free(val);
return -1;
}
size->height = atoi(tok);
diff --git a/src/widget_instance.c b/src/widget_instance.c
index 6e83e1a..300d6a1 100644
--- a/src/widget_instance.c
+++ b/src/widget_instance.c
@@ -68,6 +68,7 @@ struct _widget_instance {
int status;
int stored;
int ref;
+ int err;
};
struct widget_app {
@@ -112,6 +113,8 @@ struct event_cb_s {
static int __fault_handler(int pid);
static void __free_sdk_util(void);
+extern int widget_service_get_update_period(const char *widget_id, double *period);
+
static struct _widget_instance *__pick_instance(const char *instance_id)
{
GList *instances = _widget_instances;
@@ -195,6 +198,12 @@ static struct _widget_instance *__add_instance(const char *id, const char *widge
{
struct _widget_instance *instance = NULL;
struct widget_app *app = NULL;
+ double period = 0;
+
+ if (widget_service_get_update_period(widget_id, &period) != WIDGET_ERROR_NONE) {
+ _E("Can't get update-period");
+ return NULL;
+ }
instance = (struct _widget_instance *)malloc(sizeof(struct _widget_instance));
if (instance == NULL) {
@@ -209,6 +218,8 @@ static struct _widget_instance *__add_instance(const char *id, const char *widge
instance->widget_id = strdup(widget_id);
instance->content_info = NULL;
instance->ref = 0;
+ instance->period = period;
+ instance->err = 0;
_widget_instances = g_list_append(_widget_instances, instance);
@@ -296,6 +307,35 @@ EAPI int widget_instance_create(const char *widget_id, char **instance_id)
return -1;
}
+static int __convert_aul_error(int res)
+{
+ int ret;
+
+ switch (res) {
+ case AUL_R_EREJECTED:
+ case AUL_R_ENOAPP:
+ ret = WIDGET_ERROR_NOT_EXIST;
+ break;
+ case AUL_R_EILLACC:
+ ret = WIDGET_ERROR_PERMISSION_DENIED;
+ break;
+ case AUL_R_ETIMEOUT:
+ ret = WIDGET_ERROR_TIMED_OUT;
+ break;
+ case AUL_R_ECANCELED:
+ ret = WIDGET_ERROR_CANCELED;
+ break;
+ case AUL_R_EINVAL:
+ ret = WIDGET_ERROR_INVALID_PARAMETER;
+ break;
+ default:
+ ret = WIDGET_ERROR_FAULT;
+ break;
+ }
+
+ return ret;
+}
+
static int __launch(const char *widget_id, const char *instance_id, bundle *extra)
{
int ret = 0;
@@ -323,6 +363,8 @@ static int __launch(const char *widget_id, const char *instance_id, bundle *extr
aul_svc_set_operation(b, AUL_SVC_OPERATION_LAUNCH_WIDGET);
ret = aul_launch_app_async(appid, b);
+ if (ret < 0)
+ ret = __convert_aul_error(ret);
if (!extra) {
bundle_free(b);
@@ -424,6 +466,7 @@ EAPI int widget_instance_launch(const char *instance_id, char *content_info, int
bundle_add_str(b, WIDGET_K_CALLER, pid_buf);
bundle_add_str(b, WIDGET_K_ENDPOINT, viewer_appid);
bundle_add_str(b, WIDGET_K_OPERATION, "create");
+ bundle_add_byte(b, WIDGET_K_PERIOD, &(instance->period), sizeof(double));
if (sdk_util.name) {
bundle_add_str(b, AUL_K_SDK, sdk_util.name);
@@ -494,7 +537,7 @@ EAPI int widget_instance_destroy(const char *instance_id)
return -1;
}
- if (instance->pid) {
+ if (instance->pid > 0) {
ret = __send_aul_cmd(instance, "destroy", NULL);
} else { /* uninitialized */
__remove_instance(instance);
@@ -623,8 +666,9 @@ static int __check_valid_sender(char *widget_id, int pid)
head = app->instances;
if (head) {
instance = (widget_instance_h)head->data;
- if (instance->pid == pid)
+ if (instance->pid == -1 || instance->pid == pid)
return 0;
+ _E("instance->pid (%d), pid (%d)", instance->pid, pid);
}
}
return -1;
@@ -676,7 +720,7 @@ static int __status_handler(const char *endpoint, aul_app_com_result_e e, bundle
bundle_get_byte(envelope, AUL_K_WIDGET_STATUS, (void **)&status, &status_sz);
bundle_get_str(envelope, AUL_K_COM_SENDER_PID, &sender_pid_str);
bundle_get_str(envelope, AUL_K_PKGID, &sender_pkgid);
- bundle_get_str(envelope, AUL_K_WIDGET_FAULT, &is_faulted);
+ bundle_get_str(envelope, AUL_K_IS_FAULT, &is_faulted);
if (widget_id == NULL || status == NULL) {
_E("undefined class or instance %s of %s", instance_id, widget_id);
@@ -689,9 +733,9 @@ static int __status_handler(const char *endpoint, aul_app_com_result_e e, bundle
sender_pid = atoi(sender_pid_str);
if (__check_valid_sender(widget_id, sender_pid) == -1) {
bundle_get_str(envelope, AUL_K_PKGID, &sender_pkgid);
+ LOGW("It's not my widget(%s), let's check package", widget_id);
if (__check_valid_sender_v2(sender_pkgid) < 0) {
- _E("invalid sender, pid %d do not have widget_id %s",
- sender_pid, widget_id);
+ LOGW("My package do not have widget_id %s", widget_id);
return 0;
}
}
@@ -728,7 +772,8 @@ static int __connect_status_handler()
return 0;
}
-static int __widget_instance_handler(int status, char *widget_id, char *instance_id, char *content_info)
+static int __widget_instance_handler(int status, char *widget_id,
+ char *instance_id, char *content_info, int err)
{
struct _widget_instance *instance;
@@ -772,7 +817,10 @@ static int __widget_instance_handler(int status, char *widget_id, char *instance
}
break;
case WIDGET_INSTANCE_EVENT_FAULT:
-
+ break;
+ case WIDGET_INSTANCE_EVENT_CREATE_ABORTED:
+ instance->pid = -1;
+ instance->err = err;
break;
default:
_E("unknown status: %d", status);
@@ -791,12 +839,14 @@ static int __widget_handler(const char *viewer_id, aul_app_com_result_e e, bundl
{
char *widget_id = NULL;
char *instance_id = NULL;
+ char *error_code = NULL;
int *status = NULL;
size_t status_sz = 0;
char *content_info = NULL;
char *sender_pid_str = NULL;
int sender_pid;
int ret;
+ int err = 0;
bundle_get_str(envelope, AUL_K_WIDGET_ID, &widget_id);
bundle_get_byte(envelope, AUL_K_WIDGET_STATUS, (void **)&status, &status_sz);
@@ -816,7 +866,12 @@ static int __widget_handler(const char *viewer_id, aul_app_com_result_e e, bundl
} else {
bundle_get_str(envelope, AUL_K_WIDGET_INSTANCE_ID, &instance_id);
bundle_get_str(envelope, WIDGET_K_CONTENT_INFO, &content_info);
- __widget_instance_handler(*status, widget_id, instance_id, content_info);
+ bundle_get_str(envelope, AUL_K_WIDGET_ERROR_CODE, &error_code);
+ if (error_code)
+ err = atoi(error_code);
+
+ __widget_instance_handler(*status, widget_id, instance_id,
+ content_info, err);
}
return 0;
@@ -833,7 +888,7 @@ static int __fault_handler(int pid)
while (iter) {
instance = (struct _widget_instance *)iter->data;
if (instance && instance->pid == pid) {
- instance->pid = 0;
+ instance->pid = -1;
instance->status = WIDGET_INSTANCE_TERMINATED;
__notify_event(WIDGET_INSTANCE_EVENT_FAULT, instance->widget_id, instance->id);
}
@@ -894,6 +949,16 @@ EAPI int widget_instance_fini()
return 0;
}
+EAPI int widget_instance_get_error_code(widget_instance_h instance, int *err)
+{
+ if (instance == NULL || err == NULL)
+ return -1;
+
+ *err = instance->err;
+
+ return 0;
+}
+
EAPI int widget_instance_get_id(widget_instance_h instance, char **id)
{
if (instance == NULL || id == NULL)
@@ -1004,6 +1069,9 @@ EAPI int widget_instance_trigger_update_v2(const char *widget_id,
case AUL_R_EINVAL:
ret = WIDGET_ERROR_INVALID_PARAMETER;
break;
+ case AUL_R_ECANCELED:
+ ret = WIDGET_ERROR_CANCELED;
+ break;
default:
ret = WIDGET_ERROR_FAULT;
}
diff --git a/src/widget_service.c b/src/widget_service.c
index 603be91..8d39b36 100644
--- a/src/widget_service.c
+++ b/src/widget_service.c
@@ -200,6 +200,11 @@ static void _get_column_int(sqlite3_stmt *stmt, int idx, int *i)
*i = sqlite3_column_int(stmt, idx);
}
+static void _get_column_double(sqlite3_stmt *stmt, int idx, double *i)
+{
+ *i = sqlite3_column_double(stmt, idx);
+}
+
#define WIDGET_SIZE_TYPE_MAX 13
static int size_list[WIDGET_SIZE_TYPE_MAX][5] = {
{ 1, 1, 175, 175, WIDGET_SIZE_TYPE_1x1 }, /*!< 1x1 */
@@ -781,7 +786,7 @@ EAPI int widget_service_get_widget_list(widget_list_cb cb, void *data)
return WIDGET_ERROR_PERMISSION_DENIED;
ret = _get_widget_list(NULL, getuid(), &list);
- if (ret == WIDGET_ERROR_NONE)
+ if (ret == WIDGET_ERROR_NONE && !_is_global(getuid()))
ret = _get_widget_list(NULL, GLOBALAPP_USER, &list);
for (tmp = list; tmp; tmp = tmp->next) {
@@ -823,7 +828,7 @@ EAPI int widget_service_get_widget_list_by_pkgid(const char *pkgid,
return WIDGET_ERROR_PERMISSION_DENIED;
ret = _get_widget_list(pkgid, getuid(), &list);
- if (ret == WIDGET_ERROR_NONE)
+ if (ret == WIDGET_ERROR_NONE && !_is_global(getuid()))
ret = _get_widget_list(pkgid, GLOBALAPP_USER, &list);
for (tmp = list; tmp; tmp = tmp->next) {
@@ -872,12 +877,16 @@ static char *_get_main_app_id(const char *widget_id, uid_t uid)
ret = sqlite3_step(stmt);
if (ret != SQLITE_ROW) {
- _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);
+ if (ret == SQLITE_DONE) {
+ set_last_result(WIDGET_ERROR_NOT_EXIST);
+ LOGW("No data for uid (%d)", uid);
+ } else {
+ set_last_result(WIDGET_ERROR_FAULT);
+ _E("step error: %s", sqlite3_errmsg(db));
+ }
return NULL;
}
@@ -931,7 +940,8 @@ EAPI char *widget_service_get_main_app_id(const char *widget_id)
}
appid = _get_main_app_id(widget_id, getuid());
- if (appid == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST)
+ if (appid == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST
+ && !_is_global(getuid()))
appid = _get_main_app_id(widget_id, GLOBALAPP_USER);
return appid;
@@ -961,7 +971,7 @@ EAPI int widget_service_get_supported_size_types(const char *widget_id,
ret = _get_widget_supported_info(widget_id, getuid(), cnt,
&width, &height, types);
- if (ret == WIDGET_ERROR_NOT_EXIST)
+ if (ret == WIDGET_ERROR_NOT_EXIST && !_is_global(getuid()))
ret = _get_widget_supported_info(widget_id, GLOBALAPP_USER,
cnt, &width, &height, types);
@@ -1008,12 +1018,16 @@ static char *_get_app_id_of_setup_app(const char *widget_id, uid_t uid)
ret = sqlite3_step(stmt);
if (ret != SQLITE_ROW) {
- _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);
+ if (ret == SQLITE_DONE) {
+ set_last_result(WIDGET_ERROR_NOT_EXIST);
+ LOGW("No data for uid (%d)", uid);
+ } else {
+ set_last_result(WIDGET_ERROR_FAULT);
+ _E("step error: %s", sqlite3_errmsg(db));
+ }
return NULL;
}
@@ -1050,7 +1064,8 @@ EAPI char *widget_service_get_app_id_of_setup_app(const char *widget_id)
}
appid = _get_app_id_of_setup_app(widget_id, getuid());
- if (appid == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST)
+ if (appid == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST
+ && !_is_global(getuid()))
appid = _get_app_id_of_setup_app(widget_id, GLOBALAPP_USER);
return appid;
@@ -1083,12 +1098,16 @@ static int _get_nodisplay(const char *widget_id, uid_t uid)
ret = sqlite3_step(stmt);
if (ret != SQLITE_ROW) {
- _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);
+ if (ret == SQLITE_DONE) {
+ set_last_result(WIDGET_ERROR_NOT_EXIST);
+ LOGW("No data for uid (%d)", uid);
+ } else {
+ set_last_result(WIDGET_ERROR_FAULT);
+ _E("step error: %s", sqlite3_errmsg(db));
+ }
return 0;
}
@@ -1102,6 +1121,58 @@ static int _get_nodisplay(const char *widget_id, uid_t uid)
return nodisplay;
}
+static int _get_update_period(const char *widget_id, uid_t uid, double *period)
+{
+ static const char query[] =
+ "SELECT update_period FROM widget_class WHERE classid=?";
+ int ret;
+ sqlite3 *db;
+ sqlite3_stmt *stmt;
+
+ db = _open_db(uid);
+ if (db == NULL) {
+ return WIDGET_ERROR_IO_ERROR;
+ }
+
+ ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ _E("prepare error: %s", sqlite3_errmsg(db));
+ sqlite3_close_v2(db);
+ return WIDGET_ERROR_FAULT;
+ }
+
+ sqlite3_bind_text(stmt, 1, widget_id, -1, SQLITE_STATIC);
+
+ ret = sqlite3_step(stmt);
+ if (ret != SQLITE_ROW) {
+ sqlite3_finalize(stmt);
+ sqlite3_close_v2(db);
+ if (ret == SQLITE_DONE) {
+ LOGW("No data for uid (%d)", uid);
+ return WIDGET_ERROR_NOT_EXIST;
+ } else {
+ _E("step error: %s", sqlite3_errmsg(db));
+ return WIDGET_ERROR_FAULT;
+ }
+ }
+
+ _get_column_double(stmt, 0, period);
+ sqlite3_finalize(stmt);
+ sqlite3_close_v2(db);
+
+ return WIDGET_ERROR_NONE;
+}
+
+int widget_service_get_update_period(const char *widget_id, double *period)
+{
+ int ret = _get_update_period(widget_id, getuid(), period);
+
+ if (ret == WIDGET_ERROR_NOT_EXIST)
+ ret = _get_update_period(widget_id, GLOBALAPP_USER, period);
+
+ return ret;
+}
+
EAPI int widget_service_get_nodisplay(const char *widget_id)
{
int nodisplay;
@@ -1125,7 +1196,8 @@ EAPI int widget_service_get_nodisplay(const char *widget_id)
}
nodisplay = _get_nodisplay(widget_id, getuid());
- if (get_last_result() == WIDGET_ERROR_NOT_EXIST)
+ if (get_last_result() == WIDGET_ERROR_NOT_EXIST
+ && !_is_global(getuid()))
nodisplay = _get_nodisplay(widget_id, GLOBALAPP_USER);
return nodisplay;
@@ -1226,12 +1298,16 @@ static char *_get_preview_image_path(const char *widget_id, int width,
ret = sqlite3_step(stmt);
if (ret != SQLITE_ROW) {
- _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);
+ if (ret == SQLITE_DONE) {
+ set_last_result(WIDGET_ERROR_NOT_EXIST);
+ LOGW("No data for uid (%d)", uid);
+ } else {
+ set_last_result(WIDGET_ERROR_FAULT);
+ _E("step error: %s", sqlite3_errmsg(db));
+ }
return NULL;
}
@@ -1326,7 +1402,8 @@ EAPI char *widget_service_get_preview_image_path(const char *widget_id,
_convert_type_to_support_size_ratio(size_type, &w, &h);
path = _get_preview_image_path(widget_id, w, h, getuid());
- if (path == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST)
+ if (path == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST
+ && !_is_global(getuid()))
path = _get_preview_image_path(widget_id, w, h, GLOBALAPP_USER);
if (path == NULL) {
@@ -1400,7 +1477,8 @@ static char *_get_main_widget_id(const char *pkg_id, uid_t uid)
ret = sqlite3_step(stmt);
if (ret != SQLITE_ROW) {
if (ret == SQLITE_DONE)
- _E("cannot find widget_id for pkg_id %s", pkg_id);
+ LOGW("cannot find widget_id for pkg_id %s, uid(%d)"
+ , pkg_id, uid);
else
_E("step error: %s", sqlite3_errmsg(db));
sqlite3_finalize(stmt);
@@ -1457,7 +1535,8 @@ static char *_get_icon(const char *widget_id, const char *lang, uid_t uid)
ret = sqlite3_step(stmt);
if (ret != SQLITE_ROW) {
if (ret == SQLITE_DONE)
- _E("cannot find icon for widget %s", widget_id);
+ LOGW("cannot find icon for widget_id %s, uid(%d)"
+ , widget_id, uid);
else
_E("step error: %s", sqlite3_errmsg(db));
sqlite3_finalize(stmt);
@@ -1501,11 +1580,13 @@ EAPI char *widget_service_get_icon(const char *pkgid, const char *lang)
}
widget_id = _get_main_widget_id(pkgid, getuid());
- if (widget_id == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST)
+ if (widget_id == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST
+ && !_is_global(getuid()))
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)
+ if (icon == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST
+ && !_is_global(getuid()))
icon = _get_icon(widget_id, lang, GLOBALAPP_USER);
return icon;
@@ -1547,7 +1628,8 @@ static char *_get_name(const char *widget_id, const char *lang, uid_t uid)
ret = sqlite3_step(stmt);
if (ret != SQLITE_ROW) {
if (ret == SQLITE_DONE)
- _E("cannot find label for widget %s", widget_id);
+ LOGW("cannot find label for widget_id %s, uid(%d)"
+ , widget_id, uid);
else
_E("step error: %s", sqlite3_errmsg(db));
_E("step error: %s", sqlite3_errmsg(db));
@@ -1630,7 +1712,8 @@ EAPI char *widget_service_get_name(const char *widget_id, const char *lang)
}
name = _get_name(widget_id, language, getuid());
- if (name == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST)
+ if (name == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST
+ && !_is_global(getuid()))
name = _get_name(widget_id, language, GLOBALAPP_USER);
free(language);
@@ -1657,7 +1740,8 @@ EAPI int widget_service_get_supported_sizes(const char *widget_id, int *cnt,
return WIDGET_ERROR_PERMISSION_DENIED;
ret = _get_widget_supported_sizes(widget_id, getuid(), cnt, w, h);
- if (ret == WIDGET_ERROR_NOT_EXIST)
+ if (ret == WIDGET_ERROR_NOT_EXIST
+ && !_is_global(getuid()))
ret = _get_widget_supported_sizes(widget_id, GLOBALAPP_USER,
cnt, w, h);
@@ -1759,7 +1843,8 @@ static char *__get_widget_main_appid_from_pkgid_or_appid(const char *id)
}
ret = _get_widget_list(id, getuid(), &widget_list);
- if (ret != WIDGET_ERROR_NONE || widget_list == NULL)
+ if ((ret != WIDGET_ERROR_NONE || widget_list == NULL)
+ && !_is_global(getuid()))
ret = _get_widget_list(id, GLOBALAPP_USER, &widget_list);
if (widget_list == NULL)
@@ -1817,7 +1902,8 @@ EAPI char *widget_service_get_widget_id(const char *appid)
}
classid = _get_widget_id(appid, getuid());
- if (classid == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST)
+ if (classid == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST
+ && !_is_global(getuid()))
classid = _get_widget_id(appid, GLOBALAPP_USER);
if (classid)
@@ -1832,7 +1918,8 @@ EAPI char *widget_service_get_widget_id(const char *appid)
}
classid = _get_widget_id(widget_id, getuid());
- if (classid == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST)
+ if (classid == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST
+ && !_is_global(getuid()))
classid = _get_widget_id(widget_id, GLOBALAPP_USER);
free(widget_id);
@@ -1869,12 +1956,16 @@ static char *_get_package_id(const char *widget_id, uid_t uid)
ret = sqlite3_step(stmt);
if (ret != SQLITE_ROW) {
- _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);
+ if (ret == SQLITE_DONE) {
+ set_last_result(WIDGET_ERROR_NOT_EXIST);
+ LOGW("No data for uid (%d)", uid);
+ } else {
+ set_last_result(WIDGET_ERROR_FAULT);
+ _E("step error: %s", sqlite3_errmsg(db));
+ }
return NULL;
}
@@ -1910,7 +2001,8 @@ EAPI char *widget_service_get_package_id(const char *widget_id)
}
pkgid = _get_package_id(widget_id, getuid());
- if (pkgid == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST)
+ if (pkgid == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST
+ && !_is_global(getuid()))
pkgid = _get_package_id(widget_id, GLOBALAPP_USER);
return pkgid;
@@ -2178,13 +2270,15 @@ static int __get_max_instance(const char *widget_id, uid_t uid)
ret = sqlite3_step(stmt);
if (ret != SQLITE_ROW) {
- _E("step error: %s", sqlite3_errmsg(db));
sqlite3_finalize(stmt);
sqlite3_close_v2(db);
- if (ret == SQLITE_DONE)
+ if (ret == SQLITE_DONE) {
+ LOGW("No data for uid (%d)", uid);
return WIDGET_ERROR_NOT_EXIST;
-
- return WIDGET_ERROR_FAULT;
+ } else {
+ _E("step error: %s", sqlite3_errmsg(db));
+ return WIDGET_ERROR_FAULT;
+ }
}
_get_column_int(stmt, 0, &max_instance);
@@ -2214,7 +2308,7 @@ EAPI int widget_service_get_widget_max_count(const char *widget_id)
return WIDGET_ERROR_PERMISSION_DENIED;
ret = __get_max_instance(widget_id, getuid());
- if (ret == WIDGET_ERROR_NOT_EXIST)
+ if (ret == WIDGET_ERROR_NOT_EXIST && !_is_global(getuid()))
ret = __get_max_instance(widget_id, GLOBALAPP_USER);
return ret;