예제 #1
0
void *ICQSearchResult::processEvent(Event *e)
{
    if ((e->type() > EventUser) && ((m_id1 != SEARCH_DONE) || (m_id2 != SEARCH_DONE))){
        if (e->type() == EventSearch){
            SearchResult *result = (SearchResult*)(e->param());
            if ((result->client == m_client) && (
                        (result->id == m_id1) || (result->id == m_id2))){
                new UserTblItem(tblUser, m_client, &result->data);
                m_nFound++;
                setStatus();
            }
        }
        if (e->type() == EventSearchDone){
            SearchResult *result = (SearchResult*)(e->param());
            if (result->client == m_client){
                if (result->id == m_id1)
                    setRequestId(SEARCH_DONE, m_id2);
                if (result->id == m_id2)
                    setRequestId(m_id1, SEARCH_DONE);
            }
        }
    }
    if (e->type() == EventCommandExec){
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->menu_id == MenuSearchResult){
            Contact *contact;
            if (cmd->id == CmdIcqSendMessage){
                contact = createContact(CONTACT_TEMP);
                if (!contact) return NULL;
                Message *msg = new Message(MessageGeneric);
                msg->setContact(contact->id());
                Event e(EventOpenMessage, &msg);
                e.process();
                delete msg;
            }
            if (cmd->id == CmdInfo){
                contact = createContact(CONTACT_TEMP);
                if (!contact) return NULL;
                m_client->addFullInfoRequest(atol(tblUser->currentItem()->text(0).latin1()), true);
                Command cmd;
                cmd->id = CmdInfo;
                cmd->menu_id = MenuContact;
                cmd->param   = (void*)contact->id();
                Event e(EventCommandExec, cmd);
                e.process();
            }
            return e->param();
        }
        if (cmd->menu_id == MenuIcqGroups){
            Contact *contact = createContact(0);
            if (!contact) return NULL;
            contact->setGroup(cmd->id - 1);
            Event eContact(EventContactChanged, contact);
            eContact.process();
            return e->param();
        }
    }
    if (e->type() == EventCheckState){
        CommandDef *cmd = (CommandDef*)(e->param());
        if ((cmd->menu_id == MenuIcqGroups) &&
                (cmd->id == CmdGroups)){
            unsigned n = 1;
            ContactList::GroupIterator it;
            while (++it)
                n++;
            CommandDef *cmds = new CommandDef[n];
            memset(cmds, 0, sizeof(CommandDef) * n);
            n = 0;
            it.reset();
            Group *grp;
            while ((grp = ++it) != NULL){
                cmds[n].id		 = grp->id() + 1;
                cmds[n].text	 = "_";
                QString name = grp->getName();
                if (grp->id() == 0)
                    name = i18n("Not in list");
                cmds[n].text_wrk = strdup(name.utf8());
                n++;
            }
            cmd->param = cmds;
            cmd->flags |= COMMAND_RECURSIVE;
            return e->param();
        }
    }
    return NULL;
}
예제 #2
0
void *AddResult::processEvent(Event *e)
{
    if (e->type() == EventCommandExec){
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->menu_id == MenuSearchResult){
            Contact *contact;
            if (cmd->id == CmdJabberMessage){
                contact = createContact(CONTACT_TEMP);
                if (!contact) return NULL;
                Message *msg = new Message(MessageGeneric);
                msg->setContact(contact->id());
                Event e(EventOpenMessage, &msg);
                e.process();
                delete msg;
            }
            if (cmd->id == CmdInfo){
                JabberUserData *data;
                contact = createContact(CONTACT_TEMP, &data);
                if (!contact) return NULL;
                m_client->updateInfo(contact, data);
                Command cmd;
                cmd->id = CmdInfo;
                cmd->menu_id = MenuContact;
                cmd->param   = (void*)contact->id();
                Event e(EventCommandExec, cmd);
                e.process();
            }
            return e->param();
        }
        if (cmd->menu_id == MenuJabberGroups){
            Contact *contact = createContact(0);
            if (!contact) return NULL;
            contact->setGroup(cmd->id - 1);
            Event eContact(EventContactChanged, contact);
            eContact.process();
            return e->param();
        }
    }
    if (e->type() == EventCheckState){
        CommandDef *cmd = (CommandDef*)(e->param());
        if ((cmd->menu_id == MenuJabberGroups) &&
                (cmd->id == CmdGroups)){
            unsigned n = 1;
            ContactList::GroupIterator it;
            while (++it)
                n++;
            CommandDef *cmds = new CommandDef[n];
            memset(cmds, 0, sizeof(CommandDef) * n);
            n = 0;
            it.reset();
            Group *grp;
            while ((grp = ++it) != NULL){
                cmds[n].id		 = grp->id() + 1;
                cmds[n].text	 = "_";
                QString name = grp->getName();
                if (grp->id() == 0)
                    name = i18n("Not in list");
                cmds[n].text_wrk = strdup(name.utf8());
                n++;
            }
            cmd->param = cmds;
            cmd->flags |= COMMAND_RECURSIVE;
            return e->param();
        }
    }
    if (e->type() == EventSearch){
        JabberSearchData *data = (JabberSearchData*)(e->param());
        if (m_searchId == data->ID.ptr){
            if (m_bXSearch){
                if (data->JID.ptr){
                    m_nFound++;
                    lblStatus->setText(i18n("Search") + foundStatus());
                    QListViewItem *item = new QListViewItem(tblUser);
                    item->setText(0, QString::fromUtf8(data->JID.ptr));
                    for (unsigned col = 0; col < data->nFields.value; col++)
                        item->setText(col + 1, QString::fromUtf8(get_str(data->Fields, col)));
                }else{
                    for (unsigned col = 0; col < data->nFields.value; col++)
                        tblUser->addColumn(QString::fromUtf8(get_str(data->Fields, col)));
                    tblUser->adjustColumn();
                }
            }else{
                m_nFound++;
                lblStatus->setText(i18n("Search") + foundStatus());
                QListViewItem *item = new QListViewItem(tblUser);
                if (data->JID.ptr)
                    item->setText(0, QString::fromUtf8(data->JID.ptr));
                if (data->Nick.ptr)
                    item->setText(1, QString::fromUtf8(data->Nick.ptr));
                if (data->First.ptr)
                    item->setText(2, QString::fromUtf8(data->First.ptr));
                if (data->Last.ptr)
                    item->setText(3, QString::fromUtf8(data->Last.ptr));
                if (data->EMail.ptr)
                    item->setText(4, QString::fromUtf8(data->EMail.ptr));
            }
        }
    }
    if ((e->type() == EventSearchDone) && (m_searchId == (const char*)(e->param()))){
        lblStatus->setText(i18n("Search done") + foundStatus());
        m_searchId = "";
        tblUser->adjustColumn();
        currentChanged(NULL);
    }
    return NULL;
}