mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
sipPlugin() calls to most sips would automatically create if it did not already exist. But when shutting down and trying to disconnect a plugin, you don't want it constructing as you're shutting things down...it leads to crashes. Based on some of the code I looked at/touched, this will also fix a few places where sips were being connected when unexpected, like after changing some settings.
This commit is contained in:
@@ -106,10 +106,13 @@ GoogleWrapper::~GoogleWrapper()
|
|||||||
|
|
||||||
|
|
||||||
SipPlugin*
|
SipPlugin*
|
||||||
GoogleWrapper::sipPlugin()
|
GoogleWrapper::sipPlugin( bool create )
|
||||||
{
|
{
|
||||||
if ( m_xmppSipPlugin.isNull() )
|
if ( m_xmppSipPlugin.isNull() )
|
||||||
{
|
{
|
||||||
|
if ( !create )
|
||||||
|
return 0;
|
||||||
|
|
||||||
m_xmppSipPlugin = QPointer< XmppSipPlugin >( new GoogleWrapperSip( const_cast< GoogleWrapper* >( this ) ) );
|
m_xmppSipPlugin = QPointer< XmppSipPlugin >( new GoogleWrapperSip( const_cast< GoogleWrapper* >( this ) ) );
|
||||||
|
|
||||||
connect( m_xmppSipPlugin.data(), SIGNAL( stateChanged( Tomahawk::Accounts::Account::ConnectionState ) ), this, SIGNAL( connectionStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ) );
|
connect( m_xmppSipPlugin.data(), SIGNAL( stateChanged( Tomahawk::Accounts::Account::ConnectionState ) ), this, SIGNAL( connectionStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ) );
|
||||||
|
@@ -72,7 +72,7 @@ public:
|
|||||||
virtual const QString name() const { return QString( "Google" ); }
|
virtual const QString name() const { return QString( "Google" ); }
|
||||||
virtual const QString friendlyName() const { return "Google"; }
|
virtual const QString friendlyName() const { return "Google"; }
|
||||||
|
|
||||||
virtual SipPlugin* sipPlugin();
|
virtual SipPlugin* sipPlugin( bool create = true );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer< GoogleWrapperSip > m_sipPlugin;
|
QPointer< GoogleWrapperSip > m_sipPlugin;
|
||||||
|
@@ -151,7 +151,7 @@ void
|
|||||||
HatchetAccount::deauthenticate()
|
HatchetAccount::deauthenticate()
|
||||||
{
|
{
|
||||||
if ( !m_tomahawkSipPlugin.isNull() )
|
if ( !m_tomahawkSipPlugin.isNull() )
|
||||||
sipPlugin()->disconnectPlugin();
|
m_tomahawkSipPlugin->disconnectPlugin();
|
||||||
emit deauthenticated();
|
emit deauthenticated();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,10 +173,13 @@ HatchetAccount::connectionState() const
|
|||||||
|
|
||||||
|
|
||||||
SipPlugin*
|
SipPlugin*
|
||||||
HatchetAccount::sipPlugin()
|
HatchetAccount::sipPlugin( bool create )
|
||||||
{
|
{
|
||||||
if ( m_tomahawkSipPlugin.isNull() )
|
if ( m_tomahawkSipPlugin.isNull() )
|
||||||
{
|
{
|
||||||
|
if ( !create )
|
||||||
|
return 0;
|
||||||
|
|
||||||
tLog() << Q_FUNC_INFO;
|
tLog() << Q_FUNC_INFO;
|
||||||
m_tomahawkSipPlugin = QPointer< HatchetSipPlugin >( new HatchetSipPlugin( this ) );
|
m_tomahawkSipPlugin = QPointer< HatchetSipPlugin >( new HatchetSipPlugin( this ) );
|
||||||
connect( m_tomahawkSipPlugin.data(), SIGNAL( authUrlDiscovered( Tomahawk::Accounts::HatchetAccount::Service, QString ) ),
|
connect( m_tomahawkSipPlugin.data(), SIGNAL( authUrlDiscovered( Tomahawk::Accounts::HatchetAccount::Service, QString ) ),
|
||||||
|
@@ -81,7 +81,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin() { return Tomahawk::InfoSystem::InfoPluginPtr(); }
|
virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin() { return Tomahawk::InfoSystem::InfoPluginPtr(); }
|
||||||
SipPlugin* sipPlugin();
|
SipPlugin* sipPlugin( bool create = true );
|
||||||
|
|
||||||
AccountConfigWidget* configurationWidget();
|
AccountConfigWidget* configurationWidget();
|
||||||
QWidget* aclWidget() { return 0; }
|
QWidget* aclWidget() { return 0; }
|
||||||
|
@@ -77,8 +77,8 @@ XmppAccount::authenticate()
|
|||||||
void
|
void
|
||||||
XmppAccount::deauthenticate()
|
XmppAccount::deauthenticate()
|
||||||
{
|
{
|
||||||
if ( connectionState() != Account::Disconnected )
|
if ( connectionState() != Account::Disconnected && !m_xmppSipPlugin.isNull() )
|
||||||
sipPlugin()->disconnectPlugin();
|
m_xmppSipPlugin->disconnectPlugin();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -116,10 +116,13 @@ XmppAccount::infoPlugin()
|
|||||||
|
|
||||||
|
|
||||||
SipPlugin*
|
SipPlugin*
|
||||||
XmppAccount::sipPlugin()
|
XmppAccount::sipPlugin( bool create )
|
||||||
{
|
{
|
||||||
if ( m_xmppSipPlugin.isNull() )
|
if ( m_xmppSipPlugin.isNull() )
|
||||||
{
|
{
|
||||||
|
if ( !create )
|
||||||
|
return 0;
|
||||||
|
|
||||||
m_xmppSipPlugin = QPointer< XmppSipPlugin >( new XmppSipPlugin( this ) );
|
m_xmppSipPlugin = QPointer< XmppSipPlugin >( new XmppSipPlugin( this ) );
|
||||||
|
|
||||||
connect( m_xmppSipPlugin.data(), SIGNAL( stateChanged( Tomahawk::Accounts::Account::ConnectionState ) ), this, SIGNAL( connectionStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ) );
|
connect( m_xmppSipPlugin.data(), SIGNAL( stateChanged( Tomahawk::Accounts::Account::ConnectionState ) ), this, SIGNAL( connectionStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ) );
|
||||||
|
@@ -73,7 +73,7 @@ public:
|
|||||||
|
|
||||||
Tomahawk::InfoSystem::InfoPluginPtr infoPlugin();
|
Tomahawk::InfoSystem::InfoPluginPtr infoPlugin();
|
||||||
|
|
||||||
SipPlugin* sipPlugin();
|
SipPlugin* sipPlugin( bool create = true );
|
||||||
|
|
||||||
AccountConfigWidget* configurationWidget() { return m_configWidget.data(); }
|
AccountConfigWidget* configurationWidget() { return m_configWidget.data(); }
|
||||||
QWidget* aclWidget() { return 0; }
|
QWidget* aclWidget() { return 0; }
|
||||||
|
@@ -91,8 +91,8 @@ ZeroconfAccount::authenticate()
|
|||||||
void
|
void
|
||||||
ZeroconfAccount::deauthenticate()
|
ZeroconfAccount::deauthenticate()
|
||||||
{
|
{
|
||||||
if ( isAuthenticated() )
|
if ( isAuthenticated() && !m_sipPlugin.isNull() )
|
||||||
sipPlugin()->disconnectPlugin();
|
m_sipPlugin->disconnectPlugin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -110,15 +110,19 @@ ZeroconfAccount::connectionState() const
|
|||||||
return Disconnected;
|
return Disconnected;
|
||||||
|
|
||||||
// TODO can we get called before sipPlugin()?
|
// TODO can we get called before sipPlugin()?
|
||||||
return m_sipPlugin.data()->connectionState();
|
return m_sipPlugin->connectionState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SipPlugin*
|
SipPlugin*
|
||||||
ZeroconfAccount::sipPlugin()
|
ZeroconfAccount::sipPlugin( bool create )
|
||||||
{
|
{
|
||||||
if ( m_sipPlugin.isNull() )
|
if ( m_sipPlugin.isNull() ) {
|
||||||
|
if ( !create )
|
||||||
|
return 0;
|
||||||
|
|
||||||
m_sipPlugin = QPointer< ZeroconfPlugin >( new ZeroconfPlugin( this ) );
|
m_sipPlugin = QPointer< ZeroconfPlugin >( new ZeroconfPlugin( this ) );
|
||||||
|
}
|
||||||
|
|
||||||
return m_sipPlugin.data();
|
return m_sipPlugin.data();
|
||||||
}
|
}
|
||||||
|
@@ -69,7 +69,7 @@ public:
|
|||||||
ConnectionState connectionState() const;
|
ConnectionState connectionState() const;
|
||||||
|
|
||||||
virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin() { return Tomahawk::InfoSystem::InfoPluginPtr(); }
|
virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin() { return Tomahawk::InfoSystem::InfoPluginPtr(); }
|
||||||
SipPlugin* sipPlugin();
|
SipPlugin* sipPlugin( bool create = true );
|
||||||
|
|
||||||
AccountConfigWidget* configurationWidget() { return 0; }
|
AccountConfigWidget* configurationWidget() { return 0; }
|
||||||
QWidget* aclWidget() { return 0; }
|
QWidget* aclWidget() { return 0; }
|
||||||
|
@@ -117,7 +117,7 @@ public:
|
|||||||
virtual QString errorMessage() const { QMutexLocker locker( &m_mutex ); return m_cachedError; }
|
virtual QString errorMessage() const { QMutexLocker locker( &m_mutex ); return m_cachedError; }
|
||||||
|
|
||||||
virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin() = 0;
|
virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin() = 0;
|
||||||
virtual SipPlugin* sipPlugin() = 0;
|
virtual SipPlugin* sipPlugin( bool create = true ) = 0;
|
||||||
|
|
||||||
// Some accounts cannot be enabled if authentication fails. Return true after failing to authenticate
|
// Some accounts cannot be enabled if authentication fails. Return true after failing to authenticate
|
||||||
// if this is the case, and the account will not be enabled
|
// if this is the case, and the account will not be enabled
|
||||||
|
@@ -208,7 +208,7 @@ AccountManager::disconnectAll()
|
|||||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
foreach ( Account* acc, m_enabledAccounts )
|
foreach ( Account* acc, m_enabledAccounts )
|
||||||
{
|
{
|
||||||
if ( acc->sipPlugin() )
|
if ( acc->sipPlugin( false ) )
|
||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO << "Disconnecting" << acc->accountFriendlyName();
|
tDebug() << Q_FUNC_INFO << "Disconnecting" << acc->accountFriendlyName();
|
||||||
acc->deauthenticate();
|
acc->deauthenticate();
|
||||||
@@ -440,7 +440,7 @@ AccountManager::zeroconfAccount() const
|
|||||||
{
|
{
|
||||||
foreach ( Account* account, accounts() )
|
foreach ( Account* account, accounts() )
|
||||||
{
|
{
|
||||||
if ( account->sipPlugin() && account->sipPlugin()->serviceName() == "zeroconf" )
|
if ( account->sipPlugin( false ) && account->sipPlugin()->serviceName() == "zeroconf" )
|
||||||
return account;
|
return account;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -521,7 +521,7 @@ AccountManager::onSettingsChanged()
|
|||||||
{
|
{
|
||||||
foreach ( Account* account, m_accounts )
|
foreach ( Account* account, m_accounts )
|
||||||
{
|
{
|
||||||
if ( account->types() & Accounts::SipType && account->sipPlugin() )
|
if ( account->types() & Accounts::SipType && account->sipPlugin( false ) )
|
||||||
account->sipPlugin()->checkSettings();
|
account->sipPlugin()->checkSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -92,7 +92,7 @@ public:
|
|||||||
virtual QString version() const;
|
virtual QString version() const;
|
||||||
|
|
||||||
// Not relevant
|
// Not relevant
|
||||||
virtual SipPlugin* sipPlugin() { return 0; }
|
virtual SipPlugin* sipPlugin( bool ) { return 0; }
|
||||||
virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin() { return Tomahawk::InfoSystem::InfoPluginPtr(); }
|
virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin() { return Tomahawk::InfoSystem::InfoPluginPtr(); }
|
||||||
virtual QWidget* aclWidget() { return 0; }
|
virtual QWidget* aclWidget() { return 0; }
|
||||||
|
|
||||||
|
@@ -73,7 +73,7 @@ public:
|
|||||||
virtual void deauthenticate();
|
virtual void deauthenticate();
|
||||||
virtual void authenticate();
|
virtual void authenticate();
|
||||||
|
|
||||||
virtual SipPlugin* sipPlugin() { return 0; }
|
virtual SipPlugin* sipPlugin( bool ) { return 0; }
|
||||||
virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin();
|
virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin();
|
||||||
|
|
||||||
virtual bool isAuthenticated() const;
|
virtual bool isAuthenticated() const;
|
||||||
|
@@ -100,7 +100,7 @@ public:
|
|||||||
|
|
||||||
virtual QWidget* aclWidget() { return 0; }
|
virtual QWidget* aclWidget() { return 0; }
|
||||||
virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin();
|
virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin();
|
||||||
virtual SipPlugin* sipPlugin() { return 0; }
|
virtual SipPlugin* sipPlugin( bool ) { return 0; }
|
||||||
virtual bool preventEnabling() const { return m_preventEnabling; }
|
virtual bool preventEnabling() const { return m_preventEnabling; }
|
||||||
|
|
||||||
bool hasPlaylist( const QString& plId );
|
bool hasPlaylist( const QString& plId );
|
||||||
|
Reference in New Issue
Block a user