IOS-1480 Move files. refactor
authorDirk Zimmermann <dz@pep.security>
Tue, 12 Feb 2019 16:04:14 +0100
branchrefactor
changeset 762147d2b38d27c8
parent 7620 7caf4d149c17
child 7622 a63dcb52ec64
IOS-1480 Move files.
pEpForiOS.xcodeproj/project.pbxproj
pEpForiOS/Background/BaseOperation.swift
pEpForiOS/Background/CreateRequiredFoldersOperation.swift
pEpForiOS/Background/DecryptMessagesOperation.swift
pEpForiOS/Background/EncryptAndSendOperation.swift
pEpForiOS/Background/Error/ErrorContainer.swift
pEpForiOS/Background/Error/ServiceErrorProtocol.swift
pEpForiOS/Background/FixAttachmentsOperation.swift
pEpForiOS/Background/SelfReferencingOperation.swift
pEpForiOS/Background/SyncFoldersFromServerOperation.swift
pEpForiOS/Error/ErrorPropagator.swift
pEpForiOS/Network/Service/FetchNumberOfNewMailsService.swift
pEpForiOS/Network/Service/ImapConnectionDataCache.swift
pEpForiOS/Network/Service/LoginImapOperation.swift
pEpForiOS/Network/Service/LoginSmtpOperation.swift
pEpForiOS/Network/Service/ServiceUtil.swift
pEpForiOS/Network/Service/SharedObjects.swift
pEpForiOS/Util/BackgroundTaskProtocol.swift
pEpForiOS/Util/GCD.swift
pEpForiOS/Util/KickOffMySelfProtocol.swift
     1.1 --- a/pEpForiOS.xcodeproj/project.pbxproj	Tue Feb 12 16:04:14 2019 +0100
     1.2 +++ b/pEpForiOS.xcodeproj/project.pbxproj	Tue Feb 12 16:04:14 2019 +0100
     1.3 @@ -31,7 +31,6 @@
     1.4  		004422CA2179ECD600BDF6DF /* PassiveModeViewModelTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 004422C92179ECD600BDF6DF /* PassiveModeViewModelTest.swift */; };
     1.5  		004422D9217A25AD00BDF6DF /* UnencryptedSubjectViewModelTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 004422D8217A25AD00BDF6DF /* UnencryptedSubjectViewModelTest.swift */; };
     1.6  		004A8C552112FDD500203143 /* EmailListView+UITableViewDataSourcePrefetching.swift in Sources */ = {isa = PBXBuildFile; fileRef = 004A8C542112FDD500203143 /* EmailListView+UITableViewDataSourcePrefetching.swift */; };
     1.7 -		004A8C5B211316E100203143 /* SelfReferencingOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 004A8C5A211316E100203143 /* SelfReferencingOperation.swift */; };
     1.8  		005A21FB20CAA5F50082D19F /* ThreadedEmailViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 005A21FA20CAA5F50082D19F /* ThreadedEmailViewModel.swift */; };
     1.9  		0069DCFB2110679200846EB1 /* EmailViewController+UIPopoverPresentationControllerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0069DCFA2110679200846EB1 /* EmailViewController+UIPopoverPresentationControllerDelegate.swift */; };
    1.10  		006BE6BC20F4B63C00DDE8C9 /* EmailDetailType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 006BE6BB20F4B63C00DDE8C9 /* EmailDetailType.swift */; };
    1.11 @@ -52,7 +51,6 @@
    1.12  		1508AEAA1F862C85001D5230 /* SortedSetTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1508AEA91F862C85001D5230 /* SortedSetTest.swift */; };
    1.13  		150B84C420A44DE100D8B288 /* MoveToFolderOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 150B84C320A44DE100D8B288 /* MoveToFolderOperation.swift */; };
    1.14  		150B84C620A5DD0600D8B288 /* UIDCopyOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 150B84C520A5DD0600D8B288 /* UIDCopyOperation.swift */; };
    1.15 -		150B8E981FCDACBB00374438 /* ErrorPropagator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 150B8E961FCDACBB00374438 /* ErrorPropagator.swift */; };
    1.16  		150B8E991FCDACBB00374438 /* AccountSettingsUserInputError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 150B8E971FCDACBB00374438 /* AccountSettingsUserInputError.swift */; };
    1.17  		150B8EB31FCEB93D00374438 /* UIUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 150B8EB21FCEB93D00374438 /* UIUtils.swift */; };
    1.18  		150DF6D02052A13700A9DCF7 /* SecureWebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 150DF6CF2052A13700A9DCF7 /* SecureWebViewController.swift */; };
    1.19 @@ -142,7 +140,6 @@
    1.20  		154F0A842087779200C77D72 /* ContentDispositionType + Conversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 154F0A832087779200C77D72 /* ContentDispositionType + Conversion.swift */; };
    1.21  		155050F01FE82356009CEAD2 /* UserNotificationTool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 155050EF1FE82356009CEAD2 /* UserNotificationTool.swift */; };
    1.22  		155050F21FE95D8A009CEAD2 /* UserNotificationTool+pEp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 155050F11FE95D8A009CEAD2 /* UserNotificationTool+pEp.swift */; };
    1.23 -		155050F61FEAB082009CEAD2 /* ErrorContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 155050F51FEAB082009CEAD2 /* ErrorContainer.swift */; };
    1.24  		155050F81FEAB57F009CEAD2 /* BackgroundError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 155050F71FEAB57F009CEAD2 /* BackgroundError.swift */; };
    1.25  		1554755F2137F6F8005A52D0 /* SwipeActionDescriptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1554755E2137F6F8005A52D0 /* SwipeActionDescriptor.swift */; };
    1.26  		155475642137FD96005A52D0 /* FolderType+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 155475632137FD96005A52D0 /* FolderType+Extensions.swift */; };
    1.27 @@ -185,7 +182,6 @@
    1.28  		15874BD12127493E00A3A4A6 /* TrustedServerSettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15874BBF2127493E00A3A4A6 /* TrustedServerSettingsViewModel.swift */; };
    1.29  		15874BD22127493E00A3A4A6 /* TrustedServerSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15874BC02127493E00A3A4A6 /* TrustedServerSettingsViewController.swift */; };
    1.30  		15874BD421274BD400A3A4A6 /* TrustedServerSettingCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15874BD321274BD400A3A4A6 /* TrustedServerSettingCell.swift */; };
    1.31 -		1587D1632049BE7D002C2157 /* ImapConnectionDataCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1587D1622049BE7D002C2157 /* ImapConnectionDataCache.swift */; };
    1.32  		1594C1D021281FCD00CB06E2 /* Server+Fetching.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1594C1CF21281FCD00CB06E2 /* Server+Fetching.swift */; };
    1.33  		159F4C9C21BEB9ED00244903 /* Message+FakeMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 159F4C9B21BEB9ED00244903 /* Message+FakeMessage.swift */; };
    1.34  		15A536902155136800CF6204 /* PEPUtilTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15A5368F2155136800CF6204 /* PEPUtilTest.swift */; };
    1.35 @@ -251,7 +247,6 @@
    1.36  		430E5F201EBC87A700E5D5D3 /* LanguageListTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430E5F1F1EBC87A700E5D5D3 /* LanguageListTableViewCell.swift */; };
    1.37  		43106A192045716000693144 /* OAuth2ConfigurationProtocol+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43106A182045716000693144 /* OAuth2ConfigurationProtocol+Extension.swift */; };
    1.38  		431144B51CC0FCA40007639D /* StoreFolderOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 431144B41CC0FCA40007639D /* StoreFolderOperation.swift */; };
    1.39 -		431144B71CC11D6A0007639D /* BaseOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 431144B61CC11D6A0007639D /* BaseOperation.swift */; };
    1.40  		431144B91CC11DF30007639D /* StorePrefetchedMailOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 431144B81CC11DF30007639D /* StorePrefetchedMailOperation.swift */; };
    1.41  		43122B191DF5B48B00610253 /* EmailService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43122B141DF5B48B00610253 /* EmailService.swift */; };
    1.42  		43122B1A1DF5B48B00610253 /* ImapService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43122B151DF5B48B00610253 /* ImapService.swift */; };
    1.43 @@ -279,10 +274,6 @@
    1.44  		431E8F7E1CFDCF3A00C33647 /* EmailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 431E8F7D1CFDCF3A00C33647 /* EmailViewController.swift */; };
    1.45  		431F987F1F6FD3E300A1E4D2 /* HandshakePartnerTableViewCellViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 431F987E1F6FD3E300A1E4D2 /* HandshakePartnerTableViewCellViewModelTests.swift */; };
    1.46  		43209B541ECC5A9B007E7E2E /* libpEpObjCAdapter.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 43209B531ECC5A9B007E7E2E /* libpEpObjCAdapter.a */; };
    1.47 -		432142641E8FD66900FBE987 /* FetchNumberOfNewMailsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 432142631E8FD66900FBE987 /* FetchNumberOfNewMailsService.swift */; };
    1.48 -		432142661E8FD6A400FBE987 /* ServiceUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 432142651E8FD6A400FBE987 /* ServiceUtil.swift */; };
    1.49 -		432198E81DF6B51B00318A74 /* LoginImapOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 432198E71DF6B51B00318A74 /* LoginImapOperation.swift */; };
    1.50 -		432198ED1DF6B66800318A74 /* SharedObjects.swift in Sources */ = {isa = PBXBuildFile; fileRef = 432198EC1DF6B66800318A74 /* SharedObjects.swift */; };
    1.51  		4322E82F1F9DE8260011FC55 /* Microsoft_Outlook_Probing_Message_001.txt in Resources */ = {isa = PBXBuildFile; fileRef = 4322E82E1F9DE8260011FC55 /* Microsoft_Outlook_Probing_Message_001.txt */; };
    1.52  		4323FE861E83D6FF006785E1 /* ImapFolderBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4323FE851E83D6FF006785E1 /* ImapFolderBuilder.swift */; };
    1.53  		43257C801F50064100DDC7F0 /* HtmlToTextSaxParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43257C7F1F50064100DDC7F0 /* HtmlToTextSaxParser.swift */; };
    1.54 @@ -307,12 +298,10 @@
    1.55  		43306EBE1FE125B50045DD00 /* OAuth2Authorization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43306EBD1FE125B50045DD00 /* OAuth2Authorization.swift */; };
    1.56  		43306EC21FE129840045DD00 /* OAuth2Type.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43306EC11FE129840045DD00 /* OAuth2Type.swift */; };
    1.57  		43313DFC1DEC7F6000C111C8 /* DeleteFoldersOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43313DFB1DEC7F6000C111C8 /* DeleteFoldersOperation.swift */; };
    1.58 -		4333A2A51E5C9B6E0025D8A5 /* FixAttachmentsOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4333A2A41E5C9B6E0025D8A5 /* FixAttachmentsOperation.swift */; };
    1.59  		4334CF302020CFFE00B3193E /* OAuth2Type+LibAccountSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4334CF2F2020CFFE00B3193E /* OAuth2Type+LibAccountSettings.swift */; };
    1.60  		4336229E1DC76B8100133B3D /* MessageModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4336229D1DC76B8100133B3D /* MessageModelTests.swift */; };
    1.61  		4337E52A21B68FCA00826CAB /* Thread+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4337E52921B68FCA00826CAB /* Thread+Extension.swift */; };
    1.62  		433BCD951D5388C100DD98EF /* ReplyUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 433BCD941D5388C100DD98EF /* ReplyUtil.swift */; };
    1.63 -		433C51D31E66CCA900272E19 /* CreateRequiredFoldersOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 433C51D11E66CB9C00272E19 /* CreateRequiredFoldersOperation.swift */; };
    1.64  		433F2E2A21E3581800E1CA49 /* ENGINE-505_Mail_NullInnerMimeType.txt in Resources */ = {isa = PBXBuildFile; fileRef = 433F2E2921E3581800E1CA49 /* ENGINE-505_Mail_NullInnerMimeType.txt */; };
    1.65  		4341980520AB037E0062F7F6 /* CGImageSource+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4341980420AB037E0062F7F6 /* CGImageSource+Extension.swift */; };
    1.66  		4341EBCF2089F674004CE6B8 /* QualifyServerIsLocalOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4341EBCE2089F674004CE6B8 /* QualifyServerIsLocalOperation.swift */; };
    1.67 @@ -320,7 +309,6 @@
    1.68  		43425EDB1FE3DE6E004A2728 /* OAuth2ProviderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43425EDA1FE3DE6E004A2728 /* OAuth2ProviderProtocol.swift */; };
    1.69  		43425EDD1FE3DF3B004A2728 /* OAuth2Provider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43425EDC1FE3DF3B004A2728 /* OAuth2Provider.swift */; };
    1.70  		43425EDF1FE3E052004A2728 /* OAuth2ProviderFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43425EDE1FE3E052004A2728 /* OAuth2ProviderFactory.swift */; };
    1.71 -		4348EF0D1E27ABA100F441A9 /* LoginSmtpOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4348EF0C1E27ABA100F441A9 /* LoginSmtpOperation.swift */; };
    1.72  		4348EF151E27E37400F441A9 /* Unit 1 unittest.ios.1@peptest.ch (0x9CB8DBCC) pub.asc in Resources */ = {isa = PBXBuildFile; fileRef = 4348EF141E27E37400F441A9 /* Unit 1 unittest.ios.1@peptest.ch (0x9CB8DBCC) pub.asc */; };
    1.73  		43497B38211C62DE00AC42B0 /* MessageIdentitfying.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43497B37211C62DE00AC42B0 /* MessageIdentitfying.swift */; };
    1.74  		43497B3A211C63CA00AC42B0 /* Message+MessageIdentitfying.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43497B39211C63CA00AC42B0 /* Message+MessageIdentitfying.swift */; };
    1.75 @@ -376,8 +364,6 @@
    1.76  		436795FF1EE98F6E00B03E23 /* CommunicationTypeTests_test001@peptest.ch_sec.asc in Resources */ = {isa = PBXBuildFile; fileRef = 436795FD1EE98F6E00B03E23 /* CommunicationTypeTests_test001@peptest.ch_sec.asc */; };
    1.77  		436796001EE98F6E00B03E23 /* CommunicationTypeTests_test001@peptest.ch.asc in Resources */ = {isa = PBXBuildFile; fileRef = 436795FE1EE98F6E00B03E23 /* CommunicationTypeTests_test001@peptest.ch.asc */; };
    1.78  		436796021EE9909100B03E23 /* CommunicationTypeTests_Message_test001_to_test002.txt in Resources */ = {isa = PBXBuildFile; fileRef = 436796011EE9909100B03E23 /* CommunicationTypeTests_Message_test001_to_test002.txt */; };
    1.79 -		436C23281E02948400071430 /* BackgroundTaskProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 436C23271E02948400071430 /* BackgroundTaskProtocol.swift */; };
    1.80 -		436C232D1E02A2D900071430 /* KickOffMySelfProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 436C232C1E02A2D900071430 /* KickOffMySelfProtocol.swift */; };
    1.81  		436C232F1E02A52D00071430 /* LimitedOperationQueue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 436C232E1E02A52D00071430 /* LimitedOperationQueue.swift */; };
    1.82  		436D0066215B5F3800966CC2 /* Undisplayable_HTML_Message.txt in Resources */ = {isa = PBXBuildFile; fileRef = 436D0065215B5F3800966CC2 /* Undisplayable_HTML_Message.txt */; };
    1.83  		436F8E141D36706A007E9829 /* StringExtensionsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 436F8E131D36706A007E9829 /* StringExtensionsTest.swift */; };
    1.84 @@ -422,9 +408,7 @@
    1.85  		439D40701CC78930009A4E7C /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 439D406F1CC78930009A4E7C /* libz.tbd */; };
    1.86  		439D40721CC78958009A4E7C /* libbz2.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 439D40711CC78958009A4E7C /* libbz2.tbd */; };
    1.87  		439D40741CC7897B009A4E7C /* libiconv.2.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 439D40731CC7897B009A4E7C /* libiconv.2.tbd */; };
    1.88 -		439D407A1CC79423009A4E7C /* GCD.swift in Sources */ = {isa = PBXBuildFile; fileRef = 439D40791CC79423009A4E7C /* GCD.swift */; };
    1.89  		43A0B2CF214006FC00FB779D /* ReplyUtilTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43A0B2CE214006FC00FB779D /* ReplyUtilTests.swift */; };
    1.90 -		43A26FBA1E0408FB00AF0B84 /* ServiceErrorProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43A26FB91E0408FB00AF0B84 /* ServiceErrorProtocol.swift */; };
    1.91  		43A26FBF1E041BF200AF0B84 /* ImapSyncOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43A26FBE1E041BF200AF0B84 /* ImapSyncOperation.swift */; };
    1.92  		43A384812153E4BF006AC8F8 /* 8B691AD204E22FD1BF018E0D6C9EAD5A798018D1_pub_sec.txt in Resources */ = {isa = PBXBuildFile; fileRef = 43A384802153E4BF006AC8F8 /* 8B691AD204E22FD1BF018E0D6C9EAD5A798018D1_pub_sec.txt */; };
    1.93  		43A469FA21513B10002E1036 /* PEPSwipeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43A469F921513B10002E1036 /* PEPSwipeTableViewCell.swift */; };
    1.94 @@ -447,7 +431,6 @@
    1.95  		43B54F961FE02D02008EC427 /* AppAuth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 43B54F971FE02D02008EC427 /* AppAuth.framework */; };
    1.96  		43B7154D1CECAADA0027861A /* ViewWidthsAligner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43B7154C1CECAADA0027861A /* ViewWidthsAligner.swift */; };
    1.97  		43BB86941DB4E76D00980267 /* CdAccount+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43BB86931DB4E76D00980267 /* CdAccount+Extension.swift */; };
    1.98 -		43BBB5E71E267A3800104070 /* EncryptAndSendOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43BBB5E61E267A3800104070 /* EncryptAndSendOperation.swift */; };
    1.99  		43C046BF1CF48EA500BD0D9D /* AddressBook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 43C046BE1CF48EA500BD0D9D /* AddressBook.framework */; };
   1.100  		43C273DB21C8F96D002EB4C8 /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C273DA21C8F96D002EB4C8 /* Logger.swift */; };
   1.101  		43C273DD21C9024A002EB4C8 /* LoggerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C273DC21C9024A002EB4C8 /* LoggerTest.swift */; };
   1.102 @@ -510,7 +493,6 @@
   1.103  		43F7F07A1F6AD44600BDF151 /* HandshakeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43F7F0791F6AD44600BDF151 /* HandshakeTests.swift */; };
   1.104  		43F7F07C1F6AD4FD00BDF151 /* HandshakeTests_mail_001.txt in Resources */ = {isa = PBXBuildFile; fileRef = 43F7F07B1F6AD4FD00BDF151 /* HandshakeTests_mail_001.txt */; };
   1.105  		43F848491EAA09AE00DBE460 /* Weak.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43F848481EAA09AE00DBE460 /* Weak.swift */; };
   1.106 -		43F84CD21CD899760092FCAE /* SyncFoldersFromServerOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43F84CD11CD899760092FCAE /* SyncFoldersFromServerOperation.swift */; };
   1.107  		43F9D99A1E92725700F78A1C /* AttachmentsViewHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43F9D9991E92725700F78A1C /* AttachmentsViewHelper.swift */; };
   1.108  		43FAA0D21EC9972B005BFC4B /* Tuple.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43FAA0D11EC9972B005BFC4B /* Tuple.swift */; };
   1.109  		43FAA0D41EC9CBC0005BFC4B /* DecryptionTestsInternal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43FAA0D31EC9CBC0005BFC4B /* DecryptionTestsInternal.swift */; };
   1.110 @@ -547,7 +529,6 @@
   1.111  		49DCCD2721E8ABD600ABE487 /* javascript.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 49079D9821E3867900D15A0D /* javascript.pdf */; };
   1.112  		49DCCD2821E8ABDF00ABE487 /* ScreenshotTestUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 495F689921E6600500A10C63 /* ScreenshotTestUtil.swift */; };
   1.113  		5D039A9C1D0EE7F900AD59EC /* PEPUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D039A9B1D0EE7F900AD59EC /* PEPUtil.swift */; };
   1.114 -		5D039AA21D0EEA3700AD59EC /* DecryptMessagesOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D039AA11D0EEA3700AD59EC /* DecryptMessagesOperation.swift */; };
   1.115  		5DEBAA481DE59C3B00FAE12C /* NetworkServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DEBAA471DE59C3B00FAE12C /* NetworkServiceTests.swift */; };
   1.116  		8B69E3991E30F80E0022959E /* Appearance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B69E3981E30F80E0022959E /* Appearance.swift */; };
   1.117  		8B81BB901E03F73100D38C82 /* SegueHandlerType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B81BB8F1E03F73100D38C82 /* SegueHandlerType.swift */; };
   1.118 @@ -639,7 +620,6 @@
   1.119  		004422C92179ECD600BDF6DF /* PassiveModeViewModelTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PassiveModeViewModelTest.swift; sourceTree = "<group>"; };
   1.120  		004422D8217A25AD00BDF6DF /* UnencryptedSubjectViewModelTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnencryptedSubjectViewModelTest.swift; sourceTree = "<group>"; };
   1.121  		004A8C542112FDD500203143 /* EmailListView+UITableViewDataSourcePrefetching.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "EmailListView+UITableViewDataSourcePrefetching.swift"; sourceTree = "<group>"; };
   1.122 -		004A8C5A211316E100203143 /* SelfReferencingOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelfReferencingOperation.swift; sourceTree = "<group>"; };
   1.123  		005A21FA20CAA5F50082D19F /* ThreadedEmailViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThreadedEmailViewModel.swift; sourceTree = "<group>"; };
   1.124  		0069DCFA2110679200846EB1 /* EmailViewController+UIPopoverPresentationControllerDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "EmailViewController+UIPopoverPresentationControllerDelegate.swift"; sourceTree = "<group>"; };
   1.125  		006BE6BB20F4B63C00DDE8C9 /* EmailDetailType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmailDetailType.swift; sourceTree = "<group>"; };
   1.126 @@ -660,7 +640,6 @@
   1.127  		1508AEA91F862C85001D5230 /* SortedSetTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SortedSetTest.swift; sourceTree = "<group>"; };
   1.128  		150B84C320A44DE100D8B288 /* MoveToFolderOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoveToFolderOperation.swift; sourceTree = "<group>"; };
   1.129  		150B84C520A5DD0600D8B288 /* UIDCopyOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIDCopyOperation.swift; sourceTree = "<group>"; };
   1.130 -		150B8E961FCDACBB00374438 /* ErrorPropagator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ErrorPropagator.swift; sourceTree = "<group>"; };
   1.131  		150B8E971FCDACBB00374438 /* AccountSettingsUserInputError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountSettingsUserInputError.swift; sourceTree = "<group>"; };
   1.132  		150B8EB21FCEB93D00374438 /* UIUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIUtils.swift; sourceTree = "<group>"; };
   1.133  		150DF6CF2052A13700A9DCF7 /* SecureWebViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecureWebViewController.swift; sourceTree = "<group>"; };
   1.134 @@ -751,7 +730,6 @@
   1.135  		154F0A832087779200C77D72 /* ContentDispositionType + Conversion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ContentDispositionType + Conversion.swift"; sourceTree = "<group>"; };
   1.136  		155050EF1FE82356009CEAD2 /* UserNotificationTool.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserNotificationTool.swift; sourceTree = "<group>"; };
   1.137  		155050F11FE95D8A009CEAD2 /* UserNotificationTool+pEp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserNotificationTool+pEp.swift"; sourceTree = "<group>"; };
   1.138 -		155050F51FEAB082009CEAD2 /* ErrorContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ErrorContainer.swift; sourceTree = "<group>"; };
   1.139  		155050F71FEAB57F009CEAD2 /* BackgroundError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackgroundError.swift; sourceTree = "<group>"; };
   1.140  		1554755E2137F6F8005A52D0 /* SwipeActionDescriptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwipeActionDescriptor.swift; sourceTree = "<group>"; };
   1.141  		155475632137FD96005A52D0 /* FolderType+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FolderType+Extensions.swift"; sourceTree = "<group>"; };
   1.142 @@ -794,7 +772,6 @@
   1.143  		15874BBF2127493E00A3A4A6 /* TrustedServerSettingsViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TrustedServerSettingsViewModel.swift; sourceTree = "<group>"; };
   1.144  		15874BC02127493E00A3A4A6 /* TrustedServerSettingsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TrustedServerSettingsViewController.swift; sourceTree = "<group>"; };
   1.145  		15874BD321274BD400A3A4A6 /* TrustedServerSettingCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrustedServerSettingCell.swift; sourceTree = "<group>"; };
   1.146 -		1587D1622049BE7D002C2157 /* ImapConnectionDataCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImapConnectionDataCache.swift; sourceTree = "<group>"; };
   1.147  		1594C1CF21281FCD00CB06E2 /* Server+Fetching.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Server+Fetching.swift"; sourceTree = "<group>"; };
   1.148  		159F4C9B21BEB9ED00244903 /* Message+FakeMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Message+FakeMessage.swift"; sourceTree = "<group>"; };
   1.149  		15A5368F2155136800CF6204 /* PEPUtilTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PEPUtilTest.swift; sourceTree = "<group>"; };
   1.150 @@ -857,7 +834,6 @@
   1.151  		430E5F1F1EBC87A700E5D5D3 /* LanguageListTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LanguageListTableViewCell.swift; sourceTree = "<group>"; };
   1.152  		43106A182045716000693144 /* OAuth2ConfigurationProtocol+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OAuth2ConfigurationProtocol+Extension.swift"; sourceTree = "<group>"; };
   1.153  		431144B41CC0FCA40007639D /* StoreFolderOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StoreFolderOperation.swift; sourceTree = "<group>"; };
   1.154 -		431144B61CC11D6A0007639D /* BaseOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseOperation.swift; sourceTree = "<group>"; };
   1.155  		431144B81CC11DF30007639D /* StorePrefetchedMailOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorePrefetchedMailOperation.swift; sourceTree = "<group>"; };
   1.156  		43122B141DF5B48B00610253 /* EmailService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmailService.swift; sourceTree = "<group>"; };
   1.157  		43122B151DF5B48B00610253 /* ImapService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImapService.swift; sourceTree = "<group>"; };
   1.158 @@ -886,10 +862,6 @@
   1.159  		431E8F7D1CFDCF3A00C33647 /* EmailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmailViewController.swift; sourceTree = "<group>"; };
   1.160  		431F987E1F6FD3E300A1E4D2 /* HandshakePartnerTableViewCellViewModelTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HandshakePartnerTableViewCellViewModelTests.swift; sourceTree = "<group>"; };
   1.161  		43209B531ECC5A9B007E7E2E /* libpEpObjCAdapter.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpEpObjCAdapter.a; path = "../pEpObjCAdapter/build/Debug-iphoneos/libpEpObjCAdapter.a"; sourceTree = "<group>"; };
   1.162 -		432142631E8FD66900FBE987 /* FetchNumberOfNewMailsService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchNumberOfNewMailsService.swift; sourceTree = "<group>"; };
   1.163 -		432142651E8FD6A400FBE987 /* ServiceUtil.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServiceUtil.swift; sourceTree = "<group>"; };
   1.164 -		432198E71DF6B51B00318A74 /* LoginImapOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginImapOperation.swift; sourceTree = "<group>"; };
   1.165 -		432198EC1DF6B66800318A74 /* SharedObjects.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SharedObjects.swift; sourceTree = "<group>"; };
   1.166  		4322E82E1F9DE8260011FC55 /* Microsoft_Outlook_Probing_Message_001.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Microsoft_Outlook_Probing_Message_001.txt; sourceTree = "<group>"; };
   1.167  		4323FE851E83D6FF006785E1 /* ImapFolderBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImapFolderBuilder.swift; sourceTree = "<group>"; };
   1.168  		43257C7F1F50064100DDC7F0 /* HtmlToTextSaxParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HtmlToTextSaxParser.swift; sourceTree = "<group>"; };
   1.169 @@ -914,13 +886,11 @@
   1.170  		43306EBD1FE125B50045DD00 /* OAuth2Authorization.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OAuth2Authorization.swift; sourceTree = "<group>"; };
   1.171  		43306EC11FE129840045DD00 /* OAuth2Type.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OAuth2Type.swift; sourceTree = "<group>"; };
   1.172  		43313DFB1DEC7F6000C111C8 /* DeleteFoldersOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeleteFoldersOperation.swift; sourceTree = "<group>"; };
   1.173 -		4333A2A41E5C9B6E0025D8A5 /* FixAttachmentsOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FixAttachmentsOperation.swift; sourceTree = "<group>"; };
   1.174  		4334CF2F2020CFFE00B3193E /* OAuth2Type+LibAccountSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OAuth2Type+LibAccountSettings.swift"; sourceTree = "<group>"; };
   1.175  		4336229D1DC76B8100133B3D /* MessageModelTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageModelTests.swift; sourceTree = "<group>"; };
   1.176  		433724FC1DA2C2B1005E8DF5 /* pEp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = pEp.entitlements; path = ../pEp.entitlements; sourceTree = "<group>"; };
   1.177  		4337E52921B68FCA00826CAB /* Thread+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Thread+Extension.swift"; sourceTree = "<group>"; };
   1.178  		433BCD941D5388C100DD98EF /* ReplyUtil.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReplyUtil.swift; sourceTree = "<group>"; };
   1.179 -		433C51D11E66CB9C00272E19 /* CreateRequiredFoldersOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CreateRequiredFoldersOperation.swift; sourceTree = "<group>"; };
   1.180  		433F2E2921E3581800E1CA49 /* ENGINE-505_Mail_NullInnerMimeType.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = "ENGINE-505_Mail_NullInnerMimeType.txt"; sourceTree = "<group>"; };
   1.181  		4341980420AB037E0062F7F6 /* CGImageSource+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CGImageSource+Extension.swift"; sourceTree = "<group>"; };
   1.182  		4341EBCE2089F674004CE6B8 /* QualifyServerIsLocalOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QualifyServerIsLocalOperation.swift; sourceTree = "<group>"; };
   1.183 @@ -928,7 +898,6 @@
   1.184  		43425EDA1FE3DE6E004A2728 /* OAuth2ProviderProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OAuth2ProviderProtocol.swift; sourceTree = "<group>"; };
   1.185  		43425EDC1FE3DF3B004A2728 /* OAuth2Provider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OAuth2Provider.swift; sourceTree = "<group>"; };
   1.186  		43425EDE1FE3E052004A2728 /* OAuth2ProviderFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OAuth2ProviderFactory.swift; sourceTree = "<group>"; };
   1.187 -		4348EF0C1E27ABA100F441A9 /* LoginSmtpOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginSmtpOperation.swift; sourceTree = "<group>"; };
   1.188  		4348EF141E27E37400F441A9 /* Unit 1 unittest.ios.1@peptest.ch (0x9CB8DBCC) pub.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "Unit 1 unittest.ios.1@peptest.ch (0x9CB8DBCC) pub.asc"; sourceTree = "<group>"; };
   1.189  		43497B37211C62DE00AC42B0 /* MessageIdentitfying.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageIdentitfying.swift; sourceTree = "<group>"; };
   1.190  		43497B39211C63CA00AC42B0 /* Message+MessageIdentitfying.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Message+MessageIdentitfying.swift"; sourceTree = "<group>"; };
   1.191 @@ -1003,8 +972,6 @@
   1.192  		436795FD1EE98F6E00B03E23 /* CommunicationTypeTests_test001@peptest.ch_sec.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "CommunicationTypeTests_test001@peptest.ch_sec.asc"; sourceTree = "<group>"; };
   1.193  		436795FE1EE98F6E00B03E23 /* CommunicationTypeTests_test001@peptest.ch.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "CommunicationTypeTests_test001@peptest.ch.asc"; sourceTree = "<group>"; };
   1.194  		436796011EE9909100B03E23 /* CommunicationTypeTests_Message_test001_to_test002.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CommunicationTypeTests_Message_test001_to_test002.txt; sourceTree = "<group>"; };
   1.195 -		436C23271E02948400071430 /* BackgroundTaskProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BackgroundTaskProtocol.swift; sourceTree = "<group>"; };
   1.196 -		436C232C1E02A2D900071430 /* KickOffMySelfProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KickOffMySelfProtocol.swift; sourceTree = "<group>"; };
   1.197  		436C232E1E02A52D00071430 /* LimitedOperationQueue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LimitedOperationQueue.swift; sourceTree = "<group>"; };
   1.198  		436C5A8D1CFEDF59006A195F /* UIHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIHelper.swift; sourceTree = "<group>"; };
   1.199  		436D0065215B5F3800966CC2 /* Undisplayable_HTML_Message.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Undisplayable_HTML_Message.txt; sourceTree = "<group>"; };
   1.200 @@ -1060,9 +1027,7 @@
   1.201  		439D406F1CC78930009A4E7C /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
   1.202  		439D40711CC78958009A4E7C /* libbz2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libbz2.tbd; path = usr/lib/libbz2.tbd; sourceTree = SDKROOT; };
   1.203  		439D40731CC7897B009A4E7C /* libiconv.2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libiconv.2.tbd; path = usr/lib/libiconv.2.tbd; sourceTree = SDKROOT; };
   1.204 -		439D40791CC79423009A4E7C /* GCD.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GCD.swift; sourceTree = "<group>"; };
   1.205  		43A0B2CE214006FC00FB779D /* ReplyUtilTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReplyUtilTests.swift; sourceTree = "<group>"; };
   1.206 -		43A26FB91E0408FB00AF0B84 /* ServiceErrorProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServiceErrorProtocol.swift; sourceTree = "<group>"; };
   1.207  		43A26FBE1E041BF200AF0B84 /* ImapSyncOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImapSyncOperation.swift; sourceTree = "<group>"; };
   1.208  		43A384802153E4BF006AC8F8 /* 8B691AD204E22FD1BF018E0D6C9EAD5A798018D1_pub_sec.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = 8B691AD204E22FD1BF018E0D6C9EAD5A798018D1_pub_sec.txt; sourceTree = "<group>"; };
   1.209  		43A469F921513B10002E1036 /* PEPSwipeTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PEPSwipeTableViewCell.swift; sourceTree = "<group>"; };
   1.210 @@ -1086,7 +1051,6 @@
   1.211  		43B54F971FE02D02008EC427 /* AppAuth.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = AppAuth.framework; sourceTree = BUILT_PRODUCTS_DIR; };
   1.212  		43B7154C1CECAADA0027861A /* ViewWidthsAligner.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewWidthsAligner.swift; sourceTree = "<group>"; };
   1.213  		43BB86931DB4E76D00980267 /* CdAccount+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CdAccount+Extension.swift"; sourceTree = "<group>"; };
   1.214 -		43BBB5E61E267A3800104070 /* EncryptAndSendOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EncryptAndSendOperation.swift; sourceTree = "<group>"; };
   1.215  		43C046BE1CF48EA500BD0D9D /* AddressBook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBook.framework; path = System/Library/Frameworks/AddressBook.framework; sourceTree = SDKROOT; };
   1.216  		43C273DA21C8F96D002EB4C8 /* Logger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = "<group>"; };
   1.217  		43C273DC21C9024A002EB4C8 /* LoggerTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggerTest.swift; sourceTree = "<group>"; };
   1.218 @@ -1155,7 +1119,6 @@
   1.219  		43F7F0791F6AD44600BDF151 /* HandshakeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HandshakeTests.swift; sourceTree = "<group>"; };
   1.220  		43F7F07B1F6AD4FD00BDF151 /* HandshakeTests_mail_001.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HandshakeTests_mail_001.txt; sourceTree = "<group>"; };
   1.221  		43F848481EAA09AE00DBE460 /* Weak.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Weak.swift; sourceTree = "<group>"; };
   1.222 -		43F84CD11CD899760092FCAE /* SyncFoldersFromServerOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SyncFoldersFromServerOperation.swift; sourceTree = "<group>"; };
   1.223  		43F9D9991E92725700F78A1C /* AttachmentsViewHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AttachmentsViewHelper.swift; sourceTree = "<group>"; };
   1.224  		43FAA0D11EC9972B005BFC4B /* Tuple.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Tuple.swift; sourceTree = "<group>"; };
   1.225  		43FAA0D31EC9CBC0005BFC4B /* DecryptionTestsInternal.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DecryptionTestsInternal.swift; sourceTree = "<group>"; };
   1.226 @@ -1193,7 +1156,6 @@
   1.227  		49D521561E73E1C70097987B /* ServerConfig.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = ServerConfig.framework; sourceTree = BUILT_PRODUCTS_DIR; };
   1.228  		49DCCD1F21E75BE300ABE487 /* nojavascript.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = nojavascript.pdf; sourceTree = "<group>"; };
   1.229  		5D039A9B1D0EE7F900AD59EC /* PEPUtil.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PEPUtil.swift; sourceTree = "<group>"; };
   1.230 -		5D039AA11D0EEA3700AD59EC /* DecryptMessagesOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DecryptMessagesOperation.swift; sourceTree = "<group>"; };
   1.231  		5DEBAA471DE59C3B00FAE12C /* NetworkServiceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkServiceTests.swift; sourceTree = "<group>"; };
   1.232  		8B69E3981E30F80E0022959E /* Appearance.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Appearance.swift; sourceTree = "<group>"; };
   1.233  		8B81BB8F1E03F73100D38C82 /* SegueHandlerType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SegueHandlerType.swift; sourceTree = "<group>"; };
   1.234 @@ -1318,7 +1280,6 @@
   1.235  		150B8E951FCDACBB00374438 /* Error */ = {
   1.236  			isa = PBXGroup;
   1.237  			children = (
   1.238 -				150B8E961FCDACBB00374438 /* ErrorPropagator.swift */,
   1.239  				150B8E971FCDACBB00374438 /* AccountSettingsUserInputError.swift */,
   1.240  				152130531FD00B7A00688DF2 /* DisplayUserError.swift */,
   1.241  			);
   1.242 @@ -1801,8 +1762,6 @@
   1.243  			isa = PBXGroup;
   1.244  			children = (
   1.245  				43D755F51F262B37006F933A /* PantomimeError.swift */,
   1.246 -				43A26FB91E0408FB00AF0B84 /* ServiceErrorProtocol.swift */,
   1.247 -				155050F51FEAB082009CEAD2 /* ErrorContainer.swift */,
   1.248  				155050F71FEAB57F009CEAD2 /* BackgroundError.swift */,
   1.249  			);
   1.250  			path = Error;
   1.251 @@ -1929,30 +1888,23 @@
   1.252  				43F6DFD61DEEC752006B526F /* FetchMessagesOperation.swift */,
   1.253  				1560D16F1F6FC99B00A75B39 /* FetchOlderImapMessagesOperation.swift */,
   1.254  				4356102B1DEF019400808C8E /* SyncMessagesOperation.swift */,
   1.255 -				431144B61CC11D6A0007639D /* BaseOperation.swift */,
   1.256  				43B2660C1D252C93009D57E8 /* ConcurrentBaseOperation.swift */,
   1.257 -				5D039AA11D0EEA3700AD59EC /* DecryptMessagesOperation.swift */,
   1.258 -				433C51D11E66CB9C00272E19 /* CreateRequiredFoldersOperation.swift */,
   1.259  				437671471D8FF2A5004DD205 /* DeleteFolderOperation.swift */,
   1.260  				43313DFB1DEC7F6000C111C8 /* DeleteFoldersOperation.swift */,
   1.261  				4323FE851E83D6FF006785E1 /* ImapFolderBuilder.swift */,
   1.262 -				43F84CD11CD899760092FCAE /* SyncFoldersFromServerOperation.swift */,
   1.263  				4382E6421CC600FF00AA27EA /* PersistentImapFolder.swift */,
   1.264  				431144B41CC0FCA40007639D /* StoreFolderOperation.swift */,
   1.265  				431144B81CC11DF30007639D /* StorePrefetchedMailOperation.swift */,
   1.266  				43264E9A1D76B7110098DCAC /* SyncFlagsToServerOperation.swift */,
   1.267  				43122B3D1DF5BB6600610253 /* MySelfOperation.swift */,
   1.268  				43A26FBE1E041BF200AF0B84 /* ImapSyncOperation.swift */,
   1.269 -				43BBB5E61E267A3800104070 /* EncryptAndSendOperation.swift */,
   1.270  				43DB81321E2A56BE00A20902 /* AppendMailsOperation.swift */,
   1.271 -				4333A2A41E5C9B6E0025D8A5 /* FixAttachmentsOperation.swift */,
   1.272  				4326D3FE1EFBC8DB0016AB0D /* FolderInfoOperation.swift */,
   1.273  				431E2B061F02550C000035FA /* CheckOutgoingMessagesOperation.swift */,
   1.274  				43D755EA1F25D234006F933A /* MatchUidToMsnOperation.swift */,
   1.275  				154750991FE7C0B4000D8004 /* FetchNumberOfNewMailsOperation.swift */,
   1.276  				150B84C320A44DE100D8B288 /* MoveToFolderOperation.swift */,
   1.277  				150B84C520A5DD0600D8B288 /* UIDCopyOperation.swift */,
   1.278 -				004A8C5A211316E100203143 /* SelfReferencingOperation.swift */,
   1.279  				15DD3F74211EC68D00A8714D /* DecryptMessageOperation.swift */,
   1.280  			);
   1.281  			path = Background;
   1.282 @@ -1981,12 +1933,6 @@
   1.283  				F7C16A5521A56412004B44F2 /* FolderSyncService */,
   1.284  				432DA7421EE01E1000B30BAA /* MessageSyncService */,
   1.285  				431E58F41ED57F4D00EFA77F /* AccountVerificationService */,
   1.286 -				1587D1622049BE7D002C2157 /* ImapConnectionDataCache.swift */,
   1.287 -				432142651E8FD6A400FBE987 /* ServiceUtil.swift */,
   1.288 -				432142631E8FD66900FBE987 /* FetchNumberOfNewMailsService.swift */,
   1.289 -				432198E71DF6B51B00318A74 /* LoginImapOperation.swift */,
   1.290 -				4348EF0C1E27ABA100F441A9 /* LoginSmtpOperation.swift */,
   1.291 -				432198EC1DF6B66800318A74 /* SharedObjects.swift */,
   1.292  				4307C46F1ED81F3100A276A4 /* DefaultImapSyncDelegate.swift */,
   1.293  				1560D1711F6FD1F600A75B39 /* FetchOlderImapMessagesService.swift */,
   1.294  				F7C16A5A21A56DBA004B44F2 /* FetchImapFoldersService.swift */,
   1.295 @@ -2330,7 +2276,6 @@
   1.296  				43980EF91CBD415700A7FC3C /* AppConfig.swift */,
   1.297  				43C6F35A1CBE7496006A2A18 /* ConnectionManager.swift */,
   1.298  				A1B50A811CD26FF100B1A997 /* Constants.swift */,
   1.299 -				439D40791CC79423009A4E7C /* GCD.swift */,
   1.300  				43980EDF1CBD24B000A7FC3C /* Log.swift */,
   1.301  				43C273DA21C8F96D002EB4C8 /* Logger.swift */,
   1.302  				435B42401D211E5900119048 /* MiscUtil.swift */,
   1.303 @@ -2342,8 +2287,6 @@
   1.304  				43B7154C1CECAADA0027861A /* ViewWidthsAligner.swift */,
   1.305  				222B35571DF96389007A1F82 /* Capability.swift */,
   1.306  				433019E51E01A71300788B89 /* PeriodicTask.swift */,
   1.307 -				436C23271E02948400071430 /* BackgroundTaskProtocol.swift */,
   1.308 -				436C232C1E02A2D900071430 /* KickOffMySelfProtocol.swift */,
   1.309  				436C232E1E02A52D00071430 /* LimitedOperationQueue.swift */,
   1.310  				8B69E3981E30F80E0022959E /* Appearance.swift */,
   1.311  				43F848481EAA09AE00DBE460 /* Weak.swift */,
   1.312 @@ -3249,7 +3192,6 @@
   1.313  				4351C2D71F4441190053381F /* node.c in Sources */,
   1.314  				00D3CD3E20B58976009ABBC9 /* PrimarySplitViewController.swift in Sources */,
   1.315  				43ED53771CC77F95006AB156 /* OneValueSettingCell.swift in Sources */,
   1.316 -				5D039AA21D0EEA3700AD59EC /* DecryptMessagesOperation.swift in Sources */,
   1.317  				439AAC561F21D0CC0018A29E /* CdFolder+Pantomime.swift in Sources */,
   1.318  				4351C2D51F4441190053381F /* latex.c in Sources */,
   1.319  				439932291FEA7E7A00E92C35 /* String+Email.swift in Sources */,
   1.320 @@ -3283,7 +3225,6 @@
   1.321  				43F6DFD71DEEC752006B526F /* FetchMessagesOperation.swift in Sources */,
   1.322  				150B8EB31FCEB93D00374438 /* UIUtils.swift in Sources */,
   1.323  				43AAC22A1F7A5AEE00F435F4 /* BaseTableViewController.swift in Sources */,
   1.324 -				436C232D1E02A2D900071430 /* KickOffMySelfProtocol.swift in Sources */,
   1.325  				43C322111EA91764005073FB /* UIImageView+Extension.swift in Sources */,
   1.326  				220DCE351E0AB5CC002FE716 /* MessageContentCell.swift in Sources */,
   1.327  				1526597A21623652006A78DF /* SuggestViewModel.swift in Sources */,
   1.328 @@ -3301,12 +3242,10 @@
   1.329  				43425EDF1FE3E052004A2728 /* OAuth2ProviderFactory.swift in Sources */,
   1.330  				43E657E01F3C74030014CBEC /* AXHTMLParser.m in Sources */,
   1.331  				B76CF8B320D2739B002429A8 /* MoveToFolderViewModel.swift in Sources */,
   1.332 -				155050F61FEAB082009CEAD2 /* ErrorContainer.swift in Sources */,
   1.333  				151F71D22029FA1B0057C74D /* PantomimeFolderAttribute+Extensions.swift in Sources */,
   1.334  				43425EDD1FE3DF3B004A2728 /* OAuth2Provider.swift in Sources */,
   1.335  				431144B51CC0FCA40007639D /* StoreFolderOperation.swift in Sources */,
   1.336  				152A39E021905C3E00D9F8E4 /* RecipientCell.swift in Sources */,
   1.337 -				439D407A1CC79423009A4E7C /* GCD.swift in Sources */,
   1.338  				152A39C721905C3E00D9F8E4 /* ComposeViewModel.swift in Sources */,
   1.339  				4362399B1EAE0CE800BD2EB9 /* Date+Extension.swift in Sources */,
   1.340  				43040A531E9776220083DED8 /* AttachmentSummaryView.swift in Sources */,
   1.341 @@ -3338,7 +3277,6 @@
   1.342  				43E657D11F3C33C30014CBEC /* String+HTML.swift in Sources */,
   1.343  				437671481D8FF2A5004DD205 /* DeleteFolderOperation.swift in Sources */,
   1.344  				432DA7461EE027EB00B30BAA /* MessageSyncService.swift in Sources */,
   1.345 -				43A26FBA1E0408FB00AF0B84 /* ServiceErrorProtocol.swift in Sources */,
   1.346  				15874BC52127493E00A3A4A6 /* SettingsSectionViewModel.swift in Sources */,
   1.347  				43C3220C1EA915C6005073FB /* CGRect+Util.swift in Sources */,
   1.348  				15874BC12127493E00A3A4A6 /* SettingSwitchTableViewCell.swift in Sources */,
   1.349 @@ -3386,7 +3324,6 @@
   1.350  				4362399C1EAE0CE800BD2EB9 /* NSRegularExpression+Extension.swift in Sources */,
   1.351  				43C322091EA90192005073FB /* PEP+UI.swift in Sources */,
   1.352  				004A8C552112FDD500203143 /* EmailListView+UITableViewDataSourcePrefetching.swift in Sources */,
   1.353 -				1587D1632049BE7D002C2157 /* ImapConnectionDataCache.swift in Sources */,
   1.354  				002375D620DD185100663961 /* TreadedEmailViewModel+DisplayedMessage.swift in Sources */,
   1.355  				431D60DD1E93D580001266D7 /* MessageAttachmentsCell.swift in Sources */,
   1.356  				00AEB2F620DBA7DA00DA185A /* NeedsRefreshDelegate.swift in Sources */,
   1.357 @@ -3403,13 +3340,11 @@
   1.358  				496355B120ECEA2900AA4387 /* ThreadedEmailViewModel+EmailDisplayDelegate.swift in Sources */,
   1.359  				43D070332133DC500013B120 /* DefaultAppSettings.swift in Sources */,
   1.360  				43ED536F1CC77F95006AB156 /* EmailListViewCell.swift in Sources */,
   1.361 -				432142641E8FD66900FBE987 /* FetchNumberOfNewMailsService.swift in Sources */,
   1.362  				4351C2C81F4441190053381F /* blocks.c in Sources */,
   1.363  				15BBBC6C1FD05F4300B9DCC8 /* DisplayUserError.swift in Sources */,
   1.364  				43A469FA21513B10002E1036 /* PEPSwipeTableViewCell.swift in Sources */,
   1.365  				00BEC89720B85FD300A36E60 /* NoMessagesViewController.swift in Sources */,
   1.366  				B761A80A20F5F0A6000832C2 /* UIBarButtonItem+Extension.swift in Sources */,
   1.367 -				43F84CD21CD899760092FCAE /* SyncFoldersFromServerOperation.swift in Sources */,
   1.368  				431C6E041FE7A85200E23BE0 /* OAuth2ConfigurationProtocol.swift in Sources */,
   1.369  				1541D7ED1FC81D4200D52A5D /* URL+Extensions.swift in Sources */,
   1.370  				152A39D421905C3E00D9F8E4 /* SubjectCell.swift in Sources */,
   1.371 @@ -3425,14 +3360,12 @@
   1.372  				B722EC7A1E5C879000A2B9D5 /* FolderUiProtocols.swift in Sources */,
   1.373  				4307C4721ED826E400A276A4 /* SmtpSendError.swift in Sources */,
   1.374  				15DD3F75211EC68D00A8714D /* DecryptMessageOperation.swift in Sources */,
   1.375 -				432198ED1DF6B66800318A74 /* SharedObjects.swift in Sources */,
   1.376  				A1B50A841CD26FF100B1A997 /* Constants.swift in Sources */,
   1.377  				15D4399C216E698E00EB3933 /* AccountPickerViewModel.swift in Sources */,
   1.378  				43985D0E204438480080FA9A /* AccountSettingsProtocol+Extension.swift in Sources */,
   1.379  				43D755EB1F25D234006F933A /* MatchUidToMsnOperation.swift in Sources */,
   1.380  				005A21FB20CAA5F50082D19F /* ThreadedEmailViewModel.swift in Sources */,
   1.381  				15874BD12127493E00A3A4A6 /* TrustedServerSettingsViewModel.swift in Sources */,
   1.382 -				436C23281E02948400071430 /* BackgroundTaskProtocol.swift in Sources */,
   1.383  				4351C2DC1F4441190053381F /* xml.c in Sources */,
   1.384  				430E0BE71EAF5E2600378EC2 /* NSMutableDictionary+pEp.swift in Sources */,
   1.385  				152A39D921905C3E00D9F8E4 /* NSAttributedString+BodyTextUtils.swift in Sources */,
   1.386 @@ -3443,12 +3376,9 @@
   1.387  				159F4C9C21BEB9ED00244903 /* Message+FakeMessage.swift in Sources */,
   1.388  				00EB89AD20E3D3C200CDFA0D /* ThreadedEmailViewModel+MoveToFolderDelegate.swift in Sources */,
   1.389  				431B04801DE5774800E40CD3 /* CdMessage+Pantomime.swift in Sources */,
   1.390 -				431144B71CC11D6A0007639D /* BaseOperation.swift in Sources */,
   1.391 -				432198E81DF6B51B00318A74 /* LoginImapOperation.swift in Sources */,
   1.392  				155050F21FE95D8A009CEAD2 /* UserNotificationTool+pEp.swift in Sources */,
   1.393  				B78CF82B1E76E146008C1739 /* FilterCellViewModel.swift in Sources */,
   1.394  				43497B3A211C63CA00AC42B0 /* Message+MessageIdentitfying.swift in Sources */,
   1.395 -				4333A2A51E5C9B6E0025D8A5 /* FixAttachmentsOperation.swift in Sources */,
   1.396  				431E58FA1ED591E900EFA77F /* AccountVerificationService.swift in Sources */,
   1.397  				150B84C420A44DE100D8B288 /* MoveToFolderOperation.swift in Sources */,
   1.398  				15874BC72127493E00A3A4A6 /* SettingDefaultAccountTableViewController.swift in Sources */,
   1.399 @@ -3457,7 +3387,6 @@
   1.400  				152A39D021905C3E00D9F8E4 /* AttachmentCell.swift in Sources */,
   1.401  				0033C08120D7F3C600224E61 /* ThreadViewController+ViewModelDelegate.swift in Sources */,
   1.402  				4351C2DB1F4441190053381F /* utf8.c in Sources */,
   1.403 -				4348EF0D1E27ABA100F441A9 /* LoginSmtpOperation.swift in Sources */,
   1.404  				152A39CA21905C3E00D9F8E4 /* DocumentAttachmentPickerViewController.swift in Sources */,
   1.405  				152A39CD21905C3E00D9F8E4 /* MediaAttachmentPickerProviderViewModel.swift in Sources */,
   1.406  				495D69BF20DBAEE900986007 /* ThreadViewController+SwipeCell.swift in Sources */,
   1.407 @@ -3495,8 +3424,6 @@
   1.408  				153FC45D202A263D0053CCF1 /* FolderType+IMAP.swift in Sources */,
   1.409  				15BA536A20A08B100090F126 /* Account+Extentions.swift in Sources */,
   1.410  				15255B031F825CD100A2CFC9 /* IdentityImageTool.swift in Sources */,
   1.411 -				43BBB5E71E267A3800104070 /* EncryptAndSendOperation.swift in Sources */,
   1.412 -				004A8C5B211316E100203143 /* SelfReferencingOperation.swift in Sources */,
   1.413  				43AA82531E9B925C00ABD5A8 /* UIView+Util.swift in Sources */,
   1.414  				152A39D121905C3E00D9F8E4 /* AttachmentViewModel.swift in Sources */,
   1.415  				150DF6D32052ED4800A9DCF7 /* UIView+Autolayout.swift in Sources */,
   1.416 @@ -3526,7 +3453,6 @@
   1.417  				1554756621393036005A52D0 /* Folder+Extensions.swift in Sources */,
   1.418  				0069DCFB2110679200846EB1 /* EmailViewController+UIPopoverPresentationControllerDelegate.swift in Sources */,
   1.419  				43106A192045716000693144 /* OAuth2ConfigurationProtocol+Extension.swift in Sources */,
   1.420 -				432142661E8FD6A400FBE987 /* ServiceUtil.swift in Sources */,
   1.421  				15484B6C2105E26600F9D962 /* LegacyConnectInfoProvider.swift in Sources */,
   1.422  				43C322051EA89EED005073FB /* HandshakePartnerTableViewCell.swift in Sources */,
   1.423  				43E0CA2A1F4AB81600D9BB7E /* Attachment+Extension.swift in Sources */,
   1.424 @@ -3569,7 +3495,6 @@
   1.425  				152A39CE21905C3E00D9F8E4 /* ComposeHelpers.swift in Sources */,
   1.426  				43EC03481F4AE28F0026E152 /* String+Attachment.swift in Sources */,
   1.427  				43985D0A2044296D0080FA9A /* OAuth2AuthViewModel.swift in Sources */,
   1.428 -				150B8E981FCDACBB00374438 /* ErrorPropagator.swift in Sources */,
   1.429  				49691B1520D7FD0200CA9367 /* MessageViewModelConfigurable.swift in Sources */,
   1.430  				15484B682105D5AA00F9D962 /* ConnectInfo.swift in Sources */,
   1.431  				152A39CF21905C3E00D9F8E4 /* ComposeUtil.swift in Sources */,
   1.432 @@ -3580,7 +3505,6 @@
   1.433  				228038681DC9DE6D00F1CB45 /* TextfieldResponder.swift in Sources */,
   1.434  				157455C81FDFD2D4008CA78F /* NSAttributedString+Extensions.swift in Sources */,
   1.435  				4360282D1ED6F27600C95FC4 /* NetworkError.swift in Sources */,
   1.436 -				433C51D31E66CCA900272E19 /* CreateRequiredFoldersOperation.swift in Sources */,
   1.437  				4323FE861E83D6FF006785E1 /* ImapFolderBuilder.swift in Sources */,
   1.438  				F7C16A5721A56436004B44F2 /* FolderSyncServiceProtocol.swift in Sources */,
   1.439  				B75FF00B1EFD420F00C57289 /* EmailListViewModel.swift in Sources */,
     2.1 --- a/pEpForiOS/Background/BaseOperation.swift	Tue Feb 12 16:04:14 2019 +0100
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,56 +0,0 @@
     2.4 -//
     2.5 -//  BaseOperation.swift
     2.6 -//  pEpForiOS
     2.7 -//
     2.8 -//  Created by Dirk Zimmermann on 15/04/16.
     2.9 -//  Copyright © 2016 p≡p Security S.A. All rights reserved.
    2.10 -//
    2.11 -
    2.12 -/**
    2.13 - Basic NSOperation that can gather errors.
    2.14 - */
    2.15 -open class BaseOperation: Operation, ServiceErrorProtocol {
    2.16 -    open var comp = "BaseOperation"
    2.17 -
    2.18 -    let errorContainer: ServiceErrorProtocol
    2.19 -
    2.20 -    static let moduleTitleRegex = try! NSRegularExpression(
    2.21 -        pattern: "<pEpForiOS\\.(\\w+):", options: [])
    2.22 -
    2.23 -    open var error: Error? {
    2.24 -        return errorContainer.error
    2.25 -    }
    2.26 -
    2.27 -    open func addError(_ error: Error) {
    2.28 -        errorContainer.addError(error)
    2.29 -    }
    2.30 -
    2.31 -    open func hasErrors() -> Bool {
    2.32 -        return errorContainer.hasErrors()
    2.33 -    }
    2.34 -
    2.35 -    public init(parentName: String = #function,
    2.36 -                errorContainer: ServiceErrorProtocol = ErrorContainer()) {
    2.37 -        self.errorContainer = errorContainer
    2.38 -
    2.39 -        super.init()
    2.40 -
    2.41 -        comp = String(describing: self)
    2.42 -
    2.43 -        if let m = BaseOperation.moduleTitleRegex.firstMatch(
    2.44 -            in: comp, options: [], range: comp.wholeRange()) {
    2.45 -            if m.numberOfRanges > 1 {
    2.46 -                let r = m.range(at: 1)
    2.47 -                let s = comp as NSString
    2.48 -                comp = s.substring(with: r)
    2.49 -            }
    2.50 -        }
    2.51 -
    2.52 -        comp = "\(comp) \(unsafeBitCast(self, to: UnsafeRawPointer.self)) [\(parentName)]"
    2.53 -        self.name = comp
    2.54 -    }
    2.55 -
    2.56 -    func logSelf(functionName: String) {
    2.57 -        Logger.backendLogger.log("%{public}@: %{public}@", comp, self)
    2.58 -    }
    2.59 -}
     3.1 --- a/pEpForiOS/Background/CreateRequiredFoldersOperation.swift	Tue Feb 12 16:04:14 2019 +0100
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,176 +0,0 @@
     3.4 -//
     3.5 -//  CreateRequiredFoldersOperation.swift
     3.6 -//  pEpForiOS
     3.7 -//
     3.8 -//  Created by Dirk Zimmermann on 01/03/17.
     3.9 -//  Copyright © 2016 p≡p Security S.A. All rights reserved.
    3.10 -//
    3.11 -
    3.12 -import UIKit
    3.13 -import CoreData
    3.14 -
    3.15 -import MessageModel
    3.16 -
    3.17 -/**
    3.18 - Checks for needed folders, like "Drafts", and when they don't exist, create them
    3.19 - both locally and remote.
    3.20 - */
    3.21 -public class CreateRequiredFoldersOperation: ImapSyncOperation {
    3.22 -    private struct FolderToCreate {
    3.23 -        var folderName: String
    3.24 -        let folderSeparator: String?
    3.25 -        let folderType: FolderType
    3.26 -        let cdAccount: CdAccount
    3.27 -    }
    3.28 -    private struct CreationAttempt {
    3.29 -        var count = 0
    3.30 -        var folderToCreate: FolderToCreate?
    3.31 -
    3.32 -        mutating func reset() {
    3.33 -            count = 0
    3.34 -            folderToCreate = nil
    3.35 -        }
    3.36 -    }
    3.37 -    private var currentAttempt = CreationAttempt()
    3.38 -    private var foldersToCreate = [FolderToCreate]()
    3.39 -    private var folderSeparator: String?
    3.40 -    private var syncDelegate: CreateRequiredFoldersSyncDelegate?
    3.41 -    
    3.42 -    public var numberOfFoldersCreated = 0
    3.43 -
    3.44 -    public override func main() {
    3.45 -        if !checkImapSync() {
    3.46 -            markAsFinished()
    3.47 -            return
    3.48 -        }
    3.49 -        privateMOC.perform { [weak self] in
    3.50 -            guard let me = self else {
    3.51 -                Logger.backendLogger.lostMySelf()
    3.52 -                return
    3.53 -            }
    3.54 -            me.process()
    3.55 -        }
    3.56 -    }
    3.57 -
    3.58 -    private func process() {
    3.59 -        guard
    3.60 -            let accountId = imapSyncData.connectInfo.accountObjectID,
    3.61 -            let account = privateMOC.object(with: accountId) as? CdAccount else {
    3.62 -                handleError(BackgroundError.CoreDataError.couldNotFindAccount(info: comp))
    3.63 -                return
    3.64 -        }
    3.65 -
    3.66 -        assureLocalFoldersExist(for: account.account())
    3.67 -
    3.68 -        for ft in FolderType.requiredTypes {
    3.69 -            if let cdF = CdFolder.by(folderType: ft, account: account) {
    3.70 -                if folderSeparator == nil {
    3.71 -                    folderSeparator = cdF.folderSeparatorAsString()
    3.72 -                }
    3.73 -            } else {
    3.74 -                let folderName = ft.folderName()
    3.75 -                foldersToCreate.append(
    3.76 -                    FolderToCreate(folderName: folderName, folderSeparator: folderSeparator,
    3.77 -                                   folderType: ft, cdAccount: account))
    3.78 -            }
    3.79 -        }
    3.80 -
    3.81 -        if folderSeparator == nil {
    3.82 -            folderSeparator = CdFolder.folderSeparatorAsString(cdAccount: account)
    3.83 -        }
    3.84 -
    3.85 -        if foldersToCreate.count > 0 {
    3.86 -            privateMOC.saveAndLogErrors()
    3.87 -            syncDelegate = CreateRequiredFoldersSyncDelegate(errorHandler: self)
    3.88 -            imapSyncData.sync?.delegate = syncDelegate
    3.89 -            createNextFolder()
    3.90 -        } else {
    3.91 -            waitForBackgroundTasksToFinish()
    3.92 -        }
    3.93 -    }
    3.94 -
    3.95 -    fileprivate func createNextFolder() {
    3.96 -        if let lastFolder = currentAttempt.folderToCreate {
    3.97 -            privateMOC.performAndWait { [weak self] in
    3.98 -                guard let me = self else {
    3.99 -                    Logger.backendLogger.lostMySelf()
   3.100 -                    return
   3.101 -                }
   3.102 -                me.createLocal(folderToCreate: lastFolder, context: me.privateMOC)
   3.103 -            }
   3.104 -        }
   3.105 -        guard !isCancelled, let folderToCreate = foldersToCreate.first else {
   3.106 -            // We have been cancelled or there is nothing left todo.
   3.107 -            waitForBackgroundTasksToFinish()
   3.108 -            return
   3.109 -        }
   3.110 -        currentAttempt.reset()
   3.111 -        currentAttempt.folderToCreate = folderToCreate
   3.112 -        startFolderCreation(folderToCreate: folderToCreate)
   3.113 -        foldersToCreate.removeFirst()
   3.114 -    }
   3.115 -
   3.116 -    private func startFolderCreation(folderToCreate: FolderToCreate) {
   3.117 -        imapSyncData.sync?.createFolderWithName(folderToCreate.folderName)
   3.118 -    }
   3.119 -
   3.120 -    private func createLocal(folderToCreate: FolderToCreate, context: NSManagedObjectContext) {
   3.121 -        let _ = CdFolder.insertOrUpdate(
   3.122 -            folderName: folderToCreate.folderName, folderSeparator: folderToCreate.folderSeparator,
   3.123 -            folderType: folderToCreate.folderType, account: folderToCreate.cdAccount)
   3.124 -        Record.saveAndWait(context: privateMOC)
   3.125 -
   3.126 -    }
   3.127 -
   3.128 -    fileprivate func createFolderAgain(potentialError: Error) {
   3.129 -        if currentAttempt.count == 0, var folderToCreate = currentAttempt.folderToCreate,
   3.130 -            let fs = folderSeparator {
   3.131 -            folderToCreate.folderName =
   3.132 -            "\(ImapSync.defaultImapInboxName)\(fs)\(folderToCreate.folderName)"
   3.133 -            currentAttempt.folderToCreate = folderToCreate
   3.134 -            currentAttempt.count += 1
   3.135 -            startFolderCreation(folderToCreate: folderToCreate)
   3.136 -        } else {
   3.137 -            currentAttempt.reset()
   3.138 -            addIMAPError(potentialError)
   3.139 -            waitForBackgroundTasksToFinish()
   3.140 -        }
   3.141 -    }
   3.142 -
   3.143 -    private func assureLocalFoldersExist(for account: Account) {
   3.144 -        if let _ = Folder.by(account: account, folderType: .outbox) {
   3.145 -            // Nothing to do. Outbox is currently the only existing local folder type
   3.146 -            return
   3.147 -        }
   3.148 -        let name = FolderType.outbox.folderName()
   3.149 -        let createe = Folder(name: name,
   3.150 -                             parent: nil,
   3.151 -                             account: account,
   3.152 -                             folderType: .outbox)
   3.153 -        createe.save()
   3.154 -    }
   3.155 -
   3.156 -    override func markAsFinished() {
   3.157 -        syncDelegate = nil
   3.158 -        super.markAsFinished()
   3.159 -    }
   3.160 -}
   3.161 -
   3.162 -class CreateRequiredFoldersSyncDelegate: DefaultImapSyncDelegate {
   3.163 -    public override func folderCreateCompleted(_ sync: ImapSync, notification: Notification?) {
   3.164 -        guard let op = errorHandler as? CreateRequiredFoldersOperation else {
   3.165 -            Logger.backendLogger.errorAndCrash("Sorry, wrong number.")
   3.166 -            return
   3.167 -        }
   3.168 -        op.numberOfFoldersCreated += 1
   3.169 -        op.createNextFolder()
   3.170 -    }
   3.171 -
   3.172 -    public override func folderCreateFailed(_ sync: ImapSync, notification: Notification?) {
   3.173 -        guard let op = errorHandler as? CreateRequiredFoldersOperation else {
   3.174 -            Logger.backendLogger.errorAndCrash("Sorry, wrong number.")
   3.175 -            return
   3.176 -        }
   3.177 -        op.createFolderAgain(potentialError: ImapSyncError.illegalState(#function))
   3.178 -    }
   3.179 -}
     4.1 --- a/pEpForiOS/Background/DecryptMessagesOperation.swift	Tue Feb 12 16:04:14 2019 +0100
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,317 +0,0 @@
     4.4 -//
     4.5 -//  DecryptMessagesOperation.swift
     4.6 -//  pEpForiOS
     4.7 -//
     4.8 -//  Created by hernani on 13/06/16.
     4.9 -//  Copyright © 2016 p≡p Security S.A. All rights reserved.
    4.10 -//
    4.11 -
    4.12 -import MessageModel
    4.13 -
    4.14 -import CoreData
    4.15 -
    4.16 -// Only used in Tests. Maybe refactor out.
    4.17 -public protocol DecryptMessagesOperationDelegateProtocol: class {
    4.18 -    /**
    4.19 -     Called whenever a message just got decrypted. Useful for tests.
    4.20 -     */
    4.21 -    func decrypted(originalCdMessage: CdMessage, decryptedMessageDict: NSDictionary?,
    4.22 -                   rating: PEP_rating, keys: [String])
    4.23 -}
    4.24 -
    4.25 -public class DecryptMessagesOperation: ConcurrentBaseOperation {
    4.26 -    public weak var delegate: DecryptMessagesOperationDelegateProtocol?// Only used in Tests. Maybe refactor out.
    4.27 -    private(set) var didMarkMessagesForReUpload = false
    4.28 -
    4.29 -    private var messagesToDecrypt = [CdMessage]()
    4.30 -    private var currentlyProcessedMessage: CdMessage?
    4.31 -    private var ratingBeforeEngine = Int16(PEP_rating_undefined.rawValue)
    4.32 -
    4.33 -    private func setupMessagesToDecrypt() {
    4.34 -        privateMOC.performAndWait {[weak self] in
    4.35 -            guard let me = self else {
    4.36 -                Logger.backendLogger.lostMySelf()
    4.37 -                return
    4.38 -            }
    4.39 -            guard let cdMessages = CdMessage.all(
    4.40 -                predicate: CdMessage.PredicateFactory.unknownToPep(),
    4.41 -                orderedBy: [NSSortDescriptor(key: "received", ascending: true)],
    4.42 -                in: privateMOC) as? [CdMessage] else {
    4.43 -                    me.markAsFinished()
    4.44 -                    return
    4.45 -            }
    4.46 -            messagesToDecrypt = cdMessages
    4.47 -        }
    4.48 -    }
    4.49 -
    4.50 -    public override func main() {
    4.51 -        if isCancelled {
    4.52 -            markAsFinished()
    4.53 -            return
    4.54 -        }
    4.55 -        setupMessagesToDecrypt()
    4.56 -        handleNextMessage()
    4.57 -    }
    4.58 -
    4.59 -    // MARK: - Process
    4.60 -
    4.61 -    private func cleanup() {
    4.62 -        currentlyProcessedMessage = nil
    4.63 -        ratingBeforeEngine = Int16(PEP_rating_undefined.rawValue)
    4.64 -    }
    4.65 -
    4.66 -    private func handleNextMessage() {
    4.67 -        cleanup()
    4.68 -
    4.69 -        if messagesToDecrypt.count == 0 {
    4.70 -            waitForBackgroundTasksToFinish()
    4.71 -            return
    4.72 -        }
    4.73 -
    4.74 -        privateMOC.perform { [weak self] in
    4.75 -            guard let me = self else {
    4.76 -                Logger.backendLogger.lostMySelf()
    4.77 -                return
    4.78 -            }
    4.79 -            if me.isCancelled {
    4.80 -                me.waitForBackgroundTasksToFinish()
    4.81 -                return
    4.82 -            }
    4.83 -            let cdMsg = me.messagesToDecrypt.removeFirst()
    4.84 -            me.currentlyProcessedMessage = cdMsg
    4.85 -            guard let msg = cdMsg.message() else {
    4.86 -                Logger.backendLogger.errorAndCrash("No message")
    4.87 -                me.handleError(
    4.88 -                    BackgroundError.GeneralError.illegalState(info: "No Message for CdMessage"))
    4.89 -                return
    4.90 -            }
    4.91 -            me.ratingBeforeEngine = cdMsg.pEpRating
    4.92 -            var outgoing = false
    4.93 -            if let folderType = cdMsg.parent?.folderType {
    4.94 -                outgoing = folderType.isOutgoing()
    4.95 -            }
    4.96 -            let pepMessage = PEPUtil.pEpDict(cdMessage: cdMsg, outgoing: outgoing)
    4.97 -            let flags = msg.isOnTrustedServer ? PEP_decrypt_flag_none :
    4.98 -            PEP_decrypt_flag_untrusted_server
    4.99 -            let decryptOp = DecryptMessageOperation(messageToDecrypt: pepMessage,
   4.100 -                                                    flags: flags,
   4.101 -                                                    delegate: me)
   4.102 -            me.backgroundQueue.addOperation(decryptOp)
   4.103 -        }
   4.104 -    }
   4.105 -
   4.106 -    // MARK: - Handle Result
   4.107 -
   4.108 -    private func handleDecryptionSuccess(cdMessage: CdMessage,
   4.109 -                                         pEpDecryptedMessage: NSDictionary,
   4.110 -                                         ratingBeforeEngine: Int16,
   4.111 -                                         rating: PEP_rating,
   4.112 -                                         keys: NSArray?) {
   4.113 -        privateMOC.performAndWait {[weak self] in
   4.114 -            guard let me = self else {
   4.115 -                Logger.backendLogger.lostMySelf()
   4.116 -                return
   4.117 -            }
   4.118 -            let theKeys = Array(keys ?? NSArray()) as? [String] ?? []
   4.119 -
   4.120 -            // Only used in Tests. Maybe refactor out.
   4.121 -            me.delegate?.decrypted(originalCdMessage: cdMessage,
   4.122 -                                     decryptedMessageDict: pEpDecryptedMessage,
   4.123 -                                     rating: rating,
   4.124 -                                     keys: theKeys)
   4.125 -
   4.126 -            if rating.shouldUpdateMessageContent() {
   4.127 -                me.updateWholeMessage(pEpDecryptedMessage: pEpDecryptedMessage,
   4.128 -                                   ratingBeforeEngine: ratingBeforeEngine,
   4.129 -                                   rating: rating,
   4.130 -                                   cdMessage: cdMessage,
   4.131 -                                   keys: theKeys)
   4.132 -                findDeleteAndHandleFakeMessage(forFetchedMessage: cdMessage,
   4.133 -                                               pEpDecryptedMessage: pEpDecryptedMessage)
   4.134 -                me.handleReUploadAndNotify(cdMessage: cdMessage, rating: rating)
   4.135 -            } else {
   4.136 -                if rating.rawValue != ratingBeforeEngine {
   4.137 -                    cdMessage.update(rating: rating)
   4.138 -                    saveAndNotify(cdMessage: cdMessage  )
   4.139 -                }
   4.140 -            }
   4.141 -        }
   4.142 -    }
   4.143 -
   4.144 -    /// Finds and deletes the local fake message (if exists) for a given message fetched from
   4.145 -    /// server. It also takes over the imap flags of the fake message. The user might have changed
   4.146 -    /// them (read or flagged the message) meanwhile.
   4.147 -    ///
   4.148 -    /// - Parameters:
   4.149 -    ///   - cdMessage: the message fetched from server
   4.150 -    ///   - pEpDecryptedMessage: decrypted message.
   4.151 -    ///                             We need it as the uuid differs in Mesasge >=2.0
   4.152 -    ///                             (inner message uui vs. outer message)
   4.153 -    private func findDeleteAndHandleFakeMessage(forFetchedMessage cdMessage: CdMessage,
   4.154 -                                                pEpDecryptedMessage: NSDictionary) {
   4.155 -        guard
   4.156 -            let uuid = pEpDecryptedMessage["id"] as? String,
   4.157 -            let parentFolder = cdMessage.parent?.folder()  else {
   4.158 -                Log.shared.errorAndCrash(component: #function, errorString:"Problem")
   4.159 -                return
   4.160 -        }
   4.161 -        let imapFlagsFakeMessage = Message.findAndDeleteFakeMessage(withUuid: uuid,
   4.162 -                                                                    in: parentFolder)
   4.163 -        setFlags(imapFlagsFakeMessage, toCdMessage: cdMessage)
   4.164 -    }
   4.165 -
   4.166 -    /**
   4.167 -     Updates message bodies (after decryption), then calls `updateMessage`.
   4.168 -     */
   4.169 -    private func updateWholeMessage(pEpDecryptedMessage: NSDictionary?,
   4.170 -                                    ratingBeforeEngine: Int16,
   4.171 -                                    rating: PEP_rating,
   4.172 -                                    cdMessage: CdMessage,
   4.173 -                                    keys: [String]) {
   4.174 -        cdMessage.underAttack = rating.isUnderAttack()
   4.175 -        guard let decrypted = pEpDecryptedMessage as? PEPMessageDict else {
   4.176 -
   4.177 -                Logger.backendLogger.errorAndCrash(
   4.178 -                    "Should update message with rating %d, but nil message",
   4.179 -                    rating.rawValue)
   4.180 -                return
   4.181 -        }
   4.182 -        updateMessage(cdMessage: cdMessage, keys: keys, pEpMessageDict: decrypted, rating: rating)
   4.183 -    }
   4.184 -
   4.185 -    private func setFlags(_ flags: Message.ImapFlags?,
   4.186 -                          toCdMessage cdMessage: CdMessage) {
   4.187 -        guard let imapFlags = flags else {
   4.188 -            // That's OK.
   4.189 -            // No fake message (und thus no flags) exists for the currently decrypted msg.
   4.190 -            return
   4.191 -        }
   4.192 -        cdMessage.imap?.localFlags?.flagDraft = imapFlags.draft
   4.193 -        cdMessage.imap?.localFlags?.flagAnswered = imapFlags.answered
   4.194 -        cdMessage.imap?.localFlags?.flagDeleted = imapFlags.deleted
   4.195 -        cdMessage.imap?.localFlags?.flagSeen = imapFlags.seen
   4.196 -    }
   4.197 -
   4.198 -    private func handleReUploadAndNotify(cdMessage: CdMessage, rating: PEP_rating) {
   4.199 -        do {
   4.200 -            let needsReUpload = try handleReUploadIfRequired(cdMessage: cdMessage, rating: rating)
   4.201 -            if needsReUpload {
   4.202 -                didMarkMessagesForReUpload = true
   4.203 -                Record.saveAndWait()
   4.204 -                privateMOC.saveAndLogErrors()
   4.205 -                // Don't notify. Delegate will be notified after the re-uploaded message is fetched.
   4.206 -            } else {
   4.207 -                saveAndNotify(cdMessage: cdMessage)
   4.208 -            }
   4.209 -        } catch {
   4.210 -            handleError(error)
   4.211 -        }
   4.212 -    }
   4.213 -
   4.214 -    private func saveAndNotify(cdMessage: CdMessage) {
   4.215 -        privateMOC.saveAndLogErrors()
   4.216 -        notifyDelegate(messageUpdated: cdMessage)
   4.217 -    }
   4.218 -
   4.219 -    /// Updates a message with the given data.
   4.220 -    ///
   4.221 -    /// - Parameters:
   4.222 -    ///   - cdMessage: message to update
   4.223 -    ///   - keys: keys the message has been signed with
   4.224 -    ///   - pEpMessageDict: decrypted message
   4.225 -    ///   - rating: rating to set
   4.226 -    private func updateMessage(cdMessage: CdMessage,
   4.227 -                               keys: [String],
   4.228 -                               pEpMessageDict: PEPMessageDict,
   4.229 -                               rating: PEP_rating) {
   4.230 -        cdMessage.update(pEpMessageDict: pEpMessageDict, rating: rating)
   4.231 -        cdMessage.updateKeyList(keys: keys)
   4.232 -    }
   4.233 -
   4.234 -    private func notifyDelegate(messageUpdated cdMessage: CdMessage) {
   4.235 -        guard let message = cdMessage.message() else {
   4.236 -            Logger.backendLogger.errorAndCrash("Error converting CDMesage")
   4.237 -            return
   4.238 -        }
   4.239 -        MessageModelConfig.messageFolderDelegate?.didCreate(messageFolder: message)
   4.240 -    }
   4.241 -
   4.242 -    // MARK: - Handle DecryptMessageOperationDelegate Calls
   4.243 -
   4.244 -    private func decryptMessageOperationDidDecryptMessage(result:
   4.245 -        DecryptMessageOperation.DecryptionResult) {
   4.246 -        guard
   4.247 -            let decrypted = result.pEpDecryptedMessage,
   4.248 -            let currentlyProcessedMessage = currentlyProcessedMessage else {
   4.249 -                Logger.backendLogger.errorAndCrash("Invalid state")
   4.250 -                handleError(BackgroundError.GeneralError.illegalState(info:
   4.251 -                    "Error handling decryption result"))
   4.252 -                return
   4.253 -        }
   4.254 -        handleDecryptionSuccess(cdMessage: currentlyProcessedMessage,
   4.255 -                                pEpDecryptedMessage: decrypted,
   4.256 -                                ratingBeforeEngine: ratingBeforeEngine,
   4.257 -                                rating: result.rating,
   4.258 -                                keys: result.keys)
   4.259 -        handleNextMessage()
   4.260 -    }
   4.261 -
   4.262 -    private func decryptMessageOperationDidFail(error: Error) {
   4.263 -        addError(error)
   4.264 -        handleNextMessage()
   4.265 -    }
   4.266 -}
   4.267 -
   4.268 -// MARK: - Re-Upload - Trusted Server
   4.269 -
   4.270 -extension DecryptMessagesOperation {
   4.271 -    private func handleReUploadIfRequired(cdMessage: CdMessage,
   4.272 -                                          rating: PEP_rating) throws -> Bool {
   4.273 -        guard let message = cdMessage.message() else {
   4.274 -            Logger.backendLogger.errorAndCrash("No message")
   4.275 -            throw BackgroundError.GeneralError.illegalState(info: "No Message")
   4.276 -        }
   4.277 -        if !message.isOnTrustedServer ||    // The only currently supported case for re-upload is trusted server.
   4.278 -            message.wasAlreadyUnencrypted { // If the message was not encrypted, there is no reason to re-upload it.
   4.279 -            return false
   4.280 -        }   
   4.281 -        let messageCopyForReupload = Message(message: message)
   4.282 -        setOriginalRatingHeader(rating: rating, toMessage: messageCopyForReupload)
   4.283 -        message.imapMarkDeleted()
   4.284 -
   4.285 -        return true
   4.286 -    }
   4.287 -
   4.288 -    private func setOriginalRatingHeader(rating: PEP_rating, toMessage cdMessage: CdMessage) {
   4.289 -        guard let message = cdMessage.message() else {
   4.290 -            Logger.backendLogger.errorAndCrash("No message")
   4.291 -            handleError(BackgroundError.GeneralError.illegalState(info: "No Message"))
   4.292 -            return
   4.293 -        }
   4.294 -        if message.parent.folderType == .drafts {
   4.295 -            let outgoingRating = message.outgoingMessageRating()
   4.296 -            setOriginalRatingHeader(rating: outgoingRating, toMessage: message)
   4.297 -        } else {
   4.298 -            setOriginalRatingHeader(rating: rating, toMessage: message)
   4.299 -        }
   4.300 -    }
   4.301 -
   4.302 -    private func setOriginalRatingHeader(rating: PEP_rating, toMessage msg: Message) {
   4.303 -        msg.setOriginalRatingHeader(rating: rating)
   4.304 -        msg.save()
   4.305 -    }
   4.306 -}
   4.307 -
   4.308 -// MARK: - DecryptMessageOperationDelegate
   4.309 -
   4.310 -extension DecryptMessagesOperation: DecryptMessageOperationDelegate {
   4.311 -    func decryptMessageOperation(sender: DecryptMessageOperation,
   4.312 -                                 didDecryptMessageWithResult result:
   4.313 -        DecryptMessageOperation.DecryptionResult) {
   4.314 -        decryptMessageOperationDidDecryptMessage(result: result)
   4.315 -    }
   4.316 -
   4.317 -    func decryptMessageOperation(sender: DecryptMessageOperation, failed error: Error) {
   4.318 -        decryptMessageOperationDidFail(error: error)
   4.319 -    }
   4.320 -}
     5.1 --- a/pEpForiOS/Background/EncryptAndSendOperation.swift	Tue Feb 12 16:04:14 2019 +0100
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,302 +0,0 @@
     5.4 -//
     5.5 -//  EncryptAndSendOperation.swift
     5.6 -//  pEpForiOS
     5.7 -//
     5.8 -//  Created by Dirk Zimmermann on 11/01/2017.
     5.9 -//  Copyright © 2017 p≡p Security S.A. All rights reserved.
    5.10 -//
    5.11 -
    5.12 -import CoreData
    5.13 -
    5.14 -import MessageModel
    5.15 -
    5.16 -/**
    5.17 - Encrypts and SMTPs all suitable messages.
    5.18 - */
    5.19 -public class EncryptAndSendOperation: ConcurrentBaseOperation {
    5.20 -    var smtpSend: SmtpSend!
    5.21 -    var smtpSendData: SmtpSendData
    5.22 -
    5.23 -    /** The object ID of the last sent message, so we can move it on success */
    5.24 -    var lastSentMessageObjectID: NSManagedObjectID?
    5.25 -
    5.26 -    public init(parentName: String = #function, smtpSendData: SmtpSendData,
    5.27 -                errorContainer: ServiceErrorProtocol = ErrorContainer()) {
    5.28 -        self.smtpSendData = smtpSendData
    5.29 -        super.init(parentName: parentName, errorContainer: errorContainer)
    5.30 -    }
    5.31 -
    5.32 -    private func checkSmtpSend() -> Bool {
    5.33 -        smtpSend = smtpSendData.smtp
    5.34 -        if smtpSend == nil {
    5.35 -            addError(BackgroundError.SmtpError.invalidConnection(info: comp))
    5.36 -            markAsFinished()
    5.37 -            return false
    5.38 -        }
    5.39 -        return true
    5.40 -    }
    5.41 -
    5.42 -    override public func main() {
    5.43 -        if !checkSmtpSend() {
    5.44 -            markAsFinished()
    5.45 -            return
    5.46 -        }
    5.47 -        smtpSend.delegate = self
    5.48 -        handleNextMessage()
    5.49 -    }
    5.50 -
    5.51 -    private static func outgoingMails(context: NSManagedObjectContext,
    5.52 -                                     cdAccount: CdAccount) -> [CdMessage] {
    5.53 -        let p = CdMessage.PredicateFactory.outgoingMails(in: cdAccount)
    5.54 -        return CdMessage.all(predicate: p, in: context) as? [CdMessage] ?? []
    5.55 -    }
    5.56 -
    5.57 -    static func outgoingMailsExist(in context: NSManagedObjectContext,
    5.58 -                                   forAccountWith cdAccountObjectId: NSManagedObjectID) -> Bool {
    5.59 -        var outgoingMsgs = [CdMessage]()
    5.60 -        context.performAndWait {
    5.61 -            guard let cdAccount = context.object(with: cdAccountObjectId) as? CdAccount else {
    5.62 -                Logger.backendLogger.errorAndCrash(
    5.63 -                    "No NSManagedObject for NSManagedObjectID")
    5.64 -                outgoingMsgs = []
    5.65 -                return
    5.66 -            }
    5.67 -            outgoingMsgs = outgoingMails(context: context, cdAccount: cdAccount)
    5.68 -        }
    5.69 -        return outgoingMsgs.count > 0
    5.70 -    }
    5.71 -
    5.72 -    public static func retrieveNextMessage(
    5.73 -        context: NSManagedObjectContext,
    5.74 -        cdAccount: CdAccount) -> (PEPMessageDict, Bool, NSManagedObjectID)? {
    5.75 -        var pepMessage: PEPMessageDict?
    5.76 -        var objID: NSManagedObjectID?
    5.77 -        var protected = true
    5.78 -
    5.79 -        let p = CdMessage.PredicateFactory.outgoingMails(in: cdAccount)
    5.80 -        if let m = CdMessage.first(predicate: p) {
    5.81 -            if m.sent == nil {
    5.82 -                m.sent = Date()
    5.83 -                context.saveAndLogErrors()
    5.84 -            }
    5.85 -            pepMessage = m.pEpMessageDict()
    5.86 -            protected = m.pEpProtected
    5.87 -            objID = m.objectID
    5.88 -        }
    5.89 -
    5.90 -        if let o = objID, let p = pepMessage {
    5.91 -            return (p, protected, o)
    5.92 -        }
    5.93 -        return nil
    5.94 -    }
    5.95 -
    5.96 -    func send(pEpMessageDict: PEPMessageDict?) {
    5.97 -        guard var msg = pEpMessageDict else {
    5.98 -            handleError(BackgroundError.GeneralError.invalidParameter(info: comp),
    5.99 -                        message: "Cannot send nil message")
   5.100 -            return
   5.101 -        }
   5.102 -
   5.103 -        msg.removeOriginalRatingHeader()
   5.104 -
   5.105 -        let pantMail = PEPUtil.pantomime(pEpMessageDict: msg)
   5.106 -        smtpSend.smtp.setRecipients(nil)
   5.107 -        smtpSend.smtp.setMessageData(nil)
   5.108 -        smtpSend.smtp.setMessage(pantMail)
   5.109 -        smtpSend.smtp.sendMessage()
   5.110 -    }
   5.111 -
   5.112 -    func moveLastMessageToSentFolder(context: NSManagedObjectContext) {
   5.113 -        guard
   5.114 -            let objID = lastSentMessageObjectID,
   5.115 -            let cdMessage = context.object(with: objID) as? CdMessage,
   5.116 -            let cdAccount = cdMessage.parent?.account,
   5.117 -            let sentFolder = CdFolder.by(folderType: .sent, account: cdAccount),
   5.118 -            let message = cdMessage.message()
   5.119 -            else {
   5.120 -                Logger.backendLogger.errorAndCrash("Problem moving last message")
   5.121 -                return
   5.122 -        }
   5.123 -        let rating = message.outgoingMessageRating().rawValue
   5.124 -        MessageModelConfig.messageFolderDelegate?.didDelete(messageFolder: message)
   5.125 -        cdMessage.parent = sentFolder
   5.126 -        cdMessage.imap?.localFlags?.flagSeen = true
   5.127 -        cdMessage.pEpRating = Int16(rating)
   5.128 -        Record.saveAndWait()
   5.129 -
   5.130 -        guard let refreshedMsg = cdMessage.message() else {
   5.131 -            Log.shared.errorAndCrash(component: #function, errorString: "No msg")
   5.132 -            return
   5.133 -        }
   5.134 -        Message.createCdFakeMessage(for: refreshedMsg)
   5.135 -        Log.info(component: #function,
   5.136 -                 content: "Sent message. messageID: \(String(describing: cdMessage.messageID))")
   5.137 -    }
   5.138 -
   5.139 -    func handleNextMessage() {
   5.140 -        guard !isCancelled else {
   5.141 -            waitForBackgroundTasksToFinish()
   5.142 -            return
   5.143 -        }
   5.144 -        let context = privateMOC
   5.145 -        context.perform { [weak self] in
   5.146 -            self?.handleNextMessageInternal(context: context)
   5.147 -        }
   5.148 -    }
   5.149 -
   5.150 -    private func handleMessageSent() {
   5.151 -        let moc = privateMOC
   5.152 -        moc.perform { [weak self] in
   5.153 -            guard let me = self else {
   5.154 -                Logger.backendLogger.lostMySelf()
   5.155 -                return
   5.156 -            }
   5.157 -            me.moveLastMessageToSentFolder(context: moc)
   5.158 -            me.handleNextMessageInternal(context: moc)
   5.159 -        }
   5.160 -    }
   5.161 -
   5.162 -    func handleNextMessageInternal(context: NSManagedObjectContext) {
   5.163 -        guard
   5.164 -            let accountId = smtpSendData.connectInfo.accountObjectID,
   5.165 -            let cdAccount = context.object(with: accountId) as? CdAccount else {
   5.166 -                handleError(BackgroundError.CoreDataError.couldNotFindAccount(info: nil))
   5.167 -                return
   5.168 -        }
   5.169 -
   5.170 -        lastSentMessageObjectID = nil
   5.171 -        if let (msg, protected, cdMessageObjID) = EncryptAndSendOperation.retrieveNextMessage(
   5.172 -            context: context, cdAccount: cdAccount) {
   5.173 -            lastSentMessageObjectID = cdMessageObjID
   5.174 -            let session = PEPSession()
   5.175 -            do {
   5.176 -                let (_, encryptedMessageToSend) = try session.encrypt(
   5.177 -                    pEpMessageDict: msg, encryptionFormat: protected ? PEP_enc_PEP : PEP_enc_none)
   5.178 -                guard
   5.179 -                    let encrypted = encryptedMessageToSend?.mutableCopy() as? PEPMessageDict else {
   5.180 -                    Log.shared.errorAndCrash(component: #function,
   5.181 -                                             errorString: "Could not encrypt but did not throw.")
   5.182 -                     handleError(BackgroundError.PepError.encryptionError(info:
   5.183 -                        "Could not encrypt but did not throw."))
   5.184 -                    return
   5.185 -                }
   5.186 -                setOriginalRatingHeader(toMessageWithObjId: cdMessageObjID, inContext: context)
   5.187 -                send(pEpMessageDict: encrypted)
   5.188 -            } catch let err as NSError {
   5.189 -                handleError(err)
   5.190 -            }
   5.191 -        } else {
   5.192 -            markAsFinished()
   5.193 -        }
   5.194 -    }
   5.195 -
   5.196 -    private func setOriginalRatingHeader(toMessageWithObjId objId: NSManagedObjectID,
   5.197 -                                         inContext moc: NSManagedObjectContext) {
   5.198 -        guard
   5.199 -            let unencryptedCdMessage = privateMOC.object(with: objId) as? CdMessage,
   5.200 -            let unencryptedMessage = unencryptedCdMessage.message() else {
   5.201 -            Logger.backendLogger.errorAndCrash("No message")
   5.202 -            return
   5.203 -        }
   5.204 -
   5.205 -        let originalRating = unencryptedMessage.outgoingMessageRating()
   5.206 -        unencryptedMessage.setOriginalRatingHeader(rating: originalRating)
   5.207 -        unencryptedMessage.save()
   5.208 -    }
   5.209 -}
   5.210 -
   5.211 -extension EncryptAndSendOperation: SmtpSendDelegate {
   5.212 -    public func badResponse(_ smtp: SmtpSend, response: String?) {
   5.213 -        let error = BackgroundError.SmtpError.badResponse(info: comp)
   5.214 -        handleError(error, message: "badResponse")
   5.215 -    }
   5.216 -
   5.217 -    public func messageSent(_ smtp: SmtpSend, theNotification: Notification?) {
   5.218 -        handleMessageSent()
   5.219 -    }
   5.220 -
   5.221 -    public func messageNotSent(_ smtp: SmtpSend, theNotification: Notification?) {
   5.222 -        let error = BackgroundError.SmtpError.messageNotSent(info: comp)
   5.223 -        handleError(error, message: "messageNotSent")
   5.224 -    }
   5.225 -
   5.226 -    public func transactionInitiationCompleted(_ smtp: SmtpSend, theNotification: Notification?) {}
   5.227 -
   5.228 -    public func transactionInitiationFailed(_ smtp: SmtpSend, theNotification: Notification?) {
   5.229 -        let error = BackgroundError.SmtpError.transactionInitiationFailed(info: comp)
   5.230 -        handleError(error, message: "transactionInitiationFailed")
   5.231 -    }
   5.232 -
   5.233 -    public func recipientIdentificationCompleted(_ smtp: SmtpSend, theNotification: Notification?) {}
   5.234 -
   5.235 -    public func recipientIdentificationFailed(_ smtp: SmtpSend, theNotification: Notification?) {
   5.236 -        let error = BackgroundError.SmtpError.recipientIdentificationFailed(info: comp)
   5.237 -        handleError(error, message: "recipientIdentificationFailed")
   5.238 -    }
   5.239 -
   5.240 -    public func transactionResetCompleted(_ smtp: SmtpSend, theNotification: Notification?) {}
   5.241 -
   5.242 -    public func transactionResetFailed(_ smtp: SmtpSend, theNotification: Notification?) {
   5.243 -        let error = BackgroundError.SmtpError.transactionResetFailed(info: comp)
   5.244 -        handleError(error, message: "transactionResetFailed")
   5.245 -    }
   5.246 -
   5.247 -    public func authenticationCompleted(_ smtp: SmtpSend, theNotification: Notification?) {
   5.248 -        addError(BackgroundError.GeneralError.illegalState(info: #function))
   5.249 -        markAsFinished()
   5.250 -    }
   5.251 -
   5.252 -    public func authenticationFailed(_ smtp: SmtpSend, theNotification: Notification?) {
   5.253 -        let error = BackgroundError.SmtpError.authenticationFailed(info: comp)
   5.254 -        handleError(error, message: "authenticationFailed")
   5.255 -    }
   5.256 -
   5.257 -    public func connectionEstablished(_ smtp: SmtpSend, theNotification: Notification?) {}
   5.258 -
   5.259 -    public func connectionLost(_ smtp: SmtpSend, theNotification: Notification?) {
   5.260 -        let error = BackgroundError.SmtpError.connectionLost(info: comp)
   5.261 -        handleError(error, message: "connectionLost")
   5.262 -    }
   5.263 -
   5.264 -    public func connectionTerminated(_ smtp: SmtpSend, theNotification: Notification?) {
   5.265 -        let error = BackgroundError.SmtpError.connectionTerminated(info: comp)
   5.266 -        handleError(error, message: "connectionTerminated")
   5.267 -    }
   5.268 -
   5.269 -    public func connectionTimedOut(_ smtp: SmtpSend, theNotification: Notification?) {
   5.270 -        let error = BackgroundError.SmtpError.connectionTimedOut(info: comp)
   5.271 -        handleError(error, message: "connectionTimedOut")
   5.272 -    }
   5.273 -
   5.274 -    public func requestCancelled(_ smtp: SmtpSend, theNotification: Notification?) {
   5.275 -        let error = BackgroundError.SmtpError.requestCancelled(info: comp)
   5.276 -        handleError(error, message: "requestCancelled")
   5.277 -    }
   5.278 -
   5.279 -    public func serviceInitialized(_ smtp: SmtpSend, theNotification: Notification?) {}
   5.280 -
   5.281 -    public func serviceReconnected(_ smtp: SmtpSend, theNotification: Notification?) {}
   5.282 -}
   5.283 -
   5.284 -extension Dictionary where Key == String {
   5.285 -    public mutating func removeOriginalRatingHeader() {
   5.286 -        let headersToIgnore = Set(["X-EncStatus".lowercased()])
   5.287 -        let newHeaders = NSMutableArray()
   5.288 -        if let theHeaders = self[kPepOptFields] as? [NSArray] {
   5.289 -            for aHeader in theHeaders {
   5.290 -                if aHeader.count == 2, let headerName = aHeader[0] as? String {
   5.291 -                    if !headersToIgnore.contains(headerName.lowercased()) {
   5.292 -                        newHeaders.add(aHeader)
   5.293 -                    }
   5.294 -                }
   5.295 -            }
   5.296 -            if theHeaders.count != newHeaders.count {
   5.297 -                if let newValue = newHeaders as? Value {
   5.298 -                    self[kPepOptFields] = newValue
   5.299 -                } else {
   5.300 -                    Logger.backendLogger.errorAndCrash("Can't cast to `Value`")
   5.301 -                }
   5.302 -            }
   5.303 -        }
   5.304 -    }
   5.305 -}
     6.1 --- a/pEpForiOS/Background/Error/ErrorContainer.swift	Tue Feb 12 16:04:14 2019 +0100
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,26 +0,0 @@
     6.4 -//
     6.5 -//  ErrorContainer.swift
     6.6 -//  pEp
     6.7 -//
     6.8 -//  Created by Andreas Buff on 20.12.17.
     6.9 -//  Copyright © 2017 p≡p Security S.A. All rights reserved.
    6.10 -//
    6.11 -
    6.12 -import Foundation
    6.13 -
    6.14 -open class ErrorContainer: ServiceErrorProtocol {
    6.15 -    public var error: Error?
    6.16 -
    6.17 -    public init() {}
    6.18 -
    6.19 -    public func addError(_ error: Error) {
    6.20 -        if self.error == nil {
    6.21 -            self.error = error
    6.22 -        }
    6.23 -    }
    6.24 -
    6.25 -    public func hasErrors() -> Bool {
    6.26 -        return error != nil
    6.27 -    }
    6.28 -}
    6.29 -
     7.1 --- a/pEpForiOS/Background/Error/ServiceErrorProtocol.swift	Tue Feb 12 16:04:14 2019 +0100
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,18 +0,0 @@
     7.4 -//
     7.5 -//  ServiceErrorProtocol.swift
     7.6 -//  pEpForiOS
     7.7 -//
     7.8 -//  Created by Dirk Zimmermann on 16/12/16.
     7.9 -//  Copyright © 2016 p≡p Security S.A. All rights reserved.
    7.10 -//
    7.11 -
    7.12 -import Foundation
    7.13 -
    7.14 -/**
    7.15 - For exchanging errors between `BaseOperation`s.
    7.16 - */
    7.17 -public protocol ServiceErrorProtocol {
    7.18 -    var error: Error? { get }
    7.19 -    func addError(_ error: Error)
    7.20 -    func hasErrors() -> Bool
    7.21 -}
     8.1 --- a/pEpForiOS/Background/FixAttachmentsOperation.swift	Tue Feb 12 16:04:14 2019 +0100
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,134 +0,0 @@
     8.4 -//
     8.5 -//  FixAttachmentsOperation.swift
     8.6 -//  pEpForiOS
     8.7 -//
     8.8 -//  Created by Dirk Zimmermann on 21/02/2017.
     8.9 -//  Copyright © 2017 p≡p Security S.A. All rights reserved.
    8.10 -//
    8.11 -
    8.12 -import UIKit
    8.13 -import CoreData
    8.14 -import Photos
    8.15 -
    8.16 -import MessageModel
    8.17 -
    8.18 -/**
    8.19 - When getting an image from the device, we might get no data but a URL to the data.
    8.20 - Use this operation to (down)load attachment content before sending such an image attachment.
    8.21 - */
    8.22 -public class FixAttachmentsOperation: ConcurrentBaseOperation {
    8.23 -    let pInvalidLength = NSPredicate(format: "length = 0 and data != nil")
    8.24 -    let pInvalidData = NSPredicate(format: "data = nil and (fileName != nil or assetUrl != nil)")
    8.25 -
    8.26 -    var openFetchCount = 0
    8.27 -
    8.28 -    override public func main() {
    8.29 -        if isCancelled {
    8.30 -            markAsFinished()
    8.31 -            return
    8.32 -        }
    8.33 -        privateMOC.perform {
    8.34 -            self.fixAttachments(context: self.privateMOC)
    8.35 -        }
    8.36 -    }
    8.37 -
    8.38 -    func fixZeroSizeAttachments(context: NSManagedObjectContext) -> Int {
    8.39 -        var changedAttachmentsCount = 0
    8.40 -
    8.41 -        if let cdAttachments1 = CdAttachment.all(predicate: pInvalidLength, orderedBy: nil,
    8.42 -                                                 in: context)
    8.43 -            as? [CdAttachment] {
    8.44 -            for cdAttach in cdAttachments1 {
    8.45 -                if let theData = cdAttach.data {
    8.46 -                    changedAttachmentsCount += 1
    8.47 -                    cdAttach.length = Int64(theData.count)
    8.48 -                }
    8.49 -            }
    8.50 -        }
    8.51 -
    8.52 -        return changedAttachmentsCount
    8.53 -    }
    8.54 -
    8.55 -    func fixNilDataAttachments(context: NSManagedObjectContext, handler: @escaping (Int) -> ()) {
    8.56 -        guard let cdAttachments2 = CdAttachment.all(predicate: pInvalidData, orderedBy: nil,
    8.57 -                                                    in: context)
    8.58 -            as? [CdAttachment] else {
    8.59 -                handler(0)
    8.60 -                return
    8.61 -        }
    8.62 -        let totalCount = cdAttachments2.count
    8.63 -        if totalCount == 0 {
    8.64 -            handler(0)
    8.65 -        } else {
    8.66 -            openFetchCount = totalCount
    8.67 -            for cdAttach in cdAttachments2 {
    8.68 -                if let urlString = cdAttach.assetUrl ?? cdAttach.fileName {
    8.69 -                    let theURL = URL(string: urlString)
    8.70 -                    FixAttachmentsOperation.retrieveData(fromURL: theURL) { data in
    8.71 -                        context.perform {
    8.72 -                            if let theData = data {
    8.73 -                                cdAttach.data = theData
    8.74 -                                context.saveAndLogErrors()
    8.75 -                            }
    8.76 -                            self.openFetchCount -= 1
    8.77 -                            if self.openFetchCount == 0 {
    8.78 -                                handler(totalCount)
    8.79 -                            }
    8.80 -                        }
    8.81 -                    }
    8.82 -                } else {
    8.83 -                    Logger.backendLogger.errorAndCrash("CdAttachment with invalid URL")
    8.84 -                    openFetchCount -= 1
    8.85 -                }
    8.86 -            }
    8.87 -        }
    8.88 -    }
    8.89 -
    8.90 -    /**
    8.91 -     Might be useful for debugging. Not actively called anymore.
    8.92 -     */
    8.93 -    func checkValidity(context: NSManagedObjectContext) {
    8.94 -        let p = NSCompoundPredicate(orPredicateWithSubpredicates: [pInvalidLength, pInvalidData])
    8.95 -        let cdInvalidAttachments = CdAttachment.all(predicate: p, orderedBy: nil, in: context)
    8.96 -            as? [CdAttachment] ?? []
    8.97 -        if cdInvalidAttachments.count > 0 {
    8.98 -            Logger.backendLogger.error("Still %d invalid attachments",
    8.99 -                                       cdInvalidAttachments.count)
   8.100 -        }
   8.101 -    }
   8.102 -
   8.103 -    func fixAttachments(context: NSManagedObjectContext) {
   8.104 -        fixNilDataAttachments(context: context) { countFixedData in
   8.105 -            context.perform { [weak self] in
   8.106 -                let countFixedSize = self?.fixZeroSizeAttachments(context: context) ?? 0
   8.107 -                if countFixedData + countFixedSize > 0 {
   8.108 -                    context.saveAndLogErrors()
   8.109 -                }
   8.110 -                self?.markAsFinished()
   8.111 -            }
   8.112 -        }
   8.113 -    }
   8.114 -
   8.115 -    public static func retrieveData(fromURL: URL?, block: @escaping ((Data?) -> Void)) {
   8.116 -        if let theURL = fromURL {
   8.117 -            do {
   8.118 -                let data = try Data(contentsOf: theURL)
   8.119 -                block(data)
   8.120 -                return
   8.121 -            } catch let err {
   8.122 -                Logger.backendLogger.error("%@", err.localizedDescription)
   8.123 -            }
   8.124 -            let assets = PHAsset.fetchAssets(withALAssetURLs: [theURL], options: nil)
   8.125 -            if let theAsset = assets.firstObject {
   8.126 -                PHImageManager().requestImageData(for: theAsset, options: nil) {
   8.127 -                    data, string, orientation, options in
   8.128 -                    if let theData = data {
   8.129 -                        block(theData)
   8.130 -                    }
   8.131 -                }
   8.132 -            }
   8.133 -        } else {
   8.134 -            block(nil)
   8.135 -        }
   8.136 -    }
   8.137 -}
     9.1 --- a/pEpForiOS/Background/SelfReferencingOperation.swift	Tue Feb 12 16:04:14 2019 +0100
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,25 +0,0 @@
     9.4 -//
     9.5 -//  Created by Borja González de Pablo on 02/08/2018.
     9.6 -//  Copyright © 2018 p≡p Security S.A. All rights reserved.
     9.7 -//
     9.8 -
     9.9 -import Foundation
    9.10 -
    9.11 -class SelfReferencingOperation: Operation {
    9.12 -
    9.13 -    let executionBlock: (_ operation: SelfReferencingOperation?)-> Void
    9.14 -
    9.15 -    init(executionBlock: @escaping (_ operation: SelfReferencingOperation?) -> Void) {
    9.16 -        self.executionBlock = executionBlock
    9.17 -        super.init()
    9.18 -    }
    9.19 -
    9.20 -    override func main() {
    9.21 -        if (isCancelled){
    9.22 -            return
    9.23 -        }
    9.24 -        weak var weakSelf = self
    9.25 -
    9.26 -        executionBlock(weakSelf)
    9.27 -    }
    9.28 -}
    10.1 --- a/pEpForiOS/Background/SyncFoldersFromServerOperation.swift	Tue Feb 12 16:04:14 2019 +0100
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,246 +0,0 @@
    10.4 -//
    10.5 -//  SyncFoldersFromServerOperation.swift
    10.6 -//  pEpForiOS
    10.7 -//
    10.8 -//  Created by Dirk Zimmermann on 03/05/16.
    10.9 -//  Copyright © 2016 p≡p Security S.A. All rights reserved.
   10.10 -//
   10.11 -
   10.12 -import CoreData
   10.13 -
   10.14 -import MessageModel
   10.15 -
   10.16 -protocol SyncFoldersFromServerOperationDelegate: class {
   10.17 -    /**
   10.18 -     Called if the folder was unknown before, and therefore newly created.
   10.19 -     */
   10.20 -    func didCreate(cdFolder: CdFolder)
   10.21 -}
   10.22 -
   10.23 -/**
   10.24 - This operation is not intended to be put in a queue.
   10.25 - It runs asynchronously, but mainly driven by the main runloop through the use of NSStream.
   10.26 - Therefore it behaves as a concurrent operation, handling the state itself.
   10.27 - */
   10.28 -public class SyncFoldersFromServerOperation: ImapSyncOperation {
   10.29 -    var folderBuilder: ImapFolderBuilder!
   10.30 -
   10.31 -    /**
   10.32 -     If this is true, the local folders will get checked, and only if important
   10.33 -     folders don't exist, the folders will get synced.
   10.34 -     */
   10.35 -    let onlyUpdateIfNecessary: Bool
   10.36 -
   10.37 -    var syncDelegate: SyncFoldersFromServerSyncDelegate?
   10.38 -
   10.39 -    weak var delegate: SyncFoldersFromServerOperationDelegate?
   10.40 -
   10.41 -    /// Collection of the names of all folders that exist on server.
   10.42 -    /// Used to sync local folders (might have been deleted/moved on server side)
   10.43 -    var folderNamesExistingOnServer = [String]()
   10.44 -
   10.45 -    // MARK: - LIFE CYCLE
   10.46 -
   10.47 -    init?(parentName: String = #function,
   10.48 -          errorContainer: ServiceErrorProtocol = ErrorContainer(),
   10.49 -          imapSyncData: ImapSyncData,
   10.50 -          onlyUpdateIfNecessary: Bool = false) {
   10.51 -        self.onlyUpdateIfNecessary = onlyUpdateIfNecessary
   10.52 -
   10.53 -        super.init(parentName: parentName, errorContainer: errorContainer,
   10.54 -                   imapSyncData: imapSyncData)
   10.55 -        guard let accountId = imapSyncData.connectInfo.accountObjectID else {
   10.56 -            handleError(BackgroundError.GeneralError.illegalState(info: "No CdAccount ID"))
   10.57 -            return nil
   10.58 -        }
   10.59 -        folderBuilder = ImapFolderBuilder(accountID: accountId,
   10.60 -                                          backgroundQueue: backgroundQueue,
   10.61 -                                          messageFetchedBlock: nil)
   10.62 -    }
   10.63 -
   10.64 -    // MARK: - PROCESS
   10.65 -
   10.66 -    public override func main() {
   10.67 -        if !checkImapSync() {
   10.68 -            markAsFinished()
   10.69 -            return
   10.70 -        }
   10.71 -
   10.72 -        // Serialize all folder storage to prevent duplicates
   10.73 -        backgroundQueue.maxConcurrentOperationCount = 1
   10.74 -
   10.75 -        if onlyUpdateIfNecessary {
   10.76 -            // Check if the local folder list is fairly complete
   10.77 -            privateMOC.perform() { [weak self] in
   10.78 -                guard let me = self else {
   10.79 -                    Logger.backendLogger.lostMySelf()
   10.80 -                    return
   10.81 -                }
   10.82 -                guard
   10.83 -                    let accountId = me.imapSyncData.connectInfo.accountObjectID,
   10.84 -                    let account = me.privateMOC.object(with: accountId)
   10.85 -                    as? CdAccount else {
   10.86 -                        me.handleError(
   10.87 -                            BackgroundError.CoreDataError.couldNotFindAccount(info: me.comp))
   10.88 -                        return
   10.89 -                }
   10.90 -
   10.91 -                var needSync = false
   10.92 -
   10.93 -                for ty in FolderType.requiredTypes {
   10.94 -                    if CdFolder.by(folderType: ty, account: account) == nil {
   10.95 -                        needSync = true
   10.96 -                        break
   10.97 -                    }
   10.98 -                }
   10.99 -                if needSync {
  10.100 -                    me.startSync()
  10.101 -                } else {
  10.102 -                    me.markAsFinished()
  10.103 -                }
  10.104 -            }
  10.105 -        } else {
  10.106 -            startSync()
  10.107 -        }
  10.108 -    }
  10.109 -
  10.110 -    func startSync() {
  10.111 -        syncDelegate = SyncFoldersFromServerSyncDelegate(errorHandler: self)
  10.112 -        imapSyncData.sync?.delegate = syncDelegate
  10.113 -        imapSyncData.sync?.folderBuilder = folderBuilder
  10.114 -        readFolderNamesFromImapSync(imapSyncData.sync)
  10.115 -    }
  10.116 -
  10.117 -    func readFolderNamesFromImapSync(_ sync: ImapSync?) {
  10.118 -        // We currently fetch folders only if we are missing required folders.
  10.119 -        // The actual LIST command is sent by ImapSync.
  10.120 -        if let _ = sync?.folderNames {
  10.121 -            // Required folders exist, do nothing.
  10.122 -            markAsFinished()
  10.123 -        }
  10.124 -    }
  10.125 -
  10.126 -    override func markAsFinished() {
  10.127 -        syncDelegate = nil
  10.128 -        super.markAsFinished()
  10.129 -    }
  10.130 -
  10.131 -    /// Deletes all local folders that do not exist on server any more (have been moved/deleted by
  10.132 -    /// another client).
  10.133 -    private func deleteLocalFoldersThatDoNotExistOnServerAnyMore() {
  10.134 -        privateMOC.performAndWait { [weak self] in
  10.135 -            guard let me = self else {
  10.136 -                Logger.backendLogger.lostMySelf()
  10.137 -                return
  10.138 -            }
  10.139 -            // Get all local folders that represent a remote mailbox
  10.140 -            guard
  10.141 -                let accountId = me.imapSyncData.connectInfo.accountObjectID,
  10.142 -                let cdAaccount = me.privateMOC.object(with: accountId) as? CdAccount else {
  10.143 -                    handleError(BackgroundError.GeneralError.illegalState(info:
  10.144 -                        "Problem getting CdAccount"))
  10.145 -                    return
  10.146 -            }
  10.147 -            let account = cdAaccount.account()
  10.148 -            let localSyncedFolders = Folder.allRemoteFolders(inAccount: account)
  10.149 -            // Filter local folders that do not exist on server any more ...
  10.150 -            let foldersToDelete = localSyncedFolders.filter {
  10.151 -                !folderNamesExistingOnServer.contains($0.name) && $0.subFolders().count == 0
  10.152 -            }
  10.153 -            // ... and delete them
  10.154 -            for deletee: Folder in foldersToDelete {
  10.155 -                deletee.delete()
  10.156 -            }
  10.157 -        }
  10.158 -    }
  10.159 -
  10.160 -    // MARK: - HANDLERS for SyncFoldersFromServerSyncDelegate
  10.161 -
  10.162 -    fileprivate func handleFolderListCompleted(_ sync: ImapSync?) {
  10.163 -        backgroundQueue.waitUntilAllOperationsAreFinished()
  10.164 -        deleteLocalFoldersThatDoNotExistOnServerAnyMore()
  10.165 -        markAsFinished()
  10.166 -    }
  10.167 -
  10.168 -    fileprivate func handleFolderNameParsed(syncOp: SyncFoldersFromServerOperation,
  10.169 -                                            folderName: String,
  10.170 -                                            folderSeparator: String?,
  10.171 -                                            folderType: FolderType?,
  10.172 -                                            selectable: Bool = false) {
  10.173 -        folderNamesExistingOnServer.append(folderName)
  10.174 -
  10.175 -        let folderInfo = StoreFolderOperation.FolderInfo(name: folderName,
  10.176 -                                                         separator: folderSeparator,
  10.177 -                                                         folderType: folderType,
  10.178 -                                                         selectable: selectable)
  10.179 -        let storeFolderOp = StoreFolderOperation(
  10.180 -            parentName: comp, connectInfo: syncOp.imapSyncData.connectInfo,
  10.181 -            folderInfo: folderInfo)
  10.182 -        storeFolderOp.delegate = self
  10.183 -        syncOp.backgroundQueue.addOperation(storeFolderOp)
  10.184 -    }
  10.185 -}
  10.186 -
  10.187 -// MARK: - SyncFoldersFromServerSyncDelegate
  10.188 -
  10.189 -class SyncFoldersFromServerSyncDelegate: DefaultImapSyncDelegate {
  10.190 -
  10.191 -    public override func folderListCompleted(_ sync: ImapSync, notification: Notification?) {
  10.192 -        (errorHandler as? SyncFoldersFromServerOperation)?.handleFolderListCompleted(sync)
  10.193 -    }
  10.194 -
  10.195 -    public override func folderNameParsed(_ sync: ImapSync, notification: Notification?) {
  10.196 -        guard let userInfo = (notification as NSNotification?)?.userInfo else {
  10.197 -            return
  10.198 -        }
  10.199 -        guard let folderInfoDict = userInfo[PantomimeFolderInfo] as? NSDictionary else {
  10.200 -            return
  10.201 -        }
  10.202 -        guard let folderName = folderInfoDict[PantomimeFolderNameKey] as? String else {
  10.203 -            return
  10.204 -        }
  10.205 -        guard let syncOp = errorHandler as? SyncFoldersFromServerOperation else {
  10.206 -            return
  10.207 -        }
  10.208 -
  10.209 -        let folderSeparator = folderInfoDict[PantomimeFolderSeparatorKey] as? String
  10.210 -
  10.211 -        // Check and handle if the folder is reported as Special-Use Mailbox by the server
  10.212 -        var folderType: FolderType? = nil
  10.213 -        if let specialUseMailboxType = folderInfoDict[PantomimeFolderSpecialUseKey] as? Int {
  10.214 -            folderType = FolderType.from(pantomimeSpecialUseMailboxType: specialUseMailboxType)
  10.215 -        }
  10.216 -
  10.217 -        /*
  10.218 -         IMAP (and thus Pantomime) reports several folder attributes:
  10.219 -         PantomimeHoldsFolders = 1,
  10.220 -         PantomimeHoldsMessages = 2,
  10.221 -         PantomimeNoInferiors = 4,
  10.222 -         PantomimeNoSelect = 8,
  10.223 -         PantomimeMarked = 16,
  10.224 -         PantomimeUnmarked = 32
  10.225 -
  10.226 -         We currently only take NoSelect into account. If we have to take others into account also
  10.227 -         change [Cd]Folder `isSelectable` field to `folderAttributes[RawVAlue]`.
  10.228 -         */
  10.229 -        var isSelectable = true
  10.230 -        if let rawFlags = folderInfoDict[PantomimeFolderFlagsKey] as? UInt32 {
  10.231 -            let folderFlags = PantomimeFolderAttribute(rawValue: rawFlags)
  10.232 -            isSelectable = folderFlags.isSelectable
  10.233 -        }
  10.234 -
  10.235 -        (errorHandler as? SyncFoldersFromServerOperation)?.handleFolderNameParsed(syncOp: syncOp,
  10.236 -                                                                         folderName: folderName,
  10.237 -                                                                         folderSeparator: folderSeparator,
  10.238 -                                                                         folderType:folderType,
  10.239 -                                                                         selectable: isSelectable)
  10.240 -    }
  10.241 -}
  10.242 -
  10.243 -// MARK: - StoreFolderOperationDelegate
  10.244 -
  10.245 -extension SyncFoldersFromServerOperation: StoreFolderOperationDelegate {
  10.246 -    func didCreate(cdFolder: CdFolder) {
  10.247 -        delegate?.didCreate(cdFolder: cdFolder)
  10.248 -    }
  10.249 -}
    11.1 --- a/pEpForiOS/Error/ErrorPropagator.swift	Tue Feb 12 16:04:14 2019 +0100
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,27 +0,0 @@
    11.4 -//
    11.5 -//  ErrorPropagator.swift
    11.6 -//  pEp
    11.7 -//
    11.8 -//  Created by Xavier Algarra on 10/11/2017.
    11.9 -//  Copyright © 2017 p≡p Security S.A. All rights reserved.
   11.10 -//
   11.11 -
   11.12 -import Foundation
   11.13 -
   11.14 -public protocol ErrorPropagatorSubscriber: class {
   11.15 -    /**
   11.16 -     Should the error currently handled/displayed?
   11.17 -     There are situations where this leads to glitches.
   11.18 -     */
   11.19 -    var shouldHandleErrors: Bool { get set }
   11.20 -
   11.21 -    func error(propagator: ErrorPropagator, error: Error)
   11.22 -}
   11.23 -
   11.24 -public class ErrorPropagator {
   11.25 -    public weak var subscriber: ErrorPropagatorSubscriber?
   11.26 -
   11.27 -    public func report(error: Error) {
   11.28 -        subscriber?.error(propagator: self, error: error)
   11.29 -    }
   11.30 -}
    12.1 --- a/pEpForiOS/Network/Service/FetchNumberOfNewMailsService.swift	Tue Feb 12 16:04:14 2019 +0100
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,100 +0,0 @@
    12.4 -//
    12.5 -//  FetchNumberOfNewMailsService.swift
    12.6 -//  pEpForiOS
    12.7 -//
    12.8 -//  Created by Dirk Zimmermann on 01.04.17.
    12.9 -//  Copyright © 2017 p≡p Security S.A. All rights reserved.
   12.10 -//
   12.11 -
   12.12 -import Foundation
   12.13 -import CoreData
   12.14 -
   12.15 -import MessageModel
   12.16 -
   12.17 -/// Figures out the number of new (to us) messages in Inbox, taking all verified accounts
   12.18 -/// into account.
   12.19 -class FetchNumberOfNewMailsService {
   12.20 -    private var imapConnectionDataCache: ImapConnectionDataCache
   12.21 -    private let context = Record.Context.background
   12.22 -    private let workerQueue = DispatchQueue(
   12.23 -        label: "NetworkService", qos: .utility, target: nil)
   12.24 -    private let backgroundQueue = OperationQueue()
   12.25 -    private var errorContainer: ServiceErrorProtocol?
   12.26 -
   12.27 -    init(imapConnectionDataCache: ImapConnectionDataCache? = nil,
   12.28 -         errorContainer: ServiceErrorProtocol? = ErrorContainer()) {
   12.29 -        self.imapConnectionDataCache = imapConnectionDataCache ?? ImapConnectionDataCache()
   12.30 -        self.errorContainer = errorContainer
   12.31 -    }
   12.32 -
   12.33 -    /// Starts the service
   12.34 -    ///
   12.35 -    /// - Parameter completionBlock: called when the service has finished.
   12.36 -    ///                              Passes nil if we could not figure out whether or not
   12.37 -    ///                              there are new emails.
   12.38 -    public func start(completionBlock: @escaping (_ numNewMails: Int?) -> ()) {
   12.39 -        workerQueue.async { [weak self] in
   12.40 -            if let theSelf = self {
   12.41 -                let numNewMails = theSelf.numberOfNewMails()
   12.42 -                if theSelf.errorContainer?.hasErrors() ?? false {
   12.43 -                    completionBlock(nil)
   12.44 -                } else {
   12.45 -                    completionBlock(numNewMails)
   12.46 -                }
   12.47 -            }
   12.48 -        }
   12.49 -    }
   12.50 -
   12.51 -    /// Cancels all background tasks.
   12.52 -    public func stop() {
   12.53 -        backgroundQueue.cancelAllOperations()
   12.54 -    }
   12.55 -
   12.56 -    // MARK: - Internal
   12.57 -
   12.58 -    private func fetchAccounts() -> [CdAccount] {
   12.59 -        return CdAccount.all() ?? []
   12.60 -    }
   12.61 -
   12.62 -    private func gatherConnectInfos() -> [EmailConnectInfo] {
   12.63 -        var connectInfos = [EmailConnectInfo]()
   12.64 -        for ci in imapConnectionDataCache.emailConnectInfos {
   12.65 -            connectInfos.append(ci)
   12.66 -        }
   12.67 -        if connectInfos.isEmpty {
   12.68 -            let accountCIs = ServiceUtil.gatherConnectInfos(
   12.69 -                context: context, accounts: fetchAccounts())
   12.70 -            for aci in accountCIs {
   12.71 -                if let ici = aci.imapConnectInfo {
   12.72 -                    connectInfos.append(ici)
   12.73 -                }
   12.74 -            }
   12.75 -        }
   12.76 -        return connectInfos
   12.77 -    }
   12.78 -
   12.79 -    private func numberOfNewMails() -> Int {
   12.80 -        let theErrorContainer = ErrorContainer()
   12.81 -        errorContainer = theErrorContainer
   12.82 -        let cis = gatherConnectInfos()
   12.83 -        var result = 0
   12.84 -        for connectInfo in cis {
   12.85 -            let imapSyncData = imapConnectionDataCache.imapConnectionData(for: connectInfo)
   12.86 -            let loginOp = LoginImapOperation(
   12.87 -                parentName: #function, errorContainer: theErrorContainer,
   12.88 -                imapSyncData: imapSyncData)
   12.89 -            backgroundQueue.addOperation(loginOp)
   12.90 -            let fetchNumNewMailsOp = FetchNumberOfNewMailsOperation(imapSyncData: imapSyncData) {
   12.91 -                (numNewMails: Int?) in
   12.92 -                if let safeNewMails = numNewMails {
   12.93 -                    result += safeNewMails
   12.94 -                }
   12.95 -            }
   12.96 -            fetchNumNewMailsOp.addDependency(loginOp)
   12.97 -            backgroundQueue.addOperation(fetchNumNewMailsOp)
   12.98 -        }
   12.99 -        backgroundQueue.waitUntilAllOperationsAreFinished()
  12.100 -
  12.101 -        return result
  12.102 -    }
  12.103 -}
    13.1 --- a/pEpForiOS/Network/Service/ImapConnectionDataCache.swift	Tue Feb 12 16:04:14 2019 +0100
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,31 +0,0 @@
    13.4 -//
    13.5 -//  ImapConnectionDataCache.swift
    13.6 -//  pEp
    13.7 -//
    13.8 -//  Created by Andreas Buff on 02.03.18.
    13.9 -//  Copyright © 2018 p≡p Security S.A. All rights reserved.
   13.10 -//
   13.11 -
   13.12 -import Foundation
   13.13 -
   13.14 -struct ImapConnectionDataCache {
   13.15 -    private var imapConnectionDataCache = [EmailConnectInfo: ImapSyncData]()
   13.16 -
   13.17 -    var emailConnectInfos: [EmailConnectInfo] {
   13.18 -        return Array(imapConnectionDataCache.keys)
   13.19 -    }
   13.20 -
   13.21 -    mutating func reset() {
   13.22 -        imapConnectionDataCache = [EmailConnectInfo: ImapSyncData]()
   13.23 -    }
   13.24 -
   13.25 -    mutating func imapConnectionData(for connectInfo: EmailConnectInfo) -> ImapSyncData {
   13.26 -        if let cachedData = imapConnectionDataCache[connectInfo] {
   13.27 -            return cachedData
   13.28 -        }
   13.29 -
   13.30 -        let newData = ImapSyncData(connectInfo: connectInfo)
   13.31 -        imapConnectionDataCache[connectInfo] = newData
   13.32 -        return newData
   13.33 -    }
   13.34 -}
    14.1 --- a/pEpForiOS/Network/Service/LoginImapOperation.swift	Tue Feb 12 16:04:14 2019 +0100
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,79 +0,0 @@
    14.4 -//
    14.5 -//  LoginImapOperation.swift
    14.6 -//  pEpForiOS
    14.7 -//
    14.8 -//  Created by Dirk Zimmermann on 06/12/16.
    14.9 -//  Copyright © 2016 p≡p Security S.A. All rights reserved.
   14.10 -//
   14.11 -
   14.12 -import UIKit
   14.13 -import MessageModel
   14.14 -
   14.15 -public class LoginImapOperation: ImapSyncOperation {
   14.16 -    var syncDelegate: LoginImapSyncDelegate?
   14.17 -    var capabilities: Set<String>?
   14.18 -    var service: ImapSync
   14.19 -
   14.20 -    override init(parentName: String = #function,
   14.21 -                  errorContainer: ServiceErrorProtocol = ErrorContainer(),
   14.22 -                  imapSyncData: ImapSyncData) {
   14.23 -        service = imapSyncData.sync ?? ImapSync(connectInfo: imapSyncData.connectInfo)
   14.24 -        super.init(parentName: parentName, errorContainer: errorContainer,
   14.25 -                   imapSyncData: imapSyncData)
   14.26 -    }
   14.27 -
   14.28 -    public override func main() {
   14.29 -        if isCancelled {
   14.30 -            markAsFinished()
   14.31 -            return
   14.32 -        }
   14.33 -
   14.34 -        if service.imapState.hasError {
   14.35 -            service = ImapSync(connectInfo: imapSyncData.connectInfo)
   14.36 -        }
   14.37 -        imapSyncData.sync = service
   14.38 -
   14.39 -        syncDelegate = LoginImapSyncDelegate(errorHandler: self)
   14.40 -        if !service.imapState.authenticationCompleted {
   14.41 -            service.delegate = syncDelegate
   14.42 -            service.start()
   14.43 -        } else if service.imapState.isIdling {
   14.44 -            service.delegate = syncDelegate
   14.45 -            service.exitIdle()
   14.46 -        } else {
   14.47 -            syncDelegate = nil
   14.48 -            markAsFinished()
   14.49 -        }
   14.50 -    }
   14.51 -
   14.52 -    override func markAsFinished() {
   14.53 -        syncDelegate = nil
   14.54 -        super.markAsFinished()
   14.55 -    }
   14.56 -}
   14.57 -
   14.58 -class LoginImapSyncDelegate: DefaultImapSyncDelegate {
   14.59 -    override func authenticationCompleted(_ sync: ImapSync, notification: Notification?) {
   14.60 -        guard let op = errorHandler as? LoginImapOperation else {
   14.61 -            return
   14.62 -        }
   14.63 -        op.imapSyncData.sync = sync
   14.64 -
   14.65 -        op.capabilities = sync.capabilities
   14.66 -        op.markAsFinished()
   14.67 -    }
   14.68 -
   14.69 -    override func folderOpenCompleted(_ sync: ImapSync, notification: Notification?) {
   14.70 -        (errorHandler as? ImapSyncOperation)?.markAsFinished()
   14.71 -    }
   14.72 -
   14.73 -    override func folderOpenFailed(_ sync: ImapSync, notification: Notification?) {
   14.74 -        // Should not generate an error, since we may try to select an non-existant
   14.75 -        // mailbox as alternative to CLOSE.
   14.76 -        (errorHandler as? ImapSyncOperation)?.markAsFinished()
   14.77 -    }
   14.78 -
   14.79 -    override func idleFinished(_ sync: ImapSync, notification: Notification?) {
   14.80 -        (errorHandler as? ImapSyncOperation)?.markAsFinished()
   14.81 -    }
   14.82 -}
    15.1 --- a/pEpForiOS/Network/Service/LoginSmtpOperation.swift	Tue Feb 12 16:04:14 2019 +0100
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,78 +0,0 @@
    15.4 -//
    15.5 -//  LoginSmtpOperation.swift
    15.6 -//  pEpForiOS
    15.7 -//
    15.8 -//  Created by Dirk Zimmermann on 29/04/16.
    15.9 -//  Copyright © 2016 p≡p Security S.A. All rights reserved.
   15.10 -//
   15.11 -
   15.12 -import MessageModel
   15.13 -
   15.14 -public class LoginSmtpOperation: ConcurrentBaseOperation {
   15.15 -    var service: SmtpSend!
   15.16 -    var smtpSendData: SmtpSendData
   15.17 -
   15.18 -    public init(parentName: String = #function,
   15.19 -                smtpSendData: SmtpSendData,
   15.20 -                errorContainer: ServiceErrorProtocol = ErrorContainer()) {
   15.21 -        self.smtpSendData = smtpSendData
   15.22 -        super.init(parentName: parentName, errorContainer: errorContainer)
   15.23 -    }
   15.24 -
   15.25 -    override public func main() {
   15.26 -        if isCancelled {
   15.27 -            markAsFinished()
   15.28 -            return
   15.29 -        }
   15.30 -        service = SmtpSend(connectInfo: smtpSendData.connectInfo)
   15.31 -        service.delegate = self
   15.32 -        service.start()
   15.33 -    }
   15.34 -}
   15.35 -
   15.36 -extension LoginSmtpOperation: SmtpSendDelegate {
   15.37 -    public func messageSent(_ smtp: SmtpSend, theNotification: Notification?) {}
   15.38 -    public func messageNotSent(_ smtp: SmtpSend, theNotification: Notification?) {}
   15.39 -    public func transactionInitiationCompleted(_ smtp: SmtpSend, theNotification: Notification?) {}
   15.40 -    public func transactionInitiationFailed(_ smtp: SmtpSend, theNotification: Notification?) {}
   15.41 -    public func recipientIdentificationCompleted(_ smtp: SmtpSend, theNotification: Notification?) {}
   15.42 -    public func recipientIdentificationFailed(_ smtp: SmtpSend, theNotification: Notification?) {}
   15.43 -    public func transactionResetCompleted(_ smtp: SmtpSend, theNotification: Notification?) {}
   15.44 -    public func transactionResetFailed(_ smtp: SmtpSend, theNotification: Notification?) {}
   15.45 -
   15.46 -    public func authenticationCompleted(_ smtp: SmtpSend, theNotification: Notification?) {
   15.47 -        smtpSendData.smtp = smtp
   15.48 -        self.markAsFinished()
   15.49 -    }
   15.50 -
   15.51 -    public func authenticationFailed(_ smtp: SmtpSend, theNotification: Notification?) {
   15.52 -        addError(SmtpSendError.authenticationFailed(#function, smtp.connectInfo.account.user.address))
   15.53 -        markAsFinished()
   15.54 -    }
   15.55 -
   15.56 -    public func connectionEstablished(_ smtp: SmtpSend, theNotification: Notification?) {}
   15.57 -
   15.58 -    public func connectionLost(_ smtp: SmtpSend, theNotification: Notification?) {
   15.59 -        addError(SmtpSendError.connectionLost(#function))
   15.60 -        markAsFinished()
   15.61 -    }
   15.62 -
   15.63 -    public func connectionTerminated(_ smtp: SmtpSend, theNotification: Notification?) {
   15.64 -        addError(SmtpSendError.connectionTerminated(#function))
   15.65 -        markAsFinished()
   15.66 -    }
   15.67 -
   15.68 -    public func connectionTimedOut(_ smtp: SmtpSend, theNotification: Notification?) {
   15.69 -        addError(SmtpSendError.connectionTimedOut(#function))
   15.70 -        markAsFinished()
   15.71 -    }
   15.72 -
   15.73 -    public func badResponse(_ smtp: SmtpSend, response: String?) {
   15.74 -        addError(SmtpSendError.badResponse(#function))
   15.75 -        markAsFinished()
   15.76 -    }
   15.77 -
   15.78 -    public func requestCancelled(_ smtp: SmtpSend, theNotification: Notification?) {}
   15.79 -    public func serviceInitialized(_ smtp: SmtpSend, theNotification: Notification?) {}
   15.80 -    public func serviceReconnected(_ smtp: SmtpSend, theNotification: Notification?) {}
   15.81 -}
    16.1 --- a/pEpForiOS/Network/Service/ServiceUtil.swift	Tue Feb 12 16:04:14 2019 +0100
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,31 +0,0 @@
    16.4 -//
    16.5 -//  ServiceUtil.swift
    16.6 -//  pEpForiOS
    16.7 -//
    16.8 -//  Created by Dirk Zimmermann on 01.04.17.
    16.9 -//  Copyright © 2017 p≡p Security S.A. All rights reserved.
   16.10 -//
   16.11 -
   16.12 -import Foundation
   16.13 -import CoreData
   16.14 -
   16.15 -import MessageModel
   16.16 -
   16.17 -open class ServiceUtil {
   16.18 -    public static func gatherConnectInfos(context: NSManagedObjectContext,
   16.19 -                                          accounts: [CdAccount]) -> [AccountConnectInfo] {
   16.20 -        var connectInfos = [AccountConnectInfo]()
   16.21 -        context.performAndWait {
   16.22 -            for acc in accounts {
   16.23 -                let smtpCI = acc.smtpConnectInfo
   16.24 -                let imapCI = acc.imapConnectInfo
   16.25 -                if (smtpCI != nil || imapCI != nil) {
   16.26 -                    connectInfos.append(AccountConnectInfo(accountID: acc.objectID,
   16.27 -                                                           imapConnectInfo: imapCI,
   16.28 -                                                           smtpConnectInfo: smtpCI))
   16.29 -                }
   16.30 -            }
   16.31 -        }
   16.32 -        return connectInfos
   16.33 -    }
   16.34 -}
    17.1 --- a/pEpForiOS/Network/Service/SharedObjects.swift	Tue Feb 12 16:04:14 2019 +0100
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,99 +0,0 @@
    17.4 -//
    17.5 -//  SharedObjects.swift
    17.6 -//  pEpForiOS
    17.7 -//
    17.8 -//  Created by Dirk Zimmermann on 06/12/16.
    17.9 -//  Copyright © 2016 p≡p Security S.A. All rights reserved.
   17.10 -//
   17.11 -
   17.12 -import CoreData
   17.13 -
   17.14 -/**
   17.15 - Used for building a line of operations for synching an account.
   17.16 - */
   17.17 -public struct AccountConnectInfo {
   17.18 -    let accountID: NSManagedObjectID
   17.19 -    let imapConnectInfo: EmailConnectInfo?
   17.20 -    let smtpConnectInfo: EmailConnectInfo?
   17.21 -}
   17.22 -
   17.23 -extension AccountConnectInfo {
   17.24 -    public init(accountID: NSManagedObjectID) {
   17.25 -        self.accountID = accountID
   17.26 -        self.imapConnectInfo = nil
   17.27 -        self.smtpConnectInfo = nil
   17.28 -    }
   17.29 -}
   17.30 -
   17.31 -/**
   17.32 - Some information about a list of operations needed to sync a single account.
   17.33 - */
   17.34 -class OperationLine {
   17.35 -    let accountInfo: AccountConnectInfo
   17.36 -    let operations: [Operation]
   17.37 -    let finalOperation: Operation
   17.38 -    let errorContainer: ServiceErrorProtocol
   17.39 -
   17.40 -    init(accountInfo: AccountConnectInfo, operations: [Operation], finalOperation: Operation,
   17.41 -         errorContainer: ServiceErrorProtocol) {
   17.42 -        self.accountInfo = accountInfo
   17.43 -        self.operations = operations
   17.44 -        self.finalOperation = finalOperation
   17.45 -        self.errorContainer = errorContainer
   17.46 -    }
   17.47 -}
   17.48 -
   17.49 -extension OperationLine: ServiceErrorProtocol {
   17.50 -    var error: Error? {
   17.51 -        return errorContainer.error
   17.52 -    }
   17.53 -
   17.54 -    func addError(_ error: Error) {
   17.55 -        errorContainer.addError(error)
   17.56 -    }
   17.57 -
   17.58 -    func hasErrors() -> Bool {
   17.59 -        return errorContainer.hasErrors()
   17.60 -    }
   17.61 -}
   17.62 -
   17.63 -/**
   17.64 - Used for parameters/state shared between IMAP related operations.
   17.65 - */
   17.66 -class ImapSyncData: ImapConnectionManagerProtocol {
   17.67 -    let connectInfo: EmailConnectInfo
   17.68 -
   17.69 -    public var sync: ImapSync?
   17.70 -
   17.71 -    var supportsIdle: Bool {
   17.72 -        return sync?.supportsIdle ?? false
   17.73 -    }
   17.74 -
   17.75 -    init(connectInfo: EmailConnectInfo) {
   17.76 -        self.connectInfo = connectInfo
   17.77 -    }
   17.78 -
   17.79 -    func imapConnection(connectInfo: EmailConnectInfo) -> ImapSync? {
   17.80 -        if self.connectInfo == connectInfo {
   17.81 -            return sync
   17.82 -        }
   17.83 -        return nil
   17.84 -    }
   17.85 -
   17.86 -    public func reset() {
   17.87 -        sync = nil
   17.88 -    }
   17.89 -}
   17.90 -
   17.91 -open class SmtpSendData {
   17.92 -    let connectInfo: EmailConnectInfo
   17.93 -    public var smtp: SmtpSend?
   17.94 -
   17.95 -    init(connectInfo: EmailConnectInfo) {
   17.96 -        self.connectInfo = connectInfo
   17.97 -    }
   17.98 -
   17.99 -    public func reset() {
  17.100 -        smtp = nil
  17.101 -    }
  17.102 -}
    18.1 --- a/pEpForiOS/Util/BackgroundTaskProtocol.swift	Tue Feb 12 16:04:14 2019 +0100
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,38 +0,0 @@
    18.4 -//
    18.5 -//  BackgroundTaskProtocol.swift
    18.6 -//  pEpForiOS
    18.7 -//
    18.8 -//  Created by Dirk Zimmermann on 15/12/16.
    18.9 -//  Copyright © 2016 p≡p Security S.A. All rights reserved.
   18.10 -//
   18.11 -
   18.12 -import UIKit
   18.13 -
   18.14 -public typealias BackgroundTaskID = UIBackgroundTaskIdentifier
   18.15 -
   18.16 -/**
   18.17 - Abstract away the iOS way of doing things in the background, so this can be mocked
   18.18 - independently of UIApplication.
   18.19 - */
   18.20 -public protocol BackgroundTaskProtocol {
   18.21 -    func beginBackgroundTask(taskName: String?) -> BackgroundTaskID
   18.22 -    func beginBackgroundTask() -> BackgroundTaskID
   18.23 -    func beginBackgroundTask(expirationHandler: (() -> Void)?) -> BackgroundTaskID
   18.24 -    func beginBackgroundTask(taskName: String?,
   18.25 -                             expirationHandler: (() -> Void)?) -> BackgroundTaskID
   18.26 -    func endBackgroundTask(_ taskID: BackgroundTaskID?)
   18.27 -}
   18.28 -
   18.29 -public extension BackgroundTaskProtocol {
   18.30 -    func beginBackgroundTask(taskName: String?) -> BackgroundTaskID {
   18.31 -        return beginBackgroundTask(taskName: taskName, expirationHandler: nil)
   18.32 -    }
   18.33 -
   18.34 -    func beginBackgroundTask() -> BackgroundTaskID {
   18.35 -        return beginBackgroundTask(taskName: nil, expirationHandler: nil)
   18.36 -    }
   18.37 -
   18.38 -    func beginBackgroundTask(expirationHandler: (() -> Void)? = nil) -> BackgroundTaskID {
   18.39 -        return beginBackgroundTask(taskName: nil, expirationHandler: expirationHandler)
   18.40 -    }
   18.41 -}
    19.1 --- a/pEpForiOS/Util/GCD.swift	Tue Feb 12 16:04:14 2019 +0100
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,31 +0,0 @@
    19.4 -//
    19.5 -//  GCD.swift
    19.6 -//  pEpForiOS
    19.7 -//
    19.8 -//  Created by Dirk Zimmermann on 20/04/16.
    19.9 -//  Copyright © 2016 p≡p Security S.A. All rights reserved.
   19.10 -//
   19.11 -
   19.12 -struct GCD {
   19.13 -    /**
   19.14 -     Since you will do this all the time in UI callbacks.
   19.15 -     */
   19.16 -    static func onMain(_ block: @escaping () -> Void) {
   19.17 -        DispatchQueue.main.async(execute: {
   19.18 -            block()
   19.19 -        })
   19.20 -    }
   19.21 -
   19.22 -    /**
   19.23 -     Since you will do this all the time in UI callbacks.
   19.24 -     */
   19.25 -    static func onMainWait(_ block: @escaping () -> Void) {
   19.26 -        if Thread.isMainThread {
   19.27 -            block()
   19.28 -        } else {
   19.29 -            DispatchQueue.main.sync(execute: {
   19.30 -                block()
   19.31 -            })
   19.32 -        }
   19.33 -    }
   19.34 -}
    20.1 --- a/pEpForiOS/Util/KickOffMySelfProtocol.swift	Tue Feb 12 16:04:14 2019 +0100
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,34 +0,0 @@
    20.4 -//
    20.5 -//  KickOffMySelfProtocol.swift
    20.6 -//  pEpForiOS
    20.7 -//
    20.8 -//  Created by Dirk Zimmermann on 15/12/16.
    20.9 -//  Copyright © 2016 p≡p Security S.A. All rights reserved.
   20.10 -//
   20.11 -
   20.12 -import UIKit
   20.13 -
   20.14 -public protocol KickOffMySelfProtocol {
   20.15 -    /**
   20.16 -     Should invoke mySelf on every `Identity` owned by the user.
   20.17 -     */
   20.18 -    func startMySelf()
   20.19 -}
   20.20 -
   20.21 -open class DefaultMySelfer {
   20.22 -    let backgrounder: BackgroundTaskProtocol?
   20.23 -    let queue = LimitedOperationQueue()
   20.24 -    let parentName: String
   20.25 -
   20.26 -    public init(parentName: String = #function, backgrounder: BackgroundTaskProtocol?) {
   20.27 -        self.parentName = parentName
   20.28 -        self.backgrounder = backgrounder
   20.29 -    }
   20.30 -}
   20.31 -
   20.32 -extension DefaultMySelfer: KickOffMySelfProtocol {
   20.33 -    public func startMySelf() {
   20.34 -        let op = MySelfOperation(parentName: parentName, backgrounder: backgrounder)
   20.35 -        queue.addOperation(op)
   20.36 -    }
   20.37 -}