kde kioslave: fix for new wasaToRcl shared_ptr interface. Misc warnings suppression

This commit is contained in:
Jean-Francois Dockes 2020-12-28 14:20:33 +01:00
parent 3c7e3ccbc7
commit 663da54c04
7 changed files with 249 additions and 251 deletions

View File

@ -55,25 +55,25 @@ RecollProtocol::RecollProtocol(const QByteArray &pool, const QByteArray &app)
{ {
kDebug() << endl; kDebug() << endl;
if (o_rclconfig == 0) { if (o_rclconfig == 0) {
o_rclconfig = recollinit(0, 0, 0, m_reason); o_rclconfig = recollinit(0, 0, 0, m_reason);
if (!o_rclconfig || !o_rclconfig->ok()) { if (!o_rclconfig || !o_rclconfig->ok()) {
m_reason = string("Configuration problem: ") + m_reason; m_reason = string("Configuration problem: ") + m_reason;
return; return;
} }
} }
if (o_rclconfig->getDbDir().empty()) { if (o_rclconfig->getDbDir().empty()) {
// Note: this will have to be replaced by a call to a // Note: this will have to be replaced by a call to a
// configuration building dialog for initial configuration? Or // configuration building dialog for initial configuration? Or
// do we assume that the QT GUO is always used for this ? // do we assume that the QT GUO is always used for this ?
m_reason = "No db directory in configuration ??"; m_reason = "No db directory in configuration ??";
return; return;
} }
rwSettings(false); rwSettings(false);
m_rcldb = std::shared_ptr<Rcl::Db>(new Rcl::Db(o_rclconfig)); m_rcldb = std::shared_ptr<Rcl::Db>(new Rcl::Db(o_rclconfig));
if (!m_rcldb) { if (!m_rcldb) {
m_reason = "Could not build database object. (out of memory ?)"; m_reason = "Could not build database object. (out of memory ?)";
return; return;
} }
// Decide if we allow switching between html and file manager // Decide if we allow switching between html and file manager
@ -81,9 +81,9 @@ RecollProtocol::RecollProtocol(const QByteArray &pool, const QByteArray &app)
// by switching proto names. // by switching proto names.
const char *cp = getenv("RECOLL_KIO_ALWAYS_DIR"); const char *cp = getenv("RECOLL_KIO_ALWAYS_DIR");
if (cp) { if (cp) {
m_alwaysdir = stringToBool(cp); m_alwaysdir = stringToBool(cp);
} else { } else {
o_rclconfig->getConfParam("kio_always_dir", &m_alwaysdir); o_rclconfig->getConfParam("kio_always_dir", &m_alwaysdir);
} }
cp = getenv("RECOLL_KIO_STEMLANG"); cp = getenv("RECOLL_KIO_STEMLANG");
@ -107,12 +107,12 @@ RecollProtocol::~RecollProtocol()
bool RecollProtocol::maybeOpenDb(string &reason) bool RecollProtocol::maybeOpenDb(string &reason)
{ {
if (!m_rcldb) { if (!m_rcldb) {
reason = "Internal error: initialization error"; reason = "Internal error: initialization error";
return false; return false;
} }
if (!m_rcldb->isopen() && !m_rcldb->open(Rcl::Db::DbRO)) { if (!m_rcldb->isopen() && !m_rcldb->open(Rcl::Db::DbRO)) {
reason = "Could not open database in " + o_rclconfig->getDbDir(); reason = "Could not open database in " + o_rclconfig->getDbDir();
return false; return false;
} }
return true; return true;
} }
@ -133,75 +133,75 @@ UrlIngester::UrlIngester(RecollProtocol *p, const KUrl& url)
m_alwaysdir = !url.protocol().compare("recollf"); m_alwaysdir = !url.protocol().compare("recollf");
QString path = url.path(); QString path = url.path();
if (url.host().isEmpty()) { if (url.host().isEmpty()) {
if (path.isEmpty() || !path.compare("/")) { if (path.isEmpty() || !path.compare("/")) {
m_type = UIMT_ROOTENTRY; m_type = UIMT_ROOTENTRY;
m_retType = UIRET_ROOT; m_retType = UIRET_ROOT;
return; return;
} else if (!path.compare("/help.html")) { } else if (!path.compare("/help.html")) {
m_type = UIMT_ROOTENTRY; m_type = UIMT_ROOTENTRY;
m_retType = UIRET_HELP; m_retType = UIRET_HELP;
return; return;
} else if (!path.compare("/search.html")) { } else if (!path.compare("/search.html")) {
m_type = UIMT_ROOTENTRY; m_type = UIMT_ROOTENTRY;
m_retType = UIRET_SEARCH; m_retType = UIRET_SEARCH;
// Retrieve the query value for preloading the form // Retrieve the query value for preloading the form
m_query.query = url.queryItem("q"); m_query.query = url.queryItem("q");
return; return;
} else if (m_parent->isRecollResult(url, &m_resnum, &m_query.query)) { } else if (m_parent->isRecollResult(url, &m_resnum, &m_query.query)) {
m_type = UIMT_QUERYRESULT; m_type = UIMT_QUERYRESULT;
m_query.opt = "l"; m_query.opt = "l";
m_query.page = 0; m_query.page = 0;
} else {
// Have to think this is some search string
m_type = UIMT_QUERY;
m_query.query = url.path();
m_query.opt = "l";
m_query.page = 0;
}
} else { } else {
// Have to think this is some search string // Non empty host, url must be something like :
// //search/query?q=query&param=value...
kDebug() << "host" << url.host() << "path" << url.path();
if (url.host().compare("search") || url.path().compare("/query")) {
return;
}
m_type = UIMT_QUERY; m_type = UIMT_QUERY;
m_query.query = url.path(); // Decode the forms' arguments
m_query.opt = "l"; m_query.query = url.queryItem("q");
m_query.page = 0;
}
} else {
// Non empty host, url must be something like :
// //search/query?q=query&param=value...
kDebug() << "host" << url.host() << "path" << url.path();
if (url.host().compare("search") || url.path().compare("/query")) {
return;
}
m_type = UIMT_QUERY;
// Decode the forms' arguments
m_query.query = url.queryItem("q");
m_query.opt = url.queryItem("qtp"); m_query.opt = url.queryItem("qtp");
if (m_query.opt.isEmpty()) { if (m_query.opt.isEmpty()) {
m_query.opt = "l"; m_query.opt = "l";
} }
QString p = url.queryItem("p"); QString p = url.queryItem("p");
if (p.isEmpty()) { if (p.isEmpty()) {
m_query.page = 0; m_query.page = 0;
} else { } else {
sscanf(p.toAscii(), "%d", &m_query.page); sscanf(p.toAscii(), "%d", &m_query.page);
} }
p = url.queryItem("det"); p = url.queryItem("det");
m_query.isDetReq = !p.isEmpty(); m_query.isDetReq = !p.isEmpty();
p = url.queryItem("cmd"); p = url.queryItem("cmd");
if (!p.isEmpty() && !p.compare("pv")) { if (!p.isEmpty() && !p.compare("pv")) {
p = url.queryItem("dn"); p = url.queryItem("dn");
if (!p.isEmpty()) { if (!p.isEmpty()) {
// Preview and no docnum ?? // Preview and no docnum ??
m_resnum = atoi((const char *)p.toUtf8()); m_resnum = atoi((const char *)p.toUtf8());
// Result in page is 1+ // Result in page is 1+
m_resnum--; m_resnum--;
m_type = UIMT_PREVIEW; m_type = UIMT_PREVIEW;
}
} }
} }
}
if (m_query.query.startsWith("/")) if (m_query.query.startsWith("/"))
m_query.query.remove(0,1); m_query.query.remove(0,1);
if (m_query.query.endsWith("/")) { if (m_query.query.endsWith("/")) {
kDebug() << "Ends with /"; kDebug() << "Ends with /";
m_slashend = true; m_slashend = true;
m_query.query.chop(1); m_query.query.chop(1);
} else { } else {
m_slashend = false; m_slashend = false;
} }
return; return;
} }
@ -210,12 +210,12 @@ bool RecollProtocol::syncSearch(const QueryDesc &qd)
{ {
kDebug(); kDebug();
if (!m_initok || !maybeOpenDb(m_reason)) { if (!m_initok || !maybeOpenDb(m_reason)) {
string reason = "RecollProtocol::listDir: Init error:" + m_reason; string reason = "RecollProtocol::listDir: Init error:" + m_reason;
error(KIO::ERR_SLAVE_DEFINED, reason.c_str()); error(KIO::ERR_SLAVE_DEFINED, reason.c_str());
return false; return false;
} }
if (qd.sameQuery(m_query)) { if (qd.sameQuery(m_query)) {
return true; return true;
} }
// doSearch() calls error() if appropriate. // doSearch() calls error() if appropriate.
return doSearch(qd); return doSearch(qd);
@ -229,9 +229,9 @@ void RecollProtocol::get(const KUrl& url)
kDebug() << url << endl; kDebug() << url << endl;
if (!m_initok || !maybeOpenDb(m_reason)) { if (!m_initok || !maybeOpenDb(m_reason)) {
string reason = "Recoll: init error: " + m_reason; string reason = "Recoll: init error: " + m_reason;
error(KIO::ERR_SLAVE_DEFINED, reason.c_str()); error(KIO::ERR_SLAVE_DEFINED, reason.c_str());
return; return;
} }
UrlIngester ingest(this, url); UrlIngester ingest(this, url);
@ -239,65 +239,65 @@ void RecollProtocol::get(const KUrl& url)
QueryDesc qd; QueryDesc qd;
int resnum; int resnum;
if (ingest.isRootEntry(&rettp)) { if (ingest.isRootEntry(&rettp)) {
switch(rettp) { switch(rettp) {
case UrlIngester::UIRET_HELP: case UrlIngester::UIRET_HELP:
{ {
QString location = QString location =
KStandardDirs::locate("data", "kio_recoll/help.html"); KStandardDirs::locate("data", "kio_recoll/help.html");
redirection(location); redirection(location);
} }
goto out; goto out;
default: default:
searchPage(); searchPage();
goto out; goto out;
} }
} else if (ingest.isResult(&qd, &resnum)) { } else if (ingest.isResult(&qd, &resnum)) {
// Url matched one generated by konqueror/Dolphin out of a // Url matched one generated by konqueror/Dolphin out of a
// search directory listing: ie: // search directory listing: ie:
// recoll:/some search string/recollResultxx // recoll:/some search string/recollResultxx
// //
// This happens when the user drags/drop the result to another // This happens when the user drags/drop the result to another
// app, or with the "open-with" right-click. Does not happen // app, or with the "open-with" right-click. Does not happen
// if the entry itself is clicked (the UDS_URL is apparently // if the entry itself is clicked (the UDS_URL is apparently
// used in this case // used in this case
// //
// Redirect to the result document URL // Redirect to the result document URL
if (!syncSearch(qd)) { if (!syncSearch(qd)) {
return; return;
} }
Rcl::Doc doc; Rcl::Doc doc;
if (resnum >= 0 && m_source && m_source->getDoc(resnum, doc)) { if (resnum >= 0 && m_source && m_source->getDoc(resnum, doc)) {
mimeType(doc.mimetype.c_str()); mimeType(doc.mimetype.c_str());
redirection(KUrl::fromLocalFile((const char *)(doc.url.c_str()+7))); redirection(KUrl::fromLocalFile((const char *)(doc.url.c_str()+7)));
goto out; goto out;
} }
} else if (ingest.isPreview(&qd, &resnum)) { } else if (ingest.isPreview(&qd, &resnum)) {
if (!syncSearch(qd)) { if (!syncSearch(qd)) {
return; return;
} }
Rcl::Doc doc; Rcl::Doc doc;
if (resnum >= 0 && m_source && m_source->getDoc(resnum, doc)) { if (resnum >= 0 && m_source && m_source->getDoc(resnum, doc)) {
showPreview(doc); showPreview(doc);
goto out; goto out;
} }
} else if (ingest.isQuery(&qd)) { } else if (ingest.isQuery(&qd)) {
#if 0 #if 0
// Do we need this ? // Do we need this ?
if (host.isEmpty()) { if (host.isEmpty()) {
char cpage[20];sprintf(cpage, "%d", page); char cpage[20];sprintf(cpage, "%d", page);
QString nurl = QString::fromAscii("recoll://search/query?q=") + QString nurl = QString::fromAscii("recoll://search/query?q=") +
query + "&qtp=" + opt + "&p=" + cpage; query + "&qtp=" + opt + "&p=" + cpage;
redirection(KUrl(nurl)); redirection(KUrl(nurl));
goto out; goto out;
} }
#endif #endif
// htmlDoSearch does the search syncing (needs to know about changes). // htmlDoSearch does the search syncing (needs to know about changes).
htmlDoSearch(qd); htmlDoSearch(qd);
goto out; goto out;
} }
error(KIO::ERR_SLAVE_DEFINED, "Unrecognized URL or internal error"); error(KIO::ERR_SLAVE_DEFINED, "Unrecognized URL or internal error");
out: out:
finished(); finished();
} }
@ -309,42 +309,41 @@ bool RecollProtocol::doSearch(const QueryDesc& qd)
char opt = qd.opt.isEmpty() ? 'l' : qd.opt.toUtf8().at(0); char opt = qd.opt.isEmpty() ? 'l' : qd.opt.toUtf8().at(0);
string qs = (const char *)qd.query.toUtf8(); string qs = (const char *)qd.query.toUtf8();
Rcl::SearchData *sd = 0; std::shared_ptr<Rcl::SearchData> sdata;
if (opt != 'l') { if (opt != 'l') {
Rcl::SearchDataClause *clp = 0; Rcl::SearchDataClause *clp = 0;
if (opt == 'f') { if (opt == 'f') {
clp = new Rcl::SearchDataClauseFilename(qs); clp = new Rcl::SearchDataClauseFilename(qs);
} else { } else {
clp = new Rcl::SearchDataClauseSimple(opt == 'o' ? Rcl::SCLT_OR : clp = new Rcl::SearchDataClauseSimple(opt == 'o' ? Rcl::SCLT_OR :
Rcl::SCLT_AND, qs); Rcl::SCLT_AND, qs);
} }
sd = new Rcl::SearchData(Rcl::SCLT_OR, m_stemlang); sdata = std::make_shared<Rcl::SearchData>(Rcl::SCLT_OR, m_stemlang);
if (sd && clp) if (sdata && clp)
sd->addClause(clp); sdata->addClause(clp);
} else { } else {
sd = wasaStringToRcl(o_rclconfig, m_stemlang, qs, m_reason); sdata = wasaStringToRcl(o_rclconfig, m_stemlang, qs, m_reason);
} }
if (!sd) { if (!sdata) {
m_reason = "Internal Error: cant build search"; m_reason = "Internal Error: cant build search";
error(KIO::ERR_SLAVE_DEFINED, m_reason.c_str()); error(KIO::ERR_SLAVE_DEFINED, m_reason.c_str());
return false; return false;
} }
std::shared_ptr<Rcl::SearchData> sdata(sd);
std::shared_ptr<Rcl::Query>query(new Rcl::Query(m_rcldb.get())); std::shared_ptr<Rcl::Query>query(new Rcl::Query(m_rcldb.get()));
query->setCollapseDuplicates(prefs.collapseDuplicates); query->setCollapseDuplicates(prefs.collapseDuplicates);
if (!query->setQuery(sdata)) { if (!query->setQuery(sdata)) {
m_reason = "Query execute failed. Invalid query or syntax error?"; m_reason = "Query execute failed. Invalid query or syntax error?";
error(KIO::ERR_SLAVE_DEFINED, m_reason.c_str()); error(KIO::ERR_SLAVE_DEFINED, m_reason.c_str());
return false; return false;
} }
DocSequenceDb *src = DocSequenceDb *src =
new DocSequenceDb(m_rcldb, std::shared_ptr<Rcl::Query>(query), new DocSequenceDb(m_rcldb, std::shared_ptr<Rcl::Query>(query),
"Query results", sdata); "Query results", sdata);
if (src == 0) { if (src == 0) {
error(KIO::ERR_SLAVE_DEFINED, "Can't build result sequence"); error(KIO::ERR_SLAVE_DEFINED, "Can't build result sequence");
return false; return false;
} }
m_source = std::shared_ptr<DocSequence>(src); m_source = std::shared_ptr<DocSequence>(src);
// Reset pager in all cases. Costs nothing, stays at page -1 initially // Reset pager in all cases. Costs nothing, stays at page -1 initially
@ -368,8 +367,8 @@ int kdemain(int argc, char **argv)
kDebug() << "*** starting kio_recoll " << endl; kDebug() << "*** starting kio_recoll " << endl;
if (argc != 4) { if (argc != 4) {
kDebug() << "Usage: kio_recoll proto dom-socket1 dom-socket2\n" << endl; kDebug() << "Usage: kio_recoll proto dom-socket1 dom-socket2\n" << endl;
exit(-1); exit(-1);
} }
RecollProtocol slave(argv[2], argv[3]); RecollProtocol slave(argv[2], argv[3]);

View File

@ -34,7 +34,9 @@ Recoll configuration.
Recipe: Recipe:
- Make sure the KF5 core and KIO devel packages and cmake are installed. - Make sure the KF5 core and KIO devel packages and cmake are
installed. You probably need the kio-devel and extra-cmake-modules
packages.
- Extract the Recoll source. - Extract the Recoll source.

View File

@ -117,40 +117,40 @@ static const UDSEntry resultToUDSEntry(const Rcl::Doc& doc, int num)
// asked to access it // asked to access it
char cnum[30]; char cnum[30];
sprintf(cnum, "%04d", num); sprintf(cnum, "%04d", num);
entry.insert(KIO::UDSEntry::UDS_NAME, resultBaseName + cnum); entry.fastInsert(KIO::UDSEntry::UDS_NAME, resultBaseName + cnum);
// Display the real file name // Display the real file name
entry.insert(KIO::UDSEntry::UDS_DISPLAY_NAME, url.fileName()); entry.fastInsert(KIO::UDSEntry::UDS_DISPLAY_NAME, url.fileName());
/// A local file path if the ioslave display files sitting on the /// A local file path if the ioslave display files sitting on the
/// local filesystem (but in another hierarchy, e.g. settings:/ or /// local filesystem (but in another hierarchy, e.g. settings:/ or
/// remote:/) /// remote:/)
entry.insert(KIO::UDSEntry::UDS_LOCAL_PATH, url.path()); entry.fastInsert(KIO::UDSEntry::UDS_LOCAL_PATH, url.path());
/// This file is a shortcut or mount, pointing to an /// This file is a shortcut or mount, pointing to an
/// URL in a different hierarchy /// URL in a different hierarchy
/// @since 4.1 /// @since 4.1
// We should probably set this only if the scheme is not 'file' (e.g. // We should probably set this only if the scheme is not 'file' (e.g.
// from the web cache). // from the web cache).
entry.insert(KIO::UDSEntry::UDS_TARGET_URL, doc.url.c_str()); entry.fastInsert(KIO::UDSEntry::UDS_TARGET_URL, doc.url.c_str());
if (!doc.mimetype.compare("application/x-fsdirectory") || if (!doc.mimetype.compare("application/x-fsdirectory") ||
!doc.mimetype.compare("inode/directory")) { !doc.mimetype.compare("inode/directory")) {
entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, "inode/directory"); entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, "inode/directory");
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR); entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
} else { } else {
entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, doc.mimetype.c_str()); entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, doc.mimetype.c_str());
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG); entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
} }
// For local files, supply the usual file stat information // For local files, supply the usual file stat information
struct stat info; struct stat info;
if (lstat(url.path().toUtf8(), &info) >= 0) { if (lstat(url.path().toUtf8(), &info) >= 0) {
entry.insert(KIO::UDSEntry::UDS_SIZE, info.st_size); entry.fastInsert(KIO::UDSEntry::UDS_SIZE, info.st_size);
entry.insert(KIO::UDSEntry::UDS_ACCESS, info.st_mode); entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, info.st_mode);
entry.insert(KIO::UDSEntry::UDS_MODIFICATION_TIME, info.st_mtime); entry.fastInsert(KIO::UDSEntry::UDS_MODIFICATION_TIME, info.st_mtime);
entry.insert(KIO::UDSEntry::UDS_ACCESS_TIME, info.st_atime); entry.fastInsert(KIO::UDSEntry::UDS_ACCESS_TIME, info.st_atime);
entry.insert(KIO::UDSEntry::UDS_CREATION_TIME, info.st_ctime); entry.fastInsert(KIO::UDSEntry::UDS_CREATION_TIME, info.st_ctime);
} }
return entry; return entry;
@ -161,23 +161,23 @@ static const UDSEntry resultToUDSEntry(const Rcl::Doc& doc, int num)
static void createRootEntry(KIO::UDSEntry& entry) static void createRootEntry(KIO::UDSEntry& entry)
{ {
entry.clear(); entry.clear();
entry.insert(KIO::UDSEntry::UDS_NAME, "."); entry.fastInsert(KIO::UDSEntry::UDS_NAME, ".");
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR); entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
entry.insert(KIO::UDSEntry::UDS_ACCESS, 0700); entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, 0700);
entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, "inode/directory"); entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, "inode/directory");
} }
// Points to html query screen // Points to html query screen
static void createGoHomeEntry(KIO::UDSEntry& entry) static void createGoHomeEntry(KIO::UDSEntry& entry)
{ {
entry.clear(); entry.clear();
entry.insert(KIO::UDSEntry::UDS_NAME, "search.html"); entry.fastInsert(KIO::UDSEntry::UDS_NAME, "search.html");
entry.insert(KIO::UDSEntry::UDS_DISPLAY_NAME, "Recoll search (click me)"); entry.fastInsert(KIO::UDSEntry::UDS_DISPLAY_NAME, "Recoll search (click me)");
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG); entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
entry.insert(KIO::UDSEntry::UDS_TARGET_URL, "recoll:///search.html"); entry.fastInsert(KIO::UDSEntry::UDS_TARGET_URL, "recoll:///search.html");
entry.insert(KIO::UDSEntry::UDS_ACCESS, 0500); entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, 0500);
entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, "text/html"); entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, "text/html");
entry.insert(KIO::UDSEntry::UDS_ICON_NAME, "recoll"); entry.fastInsert(KIO::UDSEntry::UDS_ICON_NAME, "recoll");
} }
// Points to help file // Points to help file
@ -187,14 +187,14 @@ static void createGoHelpEntry(KIO::UDSEntry& entry)
QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStandardPaths::locate(QStandardPaths::GenericDataLocation,
"kio_recoll/help.html"); "kio_recoll/help.html");
entry.clear(); entry.clear();
entry.insert(KIO::UDSEntry::UDS_NAME, "help"); entry.fastInsert(KIO::UDSEntry::UDS_NAME, "help");
entry.insert(KIO::UDSEntry::UDS_DISPLAY_NAME, "Recoll help (click me first)"); entry.fastInsert(KIO::UDSEntry::UDS_DISPLAY_NAME, "Recoll help (click me first)");
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG); entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
entry.insert(KIO::UDSEntry::UDS_TARGET_URL, QString("file://") + entry.fastInsert(KIO::UDSEntry::UDS_TARGET_URL, QString("file://") +
location); location);
entry.insert(KIO::UDSEntry::UDS_ACCESS, 0500); entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, 0500);
entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, "text/html"); entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, "text/html");
entry.insert(KIO::UDSEntry::UDS_ICON_NAME, "help"); entry.fastInsert(KIO::UDSEntry::UDS_ICON_NAME, "help");
} }
// As far as I can see we only ever get this on '/' so why all the code? // As far as I can see we only ever get this on '/' so why all the code?
@ -205,8 +205,8 @@ void RecollProtocol::stat(const QUrl& url)
UrlIngester ingest(this, url); UrlIngester ingest(this, url);
KIO::UDSEntry entry; KIO::UDSEntry entry;
// entry.insert(KIO::UDSEntry::UDS_TARGET_URL, url.url()); // entry.fastInsert(KIO::UDSEntry::UDS_TARGET_URL, url.url());
// entry.insert(KIO::UDSEntry::UDS_URL, url.url()); // entry.fastInsert(KIO::UDSEntry::UDS_URL, url.url());
UrlIngester::RootEntryType rettp; UrlIngester::RootEntryType rettp;
QueryDesc qd; QueryDesc qd;
int num; int num;
@ -257,12 +257,12 @@ void RecollProtocol::stat(const QUrl& url)
if (m_alwaysdir || ingest.alwaysDir() || ingest.endSlashQuery()) { if (m_alwaysdir || ingest.alwaysDir() || ingest.endSlashQuery()) {
qDebug() << "RecollProtocol::stat: Directory type:"; qDebug() << "RecollProtocol::stat: Directory type:";
// Need to check no / in there // Need to check no / in there
entry.insert(KIO::UDSEntry::UDS_NAME, qd.query); entry.fastInsert(KIO::UDSEntry::UDS_NAME, qd.query);
entry.insert(KIO::UDSEntry::UDS_ACCESS, 0700); entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, 0700);
entry.insert(KIO::UDSEntry::UDS_MODIFICATION_TIME, time(0)); entry.fastInsert(KIO::UDSEntry::UDS_MODIFICATION_TIME, time(0));
entry.insert(KIO::UDSEntry::UDS_CREATION_TIME, time(0)); entry.fastInsert(KIO::UDSEntry::UDS_CREATION_TIME, time(0));
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR); entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, "inode/directory"); entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, "inode/directory");
} }
} else { } else {
qDebug() << "RecollProtocol::stat: none of the above ??"; qDebug() << "RecollProtocol::stat: none of the above ??";

View File

@ -191,16 +191,16 @@ void RecollProtocol::queryDetails()
QByteArray array; QByteArray array;
QTextStream os(&array, QIODevice::WriteOnly); QTextStream os(&array, QIODevice::WriteOnly);
os << "<html><head>" << endl; os << "<html><head>" << "\n";
os << "<meta http-equiv=\"Content-Type\" content=\"text/html;" os << "<meta http-equiv=\"Content-Type\" content=\"text/html;"
"charset=utf-8\">" << endl; "charset=utf-8\">" << "\n";
os << "<title>" << "Recoll query details" << "</title>\n" << endl; os << "<title>" << "Recoll query details" << "</title>\n" << "\n";
os << "</head>" << endl; os << "</head>" << "\n";
os << "<body><h3>Query details:</h3>" << endl; os << "<body><h3>Query details:</h3>" << "\n";
os << "<p>" << m_pager.queryDescription().c_str() << "</p>" << endl; os << "<p>" << m_pager.queryDescription().c_str() << "</p>" << "\n";
os << "<p><a href=\"" << makeQueryUrl(m_pager.pageNumber()).c_str() << os << "<p><a href=\"" << makeQueryUrl(m_pager.pageNumber()).c_str() <<
"\">Return to results</a>" << endl; "\">Return to results</a>" << "\n";
os << "</body></html>" << endl; os << "</body></html>" << "\n";
data(array); data(array);
} }
@ -210,7 +210,7 @@ public:
: m_name(nm) { : m_name(nm) {
} }
virtual string header() { virtual string header() override {
if (m_inputhtml) { if (m_inputhtml) {
return cstr_null; return cstr_null;
} else { } else {
@ -222,11 +222,11 @@ public:
} }
} }
virtual string startMatch(unsigned int) { virtual string startMatch(unsigned int) override {
return string("<font color=\"blue\">"); return string("<font color=\"blue\">");
} }
virtual string endMatch() { virtual string endMatch() override {
return string("</font>"); return string("</font>");
} }
@ -266,14 +266,14 @@ void RecollProtocol::showPreview(const Rcl::Doc& idoc)
it != otextlist.end(); it++) { it != otextlist.end(); it++) {
os << (*it).c_str(); os << (*it).c_str();
} }
os << "</body></html>" << endl; os << "</body></html>" << "\n";
data(array); data(array);
} }
void RecollProtocol::htmlDoSearch(const QueryDesc& qd) void RecollProtocol::htmlDoSearch(const QueryDesc& qd)
{ {
qDebug() << "q" << qd.query << "option" << qd.opt << "page" << qd.page << qDebug() << "q" << qd.query << "option" << qd.opt << "page" << qd.page <<
"isdet" << qd.isDetReq << endl; "isdet" << qd.isDetReq << "\n";
mimeType("text/html"); mimeType("text/html");

View File

@ -312,7 +312,7 @@ bool RecollProtocol::doSearch(const QueryDesc& qd)
char opt = qd.opt.isEmpty() ? 'l' : qd.opt.toUtf8().at(0); char opt = qd.opt.isEmpty() ? 'l' : qd.opt.toUtf8().at(0);
string qs = (const char *)qd.query.toUtf8(); string qs = (const char *)qd.query.toUtf8();
Rcl::SearchData *sd = 0; std::shared_ptr<Rcl::SearchData> sdata;
if (opt != 'l') { if (opt != 'l') {
Rcl::SearchDataClause *clp = 0; Rcl::SearchDataClause *clp = 0;
if (opt == 'f') { if (opt == 'f') {
@ -321,20 +321,19 @@ bool RecollProtocol::doSearch(const QueryDesc& qd)
clp = new Rcl::SearchDataClauseSimple(opt == 'o' ? Rcl::SCLT_OR : clp = new Rcl::SearchDataClauseSimple(opt == 'o' ? Rcl::SCLT_OR :
Rcl::SCLT_AND, qs); Rcl::SCLT_AND, qs);
} }
sd = new Rcl::SearchData(Rcl::SCLT_OR, m_stemlang); sdata = std::make_shared<Rcl::SearchData>(Rcl::SCLT_OR, m_stemlang);
if (sd && clp) { if (sdata && clp) {
sd->addClause(clp); sdata->addClause(clp);
} }
} else { } else {
sd = wasaStringToRcl(o_rclconfig, m_stemlang, qs, m_reason); sdata = wasaStringToRcl(o_rclconfig, m_stemlang, qs, m_reason);
} }
if (!sd) { if (!sdata) {
m_reason = "Internal Error: cant build search"; m_reason = "Internal Error: cant build search";
error(KIO::ERR_SLAVE_DEFINED, u8s2qs(m_reason)); error(KIO::ERR_SLAVE_DEFINED, u8s2qs(m_reason));
return false; return false;
} }
std::shared_ptr<Rcl::SearchData> sdata(sd);
std::shared_ptr<Rcl::Query>query(new Rcl::Query(m_rcldb.get())); std::shared_ptr<Rcl::Query>query(new Rcl::Query(m_rcldb.get()));
query->setCollapseDuplicates(prefs.collapseDuplicates); query->setCollapseDuplicates(prefs.collapseDuplicates);
if (!query->setQuery(sdata)) { if (!query->setQuery(sdata)) {

View File

@ -40,15 +40,15 @@ public:
m_parent = proto; m_parent = proto;
} }
virtual bool append(const std::string& data); virtual bool append(const std::string& data) override;
virtual bool append(const std::string& data, int, const Rcl::Doc&) { virtual bool append(const std::string& data, int, const Rcl::Doc&) override {
return append(data); return append(data);
} }
virtual std::string detailsLink(); virtual std::string detailsLink() override;
virtual const std::string& parFormat(); virtual const std::string& parFormat() override;
virtual std::string nextUrl(); virtual std::string nextUrl() override;
virtual std::string prevUrl(); virtual std::string prevUrl() override;
virtual std::string pageTop(); virtual std::string pageTop() override;
private: private:
RecollProtocol *m_parent; RecollProtocol *m_parent;
@ -151,12 +151,12 @@ class RecollProtocol : public KIO::SlaveBase {
public: public:
RecollProtocol(const QByteArray& pool, const QByteArray& app); RecollProtocol(const QByteArray& pool, const QByteArray& app);
virtual ~RecollProtocol(); virtual ~RecollProtocol();
virtual void mimetype(const QUrl& url); virtual void mimetype(const QUrl& url) override;
virtual void get(const QUrl& url); virtual void get(const QUrl& url) override;
// The directory mode is not available with KDE 4.0, I could find // The directory mode is not available with KDE 4.0, I could find
// no way to avoid crashing kdirmodel // no way to avoid crashing kdirmodel
virtual void stat(const QUrl& url); virtual void stat(const QUrl& url) override;
virtual void listDir(const QUrl& url); virtual void listDir(const QUrl& url) override;
static RclConfig *o_rclconfig; static RclConfig *o_rclconfig;

View File

@ -81,10 +81,10 @@ zend_object_value query_create_handler(zend_class_entry *type TSRMLS_DC)
ALLOC_HASHTABLE(obj->std.properties); ALLOC_HASHTABLE(obj->std.properties);
zend_hash_init(obj->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0); zend_hash_init(obj->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
zend_hash_copy(obj->std.properties, &type->default_properties, zend_hash_copy(obj->std.properties, &type->default_properties,
(copy_ctor_func_t)zval_add_ref, (void *)&tmp, sizeof(zval *)); (copy_ctor_func_t)zval_add_ref, (void *)&tmp, sizeof(zval *));
retval.handle = zend_objects_store_put(obj, NULL, retval.handle = zend_objects_store_put(obj, NULL,
query_free_storage, NULL TSRMLS_CC); query_free_storage, NULL TSRMLS_CC);
retval.handlers = &query_object_handlers; retval.handlers = &query_object_handlers;
return retval; return retval;
@ -100,40 +100,38 @@ PHP_METHOD(Query, query)
long ctxwords; long ctxwords;
if (zend_parse_parameters(3 TSRMLS_CC, "sll", &qs_c, &qs_len, &maxchars, &ctxwords) == FAILURE) { if (zend_parse_parameters(3 TSRMLS_CC, "sll", &qs_c, &qs_len, &maxchars, &ctxwords) == FAILURE) {
printf("failed to get parameters\n"); printf("failed to get parameters\n");
RETURN_BOOL(false); RETURN_BOOL(false);
} }
string qs = qs_c; string qs = qs_c;
RclConfig *rclconfig = recollinit(0, 0, 0, reason, &a_config); RclConfig *rclconfig = recollinit(0, 0, 0, reason, &a_config);
if (!rclconfig || !rclconfig->ok()) { if (!rclconfig || !rclconfig->ok()) {
fprintf(stderr, "Recoll init failed: %s\n", reason.c_str()); fprintf(stderr, "Recoll init failed: %s\n", reason.c_str());
RETURN_BOOL(false); RETURN_BOOL(false);
} }
Rcl::Db *pRclDb = new Rcl::Db(rclconfig); Rcl::Db *pRclDb = new Rcl::Db(rclconfig);
if (!pRclDb->open(Rcl::Db::DbRO)) { if (!pRclDb->open(Rcl::Db::DbRO)) {
cerr << "Cant open database in " << rclconfig->getDbDir() << cerr << "Cant open database in " << rclconfig->getDbDir() <<
" reason: " << pRclDb->getReason() << endl; " reason: " << pRclDb->getReason() << endl;
RETURN_BOOL(false); RETURN_BOOL(false);
} }
pRclDb->setAbstractParams(-1, maxchars, ctxwords); pRclDb->setAbstractParams(-1, maxchars, ctxwords);
Rcl::SearchData *sd = 0;
// jf: the original implementation built an AND clause. It would // jf: the original implementation built an AND clause. It would
// be nice to offer an option, but the next best thing is to // be nice to offer an option, but the next best thing is to
// default to the query language // default to the query language
sd = wasaStringToRcl(rclconfig, "english", qs, reason); auto sdata = wasaStringToRcl(rclconfig, "english", qs, reason);
if (!sd) { if (!sdata) {
cerr << "Query string interpretation failed: " << reason << endl; cerr << "Query string interpretation failed: " << reason << endl;
RETURN_BOOL(false); RETURN_BOOL(false);
} }
std::shared_ptr<Rcl::SearchData> rq(sd);
Rcl::Query *pRclQuery = new Rcl::Query(pRclDb); Rcl::Query *pRclQuery = new Rcl::Query(pRclDb);
pRclQuery->setQuery(rq); pRclQuery->setQuery(sdata);
query_object *obj = (query_object *)zend_object_store_get_object(getThis() TSRMLS_CC); query_object *obj = (query_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
obj->pRclQuery = pRclQuery; obj->pRclQuery = pRclQuery;
@ -151,8 +149,8 @@ PHP_METHOD(Query, get_doc)
pRclQuery = obj->pRclQuery; pRclQuery = obj->pRclQuery;
if(NULL == pRclQuery) if(NULL == pRclQuery)
{ {
printf("error, NULL pointer pRclQuery\n"); printf("error, NULL pointer pRclQuery\n");
RETURN_BOOL(false); RETURN_BOOL(false);
} }
long index; long index;
@ -163,7 +161,7 @@ PHP_METHOD(Query, get_doc)
Rcl::Doc doc; Rcl::Doc doc;
if (!pRclQuery->getDoc(index, doc)) if (!pRclQuery->getDoc(index, doc))
{ {
RETURN_BOOL(false); RETURN_BOOL(false);
} }
string abs; string abs;
@ -172,10 +170,10 @@ PHP_METHOD(Query, get_doc)
char splitter[] = {7,8,1,2,0}; char splitter[] = {7,8,1,2,0};
char ret_string[1000]; char ret_string[1000];
snprintf(ret_string, 1000, "mime:%s%surl:%s%stitle:%s%sabs:%s", snprintf(ret_string, 1000, "mime:%s%surl:%s%stitle:%s%sabs:%s",
doc.mimetype.c_str(),splitter, doc.mimetype.c_str(),splitter,
doc.url.c_str(),splitter, doc.url.c_str(),splitter,
doc.meta[Rcl::Doc::keytt].c_str(), splitter, doc.meta[Rcl::Doc::keytt].c_str(), splitter,
abs.c_str()); abs.c_str());
RETURN_STRING(ret_string, 1); RETURN_STRING(ret_string, 1);
} }
@ -211,7 +209,7 @@ PHP_MINIT_FUNCTION(recoll)
query_ce = zend_register_internal_class(&ce TSRMLS_CC); query_ce = zend_register_internal_class(&ce TSRMLS_CC);
query_ce->create_object = query_create_handler; query_ce->create_object = query_create_handler;
memcpy(&query_object_handlers, memcpy(&query_object_handlers,
zend_get_std_object_handlers(), sizeof(zend_object_handlers)); zend_get_std_object_handlers(), sizeof(zend_object_handlers));
query_object_handlers.clone_obj = NULL; query_object_handlers.clone_obj = NULL;
return SUCCESS; return SUCCESS;
} }
@ -235,7 +233,7 @@ zend_module_entry recoll_module_entry = {
#ifdef COMPILE_DL_RECOLL #ifdef COMPILE_DL_RECOLL
extern "C" { extern "C" {
ZEND_GET_MODULE(recoll) ZEND_GET_MODULE(recoll)
} }
#endif #endif