mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-23 01:09:42 +01:00
Merge branch 'diag-dialog'
This commit is contained in:
commit
e36037a45e
@ -64,6 +64,7 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
|
||||
tomahawktrayicon.cpp
|
||||
audiocontrols.cpp
|
||||
settingsdialog.cpp
|
||||
diagnosticsdialog.cpp
|
||||
configdelegatebase.cpp
|
||||
sipconfigdelegate.cpp
|
||||
resolverconfigdelegate.cpp
|
||||
@ -106,6 +107,7 @@ SET( tomahawkHeadersGui ${tomahawkHeadersGui}
|
||||
tomahawktrayicon.h
|
||||
audiocontrols.h
|
||||
settingsdialog.h
|
||||
diagnosticsdialog.h
|
||||
configdelegatebase.h
|
||||
resolverconfigdelegate.h
|
||||
sipconfigdelegate.h
|
||||
@ -117,6 +119,7 @@ SET( tomahawkHeadersGui ${tomahawkHeadersGui}
|
||||
SET( tomahawkUI ${tomahawkUI}
|
||||
tomahawkwindow.ui
|
||||
settingsdialog.ui
|
||||
diagnosticsdialog.ui
|
||||
stackedsettingsdialog.ui
|
||||
proxydialog.ui
|
||||
|
||||
|
151
src/diagnosticsdialog.cpp
Normal file
151
src/diagnosticsdialog.cpp
Normal file
@ -0,0 +1,151 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2011, Dominik Schmidt <dev@dominik-schmidt.de>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "diagnosticsdialog.h"
|
||||
#include "ui_diagnosticsdialog.h"
|
||||
|
||||
#include <sip/SipHandler.h>
|
||||
#include <network/servent.h>
|
||||
#include <sourcelist.h>
|
||||
|
||||
#include <QTextEdit>
|
||||
#include <QDebug>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
|
||||
DiagnosticsDialog::DiagnosticsDialog( QWidget *parent )
|
||||
: QDialog( parent )
|
||||
, ui( new Ui::DiagnosticsDialog )
|
||||
{
|
||||
ui->setupUi( this );
|
||||
|
||||
connect( ui->updateButton, SIGNAL( clicked() ), this, SLOT( updateLogView() ) );
|
||||
connect( ui->clipboardButton, SIGNAL( clicked() ), this, SLOT( copyToClipboard() ) );
|
||||
connect( ui->buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
|
||||
|
||||
updateLogView();
|
||||
}
|
||||
|
||||
void DiagnosticsDialog::updateLogView()
|
||||
{
|
||||
QString log;
|
||||
|
||||
log.append(
|
||||
QString("TOMAHAWK DIAGNOSTICS LOG -%1 \n\n")
|
||||
.arg( QDateTime::currentDateTime().toString() )
|
||||
);
|
||||
|
||||
// network
|
||||
log.append(
|
||||
"NETWORK:\n"
|
||||
" General:\n"
|
||||
);
|
||||
if( Servent::instance()->visibleExternally() )
|
||||
{
|
||||
log.append(
|
||||
QString(
|
||||
" visible: true\n"
|
||||
" host: %1\n"
|
||||
" port: %2\n"
|
||||
"\n"
|
||||
).arg( Servent::instance()->externalAddress() )
|
||||
.arg( Servent::instance()->externalPort() )
|
||||
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
log.append(
|
||||
QString(
|
||||
" visible: false"
|
||||
)
|
||||
);
|
||||
}
|
||||
log.append("\n\n");
|
||||
|
||||
|
||||
// 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);
|
||||
QString stateString;
|
||||
switch( sip->connectionState() )
|
||||
{
|
||||
case SipPlugin::Connecting:
|
||||
stateString = "Connecting";
|
||||
break;
|
||||
|
||||
case SipPlugin::Connected:
|
||||
stateString = "Connected";
|
||||
break;
|
||||
|
||||
case SipPlugin::Disconnected:
|
||||
stateString = "Disconnected";
|
||||
break;
|
||||
}
|
||||
log.append(
|
||||
QString(" %2 (%1): %3 (%4)\n")
|
||||
.arg(sip->name())
|
||||
.arg(sip->friendlyName())
|
||||
.arg(sip->accountName())
|
||||
.arg(stateString)
|
||||
);
|
||||
|
||||
Q_FOREACH( const QString &peerId, sip->peersOnline() )
|
||||
{
|
||||
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");
|
||||
}
|
||||
|
||||
ui->logView->setPlainText(log);
|
||||
}
|
||||
|
||||
void DiagnosticsDialog::copyToClipboard()
|
||||
{
|
||||
QApplication::clipboard()->setText( ui->logView->toPlainText() );
|
||||
}
|
||||
|
46
src/diagnosticsdialog.h
Normal file
46
src/diagnosticsdialog.h
Normal file
@ -0,0 +1,46 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2011, Dominik Schmidt <dev@dominik-schmidt.de>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef DIGANOSTICSDIALOG_H
|
||||
#define DIAGNOSTICSDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QDebug>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class DiagnosticsDialog;
|
||||
}
|
||||
|
||||
class DiagnosticsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DiagnosticsDialog( QWidget* parent = 0 );
|
||||
~DiagnosticsDialog() {};
|
||||
|
||||
private slots:
|
||||
void updateLogView();
|
||||
void copyToClipboard();
|
||||
|
||||
private:
|
||||
Ui::DiagnosticsDialog* ui;
|
||||
};
|
||||
|
||||
#endif // DIAGNOSTICSDIALOG_H
|
64
src/diagnosticsdialog.ui
Normal file
64
src/diagnosticsdialog.ui
Normal file
@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DiagnosticsDialog</class>
|
||||
<widget class="QDialog" name="DiagnosticsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>621</width>
|
||||
<height>434</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>353</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Tomahawk Diagnostics</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="logView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="updateButton">
|
||||
<property name="text">
|
||||
<string>Update</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="clipboardButton">
|
||||
<property name="text">
|
||||
<string>Copy to Clipboard</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
@ -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 );
|
||||
}
|
||||
|
||||
|
||||
|
@ -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<QString, QVariantMap> m_peersSipInfos;
|
||||
QHash<QString, QPixmap> m_usernameAvatars;
|
||||
};
|
||||
|
||||
|
@ -34,6 +34,8 @@ SipPlugin::SipPlugin( const QString& pluginId, QObject* parent )
|
||||
{
|
||||
connect( this, SIGNAL( error( int, QString ) ), this, SLOT( onError( int,QString ) ) );
|
||||
connect( this, SIGNAL( stateChanged( SipPlugin::ConnectionState ) ), this, SLOT( onStateChange( SipPlugin::ConnectionState ) ) );
|
||||
connect( this, SIGNAL( peerOnline( QString ) ), this, SLOT( onPeerOnline( QString ) ) );
|
||||
connect( this, SIGNAL( peerOffline( QString ) ), this, SLOT( onPeerOffline( QString ) ) );
|
||||
}
|
||||
|
||||
QString SipPlugin::pluginId() const
|
||||
@ -67,6 +69,13 @@ SipPlugin::icon() const
|
||||
return QIcon();
|
||||
}
|
||||
|
||||
const QStringList
|
||||
SipPlugin::peersOnline() const
|
||||
{
|
||||
return m_peersOnline;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SipPlugin::setProxy( const QNetworkProxy& proxy )
|
||||
{
|
||||
@ -85,3 +94,18 @@ SipPlugin::onStateChange( SipPlugin::ConnectionState state )
|
||||
m_cachedError.clear();
|
||||
}
|
||||
|
||||
void
|
||||
SipPlugin::onPeerOnline(const QString& peerId)
|
||||
{
|
||||
if( !m_peersOnline.contains( peerId ) )
|
||||
{
|
||||
m_peersOnline.append( peerId );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SipPlugin::onPeerOffline(const QString& peerId)
|
||||
{
|
||||
m_peersOnline.removeAll( peerId );
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,9 @@ public:
|
||||
virtual void saveConfig() {} // called when the widget has been edited
|
||||
virtual QIcon icon() const;
|
||||
|
||||
// peer infos
|
||||
virtual const QStringList peersOnline() const;
|
||||
|
||||
public slots:
|
||||
virtual bool connectPlugin( bool startup = false ) = 0;
|
||||
virtual void disconnectPlugin() = 0;
|
||||
@ -108,9 +111,13 @@ private slots:
|
||||
void onError( int, const QString& );
|
||||
void onStateChange( SipPlugin::ConnectionState state );
|
||||
|
||||
void onPeerOnline( const QString &peerId );
|
||||
void onPeerOffline( const QString &peerId );
|
||||
|
||||
private:
|
||||
QString m_pluginId;
|
||||
QString m_cachedError;
|
||||
QStringList m_peersOnline;
|
||||
};
|
||||
|
||||
Q_DECLARE_INTERFACE( SipPluginFactory, "tomahawk.SipFactory/1.0" )
|
||||
|
@ -233,12 +233,6 @@ JabberPlugin::disconnectPlugin()
|
||||
return;
|
||||
}
|
||||
|
||||
foreach(const Jreen::JID &peer, m_peers.keys())
|
||||
{
|
||||
handlePeerStatus(peer, Jreen::Presence::Unavailable);
|
||||
}
|
||||
|
||||
|
||||
//m_roster->deleteLater();
|
||||
//m_roster = 0;
|
||||
//m_room->deleteLater();
|
||||
@ -326,6 +320,11 @@ JabberPlugin::onDisconnect( Jreen::Client::DisconnectReason reason )
|
||||
emit stateChanged( m_state );
|
||||
|
||||
removeMenuHelper();
|
||||
|
||||
Q_FOREACH(const Jreen::JID &peer, m_peers.keys())
|
||||
{
|
||||
handlePeerStatus(peer, Jreen::Presence::Unavailable);
|
||||
}
|
||||
}
|
||||
|
||||
QString
|
||||
|
@ -52,6 +52,7 @@
|
||||
|
||||
#include "audiocontrols.h"
|
||||
#include "settingsdialog.h"
|
||||
#include "diagnosticsdialog.h"
|
||||
#include "tomahawksettings.h"
|
||||
#include "sourcelist.h"
|
||||
#include "transferview.h"
|
||||
@ -261,6 +262,7 @@ TomahawkWindow::setupSignals()
|
||||
|
||||
// <Menu Items>
|
||||
connect( ui->actionPreferences, SIGNAL( triggered() ), SLOT( showSettingsDialog() ) );
|
||||
connect( ui->actionDiagnostics, SIGNAL( triggered() ), SLOT( showDiagnosticsDialog() ) );
|
||||
connect( ui->actionToggleConnect, SIGNAL( triggered() ), APP->sipHandler(), SLOT( toggleConnect() ) );
|
||||
// connect( ui->actionAddPeerManually, SIGNAL( triggered() ), SLOT( addPeerManually() ) );
|
||||
connect( ui->actionRescanCollection, SIGNAL( triggered() ), SLOT( updateCollectionManually() ) );
|
||||
@ -349,6 +351,13 @@ TomahawkWindow::showSettingsDialog()
|
||||
win.exec();
|
||||
}
|
||||
|
||||
void TomahawkWindow::showDiagnosticsDialog()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
DiagnosticsDialog win;
|
||||
win.exec();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::updateCollectionManually()
|
||||
|
@ -66,6 +66,7 @@ public slots:
|
||||
void createPlaylist();
|
||||
void loadSpiff();
|
||||
void showSettingsDialog();
|
||||
void showDiagnosticsDialog();
|
||||
void updateCollectionManually();
|
||||
void pluginMenuAdded(QMenu*);
|
||||
void pluginMenuRemoved(QMenu*);
|
||||
|
@ -83,6 +83,8 @@
|
||||
<property name="title">
|
||||
<string>&Help</string>
|
||||
</property>
|
||||
<addaction name="actionDiagnostics"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionAboutTomahawk"/>
|
||||
</widget>
|
||||
<addaction name="menuApp"/>
|
||||
@ -181,6 +183,11 @@
|
||||
<string>Meta+Ctrl+Z</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDiagnostics">
|
||||
<property name="text">
|
||||
<string>Diagnostics...</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user