Don't start the entire NeoChat backend when receiving push notifications

This adds a dedicated "set up for push notifications only" function in
Controller, which only sets up the KUnifiedPush connector for receiving
the message and then quitting right afterward. If the user tries to
open a notification, then it will quit and open the main client.
This commit is contained in:
Joshua Goins
2023-11-12 17:08:15 -05:00
parent 100f595026
commit d3148f8c8b
4 changed files with 47 additions and 18 deletions

View File

@@ -42,10 +42,6 @@
#include "trayicon_sni.h"
#endif
#ifdef HAVE_KUNIFIEDPUSH
#include <kunifiedpush/connector.h>
#endif
using namespace Quotient;
Controller::Controller(QObject *parent)
@@ -116,9 +112,6 @@ Controller::Controller(QObject *parent)
connection->setupPushNotifications(endpoint);
}
});
connect(connector, &KUnifiedPush::Connector::messageReceived, this, [this](const QByteArray &data) {
NotificationsManager::instance().postPushNotification(data);
});
connector->registerClient(i18n("Receiving push notifications"));
@@ -383,6 +376,19 @@ void Controller::forceRefreshTextDocument(QQuickTextDocument *textDocument, QQui
connect(textDocument->textDocument(), SIGNAL(imagesLoaded()), item, SLOT(updateWholeDocument()));
}
void Controller::listenForNotifications()
{
#ifdef HAVE_KUNIFIEDPUSH
auto connector = new KUnifiedPush::Connector(QStringLiteral("org.kde.neochat"));
connect(connector, &KUnifiedPush::Connector::messageReceived, [](const QByteArray &data) {
NotificationsManager::instance().postPushNotification(data);
});
connector->registerClient(i18n("Receiving push notifications"));
#endif
}
void Controller::setApplicationProxy()
{
NeoChatConfig *cfg = NeoChatConfig::self();