From 74fec1ddff061b31f4a5cbb8f6b86d27f1c1af6b Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Mon, 25 Mar 2013 04:08:50 +0000 Subject: [PATCH] Update License 2012 -> 2013 Unlink the kept image file when the handler is deleted. Change-Id: I292c23eea20f0df38e549c7e7aa269d9a623d234 --- CMakeLists.txt | 2 +- LICENSE | 2 +- include/client.h | 2 +- include/conf.h | 2 +- include/critical_log.h | 2 +- include/debug.h | 2 +- include/desc_parser.h | 2 +- include/dlist.h | 2 +- include/fb.h | 2 +- include/livebox-viewer_PG.h | 2 +- include/livebox.h | 27 +-- include/livebox_internal.h | 2 +- include/master_rpc.h | 2 +- include/util.h | 3 +- live.viewer/include/debug.h | 2 +- live.viewer/include/dlist.h | 2 +- live.viewer/include/lb.h | 2 +- live.viewer/include/live_scroller.h | 2 +- live.viewer/include/main.h | 2 +- live.viewer/include/scroller.h | 2 +- live.viewer/include/util.h | 2 +- live.viewer/res/live-viewer.edc | 2 +- live.viewer/src/dlist.c | 2 +- live.viewer/src/lb.c | 2 +- live.viewer/src/live_scroller.c | 2 +- live.viewer/src/main.c | 2 +- live.viewer/src/scroller.c | 2 +- live.viewer/src/util.c | 2 +- packaging/liblivebox-viewer.spec | 4 +- src/client.c | 107 ++++------- src/critical_log.c | 11 +- src/desc_parser.c | 67 +++---- src/dlist.c | 2 +- src/fb.c | 63 +++--- src/livebox.c | 372 ++++++++++++++++++------------------ src/master_rpc.c | 19 +- src/util.c | 44 ++++- 37 files changed, 395 insertions(+), 376 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 006c861..27d0e1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"") ADD_DEFINITIONS("-DLOG_TAG=\"LIVEBOX_VIEWER\"") ADD_DEFINITIONS("-DNDEBUG") #ADD_DEFINITIONS("-DFLOG") -ADD_DEFINITIONS("-DMASTER_PKGNAME=\"org.tizen.data-provider-master\"") +ADD_DEFINITIONS("-DMASTER_PKGNAME=\"data-provider-master\"") ADD_DEFINITIONS("-DINFO_SOCKET=\"/opt/usr/share/live_magazine/.live.socket\"") ADD_DEFINITIONS("-DCLIENT_SOCKET=\"/opt/usr/share/live_magazine/.client.socket\"") ADD_DEFINITIONS("-DSLAVE_SOCKET=\"/opt/usr/share/live_magazine/.slave.socket\"") diff --git a/LICENSE b/LICENSE index 27daa90..009765e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ Flora License -Version 1.0, May, 2012 +Version 1.0, May, 2013 http://www.tizenopensource.org/license diff --git a/include/client.h b/include/client.h index 873ae9d..f2eae82 100644 --- a/include/client.h +++ b/include/client.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/conf.h b/include/conf.h index 25b158d..98855a4 100644 --- a/include/conf.h +++ b/include/conf.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/critical_log.h b/include/critical_log.h index 070ac47..63f4a53 100644 --- a/include/critical_log.h +++ b/include/critical_log.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/debug.h b/include/debug.h index 2d2748e..98d671c 100644 --- a/include/debug.h +++ b/include/debug.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/desc_parser.h b/include/desc_parser.h index 0bb5502..487ee7b 100644 --- a/include/desc_parser.h +++ b/include/desc_parser.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/dlist.h b/include/dlist.h index b4a5719..7085384 100644 --- a/include/dlist.h +++ b/include/dlist.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/fb.h b/include/fb.h index 7491aa3..31da7c1 100644 --- a/include/fb.h +++ b/include/fb.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/livebox-viewer_PG.h b/include/livebox-viewer_PG.h index 62077ae..d262be8 100644 --- a/include/livebox-viewer_PG.h +++ b/include/livebox-viewer_PG.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/livebox.h b/include/livebox.h index 56121ef..5d26a30 100644 --- a/include/livebox.h +++ b/include/livebox.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. @@ -163,7 +163,7 @@ struct livebox_script_operators { * Listed functions will be called when parser meets each typed component */ int (*update_text)(struct livebox *handle, const char *id, const char *part, const char *data); /*!< Update text content */ - int (*update_image)(struct livebox *handle, const char *id, const char *part, const char *data); /*!< Update image content */ + int (*update_image)(struct livebox *handle, const char *id, const char *part, const char *data, const char *option); /*!< Update image content */ int (*update_script)(struct livebox *handle, const char *id, const char *part, const char *file, const char *group); /*!< Update script content */ int (*update_signal)(struct livebox *handle, const char *id, const char *emission, const char *signal); /*!< Update signal */ int (*update_drag)(struct livebox *handle, const char *id, const char *part, double dx, double dy); /*!< Update drag info */ @@ -182,37 +182,42 @@ typedef void (*ret_cb_t)(struct livebox *handle, int ret, void *data); /*! * \brief Initialize the livebox system - * \param[in] disp - * \return int + * \param[in] disp If you have X Display connection object, you can re-use it. but you should care its life cycle. + * It must be alive before call the livebox_fini + * \return int 0 if success or < 0 (errno) + * \sa livebox_fini */ extern int livebox_init(void *disp); /*! * \brief Finalize the livebox system - * \return int + * \return int 0 if success, -EINVAL if livebox_init is not called. + * \sa livebox_init */ extern int livebox_fini(void); /*! * \brief Client is paused. - * \return int + * \return int 0 if success, -EFAULT if it failed to send state(paused) info + * \sa livebox_client_resumed */ extern int livebox_client_paused(void); /*! * \brief Client is rfesumed. - * \return int + * \return int 0 if success, -EFAULT if it failed to send state(resumed) info + * \sa livebox_client_paused */ extern int livebox_client_resumed(void); /*! * \brief Add a new livebox - * \param[in] pkgname - * \param[in] content + * \param[in] pkgname Livebox Id + * \param[in] content Will be passed to the livebox. * \param[in] cluster * \param[in] category - * \param[in] period - * \param[in] cb + * \param[in] period Update period. if you set DEFAULT_PERIOD, the provider will use the default period which is described in the manifest. + * \param[in] cb After send the request to the provider, its result will be passed * \param[in] data * \return handle */ diff --git a/include/livebox_internal.h b/include/livebox_internal.h index 4a6b100..a329ba8 100644 --- a/include/livebox_internal.h +++ b/include/livebox_internal.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/master_rpc.h b/include/master_rpc.h index e507c27..0e54a47 100644 --- a/include/master_rpc.h +++ b/include/master_rpc.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/util.h b/include/util.h index 2c9275b..1d3f09e 100644 --- a/include/util.h +++ b/include/util.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ extern double util_timestamp(void); extern const char *util_basename(const char *name); extern int util_validate_livebox_package(const char *pkgname); extern const char *util_uri_to_path(const char *uri); +extern int util_unlink(const char *filename); #define SCHEMA_FILE "file://" #define SCHEMA_PIXMAP "pixmap://" diff --git a/live.viewer/include/debug.h b/live.viewer/include/debug.h index 2d2748e..98d671c 100644 --- a/live.viewer/include/debug.h +++ b/live.viewer/include/debug.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/live.viewer/include/dlist.h b/live.viewer/include/dlist.h index b4a5719..7085384 100644 --- a/live.viewer/include/dlist.h +++ b/live.viewer/include/dlist.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/live.viewer/include/lb.h b/live.viewer/include/lb.h index d6ea8bc..14d90f9 100644 --- a/live.viewer/include/lb.h +++ b/live.viewer/include/lb.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/live.viewer/include/live_scroller.h b/live.viewer/include/live_scroller.h index de7e77e..5758378 100644 --- a/live.viewer/include/live_scroller.h +++ b/live.viewer/include/live_scroller.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/live.viewer/include/main.h b/live.viewer/include/main.h index 33f292f..b3d2032 100644 --- a/live.viewer/include/main.h +++ b/live.viewer/include/main.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/live.viewer/include/scroller.h b/live.viewer/include/scroller.h index 41d6757..58cca5e 100644 --- a/live.viewer/include/scroller.h +++ b/live.viewer/include/scroller.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/live.viewer/include/util.h b/live.viewer/include/util.h index bf99fb4..f4f5d68 100644 --- a/live.viewer/include/util.h +++ b/live.viewer/include/util.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/live.viewer/res/live-viewer.edc b/live.viewer/res/live-viewer.edc index f4d4242..2b95757 100644 --- a/live.viewer/res/live-viewer.edc +++ b/live.viewer/res/live-viewer.edc @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/live.viewer/src/dlist.c b/live.viewer/src/dlist.c index 56ff060..78c76ba 100644 --- a/live.viewer/src/dlist.c +++ b/live.viewer/src/dlist.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/live.viewer/src/lb.c b/live.viewer/src/lb.c index cbe928b..fc1fe4d 100644 --- a/live.viewer/src/lb.c +++ b/live.viewer/src/lb.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/live.viewer/src/live_scroller.c b/live.viewer/src/live_scroller.c index 4a23dd2..fc5cd60 100644 --- a/live.viewer/src/live_scroller.c +++ b/live.viewer/src/live_scroller.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/live.viewer/src/main.c b/live.viewer/src/main.c index 362cf3f..e7d9bd5 100644 --- a/live.viewer/src/main.c +++ b/live.viewer/src/main.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/live.viewer/src/scroller.c b/live.viewer/src/scroller.c index 8eca311..243ae14 100644 --- a/live.viewer/src/scroller.c +++ b/live.viewer/src/scroller.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/live.viewer/src/util.c b/live.viewer/src/util.c index 73bca58..29b13f6 100644 --- a/live.viewer/src/util.c +++ b/live.viewer/src/util.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/packaging/liblivebox-viewer.spec b/packaging/liblivebox-viewer.spec index 4ceff01..994c068 100644 --- a/packaging/liblivebox-viewer.spec +++ b/packaging/liblivebox-viewer.spec @@ -1,8 +1,8 @@ Name: liblivebox-viewer Summary: Library for developing the application. -Version: 0.10.1 +Version: 0.10.3 Release: 1 -Group: framework/livebox +Group: HomeTF/Livebox License: Flora License Source0: %{name}-%{version}.tar.gz BuildRequires: cmake, gettext-tools, coreutils diff --git a/src/client.c b/src/client.c index e3370cc..3a483fc 100644 --- a/src/client.c +++ b/src/client.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ #include #include #include +#include #include "debug.h" #include "client.h" @@ -78,13 +79,12 @@ static struct packet *master_pinup(pid_t pid, int handle, const struct packet *p ret = packet_get(packet, "iisss", &ret, &pinup, &pkgname, &id, &content); if (ret != 5) { ErrPrint("Invalid argument\n"); - ret = -EINVAL; goto out; } handler = lb_find_livebox(pkgname, id); if (!handler) { - ret = -ENOENT; + ErrPrint("Instance (%s) is not exists\n", id); goto out; } @@ -96,7 +96,7 @@ static struct packet *master_pinup(pid_t pid, int handle, const struct packet *p handler->is_pinned_up = pinup; } else { ErrPrint("Heap: %s\n", strerror(errno)); - ret = -ENOMEM; + ret = LB_STATUS_ERROR_MEMORY; } } @@ -105,11 +105,10 @@ static struct packet *master_pinup(pid_t pid, int handle, const struct packet *p handler->pinup_cb = NULL; /*!< Reset pinup cb */ handler->pinup_cbdata = NULL; - } else { + } else if (ret == 0) { lb_invoke_event_handler(handler, LB_EVENT_PINUP_CHANGED); } - ret = 0; out: return NULL; } @@ -169,14 +168,14 @@ static struct packet *master_deleted(pid_t pid, int handle, const struct packet handler->deleted_cbdata = NULL; } - DbgPrint("Call the created cb with -ECANCELED\n"); - handler->created_cb(handler, -ECANCELED, handler->created_cbdata); + DbgPrint("Call the created cb with LB_STATUS_ERROR_CANCEL\n"); + handler->created_cb(handler, LB_STATUS_ERROR_CANCEL, handler->created_cbdata); handler->created_cb = NULL; handler->created_cbdata = NULL; } else if (handler->id) { if (handler->deleted_cb) { DbgPrint("Call the deleted cb\n"); - handler->deleted_cb(handler, 0, handler->deleted_cbdata); + handler->deleted_cb(handler, LB_STATUS_SUCCESS, handler->deleted_cbdata); handler->deleted_cb = NULL; handler->deleted_cbdata = NULL; @@ -214,13 +213,12 @@ static struct packet *master_lb_updated(pid_t pid, int handle, const struct pack &priority, &content, &title); if (ret != 8) { ErrPrint("Invalid argument\n"); - ret = -EINVAL; goto out; } handler = lb_find_livebox(pkgname, id); if (!handler) { - ret = -ENOENT; + ErrPrint("instance(%s) is not exists\n", id); goto out; } @@ -231,7 +229,7 @@ static struct packet *master_lb_updated(pid_t pid, int handle, const struct pack * Don't try to notice anything with this, Just ignore all events * Beacuse the user doesn't wants know about this anymore */ - ret = -EPERM; + DbgPrint("(%s) is not exists, but updated\n", id); goto out; } @@ -241,10 +239,11 @@ static struct packet *master_lb_updated(pid_t pid, int handle, const struct pack if (lb_text_lb(handler)) { lb_set_size(handler, lb_w, lb_h); - ret = parse_desc(handler, livebox_filename(handler), 0); + (void)parse_desc(handler, livebox_filename(handler), 0); /*! * \note * DESC parser will call the "text event callback". + * Don't need to call global event callback in this case. */ goto out; } else if (lb_get_lb_fb(handler)) { @@ -252,7 +251,7 @@ static struct packet *master_lb_updated(pid_t pid, int handle, const struct pack lb_set_lb_fb(handler, fbfile); ret = fb_sync(lb_get_lb_fb(handler)); if (ret < 0) - ErrPrint("Failed to do sync FB (%s - %s)\n", pkgname, util_basename(util_uri_to_path(id))); + ErrPrint("Failed to do sync FB (%s - %s) (%d)\n", pkgname, util_basename(util_uri_to_path(id)), ret); } else { lb_set_size(handler, lb_w, lb_h); ret = 0; @@ -284,12 +283,12 @@ static struct packet *master_pd_created(pid_t pid, int handle, const struct pack handler = lb_find_livebox(pkgname, id); if (!handler) { - ret = -ENOENT; + ErrPrint("Instance(%s) is not exists\n", id); goto out; } if (handler->state != CREATE) { - ret = -EPERM; + ErrPrint("Instance(%s) is not created\n", id); goto out; } @@ -299,11 +298,8 @@ static struct packet *master_pd_created(pid_t pid, int handle, const struct pack } else { (void)lb_set_pd_fb(handler, buf_id); ret = fb_sync(lb_get_pd_fb(handler)); - if (ret < 0) { - ErrPrint("Failed to do sync FB (%s - %s)\n", - pkgname, - util_basename(util_uri_to_path(id))); - } + if (ret < 0) + ErrPrint("Failed to do sync FB (%s - %s)\n", pkgname, util_basename(util_uri_to_path(id))); } handler->is_pd_created = (status == 0); @@ -319,7 +315,6 @@ static struct packet *master_pd_created(pid_t pid, int handle, const struct pack lb_invoke_event_handler(handler, LB_EVENT_PD_CREATED); } - ret = 0; out: return NULL; } @@ -340,12 +335,12 @@ static struct packet *master_pd_destroyed(pid_t pid, int handle, const struct pa handler = lb_find_livebox(pkgname, id); if (!handler) { - ret = -ENOENT; + ErrPrint("Instance(%s) is not exists\n", id); goto out; } if (handler->state != CREATE) { - ret = -EPERM; + ErrPrint("Instance(%s) is not created\n", id); goto out; } @@ -362,7 +357,6 @@ static struct packet *master_pd_destroyed(pid_t pid, int handle, const struct pa lb_invoke_event_handler(handler, LB_EVENT_PD_DESTROYED); } - ret = 0; out: return NULL; } @@ -384,13 +378,12 @@ static struct packet *master_pd_updated(pid_t pid, int handle, const struct pack &pd_w, &pd_h); if (ret != 6) { ErrPrint("Invalid argument\n"); - ret = -EINVAL; goto out; } handler = lb_find_livebox(pkgname, id); if (!handler) { - ret = -ENOENT; + ErrPrint("Instance(%s) is not exists\n", id); goto out; } @@ -401,27 +394,22 @@ static struct packet *master_pd_updated(pid_t pid, int handle, const struct pack * So don't try to notice anything about this anymore. * Just ignore all events. */ - ret = -EPERM; + ErrPrint("Instance(%s) is not created\n", id); goto out; } lb_set_pdsize(handler, pd_w, pd_h); if (lb_text_pd(handler)) { - ret = parse_desc(handler, descfile, 1); + (void)parse_desc(handler, descfile, 1); } else { (void)lb_set_pd_fb(handler, fbfile); ret = fb_sync(lb_get_pd_fb(handler)); - if (ret < 0) { - ErrPrint("Failed to do sync FB (%s - %s)\n", - pkgname, - util_basename(util_uri_to_path(id))); - goto out; - } - - lb_invoke_event_handler(handler, LB_EVENT_PD_UPDATED); - ret = 0; + if (ret < 0) + ErrPrint("Failed to do sync FB (%s - %s)\n", pkgname, util_basename(util_uri_to_path(id))); + else + lb_invoke_event_handler(handler, LB_EVENT_PD_UPDATED); } out: @@ -441,14 +429,12 @@ static struct packet *master_size_changed(pid_t pid, int handle, const struct pa if (!packet) { ErrPrint("Invalid packet\n"); - ret = -EINVAL; goto out; } ret = packet_get(packet, "ssiiii", &pkgname, &id, &is_pd, &w, &h, &status); if (ret != 6) { ErrPrint("Invalid argument\n"); - ret = -EINVAL; goto out; } @@ -456,14 +442,12 @@ static struct packet *master_size_changed(pid_t pid, int handle, const struct pa handler = lb_find_livebox(pkgname, id); if (!handler) { - ErrPrint("Livebox(%s - %s) is not found\n", pkgname, id); - ret = -ENOENT; + ErrPrint("Livebox(%s) is not found\n", id); goto out; } if (handler->state != CREATE) { - ErrPrint("Hander is not created yet\n"); - ret = -EPERM; + ErrPrint("Livebox(%s) is not created yet\n", id); goto out; } @@ -480,7 +464,7 @@ static struct packet *master_size_changed(pid_t pid, int handle, const struct pa lb_set_pdsize(handler, w, h); lb_invoke_event_handler(handler, LB_EVENT_PD_SIZE_CHANGED); } else { - ErrPrint("This is not possible. PD Size is changed but the return value is not ZERO\n"); + ErrPrint("This is not possible. PD Size is changed but the return value is not ZERO (%d)\n", status); } } else { if (status == 0) { @@ -493,7 +477,7 @@ static struct packet *master_size_changed(pid_t pid, int handle, const struct pa * Update it too. */ if (lb_get_lb_fb(handler)) - lb_set_lb_fb(handler, id); + (void)lb_set_lb_fb(handler, id); /*! * \NOTE @@ -535,19 +519,17 @@ static struct packet *master_period_changed(pid_t pid, int handle, const struct ret = packet_get(packet, "idss", &status, &period, &pkgname, &id); if (ret != 4) { ErrPrint("Invalid argument\n"); - ret = -EINVAL; goto out; } handler = lb_find_livebox(pkgname, id); if (!handler) { - ErrPrint("Livebox(%s - %s) is not found\n", pkgname, id); - ret = -ENOENT; + ErrPrint("Livebox(%s) is not found\n", id); goto out; } if (handler->state != CREATE) { - ret = -EPERM; + ErrPrint("Livebox(%s) is not created\n", id); goto out; } @@ -560,12 +542,10 @@ static struct packet *master_period_changed(pid_t pid, int handle, const struct handler->period_changed_cb = NULL; handler->period_cbdata = NULL; - } else { + } else if (status == 0) { lb_invoke_event_handler(handler, LB_EVENT_PERIOD_CHANGED); } - ret = 0; - out: return NULL; } @@ -583,13 +563,12 @@ static struct packet *master_group_changed(pid_t pid, int handle, const struct p ret = packet_get(packet, "ssiss", &pkgname, &id, &status, &cluster, &category); if (ret != 5) { ErrPrint("Invalid argument\n"); - ret = -EINVAL; goto out; } handler = lb_find_livebox(pkgname, id); if (!handler) { - ret = -ENOENT; + ErrPrint("Livebox(%s) is not exists\n", id); goto out; } @@ -599,25 +578,23 @@ static struct packet *master_group_changed(pid_t pid, int handle, const struct p * Do no access this handler, * You cannot believe this handler anymore. */ - ret = -EPERM; + ErrPrint("Livebox(%s) is not created\n", id); goto out; } DbgPrint("Group is changed? [%s] / [%s] (%d)\n", cluster, category, status); if (status == 0) - lb_set_group(handler, cluster, category); + (void)lb_set_group(handler, cluster, category); if (handler->group_changed_cb) { handler->group_changed_cb(handler, status, handler->group_cbdata); handler->group_changed_cb = NULL; handler->group_cbdata = NULL; - } else { + } else if (status == 0) { lb_invoke_event_handler(handler, LB_EVENT_GROUP_CHANGED); } - ret = 0; - out: return NULL; } @@ -664,7 +641,7 @@ static struct packet *master_created(pid_t pid, int handle, const struct packet &lb_type, &pd_type, &period, &title, &is_pinned_up); if (ret != 22) { ErrPrint("Invalid argument\n"); - ret = -EINVAL; + ret = LB_STATUS_ERROR_INVALID; goto out; } @@ -684,7 +661,7 @@ static struct packet *master_created(pid_t pid, int handle, const struct packet handler = lb_new_livebox(pkgname, id, timestamp); if (!handler) { ErrPrint("Failed to create a new livebox\n"); - ret = -EFAULT; + ret = LB_STATUS_ERROR_FAULT; goto out; } @@ -697,7 +674,7 @@ static struct packet *master_created(pid_t pid, int handle, const struct packet * This is not possible!!! */ ErrPrint("Invalid handler\n"); - ret = -EINVAL; + ret = LB_STATUS_ERROR_INVALID; goto out; } @@ -718,7 +695,7 @@ static struct packet *master_created(pid_t pid, int handle, const struct packet content, cluster, category, lb_fname, pd_fname); - ret = -EALREADY; + ret = LB_STATUS_ERROR_ALREADY; goto out; } @@ -818,7 +795,7 @@ out: * Do not clear this to use this from the deleted event callback. * if this value is not cleared when the deleted event callback check it, * it means that the created function is not called yet. - * Then the call the deleted event callback with -ECANCELED errno. + * Then the call the deleted event callback with LB_STATUS_ERROR_CANCEL errno. */ } diff --git a/src/critical_log.c b/src/critical_log.c index 8b626c5..d97521d 100644 --- a/src/critical_log.c +++ b/src/critical_log.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ #include "debug.h" #include "util.h" #include "critical_log.h" +#include "livebox-errno.h" /* For error code */ static struct { FILE *fp; @@ -52,7 +53,7 @@ int critical_log(const char *func, int line, const char *fmt, ...) struct timeval tv; if (!s_info.fp) - return -EIO; + return LB_STATUS_ERROR_IO; gettimeofday(&tv, NULL); fprintf(s_info.fp, "%d %lu.%lu [%s:%d] ", getpid(), tv.tv_sec, tv.tv_usec, util_basename((char *)func), line); @@ -101,7 +102,7 @@ int critical_log_init(const char *name) s_info.filename = strdup(name); if (!s_info.filename) { ErrPrint("Failed to create a log file\n"); - return -ENOMEM; + return LB_STATUS_ERROR_MEMORY; } namelen = strlen(name) + strlen(SLAVE_LOG_PATH) + 20; @@ -111,7 +112,7 @@ int critical_log_init(const char *name) ErrPrint("Failed to create a log file\n"); free(s_info.filename); s_info.filename = NULL; - return -ENOMEM; + return LB_STATUS_ERROR_MEMORY; } snprintf(filename, namelen, "%s/%d_%s", SLAVE_LOG_PATH, s_info.file_id, name); @@ -122,7 +123,7 @@ int critical_log_init(const char *name) free(s_info.filename); s_info.filename = NULL; free(filename); - return -EIO; + return LB_STATUS_ERROR_IO; } free(filename); diff --git a/src/desc_parser.c b/src/desc_parser.c index 25595c0..69b70d2 100644 --- a/src/desc_parser.c +++ b/src/desc_parser.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ #include #include +#include #include "debug.h" #include "livebox.h" @@ -53,8 +54,8 @@ struct block { char *file; int file_len; - char *group; - int group_len; + char *option; + int option_len; char *id; int id_len; @@ -66,7 +67,7 @@ static int update_text(struct livebox *handle, struct block *block, int is_pd) if (!block || !block->part || !block->data) { ErrPrint("Invalid argument\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } ops = is_pd ? &handle->pd.data.ops : &handle->lb.data.ops; @@ -81,12 +82,12 @@ static int update_image(struct livebox *handle, struct block *block, int is_pd) struct livebox_script_operators *ops; if (!block || !block->part) { ErrPrint("Invalid argument\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } ops = is_pd ? &handle->pd.data.ops : &handle->lb.data.ops; if (ops->update_image) - ops->update_image(handle, block->id, block->part, block->data); + ops->update_image(handle, block->id, block->part, block->data, block->option); return 0; } @@ -96,12 +97,12 @@ static int update_script(struct livebox *handle, struct block *block, int is_pd) struct livebox_script_operators *ops; if (!block || !block->part) { ErrPrint("Invalid argument\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } ops = is_pd ? &handle->pd.data.ops : &handle->lb.data.ops; if (ops->update_script) - ops->update_script(handle, block->id, block->part, block->data, block->group); + ops->update_script(handle, block->id, block->part, block->data, block->option); return 0; } @@ -112,7 +113,7 @@ static int update_signal(struct livebox *handle, struct block *block, int is_pd) if (!block) { ErrPrint("Invalid argument\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } ops = is_pd ? &handle->pd.data.ops : &handle->lb.data.ops; @@ -129,14 +130,14 @@ static int update_drag(struct livebox *handle, struct block *block, int is_pd) if (!block || !block->data || !block->part) { ErrPrint("Invalid argument\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } ops = is_pd ? &handle->pd.data.ops : &handle->lb.data.ops; if (sscanf(block->data, "%lfx%lf", &dx, &dy) != 2) { ErrPrint("Invalid format of data\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (ops->update_drag) @@ -151,7 +152,7 @@ static int update_info(struct livebox *handle, struct block *block, int is_pd) if (!block || !block->part || !block->data) { ErrPrint("Invalid argument\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } ops = is_pd ? &handle->pd.data.ops : &handle->lb.data.ops; @@ -161,7 +162,7 @@ static int update_info(struct livebox *handle, struct block *block, int is_pd) if (sscanf(block->data, "%dx%d", &w, &h) != 2) { ErrPrint("Invalid format (%s)\n", block->data); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (ops->update_info_size) @@ -214,7 +215,7 @@ int parse_desc(struct livebox *handle, const char *descfile, int is_pd) VALUE_PART = 0x01, VALUE_DATA = 0x02, VALUE_FILE = 0x03, - VALUE_GROUP = 0x04, + VALUE_OPTION = 0x04, VALUE_ID = 0x05, }; const char *field_name[] = { @@ -222,7 +223,7 @@ int parse_desc(struct livebox *handle, const char *descfile, int is_pd) "part", "data", "file", - "group", + "option", "id", NULL }; @@ -268,7 +269,7 @@ int parse_desc(struct livebox *handle, const char *descfile, int is_pd) fp = fopen(descfile, "rt"); if (!fp) { ErrPrint("Error: %s\n", strerror(errno)); - return -EIO; + return LB_STATUS_ERROR_IO; } update_begin(handle, is_pd); @@ -290,7 +291,7 @@ int parse_desc(struct livebox *handle, const char *descfile, int is_pd) if (!isspace(ch)) { update_end(handle, is_pd); fclose(fp); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } break; @@ -306,7 +307,7 @@ int parse_desc(struct livebox *handle, const char *descfile, int is_pd) CRITICAL_LOG("Heap: %s\n", strerror(errno)); update_end(handle, is_pd); fclose(fp); - return -ENOMEM; + return LB_STATUS_ERROR_MEMORY; } state = FIELD; @@ -365,11 +366,11 @@ int parse_desc(struct livebox *handle, const char *descfile, int is_pd) idx = 0; break; case 4: - state = VALUE_GROUP; - if (block->group) { - free(block->group); - block->group = NULL; - block->group_len = 0; + state = VALUE_OPTION; + if (block->option) { + free(block->option); + block->option = NULL; + block->option_len = 0; } idx = 0; break; @@ -496,25 +497,25 @@ int parse_desc(struct livebox *handle, const char *descfile, int is_pd) idx++; break; - case VALUE_GROUP: - if (idx == block->group_len) { - block->group_len += 256; - block->group = realloc(block->group, block->group_len); - if (!block->group) { + case VALUE_OPTION: + if (idx == block->option_len) { + block->option_len += 256; + block->option = realloc(block->option, block->option_len); + if (!block->option) { CRITICAL_LOG("Heap: %s\n", strerror(errno)); goto errout; } } if (ch == '\n') { - block->group[idx] = '\0'; + block->option[idx] = '\0'; state = FIELD; idx = 0; field_idx = 0; break; } - block->group[idx] = ch; + block->option[idx] = ch; idx++; break; case VALUE_ID: @@ -561,7 +562,7 @@ int parse_desc(struct livebox *handle, const char *descfile, int is_pd) free(block->type); free(block->part); free(block->data); - free(block->group); + free(block->option); free(block->id); free(block); block = NULL; @@ -589,7 +590,7 @@ errout: free(block->type); free(block->part); free(block->data); - free(block->group); + free(block->option); free(block->id); free(block); } @@ -597,7 +598,7 @@ errout: update_end(handle, is_pd); fclose(fp); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } /* End of a file */ diff --git a/src/dlist.c b/src/dlist.c index 56ff060..78c76ba 100644 --- a/src/dlist.c +++ b/src/dlist.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/fb.c b/src/fb.c index 1e687ef..d1fe2de 100644 --- a/src/fb.c +++ b/src/fb.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ #include #include +#include /* For error code */ #include "debug.h" #include "util.h" @@ -113,16 +114,16 @@ static inline int sync_for_file(struct fb_info *info) buffer = info->buffer; if (!buffer) /* Ignore this sync request */ - return 0; + return LB_STATUS_SUCCESS; if (buffer->state != CREATED) { ErrPrint("Invalid state of a FB\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (buffer->type != BUFFER_TYPE_FILE) { DbgPrint("Invalid buffer\n"); - return 0; + return LB_STATUS_SUCCESS; } fd = open(util_uri_to_path(info->id), O_RDONLY); @@ -137,7 +138,7 @@ static inline int sync_for_file(struct fb_info *info) * * and then update it after it gots update events */ - return 0; + return LB_STATUS_SUCCESS; } if (read(fd, buffer->data, info->bufsz) != info->bufsz) { @@ -151,11 +152,11 @@ static inline int sync_for_file(struct fb_info *info) * * and then update it after it gots update events */ - return 0; + return LB_STATUS_SUCCESS; } close(fd); - return 0; + return LB_STATUS_SUCCESS; } static inline __attribute__((always_inline)) int sync_for_pixmap(struct fb_info *info) @@ -166,16 +167,16 @@ static inline __attribute__((always_inline)) int sync_for_pixmap(struct fb_info buffer = info->buffer; if (!buffer) /*!< Ignore this sync request */ - return 0; + return LB_STATUS_SUCCESS; if (buffer->state != CREATED) { ErrPrint("Invalid state of a FB\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (buffer->type != BUFFER_TYPE_PIXMAP) { DbgPrint("Invalid buffer\n"); - return 0; + return LB_STATUS_SUCCESS; } if (!s_info.disp) { @@ -191,24 +192,24 @@ static inline __attribute__((always_inline)) int sync_for_pixmap(struct fb_info s_info.visual = DefaultVisualOfScreen(screen); } else { ErrPrint("Failed to open a display\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } } if (info->handle == 0) { DbgPrint("Pixmap ID is not valid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (info->bufsz == 0) { DbgPrint("Nothing can be sync\n"); - return 0; + return LB_STATUS_SUCCESS; } si.shmid = shmget(IPC_PRIVATE, info->bufsz, IPC_CREAT | 0666); if (si.shmid < 0) { ErrPrint("shmget: %s\n", strerror(errno)); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } si.readOnly = False; @@ -218,7 +219,7 @@ static inline __attribute__((always_inline)) int sync_for_pixmap(struct fb_info if (shmctl(si.shmid, IPC_RMID, 0) < 0) ErrPrint("shmctl: %s\n", strerror(errno)); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } /*! @@ -236,7 +237,7 @@ static inline __attribute__((always_inline)) int sync_for_pixmap(struct fb_info if (shmctl(si.shmid, IPC_RMID, 0) < 0) ErrPrint("shmctl: %s\n", strerror(errno)); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } xim->data = si.shmaddr; @@ -256,19 +257,19 @@ static inline __attribute__((always_inline)) int sync_for_pixmap(struct fb_info if (shmctl(si.shmid, IPC_RMID, 0) < 0) ErrPrint("shmctl: %s\n", strerror(errno)); - return 0; + return LB_STATUS_SUCCESS; } int fb_sync(struct fb_info *info) { if (!info) { ErrPrint("FB Handle is not valid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (!info->id || info->id[0] == '\0') { DbgPrint("Ingore sync\n"); - return 0; + return LB_STATUS_SUCCESS; } if (!strncasecmp(info->id, SCHEMA_FILE, strlen(SCHEMA_FILE))) { @@ -277,10 +278,10 @@ int fb_sync(struct fb_info *info) return sync_for_pixmap(info); } else if (!strncasecmp(info->id, SCHEMA_SHM, strlen(SCHEMA_SHM))) { /* No need to do sync */ - return 0; + return LB_STATUS_SUCCESS; } - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } struct fb_info *fb_create(const char *id, int w, int h) @@ -310,7 +311,7 @@ struct fb_info *fb_create(const char *id, int w, int h) } else if (sscanf(info->id, SCHEMA_PIXMAP "%d", &info->handle) == 1) { DbgPrint("PIXMAP-SHMID: %d is gotten\n", info->handle); } else { - info->handle = -EINVAL; + info->handle = LB_STATUS_ERROR_INVALID; } info->bufsz = 0; @@ -325,7 +326,7 @@ int fb_destroy(struct fb_info *info) { if (!info) { ErrPrint("Handle is not valid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (info->buffer) { @@ -337,7 +338,7 @@ int fb_destroy(struct fb_info *info) free(info->id); free(info); - return 0; + return LB_STATUS_SUCCESS; } int fb_is_created(struct fb_info *info) @@ -454,7 +455,7 @@ int fb_release_buffer(void *data) if (buffer->state != CREATED) { ErrPrint("Invalid handle\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } switch (buffer->type) { @@ -503,20 +504,20 @@ int fb_refcnt(void *data) int ret; if (!data) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; buffer = container_of(data, struct buffer, data); if (buffer->state != CREATED) { ErrPrint("Invalid handle\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } switch (buffer->type) { case BUFFER_TYPE_SHM: if (shmctl(buffer->refcnt, IPC_STAT, &buf) < 0) { ErrPrint("Error: %s\n", strerror(errno)); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } ret = buf.shm_nattch; @@ -528,7 +529,7 @@ int fb_refcnt(void *data) ret = buffer->refcnt; break; default: - ret = -EINVAL; + ret = LB_STATUS_ERROR_INVALID; break; } @@ -544,12 +545,12 @@ int fb_get_size(struct fb_info *info, int *w, int *h) { if (!info) { ErrPrint("Handle is not valid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } *w = info->w; *h = info->h; - return 0; + return LB_STATUS_SUCCESS; } int fb_size(struct fb_info *info) diff --git a/src/livebox.c b/src/livebox.c index bfa4f41..826cf4b 100644 --- a/src/livebox.c +++ b/src/livebox.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ #include #include #include +#include #include "debug.h" #include "fb.h" @@ -147,10 +148,10 @@ static void resize_cb(struct livebox *handler, const struct packet *result, void destroy_cb_info(info); if (!result) { - ret = -EFAULT; + ret = LB_STATUS_ERROR_FAULT; } else if (packet_get(result, "i", &ret) != 1) { ErrPrint("Invalid argument\n"); - ret = -EINVAL; + ret = LB_STATUS_ERROR_INVALID; } /*! @@ -184,10 +185,10 @@ static void text_signal_cb(struct livebox *handler, const struct packet *result, destroy_cb_info(info); if (!result) { - ret = -EFAULT; + ret = LB_STATUS_ERROR_FAULT; } else if (packet_get(result, "i", &ret) != 1) { ErrPrint("Invalid argument\n"); - ret = -EINVAL; + ret = LB_STATUS_ERROR_INVALID; } if (cb) @@ -207,10 +208,10 @@ static void set_group_ret_cb(struct livebox *handler, const struct packet *resul destroy_cb_info(info); if (!result) { - ret = -EFAULT; + ret = LB_STATUS_ERROR_FAULT; } else if (packet_get(result, "i", &ret) != 1) { ErrPrint("Invalid argument\n"); - ret = -EINVAL; + ret = LB_STATUS_ERROR_INVALID; } if (ret == 0) { /*!< Group information is successfully changed */ @@ -235,10 +236,10 @@ static void period_ret_cb(struct livebox *handler, const struct packet *result, destroy_cb_info(info); if (!result) { - ret = -EFAULT; + ret = LB_STATUS_ERROR_FAULT; } else if (packet_get(result, "i", &ret) != 1) { ErrPrint("Invalid argument\n"); - ret = -EINVAL; + ret = LB_STATUS_ERROR_INVALID; } if (ret == 0) { @@ -262,10 +263,10 @@ static void del_ret_cb(struct livebox *handler, const struct packet *result, voi if (!result) { ErrPrint("Connection lost?\n"); - ret = -EFAULT; + ret = LB_STATUS_ERROR_FAULT; } else if (packet_get(result, "i", &ret) != 1) { ErrPrint("Invalid argument\n"); - ret = -EINVAL; + ret = LB_STATUS_ERROR_INVALID; } if (ret == 0) { @@ -299,9 +300,9 @@ static void new_ret_cb(struct livebox *handler, const struct packet *result, voi destroy_cb_info(info); if (!result) { - ret = -EFAULT; + ret = LB_STATUS_ERROR_FAULT; } else if (packet_get(result, "i", &ret) != 1) { - ret = -EINVAL; + ret = LB_STATUS_ERROR_INVALID; } if (ret >= 0) { @@ -339,9 +340,9 @@ static void pd_create_cb(struct livebox *handler, const struct packet *result, v destroy_cb_info(data); if (!result) { - ret = -EFAULT; + ret = LB_STATUS_ERROR_FAULT; } else if (packet_get(result, "i", &ret) != 1) { - ret = -EINVAL; + ret = LB_STATUS_ERROR_INVALID; } if (ret == 0) { @@ -367,9 +368,9 @@ static void activated_cb(struct livebox *handler, const struct packet *result, v destroy_cb_info(info); if (!result) { - ret = -EFAULT; + ret = LB_STATUS_ERROR_FAULT; } else if (packet_get(result, "is", &ret, &pkgname) != 2) { - ret = -EINVAL; + ret = LB_STATUS_ERROR_INVALID; } if (cb) @@ -389,10 +390,10 @@ static void pd_destroy_cb(struct livebox *handler, const struct packet *result, if (!result) { DbgPrint("Result is NIL (may connection lost)\n"); - ret = -EFAULT; + ret = LB_STATUS_ERROR_FAULT; } else if (packet_get(result, "i", &ret) != 1) { DbgPrint("Invalid parameter\n"); - ret = -EINVAL; + ret = LB_STATUS_ERROR_INVALID; } if (ret == 0) { @@ -418,9 +419,9 @@ static void delete_cluster_cb(struct livebox *handler, const struct packet *resu destroy_cb_info(info); if (!result) { - ret = -EFAULT; + ret = LB_STATUS_ERROR_FAULT; } else if (packet_get(result, "i", &ret) != 1) { - ret = -EINVAL; + ret = LB_STATUS_ERROR_INVALID; } DbgPrint("Delete category returns: %d\n", ret); @@ -441,9 +442,9 @@ static void delete_category_cb(struct livebox *handler, const struct packet *res destroy_cb_info(info); if (!result) - ret = -EFAULT; + ret = LB_STATUS_ERROR_FAULT; else if (packet_get(result, "i", &ret) != 1) - ret = -EINVAL; + ret = LB_STATUS_ERROR_INVALID; DbgPrint("Delete category returns: %d\n", ret); @@ -483,9 +484,9 @@ static void pinup_done_cb(struct livebox *handler, const struct packet *result, destroy_cb_info(info); if (!result) - ret = -EFAULT; + ret = LB_STATUS_ERROR_FAULT; else if (packet_get(result, "i", &ret) != 1) - ret = -EINVAL; + ret = LB_STATUS_ERROR_INVALID; if (ret == 0) { handler->pinup_cb = cb; @@ -504,7 +505,7 @@ static int send_mouse_event(struct livebox *handler, const char *event, int x, i packet = packet_create_noack(event, "ssdii", handler->pkgname, handler->id, timestamp, x, y); if (!packet) { ErrPrint("Failed to build param\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } DbgPrint("Send: %dx%d\n", x, y); @@ -518,7 +519,7 @@ EAPI int livebox_init(void *disp) if (s_info.init_count > 0) { s_info.init_count++; - return 0; + return LB_STATUS_SUCCESS; } env = getenv("PROVIDER_DISABLE_PREVENT_OVERWRITE"); if (env && !strcasecmp(env, "true")) @@ -542,27 +543,27 @@ EAPI int livebox_init(void *disp) client_init(); s_info.init_count++; - return 0; + return LB_STATUS_SUCCESS; } EAPI int livebox_fini(void) { if (s_info.init_count <= 0) { DbgPrint("Didn't initialized\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } s_info.init_count--; if (s_info.init_count > 0) { DbgPrint("init count : %d\n", s_info.init_count); - return 0; + return LB_STATUS_SUCCESS; } client_fini(); fb_fini(); livebox_service_fini(); critical_log_fini(); - return 0; + return LB_STATUS_SUCCESS; } static inline char *lb_pkgname(const char *pkgname) @@ -611,7 +612,6 @@ EAPI struct livebox *livebox_add_with_size(const char *pkgname, const char *cont handler->pkgname = lb_pkgname(pkgname); if (!handler->pkgname) { - ErrPrint("Error: %s\n", strerror(errno)); free(handler); return NULL; } @@ -717,28 +717,28 @@ EAPI int livebox_set_period(struct livebox *handler, double period, ret_cb_t cb, if (!handler || handler->state != CREATE || !handler->id) { ErrPrint("Handler is not valid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->period_changed_cb) { ErrPrint("Previous request for changing period is not finished\n"); - return -EBUSY; + return LB_STATUS_ERROR_BUSY; } if (!handler->is_user) { ErrPrint("CA Livebox is not able to change the period\n"); - return -EPERM; + return LB_STATUS_ERROR_PERMISSION; } if (handler->lb.period == period) { DbgPrint("No changes\n"); - return -EALREADY; + return LB_STATUS_ERROR_ALREADY; } packet = packet_create("set_period", "ssd", handler->pkgname, handler->id, period); if (!packet) { ErrPrint("Failed to build a packet %s\n", handler->pkgname); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } if (!cb) @@ -751,12 +751,12 @@ EAPI int livebox_del(struct livebox *handler, ret_cb_t cb, void *data) { if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->state != CREATE) { ErrPrint("Handler is already deleted\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } handler->state = DELETE; @@ -773,7 +773,7 @@ EAPI int livebox_del(struct livebox *handler, ret_cb_t cb, void *data) */ if (cb) cb(handler, 0, data); - return 0; + return LB_STATUS_SUCCESS; } if (!cb) @@ -787,19 +787,19 @@ EAPI int livebox_set_fault_handler(int (*cb)(enum livebox_fault_type, const char struct fault_info *info; if (!cb) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; info = malloc(sizeof(*info)); if (!info) { CRITICAL_LOG("Heap: %s\n", strerror(errno)); - return -ENOMEM; + return LB_STATUS_ERROR_MEMORY; } info->handler = cb; info->user_data = data; s_info.fault_list = dlist_append(s_info.fault_list, info); - return 0; + return LB_STATUS_SUCCESS; } EAPI void *livebox_unset_fault_handler(int (*cb)(enum livebox_fault_type, const char *, const char *, const char *, void *)) @@ -827,20 +827,20 @@ EAPI int livebox_set_event_handler(int (*cb)(struct livebox *, enum livebox_even if (!cb) { ErrPrint("Invalid argument cb is nil\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } info = malloc(sizeof(*info)); if (!info) { CRITICAL_LOG("Heap: %s\n", strerror(errno)); - return -ENOMEM; + return LB_STATUS_ERROR_MEMORY; } info->handler = cb; info->user_data = data; s_info.event_list = dlist_append(s_info.event_list, info); - return 0; + return LB_STATUS_SUCCESS; } EAPI void *livebox_unset_event_handler(int (*cb)(struct livebox *, enum livebox_event_type, void *)) @@ -871,38 +871,38 @@ EAPI int livebox_resize(struct livebox *handler, int type, ret_cb_t cb, void *da if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->state != CREATE || !handler->id) { ErrPrint("Handler is not valid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->size_changed_cb) { ErrPrint("Previous resize request is not finished yet\n"); - return -EBUSY; + return LB_STATUS_ERROR_BUSY; } if (!handler->is_user) { ErrPrint("CA Livebox is not able to be resized\n"); - return -EPERM; + return LB_STATUS_ERROR_PERMISSION; } if (livebox_service_get_size(type, &w, &h) != 0) { ErrPrint("Invalid size type\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->lb.width == w && handler->lb.height == h) { DbgPrint("No changes\n"); - return -EALREADY; + return LB_STATUS_ERROR_ALREADY;; } packet = packet_create("resize", "ssii", handler->pkgname, handler->id, w, h); if (!packet) { ErrPrint("Failed to build param\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } if (!cb) @@ -919,12 +919,12 @@ EAPI int livebox_click(struct livebox *handler, double x, double y) if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->state != CREATE || !handler->id) { ErrPrint("Handler is not valid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->lb.auto_launch) @@ -935,10 +935,11 @@ EAPI int livebox_click(struct livebox *handler, double x, double y) packet = packet_create_noack("clicked", "sssddd", handler->pkgname, handler->id, "clicked", timestamp, x, y); if (!packet) { ErrPrint("Failed to build param\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } 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 */ @@ -962,12 +963,12 @@ EAPI int livebox_has_pd(struct livebox *handler) { if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->state != CREATE || !handler->id) { ErrPrint("Handler is not valid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } return !!handler->pd.data.fb; @@ -977,12 +978,12 @@ EAPI int livebox_pd_is_created(struct livebox *handler) { if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) { ErrPrint("Handler is not valid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } return handler->is_pd_created; @@ -999,23 +1000,23 @@ EAPI int livebox_create_pd_with_position(struct livebox *handler, double x, doub if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) { ErrPrint("Handler is not valid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->is_pd_created == 1) { DbgPrint("PD already created\n"); - return 0; + return LB_STATUS_SUCCESS; } packet = packet_create("create_pd", "ssdd", handler->pkgname, handler->id, x, y); if (!packet) { ErrPrint("Failed to build param\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } if (!cb) @@ -1030,23 +1031,23 @@ EAPI int livebox_move_pd(struct livebox *handler, double x, double y) if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) { ErrPrint("Handler is not valid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (!handler->is_pd_created) { DbgPrint("PD is not created\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } packet = packet_create_noack("pd_move", "ssdd", handler->pkgname, handler->id, x, y); if (!packet) { ErrPrint("Failed to build param\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } return master_rpc_request_only(handler, packet); @@ -1057,12 +1058,12 @@ EAPI int livebox_activate(const char *pkgname, ret_cb_t cb, void *data) struct packet *packet; if (!pkgname) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; packet = packet_create("activate_package", "s", pkgname); if (!packet) { ErrPrint("Failed to build a param\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } return master_rpc_async_request(NULL, packet, 0, activated_cb, create_cb_info(cb, data)); @@ -1074,23 +1075,23 @@ EAPI int livebox_destroy_pd(struct livebox *handler, ret_cb_t cb, void *data) if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) { ErrPrint("Handler is not valid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (!handler->is_pd_created) { ErrPrint("PD is not created\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } packet = packet_create("destroy_pd", "ss", handler->pkgname, handler->id); if (!packet) { ErrPrint("Failed to build a param\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } if (!cb) @@ -1108,12 +1109,12 @@ EAPI int livebox_content_event(struct livebox *handler, enum content_event_type if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->state != CREATE || !handler->id) { ErrPrint("Handler is not valid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (type & CONTENT_EVENT_PD_MASK) { @@ -1121,18 +1122,18 @@ EAPI int livebox_content_event(struct livebox *handler, enum content_event_type if (!handler->is_pd_created) { ErrPrint("PD is not created\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (type & CONTENT_EVENT_MOUSE_MASK) { if (!handler->pd.data.fb) { ErrPrint("Handler is not valid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (type & CONTENT_EVENT_MOUSE_MOVE) { if (fabs(x - handler->pd.x) < MINIMUM_EVENT && fabs(y - handler->pd.y) < MINIMUM_EVENT) - return -EBUSY; + return LB_STATUS_ERROR_BUSY; } else if (type & CONTENT_EVENT_MOUSE_SET) { flag = 0; } @@ -1152,17 +1153,17 @@ EAPI int livebox_content_event(struct livebox *handler, enum content_event_type if (type & CONTENT_EVENT_MOUSE_MASK) { if (!handler->lb.mouse_event) { ErrPrint("Box is not support the mouse event\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (!handler->lb.data.fb) { ErrPrint("Handler is not valid\n"); - return -EINVAL; + 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) - return -EBUSY; + return LB_STATUS_ERROR_BUSY; } else if (type & CONTENT_EVENT_MOUSE_SET) { flag = 0; } @@ -1226,7 +1227,7 @@ EAPI int livebox_content_event(struct livebox *handler, enum content_event_type break; default: ErrPrint("Invalid event type\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } return send_mouse_event(handler, cmd, x * w, y * h); @@ -1258,12 +1259,12 @@ EAPI int livebox_get_pdsize(struct livebox *handler, int *w, int *h) if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->state != CREATE || !handler->id) { ErrPrint("Handler is not valid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (!w) @@ -1280,7 +1281,7 @@ EAPI int livebox_get_pdsize(struct livebox *handler, int *w, int *h) *h = handler->pd.height; } - return 0; + return LB_STATUS_SUCCESS; } EAPI int livebox_size(struct livebox *handler) @@ -1290,12 +1291,12 @@ EAPI int livebox_size(struct livebox *handler) if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->state != CREATE || !handler->id) { ErrPrint("Handler is not valid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } w = handler->lb.width; @@ -1323,33 +1324,33 @@ EAPI int livebox_set_group(struct livebox *handler, const char *cluster, const c if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (!cluster || !category || handler->state != CREATE || !handler->id) { ErrPrint("Invalid argument\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->group_changed_cb) { ErrPrint("Previous group changing request is not finished yet\n"); - return -EBUSY; + return LB_STATUS_ERROR_BUSY; } if (!handler->is_user) { ErrPrint("CA Livebox is not able to change the group\n"); - return -EPERM; + return LB_STATUS_ERROR_PERMISSION; } if (!strcmp(handler->cluster, cluster) && !strcmp(handler->category, category)) { DbgPrint("No changes\n"); - return -EALREADY; + return LB_STATUS_ERROR_ALREADY; } packet = packet_create("change_group", "ssss", handler->pkgname, handler->id, cluster, category); if (!packet) { ErrPrint("Failed to build a param\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } if (!cb) @@ -1362,17 +1363,17 @@ EAPI int livebox_get_group(struct livebox *handler, char ** const cluster, char { if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (!cluster || !category || handler->state != CREATE || !handler->id) { ErrPrint("Invalid argument\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } *cluster = handler->cluster; *category = handler->category; - return 0; + return LB_STATUS_SUCCESS; } EAPI int livebox_get_supported_sizes(struct livebox *handler, int *cnt, int *size_list) @@ -1382,12 +1383,12 @@ EAPI int livebox_get_supported_sizes(struct livebox *handler, int *cnt, int *siz if (!handler || !size_list) { ErrPrint("Invalid argument, handler(%p), size_list(%p)\n", handler, size_list); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (!cnt || handler->state != CREATE || !handler->id) { ErrPrint("Handler is not valid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } for (j = i = 0; i < NR_OF_SIZE_LIST; i++) { @@ -1400,7 +1401,7 @@ EAPI int livebox_get_supported_sizes(struct livebox *handler, int *cnt, int *siz } *cnt = j; - return 0; + return LB_STATUS_SUCCESS; } EAPI const char *livebox_pkgname(struct livebox *handler) @@ -1440,7 +1441,7 @@ EAPI int livebox_delete_cluster(const char *cluster, ret_cb_t cb, void *data) packet = packet_create("delete_cluster", "s", cluster); if (!packet) { ErrPrint("Failed to build a param\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } return master_rpc_async_request(NULL, packet, 0, delete_cluster_cb, create_cb_info(cb, data)); @@ -1453,7 +1454,7 @@ EAPI int livebox_delete_category(const char *cluster, const char *category, ret_ packet = packet_create("delete_category", "ss", cluster, category); if (!packet) { ErrPrint("Failed to build a param\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } return master_rpc_async_request(NULL, packet, 0, delete_category_cb, create_cb_info(cb, data)); @@ -1527,32 +1528,32 @@ EAPI int livebox_set_pd_text_handler(struct livebox *handler, struct livebox_scr { if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->state != CREATE) { ErrPrint("Handler is not valid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } memcpy(&handler->pd.data.ops, ops, sizeof(*ops)); - return 0; + return LB_STATUS_SUCCESS; } EAPI int livebox_set_text_handler(struct livebox *handler, struct livebox_script_operators *ops) { if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->state != CREATE) { ErrPrint("Handler is not valid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } memcpy(&handler->lb.data.ops, ops, sizeof(*ops)); - return 0; + return LB_STATUS_SUCCESS; } EAPI int livebox_acquire_lb_pixmap(struct livebox *handler, ret_cb_t cb, void *data) @@ -1562,27 +1563,27 @@ EAPI int livebox_acquire_lb_pixmap(struct livebox *handler, ret_cb_t cb, void *d if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->state != CREATE || !handler->id) { ErrPrint("Invalid handle\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->lb.type != _LB_TYPE_SCRIPT && handler->lb.type != _LB_TYPE_BUFFER) { ErrPrint("Handler is not valid type\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } id = fb_id(handler->lb.data.fb); if (!id || strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP))) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; packet = packet_create("lb_acquire_pixmap", "ss", handler->pkgname, handler->id); if (!packet) { ErrPrint("Failed to build a param\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } return master_rpc_async_request(handler, packet, 0, pixmap_acquired_cb, create_cb_info(cb, data)); @@ -1594,23 +1595,23 @@ EAPI int livebox_release_lb_pixmap(struct livebox *handler, int pixmap) if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->state != CREATE || !handler->id) { ErrPrint("Invalid handle\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->lb.type != _LB_TYPE_SCRIPT && handler->lb.type != _LB_TYPE_BUFFER) { ErrPrint("Handler is not valid type\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } packet = packet_create_noack("lb_release_pixmap", "ssi", handler->pkgname, handler->id, pixmap); if (!packet) { ErrPrint("Failed to build a param\n"); - return -EFAULT; + return LB_STATUS_ERROR_INVALID; } return master_rpc_request_only(handler, packet); @@ -1623,27 +1624,27 @@ EAPI int livebox_acquire_pd_pixmap(struct livebox *handler, ret_cb_t cb, void *d if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->state != CREATE || !handler->id) { ErrPrint("Invalid handle\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->pd.type != _PD_TYPE_SCRIPT && handler->pd.type != _PD_TYPE_BUFFER) { ErrPrint("Handler is not valid type\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } id = fb_id(handler->pd.data.fb); if (!id || strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP))) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; packet = packet_create("pd_acquire_pixmap", "ss", handler->pkgname, handler->id); if (!packet) { ErrPrint("Failed to build a param\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } return master_rpc_async_request(handler, packet, 0, pixmap_acquired_cb, create_cb_info(cb, data)); @@ -1713,23 +1714,23 @@ EAPI int livebox_release_pd_pixmap(struct livebox *handler, int pixmap) if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->state != CREATE || !handler->id) { ErrPrint("Invalid handle\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->pd.type != _PD_TYPE_SCRIPT && handler->pd.type != _PD_TYPE_BUFFER) { ErrPrint("Handler is not valid type\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } packet = packet_create_noack("pd_release_pixmap", "ssi", handler->pkgname, handler->id, pixmap); if (!packet) { ErrPrint("Failed to build a param\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } return master_rpc_request_only(handler, packet); @@ -1799,12 +1800,12 @@ EAPI int livebox_pdfb_bufsz(struct livebox *handler) { if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->state != CREATE || !handler->id) { ErrPrint("Handler is not valid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } return fb_size(handler->pd.data.fb); @@ -1814,12 +1815,12 @@ EAPI int livebox_lbfb_bufsz(struct livebox *handler) { if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->state != CREATE || !handler->id) { ErrPrint("Handler is not valid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } return fb_size(handler->lb.data.fb); @@ -1829,12 +1830,12 @@ EAPI int livebox_is_user(struct livebox *handler) { if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->state != CREATE) { ErrPrint("Handler is invalid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } return handler->is_user; @@ -1846,28 +1847,28 @@ EAPI int livebox_set_pinup(struct livebox *handler, int flag, ret_cb_t cb, void if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->state != CREATE || !handler->id) { ErrPrint("Handler is not valid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->pinup_cb) { ErrPrint("Previous pinup request is not finished\n"); - return -EBUSY; + return LB_STATUS_ERROR_BUSY; } if (handler->is_pinned_up == flag) { DbgPrint("No changes\n"); - return -EALREADY; + return LB_STATUS_ERROR_ALREADY; } packet = packet_create("pinup_changed", "ssi", handler->pkgname, handler->id, flag); if (!packet) { ErrPrint("Failed to build a param\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } if (!cb) @@ -1880,11 +1881,11 @@ EAPI int livebox_is_pinned_up(struct livebox *handler) { if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->state != CREATE || !handler->id) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; return handler->is_pinned_up; } @@ -1893,11 +1894,11 @@ EAPI int livebox_has_pinup(struct livebox *handler) { if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->state != CREATE || !handler->id) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; return handler->lb.pinup_supported; } @@ -1906,14 +1907,14 @@ EAPI int livebox_set_data(struct livebox *handler, void *data) { if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->state != CREATE) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; handler->data = data; - return 0; + return LB_STATUS_SUCCESS; } EAPI void *livebox_get_data(struct livebox *handler) @@ -1974,12 +1975,12 @@ EAPI int livebox_emit_text_signal(struct livebox *handler, const char *emission, if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if ((handler->lb.type != _LB_TYPE_TEXT && handler->pd.type != _PD_TYPE_TEXT) || handler->state != CREATE || !handler->id) { ErrPrint("Handler is not valid\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (!emission) @@ -1992,7 +1993,7 @@ EAPI int livebox_emit_text_signal(struct livebox *handler, const char *emission, handler->pkgname, handler->id, emission, source, sx, sy, ex, ey); if (!packet) { ErrPrint("Failed to build a param\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } return master_rpc_async_request(handler, packet, 0, text_signal_cb, create_cb_info(cb, data)); @@ -2011,7 +2012,7 @@ EAPI int livebox_subscribe_group(const char *cluster, const char *category) packet = packet_create_noack("subscribe", "ss", cluster ? cluster : "", category ? category : ""); if (!packet) { ErrPrint("Failed to create a packet\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } return master_rpc_request_only(NULL, packet); @@ -2031,7 +2032,7 @@ EAPI int livebox_unsubscribe_group(const char *cluster, const char *category) packet = packet_create_noack("unsubscribe", "ss", cluster ? cluster : "", category ? category : ""); if (!packet) { ErrPrint("Failed to create a packet\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } return master_rpc_request_only(NULL, packet); @@ -2043,16 +2044,16 @@ EAPI int livebox_refresh(struct livebox *handler) if (!handler) { ErrPrint("Hnalder is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->state != CREATE || !handler->id) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; packet = packet_create_noack("update", "ss", handler->pkgname, handler->id); if (!packet) { ErrPrint("Failed to create a packet\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } return master_rpc_request_only(handler, packet); @@ -2064,13 +2065,13 @@ EAPI int livebox_refresh_group(const char *cluster, const char *category) if (!cluster || !category) { ErrPrint("Invalid argument\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } packet = packet_create_noack("refresh_group", "ss", cluster, category); if (!packet) { ErrPrint("Failed to create a packet\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } return master_rpc_request_only(NULL, packet); @@ -2083,29 +2084,29 @@ EAPI int livebox_set_visibility(struct livebox *handler, enum livebox_visible_st if (!handler) { ErrPrint("Handler is NIL\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->state != CREATE || !handler->id) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; if (!handler->is_user) { /* System cluster livebox cannot be changed its visible states */ if (state == LB_HIDE_WITH_PAUSE) { ErrPrint("CA Livebox is not able to change the visibility\n"); - return -EPERM; + return LB_STATUS_ERROR_PERMISSION; } } DbgPrint("Change the visibility %d <> %d, %s\n", handler->visible, state, handler->id); if (handler->visible == state) - return 0; + return LB_STATUS_ERROR_ALREADY; packet = packet_create_noack("change,visibility", "ssi", handler->pkgname, handler->id, (int)state); if (!packet) { ErrPrint("Failed to create a packet\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } ret = master_rpc_request_only(handler, packet); @@ -2122,7 +2123,7 @@ EAPI enum livebox_visible_state livebox_visibility(struct livebox *handler) return LB_VISIBLE_ERROR; } - if (handler->state != CREATE) + if (handler->state != CREATE || !handler->id) return LB_VISIBLE_ERROR; return handler->visible; @@ -2137,7 +2138,7 @@ int lb_set_group(struct livebox *handler, const char *cluster, const char *categ pc = strdup(cluster); if (!pc) { CRITICAL_LOG("Heap: %s (cluster: %s)\n", strerror(errno), cluster); - return -ENOMEM; + return LB_STATUS_ERROR_MEMORY; } } @@ -2146,7 +2147,7 @@ int lb_set_group(struct livebox *handler, const char *cluster, const char *categ if (!ps) { CRITICAL_LOG("Heap: %s (category: %s)\n", strerror(errno), category); free(pc); - return -ENOMEM; + return LB_STATUS_ERROR_MEMORY; } } @@ -2159,7 +2160,7 @@ int lb_set_group(struct livebox *handler, const char *cluster, const char *categ handler->cluster = pc; handler->category = ps; - return 0; + return LB_STATUS_SUCCESS; } void lb_set_size(struct livebox *handler, int w, int h) @@ -2329,7 +2330,7 @@ int lb_delete_all(void) lb_unref(handler); } - return 0; + return LB_STATUS_SUCCESS; } int lb_set_content(struct livebox *handler, const char *content) @@ -2343,11 +2344,11 @@ int lb_set_content(struct livebox *handler, const char *content) handler->content = strdup(content); if (!handler->content) { CRITICAL_LOG("Heap: %s (content: %s)\n", strerror(errno), content); - return -ENOMEM; + return LB_STATUS_ERROR_MEMORY; } } - return 0; + return LB_STATUS_SUCCESS; } int lb_set_title(struct livebox *handler, const char *title) @@ -2361,11 +2362,11 @@ int lb_set_title(struct livebox *handler, const char *title) handler->title = strdup(title); if (!handler->title) { CRITICAL_LOG("Heap: %s (title: %s)\n", strerror(errno), title); - return -ENOMEM; + return LB_STATUS_ERROR_MEMORY; } } - return 0; + return LB_STATUS_SUCCESS; } void lb_set_size_list(struct livebox *handler, int size_list) @@ -2413,18 +2414,18 @@ int lb_set_lb_fb(struct livebox *handler, const char *filename) struct fb_info *fb; if (!handler) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; fb = handler->lb.data.fb; if (fb && !strcmp(fb_id(fb), filename)) /*!< BUFFER is not changed, */ - return 0; + return LB_STATUS_SUCCESS; handler->lb.data.fb = NULL; if (!filename || filename[0] == '\0') { if (fb) fb_destroy(fb); - return 0; + return LB_STATUS_SUCCESS; } handler->lb.data.fb = fb_create(filename, handler->lb.width, handler->lb.height); @@ -2432,13 +2433,13 @@ int lb_set_lb_fb(struct livebox *handler, const char *filename) ErrPrint("Faield to create a FB\n"); if (fb) fb_destroy(fb); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } if (fb) fb_destroy(fb); - return 0; + return LB_STATUS_SUCCESS; } int lb_set_pd_fb(struct livebox *handler, const char *filename) @@ -2446,19 +2447,19 @@ int lb_set_pd_fb(struct livebox *handler, const char *filename) struct fb_info *fb; if (!handler) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; fb = handler->pd.data.fb; if (fb && !strcmp(fb_id(fb), filename)) { /* BUFFER is not changed, just update the content */ - return -EEXIST; + return LB_STATUS_ERROR_EXIST; } handler->pd.data.fb = NULL; if (!filename || filename[0] == '\0') { if (fb) fb_destroy(fb); - return 0; + return LB_STATUS_SUCCESS; } handler->pd.data.fb = fb_create(filename, handler->pd.width, handler->pd.height); @@ -2466,12 +2467,12 @@ int lb_set_pd_fb(struct livebox *handler, const char *filename) ErrPrint("Failed to create a FB\n"); if (fb) fb_destroy(fb); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } if (fb) fb_destroy(fb); - return 0; + return LB_STATUS_SUCCESS; } struct fb_info *lb_get_lb_fb(struct livebox *handler) @@ -2537,6 +2538,9 @@ struct livebox *lb_unref(struct livebox *handler) if (handler->refcnt > 0) return handler; + if (handler->filename) + util_unlink(handler->filename); + dlist_remove_data(s_info.livebox_list, handler); handler->state = DESTROYED; @@ -2567,21 +2571,21 @@ int lb_send_delete(struct livebox *handler, ret_cb_t cb, void *data) if (!cb && !!data) { ErrPrint("Invalid argument\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (handler->deleted_cb) { ErrPrint("Already in-progress\n"); - return -EINPROGRESS; + return LB_STATUS_ERROR_BUSY; } packet = packet_create("delete", "ss", handler->pkgname, handler->id); if (!packet) { ErrPrint("Failed to build a param\n"); if (cb) - cb(handler, -EFAULT, data); + cb(handler, LB_STATUS_ERROR_FAULT, data); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } if (!cb) @@ -2597,7 +2601,7 @@ EAPI int livebox_client_paused(void) packet = packet_create_noack("client_paused", "d", util_timestamp()); if (!packet) { ErrPrint("Failed to create a pause packet\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } return master_rpc_request_only(NULL, packet); @@ -2610,7 +2614,7 @@ EAPI int livebox_client_resumed(void) packet = packet_create_noack("client_resumed", "d", util_timestamp()); if (!packet) { ErrPrint("Failed to create a resume packet\n"); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } return master_rpc_request_only(NULL, packet); diff --git a/src/master_rpc.c b/src/master_rpc.c index d3b68e1..6e80932 100644 --- a/src/master_rpc.c +++ b/src/master_rpc.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ #include #include +#include #include "debug.h" #include "dlist.h" @@ -169,7 +170,7 @@ static int done_cb(pid_t pid, int handle, const struct packet *packet, void *dat if (packet_get(packet, "i", &ret) != 1) { ErrPrint("Invalid result packet\n"); - ret = -EINVAL; + ret = LB_STATUS_ERROR_INVALID; } DbgPrint("[%s] Returns: %d\n", packet_command(packet), ret); @@ -203,7 +204,7 @@ int master_rpc_async_request(struct livebox *handler, struct packet *packet, int ret_cb(handler, NULL, data); packet_unref(packet); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } command->ret_cb = ret_cb; @@ -217,7 +218,7 @@ int master_rpc_async_request(struct livebox *handler, struct packet *packet, int push_command(command); packet_unref(packet); - return 0; + return LB_STATUS_SUCCESS; } int master_rpc_request_only(struct livebox *handler, struct packet *packet) @@ -228,7 +229,7 @@ int master_rpc_request_only(struct livebox *handler, struct packet *packet) if (!command) { ErrPrint("Failed to create a command\n"); packet_unref(packet); - return -EFAULT; + return LB_STATUS_ERROR_FAULT; } command->ret_cb = NULL; @@ -238,7 +239,7 @@ int master_rpc_request_only(struct livebox *handler, struct packet *packet) push_command(command); packet_unref(packet); - return 0; + return LB_STATUS_SUCCESS; } int master_rpc_clear_fault_package(const char *pkgname) @@ -248,7 +249,7 @@ int master_rpc_clear_fault_package(const char *pkgname) struct command *command; if (!pkgname) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; DbgPrint("Clear requests of the fault package(%s)\n", pkgname); @@ -297,13 +298,13 @@ int master_rpc_sync_request(struct packet *packet) if (result) { if (packet_get(result, "i", &ret) != 1) { ErrPrint("Invalid result packet\n"); - ret = -EINVAL; + ret = LB_STATUS_ERROR_INVALID; } packet_unref(result); } else { ErrPrint("Failed to send a sync request\n"); - ret = -EFAULT; + ret = LB_STATUS_ERROR_FAULT; } packet_unref(packet); diff --git a/src/util.c b/src/util.c index a62a7d0..b0e7181 100644 --- a/src/util.c +++ b/src/util.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright 2013 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ #include #include +#include /* For error code */ #include "debug.h" #include "util.h" @@ -35,7 +36,7 @@ int util_check_extension(const char *filename, const char *check_ptr) name_len = strlen(filename); while (--name_len >= 0 && *check_ptr) { if (filename[name_len] != *check_ptr) - return -EINVAL; + return LB_STATUS_ERROR_INVALID; check_ptr ++; } @@ -75,14 +76,14 @@ static inline int check_native_livebox(const char *pkgname) path = malloc(len + 1); if (!path) { ErrPrint("Heap: %s\n", strerror(errno)); - return -ENOMEM; + return LB_STATUS_ERROR_MEMORY; } snprintf(path, len, "/opt/usr/live/%s/libexec/liblive-%s.so", pkgname, pkgname); if (access(path, F_OK | R_OK) != 0) { ErrPrint("%s is not a valid package\n", pkgname); free(path); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } free(path); @@ -100,14 +101,14 @@ static inline int check_web_livebox(const char *pkgname) path = malloc(len + 1); if (!path) { ErrPrint("Heap: %s\n", strerror(errno)); - return -ENOMEM; + return LB_STATUS_ERROR_MEMORY; } snprintf(path, len, "/opt/usr/apps/%s/res/wgt/livebox/index.html", pkgname); if (access(path, F_OK | R_OK) != 0) { ErrPrint("%s is not a valid package\n", pkgname); free(path); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } free(path); @@ -118,13 +119,13 @@ int util_validate_livebox_package(const char *pkgname) { if (!pkgname) { ErrPrint("Invalid argument\n"); - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } if (!check_native_livebox(pkgname) || !check_web_livebox(pkgname)) return 0; - return -EINVAL; + return LB_STATUS_ERROR_INVALID; } const char *util_uri_to_path(const char *uri) @@ -138,4 +139,31 @@ const char *util_uri_to_path(const char *uri) return uri + len; } +int util_unlink(const char *filename) +{ + char *descfile; + int desclen; + int ret; + + desclen = strlen(filename) + 6; /* .desc */ + descfile = malloc(desclen); + if (!descfile) { + ErrPrint("Heap: %s\n", strerror(errno)); + return LB_STATUS_ERROR_MEMORY; + } + + ret = snprintf(descfile, desclen, "%s.desc", filename); + if (ret < 0) { + ErrPrint("Error: %s\n", strerror(errno)); + free(descfile); + return LB_STATUS_ERROR_FAULT; + } + + (void)unlink(descfile); + free(descfile); + (void)unlink(filename); + + return LB_STATUS_SUCCESS; +} + /* End of a file */ -- 2.7.4