diff --git a/src/net/java/sip/communicator/impl/protocol/rss/OperationSetTypingNotificationsRssImpl.java b/src/net/java/sip/communicator/impl/protocol/rss/OperationSetTypingNotificationsRssImpl.java deleted file mode 100644 index 08f71ea4c..000000000 --- a/src/net/java/sip/communicator/impl/protocol/rss/OperationSetTypingNotificationsRssImpl.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * 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.impl.protocol.rss; - -import java.util.*; - -import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.protocol.event.*; -import net.java.sip.communicator.util.*; - -/** - * Implements typing notifications for the Rss protocol. The operation - * set would simply mirror all outgoing typing notifications and make them - * appear as incoming events generated by the contact that we are currently - * writing a message to. - * - * @author Emil Ivov - */ -public class OperationSetTypingNotificationsRssImpl - implements OperationSetTypingNotifications -{ - private static final Logger logger = - Logger.getLogger(OperationSetTypingNotificationsRssImpl.class); - - /** - * All currently registered TN listeners. - */ - private List typingNotificationsListeners = new ArrayList(); - - /** - * The provider that created us. - */ - private ProtocolProviderServiceRssImpl parentProvider = null; - - /** - * The currently valid persistent presence operation set.. - */ - private OperationSetPersistentPresenceRssImpl opSetPersPresence = null; - - - /** - * Creates a new instance of this operation set and keeps the parent - * provider as a reference. - * - * @param provider a ref to the ProtocolProviderServiceImpl - * that created us and that we'll use for retrieving the underlying aim - * connection. - * @param opSetPersPresence the currently valid - * OperationSetPersistentPresenceRssImpl instance. - */ - OperationSetTypingNotificationsRssImpl( - ProtocolProviderServiceRssImpl provider, - OperationSetPersistentPresenceRssImpl opSetPersPresence) - { - this.parentProvider = provider; - this.opSetPersPresence = opSetPersPresence; - } - - /** - * Adds listener to the list of listeners registered for receiving - * TypingNotificationEvents - * - * @param listener the TypingNotificationsListener listener that - * we'd like to add to the list of listeneres registered for receiving - * typing notificaions. - */ - public void addTypingNotificationsListener( - TypingNotificationsListener listener) - { - synchronized(typingNotificationsListeners) - { - typingNotificationsListeners.add(listener); - } - } - - /** - * Removes listener from the list of listeners registered for - * receiving TypingNotificationEvents - * - * @param listener the TypingNotificationsListener listener that - * we'd like to remove - */ - public void removeTypingNotificationsListener( - TypingNotificationsListener listener) - { - synchronized(typingNotificationsListeners) - { - typingNotificationsListeners.remove(listener); - } - } - - /** - * Delivers a TypingNotificationEvent to all registered listeners. - * @param sourceContact the contact who has sent the notification. - * @param evtCode the code of the event to deliver. - */ - private void fireTypingNotificationsEvent(Contact sourceContact - ,int evtCode) - { - logger.debug("Dispatching a TypingNotif. event to " - + typingNotificationsListeners.size()+" listeners. Contact " - + sourceContact.getAddress() + " has now a typing status of " - + evtCode); - - TypingNotificationEvent evt = new TypingNotificationEvent( - sourceContact, evtCode); - - Iterator listeners = null; - synchronized (typingNotificationsListeners) - { - listeners = new ArrayList(typingNotificationsListeners).iterator(); - } - - while (listeners.hasNext()) - { - TypingNotificationsListener listener - = (TypingNotificationsListener) listeners.next(); - - listener.typingNotificationReceifed(evt); - } - } - - /** - * Sends a notification to notifiedContatct that we have entered - * typingState. - * - * @param notifiedContact the Contact to notify - * @param typingState the typing state that we have entered. - * - * @throws java.lang.IllegalStateException if the underlying stack is - * not registered and initialized. - * @throws java.lang.IllegalArgumentException if notifiedContact is - * not an instance belonging to the underlying implementation. - */ - public void sendTypingNotification(Contact notifiedContact, int typingState) - throws IllegalStateException, IllegalArgumentException - { - if( !(notifiedContact instanceof ContactRssImpl) ) - throw new IllegalArgumentException( - "The specified contact is not a Rss contact." - + notifiedContact); - - - String userID = notifiedContact.getAddress(); - - //if the user id is owr own id, then this message is being routed to us - //from another instance of the rss provider. - if (userID.equals(this.parentProvider.getAccountID().getUserID())) - { - //check who is the provider sending the message - String sourceUserID = notifiedContact.getProtocolProvider() - .getAccountID().getUserID(); - - //check whether they are in our contact list - Contact from = opSetPersPresence.findContactByID(sourceUserID); - - //and if not - add them there as volatile. - if (from == null) - { - from = opSetPersPresence.createVolatileContact(sourceUserID); - } - - //and now fire the message received event. - fireTypingNotificationsEvent(from, typingState); - } - else - { - //if userID is not our own, try a check whether another provider - //has that id and if yes - deliver the message to them. - ProtocolProviderServiceRssImpl rssProvider - = this.opSetPersPresence.findProviderForRssUserID(userID); - if (rssProvider != null) - { - OperationSetTypingNotificationsRssImpl opSetTN - = (OperationSetTypingNotificationsRssImpl) - rssProvider.getOperationSet( - OperationSetTypingNotifications.class); - opSetTN.sendTypingNotification(notifiedContact, typingState); - } - else - { - //if we got here then "to" is simply someone in our contact - //list so let's just echo the message. - fireTypingNotificationsEvent(notifiedContact, typingState); - } - } - } - -}