Commit 50f9d358 authored by Sylvain Berfini's avatar Sylvain Berfini

Changes made to JNI and Java to match previous AuthInfo changes

parent 811b453d
......@@ -161,7 +161,7 @@ public class TutorialBuddyStatus implements LinphoneCoreListener {
if (mySipPassword != null) {
// create authentication structure from identity and add to linphone
lc.addAuthInfo(lcFactory.createAuthInfo(username, mySipPassword, null));
lc.addAuthInfo(lcFactory.createAuthInfo(username, mySipPassword, null, domain));
}
// create proxy config
......
......@@ -131,7 +131,7 @@ public class TutorialRegistration implements LinphoneCoreListener {
if (password != null) {
// create authentication structure from identity and add to linphone
lc.addAuthInfo(lcFactory.createAuthInfo(username, password, null));
lc.addAuthInfo(lcFactory.createAuthInfo(username, password, null, domain));
}
// create proxy config
......
......@@ -392,7 +392,7 @@ public:
static void displayMessageCb(LinphoneCore *lc, const char *message) {
}
static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username) {
static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username, const char *domain) {
}
static void globalStateChange(LinphoneCore *lc, LinphoneGlobalState gstate,const char* message) {
......@@ -850,13 +850,16 @@ extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getAuthInfosList(J
return jAuthInfos;
}
extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findAuthInfos(JNIEnv* env, jobject thiz, jlong lc, jstring jusername, jstring jrealm) {
extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findAuthInfos(JNIEnv* env, jobject thiz, jlong lc, jstring jusername, jstring jrealm, jstring jdomain) {
const char* username = env->GetStringUTFChars(jusername, NULL);
const char* realm = jrealm ? env->GetStringUTFChars(jrealm, NULL) : NULL;
const LinphoneAuthInfo *authInfo = linphone_core_find_auth_info((LinphoneCore*)lc, realm, username);
const char* domain = jdomain ? env->GetStringUTFChars(jdomain, NULL) : NULL;
const LinphoneAuthInfo *authInfo = linphone_core_find_auth_info((LinphoneCore*)lc, realm, username, domain);
if (realm)
env->ReleaseStringUTFChars(jrealm, realm);
if (domain)
env->ReleaseStringUTFChars(jdomain, domain);
env->ReleaseStringUTFChars(jusername, username);
return (jlong) authInfo;
......@@ -870,18 +873,18 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_refreshRegisters(JNIEnv*
linphone_core_refresh_registers((LinphoneCore*)lc);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo( JNIEnv* env
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo(JNIEnv* env
,jobject thiz
,jlong lc
,jlong pc) {
linphone_core_add_auth_info((LinphoneCore*)lc,(LinphoneAuthInfo*)pc);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_iterate( JNIEnv* env
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_iterate(JNIEnv* env
,jobject thiz
,jlong lc) {
linphone_core_iterate((LinphoneCore*)lc);
}
extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_invite( JNIEnv* env
extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_invite(JNIEnv* env
,jobject thiz
,jlong lc
,jstring juri) {
......@@ -891,7 +894,7 @@ extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_invite( JNIEnv* env
env->ReleaseStringUTFChars(juri, uri);
return lcd->getCall(env,lCall);
}
extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddress( JNIEnv* env
extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddress(JNIEnv* env
,jobject thiz
,jlong lc
,jlong to) {
......@@ -899,38 +902,38 @@ extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddress( JNIEnv
return lcd->getCall(env, linphone_core_invite_address((LinphoneCore*)lc,(LinphoneAddress*)to));
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall( JNIEnv* env
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall(JNIEnv* env
,jobject thiz
,jlong lc
,jlong call) {
linphone_core_terminate_call((LinphoneCore*)lc,(LinphoneCall*)call);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_declineCall( JNIEnv* env
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_declineCall(JNIEnv* env
,jobject thiz
,jlong lc
,jlong call, jint reason) {
linphone_core_decline_call((LinphoneCore*)lc,(LinphoneCall*)call,(LinphoneReason)reason);
}
extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress( JNIEnv* env
extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress(JNIEnv* env
,jobject thiz
,jlong lc) {
return (jlong)linphone_core_get_current_call_remote_address((LinphoneCore*)lc);
}
extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall( JNIEnv* env
extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall(JNIEnv* env
,jobject thiz
,jlong lc) {
return (jboolean)linphone_core_in_call((LinphoneCore*)lc);
}
extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending( JNIEnv* env
extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending(JNIEnv* env
,jobject thiz
,jlong lc) {
return (jboolean)linphone_core_inc_invite_pending((LinphoneCore*)lc);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall( JNIEnv* env
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall(JNIEnv* env
,jobject thiz
,jlong lc
,jlong call) {
......@@ -1523,7 +1526,6 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_getPasswor
} else {
return NULL;
}
}
/*
* Class: org_linphone_core_LinphoneAuthInfoImpl
......@@ -1538,7 +1540,21 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_getRealm
} else {
return NULL;
}
}
/*
* Class: org_linphone_core_LinphoneAuthInfoImpl
* Method: getDomain
* Signature: (J)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_getDomain
(JNIEnv *env , jobject, jlong auth_info) {
const char* domain = linphone_auth_info_get_domain((LinphoneAuthInfo*)auth_info);
if (domain) {
return env->NewStringUTF(domain);
} else {
return NULL;
}
}
/*
......@@ -1579,6 +1595,20 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setRealm
linphone_auth_info_set_realm((LinphoneAuthInfo*)auth_info,realm);
if (realm) env->ReleaseStringUTFChars(jrealm, realm);
}
/*
* Class: org_linphone_core_LinphoneAuthInfoImpl
* Method: setDomain
* Signature: (JLjava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setDomain
(JNIEnv *env, jobject, jlong auth_info, jstring jdomain) {
const char* domain = jdomain ? env->GetStringUTFChars(jdomain, NULL) : NULL;
linphone_auth_info_set_domain((LinphoneAuthInfo*)auth_info, domain);
if (domain)
env->ReleaseStringUTFChars(jdomain, domain);
}
/*
* Class: org_linphone_core_LinphoneAuthInfoImpl
* Method: setUsername
......
......@@ -83,6 +83,23 @@ public interface LinphoneAuthInfo {
*/
void setHa1(String ha1);
/**
* Sets the domain
* @param domain
*/
void setDomain(String domain);
/**
* Gets the domain
* @return the domain
*/
String getDomain();
/**
* Clones a current auth info
* @return the clone auth info
*/
LinphoneAuthInfo clone();
}
......@@ -399,7 +399,7 @@ public interface LinphoneCore {
/**
* Returns a matching auth info or null if no match found
*/
LinphoneAuthInfo findAuthInfo(String username, String realm);
LinphoneAuthInfo findAuthInfo(String username, String realm, String domain);
/**
* Removes a auth info.
* @param authInfo
......
......@@ -54,7 +54,7 @@ abstract public class LinphoneCoreFactory {
* @param userid user id as set in auth header
* @param passwd
* */
abstract public LinphoneAuthInfo createAuthInfo(String username,String password, String realm);
abstract public LinphoneAuthInfo createAuthInfo(String username,String password, String realm, String domain);
/**
* create {@link LinphoneAuthInfo}
* @param username
......@@ -63,7 +63,7 @@ abstract public class LinphoneCoreFactory {
* @param ha1
* @param realm
* */
abstract public LinphoneAuthInfo createAuthInfo(String username, String userid, String passwd, String ha1,String realm);
abstract public LinphoneAuthInfo createAuthInfo(String username, String userid, String passwd, String ha1, String realm, String domain);
abstract public LinphoneCore createLinphoneCore(LinphoneCoreListener listener, String userConfig,String factoryConfig,Object userdata) throws LinphoneCoreException;
abstract public LinphoneCore createLinphoneCore(LinphoneCoreListener listener) throws LinphoneCoreException;
......
......@@ -32,17 +32,20 @@ class LinphoneAuthInfoImpl implements LinphoneAuthInfo {
private native void setHa1(long ptr, String ha1);
private native String getUserId(long ptr);
private native String getHa1(long ptr);
private native String getDomain(long ptr);
private native void setDomain(long ptr, String domain);
boolean ownPtr = false;
protected LinphoneAuthInfoImpl(String username,String password, String realm) {
this(username,null,password,null,null);
protected LinphoneAuthInfoImpl(String username,String password, String realm, String domain) {
this(username, null, password, null, null, domain);
}
protected LinphoneAuthInfoImpl(String username, String userid, String passwd, String ha1,String realm) {
protected LinphoneAuthInfoImpl(String username, String userid, String passwd, String ha1, String realm, String domain) {
nativePtr = newLinphoneAuthInfo();
this.setUsername(username);
this.setUserId(userid);
this.setPassword(passwd);
this.setHa1(ha1);
this.setDomain(domain);
ownPtr = true;
}
protected LinphoneAuthInfoImpl(long aNativePtr) {
......@@ -88,4 +91,23 @@ class LinphoneAuthInfoImpl implements LinphoneAuthInfo {
setHa1(nativePtr,ha1);
}
@Override
public void setDomain(String domain) {
setDomain(nativePtr, domain);
}
@Override
public String getDomain() {
return getDomain(nativePtr);
}
public LinphoneAuthInfo clone() {
LinphoneAuthInfo clone = LinphoneCoreFactory.instance().createAuthInfo(
getUsername(),
getUserId(),
getPassword(),
getHa1(),
getRealm(),
getDomain());
return clone;
}
}
......@@ -72,8 +72,8 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory {
}
@Override
public LinphoneAuthInfo createAuthInfo(String username, String password,
String realm) {
return new LinphoneAuthInfoImpl(username,password,realm);
String realm, String domain) {
return new LinphoneAuthInfoImpl(username, password, realm, domain);
}
@Override
......@@ -145,8 +145,8 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory {
@Override
public LinphoneAuthInfo createAuthInfo(String username, String userid,
String passwd, String ha1, String realm) {
return new LinphoneAuthInfoImpl(username,userid,passwd,ha1,realm);
String passwd, String ha1, String realm, String domain) {
return new LinphoneAuthInfoImpl(username, userid, passwd, ha1, realm, domain);
}
@Override
......
......@@ -107,7 +107,7 @@ class LinphoneCoreImpl implements LinphoneCore {
private native long[] listVideoPayloadTypes(long nativePtr);
private native long[] getProxyConfigList(long nativePtr);
private native long[] getAuthInfosList(long nativePtr);
private native long findAuthInfos(long nativePtr, String username, String realm);
private native long findAuthInfos(long nativePtr, String username, String realm, String domain);
private native long[] listAudioPayloadTypes(long nativePtr);
private native void enableKeepAlive(long nativePtr,boolean enable);
private native boolean isKeepAliveEnabled(long nativePtr);
......@@ -1070,8 +1070,8 @@ class LinphoneCoreImpl implements LinphoneCore {
return authInfos;
}
public LinphoneAuthInfo findAuthInfo(String username, String realm) {
long ptr = findAuthInfos(nativePtr, username, realm);
public LinphoneAuthInfo findAuthInfo(String username, String realm, String domain) {
long ptr = findAuthInfos(nativePtr, username, realm, domain);
if (ptr == 0)
return null;
......
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