From 298d2fa57c4607a970a96ee10ea06e7834c4ada7 Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Thu, 31 Jul 2014 15:17:12 +0900 Subject: [PATCH] Separate extra info from update event path. Change-Id: Ieb63aa4c1a3480421c360131f32b39f4517e2230 --- include/livebox.h | 2 ++ include/livebox_internal.h | 3 +- src/client.c | 72 +++++++++++++++++++++++++++++++++++++--------- src/livebox.c | 14 +++++---- 4 files changed, 72 insertions(+), 19 deletions(-) diff --git a/include/livebox.h b/include/livebox.h index 6429bef..cb76c60 100644 --- a/include/livebox.h +++ b/include/livebox.h @@ -214,6 +214,8 @@ enum livebox_event_type { /**< livebox_event_handler_set Event list */ LB_EVENT_REQUEST_CLOSE_PD, /**< Livebox requests to close the PD */ + LB_EVENT_EXTRA_INFO_UPDATED, /**< Extra information is updated */ + LB_EVENT_IGNORED /**< Request is ignored */ }; diff --git a/include/livebox_internal.h b/include/livebox_internal.h index 7db6a55..2faa3c0 100644 --- a/include/livebox_internal.h +++ b/include/livebox_internal.h @@ -44,7 +44,8 @@ extern int lb_text_pd(struct livebox_common *handler); extern void lb_set_period(struct livebox_common *handler, double period); extern void lb_set_update_mode(struct livebox_common *handler, int active_mode); extern void lb_set_filename(struct livebox_common *handler, const char *filename); -extern void lb_set_alt_info(struct livebox_common *handler, const char *icon, const char *name); +extern void lb_set_alt_icon(struct livebox_common *handler, const char *icon); +extern void lb_set_alt_name(struct livebox_common *handle, const char *name); extern int lb_destroy_lock_file(struct livebox_common *common, int is_pd); extern int lb_create_lock_file(struct livebox_common *common, int is_pd); extern int lb_destroy_common_handle(struct livebox_common *common); diff --git a/src/client.c b/src/client.c index 1aee560..3760f86 100644 --- a/src/client.c +++ b/src/client.c @@ -599,29 +599,74 @@ out: return NULL; } -static struct packet *master_lb_updated(pid_t pid, int handle, const struct packet *packet) +static struct packet *master_extra_info(pid_t pid, int handle, const struct packet *packet) { const char *pkgname; const char *id; - const char *fbfile; const char *content; const char *title; - const char *safe_file; const char *icon; const char *name; + double priority; + int ret; + struct livebox *handler; + struct livebox_common *common; + struct dlist *l; + struct dlist *n; + + ret = packet_get(packet, "ssssssd", &pkgname, &id, + &content, &title, + &icon, &name, + &priority); + if (ret != 7) { + ErrPrint("Invalid parameters\n"); + goto out; + } + + common = lb_find_common_handle(pkgname, id); + if (!common) { + ErrPrint("instance(%s) is not exists\n", id); + goto out; + } + + if (common->state != CREATE) { + /*! + * \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 + */ + ErrPrint("(%s) is not exists, but updated\n", id); + goto out; + } + + lb_set_priority(common, priority); + lb_set_content(common, content); + lb_set_title(common, title); + lb_set_alt_icon(common, icon); + lb_set_alt_name(common, name); + + dlist_foreach_safe(common->livebox_list, l, n, handler) { + lb_invoke_event_handler(handler, LB_EVENT_EXTRA_INFO_UPDATED); + } +out: + return NULL; +} + +static struct packet *master_lb_updated(pid_t pid, int handle, const struct packet *packet) +{ + const char *pkgname; + const char *id; + const char *fbfile; + const char *safe_file; struct livebox *handler; struct livebox_common *common; int lb_w; int lb_h; - double priority; int ret; - ret = packet_get(packet, "sssiidsssss", - &pkgname, &id, - &fbfile, &lb_w, &lb_h, - &priority, &content, &title, - &safe_file, &icon, &name); - if (ret != 11) { + ret = packet_get(packet, "ssssii", &pkgname, &id, &fbfile, &safe_file, &lb_w, &lb_h); + if (ret != 6) { ErrPrint("Invalid argument\n"); goto out; } @@ -643,9 +688,6 @@ static struct packet *master_lb_updated(pid_t pid, int handle, const struct pack goto out; } - lb_set_priority(common, priority); - lb_set_content(common, content); - lb_set_title(common, title); lb_set_size(common, lb_w, lb_h); lb_set_filename(common, safe_file); @@ -1515,6 +1557,10 @@ static struct method s_table[] = { .handler = master_pd_updated, }, { + .cmd = "extra_info", + .handler = master_extra_info, + }, + { .cmd = "pd_created", .handler = master_pd_created, }, diff --git a/src/livebox.c b/src/livebox.c index 50bfbdd..caf5395 100644 --- a/src/livebox.c +++ b/src/livebox.c @@ -4286,10 +4286,9 @@ void lb_set_filename(struct livebox_common *common, const char *filename) } } -void lb_set_alt_info(struct livebox_common *common, const char *icon, const char *name) +void lb_set_alt_icon(struct livebox_common *common, const char *icon) { char *_icon = NULL; - char *_name = NULL; if (icon && strlen(icon)) { _icon = strdup(icon); @@ -4298,6 +4297,14 @@ void lb_set_alt_info(struct livebox_common *common, const char *icon, const char } } + free(common->alt.icon); + common->alt.icon = _icon; +} + +void lb_set_alt_name(struct livebox_common *common, const char *name) +{ + char *_name = NULL; + if (name && strlen(name)) { _name = strdup(name); if (!_name) { @@ -4305,9 +4312,6 @@ void lb_set_alt_info(struct livebox_common *common, const char *icon, const char } } - free(common->alt.icon); - common->alt.icon = _icon; - free(common->alt.name); common->alt.name = _name; } -- 2.7.4