Partial fetch configuration

pull/168/head
M66B 5 years ago
parent 4fba20b078
commit 3334cba92d

@ -62,6 +62,7 @@ public class EmailProvider {
public int order;
public String type;
public int keepalive;
public boolean partial;
public boolean useip;
public String link;
public Server imap = new Server();
@ -111,6 +112,7 @@ public class EmailProvider {
provider.domain = Arrays.asList(domain.split(","));
provider.order = xml.getAttributeIntValue(null, "order", Integer.MAX_VALUE);
provider.keepalive = xml.getAttributeIntValue(null, "keepalive", 0);
provider.partial = xml.getAttributeBooleanValue(null, "partial", true);
provider.useip = xml.getAttributeBooleanValue(null, "useip", true);
provider.link = xml.getAttributeValue(null, "link");
provider.type = xml.getAttributeValue(null, "type");
@ -191,6 +193,10 @@ public class EmailProvider {
return provider;
}
// https://docs.aws.amazon.com/workmail/latest/userguide/using_IMAP_client.html
if (autoconfig.imap.host.endsWith(".awsapps.com"))
autoconfig.partial = false;
return autoconfig;
}

@ -272,6 +272,7 @@ public class FragmentAccount extends FragmentBase {
etName.setText(position > 1 ? provider.name : null);
etInterval.setText(provider.keepalive > 0 ? Integer.toString(provider.keepalive) : null);
cbPartialFetch.setChecked(provider.partial);
grpFolders.setVisibility(View.GONE);
btnSave.setVisibility(View.GONE);
@ -559,7 +560,6 @@ public class FragmentAccount extends FragmentBase {
iservice.connect(host, Integer.parseInt(port), auth, user, password);
result.idle = iservice.hasCapability("IDLE");
result.empty = iservice.emptyMessages();
boolean inbox = false;
@ -631,8 +631,6 @@ public class FragmentAccount extends FragmentBase {
tvUtf8.setVisibility(result.utf8 == null || result.utf8 ? View.GONE : View.VISIBLE);
if (!result.idle)
etInterval.setText(Integer.toString(EntityAccount.DEFAULT_POLL_INTERVAL));
if (result.empty)
cbPartialFetch.setChecked(false);
setFolders(result.folders, result.account);
@ -1552,6 +1550,5 @@ public class FragmentAccount extends FragmentBase {
List<EntityFolder> folders;
boolean idle;
Boolean utf8;
boolean empty;
}
}

@ -245,7 +245,6 @@ public class FragmentQuickSetup extends FragmentBase {
String user = (provider.user == EmailProvider.UserType.EMAIL ? email : username);
Log.i("User type=" + provider.user + " name=" + user);
boolean empty;
List<EntityFolder> folders;
String aprotocol = provider.imap.starttls ? "imap" : "imaps";
@ -262,7 +261,6 @@ public class FragmentQuickSetup extends FragmentBase {
throw ex;
}
empty = iservice.emptyMessages();
folders = iservice.getFolders();
if (folders == null)
@ -299,8 +297,10 @@ public class FragmentQuickSetup extends FragmentBase {
account.synchronize = true;
account.primary = (primary == null);
if (empty)
account.partial_fetch = false;
if (provider.keepalive > 0)
account.poll_interval = provider.keepalive;
account.partial_fetch = provider.partial;
account.created = new Date().getTime();
account.last_connected = account.created;

@ -23,7 +23,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ExecutorService;
@ -44,7 +43,6 @@ public class MailService implements AutoCloseable {
private Properties properties;
private Session isession;
private Service iservice;
private boolean empty;
private ExecutorService executor = Helper.getBackgroundExecutor(0, "mail");
@ -282,19 +280,6 @@ public class MailService implements AutoCloseable {
for (String key : sid.keySet()) {
crumb.put(key, sid.get(key));
EntityLog.log(context, "Server " + key + "=" + sid.get(key));
if ("name".equals(key)) {
String name = sid.get(key);
if (!TextUtils.isEmpty(name)) {
name = name.toLowerCase(Locale.ROOT);
// name=Amazon WorkMail IMAP version=1.0
// name=Microsoft.Exchange.Imap4.Imap4Server version=15
if ((name.contains("amazon") && name.contains("workmail")) ||
(name.contains("microsoft") && name.contains("exchange")))
empty = true;
}
}
}
Log.breadcrumb("server", crumb);
}
@ -401,10 +386,6 @@ public class MailService implements AutoCloseable {
return false;
}
boolean emptyMessages() {
return this.empty;
}
public void close() throws MessagingException {
try {
if (iservice != null && iservice.isConnected())

@ -19,7 +19,8 @@
name="Outlook/Office365"
domain="outlook\\..*,live\\..*,hotmail\\..*"
link="https://github.com/M66B/FairEmail/blob/master/FAQ.md#user-content-faq14"
order="2">
order="2"
partial="false">
<imap
host="outlook.office365.com"
port="993"

Loading…
Cancel
Save