Add error server status for xmlrpc

This commit is contained in:
Erwan Croze 2016-10-12 15:16:56 +02:00
parent f9fe0fa968
commit 788f6cc4fc
3 changed files with 12 additions and 3 deletions

View file

@ -559,7 +559,11 @@ static void _create_account_cb(LinphoneXmlRpcRequest *request) {
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, "OK") == 0) ? LinphoneAccountCreatorAccountCreated : LinphoneAccountCreatorAccountNotCreated;
status = (strcmp(resp, "OK") == 0) ? LinphoneAccountCreatorAccountCreated
: (strcmp(resp, "ERROR_CANNOT_SEND_SMS") == 0) ? LinphoneAccountCreatorErrorServer
: (strcmp(resp, "ERROR_ACCOUNT_ALREADY_IN_USE") == 0) ? LinphoneAccountCreatorAccountExist
: (strcmp(resp, "ERROR_ALIAS_ALREADY_IN_USE") == 0) ? LinphoneAccountCreatorAccountExistWithAlias
:LinphoneAccountCreatorAccountNotCreated;
}
creator->callbacks->create_account(creator, status, resp);
}
@ -853,7 +857,9 @@ static void _recover_phone_account_cb(LinphoneXmlRpcRequest *request) {
const char* resp = linphone_xml_rpc_request_get_string_response(request);
if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) {
if (strstr(resp, "ERROR_") == resp) {
status = LinphoneAccountCreatorReqFailed;
status = (strstr(resp, "ERROR_CANNOT_SEND_SMS") == resp) ? LinphoneAccountCreatorErrorServer
: (strstr(resp, "ERROR_ACCOUNT_DOESNT_EXIST") == resp) ? LinphoneAccountCreatorAccountNotExist
: LinphoneAccountCreatorReqFailed;
} else {
status = LinphoneAccountCreatorOK;
set_string(&creator->username, resp, FALSE);

View file

@ -74,6 +74,8 @@ typedef enum _LinphoneAccountCreatorStatus {
LinphoneAccountCreatorDisplayNameInvalid,
LinphoneAccountCreatorTransportNotSupported,
LinphoneAccountCreatorCountryCodeInvalid,
LinphoneAccountCreatorErrorServer,
} LinphoneAccountCreatorStatus;
/**

View file

@ -70,6 +70,7 @@ public interface LinphoneAccountCreator {
public final static Status DisplayNameInvalid = new Status(27, "DisplayNameInvalid");
public final static Status TransportNotSupported = new Status(28, "TransportNotSupported");
public final static Status CountryCodeInvalid = new Status(29, "CountryCodeInvalid");
public final static Status ErrorServeur = new Status(30, "ErrorServer");
private Status(int value, String stringValue) {
mValue = value;
@ -113,7 +114,7 @@ public interface LinphoneAccountCreator {
String getHa1();
Status setActivationCode(String activationCode);
Status setLanguage(String lang);
Status setTransport(TransportType transport);