|
|
@ -297,6 +297,15 @@ class Core {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case EntityOperation.DOWNLOAD:
|
|
|
|
|
|
|
|
if (EntityOperation.DOWNLOAD.equals(next.name)) {
|
|
|
|
|
|
|
|
JSONArray jnext = new JSONArray(next.args);
|
|
|
|
|
|
|
|
// Same uid
|
|
|
|
|
|
|
|
if (jargs.getLong(0) == jnext.getLong(0))
|
|
|
|
|
|
|
|
skip = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case EntityOperation.MOVE:
|
|
|
|
case EntityOperation.MOVE:
|
|
|
|
if (group &&
|
|
|
|
if (group &&
|
|
|
|
message.uid != null &&
|
|
|
|
message.uid != null &&
|
|
|
@ -540,6 +549,10 @@ class Core {
|
|
|
|
onRule(context, jargs, message);
|
|
|
|
onRule(context, jargs, message);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case EntityOperation.DOWNLOAD:
|
|
|
|
|
|
|
|
onDownload(context, jargs, account, folder, message, (IMAPStore) istore, (IMAPFolder) ifolder, state);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
throw new IllegalArgumentException("Unknown operation=" + op.name);
|
|
|
|
throw new IllegalArgumentException("Unknown operation=" + op.name);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1785,6 +1798,8 @@ class Core {
|
|
|
|
if (download) {
|
|
|
|
if (download) {
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
boolean fast_fetch = prefs.getBoolean("fast_fetch", false);
|
|
|
|
boolean fast_fetch = prefs.getBoolean("fast_fetch", false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean async = false;
|
|
|
|
if (fast_fetch) {
|
|
|
|
if (fast_fetch) {
|
|
|
|
long maxSize = prefs.getInt("download", MessageHelper.DEFAULT_DOWNLOAD_SIZE);
|
|
|
|
long maxSize = prefs.getInt("download", MessageHelper.DEFAULT_DOWNLOAD_SIZE);
|
|
|
|
if (maxSize == 0)
|
|
|
|
if (maxSize == 0)
|
|
|
@ -1793,19 +1808,23 @@ class Core {
|
|
|
|
|
|
|
|
|
|
|
|
if (!message.content)
|
|
|
|
if (!message.content)
|
|
|
|
if (state.getNetworkState().isUnmetered() || (message.size != null && message.size < maxSize))
|
|
|
|
if (state.getNetworkState().isUnmetered() || (message.size != null && message.size < maxSize))
|
|
|
|
EntityOperation.queue(context, message, EntityOperation.BODY);
|
|
|
|
async = true;
|
|
|
|
|
|
|
|
|
|
|
|
List<EntityAttachment> attachments = db.attachment().getAttachments(message.id);
|
|
|
|
List<EntityAttachment> attachments = db.attachment().getAttachments(message.id);
|
|
|
|
for (EntityAttachment attachment : attachments)
|
|
|
|
for (EntityAttachment attachment : attachments)
|
|
|
|
if (!attachment.available)
|
|
|
|
if (!attachment.available)
|
|
|
|
if (state.getNetworkState().isUnmetered() || (attachment.size != null && attachment.size < maxSize))
|
|
|
|
if (state.getNetworkState().isUnmetered() || (attachment.size != null && attachment.size < maxSize))
|
|
|
|
EntityOperation.queue(context, message, EntityOperation.ATTACHMENT, attachment.id);
|
|
|
|
async = true;
|
|
|
|
|
|
|
|
|
|
|
|
if (download_eml &&
|
|
|
|
if (download_eml &&
|
|
|
|
(message.raw == null || !message.raw) &&
|
|
|
|
(message.raw == null || !message.raw) &&
|
|
|
|
(state.getNetworkState().isUnmetered() || (message.total != null && message.total < maxSize)))
|
|
|
|
(state.getNetworkState().isUnmetered() || (message.total != null && message.total < maxSize)))
|
|
|
|
EntityOperation.queue(context, message, EntityOperation.RAW);
|
|
|
|
async = true;
|
|
|
|
} else
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (async && message.uid != null)
|
|
|
|
|
|
|
|
EntityOperation.queue(context, message, EntityOperation.DOWNLOAD, message.uid);
|
|
|
|
|
|
|
|
else
|
|
|
|
downloadMessage(context, account, folder, istore, ifolder, imessage, message.id, state, stats);
|
|
|
|
downloadMessage(context, account, folder, istore, ifolder, imessage, message.id, state, stats);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2933,6 +2952,15 @@ class Core {
|
|
|
|
rule.execute(context, message);
|
|
|
|
rule.execute(context, message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void onDownload(Context context, JSONArray jargs, EntityAccount account, EntityFolder folder, EntityMessage message, IMAPStore istore, IMAPFolder ifolder, State state) throws MessagingException, IOException, JSONException {
|
|
|
|
|
|
|
|
long uid = jargs.getLong(0);
|
|
|
|
|
|
|
|
if (!Objects.equals(uid, message.uid))
|
|
|
|
|
|
|
|
throw new IllegalArgumentException("Different uid" + uid + "/" + message.uid);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MimeMessage imessage = (MimeMessage) ifolder.getMessageByUID(uid);
|
|
|
|
|
|
|
|
downloadMessage(context, account, folder, istore, ifolder, imessage, message.id, state, new SyncStats());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static void onSynchronizeMessages(
|
|
|
|
private static void onSynchronizeMessages(
|
|
|
|
Context context, JSONArray jargs,
|
|
|
|
Context context, JSONArray jargs,
|
|
|
|
EntityAccount account, final EntityFolder folder,
|
|
|
|
EntityAccount account, final EntityFolder folder,
|
|
|
|