Default mode is now AVAILABLE instead of null.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1901 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2003-04-25 20:20:32 +00:00 committed by mtucker
parent 33e3e0d232
commit fe6b9f2693
1 changed files with 8 additions and 8 deletions

View File

@ -74,8 +74,8 @@ package org.jivesoftware.smack.packet;
* <li>Priority -- non-negative numerical priority of a sender's resource. The * <li>Priority -- non-negative numerical priority of a sender's resource. The
* highest resource priority is the default recipient of packets not addressed * highest resource priority is the default recipient of packets not addressed
* to a particular resource. * to a particular resource.
* <li>Mode -- one of four presence modes: chat, away, xa (extended away, and * <li>Mode -- one of five presence modes: available (the default), chat, away,
* dnd (do not disturb). * xa (extended away, and dnd (do not disturb).
* </ul><p> * </ul><p>
* *
* Presence packets are used for two purposes. First, to notify the server of our * Presence packets are used for two purposes. First, to notify the server of our
@ -90,7 +90,7 @@ public class Presence extends Packet {
private Type type = Type.AVAILABLE; private Type type = Type.AVAILABLE;
private String status = null; private String status = null;
private int priority = -1; private int priority = -1;
private Mode mode = null; private Mode mode = Mode.AVAILABLE;
/** /**
* Creates a new presence update. Status, priority, and mode are left un-set. * Creates a new presence update. Status, priority, and mode are left un-set.
@ -174,8 +174,7 @@ public class Presence extends Packet {
} }
/** /**
* Returns the mode of the presence update, or <tt>null</tt> if no mode has been set. * Returns the mode of the presence update.
* A <tt>null</tt> value for mode means the client is in the standard "available" state.
* *
* @return the mode. * @return the mode.
*/ */
@ -215,7 +214,7 @@ public class Presence extends Packet {
if (priority != -1) { if (priority != -1) {
buf.append("<priority>").append(priority).append("</priority>"); buf.append("<priority>").append(priority).append("</priority>");
} }
if (mode != null) { if (mode != null && mode != Mode.AVAILABLE) {
buf.append("<show>").append(mode).append("</show>"); buf.append("<show>").append(mode).append("</show>");
} }
buf.append("</presence>"); buf.append("</presence>");
@ -279,6 +278,7 @@ public class Presence extends Packet {
*/ */
public static class Mode { public static class Mode {
public static final Mode AVAILABLE = new Mode("available");
public static final Mode CHAT = new Mode("chat"); public static final Mode CHAT = new Mode("chat");
public static final Mode AWAY = new Mode("away"); public static final Mode AWAY = new Mode("away");
public static final Mode EXTENDED_AWAY = new Mode("xa"); public static final Mode EXTENDED_AWAY = new Mode("xa");
@ -300,7 +300,7 @@ public class Presence extends Packet {
*/ */
public static Mode fromString(String value) { public static Mode fromString(String value) {
if (value == null) { if (value == null) {
return null; return AVAILABLE;
} }
else if (value.equals("chat")) { else if (value.equals("chat")) {
return CHAT; return CHAT;
@ -318,7 +318,7 @@ public class Presence extends Packet {
return INVISIBLE; return INVISIBLE;
} }
else { else {
return null; return AVAILABLE;
} }
} }
} }