Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1ebc487b authored by cketti's avatar cketti
Browse files

Don't use custom ServerSettings subclass in SettingsImporter

parent 97051f3f
Loading
Loading
Loading
Loading
+31 −37
Original line number Diff line number Diff line
@@ -368,7 +368,7 @@ public class SettingsImporter {
        }

        // Write incoming server settings (storeUri)
        ServerSettings incoming = new ImportedServerSettings(account.incoming);
        ServerSettings incoming = createServerSettings(account.incoming);
        BackendManager backendManager = DI.get(BackendManager.class);
        String storeUri = backendManager.createStoreUri(incoming);
        putString(editor, accountKeyPrefix + AccountPreferenceSerializer.STORE_URI_KEY, Base64.encode(storeUri));
@@ -387,7 +387,7 @@ public class SettingsImporter {
        boolean outgoingPasswordNeeded = false;
        if (account.outgoing != null) {
            // Write outgoing server settings (transportUri)
            ServerSettings outgoing = new ImportedServerSettings(account.outgoing);
            ServerSettings outgoing = createServerSettings(account.outgoing);
            String transportUri = backendManager.createTransportUri(outgoing);
            putString(editor, accountKeyPrefix + AccountPreferenceSerializer.TRANSPORT_URI_KEY, Base64.encode(transportUri));

@@ -1053,21 +1053,16 @@ public class SettingsImporter {
        return name;
    }

    private static class ImportedServerSettings extends ServerSettings {
        private final ImportedServer importedServer;

        public ImportedServerSettings(ImportedServer server) {
            super(ServerTypeConverter.toServerSettingsType(server.type), server.host, convertPort(server.port),
                    convertConnectionSecurity(server.connectionSecurity),
                    server.authenticationType, server.username, server.password,
                    server.clientCertificateAlias);
            importedServer = server;
        }

        @Override
        public Map<String, String> getExtra() {
            return (importedServer.extras != null) ?
    private static ServerSettings createServerSettings(ImportedServer importedServer) {
        String type = ServerTypeConverter.toServerSettingsType(importedServer.type);
        int port = convertPort(importedServer.port);
        ConnectionSecurity connectionSecurity = convertConnectionSecurity(importedServer.connectionSecurity);
        Map<String, String> extra = importedServer.extras != null ?
                Collections.unmodifiableMap(importedServer.extras.settings) : null;

        return new ServerSettings(type, importedServer.host, port, connectionSecurity,
                importedServer.authenticationType, importedServer.username, importedServer.password,
                importedServer.clientCertificateAlias, extra);
    }

    private static int convertPort(String port) {
@@ -1095,7 +1090,6 @@ public class SettingsImporter {
            return ConnectionSecurity.SSL_TLS_REQUIRED;
        }
    }
    }

    @VisibleForTesting
    static class Imported {
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ import java.util.Map;
/**
 * Generic container to hold server settings.
 */
public class ServerSettings {
public final class ServerSettings {
    /**
     * Name of the protocol these server settings belong to. Must be all lower case.
     */