mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-19 12:08:11 +00:00
Started method to get participants in given state for given chat message
This commit is contained in:
parent
cd08c6e2fe
commit
8966c2ca77
7 changed files with 58 additions and 0 deletions
|
|
@ -369,6 +369,8 @@ LINPHONE_PUBLIC const char* linphone_chat_message_get_text_content(const Linphon
|
|||
*/
|
||||
LINPHONE_PUBLIC bool_t linphone_chat_message_is_file_transfer_in_progress(LinphoneChatMessage *msg);
|
||||
|
||||
LINPHONE_PUBLIC bctbx_list_t *linphone_chat_message_get_participants_in_state (const LinphoneChatMessage *msg, const LinphoneChatMessageState state);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include "chat/notification/imdn.h"
|
||||
#include "content/content-type.h"
|
||||
#include "content/content.h"
|
||||
#include "conference/participant.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
|
|
@ -246,6 +247,10 @@ bool_t linphone_chat_message_is_file_transfer_in_progress(LinphoneChatMessage *m
|
|||
return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->isFileTransferInProgress();
|
||||
}
|
||||
|
||||
bctbx_list_t *linphone_chat_message_get_participants_in_state (const LinphoneChatMessage *msg, const LinphoneChatMessageState state) {
|
||||
return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_PRIVATE_FROM_C_OBJECT(msg)->getParticipantsInState((LinphonePrivate::ChatMessage::State) state));
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Old listener
|
||||
// =============================================================================
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ public:
|
|||
void setDirection (ChatMessage::Direction dir);
|
||||
|
||||
void setParticipantState (const IdentityAddress &participantAddress, ChatMessage::State newState);
|
||||
std::list<std::shared_ptr<Participant>> getParticipantsInState (const ChatMessage::State state) const;
|
||||
void setState (ChatMessage::State newState, bool force = false);
|
||||
|
||||
void setTime (time_t time);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
#include "chat/modifier/encryption-chat-message-modifier.h"
|
||||
#include "chat/modifier/file-transfer-chat-message-modifier.h"
|
||||
#include "chat/modifier/multipart-chat-message-modifier.h"
|
||||
#include "conference/participant.h"
|
||||
#include "content/file-content.h"
|
||||
#include "content/content.h"
|
||||
#include "core/core.h"
|
||||
|
|
@ -122,6 +123,29 @@ void ChatMessagePrivate::setParticipantState (const IdentityAddress &participant
|
|||
setState(ChatMessage::State::DeliveredToUser);
|
||||
}
|
||||
|
||||
list<shared_ptr<Participant>> ChatMessagePrivate::getParticipantsInState (const ChatMessage::State state) const {
|
||||
L_Q();
|
||||
|
||||
list<shared_ptr<Participant>> participantsInState;
|
||||
if (!(q->getChatRoom()->getCapabilities() & AbstractChatRoom::Capabilities::Conference) || !dbKey.isValid()) {
|
||||
return participantsInState;
|
||||
}
|
||||
|
||||
unique_ptr<MainDb> &mainDb = q->getChatRoom()->getCore()->getPrivate()->mainDb;
|
||||
shared_ptr<EventLog> eventLog = mainDb->getEventFromKey(dbKey);
|
||||
list<IdentityAddress> addressesInState = mainDb->getChatMessageParticipantsInState(eventLog, state);
|
||||
const list<shared_ptr<Participant>> &participants = q->getChatRoom()->getParticipants();
|
||||
for (IdentityAddress addr : addressesInState) {
|
||||
for (const auto &participant : participants) {
|
||||
if (participant->getAddress() == addr) {
|
||||
participantsInState.push_back(participant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return participantsInState;
|
||||
}
|
||||
|
||||
void ChatMessagePrivate::setState (ChatMessage::State newState, bool force) {
|
||||
L_Q();
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ class AbstractChatRoom;
|
|||
class Content;
|
||||
class FileTransferContent;
|
||||
class ChatMessagePrivate;
|
||||
class Participant;
|
||||
|
||||
class LINPHONE_PUBLIC ChatMessage : public Object, public CoreAccessor {
|
||||
friend class BasicToClientGroupChatRoom;
|
||||
|
|
|
|||
|
|
@ -1970,6 +1970,30 @@ list<ChatMessage::State> MainDb::getChatMessageParticipantStates (const shared_p
|
|||
};
|
||||
}
|
||||
|
||||
list<IdentityAddress> MainDb::getChatMessageParticipantsInState (const shared_ptr<EventLog> &eventLog, const ChatMessage::State state) const {
|
||||
return L_DB_TRANSACTION {
|
||||
L_D();
|
||||
|
||||
const EventLogPrivate *dEventLog = eventLog->getPrivate();
|
||||
MainDbKeyPrivate *dEventKey = static_cast<MainDbKey &>(dEventLog->dbKey).getPrivate();
|
||||
const long long &eventId = dEventKey->storageId;
|
||||
|
||||
int stateInt = static_cast<int>(state);
|
||||
list<IdentityAddress> participantsAddresses;
|
||||
|
||||
static const string query = "SELECT sip_address.value"
|
||||
" FROM sip_address, chat_message_participant"
|
||||
" WHERE event_id = :eventId AND state = :state"
|
||||
" AND sip_address.id = chat_message_participant.participant_sip_address_id";
|
||||
soci::rowset<soci::row> rows = (d->dbSession.getBackendSession()->prepare << query, soci::use(eventId), soci::use(stateInt));
|
||||
for (const auto &row : rows) {
|
||||
participantsAddresses.push_back(IdentityAddress(row.get<string>(0)));
|
||||
}
|
||||
|
||||
return participantsAddresses;
|
||||
};
|
||||
}
|
||||
|
||||
ChatMessage::State MainDb::getChatMessageParticipantState (
|
||||
const shared_ptr<EventLog> &eventLog,
|
||||
const IdentityAddress &participantAddress
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ public:
|
|||
std::list<std::shared_ptr<ChatMessage>> getUnreadChatMessages (const ChatRoomId &chatRoomId) const;
|
||||
|
||||
std::list<ChatMessage::State> getChatMessageParticipantStates (const std::shared_ptr<EventLog> &eventLog) const;
|
||||
std::list<IdentityAddress> getChatMessageParticipantsInState (const std::shared_ptr<EventLog> &eventLog, const ChatMessage::State state) const;
|
||||
ChatMessage::State getChatMessageParticipantState (
|
||||
const std::shared_ptr<EventLog> &eventLog,
|
||||
const IdentityAddress &participantAddress
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue