CryptoPassphrase  Check-in [0c2ffe58fd]

Overview
Comment:[iOS] Remove key upload functionality

It was never finished and uploading a key file unencrypted via WiFi is a
bad idea anyway.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | trunk
Files: files | file ages | folders
SHA3-256: 0c2ffe58fdc61f477675a204326a34910f476539441b81af07db77518955d844
User & Date: js on 2024-08-25 10:48:32
Other Links: manifest | tags
Context
2024-08-25
10:48
[iOS] Remove key upload functionality Leaf check-in: 0c2ffe58fd user: js tags: trunk
2024-08-11
09:08
Set version to 1.0.1 check-in: 2f8cbf3f64 user: js tags: trunk, v1.0.1
Changes

Modified iOS/Base.lproj/Main.storyboard from [08cafa2360] to [28cd945941].

1
2

3
4
5
6

7
8
9
10
11
12
13
14
15
16

17
18
19
20
21
22
23
1

2
3
4
5

6
7
8
9
10
11
12
13
14
15

16
17
18
19
20
21
22
23

-
+



-
+









-
+







<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BN3-Y7-zvx">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BN3-Y7-zvx">
    <device id="retina4_7" orientation="portrait" appearance="light"/>
    <dependencies>
        <deployment identifier="iOS"/>
        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/>
        <capability name="System colors in document resources" minToolsVersion="11.0"/>
        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
    </dependencies>
    <scenes>
        <!--Navigation Controller-->
        <scene sceneID="edE-sY-0Cv">
            <objects>
                <navigationController id="BN3-Y7-zvx" sceneMemberID="viewController">
                    <navigationBar key="navigationBar" contentMode="scaleToFill" id="K8n-wn-irC">
                        <rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
                        <rect key="frame" x="0.0" y="20" width="375" height="44"/>
                        <autoresizingMask key="autoresizingMask"/>
                    </navigationBar>
                    <connections>
                        <segue destination="P19-6i-fpd" kind="relationship" relationship="rootViewController" id="izn-Ct-ivZ"/>
                    </connections>
                </navigationController>
                <placeholder placeholderIdentifier="IBFirstResponder" id="xSr-8M-yKj" userLabel="First Responder" sceneMemberID="firstResponder"/>
36
37
38
39
40
41
42
43

44
45
46
47
48
49
50

51
52
53
54
55
56
57
36
37
38
39
40
41
42

43
44
45
46
47
48
49

50
51
52
53
54
55
56
57







-
+






-
+







                        <viewControllerLayoutGuide type="bottom" id="TZK-mv-9Bn"/>
                    </layoutGuides>
                    <view key="view" contentMode="scaleToFill" id="5FM-eD-86d">
                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                        <subviews>
                            <searchBar contentMode="redraw" translatesAutoresizingMaskIntoConstraints="NO" id="CMc-ZN-RAn">
                                <rect key="frame" x="0.0" y="44" width="375" height="51"/>
                                <rect key="frame" x="0.0" y="64" width="375" height="56"/>
                                <textInputTraits key="textInputTraits"/>
                                <connections>
                                    <outlet property="delegate" destination="P19-6i-fpd" id="G7P-7f-gbO"/>
                                </connections>
                            </searchBar>
                            <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="eoq-EJ-t3s">
                                <rect key="frame" x="0.0" y="95" width="375" height="572"/>
                                <rect key="frame" x="0.0" y="120" width="375" height="547"/>
                                <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                                <connections>
                                    <outlet property="dataSource" destination="P19-6i-fpd" id="1sa-qY-oQx"/>
                                    <outlet property="delegate" destination="P19-6i-fpd" id="Iv1-4B-R74"/>
                                </connections>
                            </tableView>
                        </subviews>
97
98
99
100
101
102
103
104

105
106
107
108
109
110
111
97
98
99
100
101
102
103

104
105
106
107
108
109
110
111







-
+







                        <viewControllerLayoutGuide type="bottom" id="NSX-G5-c03"/>
                    </layoutGuides>
                    <view key="view" contentMode="scaleToFill" id="VbJ-Zv-Wf9">
                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                        <subviews>
                            <webView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2xd-QR-99d">
                                <rect key="frame" x="0.0" y="44" width="375" height="623"/>
                                <rect key="frame" x="0.0" y="64" width="375" height="603"/>
                                <color key="backgroundColor" red="0.36078431370000003" green="0.38823529410000002" blue="0.4039215686" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                <connections>
                                    <outlet property="delegate" destination="MZ3-iZ-Dsf" id="uKq-6T-ltJ"/>
                                </connections>
                            </webView>
                        </subviews>
                        <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
230
231
232
233
234
235
236
237

238
239
240
241
242
243
244
245
246
247
248
249
250

251
252
253
254
255
256
257
230
231
232
233
234
235
236

237
238
239
240
241
242
243
244
245
246
247
248
249

250
251
252
253
254
255
256
257







-
+












-
+







                                            </constraints>
                                        </tableViewCellContentView>
                                    </tableViewCell>
                                    <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="Oqt-88-vl9">
                                        <rect key="frame" x="0.0" y="186" width="375" height="44"/>
                                        <autoresizingMask key="autoresizingMask"/>
                                        <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Oqt-88-vl9" id="j4y-Zr-ep4">
                                            <rect key="frame" x="0.0" y="0.0" width="350.5" height="44"/>
                                            <rect key="frame" x="0.0" y="0.0" width="348.5" height="44"/>
                                            <autoresizingMask key="autoresizingMask"/>
                                            <subviews>
                                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Key file" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Uyw-CW-atj">
                                                    <rect key="frame" x="16" y="11.5" width="100" height="21"/>
                                                    <constraints>
                                                        <constraint firstAttribute="width" constant="100" id="5d9-re-aJA"/>
                                                    </constraints>
                                                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                                    <nil key="textColor"/>
                                                    <nil key="highlightedColor"/>
                                                </label>
                                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="None" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wv8-GU-ahj">
                                                    <rect key="frame" x="124" y="11.5" width="217.5" height="21"/>
                                                    <rect key="frame" x="124" y="11.5" width="215.5" height="21"/>
                                                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                                    <nil key="textColor"/>
                                                    <nil key="highlightedColor"/>
                                                </label>
                                            </subviews>
                                            <constraints>
                                                <constraint firstAttribute="trailingMargin" secondItem="wv8-GU-ahj" secondAttribute="trailing" constant="1" id="0sM-gC-XNC" userLabel="trailingMargin = Label.trailing"/>
305
306
307
308
309
310
311
312

313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
305
306
307
308
309
310
311

312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327





328
329
330
331
332
333
334







-
+















-
-
-
-
-







                <tableViewController id="4bs-rP-TxE" customClass="SelectKeyFileController" customModule="CryptoPassphrase" customModuleProvider="target" sceneMemberID="viewController">
                    <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="SYH-wm-J8Z">
                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                        <prototypes>
                            <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" id="QAR-8T-qhV">
                                <rect key="frame" x="0.0" y="44.5" width="375" height="43.5"/>
                                <rect key="frame" x="0.0" y="50" width="375" height="43.5"/>
                                <autoresizingMask key="autoresizingMask"/>
                                <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="QAR-8T-qhV" id="u3r-6g-c9v">
                                    <rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
                                    <autoresizingMask key="autoresizingMask"/>
                                </tableViewCellContentView>
                            </tableViewCell>
                        </prototypes>
                        <connections>
                            <outlet property="dataSource" destination="4bs-rP-TxE" id="ETv-7q-fl3"/>
                            <outlet property="delegate" destination="4bs-rP-TxE" id="Tnz-0X-Y4f"/>
                        </connections>
                    </tableView>
                    <toolbarItems/>
                    <navigationItem key="navigationItem" id="bWa-Dd-f4f">
                        <nil key="title"/>
                        <barButtonItem key="rightBarButtonItem" enabled="NO" title="Upload" id="85s-WF-868">
                            <connections>
                                <action selector="upload:" destination="4bs-rP-TxE" id="DnV-UG-h0y"/>
                            </connections>
                        </barButtonItem>
                    </navigationItem>
                    <simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
                </tableViewController>
                <placeholder placeholderIdentifier="IBFirstResponder" id="hBM-t2-PD9" userLabel="First Responder" sceneMemberID="firstResponder"/>
            </objects>
            <point key="canvasLocation" x="2935" y="-1234"/>
        </scene>

Modified iOS/CryptoPassphrase.xcodeproj/project.pbxproj from [db9fe4f40c] to [bc7a1fac56].

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
11
12
13
14
15
16
17

18
19
20
21
22
23
24







-







		4B2E52EC1DA942840040D091 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4B2E52EB1DA942840040D091 /* Assets.xcassets */; };
		4B2E52EF1DA942840040D091 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4B2E52ED1DA942840040D091 /* LaunchScreen.storyboard */; };
		4B31D80922B58F0F00494B15 /* SiteStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B31D80822B58F0F00494B15 /* SiteStorage.swift */; };
		4B5BCEF922B5B94C00E551BD /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B5BCEF822B5B94C00E551BD /* AppDelegate.swift */; };
		4B5BCEFB22B5CF3200E551BD /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B5BCEFA22B5CF3200E551BD /* MainViewController.swift */; };
		4B5BCEFD22B5D98800E551BD /* SelectKeyFileController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B5BCEFC22B5D98800E551BD /* SelectKeyFileController.swift */; };
		4B5BCEFF22B5E36900E551BD /* ShowDetailsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B5BCEFE22B5E36900E551BD /* ShowDetailsController.swift */; };
		4B93656E22B5ADA00099DD08 /* HTTPServerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B93656D22B5ADA00099DD08 /* HTTPServerDelegate.swift */; };
		4B93657022B5AE2C0099DD08 /* AboutController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B93656F22B5AE2C0099DD08 /* AboutController.swift */; };
		4B93657222B5B1FB0099DD08 /* AddSiteController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B93657122B5B1FB0099DD08 /* AddSiteController.swift */; };
		4B9525251F96BB900095F259 /* ObjFW.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B9525231F96BB820095F259 /* ObjFW.framework */; };
		4B9525261F96BB900095F259 /* ObjFWBridge.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B9525241F96BB820095F259 /* ObjFWBridge.framework */; };
		4B9525291F994CD30095F259 /* ObjFW.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4B9525231F96BB820095F259 /* ObjFW.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
		4B95252A1F9953350095F259 /* ObjFWBridge.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4B9525241F96BB820095F259 /* ObjFWBridge.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
		4BA115D21DA9432D007ED4EA /* LegacyPasswordGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BA115CE1DA9432D007ED4EA /* LegacyPasswordGenerator.m */; settings = {COMPILER_FLAGS = "-fconstant-string-class=OFConstantString -fno-constant-cfstrings"; }; };
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
51
52
53
54
55
56
57

58
59
60
61
62
63
64







-







		4B2E52F01DA942840040D091 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
		4B31D80822B58F0F00494B15 /* SiteStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SiteStorage.swift; sourceTree = "<group>"; };
		4B38148322B5ED01005C27B2 /* bridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = bridge.h; sourceTree = "<group>"; };
		4B5BCEF822B5B94C00E551BD /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
		4B5BCEFA22B5CF3200E551BD /* MainViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = "<group>"; };
		4B5BCEFC22B5D98800E551BD /* SelectKeyFileController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectKeyFileController.swift; sourceTree = "<group>"; };
		4B5BCEFE22B5E36900E551BD /* ShowDetailsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShowDetailsController.swift; sourceTree = "<group>"; };
		4B93656D22B5ADA00099DD08 /* HTTPServerDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HTTPServerDelegate.swift; sourceTree = "<group>"; };
		4B93656F22B5AE2C0099DD08 /* AboutController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutController.swift; sourceTree = "<group>"; };
		4B93657122B5B1FB0099DD08 /* AddSiteController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddSiteController.swift; sourceTree = "<group>"; };
		4B9525231F96BB820095F259 /* ObjFW.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ObjFW.framework; path = Frameworks/ObjFW.framework; sourceTree = "<group>"; };
		4B9525241F96BB820095F259 /* ObjFWBridge.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ObjFWBridge.framework; path = Frameworks/ObjFWBridge.framework; sourceTree = "<group>"; };
		4BA115CD1DA9432D007ED4EA /* LegacyPasswordGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LegacyPasswordGenerator.h; path = ../LegacyPasswordGenerator.h; sourceTree = "<group>"; };
		4BA115CE1DA9432D007ED4EA /* LegacyPasswordGenerator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LegacyPasswordGenerator.m; path = ../LegacyPasswordGenerator.m; sourceTree = "<group>"; };
		4BA115CF1DA9432D007ED4EA /* NewPasswordGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NewPasswordGenerator.h; path = ../NewPasswordGenerator.h; sourceTree = "<group>"; };
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
104
105
106
107
108
109
110

111
112
113
114
115
116
117







-







		4B2E52DE1DA942840040D091 /* iOS */ = {
			isa = PBXGroup;
			children = (
				4B2E52EB1DA942840040D091 /* Assets.xcassets */,
				4B93656F22B5AE2C0099DD08 /* AboutController.swift */,
				4B93657122B5B1FB0099DD08 /* AddSiteController.swift */,
				4B5BCEF822B5B94C00E551BD /* AppDelegate.swift */,
				4B93656D22B5ADA00099DD08 /* HTTPServerDelegate.swift */,
				4B2E52F01DA942840040D091 /* Info.plist */,
				4B2E52ED1DA942840040D091 /* LaunchScreen.storyboard */,
				4B2E52E81DA942840040D091 /* Main.storyboard */,
				4B5BCEFA22B5CF3200E551BD /* MainViewController.swift */,
				4B5BCEFC22B5D98800E551BD /* SelectKeyFileController.swift */,
				4B5BCEFE22B5E36900E551BD /* ShowDetailsController.swift */,
				4B31D80822B58F0F00494B15 /* SiteStorage.swift */,
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
216
217
218
219
220
221
222

223
224
225
226
227
228
229







-








/* Begin PBXSourcesBuildPhase section */
		4B2E52D81DA942840040D091 /* Sources */ = {
			isa = PBXSourcesBuildPhase;
			buildActionMask = 2147483647;
			files = (
				4B5BCEF922B5B94C00E551BD /* AppDelegate.swift in Sources */,
				4B93656E22B5ADA00099DD08 /* HTTPServerDelegate.swift in Sources */,
				4B5BCEFB22B5CF3200E551BD /* MainViewController.swift in Sources */,
				4B93657222B5B1FB0099DD08 /* AddSiteController.swift in Sources */,
				4BA115D21DA9432D007ED4EA /* LegacyPasswordGenerator.m in Sources */,
				4BA115D31DA9432D007ED4EA /* NewPasswordGenerator.m in Sources */,
				4B31D80922B58F0F00494B15 /* SiteStorage.swift in Sources */,
				4B5BCEFD22B5D98800E551BD /* SelectKeyFileController.swift in Sources */,
				4B5BCEFF22B5E36900E551BD /* ShowDetailsController.swift in Sources */,

Deleted iOS/HTTPServerDelegate.swift version [9b7933e9c9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/*
 * Copyright (c) 2016 - 2023 Jonathan Schleifer <js@nil.im>
 *
 * https://fl.nil.im/cryptopassphrase
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 * PERFORMANCE OF THIS SOFTWARE.
 */

import Foundation
import ObjFW

class HTTPServerDelegate: OFObject, OFHTTPServerDelegate {
    func server(_ server: OFHTTPServer, didReceive request: OFHTTPRequest,
                requestBody: OFStream?, response: OFHTTPResponse) {
        print("\(request)")
    }
}

Modified iOS/SelectKeyFileController.swift from [0d004c181f] to [969106a0b4].

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
19
20
21
22
23
24
25















26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45







46
47
48
49
50
51
52







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-




















-
-
-
-
-
-
-







import ObjFW
import UIKit

class SelectKeyFileController: UITableViewController {
    public var addSiteController: AddSiteController?

    private var keyFiles: [String] = []
    private var httpServer: OFHTTPServer
    private var httpServerDelegate: HTTPServerDelegate
    private var httpServerThread: OFThread

    required init?(coder aDecoder: NSCoder) {
        httpServer = OFHTTPServer()
        httpServer.host = "127.0.0.1".ofObject

        httpServerDelegate = HTTPServerDelegate()
        httpServer.delegate = self.httpServerDelegate

        httpServerThread = OFThread()

        super.init(coder: aDecoder)
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        guard let documentDirectory = NSSearchPathForDirectoriesInDomains(
            .documentDirectory, .userDomainMask, true).first
        else {
            print("Could not get key files: No documents directory")
            navigationController?.popViewController(animated: true)
            return
        }

        do {
            keyFiles = try FileManager.default.contentsOfDirectory(
                atPath: documentDirectory).sorted()
        } catch let error as NSError {
            print("Could not get key files: \(error)")
            navigationController?.popViewController(animated: true)
            return
        }

        httpServerThread.start()
    }

    override func viewDidDisappear(_ animated: Bool) {
        httpServerThread.runLoop.stop()
        httpServerThread.join()
    }

    override func tableView(_ tableView: UITableView,
                            numberOfRowsInSection section: Int) -> Int {
        return keyFiles.count + 1
    }

88
89
90
91
92
93
94
95

96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
66
67
68
69
70
71
72

73
































-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
        addSiteController?.keyFile =
            indexPath.row > 0 ? keyFiles[indexPath.row - 1] : nil
        addSiteController?.keyFileLabel?.text =
            indexPath.row > 0 ? keyFiles[indexPath.row - 1] : "None"

        self.navigationController?.popViewController(animated: true)
    }

}
    @IBAction func upload(_ sender: Any?) {
        let timer = OFTimer.scheduledTimer(withTimeInterval: 0,
                                           repeats: false) { (OFTimer) in
            self.httpServer.port = 0
            self.httpServer.start()

            let message =
                "Navigate to http://\(self.httpServer.host!.nsObject):" +
                "\(self.httpServer.port)/ in your browser.\n\n" +
                "Press OK when done."
            let alert = UIAlertController(title: "Server Running",
                                          message: message,
                                          preferredStyle: .alert)
            alert.addAction(
                UIAlertAction(title: "OK", style: .default, handler: nil))

            DispatchQueue.main.sync {
                self.present(alert, animated: true) {
                    self.httpServer.stop()
                }
            }
        }
        httpServerThread.runLoop.add(timer)
    }
}