/*
 * 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 Away  status. Indicates that the user has connectivity but might
     * not be able to immediately act upon initiation of communication.
     */
    public static final SipStatusEnum AWAY
        = new SipStatusEnum(
            40,
            "Away",
            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"));
    
    /**
     * The Unknown status. Indicate that we don't know if the user is present
     * or not.
     */
    public static final SipStatusEnum UNKNOWN = new SipStatusEnum(
            1,
            "Unknown",
            loadIcon("resources/images/sip/sip16x16-offline.png"));

    /**
     * Initialize the list of supported status states.
     */
    private static List supportedStatusSet = new LinkedList();
    static
    {
        supportedStatusSet.add(OFFLINE);
        supportedStatusSet.add(AWAY);
        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;
    }

}

@@ -2204,30 +2204,29 @@
     */%0A    p
-rivate
+ublic
  static List
@@ -2314,18 +2314,17 @@
 et.add(O
-FF
+N
 LINE);%0A 
@@ -2353,20 +2353,30 @@
 Set.add(
-AWAY
+DO_NOT_DISTURB
 );%0A     
@@ -2397,38 +2397,28 @@
 atusSet.add(
-DO_NOT_DISTURB
+AWAY
 );%0A        s
@@ -2432,33 +2432,34 @@
 dStatusSet.add(O
-N
+FF
 LINE);%0A    %7D%0A%0A  

reorder the presence statuses for sip