Commit bb8bbfd6 authored by Matthieu Tanon's avatar Matthieu Tanon

Merge branch 'master' into dev_lime_v2

parents 7421eb7d 84aabf73
......@@ -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) {
......@@ -2704,6 +2741,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;
......
......@@ -5483,6 +5483,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
......
......@@ -87,7 +87,7 @@ enabled=true
# in 'a.org b.org c.org', (to.uri.domain in 'a.org b.org c.org')
# && (user-agent == 'Linphone v2')
# Default value:
filter=
filter= !(user-agent contains 'No NatHelper')
# Internal URI parameter added to response contact by first proxy
# and cleaned by last one.
......
......@@ -84,7 +84,7 @@ enabled=true
# in 'a.org b.org c.org', (to.uri.domain in 'a.org b.org c.org')
# && (user-agent == 'Linphone v2')
# Default value:
filter=
filter= !(user-agent contains 'No NatHelper')
# Internal URI parameter added to response contact by first proxy
# and cleaned by last one.
......
......@@ -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
......@@ -1350,6 +1350,91 @@ static void multi_devices_register_with_gruu(void) {
linphone_core_manager_destroy(marie);
}
static void update_contact_private_ip_address(void) {
LinphoneCoreManager *lcm;
stats* counters;
LinphoneProxyConfig *cfg;
char route[256];
LinphoneAddress *from;
char *addr;
LinphoneAuthInfo *ai;
sprintf(route,"sip:%s",test_route);
lcm = linphone_core_manager_new(NULL);
/* Remove gruu for this test */
linphone_core_remove_supported_tag(lcm->lc, "gruu");
/* Disable ipv6 */
linphone_core_enable_ipv6(lcm->lc, FALSE);
counters = get_stats(lcm->lc);
cfg = linphone_core_create_proxy_config(lcm->lc);
from = create_linphone_address(auth_domain);
linphone_proxy_config_set_identity(cfg, addr=linphone_address_as_string(from));
ms_free(addr);
linphone_proxy_config_enable_register(cfg, TRUE);
linphone_proxy_config_set_expires(cfg, 1);
linphone_proxy_config_set_route(cfg, test_route);
linphone_proxy_config_set_server_addr(cfg, test_route);
linphone_address_unref(from);
ai = linphone_auth_info_new(test_username, NULL, test_password, NULL, NULL, NULL);
linphone_core_add_auth_info(lcm->lc, ai);
linphone_auth_info_unref(ai);
linphone_core_add_proxy_config(lcm->lc, cfg);
BC_ASSERT_TRUE(wait_for(lcm->lc, lcm->lc, &counters->number_of_LinphoneRegistrationOk, 1));
BC_ASSERT_EQUAL(counters->number_of_auth_info_requested, 0, int, "%d");
LinphoneAddress *contact = linphone_address_clone(linphone_proxy_config_get_contact(cfg));
BC_ASSERT_PTR_NOT_NULL(contact);
BC_ASSERT_PTR_NOT_NULL(linphone_address_get_domain(contact));
linphone_proxy_config_unref(cfg);
linphone_core_manager_destroy(lcm);
/* We have to recreate the core manager */
lcm = linphone_core_manager_new(NULL);
linphone_core_remove_supported_tag(lcm->lc, "gruu");
linphone_core_enable_ipv6(lcm->lc, FALSE);
/* We want this REGISTER to not be processed by flexisip's NatHelper module */
linphone_core_set_user_agent(lcm->lc, "No NatHelper", NULL);
counters = get_stats(lcm->lc);
cfg = linphone_core_create_proxy_config(lcm->lc);
from = create_linphone_address(auth_domain);
linphone_proxy_config_set_identity(cfg, addr=linphone_address_as_string(from));
ms_free(addr);
linphone_proxy_config_enable_register(cfg, TRUE);
linphone_proxy_config_set_expires(cfg, 1);
linphone_proxy_config_set_route(cfg, test_route);
linphone_proxy_config_set_server_addr(cfg, test_route);
linphone_address_unref(from);
ai = linphone_auth_info_new(test_username, NULL, test_password, NULL, NULL, NULL);
linphone_core_add_auth_info(lcm->lc, ai);
linphone_auth_info_unref(ai);
linphone_core_add_proxy_config(lcm->lc, cfg);
BC_ASSERT_TRUE(wait_for_until(lcm->lc, lcm->lc, &counters->number_of_LinphoneRegistrationOk, 2, 5000));
const LinphoneAddress *contactUpdated = linphone_proxy_config_get_contact(cfg);
BC_ASSERT_PTR_NOT_NULL(contactUpdated);
BC_ASSERT_PTR_NOT_NULL(linphone_address_get_domain(contactUpdated));
BC_ASSERT_STRING_EQUAL(linphone_address_get_domain(contactUpdated), linphone_address_get_domain(contact));
linphone_address_unref(contact);
linphone_proxy_config_unref(cfg);
linphone_core_manager_destroy(lcm);
}
test_t register_tests[] = {
TEST_NO_TAG("Simple register", simple_register),
......@@ -1401,7 +1486,8 @@ test_t register_tests[] = {
TEST_NO_TAG("AuthInfo TLS client certificate authentication in callback", tls_auth_info_client_cert_cb),
TEST_NO_TAG("AuthInfo TLS client certificate authentication in callback 2", tls_auth_info_client_cert_cb_2),
TEST_NO_TAG("Register get GRUU", register_get_gruu),
TEST_NO_TAG("Register get GRUU for multi device", multi_devices_register_with_gruu)
TEST_NO_TAG("Register get GRUU for multi device", multi_devices_register_with_gruu),
TEST_NO_TAG("Update contact private IP address", update_contact_private_ip_address)
};
test_suite_t register_test_suite = {"Register", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each,
......
......@@ -47,7 +47,7 @@ static char* get_public_contact_ip(LinphoneCore* lc) {
}
static void call_with_tunnel_base(LinphoneTunnelMode tunnel_mode, bool_t with_sip, LinphoneMediaEncryption encryption, bool_t with_video_and_ice, bool_t dual_socket) {
static void call_with_tunnel_base(LinphoneTunnelMode tunnel_mode, bool_t with_sip, LinphoneMediaEncryption encryption, bool_t with_video_and_ice, bool_t dual_socket, bool_t gruu) {
if (linphone_core_tunnel_available()){
LinphoneCoreManager *pauline = linphone_core_manager_new( "pauline_rc");
LinphoneCoreManager *marie = linphone_core_manager_new( "marie_rc");
......@@ -58,12 +58,18 @@ static void call_with_tunnel_base(LinphoneTunnelMode tunnel_mode, bool_t with_si
char tunnel_ip[64];
char *public_ip, *public_ip2=NULL;
BC_ASSERT_FALSE(get_ip_from_hostname("tunnel.linphone.org",tunnel_ip,sizeof(tunnel_ip)));
linphone_core_remove_supported_tag(pauline->lc,"gruu"); /*with gruu, we have no access to the "public IP from contact*/
linphone_core_remove_supported_tag(marie->lc,"gruu");
if (!gruu) {
linphone_core_remove_supported_tag(pauline->lc,"gruu"); /*with gruu, we have no access to the "public IP from contact*/
linphone_core_remove_supported_tag(marie->lc,"gruu");
}
BC_ASSERT_TRUE(wait_for(pauline->lc,NULL,&pauline->stat.number_of_LinphoneRegistrationOk,1));
public_ip = get_public_contact_ip(pauline->lc);
BC_ASSERT_STRING_NOT_EQUAL(public_ip, tunnel_ip);
if (!gruu) {
public_ip = get_public_contact_ip(pauline->lc);
BC_ASSERT_STRING_NOT_EQUAL(public_ip, tunnel_ip);
}
linphone_core_set_media_encryption(pauline->lc, encryption);
......@@ -118,16 +124,20 @@ static void call_with_tunnel_base(LinphoneTunnelMode tunnel_mode, bool_t with_si
To:
Contact: <sip:pauline@91.121.209.194:43867>;[....] (91.121.209.194 must be tunnel.liphone.org)
*/
ms_free(public_ip);
public_ip = get_public_contact_ip(pauline->lc);
if (!dual_socket) {
BC_ASSERT_STRING_EQUAL(public_ip, tunnel_ip);
} else {
BC_ASSERT_STRING_EQUAL(public_ip, "94.23.19.176");
if (!gruu) {
ms_free(public_ip);
public_ip = get_public_contact_ip(pauline->lc);
if (!dual_socket) {
BC_ASSERT_STRING_EQUAL(public_ip, tunnel_ip);
} else {
BC_ASSERT_STRING_EQUAL(public_ip, "94.23.19.176");
}
}
} else {
public_ip2 = get_public_contact_ip(pauline->lc);
BC_ASSERT_STRING_EQUAL(public_ip, public_ip2);
if (!gruu) {
public_ip2 = get_public_contact_ip(pauline->lc);
BC_ASSERT_STRING_EQUAL(public_ip, public_ip2);
}
}
}
......@@ -179,30 +189,34 @@ static void call_with_tunnel_base(LinphoneTunnelMode tunnel_mode, bool_t with_si
static void call_with_tunnel(void) {
call_with_tunnel_base(LinphoneTunnelModeEnable, TRUE, LinphoneMediaEncryptionNone, FALSE, FALSE);
call_with_tunnel_base(LinphoneTunnelModeEnable, TRUE, LinphoneMediaEncryptionNone, FALSE, FALSE, FALSE);
}
static void call_with_tunnel_and_gruu(void) {
call_with_tunnel_base(LinphoneTunnelModeEnable, TRUE, LinphoneMediaEncryptionNone, FALSE, FALSE, TRUE);
}
static void call_with_tunnel_srtp(void) {
call_with_tunnel_base(LinphoneTunnelModeEnable, TRUE, LinphoneMediaEncryptionSRTP, FALSE, FALSE);
call_with_tunnel_base(LinphoneTunnelModeEnable, TRUE, LinphoneMediaEncryptionSRTP, FALSE, FALSE, FALSE);
}
static void call_with_tunnel_without_sip(void) {
call_with_tunnel_base(LinphoneTunnelModeEnable, FALSE, LinphoneMediaEncryptionNone, FALSE, FALSE);
call_with_tunnel_base(LinphoneTunnelModeEnable, FALSE, LinphoneMediaEncryptionNone, FALSE, FALSE, FALSE);
}
static void call_with_tunnel_auto(void) {
call_with_tunnel_base(LinphoneTunnelModeAuto, TRUE, LinphoneMediaEncryptionNone, FALSE, FALSE);
call_with_tunnel_base(LinphoneTunnelModeAuto, TRUE, LinphoneMediaEncryptionNone, FALSE, FALSE, FALSE);
}
static void call_with_tunnel_auto_without_sip_with_srtp(void) {
call_with_tunnel_base(LinphoneTunnelModeAuto, FALSE, LinphoneMediaEncryptionSRTP, FALSE, FALSE);
call_with_tunnel_base(LinphoneTunnelModeAuto, FALSE, LinphoneMediaEncryptionSRTP, FALSE, FALSE, FALSE);
}
#ifdef VIDEO_ENABLED
static void full_tunnel_video_ice_call(void){
if (linphone_core_tunnel_available()){
call_with_tunnel_base(LinphoneTunnelModeEnable, TRUE, LinphoneMediaEncryptionNone, TRUE, FALSE);
call_with_tunnel_base(LinphoneTunnelModeEnable, TRUE, LinphoneMediaEncryptionNone, TRUE, FALSE, FALSE);
}else
ms_warning("Could not test %s because tunnel functionality is not available",__FUNCTION__);
}
......@@ -304,20 +318,21 @@ static void register_on_second_tunnel(void) {
static void dual_socket_mode(void) {
if (linphone_core_tunnel_available())
call_with_tunnel_base(LinphoneTunnelModeEnable, FALSE, LinphoneMediaEncryptionNone, FALSE, TRUE);
call_with_tunnel_base(LinphoneTunnelModeEnable, FALSE, LinphoneMediaEncryptionNone, FALSE, TRUE, FALSE);
else
ms_warning("Could not test %s because tunnel functionality is not available",__FUNCTION__);
}
static void dual_socket_mode_with_sip(void) {
if (linphone_core_tunnel_available())
call_with_tunnel_base(LinphoneTunnelModeEnable, TRUE, LinphoneMediaEncryptionNone, FALSE, TRUE);
call_with_tunnel_base(LinphoneTunnelModeEnable, TRUE, LinphoneMediaEncryptionNone, FALSE, TRUE, FALSE);
else
ms_warning("Could not test %s because tunnel functionality is not available",__FUNCTION__);
}
test_t tunnel_tests[] = {
TEST_NO_TAG("Simple", call_with_tunnel),
TEST_NO_TAG("Simple call with gruu", call_with_tunnel_and_gruu),
TEST_NO_TAG("With SRTP", call_with_tunnel_srtp),
TEST_NO_TAG("Without SIP", call_with_tunnel_without_sip),
TEST_NO_TAG("In automatic mode", call_with_tunnel_auto),
......
......@@ -355,16 +355,20 @@ class CsharpTranslator(object):
enumDict['values'] = []
i = 0
lastValue = None
print 'Enum name is ' + enumDict['enumName']
for enumValue in enum.enumerators:
enumValDict = {}
enumValDict['name'] = enumValue.name.translate(self.nameTranslator)
enumValDict['doc'] = enumValue.briefDescription.translate(self.docTranslator, tagAsBrief=True)
if type(enumValue.value) is int:
if isinstance(enumValue.value, int):
print 'Enum value is int ! ' + str(enumValue.value)
lastValue = enumValue.value
enumValDict['value'] = str(enumValue.value)
elif type(enumValue.value) is AbsApi.Flag:
elif isinstance(enumValue.value, AbsApi.Flag):
print 'Enum value is flag ! ' + '1<<' + str(enumValue.value.position)
enumValDict['value'] = '1<<' + str(enumValue.value.position)
else:
print 'Unknown enum value type !'
if lastValue is not None:
enumValDict['value'] = lastValue + 1
lastValue += 1
......@@ -458,7 +462,8 @@ class InterfaceImpl(object):
self.interface = translator.translate_interface(interface)
class WrapperImpl(object):
def __init__(self, enums, interfaces, classes):
def __init__(self, version, enums, interfaces, classes):
self.version = version
self.enums = enums
self.interfaces = interfaces
self.classes = classes
......@@ -478,6 +483,9 @@ def render(renderer, item, path):
if __name__ == '__main__':
import subprocess
git_version = subprocess.check_output(["git", "describe"]).strip()
argparser = argparse.ArgumentParser(description='Generate source files for the C# wrapper')
argparser.add_argument('xmldir', type=str, help='Directory where the XML documentation of the Linphone\'s API generated by Doxygen is placed')
argparser.add_argument('-o --output', type=str, help='the directory where to generate the source files', dest='outputdir', default='.')
......@@ -521,5 +529,5 @@ if __name__ == '__main__':
enum_impl = EnumImpl(_enum, translator)
enums.append(enum_impl)
wrapper = WrapperImpl(enums, interfaces, classes)
wrapper = WrapperImpl(git_version, enums, interfaces, classes)
render(renderer, wrapper, args.outputdir + "/" + args.outputfile)
......@@ -32,6 +32,7 @@ namespace Linphone
/// </summary>
public class LinphoneWrapper
{
public const string VERSION = "{{version}}";
#if __IOS__
public const string LIB_NAME = "linphone.framework/linphone";
#else
......@@ -194,17 +195,21 @@ namespace Linphone
return null;
}
internal static IEnumerable