Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
b47a1793
Commit
b47a1793
authored
Oct 31, 2013
by
Simon Morlat
Browse files
add linphone_core_find_friend()
parent
23bca78e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
28 deletions
+19
-28
coreapi/friend.c
coreapi/friend.c
+10
-28
coreapi/linphonefriend.h
coreapi/linphonefriend.h
+9
-0
No files found.
coreapi/friend.c
View file @
b47a1793
...
...
@@ -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_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
*
linphone_core_find_friend
(
const
LinphoneCore
*
lc
,
const
LinphoneAddress
*
addr
){
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
;
}
MSList
*
elem
;
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
)){
if
(
linphone_address_weak_equal
(
lf
->
uri
,
addr
))
break
;
}
lf
=
NULL
;
}
linphone_address_destroy
(
puri
);
return
lf
;
}
LinphoneFriend
*
linphone_core_get_friend_by_address
(
const
LinphoneCore
*
lc
,
const
char
*
uri
){
LinphoneAddress
*
puri
=
linphone_address_new
(
uri
);
LinphoneFriend
*
lf
=
puri
?
linphone_core_find_friend
(
lc
,
puri
)
:
NULL
;
if
(
puri
)
linphone_address_unref
(
puri
);
return
lf
;
}
...
...
coreapi/linphonefriend.h
View file @
b47a1793
...
...
@@ -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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment