mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-16 13:04:25 +00:00
core: split nm_manager_get() to simplify manager creation
OLPC Mesh code now doesn't have to be updated every time we change the manager's creation arguments. We could make all these arguments GObject properties of the manager too, but that's more code and we'd eventually like to figure out a better solution for letting non-NMManager code listen for device addition/removal.
This commit is contained in:
parent
52e96be3c4
commit
a38032e96c
|
@ -632,7 +632,7 @@ main (int argc, char *argv[])
|
|||
goto done;
|
||||
}
|
||||
|
||||
manager = nm_manager_get (settings,
|
||||
manager = nm_manager_new (settings,
|
||||
state_file,
|
||||
net_enabled,
|
||||
wifi_enabled,
|
||||
|
|
|
@ -653,7 +653,7 @@ dispose (GObject *object)
|
|||
|
||||
device_cleanup (self);
|
||||
|
||||
manager = nm_manager_get (NULL, NULL, FALSE, FALSE, FALSE, FALSE, NULL);
|
||||
manager = nm_manager_get ();
|
||||
if (priv->device_added_id)
|
||||
g_signal_handler_disconnect (manager, priv->device_added_id);
|
||||
g_object_unref (manager);
|
||||
|
@ -852,7 +852,7 @@ is_companion (NMDeviceOlpcMesh *self, NMDevice *other)
|
|||
priv->companion = other;
|
||||
|
||||
/* When we've found the companion, stop listening for other devices */
|
||||
manager = nm_manager_get (NULL, NULL, FALSE, FALSE, FALSE, FALSE, NULL);
|
||||
manager = nm_manager_get ();
|
||||
if (priv->device_added_id) {
|
||||
g_signal_handler_disconnect (manager, priv->device_added_id);
|
||||
priv->device_added_id = 0;
|
||||
|
@ -907,7 +907,7 @@ check_companion_cb (gpointer user_data)
|
|||
if (priv->device_added_id != 0)
|
||||
return FALSE;
|
||||
|
||||
manager = nm_manager_get (NULL, NULL, FALSE, FALSE, FALSE, FALSE, NULL);
|
||||
manager = nm_manager_get ();
|
||||
|
||||
priv->device_added_id = g_signal_connect (manager, "device-added",
|
||||
G_CALLBACK (device_added_cb), self);
|
||||
|
|
|
@ -3041,8 +3041,17 @@ out:
|
|||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
static NMManager *singleton = NULL;
|
||||
|
||||
NMManager *
|
||||
nm_manager_get (NMSettings *settings,
|
||||
nm_manager_get (void)
|
||||
{
|
||||
g_assert (singleton);
|
||||
return g_object_ref (singleton);
|
||||
}
|
||||
|
||||
NMManager *
|
||||
nm_manager_new (NMSettings *settings,
|
||||
const char *state_file,
|
||||
gboolean initial_net_enabled,
|
||||
gboolean initial_wifi_enabled,
|
||||
|
@ -3050,16 +3059,14 @@ nm_manager_get (NMSettings *settings,
|
|||
gboolean initial_wimax_enabled,
|
||||
GError **error)
|
||||
{
|
||||
static NMManager *singleton = NULL;
|
||||
NMManagerPrivate *priv;
|
||||
DBusGConnection *bus;
|
||||
DBusConnection *dbus_connection;
|
||||
|
||||
if (singleton)
|
||||
return g_object_ref (singleton);
|
||||
|
||||
g_assert (settings);
|
||||
|
||||
/* Can only be called once */
|
||||
g_assert (singleton == NULL);
|
||||
singleton = (NMManager *) g_object_new (NM_TYPE_MANAGER, NULL);
|
||||
g_assert (singleton);
|
||||
|
||||
|
|
|
@ -67,7 +67,8 @@ typedef struct {
|
|||
|
||||
GType nm_manager_get_type (void);
|
||||
|
||||
NMManager *nm_manager_get (NMSettings *settings,
|
||||
/* nm_manager_new() should only be used by main.c */
|
||||
NMManager *nm_manager_new (NMSettings *settings,
|
||||
const char *state_file,
|
||||
gboolean initial_net_enabled,
|
||||
gboolean initial_wifi_enabled,
|
||||
|
@ -75,6 +76,8 @@ NMManager *nm_manager_get (NMSettings *settings,
|
|||
gboolean initial_wimax_enabled,
|
||||
GError **error);
|
||||
|
||||
NMManager *nm_manager_get (void);
|
||||
|
||||
void nm_manager_start (NMManager *manager);
|
||||
|
||||
/* Device handling */
|
||||
|
|
Loading…
Reference in a new issue