Initial support for Msn protocol version up to 15.

cusax-fix
Damian Minkov 18 years ago
parent eccdd31f13
commit 6dd45adb2c

@ -456,7 +456,7 @@
<!-- Tell the slick runner about TestSutes we've preregistered. -->
<sysproperty key="net.java.sip.communicator.slick.runner.TEST_LIST"
value="${simple.test.names}"/>
<!-- Tell java.util.logging about our logging preferences -->
<sysproperty key="java.util.logging.config.file"
value="${lib}/logging.properties"/>
@ -1035,6 +1035,7 @@ javax.swing.event, javax.swing.border"/>
prefix="net/java/sip/communicator/impl/protocol/msn"/>
<zipfileset src="${lib.noinst}/jml-1.0b2.jar" prefix=""/>
<zipfileset src="${lib.noinst}/commons-logging.jar" prefix=""/>
<zipfileset src="${lib.noinst}/httpcore-4.0-beta2.jar" prefix=""/>
</jar>
</target>

@ -29,6 +29,7 @@ org.osgi.framework.system.packages= org.osgi.framework; \
javax.sound.sampled; \
javax.naming; \
javax.naming.directory; \
javax.crypto.spec; \
javax.net; \
javax.net.ssl;

@ -10,7 +10,7 @@
/**
* Contactlist modification listener receives events
* for successful chngings
* for successful changing
*
* @author Damian Minkov
*/
@ -27,47 +27,15 @@ public void messageDelivered(int transactionID){}
* @param transactionID int the transaction that send the message
*/
public void messageDeliveredFailed(int transactionID){}
/**
* Indicates that a contact is successfully added
* @param contact MsnContact the contact
*/
public void contactAdded(MsnContact contact){}
/**
* Indicates that a contact is successfully added to the group
* @param contact MsnContact the contact
* @param group MsnGroup the group
*/
public void contactAddedInGroup(MsnContact contact, MsnGroup group){}
/**
* Indicates successful removing of a contact
* @param contact MsnContact the removed contact
*/
public void contactRemoved(MsnContact contact){}
/**
* Indicates successful removing of a contact from a group
* @param contact MsnContact the contact removed
* @param group MsnGroup the group
*/
public void contactRemovedFromGroup(MsnContact contact, MsnGroup group){}
/**
* Indicates that a group is successfully added
* @param group MsnGroup the added group
*/
public void groupAdded(MsnGroup group){}
/**
* Indicates that a group is successfully renamed
* @param group MsnGroup the renmaed group with the new name
* @param group MsnGroup the renamed group with the new name
*/
public void groupRenamed(MsnGroup group){}
/**
* Indicates successful removing of a group
* @param id String the id of the removed group
*/
public void groupRemoved(String id){}
/**
* Indicates that we are logged out
* beacuse account logged in from other location
* because account logged in from other location
*/
public void loggingFromOtherLocation(){}
}

@ -40,7 +40,7 @@ public class EventManager
/**
* Creates the manager
* @param msnMessenger BasicMessenger the messanger
* @param msnMessenger BasicMessenger the messenger
*/
public EventManager(ProtocolProviderServiceMsnImpl msnProvider,
BasicMessenger msnMessenger)
@ -53,7 +53,7 @@ public EventManager(ProtocolProviderServiceMsnImpl msnProvider,
/**
* Adds listener of the modification fired events
* @param listener the modifification listener we're adding
* @param listener the modification listener we're adding
*/
public void addModificationListener(MsnContactListEventListener listener)
{
@ -102,54 +102,11 @@ public void messageReceived(Session session, Message message)
logger.trace(msnMessenger.getOwner().getEmail().getEmailAddress() +
" incoming : " + incoming);
// These are the incoming messages that are NOT handled
//IncomingADC,IncomingANS,IncomingBLP,IncomingBPR,IncomingBYE
//IncomingCAL,IncomingCHL,IncomingCHG,IncomingCVR,IncomingFLN
//IncomingGTC,IncomingILN,IncomingIRO,IncomingJOI,IncomingLSG
//IncomingLST,IncomingMSG,IncomingNLN
//IncomingOUT - The notice message that logout. Maybe because of MSN
// server maintenance or someone login in other place.
//IncomingPRP,IncomingQNG,IncomingQRY,IncomingREA,IncomingRNG
//IncomingSYN,IncomingUBX,IncomingURL,IncomingUSR,IncomingUUX
//IncomingUnknown,IncomingVER,IncomingXFR
if(incoming instanceof IncomingACK)
{
//indicate the message has successed send to remote user.
fireMessageDelivered(((IncomingACK)incoming).getTransactionId());
}
else if(incoming instanceof IncomingADC)
{
// add user to contact list
IncomingADC incomingADC = (IncomingADC) incoming;
if (incomingADC.getId() != null &&
incomingADC.getList().equals(MsnList.FL))
{
MsnContact contact = msnMessenger.getContactList().
getContactById(incomingADC.getId());
if (incomingADC.getGroupId() != null)
{
MsnGroup group = msnMessenger.getContactList().
getGroup(incomingADC.getGroupId());
fireContactAddedInGroup(contact, group);
}
else
fireContactAdded(contact);
}
}
else if(incoming instanceof IncomingADG)
{
//indicate add a group success
IncomingADG incomingADG = (IncomingADG)incoming;
MsnGroupImpl group =
(MsnGroupImpl)msnMessenger.getContactList().getGroup(incomingADG.getGroupId());
fireGroupAdded(group);
}
else if(incoming instanceof IncomingNAK)
{
//indicate the message has not successed send to remote user.
@ -164,45 +121,6 @@ else if(incoming instanceof IncomingREG)
getGroup(incomingREG.getGroupId());
fireGroupRenamed(group);
}
else if(incoming instanceof IncomingRMG)
{
// indicate delete the group successfully.
IncomingRMG incomingRMG = (IncomingRMG)incoming;
fireGroupRemoved(incomingRMG.getGroupId());
}
else if(incoming instanceof IncomingREM)
{
// indicate delete the contact successfully.
IncomingREM incomingREM = (IncomingREM)incoming;
if(incomingREM.getList().equals(MsnList.FL))
{
if(incomingREM.getGroupId() == null)
{
// just contact removed
MsnContactImpl contact = (MsnContactImpl)
msnMessenger.getContactList().getContactById(incomingREM.getId());
if(contact != null)
{
fireContactRemoved(contact);
}
}
else
{
// contact removed from group
MsnContact contact =
msnMessenger.getContactList().
getContactById(incomingREM.getId());
MsnGroup group =
msnMessenger.getContactList().
getGroup(incomingREM.getGroupId());
fireContactRemovedFromGroup(contact, group);
}
}
}
else if(incoming instanceof IncomingOUT)
{
IncomingOUT incomingOUT = (IncomingOUT)incoming;
@ -268,85 +186,6 @@ private void fireMessageDeliveredFailed(int transactionID)
}
}
/**
* Fired when a contact is added successfully
* @param contact MsnContact
*/
private void fireContactAdded(MsnContact contact)
{
synchronized(listeners){
Iterator iter = listeners.iterator();
while (iter.hasNext())
{
((MsnContactListEventListener)iter.next()).contactAdded(contact);
}
}
}
/**
* Fired when a contact is added in a group successfully
* @param contact MsnContact
* @param group MsnGroup
*/
private void fireContactAddedInGroup(MsnContact contact, MsnGroup group)
{
synchronized(listeners){
Iterator iter = listeners.iterator();
while (iter.hasNext())
{
((MsnContactListEventListener)iter.next()).
contactAddedInGroup(contact, group);
}
}
}
/**
* Fired when a contact is removed successfully
* @param contact MsnContact
*/
private void fireContactRemoved(MsnContact contact)
{
synchronized(listeners){
Iterator iter = listeners.iterator();
while (iter.hasNext())
{
((MsnContactListEventListener)iter.next()).contactRemoved(contact);
}
}
}
/**
* Fired when a contact is removed from group successfully
* @param contact MsnContact
* @param group MsnGroup
*/
private void fireContactRemovedFromGroup(MsnContact contact, MsnGroup group)
{
synchronized(listeners){
Iterator iter = listeners.iterator();
while (iter.hasNext())
{
((MsnContactListEventListener)iter.next()).
contactRemovedFromGroup(contact, group);
}
}
}
/**
* Fired when a group is added successfully
* @param group MsnGroup
*/
private void fireGroupAdded(MsnGroup group)
{
synchronized(listeners){
Iterator iter = listeners.iterator();
while (iter.hasNext())
{
((MsnContactListEventListener)iter.next()).groupAdded(group);
}
}
}
/**
* Fired when a group is renamed successfully
* @param group MsnGroup
@ -363,22 +202,7 @@ private void fireGroupRenamed(MsnGroup group)
}
/**
* Fired when a group is removed successfully
* @param id String
*/
private void fireGroupRemoved(String id)
{
synchronized(listeners){
Iterator iter = listeners.iterator();
while (iter.hasNext())
{
((MsnContactListEventListener)iter.next()).groupRemoved(id);
}
}
}
/**
* Fired when we recived event for logging in from other location
* Fired when we received event for logging in from other location
*/
private void fireLoggingFromOtherLocation()
{

@ -10,7 +10,7 @@
/**
* Contactlist modification listener receives events
* for successful chngings
* for successful changing
*
* @author Damian Minkov
*/
@ -29,53 +29,15 @@ public interface MsnContactListEventListener
*/
public void messageDeliveredFailed(int transactionID);
/**
* Indicates that a contact is successfully added
* @param contact MsnContact the contact
*/
public void contactAdded(MsnContact contact);
/**
* Indicates that a contact is successfully added to the group
* @param contact MsnContact the contact
* @param group MsnGroup the group
*/
public void contactAddedInGroup(MsnContact contact, MsnGroup group);
/**
* Indicates successful removing of a contact
* @param contact MsnContact the removed contact
*/
public void contactRemoved(MsnContact contact);
/**
* Indicates successful removing of a contact from a group
* @param contact MsnContact the contact removed
* @param group MsnGroup the group
*/
public void contactRemovedFromGroup(MsnContact contact, MsnGroup group);
/**
* Indicates that a group is successfully added
* @param group MsnGroup the added group
*/
public void groupAdded(MsnGroup group);
/**
* Indicates that a group is successfully renamed
* @param group MsnGroup the renmaed group with the new name
* @param group MsnGroup the renamed group with the new name
*/
public void groupRenamed(MsnGroup group);
/**
* Indicates successful removing of a group
* @param id String the id of the removed group
*/
public void groupRemoved(String id);
/**
* Indicates that we are logged out
* beacuse account logged in from other location
* because account logged in from other location
*/
public void loggingFromOtherLocation();
}

@ -12,7 +12,6 @@
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.*;
import net.sf.jml.*;
import net.sf.jml.event.*;
import net.sf.jml.impl.*;
import net.sf.jml.message.p2p.*;
@ -71,6 +70,8 @@ public class ServerStoredContactListMsnImpl
* indicates whether or not the contactlist is initialized and ready.
*/
private boolean isInitialized = false;
private Vector skipAddEvent = new Vector();
/**
* Creates a ServerStoredContactList wrapper for the specified BuddyList.
@ -379,22 +380,13 @@ public void addContact(final ContactGroupMsnImpl parent, final String id)
if(parent != null)
{
contactListModListenerImpl.waitForAddInGroup(id);
ModListenerAddContactInGroup modListenerAddContactInGroup =
new ModListenerAddContactInGroup(id, parent);
contactListModManager.
addModificationListener(modListenerAddContactInGroup);
// add the buddy to the list as its not there
msnProvider.getMessenger().unblockFriend(Email.parseStr(id));
skipAddEvent.add(id);
msnProvider.getMessenger().addFriend(Email.parseStr(id), id);
modListenerAddContactInGroup.waitForEvent(1500);
contactListModManager.
removeModificationListener(modListenerAddContactInGroup);
msnProvider.getMessenger().copyFriend(
Email.parseStr(id),
parent.getSourceGroup().getGroupId());
}
else
{
@ -550,7 +542,7 @@ public void removeGroup(ContactGroupMsnImpl groupToRemove)
MsnContact[] contacts = groupToRemove.getSourceGroup().getContacts();
ModListenerRemoveGroup removedContactsListener =
new ModListenerRemoveGroup();
new ModListenerRemoveGroup(contacts.length);
contactListModManager.addModificationListener(removedContactsListener);
for (int i = 0; i < contacts.length; i++)
@ -618,8 +610,6 @@ public void moveContact(ContactMsnImpl contact,
if(oldParent instanceof RootContactGroupMsnImpl)
{
logger.trace("Will Move from root " + contact);
contactListModListenerImpl.moveFromRoot(
contact.getSourceContact().getEmail().getEmailAddress());
msnProvider.getMessenger().copyFriend(
contact.getSourceContact().getEmail(),
newParent.getSourceGroup().getGroupId());
@ -643,7 +633,7 @@ public void moveContact(ContactMsnImpl contact,
{
logger.trace("Will Move from " + contact.getParentContactGroup()
+ " to : " + newParent + " - contact: " + contact);
contactListModListenerImpl.waitForMove(contact.getAddress());
// contactListModListenerImpl.waitForMove(contact.getAddress());
msnProvider.getMessenger().moveFriend(
contact.getSourceContact().getEmail(),
( (ContactGroupMsnImpl) contact.getParentContactGroup()).
@ -901,331 +891,174 @@ public void contactRemovedMe(MsnMessenger messenger, MsnContact contact)
{
}
public void contactAddCompleted(MsnMessenger messenger, MsnContact contact){}
public void contactRemoveCompleted(MsnMessenger messenger, MsnContact contact){}
public void groupAddCompleted(MsnMessenger messenger, MsnGroup group){}
public void groupRemoveCompleted(MsnMessenger messenger, MsnGroup group){}
}
/**
* Waits for removing a group
*/
private class ModListenerRemoveGroup
extends EventAdapter
{
private Vector removedContacts = new Vector();
public void contactRemoved(MsnContact contact)
public void contactAddCompleted1(MsnMessenger messenger, MsnContact contact)
{
synchronized(this)
String contactID = contact.getEmail().getEmailAddress();
if(!skipAddEvent.remove(contactID))
{
removedContacts.remove(contact.getId());
if(removedContacts.size() == 0)
notifyAll();
ContactMsnImpl contactToAdd =
new ContactMsnImpl(
contact,
ServerStoredContactListMsnImpl.this, true, true);
rootGroup.addContact(contactToAdd);
fireContactAdded(rootGroup, contactToAdd);
}
}
public void waitForLastEvent(long waitFor)
public void contactRemoveCompleted1(MsnMessenger messenger, MsnContact contact)
{
synchronized(this)
{
if(removedContacts.size() == 0)
return;
ContactMsnImpl contactToRemove =
findContactById(contact.getEmail().getEmailAddress());
try{
wait(waitFor);
}
catch (InterruptedException ex)
{
logger.debug(
"Interrupted while waiting for a subscription evt", ex);
}
if(contactToRemove == null)
{
logger.trace("Contact not found!" + contact);
return;
}
}
}
/**
* Waits for adding contact and if pointed
* copy the contact in the specified group
* This listener emulates firing event for adding buddy in group.
* The msn does not support adding a contact directly to a group.
* The contact first must be added to the list then it is copied to a group
*/
private class ModListenerAddContactInGroup
extends EventAdapter
{
boolean isAddRecieved = false;
private String contactID = null;
private ContactGroupMsnImpl parent = null;
ModListenerAddContactInGroup(String contactID, ContactGroupMsnImpl parent)
{
this.contactID = contactID;
this.parent = parent;
}
public void contactAdded(MsnContact contact)
{
synchronized (this)
if(contactToRemove.getParentContactGroup() instanceof RootContactGroupMsnImpl)
{
if (contact.getEmail().getEmailAddress().equals(contactID))
{
isAddRecieved = true;
msnProvider.getMessenger().copyFriend(
Email.parseStr(contactID),
parent.getSourceGroup().getGroupId());
notifyAll();
}
rootGroup.removeContact(contactToRemove);
fireContactRemoved(rootGroup, contactToRemove);
}
}
public void waitForEvent(long waitFor)
{
synchronized (this)
else
{
if (isAddRecieved)
return;
try
{
wait(waitFor);
}
catch (InterruptedException ex)
{
logger.debug(
"Interrupted while waiting for a subscription evt", ex);
}
ContactGroupMsnImpl parentGroup =
(ContactGroupMsnImpl)contactToRemove.getParentContactGroup();
parentGroup.removeContact(contactToRemove);
fireContactRemoved(parentGroup, contactToRemove);
}
}
}
/**
* Emulates firing adding contact in group and moving contact to group.
* When moving contact it is first adding to the new group then
* it is removed from the old one.
*/
private class ContactListModListenerImpl
extends EventAdapter
{
private Hashtable waitAddInGroup = new Hashtable();
private Hashtable waitMove = new Hashtable();
private Hashtable waitMoveFromRoot = new Hashtable();
public void waitForAddInGroup(String id)
{
waitAddInGroup.put(id, new Integer(0));
}
public void waitForMove(String id)
public void groupAddCompleted(MsnMessenger messenger, MsnGroup group)
{
waitMove.put(id, new Integer(0));
}
logger.trace("groupAdded " + group);
ContactGroupMsnImpl newGroup =
new ContactGroupMsnImpl(group,
new MsnContact[]{},
ServerStoredContactListMsnImpl.this,
true);
public void moveFromRoot(String id)
{
waitMoveFromRoot.put(id, new Integer(0));
rootGroup.addSubGroup(newGroup);
fireGroupEvent(newGroup, ServerStoredGroupEvent.GROUP_CREATED_EVENT);
}
public void contactAdded(MsnContact newContact)
public void groupRemoveCompleted(MsnMessenger messenger, MsnGroup g)
{
ContactMsnImpl contact =
findContactById(newContact.getEmail().getEmailAddress());
ContactGroupMsnImpl group = findContactGroupByMsnId(g.getGroupId());
if(contact != null && contact.isPersistent())
if(group == null)
{
contact.setResolved(newContact);
fireContactResolved(contact.getParentContactGroup(), contact);
logger.trace("Group not found!" + g);
return;
}
else
{
Integer isWaitingForAddInGroup =
(Integer)waitAddInGroup.get(newContact.getEmail().getEmailAddress());
if(isWaitingForAddInGroup != null)
{
if(isWaitingForAddInGroup.intValue() == 0)
waitAddInGroup.put(
newContact.getEmail().getEmailAddress(),
new Integer(1));
else // something is wrong
waitAddInGroup.remove(newContact.getEmail().getEmailAddress());
}
else
{
contact = new ContactMsnImpl(
newContact,
ServerStoredContactListMsnImpl.this, true, true);
rootGroup.addContact(contact);
fireContactAdded(rootGroup, contact);
}
}
rootGroup.removeSubGroup(group);
fireGroupEvent(group, ServerStoredGroupEvent.GROUP_REMOVED_EVENT);
}
public void contactAddedInGroup(MsnContact contact, MsnGroup group)
public void contactAddInGroupCompleted(MsnMessenger messenger, MsnContact c, MsnGroup g)
{
String contactID = contact.getEmail().getEmailAddress();
ContactMsnImpl contactToAdd = findContactById(contactID);
ContactGroupMsnImpl dstGroup =
findContactGroupByMsnId(group.getGroupId());
Integer isWaitingForAddInGroup = (Integer)waitAddInGroup.get(contactID);
Integer isWaitingForMove = (Integer)waitMove.get(contactID);
Integer isWaitingForMoveFromRoot =
(Integer)waitMoveFromRoot.get(contactID);
if(dstGroup == null){
logger.trace("Group not found!" + group);
return;
}
if(isWaitingForMoveFromRoot != null &&
isWaitingForMoveFromRoot.intValue() == 0)
{
// we are moving from root to a group
logger.trace("Moving from root to a group: firing event");
waitMoveFromRoot.remove(contactID);
rootGroup.removeContact(contactToAdd);
dstGroup.addContact(contactToAdd);
fireContactMoved(rootGroup, dstGroup, contactToAdd);
return;
}
if(isWaitingForMove != null && isWaitingForMove.intValue() == 0)
ContactMsnImpl contactToAdd =
new ContactMsnImpl(
c,
ServerStoredContactListMsnImpl.this, true, true);
ContactGroupMsnImpl group =
findContactGroupByMsnId(g.getGroupId());
if(group == null)
{
// we wait for remove from the previous group to fire
// event contact moved
dstGroup.addContact(contactToAdd);
waitMove.put(contactID, dstGroup);
logger.error("Group is missing!");
return;
}
if(contactToAdd == null || isWaitingForAddInGroup != null)
{
//something wrong or we are waiting for adding contact in group
if(isWaitingForAddInGroup.intValue() == 1)
{
if(contactToAdd == null)
{
contactToAdd =
new ContactMsnImpl(
contact, ServerStoredContactListMsnImpl.this, true, true);
waitAddInGroup.remove(contactID);
dstGroup.addContact(contactToAdd);
fireContactAdded(dstGroup, contactToAdd);
}
else
{
if(!contactToAdd.isPersistent())
{
waitAddInGroup.remove(contactID);
contactToAdd.setResolved(contact);
dstGroup.addContact(contactToAdd);
fireContactMoved(contactToAdd.getParentContactGroup(),
dstGroup, contactToAdd);
}
else
{
waitAddInGroup.remove(contactID);
dstGroup.addContact(contactToAdd);
fireContactAdded(dstGroup, contactToAdd);
}
}
}
else
{
// smth. wrong
logger.trace("Contact not found!" + contact);
return;
}
}
else
{
dstGroup.addContact(contactToAdd);
fireContactAdded(dstGroup, contactToAdd);
}
group.addContact(contactToAdd);
fireContactAdded(group, contactToAdd);
}
public void contactRemoved(MsnContact contact)
public void contactRemoveFromGroupCompleted(MsnMessenger messenger,
MsnContact c, MsnGroup g)
{
ContactMsnImpl contactToRemove =
findContactById(contact.getEmail().getEmailAddress());
if(contactToRemove == null){
logger.trace("Contact not found!" + contact);
return;
}
String contactID = c.getEmail().getEmailAddress();
ContactMsnImpl contactToRemove = findContactById(contactID);
if(contactToRemove.getParentContactGroup() instanceof RootContactGroupMsnImpl)
{
rootGroup.removeContact(contactToRemove);
fireContactRemoved(rootGroup, contactToRemove);
}
else
if(g == null)
{
ContactGroupMsnImpl parentGroup =
(ContactGroupMsnImpl)contactToRemove.getParentContactGroup();
parentGroup.removeContact(contactToRemove);
fireContactRemoved(parentGroup, contactToRemove);
logger.trace("Group is null! ");
return;
}
}
public void contactRemovedFromGroup(MsnContact contact, MsnGroup group)
{
String contactID = contact.getEmail().getEmailAddress();
ContactMsnImpl contactToRemove = findContactById(contactID);
ContactGroupMsnImpl dstGroup =
findContactGroupByMsnId(group.getGroupId());
findContactGroupByMsnId(g.getGroupId());
if(contactToRemove == null)
{
logger.trace("Contact not found " + contact);
logger.trace("Contact not found " + c);
return;
}
if(dstGroup == null)
{
logger.trace("Group not found " + group);
return;
}
Object waitForMoveObj = waitMove.get(contactID);
if(waitForMoveObj != null &&
waitForMoveObj instanceof ContactGroupMsnImpl)
{
dstGroup.removeContact(contactToRemove);
fireContactMoved(
dstGroup,
(ContactGroupMsnImpl)waitForMoveObj,
contactToRemove);
logger.trace("Group not found " + g);
return;
}
dstGroup.removeContact(contactToRemove);
fireContactRemoved(dstGroup, contactToRemove);
}
}
public void groupAdded(MsnGroup group)
/**
* Waits for removing a group
*/
private class ModListenerRemoveGroup
extends EventAdapter
{
private int contactCount = 0;
public ModListenerRemoveGroup(int c)
{
logger.trace("groupAdded " + group);
ContactGroupMsnImpl newGroup =
new ContactGroupMsnImpl(group,
new MsnContact[]{},
ServerStoredContactListMsnImpl.this,
true);
this.contactCount = c;
}
rootGroup.addSubGroup(newGroup);
fireGroupEvent(newGroup, ServerStoredGroupEvent.GROUP_CREATED_EVENT);
public void contactRemoved(MsnContact contact)
{
synchronized(this)
{
contactCount--;
if(contactCount == 0)
notifyAll();
}
}
public void waitForLastEvent(long waitFor)
{
synchronized(this)
{
if(contactCount == 0)
return;
try{
wait(waitFor);
}
catch (InterruptedException ex)
{
logger.debug(
"Interrupted while waiting for a subscription evt", ex);
}
}
}
}
/**
* Emulates firing adding contact in group and moving contact to group.
* When moving contact it is first adding to the new group then
* it is removed from the old one.
*/
private class ContactListModListenerImpl
extends EventAdapter
{
public void groupRenamed(MsnGroup group)
{
ContactGroupMsnImpl groupToRename =
@ -1242,19 +1075,6 @@ public void groupRenamed(MsnGroup group)
ServerStoredGroupEvent.GROUP_RENAMED_EVENT);
}
public void groupRemoved(String id)
{
ContactGroupMsnImpl group = findContactGroupByMsnId(id);
if(group == null){
logger.trace("Group not found!" + id);
return;
}
rootGroup.removeSubGroup(group);
fireGroupEvent(group, ServerStoredGroupEvent.GROUP_REMOVED_EVENT);
}
public void loggingFromOtherLocation()
{
msnProvider.unregister(false);

@ -10,6 +10,9 @@ Import-Package: org.osgi.framework,
javax.naming,
javax.naming.directory,
org.xml.sax,
org.w3c.dom,
javax.crypto,
javax.crypto.spec,
sun.security.action,
net.java.sip.communicator.service.configuration,
net.java.sip.communicator.service.resources,

@ -12,7 +12,10 @@
import javax.swing.*;
/**
*
* The Resource Management Service gives easy access to
* common resources for the application including texts, images, sounds and
* some configurations.
*
* @author Damian Minkov
*/
public interface ResourceManagementService
@ -129,25 +132,98 @@ public interface ResourceManagementService
public char getI18nMnemonic(String key, Locale l);
// Settings pack methods
/**
* Returns an url for the setting corresponding to the given key.
* Used when the setting is an actual file.
*
* @param urlKey The key of the setting.
* @return Url to the corresponding resource.
*/
public URL getSettingsURL(String urlKey);
/**
* Returns an InputStream for the setting corresponding to the given key.
* Used when the setting is an actual file.
*
* @param streamKey The key of the setting.
* @return InputStream to the corresponding resource.
*/
public InputStream getSettingsInputStream(String streamKey);
/**
* Returns a String for the setting corresponding to the given key.
*
* @param key The key of the setting.
* @return String to the corresponding resource.
*/
public String getSettingsString(String key);
/**
* Returns an int for the setting corresponding to the given key.
*
* @param key The key of the setting.
* @return int to the corresponding resource.
*/
public int getSettingsInt(String key);
// Sound pack methods
/**
* Returns an url for the sound resource corresponding to the given key.
*
* @param urlKey The key of the setting.
* @return Url to the corresponding resource.
*/
public URL getSoundURL(String urlKey);
/**
* Returns an url for the sound resource corresponding to the given path.
*
* @param path The path to the sound resource.
* @return Url to the corresponding resource.
*/
public URL getSoundURLForPath(String path);
/**
* Returns all color keys that can be obtained from this service.
*
* @return Iterator to all color keys.
*/
public Iterator getCurrentColors();
/**
* Returns all image keys that can be obtained from this service.
*
* @return Iterator to all image keys.
*/
public Iterator getCurrentImages();
/**
* Returns all color settings that can be obtained from this service.
*
* @return Iterator to all settings keys.
*/
public Iterator getCurrentSettings();
/**
* Returns all color sounds that can be obtained from this service.
*
* @return Iterator to all sounds keys.
*/
public Iterator getCurrentSounds();
/**
* Returns all available locales for the translated texts.
*
* @return Iterator to all locales.
*/
public Iterator getAvailableLocales();
/**
* Returns all string keys that can be obtained from
* this service for the given locale.
*
* @return Iterator to all string keys.
*/
public Iterator getI18nStringsByLocale(Locale l);
/**

@ -128,7 +128,10 @@ protected void tearDown() throws Exception
* phase by the testerAgent.
*/
public void testRetrievingServerStoredContactList()
throws Exception
{
waitFor(5000);
ContactGroup rootGroup
= opSetPersPresence1.getServerStoredContactListRoot();
@ -146,7 +149,7 @@ public void testRetrievingServerStoredContactList()
//Go through the contact list retrieved by the persistence presence set
//and remove the name of every contact and group that we find there from
//the expected contct list hashtable.
//the expected contact list hashtable.
Iterator groups = rootGroup.subgroups();
while (groups.hasNext() )
{
@ -424,6 +427,8 @@ public void prepareContactList()
String groupName = (String) newGroupsEnum.nextElement();
logger.debug("Will add group " + groupName);
groupChangeCollector.collectedEvents.clear();
opSetPersPresence1.createServerStoredContactGroup(
opSetPersPresence1.getServerStoredContactListRoot(), groupName);
@ -469,9 +474,9 @@ private class GroupChangeCollector implements ServerStoredGroupListener
/**
* Blocks until at least one event is received or until waitFor
* miliseconds pass (whicever happens first).
* milliseconds pass (whichever happens first).
*
* @param waitFor the number of miliseconds that we should be waiting
* @param waitFor the number of milliseconds that we should be waiting
* for an event before simply bailing out.
*/
public void waitForEvent(long waitFor)
@ -493,7 +498,7 @@ public void waitForEvent(long waitFor)
}
/**
* Called whnever an indication is received that a new server stored
* Called whenever an indication is received that a new server stored
* group is created.
* @param evt a ServerStoredGroupChangeEvent containing a reference to
* the newly created group.
@ -525,7 +530,7 @@ public void groupNameChanged(ServerStoredGroupEvent evt)
}
/**
* Called whnever an indication is received that an existing server stored
* Called whenever an indication is received that an existing server stored
* group has been removed.
* @param evt a ServerStoredGroupChangeEvent containing a reference to the
* newly created group.
@ -541,7 +546,7 @@ public void groupRemoved(ServerStoredGroupEvent evt)
}
/**
* Called whnever an indication is received that an existing server
* Called whenever an indication is received that an existing server
* stored group has been resolved.
* @param evt a ServerStoredGroupChangeEvent containing a reference to
* the resolved group.
@ -567,9 +572,9 @@ private class SubscriptionEventCollector implements SubscriptionListener
/**
* Blocks until at least one event is received or until waitFor
* miliseconds pass (whicever happens first).
* milliseconds pass (whichever happens first).
*
* @param waitFor the number of miliseconds that we should be waiting
* @param waitFor the number of milliseconds that we should be waiting
* for an event before simply bailing out.
*/
public void waitForEvent(long waitFor)
@ -600,7 +605,7 @@ public void waitForEvent(long waitFor)
}
/**
* Stores the received subsctiption and notifies all waiting on this
* Stores the received subscription and notifies all waiting on this
* object
* @param evt the SubscriptionEvent containing the corresponding contact
*/
@ -615,7 +620,7 @@ public void subscriptionCreated(SubscriptionEvent evt)
}
/**
* Stores the received subsctiption and notifies all waiting on this
* Stores the received subscription and notifies all waiting on this
* object
* @param evt the SubscriptionEvent containing the corresponding contact
*/
@ -630,7 +635,7 @@ public void subscriptionRemoved(SubscriptionEvent evt)
}
/**
* Stores the received subsctiption and notifies all waiting on this
* Stores the received subscription and notifies all waiting on this
* object
* @param evt the SubscriptionEvent containing the corresponding contact
*/
@ -645,7 +650,7 @@ public void subscriptionFailed(SubscriptionEvent evt)
}
/**
* Stores the received subsctiption and notifies all waiting on this
* Stores the received subscription and notifies all waiting on this
* object
* @param evt the SubscriptionEvent containing the corresponding contact
*/
@ -661,7 +666,7 @@ public void subscriptionResolved(SubscriptionEvent evt)
/**
* Stores the received subsctiption and notifies all waiting on this
* Stores the received subscription and notifies all waiting on this
* object
* @param evt the SubscriptionEvent containing the corresponding contact
*/
@ -676,7 +681,7 @@ public void subscriptionMoved(SubscriptionMovedEvent evt)
}
/**
* Stores the received subsctiption and notifies all waiting on this
* Stores the received subscription and notifies all waiting on this
* object
* @param evt the SubscriptionEvent containing the corresponding contact
*/

@ -460,6 +460,18 @@ public void postTestSubscribe()
subEvtCollector.waitForEvent(10000);
operationSetPresence1.removeSubscriptionListener(subEvtCollector);
}
SubscriptionEventCollector subEvtCollector2
= new SubscriptionEventCollector();
operationSetPresence2.addSubsciptionListener(subEvtCollector2);
synchronized (subEvtCollector2){
operationSetPresence2.subscribe(fixture.userID1);
//we may already have the event, but it won't hurt to check.
subEvtCollector2.waitForEvent(10000);
operationSetPresence2.removeSubscriptionListener(subEvtCollector2);
}
assertEquals("Subscription event dispatching failed."
, 1, subEvtCollector.collectedEvents.size());

Loading…
Cancel
Save