Commit 05af238d authored by jehan's avatar jehan

make sure list subscribe is only sent when proxy config is transitioned to RegistrationOk

parent b966230c
......@@ -1409,7 +1409,6 @@ void * linphone_proxy_config_get_user_data(const LinphoneProxyConfig *cfg) {
void linphone_proxy_config_set_state(LinphoneProxyConfig *cfg, LinphoneRegistrationState state, const char *message){
LinphoneCore *lc=cfg->lc;
bool_t update_friends=FALSE;
if (state==LinphoneRegistrationProgress) {
char *msg=ortp_strdup_printf(_("Refreshing on %s..."), linphone_proxy_config_get_identity(cfg));
......@@ -1419,19 +1418,23 @@ void linphone_proxy_config_set_state(LinphoneProxyConfig *cfg, LinphoneRegistrat
}
if (cfg->state!=state || state==LinphoneRegistrationOk) { /*allow multiple notification of LinphoneRegistrationOk for refreshing*/
ms_message("Proxy config [%p] for identity [%s] moving from state [%s] to [%s]" , cfg,
linphone_proxy_config_get_identity(cfg),
linphone_registration_state_to_string(cfg->state),
linphone_registration_state_to_string(state));
if (linphone_core_should_subscribe_friends_only_when_registered(lc)){
update_friends=(state==LinphoneRegistrationOk && cfg->state!=LinphoneRegistrationOk)
|| (state!=LinphoneRegistrationOk && cfg->state==LinphoneRegistrationOk);
}
cfg->state=state;
if (update_friends){
ms_message("Proxy config [%p] for identity [%s] moving from state [%s] to [%s] on core [%p]" ,
cfg,
linphone_proxy_config_get_identity(cfg),
linphone_registration_state_to_string(cfg->state),
linphone_registration_state_to_string(state),
cfg->lc);
if (linphone_core_should_subscribe_friends_only_when_registered(lc) && cfg->state!=state && state == LinphoneRegistrationOk){
ms_message("Updating friends for identity [%s] on core [%p]",linphone_proxy_config_get_identity(cfg),cfg->lc);
/* state must be updated before calling linphone_core_update_friends_subscriptions*/
cfg->state=state;
linphone_core_update_friends_subscriptions(lc,cfg,TRUE);
} else {
/*at this point state must be updated*/
cfg->state=state;
}
if (lc){
linphone_core_notify_registration_state_changed(lc,cfg,state,message);
if (lc->calls && lp_config_get_int(lc->config, "sip", "repair_broken_calls", 1)){
......
......@@ -188,7 +188,7 @@ static void subscribe_failure_handle_by_app(void) {
LinphoneFriend* lf;
char* lf_identity=linphone_address_as_string_uri_only(pauline->identity);
linphone_core_get_default_proxy(marie->lc,&config);
config = linphone_core_get_default_proxy_config(marie->lc);
BC_ASSERT_TRUE(subscribe_to_callee_presence(marie,pauline));
wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_NewSubscriptionRequest,1); /*just to wait for unsubscription even if not notified*/
......@@ -607,9 +607,9 @@ static void test_presence_list(void) {
lcs = ms_list_append(lcs, marie->lc);
lcs = ms_list_append(lcs, pauline->lc);
wait_for_list(lcs, &laure->stat.number_of_NotifyReceived, 2, 2000);
wait_for_list(lcs, &laure->stat.number_of_NotifyReceived, 1, 2000);
wait_for_list(lcs, &laure->stat.number_of_NotifyPresenceReceived, 2, 2000);
BC_ASSERT_EQUAL(laure->stat.number_of_NotifyReceived, 2, int, "%d");
BC_ASSERT_EQUAL(laure->stat.number_of_NotifyReceived, 1, int, "%d");
BC_ASSERT_EQUAL(laure->stat.number_of_NotifyPresenceReceived, 2, int, "%d");
BC_ASSERT_EQUAL(laure->lc->friendlist->expected_notification_version, 1, int, "%d");
lf = linphone_friend_list_find_friend_by_uri(laure->lc->friendlist, marie_identity);
......@@ -663,9 +663,9 @@ static void test_presence_list(void) {
linphone_core_set_presence_model(marie->lc, linphone_core_create_presence_model_with_activity(marie->lc, LinphonePresenceActivityOnThePhone, NULL));
wait_for_list(lcs, &laure->stat.number_of_NotifyReceived, 3, 2000);
wait_for_list(lcs, &laure->stat.number_of_NotifyReceived, 2, 2000);
wait_for_list(lcs, &laure->stat.number_of_NotifyPresenceReceived, 4, 2000);
BC_ASSERT_EQUAL(laure->stat.number_of_NotifyReceived, 3, int, "%d");
BC_ASSERT_EQUAL(laure->stat.number_of_NotifyReceived, 2, int, "%d");
BC_ASSERT_EQUAL(laure->stat.number_of_NotifyPresenceReceived, 4, int, "%d");
BC_ASSERT_EQUAL(laure->lc->friendlist->expected_notification_version, 2, int, "%d");
lf = linphone_friend_list_find_friend_by_uri(laure->lc->friendlist, marie_identity);
......@@ -683,15 +683,18 @@ static void test_presence_list(void) {
enable_publish(marie, FALSE);
enable_publish(pauline, FALSE);
wait_for_list(lcs, &pauline->stat.number_of_NotifyReceived, 2, 2000);
wait_for_list(lcs, &marie->stat.number_of_NotifyReceived, 2, 2000);
wait_for_list(lcs, &laure->stat.number_of_NotifyReceived, 2, 2000);
wait_for_list(lcs, &pauline->stat.number_of_NotifyReceived, 3, 2000);
wait_for_list(lcs, &marie->stat.number_of_NotifyReceived, 3, 2000);
wait_for_list(lcs, &laure->stat.number_of_NotifyReceived, 3, 2000);
lf = linphone_friend_list_find_friend_by_uri(pauline->lc->friendlist, marie_identity);
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d");
lf = linphone_friend_list_find_friend_by_uri(pauline->lc->friendlist, pauline_identity);
lf = linphone_friend_list_find_friend_by_uri(laure->lc->friendlist, pauline_identity);
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d");
lf = linphone_friend_list_find_friend_by_uri(laure->lc->friendlist, marie_identity);
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d");
lf = linphone_friend_list_find_friend_by_uri(pauline->lc->friendlist, laure_identity);
lf = linphone_friend_list_find_friend_by_uri(marie->lc->friendlist, laure_identity);
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d");
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