Skip to content

Commit

Permalink
Remove WebDAV code
Browse files Browse the repository at this point in the history
  • Loading branch information
cketti committed May 4, 2023
1 parent 6678c5a commit ff188cd
Show file tree
Hide file tree
Showing 93 changed files with 19 additions and 4,752 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ package com.fsck.k9.preferences
object Protocols {
const val IMAP = "imap"
const val POP3 = "pop3"
const val WEBDAV = "webdav"
const val SMTP = "smtp"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ object ServerTypeConverter {
fun fromServerSettingsType(serverSettingsType: String): String = when (serverSettingsType) {
Protocols.IMAP -> "IMAP"
Protocols.POP3 -> "POP3"
Protocols.WEBDAV -> "WebDAV"
Protocols.SMTP -> "SMTP"
else -> throw AssertionError("Unsupported type: $serverSettingsType")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,37 +379,30 @@ private static AccountDescriptionPair importAccount(Context context, StorageEdit

boolean authorizationNeeded = incoming.authenticationType == AuthType.XOAUTH2;

String incomingServerType = ServerTypeConverter.toServerSettingsType(account.incoming.type);
if (account.outgoing == null && !incomingServerType.equals(Protocols.WEBDAV)) {
// All account types except WebDAV need to provide outgoing server settings
if (account.outgoing == null) {
throw new InvalidSettingValueException();
}

String outgoingServerName = null;
boolean outgoingPasswordNeeded = false;
if (account.outgoing != null) {
// Write outgoing server settings
ServerSettings outgoing = createServerSettings(account.outgoing);
String outgoingServer = serverSettingsSerializer.serialize(outgoing);
putString(editor, accountKeyPrefix + AccountPreferenceSerializer.OUTGOING_SERVER_SETTINGS_KEY, outgoingServer);

/*
* Mark account as disabled if the settings file contained a username but no password. However, no password
* is required for the outgoing server for WebDAV accounts, because incoming and outgoing servers are
* identical for this account type. Nor is a password required if the AuthType is EXTERNAL.
*/
String outgoingServerType = ServerTypeConverter.toServerSettingsType(outgoing.type);
outgoingPasswordNeeded = AuthType.EXTERNAL != outgoing.authenticationType &&
AuthType.XOAUTH2 != outgoing.authenticationType &&
!outgoingServerType.equals(Protocols.WEBDAV) &&
outgoing.username != null &&
!outgoing.username.isEmpty() &&
(outgoing.password == null || outgoing.password.isEmpty());
// Write outgoing server settings
ServerSettings outgoing = createServerSettings(account.outgoing);
String outgoingServer = serverSettingsSerializer.serialize(outgoing);
putString(editor, accountKeyPrefix + AccountPreferenceSerializer.OUTGOING_SERVER_SETTINGS_KEY, outgoingServer);

/*
* Mark account as disabled if the settings file contained a username but no password, except when the
* AuthType is EXTERNAL.
*/
outgoingPasswordNeeded = AuthType.EXTERNAL != outgoing.authenticationType &&
AuthType.XOAUTH2 != outgoing.authenticationType &&
outgoing.username != null &&
!outgoing.username.isEmpty() &&
(outgoing.password == null || outgoing.password.isEmpty());

authorizationNeeded |= outgoing.authenticationType == AuthType.XOAUTH2;
authorizationNeeded |= outgoing.authenticationType == AuthType.XOAUTH2;

outgoingServerName = outgoing.host;
}
outgoingServerName = outgoing.host;

boolean createAccountDisabled = incomingPasswordNeeded || outgoingPasswordNeeded || authorizationNeeded;
if (createAccountDisabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class ServerNameSuggester {
fun suggestServerName(serverType: String, domainPart: String): String = when (serverType) {
Protocols.IMAP -> "imap.$domainPart"
Protocols.SMTP -> "smtp.$domainPart"
Protocols.WEBDAV -> "exchange.$domainPart"
Protocols.POP3 -> "pop3.$domainPart"
else -> throw AssertionError("Missed case: $serverType")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ public void suggestServerName_forPop3Server() throws Exception {
assertEquals("pop3.example.org", result);
}

@Test
public void suggestServerName_forWebDavServer() throws Exception {
String serverType = Protocols.WEBDAV;
String domainPart = "example.org";

String result = serverNameSuggester.suggestServerName(serverType, domainPart);

assertEquals("exchange.example.org", result);
}

@Test
public void suggestServerName_forSmtpServer() throws Exception {
String serverType = Protocols.SMTP;
Expand Down
1 change: 0 additions & 1 deletion app/k9mail/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dependencies {
implementation(projects.app.cryptoOpenpgp)
implementation(projects.backend.imap)
implementation(projects.backend.pop3)
implementation(projects.backend.webdav)
debugImplementation(projects.backend.demo)

implementation(libs.androidx.appcompat)
Expand Down
16 changes: 0 additions & 16 deletions app/k9mail/src/main/java/com/fsck/k9/backends/KoinModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import app.k9mail.dev.developmentModuleAdditions
import com.fsck.k9.backend.BackendManager
import com.fsck.k9.backend.imap.BackendIdleRefreshManager
import com.fsck.k9.backend.imap.SystemAlarmManager
import com.fsck.k9.helper.DefaultTrustedSocketFactory
import com.fsck.k9.mail.store.imap.IdleRefreshManager
import com.fsck.k9.mail.store.webdav.SniHostSetter
import org.koin.dsl.module

val backendsModule = module {
Expand All @@ -16,7 +14,6 @@ val backendsModule = module {
mapOf(
"imap" to get<ImapBackendFactory>(),
"pop3" to get<Pop3BackendFactory>(),
"webdav" to get<WebDavBackendFactory>(),
) + developmentBackends(),
)
}
Expand All @@ -33,19 +30,6 @@ val backendsModule = module {
single<SystemAlarmManager> { AndroidAlarmManager(context = get(), alarmManager = get()) }
single<IdleRefreshManager> { BackendIdleRefreshManager(alarmManager = get()) }
single { Pop3BackendFactory(get(), get()) }
single {
WebDavBackendFactory(
backendStorageFactory = get(),
trustManagerFactory = get(),
sniHostSetter = get(),
folderRepository = get(),
)
}
single {
SniHostSetter { factory, socket, hostname ->
DefaultTrustedSocketFactory.setSniHost(factory, socket, hostname)
}
}

developmentModuleAdditions()
}

This file was deleted.

1 change: 0 additions & 1 deletion app/ui/legacy/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ dependencies {

// Remove AccountSetupIncoming's dependency on these
compileOnly(projects.mail.protocols.imap)
compileOnly(projects.mail.protocols.webdav)

implementation(projects.plugins.openpgpApiLib.openpgpApi)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class AccountCreator(private val preferences: Preferences, private val resources
return when (type) {
Protocols.IMAP -> DeletePolicy.ON_DELETE
Protocols.POP3 -> DeletePolicy.NEVER
Protocols.WEBDAV -> DeletePolicy.ON_DELETE
"demo" -> DeletePolicy.ON_DELETE
else -> throw AssertionError("Unhandled case: $type")
}
Expand All @@ -27,7 +26,6 @@ class AccountCreator(private val preferences: Preferences, private val resources
fun getDefaultPort(securityType: ConnectionSecurity, serverType: String): Int {
return when (serverType) {
Protocols.IMAP -> getImapDefaultPort(securityType)
Protocols.WEBDAV -> getWebDavDefaultPort(securityType)
Protocols.POP3 -> getPop3DefaultPort(securityType)
Protocols.SMTP -> getSmtpDefaultPort(securityType)
else -> throw AssertionError("Unhandled case: $serverType")
Expand All @@ -42,10 +40,6 @@ class AccountCreator(private val preferences: Preferences, private val resources
return if (connectionSecurity == ConnectionSecurity.SSL_TLS_REQUIRED) 995 else 110
}

private fun getWebDavDefaultPort(connectionSecurity: ConnectionSecurity): Int {
return if (connectionSecurity == ConnectionSecurity.SSL_TLS_REQUIRED) 443 else 80
}

private fun getSmtpDefaultPort(connectionSecurity: ConnectionSecurity): Int {
return if (connectionSecurity == ConnectionSecurity.SSL_TLS_REQUIRED) 465 else 587
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import com.fsck.k9.mail.AuthenticationFailedException
import com.fsck.k9.mail.CertificateValidationException
import com.fsck.k9.mail.MailServerDirection
import com.fsck.k9.mail.filter.Hex
import com.fsck.k9.preferences.Protocols
import com.fsck.k9.ui.R
import com.fsck.k9.ui.base.K9Activity
import com.fsck.k9.ui.observe
Expand Down Expand Up @@ -448,26 +447,16 @@ class AccountSetupCheckSettings : K9Activity(), ConfirmationDialogFragmentListen
}

private fun checkOutgoing() {
if (!isWebDavAccount) {
publishProgress(R.string.account_setup_check_settings_check_outgoing_msg)
}
publishProgress(R.string.account_setup_check_settings_check_outgoing_msg)

messagingController.checkOutgoingServerSettings(account)
}

private fun checkIncoming() {
if (isWebDavAccount) {
publishProgress(R.string.account_setup_check_settings_authenticate)
} else {
publishProgress(R.string.account_setup_check_settings_check_incoming_msg)
}
publishProgress(R.string.account_setup_check_settings_check_incoming_msg)

messagingController.checkIncomingServerSettings(account)

if (isWebDavAccount) {
publishProgress(R.string.account_setup_check_settings_fetch)
}

messagingController.refreshFolderListSynchronous(account)

val inboxFolderId = account.inboxFolderId
Expand All @@ -476,9 +465,6 @@ class AccountSetupCheckSettings : K9Activity(), ConfirmationDialogFragmentListen
}
}

private val isWebDavAccount: Boolean
get() = account.incomingServerSettings.type == Protocols.WEBDAV

override fun onProgressUpdate(vararg values: Int?) {
setMessage(values[0]!!)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import com.fsck.k9.mail.MailServerDirection;
import com.fsck.k9.mail.ServerSettings;
import com.fsck.k9.mail.store.imap.ImapStoreSettings;
import com.fsck.k9.mail.store.webdav.WebDavStoreSettings;
import com.fsck.k9.preferences.Protocols;
import com.fsck.k9.ui.R;
import com.fsck.k9.ui.base.extensions.TextInputLayoutHelper;
Expand Down Expand Up @@ -78,9 +77,6 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
private int mCurrentAuthTypeViewPosition;
private CheckBox mImapAutoDetectNamespaceView;
private TextInputEditText mImapPathPrefixView;
private TextInputEditText mWebdavPathPrefixView;
private TextInputEditText mWebdavAuthPathView;
private TextInputEditText mWebdavMailboxPathView;
private ViewGroup mAllowClientCertificateView;
private Button mNextButton;
private Account mAccount;
Expand Down Expand Up @@ -130,9 +126,6 @@ public void onCreate(Bundle savedInstanceState) {
mAuthTypeView = findViewById(R.id.account_auth_type);
mImapAutoDetectNamespaceView = findViewById(R.id.imap_autodetect_namespace);
mImapPathPrefixView = findViewById(R.id.imap_path_prefix);
mWebdavPathPrefixView = findViewById(R.id.webdav_path_prefix);
mWebdavAuthPathView = findViewById(R.id.webdav_auth_path);
mWebdavMailboxPathView = findViewById(R.id.webdav_mailbox_path);
mNextButton = findViewById(R.id.next);
useCompressionCheckBox = findViewById(R.id.use_compression);
isSendClientIdEnabledCheckBox = findViewById(R.id.is_send_client_id_enabled);
Expand Down Expand Up @@ -210,10 +203,6 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (settings.type.equals(Protocols.POP3)) {
serverLayoutView.setHint(getString(R.string.account_setup_incoming_pop_server_label));
findViewById(R.id.imap_path_prefix_section).setVisibility(View.GONE);
findViewById(R.id.webdav_advanced_header).setVisibility(View.GONE);
findViewById(R.id.webdav_mailbox_alias_section).setVisibility(View.GONE);
findViewById(R.id.webdav_owa_path_section).setVisibility(View.GONE);
findViewById(R.id.webdav_auth_path_section).setVisibility(View.GONE);
useCompressionCheckBox.setVisibility(View.GONE);
isSendClientIdEnabledCheckBox.setVisibility(View.GONE);
mSubscribedFoldersOnly.setVisibility(View.GONE);
Expand All @@ -228,42 +217,9 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mImapPathPrefixView.setText(pathPrefix);
}

findViewById(R.id.webdav_advanced_header).setVisibility(View.GONE);
findViewById(R.id.webdav_mailbox_alias_section).setVisibility(View.GONE);
findViewById(R.id.webdav_owa_path_section).setVisibility(View.GONE);
findViewById(R.id.webdav_auth_path_section).setVisibility(View.GONE);

if (!editSettings) {
findViewById(R.id.imap_folder_setup_section).setVisibility(View.GONE);
}
} else if (settings.type.equals(Protocols.WEBDAV)) {
serverLayoutView.setHint(getString(R.string.account_setup_incoming_webdav_server_label));
mConnectionSecurityChoices = new ConnectionSecurity[] {
ConnectionSecurity.NONE,
ConnectionSecurity.SSL_TLS_REQUIRED };

// Hide the unnecessary fields
findViewById(R.id.imap_path_prefix_section).setVisibility(View.GONE);
findViewById(R.id.account_auth_type_label).setVisibility(View.GONE);
findViewById(R.id.account_auth_type).setVisibility(View.GONE);
useCompressionCheckBox.setVisibility(View.GONE);
isSendClientIdEnabledCheckBox.setVisibility(View.GONE);
mSubscribedFoldersOnly.setVisibility(View.GONE);

String path = WebDavStoreSettings.getPath(settings);
if (path != null) {
mWebdavPathPrefixView.setText(path);
}

String authPath = WebDavStoreSettings.getAuthPath(settings);
if (authPath != null) {
mWebdavAuthPathView.setText(authPath);
}

String mailboxPath = WebDavStoreSettings.getMailboxPath(settings);
if (mailboxPath != null) {
mWebdavMailboxPathView.setText(mailboxPath);
}
} else {
throw new Exception("Unknown account type: " + settings.type);
}
Expand Down Expand Up @@ -614,11 +570,6 @@ protected void onNext() {
boolean autoDetectNamespace = mImapAutoDetectNamespaceView.isChecked();
String pathPrefix = mImapPathPrefixView.getText().toString();
extra = ImapStoreSettings.createExtra(autoDetectNamespace, pathPrefix);
} else if (mStoreType.equals(Protocols.WEBDAV)) {
String path = mWebdavPathPrefixView.getText().toString();
String authPath = mWebdavAuthPathView.getText().toString();
String mailboxPath = mWebdavMailboxPathView.getText().toString();
extra = WebDavStoreSettings.createExtra(null, path, authPath, mailboxPath);
}

DI.get(LocalKeyStoreManager.class).deleteCertificate(mAccount, host, port, MailServerDirection.INCOMING);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,6 @@ public void onCreate(Bundle savedInstanceState) {
mAccount = Preferences.getPreferences().getAccount(accountUuid);

ServerSettings incomingServerSettings = mAccount.getIncomingServerSettings();
if (incomingServerSettings.type.equals(Protocols.WEBDAV)) {
mAccount.setOutgoingServerSettings(incomingServerSettings);
AccountSetupCheckSettings.actionCheckSettings(this, mAccount, CheckDirection.OUTGOING);
}


mUsernameView = findViewById(R.id.account_username);
mPasswordView = findViewById(R.id.account_password);
Expand Down
Loading

0 comments on commit ff188cd

Please sign in to comment.