diff options
Diffstat (limited to 'pica-client/chatwindow.cpp')
| -rw-r--r-- | pica-client/chatwindow.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/pica-client/chatwindow.cpp b/pica-client/chatwindow.cpp index a135c19..61a1252 100644 --- a/pica-client/chatwindow.cpp +++ b/pica-client/chatwindow.cpp @@ -87,6 +87,9 @@ ChatWindow::ChatWindow(QByteArray peer_id, QString status) : QHBoxLayout *hl = new QHBoxLayout(); lbAddCtQuestion = new QLabel(tr("Do you want to add \"%1\" to your contact list?").arg(peer_name_)); + // peer_name_ comes from the peer's certificate; keep it literal so it + // cannot be interpreted as rich text. + lbAddCtQuestion->setTextFormat(Qt::PlainText); btAddCtYes = new QPushButton(tr("Yes")); btAddCtNo = new QPushButton(tr("No")); btAddCtBlacklist = new QPushButton(tr("Add to blacklist")); @@ -189,8 +192,8 @@ int ChatWindow::draw_message(QString msg, QString nickname, QString datetime, QS QString("<b><font color=%1>%2(%3) %4 : </font></b>"). arg(color). arg(delivered_mark). - arg(datetime). - arg(nickname) + arg(datetime.toHtmlEscaped()). + arg(nickname.toHtmlEscaped()) ); chatw->setCurrentCharFormat(fmt); chatw->insertPlainText(msg + '\n'); @@ -225,7 +228,7 @@ void ChatWindow::print_history(QList<History::HistoryRecord> H) name = r.peer_id.toBase64(); } - dt.setTime_t(r.timestamp); + dt.setSecsSinceEpoch(r.timestamp); //put_message(r.message, r.peer_id, r.is_me); draw_message(r.message, name, dt.toString("yyyy-MM-dd hh:mm:ss"), color, r.is_delivered); } @@ -244,15 +247,17 @@ void ChatWindow::msg_delivered() { if (undelivered_msgs.isEmpty()) { - // undelivered_msgs can be empty if new chatwindow instance was created - // and undelivered message from previous chat session is delivered + // undelivered_msgs can be empty if a new chatwindow instance was created + // and an undelivered message from a previous chat session is delivered // after that. QByteArray my_id = Accounts::GetCurrentAccount().id; QMap<QByteArray, QList<QString> > undl = hist.GetUndeliveredMessages(); - if (!undl[my_id].isEmpty()) - put_message(undl[my_id].first(), my_id, true); + // GetUndeliveredMessages() is keyed by the peer's contact_id, not by + // our own id, so this must look up peer_id_ to find anything. + if (!undl[peer_id_].isEmpty()) + put_message(undl[peer_id_].first(), my_id, true); } if (!undelivered_msgs.isEmpty()) @@ -347,19 +352,19 @@ void TextSend::keyPressEvent(QKeyEvent *e) void ChatWindow::show_history24h() { - print_history(hist.GetMessages(peer_id_, QDateTime::currentDateTime().addDays(-1).toTime_t(), - QDateTime::currentDateTime().toTime_t())); + print_history(hist.GetMessages(peer_id_, QDateTime::currentDateTime().addDays(-1).toSecsSinceEpoch(), + QDateTime::currentDateTime().toSecsSinceEpoch())); } void ChatWindow::show_history1w() { - print_history(hist.GetMessages(peer_id_, QDateTime::currentDateTime().addDays(-7).toTime_t(), - QDateTime::currentDateTime().toTime_t())); + print_history(hist.GetMessages(peer_id_, QDateTime::currentDateTime().addDays(-7).toSecsSinceEpoch(), + QDateTime::currentDateTime().toSecsSinceEpoch())); } void ChatWindow::show_historyAll() { - print_history(hist.GetMessages(peer_id_, 0, QDateTime::currentDateTime().toTime_t())); + print_history(hist.GetMessages(peer_id_, 0, QDateTime::currentDateTime().toSecsSinceEpoch())); } void ChatWindow::show_historySearch() |
