mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
proper splitting in friends chat,fixes #1375
what happened was- When message exceeded TOX_MESSAGE_LENGTH, the whole message was inserted in sender's chatlog X times. if length of message is N, X = (N/TOX_MESSAGE_LENGTH) + 1 There is no bug in recieving end. Receving end gets X messages (splitted). In the sample case provided, the message had whitespaces in the end, so the reciever thought the message is empty.
This commit is contained in:
parent
f55fd40ec6
commit
b2481fc1d8
|
@ -123,6 +123,10 @@ void ChatForm::onSendTriggered()
|
||||||
QList<CString> splittedMsg = Core::splitMessage(msg, TOX_MAX_MESSAGE_LENGTH);
|
QList<CString> splittedMsg = Core::splitMessage(msg, TOX_MAX_MESSAGE_LENGTH);
|
||||||
QDateTime timestamp = QDateTime::currentDateTime();
|
QDateTime timestamp = QDateTime::currentDateTime();
|
||||||
|
|
||||||
|
msgEdit->setLastMessage(msg); //set last message only when sending it
|
||||||
|
|
||||||
|
bool status = !Settings::getInstance().getFauxOfflineMessaging();
|
||||||
|
|
||||||
for (CString& c_msg : splittedMsg)
|
for (CString& c_msg : splittedMsg)
|
||||||
{
|
{
|
||||||
QString qt_msg = CString::toString(c_msg.data(), c_msg.size());
|
QString qt_msg = CString::toString(c_msg.data(), c_msg.size());
|
||||||
|
@ -130,12 +134,10 @@ void ChatForm::onSendTriggered()
|
||||||
if (isAction)
|
if (isAction)
|
||||||
qt_msg_hist = "/me " + qt_msg;
|
qt_msg_hist = "/me " + qt_msg;
|
||||||
|
|
||||||
bool status = !Settings::getInstance().getFauxOfflineMessaging();
|
|
||||||
|
|
||||||
int id = HistoryKeeper::getInstance()->addChatEntry(f->getToxID().publicKey, qt_msg_hist,
|
int id = HistoryKeeper::getInstance()->addChatEntry(f->getToxID().publicKey, qt_msg_hist,
|
||||||
Core::getInstance()->getSelfId().publicKey, timestamp, status);
|
Core::getInstance()->getSelfId().publicKey, timestamp, status);
|
||||||
|
|
||||||
ChatMessage::Ptr ma = addSelfMessage(msg, isAction, timestamp, false);
|
ChatMessage::Ptr ma = addSelfMessage(qt_msg, isAction, timestamp, false);
|
||||||
|
|
||||||
int rec;
|
int rec;
|
||||||
if (isAction)
|
if (isAction)
|
||||||
|
@ -144,8 +146,6 @@ void ChatForm::onSendTriggered()
|
||||||
rec = Core::getInstance()->sendMessage(f->getFriendID(), qt_msg);
|
rec = Core::getInstance()->sendMessage(f->getFriendID(), qt_msg);
|
||||||
|
|
||||||
getOfflineMsgEngine()->registerReceipt(rec, id, ma);
|
getOfflineMsgEngine()->registerReceipt(rec, id, ma);
|
||||||
|
|
||||||
msgEdit->setLastMessage(msg); //set last message only when sending it
|
|
||||||
}
|
}
|
||||||
|
|
||||||
msgEdit->clear();
|
msgEdit->clear();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user