示例#1
0
void ICQClient::processListQueue()
{
    for (;;){
        if ((sock == NULL) || (sock->isError())) return;
        if (listQueue.size() == 0) return;
        list_req lr = *listQueue.begin();
        ICQUser *u = getUser(lr.uin);
        if (u == NULL){
            listQueue.remove(lr);
            continue;
        }
        unsigned short userId = contacts.getUserId(u);
        string alias = u->Alias;
        if (*alias.c_str() == 0) alias = u->FirstName;
        if (*alias.c_str() == 0){
            char b[13];
            snprintf(b, sizeof(b), "%lu", u->Uin);
            alias = b;
        }
        ICQSetListEvent *e = new ICQSetListEvent(u->Uin, lr.list_type, lr.bSet);
        sendRoster(e,
                   lr.bSet ? ICQ_SNACxLISTS_CREATE : ICQ_SNACxLISTS_DELETE,
                   u->Uin, 0, userId, lr.list_type,
                   (lr.list_type == ICQ_IGNORE_LIST) ? "" : alias.c_str());
        return;
    }
}
示例#2
0
void ICQClientPrivate::sendRoster(ICQEvent *e,
                                  unsigned short cmd, unsigned long uin, unsigned short grp_id,
                                  unsigned short usr_id, unsigned short subCmd, const char *alias, bool waitAuth)
{
    char buff[13];
    snprintf(buff, sizeof(buff), "%lu", uin);
    sendRoster(e, cmd, buff, grp_id, usr_id, subCmd, alias, waitAuth);
}
示例#3
0
void ICQClientPrivate::setInList(ICQUser *u, bool bSet, unsigned short list_type)
{
    if ((sock == NULL) || (sock->isError())) return;
    unsigned short userId = client->contacts.getUserId(u, list_type, true);
    ICQSetListEvent *e = new ICQSetListEvent(u->Uin, list_type, bSet, bSet ? userId : 0);
    sendRoster(e, bSet ? ICQ_SNACxLISTS_CREATE : ICQ_SNACxLISTS_DELETE,
               u->Uin, 0, userId, list_type, "");
}
示例#4
0
void ICQClient::createGroup(const char *name)
{
    ICQGroup *grp = new ICQGroup;
    unsigned short id = contacts.getGroupId(grp);
    CreateGroupEvent *e = new CreateGroupEvent(grp);
    snac(ICQ_SNACxFAM_LISTS, ICQ_SNACxLISTS_EDIT);
    sendPacket();
    sendRoster(e, ICQ_SNACxLISTS_CREATE, name, id, 0, ICQ_GROUPS);
    snac(ICQ_SNACxFAM_LISTS, ICQ_SNACxLISTS_SAVE);
    sendPacket();
}
示例#5
0
void ICQClientPrivate::createGroup(const char *name)
{
    if (m_state != Logged) return;
    ICQGroup *grp = client->createGroup();
    unsigned short id = client->contacts.getGroupId(grp);
    CreateGroupEvent *e = new CreateGroupEvent(grp);
    snac(ICQ_SNACxFAM_LISTS, ICQ_SNACxLISTS_EDIT);
    sendPacket();
    sendRoster(e, ICQ_SNACxLISTS_CREATE, name, id, 0, ICQ_GROUPS);
    snac(ICQ_SNACxFAM_LISTS, ICQ_SNACxLISTS_SAVE);
    sendPacket();
}
示例#6
0
void ICQClient::renameUser(ICQUser *u, const char *alias)
{
    if ((u->GrpId() == 0) || (u->Uin() >= UIN_SPECIAL)){
        u->Alias = alias;
        ICQEvent e(EVENT_INFO_CHANGED, u->Uin);
        process_event(&e);
        return;
    }
    if (m_state != Logged) return;
    RenameUserEvent *e = new RenameUserEvent(u->Uin(), alias);
    sendRoster(e, ICQ_SNACxLISTS_RENAME, u->Uin, u->GrpId(), u->Id(), 0, alias, u->WaitAuth());
}
示例#7
0
void ICQClientPrivate::moveUser(ICQUser *u, ICQGroup *g)
{
    if (m_state != Logged) return;
    unsigned short id = client->contacts.getUserId(u, 0, false);
    MoveUserEvent *e = new MoveUserEvent(u->Uin, g->Id);
    if (!u->GrpId){
        snac(ICQ_SNACxFAM_LISTS, ICQ_SNACxLISTS_CREATE_USER);
        sock->writeBuffer.packUin(u->Uin);
        sock->writeBuffer << 0x00000000L;
        sendPacket();
    }
    snac(ICQ_SNACxFAM_LISTS, ICQ_SNACxLISTS_EDIT);
    sendPacket();
    sendRoster(e, ICQ_SNACxLISTS_CREATE, u->Uin, g->Id, id, 0, u->Alias.c_str(), u->WaitAuth);
}
示例#8
0
void ICQClient::deleteUser(ICQUser *u)
{
    if (u->inIgnore()) setInIgnore(u, false);
    if (u->inInvisible()) setInInvisible(u, false);
    if (u->inVisible()) setInVisible(u, false);
    if ((u->GrpId() == 0) || (u->Uin() >= UIN_SPECIAL)){
        contacts.users.remove(u);
        ICQEvent e(EVENT_USER_DELETED, u->Uin);
        process_event(&e);
        return;
    }
    if (m_state != Logged) return;
    DeleteUserEvent *e = new DeleteUserEvent(u->Uin());
    sendRoster(e, ICQ_SNACxLISTS_DELETE, u->Uin, u->GrpId(), u->Id(), 0, u->Alias.c_str(), u->WaitAuth());
}
示例#9
0
void ICQClient::processListQueue()
{
    for (;;){
        if (listQueue.size() == 0) return;
        list_req lr = *listQueue.begin();
        ICQUser *u = getUser(lr.uin);
        if (u == NULL){
            listQueue.remove(lr);
            continue;
        }
        unsigned short userId = contacts.getUserId(u);
        ICQSetListEvent *e = new ICQSetListEvent(u->Uin(), lr.list_type, lr.bSet);
        sendRoster(e,
                   lr.bSet ? ICQ_SNACxLISTS_CREATE : ICQ_SNACxLISTS_DELETE,
                   u->Uin, 0, userId, lr.list_type);
        return;
    }
}
示例#10
0
void ICQClientPrivate::deleteGroup(ICQGroup *g)
{
    if (m_state != Logged) return;
    unsigned short id = client->contacts.getGroupId(g);
    if (client->contacts.groups.size() <= 1) return;
    for (list<ICQUser*>::iterator u = client->contacts.users.begin(); u != client->contacts.users.end() ; u++){
        if ((*u)->GrpId != id) continue;
        moveUser(*u, (client->contacts.groups[0] == g) ? client->contacts.groups[1] : client->contacts.groups[0]);
    }
    vector<ICQGroup*>::iterator it;
    for (it = client->contacts.groups.begin(); it != client->contacts.groups.end(); it++)
        if (*it == g) break;
    if (it == client->contacts.groups.end()) return;
    DeleteGroupEvent *e = new DeleteGroupEvent(id);
    snac(ICQ_SNACxFAM_LISTS, ICQ_SNACxLISTS_EDIT);
    sendPacket();
    sendRoster(e, ICQ_SNACxLISTS_DELETE, g->Name.c_str(), id, 0, ICQ_GROUPS);
    snac(ICQ_SNACxFAM_LISTS, ICQ_SNACxLISTS_SAVE);
    sendPacket();
}
示例#11
0
void ICQClient::moveUser(ICQUser *u, ICQGroup *g)
{
    unsigned short id = contacts.getUserId(u);
    MoveUserEvent *e = new MoveUserEvent(u->Uin, g->Id());
    if (u->Uin() >= UIN_SPECIAL){
        if (e->process(this, 0))
            process_event(e);
        delete e;
        return;
    }
    if (m_state != Logged) return;
    if (!u->GrpId()){
        snac(ICQ_SNACxFAM_LISTS, ICQ_SNACxLISTS_CREATE_USER);
        writeBuffer.packUin(u->Uin);
        writeBuffer << 0x00000000L;
        sendPacket();
    }
    snac(ICQ_SNACxFAM_LISTS, ICQ_SNACxLISTS_EDIT);
    sendPacket();
    sendRoster(e, ICQ_SNACxLISTS_CREATE, u->Uin, g->Id(), id, 0, u->Alias.c_str(), u->WaitAuth());
}
示例#12
0
void ICQClientPrivate::renameGroup(ICQGroup *g, const char *name)
{
    if (m_state != Logged) return;
    RenameGroupEvent *e = new RenameGroupEvent(g->Id, name);
    sendRoster(e, ICQ_SNACxLISTS_RENAME, name, g->Id, 0, ICQ_GROUPS);
}
示例#13
0
void ICQClientPrivate::deleteUser(ICQUser *u)
{
    if (m_state != Logged) return;
    DeleteUserEvent *e = new DeleteUserEvent(u->Uin);
    sendRoster(e, ICQ_SNACxLISTS_DELETE, u->Uin, u->GrpId, u->Id, 0, u->Alias.c_str(), u->WaitAuth);
}
示例#14
0
void ICQClientPrivate::renameUser(ICQUser *u, const char *alias)
{
    if (m_state != Logged) return;
    RenameUserEvent *e = new RenameUserEvent(u->Uin, alias);
    sendRoster(e, ICQ_SNACxLISTS_RENAME, u->Uin, u->GrpId, u->Id, 0, alias, u->WaitAuth);
}