mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-30 09:49:26 +00:00
Change your password in linphone settings
This commit is contained in:
parent
c1e5007667
commit
a95e3ce0fe
3 changed files with 48 additions and 0 deletions
|
|
@ -367,6 +367,45 @@ const char * linphone_account_creator_get_password(const LinphoneAccountCreator
|
|||
return creator->password;
|
||||
}
|
||||
|
||||
LinphoneAccountCreator _password_updated_cb(LinphoneXmlRpcRequest *request) {
|
||||
LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request);
|
||||
if (creator->callbacks->password_updated != NULL) {
|
||||
LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed;
|
||||
const char* resp = linphone_xml_rpc_request_get_string_response(request);
|
||||
if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) {
|
||||
if (strcmp(resp, "OK") == 0) {
|
||||
status = LinphoneAccountCreatorOK;
|
||||
} else if (strcmp(resp, "ERROR_PASSWORD_DOESNT_MATCH") == 0) {
|
||||
status = LinphoneAccountCreatorAccountNotExist;
|
||||
} else {
|
||||
status = LinphoneAccountCreatorErrorServer;
|
||||
}
|
||||
}
|
||||
creator->callbacks->password_updated(creator, status, resp);
|
||||
}
|
||||
}
|
||||
|
||||
LinphoneAccountCreatorStatus linphone_account_creator_update_password(const LinphoneAccountCreator *creator, const char *new_pwd){
|
||||
LinphoneXmlRpcRequest *request;
|
||||
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 * new_ha1 = ms_strdup(ha1_for_passwd(username, creator->domain, new_pwd));
|
||||
|
||||
request = linphone_xml_rpc_request_new_with_args("update_hash", LinphoneXmlRpcArgString,
|
||||
LinphoneXmlRpcArgString, username,
|
||||
LinphoneXmlRpcArgString, ha1,
|
||||
LinphoneXmlRpcArgString, new_ha1,
|
||||
LinphoneXmlRpcArgString, creator->domain,
|
||||
LinphoneXmlRpcArgNone);
|
||||
|
||||
linphone_xml_rpc_request_set_user_data(request, creator);
|
||||
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _password_updated_cb);
|
||||
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
|
||||
linphone_xml_rpc_request_unref(request);
|
||||
|
||||
return LinphoneAccountCreatorOK;
|
||||
}
|
||||
|
||||
LinphoneAccountCreatorStatus linphone_account_creator_set_ha1(LinphoneAccountCreator *creator, const char *ha1){
|
||||
set_string(&creator->ha1, ha1, FALSE);
|
||||
return LinphoneAccountCreatorOK;
|
||||
|
|
|
|||
|
|
@ -145,6 +145,14 @@ LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_userna
|
|||
**/
|
||||
LINPHONE_PUBLIC const char * linphone_account_creator_get_username(const LinphoneAccountCreator *creator);
|
||||
|
||||
/**
|
||||
* Update the password.
|
||||
* @param[in] creator LinphoneAccountCreator object
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Set the phone number normalized.
|
||||
* @param[in] creator LinphoneAccountCreator object
|
||||
|
|
|
|||
|
|
@ -1342,6 +1342,7 @@ struct _LinphoneAccountCreatorCbs {
|
|||
LinphoneAccountCreatorCbsStatusCb activate_phone_number_link;
|
||||
LinphoneAccountCreatorCbsStatusCb recover_phone_account;
|
||||
LinphoneAccountCreatorCbsStatusCb is_account_linked;
|
||||
LinphoneAccountCreatorCbsStatusCb password_updated;
|
||||
};
|
||||
|
||||
BELLE_SIP_DECLARE_VPTR(LinphoneAccountCreatorCbs);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue