Revert "presence_tester.c: add some long term tests"

This reverts commit 9eca8962.
parent 3f495448
...@@ -25,8 +25,8 @@ static void register_refresher_listener (belle_sip_refresher_t* refresher ...@@ -25,8 +25,8 @@ static void register_refresher_listener (belle_sip_refresher_t* refresher
,const char* reason_phrase) { ,const char* reason_phrase) {
SalOp* op = (SalOp*)user_pointer; SalOp* op = (SalOp*)user_pointer;
belle_sip_response_t* response=belle_sip_transaction_get_response(BELLE_SIP_TRANSACTION(belle_sip_refresher_get_transaction(refresher))); belle_sip_response_t* response=belle_sip_transaction_get_response(BELLE_SIP_TRANSACTION(belle_sip_refresher_get_transaction(refresher)));
ms_message("Register refresher [%i] reason [%s] for proxy [%s]",status_code,reason_phrase,sal_op_get_proxy(op)); ms_message("Register refresher [%i] reason [%s] for proxy [%s]",status_code,reason_phrase,sal_op_get_proxy(op));
if (belle_sip_refresher_get_auth_events(refresher)) { if (belle_sip_refresher_get_auth_events(refresher)) {
if (op->auth_info) sal_auth_info_delete(op->auth_info); if (op->auth_info) sal_auth_info_delete(op->auth_info);
/*only take first one for now*/ /*only take first one for now*/
...@@ -46,7 +46,7 @@ static void register_refresher_listener (belle_sip_refresher_t* refresher ...@@ -46,7 +46,7 @@ static void register_refresher_listener (belle_sip_refresher_t* refresher
} }
sal_op_set_service_route(op,(const SalAddress*)service_route_address); sal_op_set_service_route(op,(const SalAddress*)service_route_address);
if (service_route_address) belle_sip_object_unref(service_route_address); if (service_route_address) belle_sip_object_unref(service_route_address);
sal_remove_pending_auth(op->base.root,op); /*just in case*/ sal_remove_pending_auth(op->base.root,op); /*just in case*/
if (contact) { if (contact) {
sal_op_set_contact_address(op,(SalAddress*)(BELLE_SIP_HEADER_ADDRESS(contact))); /*update contact with real value*/ sal_op_set_contact_address(op,(SalAddress*)(BELLE_SIP_HEADER_ADDRESS(contact))); /*update contact with real value*/
...@@ -79,13 +79,13 @@ int sal_register(SalOp *op, const char *proxy, const char *from, int expires,Sal ...@@ -79,13 +79,13 @@ int sal_register(SalOp *op, const char *proxy, const char *from, int expires,Sal
belle_sip_request_t *req; belle_sip_request_t *req;
belle_sip_uri_t* req_uri; belle_sip_uri_t* req_uri;
belle_sip_header_t* accept_header; belle_sip_header_t* accept_header;
if (op->refresher){ if (op->refresher){
belle_sip_refresher_stop(op->refresher); belle_sip_refresher_stop(op->refresher);
belle_sip_object_unref(op->refresher); belle_sip_object_unref(op->refresher);
op->refresher=NULL; op->refresher=NULL;
} }
op->type=SalOpRegister; op->type=SalOpRegister;
sal_op_set_from(op,from); sal_op_set_from(op,from);
sal_op_set_to(op,from); sal_op_set_to(op,from);
......
...@@ -296,7 +296,6 @@ static void linphone_friend_list_destroy(LinphoneFriendList *list) { ...@@ -296,7 +296,6 @@ static void linphone_friend_list_destroy(LinphoneFriendList *list) {
if (list->event != NULL) { if (list->event != NULL) {
linphone_event_terminate(list->event); linphone_event_terminate(list->event);
linphone_event_unref(list->event); linphone_event_unref(list->event);
list->event = NULL;
} }
if (list->uri != NULL) ms_free(list->uri); if (list->uri != NULL) ms_free(list->uri);
if (list->cbs) linphone_friend_list_cbs_unref(list->cbs); if (list->cbs) linphone_friend_list_cbs_unref(list->cbs);
...@@ -437,7 +436,7 @@ LinphoneFriendListStatus linphone_friend_list_import_friend(LinphoneFriendList * ...@@ -437,7 +436,7 @@ LinphoneFriendListStatus linphone_friend_list_import_friend(LinphoneFriendList *
return LinphoneFriendListOK; return LinphoneFriendListOK;
} }
static void carddav_done(LinphoneCardDavContext *cdc, bool_t success, const char *msg) { static void carddav_done(LinphoneCardDavContext *cdc, bool_t success, const char *msg) {
if (cdc && cdc->friend_list->cbs->sync_state_changed_cb) { if (cdc && cdc->friend_list->cbs->sync_state_changed_cb) {
cdc->friend_list->cbs->sync_state_changed_cb(cdc->friend_list, success ? LinphoneFriendListSyncSuccessful : LinphoneFriendListSyncFailure, msg); cdc->friend_list->cbs->sync_state_changed_cb(cdc->friend_list, success ? LinphoneFriendListSyncSuccessful : LinphoneFriendListSyncFailure, msg);
} }
...@@ -466,7 +465,7 @@ static LinphoneFriendListStatus _linphone_friend_list_remove_friend(LinphoneFrie ...@@ -466,7 +465,7 @@ static LinphoneFriendListStatus _linphone_friend_list_remove_friend(LinphoneFrie
} }
} }
} }
lf->friend_list = NULL; lf->friend_list = NULL;
linphone_friend_unref(lf); linphone_friend_unref(lf);
list->friends = ms_list_remove_link(list->friends, elem); list->friends = ms_list_remove_link(list->friends, elem);
...@@ -484,7 +483,7 @@ const MSList * linphone_friend_list_get_friends(const LinphoneFriendList *list) ...@@ -484,7 +483,7 @@ const MSList * linphone_friend_list_get_friends(const LinphoneFriendList *list)
void linphone_friend_list_update_dirty_friends(LinphoneFriendList *list) { void linphone_friend_list_update_dirty_friends(LinphoneFriendList *list) {
LinphoneCardDavContext *cdc = linphone_carddav_context_new(list); LinphoneCardDavContext *cdc = linphone_carddav_context_new(list);
MSList *dirty_friends = list->dirty_friends_to_update; MSList *dirty_friends = list->dirty_friends_to_update;
if (cdc) { if (cdc) {
cdc->sync_done_cb = carddav_done; cdc->sync_done_cb = carddav_done;
while (dirty_friends) { while (dirty_friends) {
...@@ -529,7 +528,7 @@ static void carddav_updated(LinphoneCardDavContext *cdc, LinphoneFriend *lf_new, ...@@ -529,7 +528,7 @@ static void carddav_updated(LinphoneCardDavContext *cdc, LinphoneFriend *lf_new,
elem->data = linphone_friend_ref(lf_new); elem->data = linphone_friend_ref(lf_new);
} }
linphone_core_store_friend_in_db(lf_new->lc, lf_new); linphone_core_store_friend_in_db(lf_new->lc, lf_new);
if (cdc->friend_list->cbs->contact_updated_cb) { if (cdc->friend_list->cbs->contact_updated_cb) {
cdc->friend_list->cbs->contact_updated_cb(lfl, lf_new, lf_old); cdc->friend_list->cbs->contact_updated_cb(lfl, lf_new, lf_old);
} }
...@@ -539,7 +538,7 @@ static void carddav_updated(LinphoneCardDavContext *cdc, LinphoneFriend *lf_new, ...@@ -539,7 +538,7 @@ static void carddav_updated(LinphoneCardDavContext *cdc, LinphoneFriend *lf_new,
void linphone_friend_list_synchronize_friends_from_server(LinphoneFriendList *list) { void linphone_friend_list_synchronize_friends_from_server(LinphoneFriendList *list) {
LinphoneCardDavContext *cdc = linphone_carddav_context_new(list); LinphoneCardDavContext *cdc = linphone_carddav_context_new(list);
if (cdc) { if (cdc) {
cdc->contact_created_cb = carddav_created; cdc->contact_created_cb = carddav_created;
cdc->contact_removed_cb = carddav_removed; cdc->contact_removed_cb = carddav_removed;
...@@ -735,7 +734,7 @@ void linphone_friend_list_subscription_state_changed(LinphoneCore *lc, LinphoneE ...@@ -735,7 +734,7 @@ void linphone_friend_list_subscription_state_changed(LinphoneCore *lc, LinphoneE
, linphone_subscription_state_to_string(state) , linphone_subscription_state_to_string(state)
, lev , lev
, list); , list);
if (state == LinphoneSubscriptionOutgoingProgress && linphone_event_get_reason(lev) == LinphoneReasonNoMatch) { if (state == LinphoneSubscriptionOutgoingProgress && linphone_event_get_reason(lev) == LinphoneReasonNoMatch) {
ms_message("Resseting version count for friend list [%p]",list); ms_message("Resseting version count for friend list [%p]",list);
list->expected_notification_version = 0; list->expected_notification_version = 0;
...@@ -750,7 +749,7 @@ LinphoneCore* linphone_friend_list_get_core(LinphoneFriendList *list) { ...@@ -750,7 +749,7 @@ LinphoneCore* linphone_friend_list_get_core(LinphoneFriendList *list) {
int linphone_friend_list_import_friends_from_vcard4_file(LinphoneFriendList *list, const char *vcard_file) { int linphone_friend_list_import_friends_from_vcard4_file(LinphoneFriendList *list, const char *vcard_file) {
MSList *vcards = linphone_vcard_list_from_vcard4_file(vcard_file); MSList *vcards = linphone_vcard_list_from_vcard4_file(vcard_file);
int count = 0; int count = 0;
#ifndef VCARD_ENABLED #ifndef VCARD_ENABLED
ms_error("vCard support wasn't enabled at compilation time"); ms_error("vCard support wasn't enabled at compilation time");
return -1; return -1;
...@@ -763,7 +762,7 @@ int linphone_friend_list_import_friends_from_vcard4_file(LinphoneFriendList *lis ...@@ -763,7 +762,7 @@ int linphone_friend_list_import_friends_from_vcard4_file(LinphoneFriendList *lis
ms_error("Can't import into a NULL list"); ms_error("Can't import into a NULL list");
return -1; return -1;
} }
while (vcards != NULL && vcards->data != NULL) { while (vcards != NULL && vcards->data != NULL) {
LinphoneVcard *vcard = (LinphoneVcard *)vcards->data; LinphoneVcard *vcard = (LinphoneVcard *)vcards->data;
LinphoneFriend *lf = linphone_friend_new_from_vcard(vcard); LinphoneFriend *lf = linphone_friend_new_from_vcard(vcard);
...@@ -786,7 +785,7 @@ int linphone_friend_list_import_friends_from_vcard4_file(LinphoneFriendList *lis ...@@ -786,7 +785,7 @@ int linphone_friend_list_import_friends_from_vcard4_file(LinphoneFriendList *lis
int linphone_friend_list_import_friends_from_vcard4_buffer(LinphoneFriendList *list, const char *vcard_buffer) { int linphone_friend_list_import_friends_from_vcard4_buffer(LinphoneFriendList *list, const char *vcard_buffer) {
MSList *vcards = linphone_vcard_list_from_vcard4_buffer(vcard_buffer); MSList *vcards = linphone_vcard_list_from_vcard4_buffer(vcard_buffer);
int count = 0; int count = 0;
#ifndef VCARD_ENABLED #ifndef VCARD_ENABLED
ms_error("vCard support wasn't enabled at compilation time"); ms_error("vCard support wasn't enabled at compilation time");
return -1; return -1;
...@@ -799,7 +798,7 @@ int linphone_friend_list_import_friends_from_vcard4_buffer(LinphoneFriendList *l ...@@ -799,7 +798,7 @@ int linphone_friend_list_import_friends_from_vcard4_buffer(LinphoneFriendList *l
ms_error("Can't import into a NULL list"); ms_error("Can't import into a NULL list");
return -1; return -1;
} }
while (vcards != NULL && vcards->data != NULL) { while (vcards != NULL && vcards->data != NULL) {
LinphoneVcard *vcard = (LinphoneVcard *)vcards->data; LinphoneVcard *vcard = (LinphoneVcard *)vcards->data;
LinphoneFriend *lf = linphone_friend_new_from_vcard(vcard); LinphoneFriend *lf = linphone_friend_new_from_vcard(vcard);
...@@ -822,13 +821,13 @@ int linphone_friend_list_import_friends_from_vcard4_buffer(LinphoneFriendList *l ...@@ -822,13 +821,13 @@ int linphone_friend_list_import_friends_from_vcard4_buffer(LinphoneFriendList *l
void linphone_friend_list_export_friends_as_vcard4_file(LinphoneFriendList *list, const char *vcard_file) { void linphone_friend_list_export_friends_as_vcard4_file(LinphoneFriendList *list, const char *vcard_file) {
FILE *file = NULL; FILE *file = NULL;
const MSList *friends = linphone_friend_list_get_friends(list); const MSList *friends = linphone_friend_list_get_friends(list);
file = fopen(vcard_file, "wb"); file = fopen(vcard_file, "wb");
if (file == NULL) { if (file == NULL) {
ms_warning("Could not write %s ! Maybe it is read-only. Contacts will not be saved.", vcard_file); ms_warning("Could not write %s ! Maybe it is read-only. Contacts will not be saved.", vcard_file);
return; return;
} }
#ifndef VCARD_ENABLED #ifndef VCARD_ENABLED
ms_error("vCard support wasn't enabled at compilation time"); ms_error("vCard support wasn't enabled at compilation time");
#endif #endif
...@@ -843,6 +842,6 @@ void linphone_friend_list_export_friends_as_vcard4_file(LinphoneFriendList *list ...@@ -843,6 +842,6 @@ void linphone_friend_list_export_friends_as_vcard4_file(LinphoneFriendList *list
} }
friends = ms_list_next(friends); friends = ms_list_next(friends);
} }
fclose(file); fclose(file);
} }
...@@ -23,9 +23,9 @@ struct _Account{ ...@@ -23,9 +23,9 @@ struct _Account{
LinphoneAddress *identity; LinphoneAddress *identity;
LinphoneAddress *modified_identity; LinphoneAddress *modified_identity;
char *password; char *password;
int registered;
int done;
int created; int created;
int done;
int auth_requested;
}; };
typedef struct _Account Account; typedef struct _Account Account;
...@@ -95,15 +95,9 @@ Account *account_manager_get_account(AccountManager *m, const LinphoneAddress *i ...@@ -95,15 +95,9 @@ Account *account_manager_get_account(AccountManager *m, const LinphoneAddress *i
static void account_created_on_server_cb(LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState state, const char *info){ static void account_created_on_server_cb(LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState state, const char *info){
Account *account=(Account*)linphone_core_get_user_data(lc); Account *account=(Account*)linphone_core_get_user_data(lc);
switch(state){ switch(state){
case LinphoneRegistrationOk: { case LinphoneRegistrationOk:
char * phrase = sal_op_get_error_info((SalOp*)cfg->op)->full_string; account->created=1;
if (phrase && strcasecmp("Test account created", phrase) == 0) { break;
account->created=1;
} else {
account->registered=1;
}
break;
}
case LinphoneRegistrationCleared: case LinphoneRegistrationCleared:
account->done=1; account->done=1;
break; break;
...@@ -112,6 +106,11 @@ static void account_created_on_server_cb(LinphoneCore *lc, LinphoneProxyConfig * ...@@ -112,6 +106,11 @@ static void account_created_on_server_cb(LinphoneCore *lc, LinphoneProxyConfig *
} }
} }
static void account_created_auth_requested_cb(LinphoneCore *lc, const char *username, const char *realm, const char *domain){
Account *account=(Account*)linphone_core_get_user_data(lc);
account->auth_requested=1;
}
void account_create_on_server(Account *account, const LinphoneProxyConfig *refcfg){ void account_create_on_server(Account *account, const LinphoneProxyConfig *refcfg){
LinphoneCoreVTable vtable={0}; LinphoneCoreVTable vtable={0};
LinphoneCore *lc; LinphoneCore *lc;
...@@ -123,6 +122,7 @@ void account_create_on_server(Account *account, const LinphoneProxyConfig *refcf ...@@ -123,6 +122,7 @@ void account_create_on_server(Account *account, const LinphoneProxyConfig *refcf
LCSipTransports tr; LCSipTransports tr;
vtable.registration_state_changed=account_created_on_server_cb; vtable.registration_state_changed=account_created_on_server_cb;
vtable.auth_info_requested=account_created_auth_requested_cb;
lc=configure_lc_from(&vtable,bc_tester_get_resource_dir_prefix(),NULL,account); lc=configure_lc_from(&vtable,bc_tester_get_resource_dir_prefix(),NULL,account);
tr.udp_port=LC_SIP_TRANSPORT_RANDOM; tr.udp_port=LC_SIP_TRANSPORT_RANDOM;
tr.tcp_port=LC_SIP_TRANSPORT_RANDOM; tr.tcp_port=LC_SIP_TRANSPORT_RANDOM;
...@@ -150,7 +150,7 @@ void account_create_on_server(Account *account, const LinphoneProxyConfig *refcf ...@@ -150,7 +150,7 @@ void account_create_on_server(Account *account, const LinphoneProxyConfig *refcf
linphone_core_add_proxy_config(lc,cfg); linphone_core_add_proxy_config(lc,cfg);
if (wait_for_until(lc,NULL,&account->created,1,10000)==FALSE){ if (wait_for_until(lc,NULL,&account->auth_requested,1,10000)==FALSE){
ms_fatal("Account for %s could not be created on server.", linphone_proxy_config_get_identity(refcfg)); ms_fatal("Account for %s could not be created on server.", linphone_proxy_config_get_identity(refcfg));
} }
linphone_proxy_config_edit(cfg); linphone_proxy_config_edit(cfg);
...@@ -168,7 +168,7 @@ void account_create_on_server(Account *account, const LinphoneProxyConfig *refcf ...@@ -168,7 +168,7 @@ void account_create_on_server(Account *account, const LinphoneProxyConfig *refcf
linphone_core_add_auth_info(lc,ai); linphone_core_add_auth_info(lc,ai);
linphone_auth_info_destroy(ai); linphone_auth_info_destroy(ai);
if (wait_for_until(lc,NULL,&account->registered,1,3000)==FALSE){ if (wait_for_until(lc,NULL,&account->created,1,3000)==FALSE){
ms_fatal("Account for %s is not working on server.", linphone_proxy_config_get_identity(refcfg)); ms_fatal("Account for %s is not working on server.", linphone_proxy_config_get_identity(refcfg));
} }
linphone_core_remove_proxy_config(lc,cfg); linphone_core_remove_proxy_config(lc,cfg);
......
...@@ -501,7 +501,7 @@ static void subscriber_no_longer_reachable(void){ ...@@ -501,7 +501,7 @@ static void subscriber_no_longer_reachable(void){
/*make sure marie subscribe is not reset by accident because of code below located in linphone_core_iterate /*make sure marie subscribe is not reset by accident because of code below located in linphone_core_iterate
if (lc->sip_network_reachable && lc->netup_time!=0 && (current_real_time-lc->netup_time)>3){ if (lc->sip_network_reachable && lc->netup_time!=0 && (current_real_time-lc->netup_time)>3){
linphone_core_send_initial_subscribes(lc); linphone_core_send_initial_subscribes(lc);
} }
*/ */
...@@ -532,10 +532,10 @@ static void subscriber_no_longer_reachable(void){ ...@@ -532,10 +532,10 @@ static void subscriber_no_longer_reachable(void){
} }
static void subscribe_with_late_publish(void) { static void test_subscribe_notify_publish(void) {
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
LinphoneProxyConfig* proxy; LinphoneProxyConfig* proxy;
LinphonePresenceModel* presence; LinphonePresenceModel* presence;
LpConfig *pauline_lp; LpConfig *pauline_lp;
...@@ -611,7 +611,7 @@ static void test_forked_subscribe_notify_publish(void) { ...@@ -611,7 +611,7 @@ static void test_forked_subscribe_notify_publish(void) {
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
LinphoneCoreManager* marie2 = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* marie2 = linphone_core_manager_new( "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
LinphoneProxyConfig* proxy; LinphoneProxyConfig* proxy;
LinphonePresenceModel* presence; LinphonePresenceModel* presence;
LpConfig *pauline_lp; LpConfig *pauline_lp;
...@@ -701,7 +701,7 @@ static void enable_deflate_content_encoding(LinphoneCoreManager *mgr, bool_t ena ...@@ -701,7 +701,7 @@ static void enable_deflate_content_encoding(LinphoneCoreManager *mgr, bool_t ena
static void test_presence_list_base(bool_t enable_compression) { static void test_presence_list_base(bool_t enable_compression) {
LinphoneCoreManager *laure = linphone_core_manager_new("laure_tcp_rc"); LinphoneCoreManager *laure = linphone_core_manager_new("laure_tcp_rc");
LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc");
const char *rls_uri = "sip:rls@sip.example.org"; const char *rls_uri = "sip:rls@sip.example.org";
LinphoneFriendList *lfl; LinphoneFriendList *lfl;
LinphoneFriend *lf; LinphoneFriend *lf;
...@@ -744,20 +744,20 @@ static void test_presence_list_base(bool_t enable_compression) { ...@@ -744,20 +744,20 @@ static void test_presence_list_base(bool_t enable_compression) {
lcs = ms_list_append(lcs, pauline->lc); lcs = ms_list_append(lcs, pauline->lc);
wait_for_list(lcs, &laure->stat.number_of_NotifyPresenceReceived, 2, 2000); wait_for_list(lcs, &laure->stat.number_of_NotifyPresenceReceived, 2, 2000);
BC_ASSERT_EQUAL_FATAL(laure->stat.number_of_NotifyPresenceReceived, 2, int, "%d"); BC_ASSERT_EQUAL(laure->stat.number_of_NotifyPresenceReceived, 2, int, "%d");
BC_ASSERT_EQUAL_FATAL(linphone_core_get_default_friend_list(laure->lc)->expected_notification_version, 1, int, "%d"); BC_ASSERT_EQUAL(linphone_core_get_default_friend_list(laure->lc)->expected_notification_version, 1, int, "%d");
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), marie_identity); lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), marie_identity);
BC_ASSERT_EQUAL_FATAL(linphone_friend_get_status(lf), LinphoneStatusBusy, int, "%d"); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusBusy, int, "%d");
BC_ASSERT_TRUE_FATAL(lf->presence_received); BC_ASSERT_EQUAL(lf->presence_received, TRUE, int, "%d");
BC_ASSERT_TRUE_FATAL(lf->subscribe_active); BC_ASSERT_EQUAL(lf->subscribe_active, TRUE, int, "%d");
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), pauline_identity); lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), pauline_identity);
BC_ASSERT_EQUAL_FATAL(linphone_friend_get_status(lf), LinphoneStatusVacation, int, "%d"); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusVacation, int, "%d");
BC_ASSERT_TRUE_FATAL(lf->presence_received); BC_ASSERT_EQUAL(lf->presence_received, TRUE, int, "%d");
BC_ASSERT_TRUE_FATAL(lf->subscribe_active); BC_ASSERT_EQUAL(lf->subscribe_active, TRUE, int, "%d");
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), "sip:michelle@sip.inexistentdomain.com"); lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), "sip:michelle@sip.inexistentdomain.com");
BC_ASSERT_EQUAL_FATAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d"); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d");
BC_ASSERT_FALSE_FATAL(lf->presence_received); BC_ASSERT_EQUAL(lf->presence_received, FALSE, int, "%d");
BC_ASSERT_TRUE_FATAL(lf->subscribe_active); BC_ASSERT_EQUAL(lf->subscribe_active, TRUE, int, "%d");
lfl = linphone_core_create_friend_list(marie->lc); lfl = linphone_core_create_friend_list(marie->lc);
linphone_friend_list_set_rls_uri(lfl, rls_uri); linphone_friend_list_set_rls_uri(lfl, rls_uri);
...@@ -770,12 +770,12 @@ static void test_presence_list_base(bool_t enable_compression) { ...@@ -770,12 +770,12 @@ static void test_presence_list_base(bool_t enable_compression) {
linphone_friend_list_update_subscriptions(linphone_core_get_default_friend_list(marie->lc), NULL, FALSE); linphone_friend_list_update_subscriptions(linphone_core_get_default_friend_list(marie->lc), NULL, FALSE);
wait_for_list(lcs, &marie->stat.number_of_NotifyPresenceReceived, 1, 2000); wait_for_list(lcs, &marie->stat.number_of_NotifyPresenceReceived, 1, 2000);
BC_ASSERT_EQUAL_FATAL(marie->stat.number_of_NotifyPresenceReceived, 1, int, "%d"); BC_ASSERT_EQUAL(marie->stat.number_of_NotifyPresenceReceived, 1, int, "%d");
BC_ASSERT_EQUAL_FATAL(linphone_core_get_default_friend_list(marie->lc)->expected_notification_version, 1, int, "%d"); BC_ASSERT_EQUAL(linphone_core_get_default_friend_list(marie->lc)->expected_notification_version, 1, int, "%d");
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(marie->lc), laure_identity); lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(marie->lc), laure_identity);
BC_ASSERT_EQUAL_FATAL(linphone_friend_get_status(lf), LinphoneStatusOnline, int, "%d"); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOnline, int, "%d");
BC_ASSERT_TRUE_FATAL(lf->presence_received); BC_ASSERT_EQUAL(lf->presence_received, TRUE, int, "%d");
BC_ASSERT_TRUE_FATAL(lf->subscribe_active); BC_ASSERT_EQUAL(lf->subscribe_active, TRUE, int, "%d");
lfl = linphone_core_create_friend_list(pauline->lc); lfl = linphone_core_create_friend_list(pauline->lc);
linphone_friend_list_set_rls_uri(lfl, rls_uri); linphone_friend_list_set_rls_uri(lfl, rls_uri);
...@@ -788,12 +788,12 @@ static void test_presence_list_base(bool_t enable_compression) { ...@@ -788,12 +788,12 @@ static void test_presence_list_base(bool_t enable_compression) {
linphone_friend_list_update_subscriptions(linphone_core_get_default_friend_list(pauline->lc), NULL, FALSE); linphone_friend_list_update_subscriptions(linphone_core_get_default_friend_list(pauline->lc), NULL, FALSE);
wait_for_list(lcs, &pauline->stat.number_of_NotifyPresenceReceived, 1, 2000); wait_for_list(lcs, &pauline->stat.number_of_NotifyPresenceReceived, 1, 2000);
BC_ASSERT_EQUAL_FATAL(pauline->stat.number_of_NotifyPresenceReceived, 1, int, "%d"); BC_ASSERT_EQUAL(pauline->stat.number_of_NotifyPresenceReceived, 1, int, "%d");
BC_ASSERT_EQUAL_FATAL(linphone_core_get_default_friend_list(pauline->lc)->expected_notification_version, 1, int, "%d"); BC_ASSERT_EQUAL(linphone_core_get_default_friend_list(pauline->lc)->expected_notification_version, 1, int, "%d");
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(pauline->lc), marie_identity); lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(pauline->lc), marie_identity);
BC_ASSERT_EQUAL_FATAL(linphone_friend_get_status(lf), LinphoneStatusBusy, int, "%d"); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusBusy, int, "%d");
BC_ASSERT_TRUE_FATAL(lf->presence_received); BC_ASSERT_EQUAL(lf->presence_received, TRUE, int, "%d");
BC_ASSERT_TRUE_FATAL(lf->subscribe_active); BC_ASSERT_EQUAL(lf->subscribe_active, TRUE, int, "%d");
linphone_core_set_presence_model(marie->lc, linphone_core_create_presence_model_with_activity(marie->lc, LinphonePresenceActivityOnThePhone, NULL)); linphone_core_set_presence_model(marie->lc, linphone_core_create_presence_model_with_activity(marie->lc, LinphonePresenceActivityOnThePhone, NULL));
...@@ -801,40 +801,40 @@ static void test_presence_list_base(bool_t enable_compression) { ...@@ -801,40 +801,40 @@ static void test_presence_list_base(bool_t enable_compression) {
/* The number of PresenceReceived events can be 3 or 4 here. TODO: ideally it should always be 3. */ /* The number of PresenceReceived events can be 3 or 4 here. TODO: ideally it should always be 3. */
BC_ASSERT_GREATER(laure->stat.number_of_NotifyPresenceReceived, 3, int, "%d"); BC_ASSERT_GREATER(laure->stat.number_of_NotifyPresenceReceived, 3, int, "%d");
BC_ASSERT_LOWER(laure->stat.number_of_NotifyPresenceReceived, 4, int, "%d"); BC_ASSERT_LOWER(laure->stat.number_of_NotifyPresenceReceived, 4, int, "%d");
BC_ASSERT_EQUAL_FATAL(linphone_core_get_default_friend_list(laure->lc)->expected_notification_version, 2, int, "%d"); BC_ASSERT_EQUAL(linphone_core_get_default_friend_list(laure->lc)->expected_notification_version, 2, int, "%d");
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), marie_identity); lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), marie_identity);
BC_ASSERT_EQUAL_FATAL(linphone_friend_get_status(lf), LinphoneStatusOnThePhone, int, "%d"); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOnThePhone, int, "%d");
wait_for_list(lcs, &pauline->stat.number_of_NotifyPresenceReceived, 2, 2000); wait_for_list(lcs, &pauline->stat.number_of_NotifyPresenceReceived, 2, 2000);
BC_ASSERT_EQUAL_FATAL(pauline->stat.number_of_NotifyPresenceReceived, 2, int, "%d"); BC_ASSERT_EQUAL(pauline->stat.number_of_NotifyPresenceReceived, 2, int, "%d");
BC_ASSERT_EQUAL_FATAL(linphone_core_get_default_friend_list(pauline->lc)->expected_notification_version, 2, int, "%d"); BC_ASSERT_EQUAL(linphone_core_get_default_friend_list(pauline->lc)->expected_notification_version, 2, int, "%d");
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(pauline->lc), marie_identity); lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(pauline->lc), marie_identity);
BC_ASSERT_EQUAL_FATAL(linphone_friend_get_status(lf), LinphoneStatusOnThePhone, int, "%d"); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOnThePhone, int, "%d");
ms_message("Disabling publish"); ms_message("Disabling publish");
enable_publish(laure, FALSE); enable_publish(laure, FALSE);
enable_publish(marie, FALSE); enable_publish(marie, FALSE);
enable_publish(pauline, FALSE); enable_publish(pauline, FALSE);
reset_counters(&pauline->stat); reset_counters(&pauline->stat);
reset_counters(&laure->stat); reset_counters(&laure->stat);
reset_counters(&marie->stat); reset_counters(&marie->stat);
BC_ASSERT_TRUE_FATAL(wait_for_list(lcs, &pauline->stat.number_of_LinphonePresenceActivityOffline, 1, 2000)); BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphonePresenceActivityOffline, 1, 2000));
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(pauline->lc), marie_identity); lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(pauline->lc), marie_identity);
BC_ASSERT_EQUAL_FATAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d"); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d");
BC_ASSERT_TRUE_FATAL(wait_for_list(lcs, &laure->stat.number_of_LinphonePresenceActivityOffline, 2, 2000)); BC_ASSERT_TRUE(wait_for_list(lcs, &laure->stat.number_of_LinphonePresenceActivityOffline, 2, 2000));
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), pauline_identity); lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), pauline_identity);
BC_ASSERT_EQUAL_FATAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d"); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d");
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), marie_identity); lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), marie_identity);
BC_ASSERT_EQUAL_FATAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d"); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d");
BC_ASSERT_TRUE_FATAL(wait_for_list(lcs, &marie->stat.number_of_LinphonePresenceActivityOffline, 1, 2000)); BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphonePresenceActivityOffline, 1, 2000));
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(marie->lc), laure_identity); lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(marie->lc), laure_identity);
BC_ASSERT_EQUAL_FATAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d"); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d");
linphone_core_manager_destroy(laure); linphone_core_manager_destroy(laure);
linphone_core_manager_destroy(marie); linphone_core_manager_destroy(marie);
...@@ -852,7 +852,7 @@ static void test_presence_list_without_compression(void) { ...@@ -852,7 +852,7 @@ static void test_presence_list_without_compression(void) {
#if 0 #if 0
static void test_presence_list_subscribe_before_publish(void) { static void test_presence_list_subscribe_before_publish(void) {
LinphoneCoreManager *laure = linphone_core_manager_new("laure_tcp_rc"); LinphoneCoreManager *laure = linphone_core_manager_new("laure_tcp_rc");
LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc");
const char *rls_uri = "sip:rls@sip.example.org"; const char *rls_uri = "sip:rls@sip.example.org";
LinphoneFriendList *lfl; LinphoneFriendList *lfl;
LinphoneFriend *lf; LinphoneFriend *lf;
...@@ -887,12 +887,12 @@ static void test_presence_list_subscribe_before_publish(void) { ...@@ -887,12 +887,12 @@ static void test_presence_list_subscribe_before_publish(void) {
BC_ASSERT_GREATER(linphone_core_get_default_friend_list(laure->lc)->expected_notification_version, 1, int, "%d"); BC_ASSERT_GREATER(linphone_core_get_default_friend_list(laure->lc)->expected_notification_version, 1, int, "%d");
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), pauline_identity); lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), pauline_identity);
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusVacation, int, "%d"); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusVacation, int, "%d");
BC_ASSERT_TRUE(lf->presence_received); BC_ASSERT_EQUAL(lf->presence_received, TRUE, int, "%d");
BC_ASSERT_TRUE(lf->subscribe_active); BC_ASSERT_EQUAL(lf->subscribe_active, TRUE, int, "%d");
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), "sip:michelle@sip.inexistentdomain.com"); lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), "sip:michelle@sip.inexistentdomain.com");
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d"); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d");
BC_ASSERT_FALSE(lf->presence_received); BC_ASSERT_EQUAL(lf->presence_received, FALSE, int, "%d");
BC_ASSERT_TRUE(lf->subscribe_active); BC_ASSERT_EQUAL(lf->subscribe_active, TRUE, int, "%d");
enable_publish(laure, FALSE); enable_publish(laure, FALSE);
enable_publish(pauline, FALSE); enable_publish(pauline, FALSE);
...@@ -927,7 +927,7 @@ static void test_presence_list_subscription_expire_for_unknown(void) { ...@@ -927,7 +927,7 @@ static void test_presence_list_subscription_expire_for_unknown(void) {
static void test_presence_list_subscribe_with_error(bool_t io_error) { static void test_presence_list_subscribe_with_error(bool_t io_error) {
LinphoneCoreManager *laure = linphone_core_manager_new("laure_tcp_rc"); LinphoneCoreManager *laure = linphone_core_manager_new("laure_tcp_rc");
LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc");
const char *rls_uri = "sip:rls@sip.example.org"; const char *rls_uri = "sip:rls@sip.example.org";
LinphoneFriendList *lfl; LinphoneFriendList *lfl;
LinphoneFriend *lf; LinphoneFriend *lf;
...@@ -963,12 +963,12 @@ static void test_presence_list_subscribe_with_error(bool_t io_error) { ...@@ -963,12 +963,12 @@ static void test_presence_list_subscribe_with_error(bool_t io_error) {
BC_ASSERT_GREATER(linphone_core_get_default_friend_list(laure->lc)->expected_notification_version, 1, int, "%d"); BC_ASSERT_GREATER(linphone_core_get_default_friend_list(laure->lc)->expected_notification_version, 1, int, "%d");
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), pauline_identity); lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), pauline_identity);
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusVacation, int, "%d"); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusVacation, int, "%d");
BC_ASSERT_TRUE(lf->presence_received); BC_ASSERT_EQUAL(lf->presence_received, TRUE, int, "%d");
BC_ASSERT_TRUE(lf->subscribe_active); BC_ASSERT_EQUAL(lf->subscribe_active, TRUE, int, "%d");
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), "sip:michelle@sip.inexistentdomain.com"); lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), "sip:michelle@sip.inexistentdomain.com");
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d"); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d");
BC_ASSERT_FALSE(lf->presence_received); BC_ASSERT_EQUAL(lf->presence_received, FALSE, int, "%d");
BC_ASSERT_TRUE(lf->subscribe_active); BC_ASSERT_EQUAL(lf->subscribe_active, TRUE, int, "%d");
BC_ASSERT_TRUE(wait_for_until(laure->lc, pauline->lc, &laure->stat.number_of_LinphonePresenceActivityVacation, 2, 6000)); BC_ASSERT_TRUE(wait_for_until(laure->lc, pauline->lc, &laure->stat.number_of_LinphonePresenceActivityVacation, 2, 6000));
if (io_error) { if (io_error) {
...@@ -997,11 +997,11 @@ static void test_presence_list_subscribe_with_error(bool_t io_error) { ...@@ -997,11 +997,11 @@ static void test_presence_list_subscribe_with_error(bool_t io_error) {
linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(pauline);
} }
static void presence_list_subscribe_dialog_expire(void) { static void test_presence_list_subscribe_dialog_expire(void) {
test_presence_list_subscribe_with_error(FALSE); test_presence_list_subscribe_with_error(FALSE);
} }
static void presence_list_subscribe_io_error(void) { static void test_presence_list_subscribe_io_error(void) {
test_presence_list_subscribe_with_error(TRUE); test_presence_list_subscribe_with_error(TRUE);
} }
...@@ -1010,97 +1010,30 @@ static void simple_subscribe_with_friend_from_rc(void) { ...@@ -1010,97 +1010,30 @@ static void simple_subscribe_with_friend_from_rc(void) {
LinphoneCoreManager* pauline = presence_linphone_core_manager_new("pauline"); LinphoneCoreManager* pauline = presence_linphone_core_manager_new("pauline");
LinphoneCoreManager *marie = presence_linphone_core_manager_new_with_rc_name("marie", "pauline_as_friend_rc"); LinphoneCoreManager *marie = presence_linphone_core_manager_new_with_rc_name("marie", "pauline_as_friend_rc");
LinphoneFriend *pauline_as_friend; LinphoneFriend *pauline_as_friend;
BC_ASSERT_EQUAL(ms_list_size(linphone_core_get_friend_list(marie->lc)), 1, int , "%i"); BC_ASSERT_EQUAL(ms_list_size(linphone_core_get_friend_list(marie->lc)), 1, int , "%i");
if (ms_list_size(linphone_core_get_friend_list(marie->lc))>0) { if (ms_list_size(linphone_core_get_friend_list(marie->lc))>0) {
pauline_as_friend = (LinphoneFriend*)linphone_core_get_friend_list(marie->lc)->data; pauline_as_friend = (LinphoneFriend*)linphone_core_get_friend_list(marie->lc)->data;
linphone_friend_set_address(pauline_as_friend, pauline->identity); /*hack to update addr with port number*/ linphone_friend_set_address(pauline_as_friend, pauline->identity); /*hack to update addr with port number*/
} }
BC_ASSERT_TRUE (wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePresenceActivityOnline,1)); BC_ASSERT_TRUE (wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePresenceActivityOnline,1));
BC_ASSERT_EQUAL(pauline->stat.number_of_NewSubscriptionRequest,1, int, "%d"); BC_ASSERT_EQUAL(pauline->stat.number_of_NewSubscriptionRequest,1, int, "%d");
BC_ASSERT_EQUAL(marie->stat.number_of_NotifyPresenceReceived,1, int, "%d"); BC_ASSERT_EQUAL(marie->stat.number_of_NotifyPresenceReceived,1, int, "%d");
linphone_core_manager_destroy(marie); linphone_core_manager_destroy(marie);
/*unsubscribe is not reported ?*/ /*unsubscribe is not reported ?*/
BC_ASSERT_FALSE(wait_for(NULL,pauline->lc,&pauline->stat.number_of_NewSubscriptionRequest,2)); /*just to wait for unsubscription even if not notified*/ BC_ASSERT_FALSE(wait_for(NULL,pauline->lc,&pauline->stat.number_of_NewSubscriptionRequest,2)); /*just to wait for unsubscription even if not notified*/
linphone_core_manager_destroy(pauline);
}
static void long_term_presence_base(const char* addr, bool_t exist) {
LinphoneFriend* friend;
LinphoneCoreManager* pauline = presence_linphone_core_manager_new("pauline");
linphone_core_set_user_agent(pauline->lc, "full-presence-support", NULL);
friend=linphone_core_create_friend_with_address(pauline->lc,addr);
linphone_friend_edit(friend);
linphone_friend_enable_subscribes(friend,TRUE);
linphone_friend_done(friend);
linphone_core_add_friend(pauline->lc,friend);
if (exist) {
BC_ASSERT_TRUE(wait_for(pauline->lc,NULL,&pauline->stat.number_of_LinphonePresenceActivityOnline,1));
BC_ASSERT_EQUAL(pauline->stat.number_of_LinphonePresenceActivityOnline, 1, int, "%d");
BC_ASSERT_EQUAL(linphone_presence_model_get_basic_status(linphone_friend_get_presence_model(friend)), LinphonePresenceBasicStatusOpen, int, "%d");
} else {
BC_ASSERT_TRUE(wait_for(pauline->lc,NULL,&pauline->stat.number_of_LinphonePresenceActivityOffline,1));
BC_ASSERT_EQUAL(pauline->stat.number_of_LinphonePresenceActivityOffline, 1, int, "%d");
BC_ASSERT_EQUAL(linphone_presence_model_get_basic_status(linphone_friend_get_presence_model(friend)), LinphonePresenceBasicStatusClosed, int, "%d");
}
linphone_friend_unref(friend);
linphone_core_manager_destroy(pauline);
}
static void long_term_presence_existing_friend(void) {
// this friend is not online, but is known from flexisip to be registered (see flexisip/userdb.conf),
// so we expect to get a report that he is currently not online
long_term_presence_base("sip:liblinphone_tester@sip.example.org", TRUE);
}
static void long_term_presence_inexistent_friend(void) {
long_term_presence_base("sip:random_unknown@sip.example.org", FALSE);