Эх сурвалжийг харах

set Imap/SMTP automatic value to 0x000/0x00000

Bastian van de Wetering 6 жил өмнө
parent
commit
4b0de17eb2

+ 12 - 9
deltachat-ios/Controller/AccountSetup/SecuritySettingsController.swift

@@ -103,6 +103,7 @@ enum SecurityType {
 }
 
 enum SecurityValue: String {
+	case AUTO = "Automatic"
 	case TLS = "SSL / TLS"
 	case STARTTLS = "STARTTLS"
 	case PLAIN = "OFF"
@@ -110,10 +111,12 @@ enum SecurityValue: String {
 
 class SecurityConverter {
 
-	static func convert(type: SecurityType, test value: SecurityValue) -> Int {
+	static func convertValueToInt(type: SecurityType, value: SecurityValue) -> Int {
 		switch type {
 		case .IMAPSecurity:
 			switch value {
+			case .AUTO:
+				return 0x000
 			case .STARTTLS:
 				return 0x100
 			case .TLS:
@@ -123,6 +126,8 @@ class SecurityConverter {
 			}
 		case .SMTPSecurity:
 			switch value{
+			case .AUTO:
+				return 0x00000
 			case .STARTTLS:
 				return 0x10000
 			case .TLS:
@@ -133,18 +138,16 @@ class SecurityConverter {
 		}
 	}
 
-	static func convert(type: SecurityType, hex value: Int) -> String {
+	static func convertHexToString(type: SecurityType, hex value: Int) -> String {
 		switch type {
 		case .IMAPSecurity:
 			switch value {
-			case 0:
+			case 0x00:
 				return "Automatic"
 			case 0x100:
 				return "STARTTLS"
 			case 0x200:
 				return "SSL / TLS"
-			case 0x300:
-				return "OFF"
 			case  0x400:
 				return "OFF"
 			default:
@@ -152,15 +155,15 @@ class SecurityConverter {
 			}
 		case .SMTPSecurity:
 			switch value {
-			case 0:
+			case 0x00000:
 				return "Automatic"
 			case 0x10000:
 					return "STARTTLS"
-				case 0x20000:
+			case 0x20000:
 				return "SSL / TLS"
-				case  0x40000:
+			case  0x40000:
 				return "OFF"
-				default:
+			default:
 				return "Undefined"
 			}
 		}

+ 2 - 2
deltachat-ios/Controller/AccountSetupController.swift

@@ -163,8 +163,8 @@ class AccountSetupController: UITableViewController {
 		// needs to be changed if returning from portSettingsController
 		smtpPortCell.detailTextLabel?.text = MRConfig.sendPort ?? MRConfig.configuredSendPort
 		imapPortCell.detailTextLabel?.text = MRConfig.mailPort ?? MRConfig.configuredMailPort
-		smtpSecurityCell.detailTextLabel?.text = SecurityConverter.convert(type: .SMTPSecurity, hex: MRConfig.getSmtpSecurity())
-		imapSecurityCell.detailTextLabel?.text  = SecurityConverter.convert(type: .IMAPSecurity, hex: MRConfig.getImapSecurity())
+		smtpSecurityCell.detailTextLabel?.text = SecurityConverter.convertHexToString(type: .SMTPSecurity, hex: MRConfig.getSmtpSecurity())
+		imapSecurityCell.detailTextLabel?.text  = SecurityConverter.convertHexToString(type: .IMAPSecurity, hex: MRConfig.getImapSecurity())
 	}
 
   override func viewDidAppear(_ animated: Bool) {

+ 4 - 4
deltachat-ios/Coordinator/AppCoordinator.swift

@@ -222,12 +222,12 @@ class AccountSetupCoordinator: Coordinator {
 
 	func showImapSecurityOptions() {
 		let currentSecurityOption = MRConfig.getImapSecurity()
-		let convertedOption = SecurityConverter.convert(type: .IMAPSecurity, hex: currentSecurityOption)
+		let convertedOption = SecurityConverter.convertHexToString(type: .IMAPSecurity, hex: currentSecurityOption)
 		let securitySettingsController = SecuritySettingsController(title: "IMAP Security", options: ["Automatic", "SSL / TLS", "STARTTLS", "OFF"], selectedOption: convertedOption)
 		securitySettingsController.onDismiss = {
 			option in
 			if let secValue = SecurityValue(rawValue: option) {
-				let value = SecurityConverter.convert(type: .IMAPSecurity, test: secValue)
+				let value = SecurityConverter.convertValueToInt(type: .IMAPSecurity, value: secValue)
 				MRConfig.setImapSecurity(imapFlags: value)
 				dc_configure(mailboxPointer)
 			}
@@ -249,12 +249,12 @@ class AccountSetupCoordinator: Coordinator {
 
 	func showSmptpSecurityOptions() {
 		let currentSecurityOption = MRConfig.getSmtpSecurity()
-		let convertedOption = SecurityConverter.convert(type: .SMTPSecurity, hex: currentSecurityOption)
+		let convertedOption = SecurityConverter.convertHexToString(type: .SMTPSecurity, hex: currentSecurityOption)
 		let securitySettingsController = SecuritySettingsController(title: "IMAP Security", options: ["Automatic", "SSL / TLS", "STARTTLS", "OFF"], selectedOption: convertedOption)
 		securitySettingsController.onDismiss = {
 			option in
 			if let secValue = SecurityValue(rawValue: option) {
-				let value = SecurityConverter.convert(type: .SMTPSecurity, test: secValue)
+				let value = SecurityConverter.convertValueToInt(type: .SMTPSecurity, value: secValue)
 				MRConfig.setSmtpSecurity(smptpFlags: value)
 				dc_configure(mailboxPointer)
 			}