1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-01 20:00:13 +02:00

Do not squash Peers with no nodeid

This commit is contained in:
Uwe L. Korn
2013-06-10 17:36:35 +02:00
parent 9500f5e593
commit 6ab30bd7af
2 changed files with 38 additions and 24 deletions

View File

@@ -169,6 +169,12 @@ DiagnosticsDialog::accountLog( Tomahawk::Accounts::Account* account )
QMap< QString, QList< Tomahawk::peerinfo_ptr > > nodes; QMap< QString, QList< Tomahawk::peerinfo_ptr > > nodes;
foreach ( const Tomahawk::peerinfo_ptr& peerInfo, account->sipPlugin()->peersOnline() ) foreach ( const Tomahawk::peerinfo_ptr& peerInfo, account->sipPlugin()->peersOnline() )
{ {
if ( peerInfo->nodeId().isEmpty() )
{
QList< Tomahawk::peerinfo_ptr> infos;
infos.append( peerInfo );
accountInfo.append( peerLog( peerInfo->nodeId(), infos ) );
}
if ( !nodes.contains( peerInfo->nodeId() ) ) if ( !nodes.contains( peerInfo->nodeId() ) )
{ {
nodes[peerInfo->nodeId()] = QList< Tomahawk::peerinfo_ptr >(); nodes[peerInfo->nodeId()] = QList< Tomahawk::peerinfo_ptr >();
@@ -177,16 +183,26 @@ DiagnosticsDialog::accountLog( Tomahawk::Accounts::Account* account )
} }
foreach ( const QString& nodeid, nodes.keys() ) foreach ( const QString& nodeid, nodes.keys() )
{ {
accountInfo.append( QString( " " ) ); accountInfo.append( peerLog( nodeid, nodes.value( nodeid ) ) );
}
accountInfo.append( "\n" );
return accountInfo;
}
QString
DiagnosticsDialog::peerLog( const QString& nodeid, const QList<Tomahawk::peerinfo_ptr> &peerInfos )
{
QString peerLine( " " );
QStringList peerIds; QStringList peerIds;
foreach ( const Tomahawk::peerinfo_ptr& peerInfo, nodes.value( nodeid ) ) foreach ( const Tomahawk::peerinfo_ptr& peerInfo, peerInfos )
{ {
peerIds << peerInfo->id(); peerIds << peerInfo->id();
} }
accountInfo.append( peerIds.join( QChar( ',' ) ) ); peerLine.append( peerIds.join( QChar( ',' ) ) );
accountInfo.append( QString( ": %1 @ ").arg( nodeid ) ); peerLine.append( QString( ": %1 @ ").arg( nodeid ) );
QStringList sipInfos; QStringList sipInfos;
foreach ( const Tomahawk::peerinfo_ptr& peerInfo, nodes.value( nodeid ) ) foreach ( const Tomahawk::peerinfo_ptr& peerInfo, peerInfos )
{ {
foreach ( SipInfo info, peerInfo->sipInfos() ) foreach ( SipInfo info, peerInfo->sipInfos() )
{ {
@@ -197,12 +213,9 @@ DiagnosticsDialog::accountLog( Tomahawk::Accounts::Account* account )
} }
} }
sipInfos.removeDuplicates(); sipInfos.removeDuplicates();
accountInfo.append( sipInfos.join( QChar( ';' ) ) ); peerLine.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() ) ) if ( ( ( peerInfos.first()->sipInfos().length() == 1 ) && ( !peerInfos.first()->sipInfos().first().isVisible() ) ) || ( peerInfos.first()->sipInfos().isEmpty() ) )
accountInfo.append( "(outbound connections only) "); peerLine.append( "(outbound connections only) ");
accountInfo.append( QString( " (%1)\n" ).arg( nodes.value( nodeid ).first()->versionString() ) ); peerLine.append( QString( " (%1)\n" ).arg( peerInfos.first()->versionString() ) );
} return peerLine;
accountInfo.append( "\n" );
return accountInfo;
} }

View File

@@ -51,6 +51,7 @@ private slots:
private: private:
Ui::DiagnosticsDialog* ui; Ui::DiagnosticsDialog* ui;
QString peerLog( const QString& nodeid, const QList<Tomahawk::peerinfo_ptr>& peerInfos );
}; };
#endif // DIAGNOSTICSDIALOG_H #endif // DIAGNOSTICSDIALOG_H