From 319dcd408f0b5e261f2ef6ab1f2f085687df6fe4 Mon Sep 17 00:00:00 2001 From: Matt Tucker Date: Sat, 17 Feb 2007 19:43:44 +0000 Subject: [PATCH] Added convenience methods (SMACK-200). git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7179 b35dd754-fafc-0310-a699-88a17e54d16e --- .../jivesoftware/smack/packet/Presence.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/source/org/jivesoftware/smack/packet/Presence.java b/source/org/jivesoftware/smack/packet/Presence.java index a730146f8..1110ef908 100644 --- a/source/org/jivesoftware/smack/packet/Presence.java +++ b/source/org/jivesoftware/smack/packet/Presence.java @@ -87,6 +87,32 @@ public class Presence extends Packet { this.mode = mode; } + /** + * Returns true if the {@link Type presence type} is available (online) and + * false if the user is unavailable (offline), or if this is a presence packet + * involved in a subscription operation. This is a convenience method + * equivalent to getType() == Presence.Type.available. + * + * @return true if the presence type is available. + */ + public boolean isAvailable() { + return type == Type.available; + } + + /** + * Returns true if the presence type is {@link Type#available available} and the presence + * mode is {@link Mode#away away}, {@link Mode#xa extended away}, or + * {@link Mode#dnd do not disturb}. False will be returned when the type or mode + * is any other value, including when the presence type is unavailable (offline). + * This is a convenience method equivalent to + * type == Type.available && (mode == Mode.away || mode == Mode.xa || mode == Mode.dnd). + * + * @return true if the presence type is available and the presence mode is away, xa, or dnd. + */ + public boolean isAway() { + return type == Type.available && (mode == Mode.away || mode == Mode.xa || mode == Mode.dnd); + } + /** * Returns the type of this presence packet. *