com.echomine.jabber
Class JabberPresenceMessage

java.lang.Object
  extended by com.echomine.jabber.JabberMessage
      extended by com.echomine.jabber.JabberJDOMMessage
          extended by com.echomine.jabber.AbstractJabberMessage
              extended by com.echomine.jabber.JabberPresenceMessage
All Implemented Interfaces:
JabberCode, JabberMessageParsable, PresenceCode

public class JabberPresenceMessage
extends AbstractJabberMessage
implements PresenceCode, JabberCode

This parses the presence message and makes it easy to retrieve the information. The Presence Message support X Namespaces and by default will add those X Namespaces into outgoing messages.

This is how presence works. You declare yourself to be available, then you can set your state to away, extended away, do not disturb, etc. If you set yourself unavailable, then no one will see you online (essentially, you are "invisible"). If you set your state to one of the mentioned states, then you can set a descriptive text by setting the status.

The type indicates what kind of presence this is, either to be available or unavailable, or if it's a subscription request.

The to and from are used to indicate where the presence is going to or where it's coming from, respectively. These two fields are not always available, depending on what the type is.

The show tells others about you current state, whether you are away, extended away, etc.

The status is the descriptive text that tells others what you're doing. You may put anything for status when you set yourself to away/extended away/do not disturb.

The priority is used when you have multiple logins. The "default" is the highest priority and will receive the private messages. Negative priority is a preference that the sender should not be used for direct or immediate contact.

Current Implementation: JEP-0018 Version 0.1

Conforms with: XMPP Presence protocol


Field Summary
 
Fields inherited from class com.echomine.jabber.AbstractJabberMessage
TYPE_ERROR
 
Fields inherited from class com.echomine.jabber.JabberMessage
messageID
 
Fields inherited from interface com.echomine.jabber.PresenceCode
SHOW_AWAY, SHOW_CHAT, SHOW_DO_NOT_DISTURB, SHOW_EXTENDED_AWAY, SHOW_ONLINE, TYPE_AVAILABLE, TYPE_INVISIBLE, TYPE_PROBE, TYPE_SUBSCRIBE, TYPE_SUBSCRIBED, TYPE_UNAVAILABLE, TYPE_UNSUBSCRIBE, TYPE_UNSUBSCRIBED
 
Fields inherited from interface com.echomine.jabber.JabberCode
MSG_CHAT, MSG_INIT, MSG_IQ, MSG_IQ_AGENTS, MSG_IQ_AUTH, MSG_IQ_BROWSE, MSG_IQ_DISCO_INFO, MSG_IQ_DISCO_ITEMS, MSG_IQ_GATEWAY, MSG_IQ_LAST, MSG_IQ_OOB, MSG_IQ_PRIVATE, MSG_IQ_REGISTER, MSG_IQ_ROSTER, MSG_IQ_SEARCH, MSG_IQ_TIME, MSG_IQ_VACATION, MSG_IQ_VCARD, MSG_IQ_VERSION, MSG_IQ_XMLRPC, MSG_PRESENCE, MSG_UNKNOWN, MSG_X_DATA, MSG_X_DELAY, MSG_X_EVENT, MSG_X_EXPIRE, MSG_X_OOB, MSG_X_PGP_ENCRYPTED, MSG_X_PGP_SIGNED, MSG_X_ROSTER, PARSER_CHAT, PARSER_IQ, PARSER_IQ_AGENTS, PARSER_IQ_AUTH, PARSER_IQ_BROWSE, PARSER_IQ_DISCO_INFO, PARSER_IQ_DISCO_ITEMS, PARSER_IQ_GATEWAY, PARSER_IQ_LAST, PARSER_IQ_OOB, PARSER_IQ_PRIVATE, PARSER_IQ_REGISTER, PARSER_IQ_ROSTER, PARSER_IQ_SEARCH, PARSER_IQ_TIME, PARSER_IQ_VACATION, PARSER_IQ_VCARD, PARSER_IQ_VERSION, PARSER_IQ_XMLRPC, PARSER_PRESENCE, PARSER_X_DATA, PARSER_X_DELAY, PARSER_X_EVENT, PARSER_X_EXPIRE, PARSER_X_OOB, PARSER_X_PGP_ENCRYPTED, PARSER_X_PGP_SIGNED, PARSER_X_ROSTER, XMLNS_CHAT, XMLNS_ERROR_STANZA, XMLNS_ERROR_STREAM, XMLNS_IQ, XMLNS_IQ_AGENTS, XMLNS_IQ_AUTH, XMLNS_IQ_BROWSE, XMLNS_IQ_DISCO_INFO, XMLNS_IQ_DISCO_ITEMS, XMLNS_IQ_GATEWAY, XMLNS_IQ_LAST, XMLNS_IQ_OOB, XMLNS_IQ_PRIVATE, XMLNS_IQ_REGISTER, XMLNS_IQ_ROSTER, XMLNS_IQ_SEARCH, XMLNS_IQ_TIME, XMLNS_IQ_VACATION, XMLNS_IQ_VCARD, XMLNS_IQ_VERSION, XMLNS_IQ_XMLRPC, XMLNS_PRESENCE, XMLNS_STREAM, XMLNS_X_DATA, XMLNS_X_DELAY, XMLNS_X_EVENT, XMLNS_X_EXPIRE, XMLNS_X_OOB, XMLNS_X_PGP_ENCRYPTED, XMLNS_X_PGP_SIGNED, XMLNS_X_ROSTER
 
Constructor Summary
JabberPresenceMessage()
          constructs a default type of AVAILABLE
JabberPresenceMessage(java.lang.String type)
          Normally used for creating an outgoing message
 
Method Summary
 DelayXMessage getDelayMessage()
          convenience method to retrieve the Delay X Message (you can get the message by calling getXMessage() as well)
 int getMessageType()
          the default message type is unknown.
 PGPSignedXMessage getPGPSignedMessage()
          Convenience method to retrieve the signature of the presence message signed in PGP.
 int getPriority()
           
 java.lang.String getShowState()
          Retrieve the show string that is included with the presence message.
 java.lang.String getStatus()
           
 JabberMessage parse(JabberMessageParser parser, Element msgTree)
          parses the message.
 void setPriority(int priority)
          The "default" is the highest priority and will receive the private messages.
 void setShowState(java.lang.String showState)
          sets the string for show state.
 void setStatus(java.lang.String status)
          sets the status string when available.
 void setType(java.lang.String type)
          The method is overridden to conform properly with XMPP protocol standards.
 
Methods inherited from class com.echomine.jabber.AbstractJabberMessage
getErrorMessage, getFrom, getTo, getType, isError, setErrorMessage, setFrom, setTo
 
Methods inherited from class com.echomine.jabber.JabberJDOMMessage
encode, getDOM, getXMLOutputter, setMessageID, toString
 
Methods inherited from class com.echomine.jabber.JabberMessage
getMessageID, getReplyMessage, getTimeout, getXMessage, getXMessages, interrupt, isReplyRequired, isSendXMessages, isSynchronized, replyReceived, setReplyRequired, setSendXMessages, setSynchronized, setTimeout, setXMessage, setXMessages
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JabberPresenceMessage

public JabberPresenceMessage(java.lang.String type)
Normally used for creating an outgoing message


JabberPresenceMessage

public JabberPresenceMessage()
constructs a default type of AVAILABLE

Method Detail

parse

public JabberMessage parse(JabberMessageParser parser,
                           Element msgTree)
                    throws ParseException
Description copied from class: AbstractJabberMessage
parses the message. The parser is really not used

Specified by:
parse in interface JabberMessageParsable
Overrides:
parse in class AbstractJabberMessage
Throws:
ParseException

setType

public void setType(java.lang.String type)
The method is overridden to conform properly with XMPP protocol standards. In XMPP, when a presence is available, it should simply remove the type from being sent.

Overrides:
setType in class AbstractJabberMessage
Parameters:
type - the type of presence (available, unavailable, dnd, etc)

setStatus

public void setStatus(java.lang.String status)
sets the status string when available. Set status to null to remove the status


getStatus

public java.lang.String getStatus()
Returns:
the status string of the presence message, null if none exists

getShowState

public java.lang.String getShowState()
Retrieve the show string that is included with the presence message. If no show state exist, the default SHOW_ONLINE will be returned as default per XMPP protocol specs.

Returns:
the show state, never null

setShowState

public void setShowState(java.lang.String showState)
sets the string for show state. Null to remove the show state string


getPriority

public int getPriority()
Returns:
the priority of the message, 0 is default

setPriority

public void setPriority(int priority)
The "default" is the highest priority and will receive the private messages. Negative priority is a preference that the sender should not be used for direct or immediate contact. It must be an integer value between -127 to +127. A 0 value is the default.


getMessageType

public int getMessageType()
Description copied from class: JabberJDOMMessage
the default message type is unknown. It doesn't mean that there is no type. It just means that there is no known message parser for this particular object.

Overrides:
getMessageType in class JabberJDOMMessage
Returns:
a message code that is unique to the message
See Also:
JabberCode

getDelayMessage

public DelayXMessage getDelayMessage()
convenience method to retrieve the Delay X Message (you can get the message by calling getXMessage() as well)

Returns:
the delay message, null if none exists

getPGPSignedMessage

public PGPSignedXMessage getPGPSignedMessage()
Convenience method to retrieve the signature of the presence message signed in PGP.



Copyright © 2001-2005 Echomine. All Rights Reserved.