merge default IOS-1628
authorDirk Zimmermann <dz@pep.security>
Tue, 11 Jun 2019 06:47:56 +0200
branchIOS-1628
changeset 8969e90c044aaccb
parent 8967 16624ad559fb
parent 8968 d4c60d2954e2
child 9100 6be6961b0c39
merge default
     1.1 --- a/pEpForiOS/UI/EmailDisplay/EmailViewController.swift	Fri Jun 07 16:33:04 2019 +0200
     1.2 +++ b/pEpForiOS/UI/EmailDisplay/EmailViewController.swift	Tue Jun 11 06:47:56 2019 +0200
     1.3 @@ -424,6 +424,7 @@
     1.4          }
     1.5          Message.imapDelete(messages: [message])
     1.6          delegate?.emailDisplayDidDelete(message: message)
     1.7 +        navigationController?.popViewController(animated: true)
     1.8      }
     1.9  
    1.10      /**
     2.1 --- a/pEpForiOS/Util/IdentityImageTool.swift	Fri Jun 07 16:33:04 2019 +0200
     2.2 +++ b/pEpForiOS/Util/IdentityImageTool.swift	Tue Jun 11 06:47:56 2019 +0200
     2.3 @@ -64,85 +64,10 @@
     2.4          IdentityImageTool.imageCache.removeAll()
     2.5      }
     2.6  
     2.7 -    //    func cachedIdentityImage(for identity: Identity) -> UIImage? { //!!!: cleanup
     2.8 -//        var searchKey: IdentityKey? = nil
     2.9 -//        let session = Session()
    2.10 -//        session.performAndWait {
    2.11 -//            let safeIdentity = identity.safeForSession(session)
    2.12 -//            searchKey = IdentityKey(identity: safeIdentity)
    2.13 -//        }
    2.14 -//        guard let key = searchKey else {
    2.15 -//            return nil
    2.16 -//        }
    2.17 -//        return IdentityImageTool.imageCache[key]
    2.18 -//    }
    2.19 -
    2.20      func cachedIdentityImage(for key: IdentityKey) -> UIImage? {
    2.21          return IdentityImageTool.imageCache[key]
    2.22      }
    2.23  
    2.24 -    /// Creates (and caches) the contact image to display for an identity.
    2.25 -    /// This is a possibly time consuming process and shold not be called from the main thread.
    2.26 -    ///
    2.27 -    /// - Parameters:
    2.28 -    ///   - identity: identity to create contact image to doisplay for
    2.29 -    ///   - imageSize: size of the image to create
    2.30 -    ///   - textColor: text color to use in case the resulting images contains the users initials
    2.31 -    ///   - backgroundColor: backgroundcolor to use in case the resulting images contains
    2.32 -    ///     the users initials
    2.33 -    /// - Returns: contact image to display
    2.34 -//    func identityImage(for identity: Identity, //!!!: cleanup
    2.35 -//                       imageSize: CGSize = CGSize.defaultAvatarSize,
    2.36 -//                       textColor: UIColor = UIColor.white,
    2.37 -//                       backgroundColor: UIColor = UIColor(hexString: "#c8c7cc")) -> UIImage? {
    2.38 -//        if let cachedImage = cachedIdentityImage(for: identity) {
    2.39 -//            // We have the image in cache. Return it.
    2.40 -//            return cachedImage
    2.41 -//        }
    2.42 -//
    2.43 -//        var image:UIImage?
    2.44 -//
    2.45 -//        let session = Session()
    2.46 -//        let safeIdentity = identity.safeForSession(session)
    2.47 -//        session.performAndWait { [weak self] in
    2.48 -//
    2.49 -//
    2.50 -//            guard let me = self else {
    2.51 -//                Log.shared.errorAndCrash(component: #function, errorString: "Lost myself")
    2.52 -//                return
    2.53 -//            }
    2.54 -//
    2.55 -//            if let addressBookID = safeIdentity.addressBookID {
    2.56 -//                // Get image from system AddressBook if any
    2.57 -//                let ab = AddressBook()
    2.58 -//                if let contact = ab.contactBy(addressBookID: addressBookID),
    2.59 -//                    let imgData = contact.thumbnailImageData {
    2.60 -//                    image = UIImage(data: imgData)
    2.61 -//                }
    2.62 -//            }
    2.63 -//
    2.64 -//            if image == nil {
    2.65 -//                // We cound not find an image anywhere. Let's create one with the initials
    2.66 -//                var initials = "?"
    2.67 -//                if let userName = safeIdentity.userName {
    2.68 -//                    initials = userName.initials()
    2.69 -//                } else {
    2.70 -//                    let namePart = safeIdentity.address.namePartOfEmail()
    2.71 -//                    initials = namePart.initials()
    2.72 -//                }
    2.73 -//                image =  me.identityImageFromName(initials: initials,
    2.74 -//                                              size: imageSize,
    2.75 -//                                              textColor: textColor,
    2.76 -//                                              imageBackgroundColor: backgroundColor)
    2.77 -//            }
    2.78 -//            if let safeImage = image {
    2.79 -//                // cache image
    2.80 -//                let saveKey = IdentityKey(identity: safeIdentity)
    2.81 -//                IdentityImageTool.imageCache[saveKey] = safeImage
    2.82 -//            }
    2.83 -//        }
    2.84 -//        return image
    2.85 -//    }
    2.86  
    2.87      func identityImage(for identityKey: IdentityKey,
    2.88                         imageSize: CGSize = CGSize.defaultAvatarSize,
     3.1 --- a/pEpForiOSTests/Models/SetOwnKeyViewModelTests.swift	Fri Jun 07 16:33:04 2019 +0200
     3.2 +++ b/pEpForiOSTests/Models/SetOwnKeyViewModelTests.swift	Tue Jun 11 06:47:56 2019 +0200
     3.3 @@ -127,10 +127,7 @@
     3.4          let attachments = theCdMessage.attachments?.array as? [CdAttachment] ?? []
     3.5          XCTAssertEqual(attachments.count, 0)
     3.6  
     3.7 -        guard let msg = theCdMessage.message() else {
     3.8 -            XCTFail()
     3.9 -            return
    3.10 -        }
    3.11 +        let msg = MessageModelObjectUtils.getMessage(fromCdMessage: theCdMessage)
    3.12  
    3.13          XCTAssertEqual(msg.attachments.count, 0)
    3.14  
     4.1 --- a/pEpForiOSTests/TestUtils/Message+TestUtils.swift	Fri Jun 07 16:33:04 2019 +0200
     4.2 +++ b/pEpForiOSTests/TestUtils/Message+TestUtils.swift	Tue Jun 11 06:47:56 2019 +0200
     4.3 @@ -55,7 +55,9 @@
     4.4          let pFolder =
     4.5              CdMessage.PredicateFactory.belongingToParentFolderNamed(parentFolderName: folderName)
     4.6          let p = NSCompoundPredicate(andPredicateWithSubpredicates: [pAccount, pUid, pFolder])
     4.7 -        let cdMessage = CdMessage.all(predicate: p)?.first as? CdMessage
     4.8 -        return cdMessage?.message()
     4.9 +        guard let cdMessage = CdMessage.all(predicate: p)?.first as? CdMessage else {
    4.10 +            return nil
    4.11 +        }
    4.12 +        return MessageModelObjectUtils.getMessage(fromCdMessage: cdMessage)
    4.13      }
    4.14  }
     5.1 --- a/pEpForiOSTests/TestUtils/TestUtil.swift	Fri Jun 07 16:33:04 2019 +0200
     5.2 +++ b/pEpForiOSTests/TestUtils/TestUtil.swift	Tue Jun 11 06:47:56 2019 +0200
     5.3 @@ -710,14 +710,16 @@
     5.4      static func setUpPepFromMail(emailFilePath: String,
     5.5                                   decryptDelegate: DecryptMessagesOperationDelegateProtocol? = nil)
     5.6          -> (mySelf: Identity, partner: Identity, message: Message)? {
     5.7 -            if let (mySelfID, partnerID, message) = cdMessageAndSetUpPepFromMail(
     5.8 -                emailFilePath: emailFilePath, decryptDelegate: decryptDelegate),
     5.9 -                let msg = message.message(),
    5.10 +            guard
    5.11 +                let (mySelfID, partnerID, cdMessage) = cdMessageAndSetUpPepFromMail(
    5.12 +                    emailFilePath: emailFilePath, decryptDelegate: decryptDelegate),
    5.13                  let mySelf = mySelfID.identity(),
    5.14 -                let partner = partnerID.identity() {
    5.15 -                return (mySelf: mySelf, partner: partner, message: msg)
    5.16 +                let partner = partnerID.identity()
    5.17 +                else {
    5.18 +                    return nil
    5.19              }
    5.20 -            return nil
    5.21 +            let msg = MessageModelObjectUtils.getMessage(fromCdMessage: cdMessage)
    5.22 +            return (mySelf: mySelf, partner: partner, message: msg)
    5.23      }
    5.24  
    5.25      /**