File indexing completed on 2024-04-28 16:55:43

0001 /*
0002  * SPDX-FileCopyrightText: 2020 Red Hat Inc
0003  * SPDX-License-Identifier: LGPL-2.0-or-later
0004  *
0005  * SPDX-FileCopyrightText: 2020 Jan Grulich <jgrulich@redhat.com>
0006  */
0007 
0008 #include "account.h"
0009 #include "account_debug.h"
0010 #include "userinfodialog.h"
0011 #include "utils.h"
0012 
0013 AccountPortal::AccountPortal(QObject *parent)
0014     : QDBusAbstractAdaptor(parent)
0015 {
0016 }
0017 
0018 AccountPortal::~AccountPortal()
0019 {
0020 }
0021 
0022 uint AccountPortal::GetUserInformation(const QDBusObjectPath &handle,
0023                                        const QString &app_id,
0024                                        const QString &parent_window,
0025                                        const QVariantMap &options,
0026                                        QVariantMap &results)
0027 {
0028     qCDebug(XdgDesktopPortalKdeAccount) << "GetUserInformation called with parameters:";
0029     qCDebug(XdgDesktopPortalKdeAccount) << "    handle: " << handle.path();
0030     qCDebug(XdgDesktopPortalKdeAccount) << "    parent_window: " << parent_window;
0031     qCDebug(XdgDesktopPortalKdeAccount) << "    app_id: " << app_id;
0032     qCDebug(XdgDesktopPortalKdeAccount) << "    options: " << options;
0033 
0034     QString reason;
0035 
0036     if (options.contains(QStringLiteral("reason"))) {
0037         reason = options.value(QStringLiteral("reason")).toString();
0038     }
0039 
0040     UserInfoDialog *userInfoDialog = new UserInfoDialog(reason);
0041     Utils::setParentWindow(userInfoDialog->windowHandle(), parent_window);
0042 
0043     int result = userInfoDialog->exec();
0044 
0045     if (result) {
0046         results.insert(QStringLiteral("id"), userInfoDialog->id());
0047         results.insert(QStringLiteral("name"), userInfoDialog->name());
0048         results.insert(QStringLiteral("image"), userInfoDialog->image());
0049     }
0050 
0051     userInfoDialog->deleteLater();
0052 
0053     return !result;
0054 }