From 2810115d2ffb917475f9a15ab65530013d03f133 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 14 Dec 2023 17:06:40 +0100 Subject: [PATCH] Log capabilities --- .../main/java/com/sun/mail/smtp/SMTPTransport.java | 4 ++++ app/src/main/java/eu/faircode/email/Core.java | 6 +++--- .../main/java/eu/faircode/email/EmailService.java | 13 +++++++------ .../main/java/eu/faircode/email/ServiceSend.java | 3 +++ .../java/eu/faircode/email/ServiceSynchronize.java | 1 + 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/sun/mail/smtp/SMTPTransport.java b/app/src/main/java/com/sun/mail/smtp/SMTPTransport.java index b685794ecb..be4f4192a9 100644 --- a/app/src/main/java/com/sun/mail/smtp/SMTPTransport.java +++ b/app/src/main/java/com/sun/mail/smtp/SMTPTransport.java @@ -2653,6 +2653,10 @@ public class SMTPTransport extends Transport { extMap.get(ext.toUpperCase(Locale.ENGLISH)); } + public Map getExtensionParameters() { + return extMap; + } + /** * Does the server we're connected to support the specified * authentication mechanism? Uses the extension information diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index c9607d2ad2..d732e84bd8 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -3209,9 +3209,9 @@ class Core { // Get capabilities Map caps = istore.capabilities(); boolean hasUidl = caps.containsKey("UIDL"); - EntityLog.log(context, account.name + - " POP capabilities= " + caps.keySet() + - " uidl=" + account.capability_uidl); + String capabilities = TextUtils.join(" ", caps.values()); + EntityLog.log(context, EntityLog.Type.Protocol, account, capabilities); + db.account().setAccountCapabilities(account.id, capabilities, false, false); if (hasUidl) { if (Boolean.FALSE.equals(account.capability_uidl)) { diff --git a/app/src/main/java/eu/faircode/email/EmailService.java b/app/src/main/java/eu/faircode/email/EmailService.java index a685b1b986..4a6b52bfb0 100644 --- a/app/src/main/java/eu/faircode/email/EmailService.java +++ b/app/src/main/java/eu/faircode/email/EmailService.java @@ -940,17 +940,18 @@ public class EmailService implements AutoCloseable { List getCapabilities() throws MessagingException { List result = new ArrayList<>(); - Store store = getStore(); Map capabilities; - if (store instanceof IMAPStore) - capabilities = ((IMAPStore) getStore()).getCapabilities(); - else if (store instanceof POP3Store) - capabilities = ((POP3Store) getStore()).getCapabilities(); + if (iservice instanceof IMAPStore) + capabilities = ((IMAPStore) iservice).getCapabilities(); + else if (iservice instanceof POP3Store) + capabilities = ((POP3Store) iservice).getCapabilities(); + else if (iservice instanceof SMTPTransport) + capabilities = ((SMTPTransport) iservice).getExtensionParameters(); else capabilities = null; if (capabilities != null) - result.addAll(capabilities.keySet()); + result.addAll(capabilities.values()); return result; } diff --git a/app/src/main/java/eu/faircode/email/ServiceSend.java b/app/src/main/java/eu/faircode/email/ServiceSend.java index aba48bd7c7..56ee84e183 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSend.java +++ b/app/src/main/java/eu/faircode/email/ServiceSend.java @@ -778,6 +778,9 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar throw new IOException("Test"); db.identity().setIdentityState(ident.id, "connected"); + EntityLog.log(this, EntityLog.Type.Protocol, ident.email + " " + + TextUtils.join(" ", iservice.getCapabilities())); + max_size = iservice.getMaxSize(); List
recipients = new ArrayList<>(); diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 6596c8680c..4522c590ee 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -1738,6 +1738,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences final boolean capNotify = iservice.hasCapability("NOTIFY"); String capabilities = TextUtils.join(" ", iservice.getCapabilities()); + EntityLog.log(this, EntityLog.Type.Protocol, account, capabilities); if (capabilities.length() > 500) capabilities = capabilities.substring(0, 500) + "...";