Also index non-html files from the web queue and fix the Open operation for them

This commit is contained in:
Jean-Francois Dockes
2015-07-24 16:30:13 +02:00
parent 208619697a
commit 4d35cbabfb
8 changed files with 204 additions and 142 deletions
+4 -14
View File
@@ -31,6 +31,7 @@
#include "readfile.h"
#include "xmltosd.h"
#include "searchdata.h"
#include "copyfile.h"
using namespace std;
using namespace Rcl;
@@ -90,23 +91,12 @@ void RclMain::saveLastQuery()
string tofile((const char *)s.toLocal8Bit());
LOGDEB(("RclMain::saveLastQuery: XML: [%s]\n", xml.c_str()));
int fd = ::open(tofile.c_str(), O_WRONLY|O_CREAT|O_TRUNC, 0600);
if (fd < 0) {
QMessageBox::warning(this, tr("Open failed"),
tr("Could not open/create file"));
return;
}
if (::write(fd, xml.c_str(), xml.size()) != int(xml.size())) {
::close(fd);
string reason;
if (!stringtofile(xml, tofile.c_str(), reason)) {
QMessageBox::warning(this, tr("Write failed"),
tr("Could not write to file"));
return;
}
if (::close(fd) != 0) {
QMessageBox::warning(this, tr("Close failed"), tr("File close error"));
return;
}
return;
}
+11 -2
View File
@@ -291,11 +291,20 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term)
LOGDEB(("RclMain::startNV: groksipath %d wantsf %d wantsparentf %d\n",
groksipath, wantsfile, wantsparentfile));
bool notinfs = false;
{
string backend;
doc.getmeta(Rcl::Doc::keybcknd, &backend);
if (!backend.empty() && backend.compare("FS"))
notinfs = true;
}
// If the command wants a file but this is not a file url, or
// there is an ipath that it won't understand, we need a temp file:
theconfig->setKeyDir(path_getfather(fn));
if (((wantsfile || wantsparentfile) && fn.empty()) ||
(!groksipath && !doc.ipath.empty())) {
if (notinfs ||
((wantsfile || wantsparentfile) && fn.empty()) ||
(!groksipath && !doc.ipath.empty()) ) {
TempFile temp;
Rcl::Doc& thedoc = wantsparentfile ? pdoc : doc;
if (!FileInterner::idocToFile(temp, string(), theconfig, thedoc)) {
+2 -6
View File
@@ -111,17 +111,13 @@ void RTIToolW::accept()
dir = path_cat(dir, "autostart");
mkdir(dir.c_str(), 0700);
int fd = ::open(autostartfile.c_str(), O_WRONLY|O_CREAT, 0644);
if (fd < 0 || ::write(fd, text.c_str(), size_t(text.size()))
!= ssize_t(text.size()) || ::close(fd) != 0) {
if (fd >=0)
::close(fd);
string reason;
if (!stringtofile(text, autostartfile.c_str(), reason)) {
QString msg = tr("Can't create: ") +
QString::fromLocal8Bit(autostartfile.c_str());
QMessageBox::warning(0, tr("Warning"), msg, QMessageBox::Ok);
return;
}
::close(fd);
if (nowCB->isChecked()) {
ExecCmd cmd;