From aaede55f33454393011ec1e0979ec0f8849f7e13 Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Sun, 5 Jan 2014 18:16:44 +0900 Subject: [PATCH] Sync with the latest one Change-Id: I240b852f1abab4bdab2f58895fd543723ebeb438 --- CMakeLists.txt | 3 +- include/client.h | 2 +- include/conf.h | 2 +- include/critical_log.h | 23 -- include/fb.h | 1 + include/livebox.h | 743 +++++++++++++++++++++++++-------------- include/livebox_internal.h | 15 +- live.viewer/CMakeLists.txt | 2 +- packaging/liblivebox-viewer.spec | 8 +- src/client.c | 188 +++++++++- src/critical_log.c | 166 --------- src/desc_parser.c | 16 +- src/fb.c | 39 +- src/livebox.c | 595 +++++++++++++++++++++++++++---- src/master_rpc.c | 1 + 15 files changed, 1261 insertions(+), 543 deletions(-) delete mode 100644 include/critical_log.h delete mode 100644 src/critical_log.c diff --git a/CMakeLists.txt b/CMakeLists.txt index b72dbb6..cd29c15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ FOREACH(flag ${pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Winline -g") +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror -Winline -g") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") @@ -54,7 +54,6 @@ ADD_LIBRARY(${PROJECT_NAME} SHARED src/desc_parser.c src/master_rpc.c src/client.c - src/critical_log.c src/file_service.c src/conf.c ) diff --git a/include/client.h b/include/client.h index e0348d4..db8a931 100644 --- a/include/client.h +++ b/include/client.h @@ -14,7 +14,7 @@ * limitations under the License. */ -extern int client_init(void); +extern int client_init(int use_thread); extern int client_fd(void); extern const char *client_addr(void); extern int client_fini(void); diff --git a/include/conf.h b/include/conf.h index 7258093..f134310 100644 --- a/include/conf.h +++ b/include/conf.h @@ -20,7 +20,7 @@ */ #define MAX_LOG_FILE 3 #define MAX_LOG_LINE 1000 -#define SLAVE_LOG_PATH "/opt/usr/share/live_magazine/log" +#define SLAVE_LOG_PATH "/tmp/.dbox.service/log/" #if !defined(VCONFKEY_MASTER_STARTED) #define VCONFKEY_MASTER_STARTED "memory/data-provider-master/started" diff --git a/include/critical_log.h b/include/critical_log.h deleted file mode 100644 index 4c6c23c..0000000 --- a/include/critical_log.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -extern int critical_log(const char *func, int line, const char *fmt, ...); -extern int critical_log_init(const char *tag); -extern int critical_log_fini(void); - -#define CRITICAL_LOG(args...) critical_log(__func__, __LINE__, args) - -/* End of a file */ diff --git a/include/fb.h b/include/fb.h index 4434692..9e567dd 100644 --- a/include/fb.h +++ b/include/fb.h @@ -31,6 +31,7 @@ extern int fb_sync(struct fb_info *info); extern int fb_size(struct fb_info *info); extern int fb_refcnt(void *data); extern int fb_is_created(struct fb_info *info); +extern int fb_type(struct fb_info *info); extern struct fb_info *fb_create(const char *filename, int w, int h); extern int fb_destroy(struct fb_info *info); diff --git a/include/livebox.h b/include/livebox.h index 876d6e3..d97c217 100644 --- a/include/livebox.h +++ b/include/livebox.h @@ -34,7 +34,7 @@ struct livebox; /*! * \brief - * Use the default update period which is defined in the livebox package manifest. + * Use the default update period which is defined in the package manifest file of a livebox. */ #define DEFAULT_PERIOD -1.0f @@ -52,8 +52,12 @@ enum content_event_type { CONTENT_EVENT_MOUSE_SET = 0x00000020, /*!< LB mouse set auto event for livebox */ CONTENT_EVENT_MOUSE_UNSET = 0x00000040, /*!< LB mouse unset auto event for livebox */ - CONTENT_EVENT_KEY_DOWN = 0x00100000, /*!< LB key press */ - CONTENT_EVENT_KEY_UP = 0x00200000, /*!< LB key release */ + CONTENT_EVENT_KEY_DOWN = 0x00000001, /*!< LB key press */ + CONTENT_EVENT_KEY_UP = 0x00000002, /*!< LB key release */ + CONTENT_EVENT_KEY_FOCUS_IN = 0x00000008, /*!< LB key focused in */ + CONTENT_EVENT_KEY_FOCUS_OUT = 0x00000010, /*!< LB key focused out */ + CONTENT_EVENT_KEY_SET = 0x00000020, /*!< LB Key, start feeding event by master */ + CONTENT_EVENT_KEY_UNSET = 0x00000040, /*!< LB key, stop feeding event by master */ CONTENT_EVENT_KEY_MASK = 0x80000000, CONTENT_EVENT_MOUSE_MASK = 0x20000000, @@ -65,22 +69,30 @@ enum content_event_type { LB_MOUSE_MOVE = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_MOVE, /*!< Move move on the livebox */ LB_MOUSE_ENTER = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_ENTER, /*!< Mouse enter to the livebox */ LB_MOUSE_LEAVE = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_LEAVE, /*!< Mouse leave from the livebox */ - LB_MOUSE_SET = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_SET, - LB_MOUSE_UNSET = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_UNSET, + LB_MOUSE_SET = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_SET, /*!< Mouse event, start feeding event by master */ + LB_MOUSE_UNSET = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_UNSET, /*!< Mouse event, stop feeding event by master */ PD_MOUSE_DOWN = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_DOWN, /*!< Mouse down on the PD */ PD_MOUSE_UP = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_UP, /*!< Mouse up on the PD */ PD_MOUSE_MOVE = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_MOVE, /*!< Mouse move on the PD */ PD_MOUSE_ENTER = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_ENTER, /*!< Mouse enter to the PD */ PD_MOUSE_LEAVE = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_LEAVE, /*!< Mouse leave from the PD */ - PD_MOUSE_SET = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_SET, - PD_MOUSE_UNSET = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_UNSET, + PD_MOUSE_SET = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_SET, /*!< Mouse event, start feeding event by master */ + PD_MOUSE_UNSET = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_UNSET, /*!< Mouse event, stop feeding event by master */ LB_KEY_DOWN = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_DOWN, /*!< Key down on the livebox */ LB_KEY_UP = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_UP, /*!< Key up on the livebox */ + LB_KEY_SET = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_SET, /*!< Key event, start feeding event by master */ + LB_KEY_UNSET = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_UNSET, /*!< Key event, stop feeding event by master */ + LB_KEY_FOCUS_IN = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_FOCUS_IN, /*!< Key event, focus in */ + LB_KEY_FOCUS_OUT = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_FOCUS_OUT, /*!< Key event, foucs out */ PD_KEY_DOWN = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_DOWN, /*!< Key down on the livebox */ PD_KEY_UP = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_UP, /*!< Key up on the livebox */ + PD_KEY_SET = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_SET, /*!< Key event, start feeding event by master */ + PD_KEY_UNSET = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_UNSET, /*!< Key event, stop feeding event by master */ + PD_KEY_FOCUS_IN = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_FOCUS_IN, /*!< Key event, focus in */ + PD_KEY_FOCUS_OUT = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_FOCUS_OUT, /*!< Key event, focus out */ CONTENT_EVENT_MAX = 0xFFFFFFFF }; @@ -116,16 +128,16 @@ enum access_event_type { LB_ACCESS_SCROLL_MOVE = ACCESS_EVENT_LB_MASK | ACCESS_EVENT_SCROLL_MOVE, /*!< Access event - scroll move */ LB_ACCESS_SCROLL_UP = ACCESS_EVENT_LB_MASK | ACCESS_EVENT_SCROLL_UP, /*!< Access event - scroll up */ - PD_ACCESS_HIGHLIGHT = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_HIGHLIGHT, - PD_ACCESS_HIGHLIGHT_NEXT = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_HIGHLIGHT_NEXT, - PD_ACCESS_HIGHLIGHT_PREV = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_HIGHLIGHT_PREV, - PD_ACCESS_UNHIGHLIGHT = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_UNHIGHLIGHT, - PD_ACCESS_ACTIVATE = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_ACTIVATE, - PD_ACCESS_ACTION_DOWN = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_ACTION_DOWN, - PD_ACCESS_ACTION_UP = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_ACTION_UP, - PD_ACCESS_SCROLL_DOWN = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_SCROLL_DOWN, - PD_ACCESS_SCROLL_MOVE = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_SCROLL_MOVE, - PD_ACCESS_SCROLL_UP = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_SCROLL_UP + PD_ACCESS_HIGHLIGHT = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_HIGHLIGHT, /*!< Access event - Highlight an object in the PD */ + PD_ACCESS_HIGHLIGHT_NEXT = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_HIGHLIGHT_NEXT, /*!< Access event - Move highlight to the next object in a PD */ + PD_ACCESS_HIGHLIGHT_PREV = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_HIGHLIGHT_PREV, /*!< Access event - Move highlight to the prev object in a PD */ + PD_ACCESS_UNHIGHLIGHT = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_UNHIGHLIGHT, /*!< Access event - Delet highlight from the PD */ + PD_ACCESS_ACTIVATE = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_ACTIVATE, /*!< Access event - Launch or activate the highlighted object */ + PD_ACCESS_ACTION_DOWN = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_ACTION_DOWN, /*!< Access event - down */ + PD_ACCESS_ACTION_UP = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_ACTION_UP, /*!< Access event - up */ + PD_ACCESS_SCROLL_DOWN = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_SCROLL_DOWN, /*!< Access event - scroll down */ + PD_ACCESS_SCROLL_MOVE = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_SCROLL_MOVE, /*!< Access event - scroll move */ + PD_ACCESS_SCROLL_UP = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_SCROLL_UP /*!< Access event - scroll up */ }; /*! @@ -186,6 +198,8 @@ enum livebox_event_type { /*!< livebox_event_handler_set Event list */ LB_EVENT_UPDATE_MODE_CHANGED, /*!< Livebox Update mode is changed */ + LB_EVENT_REQUEST_CLOSE_PD, /*!< Livebox requests to close the PD */ + LB_EVENT_IGNORED /*!< Request is ignored */ }; @@ -262,14 +276,18 @@ typedef void (*ret_cb_t)(struct livebox *handle, int ret, void *data); /*! * \brief Initialize the livebox system * \details N/A - * \remarks N/A - * \param[in] disp If you have X Display connection object, you can re-use it. but you should care its life cycle. + * \remarks + * This API uses get/setenv APIs. + * Those APIs are not thread-safe. + * So you have to consider to use the livebox_init_with_options instead of this if you are developing multi-threaded viewer. + * \param[in] disp If you have X Display connection object already, you can re-use it. but you should care its life cycle. * It must be alive before call the livebox_fini * \return int * \retval LB_STATUS_SUCCESS if success * \pre N/A * \post N/A * \see livebox_fini + * \see livebox_init_with_options */ extern int livebox_init(void *disp); @@ -279,17 +297,18 @@ extern int livebox_init(void *disp); * But some application doesn't want to use the env value. * For them, this API will give a chance to set default options using given arguments * \remarks N/A - * \param[in] disp - * \param[in] prevent_overwrite - * \param[in] event_filter - * \return int + * \param[in] disp if this display is NULL, the library will try to acquire a new connection with X + * \param[in] prevent_overwrite If the content of image type livebox is updated, don't overwrite it(1) or overwrite old file(0) + * \param[in] event_filter If the next event comes in this period, ignore it. It is too fast to processing it in time. + * \param[in] use_thread Use the receive thread. + * \return int Integer, Livebox status code * \retval LB_STATUS_SUCCESS if success * \pre N/A * \post N/A * \see livebox_init * \see livebox_fini */ -extern int livebox_init_with_options(void *disp, int prevent_overwrite, double event_filter); +extern int livebox_init_with_options(void *disp, int prevent_overwrite, double event_filter, int use_thread); /*! * \brief Finalize the livebox system @@ -301,11 +320,12 @@ extern int livebox_init_with_options(void *disp, int prevent_overwrite, double e * \pre N/A * \post N/A * \see livebox_init + * \see livebox_init_with_options */ extern int livebox_fini(void); /*! - * \brief Client is paused. + * \brief Notify the status of client to the provider. "it is paused". * \details N/A * \remarks N/A * \return int @@ -318,7 +338,7 @@ extern int livebox_fini(void); extern int livebox_client_paused(void); /*! - * \brief Client is rfesumed. + * \brief Notify the status of client to the provider. "it is resumed". * \details N/A * \remarks N/A * \return int @@ -357,26 +377,32 @@ extern struct livebox *livebox_add(const char *pkgname, const char *content, con /*! * \brief Add a new livebox * \details + * If the screen size if "1280x720" + * Below size lists are used for default. + * Or you can find the default sizes in pixel from /usr/share/data-provider-master/resolution.ini + * Size types are defined from the liblivebox-service package. (livebox-service.h) + * * Normal mode livebox - * 1x1=175x175 - * 2x1=354x175 - * 2x2=354x354 - * 4x1=712x175 - * 4x2=712x354 - * 4x4=712x712 + * 1x1=175x175, LB_SIZE_TYPE_1x1 + * 2x1=354x175, LB_SIZE_TYPE_2x1 + * 2x2=354x354, LB_SIZE_TYPE_2x2 + * 4x1=712x175, LB_SIZE_TYPE_4x1 + * 4x2=712x354, LB_SIZE_TYPE_4x2 + * 4x4=712x712, LB_SIZE_TYPE_4x4 * * Extended sizes - * 4x3=712x533 - * 4x5=712x891 - * 4x6=712x1070 + * 4x3=712x533, LB_SIZE_TYPE_4x3 + * 4x5=712x891, LB_SIZE_TYPE_4x5 + * 4x6=712x1070, LB_SIZE_TYPE_4x6 * * Easy mode livebox - * 21x21=224x215 - * 23x21=680x215 - * 23x23=680x653 + * 21x21=224x215, LB_SIZE_TYPE_EASY_1x1 + * 23x21=680x215, LB_SIZE_TYPE_EASY_3x1 + * 23x23=680x653, LB_SIZE_TYPE_EASY_3x3 * * Special livebox - * 0x0=720x1280 + * 0x0=720x1280, LB_SIZE_TYPE_0x0 + * * \remarks * Even if you get the handle by return value of this function, it is not created instance. * So you have to deal it as not initialized handle. @@ -398,12 +424,12 @@ extern struct livebox *livebox_add(const char *pkgname, const char *content, con extern struct livebox *livebox_add_with_size(const char *pkgname, const char *content, const char *cluster, const char *category, double period, int type, ret_cb_t cb, void *data); /*! - * \brief Delete a livebox + * \brief Delete a livebox (deprecated) * \details N/A * \remarks * If you call this with uninitialized handle, the return callback will be called synchronously. * So before return from this function, the return callback will be called first. - * \param[in] handler Handle of a livebox instance + * \param[in] handler Handler of a livebox instance * \param[in] cb return callback * \param[in] data user data for return callback * \return int @@ -418,6 +444,27 @@ extern struct livebox *livebox_add_with_size(const char *pkgname, const char *co extern int livebox_del(struct livebox *handler, ret_cb_t cb, void *data); /*! + * \brief Delete a livebox (will be replaced with livebox_del) + * \details N/A + * \remarks + * If you call this with uninitialized handle, the return callback will be called synchronously. + * So before return from this function, the return callback will be called first. + * \param[in] handler Handler of a livebox instance + * \param[in] type Deletion type, LB_DELETE_PERMANENTLY or LB_DELETE_TEMPORARY + * \param[in] cb return callback + * \param[in] data user data for return callback + * \return int + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_ERROR_BUSY already in process + * \retval LB_STATUS_ERROR_FAULT failed to create a request packet + * \retval LB_STATUS_SUCCESS successfully sent, return callack will be called + * \pre N/A + * \post N/A + * \see ret_cb_t + */ +extern int livebox_del_NEW(struct livebox *handler, int type, ret_cb_t cb, void *data); + +/*! * \brief Set a livebox events callback * \details * To get the events push from the provider, register the event callback using this function @@ -439,8 +486,8 @@ extern int livebox_set_event_handler(int (*cb)(struct livebox *handler, enum liv * \brief Unset the livebox event handler * \details N/A * \remarks N/A - * \param[in] cb - * \return void * + * \param[in] cb Event handler + * \return void * Event handler data * \retval pointer of 'data' which is used with the livebox_set_event_handler * \pre N/A * \post N/A @@ -454,8 +501,8 @@ extern void *livebox_unset_event_handler(int (*cb)(struct livebox *handler, enum * event, pkgname, filename, funcname * \details N/A * \remarks N/A - * \param[in] cb - * \param[in] data + * \param[in] cb Event handler + * \param[in] data Event handler data * \return int * \retval LB_STATUS_SUCCESS if succeed to set fault event handler * \retval LB_STATUS_ERROR_INVALID Invalid argument @@ -470,8 +517,8 @@ extern int livebox_set_fault_handler(int (*cb)(enum livebox_fault_type, const ch * \brief Unset the live box fault event handler * \details N/A * \remarks N/A - * \param[in] cb - * \return void * + * \param[in] cb Event handler + * \return void * Callback data which is set via livebox_set_fault_handler * \retval pointer of 'data' which is used with the livebox_set_fault_handler * \pre N/A * \post N/A @@ -486,9 +533,9 @@ extern void *livebox_unset_fault_handler(int (*cb)(enum livebox_fault_type, cons * \remarks * Even though this function returns SUCCESS, it means just successfully sent a request to provider. * So you have to check the return callback. and its "ret" argument. - * \param[in] pkgname - * \param[in] cb - * \param[in] data + * \param[in] pkgname Package name which should be activated + * \param[in] cb Result callback + * \param[in] data Callback data * \return int * \retval LB_STATUS_SUCCESS Successfully sent a request * \retval LB_STATUS_ERROR_INVALID Invalid argument @@ -503,28 +550,28 @@ extern int livebox_activate(const char *pkgname, ret_cb_t cb, void *data); * \brief Resize the livebox * \details * Normal mode livebox size - * 1x1=175x175 - * 2x1=354x175 - * 2x2=354x354 - * 4x1=712x175 - * 4x2=712x354 - * 4x4=712x712 + * 1x1=175x175, LB_SIZE_TYPE_1x1 + * 2x1=354x175, LB_SIZE_TYPE_2x1 + * 2x2=354x354, LB_SIZE_TYPE_2x2 + * 4x1=712x175, LB_SIZE_TYPE_4x1 + * 4x2=712x354, LB_SIZE_TYPE_4x2 + * 4x4=712x712, LB_SIZE_TYPE_4x4 * * Extended livebox size - * 4x3=712x533 - * 4x5=712x891 - * 4x6=712x1070 + * 4x3=712x533, LB_SIZE_TYPE_4x3 + * 4x5=712x891, LB_SIZE_TYPE_4x5 + * 4x6=712x1070, LB_SIZE_TYPE_4x6 * * Easy mode livebox size - * 21x21=224x215 - * 23x21=680x215 - * 23x23=680x653 + * 21x21=224x215, LB_SIZE_TYPE_EASY_1x1 + * 23x21=680x215, LB_SIZE_TYPE_EASY_3x1 + * 23x23=680x653, LB_SIZE_TYPE_EASY_3x3 * * Special mode livebox size - * 0x0=720x1280 + * 0x0=720x1280, LB_SIZE_TYPE_0x0 * \remarks * You have to check the return callback. - * \param[in] handler Handler of a livebox + * \param[in] handler Handler of a livebox instance * \param[in] type Type of a livebox size, LB_SIZE_TYPE_1x1, ... * \param[in] cb Result callback of the resize operation. * \param[in] data User data for return callback @@ -544,13 +591,13 @@ extern int livebox_resize(struct livebox *handler, int type, ret_cb_t cb, void * * \brief Send the click event for a livebox. * \details N/A * \remarks N/A - * \param[in] handler Handler of a livebox + * \param[in] handler Handler of a livebox instance * \param[in] x Rational X of the content width. * \param[in] y Rational Y of the content height. * \return int - * \retval LB_STATUS_ERROR_INVALID - * \retval LB_STATUS_ERROR_FAULT - * \retval LB_STATUS_SUCCESS + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred + * \retval LB_STATUS_SUCCESS Successfully done * \pre N/A * \post N/A * \see N/A @@ -561,7 +608,7 @@ extern int livebox_click(struct livebox *handler, double x, double y); * \brief Change the cluster/sub-cluster name of given livebox handler * \details N/A * \remarks N/A - * \param[in] handler Handler of a livebox + * \param[in] handler Handler of a livebox instance * \param[in] cluster New cluster of a livebox * \param[in] category New category of a livebox * \param[in] cb Result callback for changing the cluster/category of a livebox @@ -584,17 +631,17 @@ extern int livebox_set_group(struct livebox *handler, const char *cluster, const * \remarks * You have to do not release the cluster & category. * It is allocated inside of given livebox instance, so you can only read it. - * \param[in] handler Handler of a livebox + * \param[in] handler Handler of a livebox instance * \param[out] cluster Storage(memory) for containing the cluster name * \param[out] category Storage(memory) for containing the category name * \return int - * \retval LB_STATUS_ERROR_INVALID - * \retval LB_STATUS_SUCCESS + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_SUCCESS Successfully done * \pre N/A * \post N/A * \see N/A */ -extern int livebox_get_group(struct livebox *handler, char ** const cluster, char ** const category); +extern int livebox_get_group(struct livebox *handler, const char **cluster, const char **category); /*! * \brief Get the period of this livebox handler @@ -603,7 +650,7 @@ extern int livebox_get_group(struct livebox *handler, char ** const cluster, cha * if this function returns 0.0f, it means the livebox has no update period. * or the handle is not valid. * This function only can be works after the return callback of livebox_create fucntion is called. - * \param[in] handler Handler of a livebox + * \param[in] handler Handler of a livebox instance * \return double * \retval Current update period of a livebox * \retval 0.0f it means the box has no update period, or it can returns 0.0 if the handles is not valid. @@ -617,16 +664,16 @@ extern double livebox_period(struct livebox *handler); * \brief Change the update period * \details N/A * \remarks N/A - * \param[in] handler Handler of a livebox + * \param[in] handler Handler of a livebox instance * \param[in] period New update period of a livebox * \param[in] cb Result callback of changing the update period of this livebox * \param[in] data User data for the result callback * \return int - * \retval LB_STATUS_SUCCESS - * \retval LB_STATUS_ERROR_INVALID + * \retval LB_STATUS_SUCCESS Successfully done + * \retval LB_STATUS_ERROR_INVALID Invalid argument * \retval LB_STATUS_ERROR_BUSY * \retval LB_STATUS_ERROR_ALREADY - * \retval LB_STATUS_ERROR_FAULT + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred * \pre N/A * \post N/A * \see ret_cb_t @@ -637,7 +684,7 @@ extern int livebox_set_period(struct livebox *handler, double period, ret_cb_t c * \brief Is this an text type livebox? * \details N/A * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \return livebox_lb_type * \retval LB_TYPE_IMAGE Contents of a livebox is based on the image file * \retval LB_TYPE_BUFFER Contents of a livebox is based on canvas buffer(shared) @@ -655,7 +702,7 @@ extern enum livebox_lb_type livebox_lb_type(struct livebox *handler); * \details * If the livebox instance is created by system this will returns 0. * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \return int * \retval LB_STATUS_ERROR_INVALID Invalid argument * \retval 0 automatically created livebox by the provider @@ -672,8 +719,8 @@ extern int livebox_is_user(struct livebox *handler); * \brief Get the content information string of given livebox * \details N/A * \remarks N/A - * \param[in] handler - * \return char * + * \param[in] handler Handler of a livebox instance + * \return const char * * \retval content_info Livebox content info that can be used again via content_info argument of livebox_add or livebox_add_with_size. * \pre N/A * \post N/A @@ -684,9 +731,15 @@ extern const char *livebox_content(struct livebox *handler); /*! * \brief Get the sub cluster title string of given livebox - * \details N/A - * \remarks N/A - * \param[in] handler + * \details + * This API is now used for accessibility. + * Each box should set their content as a string to read by TTS. + * So if the box has focus on the homescreen, the homescreen will read a text using this API. + * \remarks + * The title which is returned by this, the TTS should read it. + * But it is just recomended to a homescreen. + * So read it or not is depends on implementation of the homescreen. + * \param[in] handler Handler of a livebox instance * \return const char * * \retval sub cluster name * \retval NULL @@ -698,9 +751,11 @@ extern const char *livebox_category_title(struct livebox *handler); /*! * \brief Get the filename of given livebox, if it is an IMAGE type livebox - * \details N/A + * \details + * If the box is developed as image format to represent its contents, + * The homescreen should know its image file name. * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \return const char * * \retval filename if the livebox type is image this function will give you a abspath of an image file (content is rendered) * \retval NULL if this has no image file or type is not image file. @@ -714,7 +769,7 @@ extern const char *livebox_filename(struct livebox *handler); * \brief Get the package name of given livebox handler * \details N/A * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \return const char * * \retval pkgname package name * \retval NULL if the handler is not valid @@ -728,7 +783,7 @@ extern const char *livebox_pkgname(struct livebox *handler); * \brief Get the priority of a current content. * \details N/A * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \return double * \retval 0.0f handler is NULL * \retval -1.0f Handler is not valid (not yet initialized) @@ -743,7 +798,7 @@ extern double livebox_priority(struct livebox *handler); * \brief Acquire the buffer of given livebox (Only for the buffer type) * \details N/A * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \return void * * \retval address of a FB * \retval NULL if it fails to get fb address @@ -759,8 +814,8 @@ extern void *livebox_acquire_fb(struct livebox *handler); * \remarks N/A * \param[in] buffer * \return int - * \retval LB_STATUS_ERROR_INVALID - * \retval LB_STATUS_SUCCESS + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_SUCCESS Successfully done * \pre N/A * \post N/A * \see livebox_acquire_fb @@ -773,8 +828,8 @@ extern int livebox_release_fb(void *buffer); * \remarks N/A * \param[in] buffer * \return int - * \retval LB_STATUS_ERROR_INVALID - * \retval LB_STATUS_ERROR_FAULT + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred * \retval refcnt positive integer including ZERO * \pre N/A * \post N/A @@ -786,7 +841,7 @@ extern int livebox_fb_refcnt(void *buffer); * \brief Acquire the buffer of a PD frame (Only for the buffer type) * \details N/A * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \return int * \retval NULL * \retval adress of buffer of PD @@ -802,8 +857,8 @@ extern void *livebox_acquire_pdfb(struct livebox *handler); * \remarks N/A * \param[in] buffer * \return int - * \retval LB_STATUS_ERROR_INVALID - * \retval LB_STATUS_SUCCESS + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_SUCCESS Successfully done * \pre N/A * \post N/A * \see livebox_acquire_pdfb @@ -816,8 +871,8 @@ extern int livebox_release_pdfb(void *buffer); * \remarks N/A * \param[in] buffer * \return int - * \retval LB_STATUS_ERROR_INVALID - * \retval LB_STATUS_ERROR_FAULT + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred * \retval reference count * \pre N/A * \post N/A @@ -829,7 +884,7 @@ extern int livebox_pdfb_refcnt(void *buffer); * \brief Get the size of the Livebox * \details N/A * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \return int * \retval LB_SIZE_TYPE_NxM * \retval LB_SIZE_TYPE_INVALID @@ -843,12 +898,12 @@ extern int livebox_size(struct livebox *handler); * \brief Get the size of the Progressive Disclosure * \details N/A * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \param[out] w * \param[out] h * \return int - * \retval LB_STATUS_ERROR_INVALID - * \retval LB_STATUS_SUCCESS + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_SUCCESS Successfully done * \pre N/A * \post N/A * \see N/A @@ -859,12 +914,12 @@ extern int livebox_get_pdsize(struct livebox *handler, int *w, int *h); * \brief List of supported sizes of given handler * \details N/A * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \param[out] cnt * \param[out] size_list * \return int - * \retval LB_STATUS_ERROR_INVALID - * \retval LB_STATUS_SUCCESS + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_SUCCESS Successfully done * \pre N/A * \post N/A * \see N/A @@ -875,9 +930,9 @@ extern int livebox_get_supported_sizes(struct livebox *handler, int *cnt, int *s * \brief BUFFER SIZE of the livebox if it is a buffer type * \details N/A * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \return int - * \retval LB_STATUS_ERROR_INVALID + * \retval LB_STATUS_ERROR_INVALID Invalid argument * \retval size of livebox buffer * \pre N/A * \post N/A @@ -889,9 +944,9 @@ extern int livebox_lbfb_bufsz(struct livebox *handler); * \brief BUFFER SIZE of the progiressive disclosure if it is a buffer type * \details N/A * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \return int - * \retval LB_STATUS_ERROR_INVALID + * \retval LB_STATUS_ERROR_INVALID Invalid argument * \retval size of PD buffer * \pre N/A * \post N/A @@ -902,56 +957,106 @@ extern int livebox_pdfb_bufsz(struct livebox *handler); /*! * \brief Send the content event (for buffer type) to provider(livebox) * \details N/A - * \remarks N/A - * \param[in] handler - * \param[in] type - * \param[in] x - * \param[in] y + * \remarks DEPRECATED + * Use the livebox_mouse_event function instead of this. + * \param[in] handler Handler of a livebox instance + * \param[in] type Event type + * \param[in] x coordinates of X axis + * \param[in] y coordinates of Y axis * \return int - * \retval LB_STATUS_ERROR_INVALID - * \retval LB_STATUS_ERROR_BUSY - * \retval LB_STATUS_ERROR_FAULT - * \retval LB_STATUS_SUCCESS + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_ERROR_BUSY Previous operaion is not finished yet + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred + * \retval LB_STATUS_SUCCESS Successfully sent * \pre N/A * \post N/A + * \see livebox_mouse_event * \see livebox_access_event + * \see livebox_key_event */ extern int livebox_content_event(struct livebox *handler, enum content_event_type type, double x, double y); /*! - * \brief Send the access event(for buffer type) to provider(livebox). + * \brief Send the content event (for buffer type) to provider(livebox) * \details N/A * \remarks N/A - * \param[in] handler - * \param[in] type - * \param[in] x - * \param[in] y - * \param[in] cb - * \param[in] data + * \param[in] handler Handler of a livebox instance + * \param[in] type Event type + * \param[in] x coordinates of X axis + * \param[in] y coordinates of Y axis * \return int - * \retval LB_STATUS_ERROR_INVALID - * \retval LB_STATUS_ERROR_BUSY - * \retval LB_STATUS_ERROR_FAULT - * \retval LB_STATUS_SUCCESS + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_ERROR_BUSY Previous operation is not finished yet + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred + * \retval LB_STATUS_SUCCESS Successfully sent * \pre N/A * \post N/A * \see livebox_content_event + * \see livebox_access_event + * \see livebox_key_event + */ +extern int livebox_mouse_event(struct livebox *handler, enum content_event_type type, double x, double y); + +/*! + * \brief Send the access event(for buffer type) to provider(livebox). + * \details N/A + * \remarks N/A + * \param[in] handler Handler of a livebox instance + * \param[in] type Event type + * \param[in] x coordinates of X axsis + * \param[in] y coordinates of Y axsis + * \param[in] cb Result callback function + * \param[in] data Callback data + * \return int + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_ERROR_BUSY Previous operation is not finished yet + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred + * \retval LB_STATUS_SUCCESS Successfully sent + * \pre N/A + * \post N/A + * \see livebox_mouse_event + * \see livebox_key_event */ extern int livebox_access_event(struct livebox *handler, enum access_event_type type, double x, double y, ret_cb_t cb, void *data); /*! - * \brief Do pin up or not. + * \brief Send the key event(for buffer type) to provider(livebox). * \details N/A * \remarks N/A - * \param[in] handler - * \param[in] flag - * \param[in] cb - * \param[in] data + * \param[in] handler Handler of a livebox instance + * \param[in] type Key event type + * \param[in] keycode Code of key + * \param[in] cb Result callback + * \param[in] data Callback data * \return int - * \retval LB_STATUS_ERROR_INVALID - * \retval 1 box is pinned up - * \retval 0 box is not pinned up + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_ERROR_BUSY Previous operation is not finished yet + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred + * \retval LB_STATUS_SUCCESS Successfully sent + * \pre N/A + * \post N/A + * \see livebox_mouse_event + * \see livebox_access_event + */ +extern int livebox_key_event(struct livebox *handler, enum content_event_type type, unsigned int keycode, ret_cb_t cb, void *data); + +/*! + * \brief Do pin up or not. + * \details + * If the livebox supports the pinup feature, + * you can freeze the update of given livebox. + * But it is different with pause. + * The box will be updated and it will decide wheter update its content or not when the pinup is on. + * \remarks N/A + * \param[in] handler Handler of a livebox instance + * \param[in] flag Pinup value + * \param[in] cb Result callback + * \param[in] data Callback data + * \return int + * \retval LB_STATUS_ERROR_INVALID Invalid parameters * \see ret_cb_t + * \see livebox_set_visibility + * \see livebox_is_pinned_up */ extern int livebox_set_pinup(struct livebox *handler, int flag, ret_cb_t cb, void *data); @@ -959,8 +1064,12 @@ extern int livebox_set_pinup(struct livebox *handler, int flag, ret_cb_t cb, voi * \brief Check the PIN-UP status of given handler * \details N/A * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \return int + * \retval LB_STATUS_ERROR_INVALID Invalid parameters + * \retval 1 box is pinned up + * \retval 0 box is not pinned up + * \see livebox_set_pinup */ extern int livebox_is_pinned_up(struct livebox *handler); @@ -968,14 +1077,15 @@ extern int livebox_is_pinned_up(struct livebox *handler); * \brief Check the PINUP feature availability of the given handler * \details N/A * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \return int - * \retval LB_STATUS_ERROR_INVALID + * \retval LB_STATUS_ERROR_INVALID Invalid argument * \retval 1 if the box support Pinup feature * \retval 0 if the box does not support the Pinup feature * \pre N/A * \post N/A - * \see N/A + * \see livebox_is_pinned_up + * \see livebox_set_pinup */ extern int livebox_has_pinup(struct livebox *handler); @@ -983,9 +1093,9 @@ extern int livebox_has_pinup(struct livebox *handler); * \brief Check the PD existence of given handler * \details N/A * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \return int - * \retval LB_STATUS_ERROR_INVALID + * \retval LB_STATUS_ERROR_INVALID Invalid argument * \retval 1 if the box support the PD * \retval 0 if the box has no PD * \pre N/A @@ -998,17 +1108,20 @@ extern int livebox_has_pd(struct livebox *handler); * \brief Create the PD of given handler * \details N/A * \remarks N/A - * \param[in] handler - * \param[in] cb - * \param[in] data + * \param[in] handler Handler of a livebox instance + * \param[in] cb Result callback + * \param[in] data Callback data * \return int - * \retval LB_STATUS_SUCCESS - * \retval LB_STATUS_ERROR_INVALID - * \retval LB_STATUS_ERROR_BUSY - * \retval LB_STATUS_ERROR_FAULT + * \retval LB_STATUS_SUCCESS Successfully done + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_ERROR_BUSY Previous operation is not finished yet + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred * \pre N/A * \post N/A * \see ret_cb_t + * \see livebox_create_pd_with_position + * \see livebox_move_pd + * \see livebox_destroy_pd */ extern int livebox_create_pd(struct livebox *handler, ret_cb_t cb, void *data); @@ -1016,19 +1129,21 @@ extern int livebox_create_pd(struct livebox *handler, ret_cb_t cb, void *data); * \brief Create the PD of given handler with the relative position from livebox * \details N/A * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \param[in] x 0.0 ~ 1.0 * \param[in] y 0.0 ~ 1.0 - * \param[in] cb - * \param[in] data + * \param[in] cb Result callback + * \param[in] data Callback data * \return int - * \retval LB_STATUS_SUCCESS - * \retval LB_STATUS_ERROR_INVALID - * \retval LB_STATUS_ERROR_BUSY - * \retval LB_STATUS_ERROR_FAULT + * \retval LB_STATUS_SUCCESS Successfully done + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_ERROR_BUSY Previous operation is not finished yet + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred * \pre N/A * \post N/A - * \see N/A + * \see livebox_create_pd + * \see livebox_destroy_pd + * \see livebox_move_pd */ extern int livebox_create_pd_with_position(struct livebox *handler, double x, double y, ret_cb_t cb, void *data); @@ -1036,13 +1151,13 @@ extern int livebox_create_pd_with_position(struct livebox *handler, double x, do * \brief PD position is updated. * \details N/A * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \param[in] x 0.0 ~ 1.0 * \param[in] y 0.0 ~ 1.0 * \return int * \retval LB_STATUS_SUCCESS if succeed to send request for updating position of the PD. - * \retval LB_STATUS_ERROR_FAULT - * \retval LB_STATUS_ERROR_INVALID + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred + * \retval LB_STATUS_ERROR_INVALID Invalid argument * \pre N/A * \post N/A * \see N/A @@ -1053,13 +1168,13 @@ extern int livebox_move_pd(struct livebox *handler, double x, double y); * \brief Destroy the PD of given handler if it is created. * \details N/A * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \param[in] cb * \param[in] data * \return int - * \retval LB_STATUS_ERROR_INVALID - * \retval LB_STATUS_ERROR_FAULT - * \retval LB_STATUS_SUCCESS + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred + * \retval LB_STATUS_SUCCESS Successfully done * \pre N/A * \post N/A * \see ret_cb_t @@ -1070,9 +1185,9 @@ extern int livebox_destroy_pd(struct livebox *handler, ret_cb_t cb, void *data); * \brief Check the create status of given livebox handler * \details N/A * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \return int - * \retval LB_STATUS_ERROR_INVALID + * \retval LB_STATUS_ERROR_INVALID Invalid argument * \retval 0 PD is not created * \retval 1 PD is created */ @@ -1082,7 +1197,7 @@ extern int livebox_pd_is_created(struct livebox *handler); * \brief Check the content type of the progressive disclosure of given handler * \details N/A * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \return int * \retval PD_TYPE_BUFFER Contents of a PD is based on canvas buffer(shared) * \retval PD_TYPE_TEXT Contents of a PD is based on formatted text file @@ -1112,11 +1227,11 @@ extern int livebox_is_exists(const char *pkgname); * \brief Set function table for parsing the text content of a livebox * \details N/A * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \param[in] ops * \return int - * \retval LB_STATUS_SUCCESS - * \retval LB_STATUS_ERROR_INVALID + * \retval LB_STATUS_SUCCESS Successfully done + * \retval LB_STATUS_ERROR_INVALID Invalid argument * \see livebox_set_pd_text_handler */ extern int livebox_set_text_handler(struct livebox *handler, struct livebox_script_operators *ops); @@ -1125,11 +1240,11 @@ extern int livebox_set_text_handler(struct livebox *handler, struct livebox_scri * \brief Set function table for parsing the text content of a Progressive Disclosure * \details N/A * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \param[in] ops * \return int - * \retval LB_STATUS_SUCCESS - * \retval LB_STATUS_ERROR_INVALID + * \retval LB_STATUS_SUCCESS Successfully done + * \retval LB_STATUS_ERROR_INVALID Invalid argument * \see livebox_set_text_handler */ extern int livebox_set_pd_text_handler(struct livebox *handler, struct livebox_script_operators *ops); @@ -1138,19 +1253,19 @@ extern int livebox_set_pd_text_handler(struct livebox *handler, struct livebox_s * \brief Emit a text signal to given livebox only if it is a text type. * \details N/A * \remarks N/A - * \param[in] handler - * \param[in] emission - * \param[in] source - * \param[in] sx - * \param[in] sy - * \param[in] ex - * \param[in] ey - * \param[in] cb - * \param[in] data + * \param[in] handler Handler of a livebox instance + * \param[in] emission Emission string + * \param[in] source Source string + * \param[in] sx start X + * \param[in] sy start Y + * \param[in] ex end X + * \param[in] ey end Y + * \param[in] cb Result callback + * \param[in] data Callback data * \return int - * \retval LB_STATUS_ERROR_INVALID - * \retval LB_STATUS_ERROR_FAULT - * \retval LB_STATUS_SUCCESS + * \retval LB_STATUS_ERROR_INVALID Invalid parameters + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred + * \retval LB_STATUS_SUCCESS Successfully emitted * \see ret_cb_t */ extern int livebox_emit_text_signal(struct livebox *handler, const char *emission, const char *source, double sx, double sy, double ex, double ey, ret_cb_t cb, void *data); @@ -1159,11 +1274,11 @@ extern int livebox_emit_text_signal(struct livebox *handler, const char *emissio * \brief Set a private data pointer to carry it using given handler * \details N/A * \remarks N/A - * \param[in] handler - * \param[in] data + * \param[in] handler Handler of a livebox instance + * \param[in] data data pointer * \return int - * \retval LB_STATUS_SUCCESS - * \retval LB_STATUS_ERROR_INVALID + * \retval LB_STATUS_SUCCESS Successfully registered + * \retval LB_STATUS_ERROR_INVALID Invalid argument * \pre N/A * \post N/A * \see livebox_get_data @@ -1174,9 +1289,10 @@ extern int livebox_set_data(struct livebox *handler, void *data); * \brief Get private data pointer which is carried by given handler * \details N/A * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \return void * * \retval data pointer + * \retval NULL if there is not data * \pre N/A * \post N/A * \see livebox_set_data @@ -1185,14 +1301,17 @@ extern void *livebox_get_data(struct livebox *handler); /*! * \brief Subscribe the event for liveboxes only in given cluster and sub-cluster - * \details N/A + * \details + * If you wrote a view-only client. + * you can receive the event of specific liveboxes which are grouped in given cluster/category + * But you cannot modify their attributes (such as size, ...). * \remarks N/A * \param[in] cluster "*" can be used for subscribe all cluster's liveboxes event. * If you use the "*", value in the category will be ignored. * \param[in] category "*" can be used for subscribe liveboxes events of all category(sub-cluster) in given "cluster" * \return int - * \retval LB_STATUS_ERROR_FAULT - * \retval LB_STATUS_SUCCESS + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred + * \retval LB_STATUS_SUCCESS Successfully requested * \pre N/A * \post N/A * \see livebox_unsubscribe_group @@ -1207,8 +1326,8 @@ extern int livebox_subscribe_group(const char *cluster, const char *category); * If you use the "*", value in the category will be ignored. * \param[in] category "*" can be used for subscribe all sub-cluster's liveboxes event in given "cluster" * \return int - * \retval LB_STATUS_ERROR_FAULT - * \retval LB_STATUS_SUCCESS + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred + * \retval LB_STATUS_SUCCESS Successfully requested * \pre N/A * \post N/A * \see livebox_subscribe_group @@ -1217,18 +1336,21 @@ extern int livebox_unsubscribe_group(const char *cluster, const char *category); /*! * \brief Refresh the group(cluster/sub-cluser(aka. category)) - * \details N/A - * \remarks N/A + * \details + * This function will trigger the update of all liveboxes in given cluster/category group + * \remarks + * Basically default livebox system doesn't use the cluster/category concept. + * But you can use it. so if you decide to use it then you can trigger the update of all liveboxes in given group. * \param[in] cluster Cluster ID * \param[in] category Sub-cluster ID * \param[in] force 1 if the boxes should be updated even if they are paused * \return int - * \retval LB_STATUS_ERROR_INVALID - * \retval LB_STATUS_ERROR_FAULT - * \retval LB_STATUS_SUCCESS + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred + * \retval LB_STATUS_SUCCESS Successfully requested * \pre N/A * \post N/A - * \see N/A + * \see livebox_refresh */ extern int livebox_refresh_group(const char *cluster, const char *category, int force); @@ -1236,23 +1358,26 @@ extern int livebox_refresh_group(const char *cluster, const char *category, int * \brief Refresh a livebox * \details N/A * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \param[in] force 1 if the box should be updated even if it is paused * \return int - * \retval LB_STATUS_ERROR_INVALID - * \retval LB_STATUS_ERROR_FAULT - * \retval LB_STATUS_SUCCESS + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred + * \retval LB_STATUS_SUCCESS Successfully requested * \pre N/A * \post N/A - * \see N/A + * \see livebox_refresh_group */ extern int livebox_refresh(struct livebox *handler, int force); /*! * \brief Pixmap Id of a livebox content - * \details N/A + * \details + * This function doesn't guarantees the life-cycle of the pixmap. + * If the service provider destroy the pixmap, you will not know about it. + * So you should validate it before access it. * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \return int * \retval 0 if the pixmap is not created * \retval pixmap Pixmap Id need to be casted to (unsigned int) type @@ -1264,9 +1389,12 @@ extern int livebox_lb_pixmap(const struct livebox *handler); /*! * \brief Pixmap Id of a PD content - * \details N/A + * \details + * This function doesn't guarantees the life-cycle of the pixmap. + * If the service provider destroy the pixmap, you will not know about it. + * So you should validate it before access it. * \remarks N/A - * \param[in] handler + * \param[in] handler Handler of a livebox instance * \return int * \retval 0 if the pixmap is not created * \retval pixmap Pixmap Id need to be casted to (unsigned int) type @@ -1277,16 +1405,18 @@ extern int livebox_lb_pixmap(const struct livebox *handler); extern int livebox_pd_pixmap(const struct livebox *handler); /*! - * \brief - * \details N/A + * \brief Acquire the pixmap of PD + * \details + * After acquire the pixmap of PD, it will not be destroyed + * So if the new update is comming with new pixmap Id, you should release old pixmap manually * \remarks N/A - * \param[in] handler - * \param[in] cb - * \param[in] data + * \param[in] handler Handler of a livebox instance + * \param[in] cb Result callback for acquiring request + * \param[in] data Callback Data * \return int - * \retval LB_STATUS_ERROR_INVALID - * \retval LB_STATUS_ERROR_FAULT - * \retval LB_STATUS_SUCCESS + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_ERROR_FAULT Failed to send a request to the service provider or there is critical error that is unrecoverable + * \retval LB_STATUS_SUCCESS Successfully requested to acquire the pixmap of PD * \pre N/A * \post N/A * \see livebox_release_pd_pixmap @@ -1299,12 +1429,12 @@ extern int livebox_acquire_pd_pixmap(struct livebox *handler, ret_cb_t cb, void * \brief Release the acquired pixmap ID * \details N/A * \remarks N/A - * \param[in] handler - * \param[in] pixmap + * \param[in] handler Handler of a livebox instance + * \param[in] pixmap Pixmap Id to release it * \return int - * \retval LB_STATUS_ERROR_INVALID - * \retval LB_STATUS_ERROR_FAULT - * \retval LB_STATUS_SUCCESS + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred + * \retval LB_STATUS_SUCCESS Successfully released (request is sent) * \pre N/A * \post N/A * \see livebox_acquire_pd_pixmap @@ -1313,17 +1443,21 @@ extern int livebox_acquire_pd_pixmap(struct livebox *handler, ret_cb_t cb, void extern int livebox_release_pd_pixmap(struct livebox *handler, int pixmap); /*! - * \brief - * \details N/A + * \brief Getting the PIXMAP of a livebox + * \details + * Even if the render process release the pixmap, the pixmap will be kept before released by livebox_release_lb_pixmap + * You should release the pixmap manually. * \remarks N/A - * \param[in] handler - * \param[in] cb - * \param[in] data + * \param[in] handler Handler of a livebox instance + * \param[in] cb Callback function which will be called with result of acquiring lb pixmap + * \param[in] data Callback data * \return int - * \retval LB_STATUS_ERROR_INVALID - * \retval LB_STATUS_ERROR_FAULT - * \retval LB_STATUS_SUCCESS - * \pre N/A + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred + * \retval LB_STATUS_SUCCESS Successfully requested + * \pre + * Livebox service system should support the PIXMAP type buffer. + * The livebox should be designed to use the buffer (script type) * \post N/A * \see livebox_release_lb_pixmap * \see livebox_acquire_pd_pixmap @@ -1332,16 +1466,19 @@ extern int livebox_release_pd_pixmap(struct livebox *handler, int pixmap); extern int livebox_acquire_lb_pixmap(struct livebox *handler, ret_cb_t cb, void *data); /*! - * \brief - * \details N/A + * \brief Release the pixmap of a livebox + * \details + * After the client gets new pixmap or no more need to keep current pixmap, use this to release it. + * If there is no user for given pixmap, the pixmap will be destroyed. * \remarks N/A - * \param[in] handler - * \param[in] pixmap + * \param[in] handler Handler of a livebox instance + * \param[in] pixmap Pixmap Id of given livebox handler * \return int - * \retval LB_STATUS_ERROR_INVALID - * \retval LB_STATUS_ERROR_FAULT - * \retval LB_STATUS_SUCCESS - * \pre N/A + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred + * \retval LB_STATUS_SUCCESS Successfully done + * \pre + * The pixmap should be acquired by livebox_acquire_lb_pixmap * \post N/A * \see livebox_acquire_lb_pixmap * \see livebox_release_pd_pixmap @@ -1352,15 +1489,15 @@ extern int livebox_release_lb_pixmap(struct livebox *handler, int pixmap); * \brief Update the visible state of a livebox * \details N/A * \remarks N/A - * \param[in] handler Handler of a livebox + * \param[in] handler Handler of a livebox instance * \param[in] state Configure the current visible state of a livebox * \return int - * \retval LB_STATUS_ERROR_INVALID + * \retval LB_STATUS_ERROR_INVALID Invalid argument * \retval LB_STATUS_ERROR_BUSY * \retval LB_STATUS_ERROR_PERMISSION * \retval LB_STATUS_ERROR_ALREADY - * \retval LB_STATUS_ERROR_FAULT - * \retval LB_STATUS_SUCCESS + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred + * \retval LB_STATUS_SUCCESS Successfully done * \pre N/A * \post N/A * \see N/A @@ -1371,7 +1508,7 @@ extern int livebox_set_visibility(struct livebox *handler, enum livebox_visible_ * \brief Current visible state of a livebox * \details N/A * \remarks N/A - * \param[in] handler Handler of a livebox + * \param[in] handler Handler of a livebox instance * \return livebox_visible_state * \retval LB_SHOW Livebox is showed. Default state * \retval LB_HIDE Livebox is hide, Update timer is not be freezed. but you cannot receive any updates events. you should refresh(reload) the content of a livebox when you make this show again @@ -1390,17 +1527,19 @@ extern enum livebox_visible_state livebox_visibility(struct livebox *handler); * if you set 1 for active update mode, you should get buffer without updated event from provider. * But is passive mode, you have to update content of a box when you get updated event. * Default is Passive mode. - * \param[in] handler Handler of a livebox + * \param[in] handler Handler of a livebox instance * \param[in] active_update 1 means active update, 0 means passive update (default) * \param[in] cb Result callback function * \param[in] data Callback data * \return int - * \retval LB_STATUS_ERROR_INVALID + * \retval LB_STATUS_ERROR_INVALID Invalid argument * \retval LB_STATUS_ERROR_BUSY * \retval LB_STATUS_ERROR_PERMISSION * \retval LB_STATUS_ERROR_ALREADY - * \retval LB_STATUS_ERROR_FAULT - * \retval LB_STATUS_SUCCESS + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred + * \retval LB_STATUS_SUCCESS Successfully done + * \pre N/A + * \post N/A * \see ret_cb_t */ extern int livebox_set_update_mode(struct livebox *handler, int active_update, ret_cb_t cb, void *data); @@ -1409,10 +1548,12 @@ extern int livebox_set_update_mode(struct livebox *handler, int active_update, r * \brief Is this box in the active update mode? * \details N/A * \remarks N/A - * \param[in] handler HAndler of a livebox + * \param[in] handler Handler of a livebox instance * \return int * \retval 0 if passive mode * \retval 1 if active mode or error code + * \pre N/A + * \post N/A * \see N/A */ extern int livebox_is_active_update(struct livebox *handler); @@ -1423,6 +1564,8 @@ extern int livebox_is_active_update(struct livebox *handler); * \remarks N/A * param[in] flag * \return void + * \pre N/A + * \post N/A * \see livebox_manual_sync * \see livebox_sync_pd_fb * \see livebox_sync_lb_fb @@ -1436,6 +1579,8 @@ extern void livebox_set_manual_sync(int flag); * \return int * \retval 0 if auto sync * \retval 1 if manual sync + * \pre N/A + * \post N/A * \see livebox_set_manual_sync * \see livebox_sync_pd_fb * \see livebox_sync_lb_fb @@ -1446,19 +1591,26 @@ extern int livebox_manual_sync(void); * \brief Use the frame drop while resizing contents * \details N/A * \remarks N/A - * \param[in] flag + * \param[in] flag 1 for dropping frames of old size or 0. * \return void + * \pre N/A + * \post N/A * \see livebox_frame_drop_for_resizing */ extern void livebox_set_frame_drop_for_resizing(int flag); /*! * \brief Get current mode - * \details N/A + * \details + * While resizing the box, viewer doesn't want to know the updaed frames of old size anymore, + * In that case, if this mode is turnned on, the provider will not send the updated event to the viewer about old size. + * So the viewer can reduce its burden to update (or ignore) unnecessary frames * \remarks N/A * \return int - * \retval 0 if disabled - * \retval 1 if enabled + * \retval 0 if it is disabled + * \retval 1 if it is enabled + * \pre N/A + * \post N/A * \see livebox_set_frame_drop_for_resizing */ extern int livebox_frame_drop_for_resizing(void); @@ -1467,9 +1619,12 @@ extern int livebox_frame_drop_for_resizing(void); * \brief Sync manually * \details N/A * \remarks N/A - * param[in] handler + * param[in] handler Handler of a livebox instance * \return void - * \retval 0 if success + * \retval LB_STATUS_SUCCESS If success + * \retval LB_STATUS_ERROR_INVALID Invalid handle + * \pre N/A + * \post N/A * \see livebox_set_manual_sync * \see livebox_manual_sync * \see livebox_sync_lb_fb @@ -1480,9 +1635,12 @@ extern int livebox_sync_pd_fb(struct livebox *handler); * \brief Sync manually * \details N/A * \remarks N/A - * param[in] handler + * \param[in] handler Handler of a livebox instance * \return void - * \retval 0 if success + * \retval LB_STATUS_SUCCESS If success + * \retval LB_STATUS_ERROR_INVALID Invalid handle + * \pre N/A + * \post N/A * \see livebox_set_manual_sync * \see livebox_manual_sync * \see livebox_sync_pd_fb @@ -1490,6 +1648,71 @@ extern int livebox_sync_pd_fb(struct livebox *handler); extern int livebox_sync_lb_fb(struct livebox *handler); /*! + * \brief Getting the alternative icon of given livebox instance. + * \details If the box should be represented as a shortcut icon, this function will get the alternative icon. + * \remarks N/A + * \param[in] handler Handler of a livebox instance + * \return const char * + * \retval address Absolute path of an alternative icon file + * \retval NULL Livebox has no alternative icon file + * \pre N/A + * \post N/A + * \see livebox_alt_name + */ +extern const char *livebox_alt_icon(struct livebox *handler); + +/*! + * \brief Getting the alternative name of given livebox instance. + * \details If the box should be represented as a shortcut name, this function will get the alternative name. + * \remarks N/A + * \param[in] handler Handler of a livebox instance + * \return const char * + * \retval name Alternative name of a livebox + * \retval NULL Livebox has no alternative name + * \pre N/A + * \post N/A + * \see livebox_alt_icon + */ +extern const char *livebox_alt_name(struct livebox *handler); + +/*! + * \brief Get the lock for frame buffer. + * \details + * This function should be used to prevent from rendering to the frame buffer while reading it. + * And the locking area should be short and must be released ASAP + * Or the render thread will be hang'd. + * \remarks + * \param[in] handler Handler of a livebox instance + * \param[in] is_pd 1 for PD or 0 + * \return int + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_SUCCESS Successfully done + * \pre N/A + * \post N/A + * \see livebox_release_fb_lock + */ +extern int livebox_acquire_fb_lock(struct livebox *handler, int is_pd); + +/*! + * \brief Release the lock of frame buffer + * \details + * This function should be called ASAP after acquire a lock of FB. + * Or the render process will be blocked. + * \remarks N/A + * \param[in] handler Handler of a livebox instance + * \param[in] is_pd 1 for PD or 0 + * \return int + * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred + * \retval LB_STATUS_ERROR_INVALID Invalid argument + * \retval LB_STATUS_SUCCESS Successfully done + * \pre N/A + * \post N/A + * \see livebox_acquire_fb_lock + */ +extern int livebox_release_fb_lock(struct livebox *handler, int is_pd); + +/*! * \} */ diff --git a/include/livebox_internal.h b/include/livebox_internal.h index cbbefbc..fb9da64 100644 --- a/include/livebox_internal.h +++ b/include/livebox_internal.h @@ -43,9 +43,12 @@ extern void lb_set_period(struct livebox *handler, double period); extern void lb_set_update_mode(struct livebox *handler, int active_mode); extern struct livebox *lb_ref(struct livebox *handler); extern struct livebox *lb_unref(struct livebox *handler); -extern int lb_send_delete(struct livebox *handler, ret_cb_t cb, void *data); +extern int lb_send_delete(struct livebox *handler, int type, ret_cb_t cb, void *data); extern int lb_delete_all(void); extern void lb_set_filename(struct livebox *handler, const char *filename); +extern void lb_set_alt_info(struct livebox *handler, const char *icon, const char *name); +extern int lb_destroy_lock_file(struct livebox *info, int is_pd); +extern int lb_create_lock_file(struct livebox *info, int is_pd); enum lb_type { /*!< Must have to be sync with data-provider-master */ _LB_TYPE_NONE = 0x0, @@ -78,10 +81,13 @@ struct livebox { char *content; char *title; char *filename; + char *icon; + char *name; double timestamp; enum livebox_visible_state visible; + enum livebox_delete_type delete_type; int is_user; int is_pd_created; @@ -109,6 +115,8 @@ struct livebox { /* For the filtering event */ double x; double y; + char *lock; + int lock_fd; } lb; struct { @@ -127,6 +135,8 @@ struct livebox { /* For the filtering event */ double x; double y; + char *lock; + int lock_fd; } pd; int nr_of_sizes; @@ -162,6 +172,9 @@ struct livebox { ret_cb_t access_event_cb; void *access_event_cbdata; + + ret_cb_t key_event_cb; + void *key_event_cbdata; }; /* End of a file */ diff --git a/live.viewer/CMakeLists.txt b/live.viewer/CMakeLists.txt index 954350e..9be5a14 100644 --- a/live.viewer/CMakeLists.txt +++ b/live.viewer/CMakeLists.txt @@ -19,7 +19,7 @@ FOREACH(flag ${pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -Winline -g") +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -Werror -Winline -g") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") SET(PKGROOT "/opt/usr/apps/live.viewer") diff --git a/packaging/liblivebox-viewer.spec b/packaging/liblivebox-viewer.spec index a82f2d7..86e61c4 100644 --- a/packaging/liblivebox-viewer.spec +++ b/packaging/liblivebox-viewer.spec @@ -1,6 +1,6 @@ Name: liblivebox-viewer Summary: Library for developing the application -Version: 0.14.9 +Version: 0.19.0 Release: 1 Group: HomeTF/Livebox License: Flora @@ -35,6 +35,12 @@ Livebox viewer development library (dev) cp %{SOURCE1001} . %build +%if 0%{?sec_build_binary_debug_enable} +export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE" +export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE" +export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE" +%endif + %if 0%{?tizen_build_binary_release_type_eng} export CFLAGS="${CFLAGS} -DTIZEN_ENGINEER_MODE" export CXXFLAGS="${CXXFLAGS} -DTIZEN_ENGINEER_MODE" diff --git a/src/client.c b/src/client.c index 6d7d011..3a3266d 100644 --- a/src/client.c +++ b/src/client.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include "debug.h" @@ -42,7 +43,6 @@ #include "util.h" #include "master_rpc.h" #include "conf.h" -#include "critical_log.h" #include "file_service.h" int errno; @@ -185,7 +185,7 @@ static struct packet *master_deleted(pid_t pid, int handle, const struct packet * \note * This is not possible */ - CRITICAL_LOG("Already deleted handler (%s - %s)\n", pkgname, id); + ErrPrint("Already deleted handler (%s - %s)\n", pkgname, id); return NULL; } } @@ -241,6 +241,12 @@ static struct packet *master_deleted(pid_t pid, int handle, const struct packet } } + /*! + * \note + * Lock file should be deleted after all callbacks are processed. + */ + lb_destroy_lock_file(handler, 0); + /* Just try to delete it, if a user didn't remove it from the live box list */ lb_unref(handler); @@ -290,7 +296,7 @@ static struct packet *master_lb_update_begin(pid_t pid, int handle, const struct if (lb_get_lb_fb(handler)) { (void)lb_set_lb_fb(handler, fbfile); - ret = fb_sync(lb_get_lb_fb(handler)); + ret = livebox_sync_lb_fb(handler); if (ret != LB_STATUS_SUCCESS) { ErrPrint("Failed to do sync FB (%s - %s) (%d)\n", pkgname, fbfile, ret); } else { @@ -332,7 +338,7 @@ static struct packet *master_pd_update_begin(pid_t pid, int handle, const struct if (lb_get_pd_fb(handler)) { (void)lb_set_lb_fb(handler, fbfile); - ret = fb_sync(lb_get_lb_fb(handler)); + ret = livebox_sync_lb_fb(handler); if (ret != LB_STATUS_SUCCESS) { ErrPrint("Failed to do sync FB (%s - %s) (%d)\n", pkgname, fbfile, ret); } else { @@ -380,6 +386,80 @@ out: return NULL; } +static struct packet *master_key_status(pid_t pid, int handle, const struct packet *packet) +{ + struct livebox *handler; + const char *pkgname; + const char *id; + int ret; + int status; + + ret = packet_get(packet, "ssi", &pkgname, &id, &status); + if (ret != 3) { + ErrPrint("Invalid argument\n"); + goto out; + } + + handler = lb_find_livebox(pkgname, id); + if (!handler) { + ErrPrint("Instance[%s] is not exists\n", id); + goto out; + } + + if (handler->state != CREATE) { + ErrPrint("[%s] is not created\n", id); + goto out; + } + + if (handler->key_event_cb) { + ret_cb_t cb; + void *cbdata; + + cb = handler->key_event_cb; + cbdata = handler->key_event_cbdata; + + handler->key_event_cb = NULL; + handler->key_event_cbdata = NULL; + + cb(handler, status, cbdata); + } else { + ErrPrint("Invalid event[%s]\n", id); + } +out: + return NULL; +} + +static struct packet *master_request_close_pd(pid_t pid, int handle, const struct packet *packet) +{ + struct livebox *handler; + const char *pkgname; + const char *id; + int ret; + int reason; + + ret = packet_get(packet, "ssi", &pkgname, &id, &reason); + if (ret != 3) { + ErrPrint("Invalid argument\n"); + goto out; + } + + handler = lb_find_livebox(pkgname, id); + if (!handler) { + ErrPrint("Instance[%s] is not exists\n", id); + goto out; + } + + if (handler->state != CREATE) { + ErrPrint("[%s] is not created\n", id); + goto out; + } + + DbgPrint("Reason: %d\n", reason); + lb_invoke_event_handler(handler, LB_EVENT_REQUEST_CLOSE_PD); +out: + return NULL; +} + static struct packet *master_access_status(pid_t pid, int handle, const struct packet *packet) { struct livebox *handler; @@ -465,18 +545,20 @@ static struct packet *master_lb_updated(pid_t pid, int handle, const struct pack const char *content; const char *title; const char *safe_file; + const char *icon; + const char *name; struct livebox *handler; int lb_w; int lb_h; double priority; int ret; - ret = packet_get(packet, "sssiidsss", + ret = packet_get(packet, "sssiidsssss", &pkgname, &id, &fbfile, &lb_w, &lb_h, &priority, &content, &title, - &safe_file); - if (ret != 9) { + &safe_file, &icon, &name); + if (ret != 11) { ErrPrint("Invalid argument\n"); goto out; } @@ -521,7 +603,7 @@ static struct packet *master_lb_updated(pid_t pid, int handle, const struct pack (void)lb_set_lb_fb(handler, fbfile); if (!conf_manual_sync()) { - ret = fb_sync(lb_get_lb_fb(handler)); + ret = livebox_sync_lb_fb(handler); if (ret != LB_STATUS_SUCCESS) { ErrPrint("Failed to do sync FB (%s - %s) (%d)\n", pkgname, util_basename(util_uri_to_path(id)), ret); } @@ -574,7 +656,7 @@ static struct packet *master_pd_created(pid_t pid, int handle, const struct pack DbgPrint("Text TYPE does not need to handle this\n"); } else { (void)lb_set_pd_fb(handler, buf_id); - ret = fb_sync(lb_get_pd_fb(handler)); + ret = livebox_sync_pd_fb(handler); if (ret < 0) { ErrPrint("Failed to do sync FB (%s - %s)\n", pkgname, util_basename(util_uri_to_path(id))); } @@ -582,6 +664,25 @@ static struct packet *master_pd_created(pid_t pid, int handle, const struct pack handler->is_pd_created = (status == 0); + switch (handler->pd.type) { + case _PD_TYPE_SCRIPT: + case _PD_TYPE_BUFFER: + switch (fb_type(lb_get_pd_fb(handler))) { + case BUFFER_TYPE_FILE: + case BUFFER_TYPE_SHM: + lb_create_lock_file(handler, 1); + break; + case BUFFER_TYPE_PIXMAP: + case BUFFER_TYPE_ERROR: + default: + break; + } + break; + case _PD_TYPE_TEXT: + default: + break; + } + if (handler->pd_created_cb) { ret_cb_t cb; void *cbdata; @@ -654,6 +755,29 @@ static struct packet *master_pd_destroyed(pid_t pid, int handle, const struct pa lb_invoke_event_handler(handler, LB_EVENT_PD_DESTROYED); } + /*! + * \note + * Lock file should be deleted after all callbacks are processed. + */ + switch (handler->pd.type) { + case _PD_TYPE_SCRIPT: + case _PD_TYPE_BUFFER: + switch (fb_type(lb_get_pd_fb(handler))) { + case BUFFER_TYPE_FILE: + case BUFFER_TYPE_SHM: + lb_destroy_lock_file(handler, 1); + break; + case BUFFER_TYPE_PIXMAP: + case BUFFER_TYPE_ERROR: + default: + break; + } + break; + case _PD_TYPE_TEXT: + default: + break; + } + out: return NULL; } @@ -707,7 +831,7 @@ static struct packet *master_pd_updated(pid_t pid, int handle, const struct pack (void)lb_set_pd_fb(handler, fbfile); if (!conf_manual_sync()) { - ret = fb_sync(lb_get_pd_fb(handler)); + ret = livebox_sync_pd_fb(handler); if (ret < 0) { ErrPrint("Failed to do sync FB (%s - %s), %d\n", pkgname, util_basename(util_uri_to_path(id)), ret); } else { @@ -837,7 +961,7 @@ static struct packet *master_size_changed(pid_t pid, int handle, const struct pa if (lb_get_lb_fb(handler)) { (void)lb_set_lb_fb(handler, fbfile); - ret = fb_sync(lb_get_lb_fb(handler)); + ret = livebox_sync_lb_fb(handler); if (ret < 0) { ErrPrint("Failed to do sync FB (%s - %s)\n", pkgname, util_basename(util_uri_to_path(id))); } @@ -1105,7 +1229,24 @@ static struct packet *master_created(pid_t pid, int handle, const struct packet } (void)lb_set_lb_fb(handler, lb_fname); - ret = fb_sync(lb_get_lb_fb(handler)); + /*! + * \note + * Livebox should create the lock file from here. + * Even if the old_state == DELETE, + * the lock file will be deleted from deleted event callback. + */ + switch (fb_type(lb_get_lb_fb(handler))) { + case BUFFER_TYPE_FILE: + case BUFFER_TYPE_SHM: + lb_create_lock_file(handler, 0); + break; + case BUFFER_TYPE_PIXMAP: + case BUFFER_TYPE_ERROR: + default: + break; + } + + ret = livebox_sync_lb_fb(handler); if (ret < 0) { ErrPrint("Failed to do sync FB (%s - %s)\n", pkgname, util_basename(util_uri_to_path(id))); } @@ -1128,10 +1269,17 @@ static struct packet *master_created(pid_t pid, int handle, const struct packet } lb_set_pd_fb(handler, pd_fname); - ret = fb_sync(lb_get_pd_fb(handler)); + ret = livebox_sync_pd_fb(handler); if (ret < 0) { ErrPrint("Failed to do sync FB (%s - %s)\n", pkgname, util_basename(util_uri_to_path(id))); } + + /*! + * \brief + * PD doesn't need to create the lock file from here. + * Just create it from PD_CREATED event. + */ + break; case _PD_TYPE_TEXT: lb_set_text_pd(handler); @@ -1182,7 +1330,7 @@ static struct packet *master_created(pid_t pid, int handle, const struct packet out: if (ret == 0 && old_state == DELETE) { - lb_send_delete(handler, handler->created_cb, handler->created_cbdata); + lb_send_delete(handler, handler->delete_type, handler->created_cb, handler->created_cbdata); /*! * \note @@ -1276,6 +1424,14 @@ static struct method s_table[] = { .cmd = "access_status", .handler = master_access_status, }, + { + .cmd = "key_status", + .handler = master_key_status, + }, + { + .cmd = "close_pd", + .handler = master_request_close_pd, + }, { .cmd = NULL, @@ -1396,8 +1552,10 @@ static int disconnected_cb(int handle, void *data) return 0; } -int client_init(void) +int client_init(int use_thread) { + com_core_packet_use_thread(use_thread); + s_info.client_addr = vconf_get_str(VCONFKEY_MASTER_CLIENT_ADDR); if (!s_info.client_addr) { s_info.client_addr = strdup(CLIENT_SOCKET); diff --git a/src/critical_log.c b/src/critical_log.c deleted file mode 100644 index 12fd8a1..0000000 --- a/src/critical_log.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright 2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "conf.h" -#include "debug.h" -#include "util.h" -#include "critical_log.h" -#include "livebox-errno.h" /* For error code */ - -static struct { - FILE *fp; - int file_id; - int nr_of_lines; - char *filename; -} s_info = { - .fp = NULL, - .file_id = 0, - .nr_of_lines = 0, - .filename = NULL, -}; - - - -int critical_log(const char *func, int line, const char *fmt, ...) -{ - va_list ap; - int ret; - - if (!s_info.fp) { - return LB_STATUS_ERROR_IO; - } - -#if defined(_USE_ECORE_TIME_GET) - double tv; - tv = util_timestamp(); - fprintf(s_info.fp, "%d %lf [%s:%d] ", getpid(), tv, util_basename((char *)func), line); -#else - struct timeval tv; - gettimeofday(&tv, NULL); - fprintf(s_info.fp, "%d %lu.%lu [%s:%d] ", getpid(), tv.tv_sec, tv.tv_usec, util_basename((char *)func), line); -#endif - - va_start(ap, fmt); - ret = vfprintf(s_info.fp, fmt, ap); - va_end(ap); - - s_info.nr_of_lines++; - if (s_info.nr_of_lines == MAX_LOG_LINE) { - char *filename; - int namelen; - - s_info.file_id = (s_info.file_id + 1) % MAX_LOG_FILE; - - namelen = strlen(s_info.filename) + strlen(SLAVE_LOG_PATH) + 20; - filename = malloc(namelen); - if (filename) { - snprintf(filename, namelen, "%s/%d_%s", SLAVE_LOG_PATH, s_info.file_id, s_info.filename); - - if (s_info.fp) { - if (fclose(s_info.fp) != 0) { - ErrPrint("fclose: %s\n", strerror(errno)); - } - } - - s_info.fp = fopen(filename, "w+"); - if (!s_info.fp) { - ErrPrint("Failed to open a file: %s\n", filename); - } - - free(filename); - } - - s_info.nr_of_lines = 0; - } - return ret; -} - - - -int critical_log_init(const char *name) -{ - int namelen; - char *filename; - - if (s_info.fp) { - return 0; - } - - s_info.filename = strdup(name); - if (!s_info.filename) { - ErrPrint("Failed to create a log file\n"); - return LB_STATUS_ERROR_MEMORY; - } - - namelen = strlen(name) + strlen(SLAVE_LOG_PATH) + 20; - - filename = malloc(namelen); - if (!filename) { - ErrPrint("Failed to create a log file\n"); - free(s_info.filename); - s_info.filename = NULL; - return LB_STATUS_ERROR_MEMORY; - } - - snprintf(filename, namelen, "%s/%d_%s", SLAVE_LOG_PATH, s_info.file_id, name); - - s_info.fp = fopen(filename, "w+"); - if (!s_info.fp) { - ErrPrint("Failed to open log: %s\n", strerror(errno)); - free(s_info.filename); - s_info.filename = NULL; - free(filename); - return LB_STATUS_ERROR_IO; - } - - free(filename); - return 0; -} - - - -int critical_log_fini(void) -{ - if (s_info.filename) { - free(s_info.filename); - s_info.filename = NULL; - } - - if (s_info.fp) { - if (fclose(s_info.fp) != 0) { - ErrPrint("fclose: %s\n", strerror(errno)); - } - s_info.fp = NULL; - } - - return 0; -} - - - -/* End of a file */ diff --git a/src/desc_parser.c b/src/desc_parser.c index b5abe7d..d0fa14c 100644 --- a/src/desc_parser.c +++ b/src/desc_parser.c @@ -22,6 +22,7 @@ #include #include +#include #include "debug.h" #include "livebox.h" @@ -29,7 +30,6 @@ #include "desc_parser.h" #include "dlist.h" #include "util.h" -#include "critical_log.h" #define TYPE_TEXT "text" #define TYPE_IMAGE "image" @@ -360,7 +360,7 @@ int parse_desc(struct livebox *handle, const char *descfile, int is_pd) block = calloc(1, sizeof(*block)); if (!block) { - CRITICAL_LOG("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %s\n", strerror(errno)); update_end(handle, is_pd); if (fclose(fp) != 0) { ErrPrint("fclose: %s\n", strerror(errno)); @@ -482,7 +482,7 @@ int parse_desc(struct livebox *handle, const char *descfile, int is_pd) block->type_len += 256; block->type = realloc(block->type, block->type_len); if (!block->type) { - CRITICAL_LOG("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %s\n", strerror(errno)); goto errout; } } @@ -504,7 +504,7 @@ int parse_desc(struct livebox *handle, const char *descfile, int is_pd) block->part_len += 256; block->part = realloc(block->part, block->part_len); if (!block->part) { - CRITICAL_LOG("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %s\n", strerror(errno)); goto errout; } } @@ -526,7 +526,7 @@ int parse_desc(struct livebox *handle, const char *descfile, int is_pd) block->data_len += 256; block->data = realloc(block->data, block->data_len); if (!block->data) { - CRITICAL_LOG("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %s\n", strerror(errno)); goto errout; } } @@ -548,7 +548,7 @@ int parse_desc(struct livebox *handle, const char *descfile, int is_pd) block->file_len += 256; block->file = realloc(block->file, block->file_len); if (!block->file) { - CRITICAL_LOG("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %s\n", strerror(errno)); goto errout; } } @@ -570,7 +570,7 @@ int parse_desc(struct livebox *handle, const char *descfile, int is_pd) block->option_len += 256; block->option = realloc(block->option, block->option_len); if (!block->option) { - CRITICAL_LOG("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %s\n", strerror(errno)); goto errout; } } @@ -591,7 +591,7 @@ int parse_desc(struct livebox *handle, const char *descfile, int is_pd) block->id_len += 256; block->id = realloc(block->id, block->id_len); if (!block->id) { - CRITICAL_LOG("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %s\n", strerror(errno)); goto errout; } } diff --git a/src/fb.c b/src/fb.c index 20bffc9..69c5dde 100644 --- a/src/fb.c +++ b/src/fb.c @@ -37,7 +37,6 @@ #include "debug.h" #include "util.h" #include "fb.h" -#include "critical_log.h" int errno; @@ -316,13 +315,13 @@ struct fb_info *fb_create(const char *id, int w, int h) info = calloc(1, sizeof(*info)); if (!info) { - CRITICAL_LOG("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %s\n", strerror(errno)); return NULL; } info->id = strdup(id); if (!info->id) { - CRITICAL_LOG("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %s\n", strerror(errno)); free(info); return NULL; } @@ -401,7 +400,7 @@ void *fb_acquire_buffer(struct fb_info *info) buffer = calloc(1, sizeof(*buffer) + info->bufsz); if (!buffer) { - CRITICAL_LOG("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %s\n", strerror(errno)); info->bufsz = 0; return NULL; } @@ -422,7 +421,7 @@ void *fb_acquire_buffer(struct fb_info *info) buffer = calloc(1, sizeof(*buffer) + info->bufsz); if (!buffer) { - CRITICAL_LOG("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %s\n", strerror(errno)); info->bufsz = 0; return NULL; } @@ -591,4 +590,34 @@ int fb_size(struct fb_info *info) return info->bufsz; } +int fb_type(struct fb_info *info) +{ + struct buffer *buffer; + + if (!info) { + return BUFFER_TYPE_ERROR; + } + + buffer = info->buffer; + if (!buffer) { + int type = BUFFER_TYPE_ERROR; + /*! + * \note + * Try to get this from SCHEMA + */ + if (info->id) { + if (!strncasecmp(info->id, SCHEMA_FILE, strlen(SCHEMA_FILE))) { + type = BUFFER_TYPE_FILE; + } else if (!strncasecmp(info->id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP))) { + type = BUFFER_TYPE_PIXMAP; + } else if (!strncasecmp(info->id, SCHEMA_SHM, strlen(SCHEMA_SHM))) { + type = BUFFER_TYPE_SHM; + } + } + + return type; + } + + return buffer->type; +} /* End of a file */ diff --git a/src/livebox.c b/src/livebox.c index 897b0c6..c9d3635 100644 --- a/src/livebox.c +++ b/src/livebox.c @@ -20,6 +20,9 @@ #include /* strdup */ #include #include +#include +#include +#include #include #include @@ -37,7 +40,6 @@ #include "util.h" #include "master_rpc.h" #include "client.h" -#include "critical_log.h" #include "conf.h" #define EAPI __attribute__((visibility("default"))) @@ -128,13 +130,18 @@ static inline void default_access_event_cb(struct livebox *handler, int ret, voi DbgPrint("Default access event handler: %d\n", ret); } +static inline void default_key_event_cb(struct livebox *handler, int ret, void *data) +{ + DbgPrint("Default key event handler: %d\n", ret); +} + static inline __attribute__((always_inline)) struct cb_info *create_cb_info(ret_cb_t cb, void *data) { struct cb_info *info; info = malloc(sizeof(*info)); if (!info) { - CRITICAL_LOG("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %s\n", strerror(errno)); return NULL; } @@ -148,6 +155,126 @@ static inline void destroy_cb_info(struct cb_info *info) free(info); } +static int do_fb_lock(int fd) +{ + struct flock flock; + int ret; + + flock.l_type = F_RDLCK; + flock.l_whence = SEEK_SET; + flock.l_start = 0; + flock.l_len = 0; + flock.l_pid = getpid(); + + do { + ret = fcntl(fd, F_SETLKW, &flock); + if (ret < 0) { + ret = errno; + ErrPrint("fcntl: %s\n", strerror(errno)); + } + } while (ret == EINTR); + + return ret; +} + +static int do_fb_unlock(int fd) +{ + struct flock flock; + int ret; + + flock.l_type = F_UNLCK; + flock.l_whence = SEEK_SET; + flock.l_start = 0; + flock.l_len = 0; + flock.l_pid = getpid(); + + do { + ret = fcntl(fd, F_SETLKW, &flock); + if (ret < 0) { + ret = errno; + ErrPrint("fcntl: %s\n", strerror(errno)); + } + } while (ret == EINTR); + + return ret; +} + +int lb_destroy_lock_file(struct livebox *info, int is_pd) +{ + if (is_pd) { + if (!info->pd.lock) { + return -EINVAL; + } + + if (close(info->pd.lock_fd) < 0) { + ErrPrint("close: %s\n", strerror(errno)); + } + info->pd.lock_fd = -1; + + if (unlink(info->pd.lock) < 0) { + ErrPrint("unlink: %s\n", strerror(errno)); + } + + free(info->pd.lock); + info->pd.lock = NULL; + } else { + if (!info->lb.lock) { + return -EINVAL; + } + + if (close(info->lb.lock_fd) < 0) { + ErrPrint("close: %s\n", strerror(errno)); + } + info->lb.lock_fd = -1; + + if (unlink(info->lb.lock) < 0) { + ErrPrint("unlink: %s\n", strerror(errno)); + } + + free(info->lb.lock); + info->lb.lock = NULL; + } + + return 0; +} + +int lb_create_lock_file(struct livebox *info, int is_pd) +{ + int len; + char *file; + + len = strlen(info->id); + file = malloc(len + 20); + if (!file) { + ErrPrint("Heap: %s\n", strerror(errno)); + return -ENOMEM; + } + + snprintf(file, len + 20, "%s.%s.lck", util_uri_to_path(info->id), is_pd ? "pd" : "lb"); + + if (is_pd) { + info->pd.lock_fd = open(file, O_RDONLY); + if (info->pd.lock_fd < 0) { + ErrPrint("open: %s\n", strerror(errno)); + free(file); + return -EIO; + } + + info->pd.lock = file; + } else { + info->lb.lock_fd = open(file, O_RDONLY); + if (info->lb.lock_fd < 0) { + ErrPrint("open: %s\n", strerror(errno)); + free(file); + return -EIO; + } + + info->lb.lock = file; + } + + return 0; +} + static void update_mode_cb(struct livebox *handler, const struct packet *result, void *data) { int ret; @@ -564,6 +691,32 @@ errout: handler->pinup_cbdata = NULL; } +static void key_ret_cb(struct livebox *handler, const struct packet *result, void *data) +{ + int ret; + + if (!result) { + ret = LB_STATUS_ERROR_FAULT; + return; + } + + if (packet_get(result, "i", &ret) != 1) { + ret = LB_STATUS_ERROR_INVALID; + return; + } + + if (ret != LB_STATUS_SUCCESS) { + goto errout; + } + + return; +errout: + handler->key_event_cb(handler, ret, handler->key_event_cbdata); + handler->key_event_cb = NULL; + handler->key_event_cbdata = NULL; + return; +} + static void access_ret_cb(struct livebox *handler, const struct packet *result, void *data) { int ret; @@ -607,6 +760,21 @@ static int send_access_event(struct livebox *handler, const char *event, int x, return master_rpc_async_request(handler, packet, 0, access_ret_cb, NULL); } +static int send_key_event(struct livebox *handler, const char *event, unsigned int keycode) +{ + struct packet *packet; + double timestamp; + + timestamp = util_timestamp(); + packet = packet_create(event, "ssdi", handler->pkgname, handler->id, timestamp, keycode); + if (!packet) { + ErrPrint("Failed to build packet\n"); + return LB_STATUS_ERROR_FAULT; + } + + return master_rpc_async_request(handler, packet, 0, key_ret_cb, NULL); +} + static int send_mouse_event(struct livebox *handler, const char *event, int x, int y) { struct packet *packet; @@ -622,7 +790,7 @@ static int send_mouse_event(struct livebox *handler, const char *event, int x, i return master_rpc_request_only(handler, packet); } -static void initialize_livebox(void *disp) +static void initialize_livebox(void *disp, int use_thread) { #if defined(FLOG) char filename[BUFSIZ]; @@ -632,16 +800,15 @@ static void initialize_livebox(void *disp) __file_log_fp = fdopen(1, "w+t"); } #endif - critical_log_init("viewer"); livebox_service_init(); fb_init(disp); - client_init(); + client_init(use_thread); s_info.init_count++; } -EAPI int livebox_init_with_options(void *disp, int prevent_overwrite, double event_filter) +EAPI int livebox_init_with_options(void *disp, int prevent_overwrite, double event_filter, int use_thread) { if (s_info.init_count > 0) { s_info.init_count++; @@ -656,7 +823,7 @@ EAPI int livebox_init_with_options(void *disp, int prevent_overwrite, double eve s_info.prevent_overwrite = prevent_overwrite; MINIMUM_EVENT = event_filter; - initialize_livebox(disp); + initialize_livebox(disp, use_thread); return LB_STATUS_SUCCESS; } @@ -679,7 +846,7 @@ EAPI int livebox_init(void *disp) sscanf(env, "%lf", &MINIMUM_EVENT); } - initialize_livebox(disp); + initialize_livebox(disp, 0); return LB_STATUS_SUCCESS; } @@ -699,7 +866,6 @@ EAPI int livebox_fini(void) client_fini(); fb_fini(); livebox_service_fini(); - critical_log_fini(); return LB_STATUS_SUCCESS; } @@ -741,7 +907,7 @@ EAPI struct livebox *livebox_add_with_size(const char *pkgname, const char *cont } if (type != LB_SIZE_TYPE_UNKNOWN) { - livebox_service_get_size(type, &width, &height); + (void)livebox_service_get_size(type, &width, &height); } handler = calloc(1, sizeof(*handler)); @@ -812,6 +978,11 @@ EAPI struct livebox *livebox_add_with_size(const char *pkgname, const char *cont handler->timestamp = util_timestamp(); handler->is_user = 1; handler->visible = LB_SHOW; + handler->delete_type = LB_DELETE_PERMANENTLY; + handler->pd.lock = NULL; + handler->pd.lock_fd = -1; + handler->lb.lock = NULL; + handler->lb.lock_fd = -1; s_info.livebox_list = dlist_append(s_info.livebox_list, handler); @@ -908,6 +1079,44 @@ EAPI int livebox_set_period(struct livebox *handler, double period, ret_cb_t cb, return ret; } +EAPI int livebox_del_NEW(struct livebox *handler, int type, ret_cb_t cb, void *data) +{ + if (!handler) { + ErrPrint("Handler is NIL\n"); + return LB_STATUS_ERROR_INVALID; + } + + if (handler->state != CREATE) { + ErrPrint("Handler is already deleted\n"); + return LB_STATUS_ERROR_INVALID; + } + + handler->state = DELETE; + handler->delete_type = type; + + if (!handler->id) { + /*! + * \note + * The id is not determined yet. + * It means a user didn't receive created event yet. + * Then just stop to delete procedure from here. + * Because the "created" event handler will release this. + * By the way, if the user adds any callback for getting return status of this, + * call it at here. + */ + if (cb) { + cb(handler, 0, data); + } + return LB_STATUS_SUCCESS; + } + + if (!cb) { + cb = default_delete_cb; + } + + return lb_send_delete(handler, type, cb, data); +} + EAPI int livebox_del(struct livebox *handler, ret_cb_t cb, void *data) { if (!handler) { @@ -921,6 +1130,7 @@ EAPI int livebox_del(struct livebox *handler, ret_cb_t cb, void *data) } handler->state = DELETE; + handler->delete_type = LB_DELETE_PERMANENTLY; if (!handler->id) { /*! @@ -942,7 +1152,7 @@ EAPI int livebox_del(struct livebox *handler, ret_cb_t cb, void *data) cb = default_delete_cb; } - return lb_send_delete(handler, cb, data); + return lb_send_delete(handler, LB_DELETE_PERMANENTLY, cb, data); } EAPI int livebox_set_fault_handler(int (*cb)(enum livebox_fault_type, const char *, const char *, const char *, void *), void *data) @@ -955,7 +1165,7 @@ EAPI int livebox_set_fault_handler(int (*cb)(enum livebox_fault_type, const char info = malloc(sizeof(*info)); if (!info) { - CRITICAL_LOG("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %s\n", strerror(errno)); return LB_STATUS_ERROR_MEMORY; } @@ -997,7 +1207,7 @@ EAPI int livebox_set_event_handler(int (*cb)(struct livebox *, enum livebox_even info = malloc(sizeof(*info)); if (!info) { - CRITICAL_LOG("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %s\n", strerror(errno)); return LB_STATUS_ERROR_MEMORY; } @@ -1220,7 +1430,7 @@ EAPI int livebox_pd_is_created(struct livebox *handler) return LB_STATUS_ERROR_INVALID; } - if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) { + if (handler->state != CREATE || !handler->pd.data.fb || !handler->id) { ErrPrint("Handler is not valid\n"); return LB_STATUS_ERROR_INVALID; } @@ -1243,7 +1453,7 @@ EAPI int livebox_create_pd_with_position(struct livebox *handler, double x, doub return LB_STATUS_ERROR_INVALID; } - if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) { + if (handler->state != CREATE || !handler->pd.data.fb || !handler->id) { ErrPrint("Handler is not valid\n"); return LB_STATUS_ERROR_INVALID; } @@ -1287,7 +1497,7 @@ EAPI int livebox_move_pd(struct livebox *handler, double x, double y) return LB_STATUS_ERROR_INVALID; } - if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) { + if (handler->state != CREATE || !handler->pd.data.fb || !handler->id) { ErrPrint("Handler is not valid\n"); return LB_STATUS_ERROR_INVALID; } @@ -1348,7 +1558,7 @@ EAPI int livebox_destroy_pd(struct livebox *handler, ret_cb_t cb, void *data) return LB_STATUS_ERROR_INVALID; } - if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) { + if (handler->state != CREATE || !handler->pd.data.fb || !handler->id) { ErrPrint("Handler is not valid\n"); return LB_STATUS_ERROR_INVALID; } @@ -1474,6 +1684,11 @@ EAPI int livebox_access_event(struct livebox *handler, enum access_event_type ty EAPI int livebox_content_event(struct livebox *handler, enum content_event_type type, double x, double y) { + return livebox_mouse_event(handler, type, x, y); +} + +EAPI int livebox_mouse_event(struct livebox *handler, enum content_event_type type, double x, double y) +{ int w = 1; int h = 1; char cmd[32] = { '\0', }; @@ -1489,6 +1704,11 @@ EAPI int livebox_content_event(struct livebox *handler, enum content_event_type return LB_STATUS_ERROR_INVALID; } + if (!(type & CONTENT_EVENT_MOUSE_MASK)) { + ErrPrint("Invalid content event is used\n"); + return LB_STATUS_ERROR_INVALID; + } + if (type & CONTENT_EVENT_PD_MASK) { int flag = 1; @@ -1497,19 +1717,17 @@ EAPI int livebox_content_event(struct livebox *handler, enum content_event_type return LB_STATUS_ERROR_INVALID; } - if (type & CONTENT_EVENT_MOUSE_MASK) { - if (!handler->pd.data.fb) { - ErrPrint("Handler is not valid\n"); - return LB_STATUS_ERROR_INVALID; - } + if (!handler->pd.data.fb) { + ErrPrint("Handler is not valid\n"); + 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 LB_STATUS_ERROR_BUSY; - } - } else if (type & CONTENT_EVENT_MOUSE_SET) { - flag = 0; + if (type & CONTENT_EVENT_MOUSE_MOVE) { + if (fabs(x - handler->pd.x) < MINIMUM_EVENT && fabs(y - handler->pd.y) < MINIMUM_EVENT) { + return LB_STATUS_ERROR_BUSY; } + } else if (type & CONTENT_EVENT_MOUSE_SET) { + flag = 0; } if (flag) { @@ -1523,23 +1741,21 @@ EAPI int livebox_content_event(struct livebox *handler, enum content_event_type } else if (type & CONTENT_EVENT_LB_MASK) { int flag = 1; - if (type & CONTENT_EVENT_MOUSE_MASK) { - if (!handler->lb.mouse_event) { - return LB_STATUS_ERROR_INVALID; - } + if (!handler->lb.mouse_event) { + return LB_STATUS_ERROR_INVALID; + } - if (!handler->lb.data.fb) { - ErrPrint("Handler is not valid\n"); - return LB_STATUS_ERROR_INVALID; - } + if (!handler->lb.data.fb) { + ErrPrint("Handler is not valid\n"); + return LB_STATUS_ERROR_INVALID; + } - if (type & CONTENT_EVENT_MOUSE_MOVE) { - if (fabs(x - handler->lb.x) < MINIMUM_EVENT && fabs(y - handler->lb.y) < MINIMUM_EVENT) { - return LB_STATUS_ERROR_BUSY; - } - } else if (type & CONTENT_EVENT_MOUSE_SET) { - flag = 0; + if (type & CONTENT_EVENT_MOUSE_MOVE) { + if (fabs(x - handler->lb.x) < MINIMUM_EVENT && fabs(y - handler->lb.y) < MINIMUM_EVENT) { + return LB_STATUS_ERROR_BUSY; } + } else if (type & CONTENT_EVENT_MOUSE_SET) { + flag = 0; } if (flag) { @@ -1580,18 +1796,126 @@ EAPI int livebox_content_event(struct livebox *handler, enum content_event_type case CONTENT_EVENT_MOUSE_UNSET | CONTENT_EVENT_MOUSE_MASK: strcpy(ptr, "_mouse_unset"); break; - case CONTENT_EVENT_KEY_DOWN | CONTENT_EVENT_KEY_MASK: - strcpy(ptr, "_key_down"); + default: + ErrPrint("Invalid event type\n"); + return LB_STATUS_ERROR_INVALID; + } + + return send_mouse_event(handler, cmd, x * w, y * h); +} + +EAPI int livebox_key_event(struct livebox *handler, enum content_event_type type, unsigned int keycode, ret_cb_t cb, void *data) +{ + char cmd[32] = { '\0', }; + char *ptr = cmd; + int ret; + + if (!handler) { + ErrPrint("Handler is NIL\n"); + return LB_STATUS_ERROR_INVALID; + } + + if (handler->state != CREATE || !handler->id) { + ErrPrint("Handler is not valid\n"); + return LB_STATUS_ERROR_INVALID; + } + + if (!(type & CONTENT_EVENT_KEY_MASK)) { + ErrPrint("Invalid key event is used\n"); + return LB_STATUS_ERROR_INVALID; + } + + if (type & CONTENT_EVENT_PD_MASK) { + if (!handler->is_pd_created) { + ErrPrint("PD is not created\n"); + return LB_STATUS_ERROR_INVALID; + } + + if (!handler->pd.data.fb) { + ErrPrint("Handler is not valid\n"); + return LB_STATUS_ERROR_INVALID; + } + + if (type & CONTENT_EVENT_KEY_DOWN) { + /*! + * \TODO + * filtering the reproduced events if it is too fast + */ + } else if (type & CONTENT_EVENT_KEY_SET) { + /*! + * \TODO + * What can I do for this case? + */ + } + + *ptr++ = 'p'; + *ptr++ = 'd'; + } else if (type & CONTENT_EVENT_LB_MASK) { + if (!handler->lb.mouse_event) { + return LB_STATUS_ERROR_INVALID; + } + + if (!handler->lb.data.fb) { + ErrPrint("Handler is not valid\n"); + return LB_STATUS_ERROR_INVALID; + } + + if (type & CONTENT_EVENT_KEY_DOWN) { + /*! + * \TODO + * filtering the reproduced events if it is too fast + */ + } else if (type & CONTENT_EVENT_KEY_SET) { + /*! + * What can I do for this case? + */ + } + + *ptr++ = 'l'; + *ptr++ = 'b'; + } else { + ErrPrint("Invalid event type\n"); + return LB_STATUS_ERROR_INVALID; + } + + /*! + * Must be short than 29 bytes. + */ + switch ((type & ~(CONTENT_EVENT_PD_MASK | CONTENT_EVENT_LB_MASK))) { + case CONTENT_EVENT_KEY_FOCUS_IN | CONTENT_EVENT_KEY_MASK: + strcpy(ptr, "_key_focus_in"); + break; + case CONTENT_EVENT_KEY_FOCUS_OUT | CONTENT_EVENT_KEY_MASK: + strcpy(ptr, "_key_focus_out"); break; case CONTENT_EVENT_KEY_UP | CONTENT_EVENT_KEY_MASK: strcpy(ptr, "_key_up"); break; + case CONTENT_EVENT_KEY_DOWN | CONTENT_EVENT_KEY_MASK: + strcpy(ptr, "_key_down"); + break; + case CONTENT_EVENT_KEY_SET | CONTENT_EVENT_KEY_MASK: + strcpy(ptr, "_key_set"); + break; + case CONTENT_EVENT_KEY_UNSET | CONTENT_EVENT_KEY_MASK: + strcpy(ptr, "_key_unset"); + break; default: ErrPrint("Invalid event type\n"); return LB_STATUS_ERROR_INVALID; } - return send_mouse_event(handler, cmd, x * w, y * h); + if (!cb) { + cb = default_key_event_cb; + } + + ret = send_key_event(handler, cmd, keycode); + if (ret == LB_STATUS_SUCCESS) { + handler->key_event_cb = cb; + handler->key_event_cbdata = data; + } + + return ret; } EAPI const char *livebox_filename(struct livebox *handler) @@ -1729,7 +2053,7 @@ EAPI int livebox_set_group(struct livebox *handler, const char *cluster, const c return ret; } -EAPI int livebox_get_group(struct livebox *handler, char ** const cluster, char ** const category) +EAPI int livebox_get_group(struct livebox *handler, const char **cluster, const char **category) { if (!handler) { ErrPrint("Handler is NIL\n"); @@ -2421,7 +2745,7 @@ EAPI int livebox_emit_text_signal(struct livebox *handler, const char *emission, return LB_STATUS_ERROR_INVALID; } - if ((handler->lb.type != _LB_TYPE_TEXT && handler->pd.type != _PD_TYPE_TEXT) || handler->state != CREATE || !handler->id) { + if (handler->state != CREATE || (handler->lb.type != _LB_TYPE_TEXT && handler->pd.type != _PD_TYPE_TEXT) || !handler->id) { ErrPrint("Handler is not valid\n"); return LB_STATUS_ERROR_INVALID; } @@ -2596,7 +2920,7 @@ int lb_set_group(struct livebox *handler, const char *cluster, const char *categ if (cluster) { pc = strdup(cluster); if (!pc) { - CRITICAL_LOG("Heap: %s (cluster: %s)\n", strerror(errno), cluster); + ErrPrint("Heap: %s (cluster: %s)\n", strerror(errno), cluster); return LB_STATUS_ERROR_MEMORY; } } @@ -2604,7 +2928,7 @@ int lb_set_group(struct livebox *handler, const char *cluster, const char *categ if (category) { ps = strdup(category); if (!ps) { - CRITICAL_LOG("Heap: %s (category: %s)\n", strerror(errno), category); + ErrPrint("Heap: %s (category: %s)\n", strerror(errno), category); free(pc); return LB_STATUS_ERROR_MEMORY; } @@ -2735,6 +3059,11 @@ struct livebox *lb_new_livebox(const char *pkgname, const char *id, double times handler->pd.type = _PD_TYPE_SCRIPT; handler->state = CREATE; handler->visible = LB_SHOW; + handler->delete_type = LB_DELETE_PERMANENTLY; + handler->pd.lock = NULL; + handler->pd.lock_fd = -1; + handler->lb.lock = NULL; + handler->lb.lock_fd = -1; s_info.livebox_list = dlist_append(s_info.livebox_list, handler); lb_ref(handler); @@ -2765,7 +3094,7 @@ int lb_set_content(struct livebox *handler, const char *content) if (content) { handler->content = strdup(content); if (!handler->content) { - CRITICAL_LOG("Heap: %s (content: %s)\n", strerror(errno), content); + ErrPrint("Heap: %s (content: %s)\n", strerror(errno), content); return LB_STATUS_ERROR_MEMORY; } } @@ -2783,7 +3112,7 @@ int lb_set_title(struct livebox *handler, const char *title) if (title) { handler->title = strdup(title); if (!handler->title) { - CRITICAL_LOG("Heap: %s (title: %s)\n", strerror(errno), title); + ErrPrint("Heap: %s (title: %s)\n", strerror(errno), title); return LB_STATUS_ERROR_MEMORY; } } @@ -2828,8 +3157,10 @@ void lb_set_id(struct livebox *handler, const char *id) void lb_set_filename(struct livebox *handler, const char *filename) { if (handler->filename) { - if (handler->filename[0] && unlink(handler->filename) < 0) { - ErrPrint("unlink: %s (%s)\n", strerror(errno), handler->filename); + if (handler->lb.type == _LB_TYPE_FILE || handler->lb.type == _LB_TYPE_TEXT) { + if (handler->filename[0] && unlink(handler->filename) < 0) { + ErrPrint("unlink: %s (%s)\n", strerror(errno), handler->filename); + } } free(handler->filename); @@ -2837,11 +3168,42 @@ void lb_set_filename(struct livebox *handler, const char *filename) handler->filename = strdup(filename); if (!handler->filename) { - ErrPrint("Heap: %s (%s)\n", strerror(errno), handler->filename); - return; + ErrPrint("Heap: %s\n", strerror(errno)); } } +void lb_set_alt_info(struct livebox *handler, const char *icon, const char *name) +{ + char *_icon = NULL; + char *_name = NULL; + + if (icon && strlen(icon)) { + _icon = strdup(icon); + if (!_icon) { + ErrPrint("Heap: %s\n", strerror(errno)); + } + } + + if (name && strlen(name)) { + _name = strdup(name); + if (!_name) { + ErrPrint("Heap: %s\n", strerror(errno)); + } + } + + if (handler->icon) { + free(handler->icon); + } + + handler->icon = _icon; + + if (handler->name) { + free(handler->name); + } + + handler->name = _name; +} + int lb_set_lb_fb(struct livebox *handler, const char *filename) { struct fb_info *fb; @@ -3043,6 +3405,12 @@ struct livebox *lb_unref(struct livebox *handler) handler->access_event_cbdata = NULL; } + if (handler->key_event_cb) { + handler->key_event_cb(handler, LB_KEY_STATUS_ERROR, handler->key_event_cbdata); + handler->key_event_cb = NULL; + handler->key_event_cbdata = NULL; + } + if (handler->filename) { (void)util_unlink(handler->filename); } @@ -3056,6 +3424,8 @@ struct livebox *lb_unref(struct livebox *handler) free(handler->pkgname); free(handler->filename); free(handler->lb.auto_launch); + free(handler->icon); + free(handler->name); if (handler->lb.data.fb) { fb_destroy(handler->lb.data.fb); @@ -3071,7 +3441,7 @@ struct livebox *lb_unref(struct livebox *handler) return NULL; } -int lb_send_delete(struct livebox *handler, ret_cb_t cb, void *data) +int lb_send_delete(struct livebox *handler, int type, ret_cb_t cb, void *data) { struct packet *packet; struct cb_info *cbinfo; @@ -3087,7 +3457,7 @@ int lb_send_delete(struct livebox *handler, ret_cb_t cb, void *data) return LB_STATUS_ERROR_BUSY; } - packet = packet_create("delete", "ss", handler->pkgname, handler->id); + packet = packet_create("delete", "ssi", handler->pkgname, handler->id, type); if (!packet) { ErrPrint("Failed to build a param\n"); if (cb) { @@ -3163,12 +3533,119 @@ EAPI int livebox_frame_drop_for_resizing(void) EAPI int livebox_sync_lb_fb(struct livebox *handler) { - return fb_sync(lb_get_lb_fb(handler)); + int ret; + + if (fb_type(lb_get_lb_fb(handler)) == BUFFER_TYPE_FILE && handler->lb.lock_fd >= 0) { + (void)do_fb_lock(handler->lb.lock_fd); + ret = fb_sync(lb_get_lb_fb(handler)); + (void)do_fb_unlock(handler->lb.lock_fd); + } else { + ret = fb_sync(lb_get_lb_fb(handler)); + } + + return ret; } EAPI int livebox_sync_pd_fb(struct livebox *handler) { - return fb_sync(lb_get_pd_fb(handler)); + int ret; + + if (fb_type(lb_get_pd_fb(handler)) == BUFFER_TYPE_FILE && handler->pd.lock_fd >= 0) { + (void)do_fb_lock(handler->pd.lock_fd); + ret = fb_sync(lb_get_pd_fb(handler)); + (void)do_fb_unlock(handler->pd.lock_fd); + } else { + ret = fb_sync(lb_get_pd_fb(handler)); + } + + return ret; +} + +EAPI const char *livebox_alt_icon(struct livebox *handler) +{ + if (!handler || handler->state != CREATE) { + ErrPrint("Handler is not valid[%p]\n", handler); + return NULL; + } + return handler->icon; +} + +EAPI const char *livebox_alt_name(struct livebox *handler) +{ + if (!handler || handler->state != CREATE) { + ErrPrint("Handler is not valid[%p]\n", handler); + return NULL; + } + + return handler->name; +} + +EAPI int livebox_acquire_fb_lock(struct livebox *handler, int is_pd) +{ + int ret = LB_STATUS_SUCCESS; + int fd; + + if (is_pd) { + if (!handler->pd.lock || handler->pd.lock_fd < 0) { + DbgPrint("Lock: %s (%d)\n", handler->pd.lock, handler->pd.lock_fd); + return LB_STATUS_ERROR_INVALID; + } + + if (fb_type(lb_get_pd_fb(handler)) == BUFFER_TYPE_FILE) { + return LB_STATUS_SUCCESS; + } + + fd = handler->pd.lock_fd; + } else { + if (!handler->lb.lock || handler->lb.lock_fd < 0) { + DbgPrint("Lock: %s (%d)\n", handler->lb.lock, handler->lb.lock_fd); + return LB_STATUS_ERROR_INVALID; + } + + if (fb_type(lb_get_lb_fb(handler)) == BUFFER_TYPE_FILE) { + return LB_STATUS_SUCCESS; + } + + fd = handler->lb.lock_fd; + } + + ret = do_fb_lock(fd); + + return ret == 0 ? LB_STATUS_SUCCESS : LB_STATUS_ERROR_FAULT; +} + +EAPI int livebox_release_fb_lock(struct livebox *handler, int is_pd) +{ + int ret = LB_STATUS_SUCCESS; + int fd; + + if (is_pd) { + if (!handler->pd.lock || handler->pd.lock_fd < 0) { + DbgPrint("Unlock: %s (%d)\n", handler->pd.lock, handler->pd.lock_fd); + return LB_STATUS_ERROR_INVALID; + } + + if (fb_type(lb_get_pd_fb(handler)) == BUFFER_TYPE_FILE) { + return LB_STATUS_SUCCESS; + } + + fd = handler->pd.lock_fd; + } else { + if (!handler->lb.lock || handler->lb.lock_fd < 0) { + DbgPrint("Unlock: %s (%d)\n", handler->lb.lock, handler->lb.lock_fd); + return LB_STATUS_ERROR_INVALID; + } + + if (fb_type(lb_get_lb_fb(handler)) == BUFFER_TYPE_FILE) { + return LB_STATUS_SUCCESS; + } + + fd = handler->lb.lock_fd; + } + + ret = do_fb_unlock(fd); + + return ret == 0 ? LB_STATUS_SUCCESS : LB_STATUS_ERROR_FAULT; } /* End of a file */ diff --git a/src/master_rpc.c b/src/master_rpc.c index 0be7028..3af85ed 100644 --- a/src/master_rpc.c +++ b/src/master_rpc.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "debug.h" #include "dlist.h" -- 2.7.4