mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-23 06:08:07 +00:00
Add JNI for update password
This commit is contained in:
parent
4749f195b8
commit
a988e996ca
5 changed files with 61 additions and 5 deletions
|
|
@ -375,7 +375,7 @@ const char * linphone_account_creator_get_password(const LinphoneAccountCreator
|
|||
return creator->password;
|
||||
}
|
||||
|
||||
LinphoneAccountCreator _password_updated_cb(LinphoneXmlRpcRequest *request) {
|
||||
static void _password_updated_cb(LinphoneXmlRpcRequest *request) {
|
||||
LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request);
|
||||
if (creator->callbacks->update_hash != NULL) {
|
||||
LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed;
|
||||
|
|
@ -390,13 +390,22 @@ LinphoneAccountCreator _password_updated_cb(LinphoneXmlRpcRequest *request) {
|
|||
}
|
||||
}
|
||||
creator->callbacks->update_hash(creator, status, resp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LinphoneAccountCreatorStatus linphone_account_creator_update_password(const LinphoneAccountCreator *creator, const char *new_pwd){
|
||||
LinphoneAccountCreatorStatus linphone_account_creator_update_password(LinphoneAccountCreator *creator, const char *new_pwd){
|
||||
LinphoneXmlRpcRequest *request;
|
||||
char *identity = _get_identity(creator);
|
||||
if (!identity || (!creator->username && !creator->phone_number
|
||||
&& !creator->domain && (!creator->password || !creator->ha1))) {
|
||||
if (creator->callbacks->update_hash != NULL) {
|
||||
creator->callbacks->update_hash(creator, LinphoneAccountCreatorReqFailed, "Missing required parameters");
|
||||
}
|
||||
return LinphoneAccountCreatorReqFailed;
|
||||
}
|
||||
|
||||
const char * username = creator->username ? creator->username : creator->phone_number;
|
||||
const char * ha1 = ms_strdup(creator->password ? ha1_for_passwd(username, creator->domain, creator->password) : creator->ha1);
|
||||
const char * ha1 = ms_strdup(creator->ha1 ? creator->ha1 : ha1_for_passwd(username, creator->domain, creator->password) );
|
||||
const char * new_ha1 = ms_strdup(ha1_for_passwd(username, creator->domain, new_pwd));
|
||||
|
||||
request = linphone_xml_rpc_request_new_with_args("update_hash", LinphoneXmlRpcArgString,
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ LINPHONE_PUBLIC const char * linphone_account_creator_get_username(const Linphon
|
|||
* @param[in] new_pwd const char * : new password for the account creator
|
||||
* @return LinphoneAccountCreatorOk if everything is OK, or a specific error otherwise.
|
||||
**/
|
||||
LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_update_password(const LinphoneAccountCreator *creator, const char *new_pwd);
|
||||
LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_update_password(LinphoneAccountCreator *creator, const char *new_pwd);
|
||||
|
||||
/**
|
||||
* Set the phone number normalized.
|
||||
|
|
|
|||
|
|
@ -8224,6 +8224,34 @@ static void account_creator_phone_account_recovered(LinphoneAccountCreator *crea
|
|||
env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject);
|
||||
}
|
||||
|
||||
static void account_creator_password_updated(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) {
|
||||
JNIEnv *env = 0;
|
||||
jint result = jvm->AttachCurrentThread(&env,NULL);
|
||||
if (result != 0) {
|
||||
ms_error("cannot attach VM\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ms_warning("test callback password updated");
|
||||
|
||||
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, "onAccountCreatorPasswordUpdated","(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);
|
||||
|
|
@ -8253,6 +8281,7 @@ extern "C" void Java_org_linphone_core_LinphoneAccountCreatorImpl_setListener(JN
|
|||
linphone_account_creator_cbs_set_recover_phone_account(cbs, account_creator_phone_account_recovered);
|
||||
linphone_account_creator_cbs_set_is_phone_number_used(cbs, account_creator_is_phone_number_used);
|
||||
linphone_account_creator_cbs_set_is_account_linked(cbs, account_creator_is_account_linked);
|
||||
linphone_account_creator_cbs_set_update_hash(cbs, account_creator_password_updated);
|
||||
}
|
||||
|
||||
extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setUsername(JNIEnv *env, jobject thiz, jlong ptr, jstring jusername) {
|
||||
|
|
@ -8451,6 +8480,15 @@ extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_recoverPhoneAc
|
|||
return (jint) linphone_account_creator_recover_phone_account(account_creator);
|
||||
}
|
||||
|
||||
extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_updatePassword(JNIEnv *env, jobject thiz, jlong ptr, jstring jpasswd) {
|
||||
jint status;
|
||||
LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr;
|
||||
const char* passwd = GetStringUTFChars(env, jpasswd);
|
||||
status = (jint) linphone_account_creator_update_password(account_creator, passwd);
|
||||
ReleaseStringUTFChars(env, jpasswd, passwd);
|
||||
return status;
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ public interface LinphoneAccountCreator {
|
|||
void onAccountCreatorPhoneAccountRecovered(LinphoneAccountCreator accountCreator, Status status);
|
||||
void onAccountCreatorIsAccountLinked(LinphoneAccountCreator accountCreator, Status status);
|
||||
void onAccountCreatorIsPhoneNumberUsed(LinphoneAccountCreator accountCreator, Status status);
|
||||
void onAccountCreatorPasswordUpdated(LinphoneAccountCreator accountCreator, Status status);
|
||||
}
|
||||
|
||||
public static class Status {
|
||||
|
|
@ -157,5 +158,7 @@ public interface LinphoneAccountCreator {
|
|||
|
||||
Status recoverPhoneAccount();
|
||||
|
||||
Status updatePassword(String newPassword);
|
||||
|
||||
LinphoneProxyConfig configure();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -226,6 +226,12 @@ public class LinphoneAccountCreatorImpl implements LinphoneAccountCreator {
|
|||
return Status.fromInt(recoverPhoneAccount(nativePtr));
|
||||
}
|
||||
|
||||
private native int updatePassword(long ptr, String newPassword);
|
||||
@Override
|
||||
public Status updatePassword(String newPassword) {
|
||||
return Status.fromInt(updatePassword(nativePtr, newPassword));
|
||||
}
|
||||
|
||||
private native LinphoneProxyConfig configure(long ptr);
|
||||
@Override
|
||||
public LinphoneProxyConfig configure() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue