libpass: Remove libpass (libdeviced of deviced)
authorWook Song <wook16.song@samsung.com>
Fri, 18 Nov 2016 06:47:39 +0000 (15:47 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Mon, 16 Jan 2017 11:35:36 +0000 (20:35 +0900)
This patch removes libpass packages, which were libdeviced of deviced.
These packages are required to build devicectl. Since devicectl has been
removed, there is no reason to remain these packages at this point.

Now, when the building is successfully done, you can find only following
packages as the results:

- pass-0.0.1-1.armv7l.rpm
- pass-debuginfo-0.0.1-1.armv7l.rpm
- pass-debugsource-0.0.1-1.armv7l.rpm

Signed-off-by: Wook Song <wook16.song@samsung.com>
14 files changed:
CMakeLists.txt
packaging/libpass.manifest [deleted file]
packaging/pass.spec
src/libdeviced/CMakeLists.txt [deleted file]
src/libdeviced/dbus.c [deleted file]
src/libdeviced/deviced-conf.c [deleted file]
src/libdeviced/deviced-noti.c [deleted file]
src/libdeviced/deviced-util.c [deleted file]
src/libdeviced/display.c [deleted file]
src/libdeviced/haptic.c [deleted file]
src/libdeviced/led.c [deleted file]
src/libdeviced/mmc.c [deleted file]
src/libdeviced/storage.c [deleted file]
src/libdeviced/usbhost.c [deleted file]

index 7ee48ef..05bdf40 100644 (file)
@@ -222,9 +222,7 @@ INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/systemd/ DESTINATION lib/systemd/s
                PATTERN "deviced-vibrator.service" EXCLUDE
                )
 
-
 ADD_SUBDIRECTORY(src/shared)
-ADD_SUBDIRECTORY(src/libdeviced)
 
 IF(HAPTIC_MODULE STREQUAL on)
        ADD_SUBDIRECTORY(src/haptic)
diff --git a/packaging/libpass.manifest b/packaging/libpass.manifest
deleted file mode 100644 (file)
index 3256181..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<manifest>
-<request>
-       <domain name="_"/>
-</request>
-</manifest>
index e908c17..9aec94e 100644 (file)
@@ -46,7 +46,6 @@ Group:      System/Management
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 Source1:    %{name}.manifest
-Source2:    %{libdaemon_name}.manifest
 
 BuildRequires:  cmake
 BuildRequires:  libattr-devel
@@ -98,22 +97,6 @@ Group:      main
 %description %{daemon_name}
 PASS systemd daemon.
 
-%package -n %{libdaemon_name}
-Summary:    PASS library
-Group:      Development/Libraries
-Requires:   %{name} = %{version}-%{release}
-
-%description -n %{libdaemon_name}
-PASS library for the helper tools.
-
-%package -n %{libdaemon_name}-devel
-Summary:    PASS library for (devel)
-Group:      Development/Libraries
-Requires:   %{libdaemon_name} = %{version}-%{release}
-
-%description -n %{libdaemon_name}-devel
-Deviced library for device control (devel)
-
 %prep
 %setup -q
 %if %{with emulator}
@@ -167,7 +150,6 @@ Deviced library for device control (devel)
 
 %build
 cp %{SOURCE1} .
-cp %{SOURCE2} .
 make %{?jobs:-j%jobs}
 
 %install
@@ -204,10 +186,6 @@ fi
 %postun
 systemctl daemon-reload
 
-%post -n %{libdaemon_name} -p /sbin/ldconfig
-
-%postun -n %{libdaemon_name} -p /sbin/ldconfig
-
 %files -n %{daemon_name}
 %manifest %{name}.manifest
 %license LICENSE
@@ -233,14 +211,3 @@ systemctl daemon-reload
 %if %{?display_module} == on
 %config %{_sysconfdir}/deviced/display.conf
 %endif
-
-%files -n %{libdaemon_name}
-%manifest %{libdaemon_name}.manifest
-%defattr(-,root,root,-)
-%{_libdir}/%{libdaemon_name}.so.*
-
-%files -n %{libdaemon_name}-devel
-%defattr(-,root,root,-)
-%{_includedir}/%{daemon_name}/*.h
-%{_libdir}/%{libdaemon_name}.so
-%{_libdir}/pkgconfig/%{daemon_name}.pc
diff --git a/src/libdeviced/CMakeLists.txt b/src/libdeviced/CMakeLists.txt
deleted file mode 100755 (executable)
index 28e0e2c..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(libpass C)
-
-SET(MAIN_PRJ_NAME pass)
-
-SET(LIBPASS_SRCS
-       display.c
-       dbus.c
-       haptic.c
-       led.c
-       mmc.c
-       storage.c
-       usbhost.c
-       deviced-conf.c
-       deviced-noti.c
-       deviced-util.c
-)
-
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/deviced ${CMAKE_SOURCE_DIR}/src/shared)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(libpkgs REQUIRED
-       vconf
-       dlog
-       storage
-       dbus-1
-       dbus-glib-1
-       edbus
-       glib-2.0)
-
-FOREACH(flag ${libpkgs_CFLAGS})
-       SET(EXTRA_LIB_CFLAGS "${EXTRA_LIB_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_LIB_CFLAGS}")
-
-# libpass
-ADD_LIBRARY(${PROJECT_NAME} SHARED ${LIBPASS_SRCS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${libpkgs_LDFLAGS})
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
-# CMake Policy (CMP0002)
-# The logical name of executable and library targes
-# does not have to correspond to the physical file name built.
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${MAIN_PRJ_NAME})
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
diff --git a/src/libdeviced/dbus.c b/src/libdeviced/dbus.c
deleted file mode 100644 (file)
index c26711e..0000000
+++ /dev/null
@@ -1,358 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
- *
- * 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.
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <errno.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include "common.h"
-#include "log.h"
-#include "dbus.h"
-
-/* -1 is a default timeout value, it's converted to 25*1000 internally. */
-#define DBUS_REPLY_TIMEOUT     (-1)
-
-struct pending_call_data {
-       dbus_pending_cb func;
-       void *data;
-};
-
-int append_variant(DBusMessageIter *iter, const char *sig, char *param[])
-{
-       char *ch;
-       int i;
-       int int_type;
-       dbus_bool_t bool_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':
-                       bool_type = (atoi(param[i])) ? TRUE : FALSE;
-                       dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &bool_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':
-                       ++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;
-               default:
-                       return -EINVAL;
-               }
-       }
-
-       return 0;
-}
-
-DBusMessage *dbus_method_sync_with_reply(const char *dest, const char *path,
-               const char *interface, const char *method,
-               const char *sig, char *param[])
-{
-       DBusConnection *conn;
-       DBusMessage *msg;
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       DBusError err;
-       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);
-               return NULL;
-       }
-
-       dbus_message_iter_init_append(msg, &iter);
-       r = append_variant(&iter, sig, param);
-       if (r < 0) {
-               _E("append_variant error(%d) %s %s:%s-%s",
-                       r, dest, path, interface, method);
-               dbus_message_unref(msg);
-               return NULL;
-       }
-
-       dbus_error_init(&err);
-
-       reply = dbus_connection_send_with_reply_and_block(conn, msg, DBUS_REPLY_TIMEOUT, &err);
-       if (!reply) {
-               _E("dbus_connection_send error(No reply) %s %s:%s-%s",
-                       dest, path, interface, method);
-       }
-
-       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);
-               dbus_error_free(&err);
-               reply = NULL;
-       }
-
-       dbus_message_unref(msg);
-       return reply;
-}
-
-int dbus_method_sync(const char *dest, const char *path,
-               const char *interface, const char *method,
-               const char *sig, char *param[])
-{
-       DBusConnection *conn;
-       DBusMessage *msg;
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       DBusError err;
-       int ret, result;
-
-       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) %s %s:%s-%s",
-                       ret, dest, path, interface, method);
-               dbus_message_unref(msg);
-               return ret;
-       }
-
-       dbus_error_init(&err);
-
-       reply = dbus_connection_send_with_reply_and_block(conn, msg, DBUS_REPLY_TIMEOUT, &err);
-       dbus_message_unref(msg);
-       if (!reply) {
-               _E("dbus_connection_send error(%s:%s) %s %s:%s-%s",
-                       err.name, err.message, dest, path, interface, method);
-               dbus_error_free(&err);
-               return -ECOMM;
-       }
-
-       ret = dbus_message_get_args(reply, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
-       dbus_message_unref(reply);
-       if (!ret) {
-               _E("no message : [%s:%s] %s %s:%s-%s",
-                       err.name, err.message, dest, path, interface, method);
-               dbus_error_free(&err);
-               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;
-       DBusMessage *msg;
-       DBusMessageIter iter;
-       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) %s %s:%s-%s",
-                       ret, dest, path, interface, method);
-               dbus_message_unref(msg);
-               return ret;
-       }
-
-       ret = dbus_connection_send(conn, msg, NULL);
-       dbus_message_unref(msg);
-       if (ret != TRUE) {
-               _E("dbus_connection_send error(%s %s:%s-%s)",
-                       dest, path, interface, method);
-               return -ECOMM;
-       }
-
-       return 0;
-}
-
-static void cb_pending(DBusPendingCall *pending, void *user_data)
-{
-       DBusMessage *msg;
-       DBusError err;
-       struct pending_call_data *data = user_data;
-       int ret;
-
-       ret = dbus_pending_call_get_completed(pending);
-       if (!ret) {
-               _I("dbus_pending_call_get_completed() fail");
-               dbus_pending_call_unref(pending);
-               return;
-       }
-
-       dbus_error_init(&err);
-       msg = dbus_pending_call_steal_reply(pending);
-       if (!msg) {
-               _E("no message : [%s:%s]", err.name, err.message);
-
-               if (data->func) {
-                       dbus_set_error(&err, "org.tizen.system.deviced.NoReply",
-                                       "There was no reply to this method call");
-                       data->func(data->data, NULL, &err);
-                       dbus_error_free(&err);
-               }
-               return;
-       }
-
-       ret = dbus_set_error_from_message(&err, msg);
-       if (ret) {
-               _E("error msg : [%s:%s]", err.name, err.message);
-
-               if (data->func)
-                       data->func(data->data, NULL, &err);
-               dbus_error_free(&err);
-       } else {
-               if (data->func)
-                       data->func(data->data, msg, &err);
-       }
-
-       dbus_message_unref(msg);
-       dbus_pending_call_unref(pending);
-}
-
-int dbus_method_async_with_reply(const char *dest, const char *path,
-               const char *interface, const char *method,
-               const char *sig, char *param[], dbus_pending_cb cb, int timeout, void *data)
-{
-       DBusConnection *conn;
-       DBusMessage *msg;
-       DBusMessageIter iter;
-       DBusPendingCall *pending = NULL;
-       struct pending_call_data *pdata;
-       int ret;
-
-       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
-       if (!conn) {
-               _E("dbus_bus_get error");
-               return -EPERM;
-       }
-
-       /* this function should be invoked to receive dbus messages
-        * does nothing if it's already been done */
-       dbus_connection_setup_with_g_main(conn, 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);
-               return -EBADMSG;
-       }
-
-       dbus_message_iter_init_append(msg, &iter);
-       ret = append_variant(&iter, sig, param);
-       if (ret < 0) {
-               _E("append_variant error(%d)%s %s:%s-%s",
-                       ret, dest, path, interface, method);
-               dbus_message_unref(msg);
-               return ret;
-       }
-
-       ret = dbus_connection_send_with_reply(conn, msg, &pending, timeout);
-       if (!ret) {
-               dbus_message_unref(msg);
-               _E("dbus_connection_send error(%s %s:%s-%s)",
-                       dest, path, interface, method);
-               return -ECOMM;
-       }
-
-       dbus_message_unref(msg);
-
-       if (cb && pending) {
-               pdata = malloc(sizeof(struct pending_call_data));
-               if (!pdata)
-                       return -ENOMEM;
-
-               pdata->func = cb;
-               pdata->data = data;
-
-               ret = dbus_pending_call_set_notify(pending, cb_pending, pdata, free);
-               if (!ret) {
-                       free(pdata);
-                       dbus_pending_call_cancel(pending);
-                       return -ECOMM;
-               }
-       }
-
-       return 0;
-}
-
-static void __CONSTRUCTOR__ dbus_init(void)
-{
-       dbus_threads_init_default();
-}
diff --git a/src/libdeviced/deviced-conf.c b/src/libdeviced/deviced-conf.c
deleted file mode 100644 (file)
index 4a45690..0000000
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
- *
- * 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.
- */
-
-
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dlfcn.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <errno.h>
-
-#include "log.h"
-#include "deviced-priv.h"
-#include "dd-deviced.h"
-#include "dbus.h"
-#include "score-defines.h"
-
-#define PERMANENT_DIR          "/tmp/permanent"
-#define VIP_DIR                        "/tmp/vip"
-
-#define OOMADJ_SET             "oomadj_set"
-#define PROCESS_GROUP_SET      "process_group_set"
-#define PROCESS_VIP            "process_vip"
-#define PROCESS_PERMANENT      "process_permanent"
-
-enum mp_entry_type {
-       MP_VIP,
-       MP_PERMANENT,
-       MP_NONE
-};
-
-int util_oomadj_set(int pid, int oomadj_val)
-{
-       DBusError err;
-       DBusMessage *msg;
-       char *pa[4];
-       char buf1[SYSTEM_NOTI_MAXARG];
-       char buf2[SYSTEM_NOTI_MAXARG];
-       int ret, val;
-
-       snprintf(buf1, sizeof(buf1), "%d", pid);
-       snprintf(buf2, sizeof(buf2), "%d", oomadj_val);
-
-       pa[0] = OOMADJ_SET;
-       pa[1] = "2";
-       pa[2] = buf1;
-       pa[3] = buf2;
-
-       msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
-                       DEVICED_PATH_PROCESS, DEVICED_INTERFACE_PROCESS,
-                       pa[0], "siss", pa);
-       if (!msg)
-               return -EBADMSG;
-
-       dbus_error_init(&err);
-
-       ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
-       if (!ret) {
-               _E("no message : [%s:%s]", err.name, err.message);
-               val = -EBADMSG;
-       }
-
-       dbus_message_unref(msg);
-       dbus_error_free(&err);
-
-       _D("%s-%s : %d", DEVICED_INTERFACE_PROCESS, pa[0], val);
-       return val;
-}
-
-static int util_process_group_set(char* name, int pid)
-{
-       DBusError err;
-       DBusMessage *msg;
-       char *pa[4];
-       char buf[SYSTEM_NOTI_MAXARG];
-       int ret, val;
-
-       if (strncmp(PROCESS_VIP, name, strlen(name)) != 0 &&
-           strncmp(PROCESS_PERMANENT, name, strlen(name)) != 0) {
-               _E("fail to insert at %s group", name);
-               return -1;
-       }
-
-       snprintf(buf, sizeof(buf), "%d", pid);
-       _D("pid(%d) is inserted at vip", pid);
-
-       pa[0] = PROCESS_GROUP_SET;
-       pa[1] = "2";
-       pa[2] = buf;
-       pa[3] = name;
-
-       msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
-                       DEVICED_PATH_PROCESS, DEVICED_INTERFACE_PROCESS,
-                       pa[0], "siss", pa);
-       if (!msg)
-               return -EBADMSG;
-
-       dbus_error_init(&err);
-
-       ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
-       if (!ret) {
-               _E("no message : [%s:%s]", err.name, err.message);
-               val = -EBADMSG;
-       }
-
-       dbus_message_unref(msg);
-       dbus_error_free(&err);
-
-       _D("%s-%s : %d", DEVICED_INTERFACE_PROCESS, pa[0], val);
-       return val;
-}
-
-API int deviced_conf_set_mempolicy_bypid(int pid, enum mem_policy mempol)
-{
-       if (pid < 1)
-               return -1;
-
-       int oomadj_val = 0;
-
-       switch (mempol) {
-       case OOM_LIKELY:
-               oomadj_val = OOMADJ_BACKGRD_UNLOCKED;
-               break;
-       case OOM_IGNORE:
-               oomadj_val = OOMADJ_SU;
-               break;
-       default:
-               return -1;
-       }
-
-       return util_oomadj_set(pid, oomadj_val);
-}
-
-API int deviced_conf_set_mempolicy(enum mem_policy mempol)
-{
-       return deviced_conf_set_mempolicy_bypid(getpid(), mempol);
-}
-
-static int already_permanent(int pid)
-{
-       char buf[BUFF_MAX];
-
-       snprintf(buf, BUFF_MAX, "%s/%d", PERMANENT_DIR, pid);
-
-       if (access(buf, R_OK) == 0) {
-               _D("already_permanent process : %d", pid);
-               return 1;
-       }
-       return 0;
-}
-
-static int copy_cmdline(int pid)
-{
-       char buf[PATH_MAX];
-       char filepath[PATH_MAX];
-       int fd;
-       int cnt;
-       int r;
-
-       if (access(PERMANENT_DIR, R_OK) < 0) {
-               _D("no predefined matrix dir = %s, so created", PERMANENT_DIR);
-               r = mkdir(PERMANENT_DIR, 0777);
-               if (r < 0) {
-                       _E("permanent directory mkdir is failed");
-                       return -1;
-               }
-       }
-
-       snprintf(filepath, PATH_MAX, "/proc/%d/cmdline", pid);
-
-       fd = open(filepath, O_RDONLY);
-       if (fd == -1) {
-               _E("Failed to open");
-               return -1;
-       }
-
-       cnt = read(fd, buf, PATH_MAX);
-       close(fd);
-
-       if (cnt <= 0) {
-               /* Read /proc/<pid>/cmdline error */
-               _E("Failed to read");
-               return -1;
-       }
-
-       snprintf(filepath, PATH_MAX, "%s/%d", PERMANENT_DIR, pid);
-
-       fd = open(filepath, O_CREAT | O_WRONLY, 0644);
-       if (fd == -1) {
-               _E("Failed to open");
-               return -1;
-       }
-
-       if (write(fd, buf, cnt) == -1) {
-               _E("Failed to write");
-               close(fd);
-               return -1;
-       }
-
-       close(fd);
-       return 0;
-}
-
-API int deviced_conf_set_vip(int pid)
-{
-       char buf[BUFF_MAX];
-       int fd;
-       int r;
-
-       if (pid < 1)
-               return -1;
-
-       if (access(VIP_DIR, R_OK) < 0) {
-               _D("no predefined matrix dir = %s, so created", VIP_DIR);
-               r = mkdir(VIP_DIR, 0777);
-               if (r < 0) {
-                       _E("sysconf_set_vip vip mkdir is failed");
-                       return -1;
-               }
-       }
-
-       snprintf(buf, BUFF_MAX, "%s/%d", VIP_DIR, pid);
-       fd = open(buf, O_CREAT | O_RDWR, 0644);
-       if (fd < 0) {
-               _E("sysconf_set_vip fd open failed");
-               return -1;
-       }
-       close(fd);
-       if (util_process_group_set(PROCESS_VIP, pid) < 0) {
-               _E("set vip failed");
-               return -1;
-       }
-
-       return 0;
-}
-
-API int deviced_conf_is_vip(int pid)
-{
-       if (pid < 1)
-               return -1;
-
-       char buf[BUFF_MAX];
-
-       snprintf(buf, BUFF_MAX, "%s/%d", VIP_DIR, pid);
-
-       if (access(buf, R_OK) == 0)
-               return 1;
-       else
-               return 0;
-}
-
-API int deviced_conf_set_permanent_bypid(int pid)
-{
-       if (already_permanent(pid))
-               goto MEMPOL_SET;
-
-       if (copy_cmdline(pid) < 0)
-               return -1;
-
-       if (util_process_group_set(PROCESS_PERMANENT, pid) < 0) {
-               _E("set vip failed");
-               return -1;
-       }
-
- MEMPOL_SET:
-       util_oomadj_set(pid, OOMADJ_SU);
-
-       return 0;
-}
-
-API int deviced_conf_set_permanent(void)
-{
-       pid_t pid = getpid();
-       return deviced_conf_set_permanent_bypid(pid);
-}
diff --git a/src/libdeviced/deviced-noti.c b/src/libdeviced/deviced-noti.c
deleted file mode 100644 (file)
index 812f63c..0000000
+++ /dev/null
@@ -1,504 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
- *
- * 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.
- */
-
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <errno.h>
-#include <vconf.h>
-#include <vconf-keys.h>
-#include <limits.h>
-
-#include "dd-deviced.h"
-#include "deviced-priv.h"
-#include "log.h"
-#include "dbus.h"
-
-#define PREDEF_PWROFF_POPUP                    "pwroff-popup"
-#define PREDEF_ENTERSLEEP                      "entersleep"
-#define PREDEF_LEAVESLEEP                      "leavesleep"
-#define PREDEF_REBOOT                          "reboot"
-#define PREDEF_BACKGRD                         "backgrd"
-#define PREDEF_FOREGRD                         "foregrd"
-#define PREDEF_ACTIVE                          "active"
-#define PREDEF_INACTIVE                                "inactive"
-#define PREDEF_SET_DATETIME                    "set_datetime"
-#define PREDEF_SET_TIMEZONE                    "set_timezone"
-
-#define PREDEF_SET_MAX_FREQUENCY               "set_max_frequency"
-#define PREDEF_SET_MIN_FREQUENCY               "set_min_frequency"
-#define PREDEF_RELEASE_MAX_FREQUENCY           "release_max_frequency"
-#define PREDEF_RELEASE_MIN_FREQUENCY           "release_min_frequency"
-
-#define ALARM_BUS_NAME         "com.samsung.alarm.manager"
-#define ALARM_PATH_NAME                "/com/samsung/alarm/manager"
-#define ALARM_INTERFACE_NAME   ALARM_BUS_NAME
-#define ALARM_SET_TIME_METHOD  "alarm_set_time"
-
-enum deviced_noti_cmd {
-       ADD_deviced_ACTION,
-       CALL_deviced_ACTION
-};
-
-#define SYSTEM_NOTI_SOCKET_PATH "/tmp/sn"
-#define RETRY_READ_COUNT       10
-
-static inline int send_int(int fd, int val)
-{
-       return write(fd, &val, sizeof(int));
-}
-
-static inline int send_str(int fd, char *str)
-{
-       int len;
-       int ret;
-       if (str == NULL) {
-               len = 0;
-               ret = write(fd, &len, sizeof(int));
-       } else {
-               len = strlen(str);
-               if (len > SYSTEM_NOTI_MAXSTR)
-                       len = SYSTEM_NOTI_MAXSTR;
-               ret = write(fd, &len, sizeof(int));
-               if (ret < 0)
-                       _E("Failed to write (%d)", errno);
-               ret = write(fd, str, len);
-               if (ret < 0)
-                       _E("Failed to write (%d)", errno);
-       }
-       return ret;
-}
-
-static int noti_send(struct sysnoti *msg)
-{
-       int client_len;
-       int client_sockfd;
-       int result;
-       int r;
-       int retry_count = 0;
-       struct sockaddr_un clientaddr;
-       int i;
-
-       client_sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
-       if (client_sockfd == -1) {
-               _E("socket create failed");
-               return -1;
-       }
-       bzero(&clientaddr, sizeof(clientaddr));
-       clientaddr.sun_family = AF_UNIX;
-       strncpy(clientaddr.sun_path, SYSTEM_NOTI_SOCKET_PATH, sizeof(clientaddr.sun_path) - 1);
-       client_len = sizeof(clientaddr);
-
-       if (connect(client_sockfd, (struct sockaddr *)&clientaddr, client_len) <
-           0) {
-               _E("connect failed");
-               close(client_sockfd);
-               return -1;
-       }
-
-       send_int(client_sockfd, msg->pid);
-       send_int(client_sockfd, msg->cmd);
-       send_str(client_sockfd, msg->type);
-       send_str(client_sockfd, msg->path);
-       send_int(client_sockfd, msg->argc);
-       for (i = 0; i < msg->argc; i++)
-               send_str(client_sockfd, msg->argv[i]);
-
-       while (retry_count < RETRY_READ_COUNT) {
-               r = read(client_sockfd, &result, sizeof(int));
-               if (r < 0) {
-                       if (errno == EINTR) {
-                               _E("Re-read for error(EINTR)");
-                               retry_count++;
-                               continue;
-                       }
-                       _E("Read fail for str length");
-                       result = -1;
-                       break;
-
-               }
-               break;
-       }
-       if (retry_count == RETRY_READ_COUNT) {
-               _E("Read retry failed");
-       }
-
-       close(client_sockfd);
-       return result;
-}
-
-API int deviced_call_predef_action(const char *type, int num, ...)
-{
-       struct sysnoti *msg;
-       int ret;
-       va_list argptr;
-       int i;
-       char *args = NULL;
-
-       if (type == NULL || num > SYSTEM_NOTI_MAXARG) {
-               errno = EINVAL;
-               return -1;
-       }
-
-       msg = malloc(sizeof(struct sysnoti));
-
-       if (msg == NULL) {
-               /* Do something for not enought memory error */
-               return -1;
-       }
-
-       msg->pid = getpid();
-       msg->cmd = CALL_deviced_ACTION;
-       msg->type = (char *)type;
-       msg->path = NULL;
-
-       msg->argc = num;
-       va_start(argptr, num);
-       for (i = 0; i < num; i++) {
-               args = va_arg(argptr, char *);
-               msg->argv[i] = args;
-       }
-       va_end(argptr);
-
-       ret = noti_send(msg);
-       free(msg);
-
-       return ret;
-}
-
-static int dbus_proc_handler(char* type, char *buf)
-{
-       DBusError err;
-       DBusMessage *msg;
-       char *pa[3];
-       int ret, val;
-
-       pa[0] = type;
-       pa[1] = "1";
-       pa[2] = buf;
-
-       msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
-                       DEVICED_PATH_PROCESS, DEVICED_INTERFACE_PROCESS,
-                       pa[0], "sis", pa);
-       if (!msg)
-               return -EBADMSG;
-
-       dbus_error_init(&err);
-
-       ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
-       if (!ret) {
-               _E("no message : [%s:%s]", err.name, err.message);
-               val = -EBADMSG;
-       }
-
-       dbus_message_unref(msg);
-       dbus_error_free(&err);
-
-       _D("%s-%s : %d", DEVICED_INTERFACE_PROCESS, pa[0], val);
-       return val;
-}
-
-API int deviced_inform_foregrd(void)
-{
-       char buf[255];
-       snprintf(buf, sizeof(buf), "%d", getpid());
-       return dbus_proc_handler(PREDEF_FOREGRD, buf);
-}
-
-API int deviced_inform_backgrd(void)
-{
-       char buf[255];
-       snprintf(buf, sizeof(buf), "%d", getpid());
-       return dbus_proc_handler(PREDEF_BACKGRD, buf);
-}
-
-API int deviced_inform_active(pid_t pid)
-{
-       char buf[255];
-       snprintf(buf, sizeof(buf), "%d", pid);
-       return dbus_proc_handler(PREDEF_ACTIVE, buf);
-}
-
-API int deviced_inform_inactive(pid_t pid)
-{
-       char buf[255];
-       snprintf(buf, sizeof(buf), "%d", pid);
-       return dbus_proc_handler(PREDEF_INACTIVE, buf);
-}
-
-static int dbus_power_handler(char* type)
-{
-       DBusError err;
-       DBusMessage *msg;
-       char *pa[2];
-       int ret, val;
-
-       pa[0] = type;
-       pa[1] = "0";
-
-       msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
-                       DEVICED_PATH_POWER, DEVICED_INTERFACE_POWER,
-                       pa[0], "si", pa);
-       if (!msg)
-               return -EBADMSG;
-
-       dbus_error_init(&err);
-
-       ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
-       if (!ret) {
-               _E("no message : [%s:%s]", err.name, err.message);
-               val = -EBADMSG;
-       }
-
-       dbus_message_unref(msg);
-       dbus_error_free(&err);
-
-       _D("%s-%s : %d", DEVICED_INTERFACE_POWER, pa[0], val);
-       return val;
-}
-
-API int deviced_request_poweroff(void)
-{
-       return dbus_power_handler(PREDEF_PWROFF_POPUP);
-}
-
-API int deviced_request_entersleep(void)
-{
-       return dbus_power_handler(PREDEF_ENTERSLEEP);
-}
-
-API int deviced_request_leavesleep(void)
-{
-       return dbus_power_handler(PREDEF_LEAVESLEEP);
-}
-
-API int deviced_request_reboot(void)
-{
-       return dbus_power_handler(PREDEF_REBOOT);
-}
-
-static int dbus_time_handler(char* type, char* buf)
-{
-       DBusError err;
-       DBusMessage *msg;
-       pid_t pid;
-       char name[PATH_MAX];
-       char *pa[3];
-       int ret, val;
-
-       pa[0] = type;
-       pa[1] = "1";
-       pa[2] = buf;
-
-       pid = getpid();
-       ret = deviced_get_cmdline_name(pid, name, sizeof(name));
-       if (ret != 0)
-               snprintf(name, sizeof(name), "%d", pid);
-
-       msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
-                       DEVICED_PATH_SYSNOTI, DEVICED_INTERFACE_SYSNOTI,
-                       pa[0], "sis", pa);
-       if (!msg)
-               return -EBADMSG;
-
-       dbus_error_init(&err);
-
-       ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
-       if (!ret) {
-               _E("no message : [%s:%s]", err.name, err.message);
-               val = -EBADMSG;
-       }
-
-       dbus_message_unref(msg);
-       dbus_error_free(&err);
-
-       _SI("[%s] %s-%s(%s) : %d", name, DEVICED_INTERFACE_SYSNOTI, pa[0], pa[2], val);
-
-       return val;
-}
-
-static DBusMessage *alarm_set_time_sync_with_reply(time_t timet)
-{
-       DBusConnection *conn;
-       DBusMessage *msg;
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       DBusError err;
-
-       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
-       if (!conn) {
-               _E("dbus_bus_get error");
-               return NULL;
-       }
-
-       msg = dbus_message_new_method_call(ALARM_BUS_NAME, ALARM_PATH_NAME, ALARM_INTERFACE_NAME, ALARM_SET_TIME_METHOD);
-       if (!msg) {
-               _E("dbus_message_new_method_call(%s:%s-%s)",
-                       ALARM_PATH_NAME, ALARM_INTERFACE_NAME, ALARM_SET_TIME_METHOD);
-               return NULL;
-       }
-
-       dbus_message_iter_init_append(msg, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &timet);
-
-       dbus_error_init(&err);
-
-       reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, &err);
-       if (!reply) {
-               _E("dbus_connection_send error(No reply) %s %s:%s-%s",
-                       ALARM_BUS_NAME, ALARM_PATH_NAME, ALARM_INTERFACE_NAME, ALARM_SET_TIME_METHOD);
-       }
-
-       if (dbus_error_is_set(&err)) {
-               _E("dbus_connection_send error(%s:%s) %s %s:%s-%s",
-                       err.name, err.message, ALARM_BUS_NAME, ALARM_PATH_NAME, ALARM_INTERFACE_NAME, ALARM_SET_TIME_METHOD);
-               dbus_error_free(&err);
-               reply = NULL;
-       }
-
-       dbus_message_unref(msg);
-       return reply;
-}
-
-static int alarm_set_time(time_t timet)
-{
-       DBusError err;
-       DBusMessage *msg;
-       pid_t pid;
-       char name[PATH_MAX];
-       int ret, val;
-
-       pid = getpid();
-       ret = deviced_get_cmdline_name(pid, name, sizeof(name));
-       if (ret != 0)
-               snprintf(name, sizeof(name), "%d", pid);
-       _SI("[%s]start %s %ld", name, ALARM_INTERFACE_NAME, timet);
-
-       msg = alarm_set_time_sync_with_reply(timet);
-       if (!msg)
-               return -EBADMSG;
-
-       dbus_error_init(&err);
-
-       ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
-       if (!ret) {
-               _E("no message : [%s:%s]", err.name, err.message);
-               val = -EBADMSG;
-       }
-
-       dbus_message_unref(msg);
-       dbus_error_free(&err);
-
-       _SI("[%s]end %s %ld, %d", name, ALARM_INTERFACE_NAME, timet, val);
-       return val;
-}
-
-API int deviced_set_datetime(time_t timet)
-{
-       if (timet < 0L)
-               return -1;
-       return alarm_set_time(timet);
-}
-
-API int deviced_set_timezone(char *tzpath_str)
-{
-       if (tzpath_str == NULL)
-               return -1;
-       char buf[255];
-       snprintf(buf, sizeof(buf), "%s", tzpath_str);
-       return dbus_time_handler(PREDEF_SET_TIMEZONE, buf);
-}
-
-static int dbus_cpu_handler(char* type, char* buf_pid, char* buf_freq)
-{
-       DBusError err;
-       DBusMessage *msg;
-       char *pa[4];
-       int ret, val;
-
-       pa[0] = type;
-       pa[1] = "2";
-       pa[2] = buf_pid;
-       pa[3] = buf_freq;
-
-       msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
-                       DEVICED_PATH_SYSNOTI, DEVICED_INTERFACE_SYSNOTI,
-                       pa[0], "siss", pa);
-       if (!msg)
-               return -EBADMSG;
-
-       dbus_error_init(&err);
-
-       ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
-       if (!ret) {
-               _E("no message : [%s:%s]", err.name, err.message);
-               val = -EBADMSG;
-       }
-
-       dbus_message_unref(msg);
-       dbus_error_free(&err);
-
-       _D("%s-%s : %d", DEVICED_INTERFACE_SYSNOTI, pa[0], val);
-       return val;
-}
-
-API int deviced_request_set_cpu_max_frequency(int val)
-{
-       char buf_pid[8];
-       char buf_freq[256];
-
-       // to do - need to check new frequncy is valid
-       snprintf(buf_pid, sizeof(buf_pid), "%d", getpid());
-       snprintf(buf_freq, sizeof(buf_freq), "%d", val * 1000);
-
-       return dbus_cpu_handler(PREDEF_SET_MAX_FREQUENCY, buf_pid, buf_freq);
-}
-
-API int deviced_request_set_cpu_min_frequency(int val)
-{
-       char buf_pid[8];
-       char buf_freq[256];
-
-       // to do - need to check new frequncy is valid
-       snprintf(buf_pid, sizeof(buf_pid), "%d", getpid());
-       snprintf(buf_freq, sizeof(buf_freq), "%d", val * 1000);
-
-       return dbus_cpu_handler(PREDEF_SET_MIN_FREQUENCY, buf_pid, buf_freq);
-}
-
-API int deviced_release_cpu_max_frequency()
-{
-       char buf_pid[8];
-
-       snprintf(buf_pid, sizeof(buf_pid), "%d", getpid());
-
-       return dbus_cpu_handler(PREDEF_RELEASE_MAX_FREQUENCY, buf_pid, "2");
-}
-
-API int deviced_release_cpu_min_frequency()
-{
-       char buf_pid[8];
-
-       snprintf(buf_pid, sizeof(buf_pid), "%d", getpid());
-
-       return dbus_cpu_handler(PREDEF_RELEASE_MIN_FREQUENCY, buf_pid, "2");
-}
diff --git a/src/libdeviced/deviced-util.c b/src/libdeviced/deviced-util.c
deleted file mode 100644 (file)
index 8071c7a..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
- *
- * 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.
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <ctype.h>
-#include <string.h>
-#include <stdarg.h>
-#include <errno.h>
-#include <poll.h>
-
-#include "log.h"
-#include "dd-deviced.h"
-#include "deviced-priv.h"
-
-API int deviced_get_pid(const char *execpath)
-{
-       DIR *dp;
-       struct dirent entry;
-       struct dirent *dentry;
-       int pid = -1, fd;
-       char buf[BUFF_MAX];
-       char buf2[BUFF_MAX];
-       int ret;
-
-       dp = opendir("/proc");
-       if (!dp) {
-               _E("open /proc");
-               return -1;
-       }
-
-       if ((readdir_r(dp, &entry, &dentry)) != 0)
-               dentry = NULL;
-
-       while (dentry != NULL) {
-               if (!isdigit(dentry->d_name[0]))
-                       continue;
-
-               pid = atoi(dentry->d_name);
-
-               snprintf(buf, BUFF_MAX, "/proc/%d/cmdline", pid);
-               fd = open(buf, O_RDONLY);
-               if (fd < 0)
-                       continue;
-
-               ret = read(fd, buf2, BUFF_MAX);
-               close(fd);
-
-               if (ret < 0 || ret >= BUFF_MAX)
-                       continue;
-
-               buf2[ret] = '\0';
-
-               if (!strcmp(buf2, execpath)) {
-                       closedir(dp);
-                       return pid;
-               }
-       }
-
-       errno = ESRCH;
-       closedir(dp);
-       return -1;
-}
-
-API int deviced_get_cmdline_name(pid_t pid, char *cmdline, size_t cmdline_size)
-{
-       int fd, ret;
-       char buf[PATH_MAX + 1];
-       char *filename;
-
-       if (cmdline == NULL) {
-               errno = EINVAL;
-               return -EINVAL;
-       }
-
-       snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
-       fd = open(buf, O_RDONLY);
-       if (fd < 0) {
-               errno = ESRCH;
-               return -ESRCH;
-       }
-
-       ret = read(fd, buf, PATH_MAX);
-       close(fd);
-       if (ret < 0) {
-               ret = -errno;
-               _E("read() failed (%d)", ret);
-               return ret;
-       }
-       buf[PATH_MAX] = '\0';
-
-       filename = strrchr(buf, '/');
-       if (filename == NULL)
-               filename = buf;
-       else
-               filename = filename + 1;
-
-       if (cmdline_size < strlen(filename) + 1) {
-               errno = EOVERFLOW;
-               return -EOVERFLOW;
-       }
-
-       strncpy(cmdline, filename, cmdline_size - 1);
-       cmdline[cmdline_size - 1] = '\0';
-       return 0;
-}
-
-API int deviced_get_apppath(pid_t pid, char *app_path, size_t app_path_size)
-{
-       char buf[PATH_MAX];
-       int ret;
-
-       snprintf(buf, PATH_MAX, "/proc/%d/exe", pid);
-       if (app_path == NULL
-           || (ret = readlink(buf, app_path, app_path_size)) == -1)
-               return -1;
-       if (app_path_size == ret) {
-               app_path[ret - 1] = '\0';
-               errno = EOVERFLOW;
-               return -1;
-       }
-
-       app_path[ret] = '\0';
-       return 0;
-}
diff --git a/src/libdeviced/display.c b/src/libdeviced/display.c
deleted file mode 100644 (file)
index f9174b2..0000000
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
- *
- * 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.
- */
-
-
-#include <stdio.h>
-#include <errno.h>
-
-#include "log.h"
-#include "dbus.h"
-#include "common.h"
-#include "dd-display.h"
-
-#define DISPLAY_MAX_BRIGHTNESS  100
-#define DISPLAY_MIN_BRIGHTNESS  1
-#define DISPLAY_DIM_BRIGHTNESS  0
-
-#define HOLDKEY_BLOCK_BIT              0x1
-
-#define METHOD_SET_REFRESH_RATE        "SetRefreshRate"
-#define METHOD_LOCK_STATE              "lockstate"
-#define METHOD_UNLOCK_STATE            "unlockstate"
-#define METHOD_CHANGE_STATE            "changestate"
-#define METHOD_GET_DISPLAY_COUNT       "GetDisplayCount"
-#define METHOD_GET_MAX_BRIGHTNESS      "GetMaxBrightness"
-#define METHOD_GET_BRIGHTNESS  "GetBrightness"
-#define METHOD_SET_BRIGHTNESS  "SetBrightness"
-#define METHOD_HOLD_BRIGHTNESS "HoldBrightness"
-#define METHOD_RELEASE_BRIGHTNESS      "ReleaseBrightness"
-#define METHOD_GET_ACL_STATUS  "GetAclStatus"
-#define METHOD_SET_ACL_STATUS  "SetAclStatus"
-
-#define STR_LCD_OFF   "lcdoff"
-#define STR_LCD_DIM   "lcddim"
-#define STR_LCD_ON    "lcdon"
-#define STR_SUSPEND   "suspend"
-
-#define STR_STAYCURSTATE "staycurstate"
-#define STR_GOTOSTATENOW "gotostatenow"
-
-#define STR_HOLDKEYBLOCK "holdkeyblock"
-#define STR_NULL         "NULL"
-
-#define STR_SLEEP_MARGIN "sleepmargin"
-#define STR_RESET_TIMER  "resettimer"
-#define STR_KEEP_TIMER   "keeptimer"
-
-API int display_get_max_brightness(void)
-{
-       int ret;
-
-       ret = dbus_method_sync(DEVICED_BUS_NAME,
-                       DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
-                       METHOD_GET_MAX_BRIGHTNESS, NULL, NULL);
-       if (ret < 0)
-               return DISPLAY_MAX_BRIGHTNESS;
-
-       _D("get max brightness : %d", ret);
-       return ret;
-}
-
-API int display_set_brightness_with_setting(int val)
-{
-       char str_val[32];
-       char *arr[1];
-       int ret;
-
-       if (val < 0 || val > 100)
-               return -EINVAL;
-
-       snprintf(str_val, sizeof(str_val), "%d", val);
-       arr[0] = str_val;
-
-       ret = dbus_method_async(DEVICED_BUS_NAME,
-                       DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
-                       METHOD_SET_BRIGHTNESS, "i", arr);
-       if (ret < 0)
-               _E("no message : failed to setting");
-
-       return ret;
-}
-
-static inline char *get_lcd_str(unsigned int val)
-{
-       switch (val) {
-       case LCD_NORMAL:
-               return STR_LCD_ON;
-       case LCD_DIM:
-               return STR_LCD_DIM;
-       case LCD_OFF:
-               return STR_LCD_OFF;
-       case SUSPEND:
-               return STR_SUSPEND;
-       default:
-               return NULL;
-       }
-}
-
-static void display_change_cb(void *data, DBusMessage *msg, DBusError *unused)
-{
-       DBusError err;
-       int ret, val;
-
-       if (!msg)
-               return;
-
-       dbus_error_init(&err);
-       ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
-       if (!ret) {
-               _E("no message [%s:%s]", err.name, err.message);
-               dbus_error_free(&err);
-               return;
-       }
-       _D("%s-%s : %d", DEVICED_INTERFACE_DISPLAY, METHOD_CHANGE_STATE, val);
-}
-
-API int display_change_state(unsigned int s_bits)
-{
-       char *p, *pa[1];
-       int ret;
-
-       p = get_lcd_str(s_bits);
-       if (!p)
-               return -EINVAL;
-       pa[0] = p;
-
-       ret = dbus_method_async_with_reply(DEVICED_BUS_NAME,
-                       DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
-                       METHOD_CHANGE_STATE, "s", pa, display_change_cb, -1, NULL);
-       if (ret < 0)
-               _E("no message : failed to change state");
-
-       _D("%s-%s : %d", DEVICED_INTERFACE_DISPLAY, METHOD_CHANGE_STATE, ret);
-
-       return ret;
-}
-
-static void display_lock_cb(void *data, DBusMessage *msg, DBusError *unused)
-{
-       DBusError err;
-       int ret, val;
-
-       if (!msg)
-               return;
-
-       dbus_error_init(&err);
-       ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
-       if (!ret) {
-               _E("no message [%s:%s]", err.name, err.message);
-               dbus_error_free(&err);
-               return;
-       }
-       _D("%s-%s : %d", DEVICED_INTERFACE_DISPLAY, METHOD_LOCK_STATE, val);
-}
-
-API int display_lock_state(unsigned int s_bits, unsigned int flag,
-                     unsigned int timeout)
-{
-       char *p, *pa[4];
-       char str_timeout[32];
-       int ret;
-
-       p = get_lcd_str(s_bits);
-       if (!p)
-               return -EINVAL;
-       pa[0] = p;
-
-       if (flag & GOTO_STATE_NOW)
-               /* if the flag is true, go to the locking state directly */
-               p = STR_GOTOSTATENOW;
-       else
-               p = STR_STAYCURSTATE;
-       pa[1] = p;
-
-       if (flag & HOLD_KEY_BLOCK)
-               p = STR_HOLDKEYBLOCK;
-       else
-               p = STR_NULL;
-       pa[2] = p;
-
-       snprintf(str_timeout, sizeof(str_timeout), "%d", timeout);
-       pa[3] = str_timeout;
-
-       ret = dbus_method_async_with_reply(DEVICED_BUS_NAME,
-                       DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
-                       METHOD_LOCK_STATE, "sssi", pa, display_lock_cb, -1, NULL);
-       if (ret < 0)
-               _E("no message : failed to lock state");
-
-       _D("%s-%s : %d", DEVICED_INTERFACE_DISPLAY, METHOD_LOCK_STATE, ret);
-
-       return ret;
-}
-
-static void display_unlock_cb(void *data, DBusMessage *msg, DBusError *unused)
-{
-       DBusError err;
-       int ret, val;
-
-       if (!msg)
-               return;
-
-       dbus_error_init(&err);
-       ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
-       if (!ret) {
-               _E("no message [%s:%s]", err.name, err.message);
-               dbus_error_free(&err);
-               return;
-       }
-       _D("%s-%s : %d", DEVICED_INTERFACE_DISPLAY, METHOD_UNLOCK_STATE, val);
-}
-
-API int display_unlock_state(unsigned int s_bits, unsigned int flag)
-{
-       char *p, *pa[2];
-       int ret;
-
-       p = get_lcd_str(s_bits);
-       if (!p)
-               return -EINVAL;
-       pa[0] = p;
-
-       switch (flag) {
-       case PM_SLEEP_MARGIN:
-               p = STR_SLEEP_MARGIN;
-               break;
-       case PM_RESET_TIMER:
-               p = STR_RESET_TIMER;
-               break;
-       case PM_KEEP_TIMER:
-               p = STR_KEEP_TIMER;
-               break;
-       default:
-               return -EINVAL;
-       }
-       pa[1] = p;
-
-       ret = dbus_method_async_with_reply(DEVICED_BUS_NAME,
-                       DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
-                       METHOD_UNLOCK_STATE, "ss", pa, display_unlock_cb, -1, NULL);
-       if (ret < 0)
-               _E("no message : failed to unlock state");
-
-       _D("%s-%s : %d", DEVICED_INTERFACE_DISPLAY, METHOD_UNLOCK_STATE, ret);
-
-       return ret;
-}
diff --git a/src/libdeviced/haptic.c b/src/libdeviced/haptic.c
deleted file mode 100644 (file)
index 6971fe7..0000000
+++ /dev/null
@@ -1,771 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
- *
- * 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.
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <dlfcn.h>
-#include <vconf.h>
-
-#include "log.h"
-#include "dbus.h"
-#include "haptic-plugin-intf.h"
-#include "dd-haptic.h"
-#include "common.h"
-
-#define METHOD_OPEN_DEVICE                     "OpenDevice"
-#define METHOD_CLOSE_DEVICE                    "CloseDevice"
-#define METHOD_STOP_DEVICE                     "StopDevice"
-#define METHOD_VIBRATE_MONOTONE                "VibrateMonotone"
-#define METHOD_VIBRATE_BUFFER          "VibrateBuffer"
-#define METHOD_GET_COUNT                       "GetCount"
-#define METHOD_GET_STATE                       "GetState"
-#define METHOD_GET_DURATION                    "GetDuration"
-#define METHOD_CREATE_EFFECT           "CreateEffect"
-#define METHOD_SAVE_BINARY                     "SaveBinary"
-
-#define TEMP_BUFFER_SIZE                       (64*1024)
-
-/* START of Static Function Section */
-static unsigned char *convert_file_to_buffer(const char *file_name, int *size)
-{
-       FILE *pf;
-       long file_size;
-       unsigned char *pdata = NULL;
-
-       if (!file_name)
-               return NULL;
-
-       /* Get File Stream Pointer */
-       pf = fopen(file_name, "rb");
-       if (!pf) {
-               _E("fopen failed : %d", errno);
-               return NULL;
-       }
-
-       if (fseek(pf, 0, SEEK_END))
-               goto error;
-
-       file_size = ftell(pf);
-       if (fseek(pf, 0, SEEK_SET))
-               goto error;
-
-       if (file_size < 0)
-               goto error;
-
-       pdata = (unsigned char *)malloc(file_size);
-       if (!pdata)
-               goto error;
-
-       if (fread(pdata, 1, file_size, pf) != file_size)
-               goto err_free;
-
-       fclose(pf);
-       *size = file_size;
-       return pdata;
-
-err_free:
-       free(pdata);
-
-error:
-       fclose(pf);
-
-       _E("failed to convert file to buffer (%d)", errno);
-       return NULL;
-}
-
-static int save_data(const unsigned char *data, int size, const char *file_path)
-{
-       FILE *file;
-       int fd;
-
-       file = fopen(file_path, "wb+");
-       if (file == NULL) {
-               _E("To open file is failed : %d", errno);
-               return -1;
-       }
-
-       if (fwrite(data, 1, size, file) != size) {
-               _E("To write file is failed : %d", errno);
-               fclose(file);
-               return -1;
-       }
-
-       fd = fileno(file);
-       if (fd < 0) {
-               _E("To get file descriptor is failed : %d", errno);
-               fclose(file);
-               return -1;
-       }
-
-       if (fsync(fd) < 0) {
-               _E("To be synchronized with the disk is failed : %d", errno);
-               fclose(file);
-               return -1;
-       }
-
-       fclose(file);
-       return 0;
-}
-
-static haptic_feedback_e convert_setting_to_module_level(void)
-{
-       int setting_fb_level;
-
-       if (vconf_get_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, &setting_fb_level) < 0) {
-               setting_fb_level = SETTING_VIB_FEEDBACK_LEVEL3;
-       }
-
-       if (setting_fb_level < HAPTIC_FEEDBACK_0 || setting_fb_level > HAPTIC_FEEDBACK_5)
-               return -1;
-
-       switch (setting_fb_level) {
-       case SETTING_VIB_FEEDBACK_LEVEL0:
-               return HAPTIC_FEEDBACK_0;
-       case SETTING_VIB_FEEDBACK_LEVEL1:
-               return HAPTIC_FEEDBACK_1;
-       case SETTING_VIB_FEEDBACK_LEVEL2:
-               return HAPTIC_FEEDBACK_2;
-       case SETTING_VIB_FEEDBACK_LEVEL3:
-               return HAPTIC_FEEDBACK_3;
-       case SETTING_VIB_FEEDBACK_LEVEL4:
-               return HAPTIC_FEEDBACK_4;
-       case SETTING_VIB_FEEDBACK_LEVEL5:
-               return HAPTIC_FEEDBACK_5;
-       default:
-               break;
-       }
-       return -1;
-}
-/* END of Static Function Section */
-
-API int haptic_get_count(int *device_number)
-{
-       int ret;
-
-       /* check if pointer is valid */
-       if (device_number == NULL) {
-               _E("Invalid parameter : device_number(NULL)");
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       /* request to deviced to get haptic count */
-       ret = dbus_method_sync(VIBRATOR_BUS_NAME,
-                       VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC,
-                       METHOD_GET_COUNT, NULL, NULL);
-       if (ret < 0)
-               return HAPTIC_ERROR_OPERATION_FAILED;
-
-       *device_number = ret;
-       return HAPTIC_ERROR_NONE;
-}
-
-API int haptic_open(haptic_device_e device_index, haptic_device_h *device_handle)
-{
-       char str_index[32];
-       char *arr[1];
-       int ret;
-
-       /* check if index is valid */
-       if (!(device_index == HAPTIC_DEVICE_0 || device_index == HAPTIC_DEVICE_1 ||
-                               device_index == HAPTIC_DEVICE_ALL)) {
-               _E("Invalid parameter : device_index(%d)", device_index);
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       /* check if pointer is valid */
-       if (device_handle == NULL) {
-               _E("Invalid parameter : device_handle(NULL)");
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       snprintf(str_index, sizeof(str_index), "%d", device_index);
-       arr[0] = str_index;
-
-       /* request to deviced to open haptic device */
-       ret = dbus_method_sync(VIBRATOR_BUS_NAME,
-                       VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC,
-                       METHOD_OPEN_DEVICE, "i", arr);
-       if (ret < 0)
-               return HAPTIC_ERROR_OPERATION_FAILED;
-
-       *device_handle = (haptic_device_h)ret;
-       return HAPTIC_ERROR_NONE;
-}
-
-API int haptic_close(haptic_device_h device_handle)
-{
-       char str_handle[32];
-       char *arr[1];
-       int ret;
-
-       /* check if handle is valid */
-       if (!device_handle) {
-               _E("Invalid parameter : device_handle");
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       snprintf(str_handle, sizeof(str_handle), "%u", device_handle);
-       arr[0] = str_handle;
-
-       /* request to deviced to open haptic device */
-       ret = dbus_method_sync(VIBRATOR_BUS_NAME,
-                       VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC,
-                       METHOD_CLOSE_DEVICE, "u", arr);
-       if (ret < 0)
-               return HAPTIC_ERROR_OPERATION_FAILED;
-
-       return HAPTIC_ERROR_NONE;
-}
-
-API int haptic_vibrate_monotone(haptic_device_h device_handle, int duration, haptic_effect_h *effect_handle)
-{
-       return haptic_vibrate_monotone_with_detail(device_handle,
-                                                                                          duration,
-                                                                                          HAPTIC_FEEDBACK_AUTO,
-                                                                                          HAPTIC_PRIORITY_MIN,
-                                                                                          effect_handle);
-}
-
-API int haptic_vibrate_monotone_with_detail(haptic_device_h device_handle,
-                                       int duration,
-                                       haptic_feedback_e feedback,
-                                       haptic_priority_e priority,
-                                       haptic_effect_h *effect_handle)
-{
-       char str_handle[32];
-       char str_duration[32];
-       char str_feedback[32];
-       char str_priority[32];
-       char *arr[4];
-       int ret;
-
-       /* check if handle is valid */
-       if (!device_handle) {
-               _E("Invalid parameter : device_handle");
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       /* check if passed arguments are valid */
-       if (duration < 0 && duration != HAPTIC_DURATION_UNLIMITED) {
-               _E("Invalid parameter : duration(%d)", duration);
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       if (feedback < HAPTIC_FEEDBACK_0 || feedback > HAPTIC_FEEDBACK_AUTO) {
-               _E("Invalid parameter : feedback(%d)", feedback);
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       if (priority < HAPTIC_PRIORITY_MIN || priority > HAPTIC_PRIORITY_HIGH) {
-               _E("Invalid parameter : priority(%d)", priority);
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       /* in case of FEEDBACK_AUTO, should be converted */
-       if (feedback == HAPTIC_FEEDBACK_AUTO)
-               feedback = convert_setting_to_module_level();
-
-       snprintf(str_handle, sizeof(str_handle), "%u", device_handle);
-       arr[0] = str_handle;
-       snprintf(str_duration, sizeof(str_duration), "%d", duration);
-       arr[1] = str_duration;
-       snprintf(str_feedback, sizeof(str_feedback), "%d", feedback);
-       arr[2] = str_feedback;
-       snprintf(str_priority, sizeof(str_priority), "%d", priority);
-       arr[3] = str_priority;
-
-       /* request to deviced to open haptic device */
-       ret = dbus_method_sync(VIBRATOR_BUS_NAME,
-                       VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC,
-                       METHOD_VIBRATE_MONOTONE, "uiii", arr);
-       if (ret < 0)
-               return HAPTIC_ERROR_OPERATION_FAILED;
-
-       if (effect_handle != NULL)
-               *effect_handle = (haptic_effect_h)ret;
-
-       return HAPTIC_ERROR_NONE;
-}
-
-API int haptic_vibrate_file(haptic_device_h device_handle, const char *file_path, haptic_effect_h *effect_handle)
-{
-       unsigned char *vibe_buffer;
-       int size, ret;
-
-       vibe_buffer = convert_file_to_buffer(file_path, &size);
-       if (!vibe_buffer) {
-               _E("Convert file to buffer error");
-               return HAPTIC_ERROR_OPERATION_FAILED;
-       }
-
-       ret = haptic_vibrate_buffers_with_detail(device_handle,
-                                                                                       (const unsigned char *)vibe_buffer,
-                                                                                       size,
-                                                                                       HAPTIC_ITERATION_ONCE,
-                                                                                       HAPTIC_FEEDBACK_AUTO,
-                                                                                       HAPTIC_PRIORITY_MIN,
-                                                                                       effect_handle);
-       free(vibe_buffer);
-       return ret;
-}
-
-API int haptic_vibrate_file_with_detail(haptic_device_h device_handle,
-                                       const char *file_path,
-                                       haptic_iteration_e iteration,
-                                       haptic_feedback_e feedback,
-                                       haptic_priority_e priority,
-                                       haptic_effect_h *effect_handle)
-{
-       unsigned char *vibe_buffer;
-       int size, ret;
-
-       vibe_buffer = convert_file_to_buffer(file_path, &size);
-       if (!vibe_buffer) {
-               _E("Convert file to buffer error");
-               return HAPTIC_ERROR_OPERATION_FAILED;
-       }
-
-       ret = haptic_vibrate_buffers_with_detail(device_handle,
-                                                                                       (const unsigned char *)vibe_buffer,
-                                                                                       size,
-                                                                                       iteration,
-                                                                                       feedback,
-                                                                                       priority,
-                                                                                       effect_handle);
-       free(vibe_buffer);
-       return ret;
-}
-
-API int haptic_vibrate_buffer(haptic_device_h device_handle, const unsigned char *vibe_buffer, haptic_effect_h *effect_handle)
-{
-       return haptic_vibrate_buffers_with_detail(device_handle,
-                                                                                        vibe_buffer,
-                                                                                        TEMP_BUFFER_SIZE,
-                                                                                        HAPTIC_ITERATION_ONCE,
-                                                                                        HAPTIC_FEEDBACK_AUTO,
-                                                                                        HAPTIC_PRIORITY_MIN,
-                                                                                        effect_handle);
-}
-
-API int haptic_vibrate_buffer_with_detail(haptic_device_h device_handle,
-                                       const unsigned char *vibe_buffer,
-                                       haptic_iteration_e iteration,
-                                       haptic_feedback_e feedback,
-                                       haptic_priority_e priority,
-                                       haptic_effect_h *effect_handle)
-{
-       return haptic_vibrate_buffers_with_detail(device_handle,
-                                                                                        vibe_buffer,
-                                                                                        TEMP_BUFFER_SIZE,
-                                                                                        iteration,
-                                                                                        feedback,
-                                                                                        priority,
-                                                                                        effect_handle);
-}
-
-API int haptic_vibrate_buffers(haptic_device_h device_handle,
-                                                       const unsigned char *vibe_buffer,
-                                                       int size,
-                                                       haptic_effect_h *effect_handle)
-{
-       return haptic_vibrate_buffers_with_detail(device_handle,
-                                                                                        vibe_buffer,
-                                                                                        size,
-                                                                                        HAPTIC_ITERATION_ONCE,
-                                                                                        HAPTIC_FEEDBACK_AUTO,
-                                                                                        HAPTIC_PRIORITY_MIN,
-                                                                                        effect_handle);
-}
-
-API int haptic_vibrate_buffers_with_detail(haptic_device_h device_handle,
-                                       const unsigned char *vibe_buffer,
-                                       int size,
-                                       haptic_iteration_e iteration,
-                                       haptic_feedback_e feedback,
-                                       haptic_priority_e priority,
-                                       haptic_effect_h *effect_handle)
-{
-       char str_handle[32];
-       char str_iteration[32];
-       char str_feedback[32];
-       char str_priority[32];
-       char *arr[6];
-       struct dbus_byte bytes;
-       int ret;
-
-       /* check if handle is valid */
-       if (!device_handle) {
-               _E("Invalid parameter : device_handle");
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       /* check if passed arguments are valid */
-       if (vibe_buffer == NULL) {
-               _E("Invalid parameter : vibe_buffer(NULL)");
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       if (iteration < HAPTIC_ITERATION_ONCE || iteration > HAPTIC_ITERATION_INFINITE) {
-               _E("Invalid parameter : iteration(%d)", iteration);
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       if (feedback < HAPTIC_FEEDBACK_0 || feedback > HAPTIC_FEEDBACK_AUTO) {
-               _E("Invalid parameter : feedback(%d)", feedback);
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       if (priority < HAPTIC_PRIORITY_MIN || priority > HAPTIC_PRIORITY_HIGH) {
-               _E("Invalid parameter : priority(%d)", priority);
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       /* in case of FEEDBACK_AUTO, should be converted */
-       if (feedback == HAPTIC_FEEDBACK_AUTO)
-               feedback = convert_setting_to_module_level();
-
-       snprintf(str_handle, sizeof(str_handle), "%u", device_handle);
-       arr[0] = str_handle;
-       bytes.size = size;
-       bytes.data = vibe_buffer;
-       arr[2] = (char *)&bytes;
-       snprintf(str_iteration, sizeof(str_iteration), "%d", iteration);
-       arr[3] = str_iteration;
-       snprintf(str_feedback, sizeof(str_feedback), "%d", feedback);
-       arr[4] = str_feedback;
-       snprintf(str_priority, sizeof(str_priority), "%d", priority);
-       arr[5] = str_priority;
-
-       /* request to deviced to open haptic device */
-       ret = dbus_method_sync(VIBRATOR_BUS_NAME,
-                       VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC,
-                       METHOD_VIBRATE_BUFFER, "uayiii", arr);
-       if (ret < 0)
-               return HAPTIC_ERROR_OPERATION_FAILED;
-
-       if (effect_handle != NULL)
-               *effect_handle = (haptic_effect_h)ret;
-
-       return HAPTIC_ERROR_NONE;
-}
-
-API int haptic_stop_effect(haptic_device_h device_handle, haptic_effect_h effect_handle)
-{
-       return haptic_stop_all_effects(device_handle);
-}
-
-API int haptic_stop_all_effects(haptic_device_h device_handle)
-{
-       char str_handle[32];
-       char *arr[1];
-       int ret;
-
-       /* check if handle is valid */
-       if (!device_handle) {
-               _E("Invalid parameter : device_handle");
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       snprintf(str_handle, sizeof(str_handle), "%u", device_handle);
-       arr[0] = str_handle;
-
-       /* request to deviced to open haptic device */
-       ret = dbus_method_sync(VIBRATOR_BUS_NAME,
-                       VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC,
-                       METHOD_STOP_DEVICE, "u", arr);
-       if (ret < 0)
-               return HAPTIC_ERROR_OPERATION_FAILED;
-
-       return HAPTIC_ERROR_NONE;
-}
-
-API int haptic_get_effect_state(haptic_device_h device_handle, haptic_effect_h effect_handle, haptic_state_e *effect_state)
-{
-       char str_index[32];
-       char *arr[1];
-       int ret;
-
-       /* check if handle is valid */
-       if (!device_handle) {
-               _E("Invalid parameter : device_handle");
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       /* check if pointer is valid */
-       if (effect_state == NULL) {
-               _E("Invalid parameter : effect_state(NULL)");
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       snprintf(str_index, sizeof(str_index), "%d", HAPTIC_DEVICE_0);
-       arr[0] = str_index;
-
-       /* request to deviced to open haptic device */
-       ret = dbus_method_sync(VIBRATOR_BUS_NAME,
-                       VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC,
-                       METHOD_GET_STATE, "i", arr);
-       if (ret < 0)
-               return HAPTIC_ERROR_OPERATION_FAILED;
-
-       *effect_state = (haptic_state_e)ret;
-       return HAPTIC_ERROR_NONE;
-}
-
-API int haptic_create_effect(unsigned char *vibe_buffer,
-                               int max_bufsize,
-                               haptic_effect_element_s *elem_arr,
-                               int max_elemcnt)
-{
-       DBusError err;
-       DBusMessage *msg;
-       dbus_bool_t ret;
-       char str_bufsize[32];
-       char str_elemcnt[32];
-       char *arr[4];
-       char *data;
-       int i, temp, size, ret_val;
-       struct dbus_byte bytes;
-
-       /* check if passed arguments are valid */
-       if (vibe_buffer == NULL) {
-               _E("Invalid parameter : vibe_buffer(NULL)");
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       if (max_bufsize <= 0) {
-               _E("Invalid parameter : max_bufsize(%d)", max_bufsize);
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       if (elem_arr == NULL) {
-               _E("Invalid parameter : elem_arr(NULL)");
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       if (max_elemcnt <= 0) {
-               _E("Invalid parameter : max_elemcnt(%d)", max_elemcnt);
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       /* convert to proper feedback level in case of auto */
-       for (i = 0; i < max_elemcnt; i++) {
-               if (elem_arr[i].haptic_level == HAPTIC_FEEDBACK_AUTO) {
-                       vconf_get_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, &temp);
-                       elem_arr[i].haptic_level = temp*20;
-               }
-       }
-
-       snprintf(str_bufsize, sizeof(str_bufsize), "%d", max_bufsize);
-       arr[0] = str_bufsize;
-       bytes.size = sizeof(haptic_effect_element_s)*max_elemcnt;
-       bytes.data = (unsigned char *)elem_arr;
-       arr[2] = (char *)&bytes;
-       snprintf(str_elemcnt, sizeof(str_elemcnt), "%d", max_elemcnt);
-       arr[3] = str_elemcnt;
-
-       /* request to deviced to open haptic device */
-       msg = dbus_method_sync_with_reply(VIBRATOR_BUS_NAME,
-                       VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC,
-                       METHOD_CREATE_EFFECT, "iayi", arr);
-       if (!msg)
-               return HAPTIC_ERROR_OPERATION_FAILED;
-
-       dbus_error_init(&err);
-
-       ret = dbus_message_get_args(msg, &err, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &data, &size,
-                       DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
-       if (!ret) {
-               _E("no message : [%s:%s]", err.name, err.message);
-               dbus_error_free(&err);
-               goto err;
-       }
-
-       if (ret_val < 0) {
-               _E("%s-%s failed : %d", VIBRATOR_INTERFACE_HAPTIC, METHOD_CREATE_EFFECT, ret_val);
-               goto err;
-       }
-
-       if (max_bufsize < size) {
-               _E("max_bufsize(%d) is smaller than effect buffer size(%d)", max_bufsize, size);
-               goto err;
-       }
-
-       memcpy(vibe_buffer, data, max_bufsize);
-       dbus_message_unref(msg);
-       return HAPTIC_ERROR_NONE;
-err:
-       dbus_message_unref(msg);
-       return HAPTIC_ERROR_OPERATION_FAILED;
-}
-
-API int haptic_save_effect(const unsigned char *vibe_buffer,
-                       int max_bufsize,
-                       const char *file_path)
-{
-       struct stat buf;
-       int ret;
-
-       /* check if passed arguments are valid */
-       if (vibe_buffer == NULL) {
-               _E("Invalid parameter : vibe_buffer(NULL)");
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       if (max_bufsize <= 0) {
-               _E("Invalid parameter : max_bufsize(%d)", max_bufsize);
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       if (file_path == NULL) {
-               _E("Invalid parameter : file_path(NULL)");
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       /* check if the file already exists */
-       if (!stat(file_path, &buf)) {
-               _E("Already exist : file_path(%s)", file_path);
-               return HAPTIC_ERROR_FILE_EXISTS;
-       }
-
-       _D("file path : %s", file_path);
-       ret = save_data(vibe_buffer, max_bufsize, file_path);
-       if (ret < 0) {
-               _E("fail to save data");
-               return HAPTIC_MODULE_OPERATION_FAILED;
-       }
-
-       return HAPTIC_ERROR_NONE;
-}
-
-API int haptic_get_file_duration(haptic_device_h device_handle, const char *file_path, int *file_duration)
-{
-       unsigned char *vibe_buffer;
-       int size, ret;
-
-       vibe_buffer = convert_file_to_buffer(file_path, &size);
-       if (!vibe_buffer) {
-               _E("Convert file to buffer error");
-               return HAPTIC_ERROR_OPERATION_FAILED;
-       }
-
-       ret = haptic_get_buffers_duration(device_handle,
-                                                                        (const unsigned char *)vibe_buffer,
-                                                                        size,
-                                                                        file_duration);
-       free(vibe_buffer);
-       return ret;
-}
-
-API int haptic_get_buffer_duration(haptic_device_h device_handle, const unsigned char *vibe_buffer, int *buffer_duration)
-{
-       return haptic_get_buffers_duration(device_handle,
-                                                                       vibe_buffer,
-                                                                       TEMP_BUFFER_SIZE,
-                                                                       buffer_duration);
-}
-
-API int haptic_get_buffers_duration(haptic_device_h device_handle, const unsigned char *vibe_buffer, int size, int *buffer_duration)
-{
-       char str_handle[32];
-       char *arr[3];
-       struct dbus_byte bytes;
-       int ret;
-
-       /* check if handle is valid */
-       if (!device_handle) {
-               _E("Invalid parameter : device_handle");
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       if (vibe_buffer == NULL) {
-               _E("Invalid parameter : vibe_buffer(NULL)");
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       /* check if pointer is valid */
-       if (buffer_duration == NULL) {
-               _E("Invalid parameter : buffer_duration(NULL)");
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       snprintf(str_handle, sizeof(str_handle), "%u", device_handle);
-       arr[0] = str_handle;
-       bytes.size = size;
-       bytes.data = vibe_buffer;
-       arr[2] = (char *)&bytes;
-
-       /* request to deviced to open haptic device */
-       ret = dbus_method_sync(VIBRATOR_BUS_NAME,
-                       VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC,
-                       METHOD_GET_DURATION, "uay", arr);
-       if (ret < 0)
-               return HAPTIC_ERROR_OPERATION_FAILED;
-
-       *buffer_duration = ret;
-       return HAPTIC_ERROR_NONE;
-}
-
-API int haptic_save_led(const unsigned char *vibe_buffer, int max_bufsize, const char *file_path)
-{
-       struct stat buf;
-       char *arr[3];
-       struct dbus_byte bytes;
-       int ret;
-
-       /* check if passed arguments are valid */
-       if (vibe_buffer == NULL) {
-               _E("Invalid parameter : vibe_buffer(NULL)");
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       if (max_bufsize <= 0) {
-               _E("Invalid parameter : max_bufsize(%d)", max_bufsize);
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       if (file_path == NULL) {
-               _E("Invalid parameter : file_path(NULL)");
-               return HAPTIC_ERROR_INVALID_PARAMETER;
-       }
-
-       /* check if the file already exists */
-       if (!stat(file_path, &buf)) {
-               _E("Already exist : file_path(%s)", file_path);
-               return HAPTIC_ERROR_FILE_EXISTS;
-       }
-
-       bytes.size = max_bufsize;
-       bytes.data = vibe_buffer;
-       arr[1] = (char *)&bytes;
-       arr[2] = (char *)file_path;
-
-       /* request to deviced to open haptic device */
-       ret = dbus_method_sync(VIBRATOR_BUS_NAME,
-                       VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC,
-                       METHOD_SAVE_BINARY, "ays", arr);
-       if (ret < 0)
-               return HAPTIC_ERROR_OPERATION_FAILED;
-
-       return HAPTIC_ERROR_NONE;
-}
diff --git a/src/libdeviced/led.c b/src/libdeviced/led.c
deleted file mode 100644 (file)
index b27c3f3..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
- *
- * 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.
- */
-
-
-#include <stdio.h>
-#include <stdbool.h>
-#include <errno.h>
-
-#include "log.h"
-#include "dbus.h"
-#include "common.h"
-
-#define METHOD_GET_BRIGHTNESS          "GetBrightness"
-#define METHOD_GET_MAX_BRIGHTNESS      "GetMaxBrightness"
-#define METHOD_SET_BRIGHTNESS          "SetBrightness"
-#define METHOD_SET_IR_COMMAND          "SetIrCommand"
-
-API int led_get_brightness(void)
-{
-       DBusError err;
-       DBusMessage *msg;
-       int ret, ret_val;
-
-       msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
-                       DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
-                       METHOD_GET_BRIGHTNESS, NULL, NULL);
-       if (!msg)
-               return -EBADMSG;
-
-       dbus_error_init(&err);
-
-       ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
-       if (!ret) {
-               _E("no message : [%s:%s]", err.name, err.message);
-               dbus_error_free(&err);
-               ret_val = -EBADMSG;
-       }
-
-       dbus_message_unref(msg);
-       return ret_val;
-}
-
-API int led_get_max_brightness(void)
-{
-       DBusError err;
-       DBusMessage *msg;
-       int ret, ret_val;
-
-       msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
-                       DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
-                       METHOD_GET_MAX_BRIGHTNESS, NULL, NULL);
-       if (!msg)
-               return -EBADMSG;
-
-       dbus_error_init(&err);
-
-       ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
-       if (!ret) {
-               _E("no message : [%s:%s]", err.name, err.message);
-               dbus_error_free(&err);
-               ret_val = -EBADMSG;
-       }
-
-       dbus_message_unref(msg);
-       return ret_val;
-}
-
-API int led_set_brightness_with_noti(int val, bool enable)
-{
-       DBusError err;
-       DBusMessage *msg;
-       char *arr[2];
-       char buf_val[32];
-       char buf_noti[32];
-       int ret, ret_val;
-
-       snprintf(buf_val, sizeof(buf_val), "%d", val);
-       arr[0] = buf_val;
-       snprintf(buf_noti, sizeof(buf_noti), "%d", enable);
-       arr[1] = buf_noti;
-
-       msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
-                       DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
-                       METHOD_SET_BRIGHTNESS, "ii", arr);
-       if (!msg)
-               return -EBADMSG;
-
-       dbus_error_init(&err);
-
-       ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
-       if (!ret) {
-               _E("no message : [%s:%s]", err.name, err.message);
-               dbus_error_free(&err);
-               ret_val = -EBADMSG;
-       }
-
-       dbus_message_unref(msg);
-       return ret_val;
-}
diff --git a/src/libdeviced/mmc.c b/src/libdeviced/mmc.c
deleted file mode 100644 (file)
index 6178cf9..0000000
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
- *
- * 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.
- */
-
-
-#include <stdio.h>
-#include <vconf.h>
-#include <errno.h>
-#include <stdbool.h>
-#include <storage.h>
-#include <glib.h>
-
-#include "log.h"
-#include "dbus.h"
-#include "common.h"
-#include "dd-mmc.h"
-
-#define METHOD_REQUEST_SECURE_MOUNT            "RequestSecureMount"
-#define METHOD_REQUEST_SECURE_UNMOUNT  "RequestSecureUnmount"
-
-#define ODE_MOUNT_STATE 1
-
-#define FORMAT_TIMEOUT (120*1000)
-#define STORAGE_MMC 1
-#define BUF_MAX 256
-
-API int mmc_secure_mount(const char *mount_point)
-{
-       if (mount_point == NULL) {
-               return -EINVAL;
-       }
-
-       char *arr[1];
-       arr[0] = (char *)mount_point;
-       return dbus_method_sync(DEVICED_BUS_NAME, DEVICED_PATH_MMC,
-                       DEVICED_INTERFACE_MMC, METHOD_REQUEST_SECURE_MOUNT, "s", arr);
-}
-
-API int mmc_secure_unmount(const char *mount_point)
-{
-       if (mount_point == NULL) {
-               return -EINVAL;
-       }
-
-       char *arr[1];
-       arr[0] = (char *)mount_point;
-       return dbus_method_sync(DEVICED_BUS_NAME, DEVICED_PATH_MMC,
-                       DEVICED_INTERFACE_MMC, METHOD_REQUEST_SECURE_UNMOUNT, "s", arr);
-}
-
-static int get_mmc_primary_id()
-{
-       DBusMessage *reply;
-       DBusMessageIter iter;
-       DBusMessageIter aiter, piter;
-       char *param[1];
-       int type;
-       char *devnode = NULL;
-       bool primary;
-       int ret;
-       int id;
-
-       param[0] = "mmc";
-       reply = dbus_method_sync_with_reply(
-                       STORAGE_BUS_NAME,
-                       DEVICED_PATH_BLOCK_MANAGER,
-                       DEVICED_INTERFACE_BLOCK_MANAGER,
-                       "GetDeviceList", "s", param);
-       if (!reply) {
-               _E("Failed to get mmc storage list");
-               return -EPERM;
-       }
-
-       dbus_message_iter_init(reply, &iter);
-       dbus_message_iter_recurse(&iter, &aiter);
-
-       while (dbus_message_iter_get_arg_type(&aiter) != DBUS_TYPE_INVALID) {
-               devnode = NULL;
-               dbus_message_iter_recurse(&aiter, &piter); /*type*/
-               dbus_message_iter_get_basic(&piter, &type);
-               dbus_message_iter_next(&piter); /* devnode */
-               dbus_message_iter_get_basic(&piter, &devnode);
-               dbus_message_iter_next(&piter); /* syspath */
-               dbus_message_iter_next(&piter); /* fsusage */
-               dbus_message_iter_next(&piter); /* fstype */
-               dbus_message_iter_next(&piter); /* fsversion */
-               dbus_message_iter_next(&piter); /* fsuuid */
-               dbus_message_iter_next(&piter); /* readonly */
-               dbus_message_iter_next(&piter); /* mountpath */
-               dbus_message_iter_next(&piter); /* state */
-               dbus_message_iter_next(&piter); /* primary */
-               dbus_message_iter_get_basic(&piter, &primary);
-               dbus_message_iter_next(&piter); /* flags */
-               dbus_message_iter_next(&piter); /* storage id */
-               dbus_message_iter_get_basic(&piter, &id);
-               dbus_message_iter_next(&aiter);
-
-               if (type == STORAGE_MMC && primary && devnode)
-                       break;
-       }
-
-       if (devnode)
-               ret = id;
-       else
-               ret = -ENODEV;
-
-       dbus_message_unref(reply);
-       return ret;
-}
-
-static void mount_mmc_cb(void *data, DBusMessage *msg, DBusError *err)
-{
-       struct mmc_contents *mmc_data = (struct mmc_contents*)data;
-       DBusError r_err;
-       int r, mmc_ret;
-
-       _D("mount_mmc_cb called");
-
-       if (!msg) {
-               _E("no message [%s:%s]", err->name, err->message);
-               mmc_ret = -EBADMSG;
-               goto exit;
-       }
-
-       dbus_error_init(&r_err);
-       r = dbus_message_get_args(msg, &r_err, DBUS_TYPE_INT32, &mmc_ret, DBUS_TYPE_INVALID);
-       if (!r) {
-               _E("no message [%s:%s]", r_err.name, r_err.message);
-               dbus_error_free(&r_err);
-               mmc_ret = -EBADMSG;
-               goto exit;
-       }
-
-       _I("Mount State : %d", mmc_ret);
-
-exit:
-       (mmc_data->mmc_cb)(mmc_ret, mmc_data->user_data);
-}
-
-API int deviced_request_mount_mmc(struct mmc_contents *mmc_data)
-{
-       void (*mount_cb)(void*, DBusMessage*, DBusError*) = NULL;
-       void *data = NULL;
-       int ret;
-       int id;
-       char buf_id[32];
-       char *param[2];
-
-       if (mmc_data && mmc_data->mmc_cb) {
-               _I("Mount callback exists");
-               mount_cb = mount_mmc_cb;
-               data = mmc_data;
-       }
-
-       id = get_mmc_primary_id();
-       if (id < 0)
-               return id;
-
-       snprintf(buf_id, sizeof(buf_id), "%d", id);
-       param[0] = buf_id;
-       param[1] = "";
-       ret = dbus_method_async_with_reply(STORAGE_BUS_NAME, DEVICED_PATH_BLOCK_MANAGER,
-                       DEVICED_INTERFACE_BLOCK_MANAGER, "Mount", "is", param,
-                       mount_cb, -1, data);
-
-       _I("Mount Request %s", ret == 0 ? "Success" : "Failed");
-
-       return ret;
-}
-
-static void unmount_mmc_cb(void *data, DBusMessage *msg, DBusError *err)
-{
-       struct mmc_contents *mmc_data = (struct mmc_contents*)data;
-       DBusError r_err;
-       int r, mmc_ret;
-
-       _D("unmount_mmc_cb called");
-
-       if (!msg) {
-               _E("no message [%s:%s]", err->name, err->message);
-               mmc_ret = -EBADMSG;
-               goto exit;
-       }
-
-       dbus_error_init(&r_err);
-       r = dbus_message_get_args(msg, &r_err, DBUS_TYPE_INT32, &mmc_ret, DBUS_TYPE_INVALID);
-       if (!r) {
-               _E("no message [%s:%s]", r_err.name, r_err.message);
-               dbus_error_free(&r_err);
-               mmc_ret = -EBADMSG;
-               goto exit;
-       }
-
-       _I("Unmount State : %d", mmc_ret);
-
-exit:
-       (mmc_data->mmc_cb)(mmc_ret, mmc_data->user_data);
-}
-
-API int deviced_request_unmount_mmc(struct mmc_contents *mmc_data, int option)
-{
-       void (*unmount_cb)(void*, DBusMessage*, DBusError*) = NULL;
-       void *data = NULL;
-       char buf_opt[32];
-       char buf_id[32];
-       int ret;
-       int id;
-       char *param[2];
-
-       if (option < 0 || option > 1)
-               return -EINVAL;
-
-       if (mmc_data && mmc_data->mmc_cb) {
-               _I("Mount callback exists");
-               unmount_cb = unmount_mmc_cb;
-               data = mmc_data;
-       }
-
-       id = get_mmc_primary_id();
-       if (id < 0)
-               return id;
-
-       snprintf(buf_id, sizeof(buf_id), "%d", id);
-       param[0] = buf_id;
-       snprintf(buf_opt, sizeof(buf_opt), "%d", option);
-       param[1] = buf_opt;
-       ret = dbus_method_async_with_reply(STORAGE_BUS_NAME, DEVICED_PATH_BLOCK_MANAGER,
-                       DEVICED_INTERFACE_BLOCK_MANAGER, "Unmount", "ii", param,
-                       unmount_cb, -1, data);
-
-       _I("Unmount Request %s", ret == 0 ? "Success" : "Failed");
-
-       return ret;
-}
-
-static void format_mmc_cb(void *data, DBusMessage *msg, DBusError *err)
-{
-       struct mmc_contents *mmc_data = (struct mmc_contents*)data;
-       DBusError r_err;
-       int r, mmc_ret;
-
-       _D("format_mmc_cb called");
-
-       if (!msg) {
-               _E("no message [%s:%s]", err->name, err->message);
-               mmc_ret = -EBADMSG;
-               goto exit;
-       }
-
-       dbus_error_init(&r_err);
-       r = dbus_message_get_args(msg, &r_err, DBUS_TYPE_INT32, &mmc_ret, DBUS_TYPE_INVALID);
-       if (!r) {
-               _E("no message [%s:%s]", r_err.name, r_err.message);
-               dbus_error_free(&r_err);
-               mmc_ret = -EBADMSG;
-               goto exit;
-       }
-
-       _I("Format State : %d", mmc_ret);
-
-exit:
-       (mmc_data->mmc_cb)(mmc_ret, mmc_data->user_data);
-}
-
-API int deviced_request_format_mmc(struct mmc_contents *mmc_data)
-{
-       return deviced_format_mmc(mmc_data, 1);
-}
-
-API int deviced_format_mmc(struct mmc_contents *mmc_data, int option)
-{
-       void (*format_cb)(void*, DBusMessage*, DBusError*) = NULL;
-       void *data = NULL;
-       char buf_opt[32];
-       char buf_id[32];
-       int ret;
-       int id;
-       char *param[2];
-
-       if (option < 0 || option > 1)
-               return -EINVAL;
-
-       if (mmc_data && mmc_data->mmc_cb) {
-               _I("Mount callback exists");
-               format_cb = format_mmc_cb;
-               data = mmc_data;
-       }
-
-       id = get_mmc_primary_id();
-       if (id < 0)
-               return id;
-
-       snprintf(buf_id, sizeof(buf_id), "%d", id);
-       param[0] = buf_id;
-       snprintf(buf_opt, sizeof(buf_opt), "%d", option);
-       param[1] = buf_opt;
-       ret = dbus_method_async_with_reply(STORAGE_BUS_NAME, DEVICED_PATH_BLOCK_MANAGER,
-                       DEVICED_INTERFACE_BLOCK_MANAGER, "Format", "ii", param,
-                       format_cb, FORMAT_TIMEOUT, data);
-
-       _I("Format Request %s", ret == 0 ? "Success" : "Failed");
-
-       return ret;
-}
diff --git a/src/libdeviced/storage.c b/src/libdeviced/storage.c
deleted file mode 100644 (file)
index 23fbe8d..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
- *
- * 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.
- */
-
-
-#include <stdio.h>
-#include <stdbool.h>
-#include <sys/stat.h>
-#include <vconf.h>
-#include <errno.h>
-#include <storage.h>
-
-#include "log.h"
-#include "common.h"
-#include "dd-deviced.h"
-#include "dd-storage.h"
-
-struct storage_info {
-       storage_type_e type;
-       char *path;
-       size_t len;
-};
-
-static bool storage_get_info(int storage_id, storage_type_e type,
-               storage_state_e state, const char *path, void *user_data)
-{
-       struct storage_info *info;
-
-       if (storage_id < 0 || !path || !user_data)
-               return true;
-
-       info = (struct storage_info *)user_data;
-       if (type != info->type)
-               return true;
-
-       if (state != STORAGE_STATE_MOUNTED &&
-               state != STORAGE_STATE_MOUNTED_READ_ONLY)
-               return true;
-
-       snprintf(info->path, info->len, "%s", path);
-       return false;
-}
-
-API int storage_get_path(int type, char *path, int size)
-{
-       static char int_path[256] = { 0, };
-       static char ext_path[256] = { 0, };
-       int ret;
-       struct storage_info info;
-
-       if (!path || size <= 0)
-               return -1;
-
-       switch (type) {
-       case STORAGE_DEFAULT:
-       case STORAGE_INTERNAL:
-               if (strlen(int_path) > 0) {
-                       snprintf(path, size, "%s", int_path);
-                       return 0;
-               }
-               info.path = int_path;
-               info.len = sizeof(int_path);
-               info.type = type;
-               break;
-       case STORAGE_EXTERNAL:
-               if (strlen(ext_path) > 0) {
-                       snprintf(path, size, "%s", ext_path);
-                       return 0;
-               }
-               info.path = ext_path;
-               info.len = sizeof(ext_path);
-               info.type = type;
-               break;
-       default:
-               _E("Invalid type (%d)", type);
-               return -1;
-       }
-
-       ret = storage_foreach_device_supported(storage_get_info, &info);
-       if (ret != STORAGE_ERROR_NONE) {
-               _E("Failed to get storage information (%d)", ret);
-               return -1;
-       }
-
-       if (strlen(info.path) == 0)
-               return -1;
-
-       snprintf(path, size, "%s", info.path);
-       return 0;
-}
diff --git a/src/libdeviced/usbhost.c b/src/libdeviced/usbhost.c
deleted file mode 100644 (file)
index 1cb0d1d..0000000
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
- *
- * 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.
- */
-
-
-#include <stdio.h>
-#include <errno.h>
-#include <E_DBus.h>
-
-#include "log.h"
-#include "common.h"
-#include "dbus.h"
-#include "dd-usbhost.h"
-#include "core/list.h"
-
-#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
-
-#define METHOD_OPEN_DEVICE                "OpenDevice"
-#define METHOD_REQUEST_STORAGE_INFO_ALL   "StorageInfoAll"
-#define METHOD_REQUEST_STORAGE_MOUNT      "StorageMount"
-#define METHOD_REQUEST_STORAGE_UNMOUNT    "StorageUnmount"
-#define METHOD_REQUEST_STORAGE_FORMAT     "StorageFormat"
-#define SIGNAL_NAME_USB_STORAGE_CHANGED   "usb_storage_changed"
-#define SIGNAL_NAME_USB_DEVICE_CHANGED    "ChangedDevice"
-#define RETRY_MAX 5
-
-union action {
-       void (*storage)(char *type, char *path, int mount, void *param);
-       void (*device)(struct usbhost_device *device, int state, void *data);
-};
-
-struct signal_handler {
-       const char *name;
-       E_DBus_Signal_Handler *handler;
-       union action action;
-       void *data;
-};
-
-static dd_list *handlers;
-
-static E_DBus_Connection *conn = NULL;
-
-static int register_edbus_signal_handler(const char *path, const char *interface,
-               const char *name, E_DBus_Signal_Cb cb,
-               union action action,
-               void *data)
-{
-       int ret;
-       struct signal_handler *handler = NULL;
-
-       if (!conn) {
-               _E("Use init_usbhost_signal() first to use this function");
-               ret = -1;
-               goto out;
-       }
-
-       handler = calloc(1, sizeof(*handler));
-       if (!handler) {
-               _E("No memory");
-               ret = -1;
-               goto out;
-       }
-       handler->name = name;
-       handler->handler = e_dbus_signal_handler_add(conn, NULL, path,
-                                       interface, name, cb, NULL);
-       if (!(handler->handler)) {
-               _E("fail to add edbus handler");
-               ret = -1;
-               goto out;
-       }
-
-       handler->action = action;
-       handler->data = data;
-
-       DD_LIST_APPEND(handlers, handler);
-
-       return 0;
-
-out:
-       free(handler);
-       return ret;
-}
-
-static void storage_signal_handler(void *data, DBusMessage *msg)
-{
-       char *type, *path;
-       int mount;
-       DBusError err;
-       dd_list *elem;
-       struct signal_handler *handler;
-
-       if (dbus_message_is_signal(msg, DEVICED_INTERFACE_USBHOST, SIGNAL_NAME_USB_STORAGE_CHANGED) == 0) {
-               _E("The signal is not for storage changed");
-               return;
-       }
-
-       dbus_error_init(&err);
-
-       if (dbus_message_get_args(msg, &err,
-                               DBUS_TYPE_STRING, &type,
-                               DBUS_TYPE_STRING, &path,
-                               DBUS_TYPE_INT32, &mount,
-                               DBUS_TYPE_INVALID) == 0) {
-               _E("Failed to get storage info");
-               return;
-       }
-
-       DD_LIST_FOREACH(handlers, elem, handler) {
-               if (strcmp(handler->name, SIGNAL_NAME_USB_STORAGE_CHANGED))
-                       continue;
-
-               if (handler->action.storage)
-                       handler->action.storage(type, path, mount, handler->data);
-       }
-}
-
-static void device_signal_handler(void *data, DBusMessage *msg)
-{
-       char *path;
-       struct usbhost_device device;
-       int state;
-       DBusError err;
-       struct signal_handler *handler;
-       dd_list *element;
-
-       if (dbus_message_is_signal(msg, DEVICED_INTERFACE_USBHOST, SIGNAL_NAME_USB_DEVICE_CHANGED) == 0) {
-               _E("The signal is not ChangedDevice");
-               return;
-       }
-
-       dbus_error_init(&err);
-       if (dbus_message_get_args(msg, &err,
-                               DBUS_TYPE_INT32, &state,
-                               DBUS_TYPE_STRING, &path,
-                               DBUS_TYPE_INT32, &device.baseclass,
-                               DBUS_TYPE_INT32, &device.subclass,
-                               DBUS_TYPE_INT32, &device.protocol,
-                               DBUS_TYPE_INT32, &device.vendorid,
-                               DBUS_TYPE_INT32, &device.productid,
-                               DBUS_TYPE_STRING, &device.manufacturer,
-                               DBUS_TYPE_STRING, &device.product,
-                               DBUS_TYPE_STRING, &device.serial,
-                               DBUS_TYPE_INVALID) == 0) {
-               _E("Failed to get device info");
-               return;
-       }
-
-       strncpy(device.devpath, path, PATH_MAX);
-
-       DD_LIST_FOREACH(handlers, element, handler) {
-               if (strcmp(handler->name, SIGNAL_NAME_USB_DEVICE_CHANGED))
-                       continue;
-
-               if (handler->action.device)
-                       handler->action.device(&device, state, handler->data);
-       }
-}
-
-API int init_usbhost_signal(void)
-{
-       int retry;
-
-       if (conn)
-               return 0;
-
-       retry = 0;
-       do {
-               if (e_dbus_init() > 0)
-                       break;
-               if (retry >= RETRY_MAX)
-                       return -1;
-       } while (retry++ < RETRY_MAX);
-
-       conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
-       if (!conn) {
-               _E("Failed to get edbus bus");
-               e_dbus_shutdown();
-               return -1;
-       }
-
-       return 0;
-}
-
-API void deinit_usbhost_signal(void)
-{
-       dd_list *n, *next;
-       struct signal_handler *handler;
-
-       if (!conn)
-               return;
-
-       DD_LIST_FOREACH_SAFE(handlers, n, next, handler) {
-               DD_LIST_REMOVE(handlers, handler);
-               if (handler->handler) {
-                       e_dbus_signal_handler_del(conn, handler->handler);
-                       handler->handler = NULL;
-               }
-
-               free(handler);
-       }
-
-       e_dbus_connection_close(conn);
-       conn = NULL;
-
-       e_dbus_shutdown();
-}
-
-API int request_usb_storage_info(void)
-{
-       return dbus_method_sync(DEVICED_BUS_NAME, DEVICED_PATH_USBHOST,
-                       DEVICED_INTERFACE_USBHOST, METHOD_REQUEST_STORAGE_INFO_ALL, NULL, NULL);
-}
-
-API int register_usb_storage_change_handler(
-               void (*storage_changed)(char *type, char *path, int mount, void *param),
-               void *data)
-{
-       union action action;
-       if (!storage_changed)
-               return -EINVAL;
-
-       action.storage = storage_changed;
-       return register_edbus_signal_handler(DEVICED_PATH_USBHOST,
-                       DEVICED_INTERFACE_USBHOST,
-                       SIGNAL_NAME_USB_STORAGE_CHANGED,
-                       storage_signal_handler,
-                       action,
-                       data);
-}
-
-API int register_usb_device_change_handler(
-               void (*device_changed)(struct usbhost_device *device, int state, void *data),
-               void *data)
-{
-       union action action;
-       if (!device_changed)
-               return -EINVAL;
-
-       action.device = device_changed;
-       return register_edbus_signal_handler(DEVICED_PATH_USBHOST,
-                       DEVICED_INTERFACE_USBHOST,
-                       SIGNAL_NAME_USB_DEVICE_CHANGED,
-                       device_signal_handler,
-                       action,
-                       data);
-}
-
-API int unregister_usb_storage_change_handler(void)
-{
-       dd_list *n, *next;
-       struct signal_handler *handler;
-
-       DD_LIST_FOREACH_SAFE(handlers, n, next, handler) {
-               if (strcmp(handler->name, SIGNAL_NAME_USB_STORAGE_CHANGED))
-                       continue;
-               if (handler->handler == NULL)
-                       continue;
-
-               e_dbus_signal_handler_del(conn, handler->handler);
-               DD_LIST_REMOVE(handlers, handler);
-               free(handler);
-       }
-
-       return 0;
-}
-
-API int unregister_usb_device_change_handler(
-               void (*device_changed)(struct usbhost_device *device, int state, void *data))
-{
-       dd_list *n, *next;
-       struct signal_handler *handler;
-
-       DD_LIST_FOREACH_SAFE(handlers, n, next, handler) {
-               if (strcmp(handler->name, SIGNAL_NAME_USB_DEVICE_CHANGED))
-                       continue;
-               if (handler->handler == NULL)
-                       continue;
-               if (handler->action.device != device_changed)
-                       continue;
-
-               e_dbus_signal_handler_del(conn, handler->handler);
-               DD_LIST_REMOVE(handlers, handler);
-               free(handler);
-       }
-
-       return -1;
-}
-
-API int mount_usb_storage(char *path)
-{
-       char *param[1];
-
-       if (!path)
-               return -1;
-
-       param[0] = path;
-       return dbus_method_sync(DEVICED_BUS_NAME, DEVICED_PATH_USBHOST,
-                       DEVICED_INTERFACE_USBHOST, METHOD_REQUEST_STORAGE_MOUNT, "s", param);
-}
-
-API int unmount_usb_storage(char *path)
-{
-       char *param[1];
-
-       if (!path)
-               return -1;
-
-       param[0] = path;
-       return dbus_method_sync(DEVICED_BUS_NAME, DEVICED_PATH_USBHOST,
-                       DEVICED_INTERFACE_USBHOST, METHOD_REQUEST_STORAGE_UNMOUNT, "s", param);
-}
-
-API int format_usb_storage(char *path)
-{
-       char *param[1];
-
-       if (!path)
-               return -1;
-
-       param[0] = path;
-       return dbus_method_sync(DEVICED_BUS_NAME, DEVICED_PATH_USBHOST,
-                       DEVICED_INTERFACE_USBHOST, METHOD_REQUEST_STORAGE_FORMAT, "s", param);
-}
-
-API int open_usb_device(char *path, int *fd)
-{
-       DBusMessage *reply;
-       DBusError err;
-       int ret, rfd;
-       dbus_bool_t result;
-
-       if (!fd || !path)
-               return -EINVAL;
-
-       dbus_error_init(&err);
-
-       reply = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
-                       DEVICED_PATH_USBHOST,
-                       DEVICED_INTERFACE_USBHOST,
-                       METHOD_OPEN_DEVICE,
-                       "s", &path);
-
-       if (!reply) {
-               _E("Unable to open USB device");
-               return -1;
-       }
-
-       result = dbus_message_get_args(reply, &err, DBUS_TYPE_INT32, &ret, DBUS_TYPE_UNIX_FD, &rfd, DBUS_TYPE_INVALID);
-       if (!result) {
-               _E("Failed to get arguments: %s", err.message);
-               return -1;
-       }
-
-       if (ret >= 0)
-               *fd = rfd;
-
-       return ret;
-}