[kcms/user] Set interactive auth flag for more calls

Creating and deleting users needs that too

This also means that we need to be more correct with the types passed into the DBus calls since with passing the args as list we don't get implicit conversion to the correct type any more

BUG: 450122
FIXED-IN: 5.24.2
wilder-5.25
Nicolas Fella 4 years ago
parent 096f29e76b
commit 79113d99e4
  1. 15
      kcms/users/src/kcm.cpp
  2. 2
      kcms/users/src/kcm.h

@ -28,6 +28,15 @@ Q_LOGGING_CATEGORY(kcm_users, "kcm_users")
K_PLUGIN_CLASS_WITH_JSON(KCMUser, "kcm_users.json")
// Work around QTBUG-100458
inline auto asyncCall(OrgFreedesktopAccountsInterface *ptr, const QString &method, const QVariantList &arguments)
{
auto mc = QDBusMessage::createMethodCall(ptr->service(), ptr->path(), ptr->interface(), method);
mc.setArguments(arguments);
mc.setInteractiveAuthorizationAllowed(true);
return QDBusConnection::systemBus().asyncCall(mc);
}
KCMUser::KCMUser(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
: KQuickAddons::ConfigModule(parent, data, args)
, m_dbusInterface(new OrgFreedesktopAccountsInterface(QStringLiteral("org.freedesktop.Accounts"),
@ -56,7 +65,7 @@ KCMUser::KCMUser(QObject *parent, const KPluginMetaData &data, const QVariantLis
bool KCMUser::createUser(const QString &name, const QString &realName, const QString &password, bool isAdmin)
{
QDBusPendingReply<QDBusObjectPath> reply = m_dbusInterface->CreateUser(name, realName, isAdmin);
QDBusPendingReply<QDBusObjectPath> reply = asyncCall(m_dbusInterface, "CreateUser", {name, realName, static_cast<qint32>(isAdmin)});
reply.waitForFinished();
if (reply.isValid()) {
User *createdUser = new User(this);
@ -68,9 +77,9 @@ bool KCMUser::createUser(const QString &name, const QString &realName, const QSt
return false;
}
bool KCMUser::deleteUser(int id, bool deleteHome)
bool KCMUser::deleteUser(qint64 id, bool deleteHome)
{
QDBusPendingReply<> reply = m_dbusInterface->DeleteUser(id, deleteHome);
QDBusPendingReply<> reply = asyncCall(m_dbusInterface, "DeleteUser", {id, deleteHome});
reply.waitForFinished();
if (reply.isError()) {
return false;

@ -32,7 +32,7 @@ public:
~KCMUser() override;
Q_SCRIPTABLE bool createUser(const QString &name, const QString &realName, const QString &password, bool admin);
Q_SCRIPTABLE bool deleteUser(int index, bool deleteHome);
Q_SCRIPTABLE bool deleteUser(qint64 index, bool deleteHome);
// Grab the initials of a string
Q_SCRIPTABLE QString initializeString(const QString &stringToGrabInitialsOf);
Q_SCRIPTABLE QString plonkImageInTempfile(const QImage &image);

Loading…
Cancel
Save