RECOLL_EXTRA_DBS environment variable
This commit is contained in:
parent
678e661190
commit
ab905355b6
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: guiutils.cpp,v 1.7 2006-04-05 13:39:07 dockes Exp $ (C) 2005 Jean-Francois Dockes";
|
static char rcsid[] = "@(#$Id: guiutils.cpp,v 1.8 2006-04-07 13:08:08 dockes Exp $ (C) 2005 Jean-Francois Dockes";
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -25,6 +25,7 @@ static char rcsid[] = "@(#$Id: guiutils.cpp,v 1.7 2006-04-05 13:39:07 dockes Exp
|
|||||||
#include "guiutils.h"
|
#include "guiutils.h"
|
||||||
#include "pathut.h"
|
#include "pathut.h"
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
|
#include "rcldb.h"
|
||||||
|
|
||||||
#include <qsettings.h>
|
#include <qsettings.h>
|
||||||
#include <qstringlist.h>
|
#include <qstringlist.h>
|
||||||
@ -32,8 +33,10 @@ static char rcsid[] = "@(#$Id: guiutils.cpp,v 1.7 2006-04-05 13:39:07 dockes Exp
|
|||||||
const static char *htmlbrowserlist =
|
const static char *htmlbrowserlist =
|
||||||
"opera konqueror firefox mozilla netscape";
|
"opera konqueror firefox mozilla netscape";
|
||||||
|
|
||||||
// Search for and launch an html browser for the documentation. If the
|
/**
|
||||||
// user has set a preference, we use it directly instead of guessing.
|
* Search for and launch an html browser for the documentation. If the
|
||||||
|
* user has set a preference, we use it directly instead of guessing.
|
||||||
|
*/
|
||||||
bool startHelpBrowser(const string &iurl)
|
bool startHelpBrowser(const string &iurl)
|
||||||
{
|
{
|
||||||
string url;
|
string url;
|
||||||
@ -44,7 +47,6 @@ bool startHelpBrowser(const string &iurl)
|
|||||||
} else
|
} else
|
||||||
url = iurl;
|
url = iurl;
|
||||||
|
|
||||||
|
|
||||||
// If the user set a preference with an absolute path then things are
|
// If the user set a preference with an absolute path then things are
|
||||||
// simple
|
// simple
|
||||||
if (!prefs.htmlBrowser.isEmpty() && prefs.htmlBrowser.find('/') != -1) {
|
if (!prefs.htmlBrowser.isEmpty() && prefs.htmlBrowser.find('/') != -1) {
|
||||||
@ -97,11 +99,11 @@ bool startHelpBrowser(const string &iurl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////
|
// The global preferences structure
|
||||||
// Global variables for user preferences. These are set in the user preference
|
|
||||||
// dialog and saved restored to the appropriate place in the qt settings
|
|
||||||
PrefsPack prefs;
|
PrefsPack prefs;
|
||||||
|
|
||||||
|
// Using the same macro to read/write a setting. insurance against typing
|
||||||
|
// mistakes
|
||||||
#define SETTING_RW(var, nm, tp, def) \
|
#define SETTING_RW(var, nm, tp, def) \
|
||||||
if (writing) { \
|
if (writing) { \
|
||||||
settings.writeEntry(nm , var); \
|
settings.writeEntry(nm , var); \
|
||||||
@ -109,6 +111,11 @@ PrefsPack prefs;
|
|||||||
var = settings.read##tp##Entry(nm, def); \
|
var = settings.read##tp##Entry(nm, def); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saving and restoring user preferences. These are stored in a global
|
||||||
|
* structure during program execution and saved to disk using the QT
|
||||||
|
* settings mechanism
|
||||||
|
*/
|
||||||
void rwSettings(bool writing)
|
void rwSettings(bool writing)
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
@ -132,6 +139,12 @@ void rwSettings(bool writing)
|
|||||||
SETTING_RW(prefs.queryReplaceAbstract,
|
SETTING_RW(prefs.queryReplaceAbstract,
|
||||||
"/Recoll/prefs/query/replaceAbstract", Bool, false);
|
"/Recoll/prefs/query/replaceAbstract", Bool, false);
|
||||||
|
|
||||||
|
// The extra databases settings. These are stored as a list of
|
||||||
|
// xapian directory names, encoded in base64 to avoid any
|
||||||
|
// binary/charset conversion issues. There are 2 lists for all
|
||||||
|
// known dbs and active (searched) ones.
|
||||||
|
// When starting up, we also add from the RECOLL_EXTRA_DBS environment
|
||||||
|
// variable.
|
||||||
QStringList qsl;
|
QStringList qsl;
|
||||||
if (writing) {
|
if (writing) {
|
||||||
for (list<string>::const_iterator it = prefs.allExtraDbs.begin();
|
for (list<string>::const_iterator it = prefs.allExtraDbs.begin();
|
||||||
@ -158,7 +171,24 @@ void rwSettings(bool writing)
|
|||||||
base64_decode((*it).ascii(), dec);
|
base64_decode((*it).ascii(), dec);
|
||||||
prefs.allExtraDbs.push_back(dec);
|
prefs.allExtraDbs.push_back(dec);
|
||||||
}
|
}
|
||||||
|
const char *cp;
|
||||||
|
if ((cp = getenv("RECOLL_EXTRA_DBS")) != 0) {
|
||||||
|
list<string> dbl;
|
||||||
|
stringToTokens(cp, dbl, ":");
|
||||||
|
for (list<string>::iterator dit = dbl.begin(); dit != dbl.end();
|
||||||
|
dit++) {
|
||||||
|
string dbdir = path_canon(*dit);
|
||||||
|
path_catslash(dbdir);
|
||||||
|
if (find(prefs.allExtraDbs.begin(), prefs.allExtraDbs.end(),
|
||||||
|
dbdir) != prefs.allExtraDbs.end())
|
||||||
|
continue;
|
||||||
|
if (!Rcl::Db::testDbDir(dbdir)) {
|
||||||
|
LOGERR(("Not a xapian database: [%s]\n", dbdir.c_str()));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
prefs.allExtraDbs.push_back(dbdir);
|
||||||
|
}
|
||||||
|
}
|
||||||
qsl = settings.readListEntry("/Recoll/prefs/query/activeExtraDbs");
|
qsl = settings.readListEntry("/Recoll/prefs/query/activeExtraDbs");
|
||||||
prefs.activeExtraDbs.clear();
|
prefs.activeExtraDbs.clear();
|
||||||
for (QStringList::iterator it = qsl.begin(); it != qsl.end(); it++) {
|
for (QStringList::iterator it = qsl.begin(); it != qsl.end(); it++) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user