From ce01af18f78925d387ac3b6db14a0c9744ae817f Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 4 Jan 2016 17:06:50 +0100 Subject: [PATCH] Notify presence list notify events only to the internal vtables. --- coreapi/event.c | 8 ++++++++ coreapi/friendlist.c | 1 + coreapi/linphonecore.c | 2 ++ coreapi/linphonecore.h | 1 + coreapi/private.h | 7 +++++++ coreapi/vtables.c | 21 ++++++++++++++++++++- 6 files changed, 39 insertions(+), 1 deletion(-) diff --git a/coreapi/event.c b/coreapi/event.c index 8fd95ede6..7505fd723 100644 --- a/coreapi/event.c +++ b/coreapi/event.c @@ -88,6 +88,14 @@ LinphoneEvent *linphone_event_new_with_out_of_dialog_op(LinphoneCore *lc, SalOp return linphone_event_new_with_op_base(lc,op,dir,name,TRUE); } +void linphone_event_set_internal(LinphoneEvent *lev, bool_t internal) { + lev->internal = internal; +} + +bool_t linphone_event_is_internal(LinphoneEvent *lev) { + return lev->internal; +} + void linphone_event_set_state(LinphoneEvent *lev, LinphoneSubscriptionState state){ if (lev->subscription_state!=state){ ms_message("LinphoneEvent [%p] moving to subscription state %s",lev,linphone_subscription_state_to_string(state)); diff --git a/coreapi/friendlist.c b/coreapi/friendlist.c index 02dcec40a..e620dba08 100644 --- a/coreapi/friendlist.c +++ b/coreapi/friendlist.c @@ -381,6 +381,7 @@ void linphone_friend_list_update_subscriptions(LinphoneFriendList *list, Linphon int expires = lp_config_get_int(list->lc->config, "sip", "rls_presence_expires", 3600); list->expected_notification_version = 0; list->event = linphone_core_create_subscribe(list->lc, address, "presence", expires); + linphone_event_set_internal(list->event, TRUE); linphone_event_add_custom_header(list->event, "Require", "recipient-list-subscribe"); linphone_event_add_custom_header(list->event, "Supported", "eventlist"); linphone_event_add_custom_header(list->event, "Accept", "multipart/related, application/pidf+xml, application/rlmi+xml"); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 3d22687be..b90f4799c 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1685,6 +1685,8 @@ static void linphone_core_init(LinphoneCore * lc, const LinphoneCoreVTable *vtab const char *remote_provisioning_uri = NULL; LinphoneCoreVTable* local_vtable= linphone_core_v_table_new(); LinphoneCoreVTable *internal_vtable = linphone_core_v_table_new(); + + linphone_core_v_table_set_internal(internal_vtable, TRUE); ms_message("Initializing LinphoneCore %s", linphone_core_get_version()); lc->config=lp_config_ref(config); diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index a801b7e1c..475fcd65b 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -2090,6 +2090,7 @@ typedef struct _LinphoneCoreVTable{ LinphoneCoreLogCollectionUploadStateChangedCb log_collection_upload_state_changed; /**< Callback to upload collected logs */ LinphoneCoreLogCollectionUploadProgressIndicationCb log_collection_upload_progress_indication; /**< Callback to indicate log collection upload progress */ void *user_data; /**user_data; } +void linphone_core_v_table_set_internal(LinphoneCoreVTable *table, bool_t internal) { + table->internal = internal; +} + +bool_t linphone_core_v_table_is_internal(LinphoneCoreVTable *table) { + return table->internal; +} + void linphone_core_v_table_destroy(LinphoneCoreVTable* table) { ms_free(table); } @@ -66,6 +74,17 @@ static void cleanup_dead_vtable_refs(LinphoneCore *lc){ }\ if (has_cb) ms_message("Linphone core [%p] notifying [%s]",lc,#function_name) +#define NOTIFY_IF_EXIST_INTERNAL(function_name, internal, ...) \ + MSList* iterator; \ + VTableReference *ref; \ + bool_t has_cb = FALSE; \ + for (iterator=lc->vtable_refs; iterator!=NULL; iterator=iterator->next)\ + if ((ref=(VTableReference*)iterator->data)->valid && (lc->current_vtable=ref->vtable)->function_name && (linphone_core_v_table_is_internal(lc->current_vtable) == internal)) {\ + lc->current_vtable->function_name(__VA_ARGS__);\ + has_cb = TRUE;\ + }\ + if (has_cb) ms_message("Linphone core [%p] notifying [%s]",lc,#function_name) + void linphone_core_notify_global_state_changed(LinphoneCore *lc, LinphoneGlobalState gstate, const char *message) { NOTIFY_IF_EXIST(global_state_changed,lc,gstate,message); cleanup_dead_vtable_refs(lc); @@ -229,7 +248,7 @@ void linphone_core_notify_network_reachable(LinphoneCore *lc, bool_t reachable) } void linphone_core_notify_notify_received(LinphoneCore *lc, LinphoneEvent *lev, const char *notified_event, const LinphoneContent *body) { - NOTIFY_IF_EXIST(notify_received, lc,lev,notified_event,body); + NOTIFY_IF_EXIST_INTERNAL(notify_received, linphone_event_is_internal(lev), lc, lev, notified_event, body); cleanup_dead_vtable_refs(lc); }