Changeset View
Changeset View
Standalone View
Standalone View
src/solid/devices/backends/fstab/system_filesystem_table.h
- This file was added.
1 | /*************************************************************************** | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2019 by David Hallas <david@davidhallas.dk> * | ||||
3 | * * | ||||
4 | * This program is free software; you can redistribute it and/or modify * | ||||
5 | * it under the terms of the GNU General Public License as published by * | ||||
6 | * the Free Software Foundation; either version 2 of the License, or * | ||||
7 | * (at your option) any later version. * | ||||
8 | * * | ||||
9 | * This program is distributed in the hope that it will be useful, * | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||||
12 | * GNU General Public License for more details. * | ||||
13 | * * | ||||
14 | * You should have received a copy of the GNU General Public License * | ||||
15 | * along with this program; if not, write to the * | ||||
16 | * Free Software Foundation, Inc., * | ||||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | ||||
18 | ***************************************************************************/ | ||||
19 | | ||||
20 | #ifndef SOLID_BACKENDS_FSTAB_SYSTEM_FILESYSTEM_TABLE_H | ||||
21 | #define SOLID_BACKENDS_FSTAB_SYSTEM_FILESYSTEM_TABLE_H | ||||
22 | | ||||
23 | #include "filesystem_table_parser.h" | ||||
24 | #include "filesystem_table_watcher.h" | ||||
25 | | ||||
26 | #include <QObject> | ||||
27 | #include <QList> | ||||
28 | #include <QString> | ||||
29 | #include <QStringList> | ||||
30 | | ||||
31 | namespace Solid | ||||
32 | { | ||||
33 | namespace Backends | ||||
34 | { | ||||
35 | namespace Fstab | ||||
36 | { | ||||
37 | | ||||
38 | // The Default Filter Function that filters the filesystems supported by the Fstab Solid Backend | ||||
39 | extern const FilesystemTableParser::FilterFunction DefaultFilterFunction; | ||||
40 | | ||||
41 | // Class that represents the available mountable filesystems and the currently mounted filesystem of the system | ||||
42 | // This class provides an interface that sums up the fstab file and the mtab file. It also monitors the two files | ||||
43 | // and notifies if they change | ||||
44 | class SystemFilesystemTable : public QObject | ||||
45 | { | ||||
46 | Q_OBJECT | ||||
47 | public: | ||||
48 | SystemFilesystemTable(const QString& fstabPath = QString(), const QString& mtabPath = QString(), | ||||
49 | FilesystemTableParser::FilterFunction filterFunction = DefaultFilterFunction); | ||||
50 | virtual ~SystemFilesystemTable(); | ||||
51 | QStringList filesystemIds() const; | ||||
52 | const FilesystemEntry* filesystemEntry(const QString &id) const; | ||||
53 | bool isMounted(const FilesystemEntry &fsEntry) const; | ||||
54 | Q_SIGNALS: | ||||
55 | void tableChanged(); | ||||
56 | private Q_SLOTS: | ||||
57 | void fstabChanged(); | ||||
58 | void mtabChanged(); | ||||
59 | private: | ||||
60 | const QString m_fstabPath; | ||||
61 | const QString m_mtabPath; | ||||
62 | const FilesystemTableParser::FilterFunction m_filterFunction; | ||||
63 | FilesystemTableWatcher m_fstabWatcher; | ||||
64 | FilesystemTableWatcher m_mtabWatcher; | ||||
65 | // The fstab entries represent the filesystems that the system can mount | ||||
66 | QList<FilesystemEntry> m_fstabEntries; | ||||
67 | // The mtab entries represent the filesystems that the system has currently mounted | ||||
68 | QList<FilesystemEntry> m_mtabEntries; | ||||
69 | }; | ||||
70 | | ||||
71 | } // namespace Fstab | ||||
72 | } // namespace Backends | ||||
73 | } // namespace Solid | ||||
74 | | ||||
75 | #endif |