Browse Source

Merge pull request #2646 from nextcloud/keychain

Keychain
Marino Faggiana 1 year ago
parent
commit
140b6d8655
100 changed files with 591 additions and 942 deletions
  1. 1 1
      Brand/Database.swift
  2. 7 9
      File Provider Extension/FileProviderData.swift
  3. 2 2
      File Provider Extension/FileProviderEnumerator.swift
  4. 8 8
      File Provider Extension/FileProviderExtension+Actions.swift
  5. 2 2
      File Provider Extension/FileProviderExtension+Thumbnail.swift
  6. 15 15
      File Provider Extension/FileProviderExtension.swift
  7. 1 1
      File Provider Extension/FileProviderItem.swift
  8. 2 2
      File Provider Extension/FileProviderUtility.swift
  9. 4 93
      Nextcloud.xcodeproj/project.pbxproj
  10. 1 1
      Notification Service Extension/NotificationService.swift
  11. 1 1
      Share/NCShareCell.swift
  12. 4 7
      Share/NCShareExtension+DataSource.swift
  13. 3 2
      Share/NCShareExtension+Files.swift
  14. 1 1
      Share/NCShareExtension+NCDelegate.swift
  15. 4 7
      Share/NCShareExtension.swift
  16. 7 9
      Widget/Dashboard/DashboardData.swift
  17. 9 10
      Widget/Files/FilesData.swift
  18. 3 3
      Widget/Lockscreen/LockscreenData.swift
  19. 2 4
      iOSClient/Activity/NCActivity.swift
  20. 1 1
      iOSClient/Activity/NCActivityCommentView.swift
  21. 2 5
      iOSClient/Activity/NCActivityTableViewCell.swift
  22. 45 55
      iOSClient/AppDelegate.swift
  23. 2 3
      iOSClient/Data/NCManageDatabase+Account.swift
  24. 4 4
      iOSClient/Data/NCManageDatabase+Avatar.swift
  25. 2 2
      iOSClient/Data/NCManageDatabase+Chunk.swift
  26. 5 5
      iOSClient/Data/NCManageDatabase+Metadata.swift
  27. 1 1
      iOSClient/Extensions/PHAsset+Extension.swift
  28. 2 2
      iOSClient/Extensions/UIAlertController+Extension.swift
  29. 1 1
      iOSClient/Favorites/NCFavorite.swift
  30. 1 1
      iOSClient/Groupfolders/NCGroupfolders.swift
  31. 3 6
      iOSClient/Login/NCLogin.swift
  32. 5 7
      iOSClient/Login/NCLoginWeb.swift
  33. 1 1
      iOSClient/Login/NCViewCertificateDetails.swift
  34. 43 26
      iOSClient/Main/Collection Common/NCCollectionViewCommon.swift
  35. 1 1
      iOSClient/Main/Collection Common/NCGridCell.swift
  36. 1 1
      iOSClient/Main/Collection Common/NCListCell.swift
  37. 13 13
      iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift
  38. 5 8
      iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift
  39. 4 7
      iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift
  40. 9 9
      iOSClient/Main/Create cloud/NCUploadAssets.swift
  41. 26 28
      iOSClient/Main/NCActionCenter.swift
  42. 1 5
      iOSClient/Main/NCMainTabBar.swift
  43. 3 9
      iOSClient/Main/NCPickerViewController.swift
  44. 2 2
      iOSClient/Main/Section Header Footer/NCSectionHeaderMenu.swift
  45. 15 16
      iOSClient/Media/NCMedia.swift
  46. 4 4
      iOSClient/Media/NCMediaCache.swift
  47. 5 9
      iOSClient/Menu/AppDelegate+Menu.swift
  48. 2 2
      iOSClient/Menu/NCCollectionViewCommon+Menu.swift
  49. 3 3
      iOSClient/Menu/NCContextMenu.swift
  50. 6 6
      iOSClient/Menu/NCMedia+Menu.swift
  51. 2 2
      iOSClient/Menu/NCMenuAction.swift
  52. 2 2
      iOSClient/Menu/NCOperationSaveLivePhoto.swift
  53. 1 1
      iOSClient/Menu/NCTrash+Menu.swift
  54. 4 4
      iOSClient/Menu/NCViewer+Menu.swift
  55. 3 8
      iOSClient/More/NCMore.swift
  56. 0 1
      iOSClient/NCGlobal.swift
  57. 1 1
      iOSClient/Networking/E2EE/NCEndToEndEncryption.m
  58. 5 5
      iOSClient/Networking/E2EE/NCEndToEndMetadataV1.swift
  59. 5 5
      iOSClient/Networking/E2EE/NCEndToEndMetadataV20.swift
  60. 1 1
      iOSClient/Networking/E2EE/NCNetworkingE2EE.swift
  61. 1 1
      iOSClient/Networking/E2EE/NCNetworkingE2EECreateFolder.swift
  62. 4 3
      iOSClient/Networking/E2EE/NCNetworkingE2EERename.swift
  63. 4 4
      iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift
  64. 2 2
      iOSClient/Networking/NCAutoUpload.swift
  65. 41 48
      iOSClient/Networking/NCNetworking.swift
  66. 4 3
      iOSClient/Networking/NCNetworkingCheckRemoteUser.swift
  67. 3 7
      iOSClient/Networking/NCNetworkingProcessUpload.swift
  68. 4 6
      iOSClient/Networking/NCService.swift
  69. 3 6
      iOSClient/Notification/NCNotification.swift
  70. 21 21
      iOSClient/PushNotification/NCPushNotification.m
  71. 1 1
      iOSClient/PushNotification/NCPushNotificationEncryption.h
  72. 4 4
      iOSClient/PushNotification/NCPushNotificationEncryption.m
  73. 1 1
      iOSClient/Recent/NCRecent.swift
  74. 3 5
      iOSClient/RichWorkspace/NCRichWorkspaceCommon.swift
  75. 1 4
      iOSClient/RichWorkspace/NCViewerRichWorkspace.swift
  76. 1 1
      iOSClient/Scan document/NCDocumentCamera.swift
  77. 3 3
      iOSClient/Scan document/NCScan+CollectionView.swift
  78. 4 4
      iOSClient/Scan document/NCScan.swift
  79. 9 11
      iOSClient/Scan document/NCUploadScanDocument.swift
  80. 6 6
      iOSClient/Select/NCSelect.swift
  81. 2 2
      iOSClient/Settings/Acknowledgements.rtf
  82. 31 31
      iOSClient/Settings/CCAdvanced.m
  83. 3 4
      iOSClient/Settings/CCManageAccount.m
  84. 8 1
      iOSClient/Settings/CCManageAutoUpload.m
  85. 21 25
      iOSClient/Settings/NCEndToEndInitialize.swift
  86. 11 14
      iOSClient/Settings/NCManageAutoUploadFileName.swift
  87. 10 18
      iOSClient/Settings/NCManageE2EE.swift
  88. 28 28
      iOSClient/Settings/NCSettings.m
  89. 5 5
      iOSClient/Settings/NCSettingsBundleHelper.swift
  90. 2 2
      iOSClient/Share/Advanced/NCShareAdvancePermissionHeader.swift
  91. 9 2
      iOSClient/Share/NCShare.swift
  92. 3 6
      iOSClient/Share/NCShareNetworking.swift
  93. 3 3
      iOSClient/Share/NCSharePaging.swift
  94. 1 1
      iOSClient/Share/NCShareUserCell.swift
  95. 1 1
      iOSClient/Transfers/NCTransferCell.swift
  96. 6 6
      iOSClient/Transfers/NCTransfers.swift
  97. 1 1
      iOSClient/Trash/Cell/NCTrashListCell+NCTrashCellProtocol.swift
  98. 5 5
      iOSClient/Trash/NCTrash+CollectionView.swift
  99. 2 2
      iOSClient/Trash/NCTrash.swift
  100. 0 193
      iOSClient/Utility/CCUtility.h

+ 1 - 1
Brand/Database.swift

@@ -26,4 +26,4 @@ import Foundation
 // Database Realm
 // Database Realm
 //
 //
 let databaseName                    = "nextcloud.realm"
 let databaseName                    = "nextcloud.realm"
-let databaseSchemaVersion: UInt64   = 320
+let databaseSchemaVersion: UInt64   = 321

+ 7 - 9
File Provider Extension/FileProviderData.swift

@@ -72,13 +72,11 @@ class fileProviderData: NSObject {
         }
         }
 
 
         // LOG
         // LOG
-        if let pathDirectoryGroup = CCUtility.getDirectoryGroup()?.path {
-            NextcloudKit.shared.nkCommonInstance.pathLog = pathDirectoryGroup
-            let levelLog = CCUtility.getLogLevel()
-            NextcloudKit.shared.nkCommonInstance.levelLog = levelLog
-            let version = NSString(format: NCBrandOptions.shared.textCopyrightNextcloudiOS as NSString, NCUtility.shared.getVersionApp()) as String
-            NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Start File Provider session with level \(levelLog) " + version + " (File Provider Extension)")
-        }
+        NextcloudKit.shared.nkCommonInstance.pathLog = NCUtilityFileSystem.shared.directoryGroup
+        let levelLog = NCKeychain().logLevel
+        NextcloudKit.shared.nkCommonInstance.levelLog = levelLog
+        let version = NSString(format: NCBrandOptions.shared.textCopyrightNextcloudiOS as NSString, NCUtility.shared.getVersionApp()) as String
+        NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Start File Provider session with level \(levelLog) " + version + " (File Provider Extension)")
 
 
         // NO DOMAIN -> Set default account
         // NO DOMAIN -> Set default account
         if domain == nil {
         if domain == nil {
@@ -93,7 +91,7 @@ class fileProviderData: NSObject {
 
 
             NCManageDatabase.shared.setCapabilities(account: account)
             NCManageDatabase.shared.setCapabilities(account: account)
 
 
-            NextcloudKit.shared.setup(account: activeAccount.account, user: activeAccount.user, userId: activeAccount.userId, password: CCUtility.getPassword(activeAccount.account), urlBase: activeAccount.urlBase, userAgent: userAgent, nextcloudVersion: NCGlobal.shared.capabilityServerVersionMajor, delegate: NCNetworking.shared)
+            NextcloudKit.shared.setup(account: activeAccount.account, user: activeAccount.user, userId: activeAccount.userId, password: NCKeychain().getPassword(account: activeAccount.account), urlBase: activeAccount.urlBase, userAgent: userAgent, nextcloudVersion: NCGlobal.shared.capabilityServerVersionMajor, delegate: NCNetworking.shared)
             NCNetworking.shared.delegate = providerExtension as? NCNetworkingDelegate
             NCNetworking.shared.delegate = providerExtension as? NCNetworkingDelegate
 
 
             return tableAccount.init(value: activeAccount)
             return tableAccount.init(value: activeAccount)
@@ -117,7 +115,7 @@ class fileProviderData: NSObject {
 
 
                 NCManageDatabase.shared.setCapabilities(account: account)
                 NCManageDatabase.shared.setCapabilities(account: account)
 
 
-                NextcloudKit.shared.setup(account: activeAccount.account, user: activeAccount.user, userId: activeAccount.userId, password: CCUtility.getPassword(activeAccount.account), urlBase: activeAccount.urlBase, userAgent: userAgent, nextcloudVersion: NCGlobal.shared.capabilityServerVersionMajor, delegate: NCNetworking.shared)
+                NextcloudKit.shared.setup(account: activeAccount.account, user: activeAccount.user, userId: activeAccount.userId, password: NCKeychain().getPassword(account: activeAccount.account), urlBase: activeAccount.urlBase, userAgent: userAgent, nextcloudVersion: NCGlobal.shared.capabilityServerVersionMajor, delegate: NCNetworking.shared)
                 NCNetworking.shared.delegate = providerExtension as? NCNetworkingDelegate
                 NCNetworking.shared.delegate = providerExtension as? NCNetworkingDelegate
 
 
                 return tableAccount.init(value: activeAccount)
                 return tableAccount.init(value: activeAccount)

+ 2 - 2
File Provider Extension/FileProviderEnumerator.swift

@@ -203,11 +203,11 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
             directoryEtag = tableDirectory.etag
             directoryEtag = tableDirectory.etag
         }
         }
 
 
-        NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl, depth: "0", showHiddenFiles: CCUtility.getShowHiddenFiles()) { account, files, _, error in
+        NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl, depth: "0", showHiddenFiles: NCKeychain().showHiddenFiles) { account, files, _, error in
 
 
             if directoryEtag != files.first?.etag {
             if directoryEtag != files.first?.etag {
 
 
-                NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl, depth: "1", showHiddenFiles: CCUtility.getShowHiddenFiles()) { account, files, _, error in
+                NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl, depth: "1", showHiddenFiles: NCKeychain().showHiddenFiles) { account, files, _, error in
 
 
                     if error == .success {
                     if error == .success {
                         DispatchQueue.global().async {
                         DispatchQueue.global().async {

+ 8 - 8
File Provider Extension/FileProviderExtension+Actions.swift

@@ -41,7 +41,7 @@ extension FileProviderExtension {
 
 
             if error == .success {
             if error == .success {
 
 
-                NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrlFileName, depth: "0", showHiddenFiles: CCUtility.getShowHiddenFiles()) { _, files, _, error in
+                NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrlFileName, depth: "0", showHiddenFiles: NCKeychain().showHiddenFiles) { _, files, _, error in
 
 
                     if error == .success, let file = files.first {
                     if error == .success, let file = files.first {
 
 
@@ -92,7 +92,7 @@ extension FileProviderExtension {
 
 
             if error == .success { // || error == kOCErrorServerPathNotFound {
             if error == .success { // || error == kOCErrorServerPathNotFound {
 
 
-                let fileNamePath = CCUtility.getDirectoryProviderStorageOcId(itemIdentifier.rawValue)!
+                let fileNamePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(itemIdentifier.rawValue)
                 do {
                 do {
                     try fileProviderUtility.shared.fileManager.removeItem(atPath: fileNamePath)
                     try fileProviderUtility.shared.fileManager.removeItem(atPath: fileNamePath)
                 } catch let error {
                 } catch let error {
@@ -100,8 +100,8 @@ extension FileProviderExtension {
                 }
                 }
 
 
                 if isDirectory {
                 if isDirectory {
-                    let dirForDelete = CCUtility.stringAppendServerUrl(serverUrl, addFileName: fileName)
-                    NCManageDatabase.shared.deleteDirectoryAndSubDirectory(serverUrl: dirForDelete!, account: account)
+                    let dirForDelete = NCUtilityFileSystem.shared.stringAppendServerUrl(serverUrl, addFileName: fileName)
+                    NCManageDatabase.shared.deleteDirectoryAndSubDirectory(serverUrl: dirForDelete, account: account)
                 }
                 }
 
 
                 NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", ocId))
                 NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", ocId))
@@ -201,11 +201,11 @@ extension FileProviderExtension {
                     let itemIdentifier = fileProviderUtility.shared.getItemIdentifier(metadata: metadata)
                     let itemIdentifier = fileProviderUtility.shared.getItemIdentifier(metadata: metadata)
 
 
                     // rename file
                     // rename file
-                    _ = fileProviderUtility.shared.moveFile(CCUtility.getDirectoryProviderStorageOcId(itemIdentifier.rawValue, fileNameView: fileNameFrom), toPath: CCUtility.getDirectoryProviderStorageOcId(itemIdentifier.rawValue, fileNameView: itemName))
+                    _ = fileProviderUtility.shared.moveFile(NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(itemIdentifier.rawValue, fileNameView: fileNameFrom), toPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(itemIdentifier.rawValue, fileNameView: itemName))
 
 
-                    _ = fileProviderUtility.shared.moveFile(CCUtility.getDirectoryProviderStoragePreviewOcId(itemIdentifier.rawValue, etag: metadata.etag), toPath: CCUtility.getDirectoryProviderStoragePreviewOcId(itemIdentifier.rawValue, etag: metadata.etag))
+                    _ = fileProviderUtility.shared.moveFile(NCUtilityFileSystem.shared.getDirectoryProviderStoragePreviewOcId(itemIdentifier.rawValue, etag: metadata.etag), toPath: NCUtilityFileSystem.shared.getDirectoryProviderStoragePreviewOcId(itemIdentifier.rawValue, etag: metadata.etag))
 
 
-                    _ = fileProviderUtility.shared.moveFile(CCUtility.getDirectoryProviderStorageIconOcId(itemIdentifier.rawValue, etag: metadata.etag), toPath: CCUtility.getDirectoryProviderStorageIconOcId(itemIdentifier.rawValue, etag: metadata.etag))
+                    _ = fileProviderUtility.shared.moveFile(NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(itemIdentifier.rawValue, etag: metadata.etag), toPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(itemIdentifier.rawValue, etag: metadata.etag))
 
 
                     NCManageDatabase.shared.setLocalFile(ocId: ocId, fileName: itemName, etag: nil)
                     NCManageDatabase.shared.setLocalFile(ocId: ocId, fileName: itemName, etag: nil)
                 }
                 }
@@ -245,7 +245,7 @@ extension FileProviderExtension {
         }
         }
 
 
         if (favorite == true && metadata.favorite == false) || (favorite == false && metadata.favorite == true) {
         if (favorite == true && metadata.favorite == false) || (favorite == false && metadata.favorite == true) {
-            let fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId, account: metadata.account)!
+            let fileNamePath = NCUtilityFileSystem.shared.getFileNamePath(metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId)
 
 
             NextcloudKit.shared.setFavorite(fileName: fileNamePath, favorite: favorite) { _, error in
             NextcloudKit.shared.setFavorite(fileName: fileNamePath, favorite: favorite) { _, error in
 
 

+ 2 - 2
File Provider Extension/FileProviderExtension+Thumbnail.swift

@@ -42,8 +42,8 @@ extension FileProviderExtension {
 
 
             if metadata.hasPreview {
             if metadata.hasPreview {
 
 
-                let fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId, account: metadata.account)!
-                let fileNameIconLocalPath = CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)!
+                let fileNamePath = NCUtilityFileSystem.shared.getFileNamePath(metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId)
+                let fileNameIconLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)
 
 
                 if let urlBase = metadata.urlBase.urlEncoded,
                 if let urlBase = metadata.urlBase.urlEncoded,
                    let fileNamePath = fileNamePath.urlEncoded,
                    let fileNamePath = fileNamePath.urlEncoded,

+ 15 - 15
File Provider Extension/FileProviderExtension.swift

@@ -60,7 +60,7 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate {
         super.init()
         super.init()
 
 
         // Create directory File Provider Storage
         // Create directory File Provider Storage
-        CCUtility.getDirectoryProviderStorage()
+        _ = NCUtilityFileSystem.shared.directoryProviderStorage
         // Configure URLSession
         // Configure URLSession
         _ = NCNetworking.shared.sessionManagerBackgroundExtension
         _ = NCNetworking.shared.sessionManagerBackgroundExtension
     }
     }
@@ -78,9 +78,9 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate {
         if containerItemIdentifier != NSFileProviderItemIdentifier.workingSet {
         if containerItemIdentifier != NSFileProviderItemIdentifier.workingSet {
             if fileProviderData.shared.setupAccount(domain: domain, providerExtension: self) == nil {
             if fileProviderData.shared.setupAccount(domain: domain, providerExtension: self) == nil {
                 throw NSError(domain: NSFileProviderErrorDomain, code: NSFileProviderError.notAuthenticated.rawValue, userInfo: [:])
                 throw NSError(domain: NSFileProviderErrorDomain, code: NSFileProviderError.notAuthenticated.rawValue, userInfo: [:])
-            } else if let passcode = CCUtility.getPasscode(), !passcode.isEmpty, CCUtility.isPasscodeAtStartEnabled() {
+            } else if NCKeychain().passcode != nil, NCKeychain().requestPasscodeAtStart {
                 throw NSError(domain: NSFileProviderErrorDomain, code: NSFileProviderError.notAuthenticated.rawValue, userInfo: ["code": NSNumber(value: NCGlobal.shared.errorUnauthorizedFilesPasscode)])
                 throw NSError(domain: NSFileProviderErrorDomain, code: NSFileProviderError.notAuthenticated.rawValue, userInfo: ["code": NSNumber(value: NCGlobal.shared.errorUnauthorizedFilesPasscode)])
-            } else if CCUtility.getDisableFilesApp() || NCBrandOptions.shared.disable_openin_file {
+            } else if NCKeychain().disableFilesApp || NCBrandOptions.shared.disable_openin_file {
                 throw NSError(domain: NSFileProviderErrorDomain, code: NSFileProviderError.notAuthenticated.rawValue, userInfo: ["code": NSNumber(value: NCGlobal.shared.errorDisableFilesApp)])
                 throw NSError(domain: NSFileProviderErrorDomain, code: NSFileProviderError.notAuthenticated.rawValue, userInfo: ["code": NSNumber(value: NCGlobal.shared.errorDisableFilesApp)])
             }
             }
         }
         }
@@ -204,12 +204,12 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate {
         }
         }
 
 
         let tableLocalFile = NCManageDatabase.shared.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
         let tableLocalFile = NCManageDatabase.shared.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
-        if tableLocalFile != nil && CCUtility.fileProviderStorageExists(metadata) && tableLocalFile?.etag == metadata.etag {
+        if tableLocalFile != nil && NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) && tableLocalFile?.etag == metadata.etag {
             return completionHandler(nil)
             return completionHandler(nil)
         }
         }
 
 
         let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
         let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
-        let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileName)!
+        let fileNameLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileName)
 
 
         // Update status
         // Update status
         NCManageDatabase.shared.setMetadataStatus(ocId: metadata.ocId, status: NCGlobal.shared.metadataStatusDownloading)
         NCManageDatabase.shared.setMetadataStatus(ocId: metadata.ocId, status: NCGlobal.shared.metadataStatusDownloading)
@@ -274,9 +274,9 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate {
         // Temp ocId ?
         // Temp ocId ?
         if outstandingOcIdTemp[ocId] != nil && outstandingOcIdTemp[ocId] != ocId {
         if outstandingOcIdTemp[ocId] != nil && outstandingOcIdTemp[ocId] != ocId {
             ocId = outstandingOcIdTemp[ocId]!
             ocId = outstandingOcIdTemp[ocId]!
-            let atPath = CCUtility.getDirectoryProviderStorageOcId(itemIdentifier.rawValue, fileNameView: fileName)
-            let toPath = CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileName)
-            CCUtility.copyFile(atPath: atPath, toPath: toPath)
+            let atPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(itemIdentifier.rawValue, fileNameView: fileName)
+            let toPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId, fileNameView: fileName)
+            NCUtilityFileSystem.shared.copyFile(atPath: atPath, toPath: toPath)
         }
         }
         guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) else { return }
         guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) else { return }
 
 
@@ -348,7 +348,7 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate {
                 let ocIdTemp = NSUUID().uuidString.lowercased()
                 let ocIdTemp = NSUUID().uuidString.lowercased()
 
 
                 NSFileCoordinator().coordinate(readingItemAt: fileURL, options: .withoutChanges, error: &error) { url in
                 NSFileCoordinator().coordinate(readingItemAt: fileURL, options: .withoutChanges, error: &error) { url in
-                    _ = fileProviderUtility.shared.copyFile(url.path, toPath: CCUtility.getDirectoryProviderStorageOcId(ocIdTemp, fileNameView: fileName))
+                    _ = fileProviderUtility.shared.copyFile(url.path, toPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocIdTemp, fileNameView: fileName))
                 }
                 }
 
 
                 fileURL.stopAccessingSecurityScopedResource()
                 fileURL.stopAccessingSecurityScopedResource()
@@ -361,7 +361,7 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate {
                 NCManageDatabase.shared.addMetadata(metadata)
                 NCManageDatabase.shared.addMetadata(metadata)
 
 
                 let serverUrlFileName = tableDirectory.serverUrl + "/" + fileName
                 let serverUrlFileName = tableDirectory.serverUrl + "/" + fileName
-                let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(ocIdTemp, fileNameView: fileName)!
+                let fileNameLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocIdTemp, fileNameView: fileName)
 
 
                 if let task = NKBackground(nkCommonInstance: NextcloudKit.shared.nkCommonInstance).upload(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, dateCreationFile: nil, dateModificationFile: nil, description: ocIdTemp, session: NCNetworking.shared.sessionManagerBackgroundExtension) {
                 if let task = NKBackground(nkCommonInstance: NextcloudKit.shared.nkCommonInstance).upload(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, dateCreationFile: nil, dateModificationFile: nil, description: ocIdTemp, session: NCNetworking.shared.sessionManagerBackgroundExtension) {
 
 
@@ -383,7 +383,7 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate {
         guard let metadataTemp = NCManageDatabase.shared.getMetadataFromOcId(ocIdTemp) else { return }
         guard let metadataTemp = NCManageDatabase.shared.getMetadataFromOcId(ocIdTemp) else { return }
         let metadata = tableMetadata.init(value: metadataTemp)
         let metadata = tableMetadata.init(value: metadataTemp)
 
 
-        let url = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(ocIdTemp, fileNameView: fileName))
+        let url = URL(fileURLWithPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocIdTemp, fileNameView: fileName))
         DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
         DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
             self.outstandingSessionTasks.removeValue(forKey: url)
             self.outstandingSessionTasks.removeValue(forKey: url)
         }
         }
@@ -411,14 +411,14 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate {
             NCManageDatabase.shared.addLocalFile(metadata: metadata)
             NCManageDatabase.shared.addLocalFile(metadata: metadata)
 
 
             // New file
             // New file
-            if ocId != ocIdTemp {
+            if let ocId, ocId != ocIdTemp {
 
 
                 NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", ocIdTemp))
                 NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", ocIdTemp))
 
 
                 // File system
                 // File system
-                let atPath = CCUtility.getDirectoryProviderStorageOcId(ocIdTemp)
-                let toPath = CCUtility.getDirectoryProviderStorageOcId(ocId)
-                CCUtility.copyFile(atPath: atPath, toPath: toPath)
+                let atPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocIdTemp)
+                let toPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId)
+                NCUtilityFileSystem.shared.copyFile(atPath: atPath, toPath: toPath)
             }
             }
 
 
             fileProviderData.shared.signalEnumerator(ocId: metadata.ocId, update: true)
             fileProviderData.shared.signalEnumerator(ocId: metadata.ocId, update: true)

+ 1 - 1
File Provider Extension/FileProviderItem.swift

@@ -105,7 +105,7 @@ class FileProviderItem: NSObject, NSFileProviderItem {
         if metadata.directory {
         if metadata.directory {
             return true
             return true
         }
         }
-        if CCUtility.fileProviderStorageExists(metadata) {
+        if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) {
             return true
             return true
         } else {
         } else {
             return false
             return false

+ 2 - 2
File Provider Extension/FileProviderUtility.swift

@@ -53,9 +53,9 @@ class fileProviderUtility: NSObject {
         let itemIdentifier = getItemIdentifier(metadata: metadata)
         let itemIdentifier = getItemIdentifier(metadata: metadata)
 
 
         if metadata.directory {
         if metadata.directory {
-            CCUtility.getDirectoryProviderStorageOcId(itemIdentifier.rawValue)
+            _ = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(itemIdentifier.rawValue)
         } else {
         } else {
-            CCUtility.getDirectoryProviderStorageOcId(itemIdentifier.rawValue, fileNameView: metadata.fileNameView)
+            NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(itemIdentifier.rawValue, fileNameView: metadata.fileNameView)
         }
         }
     }
     }
 
 

+ 4 - 93
Nextcloud.xcodeproj/project.pbxproj

@@ -70,9 +70,7 @@
 		AFCE353927E5DE0500FEA6C2 /* NCShare+Helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353827E5DE0400FEA6C2 /* NCShare+Helper.swift */; };
 		AFCE353927E5DE0500FEA6C2 /* NCShare+Helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353827E5DE0400FEA6C2 /* NCShare+Helper.swift */; };
 		C0046CDD2A17B98400D87C9D /* LoginUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0046CDC2A17B98400D87C9D /* LoginUITests.swift */; };
 		C0046CDD2A17B98400D87C9D /* LoginUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0046CDC2A17B98400D87C9D /* LoginUITests.swift */; };
 		C03BA14A2A17BC57002C8BA3 /* XLForm in Frameworks */ = {isa = PBXBuildFile; productRef = C03BA1492A17BC57002C8BA3 /* XLForm */; };
 		C03BA14A2A17BC57002C8BA3 /* XLForm in Frameworks */ = {isa = PBXBuildFile; productRef = C03BA1492A17BC57002C8BA3 /* XLForm */; };
-		C03BA14C2A17BC60002C8BA3 /* UICKeyChainStore in Frameworks */ = {isa = PBXBuildFile; productRef = C03BA14B2A17BC60002C8BA3 /* UICKeyChainStore */; };
 		C04E2F192A17BA78001BAD85 /* XLForm in Frameworks */ = {isa = PBXBuildFile; productRef = C04E2F182A17BA78001BAD85 /* XLForm */; };
 		C04E2F192A17BA78001BAD85 /* XLForm in Frameworks */ = {isa = PBXBuildFile; productRef = C04E2F182A17BA78001BAD85 /* XLForm */; };
-		C04E2F1B2A17BAAB001BAD85 /* UICKeyChainStore in Frameworks */ = {isa = PBXBuildFile; productRef = C04E2F1A2A17BAAB001BAD85 /* UICKeyChainStore */; };
 		C04E2F232A17BB4D001BAD85 /* FilesIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04E2F222A17BB4D001BAD85 /* FilesIntegrationTests.swift */; };
 		C04E2F232A17BB4D001BAD85 /* FilesIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04E2F222A17BB4D001BAD85 /* FilesIntegrationTests.swift */; };
 		D575039F27146F93008DC9DC /* String+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7A0D1342591FBC5008F8A13 /* String+Extension.swift */; };
 		D575039F27146F93008DC9DC /* String+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7A0D1342591FBC5008F8A13 /* String+Extension.swift */; };
 		D5B6AA7827200C7200D49C24 /* NCActivityTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5B6AA7727200C7200D49C24 /* NCActivityTableViewCell.swift */; };
 		D5B6AA7827200C7200D49C24 /* NCActivityTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5B6AA7727200C7200D49C24 /* NCActivityTableViewCell.swift */; };
@@ -93,7 +91,6 @@
 		F31F69542A2F89C400162F76 /* SwiftRichString in Frameworks */ = {isa = PBXBuildFile; productRef = F31F69532A2F89C400162F76 /* SwiftRichString */; };
 		F31F69542A2F89C400162F76 /* SwiftRichString in Frameworks */ = {isa = PBXBuildFile; productRef = F31F69532A2F89C400162F76 /* SwiftRichString */; };
 		F31F69562A2F89C400162F76 /* FirebaseDatabase in Frameworks */ = {isa = PBXBuildFile; productRef = F31F69552A2F89C400162F76 /* FirebaseDatabase */; };
 		F31F69562A2F89C400162F76 /* FirebaseDatabase in Frameworks */ = {isa = PBXBuildFile; productRef = F31F69552A2F89C400162F76 /* FirebaseDatabase */; };
 		F31F69582A2F89C400162F76 /* XLForm in Frameworks */ = {isa = PBXBuildFile; productRef = F31F69572A2F89C400162F76 /* XLForm */; };
 		F31F69582A2F89C400162F76 /* XLForm in Frameworks */ = {isa = PBXBuildFile; productRef = F31F69572A2F89C400162F76 /* XLForm */; };
-		F31F695A2A2F89C400162F76 /* UICKeyChainStore in Frameworks */ = {isa = PBXBuildFile; productRef = F31F69592A2F89C400162F76 /* UICKeyChainStore */; };
 		F31F695C2A2F89C400162F76 /* Realm in Frameworks */ = {isa = PBXBuildFile; productRef = F31F695B2A2F89C400162F76 /* Realm */; };
 		F31F695C2A2F89C400162F76 /* Realm in Frameworks */ = {isa = PBXBuildFile; productRef = F31F695B2A2F89C400162F76 /* Realm */; };
 		F31F695E2A2F89C400162F76 /* JGProgressHUD in Frameworks */ = {isa = PBXBuildFile; productRef = F31F695D2A2F89C400162F76 /* JGProgressHUD */; };
 		F31F695E2A2F89C400162F76 /* JGProgressHUD in Frameworks */ = {isa = PBXBuildFile; productRef = F31F695D2A2F89C400162F76 /* JGProgressHUD */; };
 		F31F69612A2F907800162F76 /* __Snapshots__ in Resources */ = {isa = PBXBuildFile; fileRef = F31F69602A2F907800162F76 /* __Snapshots__ */; };
 		F31F69612A2F907800162F76 /* __Snapshots__ in Resources */ = {isa = PBXBuildFile; fileRef = F31F69602A2F907800162F76 /* __Snapshots__ */; };
@@ -157,7 +154,6 @@
 		F70716E62987F81500E72C1D /* DocumentActionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F70716E52987F81500E72C1D /* DocumentActionViewController.swift */; };
 		F70716E62987F81500E72C1D /* DocumentActionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F70716E52987F81500E72C1D /* DocumentActionViewController.swift */; };
 		F70716E92987F81500E72C1D /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F70716E72987F81500E72C1D /* MainInterface.storyboard */; };
 		F70716E92987F81500E72C1D /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F70716E72987F81500E72C1D /* MainInterface.storyboard */; };
 		F70716ED2987F81500E72C1D /* File Provider Extension UI.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = F70716E32987F81500E72C1D /* File Provider Extension UI.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
 		F70716ED2987F81500E72C1D /* File Provider Extension UI.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = F70716E32987F81500E72C1D /* File Provider Extension UI.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
-		F70716F929881CFA00E72C1D /* UICKeyChainStore in Frameworks */ = {isa = PBXBuildFile; productRef = F70716F829881CFA00E72C1D /* UICKeyChainStore */; };
 		F70753EB2542A99800972D44 /* NCViewerMediaPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = F70753EA2542A99800972D44 /* NCViewerMediaPage.swift */; };
 		F70753EB2542A99800972D44 /* NCViewerMediaPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = F70753EA2542A99800972D44 /* NCViewerMediaPage.swift */; };
 		F70753F12542A9A200972D44 /* NCViewerMedia.swift in Sources */ = {isa = PBXBuildFile; fileRef = F70753F02542A9A200972D44 /* NCViewerMedia.swift */; };
 		F70753F12542A9A200972D44 /* NCViewerMedia.swift in Sources */ = {isa = PBXBuildFile; fileRef = F70753F02542A9A200972D44 /* NCViewerMedia.swift */; };
 		F70753F72542A9C000972D44 /* NCViewerMediaPage.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F70753F62542A9C000972D44 /* NCViewerMediaPage.storyboard */; };
 		F70753F72542A9C000972D44 /* NCViewerMediaPage.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F70753F62542A9C000972D44 /* NCViewerMediaPage.storyboard */; };
@@ -243,7 +239,6 @@
 		F7346E1628B0EF5C006CE2D2 /* Widget.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7346E1528B0EF5C006CE2D2 /* Widget.swift */; };
 		F7346E1628B0EF5C006CE2D2 /* Widget.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7346E1528B0EF5C006CE2D2 /* Widget.swift */; };
 		F7346E1C28B0EF5E006CE2D2 /* Widget.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = F7346E1028B0EF5B006CE2D2 /* Widget.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
 		F7346E1C28B0EF5E006CE2D2 /* Widget.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = F7346E1028B0EF5B006CE2D2 /* Widget.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
 		F7346E2328B0FEBA006CE2D2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F7346E2228B0FEBA006CE2D2 /* Assets.xcassets */; };
 		F7346E2328B0FEBA006CE2D2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F7346E2228B0FEBA006CE2D2 /* Assets.xcassets */; };
-		F7346E2528B0FEFA006CE2D2 /* UICKeyChainStore in Frameworks */ = {isa = PBXBuildFile; productRef = F7346E2428B0FEFA006CE2D2 /* UICKeyChainStore */; };
 		F7346E2928B0FFF2006CE2D2 /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = F7346E2828B0FFF2006CE2D2 /* RealmSwift */; };
 		F7346E2928B0FFF2006CE2D2 /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = F7346E2828B0FFF2006CE2D2 /* RealmSwift */; };
 		F734B06628E75C0100E180D5 /* TLPhotoPicker in Frameworks */ = {isa = PBXBuildFile; productRef = F734B06528E75C0100E180D5 /* TLPhotoPicker */; };
 		F734B06628E75C0100E180D5 /* TLPhotoPicker in Frameworks */ = {isa = PBXBuildFile; productRef = F734B06528E75C0100E180D5 /* TLPhotoPicker */; };
 		F7362A1F220C853A005101B5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7362A1E220C853A005101B5 /* LaunchScreen.storyboard */; };
 		F7362A1F220C853A005101B5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7362A1E220C853A005101B5 /* LaunchScreen.storyboard */; };
@@ -417,7 +412,6 @@
 		F76DA95B277B75A90082465B /* TOPasscodeViewController.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = F70B86822642CF5500ED5349 /* TOPasscodeViewController.xcframework */; };
 		F76DA95B277B75A90082465B /* TOPasscodeViewController.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = F70B86822642CF5500ED5349 /* TOPasscodeViewController.xcframework */; };
 		F76DA95C277B75A90082465B /* TOPasscodeViewController.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = F70B86822642CF5500ED5349 /* TOPasscodeViewController.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
 		F76DA95C277B75A90082465B /* TOPasscodeViewController.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = F70B86822642CF5500ED5349 /* TOPasscodeViewController.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
 		F76DA963277B760E0082465B /* Queuer in Frameworks */ = {isa = PBXBuildFile; productRef = F76DA962277B760E0082465B /* Queuer */; };
 		F76DA963277B760E0082465B /* Queuer in Frameworks */ = {isa = PBXBuildFile; productRef = F76DA962277B760E0082465B /* Queuer */; };
-		F76DA966277B76F30082465B /* UICKeyChainStore in Frameworks */ = {isa = PBXBuildFile; productRef = F76DA965277B76F30082465B /* UICKeyChainStore */; };
 		F76DA969277B77EA0082465B /* DropDown in Frameworks */ = {isa = PBXBuildFile; productRef = F76DA968277B77EA0082465B /* DropDown */; };
 		F76DA969277B77EA0082465B /* DropDown in Frameworks */ = {isa = PBXBuildFile; productRef = F76DA968277B77EA0082465B /* DropDown */; };
 		F76DEE9728F808AF0041B1C9 /* LockscreenData.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76DEE9428F808AF0041B1C9 /* LockscreenData.swift */; };
 		F76DEE9728F808AF0041B1C9 /* LockscreenData.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76DEE9428F808AF0041B1C9 /* LockscreenData.swift */; };
 		F76DEE9828F808AF0041B1C9 /* LockscreenWidgetProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76DEE9528F808AF0041B1C9 /* LockscreenWidgetProvider.swift */; };
 		F76DEE9828F808AF0041B1C9 /* LockscreenWidgetProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76DEE9528F808AF0041B1C9 /* LockscreenWidgetProvider.swift */; };
@@ -580,7 +574,6 @@
 		F7A7FA6329265CF4000603EF /* NCManageE2EE.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7A7FA6229265CF4000603EF /* NCManageE2EE.swift */; };
 		F7A7FA6329265CF4000603EF /* NCManageE2EE.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7A7FA6229265CF4000603EF /* NCManageE2EE.swift */; };
 		F7A8D72428F1771B008BBE1C /* NextcloudKit in Frameworks */ = {isa = PBXBuildFile; productRef = F7A8D72328F1771B008BBE1C /* NextcloudKit */; };
 		F7A8D72428F1771B008BBE1C /* NextcloudKit in Frameworks */ = {isa = PBXBuildFile; productRef = F7A8D72328F1771B008BBE1C /* NextcloudKit */; };
 		F7A8D72828F17728008BBE1C /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = F7A8D72728F17728008BBE1C /* RealmSwift */; };
 		F7A8D72828F17728008BBE1C /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = F7A8D72728F17728008BBE1C /* RealmSwift */; };
-		F7A8D72E28F17764008BBE1C /* UICKeyChainStore in Frameworks */ = {isa = PBXBuildFile; productRef = F7A8D72D28F17764008BBE1C /* UICKeyChainStore */; };
 		F7A8D73428F17E12008BBE1C /* NCDatabase.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7BAADB41ED5A87C00B7EAD4 /* NCDatabase.swift */; };
 		F7A8D73428F17E12008BBE1C /* NCDatabase.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7BAADB41ED5A87C00B7EAD4 /* NCDatabase.swift */; };
 		F7A8D73528F17E16008BBE1C /* NCManageDatabase.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7BAADB51ED5A87C00B7EAD4 /* NCManageDatabase.swift */; };
 		F7A8D73528F17E16008BBE1C /* NCManageDatabase.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7BAADB51ED5A87C00B7EAD4 /* NCManageDatabase.swift */; };
 		F7A8D73628F17E1A008BBE1C /* NCManageDatabase+Activity.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF4BF61D27562B3F0081CEEF /* NCManageDatabase+Activity.swift */; };
 		F7A8D73628F17E1A008BBE1C /* NCManageDatabase+Activity.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF4BF61D27562B3F0081CEEF /* NCManageDatabase+Activity.swift */; };
@@ -663,9 +656,6 @@
 		F7E98C1727E0D0FC001F9F19 /* NCManageDatabase+Video.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7E98C1527E0D0FC001F9F19 /* NCManageDatabase+Video.swift */; };
 		F7E98C1727E0D0FC001F9F19 /* NCManageDatabase+Video.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7E98C1527E0D0FC001F9F19 /* NCManageDatabase+Video.swift */; };
 		F7E98C1827E0D0FC001F9F19 /* NCManageDatabase+Video.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7E98C1527E0D0FC001F9F19 /* NCManageDatabase+Video.swift */; };
 		F7E98C1827E0D0FC001F9F19 /* NCManageDatabase+Video.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7E98C1527E0D0FC001F9F19 /* NCManageDatabase+Video.swift */; };
 		F7E98C1927E0D0FC001F9F19 /* NCManageDatabase+Video.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7E98C1527E0D0FC001F9F19 /* NCManageDatabase+Video.swift */; };
 		F7E98C1927E0D0FC001F9F19 /* NCManageDatabase+Video.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7E98C1527E0D0FC001F9F19 /* NCManageDatabase+Video.swift */; };
-		F7EBCDCF277B81FF00A4EF67 /* UICKeyChainStore in Frameworks */ = {isa = PBXBuildFile; productRef = F7EBCDCE277B81FF00A4EF67 /* UICKeyChainStore */; };
-		F7EBCDD1277B820D00A4EF67 /* UICKeyChainStore in Frameworks */ = {isa = PBXBuildFile; productRef = F7EBCDD0277B820D00A4EF67 /* UICKeyChainStore */; };
-		F7EBCDD3277B821700A4EF67 /* UICKeyChainStore in Frameworks */ = {isa = PBXBuildFile; productRef = F7EBCDD2277B821700A4EF67 /* UICKeyChainStore */; };
 		F7ED547C25EEA65400956C55 /* QRCodeReader in Frameworks */ = {isa = PBXBuildFile; productRef = F7ED547B25EEA65400956C55 /* QRCodeReader */; };
 		F7ED547C25EEA65400956C55 /* QRCodeReader in Frameworks */ = {isa = PBXBuildFile; productRef = F7ED547B25EEA65400956C55 /* QRCodeReader */; };
 		F7EDE4CC262D7B6F00414FE6 /* NCEmptyDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7239870253D86B600257F49 /* NCEmptyDataSet.swift */; };
 		F7EDE4CC262D7B6F00414FE6 /* NCEmptyDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7239870253D86B600257F49 /* NCEmptyDataSet.swift */; };
 		F7EDE4D1262D7B8400414FE6 /* NCDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C1EEA425053A9C00866ACC /* NCDataSource.swift */; };
 		F7EDE4D1262D7B8400414FE6 /* NCDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C1EEA425053A9C00866ACC /* NCDataSource.swift */; };
@@ -1398,7 +1388,6 @@
 				F72AD71128C24BBB006CB92D /* NextcloudKit in Frameworks */,
 				F72AD71128C24BBB006CB92D /* NextcloudKit in Frameworks */,
 				F314F1112A30C11200BC7FAB /* PreviewSnapshots in Frameworks */,
 				F314F1112A30C11200BC7FAB /* PreviewSnapshots in Frameworks */,
 				F710FC88277B7D3F00AA9FBF /* RealmSwift in Frameworks */,
 				F710FC88277B7D3F00AA9FBF /* RealmSwift in Frameworks */,
-				F7EBCDD3277B821700A4EF67 /* UICKeyChainStore in Frameworks */,
 				F760DE0F2AE66EE60027D78A /* KeychainAccess in Frameworks */,
 				F760DE0F2AE66EE60027D78A /* KeychainAccess in Frameworks */,
 			);
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 			runOnlyForDeploymentPostprocessing = 0;
@@ -1414,7 +1403,6 @@
 			isa = PBXFrameworksBuildPhase;
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			buildActionMask = 2147483647;
 			files = (
 			files = (
-				C04E2F1B2A17BAAB001BAD85 /* UICKeyChainStore in Frameworks */,
 				C04E2F192A17BA78001BAD85 /* XLForm in Frameworks */,
 				C04E2F192A17BA78001BAD85 /* XLForm in Frameworks */,
 				F760DE152AE66F020027D78A /* KeychainAccess in Frameworks */,
 				F760DE152AE66F020027D78A /* KeychainAccess in Frameworks */,
 			);
 			);
@@ -1429,7 +1417,6 @@
 				F30A96362A2DFCD000D7BCFE /* RealmSwift in Frameworks */,
 				F30A96362A2DFCD000D7BCFE /* RealmSwift in Frameworks */,
 				F30A96342A2DFCD000D7BCFE /* Realm in Frameworks */,
 				F30A96342A2DFCD000D7BCFE /* Realm in Frameworks */,
 				F760DE112AE66EF00027D78A /* KeychainAccess in Frameworks */,
 				F760DE112AE66EF00027D78A /* KeychainAccess in Frameworks */,
-				C03BA14C2A17BC60002C8BA3 /* UICKeyChainStore in Frameworks */,
 				F30A963A2A2DFD3100D7BCFE /* JGProgressHUD in Frameworks */,
 				F30A963A2A2DFD3100D7BCFE /* JGProgressHUD in Frameworks */,
 				C03BA14A2A17BC57002C8BA3 /* XLForm in Frameworks */,
 				C03BA14A2A17BC57002C8BA3 /* XLForm in Frameworks */,
 			);
 			);
@@ -1440,7 +1427,6 @@
 			buildActionMask = 2147483647;
 			buildActionMask = 2147483647;
 			files = (
 			files = (
 				F31F695C2A2F89C400162F76 /* Realm in Frameworks */,
 				F31F695C2A2F89C400162F76 /* Realm in Frameworks */,
-				F31F695A2A2F89C400162F76 /* UICKeyChainStore in Frameworks */,
 				F31F69582A2F89C400162F76 /* XLForm in Frameworks */,
 				F31F69582A2F89C400162F76 /* XLForm in Frameworks */,
 				F31F69542A2F89C400162F76 /* SwiftRichString in Frameworks */,
 				F31F69542A2F89C400162F76 /* SwiftRichString in Frameworks */,
 				F760DE132AE66EF80027D78A /* KeychainAccess in Frameworks */,
 				F760DE132AE66EF80027D78A /* KeychainAccess in Frameworks */,
@@ -1460,7 +1446,6 @@
 				F7490E8B29882CE4009DCE94 /* NextcloudKit in Frameworks */,
 				F7490E8B29882CE4009DCE94 /* NextcloudKit in Frameworks */,
 				F7490E8929882CC8009DCE94 /* SwiftEntryKit in Frameworks */,
 				F7490E8929882CC8009DCE94 /* SwiftEntryKit in Frameworks */,
 				F7490E7229882BB4009DCE94 /* RealmSwift in Frameworks */,
 				F7490E7229882BB4009DCE94 /* RealmSwift in Frameworks */,
-				F70716F929881CFA00E72C1D /* UICKeyChainStore in Frameworks */,
 				F760DE0D2AE66EDF0027D78A /* KeychainAccess in Frameworks */,
 				F760DE0D2AE66EDF0027D78A /* KeychainAccess in Frameworks */,
 			);
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 			runOnlyForDeploymentPostprocessing = 0;
@@ -1476,7 +1461,6 @@
 				F760DE092AE66ED00027D78A /* KeychainAccess in Frameworks */,
 				F760DE092AE66ED00027D78A /* KeychainAccess in Frameworks */,
 				F73ADD2126554F8E0069EA0D /* SwiftEntryKit in Frameworks */,
 				F73ADD2126554F8E0069EA0D /* SwiftEntryKit in Frameworks */,
 				F7A560482AE15D5000BE8FD6 /* Queuer in Frameworks */,
 				F7A560482AE15D5000BE8FD6 /* Queuer in Frameworks */,
-				F7EBCDCF277B81FF00A4EF67 /* UICKeyChainStore in Frameworks */,
 				F70821D829E59E6D001CA2D7 /* TagListView in Frameworks */,
 				F70821D829E59E6D001CA2D7 /* TagListView in Frameworks */,
 				F7F623B72A5EFA0C0022D3D4 /* Gzip in Frameworks */,
 				F7F623B72A5EFA0C0022D3D4 /* Gzip in Frameworks */,
 				F72D7EB7263B1207000B3DFC /* MarkdownKit in Frameworks */,
 				F72D7EB7263B1207000B3DFC /* MarkdownKit in Frameworks */,
@@ -1488,7 +1472,6 @@
 			buildActionMask = 2147483647;
 			buildActionMask = 2147483647;
 			files = (
 			files = (
 				F787AC0B298BCB540001BB00 /* SVGKitSwift in Frameworks */,
 				F787AC0B298BCB540001BB00 /* SVGKitSwift in Frameworks */,
-				F7346E2528B0FEFA006CE2D2 /* UICKeyChainStore in Frameworks */,
 				F783034428B5142B00B84583 /* NextcloudKit in Frameworks */,
 				F783034428B5142B00B84583 /* NextcloudKit in Frameworks */,
 				F7346E1328B0EF5B006CE2D2 /* SwiftUI.framework in Frameworks */,
 				F7346E1328B0EF5B006CE2D2 /* SwiftUI.framework in Frameworks */,
 				F760DE052AE66EBE0027D78A /* KeychainAccess in Frameworks */,
 				F760DE052AE66EBE0027D78A /* KeychainAccess in Frameworks */,
@@ -1505,7 +1488,6 @@
 			buildActionMask = 2147483647;
 			buildActionMask = 2147483647;
 			files = (
 			files = (
 				F7A560442AE15D2900BE8FD6 /* Queuer in Frameworks */,
 				F7A560442AE15D2900BE8FD6 /* Queuer in Frameworks */,
-				F7EBCDD1277B820D00A4EF67 /* UICKeyChainStore in Frameworks */,
 				F760DE0B2AE66ED80027D78A /* KeychainAccess in Frameworks */,
 				F760DE0B2AE66ED80027D78A /* KeychainAccess in Frameworks */,
 				F73ADD2426554FE20069EA0D /* SwiftEntryKit in Frameworks */,
 				F73ADD2426554FE20069EA0D /* SwiftEntryKit in Frameworks */,
 				F710FC84277B7D3500AA9FBF /* RealmSwift in Frameworks */,
 				F710FC84277B7D3500AA9FBF /* RealmSwift in Frameworks */,
@@ -1530,7 +1512,6 @@
 				F710FC7C277B7D0000AA9FBF /* RealmSwift in Frameworks */,
 				F710FC7C277B7D0000AA9FBF /* RealmSwift in Frameworks */,
 				F758A01227A7F03E0069468B /* JGProgressHUD in Frameworks */,
 				F758A01227A7F03E0069468B /* JGProgressHUD in Frameworks */,
 				F77333882927A72100466E35 /* OpenSSL in Frameworks */,
 				F77333882927A72100466E35 /* OpenSSL in Frameworks */,
-				F76DA966277B76F30082465B /* UICKeyChainStore in Frameworks */,
 				F7792DE529EEE02D005930CE /* MobileVLCKit.xcframework in Frameworks */,
 				F7792DE529EEE02D005930CE /* MobileVLCKit.xcframework in Frameworks */,
 				F753BA93281FD8020015BFB6 /* EasyTipView in Frameworks */,
 				F753BA93281FD8020015BFB6 /* EasyTipView in Frameworks */,
 				F76DA95B277B75A90082465B /* TOPasscodeViewController.xcframework in Frameworks */,
 				F76DA95B277B75A90082465B /* TOPasscodeViewController.xcframework in Frameworks */,
@@ -1555,7 +1536,6 @@
 			buildActionMask = 2147483647;
 			buildActionMask = 2147483647;
 			files = (
 			files = (
 				F7A8D72828F17728008BBE1C /* RealmSwift in Frameworks */,
 				F7A8D72828F17728008BBE1C /* RealmSwift in Frameworks */,
-				F7A8D72E28F17764008BBE1C /* UICKeyChainStore in Frameworks */,
 				F7A8D72428F1771B008BBE1C /* NextcloudKit in Frameworks */,
 				F7A8D72428F1771B008BBE1C /* NextcloudKit in Frameworks */,
 				F7C9739228F17131002C43E2 /* Intents.framework in Frameworks */,
 				F7C9739228F17131002C43E2 /* Intents.framework in Frameworks */,
 				F760DE072AE66EC70027D78A /* KeychainAccess in Frameworks */,
 				F760DE072AE66EC70027D78A /* KeychainAccess in Frameworks */,
@@ -2683,7 +2663,6 @@
 			name = "Notification Service Extension";
 			name = "Notification Service Extension";
 			packageProductDependencies = (
 			packageProductDependencies = (
 				F710FC87277B7D3F00AA9FBF /* RealmSwift */,
 				F710FC87277B7D3F00AA9FBF /* RealmSwift */,
-				F7EBCDD2277B821700A4EF67 /* UICKeyChainStore */,
 				F72AD71028C24BBB006CB92D /* NextcloudKit */,
 				F72AD71028C24BBB006CB92D /* NextcloudKit */,
 				F314F1102A30C11200BC7FAB /* PreviewSnapshots */,
 				F314F1102A30C11200BC7FAB /* PreviewSnapshots */,
 				F760DE0E2AE66EE60027D78A /* KeychainAccess */,
 				F760DE0E2AE66EE60027D78A /* KeychainAccess */,
@@ -2726,7 +2705,6 @@
 			name = NextcloudUITests;
 			name = NextcloudUITests;
 			packageProductDependencies = (
 			packageProductDependencies = (
 				C04E2F182A17BA78001BAD85 /* XLForm */,
 				C04E2F182A17BA78001BAD85 /* XLForm */,
-				C04E2F1A2A17BAAB001BAD85 /* UICKeyChainStore */,
 				F760DE142AE66F020027D78A /* KeychainAccess */,
 				F760DE142AE66F020027D78A /* KeychainAccess */,
 			);
 			);
 			productName = NextcloudUITests;
 			productName = NextcloudUITests;
@@ -2749,7 +2727,6 @@
 			name = NextcloudIntegrationTests;
 			name = NextcloudIntegrationTests;
 			packageProductDependencies = (
 			packageProductDependencies = (
 				C03BA1492A17BC57002C8BA3 /* XLForm */,
 				C03BA1492A17BC57002C8BA3 /* XLForm */,
-				C03BA14B2A17BC60002C8BA3 /* UICKeyChainStore */,
 				F30A96332A2DFCD000D7BCFE /* Realm */,
 				F30A96332A2DFCD000D7BCFE /* Realm */,
 				F30A96352A2DFCD000D7BCFE /* RealmSwift */,
 				F30A96352A2DFCD000D7BCFE /* RealmSwift */,
 				F30A96372A2DFD2900D7BCFE /* FirebaseDatabase */,
 				F30A96372A2DFD2900D7BCFE /* FirebaseDatabase */,
@@ -2781,7 +2758,6 @@
 				F31F69532A2F89C400162F76 /* SwiftRichString */,
 				F31F69532A2F89C400162F76 /* SwiftRichString */,
 				F31F69552A2F89C400162F76 /* FirebaseDatabase */,
 				F31F69552A2F89C400162F76 /* FirebaseDatabase */,
 				F31F69572A2F89C400162F76 /* XLForm */,
 				F31F69572A2F89C400162F76 /* XLForm */,
-				F31F69592A2F89C400162F76 /* UICKeyChainStore */,
 				F31F695B2A2F89C400162F76 /* Realm */,
 				F31F695B2A2F89C400162F76 /* Realm */,
 				F31F695D2A2F89C400162F76 /* JGProgressHUD */,
 				F31F695D2A2F89C400162F76 /* JGProgressHUD */,
 				F31F69652A2F929600162F76 /* PreviewSnapshotsTesting */,
 				F31F69652A2F929600162F76 /* PreviewSnapshotsTesting */,
@@ -2806,7 +2782,6 @@
 			);
 			);
 			name = "File Provider Extension UI";
 			name = "File Provider Extension UI";
 			packageProductDependencies = (
 			packageProductDependencies = (
-				F70716F829881CFA00E72C1D /* UICKeyChainStore */,
 				F7490E7129882BB4009DCE94 /* RealmSwift */,
 				F7490E7129882BB4009DCE94 /* RealmSwift */,
 				F7490E8829882CC8009DCE94 /* SwiftEntryKit */,
 				F7490E8829882CC8009DCE94 /* SwiftEntryKit */,
 				F7490E8A29882CE4009DCE94 /* NextcloudKit */,
 				F7490E8A29882CE4009DCE94 /* NextcloudKit */,
@@ -2833,7 +2808,6 @@
 				F72D7EB6263B1207000B3DFC /* MarkdownKit */,
 				F72D7EB6263B1207000B3DFC /* MarkdownKit */,
 				F73ADD2026554F8E0069EA0D /* SwiftEntryKit */,
 				F73ADD2026554F8E0069EA0D /* SwiftEntryKit */,
 				F710FC7F277B7D2700AA9FBF /* RealmSwift */,
 				F710FC7F277B7D2700AA9FBF /* RealmSwift */,
-				F7EBCDCE277B81FF00A4EF67 /* UICKeyChainStore */,
 				F72CD01127A7E92400E59476 /* JGProgressHUD */,
 				F72CD01127A7E92400E59476 /* JGProgressHUD */,
 				F72AD70E28C24BA1006CB92D /* NextcloudKit */,
 				F72AD70E28C24BA1006CB92D /* NextcloudKit */,
 				F70821D729E59E6D001CA2D7 /* TagListView */,
 				F70821D729E59E6D001CA2D7 /* TagListView */,
@@ -2860,7 +2834,6 @@
 			);
 			);
 			name = Widget;
 			name = Widget;
 			packageProductDependencies = (
 			packageProductDependencies = (
-				F7346E2428B0FEFA006CE2D2 /* UICKeyChainStore */,
 				F7346E2828B0FFF2006CE2D2 /* RealmSwift */,
 				F7346E2828B0FFF2006CE2D2 /* RealmSwift */,
 				F783030C28B4C59A00B84583 /* SwiftEntryKit */,
 				F783030C28B4C59A00B84583 /* SwiftEntryKit */,
 				F783034328B5142B00B84583 /* NextcloudKit */,
 				F783034328B5142B00B84583 /* NextcloudKit */,
@@ -2889,7 +2862,6 @@
 			packageProductDependencies = (
 			packageProductDependencies = (
 				F73ADD2326554FE20069EA0D /* SwiftEntryKit */,
 				F73ADD2326554FE20069EA0D /* SwiftEntryKit */,
 				F710FC83277B7D3500AA9FBF /* RealmSwift */,
 				F710FC83277B7D3500AA9FBF /* RealmSwift */,
-				F7EBCDD0277B820D00A4EF67 /* UICKeyChainStore */,
 				F72AD71228C24BCC006CB92D /* NextcloudKit */,
 				F72AD71228C24BCC006CB92D /* NextcloudKit */,
 				F7A560432AE15D2900BE8FD6 /* Queuer */,
 				F7A560432AE15D2900BE8FD6 /* Queuer */,
 				F753791F2AE2AD9400C0250E /* JGProgressHUD */,
 				F753791F2AE2AD9400C0250E /* JGProgressHUD */,
@@ -2932,7 +2904,6 @@
 				F75EAED726D2552E00F4320E /* MarqueeLabel */,
 				F75EAED726D2552E00F4320E /* MarqueeLabel */,
 				F74E771F277A2EF40013B958 /* XLForm */,
 				F74E771F277A2EF40013B958 /* XLForm */,
 				F76DA962277B760E0082465B /* Queuer */,
 				F76DA962277B760E0082465B /* Queuer */,
-				F76DA965277B76F30082465B /* UICKeyChainStore */,
 				F76DA968277B77EA0082465B /* DropDown */,
 				F76DA968277B77EA0082465B /* DropDown */,
 				F710FC79277B7D0000AA9FBF /* Realm */,
 				F710FC79277B7D0000AA9FBF /* Realm */,
 				F710FC7B277B7D0000AA9FBF /* RealmSwift */,
 				F710FC7B277B7D0000AA9FBF /* RealmSwift */,
@@ -2971,7 +2942,6 @@
 			packageProductDependencies = (
 			packageProductDependencies = (
 				F7A8D72328F1771B008BBE1C /* NextcloudKit */,
 				F7A8D72328F1771B008BBE1C /* NextcloudKit */,
 				F7A8D72728F17728008BBE1C /* RealmSwift */,
 				F7A8D72728F17728008BBE1C /* RealmSwift */,
-				F7A8D72D28F17764008BBE1C /* UICKeyChainStore */,
 				F760DE062AE66EC70027D78A /* KeychainAccess */,
 				F760DE062AE66EC70027D78A /* KeychainAccess */,
 			);
 			);
 			productName = WidgetDashboardIntentHandler;
 			productName = WidgetDashboardIntentHandler;
@@ -3110,7 +3080,6 @@
 				F75EAED626D2552E00F4320E /* XCRemoteSwiftPackageReference "MarqueeLabel" */,
 				F75EAED626D2552E00F4320E /* XCRemoteSwiftPackageReference "MarqueeLabel" */,
 				F74E771E277A2EF40013B958 /* XCRemoteSwiftPackageReference "XLForm" */,
 				F74E771E277A2EF40013B958 /* XCRemoteSwiftPackageReference "XLForm" */,
 				F76DA961277B760E0082465B /* XCRemoteSwiftPackageReference "Queuer" */,
 				F76DA961277B760E0082465B /* XCRemoteSwiftPackageReference "Queuer" */,
-				F76DA964277B76F10082465B /* XCRemoteSwiftPackageReference "UICKeyChainStore" */,
 				F76DA967277B77E90082465B /* XCRemoteSwiftPackageReference "DropDown" */,
 				F76DA967277B77E90082465B /* XCRemoteSwiftPackageReference "DropDown" */,
 				F710FC78277B7CFF00AA9FBF /* XCRemoteSwiftPackageReference "realm-swift" */,
 				F710FC78277B7CFF00AA9FBF /* XCRemoteSwiftPackageReference "realm-swift" */,
 				F7BB7E4527A18C56009B9F29 /* XCRemoteSwiftPackageReference "Parchment" */,
 				F7BB7E4527A18C56009B9F29 /* XCRemoteSwiftPackageReference "Parchment" */,
@@ -4744,7 +4713,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 5;
+				CURRENT_PROJECT_VERSION = 6;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -4809,7 +4778,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 5;
+				CURRENT_PROJECT_VERSION = 6;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_TESTABILITY = YES;
 				ENABLE_TESTABILITY = YES;
@@ -5087,14 +5056,6 @@
 				minimumVersion = 2.0.0;
 				minimumVersion = 2.0.0;
 			};
 			};
 		};
 		};
-		F76DA964277B76F10082465B /* XCRemoteSwiftPackageReference "UICKeyChainStore" */ = {
-			isa = XCRemoteSwiftPackageReference;
-			repositoryURL = "https://github.com/kishikawakatsumi/UICKeyChainStore";
-			requirement = {
-				branch = master;
-				kind = branch;
-			};
-		};
 		F76DA967277B77E90082465B /* XCRemoteSwiftPackageReference "DropDown" */ = {
 		F76DA967277B77E90082465B /* XCRemoteSwiftPackageReference "DropDown" */ = {
 			isa = XCRemoteSwiftPackageReference;
 			isa = XCRemoteSwiftPackageReference;
 			repositoryURL = "https://github.com/AssistoLab/DropDown";
 			repositoryURL = "https://github.com/AssistoLab/DropDown";
@@ -5131,8 +5092,8 @@
 			isa = XCRemoteSwiftPackageReference;
 			isa = XCRemoteSwiftPackageReference;
 			repositoryURL = "https://github.com/nextcloud/NextcloudKit";
 			repositoryURL = "https://github.com/nextcloud/NextcloudKit";
 			requirement = {
 			requirement = {
-				branch = develop;
-				kind = branch;
+				kind = exactVersion;
+				version = 2.9.0;
 			};
 			};
 		};
 		};
 		F788ECC5263AAAF900ADC67F /* XCRemoteSwiftPackageReference "MarkdownKit" */ = {
 		F788ECC5263AAAF900ADC67F /* XCRemoteSwiftPackageReference "MarkdownKit" */ = {
@@ -5191,21 +5152,11 @@
 			package = F74E771E277A2EF40013B958 /* XCRemoteSwiftPackageReference "XLForm" */;
 			package = F74E771E277A2EF40013B958 /* XCRemoteSwiftPackageReference "XLForm" */;
 			productName = XLForm;
 			productName = XLForm;
 		};
 		};
-		C03BA14B2A17BC60002C8BA3 /* UICKeyChainStore */ = {
-			isa = XCSwiftPackageProductDependency;
-			package = F76DA964277B76F10082465B /* XCRemoteSwiftPackageReference "UICKeyChainStore" */;
-			productName = UICKeyChainStore;
-		};
 		C04E2F182A17BA78001BAD85 /* XLForm */ = {
 		C04E2F182A17BA78001BAD85 /* XLForm */ = {
 			isa = XCSwiftPackageProductDependency;
 			isa = XCSwiftPackageProductDependency;
 			package = F74E771E277A2EF40013B958 /* XCRemoteSwiftPackageReference "XLForm" */;
 			package = F74E771E277A2EF40013B958 /* XCRemoteSwiftPackageReference "XLForm" */;
 			productName = XLForm;
 			productName = XLForm;
 		};
 		};
-		C04E2F1A2A17BAAB001BAD85 /* UICKeyChainStore */ = {
-			isa = XCSwiftPackageProductDependency;
-			package = F76DA964277B76F10082465B /* XCRemoteSwiftPackageReference "UICKeyChainStore" */;
-			productName = UICKeyChainStore;
-		};
 		F30A96332A2DFCD000D7BCFE /* Realm */ = {
 		F30A96332A2DFCD000D7BCFE /* Realm */ = {
 			isa = XCSwiftPackageProductDependency;
 			isa = XCSwiftPackageProductDependency;
 			package = F710FC78277B7CFF00AA9FBF /* XCRemoteSwiftPackageReference "realm-swift" */;
 			package = F710FC78277B7CFF00AA9FBF /* XCRemoteSwiftPackageReference "realm-swift" */;
@@ -5261,11 +5212,6 @@
 			package = F74E771E277A2EF40013B958 /* XCRemoteSwiftPackageReference "XLForm" */;
 			package = F74E771E277A2EF40013B958 /* XCRemoteSwiftPackageReference "XLForm" */;
 			productName = XLForm;
 			productName = XLForm;
 		};
 		};
-		F31F69592A2F89C400162F76 /* UICKeyChainStore */ = {
-			isa = XCSwiftPackageProductDependency;
-			package = F76DA964277B76F10082465B /* XCRemoteSwiftPackageReference "UICKeyChainStore" */;
-			productName = UICKeyChainStore;
-		};
 		F31F695B2A2F89C400162F76 /* Realm */ = {
 		F31F695B2A2F89C400162F76 /* Realm */ = {
 			isa = XCSwiftPackageProductDependency;
 			isa = XCSwiftPackageProductDependency;
 			package = F710FC78277B7CFF00AA9FBF /* XCRemoteSwiftPackageReference "realm-swift" */;
 			package = F710FC78277B7CFF00AA9FBF /* XCRemoteSwiftPackageReference "realm-swift" */;
@@ -5291,11 +5237,6 @@
 			package = F31F69672A2F92F000162F76 /* XCRemoteSwiftPackageReference "SnapshotTestingHEIC" */;
 			package = F31F69672A2F92F000162F76 /* XCRemoteSwiftPackageReference "SnapshotTestingHEIC" */;
 			productName = SnapshotTestingHEIC;
 			productName = SnapshotTestingHEIC;
 		};
 		};
-		F70716F829881CFA00E72C1D /* UICKeyChainStore */ = {
-			isa = XCSwiftPackageProductDependency;
-			package = F76DA964277B76F10082465B /* XCRemoteSwiftPackageReference "UICKeyChainStore" */;
-			productName = UICKeyChainStore;
-		};
 		F70821D729E59E6D001CA2D7 /* TagListView */ = {
 		F70821D729E59E6D001CA2D7 /* TagListView */ = {
 			isa = XCSwiftPackageProductDependency;
 			isa = XCSwiftPackageProductDependency;
 			package = F7A1050C29E587AF00FFD92B /* XCRemoteSwiftPackageReference "TagListView" */;
 			package = F7A1050C29E587AF00FFD92B /* XCRemoteSwiftPackageReference "TagListView" */;
@@ -5366,11 +5307,6 @@
 			package = F72DA9B225F53E4E00B87DB1 /* XCRemoteSwiftPackageReference "SwiftRichString" */;
 			package = F72DA9B225F53E4E00B87DB1 /* XCRemoteSwiftPackageReference "SwiftRichString" */;
 			productName = SwiftRichString;
 			productName = SwiftRichString;
 		};
 		};
-		F7346E2428B0FEFA006CE2D2 /* UICKeyChainStore */ = {
-			isa = XCSwiftPackageProductDependency;
-			package = F76DA964277B76F10082465B /* XCRemoteSwiftPackageReference "UICKeyChainStore" */;
-			productName = UICKeyChainStore;
-		};
 		F7346E2828B0FFF2006CE2D2 /* RealmSwift */ = {
 		F7346E2828B0FFF2006CE2D2 /* RealmSwift */ = {
 			isa = XCSwiftPackageProductDependency;
 			isa = XCSwiftPackageProductDependency;
 			package = F710FC78277B7CFF00AA9FBF /* XCRemoteSwiftPackageReference "realm-swift" */;
 			package = F710FC78277B7CFF00AA9FBF /* XCRemoteSwiftPackageReference "realm-swift" */;
@@ -5501,11 +5437,6 @@
 			package = F76DA961277B760E0082465B /* XCRemoteSwiftPackageReference "Queuer" */;
 			package = F76DA961277B760E0082465B /* XCRemoteSwiftPackageReference "Queuer" */;
 			productName = Queuer;
 			productName = Queuer;
 		};
 		};
-		F76DA965277B76F30082465B /* UICKeyChainStore */ = {
-			isa = XCSwiftPackageProductDependency;
-			package = F76DA964277B76F10082465B /* XCRemoteSwiftPackageReference "UICKeyChainStore" */;
-			productName = UICKeyChainStore;
-		};
 		F76DA968277B77EA0082465B /* DropDown */ = {
 		F76DA968277B77EA0082465B /* DropDown */ = {
 			isa = XCSwiftPackageProductDependency;
 			isa = XCSwiftPackageProductDependency;
 			package = F76DA967277B77E90082465B /* XCRemoteSwiftPackageReference "DropDown" */;
 			package = F76DA967277B77E90082465B /* XCRemoteSwiftPackageReference "DropDown" */;
@@ -5586,11 +5517,6 @@
 			package = F710FC78277B7CFF00AA9FBF /* XCRemoteSwiftPackageReference "realm-swift" */;
 			package = F710FC78277B7CFF00AA9FBF /* XCRemoteSwiftPackageReference "realm-swift" */;
 			productName = RealmSwift;
 			productName = RealmSwift;
 		};
 		};
-		F7A8D72D28F17764008BBE1C /* UICKeyChainStore */ = {
-			isa = XCSwiftPackageProductDependency;
-			package = F76DA964277B76F10082465B /* XCRemoteSwiftPackageReference "UICKeyChainStore" */;
-			productName = UICKeyChainStore;
-		};
 		F7BB7E4627A18C56009B9F29 /* Parchment */ = {
 		F7BB7E4627A18C56009B9F29 /* Parchment */ = {
 			isa = XCSwiftPackageProductDependency;
 			isa = XCSwiftPackageProductDependency;
 			package = F7BB7E4527A18C56009B9F29 /* XCRemoteSwiftPackageReference "Parchment" */;
 			package = F7BB7E4527A18C56009B9F29 /* XCRemoteSwiftPackageReference "Parchment" */;
@@ -5601,21 +5527,6 @@
 			package = F7D56B182972405400FA46C4 /* XCRemoteSwiftPackageReference "Mantis" */;
 			package = F7D56B182972405400FA46C4 /* XCRemoteSwiftPackageReference "Mantis" */;
 			productName = Mantis;
 			productName = Mantis;
 		};
 		};
-		F7EBCDCE277B81FF00A4EF67 /* UICKeyChainStore */ = {
-			isa = XCSwiftPackageProductDependency;
-			package = F76DA964277B76F10082465B /* XCRemoteSwiftPackageReference "UICKeyChainStore" */;
-			productName = UICKeyChainStore;
-		};
-		F7EBCDD0277B820D00A4EF67 /* UICKeyChainStore */ = {
-			isa = XCSwiftPackageProductDependency;
-			package = F76DA964277B76F10082465B /* XCRemoteSwiftPackageReference "UICKeyChainStore" */;
-			productName = UICKeyChainStore;
-		};
-		F7EBCDD2277B821700A4EF67 /* UICKeyChainStore */ = {
-			isa = XCSwiftPackageProductDependency;
-			package = F76DA964277B76F10082465B /* XCRemoteSwiftPackageReference "UICKeyChainStore" */;
-			productName = UICKeyChainStore;
-		};
 		F7ED547B25EEA65400956C55 /* QRCodeReader */ = {
 		F7ED547B25EEA65400956C55 /* QRCodeReader */ = {
 			isa = XCSwiftPackageProductDependency;
 			isa = XCSwiftPackageProductDependency;
 			package = F7ED547A25EEA65400956C55 /* XCRemoteSwiftPackageReference "QRCodeReader" */;
 			package = F7ED547A25EEA65400956C55 /* XCRemoteSwiftPackageReference "QRCodeReader" */;

+ 1 - 1
Notification Service Extension/NotificationService.swift

@@ -38,7 +38,7 @@ class NotificationService: UNNotificationServiceExtension {
                 if let message = bestAttemptContent.userInfo["subject"] as? String {
                 if let message = bestAttemptContent.userInfo["subject"] as? String {
                     let tableAccounts = NCManageDatabase.shared.getAllAccount()
                     let tableAccounts = NCManageDatabase.shared.getAllAccount()
                     for tableAccount in tableAccounts {
                     for tableAccount in tableAccounts {
-                        guard let privateKey = CCUtility.getPushNotificationPrivateKey(tableAccount.account),
+                        guard let privateKey = NCKeychain().getPushNotificationPrivateKey(account: tableAccount.account),
                               let decryptedMessage = NCPushNotificationEncryption.shared().decryptPushNotification(message, withDevicePrivateKey: privateKey),
                               let decryptedMessage = NCPushNotificationEncryption.shared().decryptPushNotification(message, withDevicePrivateKey: privateKey),
                               let data = decryptedMessage.data(using: .utf8) else {
                               let data = decryptedMessage.data(using: .utf8) else {
                             continue
                             continue

+ 1 - 1
Share/NCShareCell.swift

@@ -59,7 +59,7 @@ class NCShareCell: UITableViewCell {
         fileNameCell?.text = fileName
         fileNameCell?.text = fileName
 
 
         let fileSize = NCUtilityFileSystem.shared.getFileSize(filePath: (NSTemporaryDirectory() + fileName))
         let fileSize = NCUtilityFileSystem.shared.getFileSize(filePath: (NSTemporaryDirectory() + fileName))
-        sizeCell?.text = CCUtility.transformedSize(fileSize)
+        sizeCell?.text = NCUtilityFileSystem.shared.transformedSize(fileSize)
 
 
         moreButton?.setImage(NCUtility.shared.loadImage(named: "more").image(color: .label, size: 15), for: .normal)
         moreButton?.setImage(NCUtility.shared.loadImage(named: "more").image(color: .label, size: 15), for: .normal)
     }
     }

+ 4 - 7
Share/NCShareExtension+DataSource.swift

@@ -29,12 +29,9 @@ import NextcloudKit
 extension NCShareExtension: UICollectionViewDelegate {
 extension NCShareExtension: UICollectionViewDelegate {
 
 
     func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
     func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
-        guard let metadata = dataSource.cellForItemAt(indexPath: indexPath),
-              let serverUrl = CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName) else {
-                  return showAlert(description: "_invalid_url_")
-              }
-
-        if metadata.e2eEncrypted && !CCUtility.isEnd(toEndEnabled: activeAccount.account) {
+        guard let metadata = dataSource.cellForItemAt(indexPath: indexPath) else { return showAlert(description: "_invalid_url_") }
+        let serverUrl = NCUtilityFileSystem.shared.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName)
+        if metadata.e2eEncrypted && !NCKeychain().isEndToEndEnabled(account: activeAccount.account) {
             showAlert(title: "_info_", description: "_e2e_goto_settings_for_enable_")
             showAlert(title: "_info_", description: "_e2e_goto_settings_for_enable_")
         }
         }
 
 
@@ -138,7 +135,7 @@ extension NCShareExtension: UICollectionViewDataSource {
 
 
         cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date)
         cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date)
 
 
-        let lockServerUrl = CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName)!
+        let lockServerUrl = NCUtilityFileSystem.shared.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName)
         let tableDirectory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", activeAccount.account, lockServerUrl))
         let tableDirectory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", activeAccount.account, lockServerUrl))
 
 
         // Local image: offline
         // Local image: offline

+ 3 - 2
Share/NCShareExtension+Files.swift

@@ -99,7 +99,7 @@ class NCFilesExtensionHandler {
 
 
     @discardableResult
     @discardableResult
     init(items: [NSExtensionItem], completion: @escaping ([String]) -> Void) {
     init(items: [NSExtensionItem], completion: @escaping ([String]) -> Void) {
-        CCUtility.emptyTemporaryDirectory()
+        NCUtilityFileSystem.shared.emptyTemporaryDirectory()
         var counter = 0
         var counter = 0
 
 
         self.itemsProvider = items.compactMap({ $0.attachments }).flatMap { $0.filter({
         self.itemsProvider = items.compactMap({ $0.attachments }).flatMap { $0.filter({
@@ -118,7 +118,8 @@ class NCFilesExtensionHandler {
                 if let url = item as? URL, url.isFileURL, !url.lastPathComponent.isEmpty {
                 if let url = item as? URL, url.isFileURL, !url.lastPathComponent.isEmpty {
                     originalName = url.lastPathComponent
                     originalName = url.lastPathComponent
 
 
-                    if fileNames.contains(originalName), let incrementalNumber = CCUtility.getIncrementalNumber() {
+                    if fileNames.contains(originalName) {
+                        let incrementalNumber = NCKeychain().incrementalNumber
                         originalName = "\(url.deletingPathExtension().lastPathComponent) \(incrementalNumber).\(url.pathExtension)"
                         originalName = "\(url.deletingPathExtension().lastPathComponent) \(incrementalNumber).\(url.pathExtension)"
                     }
                     }
                 }
                 }

+ 1 - 1
Share/NCShareExtension+NCDelegate.swift

@@ -88,7 +88,7 @@ extension NCShareExtension: NCEmptyDataSetDelegate, NCAccountRequestDelegate {
             account: activeAccount.account,
             account: activeAccount.account,
             user: activeAccount.user,
             user: activeAccount.user,
             userId: activeAccount.userId,
             userId: activeAccount.userId,
-            password: CCUtility.getPassword(activeAccount.account),
+            password: NCKeychain().getPassword(account: activeAccount.account),
             urlBase: activeAccount.urlBase,
             urlBase: activeAccount.urlBase,
             userAgent: userAgent,
             userAgent: userAgent,
             nextcloudVersion: 0,
             nextcloudVersion: 0,

+ 4 - 7
Share/NCShareExtension.swift

@@ -111,14 +111,12 @@ class NCShareExtension: UIViewController {
         uploadView.addGestureRecognizer(uploadGesture)
         uploadView.addGestureRecognizer(uploadGesture)
 
 
         // LOG
         // LOG
-        let levelLog = CCUtility.getLogLevel()
+        let levelLog = NCKeychain().logLevel
         let isSimulatorOrTestFlight = NCUtility.shared.isSimulatorOrTestFlight()
         let isSimulatorOrTestFlight = NCUtility.shared.isSimulatorOrTestFlight()
         let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp())
         let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp())
 
 
         NextcloudKit.shared.nkCommonInstance.levelLog = levelLog
         NextcloudKit.shared.nkCommonInstance.levelLog = levelLog
-        if let pathDirectoryGroup = CCUtility.getDirectoryGroup()?.path {
-            NextcloudKit.shared.nkCommonInstance.pathLog = pathDirectoryGroup
-        }
+        NextcloudKit.shared.nkCommonInstance.pathLog = NCUtilityFileSystem.shared.directoryGroup
         if isSimulatorOrTestFlight {
         if isSimulatorOrTestFlight {
             NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Start Share session with level \(levelLog) " + versionNextcloudiOS + " (Simulator / TestFlight)")
             NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Start Share session with level \(levelLog) " + versionNextcloudiOS + " (Simulator / TestFlight)")
         } else {
         } else {
@@ -297,7 +295,7 @@ extension NCShareExtension {
         var conflicts: [tableMetadata] = []
         var conflicts: [tableMetadata] = []
         for fileName in filesName {
         for fileName in filesName {
             let ocId = NSUUID().uuidString
             let ocId = NSUUID().uuidString
-            let toPath = CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileName)!
+            let toPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId, fileNameView: fileName)
             guard NCUtilityFileSystem.shared.copyFile(atPath: (NSTemporaryDirectory() + fileName), toPath: toPath) else { continue }
             guard NCUtilityFileSystem.shared.copyFile(atPath: (NSTemporaryDirectory() + fileName), toPath: toPath) else { continue }
             let metadata = NCManageDatabase.shared.createMetadata(
             let metadata = NCManageDatabase.shared.createMetadata(
                 account: activeAccount.account, user: activeAccount.user, userId: activeAccount.userId,
                 account: activeAccount.account, user: activeAccount.user, userId: activeAccount.userId,
@@ -358,9 +356,8 @@ extension NCShareExtension {
             self.hud.progress = Float(fractionCompleted)
             self.hud.progress = Float(fractionCompleted)
         } completion: { error in
         } completion: { error in
             if error != .success {
             if error != .success {
-                let path = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId)!
                 NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                 NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
-                NCUtilityFileSystem.shared.deleteFile(filePath: path)
+                NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId))
                 self.uploadErrors.append(metadata)
                 self.uploadErrors.append(metadata)
             }
             }
             self.counterUploaded += 1
             self.counterUploaded += 1

+ 7 - 9
Widget/Dashboard/DashboardData.swift

@@ -90,7 +90,7 @@ func convertDataToImage(data: Data?, size: CGSize, fileNameToWrite: String?) ->
     }
     }
     if let fileName = fileNameToWrite, let image = imageData {
     if let fileName = fileNameToWrite, let image = imageData {
         do {
         do {
-            let fileNamePath: String = CCUtility.getDirectoryUserData() + "/" + fileName + ".png"
+            let fileNamePath: String = NCUtilityFileSystem.shared.directoryUserData + "/" + fileName + ".png"
             try image.pngData()?.write(to: URL(fileURLWithPath: fileNamePath), options: .atomic)
             try image.pngData()?.write(to: URL(fileURLWithPath: fileNamePath), options: .atomic)
         } catch { }
         } catch { }
     }
     }
@@ -130,7 +130,7 @@ func getDashboardDataEntry(configuration: DashboardIntent?, isPreview: Bool, dis
     }
     }
 
 
     // NETWORKING
     // NETWORKING
-    let password = CCUtility.getPassword(account.account)!
+    let password = NCKeychain().getPassword(account: account.account)
     NextcloudKit.shared.setup(
     NextcloudKit.shared.setup(
         account: account.account,
         account: account.account,
         user: account.user,
         user: account.user,
@@ -142,14 +142,12 @@ func getDashboardDataEntry(configuration: DashboardIntent?, isPreview: Bool, dis
         delegate: NCNetworking.shared)
         delegate: NCNetworking.shared)
 
 
     // LOG
     // LOG
-    let levelLog = CCUtility.getLogLevel()
+    let levelLog = NCKeychain().logLevel
     let isSimulatorOrTestFlight = NCUtility.shared.isSimulatorOrTestFlight()
     let isSimulatorOrTestFlight = NCUtility.shared.isSimulatorOrTestFlight()
     let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp())
     let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp())
 
 
     NextcloudKit.shared.nkCommonInstance.levelLog = levelLog
     NextcloudKit.shared.nkCommonInstance.levelLog = levelLog
-    if let pathDirectoryGroup = CCUtility.getDirectoryGroup()?.path {
-        NextcloudKit.shared.nkCommonInstance.pathLog = pathDirectoryGroup
-    }
+    NextcloudKit.shared.nkCommonInstance.pathLog = NCUtilityFileSystem.shared.directoryGroup
     if isSimulatorOrTestFlight {
     if isSimulatorOrTestFlight {
         NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Start \(NCBrandOptions.shared.brand) dashboard widget session with level \(levelLog) " + versionNextcloudiOS + " (Simulator / TestFlight)")
         NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Start \(NCBrandOptions.shared.brand) dashboard widget session with level \(levelLog) " + versionNextcloudiOS + " (Simulator / TestFlight)")
     } else {
     } else {
@@ -162,7 +160,7 @@ func getDashboardDataEntry(configuration: DashboardIntent?, isPreview: Bool, dis
 
 
     var imagetmp = UIImage(named: "widget")!
     var imagetmp = UIImage(named: "widget")!
     if let fileName = tableDashboard?.iconClass {
     if let fileName = tableDashboard?.iconClass {
-        let fileNamePath: String = CCUtility.getDirectoryUserData() + "/" + fileName + ".png"
+        let fileNamePath: String = NCUtilityFileSystem.shared.directoryUserData + "/" + fileName + ".png"
         if let image = UIImage(contentsOfFile: fileNamePath) {
         if let image = UIImage(contentsOfFile: fileNamePath) {
             imagetmp = image.withTintColor(.label, renderingMode: .alwaysOriginal)
             imagetmp = image.withTintColor(.label, renderingMode: .alwaysOriginal)
         }
         }
@@ -206,7 +204,7 @@ func getDashboardDataEntry(configuration: DashboardIntent?, isPreview: Bool, dis
                                     if (pathComponents.last as? NSString)?.pathExtension.lowercased() == "svg" {
                                     if (pathComponents.last as? NSString)?.pathExtension.lowercased() == "svg" {
                                         imageTemplate = true
                                         imageTemplate = true
                                     }
                                     }
-                                    if let item = CCUtility.value(forKey: "fileId", fromQueryItems: queryItems) {
+                                    if let item = queryItems?.filter({ $0.name == "fileId" }).first?.value {
                                         iconFileName = item
                                         iconFileName = item
                                     } else if pathComponents.contains("avatar") {
                                     } else if pathComponents.contains("avatar") {
                                         iconFileName = pathComponents[pathComponents.count - 2]
                                         iconFileName = pathComponents[pathComponents.count - 2]
@@ -224,7 +222,7 @@ func getDashboardDataEntry(configuration: DashboardIntent?, isPreview: Bool, dis
                                     imageColor = UIColor(hex: colorString)
                                     imageColor = UIColor(hex: colorString)
                                     icon = UIImage(systemName: "circle.fill")!
                                     icon = UIImage(systemName: "circle.fill")!
                                 } else if let fileName = iconFileName {
                                 } else if let fileName = iconFileName {
-                                    let fileNamePath: String = CCUtility.getDirectoryUserData() + "/" + fileName + ".png"
+                                    let fileNamePath: String = NCUtilityFileSystem.shared.directoryUserData + "/" + fileName + ".png"
                                     if FileManager().fileExists(atPath: fileNamePath), let image = UIImage(contentsOfFile: fileNamePath) {
                                     if FileManager().fileExists(atPath: fileNamePath), let image = UIImage(contentsOfFile: fileNamePath) {
                                         icon = image
                                         icon = image
                                     } else {
                                     } else {

+ 9 - 10
Widget/Files/FilesData.swift

@@ -124,7 +124,7 @@ func getFilesDataEntry(configuration: AccountIntent?, isPreview: Bool, displaySi
     }
     }
 
 
     // NETWORKING
     // NETWORKING
-    let password = CCUtility.getPassword(account.account)!
+    let password = NCKeychain().getPassword(account: account.account)
     NextcloudKit.shared.setup(
     NextcloudKit.shared.setup(
         account: account.account,
         account: account.account,
         user: account.user,
         user: account.user,
@@ -192,14 +192,13 @@ func getFilesDataEntry(configuration: AccountIntent?, isPreview: Bool, displaySi
     let requestBody = String(format: requestBodyRecent, "/files/" + account.userId, lessDateString)
     let requestBody = String(format: requestBodyRecent, "/files/" + account.userId, lessDateString)
 
 
     // LOG
     // LOG
-    let levelLog = CCUtility.getLogLevel()
+    let levelLog = NCKeychain().logLevel
     let isSimulatorOrTestFlight = NCUtility.shared.isSimulatorOrTestFlight()
     let isSimulatorOrTestFlight = NCUtility.shared.isSimulatorOrTestFlight()
     let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp())
     let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp())
 
 
     NextcloudKit.shared.nkCommonInstance.levelLog = levelLog
     NextcloudKit.shared.nkCommonInstance.levelLog = levelLog
-    if let pathDirectoryGroup = CCUtility.getDirectoryGroup()?.path {
-        NextcloudKit.shared.nkCommonInstance.pathLog = pathDirectoryGroup
-    }
+    NextcloudKit.shared.nkCommonInstance.pathLog = NCUtilityFileSystem.shared.directoryGroup
+
     if isSimulatorOrTestFlight {
     if isSimulatorOrTestFlight {
         NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Start \(NCBrandOptions.shared.brand) widget session with level \(levelLog) " + versionNextcloudiOS + " (Simulator / TestFlight)")
         NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Start \(NCBrandOptions.shared.brand) widget session with level \(levelLog) " + versionNextcloudiOS + " (Simulator / TestFlight)")
     } else {
     } else {
@@ -207,7 +206,7 @@ func getFilesDataEntry(configuration: AccountIntent?, isPreview: Bool, displaySi
     }
     }
 
 
     let options = NKRequestOptions(timeout: 90, queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)
     let options = NKRequestOptions(timeout: 90, queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)
-    NextcloudKit.shared.searchBodyRequest(serverUrl: account.urlBase, requestBody: requestBody, showHiddenFiles: CCUtility.getShowHiddenFiles(), options: options) { _, files, data, error in
+    NextcloudKit.shared.searchBodyRequest(serverUrl: account.urlBase, requestBody: requestBody, showHiddenFiles: NCKeychain().showHiddenFiles, options: options) { _, files, data, error in
         Task {
         Task {
             var datas: [FilesData] = []
             var datas: [FilesData] = []
             var imageRecent = UIImage(named: "file")!
             var imageRecent = UIImage(named: "file")!
@@ -219,7 +218,7 @@ func getFilesDataEntry(configuration: AccountIntent?, isPreview: Bool, displaySi
                 guard !isLive(file: file, files: files) else { continue }
                 guard !isLive(file: file, files: files) else { continue }
 
 
                 // SUBTITLE
                 // SUBTITLE
-                let subTitle = CCUtility.dateDiff(file.date as Date) + " · " + CCUtility.transformedSize(file.size)
+                let subTitle = CCUtility.dateDiff(file.date as Date) + " · " + NCUtilityFileSystem.shared.transformedSize(file.size)
 
 
                 // URL: nextcloud://open-file?path=Talk/IMG_0000123.jpg&user=marinofaggiana&link=https://cloud.nextcloud.com/f/123
                 // URL: nextcloud://open-file?path=Talk/IMG_0000123.jpg&user=marinofaggiana&link=https://cloud.nextcloud.com/f/123
                 guard var path = NCUtilityFileSystem.shared.getPath(path: file.path, user: file.user, fileName: file.fileName).urlEncoded else { continue }
                 guard var path = NCUtilityFileSystem.shared.getPath(path: file.path, user: file.user, fileName: file.fileName).urlEncoded else { continue }
@@ -236,9 +235,9 @@ func getFilesDataEntry(configuration: AccountIntent?, isPreview: Bool, displaySi
                 if let image = NCUtility.shared.createFilePreviewImage(ocId: file.ocId, etag: file.etag, fileNameView: file.fileName, classFile: file.classFile, status: 0, createPreviewMedia: false) {
                 if let image = NCUtility.shared.createFilePreviewImage(ocId: file.ocId, etag: file.etag, fileNameView: file.fileName, classFile: file.classFile, status: 0, createPreviewMedia: false) {
                     imageRecent = image
                     imageRecent = image
                 } else if file.hasPreview {
                 } else if file.hasPreview {
-                    let fileNamePathOrFileId = CCUtility.returnFileNamePath(fromFileName: file.fileName, serverUrl: file.serverUrl, urlBase: file.urlBase, userId: file.userId, account: account.account)!
-                    let fileNamePreviewLocalPath = CCUtility.getDirectoryProviderStoragePreviewOcId(file.ocId, etag: file.etag)!
-                    let fileNameIconLocalPath = CCUtility.getDirectoryProviderStorageIconOcId(file.ocId, etag: file.etag)!
+                    let fileNamePathOrFileId = NCUtilityFileSystem.shared.getFileNamePath(file.fileName, serverUrl: file.serverUrl, urlBase: file.urlBase, userId: file.userId)
+                    let fileNamePreviewLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStoragePreviewOcId(file.ocId, etag: file.etag)
+                    let fileNameIconLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(file.ocId, etag: file.etag)
                     let (_, _, imageIcon, _, _, _) = await NextcloudKit.shared.downloadPreview(fileNamePathOrFileId: fileNamePathOrFileId, fileNamePreviewLocalPath: fileNamePreviewLocalPath, widthPreview: NCGlobal.shared.sizePreview, heightPreview: NCGlobal.shared.sizePreview, fileNameIconLocalPath: fileNameIconLocalPath, sizeIcon: NCGlobal.shared.sizeIcon, options: options)
                     let (_, _, imageIcon, _, _, _) = await NextcloudKit.shared.downloadPreview(fileNamePathOrFileId: fileNamePathOrFileId, fileNamePreviewLocalPath: fileNamePreviewLocalPath, widthPreview: NCGlobal.shared.sizePreview, heightPreview: NCGlobal.shared.sizePreview, fileNameIconLocalPath: fileNameIconLocalPath, sizeIcon: NCGlobal.shared.sizeIcon, options: options)
                     if let image = imageIcon {
                     if let image = imageIcon {
                         imageRecent = image
                         imageRecent = image

+ 3 - 3
Widget/Lockscreen/LockscreenData.swift

@@ -63,7 +63,7 @@ func getLockscreenDataEntry(configuration: AccountIntent?, isPreview: Bool, fami
     }
     }
 
 
     // NETWORKING
     // NETWORKING
-    let password = CCUtility.getPassword(account.account)!
+    let password = NCKeychain().getPassword(account: account.account)
     NextcloudKit.shared.setup(
     NextcloudKit.shared.setup(
         account: account.account,
         account: account.account,
         user: account.user,
         user: account.user,
@@ -82,7 +82,7 @@ func getLockscreenDataEntry(configuration: AccountIntent?, isPreview: Bool, fami
                     if userProfile.quotaRelative > 0 {
                     if userProfile.quotaRelative > 0 {
                         quotaRelative = Float(userProfile.quotaRelative) / 100
                         quotaRelative = Float(userProfile.quotaRelative) / 100
                     }
                     }
-                    let quotaUsed: String = CCUtility.transformedSize(userProfile.quotaUsed)
+                    let quotaUsed: String = NCUtilityFileSystem.shared.transformedSize(userProfile.quotaUsed)
                     var quotaTotal: String = ""
                     var quotaTotal: String = ""
 
 
                     switch userProfile.quotaTotal {
                     switch userProfile.quotaTotal {
@@ -93,7 +93,7 @@ func getLockscreenDataEntry(configuration: AccountIntent?, isPreview: Bool, fami
                     case -3:
                     case -3:
                         quotaTotal = ""
                         quotaTotal = ""
                     default:
                     default:
-                        quotaTotal = CCUtility.transformedSize(userProfile.quotaTotal)
+                        quotaTotal = NCUtilityFileSystem.shared.transformedSize(userProfile.quotaTotal)
                     }
                     }
                     completion(LockscreenData(date: Date(), isPlaceholder: false, activity: "", link: URL(string: "https://")!, quotaRelative: quotaRelative, quotaUsed: quotaUsed, quotaTotal: quotaTotal, error: false))
                     completion(LockscreenData(date: Date(), isPlaceholder: false, activity: "", link: URL(string: "https://")!, quotaRelative: quotaRelative, quotaUsed: quotaUsed, quotaTotal: quotaTotal, error: false))
                 } else {
                 } else {

+ 2 - 4
iOSClient/Activity/NCActivity.swift

@@ -39,9 +39,7 @@ class NCActivity: UIViewController, NCSharePagingContent {
     var metadata: tableMetadata?
     var metadata: tableMetadata?
     var showComments: Bool = false
     var showComments: Bool = false
 
 
-    // swiftlint:disable force_cast
-    private let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
 
 
     var allItems: [DateCompareable] = []
     var allItems: [DateCompareable] = []
     var sectionDates: [Date] = []
     var sectionDates: [Date] = []
@@ -252,7 +250,7 @@ extension NCActivity: UITableViewDataSource {
         if !activity.icon.isEmpty {
         if !activity.icon.isEmpty {
 
 
             let fileNameIcon = (activity.icon as NSString).lastPathComponent
             let fileNameIcon = (activity.icon as NSString).lastPathComponent
-            let fileNameLocalPath = CCUtility.getDirectoryUserData() + "/" + fileNameIcon
+            let fileNameLocalPath = NCUtilityFileSystem.shared.directoryUserData + "/" + fileNameIcon
 
 
             if FileManager.default.fileExists(atPath: fileNameLocalPath) {
             if FileManager.default.fileExists(atPath: fileNameLocalPath) {
                 if let image = UIImage(contentsOfFile: fileNameLocalPath) {
                 if let image = UIImage(contentsOfFile: fileNameLocalPath) {

+ 1 - 1
iOSClient/Activity/NCActivityCommentView.swift

@@ -36,7 +36,7 @@ class NCActivityCommentView: UIView, UITextFieldDelegate {
         newCommentField.delegate = self
         newCommentField.delegate = self
 
 
         let fileName = urlBase.userBaseUrl + "-" + urlBase.user + ".png"
         let fileName = urlBase.userBaseUrl + "-" + urlBase.user + ".png"
-        let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + fileName
+        let fileNameLocalPath = NCUtilityFileSystem.shared.directoryUserData + "/" + fileName
         if let image = UIImage(contentsOfFile: fileNameLocalPath) {
         if let image = UIImage(contentsOfFile: fileNameLocalPath) {
             imageItem.image = image
             imageItem.image = image
         } else {
         } else {

+ 2 - 5
iOSClient/Activity/NCActivityTableViewCell.swift

@@ -41,10 +41,6 @@ class NCActivityCollectionViewCell: UICollectionViewCell {
 
 
 class NCActivityTableViewCell: UITableViewCell, NCCellProtocol {
 class NCActivityTableViewCell: UITableViewCell, NCCellProtocol {
 
 
-    // swiftlint:disable force_cast
-    private let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
     @IBOutlet weak var collectionView: UICollectionView!
     @IBOutlet weak var collectionView: UICollectionView!
     @IBOutlet weak var icon: UIImageView!
     @IBOutlet weak var icon: UIImageView!
     @IBOutlet weak var avatar: UIImageView!
     @IBOutlet weak var avatar: UIImageView!
@@ -52,6 +48,7 @@ class NCActivityTableViewCell: UITableViewCell, NCCellProtocol {
     @IBOutlet weak var subjectTrailingConstraint: NSLayoutConstraint!
     @IBOutlet weak var subjectTrailingConstraint: NSLayoutConstraint!
     @IBOutlet weak var collectionViewHeightConstraint: NSLayoutConstraint!
     @IBOutlet weak var collectionViewHeightConstraint: NSLayoutConstraint!
 
 
+    private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     private var user: String = ""
     private var user: String = ""
     private var index = IndexPath()
     private var index = IndexPath()
 
 
@@ -190,7 +187,7 @@ extension NCActivityTableViewCell: UICollectionViewDataSource {
 
 
                 if let activitySubjectRich = NCManageDatabase.shared.getActivitySubjectRich(account: activityPreview.account, idActivity: idActivity, id: fileId) {
                 if let activitySubjectRich = NCManageDatabase.shared.getActivitySubjectRich(account: activityPreview.account, idActivity: idActivity, id: fileId) {
 
 
-                    let fileNamePath = CCUtility.getDirectoryUserData() + "/" + activitySubjectRich.name
+                    let fileNamePath = NCUtilityFileSystem.shared.directoryUserData + "/" + activitySubjectRich.name
 
 
                     if FileManager.default.fileExists(atPath: fileNamePath), let image = UIImage(contentsOfFile: fileNamePath) {
                     if FileManager.default.fileExists(atPath: fileNamePath), let image = UIImage(contentsOfFile: fileNamePath) {
                         cell.imageView.image = image
                         cell.imageView.image = image

+ 45 - 55
iOSClient/AppDelegate.swift

@@ -80,13 +80,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp())
         let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp())
 
 
         UserDefaults.standard.register(defaults: ["UserAgent": userAgent])
         UserDefaults.standard.register(defaults: ["UserAgent": userAgent])
-        if !CCUtility.getDisableCrashservice() && !NCBrandOptions.shared.disable_crash_service {
+        if !NCKeychain().disableCrashservice, !NCBrandOptions.shared.disable_crash_service {
             FirebaseApp.configure()
             FirebaseApp.configure()
         }
         }
 
 
-        CCUtility.createDirectoryStandard()
-        CCUtility.emptyTemporaryDirectory()
-        NCUtility.shared.clearCacheDirectory("com.limit-point.LivePhoto")
+        NCUtilityFileSystem.shared.createDirectoryStandard()
+        NCUtilityFileSystem.shared.emptyTemporaryDirectory()
+        NCUtilityFileSystem.shared.clearCacheDirectory("com.limit-point.LivePhoto")
 
 
         // Activated singleton
         // Activated singleton
         _ = NCActionCenter.shared
         _ = NCActionCenter.shared
@@ -98,18 +98,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         startTimerErrorNetworking()
         startTimerErrorNetworking()
 
 
         var levelLog = 0
         var levelLog = 0
-        if let pathDirectoryGroup = CCUtility.getDirectoryGroup()?.path {
-            NextcloudKit.shared.nkCommonInstance.pathLog = pathDirectoryGroup
-        }
+        NextcloudKit.shared.nkCommonInstance.pathLog = NCUtilityFileSystem.shared.directoryGroup
 
 
         if NCBrandOptions.shared.disable_log {
         if NCBrandOptions.shared.disable_log {
 
 
-            NCUtilityFileSystem.shared.deleteFile(filePath: NextcloudKit.shared.nkCommonInstance.filenamePathLog)
-            NCUtilityFileSystem.shared.deleteFile(filePath: NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first! + "/" + NextcloudKit.shared.nkCommonInstance.filenameLog)
+            NCUtilityFileSystem.shared.removeFile(atPath: NextcloudKit.shared.nkCommonInstance.filenamePathLog)
+            NCUtilityFileSystem.shared.removeFile(atPath: NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first! + "/" + NextcloudKit.shared.nkCommonInstance.filenameLog)
 
 
         } else {
         } else {
 
 
-            levelLog = CCUtility.getLogLevel()
+            levelLog = NCKeychain().logLevel
             NextcloudKit.shared.nkCommonInstance.levelLog = levelLog
             NextcloudKit.shared.nkCommonInstance.levelLog = levelLog
             NextcloudKit.shared.nkCommonInstance.copyLogToDocumentDirectory = true
             NextcloudKit.shared.nkCommonInstance.copyLogToDocumentDirectory = true
             NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Start session with level \(levelLog) " + versionNextcloudiOS)
             NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Start session with level \(levelLog) " + versionNextcloudiOS)
@@ -117,7 +115,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
 
 
         if let account = NCManageDatabase.shared.getActiveAccount() {
         if let account = NCManageDatabase.shared.getActiveAccount() {
             NextcloudKit.shared.nkCommonInstance.writeLog("Account active \(account.account)")
             NextcloudKit.shared.nkCommonInstance.writeLog("Account active \(account.account)")
-            if CCUtility.getPassword(account.account).isEmpty {
+            if NCKeychain().getPassword(account: account.account).isEmpty {
                 NextcloudKit.shared.nkCommonInstance.writeLog("[ERROR] PASSWORD NOT FOUND for \(account.account)")
                 NextcloudKit.shared.nkCommonInstance.writeLog("[ERROR] PASSWORD NOT FOUND for \(account.account)")
             }
             }
         }
         }
@@ -128,7 +126,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
             urlBase = activeAccount.urlBase
             urlBase = activeAccount.urlBase
             user = activeAccount.user
             user = activeAccount.user
             userId = activeAccount.userId
             userId = activeAccount.userId
-            password = CCUtility.getPassword(account)
+            password = NCKeychain().getPassword(account: account)
 
 
             NextcloudKit.shared.setup(account: account, user: user, userId: userId, password: password, urlBase: urlBase)
             NextcloudKit.shared.setup(account: account, user: user, userId: userId, password: password, urlBase: urlBase)
             NCManageDatabase.shared.setCapabilities(account: account)
             NCManageDatabase.shared.setCapabilities(account: account)
@@ -139,7 +137,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
 
 
         } else {
         } else {
 
 
-            CCUtility.deleteAllChainStore()
+            NCKeychain().removeAll()
             if let bundleID = Bundle.main.bundleIdentifier {
             if let bundleID = Bundle.main.bundleIdentifier {
                 UserDefaults.standard.removePersistentDomain(forName: bundleID)
                 UserDefaults.standard.removePersistentDomain(forName: bundleID)
             }
             }
@@ -170,12 +168,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
 
 
         // Intro
         // Intro
         if NCBrandOptions.shared.disable_intro {
         if NCBrandOptions.shared.disable_intro {
-            CCUtility.setIntro(true)
+            NCKeychain().intro = true
             if account.isEmpty {
             if account.isEmpty {
                 openLogin(viewController: nil, selector: NCGlobal.shared.introLogin, openLoginWeb: false)
                 openLogin(viewController: nil, selector: NCGlobal.shared.introLogin, openLoginWeb: false)
             }
             }
         } else {
         } else {
-            if !CCUtility.getIntro() {
+            if !NCKeychain().intro {
                 if let viewController = UIStoryboard(name: "NCIntro", bundle: nil).instantiateInitialViewController() {
                 if let viewController = UIStoryboard(name: "NCIntro", bundle: nil).instantiateInitialViewController() {
                     let navigationController = NCLoginNavigationController(rootViewController: viewController)
                     let navigationController = NCLoginNavigationController(rootViewController: viewController)
                     window?.rootViewController = navigationController
                     window?.rootViewController = navigationController
@@ -229,7 +227,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         NCNetworkingProcessUpload.shared.invalidateObserveTableMetadata()
         NCNetworkingProcessUpload.shared.invalidateObserveTableMetadata()
         NCNetworkingProcessUpload.shared.stopTimer()
         NCNetworkingProcessUpload.shared.stopTimer()
 
 
-        if CCUtility.getPrivacyScreenEnabled() {
+        if NCKeychain().privacyScreenEnabled {
             showPrivacyProtectionWindow()
             showPrivacyProtectionWindow()
         }
         }
 
 
@@ -237,10 +235,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         WidgetCenter.shared.reloadAllTimelines()
         WidgetCenter.shared.reloadAllTimelines()
 
 
         // Clear older files
         // Clear older files
-        let days = CCUtility.getCleanUpDay()
-        if let directory = CCUtility.getDirectoryProviderStorage() {
-            NCUtilityFileSystem.shared.cleanUp(directory: directory, days: TimeInterval(days))
-        }
+        let days = NCKeychain().cleanUpDay
+        NCUtilityFileSystem.shared.cleanUp(directory: NCUtilityFileSystem.shared.directoryProviderStorage, days: TimeInterval(days))
 
 
         NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterApplicationWillResignActive)
         NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterApplicationWillResignActive)
     }
     }
@@ -529,7 +525,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     }
     }
 
 
     @objc private func checkErrorNetworking() {
     @objc private func checkErrorNetworking() {
-        guard !account.isEmpty, CCUtility.getPassword(account)!.isEmpty else { return }
+        guard !account.isEmpty, NCKeychain().getPassword(account: account).isEmpty else { return }
         openLogin(viewController: window?.rootViewController, selector: NCGlobal.shared.introLogin, openLoginWeb: true)
         openLogin(viewController: window?.rootViewController, selector: NCGlobal.shared.introLogin, openLoginWeb: true)
     }
     }
 
 
@@ -541,7 +537,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
               host == currentHost
               host == currentHost
         else { return }
         else { return }
 
 
-        let certificateHostSavedPath = CCUtility.getDirectoryCerificates()! + "/" + host + ".der"
+        let certificateHostSavedPath = NCUtilityFileSystem.shared.directoryCertificates + "/" + host + ".der"
         var title = NSLocalizedString("_ssl_certificate_changed_", comment: "")
         var title = NSLocalizedString("_ssl_certificate_changed_", comment: "")
 
 
         if !FileManager.default.fileExists(atPath: certificateHostSavedPath) {
         if !FileManager.default.fileExists(atPath: certificateHostSavedPath) {
@@ -583,7 +579,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         self.urlBase = tableAccount.urlBase
         self.urlBase = tableAccount.urlBase
         self.user = tableAccount.user
         self.user = tableAccount.user
         self.userId = tableAccount.userId
         self.userId = tableAccount.userId
-        self.password = CCUtility.getPassword(tableAccount.account)
+        self.password = NCKeychain().getPassword(account: tableAccount.account)
 
 
         NextcloudKit.shared.setup(account: account, user: user, userId: userId, password: password, urlBase: urlBase)
         NextcloudKit.shared.setup(account: account, user: user, userId: userId, password: password, urlBase: urlBase)
         NCManageDatabase.shared.setCapabilities(account: account)
         NCManageDatabase.shared.setCapabilities(account: account)
@@ -617,13 +613,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
 
 
         let results = NCManageDatabase.shared.getTableLocalFiles(predicate: NSPredicate(format: "account == %@", account), sorted: "ocId", ascending: false)
         let results = NCManageDatabase.shared.getTableLocalFiles(predicate: NSPredicate(format: "account == %@", account), sorted: "ocId", ascending: false)
         for result in results {
         for result in results {
-            CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(result.ocId))
+            NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(result.ocId))
         }
         }
         NCManageDatabase.shared.clearDatabase(account: account, removeAccount: true)
         NCManageDatabase.shared.clearDatabase(account: account, removeAccount: true)
 
 
-        CCUtility.clearAllKeysEnd(toEnd: account)
-        CCUtility.clearAllKeysPushNotification(account)
-        CCUtility.setPassword(account, password: nil)
+        NCKeychain().clearAllKeysEndToEnd(account: account)
+        NCKeychain().clearAllKeysPushNotification(account: account)
+        NCKeychain().setPassword(account: account, password: nil)
 
 
         self.account = ""
         self.account = ""
         self.urlBase = ""
         self.urlBase = ""
@@ -659,7 +655,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
             let name = account.alias.isEmpty ? account.displayName : account.alias
             let name = account.alias.isEmpty ? account.displayName : account.alias
             let userBaseUrl = account.user + "-" + (URL(string: account.urlBase)?.host ?? "")
             let userBaseUrl = account.user + "-" + (URL(string: account.urlBase)?.host ?? "")
             let avatarFileName = userBaseUrl + "-\(account.user).png"
             let avatarFileName = userBaseUrl + "-\(account.user).png"
-            let pathAvatarFileName = String(CCUtility.getDirectoryUserData()) + "/" + avatarFileName
+            let pathAvatarFileName = NCUtilityFileSystem.shared.directoryUserData + "/" + avatarFileName
             let image = UIImage(contentsOfFile: pathAvatarFileName)
             let image = UIImage(contentsOfFile: pathAvatarFileName)
             accounts.append(NKShareAccounts.DataAccounts(withUrl: account.urlBase, user: account.user, name: name, image: image))
             accounts.append(NKShareAccounts.DataAccounts(withUrl: account.urlBase, user: account.user, name: name, image: image))
         }
         }
@@ -675,7 +671,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     func requestAccount() {
     func requestAccount() {
 
 
         if isPasscodePresented() { return }
         if isPasscodePresented() { return }
-        if !CCUtility.getAccountRequest() { return }
+        if !NCKeychain().accountRequest { return }
 
 
         let accounts = NCManageDatabase.shared.getAllAccount()
         let accounts = NCManageDatabase.shared.getAllAccount()
 
 
@@ -714,7 +710,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         defer { self.requestAccount() }
         defer { self.requestAccount() }
 
 
         let presentedViewController = window?.rootViewController?.presentedViewController
         let presentedViewController = window?.rootViewController?.presentedViewController
-        guard !account.isEmpty, CCUtility.isPasscodeAtStartEnabled(), !(presentedViewController is NCLoginNavigationController) else { return }
+        guard !account.isEmpty, NCKeychain().passcode != nil, NCKeychain().requestPasscodeAtStart, !(presentedViewController is NCLoginNavigationController) else { return }
 
 
         // Make sure we have a privacy window (in case it's not enabled)
         // Make sure we have a privacy window (in case it's not enabled)
         showPrivacyProtectionWindow()
         showPrivacyProtectionWindow()
@@ -722,7 +718,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         let passcodeViewController = TOPasscodeViewController(passcodeType: .sixDigits, allowCancel: false)
         let passcodeViewController = TOPasscodeViewController(passcodeType: .sixDigits, allowCancel: false)
         passcodeViewController.delegate = self
         passcodeViewController.delegate = self
         passcodeViewController.keypadButtonShowLettering = false
         passcodeViewController.keypadButtonShowLettering = false
-        if CCUtility.getEnableTouchFaceID() && laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
+        if NCKeychain().touchFaceID, laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
             if error == nil {
             if error == nil {
                 if laContext.biometryType == .faceID {
                 if laContext.biometryType == .faceID {
                     passcodeViewController.biometryType = .faceID
                     passcodeViewController.biometryType = .faceID
@@ -746,8 +742,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
 
 
     func enableTouchFaceID() {
     func enableTouchFaceID() {
         guard !account.isEmpty,
         guard !account.isEmpty,
-              CCUtility.getEnableTouchFaceID(),
-              CCUtility.isPasscodeAtStartEnabled(),
+              NCKeychain().touchFaceID,
+              NCKeychain().passcode != nil,
+              NCKeychain().requestPasscodeAtStart,
               let passcodeViewController = privacyProtectionWindow?.rootViewController?.presentedViewController as? TOPasscodeViewController
               let passcodeViewController = privacyProtectionWindow?.rootViewController?.presentedViewController as? TOPasscodeViewController
         else { return }
         else { return }
 
 
@@ -775,7 +772,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     }
     }
 
 
     func passcodeViewController(_ passcodeViewController: TOPasscodeViewController, isCorrectCode code: String) -> Bool {
     func passcodeViewController(_ passcodeViewController: TOPasscodeViewController, isCorrectCode code: String) -> Bool {
-        return code == CCUtility.getPasscode()
+        return code == NCKeychain().passcode
     }
     }
 
 
     func didPerformBiometricValidationRequest(in passcodeViewController: TOPasscodeViewController) {
     func didPerformBiometricValidationRequest(in passcodeViewController: TOPasscodeViewController) {
@@ -840,8 +837,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         var serverUrl: String = ""
         var serverUrl: String = ""
 
 
         /*
         /*
-         Example:
-         nextcloud://open-action?action=create-voice-memo&&user=marinofaggiana&url=https://cloud.nextcloud.com
+         Example: nextcloud://open-action?action=create-voice-memo&&user=marinofaggiana&url=https://cloud.nextcloud.com
          */
          */
 
 
         if !account.isEmpty && scheme == NCGlobal.shared.appScheme && action == "open-action" {
         if !account.isEmpty && scheme == NCGlobal.shared.appScheme && action == "open-action" {
@@ -849,16 +845,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
             if let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) {
             if let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) {
 
 
                 let queryItems = urlComponents.queryItems
                 let queryItems = urlComponents.queryItems
-                guard let actionScheme = CCUtility.value(forKey: "action", fromQueryItems: queryItems), let rootViewController = window?.rootViewController else { return false }
-                guard let userScheme = CCUtility.value(forKey: "user", fromQueryItems: queryItems) else { return false }
-                guard let urlScheme = CCUtility.value(forKey: "url", fromQueryItems: queryItems) else { return false }
+                guard let actionScheme = queryItems?.filter({ $0.name == "action" }).first?.value,
+                      let userScheme = queryItems?.filter({ $0.name == "user" }).first?.value,
+                      let urlScheme = queryItems?.filter({ $0.name == "url" }).first?.value,
+                      let rootViewController = window?.rootViewController else { return false }
                 if getMatchedAccount(userId: userScheme, url: urlScheme) == nil {
                 if getMatchedAccount(userId: userScheme, url: urlScheme) == nil {
                     let message = NSLocalizedString("_the_account_", comment: "") + " " + userScheme + NSLocalizedString("_of_", comment: "") + " " + urlScheme + " " + NSLocalizedString("_does_not_exist_", comment: "")
                     let message = NSLocalizedString("_the_account_", comment: "") + " " + userScheme + NSLocalizedString("_of_", comment: "") + " " + urlScheme + " " + NSLocalizedString("_does_not_exist_", comment: "")
                     let alertController = UIAlertController(title: NSLocalizedString("_info_", comment: ""), message: message, preferredStyle: .alert)
                     let alertController = UIAlertController(title: NSLocalizedString("_info_", comment: ""), message: message, preferredStyle: .alert)
                     alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in }))
                     alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in }))
 
 
                     window?.rootViewController?.present(alertController, animated: true, completion: { })
                     window?.rootViewController?.present(alertController, animated: true, completion: { })
-
                     return false
                     return false
                 }
                 }
 
 
@@ -896,7 +892,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
 
 
                     NCAskAuthorization.shared.askAuthorizationAudioRecord(viewController: rootViewController) { hasPermission in
                     NCAskAuthorization.shared.askAuthorizationAudioRecord(viewController: rootViewController) { hasPermission in
                         if hasPermission {
                         if hasPermission {
-                            let fileName = CCUtility.createFileNameDate(NSLocalizedString("_voice_memo_filename_", comment: ""), extension: "m4a")!
+                            let fileName = NCUtilityFileSystem.shared.createFileNameDate(NSLocalizedString("_voice_memo_filename_", comment: ""), ext: "m4a")
                             if let viewController = UIStoryboard(name: "NCAudioRecorderViewController", bundle: nil).instantiateInitialViewController() as? NCAudioRecorderViewController {
                             if let viewController = UIStoryboard(name: "NCAudioRecorderViewController", bundle: nil).instantiateInitialViewController() as? NCAudioRecorderViewController {
 
 
                                 viewController.delegate = self
                                 viewController.delegate = self
@@ -917,8 +913,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         }
         }
 
 
         /*
         /*
-         Example:
-         nextcloud://open-file?path=Talk/IMG_0000123.jpg&user=marinofaggiana&link=https://cloud.nextcloud.com/f/123
+         Example: nextcloud://open-file?path=Talk/IMG_0000123.jpg&user=marinofaggiana&link=https://cloud.nextcloud.com/f/123
          */
          */
 
 
         else if !account.isEmpty && scheme == NCGlobal.shared.appScheme && action == "open-file" {
         else if !account.isEmpty && scheme == NCGlobal.shared.appScheme && action == "open-file" {
@@ -926,19 +921,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
             if let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) {
             if let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) {
 
 
                 let queryItems = urlComponents.queryItems
                 let queryItems = urlComponents.queryItems
-                guard let userScheme = CCUtility.value(forKey: "user", fromQueryItems: queryItems) else { return false }
-                guard let pathScheme = CCUtility.value(forKey: "path", fromQueryItems: queryItems) else { return false }
-                guard let linkScheme = CCUtility.value(forKey: "link", fromQueryItems: queryItems) else { return false }
+                guard let userScheme = queryItems?.filter({ $0.name == "user" }).first?.value,
+                      let pathScheme = queryItems?.filter({ $0.name == "path" }).first?.value,
+                      let linkScheme = queryItems?.filter({ $0.name == "link" }).first?.value else { return false}
+
                 guard let matchedAccount = getMatchedAccount(userId: userScheme, url: linkScheme) else {
                 guard let matchedAccount = getMatchedAccount(userId: userScheme, url: linkScheme) else {
                     guard let domain = URL(string: linkScheme)?.host else { return true }
                     guard let domain = URL(string: linkScheme)?.host else { return true }
                     fileName = (pathScheme as NSString).lastPathComponent
                     fileName = (pathScheme as NSString).lastPathComponent
                     let message = String(format: NSLocalizedString("_account_not_available_", comment: ""), userScheme, domain, fileName)
                     let message = String(format: NSLocalizedString("_account_not_available_", comment: ""), userScheme, domain, fileName)
-
                     let alertController = UIAlertController(title: NSLocalizedString("_info_", comment: ""), message: message, preferredStyle: .alert)
                     let alertController = UIAlertController(title: NSLocalizedString("_info_", comment: ""), message: message, preferredStyle: .alert)
                     alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in }))
                     alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in }))
 
 
                     window?.rootViewController?.present(alertController, animated: true, completion: { })
                     window?.rootViewController?.present(alertController, animated: true, completion: { })
-
                     return false
                     return false
                 }
                 }
 
 
@@ -958,22 +952,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
             return true
             return true
 
 
         /*
         /*
-         Example:
-         nextcloud://open-and-switch-account?user=marinofaggiana&url=https://cloud.nextcloud.com
+         Example: nextcloud://open-and-switch-account?user=marinofaggiana&url=https://cloud.nextcloud.com
          */
          */
 
 
         } else if !account.isEmpty && scheme == NCGlobal.shared.appScheme && action == "open-and-switch-account" {
         } else if !account.isEmpty && scheme == NCGlobal.shared.appScheme && action == "open-and-switch-account" {
             guard let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) else { return false }
             guard let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) else { return false }
             let queryItems = urlComponents.queryItems
             let queryItems = urlComponents.queryItems
-
-            guard let userScheme = CCUtility.value(forKey: "user", fromQueryItems: queryItems) else { return false }
-            guard let urlScheme = CCUtility.value(forKey: "url", fromQueryItems: queryItems) else { return false }
-
+            guard let userScheme = queryItems?.filter({ $0.name == "user" }).first?.value,
+                  let urlScheme = queryItems?.filter({ $0.name == "url" }).first?.value else { return false}
             // If the account doesn't exist, return false which will open the app without switching
             // If the account doesn't exist, return false which will open the app without switching
             if getMatchedAccount(userId: userScheme, url: urlScheme) == nil {
             if getMatchedAccount(userId: userScheme, url: urlScheme) == nil {
                 return false
                 return false
             }
             }
-
             // Otherwise open the app and switch accounts
             // Otherwise open the app and switch accounts
             return true
             return true
         } else {
         } else {

+ 2 - 3
iOSClient/Data/NCManageDatabase+Account.swift

@@ -106,7 +106,7 @@ extension NCManageDatabase {
                     addObject.autoUploadWWAnVideo = true
                     addObject.autoUploadWWAnVideo = true
                 }
                 }
 
 
-                CCUtility.setPassword(account, password: password)
+                NCKeychain().setPassword(account: account, password: password)
 
 
                 addObject.urlBase = urlBase
                 addObject.urlBase = urlBase
                 addObject.user = user
                 addObject.user = user
@@ -263,8 +263,7 @@ extension NCManageDatabase {
 
 
         let cameraFileName = self.getAccountAutoUploadFileName()
         let cameraFileName = self.getAccountAutoUploadFileName()
         let cameraDirectory = self.getAccountAutoUploadDirectory(urlBase: urlBase, userId: userId, account: account)
         let cameraDirectory = self.getAccountAutoUploadDirectory(urlBase: urlBase, userId: userId, account: account)
-
-        let folderPhotos = CCUtility.stringAppendServerUrl(cameraDirectory, addFileName: cameraFileName)!
+        let folderPhotos = NCUtilityFileSystem.shared.stringAppendServerUrl(cameraDirectory, addFileName: cameraFileName)
 
 
         return folderPhotos
         return folderPhotos
     }
     }

+ 4 - 4
iOSClient/Data/NCManageDatabase+Avatar.swift

@@ -89,7 +89,7 @@ extension NCManageDatabase {
     @discardableResult
     @discardableResult
     func setAvatarLoaded(fileName: String) -> UIImage? {
     func setAvatarLoaded(fileName: String) -> UIImage? {
 
 
-        let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + fileName
+        let fileNameLocalPath = NCUtilityFileSystem.shared.directoryUserData + "/" + fileName
         var image: UIImage?
         var image: UIImage?
 
 
         do {
         do {
@@ -113,14 +113,14 @@ extension NCManageDatabase {
 
 
     func getImageAvatarLoaded(fileName: String) -> UIImage? {
     func getImageAvatarLoaded(fileName: String) -> UIImage? {
 
 
-        let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + fileName
+        let fileNameLocalPath = NCUtilityFileSystem.shared.directoryUserData + "/" + fileName
 
 
         do {
         do {
             let realm = try Realm()
             let realm = try Realm()
             realm.refresh()
             realm.refresh()
             let result = realm.objects(tableAvatar.self).filter("fileName == %@", fileName).first
             let result = realm.objects(tableAvatar.self).filter("fileName == %@", fileName).first
             if result == nil {
             if result == nil {
-                NCUtilityFileSystem.shared.deleteFile(filePath: fileNameLocalPath)
+                NCUtilityFileSystem.shared.removeFile(atPath: fileNameLocalPath)
                 return nil
                 return nil
             } else if result?.loaded == false {
             } else if result?.loaded == false {
                 return nil
                 return nil
@@ -130,7 +130,7 @@ extension NCManageDatabase {
             NextcloudKit.shared.nkCommonInstance.writeLog("Could not access database: \(error)")
             NextcloudKit.shared.nkCommonInstance.writeLog("Could not access database: \(error)")
         }
         }
 
 
-        NCUtilityFileSystem.shared.deleteFile(filePath: fileNameLocalPath)
+        NCUtilityFileSystem.shared.removeFile(atPath: fileNameLocalPath)
         return nil
         return nil
     }
     }
 }
 }

+ 2 - 2
iOSClient/Data/NCManageDatabase+Chunk.swift

@@ -100,7 +100,7 @@ extension NCManageDatabase {
                 let result = realm.objects(tableChunk.self).filter(NSPredicate(format: "account == %@ AND ocId == %@ AND fileName == %d", account, ocId, Int(fileChunk.fileName) ?? 0))
                 let result = realm.objects(tableChunk.self).filter(NSPredicate(format: "account == %@ AND ocId == %@ AND fileName == %d", account, ocId, Int(fileChunk.fileName) ?? 0))
                 realm.delete(result)
                 realm.delete(result)
                 let filePath = directory + "/\(fileChunk.fileName)"
                 let filePath = directory + "/\(fileChunk.fileName)"
-                NCUtilityFileSystem.shared.deleteFile(filePath: filePath)
+                NCUtilityFileSystem.shared.removeFile(atPath: filePath)
             }
             }
         } catch let error {
         } catch let error {
             NextcloudKit.shared.nkCommonInstance.writeLog("Could not write to database: \(error)")
             NextcloudKit.shared.nkCommonInstance.writeLog("Could not write to database: \(error)")
@@ -115,7 +115,7 @@ extension NCManageDatabase {
                 let results = realm.objects(tableChunk.self).filter(NSPredicate(format: "account == %@ AND ocId == %@", account, ocId))
                 let results = realm.objects(tableChunk.self).filter(NSPredicate(format: "account == %@ AND ocId == %@", account, ocId))
                 for result in results {
                 for result in results {
                     let filePath = directory + "/\(result.fileName)"
                     let filePath = directory + "/\(result.fileName)"
-                    NCUtilityFileSystem.shared.deleteFile(filePath: filePath)
+                    NCUtilityFileSystem.shared.removeFile(atPath: filePath)
                 }
                 }
                 realm.delete(results)
                 realm.delete(results)
             }
             }

+ 5 - 5
iOSClient/Data/NCManageDatabase+Metadata.swift

@@ -202,11 +202,11 @@ extension tableMetadata {
     }
     }
 
 
     var isDirectoySettableE2EE: Bool {
     var isDirectoySettableE2EE: Bool {
-        return directory && size == 0 && !e2eEncrypted && CCUtility.isEnd(toEndEnabled: account)
+        return directory && size == 0 && !e2eEncrypted && NCKeychain().isEndToEndEnabled(account: account)
     }
     }
 
 
     var isDirectoryUnsettableE2EE: Bool {
     var isDirectoryUnsettableE2EE: Bool {
-        return !isDirectoryE2EE && directory && size == 0 && e2eEncrypted && CCUtility.isEnd(toEndEnabled: account)
+        return !isDirectoryE2EE && directory && size == 0 && e2eEncrypted && NCKeychain().isEndToEndEnabled(account: account)
     }
     }
 
 
     var canOpenExternalEditor: Bool {
     var canOpenExternalEditor: Bool {
@@ -1057,7 +1057,7 @@ extension NCManageDatabase {
         var classFile = metadata.classFile
         var classFile = metadata.classFile
         var fileName = (metadata.fileNameView as NSString).deletingPathExtension
         var fileName = (metadata.fileNameView as NSString).deletingPathExtension
 
 
-        if !metadata.livePhoto || !CCUtility.getLivePhoto() {
+        if !metadata.livePhoto || !NCKeychain().livePhoto {
             return nil
             return nil
         }
         }
 
 
@@ -1148,7 +1148,7 @@ extension NCManageDatabase {
     func isDownloadMetadata(_ metadata: tableMetadata, download: Bool) -> Bool {
     func isDownloadMetadata(_ metadata: tableMetadata, download: Bool) -> Bool {
 
 
         let localFile = getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
         let localFile = getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
-        let fileSize = CCUtility.fileProviderStorageSize(metadata.ocId, fileNameView: metadata.fileNameView)
+        let fileSize = NCUtilityFileSystem.shared.fileProviderStorageSize(metadata.ocId, fileNameView: metadata.fileNameView)
         if (localFile != nil || download) && (localFile?.etag != metadata.etag || fileSize == 0) {
         if (localFile != nil || download) && (localFile?.etag != metadata.etag || fileSize == 0) {
             return true
             return true
         }
         }
@@ -1162,7 +1162,7 @@ extension NCManageDatabase {
         let fileNameNoExtension = (fileNameView as NSString).deletingPathExtension
         let fileNameNoExtension = (fileNameView as NSString).deletingPathExtension
         var fileNameConflict = fileNameView
         var fileNameConflict = fileNameView
 
 
-        if fileNameExtension == "heic" && CCUtility.getFormatCompatibility() {
+        if fileNameExtension == "heic", NCKeychain().formatCompatibility {
             fileNameConflict = fileNameNoExtension + ".jpg"
             fileNameConflict = fileNameNoExtension + ".jpg"
         }
         }
         return getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameView == %@", account, serverUrl, fileNameConflict))
         return getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameView == %@", account, serverUrl, fileNameConflict))

+ 1 - 1
iOSClient/Extensions/PHAsset+Extension.swift

@@ -30,7 +30,7 @@ extension PHAsset {
             return resource.originalFilename as NSString
             return resource.originalFilename as NSString
         } else {
         } else {
             return self.value(forKey: "filename") as? NSString
             return self.value(forKey: "filename") as? NSString
-            ?? ("IMG_" + CCUtility.getIncrementalNumber() + getExtension()) as NSString
+            ?? ("IMG_" + NCKeychain().incrementalNumber + getExtension()) as NSString
         }
         }
     }
     }
 
 

+ 2 - 2
iOSClient/Extensions/UIAlertController+Extension.swift

@@ -73,8 +73,8 @@ extension UIAlertController {
             forName: UITextField.textDidChangeNotification,
             forName: UITextField.textDidChangeNotification,
             object: alertController.textFields?.first,
             object: alertController.textFields?.first,
             queue: .main) { _ in
             queue: .main) { _ in
-                guard let text = alertController.textFields?.first?.text,
-                      let folderName = CCUtility.removeForbiddenCharactersServer(text)?.trimmingCharacters(in: .whitespaces) else { return }
+                guard let text = alertController.textFields?.first?.text else { return }
+                let folderName = NCUtility.shared.removeForbiddenCharacters(text).trimmingCharacters(in: .whitespaces)
                 okAction.isEnabled = !folderName.isEmpty && folderName != "." && folderName != ".."
                 okAction.isEnabled = !folderName.isEmpty && folderName != "." && folderName != ".."
             }
             }
 
 

+ 1 - 1
iOSClient/Favorites/NCFavorite.swift

@@ -91,7 +91,7 @@ class NCFavorite: NCCollectionViewCommon {
         isReloadDataSourceNetworkInProgress = true
         isReloadDataSourceNetworkInProgress = true
         collectionView?.reloadData()
         collectionView?.reloadData()
 
 
-        NextcloudKit.shared.listingFavorites(showHiddenFiles: CCUtility.getShowHiddenFiles(),
+        NextcloudKit.shared.listingFavorites(showHiddenFiles: NCKeychain().showHiddenFiles,
                                              options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { account, files, _, error in
                                              options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { account, files, _, error in
 
 
             self.isReloadDataSourceNetworkInProgress = false
             self.isReloadDataSourceNetworkInProgress = false

+ 1 - 1
iOSClient/Groupfolders/NCGroupfolders.swift

@@ -102,7 +102,7 @@ class NCGroupfolders: NCCollectionViewCommon {
                         let mountPoint = groupfolder.mountPoint.hasPrefix("/") ? groupfolder.mountPoint : "/" + groupfolder.mountPoint
                         let mountPoint = groupfolder.mountPoint.hasPrefix("/") ? groupfolder.mountPoint : "/" + groupfolder.mountPoint
                         let serverUrlFileName = homeServerUrl + mountPoint
                         let serverUrlFileName = homeServerUrl + mountPoint
                         if NCManageDatabase.shared.getMetadataFromDirectory(account: self.appDelegate.account, serverUrl: serverUrlFileName) == nil {
                         if NCManageDatabase.shared.getMetadataFromDirectory(account: self.appDelegate.account, serverUrl: serverUrlFileName) == nil {
-                            let results = await NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrlFileName, depth: "0", showHiddenFiles: CCUtility.getShowHiddenFiles())
+                            let results = await NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrlFileName, depth: "0", showHiddenFiles: NCKeychain().showHiddenFiles)
                             if results.error == .success, let file = results.files.first {
                             if results.error == .success, let file = results.files.first {
                                 let isDirectoryE2EE = NCUtility.shared.isDirectoryE2EE(file: file)
                                 let isDirectoryE2EE = NCUtility.shared.isDirectoryE2EE(file: file)
                                 let metadata = NCManageDatabase.shared.convertFileToMetadata(file, isDirectoryE2EE: isDirectoryE2EE)
                                 let metadata = NCManageDatabase.shared.convertFileToMetadata(file, isDirectoryE2EE: isDirectoryE2EE)

+ 3 - 6
iOSClient/Login/NCLogin.swift

@@ -36,10 +36,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
     @IBOutlet weak var qrCode: UIButton!
     @IBOutlet weak var qrCode: UIButton!
     @IBOutlet weak var certificate: UIButton!
     @IBOutlet weak var certificate: UIButton!
 
 
-    // swiftlint:disable force_cast
-    private let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     private var textColor: UIColor = .white
     private var textColor: UIColor = .white
     private var textColorOpponent: UIColor = .black
     private var textColorOpponent: UIColor = .black
     private var activeTextfieldDiff: CGFloat = 0
     private var activeTextfieldDiff: CGFloat = 0
@@ -407,10 +404,10 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
 
 
                     self.appDelegate.changeAccount(account, userProfile: userProfile)
                     self.appDelegate.changeAccount(account, userProfile: userProfile)
 
 
-                    if CCUtility.getIntro() {
+                    if NCKeychain().intro {
                         self.dismiss(animated: true)
                         self.dismiss(animated: true)
                     } else {
                     } else {
-                        CCUtility.setIntro(true)
+                        NCKeychain().intro = true
                         if self.presentingViewController == nil {
                         if self.presentingViewController == nil {
                             let viewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()
                             let viewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()
                             viewController?.modalPresentationStyle = .fullScreen
                             viewController?.modalPresentationStyle = .fullScreen

+ 5 - 7
iOSClient/Login/NCLoginWeb.swift

@@ -30,9 +30,7 @@ class NCLoginWeb: UIViewController {
 
 
     var webView: WKWebView?
     var webView: WKWebView?
 
 
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
 
 
     var titleView: String = ""
     var titleView: String = ""
 
 
@@ -131,7 +129,7 @@ class NCLoginWeb: UIViewController {
         // TITLE
         // TITLE
         if let host = URL(string: urlBase)?.host {
         if let host = URL(string: urlBase)?.host {
             titleView = host
             titleView = host
-            if let account = NCManageDatabase.shared.getActiveAccount(), CCUtility.getPassword(account.account).isEmpty {
+            if let account = NCManageDatabase.shared.getActiveAccount(), NCKeychain().getPassword(account: account.account).isEmpty {
                 titleView = NSLocalizedString("_user_", comment: "") + " " + account.userId + " " + NSLocalizedString("_in_", comment: "") + " " + host
                 titleView = NSLocalizedString("_user_", comment: "") + " " + account.userId + " " + NSLocalizedString("_in_", comment: "") + " " + host
             }
             }
         }
         }
@@ -144,7 +142,7 @@ class NCLoginWeb: UIViewController {
         // Stop timer error network
         // Stop timer error network
         appDelegate.timerErrorNetworking?.invalidate()
         appDelegate.timerErrorNetworking?.invalidate()
 
 
-        if let account = NCManageDatabase.shared.getActiveAccount(), CCUtility.getPassword(account.account).isEmpty {
+        if let account = NCManageDatabase.shared.getActiveAccount(), NCKeychain().getPassword(account: account.account).isEmpty {
 
 
             let message = "\n" + NSLocalizedString("_password_not_present_", comment: "")
             let message = "\n" + NSLocalizedString("_password_not_present_", comment: "")
             let alertController = UIAlertController(title: titleView, message: message, preferredStyle: .alert)
             let alertController = UIAlertController(title: titleView, message: message, preferredStyle: .alert)
@@ -303,10 +301,10 @@ extension NCLoginWeb: WKNavigationDelegate {
 
 
                 self.appDelegate.changeAccount(account, userProfile: userProfile)
                 self.appDelegate.changeAccount(account, userProfile: userProfile)
 
 
-                if CCUtility.getIntro() {
+                if NCKeychain().intro {
                     self.dismiss(animated: true)
                     self.dismiss(animated: true)
                 } else {
                 } else {
-                    CCUtility.setIntro(true)
+                    NCKeychain().intro = true
                     if self.presentingViewController == nil {
                     if self.presentingViewController == nil {
                         if let viewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController() {
                         if let viewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController() {
                             viewController.modalPresentationStyle = .fullScreen
                             viewController.modalPresentationStyle = .fullScreen

+ 1 - 1
iOSClient/Login/NCViewCertificateDetails.swift

@@ -53,7 +53,7 @@ class NCViewCertificateDetails: UIViewController {
         buttonCancel.title = NSLocalizedString("_close_", comment: "")
         buttonCancel.title = NSLocalizedString("_close_", comment: "")
 
 
         if fileNamePath.isEmpty {
         if fileNamePath.isEmpty {
-            fileNamePath = CCUtility.getDirectoryCerificates()! + "/" + host + ".txt"
+            fileNamePath = NCUtilityFileSystem.shared.directoryCertificates + "/" + host + ".txt"
         }
         }
 
 
         if FileManager.default.fileExists(atPath: fileNamePath) {
         if FileManager.default.fileExists(atPath: fileNamePath) {

+ 43 - 26
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -32,10 +32,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
 
     @IBOutlet weak var collectionView: UICollectionView!
     @IBOutlet weak var collectionView: UICollectionView!
 
 
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    internal let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     internal let refreshControl = UIRefreshControl()
     internal let refreshControl = UIRefreshControl()
     internal var searchController: UISearchController?
     internal var searchController: UISearchController?
     internal var emptyDataSet: NCEmptyDataSet?
     internal var emptyDataSet: NCEmptyDataSet?
@@ -542,12 +539,12 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                     cell.fileProgressView?.progress = progressNumber.floatValue
                     cell.fileProgressView?.progress = progressNumber.floatValue
                     cell.setButtonMore(named: NCGlobal.shared.buttonMoreStop, image: NCBrandColor.cacheImages.buttonStop)
                     cell.setButtonMore(named: NCGlobal.shared.buttonMoreStop, image: NCBrandColor.cacheImages.buttonStop)
                     if status == NCGlobal.shared.metadataStatusInDownload {
                     if status == NCGlobal.shared.metadataStatusInDownload {
-                        cell.fileInfoLabel?.text = CCUtility.transformedSize(totalBytesExpected) + " - ↓ " + CCUtility.transformedSize(totalBytes)
+                        cell.fileInfoLabel?.text = NCUtilityFileSystem.shared.transformedSize(totalBytesExpected) + " - ↓ " + NCUtilityFileSystem.shared.transformedSize(totalBytes)
                     } else if status == NCGlobal.shared.metadataStatusInUpload {
                     } else if status == NCGlobal.shared.metadataStatusInUpload {
                         if totalBytes > 0 {
                         if totalBytes > 0 {
-                            cell.fileInfoLabel?.text = CCUtility.transformedSize(totalBytesExpected) + " - ↑ " + CCUtility.transformedSize(totalBytes)
+                            cell.fileInfoLabel?.text = NCUtilityFileSystem.shared.transformedSize(totalBytesExpected) + " - ↑ " + NCUtilityFileSystem.shared.transformedSize(totalBytes)
                         } else {
                         } else {
-                            cell.fileInfoLabel?.text = CCUtility.transformedSize(totalBytesExpected) + " - ↑ …"
+                            cell.fileInfoLabel?.text = NCUtilityFileSystem.shared.transformedSize(totalBytesExpected) + " - ↑ …"
                         }
                         }
                     }
                     }
                 }
                 }
@@ -1015,8 +1012,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                     self.metadataFolder = metadataFolder
                     self.metadataFolder = metadataFolder
                     // E2EE
                     // E2EE
                     if let metadataFolder = metadataFolder,
                     if let metadataFolder = metadataFolder,
-                        metadataFolder.e2eEncrypted,
-                        CCUtility.isEnd(toEndEnabled: self.appDelegate.account),
+                       metadataFolder.e2eEncrypted,
+                       NCKeychain().isEndToEndEnabled(account: self.appDelegate.account),
                        !NCNetworkingE2EE.shared.isInUpload(account: self.appDelegate.account, serverUrl: self.serverUrl) {
                        !NCNetworkingE2EE.shared.isInUpload(account: self.appDelegate.account, serverUrl: self.serverUrl) {
                         let lock = NCManageDatabase.shared.getE2ETokenLock(account: self.appDelegate.account, serverUrl: self.serverUrl)
                         let lock = NCManageDatabase.shared.getE2ETokenLock(account: self.appDelegate.account, serverUrl: self.serverUrl)
                         NextcloudKit.shared.getE2EEMetadata(fileId: metadataFolder.ocId, e2eToken: lock?.e2eToken) { _, e2eMetadata, signature, _, error in
                         NextcloudKit.shared.getE2EEMetadata(fileId: metadataFolder.ocId, e2eToken: lock?.e2eToken) { _, e2eMetadata, signature, _, error in
@@ -1055,7 +1052,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
 
     func pushMetadata(_ metadata: tableMetadata) {
     func pushMetadata(_ metadata: tableMetadata) {
 
 
-        guard let serverUrlPush = CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName) else { return }
+        let serverUrlPush = NCUtilityFileSystem.shared.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName)
         appDelegate.activeMetadata = metadata
         appDelegate.activeMetadata = metadata
 
 
         if let viewController = appDelegate.listFilesVC[serverUrlPush], viewController.isViewLoaded {
         if let viewController = appDelegate.listFilesVC[serverUrlPush], viewController.isViewLoaded {
@@ -1108,7 +1105,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
 
 
         if metadata.e2eEncrypted {
         if metadata.e2eEncrypted {
             if NCGlobal.shared.capabilityE2EEEnabled {
             if NCGlobal.shared.capabilityE2EEEnabled {
-                if !CCUtility.isEnd(toEndEnabled: appDelegate.account) {
+                if !NCKeychain().isEndToEndEnabled(account: appDelegate.account) {
                     let e2ee = NCEndToEndInitialize()
                     let e2ee = NCEndToEndInitialize()
                     e2ee.delegate = self
                     e2ee.delegate = self
                     e2ee.initEndToEndEncryption()
                     e2ee.initEndToEndEncryption()
@@ -1126,7 +1123,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
 
 
         } else {
         } else {
 
 
-            let imageIcon = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag))
+            let imageIcon = UIImage(contentsOfFile: NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag))
 
 
             if !metadata.isDirectoryE2EE && (metadata.isImage || metadata.isAudioOrVideo) {
             if !metadata.isDirectoryE2EE && (metadata.isImage || metadata.isAudioOrVideo) {
                 var metadatas: [tableMetadata] = []
                 var metadatas: [tableMetadata] = []
@@ -1139,7 +1136,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
                 return
                 return
             }
             }
 
 
-            if CCUtility.fileProviderStorageExists(metadata) {
+            if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) {
                 NCViewer.shared.view(viewController: self, metadata: metadata, metadatas: [metadata], imageIcon: imageIcon)
                 NCViewer.shared.view(viewController: self, metadata: metadata, metadatas: [metadata], imageIcon: imageIcon)
             } else if NextcloudKit.shared.isNetworkReachable() {
             } else if NextcloudKit.shared.isNetworkReachable() {
                 NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorLoadFileView) { _, _ in }
                 NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorLoadFileView) { _, _ in }
@@ -1207,7 +1204,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                     } else {
                     } else {
                         (cell as? NCCellProtocol)?.filePreviewImageView?.image = UIImage(named: metadata.iconName)
                         (cell as? NCCellProtocol)?.filePreviewImageView?.image = UIImage(named: metadata.iconName)
                     }
                     }
-                    if metadata.hasPreview && metadata.status == NCGlobal.shared.metadataStatusNormal && (!CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag)) {
+                    if metadata.hasPreview && metadata.status == NCGlobal.shared.metadataStatusNormal && (!NCUtilityFileSystem.shared.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag)) {
                         for case let operation as NCCollectionViewDownloadThumbnail in appDelegate.downloadThumbnailQueue.operations where operation.metadata.ocId == metadata.ocId { return }
                         for case let operation as NCCollectionViewDownloadThumbnail in appDelegate.downloadThumbnailQueue.operations where operation.metadata.ocId == metadata.ocId { return }
                         appDelegate.downloadThumbnailQueue.addOperation(NCCollectionViewDownloadThumbnail(metadata: metadata, cell: (cell as? NCCellProtocol), collectionView: collectionView))
                         appDelegate.downloadThumbnailQueue.addOperation(NCCollectionViewDownloadThumbnail(metadata: metadata, cell: (cell as? NCCellProtocol), collectionView: collectionView))
                     }
                     }
@@ -1236,7 +1233,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                 }
                 }
 
 
                 if !metadata.iconUrl.isEmpty {
                 if !metadata.iconUrl.isEmpty {
-                    if let ownerId = NCUtility.shared.getAvatarFromIconUrl(metadata: metadata), let cell = cell as? NCCellProtocol {
+                    if let ownerId = getAvatarFromIconUrl(metadata: metadata), let cell = cell as? NCCellProtocol {
                         let fileName = metadata.userBaseUrl + "-" + ownerId + ".png"
                         let fileName = metadata.userBaseUrl + "-" + ownerId + ".png"
                         NCNetworking.shared.downloadAvatar(user: ownerId, dispalyName: nil, fileName: fileName, cell: cell, view: collectionView, cellImageView: cell.filePreviewImageView)
                         NCNetworking.shared.downloadAvatar(user: ownerId, dispalyName: nil, fileName: fileName, cell: cell, view: collectionView, cellImageView: cell.filePreviewImageView)
                     }
                     }
@@ -1385,7 +1382,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             if NCManageDatabase.shared.getTableLocalFile(ocId: metadata.ocId) != nil {
             if NCManageDatabase.shared.getTableLocalFile(ocId: metadata.ocId) != nil {
                 a11yValues.append(NSLocalizedString("_offline_", comment: ""))
                 a11yValues.append(NSLocalizedString("_offline_", comment: ""))
                 cell.fileLocalImage?.image = NCBrandColor.cacheImages.offlineFlag
                 cell.fileLocalImage?.image = NCBrandColor.cacheImages.offlineFlag
-            } else if CCUtility.fileProviderStorageExists(metadata) {
+            } else if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) {
                 cell.fileLocalImage?.image = NCBrandColor.cacheImages.local
                 cell.fileLocalImage?.image = NCBrandColor.cacheImages.local
             }
             }
         }
         }
@@ -1423,19 +1420,19 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
         // Write status on Label Info
         // Write status on Label Info
         switch metadata.status {
         switch metadata.status {
         case NCGlobal.shared.metadataStatusWaitDownload:
         case NCGlobal.shared.metadataStatusWaitDownload:
-            cell.fileInfoLabel?.text = CCUtility.transformedSize(metadata.size) + " - " + NSLocalizedString("_status_wait_download_", comment: "")
+            cell.fileInfoLabel?.text = NCUtilityFileSystem.shared.transformedSize(metadata.size) + " - " + NSLocalizedString("_status_wait_download_", comment: "")
         case NCGlobal.shared.metadataStatusInDownload:
         case NCGlobal.shared.metadataStatusInDownload:
-            cell.fileInfoLabel?.text = CCUtility.transformedSize(metadata.size) + " - " + NSLocalizedString("_status_in_download_", comment: "")
+            cell.fileInfoLabel?.text = NCUtilityFileSystem.shared.transformedSize(metadata.size) + " - " + NSLocalizedString("_status_in_download_", comment: "")
         case NCGlobal.shared.metadataStatusDownloading:
         case NCGlobal.shared.metadataStatusDownloading:
-            cell.fileInfoLabel?.text = CCUtility.transformedSize(metadata.size) + " - ↓ …"
+            cell.fileInfoLabel?.text = NCUtilityFileSystem.shared.transformedSize(metadata.size) + " - ↓ …"
         case NCGlobal.shared.metadataStatusWaitUpload:
         case NCGlobal.shared.metadataStatusWaitUpload:
-            cell.fileInfoLabel?.text = CCUtility.transformedSize(metadata.size) + " - " + NSLocalizedString("_status_wait_upload_", comment: "")
+            cell.fileInfoLabel?.text = NCUtilityFileSystem.shared.transformedSize(metadata.size) + " - " + NSLocalizedString("_status_wait_upload_", comment: "")
             cell.fileLocalImage?.image = nil
             cell.fileLocalImage?.image = nil
         case NCGlobal.shared.metadataStatusInUpload:
         case NCGlobal.shared.metadataStatusInUpload:
-            cell.fileInfoLabel?.text = CCUtility.transformedSize(metadata.size) + " - " + NSLocalizedString("_status_in_upload_", comment: "")
+            cell.fileInfoLabel?.text = NCUtilityFileSystem.shared.transformedSize(metadata.size) + " - " + NSLocalizedString("_status_in_upload_", comment: "")
             cell.fileLocalImage?.image = nil
             cell.fileLocalImage?.image = nil
         case NCGlobal.shared.metadataStatusUploading:
         case NCGlobal.shared.metadataStatusUploading:
-            cell.fileInfoLabel?.text = CCUtility.transformedSize(metadata.size) + " - ↑ …"
+            cell.fileInfoLabel?.text = NCUtilityFileSystem.shared.transformedSize(metadata.size) + " - ↑ …"
             cell.fileLocalImage?.image = nil
             cell.fileLocalImage?.image = nil
         case NCGlobal.shared.metadataStatusUploadError:
         case NCGlobal.shared.metadataStatusUploadError:
             if metadata.sessionError.isEmpty {
             if metadata.sessionError.isEmpty {
@@ -1458,7 +1455,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             cell.fileLocalImage?.image = nil
             cell.fileLocalImage?.image = nil
             cell.hideButtonShare(true)
             cell.hideButtonShare(true)
             cell.hideButtonMore(true)
             cell.hideButtonMore(true)
-            if let ownerId = NCUtility.shared.getAvatarFromIconUrl(metadata: metadata) {
+            if let ownerId = getAvatarFromIconUrl(metadata: metadata) {
                 cell.fileUser = ownerId
                 cell.fileUser = ownerId
             }
             }
         }
         }
@@ -1706,6 +1703,26 @@ extension NCCollectionViewCommon: EasyTipViewDelegate {
     }
     }
 }
 }
 
 
+extension NCCollectionViewCommon {
+
+    func getAvatarFromIconUrl(metadata: tableMetadata) -> String? {
+
+        var ownerId: String?
+        if metadata.iconUrl.contains("http") && metadata.iconUrl.contains("avatar") {
+            let splitIconUrl = metadata.iconUrl.components(separatedBy: "/")
+            var found: Bool = false
+            for item in splitIconUrl {
+                if found {
+                    ownerId = item
+                    break
+                }
+                if item == "avatar" { found = true}
+            }
+        }
+        return ownerId
+    }
+}
+
 // MARK: -
 // MARK: -
 
 
 class NCOperationUnifiedSearch: ConcurrentOperation {
 class NCOperationUnifiedSearch: ConcurrentOperation {
@@ -1754,9 +1771,9 @@ class NCCollectionViewDownloadThumbnail: ConcurrentOperation {
         self.metadata = tableMetadata.init(value: metadata)
         self.metadata = tableMetadata.init(value: metadata)
         self.cell = cell
         self.cell = cell
         self.collectionView = collectionView
         self.collectionView = collectionView
-        self.fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId, account: metadata.account)!
-        self.fileNamePreviewLocalPath = CCUtility.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)!
-        self.fileNameIconLocalPath = CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)!
+        self.fileNamePath = NCUtilityFileSystem.shared.getFileNamePath(metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId)
+        self.fileNamePreviewLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)
+        self.fileNameIconLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)
     }
     }
 
 
     override func start() {
     override func start() {

+ 1 - 1
iOSClient/Main/Collection Common/NCGridCell.swift

@@ -209,7 +209,7 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
         dateFormatter.timeStyle = .none
         dateFormatter.timeStyle = .none
         dateFormatter.locale = Locale.current
         dateFormatter.locale = Locale.current
 
 
-        labelInfo.text = dateFormatter.string(from: date as Date) + " · " + CCUtility.transformedSize(size)
+        labelInfo.text = dateFormatter.string(from: date as Date) + " · " + NCUtilityFileSystem.shared.transformedSize(size)
     }
     }
 
 
     func setAccessibility(label: String, value: String) {
     func setAccessibility(label: String, value: String) {

+ 1 - 1
iOSClient/Main/Collection Common/NCListCell.swift

@@ -271,7 +271,7 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
     }
     }
 
 
     func writeInfoDateSize(date: NSDate, size: Int64) {
     func writeInfoDateSize(date: NSDate, size: Int64) {
-        labelInfo.text = CCUtility.dateDiff(date as Date) + " · " + CCUtility.transformedSize(size)
+        labelInfo.text = CCUtility.dateDiff(date as Date) + " · " + NCUtilityFileSystem.shared.transformedSize(size)
     }
     }
 
 
     func setAccessibility(label: String, value: String) {
     func setAccessibility(label: String, value: String) {

+ 13 - 13
iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift

@@ -245,10 +245,10 @@ class NCCreateFormUploadConflict: UIViewController {
                 var fileName = metadata.fileNameView
                 var fileName = metadata.fileNameView
                 let fileNameExtension = (fileName as NSString).pathExtension.lowercased()
                 let fileNameExtension = (fileName as NSString).pathExtension.lowercased()
                 let fileNameNoExtension = (fileName as NSString).deletingPathExtension
                 let fileNameNoExtension = (fileName as NSString).deletingPathExtension
-                if fileNameExtension == "heic" && CCUtility.getFormatCompatibility() {
+                if fileNameExtension == "heic" && NCKeychain().formatCompatibility {
                     fileName = fileNameNoExtension + ".jpg"
                     fileName = fileNameNoExtension + ".jpg"
                 }
                 }
-                let oldPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)
+                let oldPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)
                 let newFileName = NCUtilityFileSystem.shared.createFileName(fileName, serverUrl: metadata.serverUrl, account: metadata.account)
                 let newFileName = NCUtilityFileSystem.shared.createFileName(fileName, serverUrl: metadata.serverUrl, account: metadata.account)
 
 
                 metadata.ocId = UUID().uuidString
                 metadata.ocId = UUID().uuidString
@@ -257,8 +257,8 @@ class NCCreateFormUploadConflict: UIViewController {
 
 
                 // This is not an asset - [file]
                 // This is not an asset - [file]
                 if metadata.assetLocalIdentifier.isEmpty || metadata.isExtractFile {
                 if metadata.assetLocalIdentifier.isEmpty || metadata.isExtractFile {
-                    let newPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: newFileName)
-                    CCUtility.moveFile(atPath: oldPath, toPath: newPath)
+                    let newPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: newFileName)
+                    NCUtilityFileSystem.shared.moveFile(atPath: oldPath, toPath: newPath)
                 }
                 }
 
 
                 metadatasNOConflict.append(metadata)
                 metadatasNOConflict.append(metadata)
@@ -323,11 +323,11 @@ extension NCCreateFormUploadConflict: UITableViewDataSource {
             // -----> Already Existing File
             // -----> Already Existing File
 
 
             guard let metadataAlreadyExists = NCManageDatabase.shared.getMetadataConflict(account: metadataNewFile.account, serverUrl: metadataNewFile.serverUrl, fileNameView: metadataNewFile.fileNameView) else { return UITableViewCell() }
             guard let metadataAlreadyExists = NCManageDatabase.shared.getMetadataConflict(account: metadataNewFile.account, serverUrl: metadataNewFile.serverUrl, fileNameView: metadataNewFile.fileNameView) else { return UITableViewCell() }
-            if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconOcId(metadataAlreadyExists.ocId, etag: metadataAlreadyExists.etag)) {
-                cell.imageAlreadyExistingFile.image = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadataAlreadyExists.ocId, etag: metadataAlreadyExists.etag))
-            } else if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageOcId(metadataAlreadyExists.ocId, fileNameView: metadataAlreadyExists.fileNameView)) && metadataAlreadyExists.contentType == "application/pdf" {
+            if FileManager().fileExists(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(metadataAlreadyExists.ocId, etag: metadataAlreadyExists.etag)) {
+                cell.imageAlreadyExistingFile.image = UIImage(contentsOfFile: NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(metadataAlreadyExists.ocId, etag: metadataAlreadyExists.etag))
+            } else if FileManager().fileExists(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadataAlreadyExists.ocId, fileNameView: metadataAlreadyExists.fileNameView)) && metadataAlreadyExists.contentType == "application/pdf" {
 
 
-                let url = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadataAlreadyExists.ocId, fileNameView: metadataAlreadyExists.fileNameView))
+                let url = URL(fileURLWithPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadataAlreadyExists.ocId, fileNameView: metadataAlreadyExists.fileNameView))
                 if let image = NCUtility.shared.pdfThumbnail(url: url) {
                 if let image = NCUtility.shared.pdfThumbnail(url: url) {
                     cell.imageAlreadyExistingFile.image = image
                     cell.imageAlreadyExistingFile.image = image
                 } else {
                 } else {
@@ -341,7 +341,7 @@ extension NCCreateFormUploadConflict: UITableViewDataSource {
                     cell.imageAlreadyExistingFile.image = UIImage(named: metadataAlreadyExists.iconName)
                     cell.imageAlreadyExistingFile.image = UIImage(named: metadataAlreadyExists.iconName)
                 }
                 }
             }
             }
-            cell.labelDetailAlreadyExistingFile.text = CCUtility.dateDiff(metadataAlreadyExists.date as Date) + "\n" + CCUtility.transformedSize(metadataAlreadyExists.size)
+            cell.labelDetailAlreadyExistingFile.text = CCUtility.dateDiff(metadataAlreadyExists.date as Date) + "\n" + NCUtilityFileSystem.shared.transformedSize(metadataAlreadyExists.size)
 
 
             if metadatasConflictAlreadyExistingFiles.contains(metadataNewFile.ocId) {
             if metadatasConflictAlreadyExistingFiles.contains(metadataNewFile.ocId) {
                 cell.switchAlreadyExistingFile.isOn = true
                 cell.switchAlreadyExistingFile.isOn = true
@@ -356,7 +356,7 @@ extension NCCreateFormUploadConflict: UITableViewDataSource {
             } else {
             } else {
                 cell.imageNewFile.image = UIImage(named: metadataNewFile.iconName)
                 cell.imageNewFile.image = UIImage(named: metadataNewFile.iconName)
             }
             }
-            let filePathNewFile = CCUtility.getDirectoryProviderStorageOcId(metadataNewFile.ocId, fileNameView: metadataNewFile.fileNameView)!
+            let filePathNewFile = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadataNewFile.ocId, fileNameView: metadataNewFile.fileNameView)
             if !metadataNewFile.assetLocalIdentifier.isEmpty {
             if !metadataNewFile.assetLocalIdentifier.isEmpty {
 
 
                 let result = PHAsset.fetchAssets(withLocalIdentifiers: [metadataNewFile.assetLocalIdentifier], options: nil)
                 let result = PHAsset.fetchAssets(withLocalIdentifiers: [metadataNewFile.assetLocalIdentifier], options: nil)
@@ -380,7 +380,7 @@ extension NCCreateFormUploadConflict: UITableViewDataSource {
                         let fileDictionary = try FileManager.default.attributesOfItem(atPath: fileNamePath)
                         let fileDictionary = try FileManager.default.attributesOfItem(atPath: fileNamePath)
                         let fileSize = fileDictionary[FileAttributeKey.size] as? Int64 ?? 0
                         let fileSize = fileDictionary[FileAttributeKey.size] as? Int64 ?? 0
 
 
-                        cell.labelDetailNewFile.text = CCUtility.dateDiff(date) + "\n" + CCUtility.transformedSize(fileSize)
+                        cell.labelDetailNewFile.text = CCUtility.dateDiff(date) + "\n" + NCUtilityFileSystem.shared.transformedSize(fileSize)
 
 
                     } catch { print("Error: \(error)") }
                     } catch { print("Error: \(error)") }
 
 
@@ -404,7 +404,7 @@ extension NCCreateFormUploadConflict: UITableViewDataSource {
                                         DispatchQueue.main.async { cell.imageNewFile.image = image }
                                         DispatchQueue.main.async { cell.imageNewFile.image = image }
                                     }
                                     }
                                 }
                                 }
-                                DispatchQueue.main.async { cell.labelDetailNewFile.text = CCUtility.dateDiff(date) + "\n" + CCUtility.transformedSize(fileSize) }
+                                DispatchQueue.main.async { cell.labelDetailNewFile.text = CCUtility.dateDiff(date) + "\n" + NCUtilityFileSystem.shared.transformedSize(fileSize) }
                             } catch { print("Error: \(error)") }
                             } catch { print("Error: \(error)") }
                         }
                         }
                     }
                     }
@@ -423,7 +423,7 @@ extension NCCreateFormUploadConflict: UITableViewDataSource {
                     let fileDictionary = try FileManager.default.attributesOfItem(atPath: filePathNewFile)
                     let fileDictionary = try FileManager.default.attributesOfItem(atPath: filePathNewFile)
                     let fileSize = fileDictionary[FileAttributeKey.size] as? Int64 ?? 0
                     let fileSize = fileDictionary[FileAttributeKey.size] as? Int64 ?? 0
 
 
-                    cell.labelDetailNewFile.text = CCUtility.dateDiff(metadataNewFile.date as Date) + "\n" + CCUtility.transformedSize(fileSize)
+                    cell.labelDetailNewFile.text = CCUtility.dateDiff(metadataNewFile.date as Date) + "\n" + NCUtilityFileSystem.shared.transformedSize(fileSize)
 
 
                 } catch { print("Error: \(error)") }
                 } catch { print("Error: \(error)") }
 
 

+ 5 - 8
iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift

@@ -33,10 +33,7 @@ import XLForm
     @IBOutlet weak var collectionView: UICollectionView!
     @IBOutlet weak var collectionView: UICollectionView!
     @IBOutlet weak var collectionViewHeigth: NSLayoutConstraint!
     @IBOutlet weak var collectionViewHeigth: NSLayoutConstraint!
 
 
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     var editorId = ""
     var editorId = ""
     var creatorId = ""
     var creatorId = ""
     var typeTemplate = ""
     var typeTemplate = ""
@@ -169,7 +166,7 @@ import XLForm
         // image
         // image
         let imagePreview = cell.viewWithTag(100) as? UIImageView
         let imagePreview = cell.viewWithTag(100) as? UIImageView
         if !template.preview.isEmpty {
         if !template.preview.isEmpty {
-            let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + template.name + ".png"
+            let fileNameLocalPath = NCUtilityFileSystem.shared.directoryUserData + "/" + template.name + ".png"
             if FileManager.default.fileExists(atPath: fileNameLocalPath) {
             if FileManager.default.fileExists(atPath: fileNameLocalPath) {
                 let imageURL = URL(fileURLWithPath: fileNameLocalPath)
                 let imageURL = URL(fileURLWithPath: fileNameLocalPath)
                 if let image = UIImage(contentsOfFile: imageURL.path) {
                 if let image = UIImage(contentsOfFile: imageURL.path) {
@@ -279,7 +276,7 @@ import XLForm
 
 
         } else {
         } else {
 
 
-            let fileNamePath = CCUtility.returnFileNamePath(fromFileName: String(describing: fileNameForm), serverUrl: serverUrl, urlBase: appDelegate.urlBase, userId: appDelegate.userId, account: appDelegate.account)!
+            let fileNamePath = NCUtilityFileSystem.shared.getFileNamePath(String(describing: fileNameForm), serverUrl: serverUrl, urlBase: appDelegate.urlBase, userId: appDelegate.userId)
             createDocument(fileNamePath: fileNamePath, fileName: String(describing: fileNameForm))
             createDocument(fileNamePath: fileNamePath, fileName: String(describing: fileNameForm))
         }
         }
     }
     }
@@ -288,7 +285,7 @@ import XLForm
 
 
         if let metadatas {
         if let metadatas {
             let fileName = metadatas[0].fileName
             let fileName = metadatas[0].fileName
-            let fileNamePath = CCUtility.returnFileNamePath(fromFileName: fileName, serverUrl: serverUrl, urlBase: appDelegate.urlBase, userId: appDelegate.userId, account: appDelegate.account)!
+            let fileNamePath = NCUtilityFileSystem.shared.getFileNamePath(fileName, serverUrl: serverUrl, urlBase: appDelegate.urlBase, userId: appDelegate.userId)
             createDocument(fileNamePath: fileNamePath, fileName: fileName)
             createDocument(fileNamePath: fileNamePath, fileName: fileName)
         } else {
         } else {
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
@@ -489,7 +486,7 @@ import XLForm
 
 
     func getImageFromTemplate(name: String, preview: String, indexPath: IndexPath) {
     func getImageFromTemplate(name: String, preview: String, indexPath: IndexPath) {
 
 
-        let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + name + ".png"
+        let fileNameLocalPath = NCUtilityFileSystem.shared.directoryUserData + "/" + name + ".png"
 
 
         NextcloudKit.shared.download(serverUrlFileName: preview, fileNameLocalPath: fileNameLocalPath, requestHandler: { _ in
         NextcloudKit.shared.download(serverUrlFileName: preview, fileNameLocalPath: fileNameLocalPath, requestHandler: { _ in
 
 

+ 4 - 7
iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift

@@ -31,10 +31,7 @@ class NCCreateFormUploadVoiceNote: XLFormViewController, NCSelectDelegate, AVAud
     @IBOutlet weak var labelDuration: UILabel!
     @IBOutlet weak var labelDuration: UILabel!
     @IBOutlet weak var progressView: UIProgressView!
     @IBOutlet weak var progressView: UIProgressView!
 
 
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     private var serverUrl = ""
     private var serverUrl = ""
     private var titleServerUrl = ""
     private var titleServerUrl = ""
     private var fileName = ""
     private var fileName = ""
@@ -170,8 +167,8 @@ class NCCreateFormUploadVoiceNote: XLFormViewController, NCSelectDelegate, AVAud
 
 
             self.form.delegate = nil
             self.form.delegate = nil
 
 
-            if let fileNameNew = formRow.value {
-                self.fileName = CCUtility.removeForbiddenCharactersServer(fileNameNew as? String)
+            if let fileNameNew = formRow.value as? String {
+                self.fileName = NCUtility.shared.removeForbiddenCharacters(fileNameNew)
             }
             }
 
 
             formRow.value = self.fileName
             formRow.value = self.fileName
@@ -259,7 +256,7 @@ class NCCreateFormUploadVoiceNote: XLFormViewController, NCSelectDelegate, AVAud
 
 
     func dismissAndUpload(_ metadata: tableMetadata) {
     func dismissAndUpload(_ metadata: tableMetadata) {
 
 
-        CCUtility.copyFile(atPath: self.fileNamePath, toPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))
+        NCUtilityFileSystem.shared.copyFile(atPath: self.fileNamePath, toPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))
 
 
         NCNetworkingProcessUpload.shared.createProcessUploads(metadatas: [metadata], completion: { _ in })
         NCNetworkingProcessUpload.shared.createProcessUploads(metadatas: [metadata], completion: { _ in })
 
 

+ 9 - 9
iOSClient/Main/Create cloud/NCUploadAssets.swift

@@ -147,9 +147,9 @@ class NCUploadAssets: NSObject, ObservableObject, NCCreateFormUploadConflictDele
 
 
 struct UploadAssetsView: View {
 struct UploadAssetsView: View {
 
 
-    @State private var fileName: String = CCUtility.getFileNameMask(NCGlobal.shared.keyFileNameMask)
-    @State private var isMaintainOriginalFilename: Bool = CCUtility.getOriginalFileName(NCGlobal.shared.keyFileNameOriginal)
-    @State private var isAddFilenametype: Bool = CCUtility.getFileNameType(NCGlobal.shared.keyFileNameType)
+    @State private var fileName: String = NCKeychain().getFileNameMask(key: NCGlobal.shared.keyFileNameMask)
+    @State private var isMaintainOriginalFilename: Bool = NCKeychain().getOriginalFileName(key: NCGlobal.shared.keyFileNameOriginal)
+    @State private var isAddFilenametype: Bool = NCKeychain().getFileNameType(key: NCGlobal.shared.keyFileNameType)
     @State private var isPresentedSelect = false
     @State private var isPresentedSelect = false
     @State private var isPresentedUploadConflict = false
     @State private var isPresentedUploadConflict = false
     @State private var isPresentedQuickLook = false
     @State private var isPresentedQuickLook = false
@@ -185,9 +185,9 @@ struct UploadAssetsView: View {
         var preview: String = ""
         var preview: String = ""
         let creationDate = asset.creationDate ?? Date()
         let creationDate = asset.creationDate ?? Date()
 
 
-        CCUtility.setOriginalFileName(isMaintainOriginalFilename, key: NCGlobal.shared.keyFileNameOriginal)
-        CCUtility.setFileNameType(isAddFilenametype, key: NCGlobal.shared.keyFileNameType)
-        CCUtility.setFileNameMask(fileName, key: NCGlobal.shared.keyFileNameMask)
+        NCKeychain().setOriginalFileName(key: NCGlobal.shared.keyFileNameOriginal, value: isMaintainOriginalFilename)
+        NCKeychain().setFileNameType(key: NCGlobal.shared.keyFileNameType, prefix: isAddFilenametype)
+        NCKeychain().setFileNameMask(key: NCGlobal.shared.keyFileNameMask, mask: fileName)
 
 
         preview = CCUtility.createFileName(
         preview = CCUtility.createFileName(
             getOriginalFilenameForPreview() as String,
             getOriginalFilenameForPreview() as String,
@@ -230,7 +230,7 @@ struct UploadAssetsView: View {
                                        forcedNewFileName: false)!
                                        forcedNewFileName: false)!
             : (previewStore.fileName + "." + ext)
             : (previewStore.fileName + "." + ext)
 
 
-            if previewStore.assetType == .livePhoto && CCUtility.getLivePhoto() && previewStore.data == nil {
+            if previewStore.assetType == .livePhoto && NCKeychain().livePhoto && previewStore.data == nil {
                 livePhoto = true
                 livePhoto = true
             }
             }
 
 
@@ -271,7 +271,7 @@ struct UploadAssetsView: View {
                     metadata.fileName = fileNameNoExtension + ".jpg"
                     metadata.fileName = fileNameNoExtension + ".jpg"
                     metadata.fileNameView = fileNameNoExtension + ".jpg"
                     metadata.fileNameView = fileNameNoExtension + ".jpg"
                 }
                 }
-                let fileNamePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
+                let fileNamePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)
                 do {
                 do {
                     try data.write(to: URL(fileURLWithPath: fileNamePath))
                     try data.write(to: URL(fileURLWithPath: fileNamePath))
                     metadata.isExtractFile = true
                     metadata.isExtractFile = true
@@ -323,7 +323,7 @@ struct UploadAssetsView: View {
     }
     }
 
 
     private func getOriginalFilenameForPreview() -> NSString {
     private func getOriginalFilenameForPreview() -> NSString {
-        CCUtility.setOriginalFileName(isMaintainOriginalFilename, key: NCGlobal.shared.keyFileNameOriginal)
+        NCKeychain().setOriginalFileName(key: NCGlobal.shared.keyFileNameOriginal, value: isMaintainOriginalFilename)
 
 
         if let asset = uploadAssets.assets.first?.phAsset {
         if let asset = uploadAssets.assets.first?.phAsset {
             return asset.originalFilename
             return asset.originalFilename

+ 26 - 28
iOSClient/Main/NCActionCenter.swift

@@ -57,7 +57,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec
             // File do not exists on server, remove in local
             // File do not exists on server, remove in local
             if error.errorCode == NCGlobal.shared.errorResourceNotFound || error.errorCode == NCGlobal.shared.errorBadServerResponse {
             if error.errorCode == NCGlobal.shared.errorResourceNotFound || error.errorCode == NCGlobal.shared.errorBadServerResponse {
                 do {
                 do {
-                    try FileManager.default.removeItem(atPath: CCUtility.getDirectoryProviderStorageOcId(ocId))
+                    try FileManager.default.removeItem(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId))
                 } catch { }
                 } catch { }
                 NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", ocId))
                 NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", ocId))
                 NCManageDatabase.shared.deleteLocalFile(predicate: NSPredicate(format: "ocId == %@", ocId))
                 NCManageDatabase.shared.deleteLocalFile(predicate: NSPredicate(format: "ocId == %@", ocId))
@@ -70,7 +70,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec
 
 
         switch selector {
         switch selector {
         case NCGlobal.shared.selectorLoadFileQuickLook:
         case NCGlobal.shared.selectorLoadFileQuickLook:
-            let fileNamePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
+            let fileNamePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)
             let fileNameTemp = NSTemporaryDirectory() + metadata.fileNameView
             let fileNameTemp = NSTemporaryDirectory() + metadata.fileNameView
             let viewerQuickLook = NCViewerQuickLook(with: URL(fileURLWithPath: fileNameTemp), isEditingEnabled: true, metadata: metadata)
             let viewerQuickLook = NCViewerQuickLook(with: URL(fileURLWithPath: fileNameTemp), isEditingEnabled: true, metadata: metadata)
             if let image = UIImage(contentsOfFile: fileNamePath) {
             if let image = UIImage(contentsOfFile: fileNamePath) {
@@ -85,7 +85,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec
                 navigationController.modalPresentationStyle = .fullScreen
                 navigationController.modalPresentationStyle = .fullScreen
                 appDelegate.window?.rootViewController?.present(navigationController, animated: true)
                 appDelegate.window?.rootViewController?.present(navigationController, animated: true)
             } else {
             } else {
-                CCUtility.copyFile(atPath: fileNamePath, toPath: fileNameTemp)
+                NCUtilityFileSystem.shared.copyFile(atPath: fileNamePath, toPath: fileNameTemp)
                 appDelegate.window?.rootViewController?.present(viewerQuickLook, animated: true)
                 appDelegate.window?.rootViewController?.present(viewerQuickLook, animated: true)
             }
             }
 
 
@@ -98,7 +98,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec
                 self.openDocumentController(metadata: metadata)
                 self.openDocumentController(metadata: metadata)
             } else {
             } else {
                 if let viewController = appDelegate.activeViewController {
                 if let viewController = appDelegate.activeViewController {
-                    let imageIcon = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag))
+                    let imageIcon = UIImage(contentsOfFile: NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag))
                     NCViewer.shared.view(viewController: viewController, metadata: metadata, metadatas: [metadata], imageIcon: imageIcon)
                     NCViewer.shared.view(viewController: viewController, metadata: metadata, metadatas: [metadata], imageIcon: imageIcon)
                 }
                 }
             }
             }
@@ -159,17 +159,15 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec
         var downloadRequest: DownloadRequest?
         var downloadRequest: DownloadRequest?
 
 
         if let metadata = NCManageDatabase.shared.getMetadataFromFileId(fileId) {
         if let metadata = NCManageDatabase.shared.getMetadataFromFileId(fileId) {
-            if let filePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) {
-                do {
-                    let attr = try FileManager.default.attributesOfItem(atPath: filePath)
-                    let fileSize = attr[FileAttributeKey.size] as? UInt64 ?? 0
-                    if fileSize > 0 {
-                        NCViewer.shared.view(viewController: viewController, metadata: metadata, metadatas: [metadata], imageIcon: nil)
-                        return
-                    }
-                } catch {
-                    print("Error: \(error)")
+            do {
+                let attr = try FileManager.default.attributesOfItem(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))
+                let fileSize = attr[FileAttributeKey.size] as? UInt64 ?? 0
+                if fileSize > 0 {
+                    NCViewer.shared.view(viewController: viewController, metadata: metadata, metadatas: [metadata], imageIcon: nil)
+                    return
                 }
                 }
+            } catch {
+                print("Error: \(error)")
             }
             }
         }
         }
 
 
@@ -197,7 +195,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec
                 NCManageDatabase.shared.addMetadata(metadata)
                 NCManageDatabase.shared.addMetadata(metadata)
 
 
                 let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
                 let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
-                let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
+                let fileNameLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)
 
 
                 if metadata.isAudioOrVideo {
                 if metadata.isAudioOrVideo {
                     NCViewer.shared.view(viewController: viewController, metadata: metadata, metadatas: [metadata], imageIcon: nil)
                     NCViewer.shared.view(viewController: viewController, metadata: metadata, metadatas: [metadata], imageIcon: nil)
@@ -296,7 +294,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec
 
 
         guard let appDelegate = UIApplication.shared.delegate as? AppDelegate,
         guard let appDelegate = UIApplication.shared.delegate as? AppDelegate,
               let mainTabBar = appDelegate.mainTabBar else { return }
               let mainTabBar = appDelegate.mainTabBar else { return }
-        let fileURL = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))
+        let fileURL = URL(fileURLWithPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))
 
 
         documentController = UIDocumentInteractionController(url: fileURL)
         documentController = UIDocumentInteractionController(url: fileURL)
         documentController?.presentOptionsMenu(from: mainTabBar.menuRect, in: mainTabBar, animated: true)
         documentController?.presentOptionsMenu(from: mainTabBar.menuRect, in: mainTabBar, animated: true)
@@ -310,8 +308,8 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec
         var downloadMetadata: [(tableMetadata, URL)] = []
         var downloadMetadata: [(tableMetadata, URL)] = []
 
 
         for metadata in metadatas {
         for metadata in metadatas {
-            let fileURL = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))
-            if CCUtility.fileProviderStorageExists(metadata) {
+            let fileURL = URL(fileURLWithPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))
+            if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) {
                 items.append(fileURL)
                 items.append(fileURL)
             } else {
             } else {
                 downloadMetadata.append((metadata, fileURL))
                 downloadMetadata.append((metadata, fileURL))
@@ -325,7 +323,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec
                 } progressHandler: { progress in
                 } progressHandler: { progress in
                     processor.hud?.progress = Float(progress.fractionCompleted)
                     processor.hud?.progress = Float(progress.fractionCompleted)
                 } completion: { _, _ in
                 } completion: { _, _ in
-                    if CCUtility.fileProviderStorageExists(metadata) { items.append(url) }
+                    if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) { items.append(url) }
                     completion()
                     completion()
                 }
                 }
             }
             }
@@ -346,9 +344,9 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec
     func saveAsScan(metadata: tableMetadata) {
     func saveAsScan(metadata: tableMetadata) {
         guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
         guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
 
 
-        let fileNamePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
+        let fileNamePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)
         let fileNameDestination = CCUtility.createFileName("scan.png", fileDate: Date(), fileType: PHAssetMediaType.image, keyFileName: NCGlobal.shared.keyFileNameMask, keyFileNameType: NCGlobal.shared.keyFileNameType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal, forcedNewFileName: true)!
         let fileNameDestination = CCUtility.createFileName("scan.png", fileDate: Date(), fileType: PHAssetMediaType.image, keyFileName: NCGlobal.shared.keyFileNameMask, keyFileNameType: NCGlobal.shared.keyFileNameType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal, forcedNewFileName: true)!
-        let fileNamePathDestination = CCUtility.getDirectoryScan() + "/" + fileNameDestination
+        let fileNamePathDestination = NCUtilityFileSystem.shared.directoryScan + "/" + fileNameDestination
 
 
         NCUtilityFileSystem.shared.copyFile(atPath: fileNamePath, toPath: fileNamePathDestination)
         NCUtilityFileSystem.shared.copyFile(atPath: fileNamePath, toPath: fileNamePathDestination)
 
 
@@ -364,7 +362,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec
 
 
     func printDocument(metadata: tableMetadata) {
     func printDocument(metadata: tableMetadata) {
 
 
-        let fileNameURL = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!)
+        let fileNameURL = URL(fileURLWithPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))
         let printController = UIPrintInteractionController.shared
         let printController = UIPrintInteractionController.shared
         let printInfo = UIPrintInfo(dictionary: nil)
         let printInfo = UIPrintInfo(dictionary: nil)
 
 
@@ -403,7 +401,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec
     func saveAlbum(metadata: tableMetadata) {
     func saveAlbum(metadata: tableMetadata) {
         guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
         guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
 
 
-        let fileNamePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
+        let fileNamePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)
 
 
         NCAskAuthorization.shared.askAuthorizationPhotoLibrary(viewController: appDelegate.mainTabBar?.window?.rootViewController) { hasPermission in
         NCAskAuthorization.shared.askAuthorizationPhotoLibrary(viewController: appDelegate.mainTabBar?.window?.rootViewController) { hasPermission in
             guard hasPermission else {
             guard hasPermission else {
@@ -503,7 +501,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec
             } completionHandler: { account, ocId, etag, _, _, _, afError, error in
             } completionHandler: { account, ocId, etag, _, _, _, afError, error in
                 NCNetworking.shared.uploadRequest.removeValue(forKey: fileNameLocalPath)
                 NCNetworking.shared.uploadRequest.removeValue(forKey: fileNameLocalPath)
                 if error == .success && etag != nil && ocId != nil {
                 if error == .success && etag != nil && ocId != nil {
-                    let toPath = CCUtility.getDirectoryProviderStorageOcId(ocId!, fileNameView: fileName)!
+                    let toPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId!, fileNameView: fileName)
                     NCUtilityFileSystem.shared.moveFile(atPath: fileNameLocalPath, toPath: toPath)
                     NCUtilityFileSystem.shared.moveFile(atPath: fileNameLocalPath, toPath: toPath)
                     NCManageDatabase.shared.addLocalFile(account: account, etag: etag!, ocId: ocId!, fileName: fileName)
                     NCManageDatabase.shared.addLocalFile(account: account, etag: etag!, ocId: ocId!, fileName: fileName)
                     NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSourceNetworkForced)
                     NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSourceNetworkForced)
@@ -523,10 +521,10 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec
                 guard !results.ext.isEmpty,
                 guard !results.ext.isEmpty,
                       let data = UIPasteboard.general.data(forPasteboardType: item.key, inItemSet: IndexSet([index]))?.first
                       let data = UIPasteboard.general.data(forPasteboardType: item.key, inItemSet: IndexSet([index]))?.first
                 else { continue }
                 else { continue }
-                let fileName = results.name + "_" + CCUtility.getIncrementalNumber() + "." + results.ext
+                let fileName = results.name + "_" + NCKeychain().incrementalNumber + "." + results.ext
                 let serverUrlFileName = serverUrl + "/" + fileName
                 let serverUrlFileName = serverUrl + "/" + fileName
                 let ocIdUpload = UUID().uuidString
                 let ocIdUpload = UUID().uuidString
-                let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(ocIdUpload, fileNameView: fileName)!
+                let fileNameLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocIdUpload, fileNameView: fileName)
                 do { try data.write(to: URL(fileURLWithPath: fileNameLocalPath)) } catch { continue }
                 do { try data.write(to: URL(fileURLWithPath: fileNameLocalPath)) } catch { continue }
                 processor.execute { completion in
                 processor.execute { completion in
                     uploadPastePasteboard(fileName: fileName, serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, serverUrl: serverUrl, completion: completion)
                     uploadPastePasteboard(fileName: fileName, serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, serverUrl: serverUrl, completion: completion)
@@ -699,8 +697,8 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec
 fileprivate extension tableMetadata {
 fileprivate extension tableMetadata {
     func toPasteBoardItem() -> [String: Any]? {
     func toPasteBoardItem() -> [String: Any]? {
         // Get Data
         // Get Data
-        let fileUrl = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView))
-        guard CCUtility.fileProviderStorageExists(self),
+        let fileUrl = URL(fileURLWithPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView))
+        guard NCUtilityFileSystem.shared.fileProviderStorageExists(self),
               let data = try? Data(contentsOf: fileUrl),
               let data = try? Data(contentsOf: fileUrl),
               let unmanagedFileUTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension as CFString, nil)
               let unmanagedFileUTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension as CFString, nil)
         else { return nil }
         else { return nil }

+ 1 - 5
iOSClient/Main/NCMainTabBar.swift

@@ -28,11 +28,7 @@ class NCMainTabBar: UITabBar {
 
 
     private var fillColor: UIColor!
     private var fillColor: UIColor!
     private var shapeLayer: CALayer?
     private var shapeLayer: CALayer?
-
-    // swiftlint:disable force_cast
-    private let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     private let centerButtonY: CGFloat = -28
     private let centerButtonY: CGFloat = -28
 
 
     public var menuRect: CGRect {
     public var menuRect: CGRect {

+ 3 - 9
iOSClient/Main/NCPickerViewController.swift

@@ -31,10 +31,7 @@ import NextcloudKit
 
 
 class NCPhotosPickerViewController: NSObject {
 class NCPhotosPickerViewController: NSObject {
 
 
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     var sourceViewController: UIViewController
     var sourceViewController: UIViewController
     var maxSelectedAssets = 1
     var maxSelectedAssets = 1
     var singleSelectedMode = false
     var singleSelectedMode = false
@@ -118,10 +115,7 @@ class customPhotoPickerViewController: TLPhotosPickerViewController {
 
 
 class NCDocumentPickerViewController: NSObject, UIDocumentPickerDelegate {
 class NCDocumentPickerViewController: NSObject, UIDocumentPickerDelegate {
 
 
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     var isViewerMedia: Bool
     var isViewerMedia: Bool
     var viewController: UIViewController?
     var viewController: UIViewController?
 
 
@@ -168,7 +162,7 @@ class NCDocumentPickerViewController: NSObject, UIDocumentPickerDelegate {
                 let ocId = NSUUID().uuidString
                 let ocId = NSUUID().uuidString
 
 
                 let fileName = urlIn.lastPathComponent
                 let fileName = urlIn.lastPathComponent
-                let toPath = CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileName)!
+                let toPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId, fileNameView: fileName)
                 let urlOut = URL(fileURLWithPath: toPath)
                 let urlOut = URL(fileURLWithPath: toPath)
 
 
                 guard self.copySecurityScopedResource(url: urlIn, urlOut: urlOut) != nil else { continue }
                 guard self.copySecurityScopedResource(url: urlIn, urlOut: urlOut) != nil else { continue }

+ 2 - 2
iOSClient/Main/Section Header Footer/NCSectionHeaderMenu.swift

@@ -319,9 +319,9 @@ class NCSectionFooter: UICollectionReusableView, NCSectionFooterDelegate {
         }
         }
 
 
         if files > 1 {
         if files > 1 {
-            filesText = "\(files) " + NSLocalizedString("_files_", comment: "") + " " + CCUtility.transformedSize(size)
+            filesText = "\(files) " + NSLocalizedString("_files_", comment: "") + " " + NCUtilityFileSystem.shared.transformedSize(size)
         } else if files == 1 {
         } else if files == 1 {
-            filesText = "1 " + NSLocalizedString("_file_", comment: "") + " " + CCUtility.transformedSize(size)
+            filesText = "1 " + NSLocalizedString("_file_", comment: "") + " " + NCUtilityFileSystem.shared.transformedSize(size)
         }
         }
 
 
         if foldersText.isEmpty {
         if foldersText.isEmpty {

+ 15 - 16
iOSClient/Media/NCMedia.swift

@@ -35,9 +35,7 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate {
     private var gridLayout: NCGridMediaLayout!
     private var gridLayout: NCGridMediaLayout!
     internal var documentPickerViewController: NCDocumentPickerViewController?
     internal var documentPickerViewController: NCDocumentPickerViewController?
 
 
-    // swiftlint:disable force_cast
-    internal let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
+    internal let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
 
 
     //private var account: String = ""
     //private var account: String = ""
 
 
@@ -81,7 +79,7 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate {
         collectionView.backgroundColor = .systemBackground
         collectionView.backgroundColor = .systemBackground
 
 
         gridLayout = NCGridMediaLayout()
         gridLayout = NCGridMediaLayout()
-        gridLayout.itemForLine = CGFloat(min(CCUtility.getMediaWidthImage(), 5))
+        gridLayout.itemForLine = CGFloat(min(NCKeychain().mediaWidthImage, 5))
         gridLayout.sectionHeadersPinToVisibleBounds = true
         gridLayout.sectionHeadersPinToVisibleBounds = true
 
 
         collectionView.collectionViewLayout = gridLayout
         collectionView.collectionViewLayout = gridLayout
@@ -243,7 +241,7 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate {
             }
             }
 
 
             self.collectionView.collectionViewLayout.invalidateLayout()
             self.collectionView.collectionViewLayout.invalidateLayout()
-            CCUtility.setMediaWidthImage(Int(self.gridLayout.itemForLine))
+            NCKeychain().mediaWidthImage = Int(self.gridLayout.itemForLine)
         })
         })
     }
     }
 
 
@@ -259,7 +257,7 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate {
             }
             }
 
 
             self.collectionView.collectionViewLayout.invalidateLayout()
             self.collectionView.collectionViewLayout.invalidateLayout()
-            CCUtility.setMediaWidthImage(Int(self.gridLayout.itemForLine))
+            NCKeychain().mediaWidthImage = Int(self.gridLayout.itemForLine)
         })
         })
     }
     }
 
 
@@ -273,8 +271,9 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate {
     func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String, items: [Any], indexPath: [IndexPath], overwrite: Bool, copy: Bool, move: Bool) {
     func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String, items: [Any], indexPath: [IndexPath], overwrite: Bool, copy: Bool, move: Bool) {
 
 
         guard let serverUrl = serverUrl else { return }
         guard let serverUrl = serverUrl else { return }
-        let path = CCUtility.returnPathfromServerUrl(serverUrl, urlBase: appDelegate.urlBase, userId: appDelegate.userId, account: appDelegate.account) ?? ""
-            NCManageDatabase.shared.setAccountMediaPath(path, account: appDelegate.account)
+        let home = NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, userId: appDelegate.userId)
+        let path = serverUrl.replacingOccurrences(of: home, with: "")
+        NCManageDatabase.shared.setAccountMediaPath(path, account: appDelegate.account)
         reloadDataSourceWithCompletion { _ in
         reloadDataSourceWithCompletion { _ in
             self.searchNewMedia()
             self.searchNewMedia()
         }
         }
@@ -390,14 +389,14 @@ extension NCMedia: UICollectionViewDataSource {
             if let image = NCMediaCache.shared.getImage(ocId: metadata.ocId) {
             if let image = NCMediaCache.shared.getImage(ocId: metadata.ocId) {
                 cell.imageItem.backgroundColor = nil
                 cell.imageItem.backgroundColor = nil
                 cell.imageItem.image = image
                 cell.imageItem.image = image
-            } else if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)) {
-                if let image = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)) {
+            } else if FileManager().fileExists(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)) {
+                if let image = UIImage(contentsOfFile: NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)) {
                     cell.imageItem.backgroundColor = nil
                     cell.imageItem.backgroundColor = nil
                     cell.imageItem.image = image
                     cell.imageItem.image = image
                     NCMediaCache.shared.setImage(ocId: metadata.ocId, image: image)
                     NCMediaCache.shared.setImage(ocId: metadata.ocId, image: image)
                 }
                 }
             } else {
             } else {
-                if metadata.hasPreview && metadata.status == NCGlobal.shared.metadataStatusNormal && (!CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag)) {
+                if metadata.hasPreview && metadata.status == NCGlobal.shared.metadataStatusNormal && (!NCUtilityFileSystem.shared.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag)) {
                     if appDelegate.downloadThumbnailQueue.operations.filter({ ($0 as? NCMediaDownloadThumbnaill)?.metadata.ocId == metadata.ocId }).isEmpty {
                     if appDelegate.downloadThumbnailQueue.operations.filter({ ($0 as? NCMediaDownloadThumbnaill)?.metadata.ocId == metadata.ocId }).isEmpty {
                         appDelegate.downloadThumbnailQueue.addOperation(NCMediaDownloadThumbnaill(metadata: metadata, cell: cell, collectionView: collectionView))
                         appDelegate.downloadThumbnailQueue.addOperation(NCMediaDownloadThumbnaill(metadata: metadata, cell: cell, collectionView: collectionView))
                     }
                     }
@@ -502,7 +501,7 @@ extension NCMedia {
 
 
         let options = NKRequestOptions(timeout: 300, queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)
         let options = NKRequestOptions(timeout: 300, queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)
 
 
-        NextcloudKit.shared.searchMedia(path: mediaPath, lessDate: lessDate, greaterDate: greaterDate, elementDate: "d:getlastmodified/", limit: limit, showHiddenFiles: CCUtility.getShowHiddenFiles(), options: options) { account, files, _, error in
+        NextcloudKit.shared.searchMedia(path: mediaPath, lessDate: lessDate, greaterDate: greaterDate, elementDate: "d:getlastmodified/", limit: limit, showHiddenFiles: NCKeychain().showHiddenFiles, options: options) { account, files, _, error in
 
 
             self.oldInProgress = false
             self.oldInProgress = false
             DispatchQueue.main.async {
             DispatchQueue.main.async {
@@ -585,7 +584,7 @@ extension NCMedia {
 
 
             let options = NKRequestOptions(timeout: 300, queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)
             let options = NKRequestOptions(timeout: 300, queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)
 
 
-            NextcloudKit.shared.searchMedia(path: self.mediaPath, lessDate: lessDate, greaterDate: greaterDate, elementDate: "d:getlastmodified/", limit: limit, showHiddenFiles: CCUtility.getShowHiddenFiles(), options: options) { account, files, _, error in
+            NextcloudKit.shared.searchMedia(path: self.mediaPath, lessDate: lessDate, greaterDate: greaterDate, elementDate: "d:getlastmodified/", limit: limit, showHiddenFiles: NCKeychain().showHiddenFiles, options: options) { account, files, _, error in
 
 
                 self.newInProgress = false
                 self.newInProgress = false
                 DispatchQueue.main.async {
                 DispatchQueue.main.async {
@@ -817,9 +816,9 @@ class NCMediaDownloadThumbnaill: ConcurrentOperation {
         self.metadata = tableMetadata.init(value: metadata)
         self.metadata = tableMetadata.init(value: metadata)
         self.cell = cell
         self.cell = cell
         self.collectionView = collectionView
         self.collectionView = collectionView
-        self.fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId, account: metadata.account)!
-        self.fileNamePreviewLocalPath = CCUtility.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)!
-        self.fileNameIconLocalPath = CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)!
+        self.fileNamePath = NCUtilityFileSystem.shared.getFileNamePath(metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId)
+        self.fileNamePreviewLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)
+        self.fileNameIconLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)
     }
     }
 
 
     override func start() {
     override func start() {

+ 4 - 4
iOSClient/Media/NCMediaCache.swift

@@ -48,7 +48,7 @@ import NextcloudKit
         metadatas.removeAll()
         metadatas.removeAll()
         getMetadatasMedia(account: account)
         getMetadatasMedia(account: account)
 
 
-        guard !metadatas.isEmpty, let directory = CCUtility.getDirectoryProviderStorage() else { return }
+        guard !metadatas.isEmpty else { return }
         let ext = ".preview.ico"
         let ext = ".preview.ico"
         let manager = FileManager.default
         let manager = FileManager.default
         let resourceKeys = Set<URLResourceKey>([.nameKey, .pathKey, .fileSizeKey, .creationDateKey])
         let resourceKeys = Set<URLResourceKey>([.nameKey, .pathKey, .fileSizeKey, .creationDateKey])
@@ -64,7 +64,7 @@ import NextcloudKit
             ocIdEtag[metadata.ocId] = metadata.etag
             ocIdEtag[metadata.ocId] = metadata.etag
         }
         }
 
 
-        if let enumerator = manager.enumerator(at: URL(fileURLWithPath: directory), includingPropertiesForKeys: [.isRegularFileKey], options: [.skipsHiddenFiles]) {
+        if let enumerator = manager.enumerator(at: URL(fileURLWithPath: NCUtilityFileSystem.shared.directoryProviderStorage), includingPropertiesForKeys: [.isRegularFileKey], options: [.skipsHiddenFiles]) {
             for case let fileURL as URL in enumerator where fileURL.lastPathComponent.hasSuffix(ext) {
             for case let fileURL as URL in enumerator where fileURL.lastPathComponent.hasSuffix(ext) {
                 let fileName = fileURL.lastPathComponent
                 let fileName = fileURL.lastPathComponent
                 let ocId = fileURL.deletingLastPathComponent().lastPathComponent
                 let ocId = fileURL.deletingLastPathComponent().lastPathComponent
@@ -136,10 +136,10 @@ import NextcloudKit
 
 
         guard let predicate = predicate else { return }
         guard let predicate = predicate else { return }
 
 
-        livePhoto = CCUtility.getLivePhoto()
+        livePhoto = NCKeychain().livePhoto
         metadatas = NCManageDatabase.shared.getMetadatasMedia(predicate: predicate, livePhoto: livePhoto)
         metadatas = NCManageDatabase.shared.getMetadatasMedia(predicate: predicate, livePhoto: livePhoto)
 
 
-        switch CCUtility.getMediaSortDate() {
+        switch NCKeychain().mediaSortDate {
         case "date":
         case "date":
             metadatas = self.metadatas.sorted(by: {($0.date as Date) > ($1.date as Date)})
             metadatas = self.metadatas.sorted(by: {($0.date as Date) > ($1.date as Date)})
         case "creationDate":
         case "creationDate":

+ 5 - 9
iOSClient/Menu/AppDelegate+Menu.swift

@@ -32,11 +32,7 @@ extension AppDelegate {
     func toggleMenu(viewController: UIViewController) {
     func toggleMenu(viewController: UIViewController) {
 
 
         var actions: [NCMenuAction] = []
         var actions: [NCMenuAction] = []
-
-        // swiftlint:disable force_cast
-        let appDelegate = UIApplication.shared.delegate as! AppDelegate
-        // swiftlint:enable force_cast
-
+        let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
         let directEditingCreators = NCManageDatabase.shared.getDirectEditingCreators(account: appDelegate.account)
         let directEditingCreators = NCManageDatabase.shared.getDirectEditingCreators(account: appDelegate.account)
         let isDirectoryE2EE = NCUtility.shared.isDirectoryE2EE(serverUrl: appDelegate.activeServerUrl, userBase: appDelegate)
         let isDirectoryE2EE = NCUtility.shared.isDirectoryE2EE(serverUrl: appDelegate.activeServerUrl, userBase: appDelegate)
         let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, appDelegate.activeServerUrl))
         let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, appDelegate.activeServerUrl))
@@ -99,7 +95,7 @@ extension AppDelegate {
                 title: NSLocalizedString("_create_voice_memo_", comment: ""), icon: UIImage(named: "microphone")!.image(color: UIColor.systemGray, size: 50), action: { _ in
                 title: NSLocalizedString("_create_voice_memo_", comment: ""), icon: UIImage(named: "microphone")!.image(color: UIColor.systemGray, size: 50), action: { _ in
                     NCAskAuthorization.shared.askAuthorizationAudioRecord(viewController: viewController) { hasPermission in
                     NCAskAuthorization.shared.askAuthorizationAudioRecord(viewController: viewController) { hasPermission in
                         if hasPermission {
                         if hasPermission {
-                            let fileName = CCUtility.createFileNameDate(NSLocalizedString("_voice_memo_filename_", comment: ""), extension: "m4a")!
+                            let fileName = NCUtilityFileSystem.shared.createFileNameDate(NSLocalizedString("_voice_memo_filename_", comment: ""), ext: "m4a")
                             if let viewController = UIStoryboard(name: "NCAudioRecorderViewController", bundle: nil).instantiateInitialViewController() as? NCAudioRecorderViewController {
                             if let viewController = UIStoryboard(name: "NCAudioRecorderViewController", bundle: nil).instantiateInitialViewController() as? NCAudioRecorderViewController {
 
 
                                 viewController.delegate = self
                                 viewController.delegate = self
@@ -115,7 +111,7 @@ extension AppDelegate {
             )
             )
         )
         )
 
 
-        if CCUtility.isEnd(toEndEnabled: appDelegate.account) {
+        if NCKeychain().isEndToEndEnabled(account: appDelegate.account) {
             actions.append(.seperator(order: 0))
             actions.append(.seperator(order: 0))
         }
         }
 
 
@@ -132,7 +128,7 @@ extension AppDelegate {
         )
         )
 
 
         // Folder encrypted
         // Folder encrypted
-        if !isDirectoryE2EE && CCUtility.isEnd(toEndEnabled: appDelegate.account) {
+        if !isDirectoryE2EE && NCKeychain().isEndToEndEnabled(account: appDelegate.account) {
             actions.append(
             actions.append(
                 NCMenuAction(title: NSLocalizedString("_create_folder_e2ee_", comment: ""),
                 NCMenuAction(title: NSLocalizedString("_create_folder_e2ee_", comment: ""),
                              icon: UIImage(named: "folderEncrypted")!.image(color: NCBrandColor.shared.brandElement, size: 50),
                              icon: UIImage(named: "folderEncrypted")!.image(color: NCBrandColor.shared.brandElement, size: 50),
@@ -144,7 +140,7 @@ extension AppDelegate {
             )
             )
         }
         }
 
 
-        if CCUtility.isEnd(toEndEnabled: appDelegate.account) {
+        if NCKeychain().isEndToEndEnabled(account: appDelegate.account) {
             actions.append(.seperator(order: 0))
             actions.append(.seperator(order: 0))
         }
         }
 
 

+ 2 - 2
iOSClient/Menu/NCCollectionViewCommon+Menu.swift

@@ -286,7 +286,7 @@ extension NCCollectionViewCommon {
                     icon: NCUtility.shared.loadImage(named: "viewfinder.circle"),
                     icon: NCUtility.shared.loadImage(named: "viewfinder.circle"),
                     order: 110,
                     order: 110,
                     action: { _ in
                     action: { _ in
-                        if CCUtility.fileProviderStorageExists(metadata) {
+                        if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) {
                             NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedFile, userInfo: ["ocId": metadata.ocId, "selector": NCGlobal.shared.selectorSaveAsScan, "error": NKError(), "account": metadata.account])
                             NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedFile, userInfo: ["ocId": metadata.ocId, "selector": NCGlobal.shared.selectorSaveAsScan, "error": NKError(), "account": metadata.account])
                         } else {
                         } else {
                             NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorSaveAsScan) { _, _ in }
                             NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorSaveAsScan) { _, _ in }
@@ -346,7 +346,7 @@ extension NCCollectionViewCommon {
                     icon: NCUtility.shared.loadImage(named: "pencil.tip.crop.circle"),
                     icon: NCUtility.shared.loadImage(named: "pencil.tip.crop.circle"),
                     order: 150,
                     order: 150,
                     action: { _ in
                     action: { _ in
-                        if CCUtility.fileProviderStorageExists(metadata) {
+                        if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) {
                             NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedFile, userInfo: ["ocId": metadata.ocId, "selector": NCGlobal.shared.selectorLoadFileQuickLook, "error": NKError(), "account": metadata.account])
                             NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedFile, userInfo: ["ocId": metadata.ocId, "selector": NCGlobal.shared.selectorLoadFileQuickLook, "error": NKError(), "account": metadata.account])
                         } else {
                         } else {
                             NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorLoadFileQuickLook) { _, _ in }
                             NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorLoadFileQuickLook) { _, _ in }

+ 3 - 3
iOSClient/Menu/NCContextMenu.swift

@@ -70,7 +70,7 @@ class NCContextMenu: NSObject {
 
 
         let openIn = UIAction(title: NSLocalizedString("_open_in_", comment: ""),
         let openIn = UIAction(title: NSLocalizedString("_open_in_", comment: ""),
                               image: UIImage(systemName: "square.and.arrow.up") ) { _ in
                               image: UIImage(systemName: "square.and.arrow.up") ) { _ in
-            if CCUtility.fileProviderStorageExists(metadata) {
+            if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) {
                 NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedFile, userInfo: ["ocId": metadata.ocId, "selector": NCGlobal.shared.selectorOpenIn, "error": NKError(), "account": metadata.account])
                 NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedFile, userInfo: ["ocId": metadata.ocId, "selector": NCGlobal.shared.selectorOpenIn, "error": NKError(), "account": metadata.account])
             } else {
             } else {
                 hud.show(in: viewController.view)
                 hud.show(in: viewController.view)
@@ -102,7 +102,7 @@ class NCContextMenu: NSObject {
                     appDelegate.saveLivePhotoQueue.addOperation(NCOperationSaveLivePhoto(metadata: metadata, metadataMOV: metadataMOV))
                     appDelegate.saveLivePhotoQueue.addOperation(NCOperationSaveLivePhoto(metadata: metadata, metadataMOV: metadataMOV))
                 }
                 }
             } else {
             } else {
-                if CCUtility.fileProviderStorageExists(metadata) {
+                if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) {
                     NCActionCenter.shared.saveAlbum(metadata: metadata)
                     NCActionCenter.shared.saveAlbum(metadata: metadata)
                 } else {
                 } else {
                     hud.show(in: viewController.view)
                     hud.show(in: viewController.view)
@@ -125,7 +125,7 @@ class NCContextMenu: NSObject {
 
 
         let modify = UIAction(title: NSLocalizedString("_modify_", comment: ""),
         let modify = UIAction(title: NSLocalizedString("_modify_", comment: ""),
                               image: UIImage(systemName: "pencil.tip.crop.circle")) { _ in
                               image: UIImage(systemName: "pencil.tip.crop.circle")) { _ in
-            if CCUtility.fileProviderStorageExists(metadata) {
+            if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) {
                 NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedFile, userInfo: ["ocId": metadata.ocId, "selector": NCGlobal.shared.selectorLoadFileQuickLook, "error": NKError(), "account": metadata.account])
                 NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedFile, userInfo: ["ocId": metadata.ocId, "selector": NCGlobal.shared.selectorLoadFileQuickLook, "error": NKError(), "account": metadata.account])
             } else {
             } else {
                 hud.show(in: viewController.view)
                 hud.show(in: viewController.view)

+ 6 - 6
iOSClient/Menu/NCMedia+Menu.swift

@@ -146,10 +146,10 @@ extension NCMedia {
                 NCMenuAction(
                 NCMenuAction(
                     title: NSLocalizedString("_media_by_modified_date_", comment: ""),
                     title: NSLocalizedString("_media_by_modified_date_", comment: ""),
                     icon: NCUtility.shared.loadImage(named: "circle.grid.cross.up.fill"),
                     icon: NCUtility.shared.loadImage(named: "circle.grid.cross.up.fill"),
-                    selected: CCUtility.getMediaSortDate() == "date",
+                    selected: NCKeychain().mediaSortDate == "date",
                     on: true,
                     on: true,
                     action: { _ in
                     action: { _ in
-                        CCUtility.setMediaSortDate("date")
+                        NCKeychain().mediaSortDate = "date"
                         self.reloadDataSourceWithCompletion { _ in }
                         self.reloadDataSourceWithCompletion { _ in }
                     }
                     }
                 )
                 )
@@ -159,10 +159,10 @@ extension NCMedia {
                 NCMenuAction(
                 NCMenuAction(
                     title: NSLocalizedString("_media_by_created_date_", comment: ""),
                     title: NSLocalizedString("_media_by_created_date_", comment: ""),
                     icon: NCUtility.shared.loadImage(named: "circle.grid.cross.down.fill"),
                     icon: NCUtility.shared.loadImage(named: "circle.grid.cross.down.fill"),
-                    selected: CCUtility.getMediaSortDate() == "creationDate",
+                    selected: NCKeychain().mediaSortDate == "creationDate",
                     on: true,
                     on: true,
                     action: { _ in
                     action: { _ in
-                        CCUtility.setMediaSortDate("creationDate")
+                        NCKeychain().mediaSortDate = "creationDate"
                         self.reloadDataSourceWithCompletion { _ in }
                         self.reloadDataSourceWithCompletion { _ in }
                     }
                     }
                 )
                 )
@@ -172,10 +172,10 @@ extension NCMedia {
                 NCMenuAction(
                 NCMenuAction(
                     title: NSLocalizedString("_media_by_upload_date_", comment: ""),
                     title: NSLocalizedString("_media_by_upload_date_", comment: ""),
                     icon: NCUtility.shared.loadImage(named: "circle.grid.cross.right.fill"),
                     icon: NCUtility.shared.loadImage(named: "circle.grid.cross.right.fill"),
-                    selected: CCUtility.getMediaSortDate() == "uploadDate",
+                    selected: NCKeychain().mediaSortDate == "uploadDate",
                     on: true,
                     on: true,
                     action: { _ in
                     action: { _ in
-                        CCUtility.setMediaSortDate("uploadDate")
+                        NCKeychain().mediaSortDate = "uploadDate"
                         self.reloadDataSourceWithCompletion { _ in }
                         self.reloadDataSourceWithCompletion { _ in }
                     }
                     }
                 )
                 )

+ 2 - 2
iOSClient/Menu/NCMenuAction.swift

@@ -226,7 +226,7 @@ extension NCMenuAction {
                             appDelegate.saveLivePhotoQueue.addOperation(NCOperationSaveLivePhoto(metadata: metadata, metadataMOV: metadataMOV))
                             appDelegate.saveLivePhotoQueue.addOperation(NCOperationSaveLivePhoto(metadata: metadata, metadataMOV: metadataMOV))
                         }
                         }
                     } else {
                     } else {
-                        if CCUtility.fileProviderStorageExists(metadata) {
+                        if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) {
                             NCActionCenter.shared.saveAlbum(metadata: metadata)
                             NCActionCenter.shared.saveAlbum(metadata: metadata)
                         } else {
                         } else {
                             if let appDelegate = (UIApplication.shared.delegate as? AppDelegate), appDelegate.downloadQueue.operations.filter({ ($0 as? NCOperationDownload)?.metadata.ocId == metadata.ocId }).isEmpty {
                             if let appDelegate = (UIApplication.shared.delegate as? AppDelegate), appDelegate.downloadQueue.operations.filter({ ($0 as? NCOperationDownload)?.metadata.ocId == metadata.ocId }).isEmpty {
@@ -286,7 +286,7 @@ extension NCMenuAction {
             icon: NCUtility.shared.loadImage(named: "printer"),
             icon: NCUtility.shared.loadImage(named: "printer"),
             order: order,
             order: order,
             action: { _ in
             action: { _ in
-                if CCUtility.fileProviderStorageExists(metadata) {
+                if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) {
                     NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedFile, userInfo: ["ocId": metadata.ocId, "selector": NCGlobal.shared.selectorPrint, "error": NKError(), "account": metadata.account])
                     NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedFile, userInfo: ["ocId": metadata.ocId, "selector": NCGlobal.shared.selectorPrint, "error": NKError(), "account": metadata.account])
                 } else {
                 } else {
                     NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorPrint) { _, _ in }
                     NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorPrint) { _, _ in }

+ 2 - 2
iOSClient/Menu/NCOperationSaveLivePhoto.swift

@@ -85,8 +85,8 @@ class NCOperationSaveLivePhoto: ConcurrentOperation {
 
 
     func saveLivePhotoToDisk(metadata: tableMetadata, metadataMov: tableMetadata) {
     func saveLivePhotoToDisk(metadata: tableMetadata, metadataMov: tableMetadata) {
 
 
-        let fileNameImage = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!)
-        let fileNameMov = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadataMov.ocId, fileNameView: metadataMov.fileNameView)!)
+        let fileNameImage = URL(fileURLWithPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))
+        let fileNameMov = URL(fileURLWithPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadataMov.ocId, fileNameView: metadataMov.fileNameView))
 
 
         DispatchQueue.main.async {
         DispatchQueue.main.async {
             self.hud.textLabel.text = NSLocalizedString("_livephoto_save_", comment: "")
             self.hud.textLabel.text = NSLocalizedString("_livephoto_save_", comment: "")

+ 1 - 1
iOSClient/Menu/NCTrash+Menu.swift

@@ -121,7 +121,7 @@ extension NCTrash {
         var actions: [NCMenuAction] = []
         var actions: [NCMenuAction] = []
 
 
         var iconHeader: UIImage!
         var iconHeader: UIImage!
-        if let icon = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(tableTrash.fileId, etag: tableTrash.fileName)) {
+        if let icon = UIImage(contentsOfFile: NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(tableTrash.fileId, etag: tableTrash.fileName)) {
             iconHeader = icon
             iconHeader = icon
         } else {
         } else {
             if tableTrash.directory {
             if tableTrash.directory {

+ 4 - 4
iOSClient/Menu/NCViewer+Menu.swift

@@ -110,7 +110,7 @@ extension NCViewer {
                     title: NSLocalizedString("_print_", comment: ""),
                     title: NSLocalizedString("_print_", comment: ""),
                     icon: NCUtility.shared.loadImage(named: "printer"),
                     icon: NCUtility.shared.loadImage(named: "printer"),
                     action: { _ in
                     action: { _ in
-                        if CCUtility.fileProviderStorageExists(metadata) {
+                        if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) {
                             NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedFile, userInfo: ["ocId": metadata.ocId, "selector": NCGlobal.shared.selectorPrint, "error": NKError(), "account": metadata.account])
                             NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedFile, userInfo: ["ocId": metadata.ocId, "selector": NCGlobal.shared.selectorPrint, "error": NKError(), "account": metadata.account])
                         } else {
                         } else {
                             NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorPrint) { _, _ in }
                             NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorPrint) { _, _ in }
@@ -157,7 +157,7 @@ extension NCViewer {
                     title: NSLocalizedString("_save_as_scan_", comment: ""),
                     title: NSLocalizedString("_save_as_scan_", comment: ""),
                     icon: NCUtility.shared.loadImage(named: "viewfinder.circle"),
                     icon: NCUtility.shared.loadImage(named: "viewfinder.circle"),
                     action: { _ in
                     action: { _ in
-                        if CCUtility.fileProviderStorageExists(metadata) {
+                        if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) {
                             NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedFile, userInfo: ["ocId": metadata.ocId, "selector": NCGlobal.shared.selectorSaveAsScan, "error": NKError(), "account": metadata.account])
                             NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedFile, userInfo: ["ocId": metadata.ocId, "selector": NCGlobal.shared.selectorSaveAsScan, "error": NKError(), "account": metadata.account])
                         } else {
                         } else {
                             NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorSaveAsScan) { _, _ in }
                             NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorSaveAsScan) { _, _ in }
@@ -210,7 +210,7 @@ extension NCViewer {
         //
         //
         // DOWNLOAD LOCALLY
         // DOWNLOAD LOCALLY
         //
         //
-        if !webView, metadata.session.isEmpty, !CCUtility.fileProviderStorageExists(metadata) {
+        if !webView, metadata.session.isEmpty, !NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) {
             actions.append(
             actions.append(
                 NCMenuAction(
                 NCMenuAction(
                     title: NSLocalizedString("_download_locally_", comment: ""),
                     title: NSLocalizedString("_download_locally_", comment: ""),
@@ -256,7 +256,7 @@ extension NCViewer {
                     title: NSLocalizedString("_modify_", comment: ""),
                     title: NSLocalizedString("_modify_", comment: ""),
                     icon: NCUtility.shared.loadImage(named: "pencil.tip.crop.circle"),
                     icon: NCUtility.shared.loadImage(named: "pencil.tip.crop.circle"),
                     action: { _ in
                     action: { _ in
-                        if CCUtility.fileProviderStorageExists(metadata) {
+                        if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) {
                             NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedFile, userInfo: ["ocId": metadata.ocId, "selector": NCGlobal.shared.selectorLoadFileQuickLook, "error": NKError(), "account": metadata.account])
                             NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedFile, userInfo: ["ocId": metadata.ocId, "selector": NCGlobal.shared.selectorLoadFileQuickLook, "error": NKError(), "account": metadata.account])
                         } else {
                         } else {
                             NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorLoadFileQuickLook) { _, _ in }
                             NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorLoadFileQuickLook) { _, _ in }

+ 3 - 8
iOSClient/More/NCMore.swift

@@ -37,13 +37,8 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
     private var externalSiteMenu: [NKExternalSite] = []
     private var externalSiteMenu: [NKExternalSite] = []
     private var settingsMenu: [NKExternalSite] = []
     private var settingsMenu: [NKExternalSite] = []
     private var quotaMenu: [NKExternalSite] = []
     private var quotaMenu: [NKExternalSite] = []
-
-    // swiftlint:disable force_cast
-    private let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     private let applicationHandle = NCApplicationHandle()
     private let applicationHandle = NCApplicationHandle()
-
     private var tabAccount: tableAccount?
     private var tabAccount: tableAccount?
 
 
     private struct Section {
     private struct Section {
@@ -213,10 +208,10 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
             case -3:
             case -3:
                 quota = NSLocalizedString("_quota_space_unlimited_", comment: "")
                 quota = NSLocalizedString("_quota_space_unlimited_", comment: "")
             default:
             default:
-                quota = CCUtility.transformedSize(activeAccount.quotaTotal)
+                quota = NCUtilityFileSystem.shared.transformedSize(activeAccount.quotaTotal)
             }
             }
 
 
-            let quotaUsed: String = CCUtility.transformedSize(activeAccount.quotaUsed)
+            let quotaUsed: String = NCUtilityFileSystem.shared.transformedSize(activeAccount.quotaUsed)
 
 
             labelQuota.text = String.localizedStringWithFormat(NSLocalizedString("_quota_using_", comment: ""), quotaUsed, quota)
             labelQuota.text = String.localizedStringWithFormat(NSLocalizedString("_quota_using_", comment: ""), quotaUsed, quota)
         }
         }

+ 0 - 1
iOSClient/NCGlobal.swift

@@ -79,7 +79,6 @@ class NCGlobal: NSObject {
 
 
     // Service
     // Service
     //
     //
-    @objc let serviceShareKeyChain                  = "Crypto Cloud"
     let metadataKeyedUnarchiver                     = "it.twsweb.nextcloud.metadata"
     let metadataKeyedUnarchiver                     = "it.twsweb.nextcloud.metadata"
     let refreshTask                                 = "com.nextcloud.refreshTask"
     let refreshTask                                 = "com.nextcloud.refreshTask"
     let processingTask                              = "com.nextcloud.processingTask"
     let processingTask                              = "com.nextcloud.processingTask"

+ 1 - 1
iOSClient/Networking/E2EE/NCEndToEndEncryption.m

@@ -564,7 +564,7 @@
     NSData *initializationVectorData = [[NSData alloc] initWithBase64EncodedString:initializationVector options:0];
     NSData *initializationVectorData = [[NSData alloc] initWithBase64EncodedString:initializationVector options:0];
     NSData *authenticationTagData = [[NSData alloc] initWithBase64EncodedString:authenticationTag options:0];
     NSData *authenticationTagData = [[NSData alloc] initWithBase64EncodedString:authenticationTag options:0];
 
 
-   return [self decryptFile:[CCUtility getDirectoryProviderStorageOcId:ocId fileNameView:fileName] fileNamePlain:[CCUtility getDirectoryProviderStorageOcId:ocId fileNameView:fileNameView] key:keyData keyLen:AES_KEY_128_LENGTH initializationVector:initializationVectorData authenticationTag:authenticationTagData];
+    return [self decryptFile:[[NCUtilityFileSystem shared] getDirectoryProviderStorageOcId:ocId fileNameView:fileName] fileNamePlain:[[NCUtilityFileSystem shared] getDirectoryProviderStorageOcId:ocId fileNameView:fileNameView] key:keyData keyLen:AES_KEY_128_LENGTH initializationVector:initializationVectorData authenticationTag:authenticationTagData];
 }
 }
 
 
 // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------

+ 5 - 5
iOSClient/Networking/E2EE/NCEndToEndMetadataV1.swift

@@ -95,7 +95,7 @@ extension NCEndToEndMetadata {
         var filesCodable: [String: E2eeV12.Files]?
         var filesCodable: [String: E2eeV12.Files]?
         var filedrop: [String: E2eeV12.Filedrop] = [:]
         var filedrop: [String: E2eeV12.Filedrop] = [:]
         var filedropCodable: [String: E2eeV12.Filedrop]?
         var filedropCodable: [String: E2eeV12.Filedrop]?
-        let privateKey = CCUtility.getEndToEndPrivateKey(account)
+        let privateKey = NCKeychain().getEndToEndPrivateKey(account: account)
         var fileNameIdentifiers: [String] = []
         var fileNameIdentifiers: [String] = []
 
 
         let e2eEncryptions = NCManageDatabase.shared.getE2eEncryptions(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", account, serverUrl))
         let e2eEncryptions = NCManageDatabase.shared.getE2eEncryptions(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", account, serverUrl))
@@ -166,7 +166,7 @@ extension NCEndToEndMetadata {
         }
         }
 
 
         // Create checksum
         // Create checksum
-        let passphrase = CCUtility.getEndToEndPassphrase(account).replacingOccurrences(of: " ", with: "")
+        let passphrase = NCKeychain().getEndToEndPassphrase(account: account)?.replacingOccurrences(of: " ", with: "") ?? ""
         let dataChecksum = (passphrase + fileNameIdentifiers.sorted().joined() + metadataKey).data(using: .utf8)
         let dataChecksum = (passphrase + fileNameIdentifiers.sorted().joined() + metadataKey).data(using: .utf8)
         let checksum = NCEndToEndEncryption.sharedManager().createSHA256(dataChecksum)
         let checksum = NCEndToEndEncryption.sharedManager().createSHA256(dataChecksum)
 
 
@@ -200,7 +200,7 @@ extension NCEndToEndMetadata {
         }
         }
 
 
         let decoder = JSONDecoder()
         let decoder = JSONDecoder()
-        let privateKey = CCUtility.getEndToEndPrivateKey(account)
+        let privateKey = NCKeychain().getEndToEndPrivateKey(account: account)
         var metadataVersion: Double = 0
         var metadataVersion: Double = 0
         var metadataKey = ""
         var metadataKey = ""
 
 
@@ -345,7 +345,7 @@ extension NCEndToEndMetadata {
             }
             }
 
 
             // verify checksum
             // verify checksum
-            let passphrase = CCUtility.getEndToEndPassphrase(account).replacingOccurrences(of: " ", with: "")
+            let passphrase = NCKeychain().getEndToEndPassphrase(account: account)?.replacingOccurrences(of: " ", with: "") ?? ""
             let dataChecksum = (passphrase + fileNameIdentifiers.sorted().joined() + metadata.metadataKey).data(using: .utf8)
             let dataChecksum = (passphrase + fileNameIdentifiers.sorted().joined() + metadata.metadataKey).data(using: .utf8)
             let checksum = NCEndToEndEncryption.sharedManager().createSHA256(dataChecksum)
             let checksum = NCEndToEndEncryption.sharedManager().createSHA256(dataChecksum)
             if metadata.checksum != checksum {
             if metadata.checksum != checksum {
@@ -369,7 +369,7 @@ extension NCEndToEndMetadata {
         }
         }
 
 
         let decoder = JSONDecoder()
         let decoder = JSONDecoder()
-        let privateKey = CCUtility.getEndToEndPrivateKey(account)
+        let privateKey = NCKeychain().getEndToEndPrivateKey(account: account)
         var metadataVersion: Double = 0
         var metadataVersion: Double = 0
 
 
         do {
         do {

+ 5 - 5
iOSClient/Networking/E2EE/NCEndToEndMetadataV20.swift

@@ -100,7 +100,7 @@ extension NCEndToEndMetadata {
 
 
     func encodeMetadataV20(account: String, serverUrl: String, ocIdServerUrl: String, userId: String, addUserId: String?, addCertificate: String?, removeUserId: String?) -> (metadata: String?, signature: String?, counter: Int, error: NKError) {
     func encodeMetadataV20(account: String, serverUrl: String, ocIdServerUrl: String, userId: String, addUserId: String?, addCertificate: String?, removeUserId: String?) -> (metadata: String?, signature: String?, counter: Int, error: NKError) {
 
 
-        guard let directoryTop = NCUtility.shared.getDirectoryE2EETop(serverUrl: serverUrl, account: account) else {
+        guard let directoryTop = NCUtility.shared.getDirectoryE2EETop(serverUrl: serverUrl, account: account), let certificate = NCKeychain().getEndToEndCertificate(account: account) else {
             return (nil, nil, 0, NKError(errorCode: NCGlobal.shared.errorUnexpectedResponseFromDB, errorDescription: "_e2e_error_"))
             return (nil, nil, 0, NKError(errorCode: NCGlobal.shared.errorUnexpectedResponseFromDB, errorDescription: "_e2e_error_"))
         }
         }
 
 
@@ -134,7 +134,7 @@ extension NCEndToEndMetadata {
                let metadataKey = tableUserId.metadataKey {
                let metadataKey = tableUserId.metadataKey {
                 key = metadataKey
                 key = metadataKey
             } else {
             } else {
-                addUser(userId: userId, certificate: CCUtility.getEndToEndCertificate(account), key: key)
+                addUser(userId: userId, certificate: certificate, key: key)
             }
             }
             // ADDUSERID
             // ADDUSERID
             if let addUserId {
             if let addUserId {
@@ -237,7 +237,7 @@ extension NCEndToEndMetadata {
             e2eeData.printJson()
             e2eeData.printJson()
 
 
             let e2eeJson = String(data: e2eeData, encoding: .utf8)
             let e2eeJson = String(data: e2eeData, encoding: .utf8)
-            let signature = createSignature(account: account, userId: userId, metadata: metadataCodable, users: usersCodable, version: NCGlobal.shared.e2eeVersionV20, certificate: CCUtility.getEndToEndCertificate(account))
+            let signature = createSignature(account: account, userId: userId, metadata: metadataCodable, users: usersCodable, version: NCGlobal.shared.e2eeVersionV20, certificate: certificate)
 
 
             return (e2eeJson, signature, counter, NKError())
             return (e2eeJson, signature, counter, NKError())
 
 
@@ -303,7 +303,7 @@ extension NCEndToEndMetadata {
                     var metadataKey: Data?
                     var metadataKey: Data?
                     if let encryptedMetadataKey = user.encryptedMetadataKey {
                     if let encryptedMetadataKey = user.encryptedMetadataKey {
                         let data = Data(base64Encoded: encryptedMetadataKey)
                         let data = Data(base64Encoded: encryptedMetadataKey)
-                        if let decrypted = NCEndToEndEncryption.sharedManager().decryptAsymmetricData(data, privateKey: CCUtility.getEndToEndPrivateKey(account)) {
+                        if let decrypted = NCEndToEndEncryption.sharedManager().decryptAsymmetricData(data, privateKey: NCKeychain().getEndToEndPrivateKey(account: account)) {
                             metadataKey = decrypted
                             metadataKey = decrypted
                         }
                         }
                     }
                     }
@@ -447,7 +447,7 @@ extension NCEndToEndMetadata {
             let decoded = try? JSONSerialization.data(withJSONObject: dataSerialization, options: [.sortedKeys, .withoutEscapingSlashes])
             let decoded = try? JSONSerialization.data(withJSONObject: dataSerialization, options: [.sortedKeys, .withoutEscapingSlashes])
             let base64 = decoded!.base64EncodedString()
             let base64 = decoded!.base64EncodedString()
             if let base64Data = base64.data(using: .utf8),
             if let base64Data = base64.data(using: .utf8),
-               let signatureData = NCEndToEndEncryption.sharedManager().generateSignatureCMS(base64Data, certificate: certificate, privateKey: CCUtility.getEndToEndPrivateKey(account), userId: userId) {
+               let signatureData = NCEndToEndEncryption.sharedManager().generateSignatureCMS(base64Data, certificate: certificate, privateKey: NCKeychain().getEndToEndPrivateKey(account: account), userId: userId) {
                 return signatureData.base64EncodedString()
                 return signatureData.base64EncodedString()
             }
             }
         } catch {
         } catch {

+ 1 - 1
iOSClient/Networking/E2EE/NCNetworkingE2EE.swift

@@ -191,7 +191,7 @@ class NCNetworkingE2EE: NSObject {
 
 
     func unlockAll(account: String) {
     func unlockAll(account: String) {
 
 
-        guard CCUtility.isEnd(toEndEnabled: account) else { return }
+        guard NCKeychain().isEndToEndEnabled(account: account) else { return }
 
 
         Task {
         Task {
             for result in NCManageDatabase.shared.getE2EAllTokenLock(account: account) {
             for result in NCManageDatabase.shared.getE2EAllTokenLock(account: account) {

+ 1 - 1
iOSClient/Networking/E2EE/NCNetworkingE2EECreateFolder.swift

@@ -32,7 +32,7 @@ class NCNetworkingE2EECreateFolder: NSObject {
 
 
         let fileNameIdentifier = NCNetworkingE2EE.shared.generateRandomIdentifier()
         let fileNameIdentifier = NCNetworkingE2EE.shared.generateRandomIdentifier()
         let serverUrlFileName = serverUrl + "/" + fileNameIdentifier
         let serverUrlFileName = serverUrl + "/" + fileNameIdentifier
-        let fileNameFolder = NCUtilityFileSystem.shared.createFileName(CCUtility.removeForbiddenCharactersServer(fileName)!, serverUrl: serverUrl, account: account)
+        let fileNameFolder = NCUtilityFileSystem.shared.createFileName(NCUtility.shared.removeForbiddenCharacters(fileName), serverUrl: serverUrl, account: account)
         if fileNameFolder.isEmpty {
         if fileNameFolder.isEmpty {
             return NKError(errorCode: NCGlobal.shared.errorUnexpectedResponseFromDB, errorDescription: NSLocalizedString("_e2e_error_", comment: ""))
             return NKError(errorCode: NCGlobal.shared.errorUnexpectedResponseFromDB, errorDescription: NSLocalizedString("_e2e_error_", comment: ""))
         }
         }

+ 4 - 3
iOSClient/Networking/E2EE/NCNetworkingE2EERename.swift

@@ -55,7 +55,8 @@ class NCNetworkingE2EERename: NSObject {
 
 
         // DB RENAME
         // DB RENAME
         //
         //
-        NCManageDatabase.shared.renameFileE2eEncryption(account: metadata.account, serverUrl: metadata.serverUrl, fileNameIdentifier: metadata.fileName, newFileName: fileNameNew, newFileNamePath: CCUtility.returnFileNamePath(fromFileName: fileNameNew, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId, account: metadata.account))
+        let newFileNamePath = NCUtilityFileSystem.shared.getFileNamePath(fileNameNew, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId)
+        NCManageDatabase.shared.renameFileE2eEncryption(account: metadata.account, serverUrl: metadata.serverUrl, fileNameIdentifier: metadata.fileName, newFileName: fileNameNew, newFileNamePath: newFileNamePath)
 
 
         // UPLOAD METADATA
         // UPLOAD METADATA
         //
         //
@@ -77,8 +78,8 @@ class NCNetworkingE2EERename: NSObject {
 
 
         // MOVE FILE SYSTEM
         // MOVE FILE SYSTEM
         //
         //
-        let atPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId) + "/" + metadata.fileNameView
-        let toPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId) + "/" + fileNameNew
+        let atPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId) + "/" + metadata.fileNameView
+        let toPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId) + "/" + fileNameNew
         do {
         do {
             try FileManager.default.moveItem(atPath: atPath, toPath: toPath)
             try FileManager.default.moveItem(atPath: atPath, toPath: toPath)
         } catch { }
         } catch { }

+ 4 - 4
iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift

@@ -66,7 +66,7 @@ class NCNetworkingE2EEUpload: NSObject {
 
 
             // ENCRYPT FILE
             // ENCRYPT FILE
             //
             //
-            if NCEndToEndEncryption.sharedManager()?.encryptFile(metadata.fileNameView, fileNameIdentifier: metadata.fileName, directory: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId), key: &key, initializationVector: &initializationVector, authenticationTag: &authenticationTag) == false {
+            if NCEndToEndEncryption.sharedManager()?.encryptFile(metadata.fileNameView, fileNameIdentifier: metadata.fileName, directory: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId), key: &key, initializationVector: &initializationVector, authenticationTag: &authenticationTag) == false {
                 return NKError(errorCode: NCGlobal.shared.errorE2EEEncryptFile, errorDescription: NSLocalizedString("_e2e_error_", comment: ""))
                 return NKError(errorCode: NCGlobal.shared.errorE2EEEncryptFile, errorDescription: NSLocalizedString("_e2e_error_", comment: ""))
             }
             }
             guard let key = key as? String, let initializationVector = initializationVector as? String else {
             guard let key = key as? String, let initializationVector = initializationVector as? String else {
@@ -159,14 +159,14 @@ class NCNetworkingE2EEUpload: NSObject {
 
 
         if let afError = resultsSendFile.afError, afError.isExplicitlyCancelledError {
         if let afError = resultsSendFile.afError, afError.isExplicitlyCancelledError {
 
 
-            CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
+            NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId))
             NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
             NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
             NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterUploadedFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account, "fileName": metadata.fileName, "ocIdTemp": ocIdTemp, "error": resultsSendFile.error])
             NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterUploadedFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account, "fileName": metadata.fileName, "ocIdTemp": ocIdTemp, "error": resultsSendFile.error])
 
 
         } else if resultsSendFile.error == .success, let ocId = resultsSendFile.ocId {
         } else if resultsSendFile.error == .success, let ocId = resultsSendFile.ocId {
 
 
             NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
             NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
-            NCUtilityFileSystem.shared.moveFileInBackground(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId), toPath: CCUtility.getDirectoryProviderStorageOcId(ocId))
+            NCUtilityFileSystem.shared.moveFileInBackground(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId), toPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId))
 
 
             metadata.date = resultsSendFile.date ?? NSDate()
             metadata.date = resultsSendFile.date ?? NSDate()
             metadata.etag = resultsSendFile.etag ?? ""
             metadata.etag = resultsSendFile.etag ?? ""
@@ -212,7 +212,7 @@ class NCNetworkingE2EEUpload: NSObject {
 
 
         } else {
         } else {
 
 
-            let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileName)!
+            let fileNameLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileName)
             return await withCheckedContinuation({ continuation in
             return await withCheckedContinuation({ continuation in
                 NCNetworking.shared.uploadFile(metadata: metadata, fileNameLocalPath: fileNameLocalPath, withUploadComplete: false, addCustomHeaders: ["e2e-token": e2eToken]) {
                 NCNetworking.shared.uploadFile(metadata: metadata, fileNameLocalPath: fileNameLocalPath, withUploadComplete: false, addCustomHeaders: ["e2e-token": e2eToken]) {
 #if !EXTENSION
 #if !EXTENSION

+ 2 - 2
iOSClient/Networking/NCAutoUpload.swift

@@ -117,7 +117,7 @@ class NCAutoUpload: NSObject {
                 var serverUrl: String = ""
                 var serverUrl: String = ""
                 let fileName = CCUtility.createFileName(asset.originalFilename as String, fileDate: assetDate, fileType: assetMediaType, keyFileName: NCGlobal.shared.keyFileNameAutoUploadMask, keyFileNameType: NCGlobal.shared.keyFileNameAutoUploadType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginalAutoUpload, forcedNewFileName: false)!
                 let fileName = CCUtility.createFileName(asset.originalFilename as String, fileDate: assetDate, fileType: assetMediaType, keyFileName: NCGlobal.shared.keyFileNameAutoUploadMask, keyFileNameType: NCGlobal.shared.keyFileNameAutoUploadType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginalAutoUpload, forcedNewFileName: false)!
 
 
-                if asset.mediaSubtypes.contains(.photoLive) && CCUtility.getLivePhoto() {
+                if asset.mediaSubtypes.contains(.photoLive), NCKeychain().livePhoto {
                     livePhoto = true
                     livePhoto = true
                 }
                 }
 
 
@@ -151,7 +151,7 @@ class NCAutoUpload: NSObject {
                 var fileNameSearchMetadata = fileName
                 var fileNameSearchMetadata = fileName
                 let ext = (fileNameSearchMetadata as NSString).pathExtension.uppercased()
                 let ext = (fileNameSearchMetadata as NSString).pathExtension.uppercased()
 
 
-                if ext == "HEIC" && CCUtility.getFormatCompatibility() {
+                if ext == "HEIC", NCKeychain().formatCompatibility {
                     fileNameSearchMetadata = (fileNameSearchMetadata as NSString).deletingPathExtension + ".jpg"
                     fileNameSearchMetadata = (fileNameSearchMetadata as NSString).deletingPathExtension + ".jpg"
                 }
                 }
 
 

+ 41 - 48
iOSClient/Networking/NCNetworking.swift

@@ -174,7 +174,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
     public func checkTrustedChallenge(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
     public func checkTrustedChallenge(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
 
 
         let protectionSpace: URLProtectionSpace = challenge.protectionSpace
         let protectionSpace: URLProtectionSpace = challenge.protectionSpace
-        let directoryCertificate = CCUtility.getDirectoryCerificates()!
+        let directoryCertificate = NCUtilityFileSystem.shared.directoryCertificates
         let host = challenge.protectionSpace.host
         let host = challenge.protectionSpace.host
         let certificateSavedPath = directoryCertificate + "/" + host + ".der"
         let certificateSavedPath = directoryCertificate + "/" + host + ".der"
         var isTrusted: Bool
         var isTrusted: Bool
@@ -215,7 +215,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
 
 
     func writeCertificate(host: String) {
     func writeCertificate(host: String) {
 
 
-        let directoryCertificate = CCUtility.getDirectoryCerificates()!
+        let directoryCertificate = NCUtilityFileSystem.shared.directoryCertificates
         let certificateAtPath = directoryCertificate + "/" + host + ".tmp"
         let certificateAtPath = directoryCertificate + "/" + host + ".tmp"
         let certificateToPath = directoryCertificate + "/" + host + ".der"
         let certificateToPath = directoryCertificate + "/" + host + ".der"
 
 
@@ -294,12 +294,12 @@ class NCNetworking: NSObject, NKCommonDelegate {
                   completion: @escaping (_ afError: AFError?, _ error: NKError) -> Void) {
                   completion: @escaping (_ afError: AFError?, _ error: NKError) -> Void) {
 
 
         guard !metadata.isInTransfer else { return completion(nil, NKError()) }
         guard !metadata.isInTransfer else { return completion(nil, NKError()) }
-        if checkfileProviderStorageExists, CCUtility.fileProviderStorageExists(metadata) {
+        if checkfileProviderStorageExists, NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) {
             return completion(nil, NKError())
             return completion(nil, NKError())
         }
         }
 
 
         let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
         let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
-        let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileName)!
+        let fileNameLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileName)
 
 
         if NCManageDatabase.shared.getMetadataFromOcId(metadata.ocId) == nil {
         if NCManageDatabase.shared.getMetadataFromOcId(metadata.ocId) == nil {
             NCManageDatabase.shared.addMetadata(tableMetadata.init(value: metadata))
             NCManageDatabase.shared.addMetadata(tableMetadata.init(value: metadata))
@@ -358,7 +358,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
 #if !EXTENSION
 #if !EXTENSION
     func downloadAvatar(user: String, dispalyName: String?, fileName: String, cell: NCCellProtocol, view: UIView?, cellImageView: UIImageView?) {
     func downloadAvatar(user: String, dispalyName: String?, fileName: String, cell: NCCellProtocol, view: UIView?, cellImageView: UIImageView?) {
         guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
         guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
-        let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + fileName
+        let fileNameLocalPath = NCUtilityFileSystem.shared.directoryUserData + "/" + fileName
 
 
         if let image = NCManageDatabase.shared.getImageAvatarLoaded(fileName: fileName) {
         if let image = NCManageDatabase.shared.getImageAvatarLoaded(fileName: fileName) {
             cellImageView?.image = image
             cellImageView?.image = image
@@ -412,7 +412,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
                 completion(error)
                 completion(error)
             }
             }
         } else if metadata.session == NextcloudKit.shared.nkCommonInstance.sessionIdentifierUpload {
         } else if metadata.session == NextcloudKit.shared.nkCommonInstance.sessionIdentifierUpload {
-            let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
+            let fileNameLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)
             uploadFile(metadata: metadata, fileNameLocalPath: fileNameLocalPath, start: start, progressHandler: progressHandler) { _, _, _, _, _, _, _, error in
             uploadFile(metadata: metadata, fileNameLocalPath: fileNameLocalPath, start: start, progressHandler: progressHandler) { _, _, _, _, _, _, _, error in
                 completion(error)
                 completion(error)
             }
             }
@@ -479,8 +479,8 @@ class NCNetworking: NSObject, NKCommonDelegate {
                          progressHandler: @escaping (_ totalBytesExpected: Int64, _ totalBytes: Int64, _ fractionCompleted: Double) -> Void = { _, _, _ in },
                          progressHandler: @escaping (_ totalBytesExpected: Int64, _ totalBytes: Int64, _ fractionCompleted: Double) -> Void = { _, _, _ in },
                          completion: @escaping (_ account: String, _ file: NKFile?, _ afError: AFError?, _ error: NKError) -> Void) {
                          completion: @escaping (_ account: String, _ file: NKFile?, _ afError: AFError?, _ error: NKError) -> Void) {
 
 
-        let directory = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId)!
-        let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
+        let directory = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)
+        let fileNameLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)
         let chunkFolder = NCManageDatabase.shared.getChunkFolder(account: metadata.account, ocId: metadata.ocId)
         let chunkFolder = NCManageDatabase.shared.getChunkFolder(account: metadata.account, ocId: metadata.ocId)
         let filesChunk = NCManageDatabase.shared.getChunks(account: metadata.account, ocId: metadata.ocId)
         let filesChunk = NCManageDatabase.shared.getChunks(account: metadata.account, ocId: metadata.ocId)
         var uploadTask: URLSessionTask?
         var uploadTask: URLSessionTask?
@@ -582,7 +582,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
         var session: URLSession?
         var session: URLSession?
         let metadata = tableMetadata.init(value: metadata)
         let metadata = tableMetadata.init(value: metadata)
         let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
         let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
-        let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
+        let fileNameLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)
 
 
         if metadata.session == sessionIdentifierBackground || metadata.session == sessionIdentifierBackgroundExtension {
         if metadata.session == sessionIdentifierBackground || metadata.session == sessionIdentifierBackgroundExtension {
             session = sessionManagerBackground
             session = sessionManagerBackground
@@ -648,7 +648,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
             metadata.status = NCGlobal.shared.metadataStatusNormal
             metadata.status = NCGlobal.shared.metadataStatusNormal
 
 
             // Delete Asset on Photos album
             // Delete Asset on Photos album
-            if CCUtility.getRemovePhotoCameraRoll() && !metadata.assetLocalIdentifier.isEmpty {
+            if NCKeychain().removePhotoCameraRoll, !metadata.assetLocalIdentifier.isEmpty {
                 metadata.deleteAssetLocalIdentifier = true
                 metadata.deleteAssetLocalIdentifier = true
             }
             }
 
 
@@ -656,10 +656,10 @@ class NCNetworking: NSObject, NKCommonDelegate {
             NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", ocIdTemp))
             NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", ocIdTemp))
 
 
             if selector == NCGlobal.shared.selectorUploadFileNODelete {
             if selector == NCGlobal.shared.selectorUploadFileNODelete {
-                NCUtilityFileSystem.shared.moveFile(atPath: CCUtility.getDirectoryProviderStorageOcId(ocIdTemp), toPath: CCUtility.getDirectoryProviderStorageOcId(ocId))
+                NCUtilityFileSystem.shared.moveFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocIdTemp), toPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId))
                 NCManageDatabase.shared.addLocalFile(metadata: metadata)
                 NCManageDatabase.shared.addLocalFile(metadata: metadata)
             } else {
             } else {
-                NCUtilityFileSystem.shared.deleteFile(filePath: CCUtility.getDirectoryProviderStorageOcId(ocIdTemp))
+                NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocIdTemp))
             }
             }
 
 
             NextcloudKit.shared.nkCommonInstance.writeLog("[SUCCESS] Upload complete " + serverUrl + "/" + fileName + ", result: success(\(size) bytes)")
             NextcloudKit.shared.nkCommonInstance.writeLog("[SUCCESS] Upload complete " + serverUrl + "/" + fileName + ", result: success(\(size) bytes)")
@@ -669,7 +669,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
 
 
             if error.errorCode == NSURLErrorCancelled || error.errorCode == NCGlobal.shared.errorRequestExplicityCancelled {
             if error.errorCode == NSURLErrorCancelled || error.errorCode == NCGlobal.shared.errorRequestExplicityCancelled {
 
 
-                CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
+                NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId))
                 NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                 NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                 NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterUploadCancelFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account])
                 NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterUploadCancelFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account])
 
 
@@ -679,21 +679,18 @@ class NCNetworking: NSObject, NKCommonDelegate {
                     let newFileName = NCUtilityFileSystem.shared.createFileName(metadata.fileName, serverUrl: metadata.serverUrl, account: metadata.account)
                     let newFileName = NCUtilityFileSystem.shared.createFileName(metadata.fileName, serverUrl: metadata.serverUrl, account: metadata.account)
                     let alertController = UIAlertController(title: error.errorDescription, message: NSLocalizedString("_change_upload_filename_", comment: ""), preferredStyle: .alert)
                     let alertController = UIAlertController(title: error.errorDescription, message: NSLocalizedString("_change_upload_filename_", comment: ""), preferredStyle: .alert)
                     alertController.addAction(UIAlertAction(title: String(format: NSLocalizedString("_save_file_as_", comment: ""), newFileName), style: .default, handler: { _ in
                     alertController.addAction(UIAlertAction(title: String(format: NSLocalizedString("_save_file_as_", comment: ""), newFileName), style: .default, handler: { _ in
-                        let atpath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId) + "/" + metadata.fileName
-                        let toPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId) + "/" + newFileName
+                        let atpath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId) + "/" + metadata.fileName
+                        let toPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId) + "/" + newFileName
                         NCUtilityFileSystem.shared.moveFile(atPath: atpath, toPath: toPath)
                         NCUtilityFileSystem.shared.moveFile(atPath: atpath, toPath: toPath)
                         NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, newFileName: newFileName, session: nil, sessionError: "", sessionSelector: nil, sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusWaitUpload, errorCode: error.errorCode)
                         NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, newFileName: newFileName, session: nil, sessionError: "", sessionSelector: nil, sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusWaitUpload, errorCode: error.errorCode)
                     }))
                     }))
                     alertController.addAction(UIAlertAction(title: NSLocalizedString("_discard_changes_", comment: ""), style: .destructive, handler: { _ in
                     alertController.addAction(UIAlertAction(title: NSLocalizedString("_discard_changes_", comment: ""), style: .destructive, handler: { _ in
-                        CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
+                        NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId))
                         NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                         NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                         NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterUploadCancelFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account])
                         NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterUploadCancelFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account])
                     }))
                     }))
 
 
-                    // swiftlint:disable force_cast
-                    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-                    // swiftlint:enable force_cast
-
+                    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
                     appDelegate.window?.rootViewController?.present(alertController, animated: true)
                     appDelegate.window?.rootViewController?.present(alertController, animated: true)
                 }
                 }
 #endif
 #endif
@@ -790,12 +787,12 @@ class NCNetworking: NSObject, NKCommonDelegate {
 
 
         // DOWNLOAD
         // DOWNLOAD
         for metadata in metadatasDownload {
         for metadata in metadatasDownload {
-            CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
+            NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId))
             NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, session: "", sessionError: "", sessionSelector: "", sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusNormal, errorCode: 0)
             NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, session: "", sessionError: "", sessionSelector: "", sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusNormal, errorCode: 0)
         }
         }
         // UPLOAD
         // UPLOAD
         for metadata in metadatasUpload {
         for metadata in metadatasUpload {
-            CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
+            NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId))
             NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
             NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
         }
         }
 
 
@@ -803,7 +800,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
 
 
         // BACKGROUND
         // BACKGROUND
         for metadata in metadatasUploadBackground {
         for metadata in metadatasUploadBackground {
-            CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
+            NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId))
             NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
             NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
         }
         }
 
 
@@ -822,8 +819,8 @@ class NCNetworking: NSObject, NKCommonDelegate {
 
 
     func cancel(metadata: tableMetadata) async {
     func cancel(metadata: tableMetadata) async {
 
 
-        let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
-        CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
+        let fileNameLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)
+        NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId))
 
 
         // No session found
         // No session found
         if metadata.session.isEmpty {
         if metadata.session.isEmpty {
@@ -880,7 +877,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
 
 
         NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl,
         NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl,
                                              depth: "1",
                                              depth: "1",
-                                             showHiddenFiles: CCUtility.getShowHiddenFiles(),
+                                             showHiddenFiles: NCKeychain().showHiddenFiles,
                                              includeHiddenFiles: NCGlobal.shared.includeHiddenFiles,
                                              includeHiddenFiles: NCGlobal.shared.includeHiddenFiles,
                                              options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { account, files, _, error in
                                              options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { account, files, _, error in
 
 
@@ -912,7 +909,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
         }
         }
     }
     }
 
 
-    func readFile(serverUrlFileName: String, showHiddenFiles: Bool = CCUtility.getShowHiddenFiles(), queue: DispatchQueue = NextcloudKit.shared.nkCommonInstance.backgroundQueue, completion: @escaping (_ account: String, _ metadata: tableMetadata?, _ error: NKError) -> Void) {
+    func readFile(serverUrlFileName: String, showHiddenFiles: Bool = NCKeychain().showHiddenFiles, queue: DispatchQueue = NextcloudKit.shared.nkCommonInstance.backgroundQueue, completion: @escaping (_ account: String, _ metadata: tableMetadata?, _ error: NKError) -> Void) {
 
 
         let options = NKRequestOptions(queue: queue)
         let options = NKRequestOptions(queue: queue)
 
 
@@ -977,7 +974,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
 #if !EXTENSION
 #if !EXTENSION
         NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl,
         NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl,
                                              depth: "infinity",
                                              depth: "infinity",
-                                             showHiddenFiles: CCUtility.getShowHiddenFiles(),
+                                             showHiddenFiles: NCKeychain().showHiddenFiles,
                                              options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { account, files, _, error in
                                              options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { account, files, _, error in
 
 
             if error == .success {
             if error == .success {
@@ -1010,7 +1007,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
         NextcloudKit.shared.searchLiteral(serverUrl: urlBase.urlBase,
         NextcloudKit.shared.searchLiteral(serverUrl: urlBase.urlBase,
                                           depth: "infinity",
                                           depth: "infinity",
                                           literal: literal,
                                           literal: literal,
-                                          showHiddenFiles: CCUtility.getShowHiddenFiles(),
+                                          showHiddenFiles: NCKeychain().showHiddenFiles,
                                           options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { account, files, _, error in
                                           options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { account, files, _, error in
 
 
             guard error == .success else {
             guard error == .success else {
@@ -1200,7 +1197,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
 
 
     private func createFolderPlain(fileName: String, serverUrl: String, account: String, urlBase: String, overwrite: Bool, withPush: Bool, completion: @escaping (_ error: NKError) -> Void) {
     private func createFolderPlain(fileName: String, serverUrl: String, account: String, urlBase: String, overwrite: Bool, withPush: Bool, completion: @escaping (_ error: NKError) -> Void) {
 
 
-        var fileNameFolder = CCUtility.removeForbiddenCharactersServer(fileName)!
+        var fileNameFolder = NCUtility.shared.removeForbiddenCharacters(fileName)
 
 
         if !overwrite {
         if !overwrite {
             fileNameFolder = NCUtilityFileSystem.shared.createFileName(fileNameFolder, serverUrl: serverUrl, account: account)
             fileNameFolder = NCUtilityFileSystem.shared.createFileName(fileNameFolder, serverUrl: serverUrl, account: account)
@@ -1321,11 +1318,11 @@ class NCNetworking: NSObject, NKCommonDelegate {
 
 
                 NCManageDatabase.shared.deleteVideo(metadata: metadata)
                 NCManageDatabase.shared.deleteVideo(metadata: metadata)
                 NCManageDatabase.shared.deleteLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                 NCManageDatabase.shared.deleteLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
-                NCUtilityFileSystem.shared.deleteFile(filePath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
+                NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId))
 
 
                 if let metadataLivePhoto = NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata) {
                 if let metadataLivePhoto = NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata) {
                     NCManageDatabase.shared.deleteLocalFile(predicate: NSPredicate(format: "ocId == %@", metadataLivePhoto.ocId))
                     NCManageDatabase.shared.deleteLocalFile(predicate: NSPredicate(format: "ocId == %@", metadataLivePhoto.ocId))
-                    NCUtilityFileSystem.shared.deleteFile(filePath: CCUtility.getDirectoryProviderStorageOcId(metadataLivePhoto.ocId))
+                    NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadataLivePhoto.ocId))
                 }
                 }
             }
             }
             return NKError()
             return NKError()
@@ -1378,7 +1375,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
         if result.error == .success || result.error.errorCode == NCGlobal.shared.errorResourceNotFound {
         if result.error == .success || result.error.errorCode == NCGlobal.shared.errorResourceNotFound {
 
 
             do {
             do {
-                try FileManager.default.removeItem(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
+                try FileManager.default.removeItem(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId))
             } catch { }
             } catch { }
 
 
             NCManageDatabase.shared.deleteVideo(metadata: metadata)
             NCManageDatabase.shared.deleteVideo(metadata: metadata)
@@ -1386,7 +1383,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
             NCManageDatabase.shared.deleteLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
             NCManageDatabase.shared.deleteLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
 
 
             if metadata.directory {
             if metadata.directory {
-                NCManageDatabase.shared.deleteDirectoryAndSubDirectory(serverUrl: CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName), account: metadata.account)
+                NCManageDatabase.shared.deleteDirectoryAndSubDirectory(serverUrl: NCUtilityFileSystem.shared.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName), account: metadata.account)
             }
             }
         }
         }
 
 
@@ -1412,7 +1409,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
 
 
     private func favoriteMetadataPlain(_ metadata: tableMetadata, completion: @escaping (_ error: NKError) -> Void) {
     private func favoriteMetadataPlain(_ metadata: tableMetadata, completion: @escaping (_ error: NKError) -> Void) {
 
 
-        let fileName = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId, account: metadata.account)!
+        let fileName = NCUtilityFileSystem.shared.getFileNamePath(metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId)
         let favorite = !metadata.favorite
         let favorite = !metadata.favorite
         let ocId = metadata.ocId
         let ocId = metadata.ocId
 
 
@@ -1493,9 +1490,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
         if !metadata.permissions.isEmpty && !permission {
         if !metadata.permissions.isEmpty && !permission {
             return completion(NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_no_permission_modify_file_"))
             return completion(NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_no_permission_modify_file_"))
         }
         }
-        guard let fileNameNew = CCUtility.removeForbiddenCharactersServer(fileNameNew) else {
-            return completion(NKError())
-        }
+        let fileNameNew = NCUtility.shared.removeForbiddenCharacters(fileNameNew)
         if fileNameNew.isEmpty || fileNameNew == metadata.fileNameView {
         if fileNameNew.isEmpty || fileNameNew == metadata.fileNameView {
             return completion(NKError())
             return completion(NKError())
         }
         }
@@ -1512,8 +1507,8 @@ class NCNetworking: NSObject, NKCommonDelegate {
 
 
                 if metadata.directory {
                 if metadata.directory {
 
 
-                    let serverUrl = CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName)!
-                    let serverUrlTo = CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: fileNameNew)!
+                    let serverUrl = NCUtilityFileSystem.shared.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName)
+                    let serverUrlTo = NCUtilityFileSystem.shared.stringAppendServerUrl(metadata.serverUrl, addFileName: fileNameNew)
                     if let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", metadata.account, metadata.serverUrl)) {
                     if let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", metadata.account, metadata.serverUrl)) {
 
 
                         NCManageDatabase.shared.setDirectory(serverUrl: serverUrl, serverUrlTo: serverUrlTo, etag: "", ocId: nil, fileId: nil, encrypted: directory.e2eEncrypted, richWorkspace: nil, account: metadata.account)
                         NCManageDatabase.shared.setDirectory(serverUrl: serverUrl, serverUrlTo: serverUrlTo, etag: "", ocId: nil, fileId: nil, encrypted: directory.e2eEncrypted, richWorkspace: nil, account: metadata.account)
@@ -1526,17 +1521,15 @@ class NCNetworking: NSObject, NKCommonDelegate {
 
 
                     if ext != extNew {
                     if ext != extNew {
 
 
-                        if let path = CCUtility.getDirectoryProviderStorageOcId(ocId) {
-                            NCUtilityFileSystem.shared.deleteFile(filePath: path)
-                        }
+                        NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId))
                         NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSourceNetworkForced)
                         NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSourceNetworkForced)
 
 
                     } else {
                     } else {
 
 
                         NCManageDatabase.shared.setLocalFile(ocId: ocId, fileName: fileNameNew, etag: nil)
                         NCManageDatabase.shared.setLocalFile(ocId: ocId, fileName: fileNameNew, etag: nil)
                         // Move file system
                         // Move file system
-                        let atPath = CCUtility.getDirectoryProviderStorageOcId(ocId) + "/" + metadata.fileName
-                        let toPath = CCUtility.getDirectoryProviderStorageOcId(ocId) + "/" + fileNameNew
+                        let atPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId) + "/" + metadata.fileName
+                        let toPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId) + "/" + fileNameNew
                         do {
                         do {
                             try FileManager.default.moveItem(atPath: atPath, toPath: toPath)
                             try FileManager.default.moveItem(atPath: atPath, toPath: toPath)
                         } catch { }
                         } catch { }
@@ -1580,7 +1573,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
         let result = await NextcloudKit.shared.moveFileOrFolder(serverUrlFileNameSource: serverUrlFileNameSource, serverUrlFileNameDestination: serverUrlFileNameDestination, overwrite: overwrite)
         let result = await NextcloudKit.shared.moveFileOrFolder(serverUrlFileNameSource: serverUrlFileNameSource, serverUrlFileNameDestination: serverUrlFileNameDestination, overwrite: overwrite)
         if result.error == .success {
         if result.error == .success {
             if metadata.directory {
             if metadata.directory {
-                NCManageDatabase.shared.deleteDirectoryAndSubDirectory(serverUrl: CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName), account: result.account)
+                NCManageDatabase.shared.deleteDirectoryAndSubDirectory(serverUrl: NCUtilityFileSystem.shared.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName), account: result.account)
             }
             }
             NCManageDatabase.shared.moveMetadata(ocId: metadata.ocId, serverUrlTo: serverUrlTo)
             NCManageDatabase.shared.moveMetadata(ocId: metadata.ocId, serverUrlTo: serverUrlTo)
         }
         }
@@ -1627,8 +1620,8 @@ class NCNetworking: NSObject, NKCommonDelegate {
             } else {
             } else {
                 completition(URL(string: metadata.url), true, .success)
                 completition(URL(string: metadata.url), true, .success)
             }
             }
-        } else if CCUtility.fileProviderStorageExists(metadata) {
-            completition(URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)), false, .success)
+        } else if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) {
+            completition(URL(fileURLWithPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)), false, .success)
         } else {
         } else {
             NextcloudKit.shared.getDirectDownload(fileId: metadata.fileId) { _, url, _, error in
             NextcloudKit.shared.getDirectDownload(fileId: metadata.fileId) { _, url, _, error in
                 if error == .success && url != nil {
                 if error == .success && url != nil {

+ 4 - 3
iOSClient/Networking/NCNetworkingCheckRemoteUser.swift

@@ -28,8 +28,9 @@ class NCNetworkingCheckRemoteUser {
 
 
     func checkRemoteUser(account: String, error: NKError) {
     func checkRemoteUser(account: String, error: NKError) {
 
 
+        let token = NCKeychain().getPassword(account: account)
         guard let tableAccount = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", account)),
         guard let tableAccount = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", account)),
-              let token = CCUtility.getPassword(account), !token.isEmpty,
+              !token.isEmpty,
               let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
               let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
 
 
         NCNetworking.shared.cancel(inBackground: true)
         NCNetworking.shared.cancel(inBackground: true)
@@ -51,7 +52,7 @@ class NCNetworkingCheckRemoteUser {
                         let description = String.localizedStringWithFormat(NSLocalizedString("_error_check_remote_user_", comment: ""), tableAccount.user, tableAccount.urlBase)
                         let description = String.localizedStringWithFormat(NSLocalizedString("_error_check_remote_user_", comment: ""), tableAccount.user, tableAccount.urlBase)
                         let error = NKError(errorCode: error.errorCode, errorDescription: description)
                         let error = NKError(errorCode: error.errorCode, errorDescription: description)
                         NCContentPresenter.shared.showError(error: error, priority: .max)
                         NCContentPresenter.shared.showError(error: error, priority: .max)
-                        CCUtility.setPassword(account, password: nil)
+                        NCKeychain().setPassword(account: account, password: nil)
                         NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Password removed.")
                         NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Password removed.")
                     }
                     }
                 }
                 }
@@ -63,7 +64,7 @@ class NCNetworkingCheckRemoteUser {
                 let description = String.localizedStringWithFormat(NSLocalizedString("_error_check_remote_user_", comment: ""), tableAccount.user, tableAccount.urlBase)
                 let description = String.localizedStringWithFormat(NSLocalizedString("_error_check_remote_user_", comment: ""), tableAccount.user, tableAccount.urlBase)
                 let error = NKError(errorCode: error.errorCode, errorDescription: description)
                 let error = NKError(errorCode: error.errorCode, errorDescription: description)
                 NCContentPresenter.shared.showError(error: error, priority: .max)
                 NCContentPresenter.shared.showError(error: error, priority: .max)
-                CCUtility.setPassword(account, password: nil)
+                NCKeychain().setPassword(account: account, password: nil)
             }
             }
         }
         }
     }
     }

+ 3 - 7
iOSClient/Networking/NCNetworkingProcessUpload.swift

@@ -33,10 +33,7 @@ class NCNetworkingProcessUpload: NSObject {
         return instance
         return instance
     }()
     }()
 
 
-    // swiftlint:disable force_cast
-    private let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     private var notificationToken: NotificationToken?
     private var notificationToken: NotificationToken?
     private var timerProcess: Timer?
     private var timerProcess: Timer?
     private var pauseProcess: Bool = false
     private var pauseProcess: Bool = false
@@ -274,9 +271,8 @@ class NCNetworkingProcessUpload: NSObject {
         // remove leaning upload share extension
         // remove leaning upload share extension
         let metadatasUploadShareExtension = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "session == %@ AND sessionSelector == %@", NextcloudKit.shared.nkCommonInstance.sessionIdentifierUpload, NCGlobal.shared.selectorUploadFileShareExtension))
         let metadatasUploadShareExtension = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "session == %@ AND sessionSelector == %@", NextcloudKit.shared.nkCommonInstance.sessionIdentifierUpload, NCGlobal.shared.selectorUploadFileShareExtension))
         for metadata in metadatasUploadShareExtension {
         for metadata in metadatasUploadShareExtension {
-            let path = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId)!
             NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
             NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
-            NCUtilityFileSystem.shared.deleteFile(filePath: path)
+            NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId))
         }
         }
 
 
         // verify metadataStatusInUpload (BACKGROUND)
         // verify metadataStatusInUpload (BACKGROUND)
@@ -328,7 +324,7 @@ class NCNetworkingProcessUpload: NSObject {
             NCNetworking.shared.transferInForegorund = nil
             NCNetworking.shared.transferInForegorund = nil
         }
         }
         for metadata in metadatasUploading {
         for metadata in metadatasUploading {
-            let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
+            let fileNameLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)
             if NCNetworking.shared.uploadRequest[fileNameLocalPath] == nil {
             if NCNetworking.shared.uploadRequest[fileNameLocalPath] == nil {
                 NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, session: nil, sessionError: "", sessionSelector: nil, sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusWaitUpload, errorCode: nil)
                 NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, session: nil, sessionError: "", sessionSelector: nil, sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusWaitUpload, errorCode: nil)
             }
             }

+ 4 - 6
iOSClient/Networking/NCService.swift

@@ -32,9 +32,7 @@ class NCService: NSObject {
         return instance
         return instance
     }()
     }()
 
 
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
 
 
     // MARK: -
     // MARK: -
 
 
@@ -139,7 +137,7 @@ class NCService: NSObject {
     func synchronize() {
     func synchronize() {
 
 
         NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] start synchronize Favorite")
         NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] start synchronize Favorite")
-        NextcloudKit.shared.listingFavorites(showHiddenFiles: CCUtility.getShowHiddenFiles(),
+        NextcloudKit.shared.listingFavorites(showHiddenFiles: NCKeychain().showHiddenFiles,
                                              options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { account, files, _, error in
                                              options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { account, files, _, error in
 
 
             guard error == .success else { return }
             guard error == .success else { return }
@@ -155,7 +153,7 @@ class NCService: NSObject {
     func getAvatar() {
     func getAvatar() {
 
 
         let fileName = appDelegate.userBaseUrl + "-" + self.appDelegate.user + ".png"
         let fileName = appDelegate.userBaseUrl + "-" + self.appDelegate.user + ".png"
-        let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + fileName
+        let fileNameLocalPath = NCUtilityFileSystem.shared.directoryUserData + "/" + fileName
         let etag = NCManageDatabase.shared.getTableAvatar(fileName: fileName)?.etag
         let etag = NCManageDatabase.shared.getTableAvatar(fileName: fileName)?.etag
 
 
         NextcloudKit.shared.downloadAvatar(user: appDelegate.userId,
         NextcloudKit.shared.downloadAvatar(user: appDelegate.userId,
@@ -271,7 +269,7 @@ class NCService: NSObject {
             }
             }
             if let fileName = fileNameToWrite, let image = imageData {
             if let fileName = fileNameToWrite, let image = imageData {
                 do {
                 do {
-                    let fileNamePath: String = CCUtility.getDirectoryUserData() + "/" + fileName + ".png"
+                    let fileNamePath = NCUtilityFileSystem.shared.directoryUserData + "/" + fileName + ".png"
                     try image.pngData()?.write(to: URL(fileURLWithPath: fileNamePath), options: .atomic)
                     try image.pngData()?.write(to: URL(fileURLWithPath: fileNamePath), options: .atomic)
                 } catch { }
                 } catch { }
             }
             }

+ 3 - 6
iOSClient/Notification/NCNotification.swift

@@ -29,10 +29,7 @@ import JGProgressHUD
 
 
 class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmptyDataSetDelegate {
 class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmptyDataSetDelegate {
 
 
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     var notifications: [NKNotifications] = []
     var notifications: [NKNotifications] = []
     var emptyDataSet: NCEmptyDataSet?
     var emptyDataSet: NCEmptyDataSet?
     var isReloadDataSourceNetworkInProgress: Bool = false
     var isReloadDataSourceNetworkInProgress: Bool = false
@@ -128,7 +125,7 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
         var image: UIImage?
         var image: UIImage?
 
 
         if let urlIcon = urlIcon {
         if let urlIcon = urlIcon {
-            let pathFileName = String(CCUtility.getDirectoryUserData()) + "/" + urlIcon.deletingPathExtension().lastPathComponent + ".png"
+            let pathFileName = NCUtilityFileSystem.shared.directoryUserData + "/" + urlIcon.deletingPathExtension().lastPathComponent + ".png"
             image = UIImage(contentsOfFile: pathFileName)
             image = UIImage(contentsOfFile: pathFileName)
         }
         }
 
 
@@ -148,7 +145,7 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
             cell.avatarLeadingMargin.constant = 50
             cell.avatarLeadingMargin.constant = 50
 
 
             let fileName = appDelegate.userBaseUrl + "-" + user + ".png"
             let fileName = appDelegate.userBaseUrl + "-" + user + ".png"
-            let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + fileName
+            let fileNameLocalPath = NCUtilityFileSystem.shared.directoryUserData + "/" + fileName
 
 
             if let image = UIImage(contentsOfFile: fileNameLocalPath) {
             if let image = UIImage(contentsOfFile: fileNameLocalPath) {
                 cell.avatar.image = image
                 cell.avatar.image = image

+ 21 - 21
iOSClient/PushNotification/NCPushNotification.m

@@ -54,8 +54,8 @@
     
     
     for (tableAccount *result in [[NCManageDatabase shared] getAllAccount]) {
     for (tableAccount *result in [[NCManageDatabase shared] getAllAccount]) {
         
         
-        NSString *token = [CCUtility getPushNotificationToken:result.account];
-        
+        NSString *token = [[[NCKeychain alloc] init] getPushNotificationTokenWithAccount:result.account];
+
         if (![token isEqualToString:self.pushKitToken]) {
         if (![token isEqualToString:self.pushKitToken]) {
             if (token != nil) {
             if (token != nil) {
                 // unsubscribing + subscribing
                 // unsubscribing + subscribing
@@ -73,8 +73,8 @@
     if (message) {
     if (message) {
         NSArray *results = [[NCManageDatabase shared] getAllAccount];
         NSArray *results = [[NCManageDatabase shared] getAllAccount];
         for (tableAccount *result in results) {
         for (tableAccount *result in results) {
-            if ([CCUtility getPushNotificationPrivateKey:result.account]) {
-                NSData *decryptionKey = [CCUtility getPushNotificationPrivateKey:result.account];
+            if ([[[NCKeychain alloc] init] getPushNotificationPrivateKeyWithAccount:result.account]) {
+                NSData *decryptionKey = [[[NCKeychain alloc] init] getPushNotificationPrivateKeyWithAccount:result.account];
                 NSString *decryptedMessage = [[NCPushNotificationEncryption shared] decryptPushNotification:message withDevicePrivateKey:decryptionKey];
                 NSString *decryptedMessage = [[NCPushNotificationEncryption shared] decryptPushNotification:message withDevicePrivateKey:decryptionKey];
                 if (decryptedMessage) {
                 if (decryptedMessage) {
                     NSData *data = [decryptedMessage dataUsingEncoding:NSUTF8StringEncoding];
                     NSData *data = [decryptedMessage dataUsingEncoding:NSUTF8StringEncoding];
@@ -102,11 +102,11 @@
     [[NCPushNotificationEncryption shared] generatePushNotificationsKeyPair:account];
     [[NCPushNotificationEncryption shared] generatePushNotificationsKeyPair:account];
 
 
     NSString *pushTokenHash = [[NCEndToEndEncryption sharedManager] createSHA512:self.pushKitToken];
     NSString *pushTokenHash = [[NCEndToEndEncryption sharedManager] createSHA512:self.pushKitToken];
-    NSData *pushPublicKey = [CCUtility getPushNotificationPublicKey:account];
+    NSData *pushPublicKey = [[[NCKeychain alloc] init] getPushNotificationPublicKeyWithAccount:account];
     NSString *pushDevicePublicKey = [[NSString alloc] initWithData:pushPublicKey encoding:NSUTF8StringEncoding];
     NSString *pushDevicePublicKey = [[NSString alloc] initWithData:pushPublicKey encoding:NSUTF8StringEncoding];
     NSString *proxyServerPath = [NCBrandOptions shared].pushNotificationServerProxy;
     NSString *proxyServerPath = [NCBrandOptions shared].pushNotificationServerProxy;
     
     
-    [[NextcloudKit shared] subscribingPushNotificationWithServerUrl:urlBase account:account user:user password:[CCUtility getPassword:account] pushTokenHash:pushTokenHash devicePublicKey:pushDevicePublicKey proxyServerUrl:proxyServerPath customUserAgent:nil addCustomHeaders:nil queue:dispatch_get_main_queue() completion:^(NSString *account, NSString *deviceIdentifier, NSString *signature, NSString *publicKey, NSData *data, NKError *error) {
+    [[NextcloudKit shared] subscribingPushNotificationWithServerUrl:urlBase account:account user:user password:[[[NCKeychain alloc] init] getPasswordWithAccount:account] pushTokenHash:pushTokenHash devicePublicKey:pushDevicePublicKey proxyServerUrl:proxyServerPath customUserAgent:nil addCustomHeaders:nil queue:dispatch_get_main_queue() completion:^(NSString *account, NSString *deviceIdentifier, NSString *signature, NSString *publicKey, NSData *data, NKError *error) {
         if (error == NKError.success) {
         if (error == NKError.success) {
             NSString *userAgent = [NSString stringWithFormat:@"%@  (Strict VoIP)", [[NCBrandOptions shared] getUserAgent]];
             NSString *userAgent = [NSString stringWithFormat:@"%@  (Strict VoIP)", [[NCBrandOptions shared] getUserAgent]];
             [[NextcloudKit shared] subscribingPushProxyWithProxyServerUrl:proxyServerPath pushToken:self.pushKitToken deviceIdentifier:deviceIdentifier signature:signature publicKey:publicKey userAgent:userAgent queue:dispatch_get_main_queue() completion:^(NKError *error) {
             [[NextcloudKit shared] subscribingPushProxyWithProxyServerUrl:proxyServerPath pushToken:self.pushKitToken deviceIdentifier:deviceIdentifier signature:signature publicKey:publicKey userAgent:userAgent queue:dispatch_get_main_queue() completion:^(NKError *error) {
@@ -114,10 +114,10 @@
 
 
                     [[[NextcloudKit shared] nkCommonInstance] writeLog:@"[INFO] Subscribed to Push Notification server & proxy successfully"];
                     [[[NextcloudKit shared] nkCommonInstance] writeLog:@"[INFO] Subscribed to Push Notification server & proxy successfully"];
 
 
-                    [CCUtility setPushNotificationToken:account token:self.pushKitToken];
-                    [CCUtility setPushNotificationDeviceIdentifier:account deviceIdentifier:deviceIdentifier];
-                    [CCUtility setPushNotificationDeviceIdentifierSignature:account deviceIdentifierSignature:signature];
-                    [CCUtility setPushNotificationSubscribingPublicKey:account publicKey:publicKey];
+                    [[[NCKeychain alloc] init] setPushNotificationTokenWithAccount:account token:self.pushKitToken];
+                    [[[NCKeychain alloc] init] setPushNotificationDeviceIdentifierWithAccount:account deviceIdentifier:deviceIdentifier];
+                    [[[NCKeychain alloc] init] setPushNotificationDeviceIdentifierSignatureWithAccount:account deviceIdentifierSignature:signature];
+                    [[[NCKeychain alloc] init] setPushNotificationSubscribingPublicKeyWithAccount:account publicKey:publicKey];
                 }
                 }
             }];
             }];
         }
         }
@@ -128,11 +128,11 @@
 {
 {
     if (appDelegate.account == nil || appDelegate.account.length == 0) { return; }
     if (appDelegate.account == nil || appDelegate.account.length == 0) { return; }
     
     
-    NSString *deviceIdentifier = [CCUtility getPushNotificationDeviceIdentifier:account];
-    NSString *signature = [CCUtility getPushNotificationDeviceIdentifierSignature:account];
-    NSString *publicKey = [CCUtility getPushNotificationSubscribingPublicKey:account];
+    NSString *deviceIdentifier = [[[NCKeychain alloc] init] getPushNotificationDeviceIdentifierWithAccount:account];
+    NSString *signature = [[[NCKeychain alloc] init] getPushNotificationDeviceIdentifierSignatureWithAccount:account];
+    NSString *publicKey = [[[NCKeychain alloc] init] getPushNotificationSubscribingPublicKeyWithAccount:account];
 
 
-    [[NextcloudKit shared] unsubscribingPushNotificationWithServerUrl:urlBase account:account user:user password:[CCUtility getPassword:account] customUserAgent:nil addCustomHeaders:nil queue:dispatch_get_main_queue() completion:^(NSString *account, NKError *error) {
+    [[NextcloudKit shared] unsubscribingPushNotificationWithServerUrl:urlBase account:account user:user password:[[[NCKeychain alloc] init] getPasswordWithAccount:account] customUserAgent:nil addCustomHeaders:nil queue:dispatch_get_main_queue() completion:^(NSString *account, NKError *error) {
         if (error == NKError.success) {
         if (error == NKError.success) {
             NSString *userAgent = [NSString stringWithFormat:@"%@  (Strict VoIP)", [[NCBrandOptions shared] getUserAgent]];
             NSString *userAgent = [NSString stringWithFormat:@"%@  (Strict VoIP)", [[NCBrandOptions shared] getUserAgent]];
             NSString *proxyServerPath = [NCBrandOptions shared].pushNotificationServerProxy;
             NSString *proxyServerPath = [NCBrandOptions shared].pushNotificationServerProxy;
@@ -141,13 +141,13 @@
                 
                 
                     [[[NextcloudKit shared] nkCommonInstance] writeLog:@"[INFO] Unsubscribed to Push Notification server & proxy successfully."];
                     [[[NextcloudKit shared] nkCommonInstance] writeLog:@"[INFO] Unsubscribed to Push Notification server & proxy successfully."];
                     
                     
-                    [CCUtility setPushNotificationPublicKey:account data:nil];
-                    [CCUtility setPushNotificationSubscribingPublicKey:account publicKey:nil];
-                    [CCUtility setPushNotificationPrivateKey:account data:nil];
-                    [CCUtility setPushNotificationToken:account token:nil];
-                    [CCUtility setPushNotificationDeviceIdentifier:account deviceIdentifier:nil];
-                    [CCUtility setPushNotificationDeviceIdentifierSignature:account deviceIdentifierSignature:nil];
-                    
+                    [[[NCKeychain alloc] init] setPushNotificationPublicKeyWithAccount:account data:nil];
+                    [[[NCKeychain alloc] init] setPushNotificationSubscribingPublicKeyWithAccount:account publicKey:nil];
+                    [[[NCKeychain alloc] init] setPushNotificationPrivateKeyWithAccount:account data:nil];
+                    [[[NCKeychain alloc] init] setPushNotificationTokenWithAccount:account token:nil];
+                    [[[NCKeychain alloc] init] setPushNotificationDeviceIdentifierWithAccount:account deviceIdentifier:nil];
+                    [[[NCKeychain alloc] init] setPushNotificationDeviceIdentifierSignatureWithAccount:account deviceIdentifierSignature:nil];
+
                     if (self.pushKitToken != nil && subscribing) {
                     if (self.pushKitToken != nil && subscribing) {
                         [self subscribingNextcloudServerPushNotification:account urlBase:urlBase user:user];
                         [self subscribingNextcloudServerPushNotification:account urlBase:urlBase user:user];
                     }
                     }

+ 1 - 1
iOSClient/PushNotification/NCPushNotificationEncryption.h

@@ -23,7 +23,7 @@
 //  This code derived from : Nextcloud Talk - NCSettingsController Created by Ivan Sein on 26.06.17. Copyright © 2017 struktur AG. All rights reserved.
 //  This code derived from : Nextcloud Talk - NCSettingsController Created by Ivan Sein on 26.06.17. Copyright © 2017 struktur AG. All rights reserved.
 //
 //
 
 
-#import <Foundation/Foundation.h>
+#import <UIKit/UIKit.h>
 
 
 @interface NCPushNotificationEncryption : NSObject
 @interface NCPushNotificationEncryption : NSObject
 
 

+ 4 - 4
iOSClient/PushNotification/NCPushNotificationEncryption.m

@@ -24,10 +24,9 @@
 //
 //
 
 
 #import "NCPushNotificationEncryption.h"
 #import "NCPushNotificationEncryption.h"
-
+#import "NCBridgeSwift.h"
 #import <OpenSSL/OpenSSL.h>
 #import <OpenSSL/OpenSSL.h>
 #import <CommonCrypto/CommonDigest.h>
 #import <CommonCrypto/CommonDigest.h>
-
 #import "NCEndToEndEncryption.h"
 #import "NCEndToEndEncryption.h"
 #import "CCUtility.h"
 #import "CCUtility.h"
 
 
@@ -75,7 +74,8 @@
     
     
     BIO_read(publicKeyBIO, keyBytes, len);
     BIO_read(publicKeyBIO, keyBytes, len);
     NSData *ncPNPublicKey = [NSData dataWithBytes:keyBytes length:len];
     NSData *ncPNPublicKey = [NSData dataWithBytes:keyBytes length:len];
-    [CCUtility setPushNotificationPublicKey:account data:ncPNPublicKey];
+
+    [[[NCKeychain alloc] init] setPushNotificationPublicKeyWithAccount:account data:ncPNPublicKey];
     NSLog(@"Push Notifications Key Pair generated: \n%@", [[NSString alloc] initWithData:ncPNPublicKey encoding:NSUTF8StringEncoding]);
     NSLog(@"Push Notifications Key Pair generated: \n%@", [[NSString alloc] initWithData:ncPNPublicKey encoding:NSUTF8StringEncoding]);
     
     
     // PrivateKey
     // PrivateKey
@@ -87,7 +87,7 @@
     
     
     BIO_read(privateKeyBIO, keyBytes, len);
     BIO_read(privateKeyBIO, keyBytes, len);
     NSData *ncPNPrivateKey = [NSData dataWithBytes:keyBytes length:len];
     NSData *ncPNPrivateKey = [NSData dataWithBytes:keyBytes length:len];
-    [CCUtility setPushNotificationPrivateKey:account data:ncPNPrivateKey];
+    [[[NCKeychain alloc] init] setPushNotificationPrivateKeyWithAccount:account data:ncPNPrivateKey];
     
     
     RSA_free(rsa);
     RSA_free(rsa);
     BN_free(bigNumber);
     BN_free(bigNumber);

+ 1 - 1
iOSClient/Recent/NCRecent.swift

@@ -151,7 +151,7 @@ class NCRecent: NCCollectionViewCommon {
 
 
         NextcloudKit.shared.searchBodyRequest(serverUrl: appDelegate.urlBase,
         NextcloudKit.shared.searchBodyRequest(serverUrl: appDelegate.urlBase,
                                               requestBody: requestBody,
                                               requestBody: requestBody,
-                                              showHiddenFiles: CCUtility.getShowHiddenFiles(),
+                                              showHiddenFiles: NCKeychain().showHiddenFiles,
                                               options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { account, files, _, error in
                                               options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { account, files, _, error in
 
 
             self.isReloadDataSourceNetworkInProgress = false
             self.isReloadDataSourceNetworkInProgress = false

+ 3 - 5
iOSClient/RichWorkspace/NCRichWorkspaceCommon.swift

@@ -26,9 +26,7 @@ import NextcloudKit
 
 
 @objc class NCRichWorkspaceCommon: NSObject {
 @objc class NCRichWorkspaceCommon: NSObject {
 
 
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
 
 
     @objc func createViewerNextcloudText(serverUrl: String, viewController: UIViewController) {
     @objc func createViewerNextcloudText(serverUrl: String, viewController: UIViewController) {
 
 
@@ -42,7 +40,7 @@ import NextcloudKit
 
 
         NCActivityIndicator.shared.start(backgroundView: viewController.view)
         NCActivityIndicator.shared.start(backgroundView: viewController.view)
 
 
-        let fileNamePath = CCUtility.returnFileNamePath(fromFileName: NCGlobal.shared.fileNameRichWorkspace, serverUrl: serverUrl, urlBase: appDelegate.urlBase, userId: appDelegate.userId, account: appDelegate.account)!
+        let fileNamePath = NCUtilityFileSystem.shared.getFileNamePath(NCGlobal.shared.fileNameRichWorkspace, serverUrl: serverUrl, urlBase: appDelegate.urlBase, userId: appDelegate.userId)
         NextcloudKit.shared.NCTextCreateFile(fileNamePath: fileNamePath, editorId: directEditingCreator.editor, creatorId: directEditingCreator.identifier, templateId: "") { account, url, _, error in
         NextcloudKit.shared.NCTextCreateFile(fileNamePath: fileNamePath, editorId: directEditingCreator.editor, creatorId: directEditingCreator.identifier, templateId: "") { account, url, _, error in
 
 
             NCActivityIndicator.shared.stop()
             NCActivityIndicator.shared.stop()
@@ -77,7 +75,7 @@ import NextcloudKit
 
 
                 NCActivityIndicator.shared.start(backgroundView: viewController.view)
                 NCActivityIndicator.shared.start(backgroundView: viewController.view)
 
 
-                let fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, urlBase: appDelegate.urlBase, userId: appDelegate.userId, account: appDelegate.account)!
+                let fileNamePath = NCUtilityFileSystem.shared.getFileNamePath(metadata.fileName, serverUrl: metadata.serverUrl, urlBase: appDelegate.urlBase, userId: appDelegate.userId)
                 NextcloudKit.shared.NCTextOpenFile(fileNamePath: fileNamePath, editor: "text") { account, url, _, error in
                 NextcloudKit.shared.NCTextOpenFile(fileNamePath: fileNamePath, editor: "text") { account, url, _, error in
 
 
                     NCActivityIndicator.shared.stop()
                     NCActivityIndicator.shared.stop()

+ 1 - 4
iOSClient/RichWorkspace/NCViewerRichWorkspace.swift

@@ -29,10 +29,7 @@ import MarkdownKit
 
 
     @IBOutlet weak var textView: UITextView!
     @IBOutlet weak var textView: UITextView!
 
 
-    // swiftlint:disable force_cast
-    private let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     private let richWorkspaceCommon = NCRichWorkspaceCommon()
     private let richWorkspaceCommon = NCRichWorkspaceCommon()
     private var markdownParser = MarkdownParser()
     private var markdownParser = MarkdownParser()
     private var textViewColor: UIColor?
     private var textViewColor: UIColor?

+ 1 - 1
iOSClient/Scan document/NCDocumentCamera.swift

@@ -54,7 +54,7 @@ class NCDocumentCamera: NSObject, VNDocumentCameraViewControllerDelegate {
                                                     keyFileNameType: NCGlobal.shared.keyFileNameType,
                                                     keyFileNameType: NCGlobal.shared.keyFileNameType,
                                                     keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal,
                                                     keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal,
                                                     forcedNewFileName: true)!
                                                     forcedNewFileName: true)!
-            let fileNamePath = CCUtility.getDirectoryScan() + "/" + fileName
+            let fileNamePath = NCUtilityFileSystem.shared.directoryScan + "/" + fileName
             let image = scan.imageOfPage(at: pageNumber)
             let image = scan.imageOfPage(at: pageNumber)
             do {
             do {
                 try image.pngData()?.write(to: NSURL.fileURL(withPath: fileNamePath))
                 try image.pngData()?.write(to: NSURL.fileURL(withPath: fileNamePath))

+ 3 - 3
iOSClient/Scan document/NCScan+CollectionView.swift

@@ -36,7 +36,7 @@ extension NCScan: UICollectionViewDataSource {
 
 
             let cell = (collectionView.dequeueReusableCell(withReuseIdentifier: "cell1", for: indexPath) as? NCScanCell)!
             let cell = (collectionView.dequeueReusableCell(withReuseIdentifier: "cell1", for: indexPath) as? NCScanCell)!
 
 
-            let fileNamePath = CCUtility.getDirectoryScan() + "/" + itemsSource[indexPath.row]
+            let fileNamePath = NCUtilityFileSystem.shared.directoryScan + "/" + itemsSource[indexPath.row]
 
 
             guard let data = try? Data(contentsOf: URL(fileURLWithPath: fileNamePath)), var image = UIImage(data: data) else { return cell }
             guard let data = try? Data(contentsOf: URL(fileURLWithPath: fileNamePath)), var image = UIImage(data: data) else { return cell }
 
 
@@ -55,8 +55,8 @@ extension NCScan: UICollectionViewDataSource {
                 let buttonPosition: CGPoint = (sender as? UIButton)!.convert(.zero, to: self.collectionViewSource)
                 let buttonPosition: CGPoint = (sender as? UIButton)!.convert(.zero, to: self.collectionViewSource)
                 if let indexPath = self.collectionViewSource.indexPathForItem(at: buttonPosition) {
                 if let indexPath = self.collectionViewSource.indexPathForItem(at: buttonPosition) {
 
 
-                    let fileNameAtPath = CCUtility.getDirectoryScan() + "/" + self.itemsSource[indexPath.row]
-                    CCUtility.removeFile(atPath: fileNameAtPath)
+                    let fileNameAtPath = NCUtilityFileSystem.shared.directoryScan + "/" + self.itemsSource[indexPath.row]
+                    NCUtilityFileSystem.shared.removeFile(atPath: fileNameAtPath)
                     self.itemsSource.remove(at: indexPath.row)
                     self.itemsSource.remove(at: indexPath.row)
 
 
                     self.collectionViewSource.deleteItems(at: [indexPath])
                     self.collectionViewSource.deleteItems(at: [indexPath])

+ 4 - 4
iOSClient/Scan document/NCScan.swift

@@ -191,7 +191,7 @@ class NCScan: UIViewController, NCScanCellCellDelegate {
 
 
         for fileName in itemsSource where !itemsDestination.contains(fileName) {
         for fileName in itemsSource where !itemsDestination.contains(fileName) {
 
 
-            let fileNamePathAt = CCUtility.getDirectoryScan() + "/" + fileName
+            let fileNamePathAt = NCUtilityFileSystem.shared.directoryScan + "/" + fileName
             guard let data = try? Data(contentsOf: URL(fileURLWithPath: fileNamePathAt)), let image = UIImage(data: data) else { return }
             guard let data = try? Data(contentsOf: URL(fileURLWithPath: fileNamePathAt)), let image = UIImage(data: data) else { return }
 
 
             imagesDestination.append(image)
             imagesDestination.append(image)
@@ -228,7 +228,7 @@ class NCScan: UIViewController, NCScanCellCellDelegate {
         itemsSource.removeAll()
         itemsSource.removeAll()
 
 
         do {
         do {
-            let atPath = CCUtility.getDirectoryScan()!
+            let atPath = NCUtilityFileSystem.shared.directoryScan
             let directoryContents = try FileManager.default.contentsOfDirectory(atPath: atPath)
             let directoryContents = try FileManager.default.contentsOfDirectory(atPath: atPath)
             for fileName in directoryContents where fileName.first != "." {
             for fileName in directoryContents where fileName.first != "." {
                 itemsSource.append(fileName)
                 itemsSource.append(fileName)
@@ -329,7 +329,7 @@ class NCScan: UIViewController, NCScanCellCellDelegate {
                 if collectionView === collectionViewDestination {
                 if collectionView === collectionViewDestination {
 
 
                     let fileName = (item.dragItem.localObject as? String)!
                     let fileName = (item.dragItem.localObject as? String)!
-                    let fileNamePathAt = CCUtility.getDirectoryScan() + "/" + fileName
+                    let fileNamePathAt = NCUtilityFileSystem.shared.directoryScan + "/" + fileName
 
 
                     guard let data = try? Data(contentsOf: URL(fileURLWithPath: fileNamePathAt)), let image = UIImage(data: data) else { return }
                     guard let data = try? Data(contentsOf: URL(fileURLWithPath: fileNamePathAt)), let image = UIImage(data: data) else { return }
 
 
@@ -382,7 +382,7 @@ class NCScan: UIViewController, NCScanCellCellDelegate {
                                                     keyFileNameType: NCGlobal.shared.keyFileNameType,
                                                     keyFileNameType: NCGlobal.shared.keyFileNameType,
                                                     keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal,
                                                     keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal,
                                                     forcedNewFileName: true)!
                                                     forcedNewFileName: true)!
-            let fileNamePath = CCUtility.getDirectoryScan() + "/" + fileName
+            let fileNamePath = NCUtilityFileSystem.shared.directoryScan + "/" + fileName
 
 
             do {
             do {
                 try image.pngData()?.write(to: NSURL.fileURL(withPath: fileNamePath), options: .atomic)
                 try image.pngData()?.write(to: NSURL.fileURL(withPath: fileNamePath), options: .atomic)

+ 9 - 11
iOSClient/Scan document/NCUploadScanDocument.swift

@@ -99,7 +99,7 @@ class NCUploadScanDocument: ObservableObject {
     func createPDF(metadata: tableMetadata, completion: @escaping (_ error: Bool) -> Void) {
     func createPDF(metadata: tableMetadata, completion: @escaping (_ error: Bool) -> Void) {
 
 
         DispatchQueue.global().async {
         DispatchQueue.global().async {
-            let fileNamePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
+            let fileNamePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)
             let pdfData = NSMutableData()
             let pdfData = NSMutableData()
 
 
             if self.password.isEmpty {
             if self.password.isEmpty {
@@ -127,7 +127,7 @@ class NCUploadScanDocument: ObservableObject {
                 metadata.size = NCUtilityFileSystem.shared.getFileSize(filePath: fileNamePath)
                 metadata.size = NCUtilityFileSystem.shared.getFileSize(filePath: fileNamePath)
                 NCNetworkingProcessUpload.shared.createProcessUploads(metadatas: [metadata], completion: { _ in })
                 NCNetworkingProcessUpload.shared.createProcessUploads(metadatas: [metadata], completion: { _ in })
                 if self.removeAllFiles {
                 if self.removeAllFiles {
-                    let path = CCUtility.getDirectoryScan()!
+                    let path = NCUtilityFileSystem.shared.directoryScan
                     let filePaths = try FileManager.default.contentsOfDirectory(atPath: path)
                     let filePaths = try FileManager.default.contentsOfDirectory(atPath: path)
                     for filePath in filePaths {
                     for filePath in filePaths {
                         try FileManager.default.removeItem(atPath: path + "/" + filePath)
                         try FileManager.default.removeItem(atPath: path + "/" + filePath)
@@ -319,7 +319,6 @@ extension NCUploadScanDocument: NCSelectDelegate {
     func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String, items: [Any], indexPath: [IndexPath], overwrite: Bool, copy: Bool, move: Bool) {
     func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String, items: [Any], indexPath: [IndexPath], overwrite: Bool, copy: Bool, move: Bool) {
 
 
         if let serverUrl = serverUrl {
         if let serverUrl = serverUrl {
-            CCUtility.setDirectoryScanDocument(serverUrl)
             self.serverUrl = serverUrl
             self.serverUrl = serverUrl
         }
         }
     }
     }
@@ -345,12 +344,12 @@ extension NCUploadScanDocument: NCCreateFormUploadConflictDelegate {
 
 
 struct UploadScanDocumentView: View {
 struct UploadScanDocumentView: View {
 
 
-    @State var fileName = CCUtility.createFileNameDate("scan", extension: "") ?? "scan"
+    @State var fileName = NCUtilityFileSystem.shared.createFileNameDate("scan", ext: "")
     @State var password: String = ""
     @State var password: String = ""
     @State var isSecuredPassword: Bool = true
     @State var isSecuredPassword: Bool = true
-    @State var isTextRecognition: Bool = CCUtility.getTextRecognitionStatus()
-    @State var quality = CCUtility.getQualityScanDocument()
-    @State var removeAllFiles: Bool = CCUtility.getDeleteAllScanImages()
+    @State var isTextRecognition: Bool = NCKeychain().textRecognitionStatus
+    @State var quality = NCKeychain().qualityScanDocument
+    @State var removeAllFiles: Bool = NCKeychain().deleteAllScanImages
     @State var isPresentedSelect = false
     @State var isPresentedSelect = false
     @State var isPresentedUploadConflict = false
     @State var isPresentedUploadConflict = false
 
 
@@ -437,7 +436,7 @@ struct UploadScanDocumentView: View {
                             Toggle(NSLocalizedString("_text_recognition_", comment: ""), isOn: $isTextRecognition)
                             Toggle(NSLocalizedString("_text_recognition_", comment: ""), isOn: $isTextRecognition)
                                 .toggleStyle(SwitchToggleStyle(tint: Color(NCBrandColor.shared.brand)))
                                 .toggleStyle(SwitchToggleStyle(tint: Color(NCBrandColor.shared.brand)))
                                 .onChange(of: isTextRecognition) { newValue in
                                 .onChange(of: isTextRecognition) { newValue in
-                                    CCUtility.setTextRecognitionStatus(newValue)
+                                    NCKeychain().textRecognitionStatus = newValue
                                 }
                                 }
                         }
                         }
                     }
                     }
@@ -450,8 +449,7 @@ struct UploadScanDocumentView: View {
                         Toggle(NSLocalizedString("_delete_all_scanned_images_", comment: ""), isOn: $removeAllFiles)
                         Toggle(NSLocalizedString("_delete_all_scanned_images_", comment: ""), isOn: $removeAllFiles)
                             .toggleStyle(SwitchToggleStyle(tint: Color(NCBrandColor.shared.brand)))
                             .toggleStyle(SwitchToggleStyle(tint: Color(NCBrandColor.shared.brand)))
                             .onChange(of: removeAllFiles) { newValue in
                             .onChange(of: removeAllFiles) { newValue in
-                                CCUtility.setDeleteAllScanImages(newValue)
-
+                                NCKeychain().deleteAllScanImages = newValue
                             }
                             }
 
 
                         Button(NSLocalizedString("_save_", comment: "")) {
                         Button(NSLocalizedString("_save_", comment: "")) {
@@ -478,7 +476,7 @@ struct UploadScanDocumentView: View {
                         VStack {
                         VStack {
                             Slider(value: $quality, in: 0...4, step: 1, onEditingChanged: { touch in
                             Slider(value: $quality, in: 0...4, step: 1, onEditingChanged: { touch in
                                 if !touch {
                                 if !touch {
-                                    CCUtility.setQualityScanDocument(quality)
+                                    NCKeychain().qualityScanDocument = quality
                                 }
                                 }
                             })
                             })
                             .accentColor(Color(NCBrandColor.shared.brand))
                             .accentColor(Color(NCBrandColor.shared.brand))

+ 6 - 6
iOSClient/Select/NCSelect.swift

@@ -249,7 +249,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
 
 
     func pushMetadata(_ metadata: tableMetadata) {
     func pushMetadata(_ metadata: tableMetadata) {
 
 
-        guard let serverUrlPush = CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName) else { return }
+        let serverUrlPush = NCUtilityFileSystem.shared.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName)
         guard let viewController = UIStoryboard(name: "NCSelect", bundle: nil).instantiateViewController(withIdentifier: "NCSelect.storyboard") as? NCSelect else { return }
         guard let viewController = UIStoryboard(name: "NCSelect", bundle: nil).instantiateViewController(withIdentifier: "NCSelect.storyboard") as? NCSelect else { return }
 
 
         self.serverUrlPush = serverUrlPush
         self.serverUrlPush = serverUrlPush
@@ -298,15 +298,15 @@ extension NCSelect: UICollectionViewDataSource {
 
 
         // Thumbnail
         // Thumbnail
         if !metadata.directory {
         if !metadata.directory {
-            if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)) {
-                (cell as? NCCellProtocol)?.filePreviewImageView?.image = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag))
+            if FileManager().fileExists(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)) {
+                (cell as? NCCellProtocol)?.filePreviewImageView?.image = UIImage(contentsOfFile: NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag))
             } else {
             } else {
                 if metadata.iconName.isEmpty {
                 if metadata.iconName.isEmpty {
                     (cell as? NCCellProtocol)?.filePreviewImageView?.image = NCBrandColor.cacheImages.file
                     (cell as? NCCellProtocol)?.filePreviewImageView?.image = NCBrandColor.cacheImages.file
                 } else {
                 } else {
                     (cell as? NCCellProtocol)?.filePreviewImageView?.image = UIImage(named: metadata.iconName)
                     (cell as? NCCellProtocol)?.filePreviewImageView?.image = UIImage(named: metadata.iconName)
                 }
                 }
-                if metadata.hasPreview && metadata.status == NCGlobal.shared.metadataStatusNormal && (!CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag)) {
+                if metadata.hasPreview && metadata.status == NCGlobal.shared.metadataStatusNormal && (!NCUtilityFileSystem.shared.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag)) {
                     for case let operation as NCCollectionViewDownloadThumbnail in appDelegate.downloadThumbnailQueue.operations where operation.metadata.ocId == metadata.ocId { return }
                     for case let operation as NCCollectionViewDownloadThumbnail in appDelegate.downloadThumbnailQueue.operations where operation.metadata.ocId == metadata.ocId { return }
                     appDelegate.downloadThumbnailQueue.addOperation(NCCollectionViewDownloadThumbnail(metadata: metadata, cell: (cell as? NCCellProtocol), collectionView: collectionView))
                     appDelegate.downloadThumbnailQueue.addOperation(NCCollectionViewDownloadThumbnail(metadata: metadata, cell: (cell as? NCCellProtocol), collectionView: collectionView))
                 }
                 }
@@ -391,12 +391,12 @@ extension NCSelect: UICollectionViewDataSource {
 
 
         } else {
         } else {
 
 
-            cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date) + " · " + CCUtility.transformedSize(metadata.size)
+            cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date) + " · " + NCUtilityFileSystem.shared.transformedSize(metadata.size)
 
 
             // image local
             // image local
             if NCManageDatabase.shared.getTableLocalFile(ocId: metadata.ocId) != nil {
             if NCManageDatabase.shared.getTableLocalFile(ocId: metadata.ocId) != nil {
                 cell.imageLocal.image = NCBrandColor.cacheImages.offlineFlag
                 cell.imageLocal.image = NCBrandColor.cacheImages.offlineFlag
-            } else if CCUtility.fileProviderStorageExists(metadata) {
+            } else if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) {
                 cell.imageLocal.image = NCBrandColor.cacheImages.local
                 cell.imageLocal.image = NCBrandColor.cacheImages.local
             }
             }
         }
         }

+ 2 - 2
iOSClient/Settings/Acknowledgements.rtf

@@ -1,4 +1,4 @@
-{\rtf1\ansi\ansicpg1252\cocoartf2708
+{\rtf1\ansi\ansicpg1252\cocoartf2757
 \cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fswiss\fcharset0 Helvetica-Bold;}
 \cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fswiss\fcharset0 Helvetica-Bold;}
 {\colortbl;\red255\green255\blue255;}
 {\colortbl;\red255\green255\blue255;}
 {\*\expandedcolortbl;;}
 {\*\expandedcolortbl;;}
@@ -57,7 +57,7 @@ Copyright (c) 2014-2017 https://realm.io\
 __________________________________\
 __________________________________\
 \
 \
 
 
-\f1\b UICKeyChainStore
+\f1\b KeychainAccess
 \f0\b0 \
 \f0\b0 \
 \
 \
 MIT License\
 MIT License\

+ 31 - 31
iOSClient/Settings/CCAdvanced.m

@@ -48,7 +48,7 @@
     
     
     row = [XLFormRowDescriptor formRowDescriptorWithTag:@"showHiddenFiles" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_show_hidden_files_", nil)];
     row = [XLFormRowDescriptor formRowDescriptorWithTag:@"showHiddenFiles" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_show_hidden_files_", nil)];
     row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
     row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
-    if ([CCUtility getShowHiddenFiles]) row.value = @"1";
+    if ([[[NCKeychain alloc] init] showHiddenFiles]) row.value = @"1";
     else row.value = @"0";
     else row.value = @"0";
     [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
     [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
     [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
     [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
@@ -62,7 +62,7 @@
 
 
     row = [XLFormRowDescriptor formRowDescriptorWithTag:@"formatCompatibility" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_format_compatibility_", nil)];
     row = [XLFormRowDescriptor formRowDescriptorWithTag:@"formatCompatibility" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_format_compatibility_", nil)];
     row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
     row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
-    if ([CCUtility getFormatCompatibility]) row.value = @"1";
+    if ([[[NCKeychain alloc] init] formatCompatibility]) row.value = @"1";
     else row.value = @"0";
     else row.value = @"0";
     [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
     [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
     [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
     [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
@@ -70,7 +70,7 @@
     
     
     row = [XLFormRowDescriptor formRowDescriptorWithTag:@"livePhoto" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_upload_mov_livephoto_", nil)];
     row = [XLFormRowDescriptor formRowDescriptorWithTag:@"livePhoto" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_upload_mov_livephoto_", nil)];
     row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
     row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
-    if ([CCUtility getLivePhoto]) row.value = @"1";
+    if ([[[NCKeychain alloc] init] livePhoto]) row.value = @"1";
     else row.value = @"0";
     else row.value = @"0";
     [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
     [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
     [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
     [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
@@ -78,7 +78,7 @@
 
 
     row = [XLFormRowDescriptor formRowDescriptorWithTag:@"removePhotoCameraRoll" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_remove_photo_CameraRoll_", nil)];
     row = [XLFormRowDescriptor formRowDescriptorWithTag:@"removePhotoCameraRoll" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_remove_photo_CameraRoll_", nil)];
     row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
     row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
-    if ([CCUtility getRemovePhotoCameraRoll]) row.value = @"1";
+    if ([[[NCKeychain alloc] init] removePhotoCameraRoll]) row.value = @"1";
     else row.value = @0;
     else row.value = @0;
     [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
     [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
     [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
     [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
@@ -95,7 +95,7 @@
         // Disable Files App
         // Disable Files App
         row = [XLFormRowDescriptor formRowDescriptorWithTag:@"disablefilesapp" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_disable_files_app_", nil)];
         row = [XLFormRowDescriptor formRowDescriptorWithTag:@"disablefilesapp" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_disable_files_app_", nil)];
         row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
         row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
-        if ([CCUtility getDisableFilesApp]) row.value = @"1";
+        if ([[NCKeychain alloc] init].disableFilesApp) row.value = @"1";
         else row.value = @"0";
         else row.value = @"0";
         [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
         [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
         [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
         [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
@@ -115,7 +115,7 @@
         [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
         [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
         [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
         [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
         [row.cellConfig setObject:[[UIImage imageNamed:@"crashservice"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"];
         [row.cellConfig setObject:[[UIImage imageNamed:@"crashservice"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"];
-        if ([CCUtility getDisableCrashservice]) row.value = @"1";
+        if ([[[NCKeychain alloc] init] disableCrashservice]) row.value = @"1";
         else row.value = @"0";
         else row.value = @"0";
         [section addFormRow:row];
         [section addFormRow:row];
     }
     }
@@ -153,7 +153,7 @@
 
 
             [[[NextcloudKit shared] nkCommonInstance] clearFileLog];
             [[[NextcloudKit shared] nkCommonInstance] clearFileLog];
             
             
-            NSInteger logLevel = [CCUtility getLogLevel];
+            NSInteger logLevel = [[NCKeychain alloc] init].logLevel;
             BOOL isSimulatorOrTestFlight = [[NCUtility shared] isSimulatorOrTestFlight];
             BOOL isSimulatorOrTestFlight = [[NCUtility shared] isSimulatorOrTestFlight];
             NSString *versionNextcloudiOS = [NSString stringWithFormat:[NCBrandOptions shared].textCopyrightNextcloudiOS, [[NCUtility shared] getVersionAppWithBuild:true]];
             NSString *versionNextcloudiOS = [NSString stringWithFormat:[NCBrandOptions shared].textCopyrightNextcloudiOS, [[NCUtility shared] getVersionAppWithBuild:true]];
             if (isSimulatorOrTestFlight) {
             if (isSimulatorOrTestFlight) {
@@ -169,7 +169,7 @@
         [row.cellConfig setObject:@(NSTextAlignmentCenter) forKey:@"textLabel.textAlignment"];
         [row.cellConfig setObject:@(NSTextAlignmentCenter) forKey:@"textLabel.textAlignment"];
         [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
         [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
         [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
         [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
-        NSInteger logLevel = [CCUtility getLogLevel];
+        NSInteger logLevel = [[NCKeychain alloc] init].logLevel;
         row.value = @(logLevel);
         row.value = @(logLevel);
         [row.cellConfigAtConfigure setObject:@(2) forKey:@"slider.maximumValue"];
         [row.cellConfigAtConfigure setObject:@(2) forKey:@"slider.maximumValue"];
         [row.cellConfigAtConfigure setObject:@(0) forKey:@"slider.minimumValue"];
         [row.cellConfigAtConfigure setObject:@(0) forKey:@"slider.minimumValue"];
@@ -200,7 +200,7 @@
 
 
     row = [XLFormRowDescriptor formRowDescriptorWithTag:@"deleteoldfiles" rowType:XLFormRowDescriptorTypeSelectorPush title:NSLocalizedString(@"_delete_old_files_", nil)];
     row = [XLFormRowDescriptor formRowDescriptorWithTag:@"deleteoldfiles" rowType:XLFormRowDescriptorTypeSelectorPush title:NSLocalizedString(@"_delete_old_files_", nil)];
     
     
-    switch (CCUtility.getCleanUpDay) {
+    switch ([[NCKeychain alloc] init].cleanUpDay) {
         case 0:
         case 0:
             row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(0) displayText:NSLocalizedString(@"_never_", nil)];
             row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(0) displayText:NSLocalizedString(@"_never_", nil)];
             break;
             break;
@@ -313,33 +313,33 @@
     
     
     if ([rowDescriptor.tag isEqualToString:@"showHiddenFiles"]) {
     if ([rowDescriptor.tag isEqualToString:@"showHiddenFiles"]) {
         
         
-        [CCUtility setShowHiddenFiles:[[rowDescriptor.value valueData] boolValue]];        
+        [[NCKeychain alloc] init].showHiddenFiles = [[rowDescriptor.value valueData] boolValue];
     }
     }
     
     
     if ([rowDescriptor.tag isEqualToString:@"formatCompatibility"]) {
     if ([rowDescriptor.tag isEqualToString:@"formatCompatibility"]) {
         
         
-        [CCUtility setFormatCompatibility:[[rowDescriptor.value valueData] boolValue]];
+        [[NCKeychain alloc] init].formatCompatibility = [[rowDescriptor.value valueData] boolValue];
     }
     }
     
     
     if ([rowDescriptor.tag isEqualToString:@"livePhoto"]) {
     if ([rowDescriptor.tag isEqualToString:@"livePhoto"]) {
         
         
-        [CCUtility setLivePhoto:[[rowDescriptor.value valueData] boolValue]];
+        [[NCKeychain alloc] init].livePhoto = [[rowDescriptor.value valueData] boolValue];
     }
     }
 
 
     if ([rowDescriptor.tag isEqualToString:@"removePhotoCameraRoll"]) {
     if ([rowDescriptor.tag isEqualToString:@"removePhotoCameraRoll"]) {
 
 
-        [CCUtility setRemovePhotoCameraRoll:[[rowDescriptor.value valueData] boolValue]];
+        [[NCKeychain alloc] init].removePhotoCameraRoll = [[rowDescriptor.value valueData] boolValue];
     }
     }
 
 
     if ([rowDescriptor.tag isEqualToString:@"disablefilesapp"]) {
     if ([rowDescriptor.tag isEqualToString:@"disablefilesapp"]) {
         
         
-        [CCUtility setDisableFilesApp:[[rowDescriptor.value valueData] boolValue]];
+        [[NCKeychain alloc] init].disableFilesApp = [[rowDescriptor.value valueData] boolValue];
     }
     }
     
     
     if ([rowDescriptor.tag isEqualToString:@"crashservice"]) {
     if ([rowDescriptor.tag isEqualToString:@"crashservice"]) {
         
         
-        [CCUtility setDisableCrashservice:[[rowDescriptor.value valueData] boolValue]];
-        
+        [[NCKeychain alloc] init].disableCrashservice = [[rowDescriptor.value valueData] boolValue];
+
         UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_crashservice_title_", nil) message:NSLocalizedString(@"_crashservice_alert_", nil) preferredStyle:UIAlertControllerStyleAlert];
         UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_crashservice_title_", nil) message:NSLocalizedString(@"_crashservice_alert_", nil) preferredStyle:UIAlertControllerStyleAlert];
         UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
         UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
             exit(0);
             exit(0);
@@ -352,14 +352,14 @@
     if ([rowDescriptor.tag isEqualToString:@"logLevel"]) {
     if ([rowDescriptor.tag isEqualToString:@"logLevel"]) {
         
         
         NSInteger levelLog = [[rowDescriptor.value valueData] intValue];
         NSInteger levelLog = [[rowDescriptor.value valueData] intValue];
-        [CCUtility setLogLevel:levelLog];
+        [[NCKeychain alloc] init].logLevel = levelLog;
         [[[NextcloudKit shared] nkCommonInstance] setLevelLog:levelLog];
         [[[NextcloudKit shared] nkCommonInstance] setLevelLog:levelLog];
     }
     }
 
 
     if ([rowDescriptor.tag isEqualToString:@"deleteoldfiles"]) {
     if ([rowDescriptor.tag isEqualToString:@"deleteoldfiles"]) {
         
         
         NSInteger days = [[rowDescriptor.value valueData] intValue];
         NSInteger days = [[rowDescriptor.value valueData] intValue];
-        [CCUtility setCleanUpDay:days];
+        [[NCKeychain alloc] init].cleanUpDay = days;
     }
     }
 }
 }
 
 
@@ -376,13 +376,13 @@
 
 
         [[NCManageDatabase shared] clearDatabaseWithAccount:account removeAccount:false];
         [[NCManageDatabase shared] clearDatabaseWithAccount:account removeAccount:false];
 
 
-        [CCUtility removeGroupDirectoryProviderStorage];
-        [CCUtility removeGroupLibraryDirectory];
+        [[NCUtilityFileSystem shared] removeGroupDirectoryProviderStorage];
+        [[NCUtilityFileSystem shared] removeGroupLibraryDirectory];
 
 
-        [CCUtility removeDocumentsDirectory];
-        [CCUtility removeTemporaryDirectory];
+        [[NCUtilityFileSystem shared] removeDocumentsDirectory];
+        [[NCUtilityFileSystem shared] removeTemporaryDirectory];
 
 
-        [CCUtility createDirectoryStandard];
+        [[NCUtilityFileSystem shared] createDirectoryStandard];
 
 
         [[NCAutoUpload shared] alignPhotoLibraryWithViewController:self];
         [[NCAutoUpload shared] alignPhotoLibraryWithViewController:self];
 
 
@@ -430,10 +430,10 @@
 - (void)calculateSize
 - (void)calculateSize
 {
 {
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        NSString *directory = CCUtility.getDirectoryProviderStorage;
+        NSString *directory =  [[NCUtilityFileSystem shared] directoryProviderStorage];
         int64_t totalSize = [[NCUtilityFileSystem shared] getDirectorySizeWithDirectory:directory];
         int64_t totalSize = [[NCUtilityFileSystem shared] getDirectorySizeWithDirectory:directory];
-        sectionSize.footerTitle = [NSString stringWithFormat:@"%@. (%@ %@)", NSLocalizedString(@"_clear_cache_footer_", nil), NSLocalizedString(@"_used_space_", nil), [CCUtility transformedSize:totalSize]];
-            
+        sectionSize.footerTitle = [NSString stringWithFormat:@"%@. (%@ %@)", NSLocalizedString(@"_clear_cache_footer_", nil), NSLocalizedString(@"_used_space_", nil), [[NCUtilityFileSystem shared] transformedSize:totalSize]];
+
         dispatch_async(dispatch_get_main_queue(), ^{
         dispatch_async(dispatch_get_main_queue(), ^{
             [self.tableView reloadData];
             [self.tableView reloadData];
         });
         });
@@ -459,13 +459,13 @@
             [[NSURLCache sharedURLCache] setMemoryCapacity:0];
             [[NSURLCache sharedURLCache] setMemoryCapacity:0];
             [[NSURLCache sharedURLCache] setDiskCapacity:0];
             [[NSURLCache sharedURLCache] setDiskCapacity:0];
 
 
-            [CCUtility removeGroupDirectoryProviderStorage];
-            [CCUtility removeGroupApplicationSupport];
+            [[NCUtilityFileSystem shared] removeGroupDirectoryProviderStorage];
+            [[NCUtilityFileSystem shared] removeGroupApplicationSupport];
 
 
-            [CCUtility removeDocumentsDirectory];
-            [CCUtility removeTemporaryDirectory];
+            [[NCUtilityFileSystem shared] removeDocumentsDirectory];
+            [[NCUtilityFileSystem shared] removeTemporaryDirectory];
 
 
-            [CCUtility deleteAllChainStore];
+            [[[NCKeychain alloc] init] removeAll];
 
 
             exit(0);
             exit(0);
         });
         });

+ 3 - 4
iOSClient/Settings/CCManageAccount.m

@@ -123,7 +123,7 @@
             [row.cellConfig setObject:[[UIImage imageNamed:@"users"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"];
             [row.cellConfig setObject:[[UIImage imageNamed:@"users"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"];
             [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
             [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
             [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
             [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
-            if ([CCUtility getAccountRequest]) row.value = @1;
+            if ([[NCKeychain alloc] init].accountRequest) row.value = @1;
             else row.value = @0;
             else row.value = @0;
             [section addFormRow:row];
             [section addFormRow:row];
         }
         }
@@ -205,7 +205,6 @@
         [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
         [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
         [row.cellConfig setObject:[[UIImage imageNamed:@"country"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"];
         [row.cellConfig setObject:[[UIImage imageNamed:@"country"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"];
         row.value = [[NSLocale systemLocale] displayNameForKey:NSLocaleCountryCode value:activeAccount.country];
         row.value = [[NSLocale systemLocale] displayNameForKey:NSLocaleCountryCode value:activeAccount.country];
-        //NSArray *countryCodes = [NSLocale ISOCountryCodes];
         [section addFormRow:row];
         [section addFormRow:row];
     }
     }
     
     
@@ -306,9 +305,9 @@
     if ([rowDescriptor.tag isEqualToString:@"accountRequest"]) {
     if ([rowDescriptor.tag isEqualToString:@"accountRequest"]) {
         
         
         if ([[rowDescriptor.value valueData] boolValue] == YES) {
         if ([[rowDescriptor.value valueData] boolValue] == YES) {
-            [CCUtility setAccountRequest:true];
+            [[NCKeychain alloc] init].accountRequest = true;
         } else {
         } else {
-            [CCUtility setAccountRequest:false];
+            [[NCKeychain alloc] init].accountRequest = false;
         }
         }
     }
     }
     
     

+ 8 - 1
iOSClient/Settings/CCManageAutoUpload.m

@@ -399,7 +399,7 @@
             sectionName = NSLocalizedString(@"_autoupload_description_", nil);
             sectionName = NSLocalizedString(@"_autoupload_description_", nil);
             break;
             break;
         case 1:
         case 1:
-            if (activeAccount.autoUpload) sectionName = [NSString stringWithFormat:@"%@: %@", NSLocalizedString(@"_autoupload_current_folder_", nil), [CCUtility returnPathfromServerUrl:autoUploadPath urlBase:appDelegate.urlBase userId:appDelegate.userId account:appDelegate.account]];
+            if (activeAccount.autoUpload) sectionName = [NSString stringWithFormat:@"%@: %@", NSLocalizedString(@"_autoupload_current_folder_", nil), [self returnPathfromServerUrl:autoUploadPath urlBase:appDelegate.urlBase userId:appDelegate.userId account:appDelegate.account]];
             else sectionName = @"";
             else sectionName = @"";
             break;
             break;
         case 4:
         case 4:
@@ -453,4 +453,11 @@
      }];
      }];
  }
  }
 
 
+- (NSString *)returnPathfromServerUrl:(NSString *)serverUrl urlBase:(NSString *)urlBase userId:(NSString *)userId account:(NSString *)account
+{
+   NSString *homeServer = [[NCUtilityFileSystem shared] getHomeServerWithUrlBase:urlBase userId:userId];
+   NSString *path = [serverUrl stringByReplacingOccurrencesOfString:homeServer withString:@""];
+   return path;
+}
+
 @end
 @end

+ 21 - 25
iOSClient/Settings/NCEndToEndInitialize.swift

@@ -32,11 +32,7 @@ import NextcloudKit
 class NCEndToEndInitialize: NSObject {
 class NCEndToEndInitialize: NSObject {
 
 
     @objc weak var delegate: NCEndToEndInitializeDelegate?
     @objc weak var delegate: NCEndToEndInitializeDelegate?
-
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     var extractedPublicKey: String?
     var extractedPublicKey: String?
 
 
     override init() {
     override init() {
@@ -49,7 +45,7 @@ class NCEndToEndInitialize: NSObject {
     @objc func initEndToEndEncryption() {
     @objc func initEndToEndEncryption() {
 
 
         // Clear all keys
         // Clear all keys
-        CCUtility.clearAllKeysEnd(toEnd: appDelegate.account)
+        NCKeychain().clearAllKeysEndToEnd(account: appDelegate.account)
 
 
         self.getPublicKey()
         self.getPublicKey()
     }
     }
@@ -65,9 +61,9 @@ class NCEndToEndInitialize: NSObject {
 
 
         NextcloudKit.shared.getE2EECertificate { account, certificate, _, _, error in
         NextcloudKit.shared.getE2EECertificate { account, certificate, _, _, error in
 
 
-            if error == .success && account == self.appDelegate.account {
+            if error == .success, account == self.appDelegate.account, let certificate {
 
 
-                CCUtility.setEndToEndCertificate(account, certificate: certificate)
+                NCKeychain().setEndToEndCertificate(account: account, certificate: certificate)
 
 
                 self.extractedPublicKey = NCEndToEndEncryption.sharedManager().extractPublicKey(fromCertificate: certificate)
                 self.extractedPublicKey = NCEndToEndEncryption.sharedManager().extractPublicKey(fromCertificate: certificate)
 
 
@@ -83,7 +79,7 @@ class NCEndToEndInitialize: NSObject {
                     NCContentPresenter.shared.messageNotification("E2E get publicKey", error: error, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, priority: .max)
                     NCContentPresenter.shared.messageNotification("E2E get publicKey", error: error, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, priority: .max)
 
 
                 case NCGlobal.shared.errorResourceNotFound:
                 case NCGlobal.shared.errorResourceNotFound:
-                    guard let csr = NCEndToEndEncryption.sharedManager().createCSR(self.appDelegate.userId, directory: CCUtility.getDirectoryUserData()) else {
+                    guard let csr = NCEndToEndEncryption.sharedManager().createCSR(self.appDelegate.userId, directory: NCUtilityFileSystem.shared.directoryUserData) else {
                         let error = NKError(errorCode: error.errorCode, errorDescription: "Error to create Csr")
                         let error = NKError(errorCode: error.errorCode, errorDescription: "Error to create Csr")
                         NCContentPresenter.shared.messageNotification("E2E Csr", error: error, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, priority: .max)
                         NCContentPresenter.shared.messageNotification("E2E Csr", error: error, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, priority: .max)
 
 
@@ -92,7 +88,7 @@ class NCEndToEndInitialize: NSObject {
 
 
                     NextcloudKit.shared.signE2EECertificate(certificate: csr) { account, certificate, _, error in
                     NextcloudKit.shared.signE2EECertificate(certificate: csr) { account, certificate, _, error in
 
 
-                        if error == .success && account == self.appDelegate.account {
+                        if error == .success, account == self.appDelegate.account, let certificate {
 
 
                             // TEST publicKey
                             // TEST publicKey
                             let extractedPublicKey = NCEndToEndEncryption.sharedManager().extractPublicKey(fromCertificate: certificate)
                             let extractedPublicKey = NCEndToEndEncryption.sharedManager().extractPublicKey(fromCertificate: certificate)
@@ -102,7 +98,7 @@ class NCEndToEndInitialize: NSObject {
 
 
                             } else {
                             } else {
 
 
-                                CCUtility.setEndToEndCertificate(account, certificate: certificate)
+                                NCKeychain().setEndToEndCertificate(account: account, certificate: certificate)
 
 
                                 // Request PrivateKey chiper to Server
                                 // Request PrivateKey chiper to Server
                                 self.getPrivateKeyCipher()
                                 self.getPrivateKeyCipher()
@@ -152,14 +148,14 @@ class NCEndToEndInitialize: NSObject {
 
 
                 let ok = UIAlertAction(title: "OK", style: .default, handler: { _ -> Void in
                 let ok = UIAlertAction(title: "OK", style: .default, handler: { _ -> Void in
 
 
-                    let passphrase = passphraseTextField?.text
+                    let passphrase = passphraseTextField?.text ?? ""
 
 
-                    let publicKey = CCUtility.getEndToEndCertificate(self.appDelegate.account)
+                    let publicKey = NCKeychain().getEndToEndCertificate(account: self.appDelegate.account)
 
 
                     if let privateKeyData = (NCEndToEndEncryption.sharedManager().decryptPrivateKey(privateKeyChiper, passphrase: passphrase, publicKey: publicKey, iterationCount: 1024)),
                     if let privateKeyData = (NCEndToEndEncryption.sharedManager().decryptPrivateKey(privateKeyChiper, passphrase: passphrase, publicKey: publicKey, iterationCount: 1024)),
-                       let keyData = Data(base64Encoded: privateKeyData) {
-                        let privateKey = String(data: keyData, encoding: .utf8)
-                        CCUtility.setEndToEndPrivateKey(self.appDelegate.account, privateKey: privateKey)
+                       let keyData = Data(base64Encoded: privateKeyData), 
+                       let privateKey = String(data: keyData, encoding: .utf8) {
+                        NCKeychain().setEndToEndPrivateKey(account: self.appDelegate.account, privateKey: privateKey)
                     } else {
                     } else {
 
 
                         let error = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "Serious internal error to decrypt Private Key")
                         let error = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "Serious internal error to decrypt Private Key")
@@ -169,14 +165,14 @@ class NCEndToEndInitialize: NSObject {
                     }
                     }
 
 
                     // Save to keychain
                     // Save to keychain
-                    CCUtility.setEndToEndPassphrase(self.appDelegate.account, passphrase: passphrase)
+                    NCKeychain().setEndToEndPassphrase(account: self.appDelegate.account, passphrase: passphrase)
 
 
                     // request server publicKey
                     // request server publicKey
                     NextcloudKit.shared.getE2EEPublicKey { account, publicKey, _, error in
                     NextcloudKit.shared.getE2EEPublicKey { account, publicKey, _, error in
 
 
-                        if error == .success && account == self.appDelegate.account {
+                        if error == .success, account == self.appDelegate.account, let publicKey {
 
 
-                            CCUtility.setEndToEndPublicKey(account, publicKey: publicKey)
+                            NCKeychain().setEndToEndPublicKey(account: account, publicKey: publicKey)
                             NCManageDatabase.shared.clearTablesE2EE(account: account)
                             NCManageDatabase.shared.clearTablesE2EE(account: account)
 
 
                             self.delegate?.endToEndInitializeSuccess()
                             self.delegate?.endToEndInitializeSuccess()
@@ -259,7 +255,7 @@ class NCEndToEndInitialize: NSObject {
 
 
         var privateKeyString: NSString?
         var privateKeyString: NSString?
 
 
-        guard let privateKeyChiper = NCEndToEndEncryption.sharedManager().encryptPrivateKey(self.appDelegate.userId, directory: CCUtility.getDirectoryUserData(), passphrase: e2ePassphrase, privateKey: &privateKeyString, iterationCount: 1024) else {
+        guard let privateKeyChiper = NCEndToEndEncryption.sharedManager().encryptPrivateKey(self.appDelegate.userId, directory: NCUtilityFileSystem.shared.directoryUserData, passphrase: e2ePassphrase, privateKey: &privateKeyString, iterationCount: 1024) else {
             let error = NKError(errorCode: error.errorCode, errorDescription: "Serious internal error to create PrivateKey chiper")
             let error = NKError(errorCode: error.errorCode, errorDescription: "Serious internal error to create PrivateKey chiper")
             NCContentPresenter.shared.messageNotification("E2E privateKey", error: error, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, priority: .max)
             NCContentPresenter.shared.messageNotification("E2E privateKey", error: error, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, priority: .max)
             return
             return
@@ -270,17 +266,17 @@ class NCEndToEndInitialize: NSObject {
 
 
         NextcloudKit.shared.storeE2EEPrivateKey(privateKey: privateKeyChiper) { account, _, _, error in
         NextcloudKit.shared.storeE2EEPrivateKey(privateKey: privateKeyChiper) { account, _, _, error in
 
 
-            if error == .success && account == self.appDelegate.account {
+            if error == .success, account == self.appDelegate.account, let privateKey = privateKeyString {
 
 
-                CCUtility.setEndToEndPrivateKey(account, privateKey: privateKeyString! as String)
-                CCUtility.setEndToEndPassphrase(account, passphrase: e2ePassphrase)
+                NCKeychain().setEndToEndPrivateKey(account: account, privateKey: String(privateKey))
+                NCKeychain().setEndToEndPassphrase(account: account, passphrase: e2ePassphrase)
 
 
                 // request server publicKey
                 // request server publicKey
                 NextcloudKit.shared.getE2EEPublicKey { account, publicKey, _, error in
                 NextcloudKit.shared.getE2EEPublicKey { account, publicKey, _, error in
 
 
-                    if error == .success && account == self.appDelegate.account {
+                    if error == .success, account == self.appDelegate.account, let publicKey {
 
 
-                        CCUtility.setEndToEndPublicKey(account, publicKey: publicKey)
+                        NCKeychain().setEndToEndPublicKey(account: account, publicKey: publicKey)
                         NCManageDatabase.shared.clearTablesE2EE(account: account)
                         NCManageDatabase.shared.clearTablesE2EE(account: account)
 
 
                         if copyPassphrase {
                         if copyPassphrase {

+ 11 - 14
iOSClient/Settings/NCManageAutoUploadFileName.swift

@@ -27,10 +27,7 @@ import NextcloudKit
 
 
 class NCManageAutoUploadFileName: XLFormViewController {
 class NCManageAutoUploadFileName: XLFormViewController {
 
 
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     let dateExample = Date()
     let dateExample = Date()
 
 
     func initializeForm() {
     func initializeForm() {
@@ -49,7 +46,7 @@ class NCManageAutoUploadFileName: XLFormViewController {
         // Maintain the original fileName
         // Maintain the original fileName
 
 
         row = XLFormRowDescriptor(tag: "maintainOriginalFileName", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_maintain_original_filename_", comment: ""))
         row = XLFormRowDescriptor(tag: "maintainOriginalFileName", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_maintain_original_filename_", comment: ""))
-        row.value = CCUtility.getOriginalFileName(NCGlobal.shared.keyFileNameOriginalAutoUpload)
+        row.value = NCKeychain().getOriginalFileName(key: NCGlobal.shared.keyFileNameOriginalAutoUpload)
         row.cellConfig["backgroundColor"] = UIColor.secondarySystemGroupedBackground
         row.cellConfig["backgroundColor"] = UIColor.secondarySystemGroupedBackground
 
 
         row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
         row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
@@ -60,7 +57,7 @@ class NCManageAutoUploadFileName: XLFormViewController {
         // Add File Name Type
         // Add File Name Type
 
 
         row = XLFormRowDescriptor(tag: "addFileNameType", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_add_filenametype_", comment: ""))
         row = XLFormRowDescriptor(tag: "addFileNameType", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_add_filenametype_", comment: ""))
-        row.value = CCUtility.getFileNameType(NCGlobal.shared.keyFileNameAutoUploadType)
+        row.value = NCKeychain().getFileNameType(key: NCGlobal.shared.keyFileNameAutoUploadType)
         row.hidden = "$\("maintainOriginalFileName") == 1"
         row.hidden = "$\("maintainOriginalFileName") == 1"
         row.cellConfig["backgroundColor"] = UIColor.secondarySystemGroupedBackground
         row.cellConfig["backgroundColor"] = UIColor.secondarySystemGroupedBackground
 
 
@@ -75,7 +72,7 @@ class NCManageAutoUploadFileName: XLFormViewController {
         form.addFormSection(section)
         form.addFormSection(section)
 
 
         row = XLFormRowDescriptor(tag: "maskFileName", rowType: XLFormRowDescriptorTypeText, title: (NSLocalizedString("_filename_", comment: "")))
         row = XLFormRowDescriptor(tag: "maskFileName", rowType: XLFormRowDescriptorTypeText, title: (NSLocalizedString("_filename_", comment: "")))
-        let fileNameMask: String = CCUtility.getFileNameMask(NCGlobal.shared.keyFileNameAutoUploadMask)
+        let fileNameMask: String = NCKeychain().getFileNameMask(key: NCGlobal.shared.keyFileNameAutoUploadMask)
         if !fileNameMask.isEmpty {
         if !fileNameMask.isEmpty {
             row.value = fileNameMask
             row.value = fileNameMask
         }
         }
@@ -147,10 +144,10 @@ class NCManageAutoUploadFileName: XLFormViewController {
         super.formRowDescriptorValueHasChanged(formRow, oldValue: oldValue, newValue: newValue)
         super.formRowDescriptorValueHasChanged(formRow, oldValue: oldValue, newValue: newValue)
 
 
         if formRow.tag == "addFileNameType" {
         if formRow.tag == "addFileNameType" {
-            CCUtility.setFileNameType((formRow.value! as AnyObject).boolValue, key: NCGlobal.shared.keyFileNameAutoUploadType)
+            NCKeychain().setFileNameType(key: NCGlobal.shared.keyFileNameAutoUploadType, prefix: (formRow.value! as AnyObject).boolValue) 
             self.reloadForm()
             self.reloadForm()
         } else if formRow.tag == "maintainOriginalFileName" {
         } else if formRow.tag == "maintainOriginalFileName" {
-            CCUtility.setOriginalFileName((formRow.value! as AnyObject).boolValue, key: NCGlobal.shared.keyFileNameOriginalAutoUpload)
+            NCKeychain().setOriginalFileName(key: NCGlobal.shared.keyFileNameOriginalAutoUpload, value: (formRow.value! as AnyObject).boolValue)
             self.reloadForm()
             self.reloadForm()
         } else if formRow.tag == "maskFileName" {
         } else if formRow.tag == "maskFileName" {
 
 
@@ -159,7 +156,7 @@ class NCManageAutoUploadFileName: XLFormViewController {
             self.form.delegate = nil
             self.form.delegate = nil
 
 
             if let fileName = fileName {
             if let fileName = fileName {
-                formRow.value = CCUtility.removeForbiddenCharactersServer(fileName)
+                formRow.value = NCUtility.shared.removeForbiddenCharacters(fileName)
             }
             }
 
 
             self.form.delegate = self
             self.form.delegate = self
@@ -189,7 +186,7 @@ class NCManageAutoUploadFileName: XLFormViewController {
 
 
         var returnString: String = ""
         var returnString: String = ""
 
 
-        if CCUtility.getOriginalFileName(NCGlobal.shared.keyFileNameOriginalAutoUpload) {
+        if NCKeychain().getOriginalFileName(key: NCGlobal.shared.keyFileNameOriginalAutoUpload) {
 
 
             return (NSLocalizedString("_filename_", comment: "") + ": IMG_0001.JPG")
             return (NSLocalizedString("_filename_", comment: "") + ": IMG_0001.JPG")
 
 
@@ -199,13 +196,13 @@ class NCManageAutoUploadFileName: XLFormViewController {
 
 
             if valueRenameTrimming.isEmpty {
             if valueRenameTrimming.isEmpty {
 
 
-                CCUtility.setFileNameMask("", key: NCGlobal.shared.keyFileNameAutoUploadMask)
+                NCKeychain().setFileNameMask(key: NCGlobal.shared.keyFileNameAutoUploadMask, mask: "")
                 returnString = CCUtility.createFileName("IMG_0001.JPG", fileDate: dateExample, fileType: PHAssetMediaType.image, keyFileName: nil, keyFileNameType: NCGlobal.shared.keyFileNameAutoUploadType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginalAutoUpload, forcedNewFileName: false)
                 returnString = CCUtility.createFileName("IMG_0001.JPG", fileDate: dateExample, fileType: PHAssetMediaType.image, keyFileName: nil, keyFileNameType: NCGlobal.shared.keyFileNameAutoUploadType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginalAutoUpload, forcedNewFileName: false)
 
 
             } else {
             } else {
 
 
                 self.form.delegate = nil
                 self.form.delegate = nil
-                CCUtility.setFileNameMask(valueRename, key: NCGlobal.shared.keyFileNameAutoUploadMask)
+                NCKeychain().setFileNameMask(key: NCGlobal.shared.keyFileNameAutoUploadMask, mask: valueRename)
                 self.form.delegate = self
                 self.form.delegate = self
 
 
                 returnString = CCUtility.createFileName("IMG_0001.JPG", fileDate: dateExample, fileType: PHAssetMediaType.image, keyFileName: NCGlobal.shared.keyFileNameAutoUploadMask, keyFileNameType: NCGlobal.shared.keyFileNameAutoUploadType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginalAutoUpload, forcedNewFileName: false)
                 returnString = CCUtility.createFileName("IMG_0001.JPG", fileDate: dateExample, fileType: PHAssetMediaType.image, keyFileName: NCGlobal.shared.keyFileNameAutoUploadMask, keyFileNameType: NCGlobal.shared.keyFileNameAutoUploadType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginalAutoUpload, forcedNewFileName: false)
@@ -213,7 +210,7 @@ class NCManageAutoUploadFileName: XLFormViewController {
 
 
         } else {
         } else {
 
 
-            CCUtility.setFileNameMask("", key: NCGlobal.shared.keyFileNameAutoUploadMask)
+            NCKeychain().setFileNameMask(key: NCGlobal.shared.keyFileNameAutoUploadMask, mask: "")
             returnString = CCUtility.createFileName("IMG_0001.JPG", fileDate: dateExample, fileType: PHAssetMediaType.image, keyFileName: nil, keyFileNameType: NCGlobal.shared.keyFileNameAutoUploadType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginalAutoUpload, forcedNewFileName: false)
             returnString = CCUtility.createFileName("IMG_0001.JPG", fileDate: dateExample, fileType: PHAssetMediaType.image, keyFileName: nil, keyFileNameType: NCGlobal.shared.keyFileNameAutoUploadType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginalAutoUpload, forcedNewFileName: false)
         }
         }
 
 

+ 10 - 18
iOSClient/Settings/NCManageE2EE.swift

@@ -30,10 +30,6 @@ import LocalAuthentication
 
 
     @objc func makeShipDetailsUI(account: String) -> UIViewController {
     @objc func makeShipDetailsUI(account: String) -> UIViewController {
 
 
-        // swiftlint:disable force_cast
-        let account = (UIApplication.shared.delegate as! AppDelegate).account
-        // swiftlint:enable force_cast
-
         let details = NCViewE2EE(account: account)
         let details = NCViewE2EE(account: account)
         let vc = UIHostingController(rootView: details)
         let vc = UIHostingController(rootView: details)
         vc.title = NSLocalizedString("_e2e_settings_", comment: "")
         vc.title = NSLocalizedString("_e2e_settings_", comment: "")
@@ -44,11 +40,7 @@ import LocalAuthentication
 class NCManageE2EE: NSObject, ObservableObject, NCEndToEndInitializeDelegate, TOPasscodeViewControllerDelegate {
 class NCManageE2EE: NSObject, ObservableObject, NCEndToEndInitializeDelegate, TOPasscodeViewControllerDelegate {
 
 
     let endToEndInitialize = NCEndToEndInitialize()
     let endToEndInitialize = NCEndToEndInitialize()
-
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     var passcodeType = ""
     var passcodeType = ""
 
 
     @Published var isEndToEndEnabled: Bool = false
     @Published var isEndToEndEnabled: Bool = false
@@ -58,7 +50,7 @@ class NCManageE2EE: NSObject, ObservableObject, NCEndToEndInitializeDelegate, TO
         super.init()
         super.init()
 
 
         endToEndInitialize.delegate = self
         endToEndInitialize.delegate = self
-        isEndToEndEnabled = CCUtility.isEnd(toEndEnabled: appDelegate.account)
+        isEndToEndEnabled = NCKeychain().isEndToEndEnabled(account: appDelegate.account)
         if isEndToEndEnabled {
         if isEndToEndEnabled {
             statusOfService = NSLocalizedString("_status_e2ee_configured_", comment: "")
             statusOfService = NSLocalizedString("_status_e2ee_configured_", comment: "")
         } else {
         } else {
@@ -88,7 +80,7 @@ class NCManageE2EE: NSObject, ObservableObject, NCEndToEndInitializeDelegate, TO
         let passcodeViewController = TOPasscodeViewController(passcodeType: .sixDigits, allowCancel: true)
         let passcodeViewController = TOPasscodeViewController(passcodeType: .sixDigits, allowCancel: true)
         passcodeViewController.delegate = self
         passcodeViewController.delegate = self
         passcodeViewController.keypadButtonShowLettering = false
         passcodeViewController.keypadButtonShowLettering = false
-        if CCUtility.getEnableTouchFaceID() && laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
+        if NCKeychain().touchFaceID, laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
             if error == nil {
             if error == nil {
                 if laContext.biometryType == .faceID {
                 if laContext.biometryType == .faceID {
                     passcodeViewController.biometryType = .faceID
                     passcodeViewController.biometryType = .faceID
@@ -111,7 +103,7 @@ class NCManageE2EE: NSObject, ObservableObject, NCEndToEndInitializeDelegate, TO
         case "startE2E":
         case "startE2E":
             endToEndInitialize.initEndToEndEncryption()
             endToEndInitialize.initEndToEndEncryption()
         case "readPassphrase":
         case "readPassphrase":
-            if let e2ePassphrase = CCUtility.getEndToEndPassphrase(appDelegate.account) {
+            if let e2ePassphrase = NCKeychain().getEndToEndPassphrase(account: appDelegate.account) {
                 print("[LOG]Passphrase: " + e2ePassphrase)
                 print("[LOG]Passphrase: " + e2ePassphrase)
                 let message = "\n" + NSLocalizedString("_e2e_settings_the_passphrase_is_", comment: "") + "\n\n\n" + e2ePassphrase
                 let message = "\n" + NSLocalizedString("_e2e_settings_the_passphrase_is_", comment: "") + "\n\n\n" + e2ePassphrase
                 let alertController = UIAlertController(title: NSLocalizedString("_info_", comment: ""), message: message, preferredStyle: .alert)
                 let alertController = UIAlertController(title: NSLocalizedString("_info_", comment: ""), message: message, preferredStyle: .alert)
@@ -124,8 +116,8 @@ class NCManageE2EE: NSObject, ObservableObject, NCEndToEndInitializeDelegate, TO
         case "removeLocallyEncryption":
         case "removeLocallyEncryption":
             let alertController = UIAlertController(title: NSLocalizedString("_e2e_settings_remove_", comment: ""), message: NSLocalizedString("_e2e_settings_remove_message_", comment: ""), preferredStyle: .alert)
             let alertController = UIAlertController(title: NSLocalizedString("_e2e_settings_remove_", comment: ""), message: NSLocalizedString("_e2e_settings_remove_message_", comment: ""), preferredStyle: .alert)
             alertController.addAction(UIAlertAction(title: NSLocalizedString("_remove_", comment: ""), style: .default, handler: { _ in
             alertController.addAction(UIAlertAction(title: NSLocalizedString("_remove_", comment: ""), style: .default, handler: { _ in
-                CCUtility.clearAllKeysEnd(toEnd: self.appDelegate.account)
-                self.isEndToEndEnabled = CCUtility.isEnd(toEndEnabled: self.appDelegate.account)
+                NCKeychain().clearAllKeysEndToEnd(account: self.appDelegate.account)
+                self.isEndToEndEnabled = NCKeychain().isEndToEndEnabled(account: self.appDelegate.account)
             }))
             }))
             alertController.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .default, handler: { _ in }))
             alertController.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .default, handler: { _ in }))
             appDelegate.window?.rootViewController?.present(alertController, animated: true)
             appDelegate.window?.rootViewController?.present(alertController, animated: true)
@@ -136,7 +128,7 @@ class NCManageE2EE: NSObject, ObservableObject, NCEndToEndInitializeDelegate, TO
 
 
     func passcodeViewController(_ passcodeViewController: TOPasscodeViewController, isCorrectCode code: String) -> Bool {
     func passcodeViewController(_ passcodeViewController: TOPasscodeViewController, isCorrectCode code: String) -> Bool {
 
 
-        if code == CCUtility.getPasscode() {
+        if code == NCKeychain().passcode {
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
                 self.correctPasscode()
                 self.correctPasscode()
             }
             }
@@ -202,7 +194,7 @@ struct NCViewE2EE: View {
                     }
                     }
                     .contentShape(Rectangle())
                     .contentShape(Rectangle())
                     .onTapGesture {
                     .onTapGesture {
-                        if let passcode = CCUtility.getPasscode(), !passcode.isEmpty {
+                        if NCKeychain().passcode != nil {
                             manageE2EE.requestPasscodeType("readPassphrase")
                             manageE2EE.requestPasscodeType("readPassphrase")
                         } else {
                         } else {
                             NCContentPresenter.shared.showInfo(error: NKError(errorCode: 0, errorDescription: "_e2e_settings_lock_not_active_"))
                             NCContentPresenter.shared.showInfo(error: NKError(errorCode: 0, errorDescription: "_e2e_settings_lock_not_active_"))
@@ -222,7 +214,7 @@ struct NCViewE2EE: View {
                     }
                     }
                     .contentShape(Rectangle())
                     .contentShape(Rectangle())
                     .onTapGesture {
                     .onTapGesture {
-                        if let passcode = CCUtility.getPasscode(), !passcode.isEmpty {
+                        if let passcode = NCKeychain().passcode {
                             manageE2EE.requestPasscodeType("removeLocallyEncryption")
                             manageE2EE.requestPasscodeType("removeLocallyEncryption")
                         } else {
                         } else {
                             NCContentPresenter.shared.showInfo(error: NKError(errorCode: 0, errorDescription: "_e2e_settings_lock_not_active_"))
                             NCContentPresenter.shared.showInfo(error: NKError(errorCode: 0, errorDescription: "_e2e_settings_lock_not_active_"))
@@ -252,7 +244,7 @@ struct NCViewE2EE: View {
                         }
                         }
                         .contentShape(Rectangle())
                         .contentShape(Rectangle())
                         .onTapGesture {
                         .onTapGesture {
-                            if let passcode = CCUtility.getPasscode(), !passcode.isEmpty {
+                            if let passcode = NCKeychain().passcode {
                                 manageE2EE.requestPasscodeType("startE2E")
                                 manageE2EE.requestPasscodeType("startE2E")
                             } else {
                             } else {
                                 NCContentPresenter.shared.showInfo(error: NKError(errorCode: 0, errorDescription: "_e2e_settings_lock_not_active_"))
                                 NCContentPresenter.shared.showInfo(error: NKError(errorCode: 0, errorDescription: "_e2e_settings_lock_not_active_"))

+ 28 - 28
iOSClient/Settings/NCSettings.m

@@ -265,7 +265,7 @@
 
 
     // ------------------------------------------------------------------
     // ------------------------------------------------------------------
     
     
-    if ([[CCUtility getPasscode] length]) {
+    if ([[NCKeychain alloc] init].passcode) {
         rowBloccoPasscode.title = NSLocalizedString(@"_lock_active_", nil);
         rowBloccoPasscode.title = NSLocalizedString(@"_lock_active_", nil);
         [rowBloccoPasscode.cellConfig setObject:[[UIImage imageNamed:@"lock"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"];
         [rowBloccoPasscode.cellConfig setObject:[[UIImage imageNamed:@"lock"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"];
     } else {
     } else {
@@ -273,9 +273,9 @@
         [rowBloccoPasscode.cellConfig setObject:[[UIImage imageNamed:@"lock_open"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"];
         [rowBloccoPasscode.cellConfig setObject:[[UIImage imageNamed:@"lock_open"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"];
     }
     }
     
     
-    if ([CCUtility getEnableTouchFaceID]) [rowEnableTouchDaceID setValue:@1]; else [rowEnableTouchDaceID setValue:@0];
-    if ([CCUtility getNotPasscodeAtStart]) [rowNotPasscodeAtStart setValue:@1]; else [rowNotPasscodeAtStart setValue:@0];
-    if ([CCUtility getPrivacyScreenEnabled]) [rowPrivacyScreen setValue:@1]; else [rowPrivacyScreen setValue:@0];
+    if ([[NCKeychain alloc] init].touchFaceID) [rowEnableTouchDaceID setValue:@1]; else [rowEnableTouchDaceID setValue:@0];
+    if ([[NCKeychain alloc] init].requestPasscodeAtStart) [rowNotPasscodeAtStart setValue:@0]; else [rowNotPasscodeAtStart setValue:@1];
+    if ([[NCKeychain alloc] init].privacyScreenEnabled) [rowPrivacyScreen setValue:@1]; else [rowPrivacyScreen setValue:@0];
 
 
 
 
     // -----------------------------------------------------------------
     // -----------------------------------------------------------------
@@ -292,27 +292,27 @@
     if ([rowDescriptor.tag isEqualToString:@"notPasscodeAtStart"]) {
     if ([rowDescriptor.tag isEqualToString:@"notPasscodeAtStart"]) {
         
         
         if ([[rowDescriptor.value valueData] boolValue] == YES) {
         if ([[rowDescriptor.value valueData] boolValue] == YES) {
-            [CCUtility setNotPasscodeAtStart:true];
+            [[NCKeychain alloc] init].requestPasscodeAtStart = false;
         } else {
         } else {
-            [CCUtility setNotPasscodeAtStart:false];
+            [[NCKeychain alloc] init].requestPasscodeAtStart = true;
         }
         }
     }
     }
     
     
     if ([rowDescriptor.tag isEqualToString:@"enableTouchDaceID"]) {
     if ([rowDescriptor.tag isEqualToString:@"enableTouchDaceID"]) {
         
         
         if ([[rowDescriptor.value valueData] boolValue] == YES) {
         if ([[rowDescriptor.value valueData] boolValue] == YES) {
-            [CCUtility setEnableTouchFaceID:true];
+            [[NCKeychain alloc] init].touchFaceID = true;
         } else {
         } else {
-            [CCUtility setEnableTouchFaceID:false];
+            [[NCKeychain alloc] init].touchFaceID = false;
         }
         }
     }
     }
     
     
     if ([rowDescriptor.tag isEqualToString:@"privacyScreen"]) {
     if ([rowDescriptor.tag isEqualToString:@"privacyScreen"]) {
         
         
         if ([[rowDescriptor.value valueData] boolValue] == YES) {
         if ([[rowDescriptor.value valueData] boolValue] == YES) {
-            [CCUtility setPrivacyScreenEnabled:true];
+            [[NCKeychain alloc] init].privacyScreenEnabled = true;
         } else {
         } else {
-            [CCUtility setPrivacyScreenEnabled:false];
+            [[NCKeychain alloc] init].privacyScreenEnabled = false;
         }
         }
     }
     }
 }
 }
@@ -370,7 +370,7 @@
     [[LAContext new] evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:[[NCBrandOptions shared] brand] reply:^(BOOL success, NSError * _Nullable error) {
     [[LAContext new] evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:[[NCBrandOptions shared] brand] reply:^(BOOL success, NSError * _Nullable error) {
         if (success) {
         if (success) {
             dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
             dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
-                [CCUtility setPasscode:@""];
+                [[NCKeychain alloc] init].passcode = nil;
                 [passcodeViewController dismissViewControllerAnimated:YES completion:nil];
                 [passcodeViewController dismissViewControllerAnimated:YES completion:nil];
                 [self reloadForm];
                 [self reloadForm];
             });
             });
@@ -380,7 +380,7 @@
 
 
 - (void)passcodeSettingsViewController:(TOPasscodeSettingsViewController *)passcodeSettingsViewController didChangeToNewPasscode:(NSString *)passcode ofType:(TOPasscodeType)type
 - (void)passcodeSettingsViewController:(TOPasscodeSettingsViewController *)passcodeSettingsViewController didChangeToNewPasscode:(NSString *)passcode ofType:(TOPasscodeType)type
 {
 {
-    [CCUtility setPasscode:passcode];
+    [[NCKeychain alloc] init].passcode = passcode;
     [passcodeSettingsViewController dismissViewControllerAnimated:YES completion:nil];
     [passcodeSettingsViewController dismissViewControllerAnimated:YES completion:nil];
     
     
     [self reloadForm];
     [self reloadForm];
@@ -393,8 +393,8 @@
 
 
 - (BOOL)passcodeViewController:(TOPasscodeViewController *)passcodeViewController isCorrectCode:(NSString *)code
 - (BOOL)passcodeViewController:(TOPasscodeViewController *)passcodeViewController isCorrectCode:(NSString *)code
 {
 {
-    if ([code isEqualToString:[CCUtility getPasscode]]) {
-        [CCUtility setPasscode:@""];
+    if ([code isEqualToString:[[NCKeychain alloc] init].passcode]) {
+        [[NCKeychain alloc] init].passcode = nil;
         [self reloadForm];
         [self reloadForm];
         
         
         return YES;
         return YES;
@@ -410,23 +410,13 @@
     
     
     [self deselectFormRow:sender];
     [self deselectFormRow:sender];
 
 
-    if ([[CCUtility getPasscode] length] == 0) {
-        
-        passcodeSettingsViewController = [[TOPasscodeSettingsViewController alloc] init];
-        passcodeSettingsViewController.hideOptionsButton = YES;
-        passcodeSettingsViewController.requireCurrentPasscode = NO;
-        passcodeSettingsViewController.passcodeType = TOPasscodeTypeSixDigits;
-        passcodeSettingsViewController.delegate = self;
-        
-        [self presentViewController:passcodeSettingsViewController animated:YES completion:nil];
-        
-    } else {
-     
+    if ([[NCKeychain alloc] init].passcode) {
+
         passcodeViewController = [[TOPasscodeViewController alloc] initPasscodeType:TOPasscodeTypeSixDigits allowCancel:true];
         passcodeViewController = [[TOPasscodeViewController alloc] initPasscodeType:TOPasscodeTypeSixDigits allowCancel:true];
         passcodeViewController.delegate = self;
         passcodeViewController.delegate = self;
         passcodeViewController.keypadButtonShowLettering = false;
         passcodeViewController.keypadButtonShowLettering = false;
-        
-        if (CCUtility.getEnableTouchFaceID && [laContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
+
+        if ([[NCKeychain alloc] init].touchFaceID && [laContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
             if (error == NULL) {
             if (error == NULL) {
                 if (laContext.biometryType == LABiometryTypeFaceID) {
                 if (laContext.biometryType == LABiometryTypeFaceID) {
                     passcodeViewController.biometryType = TOPasscodeBiometryTypeFaceID;
                     passcodeViewController.biometryType = TOPasscodeBiometryTypeFaceID;
@@ -443,6 +433,16 @@
         }
         }
 
 
         [self presentViewController:passcodeViewController animated:YES completion:nil];
         [self presentViewController:passcodeViewController animated:YES completion:nil];
+
+    } else {
+     
+        passcodeSettingsViewController = [[TOPasscodeSettingsViewController alloc] init];
+        passcodeSettingsViewController.hideOptionsButton = YES;
+        passcodeSettingsViewController.requireCurrentPasscode = NO;
+        passcodeSettingsViewController.passcodeType = TOPasscodeTypeSixDigits;
+        passcodeSettingsViewController.delegate = self;
+
+        [self presentViewController:passcodeSettingsViewController animated:YES completion:nil];
     }
     }
 }
 }
 
 

+ 5 - 5
iOSClient/Settings/NCSettingsBundleHelper.swift

@@ -42,12 +42,12 @@ class NCSettingsBundleHelper: NSObject {
             URLCache.shared.memoryCapacity = 0
             URLCache.shared.memoryCapacity = 0
             URLCache.shared.diskCapacity = 0
             URLCache.shared.diskCapacity = 0
 
 
-            CCUtility.removeGroupDirectoryProviderStorage()
-            CCUtility.removeGroupApplicationSupport()
-            CCUtility.removeDocumentsDirectory()
-            CCUtility.removeTemporaryDirectory()
+            NCUtilityFileSystem.shared.removeGroupDirectoryProviderStorage()
+            NCUtilityFileSystem.shared.removeGroupApplicationSupport()
+            NCUtilityFileSystem.shared.removeDocumentsDirectory()
+            NCUtilityFileSystem.shared.removeTemporaryDirectory()
 
 
-            CCUtility.deleteAllChainStore()
+            NCKeychain().removeAll()
             NCManageDatabase.shared.removeDB()
             NCManageDatabase.shared.removeDB()
 
 
             DispatchQueue.main.asyncAfter(deadline: .now() + delay) {
             DispatchQueue.main.asyncAfter(deadline: .now() + delay) {

+ 2 - 2
iOSClient/Share/Advanced/NCShareAdvancePermissionHeader.swift

@@ -30,7 +30,7 @@ class NCShareAdvancePermissionHeader: UIView {
     @IBOutlet weak var fullWidthImageView: UIImageView!
     @IBOutlet weak var fullWidthImageView: UIImageView!
 
 
     func setupUI(with metadata: tableMetadata) {
     func setupUI(with metadata: tableMetadata) {
-        if FileManager.default.fileExists(atPath: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)) {
+        if FileManager.default.fileExists(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)) {
             fullWidthImageView.image = NCUtility.shared.getImageMetadata(metadata, for: frame.height)
             fullWidthImageView.image = NCUtility.shared.getImageMetadata(metadata, for: frame.height)
             fullWidthImageView.contentMode = .scaleAspectFill
             fullWidthImageView.contentMode = .scaleAspectFill
             imageView.isHidden = true
             imageView.isHidden = true
@@ -46,6 +46,6 @@ class NCShareAdvancePermissionHeader: UIView {
         fileName.text = metadata.fileNameView
         fileName.text = metadata.fileNameView
         fileName.textColor = .label
         fileName.textColor = .label
         info.textColor = .secondaryLabel
         info.textColor = .secondaryLabel
-        info.text = CCUtility.transformedSize(metadata.size) + ", " + CCUtility.dateDiff(metadata.date as Date)
+        info.text = NCUtilityFileSystem.shared.transformedSize(metadata.size) + ", " + CCUtility.dateDiff(metadata.date as Date)
     }
     }
 }
 }

+ 9 - 2
iOSClient/Share/NCShare.swift

@@ -166,7 +166,7 @@ class NCShare: UIViewController, NCShareNetworkingDelegate, NCSharePagingContent
         let fileName = appDelegate.userBaseUrl + "-" + metadata.ownerId + ".png"
         let fileName = appDelegate.userBaseUrl + "-" + metadata.ownerId + ".png"
 
 
         if NCManageDatabase.shared.getImageAvatarLoaded(fileName: fileName) == nil {
         if NCManageDatabase.shared.getImageAvatarLoaded(fileName: fileName) == nil {
-            let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + fileName
+            let fileNameLocalPath = NCUtilityFileSystem.shared.directoryUserData + "/" + fileName
             let etag = NCManageDatabase.shared.getTableAvatar(fileName: fileName)?.etag
             let etag = NCManageDatabase.shared.getTableAvatar(fileName: fileName)?.etag
 
 
             NextcloudKit.shared.downloadAvatar(
             NextcloudKit.shared.downloadAvatar(
@@ -204,8 +204,15 @@ class NCShare: UIViewController, NCShareNetworkingDelegate, NCSharePagingContent
     // MARK: - IBAction
     // MARK: - IBAction
 
 
     @IBAction func searchFieldDidEndOnExit(textField: UITextField) {
     @IBAction func searchFieldDidEndOnExit(textField: UITextField) {
+        // https://stackoverflow.com/questions/25471114/how-to-validate-an-e-mail-address-in-swift
+        func isValidEmail(_ email: String) -> Bool {
+
+            let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"
+            let emailPred = NSPredicate(format: "SELF MATCHES %@", emailRegEx)
+            return emailPred.evaluate(with: email)
+        }
         guard let searchString = textField.text, !searchString.isEmpty else { return }
         guard let searchString = textField.text, !searchString.isEmpty else { return }
-        if searchString.contains("@"), !NCUtility.shared.isValidEmail(searchString) { return }
+        if searchString.contains("@"), !isValidEmail(searchString) { return }
         networking?.getSharees(searchString: searchString)
         networking?.getSharees(searchString: searchString)
     }
     }
 
 

+ 3 - 6
iOSClient/Share/NCShareNetworking.swift

@@ -25,10 +25,7 @@ import NextcloudKit
 
 
 class NCShareNetworking: NSObject {
 class NCShareNetworking: NSObject {
 
 
-    // swiftlint:disable force_cast
-    private let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     weak var delegate: NCShareNetworkingDelegate?
     weak var delegate: NCShareNetworkingDelegate?
     var view: UIView
     var view: UIView
     var metadata: tableMetadata
     var metadata: tableMetadata
@@ -47,7 +44,7 @@ class NCShareNetworking: NSObject {
             NCActivityIndicator.shared.start(backgroundView: view)
             NCActivityIndicator.shared.start(backgroundView: view)
         }
         }
 
 
-        let filenamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId, account: metadata.account)!
+        let filenamePath = NCUtilityFileSystem.shared.getFileNamePath(metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId)
         let parameter = NKShareParameter(path: filenamePath)
         let parameter = NKShareParameter(path: filenamePath)
 
 
         NextcloudKit.shared.readShares(parameters: parameter) { account, shares, _, error in
         NextcloudKit.shared.readShares(parameters: parameter) { account, shares, _, error in
@@ -83,7 +80,7 @@ class NCShareNetworking: NSObject {
         // https://github.com/nextcloud/ios-communication-library/pull/104
         // https://github.com/nextcloud/ios-communication-library/pull/104
 
 
         NCActivityIndicator.shared.start(backgroundView: view)
         NCActivityIndicator.shared.start(backgroundView: view)
-        let filenamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId, account: metadata.account)!
+        let filenamePath = NCUtilityFileSystem.shared.getFileNamePath(metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId)
 
 
         NextcloudKit.shared.createShare(path: filenamePath, shareType: option.shareType, shareWith: option.shareWith, password: option.password, note: option.note, permissions: option.permissions, attributes: option.attributes) { _, share, _, error in
         NextcloudKit.shared.createShare(path: filenamePath, shareType: option.shareType, shareWith: option.shareWith, password: option.password, note: option.note, permissions: option.permissions, attributes: option.attributes) { _, share, _, error in
             NCActivityIndicator.shared.stop()
             NCActivityIndicator.shared.stop()

+ 3 - 3
iOSClient/Share/NCSharePaging.swift

@@ -276,8 +276,8 @@ class NCSharePagingView: PagingView {
         dateFormatter.timeStyle = .short
         dateFormatter.timeStyle = .short
         dateFormatter.locale = Locale.current
         dateFormatter.locale = Locale.current
 
 
-        if FileManager.default.fileExists(atPath: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)) {
-            headerView.imageView.image = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag))
+        if FileManager.default.fileExists(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)) {
+            headerView.imageView.image = UIImage(contentsOfFile: NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag))
         } else {
         } else {
             if metadata.directory {
             if metadata.directory {
                 let image = metadata.e2eEncrypted ? UIImage(named: "folderEncrypted") : UIImage(named: "folder")
                 let image = metadata.e2eEncrypted ? UIImage(named: "folderEncrypted") : UIImage(named: "folder")
@@ -297,7 +297,7 @@ class NCSharePagingView: PagingView {
         } else {
         } else {
             headerView.favorite.setImage(NCUtility.shared.loadImage(named: "star.fill", color: .systemGray, size: 20), for: .normal)
             headerView.favorite.setImage(NCUtility.shared.loadImage(named: "star.fill", color: .systemGray, size: 20), for: .normal)
         }
         }
-        headerView.info.text = CCUtility.transformedSize(metadata.size) + ", " + NSLocalizedString("_modified_", comment: "") + " " + dateFormatter.string(from: metadata.date as Date)
+        headerView.info.text = NCUtilityFileSystem.shared.transformedSize(metadata.size) + ", " + NSLocalizedString("_modified_", comment: "") + " " + dateFormatter.string(from: metadata.date as Date)
         headerView.info.textColor = .systemGray
         headerView.info.textColor = .systemGray
         headerView.creation.text = NSLocalizedString("_creation_", comment: "") + " " + dateFormatter.string(from: metadata.creationDate as Date)
         headerView.creation.text = NSLocalizedString("_creation_", comment: "") + " " + dateFormatter.string(from: metadata.creationDate as Date)
         headerView.creation.textColor = .systemGray
         headerView.creation.textColor = .systemGray

+ 1 - 1
iOSClient/Share/NCShareUserCell.swift

@@ -171,7 +171,7 @@ class NCSearchUserDropDownCell: DropDownCell, NCCellProtocol {
 
 
         let fileName = baseUrl.userBaseUrl + "-" + sharee.shareWith + ".png"
         let fileName = baseUrl.userBaseUrl + "-" + sharee.shareWith + ".png"
         if NCManageDatabase.shared.getImageAvatarLoaded(fileName: fileName) == nil {
         if NCManageDatabase.shared.getImageAvatarLoaded(fileName: fileName) == nil {
-            let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + fileName
+            let fileNameLocalPath = NCUtilityFileSystem.shared.directoryUserData + "/" + fileName
             let etag = NCManageDatabase.shared.getTableAvatar(fileName: fileName)?.etag
             let etag = NCManageDatabase.shared.getTableAvatar(fileName: fileName)?.etag
 
 
             NextcloudKit.shared.downloadAvatar(
             NextcloudKit.shared.downloadAvatar(

+ 1 - 1
iOSClient/Transfers/NCTransferCell.swift

@@ -141,7 +141,7 @@ class NCTransferCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellP
     }
     }
 
 
     func writeInfoDateSize(date: NSDate, size: Int64) {
     func writeInfoDateSize(date: NSDate, size: Int64) {
-        labelInfo.text = CCUtility.dateDiff(date as Date) + " · " + CCUtility.transformedSize(size)
+        labelInfo.text = CCUtility.dateDiff(date as Date) + " · " + NCUtilityFileSystem.shared.transformedSize(size)
     }
     }
 }
 }
 
 

+ 6 - 6
iOSClient/Transfers/NCTransfers.swift

@@ -196,7 +196,7 @@ class NCTransfers: NCCollectionViewCommon, NCTransferCellDelegate {
         } else {
         } else {
             cell.imageItem.image = UIImage(named: "file")
             cell.imageItem.image = UIImage(named: "file")
         }
         }
-        cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date) + " · " + CCUtility.transformedSize(metadata.size)
+        cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date) + " · " + NCUtilityFileSystem.shared.transformedSize(metadata.size)
         if metadata.status == NCGlobal.shared.metadataStatusDownloading || metadata.status == NCGlobal.shared.metadataStatusUploading {
         if metadata.status == NCGlobal.shared.metadataStatusDownloading || metadata.status == NCGlobal.shared.metadataStatusUploading {
             cell.progressView.isHidden = false
             cell.progressView.isHidden = false
         } else {
         } else {
@@ -206,22 +206,22 @@ class NCTransfers: NCCollectionViewCommon, NCTransferCellDelegate {
         switch metadata.status {
         switch metadata.status {
         case NCGlobal.shared.metadataStatusWaitDownload:
         case NCGlobal.shared.metadataStatusWaitDownload:
             cell.labelStatus.text = NSLocalizedString("_status_wait_download_", comment: "")
             cell.labelStatus.text = NSLocalizedString("_status_wait_download_", comment: "")
-            cell.labelInfo.text = CCUtility.transformedSize(metadata.size)
+            cell.labelInfo.text = NCUtilityFileSystem.shared.transformedSize(metadata.size)
         case NCGlobal.shared.metadataStatusInDownload:
         case NCGlobal.shared.metadataStatusInDownload:
             cell.labelStatus.text = NSLocalizedString("_status_in_download_", comment: "")
             cell.labelStatus.text = NSLocalizedString("_status_in_download_", comment: "")
-            cell.labelInfo.text = CCUtility.transformedSize(metadata.size)
+            cell.labelInfo.text = NCUtilityFileSystem.shared.transformedSize(metadata.size)
         case NCGlobal.shared.metadataStatusDownloading:
         case NCGlobal.shared.metadataStatusDownloading:
             cell.labelStatus.text = NSLocalizedString("_status_downloading_", comment: "")
             cell.labelStatus.text = NSLocalizedString("_status_downloading_", comment: "")
-            cell.labelInfo.text = CCUtility.transformedSize(metadata.size) + " - ↓ …"
+            cell.labelInfo.text = NCUtilityFileSystem.shared.transformedSize(metadata.size) + " - ↓ …"
         case NCGlobal.shared.metadataStatusWaitUpload:
         case NCGlobal.shared.metadataStatusWaitUpload:
             cell.labelStatus.text = NSLocalizedString("_status_wait_upload_", comment: "")
             cell.labelStatus.text = NSLocalizedString("_status_wait_upload_", comment: "")
             cell.labelInfo.text = ""
             cell.labelInfo.text = ""
         case NCGlobal.shared.metadataStatusInUpload:
         case NCGlobal.shared.metadataStatusInUpload:
             cell.labelStatus.text = NSLocalizedString("_status_in_upload_", comment: "")
             cell.labelStatus.text = NSLocalizedString("_status_in_upload_", comment: "")
-            cell.labelInfo.text = CCUtility.transformedSize(metadata.size)
+            cell.labelInfo.text = NCUtilityFileSystem.shared.transformedSize(metadata.size)
         case NCGlobal.shared.metadataStatusUploading:
         case NCGlobal.shared.metadataStatusUploading:
             cell.labelStatus.text = NSLocalizedString("_status_uploading_", comment: "")
             cell.labelStatus.text = NSLocalizedString("_status_uploading_", comment: "")
-            cell.labelInfo.text = CCUtility.transformedSize(metadata.size) + " - ↑ …"
+            cell.labelInfo.text = NCUtilityFileSystem.shared.transformedSize(metadata.size) + " - ↑ …"
         case NCGlobal.shared.metadataStatusUploadError:
         case NCGlobal.shared.metadataStatusUploadError:
             cell.labelStatus.text = NSLocalizedString("_status_upload_error_", comment: "")
             cell.labelStatus.text = NSLocalizedString("_status_upload_error_", comment: "")
             cell.labelInfo.text = metadata.sessionError
             cell.labelInfo.text = metadata.sessionError

+ 1 - 1
iOSClient/Trash/Cell/NCTrashListCell+NCTrashCellProtocol.swift

@@ -162,7 +162,7 @@ extension NCTrashCellProtocol where Self: UICollectionViewCell {
             self.imageItem.image = NCBrandColor.cacheImages.folder
             self.imageItem.image = NCBrandColor.cacheImages.folder
         } else {
         } else {
             self.imageItem.image = image
             self.imageItem.image = image
-            self.labelInfo?.text = (self.labelInfo?.text ?? "") + " · " + CCUtility.transformedSize(tableTrash.size)
+            self.labelInfo?.text = (self.labelInfo?.text ?? "") + " · " + NCUtilityFileSystem.shared.transformedSize(tableTrash.size)
         }
         }
         self.accessibilityLabel = tableTrash.trashbinFileName + ", " + (self.labelInfo?.text ?? "")
         self.accessibilityLabel = tableTrash.trashbinFileName + ", " + (self.labelInfo?.text ?? "")
     }
     }

+ 5 - 5
iOSClient/Trash/NCTrash+CollectionView.swift

@@ -68,10 +68,10 @@ extension NCTrash: UICollectionViewDataSource {
             image = UIImage(named: tableTrash.iconName)
             image = UIImage(named: tableTrash.iconName)
         }
         }
 
 
-        if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconOcId(tableTrash.fileId, etag: tableTrash.fileName)) {
-            image = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(tableTrash.fileId, etag: tableTrash.fileName))
+        if FileManager().fileExists(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(tableTrash.fileId, etag: tableTrash.fileName)) {
+            image = UIImage(contentsOfFile: NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(tableTrash.fileId, etag: tableTrash.fileName))
         } else {
         } else {
-            if tableTrash.hasPreview && !CCUtility.fileProviderStoragePreviewIconExists(tableTrash.fileId, etag: tableTrash.fileName) {
+            if tableTrash.hasPreview && !NCUtilityFileSystem.shared.fileProviderStoragePreviewIconExists(tableTrash.fileId, etag: tableTrash.fileName) {
                 downloadThumbnail(with: tableTrash, indexPath: indexPath)
                 downloadThumbnail(with: tableTrash, indexPath: indexPath)
             }
             }
         }
         }
@@ -123,9 +123,9 @@ extension NCTrash: UICollectionViewDataSource {
         }
         }
 
 
         if files > 1 {
         if files > 1 {
-            filesText = "\(files) " + NSLocalizedString("_files_", comment: "") + " " + CCUtility.transformedSize(size)
+            filesText = "\(files) " + NSLocalizedString("_files_", comment: "") + " " + NCUtilityFileSystem.shared.transformedSize(size)
         } else if files == 1 {
         } else if files == 1 {
-            filesText = "1 " + NSLocalizedString("_file_", comment: "") + " " + CCUtility.transformedSize(size)
+            filesText = "1 " + NSLocalizedString("_file_", comment: "") + " " + NCUtilityFileSystem.shared.transformedSize(size)
         }
         }
 
 
         if foldersText.isEmpty {
         if foldersText.isEmpty {

+ 2 - 2
iOSClient/Trash/NCTrash.swift

@@ -347,8 +347,8 @@ extension NCTrash {
 
 
     func downloadThumbnail(with tableTrash: tableTrash, indexPath: IndexPath) {
     func downloadThumbnail(with tableTrash: tableTrash, indexPath: IndexPath) {
 
 
-        let fileNamePreviewLocalPath = CCUtility.getDirectoryProviderStoragePreviewOcId(tableTrash.fileId, etag: tableTrash.fileName)!
-        let fileNameIconLocalPath = CCUtility.getDirectoryProviderStorageIconOcId(tableTrash.fileId, etag: tableTrash.fileName)!
+        let fileNamePreviewLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStoragePreviewOcId(tableTrash.fileId, etag: tableTrash.fileName)
+        let fileNameIconLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(tableTrash.fileId, etag: tableTrash.fileName)
 
 
         NextcloudKit.shared.downloadPreview(fileNamePathOrFileId: tableTrash.fileId,
         NextcloudKit.shared.downloadPreview(fileNamePathOrFileId: tableTrash.fileId,
                                             fileNamePreviewLocalPath: fileNamePreviewLocalPath,
                                             fileNamePreviewLocalPath: fileNamePreviewLocalPath,

+ 0 - 193
iOSClient/Utility/CCUtility.h

@@ -27,7 +27,6 @@
 #import <sys/sysctl.h>
 #import <sys/sysctl.h>
 #import <AssetsLibrary/AssetsLibrary.h>
 #import <AssetsLibrary/AssetsLibrary.h>
 #import <MessageUI/MessageUI.h>
 #import <MessageUI/MessageUI.h>
-#import <UICKeyChainStore.h>
 #import <Photos/Photos.h>
 #import <Photos/Photos.h>
 #import <PDFKit/PDFKit.h>
 #import <PDFKit/PDFKit.h>
 
 
@@ -35,200 +34,9 @@
 
 
 @interface CCUtility : NSObject
 @interface CCUtility : NSObject
 
 
-// ===== KeyChainStore =====
-
-// GET/SET
-
-+ (void)deleteAllChainStore;
-+ (void)storeAllChainInService;
-
-+ (NSString *)getPasscode;
-+ (void)setPasscode:(NSString *)passcode;
-
-+ (BOOL)getNotPasscodeAtStart;
-+ (void)setNotPasscodeAtStart:(BOOL)set;
-
-+ (BOOL)getEnableTouchFaceID;
-+ (void)setEnableTouchFaceID:(BOOL)set;
-
-+ (BOOL)isPasscodeAtStartEnabled;
-
-+ (NSString *)getGroupBySettings;
-+ (void)setGroupBySettings:(NSString *)groupby;
-
-+ (BOOL)getIntro;
-+ (void)setIntro:(BOOL)set;
-
-+ (NSString *)getIncrementalNumber;
-
-+ (NSString *)getAccountExt;
-+ (void)setAccountExt:(NSString *)account;
-
-+ (NSString *)getServerUrlExt;
-+ (void)setServerUrlExt:(NSString *)serverUrl;
-
-+ (NSString *)getTitleServerUrlExt;
-+ (void)setTitleServerUrlExt:(NSString *)titleServerUrl;
-
-+ (NSString *)getFileNameExt;
-+ (void)setFileNameExt:(NSString *)fileName;
-
-+ (NSString *)getEmail;
-+ (void)setEmail:(NSString *)email;
-
-+ (NSString *)getHint;
-+ (void)setHint:(NSString *)hint;
-
-+ (BOOL)getOriginalFileName:(NSString *)key;
-+ (void)setOriginalFileName:(BOOL)value key:(NSString *)key;
-
-+ (NSString *)getFileNameMask:(NSString *)key;
-+ (void)setFileNameMask:(NSString *)mask key:(NSString *)key;
-
-+ (BOOL)getFileNameType:(NSString *)key;
-+ (void)setFileNameType:(BOOL)prefix key:(NSString *)key;
-
-+ (BOOL)getActivityVerboseHigh;
-+ (void)setActivityVerboseHigh:(BOOL)debug;
-
-+ (BOOL)getShowHiddenFiles;
-+ (void)setShowHiddenFiles:(BOOL)show;
-
-+ (BOOL)getFormatCompatibility;
-+ (void)setFormatCompatibility:(BOOL)set;
-
-// E2EE -------------------------------------------
-
-+ (NSString *)getEndToEndCertificate:(NSString *)account;
-+ (void)setEndToEndCertificate:(NSString *)account certificate:(NSString *)certificate;
-
-+ (NSString *)getEndToEndPrivateKey:(NSString *)account;
-+ (void)setEndToEndPrivateKey:(NSString *)account privateKey:(NSString *)privateKey;
-
-+ (NSString *)getEndToEndPublicKey:(NSString *)account;
-+ (void)setEndToEndPublicKey:(NSString *)account publicKey:(NSString *)publicKey;
-
-+ (NSString *)getEndToEndPassphrase:(NSString *)account;
-+ (void)setEndToEndPassphrase:(NSString *)account passphrase:(NSString *)passphrase;
-
-+ (BOOL)isEndToEndEnabled:(NSString *)account;
-
-// E2EE -------------------------------------------
-
-+ (void)clearAllKeysEndToEnd:(NSString *)account;
-
-+ (BOOL)getDisableFilesApp;
-+ (void)setDisableFilesApp:(BOOL)disable;
-
-+ (void)setPushNotificationPublicKey:(NSString *)account data:(NSData *)data;
-+ (NSData *)getPushNotificationPublicKey:(NSString *)account;
-+ (void)setPushNotificationSubscribingPublicKey:(NSString *)account publicKey:(NSString *)publicKey;
-+ (NSString *)getPushNotificationSubscribingPublicKey:(NSString *)account;
-+ (void)setPushNotificationPrivateKey:(NSString *)account data:(NSData *)data;
-+ (NSData *)getPushNotificationPrivateKey:(NSString *)account;
-+ (void)setPushNotificationToken:(NSString *)account token:(NSString *)token;
-+ (NSString *)getPushNotificationToken:(NSString *)account;
-+ (void)setPushNotificationDeviceIdentifier:(NSString *)account deviceIdentifier:(NSString *)deviceIdentifier;
-+ (NSString *)getPushNotificationDeviceIdentifier:(NSString *)account;
-+ (void)setPushNotificationDeviceIdentifierSignature:(NSString *)account deviceIdentifierSignature:(NSString *)deviceIdentifierSignature;
-+ (NSString *)getPushNotificationDeviceIdentifierSignature:(NSString *)account;
-+ (void)clearAllKeysPushNotification:(NSString *)account;
-
-+ (NSInteger)getMediaWidthImage;
-+ (void)setMediaWidthImage:(NSInteger)width;
-
-+ (BOOL)getDisableCrashservice;
-+ (void)setDisableCrashservice:(BOOL)disable;
-
-+ (void)setPassword:(NSString *)account password:(NSString *)password;
-+ (NSString *)getPassword:(NSString *)account;
-
-+ (void)setHCBusinessType:(NSString *)professions;
-+ (NSString *)getHCBusinessType;
-
-+ (NSData *)getDatabaseEncryptionKey;
-
-+ (BOOL)getLivePhoto;
-+ (void)setLivePhoto:(BOOL)set;
-
-+ (NSString *)getMediaSortDate;
-+ (void)setMediaSortDate:(NSString *)value;
-
-+ (BOOL)getTextRecognitionStatus;
-+ (void)setTextRecognitionStatus:(BOOL)value;
-+ (BOOL)getDeleteAllScanImages;
-+ (void)setDeleteAllScanImages:(BOOL)value;
-+ (NSString *)getDirectoryScanDocument;
-+ (void)setDirectoryScanDocument:(NSString *)value;
-+ (double)getQualityScanDocument;
-+ (void)setQualityScanDocument:(double)value;
-
-+ (NSInteger)getLogLevel;
-+ (void)setLogLevel:(NSInteger)value;
-
-+ (BOOL)getAccountRequest;
-+ (void)setAccountRequest:(BOOL)set;
-
-+ (NSInteger)getCleanUpDay;
-+ (void)setCleanUpDay:(NSInteger)days;
-
-+ (BOOL)getPrivacyScreenEnabled;
-+ (void)setPrivacyScreenEnabled:(BOOL)set;
-
-+ (BOOL)getRemovePhotoCameraRoll;
-+ (void)setRemovePhotoCameraRoll:(BOOL)set;
-
-// ===== Varius =====
-
-+ (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL;
-
 + (NSString *)dateDiff:(NSDate *)convertedDate;
 + (NSString *)dateDiff:(NSDate *)convertedDate;
-+ (NSString *)transformedSize:(int64_t)value;
-
-+ (NSString *)removeForbiddenCharactersServer:(NSString *)fileName;
-+ (NSString *)removeForbiddenCharactersFileSystem:(NSString *)fileName;
-
-+ (NSString *)stringAppendServerUrl:(NSString *)serverUrl addFileName:(NSString *)addFileName;
-
-+ (NSString *)createFileNameDate:(NSString *)fileName extension:(NSString *)extension;
 + (NSString *)createFileName:(NSString *)fileName fileDate:(NSDate *)fileDate fileType:(PHAssetMediaType)fileType keyFileName:(NSString *)keyFileName keyFileNameType:(NSString *)keyFileNameType keyFileNameOriginal:(NSString *)keyFileNameOriginal forcedNewFileName:(BOOL)forcedNewFileName;
 + (NSString *)createFileName:(NSString *)fileName fileDate:(NSDate *)fileDate fileType:(PHAssetMediaType)fileType keyFileName:(NSString *)keyFileName keyFileNameType:(NSString *)keyFileNameType keyFileNameOriginal:(NSString *)keyFileNameOriginal forcedNewFileName:(BOOL)forcedNewFileName;
-
-+ (void)createDirectoryStandard;
-
-+ (NSURL *)getDirectoryGroup;
-+ (NSString *)getDirectoryDocuments;
-+ (NSString *)getDirectoryReaderMetadata;
-+ (NSString *)getDirectoryAudio;
-+ (NSString *)getDirectoryCerificates;
-+ (NSString *)getDirectoryUserData;
-+ (NSString *)getDirectoryProviderStorage;
-+ (NSString *)getDirectoryProviderStorageOcId:(NSString *)ocId;
-+ (NSString *)getDirectoryProviderStorageOcId:(NSString *)ocId fileNameView:(NSString *)fileNameView;
-+ (NSString *)getDirectoryProviderStorageIconOcId:(NSString *)ocId etag:(NSString *)etag;
-+ (NSString *)getDirectoryProviderStoragePreviewOcId:(NSString *)ocId etag:(NSString *)etag;
-+ (BOOL)fileProviderStorageExists:(tableMetadata *)metadata;
-+ (int64_t)fileProviderStorageSize:(NSString *)ocId fileNameView:(NSString *)fileNameView;
-+ (BOOL)fileProviderStoragePreviewIconExists:(NSString *)ocId etag:(NSString *)etag;
-
-+ (void)removeGroupApplicationSupport;
-+ (void)removeGroupLibraryDirectory;
-+ (void)removeGroupDirectoryProviderStorage;
-+ (void)removeDocumentsDirectory;
-+ (void)removeTemporaryDirectory;
-+ (void)emptyTemporaryDirectory;
-
 + (NSString *)getTitleSectionDate:(NSDate *)date;
 + (NSString *)getTitleSectionDate:(NSDate *)date;
-
-+ (void)moveFileAtPath:(NSString *)atPath toPath:(NSString *)toPath;
-+ (void)copyFileAtPath:(NSString *)atPath toPath:(NSString *)toPath;
-+ (void)removeFileAtPath:(NSString *)atPath;
-+ (void)createDirectoryAtPath:(NSString *)atPath;
-
-+ (NSString *)returnPathfromServerUrl:(NSString *)serverUrl urlBase:(NSString *)urlBase userId:(NSString *)userId account:(NSString *)account;
-+ (NSString *)returnFileNamePathFromFileName:(NSString *)metadataFileName serverUrl:(NSString *)serverUrl urlBase:(NSString *)urlBase userId:(NSString *)userId account:(NSString *)account;
-
-+ (NSString *)getDirectoryScan;
-
 + (NSString *)getMimeType:(NSString *)fileNameView;
 + (NSString *)getMimeType:(NSString *)fileNameView;
 
 
 // ===== Share Permissions =====
 // ===== Share Permissions =====
@@ -246,7 +54,6 @@
 
 
 + (NSString *)getExtension:(NSString*)fileName;
 + (NSString *)getExtension:(NSString*)fileName;
 + (NSDate *)datetimeWithOutTime:(NSDate *)datDate;
 + (NSDate *)datetimeWithOutTime:(NSDate *)datDate;
-+ (NSString *)valueForKey:(NSString *)key fromQueryItems:(NSArray *)queryItems;
 + (NSDate *)getATime:(const char *)path;
 + (NSDate *)getATime:(const char *)path;
 
 
 @end
 @end

Some files were not shown because too many files changed in this diff