summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSung-jae Park <nicesj.park@samsung.com>2013-08-13 10:43:22 +0900
committerSung-jae Park <nicesj.park@samsung.com>2013-08-13 10:47:42 +0900
commit2ceaa0aeb0e91eb985ba5a992a3efa96654b9ede (patch)
tree271891ea09bff807fdc8079342bd1699b2728952
parent12933ab4c3956e76dd9a13e192dda254e4802103 (diff)
downloadprovider-2ceaa0aeb0e91eb985ba5a992a3efa96654b9ede.tar.gz
provider-2ceaa0aeb0e91eb985ba5a992a3efa96654b9ede.tar.bz2
provider-2ceaa0aeb0e91eb985ba5a992a3efa96654b9ede.zip
Update coding convention - Send XDamage if gem buffer is updated.
Send the XDamage event if the GEM buffer is updated. Change-Id: I856de4f20fd5181184082d32a282aa993feae9ca
-rw-r--r--include/fb.h1
-rw-r--r--packaging/libprovider.spec8
-rw-r--r--src/dlist.c29
-rw-r--r--src/fb.c99
-rw-r--r--src/provider.c163
-rw-r--r--src/provider_buffer.c108
-rw-r--r--src/util.c6
7 files changed, 286 insertions, 128 deletions
diff --git a/include/fb.h b/include/fb.h
index adc3efa..7d7c203 100644
--- a/include/fb.h
+++ b/include/fb.h
@@ -37,5 +37,6 @@ extern int fb_destroy_gem(struct fb_info *info);
extern void *fb_acquire_gem(struct fb_info *info);
extern int fb_release_gem(struct fb_info *info);
extern int fb_has_gem(struct fb_info *info);
+extern int fb_sync_xdamage(struct fb_info *info);
/* End of a file */
diff --git a/packaging/libprovider.spec b/packaging/libprovider.spec
index 631084c..fbce36f 100644
--- a/packaging/libprovider.spec
+++ b/packaging/libprovider.spec
@@ -1,6 +1,6 @@
Name: libprovider
Summary: Library for developing the livebox service provider.
-Version: 0.9.6
+Version: 0.9.8
Release: 1
Group: HomeTF/Livebox
License: Flora License
@@ -37,6 +37,12 @@ Livebox data provider development library (dev)
%setup -q
%build
+%if 0%{?tizen_build_binary_release_type_eng}
+export CFLAGS="${CFLAGS} -DTIZEN_ENGINEER_MODE"
+export CXXFLAGS="${CXXFLAGS} -DTIZEN_ENGINEER_MODE"
+export FFLAGS="${FFLAGS} -DTIZEN_ENGINEER_MODE"
+%endif
+
%cmake .
make %{?jobs:-j%jobs}
diff --git a/src/dlist.c b/src/dlist.c
index fa3082a..3ae571b 100644
--- a/src/dlist.c
+++ b/src/dlist.c
@@ -45,8 +45,9 @@ struct dlist *dlist_append(struct dlist *list, void *data)
struct dlist *item;
item = malloc(sizeof(*item));
- if (!item)
+ if (!item) {
return NULL;
+ }
item->next = NULL;
item->data = data;
@@ -71,8 +72,9 @@ struct dlist *dlist_prepend(struct dlist *list, void *data)
struct dlist *item;
item = malloc(sizeof(*item));
- if (!item)
+ if (!item) {
return NULL;
+ }
item->data = data;
@@ -80,8 +82,9 @@ struct dlist *dlist_prepend(struct dlist *list, void *data)
item->prev = item;
item->next = NULL;
} else {
- if (list->prev->next)
+ if (list->prev->next) {
list->prev->next = item;
+ }
item->prev = list->prev;
item->next = list;
@@ -95,16 +98,19 @@ struct dlist *dlist_prepend(struct dlist *list, void *data)
struct dlist *dlist_remove(struct dlist *list, struct dlist *l)
{
- if (!list || !l)
+ if (!list || !l) {
return NULL;
+ }
- if (l == list)
+ if (l == list) {
list = l->next;
- else
+ } else {
l->prev->next = l->next;
+ }
- if (l->next)
+ if (l->next) {
l->next->prev = l->prev;
+ }
/*!
* \note
* If the removed entry 'l' has no next element, it is the last element.
@@ -113,8 +119,9 @@ struct dlist *dlist_remove(struct dlist *list, struct dlist *l)
*
* If we didn't care about this, the head element(list) can indicates the invalid element.
*/
- else if (list)
+ else if (list) {
list->prev = l->prev;
+ }
free(l);
return list;
@@ -126,8 +133,9 @@ struct dlist *dlist_find_data(struct dlist *list, void *data)
void *_data;
dlist_foreach(list, l, _data) {
- if (data == _data)
+ if (data == _data) {
return l;
+ }
}
return NULL;
@@ -169,8 +177,9 @@ struct dlist *dlist_nth(struct dlist *l, int nth)
i = 0;
for (n = l; n; n = n->next) {
- if (i == nth)
+ if (i == nth) {
return n;
+ }
i++;
}
diff --git a/src/fb.c b/src/fb.c
index 9b49bfb..a1b3036 100644
--- a/src/fb.c
+++ b/src/fb.c
@@ -187,7 +187,9 @@ int fb_init(void *disp)
DbgPrint("DRM Magic: 0x%X\n", magic);
if (!DRI2Authenticate(s_info.disp, DefaultRootWindow(s_info.disp), (unsigned int)magic)) {
ErrPrint("Failed to do authenticate for DRI2\n");
- close(s_info.fd);
+ if (close(s_info.fd) < 0) {
+ ErrPrint("close: %s\n", strerror(errno));
+ }
s_info.fd = -1;
s_info.evt_base = 0;
s_info.err_base = 0;
@@ -197,7 +199,9 @@ int fb_init(void *disp)
s_info.bufmgr = tbm_bufmgr_init(s_info.fd);
if (!s_info.bufmgr) {
ErrPrint("Failed to init bufmgr\n");
- close(s_info.fd);
+ if (close(s_info.fd) < 0) {
+ ErrPrint("close: %s\n", strerror(errno));
+ }
s_info.fd = -1;
s_info.evt_base = 0;
s_info.err_base = 0;
@@ -210,7 +214,9 @@ int fb_init(void *disp)
int fb_fini(void)
{
if (s_info.fd >= 0) {
- close(s_info.fd);
+ if (close(s_info.fd) < 0) {
+ ErrPrint("close: %s\n", strerror(errno));
+ }
s_info.fd = -1;
}
@@ -259,11 +265,15 @@ static inline int sync_for_file(struct fb_info *info)
if (write(fd, buffer->data, info->bufsz) != info->bufsz) {
ErrPrint("write: %s\n", strerror(errno));
- close(fd);
+ if (close(fd) < 0) {
+ ErrPrint("close: %s\n", strerror(errno));
+ }
return LB_STATUS_ERROR_IO;
}
- close(fd);
+ if (close(fd) < 0) {
+ ErrPrint("close: %s\n", strerror(errno));
+ }
return LB_STATUS_SUCCESS;
}
@@ -364,8 +374,9 @@ static inline struct fb_info *find_shm_by_canvas(void *canvas)
}
pixmap_info = (struct pixmap_info *)buffer->data;
- if (pixmap_info->si.shmaddr == canvas)
+ if (pixmap_info->si.shmaddr == canvas) {
break;
+ }
info = NULL;
}
@@ -380,8 +391,9 @@ static inline struct gem_data *find_gem_by_pixmap(Pixmap id)
gem = NULL;
dlist_foreach(s_info.gem_list, l, gem) {
- if (gem->pixmap == id)
+ if (gem->pixmap == id) {
break;
+ }
gem = NULL;
}
@@ -396,8 +408,9 @@ static inline struct gem_data *find_gem_by_canvas(void *canvas)
gem = NULL;
dlist_foreach(s_info.gem_list, l, gem) {
- if (gem->data == canvas || gem->compensate_data == canvas)
+ if (gem->data == canvas || gem->compensate_data == canvas) {
break;
+ }
gem = NULL;
}
@@ -422,8 +435,9 @@ static inline int create_pixmap_info(struct fb_info *info)
pixmap_info->si.readOnly = False;
pixmap_info->si.shmaddr = shmat(pixmap_info->si.shmid, NULL, 0);
if (pixmap_info->si.shmaddr == (void *)-1) {
- if (shmctl(pixmap_info->si.shmid, IPC_RMID, 0) < 0)
+ if (shmctl(pixmap_info->si.shmid, IPC_RMID, 0) < 0) {
ErrPrint("shmctl: %s\n", strerror(errno));
+ }
return LB_STATUS_ERROR_FAULT;
}
@@ -434,11 +448,13 @@ static inline int create_pixmap_info(struct fb_info *info)
*/
pixmap_info->xim = XShmCreateImage(s_info.disp, s_info.visual, (s_info.depth << 3), ZPixmap, NULL, &pixmap_info->si, info->w, info->h);
if (pixmap_info->xim == NULL) {
- if (shmdt(pixmap_info->si.shmaddr) < 0)
+ if (shmdt(pixmap_info->si.shmaddr) < 0) {
ErrPrint("shmdt: %s\n", strerror(errno));
+ }
- if (shmctl(pixmap_info->si.shmid, IPC_RMID, 0) < 0)
+ if (shmctl(pixmap_info->si.shmid, IPC_RMID, 0) < 0) {
ErrPrint("shmctl: %s\n", strerror(errno));
+ }
return LB_STATUS_ERROR_FAULT;
}
@@ -452,11 +468,13 @@ static inline int create_pixmap_info(struct fb_info *info)
XShmDetach(s_info.disp, &pixmap_info->si);
XDestroyImage(pixmap_info->xim);
- if (shmdt(pixmap_info->si.shmaddr) < 0)
+ if (shmdt(pixmap_info->si.shmaddr) < 0) {
ErrPrint("shmdt: %s\n", strerror(errno));
+ }
- if (shmctl(pixmap_info->si.shmid, IPC_RMID, 0) < 0)
+ if (shmctl(pixmap_info->si.shmid, IPC_RMID, 0) < 0) {
ErrPrint("shmctl: %s\n", strerror(errno));
+ }
return LB_STATUS_ERROR_FAULT;
}
@@ -478,11 +496,13 @@ static inline int destroy_pixmap_info(struct fb_info *info)
XShmDetach(s_info.disp, &pixmap_info->si);
XDestroyImage(pixmap_info->xim);
- if (shmdt(pixmap_info->si.shmaddr) < 0)
+ if (shmdt(pixmap_info->si.shmaddr) < 0) {
ErrPrint("shmdt: %s\n", strerror(errno));
+ }
- if (shmctl(pixmap_info->si.shmid, IPC_RMID, 0) < 0)
+ if (shmctl(pixmap_info->si.shmid, IPC_RMID, 0) < 0) {
ErrPrint("shmctl: %s\n", strerror(errno));
+ }
dlist_remove_data(s_info.shm_list, info);
DbgPrint("Destroy a pixmap info\n");
@@ -574,8 +594,9 @@ static inline void *acquire_gem(struct gem_data *gem)
tbm_bo_handle handle;
handle = tbm_bo_map(gem->pixmap_bo, TBM_DEVICE_CPU, TBM_OPTION_READ | TBM_OPTION_WRITE);
gem->data = handle.ptr;
- if (!gem->data)
+ if (!gem->data) {
ErrPrint("Failed to get BO\n");
+ }
}
gem->refcnt++;
@@ -749,8 +770,9 @@ void *fb_acquire_buffer(struct fb_info *info)
struct buffer *buffer;
void *addr;
- if (!info)
+ if (!info) {
return NULL;
+ }
if (!info->buffer) {
if (!strncasecmp(info->id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP))) {
@@ -832,14 +854,16 @@ int fb_release_buffer(void *data)
struct buffer *buffer;
struct fb_info *info;
- if (!data)
+ if (!data) {
return LB_STATUS_SUCCESS;
+ }
info = find_shm_by_canvas(data);
- if (info)
+ if (info) {
buffer = info->buffer;
- else
+ } else {
buffer = container_of(data, struct buffer, data);
+ }
if (buffer->state != CREATED) {
ErrPrint("Invalid handle\n");
@@ -853,16 +877,18 @@ int fb_release_buffer(void *data)
* SHM can not use the "info"
* it is NULL
*/
- if (shmdt(buffer) < 0)
+ if (shmdt(buffer) < 0) {
ErrPrint("shmdt: %s\n", strerror(errno));
+ }
break;
case BUFFER_TYPE_PIXMAP:
buffer->refcnt--;
if (buffer->refcnt == 0) {
if (info) {
destroy_pixmap_info(info);
- if (info->buffer == buffer)
+ if (info->buffer == buffer) {
info->buffer = NULL;
+ }
}
buffer->state = DESTROYED;
free(buffer);
@@ -877,8 +903,9 @@ int fb_release_buffer(void *data)
buffer->state = DESTROYED;
free(buffer);
- if (info && info->buffer == buffer)
+ if (info && info->buffer == buffer) {
info->buffer = NULL;
+ }
}
break;
default:
@@ -895,8 +922,9 @@ int fb_refcnt(void *data)
struct shmid_ds buf;
int ret;
- if (!data)
+ if (!data) {
return LB_STATUS_ERROR_INVALID;
+ }
buffer = container_of(data, struct buffer, data);
@@ -957,4 +985,27 @@ int fb_size(struct fb_info *info)
return info->bufsz;
}
+int fb_sync_xdamage(struct fb_info *info)
+{
+ XRectangle rect;
+ XserverRegion region;
+
+ if (!info || s_info.fd < 0) {
+ ErrPrint("Handle is not valid\n");
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = info->w;
+ rect.height = info->h;
+
+ region = XFixesCreateRegion(s_info.disp, &rect, 1);
+ XDamageAdd(s_info.disp, (Pixmap)info->handle, region);
+ XFixesDestroyRegion(s_info.disp, region);
+ XFlush(s_info.disp);
+
+ return LB_STATUS_SUCCESS;
+}
+
/* End of a file */
diff --git a/src/provider.c b/src/provider.c
index 53de73b..8275e92 100644
--- a/src/provider.c
+++ b/src/provider.c
@@ -74,8 +74,9 @@ static struct packet *master_script(pid_t pid, int handle, const struct packet *
arg.type = EVENT_CONTENT_EVENT;
- if (s_info.table.content_event)
+ if (s_info.table.content_event) {
(void)s_info.table.content_event(&arg, s_info.data);
+ }
errout:
return NULL;
@@ -99,8 +100,9 @@ static struct packet *master_clicked(pid_t pid, int handle, const struct packet
arg.type = EVENT_CLICKED;
- if (s_info.table.clicked)
+ if (s_info.table.clicked) {
(void)s_info.table.clicked(&arg, s_info.data);
+ }
errout:
return NULL;
@@ -128,8 +130,9 @@ static struct packet *master_text_signal(pid_t pid, int handle, const struct pac
arg.info.text_signal.info.pointer.down = 0;
arg.type = EVENT_TEXT_SIGNAL;
- if (s_info.table.text_signal)
+ if (s_info.table.text_signal) {
(void)s_info.table.text_signal(&arg, s_info.data);
+ }
errout:
return NULL;
@@ -151,10 +154,11 @@ static struct packet *master_delete(pid_t pid, int handle, const struct packet *
arg.type = EVENT_DELETE;
- if (s_info.table.lb_destroy)
+ if (s_info.table.lb_destroy) {
ret = s_info.table.lb_destroy(&arg, s_info.data);
- else
+ } else {
ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
+ }
errout:
result = packet_create_reply(packet, "i", ret);
@@ -177,10 +181,11 @@ static struct packet *master_resize(pid_t pid, int handle, const struct packet *
arg.type = EVENT_RESIZE;
- if (s_info.table.resize)
+ if (s_info.table.resize) {
ret = s_info.table.resize(&arg, s_info.data);
- else
+ } else {
ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
+ }
errout:
result = packet_create_reply(packet, "i", ret);
@@ -218,21 +223,24 @@ static struct packet *master_renew(pid_t pid, int handle, const struct packet *p
arg.type = EVENT_RENEW;
- if (s_info.table.lb_recreate)
+ if (s_info.table.lb_recreate) {
ret = s_info.table.lb_recreate(&arg, s_info.data);
- else
+ } else {
ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
+ }
errout:
- if (arg.info.lb_recreate.out_content)
+ if (arg.info.lb_recreate.out_content) {
content = arg.info.lb_recreate.out_content;
- else
+ } else {
content = "";
+ }
- if (arg.info.lb_recreate.out_title)
+ if (arg.info.lb_recreate.out_title) {
title = arg.info.lb_recreate.out_title;
- else
+ } else {
title = "";
+ }
result = packet_create_reply(packet, "issi", ret, content, title, arg.info.lb_recreate.out_is_pinned_up);
/*!
@@ -278,21 +286,24 @@ static struct packet *master_new(pid_t pid, int handle, const struct packet *pac
arg.type = EVENT_NEW;
- if (s_info.table.lb_create)
+ if (s_info.table.lb_create) {
ret = s_info.table.lb_create(&arg, &width, &height, &priority, s_info.data);
- else
+ } else {
ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
+ }
errout:
- if (arg.info.lb_create.out_content)
+ if (arg.info.lb_create.out_content) {
content = arg.info.lb_create.out_content;
- else
+ } else {
content = "";
+ }
- if (arg.info.lb_create.out_title)
+ if (arg.info.lb_create.out_title) {
title = arg.info.lb_create.out_title;
- else
+ } else {
title = "";
+ }
result = packet_create_reply(packet, "iiidssi", ret, width, height, priority, content, title, arg.info.lb_create.out_is_pinned_up);
@@ -321,10 +332,11 @@ static struct packet *master_set_period(pid_t pid, int handle, const struct pack
arg.type = EVENT_SET_PERIOD;
- if (s_info.table.set_period)
+ if (s_info.table.set_period) {
ret = s_info.table.set_period(&arg, s_info.data);
- else
+ } else {
ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
+ }
errout:
result = packet_create_reply(packet, "i", ret);
@@ -348,10 +360,11 @@ static struct packet *master_change_group(pid_t pid, int handle, const struct pa
arg.type = EVENT_CHANGE_GROUP;
- if (s_info.table.change_group)
+ if (s_info.table.change_group) {
ret = s_info.table.change_group(&arg, s_info.data);
- else
+ } else {
ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
+ }
errout:
result = packet_create_reply(packet, "i", ret);
@@ -375,19 +388,22 @@ static struct packet *master_pinup(pid_t pid, int handle, const struct packet *p
arg.type = EVENT_PINUP;
- if (s_info.table.pinup)
+ if (s_info.table.pinup) {
ret = s_info.table.pinup(&arg, s_info.data);
- else
+ } else {
ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
+ }
errout:
content = "default";
- if (ret == 0 && arg.info.pinup.content_info)
+ if (ret == 0 && arg.info.pinup.content_info) {
content = arg.info.pinup.content_info;
+ }
result = packet_create_reply(packet, "is", ret, content);
- if (ret == 0)
+ if (ret == 0) {
free(arg.info.pinup.content_info);
+ }
return result;
}
@@ -405,8 +421,9 @@ static struct packet *master_update_content(pid_t pid, int handle, const struct
arg.type = EVENT_UPDATE_CONTENT;
- if (s_info.table.update_content)
+ if (s_info.table.update_content) {
(void)s_info.table.update_content(&arg, s_info.data);
+ }
errout:
return NULL;
@@ -425,8 +442,9 @@ static struct packet *master_lb_pause(pid_t pid, int handle, const struct packet
arg.type = EVENT_LB_PAUSE;
- if (s_info.table.lb_pause)
+ if (s_info.table.lb_pause) {
(void)s_info.table.lb_pause(&arg, s_info.data);
+ }
return NULL;
}
@@ -444,8 +462,9 @@ static struct packet *master_lb_resume(pid_t pid, int handle, const struct packe
arg.type = EVENT_LB_RESUME;
- if (s_info.table.lb_resume)
+ if (s_info.table.lb_resume) {
(void)s_info.table.lb_resume(&arg, s_info.data);
+ }
return NULL;
}
@@ -467,10 +486,11 @@ static struct packet *master_pause(pid_t pid, int handle, const struct packet *p
arg.id = NULL;
arg.type = EVENT_PAUSE;
- if (s_info.table.pause)
+ if (s_info.table.pause) {
ret = s_info.table.pause(&arg, s_info.data);
- else
+ } else {
ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
+ }
errout:
result = packet_create_reply(packet, "i", ret);
@@ -490,10 +510,11 @@ static struct packet *master_update_mode(pid_t pid, int handle, const struct pac
goto errout;
}
- if (s_info.table.update_mode)
+ if (s_info.table.update_mode) {
ret = s_info.table.update_mode(&arg, s_info.data);
- else
+ } else {
ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
+ }
errout:
result = packet_create_reply(packet, "i", ret);
@@ -518,15 +539,17 @@ static struct packet *master_resume(pid_t pid, int handle, const struct packet *
arg.id = NULL;
arg.type = EVENT_RESUME;
- if (s_info.table.resume)
+ if (s_info.table.resume) {
ret = s_info.table.resume(&arg, s_info.data);
- else
+ } else {
ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
+ }
errout:
result = packet_create_reply(packet, "i", ret);
- if (!result)
+ if (!result) {
ErrPrint("Failed to create result packet\n");
+ }
return result;
}
@@ -543,9 +566,10 @@ struct packet *master_pd_create(pid_t pid, int handle, const struct packet *pack
arg.type = EVENT_PD_CREATE;
- DbgPrint("CREATE_PD\n");
- if (s_info.table.pd_create)
+ DbgPrint("PERF_DBOX\n");
+ if (s_info.table.pd_create) {
(void)s_info.table.pd_create(&arg, s_info.data);
+ }
out:
return NULL;
@@ -564,8 +588,9 @@ struct packet *master_pd_move(pid_t pid, int handle, const struct packet *packet
arg.type = EVENT_PD_MOVE;
- if (s_info.table.pd_move)
+ if (s_info.table.pd_move) {
(void)s_info.table.pd_move(&arg, s_info.data);
+ }
out:
return NULL;
@@ -583,8 +608,9 @@ struct packet *master_pd_destroy(pid_t pid, int handle, const struct packet *pac
}
arg.type = EVENT_PD_DESTROY;
- if (s_info.table.pd_destroy)
+ if (s_info.table.pd_destroy) {
(void)s_info.table.pd_destroy(&arg, s_info.data);
+ }
out:
return NULL;
@@ -824,8 +850,9 @@ static int connected_cb(int handle, void *data)
s_info.fd = handle;
- if (s_info.table.connected)
+ if (s_info.table.connected) {
s_info.table.connected(NULL, s_info.data);
+ }
return 0;
}
@@ -838,8 +865,9 @@ static int disconnected_cb(int handle, void *data)
}
DbgPrint("Disconnected (%d)\n", handle);
- if (s_info.table.disconnected)
+ if (s_info.table.disconnected) {
s_info.table.disconnected(NULL, s_info.data);
+ }
/* Reset the FD */
s_info.fd = -1;
@@ -852,12 +880,14 @@ EAPI int provider_init(void *disp, const char *name, struct event_handler *table
const char *option;
option = getenv("PROVIDER_DISABLE_PREVENT_OVERWRITE");
- if (option && !strcasecmp(option, "true"))
+ if (option && !strcasecmp(option, "true")) {
s_info.prevent_overwrite = 1;
+ }
option = getenv("PROVIDER_COM_CORE_THREAD");
- if (option && !strcasecmp(option, "true"))
+ if (option && !strcasecmp(option, "true")) {
com_core_packet_use_thread(1);
+ }
if (!name || !table) {
ErrPrint("Invalid argument\n");
@@ -1053,8 +1083,9 @@ static char *keep_file_in_safe(const char *id, int uri)
/*!
* \TODO: REMOVE ME
*/
- if (s_info.prevent_overwrite)
+ if (s_info.prevent_overwrite) {
return NULL;
+ }
if (access(path, R_OK | F_OK) != 0) {
ErrPrint("[%s] %s\n", path, strerror(errno));
@@ -1076,11 +1107,13 @@ static char *keep_file_in_safe(const char *id, int uri)
strncpy(new_path, path, base_idx);
snprintf(new_path + base_idx, len + 10 - base_idx, "reader/%s", path + base_idx);
- if (unlink(new_path) < 0)
+ if (unlink(new_path) < 0) {
ErrPrint("Unlink(%s): %s\n", new_path, strerror(errno));
+ }
- if (rename(path, new_path) < 0)
+ if (rename(path, new_path) < 0) {
ErrPrint("Failed to keep content in safe: %s (%s -> %s)\n", strerror(errno), path, new_path);
+ }
return new_path;
}
@@ -1099,11 +1132,13 @@ EAPI int provider_send_lb_update_begin(const char *pkgname, const char *id, doub
return LB_STATUS_ERROR_INVALID;
}
- if (!content_info)
+ if (!content_info) {
content_info = "";
+ }
- if (!title)
+ if (!title) {
title = "";
+ }
if (s_info.fd < 0) {
ErrPrint("Connection is not established\n");
@@ -1210,6 +1245,7 @@ EAPI int provider_send_pd_update_end(const char *pkgname, const char *id)
EAPI int provider_send_updated(const char *pkgname, const char *id, int w, int h, double priority, const char *content_info, const char *title)
{
+ struct livebox_buffer *info;
struct packet *packet;
int ret;
@@ -1218,21 +1254,26 @@ EAPI int provider_send_updated(const char *pkgname, const char *id, int w, int h
return LB_STATUS_ERROR_INVALID;
}
- if (!content_info)
+ if (!content_info) {
content_info = "";
+ }
- if (!title)
+ if (!title) {
title = "";
+ }
if (s_info.fd < 0) {
ErrPrint("Connection is not established\n");
return LB_STATUS_ERROR_INVALID;
}
- if (!provider_buffer_find_buffer(TYPE_LB, pkgname, id)) {
+ info = provider_buffer_find_buffer(TYPE_LB, pkgname, id);
+ if (!info) {
char *tmp;
tmp = keep_file_in_safe(id, 1);
free(tmp);
+ } else {
+ fb_sync_xdamage(info->fb);
}
packet = packet_create_noack("updated", "ssiidss",
@@ -1249,6 +1290,7 @@ EAPI int provider_send_updated(const char *pkgname, const char *id, int w, int h
EAPI int provider_send_desc_updated(const char *pkgname, const char *id, const char *descfile)
{
+ struct livebox_buffer *info;
struct packet *packet;
char *desc_path = NULL;
int ret;
@@ -1263,13 +1305,24 @@ EAPI int provider_send_desc_updated(const char *pkgname, const char *id, const c
return LB_STATUS_ERROR_INVALID;
}
- if (!descfile)
+ if (!descfile) {
descfile = util_uri_to_path(id); /* In case of the NULL descfilename, use the ID */
+ }
- if (!provider_buffer_find_buffer(TYPE_PD, pkgname, id)) {
+ info = provider_buffer_find_buffer(TYPE_PD, pkgname, id);
+ if (!info) {
desc_path = keep_file_in_safe(descfile, 0);
+ if (!desc_path) {
+ return LB_STATUS_ERROR_INVALID;
+ }
} else {
desc_path = strdup(descfile);
+ if (!desc_path) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ return LB_STATUS_ERROR_MEMORY;
+ }
+
+ fb_sync_xdamage(info->fb);
}
packet = packet_create_noack("desc_updated", "sss", pkgname, id, desc_path);
diff --git a/src/provider_buffer.c b/src/provider_buffer.c
index 3554432..f9efc94 100644
--- a/src/provider_buffer.c
+++ b/src/provider_buffer.c
@@ -157,11 +157,13 @@ struct livebox_buffer *provider_buffer_find_buffer(enum target_type type, const
struct livebox_buffer *info;
dlist_foreach_safe(s_info.buffer_list, l, n, info) {
- if (info->type != type)
+ if (info->type != type) {
continue;
+ }
- if (!strcmp(info->pkgname, pkgname) && !strcmp(info->id, id))
+ if (!strcmp(info->pkgname, pkgname) && !strcmp(info->id, id)) {
return info;
+ }
}
return NULL;
@@ -207,8 +209,9 @@ EAPI struct livebox_buffer *provider_buffer_acquire(enum target_type type, const
return NULL;
}
- if (!handler)
+ if (!handler) {
DbgPrint("Event handler is not speicified\n");
+ }
DbgPrint("acquire_buffer: [%s] %s, %dx%d, size: %d, handler: %p\n",
type == TYPE_LB ? "LB" : "PD", id,
@@ -266,8 +269,9 @@ EAPI int provider_buffer_resize(struct livebox_buffer *info, int w, int h)
}
fb = send_resize_request(info->type, info->pkgname, info->id, w, h);
- if (!fb)
+ if (!fb) {
return LB_STATUS_ERROR_INVALID;
+ }
/*!
* \note
@@ -377,14 +381,17 @@ EAPI int provider_buffer_get_size(struct livebox_buffer *info, int *w, int *h, i
return LB_STATUS_ERROR_INVALID;
}
- if (w)
+ if (w) {
*w = info->width;
+ }
- if (h)
+ if (h) {
*h = info->height;
+ }
- if (pixel_size)
+ if (pixel_size) {
*pixel_size = info->pixel_size;
+ }
return LB_STATUS_SUCCESS;
}
@@ -415,8 +422,9 @@ EAPI unsigned long provider_buffer_pixmap_id(struct livebox_buffer *info)
}
id = fb_id(info->fb);
- if (!id)
+ if (!id) {
return 0;
+ }
if (sscanf(id, SCHEMA_PIXMAP "%lu", &pixmap) != 1) {
ErrPrint("Invalid ID: %s\n", id);
@@ -428,24 +436,27 @@ EAPI unsigned long provider_buffer_pixmap_id(struct livebox_buffer *info)
EAPI int provider_buffer_pixmap_is_support_hw(struct livebox_buffer *info)
{
- if (!info)
+ if (!info) {
return LB_STATUS_ERROR_INVALID;
+ }
return fb_has_gem(info->fb);
}
EAPI int provider_buffer_pixmap_create_hw(struct livebox_buffer *info)
{
- if (!fb_has_gem(info->fb))
+ if (!fb_has_gem(info->fb)) {
return LB_STATUS_ERROR_INVALID;
+ }
return fb_create_gem(info->fb);
}
EAPI int provider_buffer_pixmap_destroy_hw(struct livebox_buffer *info)
{
- if (!info || !fb_has_gem(info->fb))
+ if (!info || !fb_has_gem(info->fb)) {
return LB_STATUS_ERROR_INVALID;
+ }
return fb_destroy_gem(info->fb);
}
@@ -454,8 +465,9 @@ EAPI void *provider_buffer_pixmap_hw_addr(struct livebox_buffer *info)
{
void *addr;
- if (!info || !fb_has_gem(info->fb))
+ if (!info || !fb_has_gem(info->fb)) {
return NULL;
+ }
addr = fb_acquire_gem(info->fb);
fb_release_gem(info->fb);
@@ -467,11 +479,13 @@ EAPI int provider_buffer_pre_render(struct livebox_buffer *info)
{
int ret = LB_STATUS_SUCCESS;
- if (!info)
+ if (!info) {
return LB_STATUS_ERROR_INVALID;
+ }
- if (fb_has_gem(info->fb))
+ if (fb_has_gem(info->fb)) {
ret = fb_acquire_gem(info->fb) ? 0 : -EFAULT;
+ }
return ret;
}
@@ -480,11 +494,13 @@ EAPI int provider_buffer_post_render(struct livebox_buffer *info)
{
int ret = LB_STATUS_SUCCESS;
- if (!info)
+ if (!info) {
return LB_STATUS_ERROR_INVALID;
+ }
- if (fb_has_gem(info->fb))
+ if (fb_has_gem(info->fb)) {
ret = fb_release_gem(info->fb);
+ }
return ret;
}
@@ -1016,8 +1032,9 @@ struct packet *provider_buffer_pd_access_action_up(pid_t pid, int handle, const
int w;
int h;
- if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
+ if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
+ }
(void)info->handler(info, BUFFER_EVENT_ACTION_UP, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
} else {
@@ -1055,8 +1072,9 @@ struct packet *provider_buffer_pd_access_action_down(pid_t pid, int handle, cons
int w;
int h;
- if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
+ if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
+ }
(void)info->handler(info, BUFFER_EVENT_ACTION_DOWN, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
} else {
@@ -1094,8 +1112,9 @@ struct packet *provider_buffer_pd_access_scroll_down(pid_t pid, int handle, cons
int w;
int h;
- if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
+ if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
+ }
(void)info->handler(info, BUFFER_EVENT_SCROLL_DOWN, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
} else {
@@ -1133,8 +1152,9 @@ struct packet *provider_buffer_pd_access_scroll_move(pid_t pid, int handle, cons
int w;
int h;
- if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
+ if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
+ }
(void)info->handler(info, BUFFER_EVENT_SCROLL_MOVE, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
} else {
@@ -1172,8 +1192,9 @@ struct packet *provider_buffer_pd_access_scroll_up(pid_t pid, int handle, const
int w;
int h;
- if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
+ if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
+ }
(void)info->handler(info, BUFFER_EVENT_SCROLL_UP, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
} else {
@@ -1211,8 +1232,9 @@ struct packet *provider_buffer_pd_access_unhighlight(pid_t pid, int handle, cons
int w;
int h;
- if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
+ if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
+ }
(void)info->handler(info, BUFFER_EVENT_UNHIGHLIGHT, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
} else {
@@ -1250,8 +1272,9 @@ struct packet *provider_buffer_pd_access_hl(pid_t pid, int handle, const struct
int w;
int h;
- if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
+ if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
+ }
(void)info->handler(info, BUFFER_EVENT_HIGHLIGHT, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
} else {
@@ -1289,8 +1312,9 @@ struct packet *provider_buffer_pd_access_hl_prev(pid_t pid, int handle, const st
int w;
int h;
- if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
+ if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
+ }
(void)info->handler(info, BUFFER_EVENT_HIGHLIGHT_PREV, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
} else {
@@ -1328,8 +1352,9 @@ struct packet *provider_buffer_pd_access_hl_next(pid_t pid, int handle, const st
int w;
int h;
- if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
+ if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
+ }
(void)info->handler(info, BUFFER_EVENT_HIGHLIGHT_NEXT, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
} else {
@@ -1367,8 +1392,9 @@ struct packet *provider_buffer_pd_access_activate(pid_t pid, int handle, const s
int w;
int h;
- if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
+ if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
+ }
(void)info->handler(info, BUFFER_EVENT_ACTIVATE, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
} else {
@@ -1406,8 +1432,9 @@ struct packet *provider_buffer_lb_access_unhighlight(pid_t pid, int handle, cons
int w;
int h;
- if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
+ if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
+ }
(void)info->handler(info, BUFFER_EVENT_UNHIGHLIGHT, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
} else {
@@ -1445,8 +1472,9 @@ struct packet *provider_buffer_lb_access_hl(pid_t pid, int handle, const struct
int w;
int h;
- if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
+ if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
+ }
(void)info->handler(info, BUFFER_EVENT_HIGHLIGHT, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
} else {
@@ -1484,8 +1512,9 @@ struct packet *provider_buffer_lb_access_hl_prev(pid_t pid, int handle, const st
int w;
int h;
- if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
+ if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
+ }
(void)info->handler(info, BUFFER_EVENT_HIGHLIGHT_PREV, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
} else {
@@ -1523,8 +1552,9 @@ struct packet *provider_buffer_lb_access_hl_next(pid_t pid, int handle, const st
int w;
int h;
- if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
+ if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
+ }
(void)info->handler(info, BUFFER_EVENT_HIGHLIGHT_NEXT, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
} else {
@@ -1562,8 +1592,9 @@ struct packet *provider_buffer_lb_access_action_up(pid_t pid, int handle, const
int w;
int h;
- if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
+ if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
+ }
(void)info->handler(info, BUFFER_EVENT_ACTION_UP, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
} else {
@@ -1601,8 +1632,9 @@ struct packet *provider_buffer_lb_access_action_down(pid_t pid, int handle, cons
int w;
int h;
- if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
+ if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
+ }
(void)info->handler(info, BUFFER_EVENT_ACTION_DOWN, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
} else {
@@ -1640,8 +1672,9 @@ struct packet *provider_buffer_lb_access_scroll_down(pid_t pid, int handle, cons
int w;
int h;
- if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
+ if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
+ }
(void)info->handler(info, BUFFER_EVENT_SCROLL_DOWN, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
} else {
@@ -1679,8 +1712,9 @@ struct packet *provider_buffer_lb_access_scroll_move(pid_t pid, int handle, cons
int w;
int h;
- if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
+ if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
+ }
(void)info->handler(info, BUFFER_EVENT_SCROLL_MOVE, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
} else {
@@ -1718,8 +1752,9 @@ struct packet *provider_buffer_lb_access_scroll_up(pid_t pid, int handle, const
int w;
int h;
- if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
+ if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
+ }
(void)info->handler(info, BUFFER_EVENT_SCROLL_UP, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
} else {
@@ -1757,8 +1792,9 @@ struct packet *provider_buffer_lb_access_activate(pid_t pid, int handle, const s
int w;
int h;
- if (provider_buffer_get_size(info, &w, &h, NULL) < 0)
+ if (provider_buffer_get_size(info, &w, &h, NULL) < 0) {
ErrPrint("Failed to get buffer size[%s:%s]\n", pkgname, id);
+ }
(void)info->handler(info, BUFFER_EVENT_ACTIVATE, timestamp, (double)x / (double)w, (double)y / (double)h, info->data);
} else {
diff --git a/src/util.c b/src/util.c
index 2a77c44..defbdb0 100644
--- a/src/util.c
+++ b/src/util.c
@@ -37,8 +37,9 @@ const char *util_basename(const char *name)
{
int length;
length = name ? strlen(name) : 0;
- if (!length)
+ if (!length) {
return ".";
+ }
while (--length > 0 && name[length] != '/');
@@ -50,8 +51,9 @@ const char *util_uri_to_path(const char *uri)
int len;
len = strlen(SCHEMA_FILE);
- if (strncasecmp(uri, SCHEMA_FILE, len))
+ if (strncasecmp(uri, SCHEMA_FILE, len)) {
return NULL;
+ }
return uri + len;
}