mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Refactor the creation of local SipInfos into its own method
This commit is contained in:
@@ -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
|
void
|
||||||
Servent::registerPeer( const Tomahawk::peerinfo_ptr& peerInfo )
|
Servent::registerPeer( const Tomahawk::peerinfo_ptr& peerInfo )
|
||||||
{
|
{
|
||||||
@@ -398,37 +436,7 @@ Servent::registerPeer( const Tomahawk::peerinfo_ptr& peerInfo )
|
|||||||
conn->addPeerInfo( peerInfo );
|
conn->addPeerInfo( peerInfo );
|
||||||
|
|
||||||
registerOffer( key, conn );
|
registerOffer( key, conn );
|
||||||
QList<SipInfo> sipInfos = QList<SipInfo>();
|
QList<SipInfo> sipInfos = getLocalSipInfos( nodeid, key );
|
||||||
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.";
|
|
||||||
}
|
|
||||||
|
|
||||||
peerInfo->sendLocalSipInfos( sipInfos );
|
peerInfo->sendLocalSipInfos( sipInfos );
|
||||||
|
|
||||||
|
@@ -130,6 +130,7 @@ public:
|
|||||||
|
|
||||||
bool isReady() const { return m_ready; }
|
bool isReady() const { return m_ready; }
|
||||||
|
|
||||||
|
QList<SipInfo> getLocalSipInfos(const QString& nodeid, QString key);
|
||||||
signals:
|
signals:
|
||||||
void dbSyncTriggered();
|
void dbSyncTriggered();
|
||||||
void streamStarted( StreamConnection* );
|
void streamStarted( StreamConnection* );
|
||||||
|
Reference in New Issue
Block a user