5 * Copyright (C) 2012 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 #include <connman/log.h>
31 #include "../src/connman.h"
34 #include "connman/vpn-dbus.h"
36 static int vpn_connect_count;
37 static DBusConnection *connection;
39 static DBusMessage *create(DBusConnection *conn, DBusMessage *msg, void *data)
45 err = __vpn_provider_create_and_connect(msg);
47 if (err == -EINPROGRESS) {
48 connman_error("Invalid return code (%d) "
53 return __connman_error_failed(msg, -err);
59 static DBusMessage *remove(DBusConnection *conn, DBusMessage *msg, void *data)
64 dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,
67 DBG("conn %p path %s", conn, path);
69 err = __vpn_provider_remove(path);
71 return __connman_error_failed(msg, -err);
73 return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
76 static DBusMessage *get_connections(DBusConnection *conn, DBusMessage *msg,
83 reply = __vpn_provider_get_connections(msg);
85 return __connman_error_failed(msg, -EINVAL);
90 static const GDBusMethodTable manager_methods[] = {
91 { GDBUS_ASYNC_METHOD("Create",
92 GDBUS_ARGS({ "properties", "a{sv}" }),
93 GDBUS_ARGS({ "path", "o" }),
95 { GDBUS_ASYNC_METHOD("Remove",
96 GDBUS_ARGS({ "identifier", "o" }), NULL,
98 { GDBUS_METHOD("GetConnections", NULL,
99 GDBUS_ARGS({ "connections", "a(oa{sv})" }),
104 static const GDBusSignalTable manager_signals[] = {
105 { GDBUS_SIGNAL("ConnectionAdded",
106 GDBUS_ARGS({ "identifier", "o" },
107 { "properties", "a{sv}" })) },
108 { GDBUS_SIGNAL("ConnectionRemoved",
109 GDBUS_ARGS({ "identifier", "o" })) },
113 int __vpn_manager_init(void)
117 connection = connman_dbus_get_connection();
118 if (connection == NULL)
121 g_dbus_register_interface(connection, VPN_MANAGER_PATH,
122 VPN_MANAGER_INTERFACE,
124 manager_signals, NULL, NULL, NULL);
126 vpn_connect_count = 0;
131 void __vpn_manager_cleanup(void)
135 if (connection == NULL)
138 g_dbus_unregister_interface(connection, VPN_MANAGER_PATH,
139 VPN_MANAGER_INTERFACE);
141 dbus_connection_unref(connection);