[PATCH v3 21/42] vpn: Add preliminary agent support

Jukka Rissanen jukka.rissanen at linux.intel.com
Wed Nov 7 03:48:47 PST 2012


---
 include/vpn-dbus.h |  1 +
 vpn/main.c         |  2 ++
 vpn/vpn-manager.c  | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+)

diff --git a/include/vpn-dbus.h b/include/vpn-dbus.h
index fec925b..01780cb 100644
--- a/include/vpn-dbus.h
+++ b/include/vpn-dbus.h
@@ -37,6 +37,7 @@ extern "C" {
 #define VPN_MANAGER_PATH		"/"
 
 #define VPN_CONNECTION_INTERFACE	VPN_SERVICE ".Connection"
+#define VPN_AGENT_INTERFACE		VPN_SERVICE ".Agent"
 #define VPN_TASK_INTERFACE		VPN_SERVICE ".Task"
 
 #define VPN_PRIVILEGE_MODIFY		1
diff --git a/vpn/main.c b/vpn/main.c
index 1decbec..161df98 100644
--- a/vpn/main.c
+++ b/vpn/main.c
@@ -308,6 +308,7 @@ int main(int argc, char *argv[])
 	else
 		config_init(option_config);
 
+	__connman_agent_init();
 	__vpn_provider_init(option_routes);
 	__vpn_manager_init();
 	__vpn_ipconfig_init();
@@ -329,6 +330,7 @@ int main(int argc, char *argv[])
 	__vpn_ipconfig_cleanup();
 	__vpn_manager_cleanup();
 	__vpn_provider_cleanup();
+	__connman_agent_cleanup();
 	__connman_dbus_cleanup();
 	__connman_log_cleanup(FALSE);
 
diff --git a/vpn/vpn-manager.c b/vpn/vpn-manager.c
index 1569a55..1f14468 100644
--- a/vpn/vpn-manager.c
+++ b/vpn/vpn-manager.c
@@ -27,6 +27,7 @@
 
 #include <gdbus.h>
 #include <connman/log.h>
+#include <connman/agent.h>
 
 #include "../src/connman.h"
 
@@ -87,6 +88,46 @@ static DBusMessage *get_connections(DBusConnection *conn, DBusMessage *msg,
 	return reply;
 }
 
+static DBusMessage *register_agent(DBusConnection *conn,
+					DBusMessage *msg, void *data)
+{
+	const char *sender, *path;
+	int err;
+
+	DBG("conn %p", conn);
+
+	sender = dbus_message_get_sender(msg);
+
+	dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,
+							DBUS_TYPE_INVALID);
+
+	err = connman_agent_register(sender, path);
+	if (err < 0)
+		return __connman_error_failed(msg, -err);
+
+	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+}
+
+static DBusMessage *unregister_agent(DBusConnection *conn,
+					DBusMessage *msg, void *data)
+{
+	const char *sender, *path;
+	int err;
+
+	DBG("conn %p", conn);
+
+	sender = dbus_message_get_sender(msg);
+
+	dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,
+							DBUS_TYPE_INVALID);
+
+	err = connman_agent_unregister(sender, path);
+	if (err < 0)
+		return __connman_error_failed(msg, -err);
+
+	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+}
+
 static const GDBusMethodTable manager_methods[] = {
 	{ GDBUS_ASYNC_METHOD("Create",
 			GDBUS_ARGS({ "properties", "a{sv}" }),
@@ -98,6 +139,12 @@ static const GDBusMethodTable manager_methods[] = {
 	{ GDBUS_METHOD("GetConnections", NULL,
 			GDBUS_ARGS({ "connections", "a(oa{sv})" }),
 			get_connections) },
+	{ GDBUS_METHOD("RegisterAgent",
+			GDBUS_ARGS({ "path", "o" }), NULL,
+			register_agent) },
+	{ GDBUS_METHOD("UnregisterAgent",
+			GDBUS_ARGS({ "path", "o" }), NULL,
+			unregister_agent) },
 	{ },
 };
 
-- 
1.7.11.4




More information about the connman mailing list