whiteboard implementation

cusax-fix
Yana Stamcheva 18 years ago
parent 3a0cfbbc8a
commit 3db54ce3c7

@ -0,0 +1,494 @@
/*
* 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.jabber;
import java.util.*;
import net.java.sip.communicator.impl.protocol.jabber.extensions.whiteboard.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.service.protocol.whiteboardobjects.*;
import net.java.sip.communicator.util.*;
import org.jivesoftware.smack.*;
import org.jivesoftware.smack.filter.*;
import org.jivesoftware.smack.packet.*;
import org.jivesoftware.smack.provider.*;
import org.jivesoftware.smack.util.*;
/**
* Provides basic functionality for white-board.
*
* @author Julien Waechter
* @author Yana Stamcheva
*/
public class OperationSetWhiteboardingJabberImpl
implements OperationSetWhiteboarding
{
private static final Logger logger =
Logger.getLogger(OperationSetWhiteboardingJabberImpl.class);
/**
* The provider that created us.
*/
private ProtocolProviderServiceJabberImpl jabberProvider = null;
/**
* A list of listeners subscribed for invitations multi user chat events.
*/
private Vector invitationListeners = new Vector();
/**
* A list of listeners subscribed for events indicating rejection of a
* multi user chat invitation sent by us.
*/
private Vector invitationRejectionListeners = new Vector();
/**
* Listeners that will be notified of changes in our status in the
* room such as us being kicked, banned, or granted admin permissions.
*/
private Vector presenceListeners = new Vector();
private Vector whiteboardSessions = new Vector();
private OperationSetPersistentPresenceJabberImpl presenceOpSet;
/**
* Creates an instance of this operation set.
* @param provider a ref to the <tt>ProtocolProviderServiceImpl</tt>
* that created us and that we'll use for retrieving the underlying aim
* connection.
*/
public OperationSetWhiteboardingJabberImpl(
ProtocolProviderServiceJabberImpl provider)
{
this.jabberProvider = provider;
provider.addRegistrationStateChangeListener(
new RegistrationStateListener());
// Add the custom WhiteboardObjectJabberProvider to the Smack library
ProviderManager pManager = ProviderManager.getInstance();
pManager.addExtensionProvider(
WhiteboardObjectPacketExtensionImpl.ELEMENT_NAME,
WhiteboardObjectPacketExtensionImpl.NAMESPACE,
new WhiteboardObjectJabberProvider());
}
/**
* Adds a listener to invitation notifications.
*
* @param listener an invitation listener.
*/
public void addInvitationListener(WhiteboardInvitationListener listener)
{
synchronized(invitationListeners)
{
if (!invitationListeners.contains(listener))
invitationListeners.add(listener);
}
}
/**
* Removes <tt>listener</tt> from the list of invitation listeners
* registered to receive invitation events.
*
* @param listener the invitation listener to remove.
*/
public void removeInvitationListener(WhiteboardInvitationListener listener)
{
synchronized(invitationListeners)
{
invitationListeners.remove(listener);
}
}
/**
* Subscribes <tt>listener</tt> so that it would receive events indicating
* rejection of a multi-user chat invitation that we've sent earlier.
*
* @param listener the listener that we'll subscribe for invitation
* rejection events.
*/
public void addInvitationRejectionListener(
WhiteboardInvitationRejectionListener listener)
{
synchronized(invitationRejectionListeners)
{
if (!invitationRejectionListeners.contains(listener))
invitationRejectionListeners.add(listener);
}
}
/**
* Removes <tt>listener</tt> from the list of invitation listeners
* registered to receive invitation rejection events.
*
* @param listener the invitation listener to remove.
*/
public void removeInvitationRejectionListener(
WhiteboardInvitationRejectionListener listener)
{
synchronized(invitationRejectionListeners)
{
invitationRejectionListeners.remove(listener);
}
}
/**
* Adds a listener that will be notified of changes in our status in a chat
* room such as us being kicked, banned or dropped.
*
* @param listener the <tt>LocalUserChatRoomPresenceListener</tt>.
*/
public void addPresenceListener(WhiteboardSessionPresenceListener listener)
{
synchronized(presenceListeners)
{
if (!presenceListeners.contains(listener))
presenceListeners.add(listener);
}
}
/**
* Removes a listener that was being notified of changes in our status in
* a room such as us being kicked, banned or dropped.
*
* @param listener the <tt>LocalUserChatRoomPresenceListener</tt>.
*/
public void removePresenceListener(
WhiteboardSessionPresenceListener listener)
{
synchronized(presenceListeners)
{
presenceListeners.remove(listener);
}
}
/**
* Creates a <tt>WhiteboardSession</tt>. For now the session is created
* locally and neither the sessionName, nor the sessionProperties are
* used.
* @param sessionName the name of the session
* @param sessionProperties the settings of the session
* @throws OperationFailedException if the room couldn't be created for some
* reason (e.g. room already exists; user already joined to an existent
* room or user has no permissions to create a chat room).
* @throws OperationNotSupportedException if chat room creation is not
* supported by this server
* @return the created white-board session
*/
public WhiteboardSession createWhiteboardSession(
String sessionName,
Hashtable sessionProperties)
throws OperationFailedException,
OperationNotSupportedException
{
WhiteboardSessionJabberImpl session
= new WhiteboardSessionJabberImpl(jabberProvider, this);
whiteboardSessions.add(session);
return session;
}
/**
* Returns a reference to a <tt>WhiteboardSession</tt> named
* <tt>sessionName</tt> or null if no such session exists.
* <p>
* @param sessionName the name of the <tt>WhiteboardSession</tt> that we're
* looking for.
* @return the <tt>WhiteboardSession</tt> named <tt>sessionName</tt> or null
* if no such session exists on the server that this provider is currently
* connected to.
*
* @throws OperationFailedException if an error occurs while trying to
* discover the white-board session on the server.
* @throws OperationNotSupportedException if the server does not support
* white-boarding
*/
public WhiteboardSession findWhiteboardSession(String sessionName)
throws OperationFailedException,
OperationNotSupportedException
{
// TODO: Implement findWhiteboardSession
return null;
}
/**
* Returns a list of the white-board sessions that we have joined and are
* currently active in.
*
* @return a <tt>List</tt> of the white-board sessions where the user has
* joined using a given connection.
*/
public List getCurrentlyJoinedWhiteboards()
{
synchronized(whiteboardSessions)
{
List joinedWhiteboards
= new LinkedList(whiteboardSessions);
Iterator joinedWhiteboardsIter = whiteboardSessions.iterator();
while (joinedWhiteboardsIter.hasNext())
{
if (!((WhiteboardSession) joinedWhiteboardsIter.next())
.isJoined())
joinedWhiteboardsIter.remove();
}
return joinedWhiteboards;
}
}
/**
* Returns a list of the <tt>WhiteboardSession</tt>s that
* <tt>WhiteboardParticipant</tt> has joined and is currently active in.
*
* @param participant the participant whose current
* <tt>WhiteboardSession</tt>s we will be querying.
* @return a list of the <tt>WhiteboardSession</tt>s that
* <tt>WhiteboardParticipant</tt> has joined and is currently active in.
*
* @throws OperationFailedException if an error occurs while trying to
* discover the session.
* @throws OperationNotSupportedException if the server does not support
* white-boarding
*/
public List getCurrentlyJoinedWhiteboards(WhiteboardParticipant participant)
throws OperationFailedException,
OperationNotSupportedException
{
// TODO: Implement getCurrentlyJoinedWhiteboards(
// WhiteboardParticipant participant)
return null;
}
/**
* Returns true if <tt>contact</tt> supports white-board sessions.
*
* @param contact reference to the contact whose support for white-boards
* we are currently querying.
* @return a boolean indicating whether <tt>contact</tt> supports
* white-boards.
*/
public boolean isWhiteboardingSupportedByContact(Contact contact)
{
if(contact.getProtocolProvider()
.getOperationSet(OperationSetWhiteboarding.class) != null)
return true;
return false;
}
/**
* Informs the sender of an invitation that we decline their invitation.
*
* @param invitation the invitation we are rejecting.
* @param rejectReason the reason to reject the invitation (optional)
*/
public void rejectInvitation(WhiteboardInvitation invitation,
String rejectReason)
{
// TODO: Implement rejectInvitation(WhiteboardInvitation invitation,
// String rejectReason)
}
/**
* Our listener that will tell us when we're registered to
*/
private class RegistrationStateListener
implements RegistrationStateChangeListener
{
/**
* The method is called by a ProtocolProvider implementation whenever
* a change in the registration state of the corresponding provider had
* occurred.
* @param evt ProviderStatusChangeEvent the event describing the status
* change.
*/
public void registrationStateChanged(RegistrationStateChangeEvent evt)
{
if (evt.getNewState() == RegistrationState.REGISTERED)
{
presenceOpSet
= (OperationSetPersistentPresenceJabberImpl) jabberProvider
.getOperationSet(OperationSetPresence.class);
PacketExtensionFilter filterWhiteboard =
new PacketExtensionFilter(
WhiteboardObjectPacketExtensionImpl.ELEMENT_NAME,
WhiteboardObjectPacketExtensionImpl.NAMESPACE);
jabberProvider.getConnection().addPacketListener(
new WhiteboardSmackMessageListener(), filterWhiteboard);
}
}
}
/**
* Listens for white-board messages and checks if a white-board session
* already exists and if not simulates an invitation to the user.
*/
private class WhiteboardSmackMessageListener
implements PacketListener
{
public void processPacket(Packet packet)
{
if (!(packet instanceof org.jivesoftware.smack.packet.Message))
return;
PacketExtension ext =
packet.getExtension(
WhiteboardObjectPacketExtensionImpl.ELEMENT_NAME,
WhiteboardObjectPacketExtensionImpl.NAMESPACE);
org.jivesoftware.smack.packet.Message msg =
(org.jivesoftware.smack.packet.Message) packet;
if (ext == null)
return;
String fromUserID = StringUtils.parseBareAddress(msg.getFrom());
// We check if a white-board session with the given contact already
// exists and if this is the case we don't continue.
for (int i = 0; i < whiteboardSessions.size(); i ++)
{
WhiteboardSessionJabberImpl session
= (WhiteboardSessionJabberImpl) whiteboardSessions.get(i);
// Should be replaced by getParticipants when implementing
// the multi user white-boarding
if(session.isJoined()
&& session.isParticipantContained(fromUserID))
return;
}
// If we're here this means that no white board session has been
// found and we will send an invitation to the user to join a
// white-board session created by us.
WhiteboardObjectPacketExtensionImpl newMessage
= (WhiteboardObjectPacketExtensionImpl) ext;
WhiteboardSessionJabberImpl session
= new WhiteboardSessionJabberImpl(
jabberProvider,
OperationSetWhiteboardingJabberImpl.this);
whiteboardSessions.add(session);
ContactJabberImpl sourceContact
= (ContactJabberImpl) presenceOpSet.findContactByID(fromUserID);
if (sourceContact == null)
{
logger.debug("Received a message from an unknown contact: "
+ fromUserID);
//create the volatile contact
sourceContact
= presenceOpSet.createVolatileContact(fromUserID);
}
session.addWhiteboardParticipant(
new WhiteboardParticipantJabberImpl(sourceContact, session));
fireInvitationEvent(session,
newMessage.getWhiteboardObject(),
fromUserID,
null,
null);
}
}
/**
* Delivers a <tt>WhiteboardInvitationEvent</tt> to all
* registered <tt>WhiteboardInvitationListener</tt>s.
*
* @param targetWhiteboard the white-board that invitation refers to
* @param whiteboardObject the white-board object that inviter send
* with this invitation and which will be shown on the white-board if the
* user accepts the invitation
* @param inviter the inviter that sent the invitation
* @param reason the reason why the inviter sent the invitation
* @param password the password to use when joining the room
*/
public void fireInvitationEvent(WhiteboardSession targetWhiteboard,
WhiteboardObject whiteboardObject,
String inviter,
String reason,
byte[] password)
{
WhiteboardInvitationJabberImpl invitation
= new WhiteboardInvitationJabberImpl( targetWhiteboard,
whiteboardObject,
inviter,
reason,
password);
WhiteboardInvitationReceivedEvent evt
= new WhiteboardInvitationReceivedEvent(this, invitation,
new Date(System.currentTimeMillis()));
logger.debug("Dispatching a WhiteboardInvitation event to "
+ invitationListeners.size() + " listeners. event is: "
+ evt.toString());
Iterator listeners = null;
synchronized (invitationListeners)
{
listeners = new ArrayList(invitationListeners).iterator();
}
while (listeners.hasNext())
{
WhiteboardInvitationListener listener
= (WhiteboardInvitationListener) listeners.next();
listener.invitationReceived(evt);
}
}
/**
* Delivers a <tt>WhiteboardSessionPresenceChangeEvent</tt> to all
* registered <tt>WhiteboardSessionPresenceChangeEvent</tt>s.
*
* @param session the <tt>WhiteboardSession</tt> which has been joined,
* left, etc.
* @param eventType the type of this event; one of LOCAL_USER_JOINED,
* LOCAL_USER_LEFT, etc.
* @param reason the reason
*/
public void fireWhiteboardSessionPresenceEvent( WhiteboardSession session,
String eventType,
String reason)
{
WhiteboardSessionPresenceChangeEvent evt
= new WhiteboardSessionPresenceChangeEvent( this,
session,
eventType,
reason);
Iterator listeners = null;
synchronized (presenceListeners)
{
listeners = new ArrayList(presenceListeners).iterator();
}
while (listeners.hasNext())
{
WhiteboardSessionPresenceListener listener
= (WhiteboardSessionPresenceListener) listeners.next();
listener.whiteboardSessionPresenceChanged(evt);
}
}
}

@ -0,0 +1,111 @@
/*
* 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.jabber;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.whiteboardobjects.*;
/**
* The Jabber implementation of the <tt>WhiteboardInvitation</tt> interface.
*
* @author Yana Stamcheva
*/
public class WhiteboardInvitationJabberImpl
implements WhiteboardInvitation
{
private WhiteboardSession whiteboardSession;
private WhiteboardObject firstWhiteboardObject;
private String inviter;
private String reason;
private byte[] password;
/**
* Creates an invitation for the given <tt>targetWhiteboard</tt>, from the
* given <tt>inviter</tt>.
*
* @param targetWhiteboard the <tt>WhiteboardSession</tt> for which the
* invitation is
* @param firstWhiteboardObject the white-board object that inviter send
* with this invitation and which will be shown on the white-board if the
* user accepts the invitation
* @param inviter the <tt>WhiteboardParticipant</tt>, which sent the
* invitation
* @param reason the reason of the invitation
* @param password the password to use to join the given white-board
*/
public WhiteboardInvitationJabberImpl(
WhiteboardSession targetWhiteboard,
WhiteboardObject firstWhiteboardObject,
String inviter,
String reason,
byte[] password)
{
this.whiteboardSession = targetWhiteboard;
this.firstWhiteboardObject = firstWhiteboardObject;
this.inviter = inviter;
this.reason = reason;
this.password = password;
}
/**
* Returns the <tt>WhiteboardSession</tt>, that this invitation is about.
*
* @return the <tt>WhiteboardSession</tt>, that this invitation is about
*/
public WhiteboardSession getTargetWhiteboard()
{
return whiteboardSession;
}
/**
* Returns the inviter, who sent this invitation.
*
* @return the inviter, who sent this invitation
*/
public String getInviter()
{
return inviter;
}
/**
* Returns the reason of the invitation.
*
* @return the reason of the invitation
*/
public String getReason()
{
return reason;
}
/**
* Returns the password to use in order to join the white-board, that this
* invitation is about.
*
* @return the password to use in order to join the white-board, that this
* invitation is about.
*/
public byte[] getWhiteboardPassword()
{
return password;
}
/**
* Returns the first white-board object that the inviter would like to
* exchange with the user. If the user accepts this invitation he/she
* should see this object on his white-board.
*
* @return the first white-board object
*/
public WhiteboardObject getWhiteboardInitialObject()
{
return firstWhiteboardObject;
}
}

@ -0,0 +1,420 @@
/*
* 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.jabber;
import java.util.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.*;
/**
* The WhiteboardParticipantJabberImpl is a class that represents participants
* in a whiteboard.
*
* @author Julien Waechter
*/
public class WhiteboardParticipantJabberImpl
implements WhiteboardParticipant
{
private static final Logger logger =
Logger.getLogger(WhiteboardParticipantJabberImpl.class);
/**
* The participant
*/
private ContactJabberImpl participant = null;
/**
* The state of the whiteboard participant.
*/
protected WhiteboardParticipantState whiteboardParticipantState =
WhiteboardParticipantState.UNKNOWN;
/**
* Indicates the date when is whiteboard participant passed into its current
* state.
*/
protected Date currentStateStartDate = new Date();
/**
* A byte array containing the image/photo representing the whiteboard
* participant.
*/
private byte[] image;
/**
* A string uniquely identifying the participant.
*/
private String participantID;
/**
* The whiteboard this participant belongs to.
*/
private WhiteboardSessionJabberImpl whiteboard;
/**
* Creates a new whiteboard participant with address
* <tt>participantAddress</tt>.
*
* @param participant the JAIN SIP <tt>Address</tt> of the new whiteboard
* participant.
*
* @param owningWhiteboard the whiteboard that contains this whiteboard
* participant.
*/
public WhiteboardParticipantJabberImpl(ContactJabberImpl participant,
WhiteboardSessionJabberImpl owningWhiteboard)
{
this.participant = participant;
this.whiteboard = owningWhiteboard;
whiteboard.addWhiteboardParticipant(this);
// create the uid
this.participantID =
String.valueOf(System.currentTimeMillis())
+ String.valueOf(hashCode());
}
/**
* Returns the contact identifier representing this contact.
*
* @return a String contact address
*/
public String getContactAddress()
{
return this.participant.getAddress();
}
/**
* Returns an object representing the current state of that participant.
* WhiteboardParticipantState may vary among CONNECTING, BUSY, CONNECTED...
*
* @return a WhiteboardParticipantState instance representin the
* participant's state.
*/
public WhiteboardParticipantState getState()
{
return whiteboardParticipantState;
}
/**
* Causes this WhiteboardParticipant to enter the specified state. The
* method also sets the currentStateStartDate field and fires a
* WhiteboardParticipantChangeEvent.
*
* @param newState the state this whiteboard participant should enter.
* @param reason a string that could be set to contain a human readable
* explanation for the transition (particularly handy when moving
* into a FAILED state).
*/
protected void setState(WhiteboardParticipantState newState, String reason)
{
WhiteboardParticipantState oldState = getState();
if (oldState == newState)
return;
this.whiteboardParticipantState = newState;
this.currentStateStartDate = new Date();
fireWhiteboardParticipantChangeEvent(
WhiteboardParticipantChangeEvent.WHITEBOARD_PARTICIPANT_STATE_CHANGE,
oldState, newState);
}
/**
* Causes this WhiteboardParticipant to enter the specified state. The
* method also sets the currentStateStartDate field and fires a
* WhiteboardParticipantChangeEvent.
*
* @param newState the state this whiteboard participant should enter.
*/
protected void setState(WhiteboardParticipantState newState)
{
setState(newState, null);
}
/**
* Returns the date (time) when this whiteboard participant acquired its
* current status.
*
* @return a java.util.Date object containing the date when this whiteboard
* participant entered its current state.
*/
public Date getCurrentStateStartDate()
{
return currentStateStartDate;
}
/**
* Returns a human readable name representing this participant.
*
* @return a String containing a name for that participant.
*/
public String getDisplayName()
{
String displayName = participant.getDisplayName();
return (displayName == null) ? "" : displayName;
}
/**
* Sets a human readable name representing this participant.
*
* @param displayName the participant's display name
*/
protected void setDisplayName(String displayName)
{
String oldName = getDisplayName();
/*
* try { this.participant.setDisplayName(displayName); } catch
* (ParseException ex) { //couldn't happen logger.error(ex.getMessage(),
* ex); throw new IllegalArgumentException(ex.getMessage()); }
*/
// Fire the Event
fireWhiteboardParticipantChangeEvent(
WhiteboardParticipantChangeEvent.WHITEBOARD_PARTICIPANT_DISPLAY_NAME_CHANGE,
oldName, displayName);
}
/**
* The method returns an image representation of the whiteboard participant
* (e.g.
*
* @return byte[] a byte array containing the image or null if no image is
* available.
*/
public byte[] getImage()
{
return image;
}
/**
* Sets the byte array containing an image representation (photo or picture)
* of the whiteboard participant.
*
* @param image a byte array containing the image
*/
protected void setImage(byte[] image)
{
byte[] oldImage = getImage();
this.image = image;
// Fire the Event
fireWhiteboardParticipantChangeEvent(
WhiteboardParticipantChangeEvent.WHITEBOARD_PARTICIPANT_IMAGE_CHANGE,
oldImage, image);
}
/**
* Returns a unique identifier representing this participant.
*
* @return an identifier representing this whiteboard participant.
*/
public String getParticipantID()
{
return participantID;
}
/**
* Sets the String that serves as a unique identifier of this
* WhiteboardParticipant.
*
* @param participantID the ID of this whiteboard participant.
*/
protected void setParticipantID(String participantID)
{
this.participantID = participantID;
}
/**
* Returns the chat room that this member is participating in.
*
* @return the <tt>WhiteboardSession</tt> instance that this member
* belongs to.
*/
public WhiteboardSession getWhiteboardSession()
{
return whiteboard;
}
/**
* Sets the whiteboard containing this participant.
*
* @param whiteboard the whiteboard that this whiteboard participant is
* partdicipating in.
*/
protected void setWhiteboard(WhiteboardSessionJabberImpl whiteboard)
{
this.whiteboard = whiteboard;
}
/**
* Returns the protocol provider instance that this member has originated
* in.
*
* @return the <tt>ProtocolProviderService</tt> instance that created this
* member and its containing cht room
*/
public ProtocolProviderService getProtocolProvider()
{
return this.getWhiteboardSession().getProtocolProvider();
}
/**
* Returns the contact corresponding to this participant or null if no
* particular contact has been associated.
* <p>
*
* @return the <tt>Contact</tt> corresponding to this participant or null
* if no particular contact has been associated.
*/
public Contact getContact()
{
return this.participant;
}
/**
* All the WhiteboardParticipant listeners registered with this
* WhiteboardParticipant.
*/
protected ArrayList whiteboardParticipantListeners = new ArrayList();
/**
* Allows the user interface to register a listener interested in changes
*
* @param listener a listener instance to register with this participant.
*/
public void addWhiteboardParticipantListener(
WhiteboardParticipantListener listener)
{
synchronized (whiteboardParticipantListeners)
{
if (!whiteboardParticipantListeners.contains(listener))
this.whiteboardParticipantListeners.add(listener);
}
}
/**
* Unregisters the specified listener.
*
* @param listener the listener to unregister.
*/
public void removeWhiteboardParticipantListener(
WhiteboardParticipantListener listener)
{
synchronized (whiteboardParticipantListeners)
{
if (listener == null)
return;
whiteboardParticipantListeners.remove(listener);
}
}
/**
* Constructs a <tt>WhiteboardParticipantChangeEvent</tt> using this
* whiteboard participant as source, setting it to be of type
* <tt>eventType</tt> and the corresponding <tt>oldValue</tt> and
* <tt>newValue</tt>,
*
* @param eventType the type of the event to create and dispatch.
* @param oldValue the value of the source property before it changed.
* @param newValue the current value of the source property.
*/
protected void fireWhiteboardParticipantChangeEvent(String eventType,
Object oldValue, Object newValue)
{
this.fireWhiteboardParticipantChangeEvent(eventType, oldValue,
newValue, null);
}
/**
* Constructs a <tt>WhiteboardParticipantChangeEvent</tt> using this
* whiteboard participant as source, setting it to be of type
* <tt>eventType</tt> and the corresponding <tt>oldValue</tt> and
* <tt>newValue</tt>,
*
* @param eventType the type of the event to create and dispatch.
* @param oldValue the value of the source property before it changed.
* @param newValue the current value of the source property.
* @param reason a string that could be set to contain a human readable
* explanation for the transition (particularly handy when moving
* into a FAILED state).
*/
protected void fireWhiteboardParticipantChangeEvent(String eventType,
Object oldValue, Object newValue, String reason)
{
WhiteboardParticipantChangeEvent evt =
new WhiteboardParticipantChangeEvent(this, eventType, oldValue,
newValue, reason);
logger.debug("Dispatching a WhiteboardParticipantChangeEvent event to "
+ whiteboardParticipantListeners.size() + " listeners. event is: "
+ evt.toString());
Iterator listeners = null;
synchronized (whiteboardParticipantListeners)
{
listeners =
new ArrayList(whiteboardParticipantListeners).iterator();
}
while (listeners.hasNext())
{
WhiteboardParticipantListener listener =
(WhiteboardParticipantListener) listeners.next();
if (eventType
.equals(WhiteboardParticipantChangeEvent.WHITEBOARD_PARTICIPANT_DISPLAY_NAME_CHANGE))
{
listener.participantDisplayNameChanged(evt);
}
else if (eventType
.equals(WhiteboardParticipantChangeEvent.WHITEBOARD_PARTICIPANT_IMAGE_CHANGE))
{
listener.participantImageChanged(evt);
}
else if (eventType
.equals(WhiteboardParticipantChangeEvent.WHITEBOARD_PARTICIPANT_STATE_CHANGE))
{
listener.participantStateChanged(evt);
}
}
}
/**
* Returns a string representation of the participant in the form of <br>
* Display Name <address>;status=WhiteboardParticipantStatus
*
* @return a string representation of the participant and its state.
*/
public String toString()
{
return getDisplayName();
}
/**
* Returns the name of this member
*
* @return the name of this member in the room (nickname).
*/
public String getName()
{
return this.participant.getDisplayName();
}
/**
* Sets the chat room that this member is participating in.
*
* @param session
*/
public void setWhiteboardSession(WhiteboardSessionJabberImpl session)
{
this.whiteboard = session;
}
}
Loading…
Cancel
Save