Commit 7bfd1278 authored by Sylvain Berfini's avatar Sylvain Berfini

Added JNI wrapper for LinphoneAddress set/get transport methods

parent 3e876562
......@@ -1804,6 +1804,12 @@ extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv*
return NULL;
}
}
extern "C" jint Java_org_linphone_core_LinphoneAddressImpl_getTransport(JNIEnv* env
,jobject thiz
,jlong ptr) {
LinphoneTransportType transporttype = linphone_address_get_transport((LinphoneAddress*)ptr);
return (jint)transporttype;
}
extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv* env
,jobject thiz
,jlong ptr) {
......@@ -1844,7 +1850,12 @@ extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDomain(JNIEnv* en
linphone_address_set_domain((LinphoneAddress*)address,domain);
if (domain != NULL) env->ReleaseStringUTFChars(jdomain, domain);
}
extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setTransport(JNIEnv* env
,jobject thiz
,jlong address
,jint jtransport) {
linphone_address_set_transport((LinphoneAddress*)address, (LinphoneTransportType) jtransport);
}
//CallLog
extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv* env
......
......@@ -17,6 +17,9 @@ 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 java.util.Vector;
/**
* Object that represents a SIP address.
* The LinphoneAddress is an opaque object to represents SIP addresses, ie the content of SIP's 'from' and 'to' headers.
......@@ -28,6 +31,38 @@ package org.linphone.core;
*
*/
public interface LinphoneAddress {
static public class TransportType {
static private Vector<TransportType> values = new Vector<TransportType>();
static public TransportType LinphoneTransportUdp = new TransportType(0, "LinphoneTransportUdp");
static public TransportType LinphoneTransportTcp = new TransportType(1, "LinphoneTransportTcp");
static public TransportType LinphoneTransportTls = new TransportType(2, "LinphoneTransportTls");
private final int mValue;
private final String mStringValue;
private TransportType(int value, String stringValue) {
mValue = value;
values.addElement(this);
mStringValue = stringValue;
}
public static TransportType fromInt(int value) {
for (int i = 0; i < values.size(); i++) {
TransportType type = (TransportType) values.elementAt(i);
if (type.mValue == value) return type;
}
throw new RuntimeException("state not found ["+value+"]");
}
public String toString() {
return mStringValue;
}
public int toInt() {
return mValue;
}
}
/**
* Human display name
* @return null if not set
......@@ -99,4 +134,16 @@ public interface LinphoneAddress {
*
* */
public String toString();
/**
* Gets the transport set in the address
* @return the transport
*/
public TransportType getTransport();
/**
* Sets the transport in the address
* @param transport the transport to set
*/
public void setTransport(TransportType transport);
}
......@@ -34,10 +34,12 @@ public class LinphoneAddressImpl implements LinphoneAddress {
private native String getDisplayName(long ptr);
private native String getUserName(long ptr);
private native String getDomain(long ptr);
private native int getTransport(long ptr);
private native String toUri(long ptr);
private native void setDisplayName(long ptr,String name);
private native void setDomain(long ptr,String domain);
private native void setUserName(long ptr,String username);
private native void setTransport(long ptr, int transport);
private native String toString(long ptr);
protected LinphoneAddressImpl(String identity) throws LinphoneCoreException{
......@@ -84,6 +86,9 @@ public class LinphoneAddressImpl implements LinphoneAddress {
public String getUserName() {
return getUserName(nativePtr);
}
public TransportType getTransport() {
return TransportType.fromInt(getTransport(nativePtr));
}
public String toString() {
return toString(nativePtr);
......@@ -121,5 +126,7 @@ public class LinphoneAddressImpl implements LinphoneAddress {
public void setUserName(String username) {
setUserName(nativePtr,username);
}
public void setTransport(TransportType transport) {
setTransport(nativePtr, transport.toInt());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment