mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-27 07:59:20 +00:00
Fix chat related code that was broken with the introduction of ChatRoomId.
This commit is contained in:
parent
a39d7d01b9
commit
f117ff958c
10 changed files with 62 additions and 62 deletions
|
|
@ -129,7 +129,7 @@ static void call_received(SalCallOp *h) {
|
|||
linphone_address_unref(toAddr);
|
||||
linphone_address_unref(fromAddr);
|
||||
shared_ptr<ChatRoom> chatRoom = lc->cppCore->findChatRoom(
|
||||
ChatRoomId(SimpleAddress(h->get_to()), SimpleAddress(h->get_from()))
|
||||
ChatRoomId(SimpleAddress(h->get_to()), SimpleAddress(h->get_to()))
|
||||
);
|
||||
if (chatRoom) {
|
||||
L_GET_PRIVATE(static_pointer_cast<ServerGroupChatRoom>(chatRoom))->confirmJoining(h);
|
||||
|
|
@ -753,10 +753,10 @@ static void refer_received(SalOp *op, const SalAddress *refer_to){
|
|||
if (linphone_core_conference_server_enabled(lc)) {
|
||||
// Removal of a participant at the server side
|
||||
shared_ptr<ChatRoom> chatRoom = lc->cppCore->findChatRoom(
|
||||
ChatRoomId(SimpleAddress(op->get_to()), SimpleAddress(op->get_from()))
|
||||
ChatRoomId(SimpleAddress(op->get_to()), SimpleAddress(op->get_to()))
|
||||
);
|
||||
if (chatRoom) {
|
||||
std::shared_ptr<Participant> participant = chatRoom->findParticipant(chatRoom->getLocalAddress());
|
||||
std::shared_ptr<Participant> participant = chatRoom->findParticipant(SimpleAddress(op->get_from()));
|
||||
if (!participant || !participant->isAdmin()) {
|
||||
static_cast<SalReferOp *>(op)->reply(SalReasonDeclined);
|
||||
return;
|
||||
|
|
@ -770,7 +770,7 @@ static void refer_received(SalOp *op, const SalAddress *refer_to){
|
|||
} else {
|
||||
// The server asks a participant to leave a chat room
|
||||
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(
|
||||
lc->cppCore->findChatRoom(ChatRoomId(addr, SimpleAddress(op->get_from())))
|
||||
lc->cppCore->findChatRoom(ChatRoomId(addr, SimpleAddress(op->get_to())))
|
||||
);
|
||||
if (cr) {
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(cr)->leave();
|
||||
|
|
@ -781,7 +781,7 @@ static void refer_received(SalOp *op, const SalAddress *refer_to){
|
|||
}
|
||||
} else if (addr.hasParam("admin")) {
|
||||
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(lc->cppCore->findChatRoom(
|
||||
ChatRoomId(SimpleAddress(op->get_to()), SimpleAddress(op->get_from()))
|
||||
ChatRoomId(SimpleAddress(op->get_to()), SimpleAddress(op->get_to()))
|
||||
));
|
||||
if (cr) {
|
||||
Address fromAddr(op->get_from());
|
||||
|
|
@ -799,9 +799,7 @@ static void refer_received(SalOp *op, const SalAddress *refer_to){
|
|||
return;
|
||||
}
|
||||
} else {
|
||||
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(lc->cppCore->findChatRoom(
|
||||
ChatRoomId(addr, SimpleAddress(op->get_from()))
|
||||
));
|
||||
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(lc->cppCore->findChatRoom(ChatRoomId(addr, SimpleAddress(op->get_to()))));
|
||||
if (!cr)
|
||||
cr = _linphone_client_group_chat_room_new(lc, addr.asString().c_str(), nullptr);
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(cr)->join();
|
||||
|
|
|
|||
|
|
@ -111,15 +111,21 @@ LinphoneChatRoom *linphone_core_get_chat_room_from_uri(LinphoneCore *lc, const c
|
|||
|
||||
int linphone_core_message_received(LinphoneCore *lc, LinphonePrivate::SalOp *op, const SalMessage *sal_msg) {
|
||||
LinphoneReason reason = LinphoneReasonNotAcceptable;
|
||||
const char *peerAddress = linphone_core_conference_server_enabled(lc) ? op->get_to() : op->get_from();
|
||||
const char *peerAddress;
|
||||
const char *localAddress;
|
||||
if (linphone_core_conference_server_enabled(lc)) {
|
||||
localAddress = peerAddress = op->get_to();
|
||||
} else {
|
||||
peerAddress = op->get_from();
|
||||
localAddress = op->get_to();
|
||||
}
|
||||
|
||||
// TODO: Use local address.
|
||||
list<shared_ptr<LinphonePrivate::ChatRoom>> chatRooms = lc->cppCore->findChatRooms(
|
||||
LinphonePrivate::SimpleAddress(peerAddress)
|
||||
shared_ptr<LinphonePrivate::ChatRoom> chatRoom = lc->cppCore->findChatRoom(
|
||||
LinphonePrivate::ChatRoomId(LinphonePrivate::SimpleAddress(peerAddress), LinphonePrivate::SimpleAddress(localAddress))
|
||||
);
|
||||
|
||||
if (!chatRooms.empty())
|
||||
reason = L_GET_PRIVATE(chatRooms.front())->messageReceived(op, sal_msg);
|
||||
if (chatRoom)
|
||||
reason = L_GET_PRIVATE(chatRoom)->messageReceived(op, sal_msg);
|
||||
else {
|
||||
LinphoneAddress *addr = linphone_address_new(sal_msg->from);
|
||||
linphone_address_clean(addr);
|
||||
|
|
|
|||
|
|
@ -2135,16 +2135,17 @@ static void linphone_core_internal_notify_received(LinphoneCore *lc, LinphoneEve
|
|||
}
|
||||
} else if (strcmp(notified_event, "conference") == 0) {
|
||||
const LinphoneAddress *resource = linphone_event_get_resource(lev);
|
||||
const LinphoneAddress *from = linphone_event_get_from(lev);
|
||||
|
||||
// TODO: Ensure it is the good solution.
|
||||
list<shared_ptr<ChatRoom>> chatRooms = lc->cppCore->findChatRooms(
|
||||
SimpleAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(resource))
|
||||
);
|
||||
shared_ptr<ChatRoom> chatRoom = lc->cppCore->findChatRoom(LinphonePrivate::ChatRoomId(
|
||||
SimpleAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(resource)),
|
||||
SimpleAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(from))
|
||||
));
|
||||
|
||||
if (!chatRooms.empty())
|
||||
L_GET_PRIVATE(static_pointer_cast<ClientGroupChatRoom>(chatRooms.front()))->notifyReceived(
|
||||
if (chatRoom)
|
||||
L_GET_PRIVATE(static_pointer_cast<ClientGroupChatRoom>(chatRoom))->notifyReceived(
|
||||
linphone_content_get_string_buffer(body)
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2154,15 +2155,13 @@ static void _linphone_core_conference_subscription_state_changed(LinphoneCore *l
|
|||
state == LinphoneSubscriptionIncomingReceived
|
||||
) {
|
||||
const LinphoneAddress *resource = linphone_event_get_resource(lev);
|
||||
|
||||
// TODO: Ensure it is the good solution.
|
||||
list<shared_ptr<ChatRoom>> chatRooms = lc->cppCore->findChatRooms(
|
||||
shared_ptr<ChatRoom> chatRoom = lc->cppCore->findChatRoom(LinphonePrivate::ChatRoomId(
|
||||
SimpleAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(resource)),
|
||||
SimpleAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(resource))
|
||||
);
|
||||
|
||||
if (!chatRooms.empty()) {
|
||||
));
|
||||
if (chatRoom) {
|
||||
linphone_event_accept_subscription(lev);
|
||||
L_GET_PRIVATE(static_pointer_cast<ServerGroupChatRoom>(chatRooms.front()))->subscribeReceived(lev);
|
||||
L_GET_PRIVATE(static_pointer_cast<ServerGroupChatRoom>(chatRoom))->subscribeReceived(lev);
|
||||
} else
|
||||
linphone_event_deny_subscription(lev, LinphoneReasonDeclined);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,13 +56,14 @@ bctbx_list_t **linphone_core_get_call_logs_attribute(LinphoneCore *lc) {
|
|||
return &lc->call_logs;
|
||||
}
|
||||
|
||||
LinphoneChatRoom * linphone_core_find_chat_room (const LinphoneCore *lc, const LinphoneAddress *addr) {
|
||||
list<shared_ptr<ChatRoom>> chatRooms = lc->cppCore->findChatRooms(
|
||||
SimpleAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(addr))
|
||||
);
|
||||
LinphoneChatRoom * linphone_core_find_chat_room (const LinphoneCore *lc, const LinphoneAddress *peerAddr, const LinphoneAddress *localAddr) {
|
||||
shared_ptr<ChatRoom> chatRoom = lc->cppCore->findChatRoom(ChatRoomId(
|
||||
SimpleAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(peerAddr)),
|
||||
SimpleAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(localAddr))
|
||||
));
|
||||
|
||||
if (!chatRooms.empty())
|
||||
return L_GET_C_BACK_PTR(chatRooms.front());
|
||||
if (chatRoom)
|
||||
return L_GET_C_BACK_PTR(chatRoom);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ LINPHONE_PUBLIC LinphoneQualityReporting *linphone_call_log_get_quality_reportin
|
|||
LINPHONE_PUBLIC reporting_session_report_t **linphone_quality_reporting_get_reports(LinphoneQualityReporting *qreporting);
|
||||
|
||||
LINPHONE_PUBLIC bctbx_list_t * linphone_chat_room_get_transient_messages(const LinphoneChatRoom *cr);
|
||||
LINPHONE_PUBLIC LinphoneChatRoom * linphone_core_find_chat_room (const LinphoneCore *lc, const LinphoneAddress *addr);
|
||||
LINPHONE_PUBLIC LinphoneChatRoom * linphone_core_find_chat_room (const LinphoneCore *lc, const LinphoneAddress *peerAddr, const LinphoneAddress *localAddr);
|
||||
|
||||
LINPHONE_PUBLIC MSList* linphone_core_fetch_friends_from_db(LinphoneCore *lc, LinphoneFriendList *list);
|
||||
LINPHONE_PUBLIC MSList* linphone_core_fetch_friends_lists_from_db(LinphoneCore *lc);
|
||||
|
|
|
|||
|
|
@ -67,6 +67,10 @@ public:
|
|||
this->fromAddress = fromAddress;
|
||||
}
|
||||
|
||||
inline void forceToAddress (const SimpleAddress &toAddress) {
|
||||
this->toAddress = toAddress;
|
||||
}
|
||||
|
||||
unsigned int getStorageId() const;
|
||||
void setStorageId(unsigned int id);
|
||||
|
||||
|
|
@ -149,6 +153,7 @@ private:
|
|||
std::weak_ptr<ChatRoom> chatRoom;
|
||||
ChatRoomId chatRoomId;
|
||||
SimpleAddress fromAddress;
|
||||
SimpleAddress toAddress;
|
||||
|
||||
ChatMessage::State state = ChatMessage::State::Idle;
|
||||
ChatMessage::Direction direction = ChatMessage::Direction::Incoming;
|
||||
|
|
|
|||
|
|
@ -678,26 +678,21 @@ void ChatMessagePrivate::send () {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
ChatMessage::ChatMessage (const shared_ptr<ChatRoom> &chatRoom) :
|
||||
ChatMessage::ChatMessage (const shared_ptr<ChatRoom> &chatRoom, ChatMessage::Direction direction) :
|
||||
Object(*new ChatMessagePrivate), CoreAccessor(chatRoom->getCore()) {
|
||||
L_ASSERT(chatRoom);
|
||||
L_D();
|
||||
|
||||
d->chatRoom = chatRoom;
|
||||
d->chatRoomId = chatRoom->getChatRoomId();
|
||||
d->fromAddress = chatRoom->getLocalAddress();
|
||||
d->direction = Direction::Outgoing;
|
||||
}
|
||||
|
||||
ChatMessage::ChatMessage (const shared_ptr<ChatRoom> &chatRoom, const SimpleAddress &fromAddress) :
|
||||
Object(*new ChatMessagePrivate), CoreAccessor(chatRoom->getCore()) {
|
||||
L_ASSERT(chatRoom);
|
||||
L_D();
|
||||
|
||||
d->chatRoom = chatRoom;
|
||||
d->chatRoomId = chatRoom->getChatRoomId();
|
||||
d->fromAddress = fromAddress;
|
||||
d->direction = Direction::Incoming;
|
||||
if (direction == Direction::Outgoing) {
|
||||
d->fromAddress = chatRoom->getLocalAddress();
|
||||
d->toAddress = chatRoom->getPeerAddress();
|
||||
} else {
|
||||
d->fromAddress = chatRoom->getPeerAddress();
|
||||
d->toAddress = chatRoom->getLocalAddress();
|
||||
}
|
||||
d->direction = direction;
|
||||
}
|
||||
|
||||
ChatMessage::~ChatMessage () {
|
||||
|
|
@ -779,7 +774,7 @@ const SimpleAddress &ChatMessage::getFromAddress () const {
|
|||
|
||||
const SimpleAddress &ChatMessage::getToAddress () const {
|
||||
L_D();
|
||||
return d->direction == Direction::Outgoing ? d->chatRoomId.getPeerAddress() : d->chatRoomId.getLocalAddress();
|
||||
return d->toAddress;
|
||||
}
|
||||
|
||||
const SimpleAddress &ChatMessage::getLocalAddress () const {
|
||||
|
|
|
|||
|
|
@ -55,14 +55,6 @@ public:
|
|||
L_DECLARE_ENUM(State, L_ENUM_VALUES_CHAT_MESSAGE_STATE);
|
||||
L_DECLARE_ENUM(Direction, L_ENUM_VALUES_CHAT_MESSAGE_DIRECTION);
|
||||
|
||||
// TODO: Make me private.
|
||||
|
||||
// Build an outgoing message.
|
||||
ChatMessage (const std::shared_ptr<ChatRoom> &chatRoom);
|
||||
|
||||
// Build and incoming message.
|
||||
ChatMessage (const std::shared_ptr<ChatRoom> &chatRoom, const SimpleAddress &fromAddress);
|
||||
|
||||
~ChatMessage ();
|
||||
|
||||
// ----- TODO: Remove me.
|
||||
|
|
@ -114,6 +106,8 @@ public:
|
|||
bool downloadFile (FileTransferContent &content);
|
||||
|
||||
private:
|
||||
ChatMessage (const std::shared_ptr<ChatRoom> &chatRoom, ChatMessage::Direction direction);
|
||||
|
||||
L_DECLARE_PRIVATE(ChatMessage);
|
||||
L_DISABLE_COPY(ChatMessage);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ void ChatRoomPrivate::sendIsComposingNotification () {
|
|||
if (linphone_im_notif_policy_get_send_is_composing(policy)) {
|
||||
string payload = isComposingHandler->marshal(isComposing);
|
||||
if (!payload.empty()) {
|
||||
shared_ptr<ChatMessage> msg = q->createMessage();
|
||||
shared_ptr<ChatMessage> msg = createChatMessage(ChatMessage::Direction::Outgoing);
|
||||
Content *content = new Content();
|
||||
content->setContentType(ContentType::ImIsComposing);
|
||||
content->setBody(payload);
|
||||
|
|
@ -164,8 +164,8 @@ void ChatRoomPrivate::sendIsComposingNotification () {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
shared_ptr<ChatMessage> ChatRoomPrivate::createChatMessage (ChatMessage::Direction direction) {
|
||||
// TODO: Create me.
|
||||
return nullptr;
|
||||
L_Q();
|
||||
return shared_ptr<ChatMessage>(new ChatMessage(q->getSharedFromThis(), direction));
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@ static inline ChatRoomId resolveWorkaroundClientGroupChatRoomId (
|
|||
|
||||
SimpleAddress peerAddress = chatRoomId.getPeerAddress();
|
||||
peerAddress.setDomain(Address(uri).getDomain());
|
||||
return ChatRoomId(peerAddress, chatRoomId.getLocalAddress());
|
||||
SimpleAddress localAddress = chatRoomId.getLocalAddress();
|
||||
localAddress.setDomain(Address(uri).getDomain());
|
||||
return ChatRoomId(peerAddress, localAddress);
|
||||
}
|
||||
|
||||
// TODO: Remove me later.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue