void
TwitterConfigWidget::startPostGotTomahawkStatus()
{
    qDebug() << Q_FUNC_INFO;
    m_postGTtype = m_ui->twitterTweetComboBox->currentText();

    if ( m_postGTtype != "Global Tweet" && ( m_ui->twitterUserTweetLineEdit->text().isEmpty() || m_ui->twitterUserTweetLineEdit->text() == "@" ) )
    {
        QMessageBox::critical( this, tr("Tweetin' Error"), tr("You must enter a user name for this type of tweet.") );
        return;
    }

    qDebug() << "Posting Got Tomahawk status";
    QVariantHash credentials = m_account->credentials();

    if ( credentials[ "oauthtoken" ].toString().isEmpty() ||
         credentials[ "oauthtokensecret" ].toString().isEmpty() ||
         credentials[ "username" ].toString().isEmpty() )
    {
        QMessageBox::critical( this, tr("Tweetin' Error"), tr("Your saved credentials could not be loaded.\nYou may wish to try re-authenticating.") );
        emit twitterAuthed( false );
        return;
    }
    TomahawkOAuthTwitter *twitAuth = new TomahawkOAuthTwitter( TomahawkUtils::nam(), this );
    twitAuth->setOAuthToken( credentials[ "oauthtoken" ].toString().toLatin1() );
    twitAuth->setOAuthTokenSecret( credentials[ "oauthtokensecret" ].toString().toLatin1() );
    QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( twitAuth, this );
    connect( credVerifier, SIGNAL( parsedUser(const QTweetUser &) ), SLOT( postGotTomahawkStatusAuthVerifyReply(const QTweetUser &) ) );
    credVerifier->verify();
}
Beispiel #2
0
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;
}
Beispiel #3
0
void
TwitterConfigWidget::startPostGotTomahawkStatus()
{
    m_postGTtype = ui->twitterTweetComboBox->currentText();
    
    if ( m_postGTtype != "Global Tweet" && ( ui->twitterUserTweetLineEdit->text().isEmpty() || ui->twitterUserTweetLineEdit->text() == "@" ) )
    {
        QMessageBox::critical( this, tr("Tweetin' Error"), tr("You must enter a user name for this type of tweet.") );
        return;
    }
    
    qDebug() << "Posting Got Tomahawk status";
    TomahawkSettings* s = TomahawkSettings::instance();
    if ( s->twitterOAuthToken().isEmpty() || s->twitterOAuthTokenSecret().isEmpty() || s->twitterScreenName().isEmpty() )
    {
        QMessageBox::critical( this, tr("Tweetin' Error"), tr("Your saved credentials could not be loaded.\nYou may wish to try re-authenticating.") );
        emit twitterAuthed( false );
        return;
    }
    TomahawkOAuthTwitter *twitAuth = new TomahawkOAuthTwitter( this );
    twitAuth->setNetworkAccessManager( TomahawkUtils::nam() );
    twitAuth->setOAuthToken( s->twitterOAuthToken().toLatin1() );
    twitAuth->setOAuthTokenSecret( s->twitterOAuthTokenSecret().toLatin1() );
    QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( twitAuth, this );
    connect( credVerifier, SIGNAL( parsedUser(const QTweetUser &) ), SLOT( postGotTomahawkStatusAuthVerifyReply(const QTweetUser &) ) );
    credVerifier->verify();
}
Beispiel #4
0
void MainWindow::authorizationFinished()
{
    qDebug() << "Authorization succesfull";

    QTweetAccountVerifyCredentials *tweetVerifyCredentials = new QTweetAccountVerifyCredentials;
    tweetVerifyCredentials->setOAuthTwitter(m_oauthTwitter);
    tweetVerifyCredentials->verify();
    connect(tweetVerifyCredentials, SIGNAL(parsedUser(QTweetUser)),
            this, SLOT(verifyCredentialsFinished(QTweetUser)));
}
void
TwitterConfigWidget::authenticateTwitter()
{
    qDebug() << Q_FUNC_INFO;
    TomahawkOAuthTwitter *twitAuth = new TomahawkOAuthTwitter( TomahawkUtils::nam(), this );
    twitAuth->authorizePin();

    m_plugin->setTwitterOAuthToken( twitAuth->oauthToken() );
    m_plugin->setTwitterOAuthTokenSecret( twitAuth->oauthTokenSecret() );

    QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( twitAuth, this );
    connect( credVerifier, SIGNAL( parsedUser( const QTweetUser & ) ), SLOT( authenticateVerifyReply( const QTweetUser & ) ) );
    connect( credVerifier, SIGNAL( error( QTweetNetBase::ErrorCode, QString ) ), SLOT( authenticateVerifyError( QTweetNetBase::ErrorCode, QString ) ) );
    credVerifier->verify();
}
void
TwitterConfigWidget::startPostGotTomahawkStatus()
{
    qDebug() << "Posting Got Tomahawk status";
    TomahawkSettings* s = TomahawkSettings::instance();
    if ( s->twitterOAuthToken().isEmpty() || s->twitterOAuthTokenSecret().isEmpty() )
    {
        QMessageBox::critical( 0, QString("Tweetin' Error"), QString("Your saved credentials could not be loaded.\nYou may wish to try re-authenticating.") );
        return;
    }
    TomahawkOAuthTwitter *twitAuth = new TomahawkOAuthTwitter( this );
    twitAuth->setNetworkAccessManager( TomahawkUtils::nam() );
    twitAuth->setOAuthToken( s->twitterOAuthToken().toLatin1() );
    twitAuth->setOAuthTokenSecret( s->twitterOAuthTokenSecret().toLatin1() );
    QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( twitAuth, this );
    connect( credVerifier, SIGNAL( parsedUser(const QTweetUser &) ), SLOT( postGotTomahawkStatusAuthVerifyReply(const QTweetUser &) ) );
    credVerifier->verify();
}
Beispiel #7
0
void MainWindow::verifyCredentialsFinished(const QTweetUser& userinfo)
{
    qDebug() << "Verify Credential succesfull";

    QTweetAccountVerifyCredentials *tweetVerifyCredentials = qobject_cast<QTweetAccountVerifyCredentials*>(sender());
    if (tweetVerifyCredentials) {
        QSettings settings(QSettings::IniFormat, QSettings::UserScope, "QTwitdget", "QTwitdget");
        settings.setValue("oauth_token", m_oauthTwitter->oauthToken());
        settings.setValue("oauth_token_secret", m_oauthTwitter->oauthTokenSecret());
        settings.setValue("user_id", userinfo.id());
        settings.setValue("user_screenname", userinfo.screenName());

        m_userId = userinfo.id();
        m_userScreenName = userinfo.screenName();

        emit userScreenNameChanged();

        tweetVerifyCredentials->deleteLater();

        startUp();
    }
}
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();
    }
}
Beispiel #9
0
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();
    }
}