5 * Copyright (C) 2007-2010 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
30 #include <netinet/ether.h>
34 #define CONNMAN_API_SUBJECT_TO_CHANGE
35 #include <connman/plugin.h>
36 #include <connman/technology.h>
37 #include <connman/device.h>
38 #include <connman/inet.h>
39 #include <connman/dbus.h>
40 #include <connman/log.h>
42 #define BLUEZ_SERVICE "org.bluez"
43 #define BLUEZ_MANAGER_INTERFACE BLUEZ_SERVICE ".Manager"
44 #define BLUEZ_ADAPTER_INTERFACE BLUEZ_SERVICE ".Adapter"
45 #define BLUEZ_DEVICE_INTERFACE BLUEZ_SERVICE ".Device"
46 #define BLUEZ_NETWORK_INTERFACE BLUEZ_SERVICE ".Network"
48 #define LIST_ADAPTERS "ListAdapters"
49 #define ADAPTER_ADDED "AdapterAdded"
50 #define ADAPTER_REMOVED "AdapterRemoved"
51 #define DEVICE_REMOVED "DeviceRemoved"
53 #define PROPERTY_CHANGED "PropertyChanged"
54 #define GET_PROPERTIES "GetProperties"
55 #define SET_PROPERTY "SetProperty"
57 #define CONNECT "Connect"
58 #define DISCONNECT "Disconnect"
60 #define UUID_NAP "00001116-0000-1000-8000-00805f9b34fb"
64 static DBusConnection *connection;
66 static GHashTable *bluetooth_devices = NULL;
67 static GHashTable *bluetooth_networks = NULL;
69 static int pan_probe(struct connman_network *network)
71 DBG("network %p", network);
76 static void pan_remove(struct connman_network *network)
78 DBG("network %p", network);
81 static void connect_reply(DBusPendingCall *call, void *user_data)
83 struct connman_network *network = user_data;
86 const char *interface = NULL;
89 DBG("network %p", network);
91 reply = dbus_pending_call_steal_reply(call);
93 dbus_error_init(&error);
95 if (dbus_set_error_from_message(&error, reply) == TRUE) {
96 connman_error("%s", error.message);
97 dbus_error_free(&error);
101 if (dbus_message_get_args(reply, &error,
102 DBUS_TYPE_STRING, &interface,
103 DBUS_TYPE_INVALID) == FALSE) {
104 if (dbus_error_is_set(&error) == TRUE) {
105 connman_error("%s", error.message);
106 dbus_error_free(&error);
108 connman_error("Wrong arguments for connect");
112 if (interface == NULL)
115 DBG("interface %s", interface);
117 index = connman_inet_ifindex(interface);
119 connman_network_set_index(network, index);
121 connman_network_set_connected(network, TRUE);
124 dbus_message_unref(reply);
126 dbus_pending_call_unref(call);
129 static int pan_connect(struct connman_network *network)
131 const char *path = connman_network_get_string(network, "Path");
132 const char *uuid = "nap";
133 DBusMessage *message;
134 DBusPendingCall *call;
136 DBG("network %p", network);
141 message = dbus_message_new_method_call(BLUEZ_SERVICE, path,
142 BLUEZ_NETWORK_INTERFACE, CONNECT);
146 dbus_message_set_auto_start(message, FALSE);
148 dbus_message_append_args(message, DBUS_TYPE_STRING, &uuid,
151 if (dbus_connection_send_with_reply(connection, message,
152 &call, TIMEOUT * 10) == FALSE) {
153 connman_error("Failed to connect service");
154 dbus_message_unref(message);
159 connman_error("D-Bus connection not available");
160 dbus_message_unref(message);
164 dbus_pending_call_set_notify(call, connect_reply, network, NULL);
166 dbus_message_unref(message);
171 static void disconnect_reply(DBusPendingCall *call, void *user_data)
173 struct connman_network *network = user_data;
177 DBG("network %p", network);
179 reply = dbus_pending_call_steal_reply(call);
181 dbus_error_init(&error);
183 if (dbus_set_error_from_message(&error, reply) == TRUE) {
184 connman_error("%s", error.message);
185 dbus_error_free(&error);
189 if (dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) == FALSE) {
190 if (dbus_error_is_set(&error) == TRUE) {
191 connman_error("%s", error.message);
192 dbus_error_free(&error);
194 connman_error("Wrong arguments for disconnect");
198 connman_network_set_connected(network, FALSE);
201 dbus_message_unref(reply);
203 dbus_pending_call_unref(call);
205 connman_network_unref(network);
208 static int pan_disconnect(struct connman_network *network)
210 const char *path = connman_network_get_string(network, "Path");
211 DBusMessage *message;
212 DBusPendingCall *call;
214 DBG("network %p", network);
219 message = dbus_message_new_method_call(BLUEZ_SERVICE, path,
220 BLUEZ_NETWORK_INTERFACE, DISCONNECT);
224 dbus_message_set_auto_start(message, FALSE);
226 dbus_message_append_args(message, DBUS_TYPE_INVALID);
228 if (dbus_connection_send_with_reply(connection, message,
229 &call, TIMEOUT) == FALSE) {
230 connman_error("Failed to disconnect service");
231 dbus_message_unref(message);
236 connman_error("D-Bus connection not available");
237 dbus_message_unref(message);
241 connman_network_ref(network);
243 connman_network_set_associating(network, FALSE);
245 dbus_pending_call_set_notify(call, disconnect_reply, network, NULL);
247 dbus_message_unref(message);
252 static struct connman_network_driver pan_driver = {
253 .name = "bluetooth-pan",
254 .type = CONNMAN_NETWORK_TYPE_BLUETOOTH_PAN,
256 .remove = pan_remove,
257 .connect = pan_connect,
258 .disconnect = pan_disconnect,
261 static gboolean network_changed(DBusConnection *connection,
262 DBusMessage *message, void *user_data)
264 const char *path = dbus_message_get_path(message);
265 struct connman_network *network;
266 DBusMessageIter iter, value;
269 DBG("path %s", path);
271 network = g_hash_table_lookup(bluetooth_networks, path);
275 if (dbus_message_iter_init(message, &iter) == FALSE)
278 dbus_message_iter_get_basic(&iter, &key);
280 dbus_message_iter_next(&iter);
281 dbus_message_iter_recurse(&iter, &value);
283 if (g_str_equal(key, "Connected") == TRUE) {
284 dbus_bool_t connected;
286 dbus_message_iter_get_basic(&value, &connected);
288 if (connected == TRUE)
291 connman_network_set_associating(network, FALSE);
292 connman_network_set_connected(network, FALSE);
298 static void extract_properties(DBusMessage *reply, const char **parent,
299 const char **address,
302 dbus_bool_t *powered,
303 dbus_bool_t *scanning,
304 DBusMessageIter *uuids,
305 DBusMessageIter *networks)
307 DBusMessageIter array, dict;
309 if (dbus_message_iter_init(reply, &array) == FALSE)
312 if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY)
315 dbus_message_iter_recurse(&array, &dict);
317 while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
318 DBusMessageIter entry, value;
321 dbus_message_iter_recurse(&dict, &entry);
322 dbus_message_iter_get_basic(&entry, &key);
324 dbus_message_iter_next(&entry);
325 dbus_message_iter_recurse(&entry, &value);
327 if (g_str_equal(key, "Adapter") == TRUE) {
329 dbus_message_iter_get_basic(&value, parent);
330 } else if (g_str_equal(key, "Address") == TRUE) {
332 dbus_message_iter_get_basic(&value, address);
333 } else if (g_str_equal(key, "Name") == TRUE) {
335 dbus_message_iter_get_basic(&value, name);
336 } else if (g_str_equal(key, "Alias") == TRUE) {
338 dbus_message_iter_get_basic(&value, alias);
339 } else if (g_str_equal(key, "Powered") == TRUE) {
341 dbus_message_iter_get_basic(&value, powered);
342 } else if (g_str_equal(key, "Discovering") == TRUE) {
343 if (scanning != NULL)
344 dbus_message_iter_get_basic(&value, scanning);
345 } else if (g_str_equal(key, "Devices") == TRUE) {
346 if (networks != NULL)
347 memcpy(networks, &value, sizeof(value));
348 } else if (g_str_equal(key, "UUIDs") == TRUE) {
350 memcpy(uuids, &value, sizeof(value));
353 dbus_message_iter_next(&dict);
357 static dbus_bool_t has_pan(DBusMessageIter *array)
359 DBusMessageIter value;
361 if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_ARRAY)
364 dbus_message_iter_recurse(array, &value);
366 while (dbus_message_iter_get_arg_type(&value) == DBUS_TYPE_STRING) {
369 dbus_message_iter_get_basic(&value, &uuid);
371 if (g_strcmp0(uuid, UUID_NAP) == 0)
374 dbus_message_iter_next(&value);
380 static void network_properties_reply(DBusPendingCall *call, void *user_data)
382 char *path = user_data;
383 struct connman_device *device;
384 struct connman_network *network;
386 DBusMessageIter uuids;
387 const char *parent = NULL, *address = NULL, *name = NULL;
388 struct ether_addr addr;
391 reply = dbus_pending_call_steal_reply(call);
393 extract_properties(reply, &parent, &address, NULL, &name,
394 NULL, NULL, &uuids, NULL);
399 device = g_hash_table_lookup(bluetooth_devices, parent);
406 ether_aton_r(address, &addr);
408 snprintf(ident, 13, "%02x%02x%02x%02x%02x%02x",
409 addr.ether_addr_octet[0],
410 addr.ether_addr_octet[1],
411 addr.ether_addr_octet[2],
412 addr.ether_addr_octet[3],
413 addr.ether_addr_octet[4],
414 addr.ether_addr_octet[5]);
416 if (has_pan(&uuids) == FALSE)
419 network = connman_device_get_network(device, ident);
423 network = connman_network_create(ident,
424 CONNMAN_NETWORK_TYPE_BLUETOOTH_PAN);
428 connman_network_set_string(network, "Path", path);
430 connman_network_set_protocol(network, CONNMAN_NETWORK_PROTOCOL_IP);
432 connman_network_set_name(network, name);
434 connman_device_add_network(device, network);
436 connman_network_set_group(network, ident);
438 g_hash_table_insert(bluetooth_networks, g_strdup(path), network);
441 dbus_message_unref(reply);
443 dbus_pending_call_unref(call);
446 static void add_network(struct connman_device *device, const char *path)
448 DBusMessage *message;
449 DBusPendingCall *call;
451 DBG("path %s", path);
453 message = dbus_message_new_method_call(BLUEZ_SERVICE, path,
454 BLUEZ_DEVICE_INTERFACE, GET_PROPERTIES);
458 dbus_message_set_auto_start(message, FALSE);
460 if (dbus_connection_send_with_reply(connection, message,
461 &call, TIMEOUT) == FALSE) {
462 connman_error("Failed to get network properties for %s", path);
467 connman_error("D-Bus connection not available");
471 dbus_pending_call_set_notify(call, network_properties_reply,
472 g_strdup(path), g_free);
475 dbus_message_unref(message);
478 static void check_networks(struct connman_device *device,
479 DBusMessageIter *array)
481 DBusMessageIter value;
483 if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_ARRAY)
486 dbus_message_iter_recurse(array, &value);
488 while (dbus_message_iter_get_arg_type(&value) == DBUS_TYPE_OBJECT_PATH) {
491 dbus_message_iter_get_basic(&value, &path);
493 add_network(device, path);
495 dbus_message_iter_next(&value);
499 static gboolean adapter_changed(DBusConnection *connection,
500 DBusMessage *message, void *user_data)
502 const char *path = dbus_message_get_path(message);
503 struct connman_device *device;
504 DBusMessageIter iter, value;
507 DBG("path %s", path);
509 device = g_hash_table_lookup(bluetooth_devices, path);
513 if (dbus_message_iter_init(message, &iter) == FALSE)
516 dbus_message_iter_get_basic(&iter, &key);
518 dbus_message_iter_next(&iter);
519 dbus_message_iter_recurse(&iter, &value);
521 if (g_str_equal(key, "Powered") == TRUE) {
524 dbus_message_iter_get_basic(&value, &val);
525 connman_device_set_powered(device, val);
526 } else if (g_str_equal(key, "Discovering") == TRUE) {
529 dbus_message_iter_get_basic(&value, &val);
530 connman_device_set_scanning(device, val);
531 } else if (g_str_equal(key, "Devices") == TRUE) {
532 check_networks(device, &value);
538 static gboolean device_removed(DBusConnection *connection,
539 DBusMessage *message, void *user_data)
541 const char *network_path;
542 DBusMessageIter iter;
546 if (dbus_message_iter_init(message, &iter) == FALSE)
549 dbus_message_iter_get_basic(&iter, &network_path);
551 g_hash_table_remove(bluetooth_networks, network_path);
556 static gboolean device_changed(DBusConnection *connection,
557 DBusMessage *message, void *user_data)
559 const char *path = dbus_message_get_path(message);
560 DBusMessageIter iter, value;
563 DBG("path %s", path);
565 if (dbus_message_iter_init(message, &iter) == FALSE)
568 dbus_message_iter_get_basic(&iter, &key);
570 dbus_message_iter_next(&iter);
571 dbus_message_iter_recurse(&iter, &value);
575 if (g_str_equal(key, "UUIDs") == TRUE)
576 add_network(NULL, path);
581 static void adapter_properties_reply(DBusPendingCall *call, void *user_data)
583 char *path = user_data;
584 struct connman_device *device;
586 DBusMessageIter networks;
587 const char *address = NULL, *name = NULL;
588 dbus_bool_t powered = FALSE, scanning = FALSE;
589 struct ether_addr addr;
592 DBG("path %s", path);
594 reply = dbus_pending_call_steal_reply(call);
599 extract_properties(reply, NULL, &address, &name, NULL,
600 &powered, &scanning, NULL, &networks);
605 device = g_hash_table_lookup(bluetooth_devices, path);
609 ether_aton_r(address, &addr);
611 snprintf(ident, 13, "%02x%02x%02x%02x%02x%02x",
612 addr.ether_addr_octet[0],
613 addr.ether_addr_octet[1],
614 addr.ether_addr_octet[2],
615 addr.ether_addr_octet[3],
616 addr.ether_addr_octet[4],
617 addr.ether_addr_octet[5]);
619 device = connman_device_create(ident, CONNMAN_DEVICE_TYPE_BLUETOOTH);
623 connman_device_set_ident(device, ident);
625 connman_device_set_mode(device, CONNMAN_DEVICE_MODE_NETWORK_MULTIPLE);
627 connman_device_set_string(device, "Path", path);
629 if (connman_device_register(device) < 0) {
630 connman_device_unref(device);
634 g_hash_table_insert(bluetooth_devices, g_strdup(path), device);
637 connman_device_set_string(device, "Address", address);
638 connman_device_set_string(device, "Name", name);
639 connman_device_set_string(device, "Path", path);
641 connman_device_set_powered(device, powered);
642 connman_device_set_scanning(device, scanning);
645 check_networks(device, &networks);
648 dbus_message_unref(reply);
650 dbus_pending_call_unref(call);
653 static void add_adapter(DBusConnection *connection, const char *path)
655 DBusMessage *message;
656 DBusPendingCall *call;
658 DBG("path %s", path);
660 message = dbus_message_new_method_call(BLUEZ_SERVICE, path,
661 BLUEZ_ADAPTER_INTERFACE, GET_PROPERTIES);
665 dbus_message_set_auto_start(message, FALSE);
667 if (dbus_connection_send_with_reply(connection, message,
668 &call, TIMEOUT) == FALSE) {
669 connman_error("Failed to get adapter properties for %s", path);
674 connman_error("D-Bus connection not available");
678 dbus_pending_call_set_notify(call, adapter_properties_reply,
679 g_strdup(path), g_free);
682 dbus_message_unref(message);
685 static gboolean adapter_added(DBusConnection *connection, DBusMessage *message,
690 dbus_message_get_args(message, NULL, DBUS_TYPE_OBJECT_PATH, &path,
692 add_adapter(connection, path);
696 static void remove_adapter(DBusConnection *connection, const char *path)
698 DBG("path %s", path);
700 g_hash_table_remove(bluetooth_devices, path);
703 static gboolean adapter_removed(DBusConnection *connection, DBusMessage *message,
708 dbus_message_get_args(message, NULL, DBUS_TYPE_OBJECT_PATH, &path,
710 remove_adapter(connection, path);
714 static void list_adapters_reply(DBusPendingCall *call, void *user_data)
723 reply = dbus_pending_call_steal_reply(call);
725 dbus_error_init(&error);
727 if (dbus_set_error_from_message(&error, reply) == TRUE) {
728 connman_error("%s", error.message);
729 dbus_error_free(&error);
733 if (dbus_message_get_args(reply, &error,
734 DBUS_TYPE_ARRAY, DBUS_TYPE_OBJECT_PATH,
735 &adapters, &num_adapters,
736 DBUS_TYPE_INVALID) == FALSE) {
737 if (dbus_error_is_set(&error) == TRUE) {
738 connman_error("%s", error.message);
739 dbus_error_free(&error);
741 connman_error("Wrong arguments for adapter list");
745 for (i = 0; i < num_adapters; i++)
746 add_adapter(connection, adapters[i]);
748 g_strfreev(adapters);
751 dbus_message_unref(reply);
753 dbus_pending_call_unref(call);
756 static void unregister_device(gpointer data)
758 struct connman_device *device = data;
762 connman_device_unregister(device);
763 connman_device_unref(device);
766 static void unregister_network(gpointer data)
768 struct connman_network *network = data;
769 struct connman_device *device;
770 const char *identifier;
772 device = connman_network_get_device(network);
776 identifier = connman_network_get_identifier(network);
778 connman_device_remove_network(device, identifier);
781 static void bluetooth_connect(DBusConnection *connection, void *user_data)
783 DBusMessage *message;
784 DBusPendingCall *call;
786 DBG("connection %p", connection);
788 bluetooth_devices = g_hash_table_new_full(g_str_hash, g_str_equal,
789 g_free, unregister_device);
791 bluetooth_networks = g_hash_table_new_full(g_str_hash, g_str_equal,
792 g_free, unregister_network);
794 message = dbus_message_new_method_call(BLUEZ_SERVICE, "/",
795 BLUEZ_MANAGER_INTERFACE, LIST_ADAPTERS);
799 dbus_message_set_auto_start(message, FALSE);
801 if (dbus_connection_send_with_reply(connection, message,
802 &call, TIMEOUT) == FALSE) {
803 connman_error("Failed to get Bluetooth adapters");
808 connman_error("D-Bus connection not available");
812 dbus_pending_call_set_notify(call, list_adapters_reply, NULL, NULL);
815 dbus_message_unref(message);
818 static void bluetooth_disconnect(DBusConnection *connection, void *user_data)
820 DBG("connection %p", connection);
822 if (bluetooth_devices == NULL)
825 g_hash_table_destroy(bluetooth_networks);
826 g_hash_table_destroy(bluetooth_devices);
827 bluetooth_devices = NULL;
830 static int bluetooth_probe(struct connman_device *device)
832 DBG("device %p", device);
837 static void bluetooth_remove(struct connman_device *device)
839 DBG("device %p", device);
842 static void powered_reply(DBusPendingCall *call, void *user_data)
849 reply = dbus_pending_call_steal_reply(call);
851 dbus_error_init(&error);
853 if (dbus_set_error_from_message(&error, reply) == TRUE) {
854 connman_error("%s", error.message);
855 dbus_error_free(&error);
856 dbus_message_unref(reply);
857 dbus_pending_call_unref(call);
861 dbus_message_unref(reply);
862 dbus_pending_call_unref(call);
864 add_adapter(connection, user_data);
867 static int change_powered(DBusConnection *connection, const char *path,
870 DBusMessage *message;
871 DBusMessageIter iter;
872 DBusPendingCall *call;
879 message = dbus_message_new_method_call(BLUEZ_SERVICE, path,
880 BLUEZ_ADAPTER_INTERFACE, SET_PROPERTY);
884 dbus_message_set_auto_start(message, FALSE);
886 dbus_message_iter_init_append(message, &iter);
887 connman_dbus_property_append_basic(&iter, "Powered",
888 DBUS_TYPE_BOOLEAN, &powered);
890 if (dbus_connection_send_with_reply(connection, message,
891 &call, TIMEOUT) == FALSE) {
892 connman_error("Failed to change Powered property");
893 dbus_message_unref(message);
898 connman_error("D-Bus connection not available");
899 dbus_message_unref(message);
903 dbus_pending_call_set_notify(call, powered_reply,
904 g_strdup(path), g_free);
906 dbus_message_unref(message);
911 static int bluetooth_enable(struct connman_device *device)
913 const char *path = connman_device_get_string(device, "Path");
915 DBG("device %p", device);
917 return change_powered(connection, path, TRUE);
920 static int bluetooth_disable(struct connman_device *device)
922 const char *path = connman_device_get_string(device, "Path");
924 DBG("device %p", device);
926 return change_powered(connection, path, FALSE);
929 static struct connman_device_driver bluetooth_driver = {
931 .type = CONNMAN_DEVICE_TYPE_BLUETOOTH,
932 .probe = bluetooth_probe,
933 .remove = bluetooth_remove,
934 .enable = bluetooth_enable,
935 .disable = bluetooth_disable,
938 static int tech_probe(struct connman_technology *technology)
943 static void tech_remove(struct connman_technology *technology)
947 static int tech_set_tethering(struct connman_technology *technology,
948 connman_bool_t enabled)
953 static struct connman_technology_driver tech_driver = {
955 .type = CONNMAN_SERVICE_TYPE_BLUETOOTH,
957 .remove = tech_remove,
958 .set_tethering = tech_set_tethering,
962 static guint added_watch;
963 static guint removed_watch;
964 static guint adapter_watch;
965 static guint device_watch;
966 static guint device_removed_watch;
967 static guint network_watch;
969 static int bluetooth_init(void)
973 connection = connman_dbus_get_connection();
974 if (connection == NULL)
977 watch = g_dbus_add_service_watch(connection, BLUEZ_SERVICE,
978 bluetooth_connect, bluetooth_disconnect, NULL, NULL);
980 added_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
981 BLUEZ_MANAGER_INTERFACE,
982 ADAPTER_ADDED, adapter_added,
985 removed_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
986 BLUEZ_MANAGER_INTERFACE,
987 ADAPTER_REMOVED, adapter_removed,
990 adapter_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
991 BLUEZ_ADAPTER_INTERFACE,
992 PROPERTY_CHANGED, adapter_changed,
995 device_removed_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
996 BLUEZ_ADAPTER_INTERFACE,
997 DEVICE_REMOVED, device_removed,
1000 device_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
1001 BLUEZ_DEVICE_INTERFACE,
1002 PROPERTY_CHANGED, device_changed,
1005 network_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
1006 BLUEZ_NETWORK_INTERFACE,
1007 PROPERTY_CHANGED, network_changed,
1010 if (watch == 0 || added_watch == 0 || removed_watch == 0
1011 || adapter_watch == 0 || network_watch == 0
1012 || device_watch == 0
1013 || device_removed_watch == 0) {
1018 err = connman_network_driver_register(&pan_driver);
1022 err = connman_device_driver_register(&bluetooth_driver);
1024 connman_network_driver_unregister(&pan_driver);
1028 err = connman_technology_driver_register(&tech_driver);
1030 connman_device_driver_unregister(&bluetooth_driver);
1031 connman_network_driver_unregister(&pan_driver);
1038 g_dbus_remove_watch(connection, watch);
1039 g_dbus_remove_watch(connection, added_watch);
1040 g_dbus_remove_watch(connection, removed_watch);
1041 g_dbus_remove_watch(connection, adapter_watch);
1042 g_dbus_remove_watch(connection, device_removed_watch);
1043 g_dbus_remove_watch(connection, device_watch);
1044 g_dbus_remove_watch(connection, network_watch);
1046 dbus_connection_unref(connection);
1051 static void bluetooth_exit(void)
1053 g_dbus_remove_watch(connection, watch);
1054 g_dbus_remove_watch(connection, added_watch);
1055 g_dbus_remove_watch(connection, removed_watch);
1056 g_dbus_remove_watch(connection, adapter_watch);
1057 g_dbus_remove_watch(connection, device_removed_watch);
1058 g_dbus_remove_watch(connection, device_watch);
1059 g_dbus_remove_watch(connection, network_watch);
1061 bluetooth_disconnect(connection, NULL);
1063 connman_technology_driver_unregister(&tech_driver);
1065 connman_device_driver_unregister(&bluetooth_driver);
1066 connman_network_driver_unregister(&pan_driver);
1068 dbus_connection_unref(connection);
1071 CONNMAN_PLUGIN_DEFINE(bluetooth, "Bluetooth technology plugin", VERSION,
1072 CONNMAN_PLUGIN_PRIORITY_DEFAULT, bluetooth_init, bluetooth_exit)