add NetConnection state

This commit is contained in:
Doug MacEachern 2005-03-11 17:15:24 +00:00
parent 3c0527670c
commit 98761935f7
2 changed files with 17 additions and 0 deletions

View File

@ -739,6 +739,11 @@ my %classes = (
desc => '', desc => '',
plat => 'L' plat => 'L'
}, },
{
name => 'state', type => 'Int',
desc => '',
plat => 'L'
},
], ],
Who => [ Who => [
{ {
@ -1002,6 +1007,8 @@ my %extra_code = (
EOF EOF
NetConnection => <<'EOF', NetConnection => <<'EOF',
public native String getTypeString(); public native String getTypeString();
public native String getStateString();
EOF EOF
Mem => <<'EOF', Mem => <<'EOF',
public String toString() { public String toString() {

View File

@ -760,6 +760,16 @@ JNIEXPORT jstring SIGAR_JNI(NetConnection_getTypeString)
sigar_net_connection_type_get(type)); sigar_net_connection_type_get(type));
} }
JNIEXPORT jstring SIGAR_JNI(NetConnection_getStateString)
(JNIEnv *env, jobject obj)
{
jclass cls = JENV->GetObjectClass(env, obj);
jfieldID field = JENV->GetFieldID(env, cls, "state", "I");
jint type = JENV->GetIntField(env, obj, field);
return JENV->NewStringUTF(env,
sigar_net_connection_state_get(type));
}
JNIEXPORT jobjectArray SIGAR_JNI(Sigar_getWhoList) JNIEXPORT jobjectArray SIGAR_JNI(Sigar_getWhoList)
(JNIEnv *env, jobject sigar_obj) (JNIEnv *env, jobject sigar_obj)
{ {