diff --git a/enzevalos_iphone/AppDelegate.swift b/enzevalos_iphone/AppDelegate.swift index 326050e8d44614e022f8f2e6a97508d76e0c4d90..ffd6c5482a644d87fed84c226f09256f083c7373 100644 --- a/enzevalos_iphone/AppDelegate.swift +++ b/enzevalos_iphone/AppDelegate.swift @@ -144,7 +144,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { }) let handler = DataHandler.init() let keyId = handler.createNewSecretKey(adr: UserManager.loadUserValue(Attribute.userAddr) as! String) - _ = handler.getContact(name: UserManager.loadUserValue(Attribute.accountname) as! String, address: UserManager.loadUserValue(Attribute.userAddr) as! String, key: keyId.keyID!, prefer_enc: true) + _ = handler.getContact(name: UserManager.loadUserValue(Attribute.accountname) as! String, address: UserManager.loadUserValue(Attribute.userAddr) as! String, key: keyId.keyID, prefer_enc: true) handler.save(during: "setup user") StudySettings.setupStudyKeys() Mailbot.firstMail() diff --git a/enzevalos_iphone/Autocrypt.swift b/enzevalos_iphone/Autocrypt.swift index b9479a14dd0abd5d7c6bff65c4ff7b1b1aff156d..674f3bfe13500c5fbff7a96284b6c1d388c036e8 100644 --- a/enzevalos_iphone/Autocrypt.swift +++ b/enzevalos_iphone/Autocrypt.swift @@ -114,14 +114,13 @@ class Autocrypt { let encPref = EncState.MUTUAL let pgp = SwiftPGP() - if let id = skID { - if let key = pgp.exportKey(id: id, isSecretkey: false, autocrypt: true) { - var string = "\(ADDR)=" + adr - string = string + "; \(ENCRYPTION)=\(encPref.name)" - string = string + "; \(KEY)=" + key - builder.header.setExtraHeaderValue(string, forName: AUTOCRYPTHEADER) - } + if let key = pgp.exportKey(id: skID, isSecretkey: false, autocrypt: true) { + var string = "\(ADDR)=" + adr + string = string + "; \(ENCRYPTION)=\(encPref.name)" + string = string + "; \(KEY)=" + key + builder.header.setExtraHeaderValue(string, forName: AUTOCRYPTHEADER) } + } static func recommandateEncryption (receiver: MailAddress) -> (hasAutocrypt: Bool, recommandEnc: Bool){ diff --git a/enzevalos_iphone/DataHandler.swift b/enzevalos_iphone/DataHandler.swift index 4e276a01fc6084eec91beb88e55c596e013642e7..37281a5e4b46488fd34121498665f4746312357e 100644 --- a/enzevalos_iphone/DataHandler.swift +++ b/enzevalos_iphone/DataHandler.swift @@ -304,7 +304,7 @@ class DataHandler { sk = NSEntityDescription.insertNewObject(forEntityName: "SecretKey", into: managedObjectContext) as! SecretKey sk.keyID = keyID sk.obsolete = false - sk.importedDate = Date() + sk.importedDate = Date() as NSDate UserManager.storeUserValue(keyID as AnyObject, attribute: Attribute.prefSecretKeyID) let adr = UserManager.loadUserValue(Attribute.userAddr) as! String let name = adr // TODO Change here displayname diff --git a/enzevalos_iphone/ExportViewController.swift b/enzevalos_iphone/ExportViewController.swift index 59c2f16306d689a5186195546e9ba7ad2e7fba4b..02cdfcead3da207e8790b87252053c8ce060c25f 100644 --- a/enzevalos_iphone/ExportViewController.swift +++ b/enzevalos_iphone/ExportViewController.swift @@ -54,7 +54,8 @@ class ExportViewController: UITableViewController { let handler = DataHandler.handler let sk = handler.prefSecretKey() //handler.findSecretKeys() let pgp = SwiftPGP() - if let sk = sk, let keyId = sk.keyID { + if let sk = sk { + let keyId = sk.keyID if alreadySent { if let message = pgp.exportKey(id: keyId, isSecretkey: true, autocrypt: true, newPasscode: true) { passcode = pgp.loadExportPasscode(id: keyId)! @@ -148,10 +149,9 @@ class ExportViewController: UITableViewController { if ids.count > 0 { let id = ids[0] let pgp = SwiftPGP() - if let keyId = id.keyID { - passcode = pgp.loadExportPasscode(id: keyId) ?? "" - alreadySent = passcode != "" - } + let keyId = id.keyID + passcode = pgp.loadExportPasscode(id: keyId) ?? "" + alreadySent = passcode != "" } diff --git a/enzevalos_iphone/InboxViewController.swift b/enzevalos_iphone/InboxViewController.swift index 1e4bf36cadb14a2a5bc1ff2eb72214184e82cb9a..6f28acfa54e767a44a10adc9722a1aedc87923c5 100644 --- a/enzevalos_iphone/InboxViewController.swift +++ b/enzevalos_iphone/InboxViewController.swift @@ -112,7 +112,6 @@ class InboxViewController: UITableViewController, InboxCellDelegator { } else { lastUpdateText = NSLocalizedString("NeverUpdated", comment: "Error while loading mailscomment") if AppDelegate.getAppDelegate().currentReachabilityStatus != .notReachable && counterRefreshs < 100{ - print("REFRESH AGAIN!") counterRefreshs += 1 refresh(nil) } diff --git a/enzevalos_iphone/ItunesHandler.swift b/enzevalos_iphone/ItunesHandler.swift index 6728c8d9f9d487b6cd3f1e302aabf6cbf0a1e624..397c628f195c20fecc6ab9deee725959566a4b21 100644 --- a/enzevalos_iphone/ItunesHandler.swift +++ b/enzevalos_iphone/ItunesHandler.swift @@ -86,7 +86,7 @@ class ItunesKeyHandling { func importPublicKeys() -> [String]{ var publicKeys = storedKeys.filter{!$0.isSecret} - publicKeys = publicKeys.filter{DataHandler.handler.findKey(keyID: $0.keyID!) == nil} + publicKeys = publicKeys.filter{DataHandler.handler.findKey(keyID: $0.keyID) == nil} let keyIds = pgp.store(tempKeys: publicKeys) //TODO: Store in Datahandler -> in tempKey? return keyIds @@ -104,9 +104,7 @@ class MinimalImportUI { var secretKeyPasswordField: UITextField? = nil func importSecretKeyDialog(first: Bool) { - guard let keyID = secretKey.keyID else { - return - } + let keyID = secretKey.keyID let format = NSLocalizedString("Read.Import.Secret.Body.Plain", comment: "NewSecretKeyMessage") var message = String.localizedStringWithFormat(format, keyID) if secretKey.hasPassword { diff --git a/enzevalos_iphone/KeyCell.xib b/enzevalos_iphone/KeyCell.xib index 2420ba39656ea61c047737e70360dda6a87111cf..1fc1eacec612df2cb012034d7dcf208ea8e21fab 100644 --- a/enzevalos_iphone/KeyCell.xib +++ b/enzevalos_iphone/KeyCell.xib @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> <device id="retina4_7" orientation="portrait"> <adaptation id="fullscreen"/> </device> <dependencies> <deployment identifier="iOS"/> - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> </dependencies> diff --git a/enzevalos_iphone/MailHandler.swift b/enzevalos_iphone/MailHandler.swift index b23b9d233641ff8d1b548fe13aed060ce9e81258..ae83d829bb2ce457251eaeff6d6229537b76cad6 100644 --- a/enzevalos_iphone/MailHandler.swift +++ b/enzevalos_iphone/MailHandler.swift @@ -857,9 +857,7 @@ class MailHandler { let secretkeys = DataHandler.handler.findSecretKeys() var decIds = [String]() for sk in secretkeys { - if let id = sk.keyID { - decIds.append(id) - } + decIds.append(sk.keyID) } return pgp.decrypt(data: data, decKeyIDs: decIds, signatureIDs: keyIds, fromAddr: sender ?? "") diff --git a/enzevalos_iphone/OutgoingMail.swift b/enzevalos_iphone/OutgoingMail.swift index 9abd04774c924a7243096bae32f7b2af3f4b9ea3..127e446735bc3fcc47ee5d97e164e4c4f3e97dae 100644 --- a/enzevalos_iphone/OutgoingMail.swift +++ b/enzevalos_iphone/OutgoingMail.swift @@ -268,10 +268,13 @@ class OutgoingMail { var missingOwnPublic = false var pgpKeyIds: [String] = [] var skKeyID = "" - if let sk = sk, let skID = sk.keyID { + if let sk = sk { + let skID = sk.keyID pgpKeyIds.append(skID) skKeyID = skID } + + if !onlySelfEnc { pgpKeyIds.append(contentsOf: OutgoingMail.addKeys(adrs: pgpAddresses)) } @@ -285,7 +288,8 @@ class OutgoingMail { } } if missingOwnPublic, let sk = sk { - if let id = sk.keyID, let myPK = pgp.exportKey(id: id, isSecretkey: false, autocrypt: false), let data = myPK.data(using: .utf8) { + let id = sk.keyID + if let myPK = pgp.exportKey(id: id, isSecretkey: false, autocrypt: false), let data = myPK.data(using: .utf8) { addAttachment(filename: "\(id).asc", mimeType: "application/pgp-keys", charset: nil, data: data) } } diff --git a/enzevalos_iphone/SecretKey+CoreDataClass.swift b/enzevalos_iphone/SecretKey+CoreDataClass.swift new file mode 100644 index 0000000000000000000000000000000000000000..f420d7f57e7899ef09aa018af97fa81720236258 --- /dev/null +++ b/enzevalos_iphone/SecretKey+CoreDataClass.swift @@ -0,0 +1,16 @@ +// +// SecretKey+CoreDataClass.swift +// enzevalos_iphone +// +// Created by Oliver Wiese on 02.10.19. +// Copyright © 2019 fu-berlin. All rights reserved. +// +// + +import Foundation +import CoreData + +@objc(SecretKey) +public class SecretKey: NSManagedObject { + +} diff --git a/enzevalos_iphone/SecretKey+CoreDataProperties.swift b/enzevalos_iphone/SecretKey+CoreDataProperties.swift new file mode 100644 index 0000000000000000000000000000000000000000..2bb74ef73356cf506c1b719f73363cc827d32043 --- /dev/null +++ b/enzevalos_iphone/SecretKey+CoreDataProperties.swift @@ -0,0 +1,45 @@ +// +// SecretKey+CoreDataProperties.swift +// enzevalos_iphone +// +// Created by Oliver Wiese on 02.10.19. +// Copyright © 2019 fu-berlin. All rights reserved. +// +// + +import Foundation +import CoreData + + +extension SecretKey { + + @nonobjc public class func fetchRequest() -> NSFetchRequest<SecretKey> { + return NSFetchRequest<SecretKey>(entityName: "SecretKey") + } + + @NSManaged public var exported: Bool + @NSManaged public var importedDate: NSDate? + @NSManaged public var keyID: String + @NSManaged public var obsolete: Bool + @NSManaged public var origin: Int16 + @NSManaged public var account: Account? + @NSManaged public var decryptedMails: NSSet? + +} + +// MARK: Generated accessors for decryptedMails +extension SecretKey { + + @objc(addDecryptedMailsObject:) + @NSManaged public func addToDecryptedMails(_ value: PersistentMail) + + @objc(removeDecryptedMailsObject:) + @NSManaged public func removeFromDecryptedMails(_ value: PersistentMail) + + @objc(addDecryptedMails:) + @NSManaged public func addToDecryptedMails(_ values: NSSet) + + @objc(removeDecryptedMails:) + @NSManaged public func removeFromDecryptedMails(_ values: NSSet) + +} diff --git a/enzevalos_iphone/SecretKeyTableViewController.swift b/enzevalos_iphone/SecretKeyTableViewController.swift index 634829f9af7bba6172888e09e0eaf82de73f128a..9fa4595684d9c2263b3242eff5aa761c3e6cc76e 100644 --- a/enzevalos_iphone/SecretKeyTableViewController.swift +++ b/enzevalos_iphone/SecretKeyTableViewController.swift @@ -11,7 +11,7 @@ import Foundation class SecretKeyTableViewController: UITableViewController { static let storyboardID = "secretKeyTable" - var keys: [DisplaySecretKey] = [] + var keys: [DisplayKey] = [] private var prefKeyID: String? { get { @@ -76,10 +76,8 @@ class SecretKeyTableViewController: UITableViewController { return } let newPrefKey = keys[indexPath.row] - guard let id = newPrefKey.keyID else { - tableView.reloadRows(at: [indexPath], with: .none) - return - } + let id = newPrefKey.keyID + let pgp = SwiftPGP.init() if pgp.checkPasswordFor(secretKeyID: id, password: nil, secretkey: newPrefKey.pgpKey) { changePrefKey(tableView: tableView, indexPath: indexPath) diff --git a/enzevalos_iphone/TempKey.swift b/enzevalos_iphone/TempKey.swift index 07976e6323d53b1bb2b307719ef704b8f9df8e4e..199244358153a94c36d7e6255f26ddd464a5cd89 100644 --- a/enzevalos_iphone/TempKey.swift +++ b/enzevalos_iphone/TempKey.swift @@ -9,11 +9,11 @@ import Foundation -protocol DisplaySecretKey { +protocol DisplayKey { var importDate: Date { get } - var keyID: String? { + var keyID: String { get } var pgpKey: Key? { @@ -22,7 +22,8 @@ protocol DisplaySecretKey { func save() -> SecretKey? } -class TempKey: DisplaySecretKey { +class TempKey: DisplayKey { + var pgpkey: Key let mailAddresses: [String] let importDate: Date @@ -46,7 +47,7 @@ class TempKey: DisplaySecretKey { } } - var keyID: String? { + var keyID: String { get { return pgpkey.keyID.longIdentifier } @@ -100,27 +101,45 @@ class TempKey: DisplaySecretKey { } } -extension SecretKey: DisplaySecretKey { +extension SecretKey: DisplayKey { var importDate: Date { if let date = self.importedDate { - return date + return date as Date } let date = Date.init() - self.importedDate = date + self.importedDate = date as NSDate return date } var pgpKey: Key? { let pgp = SwiftPGP() - if let id = keyID { - return pgp.loadKey(id: id) - } - return nil + let id = keyID + return pgp.loadKey(id: id) } func save() -> SecretKey? { return self } +} + +extension PersistentKey: DisplayKey { + var importDate: Date { + if let date = self.discoveryDate { + return date + } + else { + let date = Date() + self.discoveryDate = date + return date + } + } + var pgpKey: Key? { + let pgp = SwiftPGP() + return pgp.loadKey(id: keyID) + } + func save() -> SecretKey? { + return nil + } } diff --git a/enzevalos_iphone/TravelHandler.swift b/enzevalos_iphone/TravelHandler.swift index 3d1aa9f3a58b26abf3463276fb95aabb6712475e..52490232f4503d4cd7d5fead5a7418c225195057 100644 --- a/enzevalos_iphone/TravelHandler.swift +++ b/enzevalos_iphone/TravelHandler.swift @@ -296,7 +296,7 @@ public class TravelHandler { if let fingerprint = DataHandler.handler.getMailAddress(UserManager.loadUserValue(Attribute.userAddr) as! String, temporary: true).primaryKey!.currentlyActiveKey.fingerprint { oldFingerprint = fingerprint } - let keyID = DataHandler.handler.createNewSecretKey(adr: UserManager.loadUserValue(Attribute.userAddr) as! String).keyID! + let keyID = DataHandler.handler.createNewSecretKey(adr: UserManager.loadUserValue(Attribute.userAddr) as! String).keyID let pubKey = pgp.exportKey(id: keyID, isSecretkey: false, autocrypt: false)! let sharedSecrets = try traveler.getToSend() for c in traveler.contacts { @@ -333,7 +333,7 @@ public class TravelHandler { if let fingerprint = DataHandler.handler.getMailAddress(UserManager.loadUserValue(Attribute.userAddr) as! String, temporary: true).primaryKey!.currentlyActiveKey.fingerprint { oldFingerprint = fingerprint } - let keyID = DataHandler.handler.createNewSecretKey(adr: UserManager.loadUserValue(Attribute.userAddr) as! String).keyID! + let keyID = DataHandler.handler.createNewSecretKey(adr: UserManager.loadUserValue(Attribute.userAddr) as! String).keyID let pubKey = pgp.exportKey(id: keyID, isSecretkey: false, autocrypt: false)! let traveler: Traveler if let data = travelerStored { diff --git a/enzevalos_iphone/enzevalos_iphone.xcdatamodeld/.xccurrentversion b/enzevalos_iphone/enzevalos_iphone.xcdatamodeld/.xccurrentversion index 756dc7ebbf3da6381d976322c4037d2914d39d55..b24719e7c69bc07e985d15759e78b50ea73a1a2e 100644 --- a/enzevalos_iphone/enzevalos_iphone.xcdatamodeld/.xccurrentversion +++ b/enzevalos_iphone/enzevalos_iphone.xcdatamodeld/.xccurrentversion @@ -3,6 +3,6 @@ <plist version="1.0"> <dict> <key>_XCCurrentVersionName</key> - <string>enzevalos_iphone 7.xcdatamodel</string> + <string>enzevalos_iphone 8.xcdatamodel</string> </dict> </plist> diff --git a/enzevalos_iphone/enzevalos_iphone.xcdatamodeld/enzevalos_iphone 7.xcdatamodel/contents b/enzevalos_iphone/enzevalos_iphone.xcdatamodeld/enzevalos_iphone 7.xcdatamodel/contents index 3ad3b609a85dfff4d01c906061b24d6654d9892a..207b917da1b01e4d0f3e94c76a26007517fbe341 100644 --- a/enzevalos_iphone/enzevalos_iphone.xcdatamodeld/enzevalos_iphone 7.xcdatamodel/contents +++ b/enzevalos_iphone/enzevalos_iphone.xcdatamodeld/enzevalos_iphone 7.xcdatamodel/contents @@ -143,7 +143,7 @@ <entity name="SecretKey" representedClassName="SecretKey" syncable="YES" codeGenerationType="class"> <attribute name="exported" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/> <attribute name="importedDate" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/> - <attribute name="keyID" optional="YES" attributeType="String" syncable="YES"/> + <attribute name="keyID" optional="YES" attributeType="String" defaultValueString="nil" syncable="YES"/> <attribute name="obsolete" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/> <relationship name="account" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Account" inverseName="keys" inverseEntity="Account" syncable="YES"/> <relationship name="decryptedMails" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PersistentMail" inverseName="decryptedKey" inverseEntity="PersistentMail" syncable="YES"/> @@ -168,7 +168,7 @@ <element name="Mail_Address" positionX="-297" positionY="-18" width="128" height="210"/> <element name="PersistentKey" positionX="-315" positionY="-36" width="128" height="390"/> <element name="PersistentMail" positionX="-416" positionY="-189" width="128" height="30"/> - <element name="SecretKey" positionX="-306" positionY="-27" width="128" height="135"/> + <element name="SecretKey" positionX="-306" positionY="-27" width="128" height="133"/> <element name="Server" positionX="-306" positionY="-27" width="128" height="135"/> </elements> </model> \ No newline at end of file diff --git a/enzevalos_iphone/enzevalos_iphone.xcdatamodeld/enzevalos_iphone 8.xcdatamodel/contents b/enzevalos_iphone/enzevalos_iphone.xcdatamodeld/enzevalos_iphone 8.xcdatamodel/contents new file mode 100644 index 0000000000000000000000000000000000000000..2598362e58ff0627acd08d8eb6e84cdfcef305b4 --- /dev/null +++ b/enzevalos_iphone/enzevalos_iphone.xcdatamodeld/enzevalos_iphone 8.xcdatamodel/contents @@ -0,0 +1,176 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="14490.99" systemVersion="18G95" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier=""> + <entity name="Account" representedClassName="Account" syncable="YES" codeGenerationType="class"> + <attribute name="archiveFolderPath" attributeType="String" syncable="YES"/> + <attribute name="displayName" attributeType="String" syncable="YES"/> + <attribute name="draftFolderPath" attributeType="String" syncable="YES"/> + <attribute name="inboxFolderPath" attributeType="String" syncable="YES"/> + <attribute name="loginName" attributeType="String" syncable="YES"/> + <attribute name="prefEnc" optional="YES" attributeType="String" syncable="YES"/> + <attribute name="prefMailAdr" optional="YES" attributeType="String" syncable="YES"/> + <attribute name="prefSecretKeyID" optional="YES" attributeType="String" syncable="YES"/> + <attribute name="sentFolderPath" attributeType="String" syncable="YES"/> + <attribute name="trashFolderPath" attributeType="String" syncable="YES"/> + <relationship name="aliase" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Mail_Address" inverseName="account" inverseEntity="Mail_Address" syncable="YES"/> + <relationship name="imap" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Server" inverseName="imap" inverseEntity="Server" syncable="YES"/> + <relationship name="keys" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="SecretKey" inverseName="account" inverseEntity="SecretKey" syncable="YES"/> + <relationship name="smtp" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Server" inverseName="smtp" inverseEntity="Server" syncable="YES"/> + </entity> + <entity name="Attachment" representedClassName="Attachment" syncable="YES" codeGenerationType="class"> + <attribute name="contentID" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/> + <attribute name="data" attributeType="Binary" syncable="YES"/> + <attribute name="encryptionState" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/> + <attribute name="isExplicitAttachment" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/> + <attribute name="mcoPartType" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/> + <attribute name="mimeType" attributeType="String" syncable="YES"/> + <attribute name="name" attributeType="String" syncable="YES"/> + <attribute name="signatureState" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/> + <relationship name="mail" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="PersistentMail" inverseName="attachments" inverseEntity="PersistentMail" syncable="YES"/> + <relationship name="parentOf" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Attachment" inverseName="partOf" inverseEntity="Attachment" syncable="YES"/> + <relationship name="partOf" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Attachment" inverseName="parentOf" inverseEntity="Attachment" syncable="YES"/> + </entity> + <entity name="EnzevalosContact" representedClassName="EnzevalosContact" syncable="YES"> + <attribute name="cnidentifier" optional="YES" attributeType="String" syncable="YES"/> + <attribute name="color" optional="YES" attributeType="Transformable" customClassName="UIColor" syncable="YES"/> + <attribute name="displayname" attributeType="String" syncable="YES"/> + <relationship name="addresses" toMany="YES" deletionRule="Cascade" destinationEntity="Mail_Address" inverseName="contact" inverseEntity="Mail_Address" syncable="YES"/> + <relationship name="keyrecords" optional="YES" toMany="YES" deletionRule="Cascade" destinationEntity="KeyRecord" inverseName="contact" inverseEntity="KeyRecord" syncable="YES"/> + </entity> + <entity name="Folder" representedClassName="Folder" syncable="YES"> + <attribute name="delimiter" optional="YES" attributeType="String" syncable="YES"/> + <attribute name="flags" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/> + <attribute name="icon" optional="YES" attributeType="String" syncable="YES"/> + <attribute name="lastUpdate" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/> + <attribute name="maxID" optional="YES" attributeType="Decimal" defaultValueString="1" syncable="YES"/> + <attribute name="minUID" optional="YES" attributeType="Decimal" defaultValueString="0.0" syncable="YES"/> + <attribute name="path" attributeType="String" syncable="YES"/> + <attribute name="pseudonym" attributeType="String" syncable="YES"/> + <attribute name="uidvalidity" optional="YES" attributeType="Decimal" defaultValueString="0.0" syncable="YES"/> + <relationship name="keyRecords" optional="YES" toMany="YES" deletionRule="Nullify" ordered="YES" destinationEntity="KeyRecord" inverseName="folder" inverseEntity="KeyRecord" syncable="YES"/> + <relationship name="mails" optional="YES" toMany="YES" deletionRule="Nullify" ordered="YES" destinationEntity="PersistentMail" inverseName="folder" inverseEntity="PersistentMail" syncable="YES"/> + <relationship name="parent" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Folder" inverseName="subfolder" inverseEntity="Folder" syncable="YES"/> + <relationship name="subfolder" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Folder" inverseName="parent" inverseEntity="Folder" syncable="YES"/> + </entity> + <entity name="KeyRecord" representedClassName="KeyRecord" syncable="YES"> + <attribute name="newestDate" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/> + <attribute name="nick" optional="YES" attributeType="String" syncable="YES"/> + <relationship name="contact" maxCount="1" deletionRule="Nullify" destinationEntity="EnzevalosContact" inverseName="keyrecords" inverseEntity="EnzevalosContact" syncable="YES"/> + <relationship name="folder" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Folder" inverseName="keyRecords" inverseEntity="Folder" syncable="YES"/> + <relationship name="key" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="PersistentKey" inverseName="record" inverseEntity="PersistentKey" syncable="YES"/> + <relationship name="persistentMails" optional="YES" toMany="YES" deletionRule="Nullify" ordered="YES" destinationEntity="PersistentMail" inverseName="record" inverseEntity="PersistentMail" syncable="YES"/> + </entity> + <entity name="Mail_Address" representedClassName="Mail_Address" syncable="YES"> + <attribute name="address" attributeType="String" defaultValueString="""" syncable="YES"/> + <attribute name="invitations" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/> + <attribute name="primaryKeyID" optional="YES" attributeType="String" syncable="YES"/> + <attribute name="pseudonym" attributeType="String" syncable="YES"/> + <relationship name="account" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Account" inverseName="aliase" inverseEntity="Account" syncable="YES"/> + <relationship name="bcc" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PersistentMail" inverseName="bcc" inverseEntity="PersistentMail" syncable="YES"/> + <relationship name="cc" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PersistentMail" inverseName="cc" inverseEntity="PersistentMail" syncable="YES"/> + <relationship name="contact" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="EnzevalosContact" inverseName="addresses" inverseEntity="EnzevalosContact" syncable="YES"/> + <relationship name="from" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PersistentMail" inverseName="from" inverseEntity="PersistentMail" syncable="YES"/> + <relationship name="keys" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PersistentKey" inverseName="mailaddress" inverseEntity="PersistentKey" syncable="YES"/> + <relationship name="to" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PersistentMail" inverseName="to" inverseEntity="PersistentMail" syncable="YES"/> + </entity> + <entity name="PersistentKey" representedClassName="PersistentKey" syncable="YES"> + <attribute name="autocryptGossip" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/> + <attribute name="discoveryDate" attributeType="Date" usesScalarValueType="NO" syncable="YES"/> + <attribute name="encryptionType" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/> + <attribute name="gossip_timestamp" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/> + <attribute name="gotFailedCallForUse" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/> + <attribute name="isMisstrusted" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/> + <attribute name="isRepealed" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/> + <attribute name="keyID" attributeType="String" syncable="YES"/> + <attribute name="lastSeen" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/> + <attribute name="lastSeenAutocrypt" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/> + <attribute name="origin" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/> + <attribute name="preferEncryption" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/> + <attribute name="pseudonym" attributeType="String" syncable="YES"/> + <attribute name="sentOwnPublicKey" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/> + <attribute name="verifiedDate" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/> + <relationship name="activeKey" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="PersistentKey" syncable="YES"/> + <relationship name="activeRepeal" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="PersistentMail" syncable="YES"/> + <relationship name="childKeys" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PersistentKey" inverseName="parentKey" inverseEntity="PersistentKey" syncable="YES"/> + <relationship name="firstMail" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="PersistentMail" inverseName="attachedKeys" inverseEntity="PersistentMail" syncable="YES"/> + <relationship name="mailaddress" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Mail_Address" inverseName="keys" inverseEntity="Mail_Address" syncable="YES"/> + <relationship name="parentKey" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="PersistentKey" inverseName="childKeys" inverseEntity="PersistentKey" syncable="YES"/> + <relationship name="record" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="KeyRecord" inverseName="key" inverseEntity="KeyRecord" syncable="YES"/> + <relationship name="repealedByMails" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PersistentMail" inverseName="repealsKey" inverseEntity="PersistentMail" syncable="YES"/> + <relationship name="signedMails" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PersistentMail" inverseName="signedKey" inverseEntity="PersistentMail" syncable="YES"/> + </entity> + <entity name="PersistentMail" representedClassName="PersistentMail" syncable="YES"> + <attribute name="body" optional="YES" attributeType="String" syncable="YES"/> + <attribute name="date" attributeType="Date" defaultDateTimeInterval="-31582140" usesScalarValueType="NO" syncable="YES"/> + <attribute name="decryptedBody" optional="YES" attributeType="String" syncable="YES"/> + <attribute name="decrytionCode" optional="YES" attributeType="String" syncable="YES"/> + <attribute name="deleteWhileTravel" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/> + <attribute name="encryptedBody" optional="YES" attributeType="String" syncable="YES"/> + <attribute name="flag" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/> + <attribute name="gmailMessageID" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/> + <attribute name="gmailThreadID" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/> + <attribute name="isCorrectlySigned" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/> + <attribute name="isEncrypted" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/> + <attribute name="isSigned" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/> + <attribute name="keyID" optional="YES" attributeType="String" syncable="YES"/> + <attribute name="messageID" optional="YES" attributeType="String" syncable="YES"/> + <attribute name="modSeqValue" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/> + <attribute name="notLoadedMessageIDs" optional="YES" attributeType="String" syncable="YES"/> + <attribute name="received" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES" syncable="YES"/> + <attribute name="secretKey" optional="YES" attributeType="String" syncable="YES"/> + <attribute name="storeEncrypted" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/> + <attribute name="subject" attributeType="String" syncable="YES"/> + <attribute name="trouble" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/> + <attribute name="uid" attributeType="Decimal" defaultValueString="0" syncable="YES"/> + <attribute name="uidvalidity" optional="YES" attributeType="Decimal" defaultValueString="0.0" syncable="YES"/> + <attribute name="unableToDecrypt" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/> + <attribute name="visibleBody" optional="YES" attributeType="String" syncable="YES"/> + <attribute name="xMailer" optional="YES" attributeType="String" syncable="YES"/> + <relationship name="attachedKeys" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PersistentKey" inverseName="firstMail" inverseEntity="PersistentKey" syncable="YES"/> + <relationship name="attachments" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Attachment" inverseName="mail" inverseEntity="Attachment" syncable="YES"/> + <relationship name="bcc" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Mail_Address" inverseName="bcc" inverseEntity="Mail_Address" syncable="YES"/> + <relationship name="cc" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Mail_Address" inverseName="cc" inverseEntity="Mail_Address" syncable="YES"/> + <relationship name="decryptedKey" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="SecretKey" inverseName="decryptedMails" inverseEntity="SecretKey" syncable="YES"/> + <relationship name="folder" maxCount="1" deletionRule="Nullify" destinationEntity="Folder" inverseName="mails" inverseEntity="Folder" syncable="YES"/> + <relationship name="from" maxCount="1" deletionRule="Nullify" destinationEntity="Mail_Address" inverseName="from" inverseEntity="Mail_Address" syncable="YES"/> + <relationship name="record" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="KeyRecord" inverseName="persistentMails" inverseEntity="KeyRecord" syncable="YES"/> + <relationship name="referenceMails" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="PersistentMail" inverseName="referenceMails" inverseEntity="PersistentMail" syncable="YES"/> + <relationship name="repealsKey" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="PersistentKey" inverseName="repealedByMails" inverseEntity="PersistentKey" syncable="YES"/> + <relationship name="signedKey" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="PersistentKey" inverseName="signedMails" inverseEntity="PersistentKey" syncable="YES"/> + <relationship name="to" toMany="YES" deletionRule="Nullify" destinationEntity="Mail_Address" inverseName="to" inverseEntity="Mail_Address" syncable="YES"/> + <fetchIndex name="byDateIndex"> + <fetchIndexElement property="date" type="Binary" order="ascending"/> + </fetchIndex> + </entity> + <entity name="SecretKey" representedClassName="SecretKey" syncable="YES"> + <attribute name="exported" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/> + <attribute name="importedDate" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/> + <attribute name="keyID" attributeType="String" defaultValueString="no" syncable="YES"/> + <attribute name="obsolete" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/> + <attribute name="origin" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/> + <relationship name="account" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Account" inverseName="keys" inverseEntity="Account" syncable="YES"/> + <relationship name="decryptedMails" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PersistentMail" inverseName="decryptedKey" inverseEntity="PersistentMail" syncable="YES"/> + </entity> + <entity name="Server" representedClassName="Server" syncable="YES" codeGenerationType="class"> + <attribute name="authType" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/> + <attribute name="connectionType" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/> + <attribute name="hostname" attributeType="String" syncable="YES"/> + <attribute name="port" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/> + <relationship name="imap" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Account" inverseName="imap" inverseEntity="Account" syncable="YES"/> + <relationship name="smtp" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Account" inverseName="smtp" inverseEntity="Account" syncable="YES"/> + </entity> + <fetchRequest name="allKeyRecords" entity="KeyRecord" predicateString="NOT (FALSEPREDICATE)" returnDistinctResults="YES"/> + <fetchRequest name="getFolder" entity="Folder" predicateString="name == "$folder""/> + <fetchRequest name="getMailAddress" entity="Mail_Address" predicateString="address == "$adr""/> + <elements> + <element name="Account" positionX="-315" positionY="-36" width="128" height="255"/> + <element name="Attachment" positionX="-315" positionY="-36" width="128" height="210"/> + <element name="EnzevalosContact" positionX="-209" positionY="198" width="128" height="120"/> + <element name="Folder" positionX="-297" positionY="-18" width="128" height="240"/> + <element name="KeyRecord" positionX="-315" positionY="-36" width="128" height="135"/> + <element name="Mail_Address" positionX="-297" positionY="-18" width="128" height="210"/> + <element name="PersistentKey" positionX="-315" positionY="-36" width="128" height="405"/> + <element name="PersistentMail" positionX="-416" positionY="-189" width="128" height="30"/> + <element name="SecretKey" positionX="-306" positionY="-27" width="128" height="150"/> + <element name="Server" positionX="-306" positionY="-27" width="128" height="135"/> + </elements> +</model> \ No newline at end of file diff --git a/enzevalos_iphone/mail/IncomingMail.swift b/enzevalos_iphone/mail/IncomingMail.swift index 7697ba252f8b52a5d69d792db8bf24b725968fe1..9289b0724540f8ce5c889a05b3324c83acc1b78a 100644 --- a/enzevalos_iphone/mail/IncomingMail.swift +++ b/enzevalos_iphone/mail/IncomingMail.swift @@ -192,9 +192,7 @@ class IncomingMail { let secretkeys = DataHandler.handler.findSecretKeys() var decIds = [String]() for sk in secretkeys { - if let id = sk.keyID { - decIds.append(id) - } + decIds.append(sk.keyID) } return decIds } @@ -510,9 +508,7 @@ class IncomingMail { let secretkeys = DataHandler.handler.findSecretKeys() var decIds = [String]() for sk in secretkeys { - if let id = sk.keyID { - decIds.append(id) - } + decIds.append(sk.keyID ) } return pgp.decrypt(data: data, decKeyIDs: decIds, signatureIDs: keyIds, fromAddr: sender ?? "")