trivial: move code

(cherry picked from commit 42b272b604)
This commit is contained in:
Dan Williams 2015-04-29 10:56:36 +02:00 committed by Thomas Haller
parent c174da8e13
commit 7473a248f4
2 changed files with 94 additions and 94 deletions

View file

@ -49,61 +49,6 @@ nm_device_factory_emit_component_added (NMDeviceFactory *factory, GObject *compo
return consumed;
}
static void
interface_init (gpointer g_iface)
{
GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
static gboolean initialized = FALSE;
if (G_LIKELY (initialized))
return;
/* Signals */
signals[DEVICE_ADDED] = g_signal_new (NM_DEVICE_FACTORY_DEVICE_ADDED,
iface_type,
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMDeviceFactory, device_added),
NULL, NULL, NULL,
G_TYPE_NONE, 1, NM_TYPE_DEVICE);
signals[COMPONENT_ADDED] = g_signal_new (NM_DEVICE_FACTORY_COMPONENT_ADDED,
iface_type,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (NMDeviceFactory, component_added),
g_signal_accumulator_true_handled, NULL, NULL,
G_TYPE_BOOLEAN, 1, G_TYPE_OBJECT);
initialized = TRUE;
}
GType
nm_device_factory_get_type (void)
{
static GType device_factory_type = 0;
if (!device_factory_type) {
const GTypeInfo device_factory_info = {
sizeof (NMDeviceFactory), /* class_size */
interface_init, /* base_init */
NULL, /* base_finalize */
NULL,
NULL, /* class_finalize */
NULL, /* class_data */
0,
0, /* n_preallocs */
NULL
};
device_factory_type = g_type_register_static (G_TYPE_INTERFACE,
"NMDeviceFactory",
&device_factory_info,
0);
g_type_interface_add_prerequisite (device_factory_type, G_TYPE_OBJECT);
}
return device_factory_type;
}
void
nm_device_factory_get_supported_types (NMDeviceFactory *factory,
const NMLinkType **out_link_types,
@ -217,6 +162,63 @@ nm_device_factory_create_virtual_device_for_connection (NMDeviceFactory *factory
/*******************************************************************/
static void
interface_init (gpointer g_iface)
{
GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
static gboolean initialized = FALSE;
if (G_LIKELY (initialized))
return;
/* Signals */
signals[DEVICE_ADDED] = g_signal_new (NM_DEVICE_FACTORY_DEVICE_ADDED,
iface_type,
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMDeviceFactory, device_added),
NULL, NULL, NULL,
G_TYPE_NONE, 1, NM_TYPE_DEVICE);
signals[COMPONENT_ADDED] = g_signal_new (NM_DEVICE_FACTORY_COMPONENT_ADDED,
iface_type,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (NMDeviceFactory, component_added),
g_signal_accumulator_true_handled, NULL, NULL,
G_TYPE_BOOLEAN, 1, G_TYPE_OBJECT);
initialized = TRUE;
}
GType
nm_device_factory_get_type (void)
{
static GType device_factory_type = 0;
if (!device_factory_type) {
const GTypeInfo device_factory_info = {
sizeof (NMDeviceFactory), /* class_size */
interface_init, /* base_init */
NULL, /* base_finalize */
NULL,
NULL, /* class_finalize */
NULL, /* class_data */
0,
0, /* n_preallocs */
NULL
};
device_factory_type = g_type_register_static (G_TYPE_INTERFACE,
"NMDeviceFactory",
&device_factory_info,
0);
g_type_interface_add_prerequisite (device_factory_type, G_TYPE_OBJECT);
}
return device_factory_type;
}
/*******************************************************************/
static GSList *internal_types = NULL;
static GHashTable *factories_by_link = NULL;
static GHashTable *factories_by_setting = NULL;

View file

@ -127,8 +127,6 @@ static NMActiveConnection *_new_active_connection (NMManager *self,
static void policy_activating_device_changed (GObject *object, GParamSpec *pspec, gpointer user_data);
static NMDevice *find_device_by_ip_iface (NMManager *self, const gchar *iface);
static void rfkill_change (const char *desc, RfKillType rtype, gboolean enabled);
static gboolean find_master (NMManager *self,
@ -515,6 +513,43 @@ nm_manager_get_device_by_ifindex (NMManager *manager, int ifindex)
return NULL;
}
static NMDevice *
get_device_from_hwaddr (NMManager *self, const char *setting_mac)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
const char *device_mac;
GSList *iter;
if (!setting_mac)
return NULL;
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
NMDevice *device = iter->data;
device_mac = nm_device_get_hw_address (iter->data);
if (!device_mac)
continue;
if (nm_utils_hwaddr_matches (setting_mac, -1, device_mac, -1))
return device;
}
return NULL;
}
static NMDevice *
find_device_by_ip_iface (NMManager *self, const gchar *iface)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
GSList *iter;
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
NMDevice *candidate = iter->data;
if (g_strcmp0 (nm_device_get_ip_iface (candidate), iface) == 0)
return candidate;
}
return NULL;
}
static gboolean
manager_sleeping (NMManager *self)
{
@ -847,28 +882,6 @@ nm_manager_get_state (NMManager *manager)
/* Settings stuff via NMSettings */
/*******************************************************************/
static NMDevice *
get_device_from_hwaddr (NMManager *self, const char *setting_mac)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
const char *device_mac;
GSList *iter;
if (!setting_mac)
return NULL;
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
NMDevice *device = iter->data;
device_mac = nm_device_get_hw_address (iter->data);
if (!device_mac)
continue;
if (nm_utils_hwaddr_matches (setting_mac, -1, device_mac, -1))
return device;
}
return NULL;
}
static NMDevice *
find_vlan_parent (NMManager *self,
NMConnection *connection)
@ -1903,21 +1916,6 @@ add_device (NMManager *self, NMDevice *device, gboolean try_assume)
system_create_virtual_devices (self);
}
static NMDevice *
find_device_by_ip_iface (NMManager *self, const gchar *iface)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
GSList *iter;
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
NMDevice *candidate = iter->data;
if (g_strcmp0 (nm_device_get_ip_iface (candidate), iface) == 0)
return candidate;
}
return NULL;
}
/*******************************************************************/
static void