Commit 1b268d0f authored by jehan's avatar jehan

start presence server tester improvements

parent 425cb857
......@@ -450,9 +450,8 @@ LinphoneAccountCreatorPhoneNumberStatusMask linphone_account_creator_set_phone_n
if (!normalized_phone_number) {
return LinphoneAccountCreatorPhoneNumberStatusInvalid;
}
// if phone is valid, we lastly want to check that length is OK
{
// if phone is valid, we lastly want to check that length is OK in case phone_nunber was normilized
if (strcmp(normalized_phone_number,phone_number) != 0) {
const DialPlan &plan = DialPlan::findByCcc(creator->phone_country_code);
int size = (int)strlen(phone_number);
if (plan.isGeneric()) {
......
......@@ -7624,6 +7624,7 @@ static void update_check_process_response_event(void *ctx, const belle_http_resp
char *url = strchr(body, '\t');
char *ptr;
if (url == NULL) {
ms_error("Bad format for update check answer, cannot find TAB between version and URL");
update_check_process_terminated(lc, LinphoneVersionUpdateCheckError, NULL, NULL);
bctbx_free(body);
return;
......
......@@ -107,11 +107,11 @@ static const char *person_prefix = "/pidf:presence/dm:person";
* PRIVATE FUNCTIONS *
****************************************************************************/
/* Defined in http://www.w3.org/TR/REC-xml/ */
/* Defined in https://www.w3.org/TR/REC-xml-names/#NT-NCName */
static char presence_id_valid_characters[] = "0123456789abcdefghijklmnopqrstuvwxyz-.";
/* NameStartChar (NameChar)* */
static char presence_id_valid_start_characters[] = ":_abcdefghijklmnopqrstuvwxyz";
static char presence_id_valid_start_characters[] = "_abcdefghijklmnopqrstuvwxyz";
static char * generate_presence_id(void) {
char id[7];
......
......@@ -175,7 +175,7 @@ const list<DialPlan> DialPlanPrivate::DialPlans = {
{ "Monaco", "MC", "377", 8, "00" },
{ "Mongolia", "MN", "976", 8, "001" },
{ "Montenegro", "ME", "382", 8, "00" },
{ "Montserrat", "MS", "664", 10, "011" },
{ "Montserrat", "MS", "1", 10, "011" },
{ "Morocco", "MA", "212", 9, "00" },
{ "Mozambique", "MZ", "258", 9, "00" },
{ "Myanmar", "MM", "95", 10, "00" },
......
......@@ -297,7 +297,17 @@ void account_create_in_db(Account *account, LinphoneProxyConfig *cfg, const char
linphone_account_creator_set_user_data(creator, &state);
if (account->phone_alias) {
linphone_account_creator_set_phone_number(creator, account->phone_alias, "33");
LinphoneAccountCreatorPhoneNumberStatusMask err = 0;
const char* country_code = NULL;
if (account->phone_alias[0] == '+') {
const LinphoneDialPlan * ccc = linphone_dial_plan_by_ccc_as_int(linphone_dial_plan_lookup_ccc_from_e164(account->phone_alias));
country_code = linphone_dial_plan_get_country_calling_code(ccc);
}
if ((err = linphone_account_creator_set_phone_number(creator, account->phone_alias, country_code)) != LinphoneAccountCreatorPhoneNumberStatusOk) {
ms_fatal("Could not set phone alias [%s] for account [%s], error [%i]" , account->phone_alias
, linphone_proxy_config_get_identity(cfg)
, err);
};
}
linphone_account_creator_create_account(creator);
......
......@@ -47,6 +47,28 @@ static void enable_deflate_content_encoding(LinphoneCoreManager *mgr, bool_t ena
lp_config_set_string(linphone_core_get_config(lc), "sip", "handle_content_encoding", "none");
}
static char * generate_random_e164_phone_from_dial_plan(const LinphoneDialPlan *dialPlan) {
char phone[64];
size_t i;
/*now with have a dialplan*/
for (i = 0; i < MIN((size_t)linphone_dial_plan_get_national_number_length(dialPlan),sizeof(phone)-1); i++) {
phone[i] = '0' + rand() % 10;
}
phone[i]='\0';
return ms_strdup_printf("+%s%s",linphone_dial_plan_get_country_calling_code(dialPlan),phone);
}
char* generate_random_e164_phone(void) {
const LinphoneDialPlan *dialPlan;
const LinphoneDialPlan *genericDialPlan = linphone_dial_plan_by_ccc(NULL);
while ((dialPlan = linphone_dial_plan_by_ccc_as_int(bctbx_random()%900)) == genericDialPlan);
belle_sip_object_remove_from_leak_detector((void*)genericDialPlan);
belle_sip_object_remove_from_leak_detector((void*)dialPlan); //because mostCommon dial plan is a static object freed at the end of the process. This f is only to avoid wrong leak detection.
return generate_random_e164_phone_from_dial_plan(dialPlan);
}
static void simple(void) {
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
......@@ -866,20 +888,9 @@ static void long_term_presence_phone_alias(void) {
long_term_presence_base("sip:+33123456789@sip.example.org", TRUE, "sip:liblinphone_tester@sip.example.org");
}
static const char* random_phone_number(void) {
static char phone[11];
int i;
phone[0] = '+';
srand ((unsigned int)time(NULL));
for (i = 1; i < 10; i++) {
phone[i] = '0' + rand() % 10;
}
phone[10] = '\0';
return phone;
}
static void long_term_presence_phone_alias2(void) {
LinphoneCoreManager *marie = linphone_core_manager_new3("marie_rc", TRUE, random_phone_number());
char* marie_e164;
LinphoneCoreManager *marie = linphone_core_manager_new3("marie_rc", TRUE, marie_e164 = generate_random_e164_phone());
linphone_core_set_user_agent(marie->lc, "bypass", NULL);
char * identity = linphone_address_as_string_uri_only(marie->identity);
LinphoneAddress * phone_addr = linphone_core_interpret_url(marie->lc, marie->phone_alias);
......@@ -887,6 +898,7 @@ static void long_term_presence_phone_alias2(void) {
long_term_presence_base(phone_addr_uri, TRUE, identity);
ms_free(identity);
ms_free(phone_addr_uri);
ms_free(marie_e164);
linphone_address_unref(phone_addr);
linphone_core_manager_destroy(marie);
}
......@@ -951,7 +963,8 @@ static void long_term_presence_list(void) {
static void long_term_presence_with_e164_phone_without_sip_base(bool_t background_foreground_changes) {
if (linphone_core_vcard_supported()){
LinphoneCoreManager *marie = linphone_core_manager_new3("marie_rc", TRUE, random_phone_number());
char* marie_e164;
LinphoneCoreManager *marie = linphone_core_manager_new3("marie_rc", TRUE, marie_e164 = generate_random_e164_phone());
linphone_core_set_user_agent(marie->lc, "bypass", NULL);
char * identity = linphone_address_as_string_uri_only(marie->identity);
LinphoneAddress * phone_addr = linphone_core_interpret_url(marie->lc, marie->phone_alias);
......@@ -961,7 +974,8 @@ static void long_term_presence_with_e164_phone_without_sip_base(bool_t backgroun
char *presence_contact;
LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
linphone_core_set_user_agent(pauline->lc, "full-presence-support-bypass", NULL);
ms_free(marie_e164);
friend2=linphone_core_create_friend(pauline->lc);
linphone_friend_add_phone_number(friend2, marie->phone_alias);
linphone_core_add_friend(pauline->lc,friend2);
......@@ -1085,17 +1099,6 @@ static void long_term_presence_with_phone_without_sip(void) {
}else ms_warning("Test skipped, no vcard support");
}
static char * generate_random_e164_phone_from_dial_plan(const LinphoneDialPlan *dialPlan) {
char phone[64];
size_t i;
/*now with have a dialplan*/
for (i = 0; i < MIN((size_t)linphone_dial_plan_get_national_number_length(dialPlan),sizeof(phone)-1); i++) {
phone[i] = '0' + rand() % 10;
}
phone[i]='\0';
return ms_strdup_printf("+%s%s",linphone_dial_plan_get_country_calling_code(dialPlan),phone);
}
/* use case:
I have a friend, I invite him to use Linphone for the first time.
This friend is already in my addressbook, with his phone number.
......@@ -1105,16 +1108,12 @@ static char * generate_random_e164_phone_from_dial_plan(const LinphoneDialPlan *
*/
static void long_term_presence_with_crossed_references(void) {
if (linphone_core_vcard_supported()){
const LinphoneDialPlan *dialPlan;
char *e164_marie, *e164_pauline, *e164_laure;
LinphoneFriend* friend2;
while ((dialPlan = linphone_dial_plan_by_ccc_as_int(bctbx_random()%900)) == linphone_dial_plan_by_ccc(NULL));
ms_message("Marie's phone number is %s", e164_marie=generate_random_e164_phone_from_dial_plan(dialPlan));
ms_message("Pauline's phone number is %s", e164_pauline=generate_random_e164_phone_from_dial_plan(dialPlan));
ms_message("Laure's phone number is %s", e164_laure=generate_random_e164_phone_from_dial_plan(dialPlan));
ms_message("Marie's phone number is %s", e164_marie=generate_random_e164_phone());
ms_message("Pauline's phone number is %s", e164_pauline=generate_random_e164_phone());
ms_message("Laure's phone number is %s", e164_laure=generate_random_e164_phone());
/*pauline has marie as friend*/
LinphoneCoreManager *pauline = linphone_core_manager_new3("pauline_tcp_rc",TRUE,e164_pauline);
......@@ -1167,7 +1166,6 @@ static void long_term_presence_with_crossed_references(void) {
BC_ASSERT_TRUE(wait_for_until(pauline->lc,pauline->lc,&pauline->stat.number_of_LinphonePresenceActivityAway,1,4000));
belle_sip_object_remove_from_leak_detector((void*)dialPlan); //because mostCommon dial plan is a static object freed at the end of the process. This f is only to avoid wrong leak detection.
linphone_core_manager_destroy(pauline);
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(laure);
......
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