mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-20 12:38:09 +00:00
add linphone_core_find_friend()
This commit is contained in:
parent
23bca78eef
commit
b47a179309
2 changed files with 21 additions and 30 deletions
|
|
@ -516,40 +516,22 @@ const char *linphone_friend_get_ref_key(const LinphoneFriend *lf){
|
|||
return lf->refkey;
|
||||
}
|
||||
|
||||
static bool_t username_match(const char *u1, const char *u2){
|
||||
if (u1==NULL && u2==NULL) return TRUE;
|
||||
if (u1 && u2 && strcasecmp(u1,u2)==0) return TRUE;
|
||||
return FALSE;
|
||||
LinphoneFriend *linphone_core_find_friend(const LinphoneCore *lc, const LinphoneAddress *addr){
|
||||
LinphoneFriend *lf=NULL;
|
||||
MSList *elem;
|
||||
for(elem=lc->friends;elem!=NULL;elem=ms_list_next(elem)){
|
||||
lf=(LinphoneFriend*)elem->data;
|
||||
if (linphone_address_weak_equal(lf->uri,addr))
|
||||
break;
|
||||
lf=NULL;
|
||||
}
|
||||
return lf;
|
||||
}
|
||||
|
||||
LinphoneFriend *linphone_core_get_friend_by_address(const LinphoneCore *lc, const char *uri){
|
||||
LinphoneAddress *puri=linphone_address_new(uri);
|
||||
const MSList *elem;
|
||||
const char *username;
|
||||
const char *domain;
|
||||
const char *it_username;
|
||||
const char *it_host;
|
||||
LinphoneFriend *lf=NULL;
|
||||
|
||||
if (puri==NULL){
|
||||
return NULL;
|
||||
}
|
||||
username=linphone_address_get_username(puri);
|
||||
domain=linphone_address_get_domain(puri);
|
||||
if (domain==NULL) {
|
||||
linphone_address_destroy(puri);
|
||||
return NULL;
|
||||
}
|
||||
for(elem=lc->friends;elem!=NULL;elem=ms_list_next(elem)){
|
||||
lf=(LinphoneFriend*)elem->data;
|
||||
it_username=linphone_address_get_username(lf->uri);
|
||||
it_host=linphone_address_get_domain(lf->uri);;
|
||||
if (strcasecmp(domain,it_host)==0 && username_match(username,it_username)){
|
||||
break;
|
||||
}
|
||||
lf=NULL;
|
||||
}
|
||||
linphone_address_destroy(puri);
|
||||
LinphoneFriend *lf=puri ? linphone_core_find_friend(lc,puri) : NULL;
|
||||
if (puri) linphone_address_unref(puri);
|
||||
return lf;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -372,9 +372,18 @@ LINPHONE_PUBLIC void linphone_core_notify_all_friends(LinphoneCore *lc, Linphone
|
|||
* @param[in] lc #LinphoneCore object.
|
||||
* @param[in] addr The address to use to search the friend.
|
||||
* @returns The #LinphoneFriend object corresponding to the given address.
|
||||
* @deprecated use linphone_core_find_friend() instead.
|
||||
*/
|
||||
LINPHONE_PUBLIC LinphoneFriend *linphone_core_get_friend_by_address(const LinphoneCore *lc, const char *addr);
|
||||
|
||||
/**
|
||||
* Search a LinphoneFriend by its address.
|
||||
* @param[in] lc #LinphoneCore object.
|
||||
* @param[in] addr The address to use to search the friend.
|
||||
* @returns The #LinphoneFriend object corresponding to the given address.
|
||||
*/
|
||||
LINPHONE_PUBLIC LinphoneFriend *linphone_core_find_friend(const LinphoneCore *lc, const LinphoneAddress *addr);
|
||||
|
||||
/**
|
||||
* Search a LinphoneFriend by its reference key.
|
||||
* @param[in] lc #LinphoneCore object.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue