mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-18 03:28:07 +00:00
Add status if an account is linked + JNI
This commit is contained in:
parent
a47a9a9c06
commit
a5cdc5953c
6 changed files with 122 additions and 17 deletions
|
|
@ -101,6 +101,14 @@ void linphone_account_creator_cbs_set_activate_phone_number_link(LinphoneAccount
|
|||
cbs->activate_phone_number_link = cb;
|
||||
}
|
||||
|
||||
void linphone_account_creator_cbs_set_is_account_linked(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) {
|
||||
cbs->is_account_linked = cb;
|
||||
}
|
||||
|
||||
LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_account_linked(const LinphoneAccountCreatorCbs *cbs) {
|
||||
return cbs->is_account_linked;
|
||||
}
|
||||
|
||||
LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_account_activated(const LinphoneAccountCreatorCbs *cbs) {
|
||||
return cbs->is_account_activated;
|
||||
}
|
||||
|
|
@ -701,6 +709,36 @@ LinphoneAccountCreatorStatus linphone_account_creator_link_phone_number_with_acc
|
|||
linphone_xml_rpc_request_unref(request);
|
||||
return LinphoneAccountCreatorOK;
|
||||
}
|
||||
|
||||
static void _get_phone_number_for_account_cb(LinphoneXmlRpcRequest *request) {
|
||||
LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request);
|
||||
if (creator->callbacks->is_account_linked != NULL) {
|
||||
LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed;
|
||||
const char* resp = linphone_xml_rpc_request_get_string_response(request);
|
||||
if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) {
|
||||
status = (strcmp(resp, "ERROR_USERNAME_PARAMETER_NOT_FOUND") == 0
|
||||
|| strcmp(resp, "ERROR_ACCOUNT_DOESNT_EXIST") == 0
|
||||
|| strcmp(resp, "ERROR_ALIAS_DOESNT_EXIST") == 0) ? LinphoneAccountCreatorAccountNotLinked : LinphoneAccountCreatorAccountLinked;
|
||||
}
|
||||
creator->callbacks->link_phone_number_with_account(creator, status, resp);
|
||||
}
|
||||
}
|
||||
|
||||
LinphoneAccountCreatorStatus linphone_account_creator_is_account_linked(LinphoneAccountCreator *creator) {
|
||||
LinphoneXmlRpcRequest *request;
|
||||
if (!creator->username || !creator->domain) {
|
||||
return LinphoneAccountCreatorReqFailed;
|
||||
}
|
||||
request = linphone_xml_rpc_request_new_with_args("get_phone_number_for_account",LinphoneXmlRpcArgString,
|
||||
LinphoneXmlRpcArgString, creator->username,
|
||||
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), _get_phone_number_for_account_cb);
|
||||
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
|
||||
linphone_xml_rpc_request_unref(request);
|
||||
return LinphoneAccountCreatorOK;
|
||||
}
|
||||
/****************** END OF LINK PHONE NUMBER WITH ACCOUNT SECTION *************/
|
||||
|
||||
/****************** START OF ACTIVE PHONE NUMBER LINK **************************/
|
||||
|
|
|
|||
|
|
@ -49,6 +49,9 @@ typedef enum _LinphoneAccountCreatorStatus {
|
|||
LinphoneAccountCreatorAccountAlreadyActivated,
|
||||
LinphoneAccountCreatorAccountNotActivated,
|
||||
|
||||
LinphoneAccountCreatorAccountLinked,
|
||||
LinphoneAccountCreatorAccountNotLinked,
|
||||
|
||||
LinphoneAccountCreatorEmailInvalid,
|
||||
LinphoneAccountCreatorUsernameInvalid,
|
||||
LinphoneAccountCreatorUsernameTooShort,
|
||||
|
|
@ -312,6 +315,13 @@ LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_activate_p
|
|||
|
||||
LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_recover_phone_account(LinphoneAccountCreator *creator);
|
||||
|
||||
/**
|
||||
* Send an XML-RPC request to ask if an account is linked with a phone number
|
||||
* @param[in] creator LinphoneAccountCreator object
|
||||
* @return if this account is linked with a phone number
|
||||
**/
|
||||
LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_is_account_linked(LinphoneAccountCreator *creator);
|
||||
|
||||
/**
|
||||
* Configure an account (create a proxy config and authentication info for it).
|
||||
* @param[in] creator LinphoneAccountCreator object
|
||||
|
|
@ -346,6 +356,20 @@ LINPHONE_PUBLIC void *linphone_account_creator_cbs_get_user_data(const LinphoneA
|
|||
**/
|
||||
LINPHONE_PUBLIC void linphone_account_creator_cbs_set_user_data(LinphoneAccountCreatorCbs *cbs, void *ud);
|
||||
|
||||
/**
|
||||
* Get the current linked tested callback.
|
||||
* @param[in] cbs LinphoneAccountCreatorCbs object.
|
||||
* @return The current linked tested callback.
|
||||
**/
|
||||
LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_account_linked(const LinphoneAccountCreatorCbs *cbs);
|
||||
|
||||
/**
|
||||
* Set the linked tested callback
|
||||
* @param[in] cbs LinphoneAccountCreatorCbs object.
|
||||
* @param[in] cb The existence tested callback to be used.
|
||||
**/
|
||||
LINPHONE_PUBLIC void linphone_account_creator_cbs_set_is_account_linked(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb);
|
||||
|
||||
/**
|
||||
* Get the existence tested callback.
|
||||
* @param[in] cbs LinphoneAccountCreatorCbs object.
|
||||
|
|
|
|||
|
|
@ -8066,6 +8066,32 @@ static void account_creator_activate_phone_number_link(LinphoneAccountCreator *c
|
|||
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, "onAccountCreatorPhoneNumberLinkActivated","(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);
|
||||
}
|
||||
|
||||
static void account_creator_is_account_linked(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;
|
||||
}
|
||||
|
||||
LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
|
||||
jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs);
|
||||
|
|
@ -8078,7 +8104,7 @@ static void account_creator_activate_phone_number_link(LinphoneAccountCreator *c
|
|||
LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc);
|
||||
|
||||
jclass clazz = (jclass) env->GetObjectClass(listener);
|
||||
jmethodID method = env->GetMethodID(clazz, "onAccountCreatorPhoneNumberLinkActivated","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V");
|
||||
jmethodID method = env->GetMethodID(clazz, "onAccountCreatorIsAccountLinked","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V");
|
||||
env->DeleteLocalRef(clazz);
|
||||
|
||||
jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status);
|
||||
|
|
@ -8315,6 +8341,11 @@ extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_activateAccoun
|
|||
return (jint) linphone_account_creator_activate_account(account_creator);
|
||||
}
|
||||
|
||||
extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_isAccountLinked(JNIEnv *env, jobject thiz, jlong ptr) {
|
||||
LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr;
|
||||
return (jint) linphone_account_creator_is_account_linked(account_creator);
|
||||
}
|
||||
|
||||
extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_isAccountActivated(JNIEnv *env, jobject thiz, jlong ptr) {
|
||||
LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr;
|
||||
return (jint) linphone_account_creator_is_account_activated(account_creator);
|
||||
|
|
|
|||
|
|
@ -1335,6 +1335,7 @@ struct _LinphoneAccountCreatorCbs {
|
|||
LinphoneAccountCreatorCbsStatusCb link_phone_number_with_account;
|
||||
LinphoneAccountCreatorCbsStatusCb activate_phone_number_link;
|
||||
LinphoneAccountCreatorCbsStatusCb recover_phone_account;
|
||||
LinphoneAccountCreatorCbsStatusCb is_account_linked;
|
||||
};
|
||||
|
||||
BELLE_SIP_DECLARE_VPTR(LinphoneAccountCreatorCbs);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ public interface LinphoneAccountCreator {
|
|||
void onAccountCreatorPhoneNumberLinkActivated(LinphoneAccountCreator accountCreator, Status status);
|
||||
void onAccountCreatorIsAccountActivated(LinphoneAccountCreator accountCreator, Status status);
|
||||
void onAccountCreatorPhoneAccountRecovered(LinphoneAccountCreator accountCreator, Status status);
|
||||
void onAccountCreatorIsAccountLinked(LinphoneAccountCreator accountCreator, Status status);
|
||||
}
|
||||
|
||||
public static class Status {
|
||||
|
|
@ -48,21 +49,23 @@ public interface LinphoneAccountCreator {
|
|||
public final static Status AccountActivated = new Status(7, "AccountActivated");
|
||||
public final static Status AccountAlreadyActivated = new Status(8, "AccountAlreadyActivated");
|
||||
public final static Status AccountNotActivated = new Status(9, "AccountNotActivated");
|
||||
public final static Status EmailInvalid = new Status(10, "EmailInvalid");
|
||||
public final static Status UsernameInvalid = new Status(11, "UsernameInvalid");
|
||||
public final static Status UsernameTooShort = new Status(12, "UsernameTooShort");
|
||||
public final static Status UsernameTooLong = new Status(13, "UsernameTooLong");
|
||||
public final static Status UsernameInvalidSize = new Status(14, "UsernameInvalidSize");
|
||||
public final static Status PhoneNumberInvalid = new Status(15, "PhoneNumberInvalid");
|
||||
public final static Status PhoneNumberTooShort = new Status(16, "PhoneNumberTooShort");
|
||||
public final static Status PhoneNumberTooLong = new Status(17, "PhoneNumberTooLong");
|
||||
public final static Status PasswordTooShort = new Status(18, "PasswordTooShort");
|
||||
public final static Status PasswordTooLong = new Status(19, "PasswordTooLong");
|
||||
public final static Status DomainInvalid = new Status(20, "DomainInvalid");
|
||||
public final static Status RouteInvalid = new Status(21, "RouteInvalid");
|
||||
public final static Status DisplayNameInvalid = new Status(22, "DisplayNameInvalid");
|
||||
public final static Status TransportNotSupported = new Status(23, "TransportNotSupported");
|
||||
public final static Status CountryCodeInvalid = new Status(24, "CountryCodeInvalid");
|
||||
public final static Status AccountLinked = new Status(10, "AccountLinked");
|
||||
public final static Status AccountNotLinked = new Status(11, "AccountNotLinked");
|
||||
public final static Status EmailInvalid = new Status(12, "EmailInvalid");
|
||||
public final static Status UsernameInvalid = new Status(13, "UsernameInvalid");
|
||||
public final static Status UsernameTooShort = new Status(14, "UsernameTooShort");
|
||||
public final static Status UsernameTooLong = new Status(15, "UsernameTooLong");
|
||||
public final static Status UsernameInvalidSize = new Status(16, "UsernameInvalidSize");
|
||||
public final static Status PhoneNumberInvalid = new Status(17, "PhoneNumberInvalid");
|
||||
public final static Status PhoneNumberTooShort = new Status(18, "PhoneNumberTooShort");
|
||||
public final static Status PhoneNumberTooLong = new Status(19, "PhoneNumberTooLong");
|
||||
public final static Status PasswordTooShort = new Status(20, "PasswordTooShort");
|
||||
public final static Status PasswordTooLong = new Status(21, "PasswordTooLong");
|
||||
public final static Status DomainInvalid = new Status(22, "DomainInvalid");
|
||||
public final static Status RouteInvalid = new Status(23, "RouteInvalid");
|
||||
public final static Status DisplayNameInvalid = new Status(24, "DisplayNameInvalid");
|
||||
public final static Status TransportNotSupported = new Status(25, "TransportNotSupported");
|
||||
public final static Status CountryCodeInvalid = new Status(26, "CountryCodeInvalid");
|
||||
|
||||
private Status(int value, String stringValue) {
|
||||
mValue = value;
|
||||
|
|
@ -138,7 +141,9 @@ public interface LinphoneAccountCreator {
|
|||
Status linkPhoneNumberWithAccount();
|
||||
|
||||
Status activatePhoneNumberLink();
|
||||
|
||||
|
||||
Status isAccountLinked();
|
||||
|
||||
Status recoverPhoneAccount();
|
||||
|
||||
LinphoneProxyConfig configure();
|
||||
|
|
|
|||
|
|
@ -177,6 +177,12 @@ public class LinphoneAccountCreatorImpl implements LinphoneAccountCreator {
|
|||
public Status activateAccount() {
|
||||
return Status.fromInt(activateAccount(nativePtr));
|
||||
}
|
||||
|
||||
private native int isAccountLinked(long ptr);
|
||||
@Override
|
||||
public Status isAccountLinked() {
|
||||
return Status.fromInt(isAccountLinked(nativePtr));
|
||||
}
|
||||
|
||||
private native int isAccountActivated(long ptr);
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue