core: handle some connection timestamp updating in NMActiveConnection

Handle it in the base active connection class instead of in separate
places for the device and the VPN cases.
This commit is contained in:
Dan Williams 2012-08-22 17:34:42 -05:00
parent 3a10f695b3
commit 6ddc25dcab
3 changed files with 13 additions and 32 deletions

View file

@ -27,6 +27,7 @@
#include "nm-dbus-manager.h"
#include "nm-properties-changed-signal.h"
#include "nm-device.h"
#include "nm-settings-connection.h"
#include "nm-active-connection-glue.h"
@ -95,10 +96,19 @@ nm_active_connection_set_state (NMActiveConnection *self,
NMActiveConnectionState new_state)
{
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
NMActiveConnectionState old_state;
if (priv->state != new_state) {
priv->state = new_state;
g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_STATE);
if (priv->state == new_state)
return;
old_state = priv->state;
priv->state = new_state;
g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_STATE);
if ( new_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED
|| old_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
nm_settings_connection_update_timestamp (NM_SETTINGS_CONNECTION (priv->connection),
(guint64) time (NULL), TRUE);
}
}

View file

@ -4789,15 +4789,6 @@ nm_device_state_changed (NMDevice *device,
/* Cache the activation request for the dispatcher */
req = priv->act_request ? g_object_ref (priv->act_request) : NULL;
/* Update connection timestamps; do this before possibly deactivating the
* device since that will clear the activation request and thus the
* connection, which we need.
*/
if (state == NM_DEVICE_STATE_ACTIVATED || old_state == NM_DEVICE_STATE_ACTIVATED) {
nm_settings_connection_update_timestamp (NM_SETTINGS_CONNECTION (nm_act_request_get_connection (req)),
(guint64) time (NULL), TRUE);
}
if (state <= NM_DEVICE_STATE_UNAVAILABLE)
_clear_available_connections (device, TRUE);

View file

@ -223,7 +223,6 @@ typedef struct {
gboolean net_enabled;
NMVPNManager *vpn_manager;
gulong vpn_manager_activated_id;
NMModemManager *modem_manager;
guint modem_added_id;
@ -430,18 +429,6 @@ manager_sleeping (NMManager *self)
return FALSE;
}
static void
vpn_manager_connection_activated_cb (NMVPNManager *manager,
NMVPNConnection *vpn,
gpointer user_data)
{
NMConnection *connection = nm_vpn_connection_get_connection (vpn);
/* Update timestamp for the VPN connection */
nm_settings_connection_update_timestamp (NM_SETTINGS_CONNECTION (connection),
(guint64) time (NULL), TRUE);
}
static void
modem_added (NMModemManager *modem_manager,
NMModem *modem,
@ -4087,11 +4074,6 @@ dispose (GObject *object)
g_free (priv->hostname);
g_object_unref (priv->settings);
if (priv->vpn_manager_activated_id) {
g_source_remove (priv->vpn_manager_activated_id);
priv->vpn_manager_activated_id = 0;
}
g_object_unref (priv->vpn_manager);
if (priv->modem_added_id) {
@ -4407,8 +4389,6 @@ nm_manager_init (NMManager *manager)
G_CALLBACK (modem_removed), manager);
priv->vpn_manager = nm_vpn_manager_get ();
priv->vpn_manager_activated_id = g_signal_connect (G_OBJECT (priv->vpn_manager), "connection-activated",
G_CALLBACK (vpn_manager_connection_activated_cb), manager);
g_connection = nm_dbus_manager_get_connection (priv->dbus_mgr);