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

Commit be7ee18f authored by Michael Enoma's avatar Michael Enoma 👽
Browse files

EElo Account

parent baabc140
Loading
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ import com.fsck.k9.autodiscovery.api.DiscoveryResults;
import com.fsck.k9.autodiscovery.api.DiscoveryTarget;
import com.fsck.k9.autodiscovery.providersxml.ProvidersXmlDiscovery;
import com.fsck.k9.mail.ServerSettings;
import com.fsck.k9.mailstore.SpecialLocalFoldersCreator;
import com.fsck.k9.ui.ConnectionSettings;
import timber.log.Timber;

@@ -21,11 +22,13 @@ import timber.log.Timber;
public class EeloAccountCreator {
    private static final ProvidersXmlDiscovery providersXmlDiscovery = DI.get(ProvidersXmlDiscovery.class);
    private static final AccountCreator accountCreator = DI.get(AccountCreator.class);
    private static final SpecialLocalFoldersCreator localFoldersCreator = DI.get(SpecialLocalFoldersCreator.class);

    public static void createAccount(Context context, String emailId, String password) {
        Preferences preferences = Preferences.getPreferences(context);

        Account account = preferences.newAccount();
        account.setChipColor(accountCreator.pickColor());
        account.setEmail(emailId);
        account.setDescription(emailId);

@@ -34,20 +37,22 @@ public class EeloAccountCreator {
            Timber.e("Error while trying to initialise account configuration.");
            return;
        }
        ServerSettings incomingSettings = connectionSettings.getIncoming();
        incomingSettings.newPassword(password);
        ServerSettings outgoingSettings = connectionSettings.getOutgoing();
        outgoingSettings.newPassword(password);
        ServerSettings incomingSettings = connectionSettings.getIncoming().newPassword(password);
        account.setIncomingServerSettings(incomingSettings);
        ServerSettings outgoingSettings = connectionSettings.getOutgoing().newPassword(password);
        account.setOutgoingServerSettings(outgoingSettings);

        DeletePolicy deletePolicy = accountCreator.getDefaultDeletePolicy(incomingSettings.type);
        account.setDeletePolicy(deletePolicy);

        localFoldersCreator.createSpecialLocalFolders(account);
        account.markSetupFinished();

        preferences.saveAccount(account);
        Core.setServicesEnabled(context);
    }


    private static ConnectionSettings providersXmlDiscoveryDiscover(String email) {
        DiscoveryResults discoveryResults =
                providersXmlDiscovery.discover(email, DiscoveryTarget.INCOMING_AND_OUTGOING);