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
4ed61100
Commit
4ed61100
authored
4 years ago
by
cruxfilm
Browse files
Options
Downloads
Patches
Plain Diff
Fixed merge conflict in DisplayProtocols.
parent
e3aa8d28
Branches
Branches containing commit
No related tags found
1 merge request
!74
Integration of new ComposeView
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
enzevalos_iphone/SwiftUI/DisplayProtocols.swift
+59
-49
59 additions, 49 deletions
enzevalos_iphone/SwiftUI/DisplayProtocols.swift
with
59 additions
and
49 deletions
enzevalos_iphone/SwiftUI/DisplayProtocols.swift
+
59
−
49
View file @
4ed61100
...
@@ -8,18 +8,25 @@
...
@@ -8,18 +8,25 @@
import
Foundation
import
Foundation
import
SwiftUI
import
SwiftUI
//TODO D
O
cumentView?? StateObject
//
TODO
:
D
o
cumentView?? StateObject
/*
/*
Here are protocols to display an email, key, address and a contact
Here are protocols to display an email, key, address and a contact
*/
*/
/// Enums
/// Enums
enum
FolderType
{
enum
FolderType
{
case
Archive
,
Trash
,
Inbox
,
Sent
,
Draft
,
Other
case
Archive
case
Trash
case
Inbox
case
Sent
case
Draft
case
Other
}
}
enum
ResponseType
{
enum
ResponseType
{
case
Reply
,
Forward
,
Draft
case
Reply
case
Forward
case
Draft
func
addPrefix
(
subject
:
String
)
->
String
{
func
addPrefix
(
subject
:
String
)
->
String
{
switch
self
{
switch
self
{
...
@@ -38,7 +45,14 @@ enum ResponseType {
...
@@ -38,7 +45,14 @@ enum ResponseType {
}
}
enum
CryptoState
{
enum
CryptoState
{
case
UnableToDecrypt
,
InvalidSignature
,
NoCrypto
,
PlainMissingPublicKeyToVerify
,
PlainButValidSignature
,
EncValidSign
,
EncNoSignature
,
EncButMissingPublicKeyToVerify
case
UnableToDecrypt
case
InvalidSignature
case
NoCrypto
case
PlainMissingPublicKeyToVerify
case
PlainButValidSignature
case
EncValidSign
case
EncNoSignature
case
EncButMissingPublicKeyToVerify
var
buttonActions
:
[
ButtonAction
]
{
var
buttonActions
:
[
ButtonAction
]
{
get
{
get
{
...
@@ -54,12 +68,11 @@ enum CryptoState {
...
@@ -54,12 +68,11 @@ enum CryptoState {
}
}
}
}
}
}
}
}
enum
ContactSecurityRating
{
enum
ContactSecurityRating
{
case
Trustworthy
,
Forgable
case
Trustworthy
case
Forgable
var
name
:
LocalizedStringKey
{
var
name
:
LocalizedStringKey
{
switch
self
{
switch
self
{
...
@@ -82,7 +95,6 @@ enum ContactSecurityRating {
...
@@ -82,7 +95,6 @@ enum ContactSecurityRating {
protocol
DisplayKey
{
protocol
DisplayKey
{
var
keyID
:
String
{
get
}
var
keyID
:
String
{
get
}
var
discovery
:
Date
?
{
get
}
var
discovery
:
Date
?
{
get
}
var
lastSeen
:
Date
?
{
get
}
var
lastSeen
:
Date
?
{
get
}
...
@@ -108,7 +120,7 @@ protocol DisplayAttachment {
...
@@ -108,7 +120,7 @@ protocol DisplayAttachment {
protocol
DisplayContact
{
protocol
DisplayContact
{
associatedtype
K
:
DisplayKey
associatedtype
K
:
DisplayKey
// General
// General
var
name
:
String
{
get
}
var
name
:
String
{
get
}
var
email
:
String
{
get
}
var
email
:
String
{
get
}
...
@@ -129,9 +141,7 @@ protocol DisplayContact {
...
@@ -129,9 +141,7 @@ protocol DisplayContact {
}
}
extension
DisplayContact
{
extension
DisplayContact
{
func
findAddress
(
temp
:
Bool
)
->
AddressRecord
{
func
findAddress
(
temp
:
Bool
)
->
MailAddress
{
if
let
addr
=
PersistentDataProvider
.
dataProvider
.
fetchedAddressResultController
.
fetchedObjects
?
.
first
{
if
let
addr
=
PersistentDataProvider
.
dataProvider
.
fetchedAddressResultController
.
fetchedObjects
?
.
first
{
return
addr
return
addr
}
}
...
@@ -176,18 +186,18 @@ protocol DisplayMail {
...
@@ -176,18 +186,18 @@ protocol DisplayMail {
var
encryptionType
:
CryptoScheme
?
{
get
}
var
encryptionType
:
CryptoScheme
?
{
get
}
var
transportEnc
:
Bool
{
get
}
var
transportEnc
:
Bool
{
get
}
var
signatureKey
:
K
?
{
get
}
var
signatureKey
:
K
?
{
get
}
var
persistentMail
:
MailRecord
?
{
get
}
var
persistentMail
:
MailRecord
?
{
get
}
func
markAsRead
(
isRead
:
Bool
)
func
markAsRead
(
isRead
:
Bool
)
}
}
extension
DisplayMail
{
extension
DisplayMail
{
/* TODO: MORE DIALOGS
/* TODO: MORE DIALOGS
//else if (mail.isNewPubKey) {}
//else if (mail.isNewPubKey) {}
// message contained new public key
// message contained new public key
*/
*/
var
signatureType
:
CryptoScheme
?
{
var
signatureType
:
CryptoScheme
?
{
get
{
get
{
...
@@ -199,14 +209,14 @@ extension DisplayMail {
...
@@ -199,14 +209,14 @@ extension DisplayMail {
get
{
get
{
var
key
=
""
var
key
=
""
switch
evaluateSecurity
()
{
switch
evaluateSecurity
()
{
case
(
_
,
.
NoCrypto
):
key
=
"Security.Dialog.Title.No.Crypto"
case
(
_
,
.
NoCrypto
):
key
=
"Security.Dialog.Title.No.Crypto"
case
(
_
,
.
UnableToDecrypt
):
key
=
"Security.Dialog.Title.UnableToDecrypt"
case
(
_
,
.
UnableToDecrypt
):
key
=
"Security.Dialog.Title.UnableToDecrypt"
case
(
_
,
.
InvalidSignature
):
key
=
"Security.Dialog.Title.InvalidSignature"
case
(
_
,
.
InvalidSignature
):
key
=
"Security.Dialog.Title.InvalidSignature"
case
(
_
,
.
PlainMissingPublicKeyToVerify
):
key
=
"Security.Dialog.Title.PlainMissingPublicKeyToVerify"
case
(
_
,
.
PlainMissingPublicKeyToVerify
):
key
=
"Security.Dialog.Title.PlainMissingPublicKeyToVerify"
case
(
_
,
.
PlainButValidSignature
):
key
=
"Security.Dialog.Title.Plain+Sig"
case
(
_
,
.
PlainButValidSignature
):
key
=
"Security.Dialog.Title.Plain+Sig"
case
(
_
,
.
EncValidSign
):
key
=
"Security.Dialog.Title.Enc+Sign"
case
(
_
,
.
EncValidSign
):
key
=
"Security.Dialog.Title.Enc+Sign"
case
(
_
,
.
EncNoSignature
):
key
=
"Security.Dialog.Title.Enc+NoSign"
case
(
_
,
.
EncNoSignature
):
key
=
"Security.Dialog.Title.Enc+NoSign"
case
(
_
,
.
EncButMissingPublicKeyToVerify
):
key
=
"Security.Dialog.Title.EncMissingPublicKeyToVerify"
case
(
_
,
.
EncButMissingPublicKeyToVerify
):
key
=
"Security.Dialog.Title.EncMissingPublicKeyToVerify"
}
}
return
NSLocalizedString
(
key
,
comment
:
""
)
return
NSLocalizedString
(
key
,
comment
:
""
)
}
}
...
@@ -258,8 +268,8 @@ extension DisplayMail {
...
@@ -258,8 +268,8 @@ extension DisplayMail {
case
(
_
,
.
EncValidSign
):
case
(
_
,
.
EncValidSign
):
color
=
ThemeManager
.
encryptedMessageColor
()
color
=
ThemeManager
.
encryptedMessageColor
()
bodyKey
=
"OnboardingIntroSection.Confidential.description"
bodyKey
=
"OnboardingIntroSection.Confidential.description"
// ctaButton -> Ok
// ctaButton -> Ok
case
(
_
,
.
UnableToDecrypt
):
case
(
_
,
.
UnableToDecrypt
):
color
=
ThemeManager
.
troubleMessageColor
()
color
=
ThemeManager
.
troubleMessageColor
()
bodyKey
=
"ReceiveInsecureInfoDecryptionFailed"
bodyKey
=
"ReceiveInsecureInfoDecryptionFailed"
...
@@ -355,16 +365,16 @@ extension DisplayMail {
...
@@ -355,16 +365,16 @@ extension DisplayMail {
get
{
get
{
var
result
=
[
DialogStruct
]
()
var
result
=
[
DialogStruct
]
()
switch
evaluateSecurity
()
{
switch
evaluateSecurity
()
{
case
(
_
,
.
EncValidSign
),
(
_
,
.
NoCrypto
),
(
_
,
.
PlainButValidSignature
),
(
_
,
.
EncNoSignature
):
case
(
_
,
.
EncValidSign
),
(
_
,
.
NoCrypto
),
(
_
,
.
PlainButValidSignature
),
(
_
,
.
EncNoSignature
):
break
// No warning required
break
// No warning required
case
(
_
,
.
UnableToDecrypt
),
(
_
,
.
InvalidSignature
)
,
(
_
,
.
PlainMissingPublicKeyToVerify
),
(
_
,
.
EncButMissingPublicKeyToVerify
):
case
(
_
,
.
UnableToDecrypt
),
(
_
,
.
InvalidSignature
)
,
(
_
,
.
PlainMissingPublicKeyToVerify
),
(
_
,
.
EncButMissingPublicKeyToVerify
):
result
.
append
(
dialog
)
// warning required
result
.
append
(
dialog
)
// warning required
}
}
if
self
.
sender
.
primaryKey
!=
nil
&&
self
.
signatureState
==
.
NoSignature
{
if
self
.
sender
.
primaryKey
!=
nil
&&
self
.
signatureState
==
.
NoSignature
{
let
icon
=
Image
(
systemName
:
"exclamationmark.triangl.fill"
)
let
icon
=
Image
(
systemName
:
"exclamationmark.triangl.fill"
)
let
missingSignature
=
DialogStruct
(
dialogColor
:
Color
(
ThemeManager
.
unencryptedMessageColor
()),
let
missingSignature
=
DialogStruct
(
dialogColor
:
Color
(
ThemeManager
.
unencryptedMessageColor
()),
title
:
NSLocalizedString
(
"encryptedBeforeHeadline"
,
title
:
NSLocalizedString
(
"encryptedBeforeHeadline"
,
comment
:
"encrypted by sender before"
),
comment
:
"encrypted by sender before"
),
body
:
NSLocalizedString
(
"encryptedBeforeText"
,
comment
:
"encrypted by sender before"
),
body
:
NSLocalizedString
(
"encryptedBeforeText"
,
comment
:
"encrypted by sender before"
),
img
:
icon
,
messageImage
:
icon
,
img
:
icon
,
messageImage
:
icon
,
ctaButtonTitle
:
NSLocalizedString
(
"Security.Dialog.Button.Title.Confirmation"
,
comment
:
""
),
ctaButtonTitle
:
NSLocalizedString
(
"Security.Dialog.Button.Title.Confirmation"
,
comment
:
""
),
...
@@ -389,18 +399,18 @@ extension DisplayMail {
...
@@ -389,18 +399,18 @@ extension DisplayMail {
private
func
evaluateCryptoState
()
->
CryptoState
{
private
func
evaluateCryptoState
()
->
CryptoState
{
switch
(
self
.
encryptionState
,
self
.
signatureState
)
{
switch
(
self
.
encryptionState
,
self
.
signatureState
)
{
// General error cases -> cast other states
// General error cases -> cast other states
case
(
.
UnableToDecrypt
,
_
):
return
.
UnableToDecrypt
case
(
.
UnableToDecrypt
,
_
):
return
.
UnableToDecrypt
case
(
_
,
.
InvalidSignature
):
return
.
InvalidSignature
case
(
_
,
.
InvalidSignature
):
return
.
InvalidSignature
case
(
.
NoEncryption
,
.
NoSignature
):
return
.
NoCrypto
case
(
.
NoEncryption
,
.
NoSignature
):
return
.
NoCrypto
case
(
.
NoEncryption
,
.
NoPublicKey
):
return
.
PlainMissingPublicKeyToVerify
case
(
.
NoEncryption
,
.
NoPublicKey
):
return
.
PlainMissingPublicKeyToVerify
case
(
.
NoEncryption
,
.
ValidSignature
):
return
.
PlainButValidSignature
case
(
.
NoEncryption
,
.
ValidSignature
):
return
.
PlainButValidSignature
case
(
.
ValidEncryptedWithOldKey
,
.
ValidSignature
):
return
.
EncValidSign
case
(
.
ValidEncryptedWithOldKey
,
.
ValidSignature
):
return
.
EncValidSign
case
(
.
ValidedEncryptedWithCurrentKey
,
.
ValidSignature
):
return
.
EncValidSign
case
(
.
ValidedEncryptedWithCurrentKey
,
.
ValidSignature
):
return
.
EncValidSign
case
(
.
ValidEncryptedWithOldKey
,
.
NoSignature
):
return
.
EncNoSignature
case
(
.
ValidEncryptedWithOldKey
,
.
NoSignature
):
return
.
EncNoSignature
case
(
.
ValidEncryptedWithOldKey
,
.
NoPublicKey
):
return
.
EncButMissingPublicKeyToVerify
case
(
.
ValidEncryptedWithOldKey
,
.
NoPublicKey
):
return
.
EncButMissingPublicKeyToVerify
case
(
.
ValidedEncryptedWithCurrentKey
,
.
NoSignature
):
return
.
EncNoSignature
case
(
.
ValidedEncryptedWithCurrentKey
,
.
NoSignature
):
return
.
EncNoSignature
case
(
.
ValidedEncryptedWithCurrentKey
,
.
NoPublicKey
):
return
.
EncButMissingPublicKeyToVerify
case
(
.
ValidedEncryptedWithCurrentKey
,
.
NoPublicKey
):
return
.
EncButMissingPublicKeyToVerify
}
}
}
}
...
@@ -421,15 +431,15 @@ extension DisplayMail {
...
@@ -421,15 +431,15 @@ extension DisplayMail {
if
self
.
ccs
.
count
>
0
{
if
self
.
ccs
.
count
>
0
{
body
.
append
(
"
\n\(
NSLocalizedString
(
"Cc"
,
comment
:
""
)
)
: "
)
body
.
append
(
"
\n\(
NSLocalizedString
(
"Cc"
,
comment
:
""
)
)
: "
)
for
addr
in
self
.
ccs
{
for
addr
in
self
.
ccs
{
body
.
append
(
"
\(
addr
.
email
)
, "
)
}
body
.
append
(
"
\(
addr
.
email
)
, "
)
}
}
}
body
.
append
(
"
\n
"
+
NSLocalizedString
(
"subject"
,
comment
:
"describing what subject was choosen"
)
+
": "
+
(
self
.
subject
))
body
.
append
(
"
\n
"
+
NSLocalizedString
(
"subject"
,
comment
:
"describing what subject was choosen"
)
+
": "
+
(
self
.
subject
))
body
.
append
(
"
\n
------------------------
\n\n
"
+
(
self
.
body
))
body
.
append
(
"
\n
------------------------
\n\n
"
+
(
self
.
body
))
body
=
body
.
components
(
separatedBy
:
"
\n
"
)
.
map
{
line
in
body
=
body
.
components
(
separatedBy
:
"
\n
"
)
.
map
{
line
in
if
line
.
hasPrefix
(
">"
)
{
if
line
.
hasPrefix
(
">"
)
{
return
">"
+
line
return
">"
+
line
}
}
return
"> "
+
line
return
"> "
+
line
}
.
reduce
(
""
,
{
$0
+
"
\n
"
+
$1
})
}
.
reduce
(
""
,
{
$0
+
"
\n
"
+
$1
})
return
body
return
body
}
}
...
...
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