mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-02-07 14:18:25 +00:00
Adding and implementing find_contacts_by_char
This commit is contained in:
parent
86dd768ae9
commit
04b6f1386d
5 changed files with 75 additions and 1 deletions
|
|
@ -2587,6 +2587,35 @@ void linphone_core_add_friend_list(LinphoneCore *lc, LinphoneFriendList *list) {
|
|||
linphone_core_notify_friend_list_created(lc, list);
|
||||
}
|
||||
|
||||
const bctbx_list_t * linphone_core_find_contacts_by_char(LinphoneCore *core, const char *filter, bool_t sip_only) {
|
||||
// Get sipuri from filter if possible
|
||||
bctbx_list_t *list, *_list = NULL;
|
||||
LinphoneAddress *addr = linphone_core_interpret_url(core, (sip_only) ? filter : "");
|
||||
bctbx_list_t* listFriendsList = (bctbx_list_t*)linphone_core_get_friends_lists(core);
|
||||
bctbx_list_t* listFriend = (listFriendsList != NULL)
|
||||
? (bctbx_list_t*)linphone_friend_list_get_friends((LinphoneFriendList*)listFriendsList->data) : NULL;
|
||||
|
||||
if (addr != NULL)
|
||||
list = bctbx_list_new(addr);
|
||||
|
||||
while (listFriend != NULL && listFriend->data != NULL) {
|
||||
LinphoneAddress *buff = (LinphoneAddress*)linphone_friend_get_address((LinphoneFriend*)listFriend->data);
|
||||
if (buff != NULL) {
|
||||
bctbx_list_t *new_list = bctbx_list_new(buff);
|
||||
if (list == NULL) {
|
||||
_list = list = new_list;
|
||||
} else {
|
||||
if (_list == NULL) _list = list;
|
||||
_list->next = new_list;
|
||||
_list = _list->next;
|
||||
}
|
||||
}
|
||||
listFriend = listFriend->next;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
void linphone_core_enable_audio_adaptive_jittcomp(LinphoneCore* lc, bool_t val) {
|
||||
lc->rtp_conf.audio_adaptive_jitt_comp_enabled = val;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2436,6 +2436,30 @@ extern "C" jobjectArray Java_org_linphone_core_LinphoneCoreImpl_getFriendLists(J
|
|||
return jFriends;
|
||||
}
|
||||
|
||||
extern "C" jobjectArray Java_org_linphone_core_LinphoneCoreImpl_findContactsByChar(JNIEnv* env
|
||||
,jobject thiz
|
||||
,jlong lc
|
||||
,jstring jfilter
|
||||
,jboolean jsiponly) {
|
||||
const char* filter = GetStringUTFChars(env, jfilter);
|
||||
const bctbx_list_t* contacts = linphone_core_find_contacts_by_char((LinphoneCore*)lc, filter, jsiponly);
|
||||
size_t contactsSize = bctbx_list_size(contacts);
|
||||
LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data((LinphoneCore *)lc);
|
||||
jobjectArray jContacts = env->NewObjectArray(contactsSize, ljb->addressClass, NULL);
|
||||
|
||||
for (size_t i = 0; i < contactsSize; i++) {
|
||||
LinphoneAddress *addr = (LinphoneAddress*)contacts->data;
|
||||
jobject jcontact = env->NewObject(ljb->addressClass, ljb->addressCtrId, (jlong)addr);
|
||||
if(jcontact != NULL){
|
||||
env->SetObjectArrayElement(jContacts, i, jcontact);
|
||||
}
|
||||
contacts = contacts->next;
|
||||
}
|
||||
ReleaseStringUTFChars(env, jfilter, filter);
|
||||
|
||||
return jContacts;
|
||||
}
|
||||
|
||||
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv* env
|
||||
,jobject thiz
|
||||
,jlong lc
|
||||
|
|
|
|||
|
|
@ -5250,6 +5250,15 @@ LINPHONE_PUBLIC const bctbx_list_t * linphone_core_get_friends_lists(const Linph
|
|||
*/
|
||||
LINPHONE_PUBLIC LinphoneFriendList * linphone_core_get_default_friend_list(const LinphoneCore *lc);
|
||||
|
||||
/**
|
||||
* Retrieves a list of LinphoneAddress sort and filter
|
||||
* @param[in] lc LinphoneCore object
|
||||
* @param[in] filter Chars used for the filter*
|
||||
* @param[in] sip_only Only sip address or not
|
||||
* @return \bctbx_list{LinphoneAddress} a list of filtered LinphoneAddress + the LinphoneAddress created with the filter
|
||||
**/
|
||||
LINPHONE_PUBLIC const bctbx_list_t * linphone_core_find_contacts_by_char(LinphoneCore *core, const char *filter, bool_t sip_only);
|
||||
|
||||
/**
|
||||
* Create a LinphonePresenceActivity with the given type and description.
|
||||
* @param[in] lc #LinphoneCore object.
|
||||
|
|
|
|||
|
|
@ -1100,6 +1100,14 @@ public interface LinphoneCore {
|
|||
*/
|
||||
LinphoneFriendList[] getFriendLists();
|
||||
|
||||
/**
|
||||
* Get filtered list by filter
|
||||
* @param filter
|
||||
* @param sipOnly get only sip address
|
||||
* @return LinphoneAddress list
|
||||
*/
|
||||
LinphoneAddress[] findContactsByChar(String filter, boolean sipOnly);
|
||||
|
||||
/**
|
||||
* Set my presence status
|
||||
* @param minutes_away how long in away
|
||||
|
|
|
|||
|
|
@ -195,7 +195,6 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
private native Object createFriend(long nativePtr);
|
||||
private native Object createFriendWithAddress(long nativePtr, String address);
|
||||
private native int getIncomingTimeout(long nativePtr);
|
||||
|
||||
LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig, File factoryConfig, Object userdata, Object context) throws IOException {
|
||||
mListener = listener;
|
||||
String user = userConfig == null ? null : userConfig.getCanonicalPath();
|
||||
|
|
@ -495,6 +494,11 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
return getFriendLists(nativePtr);
|
||||
}
|
||||
|
||||
private native LinphoneAddress[] findContactsByChar(long nativePtr, String filter, boolean sipOnly);
|
||||
public synchronized LinphoneAddress[] findContactsByChar(String filter, boolean sipOnly) {
|
||||
return findContactsByChar(nativePtr, filter, sipOnly);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public synchronized void setPresenceInfo(int minutes_away, String alternative_contact, OnlineStatus status) {
|
||||
setPresenceInfo(nativePtr, minutes_away, alternative_contact, status.mValue);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue