Ejemplo n.º 1
0
void JabberBrowser::stop(const QString &err)
{
    Command cmd;
    cmd->id			 = static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdUrl;
    cmd->text		 = I18N_NOOP("JID");
    cmd->icon		 = "run";
    cmd->bar_grp	 = 0x2000;
    cmd->flags		 = BTN_COMBO_CHECK;
    cmd->param		 = this;
    Event e(EventCommandChange, cmd);
    e.process();
    cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdInfo;
    cmd->flags	= (m_category.isEmpty() && m_type.isEmpty() && m_name.isEmpty() && m_features.isEmpty()) ? COMMAND_DISABLED : 0;
    cmd->param	= this;
    Event eNext(EventCommandDisabled, cmd);
    eNext.process();
    cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdSearch;
    cmd->flags	= haveFeature("jabber:iq:search") ? 0 : COMMAND_DISABLED;
    eNext.process();
    cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdRegister;
    cmd->flags	= haveFeature("jabber:iq:register") ? 0 : COMMAND_DISABLED;
    eNext.process();
    if (!err.isEmpty()) {
        Command cmd;
        cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdUrl;
        cmd->param	= this;
        Event eWidget(EventCommandWidget, cmd);
        QWidget *parent = (QWidget*)(eWidget.process());
        if (parent == NULL)
            parent = this;
        BalloonMsg::message(err, parent);
    }
    m_status->message(err);
}
Ejemplo n.º 2
0
void HistoryWindow::next()
{
    if (m_it == NULL)
        return;
    string state = m_it->state();
    Message *msg = NULL;
    if (m_bDirection){
        msg = --(*m_it);
    }else{
        msg = ++(*m_it);
    }
    if (++m_nMessages > CorePlugin::m_plugin->getHistoryPage()){
        if (msg){
            Command cmd;
            cmd->id		= CmdHistoryNext;
            cmd->flags  = 0;
            cmd->param	= (void*)m_id;
            Event eNext(EventCommandDisabled, cmd);
            eNext.process();
            msg = NULL;
            m_states.push_back(state);
        }
    }
    if (msg){
        m_view->addMessage(msg);
        m_progress->setProgress(m_nMessages);
        QTimer::singleShot(0, this, SLOT(next()));
        return;
    }
    delete m_progress;
    delete m_it;
    m_it = NULL;
    m_progress = NULL;
}
Ejemplo n.º 3
0
void JabberBrowser::go(const QString &url, const QString &node)
{
    setNavigation();
    Command cmd;
    setTitle();
    m_list->clear();
    cmd->id		= CmdBrowseInfo;
    cmd->flags	= COMMAND_DISABLED;
    cmd->param	= this;
    Event eNext(EventCommandDisabled, cmd);
    eNext.process();
    cmd->id		= CmdBrowseSearch;
    cmd->flags	= COMMAND_DISABLED;
    cmd->param	= this;
    eNext.process();
    cmd->id		= CmdRegister;
    cmd->flags	= COMMAND_DISABLED;
    cmd->param	= this;
    eNext.process();
    cmd->id		= CmdBrowseConfigure;
    cmd->flags	= COMMAND_DISABLED;
    cmd->param	= this;
    eNext.process();
    m_bInProcess = true;
    QListViewItem *item = new QListViewItem(m_list);
    item->setText(COL_JID, url);
    item->setText(COL_NAME, url);
    item->setText(COL_NODE, node);
    m_bError = false;
    unsigned mode = 0;
    if (m_client->getBrowseType() & BROWSE_DISCO){
        item->setText(COL_ID_DISCO_ITEMS, m_client->discoItems(url.utf8(), node.utf8()).c_str());
        item->setText(COL_ID_DISCO_INFO, m_client->discoInfo(url.utf8(), node.utf8()).c_str());
        mode = BROWSE_DISCO | BROWSE_INFO;
    }
    if (m_client->getBrowseType() & BROWSE_BROWSE){
        if (node.isEmpty()){
            item->setText(COL_ID_BROWSE, m_client->browse(url.utf8()).c_str());
            mode |= BROWSE_BROWSE;
        }
    }
    item->setText(COL_MODE, QString::number(mode));
    item->setPixmap(COL_NAME, Pict("empty"));
    cmd->id		= CmdUrl;
    cmd->param	= this;
    Event eWidget(EventCommandWidget, cmd);
    CToolCombo *cmbUrl = (CToolCombo*)(eWidget.process());
    if (cmbUrl)
        cmbUrl->setText(url);
    cmd->id		= CmdNode;
    CToolCombo *cmbNode = (CToolCombo*)(eWidget.process());
    if (cmbNode)
        cmbNode->setText(node);
	startProcess();
    if (item->text(COL_ID_DISCO_INFO).isEmpty())
        stop(i18n("Client offline"));
}
Ejemplo n.º 4
0
void HistoryWindow::next()
{
    if (m_it == NULL)
        return;
    time_t start;
    bool bAdd = false;
#ifndef WIN32
    unsigned n = m_view->paragraphs();
    if (n > 0)
        n--;
#endif
    time(&start);
    for (;;){
        string state = m_it->state();
        Message *msg = NULL;
        if (m_bDirection){
            msg = --(*m_it);
        }else{
            msg = ++(*m_it);
        }
        if (++m_nMessages > CorePlugin::m_plugin->getHistoryPage()){
            if (msg){
                Command cmd;
                cmd->id		= CmdHistoryNext;
                cmd->flags  = 0;
                cmd->param	= (void*)m_id;
                Event eNext(EventCommandDisabled, cmd);
                eNext.process();
                msg = NULL;
                m_states.push_back(state);
            }
        }
        if (msg == NULL)
            break;
        bAdd = true;
        m_view->addMessage(msg, false, false);
        time_t now;
        time(&now);
        if (now > start + 1)
            break;
    }
    if (bAdd){
#ifndef WIN32
        m_view->sync(n);
#endif
        m_progress->setProgress(m_nMessages);
        QTimer::singleShot(0, this, SLOT(next()));
        return;
    }
    delete m_progress;
    delete m_it;
    m_it = NULL;
    m_progress = NULL;
    log(L_DEBUG, "Stop");
}
Ejemplo n.º 5
0
void JabberBrowser::setNavigation()
{
    Command cmd;
    cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdBack;
    cmd->flags	= m_historyPos ? 0 : COMMAND_DISABLED;
    cmd->param	= this;
    Event eNext(EventCommandDisabled, cmd);
    eNext.process();
    cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdForward;
    cmd->flags	= (m_historyPos + 1 < (int)(m_history.size())) ? 0 : COMMAND_DISABLED;
    cmd->param	= this;
    eNext.process();
}
Ejemplo n.º 6
0
void JabberBrowser::setNavigation()
{
    Command cmd;
    cmd->id		= CmdBack;
    cmd->flags	= m_historyPos ? 0 : COMMAND_DISABLED;
    cmd->param	= this;
    Event eNext(EventCommandDisabled, cmd);
    eNext.process();
    cmd->id		= CmdForward;
    cmd->flags	= (m_historyPos + 1 < (int)(m_history.size())) ? 0 : COMMAND_DISABLED;
    cmd->param	= this;
    eNext.process();
}
Ejemplo n.º 7
0
void JabberBrowser::go(const QString &url, const QString &node)
{
    setNavigation();
    Command cmd;
    setTitle();
    m_list->clear();
    m_category	= "";
    m_type		= "";
    m_name      = "";
    m_features	= "";
    cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdInfo;
    cmd->flags	= COMMAND_DISABLED;
    cmd->param	= this;
    Event eNext(EventCommandDisabled, cmd);
    eNext.process();
    cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdSearch;
    cmd->flags	= COMMAND_DISABLED;
    cmd->param	= this;
    eNext.process();
    cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdRegister;
    cmd->flags	= COMMAND_DISABLED;
    cmd->param	= this;
    eNext.process();
    cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdConfigure;
    cmd->flags	= COMMAND_DISABLED;
    cmd->param	= this;
    eNext.process();
    m_id1 = m_client->discoItems(url.utf8(), node.utf8());
    m_id2 = m_client->discoInfo(url.utf8(), node.utf8());
    cmd->id			 = static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdUrl;
    cmd->text		 = I18N_NOOP("Stop");
    cmd->icon		 = "cancel";
    cmd->bar_grp	 = 0x2000;
    cmd->flags		 = BTN_COMBO_CHECK;
    cmd->param		 = this;
    Event e(EventCommandChange, cmd);
    e.process();
    cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdUrl;
    cmd->param	= this;
    Event eWidget(EventCommandWidget, cmd);
    CToolCombo *cmbUrl = (CToolCombo*)(eWidget.process());
    if (cmbUrl)
        cmbUrl->setText(url);
    cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdNode;
    CToolCombo *cmbNode = (CToolCombo*)(eWidget.process());
    if (cmbNode)
        cmbNode->setText(node);
    m_status->message(i18n("Process"));
    if (m_id1.empty())
        stop(i18n("Client offline"));
}
Ejemplo n.º 8
0
void HistoryWindow::next()
{
    if ( (m_it == NULL) )
        return;

    for (;;){
        string state = m_it->state();
        Message *msg = NULL;
        if (m_bDirection){
            msg = --(*m_it);
        }else{
            msg = ++(*m_it);
        }

        if (++m_nMessages > m_history_page_count){
            if (msg){
                Command cmd;
                cmd->id		= CmdHistoryNext;
                cmd->flags  = 0;
                cmd->param	= (void*)m_id;
                Event eNext(EventCommandDisabled, cmd);
                eNext.process();
                msg = NULL;
                if (m_page+1>=m_states.size())
                   m_states.push_back(state);
            }
        }

        if (msg == NULL)
            break;

        m_view->addMessage(msg, false, false);
        m_progress->setProgress(m_nMessages);
    }

    delete m_progress;
    delete m_it;
    m_it = NULL;
    m_progress = NULL;
    log(L_DEBUG, "Stop");
}
Ejemplo n.º 9
0
void JabberBrowser::currentChanged(QListViewItem*)
{
    Command cmd;
    cmd->id		= CmdBrowseInfo;
    cmd->flags	= m_list->currentItem() ? 0 : COMMAND_DISABLED;
    cmd->param	= this;
    Event eNext(EventCommandDisabled, cmd);
    eNext.process();
    cmd->id		= CmdBrowseSearch;
    cmd->flags	= haveFeature("jabber:iq:search") ? 0 : COMMAND_DISABLED;
    eNext.process();
    cmd->id		= CmdRegister;
    cmd->flags	= haveFeature("jabber:iq:register") ? 0 : COMMAND_DISABLED;
    eNext.process();
    cmd->id		= CmdBrowseConfigure;
    cmd->flags	= haveFeature("jabber:iq:data") ? 0 : COMMAND_DISABLED;
    eNext.process();
	QListViewItem *item = m_list->currentItem();
	if (item == NULL)
		return;
	loadItem(item);
}
Ejemplo n.º 10
0
void HistoryWindow::fill()
{
    log(L_DEBUG, "Fill");
    if (m_it == NULL)
        m_it = new HistoryIterator(m_id);
    if (m_progress == NULL){
        m_progress = new HistoryProgressBar(m_status);
        m_status->addWidget(m_progress, 1);
    }
    m_it->setFilter(m_filter);
    m_progress->setTotalSteps(CorePlugin::m_plugin->getHistoryPage());
    m_progress->setProgress(0);
    m_progress->show();
    m_nMessages = 0;
    if (m_bDirection){
        m_it->end();
    }else{
        m_it->begin();
    }
    if (m_states.size()){
        m_it->setState(m_states[m_page].c_str());
    }else{
        m_states.push_back(m_it->state());
    }
    m_view->setText(QString::null);
    QTimer::singleShot(0, this, SLOT(next()));
    Command cmd;
    cmd->id		= CmdHistoryNext;
    cmd->flags	= COMMAND_DISABLED;
    cmd->param	= (void*)m_id;
    Event eNext(EventCommandDisabled, cmd);
    eNext.process();
    cmd->id		= CmdHistoryPrev;
    cmd->flags  = (m_page > 0) ? 0 : COMMAND_DISABLED;
    Event ePrev(EventCommandDisabled, cmd);
    ePrev.process();
}