2 * Copyright (C) 2013 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 * Author: Michael Terry <michael.terry@canonical.com>
19#include "AccountsService.h"
20#include <QDBusConnection>
21#include <QDBusConnectionInterface>
22#include <QDBusMessage>
23#include <QDBusVariant>
25AccountsService::AccountsService(QObject* parent)
27 accounts_manager(NULL),
30 auto connection = QDBusConnection::SM_BUSNAME();
31 auto interface = connection.interface();
32 interface->startService("org.freedesktop.Accounts");
33 accounts_manager = new QDBusInterface("org.freedesktop.Accounts",
34 "/org/freedesktop/Accounts",
35 "org.freedesktop.Accounts",
39QVariant AccountsService::getUserProperty(const QString &user, const QString &property)
41 auto iface = getUserInterface(user);
42 if (iface != nullptr && iface->isValid()) {
43 auto answer = iface->call("Get", "com.canonical.unity.AccountsService", property);
44 if (answer.type() == QDBusMessage::ReplyMessage) {
45 return answer.arguments()[0].value<QDBusVariant>().variant();
51void AccountsService::setUserProperty(const QString &user, const QString &property, const QVariant &value)
53 auto iface = getUserInterface(user);
54 if (iface != nullptr && iface->isValid()) {
55 // The value needs to be carefully wrapped
56 iface->call("Set", "com.canonical.unity.AccountsService", property, QVariant::fromValue(QDBusVariant(value)));
60QDBusInterface *AccountsService::getUserInterface(const QString &user)
62 auto iface = users.value(user);
63 if (iface == nullptr && accounts_manager->isValid()) {
64 auto answer = accounts_manager->call("FindUserByName", user);
65 if (answer.type() == QDBusMessage::ReplyMessage) {
66 iface = new QDBusInterface("org.freedesktop.Accounts",
67 answer.arguments()[0].value<QDBusObjectPath>().path(),
68 "org.freedesktop.DBus.Properties",
69 accounts_manager->connection(), this);
70 users.insert(user, iface);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list