From 03261a97b161cb736d8ce2609c7cf8c8d98a948e Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 18 Dec 2015 14:56:20 +0100 Subject: [PATCH] Add API to refresh a subscription. --- coreapi/bellesip_sal/sal_op_events.c | 9 +++++++++ coreapi/event.c | 4 ++++ coreapi/event.h | 9 ++++++++- include/sal/sal.h | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/coreapi/bellesip_sal/sal_op_events.c b/coreapi/bellesip_sal/sal_op_events.c index d41440d96..631e23b36 100644 --- a/coreapi/bellesip_sal/sal_op_events.c +++ b/coreapi/bellesip_sal/sal_op_events.c @@ -223,6 +223,15 @@ int sal_subscribe(SalOp *op, const char *from, const char *to, const char *event return -1; } +int sal_subscribe_refresh(SalOp *op) { + if (op->refresher) { + belle_sip_refresher_refresh(op->refresher,belle_sip_refresher_get_expires(op->refresher)); + return 0; + } + ms_warning("sal_refresh_subscribe(): no refresher"); + return -1; +} + int sal_unsubscribe(SalOp *op){ if (op->refresher){ const belle_sip_transaction_t *tr=(const belle_sip_transaction_t*) belle_sip_refresher_get_transaction(op->refresher); diff --git a/coreapi/event.c b/coreapi/event.c index 9320047ae..8fd95ede6 100644 --- a/coreapi/event.c +++ b/coreapi/event.c @@ -192,6 +192,10 @@ int linphone_event_update_subscribe(LinphoneEvent *lev, const LinphoneContent *b return linphone_event_send_subscribe(lev,body); } +int linphone_event_refresh_subscribe(LinphoneEvent *lev) { + return sal_subscribe_refresh(lev->op); +} + int linphone_event_accept_subscription(LinphoneEvent *lev){ int err; if (lev->subscription_state!=LinphoneSubscriptionIncomingReceived){ diff --git a/coreapi/event.h b/coreapi/event.h index fe3f984de..5200beb66 100644 --- a/coreapi/event.h +++ b/coreapi/event.h @@ -138,12 +138,19 @@ LINPHONE_PUBLIC LinphoneEvent *linphone_core_create_subscribe(LinphoneCore *lc, LINPHONE_PUBLIC int linphone_event_send_subscribe(LinphoneEvent *ev, const LinphoneContent *body); /** - * Update (refresh) an outgoing subscription. + * Update (refresh) an outgoing subscription, changing the body. * @param lev a LinphoneEvent * @param body an optional body to include in the subscription update, may be NULL. **/ LINPHONE_PUBLIC int linphone_event_update_subscribe(LinphoneEvent *lev, const LinphoneContent *body); +/** + * Refresh an outgoing subscription keeping the same body. + * @param lev LinphoneEvent object. + * @return 0 if successful, -1 otherwise. + */ +LINPHONE_PUBLIC int linphone_event_refresh_subscribe(LinphoneEvent *lev); + /** * Accept an incoming subcription. diff --git a/include/sal/sal.h b/include/sal/sal.h index 6031278bf..dccc2d08e 100644 --- a/include/sal/sal.h +++ b/include/sal/sal.h @@ -742,6 +742,7 @@ int sal_subscribe(SalOp *op, const char *from, const char *to, const char *event int sal_unsubscribe(SalOp *op); int sal_subscribe_accept(SalOp *op); int sal_subscribe_decline(SalOp *op, SalReason reason); +int sal_subscribe_refresh(SalOp *op); int sal_notify(SalOp *op, const SalBodyHandler *body); int sal_notify_close(SalOp *op); int sal_publish(SalOp *op, const char *from, const char *to, const char*event_name, int expires, const SalBodyHandler *body);