Package net.sf.jml.impl

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


        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

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

        MsnContactListImpl contactList = (MsnContactListImpl) session
                .getMessenger().getContactList();
        String[] groupId = getGroupId();
        String id = getId();

        MsnContactImpl contact = new MsnContactImpl(contactList);
        contact.setEmail(getEmail());
        contact.setTelephone(getTelephone());
       
        if (id != null){
          contact.setId(id);
        }else if (contact.getEmail() != null){
          contact.setId(contact.getEmail().getEmailAddress());
        }else if (contact.getTelephone() != null){
          contact.setId(contact.getTelephone().getTelephoneNumber());
        }
        contact.setFriendlyName(getFriendlyName());
        contact.setDisplayName(contact.getFriendlyName());
        contact.setListNumber(getListNum());
        for (String aGroupId : groupId) {
            contact.addBelongGroup(aGroupId);
        }
        contactList.addContact(contact);

        //Judge sync complete
        if (contactList.getCurrentContactCount() == contactList
                .getContactCount()
                && contactList.getCurrentGroupCount() == contactList
                        .getGroupCount()) {
            ((AbstractMessenger) session.getMessenger())
                    .fireContactListSyncCompleted(); //Sync completed
        }
    }
View Full Code Here

        }
    }

    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

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

        MsnContactListImpl contactList = (MsnContactListImpl) session
                .getMessenger().getContactList();
        MsnGroupImpl group = new MsnGroupImpl(contactList);
        group.setGroupId(getGroupId());
        group.setGroupName(getGroupName());
        contactList.addGroup(group);

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

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

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

        int syntaxType = getSyntaxType();
        switch (syntaxType) {
        case 1:
            contact = (MsnContactImpl) contactList
                    .getContactByEmail(getEmail());
            if (contact != null)
                contact.setInList(list, true);
            ((AbstractMessenger) session.getMessenger())
                    .fireContactAddCompleted(contact, list);
            break;
        case 3:
            contact = (MsnContactImpl) contactList.getContactById(getId());
            if (contact != null)
            {
                contact.addBelongGroup(getGroupId());
                ((AbstractMessenger) session.getMessenger())
                        .fireContactAddInGroupCompleted(
                            contact, contactList.getGroup(getGroupId()));
            }
            break;
        case 2:
        case 4:
            contact = (MsnContactImpl) contactList
                    .getContactByEmail(getEmail());
            if (contact == null) {
                contact = new MsnContactImpl(contactList);
                contact.setEmail(getEmail());
                contact.setFriendlyName(getFriendlyName());
                contact.setDisplayName(contact.getFriendlyName());
                contactList.addContact(contact);
            }
            if (syntaxType == 2) {
                contact.setId(getId());
                contact.setInList(MsnList.FL, true);
                ((AbstractMessenger) session.getMessenger())
View Full Code Here

TOP

Related Classes of net.sf.jml.impl.MsnContactListImpl

Copyright © 2018 www.massapicom. 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.