Beispiel #1
0
void CoreConnection::reconnectToCore()
{
    if (currentAccount().isValid()) {
        _wasReconnect = true;
        connectToCore(currentAccount().accountId());
    }
}
void FacebookComposerWidget::submitPost(const QString& txt)
{
    if( mediumToAttach.isEmpty() ){
        Choqok::UI::ComposerWidget::submitPost(txt);
    } else {
        kDebug();
        editorContainer()->setEnabled(false);
        QString text = txt;
        if( currentAccount()->microblog()->postCharLimit() &&
            text.size() > (int)currentAccount()->microblog()->postCharLimit() )
            text = Choqok::ShortenManager::self()->parseText(text);
        setPostToSubmit(0L);
        setPostToSubmit( new Choqok::Post );
        postToSubmit()->content = text;
        if( !replyToId.isEmpty() ) {
            postToSubmit()->replyToPostId = replyToId;
        }
        connect( currentAccount()->microblog(), SIGNAL(postCreated(Choqok::Account*,Choqok::Post*)),
                SLOT(slotPostMediaSubmitted(Choqok::Account*,Choqok::Post*)) );
        connect(currentAccount()->microblog(),
                SIGNAL(errorPost(Choqok::Account*,Choqok::Post*,Choqok::MicroBlog::ErrorType,
                                         QString,Choqok::MicroBlog::ErrorLevel)),
                SLOT(slotErrorPost(Choqok::Account*,Choqok::Post*)));
        btnAbort = new KPushButton(KIcon("dialog-cancel"), i18n("Abort"), this);
        layout()->addWidget(btnAbort);
        connect( btnAbort, SIGNAL(clicked(bool)), SLOT(abort()) );
        FacebookMicroBlog *mBlog = qobject_cast<FacebookMicroBlog*>(currentAccount()->microblog());
        mBlog->createPostWithAttachment( currentAccount(), postToSubmit(), mediumToAttach );
    }
}
Beispiel #3
0
void ComposerWidget::submitPost( const QString &txt )
{
    kDebug();
    editorContainer()->setEnabled(false);
    QString text = txt;
    if( currentAccount()->microblog()->postCharLimit() &&
       text.size() > (int)currentAccount()->microblog()->postCharLimit() )
        text = Choqok::ShortenManager::self()->parseText(text);
    delete d->postToSubmit;
    d->postToSubmit = new Choqok::Post;
    d->postToSubmit->content = text;
    if( !replyToId.isEmpty() ) {
        d->postToSubmit->replyToPostId = replyToId;
    }
    connect(d->currentAccount->microblog(), SIGNAL(postCreated(Choqok::Account*,Choqok::Post*)),
            SLOT(slotPostSubmited(Choqok::Account*,Choqok::Post*)) );
    connect(d->currentAccount->microblog(),
            SIGNAL(errorPost(Choqok::Account*,Choqok::Post*,Choqok::MicroBlog::ErrorType,
                             QString,Choqok::MicroBlog::ErrorLevel)),
            SLOT(slotErrorPost(Choqok::Account*,Choqok::Post*)));
    btnAbort = new KPushButton(KIcon("dialog-cancel"), i18n("Abort"), this);
    layout()->addWidget(btnAbort);
    connect( btnAbort, SIGNAL(clicked(bool)), SLOT(abort()) );
    currentAccount()->microblog()->createPost( currentAccount(),d->postToSubmit);
}
Beispiel #4
0
void CoreConnection::connectToCurrentAccount()
{
    if (_authHandler) {
        qWarning() << Q_FUNC_INFO << "Already connected!";
        return;
    }

    resetConnection(false);

    if (currentAccount().isInternal()) {
        if (Quassel::runMode() != Quassel::Monolithic) {
            qWarning() << "Cannot connect to internal core in client-only mode!";
            return;
        }
        emit startInternalCore();

        InternalPeer *peer = new InternalPeer();
        _peer = peer;
        Client::instance()->signalProxy()->addPeer(peer); // sigproxy will take ownership
        emit connectToInternalCore(peer);
        setState(Connected);

        return;
    }

    _authHandler = new ClientAuthHandler(currentAccount(), this);

    connect(_authHandler, SIGNAL(disconnected()), SLOT(coreSocketDisconnected()));
    connect(_authHandler, SIGNAL(connectionReady()), SLOT(onConnectionReady()));
    connect(_authHandler, SIGNAL(socketError(QAbstractSocket::SocketError,QString)), SLOT(coreSocketError(QAbstractSocket::SocketError,QString)));
    connect(_authHandler, SIGNAL(transferProgress(int,int)), SLOT(updateProgress(int,int)));
    connect(_authHandler, SIGNAL(requestDisconnect(QString,bool)), SLOT(disconnectFromCore(QString,bool)));

    connect(_authHandler, SIGNAL(errorMessage(QString)), SIGNAL(connectionError(QString)));
    connect(_authHandler, SIGNAL(errorPopup(QString)), SIGNAL(connectionErrorPopup(QString)), Qt::QueuedConnection);
    connect(_authHandler, SIGNAL(statusMessage(QString)), SIGNAL(connectionMsg(QString)));
    connect(_authHandler, SIGNAL(encrypted(bool)), SIGNAL(encrypted(bool)));
    connect(_authHandler, SIGNAL(startCoreSetup(QVariantList)), SIGNAL(startCoreSetup(QVariantList)));
    connect(_authHandler, SIGNAL(coreSetupFailed(QString)), SIGNAL(coreSetupFailed(QString)));
    connect(_authHandler, SIGNAL(coreSetupSuccessful()), SIGNAL(coreSetupSuccess()));
    connect(_authHandler, SIGNAL(userAuthenticationRequired(CoreAccount*,bool*,QString)), SIGNAL(userAuthenticationRequired(CoreAccount*,bool*,QString)));
    connect(_authHandler, SIGNAL(handleNoSslInClient(bool*)), SIGNAL(handleNoSslInClient(bool*)));
    connect(_authHandler, SIGNAL(handleNoSslInCore(bool*)), SIGNAL(handleNoSslInCore(bool*)));
#ifdef HAVE_SSL
    connect(_authHandler, SIGNAL(handleSslErrors(const QSslSocket*,bool*,bool*)), SIGNAL(handleSslErrors(const QSslSocket*,bool*,bool*)));
#endif

    connect(_authHandler, SIGNAL(loginSuccessful(CoreAccount)), SLOT(onLoginSuccessful(CoreAccount)));
    connect(_authHandler, SIGNAL(handshakeComplete(RemotePeer*,Protocol::SessionState)), SLOT(onHandshakeComplete(RemotePeer*,Protocol::SessionState)));

    setState(Connecting);
    _authHandler->connectToCore();
}
void TimelineWidget::addNewPosts( QList< Choqok::Post* >& postList)
{
    kDebug()<<d->currentAccount->alias()<<' '<<d->timelineName<<' '<<postList.count();
    QList<Post*>::const_iterator it, endIt = postList.constEnd();
    int unread = 0;
    for(it = postList.constBegin(); it!= endIt; ++it){
        if(d->posts.keys().contains((*it)->postId))
            continue;
        PostWidget *pw = d->currentAccount->microblog()->createPostWidget(d->currentAccount, *it, this);
        if(pw) {
            addPostWidgetToUi(pw);
            if( !pw->isRead() )
                ++unread;
        }
    }
    removeOldPosts();
    if(unread){
        d->unreadCount += unread;
        Choqok::NotifyManager::newPostArrived( i18np( "1 new post in %2(%3)",
                                                      "%1 new posts in %2(%3)",
                                                      unread, currentAccount()->alias(), d->timelineName ) );

        emit updateUnreadCount(unread);
        showMarkAllAsReadButton();
    }
}
Beispiel #6
0
void CoreConnection::checkSyncState()
{
    if (_netsToSync.isEmpty() && state() >= Synchronizing) {
        setState(Synchronized);
        setProgressText(tr("Synchronized to %1").arg(currentAccount().accountName()));
        setProgressMaximum(-1);
        emit synchronized();
    }
}
Beispiel #7
0
bool CoreConnection::isLocalConnection() const
{
    if (!isConnected())
        return false;
    if (currentAccount().isInternal())
        return true;
    if (_peer->isLocal())
        return true;

    return false;
}
Beispiel #8
0
void ComposerWidget::slotPostSubmited(Choqok::Account* theAccount, Choqok::Post* post)
{
    kDebug();
    if( currentAccount() == theAccount && post == d->postToSubmit ) {
        kDebug()<<"Accepted";
        disconnect(d->currentAccount->microblog(), SIGNAL(postCreated(Choqok::Account*,Choqok::Post*)),
                    this, SLOT(slotPostSubmited(Choqok::Account*,Choqok::Post*)) );
        disconnect(d->currentAccount->microblog(),
                    SIGNAL(errorPost(Choqok::Account*,Choqok::Post*,Choqok::MicroBlog::ErrorType,
                             QString,Choqok::MicroBlog::ErrorLevel)),
                    this, SLOT(slotErrorPost(Choqok::Account*,Choqok::Post*)));
        if(btnAbort){
            btnAbort->deleteLater();
        }
        d->editor->clear();
        replyToId.clear();
        editorContainer()->setEnabled(true);
        delete d->postToSubmit;
        d->postToSubmit = 0L;
        currentAccount()->microblog()->updateTimelines(currentAccount());
    }
void InstagramClient::sendComment(QString mediaID, QString comment, QJSValue callback)
{
    QJsonObject json;
    json["_uid"] = QString::number(currentAccount()->userID());
    json["_uuid"] = guid();
    json["comment_text"] = comment.trimmed();

    QByteArray body = this->getSignedBody(json);

    QUrl url(QString("https://i.instagram.com/api/v1/media/%1/comment/").arg(mediaID));
    executePostRequest(url, body, callback);
}
void LaconicaConversationTimelineWidget::slotConversationFetched(Choqok::Account* theAccount,
                                                                 const ChoqokId& convId,
                                                                 QList< Choqok::Post* > posts)
{
    if( currentAccount() == theAccount && convId == this->conversationId){
        setWindowTitle(i18n("Conversation"));
        addNewPosts(posts);
        foreach(Choqok::UI::PostWidget* post, postWidgets()){
            post->setReadWithSignal();
        }
        QTimer::singleShot(0, this, SLOT(updateHeight()));
    }
void FacebookComposerWidget::slotPostMediaSubmitted(Choqok::Account* theAccount, Choqok::Post* post)
{
    kDebug();
    if( currentAccount() == theAccount && post == postToSubmit() ) {
        kDebug()<<"Accepted";
        disconnect(currentAccount()->microblog(), SIGNAL(postCreated(Choqok::Account*,Choqok::Post*)),
                   this, SLOT(slotPostMediaSubmitted(Choqok::Account*,Choqok::Post*)) );
        disconnect(currentAccount()->microblog(),
                    SIGNAL(errorPost(Choqok::Account*,Choqok::Post*,Choqok::MicroBlog::ErrorType,
                                    QString,Choqok::MicroBlog::ErrorLevel)),
                    this, SLOT(slotErrorPost(Choqok::Account*,Choqok::Post*)));
        if(btnAbort){
            btnAbort->deleteLater();
        }
        Choqok::NotifyManager::success(i18n("New post submitted successfully"));
        editor()->clear();
        replyToId.clear();
        editorContainer()->setEnabled(true);
        setPostToSubmit( 0L );
        cancelAttachMedium();
        currentAccount()->microblog()->updateTimelines(currentAccount());
    }
void InstagramClient::unlike(QString mediaID, QJSValue callback)
{
    QJsonObject json;
    json["module_name"] = QString("feed_timeline");
    json["media_id"] = mediaID;
    json["_uid"] = currentAccount()->userID();
    json["_uuid"] = guid();

    QByteArray body = this->getSignedBody(json);

    QUrl url(QString("https://i.instagram.com/api/v1/media/%1/unlike/").arg(mediaID));
    executePostRequest(url, body, callback);
}
void InstagramClient::deleteComments(QString mediaID, QStringList commentIDs, QJSValue callback)
{
    QJsonObject json;
    json["_uid"] = QString::number(currentAccount()->userID());
    json["_uuid"] = guid();
    json["comment_ids_to_delete"] = commentIDs.join(QChar(','));

    QByteArray body = this->getSignedBody(json);

    QUrl url(QString("https://i.instagram.com/api/v1/media/%1/comment/bulk_delete/").arg(mediaID));
    executePostRequest(url, body, callback);

}
bool AccountManager::setCurrentAccount(const Account& account)
{
    if (account == currentAccount()) {
        return false;
    }

    emit beforeAccountChanged();

    // Would emit "accountsChanged" signal
    saveAccount(account);

    return true;
}
TwitterApiSearchTimelineWidget::TwitterApiSearchTimelineWidget(Choqok::Account* account,
                                                               const QString& timelineName,
                                                               const SearchInfo &info,
                                                               QWidget* parent)
    : TimelineWidget(account, timelineName, parent), d(new Private(info))
{
    setAttribute(Qt::WA_DeleteOnClose);
    d->searchBackend = qobject_cast<TwitterApiMicroBlog*>(currentAccount()->microblog())->searchBackend();
    connect(Choqok::UI::Global::mainWindow(), SIGNAL(updateTimelines()),
            this, SLOT(slotUpdateSearchResults()) );
    addFooter();
    timelineDescription()->setText(i18n("Search results for %1", timelineName));
    setClosable();
}
bool AccountManager::setCurrentAccount(const Account& account)
{
    if (account == currentAccount()) {
        return false;
    }

    emit beforeAccountChanged();

    // Would emit "accountsChanged" signal
    saveAccount(account);

    AccountInfoService::instance()->refresh();

    return true;
}
QString FacebookPostWidget::generateSign ()
{
	FacebookPost* post = static_cast<FacebookPost*>(currentPost());
	
    QString ss = "";
 
    
    ss = "<i><a href='"+ currentAccount()->microblog()->profileUrl( currentAccount(), post->author.userId ) 
		 +      +"' title=\"" +
    post->author.realName + "\">" ;
		
		 if (post->author.realName.isEmpty())
			ss += "Anonymous";
		else
			ss += post->author.realName;
		ss += "</a> - </i> via";

    //QStringList list = currentPost()->postId.split("_");
    
    /*ss += "<a href=\"http://www.facebook.com/" + list[0] + "/posts/" + list[1]
	 
	 + "\" title=\""
	 + currentPost().creationDateTime.toString(Qt::DefaultLocaleLongDate) + "\">%1</a>";*/
    
    if( !post->appId.isEmpty())
        ss += " <a href=\"http://www.facebook.com/apps/application.php?id=" + post->appId.toString() + "\">" + post->appName + "</a>";
    else
	    ss += " web";	

    ss += " <a href='"
	 + currentAccount()->microblog()->postUrl(currentAccount(), post->author.userName, post->postId)
 	 + "'>"
	 + "<b>" + post->creationDateTime.toString(Qt::DefaultLocaleLongDate) + "</b></a>";	
    return ss;

}
void TwitterApiMicroBlogWidget::slotSearchResultsReceived(const SearchInfo &info,
                                                          QList< Choqok::Post* >& postsList)
{
    kDebug();
    if( info.account == currentAccount() ){
        kDebug()<<postsList.count();
        QString name = QString("%1%2").arg(d->mBlog->searchBackend()->optionCode(info.option)).arg(info.query);
        if(mSearchTimelines.contains(name)){
            mSearchTimelines.value(name)->addNewPosts(postsList);
        }else{
            if( postsList.isEmpty() ){
                KMessageBox::sorry(this, i18n("The search result is empty."));
            } else {
                addSearchTimelineWidgetToUi( name, info )->addNewPosts(postsList);
            }
        }
    }
}
Beispiel #19
0
void TwitterPostWidget::slotReplyToAll()
{
    QStringList nicks;
    nicks.append(currentPost().author.userName);
    
    QString txt = QString("@%1 ").arg(currentPost().author.userName);

    int pos = 0;
    while ((pos = mTwitterUserRegExp.indexIn(currentPost().content, pos)) != -1) {
        if (mTwitterUserRegExp.cap(2).toLower() != currentAccount()->username() && 
            mTwitterUserRegExp.cap(2).toLower() != currentPost().author.userName &&
            !nicks.contains(mTwitterUserRegExp.cap(2).toLower())){
            nicks.append(mTwitterUserRegExp.cap(2));
            txt += QString("@%1 ").arg(mTwitterUserRegExp.cap(2));
        }
        pos += mTwitterUserRegExp.matchedLength();
    }

    txt.chop(1);

    emit reply(txt, currentPost().postId);
}
TwitterApiSearchTimelineWidget* TwitterApiMicroBlogWidget::addSearchTimelineWidgetToUi(const QString& name,
                                                                                       const SearchInfo &info)
{
    kDebug();
    TwitterApiSearchTimelineWidget *mbw = d->mBlog->createSearchTimelineWidget(currentAccount(), name,
                                                                               info, this);
    if(mbw) {
        mbw->setObjectName(name);
        mSearchTimelines.insert(name, mbw);
        timelines().insert(name, mbw);
        timelinesTabWidget()->addTab(mbw, name);
        timelinesTabWidget()->setTabIcon(timelinesTabWidget()->indexOf(mbw), KIcon("edit-find"));
        connect( mbw, SIGNAL(updateUnreadCount(int)),
                    this, SLOT(slotUpdateUnreadCount(int)) );
        if(composer()) {
            connect( mbw, SIGNAL(forwardResendPost(QString)),
                     composer(), SLOT(setText(QString)) );
            connect( mbw, SIGNAL(forwardReply(QString,QString)),
                     composer(), SLOT(setText(QString,QString)) );
        }
        timelinesTabWidget()->setCurrentWidget(mbw);
    } else {
Beispiel #21
0
void TwitterPostWidget::checkAnchor(const QUrl& url)
{
    QString scheme = url.scheme();
    TwitterApiMicroBlog* blog = qobject_cast<TwitterApiMicroBlog*>(currentAccount()->microblog());
    TwitterApiAccount *account = qobject_cast<TwitterApiAccount*>(currentAccount());
    if( scheme == "tag" ) {
        blog->searchBackend()->requestSearchResults(currentAccount(),
                                                    KUrl::fromPunycode(url.host().toUtf8()),
                                                    (int)TwitterSearch::ReferenceHashtag);
    } else if(scheme == "user") {
        KMenu menu;
        KAction * info = new KAction( KIcon("user-identity"), i18nc("Who is user", "Who is %1", url.host()),
                                      &menu );
        KAction * from = new KAction(KIcon("edit-find-user"), i18nc("Posts from user", "Posts from %1",url.host()),
                                     &menu);
        KAction * to = new KAction(KIcon("meeting-attending"), i18nc("Replies to user", "Replies to %1",
                                                                     url.host()),
                                   &menu);
        KAction *cont = new KAction(KIcon("user-properties"),i18nc("Including user name", "Including %1",
                                                                   url.host()),
                                    &menu);
        KAction * openInBrowser = new KAction(KIcon("applications-internet"),
                                              i18nc("Open profile page in browser",
                                                    "Open profile in browser"), &menu);
        from->setData(TwitterSearch::FromUser);
        to->setData(TwitterSearch::ToUser);
        cont->setData(TwitterSearch::ReferenceUser);
        menu.addAction(info);
        menu.addAction(from);
        menu.addAction(to);
        menu.addAction(cont);
        menu.addAction(openInBrowser);

        //Subscribe/UnSubscribe/Block
        bool isSubscribe = false;
        QString accountUsername = currentAccount()->username().toLower();
        QString postUsername = url.host().toLower();
        KAction *subscribe = 0, *block = 0, *replyTo = 0, *dMessage = 0;
        if(accountUsername != postUsername){
            menu.addSeparator();
            QMenu *actionsMenu = menu.addMenu(KIcon("applications-system"), i18n("Actions"));
            replyTo = new KAction(KIcon("edit-undo"), i18nc("Write a message to user attention", "Write to %1",
                                                          url.host()), actionsMenu);
            actionsMenu->addAction(replyTo);
            if( account->friendsList().contains( url.host(),
                Qt::CaseInsensitive ) ){
                dMessage = new KAction(KIcon("mail-message-new"), i18nc("Send direct message to user",
                                                                        "Send private message to %1",
                                                                        url.host()), actionsMenu);
                actionsMenu->addAction(dMessage);
                isSubscribe = false;//It's UnSubscribe
                subscribe = new KAction( KIcon("list-remove-user"),
                                         i18nc("Unfollow user",
                                               "Unfollow %1", url.host()), actionsMenu);
            } else {
                isSubscribe = true;
                subscribe = new KAction( KIcon("list-add-user"),
                                         i18nc("Follow user",
                                               "Follow %1", url.host()), actionsMenu);
            }
            block = new KAction( KIcon("dialog-cancel"),
                                 i18nc("Block user",
                                       "Block %1", url.host()), actionsMenu);
            actionsMenu->addAction(subscribe);
            actionsMenu->addAction(block);
        }

        QAction * ret = menu.exec(QCursor::pos());
        if(ret == 0)
            return;
        if(ret == info) {
            TwitterApiWhoisWidget *wd = new TwitterApiWhoisWidget(account, url.host(),  currentPost(), this);
            wd->show(QCursor::pos());
            return;
        } else if(ret == subscribe){
            if(isSubscribe) {
                blog->createFriendship(currentAccount(), url.host());
            } else {
                blog->destroyFriendship(currentAccount(), url.host());
            }
            return;
        }else if(ret == block){
            blog->blockUser(currentAccount(), url.host());
            return;
        } else if(ret == openInBrowser){
            Choqok::openUrl( QUrl( currentAccount()->microblog()->profileUrl(currentAccount(), url.host()) ) );
            return;
        } else if(ret == replyTo){
            emit reply( QString("@%1").arg(url.host()), QString() );
            return;
        } else if(ret == dMessage){
                blog->showDirectMessageDialog(account,url.host());
            return;
        }
        int type = ret->data().toInt();
        blog->searchBackend()->requestSearchResults(currentAccount(),
                                                    url.host(),
                                                    type);
    } else
        TwitterApiPostWidget::checkAnchor(url);
}