Introduces an abstract base implementation of OperationSetPersistentPresence which takes care of the functionality to support adding and removing SubscriptionEvent listeners and firing the mentioned events. As a side effect, the Jabber implementation no longer allows adding one and the same SubscriptionListener more than once.

cusax-fix
Lyubomir Marinov 18 years ago
parent cc7bb6ce26
commit f7f37307f1

@ -25,13 +25,10 @@
* @author LITZELMANN Cedric
*/
public class OperationSetPersistentPresenceDictImpl
implements OperationSetPersistentPresence
extends AbstractOperationSetPersistentPresence<ProtocolProviderServiceDictImpl>
{
private static final Logger logger =
Logger.getLogger(OperationSetPersistentPresenceDictImpl.class);
/**
*/
private Vector subscriptionListeners = new Vector();
/**
* A list of listeners registered for <tt>ServerStoredGroupChangeEvent</tt>s.
@ -55,11 +52,6 @@ public class OperationSetPersistentPresenceDictImpl
*/
private ContactGroupDictImpl contactListRoot = null;
/**
* The provider that created us.
*/
private ProtocolProviderServiceDictImpl parentProvider = null;
/**
* The currently active status message.
*/
@ -85,7 +77,8 @@ public class OperationSetPersistentPresenceDictImpl
public OperationSetPersistentPresenceDictImpl(
ProtocolProviderServiceDictImpl provider)
{
this.parentProvider = provider;
super(provider);
contactListRoot = new ContactGroupDictImpl("RootGroup", provider);
//add our unregistration listener
@ -141,82 +134,6 @@ public void fireContactPresenceStatusChangeEvent(ContactDictImpl source,
}
}
/**
* Notifies all registered listeners of the new event.
*
* @param source the contact that has caused the event.
* @param parentGroup the group that contains the source contact.
* @param eventID an identifier of the event to dispatch.
*/
public void fireSubscriptionEvent(ContactDictImpl source,
ContactGroup parentGroup,
int eventID)
{
SubscriptionEvent evt = new SubscriptionEvent(source
, this.parentProvider
, parentGroup
, eventID);
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
if(eventID == SubscriptionEvent.SUBSCRIPTION_CREATED)
{
listener.subscriptionCreated(evt);
}
else if (eventID == SubscriptionEvent.SUBSCRIPTION_FAILED)
{
listener.subscriptionFailed(evt);
}
else if (eventID == SubscriptionEvent.SUBSCRIPTION_REMOVED)
{
listener.subscriptionRemoved(evt);
}
}
}
/**
* Notifies all registered listeners of the new event.
*
* @param source the contact that has been moved..
* @param oldParent the group where the contact was located before being
* moved.
* @param newParent the group where the contact has been moved.
*/
public void fireSubscriptionMovedEvent(Contact source,
ContactGroup oldParent,
ContactGroup newParent)
{
SubscriptionMovedEvent evt = new SubscriptionMovedEvent(source
, this.parentProvider
, oldParent
, newParent);
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
listener.subscriptionMoved(evt);
}
}
/**
* Notifies all registered listeners of the new event.
*
@ -315,21 +232,6 @@ public void addServerStoredGroupChangeListener(ServerStoredGroupListener
}
}
/**
* Dict implementation of the corresponding ProtocolProviderService
* method.
*
* @param listener the SubscriptionListener to register
*/
public void addSubsciptionListener(SubscriptionListener listener)
{
synchronized(subscriptionListeners)
{
if (!subscriptionListeners.contains(listener))
this.subscriptionListeners.add(listener);
}
}
/**
* Creates a group with the specified name and parent in the server
* stored contact list.
@ -755,19 +657,6 @@ public void removeServerStoredGroupChangeListener(ServerStoredGroupListener
}
}
/**
* Removes the specified subscription listener.
*
* @param listener the listener to remove.
*/
public void removeSubscriptionListener(SubscriptionListener listener)
{
synchronized(subscriptionListeners)
{
this.subscriptionListeners.remove(listener);
}
}
/**
* Renames the specified group from the server stored contact list.
*

@ -23,14 +23,10 @@
* @author Emil Ivov
*/
public class OperationSetPersistentPresenceGibberishImpl
implements OperationSetPersistentPresence
extends AbstractOperationSetPersistentPresence<ProtocolProviderServiceGibberishImpl>
{
private static final Logger logger =
Logger.getLogger(OperationSetPersistentPresenceGibberishImpl.class);
/**
* A list of listeners registered for <tt>SubscriptionEvent</tt>s.
*/
private Vector subscriptionListeners = new Vector();
/**
* A list of listeners registered for <tt>ServerStoredGroupChangeEvent</tt>s.
@ -54,11 +50,6 @@ public class OperationSetPersistentPresenceGibberishImpl
*/
private ContactGroupGibberishImpl contactListRoot = null;
/**
* The provider that created us.
*/
private ProtocolProviderServiceGibberishImpl parentProvider = null;
/**
* The currently active status message.
*/
@ -84,7 +75,8 @@ public class OperationSetPersistentPresenceGibberishImpl
public OperationSetPersistentPresenceGibberishImpl(
ProtocolProviderServiceGibberishImpl provider)
{
this.parentProvider = provider;
super(provider);
contactListRoot = new ContactGroupGibberishImpl("RootGroup", provider);
//add our unregistration listener
@ -140,82 +132,6 @@ public void fireContactPresenceStatusChangeEvent(ContactGibberishImpl source,
}
}
/**
* Notifies all registered listeners of the new event.
*
* @param source the contact that has caused the event.
* @param parentGroup the group that contains the source contact.
* @param eventID an identifier of the event to dispatch.
*/
public void fireSubscriptionEvent(ContactGibberishImpl source,
ContactGroup parentGroup,
int eventID)
{
SubscriptionEvent evt = new SubscriptionEvent(source
, this.parentProvider
, parentGroup
, eventID);
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
if(eventID == SubscriptionEvent.SUBSCRIPTION_CREATED)
{
listener.subscriptionCreated(evt);
}
else if (eventID == SubscriptionEvent.SUBSCRIPTION_FAILED)
{
listener.subscriptionFailed(evt);
}
else if (eventID == SubscriptionEvent.SUBSCRIPTION_REMOVED)
{
listener.subscriptionRemoved(evt);
}
}
}
/**
* Notifies all registered listeners of the new event.
*
* @param source the contact that has been moved..
* @param oldParent the group where the contact was located before being
* moved.
* @param newParent the group where the contact has been moved.
*/
public void fireSubscriptionMovedEvent(Contact source,
ContactGroup oldParent,
ContactGroup newParent)
{
SubscriptionMovedEvent evt = new SubscriptionMovedEvent(source
, this.parentProvider
, oldParent
, newParent);
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
listener.subscriptionMoved(evt);
}
}
/**
* Notifies all registered listeners of the new event.
*
@ -314,21 +230,6 @@ public void addServerStoredGroupChangeListener(ServerStoredGroupListener
}
}
/**
* Gibberish implementation of the corresponding ProtocolProviderService
* method.
*
* @param listener the SubscriptionListener to register
*/
public void addSubsciptionListener(SubscriptionListener listener)
{
synchronized(subscriptionListeners)
{
if (!subscriptionListeners.contains(listener))
this.subscriptionListeners.add(listener);
}
}
/**
* Creates a group with the specified name and parent in the server
* stored contact list.
@ -754,19 +655,6 @@ public void removeServerStoredGroupChangeListener(ServerStoredGroupListener
}
}
/**
* Removes the specified subscription listener.
*
* @param listener the listener to remove.
*/
public void removeSubscriptionListener(SubscriptionListener listener)
{
synchronized(subscriptionListeners)
{
this.subscriptionListeners.remove(listener);
}
}
/**
* Renames the specified group from the server stored contact list.
*

@ -12,7 +12,6 @@
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.service.protocol.icqconstants.*;
import net.java.sip.communicator.service.protocol.AuthorizationResponse.*;
import net.java.sip.communicator.util.*;
import net.kano.joscar.*;
import net.kano.joscar.flapcmd.*;
@ -40,28 +39,17 @@
* @author Emil Ivov
*/
public class OperationSetPersistentPresenceIcqImpl
implements OperationSetPersistentPresence
extends AbstractOperationSetPersistentPresence<ProtocolProviderServiceIcqImpl>
{
private static final Logger logger =
Logger.getLogger(OperationSetPersistentPresenceIcqImpl.class);
/**
* A callback to the ICQ provider that created us.
*/
private ProtocolProviderServiceIcqImpl icqProvider = null;
/**
* The list of presence status listeners interested in receiving presence
* notifications of changes in status of contacts in our contact list.
*/
private Vector contactPresenceStatusListeners = new Vector();
/**
* The list of subscription listeners interested in receiving notifications
* whenever .
*/
private Vector subscriptionListeners = new Vector();
/**
* The list of listeners interested in receiving changes in our local
* presencestatus.
@ -202,12 +190,12 @@ protected OperationSetPersistentPresenceIcqImpl(
ProtocolProviderServiceIcqImpl icqProvider,
String uin)
{
this.icqProvider = icqProvider;
super(icqProvider);
ssContactList = new ServerStoredContactListIcqImpl( this , icqProvider);
//add a listener that'll follow the provider's state.
icqProvider.addRegistrationStateChangeListener(
parentProvider.addRegistrationStateChangeListener(
registrationStateListener);
}
@ -247,31 +235,6 @@ public void removeContactPresenceStatusListener(
}
}
/**
* Registers a listener that would get notifications any time a new
* subscription was succesfully added, has failed or was removed.
* @param listener the SubscriptionListener to register
*/
public void addSubsciptionListener(SubscriptionListener listener)
{
synchronized(subscriptionListeners)
{
if(!subscriptionListeners.contains(listener))
subscriptionListeners.add(listener);
}
}
/**
* Removes the specified subscription listener.
* @param listener the listener to remove.
*/
public void removeSubscriptionListener(SubscriptionListener listener)
{
synchronized(subscriptionListeners){
subscriptionListeners.remove(listener);
}
}
/**
* Get the PresenceStatus for a particular contact. This method is not meant
* to be used by the user interface (which would simply register as a
@ -307,7 +270,7 @@ public PresenceStatus queryContactStatus(String contactIdentifier)
GetInfoCmd getInfoCmd =
new GetInfoCmd(GetInfoCmd.CMD_USER_INFO, contactIdentifier);
icqProvider.getAimConnection().getInfoService().getOscarConnection()
parentProvider.getAimConnection().getInfoService().getOscarConnection()
.sendSnacRequest(getInfoCmd, responseRetriever);
synchronized(responseRetriever)
@ -334,7 +297,7 @@ public PresenceStatus queryContactStatus(String contactIdentifier)
*/
private PresenceStatus statusLongToPresenceStatus(long icqStatus)
{
if(icqProvider.USING_ICQ)
if(parentProvider.USING_ICQ)
{
// Fixed order of status checking
// The order does matter, as the icqStatus consists of more than one
@ -413,7 +376,7 @@ else if ( (icqStatus & FullUserInfo.ICQSTATUS_AWAY ) != 0)
*/
private long presenceStatusToStatusLong(PresenceStatus status)
{
if(icqProvider.USING_ICQ)
if(parentProvider.USING_ICQ)
return ((Long)scToIcqStatusMappings.get(status)).longValue();
else
return ((Long)scToAimStatusMappings.get(status)).longValue();
@ -624,9 +587,9 @@ public void unsubscribe(Contact contact) throws IllegalArgumentException,
if(!contactIcqImpl.isPersistent())
{
contactGroup.removeContact(contactIcqImpl);
fireSubscriptionEvent(SubscriptionEvent.SUBSCRIPTION_REMOVED,
contactIcqImpl,
contactGroup);
fireSubscriptionEvent(contactIcqImpl,
contactGroup,
SubscriptionEvent.SUBSCRIPTION_REMOVED);
return;
}
@ -701,9 +664,9 @@ public void publishPresenceStatus(PresenceStatus status,
logger.debug("Will set status: " + status);
MainBosService bosService
= icqProvider.getAimConnection().getBosService();
= parentProvider.getAimConnection().getBosService();
if(!icqProvider.USING_ICQ)
if(!parentProvider.USING_ICQ)
{
if(status.equals(AimStatusEnum.AWAY))
{
@ -741,7 +704,7 @@ else if(getPresenceStatus().equals(AimStatusEnum.AWAY))
bosService.getOscarConnection().sendSnac(new SetExtraInfoCmd(icqStatus));
if(status.equals(IcqStatusEnum.AWAY))
icqProvider.getAimConnection().getInfoService().
parentProvider.getAimConnection().getInfoService().
setAwayMessage(statusMessage);
else
bosService.setStatusMessage(statusMessage);
@ -749,7 +712,7 @@ else if(getPresenceStatus().equals(AimStatusEnum.AWAY))
//so that everyone sees the change.
queryContactStatus(
icqProvider.getAimConnection().getScreenname().getFormatted());
parentProvider.getAimConnection().getScreenname().getFormatted());
}
/**
@ -928,7 +891,7 @@ public Iterator getSupportedStatusSet()
{
if(supportedPresenceStatusSet.size() == 0)
{
if(icqProvider.USING_ICQ)
if(parentProvider.USING_ICQ)
{
supportedPresenceStatusSet.add(IcqStatusEnum.ONLINE);
supportedPresenceStatusSet.add(IcqStatusEnum.DO_NOT_DISTURB);
@ -969,7 +932,7 @@ public void setAuthorizationHandler(AuthorizationHandler handler)
**/
this.authorizationHandler = handler;
icqProvider.getAimConnection().getSsiService().
parentProvider.getAimConnection().getSsiService().
addBuddyAuthorizationListener(authListener);
}
@ -1048,11 +1011,11 @@ public void handleTimeout(SnacRequestTimeoutEvent event) {
*/
private void assertConnected() throws IllegalStateException
{
if (icqProvider == null)
if (parentProvider == null)
throw new IllegalStateException(
"The icq provider must be non-null and signed on the ICQ "
+"service before being able to communicate.");
if (!icqProvider.isRegistered())
if (!parentProvider.isRegistered())
throw new IllegalStateException(
"The icq provider must be signed on the ICQ service before "
+"being able to communicate.");
@ -1141,7 +1104,7 @@ void fireProviderPresenceStatusChangeEvent(
ProviderPresenceStatusChangeEvent evt =
new ProviderPresenceStatusChangeEvent(
icqProvider, oldStatus, newStatus);
parentProvider, oldStatus, newStatus);
logger.debug("Dispatching Provider Status Change. Listeners="
+ providerPresenceStatusListeners.size()
@ -1173,7 +1136,7 @@ private void fireProviderStatusMessageChangeEvent(
{
PropertyChangeEvent evt = new PropertyChangeEvent(
icqProvider, ProviderPresenceStatusListener.STATUS_MESSAGE,
parentProvider, ProviderPresenceStatusListener.STATUS_MESSAGE,
oldStatusMessage, newStatusMessage);
logger.debug("Dispatching stat. msg change. Listeners="
@ -1195,130 +1158,6 @@ private void fireProviderStatusMessageChangeEvent(
}
}
/**
* Notify all subscription listeners of the corresponding event.
*
* @param eventID the int ID of the event to dispatch
* @param sourceContact the ContactIcqImpl instance that this event is
* pertaining to.
* @param parentGroup the ContactGroupIcqImpl under which the corresponding
* subscription is located.
*/
void fireSubscriptionEvent( int eventID,
ContactIcqImpl sourceContact,
ContactGroupIcqImpl parentGroup)
{
SubscriptionEvent evt =
new SubscriptionEvent(sourceContact, icqProvider, parentGroup,
eventID);
logger.debug("Dispatching a Subscription Event to"
+subscriptionListeners.size() + " listeners. Evt="+evt);
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
if (evt.getEventID() == SubscriptionEvent.SUBSCRIPTION_CREATED)
{
listener.subscriptionCreated(evt);
}
else if (evt.getEventID() == SubscriptionEvent.SUBSCRIPTION_REMOVED)
{
listener.subscriptionRemoved(evt);
}
else if (evt.getEventID() == SubscriptionEvent.SUBSCRIPTION_FAILED)
{
listener.subscriptionFailed(evt);
}
}
}
/**
* Notify all subscription listeners of the corresponding contact property
* change event.
*
* @param eventID the String ID of the event to dispatch
* @param sourceContact the ContactIcqImpl instance that this event is
* pertaining to.
* @param oldValue the value that the changed property had before the change
* occurred.
* @param newValue the value that the changed property currently has (after
* the change has occurred).
*/
void fireContactPropertyChangeEvent( String eventID,
ContactIcqImpl sourceContact,
Object oldValue,
Object newValue)
{
ContactPropertyChangeEvent evt =
new ContactPropertyChangeEvent(sourceContact, eventID
, oldValue, newValue);
logger.debug("Dispatching a Contact Property Change Event to"
+subscriptionListeners.size() + " listeners. Evt="+evt);
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
listener.contactModified(evt);
}
}
/**
* Notify all subscription listeners of the corresponding event.
*
* @param sourceContact the ContactIcqImpl instance that this event is
* pertaining to.
* @param oldParentGroup the group that was previously a parent of the
* source contact.
* @param newParentGroup the group under which the corresponding
* subscription is currently located.
*/
void fireSubscriptionMovedEvent( ContactIcqImpl sourceContact,
ContactGroupIcqImpl oldParentGroup,
ContactGroupIcqImpl newParentGroup)
{
SubscriptionMovedEvent evt =
new SubscriptionMovedEvent(sourceContact, icqProvider
, oldParentGroup, newParentGroup);
logger.debug("Dispatching a Subscription Event to"
+subscriptionListeners.size() + " listeners. Evt="+evt);
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
listener.subscriptionMoved(evt);
}
}
/**
* Notify all contact presence listeners of the corresponding event change
* @param contact the contact that changed its status
@ -1334,7 +1173,7 @@ private void fireContactPresenceStatusChangeEvent(
{
ContactPresenceStatusChangeEvent evt =
new ContactPresenceStatusChangeEvent(
contact, icqProvider, parentGroup, oldStatus, newStatus);
contact, parentProvider, parentGroup, oldStatus, newStatus);
logger.debug("Dispatching Contact Status Change. Listeners="
+ contactPresenceStatusListeners.size()
@ -1377,33 +1216,33 @@ public void registrationStateChanged(RegistrationStateChangeEvent evt)
if(evt.getNewState() == RegistrationState.REGISTERED)
{
logger.debug("adding a Bos Service Listener");
icqProvider.getAimConnection().getBosService()
parentProvider.getAimConnection().getBosService()
.addMainBosServiceListener(joustSimBosListener);
ssContactList.init(
icqProvider.getAimConnection().getSsiService());
parentProvider.getAimConnection().getSsiService());
// /**@todo implement the following
icqProvider.getAimConnection().getBuddyService()
parentProvider.getAimConnection().getBuddyService()
.addBuddyListener(joustSimBuddySerListener);
// @todo we really need this for following the status of our
// contacts and we really need it here ...*/
icqProvider.getAimConnection().getBuddyInfoManager()
parentProvider.getAimConnection().getBuddyInfoManager()
.addGlobalBuddyInfoListener(new GlobalBuddyInfoListener());
icqProvider.getAimConnection().getExternalServiceManager().
parentProvider.getAimConnection().getExternalServiceManager().
getIconServiceArbiter().addIconRequestListener(
new IconUpdateListener());
icqProvider.getAimConnection().getInfoService().
parentProvider.getAimConnection().getInfoService().
addInfoListener(new AwayMessageListener());
if(icqProvider.USING_ICQ)
if(parentProvider.USING_ICQ)
{
opSetExtendedAuthorizations =
(OperationSetExtendedAuthorizationsIcqImpl)
icqProvider.getSupportedOperationSets()
parentProvider.getSupportedOperationSets()
.get(OperationSetExtendedAuthorizations.class.getName());
if(presenceQueryTimer == null)
@ -1466,7 +1305,7 @@ else if(evt.getNewState() == RegistrationState.UNREGISTERED
if(!oldContactStatus.isOnline())
continue;
if(icqProvider.USING_ICQ)
if(parentProvider.USING_ICQ)
{
contact.updatePresenceStatus(IcqStatusEnum.OFFLINE);
@ -1548,7 +1387,7 @@ public void handleYourInfo(MainBosService service,
//update the last received field.
long oldStatus = currentIcqStatus;
if(icqProvider.USING_ICQ)
if(parentProvider.USING_ICQ)
{
currentIcqStatus = userInfo.getIcqStatus();
@ -1618,7 +1457,7 @@ public void gotBuddyStatus(BuddyService service, Screenname buddy,
PresenceStatus newStatus = null;
if(!icqProvider.USING_ICQ)
if(!parentProvider.USING_ICQ)
{
Boolean awayStatus = info.getAwayStatus();
if(awayStatus == null || awayStatus.equals(Boolean.FALSE))
@ -1677,7 +1516,7 @@ public void buddyOffline(BuddyService service, Screenname buddy)
= sourceContact.getPresenceStatus();
PresenceStatus newStatus = null;
if(icqProvider.USING_ICQ)
if(parentProvider.USING_ICQ)
newStatus = IcqStatusEnum.OFFLINE;
else
newStatus = AimStatusEnum.OFFLINE;
@ -1769,7 +1608,7 @@ public void authorizationRequestReceived(Screenname screenname,
if (authResponse.getResponseCode() == AuthorizationResponse.IGNORE)
return;
icqProvider.getAimConnection().getSsiService().
parentProvider.getAimConnection().getSsiService().
replyBuddyAuthorization(
screenname,
authResponse.getResponseCode() == AuthorizationResponse.ACCEPT,
@ -1836,10 +1675,10 @@ public boolean authorizationRequired(Screenname screenname, Group parentGroup)
if(authRequest == null)
return false;
icqProvider.getAimConnection().getSsiService().
parentProvider.getAimConnection().getSsiService().
sendFutureBuddyAuthorization(screenname, authRequest.getReason());
icqProvider.getAimConnection().getSsiService().
parentProvider.getAimConnection().getSsiService().
requestBuddyAuthorization(screenname, authRequest.getReason());
return true;

@ -243,7 +243,7 @@ private void fireContactAdded( ContactGroupIcqImpl parentGroup,
//dispatch
parentOperationSet.fireSubscriptionEvent(
SubscriptionEvent.SUBSCRIPTION_CREATED, contact, parentGroup);
contact, parentGroup, SubscriptionEvent.SUBSCRIPTION_CREATED);
}
/**
@ -263,7 +263,7 @@ private void fireContactResolved( ContactGroupIcqImpl parentGroup,
//dispatch
parentOperationSet.fireSubscriptionEvent(
SubscriptionEvent.SUBSCRIPTION_RESOLVED, contact, parentGroup);
contact, parentGroup, SubscriptionEvent.SUBSCRIPTION_RESOLVED);
}
@ -310,7 +310,7 @@ private void fireContactRemoved( ContactGroupIcqImpl parentGroup,
//dispatch
parentOperationSet.fireSubscriptionEvent(
SubscriptionEvent.SUBSCRIPTION_REMOVED, contact, parentGroup);
contact, parentGroup, SubscriptionEvent.SUBSCRIPTION_REMOVED);
}
private void fireContactsReordered( ContactGroupIcqImpl parentGroup)
@ -589,9 +589,9 @@ public void addContact(ContactGroupIcqImpl parent, String screenname)
new Thread(){
public void run(){
parentOperationSet.fireSubscriptionEvent(
SubscriptionEvent.SUBSCRIPTION_CREATED,
existingContact,
findContactGroup(existingContact));
findContactGroup(existingContact),
SubscriptionEvent.SUBSCRIPTION_CREATED);
}
}.start();
return;

@ -29,16 +29,11 @@
* @author Lubomir Marinov
*/
public class OperationSetPersistentPresenceJabberImpl
implements OperationSetPersistentPresence
extends AbstractOperationSetPersistentPresence<ProtocolProviderServiceJabberImpl>
{
private static final Logger logger =
Logger.getLogger(OperationSetPersistentPresenceJabberImpl.class);
/**
* A callback to the Jabber provider that created us.
*/
private ProtocolProviderServiceJabberImpl jabberProvider = null;
/**
* Contains our current status message. Note that this field would only
* be changed once the server has confirmed the new status message and
@ -58,12 +53,6 @@ public class OperationSetPersistentPresenceJabberImpl
*/
private Vector providerPresenceStatusListeners = new Vector();
/**
* The list of subscription listeners interested in receiving notifications
* whenever .
*/
private Vector subscriptionListeners = new Vector();
/**
* The list of presence status listeners interested in receiving presence
* notifications of changes in status of contacts in our contact list.
@ -99,15 +88,15 @@ public class OperationSetPersistentPresenceJabberImpl
public OperationSetPersistentPresenceJabberImpl(
ProtocolProviderServiceJabberImpl provider)
{
this.jabberProvider = provider;
super(provider);
currentStatus =
this.jabberProvider.getJabberStatusEnum().getStatus(
parentProvider.getJabberStatusEnum().getStatus(
JabberStatusEnum.OFFLINE);
ssContactList = new ServerStoredContactListJabberImpl( this , provider);
this.jabberProvider.addRegistrationStateChangeListener(
parentProvider.addRegistrationStateChangeListener(
new RegistrationStateListener());
}
@ -155,19 +144,6 @@ public void addServerStoredGroupChangeListener(ServerStoredGroupListener
ssContactList.addGroupListener(listener);
}
/**
* Registers a listener that would get notifications any time a new
* subscription was succesfully added, has failed or was removed.
*
* @param listener the SubscriptionListener to register
*/
public void addSubsciptionListener(SubscriptionListener listener)
{
synchronized(subscriptionListeners){
subscriptionListeners.add(listener);
}
}
/**
* Creates a group with the specified name and parent in the server
* stored contact list.
@ -345,7 +321,7 @@ public ContactGroup getServerStoredContactListRoot()
*/
public Iterator getSupportedStatusSet()
{
return jabberProvider.getJabberStatusEnum().getSupportedStatusSet();
return parentProvider.getJabberStatusEnum().getSupportedStatusSet();
}
/**
@ -396,7 +372,7 @@ public void publishPresenceStatus(PresenceStatus status,
assertConnected();
JabberStatusEnum jabberStatusEnum =
jabberProvider.getJabberStatusEnum();
parentProvider.getJabberStatusEnum();
boolean isValidStatus = false;
for (Iterator supportedStatusIter =
jabberStatusEnum.getSupportedStatusSet(); supportedStatusIter
@ -416,7 +392,7 @@ public void publishPresenceStatus(PresenceStatus status,
if (status.equals(jabberStatusEnum.getStatus(JabberStatusEnum.OFFLINE)))
{
presence = new Presence(Presence.Type.unavailable);
jabberProvider.unregister();
parentProvider.unregister();
}
else
{
@ -426,7 +402,7 @@ public void publishPresenceStatus(PresenceStatus status,
presence.setStatus(statusMessage);
presence.addExtension(new Version());
jabberProvider.getConnection().sendPacket(presence);
parentProvider.getConnection().sendPacket(presence);
}
fireProviderPresenceStatusChangeEvent(currentStatus, status);
@ -459,13 +435,13 @@ public PresenceStatus queryContactStatus(String contactIdentifier) throws
IllegalArgumentException, IllegalStateException,
OperationFailedException
{
Presence presence = jabberProvider.getConnection().getRoster().
Presence presence = parentProvider.getConnection().getRoster().
getPresence(contactIdentifier);
if(presence != null)
return jabberStatusToPresenceStatus(presence, jabberProvider);
return jabberStatusToPresenceStatus(presence, parentProvider);
else
return jabberProvider.getJabberStatusEnum().getStatus(
return parentProvider.getJabberStatusEnum().getStatus(
JabberStatusEnum.OFFLINE);
}
@ -525,18 +501,6 @@ public void removeServerStoredGroupChangeListener(ServerStoredGroupListener
ssContactList.removeGroupListener(listener);
}
/**
* Removes the specified subscription listener.
*
* @param listener the listener to remove.
*/
public void removeSubscriptionListener(SubscriptionListener listener)
{
synchronized(subscriptionListeners){
subscriptionListeners.remove(listener);
}
}
/**
* Renames the specified group from the server stored contact list.
*
@ -569,7 +533,7 @@ public void setAuthorizationHandler(AuthorizationHandler handler)
subscribtionPacketListener = new JabberSubscriptionListener();
PacketFilter packetFilter = new PacketTypeFilter(Presence.class);
jabberProvider.getConnection().
parentProvider.getConnection().
addPacketListener(subscribtionPacketListener, packetFilter);
}
@ -724,11 +688,11 @@ public static Presence.Mode presenceStatusToJabberMode(PresenceStatus status)
*/
private void assertConnected() throws IllegalStateException
{
if (jabberProvider == null)
if (parentProvider == null)
throw new IllegalStateException(
"The provider must be non-null and signed on the Jabber "
+"service before being able to communicate.");
if (!jabberProvider.isRegistered())
if (!parentProvider.isRegistered())
throw new IllegalStateException(
"The provider must be signed on the Jabber service before "
+"being able to communicate.");
@ -750,7 +714,7 @@ void fireProviderPresenceStatusChangeEvent(
ProviderPresenceStatusChangeEvent evt =
new ProviderPresenceStatusChangeEvent(
jabberProvider, oldStatus, newStatus);
parentProvider, oldStatus, newStatus);
currentStatus = newStatus;
@ -785,7 +749,7 @@ private void fireProviderStatusMessageChangeEvent(
{
PropertyChangeEvent evt = new PropertyChangeEvent(
jabberProvider, ProviderPresenceStatusListener.STATUS_MESSAGE,
parentProvider, ProviderPresenceStatusListener.STATUS_MESSAGE,
oldStatusMessage, newStatusMessage);
logger.debug("Dispatching stat. msg change. Listeners="
@ -829,11 +793,11 @@ public void registrationStateChanged(RegistrationStateChangeEvent evt)
if(evt.getNewState() == RegistrationState.REGISTERED)
{
jabberProvider.getConnection().getRoster().addRosterListener(
parentProvider.getConnection().getRoster().addRosterListener(
new ContactChangesListener());
fireProviderPresenceStatusChangeEvent(currentStatus,
jabberProvider.getJabberStatusEnum().getStatus(
parentProvider.getJabberStatusEnum().getStatus(
JabberStatusEnum.AVAILABLE));
// init ssList
@ -849,7 +813,7 @@ else if(evt.getNewState() == RegistrationState.UNREGISTERED
//were online
PresenceStatus oldStatus = currentStatus;
PresenceStatus offlineStatus =
jabberProvider.getJabberStatusEnum().getStatus(
parentProvider.getJabberStatusEnum().getStatus(
JabberStatusEnum.OFFLINE);
currentStatus = offlineStatus;
@ -916,82 +880,6 @@ else if(evt.getNewState() == RegistrationState.UNREGISTERED
}
}
/**
* Notify all subscription listeners of the corresponding event.
*
* @param eventID the int ID of the event to dispatch
* @param sourceContact the ContactJabberImpl instance that this event is
* pertaining to.
* @param parentGroup the ContactGroupJabberImpl under which the corresponding
* subscription is located.
*/
void fireSubscriptionEvent( int eventID,
ContactJabberImpl sourceContact,
ContactGroup parentGroup)
{
SubscriptionEvent evt =
new SubscriptionEvent(sourceContact, jabberProvider, parentGroup,
eventID);
logger.debug("Dispatching a Subscription Event to"
+subscriptionListeners.size() + " listeners. Evt="+evt);
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
if (evt.getEventID() == SubscriptionEvent.SUBSCRIPTION_CREATED)
listener.subscriptionCreated(evt);
else if (evt.getEventID() == SubscriptionEvent.SUBSCRIPTION_REMOVED)
listener.subscriptionRemoved(evt);
else if (evt.getEventID() == SubscriptionEvent.SUBSCRIPTION_FAILED)
listener.subscriptionFailed(evt);
}
}
/**
* Notify all subscription listeners of the corresponding event.
*
* @param sourceContact the ContactJabberImpl instance that this event is
* pertaining to.
* @param oldParentGroup the group that was previously a parent of the
* source contact.
* @param newParentGroup the group under which the corresponding
* subscription is currently located.
*/
void fireSubscriptionMovedEvent( ContactJabberImpl sourceContact,
ContactGroup oldParentGroup,
ContactGroup newParentGroup)
{
SubscriptionMovedEvent evt =
new SubscriptionMovedEvent(sourceContact, jabberProvider
, oldParentGroup, newParentGroup);
logger.debug("Dispatching a Subscription Event to"
+subscriptionListeners.size() + " listeners. Evt="+evt);
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
listener.subscriptionMoved(evt);
}
}
/**
* Notify all contact presence listeners of the corresponding event change
* @param contact the contact that changed its status
@ -1007,7 +895,7 @@ private void fireContactPresenceStatusChangeEvent(
{
ContactPresenceStatusChangeEvent evt =
new ContactPresenceStatusChangeEvent(
contact, jabberProvider, parentGroup, oldStatus, newStatus);
contact, parentProvider, parentGroup, oldStatus, newStatus);
logger.debug("Dispatching Contact Status Change. Listeners="
@ -1029,46 +917,6 @@ private void fireContactPresenceStatusChangeEvent(
}
}
/**
* Notify all subscription listeners of the corresponding contact property
* change event.
*
* @param eventID the String ID of the event to dispatch
* @param sourceContact the ContactJabberImpl instance that this event is
* pertaining to.
* @param oldValue the value that the changed property had before the change
* occurred.
* @param newValue the value that the changed property currently has (after
* the change has occurred).
*/
void fireContactPropertyChangeEvent( String eventID,
ContactJabberImpl sourceContact,
Object oldValue,
Object newValue)
{
ContactPropertyChangeEvent evt =
new ContactPropertyChangeEvent(sourceContact, eventID
, oldValue, newValue);
logger.debug("Dispatching a Contact Property Change Event to"
+subscriptionListeners.size() + " listeners. Evt="+evt);
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
listener.contactModified(evt);
}
}
/**
*
*/
@ -1107,7 +955,7 @@ public void presenceChanged(Presence presence)
= sourceContact.getPresenceStatus();
PresenceStatus newStatus =
jabberStatusToPresenceStatus(presence, jabberProvider);
jabberStatusToPresenceStatus(presence, parentProvider);
// when old and new status are the same do nothing
// no change
@ -1160,14 +1008,14 @@ public void processPacket(Packet packet)
Presence responsePacket = new Presence(Presence.Type.subscribed);
responsePacket.setTo(fromID);
logger.info("Sending Accepted Subscription");
jabberProvider.getConnection().sendPacket(responsePacket);
parentProvider.getConnection().sendPacket(responsePacket);
}
else
{
Presence responsePacket = new Presence(Presence.Type.unsubscribed);
responsePacket.setTo(fromID);
logger.info("Sending Rejected Subscription");
jabberProvider.getConnection().sendPacket(responsePacket);
parentProvider.getConnection().sendPacket(responsePacket);
}
}

@ -182,9 +182,9 @@ private void fireContactRemoved( ContactGroup parentGroup,
return;
}
//dispatch
parentOperationSet.fireSubscriptionEvent(
SubscriptionEvent.SUBSCRIPTION_REMOVED, contact, parentGroup);
// dispatch
parentOperationSet.fireSubscriptionEvent(contact, parentGroup,
SubscriptionEvent.SUBSCRIPTION_REMOVED);
}
/**
@ -730,9 +730,9 @@ void fireContactAdded( ContactGroup parentGroup,
return;
}
//dispatch
parentOperationSet.fireSubscriptionEvent(
SubscriptionEvent.SUBSCRIPTION_CREATED, contact, parentGroup);
// dispatch
parentOperationSet.fireSubscriptionEvent(contact, parentGroup,
SubscriptionEvent.SUBSCRIPTION_CREATED);
}
/**
@ -750,9 +750,9 @@ void fireContactResolved( ContactGroupJabberImpl parentGroup,
return;
}
//dispatch
parentOperationSet.fireSubscriptionEvent(
SubscriptionEvent.SUBSCRIPTION_RESOLVED, contact, parentGroup);
// dispatch
parentOperationSet.fireSubscriptionEvent(contact, parentGroup,
SubscriptionEvent.SUBSCRIPTION_RESOLVED);
}
/**

@ -18,14 +18,10 @@
* @author Emil Ivov
*/
public class MockPersistentPresenceOperationSet
implements OperationSetPersistentPresence
extends AbstractOperationSetPersistentPresence<MockProvider>
{
private static final Logger logger =
Logger.getLogger(MockPersistentPresenceOperationSet.class);
/**
* A list of listeners registered for <tt>SubscriptionEvent</tt>s.
*/
private Vector subscriptionListeners = new Vector();
/**
* A list of listeners registered for <tt>ServerStoredGroupChangeEvent</tt>s.
@ -49,11 +45,6 @@ public class MockPersistentPresenceOperationSet
*/
private MockContactGroup contactListRoot = null;
/**
* The provider that created us.
*/
private MockProvider parentProvider = null;
/**
* The currently active status message.
*/
@ -66,7 +57,8 @@ public class MockPersistentPresenceOperationSet
public MockPersistentPresenceOperationSet(MockProvider provider)
{
this.parentProvider = provider;
super(provider);
contactListRoot = new MockContactGroup("RootMockGroup", provider);
}
@ -117,49 +109,6 @@ public void fireContactPresenceStatusChangeEvent(MockContact source,
}
}
/**
* Notifies all registered listeners of the new event.
*
* @param source the contact that has caused the event.
* @param parentGroup the group that contains the source contact.
* @param eventID an identifier of the event to dispatch.
*/
public void fireSubscriptionEvent(MockContact source,
ContactGroup parentGroup,
int eventID)
{
SubscriptionEvent evt = new SubscriptionEvent(source
, this.parentProvider
, parentGroup
, eventID);
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
if(eventID == SubscriptionEvent.SUBSCRIPTION_CREATED)
{
listener.subscriptionCreated(evt);
}
else if (eventID == SubscriptionEvent.SUBSCRIPTION_FAILED)
{
listener.subscriptionFailed(evt);
}
else if (eventID == SubscriptionEvent.SUBSCRIPTION_REMOVED)
{
listener.subscriptionRemoved(evt);
}
}
}
/**
* Notifies all registered listeners of the new event.
*
@ -257,20 +206,6 @@ public void addServerStoredGroupChangeListener(ServerStoredGroupListener
}
}
/**
* Mock implementation of the corresponding ProtocolProviderService method.
*
* @param listener the SubscriptionListener to register
*/
public void addSubsciptionListener(SubscriptionListener listener)
{
synchronized(subscriptionListeners)
{
if (!subscriptionListeners.contains(listener))
this.subscriptionListeners.add(listener);
}
}
/**
* Creates a group with the specified name and parent in the server
* stored contact list.
@ -584,19 +519,6 @@ public void removeServerStoredGroupChangeListener(ServerStoredGroupListener
}
}
/**
* Removes the specified subscription listener.
*
* @param listener the listener to remove.
*/
public void removeSubscriptionListener(SubscriptionListener listener)
{
synchronized(subscriptionListeners)
{
this.subscriptionListeners.remove(listener);
}
}
/**
* Renames the specified group from the server stored contact list.
*

@ -25,16 +25,11 @@
* @author Damian Minkov
*/
public class OperationSetPersistentPresenceMsnImpl
implements OperationSetPersistentPresence
extends AbstractOperationSetPersistentPresence<ProtocolProviderServiceMsnImpl>
{
private static final Logger logger =
Logger.getLogger(OperationSetPersistentPresenceMsnImpl.class);
/**
* A callback to the Msn provider that created us.
*/
private ProtocolProviderServiceMsnImpl msnProvider = null;
/**
* Contains our current status message. Note that this field would only
* be changed once the server has confirmed the new status message and
@ -54,12 +49,6 @@ public class OperationSetPersistentPresenceMsnImpl
*/
private Vector providerPresenceStatusListeners = new Vector();
/**
* The list of subscription listeners interested in receiving notifications
* whenever .
*/
private Vector subscriptionListeners = new Vector();
/**
* The list of presence status listeners interested in receiving presence
* notifications of changes in status of contacts in our contact list.
@ -124,11 +113,11 @@ public class OperationSetPersistentPresenceMsnImpl
public OperationSetPersistentPresenceMsnImpl(
ProtocolProviderServiceMsnImpl provider)
{
this.msnProvider = provider;
super(provider);
ssContactList = new ServerStoredContactListMsnImpl( this , provider);
this.msnProvider.addRegistrationStateChangeListener(
parentProvider.addRegistrationStateChangeListener(
new RegistrationStateListener());
}
@ -176,19 +165,6 @@ public void addServerStoredGroupChangeListener(ServerStoredGroupListener
ssContactList.addGroupListener(listener);
}
/**
* Registers a listener that would get notifications any time a new
* subscription was successfully added, has failed or was removed.
*
* @param listener the SubscriptionListener to register
*/
public void addSubsciptionListener(SubscriptionListener listener)
{
synchronized(subscriptionListeners){
subscriptionListeners.add(listener);
}
}
/**
* Creates a group with the specified name and parent in the server
* stored contact list.
@ -421,7 +397,7 @@ public void publishPresenceStatus(PresenceStatus status,
if(status.equals(MsnStatusEnum.OFFLINE))
{
msnProvider.unregister();
parentProvider.unregister();
return;
}
@ -430,10 +406,10 @@ public void publishPresenceStatus(PresenceStatus status,
//(as if set the status too early the server does not provide
// any status information about the contacts in our list)
if(ssContactList.isInitialized())
msnProvider.getMessenger().getOwner().
parentProvider.getMessenger().getOwner().
setStatus((MsnUserStatus)scToMsnModesMappings.get(status));
else
msnProvider.getMessenger().getOwner().
parentProvider.getMessenger().getOwner().
setInitStatus((MsnUserStatus)scToMsnModesMappings.get(status));
}
@ -522,18 +498,6 @@ public void removeServerStoredGroupChangeListener(ServerStoredGroupListener
ssContactList.removeGroupListener(listener);
}
/**
* Removes the specified subscription listener.
*
* @param listener the listener to remove.
*/
public void removeSubscriptionListener(SubscriptionListener listener)
{
synchronized(subscriptionListeners){
subscriptionListeners.remove(listener);
}
}
/**
* Renames the specified group from the server stored contact list.
*
@ -681,11 +645,11 @@ else if(status.equals(MsnUserStatus.OUT_TO_LUNCH))
*/
private void assertConnected() throws IllegalStateException
{
if (msnProvider == null)
if (parentProvider == null)
throw new IllegalStateException(
"The provider must be non-null and signed on the msn "
+"service before being able to communicate.");
if (!msnProvider.isRegistered())
if (!parentProvider.isRegistered())
throw new IllegalStateException(
"The provider must be signed on the msn service before "
+"being able to communicate.");
@ -707,7 +671,7 @@ void fireProviderPresenceStatusChangeEvent(
ProviderPresenceStatusChangeEvent evt =
new ProviderPresenceStatusChangeEvent(
msnProvider, oldStatus, newStatus);
parentProvider, oldStatus, newStatus);
currentStatus = newStatus;
@ -742,7 +706,7 @@ private void fireProviderStatusMessageChangeEvent(
{
PropertyChangeEvent evt = new PropertyChangeEvent(
msnProvider, ProviderPresenceStatusListener.STATUS_MESSAGE,
parentProvider, ProviderPresenceStatusListener.STATUS_MESSAGE,
oldStatusMessage, newStatusMessage);
logger.debug("Dispatching stat. msg change. Listeners="
@ -786,7 +750,7 @@ public void registrationStateChanged(RegistrationStateChangeEvent evt)
if(evt.getNewState() == RegistrationState.REGISTERED)
{
msnProvider.getMessenger().
parentProvider.getMessenger().
addContactListListener(new StatusChangedListener());
}
else if(evt.getNewState() == RegistrationState.UNREGISTERED
@ -858,82 +822,6 @@ else if(evt.getNewState() == RegistrationState.UNREGISTERED
}
}
/**
* Notify all subscription listeners of the corresponding event.
*
* @param eventID the int ID of the event to dispatch
* @param sourceContact the ContactMsnImpl instance that this event is
* pertaining to.
* @param parentGroup the ContactGroupMsnImpl under which the corresponding
* subscription is located.
*/
void fireSubscriptionEvent( int eventID,
ContactMsnImpl sourceContact,
ContactGroup parentGroup)
{
SubscriptionEvent evt =
new SubscriptionEvent(sourceContact, msnProvider, parentGroup,
eventID);
logger.debug("Dispatching a Subscription Event to"
+subscriptionListeners.size() + " listeners. Evt="+evt);
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
if (evt.getEventID() == SubscriptionEvent.SUBSCRIPTION_CREATED)
listener.subscriptionCreated(evt);
else if (evt.getEventID() == SubscriptionEvent.SUBSCRIPTION_REMOVED)
listener.subscriptionRemoved(evt);
else if (evt.getEventID() == SubscriptionEvent.SUBSCRIPTION_FAILED)
listener.subscriptionFailed(evt);
}
}
/**
* Notify all subscription listeners of the corresponding event.
*
* @param sourceContact the ContactMsnImpl instance that this event is
* pertaining to.
* @param oldParentGroup the group that was previously a parent of the
* source contact.
* @param newParentGroup the group under which the corresponding
* subscription is currently located.
*/
void fireSubscriptionMovedEvent( ContactMsnImpl sourceContact,
ContactGroup oldParentGroup,
ContactGroup newParentGroup)
{
SubscriptionMovedEvent evt =
new SubscriptionMovedEvent(sourceContact, msnProvider
, oldParentGroup, newParentGroup);
logger.debug("Dispatching a Subscription Event to"
+subscriptionListeners.size() + " listeners. Evt="+evt);
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
listener.subscriptionMoved(evt);
}
}
/**
* Notify all contact presence listeners of the corresponding event change
* @param contact the contact that changed its status
@ -949,7 +837,7 @@ void fireContactPresenceStatusChangeEvent(
{
ContactPresenceStatusChangeEvent evt =
new ContactPresenceStatusChangeEvent(
contact, msnProvider, parentGroup, oldStatus, newStatus);
contact, parentProvider, parentGroup, oldStatus, newStatus);
logger.debug("Dispatching Contact Status Change. Listeners="
@ -970,46 +858,6 @@ void fireContactPresenceStatusChangeEvent(
listener.contactPresenceStatusChanged(evt);
}
}
/**
* Notify all subscription listeners of the corresponding contact property
* change event.
*
* @param eventID the String ID of the event to dispatch
* @param sourceContact the ContactJabberImpl instance that this event is
* pertaining to.
* @param oldValue the value that the changed property had before the change
* occurred.
* @param newValue the value that the changed property currently has (after
* the change has occurred).
*/
void fireContactPropertyChangeEvent( String eventID,
ContactMsnImpl sourceContact,
Object oldValue,
Object newValue)
{
ContactPropertyChangeEvent evt =
new ContactPropertyChangeEvent(sourceContact, eventID
, oldValue, newValue);
logger.debug("Dispatching a Contact Property Change Event to"
+subscriptionListeners.size() + " listeners. Evt="+evt);
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
listener.contactModified(evt);
}
}
/**
* Sets the messenger instance impl of the lib

@ -210,7 +210,7 @@ private void fireContactRemoved( ContactGroup parentGroup,
//dispatch
parentOperationSet.fireSubscriptionEvent(
SubscriptionEvent.SUBSCRIPTION_REMOVED, contact, parentGroup);
contact, parentGroup, SubscriptionEvent.SUBSCRIPTION_REMOVED);
}
/**
@ -701,7 +701,7 @@ void fireContactAdded( ContactGroup parentGroup,
//dispatch
parentOperationSet.fireSubscriptionEvent(
SubscriptionEvent.SUBSCRIPTION_CREATED, contact, parentGroup);
contact, parentGroup, SubscriptionEvent.SUBSCRIPTION_CREATED);
// sometimes when adding msn contact
// status updates comes before event for adding contact and so
@ -750,7 +750,7 @@ void fireContactResolved( ContactGroup parentGroup,
//dispatch
parentOperationSet.fireSubscriptionEvent(
SubscriptionEvent.SUBSCRIPTION_RESOLVED, contact, parentGroup);
contact, parentGroup, SubscriptionEvent.SUBSCRIPTION_RESOLVED);
}
/**

@ -25,16 +25,11 @@
* @author Emil Ivov
*/
public class OperationSetPersistentPresenceRssImpl
implements OperationSetPersistentPresence
extends AbstractOperationSetPersistentPresence<ProtocolProviderServiceRssImpl>
{
private static final Logger logger =
Logger.getLogger(OperationSetPersistentPresenceRssImpl.class);
/**
* A list of listeners registered for <tt>SubscriptionEvent</tt>s.
*/
private Vector subscriptionListeners = new Vector();
/**
* A list of listeners registered for <tt>ServerStoredGroupChangeEvent</tt>s.
*/
@ -57,11 +52,6 @@ public class OperationSetPersistentPresenceRssImpl
*/
private ContactGroupRssImpl contactListRoot = null;
/**
* The provider that created us.
*/
private ProtocolProviderServiceRssImpl parentProvider = null;
/**
* The currently active status message.
*/
@ -87,7 +77,8 @@ public class OperationSetPersistentPresenceRssImpl
public OperationSetPersistentPresenceRssImpl(
ProtocolProviderServiceRssImpl provider)
{
this.parentProvider = provider;
super(provider);
contactListRoot = new ContactGroupRssImpl("RootGroup", provider);
// add our un-registration listener
@ -143,121 +134,6 @@ public void fireContactPresenceStatusChangeEvent(ContactRssImpl source,
}
}
/**
* Notify all subscription listeners of the corresponding contact property
* change event.
*
* @param eventID the String ID of the event to dispatch
* @param sourceContact the ContactRssImpl instance that this event is
* pertaining to.
* @param oldValue the value that the changed property had before the change
* occurred.
* @param newValue the value that the changed property currently has (after
* the change has occurred).
*/
void fireContactPropertyChangeEvent( String eventID,
ContactRssImpl sourceContact,
Object oldValue,
Object newValue)
{
ContactPropertyChangeEvent evt =
new ContactPropertyChangeEvent(sourceContact, eventID
, oldValue, newValue);
logger.debug("Dispatching a Contact Property Change Event to "
+subscriptionListeners.size() + " listeners. Evt="+evt);
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
listener.contactModified(evt);
}
}
/**
* Notifies all registered listeners of the new event.
*
* @param source the contact that has caused the event.
* @param parentGroup the group that contains the source contact.
* @param eventID an identifier of the event to dispatch.
*/
public void fireSubscriptionEvent(ContactRssImpl source,
ContactGroup parentGroup,
int eventID)
{
SubscriptionEvent evt = new SubscriptionEvent(source
, this.parentProvider
, parentGroup
, eventID);
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
if(eventID == SubscriptionEvent.SUBSCRIPTION_CREATED)
{
listener.subscriptionCreated(evt);
}
else if (eventID == SubscriptionEvent.SUBSCRIPTION_FAILED)
{
listener.subscriptionFailed(evt);
}
else if (eventID == SubscriptionEvent.SUBSCRIPTION_REMOVED)
{
listener.subscriptionRemoved(evt);
}
}
}
/**
* Notifies all registered listeners of the new event.
*
* @param source the contact that has been moved..
* @param oldParent the group where the contact was located before being
* moved.
* @param newParent the group where the contact has been moved.
*/
public void fireSubscriptionMovedEvent(Contact source,
ContactGroup oldParent,
ContactGroup newParent)
{
SubscriptionMovedEvent evt = new SubscriptionMovedEvent(source
, this.parentProvider
, oldParent
, newParent);
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
listener.subscriptionMoved(evt);
}
}
/**
* Notifies all registered listeners of the new event.
*
@ -356,21 +232,6 @@ public void addServerStoredGroupChangeListener(ServerStoredGroupListener
}
}
/**
* RSS implementation of the corresponding ProtocolProviderService
* method.
*
* @param listener the SubscriptionListener to register
*/
public void addSubsciptionListener(SubscriptionListener listener)
{
synchronized(subscriptionListeners)
{
if (!subscriptionListeners.contains(listener))
this.subscriptionListeners.add(listener);
}
}
/**
* Creates a group with the specified name and parent in the server
* stored contact list.
@ -776,19 +637,6 @@ public void removeServerStoredGroupChangeListener(ServerStoredGroupListener
}
}
/**
* Removes the specified subscription listener.
*
* @param listener the listener to remove.
*/
public void removeSubscriptionListener(SubscriptionListener listener)
{
synchronized(subscriptionListeners)
{
this.subscriptionListeners.remove(listener);
}
}
/**
* Renames the specified group from the server stored contact list.
*

@ -37,14 +37,11 @@
* @author Lubomir Marinov
*/
public class OperationSetPresenceSipImpl
implements OperationSetPersistentPresence, SipListener
extends AbstractOperationSetPersistentPresence<ProtocolProviderServiceSipImpl>
implements SipListener
{
private static final Logger logger =
Logger.getLogger(OperationSetPresenceSipImpl.class);
/**
* A list of listeners registered for <tt>SubscriptionEvent</tt>s.
*/
private Vector subscriptionListeners = new Vector();
/**
* A list of listeners registered for
@ -69,11 +66,6 @@ public class OperationSetPresenceSipImpl
*/
private ContactGroupSipImpl contactListRoot = null;
/**
* The provider that created us.
*/
private ProtocolProviderServiceSipImpl parentProvider = null;
/**
* The currently active status message.
*/
@ -258,7 +250,8 @@ public OperationSetPresenceSipImpl(ProtocolProviderServiceSipImpl provider,
boolean isPresenceEnabled, boolean forceP2PMode, int pollingPeriod,
int subscriptionExpiration)
{
this.parentProvider = provider;
super(provider);
this.contactListRoot = new ContactGroupSipImpl("RootGroup", provider);
//add our registration listener
@ -480,38 +473,6 @@ public void moveContactToGroup(Contact contactToMove,
newParent);
}
/**
* Notifies all registered listeners of the new event.
*
* @param source the contact that has been moved..
* @param oldParent the group where the contact was located before being
* moved.
* @param newParent the group where the contact has been moved.
*/
public void fireSubscriptionMovedEvent(Contact source,
ContactGroup oldParent,
ContactGroup newParent)
{
SubscriptionMovedEvent evt = new SubscriptionMovedEvent(source,
this.parentProvider,
oldParent,
newParent);
Iterator listeners = null;
synchronized (this.subscriptionListeners)
{
listeners = new ArrayList(this.subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
listener.subscriptionMoved(evt);
}
}
/**
* Removes the specified group from the server stored contact list.
*
@ -3231,32 +3192,6 @@ public void removeContactPresenceStatusListener(
}
}
/**
* Registers a listener that would get notifications any time a new
* subscription was successfully added, has failed or was removed.
*
* @param listener the SubscriptionListener to register
*/
public void addSubsciptionListener(SubscriptionListener listener) {
synchronized(this.subscriptionListeners)
{
if (!this.subscriptionListeners.contains(listener))
this.subscriptionListeners.add(listener);
}
}
/**
* Removes the specified subscription listener.
*
* @param listener the listener to remove.
*/
public void removeSubscriptionListener(SubscriptionListener listener) {
synchronized(this.subscriptionListeners)
{
this.subscriptionListeners.remove(listener);
}
}
/**
* Registers a listener that would receive events upon changes in server
* stored groups.
@ -3299,71 +3234,6 @@ public String getCurrentStatusMessage() {
return this.statusMessage;
}
/**
* Notifies all registered listeners of the new event.
*
* @param source the contact that has caused the event.
* @param parentGroup the group that contains the source contact.
* @param eventID an identifier of the event to dispatch.
*/
public void fireSubscriptionEvent(ContactSipImpl source,
ContactGroup parentGroup,
int eventID)
{
fireSubscriptionEvent(source, parentGroup, eventID,
SubscriptionEvent.ERROR_UNSPECIFIED, null);
}
/**
* Notifies all registered listeners of the new event.
*
* @param source the contact that has caused the event.
* @param parentGroup the group that contains the source contact.
* @param eventID an identifier of the event to dispatch.
*/
public void fireSubscriptionEvent(ContactSipImpl source,
ContactGroup parentGroup,
int eventID,
int errorCode,
String errorReason)
{
SubscriptionEvent evt = new SubscriptionEvent(source
, this.parentProvider
, parentGroup
, eventID
, errorCode
, errorReason);
Iterator listeners = null;
synchronized (this.subscriptionListeners)
{
listeners = new ArrayList(this.subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
if(eventID == SubscriptionEvent.SUBSCRIPTION_CREATED)
{
listener.subscriptionCreated(evt);
}
else if (eventID == SubscriptionEvent.SUBSCRIPTION_FAILED)
{
listener.subscriptionFailed(evt);
}
else if (eventID == SubscriptionEvent.SUBSCRIPTION_REMOVED)
{
listener.subscriptionRemoved(evt);
}
else if (eventID == SubscriptionEvent.SUBSCRIPTION_RESOLVED)
{
listener.subscriptionResolved(evt);
}
}
}
/**
* Creates and returns a unresolved contact from the specified
* <tt>address</tt> and <tt>persistentData</tt>. The method will not try

@ -29,14 +29,10 @@
* @author Shobhit Jindal
*/
public class OperationSetPersistentPresenceSSHImpl
implements OperationSetPersistentPresence
extends AbstractOperationSetPersistentPresence<ProtocolProviderServiceSSHImpl>
{
private static final Logger logger =
Logger.getLogger(OperationSetPersistentPresenceSSHImpl.class);
/**
* A list of listeners registered for <tt>SubscriptionEvent</tt>s.
*/
private Vector subscriptionListeners = new Vector();
/**
* A list of listeners registered for <tt>ServerStoredGroupChangeEvent</tt>s.
@ -60,11 +56,6 @@ public class OperationSetPersistentPresenceSSHImpl
*/
private ContactGroupSSHImpl contactListRoot = null;
/**
* The provider that created us.
*/
private ProtocolProviderServiceSSHImpl parentProvider = null;
/**
* The currently active status message.
*/
@ -84,7 +75,8 @@ public class OperationSetPersistentPresenceSSHImpl
public OperationSetPersistentPresenceSSHImpl(
ProtocolProviderServiceSSHImpl provider)
{
this.parentProvider = provider;
super(provider);
contactListRoot = new ContactGroupSSHImpl("RootGroup", provider);
//add our unregistration listener
@ -161,85 +153,7 @@ public void fireContactPresenceStatusChangeEvent(
listener.contactPresenceStatusChanged(evt);
}
}
/**
* Notifies all registered listeners of the new event.
*
* @param source the contact that has caused the event.
* @param parentGroup the group that contains the source contact.
* @param eventID an identifier of the event to dispatch.
*/
public void fireSubscriptionEvent(
ContactSSH source,
ContactGroup parentGroup,
int eventID)
{
SubscriptionEvent evt = new SubscriptionEvent(source
, this.parentProvider
, parentGroup
, eventID);
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
if(eventID == SubscriptionEvent.SUBSCRIPTION_CREATED)
{
listener.subscriptionCreated(evt);
}
else if (eventID == SubscriptionEvent.SUBSCRIPTION_FAILED)
{
listener.subscriptionFailed(evt);
}
else if (eventID == SubscriptionEvent.SUBSCRIPTION_REMOVED)
{
listener.subscriptionRemoved(evt);
}
}
}
/**
* Notifies all registered listeners of the new event.
*
* @param source the contact that has been moved..
* @param oldParent the group where the contact was located before being
* moved.
* @param newParent the group where the contact has been moved.
*/
public void fireSubscriptionMovedEvent(
Contact source,
ContactGroup oldParent,
ContactGroup newParent)
{
SubscriptionMovedEvent evt = new SubscriptionMovedEvent(source
, this.parentProvider
, oldParent
, newParent);
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
listener.subscriptionMoved(evt);
}
}
/**
* Notifies all registered listeners of the new event.
*
@ -342,23 +256,7 @@ public void addServerStoredGroupChangeListener(
serverStoredGroupListeners.add(listener);
}
}
/**
* SSH implementation of the corresponding ProtocolProviderService
* method.
*
* @param listener the SubscriptionListener to register
*/
public void addSubsciptionListener(
SubscriptionListener listener)
{
synchronized(subscriptionListeners)
{
if (!subscriptionListeners.contains(listener))
this.subscriptionListeners.add(listener);
}
}
/**
* Creates a group with the specified name and parent in the server
* stored contact list.
@ -789,21 +687,7 @@ public void removeServerStoredGroupChangeListener(
serverStoredGroupListeners.remove(listener);
}
}
/**
* Removes the specified subscription listener.
*
* @param listener the listener to remove.
*/
public void removeSubscriptionListener(
SubscriptionListener listener)
{
synchronized(subscriptionListeners)
{
this.subscriptionListeners.remove(listener);
}
}
/**
* Renames the specified group from the server stored contact list.
*

@ -25,16 +25,11 @@
* @author Damian Minkov
*/
public class OperationSetPersistentPresenceYahooImpl
implements OperationSetPersistentPresence
extends AbstractOperationSetPersistentPresence<ProtocolProviderServiceYahooImpl>
{
private static final Logger logger =
Logger.getLogger(OperationSetPersistentPresenceYahooImpl.class);
/**
* A callback to the Yahoo provider that created us.
*/
private ProtocolProviderServiceYahooImpl yahooProvider = null;
/**
* Contains our current status message. Note that this field would only
* be changed once the server has confirmed the new status message and
@ -54,12 +49,6 @@ public class OperationSetPersistentPresenceYahooImpl
*/
private Vector providerPresenceStatusListeners = new Vector();
/**
* The list of subscription listeners interested in receiving notifications
* whenever .
*/
private Vector subscriptionListeners = new Vector();
/**
* The list of presence status listeners interested in receiving presence
* notifications of changes in status of contacts in our contact list.
@ -143,11 +132,11 @@ public class OperationSetPersistentPresenceYahooImpl
public OperationSetPersistentPresenceYahooImpl(
ProtocolProviderServiceYahooImpl provider)
{
this.yahooProvider = provider;
super(provider);
ssContactList = new ServerStoredContactListYahooImpl( this , provider);
this.yahooProvider.addRegistrationStateChangeListener(
parentProvider.addRegistrationStateChangeListener(
new RegistrationStateListener());
}
@ -195,19 +184,6 @@ public void addServerStoredGroupChangeListener(ServerStoredGroupListener
ssContactList.addGroupListener(listener);
}
/**
* Registers a listener that would get notifications any time a new
* subscription was succesfully added, has failed or was removed.
*
* @param listener the SubscriptionListener to register
*/
public void addSubsciptionListener(SubscriptionListener listener)
{
synchronized(subscriptionListeners){
subscriptionListeners.add(listener);
}
}
/**
* Creates a group with the specified name and parent in the server
* stored contact list.
@ -440,7 +416,7 @@ public void publishPresenceStatus(PresenceStatus status,
if(status.equals(YahooStatusEnum.OFFLINE))
{
yahooProvider.unregister();
parentProvider.unregister();
return;
}
@ -455,11 +431,11 @@ public void publishPresenceStatus(PresenceStatus status,
// false - away
// true - available
yahooProvider.getYahooSession().
parentProvider.getYahooSession().
setStatus(statusMessage, isAvailable);
}
yahooProvider.getYahooSession().setStatus(
parentProvider.getYahooSession().setStatus(
((Long)scToYahooModesMappings.get(status)).longValue());
fireProviderPresenceStatusChangeEvent(currentStatus, status);
@ -557,18 +533,6 @@ public void removeServerStoredGroupChangeListener(ServerStoredGroupListener
ssContactList.removeGroupListener(listener);
}
/**
* Removes the specified subscription listener.
*
* @param listener the listener to remove.
*/
public void removeSubscriptionListener(SubscriptionListener listener)
{
synchronized(subscriptionListeners){
subscriptionListeners.remove(listener);
}
}
/**
* Renames the specified group from the server stored contact list.
*
@ -730,11 +694,11 @@ else if(status == StatusConstants.STATUS_OFFLINE)
*/
private void assertConnected() throws IllegalStateException
{
if (yahooProvider == null)
if (parentProvider == null)
throw new IllegalStateException(
"The provider must be non-null and signed on the yahoo "
+"service before being able to communicate.");
if (!yahooProvider.isRegistered())
if (!parentProvider.isRegistered())
throw new IllegalStateException(
"The provider must be signed on the yahoo service before "
+"being able to communicate.");
@ -756,7 +720,7 @@ void fireProviderPresenceStatusChangeEvent(
ProviderPresenceStatusChangeEvent evt =
new ProviderPresenceStatusChangeEvent(
yahooProvider, oldStatus, newStatus);
parentProvider, oldStatus, newStatus);
currentStatus = newStatus;
@ -791,7 +755,7 @@ private void fireProviderStatusMessageChangeEvent(
{
PropertyChangeEvent evt = new PropertyChangeEvent(
yahooProvider, ProviderPresenceStatusListener.STATUS_MESSAGE,
parentProvider, ProviderPresenceStatusListener.STATUS_MESSAGE,
oldStatusMessage, newStatusMessage);
logger.debug("Dispatching stat. msg change. Listeners="
@ -819,7 +783,7 @@ private void fireProviderStatusMessageChangeEvent(
*/
private void initContactStatuses()
{
YahooGroup[] groups = yahooProvider.getYahooSession().getGroups();
YahooGroup[] groups = parentProvider.getYahooSession().getGroups();
for (int i = 0; i < groups.length; i++)
{
@ -860,10 +824,10 @@ public void registrationStateChanged(RegistrationStateChangeEvent evt)
if(evt.getNewState() == RegistrationState.REGISTERED)
{
yahooProvider.getYahooSession().
parentProvider.getYahooSession().
addSessionListener(new StatusChangedListener());
ssContactList.setYahooSession(yahooProvider.getYahooSession());
ssContactList.setYahooSession(parentProvider.getYahooSession());
initContactStatuses();
@ -921,82 +885,6 @@ else if(evt.getNewState() == RegistrationState.UNREGISTERED
}
}
/**
* Notify all subscription listeners of the corresponding event.
*
* @param eventID the int ID of the event to dispatch
* @param sourceContact the ContactYahooImpl instance that this event is
* pertaining to.
* @param parentGroup the ContactGroupYahooImpl under which the corresponding
* subscription is located.
*/
void fireSubscriptionEvent( int eventID,
ContactYahooImpl sourceContact,
ContactGroup parentGroup)
{
SubscriptionEvent evt =
new SubscriptionEvent(sourceContact, yahooProvider, parentGroup,
eventID);
logger.debug("Dispatching a Subscription Event to"
+subscriptionListeners.size() + " listeners. Evt="+evt);
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
if (evt.getEventID() == SubscriptionEvent.SUBSCRIPTION_CREATED)
listener.subscriptionCreated(evt);
else if (evt.getEventID() == SubscriptionEvent.SUBSCRIPTION_REMOVED)
listener.subscriptionRemoved(evt);
else if (evt.getEventID() == SubscriptionEvent.SUBSCRIPTION_FAILED)
listener.subscriptionFailed(evt);
}
}
/**
* Notify all subscription listeners of the corresponding event.
*
* @param sourceContact the ContactYahooImpl instance that this event is
* pertaining to.
* @param oldParentGroup the group that was previously a parent of the
* source contact.
* @param newParentGroup the group under which the corresponding
* subscription is currently located.
*/
void fireSubscriptionMovedEvent( ContactYahooImpl sourceContact,
ContactGroup oldParentGroup,
ContactGroup newParentGroup)
{
SubscriptionMovedEvent evt =
new SubscriptionMovedEvent(sourceContact, yahooProvider
, oldParentGroup, newParentGroup);
logger.debug("Dispatching a Subscription Event to"
+subscriptionListeners.size() + " listeners. Evt="+evt);
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
listener.subscriptionMoved(evt);
}
}
/**
* Notify all contact presence listeners of the corresponding event change
* @param contact the contact that changed its status
@ -1012,7 +900,7 @@ private void fireContactPresenceStatusChangeEvent(
{
ContactPresenceStatusChangeEvent evt =
new ContactPresenceStatusChangeEvent(
contact, yahooProvider, parentGroup, oldStatus, newStatus);
contact, parentProvider, parentGroup, oldStatus, newStatus);
logger.debug("Dispatching Contact Status Change. Listeners="
@ -1033,46 +921,6 @@ private void fireContactPresenceStatusChangeEvent(
listener.contactPresenceStatusChanged(evt);
}
}
/**
* Notify all subscription listeners of the corresponding contact property
* change event.
*
* @param eventID the String ID of the event to dispatch
* @param sourceContact the ContactJabberImpl instance that this event is
* pertaining to.
* @param oldValue the value that the changed property had before the change
* occurred.
* @param newValue the value that the changed property currently has (after
* the change has occurred).
*/
void fireContactPropertyChangeEvent( String eventID,
ContactYahooImpl sourceContact,
Object oldValue,
Object newValue)
{
ContactPropertyChangeEvent evt =
new ContactPropertyChangeEvent(sourceContact, eventID
, oldValue, newValue);
logger.debug("Dispatching a Contact Property Change Event to"
+subscriptionListeners.size() + " listeners. Evt="+evt);
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
listener.contactModified(evt);
}
}
private void handleContactStatusChange(YahooUser yFriend)
{
@ -1081,7 +929,7 @@ private void handleContactStatusChange(YahooUser yFriend)
if(sourceContact == null)
{
if(yahooProvider.getAccountID().getUserID().
if(parentProvider.getAccountID().getUserID().
equals(yFriend.getId()))
{
// thats my own status

@ -208,7 +208,7 @@ private void fireContactRemoved( ContactGroup parentGroup,
//dispatch
parentOperationSet.fireSubscriptionEvent(
SubscriptionEvent.SUBSCRIPTION_REMOVED, contact, parentGroup);
contact, parentGroup, SubscriptionEvent.SUBSCRIPTION_REMOVED);
}
/**
@ -698,7 +698,7 @@ void fireContactAdded( ContactGroup parentGroup,
//dispatch
parentOperationSet.fireSubscriptionEvent(
SubscriptionEvent.SUBSCRIPTION_CREATED, contact, parentGroup);
contact, parentGroup, SubscriptionEvent.SUBSCRIPTION_CREATED);
}
/**
@ -718,7 +718,7 @@ void fireContactResolved( ContactGroup parentGroup,
//dispatch
parentOperationSet.fireSubscriptionEvent(
SubscriptionEvent.SUBSCRIPTION_RESOLVED, contact, parentGroup);
contact, parentGroup, SubscriptionEvent.SUBSCRIPTION_RESOLVED);
}
/**

@ -26,14 +26,10 @@
* @author Jonathan Martin
*/
public class OperationSetPersistentPresenceZeroconfImpl
implements OperationSetPersistentPresence
extends AbstractOperationSetPersistentPresence<ProtocolProviderServiceZeroconfImpl>
{
private static final Logger logger =
Logger.getLogger(OperationSetPersistentPresenceZeroconfImpl.class);
/**
* A list of listeners registered for <tt>SubscriptionEvent</tt>s.
*/
private Vector subscriptionListeners = new Vector();
/**
* A list of listeners registered for <tt>ServerStoredGroupChangeEvent</tt>s.
@ -57,11 +53,6 @@ public class OperationSetPersistentPresenceZeroconfImpl
*/
private ContactGroupZeroconfImpl contactListRoot = null;
/**
* The provider that created us.
*/
private ProtocolProviderServiceZeroconfImpl parentProvider = null;
/**
* The currently active status message.
*/
@ -86,9 +77,9 @@ public class OperationSetPersistentPresenceZeroconfImpl
*/
public OperationSetPersistentPresenceZeroconfImpl(
ProtocolProviderServiceZeroconfImpl provider)
{
this.parentProvider = provider;
{
super(provider);
contactListRoot = new ContactGroupZeroconfImpl("RootGroup", provider);
//add our unregistration listener
@ -143,83 +134,6 @@ public void fireContactPresenceStatusChangeEvent(ContactZeroconfImpl source,
}
}
/**
* Notifies all registered listeners of the new event.
*
* @param source the contact that has caused the event.
* @param parentGroup the group that contains the source contact.
* @param eventID an identifier of the event to dispatch.
*/
public void fireSubscriptionEvent(ContactZeroconfImpl source,
ContactGroup parentGroup,
int eventID)
{
SubscriptionEvent evt = new SubscriptionEvent(source
, this.parentProvider
, parentGroup
, eventID);
//logger.debug("ZEROCNF: Creation contact " + source.getAddress());
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
if(eventID == SubscriptionEvent.SUBSCRIPTION_CREATED)
{
listener.subscriptionCreated(evt);
}
else if (eventID == SubscriptionEvent.SUBSCRIPTION_FAILED)
{
listener.subscriptionFailed(evt);
}
else if (eventID == SubscriptionEvent.SUBSCRIPTION_REMOVED)
{
listener.subscriptionRemoved(evt);
}
}
}
/**
* Notifies all registered listeners of the new event.
*
* @param source the contact that has been moved..
* @param oldParent the group where the contact was located before being
* moved.
* @param newParent the group where the contact has been moved.
*/
public void fireSubscriptionMovedEvent(Contact source,
ContactGroup oldParent,
ContactGroup newParent)
{
SubscriptionMovedEvent evt = new SubscriptionMovedEvent(source
, this.parentProvider
, oldParent
, newParent);
Iterator listeners = null;
synchronized (subscriptionListeners)
{
listeners = new ArrayList(subscriptionListeners).iterator();
}
while (listeners.hasNext())
{
SubscriptionListener listener
= (SubscriptionListener) listeners.next();
listener.subscriptionMoved(evt);
}
}
/**
* Notifies all registered listeners of the new event.
*
@ -320,21 +234,6 @@ public void addServerStoredGroupChangeListener(ServerStoredGroupListener
}
}
/**
* Zeroconf implementation of the corresponding ProtocolProviderService
* method.
*
* @param listener the SubscriptionListener to register
*/
public void addSubsciptionListener(SubscriptionListener listener)
{
synchronized(subscriptionListeners)
{
if (!subscriptionListeners.contains(listener))
this.subscriptionListeners.add(listener);
}
}
/**
* Creates a group with the specified name and parent in the server
* stored contact list.
@ -726,19 +625,6 @@ public void removeServerStoredGroupChangeListener(ServerStoredGroupListener
}
}
/**
* Removes the specified subscription listener.
*
* @param listener the listener to remove.
*/
public void removeSubscriptionListener(SubscriptionListener listener)
{
synchronized(subscriptionListeners)
{
this.subscriptionListeners.remove(listener);
}
}
/**
* Renames the specified group from the server stored contact list.
*

@ -0,0 +1,188 @@
/*
* 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;
import java.util.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.*;
/**
* Represents a default implementation of
* <tt>OperationSetPersistentPresence</tt> in order to make it easier for
* implementers to provide complete solutions while focusing on
* implementation-specific details.
*
* @author Lubomir Marinov
*/
public abstract class AbstractOperationSetPersistentPresence<T extends ProtocolProviderService>
implements OperationSetPersistentPresence
{
private static final Logger logger =
Logger.getLogger(AbstractOperationSetPersistentPresence.class);
/**
* The provider that created us.
*/
protected final T parentProvider;
/**
* The list of listeners interested in <tt>SubscriptionEvent</tt>s.
*/
private final List<SubscriptionListener> subscriptionListeners =
new Vector<SubscriptionListener>();
/**
* Initializes a new <tt>AbstractOperationSetPersistentPresence</tt>
* instance created by a specific <tt>ProtocolProviderService</tt> .
*
* @param parentProvider the <tt>ProtocolProviderService</tt> which created
* the new instance
*/
protected AbstractOperationSetPersistentPresence(T parentProvider)
{
this.parentProvider = parentProvider;
}
public void addSubsciptionListener(SubscriptionListener listener)
{
synchronized (subscriptionListeners)
{
if (!subscriptionListeners.contains(listener))
subscriptionListeners.add(listener);
}
}
/**
* Notify all subscription listeners of the corresponding contact property
* change event.
*
* @param eventID the String ID of the event to dispatch
* @param sourceContact the ContactJabberImpl instance that this event is
* pertaining to.
* @param oldValue the value that the changed property had before the change
* occurred.
* @param newValue the value that the changed property currently has (after
* the change has occurred).
*/
public void fireContactPropertyChangeEvent(String eventID, Contact source,
Object oldValue, Object newValue)
{
ContactPropertyChangeEvent evt =
new ContactPropertyChangeEvent(source, eventID, oldValue, newValue);
List<SubscriptionListener> listeners;
synchronized (subscriptionListeners)
{
listeners =
new ArrayList<SubscriptionListener>(subscriptionListeners);
}
logger.debug("Dispatching a Contact Property Change Event to"
+ listeners.size() + " listeners. Evt=" + evt);
for (Iterator<SubscriptionListener> listenerIt = listeners.iterator(); listenerIt
.hasNext();)
listenerIt.next().contactModified(evt);
}
/**
* Notifies all registered listeners of the new event.
*
* @param source the contact that has caused the event.
* @param parentGroup the group that contains the source contact.
* @param eventID an identifier of the event to dispatch.
*/
public void fireSubscriptionEvent(Contact source, ContactGroup parentGroup,
int eventID)
{
fireSubscriptionEvent(source, parentGroup, eventID,
SubscriptionEvent.ERROR_UNSPECIFIED, null);
}
public void fireSubscriptionEvent(Contact source, ContactGroup parentGroup,
int eventID, int errorCode, String errorReason)
{
SubscriptionEvent evt =
new SubscriptionEvent(source, parentProvider, parentGroup, eventID,
errorCode, errorReason);
List<SubscriptionListener> listeners;
synchronized (subscriptionListeners)
{
listeners =
new ArrayList<SubscriptionListener>(subscriptionListeners);
}
logger.debug("Dispatching a Subscription Event to" + listeners.size()
+ " listeners. Evt=" + evt);
for (Iterator<SubscriptionListener> listenerIt = listeners.iterator(); listenerIt
.hasNext();)
{
SubscriptionListener listener = listenerIt.next();
switch (eventID)
{
case SubscriptionEvent.SUBSCRIPTION_CREATED:
listener.subscriptionCreated(evt);
break;
case SubscriptionEvent.SUBSCRIPTION_FAILED:
listener.subscriptionFailed(evt);
break;
case SubscriptionEvent.SUBSCRIPTION_REMOVED:
listener.subscriptionRemoved(evt);
break;
case SubscriptionEvent.SUBSCRIPTION_RESOLVED:
listener.subscriptionResolved(evt);
break;
}
}
}
/**
* Notifies all registered listeners of the new event.
*
* @param source the contact that has been moved..
* @param oldParent the group where the contact was located before being
* moved.
* @param newParent the group where the contact has been moved.
*/
public void fireSubscriptionMovedEvent(Contact source,
ContactGroup oldParent, ContactGroup newParent)
{
SubscriptionMovedEvent evt =
new SubscriptionMovedEvent(source, parentProvider, oldParent,
newParent);
List<SubscriptionListener> listeners;
synchronized (subscriptionListeners)
{
listeners =
new ArrayList<SubscriptionListener>(subscriptionListeners);
}
logger.debug("Dispatching a Subscription Event to" + listeners.size()
+ " listeners. Evt=" + evt);
for (Iterator<SubscriptionListener> listenerIt = listeners.iterator(); listenerIt
.hasNext();)
listenerIt.next().subscriptionMoved(evt);
}
/**
* Removes the specified subscription listener.
*
* @param listener the listener to remove.
*/
public void removeSubscriptionListener(SubscriptionListener listener)
{
synchronized (subscriptionListeners)
{
subscriptionListeners.remove(listener);
}
}
}
Loading…
Cancel
Save