mirror of https://github.com/M66B/FairEmail.git
Refactoring
This commit is contained in:
parent
e1a785afc3
commit
c912f99bce
|
@ -415,7 +415,8 @@ public class ActivityEML extends ActivityBase {
|
|||
Session isession = Session.getInstance(props, null);
|
||||
MimeMessage imessage = new MimeMessage(isession, is);
|
||||
|
||||
try (EmailService iservice = new EmailService(context, account.getProtocol(), account.realm, account.insecure, true)) {
|
||||
try (EmailService iservice = new EmailService(
|
||||
context, account.getProtocol(), account.realm, account.insecure, true)) {
|
||||
iservice.setPartialFetch(account.partial_fetch);
|
||||
iservice.setIgnoreBodyStructureSize(account.ignore_size);
|
||||
iservice.connect(account);
|
||||
|
|
|
@ -303,7 +303,8 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
|||
throw new IllegalStateException(context.getString(R.string.title_no_internet));
|
||||
|
||||
Log.i("Boundary server connecting account=" + account.name);
|
||||
state.iservice = new EmailService(context, account.getProtocol(), account.realm, account.insecure, EmailService.PURPOSE_SEARCH, debug);
|
||||
state.iservice = new EmailService(
|
||||
context, account.getProtocol(), account.realm, account.insecure, EmailService.PURPOSE_SEARCH, debug);
|
||||
state.iservice.setPartialFetch(account.partial_fetch);
|
||||
state.iservice.setIgnoreBodyStructureSize(account.ignore_size);
|
||||
state.iservice.connect(account);
|
||||
|
|
|
@ -615,8 +615,12 @@ public class FragmentAccount extends FragmentBase {
|
|||
|
||||
// Check IMAP server / get folders
|
||||
String protocol = "imap" + (starttls ? "" : "s");
|
||||
try (EmailService iservice = new EmailService(context, protocol, realm, insecure, EmailService.PURPOSE_CHECK, true)) {
|
||||
iservice.connect(host, Integer.parseInt(port), auth, provider, user, password, fingerprint);
|
||||
try (EmailService iservice = new EmailService(
|
||||
context, protocol, realm, insecure, EmailService.PURPOSE_CHECK, true)) {
|
||||
iservice.connect(
|
||||
host, Integer.parseInt(port),
|
||||
auth, provider,
|
||||
user, password, fingerprint);
|
||||
|
||||
result.idle = iservice.hasCapability("IDLE");
|
||||
|
||||
|
@ -983,8 +987,12 @@ public class FragmentAccount extends FragmentBase {
|
|||
EntityFolder inbox = null;
|
||||
if (check) {
|
||||
String protocol = "imap" + (starttls ? "" : "s");
|
||||
try (EmailService iservice = new EmailService(context, protocol, realm, insecure, EmailService.PURPOSE_CHECK, true)) {
|
||||
iservice.connect(host, Integer.parseInt(port), auth, provider, user, password, fingerprint);
|
||||
try (EmailService iservice = new EmailService(
|
||||
context, protocol, realm, insecure, EmailService.PURPOSE_CHECK, true)) {
|
||||
iservice.connect(
|
||||
host, Integer.parseInt(port),
|
||||
auth, provider,
|
||||
user, password, fingerprint);
|
||||
|
||||
for (Folder ifolder : iservice.getStore().getDefaultFolder().list("*")) {
|
||||
// Check folder attributes
|
||||
|
|
|
@ -310,8 +310,12 @@ public class FragmentGmail extends FragmentBase {
|
|||
List<EntityFolder> folders;
|
||||
|
||||
String aprotocol = provider.imap.starttls ? "imap" : "imaps";
|
||||
try (EmailService iservice = new EmailService(context, aprotocol, null, false, EmailService.PURPOSE_CHECK, true)) {
|
||||
iservice.connect(provider.imap.host, provider.imap.port, EmailService.AUTH_TYPE_GMAIL, null, user, password, null);
|
||||
try (EmailService iservice = new EmailService(
|
||||
context, aprotocol, null, false, EmailService.PURPOSE_CHECK, true)) {
|
||||
iservice.connect(
|
||||
provider.imap.host, provider.imap.port,
|
||||
EmailService.AUTH_TYPE_GMAIL, null,
|
||||
user, password, null);
|
||||
|
||||
folders = iservice.getFolders();
|
||||
|
||||
|
@ -320,8 +324,12 @@ public class FragmentGmail extends FragmentBase {
|
|||
}
|
||||
|
||||
String iprotocol = provider.smtp.starttls ? "smtp" : "smtps";
|
||||
try (EmailService iservice = new EmailService(context, iprotocol, null, false, EmailService.PURPOSE_CHECK, true)) {
|
||||
iservice.connect(provider.smtp.host, provider.smtp.port, EmailService.AUTH_TYPE_GMAIL, null, user, password, null);
|
||||
try (EmailService iservice = new EmailService(
|
||||
context, iprotocol, null, false, EmailService.PURPOSE_CHECK, true)) {
|
||||
iservice.connect(
|
||||
provider.smtp.host, provider.smtp.port,
|
||||
EmailService.AUTH_TYPE_GMAIL, null,
|
||||
user, password, null);
|
||||
}
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
|
|
|
@ -776,7 +776,8 @@ public class FragmentIdentity extends FragmentBase {
|
|||
if (check) {
|
||||
// Create transport
|
||||
String protocol = (starttls ? "smtp" : "smtps");
|
||||
try (EmailService iservice = new EmailService(context, protocol, realm, insecure, EmailService.PURPOSE_CHECK, true)) {
|
||||
try (EmailService iservice = new EmailService(
|
||||
context, protocol, realm, insecure, EmailService.PURPOSE_CHECK, true)) {
|
||||
iservice.setUseIp(use_ip);
|
||||
iservice.connect(host, Integer.parseInt(port), auth, provider, user, password, fingerprint);
|
||||
}
|
||||
|
|
|
@ -469,8 +469,12 @@ public class FragmentOAuth extends FragmentBase {
|
|||
|
||||
Log.i("OAuth checking IMAP provider=" + provider.id);
|
||||
String aprotocol = provider.imap.starttls ? "imap" : "imaps";
|
||||
try (EmailService iservice = new EmailService(context, aprotocol, null, false, EmailService.PURPOSE_CHECK, true)) {
|
||||
iservice.connect(provider.imap.host, provider.imap.port, EmailService.AUTH_TYPE_OAUTH, provider.id, primaryEmail, state, null);
|
||||
try (EmailService iservice = new EmailService(
|
||||
context, aprotocol, null, false, EmailService.PURPOSE_CHECK, true)) {
|
||||
iservice.connect(
|
||||
provider.imap.host, provider.imap.port,
|
||||
EmailService.AUTH_TYPE_OAUTH, provider.id,
|
||||
primaryEmail, state, null);
|
||||
|
||||
folders = iservice.getFolders();
|
||||
|
||||
|
@ -480,8 +484,12 @@ public class FragmentOAuth extends FragmentBase {
|
|||
|
||||
Log.i("OAuth checking SMTP provider=" + provider.id);
|
||||
String iprotocol = provider.smtp.starttls ? "smtp" : "smtps";
|
||||
try (EmailService iservice = new EmailService(context, iprotocol, null, false, EmailService.PURPOSE_CHECK, true)) {
|
||||
iservice.connect(provider.smtp.host, provider.smtp.port, EmailService.AUTH_TYPE_OAUTH, provider.id, primaryEmail, state, null);
|
||||
try (EmailService iservice = new EmailService(
|
||||
context, iprotocol, null, false, EmailService.PURPOSE_CHECK, true)) {
|
||||
iservice.connect(
|
||||
provider.smtp.host, provider.smtp.port,
|
||||
EmailService.AUTH_TYPE_OAUTH, provider.id,
|
||||
primaryEmail, state, null);
|
||||
}
|
||||
|
||||
Log.i("OAuth passed provider=" + provider.id);
|
||||
|
|
|
@ -309,8 +309,12 @@ public class FragmentPop extends FragmentBase {
|
|||
// Check POP3 server
|
||||
if (check) {
|
||||
String protocol = "pop3" + (starttls ? "" : "s");
|
||||
try (EmailService iservice = new EmailService(context, protocol, null, insecure, EmailService.PURPOSE_CHECK, true)) {
|
||||
iservice.connect(host, Integer.parseInt(port), EmailService.AUTH_TYPE_PASSWORD, null, user, password, null);
|
||||
try (EmailService iservice = new EmailService(
|
||||
context, protocol, null, insecure, EmailService.PURPOSE_CHECK, true)) {
|
||||
iservice.connect(
|
||||
host, Integer.parseInt(port),
|
||||
EmailService.AUTH_TYPE_PASSWORD, null,
|
||||
user, password, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -278,9 +278,13 @@ public class FragmentQuickSetup extends FragmentBase {
|
|||
List<EntityFolder> folders;
|
||||
|
||||
String aprotocol = provider.imap.starttls ? "imap" : "imaps";
|
||||
try (EmailService iservice = new EmailService(context, aprotocol, null, false, EmailService.PURPOSE_CHECK, true)) {
|
||||
try (EmailService iservice = new EmailService(
|
||||
context, aprotocol, null, false, EmailService.PURPOSE_CHECK, true)) {
|
||||
try {
|
||||
iservice.connect(provider.imap.host, provider.imap.port, EmailService.AUTH_TYPE_PASSWORD, null, user, password, null);
|
||||
iservice.connect(
|
||||
provider.imap.host, provider.imap.port,
|
||||
EmailService.AUTH_TYPE_PASSWORD, null,
|
||||
user, password, null);
|
||||
} catch (AuthenticationFailedException ex) {
|
||||
if (!user.equals(username)) {
|
||||
Log.w(ex);
|
||||
|
@ -298,9 +302,13 @@ public class FragmentQuickSetup extends FragmentBase {
|
|||
}
|
||||
|
||||
String iprotocol = provider.smtp.starttls ? "smtp" : "smtps";
|
||||
try (EmailService iservice = new EmailService(context, iprotocol, null, false, EmailService.PURPOSE_CHECK, true)) {
|
||||
try (EmailService iservice = new EmailService(
|
||||
context, iprotocol, null, false, EmailService.PURPOSE_CHECK, true)) {
|
||||
iservice.setUseIp(provider.useip);
|
||||
iservice.connect(provider.smtp.host, provider.smtp.port, EmailService.AUTH_TYPE_PASSWORD, null, user, password, null);
|
||||
iservice.connect(
|
||||
provider.smtp.host, provider.smtp.port,
|
||||
EmailService.AUTH_TYPE_PASSWORD, null,
|
||||
user, password, null);
|
||||
}
|
||||
|
||||
if (check)
|
||||
|
|
Loading…
Reference in New Issue