2022-04-25 10:23:20 +08:00
|
|
|
#ifndef MOUNTDISKLISTENER_H
|
|
|
|
#define MOUNTDISKLISTENER_H
|
|
|
|
|
|
|
|
#include "dir-watcher-adaptor.h"
|
|
|
|
|
|
|
|
#include <QObject>
|
2023-04-08 16:54:01 +08:00
|
|
|
#include <QStringList>
|
2022-04-25 10:23:20 +08:00
|
|
|
#include <QDBusMessage>
|
|
|
|
#include <QDBusObjectPath>
|
|
|
|
#include <QDBusConnection>
|
|
|
|
#include <QDBusInterface>
|
|
|
|
#include <QDBusReply>
|
|
|
|
|
|
|
|
class DirWatcher : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
Q_CLASSINFO("D-Bus Interface","org.ukui.search.fileindex")
|
|
|
|
|
|
|
|
public:
|
|
|
|
static DirWatcher *getDirWatcher();
|
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
|
|
|
|
void initDbusService();
|
|
|
|
|
|
|
|
QStringList currentIndexableDir();
|
|
|
|
QStringList currentBlackListOfIndex();
|
|
|
|
|
|
|
|
QStringList currentSearchableDir();
|
|
|
|
QStringList searchableDirForSearchApplication();
|
|
|
|
QStringList blackListOfDir(const QString &dirPath);
|
|
|
|
|
2022-12-07 14:04:21 +08:00
|
|
|
/**
|
|
|
|
* @brief DirWatcher::appendIndexableListItem
|
|
|
|
* add a item to indexable dirs
|
|
|
|
* @param path: the path to be added to the index dirs list
|
|
|
|
* @return int: the result code
|
2023-04-08 16:54:01 +08:00
|
|
|
* 0: successful
|
|
|
|
* 1: path or its parent dir has been added
|
|
|
|
* 2: path is or under blacklist
|
|
|
|
* 3: path is in repeat mounted devices and another path which is in the same device has been indexed
|
|
|
|
* 4: another path which is in the same device has been indexed
|
|
|
|
* 5: path is not exists
|
2022-12-07 14:04:21 +08:00
|
|
|
*/
|
|
|
|
Q_SCRIPTABLE int appendIndexableListItem(const QString &path);
|
|
|
|
Q_SCRIPTABLE bool removeIndexableListItem(const QString &path);
|
2022-04-25 10:23:20 +08:00
|
|
|
|
2023-04-06 10:39:10 +08:00
|
|
|
//新接口
|
2023-04-08 16:54:01 +08:00
|
|
|
Q_SCRIPTABLE int appendSearchDir(const QString &path);
|
|
|
|
Q_SCRIPTABLE void removeSearchDir(const QString &path);
|
2023-04-06 10:39:10 +08:00
|
|
|
|
|
|
|
QStringList currentSearchDirs();
|
|
|
|
QStringList currentBlackList();
|
|
|
|
|
|
|
|
|
2022-04-25 10:23:20 +08:00
|
|
|
private:
|
|
|
|
DirWatcher(QObject *parent = nullptr);
|
|
|
|
~DirWatcher();
|
|
|
|
|
|
|
|
static QMutex s_mutex;
|
|
|
|
|
|
|
|
DirWatcherAdaptor *m_adaptor = nullptr;
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void appendIndexItem(const QString&, const QStringList&);
|
|
|
|
void removeIndexItem(const QString&);
|
2023-04-08 16:54:01 +08:00
|
|
|
//abondoned
|
|
|
|
void udiskRemoved();
|
2022-12-27 09:41:32 +08:00
|
|
|
void indexDirsChanged();
|
2022-04-25 10:23:20 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MOUNTDISKLISTENER_H
|
|
|
|
|