fix(MainDb): fetch correctly chat messages (no contents), no all chat messages for one message!!!

This commit is contained in:
Ronan Abhamon 2017-11-09 15:42:09 +01:00
parent dc00b58e98
commit 9f2db02565
3 changed files with 14 additions and 12 deletions

View file

@ -61,7 +61,7 @@ public:
void setDirection (ChatMessage::Direction dir); void setDirection (ChatMessage::Direction dir);
void setState(ChatMessage::State state); void setState(ChatMessage::State state, bool force = false);
void setTime(time_t time); void setTime(time_t time);
@ -100,16 +100,16 @@ public:
void setAppdata (const std::string &appData); void setAppdata (const std::string &appData);
const std::string &getExternalBodyUrl () const; const std::string &getExternalBodyUrl () const;
bool hasTextContent() const; bool hasTextContent() const;
const Content* getTextContent() const; const Content* getTextContent() const;
bool hasFileTransferContent() const; bool hasFileTransferContent() const;
const Content* getFileTransferContent() const; const Content* getFileTransferContent() const;
LinphoneContent *getFileTransferInformation() const; LinphoneContent *getFileTransferInformation() const;
void setFileTransferInformation(const LinphoneContent *content); void setFileTransferInformation(const LinphoneContent *content);
int downloadFile (); int downloadFile ();
void sendImdn(Imdn::Type imdnType, LinphoneReason reason); void sendImdn(Imdn::Type imdnType, LinphoneReason reason);
@ -148,7 +148,7 @@ private:
std::string cText; std::string cText;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
std::string createImdnXml(Imdn::Type imdnType, LinphoneReason reason); std::string createImdnXml(Imdn::Type imdnType, LinphoneReason reason);
L_DECLARE_PUBLIC(ChatMessage); L_DECLARE_PUBLIC(ChatMessage);

View file

@ -75,9 +75,12 @@ void ChatMessagePrivate::setIsReadOnly (bool readOnly) {
isReadOnly = readOnly; isReadOnly = readOnly;
} }
void ChatMessagePrivate::setState (ChatMessage::State s) { void ChatMessagePrivate::setState (ChatMessage::State s, bool force) {
L_Q(); L_Q();
if (force)
state = s;
if (s == state || !q->getChatRoom()) if (s == state || !q->getChatRoom())
return; return;

View file

@ -300,18 +300,17 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
*session << "SELECT local_sip_address.value, remote_sip_address.value, imdn_message_id, state, direction, is_secured" *session << "SELECT local_sip_address.value, remote_sip_address.value, imdn_message_id, state, direction, is_secured"
" FROM event, conference_chat_message_event, sip_address AS local_sip_address," " FROM event, conference_chat_message_event, sip_address AS local_sip_address,"
" sip_address AS remote_sip_address" " sip_address AS remote_sip_address"
" WHERE event_id = event.id" " WHERE event_id = :eventId"
" AND event_id = event.id"
" AND local_sip_address_id = local_sip_address.id" " AND local_sip_address_id = local_sip_address.id"
" AND remote_sip_address_id = remote_sip_address.id" " AND remote_sip_address_id = remote_sip_address.id", soci::into(localSipAddress), soci::into(remoteSipAddress),
" AND remote_sip_address.value = :peerAddress", soci::into(localSipAddress), soci::into(remoteSipAddress), soci::into(imdnMessageId), soci::into(state), soci::into(direction), soci::into(isSecured), soci::use(eventId);
soci::into(imdnMessageId), soci::into(state), soci::into(direction), soci::into(isSecured),
soci::use(peerAddress);
// TODO: Create me. // TODO: Create me.
// TODO: Use cache, do not fetch the same message twice. // TODO: Use cache, do not fetch the same message twice.
shared_ptr<ChatMessage> chatMessage = make_shared<ChatMessage>(chatRoom); shared_ptr<ChatMessage> chatMessage = make_shared<ChatMessage>(chatRoom);
chatMessage->getPrivate()->setState(static_cast<ChatMessage::State>(state)); chatMessage->getPrivate()->setState(static_cast<ChatMessage::State>(state), true);
chatMessage->getPrivate()->setDirection(static_cast<ChatMessage::Direction>(direction)); chatMessage->getPrivate()->setDirection(static_cast<ChatMessage::Direction>(direction));
chatMessage->setIsSecured(static_cast<bool>(isSecured)); chatMessage->setIsSecured(static_cast<bool>(isSecured));