void ICQSecure::deleteInvisibleItem(Q3ListViewItem *item)
{
    Contact *contact = getContacts()->contact(item->text(4).toUInt());
    if (contact) {
        ICQUserData *data;
        ClientDataIterator it(contact->clientData);
        while ((data = (ICQUserData*)(++it)) != NULL){
            data->InvisibleId.value = 0;
            Event eContact(EventContactChanged, contact);
            eContact.process();
        }
    }
}
Example #2
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;
}
Example #3
0
void RostersRequest::element_end(const char *el)
{
    if (strcmp(el, "group") == 0){
        m_data = NULL;
        return;
    }
    if (strcmp(el, "item") == 0){
        bool bChanged = false;
        JabberListRequest *lr = m_client->findRequest(m_jid.c_str(), false);
        Contact *contact;
        JabberUserData *data = m_client->findContact(m_jid.c_str(), NULL, m_name.c_str(), false, contact);
        if (data == NULL){
            if (lr && lr->bDelete){
                m_client->findRequest(m_jid.c_str(), true);
            }else{
                bChanged = true;
                data = m_client->findContact(m_jid.c_str(), NULL, m_name.c_str(), true, contact);
                if (m_bSubscription){
                    contact->setTemporary(CONTACT_TEMP);
                    Event eContact(EventContactChanged, contact);
                    eContact.process();
                    m_client->auth_request(m_jid.c_str(), MessageAuthRequest, m_subscription.c_str(), true);
                    data = m_client->findContact(m_jid.c_str(), NULL, m_name.c_str(), false, contact);
                }
            }
        }
        if (data == NULL)
            return;
        if (data->Subscribe != m_subscribe){
            bChanged = true;
            data->Subscribe = m_subscribe;
        }
        data->bChecked = true;
        if (lr == NULL){
            unsigned grp = 0;
            if (!m_grp.empty()){
                Group *group = NULL;
                ContactList::GroupIterator it;
                while ((group = ++it) != NULL){
                    if (m_grp == (const char*)(group->getName().utf8())){
                        grp = group->id();
                        break;
                    }
                }
                if (group == NULL){
                    group = getContacts()->group(0, true);
                    group->setName(QString::fromUtf8(m_grp.c_str()));
                    grp = group->id();
                    Event e(EventGroupChanged, group);
                    e.process();
                }
            }
            if (contact->getGroup() != grp){
                if (grp == 0){
                    void *d = NULL;
                    ClientDataIterator it_d(contact->clientData);
                    while ((d = ++it_d) != NULL){
                        if (d != data)
                            break;
                    }
                    if (d){
                        grp = contact->getGroup();
                        Group *group = getContacts()->group(grp);
                        if (group)
                            m_client->listRequest(data, contact->getName().utf8(), group->getName().utf8(), false);
                    }
                }
                contact->setGroup(grp);
                bChanged = true;
            }
        }
        if (bChanged){
            Event e(EventContactChanged, contact);
            e.process();
        }
    }
}
Example #4
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;
}