diff options
author | Junghoon Park <jh9216.park@samsung.com> | 2017-07-19 14:16:15 +0900 |
---|---|---|
committer | Junghoon Park <jh9216.park@samsung.com> | 2017-07-19 05:22:45 +0000 |
commit | f7a1e2d314e1d31104d0f51a6bb92656464cf805 (patch) | |
tree | 735c283fbc85a95a479db72faa9da222691fa896 | |
parent | dccc81299a8f8af5f03efd0806064917ecd8019b (diff) | |
download | widget-service-f7a1e2d314e1d31104d0f51a6bb92656464cf805.tar.gz widget-service-f7a1e2d314e1d31104d0f51a6bb92656464cf805.tar.bz2 widget-service-f7a1e2d314e1d31104d0f51a6bb92656464cf805.zip |
Add period value into bundle
- When an instance is launched, the update-period value should be sent to provider
to set the periodic timer
Change-Id: Ic4110b60fec1d3ff604a03fb359d8d0c037f9296
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
-rw-r--r-- | src/widget_instance.c | 10 | ||||
-rw-r--r-- | src/widget_service.c | 55 |
2 files changed, 65 insertions, 0 deletions
diff --git a/src/widget_instance.c b/src/widget_instance.c index cefdd6b..4b321ef 100644 --- a/src/widget_instance.c +++ b/src/widget_instance.c @@ -116,6 +116,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; @@ -199,6 +201,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) { @@ -213,6 +221,7 @@ 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; _widget_instances = g_list_append(_widget_instances, instance); @@ -446,6 +455,7 @@ EAPI int widget_instance_launch(const char *instance_id, char *content_info, int bundle_add_str(b, AUL_K_WAYLAND_DISPLAY, wayland_display); bundle_add_str(b, AUL_K_WAYLAND_WORKING_DIR, xdg_runtime_dir); 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); diff --git a/src/widget_service.c b/src/widget_service.c index 2ebf6df..322ef40 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 */ @@ -1104,6 +1109,56 @@ 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) { + _E("step error: %s", sqlite3_errmsg(db)); + sqlite3_finalize(stmt); + sqlite3_close_v2(db); + if (ret == SQLITE_DONE) + return WIDGET_ERROR_NOT_EXIST; + + 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; |