2023-04-11 10:19:35 +08:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (C) 2023, KylinSoft Co., Ltd.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
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();
|
|
|
|
|
2023-05-06 09:19:50 +08:00
|
|
|
QStringList blockDirsForUser();
|
|
|
|
int addBlockDirOfUser(const QString& dir);
|
|
|
|
void removeBlockDirOfUser(const QString& dir);
|
2023-04-06 10:39:10 +08:00
|
|
|
|
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
|
|
|
|
|