mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-18 03:28:07 +00:00
Jni update proxyConfig wrapper
This commit is contained in:
parent
c18f904b29
commit
b5aeb7e755
5 changed files with 128 additions and 45 deletions
|
|
@ -77,6 +77,23 @@ extern "C" void libmswebrtc_init();
|
|||
}
|
||||
|
||||
|
||||
#define RETURN_PROXY_CONFIG_USER_DATA_OBJECT(javaclass, funcprefix, cobj) \
|
||||
{ \
|
||||
jclass jUserDataObjectClass; \
|
||||
jmethodID jUserDataObjectCtor; \
|
||||
jobject jUserDataObj; \
|
||||
jUserDataObj = (jobject)funcprefix ## _get_user_data(cobj); \
|
||||
if (jUserDataObj == NULL) { \
|
||||
jUserDataObjectClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/" javaclass)); \
|
||||
jUserDataObjectCtor = env->GetMethodID(jUserDataObjectClass,"<init>", "(J)V"); \
|
||||
jUserDataObj = env->NewObject(jUserDataObjectClass, jUserDataObjectCtor,(jlong) cobj); \
|
||||
jUserDataObj = env->NewGlobalRef(jUserDataObj); \
|
||||
funcprefix ## _set_user_data(cobj, jUserDataObj); \
|
||||
env->DeleteGlobalRef(jUserDataObjectClass); \
|
||||
} \
|
||||
return jUserDataObj; \
|
||||
}
|
||||
|
||||
|
||||
static JavaVM *jvm=0;
|
||||
static const char* LogDomain = "Linphone";
|
||||
|
|
@ -880,24 +897,32 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDefaultProxyConfig( J
|
|||
extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig( JNIEnv* env
|
||||
,jobject thiz
|
||||
,jlong lc) {
|
||||
|
||||
LinphoneProxyConfig *config=0;
|
||||
linphone_core_get_default_proxy((LinphoneCore*)lc,&config);
|
||||
return (jlong)config;
|
||||
}
|
||||
|
||||
extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getProxyConfigList(JNIEnv* env, jobject thiz, jlong lc) {
|
||||
static jobject getOrCreateProxy(JNIEnv* env,LinphoneProxyConfig* proxy){
|
||||
RETURN_PROXY_CONFIG_USER_DATA_OBJECT("LinphoneProxyConfigImpl", linphone_proxy_config, proxy);
|
||||
}
|
||||
|
||||
extern "C" jobjectArray Java_org_linphone_core_LinphoneCoreImpl_getProxyConfigList(JNIEnv* env, jobject thiz, jlong lc) {
|
||||
const MSList* proxies = linphone_core_get_proxy_config_list((LinphoneCore*)lc);
|
||||
int proxyCount = ms_list_size(proxies);
|
||||
jlongArray jProxies = env->NewLongArray(proxyCount);
|
||||
jlong *jInternalArray = env->GetLongArrayElements(jProxies, NULL);
|
||||
jclass cls = env->FindClass("java/lang/Object");
|
||||
jobjectArray jProxies = env->NewObjectArray(proxyCount,cls,NULL);
|
||||
|
||||
for (int i = 0; i < proxyCount; i++ ) {
|
||||
jInternalArray[i] = (unsigned long) (proxies->data);
|
||||
LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)proxies->data;
|
||||
jobject jproxy = getOrCreateProxy(env,proxy);
|
||||
if(jproxy != NULL){
|
||||
env->SetObjectArrayElement(jProxies, i, jproxy);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
proxies = proxies->next;
|
||||
}
|
||||
|
||||
env->ReleaseLongArrayElements(jProxies, jInternalArray, 0);
|
||||
|
||||
return jProxies;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1116,6 +1116,9 @@ void linphone_core_remove_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *cf
|
|||
linphone_proxy_config_enable_register(cfg,FALSE);
|
||||
linphone_proxy_config_done(cfg);
|
||||
linphone_proxy_config_update(cfg); /*so that it has an effect*/
|
||||
|
||||
/*as cfg no longer in proxies, unregister will never be issued*/
|
||||
_linphone_proxy_config_unregister(cfg);
|
||||
}
|
||||
if (lc->default_proxy==cfg){
|
||||
lc->default_proxy=NULL;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@ package org.linphone.core;
|
|||
*/
|
||||
public interface LinphoneProxyConfig {
|
||||
|
||||
public void setIsDeleted(boolean b);
|
||||
public boolean getIsDeleted();
|
||||
|
||||
/**
|
||||
*Starts editing a proxy configuration.
|
||||
*Because proxy configuration must be consistent, applications MUST call {@link #edit()} before doing any attempts to modify proxy configuration (such as identity, proxy address and so on).
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
private native String getRing(long nativePtr);
|
||||
private native void setRootCA(long nativePtr, String path);
|
||||
private native long[] listVideoPayloadTypes(long nativePtr);
|
||||
private native long[] getProxyConfigList(long nativePtr);
|
||||
private native LinphoneProxyConfig[] getProxyConfigList(long nativePtr);
|
||||
private native long[] getAuthInfosList(long nativePtr);
|
||||
private native long findAuthInfos(long nativePtr, String username, String realm, String domain);
|
||||
private native long[] listAudioPayloadTypes(long nativePtr);
|
||||
|
|
@ -190,7 +190,7 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
|
||||
public synchronized LinphoneProxyConfig getDefaultProxyConfig() {
|
||||
isValid();
|
||||
long lNativePtr = getDefaultProxyConfig(nativePtr);
|
||||
long lNativePtr = getDefaultProxyConfig(nativePtr);
|
||||
if (lNativePtr!=0) {
|
||||
return new LinphoneProxyConfigImpl(this,lNativePtr);
|
||||
} else {
|
||||
|
|
@ -224,6 +224,7 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
isValid();
|
||||
removeProxyConfig(nativePtr, ((LinphoneProxyConfigImpl)proxyCfg).nativePtr);
|
||||
((LinphoneProxyConfigImpl)proxyCfg).mCore=null;
|
||||
((LinphoneProxyConfigImpl)proxyCfg).deleteNativePtr();
|
||||
}
|
||||
public synchronized void clearAuthInfos() {
|
||||
isValid();
|
||||
|
|
@ -512,17 +513,8 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
setRootCA(nativePtr, path);
|
||||
}
|
||||
|
||||
public synchronized LinphoneProxyConfig[] getProxyConfigList() {
|
||||
long[] typesPtr = getProxyConfigList(nativePtr);
|
||||
if (typesPtr == null) return null;
|
||||
|
||||
LinphoneProxyConfig[] proxies = new LinphoneProxyConfig[typesPtr.length];
|
||||
|
||||
for (int i=0; i < proxies.length; i++) {
|
||||
proxies[i] = new LinphoneProxyConfigImpl(this,typesPtr[i]);
|
||||
}
|
||||
|
||||
return proxies;
|
||||
public synchronized LinphoneProxyConfig[] getProxyConfigList() {
|
||||
return getProxyConfigList(nativePtr);
|
||||
}
|
||||
|
||||
public synchronized PayloadType[] getVideoCodecs() {
|
||||
|
|
|
|||
|
|
@ -15,20 +15,17 @@ 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
*/
|
||||
package org.linphone.core;
|
||||
|
||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
|
||||
|
||||
protected final long nativePtr;
|
||||
protected long nativePtr;
|
||||
protected LinphoneCoreImpl mCore;
|
||||
|
||||
protected boolean isDeleting;
|
||||
|
||||
private native int getState(long nativePtr);
|
||||
private native void setExpires(long nativePtr, int delay);
|
||||
private native int getExpires(long nativePtr);
|
||||
|
|
@ -39,14 +36,40 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
|
|||
setIdentity(identity);
|
||||
setProxy(proxy);
|
||||
setRoute(route);
|
||||
setIsDeleted(false);
|
||||
enableRegister(enableRegister);
|
||||
ownPtr=true;
|
||||
}
|
||||
protected LinphoneProxyConfigImpl(LinphoneCoreImpl core, long aNativePtr) {
|
||||
|
||||
protected LinphoneProxyConfigImpl(LinphoneCoreImpl core,long aNativePtr) {
|
||||
mCore=core;
|
||||
nativePtr = aNativePtr;
|
||||
ownPtr=false;
|
||||
mCore=core;
|
||||
}
|
||||
|
||||
protected LinphoneProxyConfigImpl(long aNativePtr) {
|
||||
nativePtr = aNativePtr;
|
||||
ownPtr=false;
|
||||
}
|
||||
|
||||
public boolean getIsDeleted() {
|
||||
return isDeleting;
|
||||
}
|
||||
|
||||
public void setIsDeleted(boolean b) {
|
||||
isDeleting = b;
|
||||
}
|
||||
|
||||
private void isValid() {
|
||||
if (nativePtr == 0) {
|
||||
throw new RuntimeException("proxy config removed");
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteNativePtr() {
|
||||
nativePtr=0;
|
||||
}
|
||||
|
||||
protected void finalize() throws Throwable {
|
||||
//Log.e(LinphoneService.TAG,"fixme, should release underlying proxy config");
|
||||
if (ownPtr) delete(nativePtr);
|
||||
|
|
@ -56,42 +79,44 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
|
|||
|
||||
private native void edit(long ptr);
|
||||
private native void done(long ptr);
|
||||
|
||||
|
||||
private native void setIdentity(long ptr,String identity);
|
||||
private native String getIdentity(long ptr);
|
||||
private native int setProxy(long ptr,String proxy);
|
||||
private native String getProxy(long ptr);
|
||||
|
||||
|
||||
|
||||
private native void enableRegister(long ptr,boolean value);
|
||||
private native boolean isRegisterEnabled(long ptr);
|
||||
|
||||
|
||||
private native boolean isRegistered(long ptr);
|
||||
private native void setDialPrefix(long ptr, String prefix);
|
||||
private native String getDialPrefix(long ptr);
|
||||
|
||||
|
||||
private native String normalizePhoneNumber(long ptr,String number);
|
||||
|
||||
|
||||
private native String getDomain(long ptr);
|
||||
|
||||
|
||||
private native void setDialEscapePlus(long ptr, boolean value);
|
||||
private native boolean getDialEscapePlus(long ptr);
|
||||
|
||||
|
||||
private native String getRoute(long ptr);
|
||||
private native int setRoute(long ptr,String uri);
|
||||
private native void enablePublish(long ptr,boolean enable);
|
||||
private native boolean publishEnabled(long ptr);
|
||||
private native void setContactParameters(long ptr, String params);
|
||||
|
||||
|
||||
private native int lookupCCCFromIso(long nativePtr, String iso);
|
||||
private native int lookupCCCFromE164(long nativePtr, String e164);
|
||||
|
||||
|
||||
public LinphoneProxyConfig enableRegister(boolean value) {
|
||||
isValid();
|
||||
enableRegister(nativePtr,value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void done() {
|
||||
isValid();
|
||||
Object mutex=mCore!=null ? mCore : this;
|
||||
synchronized(mutex){
|
||||
done(nativePtr);
|
||||
|
|
@ -99,6 +124,7 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
|
|||
}
|
||||
|
||||
public LinphoneProxyConfig edit() {
|
||||
isValid();
|
||||
Object mutex=mCore!=null ? mCore : this;
|
||||
synchronized(mutex){
|
||||
edit(nativePtr);
|
||||
|
|
@ -107,139 +133,173 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
|
|||
}
|
||||
|
||||
public void setIdentity(String identity) throws LinphoneCoreException {
|
||||
isValid();
|
||||
setIdentity(nativePtr,identity);
|
||||
}
|
||||
|
||||
public void setProxy(String proxyUri) throws LinphoneCoreException {
|
||||
isValid();
|
||||
if (setProxy(nativePtr,proxyUri)!=0) {
|
||||
throw new LinphoneCoreException("Bad proxy address ["+proxyUri+"]");
|
||||
}
|
||||
}
|
||||
public String normalizePhoneNumber(String number) {
|
||||
isValid();
|
||||
return normalizePhoneNumber(nativePtr,number);
|
||||
}
|
||||
public void setDialPrefix(String prefix) {
|
||||
isValid();
|
||||
setDialPrefix(nativePtr, prefix);
|
||||
}
|
||||
public String getDialPrefix() {
|
||||
isValid();
|
||||
return getDialPrefix(nativePtr);
|
||||
}
|
||||
public String getDomain() {
|
||||
isValid();
|
||||
return getDomain(nativePtr);
|
||||
}
|
||||
public void setDialEscapePlus(boolean value) {
|
||||
setDialEscapePlus(nativePtr,value);
|
||||
isValid();
|
||||
setDialEscapePlus(nativePtr,value);
|
||||
}
|
||||
public boolean getDialEscapePlus() {
|
||||
isValid();
|
||||
return getDialEscapePlus(nativePtr);
|
||||
}
|
||||
public String getIdentity() {
|
||||
isValid();
|
||||
return getIdentity(nativePtr);
|
||||
}
|
||||
public String getProxy() {
|
||||
isValid();
|
||||
return getProxy(nativePtr);
|
||||
}
|
||||
public boolean isRegistered() {
|
||||
isValid();
|
||||
return isRegistered(nativePtr);
|
||||
}
|
||||
public boolean registerEnabled() {
|
||||
isValid();
|
||||
return isRegisterEnabled(nativePtr);
|
||||
}
|
||||
public String getRoute() {
|
||||
isValid();
|
||||
return getRoute(nativePtr);
|
||||
}
|
||||
public void setRoute(String routeUri) throws LinphoneCoreException {
|
||||
isValid();
|
||||
if (setRoute(nativePtr, routeUri) != 0) {
|
||||
throw new LinphoneCoreException("cannot set route ["+routeUri+"]");
|
||||
}
|
||||
}
|
||||
public void enablePublish(boolean enable) {
|
||||
isValid();
|
||||
enablePublish(nativePtr,enable);
|
||||
}
|
||||
public RegistrationState getState() {
|
||||
isValid();
|
||||
return RegistrationState.fromInt(getState(nativePtr));
|
||||
}
|
||||
|
||||
public void setExpires(int delay) {
|
||||
isValid();
|
||||
setExpires(nativePtr, delay);
|
||||
}
|
||||
public int getExpires() {
|
||||
isValid();
|
||||
return getExpires(nativePtr);
|
||||
}
|
||||
public boolean publishEnabled() {
|
||||
isValid();
|
||||
return publishEnabled(nativePtr);
|
||||
}
|
||||
@Override
|
||||
public void setContactParameters(String params) {
|
||||
isValid();
|
||||
setContactParameters(nativePtr, params);
|
||||
}
|
||||
@Override
|
||||
public int lookupCCCFromIso(String iso) {
|
||||
isValid();
|
||||
return lookupCCCFromIso(nativePtr, iso);
|
||||
}
|
||||
@Override
|
||||
public int lookupCCCFromE164(String e164) {
|
||||
isValid();
|
||||
return lookupCCCFromE164(nativePtr, e164);
|
||||
}
|
||||
private native int getError(long nativeptr);
|
||||
@Override
|
||||
public Reason getError() {
|
||||
isValid();
|
||||
return Reason.fromInt(getError(nativePtr));
|
||||
}
|
||||
private native void setPrivacy(long nativePtr, int mask);
|
||||
@Override
|
||||
public void setPrivacy(int privacy_mask) {
|
||||
isValid();
|
||||
setPrivacy(nativePtr,privacy_mask);
|
||||
}
|
||||
|
||||
private native int getPrivacy(long nativePtr);
|
||||
@Override
|
||||
public int getPrivacy() {
|
||||
isValid();
|
||||
return getPrivacy(nativePtr);
|
||||
}
|
||||
|
||||
|
||||
private native void enableAvpf(long nativePtr, boolean enable);
|
||||
@Override
|
||||
public void enableAvpf(boolean enable) {
|
||||
isValid();
|
||||
enableAvpf(nativePtr, enable);
|
||||
}
|
||||
|
||||
private native boolean avpfEnabled(long nativePtr);
|
||||
@Override
|
||||
public boolean avpfEnabled() {
|
||||
isValid();
|
||||
return avpfEnabled(nativePtr);
|
||||
}
|
||||
|
||||
|
||||
private native void setAvpfRRInterval(long nativePtr, int interval);
|
||||
@Override
|
||||
public void setAvpfRRInterval(int interval) {
|
||||
isValid();
|
||||
setAvpfRRInterval(nativePtr, interval);
|
||||
}
|
||||
|
||||
|
||||
private native int getAvpfRRInterval(long nativePtr);
|
||||
@Override
|
||||
public int getAvpfRRInterval() {
|
||||
isValid();
|
||||
return getAvpfRRInterval(nativePtr);
|
||||
}
|
||||
|
||||
|
||||
private native String getContactParameters(long ptr);
|
||||
@Override
|
||||
public String getContactParameters() {
|
||||
isValid();
|
||||
return getContactParameters(nativePtr);
|
||||
}
|
||||
|
||||
|
||||
private native void setContactUriParameters(long ptr, String params);
|
||||
@Override
|
||||
public void setContactUriParameters(String params) {
|
||||
isValid();
|
||||
setContactUriParameters(nativePtr,params);
|
||||
}
|
||||
|
||||
|
||||
private native String getContactUriParameters(long ptr);
|
||||
@Override
|
||||
public String getContactUriParameters() {
|
||||
isValid();
|
||||
return getContactUriParameters(nativePtr);
|
||||
}
|
||||
|
||||
private native long getErrorInfo(long nativePtr);
|
||||
|
||||
@Override
|
||||
public ErrorInfo getErrorInfo() {
|
||||
return new ErrorInfoImpl(getErrorInfo(nativePtr));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue