From 4c2a57208423df96050169bd96e66176bf6bd89f Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Wed, 6 Feb 2013 14:00:13 +0000 Subject: [PATCH] Add new interface for updating box. script updated script parser is updated. use the "option" instead of the "group". New interface is added for updating a livebox individually. Change-Id: Ic7c6cf67cf9ba1463680f40424270b2983738ddb --- packaging/com.samsung.data-provider-master.spec | 2 +- src/script_handler.c | 58 ++++++++++++------------- src/server.c | 42 ++++++++++++++++++ src/util.c | 24 +++++++++- 4 files changed, 95 insertions(+), 31 deletions(-) diff --git a/packaging/com.samsung.data-provider-master.spec b/packaging/com.samsung.data-provider-master.spec index 9eb752c..bf8804b 100644 --- a/packaging/com.samsung.data-provider-master.spec +++ b/packaging/com.samsung.data-provider-master.spec @@ -1,6 +1,6 @@ Name: com.samsung.data-provider-master Summary: Master service provider for liveboxes. -Version: 0.15.13 +Version: 0.16.0 Release: 1 Group: framework/livebox License: Flora License diff --git a/src/script_handler.c b/src/script_handler.c index 024432d..6e74ae0 100644 --- a/src/script_handler.c +++ b/src/script_handler.c @@ -69,14 +69,14 @@ struct script_port { const char *(*magic_id)(void); int (*update_color)(void *handle, Evas *e, const char *id, const char *part, const char *rgba); int (*update_text)(void *handle, Evas *e, const char *id, const char *part, const char *text); - int (*update_image)(void *handle, Evas *e, const char *id, const char *part, const char *path); - int (*update_script)(void *handle, Evas *e, const char *src_id, const char *target_id, const char *part, const char *path, const char *group); + int (*update_image)(void *handle, Evas *e, const char *id, const char *part, const char *path, const char *option); + int (*update_script)(void *handle, Evas *e, const char *src_id, const char *target_id, const char *part, const char *path, const char *option); int (*update_signal)(void *handle, Evas *e, const char *id, const char *part, const char *signal); int (*update_drag)(void *handle, Evas *e, const char *id, const char *part, double x, double y); int (*update_size)(void *handle, Evas *e, const char *id, int w, int h); int (*update_category)(void *handle, Evas *e, const char *id, const char *category); - void *(*create)(const char *file, const char *group); + void *(*create)(const char *file, const char *option); int (*destroy)(void *handle); int (*load)(void *handle, Evas *e, int w, int h); @@ -99,8 +99,8 @@ struct block { char *file; int file_len; - char *group; - int group_len; + char *option; + int option_len; char *id; int id_len; @@ -317,11 +317,11 @@ HAPI int script_handler_unload(struct script_info *info, int is_pd) return 0; } -HAPI struct script_info *script_handler_create(struct inst_info *inst, const char *file, const char *group, int w, int h) +HAPI struct script_info *script_handler_create(struct inst_info *inst, const char *file, const char *option, int w, int h) { struct script_info *info; - DbgPrint("Create script: %s (%s)\n", file, group); + DbgPrint("Create script: %s (%s)\n", file, option); if (!file) return NULL; @@ -353,9 +353,9 @@ HAPI struct script_info *script_handler_create(struct inst_info *inst, const cha info->w = w; info->h = h; - info->port_data = info->port->create(file, group); + info->port_data = info->port->create(file, option); if (!info->port_data) { - ErrPrint("Failed to create a port (%s - %s)\n", file, group); + ErrPrint("Failed to create a port (%s - %s)\n", file, option); fb_destroy(info->fb); DbgFree(info); return NULL; @@ -487,7 +487,7 @@ static int update_script_image(struct inst_info *inst, struct block *block, int e = script_handler_evas(info); if (e) - info->port->update_image(info->port_data, e, block->id, block->part, block->data); + info->port->update_image(info->port_data, e, block->id, block->part, block->data, block->option); else ErrPrint("Evas: (nil) id[%s] part[%s] data[%s]\n", block->id, block->part, block->data); return 0; @@ -516,10 +516,10 @@ static int update_script_script(struct inst_info *inst, struct block *block, int e = script_handler_evas(info); if (e) - info->port->update_script(info->port_data, e, block->id, block->target_id, block->part, block->data, block->group); + info->port->update_script(info->port_data, e, block->id, block->target_id, block->part, block->data, block->option); else - ErrPrint("Evas: (nil) id[%s] part[%s] data[%s] group[%s]\n", - block->id, block->part, block->data, block->group); + ErrPrint("Evas: (nil) id[%s] part[%s] data[%s] option[%s]\n", + block->id, block->part, block->data, block->option); return 0; } @@ -684,7 +684,7 @@ HAPI int script_handler_parse_desc(const char *pkgname, const char *id, const ch VALUE_PART = 0x01, VALUE_DATA = 0x02, VALUE_FILE = 0x03, - VALUE_GROUP = 0x04, + VALUE_OPTION = 0x04, VALUE_ID = 0x05, VALUE_TARGET = 0x06, }; @@ -693,7 +693,7 @@ HAPI int script_handler_parse_desc(const char *pkgname, const char *id, const ch "part", "data", "file", - "group", + "option", "id", "target", NULL @@ -852,11 +852,11 @@ HAPI int script_handler_parse_desc(const char *pkgname, const char *id, const ch idx = 0; break; case 4: - state = VALUE_GROUP; - if (block->group) { - DbgFree(block->group); - block->group = NULL; - block->group_len = 0; + state = VALUE_OPTION; + if (block->option) { + DbgFree(block->option); + block->option = NULL; + block->option_len = 0; } idx = 0; break; @@ -1006,27 +1006,27 @@ HAPI int script_handler_parse_desc(const char *pkgname, const char *id, const ch idx++; break; - case VALUE_GROUP: - if (idx == block->group_len) { + case VALUE_OPTION: + if (idx == block->option_len) { char *tmp; - block->group_len += ADDEND; - tmp = realloc(block->group, block->group_len); + block->option_len += ADDEND; + tmp = realloc(block->option, block->option_len); if (!tmp) { ErrPrint("Heap: %s\n", strerror(errno)); goto errout; } - block->group = tmp; + block->option = tmp; } if (ch == '\n') { - block->group[idx] = '\0'; + block->option[idx] = '\0'; state = FIELD; idx = 0; field_idx = 0; break; } - block->group[idx] = ch; + block->option[idx] = ch; idx++; break; case VALUE_ID: @@ -1100,7 +1100,7 @@ HAPI int script_handler_parse_desc(const char *pkgname, const char *id, const ch DbgFree(block->type); DbgFree(block->part); DbgFree(block->data); - DbgFree(block->group); + DbgFree(block->option); DbgFree(block->id); DbgFree(block->target_id); DbgFree(block); @@ -1129,7 +1129,7 @@ errout: DbgFree(block->type); DbgFree(block->part); DbgFree(block->data); - DbgFree(block->group); + DbgFree(block->option); DbgFree(block->id); DbgFree(block->target_id); DbgFree(block); diff --git a/src/server.c b/src/server.c index 0b9be5b..75f4e18 100644 --- a/src/server.c +++ b/src/server.c @@ -3778,6 +3778,44 @@ static inline int update_pkg_cb(struct category *category, const char *pkgname) return EXIT_SUCCESS; } +static struct packet *client_update(pid_t pid, int handle, const struct packet *packet) +{ + struct inst_info *inst; + struct client_node *client; + const char *pkgname; + const char *id; + int ret; + + client = client_find_by_pid(pid); + if (!client) { + ErrPrint("Cilent %d is not exists\n", pid); + ret = -ENOMEM; + goto out; + } + + ret = packet_get(packet, "ss", &pkgname, &id); + if (ret != 2) { + ErrPrint("Invalid argument\n"); + ret = -EINVAL; + goto out; + } + + inst = package_find_instance_by_id(pkgname, id); + if (!inst) { + ret = -ENOENT; + } else if (package_is_fault(instance_package(inst))) { + ret = -EFAULT; + } else if (instance_client(inst) != client) { + ret = -EPERM; + } else { + slave_rpc_request_update(pkgname, id, instance_cluster(inst), instance_category(inst)); + } + +out: + /*! \note No reply packet */ + return NULL; +} + static struct packet *client_refresh_group(pid_t pid, int handle, const struct packet *packet) { const char *cluster_id; @@ -5119,6 +5157,10 @@ static struct method s_client_table[] = { .cmd = "refresh_group", .handler = client_refresh_group, }, + { + .cmd = "update", + .handler = client_update, + }, { .cmd = "pd_access_read", diff --git a/src/util.c b/src/util.c index 690df7e..3fe64c3 100644 --- a/src/util.c +++ b/src/util.c @@ -286,6 +286,7 @@ HAPI char *util_replace_string(const char *src, const char *pattern, const char DbgFree(ret); return NULL; } + ret = tmp; } } @@ -312,12 +313,33 @@ HAPI char *util_replace_string(const char *src, const char *pattern, const char ret = tmp; } } - if (matched) { + + if (matched || !pattern[pattern_idx]) { + if (target_idx > 0) { + while (replace[target_idx]) { + if (ret_idx >= bufsz) { + char *tmp; + tmp = extend_heap(ret, &bufsz, incsz); + if (!tmp) { + ErrPrint("Heap: %s\n", strerror(errno)); + DbgFree(ret); + return NULL; + } + + ret = tmp; + } + + ret[ret_idx] = replace[target_idx]; + ret_idx++; + target_idx++; + } + } ret[ret_idx] = '\0'; } else { DbgFree(ret); ret = NULL; } + return ret; } -- 2.7.4