mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-02-07 14:18:25 +00:00
send presence to multiple instances of a same user that subscribed to us. Fixes memory leak.
This commit is contained in:
parent
c6f1d4303c
commit
b9c32d33a5
4 changed files with 29 additions and 33 deletions
|
|
@ -92,7 +92,7 @@ LinphoneFriend *linphone_find_friend_by_inc_subscribe(MSList *l, SalOp *op){
|
|||
MSList *elem;
|
||||
for (elem=l;elem!=NULL;elem=elem->next){
|
||||
LinphoneFriend *lf=(LinphoneFriend*)elem->data;
|
||||
if (lf->insub==op) return lf;
|
||||
if (ms_list_find(lf->insubs, op)) return lf;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -227,12 +227,24 @@ int linphone_friend_set_inc_subscribe_policy(LinphoneFriend *fr, LinphoneSubscri
|
|||
}
|
||||
|
||||
void linphone_friend_notify(LinphoneFriend *lf, LinphonePresenceModel *presence){
|
||||
char *addr=linphone_address_as_string(linphone_friend_get_address(lf));
|
||||
ms_message("Want to notify %s, insub=%p",addr,lf->insub);
|
||||
ms_free(addr);
|
||||
if (lf->insub!=NULL){
|
||||
sal_notify_presence(lf->insub,(SalPresenceModel *)presence);
|
||||
MSList *elem;
|
||||
if (lf->insubs){
|
||||
char *addr=linphone_address_as_string(linphone_friend_get_address(lf));
|
||||
ms_message("Want to notify %s",addr);
|
||||
ms_free(addr);
|
||||
}
|
||||
for(elem=lf->insubs; elem!=NULL; elem=elem->next){
|
||||
SalOp *op = (SalOp*)elem->data;
|
||||
sal_notify_presence(op,(SalPresenceModel *)presence);
|
||||
}
|
||||
}
|
||||
|
||||
void linphone_friend_add_incoming_subscription(LinphoneFriend *lf, SalOp *op){
|
||||
lf->insubs = ms_list_append(lf->insubs, op);
|
||||
}
|
||||
|
||||
void linphone_friend_remove_incoming_subscription(LinphoneFriend *lf, SalOp *op){
|
||||
lf->insubs = ms_list_remove(lf->insubs, op);
|
||||
}
|
||||
|
||||
static void linphone_friend_unsubscribe(LinphoneFriend *lf){
|
||||
|
|
@ -260,17 +272,12 @@ static void linphone_friend_invalidate_subscription(LinphoneFriend *lf){
|
|||
|
||||
void linphone_friend_close_subscriptions(LinphoneFriend *lf){
|
||||
linphone_friend_unsubscribe(lf);
|
||||
if (lf->insub){
|
||||
sal_notify_presence_close(lf->insub);
|
||||
ms_list_for_each(lf->insubs, (MSIterateFunc) sal_notify_presence_close);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void _linphone_friend_destroy(LinphoneFriend *lf){
|
||||
if (lf->insub) {
|
||||
sal_op_release(lf->insub);
|
||||
lf->insub=NULL;
|
||||
}
|
||||
lf->insubs = ms_list_free_with_data(lf->insubs, (MSIterateFunc) sal_op_release);
|
||||
if (lf->outsub){
|
||||
sal_op_release(lf->outsub);
|
||||
lf->outsub=NULL;
|
||||
|
|
|
|||
|
|
@ -1445,7 +1445,7 @@ static LinphonePresenceModel * process_pidf_xml_presence_notification(xmlparsing
|
|||
void linphone_core_add_subscriber(LinphoneCore *lc, const char *subscriber, SalOp *op){
|
||||
LinphoneFriend *fl=linphone_friend_new_with_address(subscriber);
|
||||
if (fl==NULL) return ;
|
||||
fl->insub=op;
|
||||
linphone_friend_add_incoming_subscription(fl, op);
|
||||
linphone_friend_set_inc_subscribe_policy(fl,LinphoneSPAccept);
|
||||
fl->inc_subscribe_pending=TRUE;
|
||||
lc->subscribers=ms_list_append(lc->subscribers,(void *)fl);
|
||||
|
|
@ -1468,9 +1468,7 @@ void linphone_core_notify_all_friends(LinphoneCore *lc, LinphonePresenceModel *p
|
|||
if (activity_str != NULL) ms_free(activity_str);
|
||||
for(elem=lc->friends;elem!=NULL;elem=elem->next){
|
||||
LinphoneFriend *lf=(LinphoneFriend *)elem->data;
|
||||
if (lf->insub){
|
||||
linphone_friend_notify(lf,presence);
|
||||
}
|
||||
linphone_friend_notify(lf,presence);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1478,26 +1476,15 @@ void linphone_subscription_new(LinphoneCore *lc, SalOp *op, const char *from){
|
|||
LinphoneFriend *lf=NULL;
|
||||
char *tmp;
|
||||
LinphoneAddress *uri;
|
||||
LinphoneProxyConfig *cfg;
|
||||
|
||||
uri=linphone_address_new(from);
|
||||
linphone_address_clean(uri);
|
||||
tmp=linphone_address_as_string(uri);
|
||||
ms_message("Receiving new subscription from %s.",from);
|
||||
|
||||
cfg=linphone_core_lookup_known_proxy(lc,uri);
|
||||
if (cfg!=NULL){
|
||||
if (cfg->op){
|
||||
if (sal_op_get_contact_address(cfg->op)) {
|
||||
sal_op_set_contact_address (op,sal_op_get_contact_address(cfg->op));
|
||||
ms_message("Contact for next subscribe answer has been fixed using proxy "/*to %s",fixed_contact*/);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* check if we answer to this subscription */
|
||||
if (linphone_find_friend_by_address(lc->friends,uri,&lf)!=NULL){
|
||||
lf->insub=op;
|
||||
linphone_friend_add_incoming_subscription(lf, op);
|
||||
lf->inc_subscribe_pending=TRUE;
|
||||
sal_subscribe_accept(op);
|
||||
linphone_friend_done(lf); /*this will do all necessary actions */
|
||||
|
|
@ -1904,7 +1891,7 @@ void linphone_subscription_closed(LinphoneCore *lc, SalOp *op){
|
|||
lf=linphone_find_friend_by_inc_subscribe(lc->friends,op);
|
||||
sal_op_release(op);
|
||||
if (lf!=NULL){
|
||||
lf->insub=NULL;
|
||||
linphone_friend_remove_incoming_subscription(lf, op);
|
||||
}else{
|
||||
ms_warning("Receiving unsuscribe for unknown in-subscribtion from %s", sal_op_get_from(op));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -355,6 +355,8 @@ const LinphoneAddress* linphone_proxy_config_get_service_route(const LinphonePro
|
|||
void linphone_friend_close_subscriptions(LinphoneFriend *lf);
|
||||
void linphone_friend_update_subscribes(LinphoneFriend *fr, LinphoneProxyConfig *cfg, bool_t only_when_registered);
|
||||
void linphone_friend_notify(LinphoneFriend *lf, LinphonePresenceModel *presence);
|
||||
void linphone_friend_add_incoming_subscription(LinphoneFriend *lf, SalOp *op);
|
||||
void linphone_friend_remove_incoming_subscription(LinphoneFriend *lf, SalOp *op);
|
||||
LinphoneFriend *linphone_find_friend_by_inc_subscribe(MSList *l, SalOp *op);
|
||||
LinphoneFriend *linphone_find_friend_by_out_subscribe(MSList *l, SalOp *op);
|
||||
MSList *linphone_find_friend_by_address(MSList *fl, const LinphoneAddress *addr, LinphoneFriend **lf);
|
||||
|
|
@ -585,7 +587,7 @@ struct _LinphoneFriend{
|
|||
belle_sip_object_t base;
|
||||
void *user_data;
|
||||
LinphoneAddress *uri;
|
||||
SalOp *insub;
|
||||
MSList *insubs; /*list of SalOp. There can be multiple instances of a same Friend that subscribe to our presence*/
|
||||
SalOp *outsub;
|
||||
LinphoneSubscribePolicy pol;
|
||||
LinphonePresenceModel *presence;
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ void linphone_gtk_push_text(GtkWidget *w, const LinphoneAddress *from,
|
|||
int tnow_year;
|
||||
|
||||
gtk_text_buffer_get_end_iter(buffer, &iter);
|
||||
if(g_strcmp0(from_message,from_str)!=0){
|
||||
if (g_strcmp0(from_message,from_str)!=0){
|
||||
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, get_display_name(from), -1,
|
||||
"from", me ? "me" : NULL, NULL);
|
||||
gtk_text_buffer_insert_with_tags_by_name(buffer,&iter, " : ", -1,
|
||||
|
|
@ -196,8 +196,8 @@ void linphone_gtk_push_text(GtkWidget *w, const LinphoneAddress *from,
|
|||
gtk_text_buffer_insert(buffer,&iter,"\n",-1);
|
||||
g_free(from_message);
|
||||
g_object_set_data(G_OBJECT(w),"from_message",g_strdup(from_str));
|
||||
ms_free(from_str);
|
||||
}
|
||||
ms_free(from_str);
|
||||
|
||||
link_start_mark = gtk_text_buffer_create_mark(buffer, NULL, &iter, TRUE);
|
||||
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, linphone_chat_message_get_text(msg), -1,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue