mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 15:59:42 +01:00
Refactor the creation of local SipInfos into its own method
This commit is contained in:
parent
89dd9a466d
commit
11b4e1f743
@ -347,6 +347,44 @@ Servent::lookupControlConnection( const SipInfo& sipInfo )
|
||||
}
|
||||
|
||||
|
||||
QList<SipInfo>
|
||||
Servent::getLocalSipInfos( const QString& nodeid, QString key )
|
||||
{
|
||||
QList<SipInfo> sipInfos = QList<SipInfo>();
|
||||
foreach ( QHostAddress ha, m_externalAddresses )
|
||||
{
|
||||
SipInfo info = SipInfo();
|
||||
info.setHost( ha.toString() );
|
||||
info.setPort( m_port );
|
||||
info.setKey( key );
|
||||
info.setVisible( true );
|
||||
info.setNodeId( nodeid );
|
||||
sipInfos.append( info );
|
||||
}
|
||||
if ( m_externalHostname.length() > 0)
|
||||
{
|
||||
SipInfo info = SipInfo();
|
||||
info.setHost( m_externalHostname );
|
||||
info.setPort( m_externalPort );
|
||||
info.setKey( key );
|
||||
info.setVisible( true );
|
||||
info.setNodeId( nodeid );
|
||||
sipInfos.append( info );
|
||||
}
|
||||
|
||||
if ( sipInfos.isEmpty() )
|
||||
{
|
||||
// We are not visible via any IP, send a dummy SipInfo
|
||||
SipInfo info = SipInfo();
|
||||
info.setVisible( false );
|
||||
info.setKey( key );
|
||||
info.setNodeId( nodeid );
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Only accepting connections, no usable IP to listen to found.";
|
||||
}
|
||||
|
||||
return sipInfos;
|
||||
}
|
||||
|
||||
void
|
||||
Servent::registerPeer( const Tomahawk::peerinfo_ptr& peerInfo )
|
||||
{
|
||||
@ -398,37 +436,7 @@ Servent::registerPeer( const Tomahawk::peerinfo_ptr& peerInfo )
|
||||
conn->addPeerInfo( peerInfo );
|
||||
|
||||
registerOffer( key, conn );
|
||||
QList<SipInfo> sipInfos = QList<SipInfo>();
|
||||
foreach ( QHostAddress ha, m_externalAddresses )
|
||||
{
|
||||
SipInfo info = SipInfo();
|
||||
info.setHost( ha.toString() );
|
||||
info.setPort( m_port );
|
||||
info.setKey( key );
|
||||
info.setVisible( true );
|
||||
info.setNodeId( nodeid );
|
||||
sipInfos.append( info );
|
||||
}
|
||||
if ( m_externalHostname.length() > 0)
|
||||
{
|
||||
SipInfo info = SipInfo();
|
||||
info.setHost( m_externalHostname );
|
||||
info.setPort( m_externalPort );
|
||||
info.setKey( key );
|
||||
info.setVisible( true );
|
||||
info.setNodeId( nodeid );
|
||||
sipInfos.append( info );
|
||||
}
|
||||
|
||||
if ( sipInfos.isEmpty() )
|
||||
{
|
||||
// We are not visible via any IP, send a dummy SipInfo
|
||||
SipInfo info = SipInfo();
|
||||
info.setVisible( false );
|
||||
info.setKey( key );
|
||||
info.setNodeId( nodeid );
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Only accepting connections, no usable IP to listen to found.";
|
||||
}
|
||||
QList<SipInfo> sipInfos = getLocalSipInfos( nodeid, key );
|
||||
|
||||
peerInfo->sendLocalSipInfos( sipInfos );
|
||||
|
||||
|
@ -130,6 +130,7 @@ public:
|
||||
|
||||
bool isReady() const { return m_ready; }
|
||||
|
||||
QList<SipInfo> getLocalSipInfos(const QString& nodeid, QString key);
|
||||
signals:
|
||||
void dbSyncTriggered();
|
||||
void streamStarted( StreamConnection* );
|
||||
|
Loading…
x
Reference in New Issue
Block a user