diff options
72 files changed, 1273 insertions, 212 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 660cb1b..d0732e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,8 @@ pkg_check_modules(pkg REQUIRED xdamage pkgmgr livebox-service + notification + badge ) SET(PACKAGE "${PROJECT_NAME}") @@ -1,6 +1,6 @@ Flora License -Version 1.0, April, 2013 +Version 1.1, April, 2013 http://floralicense.org/license/ @@ -119,17 +119,17 @@ Object form, provided that You meet the following conditions: Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only - and do not modify the License. - -You may add Your own attribution notices within Derivative Works -that You distribute, alongside or as an addendum to the NOTICE text -from the Work, provided that such additional attribution notices -cannot be construed as modifying the License. You may add Your own -copyright statement to Your modifications and may provide additional or -different license terms and conditions for use, reproduction, or -distribution of Your modifications, or for any such Derivative Works -as a whole, provided Your use, reproduction, and distribution of -the Work otherwise complies with the conditions stated in this License. + and do not modify the License. You may add Your own attribution notices + within Derivative Works that You distribute, alongside or as an addendum + to the NOTICE text from the Work, provided that such additional attribution + notices cannot be construed as modifying the License. You may add Your own + copyright statement to Your modifications and may provide additional or + different license terms and conditions for use, reproduction, or + distribution of Your modifications, or for any such Derivative Works + as a whole, provided Your use, reproduction, and distribution of + the Work otherwise complies with the conditions stated in this License + and your own copyright statement or terms and conditions do not conflict + the conditions stated in the License including section 3. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work @@ -192,7 +192,7 @@ identification within third-party archives. Copyright [yyyy] [name of copyright owner] - Licensed under the Flora License, Version 1.0 (the "License"); + 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 diff --git a/data-provider-master.manifest b/data-provider-master.manifest index b3b7af7..4cf5ac6 100644 --- a/data-provider-master.manifest +++ b/data-provider-master.manifest @@ -13,6 +13,8 @@ </request> <permit> <smack permit="dbus" type="rx" /> + <smack permit="notification::db" type="rw" /> + <smack permit="badge::db" type="rw" /> </permit> </define> <request> diff --git a/data/data-provider-master b/data/data-provider-master index 3c04aaf..6dd2a92 100755 --- a/data/data-provider-master +++ b/data/data-provider-master @@ -2,7 +2,7 @@ # # Copyright 2013 Samsung Electronics Co., Ltd # -# Licensed under the Flora License, Version 1.0 (the "License"); +# 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 # diff --git a/data/data-provider-master.service b/data/data-provider-master.service index f412797..fb3ab4f 100644 --- a/data/data-provider-master.service +++ b/data/data-provider-master.service @@ -1,7 +1,7 @@ # # Copyright 2013 Samsung Electronics Co., Ltd # -# Licensed under the Flora License, Version 1.0 (the "License"); +# 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 # diff --git a/include/abi.h b/include/abi.h index d1900b3..2b4ebd8 100644 --- a/include/abi.h +++ b/include/abi.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/badge_service.h b/include/badge_service.h index 94fb941..ed49c9f 100644 --- a/include/badge_service.h +++ b/include/badge_service.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * @@ -14,3 +14,7 @@ * limitations under the License. */ +extern int badge_service_init(void); +extern int badge_service_fini(void); + +/* End of a file */ diff --git a/include/buffer_handler.h b/include/buffer_handler.h index 21d6707..6a70270 100644 --- a/include/buffer_handler.h +++ b/include/buffer_handler.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/client_life.h b/include/client_life.h index 4871974..446b952 100644 --- a/include/client_life.h +++ b/include/client_life.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/client_rpc.h b/include/client_rpc.h index ccfa129..20a8a38 100644 --- a/include/client_rpc.h +++ b/include/client_rpc.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/conf.h b/include/conf.h index 50a171b..7dd31a2 100644 --- a/include/conf.h +++ b/include/conf.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/critical_log.h b/include/critical_log.h index 757ae63..f060ce1 100644 --- a/include/critical_log.h +++ b/include/critical_log.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/dead_monitor.h b/include/dead_monitor.h index 118c5ac..96efa3b 100644 --- a/include/dead_monitor.h +++ b/include/dead_monitor.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/debug.h b/include/debug.h index 5058acc..fb7c780 100644 --- a/include/debug.h +++ b/include/debug.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/event.h b/include/event.h index 4cf46e4..2bae5a8 100644 --- a/include/event.h +++ b/include/event.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/fault_manager.h b/include/fault_manager.h index d61e225..cfc1bec 100644 --- a/include/fault_manager.h +++ b/include/fault_manager.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/fb.h b/include/fb.h index 066f97a..bf6d224 100644 --- a/include/fb.h +++ b/include/fb.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/group.h b/include/group.h index 161e0a4..04dfddd 100644 --- a/include/group.h +++ b/include/group.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/instance.h b/include/instance.h index 535defa..a68dbcb 100644 --- a/include/instance.h +++ b/include/instance.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * @@ -141,8 +141,9 @@ extern int instance_activate(struct inst_info *inst); extern int instance_recover_state(struct inst_info *inst); extern int instance_need_slave(struct inst_info *inst); -extern void instance_set_lb_info(struct inst_info *inst, int w, int h, double priority, const char *content, const char *title); -extern void instance_set_pd_info(struct inst_info *inst, int w, int h); +extern void instance_set_lb_info(struct inst_info *inst, double priority, const char *content, const char *title); +extern void instance_set_lb_size(struct inst_info *inst, int w, int h); +extern void instance_set_pd_size(struct inst_info *inst, int w, int h); extern int instance_set_pinup(struct inst_info *inst, int pinup); extern int instance_resize(struct inst_info *inst, int w, int h); diff --git a/include/io.h b/include/io.h index 6624db5..7639aae 100644 --- a/include/io.h +++ b/include/io.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/liveinfo.h b/include/liveinfo.h index e86e4a2..9bb6db5 100644 --- a/include/liveinfo.h +++ b/include/liveinfo.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/main.h b/include/main.h index 94fb941..67a71d8 100644 --- a/include/main.h +++ b/include/main.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/notification_service.h b/include/notification_service.h index 94fb941..e02dfa3 100644 --- a/include/notification_service.h +++ b/include/notification_service.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * @@ -14,3 +14,7 @@ * limitations under the License. */ +extern int notification_service_init(void); +extern int notification_service_fini(void); + +/* End of a file */ diff --git a/include/package.h b/include/package.h index 9735fa2..488f465 100644 --- a/include/package.h +++ b/include/package.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/parser.h b/include/parser.h index db828b9..16e297a 100644 --- a/include/parser.h +++ b/include/parser.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/pkgmgr.h b/include/pkgmgr.h index e942697..dfc8e33 100644 --- a/include/pkgmgr.h +++ b/include/pkgmgr.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/rpc_to_slave.h b/include/rpc_to_slave.h index cfc87b9..d80c021 100644 --- a/include/rpc_to_slave.h +++ b/include/rpc_to_slave.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/script_handler.h b/include/script_handler.h index c676836..1ebad1e 100644 --- a/include/script_handler.h +++ b/include/script_handler.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/server.h b/include/server.h index 570eb87..457ab15 100644 --- a/include/server.h +++ b/include/server.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/service_common.h b/include/service_common.h index fa0188c..981d6dd 100644 --- a/include/service_common.h +++ b/include/service_common.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/setting.h b/include/setting.h index 1e4989e..6d0700f 100644 --- a/include/setting.h +++ b/include/setting.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/shortcut_service.h b/include/shortcut_service.h index 65031a2..2810039 100644 --- a/include/shortcut_service.h +++ b/include/shortcut_service.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/slave_life.h b/include/slave_life.h index 821b1eb..dea9f27 100644 --- a/include/slave_life.h +++ b/include/slave_life.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/slave_rpc.h b/include/slave_rpc.h index cfcbabb..18944ab 100644 --- a/include/slave_rpc.h +++ b/include/slave_rpc.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/include/util.h b/include/util.h index 75e4715..180fffc 100644 --- a/include/util.h +++ b/include/util.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * @@ -22,7 +22,7 @@ extern int util_unlink(const char *filename); extern int util_unlink_files(const char *folder); extern char *util_slavename(void); extern const char *util_basename(const char *name); -extern unsigned long util_free_space(const char *path); +extern unsigned long long util_free_space(const char *path); extern char *util_replace_string(const char *src, const char *pattern, const char *replace); extern const char *util_uri_to_path(const char *uri); extern void *util_timer_add(double interval, Eina_Bool (*cb)(void *data), void *data); diff --git a/include/xmonitor.h b/include/xmonitor.h index 55aadeb..46d4e51 100644 --- a/include/xmonitor.h +++ b/include/xmonitor.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/packaging/data-provider-master.spec b/packaging/data-provider-master.spec index ed82bd9..b1f8314 100644 --- a/packaging/data-provider-master.spec +++ b/packaging/data-provider-master.spec @@ -1,6 +1,6 @@ Name: data-provider-master Summary: Master service provider for liveboxes. -Version: 0.22.0 +Version: 0.23.0 Release: 1 Group: HomeTF/Livebox License: Flora License @@ -32,6 +32,9 @@ BuildRequires: pkgconfig(xext) BuildRequires: pkgconfig(xdamage) BuildRequires: pkgconfig(pkgmgr) BuildRequires: pkgconfig(livebox-service) +BuildRequires: pkgconfig(notification) +BuildRequires: pkgconfig(badge) +BuildRequires: sec-product-features %description Manage the 2nd stage livebox service provider and communicate with the viewer application. @@ -41,7 +44,11 @@ Keep trace on the life-cycle of the livebox and status of the service providers, %setup -q %build +%if 0%(test "%{?sec_build_conf_tizen_product_group}" == "baltic" && echo 1) +cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DPRODUCT=baltic +%else cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DPRODUCT=private +%endif CFLAGS="${CFLAGS} -Wall -Winline -Werror" LDFLAGS="${LDFLAGS}" make %{?jobs:-j%jobs} diff --git a/pkgmgr_livebox/include/dlist.h b/pkgmgr_livebox/include/dlist.h index 99e8443..cd1a421 100644 --- a/pkgmgr_livebox/include/dlist.h +++ b/pkgmgr_livebox/include/dlist.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/pkgmgr_livebox/src/dlist.c b/pkgmgr_livebox/src/dlist.c index cf2cb63..fa3082a 100644 --- a/pkgmgr_livebox/src/dlist.c +++ b/pkgmgr_livebox/src/dlist.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/pkgmgr_livebox/src/service_register.c b/pkgmgr_livebox/src/service_register.c index 6c8536e..78bc0d6 100644 --- a/pkgmgr_livebox/src/service_register.c +++ b/pkgmgr_livebox/src/service_register.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/res/edje/master.edc b/res/edje/master.edc index e64548a..38fcf7e 100644 --- a/res/edje/master.edc +++ b/res/edje/master.edc @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/src/badge_service.c b/src/badge_service.c index 94fb941..db3e090 100644 --- a/src/badge_service.c +++ b/src/badge_service.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * @@ -14,3 +14,329 @@ * limitations under the License. */ +#include <stdio.h> + +#include <Eina.h> + +#include <dlog.h> +#include <livebox-errno.h> +#include <packet.h> + +#include <badge.h> +#include <badge_db.h> + +#include "service_common.h" +#include "debug.h" +#include "util.h" +#include "conf.h" + +#define BADGE_ADDR "/tmp/.badge.service" + +static struct info { + Eina_List *context_list; + struct service_context *svc_ctx; +} s_info = { + .context_list = NULL, /*!< \WARN: This is only used for SERVICE THREAD */ + .svc_ctx = NULL, /*!< \WARN: This is only used for MAIN THREAD */ +}; + +struct context { + struct tcb *tcb; + double seq; +}; + +struct noti_service { + const char *cmd; + void (*handler)(struct tcb *tcb, struct packet *packet, void *data); +}; + +/*! + * FUNCTIONS to handle badge + */ +static inline char *get_string(char *string) +{ + if (string == NULL) { + return NULL; + } + if (string[0] == '\0') { + return NULL; + } + + return string; +} + +/*! + * SERVICE HANDLER + */ +static void _handler_insert_badge(struct tcb *tcb, struct packet *packet, void *data) +{ + int ret = 0; + struct packet *packet_reply = NULL; + struct packet *packet_service = NULL; + char *pkgname = NULL; + char *writable_pkg = NULL; + char *caller = NULL; + + if (packet_get(packet, "sss", &pkgname, &writable_pkg, &caller) == 3) { + pkgname = get_string(pkgname); + writable_pkg = get_string(writable_pkg); + caller = get_string(caller); + + if (pkgname != NULL && writable_pkg != NULL && caller != NULL) { + ret = badge_db_insert(pkgname, writable_pkg, caller); + + } else { + ret = BADGE_ERROR_INVALID_DATA; + } + + packet_reply = packet_create_reply(packet, "i", ret); + if (packet_reply) { + service_common_unicast_packet(tcb, packet_reply); + packet_destroy(packet_reply); + } + + if (ret == BADGE_ERROR_NONE) { + packet_service = packet_create("insert_badge", "is", ret, pkgname); + if (packet_service != NULL) { + service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE); + packet_destroy(packet_service); + } + } + } else { + ErrPrint("Failed to get data from the packet"); + } +} + +static void _handler_delete_badge(struct tcb *tcb, struct packet *packet, void *data) +{ + int ret = 0; + struct packet *packet_reply = NULL; + struct packet *packet_service = NULL; + char *pkgname = NULL; + char *caller = NULL; + + if (packet_get(packet, "ss", &pkgname, &caller) == 2) { + pkgname = get_string(pkgname); + caller = get_string(caller); + + if (pkgname != NULL && caller != NULL) { + ret = badge_db_delete(pkgname, caller); + + } else { + ret = BADGE_ERROR_INVALID_DATA; + } + + packet_reply = packet_create_reply(packet, "i", ret); + if (packet_reply) { + service_common_unicast_packet(tcb, packet_reply); + packet_destroy(packet_reply); + } + + if (ret == BADGE_ERROR_NONE) { + packet_service = packet_create("delete_badge", "is", ret, pkgname); + if (packet_service != NULL) { + service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE); + packet_destroy(packet_service); + } + } + } else { + ErrPrint("Failed to get data from the packet"); + } +} + +static void _handler_set_badge_count(struct tcb *tcb, struct packet *packet, void *data) +{ + int ret = 0; + struct packet *packet_reply = NULL; + struct packet *packet_service = NULL; + char *pkgname = NULL; + char *caller = NULL; + int count = 0; + + if (packet_get(packet, "ssi", &pkgname, &caller, &count) == 3) { + pkgname = get_string(pkgname); + caller = get_string(caller); + + if (pkgname != NULL && caller != NULL) { + ret = badge_db_set_count(pkgname, caller, count); + + } else { + ret = BADGE_ERROR_INVALID_DATA; + } + + packet_reply = packet_create_reply(packet, "i", ret); + if (packet_reply) { + service_common_unicast_packet(tcb, packet_reply); + packet_destroy(packet_reply); + } + + if (ret == BADGE_ERROR_NONE) { + packet_service = packet_create("set_badge_count", "isi", ret, pkgname, count); + if (packet_service != NULL) { + service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE); + packet_destroy(packet_service); + } + } + } else { + ErrPrint("Failed to get data from the packet"); + } +} + +static void _handler_set_display_option(struct tcb *tcb, struct packet *packet, void *data) +{ + int ret = 0; + struct packet *packet_reply = NULL; + struct packet *packet_service = NULL; + char *pkgname = NULL; + char *caller = NULL; + int is_display = 0; + + if (packet_get(packet, "ssi", &pkgname, &caller, &is_display) == 3) { + pkgname = get_string(pkgname); + caller = get_string(caller); + + if (pkgname != NULL && caller != NULL) { + ret = badge_db_set_display_option(pkgname, caller, is_display); + + } else { + ret = BADGE_ERROR_INVALID_DATA; + } + + packet_reply = packet_create_reply(packet, "i", ret); + if (packet_reply) { + service_common_unicast_packet(tcb, packet_reply); + packet_destroy(packet_reply); + } + + if (ret == BADGE_ERROR_NONE) { + packet_service = packet_create("set_disp_option", "isi", ret, pkgname, is_display); + if (packet_service != NULL) { + service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE); + packet_destroy(packet_service); + } + } + } else { + ErrPrint("Failed to get data from the packet"); + } +} + +static void _handler_service_register(struct tcb *tcb, struct packet *packet, void *data) +{ + struct packet *packet_reply; + int ret; + + ret = tcb_client_type_set(tcb, TCB_CLIENT_TYPE_SERVICE); + + packet_reply = packet_create_reply(packet, "i", ret); + if (packet_reply) { + service_common_unicast_packet(tcb, packet_reply); + packet_destroy(packet_reply); + } +} + +/*! + * SERVICE THREAD + */ +static int service_thread_main(struct tcb *tcb, struct packet *packet, void *data) +{ + int i = 0; + const char *command; + static struct noti_service service_req_table[] = { + { + .cmd = "insert_badge", + .handler = _handler_insert_badge, + }, + { + .cmd = "delete_badge", + .handler = _handler_delete_badge, + }, + { + .cmd = "set_badge_count", + .handler = _handler_set_badge_count, + }, + { + .cmd = "set_disp_option", + .handler = _handler_set_display_option, + }, + { + .cmd = "service_register", + .handler = _handler_service_register, + }, + { + .cmd = NULL, + .handler = NULL, + }, + }; + + DbgPrint("TCB: %p, Packet: %p\n", tcb, packet); + + command = packet_command(packet); + if (!command) { + ErrPrint("Invalid command\n"); + return -EINVAL; + } + DbgPrint("Command: %s, Packet type[%d]\n", command, packet_type(packet)); + + switch (packet_type(packet)) { + case PACKET_REQ: + /* Need to send reply packet */ + DbgPrint("REQ: Command: [%s]\n", command); + + for (i = 0; service_req_table[i].cmd; i++) { + if (strcmp(service_req_table[i].cmd, command)) + continue; + + service_req_table[i].handler(tcb, packet, data); + break; + } + + break; + case PACKET_REQ_NOACK: + break; + case PACKET_ACK: + break; + default: + ErrPrint("Packet type is not valid[%s]\n", command); + return -EINVAL; + } + + /*! + * return value has no meanning, + * it will be printed by dlogutil. + */ + return 0; +} + + +/*! + * MAIN THREAD + * Do not try to do anyother operation in these functions + */ +HAPI int badge_service_init(void) +{ + if (s_info.svc_ctx) { + ErrPrint("Already initialized\n"); + return LB_STATUS_ERROR_ALREADY; + } + + s_info.svc_ctx = service_common_create(BADGE_ADDR, service_thread_main, NULL); + if (!s_info.svc_ctx) { + ErrPrint("Unable to activate service thread\n"); + return LB_STATUS_ERROR_FAULT; + } + + DbgPrint("Successfully initiated\n"); + return LB_STATUS_SUCCESS; +} + +HAPI int badge_service_fini(void) +{ + if (!s_info.svc_ctx) + return LB_STATUS_ERROR_INVALID; + + service_common_destroy(s_info.svc_ctx); + DbgPrint("Successfully Finalized\n"); + return LB_STATUS_SUCCESS; +} + +/* End of a file */ diff --git a/src/buffer_handler.c b/src/buffer_handler.c index 1721e86..7da0214 100644 --- a/src/buffer_handler.c +++ b/src/buffer_handler.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * @@ -1026,13 +1026,14 @@ HAPI int buffer_handler_pixmap_unref(void *buffer_ptr) s_info.pixmap_list = eina_list_remove(s_info.pixmap_list, buffer); + info = buffer->info; + if (destroy_gem(buffer) < 0) ErrPrint("Failed to destroy gem buffer\n"); if (destroy_pixmap(buffer) < 0) ErrPrint("Failed to destroy pixmap\n"); - info = buffer->info; if (info && info->buffer == buffer) info->buffer = NULL; diff --git a/src/client_life.c b/src/client_life.c index af8302d..d30417a 100644 --- a/src/client_life.c +++ b/src/client_life.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/src/client_rpc.c b/src/client_rpc.c index d87659f..78ca437 100644 --- a/src/client_rpc.c +++ b/src/client_rpc.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/src/critical_log.c b/src/critical_log.c index 38ad835..e4da632 100644 --- a/src/critical_log.c +++ b/src/critical_log.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * @@ -87,6 +87,7 @@ HAPI int critical_log(const char *func, int line, const char *fmt, ...) return LB_STATUS_ERROR_IO; if (gettimeofday(&tv, NULL) < 0) { + ErrPrint("gettimeofday: %s\n", strerror(errno)); tv.tv_sec = 0; tv.tv_usec = 0; } diff --git a/src/dead_monitor.c b/src/dead_monitor.c index 91e3a23..733abdf 100644 --- a/src/dead_monitor.c +++ b/src/dead_monitor.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/src/event.c b/src/event.c index 89c4e34..39ff21d 100644 --- a/src/event.c +++ b/src/event.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/src/fault_manager.c b/src/fault_manager.c index 837bd17..6ece35e 100644 --- a/src/fault_manager.c +++ b/src/fault_manager.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/src/group.c b/src/group.c index 0adae6a..61c9833 100644 --- a/src/group.c +++ b/src/group.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/src/instance.c b/src/instance.c index db4ab42..32d18cc 100644 --- a/src/instance.c +++ b/src/instance.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * @@ -184,7 +184,11 @@ static inline void timer_freeze(struct inst_info *inst) if (ecore_timer_interval_get(inst->update_timer) <= 1.0f) return; - gettimeofday(&tv, NULL); + if (gettimeofday(&tv, NULL) < 0) { + ErrPrint("gettimeofday: %s\n", strerror(errno)); + tv.tv_sec = 0; + tv.tv_usec = 0; + } inst->sleep_at = (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f; } @@ -682,7 +686,7 @@ static inline int fork_package(struct inst_info *inst, const char *pkgname) snprintf(inst->id, len, SCHEMA_FILE "%s%s_%d_%lf.png", IMAGE_PATH, package_name(info), client_pid(inst->client), inst->timestamp); inst->lb.auto_launch = package_auto_launch(info); - instance_set_pd_info(inst, package_pd_width(info), package_pd_height(info)); + instance_set_pd_size(inst, package_pd_width(info), package_pd_height(info)); inst->lb.timeout = package_timeout(info); inst->lb.period = package_period(info); @@ -1149,7 +1153,8 @@ static void activate_cb(struct slave_node *slave, const struct packet *packet, v * just increase the loaded instance counter * And then reset jobs. */ - instance_set_lb_info(inst, w, h, priority, content, title); + instance_set_lb_size(inst, w, h); + instance_set_lb_info(inst, priority, content, title); inst->state = INST_ACTIVATED; @@ -1185,7 +1190,7 @@ static void activate_cb(struct slave_node *slave, const struct packet *packet, v if (package_pd_type(inst->info) == PD_TYPE_SCRIPT) { if (inst->pd.width == 0 && inst->pd.height == 0) - instance_set_pd_info(inst, package_pd_width(inst->info), package_pd_height(inst->info)); + instance_set_pd_size(inst, package_pd_width(inst->info), package_pd_height(inst->info)); inst->pd.canvas.script = script_handler_create(inst, package_pd_path(inst->info), @@ -1220,7 +1225,7 @@ out: HAPI int instance_create_pd_buffer(struct inst_info *inst) { if (inst->pd.width == 0 && inst->pd.height == 0) - instance_set_pd_info(inst, package_pd_width(inst->info), package_pd_height(inst->info)); + instance_set_pd_size(inst, package_pd_width(inst->info), package_pd_height(inst->info)); if (!inst->pd.canvas.buffer) { inst->pd.canvas.buffer = buffer_handler_create(inst, s_info.env_buf_type, inst->pd.width, inst->pd.height, sizeof(int)); @@ -1854,7 +1859,7 @@ HAPI int instance_active_update(struct inst_info *inst) return inst->active_update; } -HAPI void instance_set_lb_info(struct inst_info *inst, int w, int h, double priority, const char *content, const char *title) +HAPI void instance_set_lb_info(struct inst_info *inst, double priority, const char *content, const char *title) { char *_content = NULL; char *_title = NULL; @@ -1883,7 +1888,10 @@ HAPI void instance_set_lb_info(struct inst_info *inst, int w, int h, double prio if (priority >= 0.0f && priority <= 1.0f) inst->lb.priority = priority; +} +HAPI void instance_set_lb_size(struct inst_info *inst, int w, int h) +{ if (inst->lb.width != w || inst->lb.height != h) instance_send_resized_event(inst, IS_LB, w, h, LB_STATUS_SUCCESS); @@ -1891,7 +1899,7 @@ HAPI void instance_set_lb_info(struct inst_info *inst, int w, int h, double prio inst->lb.height = h; } -HAPI void instance_set_pd_info(struct inst_info *inst, int w, int h) +HAPI void instance_set_pd_size(struct inst_info *inst, int w, int h) { if (inst->pd.width != w || inst->pd.height != h) instance_send_resized_event(inst, IS_PD, w, h, LB_STATUS_SUCCESS); @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/src/liveinfo.c b/src/liveinfo.c index d280fa3..3f76531 100644 --- a/src/liveinfo.c +++ b/src/liveinfo.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * @@ -52,6 +52,8 @@ #include "critical_log.h" #include "event.h" #include "shortcut_service.h" +#include "notification_service.h" +#include "badge_service.h" #if defined(FLOG) FILE *__file_log_fp; @@ -241,6 +243,8 @@ int main(int argc, char *argv[]) (void)util_unlink_files(SLAVE_LOG_PATH); shortcut_service_init(); + notification_service_init(); + badge_service_init(); script_init(); app_create(); @@ -252,6 +256,8 @@ int main(int argc, char *argv[]) app_terminate(); script_fini(); + badge_service_fini(); + notification_service_fini(); shortcut_service_fini(); ecore_evas_shutdown(); diff --git a/src/notification_service.c b/src/notification_service.c index 94fb941..2c2bcea 100644 --- a/src/notification_service.c +++ b/src/notification_service.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * @@ -13,4 +13,390 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include <stdio.h> +#include <Eina.h> + +#include <dlog.h> +#include <livebox-errno.h> +#include <packet.h> + +#include <notification_ipc.h> +#include <notification_noti.h> +#include <notification_error.h> + +#include "service_common.h" +#include "debug.h" +#include "util.h" +#include "conf.h" + +#ifndef NOTIFICATION_ADDR +#define NOTIFICATION_ADDR "/tmp/.notification.service" +#endif + +#ifndef NOTIFICATION_DEL_PACKET_UNIT +#define NOTIFICATION_DEL_PACKET_UNIT 10 +#endif + +static struct info { + Eina_List *context_list; + struct service_context *svc_ctx; +} s_info = { + .context_list = NULL, /*!< \WARN: This is only used for SERVICE THREAD */ + .svc_ctx = NULL, /*!< \WARN: This is only used for MAIN THREAD */ +}; + +struct context { + struct tcb *tcb; + double seq; +}; + +struct noti_service { + const char *cmd; + void (*handler)(struct tcb *tcb, struct packet *packet, void *data); +}; + +/*! + * FUNCTIONS to handle notifcation + */ +static inline int get_priv_id(int num_deleted, int *list_deleted, int index) { + if (index < num_deleted) { + return *(list_deleted + index); + } else { + return -1; + } +} + +static inline char *get_string(char *string) +{ + if (string == NULL) { + return NULL; + } + if (string[0] == '\0') { + return NULL; + } + + return string; +} + +static inline struct packet *create_packet_from_deleted_list(int op_num, int *list, int start_index) { + return packet_create( + "del_noti_multiple", + "iiiiiiiiiii", + ((op_num - start_index) > NOTIFICATION_DEL_PACKET_UNIT) ? NOTIFICATION_DEL_PACKET_UNIT : op_num - start_index, + get_priv_id(op_num, list, start_index), + get_priv_id(op_num, list, start_index + 1), + get_priv_id(op_num, list, start_index + 2), + get_priv_id(op_num, list, start_index + 3), + get_priv_id(op_num, list, start_index + 4), + get_priv_id(op_num, list, start_index + 5), + get_priv_id(op_num, list, start_index + 6), + get_priv_id(op_num, list, start_index + 7), + get_priv_id(op_num, list, start_index + 8), + get_priv_id(op_num, list, start_index + 9) + ); +} + +/*! + * SERVICE HANDLER + */ +static void _handler_insert(struct tcb *tcb, struct packet *packet, void *data) +{ + int ret = 0; + int priv_id = 0; + struct packet *packet_reply = NULL; + struct packet *packet_service = NULL; + notification_h noti = NULL; + + noti = notification_create(NOTIFICATION_TYPE_NOTI); + if (noti != NULL) { + if (notification_ipc_make_noti_from_packet(noti, packet) == NOTIFICATION_ERROR_NONE) { + ret = notification_noti_insert(noti); + if (ret != NOTIFICATION_ERROR_NONE) { + ErrPrint("failed to insert a notification\n"); + notification_free(noti); + return ; + } + + notification_get_id(noti, NULL, &priv_id); + DbgPrint("priv_id: [%d]\n", priv_id); + packet_reply = packet_create_reply(packet, "ii", ret, priv_id); + if (packet_reply) { + service_common_unicast_packet(tcb, packet_reply); + packet_destroy(packet_reply); + } + + packet_service = notification_ipc_make_packet_from_noti(noti, "add_noti", 2); + if (packet_service != NULL) { + service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE); + packet_destroy(packet_service); + } + } else { + ErrPrint("Failed to create the packet"); + } + notification_free(noti); + } +} + +static void _handler_update(struct tcb *tcb, struct packet *packet, void *data) +{ + int ret = 0; + int priv_id = 0; + struct packet *packet_reply = NULL; + struct packet *packet_service = NULL; + notification_h noti = NULL; + + noti = notification_create(NOTIFICATION_TYPE_NOTI); + if (noti != NULL) { + if (notification_ipc_make_noti_from_packet(noti, packet) == NOTIFICATION_ERROR_NONE) { + ret = notification_noti_update(noti); + if (ret != NOTIFICATION_ERROR_NONE) { + ErrPrint("failed to update a notification\n"); + notification_free(noti); + return ; + } + + notification_get_id(noti, NULL, &priv_id); + DbgPrint("priv_id: [%d]\n", priv_id); + packet_reply = packet_create_reply(packet, "ii", ret, priv_id); + if (packet_reply) { + service_common_unicast_packet(tcb, packet_reply); + packet_destroy(packet_reply); + } + + packet_service = notification_ipc_make_packet_from_noti(noti, "update_noti", 2); + if (packet_service != NULL) { + service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE); + packet_destroy(packet_service); + } + } else { + ErrPrint("Failed to create the packet"); + } + notification_free(noti); + } +} + +static void _handler_refresh(struct tcb *tcb, struct packet *packet, void *data) +{ + int ret = NOTIFICATION_ERROR_NONE; + struct packet *packet_reply = NULL; + + packet_reply = packet_create_reply(packet, "i", ret); + if (packet_reply) { + service_common_unicast_packet(tcb, packet_reply); + packet_destroy(packet_reply); + } + + service_common_multicast_packet(tcb, packet, TCB_CLIENT_TYPE_SERVICE); +} + +static void _handler_delete_single(struct tcb *tcb, struct packet *packet, void *data) +{ + int ret = 0; + int priv_id = 0; + struct packet *packet_reply = NULL; + struct packet *packet_service = NULL; + char *pkgname = NULL; + + if (packet_get(packet, "si", &pkgname, &priv_id) == 2) { + pkgname = get_string(pkgname); + + ret = notification_noti_delete_by_priv_id(pkgname, priv_id); + + DbgPrint("priv_id: [%d]\n", priv_id); + packet_reply = packet_create_reply(packet, "ii", ret, priv_id); + if (packet_reply) { + service_common_unicast_packet(tcb, packet_reply); + packet_destroy(packet_reply); + } + + packet_service = packet_create("del_noti_single", "ii", 1, priv_id); + if (packet_service != NULL) { + service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE); + packet_destroy(packet_service); + } + } else { + ErrPrint("Failed to get data from the packet"); + } +} + +static void _handler_delete_multiple(struct tcb *tcb, struct packet *packet, void *data) +{ + int ret = 0; + struct packet *packet_reply = NULL; + struct packet *packet_service = NULL; + char *pkgname = NULL; + notification_type_e type = 0; + int num_deleted = 0; + int *list_deleted = NULL; + + if (packet_get(packet, "si", &pkgname, &type) == 2) { + pkgname = get_string(pkgname); + DbgPrint("pkgname: [%s] type: [%d]\n", pkgname, type); + + ret = notification_noti_delete_all(type, pkgname, &num_deleted, &list_deleted); + DbgPrint("ret: [%d] num_deleted: [%d]\n", ret, num_deleted); + + packet_reply = packet_create_reply(packet, "ii", ret, num_deleted); + if (packet_reply) { + service_common_unicast_packet(tcb, packet_reply); + packet_destroy(packet_reply); + } + + if (num_deleted > 0) { + if (num_deleted <= NOTIFICATION_DEL_PACKET_UNIT) { + packet_service = create_packet_from_deleted_list(num_deleted, list_deleted, 0); + + if (packet_service) { + service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE); + packet_destroy(packet_service); + } + } else { + int set = 0; + int set_total = num_deleted / NOTIFICATION_DEL_PACKET_UNIT; + + for (set = 0; set <= set_total; set++) { + packet_service = create_packet_from_deleted_list(num_deleted, + list_deleted, set * NOTIFICATION_DEL_PACKET_UNIT); + + if (packet_service) { + service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE); + packet_destroy(packet_service); + } + } + } + } + + if (list_deleted != NULL) { + free(list_deleted); + list_deleted = NULL; + } + } else { + ErrPrint("Failed to get data from the packet"); + } +} + +static void _handler_service_register(struct tcb *tcb, struct packet *packet, void *data) +{ + struct packet *packet_reply; + int ret; + + ret = tcb_client_type_set(tcb, TCB_CLIENT_TYPE_SERVICE); + + packet_reply = packet_create_reply(packet, "i", ret); + if (packet_reply) { + service_common_unicast_packet(tcb, packet_reply); + packet_destroy(packet_reply); + } +} + +/*! + * SERVICE THREAD + */ +static int service_thread_main(struct tcb *tcb, struct packet *packet, void *data) +{ + int i = 0; + const char *command; + static struct noti_service service_req_table[] = { + { + .cmd = "add_noti", + .handler = _handler_insert, + }, + { + .cmd = "update_noti", + .handler = _handler_update, + }, + { + .cmd = "refresh_noti", + .handler = _handler_refresh, + }, + { + .cmd = "del_noti_single", + .handler = _handler_delete_single, + }, + { + .cmd = "del_noti_multiple", + .handler = _handler_delete_multiple, + }, + { + .cmd = "service_register", + .handler = _handler_service_register, + }, + { + .cmd = NULL, + .handler = NULL, + }, + }; + + DbgPrint("TCB: %p, Packet: %p\n", tcb, packet); + + command = packet_command(packet); + if (!command) { + ErrPrint("Invalid command\n"); + return -EINVAL; + } + DbgPrint("Command: %s, Packet type[%d]\n", command, packet_type(packet)); + + switch (packet_type(packet)) { + case PACKET_REQ: + /* Need to send reply packet */ + DbgPrint("REQ: Command: [%s]\n", command); + + for (i = 0; service_req_table[i].cmd; i++) { + if (strcmp(service_req_table[i].cmd, command)) + continue; + + service_req_table[i].handler(tcb, packet, data); + break; + } + + break; + case PACKET_REQ_NOACK: + break; + case PACKET_ACK: + break; + default: + ErrPrint("Packet type is not valid[%s]\n", command); + return -EINVAL; + } + + /*! + * return value has no meanning, + * it will be printed by dlogutil. + */ + return 0; +} + + +/*! + * MAIN THREAD + * Do not try to do anyother operation in these functions + */ +HAPI int notification_service_init(void) +{ + if (s_info.svc_ctx) { + ErrPrint("Already initialized\n"); + return LB_STATUS_ERROR_ALREADY; + } + + s_info.svc_ctx = service_common_create(NOTIFICATION_ADDR, service_thread_main, NULL); + if (!s_info.svc_ctx) { + ErrPrint("Unable to activate service thread\n"); + return LB_STATUS_ERROR_FAULT; + } + + DbgPrint("Successfully initiated\n"); + return LB_STATUS_SUCCESS; +} + +HAPI int notification_service_fini(void) +{ + if (!s_info.svc_ctx) + return LB_STATUS_ERROR_INVALID; + + service_common_destroy(s_info.svc_ctx); + DbgPrint("Successfully Finalized\n"); + return LB_STATUS_SUCCESS; +} + +/* End of a file */ diff --git a/src/package.c b/src/package.c index b0c62c1..188c170 100644 --- a/src/package.c +++ b/src/package.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/src/parser.c b/src/parser.c index 3a4f4c7..948aec8 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/src/pkgmgr.c b/src/pkgmgr.c index 2f65c13..49f0a86 100644 --- a/src/pkgmgr.c +++ b/src/pkgmgr.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/src/script_handler.c b/src/script_handler.c index 0b0e789..05d4b3a 100644 --- a/src/script_handler.c +++ b/src/script_handler.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * @@ -129,8 +129,12 @@ struct script_info { struct script_port *port; void *port_data; + + Eina_List *cached_blocks; }; +static inline void consuming_parsed_block(int lineno, struct inst_info *inst, int is_pd, struct block *block); + static inline struct script_port *find_port(const char *magic_id) { Eina_List *l; @@ -144,6 +148,18 @@ static inline struct script_port *find_port(const char *magic_id) return NULL; } +static inline void delete_block(struct block *block) +{ + DbgFree(block->file); + DbgFree(block->type); + DbgFree(block->part); + DbgFree(block->data); + DbgFree(block->option); + DbgFree(block->id); + DbgFree(block->target_id); + DbgFree(block); +} + static void render_pre_cb(void *data, Evas *e, void *event_info) { struct inst_info *inst = data; @@ -230,6 +246,15 @@ int script_signal_emit(Evas *e, const char *part, const char *signal, double sx, return ret; } +static inline void flushing_cached_block(struct script_info *info) +{ + struct block *block; + + EINA_LIST_FREE(info->cached_blocks, block) { + consuming_parsed_block(-1, info->inst, (instance_pd_script(info->inst) == info), block); + } +} + HAPI int script_handler_load(struct script_info *info, int is_pd) { int ret; @@ -270,6 +295,7 @@ HAPI int script_handler_load(struct script_info *info, int is_pd) return LB_STATUS_ERROR_FAULT; } info->loaded = 1; + flushing_cached_block(info); script_signal_emit(e, util_uri_to_path(instance_id(info->inst)), is_pd ? "pd,show" : "lb,show", 0.0f, 0.0f, 0.0f, 0.0f); } else { @@ -371,6 +397,7 @@ HAPI struct script_info *script_handler_create(struct inst_info *inst, const cha HAPI int script_handler_destroy(struct script_info *info) { + struct block *block; if (!info || !info->port) { ErrPrint("port is not valid\n"); return LB_STATUS_ERROR_INVALID; @@ -385,6 +412,10 @@ HAPI int script_handler_destroy(struct script_info *info) ErrPrint("Failed to destroy port, but go ahead\n"); fb_destroy(info->fb); + + EINA_LIST_FREE(info->cached_blocks, block) { + delete_block(block); + } DbgFree(info); return LB_STATUS_SUCCESS; } @@ -640,14 +671,12 @@ HAPI int script_handler_resize(struct script_info *info, int w, int h) ErrPrint("Evas(nil) resize to %dx%d\n", w, h); } - if (info->w != w || info->h != h) { - if (instance_lb_script(info->inst) == info) { - instance_set_lb_info(info->inst, w, h, PRIORITY_NO_CHANGE, CONTENT_NO_CHANGE, TITLE_NO_CHANGE); - } else if (instance_pd_script(info->inst) == info) { - instance_set_pd_info(info->inst, w, h); - } else { - ErrPrint("Script is not known\n"); - } + if (instance_lb_script(info->inst) == info) { + instance_set_lb_size(info->inst, w, h); + } else if (instance_pd_script(info->inst) == info) { + instance_set_pd_size(info->inst, w, h); + } else { + ErrPrint("Script is not known\n"); } info->w = w; @@ -706,43 +735,14 @@ static int update_info(struct inst_info *inst, struct block *block, int is_pd) return LB_STATUS_SUCCESS; } -HAPI int script_handler_parse_desc(const char *pkgname, const char *id, const char *descfile, int is_pd) +static inline void consuming_parsed_block(int lineno, struct inst_info *inst, int is_pd, struct block *block) { - struct inst_info *inst; - FILE *fp; - int ch; - int lineno; - enum state { - UNKNOWN = 0x10, - BLOCK_OPEN = 0x11, - FIELD = 0x12, - VALUE = 0x13, - BLOCK_CLOSE = 0x14, - - VALUE_TYPE = 0x00, - VALUE_PART = 0x01, - VALUE_DATA = 0x02, - VALUE_FILE = 0x03, - VALUE_OPTION = 0x04, - VALUE_ID = 0x05, - VALUE_TARGET = 0x06, - }; - const char *field_name[] = { - "type", - "part", - "data", - "file", - "option", - "id", - "target", - NULL - }; - enum state state; - register int field_idx; - register int idx = 0; - register int i; - struct block *block; - struct { + struct script_info *info; + /*! + * To speed up, use the static. + * But this will increase the memory slightly. + */ + static struct { const char *type; int (*handler)(struct inst_info *inst, struct block *block, int is_pd); } handlers[] = { @@ -784,6 +784,74 @@ HAPI int script_handler_parse_desc(const char *pkgname, const char *id, const ch }, }; + info = is_pd ? instance_pd_script(inst) : instance_lb_script(inst); + if (!info) { + ErrPrint("info is NIL (%d, %s)\n", is_pd, instance_id(inst)); + goto free_out; + } + + if (script_handler_is_loaded(info)) { + register int i = 0; + + while (handlers[i].type) { + if (!strcasecmp(handlers[i].type, block->type)) { + handlers[i].handler(inst, block, is_pd); + break; + } + i++; + } + + if (!handlers[i].type) + ErrPrint("%d: Unknown block type: %s\n", lineno, block->type); + + goto free_out; + } else { + info->cached_blocks = eina_list_append(info->cached_blocks, block); + DbgPrint("%d: Block is cached (%p), %d, %s\n", lineno, block, eina_list_count(info->cached_blocks), instance_id(inst)); + } + + return; + +free_out: + delete_block(block); +} + +HAPI int script_handler_parse_desc(const char *pkgname, const char *id, const char *descfile, int is_pd) +{ + struct inst_info *inst; + FILE *fp; + int ch; + int lineno; + enum state { + UNKNOWN = 0x10, + BLOCK_OPEN = 0x11, + FIELD = 0x12, + VALUE = 0x13, + BLOCK_CLOSE = 0x14, + + VALUE_TYPE = 0x00, + VALUE_PART = 0x01, + VALUE_DATA = 0x02, + VALUE_FILE = 0x03, + VALUE_OPTION = 0x04, + VALUE_ID = 0x05, + VALUE_TARGET = 0x06, + }; + const char *field_name[] = { + "type", + "part", + "data", + "file", + "option", + "id", + "target", + NULL + }; + enum state state; + register int field_idx; + register int idx = 0; + struct block *block; + block = NULL; inst = package_find_instance_by_id(pkgname, id); if (!inst) { @@ -797,6 +865,8 @@ HAPI int script_handler_parse_desc(const char *pkgname, const char *id, const ch return LB_STATUS_ERROR_IO; } + DbgPrint("Parsing %s\n", descfile); + state = UNKNOWN; field_idx = 0; lineno = 1; @@ -1127,28 +1197,7 @@ HAPI int script_handler_parse_desc(const char *pkgname, const char *id, const ch } } - i = 0; - while (handlers[i].type) { - if (!strcasecmp(handlers[i].type, block->type)) { - handlers[i].handler(inst, block, is_pd); - break; - } - i++; - } - - if (!handlers[i].type) - ErrPrint("%d: Unknown block type: %s\n", lineno, block->type); - - DbgFree(block->file); - DbgFree(block->type); - DbgFree(block->part); - DbgFree(block->data); - DbgFree(block->option); - DbgFree(block->id); - DbgFree(block->target_id); - DbgFree(block); - block = NULL; - + consuming_parsed_block(lineno, inst, is_pd, block); state = UNKNOWN; break; @@ -1167,16 +1216,8 @@ HAPI int script_handler_parse_desc(const char *pkgname, const char *id, const ch errout: ErrPrint("Parse error at %d file %s\n", lineno, util_basename(descfile)); - if (block) { - DbgFree(block->file); - DbgFree(block->type); - DbgFree(block->part); - DbgFree(block->data); - DbgFree(block->option); - DbgFree(block->id); - DbgFree(block->target_id); - DbgFree(block); - } + if (block) + delete_block(block); fclose(fp); return LB_STATUS_ERROR_INVALID; } diff --git a/src/server.c b/src/server.c index 27d4bbd..fea14c9 100644 --- a/src/server.c +++ b/src/server.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * @@ -674,9 +674,6 @@ static struct packet *client_new(pid_t pid, int handle, const struct packet *pac if (period > 0.0f && period < MINIMUM_PERIOD) period = MINIMUM_PERIOD; - if (!strlen(content)) - content = DEFAULT_CONTENT; - inst = instance_create(client, timestamp, lb_pkgname, content, cluster, category, period, width, height); /*! * \note @@ -2245,7 +2242,7 @@ out: return NULL; } -static struct packet *client_pd_access_value_change(pid_t pid, int handle, const struct packet *packet) +static struct packet *client_pd_access_action_up(pid_t pid, int handle, const struct packet *packet) { struct packet *result; struct client_node *client; @@ -2345,8 +2342,142 @@ static struct packet *client_pd_access_value_change(pid_t pid, int handle, const goto out; } - script_handler_update_pointer(script, x, y, -1); - ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_VALUE_CHANGE, timestamp); + script_handler_update_pointer(script, x, y, 0); + ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp); + if (ret >= 0) { + struct access_cbdata *cbdata; + + cbdata = malloc(sizeof(*cbdata)); + if (!cbdata) { + ret = LB_STATUS_ERROR_MEMORY; + } else { + cbdata->inst = instance_ref(inst); + cbdata->status = ret; + + if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) { + instance_unref(cbdata->inst); + free(cbdata); + ret = LB_STATUS_ERROR_FAULT; + } else { + ret = LB_STATUS_SUCCESS; + } + } + } + } else { + ErrPrint("Unsupported package\n"); + ret = LB_STATUS_ERROR_INVALID; + } + +out: + result = packet_create_reply(packet, "i", ret); + if (!result) + ErrPrint("Failed to create a reply packet\n"); + + return result; +} + +static struct packet *client_pd_access_action_down(pid_t pid, int handle, const struct packet *packet) +{ + struct packet *result; + struct client_node *client; + const char *pkgname; + const char *id; + int ret; + double timestamp; + int x; + int y; + struct inst_info *inst; + const struct pkg_info *pkg; + + client = client_find_by_pid(pid); + if (!client) { + ErrPrint("Client %d is not exists\n", pid); + ret = LB_STATUS_ERROR_NOT_EXIST; + goto out; + } + + ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y); + if (ret != 5) { + ErrPrint("Invalid parameter\n"); + ret = LB_STATUS_ERROR_INVALID; + goto out; + } + + /*! + * \NOTE: + * Trust the package name which are sent by the client. + * The package has to be a livebox package name. + */ + inst = package_find_instance_by_id(pkgname, id); + if (!inst) { + ErrPrint("Instance[%s] is not exists\n", id); + ret = LB_STATUS_ERROR_NOT_EXIST; + goto out; + } + + pkg = instance_package(inst); + if (!pkg) { + ErrPrint("Package[%s] info is not found\n", pkgname); + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + + if (package_is_fault(pkg)) { + /*! + * \note + * If the package is registered as fault module, + * slave has not load it, so we don't need to do anything at here! + */ + DbgPrint("Package[%s] is faulted\n", pkgname); + ret = LB_STATUS_ERROR_FAULT; + } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) { + struct buffer_info *buffer; + struct slave_node *slave; + // struct packet *packet; + + buffer = instance_pd_buffer(inst); + if (!buffer) { + ErrPrint("Instance[%s] has no buffer\n", id); + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + + slave = package_slave(pkg); + if (!slave) { + ErrPrint("Package[%s] has no slave\n", pkgname); + ret = LB_STATUS_ERROR_INVALID; + goto out; + } + + /* + packet = packet_create_noack("pd_mouse_enter", "ssiiddd", pkgname, id, w, h, timestamp, x, y); + if (!packet) { + ErrPrint("Failed to create a packet[%s]\n", pkgname); + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + */ + + packet_ref((struct packet *)packet); + ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0); + } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) { + struct script_info *script; + Evas *e; + + script = instance_pd_script(inst); + if (!script) { + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + + e = script_handler_evas(script); + if (!e) { + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + + script_handler_update_pointer(script, x, y, 1); + ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp); if (ret >= 0) { struct access_cbdata *cbdata; @@ -4135,7 +4266,7 @@ out: return result; } -static struct packet *client_lb_access_value_change(pid_t pid, int handle, const struct packet *packet) +static struct packet *client_lb_access_action_up(pid_t pid, int handle, const struct packet *packet) { struct packet *result; struct client_node *client; @@ -4221,8 +4352,128 @@ static struct packet *client_lb_access_value_change(pid_t pid, int handle, const goto out; } - script_handler_update_pointer(script, x, y, -1); - ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_VALUE_CHANGE, timestamp); + script_handler_update_pointer(script, x, y, 0); + ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp); + if (ret >= 0) { + struct access_cbdata *cbdata; + + cbdata = malloc(sizeof(*cbdata)); + if (!cbdata) { + ret = LB_STATUS_ERROR_MEMORY; + } else { + cbdata->inst = instance_ref(inst); + cbdata->status = ret; + + if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) { + instance_unref(cbdata->inst); + free(cbdata); + ret = LB_STATUS_ERROR_FAULT; + } else { + ret = LB_STATUS_SUCCESS; + } + } + } + } else { + ErrPrint("Unsupported package\n"); + ret = LB_STATUS_ERROR_INVALID; + } + +out: + result = packet_create_reply(packet, "i", ret); + if (!result) + ErrPrint("Failed to create a reply packet\n"); + + return result; +} + +static struct packet *client_lb_access_action_down(pid_t pid, int handle, const struct packet *packet) +{ + struct packet *result; + struct client_node *client; + const char *pkgname; + const char *id; + int ret; + double timestamp; + struct inst_info *inst; + const struct pkg_info *pkg; + int x; + int y; + + client = client_find_by_pid(pid); + if (!client) { + ErrPrint("Client %d is not exist\n", pid); + ret = LB_STATUS_ERROR_NOT_EXIST; + goto out; + } + + ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y); + if (ret != 5) { + ErrPrint("Parameter is not matched\n"); + ret = LB_STATUS_ERROR_INVALID; + goto out; + } + + inst = package_find_instance_by_id(pkgname, id); + if (!inst) { + ErrPrint("Instance[%s] is not exists\n", id); + ret = LB_STATUS_ERROR_NOT_EXIST; + goto out; + } + + pkg = instance_package(inst); + if (!pkg) { + ErrPrint("Package[%s] info is not exists\n", pkgname); + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + + if (package_is_fault(pkg)) { + ret = LB_STATUS_ERROR_FAULT; + } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) { + struct buffer_info *buffer; + struct slave_node *slave; + + buffer = instance_lb_buffer(inst); + if (!buffer) { + ErrPrint("Instance[%s] has no buffer\n", id); + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + + slave = package_slave(pkg); + if (!slave) { + ErrPrint("Slave is not exists\n"); + ret = LB_STATUS_ERROR_INVALID; + goto out; + } + + packet_ref((struct packet *)packet); + ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0); + /*! + * Enen if it fails to send packet, + * The packet will be unref'd + * So we don't need to check the ret value. + */ + } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) { + struct script_info *script; + Evas *e; + + script = instance_lb_script(inst); + if (!script) { + ErrPrint("Instance has no script\n"); + ret = LB_STATUS_ERROR_FAULT; + goto out; + } + + e = script_handler_evas(script); + if (!e) { + ErrPrint("Script has no evas\n"); + ret = LB_STATUS_ERROR_INVALID; + goto out; + } + + script_handler_update_pointer(script, x, y, 1); + ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp); if (ret >= 0) { struct access_cbdata *cbdata; @@ -5823,7 +6074,7 @@ static inline int update_pkg_cb(struct category *category, const char *pkgname) * Because this callback is called by the requests of clients. * It means. some clients wants to handle this instances ;) */ - inst = instance_create(NULL, timestamp, pkgname, DEFAULT_CONTENT, c_name, s_name, DEFAULT_PERIOD, 0, 0); + inst = instance_create(NULL, timestamp, pkgname, "", c_name, s_name, DEFAULT_PERIOD, 0, 0); if (!inst) ErrPrint("Failed to create a new instance\n"); } else { @@ -6448,6 +6699,8 @@ static struct packet *slave_updated(pid_t pid, int handle, const struct packet * } else { char *filename; + instance_set_lb_info(inst, priority, content_info, title); + switch (package_lb_type(instance_package(inst))) { case LB_TYPE_SCRIPT: script_handler_resize(instance_lb_script(inst), w, h); @@ -6467,7 +6720,7 @@ static struct packet *slave_updated(pid_t pid, int handle, const struct packet * * \check * text format (inst) */ - instance_set_lb_info(inst, w, h, priority, content_info, title); + instance_set_lb_size(inst, w, h); instance_lb_updated_by_instance(inst); break; } @@ -6552,7 +6805,7 @@ static struct packet *slave_desc_updated(pid_t pid, int handle, const struct pac } break; case PD_TYPE_TEXT: - instance_set_pd_info(inst, 0, 0); + instance_set_pd_size(inst, 0, 0); case PD_TYPE_BUFFER: instance_pd_updated(pkgname, id, descfile); break; @@ -6675,7 +6928,8 @@ static struct packet *slave_acquire_buffer(pid_t pid, int handle, const struct p ret = buffer_handler_load(info); if (ret == 0) { - instance_set_lb_info(inst, w, h, PRIORITY_NO_CHANGE, CONTENT_NO_CHANGE, TITLE_NO_CHANGE); + instance_set_lb_size(inst, w, h); + instance_set_lb_info(inst, PRIORITY_NO_CHANGE, CONTENT_NO_CHANGE, TITLE_NO_CHANGE); id = buffer_handler_id(info); DbgPrint("Buffer handler ID: %s\n", id); } else { @@ -6709,7 +6963,7 @@ static struct packet *slave_acquire_buffer(pid_t pid, int handle, const struct p ret = buffer_handler_load(info); if (ret == 0) { - instance_set_pd_info(inst, w, h); + instance_set_pd_size(inst, w, h); id = buffer_handler_id(info); DbgPrint("Buffer handler ID: %s\n", id); } else { @@ -6806,7 +7060,8 @@ static struct packet *slave_resize_buffer(pid_t pid, int handle, const struct pa */ if (!ret) { id = buffer_handler_id(info); - instance_set_lb_info(inst, w, h, PRIORITY_NO_CHANGE, CONTENT_NO_CHANGE, TITLE_NO_CHANGE); + instance_set_lb_size(inst, w, h); + instance_set_lb_info(inst, PRIORITY_NO_CHANGE, CONTENT_NO_CHANGE, TITLE_NO_CHANGE); } } } @@ -6823,7 +7078,7 @@ static struct packet *slave_resize_buffer(pid_t pid, int handle, const struct pa */ if (!ret) { id = buffer_handler_id(info); - instance_set_pd_info(inst, w, h); + instance_set_pd_size(inst, w, h); } } } @@ -7535,8 +7790,12 @@ static struct method s_client_table[] = { .handler = client_pd_access_activate, }, { - .cmd = "pd_access_value_change", - .handler = client_pd_access_value_change, + .cmd = "pd_access_action_up", + .handler = client_pd_access_action_up, + }, + { + .cmd = "pd_access_action_down", + .handler = client_pd_access_action_down, }, { .cmd = "pd_access_unhighlight", @@ -7572,8 +7831,12 @@ static struct method s_client_table[] = { .handler = client_lb_access_activate, }, { - .cmd = "lb_access_value_change", - .handler = client_lb_access_value_change, + .cmd = "lb_access_action_up", + .handler = client_lb_access_action_up, + }, + { + .cmd = "lb_access_action_down", + .handler = client_lb_access_action_down, }, { .cmd = "lb_access_unhighlight", diff --git a/src/service_common.c b/src/service_common.c index cd2f1e2..6a32976 100644 --- a/src/service_common.c +++ b/src/service_common.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * @@ -395,8 +395,6 @@ static void *server_main(void *data) struct tcb *tcb; int fd; char evt_ch; - Eina_List *l; - Eina_List *n; struct packet_info *packet_info; DbgPrint("Server thread is activated\n"); @@ -497,10 +495,9 @@ static void *server_main(void *data) * This only should be happenes while terminating the master daemon process. */ CRITICAL_SECTION_BEGIN(&svc_ctx->packet_list_lock); - EINA_LIST_FOREACH_SAFE(svc_ctx->packet_list, l, n, packet_info) { + EINA_LIST_FREE(svc_ctx->packet_list, packet_info) { ret = read(svc_ctx->evt_pipe[PIPE_READ], &evt_ch, sizeof(evt_ch)); DbgPrint("Flushing pipe: %d (%c)\n", ret, evt_ch); - svc_ctx->packet_list = eina_list_remove(svc_ctx->packet_list, packet_info); ret = svc_ctx->service_thread_main(packet_info->tcb, packet_info->packet, svc_ctx->service_thread_data); if (ret < 0) ErrPrint("Service thread returns: %d\n", ret); diff --git a/src/setting.c b/src/setting.c index c013a22..94b103a 100644 --- a/src/setting.c +++ b/src/setting.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/src/shortcut_service.c b/src/shortcut_service.c index f2339a1..73e6999 100644 --- a/src/shortcut_service.c +++ b/src/shortcut_service.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/src/slave_life.c b/src/slave_life.c index eac009d..5d7dbf3 100644 --- a/src/slave_life.c +++ b/src/slave_life.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * @@ -509,8 +509,11 @@ HAPI int slave_activated(struct slave_node *slave) slave_set_reactivation(slave, 0); slave_set_reactivate_instances(slave, 0); - if (gettimeofday(&slave->activated_at, NULL) < 0) + if (gettimeofday(&slave->activated_at, NULL) < 0) { ErrPrint("Failed to get time of day: %s\n", strerror(errno)); + slave->activated_at.tv_sec = 0; + slave->activated_at.tv_usec = 0; + } if (slave->activate_timer) { ecore_timer_del(slave->activate_timer); diff --git a/src/slave_rpc.c b/src/slave_rpc.c index 570852e..edd6bba 100644 --- a/src/slave_rpc.c +++ b/src/slave_rpc.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * @@ -20,7 +20,7 @@ #include <errno.h> #include <unistd.h> #include <stdlib.h> -#include <sys/statvfs.h> +#include <sys/vfs.h> #include <sys/types.h> #include <dirent.h> #include <ctype.h> @@ -191,18 +191,21 @@ HAPI const char *util_basename(const char *name) return length <= 0 ? name : (name + length + (name[length] == '/')); } -HAPI unsigned long util_free_space(const char *path) +/*! + * Return size of stroage in MegaBytes unit. + */ +HAPI unsigned long long util_free_space(const char *path) { - struct statvfs st; - unsigned long space; + struct statfs st; + unsigned long long space; - if (statvfs(path, &st) < 0) { + if (statfs(path, &st) < 0) { ErrPrint("statvfs: %s\n", strerror(errno)); return 0lu; } - space = st.f_bsize * st.f_bfree; - DbgPrint("Available size: %lu, f_bsize: %lu, f_bfree: %lu\n", space, st.f_bsize, st.f_bfree); + space = (unsigned long long)st.f_bsize * (unsigned long long)st.f_bavail; + DbgPrint("Available size: %llu, f_bsize: %lu, f_bavail: %lu\n", space, st.f_bsize, st.f_bavail); /*! * \note * Must have to check the overflow @@ -348,23 +351,29 @@ HAPI double util_time_delay_for_compensation(double period) unsigned long long curtime; unsigned long long _period; unsigned long long remain; - unsigned int sec; - unsigned int usec; double ret; - gettimeofday(&tv, NULL); - curtime = (unsigned long long)tv.tv_sec * 1000000llu + (unsigned long long)tv.tv_usec; + if (period == 0.0f) { + DbgPrint("Period is ZERO\n"); + return 0.0f; + } + + if (gettimeofday(&tv, NULL) < 0){ + ErrPrint("gettimeofday: %s\n", strerror(errno)); + return period; + } - sec = (unsigned int)period; - usec = (period - sec) * 1000000; - _period = (unsigned long long)sec * 1000000llu + usec; + curtime = (unsigned long long)tv.tv_sec * 1000000llu + (unsigned long long)tv.tv_usec; + _period = (unsigned long long)(period * (double)1000000); + if (_period == 0llu) { + ErrPrint("%lf <> %llu\n", period, _period); + return period; + } remain = curtime % _period; - sec = (unsigned int)(remain / 1000000llu); - usec = (unsigned int)(remain % 1000000llu); - - ret = (double)sec + (double)usec / 1000000.0f; + ret = (double)remain / (double)1000000; + DbgPrint("curtime: %llu, _period: %llu, remain: %llu, ret: %lf, result: %lf\n", curtime, _period, remain, ret, period - ret); return period - ret; } diff --git a/src/xmonitor.c b/src/xmonitor.c index 039973b..e687959 100644 --- a/src/xmonitor.c +++ b/src/xmonitor.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/util_liveinfo/include/liveinfo.h b/util_liveinfo/include/liveinfo.h index 94fb941..67a71d8 100644 --- a/util_liveinfo/include/liveinfo.h +++ b/util_liveinfo/include/liveinfo.h @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * diff --git a/util_liveinfo/src/liveinfo.c b/util_liveinfo/src/liveinfo.c index bd2dccf..a44a9f7 100644 --- a/util_liveinfo/src/liveinfo.c +++ b/util_liveinfo/src/liveinfo.c @@ -1,7 +1,7 @@ /* * Copyright 2013 Samsung Electronics Co., Ltd * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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 * |