IOS-83 trustwords segues wired
authorDirk Zimmermann <dirk@pep-project.org>
Thu, 16 Feb 2017 18:48:12 +0100
changeset 1724004282d9bf61
parent 1723 ef459fa4ae98
child 1725 2ef8f9937e40
IOS-83 trustwords segues wired
pEpForiOS/Base.lproj/Main.storyboard
pEpForiOS/UI/EmailDisplay/EmailListViewController.swift
pEpForiOS/UI/Handshake/FingerprintTableViewController.swift
pEpForiOS/UI/Handshake/TrustwordsTableViewController.swift
     1.1 --- a/pEpForiOS/Base.lproj/Main.storyboard	Thu Feb 16 14:35:56 2017 +0100
     1.2 +++ b/pEpForiOS/Base.lproj/Main.storyboard	Thu Feb 16 18:48:12 2017 +0100
     1.3 @@ -2447,9 +2447,12 @@
     1.4                          <outlet property="trustwordsLabel" destination="Zfz-MF-3Y8" id="uDU-Fz-NxY"/>
     1.5                          <outlet property="trustwordsLanaguageLabel" destination="mUu-Az-xb3" id="xEW-fh-3t1"/>
     1.6                          <segue destination="JYd-mR-vle" kind="presentation" identifier="segueFingerprint" modalTransitionStyle="crossDissolve" id="1Qm-rM-DSR"/>
     1.7 +                        <segue destination="Q27-22-ksB" kind="unwind" identifier="segueUnwindTrustedTrustwords" unwindAction="segueUnwindTrustedWithSegue:" id="xIJ-Gr-juQ"/>
     1.8 +                        <segue destination="Q27-22-ksB" kind="unwind" identifier="segueUnwindUnTrustedTrustwords" unwindAction="segueUnwindUnTrustedWithSegue:" id="H18-dB-Q4J"/>
     1.9                      </connections>
    1.10                  </tableViewController>
    1.11                  <placeholder placeholderIdentifier="IBFirstResponder" id="aMO-1d-a9s" userLabel="First Responder" sceneMemberID="firstResponder"/>
    1.12 +                <exit id="Q27-22-ksB" userLabel="Exit" sceneMemberID="exit"/>
    1.13              </objects>
    1.14              <point key="canvasLocation" x="7992.8000000000002" y="1181.5592203898052"/>
    1.15          </scene>
    1.16 @@ -2688,9 +2691,12 @@
    1.17                          <outlet property="partnerFingerprintLabel" destination="uUK-mt-BxO" id="sF6-cT-1H6"/>
    1.18                          <outlet property="partnerNameLabel" destination="BUQ-L0-Mlj" id="kV3-85-cc6"/>
    1.19                          <outlet property="trustwordsButton" destination="GzI-Qm-7yH" id="U6c-xr-KKK"/>
    1.20 +                        <segue destination="reS-BF-jea" kind="unwind" identifier="segueUnwindTrustedFingerprint" unwindAction="segueUnwindTrustedWithSegue:" id="OC9-oT-Rek"/>
    1.21 +                        <segue destination="reS-BF-jea" kind="unwind" identifier="segueUnwindUnTrustedFingerprint" unwindAction="segueUnwindUnTrustedWithSegue:" id="qpN-cI-4yf"/>
    1.22                      </connections>
    1.23                  </tableViewController>
    1.24                  <placeholder placeholderIdentifier="IBFirstResponder" id="5gX-0n-UVi" userLabel="First Responder" sceneMemberID="firstResponder"/>
    1.25 +                <exit id="reS-BF-jea" userLabel="Exit" sceneMemberID="exit"/>
    1.26              </objects>
    1.27              <point key="canvasLocation" x="9534" y="1182"/>
    1.28          </scene>
     2.1 --- a/pEpForiOS/UI/EmailDisplay/EmailListViewController.swift	Thu Feb 16 14:35:56 2017 +0100
     2.2 +++ b/pEpForiOS/UI/EmailDisplay/EmailListViewController.swift	Thu Feb 16 18:48:12 2017 +0100
     2.3 @@ -28,6 +28,12 @@
     2.4      let searchController = UISearchController(searchResultsController: nil)
     2.5      let cellsByMessageID = NSCache<NSString, EmailListViewCell>()
     2.6  
     2.7 +    /**
     2.8 +     After trustwords have been invoked, this will be the partner identity that
     2.9 +     was either confirmed or mistrusted.
    2.10 +     */
    2.11 +    var partnerIdentity: Identity?
    2.12 +
    2.13      override func viewDidLoad() {
    2.14          super.viewDidLoad()
    2.15  
    2.16 @@ -375,10 +381,21 @@
    2.17      }
    2.18  
    2.19      /**
    2.20 -     For the unwind segue from the trustwords controller, when the user chose "trust" or
    2.21 -     "no trust".
    2.22 +     For the unwind segue from the trustwords controller, when the user choses "trusted".
    2.23 +     */
    2.24 +    @IBAction func segueUnwindTrusted(segue: UIStoryboardSegue) {
    2.25 +        if let p = partnerIdentity {
    2.26 +            PEPUtil.trust(identity: p)
    2.27 +        }
    2.28 +    }
    2.29 +
    2.30 +    /**
    2.31 +     For the unwind segue from the trustwords controller, when the user choses "untrusted".
    2.32       */
    2.33      @IBAction func segueUnwindUnTrusted(segue: UIStoryboardSegue) {
    2.34 +        if let p = partnerIdentity {
    2.35 +            PEPUtil.mistrust(identity: p)
    2.36 +        }
    2.37      }
    2.38  }
    2.39  
     3.1 --- a/pEpForiOS/UI/Handshake/FingerprintTableViewController.swift	Thu Feb 16 14:35:56 2017 +0100
     3.2 +++ b/pEpForiOS/UI/Handshake/FingerprintTableViewController.swift	Thu Feb 16 18:48:12 2017 +0100
     3.3 @@ -68,18 +68,16 @@
     3.4         navigationController?.dismiss(animated: true, completion: nil)
     3.5      }
     3.6      
     3.7 -    @IBAction func confirmFingerprintButtonTapped(_ sender: RoundedButton) {
     3.8 -        PEPUtil.trust(identity: partnerIdentity)
     3.9 +    @IBAction func confirmFingerprintButtonTapped(_ sender: UIButton) {
    3.10 +        performSegue(withIdentifier: .segueUnwindTrustedFingerprint, sender: self)
    3.11      }
    3.12      
    3.13 -    @IBAction func wrongFingerprintButtonTapped(_ sender: RoundedButton) {
    3.14 -        PEPUtil.mistrust(identity: partnerIdentity)
    3.15 +    @IBAction func wrongFingerprintButtonTapped(_ sender: UIButton) {
    3.16 +        performSegue(withIdentifier: .segueUnwindUnTrustedFingerprint, sender: self)
    3.17      }
    3.18 -    
    3.19  }
    3.20  
    3.21  extension FingerprintTableViewController {
    3.22 -    
    3.23      func fingerprintFormat(_ fingerprint: String) -> String {
    3.24          let medio = fingerprint.characters.count/2
    3.25          var result = String()
    3.26 @@ -98,3 +96,24 @@
    3.27          return result
    3.28      }
    3.29  }
    3.30 +
    3.31 +extension FingerprintTableViewController: SegueHandlerType {
    3.32 +
    3.33 +    // MARK: - SegueHandlerType
    3.34 +
    3.35 +    enum SegueIdentifier: String {
    3.36 +        case segueUnwindTrustedFingerprint
    3.37 +        case segueUnwindUnTrustedFingerprint
    3.38 +    }
    3.39 +
    3.40 +    // MARK: - Navigation
    3.41 +
    3.42 +    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    3.43 +        switch segueIdentifier(for: segue) {
    3.44 +        case .segueUnwindTrustedFingerprint, .segueUnwindUnTrustedFingerprint:
    3.45 +            if let tc = segue.destination as? EmailListViewController {
    3.46 +                tc.partnerIdentity = partnerIdentity
    3.47 +            }
    3.48 +        }
    3.49 +    }
    3.50 +}
     4.1 --- a/pEpForiOS/UI/Handshake/TrustwordsTableViewController.swift	Thu Feb 16 14:35:56 2017 +0100
     4.2 +++ b/pEpForiOS/UI/Handshake/TrustwordsTableViewController.swift	Thu Feb 16 18:48:12 2017 +0100
     4.3 @@ -125,13 +125,11 @@
     4.4      }
     4.5      
     4.6      @IBAction func confirmTrustwordsTapped(_ sender: UIButton) {
     4.7 -        PEPUtil.trust(identity: partnerIdentity)
     4.8 -        performSegue(withIdentifier: .segueUnwindUnTrusted, sender: self)
     4.9 +        performSegue(withIdentifier: .segueUnwindTrustedTrustwords, sender: self)
    4.10      }
    4.11      
    4.12      @IBAction func wrongTrustwordsTapped(_ sender: UIButton) {
    4.13 -        PEPUtil.mistrust(identity: partnerIdentity)
    4.14 -        performSegue(withIdentifier: .segueUnwindUnTrusted, sender: self)
    4.15 +        performSegue(withIdentifier: .segueUnwindUnTrustedTrustwords, sender: self)
    4.16      }
    4.17  }
    4.18  
    4.19 @@ -165,21 +163,29 @@
    4.20      
    4.21      enum SegueIdentifier: String {
    4.22          case segueFingerprint
    4.23 -        case segueUnwindUnTrusted
    4.24 +        case segueUnwindTrustedTrustwords
    4.25 +        case segueUnwindUnTrustedTrustwords
    4.26          case noSegue
    4.27      }
    4.28      
    4.29      // MARK: - Navigation
    4.30      
    4.31      override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    4.32 -        let navigationController = segue.destination
    4.33 -        let destination = navigationController.childViewControllers[0]
    4.34 -            as! FingerprintTableViewController
    4.35 -        destination.myselfIdentity = myselfIdentity
    4.36 -        destination.message = message
    4.37 -        destination.appConfig = appConfig
    4.38 -        destination.partnerIdentity = partnerIdentity
    4.39 -        destination.selectedTrustwordsLanguage = selectedTrustwordsLanguage
    4.40 +        switch segueIdentifier(for: segue) {
    4.41 +        case .segueFingerprint:
    4.42 +            let navigationController = segue.destination
    4.43 +            let destination = navigationController.childViewControllers[0]
    4.44 +                as! FingerprintTableViewController
    4.45 +            destination.myselfIdentity = myselfIdentity
    4.46 +            destination.message = message
    4.47 +            destination.appConfig = appConfig
    4.48 +            destination.partnerIdentity = partnerIdentity
    4.49 +            destination.selectedTrustwordsLanguage = selectedTrustwordsLanguage
    4.50 +        case .segueUnwindTrustedTrustwords, .segueUnwindUnTrustedTrustwords:
    4.51 +            if let tc = segue.destination as? EmailListViewController {
    4.52 +                tc.partnerIdentity = partnerIdentity
    4.53 +            }
    4.54 +        case .noSegue: ()
    4.55 +        }
    4.56      }
    4.57  }
    4.58 -