Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.jabber
Class WhiteboardSessionJabberImpl

java.lang.Object
  extended by net.java.sip.communicator.impl.protocol.jabber.WhiteboardSessionJabberImpl
All Implemented Interfaces:
EventListener, WhiteboardParticipantListener, WhiteboardSession

public class WhiteboardSessionJabberImpl
extends Object
implements WhiteboardParticipantListener, WhiteboardSession

A representation of a WhiteboardSession.

Author:
Julien Waechter, Yana Stamcheva

Constructor Summary
WhiteboardSessionJabberImpl(ProtocolProviderServiceJabberImpl sourceProvider, OperationSetWhiteboardingJabberImpl opSet)
          WhiteboardSessionJabberImpl constructor.
 
Method Summary
 void addWhiteboardChangeListener(WhiteboardChangeListener listener)
          Adds a whiteboard change listener to this whiteboard so that it could receive events on new whiteboard participants, theme changes and others.
 void addWhiteboardObjectListener(WhiteboardObjectListener listener)
          Registers listener so that it would receive events every time a new WhiteboardObject is received on this whiteboard.
 void addWhiteboardParticipant(WhiteboardParticipant wbParticipant)
          Adds wbParticipant to the list of participants in this white-board.
 WhiteboardObject createWhiteboardObject(String name)
          Create a WhiteboardObject instance with the specified type.
 void deleteWhiteboardObject(WhiteboardObject obj)
          Sends a WhiteboardObject to delete and delete the local WhiteboardObject
 boolean equals(Object obj)
          Compares the specified object with this whiteboard and returns true if it the specified object is an instance of a Whiteboard object and if the extending telephony protocol considers the whiteboards represented by both objects to be the same.
 void fireMessageEvent(EventObject evt)
          Delivers the specified event to all registered message listeners.
 void fireWhiteboardChangeEvent(String type, Object oldValue, Object newValue)
          Creates a WhiteboardChangeEvent with this class as sourceWhiteboard, and the specified eventID and old and new values and dispatches it on all currently registered listeners.
 void fireWhiteboardParticipantEvent(WhiteboardParticipant sourceWhiteboardParticipant, int eventID)
          Creates a WhiteboardParticipantEvent with sourceWhiteboardParticipant and eventID and dispatches it on all currently registered listeners.
 ProtocolProviderService getProtocolProvider()
          Returns a reference to the ProtocolProviderService instance that created this whiteboard.
 WhiteboardSessionState getState()
          Returns the state that this whiteboard is currently in.
 String[] getSupportedWhiteboardObjects()
          Returns all the type of WhiteboardObject that this whiteboard support.
 String getWhiteboardID()
          Returns the id of the specified Whiteboard.
 Vector<WhiteboardObject> getWhiteboardObjects()
          Returns the WhiteboardObjects in this whiteboard session.
 Iterator<WhiteboardParticipant> getWhiteboardParticipants()
          Returns an iterator over all white-board participants.
 int getWhiteboardParticipantsCount()
          Returns the number of participants currently associated with this white-board session.
 WhiteboardSession getWhiteboardSession()
          returns the current WhiteboardSession
 WhiteboardSessionState getWhiteboardSessionState()
          Returns the state that this whiteboard is currently in.
 int hashCode()
          Returns a hash code value for this whiteboard.
 void invite(String contactAddress)
          Invites another user to this room.
 boolean isJoined()
          Returns true if the local user is currently in the white-board session (after white-boarding one of the join() methods).
 boolean isOfflineMessagingSupported()
          Determines wheter the protocol provider (or the protocol itself) support sending and receiving offline messages.
 boolean isParticipantContained(String participantName)
          Checks if the participant given by participantName is contained in this white-board session.
 void join()
          Joins this white-board with the nickname of the local user so that the user would start receiving events and WhiteboardObject for it.
 void join(byte[] password)
          Joins this white-board so that the user would start receiving events and WhiteboardObject for it.
 void leave()
          Leave this whiteboard.
 void moveWhiteboardObject(WhiteboardObject obj)
          Sends a WhiteboardObject to modify and modifies the local WhiteboardObject
 void participantAddressChanged(WhiteboardParticipantChangeEvent evt)
          Indicates that a change has occurred in the address of the source WhiteboardParticipant.
 void participantDisplayNameChanged(WhiteboardParticipantChangeEvent evt)
          Indicates that a change has occurred in the display name of the source WhiteboardParticipant.
 void participantImageChanged(WhiteboardParticipantChangeEvent evt)
          Indicates that a change has occurred in the image of the source WhiteboardParticipant.
 void participantStateChanged(WhiteboardParticipantChangeEvent evt)
          Verifies whether the whiteboard participant has entered a state.
 void participantTransportAddressChanged(WhiteboardParticipantChangeEvent evt)
          Indicates that a change has occurred in the transport address that we use to communicate with the participant.
 void removeWhiteboardChangeListener(WhiteboardChangeListener listener)
          Removes listener to this whiteboard so that it won't receive further WhiteboardChangeEvents.
 void removeWhiteboardObjectListener(WhiteboardObjectListener listener)
          Removes listener so that it won't receive any further WhiteboardObject events from this room.
 void removeWhiteboardParticipant(WhiteboardParticipant wbParticipant)
          Removes whiteboardParticipant from the list of participants in this whiteboard.
 void sendWhiteboardObject(WhiteboardObject message)
          Sends the message to the destination.
 void setState(WhiteboardSessionState newState)
          Sets the state of this whiteboard
 void setWhiteboardSessionState(WhiteboardSessionState newState)
          Sets the state of this whiteboard and fires a whiteboard change event notifying registered listeners for the change.
 String toString()
          Returns a string textually representing this Whiteboard.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WhiteboardSessionJabberImpl

public WhiteboardSessionJabberImpl(ProtocolProviderServiceJabberImpl sourceProvider,
                                   OperationSetWhiteboardingJabberImpl opSet)
WhiteboardSessionJabberImpl constructor.

Parameters:
sourceProvider - Jabber protocol provider
opSet - the whiteboard operation set
Method Detail

getWhiteboardParticipants

public Iterator<WhiteboardParticipant> getWhiteboardParticipants()
Returns an iterator over all white-board participants.

Specified by:
getWhiteboardParticipants in interface WhiteboardSession
Returns:
an Iterator over all participants currently involved in the white-board.

getWhiteboardParticipantsCount

public int getWhiteboardParticipantsCount()
Returns the number of participants currently associated with this white-board session.

Specified by:
getWhiteboardParticipantsCount in interface WhiteboardSession
Returns:
an int indicating the number of participants currently associated with this white-board.

join

public void join()
          throws OperationFailedException
Joins this white-board with the nickname of the local user so that the user would start receiving events and WhiteboardObject for it.

Specified by:
join in interface WhiteboardSession
Throws:
OperationFailedException - with the corresponding code if an error occurs while joining the room.

join

public void join(byte[] password)
          throws OperationFailedException
Joins this white-board so that the user would start receiving events and WhiteboardObject for it. The method uses the nickname of the local user and the specified password in order to enter the white-board session.

Specified by:
join in interface WhiteboardSession
Parameters:
password - the password to use when authenticating on the white-board session.
Throws:
OperationFailedException - with the corresponding code if an error occurs while joining the room.

isJoined

public boolean isJoined()
Returns true if the local user is currently in the white-board session (after white-boarding one of the join() methods).

Specified by:
isJoined in interface WhiteboardSession
Returns:
true if currently we're currently in this white-board and false otherwise.

leave

public void leave()
Leave this whiteboard. Once this method is whiteboarded, the user won't be listed as a member of the whiteboard any more and no further whiteboard events will be delivered. Depending on the underlying protocol and implementation leave() might cause the room to be destroyed if it has been created by the local user.

Specified by:
leave in interface WhiteboardSession

invite

public void invite(String contactAddress)
Invites another user to this room.

If the room is password-protected, the invitee will receive a password to use to join the room. If the room is members-only, the the invitee may be added to the member list.

Specified by:
invite in interface WhiteboardSession
Parameters:
contactAddress - the address of the user to invite to the room. (one may also invite users not on their contact list).

getWhiteboardSession

public WhiteboardSession getWhiteboardSession()
returns the current WhiteboardSession

Returns:
current WhiteboardSession

participantStateChanged

public void participantStateChanged(WhiteboardParticipantChangeEvent evt)
Verifies whether the whiteboard participant has entered a state.

Specified by:
participantStateChanged in interface WhiteboardParticipantListener
Parameters:
evt - The WhiteboardParticipantChangeEvent instance containing the source event as well as its previous and its new status.

participantDisplayNameChanged

public void participantDisplayNameChanged(WhiteboardParticipantChangeEvent evt)
Indicates that a change has occurred in the display name of the source WhiteboardParticipant.

Specified by:
participantDisplayNameChanged in interface WhiteboardParticipantListener
Parameters:
evt - The WhiteboardParticipantChangeEvent instance containing the source event as well as its previous and its new display names.

participantAddressChanged

public void participantAddressChanged(WhiteboardParticipantChangeEvent evt)
Indicates that a change has occurred in the address of the source WhiteboardParticipant.

Parameters:
evt - The WhiteboardParticipantChangeEvent instance containing the source event as well as its previous and its new address.

participantTransportAddressChanged

public void participantTransportAddressChanged(WhiteboardParticipantChangeEvent evt)
Indicates that a change has occurred in the transport address that we use to communicate with the participant.

Parameters:
evt - The WhiteboardParticipantChangeEvent instance containing the source event as well as its previous and its new transport address.

participantImageChanged

public void participantImageChanged(WhiteboardParticipantChangeEvent evt)
Indicates that a change has occurred in the image of the source WhiteboardParticipant.

Specified by:
participantImageChanged in interface WhiteboardParticipantListener
Parameters:
evt - The WhiteboardParticipantChangeEvent instance containing the source event as well as its previous and its new image.

addWhiteboardParticipant

public void addWhiteboardParticipant(WhiteboardParticipant wbParticipant)
Adds wbParticipant to the list of participants in this white-board. If the white-board participant is already included in the white-board, the method has no effect.

Specified by:
addWhiteboardParticipant in interface WhiteboardSession
Parameters:
wbParticipant - the new WhiteboardParticipant

removeWhiteboardParticipant

public void removeWhiteboardParticipant(WhiteboardParticipant wbParticipant)
Removes whiteboardParticipant from the list of participants in this whiteboard. The method has no effect if there was no such participant in the whiteboard.

Specified by:
removeWhiteboardParticipant in interface WhiteboardSession
Parameters:
wbParticipant - the WhiteboardParticipant leaving the whiteboard;

setWhiteboardSessionState

public void setWhiteboardSessionState(WhiteboardSessionState newState)
Sets the state of this whiteboard and fires a whiteboard change event notifying registered listeners for the change.

Parameters:
newState - a reference to the WhiteboardState instance that the whiteboard is to enter.

getWhiteboardSessionState

public WhiteboardSessionState getWhiteboardSessionState()
Returns the state that this whiteboard is currently in.

Returns:
a reference to the WhiteboardState instance that the whiteboard is currently in.

addWhiteboardObjectListener

public void addWhiteboardObjectListener(WhiteboardObjectListener listener)
Registers listener so that it would receive events every time a new WhiteboardObject is received on this whiteboard.

Specified by:
addWhiteboardObjectListener in interface WhiteboardSession
Parameters:
listener - a WhiteboardObjectListener that would be notified every time a new WhiteboardObject is received on this whiteboard.

removeWhiteboardObjectListener

public void removeWhiteboardObjectListener(WhiteboardObjectListener listener)
Removes listener so that it won't receive any further WhiteboardObject events from this room.

Specified by:
removeWhiteboardObjectListener in interface WhiteboardSession
Parameters:
listener - the WhiteboardObjectListener to remove from this room

createWhiteboardObject

public WhiteboardObject createWhiteboardObject(String name)
Create a WhiteboardObject instance with the specified type. This method only creates the object locally and it would not be visible to other session participants until it is resolved with the sendWhiteboardObject(WhiteboardObject) method.

Specified by:
createWhiteboardObject in interface WhiteboardSession
Parameters:
name - the name of the object to create (should be one of the WhiteboardObjectXXX.NAME fields).
Returns:
the newly created WhiteboardObject with an id

getWhiteboardID

public String getWhiteboardID()
Returns the id of the specified Whiteboard.

Specified by:
getWhiteboardID in interface WhiteboardSession
Returns:
a String uniquely identifying the whiteboard.

isOfflineMessagingSupported

public boolean isOfflineMessagingSupported()
Determines wheter the protocol provider (or the protocol itself) support sending and receiving offline messages. Most often this method would return true for protocols that support offline messages and false for those that don't. It is however possible for a protocol to support these messages and yet have a particular account that does not (i.e. feature not enabled on the protocol server). In cases like this it is possible for this method to return true even when offline messaging is not supported, and then have the sendMessage method throw an OperationFailedException with code - OFFLINE_MESSAGES_NOT_SUPPORTED.

Returns:
true if the protocol supports offline messages and false otherwise.

moveWhiteboardObject

public void moveWhiteboardObject(WhiteboardObject obj)
                          throws OperationFailedException
Sends a WhiteboardObject to modify and modifies the local WhiteboardObject

Specified by:
moveWhiteboardObject in interface WhiteboardSession
Parameters:
obj - the WhiteboardObject to send and modify
Throws:
OperationFailedException - if sending the WhiteboardObject fails for some reason.

deleteWhiteboardObject

public void deleteWhiteboardObject(WhiteboardObject obj)
                            throws OperationFailedException
Sends a WhiteboardObject to delete and delete the local WhiteboardObject

Specified by:
deleteWhiteboardObject in interface WhiteboardSession
Parameters:
obj - the WhiteboardObject to send and delete
Throws:
OperationFailedException - if sending the WhiteboardObject fails for some reason.

sendWhiteboardObject

public void sendWhiteboardObject(WhiteboardObject message)
                          throws OperationFailedException
Sends the message to the destination.

Specified by:
sendWhiteboardObject in interface WhiteboardSession
Parameters:
message - the Message to send.
Throws:
IllegalStateException - if the underlying stack is not registered and initialized.
IllegalArgumentException - if to is not an instance of ContactImpl.
OperationFailedException - if sending the WhiteboardObject fails for some reason.

equals

public boolean equals(Object obj)
Compares the specified object with this whiteboard and returns true if it the specified object is an instance of a Whiteboard object and if the extending telephony protocol considers the whiteboards represented by both objects to be the same.

Overrides:
equals in class Object
Parameters:
obj - the whiteboard to compare this one with.
Returns:
true in case both objects are pertaining to the same whiteboard and false otherwise.

hashCode

public int hashCode()
Returns a hash code value for this whiteboard.

Overrides:
hashCode in class Object
Returns:
a hash code value for this whiteboard.

toString

public String toString()
Returns a string textually representing this Whiteboard.

Overrides:
toString in class Object
Returns:
a string representation of the object.

addWhiteboardChangeListener

public void addWhiteboardChangeListener(WhiteboardChangeListener listener)
Adds a whiteboard change listener to this whiteboard so that it could receive events on new whiteboard participants, theme changes and others.

Specified by:
addWhiteboardChangeListener in interface WhiteboardSession
Parameters:
listener - the listener to register

removeWhiteboardChangeListener

public void removeWhiteboardChangeListener(WhiteboardChangeListener listener)
Removes listener to this whiteboard so that it won't receive further WhiteboardChangeEvents.

Specified by:
removeWhiteboardChangeListener in interface WhiteboardSession
Parameters:
listener - the listener to register

getProtocolProvider

public ProtocolProviderService getProtocolProvider()
Returns a reference to the ProtocolProviderService instance that created this whiteboard.

Specified by:
getProtocolProvider in interface WhiteboardSession
Returns:
a reference to the ProtocolProviderService instance that created this whiteboard.

fireWhiteboardParticipantEvent

public void fireWhiteboardParticipantEvent(WhiteboardParticipant sourceWhiteboardParticipant,
                                           int eventID)
Creates a WhiteboardParticipantEvent with sourceWhiteboardParticipant and eventID and dispatches it on all currently registered listeners.

Parameters:
sourceWhiteboardParticipant - the source WhiteboardParticipant for the newly created event.
eventID - the ID of the event to create (see CPE member ints)

fireWhiteboardChangeEvent

public void fireWhiteboardChangeEvent(String type,
                                      Object oldValue,
                                      Object newValue)
Creates a WhiteboardChangeEvent with this class as sourceWhiteboard, and the specified eventID and old and new values and dispatches it on all currently registered listeners.

Parameters:
type - the type of the event to create (see WhiteboardChangeEvent member ints)
oldValue - the value of the Whiteboard property that changed, before the event had occurred.
newValue - the value of the Whiteboard property that changed, after the event has occurred.

getWhiteboardObjects

public Vector<WhiteboardObject> getWhiteboardObjects()
Returns the WhiteboardObjects in this whiteboard session.

Specified by:
getWhiteboardObjects in interface WhiteboardSession
Returns:
an Vector of WhiteboardObjects associated with this whiteboard.

setState

public void setState(WhiteboardSessionState newState)
Sets the state of this whiteboard

Specified by:
setState in interface WhiteboardSession
Parameters:
newState - a reference to the WhiteboardState instance that the whiteboard is to enter.

getState

public WhiteboardSessionState getState()
Returns the state that this whiteboard is currently in.

Specified by:
getState in interface WhiteboardSession
Returns:
a reference to the WhiteboardState instance that the whiteboard is currently in.

fireMessageEvent

public void fireMessageEvent(EventObject evt)
Delivers the specified event to all registered message listeners.

Parameters:
evt - the EventObject that we'd like delivered to all registered message listeners.

getSupportedWhiteboardObjects

public String[] getSupportedWhiteboardObjects()
Returns all the type of WhiteboardObject that this whiteboard support.

Specified by:
getSupportedWhiteboardObjects in interface WhiteboardSession
Returns:
all the WhiteboardObject supported by this WhiteboardSession.

isParticipantContained

public boolean isParticipantContained(String participantName)
Checks if the participant given by participantName is contained in this white-board session.

Parameters:
participantName - the name of the participant to search for
Returns:
true if a participant with the given name is contained in this session, false - otherwise

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.