Using gdbus for IPC instead of com-core package 17/57417/21 tizen_3.0_dbus
authorHyunho Kang <hhstark.kang@samsung.com>
Wed, 20 Jan 2016 02:41:03 +0000 (11:41 +0900)
committerjusung son <jusung07.son@samsung.com>
Mon, 29 Feb 2016 10:14:25 +0000 (19:14 +0900)
Change-Id: I0278598d180d3e8e834464e82f0010d637bdda98
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
Signed-off-by: jusung son <jusung07.son@samsung.com>
31 files changed:
CMakeLists.txt
data-provider-master.conf.in [new file with mode: 0644]
data/CMakeLists.txt [deleted file]
data/data-provider-master [deleted file]
data/data-provider-master-badge.socket [deleted file]
data/data-provider-master-client.socket [deleted file]
data/data-provider-master-fd.socket [deleted file]
data/data-provider-master-notification.socket [deleted file]
data/data-provider-master-provider.socket [deleted file]
data/data-provider-master-service.socket [deleted file]
data/data-provider-master-shortcut.socket [deleted file]
data/data-provider-master-utility.socket [deleted file]
data/data-provider-master.path [deleted file]
data/data-provider-master.service [deleted file]
data/data-provider-master.target [deleted file]
include/badge_service.h
include/conf.h [changed mode: 0644->0755]
include/debug.h
include/notification_service.h
include/service_common.h
include/shortcut_service.h
org.tizen.data-provider-master.service.in [new file with mode: 0644]
packaging/data-provider-master.service [new file with mode: 0644]
packaging/data-provider-master.spec
src/badge_service.c [changed mode: 0644->0755]
src/critical_log.c
src/main.c
src/notification_service.c [changed mode: 0644->0755]
src/pkgmgr.c
src/service_common.c [changed mode: 0644->0755]
src/shortcut_service.c

index 235a48f..39b3d46 100644 (file)
@@ -1,6 +1,12 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 PROJECT(${NAME} C)
 
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(LIBDIR ${LIB_INSTALL_DIR})
+SET(INCLUDEDIR "\${prefix}/include")
+
+
 INCLUDE(FindPkgConfig)
 pkg_check_modules(pkg REQUIRED
        dlog
@@ -13,11 +19,9 @@ pkg_check_modules(pkg REQUIRED
        bundle
        ecore
        eina
-       com-core
        pkgmgr
        notification
        badge
-       badge-service
        libsmack
        shortcut
        pkgmgr-info
@@ -41,16 +45,6 @@ ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")
 ADD_DEFINITIONS("-D_GNU_SOURCE")
 ADD_DEFINITIONS("-D_FILE_OFFSET_BITS=64")
 
-ADD_DEFINITIONS("-DCLIENT_SOCKET=\"/tmp/.data-provider-master-client.socket\"")
-ADD_DEFINITIONS("-DSLAVE_SOCKET=\"/tmp/.data-provider-master-slave.socket\"")
-ADD_DEFINITIONS("-DSERVICE_SOCKET=\"/tmp/.data-provider-master-service.socket\"")
-
-ADD_DEFINITIONS("-DCLIENT_PORT=\"8208\"")
-
-ADD_DEFINITIONS("-DBADGE_SOCKET=\"/tmp/.badge.service\"")
-ADD_DEFINITIONS("-DSHORTCUT_SOCKET=\"/tmp/.shortcut.service\"")
-ADD_DEFINITIONS("-DNOTIFICATION_SOCKET=\"/tmp/.notification.service\"")
-
 ADD_DEFINITIONS("-DSHORTCUT_SMACK_LABEL=NULL")
 ADD_DEFINITIONS("-DNOTIFICATION_SMACK_LABEL=NULL")
 ADD_DEFINITIONS("-DBADGE_SMACK_LABEL=NULL")
@@ -71,11 +65,11 @@ SET(BUILD_SOURCE
        src/main.c
        src/util.c
        src/pkgmgr.c
-       src/critical_log.c
        src/shortcut_service.c
        src/badge_service.c
        src/notification_service.c
        src/service_common.c
+       src/critical_log.c
 )
 
 STRING(REPLACE "-L-l" "-l" pkg_fixed_LDFLAGS ${pkg_LDFLAGS})
@@ -93,7 +87,9 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkg_LDFLAGS} "-ldl -lrt -pie")
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME "${PROJECT_NAME}")
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
 
-# INCLUDE FOR BUILD & INSTALL .PO FILES
-ADD_SUBDIRECTORY(data)
+CONFIGURE_FILE(data-provider-master.conf.in data-provider-master.conf @ONLY)
+CONFIGURE_FILE(org.tizen.data-provider-master.service.in org.tizen.data-provider-master.service @ONLY)
 
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.tizen.data-provider-master.service DESTINATION ${SHARE_INSTALL_PREFIX}/dbus-1/system-services/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.conf DESTINATION ${SYSCONF_INSTALL_DIR}/dbus-1/system.d/)
 # End of a file
diff --git a/data-provider-master.conf.in b/data-provider-master.conf.in
new file mode 100644 (file)
index 0000000..4767630
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+        "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+
+<busconfig>
+        <policy user="root">
+               <allow own="org.tizen.data_provider_service"/>
+       </policy>
+       <policy context="default">
+                <allow send_destination="org.tizen.data_provider_service"/>
+               <check send_destination="org.tizen.data_provider_service" send_interface="org.tizen.data_provider_noti_service" send_member="service_register" privilege="http://tizen.org/privilege/notification"/>
+               <check send_destination="org.tizen.data_provider_service" send_interface="org.tizen.data_provider_badge_service" send_member="service_register" privilege="http://tizen.org/privilege/notification"/>
+               <check send_destination="org.tizen.data_provider_service" send_interface="org.tizen.data_provider_shortcut_service" send_member="service_register" privilege="http://tizen.org/privilege/shortcut"/>
+        </policy>
+</busconfig>
diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt
deleted file mode 100644 (file)
index 791e98c..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${PROJECT_NAME}.service DESTINATION /usr/lib/systemd/system/ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${PROJECT_NAME}.target DESTINATION /usr/lib/systemd/system/ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${PROJECT_NAME}-service.socket DESTINATION /usr/lib/systemd/system/ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${PROJECT_NAME}-badge.socket DESTINATION /usr/lib/systemd/system/ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${PROJECT_NAME}-notification.socket DESTINATION /usr/lib/systemd/system/ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${PROJECT_NAME}-shortcut.socket DESTINATION /usr/lib/systemd/system/ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
diff --git a/data/data-provider-master b/data/data-provider-master
deleted file mode 100644 (file)
index 6dd2a92..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-#!/bin/sh
-#
-# Copyright 2013  Samsung Electronics Co., Ltd
-#
-# Licensed under the Flora License, Version 1.1 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://floralicense.org/license/
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-launch_provider()
-{
-       RETRY_COUNT=0
-       while [ ! -f "/tmp/.stop.provider" ]; do
-               # PROVIDER_HEAP_MONITOR_START=false
-               # PROVIDER_DISABLE_CALL_OPTION=false
-               # PROVIDER_METHOD="shm", "pixmap", "file" (default = "file")
-               BUFMGR_LOCK_TYPE="once" BUFMGR_MAP_CACHE="true" /usr/bin/data-provider-master
-               vconftool set -t bool memory/data-provider-master/started 0 -f
-               let RETRY_COUNT=$RETRY_COUNT+1
-               if [ $RETRY_COUNT -gt 5 ]; then
-                       echo "EXCEED THE MAXIMUM RETRY COUNT: $RETRY_COUNT (max 5)"
-                       break;
-               fi
-       done
-       rm /tmp/.stop.provider
-}
-
-start ()
-{
-       OLDPID=`ps ax | grep /usr/bin/data-provider-master | grep -v grep | awk '{print $1}'`
-       if [ x"$OLDPID" != x"" ]; then
-               echo $OLDPID is already running.
-               exit 0
-       fi
-
-       rm /tmp/.stop.provider
-       launch_provider &
-}
-
-stop ()
-{
-       TMP=`which ps`
-       if [ $? -ne 0 ]; then
-               echo "'ps' is not exists"
-               exit 0
-       fi
-
-       TMP=`which grep`
-       if [ $? -ne 0 ]; then
-               echo "'grep' is not exists"
-               exit 0
-       fi
-
-       TMP=`which awk`
-       if [ $? -ne 0 ]; then
-               echo "'awk' is not exists"
-               exit 0
-       fi
-
-       if [ ! -f "/usr/bin/data-provider-master" ]; then
-               echo "Data provider master is not installed correctly";
-               exit 0;
-       fi
-
-       touch /tmp/.stop.provider
-       BIN_INODE=`stat -Lc "%i" /usr/bin/data-provider-master`
-
-       PID=`ps ax | grep 'data-provider-master' | awk '{print $1}'`
-       for I in $PID;
-       do
-               if [ ! -f "/proc/$I/exe" ]; then
-                       continue;
-               fi
-
-               INODE=`stat -Lc "%i" /proc/$I/exe 2>/dev/null`
-               if [ x"$BIN_INODE" == x"$INODE" ]; then
-                       echo "Send TERM to $I"
-                       kill $I # Try to terminate a master which is launched already
-                       break
-               fi
-       done
-}
-
-case "$1" in
-       start|"") start;;
-       stop) stop;;
-       restart) stop; start;;
-esac
-
-# End of a file
diff --git a/data/data-provider-master-badge.socket b/data/data-provider-master-badge.socket
deleted file mode 100644 (file)
index 445c8cd..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-[Socket]
-SocketUser=system
-SocketGroup=system
-ListenStream=/tmp/.badge.service
-SocketMode=0666
-
-Service=data-provider-master.service
-
-[Unit]
-Wants=data-provider-master.target
-Before=data-provider-master.target
-
-[Install]
-WantedBy=sockets.target
diff --git a/data/data-provider-master-client.socket b/data/data-provider-master-client.socket
deleted file mode 100644 (file)
index c431a59..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-[Socket]
-SocketUser=system
-SocketGroup=system
-ListenStream=/tmp/.data-provider-master-client.socket
-SocketMode=0666
-
-Service=data-provider-master.service
-
-[Unit]
-Wants=data-provider-master.target
-Before=data-provider-master.target
-
-[Install]
-WantedBy=sockets.target
diff --git a/data/data-provider-master-fd.socket b/data/data-provider-master-fd.socket
deleted file mode 100644 (file)
index f79e6c4..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-[Socket]
-SocketUser=system
-SocketGroup=system
-ListenStream=/tmp/.data-provider-master-fd.socket
-SocketMode=0666
-
-Service=data-provider-master.service
-
-[Unit]
-Wants=data-provider-master.target
-Before=data-provider-master.target
-
-[Install]
-WantedBy=sockets.target
diff --git a/data/data-provider-master-notification.socket b/data/data-provider-master-notification.socket
deleted file mode 100644 (file)
index 051b1d7..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-[Socket]
-SocketUser=system
-SocketGroup=system
-ListenStream=/tmp/.notification.service
-SocketMode=0666
-
-Service=data-provider-master.service
-
-[Unit]
-Wants=data-provider-master.target
-Before=data-provider-master.target
-
-[Install]
-WantedBy=sockets.target
diff --git a/data/data-provider-master-provider.socket b/data/data-provider-master-provider.socket
deleted file mode 100644 (file)
index 296f1ea..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-[Socket]
-SocketUser=system
-SocketGroup=system
-ListenStream=/tmp/.data-provider-master-slave.socket
-SocketMode=0666
-
-Service=data-provider-master.service
-
-[Unit]
-Wants=data-provider-master.target
-Before=data-provider-master.target
-
-[Install]
-WantedBy=sockets.target
diff --git a/data/data-provider-master-service.socket b/data/data-provider-master-service.socket
deleted file mode 100644 (file)
index bc9bb43..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-[Socket]
-SocketUser=system
-SocketGroup=system
-ListenStream=/tmp/.data-provider-master-service.socket
-SocketMode=0666
-
-Service=data-provider-master.service
-
-[Unit]
-Wants=data-provider-master.target
-Before=data-provider-master.target
-
-[Install]
-WantedBy=sockets.target
diff --git a/data/data-provider-master-shortcut.socket b/data/data-provider-master-shortcut.socket
deleted file mode 100644 (file)
index bb99196..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-[Socket]
-SocketUser=system
-SocketGroup=system
-ListenStream=/tmp/.shortcut.service
-SocketMode=0666
-
-Service=data-provider-master.service
-
-[Unit]
-Wants=data-provider-master.target
-Before=data-provider-master.target
-
-[Install]
-WantedBy=sockets.target
diff --git a/data/data-provider-master-utility.socket b/data/data-provider-master-utility.socket
deleted file mode 100644 (file)
index 90e381c..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-[Socket]
-SocketUser=system
-SocketGroup=system
-ListenStream=/tmp/.utility.service
-SocketMode=0666
-
-Service=data-provider-master.service
-
-[Unit]
-Wants=data-provider-master.target
-Before=data-provider-master.target
-
-[Install]
-WantedBy=sockets.target
diff --git a/data/data-provider-master.path b/data/data-provider-master.path
deleted file mode 100644 (file)
index deeeb85..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-[Unit]
-Description=Check the WM_READY file to launch the data-provider-master
-
-[Path]
-PathExists=/run/.wm_ready
diff --git a/data/data-provider-master.service b/data/data-provider-master.service
deleted file mode 100644 (file)
index 7d2f283..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Copyright 2013  Samsung Electronics Co., Ltd
-#
-# Licensed under the Flora License, Version 1.1 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://floralicense.org/license/
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-[Unit]
-Description=Data Provider daemon
-
-[Service]
-Environment=BUFMGR_LOCK_TYPE="once"
-Environment=BUFMGR_MAP_CACHE="true"
-EnvironmentFile=/run/tizen-system-env
-EnvironmentFile=/run/xdg-root-env
-Type=notify
-ExecStart=/usr/bin/data-provider-master
-RestartSec=1
-Restart=always
-MemoryLimit=50M
-
-[Install]
-WantedBy=default.target
diff --git a/data/data-provider-master.target b/data/data-provider-master.target
deleted file mode 100644 (file)
index cc07318..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-[Unit]
-Description=data-provider-master sockets
-DefaultDependencies=true
index ed49c9f..493d73d 100644 (file)
  * limitations under the License.
  */
 
+#include <gio/gio.h>
+
 extern int badge_service_init(void);
 extern int badge_service_fini(void);
 
+int badge_insert(GVariant *parameters, GVariant **reply_body);
+int badge_delete(GVariant *parameters, GVariant **reply_body);
+int badge_set_badge_count(GVariant *parameters, GVariant **reply_body);
+int badge_get_badge_count(GVariant *parameters, GVariant **reply_body);
+int badge_set_display_option(GVariant *parameters, GVariant **reply_body);
+int badge_get_display_option(GVariant *parameters, GVariant **reply_body);
+int badge_set_setting_property(GVariant *parameters, GVariant **reply_body);
+int badge_get_setting_property(GVariant *parameters, GVariant **reply_body);
+int badge_register_dbus_interface();
+
 /* End of a file */
old mode 100644 (file)
new mode 100755 (executable)
index bf52189..8cbb90a
@@ -17,9 +17,6 @@
 #define DELAY_TIME 0.0000001f
 #define HAPI __attribute__((visibility("hidden")))
 
-#if !defined(VCONFKEY_MASTER_STARTED)
-#define VCONFKEY_MASTER_STARTED        "memory/data-provider-master/started"
-#endif
 
 #if !defined(VCONFKEY_MASTER_RESTART_COUNT)
 #define VCONFKEY_MASTER_RESTART_COUNT  "memory/private/data-provider-master/restart_count"
index 717fb49..190994d 100644 (file)
  * limitations under the License.
  */
 
-#if !defined(FLOG)
 #define DbgPrint(format, arg...)       SECURE_LOGD(format, ##arg)
 #define ErrPrint(format, arg...)       SECURE_LOGE(format, ##arg)
 #define WarnPrint(format, arg...)      SECURE_LOGW(format, ##arg)
-#else
-extern FILE *__file_log_fp;
-#define DbgPrint(format, arg...) do { fprintf(__file_log_fp, "[LOG] [\e[32m%s/%s\e[0m:%d] " format, widget_util_basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0)
-#define ErrPrint(format, arg...) do { fprintf(__file_log_fp, "[ERR] [\e[32m%s/%s\e[0m:%d] " format, widget_util_basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0)
-#define WarnPrint(format, arg...) do { fprintf(__file_log_fp, "[WRN] [\e[32m%s/%s\e[0m:%d] " format, widget_util_basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0)
-#endif
-
-// DbgPrint("FREE\n");
-#define DbgFree(a) do { \
-       free(a); \
-} while (0)
-
-#define DbgXFree(a) do { \
-       DbgPrint("XFree\n"); \
-       XFree(a); \
-} while (0)
-
 
 #if defined(LOG_TAG)
 #undef LOG_TAG
@@ -42,31 +24,6 @@ extern FILE *__file_log_fp;
 
 #define LOG_TAG "DATA_PROVIDER_MASTER"
 
-#if defined(_ENABLE_PERF)
-#define PERF_INIT() \
-       struct timeval __stv; \
-       struct timeval __etv; \
-       struct timeval __rtv
-
-#define PERF_BEGIN() do { \
-       if (gettimeofday(&__stv, NULL) < 0) { \
-               ErrPrint("gettimeofday: %d\n", errno); \
-       } \
-} while (0)
-
-#define PERF_MARK(tag) do { \
-       if (gettimeofday(&__etv, NULL) < 0) { \
-               ErrPrint("gettimeofday: %d\n", errno); \
-       } \
-       timersub(&__etv, &__stv, &__rtv); \
-       DbgPrint("[%s] %u.%06u\n", tag, __rtv.tv_sec, __rtv.tv_usec); \
-} while (0)
-#else
-#define PERF_INIT()
-#define PERF_BEGIN()
-#define PERF_MARK(tag)
-#endif
-
 #define HAPI __attribute__((visibility("hidden")))
 
 /* End of a file */
index e02dfa3..213edf3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2013  Samsung Electronics Co., Ltd
+ * Copyright 2016  Samsung Electronics Co., Ltd
  *
  * Licensed under the Flora License, Version 1.1 (the "License");
  * you may not use this file except in compliance with the License.
  * limitations under the License.
  */
 
+#include <gio/gio.h>
+
 extern int notification_service_init(void);
 extern int notification_service_fini(void);
 
+int notification_server_register(GVariant *parameters, GVariant **reply_body);
+int notification_add_noti(GVariant *parameters, GVariant **reply_body);
+int notification_update_noti(GVariant *parameters, GVariant **reply_body);
+int notification_refresh_noti(GVariant *parameters, GVariant **reply_body);
+int notification_del_noti_single(GVariant *parameters, GVariant **reply_body);
+int notification_del_noti_multiple(GVariant *parameters, GVariant **reply_body);
+int notification_set_noti_property(GVariant *parameters, GVariant **reply_body);
+int notification_get_noti_property(GVariant *parameters, GVariant **reply_body);
+int notification_get_noti_count(GVariant *parameters, GVariant **reply_body);
+int notification_update_noti_setting(GVariant *parameters, GVariant **reply_body);
+int notification_update_noti_sys_setting(GVariant *parameters, GVariant **reply_body);
+int notification_load_noti_by_tag(GVariant *parameters, GVariant **reply_body);
+int notification_load_noti_by_priv_id(GVariant *parameters, GVariant **reply_body);
+int notification_load_grouping_list(GVariant *parameters, GVariant **reply_body);
+int notification_load_detail_list(GVariant *parameters, GVariant **reply_body);
+int notification_get_setting_array(GVariant *parameters, GVariant **reply_body);
+int notification_get_setting_by_package_name(GVariant *parameters, GVariant **reply_body);
+int notification_load_system_setting(GVariant *parameters, GVariant **reply_body);
+int notification_register_dbus_interface();
+
 /* End of a file */
index f4b22e6..28629c5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2013  Samsung Electronics Co., Ltd
+ * Copyright 2016  Samsung Electronics Co., Ltd
  *
  * Licensed under the Flora License, Version 1.1 (the "License");
  * you may not use this file except in compliance with the License.
  * limitations under the License.
  */
 
-#include <packet.h>
+#include <gio/gio.h>
+#include <notification.h>
+#include <badge.h>
+#include <shortcut.h>
+#include <stdlib.h>
 
-enum tcb_type {
-       TCB_CLIENT_TYPE_APP     = 0x00,
-       TCB_CLIENT_TYPE_SERVICE = 0x01,
-       TCB_CLIENT_TYPE_UNKNOWN = 0xff
-};
-
-enum tcb_event_type {
-       TCB_EVENT_CREATE = 0x01,
-       TCB_EVENT_DESTROY = 0x02
-};
+typedef enum {
+       NOTIFICATION_SERVICE = 0,
+       SHORTCUT_SERVICE,
+       BADGE_SERVICE,
+} service_type;
 
 enum service_common_error {
        SERVICE_COMMON_ERROR_NONE = 0,
@@ -39,45 +38,18 @@ enum service_common_error {
        SERVICE_COMMON_ERROR_ALREADY_EXIST = -8,
 };
 
-struct tcb;
-struct service_context;
-struct service_event_item;
-
-extern int tcb_fd(struct tcb *tcb);
-
-/*!
- * \remarks This function will return valid pid only after it gets the packet from a client.
- *          or it will returns -1.
- * \param[in] Thread Control Block
- * \return pid Process Id
- * \retval -1 TCB is not valid or the client is remote host. so we cannot get the PID of it.
- * \retval >0 Process Id (PID)
- */
-extern int tcb_pid(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 int tcb_is_valid(struct service_context *svc_ctx, struct tcb *tcb);
-
-extern struct service_context *service_common_create(const char *addr, const char *label, 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_destroy_tcb(struct service_context *svc_ctx, struct tcb *tcb);
-
-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);
-
-extern struct service_event_item *service_common_add_timer(struct service_context *svc_ctx, double timer, int (*timer_cb)(struct service_context *svc_cx, void *data), void *data);
-extern int service_common_update_timer(struct service_event_item *item, double timer);
-extern int service_common_del_timer(struct service_context *svc_ctx, struct service_event_item *item);
-
-extern int service_common_fd(struct service_context *ctx);
-
-extern int service_register_tcb_callback(struct service_context *svc_ctx, struct tcb *tcb, enum tcb_event_type event, void (*cb)(struct service_context *svc_ctx, struct tcb *tcb, void *data), void *data);
-extern int service_unregister_tcb_callback(struct service_context *svc_ctx, struct tcb *tcb, enum tcb_event_type event, void (*cb)(struct service_context *svc_ctx, struct tcb *tcb, void *data), void *data);
-
-extern int service_common_send_packet_to_service(struct service_context *svc_ctx, struct tcb *tcb, struct packet *packet);
-
-extern int service_check_privilege_by_socket_fd(struct service_context *svc_ctx, int socket_fd, char *privilege);
+typedef struct monitoring_info {
+       int watcher_id;
+       char *bus_name;
+} monitoring_info_s;
+
+void print_noti(notification_h noti);
+int send_notify(GVariant *body, char *cmd, GList *monitoring_app_list, char *interface_name);
+int service_register(GVariant *parameters, GVariant **reply_body, const gchar *sender,
+       GBusNameAppearedCallback name_appeared_handler,
+       GBusNameVanishedCallback name_vanished_handler,
+       GList **monitoring_list);
+GDBusConnection *service_common_get_connection();
+int service_common_register_dbus_interface(char *introspection_xml, GDBusInterfaceVTable interface_vtable);
 
 /* End of a file */
index 2810039..52f79c8 100644 (file)
  * limitations under the License.
  */
 
+#include <gio/gio.h>
+
 extern int shortcut_service_init(void);
 extern int shortcut_service_fini(void);
 
+int shortcut_add(GVariant *parameters, GVariant **reply_body);
+int shortcut_add_widget(GVariant *parameters, GVariant **reply_body);
+int shortcut_register_dbus_interface();
+
 /* End of a file */
diff --git a/org.tizen.data-provider-master.service.in b/org.tizen.data-provider-master.service.in
new file mode 100644 (file)
index 0000000..641d3bd
--- /dev/null
@@ -0,0 +1,5 @@
+[D-BUS Service]
+Name=org.tizen.data_provider_service
+Exec=/bin/false
+SystemdService=data-provider-master.service
+User=root
diff --git a/packaging/data-provider-master.service b/packaging/data-provider-master.service
new file mode 100644 (file)
index 0000000..8d7e2fb
--- /dev/null
@@ -0,0 +1,13 @@
+[Unit]
+Description=Data Provider Master
+
+[Service]
+BusName=org.tizen.data_provider_service
+Type=dbus
+ExecStart=/usr/bin/data-provider-master
+TimeoutStopSec=3s
+Restart=always
+RestartSec=0
+
+[Install]
+WantedBy=multi-user.target
index 3eab667..09fba9e 100755 (executable)
@@ -7,6 +7,7 @@ Release: 1
 Group: Applications/Core Applications
 License: Flora-1.1
 Source0: %{name}-%{version}.tar.gz
+Source1: data-provider-master.service
 Source1001: %{name}.manifest
 BuildRequires: cmake, gettext-tools, smack, coreutils
 BuildRequires: pkgconfig(dlog)
@@ -22,13 +23,11 @@ BuildRequires: pkgconfig(capi-appfw-app-manager)
 
 BuildRequires: pkgconfig(ecore)
 BuildRequires: pkgconfig(eina)
-BuildRequires: pkgconfig(com-core)
 BuildRequires: pkgconfig(libxml-2.0)
 BuildRequires: pkgconfig(pkgmgr)
 BuildRequires: pkgconfig(pkgmgr-info)
 BuildRequires: pkgconfig(notification)
 BuildRequires: pkgconfig(badge)
-BuildRequires: pkgconfig(badge-service)
 BuildRequires: pkgconfig(shortcut)
 BuildRequires: pkgconfig(security-server)
 BuildRequires: pkgconfig(libsystemd-daemon)
@@ -82,30 +81,22 @@ rm -rf %{buildroot}
 %make_install
 mkdir -p %{buildroot}/%{_datarootdir}/license
 mkdir -p %{buildroot}%{_prefix}/lib/systemd/system/multi-user.target.wants
+install -m 0644 %SOURCE1 %{buildroot}%{_unitdir}/data-provider-master.service
 ln -sf ../%{name}.service %{buildroot}%{_prefix}/lib/systemd/system/multi-user.target.wants/%{name}.service
-mkdir -p %{buildroot}/opt/usr/devel/usr/bin
-%pre
-# Executing the stop script for stopping the service of installed provider (old version)
-if [ -x %{_sysconfdir}/rc.d/init.d/%{name} ]; then
-       %{_sysconfdir}/rc.d/init.d/%{name} stop
-fi
 
 %post
 %files -n %{name}
 %manifest %{name}.manifest
-%defattr(-,system,system,-)
-#%caps(cap_chown,cap_dac_override,cap_dac_read_search,cap_sys_admin,cap_sys_nice+ep) %{_prefix}/bin/%{name}
-%{_prefix}/lib/systemd/system/multi-user.target.wants/%{name}.service
-%{_prefix}/lib/systemd/system/%{name}.service
-%{_prefix}/lib/systemd/system/%{name}.target
+%defattr(-,root,root,-)
+
+%attr(0755,root,root) %{_bindir}/data-provider-master
+%attr(0644,root,root) %{_unitdir}/data-provider-master.service
+%{_unitdir}/multi-user.target.wants/data-provider-master.service
+%attr(0644,root,root) %{_datadir}/dbus-1/system-services/org.tizen.data-provider-master.service
+%config %{_sysconfdir}/dbus-1/system.d/data-provider-master.conf
 %{_prefix}/bin/%{name}
-%{_prefix}/lib/systemd/system/%{name}-service.socket
-%{_prefix}/lib/systemd/system/%{name}-badge.socket
-%{_prefix}/lib/systemd/system/%{name}-notification.socket
-%{_prefix}/lib/systemd/system/%{name}-shortcut.socket
 %{_datarootdir}/license/*
 %if 0%{?tizen_build_binary_release_type_eng}
-/opt/usr/devel/usr/bin/*
 %endif
 #%defattr(-,owner,users,-)
 
old mode 100644 (file)
new mode 100755 (executable)
index 1636a33..c30f122
  * limitations under the License.
  */
 
-#include <stdio.h>
-
-#include <Eina.h>
-
 #include <dlog.h>
-#include <packet.h>
-
+#include <gio/gio.h>
 #include <sys/smack.h>
-
 #include <badge.h>
 #include <badge_db.h>
 #include <badge_setting_service.h>
+#include <badge_internal.h>
 
 #include "service_common.h"
+#include "badge_service.h"
 #include "debug.h"
-#include "util.h"
-#include "conf.h"
-
-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 */
-};
-
-#define ENABLE_BS_ACCESS_CONTROL 1
 
-struct context {
-       struct tcb *tcb;
-       double seq;
-};
+#define PROVIDER_BADGE_INTERFACE_NAME "org.tizen.data_provider_badge_service"
 
-struct badge_service {
-       const char *cmd;
-       void (*handler)(struct tcb *tcb, struct packet *packet, void *data);
-       const char *rule;
-       const char *access;
-};
+static GList *_monitoring_list = NULL;
 
-/*!
- * FUNCTIONS to handle badge
- */
-static inline char *get_string(char *string)
+static void _on_name_appeared(GDBusConnection *connection,
+               const gchar     *name,
+               const gchar     *name_owner,
+               gpointer         user_data)
 {
-       if (string == NULL)
-               return NULL;
-       if (string[0] == '\0')
-               return NULL;
-
-       return string;
+       DbgPrint("name appeared : %s", name);
 }
 
-/*!
- * SERVICE HANDLER
- */
-static void _handler_insert_badge(struct tcb *tcb, struct packet *packet, void *data)
+static void _on_name_vanished(GDBusConnection *connection,
+               const gchar     *name,
+               gpointer         user_data)
 {
-       int ret = 0, ret_p = 0;
-       struct packet *packet_reply = NULL;
-       struct packet *packet_service = NULL;
-       char *pkgname = NULL;
-       char *writable_pkg = NULL;
-       char *caller = NULL;
+       DbgPrint("name vanished : %s", name);
+       monitoring_info_s *info = (monitoring_info_s *)user_data;
 
-       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_PARAMETER;
-
-               packet_reply = packet_create_reply(packet, "i", ret);
-               if (packet_reply) {
-                       if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
-                               ErrPrint("Failed to send a reply packet:%d", ret_p);
-                       packet_destroy(packet_reply);
-               } else {
-                       ErrPrint("Failed to create a reply packet");
-               }
+       if (info) {
+               g_bus_unwatch_name(info->watcher_id);
 
-               if (ret == BADGE_ERROR_NONE) {
-                       packet_service = packet_create("insert_badge", "is", ret, pkgname);
-                       if (packet_service != NULL) {
-                               if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0)
-                                       ErrPrint("Failed to send a muticast packet:%d", ret_p);
-                               packet_destroy(packet_service);
-                       } else {
-                               ErrPrint("Failed to create a multicast packet");
-                       }
-               } else {
-                       ErrPrint("Failed to insert a badge:%d", ret);
+               if (info->bus_name) {
+                       _monitoring_list = g_list_remove(_monitoring_list, info->bus_name);
+                       free(info->bus_name);
                }
+               free(info);
+       }
+}
+
+static void _badge_dbus_method_call_handler(GDBusConnection *conn,
+               const gchar *sender, const gchar *object_path,
+               const gchar *iface_name, const gchar *method_name,
+               GVariant *parameters, GDBusMethodInvocation *invocation,
+               gpointer user_data)
+{
+       /* TODO : sender authority(privilege) check */
+       DbgPrint("badge method_name: %s", method_name);
+
+       GVariant *reply_body = NULL;
+       int ret = BADGE_ERROR_INVALID_PARAMETER;
+
+       if (g_strcmp0(method_name, "badge_service_register") == 0)
+               ret = service_register(parameters, &reply_body, sender,
+                _on_name_appeared, _on_name_vanished, &_monitoring_list);
+       else if (g_strcmp0(method_name, "insert_badge") == 0)
+               ret = badge_insert(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "delete_badge") == 0)
+               ret = badge_delete(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "set_badge_count") == 0)
+               ret = badge_set_badge_count(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "get_badge_count") == 0)
+               ret = badge_get_badge_count(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "set_disp_option") == 0)
+               ret = badge_set_display_option(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "get_disp_option") == 0)
+               ret = badge_get_display_option(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "set_noti_property") == 0)
+               ret = badge_set_setting_property(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "get_noti_property") == 0)
+               ret = badge_get_setting_property(parameters, &reply_body);
+
+       if (ret == BADGE_ERROR_NONE) {
+               DbgPrint("badge service success : %d", ret);
+               g_dbus_method_invocation_return_value(
+                               invocation, reply_body);
        } else {
-               ErrPrint("Failed to get data from the packet");
+               DbgPrint("badge service fail : %d", ret);
+               g_dbus_method_invocation_return_error(
+                               invocation,
+                               BADGE_ERROR,
+                               ret,
+                               "badge service error");
        }
 }
 
-static void _handler_delete_badge(struct tcb *tcb, struct packet *packet, void *data)
+static const GDBusInterfaceVTable _badge_interface_vtable = {
+               _badge_dbus_method_call_handler,
+               NULL,
+               NULL
+};
+
+int badge_register_dbus_interface()
+{
+       static gchar introspection_xml[] =
+                       "  <node>"
+                       "  <interface name='org.tizen.data_provider_badge_service'>"
+                       "        <method name='badge_service_register'>"
+                       "        </method>"
+
+                       "        <method name='insert_badge'>"
+                       "          <arg type='s' name='pkgname' direction='in'/>"
+                       "          <arg type='s' name='writable_pkg' direction='in'/>"
+                       "          <arg type='s' name='caller' direction='in'/>"
+                       "        </method>"
+
+                       "        <method name='delete_badge'>"
+                       "          <arg type='s' name='pkgname' direction='in'/>"
+                       "          <arg type='s' name='caller' direction='in'/>"
+                       "        </method>"
+
+                       "        <method name='set_badge_count'>"
+                       "          <arg type='s' name='pkgname' direction='in'/>"
+                       "          <arg type='s' name='caller' direction='in'/>"
+                       "          <arg type='i' name='count' direction='in'/>"
+                       "        </method>"
+
+                       "        <method name='get_badge_count'>"
+                       "          <arg type='s' name='pkgname' direction='in'/>"
+                       "          <arg type='i' name='count' direction='out'/>"
+                       "        </method>"
+
+                       "        <method name='set_disp_option'>"
+                       "          <arg type='s' name='pkgname' direction='in'/>"
+                       "          <arg type='s' name='caller' direction='in'/>"
+                       "          <arg type='i' name='is_display' direction='in'/>"
+                       "        </method>"
+
+                       "        <method name='get_disp_option'>"
+                       "          <arg type='s' name='pkgname' direction='in'/>"
+                       "          <arg type='i' name='is_display' direction='out'/>"
+                       "        </method>"
+
+                       "        <method name='set_noti_property'>"
+                       "          <arg type='s' name='pkgname' direction='in'/>"
+                       "          <arg type='s' name='property' direction='in'/>"
+                       "          <arg type='s' name='value' direction='in'/>"
+                       "        </method>"
+
+                       "        <method name='get_noti_property'>"
+                       "          <arg type='s' name='pkgname' direction='in'/>"
+                       "          <arg type='s' name='property' direction='in'/>"
+                       "          <arg type='s' name='value' direction='out'/>"
+                       "        </method>"
+                       "  </interface>"
+                       "  </node>";
+
+       return service_common_register_dbus_interface(introspection_xml, _badge_interface_vtable);
+}
+
+/* insert_badge */
+int badge_insert(GVariant *parameters, GVariant **reply_body)
 {
-       int ret = 0, ret_p = 0;
-       struct packet *packet_reply = NULL;
-       struct packet *packet_service = NULL;
+       int ret = BADGE_ERROR_NONE;
        char *pkgname = NULL;
+       char *writable_pkg = NULL;
        char *caller = NULL;
+       GVariant *body = NULL;
 
-       if (packet_get(packet, "ss", &pkgname, &caller) == 2) {
-               pkgname = get_string(pkgname);
-               caller = get_string(caller);
+       g_variant_get(parameters, "(&s&s&s)", &pkgname, &writable_pkg, &caller);
+       if (pkgname != NULL && writable_pkg != NULL && caller != NULL)
+               ret = badge_db_insert(pkgname, writable_pkg, caller);
+       else
+               return BADGE_ERROR_INVALID_PARAMETER;
 
-               if (pkgname != NULL && caller != NULL) {
-                       if (service_check_privilege_by_socket_fd(tcb_svc_ctx(tcb), tcb_fd(tcb), "http://tizen.org/privilege/notification") == 1)
-                               ret = badge_db_delete(pkgname, pkgname);
-                       else
-                               ret = badge_db_delete(pkgname, caller);
-               } else {
-                       ret = BADGE_ERROR_INVALID_PARAMETER;
-               }
+       if (ret != BADGE_ERROR_NONE) {
+               ErrPrint("failed to insert badge :%d\n", ret);
+               return ret;
+       }
 
-               packet_reply = packet_create_reply(packet, "i", ret);
-               if (packet_reply) {
-                       if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
-                               ErrPrint("Failed to send a reply packet:%d", ret_p);
-                       packet_destroy(packet_reply);
-               } else {
-                       ErrPrint("Failed to create a reply packet");
-               }
+       body = g_variant_new("(s)", pkgname);
+       if (body == NULL) {
+               ErrPrint("cannot make gvariant to noti");
+               return BADGE_ERROR_OUT_OF_MEMORY;
+       }
 
-               if (ret == BADGE_ERROR_NONE) {
-                       packet_service = packet_create("delete_badge", "is", ret, pkgname);
-                       if (packet_service != NULL) {
-                               if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0)
-                                       ErrPrint("Failed to send a muticast packet:%d", ret_p);
-                               packet_destroy(packet_service);
-                       } else {
-                               ErrPrint("Failed to create a multicast packet");
-                       }
-               } else {
-                       ErrPrint("Failed to delete a badge:%d", ret);
-               }
-       } else {
-               ErrPrint("Failed to get data from the packet");
+       ret = send_notify(body, "insert_badge_notify", _monitoring_list, PROVIDER_BADGE_INTERFACE_NAME);
+       g_variant_unref(body);
+
+       if (ret != BADGE_ERROR_NONE) {
+               ErrPrint("failed to send notify:%d\n", ret);
+               return ret;
        }
+
+       *reply_body = g_variant_new("()");
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make gvariant to noti");
+               return BADGE_ERROR_OUT_OF_MEMORY;
+       }
+
+       return ret;
 }
 
-static void _handler_set_badge_count(struct tcb *tcb, struct packet *packet, void *data)
+/* delete_badge */
+int badge_delete(GVariant *parameters, GVariant **reply_body)
 {
-       int ret = 0, ret_p = 0;
-       struct packet *packet_reply = NULL;
-       struct packet *packet_service = NULL;
+       int ret = BADGE_ERROR_NONE;
        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_PARAMETER;
-
-               packet_reply = packet_create_reply(packet, "i", ret);
-               if (packet_reply) {
-                       if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
-                               ErrPrint("Failed to send a reply packet:%d", ret_p);
-                       packet_destroy(packet_reply);
-               } else {
-                       ErrPrint("Failed to create a reply packet");
-               }
+       GVariant *body = NULL;
 
-               if (ret == BADGE_ERROR_NONE) {
-                       packet_service = packet_create("set_badge_count", "isi", ret, pkgname, count);
-                       if (packet_service != NULL) {
-                               if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0)
-                                       ErrPrint("Failed to send a muticast packet:%d", ret_p);
-                               packet_destroy(packet_service);
-                       } else {
-                               ErrPrint("Failed to create a multicast packet");
-                       }
-               } else {
-                       ErrPrint("Failed to set count of badge:%d", ret);
-               }
+       g_variant_get(parameters, "(&s&s)", &pkgname, &caller);
+       if (pkgname != NULL && caller != NULL) {
+               ret = badge_db_delete(pkgname, caller);
        } else {
-               ErrPrint("Failed to get data from the packet");
+               return BADGE_ERROR_INVALID_PARAMETER;
+       }
+
+       if (ret != BADGE_ERROR_NONE) {
+               ErrPrint("failed to delete badge :%d\n", ret);
+               return ret;
        }
+
+       body = g_variant_new("(s)", pkgname);
+       if (body == NULL) {
+               ErrPrint("cannot make gvariant to noti");
+               return BADGE_ERROR_OUT_OF_MEMORY;
+       }
+       ret = send_notify(body, "delete_badge_notify", _monitoring_list, PROVIDER_BADGE_INTERFACE_NAME);
+       g_variant_unref(body);
+
+       if (ret != BADGE_ERROR_NONE) {
+               ErrPrint("failed to send notify:%d\n", ret);
+               return ret;
+       }
+
+       *reply_body = g_variant_new("()");
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make gvariant to noti");
+               return BADGE_ERROR_OUT_OF_MEMORY;
+       }
+       return ret;
 }
 
-static void _handler_set_display_option(struct tcb *tcb, struct packet *packet, void *data)
+/* set_badge_count */
+int badge_set_badge_count(GVariant *parameters, GVariant **reply_body)
 {
-       int ret = 0, ret_p = 0;
-       struct packet *packet_reply = NULL;
-       struct packet *packet_service = NULL;
+       int ret = BADGE_ERROR_NONE;
        char *pkgname = NULL;
        char *caller = NULL;
-       int is_display = 0;
+       unsigned int count = 0;
+       GVariant *body = NULL;
+
+       g_variant_get(parameters, "(&s&si)", &pkgname, &caller, &count);
+       if (pkgname != NULL && caller != NULL)
+               ret = badge_db_set_count(pkgname, caller, count);
+       else
+               return BADGE_ERROR_INVALID_PARAMETER;
+
+       if (ret != BADGE_ERROR_NONE) {
+               ErrPrint("failed to set badge :%d\n", ret);
+               return ret;
+       }
 
-       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_PARAMETER;
-
-               packet_reply = packet_create_reply(packet, "i", ret);
-               if (packet_reply) {
-                       if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
-                               ErrPrint("Failed to send a reply packet:%d", ret_p);
-                       packet_destroy(packet_reply);
-               } else {
-                       ErrPrint("Failed to create a reply packet");
-               }
+       body = g_variant_new("(si)", pkgname, count);
+       if (body == NULL) {
+               ErrPrint("cannot make gvariant to noti");
+               return BADGE_ERROR_OUT_OF_MEMORY;
+       }
 
-               if (ret == BADGE_ERROR_NONE) {
-                       packet_service = packet_create("set_disp_option", "isi", ret, pkgname, is_display);
-                       if (packet_service != NULL) {
-                               if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0)
-                                       ErrPrint("Failed to send a muticast packet:%d", ret_p);
-                               packet_destroy(packet_service);
-                       } else {
-                               ErrPrint("Failed to create a multicast packet");
-                       }
-               } else {
-                       ErrPrint("Failed to set display option of badge:%d", ret);
-               }
-       } else {
-               ErrPrint("Failed to get data from the packet");
+       ret = send_notify(body, "set_badge_count_notify", _monitoring_list, PROVIDER_BADGE_INTERFACE_NAME);
+       g_variant_unref(body);
+
+       if (ret != BADGE_ERROR_NONE) {
+               ErrPrint("failed to send notify:%d\n", ret);
+               return ret;
        }
+       DbgPrint("send badge count notify done ret : %d", ret);
+
+       *reply_body = g_variant_new("()");
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make gvariant to noti");
+               return BADGE_ERROR_OUT_OF_MEMORY;
+       }
+       return ret;
 }
 
-static void _handler_set_setting_property(struct tcb *tcb, struct packet *packet, void *data)
+/* get_badge_count */
+int badge_get_badge_count(GVariant *parameters, GVariant **reply_body)
 {
-       int ret = 0, ret_p = 0;
-       int is_display = 0;
-       struct packet *packet_reply = NULL;
-       struct packet *packet_service = NULL;
+       int ret = BADGE_ERROR_NONE;
        char *pkgname = NULL;
-       char *property = NULL;
-       char *value = NULL;
+       unsigned int count = 0;
 
-       if (packet_get(packet, "sss", &pkgname, &property, &value) == 3) {
-               pkgname = get_string(pkgname);
-               property = get_string(property);
-               value = get_string(value);
-
-               if (pkgname != NULL && property != NULL && value != NULL)
-                       ret = badge_setting_db_set(pkgname, property, value);
-               else
-                       ret = BADGE_ERROR_INVALID_PARAMETER;
-
-               packet_reply = packet_create_reply(packet, "ii", ret, ret);
-               if (packet_reply) {
-                       if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
-                               ErrPrint("failed to send reply packet:%d\n", ret_p);
-                       packet_destroy(packet_reply);
-               } else {
-                       ErrPrint("failed to create a reply packet\n");
-               }
+       g_variant_get(parameters, "(&s)", &pkgname);
+       if (pkgname != NULL)
+               ret =  badge_db_get_count(pkgname, &count);
+       else
+               return BADGE_ERROR_INVALID_PARAMETER;
 
-               if (ret == BADGE_ERROR_NONE) {
-                       if (strcmp(property, "OPT_BADGE") == 0) {
-                               if (strcmp(value, "ON") == 0)
-                                       is_display = 1;
-                               else
-                                       is_display = 0;
-
-                               packet_service = packet_create("set_disp_option", "isi", ret, pkgname, is_display);
-                               if (packet_service != NULL) {
-                                       if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0)
-                                               ErrPrint("Failed to send a muticast packet:%d", ret_p);
-                                       packet_destroy(packet_service);
-                               } else {
-                                       ErrPrint("Failed to create a multicast packet");
-                               }
-                       }
-               } else {
-                       ErrPrint("failed to set noti property:%d\n", ret);
-               }
-       } else {
-               ErrPrint("Failed to get data from the packet");
+       if (ret != BADGE_ERROR_NONE) {
+               ErrPrint("failed to get badge count :%d\n", ret);
+               return ret;
+       }
+
+       *reply_body = g_variant_new("(i)", count);
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make gvariant to noti");
+               return BADGE_ERROR_OUT_OF_MEMORY;
        }
+       DbgPrint("badge_get_badge_count service done");
+       return ret;
 }
 
-static void _handler_get_setting_property(struct tcb *tcb, struct packet *packet, void *data)
+/* set_disp_option */
+int badge_set_display_option(GVariant *parameters, GVariant **reply_body)
 {
-       int ret = 0, ret_p = 0;
-       struct packet *packet_reply = NULL;
+       int ret = BADGE_ERROR_NONE;
        char *pkgname = NULL;
-       char *property = NULL;
-       char *value = NULL;
+       char *caller = NULL;
+       unsigned int is_display = 0;
+       GVariant *body = NULL;
 
-       if (packet_get(packet, "sss", &pkgname, &property) == 2) {
-               pkgname = get_string(pkgname);
-               property = get_string(property);
-
-               if (pkgname != NULL && property != NULL)
-                       ret = badge_setting_db_get(pkgname, property, &value);
-               else
-                       ret = BADGE_ERROR_INVALID_PARAMETER;
-
-               packet_reply = packet_create_reply(packet, "is", ret, value);
-               if (packet_reply) {
-                       if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
-                               ErrPrint("failed to send reply packet:%d\n", ret_p);
-                       packet_destroy(packet_reply);
-               } else {
-                       ErrPrint("failed to create a reply packet\n");
-               }
+       g_variant_get(parameters, "(&s&si)", &pkgname, &caller, &is_display);
+       DbgPrint("set disp option : %s, %s, %d", pkgname, caller, is_display);
 
-               if (value != NULL)
-                       DbgFree(value);
+       if (pkgname != NULL && caller != NULL)
+               ret = badge_db_set_display_option(pkgname, caller, is_display);
+       else
+               return BADGE_ERROR_INVALID_PARAMETER;
+
+       if (ret != BADGE_ERROR_NONE) {
+               ErrPrint("failed to set display option :%d\n", ret);
+               return ret;
        }
-}
 
-static void _handler_service_register(struct tcb *tcb, struct packet *packet, void *data)
-{
-       int ret = 0;
-       struct packet *packet_reply;
+       body = g_variant_new("(si)", pkgname, is_display);
+       if (body == NULL) {
+               ErrPrint("cannot make gvariant to noti");
+               return BADGE_ERROR_OUT_OF_MEMORY;
+       }
 
-       ret = tcb_client_type_set(tcb, TCB_CLIENT_TYPE_SERVICE);
-       if (ret < 0)
-               ErrPrint("Failed to set the type of client:%d", ret);
+       ret = send_notify(body, "set_disp_option_notify", _monitoring_list, PROVIDER_BADGE_INTERFACE_NAME);
+       g_variant_unref(body);
 
-       packet_reply = packet_create_reply(packet, "i", ret);
-       if (packet_reply) {
-               if ((ret = service_common_unicast_packet(tcb, packet_reply)) < 0)
-                       ErrPrint("Failed to send a reply packet:%d", ret);
-               packet_destroy(packet_reply);
-       } else {
-               ErrPrint("Failed to create a reply packet");
+       if (ret != BADGE_ERROR_NONE) {
+               ErrPrint("failed to send notify:%d\n", ret);
+               return ret;
+       }
+
+       *reply_body = g_variant_new("()");
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make gvariant to noti");
+               return BADGE_ERROR_OUT_OF_MEMORY;
        }
+       DbgPrint("set disp option done %d", ret);
+       return ret;
 }
 
-static void _handler_access_control_error(struct tcb *tcb, struct packet *packet)
+/* get_disp_option */
+int badge_get_display_option(GVariant *parameters, GVariant **reply_body)
 {
-       int ret_p = 0;
-       struct packet *packet_reply = NULL;
-
-       packet_reply = packet_create_reply(packet, "i", BADGE_ERROR_PERMISSION_DENIED);
-       if (packet_reply) {
-               if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
-                       ErrPrint("Failed to send a reply packet:%d", ret_p);
-               packet_destroy(packet_reply);
-       } else {
-               ErrPrint("Failed to create a reply packet");
+       int ret = BADGE_ERROR_NONE;
+       char *pkgname = NULL;
+       unsigned int is_display = 0;
+
+       g_variant_get(parameters, "(&s)", &pkgname);
+       DbgPrint("get disp option : %s", pkgname);
+
+       if (pkgname != NULL)
+               ret = badge_db_get_display_option(pkgname, &is_display);
+       else
+               return BADGE_ERROR_INVALID_PARAMETER;
+
+       if (ret != BADGE_ERROR_NONE) {
+               ErrPrint("failed to get display option :%d\n", ret);
+               return ret;
+       }
+
+       *reply_body = g_variant_new("(i)", is_display);
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make gvariant to noti");
+               return BADGE_ERROR_OUT_OF_MEMORY;
        }
+       return ret;
 }
 
-/*!
- * SERVICE THREAD
- */
-static int service_thread_main(struct tcb *tcb, struct packet *packet, void *data)
+/* set_noti_property */
+int badge_set_setting_property(GVariant *parameters, GVariant **reply_body)
 {
-       int i = 0;
-       const char *command;
-       static struct badge_service service_req_table[] = {
-               {
-                       .cmd = "insert_badge",
-                       .handler = _handler_insert_badge,
-                       .rule = "data-provider-master::badge.client",
-                       .access = "w",
-               },
-               {
-                       .cmd = "delete_badge",
-                       .handler = _handler_delete_badge,
-                       .rule = "data-provider-master::badge.client",
-                       .access = "w",
-               },
-               {
-                       .cmd = "set_badge_count",
-                       .handler = _handler_set_badge_count,
-                       .rule = "data-provider-master::badge.client",
-                       .access = "w",
-               },
-               {
-                       .cmd = "set_disp_option",
-                       .handler = _handler_set_display_option,
-                       .rule = "data-provider-master::badge.client",
-                       .access = "w",
-               },
-               {
-                       .cmd = "set_noti_property",
-                       .handler = _handler_set_setting_property,
-                       .rule = "data-provider-master::badge.client",
-                       .access = "w",
-               },
-               {
-                       .cmd = "get_noti_property",
-                       .handler = _handler_get_setting_property,
-                       .rule = "data-provider-master::badge.client",
-                       .access = "r",
-               },
-               {
-                       .cmd = "service_register",
-                       .handler = _handler_service_register,
-                       .rule = NULL,
-                       .access = NULL,
-               },
-               {
-                       .cmd = NULL,
-                       .handler = NULL,
-                       .rule = NULL,
-                       .access = NULL,
-               },
-       };
-
-       if (!packet) {
-               DbgPrint("TCB: %p is terminated (NIL packet)\n", tcb);
-               return 0;
-       }
+       int ret = 0;
+       int is_display = 0;
+       char *pkgname = NULL;
+       char *property = NULL;
+       char *value = NULL;
+       GVariant *body = NULL;
 
-       command = packet_command(packet);
-       if (!command) {
-               ErrPrint("Invalid command\n");
-               return -EINVAL;
+       g_variant_get(parameters, "(&s&s&s)", &pkgname, &property, &value);
+       if (pkgname != NULL && property != NULL && value != NULL)
+               ret = badge_setting_db_set(pkgname, property, value);
+       else
+               return BADGE_ERROR_INVALID_PARAMETER;
+
+       if (ret != BADGE_ERROR_NONE) {
+               ErrPrint("failed to setting db set :%d\n", ret);
+               return ret;
        }
-       DbgPrint("Command: [%s], Packet type[%d]\n", command, packet_type(packet));
-
-       switch (packet_type(packet)) {
-       case PACKET_REQ:
-               /* Need to send reply packet */
-               for (i = 0; service_req_table[i].cmd; i++) {
-                       if (strcmp(service_req_table[i].cmd, command))
-                               continue;
-
-#if ENABLE_BS_ACCESS_CONTROL
-                       if (service_check_privilege_by_socket_fd(tcb_svc_ctx(tcb), tcb_fd(tcb), "http://tizen.org/privilege/notification") == 1)
-                               service_req_table[i].handler(tcb, packet, data);
+
+       if (ret == BADGE_ERROR_NONE) {
+               if (strcmp(property, "OPT_BADGE") == 0) {
+                       if (strcmp(value, "ON") == 0)
+                               is_display = 1;
                        else
-                               _handler_access_control_error(tcb, packet);
-#else
-                       service_check_privilege_by_socket_fd(tcb_svc_ctx(tcb), tcb_fd(tcb), "http://tizen.org/privilege/notification");
-                       service_req_table[i].handler(tcb, packet, data);
-#endif
-                       break;
-               }
+                               is_display = 0;
 
-               break;
-       case PACKET_REQ_NOACK:
-               break;
-       case PACKET_ACK:
-               break;
-       default:
-               ErrPrint("Packet type is not valid[%s]\n", command);
-               return -EINVAL;
+                       body = g_variant_new("(si)", pkgname, is_display);
+                       if (body == NULL) {
+                               ErrPrint("cannot make gvariant to noti");
+                               return BADGE_ERROR_OUT_OF_MEMORY;
+                       }
+                       ret = send_notify(body, "set_disp_option_notify", _monitoring_list, PROVIDER_BADGE_INTERFACE_NAME);
+                       g_variant_unref(body);
+                       if (ret != BADGE_ERROR_NONE) {
+                               ErrPrint("failed to send notify:%d\n", ret);
+                               return ret;
+                       }
+               }
+       } else {
+               ErrPrint("failed to set noti property:%d\n", ret);
        }
 
-       /*!
-        * return value has no meanning,
-        * it will be printed by dlogutil.
-        */
-       return 0;
+       *reply_body = g_variant_new("()");
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make gvariant to noti");
+               return BADGE_ERROR_OUT_OF_MEMORY;
+       }
+       return ret;
 }
 
+/* get_noti_property */
+int badge_get_setting_property(GVariant *parameters, GVariant **reply_body)
+{
+       int ret = 0;
+       char *pkgname = NULL;
+       char *property = NULL;
+       char *value = NULL;
+
+       g_variant_get(parameters, "(&s&s)", &pkgname, &property);
+       if (pkgname != NULL && property != NULL)
+               ret = badge_setting_db_get(pkgname, property, &value);
+       else
+               return BADGE_ERROR_INVALID_PARAMETER;
+
+       if (ret != BADGE_ERROR_NONE) {
+               ErrPrint("failed to setting db get :%d\n", ret);
+               return ret;
+       }
+
+       *reply_body = g_variant_new("(s)", value);
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make gvariant to noti");
+               return BADGE_ERROR_OUT_OF_MEMORY;
+       }
+       return ret;
+}
 
 /*!
  * MAIN THREAD
@@ -481,30 +478,19 @@ static int service_thread_main(struct tcb *tcb, struct packet *packet, void *dat
  */
 HAPI int badge_service_init(void)
 {
-       if (s_info.svc_ctx) {
-               ErrPrint("Already initialized\n");
-               return SERVICE_COMMON_ERROR_ALREADY_STARTED;
-       }
+       int result;
 
-       s_info.svc_ctx = service_common_create(BADGE_SOCKET, BADGE_SMACK_LABEL, service_thread_main, NULL);
-       if (!s_info.svc_ctx) {
-               ErrPrint("Unable to activate service thread\n");
-               return SERVICE_COMMON_ERROR_FAULT;
+       result = badge_register_dbus_interface();
+       if(result != SERVICE_COMMON_ERROR_NONE) {
+               ErrPrint("badge register dbus fail %d", result);
        }
 
-       DbgPrint("Successfully initiated\n");
-       return SERVICE_COMMON_ERROR_NONE;
+       return result;
 }
 
 HAPI int badge_service_fini(void)
 {
-       if (!s_info.svc_ctx)
-               return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
-
-       service_common_destroy(s_info.svc_ctx);
-       s_info.svc_ctx = NULL;
-       DbgPrint("Successfully finalized\n");
-       return SERVICE_COMMON_ERROR_NONE;
+       return BADGE_ERROR_NONE;
 }
 
 /* End of a file */
index 2bcd507..bb981b5 100644 (file)
@@ -73,7 +73,7 @@ static inline void rotate_log(void)
                if (!s_info.fp)
                        ErrPrint("Failed to open a file: %s\n", filename);
 
-               DbgFree(filename);
+               free(filename);
        }
 
        s_info.nr_of_lines = 0;
@@ -127,7 +127,7 @@ HAPI int critical_log_init(const char *name)
        filename = malloc(namelen);
        if (!filename) {
                ErrPrint("Failed to create a log file\n");
-               DbgFree(s_info.filename);
+               free(s_info.filename);
                s_info.filename = NULL;
                return SERVICE_COMMON_ERROR_OUT_OF_MEMORY;
        }
@@ -137,13 +137,13 @@ HAPI int critical_log_init(const char *name)
        s_info.fp = fopen(filename, "w+");
        if (!s_info.fp) {
                ErrPrint("fopen: %d\n", errno);
-               DbgFree(s_info.filename);
+               free(s_info.filename);
                s_info.filename = NULL;
-               DbgFree(filename);
+               free(filename);
                return SERVICE_COMMON_ERROR_IO_ERROR;
        }
 
-       DbgFree(filename);
+       free(filename);
        return SERVICE_COMMON_ERROR_NONE;
 }
 
@@ -152,7 +152,7 @@ HAPI int critical_log_init(const char *name)
 HAPI void critical_log_fini(void)
 {
        if (s_info.filename) {
-               DbgFree(s_info.filename);
+               free(s_info.filename);
                s_info.filename = NULL;
        }
 
index 602a5d9..6043a46 100644 (file)
 
 #include <systemd/sd-daemon.h>
 
-#include <Ecore.h>
 #include <glib.h>
 #include <glib-object.h>
 #include <aul.h>
 #include <vconf.h>
-
-#include <packet.h>
+#include <Ecore.h>
 #include <dlog.h>
 
-#include "conf.h"
-#include "util.h"
 #include "debug.h"
+#include "util.h"
 #include "critical_log.h"
+#include "service_common.h"
 #include "shortcut_service.h"
 #include "notification_service.h"
 #include "badge_service.h"
@@ -108,7 +106,6 @@ static Eina_Bool signal_cb(void *data, Ecore_Fd_Handler *handler)
                if (cfd < 0 || close(cfd) < 0)
                        ErrPrint("stop.provider: %d\n", errno);
 
-               vconf_set_bool(VCONFKEY_MASTER_STARTED, 0);
                ecore_main_loop_quit();
        } else {
                CRITICAL_LOG("Unknown SIG[%d] received\n", fdsi.ssi_signo);
@@ -170,9 +167,7 @@ int main(int argc, char *argv[])
        restart_count++;
        vconf_set_int(VCONFKEY_MASTER_RESTART_COUNT, restart_count);
 
-       vconf_set_bool(VCONFKEY_MASTER_STARTED, 1);
        ecore_main_loop_begin();
-       vconf_set_bool(VCONFKEY_MASTER_STARTED, 0);
 
        app_terminate();
 
old mode 100644 (file)
new mode 100755 (executable)
index 769ca9e..14adacb
  * limitations under the License.
  */
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
 
-#include <Eina.h>
-
 #include <dlog.h>
-#include <packet.h>
-
 #include <sys/smack.h>
 
 #include <pkgmgr-info.h>
 
-#include <vconf.h>
 #include <notification.h>
+#include <gio/gio.h>
 
 #include "pkgmgr.h"
 #include "service_common.h"
+#include "notification_service.h"
 #include "debug.h"
-#include "util.h"
-#include "conf.h"
+
 
 #include <notification_noti.h>
 #include <notification_internal.h>
 #include <notification_ipc.h>
 #include <notification_setting_service.h>
 
-#ifndef NOTIFICATION_DEL_PACKET_UNIT
-#define NOTIFICATION_DEL_PACKET_UNIT 10
-#endif
+#define PROVIDER_NOTI_INTERFACE_NAME "org.tizen.data_provider_noti_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 */
-};
+static GList *_monitoring_list = NULL;
 
-struct context {
-       struct tcb *tcb;
-       double seq;
-};
+static int _update_noti(GVariant **reply_body, notification_h noti);
 
-struct noti_service {
-       const char *cmd;
-       void (*handler)(struct tcb *tcb, struct packet *packet, void *data);
-       const char *rule;
-       const char *access;
-       void (*handler_access_error)(struct tcb *tcb, struct packet *packet);
-};
+/*!
+ * SERVICE HANDLER
+ */
+
+/*!
+ * NOTIFICATION SERVICE INITIALIZATION
+ */
+       static void _print_noti(notification_h noti) {
+               char *pkgname = NULL;
+               char *text = NULL;
+               char *content = NULL;
+               const char *tag = NULL;
+
+               notification_get_pkgname(noti, &pkgname);
+               notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, &text);
+               notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, &content);
+               notification_get_tag(noti, &tag);
+
+               DbgPrint("client print_noti  pkgname  = %s ", pkgname );
+               DbgPrint("client print_noti  title      = %s ", text );
+               DbgPrint("client print_noti  content  = %s ", content );
+               DbgPrint("client print_noti  tag  = %s ", tag );
+       }
+
+static void _on_name_appeared(GDBusConnection *connection,
+               const gchar     *name,
+               const gchar     *name_owner,
+               gpointer         user_data)
+{
+       DbgPrint("name appeared : %s", name);
+}
 
-static inline char *_string_get(char *string)
+static void _on_name_vanished(GDBusConnection *connection,
+               const gchar     *name,
+               gpointer         user_data)
 {
-       if (string == NULL)
-               return NULL;
-       if (string[0] == '\0')
-               return NULL;
+       DbgPrint("name vanished : %s", name);
+       monitoring_info_s *info = (monitoring_info_s *)user_data;
 
-       return string;
+       if(info) {
+               g_bus_unwatch_name(info->watcher_id);
+
+               if (info->bus_name) {
+                       _monitoring_list = g_list_remove(_monitoring_list, info->bus_name);
+                       free(info->bus_name);
+               }
+               free(info);
+       }
 }
 
-/*!
- * FUNCTIONS to create packets
- */
-static inline int _priv_id_get_from_list(int num_data, int *list, int index)
+static void _noti_dbus_method_call_handler(GDBusConnection *conn,
+               const gchar *sender, const gchar *object_path,
+               const gchar *iface_name, const gchar *method_name,
+               GVariant *parameters, GDBusMethodInvocation *invocation,
+               gpointer user_data)
 {
-       if (index < num_data)
-               return *(list + index);
-       else
-               return -1;
+       /* TODO : sender authority(privilege) check */
+       DbgPrint("notification method_name: %s, sender : %s ", method_name, sender);
+
+       GVariant *reply_body = NULL;
+       int ret = NOTIFICATION_ERROR_INVALID_OPERATION;
+
+       if (g_strcmp0(method_name, "noti_service_register") == 0)
+               ret = service_register(parameters, &reply_body, sender,
+                _on_name_appeared, _on_name_vanished, &_monitoring_list);
+       else if (g_strcmp0(method_name, "update_noti") == 0)
+               ret = notification_update_noti(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "add_noti") == 0)
+               ret = notification_add_noti(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "refresh_noti") == 0)
+               ret = notification_refresh_noti(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "del_noti_single") == 0)
+               ret = notification_del_noti_single(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "del_noti_multiple") == 0)
+               ret = notification_del_noti_multiple(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "set_noti_property") == 0)
+               ret = notification_set_noti_property(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "get_noti_property") == 0)
+               ret = notification_get_noti_property(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "get_noti_count") == 0)
+               ret = notification_get_noti_count(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "update_noti_setting") == 0)
+               ret = notification_update_noti_setting(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "update_noti_sys_setting") == 0)
+               ret = notification_update_noti_sys_setting(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "load_noti_by_tag") == 0)
+               ret = notification_load_noti_by_tag(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "load_noti_by_priv_id") == 0)
+               ret = notification_load_noti_by_priv_id(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "load_noti_grouping_list") == 0)
+               ret = notification_load_grouping_list(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "load_noti_detail_list") == 0)
+               ret = notification_load_detail_list(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "get_setting_array") == 0)
+               ret = notification_get_setting_array(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "get_setting_by_package_name") == 0)
+               ret = notification_get_setting_by_package_name(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "load_system_setting") == 0)
+               ret = notification_load_system_setting(parameters, &reply_body);
+
+       if (ret == NOTIFICATION_ERROR_NONE) {
+               DbgPrint("notification service success : %d", ret);
+               g_dbus_method_invocation_return_value(
+                               invocation, reply_body);
+       } else {
+               DbgPrint("notification service fail : %d", ret);
+               g_dbus_method_invocation_return_error(
+                               invocation,
+                               NOTIFICATION_ERROR,
+                               ret,
+                               "notification service error");
+       }
+
 }
 
-static inline struct packet *_packet_create_with_list(int op_num, int *list, int start_index)
+static const GDBusInterfaceVTable _noti_interface_vtable = {
+               _noti_dbus_method_call_handler,
+               NULL,
+               NULL
+};
+
+int notification_register_dbus_interface()
 {
-       return packet_create(
-                       "del_noti_multiple",
-                       "iiiiiiiiiii",
-                       ((op_num - start_index) > NOTIFICATION_DEL_PACKET_UNIT) ? NOTIFICATION_DEL_PACKET_UNIT : op_num - start_index,
-                       _priv_id_get_from_list(op_num, list, start_index),
-                       _priv_id_get_from_list(op_num, list, start_index + 1),
-                       _priv_id_get_from_list(op_num, list, start_index + 2),
-                       _priv_id_get_from_list(op_num, list, start_index + 3),
-                       _priv_id_get_from_list(op_num, list, start_index + 4),
-                       _priv_id_get_from_list(op_num, list, start_index + 5),
-                       _priv_id_get_from_list(op_num, list, start_index + 6),
-                       _priv_id_get_from_list(op_num, list, start_index + 7),
-                       _priv_id_get_from_list(op_num, list, start_index + 8),
-                       _priv_id_get_from_list(op_num, list, start_index + 9)
-                       );
+       static gchar introspection_xml[] =
+                       "  <node>"
+                       "  <interface name='org.tizen.data_provider_noti_service'>"
+                       "        <method name='noti_service_register'>"
+                       "        </method>"
+
+                       "        <method name='add_noti'>"
+                       "          <arg type='v' name='noti' direction='in'/>"
+                       "          <arg type='i' name='priv_id' direction='out'/>"
+                       "        </method>"
+
+                       "        <method name='update_noti'>"
+                       "          <arg type='v' name='noti' direction='in'/>"
+                       "          <arg type='i' name='priv_id' direction='out'/>"
+                       "        </method>"
+
+                       "        <method name='refresh_noti'>"
+                       "        </method>"
+
+                       "        <method name='del_noti_single'>"
+                       "          <arg type='s' name='pkgname' direction='in'/>"
+                       "          <arg type='i' name='priv_id' direction='in'/>"
+                       "          <arg type='i' name='priv_id' direction='out'/>"
+                       "        </method>"
+
+                       "        <method name='del_noti_multiple'>"
+                       "          <arg type='s' name='pkgname' direction='in'/>"
+                       "          <arg type='i' name='priv_id' direction='in'/>"
+                       "          <arg type='i' name='priv_id' direction='out'/>"
+                       "        </method>"
+
+                       "        <method name='load_noti_by_tag'>"
+                       "          <arg type='s' name='pkgname' direction='in'/>"
+                       "          <arg type='s' name='tag' direction='in'/>"
+                       "          <arg type='v' name='noti' direction='out'/>"
+                       "        </method>"
+
+                       "        <method name='load_noti_by_priv_id'>"
+                       "          <arg type='s' name='pkgname' direction='in'/>"
+                       "          <arg type='i' name='priv_id' direction='in'/>"
+                       "          <arg type='v' name='noti' direction='out'/>"
+                       "        </method>"
+
+                       "        <method name='load_noti_grouping_list'>"
+                       "          <arg type='i' name='type' direction='in'/>"
+                       "          <arg type='i' name='count' direction='in'/>"
+                       "          <arg type='a(v)' name='noti_list' direction='out'/>"
+                       "        </method>"
+
+                       "        <method name='load_noti_detail_list'>"
+                       "          <arg type='s' name='pkgname' direction='in'/>"
+                       "          <arg type='i' name='group_id' direction='in'/>"
+                       "          <arg type='i' name='priv_id' direction='in'/>"
+                       "          <arg type='i' name='count' direction='in'/>"
+                       "          <arg type='a(v)' name='noti_list' direction='out'/>"
+                       "        </method>"
+
+                       "        <method name='set_noti_property'>"
+                       "          <arg type='s' name='pkgname' direction='in'/>"
+                       "          <arg type='s' name='property' direction='in'/>"
+                       "          <arg type='s' name='value' direction='in'/>"
+                       "        </method>"
+
+                       "        <method name='get_noti_property'>"
+                       "          <arg type='s' name='pkgname' direction='in'/>"
+                       "          <arg type='s' name='property' direction='in'/>"
+                       "          <arg type='s' name='ret_value' direction='out'/>"
+                       "        </method>"
+
+                       "        <method name='get_noti_count'>"
+                       "          <arg type='i' name='type' direction='in'/>"
+                       "          <arg type='s' name='pkgname' direction='in'/>"
+                       "          <arg type='i' name='group_id' direction='in'/>"
+                       "          <arg type='i' name='priv_id' direction='in'/>"
+                       "          <arg type='i' name='ret_count' direction='out'/>"
+                       "        </method>"
+
+                       "        <method name='update_noti_setting'>"
+                       "          <arg type='s' name='pkgname' direction='in'/>"
+                       "          <arg type='i' name='allow_to_notify' direction='in'/>"
+                       "          <arg type='i' name='do_not_disturb_except' direction='in'/>"
+                       "          <arg type='i' name='visibility_class' direction='in'/>"
+                       "        </method>"
+
+                       "        <method name='update_noti_sys_setting'>"
+                       "          <arg type='i' name='do_not_disturb' direction='in'/>"
+                       "          <arg type='i' name='visibility_class' direction='in'/>"
+                       "        </method>"
+
+                       "        <method name='get_setting_array'>"
+                       "          <arg type='i' name='setting_cnt' direction='out'/>"
+                       "          <arg type='a(v)' name='setting_arr' direction='out'/>"
+                       "        </method>"
+
+                       "        <method name='get_setting_by_package_name'>"
+                       "          <arg type='s' name='pkgname' direction='in'/>"
+                       "          <arg type='v' name='setting' direction='out'/>"
+                       "        </method>"
+
+                       "        <method name='load_system_setting'>"
+                       "          <arg type='v' name='setting' direction='out'/>"
+                       "        </method>"
+
+                       "        <method name='post_toast'>"
+                       "        </method>"
+                       "  </interface>"
+                       "  </node>";
+
+       return service_common_register_dbus_interface(introspection_xml, _noti_interface_vtable);
 }
 
-/*!
- * SERVICE HANDLER
- */
-static void _handler_insert_noti(struct tcb *tcb, struct packet *packet, notification_h noti, void *data)
+/* add noti */
+static int _add_noti(GVariant **reply_body, notification_h noti)
 {
-       int ret = 0, ret_p = 0;
-       int priv_id = 0;
-       struct packet *packet_reply = NULL;
-       struct packet *packet_service = NULL;
+       int ret;
+       int priv_id = NOTIFICATION_PRIV_ID_NONE;
+       GVariant *body = NULL;
 
+       print_noti(noti);
        ret = notification_noti_insert(noti);
        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) {
-               if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
-                       ErrPrint("failed to send reply packet: %d\n", ret_p);
-               packet_destroy(packet_reply);
-       } else {
-               ErrPrint("failed to create a reply packet\n");
+       DbgPrint("priv_id: [%d]", priv_id);
+
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               ErrPrint("failed to update a notification:%d\n", ret);
+               return ret;
+       }
+
+       body = notification_ipc_make_gvariant_from_noti(noti);
+       if (body == NULL) {
+               ErrPrint("cannot make gvariant to noti");
+               return NOTIFICATION_ERROR_OUT_OF_MEMORY;
        }
+       ret = send_notify(body, "add_noti_notify", _monitoring_list, PROVIDER_NOTI_INTERFACE_NAME);
+       g_variant_unref(body);
 
        if (ret != NOTIFICATION_ERROR_NONE) {
-               ErrPrint("failed to insert a notification: %d\n", ret);
-               return;
+               ErrPrint("failed to send notify:%d\n", ret);
+               return ret;
        }
 
-       packet_service = notification_ipc_make_packet_from_noti(noti, "add_noti", 2);
-       if (packet_service != NULL) {
-               if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0)
-                       ErrPrint("failed to send a multicast packet: %d\n", ret_p);
-               packet_destroy(packet_service);
+       *reply_body = g_variant_new("(i)", priv_id);
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make reply_body");
+               return NOTIFICATION_ERROR_OUT_OF_MEMORY;
+       }
+
+       DbgPrint("_insert_noti done !!");
+       return ret;
+}
+
+int notification_add_noti(GVariant *parameters, GVariant **reply_body)
+{
+       int ret;
+       notification_h noti;
+       GVariant *body = NULL;
+
+       noti = notification_create(NOTIFICATION_TYPE_NOTI);
+       if (noti != NULL) {
+               g_variant_get(parameters, "(v)", &body);
+               ret = notification_ipc_make_noti_from_gvariant(noti, body);
+               g_variant_unref(body);
+
+               if (ret == NOTIFICATION_ERROR_NONE) {
+                       ret = notification_noti_check_tag(noti);
+                       if (ret == NOTIFICATION_ERROR_NOT_EXIST_ID)
+                               ret = _add_noti(reply_body, noti);
+                       else if (ret == NOTIFICATION_ERROR_ALREADY_EXIST_ID)
+                               ret = _update_noti(reply_body, noti);
+               }
+               notification_free(noti);
+
        } else {
-               ErrPrint("failed to create a multicats packet\n");
+               ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
        }
+
+       DbgPrint("notification_add_noti ret : %d", ret);
+       return ret;
 }
 
-/*static void _handler_insert(struct tcb *tcb, struct packet *packet, void *data) // not used
-  {
-  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) {
-  _handler_insert_noti(tcb, packet, noti, data);
-  } else {
-  ErrPrint("Failed to create the packet");
-  }
-  notification_free(noti);
-  }
-  }*/
-
-static void _handler_update_noti(struct tcb *tcb, struct packet *packet, notification_h noti, void *data)
+/* update noti */
+static int _update_noti(GVariant **reply_body, notification_h noti)
 {
-       int ret = 0, ret_p = 0;
-       int priv_id = 0;
-       struct packet *packet_reply = NULL;
-       struct packet *packet_service = NULL;
+       int ret;
+       GVariant *body = NULL;
+       int priv_id = NOTIFICATION_PRIV_ID_NONE;
+
+       print_noti(noti);
+       notification_get_id(noti, NULL, &priv_id);
+       DbgPrint("priv_id: [%d]", priv_id);
 
        ret = notification_noti_update(noti);
+       if (ret != NOTIFICATION_ERROR_NONE)
+               return ret;
 
-       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) {
-               if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
-                       ErrPrint("failed to send reply packet:%d\n", ret_p);
-               packet_destroy(packet_reply);
-       } else {
-               ErrPrint("failed to create a reply packet\n");
+       body = notification_ipc_make_gvariant_from_noti(noti);
+       if (body == NULL) {
+               ErrPrint("cannot make gvariant to noti");
+               return NOTIFICATION_ERROR_IO_ERROR;
        }
 
+       ret = send_notify(body, "update_noti_notify", _monitoring_list, PROVIDER_NOTI_INTERFACE_NAME);
+       g_variant_unref(body);
+
        if (ret != NOTIFICATION_ERROR_NONE) {
-               ErrPrint("failed to update a notification:%d\n", ret);
-               return;
+               ErrPrint("failed to send notify:%d\n", ret);
+               return ret;
        }
 
-       packet_service = notification_ipc_make_packet_from_noti(noti, "update_noti", 2);
-       if (packet_service != NULL) {
-               if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0)
-                       ErrPrint("failed to send a multicast packet: %d\n", ret_p);
-               packet_destroy(packet_service);
+       *reply_body = g_variant_new("(i)", priv_id);
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make reply_body");
+               return NOTIFICATION_ERROR_OUT_OF_MEMORY;
        }
+       DbgPrint("_update_noti done !!");
+       return ret;
 }
 
-static void _handler_update(struct tcb *tcb, struct packet *packet, void *data)
+int notification_update_noti(GVariant *parameters, GVariant **reply_body)
 {
-       notification_h noti = NULL;
+       notification_h noti;
+       int ret;
+       GVariant *body = NULL;
 
        noti = notification_create(NOTIFICATION_TYPE_NOTI);
        if (noti != NULL) {
-               if (notification_ipc_make_noti_from_packet(noti, packet) == NOTIFICATION_ERROR_NONE)
-                       _handler_update_noti(tcb, packet, noti, data);
-               else
-                       ErrPrint("Failed to create the packet");
+               g_variant_get(parameters, "(v)", &body);
+               ret = notification_ipc_make_noti_from_gvariant(noti, body);
+               g_variant_unref(body);
+
+               if (ret == NOTIFICATION_ERROR_NONE)
+                       ret = _update_noti(reply_body, noti);
+
                notification_free(noti);
+       } else {
+               ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
        }
+       return ret;
 }
 
-static void _handler_check_noti_by_tag(struct tcb *tcb, struct packet *packet, void *data)
+/* load_noti_by_tag */
+int notification_load_noti_by_tag(GVariant *parameters, GVariant **reply_body)
 {
-       int ret = 0;
-       notification_h noti = NULL;
+       int ret;
+       char *tag = NULL;
+       char *pkgname = NULL;
+       notification_h noti;
 
        noti = notification_create(NOTIFICATION_TYPE_NOTI);
        if (noti != NULL) {
-               if (notification_ipc_make_noti_from_packet(noti, packet) == NOTIFICATION_ERROR_NONE) {
-                       ret = notification_noti_check_tag(noti);
-                       if (ret == NOTIFICATION_ERROR_NOT_EXIST_ID)
-                               _handler_insert_noti(tcb, packet, noti, data);
-                       else if (ret == NOTIFICATION_ERROR_ALREADY_EXIST_ID)
-                               _handler_update_noti(tcb, packet, noti, data);
-               }
+               g_variant_get(parameters, "(&s&s)", &pkgname, &tag);
+               DbgPrint("_load_noti_by_tag pkgname : %s, tag : %s ", pkgname, tag);
+               ret = notification_noti_get_by_tag(noti, pkgname, tag);
+
+               DbgPrint("notification_noti_get_by_tag ret : %d", ret);
+               _print_noti(noti);
+
+               *reply_body = notification_ipc_make_gvariant_from_noti(noti);
                notification_free(noti);
+
+               if (*reply_body == NULL) {
+                       ErrPrint("cannot make reply_body");
+                       return NOTIFICATION_ERROR_OUT_OF_MEMORY;
+               }
+       } else {
+               ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
        }
+       DbgPrint("_load_noti_by_tag done !!");
+       return ret;
 }
 
-static void _handler_load_noti_by_tag(struct tcb *tcb, struct packet *packet, void *data)
+/* load_noti_by_priv_id */
+int notification_load_noti_by_priv_id(GVariant *parameters, GVariant **reply_body)
 {
-       int ret = 0, ret_p = 0;
-       char *tag;
-       char *pkgname;
-       struct packet *packet_reply = NULL;
-       notification_h noti = NULL;
+       int ret;
+       int priv_id = NOTIFICATION_PRIV_ID_NONE;
+       char *pkgname = NULL;
+       notification_h noti;
 
        noti = notification_create(NOTIFICATION_TYPE_NOTI);
        if (noti != NULL) {
-               if (packet_get(packet, "ss", &pkgname, &tag) == 2) {
-                       ret = notification_noti_get_by_tag(noti, pkgname, tag);
-                       packet_reply = notification_ipc_make_reply_packet_from_noti(noti, packet);
-                       if (packet_reply) {
-                               if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
-                                       ErrPrint("failed to send reply packet: %d\n", ret_p);
-                               packet_destroy(packet_reply);
-                       } else {
-                               ErrPrint("failed to create a reply packet\n");
-                       }
+               g_variant_get(parameters, "(&si)", &pkgname, &priv_id);
+               DbgPrint("load_noti_by_priv_id pkgname : %s, priv_id : %d ", pkgname, priv_id);
+               ret = notification_noti_get_by_priv_id(noti, pkgname, priv_id);
 
-                       if (ret != NOTIFICATION_ERROR_NONE) {
-                               ErrPrint("failed to load_noti_by_tag : %d\n", ret);
-                               notification_free(noti);
-                               return;
-                       }
-               } else {
-                       ErrPrint("Failed to create the packet");
-               }
-               notification_free(noti);
-       }
-}
+               DbgPrint("notification_noti_get_by_priv_id ret : %d", ret);
+               print_noti(noti);
 
+               *reply_body = notification_ipc_make_gvariant_from_noti(noti);
+               notification_free(noti);
 
-static void _handler_refresh(struct tcb *tcb, struct packet *packet, void *data)
-{
-       int ret = 0;
-       struct packet *packet_reply = NULL;
-
-       packet_reply = packet_create_reply(packet, "i", ret);
-       if (packet_reply) {
-               if ((ret = service_common_unicast_packet(tcb, packet_reply)) < 0)
-                       ErrPrint("failed to send reply packet:%d\n", ret);
-               packet_destroy(packet_reply);
+               if (*reply_body == NULL) {
+                       ErrPrint("cannot make reply_body");
+                       return NOTIFICATION_ERROR_OUT_OF_MEMORY;
+               }
        } else {
-               ErrPrint("failed to create a reply packet\n");
+               ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
        }
 
-       if ((ret = service_common_multicast_packet(tcb, packet, TCB_CLIENT_TYPE_SERVICE)) < 0)
-               ErrPrint("failed to send a multicast packet:%d\n", ret);
+       DbgPrint("_load_noti_by_priv_id done !!");
+       return ret;
 }
 
-static void _handler_delete_single(struct tcb *tcb, struct packet *packet, void *data)
+/* load_noti_grouping_list */
+int notification_load_grouping_list(GVariant *parameters, GVariant **reply_body)
 {
-       int num_changes = 0;
-       int ret = 0, ret_p = 0;
-       int priv_id = 0;
-       struct packet *packet_reply = NULL;
-       struct packet *packet_service = NULL;
-       char *pkgname = NULL;
+       int ret;
+       notification_h noti;
+       GVariant *body = NULL;
+       notification_type_e type = NOTIFICATION_TYPE_NONE;
+       notification_list_h get_list = NULL;
+       notification_list_h list_iter;
+       GVariantBuilder *builder;
+       int count = 0;
+
+       g_variant_get(parameters, "(ii)", &type, &count);
+       DbgPrint("load grouping list type : %d, count : %d ", type, count);
+
+       ret = notification_noti_get_grouping_list(type, count, &get_list);
+       if (ret != NOTIFICATION_ERROR_NONE)
+               return ret;
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a(v)"));
+       if (get_list) {
+
+               list_iter = notification_list_get_head(get_list);
+               do {
+                       noti = notification_list_get_data(list_iter);
+                       body = notification_ipc_make_gvariant_from_noti(noti);
+                       g_variant_builder_add(builder, "(v)", body);
+
+                       list_iter = notification_list_get_next(list_iter);
+               } while (list_iter != NULL);
+
+               notification_free_list(get_list);
+       }
 
-       if (packet_get(packet, "si", &pkgname, &priv_id) == 2) {
-               pkgname = _string_get(pkgname);
+       *reply_body = g_variant_new("(a(v))", builder);
+       g_variant_builder_unref(builder);
 
-               ret = notification_noti_delete_by_priv_id_get_changes(pkgname, priv_id, &num_changes);
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make reply_body");
+               return NOTIFICATION_ERROR_OUT_OF_MEMORY;
+       }
 
-               DbgPrint("priv_id: [%d] num_delete:%d\n", priv_id, num_changes);
-               packet_reply = packet_create_reply(packet, "ii", ret, priv_id);
-               if (packet_reply) {
-                       if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
-                               ErrPrint("failed to send reply packet:%d\n", ret_p);
-                       packet_destroy(packet_reply);
-               } else {
-                       ErrPrint("failed to create a reply packet\n");
-               }
+       DbgPrint("load grouping list done !!");
+       return ret;
+}
 
-               if (ret != NOTIFICATION_ERROR_NONE || num_changes <= 0) {
-                       ErrPrint("failed to delete a notification:%d %d\n", ret, num_changes);
-                       return;
+/* get_setting_array */
+int notification_get_setting_array(GVariant *parameters, GVariant **reply_body)
+{
+       int ret;
+       GVariant *body;
+       GVariantBuilder *builder;
+       int count = 0;
+       int i;
+       notification_setting_h setting_array = NULL;
+       notification_setting_h temp;
+
+       ret = noti_setting_get_setting_array(&setting_array, &count);
+       if (ret != NOTIFICATION_ERROR_NONE)
+               return ret;
+
+       DbgPrint("get setting array : %d", count);
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a(v)"));
+
+       if (setting_array) {
+               for (i = 0; i < count; i++) {
+                       temp = setting_array + i;
+                       body = notification_ipc_make_gvariant_from_setting(temp);
+                       g_variant_builder_add(builder, "(v)", body);
+
+                       if(temp->package_name)
+                               free(temp->package_name);
                }
+               free(setting_array);
+       }
+       *reply_body = g_variant_new("(ia(v))", count, builder);
+       g_variant_builder_unref(builder);
 
-               packet_service = packet_create("del_noti_single", "ii", 1, priv_id);
-               if (packet_service != NULL) {
-                       if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0)
-                               ErrPrint("failed to send a multicast packet: %d\n", ret_p);
-                       packet_destroy(packet_service);
-               }
-       } else {
-               ErrPrint("Failed to get data from the packet");
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make reply_body");
+               return NOTIFICATION_ERROR_OUT_OF_MEMORY;
        }
+       return ret;
 }
 
-static void _handler_delete_multiple(struct tcb *tcb, struct packet *packet, void *data)
+/* get_setting_array */
+int notification_get_setting_by_package_name(GVariant *parameters, GVariant **reply_body)
 {
-       int ret = 0, ret_p = 0;
-       struct packet *packet_reply = NULL;
-       struct packet *packet_service = NULL;
+       int ret;
+       GVariant *body;
        char *pkgname = NULL;
-       notification_type_e type = 0;
-       int num_deleted = 0;
-       int *list_deleted = NULL;
+       notification_setting_h setting = NULL;
 
-       if (packet_get(packet, "si", &pkgname, &type) == 2) {
-               pkgname = _string_get(pkgname);
-               DbgPrint("pkgname: [%s] type: [%d]\n", pkgname, type);
+       g_variant_get(parameters, "(&s)", &pkgname);
+       DbgPrint("get setting by pkgname : %s", pkgname);
 
-               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) {
-                       if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
-                               ErrPrint("failed to send reply packet:%d\n", ret_p);
-                       packet_destroy(packet_reply);
-               } else {
-                       ErrPrint("failed to create a reply packet\n");
-               }
+       ret = noti_setting_service_get_setting_by_package_name(pkgname, &setting);
+       if (ret == NOTIFICATION_ERROR_NONE) {
+               body = notification_ipc_make_gvariant_from_setting(setting);
+               notification_setting_free_notification(setting);
 
-               if (ret != NOTIFICATION_ERROR_NONE) {
-                       ErrPrint("failed to delete notifications:%d\n", ret);
-                       if (list_deleted != NULL)
-                               DbgFree(list_deleted);
-                       return;
+               if (body == NULL) {
+                       ErrPrint("fail to make gvariant");
+                       return NOTIFICATION_ERROR_OUT_OF_MEMORY;
                }
+       } else {
+               return ret;
+       }
 
-               if (num_deleted > 0) {
-                       if (num_deleted <= NOTIFICATION_DEL_PACKET_UNIT) {
-                               packet_service = _packet_create_with_list(num_deleted, list_deleted, 0);
-
-                               if (packet_service) {
-                                       if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0)
-                                               ErrPrint("failed to send a multicast packet: %d\n", ret_p);
-                                       packet_destroy(packet_service);
-                               } else {
-                                       ErrPrint("failed to create a multicast packet\n");
-                               }
-                       } else {
-                               int set = 0;
-                               int set_total = num_deleted / NOTIFICATION_DEL_PACKET_UNIT;
-
-                               for (set = 0; set <= set_total; set++) {
-                                       packet_service = _packet_create_with_list(num_deleted,
-                                                       list_deleted, set * NOTIFICATION_DEL_PACKET_UNIT);
-
-                                       if (packet_service) {
-                                               if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0)
-                                                       ErrPrint("failed to send a multicast packet:%d\n", ret_p);
-                                               packet_destroy(packet_service);
-                                       } else {
-                                               ErrPrint("failed to create a multicast packet\n");
-                                       }
-                               }
-                       }
-               }
+       *reply_body = g_variant_new("(v)", body);
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make reply_body");
+               return NOTIFICATION_ERROR_OUT_OF_MEMORY;
+       }
+       return ret;
+}
 
-               if (list_deleted != NULL) {
-                       DbgFree(list_deleted);
-                       list_deleted = NULL;
+/* load_system_setting */
+int notification_load_system_setting(GVariant *parameters, GVariant **reply_body)
+{
+       int ret;
+       GVariant *body;
+       notification_system_setting_h setting = NULL;
+
+       ret = noti_system_setting_load_system_setting(&setting);
+       if (ret == NOTIFICATION_ERROR_NONE) {
+               body = notification_ipc_make_gvariant_from_system_setting(setting);
+               notification_system_setting_free_system_setting(setting);
+
+               if (body == NULL) {
+                       ErrPrint("fail to make gvariant");
+                       return NOTIFICATION_ERROR_OUT_OF_MEMORY;
                }
        } else {
-               ErrPrint("Failed to get data from the packet");
+               return ret;
+       }
+       *reply_body = g_variant_new("(v)", body);
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make reply_body");
+               return NOTIFICATION_ERROR_OUT_OF_MEMORY;
        }
+       DbgPrint("load system setting done !!");
+
+       return ret;
 }
 
-static void _handler_noti_property_set(struct tcb *tcb, struct packet *packet, void *data)
+/* load_noti_detail_list */
+int notification_load_detail_list(GVariant *parameters, GVariant **reply_body)
 {
-       int ret = 0, ret_p = 0;
-       struct packet *packet_reply = NULL;
+       int ret;
+       notification_h noti;
+       GVariant *body = NULL;
+       notification_list_h get_list = NULL;
+       notification_list_h list_iter;
+       GVariantBuilder *builder;
        char *pkgname = NULL;
-       char *property = NULL;
-       char *value = NULL;
+       int group_id = NOTIFICATION_GROUP_ID_NONE;
+       int priv_id = NOTIFICATION_PRIV_ID_NONE;
+       int count = 0;
+
+       g_variant_get(parameters, "(&siii)", &pkgname, &group_id, &priv_id, &count);
+       DbgPrint("load detail list pkgname : %s, group_id : %d, priv_id : %d, count : %d ",
+                       pkgname, group_id, priv_id, count);
+
+       ret = notification_noti_get_detail_list(pkgname, group_id, priv_id,
+                       count, &get_list);
+       if (ret != NOTIFICATION_ERROR_NONE)
+               return ret;
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a(v)"));
+
+       if (get_list) {
+               list_iter = notification_list_get_head(get_list);
+               do {
+                       noti = notification_list_get_data(list_iter);
+                       body = notification_ipc_make_gvariant_from_noti(noti);
+                       if (body) {
+                               g_variant_builder_add(builder, "(v)", body);
+                               list_iter = notification_list_get_next(list_iter);
+                       }
+               } while (list_iter != NULL);
+               notification_free_list(get_list);
+       }
 
-       if (packet_get(packet, "sss", &pkgname, &property, &value) == 3) {
-               pkgname = _string_get(pkgname);
-               property = _string_get(property);
-               value = _string_get(value);
+       *reply_body = g_variant_new("(a(v))", builder);
+       g_variant_builder_unref(builder);
 
-               ret = notification_setting_db_set(pkgname, property, value);
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make reply_body");
+               return NOTIFICATION_ERROR_OUT_OF_MEMORY;
+       }
 
-               packet_reply = packet_create_reply(packet, "ii", ret, ret);
-               if (packet_reply) {
-                       if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
-                               ErrPrint("failed to send reply packet:%d\n", ret_p);
-                       packet_destroy(packet_reply);
-               } else {
-                       ErrPrint("failed to create a reply packet\n");
-               }
+       DbgPrint("load detail list done !!");
+       return ret;
+}
 
-               if (ret != NOTIFICATION_ERROR_NONE)
-                       ErrPrint("failed to set noti property:%d\n", ret);
-       } else {
-               ErrPrint("Failed to get data from the packet");
+/* refresh_noti */
+int notification_refresh_noti(GVariant *parameters, GVariant **reply_body)
+{
+       int ret;
+       ret = send_notify(parameters, "refresh_noti_notify", _monitoring_list, PROVIDER_NOTI_INTERFACE_NAME);
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               ErrPrint("failed to send notify:%d\n", ret);
+               return ret;
+       }
+
+       *reply_body = g_variant_new("()");
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make reply_body");
+               return NOTIFICATION_ERROR_OUT_OF_MEMORY;
        }
+
+       DbgPrint("_refresh_noti_service done !!");
+       return ret;
 }
 
-static void _handler_noti_property_get(struct tcb *tcb, struct packet *packet, void *data)
+/* del_noti_single */
+int notification_del_noti_single(GVariant *parameters, GVariant **reply_body)
 {
-       int ret = 0, ret_p = 0;
-       struct packet *packet_reply = NULL;
+       int ret;
+       int num_changes = 0;
+       int priv_id = NOTIFICATION_PRIV_ID_NONE;
        char *pkgname = NULL;
-       char *property = NULL;
-       char *value = NULL;
+       GVariant *body = NULL;
 
-       if (packet_get(packet, "sss", &pkgname, &property) == 2) {
-               pkgname = _string_get(pkgname);
-               property = _string_get(property);
+       g_variant_get(parameters, "(&si)", &pkgname, &priv_id);
+       ret = notification_noti_delete_by_priv_id_get_changes(pkgname, priv_id, &num_changes);
+       DbgPrint("priv_id: [%d] num_delete:%d\n", priv_id, num_changes);
 
-               ret = notification_setting_db_get(pkgname, property, &value);
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               ErrPrint("failed to delete a notification:%d %d\n", ret, num_changes);
+               return ret;
+       }
 
-               packet_reply = packet_create_reply(packet, "is", ret, value);
-               if (packet_reply) {
-                       if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
-                               ErrPrint("failed to send reply packet:%d\n", ret_p);
-                       packet_destroy(packet_reply);
-               } else {
-                       ErrPrint("failed to create a reply packet\n");
+       if (num_changes > 0) {
+               body = g_variant_new("(ii)", 1, priv_id);
+               if (body == NULL) {
+                       ErrPrint("cannot make gvariant to noti");
+                       return NOTIFICATION_ERROR_OUT_OF_MEMORY;
                }
+               ret = send_notify(body, "delete_single_notify", _monitoring_list, PROVIDER_NOTI_INTERFACE_NAME);
+               g_variant_unref(body);
+               if (ret != NOTIFICATION_ERROR_NONE) {
+                       ErrPrint("failed to send notify:%d\n", ret);
+                       return ret;
+               }
+       }
 
-               if (value != NULL)
-                       DbgFree(value);
+       *reply_body = g_variant_new("(i)", priv_id);
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make reply_body");
+               return NOTIFICATION_ERROR_OUT_OF_MEMORY;
        }
+       DbgPrint("_del_noti_single done !!");
+       return ret;
 }
 
-static void _handler_noti_update_setting(struct tcb *tcb, struct packet *packet, void *data)
+/* del_noti_multiple */
+int notification_del_noti_multiple(GVariant *parameters, GVariant **reply_body)
 {
-       int ret = 0, ret_p = 0;
-       struct packet *packet_reply = NULL;
-       char *package_name = NULL;
-       int allow_to_notify = 0;
-       int do_not_disturb_except = 0;
-       int visivility_class = 0;
+       int ret;
+       char *pkgname = NULL;
+       notification_type_e type = NOTIFICATION_TYPE_NONE;
+       int num_deleted = 0;
+       int *list_deleted = NULL;
+       GVariant *deleted_noti_list;
+       GVariantBuilder * builder;
+       int i;
 
-       if (packet_get(packet, "siii", &package_name, &allow_to_notify, &do_not_disturb_except, &visivility_class) == 4) {
-               package_name = _string_get(package_name);
-               DbgPrint("package_name: [%s] allow_to_notify: [%d] do_not_disturb_except: [%d] visivility_class: [%d]\n", package_name, allow_to_notify, do_not_disturb_except, visivility_class);
-               /* ADD CODES HERE */
-               ret = notification_setting_db_update(package_name, allow_to_notify, do_not_disturb_except, visivility_class);
-
-               packet_reply = packet_create_reply(packet, "ii", ret, ret);
-               if (packet_reply) {
-                       if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
-                               ErrPrint("failed to send reply packet:%d\n", ret_p);
-                       packet_destroy(packet_reply);
-               } else {
-                       ErrPrint("failed to create a reply packet\n");
-               }
+       g_variant_get(parameters, "(&si)", &pkgname, &type);
+       DbgPrint("pkgname: [%s] type: [%d]\n", pkgname, type);
 
-               if (ret != NOTIFICATION_ERROR_NONE)
-                       ErrPrint("failed to update setting[%d]\n", ret);
-       } else {
-               ErrPrint("Failed to get data from the packet");
+       ret = notification_noti_delete_all(type, pkgname, &num_deleted, &list_deleted);
+       DbgPrint("ret: [%d] num_deleted: [%d]\n", ret, num_deleted);
+
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               ErrPrint("failed to delete notifications:%d\n", ret);
+               if (list_deleted != NULL)
+                       free(list_deleted);
+               return ret;
        }
-}
 
-static void _handler_noti_update_system_setting(struct tcb *tcb, struct packet *packet, void *data)
-{
-       int ret = 0, ret_p = 0;
-       struct packet *packet_reply = NULL;
-       int do_not_disturb = 0;
-       int visivility_class = 0;
+       if (num_deleted > 0) {
+               builder = g_variant_builder_new(G_VARIANT_TYPE("a(i)"));
 
-       if (packet_get(packet, "ii", &do_not_disturb, &visivility_class) == 2) {
-               DbgPrint("do_not_disturb [%d] visivility_class [%d]\n", do_not_disturb, visivility_class);
-               /* ADD CODES HERE */
-               ret = notification_setting_db_update_system_setting(do_not_disturb, visivility_class);
-
-               packet_reply = packet_create_reply(packet, "ii", ret, ret);
-               if (packet_reply) {
-                       if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
-                               ErrPrint("failed to send reply packet:%d\n", ret_p);
-                       packet_destroy(packet_reply);
-               } else {
-                       ErrPrint("failed to create a reply packet\n");
+               for (i = 0; i < num_deleted; i++) {
+                       g_variant_builder_add(builder, "(i)", *(list_deleted + i));
                }
+               deleted_noti_list = g_variant_new("(a(i))", builder);
+               ret = send_notify(deleted_noti_list, "delete_multiple_notify", _monitoring_list, PROVIDER_NOTI_INTERFACE_NAME);
 
-               if (ret != NOTIFICATION_ERROR_NONE)
-                       ErrPrint("failed to update system setting[%d]\n", ret);
-       } else {
-               ErrPrint("Failed to get data from the packet");
+               g_variant_builder_unref(builder);
+               g_variant_unref(deleted_noti_list);
+               free(list_deleted);
+
+               if (ret != NOTIFICATION_ERROR_NONE) {
+                       ErrPrint("failed to send notify:%d\n", ret);
+                       return ret;
+               }
+       }
+
+       *reply_body = g_variant_new("(i)", num_deleted);
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make reply_body");
+               return NOTIFICATION_ERROR_OUT_OF_MEMORY;
        }
+       DbgPrint("_del_noti_multiple done !!");
+       return ret;
 }
 
-static void _handler_service_register(struct tcb *tcb, struct packet *packet, void *data)
+/* set_noti_property */
+int notification_set_noti_property(GVariant *parameters, GVariant **reply_body)
 {
-       int ret = 0;
-       struct packet *packet_reply;
+       int ret;
+       char *pkgname = NULL;
+       char *property = NULL;
+       char *value = NULL;
 
-       ret = tcb_client_type_set(tcb, TCB_CLIENT_TYPE_SERVICE);
+       g_variant_get(parameters, "(&s&s&s)", &pkgname, &property, &value);
 
-       packet_reply = packet_create_reply(packet, "i", ret);
-       if (packet_reply) {
-               if ((ret = service_common_unicast_packet(tcb, packet_reply)) < 0)
-                       ErrPrint("failed to send reply packet:%d\n", ret);
-               packet_destroy(packet_reply);
-       } else {
-               ErrPrint("failed to create a reply packet\n");
+       ret = notification_setting_db_set(pkgname, property, value);
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               ErrPrint("failed to setting db set : %d\n", ret);
+               return ret;
        }
+       *reply_body = g_variant_new("()");
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make reply_body");
+               return NOTIFICATION_ERROR_OUT_OF_MEMORY;
+       }
+
+       DbgPrint("_set_noti_property_service done !! %d", ret);
+       return ret;
 }
 
-static void _handler_post_toast_message(struct tcb *tcb, struct packet *packet, void *data)
+/* get_noti_property */
+int notification_get_noti_property(GVariant *parameters, GVariant **reply_body)
 {
-       int ret = 0;
-       struct packet *packet_reply = NULL;
-
-       packet_reply = packet_create_reply(packet, "i", ret);
-       if (packet_reply) {
-               if ((ret = service_common_unicast_packet(tcb, packet_reply)) < 0)
-                       ErrPrint("failed to send reply packet:%d\n", ret);
-               packet_destroy(packet_reply);
-       } else {
-               ErrPrint("failed to create a reply packet\n");
+       int ret;
+       char *pkgname = NULL;
+       char *property = NULL;
+       char *value = NULL;
+
+       g_variant_get(parameters, "(&s&s)", &pkgname, &property);
+
+       ret = notification_setting_db_get(pkgname, property, &value);
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               ErrPrint("failed to setting db get : %d\n", ret);
+               return ret;
        }
+       *reply_body = g_variant_new("(s)", value);
+       free(value);
 
-       if ((ret = service_common_multicast_packet(tcb, packet, TCB_CLIENT_TYPE_SERVICE)) < 0)
-               ErrPrint("failed to send a multicast packet:%d\n", ret);
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make reply_body");
+               return NOTIFICATION_ERROR_OUT_OF_MEMORY;
+       }
+
+       DbgPrint("_get_noti_property_service done !! %d", ret);
+       return ret;
 }
 
-static void _handler_package_install(struct tcb *tcb, struct packet *packet, void *data)
+/* get_noti_count */
+int notification_get_noti_count(GVariant *parameters, GVariant **reply_body)
 {
-       int ret = NOTIFICATION_ERROR_NONE;
-       char *package_name = NULL;
+       int ret;
+       notification_type_e type = NOTIFICATION_TYPE_NONE;
+       char *pkgname = NULL;
+       int group_id = NOTIFICATION_GROUP_ID_NONE;
+       int priv_id = NOTIFICATION_PRIV_ID_NONE;
+       int noti_count = 0;
 
-       DbgPrint("_handler_package_install");
-       if (packet_get(packet, "s", &package_name) == 1) {
-               DbgPrint("package_name [%s]\n", package_name);
-               /* TODO : add codes to add a record to setting table */
+       g_variant_get(parameters, "(i&sii)", &type, &pkgname, &group_id, &priv_id);
 
-               if (ret != NOTIFICATION_ERROR_NONE)
-                       ErrPrint("failed to update setting[%d]\n", ret);
-       } else {
-               ErrPrint("Failed to get data from the packet");
+       ret = notification_noti_get_count(type, pkgname, group_id, priv_id,
+                       &noti_count);
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               ErrPrint("failed to get count : %d\n", ret);
+               return ret;
        }
-}
 
-/*!
- * SERVICE PERMISSION CHECK
- */
-static void _permission_check_common(struct tcb *tcb, struct packet *packet)
-{
-       int ret_p = 0;
-       struct packet *packet_reply = NULL;
-
-       packet_reply = packet_create_reply(packet, "ii", NOTIFICATION_ERROR_PERMISSION_DENIED, 0);
-       if (packet_reply) {
-               if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
-                       ErrPrint("Failed to send a reply packet:%d", ret_p);
-               packet_destroy(packet_reply);
-       } else {
-               ErrPrint("Failed to create a reply packet");
+       *reply_body = g_variant_new("(i)", noti_count);
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make reply_body");
+               return NOTIFICATION_ERROR_OUT_OF_MEMORY;
        }
+       DbgPrint("_get_noti_property_service done !! %d", ret);
+       return ret;
 }
 
-static void _permission_check_refresh(struct tcb *tcb, struct packet *packet)
+/* update_noti_setting */
+int notification_update_noti_setting(GVariant *parameters, GVariant **reply_body)
 {
-       int ret_p = 0;
-       struct packet *packet_reply = NULL;
-
-       packet_reply = packet_create_reply(packet, "i", NOTIFICATION_ERROR_PERMISSION_DENIED);
-       if (packet_reply) {
-               if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
-                       ErrPrint("Failed to send a reply packet:%d", ret_p);
-               packet_destroy(packet_reply);
-       } else {
-               ErrPrint("Failed to create a reply packet");
+       int ret;
+       char *pkgname = NULL;
+       int allow_to_notify = 0;
+       int do_not_disturb_except = 0;
+       int visivility_class = 0;
+
+       g_variant_get(parameters, "(&siii)",
+                       &pkgname,
+                       &allow_to_notify,
+                       &do_not_disturb_except,
+                       &visivility_class);
+
+       DbgPrint("package_name: [%s] allow_to_notify: [%d] do_not_disturb_except: [%d] visivility_class: [%d]\n",
+                       pkgname, allow_to_notify, do_not_disturb_except, visivility_class);
+       ret = notification_setting_db_update(pkgname, allow_to_notify, do_not_disturb_except, visivility_class);
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               ErrPrint("failed to setting db update : %d\n", ret);
+               return ret;
        }
+
+       *reply_body = g_variant_new("()");
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make reply_body");
+               return NOTIFICATION_ERROR_OUT_OF_MEMORY;
+       }
+       DbgPrint("_update_noti_setting_service done !! %d", ret);
+       return ret;
 }
 
-static void _permission_check_property_get(struct tcb *tcb, struct packet *packet)
+/* update_noti_sys_setting */
+int notification_update_noti_sys_setting(GVariant *parameters, GVariant **reply_body)
 {
-       int ret_p = 0;
-       struct packet *packet_reply = NULL;
-
-       packet_reply = packet_create_reply(packet, "is", NOTIFICATION_ERROR_PERMISSION_DENIED, NULL);
-       if (packet_reply) {
-               if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
-                       ErrPrint("Failed to send a reply packet:%d", ret_p);
-               packet_destroy(packet_reply);
-       } else {
-               ErrPrint("Failed to create a reply packet");
+       int ret;
+       int do_not_disturb = 0;
+       int visivility_class = 0;
+
+       g_variant_get(parameters, "(ii)",
+                       &do_not_disturb,
+                       &visivility_class);
+
+       DbgPrint("do_not_disturb [%d] visivility_class [%d]\n", do_not_disturb, visivility_class);
+       ret = notification_setting_db_update_system_setting(do_not_disturb, visivility_class);
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               ErrPrint("failed to setting db update system setting : %d\n", ret);
+               return ret;
+       }
+
+       *reply_body = g_variant_new("()");
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make reply_body");
+               return NOTIFICATION_ERROR_OUT_OF_MEMORY;
        }
+       DbgPrint("_update_noti_sys_setting_service done !! %d", ret);
+       return ret;
 }
 
-/*!
- * NOTIFICATION SERVICE INITIALIZATION
- */
 static void _notification_data_init(void)
 {
        int property = 0;
@@ -616,7 +927,7 @@ static void _notification_data_init(void)
        notification_list_h noti_list_head = NULL;
        notification_type_e noti_type = NOTIFICATION_TYPE_NONE;
 
-       notification_get_list(NOTIFICATION_TYPE_NONE, -1, &noti_list);
+       notification_noti_get_grouping_list(NOTIFICATION_TYPE_NONE, -1, &noti_list);
        noti_list_head = noti_list;
 
        while (noti_list != NULL) {
@@ -639,250 +950,15 @@ static void _notification_data_init(void)
                notification_free_list(noti_list_head);
 }
 
-static void _notification_init(void)
-{
-       int ret = -1;
-       int restart_count = 0;
-
-       ret = vconf_get_int(VCONFKEY_MASTER_RESTART_COUNT, &restart_count);
-       if (ret == 0 && restart_count <= 1)
-               _notification_data_init();
-}
-
-/*!
- * 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_check_noti_by_tag,
-                       .rule = "data-provider-master::notification.client",
-                       .access = "w",
-                       .handler_access_error = _permission_check_common,
-               },
-               {
-                       .cmd = "update_noti",
-                       .handler = _handler_update,
-                       .rule = "data-provider-master::notification.client",
-                       .access = "w",
-                       .handler_access_error = _permission_check_common,
-               },
-               {
-                       .cmd = "load_noti_by_tag",
-                       .handler = _handler_load_noti_by_tag,
-                       .rule = "data-provider-master::notification.client",
-                       .access = "r",
-                       .handler_access_error = _permission_check_common,
-               },
-               {
-                       .cmd = "refresh_noti",
-                       .handler = _handler_refresh,
-                       .rule = "data-provider-master::notification.client",
-                       .access = "w",
-                       .handler_access_error = _permission_check_refresh,
-               },
-               {
-                       .cmd = "del_noti_single",
-                       .handler = _handler_delete_single,
-                       .rule = "data-provider-master::notification.client",
-                       .access = "w",
-                       .handler_access_error = _permission_check_common,
-               },
-               {
-                       .cmd = "del_noti_multiple",
-                       .handler = _handler_delete_multiple,
-                       .rule = "data-provider-master::notification.client",
-                       .access = "w",
-                       .handler_access_error = _permission_check_common,
-               },
-               {
-                       .cmd = "set_noti_property",
-                       .handler = _handler_noti_property_set,
-                       .rule = "data-provider-master::notification.client",
-                       .access = "w",
-                       .handler_access_error = _permission_check_common,
-               },
-               {
-                       .cmd = "get_noti_property",
-                       .handler = _handler_noti_property_get,
-                       .rule = "data-provider-master::notification.client",
-                       .access = "r",
-                       .handler_access_error = _permission_check_property_get,
-               },
-               {
-                       .cmd = "update_noti_setting",
-                       .handler = _handler_noti_update_setting,
-                       .rule = "data-provider-master::notification.client",
-                       .access = "w",
-                       .handler_access_error = _permission_check_property_get,
-               },
-               {
-                       .cmd = "update_noti_sys_setting",
-                       .handler = _handler_noti_update_system_setting,
-                       .rule = "data-provider-master::notification.client",
-                       .access = "w",
-                       .handler_access_error = _permission_check_property_get,
-               },
-               {
-                       .cmd = "service_register",
-                       .handler = _handler_service_register,
-                       .rule = NULL,
-                       .access = NULL,
-                       .handler_access_error = NULL,
-               },
-               {
-                       .cmd = "post_toast",
-                       .handler = _handler_post_toast_message,
-                       .rule = NULL,
-                       .access = NULL,
-                       .handler_access_error = NULL,
-               },
-               {
-                       .cmd = NULL,
-                       .handler = NULL,
-                       .rule = NULL,
-                       .access = NULL,
-                       .handler_access_error = NULL,
-               },
-       };
-
-       static struct noti_service service_req_no_ack_table[] = {
-               {
-                       .cmd = "package_install",
-                       .handler = _handler_package_install,
-                       .rule = NULL,
-                       .access = NULL,
-                       .handler_access_error = NULL,
-               },
-               {
-                       .cmd = NULL,
-                       .handler = NULL,
-                       .rule = NULL,
-                       .access = NULL,
-                       .handler_access_error = NULL,
-               },
-       };
-
-       if (!packet) {
-               DbgPrint("TCB: %p is terminated\n", tcb);
-               return 0;
-       }
-
-       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("%p REQ: Command: [%s]\n", tcb, command);
-
-               for (i = 0; service_req_table[i].cmd; i++) {
-                       if (strcmp(service_req_table[i].cmd, command))
-                               continue;
-
-                       if (service_check_privilege_by_socket_fd(tcb_svc_ctx(tcb), tcb_fd(tcb), "http://tizen.org/privilege/notification") == 1) {
-                               service_req_table[i].handler(tcb, packet, data);
-                       } else {
-                               if (service_req_table[i].handler_access_error != NULL)
-                                       service_req_table[i].handler_access_error(tcb, packet);
-                       }
-                       break;
-               }
-
-               break;
-       case PACKET_REQ_NOACK:
-               DbgPrint("%p PACKET_REQ_NOACK: Command: [%s]\n", tcb, command);
-               for (i = 0; service_req_no_ack_table[i].cmd; i++) {
-                       if (strcmp(service_req_no_ack_table[i].cmd, command))
-                               continue;
-                       service_req_no_ack_table[i].handler(tcb, packet, data);
-                       break;
-               }
-               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;
-}
-
-/*!
- * Managing setting DB
- */
-
-static int _invoke_package_change_event(struct info *notification_service_info, enum pkgmgr_event_type event_type, const char *pkgname)
-{
-       int ret = 0;
-       struct packet *packet = NULL;
-       struct service_context *svc_ctx = notification_service_info->svc_ctx;
-
-       DbgPrint("pkgname[%s], event_type[%d]\n", pkgname, event_type);
-
-       if (event_type == PKGMGR_EVENT_INSTALL) {
-               packet = packet_create_noack("package_install", "s", pkgname);
-       } else if (event_type == PKGMGR_EVENT_UNINSTALL) {
-               packet = packet_create_noack("package_uninstall", "s", pkgname);
-       } else {
-               /* Ignore other events */
-               goto out;
-       }
-
-       if (packet == NULL) {
-               ErrPrint("packet_create_noack failed\n");
-               ret = -1;
-               goto out;
-       }
-
-       if ((ret = service_common_send_packet_to_service(svc_ctx, NULL, packet)) != 0) {
-               ErrPrint("service_common_send_packet_to_service failed[%d]\n", ret);
-               ret = -1;
-               goto out;
-       }
-
-out:
-       if (ret != 0 && packet)
-               packet_destroy(packet);
-
-       DbgPrint("_invoke_package_change_event returns [%d]\n", ret);
-       return ret;
-}
-
 static int _package_install_cb(const char *pkgname, enum pkgmgr_status status, double value, void *data)
 {
-       struct info *notification_service_info = (struct info *)data;
-
-       if (status != PKGMGR_STATUS_END)
-               return 0;
-
-       _invoke_package_change_event(notification_service_info, PKGMGR_EVENT_INSTALL, pkgname);
-
+       notification_setting_insert_package(pkgname);
        return 0;
 }
 
 static int _package_uninstall_cb(const char *pkgname, enum pkgmgr_status status, double value, void *data)
 {
-       struct info *notification_service_info = (struct info *)data;
-
-       if (status != PKGMGR_STATUS_END)
-               return 0;
-
-       _invoke_package_change_event(notification_service_info, PKGMGR_EVENT_UNINSTALL, pkgname);
-
+       notification_setting_delete_package(pkgname);
        return 0;
 }
 
@@ -892,38 +968,28 @@ static int _package_uninstall_cb(const char *pkgname, enum pkgmgr_status status,
  */
 HAPI int notification_service_init(void)
 {
-       if (s_info.svc_ctx) {
-               ErrPrint("Already initialized\n");
-               return SERVICE_COMMON_ERROR_ALREADY_STARTED;
-       }
-
-       _notification_init();
+       int result;
+       result = notification_register_dbus_interface();
 
-       s_info.svc_ctx = service_common_create(NOTIFICATION_SOCKET, NOTIFICATION_SMACK_LABEL, service_thread_main, NULL);
-       if (!s_info.svc_ctx) {
-               ErrPrint("Unable to activate service thread\n");
-               return SERVICE_COMMON_ERROR_FAULT;
+       if(result != SERVICE_COMMON_ERROR_NONE) {
+               ErrPrint("notification register dbus fail %d", result);
+               return result;
        }
+       _notification_data_init();
 
        notification_setting_refresh_setting_table();
 
        pkgmgr_init();
-       pkgmgr_add_event_callback(PKGMGR_EVENT_INSTALL, _package_install_cb, (void *)&s_info);
-       pkgmgr_add_event_callback(PKGMGR_EVENT_UPDATE, _package_install_cb, (void *)&s_info);
-       pkgmgr_add_event_callback(PKGMGR_EVENT_UNINSTALL, _package_uninstall_cb, (void *)&s_info);
+       pkgmgr_add_event_callback(PKGMGR_EVENT_INSTALL, _package_install_cb, NULL);
+       pkgmgr_add_event_callback(PKGMGR_EVENT_UPDATE, _package_install_cb, NULL);
+       pkgmgr_add_event_callback(PKGMGR_EVENT_UNINSTALL, _package_uninstall_cb, NULL);
        DbgPrint("Successfully initiated\n");
        return SERVICE_COMMON_ERROR_NONE;
 }
 
 HAPI int notification_service_fini(void)
 {
-       if (!s_info.svc_ctx)
-               return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
-
        pkgmgr_fini();
-
-       service_common_destroy(s_info.svc_ctx);
-       s_info.svc_ctx = NULL;
        DbgPrint("Successfully Finalized\n");
        return SERVICE_COMMON_ERROR_NONE;
 }
index 545a167..d8c5160 100644 (file)
@@ -203,7 +203,7 @@ static int start_cb(const char *pkgname, const char *val, void *data)
        item->pkgname = strdup(pkgname);
        if (!item->pkgname) {
                ErrPrint("strdup: %d\n", errno);
-               DbgFree(item);
+               free(item);
                return SERVICE_COMMON_ERROR_OUT_OF_MEMORY;
        }
 
@@ -220,8 +220,8 @@ static int start_cb(const char *pkgname, const char *val, void *data)
        } else if (!strcasecmp(val, "recover")) {
                item->type = PKGMGR_EVENT_RECOVER;
        } else {
-               DbgFree(item->pkgname);
-               DbgFree(item);
+               free(item->pkgname);
+               free(item);
                ErrPrint("Invalid val: %s\n", val);
                return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
        }
@@ -243,7 +243,7 @@ static int icon_path_cb(const char *pkgname, const char *val, void *data)
                return SERVICE_COMMON_ERROR_NOT_EXIST;
 
        if (item->icon)
-               DbgFree(item->icon);
+               free(item->icon);
 
        item->icon = strdup(val);
        if (!item->icon) {
@@ -307,7 +307,7 @@ static int change_pkgname_cb(const char *pkgname, const char *val, void *data)
                return SERVICE_COMMON_ERROR_OUT_OF_MEMORY;
        }
 
-       DbgFree(item->pkgname);
+       free(item->pkgname);
        item->pkgname = new_pkgname;
        return SERVICE_COMMON_ERROR_NONE;
 }
@@ -404,9 +404,9 @@ static int end_cb(const char *pkgname, const char *val, void *data)
        invoke_callback(pkgname, item, 0.0f);
 
        s_info.item_list = eina_list_remove(s_info.item_list, item);
-       DbgFree(item->icon);
-       DbgFree(item->pkgname);
-       DbgFree(item);
+       free(item->icon);
+       free(item->pkgname);
+       free(item);
        return SERVICE_COMMON_ERROR_NONE;
 }
 
@@ -477,29 +477,29 @@ HAPI int pkgmgr_fini(void)
        s_info.listen_pc = NULL;
 
        EINA_LIST_FREE(s_info.download_event, item) {
-               DbgFree(item);
+               free(item);
        }
 
        EINA_LIST_FREE(s_info.uninstall_event, item) {
-               DbgFree(item);
+               free(item);
        }
 
        EINA_LIST_FREE(s_info.install_event, item) {
-               DbgFree(item);
+               free(item);
        }
 
        EINA_LIST_FREE(s_info.update_event, item) {
-               DbgFree(item);
+               free(item);
        }
 
        EINA_LIST_FREE(s_info.recover_event, item) {
-               DbgFree(item);
+               free(item);
        }
 
        EINA_LIST_FREE(s_info.item_list, ctx) {
-               DbgFree(ctx->pkgname);
-               DbgFree(ctx->icon);
-               DbgFree(ctx);
+               free(ctx->pkgname);
+               free(ctx->icon);
+               free(ctx);
        }
 
        return SERVICE_COMMON_ERROR_NONE;
@@ -535,7 +535,7 @@ HAPI int pkgmgr_add_event_callback(enum pkgmgr_event_type type, int (*cb)(const
                s_info.recover_event = eina_list_prepend(s_info.recover_event, item);
                break;
        default:
-               DbgFree(item);
+               free(item);
                return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
        }
 
@@ -554,7 +554,7 @@ HAPI void *pkgmgr_del_event_callback(enum pkgmgr_event_type type, int (*cb)(cons
                        if (item->cb == cb && item->data == data) {
                                s_info.download_event = eina_list_remove(s_info.download_event, item);
                                cbdata = item->data;
-                               DbgFree(item);
+                               free(item);
                                break;
                        }
                }
@@ -564,7 +564,7 @@ HAPI void *pkgmgr_del_event_callback(enum pkgmgr_event_type type, int (*cb)(cons
                        if (item->cb == cb && item->data == data) {
                                s_info.uninstall_event = eina_list_remove(s_info.uninstall_event, item);
                                cbdata = item->data;
-                               DbgFree(item);
+                               free(item);
                                break;
                        }
                }
@@ -574,7 +574,7 @@ HAPI void *pkgmgr_del_event_callback(enum pkgmgr_event_type type, int (*cb)(cons
                        if (item->cb == cb && item->data == data) {
                                s_info.install_event = eina_list_remove(s_info.install_event, item);
                                cbdata = item->data;
-                               DbgFree(item);
+                               free(item);
                                break;
                        }
                }
@@ -584,7 +584,7 @@ HAPI void *pkgmgr_del_event_callback(enum pkgmgr_event_type type, int (*cb)(cons
                        if (item->cb == cb && item->data == data) {
                                s_info.update_event = eina_list_remove(s_info.update_event, item);
                                cbdata = item->data;
-                               DbgFree(item);
+                               free(item);
                                break;
                        }
                }
@@ -594,7 +594,7 @@ HAPI void *pkgmgr_del_event_callback(enum pkgmgr_event_type type, int (*cb)(cons
                        if (item->cb == cb && item->data == data) {
                                s_info.recover_event = eina_list_remove(s_info.recover_event, item);
                                cbdata = item->data;
-                               DbgFree(item);
+                               free(item);
                                break;
                        }
                }
old mode 100644 (file)
new mode 100755 (executable)
index 1b436f7..f1fe4d6
  * limitations under the License.
  */
 #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 <sys/timerfd.h>
+#include <stdlib.h>
 #include <unistd.h>
-#include <fcntl.h>
-#include <time.h>
-
+#include <gio/gio.h>
 #include <dlog.h>
-#include <Eina.h>
 #include <cynara-client.h>
 #include <cynara-session.h>
 #include <cynara-creds-socket.h>
-
-#include <com-core.h>
+#include <notification.h>
 
 #include "service_common.h"
-#include "util.h"
 #include "debug.h"
-#include "conf.h"
-
-#define EVT_CH         'e'
-#define EVT_END_CH     'x'
-#define DEFAULT_TIMEOUT        2.0f
-
-int errno;
-
-struct service_event_item {
-       enum {
-               SERVICE_EVENT_TIMER
-       } type;
-
-       union {
-               struct {
-                       int fd;
-               } timer;
-       } info;
-
-       int (*event_cb)(struct service_context *svc_cx, void *data);
-       void *cbdata;
-};
-
-struct tcb_event_cbdata {
-       struct tcb *tcb;
-       void (*cb)(struct service_context *svc_ctx, struct tcb *tcb, void *data);
-       void *data;
-};
-
-/*!
- * \note
- * Server information and global (only in this file-scope) variables are defined
- */
-struct service_context {
-       pthread_t server_thid; /*!< Server thread Id */
-       int fd; /*!< Server socket handle */
-
-       Eina_List *tcb_list; /*!< TCB list, list of every thread for client connections */
-       pthread_mutex_t tcb_list_lock;
 
-       Eina_List *packet_list;
-       pthread_mutex_t packet_list_lock;
-       int evt_pipe[PIPE_MAX];
-       int tcb_pipe[PIPE_MAX];
+#include "notification_service.h"
+#include "badge_service.h"
+#include "shortcut_service.h"
 
-       int (*service_thread_main)(struct tcb *tcb, struct packet *packet, void *data);
-       void *service_thread_data;
+#define PROVIDER_BUS_NAME "org.tizen.data_provider_service"
+#define PROVIDER_OBJECT_PATH "/org/tizen/data_provider_service"
 
-       Eina_List *event_list;
+static GDBusConnection *_gdbus_conn = NULL;
 
-       Eina_List *tcb_create_cb_list;
-       Eina_List *tcb_destroy_cb_list;
+void print_noti(notification_h noti) {
+       char *pkgname = NULL;
+       char *text = NULL;
+       char *content = NULL;
+       const char *tag = NULL;
+       const char *vibration_path = NULL;
+       notification_vibration_type_e type;
 
-       int processing_service_handler;
-
-       cynara *cynara_handle;
-};
-
-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;
-       int ctrl_pipe[PIPE_MAX];
-       pid_t pid; /*!< Keep the PID of client, if the client is remote one, this will be -1 */
-};
-
-static void _initialize_privilege_checker(struct service_context *svc_ctx)
-{
-       int ret;
-
-       /* Cynara structure init */
-       ret = cynara_initialize(&(svc_ctx->cynara_handle), NULL);
-       if (ret != CYNARA_API_SUCCESS)
-               ErrPrint("cynara_initialize failed[%d]\n", ret);
-}
-
-static void _finish_privilege_checker(struct service_context *svc_ctx)
-{
-       int ret;
+       notification_get_pkgname(noti, &pkgname);
+       notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, &text);
+       notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, &content);
+       notification_get_tag(noti, &tag);
+       notification_get_vibration(noti, &type, &vibration_path);
 
-       ret = cynara_finish(svc_ctx->cynara_handle);
-       if (ret != CYNARA_API_SUCCESS)
-               ErrPrint("cynara_initialize failed[%d]\n", ret);
+       DbgPrint("provider print_noti  pkgname  = %s ", pkgname );
+       DbgPrint("provider print_noti  title  = %s ", text );
+       DbgPrint("provider print_noti  content  = %s ", content );
+       DbgPrint("provider print_noti  tag  = %s ", tag );
+       DbgPrint("provider print_noti  vibration_path  = %s ", vibration_path);
 }
 
-HAPI int service_common_send_packet_to_service(struct service_context *svc_ctx, struct tcb *tcb, struct packet *packet)
+int send_notify(GVariant *body, char *cmd, GList *monitoring_app_list, char *interface_name)
 {
-       int ret = 0;
-       struct packet_info *packet_info = NULL;
-       char evt_ch = EVT_CH;
-
-       packet_info = malloc(sizeof(*packet_info));
-       if (!packet_info) {
-               ret = -errno;
-               ErrPrint("malloc: %d\n", errno);
-               goto out;
-       }
-
-       packet_info->packet = packet_ref(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[PIPE_WRITE], &evt_ch, sizeof(evt_ch)) != sizeof(evt_ch)) {
-               ret = -errno;
-               ErrPrint("write: %d\n", errno);
-               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_unref(packet);
-               DbgFree(packet_info);
-               goto out;
-       }
-
-out:
-       return ret;
-}
-
-/*!
- * Do services for clients
- * Routing packets to destination processes.
- * CLIENT THREAD
- */
-static void *client_packet_pump_main(void *data)
-{
-       struct tcb *tcb = data;
-       struct service_context *svc_ctx = tcb->svc_ctx;
-       struct packet *packet = NULL;
-       fd_set set;
-       char *ptr = NULL;
-       int size = 0;
-       int packet_offset = 0;
-       int recv_offset = 0;
-       long ret;
-       int fd;
-       char evt_ch = EVT_CH;
-       enum {
-               RECV_INIT,
-               RECV_HEADER,
-               RECV_PAYLOAD,
-               RECV_DONE,
-       } recv_state;
-       struct packet_info *packet_info;
-       Eina_List *l;
-
-       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);
-               FD_SET(tcb->ctrl_pipe[PIPE_READ], &set);
-               fd = tcb->fd > tcb->ctrl_pipe[PIPE_READ] ? tcb->fd : tcb->ctrl_pipe[PIPE_READ];
-               ret = select(fd + 1, &set, NULL, NULL, NULL);
-               if (ret < 0) {
-                       ret = -errno;
-                       if (errno == EINTR) {
-                               ErrPrint("INTERRUPTED\n");
-                               ret = 0;
-                               continue;
-                       }
-                       ErrPrint("select: %d\n", errno);
-                       DbgFree(ptr);
-                       ptr = NULL;
-                       break;
-               } else if (ret == 0) {
-                       ErrPrint("Timeout\n");
-                       ret = -ETIMEDOUT;
-                       DbgFree(ptr);
-                       ptr = NULL;
-                       break;
-               }
-
-               if (FD_ISSET(tcb->ctrl_pipe[PIPE_READ], &set)) {
-                       DbgPrint("Thread is canceled\n");
-                       ret = -ECANCELED;
-                       DbgFree(ptr);
-                       ptr = NULL;
-                       break;
-               }
-
-               if (!FD_ISSET(tcb->fd, &set)) {
-                       ErrPrint("Unexpected handler is toggled\n");
-                       ret = -EINVAL;
-                       DbgFree(ptr);
-                       ptr = NULL;
-                       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("malloc: %d\n", 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, &tcb->pid);
-                       if (ret <= 0) {
-                               if (ret == 0)
-                                       ret = -ECANCELED;
-                               DbgFree(ptr);
-                               ptr = NULL;
-                               break;
-                       }
-
-                       recv_offset += ret;
-                       ret = 0;
-
-                       if (recv_offset == size) {
-                               packet = packet_build(packet, packet_offset, ptr, size);
-                               DbgFree(ptr);
-                               ptr = NULL;
-                               if (!packet) {
-                                       ret = -EFAULT;
-                                       break;
-                               }
-
-                               packet_offset += recv_offset;
-
-                               size = packet_payload_size(packet);
-                               if (size <= 0) {
-                                       recv_state = RECV_DONE;
-                                       recv_offset = 0;
-                                       break;
-                               }
-
-                               recv_state = RECV_PAYLOAD;
-                               recv_offset = 0;
-
-                               ptr = malloc(size);
-                               if (!ptr) {
-                                       ErrPrint("malloc: %d\n", errno);
-                                       ret = -ENOMEM;
-                               }
-                       }
-                       break;
-               case RECV_PAYLOAD:
-                       ret = secure_socket_recv(tcb->fd, ptr, size - recv_offset, &tcb->pid);
-                       if (ret <= 0) {
-                               if (ret == 0)
-                                       ret = -ECANCELED;
-                               DbgFree(ptr);
-                               ptr = NULL;
-                               break;
-                       }
-
-                       recv_offset += ret;
-                       ret = 0;
-
-                       if (recv_offset == size) {
-                               packet = packet_build(packet, packet_offset, ptr, size);
-                               DbgFree(ptr);
-                               ptr = NULL;
-                               if (!packet) {
-                                       ret = -EFAULT;
-                                       break;
-                               }
-
-                               packet_offset += recv_offset;
-
-                               recv_state = RECV_DONE;
-                               recv_offset = 0;
-                       }
-                       break;
-               case RECV_DONE:
-               default:
-                       /* Dead code */
-                       break;
-               }
-
-               if (recv_state == 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("malloc: %d\n", 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[PIPE_WRITE], &evt_ch, sizeof(evt_ch)) != sizeof(evt_ch)) {
-                               ret = -errno;
-                               ErrPrint("write: %d\n", errno);
-                               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);
-                               DbgFree(packet_info);
-                               ErrPrint("Terminate thread: %p\n", tcb);
-                               break;
-                       } else {
-                               DbgPrint("Packet received: %d bytes\n", packet_offset);
-                               recv_state = RECV_INIT;
-                       }
-
-                       /* Take a breathe */
-                       pthread_yield();
-               }
-       }
-
-       CRITICAL_SECTION_BEGIN(&svc_ctx->packet_list_lock);
-       EINA_LIST_FOREACH(svc_ctx->packet_list, l, packet_info) {
-               if (packet_info->tcb == tcb) {
-                       DbgPrint("Reset ptr of the TCB[%p] in the list of packet info\n", tcb);
-                       packet_info->tcb = NULL;
-               }
-       }
-       CRITICAL_SECTION_END(&svc_ctx->packet_list_lock);
-
-       /*!
-        * \note
-        * Emit a signal to collect this TCB from the SERVER THREAD.
-        */
-       if (write(svc_ctx->tcb_pipe[PIPE_WRITE], &tcb, sizeof(tcb)) != sizeof(tcb))
-               ErrPrint("write: %d\n", errno);
-
-       if (ptr)
-               free(ptr);
-
-       return (void *)ret;
-}
-
-/*!
- * \note
- * SERVER THREAD
- */
-HAPI int service_register_tcb_callback(struct service_context *svc_ctx, struct tcb *tcb, enum tcb_event_type event, void (*cb)(struct service_context *svc_ctx, struct tcb *tcb, void *data), void *data)
-{
-       struct tcb_event_cbdata *cbdata;
-
-       cbdata = malloc(sizeof(*cbdata));
-       if (!cbdata) {
-               ErrPrint("malloc: %d\n", errno);
-               return SERVICE_COMMON_ERROR_OUT_OF_MEMORY;
-       }
-
-       cbdata->tcb = tcb;
-       cbdata->cb = cb;
-       cbdata->data = data;
+       GError *err = NULL;
+       GList *target_list;
+       char *target_bus_name;
 
-       switch (event) {
-       case TCB_EVENT_CREATE:
-               if (tcb)
-                       DbgPrint("To catch the create event of TCB does not requires \"tcb\" handle\n");
-               svc_ctx->tcb_create_cb_list = eina_list_append(svc_ctx->tcb_create_cb_list, cbdata);
-               break;
-       case TCB_EVENT_DESTROY:
-               svc_ctx->tcb_destroy_cb_list = eina_list_append(svc_ctx->tcb_destroy_cb_list, cbdata);
-               break;
-       default:
-               DbgFree(cbdata);
-               return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
-       }
+       target_list = g_list_first(monitoring_app_list);
+       for (; target_list != NULL; target_list = target_list->next) {
+               err = NULL;
+               target_bus_name = target_list->data;
 
-       return SERVICE_COMMON_ERROR_NONE;
-}
+               DbgPrint("emit signal to : %s", target_bus_name);
+               if (g_dbus_connection_emit_signal(_gdbus_conn,
+                                       target_bus_name,
+                                       PROVIDER_OBJECT_PATH,
+                                       interface_name,
+                                       cmd,
+                                       g_variant_ref(body),
+                                       &err) == FALSE) {
 
-/*!
- * \note
- * SERVER THREAD
- */
-HAPI int service_unregister_tcb_callback(struct service_context *svc_ctx, struct tcb *tcb, enum tcb_event_type event, void (*cb)(struct service_context *svc_ctx, struct tcb *tcb, void *data), void *data)
-{
-       struct tcb_event_cbdata *cbdata;
-       Eina_List *l;
-
-       switch (event) {
-       case TCB_EVENT_CREATE:
-               EINA_LIST_FOREACH(svc_ctx->tcb_create_cb_list, l, cbdata) {
-                       if (cbdata->tcb == tcb && cbdata->cb == cb && cbdata->data == data) {
-                               svc_ctx->tcb_create_cb_list = eina_list_remove(svc_ctx->tcb_create_cb_list, cbdata);
-                               DbgFree(cbdata);
-                               return SERVICE_COMMON_ERROR_NONE;
+                       ErrPrint("g_dbus_connection_emit_signal() is failed");
+                       if (err != NULL) {
+                               ErrPrint("g_dbus_connection_emit_signal() err : %s",
+                                               err->message);
+                               g_error_free(err);
                        }
+                       return SERVICE_COMMON_ERROR_IO_ERROR;
                }
-               break;
-       case TCB_EVENT_DESTROY:
-               EINA_LIST_FOREACH(svc_ctx->tcb_destroy_cb_list, l, cbdata) {
-                       if (cbdata->tcb == tcb && cbdata->cb == cb && cbdata->data == data) {
-                               svc_ctx->tcb_destroy_cb_list = eina_list_remove(svc_ctx->tcb_destroy_cb_list, cbdata);
-                               DbgFree(cbdata);
-                               return SERVICE_COMMON_ERROR_NONE;
-                       }
-               }
-               break;
-       default:
-               return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
+               DbgPrint("signal send done: %s", target_bus_name);
        }
 
-       return SERVICE_COMMON_ERROR_NOT_EXIST;
-}
-
-/*!
- * \note
- * SERVER THREAD
- */
-static inline struct tcb *tcb_create(struct service_context *svc_ctx, int fd)
-{
-       struct tcb *tcb;
-       int status;
-       struct tcb_event_cbdata *cbdata;
-       Eina_List *l;
-       Eina_List *n;
-
-       tcb = malloc(sizeof(*tcb));
-       if (!tcb) {
-               ErrPrint("malloc: %d\n", errno);
-               return NULL;
-       }
-
-       if (pipe2(tcb->ctrl_pipe, O_CLOEXEC) < 0) {
-               ErrPrint("pipe2: %d\n", errno);
-               DbgFree(tcb);
-               return NULL;
-       }
-
-       tcb->fd = fd;
-       tcb->svc_ctx = svc_ctx;
-       tcb->type = TCB_CLIENT_TYPE_APP;
-       tcb->pid = -1;
-
-       DbgPrint("Create a new service thread [%d]\n", fd);
-       status = pthread_create(&tcb->thid, NULL, client_packet_pump_main, tcb);
-       if (status != 0) {
-               ErrPrint("pthread_create: %d\n", status);
-               CLOSE_PIPE(tcb->ctrl_pipe);
-               DbgFree(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);
-
-       EINA_LIST_FOREACH_SAFE(svc_ctx->tcb_create_cb_list, l, n, cbdata) {
-               if (!cbdata->cb) {
-                       /* ASSERT */
-                       ErrPrint("invalid CB\n");
-                       svc_ctx->tcb_create_cb_list = eina_list_remove(svc_ctx->tcb_create_cb_list, cbdata);
-                       DbgFree(cbdata);
-                       continue;
-               }
-
-               cbdata->cb(svc_ctx, tcb, cbdata->data);
-       }
-
-       return tcb;
-}
-
-/*!
- * \note
- * SERVER THREAD
- */
-static inline void tcb_teminate_all(struct service_context *svc_ctx)
-{
-       struct tcb *tcb;
-       void *ret;
-       int status;
-       char ch = EVT_END_CH;
-
-       /*!
-        * 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.
-        */
-       EINA_LIST_FREE(svc_ctx->tcb_list, tcb) {
-               /*!
-                * ASSERT(tcb->fd >= 0);
-                */
-               if (write(tcb->ctrl_pipe[PIPE_WRITE], &ch, sizeof(ch)) != sizeof(ch))
-                       ErrPrint("write: %d\n", errno);
-
-               status = pthread_join(tcb->thid, &ret);
-               if (status != 0)
-                       ErrPrint("Unable to join a thread: %d\n", status);
-               else
-                       DbgPrint("Thread returns: %p\n", ret);
-
-               secure_socket_destroy_handle(tcb->fd);
-
-               CLOSE_PIPE(tcb->ctrl_pipe);
-               DbgFree(tcb);
-       }
-}
-
-HAPI int service_common_destroy_tcb(struct service_context *svc_ctx, struct tcb *tcb)
-{
-       if (!svc_ctx || !tcb)
-               return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
-       /**
-        * @note
-        * In this case, we just need to push terminate event to pipe.
-        */
-       if (write(svc_ctx->tcb_pipe[PIPE_WRITE], &tcb, sizeof(tcb)) != sizeof(tcb))
-               ErrPrint("write: %d\n", errno);
-
+       DbgPrint("provider _send_notify cmd %s done", cmd);
        return SERVICE_COMMON_ERROR_NONE;
 }
 
-/*!
- * \note
- * SERVER THREAD
- */
-static inline void tcb_destroy(struct service_context *svc_ctx, struct tcb *tcb)
-{
-       void *ret;
-       int status;
-       char ch = EVT_END_CH;
-       struct tcb_event_cbdata *cbdata;
-       Eina_List *l;
-       Eina_List *n;
-
-       EINA_LIST_FOREACH_SAFE(svc_ctx->tcb_destroy_cb_list, l, n, cbdata) {
-               if (!cbdata->cb) {
-                       /* ASSERT */
-                       ErrPrint("invalid CB\n");
-                       svc_ctx->tcb_destroy_cb_list = eina_list_remove(svc_ctx->tcb_destroy_cb_list, cbdata);
-                       DbgFree(cbdata);
-                       continue;
-               }
-
-               if (cbdata->tcb != tcb)
-                       continue;
-
-               cbdata->cb(svc_ctx, tcb, cbdata->data);
-
-               if (eina_list_data_find(svc_ctx->tcb_destroy_cb_list, cbdata)) {
-                       svc_ctx->tcb_destroy_cb_list = eina_list_remove(svc_ctx->tcb_destroy_cb_list, cbdata);
-                       DbgFree(cbdata);
-               }
-       }
-
-       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);
-        * Close the connection, and then collecting the return value of thread
-        */
-       if (write(tcb->ctrl_pipe[PIPE_WRITE], &ch, sizeof(ch)) != sizeof(ch))
-               ErrPrint("write: %d\n", errno);
-
-       status = pthread_join(tcb->thid, &ret);
-       if (status != 0)
-               ErrPrint("Unable to join a thread: %d\n", status);
-       else
-               DbgPrint("Thread returns: %p\n", ret);
-
-       secure_socket_destroy_handle(tcb->fd);
-
-       CLOSE_PIPE(tcb->ctrl_pipe);
-       DbgFree(tcb);
-}
-
-/*!
- * \note
- * SERVER THREAD
- */
-static inline int update_fdset(struct service_context *svc_ctx, fd_set *set)
-{
-       Eina_List *l;
-       struct service_event_item *item;
-       int fd = 0;
-
-       FD_ZERO(set);
-
-       FD_SET(svc_ctx->fd, set);
-       fd = svc_ctx->fd;
-
-       FD_SET(svc_ctx->tcb_pipe[PIPE_READ], set);
-       if (svc_ctx->tcb_pipe[PIPE_READ] > fd)
-               fd = svc_ctx->tcb_pipe[PIPE_READ];
-
-       FD_SET(svc_ctx->evt_pipe[PIPE_READ], set);
-       if (svc_ctx->evt_pipe[PIPE_READ] > fd)
-               fd = svc_ctx->evt_pipe[PIPE_READ];
+/* register service */
 
-       EINA_LIST_FOREACH(svc_ctx->event_list, l, item) {
-               if (item->type == SERVICE_EVENT_TIMER) {
-                       FD_SET(item->info.timer.fd, set);
-                       if (fd < item->info.timer.fd)
-                               fd = item->info.timer.fd;
-               }
-       }
-
-       return fd + 1;
-}
-
-/*!
- * \note
- * SERVER THREAD
- */
-static inline void processing_timer_event(struct service_context *svc_ctx, fd_set *set)
+static int _monitoring_app_list_compare_cb(gconstpointer a, gconstpointer b)
 {
-       uint64_t expired_count;
-       Eina_List *l;
-       Eina_List *n;
-       struct service_event_item *item;
-
-       EINA_LIST_FOREACH_SAFE(svc_ctx->event_list, l, n, item) {
-               switch (item->type) {
-               case SERVICE_EVENT_TIMER:
-                       if (!FD_ISSET(item->info.timer.fd, set))
-                               break;
-
-                       if (read(item->info.timer.fd, &expired_count, sizeof(expired_count)) == sizeof(expired_count)) {
-                               DbgPrint("Expired %d times\n", expired_count);
-                               if (item->event_cb(svc_ctx, item->cbdata) >= 0)
-                                       break;
-                       } else {
-                               ErrPrint("read: %d\n", errno);
-                       }
-
-                       if (!eina_list_data_find(svc_ctx->event_list, item))
-                               break;
-
-                       svc_ctx->event_list = eina_list_remove(svc_ctx->event_list, item);
-                       if (close(item->info.timer.fd) < 0)
-                               ErrPrint("close: %d\n", errno);
-                       DbgFree(item);
-                       break;
-               default:
-                       ErrPrint("Unknown event: %d\n", item->type);
-                       break;
-               }
-       }
+       return strcmp(a, b);
 }
 
-/*!
- * Accept new client connections
- * And create a new thread for service.
- *
- * Create Client threads & Destroying them
- * SERVER THREAD
- */
-static void *server_main(void *data)
+int service_register(GVariant *parameters, GVariant **reply_body, const gchar *sender,
+       GBusNameAppearedCallback name_appeared_handler,
+       GBusNameVanishedCallback name_vanished_handler,
+       GList **monitoring_list)
 {
-       struct service_context *svc_ctx = data;
-       fd_set set;
-       fd_set except_set;
-       long ret;
-       int client_fd;
-       struct tcb *tcb;
-       int fd;
-       char evt_ch;
-       struct packet_info *packet_info;
-
-       DbgPrint("Server thread is activated\n");
-       while (1) {
-               fd = update_fdset(svc_ctx, &set);
-               memcpy(&except_set, &set, sizeof(set));
-
-               ret = select(fd, &set, NULL, &except_set, NULL);
-               if (ret < 0) {
-                       ret = -errno;
-                       if (errno == EINTR) {
-                               DbgPrint("INTERRUPTED\n");
-                               continue;
-                       }
-                       ErrPrint("select: %d\n", errno);
-                       break;
-               } else if (ret == 0) {
-                       ErrPrint("Timeout\n");
-                       ret = -ETIMEDOUT;
-                       break;
-               }
-
-               if (FD_ISSET(svc_ctx->fd, &set)) {
-                       client_fd = secure_socket_get_connection_handle(svc_ctx->fd);
-                       if (client_fd < 0) {
-                               ErrPrint("Failed to establish a new connection [%d]\n", svc_ctx->fd);
-                               ret = -EFAULT;
-                               break;
-                       }
-
-                       tcb = tcb_create(svc_ctx, client_fd);
-                       if (!tcb) {
-                               ErrPrint("Failed to create a new TCB: %d (%d)\n", client_fd, svc_ctx->fd);
-                               secure_socket_destroy_handle(client_fd);
-                       }
-               }
-
-               if (FD_ISSET(svc_ctx->evt_pipe[PIPE_READ], &set)) {
-                       if (read(svc_ctx->evt_pipe[PIPE_READ], &evt_ch, sizeof(evt_ch)) != sizeof(evt_ch)) {
-                               ErrPrint("read: %d\n", errno);
-                               ret = -EFAULT;
-                               break;
-                       }
+       GList *added_list;
+       const char *bus_name = sender;
+       monitoring_info_s *m_info = NULL;
 
-                       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);
+       if (sender == NULL)
+               return SERVICE_COMMON_ERROR_IO_ERROR;
 
-                       if (packet_info) {
-                               /*!
-                                * \CRITICAL
-                                * What happens if the client thread is terminated, so the packet_info->tcb is deleted
-                                * while processing svc_ctx->service_thread_main?
-                                */
-                               svc_ctx->processing_service_handler = 1;
-                               ret = svc_ctx->service_thread_main(packet_info->tcb, packet_info->packet, svc_ctx->service_thread_data);
-                               svc_ctx->processing_service_handler = 0;
-                               if (ret < 0)
-                                       ErrPrint("Service thread returns: %d\n", ret);
+       added_list = g_list_find_custom(*monitoring_list, bus_name,
+                       (GCompareFunc)_monitoring_app_list_compare_cb);
 
-                               packet_destroy(packet_info->packet);
-                               DbgFree(packet_info);
-                       }
-
-                       /* Take a breathe */
-                       pthread_yield();
+       if (added_list == NULL) {
+               m_info = (monitoring_info_s *)calloc(1, sizeof(monitoring_info_s));
+               if (m_info == NULL) {
+                       ErrPrint("Can not alloc monitoring_info_s");
+                       return SERVICE_COMMON_ERROR_IO_ERROR;
                }
 
-               processing_timer_event(svc_ctx, &set);
-
-               /*!
-                * \note
-                * Destroying TCB should be processed at last.
-                */
-               if (FD_ISSET(svc_ctx->tcb_pipe[PIPE_READ], &set)) {
-                       Eina_List *lockfree_packet_list;
-                       Eina_List *l;
-                       Eina_List *n;
-
-                       if (read(svc_ctx->tcb_pipe[PIPE_READ], &tcb, sizeof(tcb)) != sizeof(tcb)) {
-                               ErrPrint("read: %d\n", errno);
-                               ret = -EFAULT;
-                               break;
-                       }
-
-                       if (!tcb) {
-                               ErrPrint("Terminate service thread\n");
-                               ret = -ECANCELED;
-                               break;
-                       }
-
-                       lockfree_packet_list = NULL;
-                       CRITICAL_SECTION_BEGIN(&svc_ctx->packet_list_lock);
-                       EINA_LIST_FOREACH_SAFE(svc_ctx->packet_list, l, n, packet_info) {
-                               if (packet_info->tcb != tcb)
-                                       continue;
-
-                               svc_ctx->packet_list = eina_list_remove(svc_ctx->packet_list, packet_info);
-                               lockfree_packet_list = eina_list_append(lockfree_packet_list, packet_info);
-                       }
-                       CRITICAL_SECTION_END(&svc_ctx->packet_list_lock);
-
-                       EINA_LIST_FREE(lockfree_packet_list, packet_info) {
-                               ret = read(svc_ctx->evt_pipe[PIPE_READ], &evt_ch, sizeof(evt_ch));
-                               DbgPrint("Flushing filtered pipe: %d (%c)\n", ret, evt_ch);
-                               svc_ctx->processing_service_handler = 1;
-                               ret = svc_ctx->service_thread_main(packet_info->tcb, packet_info->packet, svc_ctx->service_thread_data);
-                               svc_ctx->processing_service_handler = 0;
-                               if (ret < 0)
-                                       ErrPrint("Service thread returns: %d\n", ret);
-
-                               packet_destroy(packet_info->packet);
-                               DbgFree(packet_info);
-                       }
-
-                       /*!
-                        * \note
-                        * Invoke the service thread main, to notify the termination of a TCB
-                        */
-                       svc_ctx->processing_service_handler = 1;
-                       ret = svc_ctx->service_thread_main(tcb, NULL, svc_ctx->service_thread_data);
-                       svc_ctx->processing_service_handler = 0;
-
-                       /*!
-                        * at this time, the client thread can access this tcb.
-                        * how can I protect this TCB from deletion without disturbing the server thread?
-                        */
-                       tcb_destroy(svc_ctx, tcb);
+               m_info->bus_name = strdup(bus_name);
+               m_info->watcher_id = g_bus_watch_name_on_connection(
+                               _gdbus_conn,
+                               bus_name,
+                               G_BUS_NAME_WATCHER_FLAGS_NONE,
+                               name_appeared_handler,
+                               name_vanished_handler,
+                               m_info,
+                               NULL);
+               if (m_info->watcher_id == 0) {
+                       ErrPrint("fail to watch name");
+                       free(m_info->bus_name);
+                       free(m_info);
+                       return SERVICE_COMMON_ERROR_IO_ERROR;
+               } else {
+                       DbgPrint("watch on %s success", bus_name);
                }
 
-               /* If there is no such triggered FD? */
-       }
-
-       /*!
-        * Consuming all pended packets before terminates server thread.
-        *
-        * If the server thread is terminated, we should flush all pended packets.
-        * And we should services them.
-        * While processing this routine, the mutex is locked.
-        * So every other client thread will be slowed down, sequently, every clients can meet problems.
-        * But in case of termination of server thread, there could be systemetic problem.
-        * This only should be happenes while terminating the master daemon process.
-        */
-       CRITICAL_SECTION_BEGIN(&svc_ctx->packet_list_lock);
-       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->processing_service_handler = 1;
-               ret = svc_ctx->service_thread_main(packet_info->tcb, packet_info->packet, svc_ctx->service_thread_data);
-               svc_ctx->processing_service_handler = 0;
-               if (ret < 0)
-                       ErrPrint("Service thread returns: %d\n", ret);
-               packet_destroy(packet_info->packet);
-               DbgFree(packet_info);
-       }
-       CRITICAL_SECTION_END(&svc_ctx->packet_list_lock);
-
-       tcb_teminate_all(svc_ctx);
-       return (void *)ret;
-}
-
-/*!
- * \NOTE
- * MAIN THREAD
- */
-HAPI struct service_context *service_common_create(const char *addr, const char *label, 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;
-       }
-
-       /**
-        * @note
-        * Do not try to delete a URI file if it is created for a remote service or by the systemd service.
-        */
-       if (strncmp(addr, COM_CORE_REMOTE_SCHEME, strlen(COM_CORE_REMOTE_SCHEME)) && strncmp(addr, COM_CORE_SD_LOCAL_SCHEME, strlen(COM_CORE_SD_LOCAL_SCHEME))) {
-               int offset;
-
-               /**
-                * @note
-                * If the address is not for the REMOTE or SD_LOCAL, we can assume it just a local(unix) domain socket file.
-                * So, find the scheme length first and then "unlink" it.
-                */
-               offset = strlen(COM_CORE_LOCAL_SCHEME);
-               if (strncmp(addr, COM_CORE_LOCAL_SCHEME, offset))
-                       offset = 0;
-
-               if (unlink(addr + offset) < 0)
-                       ErrPrint("unlink [%s] - %d\n", addr, errno);
-       }
+               *monitoring_list = g_list_append(*monitoring_list, strdup(bus_name));
+               DbgPrint("service_register : register success sender is %s , length : %d",
+                               sender, g_list_length(*monitoring_list));
 
-       svc_ctx = calloc(1, sizeof(*svc_ctx));
-       if (!svc_ctx) {
-               ErrPrint("calloc: %d\n", errno);
-               return NULL;
+       } else {
+               ErrPrint("service_register : register sender %s already exist", sender);
        }
 
-       svc_ctx->fd = secure_socket_create_server_with_permission(addr, label);
-       if (svc_ctx->fd < 0) {
-               DbgFree(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: %d\n", errno);
-
-       if (fcntl(svc_ctx->fd, F_SETFL, O_NONBLOCK) < 0)
-               ErrPrint("fcntl: %d\n", errno);
-
-       if (pipe2(svc_ctx->evt_pipe, O_CLOEXEC) < 0) {
-               ErrPrint("pipe2: %d\n", errno);
-               secure_socket_destroy_handle(svc_ctx->fd);
-               DbgFree(svc_ctx);
-               return NULL;
-       }
-
-       if (pipe2(svc_ctx->tcb_pipe, O_CLOEXEC) < 0) {
-               ErrPrint("pipe2: %d\n", errno);
-               CLOSE_PIPE(svc_ctx->evt_pipe);
-               secure_socket_destroy_handle(svc_ctx->fd);
-               DbgFree(svc_ctx);
-               return NULL;
-       }
-
-       _initialize_privilege_checker(svc_ctx);
-
-       status = pthread_mutex_init(&svc_ctx->packet_list_lock, NULL);
-       if (status != 0) {
-               ErrPrint("Unable to create a mutex: %d\n", status);
-               CLOSE_PIPE(svc_ctx->evt_pipe);
-               CLOSE_PIPE(svc_ctx->tcb_pipe);
-               secure_socket_destroy_handle(svc_ctx->fd);
-               DbgFree(svc_ctx);
-               return NULL;
-       }
-
-       DbgPrint("Creating server thread\n");
-       status = pthread_create(&svc_ctx->server_thid, NULL, server_main, svc_ctx);
-       if (status != 0) {
-               ErrPrint("Unable to create a thread for shortcut service: %d\n", status);
-               status = pthread_mutex_destroy(&svc_ctx->packet_list_lock);
-               if (status != 0)
-                       ErrPrint("mutex_destroy: %d\n", status);
-
-               CLOSE_PIPE(svc_ctx->evt_pipe);
-               CLOSE_PIPE(svc_ctx->tcb_pipe);
-               secure_socket_destroy_handle(svc_ctx->fd);
-               DbgFree(svc_ctx);
-               return NULL;
+       *reply_body = g_variant_new("()");
+       if (*reply_body == NULL) {
+               free(m_info->bus_name);
+               free(m_info);
+               *monitoring_list = g_list_remove(*monitoring_list, bus_name);
+               ErrPrint("cannot make reply_body");
+               return SERVICE_COMMON_ERROR_OUT_OF_MEMORY;
        }
 
-       /*!
-        * \note
-        * To give a chance to run for server thread.
-        */
-       pthread_yield();
-
-       return svc_ctx;
-}
-
-/*!
- * \note
- * MAIN THREAD
- */
-HAPI int service_common_destroy(struct service_context *svc_ctx)
-{
-       int status = 0;
-       void *ret;
-
-       if (!svc_ctx)
-               return -EINVAL;
-
-       /*!
-        * \note
-        * Terminate server thread
-        */
-       if (write(svc_ctx->tcb_pipe[PIPE_WRITE], &status, sizeof(status)) != sizeof(status))
-               ErrPrint("write: %d\n", errno);
-
-       status = pthread_join(svc_ctx->server_thid, &ret);
-       if (status != 0)
-               ErrPrint("Join: %d\n", status);
-       else
-               DbgPrint("Thread returns: %p\n", ret);
-
-       _finish_privilege_checker(svc_ctx);
-
-       secure_socket_destroy_handle(svc_ctx->fd);
-
-       status = pthread_mutex_destroy(&svc_ctx->packet_list_lock);
-       if (status != 0)
-               ErrPrint("destroy_mutex: %d\n", status);
-
-       CLOSE_PIPE(svc_ctx->evt_pipe);
-       CLOSE_PIPE(svc_ctx->tcb_pipe);
-       DbgFree(svc_ctx);
-       return 0;
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
-/*!
- * \note
- * SERVER THREAD or OTHER THREAD (not main)
- */
-HAPI int tcb_is_valid(struct service_context *svc_ctx, struct tcb *tcb)
+static int _dbus_init(void)
 {
-       Eina_List *l;
-       struct tcb *tmp;
-       int ret = -ENOENT;
+       GError *error = NULL;
 
-       CRITICAL_SECTION_BEGIN(&svc_ctx->tcb_list_lock);
-       EINA_LIST_FOREACH(svc_ctx->tcb_list, l, tmp) {
-               if (tmp == tcb /* && tcb->svc_ctx == svc_ctx */) {
-                       ret = tcb->fd;
-                       break;
+       if(_gdbus_conn == NULL) {
+               _gdbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+               if (_gdbus_conn == NULL) {
+                       if (error != NULL) {
+                               ErrPrint("Failed to get dbus [%s]", error->message);
+                               g_error_free(error);
+                       }
+                       return SERVICE_COMMON_ERROR_IO_ERROR;
                }
        }
-       CRITICAL_SECTION_END(&svc_ctx->tcb_list_lock);
-
-       return ret;
-}
-
-/*!
- * \note
- * SERVER THREAD
- */
-HAPI int tcb_pid(struct tcb *tcb)
-{
-       if (!tcb)
-               return -1;
-
-       return tcb->pid;
-}
-
-/*!
- * \note
- * SERVER THREAD
- */
-HAPI int tcb_fd(struct tcb *tcb)
-{
-       if (!tcb)
-               return -EINVAL;
-
-       return tcb->fd;
-}
-
-/*!
- * \note
- * SERVER THREAD
- */
-HAPI int tcb_client_type(struct tcb *tcb)
-{
-       if (!tcb)
-               return -EINVAL;
-
-       return tcb->type;
-}
-
-/*!
- * \note
- * SERVER THREAD
- */
-HAPI int tcb_client_type_set(struct tcb *tcb, enum tcb_type type)
-{
-       if (!tcb)
-               return -EINVAL;
 
-       DbgPrint("TCB[%p] Client type is changed to %d from %d\n", tcb, type, tcb->type);
-       tcb->type = type;
-       return 0;
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
-/*!
- * \note
- * SERVER THREAD
- */
-HAPI struct service_context *tcb_svc_ctx(struct tcb *tcb)
+int service_common_register_dbus_interface(char *introspection_xml, GDBusInterfaceVTable interface_vtable)
 {
-       if (!tcb)
-               return NULL;
+       int result;
+       int owner_id, noti_registration_id;
+       GError *error = NULL;
+       GDBusNodeInfo *introspection_data = NULL;
 
-       return tcb->svc_ctx;
-}
-
-/*!
- * \note
- * SERVER THREAD
- */
-HAPI int service_common_unicast_packet(struct tcb *tcb, struct packet *packet)
-{
-       if (!tcb || !packet) {
-               DbgPrint("Invalid unicast: tcb[%p], packet[%p]\n", tcb, packet);
-               return -EINVAL;
+       result = _dbus_init();
+       if (result != SERVICE_COMMON_ERROR_NONE) {
+                       ErrPrint("Can't init dbus %d", result);
+                       result = SERVICE_COMMON_ERROR_IO_ERROR;
+                       goto out;
        }
 
-       DbgPrint("Unicast packet\n");
-       return com_core_send(tcb->fd, (void *)packet_data(packet), packet_size(packet), DEFAULT_TIMEOUT);
-}
-
-/*!
- * \note
- * SERVER THREAD
- */
-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) {
-               DbgPrint("Invalid multicast: tcb[%p], packet[%p]\n", tcb, packet);
-               return -EINVAL;
+       owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
+                       PROVIDER_BUS_NAME,
+                       G_BUS_NAME_OWNER_FLAGS_NONE,
+                       NULL,
+                       NULL,
+                       NULL,
+                       NULL, NULL);
+       if (!owner_id) {
+               ErrPrint("g_bus_own_name error");
+               result = SERVICE_COMMON_ERROR_IO_ERROR;
+               goto out;
        }
 
-       svc_ctx = tcb->svc_ctx;
-
-       DbgPrint("Multicasting packets\n");
-
-       /*!
-        * \note
-        * Does not need to make a critical section from here.
-        */
-       EINA_LIST_FOREACH(svc_ctx->tcb_list, l, target) {
-               if (target == tcb || target->type != type) {
-                       DbgPrint("Skip target: %p(%d) == %p/%d\n", target, target->type, tcb, type);
-                       continue;
+       DbgPrint("Acquiring the own name : %d", owner_id);
+       introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, &error);
+       if (!introspection_data) {
+               ErrPrint("g_dbus_node_info_new_for_xml() is failed.");
+               result = SERVICE_COMMON_ERROR_IO_ERROR;
+               if (error != NULL) {
+                       ErrPrint("g_dbus_node_info_new_for_xml error [%s]", error->message);
+                       g_error_free(error);
                }
-
-               ret = com_core_send(target->fd, (void *)packet_data(packet), packet_size(packet), DEFAULT_TIMEOUT);
-               if (ret < 0)
-                       ErrPrint("Failed to send packet: %d\n", ret);
-       }
-       DbgPrint("Finish to multicast packet\n");
-       return 0;
-}
-
-/*!
- * \note
- * SERVER THREAD
- */
-HAPI struct service_event_item *service_common_add_timer(struct service_context *svc_ctx, double timer, int (*timer_cb)(struct service_context *svc_cx, void *data), void *data)
-{
-       struct service_event_item *item;
-
-       item = calloc(1, sizeof(*item));
-       if (!item) {
-               ErrPrint("calloc: %d\n", errno);
-               return NULL;
-       }
-
-       item->type = SERVICE_EVENT_TIMER;
-       item->info.timer.fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC);
-       if (item->info.timer.fd < 0) {
-               ErrPrint("timerfd_create: %d\n", errno);
-               DbgFree(item);
-               return NULL;
-       }
-
-       if (service_common_update_timer(item, timer) < 0) {
-               if (close(item->info.timer.fd) < 0)
-                       ErrPrint("close: %d\n", errno);
-               DbgFree(item);
-               return NULL;
-       }
-
-       item->event_cb = timer_cb;
-       item->cbdata = data;
-
-       svc_ctx->event_list = eina_list_append(svc_ctx->event_list, item);
-       return item;
-}
-
-HAPI int service_common_update_timer(struct service_event_item *item, double timer)
-{
-       struct itimerspec spec;
-
-       spec.it_interval.tv_sec = (time_t)timer;
-       spec.it_interval.tv_nsec = (timer - spec.it_interval.tv_sec) * 1000000000;
-
-       if (clock_gettime(CLOCK_MONOTONIC, &spec.it_value) < 0) {
-               ErrPrint("clock_gettime: %d\n", errno);
-               return -EFAULT;
-       }
-
-       spec.it_value.tv_sec += spec.it_interval.tv_sec;
-       spec.it_value.tv_nsec += spec.it_interval.tv_nsec;
-
-       if (timerfd_settime(item->info.timer.fd, TFD_TIMER_ABSTIME, &spec, NULL) < 0) {
-               ErrPrint("timerfd_settime: %d\n", errno);
-               return -EFAULT;
-       }
-
-       DbgPrint("Armed interval: %u %u\n", spec.it_interval.tv_sec, spec.it_interval.tv_nsec);
-       return 0;
-}
-
-/*!
- * \note
- * SERVER THREAD
- */
-HAPI int service_common_del_timer(struct service_context *svc_ctx, struct service_event_item *item)
-{
-       if (!eina_list_data_find(svc_ctx->event_list, item)) {
-               ErrPrint("Invalid event item\n");
-               return -EINVAL;
+               goto out;
        }
 
-       svc_ctx->event_list = eina_list_remove(svc_ctx->event_list, item);
-
-       if (close(item->info.timer.fd) < 0)
-               ErrPrint("close: %d\n", errno);
-       DbgFree(item);
-       return 0;
-}
-
-HAPI int service_common_fd(struct service_context *ctx)
-{
-       return ctx->fd;
-}
-
-
-HAPI int service_check_privilege_by_socket_fd(struct service_context *svc_ctx, int socket_fd, char *privilege)
-{
-       int ret = 0;
-       int result = 0;
-       char *uid = NULL;
-       pid_t pid;
-       char *client_smack = NULL;
-       char *session = NULL;
-
-       if (privilege != NULL) {
-
-               ret = cynara_creds_socket_get_client(socket_fd, CLIENT_METHOD_SMACK, &client_smack);
-
-               if (ret != CYNARA_API_SUCCESS) {
-                       ErrPrint("cynara_creds_socket_get_client failed [%d]", ret);
-                       goto out;
-               }
-
-               ret = cynara_creds_socket_get_user(socket_fd, USER_METHOD_UID, &uid);
-
-               if (ret != CYNARA_API_SUCCESS) {
-                       ErrPrint("cynara_creds_socket_get_user failed [%d]", ret);
-                       goto out;
-               }
-
-               ret = cynara_creds_socket_get_pid(socket_fd, &pid);
-
-               if (ret != CYNARA_API_SUCCESS) {
-                       ErrPrint("cynara_creds_socket_get_pid failed [%d]", ret);
-                       goto out;
-               }
-
-               session = cynara_session_from_pid(pid);
-
-               if (session == NULL) {
-                       ErrPrint("cynara_session_from_pid failed");
-                       goto out;
-               }
-
-               ret = cynara_check(svc_ctx->cynara_handle, client_smack, session, uid, privilege);
-
-               if (ret == CYNARA_API_ACCESS_ALLOWED) {
-                       DbgPrint("[%s] Access allowed.", privilege);
-                       result = 1;
-               } else {
-                       DbgPrint("[%s] Access denied.[%d]", privilege, ret);
-                       result = 0;
-               }
+       noti_registration_id = g_dbus_connection_register_object(_gdbus_conn,
+                       PROVIDER_OBJECT_PATH, introspection_data->interfaces[0],
+                       &interface_vtable, NULL, NULL, NULL);
 
+       DbgPrint("noti_registration_id %d", noti_registration_id);
+       if (noti_registration_id == 0) {
+               ErrPrint("Failed to g_dbus_connection_register_object");
+               result = SERVICE_COMMON_ERROR_IO_ERROR;
+               goto out;
        }
 
 out:
-       if (client_smack)
-               free(client_smack);
-
-       if (session)
-               free(session);
-
-       if (uid)
-               free(uid);
+       if (introspection_data)
+               g_dbus_node_info_unref(introspection_data);
 
        return result;
 }
-
-/* End of a file */
index ddc5d9f..fb33013 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#include <stdio.h>
-
-#include <Eina.h>
-
 #include <dlog.h>
-#include <packet.h>
-
-#include <Eina.h>
-#include <sys/smack.h>
-
-#if defined(HAVE_SECURITY_SERVER)
-#include <security-server.h>
-#endif
+#include <gio/gio.h>
+#include <shortcut_db.h>
 #include <shortcut.h>
-
 #include "service_common.h"
+#include "shortcut_service.h"
 #include "debug.h"
-#include "util.h"
-#include "conf.h"
-
-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;
-};
+#define PROVIDER_SHORTCUT_INTERFACE_NAME "org.tizen.data_provider_shortcut_service"
 
-/*!
- * SERVICE THREAD
- */
-static inline int put_reply_context(struct tcb *tcb, double seq)
+static GList *_monitoring_list = NULL;
+
+int shortcut_get_shortcut_service_list(GVariant *parameters, GVariant **reply_body);
+
+static void _on_name_appeared(GDBusConnection *connection,
+               const gchar     *name,
+               const gchar     *name_owner,
+               gpointer         user_data)
 {
-       struct context *ctx;
+       DbgPrint("name appeared : %s", name);
+}
 
-       ctx = malloc(sizeof(*ctx));
-       if (!ctx) {
-               ErrPrint("malloc: %d\n", errno);
-               return -ENOMEM;
-       }
+static void _on_name_vanished(GDBusConnection *connection,
+               const gchar     *name,
+               gpointer         user_data)
+{
+       DbgPrint("name vanished : %s", name);
+       monitoring_info_s *info = (monitoring_info_s *)user_data;
+
+       if (info) {
+               g_bus_unwatch_name(info->watcher_id);
 
-       ctx->tcb = tcb;
-       ctx->seq = seq; /* Could we this sequence value is uniq? */
+               if (info->bus_name) {
+                       _monitoring_list = g_list_remove(_monitoring_list, info->bus_name);
+                       free(info->bus_name);
+               }
+               free(info);
+       }
 
-       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)
+static void _shortcut_dbus_method_call_handler(GDBusConnection *conn,
+               const gchar *sender, const gchar *object_path,
+               const gchar *iface_name, const gchar *method_name,
+               GVariant *parameters, GDBusMethodInvocation *invocation,
+               gpointer user_data)
 {
-       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;
-               DbgFree(ctx);
-               break;
+       /* TODO : sender authority(privilege) check */
+       DbgPrint("shortcut method_name: %s", method_name);
+       GVariant *reply_body = NULL;
+       int ret = SHORTCUT_ERROR_NOT_SUPPORTED;
+
+       if (g_strcmp0(method_name, "shortcut_service_register") == 0)
+               ret = service_register(parameters, &reply_body, sender,
+                _on_name_appeared, _on_name_vanished, &_monitoring_list);
+       else if (g_strcmp0(method_name, "add_shortcut") == 0)
+               ret = shortcut_add(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "add_shortcut_widget") == 0)
+               ret = shortcut_add_widget(parameters, &reply_body);
+       else if (g_strcmp0(method_name, "get_list") == 0)
+               ret = shortcut_get_shortcut_service_list(parameters, &reply_body);
+
+       if (ret == SHORTCUT_ERROR_NONE) {
+               DbgPrint("shortcut service success : %d", ret);
+               g_dbus_method_invocation_return_value(
+                               invocation, reply_body);
+       } else {
+               DbgPrint("shortcut service fail : %d", ret);
+               g_dbus_method_invocation_return_error(
+                               invocation,
+                               SHORTCUT_ERROR,
+                               ret,
+                               "shortcut service error");
        }
-
-       return tcb;
 }
 
-static void send_reply_packet(struct tcb *tcb, struct packet *packet, int ret)
+static const GDBusInterfaceVTable _shortcut_interface_vtable = {
+               _shortcut_dbus_method_call_handler,
+               NULL,
+               NULL
+};
+
+int shortcut_register_dbus_interface()
 {
-       struct packet *reply_packet;
+       static gchar introspection_xml[] =
+                       "  <node>"
+                       "  <interface name='org.tizen.data_provider_shortcut_service'>"
+                       "        <method name='shortcut_service_register'>"
+                       "        </method>"
+                       "        <method name='get_list'>"
+                       "          <arg type='v' name='package_name' direction='in'/>"
+                       "          <arg type='i' name='shortcut_cnt' direction='out'/>"
+                       "          <arg type='a(v)' name='shortcut_list' direction='out'/>"
+                       "        </method>"
+                       "        <method name='add_shortcut'>"
+                       "          <arg type='i' name='pid' direction='in'/>"
+                       "          <arg type='s' name='appid' direction='in'/>"
+                       "          <arg type='s' name='name' direction='in'/>"
+                       "          <arg type='i' name='type' direction='in'/>"
+                       "          <arg type='s' name='uri' direction='in'/>"
+                       "          <arg type='s' name='icon' direction='in'/>"
+                       "          <arg type='i' name='allow_duplicate' direction='in'/>"
+                       "        </method>"
+
+                       "        <method name='add_shortcut_widget'>"
+                       "          <arg type='i' name='pid' direction='in'/>"
+                       "          <arg type='s' name='widget_id' direction='in'/>"
+                       "          <arg type='s' name='name' direction='in'/>"
+                       "          <arg type='i' name='size' direction='in'/>"
+                       "          <arg type='s' name='uri' direction='in'/>"
+                       "          <arg type='s' name='icon' direction='in'/>"
+                       "          <arg type='d' name='period' direction='in'/>"
+                       "          <arg type='i' name='allow_duplicate' direction='in'/>"
+                       "        </method>"
+                       "  </interface>"
+                       "  </node>";
+
+       return service_common_register_dbus_interface(introspection_xml, _shortcut_interface_vtable);
+}
 
-       reply_packet = packet_create_reply(packet, "i", ret);
-       if (!reply_packet) {
-               ErrPrint("Failed to create a packet\n");
+static void _release_shortcut_info(gpointer data)
+{
+       if (data == NULL)
                return;
+
+       shortcut_info_s *shortcut = (shortcut_info_s *)data;
+       if (shortcut->package_name)
+               free(shortcut->package_name);
+       if (shortcut->icon)
+               free(shortcut->icon);
+       if (shortcut->name)
+               free(shortcut->name);
+       if (shortcut->extra_key)
+               free(shortcut->extra_key);
+       if (shortcut->extra_data)
+               free(shortcut->extra_data);
+       free(shortcut);
+}
+
+/* get_list */
+int shortcut_get_shortcut_service_list(GVariant *parameters, GVariant **reply_body)
+{
+       int count;
+       GList *shortcut_list = NULL;
+       GList *iter_list = NULL;
+       GVariant *param_body = NULL;
+       GVariant *body = NULL;
+       shortcut_info_s *shortcut;
+       GVariantDict dict;
+       char *package_name = NULL;
+       GVariantBuilder *builder;
+
+       g_variant_get(parameters, "(v)", &param_body);
+       g_variant_dict_init(&dict, param_body);
+       g_variant_dict_lookup(&dict, "package_name", "&s", &package_name);
+       g_variant_dict_end (&dict);
+
+       count = shortcut_db_get_list(package_name, &shortcut_list);
+       DbgPrint("shortcut count : %d", count);
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a(v)"));
+       if (count > 0) {
+               iter_list = g_list_first(shortcut_list);
+               for (; iter_list != NULL; iter_list = iter_list->next) {
+                       shortcut = iter_list->data;
+                       body = g_variant_new("(&s&s&s&s&s)",
+                               shortcut->package_name, shortcut->icon, shortcut->name, shortcut->extra_key, shortcut->extra_data);
+                       g_variant_builder_add(builder, "v", body);
+               }
+               g_list_free_full(shortcut_list, (GDestroyNotify)_release_shortcut_info);
        }
 
-       if (service_common_unicast_packet(tcb, reply_packet) < 0)
-               ErrPrint("Unable to send reply packet\n");
+       *reply_body = g_variant_new("(ia(v))", count, builder);
+       g_variant_builder_unref(builder);
 
-       packet_destroy(reply_packet);
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make reply_body");
+               return SHORTCUT_ERROR_OUT_OF_MEMORY;
+       }
+
+       DbgPrint("shortcut_get_shortcut_service_list done !!");
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
-/*!
- * SERVICE THREAD
- */
-static int service_thread_main(struct tcb *tcb, struct packet *packet, void *data)
+/* add_shortcut */
+int shortcut_add(GVariant *parameters, GVariant **reply_body)
 {
-       const char *command;
+       int ret = SERVICE_COMMON_ERROR_NONE;
 
-       if (!packet) {
-               DbgPrint("TCB: %p is terminated (NIL packet)\n", tcb);
-               return 0;
+       ret = send_notify(parameters, "add_shortcut_notify", _monitoring_list, PROVIDER_SHORTCUT_INTERFACE_NAME);
+       if (ret != SERVICE_COMMON_ERROR_NONE) {
+               ErrPrint("failed to send notify:%d\n", ret);
+               return ret;
        }
 
-       command = packet_command(packet);
-       if (!command) {
-               ErrPrint("Invalid command\n");
-               return -EINVAL;
+       *reply_body = g_variant_new("()");
+       if (*reply_body == NULL) {
+               ErrPrint("Cannot make reply body");
+               return SHORTCUT_ERROR_OUT_OF_MEMORY;
        }
 
-       switch (packet_type(packet)) {
-       case PACKET_REQ:
-
-               /* Need to send reply packet */
-               DbgPrint("%p REQ: Command: [%s]\n", tcb, command);
-               if (!strcmp(command, "add_shortcut_widget") || !strcmp(command, "rm_shortcut_widget")) {
-                       int ret;
-                       ret = service_check_privilege_by_socket_fd(tcb_svc_ctx(tcb), tcb_fd(tcb), "http://tizen.org/privilege/shortcut");
-                       if (ret == 0) {
-                               ErrPrint("SMACK:Access denied\n");
-                               send_reply_packet(tcb, packet, SHORTCUT_ERROR_PERMISSION_DENIED);
-                               break;
-                       }
-
-               } else if (!strcmp(command, "add_shortcut") || !strcmp(command, "rm_shortcut")) {
-                       int ret;
-                       ret = service_check_privilege_by_socket_fd(tcb_svc_ctx(tcb), tcb_fd(tcb), "http://tizen.org/privilege/shortcut");
-                       if (ret == 0) {
-                               ErrPrint("SMACK:Access denied\n");
-                               send_reply_packet(tcb, packet, SHORTCUT_ERROR_PERMISSION_DENIED);
-                               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("%p REQ_NOACK: Command: [%s]\n", tcb, command);
-               if (!strcmp(command, "service_register")) {
-                       tcb_client_type_set(tcb, TCB_CLIENT_TYPE_SERVICE);
-                       break;
-               }
+       return ret;
+}
 
-               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("%p ACK: Command: [%s]\n", tcb, command);
-               tcb = get_reply_context(packet_seq(packet));
-               if (!tcb) {
-                       ErrPrint("There is no proper context\n");
-                       break;
-               }
+/* add_shortcut_widget */
+int shortcut_add_widget(GVariant *parameters, GVariant **reply_body)
+{
+       int ret = SERVICE_COMMON_ERROR_NONE;
 
-               if (tcb_is_valid(s_info.svc_ctx, tcb) < 0) {
-                       ErrPrint("TCB is not valid (already disconnected?)\n");
-                       break;
-               }
+       ret = send_notify(parameters, "add_shortcut_widget_notify", _monitoring_list, PROVIDER_SHORTCUT_INTERFACE_NAME);
+       if (ret != SERVICE_COMMON_ERROR_NONE) {
+               ErrPrint("failed to send notify:%d\n", ret);
+               return ret;
+       }
 
-               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;
+       *reply_body = g_variant_new("()");
+       if (*reply_body == NULL) {
+               ErrPrint("Cannot make reply body");
+               return SHORTCUT_ERROR_OUT_OF_MEMORY;
        }
 
-       /*!
-        * return value has no meanning,
-        * it will be printed by dlogutil.
-        */
-       return 0;
+       return ret;
 }
 
-
 /*!
  * MAIN THREAD
  * Do not try to do anyother operation in these functions
  */
-
 HAPI int shortcut_service_init(void)
 {
-       if (s_info.svc_ctx) {
-               ErrPrint("Already initialized\n");
-               return SERVICE_COMMON_ERROR_ALREADY_STARTED;
-       }
+       DbgPrint("Successfully initiated\n");
+       int result;
 
-       s_info.svc_ctx = service_common_create(SHORTCUT_SOCKET, SHORTCUT_SMACK_LABEL, service_thread_main, NULL);
-       if (!s_info.svc_ctx) {
-               ErrPrint("Unable to activate service thread\n");
-               return SERVICE_COMMON_ERROR_FAULT;
+       result = shortcut_register_dbus_interface();
+       if(result != SERVICE_COMMON_ERROR_NONE) {
+               ErrPrint("shortcut register dbus fail %d", result);
        }
-
-       DbgPrint("Successfully initiated\n");
-       return SERVICE_COMMON_ERROR_NONE;
+       return result;
 }
 
 HAPI int shortcut_service_fini(void)
 {
-       if (!s_info.svc_ctx)
-               return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
-
-       service_common_destroy(s_info.svc_ctx);
-       s_info.svc_ctx = NULL;
        DbgPrint("Successfully Finalized\n");
        return SERVICE_COMMON_ERROR_NONE;
 }