Code review for the RSS provider implemnetation. Fixing numerous javadoc conflicts.

Removed the class since we don't need typing notifications for RSS.
cusax-fix
Emil Ivov 19 years ago
parent 3201213ff4
commit d6e5627a8c

@ -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 <tt>ProtocolProviderServiceImpl</tt>
* that created us and that we'll use for retrieving the underlying aim
* connection.
* @param opSetPersPresence the currently valid
* <tt>OperationSetPersistentPresenceRssImpl</tt> instance.
*/
OperationSetTypingNotificationsRssImpl(
ProtocolProviderServiceRssImpl provider,
OperationSetPersistentPresenceRssImpl opSetPersPresence)
{
this.parentProvider = provider;
this.opSetPersPresence = opSetPersPresence;
}
/**
* Adds <tt>listener</tt> to the list of listeners registered for receiving
* <tt>TypingNotificationEvent</tt>s
*
* @param listener the <tt>TypingNotificationsListener</tt> 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 <tt>listener</tt> from the list of listeners registered for
* receiving <tt>TypingNotificationEvent</tt>s
*
* @param listener the <tt>TypingNotificationsListener</tt> listener that
* we'd like to remove
*/
public void removeTypingNotificationsListener(
TypingNotificationsListener listener)
{
synchronized(typingNotificationsListeners)
{
typingNotificationsListeners.remove(listener);
}
}
/**
* Delivers a <tt>TypingNotificationEvent</tt> 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 <tt>notifiedContatct</tt> that we have entered
* <tt>typingState</tt>.
*
* @param notifiedContact the <tt>Contact</tt> 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 <tt>notifiedContact</tt> 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);
}
}
}
}
Loading…
Cancel
Save