Openfire 3.5.2 Javadoc

org.jivesoftware.openfire.spi
Class PresenceManagerImpl

java.lang.Object
  extended by org.jivesoftware.openfire.container.BasicModule
      extended by org.jivesoftware.openfire.spi.PresenceManagerImpl
All Implemented Interfaces:
Module, PresenceManager

public class PresenceManagerImpl
extends BasicModule
implements PresenceManager

Simple in memory implementation of the PresenceManager interface.

Author:
Iain Shigeoka

Field Summary
 
Fields inherited from interface org.jivesoftware.openfire.PresenceManager
SORT_ONLINE_TIME, SORT_USERNAME
 
Constructor Summary
PresenceManagerImpl()
           
 
Method Summary
 boolean canProbePresence(JID prober, String probee)
          Returns true if the the prober is allowed to see the presence of the probee.
 long getLastActivity(User user)
          Returns the number of milliseconds since the user went offline or -1 if such information is not available or if the user is online.
 String getLastPresenceStatus(User user)
          Returns the status sent by the user in his last unavailable presence or null if the user is online or never set such information.
 Presence getPresence(User user)
          Returns the user's current presence, or null if the user is unavailable.
 Collection<Presence> getPresences(String username)
          Returns all presences for the user, or null if the user is unavailable.
 void handleProbe(Presence packet)
          Handle a presence probe sent by a remote server.
 void initialize(XMPPServer server)
          Initializes the basic module.
 boolean isAvailable(User user)
          Returns the availability of the user.
 void probePresence(JID prober, JID probee)
          Probes the presence of the given XMPPAddress and attempts to send it to the given user.
 void sendUnavailableFromSessions(JID recipientJID, JID userJID)
          Sends unavailable presence from all of the user's available resources to the remote user.
 void start()
          Starts the basic module.
 void stop()
          Stops the basic module.
 void userAvailable(Presence presence)
          Notification message saying that the sender of the given presence just became available.
 void userUnavailable(Presence presence)
          Notification message saying that the sender of the given presence just became unavailable.
 
Methods inherited from class org.jivesoftware.openfire.container.BasicModule
destroy, getName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PresenceManagerImpl

public PresenceManagerImpl()
Method Detail

isAvailable

public boolean isAvailable(User user)
Description copied from interface: PresenceManager

Returns the availability of the user.

Specified by:
isAvailable in interface PresenceManager
Parameters:
user - the user who's availability is in question
Returns:
true if the user as available for messaging (1 or more available sessions)

getPresence

public Presence getPresence(User user)
Description copied from interface: PresenceManager
Returns the user's current presence, or null if the user is unavailable. If the user is connected with more than one session, the user's "most available" presence status is returned.

Specified by:
getPresence in interface PresenceManager
Parameters:
user - the user.
Returns:
the user's current presence.

getPresences

public Collection<Presence> getPresences(String username)
Description copied from interface: PresenceManager
Returns all presences for the user, or null if the user is unavailable.

Specified by:
getPresences in interface PresenceManager
Parameters:
username - the name of the user.
Returns:
the Presence packets for all the users's connected sessions.

getLastPresenceStatus

public String getLastPresenceStatus(User user)
Description copied from interface: PresenceManager
Returns the status sent by the user in his last unavailable presence or null if the user is online or never set such information.

Specified by:
getLastPresenceStatus in interface PresenceManager
Parameters:
user - the user to return his last status information
Returns:
the status sent by the user in his last unavailable presence or null if the user is online or never set such information.

getLastActivity

public long getLastActivity(User user)
Description copied from interface: PresenceManager
Returns the number of milliseconds since the user went offline or -1 if such information is not available or if the user is online.

Specified by:
getLastActivity in interface PresenceManager
Parameters:
user - the user to return his information.
Returns:
the number of milliseconds since the user went offline or -1 if such information is not available or if the user is online.

userAvailable

public void userAvailable(Presence presence)
Description copied from interface: PresenceManager
Notification message saying that the sender of the given presence just became available.

Specified by:
userAvailable in interface PresenceManager
Parameters:
presence - the presence sent by the available user.

userUnavailable

public void userUnavailable(Presence presence)
Description copied from interface: PresenceManager
Notification message saying that the sender of the given presence just became unavailable.

Specified by:
userUnavailable in interface PresenceManager
Parameters:
presence - the presence sent by the unavailable user.

handleProbe

public void handleProbe(Presence packet)
                 throws UnauthorizedException
Description copied from interface: PresenceManager
Handle a presence probe sent by a remote server. The logic to apply is the following: If the remote user is not in the local user's roster with a subscription state of "From", or "Both", then return a presence stanza of type "error" in response to the presence probe. Otherwise, answer the presence of the local user sessions or the last unavailable presence.

Specified by:
handleProbe in interface PresenceManager
Parameters:
packet - the received probe presence from a remote server.
Throws:
UnauthorizedException

canProbePresence

public boolean canProbePresence(JID prober,
                                String probee)
                         throws UserNotFoundException
Description copied from interface: PresenceManager
Returns true if the the prober is allowed to see the presence of the probee.

Specified by:
canProbePresence in interface PresenceManager
Parameters:
prober - the user that is trying to probe the presence of another user.
probee - the username of the uset that is being probed.
Returns:
true if the the prober is allowed to see the presence of the probee.
Throws:
UserNotFoundException - If the probee does not exist in the local server or the prober is not present in the roster of the probee.

probePresence

public void probePresence(JID prober,
                          JID probee)
Description copied from interface: PresenceManager
Probes the presence of the given XMPPAddress and attempts to send it to the given user. If the user probing the presence is using his bare JID then the probee's presence will be sent to all connected resources of the prober.

Specified by:
probePresence in interface PresenceManager
Parameters:
prober - The user requesting the probe
probee - The XMPPAddress whos presence we would like sent have have probed

sendUnavailableFromSessions

public void sendUnavailableFromSessions(JID recipientJID,
                                        JID userJID)
Description copied from interface: PresenceManager
Sends unavailable presence from all of the user's available resources to the remote user. When a remote user unsubscribes from the presence of a local user then the server should send to the remote user unavailable presence from all of the local user's available resources. Moreover, if the recipient user is a local user then the unavailable presence will be sent to all user resources.

Specified by:
sendUnavailableFromSessions in interface PresenceManager
Parameters:
recipientJID - JID of the remote user that will receive the unavailable presences.
userJID - JID of the local user.

initialize

public void initialize(XMPPServer server)
Description copied from class: BasicModule

Initializes the basic module.

Inheriting classes that choose to override this method MUST call this initialize() method before accessing BasicModule resources.

Specified by:
initialize in interface Module
Overrides:
initialize in class BasicModule
Parameters:
server - the server hosting this module.

start

public void start()
           throws IllegalStateException
Description copied from class: BasicModule

Starts the basic module.

Inheriting classes that choose to override this method MUST call this start() method before accessing BasicModule resources.

Specified by:
start in interface Module
Overrides:
start in class BasicModule
Throws:
IllegalStateException - If start is called before initialize successfully returns

stop

public void stop()
Description copied from class: BasicModule

Stops the basic module.

Inheriting classes that choose to override this method MUST call this stop() method before accessing BasicModule resources.

Specified by:
stop in interface Module
Overrides:
stop in class BasicModule

Openfire 3.5.2 Javadoc

Copyright © 2003-2007 Jive Software.