From 451d0c7999a7741674047d1ecd3fb58a3ab0b714 Mon Sep 17 00:00:00 2001 From: apprb Date: Wed, 19 Nov 2014 22:46:50 +0900 Subject: [PATCH] check incoming data from DB --- src/historykeeper.cpp | 10 +++++----- src/widget/form/chatform.cpp | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/historykeeper.cpp b/src/historykeeper.cpp index 37ba7cb9d..309c760d9 100644 --- a/src/historykeeper.cpp +++ b/src/historykeeper.cpp @@ -122,7 +122,7 @@ HistoryKeeper::HistoryKeeper(GenericDdInterface *db_) : if (idCur != idMax) { - QString cmd = QString("INSERT INTO sent_status (id, status) VALUES (%1, 1)").arg(idMax); + QString cmd = QString("INSERT INTO sent_status (id, status) VALUES (%1, 1);").arg(idMax); db->exec(cmd); } } @@ -147,12 +147,12 @@ int HistoryKeeper::addChatEntry(const QString& chat, const QString& message, con int chat_id = getChatID(chat, ctSingle).first; int sender_id = getAliasID(sender); - db->exec("BEGIN TRANSACTION"); - db->exec(QString("INSERT INTO history (timestamp, chat_id, sender, message)") + + db->exec("BEGIN TRANSACTION;"); + db->exec(QString("INSERT INTO history (timestamp, chat_id, sender, message) ") + QString("VALUES (%1, %2, %3, '%4');") .arg(dt.toMSecsSinceEpoch()).arg(chat_id).arg(sender_id).arg(wrapMessage(message))); - db->exec(QString("INSERT INTO sent_status (status) VALUES (%1)").arg(isSent)); - db->exec("COMMIT TRANSACTION"); + db->exec(QString("INSERT INTO sent_status (status) VALUES (%1);").arg(isSent)); + db->exec("COMMIT TRANSACTION;"); messageID++; return messageID; diff --git a/src/widget/form/chatform.cpp b/src/widget/form/chatform.cpp index 44017003a..511034c2f 100644 --- a/src/widget/form/chatform.cpp +++ b/src/widget/form/chatform.cpp @@ -743,8 +743,9 @@ void ChatForm::loadHistory(QDateTime since, bool processUndelivered) } // Show each messages - MessageActionPtr ca = genMessageActionAction(ToxID::fromString(it.sender), it.message, false, msgDateTime); - if (it.isSent) + ToxID msgSender = ToxID::fromString(it.sender); + MessageActionPtr ca = genMessageActionAction(msgSender, it.message, false, msgDateTime); + if (it.isSent || !msgSender.isMine()) { ca->markAsSent(); } else {