git: fff9c832f9ef - main - net-im/neochat: fix build against newer libquotient

From: Adriaan de Groot <adridg_at_FreeBSD.org>
Date: Tue, 18 Jul 2023 07:58:00 UTC
The branch main has been updated by adridg:

URL: https://cgit.FreeBSD.org/ports/commit/?id=fff9c832f9ef4e2d3c5bd54a8a2abb4e472ed193

commit fff9c832f9ef4e2d3c5bd54a8a2abb4e472ed193
Author:     Adriaan de Groot <adridg@FreeBSD.org>
AuthorDate: 2023-07-18 07:56:27 +0000
Commit:     Adriaan de Groot <adridg@FreeBSD.org>
CommitDate: 2023-07-18 07:57:59 +0000

    net-im/neochat: fix build against newer libquotient
    
    Previous commit had rakuco@'s fixes for the build, but none
    of the patches needed to make it build against newer libquotient.
---
 net-im/neochat/Makefile                            |  2 +-
 ...-8f4e5a41c58986b68406251051c26beb059dd9ce.patch | 55 +++++++++++++
 ...-805332c599308b927a1fdc676f95c96878b28d58.patch | 75 ++++++++++++++++++
 ...-ae6056615db2fa943551acdcadfd54bfebe3c114.patch | 25 ++++++
 ...-a94f46f90462dce1f817e9f28d24dad454e0dfb4.patch | 91 ++++++++++++++++++++++
 .../files/patch-020-always-enable-e2ee.patch       | 27 +++++++
 net-im/neochat/files/patch-021-controller.patch    | 14 ++++
 7 files changed, 288 insertions(+), 1 deletion(-)

diff --git a/net-im/neochat/Makefile b/net-im/neochat/Makefile
index df345178aa6b..024a578fce1c 100644
--- a/net-im/neochat/Makefile
+++ b/net-im/neochat/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	neochat
 DISTVERSION=	${KDE_APPLICATIONS_VERSION}
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	net-im deskutils kde kde-applications
 
 MAINTAINER=	kde@FreeBSD.org
diff --git a/net-im/neochat/files/patch-003-8f4e5a41c58986b68406251051c26beb059dd9ce.patch b/net-im/neochat/files/patch-003-8f4e5a41c58986b68406251051c26beb059dd9ce.patch
new file mode 100644
index 000000000000..a0f02602943e
--- /dev/null
+++ b/net-im/neochat/files/patch-003-8f4e5a41c58986b68406251051c26beb059dd9ce.patch
@@ -0,0 +1,55 @@
+From 8f4e5a41c58986b68406251051c26beb059dd9ce Mon Sep 17 00:00:00 2001
+From: Tobias Fella <fella@posteo.de>
+Date: Sun, 28 May 2023 11:22:40 +0200
+Subject: [PATCH] Drop reset*Count invocations
+
+Still coming from Spectral, where they were taken from Quaternion, where they were dropped because they don't work as expected.
+Also, soon to be removed from libQuotient itself.
+---
+ src/neochatroom.cpp | 10 ----------
+ src/neochatroom.h   |  1 -
+ 2 files changed, 11 deletions(-)
+
+diff --git a/src/neochatroom.cpp b/src/neochatroom.cpp
+index a98b6cdbe..101c0fc50 100644
+--- src/neochatroom.cpp
++++ src/neochatroom.cpp
+@@ -66,8 +66,6 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS
+     : Room(connection, std::move(roomId), joinState)
+ {
+     connect(connection, &Connection::accountDataChanged, this, &NeoChatRoom::updatePushNotificationState);
+-    connect(this, &NeoChatRoom::notificationCountChanged, this, &NeoChatRoom::countChanged);
+-    connect(this, &NeoChatRoom::highlightCountChanged, this, &NeoChatRoom::countChanged);
+     connect(this, &Room::fileTransferCompleted, this, [this] {
+         setFileUploadingProgress(0);
+         setHasFileUploading(false);
+@@ -410,14 +408,6 @@ void NeoChatRoom::onRedaction(const RoomEvent &prevEvent, const RoomEvent & /*af
+     }
+ }
+ 
+-void NeoChatRoom::countChanged()
+-{
+-    if (displayed() && !hasUnreadMessages()) {
+-        resetNotificationCount();
+-        resetHighlightCount();
+-    }
+-}
+-
+ QDateTime NeoChatRoom::lastActiveTime()
+ {
+     if (timelineSize() == 0) {
+diff --git a/src/neochatroom.h b/src/neochatroom.h
+index d0795f383..6125cfa96 100644
+--- src/neochatroom.h
++++ src/neochatroom.h
+@@ -866,7 +866,6 @@ private:
+ #endif
+ 
+ private Q_SLOTS:
+-    void countChanged();
+     void updatePushNotificationState(QString type);
+ 
+     void cacheLastEvent();
+-- 
+GitLab
+
diff --git a/net-im/neochat/files/patch-008-805332c599308b927a1fdc676f95c96878b28d58.patch b/net-im/neochat/files/patch-008-805332c599308b927a1fdc676f95c96878b28d58.patch
new file mode 100644
index 000000000000..ed6fc8d0518e
--- /dev/null
+++ b/net-im/neochat/files/patch-008-805332c599308b927a1fdc676f95c96878b28d58.patch
@@ -0,0 +1,75 @@
+From 805332c599308b927a1fdc676f95c96878b28d58 Mon Sep 17 00:00:00 2001
+From: Tobias Fella <fella@posteo.de>
+Date: Wed, 17 May 2023 23:49:56 +0200
+Subject: [PATCH] Don't use implicit lambda captures
+
+---
+ src/controller.cpp           | 6 +++---
+ src/models/roomlistmodel.cpp | 2 +-
+ src/notificationsmanager.cpp | 4 ++--
+ 3 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/src/controller.cpp b/src/controller.cpp
+index 1fc017a4e..3d1c3ffd4 100644
+--- src/controller.cpp
++++ src/controller.cpp
+@@ -113,10 +113,10 @@ Controller::Controller(QObject *parent)
+ 
+ #ifdef QUOTIENT_07
+     static int oldAccountCount = 0;
+-    connect(&AccountRegistry::instance(), &AccountRegistry::accountCountChanged, this, [=]() {
++    connect(&AccountRegistry::instance(), &AccountRegistry::accountCountChanged, this, [this]() {
+         if (AccountRegistry::instance().size() > oldAccountCount) {
+             auto connection = AccountRegistry::instance().accounts()[AccountRegistry::instance().size() - 1];
+-            connect(connection, &Connection::syncDone, this, [=]() {
++            connect(connection, &Connection::syncDone, this, [this]() {
+                 handleNotifications(connection);
+             });
+         }
+@@ -552,7 +552,7 @@ void Controller::setActiveConnection(Connection *connection)
+             m_isOnline = true;
+             Q_EMIT isOnlineChanged(true);
+         });
+-        connect(connection, &Connection::requestFailed, this, [=](BaseJob *job) {
++        connect(connection, &Connection::requestFailed, this, [](BaseJob *job) {
+             if (dynamic_cast<DownloadFileJob *>(job) && job->jsonData()["errcode"].toString() == "M_TOO_LARGE"_ls) {
+                 RoomManager::instance().warning(i18n("File too large to download."), i18n("Contact your matrix server administrator for support."));
+             }
+diff --git a/src/models/roomlistmodel.cpp b/src/models/roomlistmodel.cpp
+index 3129b90de..c4c9a3d9c 100644
+--- src/models/roomlistmodel.cpp
++++ src/models/roomlistmodel.cpp
+@@ -281,7 +281,7 @@ void RoomListModel::updateRoom(Room *room, Room *prev)
+     }
+     // Ok, we're through with pre-checks, now for the real thing.
+     auto newRoom = static_cast<NeoChatRoom *>(room);
+-    const auto it = std::find_if(m_rooms.begin(), m_rooms.end(), [=](const NeoChatRoom *r) {
++    const auto it = std::find_if(m_rooms.begin(), m_rooms.end(), [prev, newRoom](const NeoChatRoom *r) {
+         return r == prev || r == newRoom;
+     });
+     if (it != m_rooms.end()) {
+diff --git a/src/notificationsmanager.cpp b/src/notificationsmanager.cpp
+index a79296529..baf6d50a5 100644
+--- src/notificationsmanager.cpp
++++ src/notificationsmanager.cpp
+@@ -78,7 +78,7 @@ void NotificationsManager::postNotification(NeoChatRoom *room,
+     notification->setPixmap(QPixmap::fromImage(icon));
+ 
+     notification->setDefaultAction(i18n("Open NeoChat in this room"));
+-    connect(notification, &KNotification::defaultActivated, this, [=]() {
++    connect(notification, &KNotification::defaultActivated, this, [notification, room]() {
+         WindowController::instance().showAndRaiseWindow(notification->xdgActivationToken());
+         if (!room) {
+             return;
+@@ -118,7 +118,7 @@ void NotificationsManager::postInviteNotification(NeoChatRoom *room, const QStri
+     notification->setPixmap(img);
+     notification->setFlags(KNotification::Persistent);
+     notification->setDefaultAction(i18n("Open this invitation in NeoChat"));
+-    connect(notification, &KNotification::defaultActivated, this, [=]() {
++    connect(notification, &KNotification::defaultActivated, this, [notification, room]() {
+         WindowController::instance().showAndRaiseWindow(notification->xdgActivationToken());
+         notification->close();
+         RoomManager::instance().enterRoom(room);
+-- 
+GitLab
+
diff --git a/net-im/neochat/files/patch-009-ae6056615db2fa943551acdcadfd54bfebe3c114.patch b/net-im/neochat/files/patch-009-ae6056615db2fa943551acdcadfd54bfebe3c114.patch
new file mode 100644
index 000000000000..65ede9c52c1b
--- /dev/null
+++ b/net-im/neochat/files/patch-009-ae6056615db2fa943551acdcadfd54bfebe3c114.patch
@@ -0,0 +1,25 @@
+From ae6056615db2fa943551acdcadfd54bfebe3c114 Mon Sep 17 00:00:00 2001
+From: Tobias Fella <fella@posteo.de>
+Date: Thu, 18 May 2023 00:03:07 +0200
+Subject: [PATCH] Add missing capture
+
+---
+ src/controller.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/controller.cpp b/src/controller.cpp
+index 3d1c3ffd4..dd38ede9b 100644
+--- src/controller.cpp
++++ src/controller.cpp
+@@ -116,7 +116,7 @@ Controller::Controller(QObject *parent)
+     connect(&AccountRegistry::instance(), &AccountRegistry::accountCountChanged, this, [this]() {
+         if (AccountRegistry::instance().size() > oldAccountCount) {
+             auto connection = AccountRegistry::instance().accounts()[AccountRegistry::instance().size() - 1];
+-            connect(connection, &Connection::syncDone, this, [this]() {
++            connect(connection, &Connection::syncDone, this, [this, connection]() {
+                 handleNotifications(connection);
+             });
+         }
+-- 
+GitLab
+
diff --git a/net-im/neochat/files/patch-010-a94f46f90462dce1f817e9f28d24dad454e0dfb4.patch b/net-im/neochat/files/patch-010-a94f46f90462dce1f817e9f28d24dad454e0dfb4.patch
new file mode 100644
index 000000000000..e44a17ef2cd6
--- /dev/null
+++ b/net-im/neochat/files/patch-010-a94f46f90462dce1f817e9f28d24dad454e0dfb4.patch
@@ -0,0 +1,91 @@
+From a94f46f90462dce1f817e9f28d24dad454e0dfb4 Mon Sep 17 00:00:00 2001
+From: Tobias Fella <fella@posteo.de>
+Date: Fri, 26 May 2023 17:47:26 +0200
+Subject: [PATCH] Fix build against libQuotient 0.8
+
+---
+ src/controller.cpp | 24 ++++++++++++++++++++----
+ src/login.cpp      |  4 ++++
+ 2 files changed, 24 insertions(+), 4 deletions(-)
+
+diff --git a/src/controller.cpp b/src/controller.cpp
+index dd38ede9b..3835e312b 100644
+--- src/controller.cpp
++++ src/controller.cpp
+@@ -109,18 +109,22 @@ Controller::Controller(QObject *parent)
+     }
+ #endif
+ 
++#ifdef QUOTIENT_07
++    connect(&Accounts, &AccountRegistry::accountCountChanged, this, &Controller::activeConnectionIndexChanged);
++#else
+     connect(&AccountRegistry::instance(), &AccountRegistry::accountCountChanged, this, &Controller::activeConnectionIndexChanged);
++#endif
+ 
+ #ifdef QUOTIENT_07
+     static int oldAccountCount = 0;
+-    connect(&AccountRegistry::instance(), &AccountRegistry::accountCountChanged, this, [this]() {
+-        if (AccountRegistry::instance().size() > oldAccountCount) {
+-            auto connection = AccountRegistry::instance().accounts()[AccountRegistry::instance().size() - 1];
++    connect(&Accounts, &AccountRegistry::accountCountChanged, this, [this]() {
++        if (Accounts.size() > oldAccountCount) {
++            auto connection = Accounts.accounts()[Accounts.size() - 1];
+             connect(connection, &Connection::syncDone, this, [this, connection]() {
+                 handleNotifications(connection);
+             });
+         }
+-        oldAccountCount = AccountRegistry::instance().size();
++        oldAccountCount = Accounts.size();
+     });
+ #endif
+ }
+@@ -228,10 +232,18 @@ void Controller::logout(Connection *conn, bool serverSideLogout)
+     job.start();
+     loop.exec();
+ 
++#ifdef QUOTIENT_07
++    if (Accounts.count() > 1) {
++#else
+     if (AccountRegistry::instance().count() > 1) {
++#endif
+         // Only set the connection if the the account being logged out is currently active
+         if (conn == activeConnection()) {
++#ifdef QUOTIENT_07
++            setActiveConnection(Accounts.accounts()[0]);
++#else
+             setActiveConnection(AccountRegistry::instance().accounts()[0]);
++#endif
+         }
+     } else {
+         setActiveConnection(nullptr);
+@@ -495,7 +507,11 @@ NeochatChangePasswordJob::NeochatChangePasswordJob(const QString &newPassword, b
+ 
+ int Controller::accountCount() const
+ {
++#ifdef QUOTIENT_07
++    return Accounts.count();
++#else
+     return AccountRegistry::instance().count();
++#endif
+ }
+ 
+ void Controller::setQuitOnLastWindowClosed()
+diff --git a/src/login.cpp b/src/login.cpp
+index 1121875f9..8b937abaa 100644
+--- src/login.cpp
++++ src/login.cpp
+@@ -43,7 +43,11 @@ void Login::init()
+             return;
+         }
+ 
++#ifdef QUOTIENT_07
++        m_isLoggedIn = Accounts.isLoggedIn(m_matrixId);
++#else
+         m_isLoggedIn = AccountRegistry::instance().isLoggedIn(m_matrixId);
++#endif
+         Q_EMIT isLoggedInChanged();
+         if (m_isLoggedIn) {
+             return;
+-- 
+GitLab
+
diff --git a/net-im/neochat/files/patch-020-always-enable-e2ee.patch b/net-im/neochat/files/patch-020-always-enable-e2ee.patch
new file mode 100644
index 000000000000..44bd47c34d2f
--- /dev/null
+++ b/net-im/neochat/files/patch-020-always-enable-e2ee.patch
@@ -0,0 +1,27 @@
+From 025b367a7e5b4927a823a754e677ba573f3cac60 Mon Sep 17 00:00:00 2001
+From: Tobias Fella <fella@posteo.de>
+Date: Sun, 21 May 2023 22:21:32 +0200
+Subject: [PATCH 1/4] Always enable E2EE in libQuotient
+
+It's off-by-default in libQuotient 0.8
+---
+ src/main.cpp | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/main.cpp b/src/main.cpp
+index a626d9ef..634f4af2 100644
+--- src/main.cpp
++++ src/main.cpp
+@@ -195,6 +195,10 @@ int main(int argc, char *argv[])
+ 
+     initLogging();
+ 
++#if Quotient_VERSION_MINOR == 8
++    Connection::setEncryptionDefault(true);
++#endif
++
+ #ifdef NEOCHAT_FLATPAK
+     // Copy over the included FontConfig configuration to the
+     // app's config dir:
+-- 
+2.41.0
diff --git a/net-im/neochat/files/patch-021-controller.patch b/net-im/neochat/files/patch-021-controller.patch
new file mode 100644
index 000000000000..85de3be5f2f0
--- /dev/null
+++ b/net-im/neochat/files/patch-021-controller.patch
@@ -0,0 +1,14 @@
+--- src/controller.cpp	2023-07-18 09:44:46.451178000 +0200
++++ src/controller.cpp.orig	2023-07-18 09:44:18.501074000 +0200
+@@ -307,10 +307,7 @@
+ {
+     Q_ASSERT_X(c, __FUNCTION__, "Attempt to add a null connection");
+ 
++    Accounts.add(c);
+-#ifndef QUOTIENT_07
+-    AccountRegistry::instance().add(c);
+-#endif
+-
+     c->setLazyLoading(true);
+ 
+     connect(c, &Connection::syncDone, this, [this, c] {