@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2013, 2015 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -12,8 +12,6 @@
1212 *
1313 * You should have received a copy of the GNU General Public License
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Author: Michael Terry <michael.terry@canonical.com>
1715 */
1816
1917#include "AccountsService.h"
@@ -130,6 +128,34 @@ bool AccountsService::hereLicensePathValid() const
130128 return !m_hereLicensePath.isNull();
131129}
132130
131+QString AccountsService::realName() const
132+{
133+ return m_realName;
134+}
135+
136+void AccountsService::setRealName(const QString &realName)
137+{
138+ if (realName != m_realName) {
139+ m_realName = realName;
140+ m_service->setUserProperty(m_user, "org.freedesktop.Accounts.User", "RealName", m_realName);
141+ Q_EMIT realNameChanged();
142+ }
143+}
144+
145+QString AccountsService::email() const
146+{
147+ return m_email;
148+}
149+
150+void AccountsService::setEmail(const QString &email)
151+{
152+ if (email != m_email) {
153+ m_email = email;
154+ m_service->setUserProperty(m_user, "org.freedesktop.Accounts.User", "Email", m_email);
155+ Q_EMIT emailChanged();
156+ }
157+}
158+
133159void AccountsService::updateDemoEdges(bool async)
134160{
135161 QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user,
@@ -394,6 +420,58 @@ void AccountsService::updateHereLicensePath(bool async)
394420 }
395421}
396422
423+void AccountsService::updateRealName(bool async)
424+{
425+ QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user, "org.freedesktop.Accounts.User", "RealName");
426+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
427+
428+ connect(watcher, &QDBusPendingCallWatcher::finished,
429+ this, [this](QDBusPendingCallWatcher* watcher) {
430+ QDBusPendingReply<QVariant> reply = *watcher;
431+ watcher->deleteLater();
432+ if (reply.isError()) {
433+ qWarning() << "Failed to get 'RealName' property - " << reply.error().message();
434+ return;
435+ }
436+
437+ const QString realName = reply.value().toString();
438+ if (m_realName != realName) {
439+ m_realName = realName;
440+ Q_EMIT realNameChanged();
441+ }
442+ });
443+ if (!async) {
444+ watcher->waitForFinished();
445+ delete watcher;
446+ }
447+}
448+
449+void AccountsService::updateEmail(bool async)
450+{
451+ QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user, "org.freedesktop.Accounts.User", "Email");
452+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
453+
454+ connect(watcher, &QDBusPendingCallWatcher::finished,
455+ this, [this](QDBusPendingCallWatcher* watcher) {
456+ QDBusPendingReply<QVariant> reply = *watcher;
457+ watcher->deleteLater();
458+ if (reply.isError()) {
459+ qWarning() << "Failed to get 'Email' property - " << reply.error().message();
460+ return;
461+ }
462+
463+ const QString email = reply.value().toString();
464+ if (m_email != email) {
465+ m_email = email;
466+ Q_EMIT emailChanged();
467+ }
468+ });
469+ if (!async) {
470+ watcher->waitForFinished();
471+ delete watcher;
472+ }
473+}
474+
397475uint AccountsService::failedLogins() const
398476{
399477 return m_failedLogins;
@@ -455,4 +533,6 @@ void AccountsService::onMaybeChanged(const QString &user)
455533
456534 // Standard properties might have changed
457535 updateBackgroundFile();
536+ updateRealName();
537+ updateEmail();
458538}