Baloo

filewatch.h
1 /*
2  This file is part of the KDE Project
3  SPDX-FileCopyrightText: 2007-2011 Sebastian Trueg <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef BALOO_FILE_WATCH_H_
9 #define BALOO_FILE_WATCH_H_
10 
11 #include <QObject>
12 #include "pendingfile.h"
13 
14 class KInotify;
15 
16 namespace Baloo
17 {
18 class Database;
19 class MetadataMover;
20 class FileIndexerConfig;
21 class PendingFileQueue;
22 class FileWatchTest;
23 
24 class FileWatch : public QObject
25 {
26  Q_OBJECT
27 
28 public:
29  FileWatch(Database* db, FileIndexerConfig* config, QObject* parent = nullptr);
30  ~FileWatch() override;
31 
32 public Q_SLOTS:
33  /**
34  * To be called whenever the list of indexed/excluded folders in the config
35  * changes.
36  */
37  void updateIndexedFoldersWatches();
38 
39 Q_SIGNALS:
40  void indexNewFile(const QString& string);
41  void indexModifiedFile(const QString& string);
42  void indexXAttr(const QString& path);
43 
44  /**
45  * This signal is emitted when a file has been removed, and everyone else
46  * should update their caches
47  */
48  void fileRemoved(const QString& path);
49 
50  void installedWatches();
51 
52 private Q_SLOTS:
53  void slotFileMoved(const QString& from, const QString& to);
54  void slotFileDeleted(const QString& urlString, bool isDir);
55  void slotFileCreated(const QString& path, bool isDir);
56  void slotFileClosedAfterWrite(const QString&);
57  void slotAttributeChanged(const QString& path);
58  void slotFileModified(const QString& path);
59  void slotInotifyWatchUserLimitReached(const QString&);
60 
61 private:
62  /** Watch a folder, provided it is not already watched*/
63  void watchFolder(const QString& path);
64 
65  Database* m_db;
66 
67  MetadataMover* m_metadataMover;
68  FileIndexerConfig* m_config;
69 
70  KInotify* m_dirWatch;
71 
72  /// queue used to "compress" multiple file events like downloads
73  PendingFileQueue* m_pendingFileQueue;
74 
75  QStringList m_includedFolders;
76  QStringList m_excludedFolders;
77 
78  friend class FileWatchTest;
79 };
80 }
81 
82 #endif
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
Implements storage for docIds without any associated data Instantiated for:
Definition: coding.cpp:11
A simple wrapper around inotify which only allows to add folders recursively.
Definition: kinotify.h:24
Q_SIGNALSQ_SIGNALS
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Nov 29 2023 03:56:26 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.