mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-31 08:25:38 +00:00
finished the JNI implementation of the status() method on Node
Signed-off-by: Grant Limberg <glimberg@gmail.com>
This commit is contained in:
parent
1a528aec76
commit
fa9d42b7e5
@ -43,7 +43,7 @@ namespace {
|
||||
jobject createResultObject(JNIEnv *env, ZT1_ResultCode code);
|
||||
jobject createVirtualNetworkStatus(JNIEnv *env, ZT1_VirtualNetworkStatus status);
|
||||
jobject createEvent(JNIEnv *env, ZT1_Event event);
|
||||
|
||||
|
||||
struct JniRef
|
||||
{
|
||||
JniRef()
|
||||
@ -804,7 +804,64 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_status
|
||||
ZT1_NodeStatus nodeStatus;
|
||||
ZT1_Node_status(node, &nodeStatus);
|
||||
|
||||
// TODO: copy data from C to Java
|
||||
static jfieldID addressField = NULL;
|
||||
static jfieldID publicIdentityField = NULL;
|
||||
static jfieldID secretIdentityField = NULL;
|
||||
static jfieldID onlineField = NULL;
|
||||
|
||||
if(addressField == NULL)
|
||||
{
|
||||
addressField = env->GetFieldID(nodeStatusClass, "address", "Lcom/zerotierone/sdk/NodeStatus;");
|
||||
if(addressField == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if(publicIdentityField == NULL)
|
||||
{
|
||||
publicIdentityField = env->GetFieldID(nodeStatusClass, "publicIdentity", "Lcom/zerotierone/sdk/NodeStatus;");
|
||||
if(publicIdentityField == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if(secretIdentityField == NULL)
|
||||
{
|
||||
secretIdentityField = env->GetFieldID(nodeStatusClass, "secretIdentity", "Lcom/zerotierone/sdk/NodeStatus;");
|
||||
if(secretIdentityField == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if(onlineField == NULL)
|
||||
{
|
||||
onlineField = env->GetFieldID(nodeStatusClass, "online", "Lcom/zerotierone/sdk/NodeStatus;");
|
||||
if(onlineField == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
env->SetIntField(nodeStatusObj, addressField, nodeStatus.address);
|
||||
|
||||
jstring pubIdentStr = env->NewStringUTF(nodeStatus.publicIdentity);
|
||||
if(pubIdentStr == NULL)
|
||||
{
|
||||
return NULL; // out of memory
|
||||
}
|
||||
env->SetObjectField(nodeStatusObj, publicIdentityField, pubIdentStr);
|
||||
|
||||
jstring secIdentStr = env->NewStringUTF(nodeStatus.secretIdentity);
|
||||
if(secIdentStr == NULL)
|
||||
{
|
||||
return NULL; // out of memory
|
||||
}
|
||||
env->SetObjectField(nodeStatusObj, secretIdentityField, secIdentStr);
|
||||
|
||||
env->SetBooleanField(nodeStatusObj, onlineField, nodeStatus.online);
|
||||
|
||||
return nodeStatusObj;
|
||||
}
|
||||
|
@ -31,21 +31,23 @@ public class NodeStatus {
|
||||
private long address;
|
||||
private String publicIdentity;
|
||||
private String secretIdentity;
|
||||
private int online;
|
||||
private boolean online;
|
||||
|
||||
public long getAddres() {
|
||||
private NodeStatus() {}
|
||||
|
||||
public final long getAddres() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public String getPublicIdentity() {
|
||||
public final String getPublicIdentity() {
|
||||
return publicIdentity;
|
||||
}
|
||||
|
||||
public String getSecretIdentity() {
|
||||
public final String getSecretIdentity() {
|
||||
return secretIdentity;
|
||||
}
|
||||
|
||||
public boolean isOnline() {
|
||||
return online != 0;
|
||||
public final boolean isOnline() {
|
||||
return online;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user