From ea3ae8f87a9270f6304049f3bfb7a5326d113b16 Mon Sep 17 00:00:00 2001 From: Oliver Wiese <oliver.wiese@fu-berlin.de> Date: Fri, 28 Feb 2020 11:52:55 +0100 Subject: [PATCH] fix some warnings remove print add: Store decrypted body --- enzevalos_iphone/SendViewController.swift | 2 +- enzevalos_iphone/SwiftPGP.swift | 9 ++++----- enzevalos_iphone/TempAttachment.swift | 7 ++++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/enzevalos_iphone/SendViewController.swift b/enzevalos_iphone/SendViewController.swift index ebab5f5d..c8e2f513 100644 --- a/enzevalos_iphone/SendViewController.swift +++ b/enzevalos_iphone/SendViewController.swift @@ -528,7 +528,7 @@ class SendViewController: UIViewController { self.view.layoutIfNeeded() }, completion: nil) } else { - var info = notification.userInfo! + let info = notification.userInfo! let keyboardFrame: CGRect = (info[UIResponder.keyboardFrameEndUserInfoKey] as! NSValue).cgRectValue keyboardY = keyboardFrame.origin.y if keyboardHeight == 0 { diff --git a/enzevalos_iphone/SwiftPGP.swift b/enzevalos_iphone/SwiftPGP.swift index 4dd72c7c..06791d2c 100644 --- a/enzevalos_iphone/SwiftPGP.swift +++ b/enzevalos_iphone/SwiftPGP.swift @@ -606,18 +606,17 @@ class SwiftPGP: Encryption { let datahandler = DataHandler.handler let mailList = datahandler.getAllNotDecryptedPersistentMail() for mail in mailList { - guard var data = mail.body?.data(using: String.Encoding.utf8, allowLossyConversion: true) + guard let data = mail.body?.data(using: String.Encoding.utf8, allowLossyConversion: true) else { return } // try to decrypt mail (plaindata, encState) = decryptMessage(data: data, keys: key, encForCurrentSK: true) - if encState == EncryptionState.ValidedEncryptedWithCurrentKey { - print("Mail was succesfully encrypted") + if let plaindata = plaindata, encState == EncryptionState.ValidedEncryptedWithCurrentKey || encState == EncryptionState.ValidEncryptedWithOldKey { // update database + mail.body = String.init(data: plaindata, encoding: .utf8) mail.isEncrypted = true - datahandler.save(during: "") - + datahandler.save(during: "decryption of older mails") } } } diff --git a/enzevalos_iphone/TempAttachment.swift b/enzevalos_iphone/TempAttachment.swift index 710201b4..2877cc85 100644 --- a/enzevalos_iphone/TempAttachment.swift +++ b/enzevalos_iphone/TempAttachment.swift @@ -39,8 +39,6 @@ enum MIMETYPE: String { class TempAttachment: Hashable { - var hashValue: Int - var name: String var data: Data var mimeType: MIMETYPE @@ -54,7 +52,6 @@ class TempAttachment: Hashable { self.mimeType = mimeType self.encState = encState self.sigState = sigState - self.hashValue = (name+mimeType.rawValue).hashValue } func store(mail: PersistentMail) { @@ -71,4 +68,8 @@ class TempAttachment: Hashable { } return false } + + func hash(into hasher: inout Hasher) { + hasher.combine((name+mimeType.rawValue).hashValue) + } } -- GitLab