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:
parent
37882d5bcf
commit
62df8a2edd
@ -272,6 +272,8 @@ XmppSipPlugin::disconnectPlugin()
|
||||
emit stateChanged( m_state );
|
||||
|
||||
m_client->disconnectFromServer( true );
|
||||
|
||||
setAllPeersOffline();
|
||||
}
|
||||
|
||||
|
||||
|
@ -106,6 +106,8 @@ ZeroconfPlugin::disconnectPlugin()
|
||||
|
||||
delete m_zeroconf;
|
||||
m_zeroconf = 0;
|
||||
|
||||
setAllPeersOffline();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -95,3 +95,12 @@ SipPlugin::peersOnline() const
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void SipPlugin::setAllPeersOffline()
|
||||
{
|
||||
foreach( const Tomahawk::peerinfo_ptr& peerInfo, peersOnline() )
|
||||
{
|
||||
peerInfo->setStatus( Tomahawk::PeerInfo::Offline );
|
||||
}
|
||||
}
|
||||
|
@ -85,6 +85,8 @@ signals:
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void setAllPeersOffline();
|
||||
|
||||
Tomahawk::Accounts::Account *m_account;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user