File indexing completed on 2025-02-16 04:23:13
0001 /* 0002 SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org> 0003 SPDX-License-Identifier: LGPL-2.0-or-later 0004 */ 0005 0006 #include "mockpushprovider.h" 0007 #include "client.h" 0008 #include "logging.h" 0009 0010 using namespace KUnifiedPush; 0011 0012 MockPushProvider* MockPushProvider::s_instance = nullptr; 0013 0014 MockPushProvider::MockPushProvider(QObject *parent) 0015 : AbstractPushProvider(Id, parent) 0016 { 0017 s_instance = this; 0018 0019 qRegisterMetaType<KUnifiedPush::Client>(); 0020 qRegisterMetaType<KUnifiedPush::AbstractPushProvider::Error>(); 0021 } 0022 0023 MockPushProvider::~MockPushProvider() 0024 { 0025 if (s_instance == this) { 0026 s_instance = nullptr; 0027 } 0028 } 0029 0030 bool MockPushProvider::loadSettings(const QSettings &settings) 0031 { 0032 Q_UNUSED(settings); 0033 return true; 0034 } 0035 0036 void MockPushProvider::connectToProvider() 0037 { 0038 qCDebug(Log); 0039 QMetaObject::invokeMethod(this, "connected", Qt::QueuedConnection); 0040 } 0041 0042 void MockPushProvider::disconnectFromProvider() 0043 { 0044 qCDebug(Log); 0045 QMetaObject::invokeMethod(this, "disconnected", Qt::QueuedConnection, Q_ARG(KUnifiedPush::AbstractPushProvider::Error, NoError)); 0046 } 0047 0048 void MockPushProvider::registerClient(const Client &client) 0049 { 0050 qCDebug(Log) << client.serviceName << client.token; 0051 0052 auto newClient = client; 0053 newClient.remoteId = QStringLiteral("<client-remote-id>"); 0054 newClient.endpoint = QStringLiteral("https://localhost/push-endpoint"); 0055 QMetaObject::invokeMethod(this, "clientRegistered", Qt::QueuedConnection, Q_ARG(KUnifiedPush::Client, newClient)); 0056 } 0057 0058 void MockPushProvider::unregisterClient(const Client &client) 0059 { 0060 qCDebug(Log) << client.serviceName << client.token; 0061 QMetaObject::invokeMethod(this, "clientUnregistered", Qt::QueuedConnection, Q_ARG(KUnifiedPush::Client, client)); 0062 }