File indexing completed on 2024-04-21 04:56:32
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Martin Klapetek <mklapetek@kde.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 * 0006 */ 0007 0008 #ifndef KACCOUNTSDPLUGIN_H 0009 #define KACCOUNTSDPLUGIN_H 0010 0011 #include "kaccounts_export.h" 0012 0013 #include <Accounts/Account> 0014 #include <Accounts/Service> 0015 #include <QObject> 0016 0017 namespace KAccounts 0018 { 0019 0020 /** 0021 * Plugin for KAccounts daemon 0022 * 0023 * The plugin is loaded into the KAccounts daemon (a module in KDED) 0024 * and listens for events - new account created, account removed, 0025 * account service enabled and service disabled, allowing to execute 0026 * specialized actions with certain accounts and services. 0027 * 0028 * Each plugin should be accompanied by a provider file (if one doesn't 0029 * exist yet, like Google) and a service file describing the details 0030 * of the service. See AccountsQt docs for details. 0031 * 0032 * An example - you have an application that is working with calendars. 0033 * You write a plugin by extending this class. Then you add a Google 0034 * account into KAccounts and onAccountCreated in your plugin gets called. 0035 * Now your plugin must check if it is interested in the account that was added 0036 * and/or the services that come with it. If yes, you can set up the calendar 0037 * in your application in this method, using the Google OAuth token from KAccounts. 0038 * When the Calendar service gets disabled for Google account, your plugin 0039 * should disable the Google calendar in your application. 0040 */ 0041 class KACCOUNTS_EXPORT KAccountsDPlugin : public QObject 0042 { 0043 Q_OBJECT 0044 0045 public: 0046 KAccountsDPlugin(QObject *parent, const QVariantList &args); 0047 ~KAccountsDPlugin() override; 0048 0049 public Q_SLOTS: 0050 /** 0051 * Slot that will get called in the event of new account being created 0052 * 0053 * @param accountId Id of the newly created account (it's quint32) 0054 * @param serviceList List of services that the account has 0055 */ 0056 virtual void onAccountCreated(const Accounts::AccountId accountId, const Accounts::ServiceList &serviceList) = 0; 0057 0058 /** 0059 * Slot for events of account removal 0060 * 0061 * @param accountId Id of the account that got removed 0062 */ 0063 virtual void onAccountRemoved(const Accounts::AccountId accountId) = 0; 0064 0065 /** 0066 * Slot that handles account's service being enabled 0067 * 0068 * @param accountId Id of the account of which the service status changed 0069 * @param service The service that got enabled 0070 */ 0071 virtual void onServiceEnabled(const Accounts::AccountId accountId, const Accounts::Service &service) = 0; 0072 0073 /** 0074 * Slot that handles account's service being disabled 0075 * 0076 * @param accountId Id of the account of which the service status changed 0077 * @param service The service that got disabled 0078 */ 0079 virtual void onServiceDisabled(const Accounts::AccountId accountId, const Accounts::Service &service) = 0; 0080 }; 0081 0082 }; 0083 0084 #endif // KACCOUNTSDPLUGIN_H