|
a/src/internfile/mimehandler.cpp |
|
b/src/internfile/mimehandler.cpp |
|
... |
|
... |
27 |
|
27 |
|
28 |
#include "mimehandler.h"
|
28 |
#include "mimehandler.h"
|
29 |
#include "debuglog.h"
|
29 |
#include "debuglog.h"
|
30 |
#include "rclconfig.h"
|
30 |
#include "rclconfig.h"
|
31 |
#include "smallut.h"
|
31 |
#include "smallut.h"
|
32 |
#ifdef RCL_USE_XATTR
|
|
|
33 |
#include "pxattr.h"
|
|
|
34 |
#endif // RCL_USE_XATTR
|
|
|
35 |
|
32 |
|
36 |
#include "mh_exec.h"
|
33 |
#include "mh_exec.h"
|
37 |
#include "mh_html.h"
|
34 |
#include "mh_html.h"
|
38 |
#include "mh_mail.h"
|
35 |
#include "mh_mail.h"
|
39 |
#include "mh_mbox.h"
|
36 |
#include "mh_mbox.h"
|
40 |
#include "mh_text.h"
|
37 |
#include "mh_text.h"
|
41 |
#include "mh_unknown.h"
|
38 |
#include "mh_unknown.h"
|
42 |
|
39 |
|
43 |
// Common code for all docs that are a file (not subdocs). If extended
|
40 |
// Performance help: we use a pool of already known and created
|
44 |
// attributes support is enabled, fetch the data.
|
41 |
// handlers. There can be several instances for a given mime type
|
45 |
bool RecollFilter::set_document_file(const string& path)
|
42 |
// (think email attachment in email message: 2 rfc822 handlers are
|
46 |
{
|
43 |
// needed simulteanously)
|
47 |
#ifdef RCL_USE_XATTR
|
|
|
48 |
RclConfig* rclconfig = RclConfig::getMainConfig();
|
|
|
49 |
if (rclconfig == 0) {
|
|
|
50 |
LOGERR(("RecollFilter::set_document_file: no config\n"));
|
|
|
51 |
return false;
|
|
|
52 |
}
|
|
|
53 |
vector<string> xnames;
|
|
|
54 |
if (!pxattr::list(path, &xnames)) {
|
|
|
55 |
LOGERR(("xattrToMeta: pxattr::list failed, errno %d\n", errno));
|
|
|
56 |
return false;
|
|
|
57 |
}
|
|
|
58 |
const map<string, string>& xtof = rclconfig->getXattrToField();
|
|
|
59 |
for (vector<string>::const_iterator it = xnames.begin();
|
|
|
60 |
it != xnames.end(); it++) {
|
|
|
61 |
map<string, string>::const_iterator mit;
|
|
|
62 |
if ((mit = xtof.find(*it)) != xtof.end()) {
|
|
|
63 |
string value;
|
|
|
64 |
if (!pxattr::get(path, *it, &value, pxattr::PXATTR_NOFOLLOW)) {
|
|
|
65 |
LOGERR(("xattrToMeta: pxattr::get failed for %s, errno %d\n",
|
|
|
66 |
(*it).c_str(), errno));
|
|
|
67 |
continue;
|
|
|
68 |
}
|
|
|
69 |
// Encode should we ?
|
|
|
70 |
m_fieldsFromAttrs[mit->second] = value;
|
|
|
71 |
}
|
|
|
72 |
}
|
|
|
73 |
#endif // RCL_USE_XATTR
|
|
|
74 |
return true;
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
// Pool of already known and created handlers. There can be several
|
|
|
78 |
// instances for a given mime type (think email attachment in email
|
|
|
79 |
// message: 2 rfc822 handlers are needed simulteanously)
|
|
|
80 |
static multimap<string, Dijon::Filter*> o_handlers;
|
44 |
static multimap<string, Dijon::Filter*> o_handlers;
|
81 |
|
45 |
|
82 |
/** For mime types set as "internal" in mimeconf:
|
46 |
/** For mime types set as "internal" in mimeconf:
|
83 |
* create appropriate handler object. */
|
47 |
* create appropriate handler object. */
|
84 |
static Dijon::Filter *mhFactory(const string &mime)
|
48 |
static Dijon::Filter *mhFactory(const string &mime)
|