1 /* This file is part of the KDE Project
2 Copyright (c) 2008 Sebastian Trueg <trueg@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
19 #ifndef _NEPOMUK_STRIGI_INDEX_SCHEDULER_H_
20 #define _NEPOMUK_STRIGI_INDEX_SCHEDULER_H_
22 #include <QtCore/QThread>
23 #include <QtCore/QMutex>
24 #include <QtCore/QWaitCondition>
25 #include <QtCore/QSet>
33 class StoppableConfiguration
;
42 * The IndexScheduler performs the normal indexing,
43 * ie. the initial indexing and the timed updates
46 * Events are not handled.
48 class IndexScheduler
: public QThread
53 IndexScheduler( Strigi::IndexManager
* manager
, QObject
* parent
);
56 bool isSuspended() const;
57 bool isIndexing() const;
60 * The folder currently being indexed. Empty if not indexing.
61 * If suspended the folder might still be set!
63 QString
currentFolder() const;
70 void setSuspended( bool );
73 * Slot to connect to certain event systems like KDirNotify
76 * Updates a complete folder (non-recursively). Makes sense for
77 * signals like KDirWatch::dirty.
79 void updateDir( const QString
& path
);
82 * Updates all configured folders.
87 * Analyze a resource that is not read from the local harddisk.
89 * \param uri The resource URI to identify the resource.
90 * \param modificationTime The modification date of the resource. Used to determine if
91 * an actual update is necessary.
92 * \data The data to analyze, ie. the contents of the resource.
94 void analyzeResource( const QUrl
& uri
, const QDateTime
& modificationTime
, QDataStream
& data
);
97 void indexingStarted();
98 void indexingStopped();
99 void indexingFolder( const QString
& );
107 bool waitForContinue();
108 bool updateDir( const QString
& dir
, Strigi::StreamAnalyzer
* analyzer
, bool recursive
);
109 void analyzeFile( const QFileInfo
& file
, Strigi::StreamAnalyzer
* analyzer
);
111 // emits indexingStarted or indexingStopped based on parameter. Makes sure
112 // no signal is emitted twice
113 void setIndexingStarted( bool started
);
119 QMutex m_resumeStopMutex
;
120 QWaitCondition m_resumeStopWc
;
122 StoppableConfiguration
* m_analyzerConfig
;
123 Strigi::IndexManager
* m_indexManager
;
125 // set of folders to update (+flags defined in the source file) - changed by updateDir
126 QSet
<QPair
<QString
, int> > m_dirsToUpdate
;
128 QMutex m_dirsToUpdateMutex
;
129 QWaitCondition m_dirsToUpdateWc
;
131 QString m_currentFolder
;