Commit d7e1eaf9 authored by Benjamin REIS's avatar Benjamin REIS

parse display name from notify

parent 85f8f93e
......@@ -11,6 +11,8 @@ Group changes to describe their impact on the project, as follows:
Security to invite users to upgrade in case of vulnerabilities.
## [Incomming]
- Implementation of bodyless subscription
- Parsing of Display name in presence NOTIFY
### Added
- Avoid some SIP DNS lookups by keeping SRV target names
......@@ -218,6 +218,7 @@ static void linphone_friend_list_parse_multipart_related_body(LinphoneFriendList
LinphoneFriend *lf;
LinphoneContent *presence_part;
xmlXPathObjectPtr resource_object;
xmlXPathObjectPtr name_object;
char *version_str = NULL;
char *full_state_str = NULL;
char *uri = NULL;
......@@ -261,6 +262,35 @@ static void linphone_friend_list_parse_multipart_related_body(LinphoneFriendList
}
list->expected_notification_version = version + 1;
name_object = linphone_get_xml_xpath_object_for_node_list(xml_ctx, "/rlmi:list/rlmi:resource/rlmi:name/..");
if (name_object && name_object->nodesetval) {
for (i = 1; i <= name_object->nodesetval->nodeNr; i++) {
char *name = NULL;
LinphoneAddress* addr;
linphone_xml_xpath_context_set_node(xml_ctx, xmlXPathNodeSetItem(name_object->nodesetval, i-1));
name = linphone_get_xml_text_content(xml_ctx, "./rlmi:name");
uri = linphone_get_xml_text_content(xml_ctx, "./@uri");
if (!uri)
continue;
addr = linphone_address_new(uri);
if (!addr)
continue;
lf = linphone_friend_list_find_friend_by_address(list, addr);
linphone_address_unref(addr);
if (!lf && list->bodyless_subscription) {
lf = linphone_core_create_friend_with_address(list->lc, uri);
linphone_friend_list_add_friend(list, lf);
linphone_friend_unref(lf);
}
if (name) {
linphone_friend_set_name(lf, name);
linphone_free_xml_text_content(name);
}
}
}
if (name_object)
xmlXPathFreeObject(name_object);
resource_object = linphone_get_xml_xpath_object_for_node_list(xml_ctx, "/rlmi:list/rlmi:resource/rlmi:instance[@state=\"active\"]/..");
if (resource_object && resource_object->nodesetval) {
for (i = 1; i <= resource_object->nodesetval->nodeNr; i++) {
......
......@@ -1341,7 +1341,7 @@ static void certificates_config_read(LinphoneCore *lc) {
static void bodyless_config_read(LinphoneCore *lc) {
// Clean previous friend lists
linphone_core_clear_friend_lists(lc);
linphone_core_clear_bodyless_friend_lists(lc);
bctbx_list_t *bodyless_lists = linphone_config_get_string_list(lc->config, "sip", "bodyless_lists", NULL);
while (bodyless_lists) {
......@@ -2776,11 +2776,13 @@ void linphone_core_remove_friend_list(LinphoneCore *lc, LinphoneFriendList *list
lc->friends_lists = bctbx_list_erase_link(lc->friends_lists, elem);
}
void linphone_core_clear_friend_lists(LinphoneCore *lc) {
void linphone_core_clear_bodyless_friend_lists(LinphoneCore *lc) {
bctbx_list_t* list = bctbx_list_copy(linphone_core_get_friends_lists((const LinphoneCore *)lc));
bctbx_list_t* copy = list;
for (; list != NULL; list = list->next) {
linphone_core_remove_friend_list(lc, (LinphoneFriendList *)list->data);
LinphoneFriendList *friends = (LinphoneFriendList *)list->data;
if (linphone_friend_list_is_subscription_bodyless(friends))
linphone_core_remove_friend_list(lc, (LinphoneFriendList *)list->data);
}
bctbx_list_free(copy);
}
......
......@@ -5521,10 +5521,10 @@ LINPHONE_PUBLIC void linphone_core_add_friend_list(LinphoneCore *lc, LinphoneFri
LINPHONE_PUBLIC void linphone_core_remove_friend_list(LinphoneCore *lc, LinphoneFriendList *list);
/**
* Removes all friend lists.
* Removes all bodyless friend lists.
* @param[in] lc #LinphoneCore object
*/
LINPHONE_PUBLIC void linphone_core_clear_friend_lists(LinphoneCore *lc);
LINPHONE_PUBLIC void linphone_core_clear_bodyless_friend_lists(LinphoneCore *lc);
/**
* Retrieves the list of #LinphoneFriendList from the core.
......
......@@ -1755,12 +1755,16 @@ static void simple_bodyless_list_subscription(void) {
BC_ASSERT_TRUE(wait_for_until(marie->lc, NULL, &marie->stat.number_of_NotifyPresenceReceived, 4, 15000));
BC_ASSERT_EQUAL(bctbx_list_size(linphone_friend_list_get_friends(friendList)), 4, int, "%d");
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(friendList, "sip:friend1@sip.example.org"));
LinphoneFriend *friend1 = linphone_friend_list_find_friend_by_uri(friendList, "sip:friend1@sip.example.org");
if (!BC_ASSERT_PTR_NOT_NULL(friend1))
goto end;
BC_ASSERT_STRING_EQUAL(linphone_friend_get_name(friend1), "Friend 1");
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(friendList, "sip:friend2@sip.example.org"));
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(friendList, "sip:friend3@sip.example.org"));
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(friendList, "sip:friend4@sip.example.org"));
BC_ASSERT_PTR_NULL(linphone_friend_list_find_friend_by_uri(friendList, "sip:friend5@sip.example.org"));
end:
linphone_friend_list_unref(friendList);
linphone_core_manager_destroy(marie);
}
......@@ -1789,7 +1793,10 @@ static void multiple_bodyless_list_subscription(void) {
BC_ASSERT_TRUE(wait_for_until(marie->lc, NULL, &marie->stat.number_of_NotifyPresenceReceived, 8, 8000));
BC_ASSERT_EQUAL(bctbx_list_size(linphone_friend_list_get_friends(friendList)), 4, int, "%d");
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(friendList, "sip:friend1@sip.example.org"));
LinphoneFriend *friend1 = linphone_friend_list_find_friend_by_uri(friendList, "sip:friend1@sip.example.org");
if (!BC_ASSERT_PTR_NOT_NULL(friend1))
goto end;
BC_ASSERT_STRING_EQUAL(linphone_friend_get_name(friend1), "Friend 1");
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(friendList, "sip:friend2@sip.example.org"));
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(friendList, "sip:friend3@sip.example.org"));
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(friendList, "sip:friend4@sip.example.org"));
......@@ -1805,6 +1812,7 @@ static void multiple_bodyless_list_subscription(void) {
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(broList, "sip:bro@sip.example.org"));
BC_ASSERT_PTR_NULL(linphone_friend_list_find_friend_by_uri(broList, "sip:bro2@sip.example.org"));
end:
linphone_friend_list_unref(friendList);
linphone_friend_list_unref(buddyList);
linphone_friend_list_unref(broList);
......@@ -1814,7 +1822,7 @@ static void multiple_bodyless_list_subscription(void) {
static void multiple_bodyless_list_subscription_with_rc(void) {
LinphoneCoreManager *marie = linphone_core_manager_new("marie_bodyless_rc");
BC_ASSERT_TRUE(wait_for_until(marie->lc, NULL, &marie->stat.number_of_NotifyPresenceReceived, 8, 8000));
BC_ASSERT_TRUE(wait_for_until(marie->lc, NULL, &marie->stat.number_of_NotifyPresenceReceived, 9, 8000));
LinphoneFriendList *friendList = linphone_core_get_friend_list_by_name(marie->lc, "Friends of Marie");
LinphoneFriendList *buddyList = linphone_core_get_friend_list_by_name(marie->lc, "buddies");
......@@ -1825,7 +1833,10 @@ static void multiple_bodyless_list_subscription_with_rc(void) {
BC_ASSERT_PTR_NOT_NULL(broList);
BC_ASSERT_EQUAL(bctbx_list_size(linphone_friend_list_get_friends(friendList)), 4, int, "%d");
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(friendList, "sip:friend1@sip.example.org"));
LinphoneFriend *friend1 = linphone_friend_list_find_friend_by_uri(friendList, "sip:friend1@sip.example.org");
if (!BC_ASSERT_PTR_NOT_NULL(friend1))
goto end;
BC_ASSERT_STRING_EQUAL(linphone_friend_get_name(friend1), "Friend 1");
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(friendList, "sip:friend2@sip.example.org"));
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(friendList, "sip:friend3@sip.example.org"));
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(friendList, "sip:friend4@sip.example.org"));
......@@ -1841,6 +1852,7 @@ static void multiple_bodyless_list_subscription_with_rc(void) {
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(broList, "sip:bro@sip.example.org"));
BC_ASSERT_PTR_NULL(linphone_friend_list_find_friend_by_uri(broList, "sip:bro2@sip.example.org"));
end:
linphone_core_manager_destroy(marie);
}
......
......@@ -23,11 +23,6 @@ reg_sendregister=1
publish=0
dial_escape_plus=0
[friend_0]
url="Paupoche" <sip:pauline@sip.example.org>
pol=accept
subscribe=0
[misc]
enable_basic_to_client_group_chat_room_migration=1
basic_to_client_group_chat_room_migration_timer=180
......
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