From: Sylvain Berfini Date: Fri, 5 Oct 2012 15:32:38 +0000 (+0200) Subject: Few changes in JNI interface for linphone friends + fix issue in linphone_friend_destroy X-Git-Url: http://sjero.net/git/?p=linphone;a=commitdiff_plain;h=1cc0a418af4718014a614afdbe6f1cd7690a4ccf Few changes in JNI interface for linphone friends + fix issue in linphone_friend_destroy --- diff --git a/coreapi/friend.c b/coreapi/friend.c index 05a1baee..c6dee244 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -396,8 +396,8 @@ void linphone_core_add_friend(LinphoneCore *lc, LinphoneFriend *lf) void linphone_core_remove_friend(LinphoneCore *lc, LinphoneFriend* fl){ MSList *el=ms_list_find(lc->friends,(void *)fl); if (el!=NULL){ - lc->friends=ms_list_remove_link(lc->friends,el); linphone_friend_destroy((LinphoneFriend*)el->data); + lc->friends=ms_list_remove_link(lc->friends,el); linphone_core_write_friends_config(lc); } } diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index b8d48de5..566269a7 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -1592,6 +1592,21 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv* env ,jlong ptr) { linphone_friend_done((LinphoneFriend*)ptr); } +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFriend(JNIEnv* env + ,jobject thiz + ,jlong ptr + ,jlong lf) { + linphone_core_remove_friend((LinphoneCore*)ptr, (LinphoneFriend*)lf); +} +extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getFriendByAddress(JNIEnv* env + ,jobject thiz + ,jlong ptr + ,jstring jaddress) { + const char* address = env->GetStringUTFChars(jaddress, NULL); + LinphoneFriend *lf = linphone_core_get_friend_by_address((LinphoneCore*)ptr, address); + env->ReleaseStringUTFChars(jaddress, address); + return (jlong) lf; +} //LinphoneChatRoom extern "C" long Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env ,jobject thiz diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index 6ac82132..732940fd 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -20,9 +20,6 @@ package org.linphone.core; import java.util.Vector; -import org.linphone.core.LinphoneCallLog; -import org.linphone.core.LinphoneCallParams; - /** * Linphone core main object created by method {@link LinphoneCoreFactory#createLinphoneCore(LinphoneCoreListener, String, String, Object)}. * @@ -802,4 +799,14 @@ public interface LinphoneCore { * return the version code of linphone core */ public String getVersion(); + + /** + * remove a linphone friend from linphone core and linphonerc + */ + void removeFriend(LinphoneFriend lf); + + /** + * return a linphone friend (if exists) that matches the sip address + */ + LinphoneFriend findFriendByAddress(String sipUri); } diff --git a/java/common/org/linphone/core/LinphoneFriend.java b/java/common/org/linphone/core/LinphoneFriend.java index d4f0e750..e070f692 100644 --- a/java/common/org/linphone/core/LinphoneFriend.java +++ b/java/common/org/linphone/core/LinphoneFriend.java @@ -123,5 +123,8 @@ public interface LinphoneFriend { */ String toString(); - + /** + * Return the native pointer for this object + */ + long getNativePtr(); }