/* * This file is part of OnlineAccountsDaemon * * Copyright (C) 2015 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef ONLINE_ACCOUNTS_DAEMON_MANAGER_ADAPTOR_H #define ONLINE_ACCOUNTS_DAEMON_MANAGER_ADAPTOR_H #include #include #include #include #include #include #include #include "account_info.h" #include "manager.h" namespace OnlineAccountsDaemon { class CallContext { public: explicit CallContext(QDBusContext *dbusContext); CallContext(const CallContext &other); virtual ~CallContext(); void setDelayedReply(bool delayed); void sendReply(const QList &args) const; void sendError(const QString &name, const QString &message) const; QString securityContext() const; pid_t clientPid() const; QString clientName() const; private: QDBusConnection m_connection; QDBusMessage m_message; }; class CallContextCounter: public QObject { Q_OBJECT public: static CallContextCounter *instance(); int activeContexts() const { return m_contexts; } Q_SIGNALS: void activeContextsChanged(); protected: void addContext(const CallContext &context); void removeContext(const CallContext &context); private: friend class CallContext; CallContextCounter(); int m_contexts; }; class ManagerAdaptorPrivate; class ManagerAdaptor: public QDBusAbstractAdaptor { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "com.lomiri.OnlineAccounts.Manager") Q_CLASSINFO("D-Bus Introspection", "" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" "") public: explicit ManagerAdaptor(Manager *parent); ~ManagerAdaptor(); inline Manager *parent() const { return static_cast(QObject::parent()); } inline QDBusContext *dbusContext() const { return static_cast(parent()); } void notifyAccountChange(const AccountInfo &info, uint changeType); public Q_SLOTS: QVariantMap Authenticate(uint accountId, const QString &serviceId, bool interactive, bool invalidate, const QVariantMap ¶meters); void GetAccounts(const QVariantMap &filters, QList &accounts, QList &services); AccountInfo RequestAccess(const QString &serviceId, const QVariantMap ¶meters, QVariantMap &credentials); Q_SIGNALS: void AccountChanged(const QString &serviceId, AccountInfo account); private: Q_DECLARE_PRIVATE(ManagerAdaptor) ManagerAdaptorPrivate *d_ptr; }; } // namespace #endif // ONLINE_ACCOUNTS_DAEMON_MANAGER_ADAPTOR_H