From 7aac03f81d1a9e3d0e5c476b22ca883f839e6d1c Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Thu, 24 Jan 2008 12:07:55 +0100 Subject: Add skeleton for agent infrastructure --- src/Makefile.am | 2 +- src/agent.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/connman.h | 6 ++++++ src/main.c | 4 ++++ src/manager.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 5 files changed, 111 insertions(+), 3 deletions(-) create mode 100644 src/agent.c (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 4da752e5..1a09a0f8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,7 +5,7 @@ dbus_DATA = connman.conf sbin_PROGRAMS = connmand -connmand_SOURCES = main.c connman.h manager.c plugin.c \ +connmand_SOURCES = main.c connman.h manager.c agent.c plugin.c \ iface.c iface-storage.c iface-helper.c \ iface-inet.c rtnl.c dhcp.c diff --git a/src/agent.c b/src/agent.c new file mode 100644 index 00000000..d3a27463 --- /dev/null +++ b/src/agent.c @@ -0,0 +1,52 @@ +/* + * + * Connection Manager + * + * Copyright (C) 2007 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; 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 "connman.h" + +int __connman_agent_init(void) +{ + DBG(""); + + return 0; +} + +void __connman_agent_cleanup(void) +{ + DBG(""); +} + +int __connman_agent_register(const char *path) +{ + DBG(""); + + return 0; +} + +int __connman_agent_unregister(const char *path) +{ + DBG(""); + + return 0; +} diff --git a/src/connman.h b/src/connman.h index 8756034c..ff33489e 100644 --- a/src/connman.h +++ b/src/connman.h @@ -42,6 +42,12 @@ int __connman_manager_init(DBusConnection *conn, int compat); void __connman_manager_cleanup(void); +int __connman_agent_init(void); +void __connman_agent_cleanup(void); + +int __connman_agent_register(const char *path); +int __connman_agent_unregister(const char *path); + #include int __connman_plugin_init(void); diff --git a/src/main.c b/src/main.c index 8de7fbed..1b314db8 100644 --- a/src/main.c +++ b/src/main.c @@ -120,6 +120,8 @@ int main(int argc, char *argv[]) compat = 0; } + __connman_agent_init(); + __connman_manager_init(conn, compat); __connman_plugin_init(); @@ -143,6 +145,8 @@ int main(int argc, char *argv[]) __connman_manager_cleanup(); + __connman_agent_cleanup(); + g_dbus_cleanup_connection(conn); g_main_loop_unref(main_loop); diff --git a/src/manager.c b/src/manager.c index b11d805e..2a1a738f 100644 --- a/src/manager.c +++ b/src/manager.c @@ -70,9 +70,55 @@ static DBusMessage *get_state(DBusConnection *conn, return reply; } +static DBusMessage *register_agent(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusMessage *reply; + const char *path; + + DBG("conn %p", conn); + + dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path, + DBUS_TYPE_INVALID); + + reply = dbus_message_new_method_return(msg); + if (reply == NULL) + return NULL; + + dbus_message_append_args(reply, DBUS_TYPE_INVALID); + + __connman_agent_register(path); + + return reply; +} + +static DBusMessage *unregister_agent(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusMessage *reply; + const char *path; + + DBG("conn %p", conn); + + dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path, + DBUS_TYPE_INVALID); + + reply = dbus_message_new_method_return(msg); + if (reply == NULL) + return NULL; + + dbus_message_append_args(reply, DBUS_TYPE_INVALID); + + __connman_agent_unregister(path); + + return reply; +} + static GDBusMethodTable manager_methods[] = { - { "ListInterfaces", "", "ao", list_interfaces }, - { "GetState", "", "s", get_state }, + { "ListInterfaces", "", "ao", list_interfaces }, + { "GetState", "", "s", get_state }, + { "RegisterAgent", "o", "", register_agent }, + { "UnregisterAgent", "o", "", unregister_agent }, { }, }; -- cgit v1.2.3