From c26031d755c62661ced02d11908376799e12810c Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 24 Oct 2017 18:03:20 +0200 Subject: [PATCH] feat(c-chat-room): provide a way to get history events --- include/linphone/api/c-chat-room.h | 19 ++++++++++++++++++- src/c-wrapper/api/c-chat-room.cpp | 21 +++++++++++++++++++++ src/c-wrapper/internal/c-tools.h | 2 +- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/include/linphone/api/c-chat-room.h b/include/linphone/api/c-chat-room.h index aa7fdda4c..a190ac8be 100644 --- a/include/linphone/api/c-chat-room.h +++ b/include/linphone/api/c-chat-room.h @@ -165,7 +165,7 @@ LINPHONE_PUBLIC int linphone_chat_room_get_history_size(LinphoneChatRoom *cr); * @param[in] nb_message Number of message to retrieve. 0 means everything. * @return \bctbx_list{LinphoneChatMessage} */ -LINPHONE_PUBLIC bctbx_list_t *linphone_chat_room_get_history(LinphoneChatRoom *cr,int nb_message); +LINPHONE_PUBLIC bctbx_list_t *linphone_chat_room_get_history (LinphoneChatRoom *cr,int nb_message); /** * Gets the partial list of messages in the given range, sorted from oldest to most recent. @@ -176,6 +176,23 @@ LINPHONE_PUBLIC bctbx_list_t *linphone_chat_room_get_history(LinphoneChatRoom *c */ LINPHONE_PUBLIC bctbx_list_t *linphone_chat_room_get_history_range(LinphoneChatRoom *cr, int begin, int end); +/** + * Gets nb_events most recent events from cr chat room, sorted from oldest to most recent. + * @param[in] cr The #LinphoneChatRoom object corresponding to the conversation for which events should be retrieved + * @param[in] nb_events Number of events to retrieve. 0 means everything. + * @return \bctbx_list{LinphoneEventLog} + */ +LINPHONE_PUBLIC bctbx_list_t *linphone_chat_room_get_history_events (LinphoneChatRoom *cr, int nb_events); + +/** + * Gets the partial list of events in the given range, sorted from oldest to most recent. + * @param[in] cr The #LinphoneChatRoom object corresponding to the conversation for which events should be retrieved + * @param[in] begin The first event of the range to be retrieved. History most recent event has index 0. + * @param[in] end The last event of the range to be retrieved. History oldest event has index of history size - 1 + * @return \bctbx_list{LinphoneEventLog} + */ +LINPHONE_PUBLIC bctbx_list_t *linphone_chat_room_get_history_range_events (LinphoneChatRoom *cr, int begin, int end); + LINPHONE_PUBLIC LinphoneChatMessage * linphone_chat_room_find_message(LinphoneChatRoom *cr, const char *message_id); /** diff --git a/src/c-wrapper/api/c-chat-room.cpp b/src/c-wrapper/api/c-chat-room.cpp index 08a0ff47e..e112f83c4 100644 --- a/src/c-wrapper/api/c-chat-room.cpp +++ b/src/c-wrapper/api/c-chat-room.cpp @@ -23,11 +23,13 @@ #include "linphone/wrapper_utils.h" #include "linphone/api/c-chat-room.h" +#include "event-log/event-log.h" #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/real-time-text-chat-room-p.h" #include "conference/participant.h" +#include "core/core-p.h" // ============================================================================= @@ -201,6 +203,25 @@ bctbx_list_t *linphone_chat_room_get_history (LinphoneChatRoom *cr, int nb_messa return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getHistory(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()->cppCore)->mainDb.getHistory( + L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getPeerAddress().asStringUriOnly(), + 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()->cppCore)->mainDb.getHistory( + L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getPeerAddress().asStringUriOnly(), + begin, + end + ) + ); +} + 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)); } diff --git a/src/c-wrapper/internal/c-tools.h b/src/c-wrapper/internal/c-tools.h index 3783688c6..7ec402e3c 100644 --- a/src/c-wrapper/internal/c-tools.h +++ b/src/c-wrapper/internal/c-tools.h @@ -413,7 +413,7 @@ public: template< typename CppType, - typename = typename std::enable_if::value, CppType>::type + typename = typename std::enable_if::value, CppType>::type > static inline bctbx_list_t *getResolvedCListFromCppList (const std::list> &cppList) { bctbx_list_t *result = nullptr;