|
|
@ -2234,31 +2234,40 @@ class Core {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static void onBody(Context context, JSONArray jargs, EntityFolder folder, EntityMessage message, POP3Folder ifolder, POP3Store istore) throws MessagingException, IOException {
|
|
|
|
private static void onBody(Context context, JSONArray jargs, EntityFolder folder, EntityMessage message, POP3Folder ifolder, POP3Store istore) throws MessagingException, IOException {
|
|
|
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
|
|
|
|
boolean download_plain = prefs.getBoolean("download_plain", false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean plain_text = jargs.optBoolean(0, download_plain);
|
|
|
|
|
|
|
|
String charset = (jargs.isNull(1) ? null : jargs.optString(1, null));
|
|
|
|
|
|
|
|
|
|
|
|
if (!EntityFolder.INBOX.equals(folder.type))
|
|
|
|
if (!EntityFolder.INBOX.equals(folder.type))
|
|
|
|
throw new IllegalArgumentException("Not INBOX");
|
|
|
|
throw new IllegalArgumentException("Not INBOX");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (message.content && message.isPlainOnly() == plain_text && charset == null)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
Map<EntityMessage, Message> map = findMessages(context, folder, Arrays.asList(message), istore, ifolder);
|
|
|
|
Map<EntityMessage, Message> map = findMessages(context, folder, Arrays.asList(message), istore, ifolder);
|
|
|
|
if (map.get(message) == null)
|
|
|
|
if (map.get(message) == null)
|
|
|
|
throw new IllegalArgumentException("Message not found msgid=" + message.msgid);
|
|
|
|
throw new IllegalArgumentException("Message not found msgid=" + message.msgid);
|
|
|
|
|
|
|
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
|
|
|
|
boolean download_plain = prefs.getBoolean("download_plain", false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MessageHelper helper = new MessageHelper((MimeMessage) map.entrySet().iterator().next().getValue(), context);
|
|
|
|
MessageHelper helper = new MessageHelper((MimeMessage) map.entrySet().iterator().next().getValue(), context);
|
|
|
|
MessageHelper.MessageParts parts = helper.getMessageParts();
|
|
|
|
MessageHelper.MessageParts parts = helper.getMessageParts();
|
|
|
|
|
|
|
|
|
|
|
|
String body = parts.getHtml(context, download_plain);
|
|
|
|
String body = parts.getHtml(context, plain_text, charset);
|
|
|
|
File file = message.getFile(context);
|
|
|
|
File file = message.getFile(context);
|
|
|
|
Helper.writeText(file, body);
|
|
|
|
Helper.writeText(file, body);
|
|
|
|
String text = HtmlHelper.getFullText(body, true);
|
|
|
|
String text = HtmlHelper.getFullText(body, true);
|
|
|
|
message.preview = HtmlHelper.getPreview(text);
|
|
|
|
message.preview = HtmlHelper.getPreview(text);
|
|
|
|
message.language = HtmlHelper.getLanguage(context, message.subject, text);
|
|
|
|
message.language = HtmlHelper.getLanguage(context, message.subject, text);
|
|
|
|
|
|
|
|
Integer plain_only = parts.isPlainOnly();
|
|
|
|
|
|
|
|
if (plain_text)
|
|
|
|
|
|
|
|
plain_only = 1 | (plain_only == null ? 0 : plain_only & 0x80);
|
|
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
db.message().setMessageContent(message.id,
|
|
|
|
db.message().setMessageContent(message.id,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
message.language,
|
|
|
|
message.language,
|
|
|
|
parts.isPlainOnly(download_plain),
|
|
|
|
plain_only,
|
|
|
|
message.preview,
|
|
|
|
message.preview,
|
|
|
|
parts.getWarnings(message.warning));
|
|
|
|
parts.getWarnings(message.warning));
|
|
|
|
}
|
|
|
|
}
|
|
|
|