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 "listdircommand.h" 0005 0006 #include <KIO/ListJob> 0007 0008 ListDirCommand::ListDirCommand(const QUrl &url, const QString &remoteService, const QDBusObjectPath &objectPath, QObject *parent) 0009 : BusObject(remoteService, objectPath, parent) 0010 , m_url(url) 0011 { 0012 } 0013 0014 void ListDirCommand::start() 0015 { 0016 if (!isAuthorized()) { 0017 sendErrorReply(QDBusError::AccessDenied); 0018 return; 0019 } 0020 0021 auto job = KIO::listDir(m_url); 0022 // Since we aren't file: proper we need to ensure that a mimetype is available. Otherwise KIO has a hard time guessing 0023 // what is going on and can end up without a mimetype. 0024 job->addMetaData(QStringLiteral("statDetails"), QString::number(KIO::StatDefaultDetails | KIO::StatMimeType)); 0025 setParent(job); 0026 connect(job, &KIO::ListJob::entries, this, [this](KIO::Job *, const KIO::UDSEntryList &list) { 0027 sendSignal(&ListDirCommand::entries, list); 0028 }); 0029 connect(job, &KIO::ListJob::result, this, [this](KJob *job) { 0030 sendSignal(&ListDirCommand::result, job->error(), job->errorString()); 0031 }); 0032 } 0033 0034 void ListDirCommand::kill() 0035 { 0036 doKill(); 0037 }