File indexing completed on 2024-05-26 05:13:54
0001 /*************************************************************************** 0002 * SPDX-FileCopyrightText: 2019 Daniel Vrátil <dvratil@kde.org> * 0003 * * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later * 0005 ***************************************************************************/ 0006 0007 #pragma once 0008 0009 #include <QMap> 0010 #include <QObject> 0011 0012 #include <Accounts/Manager> 0013 0014 #include <optional> 0015 0016 namespace Accounts 0017 { 0018 class Account; 0019 class Service; 0020 } 0021 0022 class AgentManager; 0023 0024 class AccountsIntegration : public QObject 0025 { 0026 Q_OBJECT 0027 public: 0028 explicit AccountsIntegration(AgentManager &agentManager); 0029 0030 private Q_SLOTS: 0031 void onAccountAdded(Accounts::AccountId); 0032 void onAccountRemoved(Accounts::AccountId); 0033 void onAccountServiceEnabled(const QString &service, bool enabled); 0034 0035 private: 0036 void configureAgentInstance(const QString &identifier, Accounts::AccountId accountId, int attempt = 0); 0037 std::optional<QString> agentForAccount(const QString &agentType, Accounts::AccountId accountId) const; 0038 void createAgent(const QString &agentType, Accounts::AccountId accountId); 0039 void removeAgentInstance(const QString &identifier); 0040 0041 AgentManager &mAgentManager; 0042 Accounts::Manager mAccountsManager; 0043 0044 QMap<QString, QString /* agent type */> mSupportedServices; 0045 };