Commit 44525a89 authored by Oliver Wiese's avatar Oliver Wiese

Update protocols

parent e83706ef
......@@ -141,7 +141,7 @@ extension KeyRecord: DisplayContact {
return self.addressNames
}
var keys: [String] {
var keyIDs: [String] {
if let id = self.keyID {
return [id]
}
......
......@@ -20,6 +20,7 @@
//
import Foundation
import SwiftUI
import CoreData
extension Mail_Address {
......@@ -154,3 +155,78 @@ extension Mail_Address {
@NSManaged private func removeFromKeys(_ values: NSSet)
}
extension Mail_Address: DisplayContact {
var name: String {
if let contact = self.contact {
return contact.name
}
return self.addr
}
var addr: String {
return self.address
}
var myImage: Image {
if let contact = self.contact {
return Image(uiImage: contact.getImageOrDefault())
}
let color = UIColor(hue: CGFloat(addr.hashValue) / CGFloat(UINT32_MAX), saturation: 1, brightness: 0.75, alpha: 1)
return PseudoContact.makeImg(addr, color: color)
}
var isInContactBook: Bool {
if let con = self.contact {
return con.cnContact != nil
}
return false
}
var otherAddresses: [String] {
if let con = contact {
return con.getMailAddresses().map({$0.mailAddress})
}
return []
}
var keyIDs: [String] {
let pks = self.publicKeys.map({$0.keyID})
return pks
}
var previousMails: Int {
if let from = from {
return from.count
}
return 0
}
var previousResponses: Int {
var responses = 0
if let to = self.to {
responses += to.count
}
if let cc = self.cc {
responses += cc.count
}
if let bcc = self.bcc {
responses += bcc.count
}
return responses
}
var hasSimilarContacts: Bool {
return false
}
var similarContacts: [String] {
return []
}
var keyRecord: KeyRecord? {
return DataHandler.handler.getKeyRecord(addr: addr, keyID: self.primaryKeyID, saveRecord: false)
}
}
......@@ -420,22 +420,22 @@ extension PersistentMail {
extension PersistentMail: DisplayMail {
typealias C = KeyRecord
typealias C = Mail_Address
var sender: C {
return self.record!
return self.from as! PersistentMail.C
}
var tos: [C] {
return [self.record!,self.record!,self.record!]
return self.getReceivers()
}
var ccs: [C] {
return [self.record!,self.record!,self.record!] // TODO
return self.getCCs()// TODO
}
var bccs: [C] {
return [self.record!,self.record!,self.record!] // TODO
return self.getBCCs()
}
var routingStops: [Landmark] {
......
......@@ -65,7 +65,7 @@ protocol DisplayContact {
var otherAddresses: [String] { get }
// Crypto related
var keys: [String] { get }
var keyIDs: [String] { get }
// Phishing related
var previousMails: Int { get }
......@@ -283,7 +283,7 @@ extension DisplayMail {
case (_, .UnableToDecrypt), (_, .InvalidSignature) , (_, .PlainMissingPublicKeyToVerify), (_, .EncButMissingPublicKeyToVerify):
result.append(dialog) // warning required
}
if self.sender.keys.count > 0 && self.signedState == .NoSignature {
if self.sender.keyIDs.count > 0 && self.signedState == .NoSignature {
let icon = Image(systemName: "exclamationmark.triangl.fill")
let missingSignature = DialogStruct(dialogColor: Color(ThemeManager.unencryptedMessageColor()),
title: NSLocalizedString("encryptedBeforeHeadline",
......
......@@ -76,7 +76,7 @@ struct PseudoContact: DisplayContact {
var otherAddresses: [String] = []
var keys: [String] = ["ABC"]
var keyIDs: [String] = ["ABC"]
var hasPreviousMails: Bool = false
......
......@@ -88,7 +88,7 @@ class ReadViewCoordinator {
let vc = mainStoryboard.instantiateViewController(identifier: ViewID.ComposeView.rawValue)
var prefilledMail: EphemeralMail?
if let subject = subject, let body = body, let responseType = responseType {
prefilledMail = EphemeralMail(to: NSSet(object: to), cc: NSSet(object: cc), bcc: NSSet(object: bcc), date: Date(), subject: responseType.addPrefix(subject: subject), body: body, uid: 0, predecessor: nil)
prefilledMail = EphemeralMail(to: NSSet.init(array: to), cc: NSSet.init(array: cc), bcc: NSSet.init(array: bcc), date: Date(), subject: responseType.addPrefix(subject: subject), body: body, uid: 0, predecessor: nil)
}
if let vc = vc as? SendViewController {
vc.wasPushed = true
......@@ -165,7 +165,7 @@ class ReadViewCoordinator {
to.append(contentsOf: findPersisentContact(persons: mail.ccs))
to.append(contentsOf: findPersisentContact(persons: mail.tos))
to = to.filter({!$0.hasKey})
pushComposeView(to: to, cc: [], bcc: [], subject: subject, body: body, responseType: .none)
pushComposeView(to: to, cc: [], bcc: [], subject: subject, body: body, responseType: .Reply)
}
......
......@@ -50,7 +50,6 @@ struct SmallContactListView <C: DisplayContact>: View {
self.goToContact(contact: contact)
}
}
}
}
.padding(10)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment