mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
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
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <sip/SipHandler.h>
|
#include <sip/SipHandler.h>
|
||||||
#include <network/servent.h>
|
#include <network/servent.h>
|
||||||
|
#include <sourcelist.h>
|
||||||
|
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@@ -79,6 +80,7 @@ void DiagnosticsDialog::updateLogView()
|
|||||||
|
|
||||||
// Peers
|
// Peers
|
||||||
log.append("SIP PLUGINS:\n");
|
log.append("SIP PLUGINS:\n");
|
||||||
|
QList< Tomahawk::source_ptr > sources = SourceList::instance()->sources( true );
|
||||||
Q_FOREACH(SipPlugin *sip, SipHandler::instance()->allPlugins())
|
Q_FOREACH(SipPlugin *sip, SipHandler::instance()->allPlugins())
|
||||||
{
|
{
|
||||||
Q_ASSERT(sip);
|
Q_ASSERT(sip);
|
||||||
@@ -105,12 +107,33 @@ void DiagnosticsDialog::updateLogView()
|
|||||||
.arg(stateString)
|
.arg(stateString)
|
||||||
);
|
);
|
||||||
|
|
||||||
Q_FOREACH(const QString &peerId, sip->peersOnline())
|
Q_FOREACH( const QString &peerId, sip->peersOnline() )
|
||||||
{
|
{
|
||||||
log.append(
|
bool connected = false;
|
||||||
QString(" %1\n")
|
Q_FOREACH( const Tomahawk::source_ptr &source, sources )
|
||||||
.arg(peerId)
|
{
|
||||||
);
|
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");
|
log.append("\n");
|
||||||
}
|
}
|
||||||
|
@@ -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
|
void
|
||||||
SipHandler::onSettingsChanged()
|
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";
|
qDebug() << Q_FUNC_INFO << "They are not visible, doing nothing atm";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_peersSipInfos.insert( from, m );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -51,6 +51,8 @@ public:
|
|||||||
SipPluginFactory* factoryFromPlugin( SipPlugin* p ) const;
|
SipPluginFactory* factoryFromPlugin( SipPlugin* p ) const;
|
||||||
|
|
||||||
const QPixmap avatar( const QString& name ) 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:
|
public slots:
|
||||||
void checkSettings();
|
void checkSettings();
|
||||||
@@ -115,7 +117,8 @@ private:
|
|||||||
QList< SipPlugin* > m_connectedPlugins;
|
QList< SipPlugin* > m_connectedPlugins;
|
||||||
bool m_connected;
|
bool m_connected;
|
||||||
|
|
||||||
|
//TODO: move this to source
|
||||||
|
QHash<QString, QVariantMap> m_peersSipInfos;
|
||||||
QHash<QString, QPixmap> m_usernameAvatars;
|
QHash<QString, QPixmap> m_usernameAvatars;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user