summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSung-jae Park <nicesj.park@samsung.com>2013-02-06 14:09:42 (GMT)
committerSung-jae Park <nicesj.park@samsung.com>2013-02-06 14:09:42 (GMT)
commita22422a5d310d5d56acb8b23e05d82cb1776cb65 (patch)
treef7dbf7050530a5ffb626a099884098dab58f1db8
parent69bbc929ae7a56fbd3e1fd19d2a3b9ccc03e8f76 (diff)
downloaddata-provider-master-a22422a5d310d5d56acb8b23e05d82cb1776cb65.zip
data-provider-master-a22422a5d310d5d56acb8b23e05d82cb1776cb65.tar.gz
data-provider-master-a22422a5d310d5d56acb8b23e05d82cb1776cb65.tar.bz2
Separte gem & pixmap create function.
Script updated. (for image, group is changed to optoin) Add the update request interface Change-Id: I9102fabe40b055df41b170e31dc83a858e10a7b1
-rw-r--r--packaging/org.tizen.data-provider-master.spec2
-rw-r--r--src/buffer_handler.c129
-rw-r--r--src/script_handler.c58
-rw-r--r--src/server.c42
-rw-r--r--src/util.c24
-rw-r--r--util_liveinfo/src/liveinfo.c27
6 files changed, 192 insertions, 90 deletions
diff --git a/packaging/org.tizen.data-provider-master.spec b/packaging/org.tizen.data-provider-master.spec
index 07b6aff..2e9f58b 100644
--- a/packaging/org.tizen.data-provider-master.spec
+++ b/packaging/org.tizen.data-provider-master.spec
@@ -1,6 +1,6 @@
Name: org.tizen.data-provider-master
Summary: Master service provider for liveboxes.
-Version: 0.15.12
+Version: 0.16.0
Release: 1
Group: framework/livebox
License: Flora License
diff --git a/src/buffer_handler.c b/src/buffer_handler.c
index 0df7254..670497c 100644
--- a/src/buffer_handler.c
+++ b/src/buffer_handler.c
@@ -164,11 +164,18 @@ HAPI struct buffer_info *buffer_handler_create(struct inst_info *inst, enum buff
return info;
}
-static inline struct buffer *create_gem(Display *disp, Window parent, struct buffer_info *info)
+static inline struct buffer *create_pixmap(struct buffer_info *info)
{
struct gem_data *gem;
struct buffer *buffer;
+ Display *disp;
+ Window parent;
+
+ disp = ecore_x_display_get();
+ if (!disp)
+ return NULL;
+ parent = DefaultRootWindow(disp);
buffer = calloc(1, sizeof(*buffer) + sizeof(*gem));
if (!buffer) {
@@ -204,37 +211,31 @@ static inline struct buffer *create_gem(Display *disp, Window parent, struct buf
XSync(disp, False);
DbgPrint("Pixmap:0x%X is created\n", gem->pixmap);
+ return buffer;
+}
- if (info->inst) {
- struct pkg_info *pkg;
+static inline int create_gem(struct buffer *buffer)
+{
+ struct gem_data *gem;
+ Display *disp;
- if (instance_lb_buffer(info->inst) == info) {
- pkg = instance_package(info->inst);
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- DbgPrint("Doesn't need to create gem for LB\n");
- return buffer;
- }
- } else if (instance_pd_buffer(info->inst) == info) {
- pkg = instance_package(info->inst);
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- DbgPrint("Doesn't need to create gem for PD\n");
- return buffer;
- }
- }
+ disp = ecore_x_display_get();
+ if (!disp) {
+ ErrPrint("Failed to get display\n");
+ return -EIO;
}
+ gem = (struct gem_data *)buffer->data;
+
if (s_info.fd < 0) {
gem->data = calloc(1, gem->w * gem->h * gem->depth);
if (!gem->data) {
ErrPrint("Heap: %s\n", strerror(errno));
- XFreePixmap(disp, gem->pixmap);
- buffer->state = DESTROYED;
- DbgFree(buffer);
- return NULL;
+ return -ENOMEM;
}
DbgPrint("DRI2(gem) is not supported - Fallback to the S/W Backend\n");
- return buffer;
+ return 0;
}
DRI2CreateDrawable(disp, gem->pixmap);
@@ -243,15 +244,12 @@ static inline struct buffer *create_gem(Display *disp, Window parent, struct buf
gem->dri2_buffer = DRI2GetBuffers(disp, gem->pixmap,
&gem->w, &gem->h, gem->attachments, gem->count, &gem->buf_count);
if (!gem->dri2_buffer || !gem->dri2_buffer->name) {
- ErrPrint("Failed to get GemBuffer\n");
+ ErrPrint("Failed to get a gem buffer\n");
DRI2DestroyDrawable(disp, gem->pixmap);
- XFreePixmap(disp, gem->pixmap);
- buffer->state = DESTROYED;
- DbgFree(buffer);
- return NULL;
+ return -EFAULT;
}
- DbgPrint("dri2_buffer: %p, name: %p, %dx%d (%dx%d)\n",
- gem->dri2_buffer, gem->dri2_buffer->name, gem->w, gem->h, info->w, info->h);
+ DbgPrint("dri2_buffer: %p, name: %p, %dx%d\n",
+ gem->dri2_buffer, gem->dri2_buffer->name, gem->w, gem->h);
DbgPrint("dri2_buffer->pitch : %d, buf_count: %d\n",
gem->dri2_buffer->pitch, gem->buf_count);
@@ -260,12 +258,9 @@ static inline struct buffer *create_gem(Display *disp, Window parent, struct buf
*/
gem->pixmap_bo = drm_slp_bo_import(s_info.slp_bufmgr, gem->dri2_buffer->name);
if (!gem->pixmap_bo) {
- DRI2DestroyDrawable(disp, gem->pixmap);
- XFreePixmap(disp, gem->pixmap);
ErrPrint("Failed to import BO\n");
- buffer->state = DESTROYED;
- DbgFree(buffer);
- return NULL;
+ DRI2DestroyDrawable(disp, gem->pixmap);
+ return -EFAULT;
}
if (gem->dri2_buffer->pitch != gem->w * gem->depth) {
@@ -279,8 +274,7 @@ static inline struct buffer *create_gem(Display *disp, Window parent, struct buf
}
}
- DbgPrint("Return buffer: %p\n", buffer);
- return buffer;
+ return 0;
}
static inline void *acquire_gem(struct buffer *buffer)
@@ -376,6 +370,28 @@ static inline void release_gem(struct buffer *buffer)
}
}
+static inline int destroy_pixmap(struct buffer *buffer)
+{
+ struct gem_data *gem;
+
+ gem = (struct gem_data *)buffer->data;
+
+ if (gem->pixmap) {
+ Display *disp;
+
+ disp = ecore_x_display_get();
+ if (!disp)
+ return -EIO;
+
+ DbgPrint("Free pixmap 0x%X\n", gem->pixmap);
+ XFreePixmap(disp, gem->pixmap);
+ }
+
+ buffer->state = DESTROYED;
+ DbgFree(buffer);
+ return 0;
+}
+
static inline int destroy_gem(struct buffer *buffer)
{
struct gem_data *gem;
@@ -411,11 +427,6 @@ static inline int destroy_gem(struct buffer *buffer)
gem->data = NULL;
}
- DbgPrint("Free pixmap 0x%X\n", gem->pixmap);
- XFreePixmap(ecore_x_display_get(), gem->pixmap);
-
- buffer->state = DESTROYED;
- DbgFree(buffer);
return 0;
}
@@ -874,19 +885,37 @@ HAPI void *buffer_handler_pixmap_ref(struct buffer_info *info)
buffer = info->buffer;
if (!buffer) {
- Display *disp;
- Window root;
+ int need_gem = 1;
- disp = ecore_x_display_get();
- root = DefaultRootWindow(disp);
-
- buffer = create_gem(disp, root, info);
+ buffer = create_pixmap(info);
if (!buffer) {
- DbgPrint("No GEM initialization\n");
+ DbgPrint("Failed to create a pixmap\n");
return NULL;
}
info->buffer = buffer;
+
+ if (info->inst) {
+ struct pkg_info *pkg;
+
+ if (instance_lb_buffer(info->inst) == info) {
+ pkg = instance_package(info->inst);
+ if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ DbgPrint("Doesn't need to create gem for LB\n");
+ need_gem = 0;
+ }
+ } else if (instance_pd_buffer(info->inst) == info) {
+ pkg = instance_package(info->inst);
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ DbgPrint("Doesn't need to create gem for PD\n");
+ need_gem = 0;
+ }
+ }
+ }
+
+ if (need_gem)
+ create_gem(buffer);
+
} else if (buffer->state != CREATED || buffer->type != BUFFER_TYPE_PIXMAP) {
ErrPrint("Invalid buffer\n");
return NULL;
@@ -977,7 +1006,11 @@ HAPI int buffer_handler_pixmap_unref(void *buffer_ptr)
s_info.pixmap_list = eina_list_remove(s_info.pixmap_list, buffer);
- destroy_gem(buffer);
+ if (destroy_gem(buffer) < 0)
+ ErrPrint("Failed to destroy gem buffer\n");
+
+ if (destroy_pixmap(buffer) < 0)
+ ErrPrint("Failed to destroy pixmap\n");
info = buffer->info;
if (info && info->buffer == buffer)
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;
}
diff --git a/util_liveinfo/src/liveinfo.c b/util_liveinfo/src/liveinfo.c
index 7506620..e7dbe1a 100644
--- a/util_liveinfo/src/liveinfo.c
+++ b/util_liveinfo/src/liveinfo.c
@@ -497,7 +497,7 @@ static inline struct node *update_target_dir(const char *cmd)
struct node *node;
node = (*cmd == '/') ? s_info.rootdir : s_info.curdir;
- node = node_find(s_info.targetdir, cmd);
+ node = node_find(node, cmd);
return node;
}
@@ -677,16 +677,21 @@ static inline void do_command(const char *cmd)
if (strlen(cmd) && *cmd != '#') {
if (!strncasecmp(cmd, "exit", 4) || !strncasecmp(cmd, "quit", 4)) {
ecore_main_loop_quit();
- } else if (!strncasecmp(cmd, "set ", 4) && do_set(cmd) == 0) {
- return;
- } else if (!strncasecmp(cmd, "get ", 4) && do_get(cmd) == 0) {
- return;
- } else if (!strncasecmp(cmd, "ls", 2) && do_ls(cmd) == 0) {
- return;
- } else if (!strncasecmp(cmd, "cd", 2) && do_cd(cmd) == 0) {
- return;
- } else if (!strncasecmp(cmd, "rm", 2) && do_rm(cmd) == 0) {
- return;
+ } else if (!strncasecmp(cmd, "set ", 4)) {
+ if (do_set(cmd) == 0)
+ return;
+ } else if (!strncasecmp(cmd, "get ", 4)) {
+ if (do_get(cmd) == 0)
+ return;
+ } else if (!strncasecmp(cmd, "ls", 2)) {
+ if (do_ls(cmd) == 0)
+ return;
+ } else if (!strncasecmp(cmd, "cd", 2)) {
+ if (do_cd(cmd) == 0)
+ return;
+ } else if (!strncasecmp(cmd, "rm", 2)) {
+ if (do_rm(cmd) == 0)
+ return;
} else {
help();
}