added code to specifically index/search file names
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.15 2006-01-23 13:32:28 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.16 2006-03-20 16:05:41 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -125,41 +125,42 @@ FileInterner::FileInterner(const std::string &f, RclConfig *cnf,
|
||||
// for a compressed file.
|
||||
m_mime = mimetype(m_fn, m_cfg, usfci);
|
||||
|
||||
// If identification fails, try to use the input parameter. Note that this
|
||||
// is normally not a compressed type (it's the mime type from the db)
|
||||
// If identification fails, try to use the input parameter. This
|
||||
// is then normally not a compressed type (it's the mime type from
|
||||
// the db), and is only set when previewing, not for indexing
|
||||
if (m_mime.empty() && imime)
|
||||
m_mime = *imime;
|
||||
|
||||
if (!m_mime.empty()) {
|
||||
// Has mime: check for a compressed file. If so, create a
|
||||
// temporary uncompressed file, and rerun the mime type
|
||||
// identification, then do the rest with the temp file.
|
||||
list<string>ucmd;
|
||||
if (m_cfg->getUncompressor(m_mime, ucmd)) {
|
||||
if (!uncompressfile(m_cfg, m_fn, ucmd, m_tdir, m_tfile)) {
|
||||
return;
|
||||
}
|
||||
LOGDEB(("internfile: after ucomp: m_tdir %s, tfile %s\n",
|
||||
m_tdir.c_str(), m_tfile.c_str()));
|
||||
m_fn = m_tfile;
|
||||
m_mime = mimetype(m_fn, m_cfg, usfci);
|
||||
if (m_mime.empty() && imime)
|
||||
m_mime = *imime;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_mime.empty()) {
|
||||
// No mime type: not listed in our map, or present in stop list
|
||||
LOGDEB(("FileInterner::FileInterner: (no mime) [%s]\n", m_fn.c_str()));
|
||||
return;
|
||||
// No mime type. We let it through as config may warrant that
|
||||
// we index all file names
|
||||
LOGDEB(("internfile: (no mime) [%s]\n", m_fn.c_str()));
|
||||
}
|
||||
|
||||
// First check for a compressed file. If so, create a temporary
|
||||
// uncompressed file, and rerun the mime type identification, then do the
|
||||
// rest with the temp file.
|
||||
list<string>ucmd;
|
||||
if (m_cfg->getUncompressor(m_mime, ucmd)) {
|
||||
if (!uncompressfile(m_cfg, m_fn, ucmd, m_tdir, m_tfile)) {
|
||||
return;
|
||||
}
|
||||
LOGDEB(("internfile: after ucomp: m_tdir %s, tfile %s\n",
|
||||
m_tdir.c_str(), m_tfile.c_str()));
|
||||
m_fn = m_tfile;
|
||||
m_mime = mimetype(m_fn, m_cfg, usfci);
|
||||
if (m_mime.empty() && imime)
|
||||
m_mime = *imime;
|
||||
if (m_mime.empty()) {
|
||||
// No mime type ?? pass on.
|
||||
LOGDEB(("internfile: (no mime) [%s]\n", m_fn.c_str()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Look for appropriate handler
|
||||
// Look for appropriate handler (might still return empty)
|
||||
m_handler = getMimeHandler(m_mime, m_cfg);
|
||||
|
||||
if (!m_handler) {
|
||||
// No handler for this type, for now :(
|
||||
// No handler for this type, for now :( if indexallfilenames
|
||||
// is set in the config, this normally wont happen (we get mh_unknown)
|
||||
LOGDEB(("FileInterner::FileInterner: %s: no handler\n",
|
||||
m_mime.c_str()));
|
||||
return;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: mimehandler.cpp,v 1.16 2006-01-23 13:32:28 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: mimehandler.cpp,v 1.17 2006-03-20 16:05:41 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -31,6 +31,7 @@ using namespace std;
|
||||
#include "mh_mail.h"
|
||||
#include "mh_text.h"
|
||||
#include "mh_exec.h"
|
||||
#include "mh_unknown.h"
|
||||
|
||||
/** Create internal handler object appropriate for given mime type */
|
||||
static MimeHandler *mhFactory(const string &mime)
|
||||
@@ -52,35 +53,48 @@ static MimeHandler *mhFactory(const string &mime)
|
||||
MimeHandler *getMimeHandler(const string &mtype, RclConfig *cfg)
|
||||
{
|
||||
// Get handler definition for mime type
|
||||
string hs = cfg->getMimeHandlerDef(mtype);
|
||||
if (hs.empty())
|
||||
return 0;
|
||||
string hs;
|
||||
if (!mtype.empty())
|
||||
hs = cfg->getMimeHandlerDef(mtype);
|
||||
|
||||
// Break definition into type and name
|
||||
list<string> toks;
|
||||
stringToStrings(hs, toks);
|
||||
if (toks.empty()) {
|
||||
LOGERR(("getMimeHandler: bad mimeconf line for %s\n", mtype.c_str()));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Retrieve handler function according to type
|
||||
if (!stringlowercmp("internal", toks.front())) {
|
||||
return mhFactory(mtype);
|
||||
} else if (!stringlowercmp("dll", toks.front())) {
|
||||
return 0;
|
||||
} else if (!stringlowercmp("exec", toks.front())) {
|
||||
if (toks.size() < 2) {
|
||||
LOGERR(("getMimeHandler: bad line for %s: %s\n", mtype.c_str(),
|
||||
hs.c_str()));
|
||||
if (!hs.empty()) {
|
||||
// Break definition into type and name
|
||||
list<string> toks;
|
||||
stringToStrings(hs, toks);
|
||||
if (toks.empty()) {
|
||||
LOGERR(("getMimeHandler: bad mimeconf line for %s\n",
|
||||
mtype.c_str()));
|
||||
return 0;
|
||||
}
|
||||
MimeHandlerExec *h = new MimeHandlerExec;
|
||||
list<string>::const_iterator it1 = toks.begin();
|
||||
it1++;
|
||||
for (;it1 != toks.end();it1++)
|
||||
h->params.push_back(*it1);
|
||||
return h;
|
||||
|
||||
// Retrieve handler function according to type
|
||||
if (!stringlowercmp("internal", toks.front())) {
|
||||
return mhFactory(mtype);
|
||||
} else if (!stringlowercmp("dll", toks.front())) {
|
||||
} else if (!stringlowercmp("exec", toks.front())) {
|
||||
if (toks.size() < 2) {
|
||||
LOGERR(("getMimeHandler: bad line for %s: %s\n",
|
||||
mtype.c_str(), hs.c_str()));
|
||||
return 0;
|
||||
}
|
||||
MimeHandlerExec *h = new MimeHandlerExec;
|
||||
list<string>::const_iterator it1 = toks.begin();
|
||||
it1++;
|
||||
for (;it1 != toks.end();it1++)
|
||||
h->params.push_back(*it1);
|
||||
return h;
|
||||
}
|
||||
}
|
||||
|
||||
// We are supposed to get here if there was no specific error, but
|
||||
// there is no identified mime type, or no handler
|
||||
// associated. These files are either ignored or their name is
|
||||
// indexed, depending on configuration
|
||||
bool indexunknown = false;
|
||||
cfg->getConfParam("indexallfilenames", &indexunknown);
|
||||
if (indexunknown) {
|
||||
return new MimeHandlerUnknown;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user