Refactor more
authorHern?ni Marques <hernani@pep-project.org>
Mon, 24 Oct 2016 22:44:35 +0200
changeset 8625a2487b11bf8
parent 859 2e99866945e3
child 863 825dd60f110f
Refactor more
pEpForiOS/Background/SyncFlagsToServerOperation.swift
pEpForiOS/Background/VerifyServiceOperation.swift
pEpForiOS/Models/CdAccount+Extension.swift
pEpForiOS/Models/CdModel.swift
pEpForiOS/Util/ConnectionManager.swift
     1.1 --- a/pEpForiOS/Background/SyncFlagsToServerOperation.swift	Mon Oct 24 15:51:19 2016 +0200
     1.2 +++ b/pEpForiOS/Background/SyncFlagsToServerOperation.swift	Mon Oct 24 22:44:35 2016 +0200
     1.3 @@ -18,7 +18,7 @@
     1.4  
     1.5      var targetFolderName: String!
     1.6  
     1.7 -    let connectInfo: ImapSmtpConnectInfo
     1.8 +    let connectInfo: EmailConnectInfo
     1.9  
    1.10      var imapSync: ImapSync!
    1.11  
     2.1 --- a/pEpForiOS/Background/VerifyServiceOperation.swift	Mon Oct 24 15:51:19 2016 +0200
     2.2 +++ b/pEpForiOS/Background/VerifyServiceOperation.swift	Mon Oct 24 22:44:35 2016 +0200
     2.3 @@ -10,7 +10,7 @@
     2.4  
     2.5  open class VerifyServiceOperation: ConcurrentBaseOperation {
     2.6      var service: Service!
     2.7 -    let connectInfo: ImapSmtpConnectInfo
     2.8 +    let connectInfo: EmailConnectInfo
     2.9      let connectionManager: ConnectionManager
    2.10  
    2.11      /**
    2.12 @@ -22,7 +22,7 @@
    2.13       */
    2.14      var isFinishing: Bool = false
    2.15  
    2.16 -    public init(grandOperator: IGrandOperator, connectInfo: ImapSmtpConnectInfo) {
    2.17 +    public init(grandOperator: IGrandOperator, connectInfo: EmailConnectInfo) {
    2.18          self.connectInfo = connectInfo
    2.19          self.connectionManager = grandOperator.connectionManager
    2.20          super.init(coreDataUtil: grandOperator.coreDataUtil)
     3.1 --- a/pEpForiOS/Models/CdAccount+Extension.swift	Mon Oct 24 15:51:19 2016 +0200
     3.2 +++ b/pEpForiOS/Models/CdAccount+Extension.swift	Mon Oct 24 22:44:35 2016 +0200
     3.3 @@ -11,12 +11,13 @@
     3.4  import MessageModel
     3.5  
     3.6  extension CdAccount {
     3.7 -    open var connectInfo: ImapSmtpConnectInfo {
     3.8 +    open var connectInfo: EmailConnectInfo {
     3.9          let passImap = KeyChain.getPassword(self.email,
    3.10                                              serverType: Server.ServerType.imap.asString())
    3.11          let passSmtp = KeyChain.getPassword(self.email,
    3.12                                              serverType: Server.ServerType.smtp.asString())
    3.13 -        return ImapSmtpConnectInfo.init(
    3.14 +        /* DEPRECATED?
    3.15 +        return EmailConnectInfo.init(
    3.16              nameOfTheUser: nameOfTheUser,
    3.17              email: email, imapUsername: imapUsername, smtpUsername: smtpUsername,
    3.18              imapPassword: passImap, smtpPassword: passSmtp,
    3.19 @@ -26,6 +27,7 @@
    3.20              smtpServerName: self.smtpServerName,
    3.21              smtpServerPort: UInt16(self.smtpServerPort.intValue),
    3.22              smtpTransport: self.rawSmtpTransport)
    3.23 +        */
    3.24      }
    3.25  
    3.26      open var rawImapTransport: ConnectionTransport {
     4.1 --- a/pEpForiOS/Models/CdModel.swift	Mon Oct 24 15:51:19 2016 +0200
     4.2 +++ b/pEpForiOS/Models/CdModel.swift	Mon Oct 24 22:44:35 2016 +0200
     4.3 @@ -306,7 +306,7 @@
     4.4          return nil
     4.5      }
     4.6  
     4.7 -    func newAccountFromImapSmtpConnectInfo(_ connectInfo: ImapSmtpConnectInfo) -> CdAccount {
     4.8 +    func newAccountFromImapSmtpConnectInfo(_ connectInfo: EmailConnectInfo) -> CdAccount {
     4.9          let account = NSEntityDescription.insertNewObject(
    4.10              forEntityName: CdAccount.entityName(), into: context) as! CdAccount
    4.11          account.nameOfTheUser = connectInfo.nameOfTheUser
    4.12 @@ -325,17 +325,17 @@
    4.13          return account
    4.14      }
    4.15  
    4.16 -    open func insertAccountFromImapSmtpConnectInfo(_ connectInfo: ImapSmtpConnectInfo) -> CdAccount {
    4.17 +    open func insertAccountFromImapSmtpConnectInfo(_ connectInfo: EmailConnectInfo) -> CdAccount {
    4.18          if let ac = accountByEmail(connectInfo.email) {
    4.19              return ac
    4.20          }
    4.21  
    4.22          let account = newAccountFromImapSmtpConnectInfo(connectInfo)
    4.23          save()
    4.24 -        let _ = KeyChain.addEmail(connectInfo.email,
    4.25 +        let _ = KeyChain.addEmail(connectInfo.userId,
    4.26                                    serverType: Server.ServerType.imap.asString(),
    4.27                                    password: connectInfo.imapPassword)
    4.28 -        let _ = KeyChain.addEmail(connectInfo.email,
    4.29 +        let _ = KeyChain.addEmail(connectInfo.userId,
    4.30                                    serverType: Server.ServerType.smtp.asString(),
    4.31                                    password: connectInfo.getSmtpPassword())
    4.32          return account
     5.1 --- a/pEpForiOS/Util/ConnectionManager.swift	Mon Oct 24 15:51:19 2016 +0200
     5.2 +++ b/pEpForiOS/Util/ConnectionManager.swift	Mon Oct 24 22:44:35 2016 +0200
     5.3 @@ -12,7 +12,7 @@
     5.4      fileprivate let comp = "ConnectionManager"
     5.5      open var cacheImapConnections: Bool = false
     5.6  
     5.7 -    var imapConnections: [ImapSmtpConnectInfo: ImapSync] = [:]
     5.8 +    var imapConnections: [EmailConnectInfo: ImapSync] = [:]
     5.9      weak var grandOperator: IGrandOperator!
    5.10  
    5.11      public init() {}
    5.12 @@ -21,7 +21,7 @@
    5.13          closeAll()
    5.14      }
    5.15  
    5.16 -    open func emailSyncConnection(_ connectInfo: ImapSmtpConnectInfo) -> ImapSync {
    5.17 +    open func emailSyncConnection(_ connectInfo: EmailConnectInfo) -> ImapSync {
    5.18          if cacheImapConnections {
    5.19              if let sync = imapConnections[connectInfo] {
    5.20                  return sync
    5.21 @@ -41,11 +41,11 @@
    5.22       - Returns: A one-way/throw-away IMAP sync connection, e.g., for testing/verifying
    5.23        a connection.
    5.24       */
    5.25 -    open func emailSyncConnectionOneWay(_ connectInfo: ImapSmtpConnectInfo) -> ImapSync {
    5.26 +    open func emailSyncConnectionOneWay(_ connectInfo: EmailConnectInfo) -> ImapSync {
    5.27          return ImapSync.init(connectInfo: connectInfo)
    5.28      }
    5.29  
    5.30 -    open func smtpConnection(_ connectInfo: ImapSmtpConnectInfo) -> SmtpSend {
    5.31 +    open func smtpConnection(_ connectInfo: EmailConnectInfo) -> SmtpSend {
    5.32          // Don't cache
    5.33          return SmtpSend.init(connectInfo: connectInfo)
    5.34      }