Switch to unified view

a/src/internfile/mh_mail.cpp b/src/internfile/mh_mail.cpp
1
#ifndef lint
1
#ifndef lint
2
static char rcsid[] = "@(#$Id: mh_mail.cpp,v 1.31 2007-12-13 06:58:21 dockes Exp $ (C) 2005 J.F.Dockes";
2
static char rcsid[] = "@(#$Id: mh_mail.cpp,v 1.32 2008-07-01 10:29:45 dockes Exp $ (C) 2005 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
...
...
34
#include "mimeparse.h"
34
#include "mimeparse.h"
35
#include "mh_mail.h"
35
#include "mh_mail.h"
36
#include "debuglog.h"
36
#include "debuglog.h"
37
#include "smallut.h"
37
#include "smallut.h"
38
#include "mh_html.h"
38
#include "mh_html.h"
39
#include "rclconfig.h"
40
#include "mimetype.h"
39
41
40
// binc imap mime definitions
42
// binc imap mime definitions
41
#include "mime.h"
43
#include "mime.h"
42
44
43
using namespace std;
45
using namespace std;
...
...
101
bool MimeHandlerMail::skip_to_document(const string& ipath) 
103
bool MimeHandlerMail::skip_to_document(const string& ipath) 
102
{
104
{
103
    LOGDEB(("MimeHandlerMail::skip_to_document(%s)\n", ipath.c_str()));
105
    LOGDEB(("MimeHandlerMail::skip_to_document(%s)\n", ipath.c_str()));
104
    if (m_idx == -1) {
106
    if (m_idx == -1) {
105
    // No decoding done yet. If ipath is null need do nothing
107
    // No decoding done yet. If ipath is null need do nothing
106
    if (ipath == "" || ipath == "-1")
108
    if (ipath.empty() || ipath == "-1")
107
        return true;
109
        return true;
108
    // ipath points to attachment: need to decode message
110
    // ipath points to attachment: need to decode message
109
    if (!next_document()) {
111
    if (!next_document()) {
110
        LOGERR(("MimeHandlerMail::skip_to_doc: next_document failed\n"));
112
        LOGERR(("MimeHandlerMail::skip_to_doc: next_document failed\n"));
111
        return false;
113
        return false;
...
...
187
    LOGDEB1(("  processAttach:ct [%s] cs [%s] fn [%s]\n", 
189
    LOGDEB1(("  processAttach:ct [%s] cs [%s] fn [%s]\n", 
188
        att->m_contentType.c_str(),
190
        att->m_contentType.c_str(),
189
        att->m_charset.c_str(),
191
        att->m_charset.c_str(),
190
        att->m_filename.c_str()));
192
        att->m_filename.c_str()));
191
193
192
    m_metaData["content"] = "";
194
    m_metaData["content"] = string();
193
    string& body = m_metaData["content"];
195
    string& body = m_metaData["content"];
194
    att->m_part->getBody(body, 0, att->m_part->bodylength);
196
    att->m_part->getBody(body, 0, att->m_part->bodylength);
195
    string decoded;
197
    string decoded;
196
    const string *bdp;
198
    const string *bdp;
197
    if (!decodeBody(att->m_contentTransferEncoding, body, decoded, &bdp)) {
199
    if (!decodeBody(att->m_contentTransferEncoding, body, decoded, &bdp)) {
...
...
211
            "for charset [%s]\n", m_metaData["charset"].c_str()));
213
            "for charset [%s]\n", m_metaData["charset"].c_str()));
212
        // Just let it through and hope for the best...
214
        // Just let it through and hope for the best...
213
    } else {
215
    } else {
214
        body = utf8;
216
        body = utf8;
215
    }
217
    }
218
    }
219
220
    // Special case for application/octet-stream: try to better
221
    // identify content, using file name if set
222
    if (m_metaData["mimetype"] == "application/octet-stream" &&
223
  !m_metaData["filename"].empty()) {
224
  string mt = mimetype(m_metaData["filename"], 0, 
225
               RclConfig::getMainConfig(), false);
226
  if (!mt.empty()) 
227
      m_metaData["mimetype"] = mt;
216
    }
228
    }
217
229
218
    // Ipath
230
    // Ipath
219
    char nbuf[10];
231
    char nbuf[10];
220
    sprintf(nbuf, "%d", m_idx);
232
    sprintf(nbuf, "%d", m_idx);