IOS-1028 cleanup and comments IOS-1028
authorbuff <andreas@pep-project.org>
Sun, 19 Aug 2018 11:50:32 +0200
branchIOS-1028
changeset 59519f6b1633183a
parent 5950 fb31885bbfb1
IOS-1028 cleanup and comments
pEpForiOS.xcodeproj/project.pbxproj
pEpForiOS/Base.lproj/KeyImport.storyboard
pEpForiOS/UI/KeyImport/Wizard/AutoWizardStepsViewController.swift
pEpForiOS/UI/KeyImport/Wizard/ViewModel/AutoWizardStepsViewModel.swift
pEpForiOS/UI/KeyImport/Wizard/ViewModel/KeyImportWizardDelegate.swift
pEpForiOS/UI/Util/BaseTableViewController.swift
pEpForiOS/Util/KeyImport/KeyImportWizzard.swift
     1.1 --- a/pEpForiOS.xcodeproj/project.pbxproj	Sun Aug 19 10:38:45 2018 +0200
     1.2 +++ b/pEpForiOS.xcodeproj/project.pbxproj	Sun Aug 19 11:50:32 2018 +0200
     1.3 @@ -510,7 +510,6 @@
     1.4  		B78CF82B1E76E146008C1739 /* FilterCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B78CF82A1E76E146008C1739 /* FilterCellViewModel.swift */; };
     1.5  		B7D1EEC81E8BEC8D00F190E3 /* CollapsibleTableViewHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7D1EEC71E8BEC8D00F190E3 /* CollapsibleTableViewHeader.swift */; };
     1.6  		B7F19A001E5DE9FB0079A513 /* FolderType+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7F199FF1E5DE9FB0079A513 /* FolderType+Extensions.swift */; };
     1.7 -		C40EB0D120EFD3670009CF5F /* KeyImportWizardDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40EB0D020EFD3670009CF5F /* KeyImportWizardDelegate.swift */; };
     1.8  		C457845120AF4CE00053BF19 /* SettingsKeyImportSelectAccountTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C457845020AF4CE00053BF19 /* SettingsKeyImportSelectAccountTableViewController.swift */; };
     1.9  		C474D25A20B3FB9C0071F638 /* KeyImport.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C474D25820B3FB9C0071F638 /* KeyImport.storyboard */; };
    1.10  		C474D25F20B44A9E0071F638 /* AutoWizardStepsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C474D25E20B44A9E0071F638 /* AutoWizardStepsViewController.swift */; };
    1.11 @@ -1089,7 +1088,6 @@
    1.12  		B78CF82A1E76E146008C1739 /* FilterCellViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FilterCellViewModel.swift; path = Filter/ViewModel/FilterCellViewModel.swift; sourceTree = "<group>"; };
    1.13  		B7D1EEC71E8BEC8D00F190E3 /* CollapsibleTableViewHeader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CollapsibleTableViewHeader.swift; path = Folder/CollapsibleTableViewHeader.swift; sourceTree = "<group>"; };
    1.14  		B7F199FF1E5DE9FB0079A513 /* FolderType+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FolderType+Extensions.swift"; sourceTree = "<group>"; };
    1.15 -		C40EB0D020EFD3670009CF5F /* KeyImportWizardDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyImportWizardDelegate.swift; sourceTree = "<group>"; };
    1.16  		C457845020AF4CE00053BF19 /* SettingsKeyImportSelectAccountTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsKeyImportSelectAccountTableViewController.swift; sourceTree = "<group>"; };
    1.17  		C474D25920B3FB9C0071F638 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/KeyImport.storyboard; sourceTree = "<group>"; };
    1.18  		C474D25E20B44A9E0071F638 /* AutoWizardStepsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoWizardStepsViewController.swift; sourceTree = "<group>"; };
    1.19 @@ -2523,7 +2521,6 @@
    1.20  			isa = PBXGroup;
    1.21  			children = (
    1.22  				C483EBE220EB624300C319D1 /* AutoWizardStepsViewModel.swift */,
    1.23 -				C40EB0D020EFD3670009CF5F /* KeyImportWizardDelegate.swift */,
    1.24  			);
    1.25  			path = ViewModel;
    1.26  			sourceTree = "<group>";
    1.27 @@ -3187,7 +3184,6 @@
    1.28  				4351C2D91F4441190053381F /* render.c in Sources */,
    1.29  				B722EC4D1E5B01B300A2B9D5 /* FolderCellViewModel.swift in Sources */,
    1.30  				43E88BDE1EFA665600E0B224 /* AsyncStateMachineProtocol.swift in Sources */,
    1.31 -				C40EB0D120EFD3670009CF5F /* KeyImportWizardDelegate.swift in Sources */,
    1.32  				15874BCF2127493E00A3A4A6 /* AccountSettingsTableViewController.swift in Sources */,
    1.33  				43122B3E1DF5BB6600610253 /* MySelfOperation.swift in Sources */,
    1.34  				B71EBBBC1E55E4AE00150177 /* FolderTableViewController.swift in Sources */,
     2.1 --- a/pEpForiOS/Base.lproj/KeyImport.storyboard	Sun Aug 19 10:38:45 2018 +0200
     2.2 +++ b/pEpForiOS/Base.lproj/KeyImport.storyboard	Sun Aug 19 11:50:32 2018 +0200
     2.3 @@ -18,7 +18,7 @@
     2.4                          <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
     2.5                          <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
     2.6                          <subviews>
     2.7 -                            <activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" animating="YES" style="gray" translatesAutoresizingMaskIntoConstraints="NO" id="DY1-Kj-Os0">
     2.8 +                            <activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" animating="YES" style="gray" translatesAutoresizingMaskIntoConstraints="NO" id="DY1-Kj-Os0">
     2.9                                  <rect key="frame" x="177" y="160" width="20" height="20"/>
    2.10                              </activityIndicatorView>
    2.11                              <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="p7I-Vo-PmL">
     3.1 --- a/pEpForiOS/UI/KeyImport/Wizard/AutoWizardStepsViewController.swift	Sun Aug 19 10:38:45 2018 +0200
     3.2 +++ b/pEpForiOS/UI/KeyImport/Wizard/AutoWizardStepsViewController.swift	Sun Aug 19 11:50:32 2018 +0200
     3.3 @@ -45,7 +45,7 @@
     3.4          cancel.isHidden = false
     3.5          //showCurrentStep()
     3.6          stepDescription.isHidden = false
     3.7 -        loading.isHidden = false
     3.8 +        loading.stopAnimating()
     3.9  
    3.10  
    3.11      }
    3.12 @@ -56,27 +56,23 @@
    3.13      }
    3.14  
    3.15      private func updateState() {
    3.16 -        if let vm = viewModel {
    3.17 -            action.titleLabel?.text = vm.userAction
    3.18 -            stepDescription.text = vm.stepDescription
    3.19 -            stepDescription.isHidden = vm.isHiddingDescription
    3.20 -            loading.isHidden = vm.isWaiting
    3.21 +        guard let vm = viewModel else {
    3.22 +            Log.shared.errorAndCrash(component: #function, errorString: "No vm")
    3.23 +            return
    3.24          }
    3.25 +        action.titleLabel?.text = vm.userAction
    3.26 +        stepDescription.text = vm.stepDescription
    3.27 +        stepDescription.isHidden = vm.isHiddingDescription
    3.28 +        vm.isWaiting ? loading.stopAnimating() : loading.startAnimating() //IOS-1028 I think this is the wrong way around, I did not want to change the implementation though
    3.29      }
    3.30  }
    3.31  
    3.32 -extension AutoWizardStepsViewController: AutoWizardViewControllerDelegate {
    3.33 +extension AutoWizardStepsViewController: AutoWizardStepsViewModelDelegate {
    3.34      func showError(error: Error) {
    3.35 -
    3.36 +        fatalError("Unimplemented stub")
    3.37      }
    3.38  
    3.39      func notifyUpdate() {
    3.40          updateState()
    3.41      }
    3.42 -
    3.43 -
    3.44  }
    3.45 -public protocol AutoWizardViewControllerDelegate: class {
    3.46 -    func showError(error: Error)
    3.47 -    func notifyUpdate()
    3.48 -}
     4.1 --- a/pEpForiOS/UI/KeyImport/Wizard/ViewModel/AutoWizardStepsViewModel.swift	Sun Aug 19 10:38:45 2018 +0200
     4.2 +++ b/pEpForiOS/UI/KeyImport/Wizard/ViewModel/AutoWizardStepsViewModel.swift	Sun Aug 19 11:50:32 2018 +0200
     4.3 @@ -9,6 +9,10 @@
     4.4  import Foundation
     4.5  import MessageModel
     4.6  
     4.7 +public protocol AutoWizardStepsViewModelDelegate: class {
     4.8 +    func showError(error: Error)
     4.9 +    func notifyUpdate()
    4.10 +}
    4.11  
    4.12  class AutoWizardStepsViewModel {
    4.13      private let keyImportService: KeyImportServiceProtocol
    4.14 @@ -28,7 +32,7 @@
    4.15          }
    4.16      }
    4.17  
    4.18 -    weak var delegate: AutoWizardViewControllerDelegate?
    4.19 +    weak var delegate: AutoWizardStepsViewModelDelegate?
    4.20      
    4.21      init(keyImportService: KeyImportServiceProtocol, account: Account,
    4.22           keyImportWizzard: KeyImportWizzard) {
    4.23 @@ -54,9 +58,7 @@
    4.24  
    4.25          self.keyImportWizzard = keyImportWizzard
    4.26          keyImportWizzard.delegate = self
    4.27 -        self.notifyUpdate()
    4.28 -
    4.29 -
    4.30 +        self.notifyUpdate() //IOS-1028: should not be neccessarry
    4.31      }
    4.32  
    4.33      func start() {
    4.34 @@ -72,6 +74,7 @@
    4.35      }
    4.36  
    4.37      func cancel() {
    4.38 +        fatalError("Unimplemented stub")
    4.39          //TODO code when cancel is pressed.
    4.40      }
    4.41  }
    4.42 @@ -81,9 +84,9 @@
    4.43          fatalError("Not implemented yet")
    4.44      }
    4.45      func notifyUpdate() {
    4.46 -        self.userAction = keyImportWizzard.userAction
    4.47 -        self.stepDescription = keyImportWizzard.stepDescription
    4.48 -        self.isWaiting = keyImportWizzard.isWaiting
    4.49 +        userAction = keyImportWizzard.userAction
    4.50 +        stepDescription = keyImportWizzard.stepDescription
    4.51 +        isWaiting = keyImportWizzard.isWaiting
    4.52          keyImportWizzard.account = account
    4.53      }
    4.54  }
     5.1 --- a/pEpForiOS/UI/KeyImport/Wizard/ViewModel/KeyImportWizardDelegate.swift	Sun Aug 19 10:38:45 2018 +0200
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,16 +0,0 @@
     5.4 -//
     5.5 -//  KeyImportWizardDelegate.swift
     5.6 -//  pEp
     5.7 -//
     5.8 -//  Created by Hussein on 06/07/2018.
     5.9 -//  Copyright © 2018 p≡p Security S.A. All rights reserved.
    5.10 -//
    5.11 -
    5.12 -import Foundation
    5.13 -
    5.14 -public protocol KeyImportWizardDelegate: class {
    5.15 -
    5.16 -    func showError(error: Error)
    5.17 -    func notifyUpdate()
    5.18 -}
    5.19 -
     6.1 --- a/pEpForiOS/UI/Util/BaseTableViewController.swift	Sun Aug 19 10:38:45 2018 +0200
     6.2 +++ b/pEpForiOS/UI/Util/BaseTableViewController.swift	Sun Aug 19 11:50:32 2018 +0200
     6.3 @@ -51,7 +51,7 @@
     6.4  
     6.5          if keyimportWizard == nil {
     6.6              keyimportWizard = KeyImportWizzard(keyImportService: appConfig.keyImportService, starter: false)
     6.7 -            keyimportWizard?.startKeyImportDelegate = self
     6.8 +            keyimportWizard?.startKeyImportDelegate = self //IOS-1028: we want to do this everytime as far as I can see.
     6.9          }
    6.10      }
    6.11  
     7.1 --- a/pEpForiOS/Util/KeyImport/KeyImportWizzard.swift	Sun Aug 19 10:38:45 2018 +0200
     7.2 +++ b/pEpForiOS/Util/KeyImport/KeyImportWizzard.swift	Sun Aug 19 11:50:32 2018 +0200
     7.3 @@ -8,6 +8,14 @@
     7.4  
     7.5  import MessageModel
     7.6  
     7.7 +protocol StartKeyImportDelegate: class {
     7.8 +    func startKeyImport(account: Account);
     7.9 +}
    7.10 +
    7.11 +public protocol KeyImportWizardDelegate: class {
    7.12 +    func showError(error: Error)
    7.13 +    func notifyUpdate()
    7.14 +}
    7.15  
    7.16  class KeyImportWizzard {
    7.17      enum WizardState {
    7.18 @@ -24,8 +32,6 @@
    7.19      weak var delegate: KeyImportWizardDelegate?
    7.20      weak var startKeyImportDelegate: StartKeyImportDelegate?
    7.21  
    7.22 -    //??? We probably needs a KeyImportWizzardDelegate to inform the client (i.e. AutoWizardStepsViewModel)
    7.23 -
    7.24      init(keyImportService: KeyImportServiceProtocol, starter: Bool) {
    7.25          self.starter = starter
    7.26          self.keyImportService = keyImportService
    7.27 @@ -93,7 +99,6 @@
    7.28          state = WizardState.INIT;
    7.29          senderFpr = ""
    7.30      }
    7.31 -
    7.32  }
    7.33  
    7.34  // MARK: - KeyImportServiceDelegate
    7.35 @@ -114,7 +119,6 @@
    7.36  
    7.37      func receivedPrivateKey(forAccount account: Account) {
    7.38          finish()
    7.39 -        fatalError("Unimplemented stub")
    7.40      }
    7.41  
    7.42      func errorOccurred(error: Error) {
    7.43 @@ -122,12 +126,6 @@
    7.44          //TODO: ask user to try later due to an error.
    7.45          //SMTP Error && Engine Error
    7.46          finish()
    7.47 -        fatalError("unimplemented stub")
    7.48      }
    7.49 -
    7.50  }
    7.51  
    7.52 -protocol StartKeyImportDelegate: class {
    7.53 -    func startKeyImport(account: Account);
    7.54 -}
    7.55 -