bool TwitterPlugin::connectPlugin( bool startup ) { Q_UNUSED( startup ); qDebug() << Q_FUNC_INFO; m_cachedPeers = twitterCachedPeers(); QStringList peerList = m_cachedPeers.keys(); qStableSort( peerList.begin(), peerList.end() ); registerOffers( peerList ); if ( twitterOAuthToken().isEmpty() || twitterOAuthTokenSecret().isEmpty() ) { qDebug() << "TwitterPlugin has empty Twitter credentials; not connecting"; return m_cachedPeers.isEmpty(); } if ( refreshTwitterAuth() ) { QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( m_twitterAuth.data(), this ); connect( credVerifier, SIGNAL( parsedUser(const QTweetUser &) ), SLOT( connectAuthVerifyReply(const QTweetUser &) ) ); credVerifier->verify(); m_state = Connecting; emit stateChanged( m_state ); } return true; }
void TwitterInfoPlugin::init() { if ( Tomahawk::InfoSystem::InfoSystem::instance()->workerThread() && thread() != Tomahawk::InfoSystem::InfoSystem::instance()->workerThread().data() ) { tDebug() << "Failure: move to the worker thread before running init"; return; } QVariantHash credentials = m_account->credentials(); if ( credentials[ "oauthtoken" ].toString().isEmpty() || credentials[ "oauthtokensecret" ].toString().isEmpty() ) { tDebug() << "TwitterInfoPlugin has empty Twitter credentials; not connecting"; return; } if ( refreshTwitterAuth() ) { QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( m_twitterAuth.data(), this ); connect( credVerifier, SIGNAL( parsedUser( const QTweetUser & ) ), SLOT( connectAuthVerifyReply( const QTweetUser & ) ) ); credVerifier->verify(); } }
void TwitterAccount::authenticateSlot() { tDebug() << Q_FUNC_INFO; if ( m_twitterInfoPlugin.isNull() ) { if ( infoPlugin() && Tomahawk::InfoSystem::InfoSystem::instance()->workerThread() ) { infoPlugin().data()->moveToThread( Tomahawk::InfoSystem::InfoSystem::instance()->workerThread().data() ); Tomahawk::InfoSystem::InfoSystem::instance()->addInfoPlugin( infoPlugin() ); } } if ( m_isAuthenticating ) { tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Already authenticating"; return; } tDebug() << Q_FUNC_INFO << "credentials: " << credentials().keys(); if ( credentials()[ "oauthtoken" ].toString().isEmpty() || credentials()[ "oauthtokensecret" ].toString().isEmpty() ) { tDebug() << Q_FUNC_INFO << "TwitterSipPlugin has empty Twitter credentials; not connecting"; return; } if ( refreshTwitterAuth() ) { m_isAuthenticating = true; tDebug() << Q_FUNC_INFO << "Verifying credentials"; QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( m_twitterAuth.data(), this ); connect( credVerifier, SIGNAL( parsedUser( const QTweetUser & ) ), SLOT( connectAuthVerifyReply( const QTweetUser & ) ) ); credVerifier->verify(); } }