indexedmimetypes

This commit is contained in:
dockes
2007-11-16 14:28:52 +00:00
parent 5aaa3032d9
commit 57b6f22901
5 changed files with 61 additions and 23 deletions
+39 -2
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.54 2007-10-17 09:57:23 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.55 2007-11-16 14:28:52 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -167,6 +167,35 @@ ConfNull *RclConfig::cloneMainConfig()
return conf;
}
// Remember what directory we're under (for further conf->get()s), and
// prefetch a few common values.
void RclConfig::setKeyDir(const string &dir)
{
m_keydir = dir;
if (m_conf == 0)
return;
if (!m_conf->get("defaultcharset", defcharset, m_keydir))
defcharset.erase();
getConfParam("guesscharset", &guesscharset);
string rmtstr;
if (m_conf->get("indexedmimetypes", rmtstr, m_keydir)) {
stringtolower(rmtstr);
if (rmtstr != m_rmtstr) {
LOGDEB2(("RclConfig::setKeyDir: rmtstr [%s]\n", rmtstr.c_str()));
m_rmtstr = rmtstr;
list<string> l;
// Yea, no good to go string->list->set. Lazy me.
stringToStrings(rmtstr, l);
for (list<string>::iterator it = l.begin(); it !=l.end(); it++) {
m_restrictMTypes.insert(*it);
}
}
}
}
bool RclConfig::getConfParam(const std::string &name, int *ivp)
{
string value;
@@ -407,9 +436,15 @@ bool RclConfig::getMimeCatTypes(const string& cat, list<string>& tps)
return true;
}
string RclConfig::getMimeHandlerDef(const std::string &mtype)
string RclConfig::getMimeHandlerDef(const std::string &mtype, bool filtertypes)
{
string hs;
if (filtertypes && !m_restrictMTypes.empty()) {
string mt = mtype;
stringtolower(mt);
if (m_restrictMTypes.find(mt) == m_restrictMTypes.end())
return hs;
}
if (!mimeconf->get(mtype, hs, "index")) {
LOGDEB1(("getMimeHandler: no handler for '%s'\n", mtype.c_str()));
}
@@ -718,6 +753,8 @@ void RclConfig::initFrom(const RclConfig& r)
m_maxsufflen = r.m_maxsufflen;
defcharset = r.defcharset;
guesscharset = r.guesscharset;
m_rmtstr = r.m_rmtstr;
m_restrictMTypes = r.m_restrictMTypes;
}
#else // -> Test
+8 -13
View File
@@ -16,17 +16,19 @@
*/
#ifndef _RCLCONFIG_H_INCLUDED_
#define _RCLCONFIG_H_INCLUDED_
/* @(#$Id: rclconfig.h,v 1.38 2007-10-09 09:43:10 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: rclconfig.h,v 1.39 2007-11-16 14:28:52 dockes Exp $ (C) 2004 J.F.Dockes */
#include <list>
#include <string>
#include <vector>
#include <set>
#include <utility>
#ifndef NO_NAMESPACES
using std::list;
using std::string;
using std::vector;
using std::pair;
using std::set;
#endif
#include "conftree.h"
@@ -60,17 +62,7 @@ class RclConfig {
string getConfDir() {return m_confdir;}
/** Set current directory reference, and fetch automatic parameters. */
void setKeyDir(const string &dir)
{
m_keydir = dir;
if (m_conf == 0)
return;
if (!m_conf->get("defaultcharset", defcharset, m_keydir))
defcharset.erase();
string str;
m_conf->get("guesscharset", str, m_keydir);
guesscharset = stringToBool(str);
}
void setKeyDir(const string &dir);
string getKeyDir() const {return m_keydir;}
/** Get generic configuration parameter according to current keydir */
@@ -136,7 +128,7 @@ class RclConfig {
string getSuffixFromMimeType(const string &mt);
/** mimeconf: get input filter for mimetype */
string getMimeHandlerDef(const string &mimetype);
string getMimeHandlerDef(const string &mimetype, bool filtertypes=false);
/** mimeconf: get icon name for mimetype */
string getMimeIconName(const string &mtype, string *path = 0);
@@ -198,6 +190,9 @@ class RclConfig {
// Parameters auto-fetched on setkeydir
string defcharset; // These are stored locally to avoid
bool guesscharset; // They are fetched initially or on setKeydir()
// Limiting set of mime types to be processed. Normally empty.
string m_rmtstr;
set<string> m_restrictMTypes;
/** Create initial user configuration */
bool initUserConfig();