Commits into trunk the changes of r5345, r5346 and r5352 which fix warnings in branches/1.0.

cusax-fix
Lyubomir Marinov 17 years ago
parent 8f4466385c
commit 3563fa97f6

@ -30,19 +30,6 @@ public class OperationSetPersistentPresenceDictImpl
private static final Logger logger = private static final Logger logger =
Logger.getLogger(OperationSetPersistentPresenceDictImpl.class); Logger.getLogger(OperationSetPersistentPresenceDictImpl.class);
/**
* A list of listeners registered for <tt>ServerStoredGroupChangeEvent</tt>s.
*/
private Vector<ServerStoredGroupListener> serverStoredGroupListeners =
new Vector<ServerStoredGroupListener>();
/**
* A list of listeners registered for
* <tt>ProviderPresenceStatusChangeEvent</tt>s.
*/
private Vector<ProviderPresenceStatusListener> providerPresenceStatusListeners =
new Vector<ProviderPresenceStatusListener>();
/** /**
* The root of the dict contact list. * The root of the dict contact list.
*/ */
@ -82,102 +69,6 @@ public OperationSetPersistentPresenceDictImpl(
new UnregistrationListener()); new UnregistrationListener());
} }
/**
* Notifies all registered listeners of the new event.
*
* @param source the contact that has caused the event.
* @param eventID an identifier of the event to dispatch.
*/
public void fireServerStoredGroupEvent(ContactGroupDictImpl source,
int eventID)
{
ServerStoredGroupEvent evt = new ServerStoredGroupEvent(
source, eventID, source.getParentContactGroup()
, this.parentProvider, this);
Iterator<ServerStoredGroupListener> listeners = null;
synchronized (serverStoredGroupListeners)
{
listeners = new ArrayList<ServerStoredGroupListener>(serverStoredGroupListeners).iterator();
}
while (listeners.hasNext())
{
ServerStoredGroupListener listener = listeners.next();
if(eventID == ServerStoredGroupEvent.GROUP_CREATED_EVENT)
{
listener.groupCreated(evt);
}
else if(eventID == ServerStoredGroupEvent.GROUP_RENAMED_EVENT)
{
listener.groupNameChanged(evt);
}
else if(eventID == ServerStoredGroupEvent.GROUP_REMOVED_EVENT)
{
listener.groupRemoved(evt);
}
}
}
/**
* Notifies all registered listeners of the new event.
*
* @param oldValue the presence status we were in before the change.
*/
public void fireProviderStatusChangeEvent(PresenceStatus oldValue)
{
ProviderPresenceStatusChangeEvent evt
= new ProviderPresenceStatusChangeEvent(this.parentProvider,
oldValue, this.getPresenceStatus());
Iterator<ProviderPresenceStatusListener> listeners = null;
synchronized (providerPresenceStatusListeners)
{
listeners = new ArrayList<ProviderPresenceStatusListener>(providerPresenceStatusListeners).iterator();
}
while (listeners.hasNext())
{
ProviderPresenceStatusListener listener = listeners.next();
listener.providerStatusChanged(evt);
}
}
/**
* Dict implementation of the corresponding ProtocolProviderService
* method.
*
* @param listener a dummy param.
*/
public void addProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized(providerPresenceStatusListeners)
{
if (!providerPresenceStatusListeners.contains(listener))
this.providerPresenceStatusListeners.add(listener);
}
}
/**
* Registers a listener that would receive events upon changes in server
* stored groups.
*
* @param listener a ServerStoredGroupChangeListener impl that would
* receive events upong group changes.
*/
public void addServerStoredGroupChangeListener(ServerStoredGroupListener
listener)
{
synchronized(serverStoredGroupListeners)
{
if (!serverStoredGroupListeners.contains(listener))
serverStoredGroupListeners.add(listener);
}
}
/** /**
* Creates a group with the specified name and parent in the server * Creates a group with the specified name and parent in the server
* stored contact list. * stored contact list.
@ -500,21 +391,6 @@ private void changePresenceStatusForAllContacts(ContactGroup parent,
} }
} }
/**
* Unregisters the specified listener so that it does not receive further
* events upon changes in local presence status.
*
* @param listener ProviderPresenceStatusListener
*/
public void removeProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized(providerPresenceStatusListeners)
{
this.providerPresenceStatusListeners.remove(listener);
}
}
/** /**
* Returns the group that is parent of the specified dictGroup or null * Returns the group that is parent of the specified dictGroup or null
* if no parent was found. * if no parent was found.
@ -571,22 +447,6 @@ public void removeServerStoredContactGroup(ContactGroup group)
dictGroup, ServerStoredGroupEvent.GROUP_REMOVED_EVENT); dictGroup, ServerStoredGroupEvent.GROUP_REMOVED_EVENT);
} }
/**
* Removes the specified group change listener so that it won't receive
* any further events.
*
* @param listener the ServerStoredGroupChangeListener to remove
*/
public void removeServerStoredGroupChangeListener(ServerStoredGroupListener
listener)
{
synchronized(serverStoredGroupListeners)
{
serverStoredGroupListeners.remove(listener);
}
}
/** /**
* Renames the specified group from the server stored contact list. * Renames the specified group from the server stored contact list.
* *

@ -29,17 +29,6 @@ public class OperationSetPersistentPresenceGibberishImpl
private static final Logger logger = private static final Logger logger =
Logger.getLogger(OperationSetPersistentPresenceGibberishImpl.class); Logger.getLogger(OperationSetPersistentPresenceGibberishImpl.class);
/**
* A list of listeners registered for <tt>ServerStoredGroupChangeEvent</tt>s.
*/
private Vector serverStoredGroupListeners = new Vector();
/**
* A list of listeners registered for
* <tt>ProviderPresenceStatusChangeEvent</tt>s.
*/
private Vector providerPresenceStatusListeners = new Vector();
/** /**
* The root of the gibberish contact list. * The root of the gibberish contact list.
*/ */
@ -79,104 +68,6 @@ public OperationSetPersistentPresenceGibberishImpl(
new UnregistrationListener()); new UnregistrationListener());
} }
/**
* Notifies all registered listeners of the new event.
*
* @param source the contact that has caused the event.
* @param eventID an identifier of the event to dispatch.
*/
public void fireServerStoredGroupEvent(ContactGroupGibberishImpl source,
int eventID)
{
ServerStoredGroupEvent evt = new ServerStoredGroupEvent(
source, eventID, (ContactGroupGibberishImpl)source.getParentContactGroup()
, this.parentProvider, this);
Iterator listeners = null;
synchronized (serverStoredGroupListeners)
{
listeners = new ArrayList(serverStoredGroupListeners).iterator();
}
while (listeners.hasNext())
{
ServerStoredGroupListener listener
= (ServerStoredGroupListener) listeners.next();
if(eventID == ServerStoredGroupEvent.GROUP_CREATED_EVENT)
{
listener.groupCreated(evt);
}
else if(eventID == ServerStoredGroupEvent.GROUP_RENAMED_EVENT)
{
listener.groupNameChanged(evt);
}
else if(eventID == ServerStoredGroupEvent.GROUP_REMOVED_EVENT)
{
listener.groupRemoved(evt);
}
}
}
/**
* Notifies all registered listeners of the new event.
*
* @param oldValue the presence status we were in before the change.
*/
public void fireProviderStatusChangeEvent(PresenceStatus oldValue)
{
ProviderPresenceStatusChangeEvent evt
= new ProviderPresenceStatusChangeEvent(this.parentProvider,
oldValue, this.getPresenceStatus());
Iterator listeners = null;
synchronized (providerPresenceStatusListeners)
{
listeners = new ArrayList(providerPresenceStatusListeners).iterator();
}
while (listeners.hasNext())
{
ProviderPresenceStatusListener listener
= (ProviderPresenceStatusListener) listeners.next();
listener.providerStatusChanged(evt);
}
}
/**
* Gibberish implementation of the corresponding ProtocolProviderService
* method.
*
* @param listener a dummy param.
*/
public void addProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized(providerPresenceStatusListeners)
{
if (!providerPresenceStatusListeners.contains(listener))
this.providerPresenceStatusListeners.add(listener);
}
}
/**
* Registers a listener that would receive events upon changes in server
* stored groups.
*
* @param listener a ServerStoredGroupChangeListener impl that would
* receive events upong group changes.
*/
public void addServerStoredGroupChangeListener(ServerStoredGroupListener
listener)
{
synchronized(serverStoredGroupListeners)
{
if (!serverStoredGroupListeners.contains(listener))
serverStoredGroupListeners.add(listener);
}
}
/** /**
* Creates a group with the specified name and parent in the server * Creates a group with the specified name and parent in the server
* stored contact list. * stored contact list.
@ -499,21 +390,6 @@ private void changePresenceStatusForAllContacts(ContactGroup parent,
} }
} }
/**
* Unregisters the specified listener so that it does not receive further
* events upon changes in local presence status.
*
* @param listener ProviderPresenceStatusListener
*/
public void removeProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized(providerPresenceStatusListeners)
{
this.providerPresenceStatusListeners.remove(listener);
}
}
/** /**
* Returns the group that is parent of the specified gibberishGroup or null * Returns the group that is parent of the specified gibberishGroup or null
* if no parent was found. * if no parent was found.
@ -570,22 +446,6 @@ public void removeServerStoredContactGroup(ContactGroup group)
gibberishGroup, ServerStoredGroupEvent.GROUP_REMOVED_EVENT); gibberishGroup, ServerStoredGroupEvent.GROUP_REMOVED_EVENT);
} }
/**
* Removes the specified group change listener so that it won't receive
* any further events.
*
* @param listener the ServerStoredGroupChangeListener to remove
*/
public void removeServerStoredGroupChangeListener(ServerStoredGroupListener
listener)
{
synchronized(serverStoredGroupListeners)
{
serverStoredGroupListeners.remove(listener);
}
}
/** /**
* Renames the specified group from the server stored contact list. * Renames the specified group from the server stored contact list.
* *

@ -24,9 +24,9 @@
import net.kano.joustsim.oscar.*; import net.kano.joustsim.oscar.*;
import net.kano.joustsim.oscar.oscar.service.bos.*; import net.kano.joustsim.oscar.oscar.service.bos.*;
import net.kano.joustsim.oscar.oscar.service.buddy.*; import net.kano.joustsim.oscar.oscar.service.buddy.*;
import net.kano.joustsim.oscar.oscar.service.icon.*;
import net.kano.joustsim.oscar.oscar.service.info.*; import net.kano.joustsim.oscar.oscar.service.info.*;
import net.kano.joustsim.oscar.oscar.service.ssi.*; import net.kano.joustsim.oscar.oscar.service.ssi.*;
import net.kano.joustsim.oscar.oscar.service.icon.*;
import net.kano.joustsim.trust.*; import net.kano.joustsim.trust.*;
/** /**
@ -43,18 +43,6 @@ public class OperationSetPersistentPresenceIcqImpl
private static final Logger logger = private static final Logger logger =
Logger.getLogger(OperationSetPersistentPresenceIcqImpl.class); Logger.getLogger(OperationSetPersistentPresenceIcqImpl.class);
/**
* The list of listeners interested in receiving changes in our local
* presencestatus.
*/
private Vector providerPresenceStatusListeners = new Vector();
/**
* Listeners notified upon changes occurring with server stored contact
* groups.
*/
private Vector serverStoredGroupChangeListeners = new Vector();
/** /**
* This one should actually be in joscar. But since it isn't we might as * This one should actually be in joscar. But since it isn't we might as
* well define it here. * well define it here.
@ -974,35 +962,6 @@ private void assertConnected() throws IllegalStateException
+"being able to communicate."); +"being able to communicate.");
} }
/**
* Adds a listener that would receive events upon changes of the provider
* presence status.
* @param listener the listener to register for changes in our PresenceStatus.
*/
public void addProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized(providerPresenceStatusListeners)
{
if(!providerPresenceStatusListeners.contains(listener))
providerPresenceStatusListeners.add(listener);
}
}
/**
* Unregisters the specified listener so that it does not receive further
* events upon changes in local presence status.
* @param listener ProviderPresenceStatusListener
*/
public void removeProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized(providerPresenceStatusListeners)
{
providerPresenceStatusListeners.remove(listener);
}
}
/** /**
* Returns the root group of the server stored contact list. Most often this * Returns the root group of the server stored contact list. Most often this
* would be a dummy group that user interface implementations may better not * would be a dummy group that user interface implementations may better not
@ -1040,75 +999,23 @@ public void removeServerStoredGroupChangeListener(
/** /**
* Notify all provider presence listeners of the corresponding event change * Notify all provider presence listeners of the corresponding event change
* @param oldStatusL the status our icq stack had so far *
* @param newStatusL the status we have from now on * @param oldStatusL
* the status our icq stack had so far
* @param newStatusL
* the status we have from now on
*/ */
void fireProviderPresenceStatusChangeEvent( void fireProviderPresenceStatusChangeEvent(long oldStatusL, long newStatusL)
long oldStatusL, long newStatusL)
{ {
PresenceStatus oldStatus = statusLongToPresenceStatus(oldStatusL); PresenceStatus oldStatus = statusLongToPresenceStatus(oldStatusL);
PresenceStatus newStatus = statusLongToPresenceStatus(newStatusL); PresenceStatus newStatus = statusLongToPresenceStatus(newStatusL);
if(oldStatus.equals(newStatus)){ if (oldStatus.equals(newStatus))
logger.debug("Ignored prov stat. change evt. old==new = " logger.debug(
+ oldStatus); "Ignored prov stat. change evt. old==new = "
return; + oldStatus);
} else
fireProviderStatusChangeEvent(oldStatus, newStatus);
ProviderPresenceStatusChangeEvent evt =
new ProviderPresenceStatusChangeEvent(
parentProvider, oldStatus, newStatus);
logger.debug("Dispatching Provider Status Change. Listeners="
+ providerPresenceStatusListeners.size()
+ " evt=" + evt);
Iterator listeners = null;
synchronized (providerPresenceStatusListeners)
{
listeners = new ArrayList(providerPresenceStatusListeners)
.iterator();
}
while (listeners.hasNext())
{
ProviderPresenceStatusListener listener
= (ProviderPresenceStatusListener) listeners.next();
listener.providerStatusChanged(evt);
}
}
/**
* Notify all provider presence listeners that a new status message has
* been set.
* @param oldStatusMessage the status message our icq stack had so far
* @param newStatusMessage the status message we have from now on
*/
private void fireProviderStatusMessageChangeEvent(
String oldStatusMessage, String newStatusMessage)
{
PropertyChangeEvent evt = new PropertyChangeEvent(
parentProvider, ProviderPresenceStatusListener.STATUS_MESSAGE,
oldStatusMessage, newStatusMessage);
logger.debug("Dispatching stat. msg change. Listeners="
+ providerPresenceStatusListeners.size()
+ " evt=" + evt);
Iterator listeners = null;
synchronized (providerPresenceStatusListeners)
{
listeners = new ArrayList(providerPresenceStatusListeners).iterator();
}
while (listeners.hasNext())
{
ProviderPresenceStatusListener listener
= (ProviderPresenceStatusListener) listeners.next();
listener.providerStatusMessageChanged(evt);
}
} }
/** /**

@ -56,10 +56,12 @@ public class OperationSetBasicInstantMessagingJabberImpl
* The timer executing tasks on specified intervals * The timer executing tasks on specified intervals
*/ */
private Timer keepAliveTimer = new Timer(); private Timer keepAliveTimer = new Timer();
/** /**
* The queue holding the received packets * The queue holding the received packets
*/ */
private LinkedList receivedKeepAlivePackets = new LinkedList(); private final LinkedList<KeepAliveEvent> receivedKeepAlivePackets
= new LinkedList<KeepAliveEvent>();
private int failedKeepalivePackets = 0; private int failedKeepalivePackets = 0;
@ -523,8 +525,7 @@ public void run()
boolean checkFirstPacket() boolean checkFirstPacket()
throws NoSuchElementException throws NoSuchElementException
{ {
KeepAliveEvent receivedEvent = KeepAliveEvent receivedEvent = receivedKeepAlivePackets.removeLast();
(KeepAliveEvent)receivedKeepAlivePackets.removeLast();
if(jabberProvider.hashCode() != receivedEvent.getSrcProviderHash() || if(jabberProvider.hashCode() != receivedEvent.getSrcProviderHash() ||
OperationSetBasicInstantMessagingJabberImpl.this.hashCode() != OperationSetBasicInstantMessagingJabberImpl.this.hashCode() !=
@ -546,8 +547,9 @@ void fireUnregisterd()
RegistrationState.CONNECTION_FAILED, RegistrationState.CONNECTION_FAILED,
RegistrationStateChangeEvent.REASON_INTERNAL_ERROR, null); RegistrationStateChangeEvent.REASON_INTERNAL_ERROR, null);
opSetPersPresence.fireProviderPresenceStatusChangeEvent( opSetPersPresence.fireProviderStatusChangeEvent(
opSetPersPresence.getPresenceStatus(), jabberProvider opSetPersPresence.getPresenceStatus(),
jabberProvider
.getJabberStatusEnum().getStatus(JabberStatusEnum.OFFLINE)); .getJabberStatusEnum().getStatus(JabberStatusEnum.OFFLINE));
} }
} }

@ -6,20 +6,19 @@
*/ */
package net.java.sip.communicator.impl.protocol.jabber; package net.java.sip.communicator.impl.protocol.jabber;
import java.beans.PropertyChangeEvent;
import java.util.*; import java.util.*;
import org.jivesoftware.smack.*;
import org.jivesoftware.smack.filter.*;
import org.jivesoftware.smack.packet.*;
import org.jivesoftware.smack.util.*;
import net.java.sip.communicator.impl.protocol.jabber.extensions.version.*; import net.java.sip.communicator.impl.protocol.jabber.extensions.version.*;
import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.service.protocol.jabberconstants.*; import net.java.sip.communicator.service.protocol.jabberconstants.*;
import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.*;
import org.jivesoftware.smack.*;
import org.jivesoftware.smack.filter.*;
import org.jivesoftware.smack.packet.*;
import org.jivesoftware.smack.util.*;
/** /**
* The Jabber implementation of a Persistent Presence Operation set. This class * The Jabber implementation of a Persistent Presence Operation set. This class
* manages our own presence status as well as subscriptions for the presence * manages our own presence status as well as subscriptions for the presence
@ -49,14 +48,6 @@ public class OperationSetPersistentPresenceJabberImpl
*/ */
private PresenceStatus currentStatus; private PresenceStatus currentStatus;
/**
* The list of listeners interested in receiving changes in our local
* presencestatus.
*/
private Vector<ProviderPresenceStatusListener>
providerPresenceStatusListeners
= new Vector<ProviderPresenceStatusListener>();
/** /**
* A map containing bindings between SIP Communicator's jabber presence status * A map containing bindings between SIP Communicator's jabber presence status
* instances and Jabber status codes * instances and Jabber status codes
@ -99,21 +90,6 @@ public OperationSetPersistentPresenceJabberImpl(
new RegistrationStateListener()); new RegistrationStateListener());
} }
/**
* Adds a listener that would receive events upon changes of the provider
* presence status.
*
* @param listener the listener to register for changes in our
* PresenceStatus.
*/
public void addProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized(providerPresenceStatusListeners){
providerPresenceStatusListeners.add(listener);
}
}
/** /**
* Registers a listener that would receive events upong changes in server * Registers a listener that would receive events upong changes in server
* stored groups. * stored groups.
@ -371,15 +347,13 @@ public void publishPresenceStatus(PresenceStatus status,
throw new IllegalArgumentException(status throw new IllegalArgumentException(status
+ " is not a valid Jabber status"); + " is not a valid Jabber status");
Presence presence = null;
if (status.equals(jabberStatusEnum.getStatus(JabberStatusEnum.OFFLINE))) if (status.equals(jabberStatusEnum.getStatus(JabberStatusEnum.OFFLINE)))
{ {
presence = new Presence(Presence.Type.unavailable);
parentProvider.unregister(); parentProvider.unregister();
} }
else else
{ {
presence = new Presence(Presence.Type.available); Presence presence = new Presence(Presence.Type.available);
presence.setMode(presenceStatusToJabberMode(status)); presence.setMode(presenceStatusToJabberMode(status));
presence.setPriority(resourcePriority); presence.setPriority(resourcePriority);
presence.setStatus(statusMessage); presence.setStatus(statusMessage);
@ -388,7 +362,7 @@ public void publishPresenceStatus(PresenceStatus status,
parentProvider.getConnection().sendPacket(presence); parentProvider.getConnection().sendPacket(presence);
} }
fireProviderPresenceStatusChangeEvent(currentStatus, status); fireProviderStatusChangeEvent(currentStatus, status);
if(!getCurrentStatusMessage().equals(statusMessage)) if(!getCurrentStatusMessage().equals(statusMessage))
{ {
@ -428,20 +402,6 @@ public PresenceStatus queryContactStatus(String contactIdentifier) throws
JabberStatusEnum.OFFLINE); JabberStatusEnum.OFFLINE);
} }
/**
* Unregisters the specified listener so that it does not receive further
* events upon changes in local presence status.
*
* @param listener ProviderPresenceStatusListener
*/
public void removeProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized(providerPresenceStatusListeners){
providerPresenceStatusListeners.remove(listener);
}
}
/** /**
* Removes the specified group from the server stored contact list. * Removes the specified group from the server stored contact list.
* *
@ -669,77 +629,15 @@ private void assertConnected() throws IllegalStateException
+"being able to communicate."); +"being able to communicate.");
} }
/** public void fireProviderStatusChangeEvent(
* Notify all provider presence listeners of the corresponding event change PresenceStatus oldStatus,
* @param oldStatus the status our stack had so far PresenceStatus newStatus)
* @param newStatus the status we have from now on
*/
void fireProviderPresenceStatusChangeEvent(
PresenceStatus oldStatus, PresenceStatus newStatus)
{
if(oldStatus.equals(newStatus)){
logger.debug("Ignored prov stat. change evt. old==new = "
+ oldStatus);
return;
}
ProviderPresenceStatusChangeEvent evt =
new ProviderPresenceStatusChangeEvent(
parentProvider, oldStatus, newStatus);
currentStatus = newStatus;
logger.debug("Dispatching Provider Status Change. Listeners="
+ providerPresenceStatusListeners.size()
+ " evt=" + evt);
Iterator<ProviderPresenceStatusListener> listeners = null;
synchronized (providerPresenceStatusListeners)
{
listeners = new ArrayList<ProviderPresenceStatusListener>(
providerPresenceStatusListeners).iterator();
}
while (listeners.hasNext())
{
ProviderPresenceStatusListener listener = listeners.next();
listener.providerStatusChanged(evt);
}
}
/**
* Notify all provider presence listeners that a new status message has
* been set.
* @param oldStatusMessage the status message our stack had so far
* @param newStatusMessage the status message we have from now on
*/
private void fireProviderStatusMessageChangeEvent(
String oldStatusMessage, String newStatusMessage)
{ {
if (!oldStatus.equals(newStatus))
PropertyChangeEvent evt = new PropertyChangeEvent(
parentProvider, ProviderPresenceStatusListener.STATUS_MESSAGE,
oldStatusMessage, newStatusMessage);
logger.debug("Dispatching stat. msg change. Listeners="
+ providerPresenceStatusListeners.size()
+ " evt=" + evt);
Iterator<ProviderPresenceStatusListener> listeners = null;
synchronized (providerPresenceStatusListeners)
{
listeners = new ArrayList<ProviderPresenceStatusListener>(
providerPresenceStatusListeners).iterator();
}
while (listeners.hasNext())
{ {
ProviderPresenceStatusListener listener = currentStatus = newStatus;
(ProviderPresenceStatusListener) listeners.next();
listener.providerStatusMessageChanged(evt); super.fireProviderStatusChangeEvent(oldStatus, newStatus);
} }
} }
@ -768,9 +666,11 @@ public void registrationStateChanged(RegistrationStateChangeEvent evt)
parentProvider.getConnection().getRoster().addRosterListener( parentProvider.getConnection().getRoster().addRosterListener(
new ContactChangesListener()); new ContactChangesListener());
fireProviderPresenceStatusChangeEvent(currentStatus, fireProviderStatusChangeEvent(
parentProvider.getJabberStatusEnum().getStatus( currentStatus,
JabberStatusEnum.AVAILABLE)); parentProvider
.getJabberStatusEnum()
.getStatus(JabberStatusEnum.AVAILABLE));
// init ssList // init ssList
ssContactList.init(); ssContactList.init();
@ -789,8 +689,7 @@ else if(evt.getNewState() == RegistrationState.UNREGISTERED
JabberStatusEnum.OFFLINE); JabberStatusEnum.OFFLINE);
currentStatus = offlineStatus; currentStatus = offlineStatus;
fireProviderPresenceStatusChangeEvent(oldStatus, fireProviderStatusChangeEvent(oldStatus, currentStatus);
currentStatus);
//send event notifications saying that all our buddies are //send event notifications saying that all our buddies are
//offline. The protocol does not implement top level buddies //offline. The protocol does not implement top level buddies

@ -719,9 +719,9 @@ public void connectionClosed()
OperationSetPersistentPresenceJabberImpl opSetPersPresence = OperationSetPersistentPresenceJabberImpl opSetPersPresence =
(OperationSetPersistentPresenceJabberImpl) getOperationSet(OperationSetPersistentPresence.class); (OperationSetPersistentPresenceJabberImpl) getOperationSet(OperationSetPersistentPresence.class);
opSetPersPresence.fireProviderPresenceStatusChangeEvent( opSetPersPresence.fireProviderStatusChangeEvent(
opSetPersPresence.getPresenceStatus(), getJabberStatusEnum() opSetPersPresence.getPresenceStatus(),
.getStatus(JabberStatusEnum.OFFLINE)); getJabberStatusEnum().getStatus(JabberStatusEnum.OFFLINE));
} }
/** /**

@ -20,17 +20,6 @@ public class MockPersistentPresenceOperationSet
extends AbstractOperationSetPersistentPresence<MockProvider> extends AbstractOperationSetPersistentPresence<MockProvider>
{ {
/**
* A list of listeners registered for <tt>ServerStoredGroupChangeEvent</tt>s.
*/
private Vector serverStoredGroupListeners = new Vector();
/**
* A list of listeners registered for
* <tt>ProviderPresenceStatusChangeEvent</tt>s.
*/
private Vector providerPresenceStatusListeners = new Vector();
/** /**
* The root of the mock contact list. * The root of the mock contact list.
*/ */
@ -53,103 +42,6 @@ public MockPersistentPresenceOperationSet(MockProvider provider)
contactListRoot = new MockContactGroup("RootMockGroup", provider); contactListRoot = new MockContactGroup("RootMockGroup", provider);
} }
/**
* Notifies all registered listeners of the new event.
*
* @param source the contact that has caused the event.
* @param eventID an identifier of the event to dispatch.
*/
public void fireServerStoredGroupEvent(MockContactGroup source,
int eventID)
{
ServerStoredGroupEvent evt = new ServerStoredGroupEvent(
source, eventID, (MockContactGroup)source.getParentContactGroup()
, this.parentProvider, this);
Iterator listeners = null;
synchronized (serverStoredGroupListeners)
{
listeners = new ArrayList(serverStoredGroupListeners).iterator();
}
while (listeners.hasNext())
{
ServerStoredGroupListener listener
= (ServerStoredGroupListener) listeners.next();
if(eventID == ServerStoredGroupEvent.GROUP_CREATED_EVENT)
{
listener.groupCreated(evt);
}
else if(eventID == ServerStoredGroupEvent.GROUP_RENAMED_EVENT)
{
listener.groupNameChanged(evt);
}
else if(eventID == ServerStoredGroupEvent.GROUP_REMOVED_EVENT)
{
listener.groupRemoved(evt);
}
}
}
/**
* Notifies all registered listeners of the new event.
*
* @param oldValue the presence status we were in before the change.
*/
public void fireProviderStatusChangeEvent(PresenceStatus oldValue)
{
ProviderPresenceStatusChangeEvent evt
= new ProviderPresenceStatusChangeEvent(this.parentProvider,
oldValue, this.getPresenceStatus());
Iterator listeners = null;
synchronized (providerPresenceStatusListeners)
{
listeners = new ArrayList(providerPresenceStatusListeners).iterator();
}
while (listeners.hasNext())
{
ProviderPresenceStatusListener listener
= (ProviderPresenceStatusListener) listeners.next();
listener.providerStatusChanged(evt);
}
}
/**
* Mock implementation of the corresponding ProtocolProviderService method.
*
* @param listener a dummy param.
*/
public void addProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized(providerPresenceStatusListeners)
{
if (!providerPresenceStatusListeners.contains(listener))
this.providerPresenceStatusListeners.add(listener);
}
}
/**
* Registers a listener that would receive events upon changes in server
* stored groups.
*
* @param listener a ServerStoredGroupChangeListener impl that would
* receive events upong group changes.
*/
public void addServerStoredGroupChangeListener(ServerStoredGroupListener
listener)
{
synchronized(serverStoredGroupListeners)
{
if (!serverStoredGroupListeners.contains(listener))
serverStoredGroupListeners.add(listener);
}
}
/** /**
* Creates a group with the specified name and parent in the server * Creates a group with the specified name and parent in the server
* stored contact list. * stored contact list.
@ -365,21 +257,6 @@ public void changePresenceStatusForContact(MockContact contact
contact, findContactParent(contact), oldStatus); contact, findContactParent(contact), oldStatus);
} }
/**
* Unregisters the specified listener so that it does not receive further
* events upon changes in local presence status.
*
* @param listener ProviderPresenceStatusListener
*/
public void removeProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized(providerPresenceStatusListeners)
{
this.providerPresenceStatusListeners.remove(listener);
}
}
/** /**
* Returns the group that is parent of the specified mockGroup or null * Returns the group that is parent of the specified mockGroup or null
* if no parent was found. * if no parent was found.
@ -432,22 +309,6 @@ public void removeServerStoredContactGroup(ContactGroup group)
mockGroup, ServerStoredGroupEvent.GROUP_REMOVED_EVENT); mockGroup, ServerStoredGroupEvent.GROUP_REMOVED_EVENT);
} }
/**
* Removes the specified group change listener so that it won't receive
* any further events.
*
* @param listener the ServerStoredGroupChangeListener to remove
*/
public void removeServerStoredGroupChangeListener(ServerStoredGroupListener
listener)
{
synchronized(serverStoredGroupListeners)
{
serverStoredGroupListeners.remove(listener);
}
}
/** /**
* Renames the specified group from the server stored contact list. * Renames the specified group from the server stored contact list.
* *

@ -6,7 +6,6 @@
*/ */
package net.java.sip.communicator.impl.protocol.msn; package net.java.sip.communicator.impl.protocol.msn;
import java.beans.PropertyChangeEvent;
import java.util.*; import java.util.*;
import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.*;
@ -43,14 +42,6 @@ public class OperationSetPersistentPresenceMsnImpl
*/ */
private PresenceStatus currentStatus = MsnStatusEnum.OFFLINE; private PresenceStatus currentStatus = MsnStatusEnum.OFFLINE;
/**
* The list of listeners interested in receiving changes in our local
* presence status.
*/
private Vector<ProviderPresenceStatusListener>
providerPresenceStatusListeners
= new Vector<ProviderPresenceStatusListener>();
/** /**
* Sometimes status changes are received before the contact list is inited * Sometimes status changes are received before the contact list is inited
* here we store such events so we can show them correctly * here we store such events so we can show them correctly
@ -122,21 +113,6 @@ public OperationSetPersistentPresenceMsnImpl(
new RegistrationStateListener()); new RegistrationStateListener());
} }
/**
* Adds a listener that would receive events upon changes of the provider
* presence status.
*
* @param listener the listener to register for changes in our
* PresenceStatus.
*/
public void addProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized(providerPresenceStatusListeners){
providerPresenceStatusListeners.add(listener);
}
}
/** /**
* Registers a listener that would receive events upon changes in server * Registers a listener that would receive events upon changes in server
* stored groups. * stored groups.
@ -427,20 +403,6 @@ public PresenceStatus queryContactStatus(String contactIdentifier) throws
return msnStatusToPresenceStatus(contact.getSourceContact().getStatus()); return msnStatusToPresenceStatus(contact.getSourceContact().getStatus());
} }
/**
* Unregisters the specified listener so that it does not receive further
* events upon changes in local presence status.
*
* @param listener ProviderPresenceStatusListener
*/
public void removeProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized(providerPresenceStatusListeners){
providerPresenceStatusListeners.remove(listener);
}
}
/** /**
* Removes the specified group from the server stored contact list. * Removes the specified group from the server stored contact list.
* *
@ -638,74 +600,20 @@ private void assertConnected() throws IllegalStateException
/** /**
* Notify all provider presence listeners of the corresponding event change * Notify all provider presence listeners of the corresponding event change
* @param oldStatus the status our stack had so far *
* @param newStatus the status we have from now on * @param oldStatus
*/ * the status our stack had so far
void fireProviderPresenceStatusChangeEvent( * @param newStatus
PresenceStatus oldStatus, PresenceStatus newStatus) * the status we have from now on
{
if(oldStatus.equals(newStatus)){
logger.debug("Ignored prov stat. change evt. old==new = "
+ oldStatus);
return;
}
ProviderPresenceStatusChangeEvent evt =
new ProviderPresenceStatusChangeEvent(
parentProvider, oldStatus, newStatus);
currentStatus = newStatus;
logger.debug("Dispatching Provider Status Change. Listeners="
+ providerPresenceStatusListeners.size()
+ " evt=" + evt);
Iterator<ProviderPresenceStatusListener> listeners = null;
synchronized (providerPresenceStatusListeners)
{
listeners = new ArrayList<ProviderPresenceStatusListener>(
providerPresenceStatusListeners).iterator();
}
while (listeners.hasNext())
{
ProviderPresenceStatusListener listener = listeners.next();
listener.providerStatusChanged(evt);
}
}
/**
* Notify all provider presence listeners that a new status message has
* been set.
* @param oldStatusMessage the status message our stack had so far
* @param newStatusMessage the status message we have from now on
*/ */
private void fireProviderStatusMessageChangeEvent( protected void fireProviderStatusChangeEvent(
String oldStatusMessage, String newStatusMessage) PresenceStatus oldStatus,
PresenceStatus newStatus)
{ {
if (!oldStatus.equals(newStatus)) {
currentStatus = newStatus;
PropertyChangeEvent evt = new PropertyChangeEvent( super.fireProviderStatusChangeEvent(oldStatus, newStatus);
parentProvider, ProviderPresenceStatusListener.STATUS_MESSAGE,
oldStatusMessage, newStatusMessage);
logger.debug("Dispatching stat. msg change. Listeners="
+ providerPresenceStatusListeners.size()
+ " evt=" + evt);
Iterator<ProviderPresenceStatusListener> listeners = null;
synchronized (providerPresenceStatusListeners)
{
listeners = new ArrayList<ProviderPresenceStatusListener>(
providerPresenceStatusListeners).iterator();
}
while (listeners.hasNext())
{
ProviderPresenceStatusListener listener = listeners.next();
listener.providerStatusMessageChanged(evt);
} }
} }
@ -745,8 +653,7 @@ else if(evt.getNewState() == RegistrationState.UNREGISTERED
PresenceStatus oldStatus = currentStatus; PresenceStatus oldStatus = currentStatus;
currentStatus = MsnStatusEnum.OFFLINE; currentStatus = MsnStatusEnum.OFFLINE;
fireProviderPresenceStatusChangeEvent(oldStatus, fireProviderStatusChangeEvent(oldStatus, currentStatus);
currentStatus);
//send event notifications saying that all our buddies are //send event notifications saying that all our buddies are
//offline. //offline.
@ -873,7 +780,7 @@ public void ownerStatusChanged(MsnMessenger messenger)
PresenceStatus oldStatus = currentStatus; PresenceStatus oldStatus = currentStatus;
currentStatus = currentStatus =
msnStatusToPresenceStatus(messenger.getOwner().getStatus()); msnStatusToPresenceStatus(messenger.getOwner().getStatus());
fireProviderPresenceStatusChangeEvent(oldStatus, currentStatus); fireProviderStatusChangeEvent(oldStatus, currentStatus);
} }
/** /**

@ -30,17 +30,6 @@ public class OperationSetPersistentPresenceRssImpl
private static final Logger logger = private static final Logger logger =
Logger.getLogger(OperationSetPersistentPresenceRssImpl.class); Logger.getLogger(OperationSetPersistentPresenceRssImpl.class);
/**
* A list of listeners registered for <tt>ServerStoredGroupChangeEvent</tt>s.
*/
private Vector serverStoredGroupListeners = new Vector();
/**
* A list of listeners registered for
* <tt>ProviderPresenceStatusChangeEvent</tt>s.
*/
private Vector providerPresenceStatusListeners = new Vector();
/** /**
* The root of the RSS contact list. * The root of the RSS contact list.
*/ */
@ -89,102 +78,14 @@ public OperationSetPersistentPresenceRssImpl(
imageRetriever.start(); imageRetriever.start();
} }
/** /*
* Notifies all registered listeners of the new event. * Overrides
* * AbstractOperationSetPersistentPresence#fireProviderStatusChangeEvent
* @param source the contact that has caused the event. * (PresenceStatus) to stop the firing of an event.
* @param eventID an identifier of the event to dispatch.
*/
public void fireServerStoredGroupEvent(ContactGroupRssImpl source,
int eventID)
{
ServerStoredGroupEvent evt = new ServerStoredGroupEvent(
source, eventID, (ContactGroupRssImpl)source.getParentContactGroup()
, this.parentProvider, this);
Iterator listeners = null;
synchronized (serverStoredGroupListeners)
{
listeners = new ArrayList(serverStoredGroupListeners).iterator();
}
while (listeners.hasNext())
{
ServerStoredGroupListener listener
= (ServerStoredGroupListener) listeners.next();
if(eventID == ServerStoredGroupEvent.GROUP_CREATED_EVENT)
{
listener.groupCreated(evt);
}
else if(eventID == ServerStoredGroupEvent.GROUP_RENAMED_EVENT)
{
listener.groupNameChanged(evt);
}
else if(eventID == ServerStoredGroupEvent.GROUP_REMOVED_EVENT)
{
listener.groupRemoved(evt);
}
}
}
/**
* Notifies all registered listeners of the new event.
*
* @param oldValue the presence status we were in before the change.
*/ */
public void fireProviderStatusChangeEvent(PresenceStatus oldValue) protected void fireProviderStatusChangeEvent(PresenceStatus oldValue)
{ {
ProviderPresenceStatusChangeEvent evt // Override the super implementation and stop the firing of an event.
= new ProviderPresenceStatusChangeEvent(this.parentProvider,
oldValue, this.getPresenceStatus());
Iterator listeners = null;
synchronized (providerPresenceStatusListeners)
{
listeners = new ArrayList(providerPresenceStatusListeners).iterator();
}
while (listeners.hasNext())
{
ProviderPresenceStatusListener listener
= (ProviderPresenceStatusListener) listeners.next();
//listener.providerStatusChanged(evt);
}
}
/**
* RSS implementation of the corresponding ProtocolProviderService
* method.
*
* @param listener a dummy parameter.
*/
public void addProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized(providerPresenceStatusListeners)
{
if (!providerPresenceStatusListeners.contains(listener))
this.providerPresenceStatusListeners.add(listener);
}
}
/**
* Registers a listener that would receive events upon changes in server
* stored groups.
*
* @param listener a ServerStoredGroupChangeListener implementation that
* would receive events upon group changes.
*/
public void addServerStoredGroupChangeListener(ServerStoredGroupListener
listener)
{
synchronized(serverStoredGroupListeners)
{
if (!serverStoredGroupListeners.contains(listener))
serverStoredGroupListeners.add(listener);
}
} }
/** /**
@ -493,21 +394,6 @@ private void changePresenceStatusForAllContacts(ContactGroup parent,
} }
} }
/**
* Unregisters the specified listener so that it does not receive further
* events upon changes in local presence status.
*
* @param listener ProviderPresenceStatusListener
*/
public void removeProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized(providerPresenceStatusListeners)
{
this.providerPresenceStatusListeners.remove(listener);
}
}
/** /**
* Returns the group that is parent of the specified rssGroup or null * Returns the group that is parent of the specified rssGroup or null
* if no parent was found. * if no parent was found.
@ -560,22 +446,6 @@ public void removeServerStoredContactGroup(ContactGroup group)
rssGroup, ServerStoredGroupEvent.GROUP_REMOVED_EVENT); rssGroup, ServerStoredGroupEvent.GROUP_REMOVED_EVENT);
} }
/**
* Removes the specified group change listener so that it won't receive
* any further events.
*
* @param listener the ServerStoredGroupChangeListener to remove
*/
public void removeServerStoredGroupChangeListener(ServerStoredGroupListener
listener)
{
synchronized(serverStoredGroupListeners)
{
serverStoredGroupListeners.remove(listener);
}
}
/** /**
* Renames the specified group from the server stored contact list. * Renames the specified group from the server stored contact list.
* *

@ -7,12 +7,13 @@
package net.java.sip.communicator.impl.protocol.sip; package net.java.sip.communicator.impl.protocol.sip;
import java.util.*; import java.util.*;
import javax.sip.*; import javax.sip.*;
import net.java.sip.communicator.service.media.*;
import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.*;
import net.java.sip.communicator.service.media.*;
/** /**
* A SIP implementation of the Call abstract class encapsulating SIP dialogs. * A SIP implementation of the Call abstract class encapsulating SIP dialogs.
@ -28,7 +29,7 @@ public class CallSipImpl
/** /**
* A list containing all <tt>CallParticipant</tt>s of this call. * A list containing all <tt>CallParticipant</tt>s of this call.
*/ */
private Vector<CallParticipantSipImpl> callParticipants = private final List<CallParticipantSipImpl> callParticipants =
new Vector<CallParticipantSipImpl>(); new Vector<CallParticipantSipImpl>();
/** /**
@ -212,7 +213,7 @@ public boolean contains(Dialog dialog)
*/ */
public CallParticipantSipImpl findCallParticipant(Dialog dialog) public CallParticipantSipImpl findCallParticipant(Dialog dialog)
{ {
Iterator callParticipants = this.getCallParticipants(); Iterator<CallParticipant> callParticipants = this.getCallParticipants();
if (logger.isTraceEnabled()) if (logger.isTraceEnabled())
{ {

@ -1503,7 +1503,7 @@ private Header stripReplacesHeader(Address address)
if (replacesHeaderValue != null) if (replacesHeaderValue != null)
{ {
for (Iterator<String> headerNameIter = sipURI.getHeaderNames(); for (Iterator<?> headerNameIter = sipURI.getHeaderNames();
headerNameIter.hasNext();) headerNameIter.hasNext();)
{ {
if (ReplacesHeader.NAME.equals(headerNameIter.next())) if (ReplacesHeader.NAME.equals(headerNameIter.next()))

@ -6,7 +6,6 @@
*/ */
package net.java.sip.communicator.impl.protocol.sip; package net.java.sip.communicator.impl.protocol.sip;
import java.beans.PropertyChangeEvent;
import java.io.*; import java.io.*;
import java.text.*; import java.text.*;
import java.util.*; import java.util.*;
@ -43,21 +42,6 @@ public class OperationSetPresenceSipImpl
private static final Logger logger = private static final Logger logger =
Logger.getLogger(OperationSetPresenceSipImpl.class); Logger.getLogger(OperationSetPresenceSipImpl.class);
/**
* A list of listeners registered for
* <tt>ProviderPresenceStatusChangeEvent</tt>s.
*/
private Vector<ProviderPresenceStatusListener>
providerPresenceStatusListeners
= new Vector<ProviderPresenceStatusListener>();
/**
* A list of listeners registered for
* <tt>ServerStoredGroupChangeEvent</tt>s.
*/
private Vector<ServerStoredGroupListener> serverStoredGroupListeners
= new Vector<ServerStoredGroupListener>();
/** /**
* The root of the SIP contact list. * The root of the SIP contact list.
*/ */
@ -321,46 +305,6 @@ public void setDistantPA(boolean useDistPA)
this.useDistantPA = useDistPA; this.useDistantPA = useDistPA;
} }
/**
* Notifies all registered listeners of the new event.
*
* @param source the contact that has caused the event.
* @param eventID an identifier of the event to dispatch.
*/
public void fireServerStoredGroupEvent(ContactGroupSipImpl source,
int eventID)
{
ServerStoredGroupEvent evt = new ServerStoredGroupEvent(
source, eventID, source.getParentContactGroup(),
this.parentProvider, this);
Iterator listeners = null;
synchronized (this.serverStoredGroupListeners)
{
listeners = new ArrayList(this.serverStoredGroupListeners)
.iterator();
}
while (listeners.hasNext())
{
ServerStoredGroupListener listener
= (ServerStoredGroupListener) listeners.next();
if(eventID == ServerStoredGroupEvent.GROUP_CREATED_EVENT)
{
listener.groupCreated(evt);
}
else if(eventID == ServerStoredGroupEvent.GROUP_RENAMED_EVENT)
{
listener.groupNameChanged(evt);
}
else if(eventID == ServerStoredGroupEvent.GROUP_REMOVED_EVENT)
{
listener.groupRemoved(evt);
}
}
}
/** /**
* Returns the root group of the server stored contact list. * Returns the root group of the server stored contact list.
* *
@ -671,38 +615,6 @@ public void publishPresenceStatus(PresenceStatus status,
this.fireProviderMsgStatusChangeEvent(oldMessage); this.fireProviderMsgStatusChangeEvent(oldMessage);
} }
/**
* Notifies all registered listeners of the new event.
*
* @param oldValue the presence status we were in before the change.
*/
private void fireProviderStatusChangeEvent(PresenceStatus oldValue)
{
ProviderPresenceStatusChangeEvent evt
= new ProviderPresenceStatusChangeEvent(this.parentProvider,
oldValue, this.getPresenceStatus());
logger.debug("Dispatching Provider Status Change. Listeners="
+ this.providerPresenceStatusListeners.size()
+ " evt=" + evt);
Iterator listeners = null;
synchronized (this.providerPresenceStatusListeners)
{
listeners = new ArrayList(this.providerPresenceStatusListeners)
.iterator();
}
while (listeners.hasNext())
{
ProviderPresenceStatusListener listener
= (ProviderPresenceStatusListener) listeners.next();
listener.providerStatusChanged(evt);
}
logger.debug("status dispatching done.");
}
/** /**
* Notifies all registered listeners of the new event. * Notifies all registered listeners of the new event.
* *
@ -710,31 +622,7 @@ private void fireProviderStatusChangeEvent(PresenceStatus oldValue)
*/ */
public void fireProviderMsgStatusChangeEvent(String oldValue) public void fireProviderMsgStatusChangeEvent(String oldValue)
{ {
PropertyChangeEvent evt = new PropertyChangeEvent( fireProviderStatusMessageChangeEvent(oldValue, this.statusMessage);
this.parentProvider,
ProviderPresenceStatusListener.STATUS_MESSAGE,
oldValue,
this.statusMessage);
logger.debug("Dispatching stat. msg change. Listeners="
+ this.providerPresenceStatusListeners.size()
+ " evt=" + evt);
Iterator<ProviderPresenceStatusListener> listeners = null;
synchronized (this.providerPresenceStatusListeners)
{
listeners = new ArrayList<ProviderPresenceStatusListener>(
this.providerPresenceStatusListeners).iterator();
}
while (listeners.hasNext())
{
ProviderPresenceStatusListener listener =
(ProviderPresenceStatusListener) listeners.next();
listener.providerStatusMessageChanged(evt);
}
logger.debug("status dispatching done.");
} }
/** /**
@ -3348,70 +3236,6 @@ public void setAuthorizationHandler(AuthorizationHandler handler)
// authorizations aren't supported by this implementation // authorizations aren't supported by this implementation
} }
/**
* Adds a listener that would receive events upon changes of the provider
* presence status.
*
* @param listener the listener to register for changes in our
* PresenceStatus.
*/
public void addProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized(this.providerPresenceStatusListeners)
{
if (!this.providerPresenceStatusListeners.contains(listener))
this.providerPresenceStatusListeners.add(listener);
}
}
/**
* Unregisters the specified listener so that it does not receive further
* events upon changes in local presence status.
*
* @param listener ProviderPresenceStatusListener
*/
public void removeProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized(this.providerPresenceStatusListeners)
{
this.providerPresenceStatusListeners.remove(listener);
}
}
/**
* Registers a listener that would receive events upon changes in server
* stored groups.
*
* @param listener a ServerStoredGroupChangeListener impl that would
* receive events upon group changes.
*/
public void addServerStoredGroupChangeListener(ServerStoredGroupListener
listener)
{
synchronized(this.serverStoredGroupListeners)
{
if (!this.serverStoredGroupListeners.contains(listener))
this.serverStoredGroupListeners.add(listener);
}
}
/**
* Removes the specified group change listener so that it won't receive
* any further events.
*
* @param listener the ServerStoredGroupChangeListener to remove
*/
public void removeServerStoredGroupChangeListener(ServerStoredGroupListener
listener)
{
synchronized(this.serverStoredGroupListeners)
{
this.serverStoredGroupListeners.remove(listener);
}
}
/** /**
* Returns the status message that was confirmed by the server * Returns the status message that was confirmed by the server
* *

@ -33,17 +33,6 @@ public class OperationSetPersistentPresenceSSHImpl
{ {
private static final Logger logger = private static final Logger logger =
Logger.getLogger(OperationSetPersistentPresenceSSHImpl.class); Logger.getLogger(OperationSetPersistentPresenceSSHImpl.class);
/**
* A list of listeners registered for <tt>ServerStoredGroupChangeEvent</tt>s.
*/
private Vector serverStoredGroupListeners = new Vector();
/**
* A list of listeners registered for
* <tt>ProviderPresenceStatusChangeEvent</tt>s.
*/
private Vector providerPresenceStatusListeners = new Vector();
/** /**
* The root of the ssh contact list. * The root of the ssh contact list.
@ -98,109 +87,6 @@ public void changeContactPresenceStatus(
fireProviderStatusChangeEvent(oldStatus); fireProviderStatusChangeEvent(oldStatus);
} }
/**
* Notifies all registered listeners of the new event.
*
* @param source the contact that has caused the event.
* @param eventID an identifier of the event to dispatch.
*/
public void fireServerStoredGroupEvent(
ContactGroupSSHImpl source,
int eventID)
{
ServerStoredGroupEvent evt = new ServerStoredGroupEvent(
source,
eventID,
(ContactGroupSSHImpl)source.getParentContactGroup(),
this.parentProvider,
this);
Iterator listeners = null;
synchronized (serverStoredGroupListeners)
{
listeners = new ArrayList(serverStoredGroupListeners).iterator();
}
while (listeners.hasNext())
{
ServerStoredGroupListener listener
= (ServerStoredGroupListener) listeners.next();
if(eventID == ServerStoredGroupEvent.GROUP_CREATED_EVENT)
{
listener.groupCreated(evt);
}
else if(eventID == ServerStoredGroupEvent.GROUP_RENAMED_EVENT)
{
listener.groupNameChanged(evt);
}
else if(eventID == ServerStoredGroupEvent.GROUP_REMOVED_EVENT)
{
listener.groupRemoved(evt);
}
}
}
/**
* Notifies all registered listeners of the new event.
*
* @param oldValue the presence status we were in before the change.
*/
public void fireProviderStatusChangeEvent(PresenceStatus oldValue)
{
ProviderPresenceStatusChangeEvent evt
= new ProviderPresenceStatusChangeEvent(this.parentProvider,
oldValue, this.getPresenceStatus());
Iterator listeners = null;
synchronized (providerPresenceStatusListeners)
{
listeners = new ArrayList(providerPresenceStatusListeners)
.iterator();
}
while (listeners.hasNext())
{
ProviderPresenceStatusListener listener
= (ProviderPresenceStatusListener) listeners.next();
listener.providerStatusChanged(evt);
}
}
/**
* SSH implementation of the corresponding ProtocolProviderService
* method.
*
* @param listener a dummy param.
*/
public void addProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized(providerPresenceStatusListeners)
{
if (!providerPresenceStatusListeners.contains(listener))
this.providerPresenceStatusListeners.add(listener);
}
}
/**
* Registers a listener that would receive events upon changes in server
* stored groups.
*
* @param listener a ServerStoredGroupChangeListener impl that would
* receive events upong group changes.
*/
public void addServerStoredGroupChangeListener(
ServerStoredGroupListener listener)
{
synchronized(serverStoredGroupListeners)
{
if (!serverStoredGroupListeners.contains(listener))
serverStoredGroupListeners.add(listener);
}
}
/** /**
* Creates a group with the specified name and parent in the server * Creates a group with the specified name and parent in the server
* stored contact list. * stored contact list.
@ -527,21 +413,6 @@ private void changePresenceStatusForAllContacts(
} }
} }
/**
* Unregisters the specified listener so that it does not receive further
* events upon changes in local presence status.
*
* @param listener ProviderPresenceStatusListener
*/
public void removeProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized(providerPresenceStatusListeners)
{
this.providerPresenceStatusListeners.remove(listener);
}
}
/** /**
* Returns the group that is parent of the specified sshGroup or null * Returns the group that is parent of the specified sshGroup or null
* if no parent was found. * if no parent was found.
@ -599,22 +470,6 @@ public void removeServerStoredContactGroup(ContactGroup group)
this.fireServerStoredGroupEvent( this.fireServerStoredGroupEvent(
sshGroup, ServerStoredGroupEvent.GROUP_REMOVED_EVENT); sshGroup, ServerStoredGroupEvent.GROUP_REMOVED_EVENT);
} }
/**
* Removes the specified group change listener so that it won't receive
* any further events.
*
* @param listener the ServerStoredGroupChangeListener to remove
*/
public void removeServerStoredGroupChangeListener(
ServerStoredGroupListener listener)
{
synchronized(serverStoredGroupListeners)
{
serverStoredGroupListeners.remove(listener);
}
}
/** /**
* Renames the specified group from the server stored contact list. * Renames the specified group from the server stored contact list.

@ -6,7 +6,6 @@
*/ */
package net.java.sip.communicator.impl.protocol.yahoo; package net.java.sip.communicator.impl.protocol.yahoo;
import java.beans.PropertyChangeEvent;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
@ -14,7 +13,6 @@
import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.service.protocol.yahooconstants.*; import net.java.sip.communicator.service.protocol.yahooconstants.*;
import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.*;
import ymsg.network.*; import ymsg.network.*;
import ymsg.network.event.*; import ymsg.network.event.*;
@ -45,12 +43,6 @@ public class OperationSetPersistentPresenceYahooImpl
*/ */
private PresenceStatus currentStatus = YahooStatusEnum.OFFLINE; private PresenceStatus currentStatus = YahooStatusEnum.OFFLINE;
/**
* The list of listeners interested in receiving changes in our local
* presencestatus.
*/
private Vector providerPresenceStatusListeners = new Vector();
/** /**
* Sometimes status changes are received before the contact list is inited * Sometimes status changes are received before the contact list is inited
* here we store such events so we can show them correctly * here we store such events so we can show them correctly
@ -143,21 +135,6 @@ public OperationSetPersistentPresenceYahooImpl(
new RegistrationStateListener()); new RegistrationStateListener());
} }
/**
* Adds a listener that would receive events upon changes of the provider
* presence status.
*
* @param listener the listener to register for changes in our
* PresenceStatus.
*/
public void addProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized(providerPresenceStatusListeners){
providerPresenceStatusListeners.add(listener);
}
}
/** /**
* Registers a listener that would receive events upong changes in server * Registers a listener that would receive events upong changes in server
* stored groups. * stored groups.
@ -425,7 +402,7 @@ public void publishPresenceStatus(PresenceStatus status,
parentProvider.getYahooSession().setStatus( parentProvider.getYahooSession().setStatus(
scToYahooModesMappings.get(status).longValue()); scToYahooModesMappings.get(status).longValue());
fireProviderPresenceStatusChangeEvent(currentStatus, status); fireProviderStatusChangeEvent(currentStatus, status);
} }
catch(IOException ex) catch(IOException ex)
{ {
@ -464,20 +441,6 @@ public PresenceStatus queryContactStatus(String contactIdentifier) throws
return yahooStatusToPresenceStatus(contact.getSourceContact().getStatus()); return yahooStatusToPresenceStatus(contact.getSourceContact().getStatus());
} }
/**
* Unregisters the specified listener so that it does not receive further
* events upon changes in local presence status.
*
* @param listener ProviderPresenceStatusListener
*/
public void removeProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized(providerPresenceStatusListeners){
providerPresenceStatusListeners.remove(listener);
}
}
/** /**
* Removes the specified group from the server stored contact list. * Removes the specified group from the server stored contact list.
* *
@ -687,74 +650,21 @@ private void assertConnected() throws IllegalStateException
/** /**
* Notify all provider presence listeners of the corresponding event change * Notify all provider presence listeners of the corresponding event change
* @param oldStatus the status our stack had so far *
* @param newStatus the status we have from now on * @param oldStatus
* the status our stack had so far
* @param newStatus
* the status we have from now on
*/ */
void fireProviderPresenceStatusChangeEvent( protected void fireProviderStatusChangeEvent(
PresenceStatus oldStatus, PresenceStatus newStatus) PresenceStatus oldStatus,
PresenceStatus newStatus)
{ {
if(oldStatus.equals(newStatus)){ if (!oldStatus.equals(newStatus))
logger.debug("Ignored prov stat. change evt. old==new = "
+ oldStatus);
return;
}
ProviderPresenceStatusChangeEvent evt =
new ProviderPresenceStatusChangeEvent(
parentProvider, oldStatus, newStatus);
currentStatus = newStatus;
logger.debug("Dispatching Provider Status Change. Listeners="
+ providerPresenceStatusListeners.size()
+ " evt=" + evt);
Iterator listeners = null;
synchronized (providerPresenceStatusListeners)
{
listeners = new ArrayList(providerPresenceStatusListeners).iterator();
}
while (listeners.hasNext())
{ {
ProviderPresenceStatusListener listener currentStatus = newStatus;
= (ProviderPresenceStatusListener) listeners.next();
listener.providerStatusChanged(evt); super.fireProviderStatusChangeEvent(oldStatus, newStatus);
}
}
/**
* Notify all provider presence listeners that a new status message has
* been set.
* @param oldStatusMessage the status message our stack had so far
* @param newStatusMessage the status message we have from now on
*/
private void fireProviderStatusMessageChangeEvent(
String oldStatusMessage, String newStatusMessage)
{
PropertyChangeEvent evt = new PropertyChangeEvent(
parentProvider, ProviderPresenceStatusListener.STATUS_MESSAGE,
oldStatusMessage, newStatusMessage);
logger.debug("Dispatching stat. msg change. Listeners="
+ providerPresenceStatusListeners.size()
+ " evt=" + evt);
Iterator listeners = null;
synchronized (providerPresenceStatusListeners)
{
listeners = new ArrayList(providerPresenceStatusListeners).iterator();
}
while (listeners.hasNext())
{
ProviderPresenceStatusListener listener =
(ProviderPresenceStatusListener) listeners.next();
listener.providerStatusMessageChanged(evt);
} }
} }
@ -837,8 +747,7 @@ else if(evt.getNewState() == RegistrationState.UNREGISTERED
PresenceStatus oldStatus = currentStatus; PresenceStatus oldStatus = currentStatus;
currentStatus = YahooStatusEnum.OFFLINE; currentStatus = YahooStatusEnum.OFFLINE;
fireProviderPresenceStatusChangeEvent(oldStatus, fireProviderStatusChangeEvent(oldStatus, currentStatus);
currentStatus);
removeSubscriptionListener(statusUpdater); removeSubscriptionListener(statusUpdater);
@ -900,7 +809,7 @@ private void handleContactStatusChange(YahooUser yFriend)
PresenceStatus oldStatus = currentStatus; PresenceStatus oldStatus = currentStatus;
currentStatus = currentStatus =
yahooStatusToPresenceStatus(yFriend.getStatus()); yahooStatusToPresenceStatus(yFriend.getStatus());
fireProviderPresenceStatusChangeEvent(oldStatus, currentStatus); fireProviderStatusChangeEvent(oldStatus, currentStatus);
return; return;
} }
@ -962,7 +871,8 @@ else if(evt.getFriends() != null)
/** /**
* Updates the statuses of newly created persistent contacts * Updates the statuses of newly created persistent contacts
*/ */
private class StatusUpdater implements SubscriptionListener private class StatusUpdater
extends SubscriptionAdapter
{ {
public void subscriptionCreated(SubscriptionEvent evt) public void subscriptionCreated(SubscriptionEvent evt)
{ {
@ -974,12 +884,6 @@ public void subscriptionCreated(SubscriptionEvent evt)
handleContactStatusChange(contact, contact.getSourceContact()); handleContactStatusChange(contact, contact.getSourceContact());
} }
public void subscriptionFailed(SubscriptionEvent evt) {}
public void subscriptionRemoved(SubscriptionEvent evt) {}
public void subscriptionMoved(SubscriptionMovedEvent evt) {}
public void subscriptionResolved(SubscriptionEvent evt) {}
public void contactModified(ContactPropertyChangeEvent evt) {}
} }
private class EarlyEventListener private class EarlyEventListener

@ -165,7 +165,7 @@ private void connectAndLogin( SecurityAuthority authority,
if(yahooSession.getSessionStatus()==StatusConstants.MESSAGING) if(yahooSession.getSessionStatus()==StatusConstants.MESSAGING)
{ {
persistentPresence.fireProviderPresenceStatusChangeEvent( persistentPresence.fireProviderStatusChangeEvent(
persistentPresence.getPresenceStatus(), persistentPresence.getPresenceStatus(),
persistentPresence.yahooStatusToPresenceStatus( persistentPresence.yahooStatusToPresenceStatus(
yahooSession.getStatus())); yahooSession.getStatus()));

@ -32,17 +32,6 @@ public class OperationSetPersistentPresenceZeroconfImpl
private static final Logger logger = private static final Logger logger =
Logger.getLogger(OperationSetPersistentPresenceZeroconfImpl.class); Logger.getLogger(OperationSetPersistentPresenceZeroconfImpl.class);
/**
* A list of listeners registered for <tt>ServerStoredGroupChangeEvent</tt>s.
*/
private Vector serverStoredGroupListeners = new Vector();
/**
* A list of listeners registered for
* <tt>ProviderPresenceStatusChangeEvent</tt>s.
*/
private Vector providerPresenceStatusListeners = new Vector();
/** /**
* The root of the zeroconf contact list. * The root of the zeroconf contact list.
*/ */
@ -82,106 +71,6 @@ public OperationSetPersistentPresenceZeroconfImpl(
new UnregistrationListener()); new UnregistrationListener());
} }
/**
* Notifies all registered listeners of the new event.
*
* @param source the contact that has caused the event.
* @param eventID an identifier of the event to dispatch.
*/
public void fireServerStoredGroupEvent(ContactGroupZeroconfImpl source,
int eventID)
{
ServerStoredGroupEvent evt = new ServerStoredGroupEvent(
source, eventID, (ContactGroupZeroconfImpl)
source.getParentContactGroup()
, this.parentProvider, this);
Iterator listeners = null;
synchronized (serverStoredGroupListeners)
{
listeners = new ArrayList(serverStoredGroupListeners).iterator();
}
while (listeners.hasNext())
{
ServerStoredGroupListener listener
= (ServerStoredGroupListener) listeners.next();
if(eventID == ServerStoredGroupEvent.GROUP_CREATED_EVENT)
{
listener.groupCreated(evt);
}
else if(eventID == ServerStoredGroupEvent.GROUP_RENAMED_EVENT)
{
listener.groupNameChanged(evt);
}
else if(eventID == ServerStoredGroupEvent.GROUP_REMOVED_EVENT)
{
listener.groupRemoved(evt);
}
}
}
/**
* Notifies all registered listeners of the new event.
*
* @param oldValue the presence status we were in before the change.
*/
public void fireProviderStatusChangeEvent(PresenceStatus oldValue)
{
ProviderPresenceStatusChangeEvent evt
= new ProviderPresenceStatusChangeEvent(this.parentProvider,
oldValue, this.getPresenceStatus());
Iterator listeners = null;
synchronized (providerPresenceStatusListeners)
{
listeners =
new ArrayList(providerPresenceStatusListeners).iterator();
}
while (listeners.hasNext())
{
ProviderPresenceStatusListener listener
= (ProviderPresenceStatusListener) listeners.next();
listener.providerStatusChanged(evt);
}
}
/**
* Zeroconf implementation of the corresponding ProtocolProviderService
* method.
*
* @param listener a dummy param.
*/
public void addProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized(providerPresenceStatusListeners)
{
if (!providerPresenceStatusListeners.contains(listener))
this.providerPresenceStatusListeners.add(listener);
}
}
/**
* Registers a listener that would receive events upon changes in server
* stored groups.
*
* @param listener a ServerStoredGroupChangeListener impl that would
* receive events upong group changes.
*/
public void addServerStoredGroupChangeListener(ServerStoredGroupListener
listener)
{
synchronized(serverStoredGroupListeners)
{
if (!serverStoredGroupListeners.contains(listener))
serverStoredGroupListeners.add(listener);
}
}
/** /**
* Creates a group with the specified name and parent in the server * Creates a group with the specified name and parent in the server
* stored contact list. * stored contact list.
@ -470,21 +359,6 @@ protected void changePresenceStatusForAllContacts(ContactGroup parent,
} }
} }
/**
* Unregisters the specified listener so that it does not receive further
* events upon changes in local presence status.
*
* @param listener ProviderPresenceStatusListener
*/
public void removeProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized(providerPresenceStatusListeners)
{
this.providerPresenceStatusListeners.remove(listener);
}
}
/** /**
* Returns the group that is parent of the specified zeroconfGroup or null * Returns the group that is parent of the specified zeroconfGroup or null
* if no parent was found. * if no parent was found.
@ -541,22 +415,6 @@ public void removeServerStoredContactGroup(ContactGroup group)
zeroconfGroup, ServerStoredGroupEvent.GROUP_REMOVED_EVENT); zeroconfGroup, ServerStoredGroupEvent.GROUP_REMOVED_EVENT);
} }
/**
* Removes the specified group change listener so that it won't receive
* any further events.
*
* @param listener the ServerStoredGroupChangeListener to remove
*/
public void removeServerStoredGroupChangeListener(ServerStoredGroupListener
listener)
{
synchronized(serverStoredGroupListeners)
{
serverStoredGroupListeners.remove(listener);
}
}
/** /**
* Renames the specified group from the server stored contact list. * Renames the specified group from the server stored contact list.
* *

@ -5,6 +5,7 @@
*/ */
package net.java.sip.communicator.service.protocol; package net.java.sip.communicator.service.protocol;
import java.beans.PropertyChangeEvent;
import java.util.*; import java.util.*;
import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.event.*;
@ -24,23 +25,36 @@ public abstract class AbstractOperationSetPersistentPresence<T extends ProtocolP
private static final Logger logger = private static final Logger logger =
Logger.getLogger(AbstractOperationSetPersistentPresence.class); Logger.getLogger(AbstractOperationSetPersistentPresence.class);
/**
* A list of listeners registered for
* <tt>ContactPresenceStatusChangeEvent</tt>s.
*/
private final List<ContactPresenceStatusListener> contactPresenceStatusListeners
= new Vector<ContactPresenceStatusListener>();
/** /**
* The provider that created us. * The provider that created us.
*/ */
protected final T parentProvider; protected final T parentProvider;
/** /**
* The list of listeners interested in <tt>SubscriptionEvent</tt>s. * A list of listeners registered for
* <tt>ProviderPresenceStatusChangeEvent</tt>s.
*/ */
private final List<SubscriptionListener> subscriptionListeners = private final List<ProviderPresenceStatusListener> providerPresenceStatusListeners
new Vector<SubscriptionListener>(); = new Vector<ProviderPresenceStatusListener>();
/** /**
* A list of listeners registered for * A list of listeners registered for <tt>ServerStoredGroupChangeEvent</tt>s.
* <tt>ContactPresenceStatusChangeEvent</tt>s.
*/ */
private final List<ContactPresenceStatusListener> contactPresenceStatusListeners private final List<ServerStoredGroupListener> serverStoredGroupListeners
= new Vector<ContactPresenceStatusListener>(); = new Vector<ServerStoredGroupListener>();
/**
* The list of listeners interested in <tt>SubscriptionEvent</tt>s.
*/
private final List<SubscriptionListener> subscriptionListeners
= new Vector<SubscriptionListener>();
/** /**
* Initializes a new <tt>AbstractOperationSetPersistentPresence</tt> * Initializes a new <tt>AbstractOperationSetPersistentPresence</tt>
@ -70,6 +84,41 @@ public void addContactPresenceStatusListener(
} }
} }
/**
* Adds a listener that would receive events upon changes of the provider
* presence status.
*
* @param listener
* the listener to register for changes in our PresenceStatus.
*/
public void addProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized (providerPresenceStatusListeners)
{
if (!providerPresenceStatusListeners.contains(listener))
providerPresenceStatusListeners.add(listener);
}
}
/**
* Registers a listener that would receive events upon changes in server
* stored groups.
*
* @param listener
* a ServerStoredGroupChangeListener impl that would receive
* events upon group changes.
*/
public void addServerStoredGroupChangeListener(
ServerStoredGroupListener listener)
{
synchronized (serverStoredGroupListeners)
{
if (!serverStoredGroupListeners.contains(listener))
serverStoredGroupListeners.add(listener);
}
}
public void addSubscriptionListener(SubscriptionListener listener) public void addSubscriptionListener(SubscriptionListener listener)
{ {
synchronized (subscriptionListeners) synchronized (subscriptionListeners)
@ -119,7 +168,7 @@ public void fireContactPresenceStatusChangeEvent(Contact source,
oldValue, oldValue,
newValue); newValue);
List<ContactPresenceStatusListener> listeners; Collection<ContactPresenceStatusListener> listeners;
synchronized (contactPresenceStatusListeners) synchronized (contactPresenceStatusListeners)
{ {
listeners = listeners =
@ -150,22 +199,151 @@ public void fireContactPresenceStatusChangeEvent(Contact source,
public void fireContactPropertyChangeEvent(String eventID, Contact source, public void fireContactPropertyChangeEvent(String eventID, Contact source,
Object oldValue, Object newValue) Object oldValue, Object newValue)
{ {
ContactPropertyChangeEvent evt = ContactPropertyChangeEvent evt
new ContactPropertyChangeEvent(source, eventID, oldValue, newValue); = new ContactPropertyChangeEvent(
source,
eventID,
oldValue,
newValue);
List<SubscriptionListener> listeners; Collection<SubscriptionListener> listeners;
synchronized (subscriptionListeners) synchronized (subscriptionListeners)
{ {
listeners = listeners
new ArrayList<SubscriptionListener>(subscriptionListeners); = new ArrayList<SubscriptionListener>(subscriptionListeners);
} }
logger.debug("Dispatching a Contact Property Change Event to" logger.debug("Dispatching a Contact Property Change Event to"
+ listeners.size() + " listeners. Evt=" + evt); + listeners.size() + " listeners. Evt=" + evt);
for (Iterator<SubscriptionListener> listenerIt = listeners.iterator(); listenerIt for (SubscriptionListener listener : listeners)
.hasNext();) listener.contactModified(evt);
listenerIt.next().contactModified(evt); }
/**
* Notifies all registered listeners of the new event.
*
* @param oldValue
* the presence status we were in before the change.
*/
protected void fireProviderStatusChangeEvent(PresenceStatus oldValue)
{
fireProviderStatusChangeEvent(oldValue, getPresenceStatus());
}
/**
* Notify all provider presence listeners of the corresponding event change
*
* @param oldStatus
* the status our stack had so far
* @param newStatus
* the status we have from now on
*/
protected void fireProviderStatusChangeEvent(
PresenceStatus oldValue,
PresenceStatus newValue)
{
ProviderPresenceStatusChangeEvent evt
= new ProviderPresenceStatusChangeEvent(
parentProvider,
oldValue,
newValue);
Collection<ProviderPresenceStatusListener> listeners;
synchronized (providerPresenceStatusListeners)
{
listeners
= new ArrayList<ProviderPresenceStatusListener>(
providerPresenceStatusListeners);
}
logger.debug(
"Dispatching Provider Status Change. Listeners="
+ listeners.size()
+ " evt=" + evt);
for (ProviderPresenceStatusListener listener : listeners)
listener.providerStatusChanged(evt);
logger.debug("status dispatching done.");
}
/**
* Notify all provider presence listeners that a new status message has been
* set.
*
* @param oldStatusMessage
* the status message our stack had so far
* @param newStatusMessage
* the status message we have from now on
*/
protected void fireProviderStatusMessageChangeEvent(
String oldStatusMessage,
String newStatusMessage)
{
PropertyChangeEvent evt
= new PropertyChangeEvent(
parentProvider,
ProviderPresenceStatusListener.STATUS_MESSAGE,
oldStatusMessage,
newStatusMessage);
Collection<ProviderPresenceStatusListener> listeners;
synchronized (providerPresenceStatusListeners)
{
listeners
= new ArrayList<ProviderPresenceStatusListener>(
providerPresenceStatusListeners);
}
logger.debug(
"Dispatching stat. msg change. Listeners="
+ listeners.size()
+ " evt=" + evt);
for (ProviderPresenceStatusListener listener : listeners)
listener.providerStatusMessageChanged(evt);
}
/**
* Notifies all registered listeners of the new event.
*
* @param source the contact that has caused the event.
* @param eventID an identifier of the event to dispatch.
*/
protected void fireServerStoredGroupEvent(
ContactGroup source,
int eventID)
{
ServerStoredGroupEvent evt
= new ServerStoredGroupEvent(
source,
eventID,
source.getParentContactGroup(),
parentProvider,
this);
Iterable<ServerStoredGroupListener> listeners;
synchronized (serverStoredGroupListeners)
{
listeners
= new ArrayList<ServerStoredGroupListener>(
serverStoredGroupListeners);
}
for (ServerStoredGroupListener listener : listeners)
switch (eventID)
{
case ServerStoredGroupEvent.GROUP_CREATED_EVENT:
listener.groupCreated(evt);
break;
case ServerStoredGroupEvent.GROUP_RENAMED_EVENT:
listener.groupNameChanged(evt);
break;
case ServerStoredGroupEvent.GROUP_REMOVED_EVENT:
listener.groupRemoved(evt);
break;
}
} }
/** /**
@ -185,11 +363,16 @@ public void fireSubscriptionEvent(Contact source, ContactGroup parentGroup,
public void fireSubscriptionEvent(Contact source, ContactGroup parentGroup, public void fireSubscriptionEvent(Contact source, ContactGroup parentGroup,
int eventID, int errorCode, String errorReason) int eventID, int errorCode, String errorReason)
{ {
SubscriptionEvent evt = SubscriptionEvent evt
new SubscriptionEvent(source, parentProvider, parentGroup, eventID, = new SubscriptionEvent(
errorCode, errorReason); source,
parentProvider,
parentGroup,
eventID,
errorCode,
errorReason);
List<SubscriptionListener> listeners; Collection<SubscriptionListener> listeners;
synchronized (subscriptionListeners) synchronized (subscriptionListeners)
{ {
listeners = listeners =
@ -200,7 +383,6 @@ public void fireSubscriptionEvent(Contact source, ContactGroup parentGroup,
+ " listeners. Evt=" + evt); + " listeners. Evt=" + evt);
for (SubscriptionListener listener : listeners) for (SubscriptionListener listener : listeners)
{
switch (eventID) switch (eventID)
{ {
case SubscriptionEvent.SUBSCRIPTION_CREATED: case SubscriptionEvent.SUBSCRIPTION_CREATED:
@ -216,7 +398,6 @@ public void fireSubscriptionEvent(Contact source, ContactGroup parentGroup,
listener.subscriptionResolved(evt); listener.subscriptionResolved(evt);
break; break;
} }
}
} }
/** /**
@ -234,11 +415,11 @@ public void fireSubscriptionMovedEvent(Contact source,
new SubscriptionMovedEvent(source, parentProvider, oldParent, new SubscriptionMovedEvent(source, parentProvider, oldParent,
newParent); newParent);
List<SubscriptionListener> listeners; Collection<SubscriptionListener> listeners;
synchronized (subscriptionListeners) synchronized (subscriptionListeners)
{ {
listeners = listeners
new ArrayList<SubscriptionListener>(subscriptionListeners); = new ArrayList<SubscriptionListener>(subscriptionListeners);
} }
logger.debug("Dispatching a Subscription Event to" + listeners.size() logger.debug("Dispatching a Subscription Event to" + listeners.size()
@ -263,6 +444,37 @@ public void removeContactPresenceStatusListener(
} }
} }
/**
* Unregisters the specified listener so that it does not receive further
* events upon changes in local presence status.
*
* @param listener
* ProviderPresenceStatusListener
*/
public void removeProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
synchronized (providerPresenceStatusListeners)
{
providerPresenceStatusListeners.remove(listener);
}
}
/**
* Removes the specified group change listener so that it won't receive
* any further events.
*
* @param listener the ServerStoredGroupChangeListener to remove
*/
public void removeServerStoredGroupChangeListener(
ServerStoredGroupListener listener)
{
synchronized (serverStoredGroupListeners)
{
serverStoredGroupListeners.remove(listener);
}
}
/** /**
* Removes the specified subscription listener. * Removes the specified subscription listener.
* *

@ -0,0 +1,69 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.service.protocol.event;
/**
* Represents a default implementation of <code>SubscriptionListener</code>
* which performs no processing of the received events and allows extenders to
* easily implement the interface in question by just overriding the methods
* they are interested in.
*
* @author Lubomir Marinov
*/
public class SubscriptionAdapter
implements SubscriptionListener
{
/*
* Implements
* SubscriptionListener#contactModified(ContactPropertyChangeEvent). Does
* nothing.
*/
public void contactModified(ContactPropertyChangeEvent evt)
{
}
/*
* Implements SubscriptionListener#subscriptionCreated(SubscriptionEvent).
* Does nothing.
*/
public void subscriptionCreated(SubscriptionEvent evt)
{
}
/*
* Implements SubscriptionListener#subscriptionFailed(SubscriptionEvent).
* Does nothing.
*/
public void subscriptionFailed(SubscriptionEvent evt)
{
}
/*
* Implements SubscriptionListener#subscriptionMoved(SubscriptionMovedEvent).
* Does nothing.
*/
public void subscriptionMoved(SubscriptionMovedEvent evt)
{
}
/*
* Implements SubscriptionListener#subscriptionRemoved(SubscriptionEvent).
* Does nothing.
*/
public void subscriptionRemoved(SubscriptionEvent evt)
{
}
/*
* Implements SubscriptionListener#subscriptionResolved(SubscriptionEvent).
* Does nothing.
*/
public void subscriptionResolved(SubscriptionEvent evt)
{
}
}

@ -1062,46 +1062,4 @@ public void waitForAuthRequest(long waitFor)
} }
} }
} }
/**
* Used to wait till buddy is removed from our contact list.
* Used in the authorization process tests
*/
private class UnsubscribeWait implements SubscriptionListener
{
public void waitForUnsubscribre(long waitFor)
{
synchronized(this)
{
try{
wait(waitFor);
}
catch (InterruptedException ex)
{
logger.debug(
"Interrupted while waiting for a subscription evt", ex);
}
}
}
public void subscriptionRemoved(SubscriptionEvent evt)
{
synchronized(this)
{
logger.debug("Got subscriptionRemoved " + evt);
notifyAll();
}
}
public void subscriptionCreated(SubscriptionEvent evt)
{}
public void subscriptionFailed(SubscriptionEvent evt)
{}
public void subscriptionMoved(SubscriptionMovedEvent evt)
{}
public void subscriptionResolved(SubscriptionEvent evt)
{}
public void contactModified(ContactPropertyChangeEvent evt)
{}
}
} }

@ -1256,7 +1256,8 @@ public void waitForAuthRequest(long waitFor)
* Used to wait till buddy is removed from our contact list. * Used to wait till buddy is removed from our contact list.
* Used in the authorization process tests * Used in the authorization process tests
*/ */
private class UnsubscribeWait implements SubscriptionListener private static class UnsubscribeWait
extends SubscriptionAdapter
{ {
public void waitForUnsubscribre(long waitFor) public void waitForUnsubscribre(long waitFor)
{ {
@ -1281,17 +1282,6 @@ public void subscriptionRemoved(SubscriptionEvent evt)
notifyAll(); notifyAll();
} }
} }
public void subscriptionCreated(SubscriptionEvent evt)
{}
public void subscriptionFailed(SubscriptionEvent evt)
{}
public void subscriptionMoved(SubscriptionMovedEvent evt)
{}
public void subscriptionResolved(SubscriptionEvent evt)
{}
public void contactModified(ContactPropertyChangeEvent evt)
{}
} }
/** /**

@ -972,46 +972,4 @@ public void contactPresenceStatusChanged(
} }
} }
} }
/**
* Used to wait till buddy is removed from our contact list.
* Used in the authorization process tests
*/
private class UnsubscribeWait implements SubscriptionListener
{
public void waitForUnsubscribre(long waitFor)
{
synchronized(this)
{
try{
wait(waitFor);
}
catch (InterruptedException ex)
{
logger.debug(
"Interrupted while waiting for a subscription evt", ex);
}
}
}
public void subscriptionRemoved(SubscriptionEvent evt)
{
synchronized(this)
{
logger.debug("Got subscriptionRemoved " + evt);
notifyAll();
}
}
public void subscriptionCreated(SubscriptionEvent evt)
{}
public void subscriptionFailed(SubscriptionEvent evt)
{}
public void subscriptionMoved(SubscriptionMovedEvent evt)
{}
public void subscriptionResolved(SubscriptionEvent evt)
{}
public void contactModified(ContactPropertyChangeEvent evt)
{}
}
} }

@ -10,6 +10,7 @@
import java.util.*; import java.util.*;
import junit.framework.*; import junit.framework.*;
import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.*;
@ -97,7 +98,6 @@ protected void setUp() throws Exception
+ "implementation of at least the one of the Presence " + "implementation of at least the one of the Presence "
+ "Operation Sets"); + "Operation Sets");
} }
} }
protected void tearDown() throws Exception protected void tearDown() throws Exception
@ -154,13 +154,12 @@ public void testChangingState() throws Exception
{ {
//first create a local list containing the presence status instances //first create a local list containing the presence status instances
//supported by the underlying implementation. //supported by the underlying implementation.
Iterator supportedStatusSetIter = Iterator<PresenceStatus> supportedStatusSetIter =
this.operationSetPresence1.getSupportedStatusSet(); this.operationSetPresence1.getSupportedStatusSet();
while (supportedStatusSetIter.hasNext()) while (supportedStatusSetIter.hasNext())
{ {
PresenceStatus supportedStatus = PresenceStatus supportedStatus = supportedStatusSetIter.next();
(PresenceStatus) supportedStatusSetIter.next();
logger.trace("Will test a transition to " logger.trace("Will test a transition to "
+ supportedStatus.getStatusName()); + supportedStatus.getStatusName());
@ -291,25 +290,22 @@ private void pauseAfterStateChanges()
* @throws java.lang.Exception if one of the transitions fails * @throws java.lang.Exception if one of the transitions fails
*/ */
public void testQueryContactStatus() public void testQueryContactStatus()
throws Exception throws Exception
{ {
//first create a local list containing the presence status instances //first create a local list containing the presence status instances
//supported by the underlying implementation. //supported by the underlying implementation.
Iterator supportedStatusSetIter = Iterator<PresenceStatus> supportedStatusSetIter =
operationSetPresence1.getSupportedStatusSet(); operationSetPresence1.getSupportedStatusSet();
while (supportedStatusSetIter.hasNext()) while (supportedStatusSetIter.hasNext())
{ {
PresenceStatus supportedStatus PresenceStatus supportedStatus = supportedStatusSetIter.next();
= (PresenceStatus)supportedStatusSetIter.next();
logger.trace("Will test a transition to " logger.trace("Will test a transition to "
+ supportedStatus.getStatusName()); + supportedStatus.getStatusName());
subtestQueryContactStatus(supportedStatus); subtestQueryContactStatus(supportedStatus);
} }
} }
/** /**
@ -365,8 +361,8 @@ public void postTestSubscribe()
= new SubscriptionEventCollector(); = new SubscriptionEventCollector();
this.operationSetPresence1.addSubscriptionListener(subEvtCollector); this.operationSetPresence1.addSubscriptionListener(subEvtCollector);
synchronized (subEvtCollector)
synchronized (subEvtCollector){ {
this.operationSetPresence1.subscribe(this.fixture.userID2); this.operationSetPresence1.subscribe(this.fixture.userID2);
//we may already have the event, but it won't hurt to check. //we may already have the event, but it won't hurt to check.
subEvtCollector.waitForEvent(10000); subEvtCollector.waitForEvent(10000);
@ -390,7 +386,8 @@ public void postTestSubscribe()
subEvtCollector.collectedEvents.clear(); subEvtCollector.collectedEvents.clear();
// wait the resolution of the contact before continuing // wait the resolution of the contact before continuing
synchronized (subEvtCollector){ synchronized (subEvtCollector)
{
subEvtCollector.waitForEvent(10000); subEvtCollector.waitForEvent(10000);
this.operationSetPresence1 this.operationSetPresence1
.removeSubscriptionListener(subEvtCollector); .removeSubscriptionListener(subEvtCollector);
@ -513,13 +510,12 @@ private PresenceStatus getSampleStatus1()
PresenceStatus mostConnectedPresenceStatus = null; PresenceStatus mostConnectedPresenceStatus = null;
int mostConnectedPresenceStatusInt = Integer.MIN_VALUE; int mostConnectedPresenceStatusInt = Integer.MIN_VALUE;
Iterator supportedStatusSetIter = Iterator<PresenceStatus> supportedStatusSetIter =
this.operationSetPresence1.getSupportedStatusSet(); this.operationSetPresence1.getSupportedStatusSet();
while (supportedStatusSetIter.hasNext()) while (supportedStatusSetIter.hasNext())
{ {
PresenceStatus supportedStatus PresenceStatus supportedStatus = supportedStatusSetIter.next();
= (PresenceStatus)supportedStatusSetIter.next();
if(supportedStatus.getStatus() > mostConnectedPresenceStatusInt) if(supportedStatus.getStatus() > mostConnectedPresenceStatusInt)
{ {
@ -546,13 +542,12 @@ private PresenceStatus getSampleStatus2()
PresenceStatus secondMostConnectedPresenceStatus = null; PresenceStatus secondMostConnectedPresenceStatus = null;
int secondMostConnectedPresenceStatusInt = Integer.MIN_VALUE; int secondMostConnectedPresenceStatusInt = Integer.MIN_VALUE;
Iterator supportedStatusSetIter = Iterator<PresenceStatus> supportedStatusSetIter =
this.operationSetPresence1.getSupportedStatusSet(); this.operationSetPresence1.getSupportedStatusSet();
while (supportedStatusSetIter.hasNext()) while (supportedStatusSetIter.hasNext())
{ {
PresenceStatus supportedStatus PresenceStatus supportedStatus = supportedStatusSetIter.next();
= (PresenceStatus)supportedStatusSetIter.next();
if(supportedStatus.getStatus() > mostConnectedPresenceStatusInt) if(supportedStatus.getStatus() > mostConnectedPresenceStatusInt)
{ {
@ -970,46 +965,4 @@ public void contactPresenceStatusChanged(
} }
} }
} }
}
/**
* Used to wait till buddy is removed from our contact list.
* Used in the authorization process tests
*/
private class UnsubscribeWait implements SubscriptionListener
{
public void waitForUnsubscribre(long waitFor)
{
synchronized(this)
{
try{
wait(waitFor);
}
catch (InterruptedException ex)
{
logger.debug(
"Interrupted while waiting for a subscription evt", ex);
}
}
}
public void subscriptionRemoved(SubscriptionEvent evt)
{
synchronized(this)
{
logger.debug("Got subscriptionRemoved " + evt);
notifyAll();
}
}
public void subscriptionCreated(SubscriptionEvent evt)
{}
public void subscriptionFailed(SubscriptionEvent evt)
{}
public void subscriptionMoved(SubscriptionMovedEvent evt)
{}
public void subscriptionResolved(SubscriptionEvent evt)
{}
public void contactModified(ContactPropertyChangeEvent evt)
{}
}
}

@ -910,48 +910,6 @@ public void contactPresenceStatusChanged(
} }
} }
/**
* Used to wait till buddy is removed from our contact list.
* Used in the authorization process tests
*/
private class UnsubscribeWait implements SubscriptionListener
{
public void waitForUnsubscribre(long waitFor)
{
synchronized(this)
{
try{
wait(waitFor);
}
catch (InterruptedException ex)
{
logger.debug(
"Interrupted while waiting for a subscription evt", ex);
}
}
}
public void subscriptionRemoved(SubscriptionEvent evt)
{
synchronized(this)
{
logger.debug("Got subscriptionRemoved " + evt);
notifyAll();
}
}
public void subscriptionCreated(SubscriptionEvent evt)
{}
public void subscriptionFailed(SubscriptionEvent evt)
{}
public void subscriptionMoved(SubscriptionMovedEvent evt)
{}
public void subscriptionResolved(SubscriptionEvent evt)
{}
public void contactModified(ContactPropertyChangeEvent evt)
{}
}
/** /**
* AuthorizationHandler which accepts all requests! * AuthorizationHandler which accepts all requests!
*/ */

Loading…
Cancel
Save