|
|
@ -926,7 +926,7 @@ class Core {
|
|
|
|
|
|
|
|
|
|
|
|
EntityMessage message = synchronizeMessage(context, account, folder, istore, ifolder, imessage, false, download, rules, state);
|
|
|
|
EntityMessage message = synchronizeMessage(context, account, folder, istore, ifolder, imessage, false, download, rules, state);
|
|
|
|
if (download && message != null)
|
|
|
|
if (download && message != null)
|
|
|
|
downloadMessage(context, folder, ifolder, imessage, message.id, state);
|
|
|
|
downloadMessage(context, account, folder, istore, ifolder, imessage, message.id, state);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
((IMAPMessage) imessage).invalidateHeaders();
|
|
|
|
((IMAPMessage) imessage).invalidateHeaders();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1911,7 +1911,8 @@ class Core {
|
|
|
|
if (ids[from + j] != null)
|
|
|
|
if (ids[from + j] != null)
|
|
|
|
downloadMessage(
|
|
|
|
downloadMessage(
|
|
|
|
context,
|
|
|
|
context,
|
|
|
|
folder, ifolder,
|
|
|
|
account, folder,
|
|
|
|
|
|
|
|
istore, ifolder,
|
|
|
|
(MimeMessage) isub[j], ids[from + j], state);
|
|
|
|
(MimeMessage) isub[j], ids[from + j], state);
|
|
|
|
} catch (FolderClosedException ex) {
|
|
|
|
} catch (FolderClosedException ex) {
|
|
|
|
throw ex;
|
|
|
|
throw ex;
|
|
|
@ -2146,23 +2147,7 @@ class Core {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (message.total != null && message.total == 0)
|
|
|
|
if (message.total != null && message.total == 0)
|
|
|
|
try {
|
|
|
|
reportEmptyMessage(context, account, istore);
|
|
|
|
if (istore.hasCapability("ID")) {
|
|
|
|
|
|
|
|
Map<String, String> id = new LinkedHashMap<>();
|
|
|
|
|
|
|
|
id.put("name", context.getString(R.string.app_name));
|
|
|
|
|
|
|
|
id.put("version", BuildConfig.VERSION_NAME);
|
|
|
|
|
|
|
|
Map<String, String> sid = istore.id(id);
|
|
|
|
|
|
|
|
if (sid != null) {
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
|
|
for (String key : sid.keySet())
|
|
|
|
|
|
|
|
sb.append(" ").append(key).append("=").append(sid.get(key));
|
|
|
|
|
|
|
|
Log.e("Empty message" + sb.toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
|
|
|
Log.e("Empty message " + account.host);
|
|
|
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
|
|
|
Log.w(ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
db.beginTransaction();
|
|
|
|
db.beginTransaction();
|
|
|
@ -2221,7 +2206,10 @@ class Core {
|
|
|
|
Log.i(folder.name + " inline downloaded message id=" + message.id +
|
|
|
|
Log.i(folder.name + " inline downloaded message id=" + message.id +
|
|
|
|
" size=" + message.size + "/" + (body == null ? null : body.length()));
|
|
|
|
" size=" + message.size + "/" + (body == null ? null : body.length()));
|
|
|
|
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(body))
|
|
|
|
Long size = parts.getBodySize();
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(body) && size != null && size > 0)
|
|
|
|
|
|
|
|
reportEmptyMessage(context, account, istore);
|
|
|
|
|
|
|
|
else
|
|
|
|
fixAttachments(context, message.id, body);
|
|
|
|
fixAttachments(context, message.id, body);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2479,7 +2467,8 @@ class Core {
|
|
|
|
|
|
|
|
|
|
|
|
private static void downloadMessage(
|
|
|
|
private static void downloadMessage(
|
|
|
|
Context context,
|
|
|
|
Context context,
|
|
|
|
EntityFolder folder, IMAPFolder ifolder,
|
|
|
|
EntityAccount account, EntityFolder folder,
|
|
|
|
|
|
|
|
IMAPStore istore, IMAPFolder ifolder,
|
|
|
|
MimeMessage imessage, long id, State state) throws MessagingException, IOException {
|
|
|
|
MimeMessage imessage, long id, State state) throws MessagingException, IOException {
|
|
|
|
if (state.getNetworkState().isRoaming())
|
|
|
|
if (state.getNetworkState().isRoaming())
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -2541,7 +2530,10 @@ class Core {
|
|
|
|
Log.i(folder.name + " downloaded message id=" + message.id +
|
|
|
|
Log.i(folder.name + " downloaded message id=" + message.id +
|
|
|
|
" size=" + message.size + "/" + (body == null ? null : body.length()));
|
|
|
|
" size=" + message.size + "/" + (body == null ? null : body.length()));
|
|
|
|
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(body))
|
|
|
|
Long size = parts.getBodySize();
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(body) && size != null && size > 0)
|
|
|
|
|
|
|
|
reportEmptyMessage(context, account, istore);
|
|
|
|
|
|
|
|
else
|
|
|
|
fixAttachments(context, message.id, body);
|
|
|
|
fixAttachments(context, message.id, body);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2559,6 +2551,26 @@ class Core {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void reportEmptyMessage(Context context, EntityAccount account, IMAPStore istore) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (istore.hasCapability("ID")) {
|
|
|
|
|
|
|
|
Map<String, String> id = new LinkedHashMap<>();
|
|
|
|
|
|
|
|
id.put("name", context.getString(R.string.app_name));
|
|
|
|
|
|
|
|
id.put("version", BuildConfig.VERSION_NAME);
|
|
|
|
|
|
|
|
Map<String, String> sid = istore.id(id);
|
|
|
|
|
|
|
|
if (sid != null) {
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
|
|
for (String key : sid.keySet())
|
|
|
|
|
|
|
|
sb.append(" ").append(key).append("=").append(sid.get(key));
|
|
|
|
|
|
|
|
Log.e("Empty message" + sb.toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
|
|
|
Log.e("Empty message " + account.host);
|
|
|
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
|
|
|
Log.w(ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static void fixAttachments(Context context, long id, String body) {
|
|
|
|
private static void fixAttachments(Context context, long id, String body) {
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
for (Element element : JsoupEx.parse(body).select("img")) {
|
|
|
|
for (Element element : JsoupEx.parse(body).select("img")) {
|
|
|
|