File indexing completed on 2024-04-28 03:51:40
0001 /* 0002 This file is part of the KDE Baloo Project 0003 SPDX-FileCopyrightText: 2021 Stefan BrĂ¼ns <stefan.bruens@rwth-aachen.de> 0004 0005 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 0008 #include <QCoreApplication> 0009 #include <QFile> 0010 #include <QSocketNotifier> 0011 #include <QTimer> 0012 0013 #include "baloodebug.h" 0014 #include "extractor/commandpipe.h" 0015 0016 #include <unistd.h> //for STDIN_FILENO 0017 0018 int main(int argc, char* argv[]) 0019 { 0020 using Baloo::Private::WorkerPipe; 0021 0022 QCoreApplication app(argc, argv); 0023 0024 QFile input; 0025 input.open(STDIN_FILENO, QIODevice::ReadOnly | QIODevice::Unbuffered); 0026 QSocketNotifier inputNotifier(STDIN_FILENO, QSocketNotifier::Read); 0027 0028 QFile output; 0029 output.open(STDOUT_FILENO, QIODevice::WriteOnly | QIODevice::Unbuffered); 0030 0031 WorkerPipe worker(&input, &output); 0032 QObject::connect(&inputNotifier, &QSocketNotifier::activated, 0033 &worker, &WorkerPipe::processIdData); 0034 0035 QObject::connect(&worker, &WorkerPipe::inputEnd, &QCoreApplication::quit); 0036 QObject::connect(&worker, &WorkerPipe::newDocumentIds, 0037 [&worker](const QVector<quint64>& ids) { 0038 QTimer::singleShot(0, [&worker, ids]() { 0039 qCInfo(BALOO) << "Processing ..."; 0040 for(auto id : ids) { 0041 worker.urlStarted(QString::number(id)); 0042 worker.urlFinished(QString::number(id)); 0043 } 0044 worker.batchFinished(); 0045 qCInfo(BALOO) << "Processing done"; 0046 }); 0047 }); 0048 0049 return app.exec(); 0050 }