Icq and Jabber status enum icon associated to each status

cusax-fix
Yana Stamcheva 20 years ago
parent 9bd6757c4f
commit 4fbc8511c5

@ -1,8 +1,11 @@
package net.java.sip.communicator.service.protocol.icqconstants;
import java.io.*;
import java.util.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.jabberconstants.*;
import net.java.sip.communicator.util.*;
/**
* An enumeration containing all status instances that MUST be supported by
@ -18,19 +21,24 @@
public class IcqStatusEnum
extends PresenceStatus
{
private static Logger logger = Logger.getLogger(IcqStatusEnum.class);
/**
* The Free For Chat ICQ status. Indicates that the user is eager to
* communicate.
*/
public static final IcqStatusEnum FREE_FOR_CHAT
= new IcqStatusEnum(70, "Free For Chat");
= new IcqStatusEnum(85, "Free For Chat",
loadIcon("resources/images/icq/icq16x16-ffc.png"));
/**
* The Online ICQ status. Indicate that the user is able and willing to
* communicate.
*/
public static final IcqStatusEnum ONLINE = new IcqStatusEnum(65, "Online");
public static final IcqStatusEnum ONLINE
= new IcqStatusEnum(65, "Online",
loadIcon("resources/images/icq/icq16x16-online.png"));
/**
* The Invisible ICQ status. Indicates that the user has connectivity even
@ -38,13 +46,16 @@ public class IcqStatusEnum
* offline.
*/
public static final IcqStatusEnum INVISIBLE
= new IcqStatusEnum(45, "Invisible");
= new IcqStatusEnum(45, "Invisible",
loadIcon("resources/images/icq/icq16x16-invisible.png"));
/**
* The Away ICQ status. Indicates that the user has connectivity but might
* not be able to immediately act upon initiation of communication.
*/
public static final IcqStatusEnum AWAY = new IcqStatusEnum(40, "Away");
public static final IcqStatusEnum AWAY
= new IcqStatusEnum(40, "Away",
loadIcon("resources/images/icq/icq16x16-away.png"));
/**
@ -54,27 +65,32 @@ public class IcqStatusEnum
*
*/
public static final IcqStatusEnum NOT_AVAILABLE
= new IcqStatusEnum(35, "Not Available");
= new IcqStatusEnum(35, "Not Available",
loadIcon("resources/images/icq/icq16x16-na.png"));
/**
* The DND ICQ status. Indicates that the user has connectivity but prefers
* not to be contacted.
*/
public static final IcqStatusEnum DO_NOT_DISTURB
= new IcqStatusEnum(30, "Do Not Disturb");
= new IcqStatusEnum(30, "Do Not Disturb",
loadIcon("resources/images/icq/icq16x16-dnd.png"));
/**
* The Occupied ICQ status. Indicates that the user has connectivity and
* communication is particularly unwanted.
*/
public static final IcqStatusEnum OCCUPIED
= new IcqStatusEnum(25, "Occupied");
= new IcqStatusEnum(25, "Occupied",
loadIcon("resources/images/icq/icq16x16-occupied.png"));
/**
* The Offline ICQ status. Indicates the user does not seem to be connected
* to the ICQ network or at least does not want us to know she is
*/
public static final IcqStatusEnum OFFLINE = new IcqStatusEnum(0, "Offline");
public static final IcqStatusEnum OFFLINE
= new IcqStatusEnum(0, "Offline",
loadIcon("resources/images/icq/icq16x16-offline.png"));
/**
* The minimal set of states that any ICQ implementation must support.
@ -92,12 +108,32 @@ public class IcqStatusEnum
}
/**
* Creates a status with the specified connectivity coeff and name
* 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 IcqStatusEnum(int status, String statusName)
protected IcqStatusEnum(int status, String statusName, byte[] statusIcon)
{
super(status, statusName);
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 = JabberStatusEnum.class.getClassLoader()
.getResourceAsStream(imagePath);
byte[] icon = null;
try {
icon = new byte[is.available()];
is.read(icon);
} catch (IOException e) {
logger.error("Failed to load icon: " + imagePath, e);
}
return icon;
}
}

@ -1,8 +1,11 @@
package net.java.sip.communicator.service.protocol.jabberconstants;
import java.io.*;
import java.util.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.icqconstants.*;
import net.java.sip.communicator.util.*;
/**
* An enumeration containing all status instances that MUST be supported by
@ -18,19 +21,23 @@
public class JabberStatusEnum
extends PresenceStatus
{
private static Logger logger = Logger.getLogger(IcqStatusEnum.class);
/**
* The Free For Chat status. Indicates that the user is eager to
* communicate.
*/
public static final JabberStatusEnum FREE_FOR_CHAT
= new JabberStatusEnum(70, "Free For Chat");
= new JabberStatusEnum(70, "Free For Chat",
loadIcon("resources/images/jabber/jabber16x16-ffc.png"));
/**
* The Online status. Indicate that the user is able and willing to
* communicate.
*/
public static final JabberStatusEnum AVAILABLE = new JabberStatusEnum(65, "Available");
public static final JabberStatusEnum AVAILABLE
= new JabberStatusEnum(65, "Available",
loadIcon("resources/images/jabber/jabber16x16-online.png"));
/**
* The Invisible status. Indicates that the user has connectivity even
@ -38,13 +45,16 @@ public class JabberStatusEnum
* offline.
*/
public static final JabberStatusEnum INVISIBLE
= new JabberStatusEnum(45, "Invisible");
= new JabberStatusEnum(45, "Invisible",
loadIcon("resources/images/jabber/jabber16x16-invisible.png"));
/**
* The Away status. Indicates that the user has connectivity but might
* not be able to immediately act upon initiation of communication.
*/
public static final JabberStatusEnum AWAY = new JabberStatusEnum(40, "Away");
public static final JabberStatusEnum AWAY
= new JabberStatusEnum(40, "Away",
loadIcon("resources/images/jabber/jabber16x16-away.png"));
/**
@ -54,20 +64,24 @@ public class JabberStatusEnum
*
*/
public static final JabberStatusEnum EXTENDED_AWAY
= new JabberStatusEnum(35, "Extended Away");
= new JabberStatusEnum(35, "Extended Away",
loadIcon("resources/images/jabber/jabber16x16-na.png"));
/**
* The DND status. Indicates that the user has connectivity but prefers
* not to be contacted.
*/
public static final JabberStatusEnum DO_NOT_DISTURB
= new JabberStatusEnum(30, "Do Not Disturb");
= new JabberStatusEnum(30, "Do Not Disturb",
loadIcon("resources/images/jabber/jabber16x16-dnd.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 JabberStatusEnum OFFLINE = new JabberStatusEnum(0, "Offline");
public static final JabberStatusEnum OFFLINE
= new JabberStatusEnum(0, "Offline",
loadIcon("resources/images/jabber/jabber16x16-offline.png"));
/**
* The minimal set of states that any implementation must support.
@ -84,12 +98,32 @@ public class JabberStatusEnum
}
/**
* Creates a status with the specified connectivity coeff and name
* 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 JabberStatusEnum(int status, String statusName)
protected JabberStatusEnum(int status, String statusName, byte[] statusIcon)
{
super(status, statusName);
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 = JabberStatusEnum.class.getClassLoader()
.getResourceAsStream(imagePath);
byte[] icon = null;
try {
icon = new byte[is.available()];
is.read(icon);
} catch (IOException e) {
logger.error("Failed to load icon: " + imagePath, e);
}
return icon;
}
}

Loading…
Cancel
Save