1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-08 15:16:34 +02: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 ); emit stateChanged( m_state );
m_client->disconnectFromServer( true ); m_client->disconnectFromServer( true );
setAllPeersOffline();
} }

View File

@@ -106,6 +106,8 @@ ZeroconfPlugin::disconnectPlugin()
delete m_zeroconf; delete m_zeroconf;
m_zeroconf = 0; 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 > const QSet< peerinfo_ptr >
ControlConnection::peerInfos() const ControlConnection::peerInfos() const
{ {

View File

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

View File

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

View File

@@ -95,3 +95,12 @@ SipPlugin::peersOnline() const
return result; 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 #endif
protected: protected:
void setAllPeersOffline();
Tomahawk::Accounts::Account *m_account; Tomahawk::Accounts::Account *m_account;
}; };