2
* This file is part of libOnlineAccounts
4
* Copyright (C) 2015 Canonical Ltd.
6
* Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
8
* This program is free software: you can redistribute it and/or modify it
9
* under the terms of the GNU Lesser General Public License version 3, as
10
* published by the Free Software Foundation.
12
* This program is distributed in the hope that it will be useful, but
13
* WITHOUT ANY WARRANTY; without even the implied warranties of
14
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15
* PURPOSE. See the GNU Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21
#include "dbus_interface.h"
23
#include <QDBusMetaType>
27
using namespace OnlineAccounts;
29
DBusInterface::DBusInterface(const QString &service,
31
const char *interface,
32
const QDBusConnection &connection,
34
QDBusAbstractInterface(service, path, interface, connection, parent)
38
qDBusRegisterMetaType<AccountInfo>();
39
qDBusRegisterMetaType<QList<AccountInfo>>();
41
bool ok = connect("AccountChanged", "s(ua{sv})",
42
this, SLOT(onAccountChanged(const QString&,const OnlineAccounts::AccountInfo&)));
43
if (Q_UNLIKELY(!ok)) {
44
qCritical() << "Connection to AccountChanged signal failed";
48
DBusInterface::~DBusInterface()
52
QDBusPendingCall DBusInterface::getAccounts(const QVariantMap &filters)
54
return asyncCall(QStringLiteral("GetAccounts"), filters);
57
QDBusPendingCall DBusInterface::authenticate(AccountId accountId,
58
const QString &service,
61
const QVariantMap ¶meters)
63
return asyncCall(QStringLiteral("Authenticate"), accountId, service,
64
interactive, invalidate, parameters);
67
QDBusPendingCall DBusInterface::requestAccess(const QString &service,
68
const QVariantMap ¶meters)
70
return asyncCall(QStringLiteral("RequestAccess"), service, parameters);
73
void DBusInterface::onAccountChanged(const QString &service,
74
const AccountInfo &info)
76
Q_EMIT accountChanged(service, info);
79
bool DBusInterface::connect(const char *signal, const char *signature,
80
QObject *receiver, const char *slot)
82
return connection().connect(service(), path(), interface(),
83
QLatin1String(signal),
84
QLatin1String(signature),