File indexing completed on 2024-05-12 17:19:14
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 "statcommand.h" 0005 0006 #include <KIO/StatJob> 0007 0008 StatCommand::StatCommand(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 StatCommand::start() 0015 { 0016 if (!isAuthorized()) { 0017 sendErrorReply(QDBusError::AccessDenied); 0018 return; 0019 } 0020 0021 auto job = KIO::stat(m_url); 0022 setParent(job); 0023 // Since we aren't file: proper we need to ensure that a mimetype is available. Otherwise KIO has a hard time guessing 0024 // what is going on and can end up without a mimetype. 0025 job->addMetaData(QStringLiteral("statDetails"), QString::number(KIO::StatDefaultDetails | KIO::StatMimeType)); 0026 connect(job, &KIO::StatJob::result, this, [this, job](KJob *) { 0027 if (job->error() == KJob::NoError) { 0028 sendSignal(&StatCommand::statEntry, job->statResult()); 0029 } 0030 sendSignal(&StatCommand::result, job->error(), job->errorString()); 0031 }); 0032 }