got rid of accesses to global config through getMainConfig()
This commit is contained in:
parent
bac0c1eeb9
commit
e1a20aa810
@ -183,8 +183,12 @@ RclConfig::RclConfig(const string *argcnf)
|
||||
|
||||
bool RclConfig::updateMainConfig()
|
||||
{
|
||||
m_conf = new ConfStack<ConfTree>("recoll.conf", m_cdirs, true);
|
||||
if (m_conf == 0 || !m_conf->ok()) {
|
||||
LOGDEB(("RclConfig::updateMainConfig\n"));
|
||||
ConfStack<ConfTree> *newconf =
|
||||
new ConfStack<ConfTree>("recoll.conf", m_cdirs, true);
|
||||
if (newconf == 0 || !newconf->ok()) {
|
||||
if (m_conf)
|
||||
return false;
|
||||
string where;
|
||||
stringsToString(m_cdirs, where);
|
||||
m_reason = string("No/bad main configuration file in: ") + where;
|
||||
@ -211,6 +215,8 @@ bool RclConfig::updateMainConfig()
|
||||
TextSplit::noNumbers();
|
||||
}
|
||||
|
||||
delete m_conf;
|
||||
m_conf = newconf;
|
||||
m_skpnstate.init(this, m_conf, "skippedNames");
|
||||
m_rmtstate.init(this, m_conf, "indexedmimetypes");
|
||||
return true;
|
||||
|
||||
@ -64,12 +64,6 @@ class RclConfig {
|
||||
// argcnf
|
||||
RclConfig(const string *argcnf = 0);
|
||||
|
||||
// Main programs must implement this, it avoids having to carry
|
||||
// the configuration parameter everywhere. Places where several
|
||||
// RclConfig instances might be needed will take care of
|
||||
// themselves.
|
||||
static RclConfig* getMainConfig();
|
||||
|
||||
// Return a writable clone of the main config. This belongs to the
|
||||
// caller (must delete it when done)
|
||||
ConfNull *cloneMainConfig();
|
||||
|
||||
@ -201,10 +201,6 @@ Usage(FILE *where = stderr)
|
||||
}
|
||||
|
||||
static RclConfig *config;
|
||||
RclConfig *RclConfig::getMainConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
|
||||
void lockorexit(Pidfile *pidfile)
|
||||
{
|
||||
|
||||
@ -1053,10 +1053,6 @@ static int op_flags;
|
||||
#define OPT_q 0x1
|
||||
|
||||
RclConfig *config;
|
||||
RclConfig *RclConfig::getMainConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
thisprog = argv[0];
|
||||
|
||||
@ -78,10 +78,7 @@ bool MimeHandlerExec::next_document()
|
||||
}
|
||||
|
||||
int filtermaxseconds = 900;
|
||||
RclConfig *conf = RclConfig::getMainConfig();
|
||||
if (conf) {
|
||||
conf->getConfParam("filtermaxseconds", &filtermaxseconds);
|
||||
}
|
||||
m_config->getConfParam("filtermaxseconds", &filtermaxseconds);
|
||||
|
||||
// Command name
|
||||
string cmd = params.front();
|
||||
|
||||
@ -57,7 +57,8 @@ class MimeHandlerExec : public RecollFilter {
|
||||
bool missingHelper;
|
||||
////////////////
|
||||
|
||||
MimeHandlerExec(const string& mt) : RecollFilter(mt), missingHelper(false)
|
||||
MimeHandlerExec(RclConfig *cnf, const string& mt)
|
||||
: RecollFilter(cnf, mt), missingHelper(false)
|
||||
{}
|
||||
virtual ~MimeHandlerExec() {}
|
||||
virtual bool set_document_file(const string &file_path) {
|
||||
|
||||
@ -251,7 +251,7 @@ bool MimeHandlerExecMultiple::next_document()
|
||||
if (!ipath.empty()) {
|
||||
m_metaData["ipath"] = ipath;
|
||||
if (mtype.empty()) {
|
||||
mtype = mimetype(ipath, 0, RclConfig::getMainConfig(), false);
|
||||
mtype = mimetype(ipath, 0, m_config, false);
|
||||
if (mtype.empty()) {
|
||||
// mimetype() won't call idFile when there is no file. Do it
|
||||
mtype = idFileMem(m_metaData["content"]);
|
||||
|
||||
@ -91,8 +91,8 @@ class MimeHandlerExecMultiple : public MimeHandlerExec {
|
||||
/////// End un-cleared stuff.
|
||||
|
||||
public:
|
||||
MimeHandlerExecMultiple(const string& mt)
|
||||
: MimeHandlerExec(mt)
|
||||
MimeHandlerExecMultiple(RclConfig *cnf, const string& mt)
|
||||
: MimeHandlerExec(cnf, mt)
|
||||
{}
|
||||
// No resources to clean up, the ExecCmd destructor does it.
|
||||
virtual ~MimeHandlerExecMultiple() {}
|
||||
|
||||
@ -27,7 +27,8 @@
|
||||
*/
|
||||
class MimeHandlerHtml : public RecollFilter {
|
||||
public:
|
||||
MimeHandlerHtml(const string& mt) : RecollFilter(mt) {}
|
||||
MimeHandlerHtml(RclConfig *cnf, const string& mt)
|
||||
: RecollFilter(cnf, mt) {}
|
||||
virtual ~MimeHandlerHtml() {}
|
||||
virtual bool set_document_file(const string &file_path);
|
||||
virtual bool set_document_string(const string &data);
|
||||
|
||||
@ -55,19 +55,18 @@ static const string cstr_title = "title";
|
||||
static const string cstr_msgid = "msgid";
|
||||
static const string cstr_abstract = "abstract";
|
||||
|
||||
MimeHandlerMail::MimeHandlerMail(const string &mt)
|
||||
: RecollFilter(mt), m_bincdoc(0), m_fd(-1), m_stream(0), m_idx(-1)
|
||||
MimeHandlerMail::MimeHandlerMail(RclConfig *cnf, const string &mt)
|
||||
: RecollFilter(cnf, mt), m_bincdoc(0), m_fd(-1), m_stream(0), m_idx(-1)
|
||||
{
|
||||
|
||||
// Look for additional headers to be processed as per config:
|
||||
list<string> hdrnames =
|
||||
RclConfig::getMainConfig()->getFieldSectNames("mail");
|
||||
m_config->getFieldSectNames("mail");
|
||||
if (hdrnames.empty())
|
||||
return;
|
||||
for (list<string>::const_iterator it = hdrnames.begin();
|
||||
it != hdrnames.end(); it++) {
|
||||
(void)RclConfig::getMainConfig()->
|
||||
getFieldConfParam(*it, "mail", m_addProcdHdrs[*it]);
|
||||
(void)m_config->getFieldConfParam(*it, "mail", m_addProcdHdrs[*it]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -282,7 +281,7 @@ bool MimeHandlerMail::processAttach()
|
||||
if (m_metaData[cstr_mimetype] == "application/octet-stream" &&
|
||||
!m_metaData["filename"].empty()) {
|
||||
string mt = mimetype(m_metaData["filename"], 0,
|
||||
RclConfig::getMainConfig(), false);
|
||||
m_config, false);
|
||||
if (!mt.empty())
|
||||
m_metaData[cstr_mimetype] = mt;
|
||||
}
|
||||
@ -532,7 +531,7 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
|
||||
!stringlowercmp("x-user-defined", charset) ||
|
||||
!stringlowercmp("x-unknown", charset) ||
|
||||
!stringlowercmp("unknown", charset) ) {
|
||||
RclConfig::getMainConfig()->getConfParam("maildefcharset", charset);
|
||||
m_config->getConfParam("maildefcharset", charset);
|
||||
if (charset.empty())
|
||||
charset = "iso-8859-1";
|
||||
}
|
||||
@ -598,7 +597,7 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
|
||||
string utf8;
|
||||
const string *putf8 = 0;
|
||||
if (!stringlowercmp("text/html", content_type.value)) {
|
||||
MimeHandlerHtml mh("text/html");
|
||||
MimeHandlerHtml mh(m_config, "text/html");
|
||||
mh.set_property(Dijon::Filter::OPERATING_MODE,
|
||||
m_forPreview ? "view" : "index");
|
||||
mh.set_property(Dijon::Filter::DEFAULT_CHARSET, charset);
|
||||
|
||||
@ -40,7 +40,7 @@ class MHMailAttach;
|
||||
*/
|
||||
class MimeHandlerMail : public RecollFilter {
|
||||
public:
|
||||
MimeHandlerMail(const string &mt);
|
||||
MimeHandlerMail(RclConfig *cnf, const string &mt);
|
||||
virtual ~MimeHandlerMail();
|
||||
virtual bool set_document_file(const string& file_path);
|
||||
virtual bool set_document_string(const string& data);
|
||||
|
||||
@ -79,11 +79,11 @@ public:
|
||||
}
|
||||
|
||||
~MboxCache() {}
|
||||
mbhoff_type get_offset(const string& udi, int msgnum)
|
||||
mbhoff_type get_offset(RclConfig *config, const string& udi, int msgnum)
|
||||
{
|
||||
LOGDEB0(("MboxCache::get_offsets: udi [%s] msgnum %d\n", udi.c_str(),
|
||||
msgnum));
|
||||
if (!ok()) {
|
||||
if (!ok(config)) {
|
||||
LOGDEB0(("MboxCache::get_offsets: init failed\n"));
|
||||
return -1;
|
||||
}
|
||||
@ -125,11 +125,11 @@ public:
|
||||
}
|
||||
|
||||
// Save array of offsets for a given file, designated by Udi
|
||||
void put_offsets(const string& udi, mbhoff_type fsize,
|
||||
void put_offsets(RclConfig *config, const string& udi, mbhoff_type fsize,
|
||||
vector<mbhoff_type>& offs)
|
||||
{
|
||||
LOGDEB0(("MboxCache::put_offsets: %u offsets\n", offs.size()));
|
||||
if (!ok() || !maybemakedir())
|
||||
if (!ok(config) || !maybemakedir())
|
||||
return;
|
||||
if (fsize < m_minfsize)
|
||||
return;
|
||||
@ -161,13 +161,10 @@ public:
|
||||
}
|
||||
|
||||
// Check state, possibly initialize
|
||||
bool ok() {
|
||||
bool ok(RclConfig *config) {
|
||||
if (m_minfsize == -1)
|
||||
return false;
|
||||
if (!m_ok) {
|
||||
RclConfig *config = RclConfig::getMainConfig();
|
||||
if (config == 0)
|
||||
return false;
|
||||
int minmbs = 5;
|
||||
config->getConfParam("mboxcacheminmbs", &minmbs);
|
||||
if (minmbs < 0) {
|
||||
@ -269,9 +266,8 @@ bool MimeHandlerMbox::set_document_file(const string &fn)
|
||||
m_quirks = 0;
|
||||
|
||||
// Check for location-based quirks:
|
||||
RclConfig *config = RclConfig::getMainConfig();
|
||||
string quirks;
|
||||
if (config && config->getConfParam(keyquirks, quirks)) {
|
||||
if (m_config && m_config->getConfParam(keyquirks, quirks)) {
|
||||
if (quirks == "tbird") {
|
||||
LOGDEB(("MimeHandlerMbox: setting quirks TBIRD\n"));
|
||||
m_quirks |= MBOXQUIRK_TBIRD;
|
||||
@ -402,7 +398,7 @@ bool MimeHandlerMbox::next_document()
|
||||
LOGDEB0(("MimeHandlerMbox::next_doc: mtarg %d m_udi[%s]\n",
|
||||
mtarg, m_udi.c_str()));
|
||||
if (!m_udi.empty() &&
|
||||
(off = mcache.get_offset(m_udi, mtarg)) >= 0 &&
|
||||
(off = mcache.get_offset(m_config, m_udi, mtarg)) >= 0 &&
|
||||
fseeko(fp, (off_t)off, SEEK_SET) >= 0 &&
|
||||
fgets(line, LL, fp) &&
|
||||
(!regexec(&fromregex, line, 0, 0, 0) ||
|
||||
@ -485,7 +481,7 @@ bool MimeHandlerMbox::next_document()
|
||||
LOGDEB2(("MimeHandlerMbox::next: eof hit\n"));
|
||||
m_havedoc = false;
|
||||
if (!m_udi.empty()) {
|
||||
mcache.put_offsets(m_udi, m_fsize, m_offsets);
|
||||
mcache.put_offsets(m_config, m_udi, m_fsize, m_offsets);
|
||||
}
|
||||
}
|
||||
return msgtxt.empty() ? false : true;
|
||||
@ -521,10 +517,6 @@ Usage(void)
|
||||
exit(1);
|
||||
}
|
||||
static RclConfig *config;
|
||||
RclConfig *RclConfig::getMainConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
static int op_flags;
|
||||
#define OPT_MOINS 0x1
|
||||
#define OPT_m 0x2
|
||||
|
||||
@ -32,8 +32,9 @@ using std::vector;
|
||||
*/
|
||||
class MimeHandlerMbox : public RecollFilter {
|
||||
public:
|
||||
MimeHandlerMbox(const string& mime)
|
||||
: RecollFilter(mime), m_vfp(0), m_msgnum(0), m_lineno(0), m_fsize(0)
|
||||
MimeHandlerMbox(RclConfig *cnf, const string& mime)
|
||||
: RecollFilter(cnf, mime), m_vfp(0), m_msgnum(0),
|
||||
m_lineno(0), m_fsize(0)
|
||||
{}
|
||||
virtual ~MimeHandlerMbox();
|
||||
virtual bool set_document_file(const string &file_path);
|
||||
|
||||
@ -59,13 +59,13 @@ bool MimeHandlerText::set_document_file(const string &fn)
|
||||
|
||||
// Max file size parameter: texts over this size are not indexed
|
||||
int maxmbs = 20;
|
||||
RclConfig::getMainConfig()->getConfParam("textfilemaxmbs", &maxmbs);
|
||||
m_config->getConfParam("textfilemaxmbs", &maxmbs);
|
||||
|
||||
if (maxmbs == -1 || st.st_size / MB <= maxmbs) {
|
||||
// Text file page size: if set, we split text files into
|
||||
// multiple documents
|
||||
int ps = 1000;
|
||||
RclConfig::getMainConfig()->getConfParam("textfilepagekbs", &ps);
|
||||
m_config->getConfParam("textfilepagekbs", &ps);
|
||||
if (ps != -1) {
|
||||
ps *= KB;
|
||||
m_paging = true;
|
||||
|
||||
@ -31,8 +31,8 @@ using std::string;
|
||||
*/
|
||||
class MimeHandlerText : public RecollFilter {
|
||||
public:
|
||||
MimeHandlerText(const string& mt)
|
||||
: RecollFilter(mt), m_paging(false), m_offs(0) {}
|
||||
MimeHandlerText(RclConfig *cnf, const string& mt)
|
||||
: RecollFilter(cnf, mt), m_paging(false), m_offs(0) {}
|
||||
virtual ~MimeHandlerText() {}
|
||||
virtual bool set_document_file(const string &file_path);
|
||||
virtual bool set_document_string(const string&);
|
||||
|
||||
@ -28,7 +28,8 @@
|
||||
*/
|
||||
class MimeHandlerUnknown : public RecollFilter {
|
||||
public:
|
||||
MimeHandlerUnknown(const string& mt) : RecollFilter(mt) {}
|
||||
MimeHandlerUnknown(RclConfig *cnf, const string& mt)
|
||||
: RecollFilter(cnf, mt) {}
|
||||
virtual ~MimeHandlerUnknown() {}
|
||||
virtual bool set_document_string(const string& fn) {
|
||||
RecollFilter::set_document_file(fn);
|
||||
|
||||
@ -51,33 +51,33 @@ static multimap<string, Dijon::Filter*> o_handlers;
|
||||
|
||||
/** For mime types set as "internal" in mimeconf:
|
||||
* create appropriate handler object. */
|
||||
static Dijon::Filter *mhFactory(const string &mime)
|
||||
static Dijon::Filter *mhFactory(RclConfig *config, const string &mime)
|
||||
{
|
||||
LOGDEB2(("mhFactory(%s)\n", mime.c_str()));
|
||||
string lmime(mime);
|
||||
stringtolower(lmime);
|
||||
if ("text/plain" == lmime) {
|
||||
return new MimeHandlerText(lmime);
|
||||
return new MimeHandlerText(config, lmime);
|
||||
} else if ("text/html" == lmime) {
|
||||
return new MimeHandlerHtml(lmime);
|
||||
return new MimeHandlerHtml(config, lmime);
|
||||
} else if ("text/x-mail" == lmime) {
|
||||
return new MimeHandlerMbox(lmime);
|
||||
return new MimeHandlerMbox(config, lmime);
|
||||
} else if ("message/rfc822" == lmime) {
|
||||
return new MimeHandlerMail(lmime);
|
||||
return new MimeHandlerMail(config, lmime);
|
||||
} else if (lmime.find("text/") == 0) {
|
||||
// Try to handle unknown text/xx as text/plain. This
|
||||
// only happen if the text/xx was defined as "internal" in
|
||||
// mimeconf, not at random. For programs, for example this
|
||||
// allows indexing and previewing as text/plain (no filter
|
||||
// exec) but still opening with a specific editor.
|
||||
return new MimeHandlerText(lmime);
|
||||
return new MimeHandlerText(config, lmime);
|
||||
} else {
|
||||
// We should not get there. It means that "internal" was set
|
||||
// as a handler in mimeconf for a mime type we actually can't
|
||||
// handle.
|
||||
LOGERR(("mhFactory: mime type [%s] set as internal but unknown\n",
|
||||
lmime.c_str()));
|
||||
return new MimeHandlerUnknown(lmime);
|
||||
return new MimeHandlerUnknown(config, lmime);
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,8 +110,8 @@ MimeHandlerExec *mhExecFactory(RclConfig *cfg, const string& mtype, string& hs,
|
||||
return 0;
|
||||
}
|
||||
MimeHandlerExec *h = multiple ?
|
||||
new MimeHandlerExecMultiple(mtype.c_str()) :
|
||||
new MimeHandlerExec(mtype.c_str());
|
||||
new MimeHandlerExecMultiple(cfg, mtype.c_str()) :
|
||||
new MimeHandlerExec(cfg, mtype.c_str());
|
||||
list<string>::iterator it = cmdtoks.begin();
|
||||
h->params.push_back(cfg->findFilter(*it++));
|
||||
h->params.insert(h->params.end(), it, cmdtoks.end());
|
||||
@ -205,9 +205,9 @@ Dijon::Filter *getMimeHandler(const string &mtype, RclConfig *cfg,
|
||||
// point in the future
|
||||
LOGDEB2(("handlertype internal, cmdstr [%s]\n", cmdstr.c_str()));
|
||||
if (!cmdstr.empty())
|
||||
h = mhFactory(cmdstr);
|
||||
h = mhFactory(cfg, cmdstr);
|
||||
else
|
||||
h = mhFactory(mtype);
|
||||
h = mhFactory(cfg, mtype);
|
||||
goto out;
|
||||
} else if (!stringlowercmp("dll", handlertype)) {
|
||||
} else {
|
||||
@ -247,7 +247,7 @@ Dijon::Filter *getMimeHandler(const string &mtype, RclConfig *cfg,
|
||||
{bool indexunknown = false;
|
||||
cfg->getConfParam("indexallfilenames", &indexunknown);
|
||||
if (indexunknown) {
|
||||
h = new MimeHandlerUnknown("application/octet-stream");
|
||||
h = new MimeHandlerUnknown(cfg, "application/octet-stream");
|
||||
goto out;
|
||||
} else {
|
||||
goto out;
|
||||
|
||||
@ -30,8 +30,9 @@ class RclConfig;
|
||||
|
||||
class RecollFilter : public Dijon::Filter {
|
||||
public:
|
||||
RecollFilter(const string& mtype)
|
||||
: Dijon::Filter(mtype), m_forPreview(false), m_havedoc(false)
|
||||
RecollFilter(RclConfig *config, const string& mtype)
|
||||
: Dijon::Filter(mtype), m_config(config),
|
||||
m_forPreview(false), m_havedoc(false)
|
||||
{}
|
||||
virtual ~RecollFilter() {}
|
||||
virtual bool set_property(Properties p, const string &v) {
|
||||
@ -93,6 +94,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
RclConfig *m_config;
|
||||
bool m_forPreview;
|
||||
string m_dfltInputCharset;
|
||||
string m_reason;
|
||||
|
||||
@ -302,5 +302,5 @@ void RecollProtocol::htmlDoSearch(const QueryDesc& qd)
|
||||
m_pager.resultPageBack();
|
||||
}
|
||||
// Display
|
||||
m_pager.displayPage();
|
||||
m_pager.displayPage(o_rclconfig);
|
||||
}
|
||||
|
||||
@ -53,11 +53,6 @@ using namespace KIO;
|
||||
|
||||
RclConfig *RecollProtocol::o_rclconfig;
|
||||
|
||||
RclConfig *RclConfig::getMainConfig()
|
||||
{
|
||||
return RecollProtocol::o_rclconfig;
|
||||
}
|
||||
|
||||
RecollProtocol::RecollProtocol(const QByteArray &pool, const QByteArray &app)
|
||||
: SlaveBase("recoll", pool, app), m_initok(false), m_rcldb(0),
|
||||
m_alwaysdir(false)
|
||||
|
||||
@ -1204,11 +1204,6 @@ static PyMethodDef recollMethods[] = {
|
||||
};
|
||||
|
||||
|
||||
RclConfig *RclConfig::getMainConfig()
|
||||
{
|
||||
return rclconfig;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(pyrecoll_doc_string,
|
||||
"This is an interface to the Recoll full text indexer.");
|
||||
|
||||
|
||||
@ -106,10 +106,6 @@ Usage(void)
|
||||
|
||||
|
||||
static RclConfig *config;
|
||||
RclConfig *RclConfig::getMainConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
@ -145,7 +145,7 @@ string QtGuiResListPager::pageTop()
|
||||
string QtGuiResListPager::iconPath(const string& mtype)
|
||||
{
|
||||
string iconpath;
|
||||
RclConfig::getMainConfig()->getMimeIconName(mtype, &iconpath);
|
||||
rclconfig->getMimeIconName(mtype, &iconpath);
|
||||
return iconpath;
|
||||
}
|
||||
|
||||
@ -511,7 +511,7 @@ void ResList::displayPage()
|
||||
{
|
||||
m_pageParaToReldocnums.clear();
|
||||
clear();
|
||||
m_pager->displayPage();
|
||||
m_pager->displayPage(rclconfig);
|
||||
LOGDEB0(("ResList::resultPageNext: hasNext %d hasPrev %d\n",
|
||||
m_pager->hasPrev(), m_pager->hasNext()));
|
||||
emit prevPageAvailable(m_pager->hasPrev());
|
||||
|
||||
@ -19,6 +19,7 @@ static char rcsid[] = "@(#$Id: reslist.cpp,v 1.52 2008-12-17 15:12:08 dockes Exp
|
||||
#include <QTextDocument>
|
||||
#include <QPainter>
|
||||
|
||||
#include "recoll.h"
|
||||
#include "refcntr.h"
|
||||
#include "docseq.h"
|
||||
#include "debuglog.h"
|
||||
@ -84,7 +85,7 @@ const string& ResTablePager::parFormat()
|
||||
string ResTablePager::iconPath(const string& mtype)
|
||||
{
|
||||
string iconpath;
|
||||
RclConfig::getMainConfig()->getMimeIconName(mtype, &iconpath);
|
||||
rclconfig->getMimeIconName(mtype, &iconpath);
|
||||
return iconpath;
|
||||
}
|
||||
|
||||
@ -179,9 +180,8 @@ RecollModel::RecollModel(const QStringList fields, QObject *parent)
|
||||
// Add dynamic "stored" fields to the full column list. This
|
||||
// could be protected to be done only once, but it's no real
|
||||
// problem
|
||||
RclConfig *config = RclConfig::getMainConfig();
|
||||
if (config) {
|
||||
const set<string>& stored = config->getStoredFields();
|
||||
if (rclconfig) {
|
||||
const set<string>& stored = rclconfig->getStoredFields();
|
||||
for (set<string>::const_iterator it = stored.begin();
|
||||
it != stored.end(); it++) {
|
||||
if (o_displayableFields.find(*it) == o_displayableFields.end()) {
|
||||
@ -488,7 +488,7 @@ void ResTable::onTableView_currentChanged(const QModelIndex& index)
|
||||
if (m_model->getDocSource()->getDoc(index.row(), doc)) {
|
||||
textBrowser->clear();
|
||||
m_detaildocnum = index.row();
|
||||
m_pager->displayDoc(index.row(), doc, m_model->m_hdata);
|
||||
m_pager->displayDoc(rclconfig, index.row(), doc, m_model->m_hdata);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -135,9 +135,9 @@ void SSearch::startSimpleSearch()
|
||||
if (tp == SST_LANG) {
|
||||
string reason;
|
||||
if (prefs.autoSuffsEnable)
|
||||
sdata = wasaStringToRcl(u8, reason, (const char *)prefs.autoSuffs.toUtf8());
|
||||
sdata = wasaStringToRcl(rclconfig, u8, reason, (const char *)prefs.autoSuffs.toUtf8());
|
||||
else
|
||||
sdata = wasaStringToRcl(u8, reason);
|
||||
sdata = wasaStringToRcl(rclconfig, u8, reason);
|
||||
if (sdata == 0) {
|
||||
QMessageBox::warning(0, "Recoll", tr("Bad query string") +
|
||||
QString::fromAscii(reason.c_str()));
|
||||
|
||||
@ -375,7 +375,7 @@ void UIPrefsDialog::addExtraDbPB_clicked()
|
||||
}
|
||||
struct stat st1, st2;
|
||||
stat(dbdir.c_str(), &st1);
|
||||
string rcldbdir = RclConfig::getMainConfig()->getDbDir();
|
||||
string rcldbdir = rclconfig->getDbDir();
|
||||
stat(rcldbdir.c_str(), &st2);
|
||||
path_catslash(rcldbdir);
|
||||
|
||||
|
||||
@ -248,7 +248,7 @@ int recollq(RclConfig **cfp, int argc, char **argv)
|
||||
if (sd)
|
||||
sd->addClause(clp);
|
||||
} else {
|
||||
sd = wasaStringToRcl(qs, reason);
|
||||
sd = wasaStringToRcl(rclconfig, qs, reason);
|
||||
}
|
||||
|
||||
if (!sd) {
|
||||
@ -325,11 +325,6 @@ int recollq(RclConfig **cfp, int argc, char **argv)
|
||||
|
||||
static RclConfig *rclconfig;
|
||||
|
||||
RclConfig *RclConfig::getMainConfig()
|
||||
{
|
||||
return rclconfig;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
exit(recollq(&rclconfig, argc, argv));
|
||||
|
||||
@ -78,7 +78,8 @@ void ResListPager::resultPageNext()
|
||||
m_respage = npage;
|
||||
}
|
||||
|
||||
void ResListPager::displayDoc(int i, Rcl::Doc& doc, const HiliteData& hdata,
|
||||
void ResListPager::displayDoc(RclConfig *config,
|
||||
int i, Rcl::Doc& doc, const HiliteData& hdata,
|
||||
const string& sh)
|
||||
{
|
||||
ostringstream chunk;
|
||||
@ -92,11 +93,11 @@ void ResListPager::displayDoc(int i, Rcl::Doc& doc, const HiliteData& hdata,
|
||||
}
|
||||
|
||||
// Determine icon to display if any
|
||||
string iconpath = iconPath(doc.mimetype);
|
||||
string iconpath = iconPath(config, doc.mimetype);
|
||||
|
||||
// Printable url: either utf-8 if transcoding succeeds, or url-encoded
|
||||
string url;
|
||||
printableUrl(RclConfig::getMainConfig()->getDefCharset(), doc.url, url);
|
||||
printableUrl(config->getDefCharset(), doc.url, url);
|
||||
|
||||
// Make title out of file name if none yet
|
||||
if (doc.meta[Rcl::Doc::keytt].empty()) {
|
||||
@ -149,7 +150,7 @@ void ResListPager::displayDoc(int i, Rcl::Doc& doc, const HiliteData& hdata,
|
||||
|
||||
// Links;
|
||||
ostringstream linksbuf;
|
||||
if (canIntern(doc.mimetype, RclConfig::getMainConfig())) {
|
||||
if (canIntern(doc.mimetype, config)) {
|
||||
linksbuf << "<a href=\"P" << docnumforlinks << "\">"
|
||||
<< trans("Preview") << "</a> ";
|
||||
}
|
||||
@ -159,7 +160,7 @@ void ResListPager::displayDoc(int i, Rcl::Doc& doc, const HiliteData& hdata,
|
||||
if ((it = doc.meta.find(Rcl::Doc::keyapptg)) != doc.meta.end())
|
||||
apptag = it->second;
|
||||
|
||||
if (!RclConfig::getMainConfig()->getMimeViewerDef(doc.mimetype, apptag).empty()) {
|
||||
if (!config->getMimeViewerDef(doc.mimetype, apptag).empty()) {
|
||||
linksbuf << "<a href=\"E" << docnumforlinks << "\">"
|
||||
<< trans("Open") << "</a>";
|
||||
}
|
||||
@ -205,7 +206,7 @@ void ResListPager::displayDoc(int i, Rcl::Doc& doc, const HiliteData& hdata,
|
||||
append(chunk.rdbuf()->str(), i, doc);
|
||||
}
|
||||
|
||||
void ResListPager::displayPage()
|
||||
void ResListPager::displayPage(RclConfig *config)
|
||||
{
|
||||
LOGDEB(("ResListPager::displayPage\n"));
|
||||
if (m_docSource.isNull()) {
|
||||
@ -296,7 +297,7 @@ void ResListPager::displayPage()
|
||||
for (int i = 0; i < (int)m_respage.size(); i++) {
|
||||
Rcl::Doc &doc(m_respage[i].doc);
|
||||
string& sh(m_respage[i].subHeader);
|
||||
displayDoc(i, doc, hdata, sh);
|
||||
displayDoc(config, i, doc, hdata, sh);
|
||||
}
|
||||
|
||||
// Footer
|
||||
@ -330,10 +331,10 @@ string ResListPager::prevUrl()
|
||||
return "p-1";
|
||||
}
|
||||
|
||||
string ResListPager::iconPath(const string& mtype)
|
||||
string ResListPager::iconPath(RclConfig *config, const string& mtype)
|
||||
{
|
||||
string iconpath;
|
||||
RclConfig::getMainConfig()->getMimeIconName(mtype, &iconpath);
|
||||
config->getMimeIconName(mtype, &iconpath);
|
||||
iconpath = string("file://") + iconpath;
|
||||
return iconpath;
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ using std::vector;
|
||||
#include "refcntr.h"
|
||||
#include "docseq.h"
|
||||
|
||||
class RclConfig;
|
||||
class PlainToRich;
|
||||
class HiliteData;
|
||||
|
||||
@ -65,9 +66,9 @@ public:
|
||||
resultPageNext();
|
||||
}
|
||||
void resultPageNext();
|
||||
void displayPage();
|
||||
void displayDoc(int idx, Rcl::Doc& doc, const HiliteData& hdata,
|
||||
const string& sh = "");
|
||||
void displayPage(RclConfig *);
|
||||
void displayDoc(RclConfig *, int idx, Rcl::Doc& doc,
|
||||
const HiliteData& hdata, const string& sh = "");
|
||||
bool pageEmpty() {return m_respage.size() == 0;}
|
||||
|
||||
string queryDescription() {return m_docSource.isNull() ? "" :
|
||||
@ -91,7 +92,7 @@ public:
|
||||
virtual string nextUrl();
|
||||
virtual string prevUrl();
|
||||
virtual string pageTop() {return string();}
|
||||
virtual string iconPath(const string& mtype);
|
||||
virtual string iconPath(RclConfig *, const string& mtype);
|
||||
virtual void suggest(const vector<string>, vector<string>&sugg) {
|
||||
sugg.clear();
|
||||
}
|
||||
|
||||
@ -24,6 +24,7 @@ static char rcsid[] = "@(#$Id: wasatorcl.cpp,v 1.18 2008-12-05 11:09:31 dockes E
|
||||
using std::string;
|
||||
using std::list;
|
||||
|
||||
#include "rclconfig.h"
|
||||
#include "wasastringtoquery.h"
|
||||
#include "rcldb.h"
|
||||
#include "searchdata.h"
|
||||
@ -34,14 +35,15 @@ using std::list;
|
||||
#include "refcntr.h"
|
||||
#include "textsplit.h"
|
||||
|
||||
Rcl::SearchData *wasaStringToRcl(const string &qs, string &reason,
|
||||
Rcl::SearchData *wasaStringToRcl(RclConfig *config,
|
||||
const string &qs, string &reason,
|
||||
const string& autosuffs)
|
||||
{
|
||||
StringToWasaQuery parser;
|
||||
WasaQuery *wq = parser.stringToQuery(qs, reason);
|
||||
if (wq == 0)
|
||||
return 0;
|
||||
Rcl::SearchData *rq = wasaQueryToRcl(wq, autosuffs);
|
||||
Rcl::SearchData *rq = wasaQueryToRcl(config, wq, autosuffs);
|
||||
if (rq == 0) {
|
||||
reason = "Failed translating xesam query structure to recoll";
|
||||
return 0;
|
||||
@ -49,7 +51,8 @@ Rcl::SearchData *wasaStringToRcl(const string &qs, string &reason,
|
||||
return rq;
|
||||
}
|
||||
|
||||
Rcl::SearchData *wasaQueryToRcl(WasaQuery *wasa, const string& autosuffs)
|
||||
Rcl::SearchData *wasaQueryToRcl(RclConfig *config,
|
||||
WasaQuery *wasa, const string& autosuffs)
|
||||
{
|
||||
if (wasa == 0)
|
||||
return 0;
|
||||
@ -91,9 +94,8 @@ Rcl::SearchData *wasaQueryToRcl(WasaQuery *wasa, const string& autosuffs)
|
||||
// categories like "audio", "presentation", etc.
|
||||
if (!stringicmp("rclcat", (*it)->m_fieldspec) ||
|
||||
!stringicmp("type", (*it)->m_fieldspec)) {
|
||||
RclConfig *conf = RclConfig::getMainConfig();
|
||||
list<string> mtypes;
|
||||
if (conf && conf->getMimeCatTypes((*it)->m_value, mtypes)) {
|
||||
if (config && config->getMimeCatTypes((*it)->m_value, mtypes)) {
|
||||
for (list<string>::iterator mit = mtypes.begin();
|
||||
mit != mtypes.end(); mit++) {
|
||||
sdata->addFiletype(*mit);
|
||||
@ -192,7 +194,7 @@ Rcl::SearchData *wasaQueryToRcl(WasaQuery *wasa, const string& autosuffs)
|
||||
LOGDEB2(("wasaQueryToRcl: OR clause [%s]:[%s]\n",
|
||||
(*it)->m_fieldspec.c_str(), (*it)->m_value.c_str()));
|
||||
// Create a subquery.
|
||||
Rcl::SearchData *sub = wasaQueryToRcl(*it);
|
||||
Rcl::SearchData *sub = wasaQueryToRcl(config, *it);
|
||||
if (sub == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -24,10 +24,13 @@ using std::string;
|
||||
#include "rcldb.h"
|
||||
#include "searchdata.h"
|
||||
|
||||
extern Rcl::SearchData *wasaStringToRcl(const string& query, string &reason,
|
||||
const string& autosuffs = string());
|
||||
class RclConfig;
|
||||
|
||||
extern Rcl::SearchData *wasaStringToRcl(RclConfig *,
|
||||
const string& query, string &reason,
|
||||
const string& autosuffs = string());
|
||||
class WasaQuery;
|
||||
extern Rcl::SearchData *wasaQueryToRcl(WasaQuery *wasa,
|
||||
extern Rcl::SearchData *wasaQueryToRcl(RclConfig *, WasaQuery *wasa,
|
||||
const string& autosuffs = string());
|
||||
|
||||
#endif /* _WASATORCL_H_INCLUDED_ */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user