aboutsummaryrefslogtreecommitdiffstats
path: root/src/net
diff options
context:
space:
mode:
authorEmil Ivov <emcho@jitsi.org>2008-06-20 09:57:23 +0000
committerEmil Ivov <emcho@jitsi.org>2008-06-20 09:57:23 +0000
commitafd8c62ae92f579dbec9758ccadd9e113c7b3843 (patch)
tree6e0f713475c611c5f4fc52ab23a229c3f82661fd /src/net
parentf3be223e8d21ad7d6c2d7c779c179747e9c41dfc (diff)
downloadjitsi-afd8c62ae92f579dbec9758ccadd9e113c7b3843.zip
jitsi-afd8c62ae92f579dbec9758ccadd9e113c7b3843.tar.gz
jitsi-afd8c62ae92f579dbec9758ccadd9e113c7b3843.tar.bz2
Committing code optimization patch from Lubomir Marinov
Diffstat (limited to 'src/net')
-rw-r--r--src/net/java/sip/communicator/impl/protocol/dict/DictAccountID.java5
-rw-r--r--src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderServiceDictImpl.java95
-rw-r--r--src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolProviderServiceGibberishImpl.java95
-rw-r--r--src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java67
-rw-r--r--src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java99
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java96
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java79
-rw-r--r--src/net/java/sip/communicator/impl/protocol/rss/ProtocolProviderServiceRssImpl.java95
-rw-r--r--src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java91
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderServiceSSHImpl.java97
-rw-r--r--src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderServiceYahooImpl.java79
-rw-r--r--src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolProviderServiceZeroconfImpl.java95
-rw-r--r--src/net/java/sip/communicator/service/protocol/AbstractProtocolProviderService.java123
-rw-r--r--src/net/java/sip/communicator/service/protocol/AccountID.java41
14 files changed, 183 insertions, 974 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/dict/DictAccountID.java b/src/net/java/sip/communicator/impl/protocol/dict/DictAccountID.java
index bf7d95e..861ee86 100644
--- a/src/net/java/sip/communicator/impl/protocol/dict/DictAccountID.java
+++ b/src/net/java/sip/communicator/impl/protocol/dict/DictAccountID.java
@@ -25,9 +25,6 @@ public class DictAccountID
*/
DictAccountID(String userID, Map accountProperties)
{
- super( userID,
- accountProperties,
- "Dict",
- "dict.org");
+ super(userID, accountProperties, ProtocolNames.DICT, "dict.org");
}
}
diff --git a/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderServiceDictImpl.java b/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderServiceDictImpl.java
index 898baad..97dc631 100644
--- a/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderServiceDictImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderServiceDictImpl.java
@@ -22,7 +22,7 @@ import org.osgi.framework.*;
* @author LITZELMANN Cedric
*/
public class ProtocolProviderServiceDictImpl
- implements ProtocolProviderService
+ extends AbstractProtocolProviderService
{
private static final Logger logger
= Logger.getLogger(ProtocolProviderServiceDictImpl.class);
@@ -48,11 +48,6 @@ public class ProtocolProviderServiceDictImpl
private Hashtable supportedOperationSets = new Hashtable();
/**
- * A list of listeners interested in changes in our registration state.
- */
- private Vector registrationStateListeners = new Vector();
-
- /**
* Indicates whether or not the provider is initialized and ready for use.
*/
private boolean isInitialized = false;
@@ -138,82 +133,6 @@ public class ProtocolProviderServiceDictImpl
}
/**
- * Registers the specified listener with this provider so that it would
- * receive notifications on changes of its state or other properties such
- * as its local address and display name.
- *
- * @param listener the listener to register.
- */
- public void addRegistrationStateChangeListener(
- RegistrationStateChangeListener listener)
- {
- synchronized(registrationStateListeners)
- {
- if (!registrationStateListeners.contains(listener))
- registrationStateListeners.add(listener);
- }
-
- }
-
- /**
- * Removes the specified registration listener so that it won't receive
- * further notifications when our registration state changes.
- *
- * @param listener the listener to remove.
- */
- public void removeRegistrationStateChangeListener(
- RegistrationStateChangeListener listener)
- {
- synchronized(registrationStateListeners)
- {
- registrationStateListeners.remove(listener);
- }
- }
-
- /**
- * Creates a <tt>RegistrationStateChangeEvent</tt> corresponding to the
- * specified old and new states and notifies all currently registered
- * listeners.
- *
- * @param oldState the state that the provider had before the change
- * occurred
- * @param newState the state that the provider is currently in.
- * @param reasonCode a value corresponding to one of the REASON_XXX fields
- * of the RegistrationStateChangeEvent class, indicating the reason for
- * this state transition.
- * @param reason a String further explaining the reason code or null if
- * no such explanation is necessary.
- */
- private void fireRegistrationStateChanged( RegistrationState oldState,
- RegistrationState newState,
- int reasonCode,
- String reason)
- {
- RegistrationStateChangeEvent event =
- new RegistrationStateChangeEvent(
- this, oldState, newState, reasonCode, reason);
-
- logger.debug("Dispatching " + event + " to "
- + registrationStateListeners.size()+ " listeners.");
-
- Iterator listeners = null;
- synchronized (registrationStateListeners)
- {
- listeners = new ArrayList(registrationStateListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- RegistrationStateChangeListener listener
- = (RegistrationStateChangeListener) listeners.next();
-
- listener.registrationStateChanged(event);
- }
-
- logger.trace("Done.");
- }
-
- /**
* Retrieve the DictAdapter linked with the account. If there is no instance, one is created
* @return a DictAdapter instance
*/
@@ -314,18 +233,6 @@ public class ProtocolProviderServiceDictImpl
}
/**
- * Returns the protocol display name. This is the name that would be used
- * by the GUI to display the protocol name.
- *
- * @return a String containing the display name of the protocol this service
- * is implementing
- */
- public String getProtocolDisplayName()
- {
- return DICT_PROTOCOL_NAME;
- }
-
- /**
* Returns the dict protocol icon.
* @return the dict protocol icon
*/
diff --git a/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolProviderServiceGibberishImpl.java b/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolProviderServiceGibberishImpl.java
index f910b55..8b8ccc7 100644
--- a/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolProviderServiceGibberishImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolProviderServiceGibberishImpl.java
@@ -18,7 +18,7 @@ import net.java.sip.communicator.util.*;
* @author Emil Ivov
*/
public class ProtocolProviderServiceGibberishImpl
- implements ProtocolProviderService
+ extends AbstractProtocolProviderService
{
private static final Logger logger
= Logger.getLogger(ProtocolProviderServiceGibberishImpl.class);
@@ -44,11 +44,6 @@ public class ProtocolProviderServiceGibberishImpl
private Hashtable supportedOperationSets = new Hashtable();
/**
- * A list of listeners interested in changes in our registration state.
- */
- private Vector registrationStateListeners = new Vector();
-
- /**
* Indicates whether or not the provider is initialized and ready for use.
*/
private boolean isInitialized = false;
@@ -135,83 +130,6 @@ public class ProtocolProviderServiceGibberishImpl
}
/**
- * Registers the specified listener with this provider so that it would
- * receive notifications on changes of its state or other properties such
- * as its local address and display name.
- *
- * @param listener the listener to register.
- */
- public void addRegistrationStateChangeListener(
- RegistrationStateChangeListener listener)
- {
- synchronized(registrationStateListeners)
- {
- if (!registrationStateListeners.contains(listener))
- registrationStateListeners.add(listener);
- }
-
- }
-
- /**
- * Removes the specified registration listener so that it won't receive
- * further notifications when our registration state changes.
- *
- * @param listener the listener to remove.
- */
- public void removeRegistrationStateChangeListener(
- RegistrationStateChangeListener listener)
- {
- synchronized(registrationStateListeners)
- {
- registrationStateListeners.remove(listener);
- }
- }
-
- /**
- * Creates a <tt>RegistrationStateChangeEvent</tt> corresponding to the
- * specified old and new states and notifies all currently registered
- * listeners.
- *
- * @param oldState the state that the provider had before the change
- * occurred
- * @param newState the state that the provider is currently in.
- * @param reasonCode a value corresponding to one of the REASON_XXX fields
- * of the RegistrationStateChangeEvent class, indicating the reason for
- * this state transition.
- * @param reason a String further explaining the reason code or null if
- * no such explanation is necessary.
- */
- private void fireRegistrationStateChanged( RegistrationState oldState,
- RegistrationState newState,
- int reasonCode,
- String reason)
- {
- RegistrationStateChangeEvent event =
- new RegistrationStateChangeEvent(
- this, oldState, newState, reasonCode, reason);
-
- logger.debug("Dispatching " + event + " to "
- + registrationStateListeners.size()+ " listeners.");
-
- Iterator listeners = null;
- synchronized (registrationStateListeners)
- {
- listeners = new ArrayList(registrationStateListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- RegistrationStateChangeListener listener
- = (RegistrationStateChangeListener) listeners.next();
-
- listener.registrationStateChanged(event);
- }
-
- logger.trace("Done.");
- }
-
-
- /**
* Returns the AccountID that uniquely identifies the account represented
* by this instance of the ProtocolProviderService.
*
@@ -250,17 +168,6 @@ public class ProtocolProviderServiceGibberishImpl
{
return GIBBERISH_PROTOCOL_NAME;
}
- /**
- * Returns the protocol display name. This is the name that would be used
- * by the GUI to display the protocol name.
- *
- * @return a String containing the display name of the protocol this service
- * is implementing
- */
- public String getProtocolDisplayName()
- {
- return GIBBERISH_PROTOCOL_NAME;
- }
/**
* Returns the state of the registration of this protocol provider with
diff --git a/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java
index c0be2cb..df19848 100644
--- a/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java
@@ -28,7 +28,7 @@ import net.kano.joustsim.oscar.proxy.*;
* @author Damian Minkov
*/
public class ProtocolProviderServiceIcqImpl
- implements ProtocolProviderService
+ extends AbstractProtocolProviderService
{
private static final Logger logger =
Logger.getLogger(ProtocolProviderServiceIcqImpl.class);
@@ -69,12 +69,6 @@ public class ProtocolProviderServiceIcqImpl
private Object initializationLock = new Object();
/**
- * A list of all listeners registered for
- * <tt>RegistrationStateChangeEvent</tt>s.
- */
- private List registrationListeners = new ArrayList();
-
- /**
* The identifier of the account that this provider represents.
*/
private AccountID accountID = null;
@@ -602,40 +596,6 @@ public class ProtocolProviderServiceIcqImpl
}
/**
- * Removes the specified registration state change listener so that it does
- * not receive any further notifications upon changes of the
- * RegistrationState of this provider.
- *
- * @param listener the listener to register for
- * <tt>RegistrationStateChangeEvent</tt>s.
- */
- public void removeRegistrationStateChangeListener(
- RegistrationStateChangeListener listener)
- {
- synchronized(registrationListeners)
- {
- registrationListeners.remove(listener);
- }
- }
-
- /**
- * Registers the specified listener with this provider so that it would
- * receive notifications on changes of its state or other properties such
- * as its local address and display name.
- *
- * @param listener the listener to register.
- */
- public void addRegistrationStateChangeListener(
- RegistrationStateChangeListener listener)
- {
- synchronized(registrationListeners)
- {
- if (!registrationListeners.contains(listener))
- registrationListeners.add(listener);
- }
- }
-
- /**
* Returns the AccountID that uniquely identifies the account represented
* by this instance of the ProtocolProviderService.
* @return the id of the account represented by this provider.
@@ -696,15 +656,11 @@ public class ProtocolProviderServiceIcqImpl
* @param reason a String further explaining the reason code or null if
* no such explanation is necessary.
*/
- void fireRegistrationStateChanged( RegistrationState oldState,
+ public void fireRegistrationStateChanged( RegistrationState oldState,
RegistrationState newState,
int reasonCode,
String reason)
{
- RegistrationStateChangeEvent event =
- new RegistrationStateChangeEvent(
- this, oldState, newState, reasonCode, reason);
-
if(newState.equals(RegistrationState.CONNECTION_FAILED) &&
isRegistered())
{
@@ -713,24 +669,7 @@ public class ProtocolProviderServiceIcqImpl
unregister();
}
- logger.debug("Dispatching " + event + " to "
- + registrationListeners.size()+ " listeners.");
-
- Iterator listeners = null;
- synchronized (registrationListeners)
- {
- listeners = new ArrayList(registrationListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- RegistrationStateChangeListener listener
- = (RegistrationStateChangeListener) listeners.next();
-
- listener.registrationStateChanged(event);
- }
-
- logger.trace("Done.");
+ super.fireRegistrationStateChanged(oldState, newState, reasonCode, reason);
}
/**
diff --git a/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java b/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java
index 3ddad20..5dda889 100644
--- a/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java
@@ -19,7 +19,7 @@ import net.java.sip.communicator.util.*;
* @author Stephane Remy
*/
public class ProtocolProviderServiceIrcImpl
- implements ProtocolProviderService
+ extends AbstractProtocolProviderService
{
private static final Logger logger
= Logger.getLogger(ProtocolProviderServiceIrcImpl.class);
@@ -50,11 +50,6 @@ public class ProtocolProviderServiceIrcImpl
private OperationSetMultiUserChatIrcImpl multiUserChat;
/**
- * A list of listeners interested in changes in our registration state.
- */
- private Vector registrationStateListeners = new Vector();
-
- /**
* Indicates whether or not the provider is initialized and ready for use.
*/
private boolean isInitialized = false;
@@ -114,86 +109,6 @@ public class ProtocolProviderServiceIrcImpl
}
/**
- * Registers the specified listener with this provider so that it would
- * receive notifications on changes of its state or other properties such
- * as its local address and display name.
- *
- * @param listener the listener to register.
- */
- public void addRegistrationStateChangeListener(
- RegistrationStateChangeListener listener)
- {
- synchronized(registrationStateListeners)
- {
- if (!registrationStateListeners.contains(listener))
- registrationStateListeners.add(listener);
- }
-
- }
-
- /**
- * Removes the specified registration listener so that it won't receive
- * further notifications when our registration state changes.
- *
- * @param listener the listener to remove.
- */
- public void removeRegistrationStateChangeListener(
- RegistrationStateChangeListener listener)
- {
- synchronized(registrationStateListeners)
- {
- registrationStateListeners.remove(listener);
- }
- }
-
- /**
- * Creates a <tt>RegistrationStateChangeEvent</tt> corresponding to the
- * specified old and new states and notifies all currently registered
- * listeners.
- *
- * @param oldState the state that the provider had before the change
- * occurred
- * @param newState the state that the provider is currently in.
- * @param reasonCode a value corresponding to one of the REASON_XXX fields
- * of the RegistrationStateChangeEvent class, indicating the reason for
- * this state transition.
- * @param reason a String further explaining the reason code or null if
- * no such explanation is necessary.
- */
- protected void fireRegistrationStateChanged(RegistrationState oldState,
- RegistrationState newState,
- int reasonCode,
- String reason)
- {
- RegistrationStateChangeEvent event =
- new RegistrationStateChangeEvent( this,
- oldState,
- newState,
- reasonCode,
- reason);
-
- logger.debug("Dispatching " + event + " to "
- + registrationStateListeners.size()+ " listeners.");
-
- Iterator listeners = null;
- synchronized (registrationStateListeners)
- {
- listeners = new ArrayList(registrationStateListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- RegistrationStateChangeListener listener
- = (RegistrationStateChangeListener) listeners.next();
-
- listener.registrationStateChanged(event);
- }
-
- logger.trace("Done.");
- }
-
-
- /**
* Returns the AccountID that uniquely identifies the account represented
* by this instance of the ProtocolProviderService.
*
@@ -234,18 +149,6 @@ public class ProtocolProviderServiceIrcImpl
}
/**
- * Returns the protocol display name. This is the name that would be used
- * by the GUI to display the protocol name.
- *
- * @return a String containing the display name of the protocol this service
- * is implementing
- */
- public String getProtocolDisplayName()
- {
- return ProtocolNames.IRC;
- }
-
- /**
* Returns the state of the registration of this protocol provider with
* the corresponding registration service.
*
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java
index 7d71a6f..149abe8 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java
@@ -26,7 +26,7 @@ import org.jivesoftware.smackx.*;
* @author Symphorien Wanko
*/
public class ProtocolProviderServiceJabberImpl
- implements ProtocolProviderService
+ extends AbstractProtocolProviderService
{
/**
* Logger of this class
@@ -55,12 +55,6 @@ public class ProtocolProviderServiceJabberImpl
private Object initializationLock = new Object();
/**
- * A list of all listeners registered for
- * <tt>RegistrationStateChangeEvent</tt>s.
- */
- private List registrationListeners = new ArrayList();
-
- /**
* The identifier of the account that this provider represents.
*/
private AccountID accountID = null;
@@ -469,18 +463,6 @@ public class ProtocolProviderServiceJabberImpl
}
/**
- * Returns the protocol display name. This is the name that would be used
- * by the GUI to display the protocol name.
- *
- * @return a String containing the display name of the protocol this service
- * is implementing
- */
- public String getProtocolDisplayName()
- {
- return ProtocolNames.JABBER;
- }
-
- /**
* Returns an array containing all operation sets supported by the
* current implementation.
*
@@ -681,40 +663,6 @@ public class ProtocolProviderServiceJabberImpl
}
/**
- * Removes the specified registration state change listener so that it does
- * not receive any further notifications upon changes of the
- * RegistrationState of this provider.
- *
- * @param listener the listener to register for
- * <tt>RegistrationStateChangeEvent</tt>s.
- */
- public void removeRegistrationStateChangeListener(
- RegistrationStateChangeListener listener)
- {
- synchronized(registrationListeners)
- {
- registrationListeners.remove(listener);
- }
- }
-
- /**
- * Registers the specified listener with this provider so that it would
- * receive notifications on changes of its state or other properties such
- * as its local address and display name.
- *
- * @param listener the listener to register.
- */
- public void addRegistrationStateChangeListener(
- RegistrationStateChangeListener listener)
- {
- synchronized(registrationListeners)
- {
- if (!registrationListeners.contains(listener))
- registrationListeners.add(listener);
- }
- }
-
- /**
* Returns the AccountID that uniquely identifies the account represented
* by this instance of the ProtocolProviderService.
* @return the id of the account represented by this provider.
@@ -735,48 +683,6 @@ public class ProtocolProviderServiceJabberImpl
}
/**
- * Creates a RegistrationStateChange event corresponding to the specified
- * old and new states and notifies all currently registered listeners.
- *
- * @param oldState the state that the provider had before the change
- * occurred
- * @param newState the state that the provider is currently in.
- * @param reasonCode a value corresponding to one of the REASON_XXX fields
- * of the RegistrationStateChangeEvent class, indicating the reason for
- * this state transition.
- * @param reason a String further explaining the reason code or null if
- * no such explanation is necessary.
- */
- void fireRegistrationStateChanged( RegistrationState oldState,
- RegistrationState newState,
- int reasonCode,
- String reason)
- {
- RegistrationStateChangeEvent event =
- new RegistrationStateChangeEvent(
- this, oldState, newState, reasonCode, reason);
-
- logger.debug("Dispatching " + event + " to "
- + registrationListeners.size()+ " listeners.");
-
- Iterator listeners = null;
- synchronized (registrationListeners)
- {
- listeners = new ArrayList(registrationListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- RegistrationStateChangeListener listener
- = (RegistrationStateChangeListener) listeners.next();
-
- listener.registrationStateChanged(event);
- }
-
- logger.trace("Done.");
- }
-
- /**
* Enable to listen for jabber connection events
*/
private class JabberConnectionListener
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java
index f2edd0d..904ffba 100644
--- a/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java
@@ -26,7 +26,7 @@ import net.sf.jml.impl.*;
* @author Damian Minkov
*/
public class ProtocolProviderServiceMsnImpl
- implements ProtocolProviderService
+ extends AbstractProtocolProviderService
{
private static final Logger logger =
Logger.getLogger(ProtocolProviderServiceMsnImpl.class);
@@ -49,12 +49,6 @@ public class ProtocolProviderServiceMsnImpl
private Object initializationLock = new Object();
/**
- * A list of all listeners registered for
- * <tt>RegistrationStateChangeEvent</tt>s.
- */
- private List registrationListeners = new ArrayList();
-
- /**
* The identifier of the account that this provider represents.
*/
private AccountID accountID = null;
@@ -266,18 +260,6 @@ public class ProtocolProviderServiceMsnImpl
}
/**
- * Returns the protocol display name. This is the name that would be used
- * by the GUI to display the protocol name.
- *
- * @return a String containing the display name of the protocol this service
- * is implementing
- */
- public String getProtocolDisplayName()
- {
- return ProtocolNames.MSN;
- }
-
- /**
* Returns an array containing all operation sets supported by the
* current implementation.
*
@@ -382,40 +364,6 @@ public class ProtocolProviderServiceMsnImpl
}
/**
- * Removes the specified registration state change listener so that it does
- * not receive any further notifications upon changes of the
- * RegistrationState of this provider.
- *
- * @param listener the listener to register for
- * <tt>RegistrationStateChangeEvent</tt>s.
- */
- public void removeRegistrationStateChangeListener(
- RegistrationStateChangeListener listener)
- {
- synchronized(registrationListeners)
- {
- registrationListeners.remove(listener);
- }
- }
-
- /**
- * Registers the specified listener with this provider so that it would
- * receive notifications on changes of its state or other properties such
- * as its local address and display name.
- *
- * @param listener the listener to register.
- */
- public void addRegistrationStateChangeListener(
- RegistrationStateChangeListener listener)
- {
- synchronized(registrationListeners)
- {
- if (!registrationListeners.contains(listener))
- registrationListeners.add(listener);
- }
- }
-
- /**
* Returns the AccountID that uniquely identifies the account represented
* by this instance of the ProtocolProviderService.
* @return the id of the account represented by this provider.
@@ -448,37 +396,16 @@ public class ProtocolProviderServiceMsnImpl
* @param reason a String further explaining the reason code or null if
* no such explanation is necessary.
*/
- void fireRegistrationStateChanged( RegistrationState oldState,
+ public void fireRegistrationStateChanged( RegistrationState oldState,
RegistrationState newState,
int reasonCode,
String reason)
{
- RegistrationStateChangeEvent event =
- new RegistrationStateChangeEvent(
- this, oldState, newState, reasonCode, reason);
-
- logger.debug("Dispatching " + event + " to "
- + registrationListeners.size()+ " listeners.");
-
if(newState.equals(RegistrationState.UNREGISTERED) ||
newState.equals(RegistrationState.CONNECTION_FAILED))
messenger = null;
- Iterator listeners = null;
- synchronized (registrationListeners)
- {
- listeners = new ArrayList(registrationListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- RegistrationStateChangeListener listener
- = (RegistrationStateChangeListener) listeners.next();
-
- listener.registrationStateChanged(event);
- }
-
- logger.trace("Done.");
+ super.fireRegistrationStateChanged(oldState, newState, reasonCode, reason);
}
/**
diff --git a/src/net/java/sip/communicator/impl/protocol/rss/ProtocolProviderServiceRssImpl.java b/src/net/java/sip/communicator/impl/protocol/rss/ProtocolProviderServiceRssImpl.java
index 44d17de..5642d07 100644
--- a/src/net/java/sip/communicator/impl/protocol/rss/ProtocolProviderServiceRssImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/rss/ProtocolProviderServiceRssImpl.java
@@ -19,7 +19,7 @@ import net.java.sip.communicator.util.*;
* @author Emil Ivov
*/
public class ProtocolProviderServiceRssImpl
- implements ProtocolProviderService
+ extends AbstractProtocolProviderService
{
private static final Logger logger
= Logger.getLogger(ProtocolProviderServiceRssImpl.class);
@@ -45,11 +45,6 @@ public class ProtocolProviderServiceRssImpl
private Hashtable supportedOperationSets = new Hashtable();
/**
- * A list of listeners interested in changes in our registration state.
- */
- private Vector registrationStateListeners = new Vector();
-
- /**
* Indicates whether or not the provider is initialized and ready for use.
*/
private boolean isInitialized = false;
@@ -135,82 +130,6 @@ public class ProtocolProviderServiceRssImpl
}
/**
- * Registers the specified listener with this provider so that it would
- * receive notifications on changes of its state or other properties such
- * as its local address and display name.
- *
- * @param listener the listener to register.
- */
- public void addRegistrationStateChangeListener(
- RegistrationStateChangeListener listener)
- {
- synchronized(registrationStateListeners)
- {
- if (!registrationStateListeners.contains(listener))
- registrationStateListeners.add(listener);
- }
-
- }
-
- /**
- * Removes the specified registration listener so that it won't receive
- * further notifications when our registration state changes.
- *
- * @param listener the listener to remove.
- */
- public void removeRegistrationStateChangeListener(
- RegistrationStateChangeListener listener)
- {
- synchronized(registrationStateListeners)
- {
- registrationStateListeners.remove(listener);
- }
- }
-
- /**
- * Creates a <tt>RegistrationStateChangeEvent</tt> corresponding to the
- * specified old and new states and notifies all currently registered
- * listeners.
- *
- * @param oldState the state that the provider had before the change
- * occurred
- * @param newState the state that the provider is currently in.
- * @param reasonCode a value corresponding to one of the REASON_XXX fields
- * of the RegistrationStateChangeEvent class, indicating the reason for
- * this state transition.
- * @param reason a String further explaining the reason code or null if
- * no such explanation is necessary.
- */
- private void fireRegistrationStateChanged( RegistrationState oldState,
- RegistrationState newState,
- int reasonCode,
- String reason)
- {
- RegistrationStateChangeEvent event =
- new RegistrationStateChangeEvent(
- this, oldState, newState, reasonCode, reason);
-
- logger.debug("Dispatching " + event + " to "
- + registrationStateListeners.size()+ " listeners.");
-
- Iterator listeners = null;
- synchronized (registrationStateListeners)
- {
- listeners = new ArrayList(registrationStateListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- RegistrationStateChangeListener listener
- = (RegistrationStateChangeListener) listeners.next();
-
- listener.registrationStateChanged(event);
- }
- logger.trace("Done.");
- }
-
-
- /**
* Returns the AccountID that uniquely identifies the account represented
* by this instance of the ProtocolProviderService.
*
@@ -251,18 +170,6 @@ public class ProtocolProviderServiceRssImpl
}
/**
- * Returns the protocol display name. This is the name that would be used
- * by the GUI to display the protocol name.
- *
- * @return a String containing the display name of the protocol this service
- * is implementing
- */
- public String getProtocolDisplayName()
- {
- return RSS_PROTOCOL_NAME;
- }
-
- /**
* Returns the state of the registration of this protocol provider with
* the corresponding registration service.
*
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java
index cb5c200..b15c81c 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java
@@ -30,7 +30,8 @@ import net.java.sip.communicator.impl.protocol.sip.security.*;
* @author Emil Ivov
*/
public class ProtocolProviderServiceSipImpl
- implements ProtocolProviderService, SipListener
+ extends AbstractProtocolProviderService
+ implements SipListener
{
private static final Logger logger =
Logger.getLogger(ProtocolProviderServiceSipImpl.class);
@@ -56,12 +57,6 @@ public class ProtocolProviderServiceSipImpl
private boolean isInitialized = false;
/**
- * A list of all listeners registered for
- * <tt>RegistrationStateChangeEvent</tt>s.
- */
- private List registrationListeners = new ArrayList();
-
- /**
* A list of all events registered for this provider.
*/
private List registeredEvents = new ArrayList();
@@ -317,62 +312,6 @@ public class ProtocolProviderServiceSipImpl
private SipStatusEnum sipStatusEnum;
/**
- * Registers the specified listener with this provider so that it would
- * receive notifications on changes of its state or other properties such
- * as its local address and display name.
- * @param listener the listener to register.
- */
- public void addRegistrationStateChangeListener(
- RegistrationStateChangeListener listener)
- {
- synchronized(registrationListeners)
- {
- if (!registrationListeners.contains(listener))
- registrationListeners.add(listener);
- }
- }
-
- /**
- * Creates a RegistrationStateChange event corresponding to the specified
- * old and new jain sip states and notifies all currently registered
- * listeners.
- * <p>
- * @param oldState the state that we had before this transition occurred.
- * @param newState the state that we have now after the transition has
- * occurred
- * @param reasonCode a code indicating the reason for the event.
- * @param reason a text explaining the reason for the event.
- */
- public void fireRegistrationStateChanged( RegistrationState oldState,
- RegistrationState newState,
- int reasonCode,
- String reason )
- {
- RegistrationStateChangeEvent event
- = new RegistrationStateChangeEvent(
- this, oldState, newState, reasonCode, reason);
-
- logger.debug("Dispatching " + event + " to "
- + registrationListeners.size()+ " listeners.");
-
- Iterator listeners = null;
- synchronized (registrationListeners)
- {
- listeners = new ArrayList(registrationListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- RegistrationStateChangeListener listener
- = (RegistrationStateChangeListener) listeners.next();
-
- listener.registrationStateChanged(event);
- }
-
- logger.trace("Done.");
- }
-
- /**
* Returns the AccountID that uniquely identifies the account represented by
* this instance of the ProtocolProviderService.
* @return the id of the account represented by this provider.
@@ -411,19 +350,6 @@ public class ProtocolProviderServiceSipImpl
}
/**
- * Returns the protocol display name. This is the name that would be used
- * by the GUI to display the protocol name.
- *
- * @return a String containing the display name of the protocol this service
- * is implementing
- */
- public String getProtocolDisplayName()
- {
- return (String) accountID.getAccountProperties()
- .get(ProtocolProviderFactory.PROTOCOL);
- }
-
- /**
* Register a new event taken in account by this provider. This is usefull
* to generate the Allow-Events header of the OPTIONS responses and to
* generate 489 responses.
@@ -462,19 +388,6 @@ public class ProtocolProviderServiceSipImpl
}
/**
- * Removes the specified listener.
- * @param listener the listener to remove.
- */
- public void removeRegistrationStateChangeListener(
- RegistrationStateChangeListener listener)
- {
- synchronized(registrationListeners)
- {
- this.registrationListeners.remove(listener);
- }
- }
-
- /**
* Returns an array containing all operation sets supported by the current
* implementation. When querying this method users must be prepared to
* receive any sybset of the OperationSet-s defined by this service. They
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderServiceSSHImpl.java b/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderServiceSSHImpl.java
index d248ded..e8a17b9 100644
--- a/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderServiceSSHImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderServiceSSHImpl.java
@@ -29,7 +29,7 @@ import net.java.sip.communicator.service.gui.*;
* @author Shobhit Jindal
*/
public class ProtocolProviderServiceSSHImpl
- implements ProtocolProviderService
+ extends AbstractProtocolProviderService
{
private static final Logger logger
= Logger.getLogger(ProtocolProviderServiceSSHImpl.class);
@@ -86,11 +86,6 @@ public class ProtocolProviderServiceSSHImpl
private OperationSetFileTransferSSHImpl fileTranfer;
/**
- * A list of listeners interested in changes in our registration state.
- */
- private Vector registrationStateListeners = new Vector();
-
- /**
* Indicates whether or not the provider is initialized and ready for use.
*/
private boolean isInitialized = false;
@@ -508,84 +503,6 @@ public class ProtocolProviderServiceSSHImpl
}
/**
- * Registers the specified listener with this provider so that it would
- * receive notifications on changes of its state or other properties such
- * as its local address and display name.
- *
- * @param listener the listener to register.
- */
- public void addRegistrationStateChangeListener(
- RegistrationStateChangeListener listener)
- {
- synchronized(registrationStateListeners)
- {
- if (!registrationStateListeners.contains(listener))
- registrationStateListeners.add(listener);
- }
-
- }
-
- /**
- * Removes the specified registration listener so that it won't receive
- * further notifications when our registration state changes.
- *
- * @param listener the listener to remove.
- */
- public void removeRegistrationStateChangeListener(
- RegistrationStateChangeListener listener)
- {
- synchronized(registrationStateListeners)
- {
- registrationStateListeners.remove(listener);
- }
- }
-
- /**
- * Creates a <tt>RegistrationStateChangeEvent</tt> corresponding to the
- * specified old and new states and notifies all currently registered
- * listeners.
- *
- * @param oldState the state that the provider had before the change
- * occurred
- * @param newState the state that the provider is currently in.
- * @param reasonCode a value corresponding to one of the REASON_XXX fields
- * of the RegistrationStateChangeEvent class, indicating the reason for
- * this state transition.
- * @param reason a String further explaining the reason code or null if
- * no such explanation is necessary.
- */
- private void fireRegistrationStateChanged(
- RegistrationState oldState,
- RegistrationState newState,
- int reasonCode,
- String reason)
- {
- RegistrationStateChangeEvent event =
- new RegistrationStateChangeEvent(
- this, oldState, newState, reasonCode, reason);
-
- logger.debug("Dispatching " + event + " to "
- + registrationStateListeners.size()+ " listeners.");
-
- Iterator listeners = null;
- synchronized (registrationStateListeners)
- {
- listeners = new ArrayList(registrationStateListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- RegistrationStateChangeListener listener
- = (RegistrationStateChangeListener) listeners.next();
-
- listener.registrationStateChanged(event);
- }
-
- logger.trace("Done.");
- }
-
-
- /**
* Returns the AccountID that uniquely identifies the account represented
* by this instance of the ProtocolProviderService.
*
@@ -626,18 +543,6 @@ public class ProtocolProviderServiceSSHImpl
}
/**
- * Returns the protocol display name. This is the name that would be used
- * by the GUI to display the protocol name.
- *
- * @return a String containing the display name of the protocol this service
- * is implementing
- */
- public String getProtocolDisplayName()
- {
- return SSH_PROTOCOL_NAME;
- }
-
- /**
* Returns the state of the registration of this protocol provider with
* the corresponding registration service.
*
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderServiceYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderServiceYahooImpl.java
index e1661f1..004752c 100644
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderServiceYahooImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderServiceYahooImpl.java
@@ -24,7 +24,7 @@ import ymsg.network.event.*;
* @author Damian Minkov
*/
public class ProtocolProviderServiceYahooImpl
- implements ProtocolProviderService
+ extends AbstractProtocolProviderService
{
private static final Logger logger =
Logger.getLogger(ProtocolProviderServiceYahooImpl.class);
@@ -47,12 +47,6 @@ public class ProtocolProviderServiceYahooImpl
private Object initializationLock = new Object();
/**
- * A list of all listeners registered for
- * <tt>RegistrationStateChangeEvent</tt>s.
- */
- private List registrationListeners = new ArrayList();
-
- /**
* The identifier of the account that this provider represents.
*/
private AccountID accountID = null;
@@ -295,18 +289,6 @@ public class ProtocolProviderServiceYahooImpl
}
/**
- * Returns the protocol display name. This is the name that would be used
- * by the GUI to display the protocol name.
- *
- * @return a String containing the display name of the protocol this service
- * is implementing
- */
- public String getProtocolDisplayName()
- {
- return ProtocolNames.YAHOO;
- }
-
- /**
* Returns an array containing all operation sets supported by the
* current implementation.
*
@@ -411,40 +393,6 @@ public class ProtocolProviderServiceYahooImpl
}
/**
- * Removes the specified registration state change listener so that it does
- * not receive any further notifications upon changes of the
- * RegistrationState of this provider.
- *
- * @param listener the listener to register for
- * <tt>RegistrationStateChangeEvent</tt>s.
- */
- public void removeRegistrationStateChangeListener(
- RegistrationStateChangeListener listener)
- {
- synchronized(registrationListeners)
- {
- registrationListeners.remove(listener);
- }
- }
-
- /**
- * Registers the specified listener with this provider so that it would
- * receive notifications on changes of its state or other properties such
- * as its local address and display name.
- *
- * @param listener the listener to register.
- */
- public void addRegistrationStateChangeListener(
- RegistrationStateChangeListener listener)
- {
- synchronized(registrationListeners)
- {
- if (!registrationListeners.contains(listener))
- registrationListeners.add(listener);
- }
- }
-
- /**
* Returns the AccountID that uniquely identifies the account represented
* by this instance of the ProtocolProviderService.
* @return the id of the account represented by this provider.
@@ -477,18 +425,11 @@ public class ProtocolProviderServiceYahooImpl
* @param reason a String further explaining the reason code or null if
* no such explanation is necessary.
*/
- void fireRegistrationStateChanged( RegistrationState oldState,
+ public void fireRegistrationStateChanged( RegistrationState oldState,
RegistrationState newState,
int reasonCode,
String reason)
{
- RegistrationStateChangeEvent event =
- new RegistrationStateChangeEvent(
- this, oldState, newState, reasonCode, reason);
-
- logger.debug("Dispatching " + event + " to "
- + registrationListeners.size()+ " listeners.");
-
if(newState.equals(RegistrationState.UNREGISTERED) ||
newState.equals(RegistrationState.CONNECTION_FAILED))
{
@@ -496,21 +437,7 @@ public class ProtocolProviderServiceYahooImpl
yahooSession = null;
}
- Iterator listeners = null;
- synchronized (registrationListeners)
- {
- listeners = new ArrayList(registrationListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- RegistrationStateChangeListener listener
- = (RegistrationStateChangeListener) listeners.next();
-
- listener.registrationStateChanged(event);
- }
-
- logger.trace("Done.");
+ super.fireRegistrationStateChanged(oldState, newState, reasonCode, reason);
}
/**
diff --git a/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolProviderServiceZeroconfImpl.java b/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolProviderServiceZeroconfImpl.java
index 99f3197..78af46e 100644
--- a/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolProviderServiceZeroconfImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolProviderServiceZeroconfImpl.java
@@ -19,7 +19,7 @@ import net.java.sip.communicator.util.*;
* @author Maxime Catelin
*/
public class ProtocolProviderServiceZeroconfImpl
- implements ProtocolProviderService
+ extends AbstractProtocolProviderService
{
private static final Logger logger =
Logger.getLogger(ProtocolProviderServiceZeroconfImpl.class);
@@ -30,12 +30,6 @@ public class ProtocolProviderServiceZeroconfImpl
private Hashtable supportedOperationSets = new Hashtable();
/**
- * A list of all listeners registered for
- * <tt>RegistrationStateChangeEvent</tt>s.
- */
- private Vector registrationStateListeners = new Vector();
-
- /**
* We use this to lock access to initialization.
*/
private Object initializationLock = new Object();
@@ -173,81 +167,6 @@ public class ProtocolProviderServiceZeroconfImpl
return (OperationSet) getSupportedOperationSets()
.get(opsetClass.getName());
}
-
- /**
- * Registers the specified listener with this provider so that it would
- * receive notifications on changes of its state or other properties such
- * as its local address and display name.
- *
- * @param listener the listener to register.
- */
- public void addRegistrationStateChangeListener(
- RegistrationStateChangeListener listener)
- {
- synchronized(registrationStateListeners)
- {
- if (!registrationStateListeners.contains(listener))
- registrationStateListeners.add(listener);
- }
- }
-
- /**
- * Removes the specified registration listener so that it won't receive
- * further notifications when our registration state changes.
- *
- * @param listener the listener to remove.
- */
- public void removeRegistrationStateChangeListener(
- RegistrationStateChangeListener listener)
- {
- synchronized(registrationStateListeners)
- {
- registrationStateListeners.remove(listener);
- }
- }
-
- /**
- * Creates a <tt>RegistrationStateChangeEvent</tt> corresponding to the
- * specified old and new states and notifies all currently registered
- * listeners.
- *
- * @param oldState the state that the provider had before the change
- * occurred
- * @param newState the state that the provider is currently in.
- * @param reasonCode a value corresponding to one of the REASON_XXX fields
- * of the RegistrationStateChangeEvent class, indicating the reason for
- * this state transition.
- * @param reason a String further explaining the reason code or null if
- * no such explanation is necessary.
- */
- private void fireRegistrationStateChanged( RegistrationState oldState,
- RegistrationState newState,
- int reasonCode,
- String reason)
- {
- RegistrationStateChangeEvent event =
- new RegistrationStateChangeEvent(
- this, oldState, newState, reasonCode, reason);
-
- logger.debug("Dispatching " + event + " to "
- + registrationStateListeners.size()+ " listeners.");
-
- Iterator listeners = null;
- synchronized (registrationStateListeners)
- {
- listeners = new ArrayList(registrationStateListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- RegistrationStateChangeListener listener
- = (RegistrationStateChangeListener) listeners.next();
-
- listener.registrationStateChanged(event);
- }
-
- logger.trace("Done.");
- }
/**
* Returns the short name of the protocol that the implementation of this
@@ -264,18 +183,6 @@ public class ProtocolProviderServiceZeroconfImpl
}
/**
- * Returns the protocol display name. This is the name that would be used
- * by the GUI to display the protocol name.
- *
- * @return a String containing the display name of the protocol this service
- * is implementing
- */
- public String getProtocolDisplayName()
- {
- return ProtocolNames.ZEROCONF;
- }
-
- /**
* Returns the state of the registration of this protocol provider with
* the corresponding registration service.
*
diff --git a/src/net/java/sip/communicator/service/protocol/AbstractProtocolProviderService.java b/src/net/java/sip/communicator/service/protocol/AbstractProtocolProviderService.java
new file mode 100644
index 0000000..800b537
--- /dev/null
+++ b/src/net/java/sip/communicator/service/protocol/AbstractProtocolProviderService.java
@@ -0,0 +1,123 @@
+/*
+ * 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.*;
+
+/**
+ * Implements "standard" functionality of <tt>ProtocolProviderService</code> in
+ * order to make it easier for implementers to provide complete solutions while
+ * focusing on protocol-specific details.
+ */
+public abstract class AbstractProtocolProviderService
+ implements ProtocolProviderService
+{
+ /**
+ * Logger of this class
+ */
+ private static final Logger logger =
+ Logger.getLogger(AbstractProtocolProviderService.class);
+
+ /**
+ * A list of all listeners registered for
+ * <tt>RegistrationStateChangeEvent</tt>s.
+ */
+ private final List registrationListeners = new ArrayList();
+
+ /**
+ * Registers the specified listener with this provider so that it would
+ * receive notifications on changes of its state or other properties such
+ * as its local address and display name.
+ *
+ * @param listener the listener to register.
+ */
+ public void addRegistrationStateChangeListener(
+ RegistrationStateChangeListener listener)
+ {
+ synchronized(registrationListeners)
+ {
+ if (!registrationListeners.contains(listener))
+ registrationListeners.add(listener);
+ }
+ }
+
+ /**
+ * Creates a RegistrationStateChange event corresponding to the specified
+ * old and new states and notifies all currently registered listeners.
+ *
+ * @param oldState the state that the provider had before the change
+ * occurred
+ * @param newState the state that the provider is currently in.
+ * @param reasonCode a value corresponding to one of the REASON_XXX fields
+ * of the RegistrationStateChangeEvent class, indicating the reason for
+ * this state transition.
+ * @param reason a String further explaining the reason code or null if
+ * no such explanation is necessary.
+ */
+ public void fireRegistrationStateChanged( RegistrationState oldState,
+ RegistrationState newState,
+ int reasonCode,
+ String reason)
+ {
+ RegistrationStateChangeEvent event =
+ new RegistrationStateChangeEvent(
+ this, oldState, newState, reasonCode, reason);
+
+ logger.debug("Dispatching " + event + " to "
+ + registrationListeners.size()+ " listeners.");
+
+ Iterator listeners = null;
+ synchronized (registrationListeners)
+ {
+ listeners = new ArrayList(registrationListeners).iterator();
+ }
+
+ while (listeners.hasNext())
+ {
+ RegistrationStateChangeListener listener
+ = (RegistrationStateChangeListener) listeners.next();
+
+ listener.registrationStateChanged(event);
+ }
+
+ logger.trace("Done.");
+ }
+
+ /**
+ * Returns the protocol display name. This is the name that would be used
+ * by the GUI to display the protocol name.
+ *
+ * @return a String containing the display name of the protocol this service
+ * is implementing
+ */
+ public String getProtocolDisplayName()
+ {
+ String displayName = (String) getAccountID().getAccountProperties()
+ .get(ProtocolProviderFactory.PROTOCOL);
+ return (displayName == null) ? getProtocolName() : displayName;
+ }
+
+ /**
+ * Removes the specified registration state change listener so that it does
+ * not receive any further notifications upon changes of the
+ * RegistrationState of this provider.
+ *
+ * @param listener the listener to register for
+ * <tt>RegistrationStateChangeEvent</tt>s.
+ */
+ public void removeRegistrationStateChangeListener(
+ RegistrationStateChangeListener listener)
+ {
+ synchronized(registrationListeners)
+ {
+ registrationListeners.remove(listener);
+ }
+ }
+}
diff --git a/src/net/java/sip/communicator/service/protocol/AccountID.java b/src/net/java/sip/communicator/service/protocol/AccountID.java
index 49c96e0..f1ba01e 100644
--- a/src/net/java/sip/communicator/service/protocol/AccountID.java
+++ b/src/net/java/sip/communicator/service/protocol/AccountID.java
@@ -32,6 +32,39 @@ import java.util.*;
public abstract class AccountID
{
/**
+ * Allows a specific set of account properties to override a given default
+ * protocol name (e.g. account registration wizards which want to present a
+ * well-known protocol name associated with the account that is different
+ * from the name of the effective protocol).
+ * <p>
+ * Note: The logic of the SIP protocol implementation at the time of this
+ * writing modifies <tt>accountProperties</tt> to contain the default
+ * protocol name if an override hasn't been defined. Since the desire is to
+ * enable all account registration wizards to override the protocol name,
+ * the current implementation places the specified
+ * <tt>defaultProtocolName</tt> in a similar fashion.
+ * </p>
+ *
+ * @param accountProperties a Map containing any other protocol and
+ * implementation specific account initialization properties
+ * @param defaultProtocolName the protocol name to be used in case
+ * <tt>accountProperties</tt> doesn't provide an overriding value
+ * @return
+ */
+ private static final String getOverriddenProtocolName(
+ Map accountProperties, String defaultProtocolName)
+ {
+ String key = ProtocolProviderFactory.PROTOCOL;
+ String protocolName = (String) accountProperties.get(key);
+ if ((protocolName == null) && (defaultProtocolName != null))
+ {
+ protocolName = defaultProtocolName;
+ accountProperties.put(key, protocolName);
+ }
+ return protocolName;
+ }
+
+ /**
* Contains all implementation specific properties that define the account.
* The exact names of the keys are protocol (and sometimes implementation)
* specific.
@@ -74,6 +107,14 @@ public abstract class AccountID
String serviceName)
{
super();
+
+ /*
+ * Allow account registration wizards to override the default protocol
+ * name through accountProperties for the purposes of presenting a
+ * well-known protocol name associated with the account that is
+ * different from the name of the effective protocol.
+ */
+ protocolName = getOverriddenProtocolName(accountProperties, protocolName);
this.userID = userID;
this.accountProperties = new Hashtable(accountProperties);