periodic_update_active_connection_timestamps (gpointer user_data)
{
	NMApplet *applet = NM_APPLET (user_data);
	const GPtrArray *connections;
	int i;

	if (!applet->nm_client || !nm_client_get_manager_running (applet->nm_client))
		return TRUE;

	connections = nm_client_get_active_connections (applet->nm_client);
	for (i = 0; connections && (i < connections->len); i++) {
		NMActiveConnection *active = NM_ACTIVE_CONNECTION (g_ptr_array_index (connections, i));
		const char *path;
		NMAGConfConnection *gconf_connection;
		NMConnection *connection;
		const GPtrArray *devices;
		int k;

		if (nm_active_connection_get_scope (active) == NM_CONNECTION_SCOPE_SYSTEM)
			continue;

		path = nm_active_connection_get_connection (active);
		gconf_connection = nma_gconf_settings_get_by_dbus_path (applet->gconf_settings, path);
		if (!gconf_connection)
			continue;

		devices = nm_active_connection_get_devices (active);
		if (!devices || !devices->len)
			continue;

		/* Check if a device owned by the active connection is completely
		 * activated before updating timestamp.
		 */
		for (k = 0; devices && (k < devices->len); k++) {
			NMDevice *device = NM_DEVICE (g_ptr_array_index (devices, k));

			if (nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED) {
				NMSettingConnection *s_con;

				connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (gconf_connection));
				s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
				g_assert (s_con);

				g_object_set (s_con, NM_SETTING_CONNECTION_TIMESTAMP, (guint64) time (NULL), NULL);
				nma_gconf_connection_save (gconf_connection);
				break;
			}
		}
	}

	return TRUE;
}
periodic_update_active_connection_timestamps (gpointer user_data)
{
	NMApplet *applet = NM_APPLET (user_data);
	const GPtrArray *connections;
	int i;

	if (!applet->nm_client || !nm_client_get_manager_running (applet->nm_client))
		return TRUE;

	connections = nm_client_get_active_connections (applet->nm_client);
	for (i = 0; connections && (i < connections->len); i++) {
		NMActiveConnection *active = NM_ACTIVE_CONNECTION (g_ptr_array_index (connections, i));
		const char *path;
		NMAGConfConnection *gconf_connection;
		NMConnection *connection;
		const GPtrArray *devices;
		int k;

		if (nm_active_connection_get_scope (active) == NM_CONNECTION_SCOPE_SYSTEM)
			continue;

		path = nm_active_connection_get_connection (active);
		gconf_connection = nma_gconf_settings_get_by_dbus_path (applet->gconf_settings, path);
		if (!gconf_connection)
			continue;

		devices = nm_active_connection_get_devices (active);
		if (!devices || !devices->len)
			continue;

		 
		for (k = 0; devices && (k < devices->len); k++) {
			NMDevice *device = NM_DEVICE (g_ptr_array_index (devices, k));

			if (nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED) {
				NMSettingConnection *s_con;

				connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (gconf_connection));
				s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
				g_assert (s_con);

				g_object_set (s_con, NM_SETTING_CONNECTION_TIMESTAMP, (guint64) time (NULL), NULL);
				nma_gconf_connection_save (gconf_connection);
				break;
			}
		}
	}

	return TRUE;
}