mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-02-07 14:18:25 +00:00
use belle-sip refresher with dialog terminated recovery capability
This commit is contained in:
parent
e73f376c0d
commit
58cb7a3f57
15 changed files with 185 additions and 46 deletions
|
|
@ -542,8 +542,8 @@ void sal_set_callbacks(Sal *ctx, const SalCallbacks *cbs){
|
|||
ctx->callbacks.notify=(SalOnNotify)unimplemented_stub;
|
||||
if (ctx->callbacks.subscribe_received==NULL)
|
||||
ctx->callbacks.subscribe_received=(SalOnSubscribeReceived)unimplemented_stub;
|
||||
if (ctx->callbacks.subscribe_closed==NULL)
|
||||
ctx->callbacks.subscribe_closed=(SalOnSubscribeClosed)unimplemented_stub;
|
||||
if (ctx->callbacks.incoming_subscribe_closed==NULL)
|
||||
ctx->callbacks.incoming_subscribe_closed=(SalOnIncomingSubscribeClosed)unimplemented_stub;
|
||||
if (ctx->callbacks.parse_presence_requested==NULL)
|
||||
ctx->callbacks.parse_presence_requested=(SalOnParsePresenceRequested)unimplemented_stub;
|
||||
if (ctx->callbacks.convert_presence_to_xml_requested==NULL)
|
||||
|
|
|
|||
|
|
@ -46,11 +46,15 @@ static void subscribe_refresher_listener (belle_sip_refresher_t* refresher
|
|||
if (status_code==200) sss=SalSubscribeActive;
|
||||
else if (status_code==202) sss=SalSubscribePending;
|
||||
set_or_update_dialog(op,belle_sip_transaction_get_dialog(tr));
|
||||
}
|
||||
if (status_code>=200){
|
||||
sal_error_info_set(&op->error_info,SalReasonUnknown,status_code,reason_phrase,NULL);
|
||||
op->base.root->callbacks.subscribe_response(op,sss);
|
||||
}else if (status_code==0){
|
||||
} else if (status_code >= 300) {
|
||||
SalReason reason = SalReasonUnknown;
|
||||
if (status_code == 503) { /*refresher returns 503 for IO error*/
|
||||
reason = SalReasonIOError;
|
||||
}
|
||||
sal_error_info_set(&op->error_info,reason,status_code,reason_phrase,NULL);
|
||||
op->base.root->callbacks.subscribe_response(op,sss);
|
||||
}if (status_code==0){
|
||||
op->base.root->callbacks.on_expire(op);
|
||||
}
|
||||
|
||||
|
|
@ -172,7 +176,7 @@ static void subscribe_process_request_event(void *op_base, const belle_sip_reque
|
|||
ms_message("Unsubscribe received from [%s]",sal_op_get_from(op));
|
||||
resp=sal_op_create_response_from_request(op,req,200);
|
||||
belle_sip_server_transaction_send_response(server_transaction,resp);
|
||||
op->base.root->callbacks.subscribe_closed(op);
|
||||
op->base.root->callbacks.incoming_subscribe_closed(op);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -518,14 +518,14 @@ SalReason _sal_reason_from_sip_code(int code) {
|
|||
return SalReasonNotImplemented;
|
||||
case 502:
|
||||
return SalReasonBadGateway;
|
||||
case 503:
|
||||
return SalReasonServiceUnavailable;
|
||||
case 504:
|
||||
return SalReasonServerTimeout;
|
||||
case 600:
|
||||
return SalReasonDoNotDisturb;
|
||||
case 603:
|
||||
return SalReasonDeclined;
|
||||
case 503:
|
||||
return SalReasonServiceUnavailable;
|
||||
default:
|
||||
return SalReasonUnknown;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1343,7 +1343,7 @@ static void subscribe_received(SalOp *op, const char *eventname, const SalBodyHa
|
|||
|
||||
}
|
||||
|
||||
static void subscribe_closed(SalOp *op){
|
||||
static void incoming_subscribe_closed(SalOp *op){
|
||||
LinphoneEvent *lev=(LinphoneEvent*)sal_op_get_user_pointer(op);
|
||||
|
||||
linphone_event_set_state(lev,LinphoneSubscriptionTerminated);
|
||||
|
|
@ -1400,7 +1400,7 @@ SalCallbacks linphone_sal_callbacks={
|
|||
is_composing_received,
|
||||
notify_refer,
|
||||
subscribe_received,
|
||||
subscribe_closed,
|
||||
incoming_subscribe_closed,
|
||||
subscribe_response,
|
||||
notify,
|
||||
subscribe_presence_received,
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ const char *linphone_subscription_state_to_string(LinphoneSubscriptionState stat
|
|||
switch(state){
|
||||
case LinphoneSubscriptionNone: return "LinphoneSubscriptionNone";
|
||||
case LinphoneSubscriptionIncomingReceived: return "LinphoneSubscriptionIncomingReceived";
|
||||
case LinphoneSubscriptionOutgoingInit: return "LinphoneSubscriptionOutoingInit";
|
||||
case LinphoneSubscriptionOutgoingProgress: return "LinphoneSubscriptionOutgoingProgress";
|
||||
case LinphoneSubscriptionPending: return "LinphoneSubscriptionPending";
|
||||
case LinphoneSubscriptionActive: return "LinphoneSubscriptionActive";
|
||||
case LinphoneSubscriptionTerminated: return "LinphoneSubscriptionTerminated";
|
||||
|
|
|
|||
|
|
@ -419,6 +419,7 @@ void linphone_friend_list_update_subscriptions(LinphoneFriendList *list, Linphon
|
|||
linphone_content_set_string_buffer(content, xml_content);
|
||||
linphone_event_send_subscribe(list->event, content);
|
||||
linphone_content_unref(content);
|
||||
linphone_event_set_user_data(list->event, list);
|
||||
}
|
||||
}
|
||||
if (address != NULL) linphone_address_unref(address);
|
||||
|
|
@ -476,3 +477,21 @@ void linphone_friend_list_notify_presence_received(LinphoneFriendList *list, Lin
|
|||
linphone_content_unref(first_part);
|
||||
}
|
||||
}
|
||||
void linphone_friend_list_subscription_state_changed(LinphoneCore *lc, LinphoneEvent *lev, LinphoneSubscriptionState state) {
|
||||
LinphoneFriendList *list = (LinphoneFriendList *)linphone_event_get_user_data(lev);
|
||||
if (!list) {
|
||||
ms_warning("core [%p] Receiving unexpected state [%s] for event [%p], no associated friend list",lc
|
||||
, linphone_subscription_state_to_string(state)
|
||||
, lev);
|
||||
} else {
|
||||
ms_message("Receiving new state [%s] for event [%p] for friend list [%p]"
|
||||
, linphone_subscription_state_to_string(state)
|
||||
, lev
|
||||
, list);
|
||||
|
||||
if (state == LinphoneSubscriptionOutgoingProgress) {
|
||||
ms_message("Resseting version count for friend list [%p]",list);
|
||||
list->expected_notification_version = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1654,6 +1654,12 @@ static void linphone_core_internal_notify_received(LinphoneCore *lc, LinphoneEve
|
|||
}
|
||||
}
|
||||
|
||||
static void linphone_core_internal_subscription_state_changed(LinphoneCore *lc, LinphoneEvent *lev, LinphoneSubscriptionState state) {
|
||||
if (strcasecmp(linphone_event_get_name(lev), "Presence") == 0) {
|
||||
linphone_friend_list_subscription_state_changed(lc, lev, state);
|
||||
}
|
||||
}
|
||||
|
||||
static void linphone_core_init(LinphoneCore * lc, const LinphoneCoreVTable *vtable, LpConfig *config, void * userdata){
|
||||
const char *remote_provisioning_uri = NULL;
|
||||
LinphoneCoreVTable* local_vtable= linphone_core_v_table_new();
|
||||
|
|
@ -1668,6 +1674,7 @@ static void linphone_core_init(LinphoneCore * lc, const LinphoneCoreVTable *vtab
|
|||
linphone_task_list_init(&lc->hooks);
|
||||
|
||||
internal_vtable->notify_received = linphone_core_internal_notify_received;
|
||||
internal_vtable->subscription_state_changed = linphone_core_internal_subscription_state_changed;
|
||||
_linphone_core_add_listener(lc, internal_vtable, TRUE, TRUE);
|
||||
memcpy(local_vtable,vtable,sizeof(LinphoneCoreVTable));
|
||||
_linphone_core_add_listener(lc, local_vtable, TRUE, FALSE);
|
||||
|
|
|
|||
|
|
@ -406,6 +406,7 @@ const LinphoneAddress* linphone_proxy_config_get_service_route(const LinphonePro
|
|||
|
||||
void linphone_friend_list_invalidate_subscriptions(LinphoneFriendList *list);
|
||||
void linphone_friend_list_notify_presence_received(LinphoneFriendList *list, LinphoneEvent *lev, const LinphoneContent *body);
|
||||
void linphone_friend_list_subscription_state_changed(LinphoneCore *lc, LinphoneEvent *lev, LinphoneSubscriptionState state);
|
||||
void _linphone_friend_list_release(LinphoneFriendList *list);
|
||||
void linphone_friend_invalidate_subscription(LinphoneFriend *lf);
|
||||
void linphone_friend_close_subscriptions(LinphoneFriend *lf);
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ void linphone_core_notify_notify_received(LinphoneCore *lc, LinphoneEvent *lev,
|
|||
}
|
||||
|
||||
void linphone_core_notify_subscription_state_changed(LinphoneCore *lc, LinphoneEvent *lev, LinphoneSubscriptionState state) {
|
||||
NOTIFY_IF_EXIST(subscription_state_changed, lc,lev,state);
|
||||
NOTIFY_IF_EXIST_INTERNAL(subscription_state_changed,linphone_event_is_internal(lev), lc,lev,state);
|
||||
cleanup_dead_vtable_refs(lc);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -489,7 +489,7 @@ typedef void (*SalOnNotifyRefer)(SalOp *op, SalReferStatus state);
|
|||
typedef void (*SalOnSubscribeResponse)(SalOp *op, SalSubscribeStatus status);
|
||||
typedef void (*SalOnNotify)(SalOp *op, SalSubscribeStatus status, const char *event, SalBodyHandler *body);
|
||||
typedef void (*SalOnSubscribeReceived)(SalOp *salop, const char *event, const SalBodyHandler *body);
|
||||
typedef void (*SalOnSubscribeClosed)(SalOp *salop);
|
||||
typedef void (*SalOnIncomingSubscribeClosed)(SalOp *salop);
|
||||
typedef void (*SalOnParsePresenceRequested)(SalOp *salop, const char *content_type, const char *content_subtype, const char *content, SalPresenceModel **result);
|
||||
typedef void (*SalOnConvertPresenceToXMLRequested)(SalOp *salop, SalPresenceModel *presence, const char *contact, char **content);
|
||||
typedef void (*SalOnNotifyPresence)(SalOp *op, SalSubscribeStatus ss, SalPresenceModel *model, const char *msg);
|
||||
|
|
@ -523,7 +523,7 @@ typedef struct SalCallbacks{
|
|||
SalOnIsComposingReceived is_composing_received;
|
||||
SalOnNotifyRefer notify_refer;
|
||||
SalOnSubscribeReceived subscribe_received;
|
||||
SalOnSubscribeClosed subscribe_closed;
|
||||
SalOnIncomingSubscribeClosed incoming_subscribe_closed;
|
||||
SalOnSubscribeResponse subscribe_response;
|
||||
SalOnNotify notify;
|
||||
SalOnSubscribePresenceReceived subscribe_presence_received;
|
||||
|
|
|
|||
|
|
@ -38,8 +38,9 @@ const char *liblinphone_tester_get_notify_content(void){
|
|||
|
||||
void linphone_notify_received(LinphoneCore *lc, LinphoneEvent *lev, const char *eventname, const LinphoneContent *content){
|
||||
LinphoneCoreManager *mgr;
|
||||
const char * ua = linphone_event_get_custom_header(lev, "User-Agent");
|
||||
BC_ASSERT_PTR_NOT_NULL_FATAL(content);
|
||||
if (!linphone_content_is_multipart(content)) {
|
||||
if (!linphone_content_is_multipart(content) && (!ua || !strcasestr(ua, "flexisip"))) { /*disable check for full presence serveur support*/
|
||||
/*hack to disable content checking for list notify */
|
||||
BC_ASSERT_STRING_EQUAL(notify_content,(const char*)linphone_content_get_buffer(content));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -617,6 +617,7 @@ ban-time=1
|
|||
[module::Presence]
|
||||
enabled=true
|
||||
presence-server = <sip:127.0.0.1:5065;transport=tcp>
|
||||
only-list-subscription = !(user-agent contains 'full-presence-support')
|
||||
|
||||
[presence-server]
|
||||
expires = 600
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
#include "private.h"
|
||||
#include "liblinphone_tester.h"
|
||||
|
||||
static void enable_publish(LinphoneCoreManager *mgr, bool_t enable);
|
||||
|
||||
static LinphoneCoreManager* presence_linphone_core_manager_new(char* username) {
|
||||
LinphoneCoreManager* mgr= linphone_core_manager_new2( "empty_rc", FALSE);
|
||||
char* identity_char;
|
||||
|
|
@ -400,25 +402,25 @@ static void subscribe_presence_expired(void){
|
|||
lcs = ms_list_append(lcs, pauline1->lc);
|
||||
|
||||
lp_config_set_int(marie->lc->config, "sip", "subscribe_expires", 10);
|
||||
|
||||
|
||||
lf = linphone_core_create_friend(marie->lc);
|
||||
linphone_friend_set_address(lf, pauline1->identity);
|
||||
linphone_friend_enable_subscribes(lf, TRUE);
|
||||
|
||||
linphone_core_add_friend(marie->lc, lf);
|
||||
linphone_friend_unref(lf);
|
||||
|
||||
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline1->stat.number_of_NewSubscriptionRequest,1, 5000));
|
||||
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePresenceActivityOnline,1, 2000));
|
||||
|
||||
lf = linphone_core_find_friend(pauline1->lc, marie->identity);
|
||||
BC_ASSERT_PTR_NOT_NULL(lf->insubs);
|
||||
|
||||
/*marie comes offline suddenly*/
|
||||
linphone_core_set_network_reachable(marie->lc, FALSE);
|
||||
/*after a certain time, pauline shall see the incoming SUBSCRIBE expired*/
|
||||
wait_for_list(lcs,NULL, 0, 11000);
|
||||
|
||||
BC_ASSERT_PTR_NULL(lf->insubs);
|
||||
|
||||
/*just make network reachable so that marie can unregister properly*/
|
||||
linphone_core_set_network_reachable(marie->lc, TRUE);
|
||||
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneRegistrationOk,2, 10000));
|
||||
|
|
@ -428,10 +430,56 @@ static void subscribe_presence_expired(void){
|
|||
ms_list_free(lcs);
|
||||
}
|
||||
|
||||
static void subscriber_no_longuer_reachable(void){
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
|
||||
LinphoneCoreManager* pauline1 = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
|
||||
LinphoneFriend *lf;
|
||||
MSList *lcs = NULL;
|
||||
LinphonePresenceModel * presence;
|
||||
|
||||
lcs = ms_list_append(lcs, marie->lc);
|
||||
lcs = ms_list_append(lcs, pauline1->lc);
|
||||
|
||||
lp_config_set_int(marie->lc->config, "sip", "subscribe_expires", 40);
|
||||
linphone_core_set_user_agent(marie->lc, "full-presence-support", NULL);
|
||||
linphone_core_set_user_agent(pauline1->lc, "full-presence-support", NULL);
|
||||
|
||||
enable_publish(pauline1, TRUE);
|
||||
|
||||
lf = linphone_core_create_friend(marie->lc);
|
||||
linphone_friend_set_address(lf, pauline1->identity);
|
||||
linphone_friend_enable_subscribes(lf, TRUE);
|
||||
|
||||
linphone_core_add_friend(marie->lc, lf);
|
||||
linphone_friend_unref(lf);
|
||||
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePresenceActivityOnline,1, 2000));
|
||||
|
||||
|
||||
presence =linphone_presence_model_new_with_activity(LinphonePresenceActivityBusy,NULL);
|
||||
linphone_core_set_presence_model(pauline1->lc,presence);
|
||||
|
||||
#define USE_PRESENCE_SERVER 0
|
||||
/*don't schedule marie to simulate Notify timeout server side*/
|
||||
wait_for_until(pauline1->lc, NULL, 0, 0, 35000);
|
||||
|
||||
//sal_set_send_error(marie->lc->sal,0);
|
||||
|
||||
/*because of notify timeout detected by server, so subscription is reset*/
|
||||
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePresenceActivityOffline,2, 4000));
|
||||
|
||||
// now subscribetion is supposed to be dead because notify was not answered in time.
|
||||
presence =linphone_presence_model_new_with_activity(LinphonePresenceActivityOnline,NULL);
|
||||
linphone_core_set_presence_model(pauline1->lc,presence);
|
||||
|
||||
/*becasue subscription is automatically restarted*/
|
||||
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePresenceActivityOnline,2, 4000));
|
||||
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline1);
|
||||
|
||||
ms_list_free(lcs);
|
||||
|
||||
}
|
||||
|
||||
#if USE_PRESENCE_SERVER
|
||||
static void test_subscribe_notify_publish(void) {
|
||||
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
|
||||
|
|
@ -439,6 +487,8 @@ static void test_subscribe_notify_publish(void) {
|
|||
LinphoneProxyConfig* proxy;
|
||||
LinphonePresenceModel* presence;
|
||||
|
||||
linphone_core_set_user_agent(marie->lc, "full-presence-support", NULL);
|
||||
linphone_core_set_user_agent(pauline->lc, "full-presence-support", NULL);
|
||||
LpConfig *pauline_lp = linphone_core_get_config(pauline->lc);
|
||||
char* lf_identity=linphone_address_as_string_uri_only(marie->identity);
|
||||
LinphoneFriend *lf = linphone_core_create_friend_with_address(pauline->lc,lf_identity);
|
||||
|
|
@ -453,7 +503,7 @@ static void test_subscribe_notify_publish(void) {
|
|||
|
||||
/*enable publish*/
|
||||
|
||||
linphone_core_get_default_proxy(marie->lc,&proxy);
|
||||
proxy = linphone_core_get_default_proxy_config(marie->lc);
|
||||
linphone_proxy_config_edit(proxy);
|
||||
|
||||
linphone_proxy_config_enable_publish(proxy,TRUE);
|
||||
|
|
@ -502,7 +552,11 @@ static void test_forked_subscribe_notify_publish(void) {
|
|||
lcs=ms_list_append(lcs,marie->lc);
|
||||
lcs=ms_list_append(lcs,marie->lc);
|
||||
lcs=ms_list_append(lcs,marie2->lc);
|
||||
linphone_core_set_user_agent(marie->lc, "full-presence-support", NULL);
|
||||
linphone_core_set_user_agent(marie2->lc, "full-presence-support", NULL);
|
||||
linphone_core_set_user_agent(pauline->lc, "full-presence-support", NULL);
|
||||
|
||||
|
||||
pauline_lp = linphone_core_get_config(pauline->lc);
|
||||
lf_identity=linphone_address_as_string_uri_only(marie->identity);
|
||||
lf = linphone_core_create_friend_with_address(pauline->lc,lf_identity);
|
||||
|
|
@ -546,16 +600,14 @@ static void test_forked_subscribe_notify_publish(void) {
|
|||
linphone_core_set_presence_model(marie2->lc,presence);
|
||||
/*wait for new status*/
|
||||
wait_for_list(lcs,&pauline->stat.number_of_NotifyPresenceReceived,5,2000);
|
||||
BC_ASSERT_EQUAL(LinphoneStatusBusy,linphone_friend_get_status(lf), int, "%d"); /*because liblinphone compositor is very simple for now (I.E only take first occurence)*/
|
||||
BC_ASSERT_TRUE(LinphoneStatusBusy == linphone_friend_get_status(lf)
|
||||
|| LinphoneStatusDoNotDisturb == linphone_friend_get_status(lf)); /*because liblinphone compositor is very simple for now */
|
||||
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(marie2);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
const char * get_identity(LinphoneCoreManager *mgr) {
|
||||
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(mgr->lc);
|
||||
return linphone_proxy_config_get_identity(cfg);
|
||||
|
|
@ -743,7 +795,7 @@ static void test_presence_list_subscribe_before_publish(void) {
|
|||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
||||
static void test_presence_list_subscription_expire(void) {
|
||||
static void test_presence_list_subscription_expire_for_unknown(void) {
|
||||
LinphoneCoreManager *laure = linphone_core_manager_new("laure_tcp_rc");
|
||||
const char *rls_uri = "sip:rls@sip.example.org";
|
||||
LinphoneFriendList *lfl;
|
||||
|
|
@ -762,16 +814,77 @@ static void test_presence_list_subscription_expire(void) {
|
|||
/* wait for refresh*/
|
||||
BC_ASSERT_FALSE(wait_for_until(laure->lc, NULL, &laure->stat.number_of_NotifyPresenceReceived, 1, 4000));
|
||||
|
||||
/*sal_set_send_error(laure->lc->sal,1500);*/ /*make sure no refresh is sent, trash the message without generating error*/
|
||||
|
||||
/*make sure we don't received any notify, even when subscribtion has expired*/
|
||||
/*BC_ASSERT_FALSE(wait_for_until(laure->lc, NULL, &laure->stat.number_of_NotifyPresenceReceived, 1, 5000));
|
||||
|
||||
sal_set_send_error(laure->lc->sal,0);*/
|
||||
|
||||
linphone_core_manager_destroy(laure);
|
||||
}
|
||||
|
||||
static void test_presence_list_subscribe_dialog_expire(void) {
|
||||
LinphoneCoreManager *laure = linphone_core_manager_new("laure_tcp_rc");
|
||||
LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc");
|
||||
const char *rls_uri = "sip:rls@sip.example.org";
|
||||
LinphoneFriendList *lfl;
|
||||
LinphoneFriend *lf;
|
||||
const char *pauline_identity;
|
||||
MSList* lcs = NULL;
|
||||
int dummy = 0;
|
||||
lp_config_set_int(laure->lc->config, "sip", "rls_presence_expires", 3);
|
||||
|
||||
|
||||
pauline_identity = get_identity(pauline);
|
||||
|
||||
linphone_core_set_presence_model(pauline->lc, linphone_core_create_presence_model_with_activity(pauline->lc, LinphonePresenceActivityVacation, NULL));
|
||||
|
||||
lfl = linphone_core_create_friend_list(laure->lc);
|
||||
linphone_friend_list_set_rls_uri(lfl, rls_uri);
|
||||
lf = linphone_core_create_friend_with_address(laure->lc, pauline_identity);
|
||||
linphone_friend_list_add_friend(lfl, lf);
|
||||
lf = linphone_core_create_friend_with_address(laure->lc, "sip:michelle@sip.inexistentdomain.com");
|
||||
linphone_friend_list_add_friend(lfl, lf);
|
||||
linphone_core_set_friend_list(laure->lc, lfl);
|
||||
linphone_friend_list_unref(lfl);
|
||||
linphone_core_set_presence_model(laure->lc, linphone_core_create_presence_model_with_activity(laure->lc, LinphonePresenceActivityOnline, NULL));
|
||||
linphone_friend_list_update_subscriptions(laure->lc->friendlist, NULL, FALSE);
|
||||
|
||||
lcs = ms_list_append(lcs, laure->lc);
|
||||
lcs = ms_list_append(lcs, pauline->lc);
|
||||
|
||||
wait_for_list(lcs, &dummy, 1, 2000); /* Wait a little bit for the subscribe to happen */
|
||||
|
||||
enable_publish(pauline, TRUE);
|
||||
wait_for_list(lcs, &pauline->stat.number_of_NotifyPresenceReceived, 1, 2000);
|
||||
BC_ASSERT_GREATER(laure->stat.number_of_NotifyPresenceReceived, 1, int, "%d");
|
||||
BC_ASSERT_GREATER(laure->lc->friendlist->expected_notification_version, 1, int, "%d");
|
||||
lf = linphone_friend_list_find_friend_by_uri(laure->lc->friendlist, pauline_identity);
|
||||
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusVacation, int, "%d");
|
||||
BC_ASSERT_EQUAL(lf->presence_received, TRUE, int, "%d");
|
||||
BC_ASSERT_EQUAL(lf->subscribe_active, TRUE, int, "%d");
|
||||
lf = linphone_friend_list_find_friend_by_uri(laure->lc->friendlist, "sip:michelle@sip.inexistentdomain.com");
|
||||
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d");
|
||||
BC_ASSERT_EQUAL(lf->presence_received, FALSE, int, "%d");
|
||||
BC_ASSERT_EQUAL(lf->subscribe_active, TRUE, int, "%d");
|
||||
|
||||
BC_ASSERT_TRUE(wait_for_until(laure->lc, pauline->lc, &laure->stat.number_of_NotifyPresenceReceived, 2, 5000));
|
||||
ms_message("Simulating in/out packets losses");
|
||||
sal_set_send_error(laure->lc->sal,1500); /*make sure no refresh is sent, trash the message without generating error*/
|
||||
sal_set_recv_error(laure->lc->sal, 1500); /*make sure server notify to close the dialog is also ignored*/
|
||||
|
||||
wait_for_list(lcs, &dummy, 1, 3000); /* Wait a little bit for the subscribe to happen */
|
||||
|
||||
/*restart normal behavior*/
|
||||
sal_set_send_error(laure->lc->sal,0);
|
||||
sal_set_recv_error(laure->lc->sal, 1);
|
||||
|
||||
|
||||
linphone_core_set_presence_model(pauline->lc, linphone_core_create_presence_model_with_activity(pauline->lc, LinphonePresenceActivityAway, NULL));
|
||||
|
||||
BC_ASSERT_TRUE(wait_for_until(laure->lc, pauline->lc, &laure->stat.number_of_NotifyPresenceReceived, 3, 5000));
|
||||
lf = linphone_friend_list_find_friend_by_uri(laure->lc->friendlist, pauline_identity);
|
||||
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusAway, int, "%d");
|
||||
|
||||
linphone_core_manager_destroy(laure);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
||||
|
||||
|
||||
test_t presence_tests[] = {
|
||||
TEST_NO_TAG("Simple Subscribe", simple_subscribe),
|
||||
|
|
@ -783,13 +896,12 @@ test_t presence_tests[] = {
|
|||
TEST_NO_TAG("App managed presence failure", subscribe_failure_handle_by_app),
|
||||
TEST_NO_TAG("Presence SUBSCRIBE forked", subscribe_presence_forked),
|
||||
TEST_NO_TAG("Presence SUBSCRIBE expired", subscribe_presence_expired),
|
||||
#if USE_PRESENCE_SERVER
|
||||
TEST_NO_TAG("Subscriber no loguer reachable using server",subscriber_no_longuer_reachable),
|
||||
TEST_NO_TAG("Subscribe with late publish", test_subscribe_notify_publish),
|
||||
TEST_NO_TAG("Forked subscribe with late publish", test_forked_subscribe_notify_publish),
|
||||
#endif
|
||||
TEST_NO_TAG("Presence list", test_presence_list),
|
||||
TEST_NO_TAG("Presence list (subscribe before publish)", test_presence_list_subscribe_before_publish),
|
||||
TEST_NO_TAG("Presence list, subscription expiration",test_presence_list_subscription_expire)
|
||||
TEST_NO_TAG("Presence list, subscription expiration for unknown contact",test_presence_list_subscription_expire_for_unknown),
|
||||
TEST_NO_TAG("Presence list, silent subscription expiration", test_presence_list_subscribe_dialog_expire)
|
||||
};
|
||||
|
||||
test_suite_t presence_test_suite = {"Presence", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each,
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ static void simple_unregister(void){
|
|||
LinphoneProxyConfig* proxy_config;
|
||||
register_with_refresh_base(lcm->lc,FALSE,NULL,NULL);
|
||||
|
||||
linphone_core_get_default_proxy(lcm->lc,&proxy_config);
|
||||
proxy_config = linphone_core_get_default_proxy_config(lcm->lc);
|
||||
|
||||
linphone_proxy_config_edit(proxy_config);
|
||||
reset_counters(counters); /*clear stats*/
|
||||
|
|
|
|||
|
|
@ -255,11 +255,6 @@ bool_t transport_supported(LinphoneTransportType transport) {
|
|||
return supported;
|
||||
}
|
||||
|
||||
|
||||
static void display_status(LinphoneCore *lc, const char *status){
|
||||
ms_message("display_status(): %s",status);
|
||||
}
|
||||
|
||||
void linphone_core_manager_init(LinphoneCoreManager *mgr, const char* rc_file) {
|
||||
char *rc_path = NULL;
|
||||
char *hellopath = bc_tester_res("sounds/hello8000.wav");
|
||||
|
|
@ -282,7 +277,6 @@ void linphone_core_manager_init(LinphoneCoreManager *mgr, const char* rc_file) {
|
|||
mgr->v_table.network_reachable=network_reachable;
|
||||
mgr->v_table.dtmf_received=dtmf_received;
|
||||
mgr->v_table.call_stats_updated=call_stats_updated;
|
||||
mgr->v_table.display_status=display_status;
|
||||
|
||||
reset_counters(&mgr->stat);
|
||||
if (rc_file) rc_path = ms_strdup_printf("rcfiles/%s", rc_file);
|
||||
|
|
@ -354,7 +348,7 @@ void linphone_core_manager_start(LinphoneCoreManager *mgr, int check_for_proxies
|
|||
BC_ASSERT_EQUAL(mgr->stat.number_of_LinphoneRegistrationOk,proxy_count, int, "%d");
|
||||
enable_codec(mgr->lc,"PCMU",8000);
|
||||
|
||||
linphone_core_get_default_proxy(mgr->lc,&proxy);
|
||||
proxy = linphone_core_get_default_proxy_config(mgr->lc);
|
||||
if (proxy) {
|
||||
mgr->identity = linphone_address_clone(linphone_proxy_config_get_identity_address(proxy));
|
||||
linphone_address_clean(mgr->identity);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue