|
|
@ -165,7 +165,6 @@ class Core {
|
|
|
|
|
|
|
|
|
|
|
|
if (message == null) {
|
|
|
|
if (message == null) {
|
|
|
|
if (!EntityOperation.FETCH.equals(op.name) &&
|
|
|
|
if (!EntityOperation.FETCH.equals(op.name) &&
|
|
|
|
!EntityOperation.DELETED.equals(op.name) &&
|
|
|
|
|
|
|
|
!EntityOperation.SYNC.equals(op.name) &&
|
|
|
|
!EntityOperation.SYNC.equals(op.name) &&
|
|
|
|
!EntityOperation.SUBSCRIBE.equals(op.name))
|
|
|
|
!EntityOperation.SUBSCRIBE.equals(op.name))
|
|
|
|
throw new MessageRemovedException();
|
|
|
|
throw new MessageRemovedException();
|
|
|
@ -242,10 +241,6 @@ class Core {
|
|
|
|
onDelete(context, jargs, folder, message, (IMAPFolder) ifolder);
|
|
|
|
onDelete(context, jargs, folder, message, (IMAPFolder) ifolder);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case EntityOperation.DELETED:
|
|
|
|
|
|
|
|
onDeleted(context, jargs, folder, (IMAPFolder) ifolder);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case EntityOperation.HEADERS:
|
|
|
|
case EntityOperation.HEADERS:
|
|
|
|
onHeaders(context, jargs, folder, message, (IMAPFolder) ifolder);
|
|
|
|
onHeaders(context, jargs, folder, message, (IMAPFolder) ifolder);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -358,8 +353,6 @@ class Core {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
if (EntityOperation.DELETE.equals(op.name) && !TextUtils.isEmpty(message.msgid))
|
|
|
|
if (EntityOperation.DELETE.equals(op.name) && !TextUtils.isEmpty(message.msgid))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
if (EntityOperation.DELETED.equals(op.name))
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Log.i(folder.name + " ensure uid op=" + op.name + " msgid=" + message.msgid);
|
|
|
|
Log.i(folder.name + " ensure uid op=" + op.name + " msgid=" + message.msgid);
|
|
|
|
|
|
|
|
|
|
|
@ -700,15 +693,16 @@ class Core {
|
|
|
|
long uid = jargs.getLong(0);
|
|
|
|
long uid = jargs.getLong(0);
|
|
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
try {
|
|
|
|
|
|
|
|
EntityAccount account = db.account().getAccount(folder.account);
|
|
|
|
EntityAccount account = db.account().getAccount(folder.account);
|
|
|
|
boolean download = db.folder().getFolderDownload(folder.id);
|
|
|
|
boolean download = db.folder().getFolderDownload(folder.id);
|
|
|
|
List<EntityRule> rules = db.rule().getEnabledRules(folder.id);
|
|
|
|
List<EntityRule> rules = db.rule().getEnabledRules(folder.id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
IMAPMessage imessage = (IMAPMessage) ifolder.getMessageByUID(uid);
|
|
|
|
IMAPMessage imessage = (IMAPMessage) ifolder.getMessageByUID(uid);
|
|
|
|
if (imessage == null || imessage.isExpunged())
|
|
|
|
if (imessage == null)
|
|
|
|
return;
|
|
|
|
throw new MessageRemovedException();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
FetchProfile fp = new FetchProfile();
|
|
|
|
FetchProfile fp = new FetchProfile();
|
|
|
|
fp.add(FetchProfile.Item.ENVELOPE);
|
|
|
|
fp.add(FetchProfile.Item.ENVELOPE);
|
|
|
|
fp.add(FetchProfile.Item.FLAGS);
|
|
|
|
fp.add(FetchProfile.Item.FLAGS);
|
|
|
@ -720,14 +714,15 @@ class Core {
|
|
|
|
fp.add(IMAPFolder.FetchProfileItem.INTERNALDATE);
|
|
|
|
fp.add(IMAPFolder.FetchProfileItem.INTERNALDATE);
|
|
|
|
ifolder.fetch(new Message[]{imessage}, fp);
|
|
|
|
ifolder.fetch(new Message[]{imessage}, fp);
|
|
|
|
|
|
|
|
|
|
|
|
if (imessage.isSet(Flags.Flag.DELETED))
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EntityMessage message = synchronizeMessage(context, account, folder, ifolder, imessage, false, download, rules, state);
|
|
|
|
EntityMessage message = synchronizeMessage(context, account, folder, ifolder, imessage, false, download, rules, state);
|
|
|
|
if (download)
|
|
|
|
if (download)
|
|
|
|
downloadMessage(context, folder, ifolder, imessage, message.id, state);
|
|
|
|
downloadMessage(context, folder, ifolder, imessage, message.id, state);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
imessage.invalidateHeaders();
|
|
|
|
imessage.invalidateHeaders();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (MessageRemovedException ex) {
|
|
|
|
|
|
|
|
Log.i(ex);
|
|
|
|
|
|
|
|
db.message().deleteMessage(folder.id, uid);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
int count = ifolder.getMessageCount();
|
|
|
|
int count = ifolder.getMessageCount();
|
|
|
|
db.folder().setFolderTotal(folder.id, count < 0 ? null : count);
|
|
|
|
db.folder().setFolderTotal(folder.id, count < 0 ? null : count);
|
|
|
@ -779,18 +774,6 @@ class Core {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static void onDeleted(Context context, JSONArray jargs, EntityFolder folder, IMAPFolder ifolder) throws JSONException, MessagingException, IOException {
|
|
|
|
|
|
|
|
long uid = jargs.getLong(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
db.message().deleteMessage(folder.id, uid);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
int count = ifolder.getMessageCount();
|
|
|
|
|
|
|
|
db.folder().setFolderTotal(folder.id, count < 0 ? null : count);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void onHeaders(Context context, JSONArray jargs, EntityFolder folder, EntityMessage message, IMAPFolder ifolder) throws MessagingException {
|
|
|
|
private static void onHeaders(Context context, JSONArray jargs, EntityFolder folder, EntityMessage message, IMAPFolder ifolder) throws MessagingException {
|
|
|
|
// Download headers
|
|
|
|
// Download headers
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|