marked const rclconfig methods

This commit is contained in:
Jean-Francois Dockes 2012-10-26 14:54:31 +02:00
parent 15ee5781c7
commit 6b1fe7195c
2 changed files with 123 additions and 120 deletions

View file

@ -98,7 +98,7 @@ void RclConfig::zeroMe() {
m_rmtstate.init(this, 0, "indexedmimetypes"); m_rmtstate.init(this, 0, "indexedmimetypes");
} }
bool RclConfig::isDefaultConfig() bool RclConfig::isDefaultConfig() const
{ {
string defaultconf = path_cat(path_canon(path_home()), ".recoll/"); string defaultconf = path_cat(path_canon(path_home()), ".recoll/");
string specifiedconf = path_canon(m_confdir); string specifiedconf = path_canon(m_confdir);
@ -106,6 +106,8 @@ bool RclConfig::isDefaultConfig()
return !defaultconf.compare(specifiedconf); return !defaultconf.compare(specifiedconf);
} }
string RclConfig::o_localecharset;
RclConfig::RclConfig(const string *argcnf) RclConfig::RclConfig(const string *argcnf)
{ {
zeroMe(); zeroMe();
@ -157,6 +159,34 @@ RclConfig::RclConfig(const string *argcnf)
return; return;
} }
// This can't change once computed inside a process. It would be
// nicer to move this to a static class initializer to avoid
// possible threading issues but this doesn't work (tried) as
// things would not be ready. In practise we make sure that this
// is called from the main thread at once, by constructing a config
// from recollinit
if (o_localecharset.empty()) {
const char *cp;
cp = nl_langinfo(CODESET);
// We don't keep US-ASCII. It's better to use a superset
// Ie: me have a C locale and some french file names, and I
// can't imagine a version of iconv that couldn't translate
// from iso8859?
// The 646 thing is for solaris.
if (cp && *cp && strcmp(cp, "US-ASCII")
#ifdef sun
&& strcmp(cp, "646")
#endif
) {
o_localecharset = string(cp);
} else {
// Use cp1252 instead of iso-8859-1, it's a superset.
o_localecharset = string(cstr_cp1252);
}
LOGDEB1(("RclConfig::getDefCharset: localecharset [%s]\n",
o_localecharset.c_str()));
}
m_cdirs.push_back(m_confdir); m_cdirs.push_back(m_confdir);
m_cdirs.push_back(path_cat(m_datadir, "examples")); m_cdirs.push_back(path_cat(m_datadir, "examples"));
string cnferrloc = m_confdir + " or " + path_cat(m_datadir, "examples"); string cnferrloc = m_confdir + " or " + path_cat(m_datadir, "examples");
@ -272,11 +302,11 @@ void RclConfig::setKeyDir(const string &dir)
if (m_conf == 0) if (m_conf == 0)
return; return;
if (!m_conf->get("defaultcharset", defcharset, m_keydir)) if (!m_conf->get("defaultcharset", m_defcharset, m_keydir))
defcharset.erase(); m_defcharset.erase();
} }
bool RclConfig::getConfParam(const string &name, int *ivp) bool RclConfig::getConfParam(const string &name, int *ivp) const
{ {
string value; string value;
if (!getConfParam(name, value)) if (!getConfParam(name, value))
@ -290,7 +320,7 @@ bool RclConfig::getConfParam(const string &name, int *ivp)
return true; return true;
} }
bool RclConfig::getConfParam(const string &name, bool *bvp) bool RclConfig::getConfParam(const string &name, bool *bvp) const
{ {
if (!bvp) if (!bvp)
return false; return false;
@ -303,7 +333,7 @@ bool RclConfig::getConfParam(const string &name, bool *bvp)
return true; return true;
} }
bool RclConfig::getConfParam(const string &name, vector<string> *svvp) bool RclConfig::getConfParam(const string &name, vector<string> *svvp) const
{ {
if (!svvp) if (!svvp)
return false; return false;
@ -313,7 +343,7 @@ bool RclConfig::getConfParam(const string &name, vector<string> *svvp)
return false; return false;
return stringToStrings(s, *svvp); return stringToStrings(s, *svvp);
} }
bool RclConfig::getConfParam(const string &name, list<string> *svvp) bool RclConfig::getConfParam(const string &name, list<string> *svvp) const
{ {
if (!svvp) if (!svvp)
return false; return false;
@ -324,7 +354,7 @@ bool RclConfig::getConfParam(const string &name, list<string> *svvp)
return stringToStrings(s, *svvp); return stringToStrings(s, *svvp);
} }
list<string> RclConfig::getTopdirs() list<string> RclConfig::getTopdirs() const
{ {
list<string> tdl; list<string> tdl;
if (!getConfParam("topdirs", &tdl)) { if (!getConfParam("topdirs", &tdl)) {
@ -348,49 +378,16 @@ list<string> RclConfig::getTopdirs()
// //
// For filenames, same thing except that we do not use the config file value // For filenames, same thing except that we do not use the config file value
// (only the locale). // (only the locale).
const string& RclConfig::getDefCharset(bool filename) const string& RclConfig::getDefCharset(bool filename) const
{ {
// This can't change once computed inside a process. It would be
// nicer to move this to a static class initializer to avoid
// possible threading issues but this doesn't work (tried) as
// things would not be ready. In practise we make sure that this
// is called from the main thread at once, by calling
// getDefCharset from recollinit
static string localecharset;
if (localecharset.empty()) {
const char *cp;
cp = nl_langinfo(CODESET);
// We don't keep US-ASCII. It's better to use a superset
// Ie: me have a C locale and some french file names, and I
// can't imagine a version of iconv that couldn't translate
// from iso8859?
// The 646 thing is for solaris.
if (cp && *cp && strcmp(cp, "US-ASCII")
#ifdef sun
&& strcmp(cp, "646")
#endif
) {
localecharset = string(cp);
} else {
// Use cp1252 instead of iso-8859-1, it's a superset.
localecharset = string(cstr_cp1252);
}
LOGDEB1(("RclConfig::getDefCharset: localecharset [%s]\n",
localecharset.c_str()));
}
if (defcharset.empty()) {
defcharset = localecharset;
}
if (filename) { if (filename) {
return localecharset; return o_localecharset;
} else { } else {
return defcharset; return m_defcharset.empty() ? o_localecharset : m_defcharset;
} }
} }
bool RclConfig::addLocalFields(map<string, string> *tgt) bool RclConfig::addLocalFields(map<string, string> *tgt) const
{ {
LOGDEB0(("RclConfig::addLocalFields: keydir [%s]\n", m_keydir.c_str())); LOGDEB0(("RclConfig::addLocalFields: keydir [%s]\n", m_keydir.c_str()));
string sfields; string sfields;
@ -421,7 +418,7 @@ bool RclConfig::addLocalFields(map<string, string> *tgt)
// //
// This unfortunately means that searches by file names and mime type // This unfortunately means that searches by file names and mime type
// filtering don't work well together. // filtering don't work well together.
vector<string> RclConfig::getAllMimeTypes() vector<string> RclConfig::getAllMimeTypes() const
{ {
vector<string> lst; vector<string> lst;
if (mimeconf == 0) if (mimeconf == 0)
@ -506,14 +503,14 @@ bool RclConfig::inStopSuffixes(const string& fni)
} }
} }
string RclConfig::getMimeTypeFromSuffix(const string& suff) string RclConfig::getMimeTypeFromSuffix(const string& suff) const
{ {
string mtype; string mtype;
mimemap->get(suff, mtype, m_keydir); mimemap->get(suff, mtype, m_keydir);
return mtype; return mtype;
} }
string RclConfig::getSuffixFromMimeType(const string &mt) string RclConfig::getSuffixFromMimeType(const string &mt) const
{ {
string suffix; string suffix;
vector<string>sfs = mimemap->getNames(cstr_null); vector<string>sfs = mimemap->getNames(cstr_null);
@ -528,7 +525,7 @@ string RclConfig::getSuffixFromMimeType(const string &mt)
} }
/** Get list of file categories from mimeconf */ /** Get list of file categories from mimeconf */
bool RclConfig::getMimeCategories(vector<string>& cats) bool RclConfig::getMimeCategories(vector<string>& cats) const
{ {
if (!mimeconf) if (!mimeconf)
return false; return false;
@ -536,7 +533,7 @@ bool RclConfig::getMimeCategories(vector<string>& cats)
return true; return true;
} }
bool RclConfig::isMimeCategory(string& cat) bool RclConfig::isMimeCategory(string& cat) const
{ {
vector<string>cats; vector<string>cats;
getMimeCategories(cats); getMimeCategories(cats);
@ -548,7 +545,7 @@ bool RclConfig::isMimeCategory(string& cat)
} }
/** Get list of mime types for category from mimeconf */ /** Get list of mime types for category from mimeconf */
bool RclConfig::getMimeCatTypes(const string& cat, vector<string>& tps) bool RclConfig::getMimeCatTypes(const string& cat, vector<string>& tps) const
{ {
tps.clear(); tps.clear();
if (!mimeconf) if (!mimeconf)
@ -581,7 +578,7 @@ string RclConfig::getMimeHandlerDef(const string &mtype, bool filtertypes)
return hs; return hs;
} }
bool RclConfig::getGuiFilterNames(vector<string>& cats) bool RclConfig::getGuiFilterNames(vector<string>& cats) const
{ {
if (!mimeconf) if (!mimeconf)
return false; return false;
@ -589,7 +586,7 @@ bool RclConfig::getGuiFilterNames(vector<string>& cats)
return true; return true;
} }
bool RclConfig::getGuiFilter(const string& catfiltername, string& frag) bool RclConfig::getGuiFilter(const string& catfiltername, string& frag) const
{ {
frag.clear(); frag.clear();
if (!mimeconf) if (!mimeconf)
@ -623,7 +620,7 @@ bool RclConfig::valueSplitAttributes(const string& whole, string& value,
} }
string RclConfig::getMissingHelperDesc() string RclConfig::getMissingHelperDesc() const
{ {
string fmiss = path_cat(getConfDir(), "missing"); string fmiss = path_cat(getConfDir(), "missing");
string out; string out;
@ -735,6 +732,7 @@ bool RclConfig::readFieldsConfig(const string& cnferrloc)
// Return specifics for field name: // Return specifics for field name:
bool RclConfig::getFieldTraits(const string& _fld, const FieldTraits **ftpp) bool RclConfig::getFieldTraits(const string& _fld, const FieldTraits **ftpp)
const
{ {
string fld = fieldCanon(_fld); string fld = fieldCanon(_fld);
map<string, FieldTraits>::const_iterator pit = m_fldtotraits.find(fld); map<string, FieldTraits>::const_iterator pit = m_fldtotraits.find(fld);
@ -751,7 +749,7 @@ bool RclConfig::getFieldTraits(const string& _fld, const FieldTraits **ftpp)
} }
} }
set<string> RclConfig::getIndexedFields() set<string> RclConfig::getIndexedFields() const
{ {
set<string> flds; set<string> flds;
if (m_fields == 0) if (m_fields == 0)
@ -762,7 +760,7 @@ set<string> RclConfig::getIndexedFields()
return flds; return flds;
} }
string RclConfig::fieldCanon(const string& f) string RclConfig::fieldCanon(const string& f) const
{ {
string fld = stringtolower(f); string fld = stringtolower(f);
map<string, string>::const_iterator it = m_aliastocanon.find(fld); map<string, string>::const_iterator it = m_aliastocanon.find(fld);
@ -776,6 +774,7 @@ string RclConfig::fieldCanon(const string& f)
} }
vector<string> RclConfig::getFieldSectNames(const string &sk, const char* patrn) vector<string> RclConfig::getFieldSectNames(const string &sk, const char* patrn)
const
{ {
if (m_fields == 0) if (m_fields == 0)
return vector<string>(); return vector<string>();
@ -783,14 +782,14 @@ vector<string> RclConfig::getFieldSectNames(const string &sk, const char* patrn)
} }
bool RclConfig::getFieldConfParam(const string &name, const string &sk, bool RclConfig::getFieldConfParam(const string &name, const string &sk,
string &value) string &value) const
{ {
if (m_fields == 0) if (m_fields == 0)
return false; return false;
return m_fields->get(name, value, sk); return m_fields->get(name, value, sk);
} }
string RclConfig::getMimeViewerAllEx() string RclConfig::getMimeViewerAllEx() const
{ {
string hs; string hs;
if (mimeview == 0) if (mimeview == 0)
@ -807,12 +806,12 @@ bool RclConfig::setMimeViewerAllEx(const string& allex)
m_reason = string("RclConfig:: cant set value. Readonly?"); m_reason = string("RclConfig:: cant set value. Readonly?");
return false; return false;
} }
return true; return true;
} }
string RclConfig::getMimeViewerDef(const string &mtype, const string& apptag, string RclConfig::getMimeViewerDef(const string &mtype, const string& apptag,
bool useall) bool useall) const
{ {
LOGDEB2(("RclConfig::getMimeViewerDef: mtype [%s] apptag [%s]\n", LOGDEB2(("RclConfig::getMimeViewerDef: mtype [%s] apptag [%s]\n",
mtype.c_str(), apptag.c_str())); mtype.c_str(), apptag.c_str()));
@ -851,7 +850,7 @@ string RclConfig::getMimeViewerDef(const string &mtype, const string& apptag,
return hs; return hs;
} }
bool RclConfig::getMimeViewerDefs(vector<pair<string, string> >& defs) bool RclConfig::getMimeViewerDefs(vector<pair<string, string> >& defs) const
{ {
if (mimeview == 0) if (mimeview == 0)
return false; return false;
@ -874,7 +873,7 @@ bool RclConfig::setMimeViewerDef(const string& mt, const string& def)
return true; return true;
} }
bool RclConfig::mimeViewerNeedsUncomp(const string &mimetype) bool RclConfig::mimeViewerNeedsUncomp(const string &mimetype) const
{ {
string s; string s;
vector<string> v; vector<string> v;
@ -886,6 +885,7 @@ bool RclConfig::mimeViewerNeedsUncomp(const string &mimetype)
} }
string RclConfig::getMimeIconPath(const string &mtype, const string &apptag) string RclConfig::getMimeIconPath(const string &mtype, const string &apptag)
const
{ {
string iconname; string iconname;
if (!apptag.empty()) if (!apptag.empty())
@ -911,7 +911,7 @@ string RclConfig::getMimeIconPath(const string &mtype, const string &apptag)
return path_cat(iconpath, iconname) + ".png"; return path_cat(iconpath, iconname) + ".png";
} }
string RclConfig::getDbDir() string RclConfig::getDbDir() const
{ {
string dbdir; string dbdir;
if (!getConfParam("dbdir", dbdir)) { if (!getConfParam("dbdir", dbdir)) {
@ -928,7 +928,7 @@ string RclConfig::getDbDir()
return path_canon(dbdir); return path_canon(dbdir);
} }
bool RclConfig::sourceChanged() bool RclConfig::sourceChanged() const
{ {
if (m_conf && m_conf->sourceChanged()) if (m_conf && m_conf->sourceChanged())
return true; return true;
@ -943,18 +943,18 @@ bool RclConfig::sourceChanged()
return false; return false;
} }
string RclConfig::getStopfile() string RclConfig::getStopfile() const
{ {
return path_cat(getConfDir(), "stoplist.txt"); return path_cat(getConfDir(), "stoplist.txt");
} }
string RclConfig::getPidfile() string RclConfig::getPidfile() const
{ {
return path_cat(getConfDir(), "index.pid"); return path_cat(getConfDir(), "index.pid");
} }
// The index status file is fast changing, so it's possible to put it outside // The index status file is fast changing, so it's possible to put it outside
// of the config directory (for ssds, not sure this is really useful). // of the config directory (for ssds, not sure this is really useful).
string RclConfig::getIdxStatusFile() string RclConfig::getIdxStatusFile() const
{ {
string path; string path;
if (!getConfParam("idxstatusfile", path)) { if (!getConfParam("idxstatusfile", path)) {
@ -977,7 +977,7 @@ vector<string>& RclConfig::getSkippedNames()
return m_skpnlist; return m_skpnlist;
} }
vector<string> RclConfig::getSkippedPaths() vector<string> RclConfig::getSkippedPaths() const
{ {
vector<string> skpl; vector<string> skpl;
getConfParam("skippedPaths", &skpl); getConfParam("skippedPaths", &skpl);
@ -997,7 +997,7 @@ vector<string> RclConfig::getSkippedPaths()
return skpl; return skpl;
} }
vector<string> RclConfig::getDaemSkippedPaths() vector<string> RclConfig::getDaemSkippedPaths() const
{ {
vector<string> dskpl; vector<string> dskpl;
getConfParam("daemSkippedPaths", &dskpl); getConfParam("daemSkippedPaths", &dskpl);
@ -1024,7 +1024,7 @@ vector<string> RclConfig::getDaemSkippedPaths()
// Look up an executable filter. We look in $RECOLL_FILTERSDIR, // Look up an executable filter. We look in $RECOLL_FILTERSDIR,
// filtersdir in config file, then let the system use the PATH // filtersdir in config file, then let the system use the PATH
string RclConfig::findFilter(const string &icmd) string RclConfig::findFilter(const string &icmd) const
{ {
// If the path is absolute, this is it // If the path is absolute, this is it
if (icmd[0] == '/') if (icmd[0] == '/')
@ -1066,7 +1066,7 @@ string RclConfig::findFilter(const string &icmd)
/** /**
* Return decompression command line for given mime type * Return decompression command line for given mime type
*/ */
bool RclConfig::getUncompressor(const string &mtype, vector<string>& cmd) bool RclConfig::getUncompressor(const string &mtype, vector<string>& cmd) const
{ {
string hs; string hs;
@ -1177,7 +1177,7 @@ void RclConfig::initFrom(const RclConfig& r)
if (r.m_stopsuffixes) if (r.m_stopsuffixes)
m_stopsuffixes = new SuffixStore(*((SuffixStore*)r.m_stopsuffixes)); m_stopsuffixes = new SuffixStore(*((SuffixStore*)r.m_stopsuffixes));
m_maxsufflen = r.m_maxsufflen; m_maxsufflen = r.m_maxsufflen;
defcharset = r.defcharset; m_defcharset = r.m_defcharset;
m_stpsuffstate.init(this, mimemap, r.m_stpsuffstate.paramname); m_stpsuffstate.init(this, mimemap, r.m_stpsuffstate.paramname);
m_skpnstate.init(this, m_conf, r.m_skpnstate.paramname); m_skpnstate.init(this, m_conf, r.m_skpnstate.paramname);

View file

@ -80,53 +80,54 @@ class RclConfig {
/** (re)Read recoll.conf */ /** (re)Read recoll.conf */
bool updateMainConfig(); bool updateMainConfig();
bool ok() {return m_ok;} bool ok() const {return m_ok;}
const string &getReason() {return m_reason;} const string &getReason() const {return m_reason;}
/** Return the directory where this configuration is stored. /** Return the directory where this configuration is stored.
* This was possibly silently created by the rclconfig * This was possibly silently created by the rclconfig
* constructor it it is the default one (~/.recoll) and it did * constructor it it is the default one (~/.recoll) and it did
* not exist yet. */ * not exist yet. */
string getConfDir() {return m_confdir;} string getConfDir() const {return m_confdir;}
/** Check if the config files were modified since we read them */ /** Check if the config files were modified since we read them */
bool sourceChanged(); bool sourceChanged() const;
/** Returns true if this is ~/.recoll */ /** Returns true if this is ~/.recoll */
bool isDefaultConfig(); bool isDefaultConfig() const;
/** Get the local value for /usr/local/share/recoll/ */ /** Get the local value for /usr/local/share/recoll/ */
const string& getDatadir() {return m_datadir;} const string& getDatadir() const {return m_datadir;}
/** Set current directory reference, and fetch automatic parameters. */ /** Set current directory reference, and fetch automatic parameters. */
void setKeyDir(const string &dir); void setKeyDir(const string &dir);
string getKeyDir() const {return m_keydir;} string getKeyDir() const {return m_keydir;}
/** Get generic configuration parameter according to current keydir */ /** Get generic configuration parameter according to current keydir */
bool getConfParam(const string &name, string &value) bool getConfParam(const string &name, string &value) const
{ {
if (m_conf == 0) if (m_conf == 0)
return false; return false;
return m_conf->get(name, value, m_keydir); return m_conf->get(name, value, m_keydir);
} }
/** Variant with autoconversion to int */ /** Variant with autoconversion to int */
bool getConfParam(const string &name, int *value); bool getConfParam(const string &name, int *value) const;
/** Variant with autoconversion to bool */ /** Variant with autoconversion to bool */
bool getConfParam(const string &name, bool *value); bool getConfParam(const string &name, bool *value) const;
/** Variant with conversion to string list/vector /** Variant with conversion to string list/vector
* (stringToStrings). Can fail if the string is malformed. */ * (stringToStrings). Can fail if the string is malformed. */
bool getConfParam(const string &name, vector<string> *value); bool getConfParam(const string &name, vector<string> *value) const;
bool getConfParam(const string &name, list<string> *value); bool getConfParam(const string &name, list<string> *value) const;
/** /**
* Get list of config names under current sk, with possible * Get list of config names under current sk, with possible
* wildcard filtering * wildcard filtering
*/ */
vector<string> getConfNames(const char *pattern = 0) { vector<string> getConfNames(const char *pattern = 0) const
{
return m_conf->getNames(m_keydir, pattern); return m_conf->getNames(m_keydir, pattern);
} }
/** Check if name exists anywhere in config */ /** Check if name exists anywhere in config */
bool hasNameAnywhere(const string& nm) bool hasNameAnywhere(const string& nm) const
{ {
return m_conf? m_conf->hasNameAnywhere(nm) : false; return m_conf? m_conf->hasNameAnywhere(nm) : false;
} }
@ -134,33 +135,33 @@ class RclConfig {
/** Get default charset for current keydir (was set during setKeydir) /** Get default charset for current keydir (was set during setKeydir)
* filenames are handled differently */ * filenames are handled differently */
const string &getDefCharset(bool filename = false); const string &getDefCharset(bool filename = false) const;
/** Get list of top directories. This is needed from a number of places /** Get list of top directories. This is needed from a number of places
* and needs some cleaning-up code. An empty list is always an error, no * and needs some cleaning-up code. An empty list is always an error, no
* need for other status */ * need for other status */
list<string> getTopdirs(); list<string> getTopdirs() const;
/** Get database directory */ /** Get database directory */
string getDbDir(); string getDbDir() const;
/** Get stoplist file name */ /** Get stoplist file name */
string getStopfile(); string getStopfile() const;
/** Get indexing pid file name */ /** Get indexing pid file name */
string getPidfile(); string getPidfile() const;
/** Get indexing status file name */ /** Get indexing status file name */
string getIdxStatusFile(); string getIdxStatusFile() const;
/** Get list of skipped file names for current keydir */ /** Get list of skipped file names for current keydir */
vector<string>& getSkippedNames(); vector<string>& getSkippedNames();
/** Get list of skipped paths patterns. Doesn't depend on the keydir */ /** Get list of skipped paths patterns. Doesn't depend on the keydir */
vector<string> getSkippedPaths(); vector<string> getSkippedPaths() const;
/** Get list of skipped paths patterns, daemon version (may add some) /** Get list of skipped paths patterns, daemon version (may add some)
Doesn't depend on the keydir */ Doesn't depend on the keydir */
vector<string> getDaemSkippedPaths(); vector<string> getDaemSkippedPaths() const;
/** conf: Add local fields to target dic */ /** conf: Add local fields to target dic */
bool addLocalFields(map<string, string> *tgt); bool addLocalFields(map<string, string> *tgt) const;
/** /**
* mimemap: Check if file name should be ignored because of suffix * mimemap: Check if file name should be ignored because of suffix
@ -177,14 +178,14 @@ class RclConfig {
* The returned command has substitutable places for input file name * The returned command has substitutable places for input file name
* and temp dir name, and will return output name * and temp dir name, and will return output name
*/ */
bool getUncompressor(const string &mtpe, vector<string>& cmd); bool getUncompressor(const string &mtpe, vector<string>& cmd) const;
/** mimemap: compute mimetype */ /** mimemap: compute mimetype */
string getMimeTypeFromSuffix(const string &suffix); string getMimeTypeFromSuffix(const string &suffix) const;
/** mimemap: get a list of all indexable mime types defined */ /** mimemap: get a list of all indexable mime types defined */
vector<string> getAllMimeTypes(); vector<string> getAllMimeTypes() const;
/** mimemap: Get appropriate suffix for mime type. This is inefficient */ /** mimemap: Get appropriate suffix for mime type. This is inefficient */
string getSuffixFromMimeType(const string &mt); string getSuffixFromMimeType(const string &mt) const;
/** mimeconf: get input filter for mimetype */ /** mimeconf: get input filter for mimetype */
string getMimeHandlerDef(const string &mimetype, bool filtertypes=false); string getMimeHandlerDef(const string &mimetype, bool filtertypes=false);
@ -193,57 +194,58 @@ class RclConfig {
* Separate the value and store the attributes in a ConfSimple * Separate the value and store the attributes in a ConfSimple
* @param whole the raw value. No way to escape a semi-colon in there. * @param whole the raw value. No way to escape a semi-colon in there.
*/ */
bool valueSplitAttributes(const string& whole, string& value, static bool valueSplitAttributes(const string& whole, string& value,
ConfSimple& attrs); ConfSimple& attrs) ;
/** Return icon path for mime type and tag */ /** Return icon path for mime type and tag */
string getMimeIconPath(const string &mt, const string& apptag); string getMimeIconPath(const string &mt, const string& apptag) const;
/** mimeconf: get list of file categories */ /** mimeconf: get list of file categories */
bool getMimeCategories(vector<string>&); bool getMimeCategories(vector<string>&) const;
/** mimeconf: is parameter one of the categories ? */ /** mimeconf: is parameter one of the categories ? */
bool isMimeCategory(string&); bool isMimeCategory(string&) const;
/** mimeconf: get list of mime types for category */ /** mimeconf: get list of mime types for category */
bool getMimeCatTypes(const string& cat, vector<string>&); bool getMimeCatTypes(const string& cat, vector<string>&) const;
/** mimeconf: get list of gui filters (doc cats by default */ /** mimeconf: get list of gui filters (doc cats by default */
bool getGuiFilterNames(vector<string>&); bool getGuiFilterNames(vector<string>&) const;
/** mimeconf: get query lang frag for named filter */ /** mimeconf: get query lang frag for named filter */
bool getGuiFilter(const string& filtername, string& frag); bool getGuiFilter(const string& filtername, string& frag) const;
/** fields: get field prefix from field name */ /** fields: get field prefix from field name */
bool getFieldTraits(const string& fldname, const FieldTraits **); bool getFieldTraits(const string& fldname, const FieldTraits **) const;
const set<string>& getStoredFields() {return m_storedFields;} const set<string>& getStoredFields() const {return m_storedFields;}
set<string> getIndexedFields(); set<string> getIndexedFields() const;
/** Get canonic name for possible alias */ /** Get canonic name for possible alias */
string fieldCanon(const string& fld); string fieldCanon(const string& fld) const;
/** Get xattr name to field names translations */ /** Get xattr name to field names translations */
const map<string, string>& getXattrToField() {return m_xattrtofld;} const map<string, string>& getXattrToField() const {return m_xattrtofld;}
/** Get value of a parameter inside the "fields" file. Only some filters /** Get value of a parameter inside the "fields" file. Only some filters
use this (ie: mh_mail). The information specific to a given filter use this (ie: mh_mail). The information specific to a given filter
is typically stored in a separate section(ie: [mail]) */ is typically stored in a separate section(ie: [mail]) */
vector<string> getFieldSectNames(const string &sk, const char* = 0); vector<string> getFieldSectNames(const string &sk, const char* = 0) const;
bool getFieldConfParam(const string &name, const string &sk, string &value); bool getFieldConfParam(const string &name, const string &sk, string &value)
const;
/** mimeview: get/set external viewer exec string(s) for mimetype(s) */ /** mimeview: get/set external viewer exec string(s) for mimetype(s) */
string getMimeViewerDef(const string &mimetype, const string& apptag, string getMimeViewerDef(const string &mimetype, const string& apptag,
bool useall); bool useall) const;
string getMimeViewerAllEx(); string getMimeViewerAllEx() const;
bool setMimeViewerAllEx(const string& allex); bool setMimeViewerAllEx(const string& allex);
bool getMimeViewerDefs(vector<pair<string, string> >&); bool getMimeViewerDefs(vector<pair<string, string> >&) const;
bool setMimeViewerDef(const string& mimetype, const string& cmd); bool setMimeViewerDef(const string& mimetype, const string& cmd);
/** Check if mime type is designated as needing no uncompress before view /** Check if mime type is designated as needing no uncompress before view
* (if a file of this type is found compressed). Default is true, * (if a file of this type is found compressed). Default is true,
* exceptions are found in the nouncompforviewmts mimeview list */ * exceptions are found in the nouncompforviewmts mimeview list */
bool mimeViewerNeedsUncomp(const string &mimetype); bool mimeViewerNeedsUncomp(const string &mimetype) const;
/** Store/retrieve missing helpers description string */ /** Store/retrieve missing helpers description string */
string getMissingHelperDesc(); string getMissingHelperDesc() const;
void storeMissingHelperDesc(const string &s); void storeMissingHelperDesc(const string &s);
/** Find exec file for external filter. cmd is the command name from the /** Find exec file for external filter. cmd is the command name from the
* command string returned by getMimeHandlerDef */ * command string returned by getMimeHandlerDef */
string findFilter(const string& cmd); string findFilter(const string& cmd) const;
~RclConfig() { ~RclConfig() {
freeAll(); freeAll();
@ -290,7 +292,8 @@ class RclConfig {
vector<string> m_skpnlist; vector<string> m_skpnlist;
// Parameters auto-fetched on setkeydir // Parameters auto-fetched on setkeydir
string defcharset; string m_defcharset;
static string o_localecharset;
// Limiting set of mime types to be processed. Normally empty. // Limiting set of mime types to be processed. Normally empty.
ParamStale m_rmtstate; ParamStale m_rmtstate;
set<string> m_restrictMTypes; set<string> m_restrictMTypes;