diff --git a/src/common/Makefile b/src/common/Makefile index 3fd41e9b..0ecb074c 100644 --- a/src/common/Makefile +++ b/src/common/Makefile @@ -1,5 +1,5 @@ +include ../mk/FreeBSD BIGLIB = ../lib/librcl.a -CXXFLAGS = -Wall -g -I. -I../unac -I../utils -I/usr/local/include PROGS = unacpp textsplit diff --git a/src/index/Makefile b/src/index/Makefile index 9110a867..36f81f6a 100644 --- a/src/index/Makefile +++ b/src/index/Makefile @@ -1,5 +1,5 @@ -CXXFLAGS = -Wall -g -I. -I../utils -I../common -I/usr/local/include +include ../mk/FreeBSD BIGLIB = ../lib/librcl.a diff --git a/src/index/recollindex.cpp b/src/index/recollindex.cpp index e73cc83b..b29ac89a 100644 --- a/src/index/recollindex.cpp +++ b/src/index/recollindex.cpp @@ -1,10 +1,11 @@ #ifndef lint -static char rcsid[] = "@(#$Id: recollindex.cpp,v 1.8 2005-01-31 14:31:09 dockes Exp $ (C) 2004 J.F.Dockes"; +static char rcsid[] = "@(#$Id: recollindex.cpp,v 1.9 2005-02-01 08:42:56 dockes Exp $ (C) 2004 J.F.Dockes"; #endif #include #include +#include "debuglog.h" #include "indexer.h" ConfIndexer *indexer; @@ -34,6 +35,8 @@ int main(int argc, const char **argv) if (signal(SIGTERM, SIG_IGN) != SIG_IGN) signal(SIGTERM, sigcleanup); + DebugLog::getdbl()->setloglevel(DEBDEB1); + DebugLog::setfilename("stderr"); RclConfig config; if (!config.ok()) { fprintf(stderr, "Config could not be built\n"); diff --git a/src/lib/Makefile b/src/lib/Makefile index c1f89c85..40cd5f64 100644 --- a/src/lib/Makefile +++ b/src/lib/Makefile @@ -1,5 +1,4 @@ -CXXFLAGS = -Wall -g -I. -I../index -I../utils -I../common \ - -I../unac -I/usr/local/include +include ../mk/FreeBSD UNACCFLAGS = -g -I. -I../unac -I/usr/local/include -DUNAC_VERSION=\"1.0.7\" diff --git a/src/qtgui/idxthread.cpp b/src/qtgui/idxthread.cpp index edb0ac9b..7f4e684b 100644 --- a/src/qtgui/idxthread.cpp +++ b/src/qtgui/idxthread.cpp @@ -3,6 +3,7 @@ #include "indexer.h" #include "debuglog.h" +#include "idxthread.h" class IdxThread : public QThread { virtual void run(); @@ -11,9 +12,10 @@ class IdxThread : public QThread { }; int startindexing; -int indexingdone; -bool indexingstatus; -int stopidxthread; +int indexingdone = 1; +bool indexingstatus = false; + +static int stopidxthread; void IdxThread::run() { @@ -24,9 +26,10 @@ void IdxThread::run() return; } if (startindexing) { - indexingdone = indexingstatus = startindexing = 0; + indexingdone = indexingstatus = 0; fprintf(stderr, "Index thread :start index\n"); indexingstatus = indexer->index(); + startindexing = 0; indexingdone = 1; } msleep(100); diff --git a/src/qtgui/main.cpp b/src/qtgui/main.cpp index 2b5b6fa0..7c03cb1f 100644 --- a/src/qtgui/main.cpp +++ b/src/qtgui/main.cpp @@ -9,13 +9,12 @@ #include "rcldb.h" #include "rclconfig.h" #include "pathut.h" +#include "recoll.h" RclConfig *rclconfig; Rcl::Db *rcldb; +int recollNeedsExit; -extern void start_idxthread(RclConfig *cnf); -extern void stop_idxthread(); -extern int startindexing; void recollCleanup() { @@ -26,7 +25,6 @@ void recollCleanup() rclconfig = 0; } -int recollNeedsExit; static void sigcleanup(int sig) { diff --git a/src/qtgui/recollmain.ui b/src/qtgui/recollmain.ui index a74e47c1..2ea476b0 100644 --- a/src/qtgui/recollmain.ui +++ b/src/qtgui/recollmain.ui @@ -29,156 +29,157 @@ - layout10 + layout3 - + unnamed - + - layout8 + queryText + + + LineEditPanel + + + Sunken - - - unnamed - - - - queryText - - - LineEditPanel - - - Sunken - - - - - Search - - - Search - - - - - listPrevPb - - - Previous page - - - - - listNextPB - - - Next page - - - - - spacer1 - - - Horizontal - - - Expanding - - - - 346 - 20 - - - - - + - splitter6 + Search + + + Search + + + + + clearqPB + + + Clear + + + Ctrl+S + + + + + listPrevPb + + + Previous page + + + + + listNextPB + + + Next page + + + + + spacer1 Horizontal - - - reslistTE - - - - 5 - 5 - 2 - 0 - - - - RichText - - - true - - - - - splitter5 - - - - 5 - 5 - 5 - 0 - - - - Vertical - - - - previewTextEdit - - - - 7 - 7 - 0 - 4 - - - - RichText - - - true - - - - - metaTextEdit - - - - 7 - 7 - 0 - 1 - - - - RichText - - - true - - - + + Expanding + + + + 346 + 20 + + + + + + + + splitter6 + + + Horizontal + + + + reslistTE + + + + 5 + 5 + 2 + 0 + + + + RichText + + + true + + + + + splitter5 + + + + 5 + 5 + 5 + 0 + + + + Vertical + + + + previewTextEdit + + + + 7 + 7 + 0 + 4 + + + + RichText + + + true + - + + + metaTextEdit + + + + 7 + 7 + 0 + 1 + + + + RichText + + + true + + + @@ -189,6 +190,8 @@ + + @@ -212,6 +215,17 @@ + + + fileStart_IndexingAction + + + Start Indexing + + + Start Indexing + + @@ -256,6 +270,18 @@ RecollMain reslistTE_clicked(int,int) + + fileStart_IndexingAction + activated() + RecollMain + fileStart_IndexingAction_activated() + + + clearqPB + clicked() + RecollMain + clearqPB_clicked() + recollmain.ui.h @@ -267,10 +293,12 @@ fileExit() checkExit() - reslistTE_doubleClicked( int par, int car ) + fileStart_IndexingAction_activated() + reslistTE_doubleClicked( int par, int ) reslistTE_clicked( int par, int car ) queryText_returnPressed() Search_clicked() + clearqPB_clicked() listPrevPB_clicked() listNextPB_clicked() diff --git a/src/qtgui/recollmain.ui.h b/src/qtgui/recollmain.ui.h index ef987e64..af25d4e0 100644 --- a/src/qtgui/recollmain.ui.h +++ b/src/qtgui/recollmain.ui.h @@ -23,24 +23,34 @@ #include "debuglog.h" #include "mimehandler.h" #include "pathut.h" +#include "recoll.h" -extern RclConfig *rclconfig; -extern Rcl::Db *rcldb; - -extern void recollCleanup(); void RecollMain::fileExit() { LOGDEB(("RecollMain: fileExit\n")); exit(0); } -extern int recollNeedsExit; +// Misnomer. This is called on a 100ms timer and actually checks for different +// things apart from a need to exit void RecollMain::checkExit() { + if (indexingstatus) { + indexingstatus = false; + // Make sure we reopen the db to get the results. + fprintf(stderr, "Indexing done: closing query database\n"); + rcldb->close(); + } if (recollNeedsExit) fileExit(); } +void RecollMain::fileStart_IndexingAction_activated() +{ + if (indexingdone == 1) + startindexing = 1; +} + static string plaintorich(const string &in) { string out = "

"; @@ -60,7 +70,7 @@ static string urltolocalpath(string url) } // Use external viewer to display file -void RecollMain::reslistTE_doubleClicked(int par, int car) +void RecollMain::reslistTE_doubleClicked(int par, int) { // restlistTE_clicked(par, car); Rcl::Doc doc; @@ -215,6 +225,10 @@ void RecollMain::Search_clicked() queryText_returnPressed(); } +void RecollMain::clearqPB_clicked() +{ + queryText->clear(); +} static const int respagesize = 10; void RecollMain::listPrevPB_clicked() @@ -307,3 +321,4 @@ void RecollMain::listNextPB_clicked() } } + diff --git a/src/query/Makefile b/src/query/Makefile index 24f82a43..5cd0329c 100644 --- a/src/query/Makefile +++ b/src/query/Makefile @@ -1,5 +1,4 @@ - -CXXFLAGS = -Wall -g -I. -I../index -I../utils -I../common -I/usr/local/include +include ../mk/FreeBSD BIGLIB=../lib/librcl.a diff --git a/src/rcldb/rcldb.cpp b/src/rcldb/rcldb.cpp index 7e5e44a5..b76170ba 100644 --- a/src/rcldb/rcldb.cpp +++ b/src/rcldb/rcldb.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.14 2005-01-31 14:31:09 dockes Exp $ (C) 2004 J.F.Dockes"; +static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.15 2005-02-01 08:42:55 dockes Exp $ (C) 2004 J.F.Dockes"; #endif #include @@ -57,6 +57,7 @@ Rcl::Db::~Db() ndb->iswritable)); if (ndb->isopen == false) return; + string ermsg; try { LOGDEB(("Rcl::Db::~Db: deleting native database\n")); if (ndb->iswritable == true) @@ -64,15 +65,15 @@ Rcl::Db::~Db() delete ndb; return; } catch (const Xapian::Error &e) { - cerr << "Exception: " << e.get_msg() << endl; + ermsg = e.get_msg(); } catch (const string &s) { - cerr << "Exception: " << s << endl; + ermsg = s; } catch (const char *s) { - cerr << "Exception: " << s << endl; + ermsg = s; } catch (...) { - cerr << "Caught unknown exception" << endl; + ermsg = "Caught unknown exception"; } - LOGERR(("Rcl::Db::~Db: got exception\n")); + LOGERR(("Rcl::Db::~Db: got exception: %s\n", ermsg.c_str())); } bool Rcl::Db::open(const string& dir, OpenMode mode) @@ -93,7 +94,11 @@ bool Rcl::Db::open(const string& dir, OpenMode mode) case DbUpd: ndb->wdb = Xapian::WritableDatabase(dir, Xapian::DB_CREATE_OR_OPEN); + LOGDEB(("Rcl::Db::open: lastdocid: %d\n", + ndb->wdb.get_lastdocid())); ndb->updated.resize(ndb->wdb.get_lastdocid() + 1); + for (unsigned int i = 0; i < ndb->updated.size(); i++) + ndb->updated[i] = false; ndb->iswritable = true; break; case DbTrunc: @@ -133,27 +138,27 @@ bool Rcl::Db::close() ndb->iswritable)); if (ndb->isopen == false) return true; + string ermsg; try { - if (ndb->iswritable == true) + if (ndb->iswritable == true) { ndb->wdb.flush(); + LOGDEB(("Called xapian flush\n")); + } delete ndb; + pdata = new Native; + if (pdata) + return true; } catch (const Xapian::Error &e) { - cerr << "Exception: " << e.get_msg() << endl; - return false; + ermsg = e.get_msg(); } catch (const string &s) { - cerr << "Exception: " << s << endl; - return false; + ermsg = s; } catch (const char *s) { - cerr << "Exception: " << s << endl; - return false; + ermsg = s; } catch (...) { - cerr << "Caught unknown exception" << endl; - return false; + ermsg = "Caught unknown exception"; } - - pdata = new Native; - if (pdata) - return true; + LOGERR(("Rcl::Db:close: exception while deleting db: %s\n", + ermsg.c_str())); return false; } @@ -290,9 +295,9 @@ bool Rcl::Db::add(const string &fn, const Rcl::Doc &doc) ndb->wdb.replace_document(pathterm, newdocument); if (did < ndb->updated.size()) { ndb->updated[did] = true; - LOGDEB(("%s updated\n", fnc)); + LOGDEB(("docid %d updated [%s]\n", did, fnc)); } else { - LOGDEB(("%s added\n", fnc)); + LOGDEB(("docid %d added [%s]\n", did, fnc)); } } catch (...) { // FIXME: is this ever actually needed? @@ -318,15 +323,13 @@ bool Rcl::Db::needUpdate(const string &filename, const struct stat *stp) if (did == ndb->wdb.postlist_end(pathterm)) return true; Xapian::Document doc = ndb->wdb.get_document(*did); - if (*did < ndb->updated.size()) - ndb->updated[*did] = true; string data = doc.get_data(); - //cerr << "DOCUMENT EXISTS " << data << endl; const char *cp = strstr(data.c_str(), "mtime="); cp += 6; long mtime = atol(cp); if (mtime >= stp->st_mtime) { - // cerr << "DOCUMENT UP TO DATE" << endl; + if (*did < ndb->updated.size()) + ndb->updated[*did] = true; return false; } } catch (...) { @@ -338,18 +341,31 @@ bool Rcl::Db::needUpdate(const string &filename, const struct stat *stp) bool Rcl::Db::purge() { + LOGDEB(("Rcl::Db::purge\n")); + // There seems to be problems with the document delete code, when + // we do this, the database is not actually updated. Especially, + // if we delete a bunch of docs, so that there is a hole in the + // docids at the beginning, we can't add anything (appears to work + // and does nothing). Maybe related to the exceptions below when + // trying to delete an unexistant document ? + // Flushing before trying the deletes seeems to work around the problem + if (pdata == 0) return false; Native *ndb = (Native *)pdata; + LOGDEB(("Rcl::Db::purge: isopen %d iswritable %d\n", ndb->isopen, + ndb->iswritable)); if (ndb->isopen == false || ndb->iswritable == false) return false; + ndb->wdb.flush(); for (Xapian::docid did = 1; did < ndb->updated.size(); ++did) { if (!ndb->updated[did]) { try { ndb->wdb.delete_document(did); LOGDEB(("Rcl::Db::purge: deleted document #%d\n", did)); } catch (const Xapian::DocNotFoundError &) { + LOGDEB(("Rcl::Db::purge: document #%d not found\n", did)); } } } diff --git a/src/utils/Makefile b/src/utils/Makefile index 0abd1e27..92200367 100644 --- a/src/utils/Makefile +++ b/src/utils/Makefile @@ -1,5 +1,4 @@ - -CXXFLAGS = -I. -g +include ../mk/FreeBSD BIGLIB = ../lib/librcl.a