From 572b696529119810350e083cec72e59b2d3e75d5 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 27 Apr 2010 14:51:30 +0200 Subject: [PATCH] cleanup LinphonecoreFactory --- coreapi/linphonecore_jni.cc | 2 +- .../linphone/core/LinphoneCoreFactory.java | 39 ++++++++++++------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index e65193e3b..4c595cd0e 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -51,7 +51,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved) //LinphoneFactory -extern "C" void Java_org_linphone_core_LinphoneCoreFactory_setDebugMode(JNIEnv* env +extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setDebugMode(JNIEnv* env ,jobject thiz ,jboolean isDebug) { if (isDebug) { diff --git a/java/org/linphone/core/LinphoneCoreFactory.java b/java/org/linphone/core/LinphoneCoreFactory.java index 24315f6dd..87572c3bd 100644 --- a/java/org/linphone/core/LinphoneCoreFactory.java +++ b/java/org/linphone/core/LinphoneCoreFactory.java @@ -21,33 +21,44 @@ package org.linphone.core; import java.io.File; import java.io.IOException; -public class LinphoneCoreFactory { + +abstract public class LinphoneCoreFactory { + private static String defaulfFactory = "org.linphone.core.LinphoneCoreFactoryImpl"; static { System.loadLibrary("linphone"); } - static LinphoneCoreFactory theLinphoneCoreFactory = new LinphoneCoreFactory(); + static LinphoneCoreFactory theLinphoneCoreFactory; + /** + * Indicate the name of the class used by this factory + * @param pathName + */ + static void setFactoryClassName (String className) { + defaulfFactory = className; + } public static LinphoneCoreFactory instance() { - + try { + if (theLinphoneCoreFactory == null) { + Class lFactoryClass = Class.forName(defaulfFactory); + theLinphoneCoreFactory = (LinphoneCoreFactory) lFactoryClass.newInstance(); + } + } catch (Exception e) { + System.err.println("cannot instanciate factory ["+defaulfFactory+"]"); + } return theLinphoneCoreFactory; } - public LinphoneAuthInfo createAuthInfo(String username,String password) { - return new LinphoneAuthInfoImpl(username,password) ; - } + abstract public LinphoneAuthInfo createAuthInfo(String username,String password); - public LinphoneCore createLinphoneCore(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { - return new LinphoneCoreImpl(listener,userConfig,factoryConfig,userdata); - } + abstract public LinphoneCore createLinphoneCore(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException; - public LinphoneAddress createLinphoneAddress(String username,String domain,String displayName) { - return new LinphoneAddressImpl(username,domain,displayName); - } + abstract public LinphoneAddress createLinphoneAddress(String username,String domain,String displayName); + abstract public LinphoneProxyConfig createProxyConfig(String identity, String proxy,String route,boolean enableRegister) throws LinphoneCoreException; /** * Enable verbose traces - * @param enable + * @param enable */ - public native void setDebugMode(boolean enable); + abstract public void setDebugMode(boolean enable); }