mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-07 06:36:55 +02:00
separate more stuff into siphandler/accountmanager
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
#define ACCOUNTDELEGATE_H
|
#define ACCOUNTDELEGATE_H
|
||||||
|
|
||||||
#include "configdelegatebase.h"
|
#include "configdelegatebase.h"
|
||||||
|
#include "accounts/AccountModel.h"
|
||||||
|
|
||||||
namespace Tomahawk
|
namespace Tomahawk
|
||||||
{
|
{
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include "sip/twittersip.h"
|
#include "sip/twittersip.h"
|
||||||
#include "accounts/accountdllmacro.h"
|
#include "accounts/accountdllmacro.h"
|
||||||
#include "accounts/account.h"
|
#include "accounts/Account.h"
|
||||||
|
|
||||||
#define MYNAME "ACCOUNTTWITTER"
|
#define MYNAME "ACCOUNTTWITTER"
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void nowAuthenticated( const QWeakPointer< TomahawkOAuthTwitter >&, const QTweetUser &user );
|
void nowAuthenticated( const QWeakPointer< TomahawkOAuthTwitter >&, const QTweetUser &user );
|
||||||
void nowDeauthenticated();
|
void nowDeauthenticated();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void configDialogAuthedSignalSlot( bool authed );
|
void configDialogAuthedSignalSlot( bool authed );
|
||||||
void connectAuthVerifyReply( const QTweetUser &user );
|
void connectAuthVerifyReply( const QTweetUser &user );
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "sip/xmppsip.h"
|
#include "sip/xmppsip.h"
|
||||||
#include "accounts/accountdllmacro.h"
|
#include "accounts/accountdllmacro.h"
|
||||||
#include "accounts/account.h"
|
#include "accounts/Account.h"
|
||||||
|
|
||||||
#define MYNAME "ACCOUNTJABBER"
|
#define MYNAME "ACCOUNTJABBER"
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ namespace Tomahawk
|
|||||||
|
|
||||||
namespace Accounts
|
namespace Accounts
|
||||||
{
|
{
|
||||||
|
|
||||||
class ACCOUNTDLLEXPORT XmppAccountFactory : public AccountFactory
|
class ACCOUNTDLLEXPORT XmppAccountFactory : public AccountFactory
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -70,7 +70,7 @@ public:
|
|||||||
QWidget* aclWidget() { return 0; }
|
QWidget* aclWidget() { return 0; }
|
||||||
|
|
||||||
void refreshProxy() {};
|
void refreshProxy() {};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui_XmppConfigWidget* m_ui; // so the google wrapper can change the config dialog a bit
|
Ui_XmppConfigWidget* m_ui; // so the google wrapper can change the config dialog a bit
|
||||||
bool m_isAuthenticated;
|
bool m_isAuthenticated;
|
||||||
|
@@ -55,14 +55,6 @@ Account::icon() const
|
|||||||
return QIcon();
|
return QIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
Account::canSelfAuthenticate() const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Account::authenticate()
|
Account::authenticate()
|
||||||
{
|
{
|
||||||
@@ -88,4 +80,23 @@ void
|
|||||||
Account::refreshProxy()
|
Account::refreshProxy()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Account::onError(int errorCode, const QString& error )
|
||||||
|
{
|
||||||
|
QMutexLocker locker( &m_mutex );
|
||||||
|
m_cachedError = error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Account::onConnectionStateChanged( Account::ConnectionState )
|
||||||
|
{
|
||||||
|
m_cachedError.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -79,8 +79,6 @@ public:
|
|||||||
|
|
||||||
virtual QIcon icon() const = 0;
|
virtual QIcon icon() const = 0;
|
||||||
|
|
||||||
virtual void authenticate() = 0;
|
|
||||||
virtual void deauthenticate() = 0;
|
|
||||||
virtual ConnectionState connectionState() = 0;
|
virtual ConnectionState connectionState() = 0;
|
||||||
virtual bool isAuthenticated() const = 0;
|
virtual bool isAuthenticated() const = 0;
|
||||||
|
|
||||||
@@ -134,6 +132,10 @@ public:
|
|||||||
|
|
||||||
virtual void sync() { QMutexLocker locker( &m_mutex ); syncConfig(); };
|
virtual void sync() { QMutexLocker locker( &m_mutex ); syncConfig(); };
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
virtual void authenticate() = 0;
|
||||||
|
virtual void deauthenticate() = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void error( int errorId, const QString& errorStr );
|
void error( int errorId, const QString& errorStr );
|
||||||
void connectionStateChanged( Tomahawk::Accounts::Account::ConnectionState state );
|
void connectionStateChanged( Tomahawk::Accounts::Account::ConnectionState state );
|
||||||
@@ -174,7 +176,7 @@ protected:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onConnectionStateChanged( Tomahawk::Accounts::Account::ConnectionState );
|
void onConnectionStateChanged( Tomahawk::Accounts::Account::ConnectionState );
|
||||||
void onError( int,QString );
|
void onError( int, const QString& );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_accountServiceName;
|
QString m_accountServiceName;
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -18,11 +19,14 @@
|
|||||||
|
|
||||||
#include "AccountManager.h"
|
#include "AccountManager.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "sourcelist.h"
|
||||||
|
|
||||||
#include <QtCore/QLibrary>
|
#include <QtCore/QLibrary>
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
#include <QtCore/QPluginLoader>
|
#include <QtCore/QPluginLoader>
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <sip/SipHandler.h>
|
||||||
|
|
||||||
namespace Tomahawk
|
namespace Tomahawk
|
||||||
{
|
{
|
||||||
@@ -63,7 +67,7 @@ AccountManager::findPluginFactories()
|
|||||||
QList< QDir > pluginDirs;
|
QList< QDir > pluginDirs;
|
||||||
|
|
||||||
QDir appDir( qApp->applicationDirPath() );
|
QDir appDir( qApp->applicationDirPath() );
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
if ( appDir.dirName() == "MacOS" )
|
if ( appDir.dirName() == "MacOS" )
|
||||||
{
|
{
|
||||||
// Development convenience-hack
|
// Development convenience-hack
|
||||||
@@ -71,7 +75,7 @@ AccountManager::findPluginFactories()
|
|||||||
appDir.cdUp();
|
appDir.cdUp();
|
||||||
appDir.cdUp();
|
appDir.cdUp();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QDir libDir( CMAKE_INSTALL_PREFIX "/lib" );
|
QDir libDir( CMAKE_INSTALL_PREFIX "/lib" );
|
||||||
|
|
||||||
@@ -141,19 +145,46 @@ AccountManager::loadPluginFactory( const QString& path )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AccountManager::connectAll()
|
||||||
|
{
|
||||||
|
foreach( Account* acc, m_accounts )
|
||||||
|
{
|
||||||
|
if ( acc->types().contains( Accounts::SipType ) && acc->sipPlugin() )
|
||||||
|
acc->sipPlugin()->connectPlugin();
|
||||||
|
|
||||||
|
}
|
||||||
|
m_connected = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AccountManager::disconnectAll()
|
||||||
|
{
|
||||||
|
foreach( Account* acc, m_connectedAccounts )
|
||||||
|
acc->sipPlugin()->disconnectPlugin();
|
||||||
|
|
||||||
|
SourceList::instance()->removeAllRemote();
|
||||||
|
m_connected = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AccountManager::toggleAccountsConnected()
|
||||||
|
{
|
||||||
|
if ( m_connected )
|
||||||
|
disconnectAll();
|
||||||
|
else
|
||||||
|
connectAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AccountManager::loadFromConfig()
|
AccountManager::loadFromConfig()
|
||||||
{
|
{
|
||||||
QStringList accountIds = TomahawkSettings::instance()->accounts();
|
QStringList accountIds = TomahawkSettings::instance()->accounts();
|
||||||
|
|
||||||
//FIXME: this is just for debugging
|
|
||||||
if ( accountIds.isEmpty() )
|
|
||||||
{
|
|
||||||
Account* account = m_accountFactories[ "twitteraccount" ]->createAccount();
|
|
||||||
addAccountPlugin( account );
|
|
||||||
TomahawkSettings::instance()->addAccount( account->accountId() );
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach( const QString& accountId, accountIds )
|
foreach( const QString& accountId, accountIds )
|
||||||
{
|
{
|
||||||
QString pluginFactory = factoryFromId( accountId );
|
QString pluginFactory = factoryFromId( accountId );
|
||||||
@@ -165,6 +196,18 @@ AccountManager::loadFromConfig()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AccountManager::initSIP()
|
||||||
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO;
|
||||||
|
foreach( Account* account, accounts( Tomahawk::Accounts::SipType ) )
|
||||||
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO << "adding plugin " << account->accountId();
|
||||||
|
SipPlugin* p = account->sipPlugin();
|
||||||
|
SipHandler::instance()->hookUpPlugin( p );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Account*
|
Account*
|
||||||
@@ -175,8 +218,8 @@ AccountManager::loadPlugin( const QString& accountId )
|
|||||||
Q_ASSERT( m_accountFactories.contains( factoryName ) );
|
Q_ASSERT( m_accountFactories.contains( factoryName ) );
|
||||||
|
|
||||||
Account* account = m_accountFactories[ factoryName ]->createAccount( accountId );
|
Account* account = m_accountFactories[ factoryName ]->createAccount( accountId );
|
||||||
|
hookupAccount( account );
|
||||||
|
|
||||||
// caller responsible for calling pluginAdded() and hookupPlugin
|
|
||||||
return account;
|
return account;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,7 +232,66 @@ AccountManager::addAccountPlugin( Account* account )
|
|||||||
foreach( AccountType type, account->types() )
|
foreach( AccountType type, account->types() )
|
||||||
m_accountsByAccountType[ type ].append( account );
|
m_accountsByAccountType[ type ].append( account );
|
||||||
|
|
||||||
emit accountAdded( account );
|
emit added( account );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AccountManager::hookupAccount( Account* account ) const
|
||||||
|
{
|
||||||
|
connect( account, SIGNAL( error( int, QString ) ), SLOT( onError( int, QString ) ) );
|
||||||
|
connect( account, SIGNAL( stateChanged( SipPlugin::ConnectionState ) ), SLOT( onStateChanged( Accounts::Account::ConnectionState ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AccountManager::onError( int code, const QString& msg )
|
||||||
|
{
|
||||||
|
Account* account = qobject_cast< Account* >( sender() );
|
||||||
|
Q_ASSERT( account );
|
||||||
|
|
||||||
|
|
||||||
|
qWarning() << "Failed to connect to SIP:" << account->accountFriendlyName() << code << msg;
|
||||||
|
|
||||||
|
if ( code == Account::AuthError )
|
||||||
|
{
|
||||||
|
emit authError( account );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QTimer::singleShot( 10000, account, SLOT( authenticate() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AccountManager::onSettingsChanged()
|
||||||
|
{
|
||||||
|
foreach( Account* account, m_accounts )
|
||||||
|
{
|
||||||
|
if ( account->types().contains( Accounts::SipType ) && account->sipPlugin() )
|
||||||
|
account->sipPlugin()->checkSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AccountManager::onStateChanged( Account::ConnectionState state )
|
||||||
|
{
|
||||||
|
Account* account = qobject_cast< Account* >( sender() );
|
||||||
|
Q_ASSERT( account );
|
||||||
|
|
||||||
|
if ( account->connectionState() == Account::Disconnected )
|
||||||
|
{
|
||||||
|
m_connectedAccounts.removeAll( account );
|
||||||
|
emit disconnected( account );
|
||||||
|
}
|
||||||
|
else if ( account->connectionState() == Account::Connected )
|
||||||
|
{
|
||||||
|
m_connectedAccounts << account;
|
||||||
|
emit connected( account );
|
||||||
|
}
|
||||||
|
|
||||||
|
emit stateChanged( account, state );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -47,6 +48,8 @@ public:
|
|||||||
void loadPluginFactories( const QStringList &paths );
|
void loadPluginFactories( const QStringList &paths );
|
||||||
|
|
||||||
void loadFromConfig();
|
void loadFromConfig();
|
||||||
|
void initSIP();
|
||||||
|
|
||||||
void loadPluginFactory( const QString &path );
|
void loadPluginFactory( const QString &path );
|
||||||
void addAccountPlugin( Account* account );
|
void addAccountPlugin( Account* account );
|
||||||
Account* loadPlugin( const QString &accountId );
|
Account* loadPlugin( const QString &accountId );
|
||||||
@@ -58,12 +61,26 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void connectAll();
|
void connectAll();
|
||||||
void disconnectAll();
|
void disconnectAll();
|
||||||
|
void toggleAccountsConnected();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void accountAdded( Tomahawk::Accounts::Account* );
|
void added( Tomahawk::Accounts::Account* );
|
||||||
void accountRemoved( Tomahawk::Accounts::Account* );
|
void removed( Tomahawk::Accounts::Account* );
|
||||||
|
|
||||||
|
void connected( Tomahawk::Accounts::Account* );
|
||||||
|
void disconnected( Tomahawk::Accounts::Account* );
|
||||||
|
void authError( Tomahawk::Accounts::Account* );
|
||||||
|
|
||||||
|
void stateChanged( Account* p, Accounts::Account::ConnectionState state );
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onStateChanged( Accounts::Account::ConnectionState state );
|
||||||
|
void onError( int code, const QString& msg );
|
||||||
|
|
||||||
|
void onSettingsChanged();
|
||||||
private:
|
private:
|
||||||
|
void hookupAccount( Account* ) const;
|
||||||
|
|
||||||
QList< Account* > m_accounts;
|
QList< Account* > m_accounts;
|
||||||
QList< Account* > m_enabledAccounts;
|
QList< Account* > m_enabledAccounts;
|
||||||
QList< Account* > m_connectedAccounts;
|
QList< Account* > m_connectedAccounts;
|
||||||
|
@@ -30,8 +30,8 @@ using namespace Accounts;
|
|||||||
AccountModel::AccountModel( QObject* parent )
|
AccountModel::AccountModel( QObject* parent )
|
||||||
: QAbstractListModel( parent )
|
: QAbstractListModel( parent )
|
||||||
{
|
{
|
||||||
connect( AccountManager::instance(), SIGNAL( accountAdded( Tomahawk::Accounts::Account* ) ), this, SLOT( accountAdded( Tomahawk::Accounts::Account* ) ) );
|
connect( AccountManager::instance(), SIGNAL( added( Tomahawk::Accounts::Account* ) ), this, SLOT( accountAdded( Tomahawk::Accounts::Account* ) ) );
|
||||||
connect( AccountManager::instance(), SIGNAL( accountRemoved( Tomahawk::Accounts::Account* ) ), this, SLOT( accountRemoved( Tomahawk::Accounts::Account* ) ) );
|
connect( AccountManager::instance(), SIGNAL( removed( Tomahawk::Accounts::Account* ) ), this, SLOT( accountRemoved( Tomahawk::Accounts::Account* ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ AccountModel::setData( const QModelIndex& index, const QVariant& value, int role
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
AccountModel::rowCount( const QModelIndex& parent ) const
|
AccountModel::rowCount( const QModelIndex& ) const
|
||||||
{
|
{
|
||||||
return AccountManager::instance()->accounts().size();
|
return AccountManager::instance()->accounts().size();
|
||||||
}
|
}
|
||||||
@@ -113,8 +113,7 @@ AccountModel::flags( const QModelIndex& index ) const
|
|||||||
void
|
void
|
||||||
AccountModel::accountAdded( Account* account )
|
AccountModel::accountAdded( Account* account )
|
||||||
{
|
{
|
||||||
Q_UNUSED( p );
|
// TODO HACK we assume account plugins are added at the end of the list.
|
||||||
// we assume account plugins are added at the end of the list.
|
|
||||||
Q_ASSERT( AccountManager::instance()->accounts().last() == account );
|
Q_ASSERT( AccountManager::instance()->accounts().last() == account );
|
||||||
if ( account->types().contains( SipType ) )
|
if ( account->types().contains( SipType ) )
|
||||||
connect( account, SIGNAL( connectionStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ), this, SLOT( accountStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ) );
|
connect( account, SIGNAL( connectionStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ), this, SLOT( accountStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ) );
|
||||||
@@ -128,17 +127,17 @@ AccountModel::accountAdded( Account* account )
|
|||||||
void
|
void
|
||||||
AccountModel::accountRemoved( Account* account )
|
AccountModel::accountRemoved( Account* account )
|
||||||
{
|
{
|
||||||
int idx = AccountManager::instance()->allPlugins().indexOf( account );
|
int idx = AccountManager::instance()->accounts().indexOf( account );
|
||||||
beginRemoveRows( QModelIndex(), idx, idx );
|
beginRemoveRows( QModelIndex(), idx, idx );
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AccountModel::accountStateChanged( Tomahawk::Accounts::Account::ConnectionState state )
|
AccountModel::accountStateChanged( Tomahawk::Accounts::Account::ConnectionState )
|
||||||
{
|
{
|
||||||
Account* account = qobject_cast< Account* >( sender() );
|
Account* account = qobject_cast< Account* >( sender() );
|
||||||
Q_ASSERT( a );
|
Q_ASSERT( account );
|
||||||
|
|
||||||
for ( int i = 0; i < AccountManager::instance()->accounts().size(); i++ )
|
for ( int i = 0; i < AccountManager::instance()->accounts().size(); i++ )
|
||||||
{
|
{
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
#include "sip/SipPlugin.h"
|
#include "sip/SipPlugin.h"
|
||||||
|
|
||||||
|
#include <QAbstractListModel>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
@@ -52,7 +52,6 @@ SipHandler::instance()
|
|||||||
|
|
||||||
SipHandler::SipHandler( QObject* parent )
|
SipHandler::SipHandler( QObject* parent )
|
||||||
: QObject( parent )
|
: QObject( parent )
|
||||||
, m_connected( false )
|
|
||||||
{
|
{
|
||||||
s_instance = this;
|
s_instance = this;
|
||||||
|
|
||||||
@@ -97,13 +96,6 @@ SipHandler::versionString( const QString& peerId ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SipHandler::onSettingsChanged()
|
|
||||||
{
|
|
||||||
checkSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SipHandler::hookUpPlugin( SipPlugin* sip )
|
SipHandler::hookUpPlugin( SipPlugin* sip )
|
||||||
{
|
{
|
||||||
@@ -113,164 +105,13 @@ SipHandler::hookUpPlugin( SipPlugin* sip )
|
|||||||
QObject::connect( sip, SIGNAL( sipInfoReceived( QString, SipInfo ) ), SLOT( onSipInfo( QString, SipInfo ) ) );
|
QObject::connect( sip, SIGNAL( sipInfoReceived( QString, SipInfo ) ), SLOT( onSipInfo( QString, SipInfo ) ) );
|
||||||
QObject::connect( sip, SIGNAL( softwareVersionReceived( QString, QString ) ), SLOT( onSoftwareVersion( QString, QString ) ) );
|
QObject::connect( sip, SIGNAL( softwareVersionReceived( QString, QString ) ), SLOT( onSoftwareVersion( QString, QString ) ) );
|
||||||
|
|
||||||
QObject::connect( sip, SIGNAL( error( int, QString ) ), SLOT( onError( int, QString ) ) );
|
|
||||||
QObject::connect( sip, SIGNAL( stateChanged( SipPlugin::ConnectionState ) ), SLOT( onStateChanged( SipPlugin::ConnectionState ) ) );
|
|
||||||
|
|
||||||
QObject::connect( sip, SIGNAL( avatarReceived( QString, QPixmap ) ), SLOT( onAvatarReceived( QString, QPixmap ) ) );
|
QObject::connect( sip, SIGNAL( avatarReceived( QString, QPixmap ) ), SLOT( onAvatarReceived( QString, QPixmap ) ) );
|
||||||
QObject::connect( sip, SIGNAL( avatarReceived( QPixmap ) ), SLOT( onAvatarReceived( QPixmap ) ) );
|
QObject::connect( sip, SIGNAL( avatarReceived( QPixmap ) ), SLOT( onAvatarReceived( QPixmap ) ) );
|
||||||
|
|
||||||
QObject::connect( sip->account(), SIGNAL( configurationChanged() ), sip, SLOT( configurationChanged() ) );
|
QObject::connect( sip->account(), SIGNAL( configurationChanged() ), sip, SLOT( configurationChanged() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
bool
|
|
||||||
SipHandler::pluginLoaded( const QString& pluginId ) const
|
|
||||||
{
|
|
||||||
foreach( SipPlugin* plugin, m_allPlugins )
|
|
||||||
{
|
|
||||||
if ( plugin->pluginId() == pluginId )
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SipHandler::checkSettings()
|
|
||||||
{
|
|
||||||
foreach( SipPlugin* sip, m_allPlugins )
|
|
||||||
{
|
|
||||||
sip->checkSettings();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SipHandler::addSipPlugin( SipPlugin* p )
|
|
||||||
{
|
|
||||||
m_allPlugins << p;
|
|
||||||
|
|
||||||
hookUpPlugin( p );
|
|
||||||
p->connectPlugin();
|
|
||||||
|
|
||||||
emit pluginAdded( p );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SipHandler::removeSipPlugin( SipPlugin* p )
|
|
||||||
{
|
|
||||||
p->disconnectPlugin();
|
|
||||||
|
|
||||||
emit pluginRemoved( p );
|
|
||||||
|
|
||||||
m_allPlugins.removeAll( p );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SipHandler::loadFromAccountManager()
|
|
||||||
{
|
|
||||||
tDebug() << Q_FUNC_INFO;
|
|
||||||
QList< Tomahawk::Accounts::Account* > accountList = Tomahawk::Accounts::AccountManager::instance()->accounts( Tomahawk::Accounts::SipType );
|
|
||||||
foreach( Tomahawk::Accounts::Account* account, accountList )
|
|
||||||
{
|
|
||||||
tDebug() << Q_FUNC_INFO << "adding plugin " << account->accountId();
|
|
||||||
SipPlugin* p = account->sipPlugin();
|
|
||||||
addSipPlugin( p );
|
|
||||||
}
|
|
||||||
m_connected = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SipHandler::connectAll()
|
|
||||||
{
|
|
||||||
foreach( SipPlugin* sip, m_allPlugins )
|
|
||||||
{
|
|
||||||
sip->connectPlugin();
|
|
||||||
}
|
|
||||||
m_connected = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SipHandler::disconnectAll()
|
|
||||||
{
|
|
||||||
foreach( SipPlugin* p, m_connectedPlugins )
|
|
||||||
p->disconnectPlugin();
|
|
||||||
|
|
||||||
SourceList::instance()->removeAllRemote();
|
|
||||||
m_connected = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SipHandler::connectPlugin( const QString &pluginId )
|
|
||||||
{
|
|
||||||
#ifndef TOMAHAWK_HEADLESS
|
|
||||||
if ( !TomahawkSettings::instance()->acceptedLegalWarning() )
|
|
||||||
{
|
|
||||||
int result = QMessageBox::question(
|
|
||||||
//TomahawkApp::instance()->mainWindow(),
|
|
||||||
0, tr( "Legal Warning" ),
|
|
||||||
tr( "By pressing OK below, you agree that your use of Tomahawk will be in accordance with any applicable laws, including copyright and intellectual property laws, in effect in your country of residence, and indemnify the Tomahawk developers and project from liability should you choose to break those laws.\n\nFor more information, please see http://gettomahawk.com/legal" ),
|
|
||||||
tr( "I Do Not Agree" ), tr( "I Agree" )
|
|
||||||
);
|
|
||||||
if ( result != 1 )
|
|
||||||
return;
|
|
||||||
else
|
|
||||||
TomahawkSettings::instance()->setAcceptedLegalWarning( true );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
foreach( SipPlugin* sip, m_allPlugins )
|
|
||||||
{
|
|
||||||
if ( sip->pluginId() == pluginId )
|
|
||||||
{
|
|
||||||
Q_ASSERT( m_allPlugins.contains( sip ) ); // make sure the plugin we're connecting is enabled. should always be the case
|
|
||||||
//each sip should refreshProxy() or take care of that function in some other way during connection
|
|
||||||
sip->connectPlugin();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SipHandler::disconnectPlugin( const QString &pluginName )
|
|
||||||
{
|
|
||||||
foreach( SipPlugin* sip, m_connectedPlugins )
|
|
||||||
{
|
|
||||||
if ( sip->account()->accountId() == pluginName )
|
|
||||||
sip->disconnectPlugin();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QList< SipPlugin* >
|
|
||||||
SipHandler::allPlugins() const
|
|
||||||
{
|
|
||||||
return m_allPlugins;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QList< SipPlugin* >
|
|
||||||
SipHandler::connectedPlugins() const
|
|
||||||
{
|
|
||||||
return m_connectedPlugins;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SipHandler::toggleConnect()
|
|
||||||
{
|
|
||||||
if( m_connected )
|
|
||||||
disconnectAll();
|
|
||||||
else
|
|
||||||
connectAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SipHandler::refreshProxy()
|
SipHandler::refreshProxy()
|
||||||
{
|
{
|
||||||
@@ -278,7 +119,7 @@ SipHandler::refreshProxy()
|
|||||||
|
|
||||||
foreach( SipPlugin* sip, m_allPlugins )
|
foreach( SipPlugin* sip, m_allPlugins )
|
||||||
sip->refreshProxy();
|
sip->refreshProxy();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -381,47 +222,6 @@ SipHandler::onMessage( const QString& from, const QString& msg )
|
|||||||
qDebug() << Q_FUNC_INFO << from << msg;
|
qDebug() << Q_FUNC_INFO << from << msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SipHandler::onError( int code, const QString& msg )
|
|
||||||
{
|
|
||||||
SipPlugin* sip = qobject_cast< SipPlugin* >( sender() );
|
|
||||||
Q_ASSERT( sip );
|
|
||||||
|
|
||||||
qWarning() << "Failed to connect to SIP:" << sip->account()->accountFriendlyName() << code << msg;
|
|
||||||
|
|
||||||
if ( code == SipPlugin::AuthError )
|
|
||||||
{
|
|
||||||
emit authError( sip );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QTimer::singleShot( 10000, sip, SLOT( connectPlugin() ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SipHandler::onStateChanged( SipPlugin::ConnectionState state )
|
|
||||||
{
|
|
||||||
SipPlugin* sip = qobject_cast< SipPlugin* >( sender() );
|
|
||||||
Q_ASSERT( sip );
|
|
||||||
|
|
||||||
if ( sip->connectionState() == SipPlugin::Disconnected )
|
|
||||||
{
|
|
||||||
m_connectedPlugins.removeAll( sip );
|
|
||||||
emit disconnected( sip );
|
|
||||||
}
|
|
||||||
else if ( sip->connectionState() == SipPlugin::Connected )
|
|
||||||
{
|
|
||||||
m_connectedPlugins << sip;
|
|
||||||
emit connected( sip );
|
|
||||||
}
|
|
||||||
|
|
||||||
emit stateChanged( sip, state );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SipHandler::onAvatarReceived( const QString& from, const QPixmap& avatar )
|
SipHandler::onAvatarReceived( const QString& from, const QPixmap& avatar )
|
||||||
{
|
{
|
||||||
|
@@ -31,8 +31,12 @@
|
|||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manages SIP plugins for connecting to friends. External interface to SIP plugins is
|
||||||
|
* through AccountManager, this is an internal class.
|
||||||
|
*/
|
||||||
|
|
||||||
class DLLEXPORT SipHandler : public QObject
|
class SipHandler : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -42,13 +46,8 @@ public:
|
|||||||
SipHandler( QObject* parent );
|
SipHandler( QObject* parent );
|
||||||
~SipHandler();
|
~SipHandler();
|
||||||
|
|
||||||
QList< SipPlugin* > allPlugins() const;
|
|
||||||
QList< SipPlugin* > connectedPlugins() const;
|
|
||||||
void loadFromAccountManager();
|
void loadFromAccountManager();
|
||||||
|
|
||||||
void addSipPlugin( SipPlugin* p );
|
|
||||||
void removeSipPlugin( SipPlugin* p );
|
|
||||||
|
|
||||||
bool hasPluginType( const QString& factoryId ) const;
|
bool hasPluginType( const QString& factoryId ) const;
|
||||||
|
|
||||||
const QPixmap avatar( const QString& name ) const;
|
const QPixmap avatar( const QString& name ) const;
|
||||||
@@ -56,25 +55,11 @@ public:
|
|||||||
const SipInfo sipInfo( const QString& peerId ) const;
|
const SipInfo sipInfo( const QString& peerId ) const;
|
||||||
const QString versionString( const QString& peerId ) const;
|
const QString versionString( const QString& peerId ) const;
|
||||||
|
|
||||||
|
void hookUpPlugin( SipPlugin* p );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void checkSettings();
|
// TODO no longer called from anywhere... can we remove it?
|
||||||
|
// void refreshProxy();
|
||||||
void connectPlugin( const QString &pluginId = QString() );
|
|
||||||
void disconnectPlugin( const QString &pluginId = QString() );
|
|
||||||
|
|
||||||
void toggleConnect();
|
|
||||||
|
|
||||||
void refreshProxy();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void connected( SipPlugin* );
|
|
||||||
void disconnected( SipPlugin* );
|
|
||||||
void authError( SipPlugin* );
|
|
||||||
|
|
||||||
void stateChanged( SipPlugin* p, SipPlugin::ConnectionState state );
|
|
||||||
|
|
||||||
void pluginAdded( SipPlugin* p );
|
|
||||||
void pluginRemoved( SipPlugin* p );
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onSipInfo( const QString& peerId, const SipInfo& info );
|
void onSipInfo( const QString& peerId, const SipInfo& info );
|
||||||
@@ -82,10 +67,6 @@ private slots:
|
|||||||
void onMessage( const QString&, const QString& );
|
void onMessage( const QString&, const QString& );
|
||||||
void onPeerOffline( const QString& );
|
void onPeerOffline( const QString& );
|
||||||
void onPeerOnline( const QString& );
|
void onPeerOnline( const QString& );
|
||||||
void onError( int code, const QString& msg );
|
|
||||||
void onStateChanged( SipPlugin::ConnectionState );
|
|
||||||
|
|
||||||
void onSettingsChanged();
|
|
||||||
|
|
||||||
// set data for local source
|
// set data for local source
|
||||||
void onAvatarReceived( const QPixmap& avatar );
|
void onAvatarReceived( const QPixmap& avatar );
|
||||||
@@ -96,14 +77,6 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
static SipHandler *s_instance;
|
static SipHandler *s_instance;
|
||||||
|
|
||||||
QStringList findPluginFactories();
|
|
||||||
bool pluginLoaded( const QString& pluginId ) const;
|
|
||||||
void hookUpPlugin( SipPlugin* p );
|
|
||||||
|
|
||||||
void loadPluginFactories( const QStringList& paths );
|
|
||||||
void loadPluginFactory( const QString& path );
|
|
||||||
QString factoryFromId( const QString& pluginId ) const;
|
|
||||||
|
|
||||||
//TODO: move this to source
|
//TODO: move this to source
|
||||||
QHash<QString, SipInfo> m_peersSipInfos;
|
QHash<QString, SipInfo> m_peersSipInfos;
|
||||||
QHash<QString, QPixmap> m_usernameAvatars;
|
QHash<QString, QPixmap> m_usernameAvatars;
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
* 2011, Dominik Schmidt <dev@dominik-schmidt.de>
|
* 2011, Dominik Schmidt <dev@dominik-schmidt.de>
|
||||||
|
* 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -67,13 +68,6 @@ SipPlugin::account() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
|
||||||
SipPlugin::errorMessage() const
|
|
||||||
{
|
|
||||||
return m_cachedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QIcon
|
QIcon
|
||||||
SipPlugin::icon() const
|
SipPlugin::icon() const
|
||||||
{
|
{
|
||||||
@@ -95,22 +89,6 @@ SipPlugin::refreshProxy()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SipPlugin::onError( int code, const QString& error )
|
|
||||||
{
|
|
||||||
Q_UNUSED( code );
|
|
||||||
m_cachedError = error;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SipPlugin::onStateChange( SipPlugin::ConnectionState state )
|
|
||||||
{
|
|
||||||
Q_UNUSED( state );
|
|
||||||
m_cachedError.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SipPlugin::onPeerOnline( const QString& peerId )
|
SipPlugin::onPeerOnline( const QString& peerId )
|
||||||
{
|
{
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
* 2011, Dominik Schmidt <dev@dominik-schmidt.de>
|
* 2011, Dominik Schmidt <dev@dominik-schmidt.de>
|
||||||
|
* 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -35,7 +35,7 @@
|
|||||||
#include "album.h"
|
#include "album.h"
|
||||||
#include "collection.h"
|
#include "collection.h"
|
||||||
#include "infosystem/infosystem.h"
|
#include "infosystem/infosystem.h"
|
||||||
#include "accounts/accountmanager.h"
|
#include "accounts/AccountManager.h"
|
||||||
#include "database/database.h"
|
#include "database/database.h"
|
||||||
#include "database/databasecollection.h"
|
#include "database/databasecollection.h"
|
||||||
#include "database/databasecommand_collectionstats.h"
|
#include "database/databasecommand_collectionstats.h"
|
||||||
@@ -505,16 +505,6 @@ void
|
|||||||
TomahawkApp::initSIP()
|
TomahawkApp::initSIP()
|
||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO;
|
tDebug() << Q_FUNC_INFO;
|
||||||
// TODO debugging hack only
|
|
||||||
foreach ( Tomahawk::Accounts::Account* account, Tomahawk::Accounts::AccountManager::instance()->accounts() )
|
|
||||||
{
|
|
||||||
tDebug() << Q_FUNC_INFO << "testing account with name " << account->accountServiceName();
|
|
||||||
if ( account->configurationWidget() && account->configuration().isEmpty() )
|
|
||||||
account->configurationWidget()->show();
|
|
||||||
if ( !account->enabled() )
|
|
||||||
account->setEnabled( true );
|
|
||||||
}
|
|
||||||
|
|
||||||
//FIXME: jabber autoconnect is really more, now that there is sip -- should be renamed and/or split out of jabber-specific settings
|
//FIXME: jabber autoconnect is really more, now that there is sip -- should be renamed and/or split out of jabber-specific settings
|
||||||
if ( !arguments().contains( "--nosip" ) )
|
if ( !arguments().contains( "--nosip" ) )
|
||||||
{
|
{
|
||||||
@@ -523,7 +513,7 @@ TomahawkApp::initSIP()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
tDebug( LOGINFO ) << "Connecting SIP classes";
|
tDebug( LOGINFO ) << "Connecting SIP classes";
|
||||||
SipHandler::instance()->loadFromAccountManager();
|
Accounts::AccountManager::instance()->loadFromConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -39,7 +39,7 @@
|
|||||||
#include "artist.h"
|
#include "artist.h"
|
||||||
#include "audio/audioengine.h"
|
#include "audio/audioengine.h"
|
||||||
#include "viewmanager.h"
|
#include "viewmanager.h"
|
||||||
#include "sip/SipHandler.h"
|
#include "accounts/AccountManager.h"
|
||||||
#include "sourcetree/sourcetreeview.h"
|
#include "sourcetree/sourcetreeview.h"
|
||||||
#include "network/servent.h"
|
#include "network/servent.h"
|
||||||
#include "utils/proxystyle.h"
|
#include "utils/proxystyle.h"
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
#include <actioncollection.h>
|
#include <actioncollection.h>
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
using namespace Accounts;
|
||||||
|
|
||||||
TomahawkWindow::TomahawkWindow( QWidget* parent )
|
TomahawkWindow::TomahawkWindow( QWidget* parent )
|
||||||
: QMainWindow( parent )
|
: QMainWindow( parent )
|
||||||
@@ -106,12 +106,12 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
|||||||
ui->menu_Help->addSeparator();
|
ui->menu_Help->addSeparator();
|
||||||
ui->menu_Help->addAction( "Crash now...", this, SLOT( crashNow() ) );
|
ui->menu_Help->addAction( "Crash now...", this, SLOT( crashNow() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->menuApp->insertAction( ui->actionCreatePlaylist, ActionCollection::instance()->getAction( "togglePrivacy" ) );
|
ui->menuApp->insertAction( ui->actionCreatePlaylist, ActionCollection::instance()->getAction( "togglePrivacy" ) );
|
||||||
ui->menuApp->insertSeparator( ui->actionCreatePlaylist );
|
ui->menuApp->insertSeparator( ui->actionCreatePlaylist );
|
||||||
|
|
||||||
// set initial state
|
// set initial state
|
||||||
onSipDisconnected();
|
onAccountDisconnected();
|
||||||
vm->setQueue( m_queueView );
|
vm->setQueue( m_queueView );
|
||||||
vm->showWelcomePage();
|
vm->showWelcomePage();
|
||||||
}
|
}
|
||||||
@@ -306,7 +306,7 @@ TomahawkWindow::setupSignals()
|
|||||||
// connect( ui->actionAddPeerManually, SIGNAL( triggered() ), SLOT( addPeerManually() ) );
|
// connect( ui->actionAddPeerManually, SIGNAL( triggered() ), SLOT( addPeerManually() ) );
|
||||||
connect( ui->actionPreferences, SIGNAL( triggered() ), SLOT( showSettingsDialog() ) );
|
connect( ui->actionPreferences, SIGNAL( triggered() ), SLOT( showSettingsDialog() ) );
|
||||||
connect( ui->actionDiagnostics, SIGNAL( triggered() ), SLOT( showDiagnosticsDialog() ) );
|
connect( ui->actionDiagnostics, SIGNAL( triggered() ), SLOT( showDiagnosticsDialog() ) );
|
||||||
connect( ui->actionToggleConnect, SIGNAL( triggered() ), SipHandler::instance(), SLOT( toggleConnect() ) );
|
connect( ui->actionToggleConnect, SIGNAL( triggered() ), AccountManager::instance(), SLOT( toggleAccountsConnected() ) );
|
||||||
connect( ui->actionUpdateCollection, SIGNAL( triggered() ), SLOT( updateCollectionManually() ) );
|
connect( ui->actionUpdateCollection, SIGNAL( triggered() ), SLOT( updateCollectionManually() ) );
|
||||||
connect( ui->actionRescanCollection, SIGNAL( triggered() ), SLOT( rescanCollectionManually() ) );
|
connect( ui->actionRescanCollection, SIGNAL( triggered() ), SLOT( rescanCollectionManually() ) );
|
||||||
connect( ui->actionLoadXSPF, SIGNAL( triggered() ), SLOT( loadSpiff() ));
|
connect( ui->actionLoadXSPF, SIGNAL( triggered() ), SLOT( loadSpiff() ));
|
||||||
@@ -328,18 +328,20 @@ TomahawkWindow::setupSignals()
|
|||||||
ui->menuWindow->menuAction()->setVisible( false );
|
ui->menuWindow->menuAction()->setVisible( false );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// <SipHandler>
|
// <AccountHandler>
|
||||||
connect( SipHandler::instance(), SIGNAL( connected( SipPlugin* ) ), SLOT( onSipConnected() ) );
|
connect( AccountManager::instance(), SIGNAL( connected( Tomahawk::Accounts::Account* ) ), SLOT( onAccountConnected() ) );
|
||||||
connect( SipHandler::instance(), SIGNAL( disconnected( SipPlugin* ) ), SLOT( onSipDisconnected() ) );
|
connect( AccountManager::instance(), SIGNAL( disconnected( Tomahawk::Accounts::Account* ) ), SLOT( onAccountDisconnected() ) );
|
||||||
connect( SipHandler::instance(), SIGNAL( authError( SipPlugin* ) ), SLOT( onSipError() ) );
|
connect( AccountManager::instance(), SIGNAL( authError( Tomahawk::Accounts::Account* ) ), SLOT( onAccountError() ) );
|
||||||
|
|
||||||
// <SipMenu>
|
// Menus for accounts that support them
|
||||||
connect( SipHandler::instance(), SIGNAL( pluginAdded( SipPlugin* ) ), this, SLOT( onSipPluginAdded( SipPlugin* ) ) );
|
connect( AccountManager::instance(), SIGNAL( added( Tomahawk::Accounts::Account* ) ), this, SLOT( onAccountAdded( Tomahawk::Accounts::Account* ) ) );
|
||||||
connect( SipHandler::instance(), SIGNAL( pluginRemoved( SipPlugin* ) ), this, SLOT( onSipPluginRemoved( SipPlugin* ) ) );
|
foreach( Account* account, AccountManager::instance()->accounts( Tomahawk::Accounts::SipType ) )
|
||||||
foreach( SipPlugin *plugin, SipHandler::instance()->allPlugins() )
|
|
||||||
{
|
{
|
||||||
connect( plugin, SIGNAL( addMenu( QMenu* ) ), this, SLOT( pluginMenuAdded( QMenu* ) ) );
|
if ( !account || !account->sipPlugin() )
|
||||||
connect( plugin, SIGNAL( removeMenu( QMenu* ) ), this, SLOT( pluginMenuRemoved( QMenu* ) ) );
|
continue;
|
||||||
|
|
||||||
|
connect( account->sipPlugin(), SIGNAL( addMenu( QMenu* ) ), this, SLOT( pluginMenuAdded( QMenu* ) ) );
|
||||||
|
connect( account->sipPlugin(), SIGNAL( removeMenu( QMenu* ) ), this, SLOT( pluginMenuRemoved( QMenu* ) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -654,39 +656,37 @@ TomahawkWindow::onPlaybackLoading( const Tomahawk::result_ptr& result )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkWindow::onSipConnected()
|
TomahawkWindow::onAccountConnected()
|
||||||
{
|
{
|
||||||
ui->actionToggleConnect->setText( tr( "Go &offline" ) );
|
ui->actionToggleConnect->setText( tr( "Go &offline" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkWindow::onSipDisconnected()
|
TomahawkWindow::onAccountDisconnected()
|
||||||
{
|
{
|
||||||
ui->actionToggleConnect->setText( tr( "Go &online" ) );
|
ui->actionToggleConnect->setText( tr( "Go &online" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkWindow::onSipPluginAdded( SipPlugin* p )
|
TomahawkWindow::onAccountAdded( Account* acc )
|
||||||
{
|
{
|
||||||
connect( p, SIGNAL( addMenu( QMenu* ) ), this, SLOT( pluginMenuAdded( QMenu* ) ) );
|
if ( !acc->types().contains( SipType ) ||
|
||||||
connect( p, SIGNAL( removeMenu( QMenu* ) ), this, SLOT( pluginMenuRemoved( QMenu* ) ) );
|
!acc->sipPlugin() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
connect( acc->sipPlugin(), SIGNAL( addMenu( QMenu* ) ), this, SLOT( pluginMenuAdded( QMenu* ) ) );
|
||||||
|
connect( acc->sipPlugin(), SIGNAL( removeMenu( QMenu* ) ), this, SLOT( pluginMenuRemoved( QMenu* ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkWindow::onSipPluginRemoved( SipPlugin* p )
|
TomahawkWindow::onAccountError()
|
||||||
{
|
{
|
||||||
Q_UNUSED( p );
|
// TODO fix.
|
||||||
}
|
// onAccountDisconnected();
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TomahawkWindow::onSipError()
|
|
||||||
{
|
|
||||||
onSipDisconnected();
|
|
||||||
|
|
||||||
|
// TODO real error message from plugin kthxbbq
|
||||||
QMessageBox::warning( this,
|
QMessageBox::warning( this,
|
||||||
tr( "Authentication Error" ),
|
tr( "Authentication Error" ),
|
||||||
QString( "Error connecting to SIP: Authentication failed!" ),
|
QString( "Error connecting to SIP: Authentication failed!" ),
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -28,9 +29,14 @@
|
|||||||
#include "result.h"
|
#include "result.h"
|
||||||
#include "utils/xspfloader.h"
|
#include "utils/xspfloader.h"
|
||||||
|
|
||||||
|
namespace Tomahawk {
|
||||||
|
namespace Accounts {
|
||||||
|
class Account;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class JobStatusModel;
|
class JobStatusModel;
|
||||||
class QSearchField;
|
class QSearchField;
|
||||||
class SipPlugin;
|
|
||||||
class SourceTreeView;
|
class SourceTreeView;
|
||||||
class QAction;
|
class QAction;
|
||||||
|
|
||||||
@@ -80,9 +86,10 @@ public slots:
|
|||||||
void showOfflineSources();
|
void showOfflineSources();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onSipConnected();
|
void onAccountAdded( Tomahawk::Accounts::Account* account );
|
||||||
void onSipDisconnected();
|
void onAccountConnected();
|
||||||
void onSipError();
|
void onAccountDisconnected();
|
||||||
|
void onAccountError();
|
||||||
|
|
||||||
void onXSPFError( XSPFLoader::XSPFErrorCode error );
|
void onXSPFError( XSPFLoader::XSPFErrorCode error );
|
||||||
void onXSPFOk( const Tomahawk::playlist_ptr& );
|
void onXSPFOk( const Tomahawk::playlist_ptr& );
|
||||||
@@ -97,9 +104,6 @@ private slots:
|
|||||||
void showAboutTomahawk();
|
void showAboutTomahawk();
|
||||||
void checkForUpdates();
|
void checkForUpdates();
|
||||||
|
|
||||||
void onSipPluginAdded( SipPlugin* p );
|
|
||||||
void onSipPluginRemoved( SipPlugin* p );
|
|
||||||
|
|
||||||
void onSearch( const QString& search );
|
void onSearch( const QString& search );
|
||||||
void onFilterEdited();
|
void onFilterEdited();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user