Commit 9e159035 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

JNI wrapper for account creator + fixes

parent fbb24ec8
......@@ -705,7 +705,7 @@ LinphoneAccountCreatorStatus linphone_account_creator_activate_phone_number_link
LinphoneXmlRpcArgString, ha1_for_passwd(creator->username, creator->password, 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), _is_account_activated_cb);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _activate_phone_number_link_cb);
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
linphone_xml_rpc_request_unref(request);
return LinphoneAccountCreatorOK;
......
This diff is collapsed.
......@@ -117,7 +117,7 @@ LINPHONE_PUBLIC int linphone_dial_plan_lookup_ccc_from_e164(const char* e164);
/**
* Return NULL-terminated array of all known dial plans
**/
LINPHONE_PUBLIC const LinphoneDialPlan* linphone_dial_plan_get_all();
LINPHONE_PUBLIC const LinphoneDialPlan* linphone_dial_plan_get_all(void);
/**
* Find best match for given CCC
......
/*LinphoneAccountCreator.java
Copyright (C) 2016 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.linphone.core;
import java.util.Vector;
import org.linphone.core.LinphoneAddress.TransportType;
public interface LinphoneAccountCreator {
interface LinphoneAccountCreatorListener {
void onAccountCreatorIsAccountUsed(LinphoneAccountCreator accountCreator, Status status);
void onAccountCreatorAccountCreated(LinphoneAccountCreator accountCreator, Status status);
void onAccountCreatorAccountActivated(LinphoneAccountCreator accountCreator, Status status);
void onAccountCreatorAccountLinkedWithPhoneNumber(LinphoneAccountCreator accountCreator, Status status);
void onAccountCreatorPhoneNumberLinkActivated(LinphoneAccountCreator accountCreator, Status status);
void onAccountCreatorIsAccountActivated(LinphoneAccountCreator accountCreator, Status status);
}
public static class Status {
static private Vector<Status> values = new Vector<Status>();
private final int mValue;
private final String mStringValue;
public final int value() { return mValue; }
public final static Status Ok = new Status(0, "Ok");
public final static Status Failed = new Status(1, "Failed");
public final static Status AccountCreated = new Status(2, "AccountCreated");
public final static Status AccountNotCreated = new Status(3, "AccountNotCreated");
public final static Status AccountExist = new Status(4, "AccountExist");
public final static Status AccountNotExist = new Status(5, "AccountNotExist");
public final static Status AccountActivated = new Status(6, "AccountActivated");
public final static Status AccountAlreadyActivated = new Status(7, "AccountAlreadyActivated");
public final static Status AccountNotActivated = new Status(8, "AccountNotActivated");
public final static Status EmailInvalid = new Status(9, "EmailInvalid");
public final static Status UsernameInvalid = new Status(10, "UsernameInvalid");
public final static Status UsernameTooShort = new Status(11, "UsernameTooShort");
public final static Status UsernameTooLong = new Status(12, "UsernameTooLong");
public final static Status UsernameInvalidSize = new Status(13, "UsernameInvalidSize");
public final static Status PhoneNumberInvalid = new Status(14, "PhoneNumberInvalid");
public final static Status PhoneNumberTooShort = new Status(15, "PhoneNumberTooShort");
public final static Status PhoneNumberTooLong = new Status(16, "PhoneNumberTooLong");
public final static Status PasswordTooShort = new Status(17, "PasswordTooShort");
public final static Status PasswordTooLong = new Status(18, "PasswordTooLong");
public final static Status DomainInvalid = new Status(19, "DomainInvalid");
public final static Status RouteInvalid = new Status(20, "RouteInvalid");
public final static Status DisplayNameInvalid = new Status(21, "DisplayNameInvalid");
public final static Status TransportNotSupported = new Status(22, "TransportNotSupported");
private Status(int value, String stringValue) {
mValue = value;
values.addElement(this);
mStringValue = stringValue;
}
public static Status fromInt(int value) {
for (int i=0; i < values.size(); i++) {
Status state = (Status) values.elementAt(i);
if (state.mValue == value) return state;
}
throw new RuntimeException("Status not found [" + value + "]");
}
public String toString() {
return mStringValue;
}
public int toInt() {
return mValue;
}
}
void setListener(LinphoneAccountCreatorListener listener);
Status setUsername(String username);
String getUsername();
Status setPhoneNumber(String phoneNumber, String countryCode);
String getPhoneNumber();
Status setPassword(String password);
String getPassword();
Status setActivationCode(String activationCode);
Status setTransport(TransportType transport);
TransportType getTransport();
Status setDomain(String domain);
String getDomain();
Status setRoute(String route);
String getRoute();
Status setDisplayName(String displayName);
String getDisplayName();
Status setEmail(String email);
String getEmail();
Status isAccountUsed();
Status createAccount();
Status activateAccount();
Status isAccountActivated();
Status linkPhoneNumberWithAccount();
Status activatePhoneNumberLink();
LinphoneProxyConfig configure();
}
/*LinphoneAccountCreatorImpl.java
Copyright (C) 2016 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.linphone.core;
import org.linphone.core.LinphoneAddress.TransportType;
public class LinphoneAccountCreatorImpl implements LinphoneAccountCreator {
protected long nativePtr;
protected LinphoneAccountCreatorImpl(long aNativePtr) {
nativePtr = aNativePtr;
}
private native long newLinphoneAccountCreator(long lc, String url);
public LinphoneAccountCreatorImpl(LinphoneCore lc, String url) {
nativePtr = newLinphoneAccountCreator(((LinphoneCoreImpl)lc).nativePtr, url);
}
public long getNativePtr() {
return nativePtr;
}
private native void unref(long ptr);
protected void finalize() {
unref(nativePtr);
}
private native void setListener(long ptr, LinphoneAccountCreatorListener listener);
@Override
public void setListener(LinphoneAccountCreatorListener listener) {
setListener(nativePtr, listener);
}
private native int setUsername(long ptr, String username);
@Override
public Status setUsername(String username) {
return Status.fromInt(setUsername(nativePtr, username));
}
private native String getUsername(long ptr);
@Override
public String getUsername() {
return getUsername(nativePtr);
}
private native int setPhoneNumber(long ptr, String phoneNumber, String countryCode);
@Override
public Status setPhoneNumber(String phoneNumber, String countryCode) {
return Status.fromInt(setPhoneNumber(nativePtr, phoneNumber, countryCode));
}
private native String getPhoneNumber(long ptr);
@Override
public String getPhoneNumber() {
return getPhoneNumber(nativePtr);
}
private native int setPassword(long ptr, String password);
@Override
public Status setPassword(String password) {
return Status.fromInt(setPassword(nativePtr, password));
}
private native String getPassword(long ptr);
@Override
public String getPassword() {
return getPassword(nativePtr);
}
private native int setActivationCode(long ptr, String activationCode);
@Override
public Status setActivationCode(String activationCode) {
return Status.fromInt(setActivationCode(nativePtr, activationCode));
}
private native int setTransport(long ptr, int transport);
@Override
public Status setTransport(TransportType transport) {
return Status.fromInt(setTransport(nativePtr, transport.toInt()));
}
private native int getTransport(long ptr);
@Override
public TransportType getTransport() {
return TransportType.fromInt(getTransport(nativePtr));
}
private native int setDomain(long ptr, String domain);
@Override
public Status setDomain(String domain) {
return Status.fromInt(setDomain(nativePtr, domain));
}
private native String getDomain(long ptr);
@Override
public String getDomain() {
return getDomain(nativePtr);
}
private native int setRoute(long ptr, String route);
@Override
public Status setRoute(String route) {
return Status.fromInt(setRoute(nativePtr, route));
}
private native String getRoute(long ptr);
@Override
public String getRoute() {
return getRoute(nativePtr);
}
private native int setDisplayName(long ptr, String displayName);
@Override
public Status setDisplayName(String displayName) {
return Status.fromInt(setDisplayName(nativePtr, displayName));
}
private native String getDisplayName(long ptr);
@Override
public String getDisplayName() {
return getDisplayName(nativePtr);
}
private native int setEmail(long ptr, String email);
@Override
public Status setEmail(String email) {
return Status.fromInt(setEmail(nativePtr, email));
}
private native String getEmail(long ptr);
@Override
public String getEmail() {
return getEmail(nativePtr);
}
private native int isAccountUsed(long ptr);
@Override
public Status isAccountUsed() {
return Status.fromInt(isAccountUsed(nativePtr));
}
private native int createAccount(long ptr);
@Override
public Status createAccount() {
return Status.fromInt(createAccount(nativePtr));
}
private native int activateAccount(long ptr);
@Override
public Status activateAccount() {
return Status.fromInt(activateAccount(nativePtr));
}
private native int linkPhoneNumberWithAccount(long ptr);
@Override
public Status isAccountActivated() {
return Status.fromInt(linkPhoneNumberWithAccount(nativePtr));
}
private native int isAccounlinkPhoneNumberWithAccounttUsed(long ptr);
@Override
public Status linkPhoneNumberWithAccount() {
return Status.fromInt(isAccounlinkPhoneNumberWithAccounttUsed(nativePtr));
}
private native int activatePhoneNumberLink(long ptr);
@Override
public Status activatePhoneNumberLink() {
return Status.fromInt(activatePhoneNumberLink(nativePtr));
}
private native LinphoneProxyConfig configure(long ptr);
@Override
public LinphoneProxyConfig configure() {
return configure(nativePtr);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment