diff --git a/src/kde/kioslave/kio_recoll-kde4/00README.txt b/src/kde/kioslave/kio_recoll-kde4/00README.txt new file mode 100644 index 00000000..933b73b7 --- /dev/null +++ b/src/kde/kioslave/kio_recoll-kde4/00README.txt @@ -0,0 +1,94 @@ +Recoll KIO slave +================ + +An experiment with a recoll KIO slave. + +Caveat: I am only currently testing this with a production, but very +recent, version of KDE 4.1, and I don't intend to really support +older versions. The most usable aspects work under KDE 4.0 though. As +a reference, my test system is an up to date (2009-01) Kubuntu 8.10. + +Usage +===== + +Depending on the protocol name used, the search results will be +returned either as HTML pages (looking quite like a normal Recoll +result list), or as directory entries. + +The HTML mode only works with Konqueror, not Dolphin. The directory +mode is available with both browsers, and also application open dialog +(ie Kate). + +The HTML mode is much more usable than the directory mode at this point + +More detailed help/explanations can be found a document accessible +from the slave: + +To try things out, after building and installing, enter "recoll:/" in +a Konqueror URL entry. Depending on the KDE version, this will bring +you either to an HTML search form, or to a directory listing, where +you should READ THE HELP FILE. + +Building and installing: +======================= + +Only tested with KDE 4.1 and later. + +The main Recoll installation shares its prefix with the KIO slave, +which needs to use the KDE one. This means that, if KDE lives in /usr, +Recoll must be configured with --prefix=/usr, not /usr/local. Else +you'll have run-time problems, the slave will not be able to find the +Recoll configuration. + +!!*Notice: You cannot share a build directory between recoll and kio_recoll +because they use different configure options for the main lib, but build it +in the same place. The main lib "configure" is run at "cmake" time for +kio_recoll, the build is done at "make" time. + + +Recipe: + - Make sure the KDE4 core devel packages and cmake are installed. + + - Extract the Recoll source. + + - IF Recoll is not installed yet: configure recoll with + --prefix=/usr (or wherever KDE lives), build and install + Recoll. + + - In the Recoll source, go to kde/kioslave/recoll, then build and + install the kio slave: + +mkdir builddir +cd builddir +cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DQT_QMAKE_EXECUTABLE=/usr/bin/qmake-qt4 +make +sudo make install + + - You should have a look at where "make install" copies things, + because misconfigured distribution, generating wrong targets, are + frequent. Especially, you should check that kio_recoll.so is copied + to the right place, meaning among the output of "kde4-config --path + module". As an additional check, there should be many other + kio_[xxx].so in there. Same for the protocol file, check that it's + not alone in its directory (really, this sounds strange, but, to + this point, I've seen more systems with broken cmake/KDE configs + than correct ones). + +You need to build/update the index with recollindex, the KIO slave +doesn't deal with indexing for now. + + +Misc build problems: +=================== + +KUBUNTU 8.10 (updated to 2008-27-11) +------------------------------------ +cmake generates a bad dependancy on + /build/buildd/kde4libs-4.1.2/obj-i486-linux-gnu/lib/libkdecore.so +inside CMakeFiles/kio_recoll.dir/build.make + +Found no way to fix this. You need to edit the line and replace the +/build/[...]/lib with /usr/lib. This manifests itself with the +following error message: + + make[2]: *** No rule to make target `/build/buildd/kde4libs-4.1.2/obj-i486-linux-gnu/lib/libkdecore.so', needed by `lib/kio_recoll.so'. Stop. diff --git a/src/kde/kioslave/kio_recoll-kde4/CMakeLists.txt b/src/kde/kioslave/kio_recoll-kde4/CMakeLists.txt new file mode 100644 index 00000000..c8dbd240 --- /dev/null +++ b/src/kde/kioslave/kio_recoll-kde4/CMakeLists.txt @@ -0,0 +1,75 @@ +cmake_minimum_required(VERSION 2.6) + +project(kio_recoll) + +find_package(KDE4 REQUIRED) + +add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS}) +add_definitions(-DKDE_DEFAULT_DEBUG_AREA=7130 + -DRECOLL_DATADIR=\\"${CMAKE_INSTALL_PREFIX}/share/recoll\\" + -DLIBDIR=\\"${CMAKE_INSTALL_PREFIX}/lib\\" + -DHAVE_CONFIG_H +) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDE4_ENABLE_EXCEPTIONS}") + +set(rcltop ${CMAKE_CURRENT_SOURCE_DIR}/../../../) + +# Execute recoll configuration to create autoconfig.h and version.h and +# generate a PIC lib +execute_process(COMMAND ${rcltop}/configure --disable-static --disable-qtgui --disable-x11mon --prefix=${CMAKE_INSTALL_PREFIX} --mandir=${CMAKE_INSTALL_PREFIX}/share/man + WORKING_DIRECTORY ${rcltop} +) + +link_directories(${rcltop}/.libs ${CMAKE_INSTALL_PREFIX}/lib) + +include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES} + ${rcltop}/aspell + ${rcltop}/bincimapmime + ${rcltop}/common + ${rcltop}/index + ${rcltop}/internfile + ${rcltop}/query + ${rcltop}/rcldb + ${rcltop}/unac + ${rcltop}/utils + ${rcltop}/qtgui +) + +set(kio_recoll_SRCS kio_recoll.cpp htmlif.cpp dirif.cpp ${rcltop}/qtgui/guiutils.cpp) + +CHECK_LIBRARY_EXISTS(dl dlopen "" DLOPEN_IN_LIBDL) +IF(DLOPEN_IN_LIBDL) + LIST(APPEND EXTRA_LIBS dl) +ENDIF(DLOPEN_IN_LIBDL) +CHECK_LIBRARY_EXISTS(pthread pthread_sigmask "" PTHREAD_IN_LIBPTHREAD) +IF(PTHREAD_IN_LIBPTHREAD) + LIST(APPEND EXTRA_LIBS pthread) +ENDIF(PTHREAD_IN_LIBPTHREAD) + +# Had the idea to add e.g. /usr/lib/recoll to the rpath so that the dyn lib +# will be found at run time. But this does not seem to work with debian +# which strips RPATH by default (I think there is a way for libs in app-specific +# paths but I did not find it). Link with the .a instead. +#SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib/recoll") + +kde4_add_plugin(kio_recoll ${kio_recoll_SRCS}) + +add_custom_target(rcllib + COMMAND make PicStatic + WORKING_DIRECTORY ${rcltop} +) +add_dependencies(kio_recoll rcllib) + +target_link_libraries(kio_recoll recoll xapian z ${EXTRA_LIBS} ${KDE4_KIO_LIBS}) + +install(TARGETS kio_recoll DESTINATION ${PLUGIN_INSTALL_DIR}) + +IF ("${KDE_VERSION_MAJOR}.${KDE_VERSION_MINOR}" GREATER 4.0) + install(FILES recoll.protocol recollf.protocol DESTINATION ${SERVICES_INSTALL_DIR}) +ELSE ("${KDE_VERSION_MAJOR}.${KDE_VERSION_MINOR}" GREATER 4.0) + install(FILES recollnolist.protocol DESTINATION ${SERVICES_INSTALL_DIR} + RENAME recoll.protocol) +ENDIF ("${KDE_VERSION_MAJOR}.${KDE_VERSION_MINOR}" GREATER 4.0) + +install(FILES data/welcome.html data/help.html + DESTINATION ${DATA_INSTALL_DIR}/kio_recoll) diff --git a/src/kde/kioslave/kio_recoll-kde4/Makefile.kde3 b/src/kde/kioslave/kio_recoll-kde4/Makefile.kde3 new file mode 100644 index 00000000..634087f7 --- /dev/null +++ b/src/kde/kioslave/kio_recoll-kde4/Makefile.kde3 @@ -0,0 +1,59 @@ +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$(KDE_INCLUDES) -I$(QT_INCLUDES) \ + -I$(depth)/common -I$(depth)/query -I$(depth)/utils \ + -I$(depth)/qtgui -I$(depth)/rcldb + +PIC_CXXFLAGS = -fPIC -DPIC +DEBUG_CXXFLAGS = -DNDEBUG -DNO_DEBUG -O2 -O +LANG_CXXFLAGS = -fno-exceptions -fno-check-new -fno-common +QT_CXXFLAGS = -DQT_CLEAN_NAMESPACE -DQT_NO_ASCII_CAST -DQT_NO_STL \ + -DQT_NO_COMPAT -DQT_NO_TRANSLATION -DQT_THREAD_SUPPORT +SYS_CXXFLAGS = -D_GNU_SOURCE +THREAD_CXXFLAGS = -D_THREAD_SAFE -pthread -D_THREAD_SAFE -pthread + + +# -rpath=/usr/lib:/usr/local/lib \ + +LDFLAGS = \ + -Wl,--rpath -Wl,/usr/local/lib \ + -Wl,--rpath -Wl,/usr/X11R6/lib \ + -Wl,-export-dynamic -Wl,-soname -Wl,kio_recoll.so +THREAD_LDFLAGS = -pthread + +kio_recoll.so : kio_recoll.o libpic + c++ -shared $(LDFLAGS) $(THREAD_LDFLAGS) \ + -Wl,--no-undefined \ + kio_recoll.o piclib/librcl.a \ + $(LIBXAPIAN) $(LIBICONV) \ + -L/opt/kde3/lib -L/usr/local/lib -L/usr/X11R6/lib -lkio -lkdecore \ + -L/usr/lib/qt3/lib -lqt-mt \ + -L/usr/lib -lstdc++ -lm -lc \ + -o kio_recoll.so + +kio_recoll.o : kio_recoll.cpp kio_recoll.h + $(CXX) -c -pipe kio_recoll.cpp $(INC_CXXFLAGS) $(PIC_CXXFLAGS) \ + $(DEBUG_CXXFLAGS) $(LANG_CXXFLAGS) $(QT_CXXFLAGS) $(SYS_CXXFLAGS) \ + $(THREAD_CXXFLAGS) \ + -o kio_recoll.o + +libpic: + cd piclib;test -f Makefile || depth=$(depth)/.. sh $(depth)/../lib/mkMake + cd piclib;$(MAKE) CXXFLAGS="$(CXXFLAGS) $(PIC_CXXFLAGS)" \ + CFLAGS="$(CFLAGS) $(PIC_CXXFLAGS)" + +.PHONY: all libpic diff --git a/src/kde/kioslave/kio_recoll-kde4/cleancmakestuff.sh b/src/kde/kioslave/kio_recoll-kde4/cleancmakestuff.sh new file mode 100644 index 00000000..52176afe --- /dev/null +++ b/src/kde/kioslave/kio_recoll-kde4/cleancmakestuff.sh @@ -0,0 +1,6 @@ +#!/bin/sh +rm -rf CMakeCache.txt CMakeFiles CTestTestfile.cmake \ + cmake_install.cmake CMakeTmp cmake_uninstall.cmake \ + CPackConfig.cmake CPackSourceConfig.cmake DartTestfile.txt \ + install_manifest.txt kio_recoll_automoc.cpp \ + kio_recoll_automoc.cpp.files kio_recoll.so lib Makefile diff --git a/src/kde/kioslave/kio_recoll-kde4/data/help.html b/src/kde/kioslave/kio_recoll-kde4/data/help.html new file mode 100644 index 00000000..689cbdf8 --- /dev/null +++ b/src/kde/kioslave/kio_recoll-kde4/data/help.html @@ -0,0 +1,100 @@ + +
+ +Use this module to perform Recoll searches from any program with + a KIO interface.
+ +The module can work in two modes:
+The module is still in its infancy. You will undoubtedly obtain + strange effects from time to time. If you have any remarks or + ideas about improving kio_recoll, or observe an interesting and + reproducible sequence, please + report it.
+kio_recoll is primarily + designed and tested with konqueror, and you will + undoubtedly get even more surprising effects with other tools.
+ +The Html interface is currently much more usable. The directory + interface is extremely quirky.
+ +The module is particularly unhelpful with search hits inside + email folders, which Konqueror has no way to access.
+ + +This works more or less like the Recoll QT GUI, much simplified. The + + Recoll manual describes the queries that can be performed.
+ +Most pages in the interface should quite self-explanatory.
+ +You normally enter this interface by entering "recoll:" or
+ "recoll:/" in the Konqueror URL entry, and following the "search"
+ link. You can also directly enter "recoll:/search.html".
+
+ In most circumstances, entering a link like
+ recoll:/john smith will also
+ yield an HTML result list.
Compared to QT Recoll, the nice point is that you can click or + drag/drop the icons to access the results in the standard desktop + way.
+ +The path part of the URI is taken as a Recoll query + language string and executed. The results are displayed as + directory entries.
+ +There are several ways to enter this interface:
++ + recoll:/red apples ext:html/ ++
RECOLL_KIO_ALWAYS_DIR
environment
+ variable or the kio_always_dir
recoll.conf variable
+ to 1. The HTML interface will then only be accessible
+ through the search link in the top "recoll:" view.No search result details (samples, relevance etc.) are available, + but this interface allows multiple selections and copies, usage + inside any KDE open dialog, etc.
+ +To avoid swamping the interface with thousands of results, the
+ result count is limited to 100 by default. You can change this value
+ by setting the kio_max_direntries
parameter in your recoll
+ configuration file (typically ~/.recoll/recoll.conf)
Because of limitations in the current KIO slave usage, the actual + entry names are not those displayed but synthetic ones like + "recollResultxxx". This has unfortunate side-effects when + dragging/dropping the entries to some other application, or when + using an open dialog (the opened file doesn't have the correct path + to the original file).
+ + + + + diff --git a/src/kde/kioslave/kio_recoll-kde4/data/searchable.html b/src/kde/kioslave/kio_recoll-kde4/data/searchable.html new file mode 100644 index 00000000..6e44f269 --- /dev/null +++ b/src/kde/kioslave/kio_recoll-kde4/data/searchable.html @@ -0,0 +1,28 @@ + + +This is a text sample in which links have been inserted for + words, such as system installation, + which can be searched for in the whole document set by + using recoll
+ +Also a little bit of javascript magic can make + all words searchable (try double-clicking any word).
+ + + diff --git a/src/kde/kioslave/kio_recoll-kde4/data/welcome.html b/src/kde/kioslave/kio_recoll-kde4/data/welcome.html new file mode 100644 index 00000000..0f13d428 --- /dev/null +++ b/src/kde/kioslave/kio_recoll-kde4/data/welcome.html @@ -0,0 +1,29 @@ + + + ++
+ + + + diff --git a/src/kde/kioslave/kio_recoll-kde4/dirif.cpp b/src/kde/kioslave/kio_recoll-kde4/dirif.cpp new file mode 100644 index 00000000..07d89ed8 --- /dev/null +++ b/src/kde/kioslave/kio_recoll-kde4/dirif.cpp @@ -0,0 +1,318 @@ +/* Copyright (C) 2008 J.F.Dockes + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/* + * A lot of code in this file was copied from kio_beagle 0.4.0, + * which is a GPL program. The authors listed are: + * Debajyoti Beram_query.query.toUtf8())); + pt += "\">New Search"; + return pt; +// Would be nice to have but doesnt work because the query may be executed +// by another kio instance which has no idea of the current page o +#if 0 && KDE_IS_VERSION(4,1,0) + " m_query.query.toUtf8())) + + "/\">Directory view (you may need to reload the page)" +#endif +} + +string RecollKioPager::nextUrl() +{ + int pagenum = pageNumber(); + if (pagenum < 0) + pagenum = 0; + else + pagenum++; + return m_parent->makeQueryUrl(pagenum); +} + +string RecollKioPager::prevUrl() +{ + int pagenum = pageNumber(); + if (pagenum <= 0) + pagenum = 0; + else + pagenum--; + return m_parent->makeQueryUrl(pagenum); +} + +static string welcomedata; + +void RecollProtocol::searchPage() +{ + mimeType("text/html"); + if (welcomedata.empty()) { + QString location = + KStandardDirs::locate("data", "kio_recoll/welcome.html"); + string reason; + if (location.isEmpty() || + !file_to_string((const char *)location.toUtf8(), + welcomedata, &reason)) { + welcomedata = "
Could not locate Recoll welcome.html file: "; + welcomedata += reason; + welcomedata += "
"; + } + } + + string catgq; +#if 0 + // Catg filtering. A bit complicated to do because of the + // stateless thing (one more thing to compare to check if same + // query) right now. Would be easy by adding to the query + // language, but not too useful in this case, so scrap it for now. + listFilter on types: "
+ "All";
+ for (list " << m_pager.queryDescription().c_str() <<" Return to results" << endl;
+ os << "" << endl;
+ data(array);
+}
+
+class PlainToRichKio : public PlainToRich {
+public:
+ PlainToRichKio(const string& nm)
+ : m_name(nm)
+ {
+ }
+
+ virtual string header() {
+ if (m_inputhtml) {
+ return cstr_null;
+ } else {
+ return string("Query details:
" << endl;
+ os << "");
+ }
+ }
+
+ virtual string startMatch(unsigned int)
+ {
+ return string("");
+ }
+
+ virtual string endMatch()
+ {
+ return string("");
+ }
+
+ const string &m_name;
+};
+
+void RecollProtocol::showPreview(const Rcl::Doc& idoc)
+{
+ FileInterner interner(idoc, o_rclconfig, FileInterner::FIF_forPreview);
+ Rcl::Doc fdoc;
+ string ipath = idoc.ipath;
+ if (!interner.internfile(fdoc, ipath)) {
+ error(KIO::ERR_SLAVE_DEFINED, "Cannot convert file to internal format");
+ return;
+ }
+ if (!interner.get_html().empty()) {
+ fdoc.text = interner.get_html();
+ fdoc.mimetype = "text/html";
+ }
+
+ mimeType("text/html");
+
+ string fname = path_getsimple(fdoc.url).c_str();
+ PlainToRichKio ptr(fname);
+ ptr.set_inputhtml(!fdoc.mimetype.compare("text/html"));
+ list