ensured compatibility with kde4.0

This commit is contained in:
dockes 2008-11-28 09:14:42 +00:00
parent a494eddb92
commit ae77b9fb99
7 changed files with 62 additions and 34 deletions

View File

@ -115,6 +115,13 @@ kde4_add_plugin(kio_recoll ${kio_recoll_SRCS})
target_link_libraries(kio_recoll xapian ${EXTRA_LIBS} ${KDE4_KIO_LIBS})
install(TARGETS kio_recoll DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES recoll.protocol DESTINATION ${SERVICES_INSTALL_DIR})
IF ("${KDE_VERSION_MAJOR}.${KDE_VERSION_MINOR}" GREATER 4.0)
install(FILES recoll.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
DESTINATION ${DATA_INSTALL_DIR}/kio_recoll)

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: dirif.cpp,v 1.2 2008-11-27 17:48:43 dockes Exp $ (C) 2008 J.F.Dockes";
static char rcsid[] = "@(#$Id: dirif.cpp,v 1.3 2008-11-28 09:14:42 dockes Exp $ (C) 2008 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -27,6 +27,12 @@ static char rcsid[] = "@(#$Id: dirif.cpp,v 1.2 2008-11-27 17:48:43 dockes Exp $
* Stephan Binner <binner@kde.org>
*/
#include <kdeversion.h>
#if KDE_IS_VERSION(4,1,0)
// Couldn't get listDir() to work with kde 4.0, konqueror keeps
// crashing because of kdirmodel, couldn't find a workaround (not
// saying it's impossible)...
#include <sys/stat.h>
#include <kurl.h>
@ -34,11 +40,27 @@ static char rcsid[] = "@(#$Id: dirif.cpp,v 1.2 2008-11-27 17:48:43 dockes Exp $
#include <kdebug.h>
#include "kio_recoll.h"
using namespace KIO;
void RecollProtocol::stat(const KUrl & url)
{
kDebug() << url << endl ;
QString path = url.path();
KIO::UDSEntry entry;
if (!path.compare("/"))
entry.insert(KIO::UDSEntry::UDS_NAME, "/welcome");
else
entry.insert(KIO::UDSEntry::UDS_NAME, url.path());
entry.insert(KIO::UDSEntry::UDS_TARGET_URL, url.url());
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
statEntry(entry);
finished();
}
const UDSEntry resultToUDSEntry(Rcl::Doc doc)
{
@ -72,22 +94,6 @@ const UDSEntry resultToUDSEntry(Rcl::Doc doc)
}
void RecollProtocol::stat(const KUrl & url)
{
kDebug() << url << endl ;
QString path = url.path();
KIO::UDSEntry entry;
if (!path.compare("/"))
entry.insert(KIO::UDSEntry::UDS_NAME, "/welcome");
else
entry.insert(KIO::UDSEntry::UDS_NAME, url.path());
entry.insert(KIO::UDSEntry::UDS_TARGET_URL, url.url());
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
statEntry(entry);
finished();
}
// From kio_beagle
void RecollProtocol::createRootEntry(KIO::UDSEntry& entry)
{
@ -172,3 +178,4 @@ void RecollProtocol::listDir(const KUrl& url)
listEntries(entries);
finished();
}
#endif // KDE 4.1+

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: kio_recoll.cpp,v 1.17 2008-11-27 17:48:43 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: kio_recoll.cpp,v 1.18 2008-11-28 09:14:42 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -119,11 +119,7 @@ bool RecollProtocol::maybeOpenDb(string &reason)
void RecollProtocol::mimetype(const KUrl &url)
{
kDebug() << url << endl;
#ifdef USEDIRMODEL
mimeType("inode/directory");
#else
mimeType("text/html");
#endif
mimeType("text/html");
finished();
}
@ -154,17 +150,14 @@ void RecollProtocol::get(const KUrl & url)
error(KIO::ERR_SLAVE_DEFINED, reason.c_str());
return;
}
#ifdef USEDIRMODEL
error(KIO::ERR_IS_DIRECTORY, QString::null);
return;
#endif
QString host = url.host();
QString path = url.path();
kDebug() << "host:" << host << " path:" << path;
if (host.isEmpty() && (!path.compare("/")||!path.compare("/welcome"))) {
if (host.isEmpty() &&
(path.isEmpty() || !path.compare("/")||!path.compare("/welcome"))) {
// recoll:/
welcomePage();
goto out;

View File

@ -1,5 +1,5 @@
#ifndef _RECOLL_H
/* @(#$Id: kio_recoll.h,v 1.8 2008-11-27 17:48:43 dockes Exp $ (C) 2005 J.F.Dockes */
/* @(#$Id: kio_recoll.h,v 1.9 2008-11-28 09:14:42 dockes Exp $ (C) 2005 J.F.Dockes */
#define _RECOLL_H
/*
* This program is free software; you can redistribute it and/or modify
@ -32,6 +32,7 @@ using std::string;
#include <kurl.h>
#include <kio/global.h>
#include <kio/slavebase.h>
#include <kdeversion.h>
#include "rclconfig.h"
#include "rcldb.h"
@ -62,8 +63,10 @@ class RecollProtocol : public KIO::SlaveBase {
virtual ~RecollProtocol();
virtual void mimetype(const KUrl & url );
virtual void get(const KUrl & url );
#if KDE_IS_VERSION(4,1,0)
virtual void stat(const KUrl & url);
virtual void listDir(const KUrl& url);
#endif
static RclConfig *o_rclconfig;

View File

@ -26,3 +26,11 @@ Output to ~/.xession-errors par defaut controle ?
Probleme quand l'url se termine par un / et qu'on edite le mot,
konqueror lance une recherche a chaque lettre.
Apparemment c'est l'entree "listing" du .protocol qui decide si le plugin
est traité plutot comme un dirlister ou comme un htmlgetter. Curieusement,
le changement ne s'opere pas toujours immediatement quand on change le
fichier .proto, y compris apres avoir tue tous les process kde (changement
à la deuxieme execution de konqueror sur kde4.0). Sur kde4.0 il faut que le
.proto soit sans entree "listing"

View File

@ -5,8 +5,7 @@ input=none
output=filesystem
listing=Name,Type, URL
reading=true
#defaultMimeType=inode/directory
defaultMimeType=text/html
Icon=help_index
Icon=recoll
Class=:local
URIMode=rawuri

View File

@ -0,0 +1,11 @@
[Protocol]
exec=kio_recoll
protocol=recoll
input=none
output=filesystem
# Version for kde4.0: no "listing" entry
reading=true
defaultMimeType=text/html
Icon=recoll
Class=:local
URIMode=rawuri