diff --git a/LinphoneAddress.java b/LinphoneAddress.java new file mode 100644 index 000000000..d7ad7c4b0 --- /dev/null +++ b/LinphoneAddress.java @@ -0,0 +1,37 @@ +/* +LinphoneAddress.java +Copyright (C) 2010 Belledonne Communications, Grenoble, France + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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; + +public interface LinphoneAddress { + /** + * Human display name + * @return null if not set + */ + public String getDisplayName(); + /** + * userinfo + * @return null if not set + */ + public String getUserName(); + /** + * + * @return null if not set + */ + public String getDomain(); +} diff --git a/LinphoneAddressImpl.java b/LinphoneAddressImpl.java new file mode 100644 index 000000000..83176180e --- /dev/null +++ b/LinphoneAddressImpl.java @@ -0,0 +1,61 @@ +/* +LinphoneAddressImpl.java +Copyright (C) 2010 Belledonne Communications, Grenoble, France + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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; + + + +public class LinphoneAddressImpl implements LinphoneAddress { + protected final long nativePtr; + boolean ownPtr = false; + private native long newLinphoneAddressImpl(String uri,String displayName); + private native void delete(long ptr); + private native String getDisplayName(long ptr); + private native String getUserName(long ptr); + private native String getDomain(long ptr); + + + protected LinphoneAddressImpl(String username,String domain,String displayName) { + nativePtr = newLinphoneAddressImpl("sip:"+username+"@"+domain, displayName); + } + protected LinphoneAddressImpl(long aNativePtr) { + nativePtr = aNativePtr; + ownPtr=false; + } + protected void finalize() throws Throwable { + if (ownPtr) delete(nativePtr); + } + public String getDisplayName() { + return getDisplayName(nativePtr); + } + public String getDomain() { + return getDomain(nativePtr); + } + public String getUserName() { + return getUserName(nativePtr); + } + + public String toString() { + String tmp=""; + if (getDisplayName()!=null) { + tmp="<"+getDisplayName()+">"; + } + return tmp+"sip:"+getUserName()+"@"+getDomain(); + } + +} diff --git a/LinphoneAuthInfoImpl.java b/LinphoneAuthInfoImpl.java index 15a064ec9..719101883 100644 --- a/LinphoneAuthInfoImpl.java +++ b/LinphoneAuthInfoImpl.java @@ -1,3 +1,21 @@ +/* +LinphoneAuthInfoImpl.java +Copyright (C) 2010 Belledonne Communications, Grenoble, France + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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; class LinphoneAuthInfoImpl implements LinphoneAuthInfo { diff --git a/LinphoneCore.java b/LinphoneCore.java index 8ae0effd3..0a327f481 100644 --- a/LinphoneCore.java +++ b/LinphoneCore.java @@ -89,6 +89,11 @@ public interface LinphoneCore { public void invite(String uri); public void terminateCall(); + /** + * get the remote address in case of in/out call + * @return null if no call engaged yet + */ + public LinphoneAddress getRemoteAddress(); public void iterate(); } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 0e4956566..2ef2895f6 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -38,6 +38,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native void addAuthInfo(long nativePtr,long authInfoNativePtr); private native void invite(long nativePtr,String uri); private native void terminateCall(long nativePtr); + private native long getRemoteAddress(long nativePtr); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; @@ -87,6 +88,14 @@ class LinphoneCoreImpl implements LinphoneCore { public void terminateCall() { terminateCall(nativePtr); } + public LinphoneAddress getRemoteAddress() { + long ptr = getRemoteAddress(nativePtr); + if (ptr==0) { + return null; + } else { + return new LinphoneAddressImpl(ptr); + } + } } diff --git a/LinphoneProxyConfig.java b/LinphoneProxyConfig.java index 17085de82..8e338e613 100644 --- a/LinphoneProxyConfig.java +++ b/LinphoneProxyConfig.java @@ -45,6 +45,10 @@ public interface LinphoneProxyConfig { * @throws LinphoneCoreException */ public void enableRegister(boolean value) throws LinphoneCoreException; - - + /** + * normalize a human readable phone number into a basic string. 888-444-222 becomes 888444222 + * @param number + * @return + */ + public String normalizePhoneNumber(String number); } diff --git a/LinphoneProxyConfigImpl.java b/LinphoneProxyConfigImpl.java index f1de9707b..7c65c7b28 100644 --- a/LinphoneProxyConfigImpl.java +++ b/LinphoneProxyConfigImpl.java @@ -55,6 +55,8 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { private native void enableRegister(long ptr,boolean value); + private native String normalizePhoneNumber(long ptr,String number); + public void enableRegister(boolean value) { enableRegister(nativePtr,value); } @@ -76,4 +78,7 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { throw new LinphoneCoreException("Bad proxy address ["+proxyUri+"]"); } } + public String normalizePhoneNumber(String number) { + return normalizePhoneNumber(nativePtr,number); + } }