From ba53ca3ee62fdac13644d1277947f81e813983cb Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 18 Jun 2013 21:26:49 +0200 Subject: [PATCH] LinphoneEvent: add accessors to resource address and from. --- coreapi/event.c | 20 ++++++++++++++++++++ coreapi/event.h | 10 ++++++++++ coreapi/help/notify.c | 2 ++ 3 files changed, 32 insertions(+) diff --git a/coreapi/event.c b/coreapi/event.c index 264b24472..0b54f607a 100644 --- a/coreapi/event.c +++ b/coreapi/event.c @@ -29,6 +29,8 @@ struct _LinphoneEvent{ void *userdata; int refcnt; char *name; + LinphoneAddress *from; + LinphoneAddress *resource_addr; }; LinphoneSubscriptionState linphone_subscription_state_from_sal(SalSubscribeStatus ss){ @@ -59,6 +61,12 @@ LinphoneEvent *linphone_event_new(LinphoneCore *lc, LinphoneSubscriptionDir dir, LinphoneEvent *linphone_event_new_with_op(LinphoneCore *lc, SalOp *op, LinphoneSubscriptionDir dir, const char *name){ LinphoneEvent *lev=linphone_event_new_base(lc, dir, name, op); + if (dir==LinphoneSubscriptionIncoming){ + lev->resource_addr=linphone_address_clone((LinphoneAddress*)sal_op_get_to_address(op)); + lev->from=linphone_address_clone((LinphoneAddress*)sal_op_get_from_address(lev->op)); + }else{ + lev->resource_addr=linphone_address_clone((LinphoneAddress*)sal_op_get_from_address(op)); + } return lev; } @@ -87,6 +95,8 @@ LinphoneEvent *linphone_core_subscribe(LinphoneCore *lc, const LinphoneAddress * LinphoneEvent *lev=linphone_event_new(lc, LinphoneSubscriptionOutgoing, event); SalBody salbody; linphone_configure_op(lc,lev->op,resource,NULL,TRUE); + lev->resource_addr=linphone_address_clone(resource); + lev->from=linphone_address_clone((LinphoneAddress*)sal_op_get_from_address(lev->op)); sal_subscribe(lev->op,NULL,NULL,event,expires,sal_body_from_content(&salbody,body)); linphone_event_set_state(lev,LinphoneSubscriptionOutoingInit); return lev; @@ -187,6 +197,8 @@ static void linphone_event_destroy(LinphoneEvent *lev){ if (lev->op) sal_op_release(lev->op); ms_free(lev->name); + if (lev->resource_addr) linphone_address_destroy(lev->resource_addr); + if (lev->from) linphone_address_destroy(lev->from); ms_free(lev); } @@ -207,3 +219,11 @@ const char *linphone_event_get_name(const LinphoneEvent *lev){ return lev->name; } +const LinphoneAddress *linphone_event_get_from(const LinphoneEvent *lev){ + return lev->from; +} + +const LinphoneAddress *linphone_event_get_resource(const LinphoneEvent *lev){ + return lev->resource_addr; +} + diff --git a/coreapi/event.h b/coreapi/event.h index d535a4c8a..6db01f46e 100644 --- a/coreapi/event.h +++ b/coreapi/event.h @@ -171,6 +171,16 @@ void linphone_event_unref(LinphoneEvent *lev); **/ const char *linphone_event_get_name(const LinphoneEvent *lev); +/** + * Get the "from" address of the subscription. +**/ +const LinphoneAddress *linphone_event_get_from(const LinphoneEvent *lev); + +/** + * Get the resource address of the subscription or publish. +**/ +const LinphoneAddress *linphone_event_get_resource(const LinphoneEvent *lev); + /** * @} **/ diff --git a/coreapi/help/notify.c b/coreapi/help/notify.c index eb8cfbda3..0055346ee 100644 --- a/coreapi/help/notify.c +++ b/coreapi/help/notify.c @@ -34,6 +34,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ +#define DEBUG 1 + #ifdef IN_LINPHONE #include "linphonecore.h" #else