|
|
|
@ -182,7 +182,8 @@ class Core {
|
|
|
|
|
if (!Objects.equals(folder.id, op.folder))
|
|
|
|
|
throw new IllegalArgumentException("Invalid folder=" + folder.id + "/" + op.folder);
|
|
|
|
|
|
|
|
|
|
if (ifolder != null && !ifolder.isOpen())
|
|
|
|
|
if (account.protocol == EntityAccount.TYPE_IMAP &&
|
|
|
|
|
!folder.local && ifolder != null && !ifolder.isOpen())
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// Fetch most recent copy of message
|
|
|
|
@ -578,6 +579,8 @@ class Core {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void ensureUid(Context context, EntityFolder folder, EntityMessage message, EntityOperation op, IMAPFolder ifolder) throws MessagingException {
|
|
|
|
|
if (folder.local)
|
|
|
|
|
return;
|
|
|
|
|
if (message == null || message.uid != null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
@ -850,6 +853,11 @@ class Core {
|
|
|
|
|
// Add message
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
|
|
|
|
|
if (folder.local) {
|
|
|
|
|
Log.i(folder.name + " local add");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Drafts can change accounts
|
|
|
|
|
if (jargs.length() == 0 && !folder.id.equals(message.folder))
|
|
|
|
|
throw new IllegalArgumentException("Message folder changed");
|
|
|
|
@ -1260,6 +1268,13 @@ class Core {
|
|
|
|
|
private static void onDelete(Context context, JSONArray jargs, EntityFolder folder, EntityMessage message, IMAPFolder ifolder) throws MessagingException {
|
|
|
|
|
// Delete message
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
|
|
|
|
|
if (folder.local) {
|
|
|
|
|
Log.i(folder.name + " local delete");
|
|
|
|
|
db.message().deleteMessage(message.id);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
boolean deleted = false;
|
|
|
|
|
|
|
|
|
@ -1556,8 +1571,10 @@ class Core {
|
|
|
|
|
boolean sync_subscribed = prefs.getBoolean("sync_subscribed", false);
|
|
|
|
|
|
|
|
|
|
// Get folder names
|
|
|
|
|
boolean drafts = false;
|
|
|
|
|
Map<String, EntityFolder> local = new HashMap<>();
|
|
|
|
|
for (EntityFolder folder : db.folder().getFolders(account.id, false, false))
|
|
|
|
|
List<EntityFolder> folders = db.folder().getFolders(account.id, false, false);
|
|
|
|
|
for (EntityFolder folder : folders)
|
|
|
|
|
if (folder.tbc != null) {
|
|
|
|
|
Log.i(folder.name + " creating");
|
|
|
|
|
Folder ifolder = istore.getFolder(folder.name);
|
|
|
|
@ -1607,11 +1624,29 @@ class Core {
|
|
|
|
|
sync_folders = true;
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
local.put(folder.name, folder);
|
|
|
|
|
if (folder.synchronize && folder.initialize != 0)
|
|
|
|
|
sync_folders = true;
|
|
|
|
|
if (EntityFolder.DRAFTS.equals(folder.type))
|
|
|
|
|
drafts = true;
|
|
|
|
|
if (!folder.local) {
|
|
|
|
|
local.put(folder.name, folder);
|
|
|
|
|
if (folder.synchronize && folder.initialize != 0)
|
|
|
|
|
sync_folders = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Log.i("Local folder count=" + local.size());
|
|
|
|
|
Log.i("Local folder count=" + local.size() + " drafts=" + drafts);
|
|
|
|
|
|
|
|
|
|
if (!drafts) {
|
|
|
|
|
EntityFolder d = new EntityFolder();
|
|
|
|
|
d.account = account.id;
|
|
|
|
|
d.name = context.getString(R.string.title_folder_local_drafts);
|
|
|
|
|
d.type = EntityFolder.DRAFTS;
|
|
|
|
|
d.local = true;
|
|
|
|
|
d.setProperties();
|
|
|
|
|
d.synchronize = false;
|
|
|
|
|
d.download = false;
|
|
|
|
|
d.sync_days = Integer.MAX_VALUE;
|
|
|
|
|
d.keep_days = Integer.MAX_VALUE;
|
|
|
|
|
db.folder().insertFolder(d);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!sync_folders)
|
|
|
|
|
return;
|
|
|
|
|