1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-24 01:39:42 +01:00

Take sources offline if no peerinfos are available anymore

This commit is contained in:
Dominik Schmidt 2013-01-14 06:18:10 +01:00
parent 37882d5bcf
commit 62df8a2edd
7 changed files with 38 additions and 0 deletions

View File

@ -272,6 +272,8 @@ XmppSipPlugin::disconnectPlugin()
emit stateChanged( m_state );
m_client->disconnectFromServer( true );
setAllPeersOffline();
}

View File

@ -106,6 +106,8 @@ ZeroconfPlugin::disconnectPlugin()
delete m_zeroconf;
m_zeroconf = 0;
setAllPeersOffline();
}

View File

@ -280,6 +280,22 @@ ControlConnection::addPeerInfo( const peerinfo_ptr& peerInfo )
}
void
ControlConnection::removePeerInfo( const peerinfo_ptr& peerInfo )
{
peerInfoDebug( peerInfo ) << "Remove peer from control connection:" << name();
Q_ASSERT( peerInfo->controlConnection() == this );
Q_ASSERT( m_peerInfos.contains( peerInfo ) );
m_peerInfos.remove( peerInfo );
if ( m_peerInfos.isEmpty() )
{
shutdown( true );
}
}
const QSet< peerinfo_ptr >
ControlConnection::peerInfos() const
{

View File

@ -49,6 +49,7 @@ public:
Tomahawk::source_ptr source() const;
void addPeerInfo( const Tomahawk::peerinfo_ptr& peerInfo );
void removePeerInfo( const Tomahawk::peerinfo_ptr& peerInfo );
const QSet< Tomahawk::peerinfo_ptr > peerInfos() const;
protected:

View File

@ -176,7 +176,13 @@ PeerInfo::setStatus( PeerInfo::Status status )
m_status = status;
if( status == Online )
{
announce();
}
else if( status == Offline && controlConnection() )
{
controlConnection()->removePeerInfo( weakRef().toStrongRef() );
}
// we need this to update the DiagnosticsDialog on new peers
// if we ever happen to have a central PeerInfo manager object

View File

@ -95,3 +95,12 @@ SipPlugin::peersOnline() const
return result;
}
void SipPlugin::setAllPeersOffline()
{
foreach( const Tomahawk::peerinfo_ptr& peerInfo, peersOnline() )
{
peerInfo->setStatus( Tomahawk::PeerInfo::Offline );
}
}

View File

@ -85,6 +85,8 @@ signals:
#endif
protected:
void setAllPeersOffline();
Tomahawk::Accounts::Account *m_account;
};