Remove ecore dependency 53/125253/11
authorKichan Kwon <k_c.kwon@samsung.com>
Tue, 11 Apr 2017 01:35:15 +0000 (10:35 +0900)
committerKichan Kwon <k_c.kwon@samsung.com>
Thu, 11 May 2017 02:20:30 +0000 (11:20 +0900)
- For resourced to be lighten

- Instead, we will use glib and libdbus
  - ecore_fd_handler -> fd-handler (based on GIO)
  - ecore_timer -> GSource (g_timeout)
  - ecore_main_loop -> g_main_loop
  - edbus -> libdbus (it is lighter than gdbus)

Change-Id: I85f0cdd0ca83438226d335a7860acea9e6ad4fb7
Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>
40 files changed:
CMakeLists.txt
packaging/resourced.spec
src/CMakeLists.txt
src/block/block-monitor.c
src/block/block.c
src/block/include/block.h
src/common/dbus-handler.c [new file with mode: 0644]
src/common/dbus-handler.h [new file with mode: 0644]
src/common/edbus-handler.c [deleted file]
src/common/edbus-handler.h [deleted file]
src/common/fd-handler.c [new file with mode: 0644]
src/common/fd-handler.h [new file with mode: 0644]
src/common/module.c
src/cpu/cpu.c
src/freezer/freezer.c
src/heart/decision.c
src/heart/heart-abnormal.c
src/heart/heart-battery.c
src/heart/heart-cpu.c
src/heart/heart-memory.c
src/heart/heart-storage.c
src/heart/heart.c
src/heart/include/logging.h
src/heart/logging.c
src/memory/lowmem-dbus.c
src/memory/vmpressure-lowmem-handler.c
src/proc-stat/include/proc-main.h
src/proc-stat/include/proc-usage-stats-helper.h
src/proc-stat/proc-appusage.c
src/proc-stat/proc-handler.c
src/proc-stat/proc-main.c
src/proc-stat/proc-monitor.c
src/proc-stat/proc-process.c
src/proc-stat/proc-usage-stats.c
src/resourced/init.c
src/resourced/init.h
src/resourced/main.c
src/swap/swap.c
src/timer-slack/timer-slack.c
src/vip-agent/vip-process.c

index 8335ae9..d16ecaa 100644 (file)
@@ -33,7 +33,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 #following section is needed for pkg-config *.in file
 SET(INCLUDEDIR ${PREFIX}/include)
 SET(PC_NAME lib${RESOURCED})
-SET(PC_REQUIRED "glib-2.0 vconf vconf-internal-keys sqlite3 dlog eina edbus")
+SET(PC_REQUIRED "glib-2.0 vconf vconf-internal-keys sqlite3 dlog dbus-1")
 
 SET(PC_CFLAGS -I\${includedir}/system)
 SET(VERSION ${FULLVER})
index 0885bda..41107a7 100644 (file)
@@ -41,9 +41,7 @@ BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(sqlite3)
 BuildRequires:  pkgconfig(vconf)
 BuildRequires:  pkgconfig(vconf-internal-keys)
-BuildRequires:  pkgconfig(ecore)
-BuildRequires:  pkgconfig(eina)
-BuildRequires:  pkgconfig(edbus)
+BuildRequires:  pkgconfig(dbus-1)
 BuildRequires:  pkgconfig(libsystemd)
 BuildRequires:  pkgconfig(openssl)
 BuildRequires:  pkgconfig(leveldb)
index 11b9ad8..2fa654e 100644 (file)
@@ -120,15 +120,12 @@ IF("${BLOCK_MODULE}" STREQUAL "ON")
 ENDIF()
 
 SET(REQUIRES_LIST ${REQUIRES_LIST}
-       ecore
        dlog
        glib-2.0
        sqlite3
        vconf
        vconf-internal-keys
-       eina
-       edbus
-       eina
+       dbus-1
        libsystemd
        leveldb
        eventsystem
index 069dd52..6a452bd 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <dirent.h>
 #include <stdbool.h>
+#include <stdlib.h>
 #include <errno.h>
 #include <ctype.h>
 #include <fcntl.h>
@@ -38,7 +39,6 @@
 #include <sys/fanotify.h>
 #include <sys/mount.h>
 #include <mntent.h>
-#include <Ecore.h>
 
 #include "notifier.h"
 #include "procfs.h"
@@ -53,6 +53,7 @@
 #include "file-helper.h"
 #include "block.h"
 #include "logging.h"
+#include "fd-handler.h"
 
 #define FAN_MODE_ACCESS                "ACCESS"
 #define FAN_MODE_READ          "READ"
@@ -165,9 +166,9 @@ static void block_logging(struct block_monitor_info *bmi, pid_t pid,
        }
 }
 
-static Eina_Bool block_monitor_cb(void *user_data, Ecore_Fd_Handler *fd_handler)
+static bool block_monitor_cb(int fd, void *user_data)
 {
-       int fd, n, ret;
+       int n, ret;
        struct fanotify_event_metadata *m;
        union {
                struct fanotify_event_metadata metadata;
@@ -177,24 +178,13 @@ static Eina_Bool block_monitor_cb(void *user_data, Ecore_Fd_Handler *fd_handler)
        struct block_monitor_info *bmi = (struct block_monitor_info *)user_data;
        gpointer hash = 0;
 
-       if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) {
-               _E("ecore_main_fd_handler_active_get error , return\n");
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       fd = ecore_main_fd_handler_fd_get(fd_handler);
-       if (fd < 0) {
-               _E("ecore_main_fd_handler_fd_get error, return\n");
-               return ECORE_CALLBACK_CANCEL;
-       }
-
        n = read(fd, &data, sizeof(data));
        if (n < 0) {
                _E("Failed to read fanotify event\n");
                if (errno == EINTR || errno == EAGAIN || errno == EACCES)
-                       return ECORE_CALLBACK_RENEW;
+                       return true;
                else
-                       return ECORE_CALLBACK_CANCEL;
+                       return false;
        }
 
        for (m = &data.metadata; FAN_EVENT_OK(m, n); m = FAN_EVENT_NEXT(m, n)) {
@@ -248,7 +238,7 @@ next:
                if (m->fd >= 0)
                        close(m->fd);
        }
-       return ECORE_CALLBACK_RENEW;
+       return true;
 }
 
 static void block_logging_init(struct block_monitor_info *bmi)
@@ -289,8 +279,7 @@ int register_fanotify(struct block_monitor_info *bmi)
                _E("Failed to mark fanotify for %s", bmi->path);
                goto error;
        }
-       bmi->fd_handler = ecore_main_fd_handler_add(
-               bmi->mfd, ECORE_FD_READ, block_monitor_cb, bmi, NULL, NULL);
+       add_fd_read_handler(bmi->mfd, block_monitor_cb, bmi, NULL, &(bmi->fd_handler));
        block_logging_init(bmi);
        return RESOURCED_ERROR_NONE;
 error:
@@ -319,6 +308,6 @@ void unregister_fanotify(struct block_monitor_info *bmi)
                        bmi->mount = BLOCK_MOUNT_ORIGINAL;
                }
                close(bmi->mfd);
-               ecore_main_fd_handler_del(bmi->fd_handler);
+               remove_fd_read_handler(&(bmi->fd_handler));
        }
 }
index 7bd3275..c8367a4 100755 (executable)
@@ -27,6 +27,7 @@
 #include <dirent.h>
 #include <errno.h>
 #include <ctype.h>
+#include <stdlib.h>
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/resource.h>
index 0b7d1fd..059fde4 100644 (file)
 
 #include <unistd.h>
 #include <glib.h>
-#include <Ecore.h>
 
 #include "resourced.h"
 #include "const.h"
+#include "fd-handler.h"
 
 struct block_monitor_info {
        int mfd;
@@ -43,7 +43,7 @@ struct block_monitor_info {
        pid_t last_monitor_pid;
        pid_t last_skip_pid;
        char path[MAX_PATH_LENGTH];
-       Ecore_Fd_Handler *fd_handler;
+       fd_handler_h fd_handler;
        GHashTable *block_include_proc;
        GHashTable *block_exclude_path;
 };
diff --git a/src/common/dbus-handler.c b/src/common/dbus-handler.c
new file mode 100644 (file)
index 0000000..4d296ca
--- /dev/null
@@ -0,0 +1,817 @@
+/*
+ * resourced
+ *
+ * Copyright (c) 2000 - 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+/*
+ * @file dbus-handler.c
+ *
+ * @desc dbus handler using libdbus
+ *
+ */
+
+#include <dbus/dbus.h>
+#include <glib.h>
+#include <stdint.h>
+
+#include "trace.h"
+#include "dbus-handler.h"
+#include "macro.h"
+#include "resourced.h"
+#include "util.h"
+#include "fd-handler.h"
+
+#define D_BUS_INIT_RETRY_COUNT 5
+
+static struct d_bus_object dbus_objects[] = {
+       { RESOURCED_DBUS_OBJECT_PATH, RESOURCED_DBUS_INTERFACE_NAME },
+       { RESOURCED_PATH_SWAP, RESOURCED_INTERFACE_SWAP },
+       { RESOURCED_PATH_FREEZER, RESOURCED_INTERFACE_FREEZER },
+       { RESOURCED_PATH_OOM, RESOURCED_INTERFACE_OOM },
+       { RESOURCED_PATH_PROCESS, RESOURCED_INTERFACE_PROCESS },
+       { RESOURCED_PATH_LOGGING, RESOURCED_INTERFACE_LOGGING },
+       { RESOURCED_PATH_DBUS,    RESOURCED_INTERFACE_DBUS },
+       { RESOURCED_PATH_APPOPT, RESOURCED_INTERFACE_APPOPT },
+       /* Add new object & interface here*/
+};
+
+static DBusConnection *dbus_conn;
+static GList *dbus_signal_list;
+static GList *dbus_method_handle_list;
+
+static struct d_bus_signal *d_bus_find_signal(const char *path, const char *interface, const char *name)
+{
+       size_t path_len, interface_len, name_len;
+       GList *iter;
+       struct d_bus_signal *signal;
+
+       path_len = strlen(path) + 1;
+       interface_len = strlen(interface) + 1;
+       name_len = strlen(name) + 1;
+
+       for (iter = dbus_signal_list; iter; iter = g_list_next(iter)) {
+               signal = (struct d_bus_signal *)iter->data;
+               if (strncmp(signal->path, path, path_len))
+                       continue;
+               if (strncmp(signal->interface, interface, interface_len))
+                       continue;
+               if (strncmp(signal->name, name, name_len))
+                       continue;
+               return signal;
+       }
+
+       return NULL;
+}
+
+static DBusHandlerResult d_bus_call_signal_handler(DBusConnection *conn, DBusMessage *msg, void *data)
+{
+       const char *path, *interface, *name;
+       struct d_bus_signal *signal;
+
+       if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_SIGNAL)
+               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+       path = dbus_message_get_path(msg);
+       interface = dbus_message_get_interface(msg);
+       name = dbus_message_get_member(msg);
+
+       signal = d_bus_find_signal(path, interface, name);
+       if (signal)
+               signal->handler(signal->user_data, msg);
+
+       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+struct d_bus_watch_info {
+       DBusWatch *watch;
+       void *data;
+};
+
+static fd_handler_h watch_handler;
+
+static bool d_bus_watch_info_changed_cb(int fd, void *data)
+{
+       struct d_bus_watch_info *winfo = data;
+
+       if (!dbus_watch_handle(winfo->watch, DBUS_WATCH_READABLE | DBUS_WATCH_ERROR))
+               return true;
+
+       dbus_connection_ref(dbus_conn);
+       while (dbus_connection_dispatch(dbus_conn) == DBUS_DISPATCH_DATA_REMAINS);
+       dbus_connection_unref(dbus_conn);
+
+       return true;
+}
+
+static void d_bus_watch_info_free(void *data)
+{
+       if (data)
+               free(data);
+}
+
+static dbus_bool_t d_bus_watch_add_cb(DBusWatch *watch, void *data)
+{
+       int fd;
+       int ret;
+       struct d_bus_watch_info *winfo;
+       dbus_bool_t enabled;
+
+       _I("add_watch_cb %s", (dbus_watch_get_enabled(watch) == 0 ? "disabled" : "enabled"));
+
+       enabled = dbus_watch_get_enabled(watch);
+
+       if (watch_handler || !enabled)
+               return TRUE;
+
+       winfo = calloc(1, sizeof(struct d_bus_watch_info));
+       if (!winfo) {
+               _E("calloc() failed");
+               return TRUE;
+       }
+
+       winfo->watch = watch;
+       winfo->data = NULL;
+
+       fd = dbus_watch_get_unix_fd(watch);
+       ret = add_fd_read_handler(fd, d_bus_watch_info_changed_cb,
+                       winfo, d_bus_watch_info_free, &watch_handler);
+       if (ret < 0)
+               _E("Failed to add fd handler (%d)", ret);
+
+       return TRUE;
+}
+
+static void d_bus_watch_remove_cb(DBusWatch *watch, void *data)
+{
+       int ret;
+
+       if (!watch_handler)
+               return;
+
+       ret = remove_fd_read_handler(&watch_handler);
+       if (ret < 0)
+               _E("Failed to remove fd handler (%d)", ret);
+       watch_handler = NULL;
+}
+
+static void d_bus_watch_toggled_cb(DBusWatch *watch, void *data)
+{
+       return;
+}
+
+static const char *d_bus_get_interface(const char *path)
+{
+       int i;
+       int path_len = strlen(path) + 1;
+       int size = sizeof(dbus_objects) / sizeof(dbus_objects[0]);
+
+       for (i = 0; i < size; i++) {
+               if (!strncmp(dbus_objects[i].path, path, path_len))
+                       return dbus_objects[i].interface;
+       }
+
+       return NULL;
+}
+
+static DBusHandlerResult d_bus_call_method_handler(DBusConnection *conn,
+               DBusMessage *msg, void *user_data)
+{
+       int i;
+       struct d_bus_method_handle *handle = (struct d_bus_method_handle *)user_data;
+       DBusMessage *reply = NULL;
+
+       if (!msg || !handle) {
+               _E("Invalid parameter");
+               return DBUS_HANDLER_RESULT_HANDLED;
+       }
+
+       for (i = 0; i < handle->num_methods; i++) {
+               if (!dbus_message_is_method_call(msg, handle->interface, handle->methods[i].name))
+                       continue;
+
+               reply = handle->methods[i].handler(msg);
+               if (!reply)
+                       _E("No reply from D-Bus method %s", handle->methods[i].name);
+               break;
+       }
+
+       if (reply)
+               d_bus_reply_message(reply);
+
+       return DBUS_HANDLER_RESULT_HANDLED;
+}
+
+static const DBusObjectPathVTable vtable = { NULL, d_bus_call_method_handler, NULL, NULL, NULL, NULL };
+
+static int append_variant(DBusMessageIter *iter,
+               const char *sig, char *param[])
+{
+       char *ch;
+       int i;
+       int int_type;
+       uint64_t int64_type;
+       DBusMessageIter arr;
+       struct dbus_byte *byte;
+
+       if (!sig || !param)
+               return 0;
+
+       for (ch = (char*)sig, i = 0; *ch != '\0'; ++i, ++ch) {
+               switch (*ch) {
+               case 'b':
+                       int_type = atoi(param[i]);
+                       dbus_message_iter_append_basic(iter,
+                               DBUS_TYPE_BOOLEAN, &int_type);
+                       break;
+               case 'i':
+                       int_type = atoi(param[i]);
+                       dbus_message_iter_append_basic(iter,
+                               DBUS_TYPE_INT32, &int_type);
+                       break;
+               case 'u':
+                       int_type = strtoul(param[i], NULL, 10);
+                       dbus_message_iter_append_basic(iter,
+                               DBUS_TYPE_UINT32, &int_type);
+                       break;
+               case 't':
+                       int64_type = atoll(param[i]);
+                       dbus_message_iter_append_basic(iter,
+                               DBUS_TYPE_UINT64, &int64_type);
+                       break;
+               case 's':
+                       dbus_message_iter_append_basic(iter,
+                               DBUS_TYPE_STRING, &param[i]);
+                       break;
+               case 'a':
+                       ++i, ++ch;
+                       switch (*ch) {
+                       case 'y':
+                               dbus_message_iter_open_container(iter,
+                                       DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &arr);
+                               byte = (struct dbus_byte*)param[i];
+                               dbus_message_iter_append_fixed_array(&arr,
+                                       DBUS_TYPE_BYTE, &(byte->data), byte->size);
+                               dbus_message_iter_close_container(iter, &arr);
+                               break;
+                       default:
+                               break;
+                       }
+                       break;
+               case 'd':
+                       dbus_message_iter_append_basic(iter,
+                               DBUS_TYPE_INT32, &param[i]);
+                       break;
+
+               default:
+                       return -EINVAL;
+               }
+       }
+
+       return 0;
+}
+
+void serialize_params(char *params[], size_t n, ...)
+{
+       va_list va;
+       int i = 0;
+       va_start(va, n);
+       for (i = 0; i < n; ++i)
+               params[i] = va_arg(va, char *);
+       va_end(va);
+}
+
+DBusMessage *d_bus_call_method_sync(const char *dest, const char *path,
+               const char *interface, const char *method,
+               const char *sig, char *param[])
+{
+       DBusConnection *conn;
+       DBusMessageIter iter;
+       DBusMessage *reply;
+       _cleanup_dbus_error_free_ DBusError err = DBUS_ERROR_INIT;
+       _cleanup_dbus_message_unref_ DBusMessage *msg = NULL;
+       int r;
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+       if (!conn) {
+               _E("dbus_bus_get error");
+               return NULL;
+       }
+
+       msg = dbus_message_new_method_call(dest, path, interface, method);
+       if (!msg) {
+               _E("dbus_message_new_method_call(%s:%s-%s)", path, interface, method);
+               dbus_connection_unref(conn);
+               return NULL;
+       }
+
+       dbus_message_iter_init_append(msg, &iter);
+       r = append_variant(&iter, sig, param);
+       if (r < 0) {
+               _E("append_variant error(%d)", r);
+               dbus_connection_unref(conn);
+               return NULL;
+       }
+
+       reply = dbus_connection_send_with_reply_and_block(conn, msg,
+                       D_BUS_REPLY_TIMEOUT, &err);
+
+       if (!reply) {
+               if (dbus_error_is_set(&err))
+                       _E("dbus_connection_send error: (%s:%s) %s %s:%s-%s", err.name, err.message, dest, path, interface, method);
+               else
+                       _E("dbus_connection_send error : %s %s:%s-%s", dest, path, interface, method);
+       }
+       dbus_connection_unref(conn);
+       return reply;
+}
+
+static int dbus_method_sync_pairs(const char *dest, const char *path,
+               const char *interface, const char *method,
+               int num, va_list args)
+{
+       DBusConnection *conn;
+       DBusMessage *reply;
+       DBusMessageIter iter;
+       DBusMessageIter aiter, piter;
+       _cleanup_dbus_error_free_ DBusError err = DBUS_ERROR_INIT;
+       _cleanup_dbus_message_unref_ DBusMessage *msg = NULL;
+       int ret, result, i;
+       char *key, *value;
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+       if (!conn) {
+               _E("dbus_bus_get error");
+               return -EPERM;
+       }
+
+       msg = dbus_message_new_method_call(dest, path, interface, method);
+       if (!msg) {
+               _E("dbus_message_new_method_call(%s:%s-%s)",
+                       path, interface, method);
+               return -EBADMSG;
+       }
+
+       dbus_message_iter_init_append(msg, &iter);
+       dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{ss}", &aiter);
+
+       for (i = 0 ; i < num ; i = i + 2) {
+               key = va_arg(args, char *);
+               value = va_arg(args, char *);
+               _I("key(%s), value(%s)", key, value);
+               dbus_message_iter_open_container(&aiter, DBUS_TYPE_DICT_ENTRY, NULL, &piter);
+               dbus_message_iter_append_basic(&piter, DBUS_TYPE_STRING, &key);
+               dbus_message_iter_append_basic(&piter, DBUS_TYPE_STRING, &value);
+               dbus_message_iter_close_container(&aiter, &piter);
+       }
+
+       dbus_message_iter_close_container(&iter, &aiter);
+
+       reply = dbus_connection_send_with_reply_and_block(conn, msg, D_BUS_REPLY_TIMEOUT, &err);
+       if (!reply) {
+               if (dbus_error_is_set(&err))
+                       _E("dbus_connection_send error: (%s:%s) %s %s:%s-%s", err.name, err.message, dest, path, interface, method);
+               else
+                       _E("dbus_connection_send error : %s %s:%s-%s", dest, path, interface, method);
+               return -ECOMM;
+       }
+
+       ret = dbus_message_get_args(reply, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
+       if (!ret) {
+               if (dbus_error_is_set(&err))
+                       _D("there is no message: %s %s", err.name, err.message);
+               else
+                       _D("there is no message");
+               return -ENOMSG;
+       }
+
+       return result;
+}
+
+int d_bus_call_method_async(const char *dest, const char *path,
+               const char *interface, const char *method,
+               const char *sig, char *param[])
+{
+       DBusConnection *conn;
+       DBusMessageIter iter;
+       _cleanup_dbus_message_unref_ DBusMessage *msg = NULL;
+       int ret;
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+       if (!conn) {
+               _E("dbus_bus_get error");
+               return -EPERM;
+       }
+
+       msg = dbus_message_new_method_call(dest, path, interface, method);
+       if (!msg) {
+               _E("dbus_message_new_method_call(%s:%s-%s)", path, interface, method);
+               return -EBADMSG;
+       }
+
+       dbus_message_iter_init_append(msg, &iter);
+       ret = append_variant(&iter, sig, param);
+       if (ret < 0) {
+               _E("append_variant error(%d)", ret);
+               dbus_message_unref(msg);
+               return ret;
+       }
+
+       ret = dbus_connection_send(conn, msg, NULL);
+       if (ret != TRUE) {
+               _E("dbus_connection_send error");
+               return -ECOMM;
+       }
+
+       return 0;
+}
+
+pid_t d_bus_get_sender_pid(DBusMessage *msg)
+{
+       const char *sender;
+       DBusMessage *send_msg;
+       DBusPendingCall *pending;
+       DBusMessageIter iter;
+       int ret;
+       pid_t pid;
+
+       if (!msg) {
+               _E("invalid argument!");
+               return RESOURCED_ERROR_FAIL;
+       }
+
+       sender = dbus_message_get_sender(msg);
+       if (!sender) {
+               _E("invalid sender!");
+               return RESOURCED_ERROR_FAIL;
+       }
+
+       send_msg = dbus_message_new_method_call(DBUS_SERVICE_DBUS,
+                                   DBUS_PATH_DBUS,
+                                   DBUS_INTERFACE_DBUS,
+                                   "GetConnectionUnixProcessID");
+       if (!send_msg) {
+               _E("invalid send msg!");
+               return RESOURCED_ERROR_FAIL;
+       }
+
+       ret = dbus_message_append_args(send_msg, DBUS_TYPE_STRING,
+                                   &sender, DBUS_TYPE_INVALID);
+       if (!ret) {
+               _E("fail to append args!");
+               dbus_message_unref(send_msg);
+               return RESOURCED_ERROR_FAIL;
+       }
+
+       if (!dbus_connection_send_with_reply(dbus_conn, send_msg, &pending, -1)) {
+               _E("dbus_connection_send_with_reply failed");
+               dbus_message_unref(send_msg);
+               return RESOURCED_ERROR_FAIL;
+       }
+
+       if (!pending) {
+               _E("pending is null!");
+               dbus_message_unref(send_msg);
+               return RESOURCED_ERROR_FAIL;
+       }
+
+       dbus_message_unref(send_msg);
+
+       /* block until reply is received */
+       dbus_pending_call_block(pending);
+
+       msg = dbus_pending_call_steal_reply(pending);
+       dbus_pending_call_unref(pending);
+       if (!msg) {
+               _E("reply msg is null!");
+               return RESOURCED_ERROR_FAIL;
+       }
+
+       dbus_message_iter_init(msg, &iter);
+       dbus_message_iter_get_basic(&iter, &pid);
+       dbus_message_unref(msg);
+
+       return pid;
+}
+
+resourced_ret_c d_bus_register_signal(const char *path, const char *interface,
+               const char *name, d_bus_signal_handler handler, void *user_data)
+{
+       struct d_bus_signal *signal;
+       char buf[256];
+
+       if (d_bus_find_signal(path, interface, name)) {
+               _E("Same D-Bus signal is already registered");
+               return RESOURCED_ERROR_FAIL;
+       }
+
+       signal = calloc(1, sizeof(struct d_bus_signal));
+       if (!signal) {
+               _E("Not enough memory!");
+               return RESOURCED_ERROR_OUT_OF_MEMORY;
+       }
+
+       signal->path = path;
+       signal->interface = interface;
+       signal->name = name;
+       signal->handler = handler;
+       signal->user_data = user_data;
+
+       snprintf(buf, 256, "type='signal',path='%s',interface='%s',member='%s'",
+                       path, interface, name);
+       dbus_bus_add_match(dbus_conn, buf, NULL);
+
+       dbus_signal_list = g_list_append(dbus_signal_list, signal);
+
+       return RESOURCED_ERROR_NONE;
+}
+
+int d_bus_broadcast_signal_str(const char *path, const char *interface,
+               const char *name, const char *sig, char *param[])
+{
+       _cleanup_dbus_message_unref_ DBusMessage *msg = NULL;
+       DBusConnection *conn;
+       DBusMessageIter iter;
+       int r;
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+       if (!conn) {
+               _E("dbus_bus_get error");
+               return -EPERM;
+       }
+
+       msg = dbus_message_new_signal(path, interface, name);
+       if (!msg) {
+               _E("fail to allocate new %s.%s signal", interface, name);
+               return -EPERM;
+       }
+
+       dbus_message_iter_init_append(msg, &iter);
+       r = append_variant(&iter, sig, param);
+       if (r < 0) {
+               _E("append_variant error(%d)", r);
+               return -EPERM;
+       }
+
+       r = dbus_connection_send(conn, msg, NULL);
+
+       if (r != TRUE) {
+               _E("dbus_connection_send error(%s:%s-%s)",
+                       path, interface, name);
+               return -ECOMM;
+       }
+
+       return RESOURCED_ERROR_NONE;
+}
+
+int d_bus_broadcast_signal(const char *path, const char *interface,
+               const char *name, int type, void *value)
+{
+       DBusConnection *conn;
+       DBusMessage *msg = dbus_message_new_signal(path, interface, name);
+       int r;
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+       if (!conn) {
+               _E("dbus_bus_get error");
+               return -EPERM;
+       }
+
+       if (!msg) {
+               _E("fail to allocate new %s.%s signal", interface, name);
+               return RESOURCED_ERROR_FAIL;
+       }
+
+       dbus_message_append_args(msg, type, value, DBUS_TYPE_INVALID);
+
+       r = dbus_connection_send(conn, msg, NULL);
+       dbus_message_unref(msg);
+
+       if (r != TRUE) {
+               _E("dbus_connection_send error(%s:%s-%s)",
+                       path, interface, name);
+               return -ECOMM;
+       }
+
+       return RESOURCED_ERROR_NONE;
+}
+
+/* You have to use h1 after this function is run */
+static resourced_ret_c d_bus_merge_method_handles(struct d_bus_method_handle *h1,
+                                                                                                 struct d_bus_method_handle *h2)
+{
+       int i;
+       int cur = 0;
+       struct d_bus_method *new_methods = calloc(h1->num_methods + h2->num_methods,
+                                                                                       sizeof(struct d_bus_method));
+
+       if (!new_methods) {
+               _E("Not enough memory!");
+               return RESOURCED_ERROR_OUT_OF_MEMORY;
+       }
+
+       for (i = 0; i < h1->num_methods; i++)
+               new_methods[cur++] = h1->methods[i];
+
+       for (i = 0; i < h2->num_methods; i++)
+               new_methods[cur++] = h2->methods[i];
+
+       if (h1->is_merged_methods)
+               free(h1->methods);
+
+       h1->methods = new_methods;
+       h1->is_merged_methods = true;
+       h1->num_methods += h2->num_methods;
+
+       return RESOURCED_ERROR_NONE;
+}
+
+resourced_ret_c d_bus_register_methods(const char *path,
+               struct d_bus_method *methods, const size_t num_methods)
+{
+       const char *interface;
+       struct d_bus_method_handle *handle = NULL;
+       struct d_bus_method_handle *old_handle = NULL;
+       _cleanup_dbus_error_free_ DBusError err = DBUS_ERROR_INIT;
+       int ret;
+
+       if (!path) {
+               _E("There is no D-Bus method path");
+               return RESOURCED_ERROR_INVALID_PARAMETER;
+       }
+
+       interface = d_bus_get_interface(path);
+       if (!interface) {
+               _E("%s is not registered path", path);
+               return RESOURCED_ERROR_INVALID_PARAMETER;
+       }
+
+       handle = (struct d_bus_method_handle *)calloc(1, sizeof(struct d_bus_method_handle));
+       if (!handle) {
+               _E("Not enough memory!");
+               return RESOURCED_ERROR_OUT_OF_MEMORY;
+       }
+
+       handle->path = path;
+       handle->interface = interface;
+       handle->methods = methods;
+       handle->is_merged_methods = false;
+       handle->num_methods = num_methods;
+
+       ret = dbus_connection_try_register_object_path(dbus_conn, handle->path, &vtable, handle, &err);
+       if (!ret) {
+               if (!strncmp(err.name, DBUS_ERROR_OBJECT_PATH_IN_USE, strlen(DBUS_ERROR_OBJECT_PATH_IN_USE) + 1)) {
+                       /*
+                        * If same path is already registered, just merge these (old + new)
+                        * methods. You don't have to unregister and re-register this path
+                        * because resourced check latest method list whenever it receive
+                        */
+                       ret = dbus_connection_get_object_path_data(dbus_conn, path, (void **)(&old_handle));
+                       if (!ret) {
+                               _E("Failed to get registered D-Bus handle");
+                               return RESOURCED_ERROR_FAIL;
+                       }
+
+                       ret = d_bus_merge_method_handles(old_handle, handle);
+                       if (ret != RESOURCED_ERROR_NONE) {
+                               _E("Failed to merge method D-Bus handles");
+                               return ret;
+                       }
+               } else {
+                       _E("Failed to register D-Bus methods with path %s : %s", path, err.message);
+                       return RESOURCED_ERROR_FAIL;
+               }
+       } else
+               dbus_method_handle_list = g_list_append(dbus_method_handle_list, handle);
+
+       return RESOURCED_ERROR_NONE;
+}
+
+resourced_ret_c d_bus_register_signals(const struct d_bus_signal *signals, const size_t size)
+{
+       int i;
+       int ret;
+
+       for (i = 0; i < size; i++) {
+               if (!signals[i].path || !signals[i].interface || !signals[i].name || !signals[i].handler)
+                       continue;
+
+               ret = d_bus_register_signal(
+                               signals[i].path,
+                               signals[i].interface,
+                               signals[i].name,
+                               signals[i].handler,
+                               signals[i].user_data);
+               if (ret != RESOURCED_ERROR_NONE) {
+                       _E("Fail to add signal %s, %s!\n", signals[i].path, signals[i].name);
+                       return RESOURCED_ERROR_FAIL;
+               }
+       }
+
+       return RESOURCED_ERROR_NONE;
+}
+
+resourced_ret_c d_bus_reply_message(DBusMessage *msg)
+{
+       if (dbus_connection_send(dbus_conn, msg, NULL))
+               return RESOURCED_ERROR_NONE;
+       else {
+               _E("Fail to reply dbus message");
+               return RESOURCED_ERROR_FAIL;
+       }
+}
+
+int launch_system_app_by_dbus(const char *dest, const char *path,
+               const char *iface, const char *method, int num, ...)
+{
+       int ret;
+       va_list args;
+
+       va_start(args, num);
+       ret = dbus_method_sync_pairs(dest, path, iface, method, num, args);
+       va_end(args);
+       return ret;
+}
+
+void d_bus_init(void)
+{
+       int retry = 0;
+       int retval;
+       _cleanup_dbus_error_free_ DBusError err = DBUS_ERROR_INIT;
+
+       dbus_threads_init_default();
+
+retry_bus_get:
+       dbus_conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
+       if (dbus_conn) {
+               retry = 0;
+               goto retry_bus_request;
+       }
+       if (retry == D_BUS_INIT_RETRY_COUNT) {
+               _E("fail to get dbus");
+               return;
+       }
+       retry++;
+       goto retry_bus_get;
+
+retry_bus_request:
+       retval = dbus_bus_request_name(dbus_conn, RESOURCED_DBUS_BUS_NAME,
+                       DBUS_NAME_FLAG_REPLACE_EXISTING, &err);
+       if (retval == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+               _I("start dbus service");
+               goto do_others;
+       }
+       if (retry == D_BUS_INIT_RETRY_COUNT) {
+               _E("fail to request dbus name");
+               dbus_connection_set_exit_on_disconnect(dbus_conn, FALSE);
+               return;
+       }
+       retry++;
+       goto retry_bus_request;
+
+do_others:
+       dbus_connection_add_filter(dbus_conn, d_bus_call_signal_handler, NULL, NULL);
+
+       dbus_connection_set_watch_functions(dbus_conn,
+                       d_bus_watch_add_cb, d_bus_watch_remove_cb, d_bus_watch_toggled_cb,
+                       NULL, NULL);
+}
+
+void d_bus_exit(void)
+{
+       GList *iter;
+       struct d_bus_signal *signal;
+       struct d_bus_method_handle *method_handle;
+       char buf[256];
+
+       /* Remove D-Bus signal list */
+       for (iter = dbus_signal_list; iter; iter = g_list_next(iter)) {
+               signal = (struct d_bus_signal *)iter->data;
+               snprintf(buf, 256, "type='signal',path='%s',interface='%s',member='%s'",
+                               signal->path, signal->interface, signal->name);
+               dbus_bus_remove_match(dbus_conn, buf, NULL);
+               free(signal);
+               dbus_signal_list = g_list_remove(dbus_signal_list, iter);
+       }
+
+       /* Remove D-Bus method list */
+       for (iter = dbus_method_handle_list; iter; iter = g_list_next(iter)) {
+               method_handle = (struct d_bus_method_handle *)iter->data;
+               dbus_connection_unregister_object_path(dbus_conn, method_handle->path);
+               free(method_handle);
+               dbus_method_handle_list = g_list_remove(dbus_method_handle_list, iter);
+       }
+}
diff --git a/src/common/dbus-handler.h b/src/common/dbus-handler.h
new file mode 100644 (file)
index 0000000..3dd06ab
--- /dev/null
@@ -0,0 +1,258 @@
+/*
+ * resourced
+ *
+ * Copyright (c) 2013 - 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+/**
+ * @file dbus-handler.h
+ * @desc  dbus handler using libdbus
+ **/
+
+#ifndef __DBUS_HANDLER_H__
+#define __DBUS_HANDLER_H__
+
+#include <dbus/dbus.h>
+#include <resourced.h>
+
+typedef void (*d_bus_signal_handler)(void *user_data, DBusMessage *msg);
+typedef DBusMessage *(*d_bus_method_handler)(DBusMessage *msg);
+
+struct d_bus_method {
+       const char *name;
+       const char *signature;
+       const char *reply_signature;
+       d_bus_method_handler handler;
+};
+
+struct d_bus_method_handle {
+       const char *path;
+       const char *interface;
+       struct d_bus_method *methods;
+       /*
+        * Libdbus allows to register methods having same path only one time.
+        *
+        * Therefore, if you want to many times, you have to load registered
+        * method handle and merge handle->methods.
+        *
+        * In this case, you should free handle->methods when it comes to be
+        * needless.
+        */
+       bool is_merged_methods;
+       size_t num_methods;
+};
+
+struct d_bus_object {
+       const char *path;
+       const char *interface;
+};
+
+struct d_bus_signal {
+       const char *path;
+       const char *interface;
+       const char *name;
+       d_bus_signal_handler handler;
+       void *user_data;
+};
+
+#define D_BUS_REPLY_TIMEOUT  (120 * 1000)
+
+#define RESOURCED_DBUS_BUS_NAME        "org.tizen.resourced"
+#define RESOURCED_DBUS_OBJECT_PATH     "/Org/Tizen/ResourceD"
+#define RESOURCED_DBUS_INTERFACE_NAME  RESOURCED_DBUS_BUS_NAME
+
+/*
+ * Core service
+ *   get/set swap status
+ *   operations about swap
+ */
+#define RESOURCED_PATH_SWAP             RESOURCED_DBUS_OBJECT_PATH"/Swap"
+#define RESOURCED_INTERFACE_SWAP        RESOURCED_DBUS_INTERFACE_NAME".swap"
+
+#define RESOURCED_PATH_FREEZER          RESOURCED_DBUS_OBJECT_PATH"/Freezer"
+#define RESOURCED_INTERFACE_FREEZER     RESOURCED_DBUS_INTERFACE_NAME".freezer"
+
+#define RESOURCED_PATH_OOM              RESOURCED_DBUS_OBJECT_PATH"/Oom"
+#define RESOURCED_INTERFACE_OOM         RESOURCED_DBUS_INTERFACE_NAME".oom"
+
+#define RESOURCED_PATH_PROCESS          RESOURCED_DBUS_OBJECT_PATH"/Process"
+#define RESOURCED_INTERFACE_PROCESS     RESOURCED_DBUS_INTERFACE_NAME".process"
+
+#define RESOURCED_PATH_DBUS             RESOURCED_DBUS_OBJECT_PATH"/DBus"
+#define RESOURCED_INTERFACE_DBUS        RESOURCED_DBUS_INTERFACE_NAME".dbus"
+
+#define RESOURCED_PATH_APPOPT           RESOURCED_DBUS_OBJECT_PATH"/Appopt"
+#define RESOURCED_INTERFACE_APPOPT      RESOURCED_DBUS_INTERFACE_NAME".appopt"
+
+#define SIGNAL_PROC_WATCHDOG_RESULT     "WatchdogResult"
+#define SIGNAL_PROC_ACTIVE              "Active"
+#define SIGNAL_PROC_EXCLUDE             "ProcExclude"
+#define SIGNAL_PROC_PRELAUNCH           "ProcPrelaunch"
+#define SIGNAL_PROC_SWEEP               "ProcSweep"
+#define SIGNAL_PROC_WATCHDOG            "ProcWatchdog"
+#define SIGNAL_PROC_SYSTEMSERVICE       "SystemService"
+#define SIGNAL_PROC_EXCLUDEAPPID        "ProcExcludeByAppid"
+
+#define SIGNAL_OOM_SET_THRESHOLD        "SetThreshold"
+#define SIGNAL_OOM_SET_LEAVE_THRESHOLD  "SetLeaveThreshold"
+#define SIGNAL_OOM_TRIGGER              "Trigger"
+#define SIGNAL_OOM_SET_PERCEPTIBLE      "SetPerceptible"
+#define SIGNAL_OOM_SET_PLATFORM         "SetPlatformSwap"
+
+#define SIGNAL_NAME_SWAP_TYPE           "SwapType"
+#define SIGNAL_NAME_SWAP_START_PID      "SwapStartPid"
+
+/*
+ * Logging
+ */
+#define RESOURCED_PATH_LOGGING       RESOURCED_DBUS_OBJECT_PATH"/Logging"
+#define RESOURCED_INTERFACE_LOGGING  RESOURCED_DBUS_INTERFACE_NAME".logging"
+
+/*
+ * System popup
+ */
+#define SYSTEM_POPUP_BUS_NAME         "org.tizen.system.popup"
+#define SYSTEM_POPUP_PATH_NAME        "/Org/Tizen/System/Popup"
+#define SYSTEM_POPUP_IFACE_NAME       SYSTEM_POPUP_BUS_NAME
+
+#define SYSTEM_POPUP_PATH_SYSTEM      SYSTEM_POPUP_PATH_NAME"/System"
+#define SYSTEM_POPUP_IFACE_SYSTEM     SYSTEM_POPUP_BUS_NAME".System"
+
+#define SYSTEM_POPUP_PATH_DATAUSAGE   SYSTEM_POPUP_PATH_NAME"/DataUsage"
+#define SYSTEM_POPUP_IFACE_DATAUSAGE  SYSTEM_POPUP_BUS_NAME".DataUsage"
+
+/*
+ * Deviced
+ */
+#define DEVICED_BUS_NAME            "org.tizen.system.deviced"
+#define DEVICED_OBJECT_PATH         "/Org/Tizen/System/DeviceD"
+
+#define DEVICED_PATH_PROCESS        DEVICED_OBJECT_PATH"/Process"
+#define DEVICED_INTERFACE_PROCESS   DEVICED_BUS_NAME".Process"
+
+#define DEVICED_PATH_DISPLAY        DEVICED_OBJECT_PATH"/Display"
+#define DEVICED_INTERFACE_DISPLAY   DEVICED_BUS_NAME".display"
+
+#define DEVICED_PATH_BATTERY        DEVICED_OBJECT_PATH"/Battery"
+#define DEVICED_INTERFACE_BATTERY   DEVICED_BUS_NAME".Battery"
+
+#define DEVICED_PATH_CORE           DEVICED_OBJECT_PATH"/Core"
+#define DEVICED_INTERFACE_CORE      DEVICED_BUS_NAME".core"
+
+#define DEVICED_PATH_POWEROFF       DEVICED_OBJECT_PATH"/PowerOff"
+#define DEVICED_INTERFACE_POWEROFF  DEVICED_BUS_NAME".PowerOff"
+
+#define DEVICED_PATH_TIME           DEVICED_OBJECT_PATH"/Time"
+#define DEVICED_INTERFACE_TIME      DEVICED_BUS_NAME".Time"
+
+
+#define SIGNAL_DEVICED_LCDON               "LCDOn"
+#define SIGNAL_DEVICED_LCDOFF              "LCDOff"
+#define SIGNAL_DEVICED_LCDONCOMPLETE       "LCDOnCompleted"
+#define SIGNAL_DEVICED_BOOTINGDONE         "BootingDone"
+#define SIGNAL_DEVICED_POWEROFF_STATE      "ChangeState"
+#define SIGNAL_DEVICED_SYSTEMTIME_CHANGED  "SystemTimeChanged"
+#define SIGNAL_DEVICED_LOW_BATTERY                "BatteryStatusLow"
+#define SIGNAL_DEVICED_EARLY_BOOTING_DONE  "EarlyBootingDone"
+
+/*
+ * dump service
+ */
+#define DUMP_SERVICE_BUS_NAME        "org.tizen.system.dumpservice"
+#define DUMP_SERVICE_OBJECT_PATH     "/Org/Tizen/System/DumpService"
+#define DUMP_SERVICE_INTERFACE_NAME  DUMP_SERVICE_BUS_NAME
+
+#define SIGNAL_DUMP         "Dump"
+#define SIGNAL_DUMP_START   "Start"
+#define SIGNAL_DUMP_FINISH  "Finish"
+
+/*
+ * Crash
+ */
+#define CRASH_BUS_NAME         "org.tizen.system.crash"
+#define CRASH_OBJECT_PATH      "/Org/Tizen/System/Crash"
+#define CRASH_INTERFACE_NAME   CRASH_BUS_NAME
+#define CRASH_PATH_CRASH       CRASH_OBJECT_PATH"/Crash"
+#define CRASH_INTERFACE_CRASH  CRASH_INTERFACE_NAME".Crash"
+#define PROCESS_CRASHED        "ProcessCrashed"
+
+/*
+ * AMD
+ */
+#define AUL_APPSTATUS_BUS_NAME        "org.tizen.aul.AppStatus"
+#define AUL_APPSTATUS_OBJECT_PATH     "/Org/Tizen/Aul/AppStatus"
+#define AUL_APPSTATUS_INTERFACE_NAME  AUL_APPSTATUS_BUS_NAME
+
+#define AUL_SUSPEND_BUS_NAME          "org.tizen.appfw.SuspendHint"
+#define AUL_SUSPEND_OBJECT_PATH       "/Org/Tizen/Appfw/SuspendHint"
+#define AUL_SUSPEND_INTERFACE_NAME    AUL_SUSPEND_BUS_NAME
+
+#define SIGNAL_AMD_LAUNCH      "AppLaunch"
+#define SIGNAL_AMD_RESUME      "AppResume"
+#define SIGNAL_AMD_TERMINATE   "AppTerminate"
+#define SIGNAL_AMD_STATE       "AppStatusChange"
+#define SIGNAL_AMD_GROUP       "AppGroup"
+#define SIGNAL_AMD_TERMINATED  "AppTerminated"
+#define SIGNAL_AMD_SUSPNED     "SuspendHint"
+
+struct dbus_byte {
+       char *data;
+       int size;
+};
+
+#define RETRY_MAX 5
+
+/*
+ * @desc helper function for filling params array
+ * That params array is used in d_bus_method_sync/d_bus_method_async
+ * */
+void serialize_params(char *params[], size_t n, ...);
+
+
+DBusMessage *d_bus_call_method_sync(const char *dest, const char *path,
+               const char *interface, const char *method,
+               const char *sig, char *param[]);
+
+int d_bus_call_method_async(const char *dest, const char *path,
+               const char *interface, const char *method,
+               const char *sig, char *param[]);
+
+resourced_ret_c d_bus_register_signal(const char *path, const char *interface,
+               const char *name, d_bus_signal_handler handler, void *user_data);
+
+pid_t d_bus_get_sender_pid(DBusMessage *msg);
+
+int d_bus_broadcast_signal_str(const char *path, const char *interface,
+               const char *name, const char *sig, char *param[]);
+
+int d_bus_broadcast_signal(const char *path, const char *interface,
+                          const char *name, int type, void *value);
+
+resourced_ret_c d_bus_register_methods(const char *path,
+               struct d_bus_method *methods, const size_t num_methods);
+
+resourced_ret_c d_bus_register_signals(const struct d_bus_signal *signals,
+                                                                          const size_t size);
+
+resourced_ret_c d_bus_reply_message(DBusMessage *msg);
+
+int launch_system_app_by_dbus(const char *dest, const char *path,
+               const char *iface, const char *method, int num, ...);
+
+void d_bus_init(void);
+void d_bus_exit(void);
+
+#endif /* __DBUS_HANDLER_H__ */
diff --git a/src/common/edbus-handler.c b/src/common/edbus-handler.c
deleted file mode 100644 (file)
index fb238bc..0000000
+++ /dev/null
@@ -1,732 +0,0 @@
-/*
- * resourced
- *
- * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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.
- *
- */
-
-/*
- * @file edbus-handler.c
- *
- * @desc dbus handler using edbus interface
- *
- * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- */
-
-#include <Eina.h>
-#include "trace.h"
-#include "edbus-handler.h"
-#include "macro.h"
-#include "resourced.h"
-#include "util.h"
-
-#define EDBUS_INIT_RETRY_COUNT 5
-
-struct edbus_list {
-       char *signal_name;
-       char *signal_path;
-
-       E_DBus_Signal_Handler *handler;
-};
-
-static struct edbus_object edbus_objects[] = {
-       { RESOURCED_DBUS_OBJECT_PATH, RESOURCED_DBUS_INTERFACE_NAME   , NULL, NULL },
-       { RESOURCED_PATH_SWAP, RESOURCED_INTERFACE_SWAP   , NULL, NULL },
-       { RESOURCED_PATH_FREEZER, RESOURCED_INTERFACE_FREEZER, NULL, NULL },
-       { RESOURCED_PATH_OOM, RESOURCED_INTERFACE_OOM, NULL, NULL },
-       { RESOURCED_PATH_PROCESS, RESOURCED_INTERFACE_PROCESS, NULL, NULL },
-       { RESOURCED_PATH_LOGGING, RESOURCED_INTERFACE_LOGGING, NULL, NULL },
-       { RESOURCED_PATH_DBUS,    RESOURCED_INTERFACE_DBUS,    NULL, NULL },
-       { RESOURCED_PATH_APPOPT, RESOURCED_INTERFACE_APPOPT, NULL, NULL },
-       /* Add new object & interface here*/
-};
-
-static Eina_List *edbus_handler_list;
-static int edbus_init_val;
-static DBusConnection *dbus_conn;
-static E_DBus_Connection *edbus_conn;
-static DBusPendingCall *edbus_request_name;
-
-static int append_variant(DBusMessageIter *iter,
-               const char *sig, char *param[])
-{
-       char *ch;
-       int i;
-       int int_type;
-       uint64_t int64_type;
-       DBusMessageIter arr;
-       struct dbus_byte *byte;
-
-       if (!sig || !param)
-               return 0;
-
-       for (ch = (char*)sig, i = 0; *ch != '\0'; ++i, ++ch) {
-               switch (*ch) {
-               case 'b':
-                       int_type = atoi(param[i]);
-                       dbus_message_iter_append_basic(iter,
-                               DBUS_TYPE_BOOLEAN, &int_type);
-                       break;
-               case 'i':
-                       int_type = atoi(param[i]);
-                       dbus_message_iter_append_basic(iter,
-                               DBUS_TYPE_INT32, &int_type);
-                       break;
-               case 'u':
-                       int_type = strtoul(param[i], NULL, 10);
-                       dbus_message_iter_append_basic(iter,
-                               DBUS_TYPE_UINT32, &int_type);
-                       break;
-               case 't':
-                       int64_type = atoll(param[i]);
-                       dbus_message_iter_append_basic(iter,
-                               DBUS_TYPE_UINT64, &int64_type);
-                       break;
-               case 's':
-                       dbus_message_iter_append_basic(iter,
-                               DBUS_TYPE_STRING, &param[i]);
-                       break;
-               case 'a':
-                       ++i, ++ch;
-                       switch (*ch) {
-                       case 'y':
-                               dbus_message_iter_open_container(iter,
-                                       DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &arr);
-                               byte = (struct dbus_byte*)param[i];
-                               dbus_message_iter_append_fixed_array(&arr,
-                                       DBUS_TYPE_BYTE, &(byte->data), byte->size);
-                               dbus_message_iter_close_container(iter, &arr);
-                               break;
-                       default:
-                               break;
-                       }
-                       break;
-               case 'd':
-                       dbus_message_iter_append_basic(iter,
-                               DBUS_TYPE_INT32, &param[i]);
-                       break;
-
-               default:
-                       return -EINVAL;
-               }
-       }
-
-       return 0;
-}
-
-void serialize_params(char *params[], size_t n, ...)
-{
-       va_list va;
-       int i = 0;
-       va_start(va, n);
-       for (i = 0; i < n; ++i)
-               params[i] = va_arg(va, char *);
-       va_end(va);
-}
-
-DBusMessage *dbus_method_sync(const char *dest, const char *path,
-               const char *interface, const char *method,
-               const char *sig, char *param[])
-{
-       DBusConnection *conn;
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       _cleanup_dbus_error_free_ DBusError err = DBUS_ERROR_INIT;
-       _cleanup_dbus_message_unref_ DBusMessage *msg = NULL;
-       int r;
-
-       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
-       if (!conn) {
-               _E("dbus_bus_get error");
-               return NULL;
-       }
-
-       msg = dbus_message_new_method_call(dest, path, interface, method);
-       if (!msg) {
-               _E("dbus_message_new_method_call(%s:%s-%s)", path, interface, method);
-               dbus_connection_unref(conn);
-               return NULL;
-       }
-
-       dbus_message_iter_init_append(msg, &iter);
-       r = append_variant(&iter, sig, param);
-       if (r < 0) {
-               _E("append_variant error(%d)", r);
-               dbus_connection_unref(conn);
-               return NULL;
-       }
-
-       reply = dbus_connection_send_with_reply_and_block(conn, msg,
-                       DBUS_REPLY_TIMEOUT, &err);
-
-       if (!reply) {
-               if (dbus_error_is_set(&err))
-                       _E("dbus_connection_send error: (%s:%s) %s %s:%s-%s", err.name, err.message, dest, path, interface, method);
-               else
-                       _E("dbus_connection_send error : %s %s:%s-%s", dest, path, interface, method);
-       }
-       dbus_connection_unref(conn);
-       return reply;
-}
-
-static int dbus_method_sync_pairs(const char *dest, const char *path,
-               const char *interface, const char *method,
-               int num, va_list args)
-{
-       DBusConnection *conn;
-       DBusMessage *reply;
-       DBusMessageIter iter;
-       DBusMessageIter aiter, piter;
-       _cleanup_dbus_error_free_ DBusError err = DBUS_ERROR_INIT;
-       _cleanup_dbus_message_unref_ DBusMessage *msg = NULL;
-       int ret, result, i;
-       char *key, *value;
-
-       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
-       if (!conn) {
-               _E("dbus_bus_get error");
-               return -EPERM;
-       }
-
-       msg = dbus_message_new_method_call(dest, path, interface, method);
-       if (!msg) {
-               _E("dbus_message_new_method_call(%s:%s-%s)",
-                       path, interface, method);
-               return -EBADMSG;
-       }
-
-       dbus_message_iter_init_append(msg, &iter);
-       dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{ss}", &aiter);
-
-       for (i = 0 ; i < num ; i = i + 2) {
-               key = va_arg(args, char *);
-               value = va_arg(args, char *);
-               _I("key(%s), value(%s)", key, value);
-               dbus_message_iter_open_container(&aiter, DBUS_TYPE_DICT_ENTRY, NULL, &piter);
-               dbus_message_iter_append_basic(&piter, DBUS_TYPE_STRING, &key);
-               dbus_message_iter_append_basic(&piter, DBUS_TYPE_STRING, &value);
-               dbus_message_iter_close_container(&aiter, &piter);
-       }
-
-       dbus_message_iter_close_container(&iter, &aiter);
-
-       reply = dbus_connection_send_with_reply_and_block(conn, msg, DBUS_REPLY_TIMEOUT, &err);
-       if (!reply) {
-               if (dbus_error_is_set(&err))
-                       _E("dbus_connection_send error: (%s:%s) %s %s:%s-%s", err.name, err.message, dest, path, interface, method);
-               else
-                       _E("dbus_connection_send error : %s %s:%s-%s", dest, path, interface, method);
-               return -ECOMM;
-       }
-
-       ret = dbus_message_get_args(reply, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
-       if (!ret) {
-               if (dbus_error_is_set(&err))
-                       _D("there is no message: %s %s", err.name, err.message);
-               else
-                       _D("there is no message");
-               return -ENOMSG;
-       }
-
-       return result;
-}
-
-int dbus_method_async(const char *dest, const char *path,
-               const char *interface, const char *method,
-               const char *sig, char *param[])
-{
-       DBusConnection *conn;
-       DBusMessageIter iter;
-       _cleanup_dbus_message_unref_ DBusMessage *msg = NULL;
-       int ret;
-
-       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
-       if (!conn) {
-               _E("dbus_bus_get error");
-               return -EPERM;
-       }
-
-       msg = dbus_message_new_method_call(dest, path, interface, method);
-       if (!msg) {
-               _E("dbus_message_new_method_call(%s:%s-%s)", path, interface, method);
-               return -EBADMSG;
-       }
-
-       dbus_message_iter_init_append(msg, &iter);
-       ret = append_variant(&iter, sig, param);
-       if (ret < 0) {
-               _E("append_variant error(%d)", ret);
-               dbus_message_unref(msg);
-               return ret;
-       }
-
-       ret = dbus_connection_send(conn, msg, NULL);
-       if (ret != TRUE) {
-               _E("dbus_connection_send error");
-               return -ECOMM;
-       }
-
-       return 0;
-}
-
-int register_edbus_interface(struct edbus_object *object)
-{
-       int ret = RESOURCED_ERROR_FAIL;
-
-       if (!object) {
-               _E("object is invalid value!");
-               return ret;
-       }
-
-       object->obj = e_dbus_object_add(edbus_conn, object->path, NULL);
-       if (!object->obj) {
-               _E("fail to add edbus obj");
-               return ret;
-       }
-
-       object->iface = e_dbus_interface_new(object->interface);
-       if (!object->iface) {
-               _E("fail to add edbus interface");
-               return ret;
-       }
-
-       e_dbus_object_interface_attach(object->obj, object->iface);
-
-       return 0;
-}
-
-E_DBus_Interface *get_edbus_interface(const char *path)
-{
-       int i;
-       int pathlen = strlen(path) + 1;
-
-       for (i = 0; i < ARRAY_SIZE(edbus_objects); i++)
-               if (!strncmp(path, edbus_objects[i].path, pathlen))
-                       return edbus_objects[i].iface;
-
-       return NULL;
-}
-
-pid_t get_edbus_sender_pid(DBusMessage *msg)
-{
-       const char *sender;
-       DBusMessage *send_msg;
-       DBusPendingCall *pending;
-       DBusMessageIter iter;
-       int ret;
-       pid_t pid;
-
-       if (!msg) {
-               _E("invalid argument!");
-               return RESOURCED_ERROR_FAIL;
-       }
-
-       sender = dbus_message_get_sender(msg);
-       if (!sender) {
-               _E("invalid sender!");
-               return RESOURCED_ERROR_FAIL;
-       }
-
-       send_msg = dbus_message_new_method_call(DBUS_SERVICE_DBUS,
-                                   DBUS_PATH_DBUS,
-                                   DBUS_INTERFACE_DBUS,
-                                   "GetConnectionUnixProcessID");
-       if (!send_msg) {
-               _E("invalid send msg!");
-               return RESOURCED_ERROR_FAIL;
-       }
-
-       ret = dbus_message_append_args(send_msg, DBUS_TYPE_STRING,
-                                   &sender, DBUS_TYPE_INVALID);
-       if (!ret) {
-               _E("fail to append args!");
-               dbus_message_unref(send_msg);
-               return RESOURCED_ERROR_FAIL;
-       }
-
-       pending = e_dbus_message_send(edbus_conn, send_msg, NULL, -1, NULL);
-       if (!pending) {
-               _E("pending is null!");
-               dbus_message_unref(send_msg);
-               return RESOURCED_ERROR_FAIL;
-       }
-
-       dbus_message_unref(send_msg);
-
-       /* block until reply is received */
-       dbus_pending_call_block(pending);
-
-       msg = dbus_pending_call_steal_reply(pending);
-       dbus_pending_call_unref(pending);
-       if (!msg) {
-               _E("reply msg is null!");
-               return RESOURCED_ERROR_FAIL;
-       }
-
-       dbus_message_iter_init(msg, &iter);
-       dbus_message_iter_get_basic(&iter, &pid);
-       dbus_message_unref(msg);
-
-       return pid;
-}
-
-static void unregister_edbus_signal_handle(void)
-{
-       Eina_List *search;
-       Eina_List *serach_next;
-       struct edbus_list *entry;
-
-       EINA_LIST_FOREACH_SAFE(edbus_handler_list, search, serach_next, entry) {
-               if (entry != NULL) {
-                       e_dbus_signal_handler_del(edbus_conn, entry->handler);
-                       edbus_handler_list = eina_list_remove(edbus_handler_list, entry);
-                       free(entry->signal_name);
-                       free(entry->signal_path);
-                       free(entry);
-               }
-       }
-}
-
-int register_edbus_signal_handler(const char *path, const char *interface,
-               const char *name, E_DBus_Signal_Cb cb, void *user_data)
-{
-       Eina_List *search;
-       struct edbus_list *entry;
-       E_DBus_Signal_Handler *handler;
-
-       EINA_LIST_FOREACH(edbus_handler_list, search, entry) {
-               if (entry != NULL && strncmp(entry->signal_name, name, strlen(name)) == 0 &&
-                       strncmp(entry->signal_path, path, strlen(path)) == 0)
-                       return RESOURCED_ERROR_FAIL;
-       }
-
-       handler = e_dbus_signal_handler_add(edbus_conn, NULL, path,
-                               interface, name, cb, user_data);
-
-       if (!handler) {
-               _E("fail to add edbus handler");
-               return RESOURCED_ERROR_FAIL;
-       }
-
-       entry = malloc(sizeof(struct edbus_list));
-
-       if (!entry) {
-               _E("Malloc failed");
-               return RESOURCED_ERROR_FAIL;
-       }
-
-       entry->signal_name = strndup(name, strlen(name)+1);
-
-       if (!entry->signal_name) {
-               _E("Malloc failed");
-               goto release_entry;
-       }
-
-       entry->signal_path = strndup(path, strlen(path)+1);
-       if (!entry->signal_path) {
-               _E("Malloc failed");
-               goto release_name;
-       }
-
-       entry->handler = handler;
-       edbus_handler_list = eina_list_prepend(edbus_handler_list, entry);
-       if (!edbus_handler_list) {
-               _E("eina_list_prepend failed");
-               goto release_path;
-       }
-
-       return RESOURCED_ERROR_NONE;
-
-release_path:
-       free(entry->signal_path);
-
-release_name:
-       free(entry->signal_name);
-
-release_entry:
-
-       free(entry);
-       return RESOURCED_ERROR_FAIL;
-}
-
-int broadcast_edbus_signal_str(const char *path, const char *interface,
-               const char *name, const char *sig, char *param[])
-{
-       _cleanup_dbus_message_unref_ DBusMessage *msg = NULL;
-       DBusConnection *conn;
-       DBusMessageIter iter;
-       int r;
-
-       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
-       if (!conn) {
-               _E("dbus_bus_get error");
-               return -EPERM;
-       }
-
-       msg = dbus_message_new_signal(path, interface, name);
-       if (!msg) {
-               _E("fail to allocate new %s.%s signal", interface, name);
-               return -EPERM;
-       }
-
-       dbus_message_iter_init_append(msg, &iter);
-       r = append_variant(&iter, sig, param);
-       if (r < 0) {
-               _E("append_variant error(%d)", r);
-               return -EPERM;
-       }
-
-       r = dbus_connection_send(conn, msg, NULL);
-
-       if (r != TRUE) {
-               _E("dbus_connection_send error(%s:%s-%s)",
-                       path, interface, name);
-               return -ECOMM;
-       }
-
-       return RESOURCED_ERROR_NONE;
-}
-
-int broadcast_edbus_signal(const char *path, const char *interface,
-               const char *name, int type, void *value)
-{
-       DBusConnection *conn;
-       DBusMessage *msg = dbus_message_new_signal(path, interface, name);
-       int r;
-
-       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
-       if (!conn) {
-               _E("dbus_bus_get error");
-               return -EPERM;
-       }
-
-       if (!msg) {
-               _E("fail to allocate new %s.%s signal", interface, name);
-               return RESOURCED_ERROR_FAIL;
-       }
-
-       dbus_message_append_args(msg, type, value, DBUS_TYPE_INVALID);
-
-       r = dbus_connection_send(conn, msg, NULL);
-       dbus_message_unref(msg);
-
-       if (r != TRUE) {
-               _E("dbus_connection_send error(%s:%s-%s)",
-                       path, interface, name);
-               return -ECOMM;
-       }
-
-       return RESOURCED_ERROR_NONE;
-}
-
-resourced_ret_c edbus_add_methods(const char *path,
-                      const struct edbus_method *const edbus_methods,
-                      const size_t size)
-{
-       E_DBus_Interface *iface;
-       int i;
-       int ret;
-
-       iface = get_edbus_interface(path);
-
-       if (!iface) {
-               _E("Fail to get edbus interface! Path = %s\n", path);
-               return RESOURCED_ERROR_FAIL;
-       }
-
-       for (i = 0; i < size; i++) {
-               if (!edbus_methods[i].member || !edbus_methods[i].func)
-                       continue;
-
-               ret = e_dbus_interface_method_add(iface,
-                                   edbus_methods[i].member,
-                                   edbus_methods[i].signature,
-                                   edbus_methods[i].reply_signature,
-                                   edbus_methods[i].func);
-               if (!ret) {
-                       _E("Fail to add method %s!\n",
-                               edbus_methods[i].member);
-                       return RESOURCED_ERROR_FAIL;
-               }
-       }
-
-       return RESOURCED_ERROR_NONE;
-}
-
-resourced_ret_c edbus_add_signals(
-                      const struct edbus_signal *const edbus_signals,
-                      const size_t size)
-{
-       int i;
-       int ret;
-
-       for (i = 0; i < size; i++) {
-               ret = register_edbus_signal_handler(
-                                   edbus_signals[i].path,
-                                   edbus_signals[i].interface,
-                                   edbus_signals[i].name,
-                                   edbus_signals[i].func,
-                                   edbus_signals[i].user_data);
-               if (ret) {
-                       _E("Fail to add signal %s, %s!\n",
-                               edbus_signals[i].path, edbus_signals[i].name);
-                       return RESOURCED_ERROR_FAIL;
-               }
-       }
-
-       return RESOURCED_ERROR_NONE;
-}
-
-resourced_ret_c dbus_message_reply(DBusMessage *msg)
-{
-       if (dbus_connection_send(dbus_conn, msg, NULL))
-               return RESOURCED_ERROR_NONE;
-       else {
-               _E("Fail to reply dbus message");
-               return RESOURCED_ERROR_FAIL;
-       }
-}
-
-int launch_system_app_by_dbus(const char *dest, const char *path,
-               const char *iface, const char *method, int num, ...)
-{
-       int ret;
-       va_list args;
-
-       va_start(args, num);
-       ret = dbus_method_sync_pairs(dest, path, iface, method, num, args);
-       va_end(args);
-       return ret;
-}
-
-static void request_name_cb(void *data, DBusMessage *msg, DBusError *error)
-{
-       _cleanup_dbus_error_free_ DBusError err = DBUS_ERROR_INIT;
-       unsigned int val;
-       int r;
-
-       if (!msg) {
-               _D("invalid DBusMessage!");
-               return;
-       }
-
-       r = dbus_message_get_args(msg, &err, DBUS_TYPE_UINT32, &val, DBUS_TYPE_INVALID);
-       if (!r) {
-               if (dbus_error_is_set(&err))
-                       _D("there is no message: %s %s", err.name, err.message);
-               else
-                       _D("there is no message");
-               return;
-       }
-
-       _I("Request Name reply : %d", val);
-}
-
-void edbus_init(void)
-{
-       int retry = 0;
-       int i;
-       _cleanup_dbus_error_free_ DBusError err = DBUS_ERROR_INIT;
-
-       dbus_threads_init_default();
-
-retry_init:
-       edbus_init_val = e_dbus_init();
-       if (edbus_init_val) {
-               retry = 0;
-               goto retry_bus_get;
-       }
-       if (retry == EDBUS_INIT_RETRY_COUNT) {
-               _E("fail to init edbus");
-               return;
-       }
-       retry++;
-       goto retry_init;
-
-retry_bus_get:
-       dbus_conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
-       if (dbus_conn) {
-               retry = 0;
-               goto retry_connection_setup;
-       }
-       if (retry == EDBUS_INIT_RETRY_COUNT) {
-               _E("fail to get dbus");
-               goto err1;
-       }
-       retry++;
-       goto retry_bus_get;
-
-retry_connection_setup:
-       edbus_conn = e_dbus_connection_setup(dbus_conn);
-       if (edbus_conn) {
-               retry = 0;
-               goto retry_bus_request;
-       }
-       if (retry == EDBUS_INIT_RETRY_COUNT) {
-               _E("fail to get edbus");
-               goto err2;
-       }
-       retry++;
-       goto retry_connection_setup;
-
-retry_bus_request:
-       edbus_request_name = e_dbus_request_name(edbus_conn, RESOURCED_DBUS_BUS_NAME,
-                       DBUS_NAME_FLAG_REPLACE_EXISTING, request_name_cb, NULL);
-       if (edbus_request_name)
-               goto register_objects;
-       if (retry == EDBUS_INIT_RETRY_COUNT) {
-               _E("fail to request edbus name");
-               goto err3;
-       }
-       retry++;
-       goto retry_bus_request;
-
-register_objects:
-       for (i = 0; i < ARRAY_SIZE(edbus_objects); i++) {
-               int ret;
-
-               ret = register_edbus_interface(&edbus_objects[i]);
-               if (ret < 0) {
-                       _E("fail to add obj & interface for %s",
-                                   edbus_objects[i].interface);
-                       return;
-               }
-
-               _I("add new obj for %s", edbus_objects[i].interface);
-       }
-
-       _I("start edbus service");
-       return;
-
-err3:
-       e_dbus_connection_close(edbus_conn);
-err2:
-       dbus_connection_set_exit_on_disconnect(dbus_conn, FALSE);
-err1:
-       e_dbus_shutdown();
-}
-
-void edbus_exit(void)
-{
-       unregister_edbus_signal_handle();
-       e_dbus_connection_close(edbus_conn);
-       e_dbus_shutdown();
-}
-
-E_DBus_Connection *get_resourced_edbus_connection(void)
-{
-       return edbus_conn;
-}
diff --git a/src/common/edbus-handler.h b/src/common/edbus-handler.h
deleted file mode 100644 (file)
index 961c8c4..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * resourced
- *
- * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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.
- *
- */
-
-/**
- * @file edbus-handler.h
- * @desc  dbus handler using edbus interface
- **/
-
-#ifndef __EDBUS_HANDLE_H__
-#define __EDBUS_HANDLE_H__
-
-#include <E_DBus.h>
-#include <resourced.h>
-
-struct edbus_method {
-       const char *member;
-       const char *signature;
-       const char *reply_signature;
-       E_DBus_Method_Cb func;
-};
-
-struct edbus_object {
-       const char *path;
-       const char *interface;
-       E_DBus_Object *obj;
-       E_DBus_Interface *iface;
-};
-
-struct edbus_signal {
-       const char *path;
-       const char *interface;
-       const char *name;
-       E_DBus_Signal_Cb func;
-       void *user_data;
-};
-
-#define DBUS_REPLY_TIMEOUT  (120 * 1000)
-
-#define RESOURCED_DBUS_BUS_NAME                "org.tizen.resourced"
-#define RESOURCED_DBUS_OBJECT_PATH     "/Org/Tizen/ResourceD"
-#define RESOURCED_DBUS_INTERFACE_NAME  RESOURCED_DBUS_BUS_NAME
-
-/*
- * Core service
- *   get/set swap status
- *   operations about swap
- */
-#define RESOURCED_PATH_SWAP            RESOURCED_DBUS_OBJECT_PATH"/Swap"
-#define RESOURCED_INTERFACE_SWAP       RESOURCED_DBUS_INTERFACE_NAME".swap"
-
-#define RESOURCED_PATH_FREEZER         RESOURCED_DBUS_OBJECT_PATH"/Freezer"
-#define RESOURCED_INTERFACE_FREEZER    RESOURCED_DBUS_INTERFACE_NAME".freezer"
-
-#define RESOURCED_PATH_OOM             RESOURCED_DBUS_OBJECT_PATH"/Oom"
-#define RESOURCED_INTERFACE_OOM                RESOURCED_DBUS_INTERFACE_NAME".oom"
-
-#define RESOURCED_PATH_PROCESS         RESOURCED_DBUS_OBJECT_PATH"/Process"
-#define RESOURCED_INTERFACE_PROCESS    RESOURCED_DBUS_INTERFACE_NAME".process"
-
-#define RESOURCED_PATH_DBUS            RESOURCED_DBUS_OBJECT_PATH"/DBus"
-#define RESOURCED_INTERFACE_DBUS       RESOURCED_DBUS_INTERFACE_NAME".dbus"
-
-#define RESOURCED_PATH_APPOPT          RESOURCED_DBUS_OBJECT_PATH"/Appopt"
-#define RESOURCED_INTERFACE_APPOPT     RESOURCED_DBUS_INTERFACE_NAME".appopt"
-
-#define SIGNAL_PROC_WATCHDOG_RESULT    "WatchdogResult"
-#define SIGNAL_PROC_ACTIVE             "Active"
-#define SIGNAL_PROC_EXCLUDE            "ProcExclude"
-#define SIGNAL_PROC_PRELAUNCH          "ProcPrelaunch"
-#define SIGNAL_PROC_SWEEP              "ProcSweep"
-#define SIGNAL_PROC_WATCHDOG           "ProcWatchdog"
-#define SIGNAL_PROC_SYSTEMSERVICE      "SystemService"
-#define SIGNAL_PROC_EXCLUDEAPPID       "ProcExcludeByAppid"
-
-#define SIGNAL_OOM_SET_THRESHOLD       "SetThreshold"
-#define SIGNAL_OOM_SET_LEAVE_THRESHOLD "SetLeaveThreshold"
-#define SIGNAL_OOM_TRIGGER             "Trigger"
-#define SIGNAL_OOM_SET_PERCEPTIBLE     "SetPerceptible"
-#define SIGNAL_OOM_SET_PLATFORM                "SetPlatformSwap"
-
-#define SIGNAL_NAME_SWAP_TYPE          "SwapType"
-#define SIGNAL_NAME_SWAP_START_PID     "SwapStartPid"
-
-/*
- * Logging
- */
-#define RESOURCED_PATH_LOGGING         RESOURCED_DBUS_OBJECT_PATH"/Logging"
-#define RESOURCED_INTERFACE_LOGGING    RESOURCED_DBUS_INTERFACE_NAME".logging"
-
-/*
- * System popup
- */
-#define SYSTEM_POPUP_BUS_NAME          "org.tizen.system.popup"
-#define SYSTEM_POPUP_PATH_NAME         "/Org/Tizen/System/Popup"
-#define SYSTEM_POPUP_IFACE_NAME                SYSTEM_POPUP_BUS_NAME
-
-#define SYSTEM_POPUP_PATH_SYSTEM       SYSTEM_POPUP_PATH_NAME"/System"
-#define SYSTEM_POPUP_IFACE_SYSTEM      SYSTEM_POPUP_BUS_NAME".System"
-
-#define SYSTEM_POPUP_PATH_DATAUSAGE    SYSTEM_POPUP_PATH_NAME"/DataUsage"
-#define SYSTEM_POPUP_IFACE_DATAUSAGE   SYSTEM_POPUP_BUS_NAME".DataUsage"
-
-/*
- * Deviced
- */
-#define DEVICED_BUS_NAME               "org.tizen.system.deviced"
-#define DEVICED_OBJECT_PATH            "/Org/Tizen/System/DeviceD"
-#define DEVICED_PATH_PROCESS           DEVICED_OBJECT_PATH"/Process"
-#define DEVICED_INTERFACE_PROCESS      DEVICED_BUS_NAME".Process"
-
-#define DEVICED_PATH_DISPLAY           DEVICED_OBJECT_PATH"/Display"
-#define DEVICED_INTERFACE_DISPLAY      DEVICED_BUS_NAME".display"
-
-#define DEVICED_PATH_BATTERY           DEVICED_OBJECT_PATH"/Battery"
-#define DEVICED_INTERFACE_BATTERY      DEVICED_BUS_NAME".Battery"
-
-#define DEVICED_PATH_CORE              DEVICED_OBJECT_PATH"/Core"
-#define DEVICED_INTERFACE_CORE         DEVICED_BUS_NAME".core"
-
-#define DEVICED_PATH_POWEROFF          DEVICED_OBJECT_PATH"/PowerOff"
-#define DEVICED_INTERFACE_POWEROFF     DEVICED_BUS_NAME".PowerOff"
-
-#define DEVICED_PATH_TIME                DEVICED_OBJECT_PATH"/Time"
-#define DEVICED_INTERFACE_TIME           DEVICED_BUS_NAME".Time"
-
-
-#define SIGNAL_DEVICED_LCDON                   "LCDOn"
-#define SIGNAL_DEVICED_LCDOFF                  "LCDOff"
-#define SIGNAL_DEVICED_LCDONCOMPLETE           "LCDOnCompleted"
-#define SIGNAL_DEVICED_BOOTINGDONE             "BootingDone"
-#define SIGNAL_DEVICED_POWEROFF_STATE          "ChangeState"
-#define SIGNAL_DEVICED_SYSTEMTIME_CHANGED      "SystemTimeChanged"
-#define SIGNAL_DEVICED_LOW_BATTERY             "BatteryStatusLow"
-#define SIGNAL_DEVICED_EARLY_BOOTING_DONE      "EarlyBootingDone"
-
-/*
- * dump service
- */
-#define DUMP_SERVICE_BUS_NAME              "org.tizen.system.dumpservice"
-#define DUMP_SERVICE_OBJECT_PATH           "/Org/Tizen/System/DumpService"
-#define DUMP_SERVICE_INTERFACE_NAME        DUMP_SERVICE_BUS_NAME
-
-#define SIGNAL_DUMP            "Dump"
-#define SIGNAL_DUMP_START      "Start"
-#define SIGNAL_DUMP_FINISH     "Finish"
-
-/*
- * Crash
- */
-#define CRASH_BUS_NAME             "org.tizen.system.crash"
-#define CRASH_OBJECT_PATH          "/Org/Tizen/System/Crash"
-#define CRASH_INTERFACE_NAME       CRASH_BUS_NAME
-#define CRASH_PATH_CRASH           CRASH_OBJECT_PATH"/Crash"
-#define CRASH_INTERFACE_CRASH      CRASH_INTERFACE_NAME".Crash"
-#define PROCESS_CRASHED                    "ProcessCrashed"
-
-/*
- * AMD
- */
-#define AUL_APPSTATUS_BUS_NAME         "org.tizen.aul.AppStatus"
-#define AUL_APPSTATUS_OBJECT_PATH      "/Org/Tizen/Aul/AppStatus"
-#define AUL_APPSTATUS_INTERFACE_NAME   AUL_APPSTATUS_BUS_NAME
-
-#define AUL_SUSPEND_BUS_NAME           "org.tizen.appfw.SuspendHint"
-#define AUL_SUSPEND_OBJECT_PATH                "/Org/Tizen/Appfw/SuspendHint"
-#define AUL_SUSPEND_INTERFACE_NAME     AUL_SUSPEND_BUS_NAME
-
-#define SIGNAL_AMD_LAUNCH      "AppLaunch"
-#define SIGNAL_AMD_RESUME      "AppResume"
-#define SIGNAL_AMD_TERMINATE   "AppTerminate"
-#define SIGNAL_AMD_STATE       "AppStatusChange"
-#define SIGNAL_AMD_GROUP       "AppGroup"
-#define SIGNAL_AMD_TERMINATED  "AppTerminated"
-#define SIGNAL_AMD_SUSPNED     "SuspendHint"
-
-struct dbus_byte {
-       char *data;
-       int size;
-};
-
-#define RETRY_MAX 5
-
-/*
- * @desc helper function for filling params array
- * That params array is used in dbus_method_sync/dbus_method_async
- * */
-void serialize_params(char *params[], size_t n, ...);
-
-
-DBusMessage *dbus_method_sync(const char *dest, const char *path,
-               const char *interface, const char *method,
-               const char *sig, char *param[]);
-
-int dbus_method_async(const char *dest, const char *path,
-               const char *interface, const char *method,
-               const char *sig, char *param[]);
-
-int register_edbus_signal_handler(const char *path, const char *interface,
-               const char *name, E_DBus_Signal_Cb cb, void *user_data);
-E_DBus_Interface *get_edbus_interface(const char *path);
-pid_t get_edbus_sender_pid(DBusMessage *msg);
-int broadcast_edbus_signal_str(const char *path, const char *interface,
-               const char *name, const char *sig, char *param[]);
-int broadcast_edbus_signal(const char *path, const char *interface,
-                          const char *name, int type, void *value);
-resourced_ret_c edbus_add_methods(const char *path,
-                      const struct edbus_method *const edbus_methods,
-                      const size_t size);
-resourced_ret_c edbus_add_signals(
-                      const struct edbus_signal *const edbus_signals,
-                      const size_t size);
-resourced_ret_c dbus_message_reply(DBusMessage *msg);
-int register_edbus_interface(struct edbus_object *object);
-
-int launch_system_app_by_dbus(const char *dest, const char *path,
-               const char *iface, const char *method, int num, ...);
-
-void edbus_init(void);
-void edbus_exit(void);
-
-E_DBus_Connection *get_resourced_edbus_connection(void);
-
-#endif /* __EDBUS_HANDLE_H__ */
diff --git a/src/common/fd-handler.c b/src/common/fd-handler.c
new file mode 100644 (file)
index 0000000..a2635bc
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * resourced
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"),
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+*/
+
+/*
+ * @file fd-handler.c
+ *
+ * @desc fd handler using glib
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "trace.h"
+#include "fd-handler.h"
+
+struct fd_handler_s {
+       int fd;
+       GIOChannel *ch;
+       guint id;
+       fd_changed_cb changed;
+       void *data;
+       release_cb free_func;
+       fd_handler_h *handler_p;
+};
+
+int remove_fd_read_handler(fd_handler_h *handler)
+{
+       struct fd_handler_s *h;
+
+       if (!handler || !(*handler))
+               return -EINVAL;
+
+       h = *handler;
+
+       if (h->free_func)
+               h->free_func(h->data);
+
+       if (h->id)
+               g_source_remove(h->id);
+
+       if (h->ch)
+               g_io_channel_unref(h->ch);
+
+       *(h->handler_p) = NULL;
+       free(h);
+
+       return 0;
+}
+
+static gboolean channel_changed(GIOChannel *source,
+               GIOCondition condition, gpointer data)
+{
+       struct fd_handler_s *h = data;
+       bool ret;
+
+       if (!h)
+               return TRUE;
+
+       if (h->ch != source)
+               return TRUE;
+
+       if (h->fd != g_io_channel_unix_get_fd(source))
+               return TRUE;
+
+       if (condition != G_IO_IN)
+               return TRUE;
+
+       ret = true;
+       if (h->changed)
+               ret = h->changed(h->fd, h->data);
+
+       if (ret)
+               return TRUE;
+
+       remove_fd_read_handler((fd_handler_h *)&h);
+
+       return FALSE;
+}
+
+int add_fd_read_handler(int fd,
+               fd_changed_cb callback, void *data,
+               release_cb free_func, fd_handler_h *handler)
+{
+       GIOChannel *ch;
+       struct fd_handler_s *h;
+       guint id;
+
+       if (fd < 0 || !callback)
+               return -EINVAL;
+
+       h = calloc(1, sizeof(struct fd_handler_s));
+       if (!h)
+               return -ENOMEM;
+
+       ch = g_io_channel_unix_new(fd);
+       if (!ch) {
+               _E("Failed to create GIOChannel");
+               free(h);
+               return -ENOMEM;
+       }
+
+       id = g_io_add_watch(ch, G_IO_IN | G_IO_ERR,
+                       channel_changed, h);
+       if (id == 0) {
+               _E("Failed to add watch for GIOChannel");
+               free(h);
+               g_io_channel_unref(ch);
+               return -ENOMEM;
+       }
+
+       h->fd = fd;
+       h->changed = callback;
+       h->data = data;
+       h->free_func = free_func;
+       h->ch = ch;
+       h->id = id;
+       h->handler_p = handler;
+
+       *handler = h;
+
+       return 0;
+}
diff --git a/src/common/fd-handler.h b/src/common/fd-handler.h
new file mode 100644 (file)
index 0000000..c8b7454
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * resourced
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+
+#ifndef __FD_HANDLER_H__
+#define __FD_HANDLER_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+#include <stdbool.h>
+
+/**
+ * @brief   File descriptor handler
+ * @since_tizen 4.0
+ */
+typedef void *fd_handler_h;
+
+/**
+ * @brief   Type for the file descriptor change callback function
+ * @since_tizen 4.0
+ */
+typedef bool (*fd_changed_cb)(int fd, void *data);
+
+/**
+ * @brief   Type of the callback function to release user data
+ * @since_tizen 4.0
+ */
+typedef void (*release_cb)(void *data);
+
+/**
+ * @brief   Register file descriptor callback function
+ * @since_tizen 4.0
+ * @param[in]  fd    The file descriptor to notify the changes.
+ * @param[in]  callback The callback function which will be called when the fd is changed.
+ * @param[in]  data  The user data which is delivered to the callback function.
+ * @param[in]  free_func  The callback function to release the user data which is called when the handler is removed by remove_fd_read_handler().
+ * @param[out] handler The handler which will be used to remove the fd handler.
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ * @remarks If the callback function returns false, the fd handler is removed automatically and the callback will not be called again.
+ */
+int add_fd_read_handler(int fd, fd_changed_cb callback,
+               void *data, release_cb free_func,
+               fd_handler_h *handler);
+
+/**
+ * @brief   Unregister file descriptor callback function
+ * @since_tizen 4.0
+ * @param[in]  handler    The fd handler which is obtained by add_fd_read_handler().
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ */
+int remove_fd_read_handler(fd_handler_h *handler);
+
+#endif /* __FD_HANDLER_H__ */
index cc75955..61dee45 100644 (file)
@@ -26,7 +26,7 @@
 #include "module.h"
 #include "resourced.h"
 #include "trace.h"
-#include "edbus-handler.h"
+#include "dbus-handler.h"
 
 #include <glib.h>
 
@@ -195,7 +195,7 @@ void modules_dump(FILE *fp, int mode)
        }
 }
 
-static DBusMessage *edbus_list_active_modules_handler(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_list_active_modules_handler(DBusMessage *msg)
 {
        DBusMessage *reply;
        DBusMessageIter iter, array_iter;
@@ -232,15 +232,14 @@ finish:
        return reply;
 }
 
-static struct edbus_method resourced_module_methods[] = {
-       { "ListActiveModuels",  NULL,   "as",   edbus_list_active_modules_handler       },
+static struct d_bus_method resourced_module_methods[] = {
+       { "ListActiveModuels",  NULL,   "as",   dbus_list_active_modules_handler        },
        { NULL,                 NULL,   NULL,   NULL                                    },
        /* Add methods here */
 };
 
 int modules_add_methods(void)
 {
-       return edbus_add_methods(RESOURCED_DBUS_OBJECT_PATH,
-                                resourced_module_methods,
-                                ARRAY_SIZE(resourced_module_methods));
+       return d_bus_register_methods(RESOURCED_DBUS_OBJECT_PATH,
+                       resourced_module_methods, ARRAY_SIZE(resourced_module_methods));
 }
index d8b0f4c..e993266 100644 (file)
@@ -27,6 +27,7 @@
 #include <dirent.h>
 #include <errno.h>
 #include <ctype.h>
+#include <stdlib.h>
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/resource.h>
@@ -66,7 +67,7 @@
 #define CPU_HIGHAPP_PRI -5
 #define CPU_QUOTA_PERIOD_USEC 1000
 
-static Ecore_Timer *cpu_predefined_timer = NULL;
+static GSource *cpu_predefined_timer;
 static bool bCPUQuota;
 
 static inline int ioprio_set(int which, int who, int ioprio)
@@ -369,7 +370,7 @@ static int cpu_exclude_state(void *data)
        return RESOURCED_ERROR_NONE;
 }
 
-static Eina_Bool cpu_predefined_cb(void *data)
+static gboolean cpu_predefined_cb(gpointer data)
 {
        int i = 0;
 
@@ -385,9 +386,8 @@ static Eina_Bool cpu_predefined_cb(void *data)
                        ioprio_set(IOPRIO_WHO_PROCESS, def_list.control[i].pid, IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT);
                }
        }
-       ecore_timer_del(cpu_predefined_timer);
        cpu_predefined_timer = NULL;
-       return ECORE_CALLBACK_CANCEL;
+       return false;
 
 }
 
@@ -405,9 +405,11 @@ static int resourced_cpu_init(void *data)
        }
        config_parse(CPU_CONF_FILE, load_cpu_config, NULL);
 
-       if (def_list.num)
-               cpu_predefined_timer =
-                       ecore_timer_add(CPU_TIMER_INTERVAL, cpu_predefined_cb, NULL);
+       if (def_list.num) {
+               cpu_predefined_timer = g_timeout_source_new_seconds(CPU_TIMER_INTERVAL);
+               g_source_set_callback(cpu_predefined_timer, cpu_predefined_cb, NULL, NULL);
+               g_source_attach(cpu_predefined_timer, NULL);
+       }
        register_notifier(RESOURCED_NOTIFIER_SERVICE_LAUNCH, cpu_service_state);
        register_notifier(RESOURCED_NOTIFIER_APP_RESUME, cpu_foreground_state);
        register_notifier(RESOURCED_NOTIFIER_APP_FOREGRD, cpu_foreground_state);
index a7cc79f..4d19fa4 100644 (file)
  */
 
 #include <dlfcn.h>
+#include <sys/stat.h>
 
 #include "macro.h"
 #include "util.h"
 #include "module.h"
 #include "module-data.h"
 #include "notifier.h"
-#include "edbus-handler.h"
+#include "dbus-handler.h"
 #include "resourced.h"
 #include "trace.h"
 #include "vconf.h"
@@ -61,7 +62,7 @@ static int (*resourced_freezer_initialize)(void *data) = NULL;
 static int (*resourced_freezer_deinitialize)(void) = NULL;
 
 /* Freezer module dbus method calls and signal handlers */
-static DBusMessage *(*resourced_freezer_dbus_method_handler)(E_DBus_Object *obj, DBusMessage *msg) = NULL;
+static DBusMessage *(*resourced_freezer_dbus_method_handler)(DBusMessage *msg) = NULL;
 static void (*resourced_freezer_dbus_signal_handler)(void *data, DBusMessage *msg) = NULL;
 
 /* Resourced notifier handlers */
@@ -87,14 +88,14 @@ int resourced_freezer_proc_late_control(void)
 }
 
 /****************************************** Internal symbols **************************************************/
-static DBusMessage *resourced_freezer_dbus_method_handler_generic(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *resourced_freezer_dbus_method_handler_generic(DBusMessage *msg)
 {
        DBusMessageIter iter;
        DBusMessage *reply;
        int ret;
 
        if (resourced_freezer_dbus_method_handler)
-               return resourced_freezer_dbus_method_handler(obj, msg);
+               return resourced_freezer_dbus_method_handler(msg);
 
        ret = 0;
 
@@ -104,13 +105,13 @@ static DBusMessage *resourced_freezer_dbus_method_handler_generic(E_DBus_Object
        return reply;
 }
 
-static struct edbus_method edbus_methods[] = {
+static struct d_bus_method dbus_methods[] = {
        { METHOD_GET_FREEZER_STATE,     NULL,   "i", resourced_freezer_dbus_method_handler_generic },
        { METHOD_GET_FREEZER_SERVICE,   NULL,   "i", resourced_freezer_dbus_method_handler_generic },
        /* Add methods here */
 };
 
-static struct edbus_method edbus_suspend_methods[] = {
+static struct d_bus_method dbus_suspend_methods[] = {
        { METHOD_SET_FREEZER_SUSPEND,   "s", "i", resourced_freezer_dbus_method_handler_generic },
        /* Add methods here */
 };
@@ -119,20 +120,20 @@ static void freezer_dbus_init(bool is_suspend)
 {
        resourced_ret_c ret;
 
-       register_edbus_signal_handler(RESOURCED_PATH_FREEZER,
+       d_bus_register_signal(RESOURCED_PATH_FREEZER,
                                      RESOURCED_INTERFACE_FREEZER,
                                      SIGNAL_FREEZER_STATUS,
                                      (void *)resourced_freezer_dbus_signal_handler,
                                      NULL);
-       register_edbus_signal_handler(RESOURCED_PATH_FREEZER,
+       d_bus_register_signal(RESOURCED_PATH_FREEZER,
                                      RESOURCED_INTERFACE_FREEZER,
                                      SIGNAL_FREEZER_SERVICE,
                                      (void *)resourced_freezer_dbus_signal_handler,
                                      NULL);
 
-       ret = edbus_add_methods(RESOURCED_PATH_FREEZER,
-                               edbus_methods,
-                               ARRAY_SIZE(edbus_methods));
+       ret = d_bus_register_methods(RESOURCED_PATH_FREEZER,
+                               dbus_methods,
+                               ARRAY_SIZE(dbus_methods));
 
        ret_msg_if(ret != RESOURCED_ERROR_NONE,
                   "DBus method registration for %s is failed",
@@ -141,15 +142,15 @@ static void freezer_dbus_init(bool is_suspend)
        if (!is_suspend)
                return;
 
-       register_edbus_signal_handler(DEVICED_PATH_DISPLAY,
+       d_bus_register_signal(DEVICED_PATH_DISPLAY,
                                      DEVICED_INTERFACE_DISPLAY,
                                      SIGNAL_DEVICED_LCDONCOMPLETE,
                                      (void *)resourced_freezer_dbus_signal_handler,
                                      NULL);
 
-       ret = edbus_add_methods(RESOURCED_PATH_FREEZER,
-                               edbus_suspend_methods,
-                               ARRAY_SIZE(edbus_suspend_methods));
+       ret = d_bus_register_methods(RESOURCED_PATH_FREEZER,
+                               dbus_suspend_methods,
+                               ARRAY_SIZE(dbus_suspend_methods));
        ret_msg_if(ret != RESOURCED_ERROR_NONE,
                   "DBus method registration for %s is failed",
                   RESOURCED_PATH_FREEZER);
index 6a35da1..96b0967 100644 (file)
@@ -25,7 +25,6 @@
  *
  */
 
-#include <Ecore.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
@@ -41,7 +40,7 @@
 #include "heart.h"
 #include "logging.h"
 #include "heart-common.h"
-#include "edbus-handler.h"
+#include "dbus-handler.h"
 #include "decision.h"
 #include "filemap.h"
 
@@ -74,7 +73,7 @@ struct decision_thread {
 };
 static struct decision_thread decisions[DECISION_THREAD_MAX];
 
-static Ecore_Timer *decision_write_timer = NULL;
+static GSource *decision_write_timer = NULL;
 
 static const struct decision_module *decision_module_find(int type)
 {
@@ -568,7 +567,7 @@ int decision_update_start(void)
        return RESOURCED_ERROR_NONE;
 }
 
-static Eina_Bool decision_send_signal_to_write(void *data)
+static gboolean decision_send_signal_to_write(gpointer data)
 {
        int ret;
 
@@ -578,14 +577,14 @@ static Eina_Bool decision_send_signal_to_write(void *data)
        ret = pthread_mutex_trylock(&decisions[DECISION_THREAD_WRITE].mutex);
        if (ret) {
                _E("pthread_mutex_trylock fail : %d, errno : %d", ret, errno);
-               return ECORE_CALLBACK_RENEW;
+               return true;
        }
 
        pthread_cond_signal(&decisions[DECISION_THREAD_WRITE].cond);
        _I("send signal to decision write thread");
        pthread_mutex_unlock(&decisions[DECISION_THREAD_WRITE].mutex);
 
-       return ECORE_CALLBACK_RENEW;
+       return true;
 }
 
 static int decision_init(void)
@@ -628,8 +627,9 @@ static int decision_init(void)
 
        if (decision_write_timer == NULL) {
                _E("decision write timer start");
-               decision_write_timer = ecore_timer_add(DECISION_WRITE_INTERVAL,
-                       decision_send_signal_to_write, (void *)NULL);
+               decision_write_timer = g_timeout_source_new_seconds(DECISION_WRITE_INTERVAL);
+               g_source_set_callback(decision_write_timer, decision_send_signal_to_write, NULL, NULL);
+               g_source_attach(decision_write_timer, NULL);
        }
 
        ret = decision_thread_create();
@@ -650,7 +650,7 @@ static int decision_exit(void)
                decision_queue = NULL;
        }
 
-       ecore_timer_del(decision_write_timer);
+       g_source_destroy(decision_write_timer);
        decision_write_timer = NULL;
 
        unregister_notifier(RESOURCED_NOTIFIER_APP_TERMINATED,
index 8b195ec..6da2392 100644 (file)
@@ -32,7 +32,7 @@
 #include "proc-common.h"
 #include "notifier.h"
 #include "resourced.h"
-#include "edbus-handler.h"
+#include "dbus-handler.h"
 #include "heart.h"
 #include "logging.h"
 #include "heart-common.h"
@@ -130,7 +130,7 @@ static void heart_abnormal_launch_popup(char *appid, int count)
        param[5] = _appid;
        _D("appid %s, count %d", appid, count);
 
-       ret = dbus_method_async("org.tizen.system.popup",
+       ret = d_bus_call_method_async("org.tizen.system.popup",
                        "/Org/Tizen/System/Popup/System",
                        "org.tizen.system.popup.System",
                        "MalfunctionNotifierLaunch", "ssssss", param);
@@ -232,7 +232,7 @@ static void heart_abnormal_free_value(gpointer value)
        free(table);
 }
 
-static DBusMessage *edbus_heart_get_abnormal_data(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *edbus_heart_get_abnormal_data(DBusMessage *msg)
 {
        int type, period, ret, count, i;
        time_t starttime;
@@ -338,7 +338,7 @@ static DBusMessage *edbus_heart_get_abnormal_data(E_DBus_Object *obj, DBusMessag
        return reply;
 }
 
-static struct edbus_method edbus_methods[] = {
+static struct d_bus_method dbus_methods[] = {
        { "GetAbnormalData",      "ii",   "a(si)",     edbus_heart_get_abnormal_data },
 };
 
@@ -352,13 +352,13 @@ static int heart_abnormal_init(void *data)
                return RESOURCED_ERROR_FAIL;
        }
 
-       ret = edbus_add_methods(RESOURCED_PATH_LOGGING, edbus_methods,
-                       ARRAY_SIZE(edbus_methods));
+       ret = d_bus_register_methods(RESOURCED_PATH_LOGGING, dbus_methods,
+                       ARRAY_SIZE(dbus_methods));
        if (ret != RESOURCED_ERROR_NONE) {
                _E("DBus method registration for %s is failed",
                                RESOURCED_PATH_LOGGING);
        }
-       ret = register_edbus_signal_handler(CRASH_PATH_CRASH,
+       ret = d_bus_register_signal(CRASH_PATH_CRASH,
                        CRASH_INTERFACE_CRASH, PROCESS_CRASHED,
                        heart_abnormal_process_crashed, NULL);
        if (ret < 0)
index d14bce4..68aa196 100644 (file)
 #include <stdbool.h>
 #include <stdlib.h>
 #include <glib.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <math.h>
 
 #include "proc-common.h"
 #include "notifier.h"
 #include "resourced.h"
-#include "edbus-handler.h"
+#include "dbus-handler.h"
 #include "heart.h"
 #include "logging.h"
 #include "heart-common.h"
@@ -1943,7 +1947,7 @@ static int heart_battery_direct_get_capacity(void)
        int capacity, ret;
        DBusMessage *msg;
 
-       msg = dbus_method_sync(DEVICED_BUS_NAME, DEVICED_PATH_BATTERY,
+       msg = d_bus_call_method_sync(DEVICED_BUS_NAME, DEVICED_PATH_BATTERY,
                        DEVICED_INTERFACE_BATTERY,
                        GET_BATTERY_CAPACITY,
                        NULL, NULL);
@@ -1965,7 +1969,7 @@ static enum charger_status_type heart_battery_direct_get_charger_status(void)
        int status, ret;
        DBusMessage *msg;
 
-       msg = dbus_method_sync(DEVICED_BUS_NAME, DEVICED_PATH_BATTERY,
+       msg = d_bus_call_method_sync(DEVICED_BUS_NAME, DEVICED_PATH_BATTERY,
                        DEVICED_INTERFACE_BATTERY,
                        GET_CHARGER_STATUS,
                        NULL, NULL);
@@ -2228,7 +2232,7 @@ int heart_battery_get_capacity_history(GArray *arrays, enum heart_data_period pe
 
 /* ============================ DBUS interface ====================== */
 
-static DBusMessage *edbus_get_battery_capacity_history_latest(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_get_battery_capacity_history_latest(DBusMessage *msg)
 {
        int i, ret, size, charge, max_size;
        DBusMessage *reply;
@@ -2282,7 +2286,7 @@ exit:
        return reply;
 }
 
-static DBusMessage *edbus_get_battery_capacity_history(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_get_battery_capacity_history(DBusMessage *msg)
 {
        int ret, size, period, index;
        DBusMessage *reply;
@@ -2358,7 +2362,7 @@ static DBusMessage *edbus_get_battery_capacity_history(E_DBus_Object *obj, DBusM
        return reply;
 }
 
-static DBusMessage *edbus_get_battery_used_time(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_get_battery_used_time(DBusMessage *msg)
 {
        int ret;
        DBusMessage *reply;
@@ -2459,7 +2463,7 @@ static int get_battery_remaining_time(int mode, enum charger_status_type status)
        }
 }
 
-static DBusMessage *edbus_get_battery_remaining_time(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_get_battery_remaining_time(DBusMessage *msg)
 {
        DBusMessage *reply;
        DBusMessageIter iter;
@@ -2489,7 +2493,7 @@ static DBusMessage *edbus_get_battery_remaining_time(E_DBus_Object *obj, DBusMes
        return reply;
 }
 
-static DBusMessage *edbus_get_battery_charging_time(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_get_battery_charging_time(DBusMessage *msg)
 {
        DBusMessage *reply;
        DBusMessageIter iter;
@@ -2505,7 +2509,7 @@ static DBusMessage *edbus_get_battery_charging_time(E_DBus_Object *obj, DBusMess
        return reply;
 }
 
-static DBusMessage *edbus_get_battery_discharge_rate_level(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_get_battery_discharge_rate_level(DBusMessage *msg)
 {
        DBusMessage *reply;
        DBusMessageIter iter;
@@ -2521,7 +2525,7 @@ static DBusMessage *edbus_get_battery_discharge_rate_level(E_DBus_Object *obj, D
        return reply;
 }
 
-static DBusMessage *edbus_battery_save_to_file(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_battery_save_to_file(DBusMessage *msg)
 {
        int ret;
        DBusMessage *reply;
@@ -2546,14 +2550,14 @@ static DBusMessage *edbus_battery_save_to_file(E_DBus_Object *obj, DBusMessage *
        return reply;
 }
 
-static struct edbus_method edbus_methods[] = {
-       { "GetBatteryCapacityHistory", "i",   "a(iii)", edbus_get_battery_capacity_history },
-       { "GetBatteryCapacityHistoryLatest", "ii", "a(iii)", edbus_get_battery_capacity_history_latest },
-       { "GetBatteryUsedTime",   NULL,   "i", edbus_get_battery_used_time },
-       { "GetBatteryRemainingTime",   "i",   "i", edbus_get_battery_remaining_time },
-       { "GetBatteryChargingTime",   NULL,   "i", edbus_get_battery_charging_time },
-       { "GetBatteryDischargeRateLevel",   NULL,   "i", edbus_get_battery_discharge_rate_level },
-       { "SaveBatteryData",   NULL,   "i", edbus_battery_save_to_file },
+static struct d_bus_method dbus_methods[] = {
+       { "GetBatteryCapacityHistory", "i",   "a(iii)", dbus_get_battery_capacity_history },
+       { "GetBatteryCapacityHistoryLatest", "ii", "a(iii)", dbus_get_battery_capacity_history_latest },
+       { "GetBatteryUsedTime",   NULL,   "i", dbus_get_battery_used_time },
+       { "GetBatteryRemainingTime",   "i",   "i", dbus_get_battery_remaining_time },
+       { "GetBatteryChargingTime",   NULL,   "i", dbus_get_battery_charging_time },
+       { "GetBatteryDischargeRateLevel",   NULL,   "i", dbus_get_battery_discharge_rate_level },
+       { "SaveBatteryData",   NULL,   "i", dbus_battery_save_to_file },
 };
 
 /* =========================  DBUS interface END ==================== */
@@ -2802,19 +2806,19 @@ static int heart_battery_init(void *data)
                return RESOURCED_ERROR_FAIL;
        }
 
-       ret = edbus_add_methods(RESOURCED_PATH_LOGGING, edbus_methods,
-                       ARRAY_SIZE(edbus_methods));
+       ret = d_bus_register_methods(RESOURCED_PATH_LOGGING, dbus_methods,
+                       ARRAY_SIZE(dbus_methods));
        if (ret != RESOURCED_ERROR_NONE) {
                _E("DBus method registration for %s is failed",
                                RESOURCED_PATH_LOGGING);
        }
-       ret = register_edbus_signal_handler(DEVICED_PATH_BATTERY,
+       ret = d_bus_register_signal(DEVICED_PATH_BATTERY,
                        DEVICED_INTERFACE_BATTERY, GET_BATTERY_CAPACITY,
                        heart_battery_capacity_status, NULL);
        if (ret < 0)
                _E("Failed to add a capacity status signal handler");
 
-       ret = register_edbus_signal_handler(DEVICED_PATH_BATTERY,
+       ret = d_bus_register_signal(DEVICED_PATH_BATTERY,
                        DEVICED_INTERFACE_BATTERY, GET_CHARGER_STATUS,
                        heart_battery_charger_status, NULL);
        if (ret < 0)
index f04a24e..637803c 100644 (file)
 #include <stdlib.h>
 #include <glib.h>
 #include <math.h>
+#include <sys/stat.h>
+#include <sys/types.h>
 
 #include "proc-common.h"
 #include "notifier.h"
 #include "resourced.h"
-#include "edbus-handler.h"
+#include "dbus-handler.h"
 #include "heart.h"
 #include "logging.h"
 #include "heart-common.h"
@@ -1191,7 +1193,7 @@ static int heart_cpu_update_appid(void *data)
        return logging_modify_appid(CPU_NAME, old_appid, new_appid, pid);
 }
 
-static DBusMessage *edbus_heart_get_cpu_data(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_heart_get_cpu_data(DBusMessage *msg)
 {
        int period, index, i, ret;
        char *appid;
@@ -1291,7 +1293,7 @@ unlock_exit:
        return reply;
 }
 
-static DBusMessage *edbus_heart_get_cpu_data_list(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_heart_get_cpu_data_list(DBusMessage *msg)
 {
        int period, index, i, ret;
        gpointer value;
@@ -1423,7 +1425,7 @@ static DBusMessage *edbus_heart_get_cpu_data_list(E_DBus_Object *obj, DBusMessag
        return reply;
 }
 
-static DBusMessage *edbus_heart_reset_cpu_data(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_heart_reset_cpu_data(DBusMessage *msg)
 {
        int ret;
        DBusMessage *reply;
@@ -1443,7 +1445,7 @@ static DBusMessage *edbus_heart_reset_cpu_data(E_DBus_Object *obj, DBusMessage *
        return reply;
 }
 
-static DBusMessage *edbus_heart_update_cpu_data(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_heart_update_cpu_data(DBusMessage *msg)
 {
        int ret = 0;
        DBusMessage *reply;
@@ -1456,7 +1458,7 @@ static DBusMessage *edbus_heart_update_cpu_data(E_DBus_Object *obj, DBusMessage
        return reply;
 }
 
-static DBusMessage *edbus_heart_sync_cpu_data(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_heart_sync_cpu_data(DBusMessage *msg)
 {
        int ret = 0;
        DBusMessage *reply;
@@ -1475,7 +1477,7 @@ static DBusMessage *edbus_heart_sync_cpu_data(E_DBus_Object *obj, DBusMessage *m
        return reply;
 }
 
-static DBusMessage *edbus_heart_save_to_file(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_heart_save_to_file(DBusMessage *msg)
 {
        int ret;
        DBusMessage *reply;
@@ -1504,13 +1506,13 @@ static DBusMessage *edbus_heart_save_to_file(E_DBus_Object *obj, DBusMessage *ms
        return reply;
 }
 
-static struct edbus_method edbus_methods[] = {
-       { "GetCpuData",     "isi",   "ii",     edbus_heart_get_cpu_data },
-       { "GetCpuDataList",  "ii",   "a(sii)", edbus_heart_get_cpu_data_list },
-       { "ResetCpuData",    NULL,   "i",      edbus_heart_reset_cpu_data },
-       { "UpdateCpuData",   NULL,   "i",      edbus_heart_update_cpu_data },
-       { "SyncCpuData",     NULL,   "i",      edbus_heart_sync_cpu_data },
-       { "SaveCpuData",     NULL,   "i",      edbus_heart_save_to_file },
+static struct d_bus_method dbus_methods[] = {
+       { "GetCpuData",     "isi",   "ii",     dbus_heart_get_cpu_data },
+       { "GetCpuDataList",  "ii",   "a(sii)", dbus_heart_get_cpu_data_list },
+       { "ResetCpuData",    NULL,   "i",      dbus_heart_reset_cpu_data },
+       { "UpdateCpuData",   NULL,   "i",      dbus_heart_update_cpu_data },
+       { "SyncCpuData",     NULL,   "i",      dbus_heart_sync_cpu_data },
+       { "SaveCpuData",     NULL,   "i",      dbus_heart_save_to_file },
 };
 
 static int heart_cpu_reset(void *data)
@@ -1574,8 +1576,8 @@ static int heart_cpu_init(void *data)
                }
        }
 
-       ret = edbus_add_methods(RESOURCED_PATH_LOGGING, edbus_methods,
-                       ARRAY_SIZE(edbus_methods));
+       ret = d_bus_register_methods(RESOURCED_PATH_LOGGING, dbus_methods,
+                       ARRAY_SIZE(dbus_methods));
        if (ret != RESOURCED_ERROR_NONE) {
                _E("DBus method registration for %s is failed",
                                RESOURCED_PATH_LOGGING);
index 07c1eea..c51adaf 100644 (file)
@@ -29,7 +29,6 @@
 #include <stdlib.h>
 #include <time.h>
 #include <glib.h>
-#include <Ecore.h>
 
 #include "resourced.h"
 #include "trace.h"
@@ -41,7 +40,7 @@
 #include "logging.h"
 #include "heart-common.h"
 #include "decision-memory.h"
-#include "edbus-handler.h"
+#include "dbus-handler.h"
 #include "smaps.h"
 
 #include <sqlite3.h>
@@ -79,7 +78,7 @@ struct heart_memory_table {
 static GHashTable *heart_memory_app_list;
 static pthread_mutex_t heart_memory_mutex = PTHREAD_MUTEX_INITIALIZER;
 static time_t last_file_update_time;
-static Ecore_Timer *heart_memory_update_timer = NULL;
+static GSource *heart_memory_update_timer = NULL;
 
 struct heart_memory_table *heart_memory_find_info(GHashTable *hashtable, char *appid)
 {
@@ -1149,14 +1148,14 @@ static int heart_memory_state_cb(void *data)
        return RESOURCED_ERROR_NONE;
 }
 
-static Eina_Bool heart_memory_notify(void *data)
+static gboolean heart_memory_notify(gpointer data)
 {
        resourced_notify(RESOURCED_NOTIFIER_LOGGING_START, NULL);
 
-       return ECORE_CALLBACK_RENEW;
+       return true;
 }
 
-static DBusMessage *edbus_get_memory_latest(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_get_memory_latest(DBusMessage *msg)
 {
        int ret;
        DBusMessageIter iter;
@@ -1189,7 +1188,7 @@ static DBusMessage *edbus_get_memory_latest(E_DBus_Object *obj, DBusMessage *msg
        return reply;
 }
 
-static DBusMessage *edbus_get_memory_data(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_get_memory_data(DBusMessage *msg)
 {
        int ret, period;
        DBusMessageIter iter;
@@ -1226,7 +1225,7 @@ static DBusMessage *edbus_get_memory_data(E_DBus_Object *obj, DBusMessage *msg)
        return reply;
 }
 
-static DBusMessage *edbus_get_memory_data_list(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_get_memory_data_list(DBusMessage *msg)
 {
        int i, ret, period;
        char *appid, *pkgid;
@@ -1283,7 +1282,7 @@ static DBusMessage *edbus_get_memory_data_list(E_DBus_Object *obj, DBusMessage *
        return reply;
 }
 
-static DBusMessage *edbus_get_memorydb(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_get_memorydb(DBusMessage *msg)
 {
        int i, ret, period;
        char *appid, *pkgid;
@@ -1334,7 +1333,7 @@ static DBusMessage *edbus_get_memorydb(E_DBus_Object *obj, DBusMessage *msg)
        return reply;
 }
 
-static DBusMessage *edbus_get_memoryforeach(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_get_memoryforeach(DBusMessage *msg)
 {
        int i, ret, period;
        char *appid, *pkgid;
@@ -1386,7 +1385,7 @@ static DBusMessage *edbus_get_memoryforeach(E_DBus_Object *obj, DBusMessage *msg
        return reply;
 }
 
-static DBusMessage *edbus_memory_save_to_file(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_memory_save_to_file(DBusMessage *msg)
 {
        int ret;
        DBusMessage *reply;
@@ -1406,13 +1405,13 @@ static DBusMessage *edbus_memory_save_to_file(E_DBus_Object *obj, DBusMessage *m
        return reply;
 }
 
-static struct edbus_method edbus_methods[] = {
-       { "GetMemoryLatest",   "s",   "uu", edbus_get_memory_latest },
-       { "GetMemoryData",   "si",   "uuuu", edbus_get_memory_data },
-       { "GetMemoryDataList",   "i",   "a(ssuuuu)", edbus_get_memory_data_list },
-       { "GetMemoryDB",   "i",   "a(ssuuuu)", edbus_get_memorydb },
-       { "GetMemoryforeach",   "i",   "a(ssuuuu)", edbus_get_memoryforeach },
-       { "SaveMemoryData",   NULL,   "i", edbus_memory_save_to_file },
+static struct d_bus_method dbus_methods[] = {
+       { "GetMemoryLatest",   "s",   "uu", dbus_get_memory_latest },
+       { "GetMemoryData",   "si",   "uuuu", dbus_get_memory_data },
+       { "GetMemoryDataList",   "i",   "a(ssuuuu)", dbus_get_memory_data_list },
+       { "GetMemoryDB",   "i",   "a(ssuuuu)", dbus_get_memorydb },
+       { "GetMemoryforeach",   "i",   "a(ssuuuu)", dbus_get_memoryforeach },
+       { "SaveMemoryData",   NULL,   "i", dbus_memory_save_to_file },
        /* Add methods here */
 };
 
@@ -1447,8 +1446,8 @@ static int heart_memory_init(void *data)
        register_notifier(RESOURCED_NOTIFIER_APP_FOREGRD, heart_memory_state_cb);
        register_notifier(RESOURCED_NOTIFIER_APP_BACKGRD, heart_memory_state_cb);
 
-       ret = edbus_add_methods(RESOURCED_PATH_LOGGING, edbus_methods,
-                       ARRAY_SIZE(edbus_methods));
+       ret = d_bus_register_methods(RESOURCED_PATH_LOGGING, dbus_methods,
+                       ARRAY_SIZE(dbus_methods));
 
        if (ret != RESOURCED_ERROR_NONE) {
                _E("DBus method registration for %s is failed", RESOURCED_PATH_LOGGING);
@@ -1459,7 +1458,9 @@ static int heart_memory_init(void *data)
 
        if (heart_memory_update_timer == NULL) {
                _D("logging memory update timer start");
-               heart_memory_update_timer = ecore_timer_add(TEN_MINUTE, heart_memory_notify, (void *)NULL);
+               heart_memory_update_timer = g_timeout_source_new_seconds(TEN_MINUTE);
+               g_source_set_callback(heart_memory_update_timer, heart_memory_notify, NULL, NULL);
+               g_source_attach(heart_memory_update_timer, NULL);
        }
 
        decision_memory_init(data);
@@ -1472,7 +1473,7 @@ static int heart_memory_exit(void *data)
        int ret;
 
        /* update timer delete */
-       ecore_timer_del(heart_memory_update_timer);
+       g_source_destroy(heart_memory_update_timer);
        heart_memory_update_timer = NULL;
 
        unregister_notifier(RESOURCED_NOTIFIER_SERVICE_LAUNCH, heart_memory_state_cb);
index 803ea1f..0d37c0d 100644 (file)
@@ -29,7 +29,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <glib.h>
-#include <Ecore.h>
 #include <stdbool.h>
 #include <time.h>
 
@@ -41,7 +40,7 @@
 #include "heart.h"
 #include "logging.h"
 #include "heart-common.h"
-#include "edbus-handler.h"
+#include "dbus-handler.h"
 
 #include <sqlite3.h>
 
@@ -53,7 +52,7 @@ static pthread_mutex_t heart_storage_verifying_mutex = PTHREAD_MUTEX_INITIALIZER
 static pthread_t heart_storage_verifying_thread = 0;
 static GQueue *queue = NULL;
 
-static DBusMessage *edbus_insert_log(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_insert_log(DBusMessage *msg)
 {
        int ret;
        int pid;
@@ -174,7 +173,7 @@ void heart_storage_verifying_thread_create(const char *data)
        pthread_mutex_unlock(&heart_storage_verifying_mutex);
 }
 
-static DBusMessage *edbus_verify_log(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_verify_log(DBusMessage *msg)
 {
        int ret;
        char *pkgid = NULL;
@@ -192,9 +191,9 @@ static DBusMessage *edbus_verify_log(E_DBus_Object *obj, DBusMessage *msg)
        return reply;
 }
 
-static const struct edbus_method edbus_methods[] = {
-       { "Insert", "ss", NULL, edbus_insert_log },
-       { "Verify", "s", NULL, edbus_verify_log }
+static struct d_bus_method dbus_methods[] = {
+       { "Insert", "ss", NULL, dbus_insert_log },
+       { "Verify", "s", NULL, dbus_verify_log }
 };
 
 static bool is_storage_logging(void)
@@ -245,7 +244,7 @@ static int heart_storage_init(void *data)
                return RESOURCED_ERROR_FAIL;
        }
 
-       ret = edbus_add_methods(RESOURCED_PATH_LOGGING, edbus_methods, ARRAY_SIZE(edbus_methods));
+       ret = d_bus_register_methods(RESOURCED_PATH_LOGGING, dbus_methods, ARRAY_SIZE(dbus_methods));
        if (ret != RESOURCED_ERROR_NONE)
                _E("DBus method registration for %s is failed", RESOURCED_PATH_LOGGING);
 
index 9507f1c..72933b5 100644 (file)
@@ -37,7 +37,7 @@
 #include "logging.h"
 #include "resourced.h"
 #include "config-parser.h"
-#include "edbus-handler.h"
+#include "dbus-handler.h"
 
 static GSList *heart_module;  /* module list */
 
@@ -119,7 +119,7 @@ static int heart_load_config(struct parse_result *result, void *user_data)
        return RESOURCED_ERROR_NONE;
 }
 
-static DBusMessage *edbus_update_data_list(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_update_data_list(DBusMessage *msg)
 {
        int ret;
        DBusMessage *reply = NULL;
@@ -140,7 +140,7 @@ static DBusMessage *edbus_update_data_list(E_DBus_Object *obj, DBusMessage *msg)
        return reply;
 }
 
-static DBusMessage *edbus_flush_cache(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_flush_cache(DBusMessage *msg)
 {
        int ret;
        DBusMessage *reply = NULL;
@@ -157,9 +157,9 @@ static DBusMessage *edbus_flush_cache(E_DBus_Object *obj, DBusMessage *msg)
        return reply;
 }
 
-static const struct edbus_method edbus_methods[] = {
-       { "UpdateDataList", NULL, NULL, edbus_update_data_list },
-       { "Flush", NULL, NULL, edbus_flush_cache }
+static struct d_bus_method dbus_methods[] = {
+       { "UpdateDataList", NULL, NULL, dbus_update_data_list },
+       { "Flush", NULL, NULL, dbus_flush_cache }
 };
 
 static int resourced_heart_init(void *data)
@@ -173,7 +173,7 @@ static int resourced_heart_init(void *data)
                return RESOURCED_ERROR_NONE;
        }
 
-       ret = edbus_add_methods(RESOURCED_PATH_LOGGING, edbus_methods, ARRAY_SIZE(edbus_methods));
+       ret = d_bus_register_methods(RESOURCED_PATH_LOGGING, dbus_methods, ARRAY_SIZE(dbus_methods));
        if (ret != RESOURCED_ERROR_NONE)
                _E("DBus method registration for %s is failed", RESOURCED_PATH_LOGGING);
 
index 80f5780..236ea30 100644 (file)
@@ -29,7 +29,7 @@
 #include <time.h>
 #include <sqlite3.h>
 #include "const.h"
-#include "edbus-handler.h"
+#include "dbus-handler.h"
 
 #ifndef CLOCK_BOOTTIME
 #define CLOCK_BOOTTIME                          7
index 13de89f..0758211 100644 (file)
@@ -26,7 +26,6 @@
  */
 
 #include <leveldb/c.h>
-#include <Ecore.h>
 #include <unistd.h>
 #include <pthread.h>
 #include <glib.h>
@@ -51,6 +50,7 @@
 #include "config-parser.h"
 #include "notifier.h"
 #include "userinfo-list.h"
+#include "fd-handler.h"
 
 #define LOGGING_BUF_MAX                        1024
 #define LOGGING_PTIORITY               20
@@ -125,7 +125,7 @@ static pthread_t logging_sync_thread = 0;
 static pthread_t logging_update_thread = 0;
 static pthread_mutex_t logging_update_mutex = PTHREAD_MUTEX_INITIALIZER;
 static pthread_cond_t logging_update_cond = PTHREAD_COND_INITIALIZER;
-static Ecore_Timer *logging_update_timer = NULL;
+static GSource *logging_update_timer = NULL;
 
 static GArray *logging_modules;
 static GHashTable *system_default_db = NULL;
@@ -137,7 +137,7 @@ static leveldb_writeoptions_t *woptions;
 
 static struct logging_object *logging_instance = NULL;
 
-Ecore_Fd_Handler *sync_efd;
+static fd_handler_h sync_fd;
 static DBusMessage *sync_reply;
 static int sync_pipes[2] = {-1, -1};
 
@@ -1394,38 +1394,25 @@ void logging_save_to_storage(int force)
        }
 }
 
-static Eina_Bool logging_sync_reply(void *arg, Ecore_Fd_Handler *fd_handler)
+static bool logging_sync_reply(int pipe_fd, void *arg)
 {
-       int pipe_fd;
        int ret = -1;
        DBusMessageIter iter;
 
-       if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) {
-               _E("ecore_main_fd_handler_active_get failed");
-               goto reply;
-       }
-
-       pipe_fd = ecore_main_fd_handler_fd_get(fd_handler);
-       if (pipe_fd < 0) {
-               _E("ecore_main_fd_handler_fd_get failed");
-               goto reply;
-       }
-
        if (read(pipe_fd, &ret, sizeof(ret)) != sizeof(ret)) {
                _E("Failed to read the return value of sync thread");
                ret = -1;
        }
 
-reply:
        dbus_message_iter_init_append(sync_reply, &iter);
        dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
 
-       if (dbus_message_reply(sync_reply) != RESOURCED_ERROR_NONE)
+       if (d_bus_reply_message(sync_reply) != RESOURCED_ERROR_NONE)
                _E("Failed to reply sync request");
 
        dbus_message_unref(sync_reply);
 
-       return ECORE_CALLBACK_RENEW;
+       return true;
 }
 
 static void *logging_sync_thread_main(void *arg)
@@ -1527,7 +1514,7 @@ static void *logging_update_thread_main(void *arg)
        return NULL;
 }
 
-static Eina_Bool logging_send_signal_to_update(void *data)
+static gboolean logging_send_signal_to_update(gpointer data)
 {
        int ret;
        DIR *dir_info;
@@ -1544,14 +1531,14 @@ static Eina_Bool logging_send_signal_to_update(void *data)
                ret = mkdir(LOGGING_FILE_PATH, S_IRWXU | S_IRWXG | S_IROTH);
                if (ret) {
                        _E("mkdir failed %s", LOGGING_FILE_PATH);
-                       return ECORE_CALLBACK_RENEW;
+                       return true;
                }
        }
 
        user_list = userinfo_get_list();
        if (!user_list) {
                _E("Fail to get user table");
-               return ECORE_CALLBACK_RENEW;
+               return true;
        }
 
        userinfo_for_each(elem, user_list) {
@@ -1566,7 +1553,7 @@ static Eina_Bool logging_send_signal_to_update(void *data)
 
                        if (ret) {
                                _E("mkdir failed %s", path);
-                               return ECORE_CALLBACK_RENEW;
+                               return true;
                        }
                }
        }
@@ -1589,7 +1576,7 @@ static Eina_Bool logging_send_signal_to_update(void *data)
                pthread_mutex_unlock(&logging_update_mutex);
        }
 
-       return ECORE_CALLBACK_RENEW;
+       return true;
 }
 
 static int logging_thread_create(void)
@@ -1616,11 +1603,11 @@ static int logging_thread_create(void)
 static void logging_thread_stop(void)
 {
        /* Delete timer invoking update function */
-       ecore_timer_del(logging_update_timer);
+       g_source_destroy(logging_update_timer);
        logging_update_timer = NULL;
 
        /* Delete fd handler for sync thread */
-       ecore_main_fd_handler_del(sync_efd);
+       remove_fd_read_handler(&sync_fd);
 
        /* Wait thread for working
         *
@@ -1720,9 +1707,9 @@ int logging_init(void *data)
                _E("Failed to create pipe");
                return RESOURCED_ERROR_FAIL;
        }
-       sync_efd = ecore_main_fd_handler_add(sync_pipes[0], ECORE_FD_READ,
-                       (Ecore_Fd_Cb)logging_sync_reply, NULL, NULL, NULL);
-       if (!sync_efd) {
+
+       ret = add_fd_read_handler(sync_pipes[0], logging_sync_reply, NULL, NULL, &sync_fd);
+       if (ret < 0) {
                _E("Failed to add pipe handler");
                return RESOURCED_ERROR_FAIL;
        }
@@ -1733,8 +1720,9 @@ int logging_init(void *data)
 
        if (logging_update_timer == NULL) {
                _D("logging data timer start");
-               logging_update_timer =
-                       ecore_timer_add(ONE_MINUTE, logging_send_signal_to_update, (void *)NULL);
+               logging_update_timer = g_timeout_source_new_seconds(ONE_MINUTE);
+               g_source_set_callback(logging_update_timer, logging_send_signal_to_update, NULL, NULL);
+               g_source_attach(logging_update_timer, NULL);
        }
 
        return RESOURCED_ERROR_NONE;
index 8a73ff9..ad5e5be 100644 (file)
  *
  */
 
-#include <Ecore.h>
-
 #include "trace.h"
 #include "lowmem-handler.h"
-#include "edbus-handler.h"
+#include "dbus-handler.h"
 #include "resourced.h"
 #include "macro.h"
 #include "memory-common.h"
@@ -155,7 +153,7 @@ static void lowmem_dbus_set_platform(void *data, DBusMessage *msg)
        lowmem_trigger_swap(pid, MEMCG_SWAP);
 }
 
-static const struct edbus_signal edbus_signals[] = {
+static const struct d_bus_signal dbus_signals[] = {
        /* RESOURCED DBUS */
        {RESOURCED_PATH_OOM, RESOURCED_INTERFACE_OOM,
            SIGNAL_OOM_SET_THRESHOLD, lowmem_dbus_oom_set_threshold, NULL},
@@ -172,5 +170,5 @@ static const struct edbus_signal edbus_signals[] = {
 
 void lowmem_dbus_init(void)
 {
-       edbus_add_signals(edbus_signals, ARRAY_SIZE(edbus_signals));
+       d_bus_register_signals(dbus_signals, ARRAY_SIZE(dbus_signals));
 }
index 2e04fda..8a307d3 100644 (file)
@@ -39,7 +39,6 @@
 #include <sys/stat.h>
 #include <sys/shm.h>
 #include <sys/sysinfo.h>
-#include <Ecore.h>
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <ctype.h>
@@ -62,8 +61,9 @@
 #include "memory-common.h"
 #include "heart-common.h"
 #include "proc-main.h"
-#include "edbus-handler.h"
+#include "dbus-handler.h"
 #include "util.h"
+#include "fd-handler.h"
 
 #define LOWMEM_NO_LIMIT                        0
 #define LOWMEM_THRES_INIT              0
@@ -1793,24 +1793,13 @@ static void lowmem_press_cgroup_handler(enum lmk_type type, struct memcg_info *m
                                BYTE_TO_MBYTE(threshold));
 }
 
-static Eina_Bool lowmem_press_eventfd_handler(void *data,
-               Ecore_Fd_Handler *fd_handler)
+static bool lowmem_press_eventfd_handler(int fd, void *data)
 {
-       int fd, i;
+       int i;
        struct memcg_info *mi;
        GSList *iter = NULL;
        enum lmk_type lmk_type = LMK_MEMORY;
 
-       if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) {
-               _E("ecore_main_fd_handler_active_get error , return\n");
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       fd = ecore_main_fd_handler_fd_get(fd_handler);
-       if (fd < 0) {
-               _E("ecore_main_fd_handler_fd_get error , return\n");
-               return ECORE_CALLBACK_CANCEL;
-       }
        lowmem_press_eventfd_read(fd);
 
        for (i = 0; i < MEMCG_MAX; i++) {
@@ -1828,7 +1817,7 @@ static Eina_Bool lowmem_press_eventfd_handler(void *data,
                                        lmk_type = LMK_INACTIVE;
                                lowmem_press_cgroup_handler(lmk_type, mi);
                        }
-                       return ECORE_CALLBACK_RENEW;
+                       return true;
                }
                /* ToDo: iterate child memcgs */
                gslist_for_each_item(iter, memcg_tree[i]->cgroups)
@@ -1842,18 +1831,19 @@ static Eina_Bool lowmem_press_eventfd_handler(void *data,
                                lowmem_press_cgroup_handler(lmk_type, mi);
                                _D("lowmem cgroup handler is called for %s",
                                                mi->name);
-                               return ECORE_CALLBACK_RENEW;
+                               return true;
                        }
                }
        }
 
-       return ECORE_CALLBACK_RENEW;
+       return true;
 }
 
 static void lowmem_press_register_eventfd(struct memcg_info *mi)
 {
        int evfd;
        const char *name = mi->name;
+       static fd_handler_h handler;
 
        if (mi->threshold[LOWMEM_MEDIUM] == LOWMEM_THRES_INIT)
                return;
@@ -1869,9 +1859,7 @@ static void lowmem_press_register_eventfd(struct memcg_info *mi)
        mi->evfd = evfd;
 
        _I("register event fd success for %s cgroup", name);
-       ecore_main_fd_handler_add(evfd, ECORE_FD_READ,
-                       (Ecore_Fd_Cb)lowmem_press_eventfd_handler, NULL, NULL,
-                       NULL);
+       add_fd_read_handler(evfd, lowmem_press_eventfd_handler, NULL, NULL, &handler);
        return;
 }
 
index 736c7e6..9a33fb3 100644 (file)
@@ -28,6 +28,7 @@
 #include <unistd.h>
 #include <glib.h>
 #include <string.h>
+#include <stdint.h>
 
 #include "proc-common.h"
 #include "resourced.h"
index 898ee44..5edb889 100644 (file)
@@ -28,9 +28,9 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <resourced.h>
-#include <E_DBus.h>
 #include <pthread.h>
 #include <time.h>
+#include <dbus/dbus.h>
 
 #define INVALID_PROCESS_INFO_FIELD_VALUE -1
 
index f9adbfb..a7b5e29 100644 (file)
@@ -25,7 +25,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <glib.h>
-#include <Ecore.h>
 
 #include "resourced.h"
 #include "logging.h"
 static int favorite_count;
 static GHashTable *appusage_favorite_htab;
 
-#ifdef HEART_SUPPORT
-static Ecore_Timer *appusage_update_timer;
-#endif
-
 static void free_key(gpointer data)
 {
        if (data)
@@ -71,13 +66,13 @@ static void print_favorite_list(gpointer key, gpointer value, gpointer user_data
 }
 
 #ifdef HEART_SUPPORT
-static Eina_Bool appusage_update_cb(void *data)
+static gboolean appusage_update_cb(gpointer data)
 {
        GHashTable *apps_htab = (GHashTable *)data;
        int ret;
 
        if (!data)
-               return ECORE_CALLBACK_CANCEL;
+               return false;
 
        ret = heart_cpu_get_appusage_list(UID_FOR_OWNER, apps_htab, favorite_count);
        if (!ret) {
@@ -85,7 +80,7 @@ static Eina_Bool appusage_update_cb(void *data)
                g_hash_table_foreach(apps_htab, print_favorite_list, NULL);
        }
 
-       return ECORE_CALLBACK_RENEW;
+       return true;
 }
 #endif
 
@@ -143,8 +138,7 @@ static int booting_done(void *data)
                return RESOURCED_ERROR_NO_DATA;
 
 #ifdef HEART_SUPPORT
-       appusage_update_timer = ecore_timer_add(UPDATE_INTERVAL,
-                       appusage_update_cb, (void *)appusage_favorite_htab);
+       g_timeout_add_seconds(UPDATE_INTERVAL, appusage_update_cb, (gpointer)appusage_favorite_htab);
 #endif
 
        return RESOURCED_ERROR_NONE;
index 7b7022e..e203d45 100644 (file)
@@ -25,7 +25,7 @@
  */
 
 #include "trace.h"
-#include "edbus-handler.h"
+#include "dbus-handler.h"
 
 #define SIGNAL_NAME_OOMADJ_SET         "OomadjSet"
 
@@ -38,7 +38,7 @@ void dbus_proc_handler(char *type, char *buf)
        pa[1] = "1";
        pa[2] = buf;
 
-       ret = broadcast_edbus_signal_str(DEVICED_PATH_PROCESS, DEVICED_INTERFACE_PROCESS,
+       ret = d_bus_broadcast_signal_str(DEVICED_PATH_PROCESS, DEVICED_INTERFACE_PROCESS,
                        SIGNAL_NAME_OOMADJ_SET, "sis", pa);
        if (ret < 0)
                _E("Fail to send dbus signal to deviced!!");
index 1c1fb55..cd82668 100644 (file)
@@ -28,7 +28,6 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
-#include <Ecore.h>
 #include <glib-object.h>
 #include <gio/gio.h>
 #include <pthread.h>
index 6409360..12e67f3 100755 (executable)
@@ -27,8 +27,6 @@
 
 #include <sys/types.h>
 #include <unistd.h>
-#include <Ecore.h>
-#include <E_DBus.h>
 #include <sys/mount.h>
 
 #include "proc-main.h"
@@ -36,8 +34,9 @@
 #include "resourced.h"
 #include "macro.h"
 #include "trace.h"
-#include "edbus-handler.h"
+#include "dbus-handler.h"
 #include "proc-process.h"
+#include "proc-usage-stats-helper.h"
 #include "procfs.h"
 #include "lowmem-handler.h"
 #include "notifier.h"
@@ -59,7 +58,7 @@
 static int proc_watchdog_state;
 static int current_lcd_state;
 
-static Ecore_Timer *watchdog_check_timer;
+static GSource *watchdog_check_timer;
 #define WATCHDOG_TIMER_INTERVAL                10
 
 static struct proc_watchdog_info {
@@ -85,7 +84,7 @@ static int proc_get_watchdog_state(void)
        return proc_watchdog_state;
 }
 
-static DBusMessage *edbus_get_meminfo(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_get_meminfo(DBusMessage *msg)
 {
        unsigned int mem_total, mem_free, mem_available, cached, used;
        unsigned int swap_total, swap_free, swap;
@@ -131,7 +130,7 @@ static DBusMessage *edbus_get_meminfo(E_DBus_Object *obj, DBusMessage *msg)
        return reply;
 }
 
-static DBusMessage *edbus_reclaim_memory(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_reclaim_memory(DBusMessage *msg)
 {
        DBusMessageIter iter;
        DBusMessage *reply;
@@ -148,7 +147,7 @@ static DBusMessage *edbus_reclaim_memory(E_DBus_Object *obj, DBusMessage *msg)
        return reply;
 }
 
-static DBusMessage *edbus_pre_poweroff(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_pre_poweroff(DBusMessage *msg)
 {
        DBusMessageIter iter;
        DBusMessage *reply;
@@ -198,7 +197,7 @@ static void proc_dbus_active_signal_handler(void *data, DBusMessage *msg)
        resourced_proc_status_change(type, pid, NULL, NULL, PROC_TYPE_NONE);
 }
 
-static DBusMessage *edbus_get_app_cpu(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_get_app_cpu(DBusMessage *msg)
 {
        int ret;
        DBusMessageIter iter;
@@ -237,7 +236,7 @@ static DBusMessage *edbus_get_app_cpu(E_DBus_Object *obj, DBusMessage *msg)
        return reply;
 }
 
-static DBusMessage *edbus_get_app_memory(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_get_app_memory(DBusMessage *msg)
 {
        int ret;
        DBusMessageIter iter;
@@ -276,7 +275,7 @@ static DBusMessage *edbus_get_app_memory(E_DBus_Object *obj, DBusMessage *msg)
        return reply;
 }
 
-static DBusMessage *edbus_get_memory_list(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_get_memory_list(DBusMessage *msg)
 {
        _cleanup_app_list_close_ GSList *proc_app_list = PAL_INIT_VALUE;
        DBusMessageIter iter;
@@ -310,7 +309,7 @@ static DBusMessage *edbus_get_memory_list(E_DBus_Object *obj, DBusMessage *msg)
        return reply;
 }
 
-static DBusMessage *edbus_get_cpu_list(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_get_cpu_list(DBusMessage *msg)
 {
        _cleanup_app_list_close_ GSList *proc_app_list = PAL_INIT_VALUE;
        DBusMessageIter iter;
@@ -352,7 +351,7 @@ static DBusMessage *edbus_get_cpu_list(E_DBus_Object *obj, DBusMessage *msg)
        return reply;
 }
 
-static DBusMessage *edbus_get_memory_lists(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_get_memory_lists(DBusMessage *msg)
 {
        _cleanup_app_list_close_ GSList *proc_app_list = PAL_INIT_VALUE;
        DBusMessageIter iter;
@@ -396,7 +395,7 @@ static DBusMessage *edbus_get_memory_lists(E_DBus_Object *obj, DBusMessage *msg)
        return reply;
 }
 
-static DBusMessage *edbus_get_cpu_lists(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_get_cpu_lists(DBusMessage *msg)
 {
        _cleanup_app_list_close_ GSList *proc_app_list = PAL_INIT_VALUE;
        DBusMessageIter iter;
@@ -613,7 +612,7 @@ static void proc_dbus_sweep_signal_handler(void *data, DBusMessage *msg)
        proc_sweep_memory(PROC_SWEEP_INCLUDE_ACTIVE, INIT_PID);
 }
 
-static Eina_Bool check_watchdog_cb(void *data)
+static gboolean check_watchdog_cb(gpointer data)
 {
        int oom_score_adj = 0, ret;
        pid_t pid = proc_watchdog.pid;
@@ -623,11 +622,11 @@ static Eina_Bool check_watchdog_cb(void *data)
                _E("watchdog pid %d not terminated, kill again\n", pid);
                kill(pid, SIGKILL);
        }
-       ecore_timer_del(watchdog_check_timer);
        watchdog_check_timer = NULL;
        proc_watchdog.pid = -1;
        proc_watchdog.signum = -1;
-       return ECORE_CALLBACK_CANCEL;
+
+       return false;
 }
 
 static void proc_dbus_watchdog_result(void *data, DBusMessage *msg)
@@ -653,9 +652,10 @@ static void proc_dbus_watchdog_result(void *data, DBusMessage *msg)
                        resourced_proc_status_change(PROC_CGROUP_SET_TERMINATE_REQUEST,
                                    proc_watchdog.pid, NULL, NULL, PROC_TYPE_NONE);
                        kill(proc_watchdog.pid, SIGABRT);
-                       if (watchdog_check_timer == NULL) {
-                               watchdog_check_timer =
-                                       ecore_timer_add(WATCHDOG_TIMER_INTERVAL, check_watchdog_cb, (void *)NULL);
+                       if (!watchdog_check_timer) {
+                               watchdog_check_timer = g_timeout_source_new_seconds(WATCHDOG_TIMER_INTERVAL);
+                               g_source_set_callback(watchdog_check_timer, check_watchdog_cb, NULL, NULL);
+                               g_source_attach(watchdog_check_timer, NULL);
                        }
                } else {
                        _E("ERROR: Unsupported signal type!");
@@ -741,10 +741,11 @@ static void proc_dbus_watchdog_handler(void *data, DBusMessage *msg)
        resourced_proc_status_change(PROC_CGROUP_SET_TERMINATE_REQUEST,
                    pid, NULL, NULL, PROC_TYPE_NONE);
        kill(pid, SIGABRT);
-       if (watchdog_check_timer == NULL) {
-               watchdog_check_timer =
-                       ecore_timer_add(WATCHDOG_TIMER_INTERVAL,
-                           check_watchdog_cb, (void *)NULL);
+       if (!watchdog_check_timer) {
+               watchdog_check_timer = g_timeout_source_new_seconds(WATCHDOG_TIMER_INTERVAL);
+               g_source_set_callback(watchdog_check_timer, check_watchdog_cb, NULL, NULL);
+               g_source_attach(watchdog_check_timer, NULL);
+
                proc_watchdog.pid = pid;
                proc_watchdog.signum = command;
        }
@@ -754,7 +755,7 @@ static void send_dump_signal(char *signal)
 {
        pid_t pid = getpid();
 
-       broadcast_edbus_signal(DUMP_SERVICE_OBJECT_PATH,
+       d_bus_broadcast_signal(DUMP_SERVICE_OBJECT_PATH,
            DUMP_SERVICE_INTERFACE_NAME, signal, DBUS_TYPE_INT32, &pid);
 }
 
@@ -809,7 +810,7 @@ static void proc_dbus_systemservice_handler(void *data, DBusMessage *msg)
                    NULL, NULL, PROC_TYPE_NONE);
 }
 
-static DBusMessage *edbus_signal_trigger(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_signal_trigger(DBusMessage *msg)
 {
        DBusMessage *reply;
        dbus_bool_t ret;
@@ -1184,21 +1185,21 @@ static void proc_dbus_suspend_hint(void *data, DBusMessage *msg)
        }
 }
 
-static const struct edbus_method edbus_methods[] = {
-       { "Signal", "ii", NULL, edbus_signal_trigger },
-       { "GetAppCpu", "s", "u", edbus_get_app_cpu },
-       { "GetCpuList", NULL, "a(su)", edbus_get_cpu_list },
-       { "GetCpuLists", "i", "a(su)", edbus_get_cpu_lists },
-       { "GetAppMemory", "s", "u", edbus_get_app_memory },
-       { "GetMemoryList", NULL, "a(su)", edbus_get_memory_list },
-       { "GetMemoryLists", "i", "a(su)", edbus_get_memory_lists },
-       { "GetMemInfo", NULL, "uuuuu", edbus_get_meminfo },
-       { "ReclaimMemory", NULL, NULL, edbus_reclaim_memory },
-       { "PrePoweroff", NULL, NULL, edbus_pre_poweroff },
+static struct d_bus_method dbus_methods[] = {
+       { "Signal", "ii", NULL, dbus_signal_trigger },
+       { "GetAppCpu", "s", "u", dbus_get_app_cpu },
+       { "GetCpuList", NULL, "a(su)", dbus_get_cpu_list },
+       { "GetCpuLists", "i", "a(su)", dbus_get_cpu_lists },
+       { "GetAppMemory", "s", "u", dbus_get_app_memory },
+       { "GetMemoryList", NULL, "a(su)", dbus_get_memory_list },
+       { "GetMemoryLists", "i", "a(su)", dbus_get_memory_lists },
+       { "GetMemInfo", NULL, "uuuuu", dbus_get_meminfo },
+       { "ReclaimMemory", NULL, NULL, dbus_reclaim_memory },
+       { "PrePoweroff", NULL, NULL, dbus_pre_poweroff },
        /* Add methods here */
 };
 
-static const struct edbus_signal edbus_signals[] = {
+static const struct d_bus_signal dbus_signals[] = {
        /* RESOURCED DBUS */
        {RESOURCED_PATH_PROCESS, RESOURCED_INTERFACE_PROCESS,
            SIGNAL_PROC_WATCHDOG_RESULT, proc_dbus_watchdog_result, NULL},
@@ -1256,20 +1257,21 @@ static const struct edbus_signal edbus_signals[] = {
 
 static int proc_dbus_init(void *data)
 {
-       edbus_add_signals(edbus_signals, ARRAY_SIZE(edbus_signals));
+       d_bus_register_signals(dbus_signals, ARRAY_SIZE(dbus_signals));
 
        /* start watchdog check timer for preveting ANR during booting */
-       watchdog_check_timer =
-               ecore_timer_add(WATCHDOG_TIMER_INTERVAL, check_watchdog_cb, (void *)NULL);
+       watchdog_check_timer = g_timeout_source_new_seconds(WATCHDOG_TIMER_INTERVAL);
+       g_source_set_callback(watchdog_check_timer, check_watchdog_cb, NULL, NULL);
+       g_source_attach(watchdog_check_timer, NULL);
 
-       return edbus_add_methods(RESOURCED_PATH_PROCESS, edbus_methods,
-                         ARRAY_SIZE(edbus_methods));
+       return d_bus_register_methods(RESOURCED_PATH_PROCESS, dbus_methods,
+                         ARRAY_SIZE(dbus_methods));
 }
 
 static int proc_dbus_exit(void *data)
 {
        if (watchdog_check_timer)
-               ecore_timer_del(watchdog_check_timer);
+               g_source_destroy(watchdog_check_timer);
        return RESOURCED_ERROR_NONE;
 }
 
index 5173403..31e71db 100644 (file)
@@ -25,7 +25,6 @@
 #include <unistd.h>
 #include <dirent.h>
 #include <sys/types.h>
-#include <Ecore.h>
 
 #include "freezer.h"
 #include "resourced.h"
@@ -41,7 +40,7 @@
 
 #define PROC_SWEEP_TIMER       3
 static GHashTable *proc_sweep_list;
-static Ecore_Timer *proc_sweep_timer;
+static GSource *proc_sweep_timer;
 
 enum proc_background_type {
        PROC_BACKGROUND_INACTIVE,
@@ -303,13 +302,14 @@ void proc_kill_victiom(gpointer key, gpointer value, gpointer user_data)
        fclose(fp);
 }
 
-static Eina_Bool proc_check_sweep_cb(void *data)
+static gboolean proc_check_sweep_cb(gpointer data)
 {
        GHashTable *List = (GHashTable *)data;
        g_hash_table_foreach(List, proc_kill_victiom, NULL);
        g_hash_table_destroy(List);
        proc_sweep_list = NULL;
-       return ECORE_CALLBACK_CANCEL;
+
+       return false;
 }
 
 int proc_sweep_memory(enum proc_sweep_type type, pid_t callpid)
@@ -328,7 +328,7 @@ int proc_sweep_memory(enum proc_sweep_type type, pid_t callpid)
        struct proc_app_info *pai;
 
        if (proc_sweep_timer)
-               ecore_timer_del(proc_sweep_timer);
+               g_source_destroy(proc_sweep_timer);
        if (proc_sweep_list)
                g_hash_table_destroy(proc_sweep_list);
        proc_sweep_list = g_hash_table_new(g_int_hash, g_int_equal);
@@ -374,9 +374,11 @@ int proc_sweep_memory(enum proc_sweep_type type, pid_t callpid)
                fclose(fp);
        }
        if (count > 0) {
-               proc_sweep_timer =
-                           ecore_timer_add(PROC_SWEEP_TIMER, proc_check_sweep_cb, (void *)proc_sweep_list);
+               proc_sweep_timer = g_timeout_source_new_seconds(PROC_SWEEP_TIMER);
+               g_source_set_callback(proc_sweep_timer, proc_check_sweep_cb, (gpointer)proc_sweep_list, NULL);
+               g_source_attach(proc_sweep_timer, NULL);
        }
+
        return count;
 }
 
index cad34e5..a176a8b 100644 (file)
@@ -29,7 +29,7 @@
  *     * The dbus method is called from runtime-info API
  *     * For each request, a runtime_info_task instance is created
  *     * This instance contains info related to that request
- *     * A pipe is created for each request and an ecore handler is added for the read end
+ *     * A pipe is created for each request and an glib fd handler is added for the read end
  *     * A thread is swapned for the request and this thread collects the needed info
  *     * After collection of the usage info, the thread writes the success status to the
  *             write end of the pipe
@@ -47,7 +47,6 @@
 
 #include <sys/types.h>
 #include <unistd.h>
-#include <Ecore.h>
 #include <errno.h>
 
 #include "proc-main.h"
 #include "resourced.h"
 #include "macro.h"
 #include "trace.h"
-#include "edbus-handler.h"
+#include "dbus-handler.h"
 #include "util.h"
-
-#define PROCESS_MEMORY_USAGE_METHOD "ProcMemoryUsage"
-#define PROCESS_CPU_USAGE_METHOD "ProcCpuUsage"
+#include "fd-handler.h"
 
 /**
  * @brief       DBus method to return the memory usage information of input processes
  * @since_tizen 2.4
  *
- * @param[in] obj       The E_DBus_Object
  * @param[in] msg       The dbus message sent by the runtime info API.
  *                     This should be an array of process IDs.
  *
  *                     are errors in computation, collection and sending of usage info, then the
  *                     response dbus message contains only an integer whose value will the error value.
  */
-static DBusMessage *edbus_proc_memory_usage(E_DBus_Object *obj, DBusMessage *msg);
+static DBusMessage *dbus_proc_memory_usage(DBusMessage *msg);
 
 /**
  * @brief       DBus method to return the cpu usage information of input processes
  * @since_tizen 2.4
  *
- * @param[in] obj       The E_DBus_Object
  * @param[in] msg       The dbus message sent by the runtime info API.
  *                     This should be an array of process IDs.
  *
@@ -97,29 +92,28 @@ static DBusMessage *edbus_proc_memory_usage(E_DBus_Object *obj, DBusMessage *msg
  *                     are errors in computation, collection and sending of usage info, then the
  *                     response dbus message contains only an integer whose value will the error value.
  */
-static DBusMessage *edbus_proc_cpu_usage(E_DBus_Object *obj, DBusMessage *msg);
+static DBusMessage *dbus_proc_cpu_usage(DBusMessage *msg);
 
-/* edbus_methods to register with edbus */
-static const struct edbus_method edbus_methods[] = {
-       { PROCESS_MEMORY_USAGE_METHOD, "ai", NULL, edbus_proc_memory_usage },
-       { PROCESS_CPU_USAGE_METHOD, "ai", NULL, edbus_proc_cpu_usage },
+/* dbus_methods to register with libdbus */
+static struct d_bus_method dbus_methods[] = {
+       { "ProcMemoryUsage", "ai", NULL, dbus_proc_memory_usage },
+       { "ProcCpuUsage", "ai", NULL, dbus_proc_cpu_usage },
 };
 
-/* Ecore file handler for the read end of the pipe.
+/* g file handler for the read end of the pipe.
  * Receives the error status from the runtime info task thread and collects
  * the usage info calculated and sends it in a dbus message or send an error dbus message back
  * with the error status added to the message
  */
-static Eina_Bool proc_runtime_info_task_cb(void *data, Ecore_Fd_Handler *fd_handler)
+static bool proc_runtime_info_task_cb(int fd, void *data)
 {
        int i, j, ret, rsize, struct_size;
-       int fd;
        int result[7];
        DBusMessage *reply;
        DBusMessageIter iter, iter_arr, iter_struct;
        struct runtime_info_task *rt_task;
 
-       /* In case of errors in ecore file hander, the returned dbus message
+       /* In case of errors in glib file hander, the returned dbus message
         * contains only a failure value */
        rt_task = (struct runtime_info_task *)data;
        if (!rt_task) {
@@ -127,17 +121,6 @@ static Eina_Bool proc_runtime_info_task_cb(void *data, Ecore_Fd_Handler *fd_hand
                goto error;
        }
 
-       if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) {
-               _E("task %s: ecore_main_fd_handler_active_get_error", rt_task->task_name);
-               goto error;
-       }
-
-       fd = ecore_main_fd_handler_fd_get(fd_handler);
-       if (fd < 0) {
-               _E("task %s: ecore_main_fd_handler_fd_get error", rt_task->task_name);
-               goto error;
-       }
-
        rsize = read(fd, &ret, sizeof(int));
        if (rsize != sizeof(int)) {
                _E("task %s: error reading value from read end of pipe", rt_task->task_name);
@@ -153,7 +136,7 @@ static Eina_Bool proc_runtime_info_task_cb(void *data, Ecore_Fd_Handler *fd_hand
        reply = dbus_message_new_method_return(rt_task->task_msg);
        if (!reply) {
                _E("task %s: out of memory to allocate for reply dbus message. not attempting again!!!", rt_task->task_name);
-               return ECORE_CALLBACK_CANCEL;
+               return false;
        }
        dbus_message_iter_init_append(reply, &iter);
        if (rt_task->task_type == RUNTIME_INFO_TASK_MEMORY) {
@@ -186,7 +169,7 @@ static Eina_Bool proc_runtime_info_task_cb(void *data, Ecore_Fd_Handler *fd_hand
 error:
        /* In case of error, return only a failure value in the reply dbus message */
        if (!rt_task)
-               return ECORE_CALLBACK_CANCEL;
+               return false;
 
        _D("task %s: error occured in collection of usage info, sending error message", rt_task->task_name);
 
@@ -198,13 +181,13 @@ error:
 send_message:
        /* Send the reply message back to the caller. Best effort feature. */
        _D("task %s: sending reply dbus message", rt_task->task_name);
-       ret = dbus_message_reply(reply);
+       ret = d_bus_reply_message(reply);
        if (ret != RESOURCED_ERROR_NONE)
                _E("task %s: sending message failed. not attempting again!!!", rt_task->task_name);
 
        proc_free_runtime_info_task(rt_task);
        dbus_message_unref(reply);
-       return ECORE_CALLBACK_CANCEL;
+       return false;
 }
 
 static int proc_runtime_info_task(struct runtime_info_task *rt_task)
@@ -262,7 +245,7 @@ static void *proc_runtime_info_task_thread(void *arg)
        return NULL;
 }
 
-static DBusMessage *proc_runtime_info_request_handler(DBusMessage *msg, runtime_info_task_type type)
+DBusMessage *proc_runtime_info_request_handler(DBusMessage *msg, runtime_info_task_type type)
 {
        int ret;
        pthread_t task_thread;
@@ -271,7 +254,7 @@ static DBusMessage *proc_runtime_info_request_handler(DBusMessage *msg, runtime_
        DBusMessageIter iter;
        _cleanup_dbus_error_free_ DBusError err = DBUS_ERROR_INIT;
        dbus_bool_t bret;
-       Ecore_Fd_Handler *task_efd;
+       static fd_handler_h fd_handler;
 
        rt_task = NULL;
 
@@ -328,17 +311,17 @@ static DBusMessage *proc_runtime_info_request_handler(DBusMessage *msg, runtime_
                goto error;
        }
 
-       /* Create pipe between main loop and (to-be-created) task thread and add ecore file handler for the read end */
+       /* Create pipe between main loop and (to-be-created) task thread and add glib file handler for the read end */
        ret = pipe(rt_task->pipe_fds);
        if (ret) {
                _E("task %s: error creating pipe.", rt_task->task_name);
                ret = -EIO;
                goto error;
        }
-       task_efd = ecore_main_fd_handler_add(rt_task->pipe_fds[0], ECORE_FD_READ,
-                       (Ecore_Fd_Cb)proc_runtime_info_task_cb, (void *)rt_task, NULL, NULL);
-       if (!task_efd) {
-               _E("task %s: error creating ecore file handler", rt_task->task_name);
+       ret = add_fd_read_handler(rt_task->pipe_fds[0], proc_runtime_info_task_cb,
+                       (void *)rt_task, NULL, &fd_handler);
+       if (ret) {
+               _E("task %s: error creating glib file handler", rt_task->task_name);
                ret = -EREMOTEIO;
                goto error;
        }
@@ -366,19 +349,19 @@ error:
        return reply;
 }
 
-static DBusMessage *edbus_proc_memory_usage(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_proc_memory_usage(DBusMessage *msg)
 {
        return proc_runtime_info_request_handler(msg, RUNTIME_INFO_TASK_MEMORY);
 }
 
-static DBusMessage *edbus_proc_cpu_usage(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_proc_cpu_usage(DBusMessage *msg)
 {
        return proc_runtime_info_request_handler(msg, RUNTIME_INFO_TASK_CPU);
 }
 
 static int proc_usage_stats_init(void *data)
 {
-       edbus_add_methods(RESOURCED_PATH_PROCESS, edbus_methods, ARRAY_SIZE(edbus_methods));
+       d_bus_register_methods(RESOURCED_PATH_PROCESS, dbus_methods, ARRAY_SIZE(dbus_methods));
        return RESOURCED_ERROR_NONE;
 }
 
index 93ffe46..c23d72a 100644 (file)
@@ -24,7 +24,7 @@
  **/
 
 #include "const.h"
-#include "edbus-handler.h"
+#include "dbus-handler.h"
 #include "cgroup.h"
 #include "init.h"
 #include "macro.h"
 #include "version.h"
 #include "file-helper.h"
 
-#include <Ecore.h>
+#include <glib.h>
 #include <getopt.h>
 #include <signal.h>
+#include <sys/stat.h>
+#include <sys/types.h>
 
 static int restarted = false;
 
@@ -104,10 +106,24 @@ static void add_signal_handler(void)
        signal(SIGINT, sig_term_handler);
 }
 
-static Eina_Bool quit_main_loop(void *user_data)
+GMainLoop *get_main_loop(void)
 {
-       ecore_main_loop_quit();
-       return ECORE_CALLBACK_CANCEL;
+       static GMainLoop *mainloop;
+
+       if (!mainloop)
+               mainloop = g_main_loop_new(NULL, false);
+
+       return mainloop;
+}
+
+static gboolean quit_main_loop(gpointer user_data)
+{
+       GMainLoop *mainloop = get_main_loop();
+
+       if (mainloop)
+               g_main_loop_quit(mainloop);
+
+       return FALSE;
 }
 
 int resourced_init(struct daemon_arg *darg)
@@ -123,9 +139,8 @@ int resourced_init(struct daemon_arg *darg)
        if (ret < 0)
                return ret;
 
-       ecore_init();
        add_signal_handler();
-       edbus_init();
+       d_bus_init();
 
        ret = modules_add_methods();
        if (ret < 0) {
@@ -133,18 +148,17 @@ int resourced_init(struct daemon_arg *darg)
                return ret;
        }
 
-       /* we couldn't create timer in signal callback, due ecore_timer_add
-        * alocates memory */
-       darg->ecore_quit = ecore_timer_add(TIME_TO_SAFE_DATA, quit_main_loop, NULL);
-       ecore_timer_freeze(darg->ecore_quit);
+       /* we couldn't create timer in signal callback,
+        * due g_timeout_source_new_seconds allocates memory */
+       darg->mainloop_quit = g_timeout_source_new_seconds(TIME_TO_SAFE_DATA);
+       g_source_set_callback(darg->mainloop_quit, quit_main_loop, NULL, NULL);
 
        return RESOURCED_ERROR_NONE;
 }
 
 int resourced_deinit(void)
 {
-       ecore_shutdown();
-       edbus_exit();
+       d_bus_exit();
        return RESOURCED_ERROR_NONE;
 }
 
@@ -158,7 +172,6 @@ void resourced_quit_mainloop(void)
 
        struct shared_modules_data *shared_data = get_shared_modules_data();
 
-       ecore_timer_thaw(shared_data->darg->ecore_quit);
+       g_source_attach(shared_data->darg->mainloop_quit, NULL);
 }
 
-
index feaaa4d..b5b40eb 100644 (file)
 #ifndef _RESOURCED_INIT_H
 #define _RESOURCED_INIT_H
 
-#include <Ecore.h>
+#include <glib.h>
 
 #include "resourced.h"
 
 struct daemon_arg {
        int argc;
        char **argv;
-       Ecore_Timer *ecore_quit;
+       GSource *mainloop_quit;
 };
 
 int resourced_restarted(void);
@@ -43,6 +43,8 @@ int resourced_init(struct daemon_arg *darg);
 
 int resourced_deinit(void);
 
+GMainLoop *get_main_loop(void);
+
 void resourced_quit_mainloop(void);
 
 struct counter_arg;
index 5ce5f4f..2a74545 100644 (file)
 #include "proc-monitor.h"
 #include "trace.h"
 #include "version.h"
-#include "edbus-handler.h"
 #include "notifier.h"
 
-#include <Ecore.h>
+#include <glib.h>
 #include <mcheck.h>
 #include <systemd/sd-daemon.h>
 
 int main(int argc, char **argv)
 {
+       GMainLoop *mainloop = get_main_loop();
        int ret_code = 0;
        struct daemon_arg darg = { argc, argv, NULL };
 
+       assert(mainloop);
+
        ret_code = resourced_init(&darg);
        ret_value_msg_if(ret_code < 0, ret_code,
                         "Resourced initialization failed\n");
@@ -63,7 +65,8 @@ int main(int argc, char **argv)
 
        sd_notify(0, "READY=1");
 
-       ecore_main_loop_begin();
+       g_main_loop_run(mainloop);
+       g_main_loop_quit(mainloop);
        modules_exit(NULL);
        resourced_deinit();
        return ret_code;
index 8324343..577e5a9 100644 (file)
@@ -37,7 +37,7 @@
 #include "macro.h"
 #include "module.h"
 #include "module-data.h"
-#include "edbus-handler.h"
+#include "dbus-handler.h"
 #include "swap-common.h"
 #include "config-parser.h"
 #include "lowmem-handler.h"
@@ -759,7 +759,7 @@ static int swap_cgroup_reset_limit(void *data)
        return ret;
 }
 
-static void swap_start_pid_edbus_signal_handler(void *data, DBusMessage *msg)
+static void swap_start_pid_dbus_signal_handler(void *data, DBusMessage *msg)
 {
        _cleanup_dbus_error_free_ DBusError err = DBUS_ERROR_INIT;
        int ret;
@@ -792,7 +792,7 @@ static void swap_start_pid_edbus_signal_handler(void *data, DBusMessage *msg)
        _I("swap cgroup entered : pid : %d", (int)pid);
 }
 
-static void swap_type_edbus_signal_handler(void *data, DBusMessage *msg)
+static void swap_type_dbus_signal_handler(void *data, DBusMessage *msg)
 {
        _cleanup_dbus_error_free_ DBusError err = DBUS_ERROR_INIT;
        enum swap_state state;
@@ -814,7 +814,7 @@ static void swap_type_edbus_signal_handler(void *data, DBusMessage *msg)
                swap_change_state(state);
 }
 
-static DBusMessage *edbus_getswaptype(E_DBus_Object *obj, DBusMessage *msg)
+static DBusMessage *dbus_getswaptype(DBusMessage *msg)
 {
        DBusMessageIter iter;
        DBusMessage *reply;
@@ -829,27 +829,27 @@ static DBusMessage *edbus_getswaptype(E_DBus_Object *obj, DBusMessage *msg)
        return reply;
 }
 
-static struct edbus_method edbus_methods[] = {
-       { "GetSwapType",   NULL,   "i", edbus_getswaptype },
+static struct d_bus_method dbus_methods[] = {
+       { "GetSwapType",   NULL,   "i", dbus_getswaptype },
        /* Add methods here */
 };
 
-static const struct edbus_signal edbus_signals[] = {
+static const struct d_bus_signal dbus_signals[] = {
        /* RESOURCED DBUS */
        {RESOURCED_PATH_SWAP, RESOURCED_INTERFACE_SWAP,
-           SIGNAL_NAME_SWAP_TYPE, swap_type_edbus_signal_handler, NULL},
+           SIGNAL_NAME_SWAP_TYPE, swap_type_dbus_signal_handler, NULL},
        {RESOURCED_PATH_SWAP, RESOURCED_INTERFACE_SWAP,
-           SIGNAL_NAME_SWAP_START_PID, swap_start_pid_edbus_signal_handler, NULL},
+           SIGNAL_NAME_SWAP_START_PID, swap_start_pid_dbus_signal_handler, NULL},
 };
 
 static void swap_dbus_init(void)
 {
        resourced_ret_c ret;
 
-       edbus_add_signals(edbus_signals, ARRAY_SIZE(edbus_signals));
+       d_bus_register_signals(dbus_signals, ARRAY_SIZE(dbus_signals));
 
-       ret = edbus_add_methods(RESOURCED_PATH_SWAP, edbus_methods,
-                         ARRAY_SIZE(edbus_methods));
+       ret = d_bus_register_methods(RESOURCED_PATH_SWAP, dbus_methods,
+                         ARRAY_SIZE(dbus_methods));
 
        ret_msg_if(ret != RESOURCED_ERROR_NONE,
                "DBus method registration for %s is failed",
index 07d8d07..56c1fb4 100644 (file)
@@ -26,7 +26,7 @@
 #include "macro.h"
 #include "module.h"
 #include "module-data.h"
-#include "edbus-handler.h"
+#include "dbus-handler.h"
 #include "resourced.h"
 #include "trace.h"
 #include "vconf.h"
index 3839daf..4a41adf 100644 (file)
@@ -28,8 +28,6 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
-#include <Ecore.h>
-
 #include "const.h"
 #include "resourced.h"
 #include "trace.h"