1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-05 13:47:26 +02:00

Get rid of double-additions of info plugins. Still not sure why it doesn't seem to delete itself.

This commit is contained in:
Jeff Mitchell
2012-04-10 12:43:47 -04:00
parent 25fba84b32
commit 4eaff7a45f
3 changed files with 17 additions and 6 deletions

View File

@@ -50,7 +50,7 @@ TwitterAccount::TwitterAccount( const QString &accountId )
, m_isAuthenticated( false ) , m_isAuthenticated( false )
{ {
setAccountServiceName( "Twitter" ); setAccountServiceName( "Twitter" );
setTypes( AccountTypes( InfoType | SipType ) ); setTypes( AccountTypes( StatusPushType | SipType ) );
qDebug() << "Got cached peers:" << configuration() << configuration()[ "cachedpeers" ]; qDebug() << "Got cached peers:" << configuration() << configuration()[ "cachedpeers" ];
@@ -120,12 +120,13 @@ TwitterAccount::authenticate()
if ( credentials()[ "oauthtoken" ].toString().isEmpty() || credentials()[ "oauthtokensecret" ].toString().isEmpty() ) if ( credentials()[ "oauthtoken" ].toString().isEmpty() || credentials()[ "oauthtokensecret" ].toString().isEmpty() )
{ {
qDebug() << "TwitterSipPlugin has empty Twitter credentials; not connecting"; tDebug() << Q_FUNC_INFO << "TwitterSipPlugin has empty Twitter credentials; not connecting";
return; return;
} }
if ( refreshTwitterAuth() ) if ( refreshTwitterAuth() )
{ {
tDebug() << Q_FUNC_INFO << "Verifying credentials";
QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( m_twitterAuth.data(), this ); QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( m_twitterAuth.data(), this );
connect( credVerifier, SIGNAL( parsedUser( const QTweetUser & ) ), SLOT( connectAuthVerifyReply( const QTweetUser & ) ) ); connect( credVerifier, SIGNAL( parsedUser( const QTweetUser & ) ), SLOT( connectAuthVerifyReply( const QTweetUser & ) ) );
credVerifier->verify(); credVerifier->verify();
@@ -136,6 +137,8 @@ TwitterAccount::authenticate()
void void
TwitterAccount::deauthenticate() TwitterAccount::deauthenticate()
{ {
tDebug() << Q_FUNC_INFO;
if ( m_twitterSipPlugin ) if ( m_twitterSipPlugin )
sipPlugin()->disconnectPlugin(); sipPlugin()->disconnectPlugin();

View File

@@ -68,18 +68,19 @@ TwitterInfoPlugin::init()
TwitterInfoPlugin::~TwitterInfoPlugin() TwitterInfoPlugin::~TwitterInfoPlugin()
{ {
tDebug() << Q_FUNC_INFO;
} }
bool bool
TwitterInfoPlugin::refreshTwitterAuth() TwitterInfoPlugin::refreshTwitterAuth()
{ {
tDebug() << Q_FUNC_INFO << " begin"; tDebug() << Q_FUNC_INFO << " begin" << this;
if( !m_twitterAuth.isNull() ) if( !m_twitterAuth.isNull() )
delete m_twitterAuth.data(); delete m_twitterAuth.data();
Q_ASSERT( TomahawkUtils::nam() != 0 ); Q_ASSERT( TomahawkUtils::nam() != 0 );
tDebug() << Q_FUNC_INFO << " with nam " << TomahawkUtils::nam(); tDebug() << Q_FUNC_INFO << " with nam " << TomahawkUtils::nam() << this;
m_twitterAuth = QWeakPointer< TomahawkOAuthTwitter >( new TomahawkOAuthTwitter( TomahawkUtils::nam(), this ) ); m_twitterAuth = QWeakPointer< TomahawkOAuthTwitter >( new TomahawkOAuthTwitter( TomahawkUtils::nam(), this ) );
if( m_twitterAuth.isNull() ) if( m_twitterAuth.isNull() )
@@ -97,13 +98,13 @@ TwitterInfoPlugin::connectAuthVerifyReply( const QTweetUser &user )
{ {
if ( user.id() == 0 ) if ( user.id() == 0 )
{ {
tDebug() << "TwitterInfoPlugin could not authenticate to Twitter"; tDebug() << "TwitterInfoPlugin could not authenticate to Twitter" << this;
deleteLater(); deleteLater();
return; return;
} }
else else
{ {
tDebug() << "TwitterInfoPlugin successfully authenticated to Twitter"; tDebug() << "TwitterInfoPlugin successfully authenticated to Twitter" << this;
return; return;
} }
} }

View File

@@ -107,6 +107,13 @@ void
InfoSystemWorker::addInfoPlugin( InfoPlugin* plugin ) InfoSystemWorker::addInfoPlugin( InfoPlugin* plugin )
{ {
tDebug() << Q_FUNC_INFO << plugin; tDebug() << Q_FUNC_INFO << plugin;
foreach ( InfoPluginPtr ptr, m_plugins )
{
if ( ptr.data() == plugin )
tDebug() << Q_FUNC_INFO << "This plugin is already added to the infosystem.";
return;
}
InfoPluginPtr weakptr( plugin ); InfoPluginPtr weakptr( plugin );
m_plugins.append( weakptr ); m_plugins.append( weakptr );
registerInfoTypes( weakptr, weakptr.data()->supportedGetTypes(), weakptr.data()->supportedPushTypes() ); registerInfoTypes( weakptr, weakptr.data()->supportedGetTypes(), weakptr.data()->supportedPushTypes() );