mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-20 20:48:07 +00:00
fix(c-chat-room): repair get history function
This commit is contained in:
parent
eb3fbf682d
commit
47cf1d436c
4 changed files with 27 additions and 32 deletions
|
|
@ -196,30 +196,24 @@ void linphone_chat_room_delete_history (LinphoneChatRoom *cr) {
|
|||
}
|
||||
|
||||
bctbx_list_t *linphone_chat_room_get_history_range (LinphoneChatRoom *cr, int startm, int endm) {
|
||||
return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getHistoryRange(startm, endm));
|
||||
list<shared_ptr<LinphonePrivate::ChatMessage>> chatMessages;
|
||||
for (auto &event : L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getHistoryRange(startm, endm))
|
||||
if (event->getType() == LinphonePrivate::EventLog::Type::ConferenceChatMessage)
|
||||
chatMessages.push_back(static_pointer_cast<LinphonePrivate::ConferenceChatMessageEvent>(event)->getChatMessage());
|
||||
|
||||
return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(chatMessages);
|
||||
}
|
||||
|
||||
bctbx_list_t *linphone_chat_room_get_history (LinphoneChatRoom *cr, int nb_message) {
|
||||
return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getHistory(nb_message));
|
||||
return linphone_chat_room_get_history_range(cr, 0, nb_message);
|
||||
}
|
||||
|
||||
bctbx_list_t *linphone_chat_room_get_history_events (LinphoneChatRoom *cr, int nb_events) {
|
||||
return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(
|
||||
L_GET_PRIVATE(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getCore())->mainDb->getHistory(
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getChatRoomId(),
|
||||
nb_events
|
||||
)
|
||||
);
|
||||
return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getHistory(nb_events));
|
||||
}
|
||||
|
||||
bctbx_list_t *linphone_chat_room_get_history_range_events (LinphoneChatRoom *cr, int begin, int end) {
|
||||
return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(
|
||||
L_GET_PRIVATE(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getCore())->mainDb->getHistory(
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getChatRoomId(),
|
||||
begin,
|
||||
end
|
||||
)
|
||||
);
|
||||
return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getHistoryRange(begin, end));
|
||||
}
|
||||
|
||||
LinphoneChatMessage *linphone_chat_room_get_last_message_in_history(LinphoneChatRoom *cr) {
|
||||
|
|
|
|||
|
|
@ -406,19 +406,18 @@ shared_ptr<ChatMessage> ChatRoom::findMessageWithDirection (const string &messag
|
|||
return ret;
|
||||
}
|
||||
|
||||
list<shared_ptr<ChatMessage> > ChatRoom::getHistory (int nbMessages) {
|
||||
return getHistoryRange(0, nbMessages - 1);
|
||||
list<shared_ptr<EventLog>> ChatRoom::getHistory (int nLast) {
|
||||
return getCore()->getPrivate()->mainDb->getHistory(getChatRoomId(), nLast);
|
||||
}
|
||||
|
||||
list<shared_ptr<EventLog>> ChatRoom::getHistoryRange (int begin, int end) {
|
||||
return getCore()->getPrivate()->mainDb->getHistoryRange(getChatRoomId(), begin, end);
|
||||
}
|
||||
|
||||
int ChatRoom::getHistorySize () {
|
||||
return getCore()->getPrivate()->mainDb->getChatMessagesCount(getChatRoomId());
|
||||
}
|
||||
|
||||
list<shared_ptr<ChatMessage> > ChatRoom::getHistoryRange (int startm, int endm) {
|
||||
// TODO: history.
|
||||
return list<shared_ptr<ChatMessage>>();
|
||||
}
|
||||
|
||||
shared_ptr<ChatMessage> ChatRoom::getLastMessageInHistory() const {
|
||||
return getCore()->getPrivate()->mainDb->getLastChatMessage(getChatRoomId());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
class ChatRoomPrivate;
|
||||
class EventLog;
|
||||
|
||||
class LINPHONE_PUBLIC ChatRoom : public Object, public CoreAccessor, public ConferenceInterface {
|
||||
friend class ChatMessage;
|
||||
|
|
@ -59,6 +60,10 @@ public:
|
|||
virtual CapabilitiesMask getCapabilities () const = 0;
|
||||
virtual bool hasBeenLeft () const = 0;
|
||||
|
||||
std::list<std::shared_ptr<EventLog>> getHistory (int nLast);
|
||||
std::list<std::shared_ptr<EventLog>> getHistoryRange (int begin, int end);
|
||||
int getHistorySize ();
|
||||
|
||||
std::shared_ptr<ChatMessage> getLastMessageInHistory () const;
|
||||
|
||||
// TODO: Remove useless functions.
|
||||
|
|
@ -69,9 +74,6 @@ public:
|
|||
void deleteHistory ();
|
||||
std::shared_ptr<ChatMessage> findMessage (const std::string &messageId);
|
||||
std::shared_ptr<ChatMessage> findMessageWithDirection (const std::string &messageId, ChatMessage::Direction direction);
|
||||
std::list<std::shared_ptr<ChatMessage>> getHistory (int nbMessages);
|
||||
int getHistorySize ();
|
||||
std::list<std::shared_ptr<ChatMessage>> getHistoryRange (int startm, int endm);
|
||||
int getUnreadChatMessagesCount ();
|
||||
bool isRemoteComposing () const;
|
||||
std::list<Address> getComposingAddresses () const;
|
||||
|
|
|
|||
|
|
@ -1566,14 +1566,14 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
|
|||
}
|
||||
|
||||
string query = "SELECT id, creation_time FROM event WHERE"
|
||||
" id IN ("
|
||||
" SELECT conference_event.event_id FROM conference_event, conference_chat_message_event"
|
||||
" WHERE";
|
||||
" id IN ("
|
||||
" SELECT conference_event.event_id FROM conference_event, conference_chat_message_event"
|
||||
" WHERE";
|
||||
if (chatRoomId.isValid())
|
||||
query += " chat_room_id = :chatRoomId AND ";
|
||||
query += " conference_event.event_id = conference_chat_message_event.event_id"
|
||||
" AND direction = " + Utils::toString(static_cast<int>(ChatMessage::Direction::Incoming)) +
|
||||
" AND state <> " + Utils::toString(static_cast<int>(ChatMessage::State::Displayed)) +
|
||||
query += " chat_room_id = :chatRoomId AND ";
|
||||
query += " conference_event.event_id = conference_chat_message_event.event_id"
|
||||
" AND direction = " + Utils::toString(static_cast<int>(ChatMessage::Direction::Incoming)) +
|
||||
" AND state <> " + Utils::toString(static_cast<int>(ChatMessage::State::Displayed)) +
|
||||
")";
|
||||
|
||||
DurationLogger durationLogger(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue