find_active_device (NMAGConfConnection *exported,
                    NMApplet *applet,
                    NMActiveConnection **out_active_connection)
{
	const GPtrArray *active_connections;
	int i;

	g_return_val_if_fail (exported != NULL, NULL);
	g_return_val_if_fail (applet != NULL, NULL);
	g_return_val_if_fail (out_active_connection != NULL, NULL);
	g_return_val_if_fail (*out_active_connection == NULL, NULL);

	/* Look through the active connection list trying to find the D-Bus
	 * object path of applet_connection.
	 */
	active_connections = nm_client_get_active_connections (applet->nm_client);
	for (i = 0; active_connections && (i < active_connections->len); i++) {
		NMActiveConnection *active;
		NMConnection *connection;
		const char *service_name;
		const char *connection_path;
		const GPtrArray *devices;

		active = NM_ACTIVE_CONNECTION (g_ptr_array_index (active_connections, i));
		service_name = nm_active_connection_get_service_name (active);
		if (strcmp (service_name, NM_DBUS_SERVICE_USER_SETTINGS))
			continue;

		connection_path = nm_active_connection_get_connection (active);

		connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (exported));
		if (!strcmp (connection_path, nm_connection_get_path (connection))) {
			devices = nm_active_connection_get_devices (active);
			if (devices)
				*out_active_connection = active;
			return devices ? NM_DEVICE (g_ptr_array_index (devices, 0)) : NULL;
		}
	}

	return NULL;
}
find_active_device (NMAGConfConnection *exported,
                    NMApplet *applet,
                    NMActiveConnection **out_active_connection)
{
	const GPtrArray *active_connections;
	int i;

	g_return_val_if_fail (exported != NULL, NULL);
	g_return_val_if_fail (applet != NULL, NULL);
	g_return_val_if_fail (out_active_connection != NULL, NULL);
	g_return_val_if_fail (*out_active_connection == NULL, NULL);

	 
	active_connections = nm_client_get_active_connections (applet->nm_client);
	for (i = 0; active_connections && (i < active_connections->len); i++) {
		NMActiveConnection *active;
		NMConnection *connection;
		const char *service_name;
		const char *connection_path;
		const GPtrArray *devices;

		active = NM_ACTIVE_CONNECTION (g_ptr_array_index (active_connections, i));
		service_name = nm_active_connection_get_service_name (active);
		if (strcmp (service_name, NM_DBUS_SERVICE_USER_SETTINGS))
			continue;

		connection_path = nm_active_connection_get_connection (active);

		connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (exported));
		if (!strcmp (connection_path, nm_connection_get_path (connection))) {
			devices = nm_active_connection_get_devices (active);
			if (devices)
				*out_active_connection = active;
			return devices ? NM_DEVICE (g_ptr_array_index (devices, 0)) : NULL;
		}
	}

	return NULL;
}