[3102] | 1 | /* |
---|
| 2 | * Jeti, a Java Jabber client, Copyright (C) 2001 E.S. de Boer |
---|
| 3 | * |
---|
| 4 | * This program is free software; you can redistribute it and/or modify |
---|
| 5 | * it under the terms of the GNU General Public License as published by |
---|
| 6 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | * (at your option) any later version. |
---|
| 8 | * |
---|
| 9 | * This program is distributed in the hope that it will be useful, |
---|
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | * GNU General Public License for more details. |
---|
| 13 | * |
---|
| 14 | * You should have received a copy of the GNU General Public License |
---|
| 15 | * along with this program; if not, write to the Free Software |
---|
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 17 | * |
---|
| 18 | * For questions, comments etc, |
---|
| 19 | * use the website at http://jeti.jabberstudio.org |
---|
| 20 | * or mail/IM me at jeti@jabber.org |
---|
| 21 | * |
---|
| 22 | * Created on 9-jan-2005 |
---|
| 23 | */ |
---|
| 24 | |
---|
| 25 | package nu.fw.jeti.jabber; |
---|
| 26 | |
---|
| 27 | import java.util.List; |
---|
| 28 | |
---|
| 29 | import javax.swing.ImageIcon; |
---|
| 30 | |
---|
| 31 | /** |
---|
| 32 | * Keeps a JID and the information about that JID together. |
---|
| 33 | * The JIDStatus is implemented in three classes |
---|
| 34 | * <ul> |
---|
| 35 | * <li>{@link nu.fw.jeti.backend.roster.PrimaryJIDStatus}</li> |
---|
| 36 | * <li>{@link nu.fw.jeti.backend.roster.NormalJIDStatus}</li> |
---|
| 37 | * <li>{@link nu.fw.jeti.backend.roster.ResourceJIDStatus}</li> |
---|
| 38 | * </ul> |
---|
| 39 | * These classes are part of the roster and are used to store and sort |
---|
| 40 | * information about the nickname and resources. This abstract class makes the most |
---|
| 41 | * used methods of those classes available, so the implementing classes are rarely needed. |
---|
| 42 | * The JIDStatussen available in the roster can be obtained by {@link Backend#getJIDStatus(JID)} |
---|
| 43 | * If you need your own jidstatus you can use {@link UnknownJIDStatus} |
---|
| 44 | * @author E.S. de Boer |
---|
| 45 | * @version 1.0 |
---|
| 46 | */ |
---|
| 47 | |
---|
| 48 | public abstract class JIDStatus implements Comparable |
---|
| 49 | { |
---|
| 50 | protected ImageIcon avatar; |
---|
| 51 | protected boolean online = false; |
---|
| 52 | protected int show; |
---|
| 53 | protected String status; |
---|
| 54 | protected JID completeJID; |
---|
| 55 | |
---|
| 56 | /** |
---|
| 57 | * get users Avatar, only works when an avatar plugin is enabled |
---|
| 58 | * @return users avatar or null when none found |
---|
| 59 | */ |
---|
| 60 | public ImageIcon getAvatar() |
---|
| 61 | { |
---|
| 62 | return avatar; |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | /** |
---|
| 67 | * Gets the JID associated with this JIDStatus. |
---|
| 68 | * @return the JID whitout resource associated with this JIDStatus. |
---|
| 69 | */ |
---|
| 70 | public abstract JID getJID(); |
---|
| 71 | |
---|
| 72 | /** |
---|
| 73 | * Gets the JID with resource associated with this JIDStatus. |
---|
| 74 | * @return If there is a known resource the JID with resource, |
---|
| 75 | * else the JID without the resource. |
---|
| 76 | */ |
---|
| 77 | public JID getCompleteJID(){return completeJID;} |
---|
| 78 | |
---|
| 79 | /** |
---|
| 80 | * Returns true when the user is online. |
---|
| 81 | * @return true when the user is online. |
---|
| 82 | */ |
---|
| 83 | public boolean isOnline() |
---|
| 84 | { |
---|
| 85 | return online; |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | /** |
---|
| 89 | * Gets the Show status of this JIDStatus. |
---|
| 90 | * one of "chat", "available", "away", "dnd", "xa" or "unavailable". |
---|
| 91 | * @return The show status of this JIDStatus. |
---|
| 92 | */ |
---|
| 93 | public int getShow() |
---|
| 94 | { |
---|
| 95 | return show; |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | /** |
---|
| 99 | * Gets the status of this JIDStatus, status is the user defined |
---|
| 100 | * message (status can be null). |
---|
| 101 | * @return The status of this JIDStatus. |
---|
| 102 | */ |
---|
| 103 | public String getStatus() |
---|
| 104 | { |
---|
| 105 | return status; |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | /** |
---|
| 109 | * Gets the nickname of this JIDStatus. |
---|
| 110 | * If the nickname is unknown this method returns the |
---|
| 111 | * JID assiocated with this JIDStatus. |
---|
| 112 | * @return The nickname |
---|
| 113 | */ |
---|
| 114 | public abstract String getNick(); |
---|
| 115 | |
---|
| 116 | /** |
---|
| 117 | * Gets the type of the transport this JIDStatus is registerd with. |
---|
| 118 | * initialy this is "jabber". The type is browsed for the registerd transports, |
---|
| 119 | * if the browse succeeded the type is changed in the type of the transport, when |
---|
| 120 | * the browse fails the type is changed to "unknown". |
---|
| 121 | * @return The type of this JIDStatus. |
---|
| 122 | */ |
---|
| 123 | public abstract String getType(); |
---|
| 124 | |
---|
| 125 | |
---|
| 126 | /** |
---|
| 127 | * Gets the subscription type of this JIDStatus |
---|
| 128 | * can be null, "none" , "to", "from", or "both". |
---|
| 129 | * @return The subscription type of this JIDStatus. |
---|
| 130 | */ |
---|
| 131 | public abstract String getSubscription(); |
---|
| 132 | |
---|
| 133 | /** |
---|
| 134 | * Gets the waiting status of this JIDStatus |
---|
| 135 | * can be null, "subscribe" or "unsubscribe". |
---|
| 136 | * @return The waiting status of this JIDStatus. |
---|
| 137 | */ |
---|
| 138 | public abstract String getWaiting(); |
---|
| 139 | |
---|
| 140 | /** |
---|
| 141 | * |
---|
| 142 | * @return copy of the groups. |
---|
| 143 | */ |
---|
| 144 | public abstract List getGroupsCopy(); |
---|
| 145 | |
---|
| 146 | /** |
---|
| 147 | * Counts the groups this JIDStatus is in. |
---|
| 148 | * @return The number of groups this JIDStatus is in. |
---|
| 149 | */ |
---|
| 150 | abstract public int groupCount(); |
---|
| 151 | |
---|
| 152 | /** |
---|
| 153 | * Returns true when this JIDStatus is in group. |
---|
| 154 | * @param group The group that is tested. |
---|
| 155 | * @return true when this JIDStatus is in group. |
---|
| 156 | */ |
---|
| 157 | abstract public boolean isGroupPresent(String group); |
---|
| 158 | } |
---|
| 159 | /* |
---|
| 160 | * Overrides for emacs |
---|
| 161 | * Local variables: |
---|
| 162 | * tab-width: 4 |
---|
| 163 | * End: |
---|
| 164 | */ |
---|