File indexing completed on 2024-04-28 05:36:49

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 uint AccountPortal::GetUserInformation(const QDBusObjectPath &handle,
0019                                        const QString &app_id,
0020                                        const QString &parent_window,
0021                                        const QVariantMap &options,
0022                                        QVariantMap &results)
0023 {
0024     qCDebug(XdgDesktopPortalKdeAccount) << "GetUserInformation called with parameters:";
0025     qCDebug(XdgDesktopPortalKdeAccount) << "    handle: " << handle.path();
0026     qCDebug(XdgDesktopPortalKdeAccount) << "    parent_window: " << parent_window;
0027     qCDebug(XdgDesktopPortalKdeAccount) << "    app_id: " << app_id;
0028     qCDebug(XdgDesktopPortalKdeAccount) << "    options: " << options;
0029 
0030     QString reason;
0031 
0032     if (options.contains(QStringLiteral("reason"))) {
0033         reason = options.value(QStringLiteral("reason")).toString();
0034     }
0035 
0036     UserInfoDialog *userInfoDialog = new UserInfoDialog(reason);
0037     Utils::setParentWindow(userInfoDialog->windowHandle(), parent_window);
0038 
0039     int result = userInfoDialog->exec();
0040 
0041     if (result) {
0042         results.insert(QStringLiteral("id"), userInfoDialog->id());
0043         results.insert(QStringLiteral("name"), userInfoDialog->name());
0044         results.insert(QStringLiteral("image"), userInfoDialog->image());
0045     }
0046 
0047     userInfoDialog->deleteLater();
0048 
0049     return !result;
0050 }