Added JNI wrapper for friends/vcards import/export methods + setFriendsDatabasePath

This commit is contained in:
Sylvain Berfini 2015-12-24 14:55:44 +01:00
parent 2af49f5700
commit aa2a82ceae
3 changed files with 55 additions and 5 deletions

View file

@ -1355,16 +1355,21 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopRinging(JNIEnv* env,
linphone_core_stop_ringing((LinphoneCore*)lc);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setChatDatabasePath(JNIEnv* env, jobject thiz, jlong lc, jstring jpath) {
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setChatDatabasePath(JNIEnv* env, jobject thiz, jlong lc, jstring jpath) {
const char* path = env->GetStringUTFChars(jpath, NULL);
linphone_core_set_chat_database_path((LinphoneCore*)lc, path);
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_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_setFriendsDatabasePath( JNIEnv* env, jobject thiz, jlong lc, jstring jpath) {
const char* path = env->GetStringUTFChars(jpath, NULL);
linphone_core_set_friends_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) {
@ -1940,6 +1945,18 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv* env
linphone_core_add_friend((LinphoneCore*)lc,(LinphoneFriend*)aFriend);
}
extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_importFriendsFromVCardFile(JNIEnv* env, jobject thiz, jlong lc, jstring jpath) {
const char* path = env->GetStringUTFChars(jpath, NULL);
return linphone_core_import_friends_from_vcard4_file((LinphoneCore*)lc, path);
env->ReleaseStringUTFChars(jpath, path);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_exportFriendsToVCardFile(JNIEnv* env, jobject thiz, jlong lc, jstring jpath) {
const char* path = env->GetStringUTFChars(jpath, NULL);
linphone_core_export_friends_as_vcard4_file((LinphoneCore*)lc, path);
env->ReleaseStringUTFChars(jpath, path);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFriendList(JNIEnv* env
,jobject thiz
,jlong lc

View file

@ -1906,6 +1906,12 @@ public interface LinphoneCore {
*/
public void setCallLogsDatabasePath(String path);
/**
* Sets the path to the database where the friends will be stored (if enabled)
* @param path the database where the friends will be stored.
*/
public void setFriendsDatabasePath(String path);
/**
* Gets the chat rooms
* @return an array of LinphoneChatRoom
@ -2241,4 +2247,14 @@ public interface LinphoneCore {
*/
public int getNortpTimeout();
/**
* Imports LinphoneFriends from a vCard 4 file
* @return the number of friend imported
**/
public int importFriendsFromVCardFile(String file);
/**
* Exports LinphoneFriends to a vCard 4 file
**/
public void exportFriendsToVCardFile(String file);
}

View file

@ -165,6 +165,7 @@ class LinphoneCoreImpl implements LinphoneCore {
private native String getPrimaryContactDisplayName(long nativePtr);
private native void setChatDatabasePath(long nativePtr, String path);
private native void setCallLogsDatabasePath(long nativePtr, String path);
private native void setFriendsDatabasePath(long nativePtr, String path);
private native long[] getChatRooms(long nativePtr);
private native int migrateToMultiTransport(long nativePtr);
private native void migrateCallLogs(long nativePtr);
@ -1196,6 +1197,10 @@ class LinphoneCoreImpl implements LinphoneCore {
public synchronized void setCallLogsDatabasePath(String path) {
setCallLogsDatabasePath(nativePtr, path);
}
public synchronized void setFriendsDatabasePath(String path) {
setFriendsDatabasePath(nativePtr, path);
}
public synchronized LinphoneChatRoom[] getChatRooms() {
long[] typesPtr = getChatRooms(nativePtr);
@ -1599,4 +1604,16 @@ class LinphoneCoreImpl implements LinphoneCore {
public int getNortpTimeout(){
return getNortpTimeout(nativePtr);
}
private native int importFriendsFromVCardFile(long nativePtr, String file);
@Override
public int importFriendsFromVCardFile(String file) {
return importFriendsFromVCardFile(nativePtr, file);
}
private native void exportFriendsToVCardFile(long nativePtr, String file);
@Override
public void exportFriendsToVCardFile(String file) {
exportFriendsToVCardFile(nativePtr, file);
}
}