Commit 84aabf73 authored by Benjamin REIS's avatar Benjamin REIS
Browse files

Merge branch 'feature/bodyless_presence_subscription'

parents c12384e3 8f1b21f8
......@@ -1339,6 +1339,41 @@ static void certificates_config_read(LinphoneCore *lc) {
lc->sal->setTlsPostcheckCallback(_linphone_core_tls_postcheck_callback, lc);
}
static void bodyless_config_read(LinphoneCore *lc) {
const char *lists = lp_config_get_string(lc->config, "sip", "bodyless_lists", NULL);
if (!lists)
return;
char tmp[256] = {0};
char name[256];
char *p, *n;
strncpy(tmp, lists, sizeof(tmp)-1);
for(p = tmp; *p != '\0'; p++) {
if (*p==' ')
continue;
n = strchr(p,',');
if (n)
*n = '\0';
sscanf(p, "%s", name);
LinphoneAddress *addr = linphone_address_new(name);
if(!addr)
continue;
ms_message("Found bodyless friendlist %s", name);
LinphoneFriendList *friendList = linphone_core_create_friend_list(lc);
linphone_friend_list_set_rls_uri(friendList, name);
linphone_friend_list_set_display_name(friendList, linphone_address_get_username(addr));
linphone_address_unref(addr);
linphone_friend_list_set_subscription_bodyless(friendList, TRUE);
linphone_core_add_friend_list(lc, friendList);
if (!n)
break;
p = n;
}
}
static void sip_config_read(LinphoneCore *lc) {
char *contact;
const char *tmpstr;
......@@ -1463,6 +1498,8 @@ static void sip_config_read(LinphoneCore *lc) {
lc->sal->setSupportedTags(lp_config_get_string(lc->config,"sip","supported","replaces, outbound, gruu"));
lc->sip_conf.save_auth_info = !!lp_config_get_int(lc->config, "sip", "save_auth_info", 1);
linphone_core_create_im_notif_policy(lc);
bodyless_config_read(lc);
}
static void rtp_config_read(LinphoneCore *lc) {
......@@ -2702,6 +2739,25 @@ LinphoneFriendList* linphone_core_get_default_friend_list(const LinphoneCore *lc
return NULL;
}
LinphoneFriendList *linphone_core_get_friend_list_by_name(const LinphoneCore *lc, const char *name) {
if (!lc)
return NULL;
LinphoneFriendList *ret = NULL;
bctbx_list_t *list_copy = lc->friends_lists;
while (list_copy) {
LinphoneFriendList *list = (LinphoneFriendList *)list_copy->data;
const char *list_name = linphone_friend_list_get_display_name(list);
if (list_name && strcmp(name, list_name) == 0) {
ret = list;
break;
}
list_copy = list_copy->next;
}
return ret;
}
void linphone_core_remove_friend_list(LinphoneCore *lc, LinphoneFriendList *list) {
bctbx_list_t *elem = bctbx_list_find(lc->friends_lists, list);
if (elem == NULL) return;
......
......@@ -5449,6 +5449,14 @@ 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 the list of #LinphoneFriend from the core that has the given display name.
* @param[in] lc #LinphoneCore object
* @param[in] name the name of the list
* @return the first #LinphoneFriendList object or NULL
*/
LINPHONE_PUBLIC LinphoneFriendList* linphone_core_get_friend_list_by_name(const LinphoneCore *lc, const char *name);
/**
* Retrieves a list of #LinphoneAddress sort and filter
* @param[in] lc #LinphoneCore object
......
......@@ -10,6 +10,15 @@ bellesip@sip.example.org md5:2fc013743b860819a784b0e6c4bee11a ;
liblinphone_sha_tester@sip.example.org clrtxt:secret ;
test%20username@sip.example.org clrtxt:secret ;
sip:friend1@sip.example.org clrtxt:secret ;
sip:friend2@sip.example.org clrtxt:secret ;
sip:friend3@sip.example.org clrtxt:secret ;
sip:friend4@sip.example.org clrtxt:secret ;
sip:buddy1@sip.example.org clrtxt:secret ;
sip:buddy2@sip.example.org clrtxt:secret ;
sip:buddy3@sip.example.org clrtxt:secret ;
sip:bro@sip.example.org clrtxt:secret ;
sip:user_1@sip.example.org clrtxt:secret ;
sip:user_2@sip.example.org clrtxt:secret ;
sip:user_3@sip.example.org clrtxt:secret ;
......
......@@ -1749,17 +1749,17 @@ static void simple_bodyless_list_subscription(void) {
LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
LinphoneFriendList *friendList = linphone_core_create_friend_list(marie->lc);
linphone_core_add_friend_list(marie->lc, friendList);
linphone_friend_list_set_rls_uri(friendList, "sip:friends@sipopen.example.org");
linphone_friend_list_set_rls_uri(friendList, "sip:friends@sip.example.org");
linphone_friend_list_set_display_name(friendList, "Friends");
linphone_friend_list_set_subscription_bodyless(friendList, TRUE);
BC_ASSERT_TRUE(wait_for_until(marie->lc, NULL, &marie->stat.number_of_NotifyPresenceReceived, 4, 4000));
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@sipopen.example.org"));
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(friendList, "sip:friend2@sipopen.example.org"));
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(friendList, "sip:friend3@sipopen.example.org"));
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(friendList, "sip:friend4@sipopen.example.org"));
BC_ASSERT_PTR_NULL(linphone_friend_list_find_friend_by_uri(friendList, "sip:friend5@sipopen.example.org"));
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(friendList, "sip:friend1@sip.example.org"));
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"));
linphone_friend_list_unref(friendList);
linphone_core_manager_destroy(marie);
......@@ -1772,38 +1772,74 @@ static void multiple_bodyless_list_subscription(void) {
LinphoneFriendList *broList = linphone_core_create_friend_list(marie->lc);
linphone_core_add_friend_list(marie->lc, friendList);
linphone_friend_list_set_rls_uri(friendList, "sip:friends@sipopen.example.org");
linphone_friend_list_set_rls_uri(friendList, "sip:friends@sip.example.org");
linphone_friend_list_set_display_name(friendList, "Friends");
linphone_friend_list_set_subscription_bodyless(friendList, TRUE);
linphone_core_add_friend_list(marie->lc, buddyList);
linphone_friend_list_set_rls_uri(buddyList, "sip:buddies@sipopen.example.org");
linphone_friend_list_set_rls_uri(buddyList, "sip:buddies@sip.example.org");
linphone_friend_list_set_display_name(buddyList, "Buddies");
linphone_friend_list_set_subscription_bodyless(buddyList, TRUE);
linphone_core_add_friend_list(marie->lc, broList);
linphone_friend_list_set_rls_uri(broList, "sip:bros@sipopen.example.org");
linphone_friend_list_set_rls_uri(broList, "sip:bros@sip.example.org");
linphone_friend_list_set_display_name(broList, "Bros");
linphone_friend_list_set_subscription_bodyless(broList, TRUE);
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@sipopen.example.org"));
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(friendList, "sip:friend2@sipopen.example.org"));
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(friendList, "sip:friend3@sipopen.example.org"));
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(friendList, "sip:friend4@sipopen.example.org"));
BC_ASSERT_PTR_NULL(linphone_friend_list_find_friend_by_uri(friendList, "sip:friend5@sipopen.example.org"));
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(friendList, "sip:friend1@sip.example.org"));
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"));
BC_ASSERT_EQUAL(bctbx_list_size(linphone_friend_list_get_friends(buddyList)), 3, int, "%d");
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(buddyList, "sip:buddy1@sipopen.example.org"));
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(buddyList, "sip:buddy2@sipopen.example.org"));
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(buddyList, "sip:buddy3@sipopen.example.org"));
BC_ASSERT_PTR_NULL(linphone_friend_list_find_friend_by_uri(buddyList, "sip:buddy4@sipopen.example.org"));
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(buddyList, "sip:buddy1@sip.example.org"));
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(buddyList, "sip:buddy2@sip.example.org"));
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(buddyList, "sip:buddy3@sip.example.org"));
BC_ASSERT_PTR_NULL(linphone_friend_list_find_friend_by_uri(buddyList, "sip:buddy4@sip.example.org"));
BC_ASSERT_EQUAL(bctbx_list_size(linphone_friend_list_get_friends(broList)), 1, int, "%d");
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(broList, "sip:bro@sipopen.example.org"));
BC_ASSERT_PTR_NULL(linphone_friend_list_find_friend_by_uri(broList, "sip:bro2@sipopen.example.org"));
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"));
linphone_friend_list_unref(friendList);
linphone_friend_list_unref(buddyList);
linphone_friend_list_unref(broList);
linphone_core_manager_destroy(marie);
}
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));
LinphoneFriendList *friendList = linphone_core_get_friend_list_by_name(marie->lc, "friends");
LinphoneFriendList *buddyList = linphone_core_get_friend_list_by_name(marie->lc, "buddies");
LinphoneFriendList *broList = linphone_core_get_friend_list_by_name(marie->lc, "bros");
BC_ASSERT_PTR_NOT_NULL(friendList);
BC_ASSERT_PTR_NOT_NULL(buddyList);
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"));
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"));
BC_ASSERT_EQUAL(bctbx_list_size(linphone_friend_list_get_friends(buddyList)), 3, int, "%d");
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(buddyList, "sip:buddy1@sip.example.org"));
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(buddyList, "sip:buddy2@sip.example.org"));
BC_ASSERT_PTR_NOT_NULL(linphone_friend_list_find_friend_by_uri(buddyList, "sip:buddy3@sip.example.org"));
BC_ASSERT_PTR_NULL(linphone_friend_list_find_friend_by_uri(buddyList, "sip:buddy4@sip.example.org"));
BC_ASSERT_EQUAL(bctbx_list_size(linphone_friend_list_get_friends(broList)), 1, int, "%d");
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"));
linphone_friend_list_unref(friendList);
linphone_friend_list_unref(buddyList);
......@@ -1843,6 +1879,7 @@ test_t presence_server_tests[] = {
TEST_NO_TAG("Extended notify only when subscribe then unsubscribe then re-subscribe 2", extended_notify_sub_unsub_sub2),
TEST_ONE_TAG("Simple bodyless list subscription", simple_bodyless_list_subscription, "bodyless"),
TEST_ONE_TAG("Multiple bodyless list subscription", multiple_bodyless_list_subscription, "bodyless"),
TEST_ONE_TAG("Multiple bodyless list subscription with rc", multiple_bodyless_list_subscription_with_rc, "bodyless"),
};
test_suite_t presence_server_test_suite = {"Presence using server", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each,
......
[sip]
sip_port=-1
sip_tcp_port=-1
sip_tls_port=-1
default_proxy=0
ping_with_options=0
composing_idle_timeout=1
store_ha1_passwd=0 #used for sipp
bodyless_lists=sip:friends@sipopen.example.org, sip:buddies@sipopen.example.org, sip:bros@sipopen.example.org
[auth_info_0]
username=marie
userid=marie
passwd=secret
realm=sip.example.org
[proxy_0]
reg_proxy=sip.example.org;transport=tcp
reg_route=sip.example.org;transport=tcp;lr
reg_identity="Super Marie" <sip:marie@sip.example.org>
reg_expires=3600
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
[rtp]
audio_rtp_port=18070-28000
video_rtp_port=28070-38000
text_rtp_port=39000-49000
[video]
display=0
capture=0
show_local=0
size=qcif
enabled=0
self_view=0
automatically_initiate=0
automatically_accept=0
device=StaticImage: Static picture
[sound]
echocancellation=0 #to not overload cpu in case of VG
[net]
dns_srv_enabled=0 #no srv needed in general
stun_server=stun.linphone.org
#leave this section, which is used by "Codec setup" test of "Setup" suite.
[video_codec_0]
mime=VP8
rate=90000
enabled=1
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