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);
}