#include "livebox_internal.h"
#include "dbus.h"
#include "desc_parser.h"
-
-#define DEFAULT_TTL 5
+#include "master_rpc.h"
static struct info {
GDBusNodeInfo *node_info;
GDBusProxy *proxy;
- struct dlist *cmd_list;
- guint cmd_timer;
guint recon_timer;
guint reg_id;
+ guint reacquire_timer;
const gchar *xml_data;
} s_info = {
.proxy = NULL,
- .cmd_list = NULL,
- .cmd_timer = 0,
.recon_timer = 0,
+ .reacquire_timer = 0,
.reg_id = 0,
.node_info = NULL,
.xml_data = "<node>"
" <method name='deleted'>"
" <arg type='s' name='pkgname' direction='in' />"
" <arg type='s' name='filename' direction='in' />"
+ " <arg type='d' name='timestamp' direction='in' />"
" <arg type='i' name='result' direction='out' />"
" </method>"
" <method name='lb_updated'>"
"</node>",
};
-struct cmd_item {
- int ttl;
- char *funcname;
- GVariant *param;
- struct livebox *handler;
- void (*ret_cb)(struct livebox *handler, int ret, void *data);
- void *data;
-};
-
-GDBusProxy *dbus_get_proxy(void)
+GDBusProxy *dbus_proxy(void)
{
return s_info.proxy;
}
-static inline int send_acquire(void)
-{
- GVariant *result;
- GError *err;
- static int sent = 0;
-
- if (sent == 1)
- return 0;
-
- err = NULL;
- result = g_dbus_proxy_call_sync(s_info.proxy, "acquire", g_variant_new("(i)", getpid()),
- G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL, &err);
- if (!result) {
- if (err) {
- ErrPrint("acquire Error: %s\n", err->message);
- g_error_free(err);
- }
-
- ErrPrint("Failed to send 'acquire'\n");
- return -EIO;
- }
-
- g_variant_unref(result);
- sent = 1;
- return 0;
-}
-
-static inline int send_release(void)
-{
- GVariant *result;
- GError *err;
-
- err = NULL;
- result = g_dbus_proxy_call_sync(s_info.proxy, "release", g_variant_new("(i)", getpid()),
- G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL, &err);
-
- if (!result) {
- if (err) {
- ErrPrint("release Error: %s\n", err->message);
- g_error_free(err);
- }
-
- return -EIO;
- }
-
- g_variant_unref(result);
- return 0;
-}
-
-static void on_signal(GDBusProxy *proxy, gchar *sender, gchar *signame, GVariant *param, gpointer data)
-{
- DbgPrint("Sender: %s\n", sender);
- DbgPrint("SigName: %s\n", signame);
-}
-
-static void done_cb(GDBusProxy *proxy, GAsyncResult *res, void *data)
-{
- GVariant *result;
- GError *err;
- int r;
- struct cmd_item *item;
-
- item = data;
-
- err = NULL;
- result = g_dbus_proxy_call_finish(proxy, res, &err);
- if (!result) {
- if (err) {
- ErrPrint("%s Error: %s\n", item->funcname, err->message);
- g_error_free(err);
- }
-
- /*! \NOTE:
- * Release resource even if
- * we failed to finish the method call
- */
- item->ttl--;
- if (item->ttl > 0) {
- s_info.cmd_list = dlist_prepend(s_info.cmd_list, item);
- return;
- }
-
- goto out;
- }
-
- g_variant_get(result, "(i)", &r);
- g_variant_unref(result);
-
- DbgPrint("%s Returns: %d, handler: %p\n", item->funcname, r, item->handler);
- if (item->ret_cb)
- item->ret_cb(item->handler, r, item->data);
-
-out:
- if (item->handler)
- lb_unref(item->handler);
- /* Decreate the item->param's refernece counter now. */
- g_variant_unref(item->param);
- free(item->funcname);
- free(item);
-}
-
-static gboolean dbus_reconnect_cb(gpointer user_data)
-{
- dbus_init();
- s_info.recon_timer = 0;
- return FALSE;
-}
-
-static gboolean cmd_consumer(gpointer user_data)
-{
- struct dlist *l;
- struct cmd_item *item;
-
- if (!s_info.proxy) {
- ErrPrint("Proxy is not valid yet, try again after 10ms\n");
- return TRUE;
- }
-
- if (send_acquire() != 0) {
- ErrPrint("Server is not ready to make connection, try again after 10ms\n");
- return TRUE;
- }
-
- l = dlist_nth(s_info.cmd_list, 0);
- if (l) {
- item = dlist_data(l);
-
- /*!
- * \NOTE:
- * Item will be deleted in the "done_cb"
- *
- * item->param be release by the g_dbus_proxy_call
- * so to use it again from the done_cb function,
- * increate the reference counter of the item->param
- */
- g_dbus_proxy_call(s_info.proxy,
- item->funcname,
- g_variant_ref(item->param),
- G_DBUS_CALL_FLAGS_NO_AUTO_START,
- -1, NULL, (GAsyncReadyCallback)done_cb, item);
-
- s_info.cmd_list = dlist_remove(s_info.cmd_list, l);
- }
-
- if (!s_info.cmd_list) {
- s_info.cmd_timer = 0;
- return FALSE;
- }
-
- return TRUE;
-}
-
static void method_fault_package(GDBusMethodInvocation *inv, GVariant *param)
{
const char *pkgname;
const char *filename;
const char *function;
+ char *_pkgname;
+ char *_filename;
+ char *_function;
g_variant_get(param, "(&s&s&s)", &pkgname, &filename, &function);
- DbgPrint("%s(%s) is deactivated\n", pkgname, filename);
- lb_invoke_fault_handler("deactivated", pkgname, filename, function);
+ _pkgname = strdup(pkgname);
+ _filename = strdup(filename);
+ _function = strdup(function);
+ DbgPrint("%s(%s) is deactivated\n", pkgname, filename);
g_dbus_method_invocation_return_value(inv, g_variant_new("(i)", 0));
+
+ lb_invoke_fault_handler("deactivated", _pkgname, _filename, _function);
+ free(_pkgname);
+ free(_filename);
+ free(_function);
}
static void method_pd_updated(GDBusMethodInvocation *inv, GVariant *param)
handler = lb_find_livebox(pkgname, filename);
if (!handler) {
- ret = -ENOENT;
- goto out;
- }
-
- if (handler->magic != 0xbeefbeef) {
- ErrPrint("Handler is not valid. magic: %lu\n", handler->magic);
- ret = 0;
- goto out;
+ g_dbus_method_invocation_return_value(inv, g_variant_new("(i)", -ENOENT));
+ return;
}
- if (handler->deleted != NOT_DELETED) {
+ if (handler->state == DELETE) {
/*!
* \note
* This handler is already deleted by the user.
* So don't try to notice anything about this anymore.
* Just ignore all events.
*/
- ret = 0;
- goto out;
+ g_dbus_method_invocation_return_value(inv, g_variant_new("(i)", 0));
+ return;
}
DbgPrint("Size of a PD is updated to [%dx%d]\n", pd_w, pd_h);
if (lb_text_pd(handler)) {
ret = parse_desc(handler, filename, 1);
+ g_dbus_method_invocation_return_value(inv, g_variant_new("(i)", ret));
} else {
if (lb_get_pd_fb(handler)) {
lb_update_pd_fb(handler, pd_w, pd_h);
* The return value of lb_get_pd_fb function can be change,
* So call lb_get_pd_fb again to get newly allocated pd buffer
*/
- fb_sync(lb_get_pd_fb(handler));
+ ret = fb_sync(lb_get_pd_fb(handler));
+ if (ret < 0) {
+ g_dbus_method_invocation_return_value(inv, g_variant_new("(i)", ret));
+ return;
+ }
}
+ g_dbus_method_invocation_return_value(inv, g_variant_new("(i)", 0));
lb_invoke_event_handler(handler, "pd,updated");
- ret = 0;
}
-out:
- g_dbus_method_invocation_return_value(inv, g_variant_new("(i)", ret));
}
static void method_lb_updated(GDBusMethodInvocation *inv, GVariant *param)
{
const char *pkgname;
const char *filename;
- int ret;
struct livebox *handler;
int lb_w;
int lb_h;
handler = lb_find_livebox(pkgname, filename);
if (!handler) {
- ret = -ENOENT;
- goto out;
- }
-
- if (handler->magic != 0xbeefbeef) {
- ErrPrint("Handler is not valid. magic: %lu\n", handler->magic);
- ret = 0;
- goto out;
+ g_dbus_method_invocation_return_value(inv, g_variant_new("(i)", -ENOENT));
+ return;
}
- if (handler->deleted != NOT_DELETED) {
+ if (handler->state == DELETE) {
/*!
* \note
* Already deleted by the user.
* Don't try to notice anything with this, Just ignore all events
* Beacuse the user doesn't wants know about this anymore
*/
- ret = 0;
- goto out;
+ g_dbus_method_invocation_return_value(inv, g_variant_new("(i)", 0));
+ return;
}
lb_set_priority(handler, priority);
lb_set_size(handler, lb_w, lb_h);
if (lb_text_lb(handler)) {
+ int ret;
ret = parse_desc(handler, filename, 0);
+ g_dbus_method_invocation_return_value(inv, g_variant_new("(i)", ret));
} else {
if (lb_get_lb_fb(handler)) {
+ int ret;
lb_update_lb_fb(handler, lb_w, lb_h);
- fb_sync(lb_get_lb_fb(handler));
+ ret = fb_sync(lb_get_lb_fb(handler));
+ if (ret < 0) {
+ g_dbus_method_invocation_return_value(inv, g_variant_new("(i)", ret));
+ return;
+ }
}
DbgPrint("%s(%s) is updated\n", handler->pkgname, handler->filename);
+ g_dbus_method_invocation_return_value(inv, g_variant_new("(i)", 0));
+
lb_invoke_event_handler(handler, "lb,updated");
- ret = 0;
}
-
-out:
- g_dbus_method_invocation_return_value(inv, g_variant_new("(i)", ret));
}
static void method_created(GDBusMethodInvocation *inv, GVariant *param)
{
struct livebox *handler;
- const char *pkgname;
- const char *filename;
+
int lb_w;
int lb_h;
int pd_w;
int pd_h;
+ const char *pkgname;
+ const char *filename;
+
const char *content;
const char *cluster;
const char *category;
const char *lb_fname;
const char *pd_fname;
+
+ char *_content;
+ char *_cluster;
+ char *_category;
+ char *_lb_fname;
+ char *_pd_fname;
+
double timestamp;
int auto_launch;
- int ret;
double priority;
int size_list;
int user;
handler = lb_new_livebox(pkgname, filename);
if (!handler) {
ErrPrint("Failed to create a new livebox\n");
- ret = -EFAULT;
- goto out;
+ g_dbus_method_invocation_return_value(inv, g_variant_new("(i)", -EFAULT));
+ return;
}
} else {
- if (handler->magic != 0xbeefbeef) {
- ErrPrint("Handler is not valid. magic: %lu\n", handler->magic);
- ret = -EINVAL;
- goto out;
- }
-
lb_set_filename(handler, filename);
- if (handler->deleted != NOT_DELETED) {
- /*!
- * \note
- * before get this created event,
- * user delete this already.
- * So user doesn't wants to know about this anymore
- * just ignore created events
- */
-
- if (handler->deleted == DELETE_ALL)
- lb_send_delete(handler);
-
- /*!
- * \note
- * This will make the method_delete function could not
- * find the handler object if the handler->deleted == DELETE_ALL
- * So the method_delete function will return -ENOENT
- */
- lb_unref(handler);
- ret = 0;
- goto out;
+ if (handler->state == DELETE) {
+ lb_send_delete(handler);
+ g_dbus_method_invocation_return_value(inv, g_variant_new("(i)", 0));
+ return;
}
}
+ _lb_fname = strdup(lb_fname);
+ _pd_fname = strdup(pd_fname);
+ _cluster = strdup(cluster);
+ _category = strdup(category);
+ _content = strdup(content);
+ g_dbus_method_invocation_return_value(inv, g_variant_new("(i)", 0));
+
lb_set_size(handler, lb_w, lb_h);
- lb_set_lb_fb(handler, lb_fname);
+ lb_set_lb_fb(handler, _lb_fname);
+ free(_lb_fname);
lb_set_pdsize(handler, pd_w, pd_h);
- lb_set_pd_fb(handler, pd_fname);
+ lb_set_pd_fb(handler, _pd_fname);
+ free(_pd_fname);
lb_set_priority(handler, priority);
lb_set_size_list(handler, size_list);
- lb_set_group(handler, cluster, category);
- lb_set_content(handler, content);
+ lb_set_group(handler, _cluster, _category);
+ free(_cluster);
+ free(_category);
+
+ lb_set_content(handler, _content);
+ free(_content);
+
lb_set_user(handler, user);
lb_set_auto_launch(handler, auto_launch);
lb_set_period(handler, period);
lb_invoke_event_handler(handler, "lb,created");
-
- ret = 0;
-out:
- g_dbus_method_invocation_return_value(inv, g_variant_new("(i)", ret));
}
static void method_deleted(GDBusMethodInvocation *inv, GVariant *param)
{
const char *pkgname;
const char *filename;
+ double timestamp;
struct livebox *handler;
- int ret;
- g_variant_get(param, "(&s&s)", &pkgname, &filename);
+ g_variant_get(param, "(&s&sd)", &pkgname, &filename, ×tamp);
- handler = lb_find_livebox(pkgname, filename);
+ handler = lb_find_livebox_by_timestamp(timestamp);
if (!handler) {
/*!
* \note
* This can be happens only if the user delete a livebox
* right after create it before receive created event.
*/
- ret = -ENOENT;
- goto out;
+ g_dbus_method_invocation_return_value(inv, g_variant_new("(i)", -ENOENT));
+ return;
}
- if (handler->magic != 0xbeefbeef) {
- ErrPrint("Handler is not valid. magic: %lu\n", handler->magic);
- ret = -EINVAL;
- goto out;
- }
+ DbgPrint("[%p] %s(%s) is deleted\n", handler, pkgname, filename);
+ g_dbus_method_invocation_return_value(inv, g_variant_new("(i)", 0));
- DbgPrint("%s(%s) is deleted\n", pkgname, filename);
lb_invoke_event_handler(handler, "lb,deleted");
-
/* Just try to delete it, if a user didn't remove it from the live box list */
lb_unref(handler);
-
- ret = 0;
-out:
- g_dbus_method_invocation_return_value(inv, g_variant_new("(i)", ret));
}
static void method_handler(GDBusConnection *conn,
break;
}
- DbgPrint("Call %s [BEGIN]\n", method_table[i].name);
method_table[i].method(invocation, param);
- DbgPrint("Call %s [END]\n", method_table[i].name);
break;
}
}
return;
}
+static inline void unregister_dbus_object(void)
+{
+ GDBusConnection *conn;
+
+ conn = g_dbus_proxy_get_connection(s_info.proxy);
+ if (!conn)
+ return;
+
+ /* FIXME: Do I really need to do this? */
+ g_dbus_connection_unregister_object(conn, s_info.reg_id);
+ s_info.reg_id = 0;
+
+ if (s_info.node_info) {
+ g_dbus_node_info_unref(s_info.node_info);
+ s_info.node_info = NULL;
+ }
+
+}
+
+static void on_signal(GDBusProxy *proxy, gchar *sender, gchar *signame, GVariant *param, gpointer data)
+{
+ DbgPrint("Sender: %s\n", sender);
+ DbgPrint("SigName: %s\n", signame);
+}
+
+static gboolean dbus_reconnect_cb(gpointer user_data)
+{
+ dbus_init();
+ s_info.recon_timer = 0;
+ return FALSE;
+}
+
static void got_proxy_cb(GObject *obj, GAsyncResult *res, gpointer user_data)
{
+ GVariant *param;
GError *err;
err = NULL;
g_signal_connect(s_info.proxy, "g-signal", G_CALLBACK(on_signal), NULL);
register_dbus_object();
- if (s_info.cmd_list && !s_info.cmd_timer) {
- s_info.cmd_timer = g_timeout_add(10, cmd_consumer, NULL);
- if (!s_info.cmd_timer)
- ErrPrint("Failed to add timer\n");
- }
-}
-
-int dbus_sync_command(const char *funcname, GVariant *param)
-{
- GVariant *result;
- GError *err;
- int ret;
-
- err = NULL;
- result = g_dbus_proxy_call_sync(s_info.proxy, funcname, param,
- G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL, &err);
- if (!result) {
- if (err) {
- ErrPrint("funcname: %s, Error: %s\n", funcname, err->message);
- g_error_free(err);
- }
-
- return -EIO;
- }
-
- g_variant_get(result, "(i)", &ret);
- g_variant_unref(result);
-
- return ret;
-}
-
-/*!
- * \note
- * "handler" could be NULL
- */
-int dbus_push_command(struct livebox *handler, const char *funcname, GVariant *param, void (*ret_cb)(struct livebox *handler, int ret, void *data), void *data)
-{
- struct cmd_item *item;
-
- item = malloc(sizeof(*item));
- if (!item) {
- ErrPrint("Failed to allocate mem for cmd_item\n");
- return -ENOMEM;
- }
-
- item->funcname = strdup(funcname);
- if (!item->funcname) {
- ErrPrint("Failed to allocate mem for funcname - %s\n", funcname);
- free(item);
- return -ENOMEM;
- }
-
- if (handler)
- lb_ref(handler);
-
- item->param = param;
- item->handler = handler;
- item->ret_cb = ret_cb;
- item->data = data;
- item->ttl = DEFAULT_TTL;
-
- s_info.cmd_list = dlist_append(s_info.cmd_list, item);
-
- if (!s_info.cmd_timer && s_info.proxy) {
- s_info.cmd_timer = g_timeout_add(10, cmd_consumer, NULL);
- if (!s_info.cmd_timer)
- ErrPrint("Failed to add timer\n");
+ param = g_variant_new("(i)", getpid());
+ if (!param) {
+ unregister_dbus_object();
+ g_object_unref(s_info.proxy);
+ s_info.proxy = NULL;
+ return;
}
- return 0;
+ master_rpc_sync_request(NULL, "acquire", param);
}
int dbus_init(void)
int dbus_fini(void)
{
- if (s_info.proxy) {
- GDBusConnection *conn;
-
- send_release();
+ GVariant *param;
- conn = g_dbus_proxy_get_connection(s_info.proxy);
- if (conn) {
- /* FIXME: Do I really need to do this? */
- g_dbus_connection_unregister_object(conn, s_info.reg_id);
- s_info.reg_id = 0;
- }
+ if (!s_info.proxy)
+ return 0;
- g_object_unref(s_info.proxy);
- s_info.proxy = NULL;
- }
+ param = g_variant_new("(i)", getpid());
+ if (param)
+ master_rpc_sync_request(NULL, "release", param);
- if (s_info.node_info) {
- g_dbus_node_info_unref(s_info.node_info);
- s_info.node_info = NULL;
- }
+ unregister_dbus_object();
+ g_object_unref(s_info.proxy);
+ s_info.proxy = NULL;
return 0;
}
#include "dlist.h"
#include "util.h"
#include "dbus.h"
+#include "master_rpc.h"
#define EAPI __attribute__((visibility("default")))
#define EVENT_INTERVAL 0.05f
FILE *__file_log_fp;
#endif
-struct info {
+static struct info {
struct dlist *livebox_list;
struct dlist *event_list;
struct dlist *fault_list;
double now;
double interval;
- now = util_get_timestamp();
+ now = util_timestamp();
interval = now - handler->event_timestamp;
if (interval < EVENT_INTERVAL)
return 0;
}
-static void event_ret_cb(struct livebox *handler, int ret, void *data)
+static void mouse_event_cb(struct livebox *handler, GVariant *result, void *data)
{
- if (handler->magic != 0xbeefbeef)
+ int ret;
+
+ if (!result) {
+ lb_invoke_event_handler(handler, "event,ignored");
return;
+ }
+
+ g_variant_get(result, "(i)", &ret);
+ g_variant_unref(result);
- if (handler->deleted != NOT_DELETED)
+ if (ret < 0)
+ lb_invoke_event_handler(handler, "event,ingored");
+}
+
+static void resize_cb(struct livebox *handler, GVariant *result, void *data)
+{
+ int ret;
+
+ if (!result) {
+ lb_invoke_event_handler(handler, "event,ignored");
return;
+ }
- if (ret < 0) {
+ g_variant_get(result, "(i)", &ret);
+ g_variant_unref(result);
+
+ if (ret < 0)
lb_invoke_event_handler(handler, "event,ignored");
- } else {
+}
+
+static void clicked_cb(struct livebox *handler, GVariant *result, void *data)
+{
+ int ret;
+
+ if (!result) {
+ lb_invoke_event_handler(handler, "event,ignored");
+ return;
}
+
+ g_variant_get(result, "(i)", &ret);
+ g_variant_unref(result);
+
+ if (ret < 0)
+ lb_invoke_event_handler(handler, "event,ignored");
+
}
-static void period_ret_cb(struct livebox *handler, int ret, void *data)
+static void text_signal_cb(struct livebox *handler, GVariant *result, void *data)
{
- double *period;
+ int ret;
- if (handler->magic != 0xbeefbeef)
+ if (!result) {
+ lb_invoke_event_handler(handler, "event,ignored");
return;
+ }
+
+ g_variant_get(result, "(i)", &ret);
+ g_variant_unref(result);
- if (handler->deleted != NOT_DELETED) {
+ if (ret < 0)
+ lb_invoke_event_handler(handler, "event,ignored");
+
+ return;
+}
+
+static void set_group_cb(struct livebox *handler, GVariant *result, void *data)
+{
+ int ret;
+
+ if (!result) {
+ lb_invoke_event_handler(handler, "event,ignored");
+ return;
+ }
+
+ g_variant_get(result, "(i)", &ret);
+ g_variant_unref(result);
+
+ if (ret < 0)
+ lb_invoke_event_handler(handler, "event,ignored");
+
+ return;
+}
+
+static void period_ret_cb(struct livebox *handler, GVariant *result, void *data)
+{
+ double *period;
+ int ret;
+
+ if (!result) {
free(data);
return;
}
+ g_variant_get(result, "(i)", &ret);
+ g_variant_unref(result);
+
period = (double *)data;
- if (ret < 0) {
+ if (ret < 0)
lb_invoke_event_handler(handler, "event,ignored");
- } else if (ret == 0) {
+ else if (ret == 0)
lb_set_period(handler, *period);
- } else {
+ else
ErrPrint("Unknown returns %d\n", ret);
- }
free(data);
}
-static void del_ret_cb(struct livebox *handler, int ret, void *data)
+static void del_ret_cb(struct livebox *handler, GVariant *result, void *data)
{
- /*
- lb_invoke_event_handler(handler, "lb,deleted");
- livebox_del(handler, 0);
- */
-}
+ int ret;
-static void new_ret_cb(struct livebox *handler, int ret, void *data)
-{
- if (handler->magic != 0xbeefbeef)
+ if (!result) {
+ lb_invoke_event_handler(handler, "event,ignored");
return;
+ }
- if (handler->deleted != NOT_DELETED)
- return;
+ g_variant_get(result, "(i)", &ret);
+ g_variant_unref(result);
if (ret < 0) {
- /*!
- * \note
- * It means the current instance is not created,
- * so user has to know about this.
- * notice it to user using "deleted" event.
- */
- lb_invoke_event_handler(handler, "lb,deleted");
- lb_unref(handler);
+ lb_invoke_event_handler(handler, "event,ignored");
+ return;
}
- /* lb,created will be receive from the master via dbus */
}
-static void pd_created_cb(struct livebox *handler, int ret, void *data)
+static void new_ret_cb(struct livebox *handler, GVariant *result, void *data)
{
- if (handler->magic != 0xbeefbeef)
+ int ret;
+
+ if (!result)
return;
- if (handler->deleted != NOT_DELETED)
+ g_variant_get(result, "(i)", &ret);
+ g_variant_unref(result);
+
+ if (ret >= 0)
return;
- if (ret != 0) {
+ /*!
+ * \note
+ * It means the current instance is not created,
+ * so user has to know about this.
+ * notice it to user using "deleted" event.
+ */
+ lb_invoke_event_handler(handler, "lb,deleted");
+ lb_unref(handler);
+}
+
+static void pd_created_cb(struct livebox *handler, GVariant *result, void *data)
+{
+ int ret;
+
+ if (!result) {
+ lb_invoke_event_handler(handler, "pd,create,failed");
+ return;
+ }
+
+ g_variant_get(result, "(i)", &ret);
+ g_variant_unref(result);
+
+ if (ret < 0) {
lb_invoke_event_handler(handler, "pd,create,failed");
return;
}
ret = fb_create_buffer(handler->pd_fb);
if (ret < 0)
- ErrPrint("Failed to create a PD buffer\n");
-
- lb_invoke_event_handler(handler, "pd,created");
+ lb_invoke_event_handler(handler, "pd,create,failed");
+ else
+ lb_invoke_event_handler(handler, "pd,created");
}
-static void activated_cb(struct livebox *handler, int ret, void *data)
+static void activated_cb(struct livebox *handler, GVariant *result, void *data)
{
+ int ret;
char *pkgname = data;
+ if (!result) {
+ lb_invoke_fault_handler("activation,failed", pkgname, NULL, NULL);
+ free(pkgname);
+ return;
+ }
+
+ g_variant_get(result, "(i)", &ret);
+ g_variant_unref(result);
+
if (ret == 0)
lb_invoke_fault_handler("activated", pkgname, NULL, NULL);
else if (ret == -EINVAL)
free(pkgname);
}
-static void pd_destroy_cb(struct livebox *handler, int ret, void *data)
+static void pd_destroy_cb(struct livebox *handler, GVariant *result, void *data)
{
- if (handler->magic != 0xbeefbeef)
+ int ret;
+
+ if (!result) {
+ lb_invoke_event_handler(handler, "event,ignored");
return;
+ }
- if (handler->deleted != NOT_DELETED)
+ g_variant_get(result, "(i)", &ret);
+ g_variant_unref(result);
+
+ if (ret < 0) {
+ lb_invoke_event_handler(handler, "event,ignored");
return;
+ }
fb_destroy_buffer(handler->pd_fb);
lb_invoke_event_handler(handler, "pd,deleted");
}
-static void pinup_done_cb(struct livebox *handler, int ret, void *data)
+static void pinup_done_cb(struct livebox *handler, GVariant *result, void *data)
{
- if (handler->magic != 0xbeefbeef)
- return;
+ int ret;
- if (handler->deleted != NOT_DELETED)
+ if (!result) {
+ lb_invoke_event_handler(handler, "event,ignored");
return;
+ }
+
+ g_variant_get(result, "(i)", &ret);
+ g_variant_unref(result);
if (ret != 0) {
ErrPrint("Pinup is not changed: %s\n", strerror(ret));
DbgPrint("Send event [%s] with %lfx%lf\n", event, x, y);
- timestamp = util_get_timestamp();
+ timestamp = util_timestamp();
param = g_variant_new("(ssiiddd)", handler->pkgname, handler->filename,
handler->pd_w, handler->pd_h,
timestamp, x, y);
if (!param)
return -EFAULT;
- ret = dbus_push_command(handler, event, param, event_ret_cb, NULL);
+ ret = master_rpc_async_request(handler, event, param, mouse_event_cb, NULL);
if (ret < 0)
g_variant_unref(param);
GVariant *param;
int ret;
+ DbgPrint("pkgname[%s], content[%s], cluster[%s], category[%s], period[%lf]\n",
+ pkgname, content, cluster, category, period);
+
if (!pkgname || !cluster || !category)
return NULL;
/* Cluster infomration is not determined yet */
handler->nr_of_sizes = 0x01;
- handler->timestamp = util_get_timestamp();
+ handler->timestamp = util_timestamp();
handler->period = period;
- lb_ref(handler);
- handler->magic = 0xbeefbeef;
+ handler->is_user = 1;
s_info.livebox_list = dlist_append(s_info.livebox_list, handler);
return NULL;
}
- ret = dbus_push_command(handler, "new", param, new_ret_cb, NULL);
+ ret = master_rpc_async_request(handler, "new", param, new_ret_cb, NULL);
if (ret < 0) {
free(handler->category);
free(handler->cluster);
return NULL;
}
- return handler;
+ handler->state = CREATE;
+ return lb_ref(handler);
}
EAPI double livebox_period(struct livebox *handler)
{
- if (!handler) {
- ErrPrint("Handler is NIL\n");
+ if (!handler || handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return 0.0f;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED || !handler->filename)
- return 0.0f;
-
return handler->period;
}
EAPI int livebox_set_period(struct livebox *handler, double period)
{
GVariant *param;
- int ret;
double *period_heap;
- if (!handler) {
- ErrPrint("Handler is NIL\n");
+ if (!handler || !handler->filename || handler->state == DELETE) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED || !handler->filename)
- return -EINVAL;
-
if (handler->period == period)
return 0;
}
*period_heap = period;
- ret = dbus_push_command(handler, "set_period", param, period_ret_cb, (void *)period_heap);
- if (ret < 0) {
- g_variant_unref(param);
- free(period_heap);
- return ret;
- }
-
- return 0;
+ return master_rpc_async_request(handler, "set_period", param, period_ret_cb, (void *)period_heap);
}
-EAPI int livebox_del(struct livebox *handler, int server)
+EAPI int livebox_del(struct livebox *handler, int unused)
{
if (!handler) {
ErrPrint("Handler is NIL\n");
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED)
+ if (handler->state == DELETE) {
+ ErrPrint("Handler is already deleted\n");
return -EINVAL;
+ }
- handler->deleted = server ? DELETE_ALL : DELETE_THIS;
+ handler->state = DELETE;
if (!handler->filename) {
/*!
return 0;
}
- if (server)
- return lb_send_delete(handler);
-
- lb_unref(handler);
- return 0;
+ return lb_send_delete(handler);
}
EAPI int livebox_fault_handler_set(int (*cb)(const char *, const char *, const char *, const char *, void *), void *data)
EAPI int livebox_resize(struct livebox *handler, int w, int h)
{
GVariant *param;
- int ret;
if (!handler) {
ErrPrint("Handler is NIL\n");
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED || !handler->filename)
+ if (handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
param = g_variant_new("(ssii)", handler->pkgname, handler->filename, w, h);
- if (!param)
+ if (!param) {
+ ErrPrint("Failed to build param\n");
return -EFAULT;
+ }
- ret = dbus_push_command(handler, "resize", param, event_ret_cb, NULL);
- if (ret < 0)
- g_variant_unref(param);
-
- return ret;
+ return master_rpc_async_request(handler, "resize", param, resize_cb, NULL);
}
EAPI int livebox_click(struct livebox *handler, double x, double y)
{
GVariant *param;
double timestamp;
- int ret;
if (!handler) {
ErrPrint("Handler is NIL\n");
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED || !handler->filename)
+ if (handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
if (handler->auto_launch)
if (aul_launch_app(handler->pkgname, NULL) < 0)
ErrPrint("Failed to launch app %s\n", handler->pkgname);
- timestamp = util_get_timestamp();
+ timestamp = util_timestamp();
param = g_variant_new("(sssddd)", handler->pkgname, handler->filename, "clicked", timestamp, x, y);
- if (!param)
+ if (!param) {
+ ErrPrint("Failed to build param\n");
return -EFAULT;
+ }
- ret = dbus_push_command(handler, "clicked", param, event_ret_cb, NULL);
- if (ret < 0)
- g_variant_unref(param);
-
- return ret;
+ return master_rpc_async_request(handler, "clicked", param, clicked_cb, NULL);
}
EAPI int livebox_has_pd(struct livebox *handler)
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED || !handler->filename)
+ if (handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
DbgPrint("%s(%s) has PD: %d\n", handler->pkgname, handler->filename, !!handler->pd_fb);
return !!handler->pd_fb;
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || !handler->pd_fb || handler->deleted != NOT_DELETED || !handler->filename)
+ if (!handler->pd_fb || handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
return fb_is_created(handler->pd_fb);
}
EAPI int livebox_create_pd(struct livebox *handler)
{
GVariant *param;
- int ret;
if (!handler) {
ErrPrint("Handler is NIL\n");
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || !handler->pd_fb || handler->deleted != NOT_DELETED || !handler->filename)
+ if (!handler->pd_fb || handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
- if (fb_is_created(handler->pd_fb) == 1)
+ if (fb_is_created(handler->pd_fb) == 1) {
+ DbgPrint("PD is already created\n");
return 0;
+ }
param = g_variant_new("(ss)", handler->pkgname, handler->filename);
- if (!param)
+ if (!param) {
+ ErrPrint("Failed to build param\n");
return -EFAULT;
+ }
- ret = dbus_push_command(handler, "create_pd", param, pd_created_cb, NULL);
- if (ret < 0)
- g_variant_unref(param);
-
- return ret;
+ return master_rpc_async_request(handler, "create_pd", param, pd_created_cb, NULL);
}
EAPI int livebox_activate(const char *pkgname)
{
GVariant *param;
- int ret;
+ char *str;
if (!pkgname)
return -EINVAL;
param = g_variant_new("(s)", pkgname);
- if (!param)
+ if (!param) {
+ ErrPrint("Failed to build a param\n");
return -EFAULT;
+ }
- ret = dbus_push_command(NULL, "activate_package", param, activated_cb, strdup(pkgname));
- if (ret < 0)
- g_variant_unref(param);
+ str = strdup(pkgname);
+ if (!str) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ return -ENOMEM;
+ }
- return ret;
+ return master_rpc_async_request(NULL, "activate_package", param, activated_cb, str);
}
EAPI int livebox_destroy_pd(struct livebox *handler)
{
GVariant *param;
- int ret;
if (!handler) {
ErrPrint("Handler is NIL\n");
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || !handler->pd_fb || handler->deleted != NOT_DELETED || !handler->filename)
+ if (!handler->pd_fb || handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
- if (fb_is_created(handler->pd_fb) != 1)
+ if (fb_is_created(handler->pd_fb) != 1) {
+ ErrPrint("PD is not created\n");
return -EINVAL;
+ }
param = g_variant_new("(ss)", handler->pkgname, handler->filename);
- if (!param)
+ if (!param) {
+ ErrPrint("Failed to build a param\n");
return -EFAULT;
+ }
- ret = dbus_push_command(handler, "destroy_pd", param, pd_destroy_cb, NULL);
- if (ret < 0)
- g_variant_unref(param);
-
- return ret;
+ return master_rpc_async_request(handler, "destroy_pd", param, pd_destroy_cb, NULL);
}
EAPI int livebox_pd_mouse_down(struct livebox *handler, double x, double y)
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || !handler->pd_fb || handler->deleted != NOT_DELETED || !handler->filename)
+ if (!handler->pd_fb || handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
return send_mouse_event(handler, "pd_mouse_down", x, y);
}
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || !handler->pd_fb || handler->deleted != NOT_DELETED || !handler->filename)
+ if (!handler->pd_fb || handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
return send_mouse_event(handler, "pd_mouse_up", x, y);
}
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || !handler->pd_fb || handler->deleted != NOT_DELETED || !handler->filename)
+ if (!handler->pd_fb || handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
ret = update_event_timestamp(handler);
if (ret < 0)
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || !handler->lb_fb || handler->deleted != NOT_DELETED || !handler->filename)
+ if (!handler->lb_fb || handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
return send_mouse_event(handler, "lb_mouse_down", x, y);
}
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || !handler->lb_fb || handler->deleted != NOT_DELETED || !handler->filename)
+ if (!handler->lb_fb || handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
return send_mouse_event(handler, "lb_mouse_up", x, y);
}
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || !handler->lb_fb || handler->deleted != NOT_DELETED || !handler->filename)
+ if (!handler->lb_fb || handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
ret = update_event_timestamp(handler);
if (ret < 0)
return NULL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED)
+ if (handler->state == DELETE) {
+ ErrPrint("Handler is not valid\n");
return NULL;
+ }
return handler->filename;
}
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED || !handler->filename)
+ if (handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
if (!w)
w = &_w;
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED || !handler->filename)
+ if (handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
if (!w)
w = &_w;
EAPI int livebox_set_group(struct livebox *handler, const char *cluster, const char *category)
{
GVariant *param;
- int ret;
if (!handler) {
ErrPrint("Handler is NIL\n");
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || !cluster || !category || handler->deleted != NOT_DELETED || !handler->filename)
+ if (!cluster || !category || handler->state == DELETE || !handler->filename) {
+ ErrPrint("Invalid argument\n");
return -EINVAL;
+ }
param = g_variant_new("(ssss)", handler->pkgname, handler->filename, cluster, category);
- if (!param)
+ if (!param) {
+ ErrPrint("Failed to build a param\n");
return -EFAULT;
+ }
- ret = dbus_push_command(handler, "change_group", param, event_ret_cb, NULL);
- if (ret < 0)
- g_variant_unref(param);
-
- return ret;
+ return master_rpc_async_request(handler, "change_group", param, set_group_cb, NULL);
}
EAPI int livebox_get_group(struct livebox *handler, char ** const cluster, char ** const category)
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || !cluster || !category || handler->deleted != NOT_DELETED || !handler->filename)
+ if (!cluster || !category || handler->state == DELETE || !handler->filename) {
+ ErrPrint("Invalid argument\n");
return -EINVAL;
+ }
*cluster = handler->cluster;
*category = handler->category;
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || !cnt || handler->deleted != NOT_DELETED || !handler->filename)
+ if (!cnt || handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
for (j = i = 0; i < NR_OF_SIZE_LIST; i++) {
if (handler->size_list & (0x01 << i)) {
return NULL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED)
+ if (handler->state == DELETE) {
+ ErrPrint("Handler is not valid\n");
return NULL;
+ }
return handler->pkgname;
}
return 0.0f;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED || !handler->filename)
- return 0.0f;
+ if (handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid (%p)\n", handler);
+ return -1.0f;
+ }
return handler->priority;
}
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED || !handler->filename)
+ if (handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
return handler->data_type == FILEDATA;
}
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED || !handler->filename)
+ if (handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
return handler->text_lb;
}
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED || !handler->filename)
+ if (handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
return handler->text_pd;
}
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED)
+ if (handler->state == DELETE) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
memcpy(&handler->pd_ops, ops, sizeof(*ops));
return 0;
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED)
+ if (handler->state == DELETE) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
memcpy(&handler->ops, ops, sizeof(*ops));
return 0;
return NULL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED || !handler->filename)
+ if (handler->state == DELETE || !handler->filename || handler->data_type != FBDATA) {
+ ErrPrint("Handler is not valid\n");
return NULL;
+ }
- if (handler->data_type == FBDATA)
- return fb_buffer(handler->lb_fb);
-
- return NULL;
+ return fb_buffer(handler->lb_fb);
}
EAPI void *livebox_pdfb(struct livebox *handler)
return NULL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED || !handler->filename)
+ if (handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return NULL;
+ }
return fb_buffer(handler->pd_fb);
}
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED || !handler->filename)
+ if (handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
return fb_size(handler->pd_fb);
}
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED || !handler->filename)
+ if (handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
return fb_size(handler->lb_fb);
}
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED || !handler->filename)
+ if (handler->state == DELETE) {
+ ErrPrint("Handler is invalid\n");
return -EINVAL;
+ }
return handler->is_user;
}
EAPI int livebox_set_pinup(struct livebox *handler, int flag)
{
GVariant *param;
- int ret;
if (!handler) {
ErrPrint("Handler is NIL\n");
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED || !handler->filename)
+ if (handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
if (handler->is_pinned_up == flag)
return 0;
param = g_variant_new("(ssi)", handler->pkgname, handler->filename, flag);
- if (!param)
+ if (!param) {
+ ErrPrint("Failed to build a param\n");
return -EFAULT;
+ }
- ret = dbus_push_command(handler, "pinup_changed", param, pinup_done_cb, (void *)flag);
- if (ret < 0)
- g_variant_unref(param);
-
- return ret;
+ return master_rpc_async_request(handler, "pinup_changed", param, pinup_done_cb, (void *)flag);
}
EAPI int livebox_pinup(struct livebox *handler)
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED || !handler->filename)
+ if (handler->state == DELETE || !handler->filename)
return -EINVAL;
return handler->is_pinned_up;
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED || !handler->filename)
+ if (handler->state == DELETE || !handler->filename)
return -EINVAL;
return handler->pinup_supported;
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED)
+ if (handler->state == DELETE)
return -EINVAL;
handler->data = data;
return NULL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED)
+ if (handler->state == DELETE)
return NULL;
return handler->data;
int ret;
param = g_variant_new("(s)", pkgname);
- if (!param)
+ if (!param) {
+ ErrPrint("Failed to build a param\n");
return -EFAULT;
+ }
- ret = dbus_sync_command("livebox_is_exists", param);
- return (ret == 0) ? 1 : ret;
+ ret = master_rpc_sync_request(NULL, "livebox_is_exists", param);
+ return ret == 0;
}
EAPI const char *livebox_content(struct livebox *handler)
return NULL;
}
- if (handler->magic != 0xbeefbeef || handler->deleted != NOT_DELETED)
+ if (handler->state == DELETE)
return NULL;
return handler->content;
EAPI int livebox_text_emit_signal(struct livebox *handler, const char *emission, const char *source, double sx, double sy, double ex, double ey)
{
GVariant *param;
- int ret;
if (!handler) {
ErrPrint("Handler is NIL\n");
return -EINVAL;
}
- if (handler->magic != 0xbeefbeef || (!handler->text_lb && !handler->text_pd) || handler->deleted != NOT_DELETED || !handler->filename)
+ if ((!handler->text_lb && !handler->text_pd) || handler->state == DELETE || !handler->filename) {
+ ErrPrint("Handler is not valid\n");
return -EINVAL;
+ }
if (!emission)
emission = "";
source = "";
param = g_variant_new("(ssssdddd)", handler->pkgname, handler->filename, emission, source, sx, sy, ex, ey);
- if (!param)
+ if (!param) {
+ ErrPrint("Failed to build a param\n");
return -EFAULT;
-
- ret = dbus_push_command(handler, "text_signal", param, event_ret_cb, NULL);
- if (ret < 0) {
- g_variant_unref(param);
- return -EIO;
}
- return 0;
+ return master_rpc_async_request(handler, "text_signal", param, text_signal_cb, NULL);
}
int lb_set_group(struct livebox *handler, const char *cluster, const char *category)
s_info.livebox_list = dlist_append(s_info.livebox_list, handler);
lb_ref(handler);
- handler->magic = 0xbeefbeef;
return handler;
}
return;
}
+ fb_sync(handler->lb_fb);
handler->data_type = FBDATA;
}
handler->period = period;
}
-void lb_ref(struct livebox *handler)
+struct livebox *lb_ref(struct livebox *handler)
{
+ if (!handler)
+ return NULL;
+
handler->refcnt++;
+ return handler;
}
-void lb_unref(struct livebox *handler)
+struct livebox *lb_unref(struct livebox *handler)
{
+ if (!handler)
+ return NULL;
+
handler->refcnt--;
if (handler->refcnt > 0)
- return;
+ return handler;
dlist_remove_data(s_info.livebox_list, handler);
handler->pd_fb = NULL;
}
- handler->magic = 0xdeaddead;
free(handler);
+ return NULL;
}
int lb_send_delete(struct livebox *handler)
{
GVariant *param;
- int ret;
param = g_variant_new("(ss)", handler->pkgname, handler->filename);
- if (!param)
+ if (!param) {
+ ErrPrint("Failed to build a param\n");
return -EFAULT;
-
- ret = dbus_push_command(handler, "delete", param, del_ret_cb, NULL);
- if (ret < 0) {
- g_variant_unref(param);
- return ret;
}
- return 0;
+ return master_rpc_async_request(handler, "delete", param, del_ret_cb, NULL);
}
/* End of a file */