예제 #1
0
void SynPacket::answer(const char *_cmd, vector<string> &args)
{
    string cmd = _cmd;
    if (cmd == "SYN"){
        m_ver = atol(args[0].c_str());
        if (m_ver != m_client->getListVer()){
            ContactList::GroupIterator itg;
            Group *grp;
            while ((grp = ++itg) != NULL){
                MSNUserData *data;
                ClientDataIterator it(grp->clientData, m_client);
                while ((data = (MSNUserData*)(++it)) != NULL){
                    data->sFlags = data->Flags;
                    data->Flags  = 0;
                }
            }
            ContactList::ContactIterator itc;
            Contact *contact;
            while ((contact = ++itc) != NULL){
                MSNUserData *data;
                ClientDataIterator it(contact->clientData, m_client);
                while ((data = (MSNUserData*)(++it)) != NULL){
                    data->sFlags = data->Flags;
                    data->Flags = 0;
                }
            }
        }
    }
    if (cmd == "LSG"){
        if (args.size() < 5){
            log(L_WARN, "Bad LSG size");
            return;
        }
        unsigned id = atol(args[3].c_str());
        if (id == 0)
            return;
        Group *grp;
        string grp_name;
        grp_name = m_client->unquote(QString::fromUtf8(args[4].c_str())).utf8();
        MSNListRequest *lr = m_client->findRequest(id, LR_GROUPxREMOVED);
        if (lr)
            return;
        MSNUserData *data = m_client->findGroup(id, NULL, grp);
        if (data){
            lr = m_client->findRequest(grp->id(), LR_GROUPxCHANGED);
            if (lr){
                data->sFlags |= MSN_CHECKED;
                return;
            }
        }
        data = m_client->findGroup(id, grp_name.c_str(), grp);
        data->sFlags |= MSN_CHECKED;
    }
    if (cmd == "LST"){
        if (args.size() < 6){
            log(L_WARN, "Bad size for LST");
            return;
        }
        string mail;
        mail = m_client->unquote(QString::fromUtf8(args[4].c_str())).utf8();
        string name;
        name = m_client->unquote(QString::fromUtf8(args[5].c_str())).utf8();
        Contact *contact;
        MSNListRequest *lr = m_client->findRequest(mail.c_str(), LR_CONTACTxREMOVED);
        if (lr)
            return;
        bool bNew = false;
        MSNUserData *data = m_client->findContact(mail.c_str(), contact);
        if (data == NULL){
            data = m_client->findContact(mail.c_str(), name.c_str(), contact);
            bNew = true;
        }else{
            set_str(&data->EMail, mail.c_str());
            set_str(&data->ScreenName, name.c_str());
        }
        data->sFlags |= MSN_CHECKED;
        lr = m_client->findRequest(mail.c_str(), LR_CONTACTxCHANGED);
        if (args[0] == "FL"){
            unsigned grp = atol(args[6].c_str());
            data->Group = grp;
            data->Flags |= MSN_FORWARD;
            Group *group = NULL;
            m_client->findGroup(grp, NULL, group);
            if ((lr == NULL) && group && (group->id() != contact->getGroup())){
                unsigned grp = group->id();
                if (grp == 0){
                    void *d;
                    ClientDataIterator it_d(contact->clientData);
                    while ((d = ++it_d) != NULL){
                        if (d != data)
                            break;
                    }
                    if (d){
                        grp = contact->getGroup();
                        m_client->findRequest(data->EMail, LR_CONTACTxCHANGED, true);
                        MSNListRequest lr;
                        lr.Type = LR_CONTACTxCHANGED;
                        lr.Name = data->EMail;
                        m_client->m_requests.push_back(lr);
                        m_client->processRequests();
                    }
                }
                contact->setGroup(grp);
                Event e(EventContactChanged, contact);
                e.process();
            }
            return;
        }
        if (args[0] == "RL"){
            if (((data->sFlags & MSN_REVERSE) == 0) && m_client->getListVer())
                m_client->auth_message(contact, MessageAdded, data);
            data->Flags |= MSN_REVERSE;
            return;
        }
        if (args[0] == "AL"){
            data->Flags |= MSN_ACCEPT;
            return;
        }
        if (args[0] == "BL"){
            data->Flags |= MSN_BLOCKED;
            if ((lr == NULL) && !contact->getIgnore()){
                contact->setIgnore(true);
                Event e(EventContactChanged, contact);
                e.process();
            }
            return;
        }
    }
}
예제 #2
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();
        }
    }
}
예제 #3
0
bool SynPacket::answer(const char *_cmd, vector<string> &args)
{
    string cmd = _cmd;
    if (cmd == "SYN"){
        m_ver = atol(args[0].c_str());
        if (m_ver == m_client->getListVer())
            return false;
        ContactList::GroupIterator itg;
        Group *grp;
        while ((grp = ++itg) != NULL){
            MSNUserData *data;
            ClientDataIterator it(grp->clientData, m_client);
            while ((data = (MSNUserData*)(++it)) != NULL){
                data->sFlags = data->Flags;
                data->Flags  = 0;
            }
        }
        ContactList::ContactIterator itc;
        Contact *contact;
        while ((contact = ++itc) != NULL){
            MSNUserData *data;
            ClientDataIterator it(contact->clientData, m_client);
            while ((data = (MSNUserData*)(++it)) != NULL){
                data->sFlags = data->Flags;
                data->Flags = 0;
            }
        }
        return true;
    }
    if (cmd == "GTC")
        return true;
    if (cmd == "BLP")
        return true;
    if (cmd == "PRP"){
        if (args.size() < 2){
            log(L_WARN, "Bad PRP size");
            return true;
        }
        if (args[0] == "PHH")
            set_str(&m_client->data.owner.PhoneHome, m_client->unquote(QString::fromUtf8(args[1].c_str())).utf8());
        if (args[0] == "PHW")
            set_str(&m_client->data.owner.PhoneWork, m_client->unquote(QString::fromUtf8(args[1].c_str())).utf8());
        if (args[0] == "PHM")
            set_str(&m_client->data.owner.PhoneMobile, m_client->unquote(QString::fromUtf8(args[1].c_str())).utf8());
        if (args[0] == "MBE")
            m_client->data.owner.Mobile = (args[1] == "Y");
        return true;
    }
    if (cmd == "BPR"){
        if (args.size() < 2){
            log(L_WARN, "Bad BPR size");
            return true;
        }
        if (m_data == NULL){
            log(L_WARN, "BRP without LST");
            return true;
        }
        if (args[0] == "PHH")
            set_str(&m_data->PhoneHome, m_client->unquote(QString::fromUtf8(args[1].c_str())).utf8());
        if (args[0] == "PHW")
            set_str(&m_data->PhoneWork, m_client->unquote(QString::fromUtf8(args[1].c_str())).utf8());
        if (args[0] == "PHM")
            set_str(&m_data->PhoneMobile, m_client->unquote(QString::fromUtf8(args[1].c_str())).utf8());
        if (args[0] == "MBE")
            m_data->Mobile = (args[1] == "Y");
        return true;
    }
    if (cmd == "LSG"){
        if (args.size() < 3){
            log(L_WARN, "Bad LSG size");
            return true;
        }
        unsigned id = atol(args[0].c_str());
        if (id == 0)
            return true;
        Group *grp;
        string grp_name;
        grp_name = m_client->unquote(QString::fromUtf8(args[1].c_str())).utf8();
        MSNListRequest *lr = m_client->findRequest(id, LR_GROUPxREMOVED);
        if (lr)
            return true;
        MSNUserData *data = m_client->findGroup(id, NULL, grp);
        if (data){
            lr = m_client->findRequest(grp->id(), LR_GROUPxCHANGED);
            if (lr){
                data->sFlags |= MSN_CHECKED;
                return true;
            }
        }
        data = m_client->findGroup(id, grp_name.c_str(), grp);
        data->sFlags |= MSN_CHECKED;
        return true;
    }
    if (cmd == "LST"){
        if (m_data){
            Contact *contact;
            if (m_client->findContact(m_data->EMail, contact)){
                m_client->setupContact(contact, m_data);
                Event e(EventContactChanged, contact);
                e.process();
            }
        }
        if (args.size() < 3){
            log(L_WARN, "Bad size for LST");
            return true;
        }
        string mail;
        mail = m_client->unquote(QString::fromUtf8(args[0].c_str())).utf8();
        string name;
        name = m_client->unquote(QString::fromUtf8(args[1].c_str())).utf8();
        Contact *contact;
        MSNListRequest *lr = m_client->findRequest(mail.c_str(), LR_CONTACTxREMOVED);
        if (lr)
            return true;
        bool bNew = false;
        m_data = m_client->findContact(mail.c_str(), contact);
        if (m_data == NULL){
            m_data = m_client->findContact(mail.c_str(), name.c_str(), contact);
            bNew = true;
        }else{
            set_str(&m_data->EMail, mail.c_str());
            set_str(&m_data->ScreenName, name.c_str());
            if (name != (const char*)(contact->getName().utf8()))
                contact->setName(QString::fromUtf8(name.c_str()));
        }
        m_data->sFlags |= MSN_CHECKED;
        lr = m_client->findRequest(mail.c_str(), LR_CONTACTxCHANGED);
        unsigned grp = NO_GROUP;
        if (args.size() > 3)
            grp = atol(args[3].c_str());
        m_data->Group = grp;
        m_data->Flags |= MSN_FORWARD;
        set_str(&m_data->PhoneHome, NULL);
        set_str(&m_data->PhoneWork, NULL);
        set_str(&m_data->PhoneMobile, NULL);
        m_data->Mobile = false;
        Group *group = NULL;
        if ((grp == 0) || (grp == NO_GROUP)){
            group = getContacts()->group(0);
        }else{
            m_client->findGroup(grp, NULL, group);
        }
        if ((lr == NULL) && group && (group->id() != contact->getGroup())){
            unsigned grp = group->id();
            if (grp == 0){
                void *d;
                ClientDataIterator it_d(contact->clientData);
                while ((d = ++it_d) != NULL){
                    if (d != m_data)
                        break;
                }
                if (d){
                    grp = contact->getGroup();
                    m_client->findRequest(m_data->EMail, LR_CONTACTxCHANGED, true);
                    MSNListRequest lr;
                    lr.Type = LR_CONTACTxCHANGED;
                    lr.Name = m_data->EMail;
                    m_client->m_requests.push_back(lr);
                }
            }
            contact->setGroup(grp);
        }
        return true;
    }
    bDone = true;
    return false;
}