Example #1
0
void MainWindow::updateButtonClicked(const QString &id, const QString &text, const QString& screenName)
{
    bool ok;

    //if screenName is not empty, then it's direct message
    if (!screenName.isEmpty()) {
        qDebug() << "Sending DM to " << screenName;

        QTweetDirectMessageNew *dm = new QTweetDirectMessageNew;
        dm->setOAuthTwitter(m_oauthTwitter);
        dm->post(screenName, text);

        connect(dm, SIGNAL(parsedDirectMessage(QTweetDMStatus)),
                this, SLOT(directMessageNewFinished(QTweetDMStatus)));

        return;
    }

    qint64 tweetid = id.toLongLong(&ok);

    QString updateText = text.left(140);

    if (updateText.isEmpty()) {
        qDebug() << "MainWindow::updateButtonClicked: empty update text";
        return;
    }

    QTweetStatusUpdate *statusUpdate = new QTweetStatusUpdate;
    statusUpdate->setOAuthTwitter(m_oauthTwitter);
    statusUpdate->post(text, tweetid);
    connect(statusUpdate, SIGNAL(postedStatus(QTweetStatus)),
            this, SLOT(statusUpdateFinished(QTweetStatus)));
}
Example #2
0
void MainWindow::directMessageNewFinished(const QTweetDMStatus& directMessage)
{
    QTweetDirectMessageNew *dm = qobject_cast<QTweetDirectMessageNew*>(sender());
    if (dm) {
        qDebug() << "Direct Message sent, id: " << directMessage.id();
        dm->deleteLater();
    }
}
Example #3
0
void
TwitterConfigWidget::postGotTomahawkStatusAuthVerifyReply( const QTweetUser &user )
{
    if ( user.id() == 0 )
    {
        QMessageBox::critical( this, tr("Tweetin' Error"), tr("Your saved credentials could not be verified.\nYou may wish to try re-authenticating.") );
        emit twitterAuthed( false );
        return;
    }
    TomahawkSettings* s = TomahawkSettings::instance();
    s->setTwitterScreenName( user.screenName() );
    TomahawkOAuthTwitter *twitAuth = new TomahawkOAuthTwitter( this );
    twitAuth->setNetworkAccessManager( TomahawkUtils::nam() );
    twitAuth->setOAuthToken( s->twitterOAuthToken().toLatin1() );
    twitAuth->setOAuthTokenSecret( s->twitterOAuthTokenSecret().toLatin1() );
    if ( m_postGTtype != "Direct Message" )
    {
        QTweetStatusUpdate *statUpdate = new QTweetStatusUpdate( twitAuth, this );
        connect( statUpdate, SIGNAL( postedStatus(const QTweetStatus &) ), SLOT( postGotTomahawkStatusUpdateReply(const QTweetStatus &) ) );
        connect( statUpdate, SIGNAL( error(QTweetNetBase::ErrorCode, const QString&) ), SLOT( postGotTomahawkStatusUpdateError(QTweetNetBase::ErrorCode, const QString &) ) );
        QString uuid = QUuid::createUuid();
        QString message = QString( "Got Tomahawk? {" ) + Database::instance()->dbid() + QString( "} (" ) + uuid.mid( 1, 8 ) + QString( ")" ) + QString( " http://gettomahawk.com" );
        if ( m_postGTtype == "@Mention" )
        {
            QString user = ui->twitterUserTweetLineEdit->text();
            if ( user.startsWith( "@" ) )
                user.remove( 0, 1 );
            message = QString( "@" ) + user + QString( " " ) + message;
        }
        statUpdate->post( message );
    }
    else
    {
        QTweetDirectMessageNew *statUpdate = new QTweetDirectMessageNew( twitAuth, this );
        connect( statUpdate, SIGNAL( parsedDirectMessage(const QTweetDMStatus &)), SLOT( postGotTomahawkDirectMessageReply(const QTweetDMStatus &) ) );
        connect( statUpdate, SIGNAL( error(QTweetNetBase::ErrorCode, const QString&) ), SLOT( postGotTomahawkStatusUpdateError(QTweetNetBase::ErrorCode, const QString &) ) );
        QString uuid = QUuid::createUuid();
        QString message = QString( "Got Tomahawk? {" ) + Database::instance()->dbid() + QString( "} (" ) + uuid.mid( 1, 8 ) + QString( ")" ) + QString( " http://gettomahawk.com" );
        QString user = ui->twitterUserTweetLineEdit->text();
        if ( user.startsWith( "@" ) )
            user.remove( 0, 1 );
        statUpdate->post( user, message );
    }
}