platform: move nm_platform_query_devices() to nm-manager

nm_platform_query_devices() would raise an 'added' signal
for all its links. That is bad style because it could
confuse other listeners for platform signals which don't
expect such artificial change signals.

The public API of NMPlatform already gives NMManager the ability
to 'pull' all the links and iterate them itself.

Before, nm_platform_query_devices() would also initialize udev
devices, so there was a more compelling reason for this function.

(cherry picked from commit d7a312d17a)
This commit is contained in:
Thomas Haller 2015-05-04 16:54:51 +02:00
parent acb39d4b31
commit 4e0af0aa52
3 changed files with 16 additions and 29 deletions

View file

@ -1977,6 +1977,21 @@ platform_link_cb (NMPlatform *platform,
}
}
static void
platform_query_devices (NMManager *self)
{
GArray *links_array;
NMPlatformLink *links;
int i;
links_array = nm_platform_link_get_all (NM_PLATFORM_GET);
links = (NMPlatformLink *) links_array->data;
for (i = 0; i < links_array->len; i++)
platform_link_added (self, links[i].ifindex, &links[i], NM_PLATFORM_REASON_INTERNAL);
g_array_unref (links_array);
}
static void
rfkill_manager_rfkill_changed_cb (NMRfkillManager *rfkill_mgr,
RfKillType rtype,
@ -4113,7 +4128,7 @@ nm_manager_start (NMManager *self)
/* Start device factories */
nm_device_factory_manager_for_each_factory (start_factory, NULL);
nm_platform_query_devices (NM_PLATFORM_GET);
platform_query_devices (self);
/*
* Connections added before the manager is started do not emit

View file

@ -383,32 +383,6 @@ nm_platform_sysctl_get_int_checked (NMPlatform *self, const char *path, guint ba
/******************************************************************/
/**
* nm_platform_query_devices:
* self: platform instance
*
* Emit #NMPlatform:link-changed ADDED signals for all currently-known links.
* Should only be called at startup.
*/
void
nm_platform_query_devices (NMPlatform *self)
{
GArray *links_array;
NMPlatformLink *links;
int i;
_CHECK_SELF_VOID (self, klass);
links_array = nm_platform_link_get_all (self);
links = (NMPlatformLink *) links_array->data;
for (i = 0; i < links_array->len; i++) {
g_signal_emit (self, signals[SIGNAL_LINK_CHANGED], 0,
links[i].ifindex, &links[i], NM_PLATFORM_SIGNAL_ADDED,
NM_PLATFORM_REASON_INTERNAL);
}
g_array_unref (links_array);
}
/**
* nm_platform_link_get_all:
* self: platform instance

View file

@ -532,8 +532,6 @@ void nm_platform_set_error (NMPlatform *self, NMPlatformError error);
NMPlatformError nm_platform_get_error (NMPlatform *self);
const char *nm_platform_get_error_msg (NMPlatform *self);
void nm_platform_query_devices (NMPlatform *self);
gboolean nm_platform_sysctl_set (NMPlatform *self, const char *path, const char *value);
char *nm_platform_sysctl_get (NMPlatform *self, const char *path);
gint32 nm_platform_sysctl_get_int32 (NMPlatform *self, const char *path, gint32 fallback);