Baloo Widgets

ondemandextractor.cpp
1/*
2 SPDX-FileCopyrightText: 2019 Stefan BrĂ¼ns <stefan.bruens@rwth-aachen.de>
3
4 SPDX-License-Identifier: LGPL-2.1-or-later
5*/
6
7#include "ondemandextractor.h"
8#include "extractorutil_p.h"
9#include "widgetsdebug.h"
10
11#include <QDataStream>
12#include <QStandardPaths>
13
14namespace Baloo
15{
16namespace Private
17{
18OnDemandExtractor::OnDemandExtractor(QObject *parent)
19 : QObject(parent)
20{
21}
22
23OnDemandExtractor::~OnDemandExtractor() = default;
24
25void OnDemandExtractor::process(const QString &filePath)
26{
27 const QString exe = QStandardPaths::findExecutable(QLatin1String("baloo_filemetadata_temp_extractor"));
28
29 m_process.setReadChannel(QProcess::StandardOutput);
30
31 connect(&m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, &OnDemandExtractor::slotIndexedFile);
32 m_process.start(exe, QStringList{filePath});
33}
34
35void OnDemandExtractor::slotIndexedFile(int, QProcess::ExitStatus exitStatus)
36{
37 if (exitStatus == QProcess::CrashExit) {
38 qCWarning(WIDGETS) << "Extractor crashed when processing" << m_process.arguments();
39 Q_EMIT fileFinished(exitStatus);
40 return;
41 }
42 QByteArray data = m_process.readAllStandardOutput();
44
45 m_properties.clear();
46 in >> m_properties;
47 Q_EMIT fileFinished(QProcess::NormalExit);
48}
49
50bool OnDemandExtractor::waitFinished()
51{
52 return m_process.waitForFinished();
53}
54
55KFileMetaData::PropertyMultiMap OnDemandExtractor::properties() const
56{
57 return m_properties;
58}
59
60} // namespace Private
61} // namespace Baloo
62
63#include "moc_ondemandextractor.cpp"
void finished(int exitCode, QProcess::ExitStatus exitStatus)
QString findExecutable(const QString &executableName, const QStringList &paths)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:57:15 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.