diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 7947042ae..af3f0dfdc 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -265,6 +265,13 @@ TwitterPlugin::connectTimerFired() foreach( QString screenName, peerlist ) { QHash< QString, QVariant > peerData = m_cachedPeers[screenName].toHash(); + + if ( QDateTime::currentDateTimeUtc().toMSecsSinceEpoch() - peerData["lastseen"].toLongLong() > 1209600000 ) // 2 weeks + { + qDebug() << "Aging peer " << screenName << " out of cache"; + m_cachedPeers.remove( screenName ); + continue; + } if ( !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) ) { @@ -568,6 +575,7 @@ TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, Q if ( peersChanged ) { + _peerData["lastseen"] = QString::number( QDateTime::currentDateTimeUtc().toMSecsSinceEpoch() ); m_cachedPeers[screenName] = QVariant::fromValue< QHash< QString, QVariant > >( _peerData ); TomahawkSettings::instance()->setTwitterCachedPeers( m_cachedPeers ); } @@ -595,7 +603,8 @@ void TwitterPlugin::makeConnection( const QString &screenName, const QHash< QString, QVariant > &peerData ) { qDebug() << Q_FUNC_INFO; - if ( !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) || !peerData.contains( "node" ) ) + if ( !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) || !peerData.contains( "node" ) || + peerData["host"].toString().isEmpty() || peerData["port"].toString().isEmpty() || peerData["pkey"].toString().isEmpty() || peerData["node"].toString().isEmpty() ) { qDebug() << "TwitterPlugin could not find host and/or port and/or pkey and/or node for peer " << screenName; return;