From 50d4dbf6d5713a66883019824087581c1c8271ec Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 27 Apr 2010 14:40:50 +0200 Subject: [PATCH 1/5] modify interface --- java/org/linphone/core/LinphoneAuthInfo.java | 7 ++++++- java/org/linphone/core/LinphoneCore.java | 10 +--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/java/org/linphone/core/LinphoneAuthInfo.java b/java/org/linphone/core/LinphoneAuthInfo.java index 2a5dbaf2d..8ae3aeea5 100644 --- a/java/org/linphone/core/LinphoneAuthInfo.java +++ b/java/org/linphone/core/LinphoneAuthInfo.java @@ -19,7 +19,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package org.linphone.core; public interface LinphoneAuthInfo { - + String getUsername(); + String getPassword(); + String getRealm(); + void setUsername(String username); + void setPassword(String password); + void setRealm(String realm); } diff --git a/java/org/linphone/core/LinphoneCore.java b/java/org/linphone/core/LinphoneCore.java index 8609e04e1..bfc9486b8 100644 --- a/java/org/linphone/core/LinphoneCore.java +++ b/java/org/linphone/core/LinphoneCore.java @@ -59,14 +59,6 @@ public interface LinphoneCore { } - /** - * @param identity sip uri sip:jehan@linphone.org - * @param proxy sip uri (sip:linphone.org) - * @param route optionnal sip usi (sip:linphone.org) - * @param register should be initiated - * @return - */ - public LinphoneProxyConfig createProxyConfig(String identity,String proxy,String route,boolean enableRegister) throws LinphoneCoreException; /** * clear all added proxy config */ @@ -123,7 +115,7 @@ public interface LinphoneCore { /** * @return a list of LinphoneCallLog */ - public List getCallLogs(); + public List getCallLogs(); /** * This method is called by the application to notify the Linphone core library when network is reachable. From 572b696529119810350e083cec72e59b2d3e75d5 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 27 Apr 2010 14:51:30 +0200 Subject: [PATCH 2/5] 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); } From b59dc8318c61d671d56075fb63987c4f0ce19d6d Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 27 Apr 2010 15:53:02 +0200 Subject: [PATCH 3/5] enrich linphoneaddress --- java/org/linphone/core/LinphoneAddress.java | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/java/org/linphone/core/LinphoneAddress.java b/java/org/linphone/core/LinphoneAddress.java index 86271674c..16c688470 100644 --- a/java/org/linphone/core/LinphoneAddress.java +++ b/java/org/linphone/core/LinphoneAddress.java @@ -34,13 +34,30 @@ public interface LinphoneAddress { * @return null if not set */ public String getDomain(); + public String getPort(); + public int getPortInt(); /** * set display name * @param name */ public void setDisplayName(String name); + public void setUserName(String username); + public void setDomain(String domain); + public void setPort(String port); + public void setPortInt(int port); + public void clean(); + /** - * @return an URI version of the address that can be used to place a call using {@link LinphoneCore#invite(String)} + * + * @return the address as a string. */ - public String toUri(); + public String asString(); + /** + * + * @return the address without display name as a string. + */ + public String asStringUriOnly(); + + /*must return the same thing as asString()*/ + public String toString(); } From ca8da575f27235558182921c72d48d4d1d7d4991 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 28 Apr 2010 16:54:37 +0200 Subject: [PATCH 4/5] api enhancements --- java/org/linphone/core/LinphoneCore.java | 22 ++++++++++++------- .../linphone/core/LinphoneCoreFactory.java | 2 ++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/java/org/linphone/core/LinphoneCore.java b/java/org/linphone/core/LinphoneCore.java index bfc9486b8..4662edb2c 100644 --- a/java/org/linphone/core/LinphoneCore.java +++ b/java/org/linphone/core/LinphoneCore.java @@ -80,7 +80,19 @@ public interface LinphoneCore { void addAuthInfo(LinphoneAuthInfo info); - public void invite(String uri); + /** + * Build an address according to the current proxy config. In case destination is not a sip address, the default proxy domain is automatically appended + * @param destination + * @return + * @throws If no LinphoneAddress can be built from destination + */ + public LinphoneAddress interpretUrl(String destination) throws LinphoneCoreException; + + /** + * Starts a call given a destination. Internally calls interpretUrl() then invite(LinphoneAddress). + * @param uri + */ + public void invite(String destination)throws LinphoneCoreException; public void invite(LinphoneAddress to); @@ -150,13 +162,7 @@ public interface LinphoneCore { * @return true is mic is muted */ public boolean isMicMuted(); - /** - * Build an address according to the current proxy config. In case destination is not a sip uri, the default proxy domain is automatically appended - * @param destination - * @return - * @throws If no LinphonrAddress can be built from destination - */ - public LinphoneAddress interpretUrl(String destination) throws LinphoneCoreException; + /** * Initiate a dtmf signal if in call * @param number diff --git a/java/org/linphone/core/LinphoneCoreFactory.java b/java/org/linphone/core/LinphoneCoreFactory.java index 87572c3bd..65f8dd9b8 100644 --- a/java/org/linphone/core/LinphoneCoreFactory.java +++ b/java/org/linphone/core/LinphoneCoreFactory.java @@ -54,6 +54,8 @@ abstract public class LinphoneCoreFactory { abstract public LinphoneAddress createLinphoneAddress(String username,String domain,String displayName); + abstract public LinphoneAddress createLinphoneAddress(String address); + abstract public LinphoneProxyConfig createProxyConfig(String identity, String proxy,String route,boolean enableRegister) throws LinphoneCoreException; /** * Enable verbose traces From 5155979f2726c01d9e1f6dca3fcf44b447081467 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 29 Apr 2010 11:16:23 +0200 Subject: [PATCH 5/5] port to j2me --- java/org/linphone/core/LinphoneCallLog.java | 6 +-- java/org/linphone/core/LinphoneCore.java | 45 ++++++++++--------- .../linphone/core/LinphoneCoreException.java | 12 +---- .../linphone/core/LinphoneCoreFactory.java | 8 ++-- 4 files changed, 32 insertions(+), 39 deletions(-) diff --git a/java/org/linphone/core/LinphoneCallLog.java b/java/org/linphone/core/LinphoneCallLog.java index 19d851a43..08cdb8034 100644 --- a/java/org/linphone/core/LinphoneCallLog.java +++ b/java/org/linphone/core/LinphoneCallLog.java @@ -19,13 +19,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package org.linphone.core; public interface LinphoneCallLog { - public enum CallDirection { - CallOutgoing,Callincoming - } + public LinphoneAddress getFrom(); public LinphoneAddress getTo (); - public LinphoneCallLog.CallDirection getDirection(); + public CallDirection getDirection(); } diff --git a/java/org/linphone/core/LinphoneCore.java b/java/org/linphone/core/LinphoneCore.java index 4662edb2c..8c3674d66 100644 --- a/java/org/linphone/core/LinphoneCore.java +++ b/java/org/linphone/core/LinphoneCore.java @@ -18,7 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core; -import java.util.List; + +import java.util.Vector; @@ -26,32 +27,36 @@ public interface LinphoneCore { /* * linphone core states */ - public enum GeneralState { + static public class GeneralState { /* states for GSTATE_GROUP_POWER */ - GSTATE_POWER_OFF(0), /* initial state */ - GSTATE_POWER_STARTUP(1), - GSTATE_POWER_ON(2), - GSTATE_POWER_SHUTDOWN(3), + static GeneralState GSTATE_POWER_OFF = new GeneralState(0); /* initial state */ + static GeneralState GSTATE_POWER_STARTUP = new GeneralState(1); + static GeneralState GSTATE_POWER_ON = new GeneralState(2); + static GeneralState GSTATE_POWER_SHUTDOWN = new GeneralState(3); /* states for GSTATE_GROUP_REG */ - GSTATE_REG_NONE(10), /* initial state */ - GSTATE_REG_OK(11), - GSTATE_REG_FAILED(12), + static GeneralState GSTATE_REG_NONE = new GeneralState(10); /* initial state */ + static GeneralState GSTATE_REG_OK = new GeneralState(11); + static GeneralState GSTATE_REG_FAILED = new GeneralState(12); /* states for GSTATE_GROUP_CALL */ - GSTATE_CALL_IDLE(20), /* initial state */ - GSTATE_CALL_OUT_INVITE(21), - GSTATE_CALL_OUT_CONNECTED(22), - GSTATE_CALL_IN_INVITE(23), - GSTATE_CALL_IN_CONNECTED(24), - GSTATE_CALL_END(25), - GSTATE_CALL_ERROR(26), - GSTATE_INVALID(27); + static GeneralState GSTATE_CALL_IDLE = new GeneralState(20); /* initial state */ + static GeneralState GSTATE_CALL_OUT_INVITE = new GeneralState(21); + static GeneralState GSTATE_CALL_OUT_CONNECTED = new GeneralState(22); + static GeneralState GSTATE_CALL_IN_INVITE = new GeneralState(23); + static GeneralState GSTATE_CALL_IN_CONNECTED = new GeneralState(24); + static GeneralState GSTATE_CALL_END = new GeneralState(25); + static GeneralState GSTATE_CALL_ERROR = new GeneralState(26); + static GeneralState GSTATE_INVALID = new GeneralState(27); private final int mValue; + static private Vector values = new Vector(); - GeneralState(int value) { + private GeneralState(int value) { mValue = value; + values.addElement(this); } public static GeneralState fromInt(int value) { - for (GeneralState state: GeneralState.values()) { + + for (int i=0; i