From 6fdaf45486deeb8dc2b5a2d43e2f3530047446de Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 5 Jun 2017 11:47:27 +0200 Subject: [PATCH] make sure publish proxy config has same From/To --- coreapi/event.c | 30 ++++++++++++++++++++++++++---- coreapi/linphonecore.c | 6 ++++-- coreapi/private.h | 3 ++- coreapi/proxy.c | 3 +-- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/coreapi/event.c b/coreapi/event.c index 44f6c1bf2..d5926dd96 100644 --- a/coreapi/event.c +++ b/coreapi/event.c @@ -272,13 +272,35 @@ LinphoneStatus linphone_event_notify(LinphoneEvent *lev, const LinphoneContent * return sal_notify(lev->op, body_handler); } -LinphoneEvent *linphone_core_create_publish(LinphoneCore *lc, const LinphoneAddress *resource, const char *event, int expires){ - LinphoneEvent *lev=linphone_event_new(lc,LinphoneSubscriptionInvalidDir, event,expires); - linphone_configure_op(lc,lev->op,resource,NULL,lp_config_get_int(lc->config,"sip","publish_msg_with_contact",0)); +static LinphoneEvent *_linphone_core_create_publish(LinphoneCore *core, LinphoneProxyConfig *cfg, const LinphoneAddress *resource, const char *event, int expires){ + LinphoneCore *lc = core; + LinphoneEvent *lev; + + if (!lc && cfg) { + if (cfg->lc) + lc = cfg->lc; + else { + ms_error("Cannot create publish from proxy config [%p] not attached to any core",cfg); + return NULL; + } + } + if (!resource && cfg) + resource = linphone_proxy_config_get_identity_address(cfg); + + lev = linphone_event_new(lc,LinphoneSubscriptionInvalidDir, event,expires); + linphone_configure_op_with_proxy(lc,lev->op,resource,NULL,lp_config_get_int(lc->config,"sip","publish_msg_with_contact",0),cfg); sal_op_set_manual_refresher_mode(lev->op,!lp_config_get_int(lc->config,"sip","refresh_generic_publish",1)); return lev; } - +LinphoneEvent *linphone_core_create_publish(LinphoneCore *lc, const LinphoneAddress *resource, const char *event, int expires){ + return _linphone_core_create_publish(lc, NULL, resource, event, expires); +} +LinphoneEvent *linphone_proxy_config_create_publish(LinphoneProxyConfig *cfg, const char *event, int expires) { + + return _linphone_core_create_publish(NULL, cfg,NULL, event, expires); + + +} LinphoneEvent *linphone_core_create_one_shot_publish(LinphoneCore *lc, const LinphoneAddress *resource, const char *event){ LinphoneEvent *lev = linphone_core_create_publish(lc, resource, event, -1); lev->oneshot = TRUE; diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index dd242bdbd..0f6ce1e57 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -3446,9 +3446,8 @@ static void linphone_transfer_routes_to_op(bctbx_list_t *routes, SalOp *op){ bctbx_list_free(routes); } -void linphone_configure_op(LinphoneCore *lc, SalOp *op, const LinphoneAddress *dest, SalCustomHeader *headers, bool_t with_contact){ +void linphone_configure_op_with_proxy(LinphoneCore *lc, SalOp *op, const LinphoneAddress *dest, SalCustomHeader *headers, bool_t with_contact, LinphoneProxyConfig *proxy){ bctbx_list_t *routes=NULL; - LinphoneProxyConfig *proxy=linphone_core_lookup_known_proxy(lc,dest); const char *identity; if (proxy){ identity=linphone_proxy_config_get_identity(proxy); @@ -3478,6 +3477,9 @@ void linphone_configure_op(LinphoneCore *lc, SalOp *op, const LinphoneAddress *d } sal_op_cnx_ip_to_0000_if_sendonly_enable(op,lp_config_get_default_int(lc->config,"sip","cnx_ip_to_0000_if_sendonly_enabled",0)); /*also set in linphone_call_new_incoming*/ } +void linphone_configure_op(LinphoneCore *lc, SalOp *op, const LinphoneAddress *dest, SalCustomHeader *headers, bool_t with_contact) { + linphone_configure_op_with_proxy(lc, op, dest, headers,with_contact,linphone_core_lookup_known_proxy(lc,dest)); +} LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const LinphoneAddress *addr, const LinphoneCallParams *params){ const char *from=NULL; diff --git a/coreapi/private.h b/coreapi/private.h index 9062a5773..8568d28d4 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -454,7 +454,7 @@ void linphone_proxy_config_write_all_to_config_file(LinphoneCore *lc); void _linphone_proxy_config_release(LinphoneProxyConfig *cfg); void _linphone_proxy_config_unpublish(LinphoneProxyConfig *obj); void linphone_proxy_config_notify_publish_state_changed(LinphoneProxyConfig *cfg, LinphonePublishState state); - +LinphoneEvent *linphone_proxy_config_create_publish(LinphoneProxyConfig *cfg, const char *event, int expires); /* * returns service route as defined in as defined by rfc3608, might be a list instead of just one. * Can be NULL @@ -1293,6 +1293,7 @@ void linphone_core_play_named_tone(LinphoneCore *lc, LinphoneToneID id); bool_t linphone_core_tone_indications_enabled(LinphoneCore*lc); const char *linphone_core_create_uuid(LinphoneCore *lc); void linphone_configure_op(LinphoneCore *lc, SalOp *op, const LinphoneAddress *dest, SalCustomHeader *headers, bool_t with_contact); +void linphone_configure_op_with_proxy(LinphoneCore *lc, SalOp *op, const LinphoneAddress *dest, SalCustomHeader *headers, bool_t with_contact, LinphoneProxyConfig *proxy); void linphone_call_create_op(LinphoneCall *call); int linphone_call_prepare_ice(LinphoneCall *call, bool_t incoming_offer); void linphone_core_notify_info_message(LinphoneCore* lc,SalOp *op, SalBodyHandler *body); diff --git a/coreapi/proxy.c b/coreapi/proxy.c index cc74dd541..f6574eeb8 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -856,8 +856,7 @@ int linphone_proxy_config_send_publish(LinphoneProxyConfig *proxy, LinphonePrese LinphoneContent *content; char *presence_body; if (proxy->presence_publish_event==NULL){ - proxy->presence_publish_event = linphone_core_create_publish(proxy->lc - , linphone_proxy_config_get_identity_address(proxy) + proxy->presence_publish_event = linphone_proxy_config_create_publish(proxy , "presence" , linphone_proxy_config_get_publish_expires(proxy)); linphone_event_ref(proxy->presence_publish_event);