File indexing completed on 2024-05-12 05:48:10

0001 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0002 // SPDX-FileCopyrightText: 2022 Harald Sitter <sitter@kde.org>
0003 
0004 #include "chmodcommand.h"
0005 
0006 #include <KIO/SimpleJob>
0007 
0008 ChmodCommand::ChmodCommand(const QUrl &url, int permissions, const QString &remoteService, const QDBusObjectPath &objectPath, QObject *parent)
0009     : BusObject(remoteService, objectPath, parent)
0010     , m_url(url)
0011     , m_permissions(permissions)
0012 {
0013 }
0014 
0015 void ChmodCommand::start()
0016 {
0017     if (!isAuthorized()) {
0018         sendErrorReply(QDBusError::AccessDenied);
0019         return;
0020     }
0021 
0022     auto job = KIO::chmod(m_url, m_permissions);
0023     setParent(job);
0024     connect(job, &KIO::SimpleJob::result, this, [this, job](KJob *) {
0025         sendSignal(&ChmodCommand::result, job->error(), job->errorString());
0026     });
0027 }