summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSung-jae Park <nicesj.park@samsung.com>2013-04-30 21:32:41 +0900
committerSung-jae Park <nicesj.park@samsung.com>2013-05-01 17:29:51 +0900
commitaf70aa83ac19764fb9f5a188b461329d97da1db0 (patch)
treec185bbc36b06247c6366d2535b373aaadfb3d9df /src
parent8d696f93e7277360f437264a21f5c97d20d759b3 (diff)
downloaddata-provider-master-af70aa83ac19764fb9f5a188b461329d97da1db0.tar.gz
data-provider-master-af70aa83ac19764fb9f5a188b461329d97da1db0.tar.bz2
data-provider-master-af70aa83ac19764fb9f5a188b461329d97da1db0.zip
Various patches are applied
Patch 9/9 Fix the bug of ignoring updated content info. Even if the box tries to update its content info, in case of script type box, the provider ignores it. This patch will fix it. Patch 8/9 Use the break after handling the service request (badge/noti) Patch 7/9 Using EINA_LIST_FREE instead of EINA_LIST_FOREACH_SAFE. To release the svc_ctx->packet_list. Patch 6/9 Keep the desc block even if the buffer of lb is not ready. Keep the desc blocks even if the buffer of livebox is not created. The provider will send the created event to the slave. Then the slave will start to generate the desc file. (script data) But the provider cannot apply desc to its buffer. Because there is no created object. To resolve this issue, This patch will create a cache. It will be used for keeping the blocks which are parsed before creating a buffer of livebox (or PD). Patch 5/9 Update License Patch 4/9 Enable Badge/Notification service. Patch 3/9 Don't set the "default" to content as default value. Client can use "" for its content value. So the provider has not to touch the "content". Patch 2/9 Update period compensation timer. Patch 1/9 Fix the storage size calculation bug. Change-Id: Ia6f0d5e0fe06ed9a348082d324b09cc7732041e7
Diffstat (limited to 'src')
-rw-r--r--src/abi.c2
-rw-r--r--src/badge_service.c328
-rw-r--r--src/buffer_handler.c5
-rw-r--r--src/client_life.c2
-rw-r--r--src/client_rpc.c2
-rw-r--r--src/conf.c2
-rw-r--r--src/critical_log.c3
-rw-r--r--src/dead_monitor.c2
-rw-r--r--src/event.c2
-rw-r--r--src/fault_manager.c2
-rw-r--r--src/fb.c2
-rw-r--r--src/group.c2
-rw-r--r--src/instance.c24
-rw-r--r--src/io.c2
-rw-r--r--src/liveinfo.c2
-rw-r--r--src/main.c8
-rw-r--r--src/notification_service.c388
-rw-r--r--src/package.c2
-rw-r--r--src/parser.c2
-rw-r--r--src/pkgmgr.c2
-rw-r--r--src/script_handler.c195
-rw-r--r--src/server.c305
-rw-r--r--src/service_common.c7
-rw-r--r--src/setting.c2
-rw-r--r--src/shortcut_service.c2
-rw-r--r--src/slave_life.c7
-rw-r--r--src/slave_rpc.c2
-rw-r--r--src/util.c47
-rw-r--r--src/xmonitor.c2
29 files changed, 1197 insertions, 156 deletions
diff --git a/src/abi.c b/src/abi.c
index d821183..713bfe5 100644
--- a/src/abi.c
+++ b/src/abi.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/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
*
diff --git a/src/conf.c b/src/conf.c
index acfdb05..03f19a7 100644
--- a/src/conf.c
+++ b/src/conf.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/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
*
diff --git a/src/fb.c b/src/fb.c
index 7d21283..0907537 100644
--- a/src/fb.c
+++ b/src/fb.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/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);
diff --git a/src/io.c b/src/io.c
index 8003f30..fee17f2 100644
--- a/src/io.c
+++ b/src/io.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/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
*
diff --git a/src/main.c b/src/main.c
index ac78525..63a16e0 100644
--- a/src/main.c
+++ b/src/main.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
*
@@ -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, &timestamp, &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, &timestamp, &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
*
diff --git a/src/util.c b/src/util.c
index b029526..a95eb37 100644
--- a/src/util.c
+++ b/src/util.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
*
@@ -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
*