CryptoPassphrase  Check-in [82f79a19ab]

Overview
Comment:Adjust to ObjFW changes
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 82f79a19ab99fd7cdb6e495212a1382829f678b44e98158b85f6fa19a9c7eae4
User & Date: js on 2022-08-21 11:58:20
Other Links: manifest | tags
Context
2022-11-15
22:54
Adjust to ObjFW changes check-in: 7b7392ad32 user: js tags: trunk
2022-08-21
11:58
Adjust to ObjFW changes check-in: 82f79a19ab user: js tags: trunk
2022-06-18
15:28
[iOS] Fix missing 0 byte after passphrase check-in: b57405c1d0 user: js tags: trunk
Changes

Modified iOS/SiteStorage.swift from [d682a8090e] to [e4b689e0a1].

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
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







-
+

-
-
+
+


-
+




-
+
-







-
+






-
-
+
+

-
+








    private var path: OFString
    private var storage: [String: [NSNumber: AnyObject]]
    private var sites: [String]

    override init() {
        let fileManager = OFFileManager.default
        let userDataPath = OFSystemInfo.userDataPath!
        let userDataURL = OFSystemInfo.userDataURL!

        if !fileManager.directoryExists(atPath: userDataPath) {
            fileManager.createDirectory(atPath: userDataPath)
        if !fileManager.directoryExists(at: userDataURL) {
            fileManager.createDirectory(at: userDataURL)
        }

        let path = userDataPath.appendingPathComponent(
        let URL = userDataURL.appendingPathComponent(
            OFString(utf8String: "sites.msgpack"))

        var storage: [String: [NSNumber: AnyObject]]? = nil
        OFException.try({
            let decoded = (OFData(contentsOfFile: path)
            let decoded = (OFData(contentsOf: URL).objectByParsingMessagePack)
                .objectByParsingMessagePack)
                as? OFDictionary<OFString, OFDictionary<OFNumber, AnyObject>>
            storage =
                (decoded?.nsObject as? [String: [NSNumber: AnyObject]]) ?? [:]
        }, catch: { (OFException) in
            storage = [:]
        })

        self.path = path
        self.path = URL.fileSystemRepresentation!
        self.storage = storage!
        self.sites = self.storage.keys.sorted()
    }

    func sites(withFilter filter: String?) -> [String] {
        return storage.keys.sorted().filter({ (name) in
            if let filter = filter {
                return name.localizedCaseInsensitiveContains(filter)
            if filter == nil || filter!.isEmpty {
                return true
            }
            return true
            return name.localizedCaseInsensitiveContains(filter!)
        })
    }

    func hasSite(_ name: String) -> Bool {
        return (storage[name] != nil)
    }