1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-19 23:39:42 +01:00

Group peers by (Account, nodeid) in the Diagnostics Dialog, add nodeid info

This commit is contained in:
Uwe L. Korn 2013-06-10 15:44:01 +02:00
parent 25d6f59cc3
commit df7550d73b

View File

@ -166,19 +166,41 @@ DiagnosticsDialog::accountLog( Tomahawk::Accounts::Account* account )
.arg( stateString )
);
foreach( const Tomahawk::peerinfo_ptr& peerInfo, account->sipPlugin()->peersOnline() )
QMap< QString, QList< Tomahawk::peerinfo_ptr > > nodes;
foreach ( const Tomahawk::peerinfo_ptr& peerInfo, account->sipPlugin()->peersOnline() )
{
accountInfo.append( QString( " %1: " ).arg( peerInfo->id() ) );
foreach ( SipInfo info, peerInfo->sipInfos() )
if ( !nodes.contains( peerInfo->nodeId() ) )
{
if ( info.isValid() )
accountInfo.append( QString( "[%1]:%2; " ).arg( info.host() ).arg( info.port() ) );
else
accountInfo.append( "SipInfo invalid; " );
nodes[peerInfo->nodeId()] = QList< Tomahawk::peerinfo_ptr >();
}
if ( ( ( peerInfo->sipInfos().length() == 1 ) && ( !peerInfo->sipInfos().first().isVisible() ) ) || ( peerInfo->sipInfos().isEmpty() ) )
nodes[peerInfo->nodeId()].append( peerInfo);
}
foreach ( const QString& nodeid, nodes.keys() )
{
accountInfo.append( QString( " " ) );
QStringList peerIds;
foreach ( const Tomahawk::peerinfo_ptr& peerInfo, nodes.value( nodeid ) )
{
peerIds << peerInfo->id();
}
accountInfo.append( peerIds.join( QChar( ',' ) ) );
accountInfo.append( QString( ": %1 @ ").arg( nodeid ) );
QStringList sipInfos;
foreach ( const Tomahawk::peerinfo_ptr& peerInfo, nodes.value( nodeid ) )
{
foreach ( SipInfo info, peerInfo->sipInfos() )
{
if ( info.isValid() )
sipInfos << QString( "[%1]:%2" ).arg( info.host() ).arg( info.port() ) ;
else
sipInfos << QString( "SipInfo invalid" );
}
}
sipInfos.removeDuplicates();
accountInfo.append( sipInfos.join( QChar( ';' ) ) );
if ( ( ( nodes.value( nodeid ).first()->sipInfos().length() == 1 ) && ( !nodes.value( nodeid ).first()->sipInfos().first().isVisible() ) ) || ( nodes.value( nodeid ).first()->sipInfos().isEmpty() ) )
accountInfo.append( "(outbound connections only) ");
accountInfo.append( QString( " (%1)\n" ).arg( peerInfo->versionString() ) );
accountInfo.append( QString( " (%1)\n" ).arg( nodes.value( nodeid ).first()->versionString() ) );
}
accountInfo.append( "\n" );