bool GenericChatDialog::isEmoteMessage(const XMPP::Message& m) { if (m.body().startsWith(me_cmd) || m.html().text().trimmed().startsWith(me_cmd)) { return true; } return false; }
QString ChatDlg::messageText(const XMPP::Message& m) { bool emote = isEmoteMessage(m); QString txt; if (m.containsHTML() && PsiOptions::instance()->getOption("options.html.chat.render").toBool() && !m.html().text().isEmpty()) { txt = m.html().toString("span"); if (emote) { int cmd = txt.indexOf(me_cmd); txt = txt.remove(cmd, me_cmd.length()); } // qWarning("html body:\n%s\n",qPrintable(txt)); } else { txt = m.body(); if (emote) txt = txt.mid(me_cmd.length()); txt = TextUtil::plain2rich(txt); txt = TextUtil::linkify(txt); // qWarning("regular body:\n%s\n",qPrintable(txt)); } if (PsiOptions::instance()->getOption("options.ui.emoticons.use-emoticons").toBool()) txt = TextUtil::emoticonify(txt); if (PsiOptions::instance()->getOption("options.ui.chat.legacy-formatting").toBool()) txt = TextUtil::legacyFormat(txt); return txt; }
bool ChatDlg::isEmoteMessage(const XMPP::Message& m) { if (m.body().startsWith(me_cmd) || m.html().text().trimmed().startsWith(me_cmd)) return true; return false; }
QString GenericChatDialog::messageText(const XMPP::Message& m) { bool emote = isEmoteMessage(m), illformed; QString txt; //reset textFormatter textFormatter()->setRemoveEmoteString(false); textFormatter()->setTextNodeNumber(0); if (m.containsHTML() && PsiOptions::instance()->getOption("options.html.chat.render").toBool()) { if (emote) { textFormatter()->setRemoveEmoteString(true); } txt = m.html().toString("span"); } else { if (emote) { txt = "<span>" + m.body().mid(me_cmd.length()) + "</span>"; } else { txt = TextUtil::plain2rich(m.body()); } } textFormatter()->setDoEmoticonify(PsiOptions::instance()->getOption("options.ui.emoticons.use-emoticons").toBool()); textFormatter()->setDoLegacyFormatting(PsiOptions::instance()->getOption("options.ui.chat.legacy-formatting").toBool()); txt = messageValidator_.validateMessage(txt, &illformed, textFormatter()); if (illformed) { //html content was illformed, plain version is displayed textFormatter()->setTextNodeNumber(0); txt = messageValidator_.validateMessage(TextUtil::plain2rich(m.body()), &illformed, textFormatter()); } //qDebug() << "messageText 2" << txt; return txt; }