Commit caacc7a8 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Started ChatRoom getLastChatMessage

parent 1a68000f
......@@ -202,6 +202,13 @@ LINPHONE_PUBLIC bctbx_list_t *linphone_chat_room_get_history_events (LinphoneCha
*/
LINPHONE_PUBLIC bctbx_list_t *linphone_chat_room_get_history_range_events (LinphoneChatRoom *cr, int begin, int end);
/**
* Gets the last chat message sent or received in this chat room
* @param[in] cr The #LinphoneChatRoom object corresponding to the conversation for which last message should be retrieved
* @return the latest #LinphoneChatMessage
*/
LINPHONE_PUBLIC LinphoneChatMessage *linphone_chat_room_get_last_message_in_history(LinphoneChatRoom *cr);
LINPHONE_PUBLIC LinphoneChatMessage * linphone_chat_room_find_message(LinphoneChatRoom *cr, const char *message_id);
/**
......
......@@ -217,6 +217,10 @@ bctbx_list_t *linphone_chat_room_get_history_range_events (LinphoneChatRoom *cr,
);
}
LinphoneChatMessage *linphone_chat_room_get_last_message_in_history(LinphoneChatRoom *cr) {
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getLastMessageInHistory());
}
LinphoneChatMessage *linphone_chat_room_find_message (LinphoneChatRoom *cr, const char *message_id) {
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->findMessage(message_id));
}
......
......@@ -447,6 +447,10 @@ list<shared_ptr<ChatMessage> > ChatRoom::getHistoryRange (int startm, int endm)
return list<shared_ptr<ChatMessage>>();
}
shared_ptr<ChatMessage> ChatRoom::getLastMessageInHistory() const {
return getCore()->getPrivate()->mainDb->getLastChatMessage(getChatRoomId());
}
int ChatRoom::getUnreadChatMessagesCount () {
return getCore()->getPrivate()->mainDb->getUnreadChatMessagesCount(getChatRoomId());
}
......
......@@ -58,6 +58,8 @@ public:
virtual CapabilitiesMask getCapabilities () const = 0;
std::shared_ptr<ChatMessage> getLastMessageInHistory() const;
// TODO: Remove useless functions.
void compose ();
std::shared_ptr<ChatMessage> createFileTransferMessage (const LinphoneContent *initialContent);
......
......@@ -1389,6 +1389,11 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
return list<shared_ptr<ChatMessage>>();
}
shared_ptr<ChatMessage> MainDb::getLastChatMessage(const ChatRoomId &chatRoomId) const {
// TODO.
return nullptr;
}
list<shared_ptr<EventLog>> MainDb::getHistory (const ChatRoomId &chatRoomId, int nLast, FilterMask mask) const {
return getHistoryRange(chatRoomId, 0, nLast - 1, mask);
}
......
......@@ -77,6 +77,7 @@ public:
int getUnreadChatMessagesCount (const ChatRoomId &chatRoomId = ChatRoomId()) const;
void markChatMessagesAsRead (const ChatRoomId &chatRoomId = ChatRoomId()) const;
std::list<std::shared_ptr<ChatMessage>> getUnreadChatMessages (const ChatRoomId &chatRoomId = ChatRoomId()) const;
std::shared_ptr<ChatMessage> getLastChatMessage(const ChatRoomId &chatRoomId = ChatRoomId()) const;
// ---------------------------------------------------------------------------
// Conference events.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment