diff --git a/generic/conferenceloggerplugin/changelog.txt b/generic/conferenceloggerplugin/changelog.txt index cc950070..35e39bf2 100644 --- a/generic/conferenceloggerplugin/changelog.txt +++ b/generic/conferenceloggerplugin/changelog.txt @@ -1,3 +1,7 @@ +2021-08-14 +v0.2.4 - kssytsrk + * Prevent from logging OMEMO-encrypted messages + 2018-11-09 v0.2.3 - tehnick * Add ".conferencehistory" extension to log files diff --git a/generic/conferenceloggerplugin/conferenceloggerplugin.cpp b/generic/conferenceloggerplugin/conferenceloggerplugin.cpp index 695c0fb2..dffed52a 100644 --- a/generic/conferenceloggerplugin/conferenceloggerplugin.cpp +++ b/generic/conferenceloggerplugin/conferenceloggerplugin.cpp @@ -186,7 +186,7 @@ bool ConferenceLogger::incomingStanza(int account, const QDomElement &stanza) { if (enabled) { if (stanza.tagName() == "message") { - if (stanza.attribute("type") == "groupchat") { + if (stanza.attribute("type") == "groupchat" && stanza.firstChildElement("encrypted").isNull()) { QString from = stanza.attribute("from"); QStringList List = from.split("/"); QString room = List.takeFirst(); diff --git a/generic/conferenceloggerplugin/psiplugin.json b/generic/conferenceloggerplugin/psiplugin.json index 3364a819..d4adf273 100644 --- a/generic/conferenceloggerplugin/psiplugin.json +++ b/generic/conferenceloggerplugin/psiplugin.json @@ -2,7 +2,7 @@ "name": "Conference Logger", "name:ru": "История Конференций", "shortname": "logger", - "version": "0.2.3", + "version": "0.2.4", "priority": 2, "icon": "base64:iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAvdQTFRF////X2BgZGVlU1VWcGhej3ZboHlSdWVXZ2dnVltfZmFdjnhitY5myplnsYhknH1gfWtaX1xYX2BhZ2JcjndftI5o0qN21aqA36Zy05deroZfjntohXZmW1ZQZGBcinVfw5Zj3Khx16d50qB0z6B01Kd62Kt70aFt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c3Lz8gsKfRmKiktKy8orKquqa2rr6hsam5pbfBla29o7Oru6e3r7+idMnDR5ytRp030ZZsycNXvO3HnzFyxctHjJ0mXLV6xc5cuwes3ades3bNy0ecvWbdt37Ny1ew/QQXv37T9w8NDhI0ePHT9x8tTpM2fBTj93/sLFS5evXL12/cbNW7d9oZ68c/fe/QcPHz1+8vTZ8xeI8Hj56vWbt3bv3n/4iBJ0nz5/+fpt5Xf0UP7x89dvjKBn8PWFWcIAAPcuf0zWlg+4AAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDEzLTA0LTEyVDAzOjMzOjUxKzA2OjAwroz6jQAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxMy0wNC0xMlQwMzozMzo1MSswNjowMN/RQjEAAAAASUVORK5CYII=", "description": "Record conversation logs of currently joined conferences and read them later with just a single toolbar click.", diff --git a/generic/omemoplugin/changelog.txt b/generic/omemoplugin/changelog.txt index b56a15ca..b6bfb081 100644 --- a/generic/omemoplugin/changelog.txt +++ b/generic/omemoplugin/changelog.txt @@ -1,3 +1,7 @@ +2021-08-14 +v2.9 kssytsrk + * Add OMEMO-encrypted MUC logging functionality + 2021-02-20 v2.8 stigger * Fix sending incorrect PEP requests from somebody else's JID when diff --git a/generic/omemoplugin/src/omemoplugin.cpp b/generic/omemoplugin/src/omemoplugin.cpp index 91e29327..573314cd 100644 --- a/generic/omemoplugin/src/omemoplugin.cpp +++ b/generic/omemoplugin/src/omemoplugin.cpp @@ -235,6 +235,23 @@ bool OMEMOPlugin::decryptMessageElement(int account, QDomElement &message) processEncryptedFile(account, message); } + // logging functionality for OMEMO-encrypted groupchats + if (message.attribute("type") == QLatin1String("groupchat")) { + QString from = message.attribute("from"); + QString room = from.section('/', 0, 0); + QString nickname = from.section('/', 1); + if (nickname != m_mucNicks.value(room)) { + QString Stamp = message.firstChildElement("x").attribute("stamp"); + QDomElement body = message.firstChildElement("body"); + if (!body.isNull()) { + QString Text = body.text(); + QString MyJid = m_accountInfo->getJid(account); + MyJid = MyJid.replace("@", "_at_"); + logMuc(room, nickname, MyJid, Text, Stamp); + } + } + } + return true; } @@ -313,8 +330,19 @@ bool OMEMOPlugin::outgoingStanza(int account, QDomElement &xml) return false; } - if (xml.nodeName() == "presence" && !xml.hasAttributes()) { - m_omemo->accountConnected(account, m_accountInfo->getJid(account)); + if (xml.nodeName() == QLatin1String("presence")) { + if (!xml.hasAttributes()) + m_omemo->accountConnected(account, m_accountInfo->getJid(account)); + // get all MUC nicks of the current account for groupchat logging + // functionality + else { + QString room = xml.attribute("to").section('/', 0, 0); + QString nick = xml.attribute("to").section('/', 1); + if (m_contactInfo->isConference(account, room)) { + m_mucNicks.insert(room, nick); + } + } + } return false; @@ -330,6 +358,24 @@ bool OMEMOPlugin::encryptMessageElement(int account, QDomElement &message) return false; } + // logging functionality for OMEMO-encrypted groupchats + if (message.attribute("type") == QLatin1String("groupchat")) { + QString room = message.attribute("to"); + QString from = m_mucNicks.value(room, m_accountInfo->getJid(account)); + if (from==QLatin1String("")) + from = m_accountInfo->getJid(account); + if (m_omemo->isEnabledForUser(account, room)) { // only log if encryption is enabled + QString Stamp = message.firstChildElement("x").attribute("stamp"); + QDomElement body = message.firstChildElement("body"); + if (!body.isNull()) { + QString Text = body.text(); + QString MyJid = m_accountInfo->getJid(account); + MyJid = MyJid.replace("@", "_at_"); + logMuc(room, from, MyJid, Text, Stamp); + } + } + } + return m_omemo->encryptMessage(m_accountInfo->getJid(account), account, message); } @@ -544,4 +590,30 @@ bool OMEMOPlugin::execute(int account, const QHash &args, QHa return false; } + +// the code partly taken from the Conference Logger plugin +void OMEMOPlugin::logMuc(QString room, const QString &from, const QString &myJid, + const QString &text, QString stamp) +{ + room = room.replace("@", "_at_"); + room = "_in_" + room; + if (stamp.isEmpty()) { + stamp = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"); + } else { + stamp.insert(4, "-"); + stamp.insert(7, "-"); + stamp.replace("T", " "); + } + QFile file(m_applicationInfo->appHistoryDir() + QDir::separator() + myJid + room + ".conferencehistory"); + if (file.open(QIODevice::WriteOnly | QIODevice::Append)) { + QTextStream out(&file); + out.setCodec("UTF-8"); + out.setGenerateByteOrderMark(false); +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) + out << stamp << " " << from << ": " << text << Qt::endl; +#else + out << stamp << " " << from << ": " << text << endl; +#endif + } +} } diff --git a/generic/omemoplugin/src/omemoplugin.h b/generic/omemoplugin/src/omemoplugin.h index fd89eb6f..b6433b86 100644 --- a/generic/omemoplugin/src/omemoplugin.h +++ b/generic/omemoplugin/src/omemoplugin.h @@ -133,6 +133,7 @@ private slots: void updateAction(int account, const QString &user); void processEncryptedFile(int account, QDomElement &xml); void showOwnFingerprint(int account, const QString &jid); + void logMuc(QString room, const QString &from, const QString &myJid, const QString &text, QString stamp); private: bool m_enabled = false; @@ -147,6 +148,7 @@ private slots: EventCreatingHost * m_eventCreator = nullptr; PsiAccountControllingHost * m_accountController = nullptr; OptionAccessingHost * m_optionHost = nullptr; + QMap m_mucNicks; }; } #endif // PSIOMEMO_OMEMOPLUGIN_H diff --git a/generic/omemoplugin/src/psiplugin.json b/generic/omemoplugin/src/psiplugin.json index b4a0b474..3562093d 100644 --- a/generic/omemoplugin/src/psiplugin.json +++ b/generic/omemoplugin/src/psiplugin.json @@ -1,7 +1,7 @@ { "name": "OMEMO", "shortname": "omemo", - "version": "2.8", + "version": "2.9", "priority": 2, "icon": "base64:iVBORw0KGgoAAAANSUhEUgAAABAAAAAKCAYAAAC9vt6cAAAEGWlDQ1BrQ0dDb2xvclNwYWNlR2Vu ZXJpY1JHQgAAOI2NVV1oHFUUPrtzZyMkzlNsNIV0qD8NJQ2TVjShtLp/3d02bpZJNtoi6GT27s6Y yc44M7v9oU9FUHwx6psUxL+3gCAo9Q/bPrQvlQol2tQgKD60+INQ6Ium65k7M5lpurHeZe58853v nnvuuWfvBei5qliWkRQBFpquLRcy4nOHj4g9K5CEh6AXBqFXUR0rXalMAjZPC3e1W99Dwntf2d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hNqy28EdkUh8C+DU9+z2v/oyeH791OncxHOs5y2AtTc7nb/f73TWPkD/qwBn jX8BoJ98VQNcC+8AAAIRSURBVCgVY2BAAzFqDAuDlBh2A4U5gZgRiM2AOAmIDYAYA4AUwAD7plKf dWLvLriwMjEwnOCzv/j+ysE31kLf1f6rWLPeO3fsS/P+N30PvzHMhWkA0cxQDvPCypjrklrm5nxS SszSTw8wc+l5SktIy6r++v2bQzmhW0jTwkXo3YnV7068+LcJqIcdiDmA+A/YBesqAqOVH25ZzMLE xHhf3ptBWoCDgVnFmuH5d2YGlZ25DHf/CP39Ja71Zcf1N4uUnWOeM+/tq3v/+Qv7ORGXjYwdVizX jFSkWPVYX6qwAd3z/A83A5NbOcPbywcYeF5fYVh39S1D2tyjDE86PBi4czYwnFvQyOD/+wDQcgaG 7FNcf5m+/2H4K/DzheLpbyIMTIyMDH/ZuBl+f//CoP76AAPH3y8MJsIMDN/fv2Zg//EOTP8HhytY PwMbM8t/Zi2hfx/VhVj//WXhVhNi/s780jyXgevOXgaWz08YDulWMqi/3MPw/ugqBlbGvwwrd59c yajvu+z65cvWp98wMD6ScJwOj4XWdD9XS+730xk/PlcQY/vz96Wg9tMD32U3yFyca24swiBw6d3/ r5n7/mz88Y+hFWg/KBCBccXwE+IWKLnSg8HrcBDzy8NBrJeTZRiEoMK8QNoFiC2AGG4hVI6BBcYA 0Z++M3y+8eZv1otvf0X/8DA4AoXWAvFnIN4DxFgBAEivuvd3beA8AAAAAElFTkSuQmCC", "description": "OMEMO is an end-to-end encryption protocol that leverages the Double Ratchet encryption scheme to provide multi-end to multi-end encryption, allowing messages to be synchronized securely across multiple clients, even if some of them are offline.",