added menu to display missing helpers

This commit is contained in:
dockes
2008-10-08 16:15:22 +00:00
parent 990e534022
commit 2462b079fa
12 changed files with 118 additions and 42 deletions
+39 -19
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.44 2008-10-04 14:26:59 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.45 2008-10-08 16:15:22 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -49,6 +49,9 @@ using namespace std;
static const string isep(":");
static const string stxtplain("text/plain");
set<string> FileInterner::o_missingExternal;
map<string, set<string> > FileInterner::o_typesForMissing;
// This is used when the user wants to retrieve a search result doc's parent
// (ie message having a given attachment)
bool FileInterner::getEnclosing(const string &url, const string &ipath,
@@ -245,35 +248,52 @@ bool FileInterner::dataToTempFile(const string& dt, const string& mt,
// See if the error string is formatted as a missing helper message,
// accumulate helper name if it is
void FileInterner::checkExternalMissing(const string& msg)
void FileInterner::checkExternalMissing(const string& msg, const string& mt)
{
if (msg.find("RECFILTERROR") == 0) {
list<string> lerr;
stringToStrings(msg, lerr);
if (lerr.size() > 2) {
list<string>::iterator it = lerr.begin();
it++;
lerr.erase(it++);
if (*it == "HELPERNOTFOUND") {
it++;
m_missingExternal.push_back(it->c_str());
lerr.erase(it++);
string s;
stringsToString(lerr, s);
o_missingExternal.insert(s);
o_typesForMissing[s].insert(mt);
}
}
}
}
// Return the list of missing external helper apps that we saw while
// working
const list<string>& FileInterner::getMissingExternal()
{
m_missingExternal.sort();
m_missingExternal.unique();
return m_missingExternal;
}
void FileInterner::getMissingExternal(string& out)
{
m_missingExternal.sort();
m_missingExternal.unique();
stringsToString(m_missingExternal, out);
stringsToString(o_missingExternal, out);
}
void FileInterner::getMissingDescription(string& out)
{
out.erase();
for (set<string>::const_iterator it = o_missingExternal.begin();
it != o_missingExternal.end(); it++) {
out += *it;
map<string, set<string> >::const_iterator it2;
it2 = o_typesForMissing.find(*it);
if (it2 != o_typesForMissing.end()) {
out += " (";
set<string>::const_iterator it3;
for (it3 = it2->second.begin();
it3 != it2->second.end(); it3++) {
out += *it3;
out += string(" ");
}
trimstring(out);
out += ")";
}
out += "\n";
}
}
// Helper for extracting a value from a map.
@@ -475,10 +495,10 @@ void FileInterner::processNextDocError(Rcl::Doc &doc, string& ipath)
{
collectIpathAndMT(doc, ipath);
m_reason = m_handlers.back()->get_error();
checkExternalMissing(m_reason);
checkExternalMissing(m_reason, doc.mimetype);
LOGERR(("FileInterner::internfile: next_document error "
"[%s%s%s] %s\n", m_fn.c_str(), ipath.empty() ? "" : "|",
ipath.c_str(), m_reason.c_str()));
"[%s%s%s] %s %s\n", m_fn.c_str(), ipath.empty() ? "" : "|",
ipath.c_str(), doc.mimetype.c_str(), m_reason.c_str()));
}
FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, string& ipath)
+13 -6
View File
@@ -16,12 +16,16 @@
*/
#ifndef _INTERNFILE_H_INCLUDED_
#define _INTERNFILE_H_INCLUDED_
/* @(#$Id: internfile.h,v 1.20 2008-10-04 14:26:59 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: internfile.h,v 1.21 2008-10-08 16:15:22 dockes Exp $ (C) 2004 J.F.Dockes */
#include <string>
#include <vector>
#include <map>
#include <set>
using std::string;
using std::vector;
using std::map;
using std::set;
#include "pathut.h"
#include "Filter.h"
@@ -95,6 +99,9 @@ class FileInterner {
*/
void setTargetMType(const string& tp) {m_targetMType = tp;}
/* In case we see an html version, it's set aside and can be recovered */
const string& get_html() {return m_html;}
/** Utility function: extract internal document into temporary file.
* This is used mainly for starting an external viewer for a
* subdocument (ie: mail attachment).
@@ -110,9 +117,8 @@ class FileInterner {
const string& ipath, const string& mtype);
const string& getReason() const {return m_reason;}
const list<string>& getMissingExternal();
void getMissingExternal(string& missing);
const string& get_html() {return m_html;}
static void getMissingExternal(string& missing);
static void getMissingDescription(string& desc);
private:
static const unsigned int MAXHANDLERS = 20;
@@ -135,7 +141,8 @@ class FileInterner {
// Error data if any
string m_reason;
// Missing external programs
list<string> m_missingExternal;
static set<string> o_missingExternal;
static map<string, set<string> > o_typesForMissing;
void tmpcleanup();
bool dijontorcl(Rcl::Doc&);
@@ -143,7 +150,7 @@ class FileInterner {
bool dataToTempFile(const string& data, const string& mt, string& fn);
void popHandler();
int addHandler();
void checkExternalMissing(const string& msg);
void checkExternalMissing(const string& msg, const string& mt);
void processNextDocError(Rcl::Doc &doc, string& ipath);
};