SET(SRCS
src/daemon/peripheral_bus.c
src/daemon/peripheral_bus_util.c
- src/daemon/peripheral_bus_gdbus_gpio.c
- src/daemon/peripheral_bus_gdbus_i2c.c
- src/daemon/peripheral_bus_gdbus_pwm.c
- src/daemon/peripheral_bus_gdbus_spi.c
- src/daemon/peripheral_bus_gdbus_uart.c
+ src/daemon/peripheral_gdbus_gpio.c
+ src/daemon/peripheral_gdbus_i2c.c
+ src/daemon/peripheral_gdbus_pwm.c
+ src/daemon/peripheral_gdbus_spi.c
+ src/daemon/peripheral_gdbus_uart.c
src/daemon/peripheral_handle_pwm.c
src/daemon/peripheral_handle_i2c.c
src/daemon/peripheral_handle_gpio.c
+++ /dev/null
-/*
- * Copyright (c) 2016-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.
- */
-
-#ifndef __PERIPHERAL_BUS_GDBUS_GPIO_H__
-#define __PERIPHERAL_BUS_GDBUS_GPIO_H__
-
-#include "peripheral_io_gdbus.h"
-
-gboolean handle_gpio_open(
- PeripheralIoGdbusGpio *gpio,
- GDBusMethodInvocation *invocation,
- GUnixFDList *fd_list,
- gint pin,
- gpointer user_data);
-
-#endif /* __PERIPHERAL_BUS_GDBUS_GPIO_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2016-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.
- */
-
-#ifndef __PERIPHERAL_BUS_GDBUS_I2C_H__
-#define __PERIPHERAL_BUS_GDBUS_I2C_H__
-
-#include "peripheral_io_gdbus.h"
-
-gboolean handle_i2c_open(
- PeripheralIoGdbusI2c *i2c,
- GDBusMethodInvocation *invocation,
- GUnixFDList *fd_list,
- gint bus,
- gint address,
- gpointer user_data);
-
-#endif /* __PERIPHERAL_BUS_GDBUS_I2C_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2016-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.
- */
-
-#ifndef __PERIPHERAL_BUS_GDBUS_PWM_H__
-#define __PERIPHERAL_BUS_GDBUS_PWM_H__
-
-#include "peripheral_io_gdbus.h"
-
-gboolean handle_pwm_open(
- PeripheralIoGdbusPwm *pwm,
- GDBusMethodInvocation *invocation,
- GUnixFDList *fd_list,
- gint chip,
- gint pin,
- gpointer user_data);
-
-#endif /* __PERIPHERAL_BUS_GDBUS_PWM_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2016-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.
- */
-
-#ifndef __PERIPHERAL_BUS_GDBUS_SPI_H__
-#define __PERIPHERAL_BUS_GDBUS_SPI_H__
-
-#include "peripheral_io_gdbus.h"
-
-gboolean handle_spi_open(
- PeripheralIoGdbusSpi *spi,
- GDBusMethodInvocation *invocation,
- GUnixFDList *fd_list,
- gint bus,
- gint cs,
- gpointer user_data);
-
-#endif /* __PERIPHERAL_BUS_GDBUS_SPI_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2016-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.
- */
-
-#ifndef __PERIPHERAL_BUS_GDBUS_UART_H__
-#define __PERIPHERAL_BUS_GDBUS_UART_H__
-
-#include "peripheral_io_gdbus.h"
-
-gboolean handle_uart_open(
- PeripheralIoGdbusUart *uart,
- GDBusMethodInvocation *invocation,
- GUnixFDList *fd_list,
- gint port,
- gpointer user_data);
-
-#endif /* __PERIPHERAL_BUS_GDBUS_UART_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2016-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.
+ */
+
+#ifndef __PERIPHERAL_GDBUS_GPIO_H__
+#define __PERIPHERAL_GDBUS_GPIO_H__
+
+#include "peripheral_io_gdbus.h"
+
+gboolean handle_gpio_open(
+ PeripheralIoGdbusGpio *gpio,
+ GDBusMethodInvocation *invocation,
+ GUnixFDList *fd_list,
+ gint pin,
+ gpointer user_data);
+
+#endif /* __PERIPHERAL_GDBUS_GPIO_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2016-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.
+ */
+
+#ifndef __PERIPHERAL_GDBUS_I2C_H__
+#define __PERIPHERAL_GDBUS_I2C_H__
+
+#include "peripheral_io_gdbus.h"
+
+gboolean handle_i2c_open(
+ PeripheralIoGdbusI2c *i2c,
+ GDBusMethodInvocation *invocation,
+ GUnixFDList *fd_list,
+ gint bus,
+ gint address,
+ gpointer user_data);
+
+#endif /* __PERIPHERAL_GDBUS_I2C_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2016-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.
+ */
+
+#ifndef __PERIPHERAL_GDBUS_PWM_H__
+#define __PERIPHERAL_GDBUS_PWM_H__
+
+#include "peripheral_io_gdbus.h"
+
+gboolean handle_pwm_open(
+ PeripheralIoGdbusPwm *pwm,
+ GDBusMethodInvocation *invocation,
+ GUnixFDList *fd_list,
+ gint chip,
+ gint pin,
+ gpointer user_data);
+
+#endif /* __PERIPHERAL_GDBUS_PWM_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2016-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.
+ */
+
+#ifndef __PERIPHERAL_GDBUS_SPI_H__
+#define __PERIPHERAL_GDBUS_SPI_H__
+
+#include "peripheral_io_gdbus.h"
+
+gboolean handle_spi_open(
+ PeripheralIoGdbusSpi *spi,
+ GDBusMethodInvocation *invocation,
+ GUnixFDList *fd_list,
+ gint bus,
+ gint cs,
+ gpointer user_data);
+
+#endif /* __PERIPHERAL_GDBUS_SPI_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2016-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.
+ */
+
+#ifndef __PERIPHERAL_GDBUS_UART_H__
+#define __PERIPHERAL_GDBUS_UART_H__
+
+#include "peripheral_io_gdbus.h"
+
+gboolean handle_uart_open(
+ PeripheralIoGdbusUart *uart,
+ GDBusMethodInvocation *invocation,
+ GUnixFDList *fd_list,
+ gint port,
+ gpointer user_data);
+
+#endif /* __PERIPHERAL_GDBUS_UART_H__ */
#include "peripheral_io_gdbus.h"
#include "peripheral_bus.h"
#include "peripheral_log.h"
-#include "peripheral_bus_gdbus_gpio.h"
-#include "peripheral_bus_gdbus_i2c.h"
-#include "peripheral_bus_gdbus_pwm.h"
-#include "peripheral_bus_gdbus_spi.h"
-#include "peripheral_bus_gdbus_uart.h"
+#include "peripheral_gdbus_gpio.h"
+#include "peripheral_gdbus_i2c.h"
+#include "peripheral_gdbus_pwm.h"
+#include "peripheral_gdbus_spi.h"
+#include "peripheral_gdbus_uart.h"
#include "privilege_checker.h"
+++ /dev/null
-/*
- * Copyright (c) 2016-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 <peripheral_io.h>
-#include <gio/gunixfdlist.h>
-
-#include "peripheral_io_gdbus.h"
-#include "peripheral_bus.h"
-#include "peripheral_handle_gpio.h"
-#include "peripheral_log.h"
-#include "peripheral_bus_util.h"
-#include "peripheral_bus_gdbus_gpio.h"
-
-static void __gpio_on_name_vanished(GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
-{
- pb_data_h gpio_handle = (pb_data_h)user_data;
- _D("appid [%s] vanished ", name);
-
- g_bus_unwatch_name(gpio_handle->watch_id);
- peripheral_bus_gpio_close(gpio_handle);
-}
-
-gboolean handle_gpio_open(
- PeripheralIoGdbusGpio *gpio,
- GDBusMethodInvocation *invocation,
- GUnixFDList *fd_list,
- gint pin,
- gpointer user_data)
-{
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
- pb_data_h gpio_handle = NULL;
-
- GUnixFDList *gpio_fd_list = NULL;
-
- ret = peripheral_bus_check_privilege(invocation, pb_data);
- if (ret != 0) {
- _E("Permission denied.");
- ret = PERIPHERAL_ERROR_PERMISSION_DENIED;
- goto out;
- }
-
- if ((ret = peripheral_bus_gpio_open(pin, &gpio_handle, user_data)) < PERIPHERAL_ERROR_NONE)
- goto out;
-
- gpio_handle->watch_id = g_bus_watch_name(G_BUS_TYPE_SYSTEM,
- g_dbus_method_invocation_get_sender(invocation),
- G_BUS_NAME_WATCHER_FLAGS_NONE,
- NULL,
- __gpio_on_name_vanished,
- gpio_handle,
- NULL);
-
-out:
- peripheral_io_gdbus_gpio_complete_open(gpio, invocation, gpio_fd_list, GPOINTER_TO_UINT(gpio_handle), ret);
-
- return true;
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2016-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 <peripheral_io.h>
-
-#include "peripheral_io_gdbus.h"
-#include "peripheral_bus.h"
-#include "peripheral_handle_i2c.h"
-#include "peripheral_log.h"
-#include "peripheral_bus_util.h"
-#include "peripheral_bus_gdbus_i2c.h"
-
-static void __i2c_on_name_vanished(GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
-{
- pb_data_h i2c_handle = (pb_data_h)user_data;
- _D("appid [%s] vanished ", name);
-
- g_bus_unwatch_name(i2c_handle->watch_id);
- peripheral_bus_i2c_close(i2c_handle);
-}
-
-gboolean handle_i2c_open(
- PeripheralIoGdbusI2c *i2c,
- GDBusMethodInvocation *invocation,
- GUnixFDList *fd_list,
- gint bus,
- gint address,
- gpointer user_data)
-{
- peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- pb_data_h i2c_handle = NULL;
-
- GUnixFDList *i2c_fd_list = NULL;
-
- ret = peripheral_bus_check_privilege(invocation, pb_data);
- if (ret != 0) {
- _E("Permission denied.");
- ret = PERIPHERAL_ERROR_PERMISSION_DENIED;
- goto out;
- }
-
- if ((ret = peripheral_bus_i2c_open(bus, address, &i2c_handle, user_data)) < PERIPHERAL_ERROR_NONE)
- goto out;
-
- i2c_handle->watch_id = g_bus_watch_name(G_BUS_TYPE_SYSTEM,
- g_dbus_method_invocation_get_sender(invocation),
- G_BUS_NAME_WATCHER_FLAGS_NONE,
- NULL,
- __i2c_on_name_vanished,
- i2c_handle,
- NULL);
-
-out:
- peripheral_io_gdbus_i2c_complete_open(i2c, invocation, i2c_fd_list, GPOINTER_TO_UINT(i2c_handle), ret);
-
- return true;
-}
+++ /dev/null
-/*
- * Copyright (c) 2016-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 <peripheral_io.h>
-
-#include "peripheral_io_gdbus.h"
-#include "peripheral_bus.h"
-#include "peripheral_handle_pwm.h"
-#include "peripheral_log.h"
-#include "peripheral_bus_util.h"
-#include "peripheral_bus_gdbus_pwm.h"
-
-static void __pwm_on_name_vanished(GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
-{
- pb_data_h pwm_handle = (pb_data_h)user_data;
- _D("appid [%s] vanished ", name);
-
- g_bus_unwatch_name(pwm_handle->watch_id);
- peripheral_bus_pwm_close(pwm_handle);
-}
-
-gboolean handle_pwm_open(
- PeripheralIoGdbusPwm *pwm,
- GDBusMethodInvocation *invocation,
- GUnixFDList *fd_list,
- gint chip,
- gint pin,
- gpointer user_data)
-{
- peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- pb_data_h pwm_handle = NULL;
-
- GUnixFDList *pwm_fd_list = NULL;
-
- ret = peripheral_bus_check_privilege(invocation, pb_data);
- if (ret != 0) {
- _E("Permission denied.");
- ret = PERIPHERAL_ERROR_PERMISSION_DENIED;
- goto out;
- }
-
- if ((ret = peripheral_bus_pwm_open(chip, pin, &pwm_handle, user_data)) < PERIPHERAL_ERROR_NONE)
- goto out;
-
- pwm_handle->watch_id = g_bus_watch_name(G_BUS_TYPE_SYSTEM,
- g_dbus_method_invocation_get_sender(invocation),
- G_BUS_NAME_WATCHER_FLAGS_NONE,
- NULL,
- __pwm_on_name_vanished,
- pwm_handle,
- NULL);
-
-out:
- peripheral_io_gdbus_pwm_complete_open(pwm, invocation, pwm_fd_list, GPOINTER_TO_UINT(pwm_handle), ret);
-
- return true;
-}
+++ /dev/null
-/*
- * Copyright (c) 2016-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 <peripheral_io.h>
-
-#include "peripheral_io_gdbus.h"
-#include "peripheral_bus.h"
-#include "peripheral_handle_spi.h"
-#include "peripheral_log.h"
-#include "peripheral_bus_util.h"
-#include "peripheral_bus_gdbus_spi.h"
-
-static void __spi_on_name_vanished(GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
-{
- pb_data_h spi_handle = (pb_data_h)user_data;
- _D("appid [%s] vanished ", name);
-
- g_bus_unwatch_name(spi_handle->watch_id);
- peripheral_bus_spi_close(spi_handle);
-}
-
-gboolean handle_spi_open(
- PeripheralIoGdbusSpi *spi,
- GDBusMethodInvocation *invocation,
- GUnixFDList *fd_list,
- gint bus,
- gint cs,
- gpointer user_data)
-{
- peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- pb_data_h spi_handle = NULL;
-
- GUnixFDList *spi_fd_list = NULL;
-
- ret = peripheral_bus_check_privilege(invocation, pb_data);
- if (ret != 0) {
- _E("Permission denied.");
- ret = PERIPHERAL_ERROR_PERMISSION_DENIED;
- goto out;
- }
-
- if ((ret = peripheral_bus_spi_open(bus, cs, &spi_handle, user_data)) < PERIPHERAL_ERROR_NONE)
- goto out;
-
- spi_handle->watch_id = g_bus_watch_name(G_BUS_TYPE_SYSTEM,
- g_dbus_method_invocation_get_sender(invocation),
- G_BUS_NAME_WATCHER_FLAGS_NONE,
- NULL,
- __spi_on_name_vanished,
- spi_handle,
- NULL);
-
-out:
- peripheral_io_gdbus_spi_complete_open(spi, invocation, spi_fd_list, GPOINTER_TO_UINT(spi_handle), ret);
-
- return true;
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2016-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 <peripheral_io.h>
-
-#include "peripheral_io_gdbus.h"
-#include "peripheral_bus.h"
-#include "peripheral_handle_uart.h"
-#include "peripheral_log.h"
-#include "peripheral_bus_util.h"
-#include "peripheral_bus_gdbus_uart.h"
-
-static void __uart_on_name_vanished(GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
-{
- pb_data_h uart_handle = (pb_data_h)user_data;
- _D("appid [%s] vanished ", name);
-
- g_bus_unwatch_name(uart_handle->watch_id);
- peripheral_bus_uart_close(uart_handle);
-}
-
-gboolean handle_uart_open(
- PeripheralIoGdbusUart *uart,
- GDBusMethodInvocation *invocation,
- GUnixFDList *fd_list,
- gint port,
- gpointer user_data)
-{
- peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- pb_data_h uart_handle = NULL;
-
- GUnixFDList *uart_fd_list = NULL;
-
- ret = peripheral_bus_check_privilege(invocation, pb_data);
- if (ret != 0) {
- _E("Permission denied.");
- ret = PERIPHERAL_ERROR_PERMISSION_DENIED;
- goto out;
- }
-
- if ((ret = peripheral_bus_uart_open(port, &uart_handle, user_data)) < PERIPHERAL_ERROR_NONE)
- goto out;
-
- uart_handle->watch_id = g_bus_watch_name(G_BUS_TYPE_SYSTEM,
- g_dbus_method_invocation_get_sender(invocation),
- G_BUS_NAME_WATCHER_FLAGS_NONE,
- NULL,
- __uart_on_name_vanished,
- uart_handle,
- NULL);
-
-out:
- peripheral_io_gdbus_uart_complete_open(uart, invocation, uart_fd_list, GPOINTER_TO_UINT(uart_handle), ret);
-
- return true;
-}
--- /dev/null
+/*
+ * Copyright (c) 2016-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 <peripheral_io.h>
+#include <gio/gunixfdlist.h>
+
+#include "peripheral_io_gdbus.h"
+#include "peripheral_bus.h"
+#include "peripheral_handle_gpio.h"
+#include "peripheral_log.h"
+#include "peripheral_bus_util.h"
+#include "peripheral_gdbus_gpio.h"
+
+static void __gpio_on_name_vanished(GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ pb_data_h gpio_handle = (pb_data_h)user_data;
+ _D("appid [%s] vanished ", name);
+
+ g_bus_unwatch_name(gpio_handle->watch_id);
+ peripheral_bus_gpio_close(gpio_handle);
+}
+
+gboolean handle_gpio_open(
+ PeripheralIoGdbusGpio *gpio,
+ GDBusMethodInvocation *invocation,
+ GUnixFDList *fd_list,
+ gint pin,
+ gpointer user_data)
+{
+ peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+ peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
+ pb_data_h gpio_handle = NULL;
+
+ GUnixFDList *gpio_fd_list = NULL;
+
+ ret = peripheral_bus_check_privilege(invocation, pb_data);
+ if (ret != 0) {
+ _E("Permission denied.");
+ ret = PERIPHERAL_ERROR_PERMISSION_DENIED;
+ goto out;
+ }
+
+ if ((ret = peripheral_bus_gpio_open(pin, &gpio_handle, user_data)) < PERIPHERAL_ERROR_NONE)
+ goto out;
+
+ gpio_handle->watch_id = g_bus_watch_name(G_BUS_TYPE_SYSTEM,
+ g_dbus_method_invocation_get_sender(invocation),
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ NULL,
+ __gpio_on_name_vanished,
+ gpio_handle,
+ NULL);
+
+out:
+ peripheral_io_gdbus_gpio_complete_open(gpio, invocation, gpio_fd_list, GPOINTER_TO_UINT(gpio_handle), ret);
+
+ return true;
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016-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 <peripheral_io.h>
+
+#include "peripheral_io_gdbus.h"
+#include "peripheral_bus.h"
+#include "peripheral_handle_i2c.h"
+#include "peripheral_log.h"
+#include "peripheral_bus_util.h"
+#include "peripheral_gdbus_i2c.h"
+
+static void __i2c_on_name_vanished(GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ pb_data_h i2c_handle = (pb_data_h)user_data;
+ _D("appid [%s] vanished ", name);
+
+ g_bus_unwatch_name(i2c_handle->watch_id);
+ peripheral_bus_i2c_close(i2c_handle);
+}
+
+gboolean handle_i2c_open(
+ PeripheralIoGdbusI2c *i2c,
+ GDBusMethodInvocation *invocation,
+ GUnixFDList *fd_list,
+ gint bus,
+ gint address,
+ gpointer user_data)
+{
+ peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
+ peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+ pb_data_h i2c_handle = NULL;
+
+ GUnixFDList *i2c_fd_list = NULL;
+
+ ret = peripheral_bus_check_privilege(invocation, pb_data);
+ if (ret != 0) {
+ _E("Permission denied.");
+ ret = PERIPHERAL_ERROR_PERMISSION_DENIED;
+ goto out;
+ }
+
+ if ((ret = peripheral_bus_i2c_open(bus, address, &i2c_handle, user_data)) < PERIPHERAL_ERROR_NONE)
+ goto out;
+
+ i2c_handle->watch_id = g_bus_watch_name(G_BUS_TYPE_SYSTEM,
+ g_dbus_method_invocation_get_sender(invocation),
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ NULL,
+ __i2c_on_name_vanished,
+ i2c_handle,
+ NULL);
+
+out:
+ peripheral_io_gdbus_i2c_complete_open(i2c, invocation, i2c_fd_list, GPOINTER_TO_UINT(i2c_handle), ret);
+
+ return true;
+}
--- /dev/null
+/*
+ * Copyright (c) 2016-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 <peripheral_io.h>
+
+#include "peripheral_io_gdbus.h"
+#include "peripheral_bus.h"
+#include "peripheral_handle_pwm.h"
+#include "peripheral_log.h"
+#include "peripheral_bus_util.h"
+#include "peripheral_gdbus_pwm.h"
+
+static void __pwm_on_name_vanished(GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ pb_data_h pwm_handle = (pb_data_h)user_data;
+ _D("appid [%s] vanished ", name);
+
+ g_bus_unwatch_name(pwm_handle->watch_id);
+ peripheral_bus_pwm_close(pwm_handle);
+}
+
+gboolean handle_pwm_open(
+ PeripheralIoGdbusPwm *pwm,
+ GDBusMethodInvocation *invocation,
+ GUnixFDList *fd_list,
+ gint chip,
+ gint pin,
+ gpointer user_data)
+{
+ peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
+ peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+ pb_data_h pwm_handle = NULL;
+
+ GUnixFDList *pwm_fd_list = NULL;
+
+ ret = peripheral_bus_check_privilege(invocation, pb_data);
+ if (ret != 0) {
+ _E("Permission denied.");
+ ret = PERIPHERAL_ERROR_PERMISSION_DENIED;
+ goto out;
+ }
+
+ if ((ret = peripheral_bus_pwm_open(chip, pin, &pwm_handle, user_data)) < PERIPHERAL_ERROR_NONE)
+ goto out;
+
+ pwm_handle->watch_id = g_bus_watch_name(G_BUS_TYPE_SYSTEM,
+ g_dbus_method_invocation_get_sender(invocation),
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ NULL,
+ __pwm_on_name_vanished,
+ pwm_handle,
+ NULL);
+
+out:
+ peripheral_io_gdbus_pwm_complete_open(pwm, invocation, pwm_fd_list, GPOINTER_TO_UINT(pwm_handle), ret);
+
+ return true;
+}
--- /dev/null
+/*
+ * Copyright (c) 2016-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 <peripheral_io.h>
+
+#include "peripheral_io_gdbus.h"
+#include "peripheral_bus.h"
+#include "peripheral_handle_spi.h"
+#include "peripheral_log.h"
+#include "peripheral_bus_util.h"
+#include "peripheral_gdbus_spi.h"
+
+static void __spi_on_name_vanished(GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ pb_data_h spi_handle = (pb_data_h)user_data;
+ _D("appid [%s] vanished ", name);
+
+ g_bus_unwatch_name(spi_handle->watch_id);
+ peripheral_bus_spi_close(spi_handle);
+}
+
+gboolean handle_spi_open(
+ PeripheralIoGdbusSpi *spi,
+ GDBusMethodInvocation *invocation,
+ GUnixFDList *fd_list,
+ gint bus,
+ gint cs,
+ gpointer user_data)
+{
+ peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
+ peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+ pb_data_h spi_handle = NULL;
+
+ GUnixFDList *spi_fd_list = NULL;
+
+ ret = peripheral_bus_check_privilege(invocation, pb_data);
+ if (ret != 0) {
+ _E("Permission denied.");
+ ret = PERIPHERAL_ERROR_PERMISSION_DENIED;
+ goto out;
+ }
+
+ if ((ret = peripheral_bus_spi_open(bus, cs, &spi_handle, user_data)) < PERIPHERAL_ERROR_NONE)
+ goto out;
+
+ spi_handle->watch_id = g_bus_watch_name(G_BUS_TYPE_SYSTEM,
+ g_dbus_method_invocation_get_sender(invocation),
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ NULL,
+ __spi_on_name_vanished,
+ spi_handle,
+ NULL);
+
+out:
+ peripheral_io_gdbus_spi_complete_open(spi, invocation, spi_fd_list, GPOINTER_TO_UINT(spi_handle), ret);
+
+ return true;
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2016-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 <peripheral_io.h>
+
+#include "peripheral_io_gdbus.h"
+#include "peripheral_bus.h"
+#include "peripheral_handle_uart.h"
+#include "peripheral_log.h"
+#include "peripheral_bus_util.h"
+#include "peripheral_gdbus_uart.h"
+
+static void __uart_on_name_vanished(GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ pb_data_h uart_handle = (pb_data_h)user_data;
+ _D("appid [%s] vanished ", name);
+
+ g_bus_unwatch_name(uart_handle->watch_id);
+ peripheral_bus_uart_close(uart_handle);
+}
+
+gboolean handle_uart_open(
+ PeripheralIoGdbusUart *uart,
+ GDBusMethodInvocation *invocation,
+ GUnixFDList *fd_list,
+ gint port,
+ gpointer user_data)
+{
+ peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
+ peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+ pb_data_h uart_handle = NULL;
+
+ GUnixFDList *uart_fd_list = NULL;
+
+ ret = peripheral_bus_check_privilege(invocation, pb_data);
+ if (ret != 0) {
+ _E("Permission denied.");
+ ret = PERIPHERAL_ERROR_PERMISSION_DENIED;
+ goto out;
+ }
+
+ if ((ret = peripheral_bus_uart_open(port, &uart_handle, user_data)) < PERIPHERAL_ERROR_NONE)
+ goto out;
+
+ uart_handle->watch_id = g_bus_watch_name(G_BUS_TYPE_SYSTEM,
+ g_dbus_method_invocation_get_sender(invocation),
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ NULL,
+ __uart_on_name_vanished,
+ uart_handle,
+ NULL);
+
+out:
+ peripheral_io_gdbus_uart_complete_open(uart, invocation, uart_fd_list, GPOINTER_TO_UINT(uart_handle), ret);
+
+ return true;
+}
#include "peripheral_interface_gpio.h"
#include "peripheral_bus.h"
-#include "peripheral_bus_gdbus_gpio.h"
#include "peripheral_log.h"
#include "peripheral_bus_util.h"