got rid of accesses to global config through getMainConfig()
This commit is contained in:
@@ -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_ */
|
||||
|
||||
Reference in New Issue
Block a user