add MODE "none"
This commit is contained in:
@ -177,8 +177,8 @@ MainAttachment::readArchiveUrl () {
|
||||
archiveDownloadURL.clear ();
|
||||
string line;
|
||||
getline (cin, line);
|
||||
LOG_BUG (line.rfind ("arch: ", 0) != 0, return, "eMailShrinker: bug ZZ: no archive link. (line: " << line << ")");
|
||||
LOG_BUG (line.rfind ("arch: bad", 0) == 0, return, "eMailShrinker: bug ZZ: bad archive link. (line: " << line << ")");
|
||||
LOG_BUG (line.rfind ("arch: ", 0) != 0, return, "eMailShrinker: bug 9: no archive link. (line: " << line << ")");
|
||||
LOG_BUG (line.rfind ("arch: bad", 0) == 0, return, "eMailShrinker: bug 10: bad archive link. (line: " << line << ")");
|
||||
if (line.rfind ("arch: none", 0) == 0)
|
||||
return;
|
||||
archiveDownloadURL = line.substr (6);
|
||||
@ -192,7 +192,7 @@ MainAttachment::readDownloadUrl (string &url) {
|
||||
string line;
|
||||
getline (cin, line);
|
||||
LOG ("get URL: " << line);
|
||||
LOG_BUG (line.rfind ("url: ", 0) != 0, return, "eMailShrinker: bug ZZ: no download link. (line: " << line << ")");
|
||||
LOG_BUG (line.rfind ("url: ", 0) != 0, return, "eMailShrinker: bug 11: no download link. (line: " << line << ")");
|
||||
url = line.substr (5);
|
||||
}
|
||||
|
||||
@ -371,30 +371,39 @@ MainAttachment::extractLinks (const vector<string> &liOne) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MainAttachment::extractPreviousKAZ (string &extractedPlainKAZ, string &extractedHtmlKAZ, ifstream &mbox, const Attachment &attach) {
|
||||
DEF_LOG ("MainAttachment::extractPreviousKAZ", "attach:" << attach);
|
||||
if (!(attach.toUpdate || attach.isKazAttachment)) // isKazAttachment => toUpdate
|
||||
return;
|
||||
string textProp = attach.getProp (contentTypeToken, textRegEx);
|
||||
if (textProp.empty ())
|
||||
return;
|
||||
string content (attach.getContent (mbox));
|
||||
if (textProp == PLAIN) {
|
||||
LOG (PLAIN);
|
||||
extractedPlainKAZ += attach.getSection (content, KAZ_PLAIN_START, KAZ_PLAIN_STOP);
|
||||
}
|
||||
if (textProp == HTML) {
|
||||
LOG (HTML);
|
||||
string section = attach.getSection (content, KAZ_HTML_START, KAZ_HTML_STOP);
|
||||
section += attach.getSection (content, KAZ_PLAIN_START, KAZ_PLAIN_STOP);
|
||||
// update href from HTML attachments
|
||||
replaceAll (section, "&", "&");
|
||||
extractedHtmlKAZ += section;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MainAttachment::extractPreviousKAZ (ifstream &mbox) {
|
||||
DEF_LOG ("MainAttachment::extractPreviousKAZ", "");
|
||||
string extractedPlainKAZ, extractedHtmlKAZ;
|
||||
for (const Attachment *attachP : allMarkedPtrs) {
|
||||
if (!(attachP->toUpdate || attachP->isKazAttachment)) // isKazAttachment => toUpdate
|
||||
continue;
|
||||
string textProp = attachP->getProp (contentTypeToken, textRegEx);
|
||||
if (textProp.empty ())
|
||||
continue;
|
||||
string content (attachP->getContent (mbox));
|
||||
if (textProp == PLAIN) {
|
||||
LOG (PLAIN);
|
||||
extractedPlainKAZ += attachP->getSection (content, KAZ_PLAIN_START, KAZ_PLAIN_STOP);
|
||||
}
|
||||
if (textProp == HTML) {
|
||||
LOG (HTML);
|
||||
string section = attachP->getSection (content, KAZ_HTML_START, KAZ_HTML_STOP);
|
||||
section += attachP->getSection (content, KAZ_PLAIN_START, KAZ_PLAIN_STOP);
|
||||
// update href from HTML attachments
|
||||
replaceAll (section, "&", "&");
|
||||
extractedHtmlKAZ += section;
|
||||
}
|
||||
}
|
||||
if (boundary.empty ())
|
||||
extractPreviousKAZ (extractedPlainKAZ, extractedHtmlKAZ, mbox, *this);
|
||||
else
|
||||
for (const Attachment *attachP : allMarkedPtrs)
|
||||
extractPreviousKAZ (extractedPlainKAZ, extractedHtmlKAZ, mbox, *attachP);
|
||||
|
||||
LOG ("extractedPlainKAZ: "<< extractedPlainKAZ);
|
||||
extractLinks (extractedPlainKAZ);
|
||||
|
||||
@ -590,8 +599,13 @@ MainAttachment::substitute (ifstream &mbox, ofstream &outbox, const SizeArg &min
|
||||
removePreviousArchive ();
|
||||
string plainDisclaim, htmlDisclaim;
|
||||
getDisclaim (plainDisclaim, htmlDisclaim);
|
||||
|
||||
// copy email
|
||||
streamoff curPos = 0;
|
||||
if (boundary.empty () && plainDisclaim.size () && (attachMode & ATTACHMENT)) {
|
||||
// XXX if no multipart ?
|
||||
LOG_BUG (true, /* */, "eMailShrinker: bug 12: not multipart.");
|
||||
}
|
||||
copy (mbox, outbox, curPos, contentPos);
|
||||
curPos = contentPos;
|
||||
|
||||
@ -599,7 +613,7 @@ MainAttachment::substitute (ifstream &mbox, ofstream &outbox, const SizeArg &min
|
||||
if (emptyEMail && (attachMode & FOOTER)) {
|
||||
// check no main text
|
||||
LOG ("Force main text");
|
||||
LOG_BUG (boundary.empty () || ! subAttachements.size (), /**/, "eMailShrinker: can't force add footer M9: : " << *this);
|
||||
cerr << "eMailShrinker: force footer" << endl;
|
||||
string content (plainDisclaim);
|
||||
base64Encode (content);
|
||||
outbox << boundary.substr (0, boundary.length () -2) << endl
|
||||
@ -614,6 +628,7 @@ MainAttachment::substitute (ifstream &mbox, ofstream &outbox, const SizeArg &min
|
||||
|
||||
if (attachP->toExtract || attachP->isKazAttachment) {
|
||||
LOG ("skip Extracted or previous attachments");
|
||||
|
||||
|
||||
} else if (attachP->toUpdate) {
|
||||
string textProp = attachP->getProp (contentTypeToken, textRegEx);
|
||||
@ -685,20 +700,24 @@ MainAttachment::substitute (ifstream &mbox, ofstream &outbox, const SizeArg &min
|
||||
curPos = attachP->endPos;
|
||||
}
|
||||
if (plainDisclaim.size () && (attachMode & ATTACHMENT)) {
|
||||
// XXX si pas de multipart
|
||||
LOG ("Add kaz attachment");
|
||||
LOG_BUG (boundary.empty () || ! subAttachements.size (), /**/, "eMailShrinker: can't add Kaz attachment M10: : " << *this);
|
||||
cerr << "eMailShrinker: force attachment" << endl;
|
||||
streamoff lastPos = subAttachements.back ().endPos;
|
||||
copy (mbox, outbox, curPos, lastPos);
|
||||
curPos = lastPos;
|
||||
string content (KAZ_HTML_CONTENT+htmlDisclaim+BODY_END+HTML_END);
|
||||
base64Encode (content);
|
||||
outbox << boundary.substr (0, boundary.length () -2) << endl
|
||||
<< KAZ_ATTACHMENT_TEXT_HTML << endl
|
||||
<< content << endl;
|
||||
|
||||
if (boundary.size ())
|
||||
outbox << boundary.substr (0, boundary.length () -2) << endl
|
||||
<< KAZ_ATTACHMENT_TEXT_HTML << endl
|
||||
<< content << endl;
|
||||
else
|
||||
outbox << "coucou No multipart" << endl;
|
||||
outbox.flush ();
|
||||
}
|
||||
copy (mbox, outbox, curPos, endPos);
|
||||
outbox << endl;
|
||||
outbox.close ();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user