Commit 68829aef authored by Margaux Clerc's avatar Margaux Clerc
Browse files

Add new methods in JNI

parent 62c62711
......@@ -1244,6 +1244,12 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setChatDatabasePath(JNIE
env->ReleaseStringUTFChars(jpath, path);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCallLogsDatabasePath( JNIEnv* env, jobject thiz, jlong lc, jstring jpath) {
const char* path = env->GetStringUTFChars(jpath, NULL);
linphone_core_set_call_logs_database_path((LinphoneCore*)lc, path);
env->ReleaseStringUTFChars(jpath, path);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPrimaryContact2(JNIEnv* env, jobject thiz, jlong lc, jstring jcontact) {
const char* contact = env->GetStringUTFChars(jcontact, NULL);
linphone_core_set_primary_contact((LinphoneCore*)lc, contact);
......@@ -1498,6 +1504,12 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs( JNI
return (jint)ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc));
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_migrateCallLogs(JNIEnv* env
,jobject thiz
,jlong lc) {
linphone_core_migrate_logs_from_rc_to_db((LinphoneCore *)lc);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMtu(JNIEnv* env
,jobject thiz
,jlong lc
......@@ -1873,6 +1885,14 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getOrCreateChatRoom(JNI
return (jlong)lResult;
}
extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getChatRoom(JNIEnv* env
,jobject thiz
,jlong lc
,jlong to) {
LinphoneChatRoom* lResult = linphone_core_get_chat_room((LinphoneCore*)lc,(LinphoneAddress *)to);
return (jlong)lResult;
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv* env
,jobject thiz
,jlong lc
......@@ -2080,7 +2100,6 @@ extern "C" JNIEXPORT jboolean JNICALL Java_org_linphone_core_LinphoneCoreImpl_ch
return (jboolean) linphone_core_chat_enabled((LinphoneCore*)ptr);
}
//ProxyConfig
extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_createProxyConfig(JNIEnv* env, jobject thiz, jlong lc) {
......@@ -2110,6 +2129,12 @@ extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JN
return NULL;
}
}
extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_getAddress(JNIEnv* env, jobject thiz, jlong proxyCfg) {
return (jlong) linphone_proxy_config_get_identity_address((LinphoneProxyConfig*)proxyCfg);
}
extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setAddress(JNIEnv* env,jobject thiz,jlong proxyCfg,jlong jidentity) {
linphone_proxy_config_set_identity_address((LinphoneProxyConfig*)proxyCfg, (LinphoneAddress*) jidentity);
}
extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) {
const char* proxy = env->GetStringUTFChars(jproxy, NULL);
jint err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy);
......@@ -2196,6 +2221,12 @@ extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhone
ms_free(normalized_phone);
return normalizedNumber;
}
extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_normalizeSipUri(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jusername) {
const char* username = env->GetStringUTFChars(jusername, NULL);
LinphoneAddress *addr = linphone_proxy_config_normalize_sip_uri((LinphoneProxyConfig*)proxyCfg, username);
env->ReleaseStringUTFChars(jusername, username);
return (jlong) addr;
}
extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_lookupCCCFromIso(JNIEnv* env, jobject thiz, jlong proxyCfg, jstring jiso) {
const char* iso = env->GetStringUTFChars(jiso, NULL);
int prefix = linphone_dial_plan_lookup_ccc_from_iso(iso);
......@@ -3261,10 +3292,10 @@ extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setFileTransferFi
env->ReleaseStringUTFChars(jpath, path);
}
extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_downloadFile(JNIEnv* env
extern "C" jint Java_org_linphone_core_LinphoneChatMessageImpl_downloadFile(JNIEnv* env
,jobject thiz
,jlong ptr) {
linphone_chat_message_download_file((LinphoneChatMessage*)ptr);
return (jint) linphone_chat_message_download_file((LinphoneChatMessage*)ptr);
}
static void message_state_changed(LinphoneChatMessage* msg, LinphoneChatMessageState state) {
......
......@@ -221,7 +221,7 @@ public interface LinphoneChatMessage {
/**
* Start the download of the file referenced in a LinphoneChatMessage from remote server.
*/
void downloadFile();
int downloadFile();
/**
* Set the callbacks associated with the LinphoneChatMessage.
......
......@@ -611,7 +611,7 @@ public interface LinphoneCore {
* @param call the LinphoneCall, must be in the {@link LinphoneCall.State#IncomingReceived} state.
* @param reason the reason for rejecting the call: {@link Reason#Declined} or {@link Reason#Busy}
*/
public void declineCall(LinphoneCall aCall, Reason reason);
public void declineCall(LinphoneCall call, Reason reason);
/**
* Returns The LinphoneCall the current call if one is in call
*
......@@ -700,7 +700,7 @@ public interface LinphoneCore {
* Calling this method with true trigger Linphone to initiate a registration process for all proxy
* configuration with parameter register set to enable.
* This method disable the automatic registration mode. It means you must call this method after each network state changes
* @param network state
* @param isReachable network state
*
*/
public void setNetworkReachable(boolean isReachable);
......@@ -747,7 +747,7 @@ public interface LinphoneCore {
/**
* Initiate a dtmf signal if in call
* @param send dtmf ['0'..'9'] | '#', '*'
* @param number send dtmf ['0'..'9'] | '#', '*'
*/
void sendDtmf(char number);
/**
......@@ -800,7 +800,7 @@ public interface LinphoneCore {
/**
* Enable payload type
* @param pt payload type to enable, can be retrieve from {@link #findPayloadType}
* @param true if enabled
* @param enable for enable or disable the payload type
* @exception LinphoneCoreException
*
*/
......@@ -968,6 +968,13 @@ public interface LinphoneCore {
* @return {@link LinphoneChatRoom} where messaging can take place.
*/
LinphoneChatRoom getOrCreateChatRoom(String to);
/**
* Create a new chat room for messaging from a linphone address
* @param to destination address for messages
*
* @return {@link LinphoneChatRoom} where messaging can take place.
*/
LinphoneChatRoom getChatRoom(LinphoneAddress to);
/**
* Set the native video window id where the video is to be displayed.
* On Android, it must be of type {@link AndroidVideoWindowImpl}
......@@ -1832,6 +1839,11 @@ public interface LinphoneCore {
*/
public int migrateToMultiTransport();
/**
* Migrates the call logs from the linphonerc to the database if not done yet
**/
public void migrateCallLogs();
/**
* When receiving an incoming, accept to start a media session as early-media.
* This means the call is not accepted but audio & video streams can be established if the remote party supports early media.
......@@ -1848,8 +1860,8 @@ public interface LinphoneCore {
* Accept an early media session for an incoming call.
* This is identical as calling linphone_core_accept_early_media_with_params() with NULL call parameters.
* @see linphone_core_accept_early_media_with_params()
* @param lc the core
* @param call the incoming call
* @param params
* @return true if successful, false otherwise.
*/
public boolean acceptEarlyMediaWithParams(LinphoneCall call, LinphoneCallParams params);
......
......@@ -37,7 +37,7 @@ public interface LinphoneProxyConfig {
public void done();
/**
* Sets the user identity as a SIP address.
* @param identy This identity is normally formed with display name, username and domain, such as: Alice <sip:alice@example.net> The REGISTER messages will have from and to set to this identity.
* @param identity This identity is normally formed with display name, username and domain, such as: Alice <sip:alice@example.net> The REGISTER messages will have from and to set to this identity.
*/
public void setIdentity(String identity) throws LinphoneCoreException;
/**
......@@ -46,6 +46,17 @@ public interface LinphoneProxyConfig {
* @return The SIP identity is a SIP address (Display Name <sip:username> )
*/
public String getIdentity();
/**
* Sets the address of the proxy configuration
* @param address
*/
public void setAddress(LinphoneAddress address) throws LinphoneCoreException;
/**
*get linphoneAddress that belongs to this proxy configuration.
*
* @return LinphoneAddress
*/
public LinphoneAddress getAddress();
/**
*Sets the proxy address
* Examples of valid sip proxy address are:
......@@ -78,6 +89,13 @@ public interface LinphoneProxyConfig {
* @return
*/
public String normalizePhoneNumber(String number);
/**
* Normalize a human readable sip uri into a fully qualified LinphoneAddress.
* A sip address should look like DisplayName \<sip:username\@domain:port\> .
* @param username the string to parse
* @return NULL if invalid input, normalized sip address otherwise.
*/
public LinphoneAddress normalizeSipUri(String username);
/**
* Useful function to automatically add international prefix to e164 phone numbers
* @param prefix
......@@ -126,8 +144,7 @@ public interface LinphoneProxyConfig {
/**
* Indicates either or not, PUBLISH must be issued for this #LinphoneProxyConfig .
* <br> In case this #LinphoneProxyConfig has been added to #LinphoneCore, follows the linphone_proxy_config_edit() rule.
* @param obj object pointer
* @param val if true, publish will be engaged
* @param enable if true, publish will be engaged
*
*/
public void enablePublish(boolean enable);
......@@ -227,7 +244,7 @@ public interface LinphoneProxyConfig {
/**
* Set the outbound proxy realm. It is used in digest authentication to avoid
* re-authentication if a previous token has already been provided.
* @param The new outbound proxy realm.
* @param realm The new outbound proxy realm.
*/
void setRealm(String realm);
......@@ -269,7 +286,7 @@ public interface LinphoneProxyConfig {
/**
* Return the international prefix for the given country
* @param country iso code
* @param iso code
*/
public int lookupCCCFromIso(String iso);
......
......@@ -16,7 +16,7 @@ public class LinphoneChatMessageImpl implements LinphoneChatMessage {
private native void store(long ptr);
private native int getStorageId(long ptr);
private native void setFileTransferFilepath(long ptr, String path);
private native void downloadFile(long ptr);
private native int downloadFile(long ptr);
private native void setListener(long ptr, LinphoneChatMessageListener listener);
private native void unref(long ptr);
......@@ -146,8 +146,8 @@ public class LinphoneChatMessageImpl implements LinphoneChatMessage {
}
@Override
public void downloadFile() {
downloadFile(nativePtr);
public int downloadFile() {
return downloadFile(nativePtr);
}
@Override
......
......@@ -98,6 +98,7 @@ class LinphoneCoreImpl implements LinphoneCore {
private native void setPresenceModel(long nativePtr, long presencePtr);
private native Object getPresenceModel(long nativePtr);
private native long getOrCreateChatRoom(long nativePtr,String to);
private native long getChatRoom(long nativePtr,long to);
private native void enableVideo(long nativePtr,boolean vcap_enabled,boolean display_enabled);
private native boolean isVideoEnabled(long nativePtr);
private native boolean isVideoSupported(long nativePtr);
......@@ -161,8 +162,10 @@ class LinphoneCoreImpl implements LinphoneCore {
private native String getPrimaryContactUsername(long nativePtr);
private native String getPrimaryContactDisplayName(long nativePtr);
private native void setChatDatabasePath(long nativePtr, String path);
private native void setCallLogsDatabasePath(long nativePtr, String path);
private native long[] getChatRooms(long nativePtr);
private native int migrateToMultiTransport(long nativePtr);
private native void migrateCallLogs(long nativePtr);
private native void setCallErrorTone(long nativePtr, int reason, String path);
private native void enableSdp200Ack(long nativePtr,boolean enable);
private native boolean isSdp200AckEnabled(long nativePtr);
......@@ -460,6 +463,9 @@ class LinphoneCoreImpl implements LinphoneCore {
public synchronized LinphoneChatRoom getOrCreateChatRoom(String to) {
return new LinphoneChatRoomImpl(getOrCreateChatRoom(nativePtr,to));
}
public synchronized LinphoneChatRoom getChatRoom(LinphoneAddress to) {
return new LinphoneChatRoomImpl(getChatRoom(nativePtr,((LinphoneAddressImpl)to).nativePtr));
}
public synchronized void setPreviewWindow(Object w) {
setPreviewWindowId(nativePtr,w);
}
......@@ -1173,6 +1179,10 @@ class LinphoneCoreImpl implements LinphoneCore {
setChatDatabasePath(nativePtr, path);
}
public synchronized void setCallLogsDatabasePath(String path) {
setCallLogsDatabasePath(nativePtr, path);
}
public synchronized LinphoneChatRoom[] getChatRooms() {
long[] typesPtr = getChatRooms(nativePtr);
if (typesPtr == null) return null;
......@@ -1224,6 +1234,11 @@ class LinphoneCoreImpl implements LinphoneCore {
return migrateToMultiTransport(nativePtr);
}
@Override
public synchronized void migrateCallLogs() {
migrateCallLogs(nativePtr);
}
private native boolean acceptEarlyMedia(long lc, long call);
@Override
public synchronized boolean acceptEarlyMedia(LinphoneCall call) {
......
......@@ -70,6 +70,8 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
private native void setIdentity(long ptr,String identity);
private native String getIdentity(long ptr);
private native void setAddress(long ptr, long address);
private native long getAddress(long ptr);
private native int setProxy(long ptr,String proxy);
private native String getProxy(long ptr);
......@@ -82,6 +84,7 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
private native String getDialPrefix(long ptr);
private native String normalizePhoneNumber(long ptr,String number);
private native long normalizeSipUri(long ptr,String username);
private native String getDomain(long ptr);
......@@ -125,6 +128,11 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
setIdentity(nativePtr,identity);
}
public void setAddress(LinphoneAddress address) throws LinphoneCoreException {
isValid();
setAddress(nativePtr,((LinphoneAddressImpl)address).nativePtr);
}
public void setProxy(String proxyUri) throws LinphoneCoreException {
isValid();
if (setProxy(nativePtr,proxyUri)!=0) {
......@@ -135,6 +143,15 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
isValid();
return normalizePhoneNumber(nativePtr,number);
}
public LinphoneAddress normalizeSipUri(String username) {
isValid();
long ptr = normalizeSipUri(nativePtr,username);
if (ptr==0) {
return null;
} else {
return new LinphoneAddressImpl(ptr,LinphoneAddressImpl.WrapMode.FromConst);
}
}
public void setDialPrefix(String prefix) {
isValid();
setDialPrefix(nativePtr, prefix);
......@@ -159,6 +176,15 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
isValid();
return getIdentity(nativePtr);
}
public LinphoneAddress getAddress() {
isValid();
long ptr = getAddress(nativePtr);
if (ptr==0) {
return null;
} else {
return new LinphoneAddressImpl(ptr,LinphoneAddressImpl.WrapMode.FromConst);
}
}
public String getProxy() {
isValid();
return getProxy(nativePtr);
......
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