|
a/src/internfile/internfile.cpp |
|
b/src/internfile/internfile.cpp |
1 |
#ifndef lint
|
1 |
#ifndef lint
|
2 |
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.42 2008-09-16 08:18:30 dockes Exp $ (C) 2004 J.F.Dockes";
|
2 |
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.43 2008-10-03 06:23:23 dockes Exp $ (C) 2004 J.F.Dockes";
|
3 |
#endif
|
3 |
#endif
|
4 |
/*
|
4 |
/*
|
5 |
* This program is free software; you can redistribute it and/or modify
|
5 |
* This program is free software; you can redistribute it and/or modify
|
6 |
* it under the terms of the GNU General Public License as published by
|
6 |
* it under the terms of the GNU General Public License as published by
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
|
... |
|
... |
40 |
#include "mimehandler.h"
|
40 |
#include "mimehandler.h"
|
41 |
#include "execmd.h"
|
41 |
#include "execmd.h"
|
42 |
#include "pathut.h"
|
42 |
#include "pathut.h"
|
43 |
#include "wipedir.h"
|
43 |
#include "wipedir.h"
|
44 |
#include "rclconfig.h"
|
44 |
#include "rclconfig.h"
|
|
|
45 |
#include "mh_html.h"
|
45 |
|
46 |
|
46 |
// The internal path element separator. This can't be the same as the rcldb
|
47 |
// The internal path element separator. This can't be the same as the rcldb
|
47 |
// file to ipath separator : "|"
|
48 |
// file to ipath separator : "|"
|
48 |
static const string isep(":");
|
49 |
static const string isep(":");
|
|
|
50 |
static const string stxtplain("text/plain");
|
49 |
|
51 |
|
50 |
// This is used when the user wants to retrieve a search result doc's parent
|
52 |
// This is used when the user wants to retrieve a search result doc's parent
|
51 |
// (ie message having a given attachment)
|
53 |
// (ie message having a given attachment)
|
52 |
bool FileInterner::getEnclosing(const string &url, const string &ipath,
|
54 |
bool FileInterner::getEnclosing(const string &url, const string &ipath,
|
53 |
string &eurl, string &eipath)
|
55 |
string &eurl, string &eipath)
|
|
... |
|
... |
192 |
for (unsigned int i = 0; i < MAXHANDLERS; i++)
|
194 |
for (unsigned int i = 0; i < MAXHANDLERS; i++)
|
193 |
m_tmpflgs[i] = false;
|
195 |
m_tmpflgs[i] = false;
|
194 |
m_handlers.push_back(df);
|
196 |
m_handlers.push_back(df);
|
195 |
LOGDEB(("FileInterner::FileInterner: %s [%s]\n", l_mime.c_str(),
|
197 |
LOGDEB(("FileInterner::FileInterner: %s [%s]\n", l_mime.c_str(),
|
196 |
m_fn.c_str()));
|
198 |
m_fn.c_str()));
|
197 |
m_targetMType = "text/plain";
|
199 |
m_targetMType = stxtplain;
|
198 |
}
|
200 |
}
|
199 |
|
201 |
|
200 |
FileInterner::~FileInterner()
|
202 |
FileInterner::~FileInterner()
|
201 |
{
|
203 |
{
|
202 |
tmpcleanup();
|
204 |
tmpcleanup();
|
|
... |
|
... |
395 |
string charset, mimetype;
|
397 |
string charset, mimetype;
|
396 |
getKeyValue(docdata, keycs, charset);
|
398 |
getKeyValue(docdata, keycs, charset);
|
397 |
getKeyValue(docdata, keymt, mimetype);
|
399 |
getKeyValue(docdata, keymt, mimetype);
|
398 |
|
400 |
|
399 |
LOGDEB(("FileInterner::addHandler: next_doc is %s\n", mimetype.c_str()));
|
401 |
LOGDEB(("FileInterner::addHandler: next_doc is %s\n", mimetype.c_str()));
|
|
|
402 |
|
400 |
// If we find a document of the target type (text/plain in
|
403 |
// If we find a document of the target type (text/plain in
|
401 |
// general), we're done decoding
|
404 |
// general), we're done decoding. If we hit text/plain, we're done
|
|
|
405 |
// in any case
|
402 |
if (!stringicmp(mimetype, m_targetMType)) {
|
406 |
if (!stringicmp(mimetype, m_targetMType) ||
|
|
|
407 |
!stringicmp(mimetype, stxtplain)) {
|
|
|
408 |
m_reachedMType = mimetype;
|
403 |
LOGDEB1(("FileInterner::addHandler: target reached\n"));
|
409 |
LOGDEB1(("FileInterner::addHandler: target reached\n"));
|
404 |
return ADD_BREAK;
|
410 |
return ADD_BREAK;
|
405 |
}
|
411 |
}
|
406 |
|
412 |
|
407 |
// We need to stack another handler. Check stack size
|
413 |
// We need to stack another handler. Check stack size
|
|
... |
|
... |
566 |
// author). This is useful for email attachments. The values will
|
572 |
// author). This is useful for email attachments. The values will
|
567 |
// be replaced by those found by dijontorcl if any, so the order
|
573 |
// be replaced by those found by dijontorcl if any, so the order
|
568 |
// of calls is important.
|
574 |
// of calls is important.
|
569 |
if (!m_forPreview)
|
575 |
if (!m_forPreview)
|
570 |
collectIpathAndMT(doc, ipath);
|
576 |
collectIpathAndMT(doc, ipath);
|
|
|
577 |
else
|
|
|
578 |
doc.mimetype = m_reachedMType;
|
|
|
579 |
|
571 |
// Keep this AFTER collectIpathAndMT
|
580 |
// Keep this AFTER collectIpathAndMT
|
572 |
dijontorcl(doc);
|
581 |
dijontorcl(doc);
|
573 |
|
582 |
|
574 |
// Possibly destack so that we can test for FIDone.
|
583 |
// Possibly destack so that we can test for FIDone. While doing this
|
|
|
584 |
// possibly set aside an ancestor html text (for the GUI preview)
|
575 |
while (!m_handlers.empty() && !m_handlers.back()->has_documents()) {
|
585 |
while (!m_handlers.empty() && !m_handlers.back()->has_documents()) {
|
|
|
586 |
LOGDEB(("FileInterner::internfile: dstck filter fpv %d tgt %s\n",
|
|
|
587 |
m_forPreview, m_targetMType.c_str()));
|
|
|
588 |
if (m_forPreview) {
|
|
|
589 |
LOGDEB(("FileInterner::internfile: Testing for html handler\n"));
|
|
|
590 |
MimeHandlerHtml *hth =
|
|
|
591 |
dynamic_cast<MimeHandlerHtml*>(m_handlers.back());
|
|
|
592 |
if (hth) {
|
|
|
593 |
m_html = hth->get_html();
|
|
|
594 |
}
|
|
|
595 |
}
|
576 |
popHandler();
|
596 |
popHandler();
|
577 |
}
|
597 |
}
|
578 |
if (m_handlers.empty())
|
598 |
if (m_handlers.empty())
|
579 |
return FIDone;
|
599 |
return FIDone;
|
580 |
else
|
600 |
else
|