|
|
|
@ -912,7 +912,6 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
ifolder.addMessageCountListener(new MessageCountAdapter() {
|
|
|
|
|
@Override
|
|
|
|
|
public void messagesAdded(MessageCountEvent e) {
|
|
|
|
|
synchronized (folder) {
|
|
|
|
|
try {
|
|
|
|
|
wlAccount.acquire();
|
|
|
|
|
Log.i(Helper.TAG, folder.name + " messages added");
|
|
|
|
@ -966,11 +965,9 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
wlAccount.release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void messagesRemoved(MessageCountEvent e) {
|
|
|
|
|
synchronized (folder) {
|
|
|
|
|
try {
|
|
|
|
|
wlAccount.acquire();
|
|
|
|
|
Log.i(Helper.TAG, folder.name + " messages removed");
|
|
|
|
@ -994,7 +991,6 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
wlAccount.release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Flags (like "seen") at the remote could be changed while synchronizing
|
|
|
|
@ -1003,7 +999,6 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
ifolder.addMessageChangedListener(new MessageChangedListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void messageChanged(MessageChangedEvent e) {
|
|
|
|
|
synchronized (folder) {
|
|
|
|
|
try {
|
|
|
|
|
wlAccount.acquire();
|
|
|
|
|
try {
|
|
|
|
@ -1050,7 +1045,6 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
wlAccount.release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Idle folder
|
|
|
|
@ -1332,7 +1326,6 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void processOperations(EntityAccount account, EntityFolder folder, Session isession, IMAPStore istore, IMAPFolder ifolder, ServiceState state) throws MessagingException, JSONException, IOException {
|
|
|
|
|
synchronized (folder) {
|
|
|
|
|
try {
|
|
|
|
|
Log.i(Helper.TAG, folder.name + " start process");
|
|
|
|
|
|
|
|
|
@ -1453,7 +1446,6 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
Log.i(Helper.TAG, folder.name + " end process state=" + state);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void doSeen(EntityFolder folder, IMAPFolder ifolder, EntityMessage message, JSONArray jargs, DB db) throws MessagingException, JSONException {
|
|
|
|
|
// Mark message (un)seen
|
|
|
|
@ -1536,6 +1528,11 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
Flags flags = new Flags(keyword);
|
|
|
|
|
imessage.setFlags(flags, set);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
db.beginTransaction();
|
|
|
|
|
|
|
|
|
|
message = db.message().getMessage(message.id);
|
|
|
|
|
|
|
|
|
|
List<String> keywords = new ArrayList<>(Arrays.asList(message.keywords));
|
|
|
|
|
if (set) {
|
|
|
|
|
if (!keywords.contains(keyword))
|
|
|
|
@ -1543,6 +1540,11 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
} else
|
|
|
|
|
keywords.remove(keyword);
|
|
|
|
|
db.message().setMessageKeywords(message.id, DB.Converters.fromStringArray(keywords.toArray(new String[0])));
|
|
|
|
|
|
|
|
|
|
db.setTransactionSuccessful();
|
|
|
|
|
} finally {
|
|
|
|
|
db.endTransaction();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void doAdd(EntityFolder folder, Session isession, IMAPStore istore, IMAPFolder ifolder, EntityMessage message, JSONArray jargs, DB db) throws MessagingException, JSONException, IOException {
|
|
|
|
@ -1672,6 +1674,9 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
try {
|
|
|
|
|
db.beginTransaction();
|
|
|
|
|
|
|
|
|
|
// Message could be moved
|
|
|
|
|
message = db.message().getMessage(message.id);
|
|
|
|
|
|
|
|
|
|
// Mark message as sent
|
|
|
|
|
// - will be moved to sent folder by synchronize message later
|
|
|
|
|
message.sent = imessage.getSentDate().getTime();
|
|
|
|
|