From b04634c4902c12fa9a2044d7bbcfbd0088913b1b Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Mon, 12 Nov 2012 14:07:37 +0200 Subject: vpn: Add preliminary agent support --- vpn/main.c | 2 ++ vpn/vpn-manager.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) (limited to 'vpn') diff --git a/vpn/main.c b/vpn/main.c index eb074d4a..732bd4b1 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 680f2fd9..cd851651 100644 --- a/vpn/vpn-manager.c +++ b/vpn/vpn-manager.c @@ -27,6 +27,7 @@ #include #include +#include #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) }, { }, }; -- cgit v1.2.3