diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 824852418..2b0c79897 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -224,6 +224,8 @@ public: /*void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url)*/ newSubscriptionRequestId = env->GetMethodID(listenerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V"); + + authInfoRequestedId = env->GetMethodID(listenerClass,"authInfoRequested","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); /*void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);*/ notifyPresenceReceivedId = env->GetMethodID(listenerClass,"notifyPresenceReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;)V"); @@ -245,7 +247,7 @@ public: proxyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneProxyConfigImpl")); - proxyCtrId = env->GetMethodID(proxyClass,"", "(J)V"); + proxyCtrId = env->GetMethodID(proxyClass,"", "(Lorg/linphone/core/LinphoneCoreImpl;J)V"); callClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallImpl")); callCtrId = env->GetMethodID(callClass,"", "(J)V"); @@ -325,6 +327,7 @@ public: jmethodID transferStateId; jmethodID infoReceivedId; jmethodID subscriptionStateId; + jmethodID authInfoRequestedId; jmethodID publishStateId; jmethodID notifyRecvId; @@ -413,7 +416,19 @@ public: } static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username, const char *domain) { - + JNIEnv *env = 0; + jint result = jvm->AttachCurrentThread(&env,NULL); + if (result != 0) { + ms_error("cannot attach VM"); + return; + } + LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc); + env->CallVoidMethod(lcData->listener, + lcData->authInfoRequestedId, + lcData->core, + realm ? env->NewStringUTF(realm):NULL, + username ? env->NewStringUTF(username) : NULL, + domain ? env->NewStringUTF(domain) : NULL); } static void globalStateChange(LinphoneCore *lc, LinphoneGlobalState gstate,const char* message) { JNIEnv *env = 0; @@ -440,7 +455,7 @@ public: env->CallVoidMethod(lcData->listener ,lcData->registrationStateId ,lcData->core - ,env->NewObject(lcData->proxyClass,lcData->proxyCtrId,(jlong)proxy) + ,env->NewObject(lcData->proxyClass,lcData->proxyCtrId,lcData->core,(jlong)proxy) ,env->CallStaticObjectMethod(lcData->registrationStateClass,lcData->registrationStateFromIntId,(jint)state), message ? env->NewStringUTF(message) : NULL); } diff --git a/java/common/org/linphone/core/LinphoneCoreListener.java b/java/common/org/linphone/core/LinphoneCoreListener.java index 5d2ac5f5f..bd83172a9 100644 --- a/java/common/org/linphone/core/LinphoneCoreListener.java +++ b/java/common/org/linphone/core/LinphoneCoreListener.java @@ -28,7 +28,7 @@ import org.linphone.core.LinphoneCore.RemoteProvisioningState; public interface LinphoneCoreListener { /**< Ask the application some authentication information * @return */ - void authInfoRequested(LinphoneCore lc,String realm,String username); + void authInfoRequested(LinphoneCore lc, String realm, String username, String Domain); /** General State notification * @param state LinphoneCore.State diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java index 7a28a0867..66597ca81 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -192,7 +192,7 @@ class LinphoneCoreImpl implements LinphoneCore { isValid(); long lNativePtr = getDefaultProxyConfig(nativePtr); if (lNativePtr!=0) { - return new LinphoneProxyConfigImpl(lNativePtr); + return new LinphoneProxyConfigImpl(this,lNativePtr); } else { return null; } @@ -218,10 +218,12 @@ class LinphoneCoreImpl implements LinphoneCore { if (addProxyConfig(proxyCfg,nativePtr,((LinphoneProxyConfigImpl)proxyCfg).nativePtr) !=0) { throw new LinphoneCoreException("bad proxy config"); } + ((LinphoneProxyConfigImpl)proxyCfg).mCore=this; } public synchronized void removeProxyConfig(LinphoneProxyConfig proxyCfg) { isValid(); removeProxyConfig(nativePtr, ((LinphoneProxyConfigImpl)proxyCfg).nativePtr); + ((LinphoneProxyConfigImpl)proxyCfg).mCore=null; } public synchronized void clearAuthInfos() { isValid(); @@ -517,7 +519,7 @@ class LinphoneCoreImpl implements LinphoneCore { LinphoneProxyConfig[] proxies = new LinphoneProxyConfig[typesPtr.length]; for (int i=0; i < proxies.length; i++) { - proxies[i] = new LinphoneProxyConfigImpl(typesPtr[i]); + proxies[i] = new LinphoneProxyConfigImpl(this,typesPtr[i]); } return proxies; @@ -1137,7 +1139,7 @@ class LinphoneCoreImpl implements LinphoneCore { } @Override public synchronized LinphoneProxyConfig createProxyConfig() { - return new LinphoneProxyConfigImpl(createProxyConfig(nativePtr)); + return new LinphoneProxyConfigImpl(this,createProxyConfig(nativePtr)); } @Override public synchronized void setCallErrorTone(Reason reason, String path) { diff --git a/java/impl/org/linphone/core/LinphoneProxyConfigImpl.java b/java/impl/org/linphone/core/LinphoneProxyConfigImpl.java index 96b153733..a78819075 100644 --- a/java/impl/org/linphone/core/LinphoneProxyConfigImpl.java +++ b/java/impl/org/linphone/core/LinphoneProxyConfigImpl.java @@ -27,6 +27,7 @@ import org.linphone.core.LinphoneCore.RegistrationState; class LinphoneProxyConfigImpl implements LinphoneProxyConfig { protected final long nativePtr; + protected LinphoneCoreImpl mCore; private native int getState(long nativePtr); private native void setExpires(long nativePtr, int delay); @@ -41,9 +42,10 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { enableRegister(enableRegister); ownPtr=true; } - protected LinphoneProxyConfigImpl(long aNativePtr) { + protected LinphoneProxyConfigImpl(LinphoneCoreImpl core, long aNativePtr) { nativePtr = aNativePtr; ownPtr=false; + mCore=core; } protected void finalize() throws Throwable { //Log.e(LinphoneService.TAG,"fixme, should release underlying proxy config"); @@ -90,11 +92,17 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { } public void done() { - done(nativePtr); + Object mutex=mCore!=null ? mCore : this; + synchronized(mutex){ + done(nativePtr); + } } public LinphoneProxyConfig edit() { - edit(nativePtr); + Object mutex=mCore!=null ? mCore : this; + synchronized(mutex){ + edit(nativePtr); + } return this; } diff --git a/mediastreamer2 b/mediastreamer2 index 6aa698351..b76e3dde1 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 6aa6983512e5fa61ccdaaedc79f109993c5de04a +Subproject commit b76e3dde111af0d24be4ac5f1d4f633361e654c1