/*
* Copyright 2013 Samsung Electronics Co., Ltd
*
- * Licensed under the Flora License, Version 1.0 (the "License");
+ * Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.tizenopensource.org/license
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
.fault_list = NULL,
.init_count = 0,
.prevent_overwrite = 0,
- .event_filter = 0.02f,
+ .event_filter = 0.01f,
};
struct cb_info {
DbgPrint("Default LB size changed event handler: %d\n", ret);
}
+static inline void default_update_mode_cb(struct livebox *handler, int ret, void *data)
+{
+ DbgPrint("Default update mode set event handler: %d\n", ret);
+}
+
+static inline void default_access_event_cb(struct livebox *handler, int ret, void *data)
+{
+ DbgPrint("Default access event handler: %d\n", ret);
+}
+
static inline __attribute__((always_inline)) struct cb_info *create_cb_info(ret_cb_t cb, void *data)
{
struct cb_info *info;
free(info);
}
-static void resize_cb(struct livebox *handler, const struct packet *result, void *data)
+static void update_mode_cb(struct livebox *handler, const struct packet *result, void *data)
{
int ret;
- struct cb_info *info = data;
- ret_cb_t cb;
- void *cbdata;
- cb = info->cb;
- cbdata = info->data;
- destroy_cb_info(info);
+ if (!result) {
+ ret = LB_STATUS_ERROR_FAULT;
+ goto errout;
+ } else if (packet_get(result, "i", &ret) != 1) {
+ ErrPrint("Invalid argument\n");
+ ret = LB_STATUS_ERROR_INVALID;
+ goto errout;
+ }
+
+ if (ret < 0) {
+ ErrPrint("Resize request is failed: %d\n", ret);
+ goto errout;
+ }
+
+ return;
+
+errout:
+ handler->update_mode_cb(handler, ret, handler->update_mode_cbdata);
+ handler->update_mode_cb = NULL;
+ handler->update_mode_cbdata = NULL;
+ return;
+}
+
+static void resize_cb(struct livebox *handler, const struct packet *result, void *data)
+{
+ int ret;
if (!result) {
ret = LB_STATUS_ERROR_FAULT;
+ goto errout;
} else if (packet_get(result, "i", &ret) != 1) {
ErrPrint("Invalid argument\n");
ret = LB_STATUS_ERROR_INVALID;
+ goto errout;
}
/*!
* So the user can only get the resized value(result) from the first update event
* after this request.
*/
- if (ret == 0) {
- DbgPrint("Resize request is done, prepare the size changed event\n");
- handler->size_changed_cb = cb;
- handler->size_cbdata = cbdata;
- } else {
- DbgPrint("Resize request is failed: %d\n", ret);
- cb(handler, ret, cbdata);
+ if (ret < 0) {
+ ErrPrint("Resize request is failed: %d\n", ret);
+ goto errout;
}
+
+ return;
+
+errout:
+ handler->size_changed_cb(handler, ret, handler->size_cbdata);
+ handler->size_changed_cb = NULL;
+ handler->size_cbdata = NULL;
}
static void text_signal_cb(struct livebox *handler, const struct packet *result, void *data)
ret = LB_STATUS_ERROR_INVALID;
}
- if (cb)
+ if (cb) {
cb(handler, ret, cbdata);
+ }
return;
}
static void set_group_ret_cb(struct livebox *handler, const struct packet *result, void *data)
{
int ret;
- void *cbdata;
- ret_cb_t cb;
- struct cb_info *info = data;
-
- cbdata = info->data;
- cb = info->cb;
- destroy_cb_info(info);
if (!result) {
ret = LB_STATUS_ERROR_FAULT;
+ goto errout;
} else if (packet_get(result, "i", &ret) != 1) {
ErrPrint("Invalid argument\n");
ret = LB_STATUS_ERROR_INVALID;
+ goto errout;
}
- if (ret == 0) { /*!< Group information is successfully changed */
- handler->group_changed_cb = cb;
- handler->group_cbdata = cbdata;
- } else if (cb) {
- cb(handler, ret, cbdata);
+ if (ret < 0) {
+ goto errout;
}
return;
+
+errout:
+ handler->group_changed_cb(handler, ret, handler->group_cbdata);
+ handler->group_changed_cb = NULL;
+ handler->group_cbdata = NULL;
}
static void period_ret_cb(struct livebox *handler, const struct packet *result, void *data)
{
- struct cb_info *info = data;
int ret;
- ret_cb_t cb;
- void *cbdata;
-
- cb = info->cb;
- cbdata = info->data;
- destroy_cb_info(info);
if (!result) {
ret = LB_STATUS_ERROR_FAULT;
+ goto errout;
} else if (packet_get(result, "i", &ret) != 1) {
ErrPrint("Invalid argument\n");
ret = LB_STATUS_ERROR_INVALID;
+ goto errout;
}
- if (ret == 0) {
- handler->period_changed_cb = cb;
- handler->period_cbdata = cbdata;
- } else if (cb) {
- cb(handler, ret, cbdata);
+ if (ret < 0) {
+ goto errout;
}
+
+ return;
+
+errout:
+ handler->period_changed_cb(handler, ret, handler->period_cbdata);
+ handler->period_changed_cb = NULL;
+ handler->period_cbdata = NULL;
}
static void del_ret_cb(struct livebox *handler, const struct packet *result, void *data)
}
if (ret == 0) {
- DbgPrint("Returns %d (waiting deleted event)\n", ret);
handler->deleted_cb = cb;
handler->deleted_cbdata = cbdata;
} else if (cb) {
}
if (ret >= 0) {
- DbgPrint("new request is sent, just waiting the created event\n");
handler->created_cb = cb;
handler->created_cbdata = cbdata;
static void pd_create_cb(struct livebox *handler, const struct packet *result, void *data)
{
- struct cb_info *info = data;
- void *cbdata;
- ret_cb_t cb;
int ret;
- cb = info->cb;
- cbdata = info->data;
- destroy_cb_info(data);
-
if (!result) {
ret = LB_STATUS_ERROR_FAULT;
+ goto errout;
} else if (packet_get(result, "i", &ret) != 1) {
ret = LB_STATUS_ERROR_INVALID;
+ goto errout;
}
- if (ret == 0) {
- DbgPrint("PD Created event handler prepared\n");
- handler->pd_created_cb = cb;
- handler->pd_created_cbdata = cbdata;
- } else if (cb) {
- DbgPrint("Failed to create a PD\n");
- cb(handler, ret, cbdata);
+ if (ret < 0) {
+ ErrPrint("Failed to create a PD[%d]\n", ret);
+ goto errout;
}
+
+ return;
+
+errout:
+ handler->pd_created_cb(handler, ret, handler->pd_created_cbdata);
+ handler->pd_created_cb = NULL;
+ handler->pd_created_cbdata = NULL;
}
static void activated_cb(struct livebox *handler, const struct packet *result, void *data)
ret = LB_STATUS_ERROR_INVALID;
}
- if (cb)
+ if (cb) {
cb(handler, ret, cbdata);
+ }
}
static void pd_destroy_cb(struct livebox *handler, const struct packet *result, void *data)
destroy_cb_info(info);
if (!result) {
- DbgPrint("Result is NIL (may connection lost)\n");
+ ErrPrint("Result is NIL (may connection lost)\n");
ret = LB_STATUS_ERROR_FAULT;
} else if (packet_get(result, "i", &ret) != 1) {
- DbgPrint("Invalid parameter\n");
+ ErrPrint("Invalid parameter\n");
ret = LB_STATUS_ERROR_INVALID;
}
if (ret == 0) {
- DbgPrint("PD Destroyed callback prepared\n");
handler->pd_destroyed_cb = cb;
handler->pd_destroyed_cbdata = cbdata;
} else if (cb) {
- DbgPrint("PD is not desroyed (forcely reset, pd flag)\n");
handler->is_pd_created = 0;
cb(handler, ret, cbdata);
}
ret = LB_STATUS_ERROR_INVALID;
}
- DbgPrint("Delete category returns: %d\n", ret);
-
- if (cb)
+ if (cb) {
cb(handler, ret, cbdata);
+ }
}
static void delete_category_cb(struct livebox *handler, const struct packet *result, void *data)
cbdata = info->data;
destroy_cb_info(info);
- if (!result)
+ if (!result) {
ret = LB_STATUS_ERROR_FAULT;
- else if (packet_get(result, "i", &ret) != 1)
+ } else if (packet_get(result, "i", &ret) != 1) {
ret = LB_STATUS_ERROR_INVALID;
+ }
- DbgPrint("Delete category returns: %d\n", ret);
-
- if (cb)
+ if (cb) {
cb(handler, ret, cbdata);
+ }
}
-static void pixmap_acquired_cb(struct livebox *handler, const struct packet *result, void *data)
+static void lb_pixmap_acquired_cb(struct livebox *handler, const struct packet *result, void *data)
{
+ int pixmap;
int ret;
ret_cb_t cb;
void *cbdata;
cbdata = info->data;
destroy_cb_info(info);
- if (!result)
- ret = 0; /* PIXMAP 0 means error */
- else if (packet_get(result, "i", &ret) != 1)
- ret = 0;
+ if (!result) {
+ pixmap = 0; /* PIXMAP 0 means error */
+ } else if (packet_get(result, "ii", &pixmap, &ret) != 2) {
+ pixmap = 0;
+ }
- if (cb)
- cb(handler, ret, cbdata);
+ if (ret == LB_STATUS_ERROR_BUSY) {
+ ret = livebox_acquire_lb_pixmap(handler, cb, cbdata);
+ DbgPrint("Busy, Try again: %d\n", ret);
+ /* Try again */
+ } else {
+ if (cb) {
+ cb(handler, pixmap, cbdata);
+ }
+ }
}
-static void pinup_done_cb(struct livebox *handler, const struct packet *result, void *data)
+static void pd_pixmap_acquired_cb(struct livebox *handler, const struct packet *result, void *data)
{
+ int pixmap;
int ret;
ret_cb_t cb;
void *cbdata;
cbdata = info->data;
destroy_cb_info(info);
- if (!result)
+ if (!result) {
+ pixmap = 0; /* PIXMAP 0 means error */
ret = LB_STATUS_ERROR_FAULT;
- else if (packet_get(result, "i", &ret) != 1)
+ } else if (packet_get(result, "ii", &pixmap, &ret) != 2) {
+ pixmap = 0;
ret = LB_STATUS_ERROR_INVALID;
+ }
- if (ret == 0) {
- handler->pinup_cb = cb;
- handler->pinup_cbdata = cbdata;
- } else if (cb) {
- cb(handler, ret, cbdata);
+ if (ret == LB_STATUS_ERROR_BUSY) {
+ ret = livebox_acquire_pd_pixmap(handler, cb, cbdata);
+ DbgPrint("Busy, Try again: %d\n", ret);
+ /* Try again */
+ } else {
+ if (cb) {
+ DbgPrint("ret: %d, pixmap: %d\n", ret, pixmap);
+ cb(handler, pixmap, cbdata);
+ }
+ }
+}
+
+static void pinup_done_cb(struct livebox *handler, const struct packet *result, void *data)
+{
+ int ret;
+
+ if (!result) {
+ ret = LB_STATUS_ERROR_FAULT;
+ goto errout;
+ } else if (packet_get(result, "i", &ret) != 1) {
+ goto errout;
+ }
+
+ if (ret < 0) {
+ goto errout;
+ }
+
+ return;
+
+errout:
+ handler->pinup_cb(handler, ret, handler->pinup_cbdata);
+ handler->pinup_cb = NULL;
+ handler->pinup_cbdata = NULL;
+}
+
+static void access_ret_cb(struct livebox *handler, const struct packet *result, void *data)
+{
+ int ret;
+
+ if (!result) {
+ ret = LB_STATUS_ERROR_FAULT;
+ return;
+ }
+
+ if (packet_get(result, "i", &ret) != 1) {
+ ret = LB_STATUS_ERROR_INVALID;
+ return;
+ }
+
+ if (ret != LB_STATUS_SUCCESS) {
+ goto errout;
+ }
+
+ return;
+
+errout:
+ handler->access_event_cb(handler, ret, handler->access_event_cbdata);
+ handler->access_event_cb = NULL;
+ handler->access_event_cbdata = NULL;
+ return;
+}
+
+static int send_access_event(struct livebox *handler, const char *event, int x, int y)
+{
+ struct packet *packet;
+ double timestamp;
+
+ timestamp = util_timestamp();
+
+ packet = packet_create(event, "ssdii", handler->pkgname, handler->id, timestamp, x, y);
+ if (!packet) {
+ ErrPrint("Failed to build packet\n");
+ return LB_STATUS_ERROR_FAULT;
}
+
+ return master_rpc_async_request(handler, packet, 0, access_ret_cb, NULL);
}
static int send_mouse_event(struct livebox *handler, const char *event, int x, int y)
return LB_STATUS_ERROR_FAULT;
}
- DbgPrint("Send: %dx%d\n", x, y);
-
return master_rpc_request_only(handler, packet);
}
return LB_STATUS_SUCCESS;
}
env = getenv("PROVIDER_DISABLE_PREVENT_OVERWRITE");
- if (env && !strcasecmp(env, "true"))
+ if (env && !strcasecmp(env, "true")) {
s_info.prevent_overwrite = 1;
+ }
env = getenv("PROVIDER_EVENT_FILTER");
- if (env)
+ if (env) {
sscanf(env, "%lf", &MINIMUM_EVENT);
+ }
#if defined(FLOG)
char filename[BUFSIZ];
snprintf(filename, sizeof(filename), "/tmp/%d.box.log", getpid());
__file_log_fp = fopen(filename, "w+t");
- if (!__file_log_fp)
+ if (!__file_log_fp) {
__file_log_fp = fdopen(1, "w+t");
+ }
#endif
critical_log_init("viewer");
livebox_service_init();
EAPI int livebox_fini(void)
{
if (s_info.init_count <= 0) {
- DbgPrint("Didn't initialized\n");
+ ErrPrint("Doesn't initialized\n");
return LB_STATUS_ERROR_INVALID;
}
s_info.init_count--;
if (s_info.init_count > 0) {
- DbgPrint("init count : %d\n", s_info.init_count);
+ ErrPrint("init count : %d\n", s_info.init_count);
return LB_STATUS_SUCCESS;
}
lb = livebox_service_pkgname(pkgname);
if (!lb) {
- if (util_validate_livebox_package(pkgname) == 0)
+ if (util_validate_livebox_package(pkgname) == 0) {
return strdup(pkgname);
+ }
}
return lb;
int ret;
int width = 0;
int height = 0;
+ struct cb_info *cbinfo;
if (!pkgname || !cluster || !category) {
ErrPrint("Invalid arguments: pkgname[%p], cluster[%p], category[%p]\n",
return NULL;
}
- if (type != LB_SIZE_TYPE_UNKNOWN)
+ if (type != LB_SIZE_TYPE_UNKNOWN) {
livebox_service_get_size(type, &width, &height);
+ }
handler = calloc(1, sizeof(*handler));
if (!handler) {
return NULL;
}
- if (!cb)
+ if (!cb) {
cb = default_create_cb;
+ }
/* Data provider will set this */
handler->lb.type = _LB_TYPE_FILE;
return NULL;
}
- ret = master_rpc_async_request(handler, packet, 0, new_ret_cb, create_cb_info(cb, data));
+ cbinfo = create_cb_info(cb, data);
+ if (!cbinfo) {
+ ErrPrint("Failed to create a cbinfo\n");
+ packet_destroy(packet);
+ free(handler->category);
+ free(handler->cluster);
+ free(handler->content);
+ free(handler->pkgname);
+ free(handler);
+ return NULL;
+ }
+
+ ret = master_rpc_async_request(handler, packet, 0, new_ret_cb, cbinfo);
if (ret < 0) {
ErrPrint("Failed to send a new packet\n");
+ destroy_cb_info(cbinfo);
free(handler->category);
free(handler->cluster);
free(handler->content);
return NULL;
}
- DbgPrint("Successfully sent a new request ([%lf] %s)\n", handler->timestamp, handler->pkgname);
handler->state = CREATE;
return lb_ref(handler);
}
EAPI int livebox_set_period(struct livebox *handler, double period, ret_cb_t cb, void *data)
{
struct packet *packet;
+ int ret;
if (!handler || handler->state != CREATE || !handler->id) {
ErrPrint("Handler is not valid\n");
return LB_STATUS_ERROR_FAULT;
}
- if (!cb)
+ if (!cb) {
cb = default_period_changed_cb;
+ }
+
+ ret = master_rpc_async_request(handler, packet, 0, period_ret_cb, NULL);
+ if (ret == LB_STATUS_SUCCESS) {
+ handler->period_changed_cb = cb;
+ handler->period_cbdata = data;
+ }
- return master_rpc_async_request(handler, packet, 0, period_ret_cb, create_cb_info(cb, data));
+ return ret;
}
EAPI int livebox_del(struct livebox *handler, ret_cb_t cb, void *data)
* By the way, if the user adds any callback for getting return status of this,
* call it at here.
*/
- if (cb)
+ if (cb) {
cb(handler, 0, data);
+ }
return LB_STATUS_SUCCESS;
}
- if (!cb)
+ if (!cb) {
cb = default_delete_cb;
+ }
return lb_send_delete(handler, cb, data);
}
{
struct fault_info *info;
- if (!cb)
+ if (!cb) {
return LB_STATUS_ERROR_INVALID;
+ }
info = malloc(sizeof(*info));
if (!info) {
dlist_foreach(s_info.fault_list, l, info) {
if (info->handler == cb) {
void *data;
+
s_info.fault_list = dlist_remove(s_info.fault_list, l);
data = info->user_data;
free(info);
return NULL;
}
+EAPI int livebox_set_update_mode(struct livebox *handler, int active_update, ret_cb_t cb, void *data)
+{
+ struct packet *packet;
+ int ret;
+
+ if (!handler) {
+ ErrPrint("Handler is NIL\n");
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (handler->state != CREATE || !handler->id) {
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (handler->update_mode_cb) {
+ ErrPrint("Previous update_mode cb is not finished yet\n");
+ return LB_STATUS_ERROR_BUSY;
+ }
+
+ if (handler->is_active_update == active_update) {
+ return LB_STATUS_ERROR_ALREADY;
+ }
+
+ if (!handler->is_user) {
+ return LB_STATUS_ERROR_PERMISSION;
+ }
+
+ packet = packet_create("update_mode", "ssi", handler->pkgname, handler->id, active_update);
+ if (!packet) {
+ return LB_STATUS_ERROR_FAULT;
+ }
+
+ if (!cb) {
+ cb = default_update_mode_cb;
+ }
+
+ ret = master_rpc_async_request(handler, packet, 0, update_mode_cb, NULL);
+ if (ret == LB_STATUS_SUCCESS) {
+ handler->update_mode_cb = cb;
+ handler->update_mode_cbdata = data;
+ }
+
+ return ret;
+}
+
+EAPI int livebox_is_active_update(struct livebox *handler)
+{
+ if (!handler) {
+ ErrPrint("Handler is NIL\n");
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (handler->state != CREATE || !handler->id) {
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ return handler->is_active_update;
+}
+
EAPI int livebox_resize(struct livebox *handler, int type, ret_cb_t cb, void *data)
{
struct packet *packet;
int w;
int h;
+ int ret;
if (!handler) {
ErrPrint("Handler is NIL\n");
return LB_STATUS_ERROR_FAULT;
}
- if (!cb)
+ if (!cb) {
cb = default_lb_size_changed_cb;
+ }
+
+ ret = master_rpc_async_request(handler, packet, 0, resize_cb, NULL);
+ if (ret == LB_STATUS_SUCCESS) {
+ handler->size_changed_cb = cb;
+ handler->size_cbdata = data;
+ }
- return master_rpc_async_request(handler, packet, 0, resize_cb, create_cb_info(cb, data));
+ return ret;
}
EAPI int livebox_click(struct livebox *handler, double x, double y)
double timestamp;
int ret;
+ timestamp = util_timestamp();
+
if (!handler) {
ErrPrint("Handler is NIL\n");
return LB_STATUS_ERROR_INVALID;
return LB_STATUS_ERROR_INVALID;
}
- if (handler->lb.auto_launch)
- if (aul_open_app(handler->lb.auto_launch) < 0)
+ if (handler->lb.auto_launch) {
+ DbgPrint("AUTO_LAUNCH [%s]\n", handler->lb.auto_launch);
+ if (aul_launch_app(handler->lb.auto_launch, NULL) < 0) {
ErrPrint("Failed to launch app %s\n", handler->lb.auto_launch);
+ }
+ }
- timestamp = util_timestamp();
packet = packet_create_noack("clicked", "sssddd", handler->pkgname, handler->id, "clicked", timestamp, x, y);
if (!packet) {
ErrPrint("Failed to build param\n");
return LB_STATUS_ERROR_FAULT;
}
+ DbgPrint("CLICKED: %lf\n", timestamp);
ret = master_rpc_request_only(handler, packet);
- DbgPrint("Click request: %d\n", ret);
if (!handler->lb.mouse_event && (handler->lb.type == _LB_TYPE_BUFFER || handler->lb.type == _LB_TYPE_SCRIPT)) {
int ret; /* Shadow variable */
ret = send_mouse_event(handler, "lb_mouse_down", x * handler->lb.width, y * handler->lb.height);
- if (ret < 0)
- DbgPrint("Failed to send Down: %d\n", ret);
+ if (ret < 0) {
+ ErrPrint("Failed to send Down: %d\n", ret);
+ }
ret = send_mouse_event(handler, "lb_mouse_move", x * handler->lb.width, y * handler->lb.height);
- if (ret < 0)
- DbgPrint("Failed to send Move: %d\n", ret);
+ if (ret < 0) {
+ ErrPrint("Failed to send Move: %d\n", ret);
+ }
ret = send_mouse_event(handler, "lb_mouse_up", x * handler->lb.width, y * handler->lb.height);
- if (ret < 0)
- DbgPrint("Failed to send Up: %d\n", ret);
+ if (ret < 0) {
+ ErrPrint("Failed to send Up: %d\n", ret);
+ }
}
return ret;
EAPI int livebox_create_pd_with_position(struct livebox *handler, double x, double y, ret_cb_t cb, void *data)
{
struct packet *packet;
+ int ret;
if (!handler) {
ErrPrint("Handler is NIL\n");
return LB_STATUS_SUCCESS;
}
+ if (handler->pd_created_cb) {
+ ErrPrint("Previous request is not completed yet\n");
+ return LB_STATUS_ERROR_BUSY;
+ }
+
packet = packet_create("create_pd", "ssdd", handler->pkgname, handler->id, x, y);
if (!packet) {
ErrPrint("Failed to build param\n");
return LB_STATUS_ERROR_FAULT;
}
- if (!cb)
- handler->pd_created_cb = default_pd_created_cb;
+ if (!cb) {
+ cb = default_pd_created_cb;
+ }
+
+ DbgPrint("PERF_DBOX\n");
+ ret = master_rpc_async_request(handler, packet, 0, pd_create_cb, NULL);
+ if (ret == LB_STATUS_SUCCESS) {
+ handler->pd_created_cb = cb;
+ handler->pd_created_cbdata = data;
+ }
- return master_rpc_async_request(handler, packet, 0, pd_create_cb, create_cb_info(cb, data));
+ return ret;
}
EAPI int livebox_move_pd(struct livebox *handler, double x, double y)
}
if (!handler->is_pd_created) {
- DbgPrint("PD is not created\n");
+ ErrPrint("PD is not created\n");
return LB_STATUS_ERROR_INVALID;
}
EAPI int livebox_activate(const char *pkgname, ret_cb_t cb, void *data)
{
struct packet *packet;
+ struct cb_info *cbinfo;
+ int ret;
- if (!pkgname)
+ if (!pkgname) {
return LB_STATUS_ERROR_INVALID;
+ }
packet = packet_create("activate_package", "s", pkgname);
if (!packet) {
return LB_STATUS_ERROR_FAULT;
}
- return master_rpc_async_request(NULL, packet, 0, activated_cb, create_cb_info(cb, data));
+ cbinfo = create_cb_info(cb, data);
+ if (!cbinfo) {
+ ErrPrint("Unable to create cbinfo\n");
+ packet_destroy(packet);
+ return LB_STATUS_ERROR_FAULT;
+ }
+
+ ret = master_rpc_async_request(NULL, packet, 0, activated_cb, cbinfo);
+ if (ret < 0) {
+ destroy_cb_info(cbinfo);
+ }
+
+ return ret;
}
EAPI int livebox_destroy_pd(struct livebox *handler, ret_cb_t cb, void *data)
{
struct packet *packet;
+ struct cb_info *cbinfo;
+ int ret;
if (!handler) {
ErrPrint("Handler is NIL\n");
return LB_STATUS_ERROR_INVALID;
}
- if (!handler->is_pd_created) {
+ if (!handler->is_pd_created && !handler->pd_created_cb) {
ErrPrint("PD is not created\n");
return LB_STATUS_ERROR_INVALID;
}
return LB_STATUS_ERROR_FAULT;
}
- if (!cb)
+ if (!cb) {
cb = default_pd_destroyed_cb;
+ }
+
+ cbinfo = create_cb_info(cb, data);
+ if (!cbinfo) {
+ packet_destroy(packet);
+ return LB_STATUS_ERROR_FAULT;
+ }
+
+ ret = master_rpc_async_request(handler, packet, 0, pd_destroy_cb, cbinfo);
+ if (ret < 0) {
+ destroy_cb_info(cbinfo);
+ }
- return master_rpc_async_request(handler, packet, 0, pd_destroy_cb, create_cb_info(cb, data));
+ return ret;
+}
+
+EAPI int livebox_access_event(struct livebox *handler, enum access_event_type type, double x, double y, ret_cb_t cb, void *data)
+{
+ int w = 1;
+ int h = 1;
+ char cmd[32] = { '\0', };
+ char *ptr = cmd;
+ int ret;
+
+ if (!handler) {
+ ErrPrint("Handler is NIL\n");
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (handler->state != CREATE || !handler->id) {
+ ErrPrint("Handler is not valid\n");
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (handler->access_event_cb) {
+ ErrPrint("Previous access event is not yet done\n");
+ return LB_STATUS_ERROR_BUSY;
+ }
+
+ if (type & ACCESS_EVENT_PD_MASK) {
+ if (!handler->is_pd_created) {
+ ErrPrint("PD is not created\n");
+ return LB_STATUS_ERROR_INVALID;
+ }
+ *ptr++ = 'p';
+ *ptr++ = 'd';
+ w = handler->pd.width;
+ h = handler->pd.height;
+ } else if (type & ACCESS_EVENT_LB_MASK) {
+ *ptr++ = 'l';
+ *ptr++ = 'b';
+ w = handler->lb.width;
+ h = handler->lb.height;
+ } else {
+ ErrPrint("Invalid event type\n");
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ switch (type & ~ACCESS_EVENT_PD_MASK) {
+ case ACCESS_EVENT_HIGHLIGHT:
+ strcpy(ptr, "_access_hl");
+ break;
+ case ACCESS_EVENT_HIGHLIGHT_NEXT:
+ strcpy(ptr, "_access_hl_next");
+ break;
+ case ACCESS_EVENT_HIGHLIGHT_PREV:
+ strcpy(ptr, "_access_hl_prev");
+ break;
+ case ACCESS_EVENT_ACTIVATE:
+ strcpy(ptr, "_access_activate");
+ break;
+ case ACCESS_EVENT_ACTION_DOWN:
+ strcpy(ptr, "_access_action_down");
+ break;
+ case ACCESS_EVENT_ACTION_UP:
+ strcpy(ptr, "_access_action_up");
+ break;
+ case ACCESS_EVENT_UNHIGHLIGHT:
+ strcpy(ptr, "_access_unhighlight");
+ break;
+ case ACCESS_EVENT_SCROLL_DOWN:
+ strcpy(ptr, "_access_scroll_down");
+ break;
+ case ACCESS_EVENT_SCROLL_MOVE:
+ strcpy(ptr, "_access_scroll_move");
+ break;
+ case ACCESS_EVENT_SCROLL_UP:
+ strcpy(ptr, "_access_scroll_up");
+ break;
+ default:
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (!cb) {
+ cb = default_access_event_cb;
+ }
+
+ ret = send_access_event(handler, cmd, x * w, y * h);
+ if (ret == LB_STATUS_SUCCESS) {
+ handler->access_event_cb = cb;
+ handler->access_event_cbdata = data;
+ }
+
+ return ret;
}
EAPI int livebox_content_event(struct livebox *handler, enum content_event_type type, double x, double y)
}
if (type & CONTENT_EVENT_MOUSE_MOVE) {
- if (fabs(x - handler->pd.x) < MINIMUM_EVENT && fabs(y - handler->pd.y) < MINIMUM_EVENT)
+ if (fabs(x - handler->pd.x) < MINIMUM_EVENT && fabs(y - handler->pd.y) < MINIMUM_EVENT) {
return LB_STATUS_ERROR_BUSY;
+ }
} else if (type & CONTENT_EVENT_MOUSE_SET) {
flag = 0;
}
}
*ptr++ = 'p';
*ptr++ = 'd';
- } else {
+ } else if (type & CONTENT_EVENT_LB_MASK) {
int flag = 1;
if (type & CONTENT_EVENT_MOUSE_MASK) {
if (!handler->lb.mouse_event) {
- ErrPrint("Box is not support the mouse event\n");
return LB_STATUS_ERROR_INVALID;
}
}
if (type & CONTENT_EVENT_MOUSE_MOVE) {
- if (fabs(x - handler->lb.x) < MINIMUM_EVENT && fabs(y - handler->lb.y) < MINIMUM_EVENT)
+ if (fabs(x - handler->lb.x) < MINIMUM_EVENT && fabs(y - handler->lb.y) < MINIMUM_EVENT) {
return LB_STATUS_ERROR_BUSY;
+ }
} else if (type & CONTENT_EVENT_MOUSE_SET) {
flag = 0;
}
}
*ptr++ = 'l';
*ptr++ = 'b';
+ } else {
+ ErrPrint("Invalid event type\n");
+ return LB_STATUS_ERROR_INVALID;
}
/*!
* Must be short than 29 bytes.
*/
- switch ((type & ~CONTENT_EVENT_PD_MASK)) {
- case CONTENT_EVENT_ACCESS_HIGHLIGHT | CONTENT_EVENT_ACCESS_MASK:
- strcpy(ptr, "_access_hl");
- break;
- case CONTENT_EVENT_ACCESS_HIGHLIGHT_PREV | CONTENT_EVENT_ACCESS_MASK:
- strcpy(ptr, "_access_hl_prev");
- break;
- case CONTENT_EVENT_ACCESS_HIGHLIGHT_NEXT | CONTENT_EVENT_ACCESS_MASK:
- strcpy(ptr, "_access_hl_next");
- break;
- case CONTENT_EVENT_ACCESS_ACTIVATE | CONTENT_EVENT_ACCESS_MASK:
- strcpy(ptr, "_access_activate");
- break;
- case CONTENT_EVENT_ACCESS_VALUE_CHANGE | CONTENT_EVENT_ACCESS_MASK:
- strcpy(ptr, "_access_value_change");
- break;
- case CONTENT_EVENT_ACCESS_SCROLL | CONTENT_EVENT_ACCESS_MASK:
- strcpy(ptr, "_access_scroll");
- break;
+ switch ((type & ~(CONTENT_EVENT_PD_MASK | CONTENT_EVENT_LB_MASK))) {
case CONTENT_EVENT_MOUSE_ENTER | CONTENT_EVENT_MOUSE_MASK:
strcpy(ptr, "_mouse_enter");
break;
return NULL;
}
- if (handler->filename)
+ if (handler->filename) {
return handler->filename;
+ }
/* Oooops */
return util_uri_to_path(handler->id);
return LB_STATUS_ERROR_INVALID;
}
- if (!w)
+ if (!w) {
w = &_w;
- if (!h)
+ }
+ if (!h) {
h = &_h;
+ }
if (!handler->is_pd_created) {
- DbgPrint("Buffer is not created yet [%dx%d]\n", *w, *h);
*w = handler->pd.default_width;
*h = handler->pd.default_height;
} else {
case _LB_TYPE_BUFFER:
case _LB_TYPE_SCRIPT:
if (!fb_is_created(handler->lb.data.fb)) {
- DbgPrint("Buffer is not created yet - reset size\n");
w = 0;
h = 0;
}
EAPI int livebox_set_group(struct livebox *handler, const char *cluster, const char *category, ret_cb_t cb, void *data)
{
struct packet *packet;
+ int ret;
if (!handler) {
ErrPrint("Handler is NIL\n");
return LB_STATUS_ERROR_FAULT;
}
- if (!cb)
+ if (!cb) {
cb = default_group_changed_cb;
+ }
+
+ ret = master_rpc_async_request(handler, packet, 0, set_group_ret_cb, NULL);
+ if (ret == LB_STATUS_SUCCESS) {
+ handler->group_changed_cb = cb;
+ handler->group_cbdata = data;
+ }
- return master_rpc_async_request(handler, packet, 0, set_group_ret_cb, create_cb_info(cb, data));
+ return ret;
}
EAPI int livebox_get_group(struct livebox *handler, char ** const cluster, char ** const category)
for (j = i = 0; i < NR_OF_SIZE_LIST; i++) {
if (handler->lb.size_list & (0x01 << i)) {
- if (j == *cnt)
+ if (j == *cnt) {
break;
+ }
size_list[j++] = (0x01 << i);
}
EAPI int livebox_delete_cluster(const char *cluster, ret_cb_t cb, void *data)
{
struct packet *packet;
+ struct cb_info *cbinfo;
+ int ret;
packet = packet_create("delete_cluster", "s", cluster);
if (!packet) {
return LB_STATUS_ERROR_FAULT;
}
- return master_rpc_async_request(NULL, packet, 0, delete_cluster_cb, create_cb_info(cb, data));
+ cbinfo = create_cb_info(cb, data);
+ if (!cbinfo) {
+ packet_destroy(packet);
+ return LB_STATUS_ERROR_FAULT;
+ }
+
+ ret = master_rpc_async_request(NULL, packet, 0, delete_cluster_cb, cbinfo);
+ if (ret < 0) {
+ destroy_cb_info(cbinfo);
+ }
+
+ return ret;
}
EAPI int livebox_delete_category(const char *cluster, const char *category, ret_cb_t cb, void *data)
{
struct packet *packet;
+ struct cb_info *cbinfo;
+ int ret;
packet = packet_create("delete_category", "ss", cluster, category);
if (!packet) {
return LB_STATUS_ERROR_FAULT;
}
- return master_rpc_async_request(NULL, packet, 0, delete_category_cb, create_cb_info(cb, data));
+ cbinfo = create_cb_info(cb, data);
+ if (!cbinfo) {
+ packet_destroy(packet);
+ return LB_STATUS_ERROR_FAULT;
+ }
+
+ ret = master_rpc_async_request(NULL, packet, 0, delete_category_cb, cbinfo);
+ if (ret < 0) {
+ destroy_cb_info(cbinfo);
+ }
+
+ return ret;
}
EAPI enum livebox_lb_type livebox_lb_type(struct livebox *handler)
{
const char *id;
id = fb_id(handler->lb.data.fb);
- if (id && !strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP)))
+ if (id && !strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP))) {
return LB_TYPE_PIXMAP;
+ }
}
return LB_TYPE_BUFFER;
case _LB_TYPE_TEXT:
{
const char *id;
id = fb_id(handler->pd.data.fb);
- if (id && !strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP)))
+ if (id && !strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP))) {
return PD_TYPE_PIXMAP;
+ }
}
return PD_TYPE_BUFFER;
default:
EAPI int livebox_acquire_lb_pixmap(struct livebox *handler, ret_cb_t cb, void *data)
{
struct packet *packet;
+ struct cb_info *cbinfo;
const char *id;
+ int ret;
if (!handler) {
ErrPrint("Handler is NIL\n");
}
id = fb_id(handler->lb.data.fb);
- if (!id || strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP)))
+ if (!id || strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP))) {
return LB_STATUS_ERROR_INVALID;
+ }
packet = packet_create("lb_acquire_pixmap", "ss", handler->pkgname, handler->id);
if (!packet) {
return LB_STATUS_ERROR_FAULT;
}
- return master_rpc_async_request(handler, packet, 0, pixmap_acquired_cb, create_cb_info(cb, data));
+ cbinfo = create_cb_info(cb, data);
+ if (!cbinfo) {
+ packet_destroy(packet);
+ return LB_STATUS_ERROR_FAULT;
+ }
+
+ ret = master_rpc_async_request(handler, packet, 0, lb_pixmap_acquired_cb, cbinfo);
+ if (ret < 0) {
+ destroy_cb_info(cbinfo);
+ }
+
+ return ret;
}
EAPI int livebox_release_lb_pixmap(struct livebox *handler, int pixmap)
{
struct packet *packet;
- if (!handler) {
- ErrPrint("Handler is NIL\n");
+ if (!handler || pixmap == 0) {
+ ErrPrint("Handler is NIL [%d]\n", pixmap);
return LB_STATUS_ERROR_INVALID;
}
EAPI int livebox_acquire_pd_pixmap(struct livebox *handler, ret_cb_t cb, void *data)
{
struct packet *packet;
+ struct cb_info *cbinfo;
const char *id;
+ int ret;
if (!handler) {
ErrPrint("Handler is NIL\n");
}
id = fb_id(handler->pd.data.fb);
- if (!id || strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP)))
+ if (!id || strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP))) {
return LB_STATUS_ERROR_INVALID;
+ }
packet = packet_create("pd_acquire_pixmap", "ss", handler->pkgname, handler->id);
if (!packet) {
return LB_STATUS_ERROR_FAULT;
}
- return master_rpc_async_request(handler, packet, 0, pixmap_acquired_cb, create_cb_info(cb, data));
+ cbinfo = create_cb_info(cb, data);
+ if (!cbinfo) {
+ packet_destroy(packet);
+ return LB_STATUS_ERROR_FAULT;
+ }
+
+ ret = master_rpc_async_request(handler, packet, 0, pd_pixmap_acquired_cb, cbinfo);
+ if (ret < 0) {
+ destroy_cb_info(cbinfo);
+ }
+
+ return ret;
}
EAPI int livebox_pd_pixmap(const struct livebox *handler)
{
struct packet *packet;
- if (!handler) {
- ErrPrint("Handler is NIL\n");
+ if (!handler || pixmap == 0) {
+ ErrPrint("Handler is NIL [%d]\n", pixmap);
return LB_STATUS_ERROR_INVALID;
}
EAPI int livebox_set_pinup(struct livebox *handler, int flag, ret_cb_t cb, void *data)
{
struct packet *packet;
+ int ret;
if (!handler) {
ErrPrint("Handler is NIL\n");
return LB_STATUS_ERROR_FAULT;
}
- if (!cb)
+ if (!cb) {
cb = default_pinup_cb;
+ }
+
+ ret = master_rpc_async_request(handler, packet, 0, pinup_done_cb, NULL);
+ if (ret == LB_STATUS_SUCCESS) {
+ handler->pinup_cb = cb;
+ handler->pinup_cbdata = data;
+ }
- return master_rpc_async_request(handler, packet, 0, pinup_done_cb, create_cb_info(cb, data));
+ return ret;
}
EAPI int livebox_is_pinned_up(struct livebox *handler)
return LB_STATUS_ERROR_INVALID;
}
- if (handler->state != CREATE || !handler->id)
+ if (handler->state != CREATE || !handler->id) {
return LB_STATUS_ERROR_INVALID;
+ }
return handler->is_pinned_up;
}
return LB_STATUS_ERROR_INVALID;
}
- if (handler->state != CREATE || !handler->id)
+ if (handler->state != CREATE || !handler->id) {
return LB_STATUS_ERROR_INVALID;
+ }
return handler->lb.pinup_supported;
}
return LB_STATUS_ERROR_INVALID;
}
- if (handler->state != CREATE)
+ if (handler->state != CREATE) {
return LB_STATUS_ERROR_INVALID;
+ }
handler->data = data;
return LB_STATUS_SUCCESS;
return NULL;
}
- if (handler->state != CREATE)
+ if (handler->state != CREATE) {
return NULL;
+ }
return handler->data;
}
return NULL;
}
- if (handler->state != CREATE)
+ if (handler->state != CREATE) {
return NULL;
+ }
return handler->content;
}
return NULL;
}
- if (handler->state != CREATE)
+ if (handler->state != CREATE) {
return NULL;
+ }
return handler->title;
}
EAPI int livebox_emit_text_signal(struct livebox *handler, const char *emission, const char *source, double sx, double sy, double ex, double ey, ret_cb_t cb, void *data)
{
struct packet *packet;
+ struct cb_info *cbinfo;
+ int ret;
if (!handler) {
ErrPrint("Handler is NIL\n");
return LB_STATUS_ERROR_INVALID;
}
- if (!emission)
+ if (!emission) {
emission = "";
+ }
- if (!source)
+ if (!source) {
source = "";
+ }
packet = packet_create("text_signal", "ssssdddd",
handler->pkgname, handler->id, emission, source, sx, sy, ex, ey);
return LB_STATUS_ERROR_FAULT;
}
- return master_rpc_async_request(handler, packet, 0, text_signal_cb, create_cb_info(cb, data));
+ cbinfo = create_cb_info(cb, data);
+ if (!cbinfo) {
+ packet_destroy(packet);
+ return LB_STATUS_ERROR_FAULT;
+ }
+
+ ret = master_rpc_async_request(handler, packet, 0, text_signal_cb, cbinfo);
+ if (ret < 0) {
+ destroy_cb_info(cbinfo);
+ }
+
+ return LB_STATUS_ERROR_FAULT;
}
EAPI int livebox_subscribe_group(const char *cluster, const char *category)
return LB_STATUS_ERROR_INVALID;
}
- if (handler->state != CREATE || !handler->id)
+ if (handler->state != CREATE || !handler->id) {
return LB_STATUS_ERROR_INVALID;
+ }
packet = packet_create_noack("update", "ss", handler->pkgname, handler->id);
if (!packet) {
return LB_STATUS_ERROR_INVALID;
}
- if (handler->state != CREATE || !handler->id)
+ if (handler->state != CREATE || !handler->id) {
return LB_STATUS_ERROR_INVALID;
+ }
if (!handler->is_user) {
/* System cluster livebox cannot be changed its visible states */
}
}
- DbgPrint("Change the visibility %d <> %d, %s\n", handler->visible, state, handler->id);
-
- if (handler->visible == state)
+ if (handler->visible == state) {
return LB_STATUS_ERROR_ALREADY;
+ }
packet = packet_create_noack("change,visibility", "ssi", handler->pkgname, handler->id, (int)state);
if (!packet) {
}
ret = master_rpc_request_only(handler, packet);
- if (ret == 0)
+ if (ret == 0) {
handler->visible = state;
+ }
return ret;
}
return LB_VISIBLE_ERROR;
}
- if (handler->state != CREATE || !handler->id)
+ if (handler->state != CREATE || !handler->id) {
return LB_VISIBLE_ERROR;
+ }
return handler->visible;
}
}
}
- if (handler->cluster)
+ if (handler->cluster) {
free(handler->cluster);
+ }
- if (handler->category)
+ if (handler->category) {
free(handler->category);
+ }
handler->cluster = pc;
handler->category = ps;
handler->lb.height = h;
}
+void lb_set_update_mode(struct livebox *handle, int active_mode)
+{
+ handle->is_active_update = active_mode;
+}
+
void lb_set_pdsize(struct livebox *handler, int w, int h)
{
handler->pd.width = w;
struct fault_info *info;
dlist_foreach_safe(s_info.fault_list, l, n, info) {
- if (info->handler(event, pkgname, file, func, info->user_data) == EXIT_FAILURE)
+ if (info->handler(event, pkgname, file, func, info->user_data) == EXIT_FAILURE) {
s_info.fault_list = dlist_remove(s_info.fault_list, l);
+ }
}
}
struct event_info *info;
dlist_foreach_safe(s_info.event_list, l, n, info) {
- if (info->handler(handler, event, info->user_data) == EXIT_FAILURE)
+ if (info->handler(handler, event, info->user_data) == EXIT_FAILURE) {
s_info.event_list = dlist_remove(s_info.event_list, l);
+ }
}
}
struct livebox *handler;
dlist_foreach(s_info.livebox_list, l, handler) {
- if (!handler->id)
+ if (!handler->id) {
continue;
+ }
- if (!strcmp(handler->pkgname, pkgname) && !strcmp(handler->id, id))
+ if (!strcmp(handler->pkgname, pkgname) && !strcmp(handler->id, id)) {
return handler;
+ }
}
return NULL;
struct livebox *handler;
dlist_foreach(s_info.livebox_list, l, handler) {
- if (handler->timestamp == timestamp)
+ if (handler->timestamp == timestamp) {
return handler;
+ }
}
return NULL;
*/
if (s_info.prevent_overwrite) {
new_path = strdup(path);
- if (!new_path)
+ if (!new_path) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
return new_path;
}
handler->filename = get_file_kept_in_safe(id);
if (!handler->filename) {
handler->filename = strdup(util_uri_to_path(id));
- if (!handler->filename)
+ if (!handler->filename) {
ErrPrint("Error: %s\n", strerror(errno));
+ }
}
handler->timestamp = timestamp;
void lb_set_auto_launch(struct livebox *handler, const char *auto_launch)
{
- if (!strlen(auto_launch))
+ if (!strlen(auto_launch)) {
return;
+ }
handler->lb.auto_launch = strdup(auto_launch);
- if (!handler->lb.auto_launch)
+ if (!handler->lb.auto_launch) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
void lb_set_priority(struct livebox *handler, double priority)
void lb_set_id(struct livebox *handler, const char *id)
{
- if (handler->id)
+ if (handler->id) {
free(handler->id);
+ }
handler->id = strdup(id);
- if (!handler->id)
+ if (!handler->id) {
ErrPrint("Error: %s\n", strerror(errno));
+ }
- if (handler->filename)
+ if (handler->filename) {
free(handler->filename);
+ }
handler->filename = get_file_kept_in_safe(id);
if (!handler->filename) {
handler->filename = strdup(util_uri_to_path(id));
- if (!handler->filename)
+ if (!handler->filename) {
ErrPrint("Error: %s\n", strerror(errno));
+ }
}
}
{
struct fb_info *fb;
- if (!handler)
+ if (!handler) {
return LB_STATUS_ERROR_INVALID;
+ }
fb = handler->lb.data.fb;
- if (fb && !strcmp(fb_id(fb), filename)) /*!< BUFFER is not changed, */
+ if (fb && !strcmp(fb_id(fb), filename)) { /*!< BUFFER is not changed, */
return LB_STATUS_SUCCESS;
+ }
handler->lb.data.fb = NULL;
if (!filename || filename[0] == '\0') {
- if (fb)
+ if (fb) {
fb_destroy(fb);
+ }
return LB_STATUS_SUCCESS;
}
handler->lb.data.fb = fb_create(filename, handler->lb.width, handler->lb.height);
if (!handler->lb.data.fb) {
ErrPrint("Faield to create a FB\n");
- if (fb)
+ if (fb) {
fb_destroy(fb);
+ }
return LB_STATUS_ERROR_FAULT;
}
- if (fb)
+ if (fb) {
fb_destroy(fb);
+ }
return LB_STATUS_SUCCESS;
}
{
struct fb_info *fb;
- if (!handler)
+ if (!handler) {
return LB_STATUS_ERROR_INVALID;
+ }
fb = handler->pd.data.fb;
if (fb && !strcmp(fb_id(fb), filename)) {
handler->pd.data.fb = NULL;
if (!filename || filename[0] == '\0') {
- if (fb)
+ if (fb) {
fb_destroy(fb);
+ }
return LB_STATUS_SUCCESS;
}
handler->pd.data.fb = fb_create(filename, handler->pd.width, handler->pd.height);
if (!handler->pd.data.fb) {
ErrPrint("Failed to create a FB\n");
- if (fb)
+ if (fb) {
fb_destroy(fb);
+ }
return LB_STATUS_ERROR_FAULT;
}
- if (fb)
+ if (fb) {
fb_destroy(fb);
+ }
return LB_STATUS_SUCCESS;
}
struct livebox *lb_ref(struct livebox *handler)
{
- if (!handler)
+ if (!handler) {
return NULL;
+ }
handler->refcnt++;
return handler;
struct livebox *lb_unref(struct livebox *handler)
{
- if (!handler)
+ if (!handler) {
return NULL;
+ }
handler->refcnt--;
- if (handler->refcnt > 0)
+ if (handler->refcnt > 0) {
return handler;
+ }
+
+ if (handler->created_cb) {
+ handler->created_cb(handler, LB_STATUS_ERROR_FAULT, handler->created_cbdata);
+ handler->created_cb = NULL;
+ handler->created_cbdata = NULL;
+ }
- if (handler->filename)
+ if (handler->deleted_cb) {
+ handler->deleted_cb(handler, LB_STATUS_ERROR_FAULT, handler->deleted_cbdata);
+ handler->deleted_cb = NULL;
+ handler->deleted_cbdata = NULL;
+ }
+
+ if (handler->pinup_cb) {
+ handler->pinup_cb(handler, LB_STATUS_ERROR_FAULT, handler->pinup_cbdata);
+ handler->pinup_cb = NULL;
+ handler->pinup_cbdata = NULL;
+ }
+
+ if (handler->group_changed_cb) {
+ handler->group_changed_cb(handler, LB_STATUS_ERROR_FAULT, handler->group_cbdata);
+ handler->group_changed_cb = NULL;
+ handler->group_cbdata = NULL;
+ }
+
+ if (handler->period_changed_cb) {
+ handler->period_changed_cb(handler, LB_STATUS_ERROR_FAULT, handler->period_cbdata);
+ handler->period_changed_cb = NULL;
+ handler->period_cbdata = NULL;
+ }
+
+ if (handler->size_changed_cb) {
+ handler->size_changed_cb(handler, LB_STATUS_ERROR_FAULT, handler->size_cbdata);
+ handler->size_changed_cb = NULL;
+ handler->size_cbdata = NULL;
+ }
+
+ if (handler->pd_created_cb) {
+ handler->pd_created_cb(handler, LB_STATUS_ERROR_FAULT, handler->pd_created_cbdata);
+ handler->pd_created_cb = NULL;
+ handler->pd_created_cbdata = NULL;
+ }
+
+ if (handler->pd_destroyed_cb) {
+ handler->pd_destroyed_cb(handler, LB_STATUS_ERROR_FAULT, handler->pd_destroyed_cbdata);
+ handler->pd_destroyed_cb = NULL;
+ handler->pd_destroyed_cbdata = NULL;
+ }
+
+ if (handler->update_mode_cb) {
+ handler->update_mode_cb(handler, LB_STATUS_ERROR_FAULT, handler->update_mode_cbdata);
+ handler->update_mode_cb = NULL;
+ handler->update_mode_cbdata = NULL;
+ }
+
+ if (handler->access_event_cb) {
+ handler->access_event_cb(handler, LB_ACCESS_STATUS_ERROR, handler->access_event_cbdata);
+ handler->access_event_cb = NULL;
+ handler->access_event_cbdata = NULL;
+ }
+
+ if (handler->filename) {
util_unlink(handler->filename);
+ }
dlist_remove_data(s_info.livebox_list, handler);
int lb_send_delete(struct livebox *handler, ret_cb_t cb, void *data)
{
struct packet *packet;
+ struct cb_info *cbinfo;
+ int ret;
if (!cb && !!data) {
ErrPrint("Invalid argument\n");
packet = packet_create("delete", "ss", handler->pkgname, handler->id);
if (!packet) {
ErrPrint("Failed to build a param\n");
- if (cb)
+ if (cb) {
cb(handler, LB_STATUS_ERROR_FAULT, data);
+ }
return LB_STATUS_ERROR_FAULT;
}
- if (!cb)
+ if (!cb) {
cb = default_delete_cb;
+ }
- return master_rpc_async_request(handler, packet, 0, del_ret_cb, create_cb_info(cb, data));
+ cbinfo = create_cb_info(cb, data);
+ if (!cbinfo) {
+ packet_destroy(packet);
+ return LB_STATUS_ERROR_FAULT;
+ }
+
+ ret = master_rpc_async_request(handler, packet, 0, del_ret_cb, cbinfo);
+ if (ret < 0) {
+ destroy_cb_info(cbinfo);
+ }
+
+ return ret;
}
EAPI int livebox_client_paused(void)