summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSung-jae Park <nicesj.park@samsung.com>2013-04-19 11:38:33 (GMT)
committerSung-jae Park <nicesj.park@samsung.com>2013-04-19 11:38:33 (GMT)
commitcc50a4eccfce0ef96156f3b49b3d33f8d1fdbb0f (patch)
tree25bc57a6f9fc9a3150ee90e1e271375e0bcc3686
parent14895012b92f92aee069d5fd5a2ef40d553fe044 (diff)
downloaddata-provider-master-cc50a4eccfce0ef96156f3b49b3d33f8d1fdbb0f.zip
data-provider-master-cc50a4eccfce0ef96156f3b49b3d33f8d1fdbb0f.tar.gz
data-provider-master-cc50a4eccfce0ef96156f3b49b3d33f8d1fdbb0f.tar.bz2
Implement the service thread & Update license
Implement the badge & shortcut & notification service threads. Change-Id: Idb9393bfd39861da6cd6679e6b370ad6e18d0b55
-rw-r--r--CMakeLists.txt4
-rwxr-xr-xdata/data-provider-master2
-rw-r--r--data/data-provider-master.service2
-rw-r--r--include/abi.h2
-rw-r--r--include/badge_service.h16
-rw-r--r--include/buffer_handler.h2
-rw-r--r--include/client_life.h2
-rw-r--r--include/client_rpc.h2
-rw-r--r--include/conf.h2
-rw-r--r--include/critical_log.h2
-rw-r--r--include/dead_monitor.h2
-rw-r--r--include/debug.h2
-rw-r--r--include/event.h2
-rw-r--r--include/fault_manager.h2
-rw-r--r--include/fb.h2
-rw-r--r--include/group.h2
-rw-r--r--include/instance.h2
-rw-r--r--include/io.h2
-rw-r--r--include/liveinfo.h2
-rw-r--r--include/main.h2
-rw-r--r--include/notification_service.h16
-rw-r--r--include/package.h2
-rw-r--r--include/parser.h2
-rw-r--r--include/pkgmgr.h2
-rw-r--r--include/rpc_to_slave.h2
-rw-r--r--include/script_handler.h2
-rw-r--r--include/server.h2
-rw-r--r--include/service_common.h37
-rw-r--r--include/setting.h2
-rw-r--r--include/shortcut_service.h17
-rw-r--r--include/slave_life.h2
-rw-r--r--include/slave_rpc.h2
-rw-r--r--include/util.h2
-rw-r--r--include/xmonitor.h2
-rw-r--r--pkgmgr_livebox/include/dlist.h2
-rw-r--r--pkgmgr_livebox/src/dlist.c2
-rw-r--r--pkgmgr_livebox/src/service_register.c2
-rw-r--r--res/edje/master.edc2
-rw-r--r--src/abi.c2
-rw-r--r--src/badge_service.c16
-rw-r--r--src/buffer_handler.c2
-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.c2
-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.c19
-rw-r--r--src/io.c2
-rw-r--r--src/liveinfo.c2
-rw-r--r--src/main.c2
-rw-r--r--src/notification_service.c16
-rw-r--r--src/package.c2
-rw-r--r--src/parser.c2
-rw-r--r--src/pkgmgr.c2
-rw-r--r--src/script_handler.c2
-rw-r--r--src/server.c2
-rw-r--r--src/service_common.c720
-rw-r--r--src/setting.c2
-rw-r--r--src/shortcut_service.c183
-rw-r--r--src/slave_life.c2
-rw-r--r--src/slave_rpc.c2
-rw-r--r--src/util.c2
-rw-r--r--src/xmonitor.c2
-rw-r--r--util_liveinfo/include/liveinfo.h2
-rw-r--r--util_liveinfo/src/liveinfo.c2
69 files changed, 1096 insertions, 66 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 507375c..660cb1b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -77,6 +77,10 @@ ADD_EXECUTABLE(${PROJECT_NAME}
src/liveinfo.c
src/pkgmgr.c
src/event.c
+ src/shortcut_service.c
+ src/badge_service.c
+ src/notification_service.c
+ src/service_common.c
)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkg_LDFLAGS} "-ldl")
diff --git a/data/data-provider-master b/data/data-provider-master
index f2125bb..a68b7d5 100755
--- a/data/data-provider-master
+++ b/data/data-provider-master
@@ -6,7 +6,7 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
-# http://floralicense.org
+# http://floralicense.org/license/
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/data/data-provider-master.service b/data/data-provider-master.service
index 6333352..f412797 100644
--- a/data/data-provider-master.service
+++ b/data/data-provider-master.service
@@ -5,7 +5,7 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
-# http://floralicense.org
+# http://floralicense.org/license/
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/abi.h b/include/abi.h
index 974999d..d1900b3 100644
--- a/include/abi.h
+++ b/include/abi.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/badge_service.h b/include/badge_service.h
new file mode 100644
index 0000000..94fb941
--- /dev/null
+++ b/include/badge_service.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright 2013 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
diff --git a/include/buffer_handler.h b/include/buffer_handler.h
index 8a5aea0..21d6707 100644
--- a/include/buffer_handler.h
+++ b/include/buffer_handler.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/client_life.h b/include/client_life.h
index 8b76f1a..4871974 100644
--- a/include/client_life.h
+++ b/include/client_life.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/client_rpc.h b/include/client_rpc.h
index 2cf0242..ccfa129 100644
--- a/include/client_rpc.h
+++ b/include/client_rpc.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/conf.h b/include/conf.h
index cd410ab..87d1070 100644
--- a/include/conf.h
+++ b/include/conf.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/critical_log.h b/include/critical_log.h
index cd0f769..757ae63 100644
--- a/include/critical_log.h
+++ b/include/critical_log.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/dead_monitor.h b/include/dead_monitor.h
index 1526f89..118c5ac 100644
--- a/include/dead_monitor.h
+++ b/include/dead_monitor.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/debug.h b/include/debug.h
index 317129f..5058acc 100644
--- a/include/debug.h
+++ b/include/debug.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/event.h b/include/event.h
index fe0d219..4cf46e4 100644
--- a/include/event.h
+++ b/include/event.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/fault_manager.h b/include/fault_manager.h
index e2bb96c..d61e225 100644
--- a/include/fault_manager.h
+++ b/include/fault_manager.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/fb.h b/include/fb.h
index baf5b4c..066f97a 100644
--- a/include/fb.h
+++ b/include/fb.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/group.h b/include/group.h
index 08de02b..161e0a4 100644
--- a/include/group.h
+++ b/include/group.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/instance.h b/include/instance.h
index 83f5c88..535defa 100644
--- a/include/instance.h
+++ b/include/instance.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/io.h b/include/io.h
index a857422..6624db5 100644
--- a/include/io.h
+++ b/include/io.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/liveinfo.h b/include/liveinfo.h
index 2dd1afd..e86e4a2 100644
--- a/include/liveinfo.h
+++ b/include/liveinfo.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/main.h b/include/main.h
index 92efdbb..94fb941 100644
--- a/include/main.h
+++ b/include/main.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/notification_service.h b/include/notification_service.h
new file mode 100644
index 0000000..94fb941
--- /dev/null
+++ b/include/notification_service.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright 2013 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
diff --git a/include/package.h b/include/package.h
index 3278c32..9735fa2 100644
--- a/include/package.h
+++ b/include/package.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/parser.h b/include/parser.h
index 82c96ef..db828b9 100644
--- a/include/parser.h
+++ b/include/parser.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/pkgmgr.h b/include/pkgmgr.h
index 2cb4008..e942697 100644
--- a/include/pkgmgr.h
+++ b/include/pkgmgr.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/rpc_to_slave.h b/include/rpc_to_slave.h
index 725a679..cfc87b9 100644
--- a/include/rpc_to_slave.h
+++ b/include/rpc_to_slave.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/script_handler.h b/include/script_handler.h
index 02c6a4f..c676836 100644
--- a/include/script_handler.h
+++ b/include/script_handler.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/server.h b/include/server.h
index ac93e32..570eb87 100644
--- a/include/server.h
+++ b/include/server.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/service_common.h b/include/service_common.h
new file mode 100644
index 0000000..6b0e4dd
--- /dev/null
+++ b/include/service_common.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2013 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+enum tcb_type {
+ TCB_CLIENT_TYPE_UNDEFINED = 0x00,
+ TCB_CLIENT_TYPE_APP = 0x01,
+ TCB_CLIENT_TYPE_SERVICE = 0x02,
+ TCB_CLIENT_TYPE_UNKNOWN = 0xff,
+};
+
+struct tcb;
+struct service_context;
+
+extern int tcb_fd(struct tcb *tcb);
+extern struct service_context *tcb_svc_ctx(struct tcb *tcb);
+extern int tcb_client_type(struct tcb *tcb);
+extern int tcb_client_type_set(struct tcb *tcb, enum tcb_type type);
+
+extern struct service_context *service_common_create(const char *addr, int (*service_thread_main)(struct tcb *tcb, struct packet *packet, void *data), void *data);
+extern int service_common_destroy(struct service_context *svc_ctx);
+
+extern int service_common_multicast_packet(struct tcb *tcb, struct packet *packet, int type);
+extern int service_common_unicast_packet(struct tcb *tcb, struct packet *packet);
+
+/* End of a file */
diff --git a/include/setting.h b/include/setting.h
index 5ec158e..1e4989e 100644
--- a/include/setting.h
+++ b/include/setting.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/shortcut_service.h b/include/shortcut_service.h
new file mode 100644
index 0000000..a7a146d
--- /dev/null
+++ b/include/shortcut_service.h
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2013 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* End of a file */
diff --git a/include/slave_life.h b/include/slave_life.h
index 256bf59..821b1eb 100644
--- a/include/slave_life.h
+++ b/include/slave_life.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/slave_rpc.h b/include/slave_rpc.h
index bef921d..cfcbabb 100644
--- a/include/slave_rpc.h
+++ b/include/slave_rpc.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/util.h b/include/util.h
index 11ffe9c..a474c06 100644
--- a/include/util.h
+++ b/include/util.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/include/xmonitor.h b/include/xmonitor.h
index 8024276..55aadeb 100644
--- a/include/xmonitor.h
+++ b/include/xmonitor.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/pkgmgr_livebox/include/dlist.h b/pkgmgr_livebox/include/dlist.h
index 5cddb58..99e8443 100644
--- a/pkgmgr_livebox/include/dlist.h
+++ b/pkgmgr_livebox/include/dlist.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/pkgmgr_livebox/src/dlist.c b/pkgmgr_livebox/src/dlist.c
index 7a890c5..cf2cb63 100644
--- a/pkgmgr_livebox/src/dlist.c
+++ b/pkgmgr_livebox/src/dlist.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/pkgmgr_livebox/src/service_register.c b/pkgmgr_livebox/src/service_register.c
index 9965d8a..6c8536e 100644
--- a/pkgmgr_livebox/src/service_register.c
+++ b/pkgmgr_livebox/src/service_register.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/res/edje/master.edc b/res/edje/master.edc
index d50e4da..e64548a 100644
--- a/res/edje/master.edc
+++ b/res/edje/master.edc
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/abi.c b/src/abi.c
index b0145cf..d821183 100644
--- a/src/abi.c
+++ b/src/abi.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/badge_service.c b/src/badge_service.c
new file mode 100644
index 0000000..94fb941
--- /dev/null
+++ b/src/badge_service.c
@@ -0,0 +1,16 @@
+/*
+ * Copyright 2013 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
diff --git a/src/buffer_handler.c b/src/buffer_handler.c
index 4ffaba7..1721e86 100644
--- a/src/buffer_handler.c
+++ b/src/buffer_handler.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/client_life.c b/src/client_life.c
index bc75d79..af8302d 100644
--- a/src/client_life.c
+++ b/src/client_life.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/client_rpc.c b/src/client_rpc.c
index edf4327..d87659f 100644
--- a/src/client_rpc.c
+++ b/src/client_rpc.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/conf.c b/src/conf.c
index c880bae..acfdb05 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/critical_log.c b/src/critical_log.c
index 9136bf0..38ad835 100644
--- a/src/critical_log.c
+++ b/src/critical_log.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/dead_monitor.c b/src/dead_monitor.c
index 2576baf..91e3a23 100644
--- a/src/dead_monitor.c
+++ b/src/dead_monitor.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/event.c b/src/event.c
index 1bc98b7..818e66f 100644
--- a/src/event.c
+++ b/src/event.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/fault_manager.c b/src/fault_manager.c
index 0c44712..837bd17 100644
--- a/src/fault_manager.c
+++ b/src/fault_manager.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/fb.c b/src/fb.c
index 220e8bd..7d21283 100644
--- a/src/fb.c
+++ b/src/fb.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/group.c b/src/group.c
index c18a279..0adae6a 100644
--- a/src/group.c
+++ b/src/group.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/instance.c b/src/instance.c
index a4df9dc..db4ab42 100644
--- a/src/instance.c
+++ b/src/instance.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -690,12 +690,17 @@ static inline int fork_package(struct inst_info *inst, const char *pkgname)
inst->info = info;
if (package_secured(info)) {
- DbgPrint("Register the update timer for secured livebox [%s]\n", package_name(info));
- inst->update_timer = util_timer_add(inst->lb.period, update_timer_cb, inst);
- if (!inst->update_timer)
- ErrPrint("Failed to add an update timer for instance %s\n", inst->id);
- else
- timer_freeze(inst); /* Freeze the update timer as default */
+ if (inst->lb.period > 0.0f) {
+ DbgPrint("Register the update timer for secured livebox [%s]\n", package_name(info));
+ inst->update_timer = util_timer_add(inst->lb.period, update_timer_cb, inst);
+ if (!inst->update_timer)
+ ErrPrint("Failed to add an update timer for instance %s\n", inst->id);
+ else
+ timer_freeze(inst); /* Freeze the update timer as default */
+ } else {
+ DbgPrint("secured livebox [%s] has no period (%lf)\n", package_name(info), inst->lb.period);
+ inst->update_timer = NULL;
+ }
}
return LB_STATUS_SUCCESS;
diff --git a/src/io.c b/src/io.c
index 3bb9f10..8003f30 100644
--- a/src/io.c
+++ b/src/io.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/liveinfo.c b/src/liveinfo.c
index 08257e4..d280fa3 100644
--- a/src/liveinfo.c
+++ b/src/liveinfo.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/main.c b/src/main.c
index 9b7ac7b..3421123 100644
--- a/src/main.c
+++ b/src/main.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/notification_service.c b/src/notification_service.c
new file mode 100644
index 0000000..94fb941
--- /dev/null
+++ b/src/notification_service.c
@@ -0,0 +1,16 @@
+/*
+ * Copyright 2013 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
diff --git a/src/package.c b/src/package.c
index 68b2d68..35e4742 100644
--- a/src/package.c
+++ b/src/package.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/parser.c b/src/parser.c
index 7efee09..3a4f4c7 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/pkgmgr.c b/src/pkgmgr.c
index 4b11fd3..2f65c13 100644
--- a/src/pkgmgr.c
+++ b/src/pkgmgr.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/script_handler.c b/src/script_handler.c
index ea709ed..0b0e789 100644
--- a/src/script_handler.c
+++ b/src/script_handler.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/server.c b/src/server.c
index 259e08d..27d4bbd 100644
--- a/src/server.c
+++ b/src/server.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/service_common.c b/src/service_common.c
new file mode 100644
index 0000000..15b5cb2
--- /dev/null
+++ b/src/service_common.c
@@ -0,0 +1,720 @@
+/*
+ * Copyright 2013 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <pthread.h>
+#include <secure_socket.h>
+#include <packet.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include <dlog.h>
+#include <Eina.h>
+
+#include "service_common.h"
+#include "util.h"
+#include "debug.h"
+#include "conf.h"
+
+#define EVT_CH 'e'
+#define EVT_END_CH 'x'
+
+#define CRITICAL_SECTION_BEGIN(handle) \
+do { \
+ int ret; \
+ ret = pthread_mutex_lock(handle); \
+ if (ret != 0) \
+ ErrPrint("Failed to lock: %s\n", strerror(ret)); \
+} while (0)
+
+#define CRITICAL_SECTION_END(handle) \
+do { \
+ int ret; \
+ ret = pthread_mutex_unlock(handle); \
+ if (ret != 0) \
+ ErrPrint("Failed to unlock: %s\n", strerror(ret)); \
+} while (0)
+
+
+int errno;
+
+/*!
+ * \note
+ * Server information and global (only in this file-scope) variables are defined
+ */
+#define EVT_READ 0
+#define EVT_WRITE 1
+#define EVT_MAX 2
+
+struct service_context {
+ pthread_t thid; /*!< Server thread Id */
+ int fd; /*!< Server socket handle */
+
+ pthread_t service_thid;
+
+ Eina_List *tcb_list; /*!< TCB list, list of every thread for client connections */
+ pthread_mutex_t tcb_list_lock; /*!< tcb_list has to be handled safely */
+
+ Eina_List *packet_list;
+ pthread_mutex_t packet_list_lock;
+ int evt_pipe[EVT_MAX];
+
+ int (*service_thread_main)(struct tcb *tcb, struct packet *packet, void *data);
+ void *service_thread_data;
+};
+
+struct packet_info {
+ struct tcb *tcb;
+ struct packet *packet;
+};
+
+/*!
+ * \note
+ * Thread Control Block
+ * - The main server will create a thread for every client connections.
+ * When a new client is comming to us, this TCB block will be allocated and initialized.
+ */
+struct tcb { /* Thread controll block */
+ struct service_context *svc_ctx;
+ pthread_t thid; /*!< Thread Id */
+ int fd; /*!< Connection handle */
+ enum tcb_type type;
+};
+
+/*!
+ * \note
+ * Called from Client Thread
+ */
+static inline int tcb_destroy(struct service_context *svc_ctx, struct tcb *tcb)
+{
+ void *ret;
+ int status;
+
+ CRITICAL_SECTION_BEGIN(&svc_ctx->tcb_list_lock);
+ svc_ctx->tcb_list = eina_list_remove(svc_ctx->tcb_list, tcb);
+ CRITICAL_SECTION_END(&svc_ctx->tcb_list_lock);
+
+ /*!
+ * ASSERT(tcb->fd >= 0);
+ */
+ secure_socket_destroy_handle(tcb->fd);
+
+ status = pthread_join(tcb->thid, &ret);
+ if (status != 0)
+ ErrPrint("Unable to join a thread: %s\n", strerror(status));
+ /*!
+ * \NOTE
+ * Waiting termination client thread
+ */
+ free(tcb);
+
+ return 0;
+}
+
+/*!
+ * Do service for clients
+ * Routing packets to destination processes.
+ */
+static void *client_packet_pump_main(void *data)
+{
+ struct tcb *tcb = data;
+ struct service_context *svc_ctx = tcb->svc_ctx;
+ struct packet *packet;
+ fd_set set;
+ char *ptr;
+ int size;
+ int packet_offset;
+ int recv_offset;
+ int pid;
+ int ret;
+ char evt_ch = EVT_CH;
+ enum {
+ RECV_INIT,
+ RECV_HEADER,
+ RECV_PAYLOAD,
+ RECV_DONE,
+ } recv_state;
+ struct packet_info *packet_info;
+
+ ret = 0;
+ recv_state = RECV_INIT;
+ /*!
+ * \note
+ * To escape from the switch statement, we use this ret value
+ */
+ while (ret == 0) {
+ FD_ZERO(&set);
+ FD_SET(tcb->fd, &set);
+ ret = select(tcb->fd + 1, &set, NULL, NULL, NULL);
+ if (ret < 0) {
+ ret = -errno;
+ if (errno == EINTR) {
+ DbgPrint("INTERRUPTED\n");
+ ret = 0;
+ continue;
+ }
+ ErrPrint("Error: %s\n",strerror(errno));
+ break;
+ } else if (ret == 0) {
+ ErrPrint("Timeout\n");
+ ret = -ETIMEDOUT;
+ break;
+ }
+
+ if (FD_ISSET(tcb->fd, &set)) {
+ ErrPrint("Unexpected handler is toggled\n");
+ ret = -EINVAL;
+ break;
+ }
+
+ /*!
+ * \TODO
+ * Service!!! Receive packet & route packet
+ */
+ switch (recv_state) {
+ case RECV_INIT:
+ size = packet_header_size();
+ packet_offset = 0;
+ recv_offset = 0;
+ packet = NULL;
+ ptr = malloc(size);
+ if (!ptr) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ ret = -ENOMEM;
+ break;
+ }
+ recv_state = RECV_HEADER;
+ /* Go through, don't break from here */
+ case RECV_HEADER:
+ ret = secure_socket_recv(tcb->fd, ptr, size - recv_offset, &pid);
+ if (ret <= 0) {
+ if (ret == 0)
+ ret = -ECANCELED;
+ free(ptr);
+ break;
+ }
+
+ recv_offset += ret;
+ ret = 0;
+
+ if (recv_offset == size) {
+ packet = packet_build(packet, packet_offset, ptr, size);
+ free(ptr);
+ if (!packet) {
+ ret = -EFAULT;
+ break;
+ }
+
+ packet_offset += recv_offset;
+
+ recv_state = RECV_PAYLOAD;
+ recv_offset = 0;
+ size = packet_payload_size(packet);
+
+ ptr = malloc(size);
+ if (!ptr) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ ret = -ENOMEM;
+ }
+ }
+ break;
+ case RECV_PAYLOAD:
+ ret = secure_socket_recv(tcb->fd, ptr, size - recv_offset, &pid);
+ if (ret <= 0) {
+ if (ret == 0)
+ ret = -ECANCELED;
+ free(ptr);
+ break;
+ }
+
+ recv_offset += ret;
+ ret = 0;
+
+ if (recv_offset == size) {
+ packet = packet_build(packet, packet_offset, ptr, size);
+ free(ptr);
+ if (!packet) {
+ ret = -EFAULT;
+ break;
+ }
+
+ packet_offset += recv_offset;
+
+ recv_state = RECV_DONE;
+ recv_offset = 0;
+ }
+ break;
+ case RECV_DONE:
+ /*!
+ * Push this packet to the packet list with TCB
+ * Then the service main function will get this.
+ */
+ packet_info = malloc(sizeof(*packet_info));
+ if (!packet_info) {
+ ret = -errno;
+ ErrPrint("Heap: %s\n", strerror(errno));
+ packet_destroy(packet);
+ break;
+ }
+
+ packet_info->packet = packet;
+ packet_info->tcb = tcb;
+
+ CRITICAL_SECTION_BEGIN(&svc_ctx->packet_list_lock);
+ svc_ctx->packet_list = eina_list_append(svc_ctx->packet_list, packet_info);
+ CRITICAL_SECTION_END(&svc_ctx->packet_list_lock);
+
+ if (write(svc_ctx->evt_pipe[EVT_WRITE], &evt_ch, sizeof(evt_ch)) != sizeof(evt_ch)) {
+ ret = -errno;
+ ErrPrint("Unable to write a pipe\n");
+ CRITICAL_SECTION_BEGIN(&svc_ctx->packet_list_lock);
+ svc_ctx->packet_list = eina_list_remove(svc_ctx->packet_list, packet_info);
+ CRITICAL_SECTION_END(&svc_ctx->packet_list_lock);
+
+ packet_destroy(packet);
+ free(packet_info);
+ break;
+ }
+ DbgPrint("Packet received: %d bytes\n", packet_offset);
+
+ recv_state = RECV_INIT;
+ break;
+ default:
+ /* Dead code */
+ break;
+ }
+ }
+
+ tcb_destroy(svc_ctx, tcb);
+ return (void *)ret;
+}
+
+/*!
+ * \note
+ * Called from Server Main Thread
+ */
+static inline struct tcb *tcb_create(struct service_context *svc_ctx, int fd)
+{
+ struct tcb *tcb;
+ int status;
+
+ tcb = malloc(sizeof(*tcb));
+ if (!tcb) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ return NULL;
+ }
+
+ tcb->fd = fd;
+ tcb->svc_ctx = svc_ctx;
+
+ status = pthread_create(&tcb->thid, NULL, client_packet_pump_main, tcb);
+ if (status != 0) {
+ ErrPrint("Unable to create a new thread: %s\n", strerror(status));
+ free(tcb);
+ return NULL;
+ }
+
+ CRITICAL_SECTION_BEGIN(&svc_ctx->tcb_list_lock);
+ svc_ctx->tcb_list = eina_list_append(svc_ctx->tcb_list, tcb);
+ CRITICAL_SECTION_END(&svc_ctx->tcb_list_lock);
+
+ return tcb;
+}
+
+/*!
+ * \note
+ * Called from Main Thread
+ */
+static inline void tcb_teminate_all(struct service_context *svc_ctx)
+{
+ struct tcb *tcb;
+ void *ret;
+ int status;
+
+ /*!
+ * We don't need to make critical section on here.
+ * If we call this after terminate the server thread first.
+ * Then there is no other thread to access tcb_list.
+ */
+ CRITICAL_SECTION_BEGIN(&svc_ctx->tcb_list_lock);
+ EINA_LIST_FREE(svc_ctx->tcb_list, tcb) {
+ /*!
+ * ASSERT(tcb->fd >= 0);
+ */
+ secure_socket_destroy_handle(tcb->fd);
+
+ status = pthread_join(tcb->thid, &ret);
+ if (status != 0)
+ ErrPrint("Unable to join a thread: %s\n", strerror(status));
+
+ free(tcb);
+ }
+ CRITICAL_SECTION_END(&svc_ctx->tcb_list_lock);
+}
+
+/*!
+ * \NOTE
+ * Packet consuming thread. service thread.
+ */
+static void *service_main(void *data)
+{
+ struct service_context *svc_ctx = data;
+ fd_set set;
+ int ret;
+ char evt_ch;
+ struct packet_info *packet_info;
+
+ while (1) {
+ FD_ZERO(&set);
+ FD_SET(svc_ctx->evt_pipe[EVT_READ], &set);
+ ret = select(svc_ctx->evt_pipe[EVT_READ] + 1, &set, NULL, NULL, NULL);
+ if (ret < 0) {
+ ret = -errno;
+ if (errno == EINTR) {
+ DbgPrint("INTERRUPTED\n");
+ continue;
+ }
+ ErrPrint("Error: %s\n",strerror(errno));
+ break;
+ } else if (ret == 0) {
+ ErrPrint("Timeout\n");
+ ret = -ETIMEDOUT;
+ break;
+ }
+
+ if (FD_ISSET(svc_ctx->evt_pipe[EVT_READ], &set)) {
+ ErrPrint("Unexpected handler is toggled\n");
+ ret = -EINVAL;
+ break;
+ }
+
+ if (read(svc_ctx->evt_pipe[EVT_READ], &evt_ch, sizeof(evt_ch)) != sizeof(evt_ch)) {
+ ErrPrint("Unable to read pipe: %s\n", strerror(errno));
+ ret = -EIO;
+ break;
+ }
+
+ if (evt_ch == EVT_END_CH) {
+ ErrPrint("Thread is terminated\n");
+ ret = 0;
+ break;
+ }
+
+ CRITICAL_SECTION_BEGIN(&svc_ctx->packet_list_lock);
+ packet_info = eina_list_nth(svc_ctx->packet_list, 0);
+ svc_ctx->packet_list = eina_list_remove(svc_ctx->packet_list, packet_info);
+ CRITICAL_SECTION_END(&svc_ctx->packet_list_lock);
+
+ 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);
+
+ packet_destroy(packet_info->packet);
+ free(packet_info);
+ }
+
+ return (void *)ret;
+}
+
+/*!
+ * Accept new client connections
+ * And create a new thread for service.
+ */
+static void *server_main(void *data)
+{
+ struct service_context *svc_ctx = data;
+ fd_set set;
+ int ret;
+ int client_fd;
+ struct tcb *tcb;
+
+ while (1) {
+ FD_ZERO(&set);
+ FD_SET(svc_ctx->fd, &set);
+ ret = select(svc_ctx->fd + 1, &set, NULL, NULL, NULL);
+ if (ret < 0) {
+ ret = -errno;
+ if (errno == EINTR) {
+ DbgPrint("INTERRUPTED\n");
+ continue;
+ }
+ ErrPrint("Error: %s\n", strerror(errno));
+ break;
+ } else if (ret == 0) {
+ ErrPrint("Timeout\n");
+ ret = -ETIMEDOUT;
+ break;
+ }
+
+ if (FD_ISSET(svc_ctx->fd, &set)) {
+ ErrPrint("Unexpected handler is toggled\n");
+ ret = -EINVAL;
+ break;
+ }
+
+ client_fd = secure_socket_get_connection_handle(svc_ctx->fd);
+ DbgPrint("New client connection arrived (%d)\n", client_fd);
+ if (client_fd < 0) {
+ ErrPrint("Failed to establish the client connection\n");
+ ret = -EFAULT;
+ break;
+ }
+
+ tcb = tcb_create(svc_ctx, client_fd);
+ if (!tcb)
+ secure_socket_destroy_handle(client_fd);
+ }
+
+ return (void *)ret;
+}
+
+HAPI struct service_context *service_common_create(const char *addr, int (*service_thread_main)(struct tcb *tcb, struct packet *packet, void *data), void *data)
+{
+ int status;
+ struct service_context *svc_ctx;
+
+ if (!service_thread_main || !addr) {
+ ErrPrint("Invalid argument\n");
+ return NULL;
+ }
+
+ svc_ctx = malloc(sizeof(*svc_ctx));
+ if (!svc_ctx) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ return NULL;
+ }
+
+ svc_ctx->fd = secure_socket_create_server(addr);
+ if (svc_ctx->fd < 0) {
+ free(svc_ctx);
+ return NULL;
+ }
+
+ svc_ctx->service_thread_main = service_thread_main;
+ svc_ctx->service_thread_data = data;
+
+ if (fcntl(svc_ctx->fd, F_SETFD, FD_CLOEXEC) < 0)
+ ErrPrint("fcntl: %s\n", strerror(errno));
+
+ if (fcntl(svc_ctx->fd, F_SETFL, O_NONBLOCK) < 0)
+ ErrPrint("fcntl: %s\n", strerror(errno));
+
+ if (pipe2(svc_ctx->evt_pipe, O_NONBLOCK | O_CLOEXEC) < 0) {
+ ErrPrint("pipe: %d\n", strerror(errno));
+ secure_socket_destroy_handle(svc_ctx->fd);
+ free(svc_ctx);
+ return NULL;
+ }
+
+ status = pthread_mutex_init(&svc_ctx->packet_list_lock, NULL);
+ if (status != 0) {
+ ErrPrint("Unable to create a mutex: %s\n", strerror(status));
+ status = close(svc_ctx->evt_pipe[EVT_READ]);
+ if (status < 0)
+ ErrPrint("Error: %s\n", strerror(errno));
+ status = close(svc_ctx->evt_pipe[EVT_WRITE]);
+ if (status < 0)
+ ErrPrint("Error: %s\n", strerror(errno));
+ secure_socket_destroy_handle(svc_ctx->fd);
+ free(svc_ctx);
+ return NULL;
+ }
+
+ status = pthread_mutex_init(&svc_ctx->tcb_list_lock, NULL);
+ if (status != 0) {
+ ErrPrint("Unable to initiate the mutex: %s\n", strerror(status));
+ status = pthread_mutex_destroy(&svc_ctx->packet_list_lock);
+ if (status != 0)
+ ErrPrint("Error: %s\n", strerror(status));
+ status = close(svc_ctx->evt_pipe[EVT_READ]);
+ if (status < 0)
+ ErrPrint("Error: %s\n", strerror(errno));
+ status = close(svc_ctx->evt_pipe[EVT_WRITE]);
+ if (status < 0)
+ ErrPrint("Error: %s\n", strerror(errno));
+ secure_socket_destroy_handle(svc_ctx->fd);
+ free(svc_ctx);
+ return NULL;
+ }
+
+ status = pthread_create(&svc_ctx->thid, NULL, server_main, svc_ctx);
+ if (status != 0) {
+ ErrPrint("Unable to create a thread for shortcut service: %s\n", strerror(status));
+ status = pthread_mutex_destroy(&svc_ctx->tcb_list_lock);
+ if (status != 0)
+ ErrPrint("Error: %s\n", strerror(status));
+ status = pthread_mutex_destroy(&svc_ctx->packet_list_lock);
+ if (status != 0)
+ ErrPrint("Error: %s\n", strerror(status));
+ status = close(svc_ctx->evt_pipe[EVT_READ]);
+ if (status != 0)
+ ErrPrint("Error: %s\n", strerror(status));
+ status = close(svc_ctx->evt_pipe[EVT_WRITE]);
+ if (status != 0)
+ ErrPrint("Error: %s\n", strerror(status));
+ secure_socket_destroy_handle(svc_ctx->fd);
+ free(svc_ctx);
+ return NULL;
+ }
+
+ status = pthread_create(&svc_ctx->service_thid, NULL, service_main, svc_ctx);
+ if (status != 0) {
+ void *ret;
+ ErrPrint("Unable to create a thread for shortcut service: %s\n", strerror(status));
+
+ secure_socket_destroy_handle(svc_ctx->fd);
+
+ status = pthread_join(svc_ctx->thid, &ret);
+ if (status != 0)
+ ErrPrint("Error: %s\n", strerror(status));
+
+ status = pthread_mutex_destroy(&svc_ctx->tcb_list_lock);
+ if (status != 0)
+ ErrPrint("Error: %s\n", strerror(status));
+ status = pthread_mutex_destroy(&svc_ctx->packet_list_lock);
+ if (status != 0)
+ ErrPrint("Error: %s\n", strerror(status));
+ status = close(svc_ctx->evt_pipe[EVT_READ]);
+ if (status < 0)
+ ErrPrint("Error: %s\n", strerror(errno));
+ status = close(svc_ctx->evt_pipe[EVT_WRITE]);
+ if (status < 0)
+ ErrPrint("Error: %s\n", strerror(errno));
+ secure_socket_destroy_handle(svc_ctx->fd);
+ free(svc_ctx);
+ return NULL;
+ }
+
+ return svc_ctx;
+}
+
+HAPI int service_common_destroy(struct service_context *svc_ctx)
+{
+ int status;
+ void *ret;
+ char evt_ch = EVT_END_CH;
+
+ if (!svc_ctx)
+ return -EINVAL;
+
+ /*!
+ * \note
+ * Terminate server thread
+ */
+ secure_socket_destroy_handle(svc_ctx->fd);
+ status = pthread_join(svc_ctx->thid, &ret);
+ if (status != 0)
+ ErrPrint("Join: %s\n", strerror(status));
+ /*!
+ * \note
+ * Terminate all client threads.
+ */
+ tcb_teminate_all(svc_ctx);
+
+ /* Emit a finish event */
+ if (write(svc_ctx->evt_pipe[EVT_WRITE], &evt_ch, sizeof(evt_ch)) == sizeof(evt_ch))
+ ErrPrint("write: %s\n", strerror(errno));
+
+ /* Waiting */
+ status = pthread_join(svc_ctx->service_thid, &ret);
+ if (status != 0)
+ ErrPrint("Join: %s\n", strerror(status));
+
+ status = pthread_mutex_destroy(&svc_ctx->tcb_list_lock);
+ if (status != 0)
+ ErrPrint("Unable to destroy a mutex: %s\n", strerror(status));
+
+ status = pthread_mutex_destroy(&svc_ctx->packet_list_lock);
+ if (status != 0)
+ ErrPrint("Unable to destroy a mutex: %s\n", strerror(status));
+
+ status = close(svc_ctx->evt_pipe[EVT_WRITE]);
+ status = close(svc_ctx->evt_pipe[EVT_READ]);
+ free(svc_ctx);
+ return 0;
+}
+
+HAPI int tcb_fd(struct tcb *tcb)
+{
+ if (!tcb)
+ return -EINVAL;
+
+ return tcb->fd;
+}
+
+HAPI int tcb_client_type(struct tcb *tcb)
+{
+ if (!tcb)
+ return -EINVAL;
+
+ return tcb->type;
+}
+
+HAPI int tcb_client_type_set(struct tcb *tcb, enum tcb_type type)
+{
+ if (!tcb)
+ return -EINVAL;
+
+ tcb->type = type;
+ return 0;
+}
+
+HAPI struct service_context *tcb_svc_ctx(struct tcb *tcb)
+{
+ if (!tcb)
+ return NULL;
+
+ return tcb->svc_ctx;
+}
+
+HAPI int service_common_unicast_packet(struct tcb *tcb, struct packet *packet)
+{
+ if (!tcb || !packet)
+ return -EINVAL;
+
+ return secure_socket_send(tcb->fd, (void *)packet_data(packet), packet_size(packet));
+}
+
+HAPI int service_common_multicast_packet(struct tcb *tcb, struct packet *packet, int type)
+{
+ Eina_List *l;
+ struct tcb *target;
+ struct service_context *svc_ctx;
+ int ret;
+
+ if (!tcb || !packet)
+ return -EINVAL;
+
+ svc_ctx = tcb->svc_ctx;
+
+ CRITICAL_SECTION_BEGIN(&svc_ctx->tcb_list_lock);
+ EINA_LIST_FOREACH(svc_ctx->tcb_list, l, target) {
+ if (target == tcb || target->type != type)
+ continue;
+
+ ret = secure_socket_send(target->fd, (void *)packet_data(packet), packet_size(packet));
+ if (ret < 0)
+ ErrPrint("Failed to send packet: %d\n", ret);
+ }
+ CRITICAL_SECTION_END(&svc_ctx->tcb_list_lock);
+
+ return 0;
+}
+
+/* End of a file */
diff --git a/src/setting.c b/src/setting.c
index d0119b1..8eaceca 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/shortcut_service.c b/src/shortcut_service.c
new file mode 100644
index 0000000..774d814
--- /dev/null
+++ b/src/shortcut_service.c
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2013 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdio.h>
+
+#include <Eina.h>
+
+#include <dlog.h>
+#include <livebox-errno.h>
+#include <packet.h>
+
+#include <Eina.h>
+
+#include "service_common.h"
+#include "debug.h"
+#include "util.h"
+
+#define SHORTCUT_ADDR "/tmp/.shortcut.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;
+};
+
+/*!
+ * SERVICE THREAD
+ */
+static inline int put_reply_context(struct tcb *tcb, double seq)
+{
+ struct context *ctx;
+
+ ctx = malloc(sizeof(*ctx));
+ if (!ctx) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ return -ENOMEM;
+ }
+
+ ctx->tcb = tcb;
+ ctx->seq = seq; /* Could we this sequence value is uniq? */
+
+ s_info.context_list = eina_list_append(s_info.context_list, ctx);
+ return 0;
+}
+
+/*!
+ * SERVICE THREAD
+ */
+static inline struct tcb *get_reply_context(double seq)
+{
+ Eina_List *l;
+ Eina_List *n;
+ struct context *ctx;
+ struct tcb *tcb;
+
+ tcb = NULL;
+ EINA_LIST_FOREACH_SAFE(s_info.context_list, l, n, ctx) {
+ if (ctx->seq != seq)
+ continue;
+
+ s_info.context_list = eina_list_remove(s_info.context_list, ctx);
+ tcb = ctx->tcb;
+ free(ctx);
+ break;
+ }
+
+ return tcb;
+}
+
+/*!
+ * SERVICE THREAD
+ */
+static int service_thread_main(struct tcb *tcb, struct packet *packet, void *data)
+{
+ const char *command;
+
+ command = packet_command(packet);
+ if (!command) {
+ ErrPrint("Invalid command\n");
+ return -EINVAL;
+ }
+
+ switch (packet_type(packet)) {
+ case PACKET_REQ:
+ /* Need to send reply packet */
+ DbgPrint("REQ: Command: [%s]\n", command);
+ if (!strcmp(command, "register_service")) {
+ /*!
+ * To multicast event packets to the service clients
+ */
+ tcb_client_type_set(tcb, TCB_CLIENT_TYPE_SERVICE);
+ break;
+ }
+
+ if (service_common_multicast_packet(tcb, packet, TCB_CLIENT_TYPE_SERVICE) < 0)
+ ErrPrint("Unable to send service request packet\n");
+ else
+ (void)put_reply_context(tcb, packet_seq(packet));
+ break;
+ case PACKET_REQ_NOACK:
+ /* Doesn't need to send reply packet */
+ DbgPrint("REQ_NOACK: Command: [%s]\n", command);
+ if (!strcmp(command, "register_service")) {
+ tcb_client_type_set(tcb, TCB_CLIENT_TYPE_SERVICE);
+ break;
+ }
+
+ if (service_common_multicast_packet(tcb, packet, TCB_CLIENT_TYPE_SERVICE) < 0)
+ ErrPrint("Unable to send service reuqest packet\n");
+ break;
+ case PACKET_ACK:
+ /* Okay, client(or app) send a reply packet to us. */
+ DbgPrint("ACK: Command: [%s]\n", command);
+ tcb = get_reply_context(packet_seq(packet));
+ if (!tcb) {
+ ErrPrint("There is no proper context\n");
+ break;
+ }
+
+ if (service_common_unicast_packet(tcb, packet) < 0)
+ ErrPrint("Unable to send reply packet\n");
+ 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
+ */
+
+int service_shortcut_init(void)
+{
+ if (s_info.svc_ctx) {
+ ErrPrint("Already initialized\n");
+ return LB_STATUS_ERROR_ALREADY;
+ }
+
+ s_info.svc_ctx = service_common_create(SHORTCUT_ADDR, service_thread_main, NULL);
+ if (!s_info.svc_ctx)
+ return LB_STATUS_ERROR_FAULT;
+
+ return LB_STATUS_SUCCESS;
+}
+
+int service_shortcut_fini(void)
+{
+ if (!s_info.svc_ctx)
+ return LB_STATUS_ERROR_INVALID;
+
+ service_common_destroy(s_info.svc_ctx);
+ return LB_STATUS_SUCCESS;
+}
+
+/* End of a file */
diff --git a/src/slave_life.c b/src/slave_life.c
index 81559a0..eac009d 100644
--- a/src/slave_life.c
+++ b/src/slave_life.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/slave_rpc.c b/src/slave_rpc.c
index 47428bd..570852e 100644
--- a/src/slave_rpc.c
+++ b/src/slave_rpc.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/util.c b/src/util.c
index da304fc..b029526 100644
--- a/src/util.c
+++ b/src/util.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/xmonitor.c b/src/xmonitor.c
index ee3f578..039973b 100644
--- a/src/xmonitor.c
+++ b/src/xmonitor.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/util_liveinfo/include/liveinfo.h b/util_liveinfo/include/liveinfo.h
index 92efdbb..94fb941 100644
--- a/util_liveinfo/include/liveinfo.h
+++ b/util_liveinfo/include/liveinfo.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/util_liveinfo/src/liveinfo.c b/util_liveinfo/src/liveinfo.c
index 7278f28..bd2dccf 100644
--- a/util_liveinfo/src/liveinfo.c
+++ b/util_liveinfo/src/liveinfo.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,