Commit 58cb7a3f authored by jehan's avatar jehan

use belle-sip refresher with dialog terminated recovery capability

parent e73f376c
......@@ -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
......
This diff is collapsed.
......@@ -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);
......
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