From 03fd8cc6fddf778f564edd141cd816b0fae4626d Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Mon, 28 Jan 2013 12:30:07 +0100 Subject: [PATCH] * Some more Servent cleanup. --- src/libtomahawk/network/Servent.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/libtomahawk/network/Servent.cpp b/src/libtomahawk/network/Servent.cpp index 443378190..8c3cff85c 100644 --- a/src/libtomahawk/network/Servent.cpp +++ b/src/libtomahawk/network/Servent.cpp @@ -360,6 +360,7 @@ Servent::registerPeer( const Tomahawk::peerinfo_ptr& peerInfo ) } } + void Servent::onSipInfoChanged() { @@ -393,7 +394,7 @@ void Servent::handleSipInfo( const Tomahawk::peerinfo_ptr& peerInfo ) ( externalAddress() == info.host() && externalPort() < info.port() ) ) { - tDebug() << "Initiate connection to" << peerInfo->id() << "at" << info.host() << " peer of: " << peerInfo->sipPlugin()->account()->accountFriendlyName(); + tDebug() << "Initiate connection to" << peerInfo->id() << "at" << info.host() << "peer of:" << peerInfo->sipPlugin()->account()->accountFriendlyName(); connectToPeer( peerInfo ); } else @@ -704,23 +705,23 @@ Servent::connectToPeer( const peerinfo_ptr& peerInfo ) // try to find a ControlConnection with the same SipInfo, then we dont need to try to connect again foreach ( ControlConnection* c, m_controlconnections ) { - if ( !c ) - continue; + Q_ASSERT( c ); if ( c->id() == sipInfo.nodeId() ) { conn = c; - foreach ( const peerinfo_ptr& currentPeerInfo, c->peerInfos() ) - { - peerInfoDebug( currentPeerInfo ) << "Same object: " << ( peerInfo == currentPeerInfo ) << ( peerInfo.data() == currentPeerInfo.data() ) << ( peerInfo->debugName() == currentPeerInfo->debugName() ); + foreach ( const peerinfo_ptr& currentPeerInfo, c->peerInfos() ) + { + peerInfoDebug( currentPeerInfo ) << "Same object:" << ( peerInfo == currentPeerInfo ) << ( peerInfo.data() == currentPeerInfo.data() ) << ( peerInfo->debugName() == currentPeerInfo->debugName() ); - if ( peerInfo == currentPeerInfo ) - { - isDupe = true; - peerInfoDebug( currentPeerInfo ) << "Not adding, because it's a dupe: peerInfoCount remains the same " << conn->peerInfos().count(); - } - } + if ( peerInfo == currentPeerInfo ) + { + isDupe = true; + peerInfoDebug( currentPeerInfo ) << "Not adding, because it's a dupe: peerInfoCount remains the same" << conn->peerInfos().count(); + break; + } + } if ( !c->peerInfos().contains( peerInfo ) ) { @@ -736,11 +737,11 @@ Servent::connectToPeer( const peerinfo_ptr& peerInfo ) } } - peerInfoDebug(peerInfo) << "connectToPeer: found a match: " << ( conn ? conn->name() : "false" ) << "dupe: " << isDupe; + peerInfoDebug( peerInfo ) << "connectToPeer: found a match:" << ( conn ? conn->name() : "false" ) << "dupe:" << isDupe; if ( isDupe ) { - peerInfoDebug(peerInfo) << "it's a dupe, nothing to do here, returning and stopping processing: peerInfoCount:" << conn->peerInfos().count(); + peerInfoDebug( peerInfo ) << "it's a dupe, nothing to do here, returning and stopping processing: peerInfoCount:" << conn->peerInfos().count(); } if ( conn )