Examples of MsnContactListImpl


Examples of net.sf.jml.impl.MsnContactListImpl

        // todo if something missing throw failed event
        if(el == null || el.getChildNodes().getLength() > 0)
            return;

        MsnContactListImpl contactList = (MsnContactListImpl) session
                .getMessenger().getContactList();

        MsnContactImpl contact = (MsnContactImpl)contactList.getContactByEmail(email);
        contact.setInList(MsnList.AL, true);
        contact.setInList(MsnList.BL, false);
    }
View Full Code Here

Examples of net.sf.jml.impl.MsnContactListImpl

        contact.setInList(MsnList.BL, false);
    }

    public void copyFriend(Email email, String groupId)
    {
        MsnContactListImpl contactList = (MsnContactListImpl) session
                .getMessenger().getContactList();

        MsnContactImpl contact = (MsnContactImpl)contactList.getContactByEmail(email);

        StringBuilder mess = new StringBuilder();

        mess.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
        mess.append("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"");
        mess.append("               xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
        mess.append("               xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"");
        mess.append("               xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\">");
        mess.append("<soap:Header>");
        mess.append("    <ABApplicationHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">");
        mess.append("        <ApplicationId>996CDE1E-AA53-4477-B943-2BE802EA6166</ApplicationId>");
        mess.append("        <IsMigration>false</IsMigration>");
        mess.append("        <PartnerScenario>GroupSave</PartnerScenario>");
        mess.append("    </ABApplicationHeader>");
        mess.append("    <ABAuthHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">");
        mess.append("        <ManagedGroupRequest>false</ManagedGroupRequest>");
        mess.append("        <TicketToken>" + sso.getContactTicket().replaceAll("&", "&amp;") + "</TicketToken>");
        mess.append("    </ABAuthHeader>");
        mess.append("</soap:Header>");
        mess.append("<soap:Body>");

        mess.append("    <ABGroupContactAdd xmlns=\"http://www.msn.com/webservices/AddressBook\">");
        mess.append("        <abId>00000000-0000-0000-0000-000000000000</abId>");
        mess.append("        <contacts><Contact><contactId>" + contact.getId() + "</contactId></Contact></contacts>");

        mess.append("        <groupFilter><groupIds>");
        mess.append("           <guid>" + groupId + "</guid>");
        mess.append("        </groupIds></groupFilter>");
        mess.append("    </ABGroupContactAdd>");

        mess.append("</soap:Body>");
        mess.append("</soap:Envelope>");

        String res = sendRequest(
            mess.toString(), addressbook_url, addressbook_action_groupContactAdd, "POST");

        DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance();
        dbfactory.setIgnoringComments(true);
        DocumentBuilder docBuilder;
        Document doc;
        try
        {

            docBuilder = dbfactory.newDocumentBuilder();

            ByteArrayInputStream in = new ByteArrayInputStream(res.getBytes("UTF-8"));
            doc = docBuilder.parse(in);
        }
        catch (ParserConfigurationException ex)
        {
            logger.error("", ex);
            return;
        }catch (SAXException ex)
        {
            logger.error("", ex);
            return;
        }catch (IOException ex)
        {
            logger.error("", ex);
            return;
        }

        Element el =
            XmlUtils.locateElement(
                doc.getDocumentElement(),
                "ABGroupContactAddResponse",
                "xmlns",
                "http://www.msn.com/webservices/AddressBook");

        // todo if something missing throw failed event
        if(el == null)
            return;

        el = XmlUtils.findChildByChain(el, new String[]{"ABGroupContactAddResult", "guid"});

        if(el != null)
        {
            contact.addBelongGroup(groupId);

            MsnGroup group = contactList.getGroup(groupId);

            ((AbstractMessenger) session.getMessenger())
                .fireContactAddInGroupCompleted(contact, group);
        }
    }
View Full Code Here

Examples of net.sf.jml.impl.MsnContactListImpl

        }
    }

    public void moveFriend(Email email, String srcGroupId, String destGroupId)
    {
        MsnContactListImpl contactList = (MsnContactListImpl) session
                .getMessenger().getContactList();
        MsnContact contact = contactList.getContactByEmail(email);

        copyFriend(email, destGroupId);
        removeFriend(MsnList.FL, email, contact.getId(), srcGroupId);
    }
View Full Code Here

Examples of net.sf.jml.impl.MsnContactListImpl

    @Override
  protected void messageReceived(MsnSession session) {
        super.messageReceived(session);

        MsnContactListImpl contactList = (MsnContactListImpl) session
                .getMessenger().getContactList();
        MsnList list = getList();

        //   Update contact list
        if (list == MsnList.RL) {
            MsnContactImpl contact = (MsnContactImpl) contactList
                    .getContactByEmail(getEmail());
            if (contact != null) {
                contact.setInList(MsnList.RL, false);
                ((AbstractMessenger) session.getMessenger())
                        .fireContactRemovedMe(contact);
            }
        } else {
            MsnContactImpl contact;
            if (list == MsnList.FL || protocol.before(MsnProtocol.MSNP10)) {
                contact = (MsnContactImpl) contactList.getContactById(getId());
            }
            else {
                contact = (MsnContactImpl) contactList.getContactByEmail(getEmail());
            }
            if (contact != null) {
                contact.setInList(list, false);
                if (contact.getListNumber() == 0) { //Not in any group, delete from contact list
                    contactList.removeContactByEmail(contact.getEmail());
                }
                if (list == MsnList.FL) { //In FL, remove user from the group.
                    MsnGroup group = contactList.getGroup(getGroupId());
                    contact.removeBelongGroup(getGroupId());
                   
                    if(group == null)
                        ((AbstractMessenger) session.getMessenger())
                                .fireContactRemoveCompleted(contact, MsnList.FL);
View Full Code Here

Examples of net.sf.jml.impl.MsnContactListImpl

    @Override
  protected void messageReceived(MsnSession session) {
        super.messageReceived(session);

        MsnContactListImpl contactList = (MsnContactListImpl) session
                .getMessenger().getContactList();
        Email email = getEmail();
        MsnList list = getList();

        //    Update contact list
        MsnContactImpl contact = (MsnContactImpl) contactList
                .getContactByEmail(email);
        if (contact == null) {
            contact = new MsnContactImpl(contactList);
            contact.setEmail(email);
            contact.setFriendlyName(getFriendlyName());
            contact.setDisplayName(contact.getFriendlyName());
            contactList.addContact(contact);
        }
        contact.setInList(list, true);

        //Added to FL, so need to added to corresponding group.
        if (list == MsnList.FL) {
View Full Code Here

Examples of net.sf.jml.impl.MsnContactListImpl

    }

    @Override
  protected void messageReceived(MsnSession session) {
        super.messageReceived(session);
        MsnContactListImpl contactList = (MsnContactListImpl) session
                .getMessenger().getContactList();
        MsnGroupImpl group = (MsnGroupImpl) contactList.getGroup(getGroupId());

        if (group != null) {
            group.clear();
            contactList.removeGroup(getGroupId());

            ((AbstractMessenger) session.getMessenger())
                    .fireGroupRemoveCompleted(group);
        }
    }
View Full Code Here

Examples of net.sf.jml.impl.MsnContactListImpl

        if(chunk == null || chunk.length == 0)
            return;

        try
        {
            MsnContactListImpl contactList = (MsnContactListImpl) session
                .getMessenger().getContactList();

            DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance();
            dbfactory.setIgnoringComments(true);
            DocumentBuilder docBuilder = dbfactory.newDocumentBuilder();

            ByteArrayInputStream in = new ByteArrayInputStream(chunk);
            Document doc = docBuilder.parse(in);
            Element rootEl = doc.getDocumentElement();

            String domain =
                XmlUtils.findChild(rootEl, "d").getAttribute("n");

            String contactName =
                XmlUtils.findChildByChain(rootEl, new String[]{"d", "c"}).getAttribute("n");
            String type =
                XmlUtils.findChildByChain(rootEl, new String[]{"d", "c"}).getAttribute("t");

            String listStr =
                XmlUtils.findChildByChain(rootEl, new String[]{"d", "c"}).getAttribute("l");

            String name =
                XmlUtils.findChildByChain(rootEl, new String[]{"d", "c"}).getAttribute("f");

            MsnContactImpl contact = (MsnContactImpl) contactList
                .getContactByEmail(Email.parseStr(contactName + "@" + domain));

            if (contact == null)
            {
                contact = new MsnContactImpl(contactList);
                contact.setEmail(Email.parseStr(contactName + "@" + domain));
                contact.setFriendlyName(name);
                contact.setDisplayName(name);

                contactList.addContact(contact);
            }

            boolean isInRList = contact.isInList(MsnList.RL);
            int listNumber = Integer.parseInt(listStr);
View Full Code Here

Examples of net.sf.jml.impl.MsnContactListImpl

    @Override
  protected void messageReceived(MsnSession session) {
        super.messageReceived(session);

        MsnMessenger messenger = session.getMessenger();
        MsnContactListImpl contactList = (MsnContactListImpl) messenger
                .getContactList();
        String version = getVersion();

        if (version.equals(contactList.getVersion())) {
            ((AbstractMessenger) messenger).fireContactListSyncCompleted();
        } else {
            int groupCount = getGroupCount();
            if (!protocol.before(MsnProtocol.MSNP10)) {
                groupCount++; //In MSNP8/MSNP9 will return default group
            }
            contactList.setVersion(version);
            contactList.setGroupCount(groupCount);
            contactList.setContactCount(getContactCount());
        }

       
        if (protocol.before(MsnProtocol.MSNP13)){
            //session.getContactList().processInit();
View Full Code Here

Examples of net.sf.jml.impl.MsnContactListImpl

    @Override
    protected void messageReceived(MsnSession session)
    {
        super.messageReceived(session);

        MsnContactListImpl contactList =
            (MsnContactListImpl) session.getMessenger().getContactList();

        MsnMessageChain chain = session.getOutgoingMessageChain();
        int trId = getTransactionId();

        for (MsnMessageIterator iterator = chain.iterator(); iterator.hasPrevious();)
        {
            MsnOutgoingMessage message = (MsnOutgoingMessage) iterator.previous();
            if (message.getTransactionId() == trId)
            {
                MsnContactImpl contact = (MsnContactImpl)((OutgoingRML) message).getContact();

                MsnList list = ((OutgoingRML) message).getList();

                contact.setInList(list, false);
                if (contact.getListNumber() == 0)
                { //Not in any group, delete from contact list
                    contactList.removeContactByEmail(contact.getEmail());
                }
                if (list == MsnList.FL)
                { //In FL, remove user from the group.
                    try
                    {
View Full Code Here

Examples of net.sf.jml.impl.MsnContactListImpl

    @Override
  protected void messageReceived(MsnSession session) {
        super.messageReceived(session);

        MsnContactListImpl contactList = (MsnContactListImpl) session
                .getMessenger().getContactList();
        String groupId = getGroupId();

        if (groupId != null) {
            MsnGroupImpl group = new MsnGroupImpl(contactList);
            group.setGroupId(groupId);
            group.setGroupName(getGroupName());
            contactList.addGroup(group);
        } else { //default group
            ((MsnGroupImpl) contactList.getDefaultGroup())
                    .setGroupName(getGroupName());
        }

        if (contactList.getCurrentContactCount() == contactList
                .getContactCount()
                && contactList.getCurrentGroupCount() == contactList
                        .getGroupCount()) {
            ((AbstractMessenger) session.getMessenger())
                    .fireContactListSyncCompleted(); //Sync completed
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.