Smack

org.jivesoftware.smackx
Class OfflineMessageManager

java.lang.Object
  extended by org.jivesoftware.smackx.OfflineMessageManager

public class OfflineMessageManager
extends Object

The OfflineMessageManager helps manage offline messages even before the user has sent an available presence. When a user asks for his offline messages before sending an available presence then the server will not send a flood with all the offline messages when the user becomes online. The server will not send a flood with all the offline messages to the session that made the offline messages request or to any other session used by the user that becomes online.

Once the session that made the offline messages request has been closed and the user becomes offline in all the resources then the server will resume storing the messages offline and will send all the offline messages to the user when he becomes online. Therefore, the server will flood the user when he becomes online unless the user uses this class to manage his offline messages.

Author:
Gaston Dombiak

Constructor Summary
OfflineMessageManager(XMPPConnection connection)
           
 
Method Summary
 void deleteMessages()
          Deletes all offline messages of the user.
 void deleteMessages(List<String> nodes)
          Deletes the specified list of offline messages.
 Iterator<OfflineMessageHeader> getHeaders()
          Returns an iterator on OfflineMessageHeader that keep information about the offline message.
 int getMessageCount()
          Returns the number of offline messages for the user of the connection.
 Iterator<Message> getMessages()
          Returns an Iterator with all the offline Messages of the user.
 Iterator<Message> getMessages(List<String> nodes)
          Returns an Iterator with the offline Messages whose stamp matches the specified request.
 boolean supportsFlexibleRetrieval()
          Returns true if the server supports Flexible Offline Message Retrieval.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OfflineMessageManager

public OfflineMessageManager(XMPPConnection connection)
Method Detail

supportsFlexibleRetrieval

public boolean supportsFlexibleRetrieval()
                                  throws XMPPException
Returns true if the server supports Flexible Offline Message Retrieval. When the server supports Flexible Offline Message Retrieval it is possible to get the header of the offline messages, get specific messages, delete specific messages, etc.

Returns:
a boolean indicating if the server supports Flexible Offline Message Retrieval.
Throws:
XMPPException - If the user is not allowed to make this request.

getMessageCount

public int getMessageCount()
                    throws XMPPException
Returns the number of offline messages for the user of the connection.

Returns:
the number of offline messages for the user of the connection.
Throws:
XMPPException - If the user is not allowed to make this request or the server does not support offline message retrieval.

getHeaders

public Iterator<OfflineMessageHeader> getHeaders()
                                          throws XMPPException
Returns an iterator on OfflineMessageHeader that keep information about the offline message. The OfflineMessageHeader includes a stamp that could be used to retrieve the complete message or delete the specific message.

Returns:
an iterator on OfflineMessageHeader that keep information about the offline message.
Throws:
XMPPException - If the user is not allowed to make this request or the server does not support offline message retrieval.

getMessages

public Iterator<Message> getMessages(List<String> nodes)
                              throws XMPPException
Returns an Iterator with the offline Messages whose stamp matches the specified request. The request will include the list of stamps that uniquely identifies the offline messages to retrieve. The returned offline messages will not be deleted from the server. Use deleteMessages(java.util.List) to delete the messages.

Parameters:
nodes - the list of stamps that uniquely identifies offline message.
Returns:
an Iterator with the offline Messages that were received as part of this request.
Throws:
XMPPException - If the user is not allowed to make this request or the server does not support offline message retrieval.

getMessages

public Iterator<Message> getMessages()
                              throws XMPPException
Returns an Iterator with all the offline Messages of the user. The returned offline messages will not be deleted from the server. Use deleteMessages(java.util.List) to delete the messages.

Returns:
an Iterator with all the offline Messages of the user.
Throws:
XMPPException - If the user is not allowed to make this request or the server does not support offline message retrieval.

deleteMessages

public void deleteMessages(List<String> nodes)
                    throws XMPPException
Deletes the specified list of offline messages. The request will include the list of stamps that uniquely identifies the offline messages to delete.

Parameters:
nodes - the list of stamps that uniquely identifies offline message.
Throws:
XMPPException - If the user is not allowed to make this request or the server does not support offline message retrieval.

deleteMessages

public void deleteMessages()
                    throws XMPPException
Deletes all offline messages of the user.

Throws:
XMPPException - If the user is not allowed to make this request or the server does not support offline message retrieval.

Smack

Copyright © 2003-2007 Jive Software.