pass relayStatus an enum rather than an int

This commit is contained in:
eehouse 2010-03-08 06:15:37 +00:00
parent 285e1b47d5
commit e73c6d1234
3 changed files with 16 additions and 11 deletions

View file

@ -85,10 +85,14 @@ and_xport_relayStatus( void* closure, CommsRelayState newState )
AndTransportProcs* aprocs = (AndTransportProcs*)closure;
if ( NULL != aprocs->jxport ) {
JNIEnv* env = *aprocs->envp;
const char* sig = "(I)V";
const char* sig = "(Lorg/eehouse/android/xw4/jni/"
"TransportProcs$CommsRelayState;)V";
jmethodID mid = getMethodID( env, aprocs->jxport, "relayStatus", sig );
(*env)->CallVoidMethod( env, aprocs->jxport, mid, newState );
jobject jenum = intToJEnum( env, newState, "org/eehouse/android/xw4/jni/"
"TransportProcs$CommsRelayState" );
(*env)->CallVoidMethod( env, aprocs->jxport, mid, jenum );
(*env)->DeleteLocalRef( env, jenum );
}
}

View file

@ -291,9 +291,9 @@ public class CommsTransport extends Thread implements TransportProcs {
return nSent;
}
public void relayStatus( int newState )
public void relayStatus( CommsRelayState newState )
{
Utils.logf( "relayStatus called; state=" + newState );
Utils.logf( "relayStatus called; state=%s", newState.toString() );
}
public void relayConnd( boolean allHere, int nMissing )

View file

@ -6,13 +6,14 @@ package org.eehouse.android.xw4.jni;
public interface TransportProcs {
int transportSend( byte[] buf, final CommsAddrRec addr );
public static final int COMMS_RELAYSTATE_UNCONNECTED = 0;
public static final int COMMS_RELAYSTATE_DENIED = 1;
public static final int COMMS_RELAYSTATE_CONNECT_PENDING = 2;
public static final int COMMS_RELAYSTATE_CONNECTED = 3;
public static final int COMMS_RELAYSTATE_RECONNECTED = 4;
public static final int COMMS_RELAYSTATE_ALLCONNECTED = 5;
void relayStatus( int newState );
enum CommsRelayState { COMMS_RELAYSTATE_UNCONNECTED
, COMMS_RELAYSTATE_DENIED
, COMMS_RELAYSTATE_CONNECT_PENDING
, COMMS_RELAYSTATE_CONNECTED
, COMMS_RELAYSTATE_RECONNECTED
, COMMS_RELAYSTATE_ALLCONNECTED
};
void relayStatus( CommsRelayState newState );
void relayConnd( boolean allHere, int nMissing );