5 * Copyright (C) 2012 BMW Car IT GmbH. 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
30 #define CONNMAN_API_SUBJECT_TO_CHANGE
31 #include <connman/plugin.h>
32 #include <connman/device.h>
33 #include <connman/network.h>
34 #include <connman/dbus.h>
36 #define DUNDEE_SERVICE "org.ofono.dundee"
38 static DBusConnection *connection;
40 static GHashTable *dundee_devices = NULL;
45 static void device_destroy(gpointer data)
47 struct dundee_data *info = data;
52 static int network_probe(struct connman_network *network)
54 DBG("network %p", network);
59 static void network_remove(struct connman_network *network)
61 DBG("network %p", network);
64 static int network_connect(struct connman_network *network)
66 DBG("network %p", network);
71 static int network_disconnect(struct connman_network *network)
73 DBG("network %p", network);
78 static struct connman_network_driver network_driver = {
80 .type = CONNMAN_NETWORK_TYPE_BLUETOOTH_DUN,
81 .probe = network_probe,
82 .remove = network_remove,
83 .connect = network_connect,
84 .disconnect = network_disconnect,
87 static int dundee_probe(struct connman_device *device)
89 DBG("device %p", device);
94 static void dundee_remove(struct connman_device *device)
96 DBG("device %p", device);
99 static int dundee_enable(struct connman_device *device)
101 DBG("device %p", device);
106 static int dundee_disable(struct connman_device *device)
108 DBG("device %p", device);
113 static struct connman_device_driver dundee_driver = {
115 .type = CONNMAN_DEVICE_TYPE_BLUETOOTH,
116 .probe = dundee_probe,
117 .remove = dundee_remove,
118 .enable = dundee_enable,
119 .disable = dundee_disable,
122 static void dundee_connect(DBusConnection *connection, void *user_data)
124 DBG("connection %p", connection);
126 dundee_devices = g_hash_table_new_full(g_str_hash, g_str_equal,
127 g_free, device_destroy);
130 static void dundee_disconnect(DBusConnection *connection, void *user_data)
132 DBG("connection %p", connection);
134 g_hash_table_destroy(dundee_devices);
135 dundee_devices = NULL;
140 static int dundee_init(void)
144 connection = connman_dbus_get_connection();
145 if (connection == NULL)
148 watch = g_dbus_add_service_watch(connection, DUNDEE_SERVICE,
149 dundee_connect, dundee_disconnect, NULL, NULL);
156 err = connman_network_driver_register(&network_driver);
160 err = connman_device_driver_register(&dundee_driver);
162 connman_network_driver_unregister(&network_driver);
169 g_dbus_remove_watch(connection, watch);
171 dbus_connection_unref(connection);
176 static void dundee_exit(void)
178 g_dbus_remove_watch(connection, watch);
180 connman_device_driver_unregister(&dundee_driver);
181 connman_network_driver_unregister(&network_driver);
183 dbus_connection_unref(connection);
186 CONNMAN_PLUGIN_DEFINE(dundee, "Dundee plugin", VERSION,
187 CONNMAN_PLUGIN_PRIORITY_DEFAULT, dundee_init, dundee_exit)