forked from mirrors/linphone-iphone
WORKAROUND set correct cpp pointer to C LinphoneChatRoom
This commit is contained in:
parent
fb8d255b4f
commit
554ad75cca
4 changed files with 46 additions and 8 deletions
|
|
@ -38,6 +38,7 @@
|
|||
#include "c-wrapper/c-wrapper.h"
|
||||
#include "chat/chat-room/basic-chat-room.h"
|
||||
#include "chat/chat-room/client-group-chat-room.h"
|
||||
#include "chat/chat-room/client-group-to-basic-chat-room.h"
|
||||
#include "chat/chat-room/real-time-text-chat-room-p.h"
|
||||
#include "chat/chat-room/real-time-text-chat-room.h"
|
||||
#include "content/content-type.h"
|
||||
|
|
@ -131,10 +132,24 @@ int linphone_core_message_received(LinphoneCore *lc, LinphonePrivate::SalOp *op,
|
|||
localAddress = op->get_to();
|
||||
}
|
||||
|
||||
shared_ptr<LinphonePrivate::AbstractChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(
|
||||
LinphonePrivate::ChatRoomId(LinphonePrivate::IdentityAddress(peerAddress), LinphonePrivate::IdentityAddress(localAddress))
|
||||
// TODO: remove when using signals
|
||||
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(
|
||||
LinphonePrivate::ChatRoomId(LinphonePrivate::IdentityAddress(peerAddress),
|
||||
LinphonePrivate::IdentityAddress(localAddress)
|
||||
))
|
||||
);
|
||||
if (!cr)
|
||||
return LinphoneReasonNone;
|
||||
shared_ptr<LinphonePrivate::AbstractChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(cr);
|
||||
|
||||
shared_ptr<LinphonePrivate::AbstractChatRoom> acr;
|
||||
if (chatRoom->getCapabilities() & LinphonePrivate::ChatRoom::Capabilities::Proxy)
|
||||
acr = static_pointer_cast<LinphonePrivate::ClientGroupToBasicChatRoom>(chatRoom)->getProxiedChatRoom();
|
||||
else
|
||||
acr = chatRoom;
|
||||
|
||||
L_SET_CPP_PTR_FROM_C_OBJECT(cr, acr);
|
||||
if (chatRoom)
|
||||
reason = L_GET_PRIVATE(chatRoom)->onSipMessageReceived(op, sal_msg);
|
||||
else {
|
||||
|
|
@ -145,6 +160,7 @@ int linphone_core_message_received(LinphoneCore *lc, LinphonePrivate::SalOp *op,
|
|||
reason = L_GET_PRIVATE_FROM_C_OBJECT(cr)->onSipMessageReceived(op, sal_msg);
|
||||
linphone_address_unref(addr);
|
||||
}
|
||||
L_SET_CPP_PTR_FROM_C_OBJECT(cr, chatRoom);
|
||||
return reason;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2136,10 +2136,14 @@ static void linphone_core_internal_notify_received(LinphoneCore *lc, LinphoneEve
|
|||
const LinphoneAddress *resource = linphone_event_get_resource(lev);
|
||||
const LinphoneAddress *from = linphone_event_get_from(lev);
|
||||
|
||||
shared_ptr<AbstractChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(LinphonePrivate::ChatRoomId(
|
||||
IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(resource)),
|
||||
IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(from))
|
||||
));
|
||||
// TODO: remove when using signals
|
||||
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(LinphonePrivate::ChatRoomId(
|
||||
IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(resource)),
|
||||
IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(from))
|
||||
))
|
||||
);
|
||||
shared_ptr<AbstractChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(cr);
|
||||
|
||||
if (chatRoom) {
|
||||
shared_ptr<ClientGroupChatRoom> cgcr;
|
||||
|
|
@ -2148,6 +2152,8 @@ static void linphone_core_internal_notify_received(LinphoneCore *lc, LinphoneEve
|
|||
static_pointer_cast<ClientGroupToBasicChatRoom>(chatRoom)->getProxiedChatRoom());
|
||||
else
|
||||
cgcr = static_pointer_cast<ClientGroupChatRoom>(chatRoom);
|
||||
|
||||
L_SET_CPP_PTR_FROM_C_OBJECT(cr, cgcr);
|
||||
if (linphone_content_is_multipart(body)) {
|
||||
// TODO : migrate to c++ 'Content'.
|
||||
int i = 0;
|
||||
|
|
@ -2158,6 +2164,8 @@ static void linphone_core_internal_notify_received(LinphoneCore *lc, LinphoneEve
|
|||
}
|
||||
} else
|
||||
L_GET_PRIVATE(cgcr)->notifyReceived(linphone_content_get_string_buffer(body));
|
||||
|
||||
L_SET_CPP_PTR_FROM_C_OBJECT(cr, chatRoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include "chat/chat-message/chat-message-p.h"
|
||||
|
||||
#include "chat/chat-room/chat-room-p.h"
|
||||
#include "chat/chat-room/client-group-to-basic-chat-room.h"
|
||||
#include "chat/chat-room/real-time-text-chat-room.h"
|
||||
#include "chat/modifier/cpim-chat-message-modifier.h"
|
||||
#include "chat/modifier/encryption-chat-message-modifier.h"
|
||||
|
|
@ -857,7 +858,20 @@ void ChatMessage::send () {
|
|||
return;
|
||||
}
|
||||
|
||||
getChatRoom()->getPrivate()->sendChatMessage(getSharedFromThis());
|
||||
// TODO: remove when using signals
|
||||
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(getCore()->findChatRoom(getChatRoom()->getChatRoomId()));
|
||||
|
||||
shared_ptr<LinphonePrivate::AbstractChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(cr);
|
||||
|
||||
shared_ptr<LinphonePrivate::AbstractChatRoom> acr;
|
||||
if (chatRoom->getCapabilities() & LinphonePrivate::ChatRoom::Capabilities::Proxy)
|
||||
acr = static_pointer_cast<LinphonePrivate::ClientGroupToBasicChatRoom>(chatRoom)->getProxiedChatRoom();
|
||||
else
|
||||
acr = chatRoom;
|
||||
|
||||
L_SET_CPP_PTR_FROM_C_OBJECT(cr, acr);
|
||||
acr->getPrivate()->sendChatMessage(getSharedFromThis());
|
||||
L_SET_CPP_PTR_FROM_C_OBJECT(cr, chatRoom);
|
||||
}
|
||||
|
||||
void ChatMessage::sendDeliveryNotification (LinphoneReason reason) {
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ void ChatRoomPrivate::sendChatMessage (const shared_ptr<ChatMessage> &chatMessag
|
|||
|
||||
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(q);
|
||||
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr);
|
||||
LinphoneChatRoomCbsParticipantAddedCb cb = linphone_chat_room_cbs_get_chat_message_sent(cbs);
|
||||
LinphoneChatRoomCbsChatMessageSentCb cb = linphone_chat_room_cbs_get_chat_message_sent(cbs);
|
||||
|
||||
// TODO: server currently don't stock message, remove condition in the future.
|
||||
if (cb && !linphone_core_conference_server_enabled(q->getCore()->getCCore())) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue