/**
  * Returns the number of offline messages for the user of the connection.
  *
  * @return 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.
  */
 public int getMessageCount() throws XMPPException {
   DiscoverInfo info =
       ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(null, namespace);
   Form extendedInfo = Form.getFormFrom(info);
   if (extendedInfo != null) {
     String value = (String) extendedInfo.getField("number_of_messages").getValues().next();
     return Integer.parseInt(value);
   }
   return 0;
 }
 /**
  * Returns an iterator on <tt>OfflineMessageHeader</tt> 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.
  *
  * @return an iterator on <tt>OfflineMessageHeader</tt> 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.
  */
 public Iterator getHeaders() throws XMPPException {
   List answer = new ArrayList();
   DiscoverItems items =
       ServiceDiscoveryManager.getInstanceFor(connection).discoverItems(null, namespace);
   for (Iterator it = items.getItems(); it.hasNext(); ) {
     DiscoverItems.Item item = (DiscoverItems.Item) it.next();
     answer.add(new OfflineMessageHeader(item));
   }
   return answer.iterator();
 }
 /**
  * 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.
  *
  * @return a boolean indicating if the server supports Flexible Offline Message Retrieval.
  * @throws XMPPException If the user is not allowed to make this request.
  */
 public boolean supportsFlexibleRetrieval() throws XMPPException {
   DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(null);
   return info.containsFeature(namespace);
 }