|
a/src/common/rclconfig.h |
|
b/src/common/rclconfig.h |
|
... |
|
... |
14 |
* Free Software Foundation, Inc.,
|
14 |
* Free Software Foundation, Inc.,
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16 |
*/
|
16 |
*/
|
17 |
#ifndef _RCLCONFIG_H_INCLUDED_
|
17 |
#ifndef _RCLCONFIG_H_INCLUDED_
|
18 |
#define _RCLCONFIG_H_INCLUDED_
|
18 |
#define _RCLCONFIG_H_INCLUDED_
|
19 |
/* @(#$Id: rclconfig.h,v 1.37 2007-10-01 06:19:21 dockes Exp $ (C) 2004 J.F.Dockes */
|
19 |
/* @(#$Id: rclconfig.h,v 1.38 2007-10-09 09:43:10 dockes Exp $ (C) 2004 J.F.Dockes */
|
20 |
|
20 |
|
21 |
#include <list>
|
21 |
#include <list>
|
22 |
#include <string>
|
22 |
#include <string>
|
23 |
#include <vector>
|
23 |
#include <vector>
|
24 |
#include <utility>
|
24 |
#include <utility>
|
|
... |
|
... |
44 |
// the configuration parameter everywhere. Places where several
|
44 |
// the configuration parameter everywhere. Places where several
|
45 |
// RclConfig instances might be needed will take care of
|
45 |
// RclConfig instances might be needed will take care of
|
46 |
// themselves.
|
46 |
// themselves.
|
47 |
static RclConfig* getMainConfig();
|
47 |
static RclConfig* getMainConfig();
|
48 |
|
48 |
|
|
|
49 |
// Return a writable clone of the main config. This belongs to the
|
|
|
50 |
// caller (must delete it when done)
|
|
|
51 |
ConfNull *cloneMainConfig();
|
|
|
52 |
|
|
|
53 |
/** (re)Read recoll.conf */
|
|
|
54 |
bool updateMainConfig();
|
|
|
55 |
|
49 |
bool ok() {return m_ok;}
|
56 |
bool ok() {return m_ok;}
|
50 |
const string &getReason() {return m_reason;}
|
57 |
const string &getReason() {return m_reason;}
|
51 |
|
58 |
|
52 |
/** Return the directory where this configuration is stored */
|
59 |
/** Return the directory where this configuration is stored */
|
53 |
string getConfDir() {return m_confdir;}
|
60 |
string getConfDir() {return m_confdir;}
|
54 |
|
61 |
|
55 |
/** Set current directory reference, and fetch automatic parameters. */
|
62 |
/** Set current directory reference, and fetch automatic parameters. */
|
56 |
void setKeyDir(const string &dir)
|
63 |
void setKeyDir(const string &dir)
|
57 |
{
|
64 |
{
|
58 |
m_keydir = dir;
|
65 |
m_keydir = dir;
|
|
|
66 |
if (m_conf == 0)
|
|
|
67 |
return;
|
59 |
if (!m_conf->get("defaultcharset", defcharset, m_keydir))
|
68 |
if (!m_conf->get("defaultcharset", defcharset, m_keydir))
|
60 |
defcharset.erase();
|
69 |
defcharset.erase();
|
61 |
string str;
|
70 |
string str;
|
62 |
m_conf->get("guesscharset", str, m_keydir);
|
71 |
m_conf->get("guesscharset", str, m_keydir);
|
63 |
guesscharset = stringToBool(str);
|
72 |
guesscharset = stringToBool(str);
|
64 |
}
|
73 |
}
|
65 |
string getKeyDir() const {return m_keydir;}
|
74 |
string getKeyDir() const {return m_keydir;}
|
66 |
/** Get all defined key directories in configuration */
|
|
|
67 |
list<string> getKeyDirs() {return m_conf->getSubKeys();}
|
|
|
68 |
|
75 |
|
69 |
/** Get generic configuration parameter according to current keydir */
|
76 |
/** Get generic configuration parameter according to current keydir */
|
70 |
bool getConfParam(const string &name, string &value)
|
77 |
bool getConfParam(const string &name, string &value)
|
71 |
{
|
78 |
{
|
72 |
if (m_conf == 0)
|
79 |
if (m_conf == 0)
|
73 |
return false;
|
80 |
return false;
|
74 |
return m_conf->get(name, value, m_keydir);
|
81 |
return m_conf->get(name, value, m_keydir);
|
75 |
}
|
82 |
}
|
76 |
/** Set generic configuration parameter according to current keydir */
|
|
|
77 |
bool setConfParam(const string &name, const string &value)
|
|
|
78 |
{
|
|
|
79 |
if (m_conf == 0)
|
|
|
80 |
return false;
|
|
|
81 |
return m_conf->set(name, value, m_keydir);
|
|
|
82 |
}
|
|
|
83 |
/** Remove parameter from configuration */
|
|
|
84 |
bool eraseConfParam(const string &name)
|
|
|
85 |
{
|
|
|
86 |
if (m_conf == 0)
|
|
|
87 |
return false;
|
|
|
88 |
return m_conf->erase(name, m_keydir);
|
|
|
89 |
}
|
|
|
90 |
/** Remove parameter from configuration */
|
|
|
91 |
bool eraseKeyDir()
|
|
|
92 |
{
|
|
|
93 |
if (m_conf == 0)
|
|
|
94 |
return false;
|
|
|
95 |
return m_conf->eraseKey(m_keydir);
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
/** Variant with autoconversion to int */
|
83 |
/** Variant with autoconversion to int */
|
99 |
bool getConfParam(const std::string &name, int *value);
|
84 |
bool getConfParam(const std::string &name, int *value);
|
100 |
/** Variant with autoconversion to bool */
|
85 |
/** Variant with autoconversion to bool */
|
101 |
bool getConfParam(const std::string &name, bool *value);
|
86 |
bool getConfParam(const std::string &name, bool *value);
|
102 |
|
87 |
|
|
... |
|
... |
195 |
}
|
180 |
}
|
196 |
|
181 |
|
197 |
private:
|
182 |
private:
|
198 |
int m_ok;
|
183 |
int m_ok;
|
199 |
string m_reason; // Explanation for bad state
|
184 |
string m_reason; // Explanation for bad state
|
200 |
string m_confdir; // Directory where the files are stored
|
185 |
string m_confdir; // User directory where the customized files are stored
|
201 |
string m_datadir; // Example: /usr/local/share/recoll
|
186 |
string m_datadir; // Example: /usr/local/share/recoll
|
202 |
string m_keydir; // Current directory used for parameter fetches.
|
187 |
string m_keydir; // Current directory used for parameter fetches.
|
|
|
188 |
list<string> m_cdirs; // directory stack for the confstacks
|
203 |
|
189 |
|
204 |
ConfStack<ConfTree> *m_conf; // Parsed configuration files
|
190 |
ConfStack<ConfTree> *m_conf; // Parsed configuration files
|
205 |
ConfStack<ConfTree> *mimemap; // The files don't change with keydir,
|
191 |
ConfStack<ConfTree> *mimemap; // The files don't change with keydir,
|
206 |
ConfStack<ConfTree> *mimeconf; // but their content may depend on it.
|
192 |
ConfStack<ConfTree> *mimeconf; // but their content may depend on it.
|
207 |
ConfStack<ConfTree> *mimeview; //
|
193 |
ConfStack<ConfTree> *mimeview; //
|
|
... |
|
... |
213 |
string defcharset; // These are stored locally to avoid
|
199 |
string defcharset; // These are stored locally to avoid
|
214 |
bool guesscharset; // They are fetched initially or on setKeydir()
|
200 |
bool guesscharset; // They are fetched initially or on setKeydir()
|
215 |
|
201 |
|
216 |
/** Create initial user configuration */
|
202 |
/** Create initial user configuration */
|
217 |
bool initUserConfig();
|
203 |
bool initUserConfig();
|
218 |
|
|
|
219 |
/** Copy from other */
|
204 |
/** Copy from other */
|
220 |
void initFrom(const RclConfig& r);
|
205 |
void initFrom(const RclConfig& r);
|
221 |
/** Init pointers to 0 */
|
206 |
/** Init pointers to 0 */
|
222 |
void zeroMe() {
|
207 |
void zeroMe() {
|
223 |
m_ok = false;
|
208 |
m_ok = false;
|