diff options
author | Damian Minkov <damencho@jitsi.org> | 2007-01-09 09:44:14 +0000 |
---|---|---|
committer | Damian Minkov <damencho@jitsi.org> | 2007-01-09 09:44:14 +0000 |
commit | 044c3e34a10bbd5c3dedd1a9472099bb40c5d041 (patch) | |
tree | 9f223cf303b268b18de41e8c3cacfc0c84dd1732 | |
parent | 9199329060a4feab1545d5163b167ac23b76d0ba (diff) | |
download | jitsi-044c3e34a10bbd5c3dedd1a9472099bb40c5d041.zip jitsi-044c3e34a10bbd5c3dedd1a9472099bb40c5d041.tar.gz jitsi-044c3e34a10bbd5c3dedd1a9472099bb40c5d041.tar.bz2 |
Start yahoo implementation. Yahoo statuses (icons still to come).
-rw-r--r-- | src/net/java/sip/communicator/service/protocol/yahooconstants/YahooStatusEnum.java | 182 |
1 files changed, 182 insertions, 0 deletions
diff --git a/src/net/java/sip/communicator/service/protocol/yahooconstants/YahooStatusEnum.java b/src/net/java/sip/communicator/service/protocol/yahooconstants/YahooStatusEnum.java new file mode 100644 index 0000000..4847cad --- /dev/null +++ b/src/net/java/sip/communicator/service/protocol/yahooconstants/YahooStatusEnum.java @@ -0,0 +1,182 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.service.protocol.yahooconstants; + +import java.io.*; +import java.util.*; + +import net.java.sip.communicator.service.protocol.*; +import net.java.sip.communicator.util.*; + +/** + * An enumeration containing all status instances that MUST be supported by + * an implementation of the yahoo protocol. Implementations may + * support other forms of PresenceStatus but they MUST ALL support those + * enumerated here. + * <p> + * For testing purposes, this class also provides a <tt>List</tt> containing + * all of the status fields. + * + * @author Damian Minkov + */ +public class YahooStatusEnum + extends PresenceStatus +{ + private static Logger logger = Logger.getLogger(YahooStatusEnum.class); + + /** + * The Online status. Indicate that the user is able and willing to + * communicate. + */ + public static final YahooStatusEnum AVAILABLE + = new YahooStatusEnum(65, "Available", + loadIcon("resources/images/msn/msn16x16-online.png")); + + /** + * The Idle status. Indicates that the user is not using the messanger. + */ + public static final YahooStatusEnum IDLE + = new YahooStatusEnum(55, "Idle", + loadIcon("resources/images/msn/msn16x16-na.png")); + + /** + * The Invisible status. Indicates that the user has connectivity even + * though it may appear otherwise to others, to whom she would appear to be + * offline. + */ + public static final YahooStatusEnum INVISIBLE + = new YahooStatusEnum(45, "Invisible", + loadIcon("resources/images/msn/msn16x16-invisible.png")); + + /** + * The STEPPED_OUT status. Indicates that the user has connectivity but might + * not be able to immediately act upon initiation of communication. + */ + public static final YahooStatusEnum STEPPED_OUT + = new YahooStatusEnum(40, "Stepped out", + loadIcon("resources/images/msn/msn16x16-away.png")); + + /** + * The Out to lunch status. Indicates that the user is eating. + */ + public static final YahooStatusEnum OUT_TO_LUNCH + = new YahooStatusEnum(39, "Out to lunch", + loadIcon("resources/images/msn/msn16x16-lunch.png")); + + /** + * The Not at home status. Indicates that the user is not at home. + */ + public static final YahooStatusEnum NOT_AT_HOME + = new YahooStatusEnum(38, "Not at home", + loadIcon("resources/images/msn/msn16x16-phone.png")); + + /** + * The On the phone status. Indicates that the user is talking to the phone. + */ + public static final YahooStatusEnum ON_THE_PHONE + = new YahooStatusEnum(37, "On the phone", + loadIcon("resources/images/msn/msn16x16-phone.png")); + + /** + * The Not at desk status. Indicates that the user is not at his desk, but + * somewhere in the office. + */ + public static final YahooStatusEnum NOT_AT_DESK + = new YahooStatusEnum(36, "Not at desk", + loadIcon("resources/images/msn/msn16x16-phone.png")); + + /** + * The Not Available status. Indicates that the user has connectivity + * but might not be able to immediately act (i.e. even less immediately than + * when in an Away status ;-P ) upon initiation of communication. + * + */ + public static final YahooStatusEnum BE_RIGHT_BACK + = new YahooStatusEnum(35, "Be Right Back", + loadIcon("resources/images/msn/msn16x16-brb.png")); + + /** + * The Not in office status. Indicates that the user is out of the office. + */ + public static final YahooStatusEnum NOT_IN_OFFICE + = new YahooStatusEnum(34, "Not in office", + loadIcon("resources/images/msn/msn16x16-phone.png")); + + /** + * The On vacation status. Indicates that the user is somewhere on the + * beach or skiing. + */ + public static final YahooStatusEnum ON_VACATION + = new YahooStatusEnum(33, "On vacation", + loadIcon("resources/images/msn/msn16x16-phone.png")); + + /** + * The DND status. Indicates that the user has connectivity but prefers + * not to be contacted. + */ + public static final YahooStatusEnum BUSY + = new YahooStatusEnum(30, "Busy", + loadIcon("resources/images/msn/msn16x16-busy.png")); + + /** + * The Offline status. Indicates the user does not seem to be connected + * to the network or at least does not want us to know she is + */ + public static final YahooStatusEnum OFFLINE + = new YahooStatusEnum(0, "Offline", + loadIcon("resources/images/msn/msn16x16-offline.png")); + + /** + * The minimal set of states that any implementation must support. + */ + public static final ArrayList msnStatusSet =new ArrayList(); + static{ + msnStatusSet.add(AVAILABLE); + msnStatusSet.add(BE_RIGHT_BACK); + msnStatusSet.add(BUSY); + msnStatusSet.add(IDLE); + msnStatusSet.add(INVISIBLE); + msnStatusSet.add(NOT_AT_DESK); + msnStatusSet.add(NOT_AT_HOME); + msnStatusSet.add(NOT_IN_OFFICE); + msnStatusSet.add(OFFLINE); + msnStatusSet.add(ON_THE_PHONE); + msnStatusSet.add(ON_VACATION); + msnStatusSet.add(OUT_TO_LUNCH); + msnStatusSet.add(STEPPED_OUT); + } + + /** + * Creates a status with the specified connectivity coeff, name and icon. + * @param status the connectivity coefficient for the specified status + * @param statusName String + * @param statusIcon the icon associated with this status + */ + protected YahooStatusEnum(int status, String statusName, byte[] statusIcon) + { + super(status, statusName, statusIcon); + } + + /** + * Loads an image from a given image path. + * @param imagePath The identifier of the image. + * @return The image for the given identifier. + */ + public static byte[] loadIcon(String imagePath) { + InputStream is = YahooStatusEnum.class.getClassLoader() + .getResourceAsStream(imagePath); + + byte[] icon = null; + try { + icon = new byte[is.available()]; + is.read(icon); + } catch (IOException exc) { + logger.error("Failed to load icon: " + imagePath, exc); + } + return icon; + } +} |