From 842fe557bbdfa9db1ef065f6fff8c2fd78ad8790 Mon Sep 17 00:00:00 2001 From: zhangzihao Date: Wed, 6 Jan 2021 14:14:38 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=A9=F0=9F=92=A9=F0=9F=92=A9add=20class?= =?UTF-8?q?=20ukui-search-qdbus=20and=20turn=20PWD=20to=20OUT=5FPWD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libsearch/index/filetypefilter.cpp | 1 + libsearch/index/index.pri | 6 ++++-- libsearch/index/inotify.cpp | 11 ++++++++++ libsearch/index/ukui-search-qdbus.cpp | 29 +++++++++++++++++++++++++++ libsearch/index/ukui-search-qdbus.h | 16 +++++++++++++++ libsearch/libsearch.h | 2 ++ libsearch/libsearch.pro | 2 +- src/main.cpp | 10 +++++++-- src/src.pro | 2 +- 9 files changed, 73 insertions(+), 6 deletions(-) create mode 100644 libsearch/index/ukui-search-qdbus.cpp create mode 100644 libsearch/index/ukui-search-qdbus.h diff --git a/libsearch/index/filetypefilter.cpp b/libsearch/index/filetypefilter.cpp index f53f0b6..418f454 100644 --- a/libsearch/index/filetypefilter.cpp +++ b/libsearch/index/filetypefilter.cpp @@ -41,3 +41,4 @@ void FileTypeFilter::Test(){ ig->creatAllIndex(this->result); } + diff --git a/libsearch/index/index.pri b/libsearch/index/index.pri index 127cb45..a0a7b8d 100644 --- a/libsearch/index/index.pri +++ b/libsearch/index/index.pri @@ -13,7 +13,8 @@ HEADERS += \ $$PWD/messagelisttemplate.h \ $$PWD/traverse_bfs.h \ # $$PWD/text-content-indexer.h \ - $$PWD/file-searcher.h + $$PWD/file-searcher.h \ + $$PWD/ukui-search-qdbus.h SOURCES += \ # $$PWD/chinesecharacterstopinyin.cpp \ @@ -29,5 +30,6 @@ SOURCES += \ $$PWD/test-Inotify-Manager.cpp \ $$PWD/traverse_bfs.cpp \ # $$PWD/text-content-indexer.cpp \ - $$PWD/file-searcher.cpp + $$PWD/file-searcher.cpp \ + $$PWD/ukui-search-qdbus.cpp diff --git a/libsearch/index/inotify.cpp b/libsearch/index/inotify.cpp index f6e7b2d..0c093e8 100644 --- a/libsearch/index/inotify.cpp +++ b/libsearch/index/inotify.cpp @@ -1,7 +1,18 @@ #include "inotify.h" +#include "ukui-search-qdbus.h" InotifyManagerRefact::InotifyManagerRefact(const QString& path) : Traverse_BFS(path) { + + /*-------------ukuisearchdbus Test start-----------------*/ + qDebug() << "setInotifyMaxUserWatches start"; + UkuiSearchQDBus usQDBus; + usQDBus.setInotifyMaxUserWatches(); + qDebug() << "setInotifyMaxUserWatches end"; + + /*-------------ukuisearchdbus Test End-----------------*/ + + // dirPath = new QMap(); m_fd = inotify_init(); qDebug() << "m_fd----------->" < + +UkuiSearchQDBus::UkuiSearchQDBus() +{ + this->tmpSystemQDBusInterface = new QDBusInterface("com.ukui.search.qt.systemdbus", + "/", + "com.ukui.search.interface", + QDBusConnection::systemBus()); + if (!tmpSystemQDBusInterface->isValid()){ + qCritical() << "Create Client Interface Failed When execute chage: " << QDBusConnection::systemBus().lastError(); + return; + } +} +UkuiSearchQDBus::~UkuiSearchQDBus(){ + delete this->tmpSystemQDBusInterface; + this->tmpSystemQDBusInterface = nullptr; +} + +//一键三连 +void UkuiSearchQDBus::setInotifyMaxUserWatches() +{ + // /proc/sys/fs/inotify/max_user_watches + this->tmpSystemQDBusInterface->call("setInotifyMaxUseWatchesStep1"); + // sysctl + this->tmpSystemQDBusInterface->call("setInotifyMaxUseWatchesStep2"); + // /etc/sysctl.conf + this->tmpSystemQDBusInterface->call("setInotifyMaxUseWatchesStep3"); +} diff --git a/libsearch/index/ukui-search-qdbus.h b/libsearch/index/ukui-search-qdbus.h new file mode 100644 index 0000000..4c5b54f --- /dev/null +++ b/libsearch/index/ukui-search-qdbus.h @@ -0,0 +1,16 @@ +#ifndef UKUISEARCHQDBUS_H +#define UKUISEARCHQDBUS_H + +#include + +class UkuiSearchQDBus +{ +public: + UkuiSearchQDBus(); + ~UkuiSearchQDBus(); + void setInotifyMaxUserWatches(); +private: + QDBusInterface* tmpSystemQDBusInterface; +}; + +#endif // UKUISEARCHQDBUS_H diff --git a/libsearch/libsearch.h b/libsearch/libsearch.h index 8c1c3b2..a5b4591 100644 --- a/libsearch/libsearch.h +++ b/libsearch/libsearch.h @@ -10,6 +10,8 @@ #include "index/filetypefilter.h" +#include "index/ukui-search-qdbus.h" + class LIBSEARCH_EXPORT GlobalSearch { public: diff --git a/libsearch/libsearch.pro b/libsearch/libsearch.pro index 1e32a06..fade056 100644 --- a/libsearch/libsearch.pro +++ b/libsearch/libsearch.pro @@ -1,4 +1,4 @@ -QT += core concurrent xml widgets +QT += core concurrent xml widgets dbus VERSION = 0.0.1 TARGET = ukui-search diff --git a/src/main.cpp b/src/main.cpp index 0b1b6e0..13abe25 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -47,6 +47,12 @@ void centerToScreen(QWidget* widget) { int main(int argc, char *argv[]) { + /*-------------ukuisearchdbus Test start-----------------*/ +// UkuiSearchQDBus usQDBus; +// usQDBus.setInotifyMaxUserWatches(); + + /*-------------ukuisearchdbus Test End-----------------*/ + //load chinese character and pinyin file to a Map FileUtils::loadHanziTable("://index/pinyinWithoutTone.txt"); /*-------------InotyifyRefact Test Start---------------*/ @@ -58,7 +64,7 @@ int main(int argc, char *argv[]) qDebug() << t2; /*-------------InotyifyRefact Test End-----------------*/ - /*-------------InotyifyRefact Test Start---------------*/ + /*-------------content index Test Start---------------*/ QTime t3 = QTime::currentTime(); FileTypeFilter* ftf = new FileTypeFilter("/home"); ftf->Test(); @@ -67,7 +73,7 @@ int main(int argc, char *argv[]) ftf = nullptr; qDebug() << t3; qDebug() << t4; - /*-------------InotyifyRefact Test End-----------------*/ + /*-------------content index Test End-----------------*/ /*-------------文本搜索 Test start-----------------*/ // FileSearcher *search = new FileSearcher(); diff --git a/src/src.pro b/src/src.pro index fd0bb72..3ba3d8d 100644 --- a/src/src.pro +++ b/src/src.pro @@ -57,7 +57,7 @@ qm_files.files = $$OUT_PWD/res/translations/*.qm INSTALLS += \ qm_files \ -LIBS += -L$$PWD/../libsearch -lukui-search -L$$PWD/../libchinese-segmentation/ -lchinese-segmentation +LIBS += -L$$OUT_PWD/../libsearch -L$$OUT_PWD/../libchinese-segmentation/ -lchinese-segmentation -lukui-search INCLUDEPATH += $$PWD/../libsearch DEPENDPATH += $$PWD/../libsearch