diff options
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | po/POTFILES.in | 4 | ||||
-rw-r--r-- | src/Makefile.am | 18 | ||||
-rw-r--r-- | src/bluez-manager/nm-bluez-manager.h | 71 | ||||
-rw-r--r-- | src/devices/bluetooth/Makefile.am | 56 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-bluez-common.h (renamed from src/bluez-manager/nm-bluez-common.h) | 0 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-bluez-device.c (renamed from src/bluez-manager/nm-bluez-device.c) | 8 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-bluez-device.h (renamed from src/bluez-manager/nm-bluez-device.h) | 8 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-bluez-manager.c (renamed from src/bluez-manager/nm-bluez-manager.c) | 196 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-bluez-manager.h | 44 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-bluez4-adapter.c (renamed from src/bluez-manager/nm-bluez4-adapter.c) | 0 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-bluez4-adapter.h (renamed from src/bluez-manager/nm-bluez4-adapter.h) | 0 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-bluez4-manager.c (renamed from src/bluez-manager/nm-bluez4-manager.c) | 26 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-bluez4-manager.h (renamed from src/bluez-manager/nm-bluez4-manager.h) | 6 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-bluez5-manager.c (renamed from src/bluez-manager/nm-bluez5-manager.c) | 21 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-bluez5-manager.h (renamed from src/bluez-manager/nm-bluez5-manager.h) | 6 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-device-bt.c (renamed from src/devices/nm-device-bt.c) | 13 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-device-bt.h (renamed from src/devices/nm-device-bt.h) | 0 | ||||
-rw-r--r-- | src/nm-manager.c | 88 |
19 files changed, 204 insertions, 362 deletions
diff --git a/configure.ac b/configure.ac index b428649997..79aa225fd5 100644 --- a/configure.ac +++ b/configure.ac @@ -764,6 +764,7 @@ src/rdisc/Makefile src/rdisc/tests/Makefile src/devices/atm/Makefile src/devices/wimax/Makefile +src/devices/bluetooth/Makefile libnm-util/libnm-util.pc libnm-util/Makefile libnm-util/tests/Makefile diff --git a/po/POTFILES.in b/po/POTFILES.in index 9806ceba19..fa7806f3f4 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -40,7 +40,6 @@ libnm-util/nm-setting-wireless.c libnm-util/nm-utils.c policy/org.freedesktop.NetworkManager.policy.in.in src/main.c -src/bluez-manager/nm-bluez-device.c src/dhcp-manager/nm-dhcp-dhclient.c src/dhcp-manager/nm-dhcp-dhclient-utils.c src/dhcp-manager/nm-dhcp-manager.c @@ -50,9 +49,10 @@ src/config/nm-config.c src/devices/atm/nm-device-adsl.c src/modem-manager/nm-modem-broadband.c src/modem-manager/nm-modem-old.c +src/devices/bluetooth/nm-bluez-device.c +src/devices/bluetooth/nm-device-bt.c src/devices/nm-device-bond.c src/devices/nm-device-bridge.c -src/devices/nm-device-bt.c src/devices/nm-device-ethernet.c src/devices/nm-device-infiniband.c src/devices/nm-device-olpc-mesh.c diff --git a/src/Makefile.am b/src/Makefile.am index 9ca1d68438..a50932ed20 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,6 +5,7 @@ include $(GLIB_MAKEFILE) SUBDIRS = \ . \ devices/atm \ + devices/bluetooth \ dhcp-manager \ ppp-manager \ settings/plugins @@ -52,18 +53,6 @@ NetworkManager_LDADD = libNetworkManager.la $(top_builddir)/libgsystem.la $(LIBN noinst_LTLIBRARIES = libNetworkManager.la nm_sources = \ - bluez-manager/nm-bluez-common.h \ - bluez-manager/nm-bluez-device.c \ - bluez-manager/nm-bluez-device.h \ - bluez-manager/nm-bluez-manager.c \ - bluez-manager/nm-bluez-manager.h \ - bluez-manager/nm-bluez4-adapter.c \ - bluez-manager/nm-bluez4-adapter.h \ - bluez-manager/nm-bluez4-manager.c \ - bluez-manager/nm-bluez4-manager.h \ - bluez-manager/nm-bluez5-manager.c \ - bluez-manager/nm-bluez5-manager.h \ - \ config/nm-config.c \ config/nm-config.h \ config/nm-config-device.c \ @@ -75,8 +64,6 @@ nm_sources = \ devices/nm-device-bond.h \ devices/nm-device-bridge.c \ devices/nm-device-bridge.h \ - devices/nm-device-bt.c \ - devices/nm-device-bt.h \ devices/nm-device-ethernet.c \ devices/nm-device-ethernet.h \ devices/nm-device-factory.c \ @@ -303,8 +290,8 @@ endif GLIB_GENERATED = nm-enum-types.h nm-enum-types.c GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM - nm_enum_types_sources = $(nm_sources) + if WITH_WIMAX nm_enum_types_sources += devices/wimax/nm-device-wimax.h AM_CPPFLAGS += -I$(top_srcdir)/src/devices/wimax @@ -319,7 +306,6 @@ glue_sources = \ nm-agent-manager-glue.h \ nm-device-bond-glue.h \ nm-device-bridge-glue.h \ - nm-device-bt-glue.h \ nm-device-ethernet-glue.h \ nm-device-generic-glue.h \ nm-device-glue.h \ diff --git a/src/bluez-manager/nm-bluez-manager.h b/src/bluez-manager/nm-bluez-manager.h deleted file mode 100644 index 836416fa8c..0000000000 --- a/src/bluez-manager/nm-bluez-manager.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2013 Red Hat, Inc. - */ - -#ifndef NM_BLUEZ_MANAGER_H -#define NM_BLUEZ_MANAGER_H - -#include <glib.h> -#include <glib-object.h> - -#include <config.h> -#include "nm-connection-provider.h" - -G_BEGIN_DECLS - -#define NM_TYPE_BLUEZ_MANAGER (nm_bluez_manager_get_type ()) -#define NM_BLUEZ_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_BLUEZ_MANAGER, NMBluezManager)) -#define NM_BLUEZ_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_BLUEZ_MANAGER, NMBluezManagerClass)) -#define NM_IS_BLUEZ_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_BLUEZ_MANAGER)) -#define NM_IS_BLUEZ_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_BLUEZ_MANAGER)) -#define NM_BLUEZ_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_BLUEZ_MANAGER, NMBluezManagerClass)) - -#define NM_BLUEZ_MANAGER_BDADDR_ADDED "bdaddr-added" -#define NM_BLUEZ_MANAGER_BDADDR_REMOVED "bdaddr-removed" - -#define NM_BLUEZ_MANAGER_PROVIDER "provider" - -typedef struct { - GObject parent; -} NMBluezManager; - -typedef struct { - GObjectClass parent; - - /* Virtual functions */ - void (*bdaddr_added) (NMBluezManager *manager, - const char *bdaddr, - const char *name, - const char *object_path, - guint uuids); - - void (*bdaddr_removed) (NMBluezManager *manager, - const char *bdaddr, - const char *object_path); -} NMBluezManagerClass; - -GType nm_bluez_manager_get_type (void); - -NMBluezManager *nm_bluez_manager_new (NMConnectionProvider *provider); - -void nm_bluez_manager_query_devices (NMBluezManager *manager); - -#endif /* NM_BLUEZ_MANAGER_H */ - diff --git a/src/devices/bluetooth/Makefile.am b/src/devices/bluetooth/Makefile.am new file mode 100644 index 0000000000..7713fc9124 --- /dev/null +++ b/src/devices/bluetooth/Makefile.am @@ -0,0 +1,56 @@ +include $(GLIB_MAKEFILE) + +@GNOME_CODE_COVERAGE_RULES@ + +AM_CPPFLAGS = \ + -I${top_srcdir}/src \ + -I${top_builddir}/src \ + -I${top_srcdir}/src/logging \ + -I${top_srcdir}/src/devices \ + -I${top_srcdir}/src/settings \ + -I${top_srcdir}/src/platform \ + -I${top_srcdir}/src/modem-manager \ + -I${top_builddir}/include \ + -I${top_srcdir}/include \ + -I${top_builddir}/libnm-util \ + -I${top_srcdir}/libnm-util \ + $(DBUS_CFLAGS) \ + $(POLKIT_CFLAGS) \ + $(LIBNL_CFLAGS) \ + $(GUDEV_CFLAGS) + +GLIB_GENERATED = nm-bt-enum-types.h nm-bt-enum-types.c +GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM +GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM +nm_bt_enum_types_sources = $(srcdir)/nm-device-bt.h + +nm-device-bt-glue.h: $(top_srcdir)/introspection/nm-device-bt.xml + dbus-binding-tool --prefix=nm_device_bt --mode=glib-server --output=$@ $< + +BUILT_SOURCES = $(GLIB_GENERATED) nm-device-bt-glue.h + +pkglib_LTLIBRARIES = libnm-device-plugin-bt.la + +libnm_device_plugin_bt_la_SOURCES = \ + nm-bluez-manager.c \ + nm-bluez-manager.h \ + nm-bluez-common.h \ + nm-bluez-device.c \ + nm-bluez-device.h \ + nm-bluez4-adapter.c \ + nm-bluez4-adapter.h \ + nm-bluez4-manager.c \ + nm-bluez4-manager.h \ + nm-bluez5-manager.c \ + nm-bluez5-manager.h \ + \ + nm-device-bt.c \ + nm-device-bt.h \ + \ + $(BUILT_SOURCES) + +libnm_device_plugin_bt_la_LDFLAGS = -module -avoid-version +libnm_device_plugin_bt_la_LIBADD = $(DBUS_LIBS) $(GUDEV_LIBS) + +CLEANFILES = $(BUILT_SOURCES) + diff --git a/src/bluez-manager/nm-bluez-common.h b/src/devices/bluetooth/nm-bluez-common.h index f80cfc2e39..f80cfc2e39 100644 --- a/src/bluez-manager/nm-bluez-common.h +++ b/src/devices/bluetooth/nm-bluez-common.h diff --git a/src/bluez-manager/nm-bluez-device.c b/src/devices/bluetooth/nm-bluez-device.c index 8e8f39d066..e04e8d4dee 100644 --- a/src/bluez-manager/nm-bluez-device.c +++ b/src/devices/bluetooth/nm-bluez-device.c @@ -87,6 +87,7 @@ enum { /* Signals */ enum { INITIALIZED, + REMOVED, LAST_SIGNAL }; static guint signals[LAST_SIGNAL] = { 0 }; @@ -1169,5 +1170,12 @@ nm_bluez_device_class_init (NMBluezDeviceClass *config_class) G_STRUCT_OFFSET (NMBluezDeviceClass, initialized), NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_BOOLEAN); + + signals[REMOVED] = g_signal_new (NM_BLUEZ_DEVICE_REMOVED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (NMBluezDeviceClass, removed), + NULL, NULL, NULL, + G_TYPE_NONE, 0); } diff --git a/src/bluez-manager/nm-bluez-device.h b/src/devices/bluetooth/nm-bluez-device.h index 5e586ea5bb..0bf7d898b0 100644 --- a/src/bluez-manager/nm-bluez-device.h +++ b/src/devices/bluetooth/nm-bluez-device.h @@ -15,7 +15,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright (C) 2009 - 2012 Red Hat, Inc. + * Copyright (C) 2009 - 2014 Red Hat, Inc. */ #ifndef NM_BLUEZ_DEVICE_H @@ -36,6 +36,7 @@ #define NM_IS_BLUEZ_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_BLUEZ_DEVICE)) #define NM_BLUEZ_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_BLUEZ_DEVICE, NMBluezDeviceClass)) +/* Properties */ #define NM_BLUEZ_DEVICE_PATH "path" #define NM_BLUEZ_DEVICE_ADDRESS "address" #define NM_BLUEZ_DEVICE_NAME "name" @@ -43,6 +44,9 @@ #define NM_BLUEZ_DEVICE_USABLE "usable" #define NM_BLUEZ_DEVICE_CONNECTED "connected" +/* Signals */ +#define NM_BLUEZ_DEVICE_REMOVED "removed" + typedef struct { GObject parent; } NMBluezDevice; @@ -53,7 +57,7 @@ typedef struct { /* virtual functions */ void (*initialized) (NMBluezDevice *self, gboolean success); - void (*invalid) (NMBluezDevice *self); + void (*removed) (NMBluezDevice *self); } NMBluezDeviceClass; GType nm_bluez_device_get_type (void); diff --git a/src/bluez-manager/nm-bluez-manager.c b/src/devices/bluetooth/nm-bluez-manager.c index b3026bc1f5..26ccb70c1a 100644 --- a/src/bluez-manager/nm-bluez-manager.c +++ b/src/devices/bluetooth/nm-bluez-manager.c @@ -15,7 +15,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright (C) 2013 Red Hat, Inc. + * Copyright (C) 2013 - 2014 Red Hat, Inc. */ #include <signal.h> @@ -25,10 +25,13 @@ #include "nm-logging.h" #include "nm-bluez-manager.h" +#include "nm-device-factory.h" #include "nm-bluez4-manager.h" #include "nm-bluez5-manager.h" #include "nm-bluez-device.h" #include "nm-bluez-common.h" +#include "nm-connection-provider.h" +#include "nm-device-bt.h" #include "nm-dbus-manager.h" @@ -47,27 +50,38 @@ typedef struct { #define NM_BLUEZ_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_BLUEZ_MANAGER, NMBluezManagerPrivate)) -G_DEFINE_TYPE (NMBluezManager, nm_bluez_manager, G_TYPE_OBJECT) +static GType nm_bluez_manager_get_type (void); -enum { - PROP_0, - PROP_PROVIDER, +static void device_factory_interface_init (NMDeviceFactory *factory_iface); - LAST_PROP -}; +G_DEFINE_TYPE_EXTENDED (NMBluezManager, nm_bluez_manager, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_DEVICE_FACTORY, device_factory_interface_init)) enum { - BDADDR_ADDED, - BDADDR_REMOVED, - - LAST_SIGNAL + PROP_0, + PROP_DEVICE_TYPE, + LAST_PROP }; -static guint signals[LAST_SIGNAL] = { 0 }; +static void check_bluez_and_try_setup (NMBluezManager *self); +/**************************************************************************/ -static void check_bluez_and_try_setup (NMBluezManager *self); +#define PLUGIN_TYPE NM_DEVICE_TYPE_BT +G_MODULE_EXPORT NMDeviceFactory * +nm_device_factory_create (GError **error) +{ + return (NMDeviceFactory *) g_object_new (NM_TYPE_BLUEZ_MANAGER, NULL); +} + +G_MODULE_EXPORT NMDeviceType +nm_device_factory_get_device_type (void) +{ + return PLUGIN_TYPE; +} + +/************************************************************************/ struct AsyncData { NMBluezManager *self; @@ -125,31 +139,34 @@ manager_bdaddr_added_cb (NMBluez4Manager *bluez_mgr, const char *bdaddr, const char *name, const char *object_path, - guint32 uuids, + guint32 capabilities, gpointer user_data) { - /* forward the signal... */ - g_signal_emit (NM_BLUEZ_MANAGER (user_data), signals[BDADDR_ADDED], 0, - bt_device, - bdaddr, - name, - object_path, - uuids); -} + NMBluezManager *self = NM_BLUEZ_MANAGER (user_data); + NMDevice *device; + gboolean has_dun = (capabilities & NM_BT_CAPABILITY_DUN); + gboolean has_nap = (capabilities & NM_BT_CAPABILITY_NAP); + + g_return_if_fail (bdaddr != NULL); + g_return_if_fail (name != NULL); + g_return_if_fail (object_path != NULL); + g_return_if_fail (capabilities != NM_BT_CAPABILITY_NONE); + g_return_if_fail (NM_IS_BLUEZ_DEVICE (bt_device)); + + device = nm_device_bt_new (bt_device, object_path, bdaddr, name, capabilities); + if (!device) + return; -static void -manager_bdaddr_removed_cb (NMBluez4Manager *bluez_mgr, - const char *bdaddr, - const char *object_path, - gpointer user_data) -{ - /* forward the signal... */ - g_signal_emit (NM_BLUEZ_MANAGER (user_data), signals[BDADDR_REMOVED], 0, - bdaddr, - object_path); + nm_log_info (LOGD_BT, "BT device %s (%s) added (%s%s%s)", + name, + bdaddr, + has_dun ? "DUN" : "", + has_dun && has_nap ? " " : "", + has_nap ? "NAP" : ""); + g_signal_emit_by_name (self, NM_DEVICE_FACTORY_DEVICE_ADDED, device); + g_object_unref (device); } - static void setup_version_number (NMBluezManager *self, int bluez_version) { @@ -180,10 +197,6 @@ setup_bluez4 (NMBluezManager *self) NM_BLUEZ_MANAGER_BDADDR_ADDED, G_CALLBACK (manager_bdaddr_added_cb), self); - g_signal_connect (manager, - NM_BLUEZ_MANAGER_BDADDR_REMOVED, - G_CALLBACK (manager_bdaddr_removed_cb), - self); nm_bluez4_manager_query_devices (manager); } @@ -203,10 +216,6 @@ setup_bluez5 (NMBluezManager *self) NM_BLUEZ_MANAGER_BDADDR_ADDED, G_CALLBACK (manager_bdaddr_added_cb), self); - g_signal_connect (manager, - NM_BLUEZ_MANAGER_BDADDR_REMOVED, - G_CALLBACK (manager_bdaddr_removed_cb), - self); nm_bluez5_manager_query_devices (manager); } @@ -364,64 +373,15 @@ check_bluez_and_try_setup (NMBluezManager *self) async_data_pack (self)); } - -void -nm_bluez_manager_query_devices (NMBluezManager *self) -{ - NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE (self); - - switch (priv->bluez_version) { - case 4: - nm_bluez4_manager_query_devices (priv->manager4); - break; - case 5: - nm_bluez5_manager_query_devices (priv->manager5); - break; - default: - /* the proxy implementation does nothing in this case. */ - break; - } -} - - -NMBluezManager * -nm_bluez_manager_new (NMConnectionProvider *provider) -{ - g_return_val_if_fail (NM_IS_CONNECTION_PROVIDER (provider), NULL); - - return g_object_new (NM_TYPE_BLUEZ_MANAGER, - NM_BLUEZ_MANAGER_PROVIDER, - provider, - NULL); -} - - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_PROVIDER: - /* Construct only */ - priv->provider = g_value_dup_object (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} +/*********************************************************************/ static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE (object); - switch (prop_id) { - case PROP_PROVIDER: - g_value_set_object (value, priv->provider); + case PROP_DEVICE_TYPE: + g_value_set_uint (value, PLUGIN_TYPE); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -429,23 +389,18 @@ get_property (GObject *object, guint prop_id, } } - static void dispose (GObject *object) { NMBluezManager *self = NM_BLUEZ_MANAGER (object); NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE (self); - g_clear_object (&priv->provider); - if (priv->manager4) { - g_signal_handlers_disconnect_by_func (priv->manager4, G_CALLBACK (manager_bdaddr_added_cb), self); - g_signal_handlers_disconnect_by_func (priv->manager4, G_CALLBACK (manager_bdaddr_removed_cb), self); + g_signal_handlers_disconnect_by_func (priv->manager4, manager_bdaddr_added_cb, self); g_clear_object (&priv->manager4); } if (priv->manager5) { - g_signal_handlers_disconnect_by_func (priv->manager5, G_CALLBACK (manager_bdaddr_added_cb), self); - g_signal_handlers_disconnect_by_func (priv->manager5, G_CALLBACK (manager_bdaddr_removed_cb), self); + g_signal_handlers_disconnect_by_func (priv->manager5, manager_bdaddr_added_cb, self); g_clear_object (&priv->manager5); } @@ -458,18 +413,24 @@ static void constructed (GObject *object) { NMBluezManager *self = NM_BLUEZ_MANAGER (object); - NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE (self); G_OBJECT_CLASS (nm_bluez_manager_parent_class)->constructed (object); - g_return_if_fail (priv->provider); - check_bluez_and_try_setup (self); } static void nm_bluez_manager_init (NMBluezManager *self) { + NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE (self); + + priv->provider = nm_connection_provider_get (); + g_assert (priv->provider); +} + +static void +device_factory_interface_init (NMDeviceFactory *factory_iface) +{ } static void @@ -482,33 +443,10 @@ nm_bluez_manager_class_init (NMBluezManagerClass *klass) /* virtual methods */ object_class->dispose = dispose; object_class->get_property = get_property; - object_class->set_property = set_property; object_class->constructed = constructed; - g_object_class_install_property - (object_class, PROP_PROVIDER, - g_param_spec_object (NM_BLUEZ_MANAGER_PROVIDER, - "Provider", - "Connection Provider", - NM_TYPE_CONNECTION_PROVIDER, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - /* Signals */ - signals[BDADDR_ADDED] = - g_signal_new (NM_BLUEZ_MANAGER_BDADDR_ADDED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMBluezManagerClass, bdaddr_added), - NULL, NULL, NULL, - G_TYPE_NONE, 5, G_TYPE_OBJECT, G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT); - - signals[BDADDR_REMOVED] = - g_signal_new (NM_BLUEZ_MANAGER_BDADDR_REMOVED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMBluezManagerClass, bdaddr_removed), - NULL, NULL, NULL, - G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); + g_object_class_override_property (object_class, + PROP_DEVICE_TYPE, + NM_DEVICE_FACTORY_DEVICE_TYPE); } diff --git a/src/devices/bluetooth/nm-bluez-manager.h b/src/devices/bluetooth/nm-bluez-manager.h new file mode 100644 index 0000000000..68d6dbe5e8 --- /dev/null +++ b/src/devices/bluetooth/nm-bluez-manager.h @@ -0,0 +1,44 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2014 Red Hat, Inc. + */ + +#ifndef NM_BLUEZ_MANAGER_H +#define NM_BLUEZ_MANAGER_H + +#include <glib.h> +#include <glib-object.h> + +G_BEGIN_DECLS + +#define NM_TYPE_BLUEZ_MANAGER (nm_bluez_manager_get_type ()) +#define NM_BLUEZ_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_BLUEZ_MANAGER, NMBluezManager)) + +#define NM_BLUEZ_MANAGER_BDADDR_ADDED "bdaddr-added" + +typedef struct { + GObject parent; +} NMBluezManager; + +typedef struct { + GObjectClass parent; +} NMBluezManagerClass; + +#endif /* NM_BLUEZ_MANAGER_H */ + diff --git a/src/bluez-manager/nm-bluez4-adapter.c b/src/devices/bluetooth/nm-bluez4-adapter.c index ad1786f02a..ad1786f02a 100644 --- a/src/bluez-manager/nm-bluez4-adapter.c +++ b/src/devices/bluetooth/nm-bluez4-adapter.c diff --git a/src/bluez-manager/nm-bluez4-adapter.h b/src/devices/bluetooth/nm-bluez4-adapter.h index 454ca557eb..454ca557eb 100644 --- a/src/bluez-manager/nm-bluez4-adapter.h +++ b/src/devices/bluetooth/nm-bluez4-adapter.h diff --git a/src/bluez-manager/nm-bluez4-manager.c b/src/devices/bluetooth/nm-bluez4-manager.c index 58162f0a81..2660cbd924 100644 --- a/src/bluez-manager/nm-bluez4-manager.c +++ b/src/devices/bluetooth/nm-bluez4-manager.c @@ -50,8 +50,6 @@ G_DEFINE_TYPE (NMBluez4Manager, nm_bluez4_manager, G_TYPE_OBJECT) enum { BDADDR_ADDED, - BDADDR_REMOVED, - LAST_SIGNAL }; @@ -93,11 +91,8 @@ device_added (NMBluez4Adapter *adapter, NMBluezDevice *device, gpointer user_dat static void device_removed (NMBluez4Adapter *adapter, NMBluezDevice *device, gpointer user_data) { - NMBluez4Manager *self = NM_BLUEZ4_MANAGER (user_data); - - g_signal_emit (self, signals[BDADDR_REMOVED], 0, - nm_bluez_device_get_address (device), - nm_bluez_device_get_path (device)); + /* Re-emit the signal on the device for now; flatten this later */ + g_signal_emit_by_name (device, NM_BLUEZ_DEVICE_REMOVED); } static void @@ -132,13 +127,8 @@ adapter_removed (DBusGProxy *proxy, const char *path, NMBluez4Manager *self) GSList *devices, *iter; devices = nm_bluez4_adapter_get_devices (priv->adapter); - for (iter = devices; iter; iter = g_slist_next (iter)) { - NMBluezDevice *device = NM_BLUEZ_DEVICE (iter->data); - - g_signal_emit (self, signals[BDADDR_REMOVED], 0, - nm_bluez_device_get_address (device), - nm_bluez_device_get_path (device)); - } + for (iter = devices; iter; iter = g_slist_next (iter)) + g_signal_emit_by_name (NM_BLUEZ_DEVICE (iter->data), NM_BLUEZ_DEVICE_REMOVED); g_slist_free (devices); } @@ -367,13 +357,5 @@ nm_bluez4_manager_class_init (NMBluez4ManagerClass *klass) NULL, NULL, NULL, G_TYPE_NONE, 5, G_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT); - - signals[BDADDR_REMOVED] = - g_signal_new (NM_BLUEZ_MANAGER_BDADDR_REMOVED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMBluez4ManagerClass, bdaddr_removed), - NULL, NULL, NULL, - G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); } diff --git a/src/bluez-manager/nm-bluez4-manager.h b/src/devices/bluetooth/nm-bluez4-manager.h index 20e6c1bc18..19b1c65a1b 100644 --- a/src/bluez-manager/nm-bluez4-manager.h +++ b/src/devices/bluetooth/nm-bluez4-manager.h @@ -44,16 +44,12 @@ typedef struct { typedef struct { GObjectClass parent; - /* Virtual functions */ + /* Signals */ void (*bdaddr_added) (NMBluez4Manager *manager, const char *bdaddr, const char *name, const char *object_path, guint uuids); - - void (*bdaddr_removed) (NMBluez4Manager *manager, - const char *bdaddr, - const char *object_path); } NMBluez4ManagerClass; GType nm_bluez4_manager_get_type (void); diff --git a/src/bluez-manager/nm-bluez5-manager.c b/src/devices/bluetooth/nm-bluez5-manager.c index 77e5bdd4ba..63006b3ab8 100644 --- a/src/bluez-manager/nm-bluez5-manager.c +++ b/src/devices/bluetooth/nm-bluez5-manager.c @@ -50,8 +50,6 @@ G_DEFINE_TYPE (NMBluez5Manager, nm_bluez5_manager, G_TYPE_OBJECT) enum { BDADDR_ADDED, - BDADDR_REMOVED, - LAST_SIGNAL }; @@ -88,13 +86,10 @@ nm_bluez5_manager_query_devices (NMBluez5Manager *self) static void remove_device (NMBluez5Manager *self, NMBluezDevice *device) { - if (nm_bluez_device_get_usable (device)) { - g_signal_emit (self, signals[BDADDR_REMOVED], 0, - nm_bluez_device_get_address (device), - nm_bluez_device_get_path (device)); - } g_signal_handlers_disconnect_by_func (device, G_CALLBACK (device_initialized), self); g_signal_handlers_disconnect_by_func (device, G_CALLBACK (device_usable), self); + if (nm_bluez_device_get_usable (device)) + g_signal_emit_by_name (device, NM_BLUEZ_DEVICE_REMOVED); } static void @@ -127,9 +122,7 @@ device_usable (NMBluezDevice *device, GParamSpec *pspec, NMBluez5Manager *self) nm_bluez_device_get_address (device)); emit_bdaddr_added (self, device); } else - g_signal_emit (self, signals[BDADDR_REMOVED], 0, - nm_bluez_device_get_address (device), - nm_bluez_device_get_path (device)); + g_signal_emit_by_name (device, NM_BLUEZ_DEVICE_REMOVED); } static void @@ -425,12 +418,4 @@ nm_bluez5_manager_class_init (NMBluez5ManagerClass *klass) NULL, NULL, NULL, G_TYPE_NONE, 5, G_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT); - - signals[BDADDR_REMOVED] = - g_signal_new (NM_BLUEZ_MANAGER_BDADDR_REMOVED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMBluez5ManagerClass, bdaddr_removed), - NULL, NULL, NULL, - G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); } diff --git a/src/bluez-manager/nm-bluez5-manager.h b/src/devices/bluetooth/nm-bluez5-manager.h index 9cef5fd344..79f347bcef 100644 --- a/src/bluez-manager/nm-bluez5-manager.h +++ b/src/devices/bluetooth/nm-bluez5-manager.h @@ -44,16 +44,12 @@ typedef struct { typedef struct { GObjectClass parent; - /* Virtual functions */ + /* Signals */ void (*bdaddr_added) (NMBluez5Manager *manager, const char *bdaddr, const char *name, const char *object_path, guint uuids); - - void (*bdaddr_removed) (NMBluez5Manager *manager, - const char *bdaddr, - const char *object_path); } NMBluez5ManagerClass; GType nm_bluez5_manager_get_type (void); diff --git a/src/devices/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c index ecb015b03c..6998bb1e20 100644 --- a/src/devices/nm-device-bt.c +++ b/src/devices/bluetooth/nm-device-bt.c @@ -44,7 +44,7 @@ #include "nm-setting-ppp.h" #include "nm-device-bt-glue.h" #include "NetworkManagerUtils.h" -#include "nm-enum-types.h" +#include "nm-bt-enum-types.h" #include "nm-utils.h" #define MM_OLD_DBUS_SERVICE "org.freedesktop.ModemManager" @@ -926,6 +926,12 @@ deactivate (NMDevice *device) NM_DEVICE_CLASS (nm_device_bt_parent_class)->deactivate (device); } +static void +bluez_device_removed (NMBluezDevice *bdev, gpointer user_data) +{ + g_signal_emit_by_name (NM_DEVICE_BT (user_data), NM_DEVICE_REMOVED); +} + /*****************************************************************************/ static gboolean @@ -1116,6 +1122,7 @@ set_property (GObject *object, guint prop_id, case PROP_BT_DEVICE: /* Construct only */ priv->bt_device = g_value_dup_object (value); + g_signal_connect (priv->bt_device, "removed", G_CALLBACK (bluez_device_removed), object); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -1155,9 +1162,7 @@ dispose (GObject *object) priv->timeout_id = 0; } - g_signal_handlers_disconnect_by_func (priv->bt_device, - G_CALLBACK (bluez_connected_changed), - object); + g_signal_handlers_disconnect_matched (priv->bt_device, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, object); if (priv->dbus_mgr && priv->mm_watch_id) { g_signal_handler_disconnect (priv->dbus_mgr, priv->mm_watch_id); diff --git a/src/devices/nm-device-bt.h b/src/devices/bluetooth/nm-device-bt.h index 83732bc09e..83732bc09e 100644 --- a/src/devices/nm-device-bt.h +++ b/src/devices/bluetooth/nm-device-bt.h diff --git a/src/nm-manager.c b/src/nm-manager.c index fa76575cf0..2d6c0f1121 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -40,7 +40,6 @@ #include "nm-dbus-manager.h" #include "nm-vpn-manager.h" #include "nm-modem-manager.h" -#include "nm-device-bt.h" #include "nm-device.h" #include "nm-device-ethernet.h" #include "nm-device-wifi.h" @@ -56,7 +55,6 @@ #include "nm-device-tun.h" #include "nm-device-macvlan.h" #include "nm-device-gre.h" -#include "nm-setting-bluetooth.h" #include "nm-setting-connection.h" #include "nm-setting-wireless.h" #include "nm-setting-vpn.h" @@ -64,8 +62,6 @@ #include "nm-platform.h" #include "nm-rfkill-manager.h" #include "nm-hostname-provider.h" -#include "nm-bluez-manager.h" -#include "nm-bluez-common.h" #include "nm-settings.h" #include "nm-settings-connection.h" #include "nm-manager-auth.h" @@ -135,19 +131,6 @@ static void impl_manager_check_connectivity (NMManager *manager, #include "nm-manager-glue.h" -static void bluez_manager_bdaddr_added_cb (NMBluezManager *bluez_mgr, - NMBluezDevice *bt_device, - const char *bdaddr, - const char *name, - const char *object_path, - guint32 uuids, - NMManager *manager); - -static void bluez_manager_bdaddr_removed_cb (NMBluezManager *bluez_mgr, - const char *bdaddr, - const char *object_path, - gpointer user_data); - static void add_device (NMManager *self, NMDevice *device, gboolean generate_con); static void remove_device (NMManager *self, NMDevice *device, gboolean quitting); @@ -217,7 +200,6 @@ typedef struct { NMDBusManager *dbus_mgr; gboolean prop_filter_added; NMRfkillManager *rfkill_mgr; - NMBluezManager *bluez_mgr; /* List of NMDeviceFactoryFunc pointers sorted in priority order */ GSList *factories; @@ -1951,62 +1933,6 @@ add_device (NMManager *self, NMDevice *device, gboolean generate_con) } } -static void -bluez_manager_bdaddr_added_cb (NMBluezManager *bluez_mgr, - NMBluezDevice *bt_device, - const char *bdaddr, - const char *name, - const char *object_path, - guint32 capabilities, - NMManager *manager) -{ - NMDevice *device; - gboolean has_dun = (capabilities & NM_BT_CAPABILITY_DUN); - gboolean has_nap = (capabilities & NM_BT_CAPABILITY_NAP); - - g_return_if_fail (bdaddr != NULL); - g_return_if_fail (name != NULL); - g_return_if_fail (object_path != NULL); - g_return_if_fail (capabilities != NM_BT_CAPABILITY_NONE); - g_return_if_fail (NM_IS_BLUEZ_DEVICE (bt_device)); - - /* Make sure the device is not already in the device list */ - if (nm_manager_get_device_by_udi (manager, object_path)) - return; - - device = nm_device_bt_new (bt_device, object_path, bdaddr, name, capabilities); - if (device) { - nm_log_info (LOGD_HW, "BT device %s (%s) added (%s%s%s)", - name, - bdaddr, - has_dun ? "DUN" : "", - has_dun && has_nap ? " " : "", - has_nap ? "NAP" : ""); - - add_device (manager, device, FALSE); - g_object_unref (device); - } -} - -static void -bluez_manager_bdaddr_removed_cb (NMBluezManager *bluez_mgr, - const char *bdaddr, - const char *object_path, - gpointer user_data) -{ - NMManager *self = NM_MANAGER (user_data); - NMDevice *device; - - g_return_if_fail (bdaddr != NULL); - g_return_if_fail (object_path != NULL); - - device = nm_manager_get_device_by_udi (self, object_path); - if (device) { - nm_log_info (LOGD_HW, "BT device %s removed", bdaddr); - remove_device (self, device, FALSE); - } -} - static NMDevice * find_device_by_ip_iface (NMManager *self, const gchar *iface) { @@ -4168,7 +4094,6 @@ nm_manager_start (NMManager *self) system_hostname_changed_cb (priv->settings, NULL, self); nm_platform_query_devices (); - nm_bluez_manager_query_devices (priv->bluez_mgr); /* * Connections added before the manager is started do not emit @@ -4732,18 +4657,6 @@ nm_manager_new (NMSettings *settings, G_CALLBACK (rfkill_manager_rfkill_changed_cb), singleton); - priv->bluez_mgr = nm_bluez_manager_new (NM_CONNECTION_PROVIDER (priv->settings)); - - g_signal_connect (priv->bluez_mgr, - NM_BLUEZ_MANAGER_BDADDR_ADDED, - G_CALLBACK (bluez_manager_bdaddr_added_cb), - singleton); - - g_signal_connect (priv->bluez_mgr, - NM_BLUEZ_MANAGER_BDADDR_REMOVED, - G_CALLBACK (bluez_manager_bdaddr_removed_cb), - singleton); - /* Force kernel WiFi rfkill state to follow NM saved wifi state in case * the BIOS doesn't save rfkill state, and to be consistent with user * changes to the WirelessEnabled property which toggles kernel rfkill. @@ -5044,7 +4957,6 @@ dispose (GObject *object) priv->dbus_mgr = NULL; } - g_clear_object (&priv->bluez_mgr); g_clear_object (&priv->aipd_proxy); g_clear_object (&priv->sleep_monitor); |