mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-12 00:54:20 +02:00
Take sources offline if no peerinfos are available anymore
This commit is contained in:
@@ -272,6 +272,8 @@ XmppSipPlugin::disconnectPlugin()
|
|||||||
emit stateChanged( m_state );
|
emit stateChanged( m_state );
|
||||||
|
|
||||||
m_client->disconnectFromServer( true );
|
m_client->disconnectFromServer( true );
|
||||||
|
|
||||||
|
setAllPeersOffline();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -106,6 +106,8 @@ ZeroconfPlugin::disconnectPlugin()
|
|||||||
|
|
||||||
delete m_zeroconf;
|
delete m_zeroconf;
|
||||||
m_zeroconf = 0;
|
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 >
|
const QSet< peerinfo_ptr >
|
||||||
ControlConnection::peerInfos() const
|
ControlConnection::peerInfos() const
|
||||||
{
|
{
|
||||||
|
@@ -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:
|
||||||
|
@@ -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
|
||||||
|
@@ -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 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -85,6 +85,8 @@ signals:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void setAllPeersOffline();
|
||||||
|
|
||||||
Tomahawk::Accounts::Account *m_account;
|
Tomahawk::Accounts::Account *m_account;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user