2022-03-01 10:37:03 +08:00
|
|
|
#ifndef MOUNTDISKLISTENER_H
|
|
|
|
#define MOUNTDISKLISTENER_H
|
|
|
|
|
2022-04-12 14:57:22 +08:00
|
|
|
#include "dir-watcher-adaptor.h"
|
|
|
|
|
2022-03-01 10:37:03 +08:00
|
|
|
#include <QObject>
|
|
|
|
#include <QStorageInfo>
|
|
|
|
#include <QHash>
|
|
|
|
#include <QDBusMessage>
|
|
|
|
#include <QDBusObjectPath>
|
|
|
|
#include <QMutex>
|
2022-04-12 14:57:22 +08:00
|
|
|
#include <QSettings>
|
|
|
|
#include <QDBusConnection>
|
2022-03-01 10:37:03 +08:00
|
|
|
|
|
|
|
#undef slots
|
|
|
|
#undef signals
|
|
|
|
#undef emit
|
|
|
|
|
|
|
|
#include <gio/gio.h>
|
|
|
|
#include <gio/gunixmounts.h>
|
|
|
|
|
|
|
|
class DirWatcher : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2022-04-12 14:57:22 +08:00
|
|
|
|
|
|
|
Q_CLASSINFO("D-Bus Interface","org.ukui.search.fileindex")
|
|
|
|
|
2022-03-01 10:37:03 +08:00
|
|
|
public:
|
|
|
|
static DirWatcher *getDirWatcher();
|
2022-04-14 11:16:26 +08:00
|
|
|
void initDbusService();
|
2022-03-01 10:37:03 +08:00
|
|
|
QStringList currentindexableDir();
|
|
|
|
QStringList currentBlackListOfIndex();
|
|
|
|
void appendBlackListItemOfIndex(const QString &path);
|
|
|
|
void appendBlackListItemOfIndex(const QStringList &pathList);
|
|
|
|
void removeBlackListItemOfIndex(const QString &path);
|
|
|
|
void removeBlackListItemOfIndex(const QStringList &pathList);
|
|
|
|
|
2022-04-08 11:15:18 +08:00
|
|
|
QStringList currentSearchableDir();
|
|
|
|
QStringList searchableDirForSearchApplication();
|
2022-03-01 10:37:03 +08:00
|
|
|
QStringList blackListOfDir(const QString &dirPath);
|
|
|
|
|
|
|
|
static void mountAddCallback(GVolumeMonitor *monitor, GMount *gmount, DirWatcher *pThis);
|
|
|
|
static void mountRemoveCallback(GVolumeMonitor *monitor, GMount *gmount, DirWatcher *pThis);
|
|
|
|
public Q_SLOTS:
|
2022-04-12 14:57:22 +08:00
|
|
|
void appendIndexableListItem(const QString &path);
|
|
|
|
void removeIndexableListItem(const QString &path);
|
|
|
|
|
2022-03-01 10:37:03 +08:00
|
|
|
void handleDisk();
|
|
|
|
void handleAddedUDiskDevice(QDBusMessage msg);
|
|
|
|
void handleRemovedUDiskDevice(QDBusMessage msg);
|
|
|
|
private:
|
|
|
|
DirWatcher(QObject *parent = nullptr);
|
|
|
|
~DirWatcher();
|
|
|
|
void initData();
|
|
|
|
void initDiskWatcher();
|
|
|
|
|
2022-04-15 10:30:01 +08:00
|
|
|
void handleIndexItemAppend(const QString &path, QStringList &blackList);
|
|
|
|
void handleIndexItemRemove(const QString &path);
|
|
|
|
|
2022-03-01 10:37:03 +08:00
|
|
|
static QMutex s_mutex;
|
|
|
|
|
|
|
|
GVolumeMonitor *m_volumeMonitor = nullptr;
|
2022-04-12 14:57:22 +08:00
|
|
|
|
|
|
|
DirWatcherAdaptor *m_adaptor = nullptr;
|
|
|
|
|
2022-03-01 10:37:03 +08:00
|
|
|
quint64 m_mountAddHandle;
|
|
|
|
quint64 m_mountRemoveHandle;
|
|
|
|
|
2022-04-12 14:57:22 +08:00
|
|
|
QSettings *m_qSettings = nullptr;
|
2022-03-01 10:37:03 +08:00
|
|
|
QStringList m_blackListOfIndex;
|
|
|
|
QStringList m_indexableDirList;
|
2022-04-12 14:57:22 +08:00
|
|
|
|
2022-04-08 11:15:18 +08:00
|
|
|
QStringList m_searchableDirList;
|
|
|
|
QStringList m_searchableListForApplication;
|
2022-03-01 10:37:03 +08:00
|
|
|
QStringList m_autoMountList;
|
|
|
|
QMultiMap<QString, QString> m_infoOfSubvolume;
|
|
|
|
QMap<QString, QStringList> m_currentMountedDeviceInfo;
|
|
|
|
QMap<QString, QStringList> m_repeatedlyMountedDeviceInfo;
|
|
|
|
|
|
|
|
QStringList m_addedUDiskDeviceList;
|
|
|
|
QString m_removedUDiskDevice;
|
|
|
|
QMap<QString, QStringList> m_currentUDiskDeviceInfo;
|
|
|
|
Q_SIGNALS:
|
|
|
|
void udiskRemoved();
|
2022-04-12 14:57:22 +08:00
|
|
|
void appendIndexItem(const QString&, const QStringList&);
|
|
|
|
void removeIndexItem(const QString&);
|
2022-03-01 10:37:03 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MOUNTDISKLISTENER_H
|
|
|
|
|