File indexing completed on 2025-01-05 04:46:23
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 "akonadiagentbase_export.h" 0010 #include <QObject> 0011 0012 #include <functional> 0013 #include <optional> 0014 0015 class Akonadi__AccountsAdaptor; 0016 namespace Akonadi 0017 { 0018 class AKONADIAGENTBASE_EXPORT AccountsIntegration : public QObject 0019 { 0020 Q_OBJECT 0021 0022 friend class ::Akonadi__AccountsAdaptor; 0023 0024 public: 0025 explicit AccountsIntegration(); 0026 ~AccountsIntegration() override = default; 0027 0028 /** 0029 * Returns whether Accounts integration is enabled. 0030 */ 0031 [[nodiscard]] bool isEnabled() const; 0032 0033 using AuthDataCallback = std::function<void(const QVariantMap &)>; 0034 using ErrorCallback = std::function<void(const QString &)>; 0035 void requestAuthData(const QString &serviceType, AuthDataCallback &&cb, ErrorCallback &&err); 0036 0037 std::optional<QString> accountName() const; 0038 public Q_SLOTS: 0039 std::optional<quint32> accountId() const; 0040 void setAccountId(quint32 accountId); 0041 0042 Q_SIGNALS: 0043 void accountChanged(); 0044 0045 private: 0046 // For DBus adaptor which doesn't understand std::optional 0047 quint32 getAccountId() const; 0048 0049 std::optional<quint32> mAccountId; 0050 }; 0051 0052 } // namespace Akonadi