summaryrefslogtreecommitdiff
path: root/src/nm-manager.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nm-manager.c')
-rw-r--r--src/nm-manager.c73
1 files changed, 28 insertions, 45 deletions
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 6b59cf085c..1c63dc6627 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -40,8 +40,9 @@
#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-manager.h"
+#include "nm-device-bt.h"
#include "nm-device-ethernet.h"
#include "nm-device-wifi.h"
#include "nm-device-olpc-mesh.h"
@@ -150,6 +151,7 @@ static void bluez_manager_bdaddr_removed_cb (NMBluezManager *bluez_mgr,
static void add_device (NMManager *self, NMDevice *device);
static void hostname_provider_init (NMHostnameProviderInterface *provider_iface);
+static void device_manager_init (NMDeviceManagerInterface *manager_iface);
static NMActiveConnection *internal_activate_device (NMManager *manager,
NMDevice *device,
@@ -260,12 +262,12 @@ typedef struct {
#define NM_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_MANAGER, NMManagerPrivate))
G_DEFINE_TYPE_EXTENDED (NMManager, nm_manager, G_TYPE_OBJECT, 0,
- G_IMPLEMENT_INTERFACE (NM_TYPE_HOSTNAME_PROVIDER,
- hostname_provider_init))
+ G_IMPLEMENT_INTERFACE (NM_TYPE_HOSTNAME_PROVIDER,
+ hostname_provider_init)
+ G_IMPLEMENT_INTERFACE (NM_TYPE_DEVICE_MANAGER,
+ device_manager_init))
enum {
- DEVICE_ADDED,
- DEVICE_REMOVED,
STATE_CHANGED,
CHECK_PERMISSIONS,
USER_PERMISSIONS_CHANGED,
@@ -438,24 +440,6 @@ nm_manager_get_device_by_path (NMManager *manager, const char *path)
}
NMDevice *
-nm_manager_get_device_by_master (NMManager *manager, const char *master, const char *driver)
-{
- GSList *iter;
-
- g_return_val_if_fail (master != NULL, NULL);
-
- for (iter = NM_MANAGER_GET_PRIVATE (manager)->devices; iter; iter = iter->next) {
- NMDevice *device = NM_DEVICE (iter->data);
-
- if (!strcmp (nm_device_get_iface (device), master) &&
- (!driver || !strcmp (nm_device_get_driver (device), driver)))
- return device;
- }
-
- return NULL;
-}
-
-NMDevice *
nm_manager_get_device_by_ifindex (NMManager *manager, int ifindex)
{
GSList *iter;
@@ -625,8 +609,6 @@ remove_one_device (NMManager *manager,
NMDevice *device,
gboolean quitting)
{
- NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
-
if (nm_device_get_managed (device)) {
/* When quitting, we want to leave up interfaces & connections
* that can be taken over again (ie, "assumed") when NM restarts
@@ -644,8 +626,7 @@ remove_one_device (NMManager *manager,
g_signal_handlers_disconnect_by_func (device, manager_device_state_changed, manager);
- nm_settings_device_removed (priv->settings, device);
- g_signal_emit (manager, signals[DEVICE_REMOVED], 0, device);
+ g_signal_emit_by_name (manager, NM_DM_SIGNAL_DEVICE_REMOVED, 0, device);
g_object_unref (device);
return g_slist_remove (list, device);
@@ -726,6 +707,18 @@ hostname_provider_init (NMHostnameProviderInterface *provider_iface)
provider_iface->get_hostname = hostname_provider_get_hostname;
}
+static const GSList *
+device_manager_get_devices (NMDeviceManager *device_manager)
+{
+ return NM_MANAGER_GET_PRIVATE (device_manager)->devices;
+}
+
+static void
+device_manager_init (NMDeviceManagerInterface *manager_iface)
+{
+ manager_iface->get_devices = device_manager_get_devices;
+}
+
NMState
nm_manager_get_state (NMManager *manager)
{
@@ -1999,8 +1992,7 @@ add_device (NMManager *self, NMDevice *device)
NM_DEVICE_STATE_REASON_NOW_MANAGED);
}
- nm_settings_device_added (priv->settings, device);
- g_signal_emit (self, signals[DEVICE_ADDED], 0, device);
+ g_signal_emit_by_name (self, NM_DM_SIGNAL_DEVICE_ADDED, 0, device);
/* New devices might be master interfaces for virtual interfaces; so we may
* need to create new virtual interfaces now.
@@ -4047,6 +4039,13 @@ nm_manager_get (void)
return g_object_ref (singleton);
}
+NMDeviceManager *
+nm_device_manager_get (void)
+{
+ g_assert (singleton);
+ return NM_DEVICE_MANAGER (singleton);
+}
+
NMManager *
nm_manager_new (NMSettings *settings,
const char *state_file,
@@ -4725,22 +4724,6 @@ nm_manager_class_init (NMManagerClass *manager_class)
G_PARAM_READABLE));
/* signals */
- signals[DEVICE_ADDED] =
- g_signal_new ("device-added",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMManagerClass, device_added),
- NULL, NULL, NULL,
- G_TYPE_NONE, 1, G_TYPE_OBJECT);
-
- signals[DEVICE_REMOVED] =
- g_signal_new ("device-removed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMManagerClass, device_removed),
- NULL, NULL, NULL,
- G_TYPE_NONE, 1, G_TYPE_OBJECT);
-
signals[STATE_CHANGED] =
g_signal_new ("state-changed",
G_OBJECT_CLASS_TYPE (object_class),