CONTENT_EVENT_MOUSE_SET = 0x00000020, /*!< LB mouse set auto event for livebox */
CONTENT_EVENT_MOUSE_UNSET = 0x00000040, /*!< LB mouse unset auto event for livebox */
- CONTENT_EVENT_ACCESS_HIGHLIGHT = 0x00000100, /*!< LB accessibility: Hightlight a object */
- CONTENT_EVENT_ACCESS_HIGHLIGHT_NEXT = 0x00000200, /*!< LB accessibility: Set highlight to next object */
- CONTENT_EVENT_ACCESS_HIGHLIGHT_PREV = 0x00000400, /*!< LB accessibility: Set highlight to prev object */
- CONTENT_EVENT_ACCESS_ACTIVATE = 0x00000800, /*!< LB accessibility activate */
- CONTENT_EVENT_ACCESS_VALUE_CHANGE = 0x00001000, /*!< LB accessibility up */
- CONTENT_EVENT_ACCESS_SCROLL = 0x00002000, /*!< LB accessibility down */
-
CONTENT_EVENT_KEY_DOWN = 0x00100000, /*!< LB key press */
CONTENT_EVENT_KEY_UP = 0x00200000, /*!< LB key release */
CONTENT_EVENT_KEY_MASK = 0x80000000,
- CONTENT_EVENT_ACCESS_MASK = 0x40000000,
CONTENT_EVENT_MOUSE_MASK = 0x20000000,
CONTENT_EVENT_PD_MASK = 0x10000000,
CONTENT_EVENT_LB_MASK = 0x00000000,
PD_MOUSE_SET = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_SET,
PD_MOUSE_UNSET = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_UNSET,
- LB_ACCESS_HIGHLIGHT = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_HIGHLIGHT,
- LB_ACCESS_HIGHLIGHT_NEXT = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_HIGHLIGHT_NEXT,
- LB_ACCESS_HIGHLIGHT_PREV = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_HIGHLIGHT_PREV,
- LB_ACCESS_ACTIVATE = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_ACTIVATE,
- LB_ACCESS_VALUE_CHANGE = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_VALUE_CHANGE,
- LB_ACCESS_SCROLL = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_SCROLL,
-
- PD_ACCESS_HIGHLIGHT = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_HIGHLIGHT,
- PD_ACCESS_HIGHLIGHT_NEXT = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_HIGHLIGHT_NEXT,
- PD_ACCESS_HIGHLIGHT_PREV = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_HIGHLIGHT_PREV,
- PD_ACCESS_ACTIVATE = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_ACTIVATE,
- PD_ACCESS_VALUE_CHANGE = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_VALUE_CHANGE,
- PD_ACCESS_SCROLL = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_ACCESS_MASK | CONTENT_EVENT_ACCESS_SCROLL,
-
LB_KEY_DOWN = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_DOWN,
LB_KEY_UP = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_UP,
CONTENT_EVENT_MAX = 0xFFFFFFFF,
};
+enum access_event_type {
+ ACCESS_EVENT_PD_MASK = 0x10000000,
+ ACCESS_EVENT_LB_MASK = 0x00000000,
+
+ ACCESS_EVENT_HIGHLIGHT = 0x00000100, /*!< LB accessibility: Hightlight a object */
+ ACCESS_EVENT_HIGHLIGHT_NEXT = 0x00000200, /*!< LB accessibility: Set highlight to next object */
+ ACCESS_EVENT_HIGHLIGHT_PREV = 0x00000400, /*!< LB accessibility: Set highlight to prev object */
+ ACCESS_EVENT_ACTIVATE = 0x00000800, /*!< LB accessibility activate */
+ ACCESS_EVENT_VALUE_CHANGE = 0x00001000, /*!< LB accessibility up */
+ ACCESS_EVENT_SCROLL = 0x00002000, /*!< LB accessibility down */
+
+ LB_ACCESS_HIGHLIGHT = ACCESS_EVENT_LB_MASK | ACCESS_EVENT_HIGHLIGHT,
+ LB_ACCESS_HIGHLIGHT_NEXT = ACCESS_EVENT_LB_MASK | ACCESS_EVENT_HIGHLIGHT_NEXT,
+ LB_ACCESS_HIGHLIGHT_PREV = ACCESS_EVENT_LB_MASK | ACCESS_EVENT_HIGHLIGHT_PREV,
+ LB_ACCESS_ACTIVATE = ACCESS_EVENT_LB_MASK | ACCESS_EVENT_ACTIVATE,
+ LB_ACCESS_VALUE_CHANGE = ACCESS_EVENT_LB_MASK | ACCESS_EVENT_VALUE_CHANGE,
+ LB_ACCESS_SCROLL = ACCESS_EVENT_LB_MASK | ACCESS_EVENT_SCROLL,
+
+ PD_ACCESS_HIGHLIGHT = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_HIGHLIGHT,
+ PD_ACCESS_HIGHLIGHT_NEXT = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_HIGHLIGHT_NEXT,
+ PD_ACCESS_HIGHLIGHT_PREV = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_HIGHLIGHT_PREV,
+ PD_ACCESS_ACTIVATE = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_ACTIVATE,
+ PD_ACCESS_VALUE_CHANGE = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_VALUE_CHANGE,
+ PD_ACCESS_SCROLL = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_SCROLL,
+};
+
/* Exported to user app */
enum livebox_lb_type {
LB_TYPE_IMAGE = 0x01, /*!< Contents of a livebox is based on the image file */
LB_EVENT_HOLD_SCROLL, /*!< If the screen should be freezed */
LB_EVENT_RELEASE_SCROLL, /*!< If the screen can be scrolled */
+ LB_EVENT_LB_UPDATE_BEGIN,
+ LB_EVENT_LB_UPDATE_END,
+
+ LB_EVENT_PD_UPDATE_BEGIN,
+ LB_EVENT_PD_UPDATE_END,
+
+ LB_EVENT_UPDATE_MODE_CHANGED,
+
LB_EVENT_IGNORED, /*!< Request is ignored */
};
* \param[in] type
* \param[in] x
* \param[in] y
+ * \return
*/
extern int livebox_content_event(struct livebox *handler, enum content_event_type type, double x, double y);
/*!
+ * \brief Send the access event(for buffer type) to provider(livebox).
+ * \param[in] handler
+ * \param[in] access_event_type
+ * \param[in] x
+ * \param[in] y
+ * \param[in] cb
+ * \param[in] data
+ * \return
+ */
+extern int livebox_access_event(struct livebox *handler, enum access_event_type type, double x, double y, ret_cb_t cb, void *data);
+
+/*!
* \brief Do pin up or not.
* \param[in] handler
* \param[in] flag
*/
extern enum livebox_visible_state livebox_visibility(struct livebox *handler);
+/*!
+ * \brief Set the update mode of current livebox
+ * if you set 1 for active update mode, you should get buffer without updated event from provider.
+ * But is passive mode, you have to update content of a box when you get updated event.
+ * Default is Passive mode.
+ * \param[in] handler Handler of a livebox
+ * \param[in] active_update 1 means active update, 0 means passive update (default)
+ * \param[in] cb Result callback function
+ * \param[in] data Callback data
+ * \return int
+ */
+extern int livebox_set_update_mode(struct livebox *handler, int active_update, ret_cb_t cb, void *data);
+
+/*!
+ * \brief Is this box in the active update mode?
+ * \param[in] handler HAndler of a livebox
+ * \return int 0 if passive mode or 1 if active mode or error code
+ */
+extern int livebox_is_active_update(struct livebox *handler);
+
#ifdef __cplusplus
}
#endif
goto out;
}
+ DbgPrint("[HOLD] %s %d\n", id, seize);
lb_invoke_event_handler(handler, seize ? LB_EVENT_HOLD_SCROLL : LB_EVENT_RELEASE_SCROLL);
out:
return NULL;
}
+static struct packet *master_lb_update_begin(pid_t pid, int handle, const struct packet *packet)
+{
+ struct livebox *handler;
+ const char *pkgname;
+ const char *id;
+ const char *content;
+ const char *title;
+ const char *fbfile;
+ double priority;
+ int ret;
+
+ ret = packet_get(packet, "ssdsss", &pkgname, &id, &priority, &content, &title, &fbfile);
+ if (ret != 6) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ handler = lb_find_livebox(pkgname, id);
+ if (!handler) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ goto out;
+ }
+
+ if (handler->state != CREATE) {
+ DbgPrint("(%s) is not created\n", id);
+ goto out;
+ }
+
+ lb_set_priority(handler, priority);
+ lb_set_content(handler, content);
+ lb_set_title(handler, title);
+
+ /*!
+ * \NOTE
+ * Width & Height is not changed in this case.
+ * If the active update is began, the size should not be changed,
+ * And if the size is changed, the provider should finish the updating first.
+ * And then begin updating again after change its size.
+ */
+ if (lb_get_lb_fb(handler)) {
+ lb_set_lb_fb(handler, fbfile);
+
+ ret = fb_sync(lb_get_lb_fb(handler));
+ if (ret != LB_STATUS_SUCCESS)
+ ErrPrint("Failed to do sync FB (%s - %s) (%d)\n", pkgname, fbfile, ret);
+ else
+ lb_invoke_event_handler(handler, LB_EVENT_LB_UPDATE_BEGIN);
+ } else {
+ ErrPrint("Invalid request[%s], %s\n", id, fbfile);
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *master_pd_update_begin(pid_t pid, int handle, const struct packet *packet)
+{
+ struct livebox *handler;
+ const char *pkgname;
+ const char *id;
+ const char *fbfile;
+ int ret;
+
+ ret = packet_get(packet, "sss", &pkgname, &id, &fbfile);
+ if (ret != 2) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ handler = lb_find_livebox(pkgname, id);
+ if (!handler) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ goto out;
+ }
+
+ if (handler->state != CREATE) {
+ DbgPrint("[%s] is not created\n", id);
+ goto out;
+ }
+
+ if (lb_get_pd_fb(handler)) {
+ lb_set_lb_fb(handler, fbfile);
+
+ ret = fb_sync(lb_get_lb_fb(handler));
+ if (ret != LB_STATUS_SUCCESS)
+ ErrPrint("Failed to do sync FB (%s - %s) (%d)\n", pkgname, fbfile, ret);
+ else
+ lb_invoke_event_handler(handler, LB_EVENT_PD_UPDATE_BEGIN);
+ } else {
+ ErrPrint("Invalid request[%s], %s\n", id, fbfile);
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *master_lb_update_end(pid_t pid, int handle, const struct packet *packet)
+{
+ struct livebox *handler;
+ const char *pkgname;
+ const char *id;
+ int ret;
+
+ ret = packet_get(packet, "ss", &pkgname, &id);
+ if (ret != 2) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ handler = lb_find_livebox(pkgname, id);
+ if (!handler) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ goto out;
+ }
+
+ if (handler->state != CREATE) {
+ DbgPrint("[%s] is not created\n", id);
+ goto out;
+ }
+
+ if (lb_get_lb_fb(handler)) {
+ lb_invoke_event_handler(handler, LB_EVENT_LB_UPDATE_END);
+ } else {
+ ErrPrint("Invalid request[%s]\n", id);
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *master_access_status(pid_t pid, int handle, const struct packet *packet)
+{
+ struct livebox *handler;
+ const char *pkgname;
+ const char *id;
+ int ret;
+ int status;
+
+ ret = packet_get(packet, "ssi", &pkgname, &id, &status);
+ if (ret != 3) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ handler = lb_find_livebox(pkgname, id);
+ if (!handler) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ goto out;
+ }
+
+ if (handler->state != CREATE) {
+ DbgPrint("[%s] is not created\n", id);
+ goto out;
+ }
+
+ DbgPrint("Access status: %d\n", status);
+
+ if (handler->access_event_cb) {
+ handler->access_event_cb(handler, status, handler->access_event_cbdata);
+ handler->access_event_cb = NULL;
+ handler->access_event_cbdata = NULL;
+ } else {
+ ErrPrint("Invalid event[%s]\n", id);
+ }
+out:
+ return NULL;
+}
+
+static struct packet *master_pd_update_end(pid_t pid, int handle, const struct packet *packet)
+{
+ struct livebox *handler;
+ const char *pkgname;
+ const char *id;
+ int ret;
+
+ ret = packet_get(packet, "ss", &pkgname, &id);
+ if (ret != 2) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ handler = lb_find_livebox(pkgname, id);
+ if (!handler) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ goto out;
+ }
+
+ if (handler->state != CREATE) {
+ DbgPrint("[%s] is not created\n", id);
+ goto out;
+ }
+
+ if (lb_get_lb_fb(handler)) {
+ lb_invoke_event_handler(handler, LB_EVENT_PD_UPDATE_END);
+ } else {
+ ErrPrint("Invalid request[%s]", id);
+ }
+
+out:
+ return NULL;
+}
+
static struct packet *master_lb_updated(pid_t pid, int handle, const struct packet *packet)
{
const char *pkgname;
} else if (lb_get_lb_fb(handler)) {
lb_set_lb_fb(handler, fbfile);
ret = fb_sync(lb_get_lb_fb(handler));
- if (ret < 0)
+ if (ret != LB_STATUS_SUCCESS)
ErrPrint("Failed to do sync FB (%s - %s) (%d)\n", pkgname, util_basename(util_uri_to_path(id)), ret);
} else {
- ret = 0;
+ ret = LB_STATUS_SUCCESS;
}
- if (ret == 0)
+ if (ret == LB_STATUS_SUCCESS)
lb_invoke_event_handler(handler, LB_EVENT_LB_UPDATED);
out:
return NULL;
}
+static struct packet *master_update_mode(pid_t pid, int handle, const struct packet *packet)
+{
+ struct livebox *handler;
+ const char *pkgname;
+ const char *id;
+ int active_mode;
+ int status;
+ int ret;
+
+ if (!packet) {
+ ErrPrint("Invalid packet\n");
+ goto out;
+ }
+
+ ret = packet_get(packet, "ssii", &pkgname, &id, &status, &active_mode);
+ if (ret != 4) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ DbgPrint("Update mode is changed: %d, %d, %s\n", status, active_mode, id);
+
+ handler = lb_find_livebox(pkgname, id);
+ if (!handler) {
+ ErrPrint("Livebox(%s) is not found\n", id);
+ goto out;
+ }
+
+ if (handler->state != CREATE) {
+ ErrPrint("Livebox(%s) is not created yet\n", id);
+ goto out;
+ }
+
+ if (status == LB_STATUS_SUCCESS)
+ lb_set_update_mode(handler, active_mode);
+
+ if (handler->update_mode_cb) {
+ handler->update_mode_cb(handler, status, handler->update_mode_cbdata);
+
+ handler->update_mode_cb = NULL;
+ handler->update_mode_cbdata = NULL;
+ } else {
+ lb_invoke_event_handler(handler, LB_EVENT_UPDATE_MODE_CHANGED);
+ }
+
+out:
+ return NULL;
+}
+
static struct packet *master_size_changed(pid_t pid, int handle, const struct packet *packet)
{
struct livebox *handler;
.cmd = "scroll",
.handler = master_hold_scroll,
},
+
+ {
+ .cmd = "update_mode",
+ .handler = master_update_mode,
+ },
+
+ {
+ .cmd = "lb_update_begin",
+ .handler = master_lb_update_begin,
+ },
+ {
+ .cmd = "lb_update_end",
+ .handler = master_lb_update_end,
+ },
+
+ {
+ .cmd = "pd_update_begin",
+ .handler = master_pd_update_begin,
+ },
+ {
+ .cmd = "pd_update_end",
+ .handler = master_pd_update_end,
+ },
+
+ {
+ .cmd = "access_status",
+ .handler = master_access_status,
+ },
+
{
.cmd = NULL,
.handler = NULL,
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 update_mode_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;
+ }
+
+ if (ret < 0) {
+ DbgPrint("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 {
+ if (ret < 0) {
DbgPrint("Resize request is failed: %d\n", ret);
- cb(handler, ret, cbdata);
+ goto errout;
}
+
+ DbgPrint("Resize request is successfully sent\n");
+ 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)
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;
+
+ DbgPrint("Succeed to send period change request, waiting result\n");
+ 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)
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) {
+ if (ret < 0) {
DbgPrint("Failed to create a PD\n");
- cb(handler, ret, cbdata);
+ 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)
static void pinup_done_cb(struct livebox *handler, const struct packet *result, void *data)
{
int ret;
- ret_cb_t cb;
- void *cbdata;
- struct cb_info *info = data;
- 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) {
+ goto errout;
+ }
- if (!result)
+ 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;
- else if (packet_get(result, "i", &ret) != 1)
+ return;
+ }
+
+ if (packet_get(result, "i", &ret) != 1) {
ret = LB_STATUS_ERROR_INVALID;
+ return;
+ }
- if (ret == 0) {
- handler->pinup_cb = cb;
- handler->pinup_cbdata = cbdata;
- } else if (cb) {
- cb(handler, ret, cbdata);
+ if (ret != LB_STATUS_SUCCESS) {
+ goto errout;
}
+
+ DbgPrint("Access event is successfully sent. waiting result\n");
+ 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;
+ }
+
+ DbgPrint("Send: %dx%d\n", x, y);
+
+ 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)
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;
}
- 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);
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");
if (!cb)
cb = default_period_changed_cb;
- return master_rpc_async_request(handler, packet, 0, period_ret_cb, create_cb_info(cb, data));
+ handler->period_changed_cb = cb;
+ handler->period_cbdata = data;
+
+ ret = master_rpc_async_request(handler, packet, 0, period_ret_cb, NULL);
+ if (ret < 0) {
+ handler->period_changed_cb = NULL;
+ handler->period_cbdata = NULL;
+ }
+
+ return ret;
}
EAPI int livebox_del(struct livebox *handler, ret_cb_t cb, void *data)
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;
+
+ handler->update_mode_cb = cb;
+ handler->update_mode_cbdata = data;
+
+ ret = master_rpc_async_request(handler, packet, 0, update_mode_cb, NULL);
+ if (ret < 0) {
+ handler->update_mode_cb = NULL;
+ handler->update_mode_cbdata = NULL;
+ }
+
+ 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");
if (!cb)
cb = default_lb_size_changed_cb;
- return master_rpc_async_request(handler, packet, 0, resize_cb, create_cb_info(cb, data));
+ handler->size_changed_cb = cb;
+ handler->size_cbdata = data;
+
+ ret = master_rpc_async_request(handler, packet, 0, resize_cb, NULL);
+ if (ret < 0) {
+ handler->size_changed_cb = NULL;
+ handler->size_cbdata = NULL;
+ }
+
+ return ret;
}
EAPI int livebox_click(struct livebox *handler, double x, double y)
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");
}
if (!cb)
- handler->pd_created_cb = default_pd_created_cb;
+ cb = default_pd_created_cb;
+
+ handler->pd_created_cb = cb;
+ handler->pd_created_cbdata = data;
+
+ ret = master_rpc_async_request(handler, packet, 0, pd_create_cb, NULL);
+ if (ret < 0) {
+ handler->pd_created_cb = NULL;
+ handler->pd_created_cbdata = NULL;
+ }
- 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)
EAPI int livebox_activate(const char *pkgname, ret_cb_t cb, void *data)
{
struct packet *packet;
+ struct cb_info *cbinfo;
+ int ret;
if (!pkgname)
return LB_STATUS_ERROR_INVALID;
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");
if (!cb)
cb = default_pd_destroyed_cb;
- return master_rpc_async_request(handler, packet, 0, pd_destroy_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_destroy_cb, cbinfo);
+ if (ret < 0)
+ destroy_cb_info(cbinfo);
+
+ 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_VALUE_CHANGE:
+ strcpy(ptr, "_access_value_change");
+ break;
+ case ACCESS_EVENT_SCROLL:
+ strcpy(ptr, "_access_scroll");
+ break;
+ default:
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (!cb)
+ cb = default_access_event_cb;
+
+ handler->access_event_cb = cb;
+ handler->access_event_cbdata = data;
+
+ ret = send_access_event(handler, cmd, x * w, y * h);
+ if (ret < 0) {
+ handler->access_event_cb = NULL;
+ handler->access_event_cbdata = NULL;
+ }
+
+ return ret;
}
EAPI int livebox_content_event(struct livebox *handler, enum content_event_type type, double x, double y)
* 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;
case CONTENT_EVENT_MOUSE_ENTER | CONTENT_EVENT_MOUSE_MASK:
strcpy(ptr, "_mouse_enter");
break;
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");
if (!cb)
cb = default_group_changed_cb;
- return master_rpc_async_request(handler, packet, 0, set_group_ret_cb, create_cb_info(cb, data));
+ handler->group_changed_cb = cb;
+ handler->group_cbdata = data;
+
+ ret = master_rpc_async_request(handler, packet, 0, set_group_ret_cb, NULL);
+ if (ret < 0) {
+ handler->group_changed_cb = NULL;
+ handler->group_cbdata = NULL;
+ }
+
+ return ret;
}
EAPI int livebox_get_group(struct livebox *handler, char ** const cluster, char ** const category)
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)
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");
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, pixmap_acquired_cb, cbinfo);
+ if (ret < 0)
+ destroy_cb_info(cbinfo);
+
+ return ret;
}
EAPI int livebox_release_lb_pixmap(struct livebox *handler, int pixmap)
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");
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, pixmap_acquired_cb, cbinfo);
+ if (ret < 0)
+ destroy_cb_info(cbinfo);
+
+ return ret;
}
EAPI int livebox_pd_pixmap(const struct livebox *handler)
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");
if (!cb)
cb = default_pinup_cb;
- return master_rpc_async_request(handler, packet, 0, pinup_done_cb, create_cb_info(cb, data));
+ handler->pinup_cb = cb;
+ handler->pinup_cbdata = data;
+
+ ret = master_rpc_async_request(handler, packet, 0, pinup_done_cb, NULL);
+ if (ret < 0) {
+ handler->pinup_cb = NULL;
+ handler->pinup_cbdata = NULL;
+ }
+
+ return ret;
}
EAPI int livebox_is_pinned_up(struct livebox *handler)
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_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)
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;
if (handler->refcnt > 0)
return handler;
+ if (handler->created_cb) {
+ DbgPrint("Clear created event callback\n");
+ handler->created_cb(handler, LB_STATUS_ERROR_FAULT, handler->created_cbdata);
+ handler->created_cb = NULL;
+ handler->created_cbdata = NULL;
+ }
+
+ if (handler->deleted_cb) {
+ DbgPrint("Clear deleted event callback\n");
+ handler->deleted_cb(handler, LB_STATUS_ERROR_FAULT, handler->deleted_cbdata);
+ handler->deleted_cb = NULL;
+ handler->deleted_cbdata = NULL;
+ }
+
+ if (handler->pinup_cb) {
+ DbgPrint("Clear pinup event callback\n");
+ handler->pinup_cb(handler, LB_STATUS_ERROR_FAULT, handler->pinup_cbdata);
+ handler->pinup_cb = NULL;
+ handler->pinup_cbdata = NULL;
+ }
+
+ if (handler->group_changed_cb) {
+ DbgPrint("Clear group changed event callback\n");
+ 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) {
+ DbgPrint("Clear period changed event callback\n");
+ 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) {
+ DbgPrint("Clear size changed event callback\n");
+ 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) {
+ DbgPrint("Clear pd created event callback\n");
+ 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) {
+ DbgPrint("Clear pd destroyed event callback\n");
+ 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) {
+ DbgPrint("Clear update mode callback\n");
+ 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) {
+ DbgPrint("Clear access status callback\n");
+ handler->access_event_cb(handler, LB_STATUS_ERROR_FAULT, handler->access_event_cbdata);
+ handler->access_event_cb = NULL;
+ handler->access_event_cbdata = NULL;
+ }
+
if (handler->filename)
util_unlink(handler->filename);
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");
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)