Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
enzevalos_iphone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
enzevalos
enzevalos_iphone
Commits
24b16a5b
Commit
24b16a5b
authored
6 years ago
by
Oliver Wiese
Browse files
Options
Downloads
Patches
Plain Diff
update server config check in detailOnboarding
parent
64fdb97c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
enzevalos_iphone/MailSession.swift
+49
-6
49 additions, 6 deletions
enzevalos_iphone/MailSession.swift
enzevalos_iphone/Onboarding.swift
+71
-8
71 additions, 8 deletions
enzevalos_iphone/Onboarding.swift
with
120 additions
and
14 deletions
enzevalos_iphone/MailSession.swift
+
49
−
6
View file @
24b16a5b
...
@@ -183,22 +183,29 @@ class MailSession {
...
@@ -183,22 +183,29 @@ class MailSession {
listeners
.
append
(
listener
)
listeners
.
append
(
listener
)
}
}
func
testConfig
(
host
:
String
,
port
:
UInt32
,
authType
:
MCOAuthType
,
connType
:
MCOConnectionType
)
{
testServer
(
hostname
:
host
,
port
:
port
,
connectionType
:
connType
,
authType
:
authType
,
completion
:
completionTestConfig
)
}
func
findInJSonFileAndTest
()
->
Bool
{
func
findInJSonFileAndTest
()
->
Bool
{
(
hostname
,
port
,
connectionType
,
authType
)
=
loadFromProviderJson
()
(
hostname
,
port
,
connectionType
,
authType
)
=
loadFromProviderJson
()
if
let
h
=
hostname
,
let
p
=
port
,
let
con
=
connectionType
{
if
let
h
=
hostname
,
let
p
=
port
,
let
con
=
connectionType
{
counter
=
MailSession
.
AUTHTYPE
.
count
return
findAndTestAuthType
(
hostname
:
h
,
port
:
p
,
connType
:
con
)
success
=
false
for
authType
in
MailSession
.
AUTHTYPE
{
testServer
(
hostname
:
h
,
port
:
p
,
connectionType
:
con
,
authType
:
authType
,
completion
:
completionTestAuthType
)
}
return
true
}
}
else
{
else
{
return
false
return
false
}
}
}
}
private
func
findAndTestAuthType
(
hostname
:
String
,
port
:
UInt32
,
connType
:
MCOConnectionType
)
->
Bool
{
counter
=
MailSession
.
AUTHTYPE
.
count
success
=
false
for
authType
in
MailSession
.
AUTHTYPE
{
testServer
(
hostname
:
hostname
,
port
:
port
,
connectionType
:
connType
,
authType
:
authType
,
completion
:
completionTestAuthType
)
}
return
true
}
func
findDefaultValuesAndTest
()
->
Bool
{
func
findDefaultValuesAndTest
()
->
Bool
{
_
=
self
.
fillWithDefaultValues
()
_
=
self
.
fillWithDefaultValues
()
...
@@ -354,6 +361,42 @@ class MailSession {
...
@@ -354,6 +361,42 @@ class MailSession {
completionTestAuthType
(
error
:
error
,
smtpSession
:
smtpSession
,
imapSession
:
imapSession
)
completionTestAuthType
(
error
:
error
,
smtpSession
:
smtpSession
,
imapSession
:
imapSession
)
}
}
private
func
completionTestConfig
(
error
:
MailServerConnectionError
?,
smtpSession
:
MCOSMTPSession
?,
imapSession
:
MCOIMAPSession
?)
{
if
let
e
=
error
{
if
e
==
MailServerConnectionError
.
AuthenticationError
||
e
==
MailServerConnectionError
.
NoInternetconnection
{
errors
.
insert
(
e
)
for
l
in
listeners
{
l
.
testFinish
(
result
:
false
)
}
}
else
{
var
host
:
String
var
port
:
UInt32
var
connType
:
MCOConnectionType
if
let
imap
=
imapSession
{
host
=
imap
.
hostname
port
=
imap
.
port
connType
=
imap
.
connectionType
_
=
findAndTestAuthType
(
hostname
:
host
,
port
:
port
,
connType
:
connType
)
}
else
if
let
smtp
=
smtpSession
{
host
=
smtp
.
hostname
port
=
smtp
.
port
connType
=
smtp
.
connectionType
_
=
findAndTestAuthType
(
hostname
:
host
,
port
:
port
,
connType
:
connType
)
}
else
{
errors
.
insert
(
e
)
for
l
in
listeners
{
l
.
testFinish
(
result
:
false
)
}
}
}
return
}
completionTestAuthType
(
error
:
error
,
smtpSession
:
smtpSession
,
imapSession
:
imapSession
)
}
private
func
completionTestAuthType
(
error
:
MailServerConnectionError
?,
smtpSession
:
MCOSMTPSession
?,
imapSession
:
MCOIMAPSession
?){
private
func
completionTestAuthType
(
error
:
MailServerConnectionError
?,
smtpSession
:
MCOSMTPSession
?,
imapSession
:
MCOIMAPSession
?){
guard
error
==
nil
else
{
guard
error
==
nil
else
{
counter
=
counter
-
1
counter
=
counter
-
1
...
...
This diff is collapsed.
Click to expand it.
enzevalos_iphone/Onboarding.swift
+
71
−
8
View file @
24b16a5b
...
@@ -576,17 +576,72 @@ class Onboarding: NSObject {
...
@@ -576,17 +576,72 @@ class Onboarding: NSObject {
}
}
}
}
static
private
func
checkDetailConfig
(
imap
:
Bool
)
{
if
let
imapHost
=
imapServer
.
text
,
let
imapPortString
=
imapPort
.
text
,
let
smtpHost
=
smtpServer
.
text
,
let
smtpPortString
=
smtpPort
.
text
,
let
smtpPort
=
Int
(
smtpPortString
),
let
imapPort
=
Int
(
imapPortString
)
{
let
imapAuthName
=
imapTransDataDelegate
.
pickedValue
let
imapConName
=
imapTransDataDelegate
.
pickedValue
let
smtpConnName
=
smtpTransDataDelegate
.
pickedValue
let
smtpAuthName
=
smtpAuthDataDelegate
.
pickedValue
var
imapAuthValue
=
0
var
imapConnValue
=
0
var
smtpAuthValue
=
0
var
smtpConnValue
=
0
for
(
value
,
name
)
in
Onboarding
.
authenticationRows
{
if
name
==
imapAuthName
{
imapAuthValue
=
value
}
if
name
==
smtpAuthName
{
smtpAuthValue
=
value
}
}
for
(
value
,
name
)
in
Onboarding
.
transportRows
{
if
name
==
imapConName
{
imapConnValue
=
value
}
if
name
==
smtpConnName
{
smtpConnValue
=
value
}
}
if
imap
{
if
imapSession
==
nil
{
_
=
setIMAPSession
()
}
if
let
imap
=
imapSession
{
imap
.
testConfig
(
host
:
imapHost
,
port
:
UInt32
(
imapPort
),
authType
:
MCOAuthType
.
init
(
rawValue
:
imapAuthValue
),
connType
:
MCOConnectionType
.
init
(
rawValue
:
imapConnValue
))
}
}
else
{
if
smtpSession
==
nil
{
_
=
setSMTPSession
()
}
if
let
smtp
=
smtpSession
{
smtp
.
testConfig
(
host
:
smtpHost
,
port
:
UInt32
(
smtpPort
),
authType
:
MCOAuthType
.
init
(
rawValue
:
smtpAuthValue
),
connType
:
MCOConnectionType
.
init
(
rawValue
:
smtpConnValue
))
}
}
}
}
static
func
checkIMAPConfig
()
{
static
private
func
setIMAPSession
()
->
MailSession
{
let
mailSession
=
MailSession
(
configSession
:
SessionType
.
IMAP
,
mailAddress
:
mailaddress
.
text
!
,
password
:
password
.
text
!
,
username
:
mailaddress
.
text
)
let
mailSession
=
MailSession
(
configSession
:
SessionType
.
IMAP
,
mailAddress
:
mailaddress
.
text
!
,
password
:
password
.
text
!
,
username
:
mailaddress
.
text
)
mailSession
.
addListener
(
listener
:
listenerIMAP
)
mailSession
.
addListener
(
listener
:
listenerIMAP
)
Onboarding
.
imapSession
=
mailSession
return
mailSession
}
static
func
checkIMAPConfig
()
{
let
mailSession
=
setIMAPSession
()
if
let
imap
=
imapSession
,
MailServerConnectionError
.
wrongServerConfig
(
errors
:
imap
.
errors
)
&&
Onboarding
.
credentialFails
==
2
{
if
let
imap
=
imapSession
,
MailServerConnectionError
.
wrongServerConfig
(
errors
:
imap
.
errors
)
&&
Onboarding
.
credentialFails
==
2
{
if
!
mailSession
.
findAndTestLong
()
{
if
!
mailSession
.
findAndTestLong
()
{
imapCompletion
(
imapWorks
:
false
)
imapCompletion
(
imapWorks
:
false
)
}
}
}
else
{
}
else
if
Onboarding
.
credentialFails
>=
3
{
checkDetailConfig
(
imap
:
true
)
}
else
{
if
!
mailSession
.
findInJSonFileAndTest
()
{
if
!
mailSession
.
findInJSonFileAndTest
()
{
if
!
mailSession
.
findDefaultValuesAndTest
()
{
if
!
mailSession
.
findDefaultValuesAndTest
()
{
if
!
mailSession
.
findAndTestLong
()
{
if
!
mailSession
.
findAndTestLong
()
{
...
@@ -595,17 +650,26 @@ class Onboarding: NSObject {
...
@@ -595,17 +650,26 @@ class Onboarding: NSObject {
}
}
}
}
}
}
Onboarding
.
imapSession
=
mailSession
}
}
static
func
checkSMTPConfig
()
{
static
private
func
setSMTPSession
()
->
MailSession
{
let
mailSession
=
MailSession
(
configSession
:
SessionType
.
SMTP
,
mailAddress
:
mailaddress
.
text
!
,
password
:
password
.
text
!
,
username
:
mailaddress
.
text
)
let
mailSession
=
MailSession
(
configSession
:
SessionType
.
SMTP
,
mailAddress
:
mailaddress
.
text
!
,
password
:
password
.
text
!
,
username
:
mailaddress
.
text
)
mailSession
.
addListener
(
listener
:
listenerSMTP
)
mailSession
.
addListener
(
listener
:
listenerSMTP
)
Onboarding
.
smtpSession
=
mailSession
return
mailSession
}
static
func
checkSMTPConfig
()
{
let
mailSession
=
setSMTPSession
()
if
let
imap
=
imapSession
,
MailServerConnectionError
.
wrongServerConfig
(
errors
:
imap
.
errors
)
{
if
let
imap
=
imapSession
,
MailServerConnectionError
.
wrongServerConfig
(
errors
:
imap
.
errors
)
{
if
!
mailSession
.
findAndTestLong
()
{
if
!
mailSession
.
findAndTestLong
()
{
smtpCompletion
(
smtpWorks
:
false
)
smtpCompletion
(
smtpWorks
:
false
)
}
}
}
else
{
}
else
if
Onboarding
.
credentialFails
>=
3
{
checkDetailConfig
(
imap
:
false
)
}
else
{
if
!
mailSession
.
findInJSonFileAndTest
()
{
if
!
mailSession
.
findInJSonFileAndTest
()
{
if
!
mailSession
.
findDefaultValuesAndTest
()
{
if
!
mailSession
.
findDefaultValuesAndTest
()
{
if
!
mailSession
.
findAndTestLong
()
{
if
!
mailSession
.
findAndTestLong
()
{
...
@@ -614,7 +678,6 @@ class Onboarding: NSObject {
...
@@ -614,7 +678,6 @@ class Onboarding: NSObject {
}
}
}
}
}
}
Onboarding
.
smtpSession
=
mailSession
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment