Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions FlowCrypt.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@
D2891AC224C59EFA008918E3 /* KeyService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2891AC124C59EFA008918E3 /* KeyService.swift */; };
D2891AC424C62446008918E3 /* ErrorHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2891AC324C62446008918E3 /* ErrorHandler.swift */; };
D28A1CBD2525C141003B760B /* CheckBoxTextNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A1CBC2525C141003B760B /* CheckBoxTextNode.swift */; };
D297990D2444A76D004A3E31 /* UserObject+Empty.swift in Sources */ = {isa = PBXBuildFile; fileRef = D297990C2444A76D004A3E31 /* UserObject+Empty.swift */; };
D29AFFF6240939AE00C1387D /* Then.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FD22A1B230FE7D0005067A6 /* Then.swift */; };
D29AFFF92409767F00C1387D /* GoogleContactsResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29AFFF82409767F00C1387D /* GoogleContactsResponse.swift */; };
D29AFFFE240990BE00C1387D /* Throttler.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29AFFFD240990BE00C1387D /* Throttler.swift */; };
Expand Down Expand Up @@ -303,8 +302,8 @@
D2F6D147243506DA00DB4065 /* MailSettingsCredentials.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2F6D146243506DA00DB4065 /* MailSettingsCredentials.swift */; };
D2FC1C0624D82C9F003B949D /* ContactsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FC1C0524D82C9F003B949D /* ContactsService.swift */; };
D2FD0F692453245E00259FF0 /* Either.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FD0F682453245E00259FF0 /* Either.swift */; };
D2FF6966243115EC007182F0 /* EmailProviderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FF6965243115EC007182F0 /* EmailProviderViewController.swift */; };
D2FF6968243115F9007182F0 /* EmailProviderViewDecorator.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FF6967243115F9007182F0 /* EmailProviderViewDecorator.swift */; };
D2FF6966243115EC007182F0 /* SetupImapViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FF6965243115EC007182F0 /* SetupImapViewController.swift */; };
D2FF6968243115F9007182F0 /* SetupImapViewDecorator.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FF6967243115F9007182F0 /* SetupImapViewDecorator.swift */; };
D952B71D1ED0CB2500E5C02B /* MessageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D952B71C1ED0CB2500E5C02B /* MessageViewController.swift */; };
E29491346F23FA1463A07459 /* Pods_FlowCryptAppTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 990E5AB8A4A7F69E1C113365 /* Pods_FlowCryptAppTests.framework */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -647,7 +646,6 @@
D2891AC124C59EFA008918E3 /* KeyService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyService.swift; sourceTree = "<group>"; };
D2891AC324C62446008918E3 /* ErrorHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ErrorHandler.swift; sourceTree = "<group>"; };
D28A1CBC2525C141003B760B /* CheckBoxTextNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckBoxTextNode.swift; sourceTree = "<group>"; };
D297990C2444A76D004A3E31 /* UserObject+Empty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserObject+Empty.swift"; sourceTree = "<group>"; };
D29AFFF82409767F00C1387D /* GoogleContactsResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoogleContactsResponse.swift; sourceTree = "<group>"; };
D29AFFFD240990BE00C1387D /* Throttler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Throttler.swift; sourceTree = "<group>"; };
D2A1D3B723FD64AB00D626D6 /* FlowCryptUIApplication.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FlowCryptUIApplication.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -682,8 +680,8 @@
D2F6D146243506DA00DB4065 /* MailSettingsCredentials.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MailSettingsCredentials.swift; sourceTree = "<group>"; };
D2FC1C0524D82C9F003B949D /* ContactsService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactsService.swift; sourceTree = "<group>"; };
D2FD0F682453245E00259FF0 /* Either.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Either.swift; sourceTree = "<group>"; };
D2FF6965243115EC007182F0 /* EmailProviderViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmailProviderViewController.swift; sourceTree = "<group>"; };
D2FF6967243115F9007182F0 /* EmailProviderViewDecorator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmailProviderViewDecorator.swift; sourceTree = "<group>"; };
D2FF6965243115EC007182F0 /* SetupImapViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetupImapViewController.swift; sourceTree = "<group>"; };
D2FF6967243115F9007182F0 /* SetupImapViewDecorator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetupImapViewDecorator.swift; sourceTree = "<group>"; };
D952B71C1ED0CB2500E5C02B /* MessageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageViewController.swift; sourceTree = "<group>"; };
DFA70003EC75596718303F14 /* Pods-FlowCryptUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FlowCryptUITests.debug.xcconfig"; path = "Target Support Files/Pods-FlowCryptUITests/Pods-FlowCryptUITests.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -1473,7 +1471,7 @@
isa = PBXGroup;
children = (
04B472911ECE29F600B8266F /* SideMenu */,
D2FF6969243115FE007182F0 /* SignIn Other */,
D2FF6969243115FE007182F0 /* SetupImap */,
32DCA8D5AF0A43354CC7F58B /* SignIn */,
C192421D1EC48B5600C3D251 /* Setup */,
D29AFFF12409301300C1387D /* Bootstrap */,
Expand Down Expand Up @@ -1812,14 +1810,13 @@
path = "Mail Sessions Providers";
sourceTree = "<group>";
};
D2FF6969243115FE007182F0 /* SignIn Other */ = {
D2FF6969243115FE007182F0 /* SetupImap */ = {
isa = PBXGroup;
children = (
D2FF6965243115EC007182F0 /* EmailProviderViewController.swift */,
D2FF6967243115F9007182F0 /* EmailProviderViewDecorator.swift */,
D297990C2444A76D004A3E31 /* UserObject+Empty.swift */,
D2FF6965243115EC007182F0 /* SetupImapViewController.swift */,
D2FF6967243115F9007182F0 /* SetupImapViewDecorator.swift */,
);
path = "SignIn Other";
path = SetupImap;
sourceTree = "<group>";
};
D952B71B1ED0CB0100E5C02B /* Msg */ = {
Expand Down Expand Up @@ -2481,7 +2478,7 @@
9F53CB7B2555E1E300C0157A /* GmailService+folders.swift in Sources */,
9F79228826696B0200DA3D80 /* PassPhraseService.swift in Sources */,
D2E26F6624F169B400612AF1 /* ContactsListDecorator.swift in Sources */,
D2FF6968243115F9007182F0 /* EmailProviderViewDecorator.swift in Sources */,
D2FF6968243115F9007182F0 /* SetupImapViewDecorator.swift in Sources */,
9F589F0D238C7A9B007FD759 /* LocalStorage.swift in Sources */,
D2FC1C0624D82C9F003B949D /* ContactsService.swift in Sources */,
9FD364862381EFCB00657302 /* SetupManuallyEnterPassPhraseViewController.swift in Sources */,
Expand Down Expand Up @@ -2528,9 +2525,8 @@
D211CE7623FC36BC00D1CE38 /* UIColorExtension.swift in Sources */,
9FC7EBAA266EBD3700F3BF5D /* InMemoryPassPhraseStorage.swift in Sources */,
9FA9C83C264C2D75005A9670 /* MessageService.swift in Sources */,
D2FF6966243115EC007182F0 /* EmailProviderViewController.swift in Sources */,
D2FF6966243115EC007182F0 /* SetupImapViewController.swift in Sources */,
D2CDC3D22402D4DA002B045F /* UIViewControllerExtensions.swift in Sources */,
D297990D2444A76D004A3E31 /* UserObject+Empty.swift in Sources */,
21C7DF0B266C0E3600C44800 /* Configuration.swift in Sources */,
D2D27B79248A8694007346FA /* BigIntExtension.swift in Sources */,
9F003D6D25EA8F3200EB38C0 /* UserAccountService.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// EmailProviderViewController.swift
// SetupImapViewController.swift
// FlowCrypt
//
// Created by Anton Kharchevskyi on 29/03/2020.
Expand All @@ -15,7 +15,7 @@ import Promises
* - User redirects here from SignInViewController
* - After successful connection user will be redirected to *setup flow* which would typically means *SetupInitialViewController*
*/
final class EmailProviderViewController: TableNodeViewController {
final class SetupImapViewController: TableNodeViewController {
private enum UserError: Error {
case password
case empty
Expand All @@ -28,15 +28,15 @@ final class EmailProviderViewController: TableNodeViewController {
private let dataService: DataServiceType
private let globalRouter: GlobalRouterType

private let decorator: EmailProviderViewDecoratorType
private let decorator: SetupImapViewDecorator
private let sessionCredentials: SessionCredentialsProvider
private let imap: Imap
private var user = UserObject.empty

init(
globalRouter: GlobalRouterType = GlobalRouter(),
dataService: DataServiceType = DataService.shared,
decorator: EmailProviderViewDecoratorType = EmailProviderViewDecorator(),
decorator: SetupImapViewDecorator = SetupImapViewDecorator(),
sessionCredentials: SessionCredentialsProvider = SessionCredentialsService(),
imap: Imap = Imap.shared
) {
Expand Down Expand Up @@ -67,7 +67,7 @@ final class EmailProviderViewController: TableNodeViewController {
}

// MARK: - Parts
extension EmailProviderViewController {
extension SetupImapViewController {
enum Section {
case account(AccountPart)
case imap(ServerPart)
Expand Down Expand Up @@ -156,7 +156,7 @@ extension EmailProviderViewController {
}

// MARK: - Setup
extension EmailProviderViewController {
extension SetupImapViewController {
private func setupUI() {
title = "Email Provider"
observeKeyboardNotifications()
Expand Down Expand Up @@ -202,7 +202,7 @@ extension EmailProviderViewController {
}

// MARK: - ASTableDelegate, ASTableDataSource
extension EmailProviderViewController: ASTableDelegate, ASTableDataSource {
extension SetupImapViewController: ASTableDelegate, ASTableDataSource {
func numberOfSections(in tableNode: ASTableNode) -> Int {
Section.numberOfSections
}
Expand All @@ -227,7 +227,7 @@ extension EmailProviderViewController: ASTableDelegate, ASTableDataSource {
}

// MARK: - Nodes
extension EmailProviderViewController {
extension SetupImapViewController {
private func titleNode(for indexPath: IndexPath) -> ASCellNode {
guard let section = Section(indexPath: indexPath) else {
assertionFailure()
Expand Down Expand Up @@ -277,7 +277,7 @@ extension EmailProviderViewController {
}

// MARK: - Helpers
extension EmailProviderViewController {
extension SetupImapViewController {
private var connections: [ConnectionType] {
ConnectionType.allCases
}
Expand Down Expand Up @@ -310,7 +310,7 @@ extension EmailProviderViewController {
}

// MARK: - Actions
extension EmailProviderViewController {
extension SetupImapViewController {
private func handleTextField(_ action: TextFieldActionType, for indexPath: IndexPath) {
guard let section = Section(indexPath: indexPath) else { return }
selectedSection = section
Expand Down Expand Up @@ -461,7 +461,7 @@ extension EmailProviderViewController {
}

// MARK: - Connect
extension EmailProviderViewController {
extension SetupImapViewController {
private func connect() {
let result = checkCurrentUser()
switch result {
Expand Down Expand Up @@ -523,7 +523,7 @@ extension EmailProviderViewController {
}

// MARK: - Picker
extension EmailProviderViewController: UIPickerViewDelegate, UIPickerViewDataSource {
extension SetupImapViewController: UIPickerViewDelegate, UIPickerViewDataSource {
func numberOfComponents(in pickerView: UIPickerView) -> Int {
1
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// EmailProviderViewDecorator.swift
// SetupImapViewDecorator.swift
// FlowCrypt
//
// Created by Anton Kharchevskyi on 29/03/2020.
Expand All @@ -9,22 +9,7 @@
import FlowCryptUI
import UIKit

protocol EmailProviderViewDecoratorType {
var connectButtonTitle: NSAttributedString { get }
var connectButtonInsets: UIEdgeInsets { get }
func title(for section: EmailProviderViewController.Section) -> InfoCellNode.Input
func textFieldInput(for section: EmailProviderViewController.Section) -> TextFieldCellNode.Input?
func stringFor(user: UserObject, for section: EmailProviderViewController.Section) -> NSAttributedString?
func switchInput(isOn: Bool) -> SwitchCellNode.Input
func shouldAddToolBar(for section: EmailProviderViewController.Section) -> Bool
func pickerView(
for: EmailProviderViewController.Section,
delegate: UIPickerViewDelegate,
dataSource: UIPickerViewDataSource
) -> UIPickerView?
}

struct EmailProviderViewDecorator: EmailProviderViewDecoratorType {
struct SetupImapViewDecorator {
var connectButtonTitle: NSAttributedString {
"other_provider_connect"
.localized
Expand All @@ -47,7 +32,7 @@ struct EmailProviderViewDecorator: EmailProviderViewDecoratorType {
)
}

func title(for section: EmailProviderViewController.Section) -> InfoCellNode.Input {
func title(for section: SetupImapViewController.Section) -> InfoCellNode.Input {
let title: String = {
switch section {
case .account(.title): return "other_provider_account_title"
Expand Down Expand Up @@ -78,8 +63,8 @@ struct EmailProviderViewDecorator: EmailProviderViewDecoratorType {
)
}

// swiftlint:disable cyclomatic_complexity
func textFieldInput(for section: EmailProviderViewController.Section) -> TextFieldCellNode.Input? {
// swiftlint:disable cyclomatic_complexity function_body_length
func textFieldInput(for section: SetupImapViewController.Section) -> TextFieldCellNode.Input? {
let placeholder: String?
var isSecure = false
var keyboardType: UIKeyboardType = .default
Expand Down Expand Up @@ -150,7 +135,7 @@ struct EmailProviderViewDecorator: EmailProviderViewDecoratorType {
)
}

func stringFor(user: UserObject, for section: EmailProviderViewController.Section) -> NSAttributedString? {
func stringFor(user: UserObject, for section: SetupImapViewController.Section) -> NSAttributedString? {
switch section {
case let .account(part):
switch part {
Expand Down Expand Up @@ -209,7 +194,7 @@ struct EmailProviderViewDecorator: EmailProviderViewDecoratorType {
}

func pickerView(
for section: EmailProviderViewController.Section,
for section: SetupImapViewController.Section,
delegate: UIPickerViewDelegate,
dataSource: UIPickerViewDataSource
) -> UIPickerView? {
Expand All @@ -224,7 +209,7 @@ struct EmailProviderViewDecorator: EmailProviderViewDecoratorType {
}
}

func shouldAddToolBar(for section: EmailProviderViewController.Section) -> Bool {
func shouldAddToolBar(for section: SetupImapViewController.Section) -> Bool {
switch section {
case .imap(.security),
.smtp(.security),
Expand Down
34 changes: 0 additions & 34 deletions FlowCrypt/Controllers/SignIn Other/UserObject+Empty.swift

This file was deleted.

4 changes: 2 additions & 2 deletions FlowCrypt/Controllers/SignIn/SignInViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import FlowCryptUI
* - User can sign in with:
* - Gmail
* - Outlook (not implemented yet)
* - Other email provider (*EmailProviderViewController*)
* - Other email provider (*SetupImapViewController*)
* - User can also check privacy, terms and security links via *WebViewController*
*/
final class SignInViewController: TableNodeViewController {
Expand Down Expand Up @@ -154,7 +154,7 @@ extension SignInViewController {
}

private func proceedToOtherProvider() {
let setupViewController = EmailProviderViewController()
let setupViewController = SetupImapViewController()
navigationController?.pushViewController(setupViewController, animated: true)
}

Expand Down
14 changes: 14 additions & 0 deletions FlowCrypt/Models/Realm Models/SessionObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,17 @@ extension SessionObject {
)
}
}

extension SessionObject {
static var empty: SessionObject {
SessionObject(
hostname: "",
port: 0,
username: "",
password: nil,
oAuth2Token: nil,
connectionType: "",
email: ""
)
}
}
11 changes: 11 additions & 0 deletions FlowCrypt/Models/Realm Models/UserObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,14 @@ extension User {
self.isActive = userObject.isActive
}
}

extension UserObject {
static var empty: UserObject {
UserObject(
name: "",
email: "",
imap: .empty,
smtp: .empty
)
}
}