mirror of https://github.com/M66B/FairEmail.git
POP3 delete messages
This commit is contained in:
parent
6e804cbc0b
commit
d7cf5736de
|
@ -810,7 +810,9 @@ class Core {
|
|||
// Delete message
|
||||
DB db = DB.getInstance(context);
|
||||
|
||||
if (!EntityFolder.INBOX.equals(folder.type))
|
||||
if (EntityFolder.INBOX.equals(folder.type)) {
|
||||
// Do nothing
|
||||
} else
|
||||
db.message().deleteMessage(folder.id, message.id);
|
||||
}
|
||||
|
||||
|
@ -1135,6 +1137,8 @@ class Core {
|
|||
final POP3Folder ifolder, State state) throws MessagingException {
|
||||
DB db = DB.getInstance(context);
|
||||
|
||||
Log.i(folder.name + " POP sync type=" + folder.type + " connected=" + (ifolder != null));
|
||||
|
||||
if (!EntityFolder.INBOX.equals(folder.type)) {
|
||||
db.folder().setFolderSyncState(folder.id, null);
|
||||
return;
|
||||
|
@ -1145,13 +1149,18 @@ class Core {
|
|||
|
||||
Message[] imessages = ifolder.getMessages();
|
||||
Log.i(folder.name + " POP messages=" + imessages.length);
|
||||
if (imessages.length == 0)
|
||||
return;
|
||||
|
||||
db.folder().setFolderSyncState(folder.id, "downloading");
|
||||
|
||||
List<String> existing = db.message().getMsgIds(folder.id);
|
||||
Log.i(folder.name + " POP existing=" + existing.size());
|
||||
|
||||
for (Message imessage : imessages)
|
||||
try {
|
||||
if (!state.isRunning())
|
||||
break;
|
||||
return;
|
||||
|
||||
MessageHelper helper = new MessageHelper((MimeMessage) imessage);
|
||||
String msgid = helper.getMessageID();
|
||||
|
@ -1160,12 +1169,14 @@ class Core {
|
|||
continue;
|
||||
}
|
||||
|
||||
List<EntityMessage> messages = db.message().getMessageByMsgId(folder.account, msgid);
|
||||
if (messages.size() > 0) {
|
||||
if (existing.contains(msgid)) {
|
||||
existing.remove(msgid);
|
||||
Log.i(folder.name + " POP having=" + msgid);
|
||||
continue;
|
||||
}
|
||||
|
||||
Log.i(folder.name + " POP sync=" + msgid);
|
||||
|
||||
String authentication = helper.getAuthentication();
|
||||
MessageHelper.MessageParts parts = helper.getMessageParts();
|
||||
|
||||
|
@ -1261,6 +1272,11 @@ class Core {
|
|||
} finally {
|
||||
((POP3Message) imessage).invalidate(true);
|
||||
}
|
||||
|
||||
for (String msgid : existing) {
|
||||
Log.i(folder.name + " POP deleted=" + msgid);
|
||||
db.message().deleteMessage(folder.id, msgid);
|
||||
}
|
||||
} finally {
|
||||
db.folder().setFolderSyncState(folder.id, null);
|
||||
}
|
||||
|
|
|
@ -226,9 +226,6 @@ public interface DaoFolder {
|
|||
@Query("UPDATE folder SET type = :type WHERE id = :id")
|
||||
int setFolderType(long id, String type);
|
||||
|
||||
@Query("UPDATE folder SET display = :display WHERE id = :id")
|
||||
int setFolderDisplay(long id, String display);
|
||||
|
||||
@Query("UPDATE folder SET `order` = :order WHERE id = :id")
|
||||
int setFolderOrder(long id, Integer order);
|
||||
|
||||
|
|
|
@ -313,6 +313,10 @@ public interface DaoMessage {
|
|||
" AND NOT uid IS NULL")
|
||||
List<Long> getUids(long folder, Long received);
|
||||
|
||||
@Query("SELECT msgid FROM message" +
|
||||
" WHERE folder = :folder")
|
||||
List<String> getMsgIds(long folder);
|
||||
|
||||
@Query("SELECT * FROM message" +
|
||||
" WHERE folder = :folder" +
|
||||
" AND uid IS NULL" +
|
||||
|
@ -459,6 +463,11 @@ public interface DaoMessage {
|
|||
" AND uid = :uid")
|
||||
int deleteMessage(long folder, long uid);
|
||||
|
||||
@Query("DELETE FROM message" +
|
||||
" WHERE folder = :folder" +
|
||||
" AND msgid = :msgid")
|
||||
int deleteMessage(long folder, String msgid);
|
||||
|
||||
@Query("DELETE FROM message" +
|
||||
" WHERE folder = :folder" +
|
||||
" AND NOT uid IS NULL")
|
||||
|
|
|
@ -68,6 +68,8 @@ public class MailService implements AutoCloseable {
|
|||
String checkserveridentity = Boolean.toString(!insecure).toLowerCase();
|
||||
|
||||
if ("pop3".equals(protocol) || "pop3s".equals(protocol)) {
|
||||
this.debug = true;
|
||||
|
||||
// https://javaee.github.io/javamail/docs/api/com/sun/mail/pop3/package-summary.html#properties
|
||||
properties.put("mail." + protocol + ".ssl.checkserveridentity", checkserveridentity);
|
||||
properties.put("mail." + protocol + ".ssl.trust", "*");
|
||||
|
@ -82,6 +84,8 @@ public class MailService implements AutoCloseable {
|
|||
properties.put("mail." + protocol + ".writetimeout", Integer.toString(WRITE_TIMEOUT)); // one thread overhead
|
||||
properties.put("mail." + protocol + ".timeout", Integer.toString(READ_TIMEOUT));
|
||||
|
||||
properties.put("mail." + protocol + ".rsetbeforequit", "true");
|
||||
|
||||
} else if ("imap".equals(protocol) || "imaps".equals(protocol)) {
|
||||
// https://javaee.github.io/javamail/docs/api/com/sun/mail/imap/package-summary.html#properties
|
||||
properties.put("mail." + protocol + ".ssl.checkserveridentity", checkserveridentity);
|
||||
|
|
Loading…
Reference in New Issue