Commit 0ce2d7cd authored by Pierre-Eric Pelloux-Prayer's avatar Pierre-Eric Pelloux-Prayer
Browse files

android: replace State java class by an enum

parent b21ac0cc
...@@ -18,7 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -18,7 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package org.linphone.core; package org.linphone.core;
import java.util.Vector;
/** /**
* Object representing a Call. calls are created using {@link LinphoneCore#invite(LinphoneAddress)} or passed to the application by listener {@link LinphoneCoreListener#callState(LinphoneCore, LinphoneCall, State, String)} * Object representing a Call. calls are created using {@link LinphoneCore#invite(LinphoneAddress)} or passed to the application by listener {@link LinphoneCoreListener#callState(LinphoneCore, LinphoneCall, State, String)}
...@@ -30,104 +29,97 @@ public interface LinphoneCall { ...@@ -30,104 +29,97 @@ public interface LinphoneCall {
* Linphone call states * Linphone call states
* *
*/ */
static class State { enum State {
@SuppressWarnings("unchecked")
static private Vector values = new Vector();
private final int mValue;
private final String mStringValue;
/** /**
* Idle * Idle
*/ */
public final static State Idle = new State(0,"Idle"); Idle(0, "Idle"),
/** /**
* Incoming call received. * Incoming call received.
*/ */
public final static State IncomingReceived = new State(1,"IncomingReceived"); IncomingReceived(1, "IncomingReceived"),
/** /**
* Outgoing call initialiazed. * Outgoing call initialiazed.
*/ */
public final static State OutgoingInit = new State(2,"OutgoingInit"); OutgoingInit(2, "OutgoingInit"),
/** /**
* Outgoing call in progress. * Outgoing call in progress.
*/ */
public final static State OutgoingProgress = new State(3,"OutgoingProgress"); OutgoingProgress(3, "OutgoingProgress"),
/** /**
* Outgoing call ringing. * Outgoing call ringing.
*/ */
public final static State OutgoingRinging = new State(4,"OutgoingRinging"); OutgoingRinging(4, "OutgoingRinging"),
/** /**
* Outgoing call early media * Outgoing call early media
*/ */
public final static State OutgoingEarlyMedia = new State(5,"OutgoingEarlyMedia"); OutgoingEarlyMedia(5, "OutgoingEarlyMedia"),
/** /**
* Connected * Connected
*/ */
public final static State Connected = new State(6,"Connected"); Connected(6, "Connected"),
/** /**
* Streams running * Streams running
*/ */
public final static State StreamsRunning = new State(7,"StreamsRunning"); StreamsRunning(7, "StreamsRunning"),
/** /**
* Paussing * Pausing
*/ */
public final static State Pausing = new State(8,"Pausing"); Pausing(8, "Pausing"),
/** /**
* Paused * Paused
*/ */
public final static State Paused = new State(9,"Paused"); Paused(9, "Paused"),
/** /**
* Resuming * Resuming
*/ */
public final static State Resuming = new State(10,"Resuming"); Resuming(10, "Resuming"),
/** /**
* Refered * Refered
*/ */
public final static State Refered = new State(11,"Refered"); Refered(11,"Refered"),
/** /**
* Error * Error
*/ */
public final static State Error = new State(12,"Error"); Error(12,"Error"),
/** /**
* Call end * Call end
*/ */
public final static State CallEnd = new State(13,"CallEnd"); CallEnd(13,"CallEnd"),
/** /**
* Paused by remote * Paused by remote
*/ */
public final static State PausedByRemote = new State(14,"PausedByRemote"); PausedByRemote(14,"PausedByRemote"),
/** /**
* The call's parameters are updated, used for example when video is asked by remote * The call's parameters are updated, used for example when video is asked by remote
*/ */
public static final State CallUpdatedByRemote = new State(15, "CallUpdatedByRemote"); CallUpdatedByRemote(15, "CallUpdatedByRemote"),
/** /**
* We are proposing early media to an incoming call * We are proposing early media to an incoming call
*/ */
public static final State CallIncomingEarlyMedia = new State(16,"CallIncomingEarlyMedia"); CallIncomingEarlyMedia(16,"CallIncomingEarlyMedia"),
/** /**
* The remote accepted the call update initiated by us * The remote accepted the call update initiated by us
*/ */
public static final State CallUpdated = new State(17, "CallUpdated"); CallUpdated(17, "CallUpdated"),
/** /**
* The call object is now released. * The call object is now released.
*/ */
public static final State CallReleased = new State(18,"CallReleased"); CallReleased(18,"CallReleased");
@SuppressWarnings("unchecked")
private State(int value,String stringValue) { private final int mValue;
mValue = value; private final String mStringValue;
values.addElement(this); private State(int v, String desc) {
mStringValue=stringValue; this.mValue = v;
this.mStringValue = desc;
} }
public static State fromInt(int value) { public static State fromInt(int value) {
State[] allStates = State.values();
for (int i=0; i<values.size();i++) { for (int i=0; i<allStates.length;i++) {
State state = (State) values.elementAt(i); if (allStates[i].mValue == value)
if (state.mValue == value) return state; return allStates[i];
} }
throw new RuntimeException("state not found ["+value+"]"); throw new RuntimeException("state not found ["+value+"]");
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment