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