Switch to unified view

a/src/internfile/mh_exec.cpp b/src/internfile/mh_exec.cpp
...
...
141
141
142
    finaldetails();
142
    finaldetails();
143
    return true;
143
    return true;
144
}
144
}
145
145
146
void MimeHandlerExec::finaldetails()
146
void MimeHandlerExec::handle_cs(const string& mt, const string& icharset)
147
{
147
{
148
    m_metaData[cstr_dj_keyorigcharset] = m_dfltInputCharset;
148
    string charset(icharset);
149
149
150
    // cfgFilterOutputCharset comes from the mimeconf filter
150
    // cfgFilterOutputCharset comes from the mimeconf filter
151
    // definition line If the value is "default", we use the charset
151
    // definition line and defaults to UTF-8 if empty. If the value is
152
    // "default", we use the default input charset value defined in
152
    // value defined in recoll.conf (which may vary depending on
153
    // recoll.conf (which may vary depending on directory)
153
    // directory)
154
    if (charset.empty()) {
154
    string& charset = m_metaData[cstr_dj_keycharset];
155
  charset = cfgFilterOutputCharset.empty() ? cstr_utf8 : 
155
    charset = cfgFilterOutputCharset.empty() ? "UTF-8" : cfgFilterOutputCharset;
156
      cfgFilterOutputCharset;
156
    if (!stringlowercmp("default", charset)) {
157
  if (!stringlowercmp("default", charset)) {
157
    charset = m_dfltInputCharset;
158
        charset = m_dfltInputCharset;
159
  }
158
    }
160
    }
159
161
    m_metaData[cstr_dj_keyorigcharset] = charset;
160
    // The output mime type is html except if defined otherwise in the filter
161
    // definition.
162
    string& mt = m_metaData[cstr_dj_keymt];
163
    mt = cfgFilterOutputMtype.empty() ? "text/html" : 
164
  cfgFilterOutputMtype;
165
162
166
    // If this is text/plain transcode_to/check utf-8
163
    // If this is text/plain transcode_to/check utf-8
167
    if (!mt.compare(cstr_textplain)) {
164
    if (!mt.compare(cstr_textplain)) {
168
    (void)txtdcode("mh_exec");
165
    (void)txtdcode("mh_exec/m");
166
    } else {
167
  m_metaData[cstr_dj_keycharset] = charset;
169
    }
168
    }
169
}
170
171
void MimeHandlerExec::finaldetails()
172
{
173
    // The default output mime type is html, but it may be defined
174
    // otherwise in the filter definition.
175
    m_metaData[cstr_dj_keymt] = cfgFilterOutputMtype.empty() ? "text/html" : 
176
  cfgFilterOutputMtype;
170
177
171
    string md5, xmd5, reason;
178
    string md5, xmd5, reason;
172
    if (MD5File(m_fn, md5, &reason)) {
179
    if (MD5File(m_fn, md5, &reason)) {
173
    m_metaData[cstr_dj_keymd5] = MD5HexPrint(md5, xmd5);
180
    m_metaData[cstr_dj_keymd5] = MD5HexPrint(md5, xmd5);
174
    } else {
181
    } else {
175
    LOGERR(("MimeHandlerExec: cant compute md5 for [%s]: %s\n", 
182
    LOGERR(("MimeHandlerExec: cant compute md5 for [%s]: %s\n", 
176
        m_fn.c_str(), reason.c_str()));
183
        m_fn.c_str(), reason.c_str()));
177
    }
184
    }
185
186
    handle_cs(m_metaData[cstr_dj_keymt]);
178
}
187
}