From aa49870d7117df201ea56838f34fe651b458d0ee Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 16 Oct 2012 14:59:32 +0200 Subject: [PATCH] remove op from chatroom --- coreapi/callbacks.c | 10 ++++++++++ coreapi/chat.c | 7 ------- coreapi/private.h | 1 - 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 7c7d4f00..e7f6a7b2 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -804,14 +804,24 @@ static LinphoneChatMessageState chatStatusSal2Linphone(SalTextDeliveryStatus sta return LinphoneChatMessageStateIdle; } +static int op_equals(LinphoneCall *a, SalOp *b) { + return a->op !=b; /*return 0 if equals*/ +} static void text_delivery_update(SalOp *op, SalTextDeliveryStatus status){ LinphoneChatMessage *chat_msg=(LinphoneChatMessage* )sal_op_get_user_pointer(op); + const MSList* calls = linphone_core_get_calls(chat_msg->chat_room->lc); + if (chat_msg && chat_msg->cb) { chat_msg->cb(chat_msg ,chatStatusSal2Linphone(status) ,chat_msg->cb_ud); } linphone_chat_message_destroy(chat_msg); + + if (!ms_list_find_custom((MSList*)calls, (MSCompareFunc) op_equals, op)) { + /*op was only create for messaging purpose, destroying*/ + sal_op_release(op); + } } SalCallbacks linphone_sal_callbacks={ diff --git a/coreapi/chat.c b/coreapi/chat.c index 31f36013..ea87c974 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -46,8 +46,6 @@ lc->chatrooms=ms_list_remove(lc->chatrooms,(void *) cr); linphone_address_destroy(cr->peer_url); ms_free(cr->peer); - if (cr->op) - sal_op_release(cr->op); } @@ -75,11 +73,6 @@ static void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatM /*sending out of calls*/ op = sal_op_new(cr->lc->sal); sal_op_set_route(op,route); - if (cr->op!=NULL){ - sal_op_release (cr->op); - cr->op=NULL; - } - cr->op=op; sal_op_set_user_pointer(op, msg); /*if out of call, directly store msg*/ } if (msg->external_body_url) { diff --git a/coreapi/private.h b/coreapi/private.h index b44fe4a9..07fd1c68 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -354,7 +354,6 @@ struct _LinphoneChatRoom{ struct _LinphoneCore *lc; char *peer; LinphoneAddress *peer_url; - SalOp *op; void * user_data; }; -- 2.39.2