From 70a4e1e265e896269670b2a62f99c6413b38923f Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Tue, 19 Jan 2021 18:30:04 -0500 Subject: [PATCH 01/86] Keep DBUS from blocking --- src/notifications/ManagerLinux.cpp | 88 ++++++++++++++++-------------- 1 file changed, 48 insertions(+), 40 deletions(-) diff --git a/src/notifications/ManagerLinux.cpp b/src/notifications/ManagerLinux.cpp index b5e9a6a4..ed5b60a2 100644 --- a/src/notifications/ManagerLinux.cpp +++ b/src/notifications/ManagerLinux.cpp @@ -2,9 +2,11 @@ #include #include -#include -#include -#include +#include +#include +#include +#include +#include NotificationsManager::NotificationsManager(QObject *parent) : QObject(parent) @@ -36,6 +38,12 @@ NotificationsManager::NotificationsManager(QObject *parent) SLOT(notificationReplied(uint, QString))); } +/** + * This function is based on code from + * https://github.com/rohieb/StratumsphereTrayIcon + * Copyright (C) 2012 Roland Hieber + * Licensed under the GNU General Public License, version 3 + */ void NotificationsManager::postNotification(const QString &roomid, const QString &eventid, @@ -44,50 +52,50 @@ NotificationsManager::postNotification(const QString &roomid, const QString &text, const QImage &icon) { - uint id = showNotification(roomname, sender + ": " + text, icon); - notificationIds[id] = roomEventId{roomid, eventid}; + Q_UNUSED(icon) + + QVariantMap hints; + hints["image-data"] = sender + ": " + text; + hints["sound-name"] = "message-new-instant"; + QList argumentList; + argumentList << "nheko"; // app_name + argumentList << (uint)0; // replace_id + argumentList << ""; // app_icon + argumentList << roomname; // summary + argumentList << text; // body + // The list of actions has always the action name and then a localized version of that + // action. Currently we just use an empty string for that. + // TODO(Nico): Look into what to actually put there. + argumentList << (QStringList("default") << "" + << "inline-reply" + << ""); // actions + argumentList << hints; // hints + argumentList << (int)-1; // timeout in ms + + static QDBusInterface notifyApp("org.freedesktop.Notifications", + "/org/freedesktop/Notifications", + "org.freedesktop.Notifications"); + auto call = + notifyApp.callWithArgumentList(QDBus::AutoDetect, "Notify", argumentList); + QDBusPendingCallWatcher watcher{QDBusPendingReply{call}}; + connect(&watcher, &QDBusPendingCallWatcher::finished, this, [&watcher, this, &roomid, &eventid]() { + if (watcher.reply().type() == QDBusMessage::ErrorMessage) + qDebug() << "D-Bus Error:" << watcher.reply().errorMessage(); + else + notificationIds[watcher.reply().arguments().first().toUInt()] = roomEventId{roomid, eventid}; + }); } -/** - * This function is based on code from - * https://github.com/rohieb/StratumsphereTrayIcon - * Copyright (C) 2012 Roland Hieber - * Licensed under the GNU General Public License, version 3 - */ + uint NotificationsManager::showNotification(const QString summary, const QString text, const QImage image) { - QVariantMap hints; - hints["image-data"] = image; - hints["sound-name"] = "message-new-instant"; - QList argumentList; - argumentList << "nheko"; // app_name - argumentList << (uint)0; // replace_id - argumentList << ""; // app_icon - argumentList << summary; // summary - argumentList << text; // body - // The list of actions has always the action name and then a localized version of that - // action. Currently we just use an empty string for that. - // TODO(Nico): Look into what to actually put there. - argumentList << (QStringList("default") << "" - << "inline-reply" - << ""); // actions - argumentList << hints; // hints - argumentList << (int)-1; // timeout in ms + Q_UNUSED(summary) + Q_UNUSED(text) + Q_UNUSED(image) - static QDBusInterface notifyApp("org.freedesktop.Notifications", - "/org/freedesktop/Notifications", - "org.freedesktop.Notifications"); - QDBusMessage reply = - notifyApp.callWithArgumentList(QDBus::AutoDetect, "Notify", argumentList); - if (reply.type() == QDBusMessage::ErrorMessage) { - qDebug() << "D-Bus Error:" << reply.errorMessage(); - return 0; - } else { - return reply.arguments().first().toUInt(); - } - return true; + return 0; } void From e2d89e093adcd8107f3e0ec891f28a25e400883f Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Tue, 19 Jan 2021 18:46:25 -0500 Subject: [PATCH 02/86] Use async call --- src/notifications/ManagerLinux.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notifications/ManagerLinux.cpp b/src/notifications/ManagerLinux.cpp index ed5b60a2..451e23b2 100644 --- a/src/notifications/ManagerLinux.cpp +++ b/src/notifications/ManagerLinux.cpp @@ -76,7 +76,7 @@ NotificationsManager::postNotification(const QString &roomid, "/org/freedesktop/Notifications", "org.freedesktop.Notifications"); auto call = - notifyApp.callWithArgumentList(QDBus::AutoDetect, "Notify", argumentList); + notifyApp.asyncCallWithArgumentList("Notify", argumentList); QDBusPendingCallWatcher watcher{QDBusPendingReply{call}}; connect(&watcher, &QDBusPendingCallWatcher::finished, this, [&watcher, this, &roomid, &eventid]() { if (watcher.reply().type() == QDBusMessage::ErrorMessage) From b04a7fbef6a6e8a8e2d588ac6770464e5d964f42 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Tue, 19 Jan 2021 18:47:18 -0500 Subject: [PATCH 03/86] Remove showNotification function --- src/notifications/Manager.h | 1 - src/notifications/ManagerLinux.cpp | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/src/notifications/Manager.h b/src/notifications/Manager.h index b5347bd6..4c9852cc 100644 --- a/src/notifications/Manager.h +++ b/src/notifications/Manager.h @@ -47,7 +47,6 @@ public: private: QDBusInterface dbus; - uint showNotification(const QString summary, const QString text, const QImage image); void closeNotification(uint id); // notification ID to (room ID, event ID) diff --git a/src/notifications/ManagerLinux.cpp b/src/notifications/ManagerLinux.cpp index 451e23b2..a52a43e9 100644 --- a/src/notifications/ManagerLinux.cpp +++ b/src/notifications/ManagerLinux.cpp @@ -86,18 +86,6 @@ NotificationsManager::postNotification(const QString &roomid, }); } -uint -NotificationsManager::showNotification(const QString summary, - const QString text, - const QImage image) -{ - Q_UNUSED(summary) - Q_UNUSED(text) - Q_UNUSED(image) - - return 0; -} - void NotificationsManager::closeNotification(uint id) { From 7727c0d2491e1fa6463720302e56b504e7e3d265 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Tue, 19 Jan 2021 18:47:44 -0500 Subject: [PATCH 04/86] make lint --- src/notifications/ManagerLinux.cpp | 67 ++++++++++++++++-------------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/src/notifications/ManagerLinux.cpp b/src/notifications/ManagerLinux.cpp index a52a43e9..b86c5223 100644 --- a/src/notifications/ManagerLinux.cpp +++ b/src/notifications/ManagerLinux.cpp @@ -1,12 +1,12 @@ #include "notifications/Manager.h" -#include -#include #include #include #include #include #include +#include +#include NotificationsManager::NotificationsManager(QObject *parent) : QObject(parent) @@ -52,38 +52,41 @@ NotificationsManager::postNotification(const QString &roomid, const QString &text, const QImage &icon) { - Q_UNUSED(icon) + Q_UNUSED(icon) - QVariantMap hints; - hints["image-data"] = sender + ": " + text; - hints["sound-name"] = "message-new-instant"; - QList argumentList; - argumentList << "nheko"; // app_name - argumentList << (uint)0; // replace_id - argumentList << ""; // app_icon - argumentList << roomname; // summary - argumentList << text; // body - // The list of actions has always the action name and then a localized version of that - // action. Currently we just use an empty string for that. - // TODO(Nico): Look into what to actually put there. - argumentList << (QStringList("default") << "" - << "inline-reply" - << ""); // actions - argumentList << hints; // hints - argumentList << (int)-1; // timeout in ms + QVariantMap hints; + hints["image-data"] = sender + ": " + text; + hints["sound-name"] = "message-new-instant"; + QList argumentList; + argumentList << "nheko"; // app_name + argumentList << (uint)0; // replace_id + argumentList << ""; // app_icon + argumentList << roomname; // summary + argumentList << text; // body + // The list of actions has always the action name and then a localized version of that + // action. Currently we just use an empty string for that. + // TODO(Nico): Look into what to actually put there. + argumentList << (QStringList("default") << "" + << "inline-reply" + << ""); // actions + argumentList << hints; // hints + argumentList << (int)-1; // timeout in ms - static QDBusInterface notifyApp("org.freedesktop.Notifications", - "/org/freedesktop/Notifications", - "org.freedesktop.Notifications"); - auto call = - notifyApp.asyncCallWithArgumentList("Notify", argumentList); - QDBusPendingCallWatcher watcher{QDBusPendingReply{call}}; - connect(&watcher, &QDBusPendingCallWatcher::finished, this, [&watcher, this, &roomid, &eventid]() { - if (watcher.reply().type() == QDBusMessage::ErrorMessage) - qDebug() << "D-Bus Error:" << watcher.reply().errorMessage(); - else - notificationIds[watcher.reply().arguments().first().toUInt()] = roomEventId{roomid, eventid}; - }); + static QDBusInterface notifyApp("org.freedesktop.Notifications", + "/org/freedesktop/Notifications", + "org.freedesktop.Notifications"); + auto call = notifyApp.asyncCallWithArgumentList("Notify", argumentList); + QDBusPendingCallWatcher watcher{QDBusPendingReply{call}}; + connect(&watcher, + &QDBusPendingCallWatcher::finished, + this, + [&watcher, this, &roomid, &eventid]() { + if (watcher.reply().type() == QDBusMessage::ErrorMessage) + qDebug() << "D-Bus Error:" << watcher.reply().errorMessage(); + else + notificationIds[watcher.reply().arguments().first().toUInt()] = + roomEventId{roomid, eventid}; + }); } void From ac36e924472582edbf99eeff879c638c708c5a41 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Wed, 20 Jan 2021 16:04:02 -0500 Subject: [PATCH 05/86] Make watcher a pointer so that it doesn't get destroyed too soon --- src/notifications/ManagerLinux.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/notifications/ManagerLinux.cpp b/src/notifications/ManagerLinux.cpp index b86c5223..ad9e2c21 100644 --- a/src/notifications/ManagerLinux.cpp +++ b/src/notifications/ManagerLinux.cpp @@ -76,16 +76,17 @@ NotificationsManager::postNotification(const QString &roomid, "/org/freedesktop/Notifications", "org.freedesktop.Notifications"); auto call = notifyApp.asyncCallWithArgumentList("Notify", argumentList); - QDBusPendingCallWatcher watcher{QDBusPendingReply{call}}; - connect(&watcher, + auto watcher = new QDBusPendingCall{QDBusPendingReply{call}}; + connect(watcher, &QDBusPendingCallWatcher::finished, this, - [&watcher, this, &roomid, &eventid]() { - if (watcher.reply().type() == QDBusMessage::ErrorMessage) + [watcher, this, &roomid, &eventid]() { + if (watcher->reply().type() == QDBusMessage::ErrorMessage) qDebug() << "D-Bus Error:" << watcher.reply().errorMessage(); else - notificationIds[watcher.reply().arguments().first().toUInt()] = + notificationIds[watcher->reply().arguments().first().toUInt()] = roomEventId{roomid, eventid}; + delete watcher; }); } From 1479743e702f2bfba4524ab4dae8cf1134547920 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Wed, 20 Jan 2021 16:09:25 -0500 Subject: [PATCH 06/86] Use async call in closeNotification --- src/notifications/ManagerLinux.cpp | 36 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/notifications/ManagerLinux.cpp b/src/notifications/ManagerLinux.cpp index ad9e2c21..d9d157fc 100644 --- a/src/notifications/ManagerLinux.cpp +++ b/src/notifications/ManagerLinux.cpp @@ -75,19 +75,17 @@ NotificationsManager::postNotification(const QString &roomid, static QDBusInterface notifyApp("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications"); - auto call = notifyApp.asyncCallWithArgumentList("Notify", argumentList); - auto watcher = new QDBusPendingCall{QDBusPendingReply{call}}; - connect(watcher, - &QDBusPendingCallWatcher::finished, - this, - [watcher, this, &roomid, &eventid]() { - if (watcher->reply().type() == QDBusMessage::ErrorMessage) - qDebug() << "D-Bus Error:" << watcher.reply().errorMessage(); - else - notificationIds[watcher->reply().arguments().first().toUInt()] = - roomEventId{roomid, eventid}; - delete watcher; - }); + auto call = notifyApp.asyncCallWithArgumentList("Notify", argumentList); + auto watcher = new QDBusPendingCallWatcher{QDBusPendingCall{QDBusPendingReply{call}}}; + connect( + watcher, &QDBusPendingCallWatcher::finished, this, [watcher, this, &roomid, &eventid]() { + if (watcher->reply().type() == QDBusMessage::ErrorMessage) + qDebug() << "D-Bus Error:" << watcher->reply().errorMessage(); + else + notificationIds[watcher->reply().arguments().first().toUInt()] = + roomEventId{roomid, eventid}; + delete watcher; + }); } void @@ -99,11 +97,13 @@ NotificationsManager::closeNotification(uint id) static QDBusInterface closeCall("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications"); - QDBusMessage reply = - closeCall.callWithArgumentList(QDBus::AutoDetect, "CloseNotification", argumentList); - if (reply.type() == QDBusMessage::ErrorMessage) { - qDebug() << "D-Bus Error:" << reply.errorMessage(); - } + auto call = closeCall.asyncCallWithArgumentList("CloseNotification", argumentList); + auto watcher = new QDBusPendingCallWatcher{QDBusPendingCall{QDBusPendingReply{call}}}; + connect(watcher, &QDBusPendingCallWatcher::finished, this, [watcher, this]() { + if (watcher->reply().type() == QDBusMessage::ErrorMessage) { + qDebug() << "D-Bus Error:" << watcher->reply().errorMessage(); + }; + }); } void From cf4f50dac854fd951066f56945f5d1adbbe679d4 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Wed, 20 Jan 2021 16:13:21 -0500 Subject: [PATCH 07/86] Use deleteLater() instead of delete --- src/notifications/ManagerLinux.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/notifications/ManagerLinux.cpp b/src/notifications/ManagerLinux.cpp index d9d157fc..36692d03 100644 --- a/src/notifications/ManagerLinux.cpp +++ b/src/notifications/ManagerLinux.cpp @@ -84,7 +84,7 @@ NotificationsManager::postNotification(const QString &roomid, else notificationIds[watcher->reply().arguments().first().toUInt()] = roomEventId{roomid, eventid}; - delete watcher; + watcher->deleteLater(); }); } @@ -103,6 +103,7 @@ NotificationsManager::closeNotification(uint id) if (watcher->reply().type() == QDBusMessage::ErrorMessage) { qDebug() << "D-Bus Error:" << watcher->reply().errorMessage(); }; + watcher->deleteLater(); }); } From 9c154e974747b699c62079c6d4edd2f81d7951ef Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Wed, 20 Jan 2021 16:15:14 -0500 Subject: [PATCH 08/86] Fix error in assignment of image/text --- src/notifications/ManagerLinux.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/notifications/ManagerLinux.cpp b/src/notifications/ManagerLinux.cpp index 36692d03..2c15a712 100644 --- a/src/notifications/ManagerLinux.cpp +++ b/src/notifications/ManagerLinux.cpp @@ -55,14 +55,14 @@ NotificationsManager::postNotification(const QString &roomid, Q_UNUSED(icon) QVariantMap hints; - hints["image-data"] = sender + ": " + text; + hints["image-data"] = icon; hints["sound-name"] = "message-new-instant"; QList argumentList; - argumentList << "nheko"; // app_name - argumentList << (uint)0; // replace_id - argumentList << ""; // app_icon - argumentList << roomname; // summary - argumentList << text; // body + argumentList << "nheko"; // app_name + argumentList << (uint)0; // replace_id + argumentList << ""; // app_icon + argumentList << roomname; // summary + argumentList << sender + ": " + text; // body // The list of actions has always the action name and then a localized version of that // action. Currently we just use an empty string for that. // TODO(Nico): Look into what to actually put there. From 89304a5c6b1b1fd02bcecd887aabc2b164d6d86a Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Wed, 20 Jan 2021 16:52:37 -0500 Subject: [PATCH 09/86] Fix crash --- src/notifications/ManagerLinux.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notifications/ManagerLinux.cpp b/src/notifications/ManagerLinux.cpp index 2c15a712..326803b2 100644 --- a/src/notifications/ManagerLinux.cpp +++ b/src/notifications/ManagerLinux.cpp @@ -78,7 +78,7 @@ NotificationsManager::postNotification(const QString &roomid, auto call = notifyApp.asyncCallWithArgumentList("Notify", argumentList); auto watcher = new QDBusPendingCallWatcher{QDBusPendingCall{QDBusPendingReply{call}}}; connect( - watcher, &QDBusPendingCallWatcher::finished, this, [watcher, this, &roomid, &eventid]() { + watcher, &QDBusPendingCallWatcher::finished, this, [watcher, this, roomid, eventid]() { if (watcher->reply().type() == QDBusMessage::ErrorMessage) qDebug() << "D-Bus Error:" << watcher->reply().errorMessage(); else From b5ead0e80dd592bc6ec9e9d46d8cd8cf7dd1c132 Mon Sep 17 00:00:00 2001 From: Weblate Date: Wed, 20 Jan 2021 17:36:40 -0500 Subject: [PATCH 10/86] Translated using Weblate (Hungarian) Currently translated at 24.1% (105 of 435 strings) Co-authored-by: maxigaz Translate-URL: https://weblate.nheko.im/projects/nheko/nheko-master/hu/ Translation: Nheko/nheko --- resources/langs/nheko_hu.ts | 38 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/resources/langs/nheko_hu.ts b/resources/langs/nheko_hu.ts index 30ad0ba7..726da410 100644 --- a/resources/langs/nheko_hu.ts +++ b/resources/langs/nheko_hu.ts @@ -345,12 +345,12 @@ Verification Code - Megerősítési kód + Ellenőrzési kód Please verify the following digits. You should see the same numbers on both sides. If they differ, please press 'They do not match!' to abort verification! - Kérlek, ellenőrizd a következő számjegyeket. Mindkét oldalon ugyanazoknak a számoknak kell szerepelniük. Ha nem ugyanazok, kérlek, válaszd azt, hogy „Nem egyeznek!” a megerősítés megszakításához! + Kérlek, ellenőrizd a következő számjegyeket. Mindkét oldalon ugyanazoknak a számoknak kell szerepelniük. Ha nem ugyanazok, kérlek, válaszd azt, hogy „Nem egyeznek!” az ellenőrzés megszakításához! @@ -440,12 +440,12 @@ Verification Code - Megerősítési kód + Ellenőrzési kód Please verify the following emoji. You should see the same emoji on both sides. If they differ, please press 'They do not match!' to abort verification! - Kérlek, ellenőrizd a következő hangulatjeleket. Mindkét oldalon ugyanazoknak a hangulatjeleknek kell szerepelniük. Ha nem ugyanazok, kérlek, válaszd azt, hogy „Nem egyeznek!” a megerősítés megszakításához! + Kérlek, ellenőrizd a következő hangulatjeleket. Mindkét oldalon ugyanazoknak a hangulatjeleknek kell szerepelniük. Ha nem ugyanazok, kérlek, válaszd azt, hogy „Nem egyeznek!” az ellenőrzés megszakításához! @@ -477,37 +477,37 @@ -- Encrypted Event (No keys found for decryption) -- Placeholder, when the message was not decrypted yet or can't be decrypted. - + -- Titkosított esemény (Nem találhatók kulcsok a titkosítás feloldásához) -- -- Decryption Error (failed to retrieve megolm keys from db) -- Placeholder, when the message can't be decrypted, because the DB access failed. - + -- Hiba a titkosítás feloldásakor (nem sikerült lekérni a megolm kulcsokat az adatbázisból) -- -- Decryption Error (%1) -- Placeholder, when the message can't be decrypted. In this case, the Olm decrytion returned an error, which is passed as %1. - + -- Hiba a titkosítás feloldásakor (%1) -- -- Encrypted Event (Unknown event type) -- Placeholder, when the message was decrypted, but we couldn't parse it, because Nheko/mtxclient don't support that event type yet. - + -- Titkosított esemény (Ismeretlen eseménytípus) -- -- Replay attack! This message index was reused! -- - + -- Újrajátszási támadás! Ez az üzenetindex újra fel lett használva! -- -- Message by unverified device! -- - + -- Nem ellenőrzött eszközről érkezett üzenet! -- @@ -1925,7 +1925,7 @@ This usually causes the application icon in the task bar to animate in some fash Cancel - Mégse + Mégse @@ -1969,7 +1969,7 @@ This usually causes the application icon in the task bar to animate in some fash Cancel - Mégse + Mégse @@ -2012,7 +2012,7 @@ This usually causes the application icon in the task bar to animate in some fash Cancel - Mégse + Mégse @@ -2030,7 +2030,7 @@ This usually causes the application icon in the task bar to animate in some fash Cancel - Mégse + Mégse @@ -2048,7 +2048,7 @@ This usually causes the application icon in the task bar to animate in some fash Cancel - Mégse + Mégse @@ -2061,7 +2061,7 @@ This usually causes the application icon in the task bar to animate in some fash Cancel - Mégse + Mégse @@ -2074,7 +2074,7 @@ This usually causes the application icon in the task bar to animate in some fash Cancel - Mégse + Mégse @@ -2092,7 +2092,7 @@ This usually causes the application icon in the task bar to animate in some fash Cancel - Mégse + Mégse @@ -2107,7 +2107,7 @@ Media size: %2 Cancel - Mégse + Mégse From 2605ce9a894217f5e6d51400498c0f67168187cd Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Wed, 20 Jan 2021 23:59:27 +0100 Subject: [PATCH 11/86] Clean up notification watching a bit --- src/notifications/ManagerLinux.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/notifications/ManagerLinux.cpp b/src/notifications/ManagerLinux.cpp index 326803b2..8f7261e6 100644 --- a/src/notifications/ManagerLinux.cpp +++ b/src/notifications/ManagerLinux.cpp @@ -52,8 +52,6 @@ NotificationsManager::postNotification(const QString &roomid, const QString &text, const QImage &icon) { - Q_UNUSED(icon) - QVariantMap hints; hints["image-data"] = icon; hints["sound-name"] = "message-new-instant"; @@ -75,8 +73,8 @@ NotificationsManager::postNotification(const QString &roomid, static QDBusInterface notifyApp("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications"); - auto call = notifyApp.asyncCallWithArgumentList("Notify", argumentList); - auto watcher = new QDBusPendingCallWatcher{QDBusPendingCall{QDBusPendingReply{call}}}; + QDBusPendingCall call = notifyApp.asyncCallWithArgumentList("Notify", argumentList); + auto watcher = new QDBusPendingCallWatcher{call, this}; connect( watcher, &QDBusPendingCallWatcher::finished, this, [watcher, this, roomid, eventid]() { if (watcher->reply().type() == QDBusMessage::ErrorMessage) @@ -91,14 +89,11 @@ NotificationsManager::postNotification(const QString &roomid, void NotificationsManager::closeNotification(uint id) { - QList argumentList; - argumentList << (uint)id; // replace_id - static QDBusInterface closeCall("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications"); - auto call = closeCall.asyncCallWithArgumentList("CloseNotification", argumentList); - auto watcher = new QDBusPendingCallWatcher{QDBusPendingCall{QDBusPendingReply{call}}}; + auto call = closeCall.asyncCall("CloseNotification", (uint)id); // replace_id + auto watcher = new QDBusPendingCallWatcher{call, this}; connect(watcher, &QDBusPendingCallWatcher::finished, this, [watcher, this]() { if (watcher->reply().type() == QDBusMessage::ErrorMessage) { qDebug() << "D-Bus Error:" << watcher->reply().errorMessage(); From 91155bf80332155b16b07f162e3ccd51bb9364cf Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Wed, 20 Jan 2021 17:44:11 -0500 Subject: [PATCH 12/86] Add commands to override Markdown setting --- src/timeline/InputBar.cpp | 8 ++++++-- src/timeline/InputBar.h | 9 ++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp index 3cddd613..49dd837b 100644 --- a/src/timeline/InputBar.cpp +++ b/src/timeline/InputBar.cpp @@ -251,12 +251,12 @@ InputBar::openFileSelection() } void -InputBar::message(QString msg) +InputBar::message(QString msg, MarkdownOverride useMarkdown) { mtx::events::msg::Text text = {}; text.body = msg.trimmed().toStdString(); - if (ChatPage::instance()->userSettings()->markdown()) { + if ((ChatPage::instance()->userSettings()->markdown() && (useMarkdown != MarkdownOverride::OFF)) || (useMarkdown == MarkdownOverride::ON)) { text.formatted_body = utils::markdownToHtml(msg).toStdString(); // Don't send formatted_body, when we don't need to @@ -477,6 +477,10 @@ InputBar::command(QString command, QString args) room->clearTimeline(); } else if (command == "rotate-megolm-session") { cache::dropOutboundMegolmSession(room->roomId().toStdString()); + } else if (command == "md") { + message(args, MarkdownOverride::ON); + } else if (command == "plain") { + message(args, MarkdownOverride::OFF); } } diff --git a/src/timeline/InputBar.h b/src/timeline/InputBar.h index c729a6fc..75bcdc3a 100644 --- a/src/timeline/InputBar.h +++ b/src/timeline/InputBar.h @@ -12,6 +12,13 @@ class QMimeData; class QDropEvent; class QStringList; +enum class MarkdownOverride +{ + NONE, // no override set + ON, + OFF, +}; + class InputBar : public QObject { Q_OBJECT @@ -41,7 +48,7 @@ public slots: void updateState(int selectionStart, int selectionEnd, int cursorPosition, QString text); void openFileSelection(); bool uploading() const { return uploading_; } - void message(QString body); + void message(QString body, MarkdownOverride useMarkdown = MarkdownOverride::NONE); QObject *completerFor(QString completerName); From 1d935708149d24b913742c76082eb10afa589ce4 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Wed, 20 Jan 2021 17:47:57 -0500 Subject: [PATCH 13/86] Make lint --- src/timeline/InputBar.cpp | 8 +++++--- src/timeline/InputBar.h | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp index 49dd837b..0e35cf64 100644 --- a/src/timeline/InputBar.cpp +++ b/src/timeline/InputBar.cpp @@ -256,7 +256,9 @@ InputBar::message(QString msg, MarkdownOverride useMarkdown) mtx::events::msg::Text text = {}; text.body = msg.trimmed().toStdString(); - if ((ChatPage::instance()->userSettings()->markdown() && (useMarkdown != MarkdownOverride::OFF)) || (useMarkdown == MarkdownOverride::ON)) { + if ((ChatPage::instance()->userSettings()->markdown() && + (useMarkdown != MarkdownOverride::OFF)) || + (useMarkdown == MarkdownOverride::ON)) { text.formatted_body = utils::markdownToHtml(msg).toStdString(); // Don't send formatted_body, when we don't need to @@ -478,9 +480,9 @@ InputBar::command(QString command, QString args) } else if (command == "rotate-megolm-session") { cache::dropOutboundMegolmSession(room->roomId().toStdString()); } else if (command == "md") { - message(args, MarkdownOverride::ON); + message(args, MarkdownOverride::ON); } else if (command == "plain") { - message(args, MarkdownOverride::OFF); + message(args, MarkdownOverride::OFF); } } diff --git a/src/timeline/InputBar.h b/src/timeline/InputBar.h index 75bcdc3a..57b38c08 100644 --- a/src/timeline/InputBar.h +++ b/src/timeline/InputBar.h @@ -14,9 +14,9 @@ class QStringList; enum class MarkdownOverride { - NONE, // no override set - ON, - OFF, + NONE, // no override set + ON, + OFF, }; class InputBar : public QObject From 06f6a5bcca60d992e48d8ea10e2e9fa52f4e086a Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Wed, 20 Jan 2021 18:47:36 -0500 Subject: [PATCH 14/86] Clarify how markdown is determined --- src/timeline/InputBar.cpp | 2 +- src/timeline/InputBar.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp index 0e35cf64..2317a407 100644 --- a/src/timeline/InputBar.cpp +++ b/src/timeline/InputBar.cpp @@ -257,7 +257,7 @@ InputBar::message(QString msg, MarkdownOverride useMarkdown) text.body = msg.trimmed().toStdString(); if ((ChatPage::instance()->userSettings()->markdown() && - (useMarkdown != MarkdownOverride::OFF)) || + (useMarkdown == MarkdownOverride::NOT_SPECIFIED)) || (useMarkdown == MarkdownOverride::ON)) { text.formatted_body = utils::markdownToHtml(msg).toStdString(); diff --git a/src/timeline/InputBar.h b/src/timeline/InputBar.h index 57b38c08..f173bbc0 100644 --- a/src/timeline/InputBar.h +++ b/src/timeline/InputBar.h @@ -14,7 +14,7 @@ class QStringList; enum class MarkdownOverride { - NONE, // no override set + NOT_SPECIFIED, // no override set ON, OFF, }; @@ -48,7 +48,7 @@ public slots: void updateState(int selectionStart, int selectionEnd, int cursorPosition, QString text); void openFileSelection(); bool uploading() const { return uploading_; } - void message(QString body, MarkdownOverride useMarkdown = MarkdownOverride::NONE); + void message(QString body, MarkdownOverride useMarkdown = MarkdownOverride::NOT_SPECIFIED); QObject *completerFor(QString completerName); From f31e2ffc7bcd860440838c5c343217907dbc000d Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Thu, 21 Jan 2021 13:21:34 +0100 Subject: [PATCH 15/86] Handle devices without keys --- src/Olm.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Olm.cpp b/src/Olm.cpp index fe789560..326e19ca 100644 --- a/src/Olm.cpp +++ b/src/Olm.cpp @@ -961,6 +961,12 @@ send_encrypted_to_device_messages(const std::mapdevice_keys.at(device); + if (!d.keys.count("curve25519:" + device) || + !d.keys.count("ed25519:" + device)) { + nhlog::crypto()->warn("Skipping device {} since it has no keys!", + device); + } + auto session = cache::getLatestOlmSession(d.keys.at("curve25519:" + device)); if (!session || force_new_session) { From 3b0d14b1b954ae76aa5c0d6affc0185efc51e696 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Thu, 21 Jan 2021 13:45:50 +0100 Subject: [PATCH 16/86] Actually use stored size in splitter after restart --- src/Splitter.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Splitter.cpp b/src/Splitter.cpp index 04375853..a2757d8e 100644 --- a/src/Splitter.cpp +++ b/src/Splitter.cpp @@ -37,20 +37,22 @@ Splitter::restoreSizes(int fallback) int savedWidth = settings.value("sidebar/width").toInt(); auto left = widget(0); - if (savedWidth == 0) { + if (savedWidth <= 0) { hideSidebar(); return; - } else if (savedWidth == sz_.small) { + } else if (savedWidth <= sz_.small) { if (left) { left->setMinimumWidth(sz_.small); left->setMaximumWidth(sz_.small); return; } + } else if (savedWidth < sz_.normal) { + savedWidth = sz_.normal; } left->setMinimumWidth(sz_.normal); left->setMaximumWidth(2 * sz_.normal); - setSizes({sz_.normal, fallback - sz_.normal}); + setSizes({savedWidth, fallback - savedWidth}); setStretchFactor(0, 0); setStretchFactor(1, 1); From db961204c82665ea479dfd32761c39fc46502002 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Thu, 21 Jan 2021 19:23:21 +0100 Subject: [PATCH 17/86] Move GNUInstallDirs after the project languages --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fc2a2bf..d03fc50c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,12 +72,13 @@ if(${CMAKE_VERSION} VERSION_LESS "3.14.0") endmacro() endif() +project(nheko LANGUAGES CXX C) + include(GNUInstallDirs) # Include Qt basic functions include(QtCommon) -project(nheko LANGUAGES CXX C) set(CPACK_PACKAGE_VERSION_MAJOR "0") set(CPACK_PACKAGE_VERSION_MINOR "8") set(CPACK_PACKAGE_VERSION_PATCH "0") From 1a83a982fc4204b6388ec2163280684882777276 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Thu, 21 Jan 2021 19:25:00 +0100 Subject: [PATCH 18/86] Properly skip device, if it has no keys --- src/Olm.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Olm.cpp b/src/Olm.cpp index 326e19ca..028095a6 100644 --- a/src/Olm.cpp +++ b/src/Olm.cpp @@ -965,6 +965,7 @@ send_encrypted_to_device_messages(const std::mapwarn("Skipping device {} since it has no keys!", device); + continue; } auto session = From 3508ed56a02434e191b6199ae830a45036cf8ef7 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Thu, 21 Jan 2021 19:05:12 -0500 Subject: [PATCH 19/86] Add item for reporting whether profiles are used --- .github/ISSUE_TEMPLATE/bug_report.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 19dfc26b..d66a165d 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -41,6 +41,16 @@ If applicable, add screenshots to help explain your problem. Windows: C:/Users//AppData/Local/nheko/cache --> +### Profile + + + + ### Debugger backtrace +- Profile used: - Installation method: - Operating System: - Qt version: @@ -41,16 +42,6 @@ If applicable, add screenshots to help explain your problem. Windows: C:/Users//AppData/Local/nheko/cache --> -### Profile - - - - ### Debugger backtrace