Commit 45bcccf4 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Added methods (and JNI bindings) to get LinphoneFriends from a...

Added methods (and JNI bindings) to get LinphoneFriends from a LinphoneFriendList and LinphoneFriendLists from LinphoneCore
parent 7d03d2e0
......@@ -448,6 +448,10 @@ LinphoneFriendListStatus linphone_friend_list_remove_friend(LinphoneFriendList *
return LinphoneFriendListOK;
}
const MSList * linphone_friend_list_get_friends(const LinphoneFriendList *list) {
return list->friends;
}
void linphone_friend_list_update_dirty_friends(LinphoneFriendList *list) {
LinphoneCardDavContext *cdc = linphone_carddav_context_new(list);
MSList *dirty_friends = list->dirty_friends_to_update;
......
......@@ -169,6 +169,13 @@ LINPHONE_PUBLIC LinphoneFriendListStatus linphone_friend_list_add_local_friend(L
**/
LINPHONE_PUBLIC LinphoneFriendListStatus linphone_friend_list_remove_friend(LinphoneFriendList *list, LinphoneFriend *afriend);
/**
* Retrieves the list of LinphoneFriend from this LinphoneFriendList.
* @param[in] list LinphoneFriendList object
* @return \mslist{LinphoneFriend} a list of LinphoneFriend
*/
LINPHONE_PUBLIC const MSList * linphone_friend_list_get_friends(const LinphoneFriendList *list);
/**
* Find a friend in the friend list using a LinphoneAddress.
* @param[in] list LinphoneFriendList object.
......
......@@ -2089,6 +2089,27 @@ extern "C" jobjectArray Java_org_linphone_core_LinphoneCoreImpl_getFriendList(JN
return jFriends;
}
extern "C" jobjectArray Java_org_linphone_core_LinphoneCoreImpl_getFriendLists(JNIEnv* env
,jobject thiz
,jlong lc) {
const MSList* friends = linphone_core_get_friends_lists((LinphoneCore*)lc);
int friendsSize = ms_list_size(friends);
LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data((LinphoneCore *)lc);
jobjectArray jFriends = env->NewObjectArray(friendsSize,ljb->friendListClass,NULL);
for (int i = 0; i < friendsSize; i++) {
LinphoneFriendList* lfriend = (LinphoneFriendList*)friends->data;
jobject jfriend = getFriendList(env,lfriend);
if(jfriend != NULL){
env->SetObjectArrayElement(jFriends, i, jfriend);
}
friends = friends->next;
}
return jFriends;
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv* env
,jobject thiz
,jlong lc
......@@ -3339,6 +3360,25 @@ extern "C" void Java_org_linphone_core_LinphoneFriendListImpl_addLocalFriend(JNI
linphone_friend_list_add_local_friend((LinphoneFriendList*)friendListptr, (LinphoneFriend*)friendPtr);
}
extern "C" jobjectArray Java_org_linphone_core_LinphoneFriendListImpl_getFriendList(JNIEnv* env, jobject thiz, jlong list) {
const MSList* friends = linphone_friend_list_get_friends((LinphoneFriendList *)list);
int friendsSize = ms_list_size(friends);
LinphoneCore *lc = linphone_friend_list_get_core((LinphoneFriendList *)list);
LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc);
jobjectArray jFriends = env->NewObjectArray(friendsSize,ljb->friendClass,NULL);
for (int i = 0; i < friendsSize; i++) {
LinphoneFriend* lfriend = (LinphoneFriend*)friends->data;
jobject jfriend = getFriend(env,lfriend);
if(jfriend != NULL){
env->SetObjectArrayElement(jFriends, i, jfriend);
}
friends = friends->next;
}
return jFriends;
}
extern "C" void Java_org_linphone_core_LinphoneFriendListImpl_updateSubscriptions(JNIEnv* env
,jobject thiz
,jlong friendListptr
......
......@@ -1020,6 +1020,12 @@ public interface LinphoneCore {
*/
LinphoneFriend[] getFriendList();
/**
* Get list of LinphoneFriendList
* @return LinphoneFriendList list
*/
LinphoneFriendList[] getFriendLists();
/**
* @brief Set my presence status
* @param minutes_away how long in away
......
......@@ -22,6 +22,7 @@ public interface LinphoneFriendList {
public void setRLSUri(String uri);
public void addFriend(LinphoneFriend friend);
public void addLocalFriend(LinphoneFriend friend);
public LinphoneFriend[] getFriendList();
public void updateSubscriptions(LinphoneProxyConfig proxyConfig,boolean onlyWhenRegistered);
public LinphoneFriend findFriendByUri(String uri);
public void setUri(String uri);
......
......@@ -471,6 +471,11 @@ class LinphoneCoreImpl implements LinphoneCore {
public synchronized LinphoneFriend[] getFriendList() {
return getFriendList(nativePtr);
}
private native LinphoneFriendList[] getFriendLists(long nativePtr);
public synchronized LinphoneFriendList[] getFriendLists() {
return getFriendLists(nativePtr);
}
@SuppressWarnings("deprecation")
public synchronized void setPresenceInfo(int minutes_away, String alternative_contact, OnlineStatus status) {
......
......@@ -28,6 +28,7 @@ class LinphoneFriendListImpl implements LinphoneFriendList, Serializable {
private native void setRLSUri(long nativePtr, String uri);
private native void addFriend(long nativePtr, long friendPtr);
private native void addLocalFriend(long nativePtr, long friendPtr);
private native LinphoneFriend[] getFriendList(long nativePtr);
private native void updateSubscriptions(long nativePtr, long proxyConfigPtr, boolean onlyWhenRegistered);
private native Object getCore(long ptr);
private native LinphoneFriend findFriendByUri(long nativePtr, String uri);
......@@ -58,6 +59,13 @@ class LinphoneFriendListImpl implements LinphoneFriendList, Serializable {
}
}
@Override
public LinphoneFriend[] getFriendList() {
synchronized(getSyncObject()){
return getFriendList(nativePtr);
}
}
@Override
public void updateSubscriptions(LinphoneProxyConfig proxyConfig,boolean onlyWhenRegistered) {
synchronized(getSyncObject()){
......
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