From 484c5db4e971a3e46c7173d7931756a71b893ed4 Mon Sep 17 00:00:00 2001 From: dockes Date: Thu, 13 Nov 2008 10:57:46 +0000 Subject: [PATCH] got the kio_slave working again --- src/kde/kioslave/recoll/00README.txt | 13 ++++++------ src/kde/kioslave/recoll/Makefile | 11 ++++++++-- src/kde/kioslave/recoll/kio_recoll.cpp | 29 +++++++++++++++----------- src/kde/kioslave/recoll/kio_recoll.la | 2 +- src/query/docseqdb.cpp | 5 +++-- 5 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/kde/kioslave/recoll/00README.txt b/src/kde/kioslave/recoll/00README.txt index 89ded2a1..7e7c8c7e 100644 --- a/src/kde/kioslave/recoll/00README.txt +++ b/src/kde/kioslave/recoll/00README.txt @@ -20,11 +20,10 @@ Implementation notes: - You MUST install a kio_recoll.la in lib/kde3 along with kio_recoll.so, else kdeinit won't be able to load the lib (probably uses the libltdl - crap?). The one in this directory was duplicated/adjusted from - kio_man.la + thingy?). The one in this directory was duplicated/adjusted from + kio_man.la. The contents don't seem too critical, just needs to exist. -- The current implementation always tries to retrieve 100 docs (doesn't - even stop if there are less). It would probably be easy to add state and +- Currently retrieves all results on one page. Need to add state and previous/next buttons. As I didn't find this thing to be particularly useful, I didn't bothered to. @@ -35,5 +34,7 @@ Implementation notes: wherever kde keeps its plugins (ie: lib/kde3), and recoll.protocol in the services directory (share/services ? look for other .protocol file). -- I saw after doing the build/config mockup that kdevelop can generate a kio_slave project. This would certainly be the next thing to do. - +- I saw after doing the build/config mockup that kdevelop can generate a + kio_slave project. This might be the next thing to do. otoh would need to + separate the kio from the main source to avoid having to distribute 2megs + of kde build config files. diff --git a/src/kde/kioslave/recoll/Makefile b/src/kde/kioslave/recoll/Makefile index 50934411..634087f7 100644 --- a/src/kde/kioslave/recoll/Makefile +++ b/src/kde/kioslave/recoll/Makefile @@ -1,13 +1,20 @@ depth=../../.. include $(depth)/mk/sysconf +# Need to set this by hand until we decide how to autoconf this without +# bringing 2mbytes of kde config files. +# May also need to adjust stuff such as the --rpath's below +# +KDE_INCLUDES=/usr/include/kde +QT_INCLUDES=/usr/include/qt3 + + all: kio_recoll.so DEPS_CXXFLAGS = -MT pop3.lo -MD -MP -MF .deps/pop3.Tpo INC_CXXFLAGS = -I. \ - -I/usr/local/include -I/usr/X11R6/include \ - -I/opt/kde3/include -I$(QTDIR)/include \ + -I$(KDE_INCLUDES) -I$(QT_INCLUDES) \ -I$(depth)/common -I$(depth)/query -I$(depth)/utils \ -I$(depth)/qtgui -I$(depth)/rcldb diff --git a/src/kde/kioslave/recoll/kio_recoll.cpp b/src/kde/kioslave/recoll/kio_recoll.cpp index b960dbc7..a1408ba3 100644 --- a/src/kde/kioslave/recoll/kio_recoll.cpp +++ b/src/kde/kioslave/recoll/kio_recoll.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: kio_recoll.cpp,v 1.10 2008-09-29 11:33:55 dockes Exp $ (C) 2005 J.F.Dockes"; +static char rcsid[] = "@(#$Id: kio_recoll.cpp,v 1.11 2008-11-13 10:57:46 dockes Exp $ (C) 2005 J.F.Dockes"; #endif #include @@ -21,7 +21,8 @@ using namespace std; #include "docseqdb.h" #include "pathut.h" #include "searchdata.h" - +#include "wasastringtoquery.h" +#include "wasatorcl.h" #include "plaintorich.h" #include "kio_recoll.h" @@ -75,8 +76,7 @@ bool RecollProtocol::maybeOpenDb(string &reason) } if (!m_rcldb->isopen() && !m_rcldb->open(m_dbdir, m_rclconfig->getStopfile(), - Rcl::Db::DbRO, - Rcl::Db::QO_STEM)) { + Rcl::Db::DbRO)) { reason = "Could not open database in " + m_dbdir; return false; } @@ -106,23 +106,23 @@ void RecollProtocol::get(const KURL & url) fprintf(stderr, "RecollProtocol::get:path [%s]\n", path.latin1()); QCString u8 = path.utf8(); - RefCntr sdata(new Rcl::SearchData(Rcl::SCLT_OR)); - sdata->addClause(new Rcl::SearchDataClauseSimple(Rcl::SCLT_AND, - (const char *)u8)); - Rcl::Query *query = new Rcl::Query(m_rcldb); + RefCntr sdata = wasaStringToRcl((const char*)u8, m_reason); + sdata->setStemlang("english"); + + RefCntrquery(new Rcl::Query(m_rcldb)); if (!query->setQuery(sdata)) { m_reason = "Internal Error: setQuery failed"; outputError(m_reason.c_str()); finished(); - delete query; return; } if (m_docsource) delete m_docsource; - m_docsource = new DocSequenceDb(RefCntr(query), - "Query results", sdata); + m_docsource = new DocSequenceDb(query, "Query results", sdata); + + string explain = m_docsource->getDescription(); QByteArray output; QTextStream os(output, IO_WriteOnly ); @@ -134,8 +134,13 @@ void RecollProtocol::get(const KURL & url) os << "Recoll: query results" << endl; os << "" << endl; + // outputError("EXPLAINING"); + os << "

Actual query performed: " << endl; + os << explain.c_str() << "

"; + Rcl::Doc doc; - for (int i = 0; i < 100; i++) { + int cnt = query->getResCnt(); + for (int i = 0; i < cnt; i++) { string sh; doc.erase(); diff --git a/src/kde/kioslave/recoll/kio_recoll.la b/src/kde/kioslave/recoll/kio_recoll.la index 3078ac0a..9fcc2454 100755 --- a/src/kde/kioslave/recoll/kio_recoll.la +++ b/src/kde/kioslave/recoll/kio_recoll.la @@ -32,4 +32,4 @@ dlopen='' dlpreopen='' # Directory that this library needs to be installed in: -libdir='/usr/local/lib/kde3' +libdir='/usr/lib/kde3' diff --git a/src/query/docseqdb.cpp b/src/query/docseqdb.cpp index d2e2d612..0e677bc4 100644 --- a/src/query/docseqdb.cpp +++ b/src/query/docseqdb.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: docseqdb.cpp,v 1.8 2008-09-29 11:33:55 dockes Exp $ (C) 2005 J.F.Dockes"; +static char rcsid[] = "@(#$Id: docseqdb.cpp,v 1.9 2008-11-13 10:57:46 dockes Exp $ (C) 2005 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -26,7 +26,8 @@ static char rcsid[] = "@(#$Id: docseqdb.cpp,v 1.8 2008-09-29 11:33:55 dockes Exp DocSequenceDb::DocSequenceDb(RefCntr q, const string &t, RefCntr sdata) - : DocSequence(t), m_q(q), m_sdata(sdata), m_rescnt(-1), m_filt(false) + : DocSequence(t), m_q(q), m_sdata(sdata), m_fsdata(sdata), + m_rescnt(-1), m_filt(false) { }