Add more needed attributes for e-mails.
authorHern?ni Marques <hernani@pep-project.org>
Mon, 24 Oct 2016 23:57:03 +0200
changeset 8644ce7ebb693bb
parent 863 825dd60f110f
child 865 85266cc78f4f
Add more needed attributes for e-mails.
pEpForiOS.xcodeproj/project.pbxproj
pEpForiOS/Network/EmailConnectInfo.swift
     1.1 --- a/pEpForiOS.xcodeproj/project.pbxproj	Mon Oct 24 23:11:12 2016 +0200
     1.2 +++ b/pEpForiOS.xcodeproj/project.pbxproj	Mon Oct 24 23:57:03 2016 +0200
     1.3 @@ -136,6 +136,8 @@
     1.4  		5D039A9C1D0EE7F900AD59EC /* PEPUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D039A9B1D0EE7F900AD59EC /* PEPUtil.swift */; };
     1.5  		5D039AA21D0EEA3700AD59EC /* DecryptMailOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D039AA11D0EEA3700AD59EC /* DecryptMailOperation.swift */; };
     1.6  		5D181C611DABE22C00379D99 /* NetworkBackgroundServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D181C601DABE22C00379D99 /* NetworkBackgroundServiceTests.swift */; };
     1.7 +		5D73EAC31DBEB11E00203AD0 /* ImapConnectInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D73EAC21DBEB11E00203AD0 /* ImapConnectInfo.swift */; };
     1.8 +		5D73EAC51DBEB13000203AD0 /* SmtpConnectInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D73EAC41DBEB13000203AD0 /* SmtpConnectInfo.swift */; };
     1.9  		5DF003981DBE430E00F11C04 /* ConnectInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DF003911DBE430E00F11C04 /* ConnectInfo.swift */; };
    1.10  		5DF003991DBE430E00F11C04 /* EmailConnectInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DF003921DBE430E00F11C04 /* EmailConnectInfo.swift */; };
    1.11  		5DF0039A1DBE430E00F11C04 /* EmailService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DF003931DBE430E00F11C04 /* EmailService.swift */; };
    1.12 @@ -391,6 +393,8 @@
    1.13  		5D039A9B1D0EE7F900AD59EC /* PEPUtil.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PEPUtil.swift; sourceTree = "<group>"; };
    1.14  		5D039AA11D0EEA3700AD59EC /* DecryptMailOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DecryptMailOperation.swift; sourceTree = "<group>"; };
    1.15  		5D181C601DABE22C00379D99 /* NetworkBackgroundServiceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkBackgroundServiceTests.swift; sourceTree = "<group>"; };
    1.16 +		5D73EAC21DBEB11E00203AD0 /* ImapConnectInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ImapConnectInfo.swift; path = pEpForiOS/Network/ImapConnectInfo.swift; sourceTree = SOURCE_ROOT; };
    1.17 +		5D73EAC41DBEB13000203AD0 /* SmtpConnectInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SmtpConnectInfo.swift; path = pEpForiOS/Network/SmtpConnectInfo.swift; sourceTree = SOURCE_ROOT; };
    1.18  		5DF003911DBE430E00F11C04 /* ConnectInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ConnectInfo.swift; path = pEpForiOS/Network/ConnectInfo.swift; sourceTree = SOURCE_ROOT; };
    1.19  		5DF003921DBE430E00F11C04 /* EmailConnectInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EmailConnectInfo.swift; path = pEpForiOS/Network/EmailConnectInfo.swift; sourceTree = SOURCE_ROOT; };
    1.20  		5DF003931DBE430E00F11C04 /* EmailService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EmailService.swift; path = pEpForiOS/Network/EmailService.swift; sourceTree = SOURCE_ROOT; };
    1.21 @@ -681,6 +685,8 @@
    1.22  			isa = PBXGroup;
    1.23  			children = (
    1.24  				5DF003911DBE430E00F11C04 /* ConnectInfo.swift */,
    1.25 +				5D73EAC21DBEB11E00203AD0 /* ImapConnectInfo.swift */,
    1.26 +				5D73EAC41DBEB13000203AD0 /* SmtpConnectInfo.swift */,
    1.27  				5DF003921DBE430E00F11C04 /* EmailConnectInfo.swift */,
    1.28  				5DF003931DBE430E00F11C04 /* EmailService.swift */,
    1.29  				5DF003941DBE430E00F11C04 /* ImapService.swift */,
    1.30 @@ -1103,6 +1109,7 @@
    1.31  				43E42FF71D7096E400164CB1 /* DeleteMessageOperation.swift in Sources */,
    1.32  				431144AC1CC0CCE30007639D /* GrandOperator.swift in Sources */,
    1.33  				434F84451CEB018A0055B7A9 /* NSData+Extensions.swift in Sources */,
    1.34 +				5D73EAC51DBEB13000203AD0 /* SmtpConnectInfo.swift in Sources */,
    1.35  				43980EF81CBD402400A7FC3C /* CoreDataUtil.swift in Sources */,
    1.36  				4305AC7C1DA3FE9A00273D16 /* CdContact.swift in Sources */,
    1.37  				A1B50A841CD26FF100B1A997 /* Constants.swift in Sources */,
    1.38 @@ -1134,6 +1141,7 @@
    1.39  				43463AAE1D8AA54800F3A673 /* CheckAndCreateFolderOfTypeOperation.swift in Sources */,
    1.40  				4340F5F91D363BE6006A5C82 /* ContactTableViewCell.swift in Sources */,
    1.41  				43980EFA1CBD415700A7FC3C /* AppConfig.swift in Sources */,
    1.42 +				5D73EAC31DBEB11E00203AD0 /* ImapConnectInfo.swift in Sources */,
    1.43  				A1014DA71D1173CD00C472A8 /* UIHelper.swift in Sources */,
    1.44  				43001F7A1D91860A00306BF0 /* FetchTableViewController.swift in Sources */,
    1.45  				43E58ED11CBFA943008AA7A7 /* KeyChain.swift in Sources */,
     2.1 --- a/pEpForiOS/Network/EmailConnectInfo.swift	Mon Oct 24 23:11:12 2016 +0200
     2.2 +++ b/pEpForiOS/Network/EmailConnectInfo.swift	Mon Oct 24 23:57:03 2016 +0200
     2.3 @@ -36,8 +36,26 @@
     2.4          } else if string.isEqual(AuthMethod.CramMD5.rawValue) {
     2.5              self = .CramMD5
     2.6          } else {
     2.7 +            // To fail
     2.8              self = .Plain
     2.9 -            assert(false, "")
    2.10 +            assert(false)
    2.11 +        }
    2.12 +    }
    2.13 +}
    2.14 +
    2.15 +public enum EmailProtocol: String {
    2.16 +    case smtp = "SMTP"
    2.17 +    case imap = "IMAP"
    2.18 +    
    2.19 +    init(emailProtocol: String) {
    2.20 +        if emailProtocol.isEqual(EmailProtocol.smtp.rawValue) {
    2.21 +            self = .smtp
    2.22 +        } else if emailProtocol.isEqual(EmailProtocol.imap.rawValue) {
    2.23 +            self = .imap
    2.24 +        } else {
    2.25 +            // To fail
    2.26 +            self = .smtp
    2.27 +            assert(false)
    2.28          }
    2.29      }
    2.30  }
    2.31 @@ -46,16 +64,36 @@
    2.32   Holds additional connection info (like server, port etc.) for IMAP and SMTP.
    2.33   */
    2.34  public protocol IEmailConnectInfo: IConnectInfo {
    2.35 +    var emailProtocol: EmailProtocol { get }
    2.36 +    
    2.37 +    var connectionTransport: ConnectionTransport? { get }
    2.38      var userPassword: String? { get }
    2.39 -    var connectionTransport: ConnectionTransport { get }
    2.40 +    var authMethod: AuthMethod? { get }
    2.41  }
    2.42  
    2.43  public class EmailConnectInfo: ConnectInfo {
    2.44 +    public var emailProtocol: EmailProtocol
    2.45 +
    2.46 +    public var connectionTransport: ConnectionTransport?
    2.47      public var userPassword: String?
    2.48 -    public var connectionTransport: ConnectionTransport?
    2.49 +    public var authMethod: AuthMethod?
    2.50      
    2.51 -    public convenience init(userId: String, userPassword: String? = nil, userName: String? = nil, connectionPort: UInt16, connectionAddress: String, connectionTransport: ConnectionTransport?)
    2.52 +    public convenience init(emailProtocol: EmailProtocol,
    2.53 +                            userId: String,
    2.54 +                            userPassword: String? = nil,
    2.55 +                            userName: String? = nil,
    2.56 +                            connectionPort: UInt16,
    2.57 +                            connectionAddress: String,
    2.58 +                            connectionTransport: ConnectionTransport? = nil,
    2.59 +                            authMethod: AuthMethod? = nil)
    2.60      {
    2.61 -        self.init(userId: userId, userPassword: nil, userName: nil, connectionPort: connectionPort, connectionAddress: connectionAddress, connectionTransport: nil)
    2.62 +        self.init(emailProtocol: emailProtocol,
    2.63 +                  userId: userId,
    2.64 +                  userPassword: nil,
    2.65 +                  userName: nil,
    2.66 +                  connectionPort: connectionPort,
    2.67 +                  connectionAddress: connectionAddress,
    2.68 +                  connectionTransport: nil,
    2.69 +                  authMethod: nil)
    2.70      }
    2.71  }