Commit 368bcf11 authored by Nicolas Michon's avatar Nicolas Michon

Fix wrong contact in headers when sending subscribes to chatrooms

parent 3dbe0c9f
......@@ -227,6 +227,13 @@ LinphoneEvent *linphone_core_create_subscribe(LinphoneCore *lc, const LinphoneAd
return lev;
LinphoneEvent *linphone_core_create_subscribe_2(LinphoneCore *lc, const LinphoneAddress *resource, LinphoneProxyConfig *cfg, const char *event, int expires){
LinphoneEvent *lev=linphone_event_new(lc, LinphoneSubscriptionOutgoing, event, expires);
return lev;
LinphoneEvent *linphone_core_create_notify(LinphoneCore *lc, const LinphoneAddress *resource, const char *event){
LinphoneEvent *lev=linphone_event_new(lc, LinphoneSubscriptionIncoming, event, -1);
......@@ -3559,6 +3559,36 @@ static bctbx_list_t *make_routes_for_proxy(LinphoneProxyConfig *proxy, const Lin
return ret;
* Returns a proxy config matching the given identity address
* Prefers registered, then first registering matching, otherwise first matching
LinphoneProxyConfig * linphone_core_lookup_proxy_by_identity(LinphoneCore *lc, const LinphoneAddress *uri){
LinphoneProxyConfig *found_cfg = NULL;
LinphoneProxyConfig *found_reg_cfg = NULL;
LinphoneProxyConfig *found_noreg_cfg = NULL;
LinphoneProxyConfig *default_cfg=lc->default_proxy;
const bctbx_list_t *elem;
for (elem=linphone_core_get_proxy_config_list(lc);elem!=NULL;elem=elem->next){
LinphoneProxyConfig *cfg = (LinphoneProxyConfig*)elem->data;
if (linphone_address_weak_equal(uri, linphone_proxy_config_get_identity_address(cfg))) {
if (linphone_proxy_config_get_state(cfg) == LinphoneRegistrationOk) {
} else if (!found_reg_cfg && linphone_proxy_config_register_enabled(cfg)) {
} else if (!found_noreg_cfg) {
if (!found_cfg && found_reg_cfg) found_cfg = found_reg_cfg;
else if (!found_cfg && found_noreg_cfg) found_cfg = found_noreg_cfg;
if (!found_cfg) found_cfg=default_cfg; /*when no matching proxy config is found, use the default proxy config*/
return found_cfg;
LinphoneProxyConfig * linphone_core_lookup_known_proxy(LinphoneCore *lc, const LinphoneAddress *uri){
const bctbx_list_t *elem;
LinphoneProxyConfig *found_cfg=NULL;
......@@ -263,6 +263,7 @@ LinphoneFriend * linphone_friend_new_from_config_file(struct _LinphoneCore *lc,
void linphone_proxy_config_update(LinphoneProxyConfig *cfg);
LinphoneProxyConfig * linphone_core_lookup_known_proxy(LinphoneCore *lc, const LinphoneAddress *uri);
LinphoneProxyConfig * linphone_core_lookup_proxy_by_identity(LinphoneCore *lc, const LinphoneAddress *uri);
const char *linphone_core_find_best_identity(LinphoneCore *lc, const LinphoneAddress *to);
LINPHONE_PUBLIC void linphone_core_get_local_ip(LinphoneCore *lc, int af, const char *dest, char *result);
......@@ -5391,6 +5391,18 @@ LINPHONE_PUBLIC LinphoneEvent *linphone_core_subscribe(LinphoneCore *lc, const L
LINPHONE_PUBLIC LinphoneEvent *linphone_core_create_subscribe(LinphoneCore *lc, const LinphoneAddress *resource, const char *event, int expires);
* Create an outgoing subscription, specifying the destination resource, the event name, and an optional content body.
* If accepted, the subscription runs for a finite period, but is automatically renewed if not terminated before.
* Unlike linphone_core_subscribe() the subscription isn't sent immediately. It will be send when calling linphone_event_send_subscribe().
* @param lc the #LinphoneCore
* @param resource the destination resource
* @param proxy the proxy configuration to use
* @param event the event name
* @param expires the whished duration of the subscription
* @return a #LinphoneEvent holding the context of the created subcription.
LINPHONE_PUBLIC LinphoneEvent *linphone_core_create_subscribe_2(LinphoneCore *lc, const LinphoneAddress *resource, LinphoneProxyConfig *proxy, const char *event, int expires);
* Create an out-of-dialog notification, specifying the destination resource, the event name.
......@@ -196,16 +196,18 @@ void RemoteConferenceEventHandlerPrivate::subscribe () {
return; // Already subscribed or application did not request subscription
const string &peerAddress = conferenceId.getPeerAddress().asString();
LinphoneAddress *lAddr = linphone_address_new(peerAddress.c_str());
const string &localAddress = conferenceId.getLocalAddress().asString();
LinphoneAddress *lAddr = linphone_address_new(localAddress.c_str());
LinphoneCore *lc = conf->getCore()->getCCore();
LinphoneProxyConfig *cfg = linphone_core_lookup_known_proxy(lc, lAddr);
LinphoneProxyConfig *cfg = linphone_core_lookup_proxy_by_identity(lc, lAddr);
if (!cfg || (linphone_proxy_config_get_state(cfg) != LinphoneRegistrationOk)) {
lev = linphone_core_create_subscribe(conf->getCore()->getCCore(), lAddr, "conference", 600);
lev = linphone_core_create_subscribe_2(conf->getCore()->getCCore(), lAddr, cfg, "conference", 600);
const string &lastNotifyStr = Utils::toString(lastNotify);
linphone_event_add_custom_header(lev, "Last-Notify-Version", lastNotifyStr.c_str());
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