JNI wrapper for newly added account creator method

This commit is contained in:
Sylvain Berfini 2016-08-08 09:59:14 +02:00
parent 7b2e4bd4e2
commit 6f1e96c8f6
4 changed files with 41 additions and 2 deletions

View file

@ -266,8 +266,6 @@ LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_is_account
**/
LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_create_account(LinphoneAccountCreator *creator);
LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_recover_account(LinphoneAccountCreator *creator);
/**
* Send an XML-RPC request to activate a Linphone account.
* @param[in] creator LinphoneAccountCreator object

View file

@ -7919,6 +7919,32 @@ static void account_creator_is_account_activated(LinphoneAccountCreator *creator
env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject);
}
static void account_creator_phone_account_recovered(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status) {
JNIEnv *env = 0;
jint result = jvm->AttachCurrentThread(&env,NULL);
if (result != 0) {
ms_error("cannot attach VM\n");
return;
}
LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs);
if (listener == NULL) {
ms_error("account_creator_response() notification without listener");
return ;
}
LinphoneCore *lc = (LinphoneCore *)creator->core;
LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc);
jclass clazz = (jclass) env->GetObjectClass(listener);
jmethodID method = env->GetMethodID(clazz, "onAccountCreatorPhoneAccountRecovered","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V");
env->DeleteLocalRef(clazz);
jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status);
env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject);
}
extern "C" jlong Java_org_linphone_core_LinphoneAccountCreatorImpl_newLinphoneAccountCreator(JNIEnv *env, jobject thiz, jlong core, jstring jurl) {
const char *url = GetStringUTFChars(env, jurl);
LinphoneAccountCreator *account_creator = linphone_account_creator_new((LinphoneCore *)core, url);
@ -7945,6 +7971,7 @@ extern "C" void Java_org_linphone_core_LinphoneAccountCreatorImpl_setListener(JN
linphone_account_creator_cbs_set_link_phone_number_with_account(cbs, account_creator_link_phone_number_with_account);
linphone_account_creator_cbs_set_activate_phone_number_link(cbs, account_creator_activate_phone_number_link);
linphone_account_creator_cbs_set_is_account_activated(cbs, account_creator_is_account_activated);
linphone_account_creator_cbs_set_recover_phone_account(cbs, account_creator_phone_account_recovered);
}
extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setUsername(JNIEnv *env, jobject thiz, jlong ptr, jstring jusername) {
@ -8097,6 +8124,11 @@ extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_activatePhoneN
return (jint) linphone_account_creator_activate_phone_number_link(account_creator);
}
extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_recoverPhoneAccount(JNIEnv *env, jobject thiz, jlong ptr) {
LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr;
return (jint) linphone_account_creator_recover_phone_account(account_creator);
}
extern "C" jobject Java_org_linphone_core_LinphoneAccountCreatorImpl_configure(JNIEnv *env, jobject thiz, jlong ptr) {
LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr;
LinphoneProxyConfig *lpc = linphone_account_creator_configure(account_creator);

View file

@ -29,6 +29,7 @@ public interface LinphoneAccountCreator {
void onAccountCreatorAccountLinkedWithPhoneNumber(LinphoneAccountCreator accountCreator, Status status);
void onAccountCreatorPhoneNumberLinkActivated(LinphoneAccountCreator accountCreator, Status status);
void onAccountCreatorIsAccountActivated(LinphoneAccountCreator accountCreator, Status status);
void onAccountCreatorPhoneAccountRecovered(LinphoneAccountCreator accountCreator, Status status);
}
public static class Status {
@ -132,5 +133,7 @@ public interface LinphoneAccountCreator {
Status activatePhoneNumberLink();
Status recoverPhoneAccount();
LinphoneProxyConfig configure();
}

View file

@ -184,6 +184,12 @@ public class LinphoneAccountCreatorImpl implements LinphoneAccountCreator {
return Status.fromInt(activatePhoneNumberLink(nativePtr));
}
private native int recoverPhoneAccount(long ptr);
@Override
public Status recoverPhoneAccount() {
return Status.fromInt(recoverPhoneAccount(nativePtr));
}
private native LinphoneProxyConfig configure(long ptr);
@Override
public LinphoneProxyConfig configure() {