From d5f765da2ff9ceeceec1dfaec8cec7508a674746 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 5 Jul 2017 14:21:18 +0200 Subject: [PATCH] Added get/set domain and configure to AccountCreator JNI wrapper --- coreapi/linphonecore_jni.cc | 14 +++++++ .../linphone/core/LinphoneAccountCreator.java | 38 +++++++++++++++++++ .../core/LinphoneAccountCreatorImpl.java | 18 +++++++++ 3 files changed, 70 insertions(+) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 8bbaef977..ad6726f24 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -8761,6 +8761,20 @@ extern "C" jstring Java_org_linphone_core_LinphoneAccountCreatorImpl_getEmail(JN return email ? env->NewStringUTF(email) : NULL; } +extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setDomain(JNIEnv *env, jobject thiz, jlong ptr, jstring jdomain) { + const char *domain = GetStringUTFChars(env, jdomain); + LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; + LinphoneAccountCreatorDomainStatus status = linphone_account_creator_set_domain(account_creator, domain); + ReleaseStringUTFChars(env, jdomain, domain); + return (jint) status; +} + +extern "C" jstring Java_org_linphone_core_LinphoneAccountCreatorImpl_getDomain(JNIEnv *env, jobject thiz, jlong ptr) { + LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; + const char *email = linphone_account_creator_get_domain(account_creator); + return email ? env->NewStringUTF(email) : NULL; +} + extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_isAccountUsed(JNIEnv *env, jobject thiz, jlong ptr) { LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; return (jint) linphone_account_creator_is_account_exist(account_creator); diff --git a/java/common/org/linphone/core/LinphoneAccountCreator.java b/java/common/org/linphone/core/LinphoneAccountCreator.java index 4b716521d..0b5bd4a18 100644 --- a/java/common/org/linphone/core/LinphoneAccountCreator.java +++ b/java/common/org/linphone/core/LinphoneAccountCreator.java @@ -138,6 +138,38 @@ public interface LinphoneAccountCreator { } } + public static class DomainCheck { + static private Vector values = new Vector(); + private final int mValue; + private final String mStringValue; + public final int value() { return mValue; } + + public final static DomainCheck Ok = new DomainCheck(0, "Ok"); + public final static DomainCheck Invalid = new DomainCheck(1, "Invalid"); + + private DomainCheck(int value, String stringValue) { + mValue = value; + values.addElement(this); + mStringValue = stringValue; + } + + public static DomainCheck fromInt(int value) { + for (int i=0; i < values.size(); i++) { + DomainCheck state = (DomainCheck) values.elementAt(i); + if (state.mValue == value) return state; + } + throw new RuntimeException("DomainCheck not found [" + value + "]"); + } + + public String toString() { + return mStringValue; + } + + public int toInt() { + return mValue; + } + } + public static class PasswordCheck { static private Vector values = new Vector(); private final int mValue; @@ -323,6 +355,12 @@ public interface LinphoneAccountCreator { String getPrefix(String phone); + DomainCheck setDomain(String domain); + + String getDomain(); + + LinphoneProxyConfig configure(); + RequestStatus isAccountUsed(); RequestStatus createAccount(); diff --git a/java/impl/org/linphone/core/LinphoneAccountCreatorImpl.java b/java/impl/org/linphone/core/LinphoneAccountCreatorImpl.java index 6519a693e..526c63f9a 100644 --- a/java/impl/org/linphone/core/LinphoneAccountCreatorImpl.java +++ b/java/impl/org/linphone/core/LinphoneAccountCreatorImpl.java @@ -134,6 +134,24 @@ public class LinphoneAccountCreatorImpl implements LinphoneAccountCreator { return getPrefix(nativePtr, phone); } + private native int setDomain(long ptr, String domain); + @Override + public DomainCheck setDomain(String domain) { + return DomainCheck.fromInt(setDomain(nativePtr, domain)); + } + + private native String getDomain(long ptr); + @Override + public String getDomain() { + return getDomain(nativePtr); + } + + private native LinphoneProxyConfig configure(long ptr); + @Override + public LinphoneProxyConfig configure() { + return configure(nativePtr); + } + private native int isAccountUsed(long ptr); @Override public RequestStatus isAccountUsed() {