From 31c3c50292fcc74220d59e739e5532bcee7ca706 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Fri, 6 May 2011 02:13:01 +0200 Subject: [PATCH] DiagnosticsDialog: Add more details on peers. Ugly caching in SipHandler, wanna avoid ugly-back-and-forth-json-parsing until we have a proper SipInfo class --- src/diagnosticsdialog.cpp | 33 +++++++++++++++++++++++++----- src/libtomahawk/sip/SipHandler.cpp | 8 +++++++- src/libtomahawk/sip/SipHandler.h | 5 ++++- 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/diagnosticsdialog.cpp b/src/diagnosticsdialog.cpp index 213d32bdd..ec2c0135e 100644 --- a/src/diagnosticsdialog.cpp +++ b/src/diagnosticsdialog.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -79,6 +80,7 @@ void DiagnosticsDialog::updateLogView() // Peers log.append("SIP PLUGINS:\n"); + QList< Tomahawk::source_ptr > sources = SourceList::instance()->sources( true ); Q_FOREACH(SipPlugin *sip, SipHandler::instance()->allPlugins()) { Q_ASSERT(sip); @@ -105,12 +107,33 @@ void DiagnosticsDialog::updateLogView() .arg(stateString) ); - Q_FOREACH(const QString &peerId, sip->peersOnline()) + Q_FOREACH( const QString &peerId, sip->peersOnline() ) { - log.append( - QString(" %1\n") - .arg(peerId) - ); + bool connected = false; + Q_FOREACH( const Tomahawk::source_ptr &source, sources ) + { + if( source->controlConnection() ) + { + connected = true; + break; + } + } + + QVariantMap sipInfo = SipHandler::instance()->sipInfo( peerId ); + if( sipInfo.value( "visible").toBool() ) + log.append( + QString(" %1: %2:%3 (%4)\n") + .arg( peerId ) + .arg( sipInfo.value( "ip" ).toString() ) + .arg( sipInfo.value( "port" ).toString() ) + .arg( connected ? "connected" : "not connected") + ); + else + log.append( + QString(" %1: visible: false (%2)\n") + .arg( peerId ) + .arg( connected ? "connected" : "not connected") + ); } log.append("\n"); } diff --git a/src/libtomahawk/sip/SipHandler.cpp b/src/libtomahawk/sip/SipHandler.cpp index b1889c74e..2907ddb8e 100644 --- a/src/libtomahawk/sip/SipHandler.cpp +++ b/src/libtomahawk/sip/SipHandler.cpp @@ -80,7 +80,11 @@ const QPixmap SipHandler::avatar( const QString& name ) const } } - +const QVariantMap +SipHandler::sipInfo(const QString& peerId) const +{ + return m_peersSipInfos.value( peerId ); +} void SipHandler::onSettingsChanged() @@ -510,6 +514,8 @@ SipHandler::onMessage( const QString& from, const QString& msg ) { qDebug() << Q_FUNC_INFO << "They are not visible, doing nothing atm"; } + + m_peersSipInfos.insert( from, m ); } diff --git a/src/libtomahawk/sip/SipHandler.h b/src/libtomahawk/sip/SipHandler.h index e108c1d28..8fc7a222b 100644 --- a/src/libtomahawk/sip/SipHandler.h +++ b/src/libtomahawk/sip/SipHandler.h @@ -51,6 +51,8 @@ public: SipPluginFactory* factoryFromPlugin( SipPlugin* p ) const; const QPixmap avatar( const QString& name ) const; + //TODO: implement a proper SipInfo class and maybe attach it to the source + const QVariantMap sipInfo( const QString& peerId ) const; public slots: void checkSettings(); @@ -115,7 +117,8 @@ private: QList< SipPlugin* > m_connectedPlugins; bool m_connected; - + //TODO: move this to source + QHash m_peersSipInfos; QHash m_usernameAvatars; };