File indexing completed on 2024-05-12 05:48:11
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 "renamecommand.h" 0005 0006 #include <KIO/SimpleJob> 0007 0008 RenameCommand::RenameCommand(const QUrl &src, 0009 const QUrl &dst, 0010 KIO::JobFlags flags, 0011 const QString &remoteService, 0012 const QDBusObjectPath &objectPath, 0013 QObject *parent) 0014 : BusObject(remoteService, objectPath, parent) 0015 , m_src(src) 0016 , m_dst(dst) 0017 , m_flags(flags) 0018 { 0019 } 0020 0021 void RenameCommand::start() 0022 { 0023 if (!isAuthorized()) { 0024 sendErrorReply(QDBusError::AccessDenied); 0025 return; 0026 } 0027 0028 auto job = KIO::rename(m_src, m_dst, m_flags); 0029 setParent(job); 0030 connect(job, &KIO::SimpleJob::result, this, [this, job](KJob *) { 0031 sendSignal(&RenameCommand::result, job->error(), job->errorString()); 0032 }); 0033 }