[sip-comm-cvs] CVS update: /sip-communicator/src/net/java/sip/communicator/impl/protocol/sip/SipStatusEnum.java

emcho at dev.java.net emcho at dev.java.net
Mon Apr 23 19:27:51 CEST 2007


User: emcho   
Date: 2007-04-23 17:27:51+0000
Log:
 adding phoney presence for the sip provider
 
 A number of phoney states that are currently supported by sip presence.

File Changes:

Directory: /sip-communicator/src/net/java/sip/communicator/impl/protocol/sip/
=============================================================================

File [added]: SipStatusEnum.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/impl/protocol/sip/SipStatusEnum.java?rev=1.1&content-type=text/vnd.viewcvs-markup
Added lines: 115
----------------
/*
 * 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.sip;

import java.util.*;

import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;
import java.io.*;

/**
 * An implementation of <tt>PresenceStatus</tt> that enumerates all states that
 * a SIP contact can currently have.
 *
 * @author Emil Ivov
 */
public class SipStatusEnum
    extends PresenceStatus
{
    private static final Logger logger
        = Logger.getLogger(SipStatusEnum.class);

    /**
     * Indicates an Offline status or status with 0 connectivity.
     */
    public static final SipStatusEnum OFFLINE
        = new SipStatusEnum(
            0
            , "Offline"
            , loadIcon("resources/images/sip/sip16x16-offline.png"));

    /**
     * The DND status. Indicates that the user has connectivity but prefers
     * not to be contacted.
     */
    public static final SipStatusEnum DO_NOT_DISTURB
        = new SipStatusEnum(
            30
            , "Do Not Disturb",
            loadIcon("resources/images/sip/sip16x16-dnd.png"));

    /**
     * The Online status. Indicate that the user is able and willing to
     * communicate.
     */
    public static final SipStatusEnum ONLINE
        = new SipStatusEnum(
            65
            , "Online"
            , loadIcon("resources/images/sip/sip16x16-online.png"));

    /**
     * Initialize the list of supported status states.
     */
    private static List supportedStatusSet = new LinkedList();
    static
    {
        supportedStatusSet.add(OFFLINE);
        supportedStatusSet.add(DO_NOT_DISTURB);
        supportedStatusSet.add(ONLINE);
    }

    /**
     * Creates an instance of <tt>SipPresneceStatus</tt> with the
     * specified parameters.
     * @param status the connectivity level of the new presence status instance
     * @param statusName the name of the presence status.
     * @param statusIcon the icon associated with this status
     */
    private SipStatusEnum(int status,
                                String statusName,
                                byte[] statusIcon)
    {
        super(status, statusName, statusIcon);
    }

    /**
     * Returns an iterator over all status instances supproted by the sip
     * provider.
     * @return an <tt>Iterator</tt> over all status instances supported by the
     * sip provider.
     */
    static Iterator supportedStatusSet()
    {
        return supportedStatusSet.iterator();
    }

    /**
     * Loads an image from a given image path.
     * @param imagePath The path to the image resource.
     * @return The image extracted from the resource at the specified path.
     */
    public static byte[] loadIcon(String imagePath)
    {
        InputStream is = SipStatusEnum.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;
    }

}




---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe at sip-communicator.dev.java.net
For additional commands, e-mail: cvs-help at sip-communicator.dev.java.net





More information about the commits mailing list