handle : change file name "peripheral_bus_util" to peripheral_handle_common" 01/161001/4
authorSegwon <segwon.han@samsung.com>
Tue, 21 Nov 2017 05:08:00 +0000 (14:08 +0900)
committerSegwon Han <segwon.han@samsung.com>
Tue, 21 Nov 2017 06:28:47 +0000 (06:28 +0000)
 - remove unused function in this file
 - move into handle directory

Change-Id: Ie2bfdeab0def13a5c247b032b8ff448f659fe8b5
Signed-off-by: Segwon <segwon.han@samsung.com>
15 files changed:
CMakeLists.txt
include/handle/peripheral_handle_common.h [moved from include/peripheral_bus_util.h with 63% similarity]
include/peripheral_log.h
src/gdbus/peripheral_gdbus_gpio.c
src/gdbus/peripheral_gdbus_i2c.c
src/gdbus/peripheral_gdbus_pwm.c
src/gdbus/peripheral_gdbus_spi.c
src/gdbus/peripheral_gdbus_uart.c
src/handle/peripheral_handle_common.c [new file with mode: 0644]
src/handle/peripheral_handle_gpio.c
src/handle/peripheral_handle_i2c.c
src/handle/peripheral_handle_pwm.c
src/handle/peripheral_handle_spi.c
src/handle/peripheral_handle_uart.c
src/peripheral_bus_util.c [deleted file]

index fbf1660..de5c17b 100644 (file)
@@ -24,7 +24,6 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/gdbus)
 SET(PERIPHERAL-BUS "peripheral-bus")
 SET(SRCS
        src/peripheral_bus.c
-       src/peripheral_bus_util.c
        src/peripheral_bus_board.c
        src/privilege_checker.c
        src/gdbus/peripheral_io_gdbus.c
@@ -33,6 +32,7 @@ SET(SRCS
        src/gdbus/peripheral_gdbus_pwm.c
        src/gdbus/peripheral_gdbus_spi.c
        src/gdbus/peripheral_gdbus_uart.c
+       src/handle/peripheral_handle_common.c
        src/handle/peripheral_handle_pwm.c
        src/handle/peripheral_handle_i2c.c
        src/handle/peripheral_handle_gpio.c
similarity index 63%
rename from include/peripheral_bus_util.h
rename to include/handle/peripheral_handle_common.h
index 45b8053..ef5cc17 100644 (file)
  * limitations under the License.
  */
 
-#ifndef __PERIPHERAL_UTIL_H__
-#define __PERIPHERAL_UTIL_H__
+#ifndef __PERIPHERAL_HANDLE_COMMON_H__
+#define __PERIPHERAL_HANDLE_COMMON_H__
 
-GVariant *peripheral_bus_build_variant_ay(uint8_t *data, int length);
-pb_data_h peripheral_bus_data_new(GList **plist);
-int peripheral_bus_data_free(pb_data_h handle);
+#include <gio/gio.h>
 
-int peripheral_bus_get_client_info(
-               GDBusMethodInvocation *invocation,
-               peripheral_bus_s *pb_data,
-               pb_client_info_s *client_info);
+#include "peripheral_bus.h"
 
-int peripheral_bus_handle_is_valid(
-               GDBusMethodInvocation *invocation,
-               pb_data_h handle,
-               GList *list);
+pb_data_h peripheral_bus_data_new(GList **plist);
+int peripheral_bus_data_free(pb_data_h handle);
 
-#endif /* __PERIPHERAL_UTIL_H__ */
+#endif /* __PERIPHERAL_HANDLE_COMMON_H__ */
index 7198845..a1c91bd 100644 (file)
@@ -16,7 +16,7 @@
 #ifndef __PERIPHERAL_LOG_H__
 #define __PERIPHERAL_LOG_H__
 
-#include <unistd.h>
+// #include <unistd.h>
 #include <dlog.h>
 
 #undef LOG_TAG
index 2401f8d..5bd576b 100644 (file)
@@ -21,7 +21,6 @@
 #include "peripheral_bus.h"
 #include "peripheral_handle_gpio.h"
 #include "peripheral_log.h"
-#include "peripheral_bus_util.h"
 #include "peripheral_gdbus_gpio.h"
 #include "privilege_checker.h"
 
index f4dea91..5ba2da4 100644 (file)
@@ -20,7 +20,6 @@
 #include "peripheral_bus.h"
 #include "peripheral_handle_i2c.h"
 #include "peripheral_log.h"
-#include "peripheral_bus_util.h"
 #include "peripheral_gdbus_i2c.h"
 #include "privilege_checker.h"
 
index 4de63b7..ac42ff2 100644 (file)
@@ -20,7 +20,6 @@
 #include "peripheral_bus.h"
 #include "peripheral_handle_pwm.h"
 #include "peripheral_log.h"
-#include "peripheral_bus_util.h"
 #include "peripheral_gdbus_pwm.h"
 #include "privilege_checker.h"
 
index 3427329..df7b9e8 100644 (file)
@@ -20,7 +20,6 @@
 #include "peripheral_bus.h"
 #include "peripheral_handle_spi.h"
 #include "peripheral_log.h"
-#include "peripheral_bus_util.h"
 #include "peripheral_gdbus_spi.h"
 #include "privilege_checker.h"
 
index bbb09a6..c0698e1 100644 (file)
@@ -20,7 +20,6 @@
 #include "peripheral_bus.h"
 #include "peripheral_handle_uart.h"
 #include "peripheral_log.h"
-#include "peripheral_bus_util.h"
 #include "peripheral_gdbus_uart.h"
 #include "privilege_checker.h"
 
diff --git a/src/handle/peripheral_handle_common.c b/src/handle/peripheral_handle_common.c
new file mode 100644 (file)
index 0000000..bbd6b61
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2017 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 <stdlib.h>
+
+#include "peripheral_handle_common.h"
+#include "peripheral_log.h"
+
+pb_data_h peripheral_bus_data_new(GList **plist)
+{
+       GList *list = *plist;
+       pb_data_h handle;
+
+       handle = (pb_data_h)calloc(1, sizeof(peripheral_bus_data_s));
+       if (handle == NULL) {
+               _E("failed to allocate peripheral_bus_data_s");
+               return NULL;
+       }
+
+       *plist = g_list_append(list, handle);
+
+       return handle;
+}
+
+int peripheral_bus_data_free(pb_data_h handle)
+{
+       GList *list = *handle->list;
+       GList *link;
+
+       RETVM_IF(handle == NULL, -1, "handle is null");
+
+       link = g_list_find(list, handle);
+       if (!link) {
+               _E("handle does not exist in list");
+               return -1;
+       }
+
+       *handle->list = g_list_remove_link(list, link);
+
+       free(handle);
+       g_list_free(link);
+
+       return 0;
+}
\ No newline at end of file
index 6ee068d..9c788ed 100644 (file)
@@ -26,7 +26,7 @@
 #include "peripheral_interface_gpio.h"
 #include "peripheral_bus.h"
 #include "peripheral_log.h"
-#include "peripheral_bus_util.h"
+#include "peripheral_handle_common.h"
 
 static bool peripheral_bus_gpio_is_available(int pin, peripheral_bus_s *pb_data)
 {
index 88f8156..5cea9c9 100644 (file)
@@ -23,7 +23,7 @@
 #include "peripheral_interface_i2c.h"
 #include "peripheral_bus.h"
 #include "peripheral_log.h"
-#include "peripheral_bus_util.h"
+#include "peripheral_handle_common.h"
 
 #define INITIAL_BUFFER_SIZE 128
 #define MAX_BUFFER_SIZE 8192
index a9c657c..73d46e8 100644 (file)
@@ -23,7 +23,7 @@
 #include "peripheral_interface_pwm.h"
 #include "peripheral_bus.h"
 #include "peripheral_log.h"
-#include "peripheral_bus_util.h"
+#include "peripheral_handle_common.h"
 
 static bool peripheral_bus_pwm_is_available(int chip, int pin, peripheral_bus_s *pb_data)
 {
index e1d7f07..52a7331 100644 (file)
@@ -23,7 +23,7 @@
 #include "peripheral_interface_spi.h"
 #include "peripheral_bus.h"
 #include "peripheral_log.h"
-#include "peripheral_bus_util.h"
+#include "peripheral_handle_common.h"
 
 static bool __peripheral_bus_spi_is_available(int bus, int cs, peripheral_bus_s *pb_data)
 {
index a73007a..bc87d5d 100644 (file)
@@ -24,7 +24,7 @@
 #include "peripheral_io_gdbus.h"
 #include "peripheral_bus.h"
 #include "peripheral_log.h"
-#include "peripheral_bus_util.h"
+#include "peripheral_handle_common.h"
 
 #define INITIAL_BUFFER_SIZE 128
 #define MAX_BUFFER_SIZE 8192
diff --git a/src/peripheral_bus_util.c b/src/peripheral_bus_util.c
deleted file mode 100644 (file)
index 075d9ae..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (c) 2017 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 <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <gio/gio.h>
-
-#include "peripheral_bus.h"
-#include "peripheral_log.h"
-
-GVariant *peripheral_bus_build_variant_ay(uint8_t *data, int length)
-{
-       GVariantBuilder *builder;
-       GVariant *variant;
-       int i;
-
-       if (data == NULL)
-               return NULL;
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
-
-       for (i = 0; i < length; i++)
-               g_variant_builder_add(builder, "(y)", data[i]);
-
-       variant = g_variant_new("a(y)", builder);
-       g_variant_builder_unref(builder);
-
-       return variant;
-}
-
-pb_data_h peripheral_bus_data_new(GList **plist)
-{
-       GList *list = *plist;
-       pb_data_h handle;
-
-       handle = (pb_data_h)calloc(1, sizeof(peripheral_bus_data_s));
-       if (handle == NULL) {
-               _E("failed to allocate peripheral_bus_data_s");
-               return NULL;
-       }
-
-       *plist = g_list_append(list, handle);
-
-       return handle;
-}
-
-int peripheral_bus_data_free(pb_data_h handle)
-{
-       GList *list = *handle->list;
-       GList *link;
-
-       RETVM_IF(handle == NULL, -1, "handle is null");
-
-       link = g_list_find(list, handle);
-       if (!link) {
-               _E("handle does not exist in list");
-               return -1;
-       }
-
-       *handle->list = g_list_remove_link(list, link);
-
-       free(handle);
-       g_list_free(link);
-
-       return 0;
-}
-
-// TODO : This function will be removed (unused)
-int peripheral_bus_get_client_info(
-               GDBusMethodInvocation *invocation,
-               peripheral_bus_s *pb_data,
-               pb_client_info_s *client_info)
-{
-       guint pid = 0;
-       GError *error = NULL;
-       GVariant *_ret;
-       const gchar *id;
-
-       id = g_dbus_method_invocation_get_sender(invocation);
-       if (id == NULL) {
-               _E("Current id is NULL");
-               return -1;
-       }
-
-       _ret = g_dbus_connection_call_sync(pb_data->connection,
-               "org.freedesktop.DBus",
-               "/org/freedesktop/DBus",
-               "org.freedesktop.DBus",
-               "GetConnectionUnixProcessID",
-               g_variant_new("(s)", id),
-               NULL,
-               G_DBUS_CALL_FLAGS_NONE,
-               -1,
-               NULL,
-               &error);
-
-       if (_ret == NULL) {
-               _E("Failed to get client pid, %s", error->message);
-               g_error_free(error);
-
-               return -1;
-       }
-
-       g_variant_get(_ret, "(u)", &pid);
-       g_variant_unref(_ret);
-
-       client_info->pid = (pid_t)pid;
-       client_info->pgid = getpgid(pid);
-       client_info->id = strdup(id);
-
-       return 0;
-}
-
-int peripheral_bus_handle_is_valid(
-               GDBusMethodInvocation *invocation,
-               pb_data_h handle,
-               GList *list)
-{
-       const gchar *id;
-
-       if (!g_list_find(list, handle)) {
-               _E("Cannot find handle");
-               return -1;
-       }
-
-       id = g_dbus_method_invocation_get_sender(invocation);
-       if (id == NULL) {
-               _E("Current id is NULL");
-               return -1;
-       }
-
-       if (strcmp(handle->client_info.id, id)) {
-               _E("Invalid access, handle id : %s, current id : %s", handle->client_info.id, id);
-               return -1;
-       }
-
-       return 0;
-}