]> sjero.net Git - linphone/commitdiff
remove op from chatroom
authorJehan Monnier <jehan.monnier@linphone.org>
Tue, 16 Oct 2012 12:59:32 +0000 (14:59 +0200)
committerJehan Monnier <jehan.monnier@linphone.org>
Tue, 16 Oct 2012 13:15:24 +0000 (15:15 +0200)
coreapi/callbacks.c
coreapi/chat.c
coreapi/private.h

index 7c7d4f00315ed44b59cc599e6d7f51d6e4d4ec48..e7f6a7b219846c85b47eb1a76d90b2a39ca3cbf4 100644 (file)
@@ -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={
index 31f36013523e72a8164d0d53d5f260737e3a05ef..ea87c9740d6777c955142cbe687bcf2d4d06e133 100644 (file)
@@ -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) {
index b44fe4a97445487875076bcc7bdfbf76b2139727..07fd1c689189766bd999982326ba06b9742de5e6 100644 (file)
@@ -354,7 +354,6 @@ struct _LinphoneChatRoom{
        struct _LinphoneCore *lc;
        char  *peer;
        LinphoneAddress *peer_url;
-       SalOp *op;
        void * user_data;
 };