mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-31 09:32:03 +02:00
Change plugin structure to fix adding friends.
This commit is contained in:
@@ -1,2 +1,7 @@
|
|||||||
#include <sip/SipPlugin.h>
|
#include <sip/SipPlugin.h>
|
||||||
|
|
||||||
|
QMenu*
|
||||||
|
SipPlugin::menu()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
@@ -17,6 +18,8 @@ public:
|
|||||||
|
|
||||||
virtual bool isValid() = 0;
|
virtual bool isValid() = 0;
|
||||||
virtual const QString name() = 0;
|
virtual const QString name() = 0;
|
||||||
|
virtual const QString accountName() = 0;
|
||||||
|
virtual QMenu *menu();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual bool connectPlugin( bool startup = false ) = 0;
|
virtual bool connectPlugin( bool startup = false ) = 0;
|
||||||
|
@@ -27,6 +27,12 @@ SipHandler::~SipHandler()
|
|||||||
disconnectPlugins();
|
disconnectPlugins();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList< SipPlugin* >
|
||||||
|
SipHandler::plugins() const
|
||||||
|
{
|
||||||
|
return m_plugins;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SipHandler::onSettingsChanged()
|
SipHandler::onSettingsChanged()
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
#ifndef SIPHANDLER_H
|
#ifndef SIPHANDLER_H
|
||||||
#define SIPHANDLER_H
|
#define SIPHANDLER_H
|
||||||
|
|
||||||
|
#include "sip/SipPlugin.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
class SipPlugin;
|
|
||||||
|
|
||||||
class SipHandler : public QObject
|
class SipHandler : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -16,6 +16,8 @@ public:
|
|||||||
SipHandler( QObject* parent );
|
SipHandler( QObject* parent );
|
||||||
~SipHandler();
|
~SipHandler();
|
||||||
|
|
||||||
|
QList< SipPlugin* > plugins() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addContact( const QString& id ) { qDebug() << Q_FUNC_INFO << id; }
|
void addContact( const QString& id ) { qDebug() << Q_FUNC_INFO << id; }
|
||||||
|
|
||||||
|
@@ -2,9 +2,22 @@
|
|||||||
|
|
||||||
#include "tomahawksettings.h"
|
#include "tomahawksettings.h"
|
||||||
|
|
||||||
|
#include "tomahawk/tomahawkapp.h"
|
||||||
|
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QInputDialog>
|
||||||
|
#include <QLineEdit>
|
||||||
|
|
||||||
|
JabberPlugin::JabberPlugin()
|
||||||
|
: p( 0 )
|
||||||
|
{
|
||||||
|
m_menu = new QMenu(QString("Jabber (").append(accountName()).append(")"));
|
||||||
|
m_addFriendAction = m_menu->addAction("Add Friend...");
|
||||||
|
|
||||||
|
connect(m_addFriendAction, SIGNAL(triggered()),
|
||||||
|
this, SLOT(showAddFriendDialog()));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
JabberPlugin::setProxy( QNetworkProxy* proxy )
|
JabberPlugin::setProxy( QNetworkProxy* proxy )
|
||||||
@@ -19,6 +32,17 @@ JabberPlugin::name()
|
|||||||
return QString( MYNAME );
|
return QString( MYNAME );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString
|
||||||
|
JabberPlugin::accountName()
|
||||||
|
{
|
||||||
|
return TomahawkSettings::instance()->jabberUsername();
|
||||||
|
}
|
||||||
|
|
||||||
|
QMenu*
|
||||||
|
JabberPlugin::menu()
|
||||||
|
{
|
||||||
|
return m_menu;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
JabberPlugin::connectPlugin( bool startup )
|
JabberPlugin::connectPlugin( bool startup )
|
||||||
@@ -74,4 +98,18 @@ JabberPlugin::onAuthError( int code, const QString& message )
|
|||||||
emit error( SipPlugin::ConnectionError, message );
|
emit error( SipPlugin::ConnectionError, message );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
JabberPlugin::showAddFriendDialog()
|
||||||
|
{
|
||||||
|
bool ok;
|
||||||
|
QString id = QInputDialog::getText( TomahawkApp::instance()->mainWindow(), tr( "Add Friend" ),
|
||||||
|
tr( "Enter Jabber ID:" ), QLineEdit::Normal,
|
||||||
|
"", &ok );
|
||||||
|
if ( !ok )
|
||||||
|
return;
|
||||||
|
|
||||||
|
qDebug() << "Attempting to add jabber contact to roster:" << id;
|
||||||
|
addContact( id );
|
||||||
|
}
|
||||||
|
|
||||||
Q_EXPORT_PLUGIN2( sip, JabberPlugin )
|
Q_EXPORT_PLUGIN2( sip, JabberPlugin )
|
||||||
|
@@ -14,9 +14,7 @@ class SIPDLLEXPORT JabberPlugin : public SipPlugin
|
|||||||
Q_INTERFACES( SipPlugin )
|
Q_INTERFACES( SipPlugin )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
JabberPlugin()
|
JabberPlugin();
|
||||||
: p( 0 )
|
|
||||||
{}
|
|
||||||
|
|
||||||
virtual ~JabberPlugin() { delete p; }
|
virtual ~JabberPlugin() { delete p; }
|
||||||
|
|
||||||
@@ -24,6 +22,9 @@ public:
|
|||||||
virtual bool isValid() { return true; }
|
virtual bool isValid() { return true; }
|
||||||
virtual const QString name();
|
virtual const QString name();
|
||||||
|
|
||||||
|
virtual const QString accountName();
|
||||||
|
virtual QMenu* menu();
|
||||||
|
|
||||||
void setProxy( QNetworkProxy* proxy );
|
void setProxy( QNetworkProxy* proxy );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@@ -58,9 +59,12 @@ public slots:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onAuthError( int, const QString& );
|
void onAuthError( int, const QString& );
|
||||||
|
void showAddFriendDialog();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Jabber_p* p;
|
Jabber_p* p;
|
||||||
|
QMenu* m_menu;
|
||||||
|
QAction* m_addFriendAction;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -53,6 +53,12 @@ TwitterPlugin::name()
|
|||||||
return QString( MYNAME );
|
return QString( MYNAME );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString
|
||||||
|
TwitterPlugin::accountName()
|
||||||
|
{
|
||||||
|
return QString( TomahawkSettings::instance()->twitterScreenName() );
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TwitterPlugin::connectPlugin( bool /*startup*/ )
|
TwitterPlugin::connectPlugin( bool /*startup*/ )
|
||||||
{
|
{
|
||||||
|
@@ -32,6 +32,7 @@ public:
|
|||||||
|
|
||||||
virtual bool isValid();
|
virtual bool isValid();
|
||||||
virtual const QString name();
|
virtual const QString name();
|
||||||
|
virtual const QString accountName();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual bool connectPlugin( bool startup );
|
virtual bool connectPlugin( bool startup );
|
||||||
|
@@ -8,6 +8,12 @@ ZeroconfPlugin::name()
|
|||||||
return QString( MYNAME );
|
return QString( MYNAME );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString
|
||||||
|
ZeroconfPlugin::accountName()
|
||||||
|
{
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ZeroconfPlugin::connectPlugin( bool /*startup*/ )
|
ZeroconfPlugin::connectPlugin( bool /*startup*/ )
|
||||||
{
|
{
|
||||||
|
@@ -24,6 +24,7 @@ public:
|
|||||||
|
|
||||||
virtual bool isValid() { return true; }
|
virtual bool isValid() { return true; }
|
||||||
virtual const QString name();
|
virtual const QString name();
|
||||||
|
virtual const QString accountName();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual bool connectPlugin( bool startup );
|
virtual bool connectPlugin( bool startup );
|
||||||
|
@@ -121,6 +121,15 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
|||||||
|
|
||||||
statusBar()->addPermanentWidget( m_audioControls, 1 );
|
statusBar()->addPermanentWidget( m_audioControls, 1 );
|
||||||
|
|
||||||
|
// propagate sip menu
|
||||||
|
foreach(SipPlugin *plugin, APP->sipHandler()->plugins())
|
||||||
|
{
|
||||||
|
if(plugin->menu())
|
||||||
|
{
|
||||||
|
ui->menuNetwork->addMenu(plugin->menu());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
setupSignals();
|
setupSignals();
|
||||||
|
|
||||||
@@ -177,7 +186,6 @@ TomahawkWindow::setupSignals()
|
|||||||
connect( ui->actionPreferences, SIGNAL( triggered() ), SLOT( showSettingsDialog() ) );
|
connect( ui->actionPreferences, SIGNAL( triggered() ), SLOT( showSettingsDialog() ) );
|
||||||
connect( ui->actionToggleConnect, SIGNAL( triggered() ), APP->sipHandler(), SLOT( toggleConnect() ) );
|
connect( ui->actionToggleConnect, SIGNAL( triggered() ), APP->sipHandler(), SLOT( toggleConnect() ) );
|
||||||
connect( ui->actionAddPeerManually, SIGNAL( triggered() ), SLOT( addPeerManually() ) );
|
connect( ui->actionAddPeerManually, SIGNAL( triggered() ), SLOT( addPeerManually() ) );
|
||||||
connect( ui->actionAddFriendManually, SIGNAL( triggered() ), SLOT( addFriendManually() ) );
|
|
||||||
connect( ui->actionRescanCollection, SIGNAL( triggered() ), SLOT( updateCollectionManually() ) );
|
connect( ui->actionRescanCollection, SIGNAL( triggered() ), SLOT( updateCollectionManually() ) );
|
||||||
connect( ui->actionLoadXSPF, SIGNAL( triggered() ), SLOT( loadSpiff() ));
|
connect( ui->actionLoadXSPF, SIGNAL( triggered() ), SLOT( loadSpiff() ));
|
||||||
connect( ui->actionCreatePlaylist, SIGNAL( triggered() ), SLOT( createPlaylist() ));
|
connect( ui->actionCreatePlaylist, SIGNAL( triggered() ), SLOT( createPlaylist() ));
|
||||||
@@ -277,21 +285,6 @@ TomahawkWindow::addPeerManually()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TomahawkWindow::addFriendManually()
|
|
||||||
{
|
|
||||||
bool ok;
|
|
||||||
QString id = QInputDialog::getText( this, tr( "Add Friend" ),
|
|
||||||
tr( "Enter Jabber ID:" ), QLineEdit::Normal,
|
|
||||||
"", &ok );
|
|
||||||
if ( !ok )
|
|
||||||
return;
|
|
||||||
|
|
||||||
qDebug() << "Attempting to add jabber contact to roster:" << id;
|
|
||||||
APP->sipHandler()->addContact( id );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkWindow::loadSpiff()
|
TomahawkWindow::loadSpiff()
|
||||||
{
|
{
|
||||||
|
@@ -52,7 +52,6 @@ private slots:
|
|||||||
void onSipError();
|
void onSipError();
|
||||||
|
|
||||||
void addPeerManually();
|
void addPeerManually();
|
||||||
void addFriendManually();
|
|
||||||
|
|
||||||
void onPlaybackLoading( const Tomahawk::result_ptr& result );
|
void onPlaybackLoading( const Tomahawk::result_ptr& result );
|
||||||
|
|
||||||
|
@@ -69,7 +69,6 @@
|
|||||||
<addaction name="actionToggleConnect"/>
|
<addaction name="actionToggleConnect"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionAddPeerManually"/>
|
<addaction name="actionAddPeerManually"/>
|
||||||
<addaction name="actionAddFriendManually"/>
|
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menu_Help">
|
<widget class="QMenu" name="menu_Help">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
Reference in New Issue
Block a user