Esempio n. 1
0
void JabberAdd::startSearch()
{
    if (m_result == NULL)
        return;
    JabberClient *client = findClient(cmbServices->currentText().latin1());
    if (client == NULL)
        return;
    if (tabAdd->currentPageIndex() == 0){
        QString jid = edtID->text();
        if (client->add_contact(jid.utf8())){
            unsigned grp_id = 0;
            ContactList::GroupIterator it;
            Group *grp;
            unsigned nGrp = cmbGroup->currentItem();
            while ((grp = ++it) != NULL){
                if (grp->id() == 0)
                    continue;
                if (nGrp-- == 0){
                    grp_id = grp->id();
                    break;
                }
            }
            Contact *contact;
            JabberUserData *data = client->findContact(jid.utf8(), NULL, false, contact);
            if (data && (contact->getGroup() != grp_id)){
                contact->setGroup(grp_id);
                Event e(EventContactChanged, contact);
                e.process();
            }
        }else{
            m_result->setText(i18n("%1 already in contact list") .arg(jid));
        }
    }else if (tabAdd->currentPage()->inherits("JabberSearch")){
        JabberSearch *search = static_cast<JabberSearch*>(tabAdd->currentPage());
        QString condition = search->condition();
        string search_id = client->search(search->id(), NULL, condition.utf8());
        m_result->setSearch(client, search_id.c_str());
    }
}
Esempio n. 2
0
void JabberAdd::startSearch()
{
    if (m_result == NULL)
        return;
    JabberClient *client = findClient(cmbServices->currentText().latin1());
    if (client == NULL)
        return;
    if (tabAdd->currentPageIndex() == 0){
        QString jid = edtID->text();
        unsigned grp_id = 0;
        ContactList::GroupIterator it;
        Group *grp;
        unsigned nGrp = cmbGroup->currentItem();
        while ((grp = ++it) != NULL){
            if (grp->id() == 0)
                continue;
            if (nGrp-- == 0){
                grp_id = grp->id();
                break;
            }
        }
        if (client->add_contact(jid.utf8(), grp_id)){
            m_result->setText(i18n("%1 added to contact list") .arg(jid));
        }else{
            m_result->setText(i18n("%1 is already in contact list") .arg(jid));
        }
        if (m_wizard)
            m_wizard->setFinishEnabled(m_result, true);
    }else if (tabAdd->currentPage()->inherits("JabberSearch")){
        JabberSearch *search = static_cast<JabberSearch*>(tabAdd->currentPage());
        bool bXSearch;
        QString condition = search->condition(bXSearch);
        string search_id = client->search(search->id(), NULL, condition.utf8());
        m_result->setSearch(client, search_id.c_str(), bXSearch);
    }
}