mirror of https://github.com/sipwise/jitsi.git
parent
a4521a845c
commit
c2d09bdf4d
|
After Width: | Height: | Size: 531 B |
|
After Width: | Height: | Size: 604 B |
|
After Width: | Height: | Size: 621 B |
|
After Width: | Height: | Size: 2.2 KiB |
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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.impl.protocol.icq;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
/**
|
||||
* Reperesents the Aim protocol icon. Implements the <tt>ProtocolIcon</tt>
|
||||
* interface in order to provide an aim icon image in two different sizes.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class ProtocolIconAimImpl
|
||||
implements ProtocolIcon
|
||||
{
|
||||
private static Logger logger = Logger.getLogger(ProtocolIconAimImpl.class);
|
||||
|
||||
/**
|
||||
* A hash table containing the protocol icon in different sizes.
|
||||
*/
|
||||
private static Hashtable iconsTable = new Hashtable();
|
||||
static {
|
||||
iconsTable.put(ProtocolIcon.ICON_SIZE_16x16,
|
||||
loadIcon("resources/images/aim/aim16x16-online.png"));
|
||||
|
||||
iconsTable.put(ProtocolIcon.ICON_SIZE_64x64,
|
||||
loadIcon("resources/images/aim/aim64x64.png"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the <tt>ProtocolIcon.getSupportedSizes()</tt> method. Returns
|
||||
* an iterator to a set containing the supported icon sizes.
|
||||
* @return an iterator to a set containing the supported icon sizes
|
||||
*/
|
||||
public Iterator getSupportedSizes()
|
||||
{
|
||||
return iconsTable.keySet().iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returne TRUE if a icon with the given size is supported, FALSE-otherwise.
|
||||
*/
|
||||
public boolean isSizeSupported(String iconSize)
|
||||
{
|
||||
return iconsTable.containsKey(iconSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the icon image in the given size.
|
||||
* @param iconSize the icon size; one of ICON_SIZE_XXX constants
|
||||
*/
|
||||
public byte[] getIcon(String iconSize)
|
||||
{
|
||||
return (byte[])iconsTable.get(iconSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the icon image used to represent the protocol connecting state.
|
||||
* @return the icon image used to represent the protocol connecting state
|
||||
*/
|
||||
public byte[] getConnectingIcon()
|
||||
{
|
||||
return loadIcon("resources/images/aim/cr16-action-aim_connecting.gif");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 = ProtocolIconAimImpl.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;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
package net.java.sip.communicator.service.protocol.aimconstants;
|
||||
|
||||
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 AIM (Oscar) 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 Emil Ivov
|
||||
*/
|
||||
public class AimStatusEnum
|
||||
extends PresenceStatus
|
||||
{
|
||||
|
||||
private static Logger logger = Logger.getLogger(AimStatusEnum.class);
|
||||
|
||||
/**
|
||||
* The Online AIM status. Indicate that the user is able and willing to
|
||||
* communicate.
|
||||
*/
|
||||
public static final AimStatusEnum ONLINE
|
||||
= new AimStatusEnum(65, "Online",
|
||||
loadIcon("resources/images/aim/aim16x16-online.png"));
|
||||
|
||||
/**
|
||||
* The Invisible AIM 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 AimStatusEnum INVISIBLE
|
||||
= new AimStatusEnum(45, "Invisible",
|
||||
loadIcon("resources/images/aim/aim16x16-invisible.png"));
|
||||
|
||||
/**
|
||||
* The Away AIM status. Indicates that the user has connectivity but might
|
||||
* not be able to immediately act upon initiation of communication.
|
||||
*/
|
||||
public static final AimStatusEnum AWAY
|
||||
= new AimStatusEnum(40, "Away",
|
||||
loadIcon("resources/images/aim/aim16x16-away.png"));
|
||||
|
||||
/**
|
||||
* The Offline AIM status. Indicates the user does not seem to be connected
|
||||
* to the AIM network or at least does not want us to know she is
|
||||
*/
|
||||
public static final AimStatusEnum OFFLINE
|
||||
= new AimStatusEnum(0, "Offline",
|
||||
loadIcon("resources/images/aim/aim16x16-offline.png"));
|
||||
|
||||
/**
|
||||
* The minimal set of states that any AIM implementation must support.
|
||||
*/
|
||||
public static final ArrayList aimStatusSet =new ArrayList();
|
||||
static{
|
||||
aimStatusSet.add(ONLINE);
|
||||
aimStatusSet.add(INVISIBLE);
|
||||
aimStatusSet.add(AWAY);
|
||||
aimStatusSet.add(OFFLINE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 AimStatusEnum(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 = AimStatusEnum.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…
Reference in new issue