From 09c29ba3e2ae62be59b99132232c723bcf595300 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Mon, 6 Oct 2014 22:13:14 -0500 Subject: [PATCH] manager: Add manager skeleton --- Makefile.am | 3 +- src/dbus.c | 3 ++ src/manager.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/manager.h | 26 +++++++++++++++ 4 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 src/manager.c create mode 100644 src/manager.h diff --git a/Makefile.am b/Makefile.am index 455f78ad..f6e1d123 100644 --- a/Makefile.am +++ b/Makefile.am @@ -45,7 +45,8 @@ src_iwd_SOURCES = src/main.c linux/nl80211.h linux/kdbus.h \ src/wiphy.h src/wiphy.c \ src/sha1.h src/sha1.c \ src/ie.h src/ie.c \ - src/dbus.h src/dbus.c + src/dbus.h src/dbus.c \ + src/manager.h src/manager.c src_iwd_LDADD = ell/libell-internal.la client_iwctl_SOURCES = client/main.c linux/kdbus.h \ diff --git a/src/dbus.c b/src/dbus.c index 3e8758ba..8eea63e8 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -26,6 +26,7 @@ #include #include "src/dbus.h" +#include "src/manager.h" struct l_dbus *g_dbus = 0; @@ -64,6 +65,7 @@ static void request_name_setup(struct l_dbus_message *message, void *user_data) static void ready_callback(void *user_data) { l_info("ready"); + manager_init(g_dbus); } static void disconnect_callback(void *user_data) @@ -95,6 +97,7 @@ bool dbus_init(void) bool dbus_exit(void) { + manager_exit(g_dbus); l_dbus_destroy(g_dbus); g_dbus = NULL; diff --git a/src/manager.c b/src/manager.c new file mode 100644 index 00000000..75c69fb0 --- /dev/null +++ b/src/manager.c @@ -0,0 +1,90 @@ +/* + * + * Wireless daemon for Linux + * + * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include "src/manager.h" + +#define IWD_MANAGER_INTERFACE "net.connman.iwd.Manager" + +static struct l_dbus_message *manager_set_property(struct l_dbus *dbus, + struct l_dbus_message *message, + void *user_data) +{ + const char *property; + struct l_dbus_message_iter variant; + + if (!l_dbus_message_get_arguments(message, "sv", &property, &variant)) + return l_dbus_message_new_error(message, + "org.test.InvalidArguments", + "Invalid arguments"); + + return l_dbus_message_new_error(message, "org.test.InvalidArguments", + "Unknown Property %s", property); +} + +static struct l_dbus_message *manager_get_properties(struct l_dbus *dbus, + struct l_dbus_message *message, + void *user_data) +{ + struct l_dbus_message *reply; + + reply = l_dbus_message_new_method_return(message); + l_dbus_message_set_arguments(reply, "a{sv}", 0); + + return reply; +} + +static void setup_manager_interface(struct l_dbus_interface *interface) +{ + l_dbus_interface_method(interface, "GetProperties", 0, + manager_get_properties, + "a{sv}", "", "properties"); + l_dbus_interface_method(interface, "SetProperty", 0, + manager_set_property, + "", "sv", "name", "value"); + + l_dbus_interface_signal(interface, "PropertyChanged", 0, + "sv", "name", "value"); +} + +bool manager_init(struct l_dbus *dbus) +{ + if (!l_dbus_register_interface(dbus, "/", IWD_MANAGER_INTERFACE, + setup_manager_interface, NULL, NULL)) { + l_info("Unable to register %s interface", + IWD_MANAGER_INTERFACE); + return false; + } + + return true; +} + +bool manager_exit(struct l_dbus *dbus) +{ + l_dbus_unregister_interface(dbus, "/", IWD_MANAGER_INTERFACE); + + return true; +} diff --git a/src/manager.h b/src/manager.h new file mode 100644 index 00000000..ad287a66 --- /dev/null +++ b/src/manager.h @@ -0,0 +1,26 @@ +/* + * + * Wireless daemon for Linux + * + * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include + +bool manager_init(struct l_dbus *dbus); +bool manager_exit(struct l_dbus *dbus);