Commit eaf58cd9 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Fixed empty friend list subscription

parent 9fc7947d
......@@ -157,7 +157,7 @@ static char * create_resource_list_xml(const LinphoneFriendList *list) {
bctbx_iterator_t* it = bctbx_map_cchar_begin(list->friends_map_uri);
bctbx_iterator_t* end = bctbx_map_cchar_end(list->friends_map_uri);
if (it == end) {
if (bctbx_iterator_cchar_equals(it, end)) {
ms_warning("%s: Empty list in subscription, ignored.", __FUNCTION__);
return NULL;
}
......@@ -652,8 +652,7 @@ void linphone_friend_list_invalidate_friends_maps(LinphoneFriendList *list) {
LinphoneFriendListStatus linphone_friend_list_import_friend(LinphoneFriendList *list, LinphoneFriend *lf, bool_t synchronize) {
if (lf->friend_list) {
if (lf->friend_list)
ms_error("linphone_friend_list_add_friend(): invalid friend, already in list");
ms_error("linphone_friend_list_add_friend(): invalid friend, already in list");
return LinphoneFriendListInvalidFriend;
}
......@@ -891,18 +890,16 @@ bctbx_list_t * linphone_friend_list_find_friends_by_uri(const LinphoneFriendList
bctbx_list_t *result = NULL;
bctbx_iterator_t *it = bctbx_map_cchar_find_key(list->friends_map_uri, uri);
bctbx_iterator_t *end = bctbx_map_cchar_end(list->friends_map_uri);
if (!bctbx_iterator_cchar_equals(it, end)) {
while (!bctbx_iterator_cchar_equals(it, end)) {
const bctbx_pair_t *pair = bctbx_iterator_cchar_get_pair(it);
const char *friend_uri = bctbx_pair_cchar_get_first(reinterpret_cast<const bctbx_pair_cchar_t*>(pair));
if (uri && friend_uri && strcmp(friend_uri, uri) == 0) {
LinphoneFriend *lf = (LinphoneFriend *)bctbx_pair_cchar_get_second(pair);
result = bctbx_list_prepend(result, linphone_friend_ref(lf));
} else {
break;
}
it = bctbx_iterator_cchar_get_next(it);
while (!bctbx_iterator_cchar_equals(it, end)) {
const bctbx_pair_t *pair = bctbx_iterator_cchar_get_pair(it);
const char *friend_uri = bctbx_pair_cchar_get_first(reinterpret_cast<const bctbx_pair_cchar_t*>(pair));
if (uri && friend_uri && strcmp(friend_uri, uri) == 0) {
LinphoneFriend *lf = (LinphoneFriend *)bctbx_pair_cchar_get_second(pair);
result = bctbx_list_prepend(result, linphone_friend_ref(lf));
} else {
break;
}
it = bctbx_iterator_cchar_get_next(it);
}
bctbx_iterator_cchar_delete(end);
bctbx_iterator_cchar_delete(it);
......
......@@ -1376,6 +1376,15 @@ static void bodyless_config_read(LinphoneCore *lc) {
}
}
void linphone_core_invalidate_friends_maps(LinphoneCore *lc) {
bctbx_list_t *elem;
for (elem = lc->friends_lists; elem != NULL; elem = bctbx_list_next(elem)) {
LinphoneFriendList *list = (LinphoneFriendList *)bctbx_list_get_data(elem);
ms_message("Invalidating friends maps for list [%p]", list);
linphone_friend_list_invalidate_friends_maps(list);
}
}
static void sip_config_read(LinphoneCore *lc) {
char *contact;
const char *tmpstr;
......@@ -1480,6 +1489,9 @@ static void sip_config_read(LinphoneCore *lc) {
tmp=lp_config_get_int(lc->config,"sip","default_proxy",-1);
linphone_core_set_default_proxy_index(lc,tmp);
/* In case of remote provisioning, recompute the phone numbers in case the dial prefix of the default proxy config has changed */
linphone_core_invalidate_friends_maps(lc);
/* read authentication information */
for(i=0;; i++){
LinphoneAuthInfo *ai=linphone_auth_info_new_from_config_file(lc->config,i);
......
......@@ -621,6 +621,8 @@ void linphone_account_creator_set_current_callbacks(LinphoneAccountCreator *crea
LinphoneXmlRpcRequestCbs * linphone_xml_rpc_request_cbs_new(void);
void linphone_xml_rpc_request_set_current_callbacks(LinphoneXmlRpcRequest *request, LinphoneXmlRpcRequestCbs *cbs);
void linphone_core_invalidate_friends_maps(LinphoneCore *lc);
#ifdef __cplusplus
}
#endif
......
......@@ -631,13 +631,11 @@ void linphone_proxy_config_set_dial_prefix(LinphoneProxyConfig *cfg, const char
cfg->dial_prefix=NULL;
}
if (prefix && prefix[0]!='\0') cfg->dial_prefix=ms_strdup(prefix);
if (cfg->lc) {
bctbx_list_t *elem;
for (elem = cfg->lc->friends_lists; elem != NULL; elem = bctbx_list_next(elem)) {
LinphoneFriendList *list = (LinphoneFriendList *)bctbx_list_get_data(elem);
linphone_friend_list_invalidate_friends_maps(list);
}
/* Ensure there is a default proxy config otherwise after invalidating friends maps we won't be able to recompute phone numbers */
/* Also it is useless to do it if the proxy config being edited isn't the default one */
if (cfg->lc && cfg == linphone_core_get_default_proxy_config(cfg->lc)) {
linphone_core_invalidate_friends_maps(cfg->lc);
}
}
......@@ -1249,8 +1247,11 @@ void linphone_core_set_default_proxy_config(LinphoneCore *lc, LinphoneProxyConfi
}
}
lc->default_proxy=config;
if (linphone_core_ready(lc))
if (linphone_core_ready(lc)) {
lp_config_set_int(lc->config,"sip","default_proxy",linphone_core_get_default_proxy_config_index(lc));
/* Invalidate phone numbers in friends maps when default proxy config changes because the new one may have a different dial prefix */
linphone_core_invalidate_friends_maps(lc);
}
}
void linphone_core_set_default_proxy_index(LinphoneCore *lc, int index){
......
......@@ -3040,6 +3040,7 @@ void MediaSessionPrivate::startTextStream () {
lInfo() << "No valid text stream defined";
}
#ifdef VIDEO_ENABLED
static void video_filter_callback(void *userdata, struct _MSFilter *f, unsigned int id, void *arg) {
switch(id) {
case MS_CAMERA_PREVIEW_SIZE_CHANGED: {
......@@ -3051,6 +3052,7 @@ static void video_filter_callback(void *userdata, struct _MSFilter *f, unsigned
}
}
}
#endif
void MediaSessionPrivate::startVideoStream (CallSession::State targetState) {
#ifdef VIDEO_ENABLED
......
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