diff options
author | Thomas Haller <thaller@redhat.com> | 2016-05-16 18:08:08 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-05-24 12:35:58 +0200 |
commit | b9b18c8a868ee0cd7a78ec5ef7e90f63df2d5efe (patch) | |
tree | 21325ab8924340ad806219f276e449d1e007a84f | |
parent | 6e54057bf754d9311e42d92956feb9b1036ca654 (diff) | |
download | NetworkManager-b9b18c8a868ee0cd7a78ec5ef7e90f63df2d5efe.tar.gz |
bluez: use NMSettings directly instead of NMConnectionProvider
-rw-r--r-- | src/devices/bluetooth/nm-bluez-device.c | 49 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-bluez-device.h | 3 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-bluez-manager.c | 17 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-bluez-manager.h | 4 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-bluez4-adapter.c | 16 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-bluez4-adapter.h | 5 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-bluez4-manager.c | 18 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-bluez4-manager.h | 4 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-bluez5-manager.c | 20 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-bluez5-manager.h | 7 |
10 files changed, 75 insertions, 68 deletions
diff --git a/src/devices/bluetooth/nm-bluez-device.c b/src/devices/bluetooth/nm-bluez-device.c index dcfa5eec24..3463da6be8 100644 --- a/src/devices/bluetooth/nm-bluez-device.c +++ b/src/devices/bluetooth/nm-bluez-device.c @@ -28,6 +28,7 @@ #include "nm-bt-error.h" #include "nm-bluez-common.h" #include "nm-bluez-device.h" +#include "nm-settings.h" #include "nm-settings-connection.h" #include "NetworkManagerUtils.h" @@ -67,7 +68,7 @@ typedef struct { NMBluez5DunContext *b5_dun_context; #endif - NMConnectionProvider *provider; + NMSettings *settings; GSList *connections; NMConnection *pan_connection; @@ -96,7 +97,7 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; -static void cp_connection_added (NMConnectionProvider *provider, +static void cp_connection_added (NMSettings *settings, NMConnection *connection, NMBluezDevice *self); static gboolean connection_compatible (NMBluezDevice *self, NMConnection *connection); @@ -233,9 +234,9 @@ pan_connection_check_create (NMBluezDevice *self) /* Adding a new connection raises a signal which eventually calls check_emit_usable (again) * which then already finds the suitable connection in priv->connections. This is confusing, * so block the signal. check_emit_usable will succeed after this function call returns. */ - g_signal_handlers_block_by_func (priv->provider, cp_connection_added, self); - added = nm_connection_provider_add_connection (priv->provider, connection, FALSE, &error); - g_signal_handlers_unblock_by_func (priv->provider, cp_connection_added, self); + g_signal_handlers_block_by_func (priv->settings, cp_connection_added, self); + added = NM_CONNECTION (nm_settings_add_connection (priv->settings, connection, FALSE, &error)); + g_signal_handlers_unblock_by_func (priv->settings, cp_connection_added, self); if (added) { g_assert (!g_slist_find (priv->connections, added)); @@ -367,7 +368,7 @@ _internal_track_connection (NMBluezDevice *self, NMConnection *connection, gbool } static void -cp_connection_added (NMConnectionProvider *provider, +cp_connection_added (NMSettings *settings, NMConnection *connection, NMBluezDevice *self) { @@ -378,7 +379,7 @@ cp_connection_added (NMConnectionProvider *provider, } static void -cp_connection_removed (NMConnectionProvider *provider, +cp_connection_removed (NMSettings *settings, NMConnection *connection, NMBluezDevice *self) { @@ -387,8 +388,9 @@ cp_connection_removed (NMConnectionProvider *provider, } static void -cp_connection_updated (NMConnectionProvider *provider, +cp_connection_updated (NMSettings *settings, NMConnection *connection, + gboolean by_user, NMBluezDevice *self) { if (_internal_track_connection (self, connection, @@ -400,12 +402,13 @@ static void load_connections (NMBluezDevice *self) { NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self); - const GSList *connections, *iter; + NMSettingsConnection *const*connections; + guint i; gboolean changed = FALSE; - connections = nm_connection_provider_get_connections (priv->provider); - for (iter = connections; iter; iter = g_slist_next (iter)) { - NMConnection *connection = iter->data; + connections = nm_settings_get_connections (priv->settings, NULL); + for (i = 0; connections[i]; i++) { + NMConnection *connection = (NMConnection *) connections[i]; if (connection_compatible (self, connection)) changed |= _internal_track_connection (self, connection, TRUE); @@ -1029,7 +1032,7 @@ on_bus_acquired (GObject *object, GAsyncResult *res, NMBluezDevice *self) NMBluezDevice * nm_bluez_device_new (const char *path, const char *adapter_address, - NMConnectionProvider *provider, + NMSettings *settings, int bluez_version) { NMBluezDevice *self; @@ -1037,7 +1040,7 @@ nm_bluez_device_new (const char *path, const char *interface_name = NULL; g_return_val_if_fail (path != NULL, NULL); - g_return_val_if_fail (NM_IS_CONNECTION_PROVIDER (provider), NULL); + g_return_val_if_fail (NM_IS_SETTINGS (settings), NULL); g_return_val_if_fail (bluez_version == 4 || bluez_version == 5, NULL); self = (NMBluezDevice *) g_object_new (NM_TYPE_BLUEZ_DEVICE, @@ -1051,14 +1054,14 @@ nm_bluez_device_new (const char *path, priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self); priv->bluez_version = bluez_version; - priv->provider = g_object_ref (provider); + priv->settings = g_object_ref (settings); g_return_val_if_fail (bluez_version == 5 || (bluez_version == 4 && adapter_address), NULL); if (adapter_address) set_adapter_address (self, adapter_address); - g_signal_connect (priv->provider, NM_CP_SIGNAL_CONNECTION_ADDED, G_CALLBACK (cp_connection_added), self); - g_signal_connect (priv->provider, NM_CP_SIGNAL_CONNECTION_REMOVED, G_CALLBACK (cp_connection_removed), self); - g_signal_connect (priv->provider, NM_CP_SIGNAL_CONNECTION_UPDATED, G_CALLBACK (cp_connection_updated), self); + g_signal_connect (priv->settings, NM_SETTINGS_SIGNAL_CONNECTION_ADDED, G_CALLBACK (cp_connection_added), self); + g_signal_connect (priv->settings, NM_SETTINGS_SIGNAL_CONNECTION_REMOVED, G_CALLBACK (cp_connection_removed), self); + g_signal_connect (priv->settings, NM_SETTINGS_SIGNAL_CONNECTION_UPDATED, G_CALLBACK (cp_connection_updated), self); g_bus_get (G_BUS_TYPE_SYSTEM, NULL, @@ -1116,10 +1119,10 @@ dispose (GObject *object) } #endif - if (priv->provider) { - g_signal_handlers_disconnect_by_func (priv->provider, cp_connection_added, self); - g_signal_handlers_disconnect_by_func (priv->provider, cp_connection_removed, self); - g_signal_handlers_disconnect_by_func (priv->provider, cp_connection_updated, self); + if (priv->settings) { + g_signal_handlers_disconnect_by_func (priv->settings, cp_connection_added, self); + g_signal_handlers_disconnect_by_func (priv->settings, cp_connection_removed, self); + g_signal_handlers_disconnect_by_func (priv->settings, cp_connection_updated, self); } g_slist_free_full (priv->connections, g_object_unref); @@ -1137,7 +1140,7 @@ dispose (GObject *object) g_object_unref (to_delete); } - g_clear_object (&priv->provider); + g_clear_object (&priv->settings); } static void diff --git a/src/devices/bluetooth/nm-bluez-device.h b/src/devices/bluetooth/nm-bluez-device.h index c956054074..66a349e0db 100644 --- a/src/devices/bluetooth/nm-bluez-device.h +++ b/src/devices/bluetooth/nm-bluez-device.h @@ -22,7 +22,6 @@ #define __NETWORKMANAGER_BLUEZ_DEVICE_H__ #include "nm-connection.h" -#include "nm-connection-provider.h" #define NM_TYPE_BLUEZ_DEVICE (nm_bluez_device_get_type ()) #define NM_BLUEZ_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_BLUEZ_DEVICE, NMBluezDevice)) @@ -59,7 +58,7 @@ GType nm_bluez_device_get_type (void); NMBluezDevice *nm_bluez_device_new (const char *path, const char *adapter_address, - NMConnectionProvider *provider, + NMSettings *settings, int bluez_version); const char *nm_bluez_device_get_path (NMBluezDevice *self); diff --git a/src/devices/bluetooth/nm-bluez-manager.c b/src/devices/bluetooth/nm-bluez-manager.c index 766ecc0abc..0d2e302cfc 100644 --- a/src/devices/bluetooth/nm-bluez-manager.c +++ b/src/devices/bluetooth/nm-bluez-manager.c @@ -20,19 +20,20 @@ #include "nm-default.h" +#include "nm-bluez-manager.h" + #include <signal.h> #include <string.h> #include <stdlib.h> #include <gmodule.h> -#include "nm-bluez-manager.h" #include "nm-device-factory.h" #include "nm-setting-bluetooth.h" +#include "nm-settings.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-core-internal.h" #include "nm-platform.h" @@ -51,7 +52,7 @@ typedef struct { int bluez_version; - NMConnectionProvider *provider; + NMSettings *settings; NMBluez4Manager *manager4; NMBluez5Manager *manager5; @@ -190,7 +191,7 @@ setup_bluez4 (NMBluezManager *self) g_return_if_fail (!priv->manager4 && !priv->manager5 && !priv->bluez_version); setup_version_number (self, 4); - priv->manager4 = manager = nm_bluez4_manager_new (priv->provider); + priv->manager4 = manager = nm_bluez4_manager_new (priv->settings); g_signal_connect (manager, NM_BLUEZ_MANAGER_BDADDR_ADDED, @@ -209,7 +210,7 @@ setup_bluez5 (NMBluezManager *self) g_return_if_fail (!priv->manager4 && !priv->manager5 && !priv->bluez_version); setup_version_number (self, 5); - priv->manager5 = manager = nm_bluez5_manager_new (priv->provider); + priv->manager5 = manager = nm_bluez5_manager_new (priv->settings); g_signal_connect (manager, NM_BLUEZ_MANAGER_BDADDR_ADDED, @@ -407,9 +408,9 @@ dispose (GObject *object) priv->bluez_version = 0; - g_clear_object (&priv->provider); - G_OBJECT_CLASS (nm_bluez_manager_parent_class)->dispose (object); + + g_clear_object (&priv->settings); } static void @@ -417,7 +418,7 @@ nm_bluez_manager_init (NMBluezManager *self) { NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE (self); - priv->provider = g_object_ref (nm_connection_provider_get ()); + priv->settings = g_object_ref (NM_SETTINGS_GET); } static NMDevice * diff --git a/src/devices/bluetooth/nm-bluez-manager.h b/src/devices/bluetooth/nm-bluez-manager.h index 1f5597d831..d23b33a7d8 100644 --- a/src/devices/bluetooth/nm-bluez-manager.h +++ b/src/devices/bluetooth/nm-bluez-manager.h @@ -22,10 +22,6 @@ #ifndef __NETWORKMANAGER_BLUEZ_MANAGER_H__ #define __NETWORKMANAGER_BLUEZ_MANAGER_H__ -#include "nm-default.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)) diff --git a/src/devices/bluetooth/nm-bluez4-adapter.c b/src/devices/bluetooth/nm-bluez4-adapter.c index 9d8fd21056..2ef071a8bf 100644 --- a/src/devices/bluetooth/nm-bluez4-adapter.c +++ b/src/devices/bluetooth/nm-bluez4-adapter.c @@ -20,13 +20,15 @@ #include "nm-default.h" +#include "nm-bluez4-adapter.h" + #include <string.h> #include "nm-dbus-interface.h" -#include "nm-bluez4-adapter.h" #include "nm-bluez-device.h" #include "nm-bluez-common.h" #include "nm-core-internal.h" +#include "nm-settings.h" G_DEFINE_TYPE (NMBluez4Adapter, nm_bluez4_adapter, G_TYPE_OBJECT) @@ -41,7 +43,7 @@ typedef struct { GHashTable *devices; /* Cached for devices */ - NMConnectionProvider *provider; + NMSettings *settings; } NMBluez4AdapterPrivate; @@ -160,7 +162,7 @@ device_created (GDBusProxy *proxy, const char *path, gpointer user_data) NMBluez4AdapterPrivate *priv = NM_BLUEZ4_ADAPTER_GET_PRIVATE (self); NMBluezDevice *device; - device = nm_bluez_device_new (path, priv->address, priv->provider, 4); + device = nm_bluez_device_new (path, priv->address, priv->settings, 4); g_signal_connect (device, "initialized", G_CALLBACK (device_initialized), self); g_signal_connect (device, "notify::usable", G_CALLBACK (device_usable), self); g_hash_table_insert (priv->devices, (gpointer) nm_bluez_device_get_path (device), device); @@ -234,17 +236,19 @@ query_properties (NMBluez4Adapter *self) /***********************************************************/ NMBluez4Adapter * -nm_bluez4_adapter_new (const char *path, NMConnectionProvider *provider) +nm_bluez4_adapter_new (const char *path, NMSettings *settings) { NMBluez4Adapter *self; NMBluez4AdapterPrivate *priv; + g_return_val_if_fail (NM_IS_SETTINGS (settings), NULL); + self = (NMBluez4Adapter *) g_object_new (NM_TYPE_BLUEZ4_ADAPTER, NM_BLUEZ4_ADAPTER_PATH, path, NULL); priv = NM_BLUEZ4_ADAPTER_GET_PRIVATE (self); - priv->provider = provider; + priv->settings = g_object_ref (settings); priv->proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, @@ -301,6 +305,8 @@ finalize (GObject *object) g_object_unref (priv->proxy); G_OBJECT_CLASS (nm_bluez4_adapter_parent_class)->finalize (object); + + g_object_unref (priv->settings); } static void diff --git a/src/devices/bluetooth/nm-bluez4-adapter.h b/src/devices/bluetooth/nm-bluez4-adapter.h index a8a2bfb4d2..ee61112f2e 100644 --- a/src/devices/bluetooth/nm-bluez4-adapter.h +++ b/src/devices/bluetooth/nm-bluez4-adapter.h @@ -21,10 +21,7 @@ #ifndef __NETWORKMANAGER_BLUEZ4_ADAPTER_H__ #define __NETWORKMANAGER_BLUEZ4_ADAPTER_H__ - -#include "nm-default.h" #include "nm-bluez-device.h" -#include "nm-connection-provider.h" #define NM_TYPE_BLUEZ4_ADAPTER (nm_bluez4_adapter_get_type ()) #define NM_BLUEZ4_ADAPTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_BLUEZ4_ADAPTER, NMBluez4Adapter)) @@ -54,7 +51,7 @@ typedef struct { GType nm_bluez4_adapter_get_type (void); NMBluez4Adapter *nm_bluez4_adapter_new (const char *path, - NMConnectionProvider *provider); + NMSettings *settings); const char *nm_bluez4_adapter_get_path (NMBluez4Adapter *self); diff --git a/src/devices/bluetooth/nm-bluez4-manager.c b/src/devices/bluetooth/nm-bluez4-manager.c index 146612a890..36bc30e59c 100644 --- a/src/devices/bluetooth/nm-bluez4-manager.c +++ b/src/devices/bluetooth/nm-bluez4-manager.c @@ -21,20 +21,22 @@ #include "nm-default.h" +#include "nm-bluez4-manager.h" + #include <signal.h> #include <string.h> #include <stdlib.h> -#include "nm-bluez-manager.h" -#include "nm-bluez4-manager.h" #include "nm-bluez4-adapter.h" +#include "nm-bluez-manager.h" #include "nm-bluez-common.h" #include "nm-core-internal.h" +#include "nm-settings.h" typedef struct { gulong name_owner_changed_id; - NMConnectionProvider *provider; + NMSettings *settings; GDBusProxy *proxy; @@ -155,7 +157,7 @@ default_adapter_changed (GDBusProxy *proxy, const char *path, NMBluez4Manager *s /* Add the new default adapter */ if (path) { - priv->adapter = nm_bluez4_adapter_new (path, priv->provider); + priv->adapter = nm_bluez4_adapter_new (path, priv->settings); g_signal_connect (priv->adapter, "initialized", G_CALLBACK (adapter_initialized), self); } } @@ -223,12 +225,14 @@ name_owner_changed_cb (GObject *object, /****************************************************************/ NMBluez4Manager * -nm_bluez4_manager_new (NMConnectionProvider *provider) +nm_bluez4_manager_new (NMSettings *settings) { NMBluez4Manager *instance; + g_return_val_if_fail (NM_IS_SETTINGS (settings), NULL); + instance = g_object_new (NM_TYPE_BLUEZ4_MANAGER, NULL); - NM_BLUEZ4_MANAGER_GET_PRIVATE (instance)->provider = provider; + NM_BLUEZ4_MANAGER_GET_PRIVATE (instance)->settings = g_object_ref (settings); return instance; } @@ -264,6 +268,8 @@ dispose (GObject *object) g_clear_object (&priv->adapter); G_OBJECT_CLASS (nm_bluez4_manager_parent_class)->dispose (object); + + g_clear_object (&priv->settings); } static void diff --git a/src/devices/bluetooth/nm-bluez4-manager.h b/src/devices/bluetooth/nm-bluez4-manager.h index f6bf76586b..dbf7688940 100644 --- a/src/devices/bluetooth/nm-bluez4-manager.h +++ b/src/devices/bluetooth/nm-bluez4-manager.h @@ -1,4 +1,3 @@ -/* -*- 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 @@ -23,7 +22,6 @@ #define __NETWORKMANAGER_BLUEZ4_MANAGER_H__ #include "nm-default.h" -#include "nm-connection-provider.h" G_BEGIN_DECLS @@ -51,7 +49,7 @@ typedef struct { GType nm_bluez4_manager_get_type (void); -NMBluez4Manager *nm_bluez4_manager_new (NMConnectionProvider *provider); +NMBluez4Manager *nm_bluez4_manager_new (NMSettings *settings); void nm_bluez4_manager_query_devices (NMBluez4Manager *manager); diff --git a/src/devices/bluetooth/nm-bluez5-manager.c b/src/devices/bluetooth/nm-bluez5-manager.c index 66d171bf2e..183f23c1e4 100644 --- a/src/devices/bluetooth/nm-bluez5-manager.c +++ b/src/devices/bluetooth/nm-bluez5-manager.c @@ -22,19 +22,21 @@ #include "nm-default.h" +#include "nm-bluez5-manager.h" + #include <signal.h> #include <string.h> #include <stdlib.h> +#include "nm-core-internal.h" + #include "nm-bluez-manager.h" -#include "nm-bluez5-manager.h" #include "nm-bluez-device.h" #include "nm-bluez-common.h" - -#include "nm-core-internal.h" +#include "nm-settings.h" typedef struct { - NMConnectionProvider *provider; + NMSettings *settings; GDBusProxy *proxy; @@ -140,7 +142,7 @@ device_added (GDBusProxy *proxy, const gchar *path, NMBluez5Manager *self) NMBluez5ManagerPrivate *priv = NM_BLUEZ5_MANAGER_GET_PRIVATE (self); NMBluezDevice *device; - device = nm_bluez_device_new (path, NULL, priv->provider, 5); + device = nm_bluez_device_new (path, NULL, priv->settings, 5); g_signal_connect (device, "initialized", G_CALLBACK (device_initialized), self); g_signal_connect (device, "notify::usable", G_CALLBACK (device_usable), self); g_hash_table_insert (priv->devices, (gpointer) nm_bluez_device_get_path (device), device); @@ -309,12 +311,14 @@ bluez_cleanup (NMBluez5Manager *self, gboolean do_signal) /****************************************************************/ NMBluez5Manager * -nm_bluez5_manager_new (NMConnectionProvider *provider) +nm_bluez5_manager_new (NMSettings *settings) { NMBluez5Manager *instance = NULL; + g_return_val_if_fail (NM_IS_SETTINGS (settings), NULL); + instance = g_object_new (NM_TYPE_BLUEZ5_MANAGER, NULL); - NM_BLUEZ5_MANAGER_GET_PRIVATE (instance)->provider = provider; + NM_BLUEZ5_MANAGER_GET_PRIVATE (instance)->settings = g_object_ref (settings); return instance; } @@ -347,6 +351,8 @@ finalize (GObject *object) g_hash_table_destroy (priv->devices); G_OBJECT_CLASS (nm_bluez5_manager_parent_class)->finalize (object); + + g_object_unref (priv->settings); } static void diff --git a/src/devices/bluetooth/nm-bluez5-manager.h b/src/devices/bluetooth/nm-bluez5-manager.h index 1c531090b7..0e309d33a3 100644 --- a/src/devices/bluetooth/nm-bluez5-manager.h +++ b/src/devices/bluetooth/nm-bluez5-manager.h @@ -22,11 +22,6 @@ #ifndef __NETWORKMANAGER_BLUEZ5_MANAGER_H__ #define __NETWORKMANAGER_BLUEZ5_MANAGER_H__ -#include "nm-default.h" -#include "nm-connection-provider.h" - -G_BEGIN_DECLS - #define NM_TYPE_BLUEZ5_MANAGER (nm_bluez5_manager_get_type ()) #define NM_BLUEZ5_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_BLUEZ5_MANAGER, NMBluez5Manager)) #define NM_BLUEZ5_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_BLUEZ5_MANAGER, NMBluez5ManagerClass)) @@ -51,7 +46,7 @@ typedef struct { GType nm_bluez5_manager_get_type (void); -NMBluez5Manager *nm_bluez5_manager_new (NMConnectionProvider *provider); +NMBluez5Manager *nm_bluez5_manager_new (NMSettings *settings); void nm_bluez5_manager_query_devices (NMBluez5Manager *manager); |