Examples of MsnContactImpl


Examples of net.sf.jml.impl.MsnContactImpl

            }
        }

        body = new String(Base64.decode(bodyBuilder.toString()), encoding);

        MsnContactImpl contact = (MsnContactImpl)
            session.getMessenger().getContactList().
                getContactByEmail(Email.parseStr(from));

        if (contact == null) {
                contact = new MsnContactImpl(session.getMessenger().getContactList());
                contact.setEmail(Email.parseStr(from));
                contact.setDisplayName(displayName);
        }

        return new OfflineMsg(body, contentType, encoding, contact, seqNum);
    }
View Full Code Here

Examples of net.sf.jml.impl.MsnContactImpl

        {
            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

Examples of net.sf.jml.impl.MsnContactImpl

        }

        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

Examples of net.sf.jml.impl.MsnContactImpl

        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\"?>");
View Full Code Here

Examples of net.sf.jml.impl.MsnContactImpl

        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();
View Full Code Here

Examples of net.sf.jml.impl.MsnContactImpl

            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

Examples of net.sf.jml.impl.MsnContactImpl

            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.MsnContactImpl

    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.MsnContactImpl

                .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);
                    else
View Full Code Here

Examples of net.sf.jml.impl.MsnContactImpl

    }

    @Override
  protected void messageReceived(MsnSession session) {
       super.messageReceived(session);
       MsnContactImpl contact = (MsnContactImpl) session.getMessenger()
               .getContactList().getContactByEmail(getEmail());

       if (contact != null) {
           contact.setPersonalMessage(getPersonalMessage());
           contact.setCurrentMedia(getCurrentMedia());
           ((AbstractMessenger) session.getMessenger())
                   .fireContactPersonalMessageChanged(contact);
       }
    }
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.