diff --git a/libsearch/file-utils.cpp b/libsearch/file-utils.cpp index 24a4c94..557cc52 100644 --- a/libsearch/file-utils.cpp +++ b/libsearch/file-utils.cpp @@ -11,6 +11,8 @@ #include #include #include "uchardet/uchardet.h" + + size_t FileUtils::_max_index_count = 0; size_t FileUtils::_current_index_count = 0; unsigned short FileUtils::_index_status = INITIAL_STATE; diff --git a/libsearch/file-utils.h b/libsearch/file-utils.h index 5594615..735b4c8 100644 --- a/libsearch/file-utils.h +++ b/libsearch/file-utils.h @@ -1,6 +1,12 @@ #ifndef FILEUTILS_H #define FILEUTILS_H #include "gobject-template.h" +#include +#include +#include +#include +#include +#include #include #include #include @@ -10,6 +16,8 @@ #define CREATING_INDEX 1 #define FINISH_CREATING_INDEX 2 +#define UKUI_SEARCH_PIPE_PATH "/tmp/ukuisearch" + class LIBSEARCH_EXPORT FileUtils { diff --git a/libsearch/index/first-index.cpp b/libsearch/index/first-index.cpp index 120cffe..5412d52 100644 --- a/libsearch/index/first-index.cpp +++ b/libsearch/index/first-index.cpp @@ -2,7 +2,7 @@ #include "first-index.h" #include -#define NEW_QUEUE(a) a = new QQueue(); qDebug("---------------------------%s %s %s new at %d..",__FILE__,__FUNCTION__,#a,__LINE__); +#define NEW_QUEUE(a) a = new QQueue(); qDebug("---------------------------%s %s %s new at %d..",__FILE__,__FUNCTION__,#a,__LINE__); //#define DELETE_QUEUE(a ) FirstIndex::FirstIndex(const QString& path) : Traverse_BFS(path) @@ -63,6 +63,18 @@ void FirstIndex::DoSomething(const QFileInfo& fileInfo){ } void FirstIndex::run(){ + int fifo_fd; + char buffer[2]; + memset(buffer, 0, sizeof(buffer)); + buffer[0] = 0x1; + buffer[1] = '\0'; + fifo_fd = open(UKUI_SEARCH_PIPE_PATH, O_RDWR); + if(fifo_fd == -1) + { + perror("open fifo error\n"); + assert(false); + } + if (this->bool_dataBaseExist){ if (this->bool_dataBaseStatusOK){ @@ -165,6 +177,14 @@ void FirstIndex::run(){ waitpid(pid,NULL,0); } + int retval = write(fifo_fd, buffer, strlen(buffer)); + if(retval == -1) + { + perror("write error\n"); + } + printf("write data ok!\n"); + close(fifo_fd); + FileUtils::_index_status = FINISH_CREATING_INDEX; //quit() is shit!!! diff --git a/libsearch/index/first-index.h b/libsearch/index/first-index.h index 794267d..6d45d98 100644 --- a/libsearch/index/first-index.h +++ b/libsearch/index/first-index.h @@ -6,7 +6,12 @@ #include #include #include -#include +#include +#include +#include +#include +#include +#include #include #include //#include diff --git a/libsearch/index/inotify-index.cpp b/libsearch/index/inotify-index.cpp index 6ff5c22..6e97091 100644 --- a/libsearch/index/inotify-index.cpp +++ b/libsearch/index/inotify-index.cpp @@ -284,6 +284,30 @@ next: */ void InotifyIndex::run(){ + int fifo_fd; + char buffer[2]; + memset(buffer, 0, sizeof(buffer)); + fifo_fd = open(UKUI_SEARCH_PIPE_PATH, O_RDWR); + if(fifo_fd == -1) + { + perror("open fifo error\n"); + assert(false); + } + int retval = read(fifo_fd, buffer, sizeof(buffer)); + if(retval == -1) + { + perror("read error\n"); + assert(false); + } + printf("read fifo=[%s]\n", buffer); + + printf("read data ok\n"); + close(fifo_fd); + if (buffer[0] & 0x1){ + printf("data confirmed\n"); + } + unlink(UKUI_SEARCH_PIPE_PATH); + qDebug() << "sigset start!"; sigset( SIGTERM, handler); qDebug() << "sigset end!"; diff --git a/src/main.cpp b/src/main.cpp index f088c9b..6878115 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include "qt-single-application.h" #include "qt-local-peer.h" //#include "inotify-manager.h" @@ -34,6 +33,7 @@ #include "global-settings.h" #include "xatom-helper.h" + void messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) { QByteArray localMsg = msg.toLocal8Bit(); @@ -92,6 +92,17 @@ void centerToScreen(QWidget* widget) { int main(int argc, char *argv[]) { + unlink(UKUI_SEARCH_PIPE_PATH); + int retval = mkfifo(UKUI_SEARCH_PIPE_PATH, 0777); + if(retval == -1) + { + perror("creat fifo error\n"); + assert(false); + return -1; + } + printf("create fifo success\n"); + + qInstallMessageHandler(messageOutput); qRegisterMetaType>("QPair"); qRegisterMetaType("Document");