Package net.sf.jml.impl

Examples of net.sf.jml.impl.MsnContactImpl


                .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) {
            contact.addBelongGroup(getGroupId());
        } else if (list == MsnList.RL) {
            ((AbstractMessenger) session.getMessenger())
                    .fireContactAddedMe(contact);
        }
View Full Code Here


        } catch (Exception e) {
            ((AbstractMessenger) messenger).fireExceptionCaught(e);
        }

        if (message != null) {
            MsnContactImpl contact = (MsnContactImpl) messenger
                    .getContactList().getContactByEmail(getEmail());
            if (contact == null) {
                contact = new MsnContactImpl(messenger.getContactList());
                contact.setEmail(getEmail());
                contact.setDisplayName(getDisplayName());
            }
            message.messageReceived(session, contact);
        }
    }
View Full Code Here

        super.messageReceived(session);

        MsnSwitchboard switchboard = session.getSwitchboard();
        if (switchboard != null) {
            MsnMessenger messenger = session.getMessenger();
            MsnContactImpl contact = (MsnContactImpl) messenger
                    .getContactList().getContactByEmail(getEmail());
            if (contact == null) {
                contact = new MsnContactImpl(messenger.getContactList());
                contact.setEmail(getEmail());
            }

            ((AbstractSwitchboard) switchboard).removeContact(contact);
            ((AbstractMessenger) messenger).fireContactLeaveSwitchboard(
                    switchboard, contact);
View Full Code Here

        for (MsnMessageIterator iterator = chain.iterator(); iterator.hasPrevious();)
        {
            MsnOutgoingMessage message = (MsnOutgoingMessage) iterator.previous();
            if (message.getTransactionId() == trId)
            {
                MsnContactImpl contact = ((OutgoingADL) message).getContact();
                if(contact != null)
                {
                    MsnList list = null;

                    if(contact.isInList(MsnList.FL))
                        list = MsnList.FL;
                    else if(contact.isInList(MsnList.AL))
                        list = MsnList.AL;

                    ((AbstractMessenger) session.getMessenger())
                        .fireContactAddCompleted(contact, list);

                    OutgoingFQY m = new OutgoingFQY(protocol);
                    m.setContact(contact);
                    session.getMessenger().send(m);

                    return;
                }
            }
        }


        byte[] chunk = getChunkData();
        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);

            if(!(!isInRList && ((listNumber & MsnList.RL.getListId()) == MsnList.RL.getListId())))
                return;

            // when we are added from other user we receive ADL for
            // the event and must add him to the Reverse List
            // its server initiated transaction so its 0
            if(trId == 0 && listNumber == MsnList.RL.getListId())
            {
                contact.setInList(MsnList.RL, true);

                ((AbstractMessenger) session.getMessenger())
                    .fireContactAddedMe(contact);
            }
            else
            {
                MsnList lists[] = new MsnList[]{
                    MsnList.AL, MsnList.BL, MsnList.FL, MsnList.PL, MsnList.RL};

                for (int i = 0; i < lists.length; i++)
                {
                    MsnList list = lists[i];
                    if((listNumber & list.getListId()) == list.getListId())
                        contact.setInList(list, true);
                    else
                        contact.setInList(list, false);
                }

                ((AbstractMessenger) session.getMessenger())
                        .fireContactAddedMe(contact);
            }
View Full Code Here

            Vector v = (Vector)e.getValue();
            Iterator i = v.iterator();
            while (i.hasNext())
            {
                MsnContactImpl mc = (MsnContactImpl)i.next();

                int listNumber = mc.getListNumber();

                if(mc.isInList(MsnList.PL))
                    listNumber -= MsnList.PL.getListId();

                if(mc.isInList(MsnList.RL))
                    listNumber -= MsnList.RL.getListId();

                mess.append("<c n=\"" + getName(mc.getEmail().getEmailAddress()) +
                    "\" l=\"" + listNumber + "\" t=\"1\" />");
            }

            mess.append("</d>");
        }
View Full Code Here

        super.messageReceived(session);
        MsnSwitchboard switchboard = session.getSwitchboard();
        if (switchboard != null) {
            MsnContactList contactList = session.getMessenger()
                    .getContactList();
            MsnContactImpl contact = (MsnContactImpl) contactList
                    .getContactByEmail(getEmail());
            if (contact == null) {
                contact = new MsnContactImpl(contactList);
                contact.setEmail(getEmail());
                contact.setDisplayName(getDisplayName());
            }
            ((AbstractSwitchboard) switchboard).addContact(contact);
        }
    }
View Full Code Here

        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())
                        .fireContactAddCompleted(contact, MsnList.FL);
            } else {
                contact.setInList(MsnList.RL, true);
                ((AbstractMessenger) session.getMessenger())
                        .fireContactAddedMe(contact);
            }
            break;
        }
View Full Code Here

        super.messageReceived(session);
        MsnSwitchboard switchboard = session.getSwitchboard();
        if (switchboard != null) {
            MsnMessenger messenger = session.getMessenger();
            MsnContactList contactList = messenger.getContactList();
            MsnContactImpl contact = (MsnContactImpl) contactList
                    .getContactByEmail(getEmail());
            if (contact == null) {
                contact = new MsnContactImpl(contactList);
                contact.setEmail(getEmail());
                contact.setDisplayName(getDisplayName());
            }
            ((AbstractSwitchboard) switchboard).addContact(contact);
            ((AbstractMessenger) messenger).fireContactJoinSwitchboard(
                    switchboard, contact);
        }
View Full Code Here

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

        MsnContactImpl contact = (MsnContactImpl) session.getMessenger()
                .getContactList().getContactByEmail(getEmail());
        if (contact != null) {
            contact.setDisplayName(getDisplayName());
            contact.setClientId(MsnClientId.parseInt(getClientId()));
            contact.setStatus(getUserStatus());
            MsnObject obj = getMsnObject();
            if (obj != null) {
              contact.setAvatar(obj);
            }
            ((AbstractMessenger) session.getMessenger()).fireContactStatusChanged(contact);
        }
    }
View Full Code Here

        {
            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

TOP

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

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.