mirror of
https://github.com/M66B/FairEmail.git
synced 2025-12-30 09:31:11 +01:00
Fixed IMAP event listener
This commit is contained in:
@@ -34,6 +34,7 @@ import javax.mail.NoSuchProviderException;
|
||||
import javax.mail.Service;
|
||||
import javax.mail.Session;
|
||||
import javax.mail.Store;
|
||||
import javax.mail.event.StoreListener;
|
||||
|
||||
public class MailService implements AutoCloseable {
|
||||
private Context context;
|
||||
@@ -43,6 +44,7 @@ public class MailService implements AutoCloseable {
|
||||
private Properties properties;
|
||||
private Session isession;
|
||||
private Service iservice;
|
||||
private StoreListener listener;
|
||||
|
||||
private ExecutorService executor = Helper.getBackgroundExecutor(0, "mail");
|
||||
|
||||
@@ -123,6 +125,7 @@ public class MailService implements AutoCloseable {
|
||||
properties.put("mail.imap.starttls.enable", "true");
|
||||
properties.put("mail.imap.starttls.required", Boolean.toString(!insecure));
|
||||
|
||||
properties.put("mail." + protocol + ".separatestoreconnection", "true");
|
||||
properties.put("mail." + protocol + ".connectionpool.debug", "true");
|
||||
properties.put("mail." + protocol + ".connectionpoolsize", "1");
|
||||
properties.put("mail." + protocol + ".connectionpooltimeout", Integer.toString(POOL_TIMEOUT));
|
||||
@@ -169,14 +172,14 @@ public class MailService implements AutoCloseable {
|
||||
useip = enabled;
|
||||
}
|
||||
|
||||
void setSeparateStoreConnection() {
|
||||
properties.put("mail." + protocol + ".separatestoreconnection", "true");
|
||||
}
|
||||
|
||||
void setLeaveOnServer(boolean keep) {
|
||||
properties.put("mail." + protocol + ".rsetbeforequit", Boolean.toString(keep));
|
||||
}
|
||||
|
||||
void setListener(StoreListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void connect(EntityAccount account) throws MessagingException {
|
||||
String password = connect(account.host, account.port, account.auth_type, account.user, account.password);
|
||||
if (password != null) {
|
||||
@@ -265,6 +268,8 @@ public class MailService implements AutoCloseable {
|
||||
|
||||
} else if ("imap".equals(protocol) || "imaps".equals(protocol)) {
|
||||
iservice = isession.getStore(protocol);
|
||||
if (listener != null)
|
||||
((IMAPStore) iservice).addStoreListener(listener);
|
||||
iservice.connect(host, port, user, password);
|
||||
|
||||
// https://www.ietf.org/rfc/rfc2971.txt
|
||||
|
||||
Reference in New Issue
Block a user