Package net.sf.jml.impl

Examples of net.sf.jml.impl.MsnContactListImpl


        AbstractMessenger messenger = (AbstractMessenger)session.getMessenger();
        MsnProtocol protocol = messenger.getActualMsnProtocol();

        if (protocol.after(MsnProtocol.MSNP12))
        {
            MsnContactListImpl contactList = (MsnContactListImpl) session
                .getMessenger().getContactList();
            MsnContact[] cs = contactList.getContacts();
            int cs_size = cs.length;
            Queue<MsnContact> csq = new LinkedList<MsnContact>();
            try
            {
                // don't know why 220 instead of ~250, but MSN server don't like it
View Full Code Here


        if(groups == null)
            return;

        List gs = XmlUtils.findChildren(groups, "Group");

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

        Iterator iter = gs.iterator();
        while (iter.hasNext())
        {
            Element el = (Element)iter.next();

            Element grIdEl = XmlUtils.findChild(el, "groupId");

            String grId = XmlUtils.getText(grIdEl).trim();

            Element grInfoEl = XmlUtils.findChild(el, "groupInfo");
            Element grNameEl = XmlUtils.findChild(grInfoEl, "name");
            String name = XmlUtils.getText(grNameEl);

            MsnGroupImpl group = new MsnGroupImpl(contactList);
            group.setGroupId(grId);
            group.setGroupName(name);
            contactList.addGroup(group);
        }
    }
View Full Code Here

        if(contacts == null)
            return;

        List cs = XmlUtils.findChildren(contacts, "Contact");

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

        Iterator iter = cs.iterator();
        while (iter.hasNext())
        {
            Element el = (Element)iter.next();

            Element cIdEl = XmlUtils.findChild(el, "contactId");

            MsnContactImpl contact = new MsnContactImpl(contactList);

            String contactId = XmlUtils.getText(cIdEl).trim();
            contact.setId(contactId);

            Element contactInfoEl = XmlUtils.findChild(el, "contactInfo");

            Element contactTypeEl = XmlUtils.findChild(contactInfoEl, "contactType");
            String cType = XmlUtils.getText(contactTypeEl);

            if(cType.equalsIgnoreCase("me"))
            {
                Element contactDisplayNameEl =
                    XmlUtils.findChild(contactInfoEl, "displayName");
                myDisplayName = XmlUtils.getText(contactDisplayNameEl);

                continue;
            }

            /* ignore non-messenger contacts */
            Element isMessengerUserEl = XmlUtils.findChild(contactInfoEl, "isMessengerUser");
            boolean isMessengerUser = Boolean.parseBoolean(XmlUtils.getText(isMessengerUserEl));

            if(!isMessengerUser)
                continue;

            Element emailNameEl = XmlUtils.findChild(contactInfoEl, "passportName");
            String email = XmlUtils.getText(emailNameEl);

            if(email == null)
            {
                // new
                Element isMessengerEnabledEl =
                    XmlUtils.findChildByChain(contactInfoEl,
                        new String[]{"emails", "ContactEmail", "isMessengerEnabled"});

                if(isMessengerEnabledEl == null ||
                    !Boolean.parseBoolean(XmlUtils.getText(isMessengerEnabledEl)))
                    continue;

                Element emailEl = XmlUtils.findChildByChain(contactInfoEl,
                    new String[]{"emails", "ContactEmail", "email"});

                if(emailEl == null)
                    continue;

                email = XmlUtils.getText(emailEl);

                if(email == null)
                    continue;
            }

            contact.setEmail(Email.parseStr(email));

            Element groupsEl = XmlUtils.findChild(contactInfoEl, "groupIds");
            if(groupsEl != null)
            {
                List grIdsEls = XmlUtils.findChildren(groupsEl, "guid");
                Iterator i = grIdsEls.iterator();
                while (i.hasNext())
                {
                    Element guid = (Element)i.next();
                    contact.addBelongGroup(XmlUtils.getText(guid).trim());
                }
            }

            Element displayNameEl = XmlUtils.findChild(contactInfoEl, "displayName");
            String displayName = XmlUtils.getText(displayNameEl);
            contact.setFriendlyName(displayName);
            contact.setDisplayName(displayName);

            // telephone ??

            // list number is sum of all lists that the contact is in.
            int listNumber = 0;
            Iterator i = membersRoles.entrySet().iterator();
            while (i.hasNext())
            {
                Entry e = (Entry)i.next();

                MemberRole mr = (MemberRole)e.getValue();

                if(mr.getMembers().contains(email))
                {
                    listNumber += mr.list.getListId();
                }
            }

            // something is wrong, contact in noone list
            if(listNumber == 0)
                continue;

            contact.setListNumber(listNumber);

            if(contact.isInList(MsnList.AL))
                contact.setInList(MsnList.FL, true);

            // Fix for error 241 (contact in allow and blocked list)
            if(contact.isInList(MsnList.AL) && contact.isInList(MsnList.BL))
            {
                contact.setInList(MsnList.FL, false);
                contact.setInList(MsnList.AL, false);
                contact.setInList(MsnList.PL, false);
            }
           
            /* It seems that such fix doesn't work as expected,
             * I leave it there anyway, but I see a l=5 in other clients raw log!
             * There's other strange 241 error I got that should be solved with the code below
             * (James Lopez - BLuEGoD)
             */
            if((listNumber | MsnList.RL.getListId())==MsnList.RL.getListId())
                contact.setInList(MsnList.PL, true);
            contactList.addContact(contact);
        }
    }
View Full Code Here

        if(e == null)
            return;

        String guid = XmlUtils.getText(e);

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

        MsnGroupImpl group = new MsnGroupImpl(contactList);
        group.setGroupId(guid);
        group.setGroupName(groupName);
        contactList.addGroup(group);

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

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

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

        MsnGroup group = contactList.getGroup(groupId);
        contactList.removeGroup(groupId);

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

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

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

        MsnGroupImpl group = (MsnGroupImpl)contactList.getGroup(groupId);
        if (group != null)
            group.setGroupName(newGroupName);
    }
View Full Code Here

            guid =
                getContactID(addBookRes, email.getEmailAddress());
        }

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

        MsnContactImpl c = new MsnContactImpl(contactList);
        c.setEmail(email);
        c.setFriendlyName(friendlyName);
        c.setId(guid);

        contactList.addContact(c);

        addFriendToList(new MsnList[]{MsnList.AL, MsnList.FL}, c);
    }
View Full Code Here

        }

        dbfactory.setIgnoringComments(true);
        Element el = null;

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

        MsnContactImpl contact = (MsnContactImpl)contactList.getContactById(id);
        contact.setFriendlyName(friendlyName);

        // update in msn and addbook
        mess = new StringBuilder();

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

        mess.append("    <ABContactUpdate xmlns=\"http://www.msn.com/webservices/AddressBook\">");
        mess.append("        <abId>00000000-0000-0000-0000-000000000000</abId>");
        mess.append("        <contacts>");
        mess.append("           <Contact xmlns=\"http://www.msn.com/webservices/AddressBook\">");
        mess.append("               <contactId>" + id + "</contactId>");
        mess.append("               <contactInfo>");
        mess.append("                   <displayName>" + friendlyName + "</displayName>");
        mess.append("               </contactInfo>");
        mess.append("               <propertiesChanged>DisplayName</propertiesChanged>");
        mess.append("           </Contact>");
        mess.append("        </contacts>");
        mess.append("    </ABContactUpdate>");

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

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

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

        el =
            XmlUtils.locateElement(
                doc.getDocumentElement(),
                "ABContactUpdateResponse",
                "xmlns",
                "http://www.msn.com/webservices/AddressBook");
        // todo if something missing throw failed event
        if(el == null || el.getChildNodes().getLength() > 0)
            return;

        // update contact
        contactList.removeContactById(id);
        contactList.addContact(contact);
    }
View Full Code Here

        }

        dbfactory.setIgnoringComments(true);
        Element el = null;

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

        MsnContactImpl contact = (MsnContactImpl)contactList.getContactById(id);

        if(groupId != null)
        {
            mess.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
            mess.append("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"\r\n");
            mess.append(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n");
            mess.append(" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\r\n");
            mess.append(" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n");
            mess.append("<soap:Header>\r\n");
            mess.append("<ABApplicationHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">\r\n");
            mess.append("<ApplicationId>CFE80F9D-180F-4399-82AB-413F33A1FA11</ApplicationId>\r\n");
            mess.append("<IsMigration>false</IsMigration>\r\n");
            mess.append("<PartnerScenario>Timer</PartnerScenario>\r\n");
            mess.append("</ABApplicationHeader>\r\n");
            mess.append("<ABAuthHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">\r\n");
            mess.append("<ManagedGroupRequest>false</ManagedGroupRequest>\r\n");
            mess.append("<TicketToken>" + sso.getContactTicket().replaceAll("&", "&amp;") + "</TicketToken>\r\n");
            mess.append("</ABAuthHeader>\r\n");
            mess.append("</soap:Header>\r\n");
            mess.append("<soap:Body>\r\n");

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

            mess.append("<groupFilter><groupIds>\r\n");
            mess.append("<guid>" + groupId + "</guid>\r\n");
            mess.append("</groupIds></groupFilter>\r\n");
            mess.append("</ABGroupContactDelete>\r\n");

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

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

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

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

            // todo if something missing throw failed event
            if(el == null || el.getChildNodes().getLength() > 0)
                logger.error("some error in " + res);
            else
            {
                contact.removeBelongGroup(groupId);

                MsnGroup group = contactList.getGroup(groupId);

                ((AbstractMessenger) session.getMessenger())
                    .fireContactRemoveFromGroupCompleted(contact, group);
            }
        }

        if(contact.getBelongGroups().length > 0)
            return;

        // remove from msn and addbook
        mess = new StringBuilder();

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

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

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

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

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

        el =
            XmlUtils.locateElement(
                doc.getDocumentElement(),
                "ABContactDeleteResponse",
                "xmlns",
                "http://www.msn.com/webservices/AddressBook");
        // todo if something missing throw failed event
        if(el == null || el.getChildNodes().getLength() > 0)
            return;

        contactList.removeContactById(id);

        // remove from list
        AbstractMessenger messenger = (AbstractMessenger)session.getMessenger();
        OutgoingRML message = new OutgoingRML(messenger.getActualMsnProtocol());
        message.setRemoveFromList(list, contact);
View Full Code Here

        // 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, false);
        contact.setInList(MsnList.BL, true);
    }
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.