dito
authorHern?ni Marques <hernani@pep-project.org>
Tue, 25 Oct 2016 01:34:01 +0200
changeset 86664469bc6c9a2
parent 865 85266cc78f4f
child 869 c3e6646e724f
dito
pEpForiOS/Background/PersistentImapFolder.swift
pEpForiOS/Background/PrefetchEmailsOperation.swift
pEpForiOS/Models/CdAccount+Extension.swift
pEpForiOS/Network/EmailConnectInfo.swift
     1.1 --- a/pEpForiOS/Background/PersistentImapFolder.swift	Tue Oct 25 00:48:01 2016 +0200
     1.2 +++ b/pEpForiOS/Background/PersistentImapFolder.swift	Tue Oct 25 01:34:01 2016 +0200
     1.3 @@ -17,7 +17,7 @@
     1.4  class PersistentImapFolder: CWIMAPFolder, CWCache, CWIMAPCache {
     1.5      let comp = "PersistentImapFolder"
     1.6  
     1.7 -    let connectInfo: ImapSmtpConnectInfo
     1.8 +    let connectInfo: EmailConnectInfo
     1.9  
    1.10      let coreDataUtil: CoreDataUtil
    1.11      lazy var privateMOC: NSManagedObjectContext = self.coreDataUtil.privateContext()
    1.12 @@ -60,7 +60,7 @@
    1.13          }
    1.14      }
    1.15  
    1.16 -    init(name: String, coreDataUtil: CoreDataUtil, connectInfo: ImapSmtpConnectInfo,
    1.17 +    init(name: String, coreDataUtil: CoreDataUtil, connectInfo: EmailConnectInfo,
    1.18           backgroundQueue: OperationQueue) {
    1.19          self.coreDataUtil = coreDataUtil
    1.20          self.connectInfo = connectInfo
    1.21 @@ -78,7 +78,7 @@
    1.22          var folder: CdFolder? = nil
    1.23          privateMOC.performAndWait({
    1.24              if let fo = self.model.insertOrUpdateFolderName(
    1.25 -                self.name(), folderSeparator: nil, accountEmail: self.connectInfo.email) {
    1.26 +                self.name(), folderSeparator: nil, accountEmail: self.connectInfo.userId) {
    1.27                  self.model.save()
    1.28                  folder = fo
    1.29              }
    1.30 @@ -116,7 +116,7 @@
    1.31  
    1.32      func predicateAllMessages() -> NSPredicate {
    1.33          let p = NSPredicate.init(format: "folder.account.email = %@ and folder.name = %@",
    1.34 -                                 connectInfo.email,
    1.35 +                                 connectInfo.userId,
    1.36                                   self.name())
    1.37          return p
    1.38      }
    1.39 @@ -141,7 +141,7 @@
    1.40      override func message(at theIndex: UInt) -> CWMessage? {
    1.41          let p = NSPredicate.init(
    1.42              format: "folder.account.email = %@ and folder.name = %@ and messageNumber = %d",
    1.43 -            connectInfo.email, self.name(), theIndex)
    1.44 +            connectInfo.userId, self.name(), theIndex)
    1.45          var msg: CdMessage?
    1.46          privateMOC.performAndWait({
    1.47              msg = self.model.messageByPredicate(p, sortDescriptors: nil)
    1.48 @@ -199,13 +199,13 @@
    1.49  
    1.50          // Quickly store the most important email proporties (synchronously)
    1.51          let opQuick = StorePrefetchedMailOperation.init(coreDataUtil: coreDataUtil,
    1.52 -                                                        accountEmail: connectInfo.email,
    1.53 +                                                        accountEmail: connectInfo.userId,
    1.54                                                          message: message, quick: true)
    1.55          opQuick.start()
    1.56  
    1.57          // Do all the time-consuming details in the background (asynchronously)
    1.58          let op = StorePrefetchedMailOperation.init(coreDataUtil: coreDataUtil,
    1.59 -                                                   accountEmail: connectInfo.email,
    1.60 +                                                   accountEmail: connectInfo.userId,
    1.61                                                     message: message, quick: false)
    1.62          backgroundQueue.addOperation(op)
    1.63      }
     2.1 --- a/pEpForiOS/Background/PrefetchEmailsOperation.swift	Tue Oct 25 00:48:01 2016 +0200
     2.2 +++ b/pEpForiOS/Background/PrefetchEmailsOperation.swift	Tue Oct 25 01:34:01 2016 +0200
     2.3 @@ -46,7 +46,7 @@
     2.4              // Treat Inbox specially, as it is the only mailbox
     2.5              // that is mandatorily case-insensitive.
     2.6              if self.folderToOpen.lowercased() == ImapSync.defaultImapInboxName.lowercased() {
     2.7 -                if let folder = self.model.folderByType(.inbox, email: self.connectInfo.email) {
     2.8 +                if let folder = self.model.folderByType(.inbox, email: self.connectInfo.userId) {
     2.9                      self.folderToOpen = folder.name
    2.10                  }
    2.11              }
     3.1 --- a/pEpForiOS/Models/CdAccount+Extension.swift	Tue Oct 25 00:48:01 2016 +0200
     3.2 +++ b/pEpForiOS/Models/CdAccount+Extension.swift	Tue Oct 25 01:34:01 2016 +0200
     3.3 @@ -12,22 +12,18 @@
     3.4  
     3.5  extension CdAccount {
     3.6      open var connectInfo: EmailConnectInfo {
     3.7 -        let passImap = KeyChain.getPassword(self.email,
     3.8 -                                            serverType: Server.ServerType.imap.asString())
     3.9 -        let passSmtp = KeyChain.getPassword(self.email,
    3.10 -                                            serverType: Server.ServerType.smtp.asString())
    3.11 -        /* DEPRECATED?
    3.12 +        let password = KeyChain.getPassword(self.email, serverType: (self.connectInfo.emailProtocol?.rawValue)!)
    3.13 +        
    3.14          return EmailConnectInfo.init(
    3.15 -            nameOfTheUser: nameOfTheUser,
    3.16 -            email: email, imapUsername: imapUsername, smtpUsername: smtpUsername,
    3.17 -            imapPassword: passImap, smtpPassword: passSmtp,
    3.18 -            imapServerName: self.imapServerName,
    3.19 -            imapServerPort: UInt16(self.imapServerPort.intValue),
    3.20 -            imapTransport: self.rawImapTransport,
    3.21 -            smtpServerName: self.smtpServerName,
    3.22 -            smtpServerPort: UInt16(self.smtpServerPort.intValue),
    3.23 -            smtpTransport: self.rawSmtpTransport)
    3.24 -        */
    3.25 +            emailProtocol: self.connectInfo.emailProtocol!,
    3.26 +            userId: self.connectInfo.userId,
    3.27 +            userPassword: password,
    3.28 +            userName: self.connectInfo.userName,
    3.29 +            networkPort: self.connectInfo.networkPort,
    3.30 +            networkAddress: self.connectInfo.networkAddress,
    3.31 +            connectionTransport: self.connectInfo.connectionTransport,
    3.32 +            authMethod: self.connectInfo.authMethod
    3.33 +        )
    3.34      }
    3.35  
    3.36      open var rawImapTransport: ConnectionTransport {
     4.1 --- a/pEpForiOS/Network/EmailConnectInfo.swift	Tue Oct 25 00:48:01 2016 +0200
     4.2 +++ b/pEpForiOS/Network/EmailConnectInfo.swift	Tue Oct 25 01:34:01 2016 +0200
     4.3 @@ -80,8 +80,8 @@
     4.4                              userId: String,
     4.5                              userPassword: String? = nil,
     4.6                              userName: String? = nil,
     4.7 -                            connectionPort: UInt16,
     4.8 -                            connectionAddress: String,
     4.9 +                            networkPort: UInt16,
    4.10 +                            networkAddress: String,
    4.11                              connectionTransport: ConnectionTransport? = nil,
    4.12                              authMethod: AuthMethod? = nil)
    4.13      {
    4.14 @@ -89,8 +89,8 @@
    4.15                    userId: userId,
    4.16                    userPassword: nil,
    4.17                    userName: nil,
    4.18 -                  connectionPort: connectionPort,
    4.19 -                  connectionAddress: connectionAddress,
    4.20 +                  networkPort: networkPort,
    4.21 +                  networkAddress: networkAddress,
    4.22                    connectionTransport: nil,
    4.23                    authMethod: nil)
    4.24      }