kde kioslave: fix for new wasaToRcl shared_ptr interface. Misc warnings suppression
This commit is contained in:
parent
3c7e3ccbc7
commit
663da54c04
@ -55,25 +55,25 @@ RecollProtocol::RecollProtocol(const QByteArray &pool, const QByteArray &app)
|
||||
{
|
||||
kDebug() << endl;
|
||||
if (o_rclconfig == 0) {
|
||||
o_rclconfig = recollinit(0, 0, 0, m_reason);
|
||||
if (!o_rclconfig || !o_rclconfig->ok()) {
|
||||
m_reason = string("Configuration problem: ") + m_reason;
|
||||
return;
|
||||
}
|
||||
o_rclconfig = recollinit(0, 0, 0, m_reason);
|
||||
if (!o_rclconfig || !o_rclconfig->ok()) {
|
||||
m_reason = string("Configuration problem: ") + m_reason;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (o_rclconfig->getDbDir().empty()) {
|
||||
// Note: this will have to be replaced by a call to a
|
||||
// configuration building dialog for initial configuration? Or
|
||||
// do we assume that the QT GUO is always used for this ?
|
||||
m_reason = "No db directory in configuration ??";
|
||||
return;
|
||||
// Note: this will have to be replaced by a call to a
|
||||
// configuration building dialog for initial configuration? Or
|
||||
// do we assume that the QT GUO is always used for this ?
|
||||
m_reason = "No db directory in configuration ??";
|
||||
return;
|
||||
}
|
||||
rwSettings(false);
|
||||
|
||||
m_rcldb = std::shared_ptr<Rcl::Db>(new Rcl::Db(o_rclconfig));
|
||||
if (!m_rcldb) {
|
||||
m_reason = "Could not build database object. (out of memory ?)";
|
||||
return;
|
||||
m_reason = "Could not build database object. (out of memory ?)";
|
||||
return;
|
||||
}
|
||||
|
||||
// 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.
|
||||
const char *cp = getenv("RECOLL_KIO_ALWAYS_DIR");
|
||||
if (cp) {
|
||||
m_alwaysdir = stringToBool(cp);
|
||||
m_alwaysdir = stringToBool(cp);
|
||||
} else {
|
||||
o_rclconfig->getConfParam("kio_always_dir", &m_alwaysdir);
|
||||
o_rclconfig->getConfParam("kio_always_dir", &m_alwaysdir);
|
||||
}
|
||||
|
||||
cp = getenv("RECOLL_KIO_STEMLANG");
|
||||
@ -107,12 +107,12 @@ RecollProtocol::~RecollProtocol()
|
||||
bool RecollProtocol::maybeOpenDb(string &reason)
|
||||
{
|
||||
if (!m_rcldb) {
|
||||
reason = "Internal error: initialization error";
|
||||
return false;
|
||||
reason = "Internal error: initialization error";
|
||||
return false;
|
||||
}
|
||||
if (!m_rcldb->isopen() && !m_rcldb->open(Rcl::Db::DbRO)) {
|
||||
reason = "Could not open database in " + o_rclconfig->getDbDir();
|
||||
return false;
|
||||
reason = "Could not open database in " + o_rclconfig->getDbDir();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -133,75 +133,75 @@ UrlIngester::UrlIngester(RecollProtocol *p, const KUrl& url)
|
||||
m_alwaysdir = !url.protocol().compare("recollf");
|
||||
QString path = url.path();
|
||||
if (url.host().isEmpty()) {
|
||||
if (path.isEmpty() || !path.compare("/")) {
|
||||
m_type = UIMT_ROOTENTRY;
|
||||
m_retType = UIRET_ROOT;
|
||||
return;
|
||||
} else if (!path.compare("/help.html")) {
|
||||
m_type = UIMT_ROOTENTRY;
|
||||
m_retType = UIRET_HELP;
|
||||
return;
|
||||
} else if (!path.compare("/search.html")) {
|
||||
m_type = UIMT_ROOTENTRY;
|
||||
m_retType = UIRET_SEARCH;
|
||||
// Retrieve the query value for preloading the form
|
||||
m_query.query = url.queryItem("q");
|
||||
return;
|
||||
} else if (m_parent->isRecollResult(url, &m_resnum, &m_query.query)) {
|
||||
m_type = UIMT_QUERYRESULT;
|
||||
m_query.opt = "l";
|
||||
m_query.page = 0;
|
||||
if (path.isEmpty() || !path.compare("/")) {
|
||||
m_type = UIMT_ROOTENTRY;
|
||||
m_retType = UIRET_ROOT;
|
||||
return;
|
||||
} else if (!path.compare("/help.html")) {
|
||||
m_type = UIMT_ROOTENTRY;
|
||||
m_retType = UIRET_HELP;
|
||||
return;
|
||||
} else if (!path.compare("/search.html")) {
|
||||
m_type = UIMT_ROOTENTRY;
|
||||
m_retType = UIRET_SEARCH;
|
||||
// Retrieve the query value for preloading the form
|
||||
m_query.query = url.queryItem("q");
|
||||
return;
|
||||
} else if (m_parent->isRecollResult(url, &m_resnum, &m_query.query)) {
|
||||
m_type = UIMT_QUERYRESULT;
|
||||
m_query.opt = "l";
|
||||
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 {
|
||||
// Have to think this is some search string
|
||||
// Non empty host, url must be something like :
|
||||
// //search/query?q=query¶m=value...
|
||||
kDebug() << "host" << url.host() << "path" << url.path();
|
||||
if (url.host().compare("search") || url.path().compare("/query")) {
|
||||
return;
|
||||
}
|
||||
m_type = UIMT_QUERY;
|
||||
m_query.query = url.path();
|
||||
m_query.opt = "l";
|
||||
m_query.page = 0;
|
||||
}
|
||||
} else {
|
||||
// Non empty host, url must be something like :
|
||||
// //search/query?q=query¶m=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");
|
||||
// Decode the forms' arguments
|
||||
m_query.query = url.queryItem("q");
|
||||
|
||||
m_query.opt = url.queryItem("qtp");
|
||||
if (m_query.opt.isEmpty()) {
|
||||
m_query.opt = "l";
|
||||
}
|
||||
QString p = url.queryItem("p");
|
||||
if (p.isEmpty()) {
|
||||
m_query.page = 0;
|
||||
} else {
|
||||
sscanf(p.toAscii(), "%d", &m_query.page);
|
||||
}
|
||||
p = url.queryItem("det");
|
||||
m_query.isDetReq = !p.isEmpty();
|
||||
m_query.opt = url.queryItem("qtp");
|
||||
if (m_query.opt.isEmpty()) {
|
||||
m_query.opt = "l";
|
||||
}
|
||||
QString p = url.queryItem("p");
|
||||
if (p.isEmpty()) {
|
||||
m_query.page = 0;
|
||||
} else {
|
||||
sscanf(p.toAscii(), "%d", &m_query.page);
|
||||
}
|
||||
p = url.queryItem("det");
|
||||
m_query.isDetReq = !p.isEmpty();
|
||||
|
||||
p = url.queryItem("cmd");
|
||||
if (!p.isEmpty() && !p.compare("pv")) {
|
||||
p = url.queryItem("dn");
|
||||
if (!p.isEmpty()) {
|
||||
// Preview and no docnum ??
|
||||
m_resnum = atoi((const char *)p.toUtf8());
|
||||
// Result in page is 1+
|
||||
m_resnum--;
|
||||
m_type = UIMT_PREVIEW;
|
||||
p = url.queryItem("cmd");
|
||||
if (!p.isEmpty() && !p.compare("pv")) {
|
||||
p = url.queryItem("dn");
|
||||
if (!p.isEmpty()) {
|
||||
// Preview and no docnum ??
|
||||
m_resnum = atoi((const char *)p.toUtf8());
|
||||
// Result in page is 1+
|
||||
m_resnum--;
|
||||
m_type = UIMT_PREVIEW;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m_query.query.startsWith("/"))
|
||||
m_query.query.remove(0,1);
|
||||
m_query.query.remove(0,1);
|
||||
if (m_query.query.endsWith("/")) {
|
||||
kDebug() << "Ends with /";
|
||||
m_slashend = true;
|
||||
m_query.query.chop(1);
|
||||
kDebug() << "Ends with /";
|
||||
m_slashend = true;
|
||||
m_query.query.chop(1);
|
||||
} else {
|
||||
m_slashend = false;
|
||||
m_slashend = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -210,12 +210,12 @@ bool RecollProtocol::syncSearch(const QueryDesc &qd)
|
||||
{
|
||||
kDebug();
|
||||
if (!m_initok || !maybeOpenDb(m_reason)) {
|
||||
string reason = "RecollProtocol::listDir: Init error:" + m_reason;
|
||||
error(KIO::ERR_SLAVE_DEFINED, reason.c_str());
|
||||
return false;
|
||||
string reason = "RecollProtocol::listDir: Init error:" + m_reason;
|
||||
error(KIO::ERR_SLAVE_DEFINED, reason.c_str());
|
||||
return false;
|
||||
}
|
||||
if (qd.sameQuery(m_query)) {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
// doSearch() calls error() if appropriate.
|
||||
return doSearch(qd);
|
||||
@ -229,9 +229,9 @@ void RecollProtocol::get(const KUrl& url)
|
||||
kDebug() << url << endl;
|
||||
|
||||
if (!m_initok || !maybeOpenDb(m_reason)) {
|
||||
string reason = "Recoll: init error: " + m_reason;
|
||||
error(KIO::ERR_SLAVE_DEFINED, reason.c_str());
|
||||
return;
|
||||
string reason = "Recoll: init error: " + m_reason;
|
||||
error(KIO::ERR_SLAVE_DEFINED, reason.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
UrlIngester ingest(this, url);
|
||||
@ -239,65 +239,65 @@ void RecollProtocol::get(const KUrl& url)
|
||||
QueryDesc qd;
|
||||
int resnum;
|
||||
if (ingest.isRootEntry(&rettp)) {
|
||||
switch(rettp) {
|
||||
case UrlIngester::UIRET_HELP:
|
||||
switch(rettp) {
|
||||
case UrlIngester::UIRET_HELP:
|
||||
{
|
||||
QString location =
|
||||
KStandardDirs::locate("data", "kio_recoll/help.html");
|
||||
redirection(location);
|
||||
QString location =
|
||||
KStandardDirs::locate("data", "kio_recoll/help.html");
|
||||
redirection(location);
|
||||
}
|
||||
goto out;
|
||||
default:
|
||||
searchPage();
|
||||
goto out;
|
||||
}
|
||||
default:
|
||||
searchPage();
|
||||
goto out;
|
||||
}
|
||||
} else if (ingest.isResult(&qd, &resnum)) {
|
||||
// Url matched one generated by konqueror/Dolphin out of a
|
||||
// search directory listing: ie:
|
||||
// Url matched one generated by konqueror/Dolphin out of a
|
||||
// search directory listing: ie:
|
||||
// recoll:/some search string/recollResultxx
|
||||
//
|
||||
// This happens when the user drags/drop the result to another
|
||||
// app, or with the "open-with" right-click. Does not happen
|
||||
// if the entry itself is clicked (the UDS_URL is apparently
|
||||
// used in this case
|
||||
//
|
||||
// Redirect to the result document URL
|
||||
if (!syncSearch(qd)) {
|
||||
return;
|
||||
}
|
||||
Rcl::Doc doc;
|
||||
if (resnum >= 0 && m_source && m_source->getDoc(resnum, doc)) {
|
||||
mimeType(doc.mimetype.c_str());
|
||||
redirection(KUrl::fromLocalFile((const char *)(doc.url.c_str()+7)));
|
||||
goto out;
|
||||
}
|
||||
//
|
||||
// This happens when the user drags/drop the result to another
|
||||
// app, or with the "open-with" right-click. Does not happen
|
||||
// if the entry itself is clicked (the UDS_URL is apparently
|
||||
// used in this case
|
||||
//
|
||||
// Redirect to the result document URL
|
||||
if (!syncSearch(qd)) {
|
||||
return;
|
||||
}
|
||||
Rcl::Doc doc;
|
||||
if (resnum >= 0 && m_source && m_source->getDoc(resnum, doc)) {
|
||||
mimeType(doc.mimetype.c_str());
|
||||
redirection(KUrl::fromLocalFile((const char *)(doc.url.c_str()+7)));
|
||||
goto out;
|
||||
}
|
||||
} else if (ingest.isPreview(&qd, &resnum)) {
|
||||
if (!syncSearch(qd)) {
|
||||
return;
|
||||
}
|
||||
Rcl::Doc doc;
|
||||
if (resnum >= 0 && m_source && m_source->getDoc(resnum, doc)) {
|
||||
showPreview(doc);
|
||||
goto out;
|
||||
}
|
||||
if (!syncSearch(qd)) {
|
||||
return;
|
||||
}
|
||||
Rcl::Doc doc;
|
||||
if (resnum >= 0 && m_source && m_source->getDoc(resnum, doc)) {
|
||||
showPreview(doc);
|
||||
goto out;
|
||||
}
|
||||
} else if (ingest.isQuery(&qd)) {
|
||||
#if 0
|
||||
// Do we need this ?
|
||||
if (host.isEmpty()) {
|
||||
char cpage[20];sprintf(cpage, "%d", page);
|
||||
QString nurl = QString::fromAscii("recoll://search/query?q=") +
|
||||
query + "&qtp=" + opt + "&p=" + cpage;
|
||||
redirection(KUrl(nurl));
|
||||
goto out;
|
||||
}
|
||||
if (host.isEmpty()) {
|
||||
char cpage[20];sprintf(cpage, "%d", page);
|
||||
QString nurl = QString::fromAscii("recoll://search/query?q=") +
|
||||
query + "&qtp=" + opt + "&p=" + cpage;
|
||||
redirection(KUrl(nurl));
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
// htmlDoSearch does the search syncing (needs to know about changes).
|
||||
htmlDoSearch(qd);
|
||||
goto out;
|
||||
// htmlDoSearch does the search syncing (needs to know about changes).
|
||||
htmlDoSearch(qd);
|
||||
goto out;
|
||||
}
|
||||
|
||||
error(KIO::ERR_SLAVE_DEFINED, "Unrecognized URL or internal error");
|
||||
out:
|
||||
out:
|
||||
finished();
|
||||
}
|
||||
|
||||
@ -309,42 +309,41 @@ bool RecollProtocol::doSearch(const QueryDesc& qd)
|
||||
|
||||
char opt = qd.opt.isEmpty() ? 'l' : qd.opt.toUtf8().at(0);
|
||||
string qs = (const char *)qd.query.toUtf8();
|
||||
Rcl::SearchData *sd = 0;
|
||||
std::shared_ptr<Rcl::SearchData> sdata;
|
||||
if (opt != 'l') {
|
||||
Rcl::SearchDataClause *clp = 0;
|
||||
if (opt == 'f') {
|
||||
clp = new Rcl::SearchDataClauseFilename(qs);
|
||||
} else {
|
||||
Rcl::SearchDataClause *clp = 0;
|
||||
if (opt == 'f') {
|
||||
clp = new Rcl::SearchDataClauseFilename(qs);
|
||||
} else {
|
||||
clp = new Rcl::SearchDataClauseSimple(opt == 'o' ? Rcl::SCLT_OR :
|
||||
Rcl::SCLT_AND, qs);
|
||||
}
|
||||
sd = new Rcl::SearchData(Rcl::SCLT_OR, m_stemlang);
|
||||
if (sd && clp)
|
||||
sd->addClause(clp);
|
||||
}
|
||||
sdata = std::make_shared<Rcl::SearchData>(Rcl::SCLT_OR, m_stemlang);
|
||||
if (sdata && clp)
|
||||
sdata->addClause(clp);
|
||||
} else {
|
||||
sd = wasaStringToRcl(o_rclconfig, m_stemlang, qs, m_reason);
|
||||
sdata = wasaStringToRcl(o_rclconfig, m_stemlang, qs, m_reason);
|
||||
}
|
||||
if (!sd) {
|
||||
m_reason = "Internal Error: cant build search";
|
||||
error(KIO::ERR_SLAVE_DEFINED, m_reason.c_str());
|
||||
return false;
|
||||
if (!sdata) {
|
||||
m_reason = "Internal Error: cant build search";
|
||||
error(KIO::ERR_SLAVE_DEFINED, m_reason.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<Rcl::SearchData> sdata(sd);
|
||||
std::shared_ptr<Rcl::Query>query(new Rcl::Query(m_rcldb.get()));
|
||||
query->setCollapseDuplicates(prefs.collapseDuplicates);
|
||||
if (!query->setQuery(sdata)) {
|
||||
m_reason = "Query execute failed. Invalid query or syntax error?";
|
||||
error(KIO::ERR_SLAVE_DEFINED, m_reason.c_str());
|
||||
return false;
|
||||
m_reason = "Query execute failed. Invalid query or syntax error?";
|
||||
error(KIO::ERR_SLAVE_DEFINED, m_reason.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
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);
|
||||
if (src == 0) {
|
||||
error(KIO::ERR_SLAVE_DEFINED, "Can't build result sequence");
|
||||
return false;
|
||||
error(KIO::ERR_SLAVE_DEFINED, "Can't build result sequence");
|
||||
return false;
|
||||
}
|
||||
m_source = std::shared_ptr<DocSequence>(src);
|
||||
// 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;
|
||||
|
||||
if (argc != 4) {
|
||||
kDebug() << "Usage: kio_recoll proto dom-socket1 dom-socket2\n" << endl;
|
||||
exit(-1);
|
||||
kDebug() << "Usage: kio_recoll proto dom-socket1 dom-socket2\n" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
RecollProtocol slave(argv[2], argv[3]);
|
||||
|
||||
@ -34,7 +34,9 @@ Recoll configuration.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
@ -117,40 +117,40 @@ static const UDSEntry resultToUDSEntry(const Rcl::Doc& doc, int num)
|
||||
// asked to access it
|
||||
char cnum[30];
|
||||
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
|
||||
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
|
||||
/// local filesystem (but in another hierarchy, e.g. settings:/ or
|
||||
/// 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
|
||||
/// URL in a different hierarchy
|
||||
/// @since 4.1
|
||||
// We should probably set this only if the scheme is not 'file' (e.g.
|
||||
// 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") ||
|
||||
!doc.mimetype.compare("inode/directory")) {
|
||||
entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, "inode/directory");
|
||||
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, "inode/directory");
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
|
||||
} else {
|
||||
entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, doc.mimetype.c_str());
|
||||
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, doc.mimetype.c_str());
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
|
||||
}
|
||||
|
||||
// For local files, supply the usual file stat information
|
||||
struct stat info;
|
||||
if (lstat(url.path().toUtf8(), &info) >= 0) {
|
||||
entry.insert(KIO::UDSEntry::UDS_SIZE, info.st_size);
|
||||
entry.insert(KIO::UDSEntry::UDS_ACCESS, info.st_mode);
|
||||
entry.insert(KIO::UDSEntry::UDS_MODIFICATION_TIME, info.st_mtime);
|
||||
entry.insert(KIO::UDSEntry::UDS_ACCESS_TIME, info.st_atime);
|
||||
entry.insert(KIO::UDSEntry::UDS_CREATION_TIME, info.st_ctime);
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_SIZE, info.st_size);
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, info.st_mode);
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_MODIFICATION_TIME, info.st_mtime);
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_ACCESS_TIME, info.st_atime);
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_CREATION_TIME, info.st_ctime);
|
||||
}
|
||||
|
||||
return entry;
|
||||
@ -161,23 +161,23 @@ static const UDSEntry resultToUDSEntry(const Rcl::Doc& doc, int num)
|
||||
static void createRootEntry(KIO::UDSEntry& entry)
|
||||
{
|
||||
entry.clear();
|
||||
entry.insert(KIO::UDSEntry::UDS_NAME, ".");
|
||||
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
|
||||
entry.insert(KIO::UDSEntry::UDS_ACCESS, 0700);
|
||||
entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, "inode/directory");
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_NAME, ".");
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, 0700);
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, "inode/directory");
|
||||
}
|
||||
|
||||
// Points to html query screen
|
||||
static void createGoHomeEntry(KIO::UDSEntry& entry)
|
||||
{
|
||||
entry.clear();
|
||||
entry.insert(KIO::UDSEntry::UDS_NAME, "search.html");
|
||||
entry.insert(KIO::UDSEntry::UDS_DISPLAY_NAME, "Recoll search (click me)");
|
||||
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
|
||||
entry.insert(KIO::UDSEntry::UDS_TARGET_URL, "recoll:///search.html");
|
||||
entry.insert(KIO::UDSEntry::UDS_ACCESS, 0500);
|
||||
entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, "text/html");
|
||||
entry.insert(KIO::UDSEntry::UDS_ICON_NAME, "recoll");
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_NAME, "search.html");
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_DISPLAY_NAME, "Recoll search (click me)");
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_TARGET_URL, "recoll:///search.html");
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, 0500);
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, "text/html");
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_ICON_NAME, "recoll");
|
||||
}
|
||||
|
||||
// Points to help file
|
||||
@ -187,14 +187,14 @@ static void createGoHelpEntry(KIO::UDSEntry& entry)
|
||||
QStandardPaths::locate(QStandardPaths::GenericDataLocation,
|
||||
"kio_recoll/help.html");
|
||||
entry.clear();
|
||||
entry.insert(KIO::UDSEntry::UDS_NAME, "help");
|
||||
entry.insert(KIO::UDSEntry::UDS_DISPLAY_NAME, "Recoll help (click me first)");
|
||||
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
|
||||
entry.insert(KIO::UDSEntry::UDS_TARGET_URL, QString("file://") +
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_NAME, "help");
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_DISPLAY_NAME, "Recoll help (click me first)");
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_TARGET_URL, QString("file://") +
|
||||
location);
|
||||
entry.insert(KIO::UDSEntry::UDS_ACCESS, 0500);
|
||||
entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, "text/html");
|
||||
entry.insert(KIO::UDSEntry::UDS_ICON_NAME, "help");
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, 0500);
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, "text/html");
|
||||
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?
|
||||
@ -205,8 +205,8 @@ void RecollProtocol::stat(const QUrl& url)
|
||||
UrlIngester ingest(this, url);
|
||||
|
||||
KIO::UDSEntry entry;
|
||||
// entry.insert(KIO::UDSEntry::UDS_TARGET_URL, url.url());
|
||||
// entry.insert(KIO::UDSEntry::UDS_URL, url.url());
|
||||
// entry.fastInsert(KIO::UDSEntry::UDS_TARGET_URL, url.url());
|
||||
// entry.fastInsert(KIO::UDSEntry::UDS_URL, url.url());
|
||||
UrlIngester::RootEntryType rettp;
|
||||
QueryDesc qd;
|
||||
int num;
|
||||
@ -257,12 +257,12 @@ void RecollProtocol::stat(const QUrl& url)
|
||||
if (m_alwaysdir || ingest.alwaysDir() || ingest.endSlashQuery()) {
|
||||
qDebug() << "RecollProtocol::stat: Directory type:";
|
||||
// Need to check no / in there
|
||||
entry.insert(KIO::UDSEntry::UDS_NAME, qd.query);
|
||||
entry.insert(KIO::UDSEntry::UDS_ACCESS, 0700);
|
||||
entry.insert(KIO::UDSEntry::UDS_MODIFICATION_TIME, time(0));
|
||||
entry.insert(KIO::UDSEntry::UDS_CREATION_TIME, time(0));
|
||||
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
|
||||
entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, "inode/directory");
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_NAME, qd.query);
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, 0700);
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_MODIFICATION_TIME, time(0));
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_CREATION_TIME, time(0));
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, "inode/directory");
|
||||
}
|
||||
} else {
|
||||
qDebug() << "RecollProtocol::stat: none of the above ??";
|
||||
|
||||
@ -191,16 +191,16 @@ void RecollProtocol::queryDetails()
|
||||
QByteArray array;
|
||||
QTextStream os(&array, QIODevice::WriteOnly);
|
||||
|
||||
os << "<html><head>" << endl;
|
||||
os << "<html><head>" << "\n";
|
||||
os << "<meta http-equiv=\"Content-Type\" content=\"text/html;"
|
||||
"charset=utf-8\">" << endl;
|
||||
os << "<title>" << "Recoll query details" << "</title>\n" << endl;
|
||||
os << "</head>" << endl;
|
||||
os << "<body><h3>Query details:</h3>" << endl;
|
||||
os << "<p>" << m_pager.queryDescription().c_str() << "</p>" << endl;
|
||||
"charset=utf-8\">" << "\n";
|
||||
os << "<title>" << "Recoll query details" << "</title>\n" << "\n";
|
||||
os << "</head>" << "\n";
|
||||
os << "<body><h3>Query details:</h3>" << "\n";
|
||||
os << "<p>" << m_pager.queryDescription().c_str() << "</p>" << "\n";
|
||||
os << "<p><a href=\"" << makeQueryUrl(m_pager.pageNumber()).c_str() <<
|
||||
"\">Return to results</a>" << endl;
|
||||
os << "</body></html>" << endl;
|
||||
"\">Return to results</a>" << "\n";
|
||||
os << "</body></html>" << "\n";
|
||||
data(array);
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ public:
|
||||
: m_name(nm) {
|
||||
}
|
||||
|
||||
virtual string header() {
|
||||
virtual string header() override {
|
||||
if (m_inputhtml) {
|
||||
return cstr_null;
|
||||
} else {
|
||||
@ -222,11 +222,11 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual string startMatch(unsigned int) {
|
||||
virtual string startMatch(unsigned int) override {
|
||||
return string("<font color=\"blue\">");
|
||||
}
|
||||
|
||||
virtual string endMatch() {
|
||||
virtual string endMatch() override {
|
||||
return string("</font>");
|
||||
}
|
||||
|
||||
@ -266,14 +266,14 @@ void RecollProtocol::showPreview(const Rcl::Doc& idoc)
|
||||
it != otextlist.end(); it++) {
|
||||
os << (*it).c_str();
|
||||
}
|
||||
os << "</body></html>" << endl;
|
||||
os << "</body></html>" << "\n";
|
||||
data(array);
|
||||
}
|
||||
|
||||
void RecollProtocol::htmlDoSearch(const QueryDesc& qd)
|
||||
{
|
||||
qDebug() << "q" << qd.query << "option" << qd.opt << "page" << qd.page <<
|
||||
"isdet" << qd.isDetReq << endl;
|
||||
"isdet" << qd.isDetReq << "\n";
|
||||
|
||||
mimeType("text/html");
|
||||
|
||||
|
||||
@ -312,7 +312,7 @@ bool RecollProtocol::doSearch(const QueryDesc& qd)
|
||||
|
||||
char opt = qd.opt.isEmpty() ? 'l' : qd.opt.toUtf8().at(0);
|
||||
string qs = (const char *)qd.query.toUtf8();
|
||||
Rcl::SearchData *sd = 0;
|
||||
std::shared_ptr<Rcl::SearchData> sdata;
|
||||
if (opt != 'l') {
|
||||
Rcl::SearchDataClause *clp = 0;
|
||||
if (opt == 'f') {
|
||||
@ -321,20 +321,19 @@ bool RecollProtocol::doSearch(const QueryDesc& qd)
|
||||
clp = new Rcl::SearchDataClauseSimple(opt == 'o' ? Rcl::SCLT_OR :
|
||||
Rcl::SCLT_AND, qs);
|
||||
}
|
||||
sd = new Rcl::SearchData(Rcl::SCLT_OR, m_stemlang);
|
||||
if (sd && clp) {
|
||||
sd->addClause(clp);
|
||||
sdata = std::make_shared<Rcl::SearchData>(Rcl::SCLT_OR, m_stemlang);
|
||||
if (sdata && clp) {
|
||||
sdata->addClause(clp);
|
||||
}
|
||||
} 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";
|
||||
error(KIO::ERR_SLAVE_DEFINED, u8s2qs(m_reason));
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<Rcl::SearchData> sdata(sd);
|
||||
std::shared_ptr<Rcl::Query>query(new Rcl::Query(m_rcldb.get()));
|
||||
query->setCollapseDuplicates(prefs.collapseDuplicates);
|
||||
if (!query->setQuery(sdata)) {
|
||||
|
||||
@ -40,15 +40,15 @@ public:
|
||||
m_parent = proto;
|
||||
}
|
||||
|
||||
virtual bool append(const std::string& data);
|
||||
virtual bool append(const std::string& data, int, const Rcl::Doc&) {
|
||||
virtual bool append(const std::string& data) override;
|
||||
virtual bool append(const std::string& data, int, const Rcl::Doc&) override {
|
||||
return append(data);
|
||||
}
|
||||
virtual std::string detailsLink();
|
||||
virtual const std::string& parFormat();
|
||||
virtual std::string nextUrl();
|
||||
virtual std::string prevUrl();
|
||||
virtual std::string pageTop();
|
||||
virtual std::string detailsLink() override;
|
||||
virtual const std::string& parFormat() override;
|
||||
virtual std::string nextUrl() override;
|
||||
virtual std::string prevUrl() override;
|
||||
virtual std::string pageTop() override;
|
||||
|
||||
private:
|
||||
RecollProtocol *m_parent;
|
||||
@ -151,12 +151,12 @@ class RecollProtocol : public KIO::SlaveBase {
|
||||
public:
|
||||
RecollProtocol(const QByteArray& pool, const QByteArray& app);
|
||||
virtual ~RecollProtocol();
|
||||
virtual void mimetype(const QUrl& url);
|
||||
virtual void get(const QUrl& url);
|
||||
virtual void mimetype(const QUrl& url) override;
|
||||
virtual void get(const QUrl& url) override;
|
||||
// The directory mode is not available with KDE 4.0, I could find
|
||||
// no way to avoid crashing kdirmodel
|
||||
virtual void stat(const QUrl& url);
|
||||
virtual void listDir(const QUrl& url);
|
||||
virtual void stat(const QUrl& url) override;
|
||||
virtual void listDir(const QUrl& url) override;
|
||||
|
||||
static RclConfig *o_rclconfig;
|
||||
|
||||
|
||||
@ -81,10 +81,10 @@ zend_object_value query_create_handler(zend_class_entry *type TSRMLS_DC)
|
||||
ALLOC_HASHTABLE(obj->std.properties);
|
||||
zend_hash_init(obj->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
|
||||
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,
|
||||
query_free_storage, NULL TSRMLS_CC);
|
||||
query_free_storage, NULL TSRMLS_CC);
|
||||
retval.handlers = &query_object_handlers;
|
||||
|
||||
return retval;
|
||||
@ -100,40 +100,38 @@ PHP_METHOD(Query, query)
|
||||
long ctxwords;
|
||||
|
||||
if (zend_parse_parameters(3 TSRMLS_CC, "sll", &qs_c, &qs_len, &maxchars, &ctxwords) == FAILURE) {
|
||||
printf("failed to get parameters\n");
|
||||
RETURN_BOOL(false);
|
||||
printf("failed to get parameters\n");
|
||||
RETURN_BOOL(false);
|
||||
}
|
||||
string qs = qs_c;
|
||||
|
||||
RclConfig *rclconfig = recollinit(0, 0, 0, reason, &a_config);
|
||||
if (!rclconfig || !rclconfig->ok()) {
|
||||
fprintf(stderr, "Recoll init failed: %s\n", reason.c_str());
|
||||
RETURN_BOOL(false);
|
||||
fprintf(stderr, "Recoll init failed: %s\n", reason.c_str());
|
||||
RETURN_BOOL(false);
|
||||
}
|
||||
|
||||
Rcl::Db *pRclDb = new Rcl::Db(rclconfig);
|
||||
if (!pRclDb->open(Rcl::Db::DbRO)) {
|
||||
cerr << "Cant open database in " << rclconfig->getDbDir() <<
|
||||
" reason: " << pRclDb->getReason() << endl;
|
||||
RETURN_BOOL(false);
|
||||
cerr << "Cant open database in " << rclconfig->getDbDir() <<
|
||||
" reason: " << pRclDb->getReason() << endl;
|
||||
RETURN_BOOL(false);
|
||||
}
|
||||
|
||||
pRclDb->setAbstractParams(-1, maxchars, ctxwords);
|
||||
Rcl::SearchData *sd = 0;
|
||||
|
||||
|
||||
// jf: the original implementation built an AND clause. It would
|
||||
// be nice to offer an option, but the next best thing is to
|
||||
// default to the query language
|
||||
sd = wasaStringToRcl(rclconfig, "english", qs, reason);
|
||||
auto sdata = wasaStringToRcl(rclconfig, "english", qs, reason);
|
||||
|
||||
if (!sd) {
|
||||
cerr << "Query string interpretation failed: " << reason << endl;
|
||||
RETURN_BOOL(false);
|
||||
if (!sdata) {
|
||||
cerr << "Query string interpretation failed: " << reason << endl;
|
||||
RETURN_BOOL(false);
|
||||
}
|
||||
|
||||
std::shared_ptr<Rcl::SearchData> rq(sd);
|
||||
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);
|
||||
obj->pRclQuery = pRclQuery;
|
||||
@ -151,8 +149,8 @@ PHP_METHOD(Query, get_doc)
|
||||
pRclQuery = obj->pRclQuery;
|
||||
if(NULL == pRclQuery)
|
||||
{
|
||||
printf("error, NULL pointer pRclQuery\n");
|
||||
RETURN_BOOL(false);
|
||||
printf("error, NULL pointer pRclQuery\n");
|
||||
RETURN_BOOL(false);
|
||||
}
|
||||
|
||||
long index;
|
||||
@ -163,7 +161,7 @@ PHP_METHOD(Query, get_doc)
|
||||
Rcl::Doc doc;
|
||||
if (!pRclQuery->getDoc(index, doc))
|
||||
{
|
||||
RETURN_BOOL(false);
|
||||
RETURN_BOOL(false);
|
||||
}
|
||||
|
||||
string abs;
|
||||
@ -172,10 +170,10 @@ PHP_METHOD(Query, get_doc)
|
||||
char splitter[] = {7,8,1,2,0};
|
||||
char ret_string[1000];
|
||||
snprintf(ret_string, 1000, "mime:%s%surl:%s%stitle:%s%sabs:%s",
|
||||
doc.mimetype.c_str(),splitter,
|
||||
doc.url.c_str(),splitter,
|
||||
doc.meta[Rcl::Doc::keytt].c_str(), splitter,
|
||||
abs.c_str());
|
||||
doc.mimetype.c_str(),splitter,
|
||||
doc.url.c_str(),splitter,
|
||||
doc.meta[Rcl::Doc::keytt].c_str(), splitter,
|
||||
abs.c_str());
|
||||
RETURN_STRING(ret_string, 1);
|
||||
}
|
||||
|
||||
@ -211,7 +209,7 @@ PHP_MINIT_FUNCTION(recoll)
|
||||
query_ce = zend_register_internal_class(&ce TSRMLS_CC);
|
||||
query_ce->create_object = query_create_handler;
|
||||
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;
|
||||
return SUCCESS;
|
||||
}
|
||||
@ -235,7 +233,7 @@ zend_module_entry recoll_module_entry = {
|
||||
|
||||
#ifdef COMPILE_DL_RECOLL
|
||||
extern "C" {
|
||||
ZEND_GET_MODULE(recoll)
|
||||
ZEND_GET_MODULE(recoll)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user