|
a/src/qtgui/idxthread.cpp |
|
b/src/qtgui/idxthread.cpp |
1 |
#include <stdio.h>
|
|
|
2 |
#include <unistd.h>
|
|
|
3 |
/*
|
1 |
/*
|
4 |
* This program is free software; you can redistribute it and/or modify
|
2 |
* This program is free software; you can redistribute it and/or modify
|
5 |
* it under the terms of the GNU General Public License as published by
|
3 |
* it under the terms of the GNU General Public License as published by
|
6 |
* the Free Software Foundation; either version 2 of the License, or
|
4 |
* the Free Software Foundation; either version 2 of the License, or
|
7 |
* (at your option) any later version.
|
5 |
* (at your option) any later version.
|
|
... |
|
... |
15 |
* along with this program; if not, write to the
|
13 |
* along with this program; if not, write to the
|
16 |
* Free Software Foundation, Inc.,
|
14 |
* Free Software Foundation, Inc.,
|
17 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
18 |
*/
|
16 |
*/
|
19 |
|
17 |
|
|
|
18 |
#include <stdio.h>
|
|
|
19 |
#include <unistd.h>
|
|
|
20 |
#include <sys/types.h>
|
20 |
|
21 |
|
21 |
#include <qthread.h>
|
22 |
#include <qthread.h>
|
22 |
#include <qmutex.h>
|
23 |
#include <qmutex.h>
|
23 |
#include <qwaitcondition.h>
|
24 |
#include <qwaitcondition.h>
|
24 |
|
25 |
|
25 |
#include "indexer.h"
|
26 |
#include "indexer.h"
|
26 |
#include "debuglog.h"
|
27 |
#include "debuglog.h"
|
27 |
#include "idxthread.h"
|
28 |
#include "idxthread.h"
|
28 |
#include "smallut.h"
|
29 |
#include "smallut.h"
|
29 |
#include "rclinit.h"
|
30 |
#include "rclinit.h"
|
|
|
31 |
#include "pathut.h"
|
30 |
|
32 |
|
31 |
static int stopindexing;
|
33 |
static int stopindexing;
|
32 |
static int startindexing;
|
34 |
static int startindexing;
|
33 |
static bool rezero;
|
35 |
static bool rezero;
|
34 |
static IdxThreadStatus indexingstatus = IDXTS_OK;
|
36 |
static IdxThreadStatus indexingstatus = IDXTS_OK;
|
|
... |
|
... |
77 |
RclConfig *myconf = new RclConfig(*cnf);
|
79 |
RclConfig *myconf = new RclConfig(*cnf);
|
78 |
int loglevel;
|
80 |
int loglevel;
|
79 |
myconf->setKeyDir("");
|
81 |
myconf->setKeyDir("");
|
80 |
myconf->getConfParam("loglevel", &loglevel);
|
82 |
myconf->getConfParam("loglevel", &loglevel);
|
81 |
DebugLog::getdbl()->setloglevel(loglevel);
|
83 |
DebugLog::getdbl()->setloglevel(loglevel);
|
82 |
ConfIndexer *indexer = new ConfIndexer(myconf, this);
|
84 |
|
83 |
if (indexer->index(rezero, ConfIndexer::IxTAll)) {
|
85 |
Pidfile pidfile(myconf->getPidfile());
|
|
|
86 |
if (pidfile.open() != 0) {
|
84 |
indexingstatus = IDXTS_OK;
|
87 |
indexingstatus = IDXTS_ERROR;
|
85 |
indexingReason = "";
|
88 |
indexingReason = "Indexing failed: other process active? " +
|
|
|
89 |
pidfile.getreason();
|
86 |
} else {
|
90 |
} else {
|
|
|
91 |
pidfile.write_pid();
|
|
|
92 |
ConfIndexer *indexer = new ConfIndexer(myconf, this);
|
|
|
93 |
if (indexer->index(rezero, ConfIndexer::IxTAll)) {
|
|
|
94 |
indexingstatus = IDXTS_OK;
|
|
|
95 |
indexingReason = "";
|
|
|
96 |
} else {
|
87 |
indexingstatus = IDXTS_ERROR;
|
97 |
indexingstatus = IDXTS_ERROR;
|
88 |
indexingReason = "Indexing failed: " + indexer->getReason();
|
98 |
indexingReason = "Indexing failed: " + indexer->getReason();
|
|
|
99 |
}
|
|
|
100 |
pidfile.close();
|
|
|
101 |
delete indexer;
|
89 |
}
|
102 |
}
|
90 |
rezero = false;
|
103 |
rezero = false;
|
91 |
delete indexer;
|
|
|
92 |
action_mutex.lock();
|
104 |
action_mutex.lock();
|
93 |
}
|
105 |
}
|
94 |
|
106 |
|
95 |
if (stopidxthread) {
|
107 |
if (stopidxthread) {
|
96 |
action_mutex.unlock();
|
108 |
action_mutex.unlock();
|