From 472b560882eb6c39d78a6b24cbccd5288df997be Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Thu, 19 Oct 2023 17:43:49 +0200 Subject: [PATCH 01/90] update NextcloudNit Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> --- .../NCCollectionViewCommon.swift | 2 +- .../Networking/E2EE/NCNetworkingE2EE.swift | 18 ++++++------------ .../E2EE/NCNetworkingE2EECreateFolder.swift | 2 +- .../E2EE/NCNetworkingE2EEMarkFolder.swift | 2 +- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index 8d1ccf700a..1657a774b8 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -1019,7 +1019,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS CCUtility.isEnd(toEndEnabled: self.appDelegate.account), !NCNetworkingE2EE.shared.isInUpload(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, route: NCNetworkingE2EE.shared.getRoute()) { _, e2eMetadata, signature, _, error in + NextcloudKit.shared.getE2EEMetadata(fileId: metadataFolder.ocId, e2eToken: lock?.e2eToken) { _, e2eMetadata, signature, _, error in if error == .success, let e2eMetadata = e2eMetadata { let error = NCEndToEndMetadata().decodeMetadata(e2eMetadata, signature: signature, serverUrl: self.serverUrl, account: self.appDelegate.account, urlBase: self.appDelegate.urlBase, userId: self.appDelegate.userId) if error == .success { diff --git a/iOSClient/Networking/E2EE/NCNetworkingE2EE.swift b/iOSClient/Networking/E2EE/NCNetworkingE2EE.swift index a16fab32f7..d5b724b3af 100644 --- a/iOSClient/Networking/E2EE/NCNetworkingE2EE.swift +++ b/iOSClient/Networking/E2EE/NCNetworkingE2EE.swift @@ -28,12 +28,6 @@ class NCNetworkingE2EE: NSObject { return instance }() - func getRoute() -> String { - let e2eeRouteV1 = "v1" - let e2eeRouteV2 = "v2" - return (NCGlobal.shared.capabilityE2EEApiVersion == NCGlobal.shared.e2eeVersionV20) ? e2eeRouteV1 : e2eeRouteV1 - } - func isInUpload(account: String, serverUrl: String) -> Bool { let counter = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND (status == %d OR status == %d OR status == %d)", account, serverUrl, NCGlobal.shared.metadataStatusWaitUpload, NCGlobal.shared.metadataStatusInUpload, NCGlobal.shared.metadataStatusUploading)).count @@ -74,7 +68,7 @@ class NCNetworkingE2EE: NSObject { // METHOD // - let resultsGetE2EEMetadata = await NextcloudKit.shared.getE2EEMetadata(fileId: fileId, e2eToken: e2eToken, route: getRoute()) + let resultsGetE2EEMetadata = await NextcloudKit.shared.getE2EEMetadata(fileId: fileId, e2eToken: e2eToken) if resultsGetE2EEMetadata.error == .success { method = "PUT" } else if resultsGetE2EEMetadata.error.errorCode != NCGlobal.shared.errorResourceNotFound { @@ -112,7 +106,7 @@ class NCNetworkingE2EE: NSObject { fileId: String, e2eToken: String) async -> NKError { - let resultsGetE2EEMetadata = await NextcloudKit.shared.getE2EEMetadata(fileId: fileId, e2eToken: e2eToken, route: getRoute()) + let resultsGetE2EEMetadata = await NextcloudKit.shared.getE2EEMetadata(fileId: fileId, e2eToken: e2eToken) guard resultsGetE2EEMetadata.error == .success, let e2eMetadata = resultsGetE2EEMetadata.e2eMetadata else { return resultsGetE2EEMetadata.error } @@ -141,7 +135,7 @@ class NCNetworkingE2EE: NSObject { return resultsEncodeMetadata.error } - let putE2EEMetadataResults = await NextcloudKit.shared.putE2EEMetadata(fileId: fileId, e2eToken: e2eToken, e2eMetadata: e2eMetadata, signature: resultsEncodeMetadata.signature, method: method, route: getRoute()) + let putE2EEMetadataResults = await NextcloudKit.shared.putE2EEMetadata(fileId: fileId, e2eToken: e2eToken, e2eMetadata: e2eMetadata, signature: resultsEncodeMetadata.signature, method: method) guard putE2EEMetadataResults.error == .success else { return putE2EEMetadataResults.error } @@ -173,7 +167,7 @@ class NCNetworkingE2EE: NSObject { e2eCounter = "\(counter)" } - let resultsLockE2EEFolder = await NextcloudKit.shared.lockE2EEFolder(fileId: directory.fileId, e2eToken: e2eToken, e2eCounter: e2eCounter, method: "POST", route: getRoute()) + let resultsLockE2EEFolder = await NextcloudKit.shared.lockE2EEFolder(fileId: directory.fileId, e2eToken: e2eToken, e2eCounter: e2eCounter, method: "POST") if resultsLockE2EEFolder.error == .success, let e2eToken = resultsLockE2EEFolder.e2eToken { NCManageDatabase.shared.setE2ETokenLock(account: account, serverUrl: serverUrl, fileId: directory.fileId, e2eToken: e2eToken) } @@ -187,7 +181,7 @@ class NCNetworkingE2EE: NSObject { return } - let resultsLockE2EEFolder = await NextcloudKit.shared.lockE2EEFolder(fileId: tableLock.fileId, e2eToken: tableLock.e2eToken, e2eCounter: nil, method: "DELETE", route: getRoute()) + let resultsLockE2EEFolder = await NextcloudKit.shared.lockE2EEFolder(fileId: tableLock.fileId, e2eToken: tableLock.e2eToken, e2eCounter: nil, method: "DELETE") if resultsLockE2EEFolder.error == .success { NCManageDatabase.shared.deleteE2ETokenLock(account: account, serverUrl: serverUrl) } @@ -201,7 +195,7 @@ class NCNetworkingE2EE: NSObject { Task { for result in NCManageDatabase.shared.getE2EAllTokenLock(account: account) { - let resultsLockE2EEFolder = await NextcloudKit.shared.lockE2EEFolder(fileId: result.fileId, e2eToken: result.e2eToken, e2eCounter: nil, method: "DELETE", route: getRoute()) + let resultsLockE2EEFolder = await NextcloudKit.shared.lockE2EEFolder(fileId: result.fileId, e2eToken: result.e2eToken, e2eCounter: nil, method: "DELETE") if resultsLockE2EEFolder.error == .success { NCManageDatabase.shared.deleteE2ETokenLock(account: account, serverUrl: result.serverUrl) } diff --git a/iOSClient/Networking/E2EE/NCNetworkingE2EECreateFolder.swift b/iOSClient/Networking/E2EE/NCNetworkingE2EECreateFolder.swift index 339975f3a0..a417f24998 100644 --- a/iOSClient/Networking/E2EE/NCNetworkingE2EECreateFolder.swift +++ b/iOSClient/Networking/E2EE/NCNetworkingE2EECreateFolder.swift @@ -124,7 +124,7 @@ class NCNetworkingE2EECreateFolder: NSObject { // SET FOLDER AS E2EE // - let resultsMarkE2EEFolder = await NextcloudKit.shared.markE2EEFolder(fileId: fileId, delete: false, route: NCNetworkingE2EE.shared.getRoute()) + let resultsMarkE2EEFolder = await NextcloudKit.shared.markE2EEFolder(fileId: fileId, delete: false) guard resultsMarkE2EEFolder.error == .success else { await NCNetworkingE2EE.shared.unlock(account: account, serverUrl: serverUrl) return resultsMarkE2EEFolder.error diff --git a/iOSClient/Networking/E2EE/NCNetworkingE2EEMarkFolder.swift b/iOSClient/Networking/E2EE/NCNetworkingE2EEMarkFolder.swift index fddef4cb5e..40b7840060 100644 --- a/iOSClient/Networking/E2EE/NCNetworkingE2EEMarkFolder.swift +++ b/iOSClient/Networking/E2EE/NCNetworkingE2EEMarkFolder.swift @@ -31,7 +31,7 @@ class NCNetworkingE2EEMarkFolder: NSObject { let resultsReadFileOrFolder = await NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrlFileName, depth: "0") guard resultsReadFileOrFolder.error == .success, let file = resultsReadFileOrFolder.files.first else { return resultsReadFileOrFolder.error } - let resultsMarkE2EEFolder = await NextcloudKit.shared.markE2EEFolder(fileId: file.fileId, delete: false, route: NCNetworkingE2EE.shared.getRoute()) + let resultsMarkE2EEFolder = await NextcloudKit.shared.markE2EEFolder(fileId: file.fileId, delete: false) guard resultsMarkE2EEFolder.error == .success else { return resultsMarkE2EEFolder.error } file.e2eEncrypted = true From 01b701418354d945c3fd5c1d8e2371fcadd8628f Mon Sep 17 00:00:00 2001 From: Nextcloud bot Date: Fri, 20 Oct 2023 02:42:09 +0000 Subject: [PATCH 02/90] Fix(l10n): Update translations from Transifex Signed-off-by: Nextcloud bot --- .../hu.lproj/InfoPlist.strings | Bin 1428 -> 1456 bytes .../hu.lproj/Localizable.strings | Bin 126632 -> 126638 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/iOSClient/Supporting Files/hu.lproj/InfoPlist.strings b/iOSClient/Supporting Files/hu.lproj/InfoPlist.strings index 1b50bf7e41e923825218619807df3f500dd10716..975fa87a5a0ffdc3254c1a480ff06477946ca1a1 100644 GIT binary patch delta 209 zcmbQjy@7kfJH}W?hAIXHhD3%OhHNmI3nZ%;9x@aIMROTa8Pb7dDMJZRw1goGNP^TV yFk}E_au_OsDpP^tFM${$4q_JpO?t^t0F=qwY|HeYDUGI9Fz7KTF<3KjF#rIl{4MVQ delta 185 zcmdnMJ%xM2J4XKyh75*O1_g#hh5{f|U?^wEWXJ(R1%_gvOg@mWz)%UKOBsrQtQ;UK s8K|}ds4AZ!4=4g56M?K;kQtL5nN>FzFx_H`pt8XXdJIYo)(l(>04b{^F#rGn diff --git a/iOSClient/Supporting Files/hu.lproj/Localizable.strings b/iOSClient/Supporting Files/hu.lproj/Localizable.strings index c5267a86b4c99cc49817fa766ee22e325ee66672..bfea7e6e6cb46f415a85cc7771ffefd03b3fb05e 100644 GIT binary patch delta 97 zcmZ2+mwnw`_J%Et0q3W0FlQ8+{6$m1HisdVAsvYG7*ZGl85J0c8LAi(8IpiFg+YNK t11OWjPzhuu0&yC{LxwCMUx6W;;SZ2bnJ)N{QFwBSzrgl0=Na$F0RU`;8-4%) delta 124 zcmZ2?mwm-u_J%Et0q4^^8A=!w7>XHEfiM?HD**W!Kz0!jD==h&Me-Q(!KzXjK&(=R tbf5~5o&ttMhGek15}-K5lstwMxETrzX+RTlfGQ@(`HOA8be{2!8~{U{9N_=} From 3de2089f3ed24a48296c6b31fa1535b070d21386 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Fri, 20 Oct 2023 11:41:07 +0200 Subject: [PATCH 03/90] lint Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> --- iOSClient/Media/NCMediaCache.swift | 2 +- iOSClient/Settings/CCAdvanced.m | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/iOSClient/Media/NCMediaCache.swift b/iOSClient/Media/NCMediaCache.swift index 4557ec201f..5c90c69f4b 100644 --- a/iOSClient/Media/NCMediaCache.swift +++ b/iOSClient/Media/NCMediaCache.swift @@ -20,7 +20,7 @@ import NextcloudKit private typealias ThumbnailLRUCache = LRUCache private let cache: ThumbnailLRUCache = ThumbnailLRUCache(countLimit: 2000) - @objc func createCache(account: String) { + func createCache(account: String) { let resultsMedia = NCManageDatabase.shared.getMediaOcIdEtag(account: account) guard !resultsMedia.isEmpty, diff --git a/iOSClient/Settings/CCAdvanced.m b/iOSClient/Settings/CCAdvanced.m index cb2ced5ede..f2aabfe1b8 100755 --- a/iOSClient/Settings/CCAdvanced.m +++ b/iOSClient/Settings/CCAdvanced.m @@ -161,8 +161,6 @@ - (void)initializeForm } else { [[[NextcloudKit shared] nkCommonInstance] writeLog:[NSString stringWithFormat:@"[INFO] Clear log with level %lu %@", (unsigned long)logLevel, versionNextcloudiOS]]; } - - [[NCMediaCache shared] createCacheWithAccount:appDelegate.account]; }; [section addFormRow:row]; From 74d530298a5a9e7fb41d726f0bc4b31decc03897 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Fri, 20 Oct 2023 12:01:26 +0200 Subject: [PATCH 04/90] lint Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> --- iOSClient/Media/NCMediaCache.swift | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/iOSClient/Media/NCMediaCache.swift b/iOSClient/Media/NCMediaCache.swift index 5c90c69f4b..349ae8d4b6 100644 --- a/iOSClient/Media/NCMediaCache.swift +++ b/iOSClient/Media/NCMediaCache.swift @@ -2,8 +2,23 @@ // NCMediaCache.swift // Nextcloud // -// Created by Milen on 10.10.23. -// Copyright © 2023 Marino Faggiana. All rights reserved. +// Created by Marino Faggiana on 18/10/23. +// Copyright © 2021 Marino Faggiana. All rights reserved. +// +// Author Marino Faggiana +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . // import UIKit From a232a022bbd75207a7346fa901560e44abd164d9 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Fri, 20 Oct 2023 12:04:24 +0200 Subject: [PATCH 05/90] lint Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> --- iOSClient/Media/NCMediaCache.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/iOSClient/Media/NCMediaCache.swift b/iOSClient/Media/NCMediaCache.swift index 349ae8d4b6..34a72a2c08 100644 --- a/iOSClient/Media/NCMediaCache.swift +++ b/iOSClient/Media/NCMediaCache.swift @@ -50,9 +50,7 @@ import NextcloudKit var date: Date } var files: [FileInfo] = [] - let startDate = Date() - NextcloudKit.shared.nkCommonInstance.writeLog("--------- start ThumbnailLRUCache image process ---------") // Get files only image / video if let enumerator = manager.enumerator(at: URL(fileURLWithPath: directory), includingPropertiesForKeys: [.isRegularFileKey], options: [.skipsHiddenFiles]) { @@ -88,9 +86,10 @@ import NextcloudKit let endDate = Date() let diffDate = endDate.timeIntervalSinceReferenceDate - startDate.timeIntervalSinceReferenceDate + NextcloudKit.shared.nkCommonInstance.writeLog("--------- ThumbnailLRUCache image process ---------") NextcloudKit.shared.nkCommonInstance.writeLog("Counter process: \(cache.count)") NextcloudKit.shared.nkCommonInstance.writeLog("Time process: \(diffDate)") - NextcloudKit.shared.nkCommonInstance.writeLog("--------- stop ThumbnailLRUCache image process ---------") + NextcloudKit.shared.nkCommonInstance.writeLog("--------- ThumbnailLRUCache image process ---------") } func getImage(ocId: String) -> UIImage? { From 6a560e3d8080181ab32ea00c29c085b2402c994e Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Fri, 20 Oct 2023 12:17:11 +0200 Subject: [PATCH 06/90] improvements Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> --- iOSClient/Media/NCMediaCache.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/iOSClient/Media/NCMediaCache.swift b/iOSClient/Media/NCMediaCache.swift index 34a72a2c08..a0e4ee465a 100644 --- a/iOSClient/Media/NCMediaCache.swift +++ b/iOSClient/Media/NCMediaCache.swift @@ -32,8 +32,11 @@ import NextcloudKit return instance }() + let limit: Int = 2000 private typealias ThumbnailLRUCache = LRUCache - private let cache: ThumbnailLRUCache = ThumbnailLRUCache(countLimit: 2000) + private lazy var cache: ThumbnailLRUCache = { + return ThumbnailLRUCache(countLimit: limit) + }() func createCache(account: String) { @@ -76,7 +79,10 @@ import NextcloudKit // Insert in cache cache.removeAllValues() + var counter: Int = 0 for file in files { + counter += 1 + if counter > limit { break } autoreleasepool { if let image = UIImage(contentsOfFile: file.path.path) { cache.setValue(image, forKey: file.ocId) From 510bdb453b4c40b9666b78e2643808beaa995a0c Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Fri, 20 Oct 2023 12:17:49 +0200 Subject: [PATCH 07/90] lint Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> --- iOSClient/Media/NCMediaCache.swift | 3 --- 1 file changed, 3 deletions(-) diff --git a/iOSClient/Media/NCMediaCache.swift b/iOSClient/Media/NCMediaCache.swift index a0e4ee465a..5a8d9ea97a 100644 --- a/iOSClient/Media/NCMediaCache.swift +++ b/iOSClient/Media/NCMediaCache.swift @@ -55,7 +55,6 @@ import NextcloudKit var files: [FileInfo] = [] let startDate = Date() - // Get files only image / video if let enumerator = manager.enumerator(at: URL(fileURLWithPath: directory), includingPropertiesForKeys: [.isRegularFileKey], options: [.skipsHiddenFiles]) { for case let fileURL as URL in enumerator where fileURL.lastPathComponent.hasSuffix(ext) { let fileName = fileURL.lastPathComponent @@ -70,14 +69,12 @@ import NextcloudKit } } - // Sort for most recent files.sort(by: { $0.date > $1.date }) if let firstDate = files.first?.date, let lastDate = files.last?.date { print("First date: \(firstDate)") print("Last date: \(lastDate)") } - // Insert in cache cache.removeAllValues() var counter: Int = 0 for file in files { From 136ec6280547c04e2501fc3ec1a073dc1b1076a4 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Fri, 20 Oct 2023 15:21:36 +0200 Subject: [PATCH 08/90] Added hud upload e2ee / chunk Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> --- Nextcloud.xcodeproj/project.pbxproj | 16 +++++++++++++ .../E2EE/NCNetworkingE2EEUpload.swift | 23 ++++++++++++++++++- iOSClient/Networking/NCNetworking.swift | 17 +++++++++++++- .../en.lproj/Localizable.strings | 1 + 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/Nextcloud.xcodeproj/project.pbxproj b/Nextcloud.xcodeproj/project.pbxproj index cfd4cf4059..0a5dd52d55 100644 --- a/Nextcloud.xcodeproj/project.pbxproj +++ b/Nextcloud.xcodeproj/project.pbxproj @@ -325,6 +325,8 @@ F74E7720277A2EF40013B958 /* XLForm in Frameworks */ = {isa = PBXBuildFile; productRef = F74E771F277A2EF40013B958 /* XLForm */; }; F7501C322212E57500FB1415 /* NCMedia.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7501C302212E57400FB1415 /* NCMedia.storyboard */; }; F7501C332212E57500FB1415 /* NCMedia.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7501C312212E57400FB1415 /* NCMedia.swift */; }; + F75379202AE2AD9400C0250E /* JGProgressHUD in Frameworks */ = {isa = PBXBuildFile; productRef = F753791F2AE2AD9400C0250E /* JGProgressHUD */; }; + F75379222AE2ADA100C0250E /* JGProgressHUD in Frameworks */ = {isa = PBXBuildFile; productRef = F75379212AE2ADA100C0250E /* JGProgressHUD */; }; F753BA93281FD8020015BFB6 /* EasyTipView in Frameworks */ = {isa = PBXBuildFile; productRef = F753BA92281FD8020015BFB6 /* EasyTipView */; }; F755BD9B20594AC7008C5FBB /* NCService.swift in Sources */ = {isa = PBXBuildFile; fileRef = F755BD9A20594AC7008C5FBB /* NCService.swift */; }; F757CC8229E7F88B00F31428 /* NCManageDatabase+Groupfolders.swift in Sources */ = {isa = PBXBuildFile; fileRef = F757CC8129E7F88B00F31428 /* NCManageDatabase+Groupfolders.swift */; }; @@ -1468,6 +1470,7 @@ F7346E2928B0FFF2006CE2D2 /* RealmSwift in Frameworks */, F7A560462AE15D3D00BE8FD6 /* Queuer in Frameworks */, F783030D28B4C59A00B84583 /* SwiftEntryKit in Frameworks */, + F75379222AE2ADA100C0250E /* JGProgressHUD in Frameworks */, F7346E1228B0EF5B006CE2D2 /* WidgetKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1480,6 +1483,7 @@ F7EBCDD1277B820D00A4EF67 /* UICKeyChainStore in Frameworks */, F73ADD2426554FE20069EA0D /* SwiftEntryKit in Frameworks */, F710FC84277B7D3500AA9FBF /* RealmSwift in Frameworks */, + F75379202AE2AD9400C0250E /* JGProgressHUD in Frameworks */, F72AD71328C24BCC006CB92D /* NextcloudKit in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2827,6 +2831,7 @@ F783034328B5142B00B84583 /* NextcloudKit */, F787AC0A298BCB540001BB00 /* SVGKitSwift */, F7A560452AE15D3D00BE8FD6 /* Queuer */, + F75379212AE2ADA100C0250E /* JGProgressHUD */, ); productName = DashboardWidgetExtension; productReference = F7346E1028B0EF5B006CE2D2 /* Widget.appex */; @@ -2851,6 +2856,7 @@ F7EBCDD0277B820D00A4EF67 /* UICKeyChainStore */, F72AD71228C24BCC006CB92D /* NextcloudKit */, F7A560432AE15D2900BE8FD6 /* Queuer */, + F753791F2AE2AD9400C0250E /* JGProgressHUD */, ); productName = "File Provider Extension"; productReference = F771E3D020E2392D00AFB62D /* File Provider Extension.appex */; @@ -5355,6 +5361,16 @@ package = F74E771E277A2EF40013B958 /* XCRemoteSwiftPackageReference "XLForm" */; productName = XLForm; }; + F753791F2AE2AD9400C0250E /* JGProgressHUD */ = { + isa = XCSwiftPackageProductDependency; + package = F72CD01027A7E92400E59476 /* XCRemoteSwiftPackageReference "JGProgressHUD" */; + productName = JGProgressHUD; + }; + F75379212AE2ADA100C0250E /* JGProgressHUD */ = { + isa = XCSwiftPackageProductDependency; + package = F72CD01027A7E92400E59476 /* XCRemoteSwiftPackageReference "JGProgressHUD" */; + productName = JGProgressHUD; + }; F753BA92281FD8020015BFB6 /* EasyTipView */ = { isa = XCSwiftPackageProductDependency; package = F753BA91281FD8010015BFB6 /* XCRemoteSwiftPackageReference "EasyTipView" */; diff --git a/iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift b/iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift index fba8c37720..b24fe3a036 100644 --- a/iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift +++ b/iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift @@ -25,6 +25,7 @@ import NextcloudKit import CFNetwork import Alamofire import Foundation +import JGProgressHUD protocol uploadE2EEDelegate: AnyObject { func start() @@ -38,6 +39,8 @@ extension uploadE2EEDelegate { class NCNetworkingE2EEUpload: NSObject { + let hud = JGProgressHUD() + func upload(metadata: tableMetadata, uploadE2EEDelegate: uploadE2EEDelegate? = nil) async -> NKError { var metadata = metadata @@ -123,10 +126,23 @@ class NCNetworkingE2EEUpload: NSObject { return NKError(errorCode: NCGlobal.shared.errorE2EELock, errorDescription: NSLocalizedString("_e2e_error_", comment: "")) } + // HUD + // +#if !EXTENSION + DispatchQueue.main.async { + guard let appDelegate = UIApplication.shared.delegate as? AppDelegate, let hudView = appDelegate.window?.rootViewController?.view else { + return + } + self.hud.textLabel.text = NSLocalizedString("_wait_file_preparation_", comment: "") + self.hud.show(in: hudView) + } +#endif + // SEND NEW METADATA // let sendE2eeError = await sendE2ee(e2eToken: e2eToken, fileId: fileId) guard sendE2eeError == .success else { + DispatchQueue.main.async { self.hud.dismiss() } NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", ocIdTemp)) NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterUploadedFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account, "fileName": metadata.fileName, "ocIdTemp": ocIdTemp, "error": sendE2eeError]) await NCNetworkingE2EE.shared.unlock(account: metadata.account, serverUrl: metadata.serverUrl) @@ -181,9 +197,11 @@ class NCNetworkingE2EEUpload: NSObject { private func sendFile(metadata: tableMetadata, e2eToken: String, uploadE2EEDelegate: uploadE2EEDelegate? = nil) async -> (ocId: String?, etag: String?, date: NSDate?, afError: AFError?, error: NKError) { if metadata.chunk > 0 { - return await withCheckedContinuation({ continuation in NCNetworking.shared.uploadChunkFile(metadata: metadata, withUploadComplete: false, addCustomHeaders: ["e2e-token": e2eToken]) { +#if !EXTENSION + DispatchQueue.main.async { self.hud.dismiss() } +#endif uploadE2EEDelegate?.start() } progressHandler: { totalBytesExpected, totalBytes, fractionCompleted in uploadE2EEDelegate?.uploadE2EEProgress(totalBytesExpected, totalBytes, fractionCompleted) @@ -197,6 +215,9 @@ class NCNetworkingE2EEUpload: NSObject { let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileName)! return await withCheckedContinuation({ continuation in NCNetworking.shared.uploadFile(metadata: metadata, fileNameLocalPath: fileNameLocalPath, withUploadComplete: false, addCustomHeaders: ["e2e-token": e2eToken]) { +#if !EXTENSION + DispatchQueue.main.async { self.hud.dismiss() } +#endif uploadE2EEDelegate?.start() } progressHandler: { totalBytesExpected, totalBytes, fractionCompleted in uploadE2EEDelegate?.uploadE2EEProgress(totalBytesExpected, totalBytes, fractionCompleted) diff --git a/iOSClient/Networking/NCNetworking.swift b/iOSClient/Networking/NCNetworking.swift index 0a7e3ea45d..2247f98b65 100644 --- a/iOSClient/Networking/NCNetworking.swift +++ b/iOSClient/Networking/NCNetworking.swift @@ -27,6 +27,7 @@ import NextcloudKit import Alamofire import Photos import Queuer +import JGProgressHUD @objc public protocol NCNetworkingDelegate { @objc optional func downloadProgress(_ progress: Float, totalBytes: Int64, totalBytesExpected: Int64, fileName: String, serverUrl: String, session: URLSession, task: URLSessionTask) @@ -382,6 +383,7 @@ class NCNetworking: NSObject, NKCommonDelegate { progressHandler: @escaping (_ totalBytesExpected: Int64, _ totalBytes: Int64, _ fractionCompleted: Double) -> Void = { _, _, _ in }, completion: @escaping (_ error: NKError) -> Void = { _ in }) { + let hud = JGProgressHUD() let metadata = tableMetadata.init(value: metadata) NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Upload file \(metadata.fileNameView) with Identifier \(metadata.assetLocalIdentifier) with size \(metadata.size) [CHUNK \(metadata.chunk), E2EE \(metadata.isDirectoryE2EE)]") @@ -393,7 +395,20 @@ class NCNetworking: NSObject, NKCommonDelegate { } #endif } else if metadata.chunk > 0 { - uploadChunkFile(metadata: metadata, start: start, progressHandler: progressHandler) { _, _, _, error in +#if !EXTENSION + DispatchQueue.main.async { + guard let appDelegate = UIApplication.shared.delegate as? AppDelegate, let hudView = appDelegate.window?.rootViewController?.view else { + return completion(.success) + } + hud.textLabel.text = NSLocalizedString("_wait_file_preparation_", comment: "") + hud.show(in: hudView) + } +#endif + uploadChunkFile(metadata: metadata) { +#if !EXTENSION + DispatchQueue.main.async { hud.dismiss() } +#endif + } completion: { _, _, _, error in completion(error) } } else if metadata.session == NextcloudKit.shared.nkCommonInstance.sessionIdentifierUpload { diff --git a/iOSClient/Supporting Files/en.lproj/Localizable.strings b/iOSClient/Supporting Files/en.lproj/Localizable.strings index 563b17d18f..0c9b127bb0 100644 --- a/iOSClient/Supporting Files/en.lproj/Localizable.strings +++ b/iOSClient/Supporting Files/en.lproj/Localizable.strings @@ -215,6 +215,7 @@ "_replace_all_action_title_" = "Replace all"; "_keep_both_for_all_action_title_" = "Keep both for all"; "_more_action_title_" = "More Details"; +"_wait_file_preparation_" = "Please wait, upload file in preparation …"; /* Background of the file listing view */ "_use_as_background_" = "Use it as a background"; From cd4ce3fcc3bff709d02b44c030e87e209f8b053a Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Fri, 20 Oct 2023 15:56:45 +0200 Subject: [PATCH 09/90] fix Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> --- .../Collection Common/NCCollectionViewCommon.swift | 10 ++++++---- iOSClient/Media/NCMedia.swift | 10 ++++++---- iOSClient/Select/NCSelect.swift | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index 1657a774b8..4c78011fa5 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -1209,7 +1209,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { } if metadata.hasPreview && metadata.status == NCGlobal.shared.metadataStatusNormal && (!CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag)) { 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), view: view)) + appDelegate.downloadThumbnailQueue.addOperation(NCCollectionViewDownloadThumbnail(metadata: metadata, cell: (cell as? NCCellProtocol), collectionView: collectionView)) } } } else { @@ -1745,15 +1745,15 @@ class NCCollectionViewDownloadThumbnail: ConcurrentOperation { var metadata: tableMetadata var cell: NCCellProtocol? - var view: UIView? + var collectionView: UICollectionView? var fileNamePath: String var fileNamePreviewLocalPath: String var fileNameIconLocalPath: String - init(metadata: tableMetadata, cell: NCCellProtocol?, view: UIView?) { + init(metadata: tableMetadata, cell: NCCellProtocol?, collectionView: UICollectionView?) { self.metadata = tableMetadata.init(value: metadata) self.cell = cell - self.view = view + 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)! @@ -1786,6 +1786,8 @@ class NCCollectionViewDownloadThumbnail: ConcurrentOperation { options: .transitionCrossDissolve, animations: { filePreviewImageView.image = image }, completion: nil) + } else { + self.collectionView?.reloadData() } } } diff --git a/iOSClient/Media/NCMedia.swift b/iOSClient/Media/NCMedia.swift index 7ec6d72ff4..0f3aa7408a 100644 --- a/iOSClient/Media/NCMedia.swift +++ b/iOSClient/Media/NCMedia.swift @@ -383,7 +383,7 @@ extension NCMedia: UICollectionViewDataSource { } else { if metadata.hasPreview && metadata.status == NCGlobal.shared.metadataStatusNormal && (!CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag)) { for case let operation as NCMediaDownloadThumbnaill in appDelegate.downloadThumbnailQueue.operations where operation.metadata.ocId == metadata.ocId { return } - appDelegate.downloadThumbnailQueue.addOperation(NCMediaDownloadThumbnaill(metadata: metadata, cell: cell, view: view)) + appDelegate.downloadThumbnailQueue.addOperation(NCMediaDownloadThumbnaill(metadata: metadata, cell: cell, collectionView: collectionView)) } } } @@ -861,15 +861,15 @@ class NCMediaDownloadThumbnaill: ConcurrentOperation { var metadata: tableMetadata var cell: NCCellProtocol? - var view: UIView? + var collectionView: UICollectionView? var fileNamePath: String var fileNamePreviewLocalPath: String var fileNameIconLocalPath: String - init(metadata: tableMetadata, cell: NCCellProtocol?, view: UIView?) { + init(metadata: tableMetadata, cell: NCCellProtocol?, collectionView: UICollectionView?) { self.metadata = tableMetadata.init(value: metadata) self.cell = cell - self.view = view + 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)! @@ -902,6 +902,8 @@ class NCMediaDownloadThumbnaill: ConcurrentOperation { options: .transitionCrossDissolve, animations: { filePreviewImageView.image = image }, completion: nil) + } else { + self.collectionView?.reloadData() } } NCMediaCache.shared.setImage(ocId: self.metadata.ocId, image: image) diff --git a/iOSClient/Select/NCSelect.swift b/iOSClient/Select/NCSelect.swift index 861790e533..3de5f162b0 100644 --- a/iOSClient/Select/NCSelect.swift +++ b/iOSClient/Select/NCSelect.swift @@ -308,7 +308,7 @@ extension NCSelect: UICollectionViewDataSource { } if metadata.hasPreview && metadata.status == NCGlobal.shared.metadataStatusNormal && (!CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag)) { 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), view: view)) + appDelegate.downloadThumbnailQueue.addOperation(NCCollectionViewDownloadThumbnail(metadata: metadata, cell: (cell as? NCCellProtocol), collectionView: collectionView)) } } } From 213c7f5f3db9c86909bc076f545a97f19ddb8f06 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Fri, 20 Oct 2023 16:02:02 +0200 Subject: [PATCH 10/90] Build 4 Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> --- Nextcloud.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Nextcloud.xcodeproj/project.pbxproj b/Nextcloud.xcodeproj/project.pbxproj index 0a5dd52d55..b962e9abef 100644 --- a/Nextcloud.xcodeproj/project.pbxproj +++ b/Nextcloud.xcodeproj/project.pbxproj @@ -4697,7 +4697,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 4; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = NKUJUXUJ3B; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -4762,7 +4762,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 4; DEVELOPMENT_TEAM = NKUJUXUJ3B; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; From 93d8ba783db0447a95efc53303aabeb21c945531 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Fri, 20 Oct 2023 16:43:59 +0200 Subject: [PATCH 11/90] coding Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> --- iOSClient/AppDelegate.swift | 1 + iOSClient/Extensions/UIImage+Extension.swift | 31 +++++++++++++++++++ iOSClient/Menu/NCOperationSaveLivePhoto.swift | 7 ++--- iOSClient/Utility/NCUtility.swift | 21 +++++++++++++ 4 files changed, 56 insertions(+), 4 deletions(-) diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index 63faeb543e..f38613674e 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -86,6 +86,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD CCUtility.createDirectoryStandard() CCUtility.emptyTemporaryDirectory() + NCUtility.shared.clearCacheDirectory("com.limit-point.LivePhoto") // Activated singleton _ = NCActionCenter.shared diff --git a/iOSClient/Extensions/UIImage+Extension.swift b/iOSClient/Extensions/UIImage+Extension.swift index 23d4b4e259..80ca865c3c 100644 --- a/iOSClient/Extensions/UIImage+Extension.swift +++ b/iOSClient/Extensions/UIImage+Extension.swift @@ -232,4 +232,35 @@ extension UIImage { } return image } + + var heic: Data? { heic() } + var cgImageOrientation: CGImagePropertyOrientation { .init(imageOrientation) } + + func heic(compressionQuality: CGFloat = 1) -> Data? { + guard + let mutableData = CFDataCreateMutable(nil, 0), + let destination = CGImageDestinationCreateWithData(mutableData, "public.heic" as CFString, 1, nil), + let cgImage = cgImage + else { return nil } + CGImageDestinationAddImage(destination, cgImage, [kCGImageDestinationLossyCompressionQuality: compressionQuality, kCGImagePropertyOrientation: cgImageOrientation.rawValue] as CFDictionary) + guard CGImageDestinationFinalize(destination) else { return nil } + return mutableData as Data + } +} + +extension CGImagePropertyOrientation { + init(_ uiOrientation: UIImage.Orientation) { + switch uiOrientation { + case .up: self = .up + case .upMirrored: self = .upMirrored + case .down: self = .down + case .downMirrored: self = .downMirrored + case .left: self = .left + case .leftMirrored: self = .leftMirrored + case .right: self = .right + case .rightMirrored: self = .rightMirrored + @unknown default: + fatalError() + } + } } diff --git a/iOSClient/Menu/NCOperationSaveLivePhoto.swift b/iOSClient/Menu/NCOperationSaveLivePhoto.swift index d7eb485480..6bdda0015c 100644 --- a/iOSClient/Menu/NCOperationSaveLivePhoto.swift +++ b/iOSClient/Menu/NCOperationSaveLivePhoto.swift @@ -1,5 +1,5 @@ // -// NCooo.swift +// NCOperationSaveLivePhoto.swift // Nextcloud // // Created by Marino Faggiana on 19/10/23. @@ -21,7 +21,6 @@ // along with this program. If not, see . // - import UIKit import Queuer import JGProgressHUD @@ -97,8 +96,8 @@ class NCOperationSaveLivePhoto: ConcurrentOperation { NCLivePhoto.generate(from: fileNameImage, videoURL: fileNameMov, progress: { progress in self.hud.progress = Float(progress) }, completion: { _, resources in - if resources != nil { - NCLivePhoto.saveToLibrary(resources!) { result in + if let resources { + NCLivePhoto.saveToLibrary(resources) { result in DispatchQueue.main.async { if !result { self.hud.indicatorView = JGProgressHUDErrorIndicatorView() diff --git a/iOSClient/Utility/NCUtility.swift b/iOSClient/Utility/NCUtility.swift index dd43e33b84..c704bde42b 100644 --- a/iOSClient/Utility/NCUtility.swift +++ b/iOSClient/Utility/NCUtility.swift @@ -841,4 +841,25 @@ class NCUtility: NSObject { return (usedmegabytes, totalmegabytes) } + + /* "com.limit-point.LivePhoto" */ + func clearCacheDirectory(_ directory: String) { + if let cacheURL = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first { + let fullDirectory = cacheURL.appendingPathComponent(directory, isDirectory: true) + let fileManager = FileManager.default + do { + // Get the directory contents urls (including subfolders urls) + let directoryContents = try FileManager.default.contentsOfDirectory( at: cacheURL, includingPropertiesForKeys: nil, options: []) + for file in directoryContents { + do { + try fileManager.removeItem(at: file) + } catch let error as NSError { + debugPrint("Ooops! Something went wrong: \(error)") + } + } + } catch let error as NSError { + print(error.localizedDescription) + } + } + } } From 981512fe89da38ff49977519284fad98fee73f7a Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Fri, 20 Oct 2023 16:49:40 +0200 Subject: [PATCH 12/90] lint Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> --- iOSClient/Utility/NCUtility.swift | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/iOSClient/Utility/NCUtility.swift b/iOSClient/Utility/NCUtility.swift index c704bde42b..2b37c5b5f2 100644 --- a/iOSClient/Utility/NCUtility.swift +++ b/iOSClient/Utility/NCUtility.swift @@ -842,17 +842,14 @@ class NCUtility: NSObject { return (usedmegabytes, totalmegabytes) } - /* "com.limit-point.LivePhoto" */ func clearCacheDirectory(_ directory: String) { if let cacheURL = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first { - let fullDirectory = cacheURL.appendingPathComponent(directory, isDirectory: true) - let fileManager = FileManager.default do { - // Get the directory contents urls (including subfolders urls) - let directoryContents = try FileManager.default.contentsOfDirectory( at: cacheURL, includingPropertiesForKeys: nil, options: []) + let directoryURL = cacheURL.appendingPathComponent(directory, isDirectory: true) + let directoryContents = try FileManager.default.contentsOfDirectory(at: directoryURL, includingPropertiesForKeys: nil, options: []) for file in directoryContents { do { - try fileManager.removeItem(at: file) + try FileManager.default.removeItem(at: file) } catch let error as NSError { debugPrint("Ooops! Something went wrong: \(error)") } From dd4d288b6180683a7926dff7dd720466057df47e Mon Sep 17 00:00:00 2001 From: Nextcloud bot Date: Sat, 21 Oct 2023 02:39:34 +0000 Subject: [PATCH 13/90] Fix(l10n): Update translations from Transifex Signed-off-by: Nextcloud bot --- .../af.lproj/Localizable.strings | Bin 120852 -> 120998 bytes .../an.lproj/Localizable.strings | Bin 120224 -> 120370 bytes .../ar.lproj/Localizable.strings | Bin 119434 -> 119580 bytes .../ast.lproj/Localizable.strings | Bin 120244 -> 120390 bytes .../az.lproj/Localizable.strings | Bin 120550 -> 120696 bytes .../be.lproj/Localizable.strings | Bin 120304 -> 120450 bytes .../bg_BG.lproj/Localizable.strings | Bin 127856 -> 128002 bytes .../bn_BD.lproj/Localizable.strings | Bin 120474 -> 120620 bytes .../br.lproj/Localizable.strings | Bin 124564 -> 124710 bytes .../bs.lproj/Localizable.strings | Bin 120528 -> 120674 bytes .../ca.lproj/Localizable.strings | Bin 127650 -> 127796 bytes .../cs-CZ.lproj/Localizable.strings | Bin 124066 -> 124212 bytes .../cy_GB.lproj/Localizable.strings | Bin 120496 -> 120642 bytes .../da.lproj/Localizable.strings | Bin 121144 -> 121290 bytes .../de.lproj/Localizable.strings | Bin 131556 -> 131702 bytes .../el.lproj/Localizable.strings | Bin 131306 -> 131452 bytes .../en-GB.lproj/Localizable.strings | Bin 120324 -> 120470 bytes .../eo.lproj/Localizable.strings | Bin 120964 -> 121110 bytes .../es-419.lproj/Localizable.strings | Bin 124416 -> 124562 bytes .../es-AR.lproj/Localizable.strings | Bin 123402 -> 123548 bytes .../es-CL.lproj/Localizable.strings | Bin 125140 -> 125286 bytes .../es-CO.lproj/Localizable.strings | Bin 124782 -> 124928 bytes .../es-CR.lproj/Localizable.strings | Bin 124774 -> 124920 bytes .../es-DO.lproj/Localizable.strings | Bin 124782 -> 124928 bytes .../es-EC.lproj/Localizable.strings | Bin 130228 -> 130374 bytes .../es-GT.lproj/Localizable.strings | Bin 124776 -> 124922 bytes .../es-HN.lproj/Localizable.strings | Bin 124400 -> 124546 bytes .../es-MX.lproj/Localizable.strings | Bin 124964 -> 125110 bytes .../es-NI.lproj/Localizable.strings | Bin 124390 -> 124536 bytes .../es-PA.lproj/Localizable.strings | Bin 124390 -> 124536 bytes .../es-PE.lproj/Localizable.strings | Bin 124390 -> 124536 bytes .../es-PR.lproj/Localizable.strings | Bin 124390 -> 124536 bytes .../es-PY.lproj/Localizable.strings | Bin 124416 -> 124562 bytes .../es-SV.lproj/Localizable.strings | Bin 124774 -> 124920 bytes .../es-UY.lproj/Localizable.strings | Bin 124414 -> 124560 bytes .../es.lproj/Localizable.strings | Bin 129300 -> 129446 bytes .../et_EE.lproj/Localizable.strings | Bin 120776 -> 120922 bytes .../eu.lproj/Localizable.strings | Bin 127700 -> 127846 bytes .../fa.lproj/Localizable.strings | Bin 121078 -> 121224 bytes .../fi-FI.lproj/Localizable.strings | Bin 123312 -> 123458 bytes .../fo.lproj/Localizable.strings | Bin 120234 -> 120380 bytes .../fr.lproj/Localizable.strings | Bin 133868 -> 134014 bytes .../gd.lproj/Localizable.strings | Bin 121734 -> 121880 bytes .../gl.lproj/Localizable.strings | Bin 129212 -> 129358 bytes .../he.lproj/Localizable.strings | Bin 118350 -> 118496 bytes .../hi_IN.lproj/Localizable.strings | Bin 120208 -> 120354 bytes .../hr.lproj/Localizable.strings | Bin 125068 -> 125214 bytes .../hsb.lproj/Localizable.strings | Bin 120214 -> 120360 bytes .../hu.lproj/Localizable.strings | Bin 126638 -> 126784 bytes .../hy.lproj/Localizable.strings | Bin 120490 -> 120636 bytes .../ia.lproj/Localizable.strings | Bin 120978 -> 121124 bytes .../id.lproj/Localizable.strings | Bin 121126 -> 121272 bytes .../ig.lproj/Localizable.strings | Bin 120184 -> 120330 bytes .../is.lproj/Localizable.strings | Bin 122496 -> 122642 bytes .../it.lproj/Localizable.strings | Bin 128662 -> 128808 bytes .../ja-JP.lproj/Localizable.strings | Bin 102780 -> 102926 bytes .../ka-GE.lproj/Localizable.strings | Bin 122916 -> 123062 bytes .../ka.lproj/Localizable.strings | Bin 120212 -> 120358 bytes .../kab.lproj/Localizable.strings | Bin 120268 -> 120414 bytes .../km.lproj/Localizable.strings | Bin 120466 -> 120612 bytes .../kn.lproj/Localizable.strings | Bin 120692 -> 120838 bytes .../ko.lproj/Localizable.strings | Bin 100542 -> 100688 bytes .../la.lproj/Localizable.strings | Bin 120198 -> 120344 bytes .../lb.lproj/Localizable.strings | Bin 120616 -> 120762 bytes .../lo.lproj/Localizable.strings | Bin 118816 -> 118962 bytes .../lt_LT.lproj/Localizable.strings | Bin 122982 -> 123128 bytes .../lv.lproj/Localizable.strings | Bin 121328 -> 121474 bytes .../mk.lproj/Localizable.strings | Bin 121518 -> 121664 bytes .../mn.lproj/Localizable.strings | Bin 120986 -> 121132 bytes .../mr.lproj/Localizable.strings | Bin 120176 -> 120322 bytes .../ms_MY.lproj/Localizable.strings | Bin 120326 -> 120472 bytes .../my.lproj/Localizable.strings | Bin 120394 -> 120540 bytes .../nb-NO.lproj/Localizable.strings | Bin 121298 -> 121444 bytes .../ne.lproj/Localizable.strings | Bin 120228 -> 120374 bytes .../nl.lproj/Localizable.strings | Bin 125870 -> 126016 bytes .../nn_NO.lproj/Localizable.strings | Bin 120346 -> 120492 bytes .../oc.lproj/Localizable.strings | Bin 121318 -> 121464 bytes .../pl.lproj/Localizable.strings | Bin 125116 -> 125262 bytes .../ps.lproj/Localizable.strings | Bin 120240 -> 120386 bytes .../pt-BR.lproj/Localizable.strings | Bin 126672 -> 126818 bytes .../pt-PT.lproj/Localizable.strings | Bin 124166 -> 124312 bytes .../ro.lproj/Localizable.strings | Bin 123208 -> 123354 bytes .../ru.lproj/Localizable.strings | Bin 127158 -> 127304 bytes .../sc.lproj/Localizable.strings | Bin 129378 -> 129524 bytes .../si.lproj/Localizable.strings | Bin 121134 -> 121280 bytes .../sk-SK.lproj/Localizable.strings | Bin 124520 -> 124666 bytes .../sl.lproj/Localizable.strings | Bin 126126 -> 126272 bytes .../sq.lproj/Localizable.strings | Bin 122010 -> 122156 bytes .../sr.lproj/Localizable.strings | Bin 124008 -> 124154 bytes .../sr@latin.lproj/Localizable.strings | Bin 120512 -> 120658 bytes .../sv.lproj/Localizable.strings | Bin 122652 -> 122798 bytes .../sw.lproj/Localizable.strings | Bin 120208 -> 120354 bytes .../ta.lproj/Localizable.strings | Bin 120542 -> 120688 bytes .../th_TH.lproj/Localizable.strings | Bin 120094 -> 120240 bytes .../tk.lproj/Localizable.strings | Bin 120908 -> 121054 bytes .../tr.lproj/Localizable.strings | Bin 124858 -> 125004 bytes .../ug.lproj/Localizable.strings | Bin 120376 -> 120522 bytes .../uk.lproj/Localizable.strings | Bin 122534 -> 122680 bytes .../ur_PK.lproj/Localizable.strings | Bin 120256 -> 120402 bytes .../uz.lproj/Localizable.strings | Bin 120208 -> 120354 bytes .../vi.lproj/Localizable.strings | Bin 121086 -> 121232 bytes .../zh-Hans.lproj/Localizable.strings | Bin 92670 -> 92816 bytes .../zh-Hant-TW.lproj/Localizable.strings | Bin 98840 -> 98986 bytes .../zh_HK.lproj/Localizable.strings | Bin 89810 -> 89956 bytes .../zu_ZA.lproj/Localizable.strings | Bin 120208 -> 120354 bytes 105 files changed, 0 insertions(+), 0 deletions(-) diff --git a/iOSClient/Supporting Files/af.lproj/Localizable.strings b/iOSClient/Supporting Files/af.lproj/Localizable.strings index 3397f6ebc4f1b5c8f71a3c901644f6242370bfbc..b7a5be2b14357f6d0b7c1ede15d64a3fdee82ac5 100644 GIT binary patch delta 115 zcmbQTfqmIV_6^6vr=Ob5$fFw1kj9Y7ki(G55YJG+Pz0n47!rYWB0~vKJf9&CD6TZw q{;)V_IZ!MUD5^7kwke~ek^+#E$Dn{ilLCX9Li2&}?FYgcLmB`Y2pz!y delta 22 ecmZ3sk$uVr_6^6vCu>DUHE)X8zA1w7OFaO2feNVr diff --git a/iOSClient/Supporting Files/an.lproj/Localizable.strings b/iOSClient/Supporting Files/an.lproj/Localizable.strings index 4dba1b320f15f6d5d2b03942402737f7914cd7d0..473c0c90b1468de82b426b13c78d9871edf5fb67 100644 GIT binary patch delta 113 zcmZ3mntjt6_6;uKlLhoxChxK4Qch#YWXNGiWr$}eU?>981q_KmI+39SD4x%d2NYMD rUO0zQd~#m{2cypP_r{EpN(w-^JO%|EIusbx6q@bAx7&p?Ce;A|!{i*I delta 23 fcmdnAhJC?m_6;uK(-TfIvNYcc-+n8cF`^Ctea;Fy diff --git a/iOSClient/Supporting Files/ar.lproj/Localizable.strings b/iOSClient/Supporting Files/ar.lproj/Localizable.strings index acca7429d0e7b56be9cc16908b0011319f5ceff1..fa7fbf11f25d740713bf954a1080f07c9fc94403 100644 GIT binary patch delta 141 zcmeBL%06cq`-ZO2=`&_9@<_%rq%mYNMs;~?D diff --git a/iOSClient/Supporting Files/ast.lproj/Localizable.strings b/iOSClient/Supporting Files/ast.lproj/Localizable.strings index 0ef22878bcd73b67013c8922ae743b77413a0092..185354a16122662fcb5b19bd5daf2ccef61da9a4 100644 GIT binary patch delta 132 zcmdn8n*G=s_6;84lTTRlDW@@HGUPC%GQ=|!Fcbml0)|8&oybrE6whbK1Bxq6pE!q6 zd~)4+4jUZ?1%^_fk{qB^B0~z02h*+qRGtUqV>d*BK}}&YM?^yNqVVmD!Wo6?0Qm|a A-T(jq delta 22 ecmX@MhJDLw_6;84lNUrpHJe0iH;G^rssjLX&ItDa diff --git a/iOSClient/Supporting Files/az.lproj/Localizable.strings b/iOSClient/Supporting Files/az.lproj/Localizable.strings index 77d3345c378696ad5f8636383dd09ef230cb7210..1a57931cbb722587caef495d5b0dcf38d2ca372b 100644 GIT binary patch delta 134 zcmaF1mi@;%_6_U8r|+7@$fFw1kj9Y7ki(G55YJG+Pz0n47!rYWB0~vKJf9&CD6TYl z{~__oJQp}@bQlyEN`WeJfHH{;DL@`fw*pXg9*~dS3^u3WgHsJ# BAPxWk delta 22 ecmZ3pj(yfz_6-ZdC;y0uYVL{H-V?#Npbh|j&I+{v diff --git a/iOSClient/Supporting Files/br.lproj/Localizable.strings b/iOSClient/Supporting Files/br.lproj/Localizable.strings index 0919d3744bc8bfef7b82ff135be554179808832c..9b1a22c69c7bbca50be3ab5b85b1092db9a82c33 100644 GIT binary patch delta 138 zcmbPomVMbd_6?gNCoj-v(Jg04WXNPFVTfl)1JXGRsX$f%LlKZJ0Ll~raS2d7pCJz@ zt~A|uEu;A4b=Np-bQlyEN`XppfKrJJDL@`fy8=*o9*~dS5CsM`h2}Mp+t)-gzUTn} D(K#a9 delta 18 acmZ2>j(y5m_6?gNn_Z%|yF@WQ>Hz>$0|_6_I4r>~mD$fFw1kj9Y7ki(G55YJG+Pz0n47!rYWB0~vKJf9&CD6Ta5 t<00|Mbv7J~I@1+R86}kzfKqu33OF<|5eh&pc|bmPgA^Fl6efGcBs4#X-u@(-ao;om DLd7Hc delta 22 ecmdn;jD68l_6=RplOM%IHJ8O~FN|AqqhGJRl#%D4>o^ph}RqnnLr6$n7g4 I8Gm&F0JUWy)Bpeg delta 18 acmdmTiha>Z_6_SIn;oLIJ47*l=>h;%7YLjH diff --git a/iOSClient/Supporting Files/cy_GB.lproj/Localizable.strings b/iOSClient/Supporting Files/cy_GB.lproj/Localizable.strings index 9185b34ea6bf4b2e00f723072daa51e2cf7b36b9..c558df118b505372857fe26c3da257204c4b3b94 100644 GIT binary patch delta 116 zcmdn6mi^E=_6-NZr#rMVvM81_Br;?&lrY3Iqygz1hEyP{fT0LT7XW377!s#n6lD~h zoOOh6a)Av8qt5jECXA9w3P81a3<{_!fu>|K}7xa0`k6 diff --git a/iOSClient/Supporting Files/de.lproj/Localizable.strings b/iOSClient/Supporting Files/de.lproj/Localizable.strings index fd350f43b5f5b33f1fb899577a1d0b32038c3d9a..98bc3cf0740b2a2dda07d7bc071e322beaedaea0 100644 GIT binary patch delta 132 zcmaFT%<-*-W5c=F$r=uP!f6bd3^@#`4Dk#F3`Ib?fFW^mp^xzN1G>e&AQu1t delta 18 Zcmey?!ttb;W5c=F=7hNI32}^KO8{2x2tEJ+ diff --git a/iOSClient/Supporting Files/el.lproj/Localizable.strings b/iOSClient/Supporting Files/el.lproj/Localizable.strings index dc0eb70d13cc4e85373032c1d85f772c00cc19ec..a02aab717bbb112a1ed63e9b489ba882103cde88 100644 GIT binary patch delta 135 zcmaFW$nmF%V}nTig?0YedxE?`Im(uqL1Oon`hJfOJJ z^uS|`;?whz898ip7!(*vfogJqa)}HnKpsrL0#JP(kdNII1qL;RX1@6CeDRET76Jg} Cf*-E{ delta 18 acmey<#PO<;V}nS1^RoEu%i=(qDvv<{hXw@(HHBuM@a;a~j63Q8^Bx?d delta 18 acmbQXmc3;S`-Y(K<|pCXpM*1RssjK~Q3$*M diff --git a/iOSClient/Supporting Files/eo.lproj/Localizable.strings b/iOSClient/Supporting Files/eo.lproj/Localizable.strings index 2bb8b29c42258a97678067a6df3340eaed7be329..d4de65fbc8ab76cd7e30287b353f47039ece5df2 100644 GIT binary patch delta 113 zcmZqK$Ubco`v#GSY3+8R8iV7>a;&0Yf5?PGl$nisv)r0mYT3 q|F35hpX?*W!KgDm+l*0CNdYLA$Dn{ihXR9|LNi~)cD@M4vIYQcUK=9- delta 18 acmbQXiM?eb`v#GS=4BDvmqjoZGyniguLsWn diff --git a/iOSClient/Supporting Files/es-419.lproj/Localizable.strings b/iOSClient/Supporting Files/es-419.lproj/Localizable.strings index bdb1281312c138bc707ed223f2a62c8980d9fd9d..a032cafb4e8cad9878d87476d4b014cadcbc08e5 100644 GIT binary patch delta 146 zcmZoT!#?RO`-YCl=?PO9S*EXB$;crY&ydED$&ka4$`H>`z)%FF3m6iCbmDY-MMlw} z0I*adLorZ7fuS5ImB~=TpaW!=0u|;k delta 27 jcmbPqmc8K&`-YCl=^Jh`vP^yw71mr5wY?;YQLYC7w37@N diff --git a/iOSClient/Supporting Files/es-AR.lproj/Localizable.strings b/iOSClient/Supporting Files/es-AR.lproj/Localizable.strings index 7cb58d9f4221b602f613fce266318feb45ec10ef..dcfdab7326333780aec96305f4a2766dc4d1432b 100644 GIT binary patch delta 136 zcmeA=!anCH`-X%_RV9XahH{2PhD?SMAS(?>=P;xKSp^J5K)L`ZQ^b%seZ3r`==7{k zM!xC$ycs!cbQlyEN`aC&4EaC>DL@`fqXN)?JRl!MJJ9G%ph}Rqn!;p-sD$QSk=u7g IG6r-20PV6N8~^|S delta 22 ecmbPpl)dW+`-X(b$vdK=nth_S`$RDYbN~Q#aS4S0 diff --git a/iOSClient/Supporting Files/es-CL.lproj/Localizable.strings b/iOSClient/Supporting Files/es-CL.lproj/Localizable.strings index 66577b1896fd9c42ef85f4544405dcad60b479af..96a984ba366ced710cb3bc4799c4283451e8874d 100644 GIT binary patch delta 124 zcmca|k^R{v_6;whCOnapF)C7#BR$&ka4$`H>`z)%FF3m6iCbmDYHWk%7-ZuVj} zIt&U7r9j~vhJ2t@3XliWq5#yI2jrt@WGDfO=7Yu66eh2TPH1+D-tH95IH?x^G~geG delta 27 jcmaEMiT%n&_6;whrZ?PSWSQ&|6V`ksdi#}V#!0;Z$w3X5 diff --git a/iOSClient/Supporting Files/es-CO.lproj/Localizable.strings b/iOSClient/Supporting Files/es-CO.lproj/Localizable.strings index 7811fb79b0160d38f05b453eada7c8cf3630c6d2..e6e0de6c49429a7a8342e6a19dd4fd8f20669259 100644 GIT binary patch delta 118 zcmaENj=kXm`-Y~-$shDtrpv5m&|DL_y(W_JQ!fCV3m%sM delta 18 ZcmZp;!2a$W`-Y~-W|64vB2kQQdI3^m2sQu! diff --git a/iOSClient/Supporting Files/es-CR.lproj/Localizable.strings b/iOSClient/Supporting Files/es-CR.lproj/Localizable.strings index 1e791e1699b80a49b4c346c7c6b5c94390dea2bc..548fd2ea3757478eb4a97c3a08e0af517eaef5f4 100644 GIT binary patch delta 126 zcmaEMj{V1Z_6<#ulRxOQ$d)rCGGsE8FvK&Y0qGouR3NK>p$JG9FeFZP^c0?csE<)( z@;h4&8yyA(hEkw#4nsarQwop=)1m;>ng`^=H3AJt1R9zNR0$GSQ)sS<++GvO_^KBG D=prFd delta 18 acmexyp8eT5_6<#u%_33TMWPs=^a21{IS8Eq diff --git a/iOSClient/Supporting Files/es-DO.lproj/Localizable.strings b/iOSClient/Supporting Files/es-DO.lproj/Localizable.strings index 764ec7db29322ba5e44e512f73bc204edf9af405..50aa35b8c46220c7a9a8f68279408574480033af 100644 GIT binary patch delta 126 zcmaENj=kXm`-Y~-$shDtWXl;688R747~&byfOHN+Dv(vcPz0n47!oHtdJ0b$S;r_c z`JF9?jShnXLn%-=han%RDFw)bX;A=b%>(k`8i58R0u9XsssxFvDKytaZm)@C{L~8o Dhmas! delta 18 ZcmZp;!2a$W`-Y~-W|64vB2kQQdI3^m2sQu! diff --git a/iOSClient/Supporting Files/es-EC.lproj/Localizable.strings b/iOSClient/Supporting Files/es-EC.lproj/Localizable.strings index a92fc7177ed380a4f0180e363fa8e57cf29ad78d..1f2ba0a8a773442411642457cbaf7ce5c43b9566 100644 GIT binary patch delta 160 zcmdn;ll|B)_6y;Sd8Oj+F88R74fUGniox_j{WEC(J0qFvuOc4;50LAke@_^z> z3U}h=+&Bz1tQB3BA8?C^grqDbu LcKf_oMzQ$-lqn+G delta 18 acmX^1i+#&a_6Igpo diff --git a/iOSClient/Supporting Files/es-GT.lproj/Localizable.strings b/iOSClient/Supporting Files/es-GT.lproj/Localizable.strings index d1fbd3312f410cf2e94ca64785c66158bb6761fc..8d11bc6664f1ee73301d6ac536ed0c100d48c6f7 100644 GIT binary patch delta 126 zcmaEHj{Vnp_6<#ulRxOQ$d)rCGGsE8FvK&Y0qGouR3NK>p$JG9FeFZP^c0?csE<)( z@;h4&8yyA(hEkw#4nsarQwop=)1m;>ng`^=H3AJt1R9zNR0$GSQ)sS<++GvO_@);C D>KGwb delta 18 acmex$p8dr+_6<#u%_33TMWPs=^#TA|e+Z)h diff --git a/iOSClient/Supporting Files/es-HN.lproj/Localizable.strings b/iOSClient/Supporting Files/es-HN.lproj/Localizable.strings index 578ed4eb0fc7f804952a502d656d18f74e4670af..f94012b4fd71b9be724a4c74ade6909ebf4b5447 100644 GIT binary patch delta 123 zcmexxn!V{P`-Y~-$shDtrq5Z)$RQffkj9Y7ki(G55YJG+Pz0n47!oHtdJ0c>P-JAA z{J>VsMu$Oxp%f^b!;sIA$dCf$!L%pqWNHPHHGGy$n7HifOMHvGo zU%W1Aqr;%UPzsdDVaNwcrT}>`O$tEGc|bmjR)!LwXg*k6O<{6HR6?^*)OMjLMxj0c D755q#0mNU diff --git a/iOSClient/Supporting Files/es-NI.lproj/Localizable.strings b/iOSClient/Supporting Files/es-NI.lproj/Localizable.strings index 4cd45b799561d591805b7ca14602e46aed2523ca..a25a1e3b6d84dbf9acf34ea5a86ee29d5c67acb0 100644 GIT binary patch delta 146 zcmaEMn*GNa_6>EBhDr?a4CM@o44DiiKvo)%&S6LevI-cAfOG*+rU-~jfa3WKc|dWc z>Gr*h;w~^PIt&U7r9fplKEBldnZZHD^U_&x&H?>j40XZVH6} diff --git a/iOSClient/Supporting Files/es-PA.lproj/Localizable.strings b/iOSClient/Supporting Files/es-PA.lproj/Localizable.strings index 4cd45b799561d591805b7ca14602e46aed2523ca..a25a1e3b6d84dbf9acf34ea5a86ee29d5c67acb0 100644 GIT binary patch delta 146 zcmaEMn*GNa_6>EBhDr?a4CM@o44DiiKvo)%&S6LevI-cAfOG*+rU-~jfa3WKc|dWc z>Gr*h;w~^PIt&U7r9fplKEBldnZZHD^U_&x&H?>j40XZVH6} diff --git a/iOSClient/Supporting Files/es-PE.lproj/Localizable.strings b/iOSClient/Supporting Files/es-PE.lproj/Localizable.strings index 4cd45b799561d591805b7ca14602e46aed2523ca..a25a1e3b6d84dbf9acf34ea5a86ee29d5c67acb0 100644 GIT binary patch delta 146 zcmaEMn*GNa_6>EBhDr?a4CM@o44DiiKvo)%&S6LevI-cAfOG*+rU-~jfa3WKc|dWc z>Gr*h;w~^PIt&U7r9fplKEBldnZZHD^U_&x&H?>j40XZVH6} diff --git a/iOSClient/Supporting Files/es-PR.lproj/Localizable.strings b/iOSClient/Supporting Files/es-PR.lproj/Localizable.strings index 4cd45b799561d591805b7ca14602e46aed2523ca..a25a1e3b6d84dbf9acf34ea5a86ee29d5c67acb0 100644 GIT binary patch delta 146 zcmaEMn*GNa_6>EBhDr?a4CM@o44DiiKvo)%&S6LevI-cAfOG*+rU-~jfa3WKc|dWc z>Gr*h;w~^PIt&U7r9fplKEBldnZZHD^U_&x&H?>j40XZVH6} diff --git a/iOSClient/Supporting Files/es-PY.lproj/Localizable.strings b/iOSClient/Supporting Files/es-PY.lproj/Localizable.strings index 093c966f84f558f77804ad4f21c838b5137473df..44a53bab651c63520c11677977c95e8e39006b2b 100644 GIT binary patch delta 125 zcmZoT!#?RO`-T~j(^sryj40LPYNRd diff --git a/iOSClient/Supporting Files/es-SV.lproj/Localizable.strings b/iOSClient/Supporting Files/es-SV.lproj/Localizable.strings index 1e791e1699b80a49b4c346c7c6b5c94390dea2bc..548fd2ea3757478eb4a97c3a08e0af517eaef5f4 100644 GIT binary patch delta 126 zcmaEMj{V1Z_6<#ulRxOQ$d)rCGGsE8FvK&Y0qGouR3NK>p$JG9FeFZP^c0?csE<)( z@;h4&8yyA(hEkw#4nsarQwop=)1m;>ng`^=H3AJt1R9zNR0$GSQ)sS<++GvO_^KBG D=prFd delta 18 acmexyp8eT5_6<#u%_33TMWPs=^a21{IS8Eq diff --git a/iOSClient/Supporting Files/es-UY.lproj/Localizable.strings b/iOSClient/Supporting Files/es-UY.lproj/Localizable.strings index 5e0c37df5cbfa58f646ad2040241d8123eddc3e3..5010c4ee60d3673d984243be0e410155226184d8 100644 GIT binary patch delta 146 zcmex&ntj4q_6>EBhDr?a4CM@o44DiiKvo)%&S6LevI-cAfOG*+rU-~jfa3WKc|dWc z=?m8|io3wH=rAZSlmeCI0HqTdQh+>|5eh&pc|bmPgA^Fl6ein6B{biN+EBldnZZHD^U_&x&GH>j40QiwaHv diff --git a/iOSClient/Supporting Files/es.lproj/Localizable.strings b/iOSClient/Supporting Files/es.lproj/Localizable.strings index 3075ad8e40a2ae9ecebb3e5e79e02f868a3926ca..93faf081e3eb3d1d2c7dc45ed16c228a0bd5bfed 100644 GIT binary patch delta 141 zcmbR8iGA5;_6^^nC-;@JO?TMA$R-)jkj9Y7ki(G55YJG+Pz0n47!rYW;`BfbM$w=E zuv8*LF;GH*p&Tfc$xy0i%AH^u3j!d9Rkhq#c^M~l| KAEFsm<^ljwRwA(g delta 22 ecmZ4XnSIJ9_6^^nCp*MOH9v~k{wRj=$Q%HQBn!|0 diff --git a/iOSClient/Supporting Files/et_EE.lproj/Localizable.strings b/iOSClient/Supporting Files/et_EE.lproj/Localizable.strings index 858c078437fd55b5e79d959c3925e4466e59c115..b1301cca7d1dfc108df6ea9f2de20d9be057af2a 100644 GIT binary patch delta 119 zcmX@Hp8eJa_6>3o)4OIf@~Fl$q%mYN0rdchB_DVI delta 22 ecmcb$f&IjK_6>3olglEbnzON=_6={Mr^{?%R delta 18 acmaF%jQz?}_6={Mo9kk>*Tpctm<9l3+X?sp diff --git a/iOSClient/Supporting Files/fa.lproj/Localizable.strings b/iOSClient/Supporting Files/fa.lproj/Localizable.strings index a3012c776d150ee352542c6e1d91afa0994c3dbc..899c553ace9992fd6a1fae07e6faebdabbf19cac 100644 GIT binary patch delta 130 zcmeyik-cLx`v#YY$rtokrk|U`$e|j~kj9Y7ki(G55YJG+Pz0n47!rYWB0~vKJf9&C yD6TYlwT--u4ub+iDNr^CD4NKS0_4GTDgagH0r}YVD=?@jG}}dNw~Juh(EtF>xgV?m delta 18 acmeC!%>Hd7`v#YY=4%n#uSGC!Y5)LMb_oUm diff --git a/iOSClient/Supporting Files/fi-FI.lproj/Localizable.strings b/iOSClient/Supporting Files/fi-FI.lproj/Localizable.strings index f81abaf16649694b3ed7323a4597d45d5b001dae..3f811371efbb24aea339247be7f96e0edd9d1ff5 100644 GIT binary patch delta 106 zcmdmRnElWZ_6;_XlQnGl#M2lu8FCm>8R8iV7>a;&0Yf5?PMq#2%P2nGtAmk;vm7Xr p$xyoO#n?-Ini)5_o006fK8L0pO delta 18 acmX?fgnh$d_6;_X&F3PwpNnKH=>Py%ZV1u< diff --git a/iOSClient/Supporting Files/fo.lproj/Localizable.strings b/iOSClient/Supporting Files/fo.lproj/Localizable.strings index 5eb6ea0447ae41e2c7256e1e01a3acc051965951..b6a7ccf4c63568b0450cf3c84d1a18b774d24c29 100644 GIT binary patch delta 111 zcmZ3rntjh2_6;84s!9y;4CM@o44DiiKvo)%&S6LevI-cAfOG*+ridYNx}Yed=;UA4 sVvIV|e;YGODk%WfeCo98FCm>8R8iV7>a;&0Yf5?PGl$nisv)r0mYRV6c}uQ zScxG3tTK_I7^qHxp&Y0x6R1uH$Swuy%K@rSWJm$>U}h=+<@11i>?SKPs3|Blb0%!( JOkjMx3IGggAYT9g delta 18 acmex2jpNN!jtzVX%?lE?FGyg#w+aAO?g<9~ diff --git a/iOSClient/Supporting Files/gd.lproj/Localizable.strings b/iOSClient/Supporting Files/gd.lproj/Localizable.strings index f40aae1ca0154614f773e4f90c6b0b274f964a69..d830947b4651552306f0224591e19774493f7f48 100644 GIT binary patch delta 125 zcmZqM&OT!Y`-T${hDr?a4CM@o44DiiKvo)%&S6LevI-cAfOG*+rU-~jfa3WKc|dWc x$!`yfPtLRDVAWwzU?`nz$RVnv0F=!G^04bsU{F(-+!2}3tQ5IjDUvaz2>{2d9?bv% delta 22 ecmbQSgS~A#`-T${lNF+(nzux5-xA4~(gXl^8ww5p diff --git a/iOSClient/Supporting Files/gl.lproj/Localizable.strings b/iOSClient/Supporting Files/gl.lproj/Localizable.strings index 7797d0ffc32590ab445468f44b0e1afd08575a3a..9763a3d9f85d11b17d859471f5ed8878b7c6b727 100644 GIT binary patch delta 144 zcmdnp$JG90A-385~tg1Fp35R zfTa={ih&Xe3@}YPKz1omVGct+P;m;72Qx$gXjmSQk75+inoOWdkhq#c^O>0KXJQyX G%mx5W^CJEL delta 23 fcmX^2iG9yU_6?U}rVG4bWNFTb-JTK4_-r-+kSGf{ diff --git a/iOSClient/Supporting Files/he.lproj/Localizable.strings b/iOSClient/Supporting Files/he.lproj/Localizable.strings index 57d7d5ed1e899a4f7e17a9479cc03e2c3bbfffa7..0aa268e6df0abd3727561e21d7429e271c89e129 100644 GIT binary patch delta 146 zcmX>%hyB4^_6=`B4V4(;8Oj+F88R74fUGniox_j{WEC(J0qFvuOc4;50LAke@_^z> z(;3Sc#a&=pbQlyEN`cC9fYON!DL@{~2nC>)JRl#tK?)3N3X|7_B{aK*ZFdV}981q_KmI+39SD4x%d2NYMD qJpZux=P;xKSp^J5K)L`ZQ^b%sJyD5KG$;Tp zmB>&Glu&?c(gCtdfeLdN@_~v|fIOHX3P8j1fP56AfYxLJRf5FT6q^4981q_KmI+39SD4x%d2NYMD zEPqJcr5q@h2^7^~P+%wps>%V%CNiV|c`y?cfbw}jK6Y~y7}OM+9m2OegfoWK0RYlN B9~J-r delta 22 ecmZ3nhJD&<_6=^~ljlW5H5)~2H;Q2VRto@dcL|mN diff --git a/iOSClient/Supporting Files/hu.lproj/Localizable.strings b/iOSClient/Supporting Files/hu.lproj/Localizable.strings index bfea7e6e6cb46f415a85cc7771ffefd03b3fb05e..25abd56bce006815a79fbbb1b5461c047aeeeafc 100644 GIT binary patch delta 250 zcmZ2?m;Jy!_6_TzRFxRw8Oj+F88R74fUGniox_j{WEC(J0qFvuOc6uk^nPVV(VzgZ zR3bw$P(lH&Ne9R-1uD#8$OkG;0rFsmC;$!11M*Rf0$P&^R0$GSQ<$6+ozTn?y`3YP zk;y;am7xkKS^|_UV|d7r1caGDKFEwTpjZ(@E>JWX$p6fc4Ya8Qto9*LJOj#01G*~* dD4GbwX$&uc`YM4cUxMuqWX#!~xr))%1pp`dIQ;+s delta 106 zcmX?bkA2-;_6_TzCbPsuHP4FPJ}a7$$zL;sA%h{4p_oB|A(tVMp%O?JF{Cn-0dXQj u4p=lFETS;^VW+sf0#G!GA)ld?p#&&b0@Rxdqziy_K9HBc{r4(HR~G<%Qygpn diff --git a/iOSClient/Supporting Files/hy.lproj/Localizable.strings b/iOSClient/Supporting Files/hy.lproj/Localizable.strings index 0eda4a71e0c343c290df48c62968899a8b3356eb..9f7c17c0ed91c9442824e4395c57f4cdc01708f9 100644 GIT binary patch delta 141 zcmZ3rmVM7U_6>W&4V4(;8Oj+F88R74fUGniox_j{WEC(J0qFvuOc4;50LAke@_^z> zllLDIpIl?ZVWY#Kz)%WQkpq-TWJm$>V7e86s`G$+>}Du1s3}aYiAZP`i`Xs}!8oN3 E0Jnr8+W-In delta 22 ecmdn9j(ycy_6>W&CyPWzHLr-+z9NEgN*w@su?ji> diff --git a/iOSClient/Supporting Files/ia.lproj/Localizable.strings b/iOSClient/Supporting Files/ia.lproj/Localizable.strings index f1a515512f44c05aa4d87f7518e66f684078b356..ecfcdc40cf51b3f406052c15cfdb4f9ea9755019 100644 GIT binary patch delta 115 zcmbQVk$uS~_6;w>Coj-rQ7mUjWXNPFVTfl)1JXGRsX$f%LlKZJ0Lm0GBu+ml#wa>j y<0#+c7%2`$o$2{zjFL(UK(%=c3aBc9rereYgT>VpCa;J{Xm*O&?i9fo&;S4~l^!<$ delta 22 ecmZ3oiG9*W_6;w>Cp$z&HD8I?ekFo2paB4U&kBG5 diff --git a/iOSClient/Supporting Files/id.lproj/Localizable.strings b/iOSClient/Supporting Files/id.lproj/Localizable.strings index 69f770d8156d6f845052013d1adfc1cca4400f80..3c4b65efb2ed6c9245bc8041e304b03f8f014af7 100644 GIT binary patch delta 108 zcmZ3siG9ar_6<4_lQ-zGOg}S+kwY?`A&nuEA%`KAA)cXtp$JG9FeC!$#OeIvjG~ig t*oZOeO#f@fD5<0XRF}t~fU1h21Spyh7FSc4{3aryxh-OQTLj~R1^{~(9oPT> delta 27 jcmdn7nSI$N_6<4_(=VK1WSQI%8P+Tjxm_ZXaX|wBsU8bO diff --git a/iOSClient/Supporting Files/ig.lproj/Localizable.strings b/iOSClient/Supporting Files/ig.lproj/Localizable.strings index bbef6e7470b9714125718f2d05591c886c7e4289..319bf275464009118ff650fc0db0b6ff7ea8f8c6 100644 GIT binary patch delta 121 zcmeydioI(M`v#Zr$pU&TllNG2DW@@HGUPC%GQ=|!Fcbml0)|8&oybrE6whbK1Bxq6 w51hj&&RY%?%mfPSFeosTPEXWk6jf3H3giK~*mWu}s3|ntg>SbDXSAvV09?QvoB#j- delta 18 acmeBL!~SCx`v#Zr=4;{GuZ1(3)Bylg%m{e^ diff --git a/iOSClient/Supporting Files/is.lproj/Localizable.strings b/iOSClient/Supporting Files/is.lproj/Localizable.strings index aa5210cd8e3cbe34a7dc0c44e29285d06a64c59f..e27d12ab81d64d7f7727aeaccda4eae0bcd5b150 100644 GIT binary patch delta 133 zcmZqJ%RXrz`-UA6(=YTevP{=m#K<8U&ydED$&ka4$`H>`z)%FF3m6h7FZ2+e{!fOH zZThuVM!v~5%^Ws532AYz{Py!Uq2aBsIOsa_*9rjEp(3UL delta 22 ecmbQVkG)|p`-UA6lLexpnwLawUlPff*9ri1rU}~s diff --git a/iOSClient/Supporting Files/it.lproj/Localizable.strings b/iOSClient/Supporting Files/it.lproj/Localizable.strings index ebe6345756f42f91a54fde8c15c3c4f2fb595f24..b31fdb1c5213ee580625db448674d974d916d5db 100644 GIT binary patch delta 153 zcmbRCmVL!L_6-g((<8Pq^3=yOq%mYNu3Wgq diff --git a/iOSClient/Supporting Files/ja-JP.lproj/Localizable.strings b/iOSClient/Supporting Files/ja-JP.lproj/Localizable.strings index 794bc1a7a6d63d6b86dbb5dc1c368b1f29f428b1..83843699e97a6dbb7ff47718a2d1db8d6e090307 100644 GIT binary patch delta 164 zcmeyfh^=o4+lD&tdL@Q=P;xKSp^J5K)L`ZQv}2%K=FKrJfOG| zg93vs5GyeRfK?_k6a&>Mz|GJBvP*&ba)9a+8B%~en3)PdGxC6Z6q9-3Mk_F=DNI)I PNoc;|z5Rwa;}TZ@ogO3R delta 18 ZcmeBM!uDqo+lD&tW&xk=0zQoYTmelL2aEs! diff --git a/iOSClient/Supporting Files/ka-GE.lproj/Localizable.strings b/iOSClient/Supporting Files/ka-GE.lproj/Localizable.strings index 1eeae4fa54ea68143d67f0ecc7214ea85e262e9e..b5923c688195ca7d034e990bc7c12a3b7f9e8bc1 100644 GIT binary patch delta 142 zcmZ2-fPLFR_6-h^hDr?a4CM@o44DiiKvo)%&S6LevI-cAfOG*+rU-~jfa3WKc|dWc z>5XlS;?vi8F>=`GFeosT0@dUIgFlLhoxChxK4Qch#YWXNGiWr$}eU?>981q_KmI+39SD4x%d2NYMD yeDHwygFlb1zAHCsh&w~Am?sRICbx(QJL diff --git a/iOSClient/Supporting Files/km.lproj/Localizable.strings b/iOSClient/Supporting Files/km.lproj/Localizable.strings index 75fa223795600d6471549ab195916fef3e0bc9a7..f0bab550db6bb392b3abd3b354aaf2eae095039a 100644 GIT binary patch delta 135 zcmbQVmVL=O_6-f;ib@Re4CM@o44DiiKvo)%&S6LevI-cAfOG*v;^anm;pqoN8QG?H z)iUx;_Os!z(P2`eF{MRc|bl~H_((spvjp)l^}67g~<*P3C*{{ Lx8Dk9+))Pr^CKbj delta 22 ecmZ3oj(yTv_6-f;lW#;sHRnWZ&xv5%Q3n8cwhBD} diff --git a/iOSClient/Supporting Files/kn.lproj/Localizable.strings b/iOSClient/Supporting Files/kn.lproj/Localizable.strings index e19e3ddf3bb0606d0bf23a403df919549d4ccda2..7be75526f18d74e5fa40a9a1d78785e3f83cc2b7 100644 GIT binary patch delta 138 zcmeyej=gOI`-UswhDr?a4CM@o44DiiKvo)%&S6LevI-cAfOG*+rU-~jfa3WKc|dWc z>4x(d#V7aKaM z3U}h=+<@11itR}MpCDarq R&+$rV4)NL^;>DO{2LPe7BRc>9 delta 22 ecmcaGiEZCRwhg~LC!2UjH9zy({>+Op%MJj3I0|3@ diff --git a/iOSClient/Supporting Files/la.lproj/Localizable.strings b/iOSClient/Supporting Files/la.lproj/Localizable.strings index 7e1c21e48cf1ff605160a8b900006ba4d80a5262..9034994d8349f7ee18cea22d9174a8db010a5b70 100644 GIT binary patch delta 131 zcmZo$%|2rd`v#Zr$pU&TllNG2DW@@HGUPC%GQ=|!Fcbml0)|8&oybrE6whbK1Bxq6 z=07Apxvzo4Mu$Oxp%kbh2Pl)skOJhvbSnT==K=ZH%}`)aQ)spe-)tWKk?g?0YedxE&$3DF(giR6k-%* z44C|1Qq)F=L4lzZD3QaE50p#+@?e@2fSU7wd=#xfV>5v&LE>r(lNW?1G+Tvlw+d%` GRsjI>y&(nw delta 22 ecmdnAkbS`d_6-lhCR;>AHJ=IJekPppSp@)mHVWhb diff --git a/iOSClient/Supporting Files/lt_LT.lproj/Localizable.strings b/iOSClient/Supporting Files/lt_LT.lproj/Localizable.strings index b9fea53c947eae0f17c3aee6a38152436a0efb5f..50a1bc547fa951b844edf406e2520b2a0afea184 100644 GIT binary patch delta 111 zcmaEMfc?io_6KPe7Io$0=|jFL(UK&d~@~Fl$q%mYN~HM>M@cZp*B(*OW?{0cJw diff --git a/iOSClient/Supporting Files/mn.lproj/Localizable.strings b/iOSClient/Supporting Files/mn.lproj/Localizable.strings index bc9e93ba5669055479502914b31879e558e2f764..c8309250e92229635bcddb660b72392fdc82e6ac 100644 GIT binary patch delta 121 zcmbQWk$uf3_6>3olPhfal+ze88FCm>8R8iV7>a;&0Yf5?PGl$nisv)r0mYRjFFY*H wUk((@1d8e~C@_>V6iha}E3Bjd6v+efvFlV|P*a$EFCwA2B4T?*1fx;|0DJ)-8~^|S delta 22 ecmZ3piG9{a_6>3olglEbnz8FhuC6yF_a(N62ICLm5s3|ntgm1SAXEdn;07noVwEzGB delta 18 acmZo#!~S6v`v#}*<}2abuY@z|)d2ughzMN( diff --git a/iOSClient/Supporting Files/ms_MY.lproj/Localizable.strings b/iOSClient/Supporting Files/ms_MY.lproj/Localizable.strings index 70ced56a97185fef6fa7378fa0ec3aeec33b7241..8189e8c9c82be82d0b6abc08759e1d264cae63c9 100644 GIT binary patch delta 118 zcmZo$!#-mz`-Y5gLnVfIhH{2PhD?SMAS(?>=P;xKSp^J5K)L`ZQv}2%K=FKrJfOJJ qWI-EwMxE*YCXA9w3P9mJ1_d076&TbMCTm0_G#?7zekh#Lr49gg)Ep)N delta 22 ecmbQSmc4Ba`-Y70$p<2$nnNPCheR;C)Byl-`w33~ diff --git a/iOSClient/Supporting Files/my.lproj/Localizable.strings b/iOSClient/Supporting Files/my.lproj/Localizable.strings index 647959e43b5083d24c4e402e75016550b56a7741..7d5cc701735af9b9570fc0f50cf1470589b16541 100644 GIT binary patch delta 127 zcmX@LhW*Z3_6>RAhDr?a4CM@o44DiiKvo)%&S6LevI-cAfOG*+rU-~jfa3WKc|dWc z$p;UJPv(>2VAo+#U?^oMn7r|}u#y5$J`c#pu1kSIO<}TLL_+h4@a-qU8Jp?=ENdYA delta 22 ecmcb!mi^Qk_6>RAlaED2HAh8kkBVSyssjLiOA0Lj diff --git a/iOSClient/Supporting Files/nb-NO.lproj/Localizable.strings b/iOSClient/Supporting Files/nb-NO.lproj/Localizable.strings index 1cd413821cbad077ae1c60007dd9a5ba0a16f3c9..556d0128bbeb9c99b8770cd25107aae1caef9260 100644 GIT binary patch delta 146 zcmcb#nf=KY_6;@>hDr?a4CM@o44DiiKvo)%&S6LevI-cAfOG*+rU-~jfa3WKc|dWc z>9&oG;w~^PIt&U7r9fplKlcz*RHETp}*N9}aX#@axZwW*I diff --git a/iOSClient/Supporting Files/ne.lproj/Localizable.strings b/iOSClient/Supporting Files/ne.lproj/Localizable.strings index 6b95eaef0148d13b6776c85ca55347969b624221..e5324021fe80b44f1d1763f52acbac009875fd4a 100644 GIT binary patch delta 122 zcmZ3ontj_E_6=U)hDr?a4CM@o44DiiKvo)%&S6LevI-cAfOG*+rU-~jfa3WKc|dWc v$rBHYPv7Uj$ib*H{jV{jq>=(qE{{P0hYke>HHFDs5edyp!j~@zXRHGNZVw*b delta 21 dcmdnChJDFu_6=U)lNUuqHJe2&H;Z7b0|02t2)zIR diff --git a/iOSClient/Supporting Files/nl.lproj/Localizable.strings b/iOSClient/Supporting Files/nl.lproj/Localizable.strings index e296ab78f28828b07929a52da7b14bcf8bc6d832..30cfe9e3e2a399f8142ca6d498666723c77c6f33 100644 GIT binary patch delta 150 zcmZ2?o&CTK_6>)kC!5*v)u%CJGUPC%GQ=|!Fcbml0)|8&oybrE6whbK1Bxp#C@|Op zu@XZ7SY;wZF;JZXLpe}YCQzLYkX;JYmjhIv$dCf$!OT)kn?qu@hr}?x=?4H>R0$6N diff --git a/iOSClient/Supporting Files/nn_NO.lproj/Localizable.strings b/iOSClient/Supporting Files/nn_NO.lproj/Localizable.strings index e393f688230998208259f9ab8d8536c8ae6dd7a9..aff4c0327cf4a37fd80f095459fc38a0bea765ac 100644 GIT binary patch delta 111 zcmbQWhJDRi_6;53(*s%=StkFn<`Pe1$YjW2NM(p;C}1c8(gh5OKss@{zbK>VWUeE8 w)9oA?IT&@O*P1X&Dk%UJ=P@XtDrG1EispmG)f6UsL?kpn3g7-HoYA5V0Ki_@% delta 22 ecmZ3pmVMS5_6;53lOIGxHJ3zeFNt8Zr~?3c7YXYC diff --git a/iOSClient/Supporting Files/oc.lproj/Localizable.strings b/iOSClient/Supporting Files/oc.lproj/Localizable.strings index 5a7021fc22ed78d6c6f930450bdc66c36ded0c2b..d6fb47b79f98b07cfff053c45015958277c7a7f4 100644 GIT binary patch delta 143 zcmaF1nf=EW_6-{%rXT2FWYH~WNMy)lC}D_aNCVP245>g?0YedxE&$3D0dWaXJf9&C zD6TYp;sQqT$>(f1Y;+hD7)pUka)45a3@Jb!OuGV5c^;6D-4F!^HHFCqkqOOQk=wZ< I8SgXz0LJtq;{X5v delta 22 ecmeydh5gxP_6-{%CUZnZHP4CMJ|~j#P6Ggg4GP=< diff --git a/iOSClient/Supporting Files/pl.lproj/Localizable.strings b/iOSClient/Supporting Files/pl.lproj/Localizable.strings index ab42d53c5a40af1320220d6f75db8dc6a4703d01..4ea36504605af3f0fc7e65db1dbaf3999326d38e 100644 GIT binary patch delta 153 zcmdmUk^S5y_6^^nrr%h_$WtHBkj9Y7ki(G55YJG+Pz0n47!rYWB0~vKJf9&CD6Yhy zz+el+N(=#Dm5B_+Ky?ZX-LKy^Amb}3L_4p4m}Lkf@wGgAR5p9kb)H(7x}jZvZb ML)7*UQH*DL0c*=74*&oF delta 22 ecmX?iiG9yS_6^^nCfmeBH9v~p{wSI;rxyTI&KM7}ys{;U5HVD1| diff --git a/iOSClient/Supporting Files/pt-BR.lproj/Localizable.strings b/iOSClient/Supporting Files/pt-BR.lproj/Localizable.strings index ef16ea09b301dd03eb2bd6051512548c7a731815..5442621558862dbecc54294292672b33294a60c4 100644 GIT binary patch delta 138 zcmca`m;KQ__6=4slPm1_#M2lu8FCm>8R8iV7>a;&0Yf5?PMlt-#3&jR0G3K*C zFq8wOG8sx3bb#zqpu!x6e4t1QkOwnF0Vtmb=P;xKSp^J5K)L`ZQ^b%sT~VG*O-k&Fu6 E00SB!4FCWD delta 22 ecmbPnn!W85`-Yy#$xou9nk%BVS41%?bOQi ylP{hWcY*29VNhTw1**yc$|f?T0C_MI6o5MNfPC!cC@`ogH1CSpzAJ{YuLS_#)*@B_ delta 18 acmcb0nEk{d_6-MOnuB7u2gNdWv;Y8FH3+8w diff --git a/iOSClient/Supporting Files/ru.lproj/Localizable.strings b/iOSClient/Supporting Files/ru.lproj/Localizable.strings index 614b3dcd2a8516481ecab650707dae3bbab74107..1d13ba1f50051ff51ddd8b85a92ac02cdcbbe671 100644 GIT binary patch delta 148 zcmdn?kp09X_6;jyRFxRw8Oj+F88R74fUGniox_j{WEC(J0qFvuOc6ukbbU2O(VzgZ zR3bw$P(lH&Ne9R-1uD#8$OkG;0rFsmC;$!11M*Rf0$P&^R0$GSQ<$6*o6yV@yPYYP Ham!=?Kc^wm delta 22 ecmX@{h<)2b_6;jyCjW_zYMv6ieM&6jmdOB(Hw&%+ diff --git a/iOSClient/Supporting Files/sc.lproj/Localizable.strings b/iOSClient/Supporting Files/sc.lproj/Localizable.strings index 8ff6b0a5ba93516dfdac21289d8255440bffaee1..f54f1e93ada7b5758582e6a5cdb24a7bb1a88eeb 100644 GIT binary patch delta 132 zcmaF#iT%rG_6-tos!9y;4CM@o44DiiKvo)%&S6LevI-cAfOG*+ridYNdb}>9C}Y6n z!Y)x89R>x4QlLZ*Lq1S41;~SGQUGes1M*R{0*%cCssxFvDNKG6m(W}kx4kHi@xv?t DqPHPR delta 22 ecmezJnf=ix_6-tolWXFmnpxtvv&1ugm<0fV;R-_l diff --git a/iOSClient/Supporting Files/si.lproj/Localizable.strings b/iOSClient/Supporting Files/si.lproj/Localizable.strings index faced2ebaa21a360ad165e95457475f0a44bdaad..8d4b18ce7079f37f2d1822a8d9cf132487101180 100644 GIT binary patch delta 139 zcmZ3tiT%K4_6@%xraN>nvM81_Br;?&lrY3Iqygz1hEyP{fT0LT7XW377!s%d7iScm zoOX=Q1*TMoL4lzZD4oNQ4^)x@}DH9w2o{w$L5Ry_cPc?*vK diff --git a/iOSClient/Supporting Files/sk-SK.lproj/Localizable.strings b/iOSClient/Supporting Files/sk-SK.lproj/Localizable.strings index 032f1ba077ff0dfb67e0d389b1b27cd647ec0f20..d198beb08d03b51d2c4d241addab4f66d3c7f6d5 100644 GIT binary patch delta 160 zcmaEHhW*!B_6Y&>rU^3u diff --git a/iOSClient/Supporting Files/sl.lproj/Localizable.strings b/iOSClient/Supporting Files/sl.lproj/Localizable.strings index 29ac11cdf60a3503677e78723063ad038d3099ab..1def6054de687fe99482f4d861acb4c53b0fff28 100644 GIT binary patch delta 135 zcmZ2?ll{Og_6={MCl^R^$YwH>FvK&YF=R62Fr)%m1q?+%x_}`ONGDF;sKO{Z{o5u+ zK9_Q!2uQ6Cg91Y-P(FttA1IOnMOLE>r(lQ+a9G`q!YcZ*@n Gm;eB^ydr=A delta 22 ecmX?bi+$Zq_6={MCws(3HQ$KYej|o4V*&t)0}E6D diff --git a/iOSClient/Supporting Files/sq.lproj/Localizable.strings b/iOSClient/Supporting Files/sq.lproj/Localizable.strings index 8c76dd46c5a76574edd489620e6c0744f055a8dd..104e85b414feb7bfc391d93193ccc23c9a899e0c 100644 GIT binary patch delta 127 zcmbQWlYPxD_6<`aCa981q_KmI+39SD4x%d2NYMDYU1uQH%y%0Cp$JG90A-385~rURWfYz4 qWh2I@GyS#+qok4oP+cB_0;(#Y37HJ}U~x5t=6&JY_k}Yu)dK)ND;wef delta 18 acmcb#j{U$|_6981q_KmI+39SD4x%d2NYMD qJpZuxUSV;k>KM%-<>js*V2sAm9As;NRrqHYxwp}lb@k1Q| D#%CSh delta 18 acmdn6ntk3X_6;Us&BwyF9}8oARR;i3_z1@U diff --git a/iOSClient/Supporting Files/tk.lproj/Localizable.strings b/iOSClient/Supporting Files/tk.lproj/Localizable.strings index f5cf625859569cad0ab87157911ac11d6b45bcd8..1eb111186fbaa9eb1bdf23eeac1618259d247d42 100644 GIT binary patch delta 111 zcmX@Jf&Jb__6;w>r$1<8WRWdrNMy)lC}D_aNCVP245>g?0YedxE?`KUe9>Ka@|J@l ylPB14FzQU#He-}jQUEH;V^BaS0xC`f8j#754;EKbn7kq)q1h>7yHf-sR|5cE?jHjH delta 22 ecmcb&k^RgD_6;w>Cp$z&HD8I?ekFpDs{sIoW(uqT diff --git a/iOSClient/Supporting Files/tr.lproj/Localizable.strings b/iOSClient/Supporting Files/tr.lproj/Localizable.strings index ef7dd3b79be80e3d432299677ef3e9186c405b5e..9a1ca6ea74f89ce309b8cf333bca9e31018868fd 100644 GIT binary patch delta 154 zcmdmWp8d=P_6>6)C#Tu+)u%CJGUPC%GQ=|!Fcbml0)|8&oybrE6whbK1Bxp#C@|Op zu@XZ7SY;wZF;JZXLpe}YCQzLYkX;JYmjhIv$dCf$!OT_BtrlI delta 21 dcmX?efqmC`_6>6)Cq+j!cSLRPh+;g_3jlaN3UB}b diff --git a/iOSClient/Supporting Files/ug.lproj/Localizable.strings b/iOSClient/Supporting Files/ug.lproj/Localizable.strings index 4c3435276ab39404ed9d1313e7fd21a6596fe4ee..095926929aa07ee18a772a622c300bff2e171f90 100644 GIT binary patch delta 130 zcmdn7hW*r9_6=*or%TLY4Kt6W;3JhurlXD^xn%N?@vqdl()d2uEWF9C0 delta 22 ecmX@LmVL(>_6=*oC$mIGHP49HJ|lwBs15*lgbA_$ diff --git a/iOSClient/Supporting Files/uk.lproj/Localizable.strings b/iOSClient/Supporting Files/uk.lproj/Localizable.strings index eb340db7a96a627d445a376c5b274111fb4167f7..c236b89438144d26efc73971bfec37d53b8e19c8 100644 GIT binary patch delta 109 zcmZ3smwm@R_6>`oCLgoqQ%+;ZWXNGiWr$}eU?>981q_KmI+39SD4x%d2NYMDeDH+$ n^coLF4o02n6RjB~l@x$-c?=3TbSN;WDKyWC+CC?Wk*fs&p$Hth delta 18 acmdn7kA2x*_6>`onoXj&n?y6Rv;Y86HV1V8 diff --git a/iOSClient/Supporting Files/ur_PK.lproj/Localizable.strings b/iOSClient/Supporting Files/ur_PK.lproj/Localizable.strings index 226e3b3aedf5544a052df1613f2294c63eff835b..531b7e156fa8d175d352bc752199cee3262217cf 100644 GIT binary patch delta 121 zcmX@Gn*Gum_6-r?lNIz>bjukM88R747~&byfOHN+Dv(vcPz0n4fHFluTmlr&XUGGJ uD@|s!k!RImP+%yXtj{5;qyUu31M;w|S71<6m@E;I(7Y*p`=)S4zB&K|fE=~} delta 22 ecmcb#hW)^5_6-r?lQ%>}HM>M?cZp!+s{;UdG6_on diff --git a/iOSClient/Supporting Files/uz.lproj/Localizable.strings b/iOSClient/Supporting Files/uz.lproj/Localizable.strings index 94689da437bd4650216b6afdf4376148625dc45b..489732df4d76b4d43820945c40e497cd5f7c5ac8 100644 GIT binary patch delta 112 zcmbQRntjn4_6;uKlLhoxChxK4Qch#YWXNGiWr$}eU?>981q_KmI+39SD4x%d2NYMD qJpZux3JhurlcgdPnzux3-x9&-)c^pv!ySGA delta 22 ecmbQRnf>2J_6<=HlQ%_1HM>P_cZ+27Y5)Lv4GEqA diff --git a/iOSClient/Supporting Files/zh-Hans.lproj/Localizable.strings b/iOSClient/Supporting Files/zh-Hans.lproj/Localizable.strings index f37c368ead216d2a649f5240292c6a6918e22a61..5eb6e8d0bedcfe7d40aa86afcf91b22db2f2072b 100644 GIT binary patch delta 147 zcmex&nRUWd)(tycRh1ax8Oj+F88R74fUGniox_j{WEC(J0qFvuOc6uk=P;xKSp^J5K)L`ZQv}2%K=FKrJfOJJ z^u3;p;*SOEZW#0eb$ diff --git a/iOSClient/Supporting Files/zh_HK.lproj/Localizable.strings b/iOSClient/Supporting Files/zh_HK.lproj/Localizable.strings index fbbfb8129d6811d4d53fe604fc5d2b64b0340771..62ce66a407e08f128d61638eeaa1eeac47a173e6 100644 GIT binary patch delta 160 zcmcb#m-Wd$)(z8K>XjJc8Oj+F88R74fUGniox_j{WEC(J0qFvuOc4;50LAke@_^z> z3U}h=+&Bz1tQB3BA8?C^grqDdW LW%~pdMkgr%Q{5rV delta 22 ecmaE|kM+`C)(z8KCZBVSYHo7f-sH;oND=^qPYQ|v diff --git a/iOSClient/Supporting Files/zu_ZA.lproj/Localizable.strings b/iOSClient/Supporting Files/zu_ZA.lproj/Localizable.strings index 94689da437bd4650216b6afdf4376148625dc45b..489732df4d76b4d43820945c40e497cd5f7c5ac8 100644 GIT binary patch delta 112 zcmbQRntjn4_6;uKlLhoxChxK4Qch#YWXNGiWr$}eU?>981q_KmI+39SD4x%d2NYMD qJpZux Date: Sat, 21 Oct 2023 15:37:51 +0200 Subject: [PATCH 14/90] coding --- iOSClient/AppDelegate.swift | 2 +- iOSClient/Media/NCMedia.swift | 93 +++++++++--------------------- iOSClient/Media/NCMediaCache.swift | 41 ++++++++++++- iOSClient/Menu/NCMedia+Menu.swift | 2 +- 4 files changed, 68 insertions(+), 70 deletions(-) diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index f38613674e..4c8827b87d 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -135,7 +135,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD NCBrandColor.shared.settingThemingColor(account: activeAccount.account) - DispatchQueue.global().async { NCMediaCache.shared.createCache(account: self.account) } + NCMediaCache.shared.createCache(account: self.account) } else { diff --git a/iOSClient/Media/NCMedia.swift b/iOSClient/Media/NCMedia.swift index 0f3aa7408a..ef822eec99 100644 --- a/iOSClient/Media/NCMedia.swift +++ b/iOSClient/Media/NCMedia.swift @@ -39,12 +39,8 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate { internal let appDelegate = UIApplication.shared.delegate as! AppDelegate // swiftlint:enable force_cast - public var metadatas: [tableMetadata] = [] private var account: String = "" - private var predicateDefault: NSPredicate? - private var predicate: NSPredicate? - internal var isEditMode = false internal var selectOcId: [String] = [] internal var selectIndexPath: [IndexPath] = [] @@ -126,10 +122,10 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate { NotificationCenter.default.addObserver(self, selector: #selector(renameFile(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterRenameFile), object: nil) NotificationCenter.default.addObserver(self, selector: #selector(uploadedFile(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterUploadedFile), object: nil) - self.reloadDataSourceWithCompletion { _ in - self.timerSearchNewMedia?.invalidate() - self.timerSearchNewMedia = Timer.scheduledTimer(timeInterval: self.timeIntervalSearchNewMedia, target: self, selector: #selector(self.searchNewMediaTimer), userInfo: nil, repeats: false) - } + timerSearchNewMedia?.invalidate() + timerSearchNewMedia = Timer.scheduledTimer(timeInterval: timeIntervalSearchNewMedia, target: self, selector: #selector(searchNewMediaTimer), userInfo: nil, repeats: false) + + collectionView.reloadData() } override func viewDidAppear(_ animated: Bool) { @@ -166,7 +162,7 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate { let error = userInfo["error"] as? NKError else { return } let onlyLocalCache: Bool = userInfo["onlyLocalCache"] as? Bool ?? false - self.queryDB(isForced: true) + NCMediaCache.shared.getMetadatasMedia(filterClassTypeImage: filterClassTypeImage, filterClassTypeVideo: filterClassTypeVideo) if error == .success, let indexPath = userInfo["indexPath"] as? [IndexPath], !indexPath.isEmpty, !onlyLocalCache { collectionView?.performBatchUpdates({ @@ -305,7 +301,7 @@ extension NCMedia: UICollectionViewDelegate { func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - let metadata = metadatas[indexPath.row] + let metadata = NCMediaCache.shared.metadatas[indexPath.row] if isEditMode { if let index = selectOcId.firstIndex(of: metadata.ocId) { selectOcId.remove(at: index) @@ -321,14 +317,14 @@ extension NCMedia: UICollectionViewDelegate { // ACTIVE SERVERURL appDelegate.activeServerUrl = metadata.serverUrl let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as? NCGridMediaCell - NCViewer.shared.view(viewController: self, metadata: metadata, metadatas: metadatas, imageIcon: cell?.imageItem.image) + NCViewer.shared.view(viewController: self, metadata: metadata, metadatas: NCMediaCache.shared.metadatas, imageIcon: cell?.imageItem.image) } } func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? { guard let cell = collectionView.cellForItem(at: indexPath) as? NCGridMediaCell else { return nil } - let metadata = metadatas[indexPath.row] + let metadata = NCMediaCache.shared.metadatas[indexPath.row] let identifier = indexPath as NSCopying let image = cell.imageItem.image @@ -364,13 +360,13 @@ extension NCMedia: UICollectionViewDataSource { } func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - emptyDataSet?.numberOfItemsInSection(metadatas.count, section: section) - return metadatas.count + emptyDataSet?.numberOfItemsInSection(NCMediaCache.shared.metadatas.count, section: section) + return NCMediaCache.shared.metadatas.count } func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) { - guard let cell = (cell as? NCGridMediaCell), indexPath.row < self.metadatas.count else { return } - let metadata = self.metadatas[indexPath.row] + guard let cell = (cell as? NCGridMediaCell), indexPath.row < NCMediaCache.shared.metadatas.count else { return } + let metadata = NCMediaCache.shared.metadatas[indexPath.row] if let image = NCMediaCache.shared.getImage(ocId: metadata.ocId) { cell.imageItem.backgroundColor = nil cell.imageItem.image = image @@ -389,8 +385,8 @@ extension NCMedia: UICollectionViewDataSource { } func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) { - if !collectionView.indexPathsForVisibleItems.contains(indexPath) && indexPath.row < metadatas.count { - let metadata = metadatas[indexPath.row] + if !collectionView.indexPathsForVisibleItems.contains(indexPath) && indexPath.row < NCMediaCache.shared.metadatas.count { + let metadata = NCMediaCache.shared.metadatas[indexPath.row] for case let operation as NCMediaDownloadThumbnaill in appDelegate.downloadThumbnailQueue.operations where operation.metadata.ocId == metadata.ocId { operation.cancel() } @@ -401,9 +397,9 @@ extension NCMedia: UICollectionViewDataSource { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as? NCGridMediaCell else { return UICollectionViewCell() } - if indexPath.section < collectionView.numberOfSections && indexPath.row < collectionView.numberOfItems(inSection: indexPath.section) && indexPath.row < metadatas.count { + if indexPath.section < collectionView.numberOfSections && indexPath.row < collectionView.numberOfItems(inSection: indexPath.section) && indexPath.row < NCMediaCache.shared.metadatas.count { - let metadata = metadatas[indexPath.row] + let metadata = NCMediaCache.shared.metadatas[indexPath.row] self.cellHeigth = cell.frame.size.height @@ -451,59 +447,22 @@ extension NCMedia: UICollectionViewDelegateFlowLayout { extension NCMedia { - // MARK: - Datasource - - func queryDB(isForced: Bool) { - - livePhoto = CCUtility.getLivePhoto() - - if let activeAccount = NCManageDatabase.shared.getActiveAccount() { - self.mediaPath = activeAccount.mediaPath - } - let startServerUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, userId: appDelegate.userId) + mediaPath - - predicateDefault = NSPredicate(format: "account == %@ AND serverUrl BEGINSWITH %@ AND (classFile == %@ OR classFile == %@) AND NOT (session CONTAINS[c] 'upload')", appDelegate.account, startServerUrl, NKCommon.TypeClassFile.image.rawValue, NKCommon.TypeClassFile.video.rawValue) - - if filterClassTypeImage { - predicate = NSPredicate(format: "account == %@ AND serverUrl BEGINSWITH %@ AND classFile == %@ AND NOT (session CONTAINS[c] 'upload')", appDelegate.account, startServerUrl, NKCommon.TypeClassFile.video.rawValue) - } else if filterClassTypeVideo { - predicate = NSPredicate(format: "account == %@ AND serverUrl BEGINSWITH %@ AND classFile == %@ AND NOT (session CONTAINS[c] 'upload')", appDelegate.account, startServerUrl, NKCommon.TypeClassFile.image.rawValue) - } else { - predicate = predicateDefault - } - - guard let predicate = predicate else { return } - - self.metadatas = NCManageDatabase.shared.getMetadatasMedia(predicate: predicate, livePhoto: self.livePhoto) - - switch CCUtility.getMediaSortDate() { - case "date": - self.metadatas = self.metadatas.sorted(by: {($0.date as Date) > ($1.date as Date)}) - case "creationDate": - self.metadatas = self.metadatas.sorted(by: {($0.creationDate as Date) > ($1.creationDate as Date)}) - case "uploadDate": - self.metadatas = self.metadatas.sorted(by: {($0.uploadDate as Date) > ($1.uploadDate as Date)}) - default: - break - } - } - @objc func reloadDataSourceWithCompletion(_ completion: @escaping (_ metadatas: [tableMetadata]) -> Void) { guard !appDelegate.account.isEmpty else { return } if account != appDelegate.account { - self.metadatas = [] + NCMediaCache.shared.metadatas = [] account = appDelegate.account DispatchQueue.main.async { self.collectionView?.reloadData() } } DispatchQueue.global().async { - self.queryDB(isForced: true) + NCMediaCache.shared.getMetadatasMedia(filterClassTypeImage: self.filterClassTypeImage, filterClassTypeVideo: self.filterClassTypeVideo) DispatchQueue.main.sync { self.reloadDataThenPerform { self.updateMediaControlVisibility() self.mediaCommandTitle() - completion(self.metadatas) + completion(NCMediaCache.shared.metadatas) } } } @@ -511,7 +470,7 @@ extension NCMedia { func updateMediaControlVisibility() { - if self.metadatas.isEmpty { + if NCMediaCache.shared.metadatas.isEmpty { if !self.filterClassTypeImage && !self.filterClassTypeVideo { self.mediaCommandView?.toggleEmptyView(isEmpty: true) self.mediaCommandView?.isHidden = false @@ -540,8 +499,8 @@ extension NCMedia { } var lessDate = Date() - if predicateDefault != nil { - if let metadata = NCManageDatabase.shared.getMetadata(predicate: predicateDefault!, sorted: "date", ascending: true) { + if let predicate = NCMediaCache.shared.predicateDefault { + if let metadata = NCManageDatabase.shared.getMetadata(predicate: predicate, sorted: "date", ascending: true) { lessDate = metadata.date as Date } } @@ -567,7 +526,7 @@ extension NCMedia { if !files.isEmpty { NCManageDatabase.shared.convertFilesToMetadatas(files, useMetadataFolder: false) { _, _, metadatas in let predicateDate = NSPredicate(format: "date > %@ AND date < %@", greaterDate as NSDate, lessDate as NSDate) - let predicateResult = NSCompoundPredicate(andPredicateWithSubpredicates: [predicateDate, self.predicateDefault!]) + let predicateResult = NSCompoundPredicate(andPredicateWithSubpredicates: [predicateDate, NCMediaCache.shared.predicateDefault!]) let metadatasResult = NCManageDatabase.shared.getMetadatas(predicate: predicateResult) let metadatasChanged = NCManageDatabase.shared.updateMetadatas(metadatas, metadatasResult: metadatasResult, addCompareLivePhoto: false) if metadatasChanged.metadatasUpdate.isEmpty { @@ -621,7 +580,7 @@ extension NCMedia { if let visibleCells = self.collectionView?.indexPathsForVisibleItems.sorted(by: { $0.row < $1.row }).compactMap({ self.collectionView?.cellForItem(at: $0) }) { if let cell = visibleCells.first as? NCGridMediaCell { if cell.date != nil { - if cell.date != self.metadatas.first?.date as Date? { + if cell.date != NCMediaCache.shared.metadatas.first?.date as Date? { lessDate = Calendar.current.date(byAdding: .second, value: 1, to: cell.date!)! limit = 0 } @@ -648,14 +607,14 @@ extension NCMedia { if error == .success, account == self.appDelegate.account, !files.isEmpty { NCManageDatabase.shared.convertFilesToMetadatas(files, useMetadataFolder: false) { _, _, metadatas in let predicate = NSPredicate(format: "date > %@ AND date < %@", greaterDate as NSDate, lessDate as NSDate) - let predicateResult = NSCompoundPredicate(andPredicateWithSubpredicates: [predicate, self.predicate!]) + let predicateResult = NSCompoundPredicate(andPredicateWithSubpredicates: [predicate, NCMediaCache.shared.predicate!]) let metadatasResult = NCManageDatabase.shared.getMetadatas(predicate: predicateResult) let updateMetadatas = NCManageDatabase.shared.updateMetadatas(metadatas, metadatasResult: metadatasResult, addCompareLivePhoto: false) if !updateMetadatas.metadatasUpdate.isEmpty || !updateMetadatas.metadatasDelete.isEmpty { self.reloadDataSourceWithCompletion { _ in } } } - } else if error == .success, files.isEmpty, self.metadatas.isEmpty { + } else if error == .success, files.isEmpty, NCMediaCache.shared.metadatas.isEmpty { self.searchOldMedia() } else if error != .success { NextcloudKit.shared.nkCommonInstance.writeLog("[ERROR] Media search new media error code \(error.errorCode) " + error.errorDescription) diff --git a/iOSClient/Media/NCMediaCache.swift b/iOSClient/Media/NCMediaCache.swift index 5a8d9ea97a..5f3bf13b73 100644 --- a/iOSClient/Media/NCMediaCache.swift +++ b/iOSClient/Media/NCMediaCache.swift @@ -32,11 +32,14 @@ import NextcloudKit return instance }() - let limit: Int = 2000 + private let limit: Int = 2000 private typealias ThumbnailLRUCache = LRUCache private lazy var cache: ThumbnailLRUCache = { return ThumbnailLRUCache(countLimit: limit) }() + public var metadatas: [tableMetadata] = [] + public var predicateDefault: NSPredicate? + public var predicate: NSPredicate? func createCache(account: String) { @@ -44,6 +47,9 @@ import NextcloudKit guard !resultsMedia.isEmpty, let directory = CCUtility.getDirectoryProviderStorage() else { return } + metadatas.removeAll() + getMetadatasMedia() + let ext = ".preview.ico" let manager = FileManager.default let resourceKeys = Set([.nameKey, .pathKey, .fileSizeKey, .creationDateKey]) @@ -109,4 +115,37 @@ import NextcloudKit cache.removeAllValues() } + + func getMetadatasMedia(filterClassTypeImage: Bool = false, filterClassTypeVideo: Bool = false) { + + let livePhoto = CCUtility.getLivePhoto() + guard let appDelegate = (UIApplication.shared.delegate as? AppDelegate), + let activeAccount = NCManageDatabase.shared.getActiveAccount() else { return } + let startServerUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, userId: appDelegate.userId) + activeAccount.mediaPath + + predicateDefault = NSPredicate(format: "account == %@ AND serverUrl BEGINSWITH %@ AND (classFile == %@ OR classFile == %@) AND NOT (session CONTAINS[c] 'upload')", appDelegate.account, startServerUrl, NKCommon.TypeClassFile.image.rawValue, NKCommon.TypeClassFile.video.rawValue) + + if filterClassTypeImage { + predicate = NSPredicate(format: "account == %@ AND serverUrl BEGINSWITH %@ AND classFile == %@ AND NOT (session CONTAINS[c] 'upload')", appDelegate.account, startServerUrl, NKCommon.TypeClassFile.video.rawValue) + } else if filterClassTypeVideo { + predicate = NSPredicate(format: "account == %@ AND serverUrl BEGINSWITH %@ AND classFile == %@ AND NOT (session CONTAINS[c] 'upload')", appDelegate.account, startServerUrl, NKCommon.TypeClassFile.image.rawValue) + } else { + predicate = predicateDefault + } + + guard let predicate = predicate else { return } + + metadatas = NCManageDatabase.shared.getMetadatasMedia(predicate: predicate, livePhoto: livePhoto) + + switch CCUtility.getMediaSortDate() { + case "date": + metadatas = self.metadatas.sorted(by: {($0.date as Date) > ($1.date as Date)}) + case "creationDate": + metadatas = self.metadatas.sorted(by: {($0.creationDate as Date) > ($1.creationDate as Date)}) + case "uploadDate": + metadatas = self.metadatas.sorted(by: {($0.uploadDate as Date) > ($1.uploadDate as Date)}) + default: + break + } + } } diff --git a/iOSClient/Menu/NCMedia+Menu.swift b/iOSClient/Menu/NCMedia+Menu.swift index 66f6cde695..1d8bc032c0 100644 --- a/iOSClient/Menu/NCMedia+Menu.swift +++ b/iOSClient/Menu/NCMedia+Menu.swift @@ -40,7 +40,7 @@ extension NCMedia { defer { presentMenu(with: actions) } if !isEditMode { - if !metadatas.isEmpty { + if !NCMediaCache.shared.metadatas.isEmpty { actions.append( NCMenuAction( title: NSLocalizedString("_select_", comment: ""), From 6ebf92e7f6859cdc3541c351b60a8d1cfde021bb Mon Sep 17 00:00:00 2001 From: Nextcloud bot Date: Sun, 22 Oct 2023 02:46:40 +0000 Subject: [PATCH 15/90] Fix(l10n): Update translations from Transifex Signed-off-by: Nextcloud bot --- .../ar.lproj/Localizable.strings | Bin 119580 -> 119590 bytes .../de.lproj/Localizable.strings | Bin 131702 -> 131714 bytes .../sv.lproj/Localizable.strings | Bin 122798 -> 122798 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/iOSClient/Supporting Files/ar.lproj/Localizable.strings b/iOSClient/Supporting Files/ar.lproj/Localizable.strings index fa7fbf11f25d740713bf954a1080f07c9fc94403..872a7dc25059154d961e266b52f0d3b129edf17d 100644 GIT binary patch delta 100 zcmbQUjD6WM_6OcuCHeH|sFR%s>UkR*9j{yWHp9xE7E(_aU7RI=&1_1jk6odc( delta 83 zcmZ3sjD5~B_6x*67*ZJ$8H$0V0z)~FmB~=TpaW!=G86#i@_`~LKwcV99HdeK bNaryqOkNl&&Z5AerqHYqwp}5Nk*yX0XWSDg diff --git a/iOSClient/Supporting Files/de.lproj/Localizable.strings b/iOSClient/Supporting Files/de.lproj/Localizable.strings index 98bc3cf0740b2a2dda07d7bc071e322beaedaea0..40469f3292754581aa5fbf81cbc8b163f0bf4f7f 100644 GIT binary patch delta 64 zcmey?!qL>qv4JCQy3}Dtp2_dJc$jq<6sE_zGs;iaS;`?E#*oiY#E`_03M5k*G8sx3 TN*VGP(wjr$wui9e3V^ajKwJV8&1cAKPK?{07{{o%1OO=c74HB5 diff --git a/iOSClient/Supporting Files/sv.lproj/Localizable.strings b/iOSClient/Supporting Files/sv.lproj/Localizable.strings index 4e1d7dc2cec207bb759d65e27c35556d8a8d40d9..f7bfacebbadb42b170045646faac07ce27cbd00c 100644 GIT binary patch delta 74 zcmZ3tpMBka_6=*or=MbF;M1& From 2cf9d0dbd8d931c7ebb8aa540d69da934710de8a Mon Sep 17 00:00:00 2001 From: Nextcloud bot Date: Mon, 23 Oct 2023 02:44:12 +0000 Subject: [PATCH 16/90] Fix(l10n): Update translations from Transifex Signed-off-by: Nextcloud bot --- .../zh_HK.lproj/Localizable.strings | Bin 89956 -> 89906 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/iOSClient/Supporting Files/zh_HK.lproj/Localizable.strings b/iOSClient/Supporting Files/zh_HK.lproj/Localizable.strings index 62ce66a407e08f128d61638eeaa1eeac47a173e6..23bf4d23559c0c5501c90d035218bf131cd304fb 100644 GIT binary patch delta 55 zcmaE|k9E^N)(sb26q2(w!l&iU4B+zH955xzBZKGv=`P+X&uRq*JusYn!Zo3}$#r{^ IE8`t<8 delta 83 zcmdnAkM+qu)(sb2%mWy57*ZJ$8H$0V0z)~FmB~=TpaW!=G86#i@_`~LKwcV99HdeK bNaryqOkV3E&Z5AerqKMsW%~ygMkgr%m`W7$ From cdc4c598933526179d3d65af1d92a7eee1837333 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Mon, 23 Oct 2023 09:53:03 +0200 Subject: [PATCH 17/90] fix Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> --- iOSClient/Media/NCMedia.swift | 37 ++++++++++++++++------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/iOSClient/Media/NCMedia.swift b/iOSClient/Media/NCMedia.swift index ef822eec99..1b0bf1b8a2 100644 --- a/iOSClient/Media/NCMedia.swift +++ b/iOSClient/Media/NCMedia.swift @@ -364,26 +364,6 @@ extension NCMedia: UICollectionViewDataSource { return NCMediaCache.shared.metadatas.count } - func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) { - guard let cell = (cell as? NCGridMediaCell), indexPath.row < NCMediaCache.shared.metadatas.count else { return } - let metadata = NCMediaCache.shared.metadatas[indexPath.row] - if let image = NCMediaCache.shared.getImage(ocId: metadata.ocId) { - cell.imageItem.backgroundColor = nil - 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)) { - cell.imageItem.backgroundColor = nil - cell.imageItem.image = image - NCMediaCache.shared.setImage(ocId: metadata.ocId, image: image) - } - } else { - if metadata.hasPreview && metadata.status == NCGlobal.shared.metadataStatusNormal && (!CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag)) { - for case let operation as NCMediaDownloadThumbnaill in appDelegate.downloadThumbnailQueue.operations where operation.metadata.ocId == metadata.ocId { return } - appDelegate.downloadThumbnailQueue.addOperation(NCMediaDownloadThumbnaill(metadata: metadata, cell: cell, collectionView: collectionView)) - } - } - } - func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) { if !collectionView.indexPathsForVisibleItems.contains(indexPath) && indexPath.row < NCMediaCache.shared.metadatas.count { let metadata = NCMediaCache.shared.metadatas[indexPath.row] @@ -408,6 +388,23 @@ extension NCMedia: UICollectionViewDataSource { cell.indexPath = indexPath cell.fileUser = metadata.ownerId + if let image = NCMediaCache.shared.getImage(ocId: metadata.ocId) { + cell.imageItem.backgroundColor = nil + 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)) { + cell.imageItem.backgroundColor = nil + cell.imageItem.image = image + NCMediaCache.shared.setImage(ocId: metadata.ocId, image: image) + } + } else { + if metadata.hasPreview && metadata.status == NCGlobal.shared.metadataStatusNormal && (!CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag)) { + if appDelegate.downloadThumbnailQueue.operations.filter({ ($0 as? NCMediaDownloadThumbnaill)?.metadata.ocId == metadata.ocId }).isEmpty { + appDelegate.downloadThumbnailQueue.addOperation(NCMediaDownloadThumbnaill(metadata: metadata, cell: cell, collectionView: collectionView)) + } + } + } + if metadata.isAudioOrVideo { cell.imageStatus.image = cacheImages.cellPlayImage } else if metadata.livePhoto && livePhoto { From 47b22a2dda951b153b6bda2f257295ee645825d9 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Mon, 23 Oct 2023 09:56:16 +0200 Subject: [PATCH 18/90] build 5 Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> --- Nextcloud.xcodeproj/project.pbxproj | 4 ++-- iOSClient/Media/NCMediaCache.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Nextcloud.xcodeproj/project.pbxproj b/Nextcloud.xcodeproj/project.pbxproj index b962e9abef..9572dc0e44 100644 --- a/Nextcloud.xcodeproj/project.pbxproj +++ b/Nextcloud.xcodeproj/project.pbxproj @@ -4697,7 +4697,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 4; + CURRENT_PROJECT_VERSION = 5; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = NKUJUXUJ3B; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -4762,7 +4762,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 4; + CURRENT_PROJECT_VERSION = 5; DEVELOPMENT_TEAM = NKUJUXUJ3B; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; diff --git a/iOSClient/Media/NCMediaCache.swift b/iOSClient/Media/NCMediaCache.swift index 5f3bf13b73..ac31c0e501 100644 --- a/iOSClient/Media/NCMediaCache.swift +++ b/iOSClient/Media/NCMediaCache.swift @@ -32,7 +32,7 @@ import NextcloudKit return instance }() - private let limit: Int = 2000 + private let limit: Int = 1500 private typealias ThumbnailLRUCache = LRUCache private lazy var cache: ThumbnailLRUCache = { return ThumbnailLRUCache(countLimit: limit) From 08d2e48da98fe05d4f679de135881dd3d34e49f7 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Mon, 23 Oct 2023 10:57:06 +0200 Subject: [PATCH 19/90] build 5 Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> --- iOSClient/AppDelegate.swift | 11 +++---- iOSClient/Media/NCMedia.swift | 12 ++----- iOSClient/Media/NCMediaCache.swift | 14 ++++----- iOSClient/Networking/NCNetworking.swift | 31 ++++++++----------- .../NCNetworkingCheckRemoteUser.swift | 2 +- iOSClient/Settings/CCAdvanced.m | 4 +-- 6 files changed, 31 insertions(+), 43 deletions(-) diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index 4c8827b87d..ee160135a7 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -135,7 +135,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD NCBrandColor.shared.settingThemingColor(account: activeAccount.account) - NCMediaCache.shared.createCache(account: self.account) + DispatchQueue.global().async { NCMediaCache.shared.createCache(account: activeAccount.account) } } else { @@ -269,7 +269,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD NextcloudKit.shared.nkCommonInstance.writeLog("[ERROR] Create share accounts \(error.localizedDescription)") } - NCNetworking.shared.cancelSessions(inBackground: false) + NCNetworking.shared.cancel(inBackground: false) presentPasscode { } @@ -279,7 +279,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD // L'applicazione terminerà func applicationWillTerminate(_ application: UIApplication) { - NCNetworking.shared.cancelSessions(inBackground: false) + NCNetworking.shared.cancel(inBackground: false) if UIApplication.shared.backgroundRefreshStatus == .available { @@ -576,10 +576,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD @objc func changeAccount(_ account: String, userProfile: NKUserProfile?) { + NCNetworking.shared.cancel(inBackground: false) guard let tableAccount = NCManageDatabase.shared.setAccountActive(account) else { return } - NCNetworking.shared.cancelSessions(inBackground: false) - self.account = tableAccount.account self.urlBase = tableAccount.urlBase self.user = tableAccount.user @@ -605,7 +604,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Initialize Auto upload with \(items) uploads") } - DispatchQueue.global().async { NCMediaCache.shared.createCache(account: account) } + DispatchQueue.global().async { NCMediaCache.shared.createCache(account: self.account) } NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterChangeUser) } diff --git a/iOSClient/Media/NCMedia.swift b/iOSClient/Media/NCMedia.swift index 1b0bf1b8a2..70e7bc21a3 100644 --- a/iOSClient/Media/NCMedia.swift +++ b/iOSClient/Media/NCMedia.swift @@ -39,7 +39,7 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate { internal let appDelegate = UIApplication.shared.delegate as! AppDelegate // swiftlint:enable force_cast - private var account: String = "" + //private var account: String = "" internal var isEditMode = false internal var selectOcId: [String] = [] @@ -162,7 +162,7 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate { let error = userInfo["error"] as? NKError else { return } let onlyLocalCache: Bool = userInfo["onlyLocalCache"] as? Bool ?? false - NCMediaCache.shared.getMetadatasMedia(filterClassTypeImage: filterClassTypeImage, filterClassTypeVideo: filterClassTypeVideo) + NCMediaCache.shared.getMetadatasMedia(account: appDelegate.account, filterClassTypeImage: filterClassTypeImage, filterClassTypeVideo: filterClassTypeVideo) if error == .success, let indexPath = userInfo["indexPath"] as? [IndexPath], !indexPath.isEmpty, !onlyLocalCache { collectionView?.performBatchUpdates({ @@ -447,14 +447,8 @@ extension NCMedia { @objc func reloadDataSourceWithCompletion(_ completion: @escaping (_ metadatas: [tableMetadata]) -> Void) { guard !appDelegate.account.isEmpty else { return } - if account != appDelegate.account { - NCMediaCache.shared.metadatas = [] - account = appDelegate.account - DispatchQueue.main.async { self.collectionView?.reloadData() } - } - DispatchQueue.global().async { - NCMediaCache.shared.getMetadatasMedia(filterClassTypeImage: self.filterClassTypeImage, filterClassTypeVideo: self.filterClassTypeVideo) + NCMediaCache.shared.getMetadatasMedia(account: self.appDelegate.account, filterClassTypeImage: self.filterClassTypeImage, filterClassTypeVideo: self.filterClassTypeVideo) DispatchQueue.main.sync { self.reloadDataThenPerform { self.updateMediaControlVisibility() diff --git a/iOSClient/Media/NCMediaCache.swift b/iOSClient/Media/NCMediaCache.swift index ac31c0e501..9e53e231d2 100644 --- a/iOSClient/Media/NCMediaCache.swift +++ b/iOSClient/Media/NCMediaCache.swift @@ -48,7 +48,7 @@ import NextcloudKit let directory = CCUtility.getDirectoryProviderStorage() else { return } metadatas.removeAll() - getMetadatasMedia() + getMetadatasMedia(account: account) let ext = ".preview.ico" let manager = FileManager.default @@ -116,19 +116,19 @@ import NextcloudKit cache.removeAllValues() } - func getMetadatasMedia(filterClassTypeImage: Bool = false, filterClassTypeVideo: Bool = false) { + func getMetadatasMedia(account: String, filterClassTypeImage: Bool = false, filterClassTypeVideo: Bool = false) { let livePhoto = CCUtility.getLivePhoto() guard let appDelegate = (UIApplication.shared.delegate as? AppDelegate), - let activeAccount = NCManageDatabase.shared.getActiveAccount() else { return } - let startServerUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, userId: appDelegate.userId) + activeAccount.mediaPath + let account = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", account)) else { return } + let startServerUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, userId: appDelegate.userId) + account.mediaPath - predicateDefault = NSPredicate(format: "account == %@ AND serverUrl BEGINSWITH %@ AND (classFile == %@ OR classFile == %@) AND NOT (session CONTAINS[c] 'upload')", appDelegate.account, startServerUrl, NKCommon.TypeClassFile.image.rawValue, NKCommon.TypeClassFile.video.rawValue) + predicateDefault = NSPredicate(format: "account == %@ AND serverUrl BEGINSWITH %@ AND (classFile == %@ OR classFile == %@) AND NOT (session CONTAINS[c] 'upload')", account.account, startServerUrl, NKCommon.TypeClassFile.image.rawValue, NKCommon.TypeClassFile.video.rawValue) if filterClassTypeImage { - predicate = NSPredicate(format: "account == %@ AND serverUrl BEGINSWITH %@ AND classFile == %@ AND NOT (session CONTAINS[c] 'upload')", appDelegate.account, startServerUrl, NKCommon.TypeClassFile.video.rawValue) + predicate = NSPredicate(format: "account == %@ AND serverUrl BEGINSWITH %@ AND classFile == %@ AND NOT (session CONTAINS[c] 'upload')", account.account, startServerUrl, NKCommon.TypeClassFile.video.rawValue) } else if filterClassTypeVideo { - predicate = NSPredicate(format: "account == %@ AND serverUrl BEGINSWITH %@ AND classFile == %@ AND NOT (session CONTAINS[c] 'upload')", appDelegate.account, startServerUrl, NKCommon.TypeClassFile.image.rawValue) + predicate = NSPredicate(format: "account == %@ AND serverUrl BEGINSWITH %@ AND classFile == %@ AND NOT (session CONTAINS[c] 'upload')", account.account, startServerUrl, NKCommon.TypeClassFile.image.rawValue) } else { predicate = predicateDefault } diff --git a/iOSClient/Networking/NCNetworking.swift b/iOSClient/Networking/NCNetworking.swift index 2247f98b65..3e39246b29 100644 --- a/iOSClient/Networking/NCNetworking.swift +++ b/iOSClient/Networking/NCNetworking.swift @@ -771,17 +771,11 @@ class NCNetworking: NSObject, NKCommonDelegate { // sessionIdentifierBackgroundWWan: String = "com.nextcloud.session.upload.backgroundWWan" // sessionIdentifierBackgroundExtension: String = "com.nextcloud.session.upload.extension" - func cancelSessions(inBackground: Bool) { - Task { - await cancel(inBackground: inBackground) - } - } - - func cancel(inBackground: Bool) async { + func cancel(inBackground: Bool) { #if !EXTENSION - if let appDelegate = await UIApplication.shared.delegate as? AppDelegate { - await appDelegate.cancelAllQueue() + if let appDelegate = UIApplication.shared.delegate as? AppDelegate { + appDelegate.cancelAllQueue() } #endif @@ -813,16 +807,17 @@ class NCNetworking: NSObject, NKCommonDelegate { NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) } - let tasksBackground = await NCNetworking.shared.sessionManagerBackground.tasks - for task in tasksBackground.1 { // ([URLSessionDataTask], [URLSessionUploadTask], [URLSessionDownloadTask]) - task.cancel() - } - let tasksBackgroundWWan = await NCNetworking.shared.sessionManagerBackgroundWWan.tasks - for task in tasksBackgroundWWan.1 { // ([URLSessionDataTask], [URLSessionUploadTask], [URLSessionDownloadTask]) - task.cancel() + Task { + let tasksBackground = await NCNetworking.shared.sessionManagerBackground.tasks + for task in tasksBackground.1 { // ([URLSessionDataTask], [URLSessionUploadTask], [URLSessionDownloadTask]) + task.cancel() + } + let tasksBackgroundWWan = await NCNetworking.shared.sessionManagerBackgroundWWan.tasks + for task in tasksBackgroundWWan.1 { // ([URLSessionDataTask], [URLSessionUploadTask], [URLSessionDownloadTask]) + task.cancel() + } + NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource) } - - NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource) } func cancel(metadata: tableMetadata) async { diff --git a/iOSClient/Networking/NCNetworkingCheckRemoteUser.swift b/iOSClient/Networking/NCNetworkingCheckRemoteUser.swift index cc83771d23..a8f293d56f 100644 --- a/iOSClient/Networking/NCNetworkingCheckRemoteUser.swift +++ b/iOSClient/Networking/NCNetworkingCheckRemoteUser.swift @@ -32,7 +32,7 @@ class NCNetworkingCheckRemoteUser { let token = CCUtility.getPassword(account), !token.isEmpty, let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return } - NCNetworking.shared.cancelSessions(inBackground: true) + NCNetworking.shared.cancel(inBackground: true) if NCGlobal.shared.capabilityServerVersionMajor >= NCGlobal.shared.nextcloudVersion17 { diff --git a/iOSClient/Settings/CCAdvanced.m b/iOSClient/Settings/CCAdvanced.m index f2aabfe1b8..592502ad78 100755 --- a/iOSClient/Settings/CCAdvanced.m +++ b/iOSClient/Settings/CCAdvanced.m @@ -367,7 +367,7 @@ - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor ol - (void)clearCache:(NSString *)account { - [[NCNetworking shared] cancelSessionsInBackground:true]; + [[NCNetworking shared] cancelInBackground:true]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) { @@ -450,7 +450,7 @@ - (void)exitNextcloud:(XLFormRowDescriptor *)sender [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { - [[NCNetworking shared] cancelSessionsInBackground:true]; + [[NCNetworking shared] cancelInBackground:true]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) { From 4eebdfe4399e401ddbbfe4755b813614e5fd3ff3 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Mon, 23 Oct 2023 12:11:43 +0200 Subject: [PATCH 20/90] #2643 Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> --- Nextcloud.xcodeproj/project.pbxproj | 105 +++++++++++++++++++++++++++ iOSClient/NCGlobal.swift | 7 ++ iOSClient/Scan document/NCScan.swift | 14 ++-- iOSClient/Utility/NCKeychain.swift | 43 +++++++++++ 4 files changed, 162 insertions(+), 7 deletions(-) create mode 100644 iOSClient/Utility/NCKeychain.swift diff --git a/Nextcloud.xcodeproj/project.pbxproj b/Nextcloud.xcodeproj/project.pbxproj index 9572dc0e44..84f9bdf367 100644 --- a/Nextcloud.xcodeproj/project.pbxproj +++ b/Nextcloud.xcodeproj/project.pbxproj @@ -358,6 +358,23 @@ F75EAED826D2552E00F4320E /* MarqueeLabel in Frameworks */ = {isa = PBXBuildFile; productRef = F75EAED726D2552E00F4320E /* MarqueeLabel */; }; F760329F252F0F8E0015A421 /* NCTransferCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F760329D252F0F8E0015A421 /* NCTransferCell.swift */; }; F76032A0252F0F8E0015A421 /* NCTransferCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F760329E252F0F8E0015A421 /* NCTransferCell.xib */; }; + F760DE032AE66EA80027D78A /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = F760DE022AE66EA80027D78A /* KeychainAccess */; }; + F760DE052AE66EBE0027D78A /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = F760DE042AE66EBE0027D78A /* KeychainAccess */; }; + F760DE072AE66EC70027D78A /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = F760DE062AE66EC70027D78A /* KeychainAccess */; }; + F760DE092AE66ED00027D78A /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = F760DE082AE66ED00027D78A /* KeychainAccess */; }; + F760DE0B2AE66ED80027D78A /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = F760DE0A2AE66ED80027D78A /* KeychainAccess */; }; + F760DE0D2AE66EDF0027D78A /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = F760DE0C2AE66EDF0027D78A /* KeychainAccess */; }; + F760DE0F2AE66EE60027D78A /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = F760DE0E2AE66EE60027D78A /* KeychainAccess */; }; + F760DE112AE66EF00027D78A /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = F760DE102AE66EF00027D78A /* KeychainAccess */; }; + F760DE132AE66EF80027D78A /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = F760DE122AE66EF80027D78A /* KeychainAccess */; }; + F760DE152AE66F020027D78A /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = F760DE142AE66F020027D78A /* KeychainAccess */; }; + F760DE172AE66F350027D78A /* NCKeychain.swift in Sources */ = {isa = PBXBuildFile; fileRef = F760DE162AE66F350027D78A /* NCKeychain.swift */; }; + F760DE182AE66F350027D78A /* NCKeychain.swift in Sources */ = {isa = PBXBuildFile; fileRef = F760DE162AE66F350027D78A /* NCKeychain.swift */; }; + F760DE192AE66F350027D78A /* NCKeychain.swift in Sources */ = {isa = PBXBuildFile; fileRef = F760DE162AE66F350027D78A /* NCKeychain.swift */; }; + F760DE1A2AE66F350027D78A /* NCKeychain.swift in Sources */ = {isa = PBXBuildFile; fileRef = F760DE162AE66F350027D78A /* NCKeychain.swift */; }; + F760DE1B2AE66F350027D78A /* NCKeychain.swift in Sources */ = {isa = PBXBuildFile; fileRef = F760DE162AE66F350027D78A /* NCKeychain.swift */; }; + F760DE1C2AE66F350027D78A /* NCKeychain.swift in Sources */ = {isa = PBXBuildFile; fileRef = F760DE162AE66F350027D78A /* NCKeychain.swift */; }; + F760DE1D2AE66F350027D78A /* NCKeychain.swift in Sources */ = {isa = PBXBuildFile; fileRef = F760DE162AE66F350027D78A /* NCKeychain.swift */; }; F761856A29E98543006EB3B0 /* NCIntro.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F761856629E98543006EB3B0 /* NCIntro.storyboard */; }; F761856B29E98543006EB3B0 /* NCIntroViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F761856729E98543006EB3B0 /* NCIntroViewController.swift */; }; F761856C29E98543006EB3B0 /* NCIntroCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F761856829E98543006EB3B0 /* NCIntroCollectionViewCell.swift */; }; @@ -1053,6 +1070,7 @@ F75EDFBE1E8C116D00E6F369 /* libstdc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libstdc++.tbd"; path = "usr/lib/libstdc++.tbd"; sourceTree = SDKROOT; }; F760329D252F0F8E0015A421 /* NCTransferCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NCTransferCell.swift; path = iOSClient/Transfers/NCTransferCell.swift; sourceTree = SOURCE_ROOT; }; F760329E252F0F8E0015A421 /* NCTransferCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = NCTransferCell.xib; path = iOSClient/Transfers/NCTransferCell.xib; sourceTree = SOURCE_ROOT; }; + F760DE162AE66F350027D78A /* NCKeychain.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCKeychain.swift; sourceTree = ""; }; F761856629E98543006EB3B0 /* NCIntro.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = NCIntro.storyboard; sourceTree = ""; }; F761856729E98543006EB3B0 /* NCIntroViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCIntroViewController.swift; sourceTree = ""; }; F761856829E98543006EB3B0 /* NCIntroCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCIntroCollectionViewCell.swift; sourceTree = ""; }; @@ -1381,6 +1399,7 @@ F314F1112A30C11200BC7FAB /* PreviewSnapshots in Frameworks */, F710FC88277B7D3F00AA9FBF /* RealmSwift in Frameworks */, F7EBCDD3277B821700A4EF67 /* UICKeyChainStore in Frameworks */, + F760DE0F2AE66EE60027D78A /* KeychainAccess in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1397,6 +1416,7 @@ files = ( C04E2F1B2A17BAAB001BAD85 /* UICKeyChainStore in Frameworks */, C04E2F192A17BA78001BAD85 /* XLForm in Frameworks */, + F760DE152AE66F020027D78A /* KeychainAccess in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1408,6 +1428,7 @@ F30A963C2A2DFD3600D7BCFE /* SVGKit in Frameworks */, F30A96362A2DFCD000D7BCFE /* RealmSwift in Frameworks */, F30A96342A2DFCD000D7BCFE /* Realm in Frameworks */, + F760DE112AE66EF00027D78A /* KeychainAccess in Frameworks */, C03BA14C2A17BC60002C8BA3 /* UICKeyChainStore in Frameworks */, F30A963A2A2DFD3100D7BCFE /* JGProgressHUD in Frameworks */, C03BA14A2A17BC57002C8BA3 /* XLForm in Frameworks */, @@ -1422,6 +1443,7 @@ F31F695A2A2F89C400162F76 /* UICKeyChainStore in Frameworks */, F31F69582A2F89C400162F76 /* XLForm in Frameworks */, F31F69542A2F89C400162F76 /* SwiftRichString in Frameworks */, + F760DE132AE66EF80027D78A /* KeychainAccess in Frameworks */, F31F69662A2F929600162F76 /* PreviewSnapshotsTesting in Frameworks */, F31F695E2A2F89C400162F76 /* JGProgressHUD in Frameworks */, F31F69522A2F89C400162F76 /* SVGKit in Frameworks */, @@ -1439,6 +1461,7 @@ F7490E8929882CC8009DCE94 /* SwiftEntryKit in Frameworks */, F7490E7229882BB4009DCE94 /* RealmSwift in Frameworks */, F70716F929881CFA00E72C1D /* UICKeyChainStore in Frameworks */, + F760DE0D2AE66EDF0027D78A /* KeychainAccess in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1450,6 +1473,7 @@ F72AD70F28C24BA1006CB92D /* NextcloudKit in Frameworks */, F72CD01227A7E92400E59476 /* JGProgressHUD in Frameworks */, F77CB6A92AA08053000C3CA4 /* OpenSSL in Frameworks */, + F760DE092AE66ED00027D78A /* KeychainAccess in Frameworks */, F73ADD2126554F8E0069EA0D /* SwiftEntryKit in Frameworks */, F7A560482AE15D5000BE8FD6 /* Queuer in Frameworks */, F7EBCDCF277B81FF00A4EF67 /* UICKeyChainStore in Frameworks */, @@ -1467,6 +1491,7 @@ F7346E2528B0FEFA006CE2D2 /* UICKeyChainStore in Frameworks */, F783034428B5142B00B84583 /* NextcloudKit in Frameworks */, F7346E1328B0EF5B006CE2D2 /* SwiftUI.framework in Frameworks */, + F760DE052AE66EBE0027D78A /* KeychainAccess in Frameworks */, F7346E2928B0FFF2006CE2D2 /* RealmSwift in Frameworks */, F7A560462AE15D3D00BE8FD6 /* Queuer in Frameworks */, F783030D28B4C59A00B84583 /* SwiftEntryKit in Frameworks */, @@ -1481,6 +1506,7 @@ files = ( F7A560442AE15D2900BE8FD6 /* Queuer in Frameworks */, F7EBCDD1277B820D00A4EF67 /* UICKeyChainStore in Frameworks */, + F760DE0B2AE66ED80027D78A /* KeychainAccess in Frameworks */, F73ADD2426554FE20069EA0D /* SwiftEntryKit in Frameworks */, F710FC84277B7D3500AA9FBF /* RealmSwift in Frameworks */, F75379202AE2AD9400C0250E /* JGProgressHUD in Frameworks */, @@ -1499,6 +1525,7 @@ F7BB7E4727A18C56009B9F29 /* Parchment in Frameworks */, F734B06628E75C0100E180D5 /* TLPhotoPicker in Frameworks */, F787AC09298BCB4A0001BB00 /* SVGKitSwift in Frameworks */, + F760DE032AE66EA80027D78A /* KeychainAccess in Frameworks */, F770768E263A8C3400A1BA94 /* FloatingPanel in Frameworks */, F710FC7C277B7D0000AA9FBF /* RealmSwift in Frameworks */, F758A01227A7F03E0069468B /* JGProgressHUD in Frameworks */, @@ -1531,6 +1558,7 @@ F7A8D72E28F17764008BBE1C /* UICKeyChainStore in Frameworks */, F7A8D72428F1771B008BBE1C /* NextcloudKit in Frameworks */, F7C9739228F17131002C43E2 /* Intents.framework in Frameworks */, + F760DE072AE66EC70027D78A /* KeychainAccess in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2252,6 +2280,7 @@ F765608E23BF813500765969 /* NCContentPresenter.swift */, F70968A324212C4E00ED60E5 /* NCLivePhoto.swift */, F702F30725EE5D47008F8E80 /* NCPopupViewController.swift */, + F760DE162AE66F350027D78A /* NCKeychain.swift */, F707C26421A2DC5200F6181E /* NCStoreReview.swift */, AF817EF0274BC781009ED85B /* NCUserBaseUrl.swift */, F70BFC7320E0FA7C00C67599 /* NCUtility.swift */, @@ -2657,6 +2686,7 @@ F7EBCDD2277B821700A4EF67 /* UICKeyChainStore */, F72AD71028C24BBB006CB92D /* NextcloudKit */, F314F1102A30C11200BC7FAB /* PreviewSnapshots */, + F760DE0E2AE66EE60027D78A /* KeychainAccess */, ); productName = "Notification Service Extension"; productReference = 2C33C47F23E2C475005F963B /* Notification Service Extension.appex */; @@ -2697,6 +2727,7 @@ packageProductDependencies = ( C04E2F182A17BA78001BAD85 /* XLForm */, C04E2F1A2A17BAAB001BAD85 /* UICKeyChainStore */, + F760DE142AE66F020027D78A /* KeychainAccess */, ); productName = NextcloudUITests; productReference = C0046CDA2A17B98400D87C9D /* NextcloudUITests.xctest */; @@ -2724,6 +2755,7 @@ F30A96372A2DFD2900D7BCFE /* FirebaseDatabase */, F30A96392A2DFD3100D7BCFE /* JGProgressHUD */, F30A963B2A2DFD3600D7BCFE /* SVGKit */, + F760DE102AE66EF00027D78A /* KeychainAccess */, ); productName = NextcloudIntegrationTests; productReference = C04E2F202A17BB4D001BAD85 /* NextcloudIntegrationTests.xctest */; @@ -2754,6 +2786,7 @@ F31F695D2A2F89C400162F76 /* JGProgressHUD */, F31F69652A2F929600162F76 /* PreviewSnapshotsTesting */, F31F69682A2F92F000162F76 /* SnapshotTestingHEIC */, + F760DE122AE66EF80027D78A /* KeychainAccess */, ); productName = NextcloudSnapshotTests; productReference = F31F69422A2F6D4500162F76 /* NextcloudSnapshotTests.xctest */; @@ -2777,6 +2810,7 @@ F7490E7129882BB4009DCE94 /* RealmSwift */, F7490E8829882CC8009DCE94 /* SwiftEntryKit */, F7490E8A29882CE4009DCE94 /* NextcloudKit */, + F760DE0C2AE66EDF0027D78A /* KeychainAccess */, ); productName = "File Provider Extension UI"; productReference = F70716E32987F81500E72C1D /* File Provider Extension UI.appex */; @@ -2806,6 +2840,7 @@ F7F623B62A5EFA0C0022D3D4 /* Gzip */, F77CB6A82AA08053000C3CA4 /* OpenSSL */, F7A560472AE15D5000BE8FD6 /* Queuer */, + F760DE082AE66ED00027D78A /* KeychainAccess */, ); productName = "Share Ext"; productReference = F7CE8AFB1DC1F8D8009CAE48 /* Share.appex */; @@ -2832,6 +2867,7 @@ F787AC0A298BCB540001BB00 /* SVGKitSwift */, F7A560452AE15D3D00BE8FD6 /* Queuer */, F75379212AE2ADA100C0250E /* JGProgressHUD */, + F760DE042AE66EBE0027D78A /* KeychainAccess */, ); productName = DashboardWidgetExtension; productReference = F7346E1028B0EF5B006CE2D2 /* Widget.appex */; @@ -2857,6 +2893,7 @@ F72AD71228C24BCC006CB92D /* NextcloudKit */, F7A560432AE15D2900BE8FD6 /* Queuer */, F753791F2AE2AD9400C0250E /* JGProgressHUD */, + F760DE0A2AE66ED80027D78A /* KeychainAccess */, ); productName = "File Provider Extension"; productReference = F771E3D020E2392D00AFB62D /* File Provider Extension.appex */; @@ -2912,6 +2949,7 @@ F31F69632A2F929600162F76 /* PreviewSnapshots */, F7F623B42A5EF4D30022D3D4 /* Gzip */, F76B649D2ADFFDEC00014640 /* LRUCache */, + F760DE022AE66EA80027D78A /* KeychainAccess */, ); productName = "Crypto Cloud"; productReference = F7CE8AFA1DC1F8D8009CAE48 /* Nextcloud.app */; @@ -2934,6 +2972,7 @@ F7A8D72328F1771B008BBE1C /* NextcloudKit */, F7A8D72728F17728008BBE1C /* RealmSwift */, F7A8D72D28F17764008BBE1C /* UICKeyChainStore */, + F760DE062AE66EC70027D78A /* KeychainAccess */, ); productName = WidgetDashboardIntentHandler; productReference = F7C9739028F17131002C43E2 /* WidgetDashboardIntentHandler.appex */; @@ -3088,6 +3127,7 @@ F31F69672A2F92F000162F76 /* XCRemoteSwiftPackageReference "SnapshotTestingHEIC" */, F7F623B32A5EF4D30022D3D4 /* XCRemoteSwiftPackageReference "GzipSwift" */, F76B649A2ADFFAD200014640 /* XCRemoteSwiftPackageReference "LRUCache" */, + F760DE012AE66E860027D78A /* XCRemoteSwiftPackageReference "KeychainAccess" */, ); productRefGroup = F7F67B9F1A24D27800EE80DA; projectDirPath = ""; @@ -3358,6 +3398,7 @@ F343A4C12A1E734600DDA874 /* Optional+Extension.swift in Sources */, F7245927289BB59300474787 /* ThreadSafeDictionary.swift in Sources */, 2C33C48223E2C475005F963B /* NotificationService.swift in Sources */, + F760DE1D2AE66F350027D78A /* NCKeychain.swift in Sources */, AF4BF617275629E20081CEEF /* NCManageDatabase+Account.swift in Sources */, F7BF9D872934CA21009EE9A6 /* NCManageDatabase+LayoutForView.swift in Sources */, F749B64F297B0CBB00087535 /* NCManageDatabase+Share.swift in Sources */, @@ -3431,6 +3472,7 @@ F78E2D6A29AF02DB0024D4F3 /* Database.swift in Sources */, F7490E7429882BCC009DCE94 /* NCManageDatabase.swift in Sources */, F7490E6E29882B56009DCE94 /* NCBrand.swift in Sources */, + F760DE1C2AE66F350027D78A /* NCKeychain.swift in Sources */, F7490E8129882C79009DCE94 /* NCManageDatabase+DashboardWidget.swift in Sources */, F7490E8629882C99009DCE94 /* NCUtilityFileSystem.swift in Sources */, F763D2A22A249C4500A3C901 /* NCManageDatabase+Capabilities.swift in Sources */, @@ -3506,6 +3548,7 @@ F71459D21D12E3B700CAFEEC /* CCUtility.m in Sources */, F75A9EE723796C6F0044CFCE /* NCNetworking.swift in Sources */, AF730AFA27843E4C00B7520E /* NCShareExtension+NCDelegate.swift in Sources */, + F760DE1A2AE66F350027D78A /* NCKeychain.swift in Sources */, F749B64D297B0CBB00087535 /* NCManageDatabase+Share.swift in Sources */, F72FD3B8297ED49A00075D28 /* NCManageDatabase+E2EE.swift in Sources */, F7EDE4E0262D7BAF00414FE6 /* NCGridCell.swift in Sources */, @@ -3537,6 +3580,7 @@ buildActionMask = 2147483647; files = ( F78302FD28B4C42B00B84583 /* NCUserBaseUrl.swift in Sources */, + F760DE182AE66F350027D78A /* NCKeychain.swift in Sources */, F793E5A128B76541005E4B02 /* NotificationCenter+MainThread.swift in Sources */, F76DEE9928F808AF0041B1C9 /* LockscreenWidgetView.swift in Sources */, F7817D0029802D3D00FFBC65 /* NCViewCertificateDetails.swift in Sources */, @@ -3617,6 +3661,7 @@ F7D68FCF28CB9051009139F3 /* NCManageDatabase+DashboardWidget.swift in Sources */, F359D86B2A7D03420023F405 /* NCUtility+Exif.swift in Sources */, F7864AD02A78FE73004870E0 /* NCManageDatabase+LocalFile.swift in Sources */, + F760DE1B2AE66F350027D78A /* NCKeychain.swift in Sources */, AF4BF61B27562A4B0081CEEF /* NCManageDatabase+Metadata.swift in Sources */, F70460542499095400BB98A7 /* NotificationCenter+MainThread.swift in Sources */, F78A10C329322E8A008499B8 /* NCManageDatabase+Directory.swift in Sources */, @@ -3815,6 +3860,7 @@ F7CBC31C24F78E79004D3812 /* NCSortMenu.swift in Sources */, F769454822E9F20D000A798A /* NCShareNetworking.swift in Sources */, F749B64A297B0CBB00087535 /* NCManageDatabase+Share.swift in Sources */, + F760DE172AE66F350027D78A /* NCKeychain.swift in Sources */, F7C9555521F0C5470024296E /* NCActivity.swift in Sources */, F7725A60251F33BB00D125E0 /* NCFiles.swift in Sources */, F3BB46522A39EC4900461F6E /* NCMoreAppSuggestionsCell.swift in Sources */, @@ -3877,6 +3923,7 @@ F7A8D73828F17E21008BBE1C /* NCManageDatabase+DashboardWidget.swift in Sources */, F7A8D73928F17E25008BBE1C /* NCManageDatabase+Metadata.swift in Sources */, F343A4B52A1E084200DDA874 /* PHAsset+Extension.swift in Sources */, + F760DE192AE66F350027D78A /* NCKeychain.swift in Sources */, F72FD3B7297ED49A00075D28 /* NCManageDatabase+E2EE.swift in Sources */, F7A8D74128F18254008BBE1C /* UIColor+Extension.swift in Sources */, F7A8D73428F17E12008BBE1C /* NCDatabase.swift in Sources */, @@ -5016,6 +5063,14 @@ minimumVersion = 4.3.0; }; }; + F760DE012AE66E860027D78A /* XCRemoteSwiftPackageReference "KeychainAccess" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/kishikawakatsumi/KeychainAccess"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 4.0.0; + }; + }; F76B649A2ADFFAD200014640 /* XCRemoteSwiftPackageReference "LRUCache" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/nicklockwood/LRUCache"; @@ -5386,6 +5441,56 @@ package = F75EAED626D2552E00F4320E /* XCRemoteSwiftPackageReference "MarqueeLabel" */; productName = MarqueeLabel; }; + F760DE022AE66EA80027D78A /* KeychainAccess */ = { + isa = XCSwiftPackageProductDependency; + package = F760DE012AE66E860027D78A /* XCRemoteSwiftPackageReference "KeychainAccess" */; + productName = KeychainAccess; + }; + F760DE042AE66EBE0027D78A /* KeychainAccess */ = { + isa = XCSwiftPackageProductDependency; + package = F760DE012AE66E860027D78A /* XCRemoteSwiftPackageReference "KeychainAccess" */; + productName = KeychainAccess; + }; + F760DE062AE66EC70027D78A /* KeychainAccess */ = { + isa = XCSwiftPackageProductDependency; + package = F760DE012AE66E860027D78A /* XCRemoteSwiftPackageReference "KeychainAccess" */; + productName = KeychainAccess; + }; + F760DE082AE66ED00027D78A /* KeychainAccess */ = { + isa = XCSwiftPackageProductDependency; + package = F760DE012AE66E860027D78A /* XCRemoteSwiftPackageReference "KeychainAccess" */; + productName = KeychainAccess; + }; + F760DE0A2AE66ED80027D78A /* KeychainAccess */ = { + isa = XCSwiftPackageProductDependency; + package = F760DE012AE66E860027D78A /* XCRemoteSwiftPackageReference "KeychainAccess" */; + productName = KeychainAccess; + }; + F760DE0C2AE66EDF0027D78A /* KeychainAccess */ = { + isa = XCSwiftPackageProductDependency; + package = F760DE012AE66E860027D78A /* XCRemoteSwiftPackageReference "KeychainAccess" */; + productName = KeychainAccess; + }; + F760DE0E2AE66EE60027D78A /* KeychainAccess */ = { + isa = XCSwiftPackageProductDependency; + package = F760DE012AE66E860027D78A /* XCRemoteSwiftPackageReference "KeychainAccess" */; + productName = KeychainAccess; + }; + F760DE102AE66EF00027D78A /* KeychainAccess */ = { + isa = XCSwiftPackageProductDependency; + package = F760DE012AE66E860027D78A /* XCRemoteSwiftPackageReference "KeychainAccess" */; + productName = KeychainAccess; + }; + F760DE122AE66EF80027D78A /* KeychainAccess */ = { + isa = XCSwiftPackageProductDependency; + package = F760DE012AE66E860027D78A /* XCRemoteSwiftPackageReference "KeychainAccess" */; + productName = KeychainAccess; + }; + F760DE142AE66F020027D78A /* KeychainAccess */ = { + isa = XCSwiftPackageProductDependency; + package = F760DE012AE66E860027D78A /* XCRemoteSwiftPackageReference "KeychainAccess" */; + productName = KeychainAccess; + }; F76B649D2ADFFDEC00014640 /* LRUCache */ = { isa = XCSwiftPackageProductDependency; package = F76B649A2ADFFAD200014640 /* XCRemoteSwiftPackageReference "LRUCache" */; diff --git a/iOSClient/NCGlobal.swift b/iOSClient/NCGlobal.swift index 257b577638..73673ec41a 100644 --- a/iOSClient/NCGlobal.swift +++ b/iOSClient/NCGlobal.swift @@ -61,6 +61,13 @@ class NCGlobal: NSObject { return result.reduce(0, { $0 + $1 }) % maximum } + // ENUM + // + public enum TypeFilterScanDocument: String { + case document = "document" + case original = "original" + } + // Directory on Group // @objc let directoryProviderStorage = "File Provider Storage" diff --git a/iOSClient/Scan document/NCScan.swift b/iOSClient/Scan document/NCScan.swift index 9d817b1ed2..7169d74bfb 100755 --- a/iOSClient/Scan document/NCScan.swift +++ b/iOSClient/Scan document/NCScan.swift @@ -44,14 +44,8 @@ class NCScan: UIViewController, NCScanCellCellDelegate { internal var itemsDestination: [String] = [] internal let appDelegate = (UIApplication.shared.delegate as? AppDelegate)! - private var tipView: EasyTipView? - - enum TypeFilter { - case document - case original - } - internal var filter: TypeFilter = TypeFilter.document + internal var filter: NCGlobal.TypeFilterScanDocument = NCKeychain().typeFilterScanDocument // MARK: - View Life Cycle @@ -81,6 +75,11 @@ class NCScan: UIViewController, NCScanCellCellDelegate { segmentControlFilter.setTitle(NSLocalizedString("_filter_document_", comment: ""), forSegmentAt: 0) segmentControlFilter.setTitle(NSLocalizedString("_filter_original_", comment: ""), forSegmentAt: 1) + if filter == .document { + segmentControlFilter.selectedSegmentIndex = 0 + } else if filter == .original { + segmentControlFilter.selectedSegmentIndex = 1 + } add.setImage(UIImage(systemName: "plus")?.image(color: .label, size: 25), for: .normal) transferDown.setImage(UIImage(systemName: "arrow.down")?.image(color: .label, size: 25), for: .normal) @@ -220,6 +219,7 @@ class NCScan: UIViewController, NCScanCellCellDelegate { break } + NCKeychain().typeFilterScanDocument = filter collectionViewDestination.reloadData() } diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift new file mode 100644 index 0000000000..455db3ccfe --- /dev/null +++ b/iOSClient/Utility/NCKeychain.swift @@ -0,0 +1,43 @@ +// +// NCKeychain.swift +// Nextcloud +// +// Created by Marino Faggiana on 23/10/23. +// Copyright © 2023 Marino Faggiana. All rights reserved. +// +// Author Marino Faggiana +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +import Foundation +import KeychainAccess + +class NCKeychain { + + let keychain = Keychain(service: "com.nextcloud.keychain") + + var typeFilterScanDocument: NCGlobal.TypeFilterScanDocument { + get { + if let rawValue = try? keychain.get("ScanDocumentTypeFilter"), let result = NCGlobal.TypeFilterScanDocument(rawValue: rawValue) { + return result + } else { + return .original + } + } + set { + keychain["ScanDocumentTypeFilter"] = newValue.rawValue + } + } +} From c837268cad3b623f67d8e4a077085f4b64e98090 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Mon, 23 Oct 2023 15:02:56 +0200 Subject: [PATCH 21/90] fix media: symbol live photo Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> --- .../Data/NCManageDatabase+Metadata.swift | 17 ---------------- iOSClient/Media/NCMedia.swift | 3 +-- iOSClient/Media/NCMediaCache.swift | 20 ++++++++++--------- 3 files changed, 12 insertions(+), 28 deletions(-) diff --git a/iOSClient/Data/NCManageDatabase+Metadata.swift b/iOSClient/Data/NCManageDatabase+Metadata.swift index 340550c53f..2c2da462ae 100644 --- a/iOSClient/Data/NCManageDatabase+Metadata.swift +++ b/iOSClient/Data/NCManageDatabase+Metadata.swift @@ -1250,21 +1250,4 @@ extension NCManageDatabase { NextcloudKit.shared.nkCommonInstance.writeLog("Could not access database: \(error)") } } - - func getMediaOcIdEtag(account: String) -> [String: String] { - - let predicate = NSPredicate(format: "account == %@ AND (classFile == %@ OR classFile == %@)", account, NKCommon.TypeClassFile.image.rawValue, NKCommon.TypeClassFile.video.rawValue) - var results: [String: String] = [:] - - do { - let realm = try Realm() - for result in realm.objects(tableMetadata.self).filter(predicate) { - results[result.ocId] = result.etag - } - } catch let error { - NextcloudKit.shared.nkCommonInstance.writeLog("Could not write to database: \(error)") - } - - return results - } } diff --git a/iOSClient/Media/NCMedia.swift b/iOSClient/Media/NCMedia.swift index 70e7bc21a3..af0d730c1e 100644 --- a/iOSClient/Media/NCMedia.swift +++ b/iOSClient/Media/NCMedia.swift @@ -56,7 +56,6 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate { private var lastContentOffsetY: CGFloat = 0 private var mediaPath = "" - private var livePhoto: Bool = false private var timeIntervalSearchNewMedia: TimeInterval = 3.0 private var timerSearchNewMedia: Timer? @@ -407,7 +406,7 @@ extension NCMedia: UICollectionViewDataSource { if metadata.isAudioOrVideo { cell.imageStatus.image = cacheImages.cellPlayImage - } else if metadata.livePhoto && livePhoto { + } else if metadata.livePhoto && NCMediaCache.shared.livePhoto { cell.imageStatus.image = cacheImages.cellLivePhotoImage } diff --git a/iOSClient/Media/NCMediaCache.swift b/iOSClient/Media/NCMediaCache.swift index 9e53e231d2..407e30216c 100644 --- a/iOSClient/Media/NCMediaCache.swift +++ b/iOSClient/Media/NCMediaCache.swift @@ -37,19 +37,18 @@ import NextcloudKit private lazy var cache: ThumbnailLRUCache = { return ThumbnailLRUCache(countLimit: limit) }() + private var ocIdEtag: [String: String] = [:] public var metadatas: [tableMetadata] = [] public var predicateDefault: NSPredicate? public var predicate: NSPredicate? + public var livePhoto: Bool = false func createCache(account: String) { - let resultsMedia = NCManageDatabase.shared.getMediaOcIdEtag(account: account) - guard !resultsMedia.isEmpty, - let directory = CCUtility.getDirectoryProviderStorage() else { return } - metadatas.removeAll() getMetadatasMedia(account: account) + guard !metadatas.isEmpty, let directory = CCUtility.getDirectoryProviderStorage() else { return } let ext = ".preview.ico" let manager = FileManager.default let resourceKeys = Set([.nameKey, .pathKey, .fileSizeKey, .creationDateKey]) @@ -61,6 +60,10 @@ import NextcloudKit var files: [FileInfo] = [] let startDate = Date() + for metadata in metadatas { + ocIdEtag[metadata.ocId] = metadata.etag + } + if let enumerator = manager.enumerator(at: URL(fileURLWithPath: directory), includingPropertiesForKeys: [.isRegularFileKey], options: [.skipsHiddenFiles]) { for case let fileURL as URL in enumerator where fileURL.lastPathComponent.hasSuffix(ext) { let fileName = fileURL.lastPathComponent @@ -69,7 +72,7 @@ import NextcloudKit let size = resourceValues.fileSize, size > 0, let date = resourceValues.creationDate, - let etag = resultsMedia[ocId], + let etag = ocIdEtag[ocId], fileName == etag + ext else { continue } files.append(FileInfo(path: fileURL, ocId: ocId, date: date)) } @@ -118,10 +121,8 @@ import NextcloudKit func getMetadatasMedia(account: String, filterClassTypeImage: Bool = false, filterClassTypeVideo: Bool = false) { - let livePhoto = CCUtility.getLivePhoto() - guard let appDelegate = (UIApplication.shared.delegate as? AppDelegate), - let account = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", account)) else { return } - let startServerUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, userId: appDelegate.userId) + account.mediaPath + guard let account = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", account)) else { return } + let startServerUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: account.urlBase, userId: account.userId) + account.mediaPath predicateDefault = NSPredicate(format: "account == %@ AND serverUrl BEGINSWITH %@ AND (classFile == %@ OR classFile == %@) AND NOT (session CONTAINS[c] 'upload')", account.account, startServerUrl, NKCommon.TypeClassFile.image.rawValue, NKCommon.TypeClassFile.video.rawValue) @@ -135,6 +136,7 @@ import NextcloudKit guard let predicate = predicate else { return } + livePhoto = CCUtility.getLivePhoto() metadatas = NCManageDatabase.shared.getMetadatasMedia(predicate: predicate, livePhoto: livePhoto) switch CCUtility.getMediaSortDate() { From 7001b4a8197803898e82ccac6c98e0542feee285 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Mon, 23 Oct 2023 15:05:58 +0200 Subject: [PATCH 22/90] lint Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> --- iOSClient/Media/NCMedia.swift | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/iOSClient/Media/NCMedia.swift b/iOSClient/Media/NCMedia.swift index af0d730c1e..39d53defe7 100644 --- a/iOSClient/Media/NCMedia.swift +++ b/iOSClient/Media/NCMedia.swift @@ -489,10 +489,8 @@ extension NCMedia { } var lessDate = Date() - if let predicate = NCMediaCache.shared.predicateDefault { - if let metadata = NCManageDatabase.shared.getMetadata(predicate: predicate, sorted: "date", ascending: true) { - lessDate = metadata.date as Date - } + if let predicate = NCMediaCache.shared.predicateDefault, let metadata = NCManageDatabase.shared.getMetadata(predicate: predicate, sorted: "date", ascending: true) { + lessDate = metadata.date as Date } var greaterDate: Date From e02b5f5c32ebfebe9ff3b70d030e62bd963c8068 Mon Sep 17 00:00:00 2001 From: Nextcloud bot Date: Tue, 24 Oct 2023 02:43:07 +0000 Subject: [PATCH 23/90] Fix(l10n): Update translations from Transifex Signed-off-by: Nextcloud bot --- .../de.lproj/Localizable.strings | Bin 131714 -> 131722 bytes .../fr.lproj/Localizable.strings | Bin 134014 -> 134094 bytes .../sr.lproj/Localizable.strings | Bin 124154 -> 124178 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/iOSClient/Supporting Files/de.lproj/Localizable.strings b/iOSClient/Supporting Files/de.lproj/Localizable.strings index 40469f3292754581aa5fbf81cbc8b163f0bf4f7f..12479b0dff50492d7d5b00ba4e0e39b5331f7a67 100644 GIT binary patch delta 34 qcmZo_<>+eV*q{;V;Z{gE}J%;X=u zV$-kuViagzlCXVA0^_ru$rl!JOy0mDG~MF?BhU0@Zy8%o#Wp$jtv1(lMiUJDCaWdGn6r;GAJZe`f+MO5Gm(jMF1u0PgVvu+dkw$I~3O&OT5CF6+6=*^+*a0B3GJ)pk y0L>|7C;&Ssks$@hO9P67R4M@JJRn&Bwx Date: Mon, 23 Oct 2023 14:40:16 +0200 Subject: [PATCH 24/90] cod --- iOSClient/Utility/CCUtility.m | 21 --------------------- iOSClient/Utility/NCKeychain.swift | 23 +++++++++++++++++++++-- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 94497fcded..fef9ce09f5 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -63,27 +63,6 @@ + (void)storeAllChainInService #pragma ------------------------------ GET/SET -+ (NSString *)getPasscode -{ - return [UICKeyChainStore stringForKey:@"passcodeBlock" service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (void)setPasscode:(NSString *)passcode -{ - [UICKeyChainStore setString:passcode forKey:@"passcodeBlock" service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (BOOL)getNotPasscodeAtStart -{ - return [[UICKeyChainStore stringForKey:@"notPasscodeAtStart" service:NCGlobal.shared.serviceShareKeyChain] boolValue]; -} - -+ (void)setNotPasscodeAtStart:(BOOL)set -{ - NSString *sSet = (set) ? @"true" : @"false"; - [UICKeyChainStore setString:sSet forKey:@"notPasscodeAtStart" service:NCGlobal.shared.serviceShareKeyChain]; -} - + (BOOL)getEnableTouchFaceID { NSString *valueString = [UICKeyChainStore stringForKey:@"enableTouchFaceID" service:NCGlobal.shared.serviceShareKeyChain]; diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index 455db3ccfe..05dc8cec16 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -27,11 +27,12 @@ import KeychainAccess class NCKeychain { let keychain = Keychain(service: "com.nextcloud.keychain") + let keychainOLD = Keychain(service: NCGlobal.shared.serviceShareKeyChain) var typeFilterScanDocument: NCGlobal.TypeFilterScanDocument { get { - if let rawValue = try? keychain.get("ScanDocumentTypeFilter"), let result = NCGlobal.TypeFilterScanDocument(rawValue: rawValue) { - return result + if let rawValue = try? keychain.get("ScanDocumentTypeFilter"), let value = NCGlobal.TypeFilterScanDocument(rawValue: rawValue) { + return value } else { return .original } @@ -40,4 +41,22 @@ class NCKeychain { keychain["ScanDocumentTypeFilter"] = newValue.rawValue } } + + var passcode: String { + get { + /* MIGRATION OLD */ + if let value = keychainOLD["passcodeBlock"], !value.isEmpty { + keychain["passcodeBlock"] = value + keychainOLD["passcodeBlock"] = nil + } + if let value = try? keychain.get("passcodeBlock") { + return value + } else { + return "" + } + } + set { + keychain["passcodeBlock"] = newValue + } + } } From 23baea08d9b4a5a588f4e55fc289703f74445a80 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Mon, 23 Oct 2023 16:22:09 +0200 Subject: [PATCH 25/90] coding --- .../FileProviderExtension.swift | 2 +- iOSClient/AppDelegate.swift | 7 +-- iOSClient/Settings/NCManageE2EE.swift | 8 ++-- iOSClient/Settings/NCSettings.m | 42 +++++++++--------- iOSClient/Utility/CCUtility.h | 8 ---- iOSClient/Utility/CCUtility.m | 6 --- iOSClient/Utility/NCKeychain.swift | 43 ++++++++++++++----- 7 files changed, 63 insertions(+), 53 deletions(-) diff --git a/File Provider Extension/FileProviderExtension.swift b/File Provider Extension/FileProviderExtension.swift index 5e7c5a469f..0450da4127 100644 --- a/File Provider Extension/FileProviderExtension.swift +++ b/File Provider Extension/FileProviderExtension.swift @@ -78,7 +78,7 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate { if containerItemIdentifier != NSFileProviderItemIdentifier.workingSet { if fileProviderData.shared.setupAccount(domain: domain, providerExtension: self) == nil { 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)]) } else if CCUtility.getDisableFilesApp() || NCBrandOptions.shared.disable_openin_file { throw NSError(domain: NSFileProviderErrorDomain, code: NSFileProviderError.notAuthenticated.rawValue, userInfo: ["code": NSNumber(value: NCGlobal.shared.errorDisableFilesApp)]) diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index ee160135a7..fb242f834e 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -714,7 +714,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD defer { self.requestAccount() } 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) showPrivacyProtectionWindow() @@ -747,7 +747,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD func enableTouchFaceID() { guard !account.isEmpty, CCUtility.getEnableTouchFaceID(), - CCUtility.isPasscodeAtStartEnabled(), + NCKeychain().passcode != nil, + NCKeychain().requestPasscodeAtStart, let passcodeViewController = privacyProtectionWindow?.rootViewController?.presentedViewController as? TOPasscodeViewController else { return } @@ -775,7 +776,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD } func passcodeViewController(_ passcodeViewController: TOPasscodeViewController, isCorrectCode code: String) -> Bool { - return code == CCUtility.getPasscode() + return code == NCKeychain().passcode } func didPerformBiometricValidationRequest(in passcodeViewController: TOPasscodeViewController) { diff --git a/iOSClient/Settings/NCManageE2EE.swift b/iOSClient/Settings/NCManageE2EE.swift index 77b3bd38c8..3c0de5b95a 100644 --- a/iOSClient/Settings/NCManageE2EE.swift +++ b/iOSClient/Settings/NCManageE2EE.swift @@ -136,7 +136,7 @@ class NCManageE2EE: NSObject, ObservableObject, NCEndToEndInitializeDelegate, TO func passcodeViewController(_ passcodeViewController: TOPasscodeViewController, isCorrectCode code: String) -> Bool { - if code == CCUtility.getPasscode() { + if code == NCKeychain().passcode { DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { self.correctPasscode() } @@ -202,7 +202,7 @@ struct NCViewE2EE: View { } .contentShape(Rectangle()) .onTapGesture { - if let passcode = CCUtility.getPasscode(), !passcode.isEmpty { + if let passcode = NCKeychain().passcode { manageE2EE.requestPasscodeType("readPassphrase") } else { NCContentPresenter.shared.showInfo(error: NKError(errorCode: 0, errorDescription: "_e2e_settings_lock_not_active_")) @@ -222,7 +222,7 @@ struct NCViewE2EE: View { } .contentShape(Rectangle()) .onTapGesture { - if let passcode = CCUtility.getPasscode(), !passcode.isEmpty { + if let passcode = NCKeychain().passcode { manageE2EE.requestPasscodeType("removeLocallyEncryption") } else { NCContentPresenter.shared.showInfo(error: NKError(errorCode: 0, errorDescription: "_e2e_settings_lock_not_active_")) @@ -252,7 +252,7 @@ struct NCViewE2EE: View { } .contentShape(Rectangle()) .onTapGesture { - if let passcode = CCUtility.getPasscode(), !passcode.isEmpty { + if let passcode = NCKeychain().passcode { manageE2EE.requestPasscodeType("startE2E") } else { NCContentPresenter.shared.showInfo(error: NKError(errorCode: 0, errorDescription: "_e2e_settings_lock_not_active_")) diff --git a/iOSClient/Settings/NCSettings.m b/iOSClient/Settings/NCSettings.m index 2a1bfdc896..20f489917a 100644 --- a/iOSClient/Settings/NCSettings.m +++ b/iOSClient/Settings/NCSettings.m @@ -265,7 +265,7 @@ - (void)reloadForm // ------------------------------------------------------------------ - if ([[CCUtility getPasscode] length]) { + if ([[NCKeychain alloc] init].passcode) { rowBloccoPasscode.title = NSLocalizedString(@"_lock_active_", nil); [rowBloccoPasscode.cellConfig setObject:[[UIImage imageNamed:@"lock"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"]; } else { @@ -274,7 +274,7 @@ - (void)reloadForm } if ([CCUtility getEnableTouchFaceID]) [rowEnableTouchDaceID setValue:@1]; else [rowEnableTouchDaceID setValue:@0]; - if ([CCUtility getNotPasscodeAtStart]) [rowNotPasscodeAtStart setValue:@1]; else [rowNotPasscodeAtStart setValue:@0]; + if ([[NCKeychain alloc] init].requestPasscodeAtStart) [rowNotPasscodeAtStart setValue:@0]; else [rowNotPasscodeAtStart setValue:@1]; if ([CCUtility getPrivacyScreenEnabled]) [rowPrivacyScreen setValue:@1]; else [rowPrivacyScreen setValue:@0]; @@ -292,9 +292,9 @@ - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor ol if ([rowDescriptor.tag isEqualToString:@"notPasscodeAtStart"]) { if ([[rowDescriptor.value valueData] boolValue] == YES) { - [CCUtility setNotPasscodeAtStart:true]; + [[NCKeychain alloc] init].requestPasscodeAtStart = false; } else { - [CCUtility setNotPasscodeAtStart:false]; + [[NCKeychain alloc] init].requestPasscodeAtStart = true; } } @@ -370,7 +370,7 @@ - (void)didPerformBiometricValidationRequestInPasscodeViewController:(TOPasscode [[LAContext new] evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:[[NCBrandOptions shared] brand] reply:^(BOOL success, NSError * _Nullable error) { if (success) { 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]; [self reloadForm]; }); @@ -380,7 +380,7 @@ - (void)didPerformBiometricValidationRequestInPasscodeViewController:(TOPasscode - (void)passcodeSettingsViewController:(TOPasscodeSettingsViewController *)passcodeSettingsViewController didChangeToNewPasscode:(NSString *)passcode ofType:(TOPasscodeType)type { - [CCUtility setPasscode:passcode]; + [[NCKeychain alloc] init].passcode = passcode; [passcodeSettingsViewController dismissViewControllerAnimated:YES completion:nil]; [self reloadForm]; @@ -393,8 +393,8 @@ - (void)didTapCancelInPasscodeViewController:(TOPasscodeViewController *)passcod - (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]; return YES; @@ -410,22 +410,12 @@ - (void)passcode:(XLFormRowDescriptor *)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.delegate = self; passcodeViewController.keypadButtonShowLettering = false; - + if (CCUtility.getEnableTouchFaceID && [laContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) { if (error == NULL) { if (laContext.biometryType == LABiometryTypeFaceID) { @@ -443,6 +433,16 @@ - (void)passcode:(XLFormRowDescriptor *)sender } [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]; } } diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 51f7516cac..2e729d0f40 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -42,17 +42,9 @@ + (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; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index fef9ce09f5..58d938ea2a 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -82,12 +82,6 @@ + (void)setEnableTouchFaceID:(BOOL)set [UICKeyChainStore setString:sSet forKey:@"enableTouchFaceID" service:NCGlobal.shared.serviceShareKeyChain]; } -+ (BOOL)isPasscodeAtStartEnabled -{ - if ([self getPasscode].length > 0 && ![self getNotPasscodeAtStart]) return true; - else return false; -} - + (NSString *)getGroupBySettings { NSString *groupby = [UICKeyChainStore stringForKey:@"groupby" service:NCGlobal.shared.serviceShareKeyChain]; diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index 05dc8cec16..c8a7296a9e 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -24,10 +24,17 @@ import Foundation import KeychainAccess -class NCKeychain { +@objc class NCKeychain: NSObject { let keychain = Keychain(service: "com.nextcloud.keychain") - let keychainOLD = Keychain(service: NCGlobal.shared.serviceShareKeyChain) + + private func migrate(key: String) { + let keychainOLD = Keychain(service: NCGlobal.shared.serviceShareKeyChain) + if let value = keychainOLD[key], !value.isEmpty { + keychain[key] = value + keychainOLD[key] = nil + } + } var typeFilterScanDocument: NCGlobal.TypeFilterScanDocument { get { @@ -42,21 +49,37 @@ class NCKeychain { } } - var passcode: String { + @objc var passcode: String? { get { - /* MIGRATION OLD */ - if let value = keychainOLD["passcodeBlock"], !value.isEmpty { - keychain["passcodeBlock"] = value - keychainOLD["passcodeBlock"] = nil - } + migrate(key: "passcodeBlock") if let value = try? keychain.get("passcodeBlock") { return value - } else { - return "" } + return nil } set { keychain["passcodeBlock"] = newValue } } + + @objc var requestPasscodeAtStart: Bool { + get { + let keychainOLD = Keychain(service: NCGlobal.shared.serviceShareKeyChain) + if let value = keychainOLD["notPasscodeAtStart"], !value.isEmpty { + if value == "true" { + keychain["requestPasscodeAtStart"] = "false" + } else if value == "false" { + keychain["requestPasscodeAtStart"] = "true" + } + keychainOLD["notPasscodeAtStart"] = nil + } + if let value = try? keychain.get("requestPasscodeAtStart"), let result = Bool(value) { + return result + } + return false + } + set { + keychain["requestPasscodeAtStart"] = String(newValue) + } + } } From 3cb5f13198cea62ab7f307e290b22313885dcc43 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Mon, 23 Oct 2023 16:30:02 +0200 Subject: [PATCH 26/90] enableTouchFaceID --- iOSClient/AppDelegate.swift | 4 ++-- iOSClient/Settings/NCManageE2EE.swift | 2 +- iOSClient/Settings/NCSettings.m | 8 ++++---- iOSClient/Utility/CCUtility.h | 3 --- iOSClient/Utility/CCUtility.m | 19 ------------------- iOSClient/Utility/NCKeychain.swift | 13 +++++++++++++ 6 files changed, 20 insertions(+), 29 deletions(-) diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index fb242f834e..c5d19e3e55 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -722,7 +722,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD let passcodeViewController = TOPasscodeViewController(passcodeType: .sixDigits, allowCancel: false) passcodeViewController.delegate = self passcodeViewController.keypadButtonShowLettering = false - if CCUtility.getEnableTouchFaceID() && laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) { + if NCKeychain().touchFaceID, laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) { if error == nil { if laContext.biometryType == .faceID { passcodeViewController.biometryType = .faceID @@ -746,7 +746,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD func enableTouchFaceID() { guard !account.isEmpty, - CCUtility.getEnableTouchFaceID(), + NCKeychain().touchFaceID, NCKeychain().passcode != nil, NCKeychain().requestPasscodeAtStart, let passcodeViewController = privacyProtectionWindow?.rootViewController?.presentedViewController as? TOPasscodeViewController diff --git a/iOSClient/Settings/NCManageE2EE.swift b/iOSClient/Settings/NCManageE2EE.swift index 3c0de5b95a..4dbe6ed237 100644 --- a/iOSClient/Settings/NCManageE2EE.swift +++ b/iOSClient/Settings/NCManageE2EE.swift @@ -88,7 +88,7 @@ class NCManageE2EE: NSObject, ObservableObject, NCEndToEndInitializeDelegate, TO let passcodeViewController = TOPasscodeViewController(passcodeType: .sixDigits, allowCancel: true) passcodeViewController.delegate = self passcodeViewController.keypadButtonShowLettering = false - if CCUtility.getEnableTouchFaceID() && laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) { + if NCKeychain().touchFaceID, laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) { if error == nil { if laContext.biometryType == .faceID { passcodeViewController.biometryType = .faceID diff --git a/iOSClient/Settings/NCSettings.m b/iOSClient/Settings/NCSettings.m index 20f489917a..f663edb555 100644 --- a/iOSClient/Settings/NCSettings.m +++ b/iOSClient/Settings/NCSettings.m @@ -273,7 +273,7 @@ - (void)reloadForm [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 ([[NCKeychain alloc] init].touchFaceID) [rowEnableTouchDaceID setValue:@1]; else [rowEnableTouchDaceID setValue:@0]; if ([[NCKeychain alloc] init].requestPasscodeAtStart) [rowNotPasscodeAtStart setValue:@0]; else [rowNotPasscodeAtStart setValue:@1]; if ([CCUtility getPrivacyScreenEnabled]) [rowPrivacyScreen setValue:@1]; else [rowPrivacyScreen setValue:@0]; @@ -301,9 +301,9 @@ - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor ol if ([rowDescriptor.tag isEqualToString:@"enableTouchDaceID"]) { if ([[rowDescriptor.value valueData] boolValue] == YES) { - [CCUtility setEnableTouchFaceID:true]; + [[NCKeychain alloc] init].touchFaceID = true; } else { - [CCUtility setEnableTouchFaceID:false]; + [[NCKeychain alloc] init].touchFaceID = false; } } @@ -416,7 +416,7 @@ - (void)passcode:(XLFormRowDescriptor *)sender passcodeViewController.delegate = self; 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 (laContext.biometryType == LABiometryTypeFaceID) { passcodeViewController.biometryType = TOPasscodeBiometryTypeFaceID; diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 2e729d0f40..68abb123b1 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -42,9 +42,6 @@ + (void)deleteAllChainStore; + (void)storeAllChainInService; -+ (BOOL)getEnableTouchFaceID; -+ (void)setEnableTouchFaceID:(BOOL)set; - + (NSString *)getGroupBySettings; + (void)setGroupBySettings:(NSString *)groupby; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 58d938ea2a..867b46aa44 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -63,25 +63,6 @@ + (void)storeAllChainInService #pragma ------------------------------ GET/SET -+ (BOOL)getEnableTouchFaceID -{ - NSString *valueString = [UICKeyChainStore stringForKey:@"enableTouchFaceID" service:NCGlobal.shared.serviceShareKeyChain]; - - // Default TRUE - if (valueString == nil) { - [self setEnableTouchFaceID:YES]; - return true; - } - - return [valueString boolValue]; -} - -+ (void)setEnableTouchFaceID:(BOOL)set -{ - NSString *sSet = (set) ? @"true" : @"false"; - [UICKeyChainStore setString:sSet forKey:@"enableTouchFaceID" service:NCGlobal.shared.serviceShareKeyChain]; -} - + (NSString *)getGroupBySettings { NSString *groupby = [UICKeyChainStore stringForKey:@"groupby" service:NCGlobal.shared.serviceShareKeyChain]; diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index c8a7296a9e..2dd84bf921 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -82,4 +82,17 @@ import KeychainAccess keychain["requestPasscodeAtStart"] = String(newValue) } } + + @objc var touchFaceID: Bool { + get { + migrate(key: "enableTouchFaceID") + if let value = try? keychain.get("enableTouchFaceID"), let result = Bool(value) { + return result + } + return false + } + set { + keychain["enableTouchFaceID"] = String(newValue) + } + } } From d7adcf29e7b3456c62966eb48db0bbd41e681bf9 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Mon, 23 Oct 2023 17:12:37 +0200 Subject: [PATCH 27/90] intro, incrementalNumber, removeAll() --- Share/NCShareExtension+Files.swift | 3 +- iOSClient/AppDelegate.swift | 5 +- iOSClient/Extensions/PHAsset+Extension.swift | 2 +- iOSClient/Login/NCLogin.swift | 4 +- iOSClient/Login/NCLoginWeb.swift | 4 +- iOSClient/Main/NCActionCenter.swift | 2 +- iOSClient/Settings/CCAdvanced.m | 1 + .../Settings/NCSettingsBundleHelper.swift | 1 + iOSClient/Utility/CCUtility.h | 9 --- iOSClient/Utility/CCUtility.m | 72 +------------------ iOSClient/Utility/NCKeychain.swift | 28 ++++++++ iOSClient/Utility/NCUtility.swift | 1 + 12 files changed, 43 insertions(+), 89 deletions(-) diff --git a/Share/NCShareExtension+Files.swift b/Share/NCShareExtension+Files.swift index 8b9d76d161..cff4fb2f86 100644 --- a/Share/NCShareExtension+Files.swift +++ b/Share/NCShareExtension+Files.swift @@ -118,7 +118,8 @@ class NCFilesExtensionHandler { if let url = item as? URL, url.isFileURL, !url.lastPathComponent.isEmpty { 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)" } } diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index c5d19e3e55..db2eb9a121 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -140,6 +140,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD } else { CCUtility.deleteAllChainStore() + NCKeychain().removeAll() if let bundleID = Bundle.main.bundleIdentifier { UserDefaults.standard.removePersistentDomain(forName: bundleID) } @@ -170,12 +171,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD // Intro if NCBrandOptions.shared.disable_intro { - CCUtility.setIntro(true) + NCKeychain().intro = true if account.isEmpty { openLogin(viewController: nil, selector: NCGlobal.shared.introLogin, openLoginWeb: false) } } else { - if !CCUtility.getIntro() { + if !NCKeychain().intro { if let viewController = UIStoryboard(name: "NCIntro", bundle: nil).instantiateInitialViewController() { let navigationController = NCLoginNavigationController(rootViewController: viewController) window?.rootViewController = navigationController diff --git a/iOSClient/Extensions/PHAsset+Extension.swift b/iOSClient/Extensions/PHAsset+Extension.swift index c2031dc57e..cefb6b0080 100644 --- a/iOSClient/Extensions/PHAsset+Extension.swift +++ b/iOSClient/Extensions/PHAsset+Extension.swift @@ -30,7 +30,7 @@ extension PHAsset { return resource.originalFilename as NSString } else { return self.value(forKey: "filename") as? NSString - ?? ("IMG_" + CCUtility.getIncrementalNumber() + getExtension()) as NSString + ?? ("IMG_" + NCKeychain().incrementalNumber + getExtension()) as NSString } } diff --git a/iOSClient/Login/NCLogin.swift b/iOSClient/Login/NCLogin.swift index 4e8822568f..965e2066d1 100644 --- a/iOSClient/Login/NCLogin.swift +++ b/iOSClient/Login/NCLogin.swift @@ -407,10 +407,10 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate { self.appDelegate.changeAccount(account, userProfile: userProfile) - if CCUtility.getIntro() { + if NCKeychain().intro { self.dismiss(animated: true) } else { - CCUtility.setIntro(true) + NCKeychain().intro = true if self.presentingViewController == nil { let viewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController() viewController?.modalPresentationStyle = .fullScreen diff --git a/iOSClient/Login/NCLoginWeb.swift b/iOSClient/Login/NCLoginWeb.swift index 6d98d3e3cf..61098ea4cb 100644 --- a/iOSClient/Login/NCLoginWeb.swift +++ b/iOSClient/Login/NCLoginWeb.swift @@ -303,10 +303,10 @@ extension NCLoginWeb: WKNavigationDelegate { self.appDelegate.changeAccount(account, userProfile: userProfile) - if CCUtility.getIntro() { + if NCKeychain().intro { self.dismiss(animated: true) } else { - CCUtility.setIntro(true) + NCKeychain().intro = true if self.presentingViewController == nil { if let viewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController() { viewController.modalPresentationStyle = .fullScreen diff --git a/iOSClient/Main/NCActionCenter.swift b/iOSClient/Main/NCActionCenter.swift index 9000bb5904..ce196437ac 100644 --- a/iOSClient/Main/NCActionCenter.swift +++ b/iOSClient/Main/NCActionCenter.swift @@ -523,7 +523,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec guard !results.ext.isEmpty, let data = UIPasteboard.general.data(forPasteboardType: item.key, inItemSet: IndexSet([index]))?.first else { continue } - let fileName = results.name + "_" + CCUtility.getIncrementalNumber() + "." + results.ext + let fileName = results.name + "_" + NCKeychain().incrementalNumber + "." + results.ext let serverUrlFileName = serverUrl + "/" + fileName let ocIdUpload = UUID().uuidString let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(ocIdUpload, fileNameView: fileName)! diff --git a/iOSClient/Settings/CCAdvanced.m b/iOSClient/Settings/CCAdvanced.m index 592502ad78..e3619fceea 100755 --- a/iOSClient/Settings/CCAdvanced.m +++ b/iOSClient/Settings/CCAdvanced.m @@ -466,6 +466,7 @@ - (void)exitNextcloud:(XLFormRowDescriptor *)sender [CCUtility removeTemporaryDirectory]; [CCUtility deleteAllChainStore]; + [[[NCKeychain alloc] init] removeAll]; exit(0); }); diff --git a/iOSClient/Settings/NCSettingsBundleHelper.swift b/iOSClient/Settings/NCSettingsBundleHelper.swift index 6af3636074..262a4d747c 100644 --- a/iOSClient/Settings/NCSettingsBundleHelper.swift +++ b/iOSClient/Settings/NCSettingsBundleHelper.swift @@ -48,6 +48,7 @@ class NCSettingsBundleHelper: NSObject { CCUtility.removeTemporaryDirectory() CCUtility.deleteAllChainStore() + NCKeychain().removeAll() NCManageDatabase.shared.removeDB() DispatchQueue.main.asyncAfter(deadline: .now() + delay) { diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 68abb123b1..d75ee564b5 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -40,15 +40,6 @@ // GET/SET + (void)deleteAllChainStore; -+ (void)storeAllChainInService; - -+ (NSString *)getGroupBySettings; -+ (void)setGroupBySettings:(NSString *)groupby; - -+ (BOOL)getIntro; -+ (void)setIntro:(BOOL)set; - -+ (NSString *)getIncrementalNumber; + (NSString *)getAccountExt; + (void)setAccountExt:(NSString *)account; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 867b46aa44..8a70015cf1 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -48,78 +48,8 @@ + (void)deleteAllChainStore [UICKeyChainStore removeAllItemsForService:NCGlobal.shared.serviceShareKeyChain]; } -+ (void)storeAllChainInService -{ - UICKeyChainStore *store = [UICKeyChainStore keyChainStore]; - - NSArray *items = store.allItems; - - for (NSDictionary *item in items) { - - [UICKeyChainStore setString:[item objectForKey:@"value"] forKey:[item objectForKey:@"key"] service:NCGlobal.shared.serviceShareKeyChain]; - [UICKeyChainStore removeItemForKey:[item objectForKey:@"key"]]; - } -} - #pragma ------------------------------ GET/SET -+ (NSString *)getGroupBySettings -{ - NSString *groupby = [UICKeyChainStore stringForKey:@"groupby" service:NCGlobal.shared.serviceShareKeyChain]; - - if (groupby == nil) { - - [self setGroupBySettings:@"none"]; - return @"none"; - } - - return @"none"; - - //return groupby; -} - -+ (void)setGroupBySettings:(NSString *)groupby -{ - [UICKeyChainStore setString:groupby forKey:@"groupby" service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (BOOL)getIntro -{ - // Set compatibility old version don't touch me - if ([[UICKeyChainStore stringForKey:[INTRO_MessageType stringByAppendingString:@"Intro"] service:NCGlobal.shared.serviceShareKeyChain] boolValue] == YES) { - [CCUtility setIntro:YES]; - return YES; - } - - return [[UICKeyChainStore stringForKey:@"intro" service:NCGlobal.shared.serviceShareKeyChain] boolValue]; -} - -+ (BOOL)getIntroMessageOldVersion -{ - NSString *key = [INTRO_MessageType stringByAppendingString:@"Intro"]; - - return [[UICKeyChainStore stringForKey:key service:NCGlobal.shared.serviceShareKeyChain] boolValue]; -} - -+ (void)setIntro:(BOOL)set -{ - NSString *sIntro = (set) ? @"true" : @"false"; - [UICKeyChainStore setString:sIntro forKey:@"intro" service:NCGlobal.shared.serviceShareKeyChain]; - -} - -+ (NSString *)getIncrementalNumber -{ - long number = [[UICKeyChainStore stringForKey:@"incrementalnumber" service:NCGlobal.shared.serviceShareKeyChain] intValue]; - - number++; - if (number >= 9999) number = 1; - - [UICKeyChainStore setString:[NSString stringWithFormat:@"%ld", number] forKey:@"incrementalnumber" service:NCGlobal.shared.serviceShareKeyChain]; - - return [NSString stringWithFormat:@"%04ld", number]; -} - + (NSString *)getAccountExt { return [UICKeyChainStore stringForKey:@"accountExt" service:NCGlobal.shared.serviceShareKeyChain]; @@ -794,7 +724,7 @@ + (NSString *)createFileName:(NSString *)fileName fileDate:(NSDate *)fileDate fi NSString *numberFileName; if ([fileName length] > 8) numberFileName = [fileName substringWithRange:NSMakeRange(04, 04)]; - else numberFileName = [CCUtility getIncrementalNumber]; + else numberFileName = [NCKeychain alloc].incrementalNumber; NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]]; diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index 2dd84bf921..a3068fbfd9 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -36,6 +36,10 @@ import KeychainAccess } } + @objc func removeAll() { + try? keychain.removeAll() + } + var typeFilterScanDocument: NCGlobal.TypeFilterScanDocument { get { if let rawValue = try? keychain.get("ScanDocumentTypeFilter"), let value = NCGlobal.TypeFilterScanDocument(rawValue: rawValue) { @@ -95,4 +99,28 @@ import KeychainAccess keychain["enableTouchFaceID"] = String(newValue) } } + + var intro: Bool { + get { + migrate(key: "intro") + if let value = try? keychain.get("intro"), let result = Bool(value) { + return result + } + return false + } + set { + keychain["intro"] = String(newValue) + } + } + + @objc var incrementalNumber: String { + migrate(key: "incrementalnumber") + var incrementalString = String(format: "%04ld", 0) + if let value = try? keychain.get("incrementalnumber"), var result = Int(value) { + result += 1 + incrementalString = String(format: "%04ld", result) + } + keychain["incrementalnumber"] = incrementalString + return incrementalString + } } diff --git a/iOSClient/Utility/NCUtility.swift b/iOSClient/Utility/NCUtility.swift index 2b37c5b5f2..58fd9e4af2 100644 --- a/iOSClient/Utility/NCUtility.swift +++ b/iOSClient/Utility/NCUtility.swift @@ -220,6 +220,7 @@ class NCUtility: NSObject { CCUtility.createDirectoryStandard() CCUtility.deleteAllChainStore() + NCKeychain().removeAll() } #endif From ca3d3adbdc12518bfdc7a6506b62915b613aaf1d Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Mon, 23 Oct 2023 17:21:33 +0200 Subject: [PATCH 28/90] cleaning --- iOSClient/Utility/CCUtility.h | 18 ----------- iOSClient/Utility/CCUtility.m | 60 ----------------------------------- 2 files changed, 78 deletions(-) diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index d75ee564b5..67cbed55ca 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -41,24 +41,6 @@ + (void)deleteAllChainStore; -+ (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; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 8a70015cf1..451ce82347 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -50,66 +50,6 @@ + (void)deleteAllChainStore #pragma ------------------------------ GET/SET -+ (NSString *)getAccountExt -{ - return [UICKeyChainStore stringForKey:@"accountExt" service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (void)setAccountExt:(NSString *)account -{ - [UICKeyChainStore setString:account forKey:@"accountExt" service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (NSString *)getServerUrlExt -{ - return [UICKeyChainStore stringForKey:@"serverUrlExt" service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (void)setServerUrlExt:(NSString *)serverUrl -{ - [UICKeyChainStore setString:serverUrl forKey:@"serverUrlExt" service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (NSString *)getTitleServerUrlExt -{ - return [UICKeyChainStore stringForKey:@"titleServerUrlExt" service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (void)setTitleServerUrlExt:(NSString *)titleServerUrl -{ - [UICKeyChainStore setString:titleServerUrl forKey:@"titleServerUrlExt" service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (NSString *)getFileNameExt -{ - return [UICKeyChainStore stringForKey:@"fileNameExt" service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (void)setFileNameExt:(NSString *)fileName -{ - [UICKeyChainStore setString:fileName forKey:@"fileNameExt" service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (NSString *)getEmail -{ - return [UICKeyChainStore stringForKey:@"email" service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (void)setEmail:(NSString *)email -{ - [UICKeyChainStore setString:email forKey:@"email" service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (NSString *)getHint -{ - return [UICKeyChainStore stringForKey:@"hint" service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (void)setHint:(NSString *)hint -{ - [UICKeyChainStore setString:hint forKey:@"hint" service:NCGlobal.shared.serviceShareKeyChain]; -} - + (BOOL)getOriginalFileName:(NSString *)key { return [[UICKeyChainStore stringForKey:key service:NCGlobal.shared.serviceShareKeyChain] boolValue]; From 7df20504f00c7eef3e15968f02291f894e550f15 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Mon, 23 Oct 2023 17:46:36 +0200 Subject: [PATCH 29/90] OriginalFileName --- .../Main/Create cloud/NCUploadAssets.swift | 6 +-- .../Settings/NCManageAutoUploadFileName.swift | 6 +-- iOSClient/Utility/CCUtility.h | 3 -- iOSClient/Utility/CCUtility.m | 13 +------ iOSClient/Utility/NCKeychain.swift | 38 +++++++++++++------ 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/iOSClient/Main/Create cloud/NCUploadAssets.swift b/iOSClient/Main/Create cloud/NCUploadAssets.swift index 403feae340..d76fce0c1a 100644 --- a/iOSClient/Main/Create cloud/NCUploadAssets.swift +++ b/iOSClient/Main/Create cloud/NCUploadAssets.swift @@ -148,7 +148,7 @@ class NCUploadAssets: NSObject, ObservableObject, NCCreateFormUploadConflictDele 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 isMaintainOriginalFilename: Bool = NCKeychain().getOriginalFileName(key: NCGlobal.shared.keyFileNameOriginal) @State private var isAddFilenametype: Bool = CCUtility.getFileNameType(NCGlobal.shared.keyFileNameType) @State private var isPresentedSelect = false @State private var isPresentedUploadConflict = false @@ -185,7 +185,7 @@ struct UploadAssetsView: View { var preview: String = "" let creationDate = asset.creationDate ?? Date() - CCUtility.setOriginalFileName(isMaintainOriginalFilename, key: NCGlobal.shared.keyFileNameOriginal) + NCKeychain().setOriginalFileName(key: NCGlobal.shared.keyFileNameOriginal, value: isMaintainOriginalFilename) CCUtility.setFileNameType(isAddFilenametype, key: NCGlobal.shared.keyFileNameType) CCUtility.setFileNameMask(fileName, key: NCGlobal.shared.keyFileNameMask) @@ -323,7 +323,7 @@ struct UploadAssetsView: View { } 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 { return asset.originalFilename diff --git a/iOSClient/Settings/NCManageAutoUploadFileName.swift b/iOSClient/Settings/NCManageAutoUploadFileName.swift index 90335789fa..cded8b490f 100644 --- a/iOSClient/Settings/NCManageAutoUploadFileName.swift +++ b/iOSClient/Settings/NCManageAutoUploadFileName.swift @@ -49,7 +49,7 @@ class NCManageAutoUploadFileName: XLFormViewController { // Maintain the original fileName 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["textLabel.font"] = UIFont.systemFont(ofSize: 15.0) @@ -150,7 +150,7 @@ class NCManageAutoUploadFileName: XLFormViewController { CCUtility.setFileNameType((formRow.value! as AnyObject).boolValue, key: NCGlobal.shared.keyFileNameAutoUploadType) self.reloadForm() } 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() } else if formRow.tag == "maskFileName" { @@ -189,7 +189,7 @@ class NCManageAutoUploadFileName: XLFormViewController { var returnString: String = "" - if CCUtility.getOriginalFileName(NCGlobal.shared.keyFileNameOriginalAutoUpload) { + if NCKeychain().getOriginalFileName(key: NCGlobal.shared.keyFileNameOriginalAutoUpload) { return (NSLocalizedString("_filename_", comment: "") + ": IMG_0001.JPG") diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 67cbed55ca..1a028fa729 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -41,9 +41,6 @@ + (void)deleteAllChainStore; -+ (BOOL)getOriginalFileName:(NSString *)key; -+ (void)setOriginalFileName:(BOOL)value key:(NSString *)key; - + (NSString *)getFileNameMask:(NSString *)key; + (void)setFileNameMask:(NSString *)mask key:(NSString *)key; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 451ce82347..f0a1d45d53 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -50,17 +50,6 @@ + (void)deleteAllChainStore #pragma ------------------------------ GET/SET -+ (BOOL)getOriginalFileName:(NSString *)key -{ - return [[UICKeyChainStore stringForKey:key service:NCGlobal.shared.serviceShareKeyChain] boolValue]; -} - -+ (void)setOriginalFileName:(BOOL)value key:(NSString *)key -{ - NSString *sValue = (value) ? @"true" : @"false"; - [UICKeyChainStore setString:sValue forKey:key service:NCGlobal.shared.serviceShareKeyChain]; -} - + (NSString *)getFileNameMask:(NSString *)key { NSString *mask = [UICKeyChainStore stringForKey:key service:NCGlobal.shared.serviceShareKeyChain]; @@ -658,7 +647,7 @@ + (NSString *)createFileName:(NSString *)fileName fileDate:(NSDate *)fileDate fi BOOL addFileNameType = NO; // Original FileName ? - if ([self getOriginalFileName:keyFileNameOriginal] && !forcedNewFileName) { + if ([[NCKeychain init] getOriginalFileNameWithKey:keyFileNameOriginal] && !forcedNewFileName) { return fileName; } diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index a3068fbfd9..cdd5b3b8f6 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -28,18 +28,6 @@ import KeychainAccess let keychain = Keychain(service: "com.nextcloud.keychain") - private func migrate(key: String) { - let keychainOLD = Keychain(service: NCGlobal.shared.serviceShareKeyChain) - if let value = keychainOLD[key], !value.isEmpty { - keychain[key] = value - keychainOLD[key] = nil - } - } - - @objc func removeAll() { - try? keychain.removeAll() - } - var typeFilterScanDocument: NCGlobal.TypeFilterScanDocument { get { if let rawValue = try? keychain.get("ScanDocumentTypeFilter"), let value = NCGlobal.TypeFilterScanDocument(rawValue: rawValue) { @@ -123,4 +111,30 @@ import KeychainAccess keychain["incrementalnumber"] = incrementalString return incrementalString } + + // MARK: - + + private func migrate(key: String) { + let keychainOLD = Keychain(service: NCGlobal.shared.serviceShareKeyChain) + if let value = keychainOLD[key], !value.isEmpty { + keychain[key] = value + keychainOLD[key] = nil + } + } + + @objc func removeAll() { + try? keychain.removeAll() + } + + @objc func getOriginalFileName(key: String) -> Bool { + migrate(key: key) + if let value = try? keychain.get(key), let result = Bool(value) { + return result + } + return false + } + + @objc func setOriginalFileName(key: String, value: Bool) { + keychain[key] = String(value) + } } From 7120b2ec07ea23638a9dc7c2acee78200b47b544 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Mon, 23 Oct 2023 18:00:15 +0200 Subject: [PATCH 30/90] FileNameMask --- .../Main/Create cloud/NCUploadAssets.swift | 4 ++-- .../Settings/NCManageAutoUploadFileName.swift | 8 ++++---- iOSClient/Utility/CCUtility.h | 3 --- iOSClient/Utility/CCUtility.m | 17 +---------------- iOSClient/Utility/NCKeychain.swift | 12 ++++++++++++ 5 files changed, 19 insertions(+), 25 deletions(-) diff --git a/iOSClient/Main/Create cloud/NCUploadAssets.swift b/iOSClient/Main/Create cloud/NCUploadAssets.swift index d76fce0c1a..3d84204084 100644 --- a/iOSClient/Main/Create cloud/NCUploadAssets.swift +++ b/iOSClient/Main/Create cloud/NCUploadAssets.swift @@ -147,7 +147,7 @@ class NCUploadAssets: NSObject, ObservableObject, NCCreateFormUploadConflictDele struct UploadAssetsView: View { - @State private var fileName: String = CCUtility.getFileNameMask(NCGlobal.shared.keyFileNameMask) + @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 = CCUtility.getFileNameType(NCGlobal.shared.keyFileNameType) @State private var isPresentedSelect = false @@ -187,7 +187,7 @@ struct UploadAssetsView: View { NCKeychain().setOriginalFileName(key: NCGlobal.shared.keyFileNameOriginal, value: isMaintainOriginalFilename) CCUtility.setFileNameType(isAddFilenametype, key: NCGlobal.shared.keyFileNameType) - CCUtility.setFileNameMask(fileName, key: NCGlobal.shared.keyFileNameMask) + NCKeychain().setFileNameMask(key: NCGlobal.shared.keyFileNameMask, mask: fileName) preview = CCUtility.createFileName( getOriginalFilenameForPreview() as String, diff --git a/iOSClient/Settings/NCManageAutoUploadFileName.swift b/iOSClient/Settings/NCManageAutoUploadFileName.swift index cded8b490f..c9e3670af5 100644 --- a/iOSClient/Settings/NCManageAutoUploadFileName.swift +++ b/iOSClient/Settings/NCManageAutoUploadFileName.swift @@ -75,7 +75,7 @@ class NCManageAutoUploadFileName: XLFormViewController { form.addFormSection(section) 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 { row.value = fileNameMask } @@ -199,13 +199,13 @@ class NCManageAutoUploadFileName: XLFormViewController { 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) } else { self.form.delegate = nil - CCUtility.setFileNameMask(valueRename, key: NCGlobal.shared.keyFileNameAutoUploadMask) + NCKeychain().setFileNameMask(key: NCGlobal.shared.keyFileNameAutoUploadMask, mask: valueRename) 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) @@ -213,7 +213,7 @@ class NCManageAutoUploadFileName: XLFormViewController { } 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) } diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 1a028fa729..b4a40ee5bb 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -41,9 +41,6 @@ + (void)deleteAllChainStore; -+ (NSString *)getFileNameMask:(NSString *)key; -+ (void)setFileNameMask:(NSString *)mask key:(NSString *)key; - + (BOOL)getFileNameType:(NSString *)key; + (void)setFileNameType:(BOOL)prefix key:(NSString *)key; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index f0a1d45d53..061b51cd66 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -50,21 +50,6 @@ + (void)deleteAllChainStore #pragma ------------------------------ GET/SET -+ (NSString *)getFileNameMask:(NSString *)key -{ - NSString *mask = [UICKeyChainStore stringForKey:key service:NCGlobal.shared.serviceShareKeyChain]; - - if (mask == nil) - mask = @""; - - return mask; -} - -+ (void)setFileNameMask:(NSString *)mask key:(NSString *)key -{ - [UICKeyChainStore setString:mask forKey:key service:NCGlobal.shared.serviceShareKeyChain]; -} - + (BOOL)getFileNameType:(NSString *)key { return [[UICKeyChainStore stringForKey:key service:NCGlobal.shared.serviceShareKeyChain] boolValue]; @@ -678,7 +663,7 @@ + (NSString *)createFileName:(NSString *)fileName fileDate:(NSDate *)fileDate fi if (keyFileName) { - fileName = [CCUtility getFileNameMask:keyFileName]; + fileName = [[NCKeychain init] getFileNameMaskWithKey:keyFileName]; if ([fileName length] > 0) { diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index cdd5b3b8f6..7f6670c01c 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -137,4 +137,16 @@ import KeychainAccess @objc func setOriginalFileName(key: String, value: Bool) { keychain[key] = String(value) } + + @objc func setFileNameMask(key: String, mask: String) { + keychain[key] = mask + } + + @objc func getFileNameMask(key: String) -> String { + if let value = try? keychain.get(key) { + return value + } else { + return "" + } + } } From 58ee4022e1dc67dab749fc81d6bb0b4e0467cc50 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 12:21:17 +0200 Subject: [PATCH 31/90] FileNameType --- .../Main/Create cloud/NCUploadAssets.swift | 4 ++-- .../Settings/NCManageAutoUploadFileName.swift | 4 ++-- iOSClient/Utility/CCUtility.h | 2 -- iOSClient/Utility/CCUtility.m | 13 +---------- iOSClient/Utility/NCKeychain.swift | 22 +++++++++++++++---- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/iOSClient/Main/Create cloud/NCUploadAssets.swift b/iOSClient/Main/Create cloud/NCUploadAssets.swift index 3d84204084..e1698123ec 100644 --- a/iOSClient/Main/Create cloud/NCUploadAssets.swift +++ b/iOSClient/Main/Create cloud/NCUploadAssets.swift @@ -149,7 +149,7 @@ struct UploadAssetsView: View { @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 = CCUtility.getFileNameType(NCGlobal.shared.keyFileNameType) + @State private var isAddFilenametype: Bool = NCKeychain().getFileNameType(key: NCGlobal.shared.keyFileNameType) @State private var isPresentedSelect = false @State private var isPresentedUploadConflict = false @State private var isPresentedQuickLook = false @@ -186,7 +186,7 @@ struct UploadAssetsView: View { let creationDate = asset.creationDate ?? Date() NCKeychain().setOriginalFileName(key: NCGlobal.shared.keyFileNameOriginal, value: isMaintainOriginalFilename) - CCUtility.setFileNameType(isAddFilenametype, key: NCGlobal.shared.keyFileNameType) + NCKeychain().setFileNameType(key: NCGlobal.shared.keyFileNameType, prefix: isAddFilenametype) NCKeychain().setFileNameMask(key: NCGlobal.shared.keyFileNameMask, mask: fileName) preview = CCUtility.createFileName( diff --git a/iOSClient/Settings/NCManageAutoUploadFileName.swift b/iOSClient/Settings/NCManageAutoUploadFileName.swift index c9e3670af5..8af8285d23 100644 --- a/iOSClient/Settings/NCManageAutoUploadFileName.swift +++ b/iOSClient/Settings/NCManageAutoUploadFileName.swift @@ -60,7 +60,7 @@ class NCManageAutoUploadFileName: XLFormViewController { // Add File Name Type 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.cellConfig["backgroundColor"] = UIColor.secondarySystemGroupedBackground @@ -147,7 +147,7 @@ class NCManageAutoUploadFileName: XLFormViewController { super.formRowDescriptorValueHasChanged(formRow, oldValue: oldValue, newValue: newValue) 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() } else if formRow.tag == "maintainOriginalFileName" { NCKeychain().setOriginalFileName(key: NCGlobal.shared.keyFileNameOriginalAutoUpload, value: (formRow.value! as AnyObject).boolValue) diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index b4a40ee5bb..a86bb60f88 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -41,8 +41,6 @@ + (void)deleteAllChainStore; -+ (BOOL)getFileNameType:(NSString *)key; -+ (void)setFileNameType:(BOOL)prefix key:(NSString *)key; + (BOOL)getActivityVerboseHigh; + (void)setActivityVerboseHigh:(BOOL)debug; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 061b51cd66..9a28e68c18 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -50,17 +50,6 @@ + (void)deleteAllChainStore #pragma ------------------------------ GET/SET -+ (BOOL)getFileNameType:(NSString *)key -{ - return [[UICKeyChainStore stringForKey:key service:NCGlobal.shared.serviceShareKeyChain] boolValue]; -} - -+ (void)setFileNameType:(BOOL)prefix key:(NSString *)key -{ - NSString *sPrefix = (prefix) ? @"true" : @"false"; - [UICKeyChainStore setString:sPrefix forKey:key service:NCGlobal.shared.serviceShareKeyChain]; -} - + (BOOL)getActivityVerboseHigh { return [[UICKeyChainStore stringForKey:@"activityVerboseHigh" service:NCGlobal.shared.serviceShareKeyChain] boolValue]; @@ -657,7 +646,7 @@ + (NSString *)createFileName:(NSString *)fileName fileDate:(NSDate *)fileDate fi // Use File Name Type if (keyFileNameType) - addFileNameType = [CCUtility getFileNameType:keyFileNameType]; + addFileNameType = [[NCKeychain init] getFileNameTypeWithKey:keyFileNameType]; NSString *fileNameExt = [[fileName pathExtension] lowercaseString]; diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index 7f6670c01c..78d8c37553 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -138,15 +138,29 @@ import KeychainAccess keychain[key] = String(value) } - @objc func setFileNameMask(key: String, mask: String) { - keychain[key] = mask - } - @objc func getFileNameMask(key: String) -> String { + migrate(key: key) if let value = try? keychain.get(key) { return value } else { return "" } } + + @objc func setFileNameMask(key: String, mask: String?) { + keychain[key] = mask + } + + @objc func getFileNameType(key: String) -> Bool { + migrate(key: key) + if let value = try? keychain.get(key), let result = Bool(value) { + return result + } else { + return false + } + } + + @objc func setFileNameType(key: String, prefix: Bool) { + keychain[key] = String(prefix) + } } From 6585883bd6beb6a7f3342f7f694ace5843ef44c2 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 12:32:26 +0200 Subject: [PATCH 32/90] showHiddenFiles --- .../FileProviderEnumerator.swift | 4 ++-- .../FileProviderExtension+Actions.swift | 2 +- Widget/Files/FilesData.swift | 2 +- iOSClient/Favorites/NCFavorite.swift | 2 +- iOSClient/Groupfolders/NCGroupfolders.swift | 2 +- iOSClient/Media/NCMedia.swift | 4 ++-- iOSClient/Networking/NCNetworking.swift | 8 +++---- iOSClient/Networking/NCService.swift | 2 +- iOSClient/Recent/NCRecent.swift | 2 +- iOSClient/Settings/CCAdvanced.m | 4 ++-- iOSClient/Utility/CCUtility.h | 6 ----- iOSClient/Utility/CCUtility.m | 22 ------------------- iOSClient/Utility/NCKeychain.swift | 13 +++++++++++ 13 files changed, 29 insertions(+), 44 deletions(-) diff --git a/File Provider Extension/FileProviderEnumerator.swift b/File Provider Extension/FileProviderEnumerator.swift index 116dc9418a..9030370dc0 100644 --- a/File Provider Extension/FileProviderEnumerator.swift +++ b/File Provider Extension/FileProviderEnumerator.swift @@ -203,11 +203,11 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator { 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 { - 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 { DispatchQueue.global().async { diff --git a/File Provider Extension/FileProviderExtension+Actions.swift b/File Provider Extension/FileProviderExtension+Actions.swift index 71f04437ab..548acc40fa 100644 --- a/File Provider Extension/FileProviderExtension+Actions.swift +++ b/File Provider Extension/FileProviderExtension+Actions.swift @@ -41,7 +41,7 @@ extension FileProviderExtension { 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 { diff --git a/Widget/Files/FilesData.swift b/Widget/Files/FilesData.swift index 9dc8dfe82b..0247eec895 100644 --- a/Widget/Files/FilesData.swift +++ b/Widget/Files/FilesData.swift @@ -207,7 +207,7 @@ func getFilesDataEntry(configuration: AccountIntent?, isPreview: Bool, displaySi } 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 { var datas: [FilesData] = [] var imageRecent = UIImage(named: "file")! diff --git a/iOSClient/Favorites/NCFavorite.swift b/iOSClient/Favorites/NCFavorite.swift index d3abf80c6d..56021de211 100644 --- a/iOSClient/Favorites/NCFavorite.swift +++ b/iOSClient/Favorites/NCFavorite.swift @@ -91,7 +91,7 @@ class NCFavorite: NCCollectionViewCommon { isReloadDataSourceNetworkInProgress = true 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 self.isReloadDataSourceNetworkInProgress = false diff --git a/iOSClient/Groupfolders/NCGroupfolders.swift b/iOSClient/Groupfolders/NCGroupfolders.swift index 71cd4f9d9c..e8fa0053cb 100644 --- a/iOSClient/Groupfolders/NCGroupfolders.swift +++ b/iOSClient/Groupfolders/NCGroupfolders.swift @@ -102,7 +102,7 @@ class NCGroupfolders: NCCollectionViewCommon { let mountPoint = groupfolder.mountPoint.hasPrefix("/") ? groupfolder.mountPoint : "/" + groupfolder.mountPoint let serverUrlFileName = homeServerUrl + mountPoint 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 { let isDirectoryE2EE = NCUtility.shared.isDirectoryE2EE(file: file) let metadata = NCManageDatabase.shared.convertFileToMetadata(file, isDirectoryE2EE: isDirectoryE2EE) diff --git a/iOSClient/Media/NCMedia.swift b/iOSClient/Media/NCMedia.swift index 39d53defe7..2969ab0383 100644 --- a/iOSClient/Media/NCMedia.swift +++ b/iOSClient/Media/NCMedia.swift @@ -502,7 +502,7 @@ extension NCMedia { 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 DispatchQueue.main.async { @@ -585,7 +585,7 @@ extension NCMedia { 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 DispatchQueue.main.async { diff --git a/iOSClient/Networking/NCNetworking.swift b/iOSClient/Networking/NCNetworking.swift index 3e39246b29..9af696b5a1 100644 --- a/iOSClient/Networking/NCNetworking.swift +++ b/iOSClient/Networking/NCNetworking.swift @@ -880,7 +880,7 @@ class NCNetworking: NSObject, NKCommonDelegate { NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl, depth: "1", - showHiddenFiles: CCUtility.getShowHiddenFiles(), + showHiddenFiles: NCKeychain().showHiddenFiles, includeHiddenFiles: NCGlobal.shared.includeHiddenFiles, options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { account, files, _, error in @@ -912,7 +912,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) @@ -977,7 +977,7 @@ class NCNetworking: NSObject, NKCommonDelegate { #if !EXTENSION NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl, depth: "infinity", - showHiddenFiles: CCUtility.getShowHiddenFiles(), + showHiddenFiles: NCKeychain().showHiddenFiles, options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { account, files, _, error in if error == .success { @@ -1010,7 +1010,7 @@ class NCNetworking: NSObject, NKCommonDelegate { NextcloudKit.shared.searchLiteral(serverUrl: urlBase.urlBase, depth: "infinity", literal: literal, - showHiddenFiles: CCUtility.getShowHiddenFiles(), + showHiddenFiles: NCKeychain().showHiddenFiles, options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { account, files, _, error in guard error == .success else { diff --git a/iOSClient/Networking/NCService.swift b/iOSClient/Networking/NCService.swift index 8dccd34e03..1b0bd529ef 100644 --- a/iOSClient/Networking/NCService.swift +++ b/iOSClient/Networking/NCService.swift @@ -139,7 +139,7 @@ class NCService: NSObject { func synchronize() { 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 guard error == .success else { return } diff --git a/iOSClient/Recent/NCRecent.swift b/iOSClient/Recent/NCRecent.swift index 380d69bac7..49a02c5981 100644 --- a/iOSClient/Recent/NCRecent.swift +++ b/iOSClient/Recent/NCRecent.swift @@ -151,7 +151,7 @@ class NCRecent: NCCollectionViewCommon { NextcloudKit.shared.searchBodyRequest(serverUrl: appDelegate.urlBase, requestBody: requestBody, - showHiddenFiles: CCUtility.getShowHiddenFiles(), + showHiddenFiles: NCKeychain().showHiddenFiles, options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { account, files, _, error in self.isReloadDataSourceNetworkInProgress = false diff --git a/iOSClient/Settings/CCAdvanced.m b/iOSClient/Settings/CCAdvanced.m index e3619fceea..86894f2134 100755 --- a/iOSClient/Settings/CCAdvanced.m +++ b/iOSClient/Settings/CCAdvanced.m @@ -48,7 +48,7 @@ - (void)initializeForm row = [XLFormRowDescriptor formRowDescriptorWithTag:@"showHiddenFiles" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_show_hidden_files_", nil)]; row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - if ([CCUtility getShowHiddenFiles]) row.value = @"1"; + if ([[NCKeychain init] showHiddenFiles]) row.value = @"1"; else row.value = @"0"; [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; @@ -313,7 +313,7 @@ - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor ol if ([rowDescriptor.tag isEqualToString:@"showHiddenFiles"]) { - [CCUtility setShowHiddenFiles:[[rowDescriptor.value valueData] boolValue]]; + [[NCKeychain alloc] init].showHiddenFiles = [[rowDescriptor.value valueData] boolValue]; } if ([rowDescriptor.tag isEqualToString:@"formatCompatibility"]) { diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index a86bb60f88..afe742e7d2 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -42,12 +42,6 @@ + (void)deleteAllChainStore; -+ (BOOL)getActivityVerboseHigh; -+ (void)setActivityVerboseHigh:(BOOL)debug; - -+ (BOOL)getShowHiddenFiles; -+ (void)setShowHiddenFiles:(BOOL)show; - + (BOOL)getFormatCompatibility; + (void)setFormatCompatibility:(BOOL)set; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 9a28e68c18..522e11eb83 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -50,28 +50,6 @@ + (void)deleteAllChainStore #pragma ------------------------------ GET/SET -+ (BOOL)getActivityVerboseHigh -{ - return [[UICKeyChainStore stringForKey:@"activityVerboseHigh" service:NCGlobal.shared.serviceShareKeyChain] boolValue]; -} - -+ (void)setActivityVerboseHigh:(BOOL)high -{ - NSString *sHigh = (high) ? @"true" : @"false"; - [UICKeyChainStore setString:sHigh forKey:@"activityVerboseHigh" service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (BOOL)getShowHiddenFiles -{ - return [[UICKeyChainStore stringForKey:@"showHiddenFiles" service:NCGlobal.shared.serviceShareKeyChain] boolValue]; -} - -+ (void)setShowHiddenFiles:(BOOL)show -{ - NSString *sShow = (show) ? @"true" : @"false"; - [UICKeyChainStore setString:sShow forKey:@"showHiddenFiles" service:NCGlobal.shared.serviceShareKeyChain]; -} - + (BOOL)getFormatCompatibility { NSString *valueString = [UICKeyChainStore stringForKey:@"formatCompatibility" service:NCGlobal.shared.serviceShareKeyChain]; diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index 78d8c37553..ab9e83c786 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -112,6 +112,19 @@ import KeychainAccess return incrementalString } + @objc var showHiddenFiles: Bool { + get { + migrate(key: "showHiddenFiles") + if let value = try? keychain.get("showHiddenFiles"), let result = Bool(value) { + return result + } + return false + } + set { + keychain["showHiddenFiles"] = String(newValue) + } + } + // MARK: - private func migrate(key: String) { From 500a7788d7f4e563063c3ec9d0383993d5947036 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 12:38:12 +0200 Subject: [PATCH 33/90] formatCompatibility --- .../Data/NCManageDatabase+Metadata.swift | 2 +- .../NCCreateFormUploadConflict.swift | 2 +- iOSClient/Networking/NCAutoUpload.swift | 2 +- iOSClient/Settings/CCAdvanced.m | 4 ++-- iOSClient/Utility/CCUtility.h | 4 ---- iOSClient/Utility/CCUtility.m | 19 ------------------- iOSClient/Utility/NCCameraRoll.swift | 2 +- iOSClient/Utility/NCKeychain.swift | 13 +++++++++++++ 8 files changed, 19 insertions(+), 29 deletions(-) diff --git a/iOSClient/Data/NCManageDatabase+Metadata.swift b/iOSClient/Data/NCManageDatabase+Metadata.swift index 2c2da462ae..a730c3be20 100644 --- a/iOSClient/Data/NCManageDatabase+Metadata.swift +++ b/iOSClient/Data/NCManageDatabase+Metadata.swift @@ -1162,7 +1162,7 @@ extension NCManageDatabase { let fileNameNoExtension = (fileNameView as NSString).deletingPathExtension var fileNameConflict = fileNameView - if fileNameExtension == "heic" && CCUtility.getFormatCompatibility() { + if fileNameExtension == "heic", NCKeychain().formatCompatibility { fileNameConflict = fileNameNoExtension + ".jpg" } return getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameView == %@", account, serverUrl, fileNameConflict)) diff --git a/iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift b/iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift index 0a847c421f..92c61d6e6f 100644 --- a/iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift +++ b/iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift @@ -245,7 +245,7 @@ class NCCreateFormUploadConflict: UIViewController { var fileName = metadata.fileNameView let fileNameExtension = (fileName as NSString).pathExtension.lowercased() let fileNameNoExtension = (fileName as NSString).deletingPathExtension - if fileNameExtension == "heic" && CCUtility.getFormatCompatibility() { + if fileNameExtension == "heic" && NCKeychain().formatCompatibility { fileName = fileNameNoExtension + ".jpg" } let oldPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) diff --git a/iOSClient/Networking/NCAutoUpload.swift b/iOSClient/Networking/NCAutoUpload.swift index 39869e28f1..f7fd8d9642 100644 --- a/iOSClient/Networking/NCAutoUpload.swift +++ b/iOSClient/Networking/NCAutoUpload.swift @@ -151,7 +151,7 @@ class NCAutoUpload: NSObject { var fileNameSearchMetadata = fileName let ext = (fileNameSearchMetadata as NSString).pathExtension.uppercased() - if ext == "HEIC" && CCUtility.getFormatCompatibility() { + if ext == "HEIC", NCKeychain().formatCompatibility { fileNameSearchMetadata = (fileNameSearchMetadata as NSString).deletingPathExtension + ".jpg" } diff --git a/iOSClient/Settings/CCAdvanced.m b/iOSClient/Settings/CCAdvanced.m index 86894f2134..d45eb949cc 100755 --- a/iOSClient/Settings/CCAdvanced.m +++ b/iOSClient/Settings/CCAdvanced.m @@ -62,7 +62,7 @@ - (void)initializeForm row = [XLFormRowDescriptor formRowDescriptorWithTag:@"formatCompatibility" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_format_compatibility_", nil)]; row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - if ([CCUtility getFormatCompatibility]) row.value = @"1"; + if ([[NCKeychain init] formatCompatibility]) row.value = @"1"; else row.value = @"0"; [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; @@ -318,7 +318,7 @@ - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor ol if ([rowDescriptor.tag isEqualToString:@"formatCompatibility"]) { - [CCUtility setFormatCompatibility:[[rowDescriptor.value valueData] boolValue]]; + [[NCKeychain alloc] init].formatCompatibility = [[rowDescriptor.value valueData] boolValue]; } if ([rowDescriptor.tag isEqualToString:@"livePhoto"]) { diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index afe742e7d2..56543f050b 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -41,10 +41,6 @@ + (void)deleteAllChainStore; - -+ (BOOL)getFormatCompatibility; -+ (void)setFormatCompatibility:(BOOL)set; - // E2EE ------------------------------------------- + (NSString *)getEndToEndCertificate:(NSString *)account; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 522e11eb83..3501fa9b04 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -50,25 +50,6 @@ + (void)deleteAllChainStore #pragma ------------------------------ GET/SET -+ (BOOL)getFormatCompatibility -{ - NSString *valueString = [UICKeyChainStore stringForKey:@"formatCompatibility" service:NCGlobal.shared.serviceShareKeyChain]; - - // Default TRUE - if (valueString == nil) { - [self setFormatCompatibility:YES]; - return true; - } - - return [valueString boolValue]; -} - -+ (void)setFormatCompatibility:(BOOL)set -{ - NSString *sSet = (set) ? @"true" : @"false"; - [UICKeyChainStore setString:sSet forKey:@"formatCompatibility" service:NCGlobal.shared.serviceShareKeyChain]; -} - + (NSString *)getEndToEndCertificate:(NSString *)account { NSString *key, *certificate; diff --git a/iOSClient/Utility/NCCameraRoll.swift b/iOSClient/Utility/NCCameraRoll.swift index 7e48686269..c769b4860b 100644 --- a/iOSClient/Utility/NCCameraRoll.swift +++ b/iOSClient/Utility/NCCameraRoll.swift @@ -139,7 +139,7 @@ class NCCameraRoll: NSObject { let creationDate = asset.creationDate ?? Date() let modificationDate = asset.modificationDate ?? Date() - if asset.mediaType == PHAssetMediaType.image && (extensionAsset == "HEIC" || extensionAsset == "DNG") && CCUtility.getFormatCompatibility() { + if asset.mediaType == PHAssetMediaType.image && (extensionAsset == "HEIC" || extensionAsset == "DNG") && NCKeychain().formatCompatibility { let fileName = (metadata.fileNameView as NSString).deletingPathExtension + ".jpg" metadata.contentType = "image/jpeg" fileNamePath = NSTemporaryDirectory() + fileName diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index ab9e83c786..b7fd716931 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -125,6 +125,19 @@ import KeychainAccess } } + @objc var formatCompatibility: Bool { + get { + migrate(key: "formatCompatibility") + if let value = try? keychain.get("formatCompatibility"), let result = Bool(value) { + return result + } + return true + } + set { + keychain["formatCompatibility"] = String(newValue) + } + } + // MARK: - private func migrate(key: String) { From b7b11adae0470be2115bb8c43046dea8b1ddf99b Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:16:06 +0200 Subject: [PATCH 34/90] getEndToEndCertificate --- .../E2EE/NCEndToEndMetadataV20.swift | 6 ++--- iOSClient/Settings/NCEndToEndInitialize.swift | 10 ++++----- iOSClient/Utility/CCUtility.h | 3 --- iOSClient/Utility/CCUtility.m | 22 ------------------- iOSClient/Utility/NCKeychain.swift | 22 +++++++++++++++++++ 5 files changed, 30 insertions(+), 33 deletions(-) diff --git a/iOSClient/Networking/E2EE/NCEndToEndMetadataV20.swift b/iOSClient/Networking/E2EE/NCEndToEndMetadataV20.swift index 5ca3980542..7f409b1214 100644 --- a/iOSClient/Networking/E2EE/NCEndToEndMetadataV20.swift +++ b/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) { - 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_")) } @@ -134,7 +134,7 @@ extension NCEndToEndMetadata { let metadataKey = tableUserId.metadataKey { key = metadataKey } else { - addUser(userId: userId, certificate: CCUtility.getEndToEndCertificate(account), key: key) + addUser(userId: userId, certificate: certificate, key: key) } // ADDUSERID if let addUserId { @@ -237,7 +237,7 @@ extension NCEndToEndMetadata { e2eeData.printJson() 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()) diff --git a/iOSClient/Settings/NCEndToEndInitialize.swift b/iOSClient/Settings/NCEndToEndInitialize.swift index 9d7bc810fe..44a5be41cf 100644 --- a/iOSClient/Settings/NCEndToEndInitialize.swift +++ b/iOSClient/Settings/NCEndToEndInitialize.swift @@ -65,9 +65,9 @@ class NCEndToEndInitialize: NSObject { 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) @@ -92,7 +92,7 @@ class NCEndToEndInitialize: NSObject { 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 let extractedPublicKey = NCEndToEndEncryption.sharedManager().extractPublicKey(fromCertificate: certificate) @@ -102,7 +102,7 @@ class NCEndToEndInitialize: NSObject { } else { - CCUtility.setEndToEndCertificate(account, certificate: certificate) + NCKeychain().setEndToEndCertificate(account: account, certificate: certificate) // Request PrivateKey chiper to Server self.getPrivateKeyCipher() @@ -154,7 +154,7 @@ class NCEndToEndInitialize: NSObject { 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)), let keyData = Data(base64Encoded: privateKeyData) { diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 56543f050b..5e5e354f40 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -43,9 +43,6 @@ // E2EE ------------------------------------------- -+ (NSString *)getEndToEndCertificate:(NSString *)account; -+ (void)setEndToEndCertificate:(NSString *)account certificate:(NSString *)certificate; - + (NSString *)getEndToEndPrivateKey:(NSString *)account; + (void)setEndToEndPrivateKey:(NSString *)account privateKey:(NSString *)privateKey; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 3501fa9b04..f3ce90640c 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -50,28 +50,6 @@ + (void)deleteAllChainStore #pragma ------------------------------ GET/SET -+ (NSString *)getEndToEndCertificate:(NSString *)account -{ - NSString *key, *certificate; - - key = [E2E_certificate stringByAppendingString:account]; - certificate = [UICKeyChainStore stringForKey:key service:NCGlobal.shared.serviceShareKeyChain]; - - // OLD VERSION - if (certificate == nil) { - key = [@"EndToEndPublicKey_" stringByAppendingString:account]; - certificate = [UICKeyChainStore stringForKey:key service:NCGlobal.shared.serviceShareKeyChain]; - } - - return certificate; -} - -+ (void)setEndToEndCertificate:(NSString *)account certificate:(NSString *)certificate -{ - NSString *key = [E2E_certificate stringByAppendingString:account]; - [UICKeyChainStore setString:certificate forKey:key service:NCGlobal.shared.serviceShareKeyChain]; -} - + (NSString *)getEndToEndPrivateKey:(NSString *)account { NSString *key = [E2E_PrivateKey stringByAppendingString:account]; diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index b7fd716931..bd898f5777 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -28,6 +28,13 @@ import KeychainAccess let keychain = Keychain(service: "com.nextcloud.keychain") + // swiftlint:disable identifier_name + let E2E_certificate = "EndToEndCertificate_" + let E2E_PrivateKey = "EndToEndPrivateKey_" + let E2E_Passphrase = "EndToEndPassphrase_" + let E2E_PublicKey = "EndToEndPublicKeyServer_" + // swiftlint:enable identifier_name + var typeFilterScanDocument: NCGlobal.TypeFilterScanDocument { get { if let rawValue = try? keychain.get("ScanDocumentTypeFilter"), let value = NCGlobal.TypeFilterScanDocument(rawValue: rawValue) { @@ -189,4 +196,19 @@ import KeychainAccess @objc func setFileNameType(key: String, prefix: Bool) { keychain[key] = String(prefix) } + + func getEndToEndCertificate(account: String) -> String? { + + let key = E2E_certificate + account + migrate(key: key) + + let certificate = try? keychain.get(key) + return certificate + } + + func setEndToEndCertificate(account: String, certificate: String) { + + let key = E2E_certificate + account + keychain[key] = certificate + } } From 28e6d8e70cceb89c48fc9a40a3e68b4cf003b943 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:29:21 +0200 Subject: [PATCH 35/90] swiftlint --- iOSClient/Activity/NCActivity.swift | 4 +--- iOSClient/Activity/NCActivityTableViewCell.swift | 5 +---- iOSClient/Login/NCLogin.swift | 5 +---- iOSClient/Login/NCLoginWeb.swift | 4 +--- .../Collection Common/NCCollectionViewCommon.swift | 5 +---- .../Create cloud/NCCreateFormUploadDocuments.swift | 5 +---- .../Create cloud/NCCreateFormUploadVoiceNote.swift | 5 +---- iOSClient/Main/NCMainTabBar.swift | 6 +----- iOSClient/Main/NCPickerViewController.swift | 10 ++-------- iOSClient/Media/NCMedia.swift | 4 +--- iOSClient/Menu/AppDelegate+Menu.swift | 6 +----- iOSClient/More/NCMore.swift | 7 +------ iOSClient/Networking/NCNetworking.swift | 5 +---- iOSClient/Networking/NCNetworkingProcessUpload.swift | 5 +---- iOSClient/Networking/NCService.swift | 4 +--- iOSClient/Notification/NCNotification.swift | 5 +---- iOSClient/RichWorkspace/NCRichWorkspaceCommon.swift | 4 +--- iOSClient/RichWorkspace/NCViewerRichWorkspace.swift | 5 +---- iOSClient/Settings/NCEndToEndInitialize.swift | 6 +----- iOSClient/Settings/NCManageAutoUploadFileName.swift | 5 +---- iOSClient/Settings/NCManageE2EE.swift | 12 ++---------- iOSClient/Share/NCShareNetworking.swift | 5 +---- iOSClient/Utility/CCUtility.m | 12 ++++++------ iOSClient/Viewer/NCViewer.swift | 5 +---- .../Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift | 5 +---- iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift | 6 +----- .../NCViewerNextcloudText.swift | 5 +---- .../NCViewerRichdocument/NCViewerRichdocument.swift | 5 +---- 28 files changed, 35 insertions(+), 125 deletions(-) diff --git a/iOSClient/Activity/NCActivity.swift b/iOSClient/Activity/NCActivity.swift index 97bea2299c..3569c9c551 100644 --- a/iOSClient/Activity/NCActivity.swift +++ b/iOSClient/Activity/NCActivity.swift @@ -39,9 +39,7 @@ class NCActivity: UIViewController, NCSharePagingContent { var metadata: tableMetadata? 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 sectionDates: [Date] = [] diff --git a/iOSClient/Activity/NCActivityTableViewCell.swift b/iOSClient/Activity/NCActivityTableViewCell.swift index 410870aa35..dd25719b88 100644 --- a/iOSClient/Activity/NCActivityTableViewCell.swift +++ b/iOSClient/Activity/NCActivityTableViewCell.swift @@ -41,10 +41,6 @@ class NCActivityCollectionViewCell: UICollectionViewCell { 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 icon: UIImageView! @IBOutlet weak var avatar: UIImageView! @@ -52,6 +48,7 @@ class NCActivityTableViewCell: UITableViewCell, NCCellProtocol { @IBOutlet weak var subjectTrailingConstraint: NSLayoutConstraint! @IBOutlet weak var collectionViewHeightConstraint: NSLayoutConstraint! + private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)! private var user: String = "" private var index = IndexPath() diff --git a/iOSClient/Login/NCLogin.swift b/iOSClient/Login/NCLogin.swift index 965e2066d1..22c1e98ed0 100644 --- a/iOSClient/Login/NCLogin.swift +++ b/iOSClient/Login/NCLogin.swift @@ -36,10 +36,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate { @IBOutlet weak var qrCode: 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 textColorOpponent: UIColor = .black private var activeTextfieldDiff: CGFloat = 0 diff --git a/iOSClient/Login/NCLoginWeb.swift b/iOSClient/Login/NCLoginWeb.swift index 61098ea4cb..ef7ef9d4f5 100644 --- a/iOSClient/Login/NCLoginWeb.swift +++ b/iOSClient/Login/NCLoginWeb.swift @@ -30,9 +30,7 @@ class NCLoginWeb: UIViewController { 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 = "" diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index 4c78011fa5..de14e87af8 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -32,10 +32,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS @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 var searchController: UISearchController? internal var emptyDataSet: NCEmptyDataSet? diff --git a/iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift b/iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift index 629fc0d007..63f8a1f5c3 100644 --- a/iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift +++ b/iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift @@ -33,10 +33,7 @@ import XLForm @IBOutlet weak var collectionView: UICollectionView! @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 creatorId = "" var typeTemplate = "" diff --git a/iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift b/iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift index 716c903714..5e0a23e980 100644 --- a/iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift +++ b/iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift @@ -31,10 +31,7 @@ class NCCreateFormUploadVoiceNote: XLFormViewController, NCSelectDelegate, AVAud @IBOutlet weak var labelDuration: UILabel! @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 titleServerUrl = "" private var fileName = "" diff --git a/iOSClient/Main/NCMainTabBar.swift b/iOSClient/Main/NCMainTabBar.swift index d8bc682e25..ecd827f8c1 100644 --- a/iOSClient/Main/NCMainTabBar.swift +++ b/iOSClient/Main/NCMainTabBar.swift @@ -28,11 +28,7 @@ class NCMainTabBar: UITabBar { private var fillColor: UIColor! 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 public var menuRect: CGRect { diff --git a/iOSClient/Main/NCPickerViewController.swift b/iOSClient/Main/NCPickerViewController.swift index 0627970f07..a2676a24e7 100644 --- a/iOSClient/Main/NCPickerViewController.swift +++ b/iOSClient/Main/NCPickerViewController.swift @@ -31,10 +31,7 @@ import NextcloudKit 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 maxSelectedAssets = 1 var singleSelectedMode = false @@ -118,10 +115,7 @@ class customPhotoPickerViewController: TLPhotosPickerViewController { 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 viewController: UIViewController? diff --git a/iOSClient/Media/NCMedia.swift b/iOSClient/Media/NCMedia.swift index 2969ab0383..6bfdfa1ab2 100644 --- a/iOSClient/Media/NCMedia.swift +++ b/iOSClient/Media/NCMedia.swift @@ -35,9 +35,7 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate { private var gridLayout: NCGridMediaLayout! 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 = "" diff --git a/iOSClient/Menu/AppDelegate+Menu.swift b/iOSClient/Menu/AppDelegate+Menu.swift index dd5855357a..7d77076eb3 100644 --- a/iOSClient/Menu/AppDelegate+Menu.swift +++ b/iOSClient/Menu/AppDelegate+Menu.swift @@ -32,11 +32,7 @@ extension AppDelegate { func toggleMenu(viewController: UIViewController) { 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 isDirectoryE2EE = NCUtility.shared.isDirectoryE2EE(serverUrl: appDelegate.activeServerUrl, userBase: appDelegate) let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, appDelegate.activeServerUrl)) diff --git a/iOSClient/More/NCMore.swift b/iOSClient/More/NCMore.swift index 93c3f7c952..ef878a57d4 100644 --- a/iOSClient/More/NCMore.swift +++ b/iOSClient/More/NCMore.swift @@ -37,13 +37,8 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { private var externalSiteMenu: [NKExternalSite] = [] private var settingsMenu: [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 var tabAccount: tableAccount? private struct Section { diff --git a/iOSClient/Networking/NCNetworking.swift b/iOSClient/Networking/NCNetworking.swift index 9af696b5a1..8ddc0c919a 100644 --- a/iOSClient/Networking/NCNetworking.swift +++ b/iOSClient/Networking/NCNetworking.swift @@ -690,10 +690,7 @@ class NCNetworking: NSObject, NKCommonDelegate { 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) } #endif diff --git a/iOSClient/Networking/NCNetworkingProcessUpload.swift b/iOSClient/Networking/NCNetworkingProcessUpload.swift index b03b9a7041..511a9889ab 100644 --- a/iOSClient/Networking/NCNetworkingProcessUpload.swift +++ b/iOSClient/Networking/NCNetworkingProcessUpload.swift @@ -33,10 +33,7 @@ class NCNetworkingProcessUpload: NSObject { 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 timerProcess: Timer? private var pauseProcess: Bool = false diff --git a/iOSClient/Networking/NCService.swift b/iOSClient/Networking/NCService.swift index 1b0bd529ef..ff8461762d 100644 --- a/iOSClient/Networking/NCService.swift +++ b/iOSClient/Networking/NCService.swift @@ -32,9 +32,7 @@ class NCService: NSObject { 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: - diff --git a/iOSClient/Notification/NCNotification.swift b/iOSClient/Notification/NCNotification.swift index ce8c306d57..ecedbb8979 100644 --- a/iOSClient/Notification/NCNotification.swift +++ b/iOSClient/Notification/NCNotification.swift @@ -29,10 +29,7 @@ import JGProgressHUD 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 emptyDataSet: NCEmptyDataSet? var isReloadDataSourceNetworkInProgress: Bool = false diff --git a/iOSClient/RichWorkspace/NCRichWorkspaceCommon.swift b/iOSClient/RichWorkspace/NCRichWorkspaceCommon.swift index e69bcad6db..549139a4e1 100644 --- a/iOSClient/RichWorkspace/NCRichWorkspaceCommon.swift +++ b/iOSClient/RichWorkspace/NCRichWorkspaceCommon.swift @@ -26,9 +26,7 @@ import NextcloudKit @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) { diff --git a/iOSClient/RichWorkspace/NCViewerRichWorkspace.swift b/iOSClient/RichWorkspace/NCViewerRichWorkspace.swift index 4cbf9dc772..dbcf4763b4 100644 --- a/iOSClient/RichWorkspace/NCViewerRichWorkspace.swift +++ b/iOSClient/RichWorkspace/NCViewerRichWorkspace.swift @@ -29,10 +29,7 @@ import MarkdownKit @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 var markdownParser = MarkdownParser() private var textViewColor: UIColor? diff --git a/iOSClient/Settings/NCEndToEndInitialize.swift b/iOSClient/Settings/NCEndToEndInitialize.swift index 44a5be41cf..e165a2228b 100644 --- a/iOSClient/Settings/NCEndToEndInitialize.swift +++ b/iOSClient/Settings/NCEndToEndInitialize.swift @@ -32,11 +32,7 @@ import NextcloudKit class NCEndToEndInitialize: NSObject { @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? override init() { diff --git a/iOSClient/Settings/NCManageAutoUploadFileName.swift b/iOSClient/Settings/NCManageAutoUploadFileName.swift index 8af8285d23..df361c1451 100644 --- a/iOSClient/Settings/NCManageAutoUploadFileName.swift +++ b/iOSClient/Settings/NCManageAutoUploadFileName.swift @@ -27,10 +27,7 @@ import NextcloudKit 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() func initializeForm() { diff --git a/iOSClient/Settings/NCManageE2EE.swift b/iOSClient/Settings/NCManageE2EE.swift index 4dbe6ed237..1d066e394c 100644 --- a/iOSClient/Settings/NCManageE2EE.swift +++ b/iOSClient/Settings/NCManageE2EE.swift @@ -30,10 +30,6 @@ import LocalAuthentication @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 vc = UIHostingController(rootView: details) vc.title = NSLocalizedString("_e2e_settings_", comment: "") @@ -44,11 +40,7 @@ import LocalAuthentication class NCManageE2EE: NSObject, ObservableObject, NCEndToEndInitializeDelegate, TOPasscodeViewControllerDelegate { 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 = "" @Published var isEndToEndEnabled: Bool = false @@ -202,7 +194,7 @@ struct NCViewE2EE: View { } .contentShape(Rectangle()) .onTapGesture { - if let passcode = NCKeychain().passcode { + if NCKeychain().passcode != nil { manageE2EE.requestPasscodeType("readPassphrase") } else { NCContentPresenter.shared.showInfo(error: NKError(errorCode: 0, errorDescription: "_e2e_settings_lock_not_active_")) diff --git a/iOSClient/Share/NCShareNetworking.swift b/iOSClient/Share/NCShareNetworking.swift index e17da597c9..f8adc2fab4 100644 --- a/iOSClient/Share/NCShareNetworking.swift +++ b/iOSClient/Share/NCShareNetworking.swift @@ -25,10 +25,7 @@ import NextcloudKit 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? var view: UIView var metadata: tableMetadata diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index f3ce90640c..0a879dead4 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -90,21 +90,21 @@ + (BOOL)isEndToEndEnabled:(NSString *)account { NSString* versionE2EE = [[NCGlobal shared] capabilityE2EEApiVersion]; - NSString *certificate = [self getEndToEndCertificate:account]; + // NSString *certificate = [self getEndToEndCertificate:account]; NSString *publicKey = [self getEndToEndPublicKey:account]; NSString *privateKey = [self getEndToEndPrivateKey:account]; NSString *passphrase = [self getEndToEndPassphrase:account]; - if (passphrase.length > 0 && privateKey.length > 0 && certificate.length > 0 && publicKey.length > 0 && [NCGlobal.shared.e2eeVersions containsObject:versionE2EE]) { + //if (passphrase.length > 0 && privateKey.length > 0 && certificate.length > 0 && publicKey.length > 0 && [NCGlobal.shared.e2eeVersions containsObject:versionE2EE]) { return YES; - } else { - return NO; - } + //} else { + // return NO; + //} } + (void)clearAllKeysEndToEnd:(NSString *)account { - [self setEndToEndCertificate:account certificate:nil]; + // [self setEndToEndCertificate:account certificate:nil]; [self setEndToEndPrivateKey:account privateKey:nil]; [self setEndToEndPublicKey:account publicKey:nil]; [self setEndToEndPassphrase:account passphrase:nil]; diff --git a/iOSClient/Viewer/NCViewer.swift b/iOSClient/Viewer/NCViewer.swift index 46918b3408..7c6de3796f 100644 --- a/iOSClient/Viewer/NCViewer.swift +++ b/iOSClient/Viewer/NCViewer.swift @@ -31,10 +31,7 @@ class NCViewer: NSObject { return instance }() - // swiftlint:disable force_cast - let appDelegate = UIApplication.shared.delegate as! AppDelegate - // swiftlint:enable force_cast - + let appDelegate = (UIApplication.shared.delegate as? AppDelegate)! private var viewerQuickLook: NCViewerQuickLook? private var metadata = tableMetadata() private var metadatas: [tableMetadata] = [] diff --git a/iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift b/iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift index c169d1ed2d..80387f9c7c 100644 --- a/iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift +++ b/iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift @@ -28,10 +28,7 @@ import MobileVLCKit class NCPlayer: NSObject { - // swiftlint:disable force_cast - internal let appDelegate = UIApplication.shared.delegate as! AppDelegate - // swiftlint:enable force_cast - + internal let appDelegate = (UIApplication.shared.delegate as? AppDelegate)! internal var url: URL? internal var player = VLCMediaPlayer() internal var dialogProvider: VLCDialogProvider? diff --git a/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift b/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift index dea29843c5..c70ddcc042 100644 --- a/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift +++ b/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift @@ -47,11 +47,7 @@ class NCViewerMedia: UIViewController { private var tipView: EasyTipView? private let player = VLCMediaPlayer() - - // swiftlint:disable force_cast - let appDelegate = UIApplication.shared.delegate as! AppDelegate - // swiftlint:enable force_cast - + private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)! weak var viewerMediaPage: NCViewerMediaPage? var playerToolBar: NCPlayerToolBar? var ncplayer: NCPlayer? diff --git a/iOSClient/Viewer/NCViewerNextcloudText/NCViewerNextcloudText.swift b/iOSClient/Viewer/NCViewerNextcloudText/NCViewerNextcloudText.swift index 3eb885f4d2..80c2a78ee5 100644 --- a/iOSClient/Viewer/NCViewerNextcloudText/NCViewerNextcloudText.swift +++ b/iOSClient/Viewer/NCViewerNextcloudText/NCViewerNextcloudText.swift @@ -26,10 +26,7 @@ import WebKit class NCViewerNextcloudText: UIViewController, WKNavigationDelegate, WKScriptMessageHandler, WKUIDelegate { - // swiftlint:disable force_cast - let appDelegate = UIApplication.shared.delegate as! AppDelegate - // swiftlint:enable force_cast - + let appDelegate = (UIApplication.shared.delegate as? AppDelegate)! var webView = WKWebView() var bottomConstraint: NSLayoutConstraint? var link: String = "" diff --git a/iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift b/iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift index 16f46937ed..e07fa4eb7d 100644 --- a/iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift +++ b/iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift @@ -27,10 +27,7 @@ import NextcloudKit class NCViewerRichdocument: UIViewController, WKNavigationDelegate, WKScriptMessageHandler, NCSelectDelegate { - // swiftlint:disable force_cast - let appDelegate = UIApplication.shared.delegate as! AppDelegate - // swiftlint:enable force_cast - + let appDelegate = (UIApplication.shared.delegate as? AppDelegate)! var webView = WKWebView() var bottomConstraint: NSLayoutConstraint? var documentController: UIDocumentInteractionController? From 3cc6a0641a7d2503af9c5d1cdcdc7ca057b69c2f Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:46:56 +0200 Subject: [PATCH 36/90] getEndToEndPrivateKey --- .../Networking/E2EE/NCEndToEndMetadataV1.swift | 6 +++--- .../E2EE/NCEndToEndMetadataV20.swift | 4 ++-- iOSClient/Settings/NCEndToEndInitialize.swift | 10 +++++----- iOSClient/Utility/CCUtility.h | 3 --- iOSClient/Utility/NCKeychain.swift | 18 +++++++++++++----- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/iOSClient/Networking/E2EE/NCEndToEndMetadataV1.swift b/iOSClient/Networking/E2EE/NCEndToEndMetadataV1.swift index 979282eb9a..a9c1047dda 100644 --- a/iOSClient/Networking/E2EE/NCEndToEndMetadataV1.swift +++ b/iOSClient/Networking/E2EE/NCEndToEndMetadataV1.swift @@ -95,7 +95,7 @@ extension NCEndToEndMetadata { var filesCodable: [String: E2eeV12.Files]? var filedrop: [String: E2eeV12.Filedrop] = [:] var filedropCodable: [String: E2eeV12.Filedrop]? - let privateKey = CCUtility.getEndToEndPrivateKey(account) + let privateKey = NCKeychain().getEndToEndPrivateKey(account: account) var fileNameIdentifiers: [String] = [] let e2eEncryptions = NCManageDatabase.shared.getE2eEncryptions(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", account, serverUrl)) @@ -200,7 +200,7 @@ extension NCEndToEndMetadata { } let decoder = JSONDecoder() - let privateKey = CCUtility.getEndToEndPrivateKey(account) + let privateKey = NCKeychain().getEndToEndPrivateKey(account: account) var metadataVersion: Double = 0 var metadataKey = "" @@ -369,7 +369,7 @@ extension NCEndToEndMetadata { } let decoder = JSONDecoder() - let privateKey = CCUtility.getEndToEndPrivateKey(account) + let privateKey = NCKeychain().getEndToEndPrivateKey(account: account) var metadataVersion: Double = 0 do { diff --git a/iOSClient/Networking/E2EE/NCEndToEndMetadataV20.swift b/iOSClient/Networking/E2EE/NCEndToEndMetadataV20.swift index 7f409b1214..2ac5eabdc6 100644 --- a/iOSClient/Networking/E2EE/NCEndToEndMetadataV20.swift +++ b/iOSClient/Networking/E2EE/NCEndToEndMetadataV20.swift @@ -303,7 +303,7 @@ extension NCEndToEndMetadata { var metadataKey: Data? if let encryptedMetadataKey = user.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 } } @@ -447,7 +447,7 @@ extension NCEndToEndMetadata { let decoded = try? JSONSerialization.data(withJSONObject: dataSerialization, options: [.sortedKeys, .withoutEscapingSlashes]) let base64 = decoded!.base64EncodedString() 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() } } catch { diff --git a/iOSClient/Settings/NCEndToEndInitialize.swift b/iOSClient/Settings/NCEndToEndInitialize.swift index e165a2228b..35efe4f423 100644 --- a/iOSClient/Settings/NCEndToEndInitialize.swift +++ b/iOSClient/Settings/NCEndToEndInitialize.swift @@ -153,9 +153,9 @@ class NCEndToEndInitialize: NSObject { let publicKey = NCKeychain().getEndToEndCertificate(account: self.appDelegate.account) 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 { let error = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "Serious internal error to decrypt Private Key") @@ -266,9 +266,9 @@ class NCEndToEndInitialize: NSObject { 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) + NCKeychain().setEndToEndPrivateKey(account: account, privateKey: String(privateKey)) CCUtility.setEndToEndPassphrase(account, passphrase: e2ePassphrase) // request server publicKey diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 5e5e354f40..a4960057b4 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -43,9 +43,6 @@ // E2EE ------------------------------------------- -+ (NSString *)getEndToEndPrivateKey:(NSString *)account; -+ (void)setEndToEndPrivateKey:(NSString *)account privateKey:(NSString *)privateKey; - + (NSString *)getEndToEndPublicKey:(NSString *)account; + (void)setEndToEndPublicKey:(NSString *)account publicKey:(NSString *)publicKey; diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index bd898f5777..7221fdf1d4 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -198,17 +198,25 @@ import KeychainAccess } func getEndToEndCertificate(account: String) -> String? { - let key = E2E_certificate + account migrate(key: key) - - let certificate = try? keychain.get(key) - return certificate + return try? keychain.get(key) } func setEndToEndCertificate(account: String, certificate: String) { - let key = E2E_certificate + account keychain[key] = certificate } + + func getEndToEndPrivateKey(account: String) -> String? { + let key = E2E_PrivateKey + account + migrate(key: key) + return try? keychain.get(key) + } + + func setEndToEndPrivateKey(account: String, privateKey: String) { + let key = E2E_PrivateKey + account + migrate(key: key) + keychain[key] = privateKey + } } From 3ccc71dd8e48a261981cf03c4c19e881159ec8c7 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:51:55 +0200 Subject: [PATCH 37/90] getEndToEndPublicKey --- iOSClient/Settings/NCEndToEndInitialize.swift | 8 ++-- iOSClient/Utility/CCUtility.h | 3 -- iOSClient/Utility/CCUtility.m | 38 ++++--------------- iOSClient/Utility/NCKeychain.swift | 12 ++++++ 4 files changed, 23 insertions(+), 38 deletions(-) diff --git a/iOSClient/Settings/NCEndToEndInitialize.swift b/iOSClient/Settings/NCEndToEndInitialize.swift index 35efe4f423..9f61753dbe 100644 --- a/iOSClient/Settings/NCEndToEndInitialize.swift +++ b/iOSClient/Settings/NCEndToEndInitialize.swift @@ -170,9 +170,9 @@ class NCEndToEndInitialize: NSObject { // request server publicKey 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) self.delegate?.endToEndInitializeSuccess() @@ -274,9 +274,9 @@ class NCEndToEndInitialize: NSObject { // request server publicKey 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) if copyPassphrase { diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index a4960057b4..1fe92cafcd 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -43,9 +43,6 @@ // E2EE ------------------------------------------- -+ (NSString *)getEndToEndPublicKey:(NSString *)account; -+ (void)setEndToEndPublicKey:(NSString *)account publicKey:(NSString *)publicKey; - + (NSString *)getEndToEndPassphrase:(NSString *)account; + (void)setEndToEndPassphrase:(NSString *)account passphrase:(NSString *)passphrase; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 0a879dead4..8c09b26f82 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -50,30 +50,6 @@ + (void)deleteAllChainStore #pragma ------------------------------ GET/SET -+ (NSString *)getEndToEndPrivateKey:(NSString *)account -{ - NSString *key = [E2E_PrivateKey stringByAppendingString:account]; - return [UICKeyChainStore stringForKey:key service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (void)setEndToEndPrivateKey:(NSString *)account privateKey:(NSString *)privateKey -{ - NSString *key = [E2E_PrivateKey stringByAppendingString:account]; - [UICKeyChainStore setString:privateKey forKey:key service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (NSString *)getEndToEndPublicKey:(NSString *)account -{ - NSString *key = [E2E_PublicKey stringByAppendingString:account]; - return [UICKeyChainStore stringForKey:key service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (void)setEndToEndPublicKey:(NSString *)account publicKey:(NSString *)publicKey -{ - NSString *key = [E2E_PublicKey stringByAppendingString:account]; - [UICKeyChainStore setString:publicKey forKey:key service:NCGlobal.shared.serviceShareKeyChain]; -} - + (NSString *)getEndToEndPassphrase:(NSString *)account { NSString *key = [E2E_Passphrase stringByAppendingString:account]; @@ -91,10 +67,10 @@ + (BOOL)isEndToEndEnabled:(NSString *)account NSString* versionE2EE = [[NCGlobal shared] capabilityE2EEApiVersion]; // NSString *certificate = [self getEndToEndCertificate:account]; - NSString *publicKey = [self getEndToEndPublicKey:account]; - NSString *privateKey = [self getEndToEndPrivateKey:account]; - NSString *passphrase = [self getEndToEndPassphrase:account]; - + //NSString *publicKey = [self getEndToEndPublicKey:account]; + //NSString *privateKey = [self getEndToEndPrivateKey:account]; + // NSString *passphrase = [self getEndToEndPassphrase:account]; + //if (passphrase.length > 0 && privateKey.length > 0 && certificate.length > 0 && publicKey.length > 0 && [NCGlobal.shared.e2eeVersions containsObject:versionE2EE]) { return YES; //} else { @@ -105,9 +81,9 @@ + (BOOL)isEndToEndEnabled:(NSString *)account + (void)clearAllKeysEndToEnd:(NSString *)account { // [self setEndToEndCertificate:account certificate:nil]; - [self setEndToEndPrivateKey:account privateKey:nil]; - [self setEndToEndPublicKey:account publicKey:nil]; - [self setEndToEndPassphrase:account passphrase:nil]; + //[self setEndToEndPrivateKey:account privateKey:nil]; + //[self setEndToEndPublicKey:account publicKey:nil]; + //[self setEndToEndPassphrase:account passphrase:nil]; // OLD [UICKeyChainStore setString:nil forKey:[@"EndToEndPublicKey_" stringByAppendingString:account] service:NCGlobal.shared.serviceShareKeyChain]; diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index 7221fdf1d4..def3b8f97d 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -219,4 +219,16 @@ import KeychainAccess migrate(key: key) keychain[key] = privateKey } + + func getEndToEndPublicKey(account: String) -> String? { + let key = E2E_PublicKey + account + migrate(key: key) + return try? keychain.get(key) + } + + func setEndToEndPublicKey(account: String, publicKey: String) { + let key = E2E_PublicKey + account + migrate(key: key) + keychain[key] = publicKey + } } From 5914964409a7987b0377b5498ac4fd8f2fe254ed Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:53:40 +0200 Subject: [PATCH 38/90] fix --- iOSClient/Utility/NCKeychain.swift | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index def3b8f97d..d3d3007c13 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -216,7 +216,6 @@ import KeychainAccess func setEndToEndPrivateKey(account: String, privateKey: String) { let key = E2E_PrivateKey + account - migrate(key: key) keychain[key] = privateKey } @@ -228,7 +227,17 @@ import KeychainAccess func setEndToEndPublicKey(account: String, publicKey: String) { let key = E2E_PublicKey + account - migrate(key: key) keychain[key] = publicKey } + + func getEndToEndPassphrase(account: String) -> String? { + let key = E2E_Passphrase + account + migrate(key: key) + return try? keychain.get(key) + } + + func setEndToEndPassphrase(account: String, passphrase: String) { + let key = E2E_Passphrase + account + keychain[key] = passphrase + } } From 783425f5d3a12391c961ebacfc5b1efda0d275f2 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 15:13:42 +0200 Subject: [PATCH 39/90] e2ee --- Share/NCShareExtension+DataSource.swift | 2 +- iOSClient/AppDelegate.swift | 2 +- .../Data/NCManageDatabase+Metadata.swift | 4 +- .../NCCollectionViewCommon.swift | 6 +-- iOSClient/Menu/AppDelegate+Menu.swift | 6 +-- .../E2EE/NCEndToEndMetadataV1.swift | 4 +- .../Networking/E2EE/NCNetworkingE2EE.swift | 2 +- iOSClient/Settings/NCEndToEndInitialize.swift | 8 ++-- iOSClient/Settings/NCManageE2EE.swift | 8 ++-- iOSClient/Utility/CCUtility.h | 11 ------ iOSClient/Utility/CCUtility.m | 39 ------------------- iOSClient/Utility/NCKeychain.swift | 27 +++++++++++-- 12 files changed, 44 insertions(+), 75 deletions(-) diff --git a/Share/NCShareExtension+DataSource.swift b/Share/NCShareExtension+DataSource.swift index 8aef98fbed..6673c47725 100644 --- a/Share/NCShareExtension+DataSource.swift +++ b/Share/NCShareExtension+DataSource.swift @@ -34,7 +34,7 @@ extension NCShareExtension: UICollectionViewDelegate { return showAlert(description: "_invalid_url_") } - if metadata.e2eEncrypted && !CCUtility.isEnd(toEndEnabled: activeAccount.account) { + if metadata.e2eEncrypted && !NCKeychain().isEndToEndEnabled(account: activeAccount.account) { showAlert(title: "_info_", description: "_e2e_goto_settings_for_enable_") } diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index db2eb9a121..4c3378beb1 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -622,7 +622,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD } NCManageDatabase.shared.clearDatabase(account: account, removeAccount: true) - CCUtility.clearAllKeysEnd(toEnd: account) + NCKeychain().clearAllKeysEndToEnd(account: account) CCUtility.clearAllKeysPushNotification(account) CCUtility.setPassword(account, password: nil) diff --git a/iOSClient/Data/NCManageDatabase+Metadata.swift b/iOSClient/Data/NCManageDatabase+Metadata.swift index a730c3be20..d9a2e3ac76 100644 --- a/iOSClient/Data/NCManageDatabase+Metadata.swift +++ b/iOSClient/Data/NCManageDatabase+Metadata.swift @@ -202,11 +202,11 @@ extension tableMetadata { } var isDirectoySettableE2EE: Bool { - return directory && size == 0 && !e2eEncrypted && CCUtility.isEnd(toEndEnabled: account) + return directory && size == 0 && !e2eEncrypted && NCKeychain().isEndToEndEnabled(account: account) } 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 { diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index de14e87af8..ba6d1f23fd 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -1012,8 +1012,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS self.metadataFolder = metadataFolder // E2EE 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) { 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 @@ -1105,7 +1105,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate { if metadata.e2eEncrypted { if NCGlobal.shared.capabilityE2EEEnabled { - if !CCUtility.isEnd(toEndEnabled: appDelegate.account) { + if !NCKeychain().isEndToEndEnabled(account: appDelegate.account) { let e2ee = NCEndToEndInitialize() e2ee.delegate = self e2ee.initEndToEndEncryption() diff --git a/iOSClient/Menu/AppDelegate+Menu.swift b/iOSClient/Menu/AppDelegate+Menu.swift index 7d77076eb3..05e4531861 100644 --- a/iOSClient/Menu/AppDelegate+Menu.swift +++ b/iOSClient/Menu/AppDelegate+Menu.swift @@ -111,7 +111,7 @@ extension AppDelegate { ) ) - if CCUtility.isEnd(toEndEnabled: appDelegate.account) { + if NCKeychain().isEndToEndEnabled(account: appDelegate.account) { actions.append(.seperator(order: 0)) } @@ -128,7 +128,7 @@ extension AppDelegate { ) // Folder encrypted - if !isDirectoryE2EE && CCUtility.isEnd(toEndEnabled: appDelegate.account) { + if !isDirectoryE2EE && NCKeychain().isEndToEndEnabled(account: appDelegate.account) { actions.append( NCMenuAction(title: NSLocalizedString("_create_folder_e2ee_", comment: ""), icon: UIImage(named: "folderEncrypted")!.image(color: NCBrandColor.shared.brandElement, size: 50), @@ -140,7 +140,7 @@ extension AppDelegate { ) } - if CCUtility.isEnd(toEndEnabled: appDelegate.account) { + if NCKeychain().isEndToEndEnabled(account: appDelegate.account) { actions.append(.seperator(order: 0)) } diff --git a/iOSClient/Networking/E2EE/NCEndToEndMetadataV1.swift b/iOSClient/Networking/E2EE/NCEndToEndMetadataV1.swift index a9c1047dda..99ca9b7dcf 100644 --- a/iOSClient/Networking/E2EE/NCEndToEndMetadataV1.swift +++ b/iOSClient/Networking/E2EE/NCEndToEndMetadataV1.swift @@ -166,7 +166,7 @@ extension NCEndToEndMetadata { } // 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 checksum = NCEndToEndEncryption.sharedManager().createSHA256(dataChecksum) @@ -345,7 +345,7 @@ extension NCEndToEndMetadata { } // 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 checksum = NCEndToEndEncryption.sharedManager().createSHA256(dataChecksum) if metadata.checksum != checksum { diff --git a/iOSClient/Networking/E2EE/NCNetworkingE2EE.swift b/iOSClient/Networking/E2EE/NCNetworkingE2EE.swift index d5b724b3af..e7eaa5e117 100644 --- a/iOSClient/Networking/E2EE/NCNetworkingE2EE.swift +++ b/iOSClient/Networking/E2EE/NCNetworkingE2EE.swift @@ -191,7 +191,7 @@ class NCNetworkingE2EE: NSObject { func unlockAll(account: String) { - guard CCUtility.isEnd(toEndEnabled: account) else { return } + guard NCKeychain().isEndToEndEnabled(account: account) else { return } Task { for result in NCManageDatabase.shared.getE2EAllTokenLock(account: account) { diff --git a/iOSClient/Settings/NCEndToEndInitialize.swift b/iOSClient/Settings/NCEndToEndInitialize.swift index 9f61753dbe..6f64ddf6a2 100644 --- a/iOSClient/Settings/NCEndToEndInitialize.swift +++ b/iOSClient/Settings/NCEndToEndInitialize.swift @@ -45,7 +45,7 @@ class NCEndToEndInitialize: NSObject { @objc func initEndToEndEncryption() { // Clear all keys - CCUtility.clearAllKeysEnd(toEnd: appDelegate.account) + NCKeychain().clearAllKeysEndToEnd(account: appDelegate.account) self.getPublicKey() } @@ -148,7 +148,7 @@ class NCEndToEndInitialize: NSObject { let ok = UIAlertAction(title: "OK", style: .default, handler: { _ -> Void in - let passphrase = passphraseTextField?.text + let passphrase = passphraseTextField?.text ?? "" let publicKey = NCKeychain().getEndToEndCertificate(account: self.appDelegate.account) @@ -165,7 +165,7 @@ class NCEndToEndInitialize: NSObject { } // Save to keychain - CCUtility.setEndToEndPassphrase(self.appDelegate.account, passphrase: passphrase) + NCKeychain().setEndToEndPassphrase(account: self.appDelegate.account, passphrase: passphrase) // request server publicKey NextcloudKit.shared.getE2EEPublicKey { account, publicKey, _, error in @@ -269,7 +269,7 @@ class NCEndToEndInitialize: NSObject { if error == .success, account == self.appDelegate.account, let privateKey = privateKeyString { NCKeychain().setEndToEndPrivateKey(account: account, privateKey: String(privateKey)) - CCUtility.setEndToEndPassphrase(account, passphrase: e2ePassphrase) + NCKeychain().setEndToEndPassphrase(account: account, passphrase: e2ePassphrase) // request server publicKey NextcloudKit.shared.getE2EEPublicKey { account, publicKey, _, error in diff --git a/iOSClient/Settings/NCManageE2EE.swift b/iOSClient/Settings/NCManageE2EE.swift index 1d066e394c..588615d715 100644 --- a/iOSClient/Settings/NCManageE2EE.swift +++ b/iOSClient/Settings/NCManageE2EE.swift @@ -50,7 +50,7 @@ class NCManageE2EE: NSObject, ObservableObject, NCEndToEndInitializeDelegate, TO super.init() endToEndInitialize.delegate = self - isEndToEndEnabled = CCUtility.isEnd(toEndEnabled: appDelegate.account) + isEndToEndEnabled = NCKeychain().isEndToEndEnabled(account: appDelegate.account) if isEndToEndEnabled { statusOfService = NSLocalizedString("_status_e2ee_configured_", comment: "") } else { @@ -103,7 +103,7 @@ class NCManageE2EE: NSObject, ObservableObject, NCEndToEndInitializeDelegate, TO case "startE2E": endToEndInitialize.initEndToEndEncryption() case "readPassphrase": - if let e2ePassphrase = CCUtility.getEndToEndPassphrase(appDelegate.account) { + if let e2ePassphrase = NCKeychain().getEndToEndPassphrase(account: appDelegate.account) { print("[LOG]Passphrase: " + 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) @@ -116,8 +116,8 @@ class NCManageE2EE: NSObject, ObservableObject, NCEndToEndInitializeDelegate, TO case "removeLocallyEncryption": 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 - 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 })) appDelegate.window?.rootViewController?.present(alertController, animated: true) diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 1fe92cafcd..328508bb8c 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -41,17 +41,6 @@ + (void)deleteAllChainStore; -// E2EE ------------------------------------------- - -+ (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; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 8c09b26f82..e074dd24c2 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -50,45 +50,6 @@ + (void)deleteAllChainStore #pragma ------------------------------ GET/SET -+ (NSString *)getEndToEndPassphrase:(NSString *)account -{ - NSString *key = [E2E_Passphrase stringByAppendingString:account]; - return [UICKeyChainStore stringForKey:key service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (void)setEndToEndPassphrase:(NSString *)account passphrase:(NSString *)passphrase -{ - NSString *key = [E2E_Passphrase stringByAppendingString:account]; - [UICKeyChainStore setString:passphrase forKey:key service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (BOOL)isEndToEndEnabled:(NSString *)account -{ - NSString* versionE2EE = [[NCGlobal shared] capabilityE2EEApiVersion]; - - // NSString *certificate = [self getEndToEndCertificate:account]; - //NSString *publicKey = [self getEndToEndPublicKey:account]; - //NSString *privateKey = [self getEndToEndPrivateKey:account]; - // NSString *passphrase = [self getEndToEndPassphrase:account]; - - //if (passphrase.length > 0 && privateKey.length > 0 && certificate.length > 0 && publicKey.length > 0 && [NCGlobal.shared.e2eeVersions containsObject:versionE2EE]) { - return YES; - //} else { - // return NO; - //} -} - -+ (void)clearAllKeysEndToEnd:(NSString *)account -{ - // [self setEndToEndCertificate:account certificate:nil]; - //[self setEndToEndPrivateKey:account privateKey:nil]; - //[self setEndToEndPublicKey:account publicKey:nil]; - //[self setEndToEndPassphrase:account passphrase:nil]; - - // OLD - [UICKeyChainStore setString:nil forKey:[@"EndToEndPublicKey_" stringByAppendingString:account] service:NCGlobal.shared.serviceShareKeyChain]; -} - + (BOOL)getDisableFilesApp { return [[UICKeyChainStore stringForKey:@"disablefilesapp" service:NCGlobal.shared.serviceShareKeyChain] boolValue]; diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index d3d3007c13..0648a2281c 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -197,13 +197,15 @@ import KeychainAccess keychain[key] = String(prefix) } + // MARK: - E2EE + func getEndToEndCertificate(account: String) -> String? { let key = E2E_certificate + account migrate(key: key) return try? keychain.get(key) } - func setEndToEndCertificate(account: String, certificate: String) { + func setEndToEndCertificate(account: String, certificate: String?) { let key = E2E_certificate + account keychain[key] = certificate } @@ -214,7 +216,7 @@ import KeychainAccess return try? keychain.get(key) } - func setEndToEndPrivateKey(account: String, privateKey: String) { + func setEndToEndPrivateKey(account: String, privateKey: String?) { let key = E2E_PrivateKey + account keychain[key] = privateKey } @@ -225,7 +227,7 @@ import KeychainAccess return try? keychain.get(key) } - func setEndToEndPublicKey(account: String, publicKey: String) { + func setEndToEndPublicKey(account: String, publicKey: String?) { let key = E2E_PublicKey + account keychain[key] = publicKey } @@ -236,8 +238,25 @@ import KeychainAccess return try? keychain.get(key) } - func setEndToEndPassphrase(account: String, passphrase: String) { + func setEndToEndPassphrase(account: String, passphrase: String?) { let key = E2E_Passphrase + account keychain[key] = passphrase } + + func isEndToEndEnabled(account: String) -> Bool { + + guard let certificate = getEndToEndCertificate(account: account), !certificate.isEmpty, + let publicKey = getEndToEndPublicKey(account: account), !publicKey.isEmpty, + let privateKey = getEndToEndPrivateKey(account: account), !privateKey.isEmpty, + let passphrase = getEndToEndPassphrase(account: account), !passphrase.isEmpty, + NCGlobal.shared.e2eeVersions.contains(NCGlobal.shared.capabilityE2EEApiVersion) else { return false } + return true + } + + func clearAllKeysEndToEnd(account: String) { + setEndToEndCertificate(account: account, certificate: nil) + setEndToEndPrivateKey(account: account, privateKey: nil) + setEndToEndPublicKey(account: account, publicKey: nil) + setEndToEndPassphrase(account: account, passphrase: nil) + } } From 2ecf8928ecd14d1a6d3e8f84670eafc03683dd50 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 15:38:41 +0200 Subject: [PATCH 40/90] c o d --- File Provider Extension/FileProviderData.swift | 4 ++-- Share/NCShareExtension+NCDelegate.swift | 2 +- Widget/Dashboard/DashboardData.swift | 2 +- Widget/Files/FilesData.swift | 2 +- Widget/Lockscreen/LockscreenData.swift | 2 +- iOSClient/AppDelegate.swift | 8 ++++---- iOSClient/Login/NCLoginWeb.swift | 4 ++-- iOSClient/Networking/NCNetworkingCheckRemoteUser.swift | 3 ++- iOSClient/PushNotification/NCPushNotification.m | 4 ++-- iOSClient/Settings/CCAdvanced.m | 4 ++-- iOSClient/Utility/CCUtility.h | 2 +- iOSClient/Utility/CCUtility.m | 6 +++--- iOSClient/Utility/NCKeychain.swift | 10 ++++++++++ 13 files changed, 32 insertions(+), 21 deletions(-) diff --git a/File Provider Extension/FileProviderData.swift b/File Provider Extension/FileProviderData.swift index 8e66267604..b2a7a34d0d 100644 --- a/File Provider Extension/FileProviderData.swift +++ b/File Provider Extension/FileProviderData.swift @@ -93,7 +93,7 @@ class fileProviderData: NSObject { 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 return tableAccount.init(value: activeAccount) @@ -117,7 +117,7 @@ class fileProviderData: NSObject { 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 return tableAccount.init(value: activeAccount) diff --git a/Share/NCShareExtension+NCDelegate.swift b/Share/NCShareExtension+NCDelegate.swift index 88bb9b4eff..1aff747636 100644 --- a/Share/NCShareExtension+NCDelegate.swift +++ b/Share/NCShareExtension+NCDelegate.swift @@ -88,7 +88,7 @@ extension NCShareExtension: NCEmptyDataSetDelegate, NCAccountRequestDelegate { account: activeAccount.account, user: activeAccount.user, userId: activeAccount.userId, - password: CCUtility.getPassword(activeAccount.account), + password: NCKeychain().getPassword(account: activeAccount.account), urlBase: activeAccount.urlBase, userAgent: userAgent, nextcloudVersion: 0, diff --git a/Widget/Dashboard/DashboardData.swift b/Widget/Dashboard/DashboardData.swift index 5e5924c43b..74da6e57e3 100644 --- a/Widget/Dashboard/DashboardData.swift +++ b/Widget/Dashboard/DashboardData.swift @@ -130,7 +130,7 @@ func getDashboardDataEntry(configuration: DashboardIntent?, isPreview: Bool, dis } // NETWORKING - let password = CCUtility.getPassword(account.account)! + let password = NCKeychain().getPassword(account: account.account) NextcloudKit.shared.setup( account: account.account, user: account.user, diff --git a/Widget/Files/FilesData.swift b/Widget/Files/FilesData.swift index 0247eec895..089d896caf 100644 --- a/Widget/Files/FilesData.swift +++ b/Widget/Files/FilesData.swift @@ -124,7 +124,7 @@ func getFilesDataEntry(configuration: AccountIntent?, isPreview: Bool, displaySi } // NETWORKING - let password = CCUtility.getPassword(account.account)! + let password = NCKeychain().getPassword(account: account.account) NextcloudKit.shared.setup( account: account.account, user: account.user, diff --git a/Widget/Lockscreen/LockscreenData.swift b/Widget/Lockscreen/LockscreenData.swift index df05f282df..0689a466ba 100644 --- a/Widget/Lockscreen/LockscreenData.swift +++ b/Widget/Lockscreen/LockscreenData.swift @@ -63,7 +63,7 @@ func getLockscreenDataEntry(configuration: AccountIntent?, isPreview: Bool, fami } // NETWORKING - let password = CCUtility.getPassword(account.account)! + let password = NCKeychain().getPassword(account: account.account) NextcloudKit.shared.setup( account: account.account, user: account.user, diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index 4c3378beb1..feeeff83fd 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -117,7 +117,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD if let account = NCManageDatabase.shared.getActiveAccount() { 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)") } } @@ -128,7 +128,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD urlBase = activeAccount.urlBase user = activeAccount.user 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) NCManageDatabase.shared.setCapabilities(account: account) @@ -530,7 +530,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD } @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) } @@ -584,7 +584,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD self.urlBase = tableAccount.urlBase self.user = tableAccount.user 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) NCManageDatabase.shared.setCapabilities(account: account) diff --git a/iOSClient/Login/NCLoginWeb.swift b/iOSClient/Login/NCLoginWeb.swift index ef7ef9d4f5..07cd75ac23 100644 --- a/iOSClient/Login/NCLoginWeb.swift +++ b/iOSClient/Login/NCLoginWeb.swift @@ -129,7 +129,7 @@ class NCLoginWeb: UIViewController { // TITLE if let host = URL(string: urlBase)?.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 } } @@ -142,7 +142,7 @@ class NCLoginWeb: UIViewController { // Stop timer error network 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 alertController = UIAlertController(title: titleView, message: message, preferredStyle: .alert) diff --git a/iOSClient/Networking/NCNetworkingCheckRemoteUser.swift b/iOSClient/Networking/NCNetworkingCheckRemoteUser.swift index a8f293d56f..08ec3ee9f6 100644 --- a/iOSClient/Networking/NCNetworkingCheckRemoteUser.swift +++ b/iOSClient/Networking/NCNetworkingCheckRemoteUser.swift @@ -28,8 +28,9 @@ class NCNetworkingCheckRemoteUser { func checkRemoteUser(account: String, error: NKError) { + let token = NCKeychain().getPassword(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 } NCNetworking.shared.cancel(inBackground: true) diff --git a/iOSClient/PushNotification/NCPushNotification.m b/iOSClient/PushNotification/NCPushNotification.m index 8c188de91a..00c91c6fc6 100644 --- a/iOSClient/PushNotification/NCPushNotification.m +++ b/iOSClient/PushNotification/NCPushNotification.m @@ -106,7 +106,7 @@ - (void)subscribingNextcloudServerPushNotification:(NSString *)account urlBase:( NSString *pushDevicePublicKey = [[NSString alloc] initWithData:pushPublicKey encoding:NSUTF8StringEncoding]; 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) { 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) { @@ -132,7 +132,7 @@ - (void)unsubscribingNextcloudServerPushNotification:(NSString *)account urlBase NSString *signature = [CCUtility getPushNotificationDeviceIdentifierSignature:account]; NSString *publicKey = [CCUtility getPushNotificationSubscribingPublicKey: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) { NSString *userAgent = [NSString stringWithFormat:@"%@ (Strict VoIP)", [[NCBrandOptions shared] getUserAgent]]; NSString *proxyServerPath = [NCBrandOptions shared].pushNotificationServerProxy; diff --git a/iOSClient/Settings/CCAdvanced.m b/iOSClient/Settings/CCAdvanced.m index d45eb949cc..568d3cb6b9 100755 --- a/iOSClient/Settings/CCAdvanced.m +++ b/iOSClient/Settings/CCAdvanced.m @@ -48,7 +48,7 @@ - (void)initializeForm row = [XLFormRowDescriptor formRowDescriptorWithTag:@"showHiddenFiles" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_show_hidden_files_", nil)]; row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - if ([[NCKeychain init] showHiddenFiles]) row.value = @"1"; + if ([[[NCKeychain alloc] init] showHiddenFiles]) row.value = @"1"; else row.value = @"0"; [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; @@ -62,7 +62,7 @@ - (void)initializeForm row = [XLFormRowDescriptor formRowDescriptorWithTag:@"formatCompatibility" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_format_compatibility_", nil)]; row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - if ([[NCKeychain init] formatCompatibility]) row.value = @"1"; + if ([[[NCKeychain alloc] init] formatCompatibility]) row.value = @"1"; else row.value = @"0"; [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 328508bb8c..a44ffe7317 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -65,7 +65,7 @@ + (void)setDisableCrashservice:(BOOL)disable; + (void)setPassword:(NSString *)account password:(NSString *)password; -+ (NSString *)getPassword:(NSString *)account; +//+ (NSString *)getPassword:(NSString *)account; + (void)setHCBusinessType:(NSString *)professions; + (NSString *)getHCBusinessType; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index e074dd24c2..9aa19eb79a 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -495,7 +495,7 @@ + (NSString *)createFileName:(NSString *)fileName fileDate:(NSDate *)fileDate fi BOOL addFileNameType = NO; // Original FileName ? - if ([[NCKeychain init] getOriginalFileNameWithKey:keyFileNameOriginal] && !forcedNewFileName) { + if ([[[NCKeychain alloc] init] getOriginalFileNameWithKey:keyFileNameOriginal] && !forcedNewFileName) { return fileName; } @@ -520,13 +520,13 @@ + (NSString *)createFileName:(NSString *)fileName fileDate:(NSDate *)fileDate fi // Use File Name Type if (keyFileNameType) - addFileNameType = [[NCKeychain init] getFileNameTypeWithKey:keyFileNameType]; + addFileNameType = [[[NCKeychain alloc] init] getFileNameTypeWithKey:keyFileNameType]; NSString *fileNameExt = [[fileName pathExtension] lowercaseString]; if (keyFileName) { - fileName = [[NCKeychain init] getFileNameMaskWithKey:keyFileName]; + fileName = [[[NCKeychain alloc] init] getFileNameMaskWithKey:keyFileName]; if ([fileName length] > 0) { diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index 0648a2281c..42bab7076f 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -35,6 +35,10 @@ import KeychainAccess let E2E_PublicKey = "EndToEndPublicKeyServer_" // swiftlint:enable identifier_name + override init() { + super.init() + } + var typeFilterScanDocument: NCGlobal.TypeFilterScanDocument { get { if let rawValue = try? keychain.get("ScanDocumentTypeFilter"), let value = NCGlobal.TypeFilterScanDocument(rawValue: rawValue) { @@ -159,6 +163,12 @@ import KeychainAccess try? keychain.removeAll() } + @objc func getPassword(account: String) -> String { + let key = "password" + account + migrate(key: key) + return (try? keychain.get(key)) ?? "" + } + @objc func getOriginalFileName(key: String) -> Bool { migrate(key: key) if let value = try? keychain.get(key), let result = Bool(value) { From 4c9216b101289dd031cc105ccedb1b34e779ad57 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 15:50:36 +0200 Subject: [PATCH 41/90] setPassword --- iOSClient/AppDelegate.swift | 2 +- iOSClient/Data/NCManageDatabase+Account.swift | 2 +- .../Networking/NCNetworkingCheckRemoteUser.swift | 4 ++-- iOSClient/Utility/CCUtility.h | 3 --- iOSClient/Utility/CCUtility.m | 14 -------------- iOSClient/Utility/NCKeychain.swift | 5 +++++ 6 files changed, 9 insertions(+), 21 deletions(-) diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index feeeff83fd..789dd1b82c 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -624,7 +624,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD NCKeychain().clearAllKeysEndToEnd(account: account) CCUtility.clearAllKeysPushNotification(account) - CCUtility.setPassword(account, password: nil) + NCKeychain().setPassword(account: account, password: nil) self.account = "" self.urlBase = "" diff --git a/iOSClient/Data/NCManageDatabase+Account.swift b/iOSClient/Data/NCManageDatabase+Account.swift index abfa7f1450..394d694e96 100644 --- a/iOSClient/Data/NCManageDatabase+Account.swift +++ b/iOSClient/Data/NCManageDatabase+Account.swift @@ -106,7 +106,7 @@ extension NCManageDatabase { addObject.autoUploadWWAnVideo = true } - CCUtility.setPassword(account, password: password) + NCKeychain().setPassword(account: account, password: password) addObject.urlBase = urlBase addObject.user = user diff --git a/iOSClient/Networking/NCNetworkingCheckRemoteUser.swift b/iOSClient/Networking/NCNetworkingCheckRemoteUser.swift index 08ec3ee9f6..6338004cb6 100644 --- a/iOSClient/Networking/NCNetworkingCheckRemoteUser.swift +++ b/iOSClient/Networking/NCNetworkingCheckRemoteUser.swift @@ -52,7 +52,7 @@ class NCNetworkingCheckRemoteUser { let description = String.localizedStringWithFormat(NSLocalizedString("_error_check_remote_user_", comment: ""), tableAccount.user, tableAccount.urlBase) let error = NKError(errorCode: error.errorCode, errorDescription: description) 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.") } } @@ -64,7 +64,7 @@ class NCNetworkingCheckRemoteUser { let description = String.localizedStringWithFormat(NSLocalizedString("_error_check_remote_user_", comment: ""), tableAccount.user, tableAccount.urlBase) let error = NKError(errorCode: error.errorCode, errorDescription: description) NCContentPresenter.shared.showError(error: error, priority: .max) - CCUtility.setPassword(account, password: nil) + NCKeychain().setPassword(account: account, password: nil) } } } diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index a44ffe7317..6ed2f82810 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -64,9 +64,6 @@ + (BOOL)getDisableCrashservice; + (void)setDisableCrashservice:(BOOL)disable; -+ (void)setPassword:(NSString *)account password:(NSString *)password; -//+ (NSString *)getPassword:(NSString *)account; - + (void)setHCBusinessType:(NSString *)professions; + (NSString *)getHCBusinessType; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 9aa19eb79a..09f134a9a5 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -171,20 +171,6 @@ + (void)setDisableCrashservice:(BOOL)disable [UICKeyChainStore setString:sDisable forKey:@"crashservice" service:NCGlobal.shared.serviceShareKeyChain]; } -+ (void)setPassword:(NSString *)account password:(NSString *)password -{ - NSString *key = [@"password" stringByAppendingString:account]; - [UICKeyChainStore setString:password forKey:key service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (NSString *)getPassword:(NSString *)account -{ - NSString *key = [@"password" stringByAppendingString:account]; - NSString *result = [UICKeyChainStore stringForKey:key service:NCGlobal.shared.serviceShareKeyChain]; - if (result == nil) { result = @""; } - return result; -} - + (void)setHCBusinessType:(NSString *)professions { [UICKeyChainStore setString:professions forKey:@"businessType" service:NCGlobal.shared.serviceShareKeyChain]; diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index 42bab7076f..d24991b6b9 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -169,6 +169,11 @@ import KeychainAccess return (try? keychain.get(key)) ?? "" } + @objc func setPassword(account: String, password: String?) { + let key = "password" + account + keychain[key] = password + } + @objc func getOriginalFileName(key: String) -> Bool { migrate(key: key) if let value = try? keychain.get(key), let result = Bool(value) { From b4162b85cb9c999c5ef521af362025579ba3eb94 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 15:57:54 +0200 Subject: [PATCH 42/90] disableFilesApp --- File Provider Extension/FileProviderExtension.swift | 2 +- iOSClient/Settings/CCAdvanced.m | 4 ++-- iOSClient/Utility/CCUtility.h | 3 --- iOSClient/Utility/CCUtility.m | 11 ----------- iOSClient/Utility/NCKeychain.swift | 13 +++++++++++++ 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/File Provider Extension/FileProviderExtension.swift b/File Provider Extension/FileProviderExtension.swift index 0450da4127..de89bb0598 100644 --- a/File Provider Extension/FileProviderExtension.swift +++ b/File Provider Extension/FileProviderExtension.swift @@ -80,7 +80,7 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate { throw NSError(domain: NSFileProviderErrorDomain, code: NSFileProviderError.notAuthenticated.rawValue, userInfo: [:]) } else if NCKeychain().passcode != nil, NCKeychain().requestPasscodeAtStart { 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)]) } } diff --git a/iOSClient/Settings/CCAdvanced.m b/iOSClient/Settings/CCAdvanced.m index 568d3cb6b9..b33bbde172 100755 --- a/iOSClient/Settings/CCAdvanced.m +++ b/iOSClient/Settings/CCAdvanced.m @@ -95,7 +95,7 @@ - (void)initializeForm // Disable Files App row = [XLFormRowDescriptor formRowDescriptorWithTag:@"disablefilesapp" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_disable_files_app_", nil)]; row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - if ([CCUtility getDisableFilesApp]) row.value = @"1"; + if ([[NCKeychain alloc] init].disableFilesApp) row.value = @"1"; else row.value = @"0"; [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; @@ -333,7 +333,7 @@ - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor ol if ([rowDescriptor.tag isEqualToString:@"disablefilesapp"]) { - [CCUtility setDisableFilesApp:[[rowDescriptor.value valueData] boolValue]]; + [[NCKeychain alloc] init].disableFilesApp = [[rowDescriptor.value valueData] boolValue]; } if ([rowDescriptor.tag isEqualToString:@"crashservice"]) { diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 6ed2f82810..9287967419 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -41,9 +41,6 @@ + (void)deleteAllChainStore; -+ (BOOL)getDisableFilesApp; -+ (void)setDisableFilesApp:(BOOL)disable; - + (void)setPushNotificationPublicKey:(NSString *)account data:(NSData *)data; + (NSData *)getPushNotificationPublicKey:(NSString *)account; + (void)setPushNotificationSubscribingPublicKey:(NSString *)account publicKey:(NSString *)publicKey; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 09f134a9a5..5730dd224a 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -50,17 +50,6 @@ + (void)deleteAllChainStore #pragma ------------------------------ GET/SET -+ (BOOL)getDisableFilesApp -{ - return [[UICKeyChainStore stringForKey:@"disablefilesapp" service:NCGlobal.shared.serviceShareKeyChain] boolValue]; -} - -+ (void)setDisableFilesApp:(BOOL)disable -{ - NSString *sDisable = (disable) ? @"true" : @"false"; - [UICKeyChainStore setString:sDisable forKey:@"disablefilesapp" service:NCGlobal.shared.serviceShareKeyChain]; -} - + (void)setPushNotificationPublicKey:(NSString *)account data:(NSData *)data { NSString *key = [@"PNPublicKey" stringByAppendingString:account]; diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index d24991b6b9..bc38c234c6 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -149,6 +149,19 @@ import KeychainAccess } } + @objc var disableFilesApp: Bool { + get { + migrate(key: "disablefilesapp") + if let value = try? keychain.get("disablefilesapp"), let result = Bool(value) { + return result + } + return true + } + set { + keychain["disablefilesapp"] = String(newValue) + } + } + // MARK: - private func migrate(key: String) { From 40b4416e72bb024c75d60d2fe9d7e299439a579e Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:01:12 +0200 Subject: [PATCH 43/90] Update NCKeychain.swift --- iOSClient/Utility/NCKeychain.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index bc38c234c6..35eca29cb2 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -79,7 +79,7 @@ import KeychainAccess if let value = try? keychain.get("requestPasscodeAtStart"), let result = Bool(value) { return result } - return false + return true } set { keychain["requestPasscodeAtStart"] = String(newValue) @@ -155,7 +155,7 @@ import KeychainAccess if let value = try? keychain.get("disablefilesapp"), let result = Bool(value) { return result } - return true + return false } set { keychain["disablefilesapp"] = String(newValue) From 874bbfbc6b87d7a287fcc27e55062207efddd070 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:10:52 +0200 Subject: [PATCH 44/90] live photo --- .../Data/NCManageDatabase+Metadata.swift | 2 +- .../Main/Create cloud/NCUploadAssets.swift | 2 +- iOSClient/Media/NCMediaCache.swift | 2 +- iOSClient/Networking/NCAutoUpload.swift | 2 +- iOSClient/Settings/CCAdvanced.m | 4 +- iOSClient/Utility/CCUtility.h | 8 ---- iOSClient/Utility/CCUtility.m | 47 ------------------- iOSClient/Utility/NCKeychain.swift | 13 +++++ 8 files changed, 19 insertions(+), 61 deletions(-) diff --git a/iOSClient/Data/NCManageDatabase+Metadata.swift b/iOSClient/Data/NCManageDatabase+Metadata.swift index d9a2e3ac76..450d09c919 100644 --- a/iOSClient/Data/NCManageDatabase+Metadata.swift +++ b/iOSClient/Data/NCManageDatabase+Metadata.swift @@ -1057,7 +1057,7 @@ extension NCManageDatabase { var classFile = metadata.classFile var fileName = (metadata.fileNameView as NSString).deletingPathExtension - if !metadata.livePhoto || !CCUtility.getLivePhoto() { + if !metadata.livePhoto || !NCKeychain().livePhoto { return nil } diff --git a/iOSClient/Main/Create cloud/NCUploadAssets.swift b/iOSClient/Main/Create cloud/NCUploadAssets.swift index e1698123ec..dbc7e2c12d 100644 --- a/iOSClient/Main/Create cloud/NCUploadAssets.swift +++ b/iOSClient/Main/Create cloud/NCUploadAssets.swift @@ -230,7 +230,7 @@ struct UploadAssetsView: View { forcedNewFileName: false)! : (previewStore.fileName + "." + ext) - if previewStore.assetType == .livePhoto && CCUtility.getLivePhoto() && previewStore.data == nil { + if previewStore.assetType == .livePhoto && NCKeychain().livePhoto && previewStore.data == nil { livePhoto = true } diff --git a/iOSClient/Media/NCMediaCache.swift b/iOSClient/Media/NCMediaCache.swift index 407e30216c..d3911013a2 100644 --- a/iOSClient/Media/NCMediaCache.swift +++ b/iOSClient/Media/NCMediaCache.swift @@ -136,7 +136,7 @@ import NextcloudKit guard let predicate = predicate else { return } - livePhoto = CCUtility.getLivePhoto() + livePhoto = NCKeychain().livePhoto metadatas = NCManageDatabase.shared.getMetadatasMedia(predicate: predicate, livePhoto: livePhoto) switch CCUtility.getMediaSortDate() { diff --git a/iOSClient/Networking/NCAutoUpload.swift b/iOSClient/Networking/NCAutoUpload.swift index f7fd8d9642..d2bf2139a7 100644 --- a/iOSClient/Networking/NCAutoUpload.swift +++ b/iOSClient/Networking/NCAutoUpload.swift @@ -117,7 +117,7 @@ class NCAutoUpload: NSObject { 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)! - if asset.mediaSubtypes.contains(.photoLive) && CCUtility.getLivePhoto() { + if asset.mediaSubtypes.contains(.photoLive), NCKeychain().livePhoto { livePhoto = true } diff --git a/iOSClient/Settings/CCAdvanced.m b/iOSClient/Settings/CCAdvanced.m index b33bbde172..ff96aa2212 100755 --- a/iOSClient/Settings/CCAdvanced.m +++ b/iOSClient/Settings/CCAdvanced.m @@ -70,7 +70,7 @@ - (void)initializeForm row = [XLFormRowDescriptor formRowDescriptorWithTag:@"livePhoto" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_upload_mov_livephoto_", nil)]; row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - if ([CCUtility getLivePhoto]) row.value = @"1"; + if ([[[NCKeychain alloc] init] livePhoto]) row.value = @"1"; else row.value = @"0"; [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; @@ -323,7 +323,7 @@ - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor ol if ([rowDescriptor.tag isEqualToString:@"livePhoto"]) { - [CCUtility setLivePhoto:[[rowDescriptor.value valueData] boolValue]]; + [[NCKeychain alloc] init].livePhoto = [[rowDescriptor.value valueData] boolValue]; } if ([rowDescriptor.tag isEqualToString:@"removePhotoCameraRoll"]) { diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 9287967419..13a76521a8 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -61,14 +61,6 @@ + (BOOL)getDisableCrashservice; + (void)setDisableCrashservice:(BOOL)disable; -+ (void)setHCBusinessType:(NSString *)professions; -+ (NSString *)getHCBusinessType; - -+ (NSData *)getDatabaseEncryptionKey; - -+ (BOOL)getLivePhoto; -+ (void)setLivePhoto:(BOOL)set; - + (NSString *)getMediaSortDate; + (void)setMediaSortDate:(NSString *)value; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 5730dd224a..d765410006 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -160,53 +160,6 @@ + (void)setDisableCrashservice:(BOOL)disable [UICKeyChainStore setString:sDisable forKey:@"crashservice" service:NCGlobal.shared.serviceShareKeyChain]; } -+ (void)setHCBusinessType:(NSString *)professions -{ - [UICKeyChainStore setString:professions forKey:@"businessType" service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (NSString *)getHCBusinessType -{ - return [UICKeyChainStore stringForKey:@"businessType" service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (NSData *)getDatabaseEncryptionKey -{ - NSData *key = [UICKeyChainStore dataForKey:@"databaseEncryptionKey" service:NCGlobal.shared.serviceShareKeyChain]; - if (key == nil) { - NSMutableData *key = [NSMutableData dataWithLength:64]; - (void)SecRandomCopyBytes(kSecRandomDefault, key.length, (uint8_t *)key.mutableBytes); - [UICKeyChainStore setData:key forKey:@"databaseEncryptionKey" service:NCGlobal.shared.serviceShareKeyChain]; - return key; - } else { - return key; - } -} - -+ (void)setDatabaseEncryptionKey:(NSData *)data -{ - [UICKeyChainStore setData:data forKey:@"databaseEncryptionKey" service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (BOOL)getLivePhoto -{ - NSString *valueString = [UICKeyChainStore stringForKey:@"livePhoto" service:NCGlobal.shared.serviceShareKeyChain]; - - // Default TRUE - if (valueString == nil) { - [self setLivePhoto:YES]; - return true; - } - - return [valueString boolValue]; -} - -+ (void)setLivePhoto:(BOOL)set -{ - NSString *sSet = (set) ? @"true" : @"false"; - [UICKeyChainStore setString:sSet forKey:@"livePhoto" service:NCGlobal.shared.serviceShareKeyChain]; -} - + (NSString *)getMediaSortDate { NSString *valueString = [UICKeyChainStore stringForKey:@"mediaSortDate" service:NCGlobal.shared.serviceShareKeyChain]; diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index 35eca29cb2..0f2890b4b0 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -162,6 +162,19 @@ import KeychainAccess } } + @objc var livePhoto: Bool { + get { + migrate(key: "livePhoto") + if let value = try? keychain.get("livePhoto"), let result = Bool(value) { + return result + } + return true + } + set { + keychain["livePhoto"] = String(newValue) + } + } + // MARK: - private func migrate(key: String) { From 63567d8e1be38b8c974ede3d3fa8962d89aae60d Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:14:25 +0200 Subject: [PATCH 45/90] disableCrashservice --- iOSClient/AppDelegate.swift | 2 +- iOSClient/Settings/CCAdvanced.m | 6 +++--- iOSClient/Utility/CCUtility.h | 3 --- iOSClient/Utility/CCUtility.m | 11 ----------- iOSClient/Utility/NCKeychain.swift | 13 +++++++++++++ 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index 789dd1b82c..e3e3b839ab 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -80,7 +80,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp()) UserDefaults.standard.register(defaults: ["UserAgent": userAgent]) - if !CCUtility.getDisableCrashservice() && !NCBrandOptions.shared.disable_crash_service { + if !NCKeychain().disableCrashservice, !NCBrandOptions.shared.disable_crash_service { FirebaseApp.configure() } diff --git a/iOSClient/Settings/CCAdvanced.m b/iOSClient/Settings/CCAdvanced.m index ff96aa2212..4c4f7558a4 100755 --- a/iOSClient/Settings/CCAdvanced.m +++ b/iOSClient/Settings/CCAdvanced.m @@ -115,7 +115,7 @@ - (void)initializeForm [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; [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"; [section addFormRow:row]; } @@ -338,8 +338,8 @@ - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor ol 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]; UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { exit(0); diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 13a76521a8..6c0e7efe96 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -58,9 +58,6 @@ + (NSInteger)getMediaWidthImage; + (void)setMediaWidthImage:(NSInteger)width; -+ (BOOL)getDisableCrashservice; -+ (void)setDisableCrashservice:(BOOL)disable; - + (NSString *)getMediaSortDate; + (void)setMediaSortDate:(NSString *)value; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index d765410006..c4763980df 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -149,17 +149,6 @@ + (void)setMediaWidthImage:(NSInteger)width [UICKeyChainStore setString:widthString forKey:@"mediaWidthImage" service:NCGlobal.shared.serviceShareKeyChain]; } -+ (BOOL)getDisableCrashservice -{ - return [[UICKeyChainStore stringForKey:@"crashservice" service:NCGlobal.shared.serviceShareKeyChain] boolValue]; -} - -+ (void)setDisableCrashservice:(BOOL)disable -{ - NSString *sDisable = (disable) ? @"true" : @"false"; - [UICKeyChainStore setString:sDisable forKey:@"crashservice" service:NCGlobal.shared.serviceShareKeyChain]; -} - + (NSString *)getMediaSortDate { NSString *valueString = [UICKeyChainStore stringForKey:@"mediaSortDate" service:NCGlobal.shared.serviceShareKeyChain]; diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index 0f2890b4b0..3499ac4e4d 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -175,6 +175,19 @@ import KeychainAccess } } + @objc var disableCrashservice: Bool { + get { + migrate(key: "crashservice") + if let value = try? keychain.get("crashservice"), let result = Bool(value) { + return result + } + return false + } + set { + keychain["crashservice"] = String(newValue) + } + } + // MARK: - private func migrate(key: String) { From 64842604a3532bae25af0dc26a30550c0e787d1c Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:21:10 +0200 Subject: [PATCH 46/90] loglevel --- File Provider Extension/FileProviderData.swift | 2 +- Share/NCShareExtension.swift | 2 +- Widget/Dashboard/DashboardData.swift | 2 +- Widget/Files/FilesData.swift | 2 +- iOSClient/AppDelegate.swift | 2 +- iOSClient/Settings/CCAdvanced.m | 6 +++--- iOSClient/Utility/CCUtility.h | 3 --- iOSClient/Utility/CCUtility.m | 17 ----------------- iOSClient/Utility/NCKeychain.swift | 13 +++++++++++++ 9 files changed, 21 insertions(+), 28 deletions(-) diff --git a/File Provider Extension/FileProviderData.swift b/File Provider Extension/FileProviderData.swift index b2a7a34d0d..7cf0d8da92 100644 --- a/File Provider Extension/FileProviderData.swift +++ b/File Provider Extension/FileProviderData.swift @@ -74,7 +74,7 @@ class fileProviderData: NSObject { // LOG if let pathDirectoryGroup = CCUtility.getDirectoryGroup()?.path { NextcloudKit.shared.nkCommonInstance.pathLog = pathDirectoryGroup - let levelLog = CCUtility.getLogLevel() + 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)") diff --git a/Share/NCShareExtension.swift b/Share/NCShareExtension.swift index 6405d46e8f..c12dee8bbd 100644 --- a/Share/NCShareExtension.swift +++ b/Share/NCShareExtension.swift @@ -111,7 +111,7 @@ class NCShareExtension: UIViewController { uploadView.addGestureRecognizer(uploadGesture) // LOG - let levelLog = CCUtility.getLogLevel() + let levelLog = NCKeychain().logLevel let isSimulatorOrTestFlight = NCUtility.shared.isSimulatorOrTestFlight() let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp()) diff --git a/Widget/Dashboard/DashboardData.swift b/Widget/Dashboard/DashboardData.swift index 74da6e57e3..555b2212c5 100644 --- a/Widget/Dashboard/DashboardData.swift +++ b/Widget/Dashboard/DashboardData.swift @@ -142,7 +142,7 @@ func getDashboardDataEntry(configuration: DashboardIntent?, isPreview: Bool, dis delegate: NCNetworking.shared) // LOG - let levelLog = CCUtility.getLogLevel() + let levelLog = NCKeychain().logLevel let isSimulatorOrTestFlight = NCUtility.shared.isSimulatorOrTestFlight() let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp()) diff --git a/Widget/Files/FilesData.swift b/Widget/Files/FilesData.swift index 089d896caf..f438c815db 100644 --- a/Widget/Files/FilesData.swift +++ b/Widget/Files/FilesData.swift @@ -192,7 +192,7 @@ func getFilesDataEntry(configuration: AccountIntent?, isPreview: Bool, displaySi let requestBody = String(format: requestBodyRecent, "/files/" + account.userId, lessDateString) // LOG - let levelLog = CCUtility.getLogLevel() + let levelLog = NCKeychain().logLevel let isSimulatorOrTestFlight = NCUtility.shared.isSimulatorOrTestFlight() let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp()) diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index e3e3b839ab..bcd577ca86 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -109,7 +109,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD } else { - levelLog = CCUtility.getLogLevel() + levelLog = NCKeychain().logLevel NextcloudKit.shared.nkCommonInstance.levelLog = levelLog NextcloudKit.shared.nkCommonInstance.copyLogToDocumentDirectory = true NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Start session with level \(levelLog) " + versionNextcloudiOS) diff --git a/iOSClient/Settings/CCAdvanced.m b/iOSClient/Settings/CCAdvanced.m index 4c4f7558a4..5838c85ea3 100755 --- a/iOSClient/Settings/CCAdvanced.m +++ b/iOSClient/Settings/CCAdvanced.m @@ -153,7 +153,7 @@ - (void)initializeForm [[[NextcloudKit shared] nkCommonInstance] clearFileLog]; - NSInteger logLevel = [CCUtility getLogLevel]; + NSInteger logLevel = [[NCKeychain alloc] init].logLevel; BOOL isSimulatorOrTestFlight = [[NCUtility shared] isSimulatorOrTestFlight]; NSString *versionNextcloudiOS = [NSString stringWithFormat:[NCBrandOptions shared].textCopyrightNextcloudiOS, [[NCUtility shared] getVersionAppWithBuild:true]]; if (isSimulatorOrTestFlight) { @@ -169,7 +169,7 @@ - (void)initializeForm [row.cellConfig setObject:@(NSTextAlignmentCenter) forKey:@"textLabel.textAlignment"]; [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; - NSInteger logLevel = [CCUtility getLogLevel]; + NSInteger logLevel = [[NCKeychain alloc] init].logLevel; row.value = @(logLevel); [row.cellConfigAtConfigure setObject:@(2) forKey:@"slider.maximumValue"]; [row.cellConfigAtConfigure setObject:@(0) forKey:@"slider.minimumValue"]; @@ -352,7 +352,7 @@ - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor ol if ([rowDescriptor.tag isEqualToString:@"logLevel"]) { NSInteger levelLog = [[rowDescriptor.value valueData] intValue]; - [CCUtility setLogLevel:levelLog]; + [[NCKeychain alloc] init].logLevel = levelLog; [[[NextcloudKit shared] nkCommonInstance] setLevelLog:levelLog]; } diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 6c0e7efe96..714bb30b1e 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -70,9 +70,6 @@ + (double)getQualityScanDocument; + (void)setQualityScanDocument:(double)value; -+ (NSInteger)getLogLevel; -+ (void)setLogLevel:(NSInteger)value; - + (BOOL)getAccountRequest; + (void)setAccountRequest:(BOOL)set; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index c4763980df..9bdd08d315 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -216,23 +216,6 @@ + (void)setQualityScanDocument:(double)value [UICKeyChainStore setString:valueString forKey:@"qualityScanDocument" service:NCGlobal.shared.serviceShareKeyChain]; } -+ (NSInteger)getLogLevel -{ - NSString *value = [UICKeyChainStore stringForKey:@"logLevel" service:NCGlobal.shared.serviceShareKeyChain]; - - if (value == nil) { - return 1; - } else { - return [value integerValue]; - } -} - -+ (void)setLogLevel:(NSInteger)value -{ - NSString *valueString = [@(value) stringValue]; - [UICKeyChainStore setString:valueString forKey:@"logLevel" service:NCGlobal.shared.serviceShareKeyChain]; -} - + (BOOL)getAccountRequest { return [[UICKeyChainStore stringForKey:@"accountRequest" service:NCGlobal.shared.serviceShareKeyChain] boolValue]; diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index 3499ac4e4d..ba0c6c0df7 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -188,6 +188,19 @@ import KeychainAccess } } + @objc var logLevel: Int { + get { + migrate(key: "logLevel") + if let value = try? keychain.get("logLevel"), let result = Int(value) { + return result + } + return 1 + } + set { + keychain["logLevel"] = String(newValue) + } + } + // MARK: - private func migrate(key: String) { From f700c1a4ec13b11ef39666f271ed934ed84a37bb Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:28:28 +0200 Subject: [PATCH 47/90] accountRequest --- iOSClient/AppDelegate.swift | 2 +- iOSClient/Settings/CCManageAccount.m | 7 +++---- iOSClient/Utility/CCUtility.h | 3 --- iOSClient/Utility/CCUtility.m | 11 ----------- iOSClient/Utility/NCKeychain.swift | 13 +++++++++++++ 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index bcd577ca86..3081df842f 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -676,7 +676,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD func requestAccount() { if isPasscodePresented() { return } - if !CCUtility.getAccountRequest() { return } + if !NCKeychain().accountRequest { return } let accounts = NCManageDatabase.shared.getAllAccount() diff --git a/iOSClient/Settings/CCManageAccount.m b/iOSClient/Settings/CCManageAccount.m index f2fc78d47c..425d42758f 100644 --- a/iOSClient/Settings/CCManageAccount.m +++ b/iOSClient/Settings/CCManageAccount.m @@ -123,7 +123,7 @@ - (void)initializeForm [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:UIColor.labelColor forKey:@"textLabel.textColor"]; - if ([CCUtility getAccountRequest]) row.value = @1; + if ([[NCKeychain alloc] init].accountRequest) row.value = @1; else row.value = @0; [section addFormRow:row]; } @@ -205,7 +205,6 @@ - (void)initializeForm [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; [row.cellConfig setObject:[[UIImage imageNamed:@"country"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"]; row.value = [[NSLocale systemLocale] displayNameForKey:NSLocaleCountryCode value:activeAccount.country]; - //NSArray *countryCodes = [NSLocale ISOCountryCodes]; [section addFormRow:row]; } @@ -306,9 +305,9 @@ -(void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor old if ([rowDescriptor.tag isEqualToString:@"accountRequest"]) { if ([[rowDescriptor.value valueData] boolValue] == YES) { - [CCUtility setAccountRequest:true]; + [[NCKeychain alloc] init].accountRequest = true; } else { - [CCUtility setAccountRequest:false]; + [[NCKeychain alloc] init].accountRequest = false; } } diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 714bb30b1e..bfcf0921a8 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -70,9 +70,6 @@ + (double)getQualityScanDocument; + (void)setQualityScanDocument:(double)value; -+ (BOOL)getAccountRequest; -+ (void)setAccountRequest:(BOOL)set; - + (NSInteger)getCleanUpDay; + (void)setCleanUpDay:(NSInteger)days; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 9bdd08d315..7df1e8d5e4 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -216,17 +216,6 @@ + (void)setQualityScanDocument:(double)value [UICKeyChainStore setString:valueString forKey:@"qualityScanDocument" service:NCGlobal.shared.serviceShareKeyChain]; } -+ (BOOL)getAccountRequest -{ - return [[UICKeyChainStore stringForKey:@"accountRequest" service:NCGlobal.shared.serviceShareKeyChain] boolValue]; -} - -+ (void)setAccountRequest:(BOOL)set -{ - NSString *sSet = (set) ? @"true" : @"false"; - [UICKeyChainStore setString:sSet forKey:@"accountRequest" service:NCGlobal.shared.serviceShareKeyChain]; -} - + (NSInteger)getCleanUpDay { NSString *size = [UICKeyChainStore stringForKey:@"cleanUpDay" service:NCGlobal.shared.serviceShareKeyChain]; diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index ba0c6c0df7..c2a254bf90 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -201,6 +201,19 @@ import KeychainAccess } } + @objc var accountRequest: Bool { + get { + migrate(key: "accountRequest") + if let value = try? keychain.get("accountRequest"), let result = Bool(value) { + return result + } + return false + } + set { + keychain["accountRequest"] = String(newValue) + } + } + // MARK: - private func migrate(key: String) { From c28729807fa37dabb89dbfe39b5b934fde45ef65 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:31:31 +0200 Subject: [PATCH 48/90] removePhotoCameraRoll --- iOSClient/Networking/NCNetworking.swift | 2 +- iOSClient/Settings/CCAdvanced.m | 4 ++-- iOSClient/Utility/CCUtility.h | 3 --- iOSClient/Utility/CCUtility.m | 11 ----------- iOSClient/Utility/NCKeychain.swift | 13 +++++++++++++ 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/iOSClient/Networking/NCNetworking.swift b/iOSClient/Networking/NCNetworking.swift index 8ddc0c919a..4764953e5b 100644 --- a/iOSClient/Networking/NCNetworking.swift +++ b/iOSClient/Networking/NCNetworking.swift @@ -648,7 +648,7 @@ class NCNetworking: NSObject, NKCommonDelegate { metadata.status = NCGlobal.shared.metadataStatusNormal // Delete Asset on Photos album - if CCUtility.getRemovePhotoCameraRoll() && !metadata.assetLocalIdentifier.isEmpty { + if NCKeychain().removePhotoCameraRoll, !metadata.assetLocalIdentifier.isEmpty { metadata.deleteAssetLocalIdentifier = true } diff --git a/iOSClient/Settings/CCAdvanced.m b/iOSClient/Settings/CCAdvanced.m index 5838c85ea3..8d3d663b28 100755 --- a/iOSClient/Settings/CCAdvanced.m +++ b/iOSClient/Settings/CCAdvanced.m @@ -78,7 +78,7 @@ - (void)initializeForm row = [XLFormRowDescriptor formRowDescriptorWithTag:@"removePhotoCameraRoll" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_remove_photo_CameraRoll_", nil)]; row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor; - if ([CCUtility getRemovePhotoCameraRoll]) row.value = @"1"; + if ([[[NCKeychain alloc] init] removePhotoCameraRoll]) row.value = @"1"; else row.value = @0; [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"]; [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"]; @@ -328,7 +328,7 @@ - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor ol if ([rowDescriptor.tag isEqualToString:@"removePhotoCameraRoll"]) { - [CCUtility setRemovePhotoCameraRoll:[[rowDescriptor.value valueData] boolValue]]; + [[NCKeychain alloc] init].removePhotoCameraRoll = [[rowDescriptor.value valueData] boolValue]; } if ([rowDescriptor.tag isEqualToString:@"disablefilesapp"]) { diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index bfcf0921a8..f413945ba8 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -76,9 +76,6 @@ + (BOOL)getPrivacyScreenEnabled; + (void)setPrivacyScreenEnabled:(BOOL)set; -+ (BOOL)getRemovePhotoCameraRoll; -+ (void)setRemovePhotoCameraRoll:(BOOL)set; - // ===== Varius ===== + (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 7df1e8d5e4..ed604aa711 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -245,17 +245,6 @@ + (void)setPrivacyScreenEnabled:(BOOL)set [UICKeyChainStore setString:sSet forKey:@"privacyScreen" service:NCGlobal.shared.serviceShareKeyChain]; } -+ (BOOL)getRemovePhotoCameraRoll -{ - return [[UICKeyChainStore stringForKey:@"removePhotoCameraRoll" service:NCGlobal.shared.serviceShareKeyChain] boolValue]; -} - -+ (void)setRemovePhotoCameraRoll:(BOOL)set -{ - NSString *sSet = (set) ? @"true" : @"false"; - [UICKeyChainStore setString:sSet forKey:@"removePhotoCameraRoll" service:NCGlobal.shared.serviceShareKeyChain]; -} - #pragma -------------------------------------------------------------------------------------------- #pragma mark ===== Various ===== #pragma -------------------------------------------------------------------------------------------- diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index c2a254bf90..1ac8eceff5 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -214,6 +214,19 @@ import KeychainAccess } } + @objc var removePhotoCameraRoll: Bool { + get { + migrate(key: "removePhotoCameraRoll") + if let value = try? keychain.get("removePhotoCameraRoll"), let result = Bool(value) { + return result + } + return false + } + set { + keychain["removePhotoCameraRoll"] = String(newValue) + } + } + // MARK: - private func migrate(key: String) { From 57c13958800522f9138e4bb98e2421bb6770e789 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:34:33 +0200 Subject: [PATCH 49/90] privacyScreen --- iOSClient/AppDelegate.swift | 2 +- iOSClient/Settings/NCSettings.m | 6 +++--- iOSClient/Utility/CCUtility.h | 3 --- iOSClient/Utility/CCUtility.m | 11 ----------- iOSClient/Utility/NCKeychain.swift | 13 +++++++++++++ 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index 3081df842f..bc7c91dccc 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -230,7 +230,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD NCNetworkingProcessUpload.shared.invalidateObserveTableMetadata() NCNetworkingProcessUpload.shared.stopTimer() - if CCUtility.getPrivacyScreenEnabled() { + if NCKeychain().privacyScreenEnabled { showPrivacyProtectionWindow() } diff --git a/iOSClient/Settings/NCSettings.m b/iOSClient/Settings/NCSettings.m index f663edb555..e3e0c0804e 100644 --- a/iOSClient/Settings/NCSettings.m +++ b/iOSClient/Settings/NCSettings.m @@ -275,7 +275,7 @@ - (void)reloadForm 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 ([CCUtility getPrivacyScreenEnabled]) [rowPrivacyScreen setValue:@1]; else [rowPrivacyScreen setValue:@0]; + if ([[NCKeychain alloc] init].privacyScreenEnabled) [rowPrivacyScreen setValue:@1]; else [rowPrivacyScreen setValue:@0]; // ----------------------------------------------------------------- @@ -310,9 +310,9 @@ - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor ol if ([rowDescriptor.tag isEqualToString:@"privacyScreen"]) { if ([[rowDescriptor.value valueData] boolValue] == YES) { - [CCUtility setPrivacyScreenEnabled:true]; + [[NCKeychain alloc] init].privacyScreenEnabled = true; } else { - [CCUtility setPrivacyScreenEnabled:false]; + [[NCKeychain alloc] init].privacyScreenEnabled = false; } } } diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index f413945ba8..a616dca7bc 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -73,9 +73,6 @@ + (NSInteger)getCleanUpDay; + (void)setCleanUpDay:(NSInteger)days; -+ (BOOL)getPrivacyScreenEnabled; -+ (void)setPrivacyScreenEnabled:(BOOL)set; - // ===== Varius ===== + (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index ed604aa711..92d098a019 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -234,17 +234,6 @@ + (void)setCleanUpDay:(NSInteger)days [UICKeyChainStore setString:daysString forKey:@"cleanUpDay" service:NCGlobal.shared.serviceShareKeyChain]; } -+ (BOOL)getPrivacyScreenEnabled -{ - return [[UICKeyChainStore stringForKey:@"privacyScreen" service:NCGlobal.shared.serviceShareKeyChain] boolValue]; -} - -+ (void)setPrivacyScreenEnabled:(BOOL)set -{ - NSString *sSet = (set) ? @"true" : @"false"; - [UICKeyChainStore setString:sSet forKey:@"privacyScreen" service:NCGlobal.shared.serviceShareKeyChain]; -} - #pragma -------------------------------------------------------------------------------------------- #pragma mark ===== Various ===== #pragma -------------------------------------------------------------------------------------------- diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index 1ac8eceff5..c3745ae45e 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -227,6 +227,19 @@ import KeychainAccess } } + @objc var privacyScreenEnabled: Bool { + get { + migrate(key: "privacyScreen") + if let value = try? keychain.get("privacyScreen"), let result = Bool(value) { + return result + } + return false + } + set { + keychain["privacyScreen"] = String(newValue) + } + } + // MARK: - private func migrate(key: String) { From 686237d6c9ac8e5b26a0f503f3d741256209b267 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:40:03 +0200 Subject: [PATCH 50/90] cleanUpDay --- iOSClient/AppDelegate.swift | 2 +- iOSClient/Settings/CCAdvanced.m | 4 ++-- iOSClient/Utility/CCUtility.h | 3 --- iOSClient/Utility/CCUtility.m | 18 ------------------ iOSClient/Utility/NCKeychain.swift | 13 +++++++++++++ 5 files changed, 16 insertions(+), 24 deletions(-) diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index bc7c91dccc..4bb0ff8866 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -238,7 +238,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD WidgetCenter.shared.reloadAllTimelines() // Clear older files - let days = CCUtility.getCleanUpDay() + let days = NCKeychain().cleanUpDay if let directory = CCUtility.getDirectoryProviderStorage() { NCUtilityFileSystem.shared.cleanUp(directory: directory, days: TimeInterval(days)) } diff --git a/iOSClient/Settings/CCAdvanced.m b/iOSClient/Settings/CCAdvanced.m index 8d3d663b28..5f6a538e9c 100755 --- a/iOSClient/Settings/CCAdvanced.m +++ b/iOSClient/Settings/CCAdvanced.m @@ -200,7 +200,7 @@ - (void)initializeForm row = [XLFormRowDescriptor formRowDescriptorWithTag:@"deleteoldfiles" rowType:XLFormRowDescriptorTypeSelectorPush title:NSLocalizedString(@"_delete_old_files_", nil)]; - switch (CCUtility.getCleanUpDay) { + switch ([[NCKeychain alloc] init].cleanUpDay) { case 0: row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(0) displayText:NSLocalizedString(@"_never_", nil)]; break; @@ -359,7 +359,7 @@ - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor ol if ([rowDescriptor.tag isEqualToString:@"deleteoldfiles"]) { NSInteger days = [[rowDescriptor.value valueData] intValue]; - [CCUtility setCleanUpDay:days]; + [[NCKeychain alloc] init].cleanUpDay = days; } } diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index a616dca7bc..0a45ec0389 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -70,9 +70,6 @@ + (double)getQualityScanDocument; + (void)setQualityScanDocument:(double)value; -+ (NSInteger)getCleanUpDay; -+ (void)setCleanUpDay:(NSInteger)days; - // ===== Varius ===== + (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 92d098a019..6593855390 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -216,24 +216,6 @@ + (void)setQualityScanDocument:(double)value [UICKeyChainStore setString:valueString forKey:@"qualityScanDocument" service:NCGlobal.shared.serviceShareKeyChain]; } -+ (NSInteger)getCleanUpDay -{ - NSString *size = [UICKeyChainStore stringForKey:@"cleanUpDay" service:NCGlobal.shared.serviceShareKeyChain]; - - if (size == nil) { - NSInteger days = [[NCBrandOptions shared] cleanUpDay]; - return days; - } else { - return [size integerValue]; - } -} - -+ (void)setCleanUpDay:(NSInteger)days -{ - NSString *daysString = [@(days) stringValue]; - [UICKeyChainStore setString:daysString forKey:@"cleanUpDay" service:NCGlobal.shared.serviceShareKeyChain]; -} - #pragma -------------------------------------------------------------------------------------------- #pragma mark ===== Various ===== #pragma -------------------------------------------------------------------------------------------- diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index c3745ae45e..86a4ea5464 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -240,6 +240,19 @@ import KeychainAccess } } + @objc var cleanUpDay: Int { + get { + migrate(key: "cleanUpDay") + if let value = try? keychain.get("cleanUpDay"), let result = Int(value) { + return result + } + return NCBrandOptions.shared.cleanUpDay + } + set { + keychain["cleanUpDay"] = String(newValue) + } + } + // MARK: - private func migrate(key: String) { From 2439ceabb0e4c9cefef90ece942901a8d795e7f3 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:44:43 +0200 Subject: [PATCH 51/90] mediaWidthImage --- iOSClient/Media/NCMedia.swift | 6 +++--- iOSClient/Utility/CCUtility.h | 3 --- iOSClient/Utility/CCUtility.m | 17 ----------------- iOSClient/Utility/NCKeychain.swift | 13 +++++++++++++ 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/iOSClient/Media/NCMedia.swift b/iOSClient/Media/NCMedia.swift index 6bfdfa1ab2..ecfe0764ae 100644 --- a/iOSClient/Media/NCMedia.swift +++ b/iOSClient/Media/NCMedia.swift @@ -79,7 +79,7 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate { collectionView.backgroundColor = .systemBackground gridLayout = NCGridMediaLayout() - gridLayout.itemForLine = CGFloat(min(CCUtility.getMediaWidthImage(), 5)) + gridLayout.itemForLine = CGFloat(min(NCKeychain().mediaWidthImage, 5)) gridLayout.sectionHeadersPinToVisibleBounds = true collectionView.collectionViewLayout = gridLayout @@ -241,7 +241,7 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate { } self.collectionView.collectionViewLayout.invalidateLayout() - CCUtility.setMediaWidthImage(Int(self.gridLayout.itemForLine)) + NCKeychain().mediaWidthImage = Int(self.gridLayout.itemForLine) }) } @@ -257,7 +257,7 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate { } self.collectionView.collectionViewLayout.invalidateLayout() - CCUtility.setMediaWidthImage(Int(self.gridLayout.itemForLine)) + NCKeychain().mediaWidthImage = Int(self.gridLayout.itemForLine) }) } diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 0a45ec0389..bca4cbec9f 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -55,9 +55,6 @@ + (NSString *)getPushNotificationDeviceIdentifierSignature:(NSString *)account; + (void)clearAllKeysPushNotification:(NSString *)account; -+ (NSInteger)getMediaWidthImage; -+ (void)setMediaWidthImage:(NSInteger)width; - + (NSString *)getMediaSortDate; + (void)setMediaSortDate:(NSString *)value; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 6593855390..6e45032b56 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -132,23 +132,6 @@ + (void)clearAllKeysPushNotification:(NSString *)account [self setPushNotificationDeviceIdentifierSignature:account deviceIdentifierSignature:nil]; } -+ (NSInteger)getMediaWidthImage -{ - NSString *width = [UICKeyChainStore stringForKey:@"mediaWidthImage" service:NCGlobal.shared.serviceShareKeyChain]; - - if (width == nil) { - return 80; - } else { - return [width integerValue]; - } -} - -+ (void)setMediaWidthImage:(NSInteger)width -{ - NSString *widthString = [@(width) stringValue]; - [UICKeyChainStore setString:widthString forKey:@"mediaWidthImage" service:NCGlobal.shared.serviceShareKeyChain]; -} - + (NSString *)getMediaSortDate { NSString *valueString = [UICKeyChainStore stringForKey:@"mediaSortDate" service:NCGlobal.shared.serviceShareKeyChain]; diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index 86a4ea5464..c118105404 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -253,6 +253,19 @@ import KeychainAccess } } + var mediaWidthImage: Int { + get { + migrate(key: "mediaWidthImage") + if let value = try? keychain.get("mediaWidthImage"), let result = Int(value) { + return result + } + return 80 + } + set { + keychain["mediaWidthImage"] = String(newValue) + } + } + // MARK: - private func migrate(key: String) { From d42f8f674734f5093719ef042920ee8fe8669972 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:49:35 +0200 Subject: [PATCH 52/90] mediaSortDate --- iOSClient/Media/NCMediaCache.swift | 2 +- iOSClient/Menu/NCMedia+Menu.swift | 12 ++++++------ iOSClient/Utility/CCUtility.h | 3 --- iOSClient/Utility/CCUtility.m | 18 ------------------ iOSClient/Utility/NCKeychain.swift | 13 +++++++++++++ 5 files changed, 20 insertions(+), 28 deletions(-) diff --git a/iOSClient/Media/NCMediaCache.swift b/iOSClient/Media/NCMediaCache.swift index d3911013a2..8996fa7205 100644 --- a/iOSClient/Media/NCMediaCache.swift +++ b/iOSClient/Media/NCMediaCache.swift @@ -139,7 +139,7 @@ import NextcloudKit livePhoto = NCKeychain().livePhoto metadatas = NCManageDatabase.shared.getMetadatasMedia(predicate: predicate, livePhoto: livePhoto) - switch CCUtility.getMediaSortDate() { + switch NCKeychain().mediaSortDate { case "date": metadatas = self.metadatas.sorted(by: {($0.date as Date) > ($1.date as Date)}) case "creationDate": diff --git a/iOSClient/Menu/NCMedia+Menu.swift b/iOSClient/Menu/NCMedia+Menu.swift index 1d8bc032c0..2214cc2f9f 100644 --- a/iOSClient/Menu/NCMedia+Menu.swift +++ b/iOSClient/Menu/NCMedia+Menu.swift @@ -146,10 +146,10 @@ extension NCMedia { NCMenuAction( title: NSLocalizedString("_media_by_modified_date_", comment: ""), icon: NCUtility.shared.loadImage(named: "circle.grid.cross.up.fill"), - selected: CCUtility.getMediaSortDate() == "date", + selected: NCKeychain().mediaSortDate == "date", on: true, action: { _ in - CCUtility.setMediaSortDate("date") + NCKeychain().mediaSortDate = "date" self.reloadDataSourceWithCompletion { _ in } } ) @@ -159,10 +159,10 @@ extension NCMedia { NCMenuAction( title: NSLocalizedString("_media_by_created_date_", comment: ""), icon: NCUtility.shared.loadImage(named: "circle.grid.cross.down.fill"), - selected: CCUtility.getMediaSortDate() == "creationDate", + selected:NCKeychain().mediaSortDate == "creationDate", on: true, action: { _ in - CCUtility.setMediaSortDate("creationDate") + NCKeychain().mediaSortDate = "creationDate" self.reloadDataSourceWithCompletion { _ in } } ) @@ -172,10 +172,10 @@ extension NCMedia { NCMenuAction( title: NSLocalizedString("_media_by_upload_date_", comment: ""), icon: NCUtility.shared.loadImage(named: "circle.grid.cross.right.fill"), - selected: CCUtility.getMediaSortDate() == "uploadDate", + selected: NCKeychain().mediaSortDate == "uploadDate", on: true, action: { _ in - CCUtility.setMediaSortDate("uploadDate") + NCKeychain().mediaSortDate = "uploadDate" self.reloadDataSourceWithCompletion { _ in } } ) diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index bca4cbec9f..a02d985288 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -55,9 +55,6 @@ + (NSString *)getPushNotificationDeviceIdentifierSignature:(NSString *)account; + (void)clearAllKeysPushNotification:(NSString *)account; -+ (NSString *)getMediaSortDate; -+ (void)setMediaSortDate:(NSString *)value; - + (BOOL)getTextRecognitionStatus; + (void)setTextRecognitionStatus:(BOOL)value; + (BOOL)getDeleteAllScanImages; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 6e45032b56..5f555c28d4 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -132,24 +132,6 @@ + (void)clearAllKeysPushNotification:(NSString *)account [self setPushNotificationDeviceIdentifierSignature:account deviceIdentifierSignature:nil]; } -+ (NSString *)getMediaSortDate -{ - NSString *valueString = [UICKeyChainStore stringForKey:@"mediaSortDate" service:NCGlobal.shared.serviceShareKeyChain]; - - // Default TRUE - if (valueString == nil) { - [self setMediaSortDate:@"date"]; - return @"date"; - } - - return valueString; -} - -+ (void)setMediaSortDate:(NSString *)value -{ - [UICKeyChainStore setString:value forKey:@"mediaSortDate" service:NCGlobal.shared.serviceShareKeyChain]; -} - + (BOOL)getTextRecognitionStatus { return [[UICKeyChainStore stringForKey:@"textRecognitionStatus" service:NCGlobal.shared.serviceShareKeyChain] boolValue]; diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index c118105404..babe63e3c3 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -266,6 +266,19 @@ import KeychainAccess } } + var mediaSortDate: String { + get { + migrate(key: "mediaSortDate") + if let value = try? keychain.get("mediaSortDate") { + return value + } + return "date" + } + set { + keychain["mediaSortDate"] = newValue + } + } + // MARK: - private func migrate(key: String) { From 23b045ac4ce2f8802a9aeffb531ce46f61a9e2e4 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 17:04:37 +0200 Subject: [PATCH 53/90] scanDocument --- iOSClient/Menu/NCMedia+Menu.swift | 2 +- .../Scan document/NCUploadScanDocument.swift | 14 +++--- iOSClient/Utility/CCUtility.h | 9 ---- iOSClient/Utility/CCUtility.m | 49 ------------------- iOSClient/Utility/NCKeychain.swift | 39 +++++++++++++++ 5 files changed, 46 insertions(+), 67 deletions(-) diff --git a/iOSClient/Menu/NCMedia+Menu.swift b/iOSClient/Menu/NCMedia+Menu.swift index 2214cc2f9f..a93e25cc14 100644 --- a/iOSClient/Menu/NCMedia+Menu.swift +++ b/iOSClient/Menu/NCMedia+Menu.swift @@ -159,7 +159,7 @@ extension NCMedia { NCMenuAction( title: NSLocalizedString("_media_by_created_date_", comment: ""), icon: NCUtility.shared.loadImage(named: "circle.grid.cross.down.fill"), - selected:NCKeychain().mediaSortDate == "creationDate", + selected: NCKeychain().mediaSortDate == "creationDate", on: true, action: { _ in NCKeychain().mediaSortDate = "creationDate" diff --git a/iOSClient/Scan document/NCUploadScanDocument.swift b/iOSClient/Scan document/NCUploadScanDocument.swift index bb0116186c..9493d10046 100644 --- a/iOSClient/Scan document/NCUploadScanDocument.swift +++ b/iOSClient/Scan document/NCUploadScanDocument.swift @@ -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) { if let serverUrl = serverUrl { - CCUtility.setDirectoryScanDocument(serverUrl) self.serverUrl = serverUrl } } @@ -348,9 +347,9 @@ struct UploadScanDocumentView: View { @State var fileName = CCUtility.createFileNameDate("scan", extension: "") ?? "scan" @State var password: String = "" @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 isPresentedUploadConflict = false @@ -437,7 +436,7 @@ struct UploadScanDocumentView: View { Toggle(NSLocalizedString("_text_recognition_", comment: ""), isOn: $isTextRecognition) .toggleStyle(SwitchToggleStyle(tint: Color(NCBrandColor.shared.brand))) .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) .toggleStyle(SwitchToggleStyle(tint: Color(NCBrandColor.shared.brand))) .onChange(of: removeAllFiles) { newValue in - CCUtility.setDeleteAllScanImages(newValue) - + NCKeychain().deleteAllScanImages = newValue } Button(NSLocalizedString("_save_", comment: "")) { @@ -478,7 +476,7 @@ struct UploadScanDocumentView: View { VStack { Slider(value: $quality, in: 0...4, step: 1, onEditingChanged: { touch in if !touch { - CCUtility.setQualityScanDocument(quality) + NCKeychain().qualityScanDocument = quality } }) .accentColor(Color(NCBrandColor.shared.brand)) diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index a02d985288..8dd789ede5 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -55,15 +55,6 @@ + (NSString *)getPushNotificationDeviceIdentifierSignature:(NSString *)account; + (void)clearAllKeysPushNotification:(NSString *)account; -+ (BOOL)getTextRecognitionStatus; -+ (void)setTextRecognitionStatus:(BOOL)value; -+ (BOOL)getDeleteAllScanImages; -+ (void)setDeleteAllScanImages:(BOOL)value; -+ (NSString *)getDirectoryScanDocument; -+ (void)setDirectoryScanDocument:(NSString *)value; -+ (double)getQualityScanDocument; -+ (void)setQualityScanDocument:(double)value; - // ===== Varius ===== + (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 5f555c28d4..5b835dceda 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -132,55 +132,6 @@ + (void)clearAllKeysPushNotification:(NSString *)account [self setPushNotificationDeviceIdentifierSignature:account deviceIdentifierSignature:nil]; } -+ (BOOL)getTextRecognitionStatus -{ - return [[UICKeyChainStore stringForKey:@"textRecognitionStatus" service:NCGlobal.shared.serviceShareKeyChain] boolValue]; -} - -+ (void)setTextRecognitionStatus:(BOOL)value -{ - NSString *valueString = (value) ? @"true" : @"false"; - [UICKeyChainStore setString:valueString forKey:@"textRecognitionStatus" service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (BOOL)getDeleteAllScanImages -{ - return [[UICKeyChainStore stringForKey:@"deleteAllScanImages" service:NCGlobal.shared.serviceShareKeyChain] boolValue]; -} - -+ (void)setDeleteAllScanImages:(BOOL)value -{ - NSString *valueString = (value) ? @"true" : @"false"; - [UICKeyChainStore setString:valueString forKey:@"deleteAllScanImages" service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (NSString *)getDirectoryScanDocument -{ - return [UICKeyChainStore stringForKey:@"directoryScanDocuments" service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (void)setDirectoryScanDocument:(NSString *)value -{ - [UICKeyChainStore setString:value forKey:@"directoryScanDocuments" service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (double)getQualityScanDocument -{ - NSString *value = [UICKeyChainStore stringForKey:@"qualityScanDocument" service:NCGlobal.shared.serviceShareKeyChain]; - - if (value == nil) { - return 2; - } else { - return [value doubleValue]; - } -} - -+ (void)setQualityScanDocument:(double)value -{ - NSString *valueString = [@(value) stringValue]; - [UICKeyChainStore setString:valueString forKey:@"qualityScanDocument" service:NCGlobal.shared.serviceShareKeyChain]; -} - #pragma -------------------------------------------------------------------------------------------- #pragma mark ===== Various ===== #pragma -------------------------------------------------------------------------------------------- diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index babe63e3c3..28ef68d7df 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -279,6 +279,45 @@ import KeychainAccess } } + var textRecognitionStatus: Bool { + get { + migrate(key: "textRecognitionStatus") + if let value = try? keychain.get("textRecognitionStatus"), let result = Bool(value) { + return result + } + return false + } + set { + keychain["textRecognitionStatus"] = String(newValue) + } + } + + var deleteAllScanImages: Bool { + get { + migrate(key: "deleteAllScanImages") + if let value = try? keychain.get("deleteAllScanImages"), let result = Bool(value) { + return result + } + return false + } + set { + keychain["deleteAllScanImages"] = String(newValue) + } + } + + var qualityScanDocument: Double { + get { + migrate(key: "qualityScanDocument") + if let value = try? keychain.get("qualityScanDocument"), let result = Double(value) { + return result + } + return 2 + } + set { + keychain["qualityScanDocument"] = String(newValue) + } + } + // MARK: - private func migrate(key: String) { From d5df5872d9a1e32db1910536053201508e2e8f60 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 17:39:07 +0200 Subject: [PATCH 54/90] PushNotification --- .../NotificationService.swift | 2 +- iOSClient/AppDelegate.swift | 3 +- .../PushNotification/NCPushNotification.m | 38 ++++---- .../NCPushNotificationEncryption.h | 2 +- .../NCPushNotificationEncryption.m | 8 +- iOSClient/Settings/CCAdvanced.m | 1 - .../Settings/NCSettingsBundleHelper.swift | 1 - iOSClient/Utility/CCUtility.h | 22 ----- iOSClient/Utility/CCUtility.m | 94 ------------------- iOSClient/Utility/NCKeychain.swift | 72 +++++++++++++- iOSClient/Utility/NCUtility.swift | 1 - 11 files changed, 97 insertions(+), 147 deletions(-) diff --git a/Notification Service Extension/NotificationService.swift b/Notification Service Extension/NotificationService.swift index 55e927aca9..24efbc8e92 100644 --- a/Notification Service Extension/NotificationService.swift +++ b/Notification Service Extension/NotificationService.swift @@ -38,7 +38,7 @@ class NotificationService: UNNotificationServiceExtension { if let message = bestAttemptContent.userInfo["subject"] as? String { let tableAccounts = NCManageDatabase.shared.getAllAccount() 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 data = decryptedMessage.data(using: .utf8) else { continue diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index 4bb0ff8866..eb8ca33e6e 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -139,7 +139,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD } else { - CCUtility.deleteAllChainStore() NCKeychain().removeAll() if let bundleID = Bundle.main.bundleIdentifier { UserDefaults.standard.removePersistentDomain(forName: bundleID) @@ -623,7 +622,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD NCManageDatabase.shared.clearDatabase(account: account, removeAccount: true) NCKeychain().clearAllKeysEndToEnd(account: account) - CCUtility.clearAllKeysPushNotification(account) + NCKeychain().clearAllKeysPushNotification(account: account) NCKeychain().setPassword(account: account, password: nil) self.account = "" diff --git a/iOSClient/PushNotification/NCPushNotification.m b/iOSClient/PushNotification/NCPushNotification.m index 00c91c6fc6..9b9b44a15e 100644 --- a/iOSClient/PushNotification/NCPushNotification.m +++ b/iOSClient/PushNotification/NCPushNotification.m @@ -54,8 +54,8 @@ - (void)pushNotification 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 != nil) { // unsubscribing + subscribing @@ -73,8 +73,8 @@ - (void)applicationdidReceiveRemoteNotification:(NSDictionary *)userInfo fetchCo if (message) { NSArray *results = [[NCManageDatabase shared] getAllAccount]; 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]; if (decryptedMessage) { NSData *data = [decryptedMessage dataUsingEncoding:NSUTF8StringEncoding]; @@ -102,7 +102,7 @@ - (void)subscribingNextcloudServerPushNotification:(NSString *)account urlBase:( [[NCPushNotificationEncryption shared] generatePushNotificationsKeyPair:account]; 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 *proxyServerPath = [NCBrandOptions shared].pushNotificationServerProxy; @@ -114,10 +114,10 @@ - (void)subscribingNextcloudServerPushNotification:(NSString *)account urlBase:( [[[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,9 +128,9 @@ - (void)unsubscribingNextcloudServerPushNotification:(NSString *)account urlBase { 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:[[[NCKeychain alloc] init] getPasswordWithAccount:account] customUserAgent:nil addCustomHeaders:nil queue:dispatch_get_main_queue() completion:^(NSString *account, NKError *error) { if (error == NKError.success) { @@ -141,13 +141,13 @@ - (void)unsubscribingNextcloudServerPushNotification:(NSString *)account urlBase [[[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) { [self subscribingNextcloudServerPushNotification:account urlBase:urlBase user:user]; } diff --git a/iOSClient/PushNotification/NCPushNotificationEncryption.h b/iOSClient/PushNotification/NCPushNotificationEncryption.h index 6c476d0f7a..6d20a79a12 100644 --- a/iOSClient/PushNotification/NCPushNotificationEncryption.h +++ b/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. // -#import +#import @interface NCPushNotificationEncryption : NSObject diff --git a/iOSClient/PushNotification/NCPushNotificationEncryption.m b/iOSClient/PushNotification/NCPushNotificationEncryption.m index 119c3962bf..91d96fe3a5 100644 --- a/iOSClient/PushNotification/NCPushNotificationEncryption.m +++ b/iOSClient/PushNotification/NCPushNotificationEncryption.m @@ -24,10 +24,9 @@ // #import "NCPushNotificationEncryption.h" - +#import "NCBridgeSwift.h" #import #import - #import "NCEndToEndEncryption.h" #import "CCUtility.h" @@ -75,7 +74,8 @@ - (BOOL)generatePushNotificationsKeyPair:(NSString *)account BIO_read(publicKeyBIO, keyBytes, 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]); // PrivateKey @@ -87,7 +87,7 @@ - (BOOL)generatePushNotificationsKeyPair:(NSString *)account BIO_read(privateKeyBIO, keyBytes, len); NSData *ncPNPrivateKey = [NSData dataWithBytes:keyBytes length:len]; - [CCUtility setPushNotificationPrivateKey:account data:ncPNPrivateKey]; + [[[NCKeychain alloc] init] setPushNotificationPrivateKeyWithAccount:account data:ncPNPrivateKey]; RSA_free(rsa); BN_free(bigNumber); diff --git a/iOSClient/Settings/CCAdvanced.m b/iOSClient/Settings/CCAdvanced.m index 5f6a538e9c..a63268e19a 100755 --- a/iOSClient/Settings/CCAdvanced.m +++ b/iOSClient/Settings/CCAdvanced.m @@ -465,7 +465,6 @@ - (void)exitNextcloud:(XLFormRowDescriptor *)sender [CCUtility removeDocumentsDirectory]; [CCUtility removeTemporaryDirectory]; - [CCUtility deleteAllChainStore]; [[[NCKeychain alloc] init] removeAll]; exit(0); diff --git a/iOSClient/Settings/NCSettingsBundleHelper.swift b/iOSClient/Settings/NCSettingsBundleHelper.swift index 262a4d747c..65aa11a3d9 100644 --- a/iOSClient/Settings/NCSettingsBundleHelper.swift +++ b/iOSClient/Settings/NCSettingsBundleHelper.swift @@ -47,7 +47,6 @@ class NCSettingsBundleHelper: NSObject { CCUtility.removeDocumentsDirectory() CCUtility.removeTemporaryDirectory() - CCUtility.deleteAllChainStore() NCKeychain().removeAll() NCManageDatabase.shared.removeDB() diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 8dd789ede5..afd6d1aa43 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -35,28 +35,6 @@ @interface CCUtility : NSObject -// ===== KeyChainStore ===== - -// GET/SET - -+ (void)deleteAllChainStore; - -+ (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; - -// ===== Varius ===== - + (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL; + (NSString *)dateDiff:(NSDate *)convertedDate; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 5b835dceda..3d86dbcb83 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -38,100 +38,6 @@ @implementation CCUtility -#pragma -------------------------------------------------------------------------------------------- -#pragma mark ======================= KeyChainStore ================================== -#pragma -------------------------------------------------------------------------------------------- - -+ (void)deleteAllChainStore -{ - [UICKeyChainStore removeAllItems]; - [UICKeyChainStore removeAllItemsForService:NCGlobal.shared.serviceShareKeyChain]; -} - -#pragma ------------------------------ GET/SET - -+ (void)setPushNotificationPublicKey:(NSString *)account data:(NSData *)data -{ - NSString *key = [@"PNPublicKey" stringByAppendingString:account]; - [UICKeyChainStore setData:data forKey:key service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (NSData *)getPushNotificationPublicKey:(NSString *)account -{ - NSString *key = [@"PNPublicKey" stringByAppendingString:account]; - return [UICKeyChainStore dataForKey:key service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (void)setPushNotificationSubscribingPublicKey:(NSString *)account publicKey:(NSString *)publicKey -{ - NSString *key = [@"PNSubscribingPublicKey" stringByAppendingString:account]; - [UICKeyChainStore setString:publicKey forKey:key service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (NSString *)getPushNotificationSubscribingPublicKey:(NSString *)account -{ - NSString *key = [@"PNSubscribingPublicKey" stringByAppendingString:account]; - return [UICKeyChainStore stringForKey:key service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (void)setPushNotificationPrivateKey:(NSString *)account data:(NSData *)data -{ - NSString *key = [@"PNPrivateKey" stringByAppendingString:account]; - [UICKeyChainStore setData:data forKey:key service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (NSData *)getPushNotificationPrivateKey:(NSString *)account -{ - NSString *key = [@"PNPrivateKey" stringByAppendingString:account]; - return [UICKeyChainStore dataForKey:key service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (void)setPushNotificationToken:(NSString *)account token:(NSString *)token -{ - NSString *key = [@"PNToken" stringByAppendingString:account]; - [UICKeyChainStore setString:token forKey:key service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (NSString *)getPushNotificationToken:(NSString *)account -{ - NSString *key = [@"PNToken" stringByAppendingString:account]; - return [UICKeyChainStore stringForKey:key service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (void)setPushNotificationDeviceIdentifier:(NSString *)account deviceIdentifier:(NSString *)deviceIdentifier -{ - NSString *key = [@"PNDeviceIdentifier" stringByAppendingString:account]; - [UICKeyChainStore setString:deviceIdentifier forKey:key service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (NSString *)getPushNotificationDeviceIdentifier:(NSString *)account -{ - NSString *key = [@"PNDeviceIdentifier" stringByAppendingString:account]; - return [UICKeyChainStore stringForKey:key service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (void)setPushNotificationDeviceIdentifierSignature:(NSString *)account deviceIdentifierSignature:(NSString *)deviceIdentifierSignature -{ - NSString *key = [@"PNDeviceIdentifierSignature" stringByAppendingString:account]; - [UICKeyChainStore setString:deviceIdentifierSignature forKey:key service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (NSString *)getPushNotificationDeviceIdentifierSignature:(NSString *)account -{ - NSString *key = [@"PNDeviceIdentifierSignature" stringByAppendingString:account]; - return [UICKeyChainStore stringForKey:key service:NCGlobal.shared.serviceShareKeyChain]; -} - -+ (void)clearAllKeysPushNotification:(NSString *)account -{ - [self setPushNotificationPublicKey:account data:nil]; - [self setPushNotificationSubscribingPublicKey:account publicKey:nil]; - [self setPushNotificationPrivateKey:account data:nil]; - [self setPushNotificationToken:account token:nil]; - [self setPushNotificationDeviceIdentifier:account deviceIdentifier:nil]; - [self setPushNotificationDeviceIdentifierSignature:account deviceIdentifierSignature:nil]; -} - #pragma -------------------------------------------------------------------------------------------- #pragma mark ===== Various ===== #pragma -------------------------------------------------------------------------------------------- diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index 28ef68d7df..7dd554074b 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -428,7 +428,6 @@ import KeychainAccess } func isEndToEndEnabled(account: String) -> Bool { - guard let certificate = getEndToEndCertificate(account: account), !certificate.isEmpty, let publicKey = getEndToEndPublicKey(account: account), !publicKey.isEmpty, let privateKey = getEndToEndPrivateKey(account: account), !privateKey.isEmpty, @@ -443,4 +442,75 @@ import KeychainAccess setEndToEndPublicKey(account: account, publicKey: nil) setEndToEndPassphrase(account: account, passphrase: nil) } + + // MARK: - PUSHNOTIFICATION + + @objc func getPushNotificationPublicKey(account: String) -> Data? { + let key = "PNPublicKey" + account + return try? keychain.getData(key) + } + + @objc func setPushNotificationPublicKey(account: String, data: Data?) { + let key = "PNPublicKey" + account + keychain[data: key] = data + } + + @objc func getPushNotificationSubscribingPublicKey(account: String) -> String? { + let key = "PNSubscribingPublicKey" + account + return try? keychain.get(key) + } + + @objc func setPushNotificationSubscribingPublicKey(account: String, publicKey: String?) { + let key = "PNSubscribingPublicKey" + account + keychain[key] = publicKey + } + + @objc func getPushNotificationPrivateKey(account: String) -> Data? { + let key = "PNPrivateKey" + account + return try? keychain.getData(key) + } + + @objc func setPushNotificationPrivateKey(account: String, data: Data?) { + let key = "PNPrivateKey" + account + keychain[data: key] = data + } + + @objc func getPushNotificationToken(account: String) -> String? { + let key = "PNToken" + account + return try? keychain.get(key) + } + + @objc func setPushNotificationToken(account: String, token: String?) { + let key = "PNToken" + account + keychain[key] = token + } + + @objc func getPushNotificationDeviceIdentifier(account: String) -> String? { + let key = "PNDeviceIdentifier" + account + return try? keychain.get(key) + } + + @objc func setPushNotificationDeviceIdentifier(account: String, deviceIdentifier: String?) { + let key = "PNDeviceIdentifier" + account + keychain[key] = deviceIdentifier + } + + @objc func getPushNotificationDeviceIdentifierSignature(account: String) -> String? { + let key = "PNDeviceIdentifierSignature" + account + return try? keychain.get(key) + } + + @objc func setPushNotificationDeviceIdentifierSignature(account: String, deviceIdentifierSignature: String?) { + let key = "PNDeviceIdentifierSignature" + account + keychain[key] = deviceIdentifierSignature + } + + @objc func clearAllKeysPushNotification(account: String) { + setPushNotificationPublicKey(account: account, data: nil) + setPushNotificationSubscribingPublicKey(account: account, publicKey: nil) + setPushNotificationPrivateKey(account: account, data: nil) + setPushNotificationToken(account: account, token: nil) + setPushNotificationDeviceIdentifier(account: account, deviceIdentifier: nil) + setPushNotificationDeviceIdentifierSignature(account: account, deviceIdentifierSignature: nil) + } } diff --git a/iOSClient/Utility/NCUtility.swift b/iOSClient/Utility/NCUtility.swift index 58fd9e4af2..7b25ae9b68 100644 --- a/iOSClient/Utility/NCUtility.swift +++ b/iOSClient/Utility/NCUtility.swift @@ -219,7 +219,6 @@ class NCUtility: NSObject { CCUtility.createDirectoryStandard() - CCUtility.deleteAllChainStore() NCKeychain().removeAll() } #endif From 6e31f8f915455b1cae08d566e40b6198b89c27a8 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 17:43:11 +0200 Subject: [PATCH 55/90] remove UICKeyChainStore --- Nextcloud.xcodeproj/project.pbxproj | 89 ------------------------- iOSClient/Settings/Acknowledgements.rtf | 4 +- iOSClient/Utility/CCUtility.h | 1 - 3 files changed, 2 insertions(+), 92 deletions(-) diff --git a/Nextcloud.xcodeproj/project.pbxproj b/Nextcloud.xcodeproj/project.pbxproj index 84f9bdf367..0c877aa8ea 100644 --- a/Nextcloud.xcodeproj/project.pbxproj +++ b/Nextcloud.xcodeproj/project.pbxproj @@ -70,9 +70,7 @@ AFCE353927E5DE0500FEA6C2 /* NCShare+Helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353827E5DE0400FEA6C2 /* NCShare+Helper.swift */; }; C0046CDD2A17B98400D87C9D /* LoginUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0046CDC2A17B98400D87C9D /* LoginUITests.swift */; }; 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 */; }; - C04E2F1B2A17BAAB001BAD85 /* UICKeyChainStore in Frameworks */ = {isa = PBXBuildFile; productRef = C04E2F1A2A17BAAB001BAD85 /* UICKeyChainStore */; }; C04E2F232A17BB4D001BAD85 /* FilesIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04E2F222A17BB4D001BAD85 /* FilesIntegrationTests.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 */; }; @@ -93,7 +91,6 @@ F31F69542A2F89C400162F76 /* SwiftRichString in Frameworks */ = {isa = PBXBuildFile; productRef = F31F69532A2F89C400162F76 /* SwiftRichString */; }; F31F69562A2F89C400162F76 /* FirebaseDatabase in Frameworks */ = {isa = PBXBuildFile; productRef = F31F69552A2F89C400162F76 /* FirebaseDatabase */; }; 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 */; }; F31F695E2A2F89C400162F76 /* JGProgressHUD in Frameworks */ = {isa = PBXBuildFile; productRef = F31F695D2A2F89C400162F76 /* JGProgressHUD */; }; F31F69612A2F907800162F76 /* __Snapshots__ in Resources */ = {isa = PBXBuildFile; fileRef = F31F69602A2F907800162F76 /* __Snapshots__ */; }; @@ -157,7 +154,6 @@ F70716E62987F81500E72C1D /* DocumentActionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F70716E52987F81500E72C1D /* DocumentActionViewController.swift */; }; 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, ); }; }; - F70716F929881CFA00E72C1D /* UICKeyChainStore in Frameworks */ = {isa = PBXBuildFile; productRef = F70716F829881CFA00E72C1D /* UICKeyChainStore */; }; F70753EB2542A99800972D44 /* NCViewerMediaPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = F70753EA2542A99800972D44 /* NCViewerMediaPage.swift */; }; F70753F12542A9A200972D44 /* NCViewerMedia.swift in Sources */ = {isa = PBXBuildFile; fileRef = F70753F02542A9A200972D44 /* NCViewerMedia.swift */; }; 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 */; }; 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 */; }; - F7346E2528B0FEFA006CE2D2 /* UICKeyChainStore in Frameworks */ = {isa = PBXBuildFile; productRef = F7346E2428B0FEFA006CE2D2 /* UICKeyChainStore */; }; F7346E2928B0FFF2006CE2D2 /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = F7346E2828B0FFF2006CE2D2 /* RealmSwift */; }; F734B06628E75C0100E180D5 /* TLPhotoPicker in Frameworks */ = {isa = PBXBuildFile; productRef = F734B06528E75C0100E180D5 /* TLPhotoPicker */; }; 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 */; }; 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 */; }; - F76DA966277B76F30082465B /* UICKeyChainStore in Frameworks */ = {isa = PBXBuildFile; productRef = F76DA965277B76F30082465B /* UICKeyChainStore */; }; F76DA969277B77EA0082465B /* DropDown in Frameworks */ = {isa = PBXBuildFile; productRef = F76DA968277B77EA0082465B /* DropDown */; }; F76DEE9728F808AF0041B1C9 /* LockscreenData.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76DEE9428F808AF0041B1C9 /* LockscreenData.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 */; }; F7A8D72428F1771B008BBE1C /* NextcloudKit in Frameworks */ = {isa = PBXBuildFile; productRef = F7A8D72328F1771B008BBE1C /* NextcloudKit */; }; 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 */; }; F7A8D73528F17E16008BBE1C /* NCManageDatabase.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7BAADB51ED5A87C00B7EAD4 /* NCManageDatabase.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 */; }; 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 */; }; - 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 */; }; F7EDE4CC262D7B6F00414FE6 /* NCEmptyDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7239870253D86B600257F49 /* NCEmptyDataSet.swift */; }; F7EDE4D1262D7B8400414FE6 /* NCDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C1EEA425053A9C00866ACC /* NCDataSource.swift */; }; @@ -1398,7 +1388,6 @@ F72AD71128C24BBB006CB92D /* NextcloudKit in Frameworks */, F314F1112A30C11200BC7FAB /* PreviewSnapshots in Frameworks */, F710FC88277B7D3F00AA9FBF /* RealmSwift in Frameworks */, - F7EBCDD3277B821700A4EF67 /* UICKeyChainStore in Frameworks */, F760DE0F2AE66EE60027D78A /* KeychainAccess in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1414,7 +1403,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - C04E2F1B2A17BAAB001BAD85 /* UICKeyChainStore in Frameworks */, C04E2F192A17BA78001BAD85 /* XLForm in Frameworks */, F760DE152AE66F020027D78A /* KeychainAccess in Frameworks */, ); @@ -1429,7 +1417,6 @@ F30A96362A2DFCD000D7BCFE /* RealmSwift in Frameworks */, F30A96342A2DFCD000D7BCFE /* Realm in Frameworks */, F760DE112AE66EF00027D78A /* KeychainAccess in Frameworks */, - C03BA14C2A17BC60002C8BA3 /* UICKeyChainStore in Frameworks */, F30A963A2A2DFD3100D7BCFE /* JGProgressHUD in Frameworks */, C03BA14A2A17BC57002C8BA3 /* XLForm in Frameworks */, ); @@ -1440,7 +1427,6 @@ buildActionMask = 2147483647; files = ( F31F695C2A2F89C400162F76 /* Realm in Frameworks */, - F31F695A2A2F89C400162F76 /* UICKeyChainStore in Frameworks */, F31F69582A2F89C400162F76 /* XLForm in Frameworks */, F31F69542A2F89C400162F76 /* SwiftRichString in Frameworks */, F760DE132AE66EF80027D78A /* KeychainAccess in Frameworks */, @@ -1460,7 +1446,6 @@ F7490E8B29882CE4009DCE94 /* NextcloudKit in Frameworks */, F7490E8929882CC8009DCE94 /* SwiftEntryKit in Frameworks */, F7490E7229882BB4009DCE94 /* RealmSwift in Frameworks */, - F70716F929881CFA00E72C1D /* UICKeyChainStore in Frameworks */, F760DE0D2AE66EDF0027D78A /* KeychainAccess in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1476,7 +1461,6 @@ F760DE092AE66ED00027D78A /* KeychainAccess in Frameworks */, F73ADD2126554F8E0069EA0D /* SwiftEntryKit in Frameworks */, F7A560482AE15D5000BE8FD6 /* Queuer in Frameworks */, - F7EBCDCF277B81FF00A4EF67 /* UICKeyChainStore in Frameworks */, F70821D829E59E6D001CA2D7 /* TagListView in Frameworks */, F7F623B72A5EFA0C0022D3D4 /* Gzip in Frameworks */, F72D7EB7263B1207000B3DFC /* MarkdownKit in Frameworks */, @@ -1488,7 +1472,6 @@ buildActionMask = 2147483647; files = ( F787AC0B298BCB540001BB00 /* SVGKitSwift in Frameworks */, - F7346E2528B0FEFA006CE2D2 /* UICKeyChainStore in Frameworks */, F783034428B5142B00B84583 /* NextcloudKit in Frameworks */, F7346E1328B0EF5B006CE2D2 /* SwiftUI.framework in Frameworks */, F760DE052AE66EBE0027D78A /* KeychainAccess in Frameworks */, @@ -1505,7 +1488,6 @@ buildActionMask = 2147483647; files = ( F7A560442AE15D2900BE8FD6 /* Queuer in Frameworks */, - F7EBCDD1277B820D00A4EF67 /* UICKeyChainStore in Frameworks */, F760DE0B2AE66ED80027D78A /* KeychainAccess in Frameworks */, F73ADD2426554FE20069EA0D /* SwiftEntryKit in Frameworks */, F710FC84277B7D3500AA9FBF /* RealmSwift in Frameworks */, @@ -1530,7 +1512,6 @@ F710FC7C277B7D0000AA9FBF /* RealmSwift in Frameworks */, F758A01227A7F03E0069468B /* JGProgressHUD in Frameworks */, F77333882927A72100466E35 /* OpenSSL in Frameworks */, - F76DA966277B76F30082465B /* UICKeyChainStore in Frameworks */, F7792DE529EEE02D005930CE /* MobileVLCKit.xcframework in Frameworks */, F753BA93281FD8020015BFB6 /* EasyTipView in Frameworks */, F76DA95B277B75A90082465B /* TOPasscodeViewController.xcframework in Frameworks */, @@ -1555,7 +1536,6 @@ buildActionMask = 2147483647; files = ( F7A8D72828F17728008BBE1C /* RealmSwift in Frameworks */, - F7A8D72E28F17764008BBE1C /* UICKeyChainStore in Frameworks */, F7A8D72428F1771B008BBE1C /* NextcloudKit in Frameworks */, F7C9739228F17131002C43E2 /* Intents.framework in Frameworks */, F760DE072AE66EC70027D78A /* KeychainAccess in Frameworks */, @@ -2683,7 +2663,6 @@ name = "Notification Service Extension"; packageProductDependencies = ( F710FC87277B7D3F00AA9FBF /* RealmSwift */, - F7EBCDD2277B821700A4EF67 /* UICKeyChainStore */, F72AD71028C24BBB006CB92D /* NextcloudKit */, F314F1102A30C11200BC7FAB /* PreviewSnapshots */, F760DE0E2AE66EE60027D78A /* KeychainAccess */, @@ -2726,7 +2705,6 @@ name = NextcloudUITests; packageProductDependencies = ( C04E2F182A17BA78001BAD85 /* XLForm */, - C04E2F1A2A17BAAB001BAD85 /* UICKeyChainStore */, F760DE142AE66F020027D78A /* KeychainAccess */, ); productName = NextcloudUITests; @@ -2749,7 +2727,6 @@ name = NextcloudIntegrationTests; packageProductDependencies = ( C03BA1492A17BC57002C8BA3 /* XLForm */, - C03BA14B2A17BC60002C8BA3 /* UICKeyChainStore */, F30A96332A2DFCD000D7BCFE /* Realm */, F30A96352A2DFCD000D7BCFE /* RealmSwift */, F30A96372A2DFD2900D7BCFE /* FirebaseDatabase */, @@ -2781,7 +2758,6 @@ F31F69532A2F89C400162F76 /* SwiftRichString */, F31F69552A2F89C400162F76 /* FirebaseDatabase */, F31F69572A2F89C400162F76 /* XLForm */, - F31F69592A2F89C400162F76 /* UICKeyChainStore */, F31F695B2A2F89C400162F76 /* Realm */, F31F695D2A2F89C400162F76 /* JGProgressHUD */, F31F69652A2F929600162F76 /* PreviewSnapshotsTesting */, @@ -2806,7 +2782,6 @@ ); name = "File Provider Extension UI"; packageProductDependencies = ( - F70716F829881CFA00E72C1D /* UICKeyChainStore */, F7490E7129882BB4009DCE94 /* RealmSwift */, F7490E8829882CC8009DCE94 /* SwiftEntryKit */, F7490E8A29882CE4009DCE94 /* NextcloudKit */, @@ -2833,7 +2808,6 @@ F72D7EB6263B1207000B3DFC /* MarkdownKit */, F73ADD2026554F8E0069EA0D /* SwiftEntryKit */, F710FC7F277B7D2700AA9FBF /* RealmSwift */, - F7EBCDCE277B81FF00A4EF67 /* UICKeyChainStore */, F72CD01127A7E92400E59476 /* JGProgressHUD */, F72AD70E28C24BA1006CB92D /* NextcloudKit */, F70821D729E59E6D001CA2D7 /* TagListView */, @@ -2860,7 +2834,6 @@ ); name = Widget; packageProductDependencies = ( - F7346E2428B0FEFA006CE2D2 /* UICKeyChainStore */, F7346E2828B0FFF2006CE2D2 /* RealmSwift */, F783030C28B4C59A00B84583 /* SwiftEntryKit */, F783034328B5142B00B84583 /* NextcloudKit */, @@ -2889,7 +2862,6 @@ packageProductDependencies = ( F73ADD2326554FE20069EA0D /* SwiftEntryKit */, F710FC83277B7D3500AA9FBF /* RealmSwift */, - F7EBCDD0277B820D00A4EF67 /* UICKeyChainStore */, F72AD71228C24BCC006CB92D /* NextcloudKit */, F7A560432AE15D2900BE8FD6 /* Queuer */, F753791F2AE2AD9400C0250E /* JGProgressHUD */, @@ -2932,7 +2904,6 @@ F75EAED726D2552E00F4320E /* MarqueeLabel */, F74E771F277A2EF40013B958 /* XLForm */, F76DA962277B760E0082465B /* Queuer */, - F76DA965277B76F30082465B /* UICKeyChainStore */, F76DA968277B77EA0082465B /* DropDown */, F710FC79277B7D0000AA9FBF /* Realm */, F710FC7B277B7D0000AA9FBF /* RealmSwift */, @@ -2971,7 +2942,6 @@ packageProductDependencies = ( F7A8D72328F1771B008BBE1C /* NextcloudKit */, F7A8D72728F17728008BBE1C /* RealmSwift */, - F7A8D72D28F17764008BBE1C /* UICKeyChainStore */, F760DE062AE66EC70027D78A /* KeychainAccess */, ); productName = WidgetDashboardIntentHandler; @@ -3110,7 +3080,6 @@ F75EAED626D2552E00F4320E /* XCRemoteSwiftPackageReference "MarqueeLabel" */, F74E771E277A2EF40013B958 /* XCRemoteSwiftPackageReference "XLForm" */, F76DA961277B760E0082465B /* XCRemoteSwiftPackageReference "Queuer" */, - F76DA964277B76F10082465B /* XCRemoteSwiftPackageReference "UICKeyChainStore" */, F76DA967277B77E90082465B /* XCRemoteSwiftPackageReference "DropDown" */, F710FC78277B7CFF00AA9FBF /* XCRemoteSwiftPackageReference "realm-swift" */, F7BB7E4527A18C56009B9F29 /* XCRemoteSwiftPackageReference "Parchment" */, @@ -5087,14 +5056,6 @@ minimumVersion = 2.0.0; }; }; - F76DA964277B76F10082465B /* XCRemoteSwiftPackageReference "UICKeyChainStore" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/kishikawakatsumi/UICKeyChainStore"; - requirement = { - branch = master; - kind = branch; - }; - }; F76DA967277B77E90082465B /* XCRemoteSwiftPackageReference "DropDown" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/AssistoLab/DropDown"; @@ -5191,21 +5152,11 @@ package = F74E771E277A2EF40013B958 /* XCRemoteSwiftPackageReference "XLForm" */; productName = XLForm; }; - C03BA14B2A17BC60002C8BA3 /* UICKeyChainStore */ = { - isa = XCSwiftPackageProductDependency; - package = F76DA964277B76F10082465B /* XCRemoteSwiftPackageReference "UICKeyChainStore" */; - productName = UICKeyChainStore; - }; C04E2F182A17BA78001BAD85 /* XLForm */ = { isa = XCSwiftPackageProductDependency; package = F74E771E277A2EF40013B958 /* XCRemoteSwiftPackageReference "XLForm" */; productName = XLForm; }; - C04E2F1A2A17BAAB001BAD85 /* UICKeyChainStore */ = { - isa = XCSwiftPackageProductDependency; - package = F76DA964277B76F10082465B /* XCRemoteSwiftPackageReference "UICKeyChainStore" */; - productName = UICKeyChainStore; - }; F30A96332A2DFCD000D7BCFE /* Realm */ = { isa = XCSwiftPackageProductDependency; package = F710FC78277B7CFF00AA9FBF /* XCRemoteSwiftPackageReference "realm-swift" */; @@ -5261,11 +5212,6 @@ package = F74E771E277A2EF40013B958 /* XCRemoteSwiftPackageReference "XLForm" */; productName = XLForm; }; - F31F69592A2F89C400162F76 /* UICKeyChainStore */ = { - isa = XCSwiftPackageProductDependency; - package = F76DA964277B76F10082465B /* XCRemoteSwiftPackageReference "UICKeyChainStore" */; - productName = UICKeyChainStore; - }; F31F695B2A2F89C400162F76 /* Realm */ = { isa = XCSwiftPackageProductDependency; package = F710FC78277B7CFF00AA9FBF /* XCRemoteSwiftPackageReference "realm-swift" */; @@ -5291,11 +5237,6 @@ package = F31F69672A2F92F000162F76 /* XCRemoteSwiftPackageReference "SnapshotTestingHEIC" */; productName = SnapshotTestingHEIC; }; - F70716F829881CFA00E72C1D /* UICKeyChainStore */ = { - isa = XCSwiftPackageProductDependency; - package = F76DA964277B76F10082465B /* XCRemoteSwiftPackageReference "UICKeyChainStore" */; - productName = UICKeyChainStore; - }; F70821D729E59E6D001CA2D7 /* TagListView */ = { isa = XCSwiftPackageProductDependency; package = F7A1050C29E587AF00FFD92B /* XCRemoteSwiftPackageReference "TagListView" */; @@ -5366,11 +5307,6 @@ package = F72DA9B225F53E4E00B87DB1 /* XCRemoteSwiftPackageReference "SwiftRichString" */; productName = SwiftRichString; }; - F7346E2428B0FEFA006CE2D2 /* UICKeyChainStore */ = { - isa = XCSwiftPackageProductDependency; - package = F76DA964277B76F10082465B /* XCRemoteSwiftPackageReference "UICKeyChainStore" */; - productName = UICKeyChainStore; - }; F7346E2828B0FFF2006CE2D2 /* RealmSwift */ = { isa = XCSwiftPackageProductDependency; package = F710FC78277B7CFF00AA9FBF /* XCRemoteSwiftPackageReference "realm-swift" */; @@ -5501,11 +5437,6 @@ package = F76DA961277B760E0082465B /* XCRemoteSwiftPackageReference "Queuer" */; productName = Queuer; }; - F76DA965277B76F30082465B /* UICKeyChainStore */ = { - isa = XCSwiftPackageProductDependency; - package = F76DA964277B76F10082465B /* XCRemoteSwiftPackageReference "UICKeyChainStore" */; - productName = UICKeyChainStore; - }; F76DA968277B77EA0082465B /* DropDown */ = { isa = XCSwiftPackageProductDependency; package = F76DA967277B77E90082465B /* XCRemoteSwiftPackageReference "DropDown" */; @@ -5586,11 +5517,6 @@ package = F710FC78277B7CFF00AA9FBF /* XCRemoteSwiftPackageReference "realm-swift" */; productName = RealmSwift; }; - F7A8D72D28F17764008BBE1C /* UICKeyChainStore */ = { - isa = XCSwiftPackageProductDependency; - package = F76DA964277B76F10082465B /* XCRemoteSwiftPackageReference "UICKeyChainStore" */; - productName = UICKeyChainStore; - }; F7BB7E4627A18C56009B9F29 /* Parchment */ = { isa = XCSwiftPackageProductDependency; package = F7BB7E4527A18C56009B9F29 /* XCRemoteSwiftPackageReference "Parchment" */; @@ -5601,21 +5527,6 @@ package = F7D56B182972405400FA46C4 /* XCRemoteSwiftPackageReference "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 */ = { isa = XCSwiftPackageProductDependency; package = F7ED547A25EEA65400956C55 /* XCRemoteSwiftPackageReference "QRCodeReader" */; diff --git a/iOSClient/Settings/Acknowledgements.rtf b/iOSClient/Settings/Acknowledgements.rtf index 0a8ff4e085..93c804f78d 100644 --- a/iOSClient/Settings/Acknowledgements.rtf +++ b/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;} {\colortbl;\red255\green255\blue255;} {\*\expandedcolortbl;;} @@ -57,7 +57,7 @@ Copyright (c) 2014-2017 https://realm.io\ __________________________________\ \ -\f1\b UICKeyChainStore +\f1\b KeychainAccess \f0\b0 \ \ MIT License\ diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index afd6d1aa43..38a58f3e4c 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -27,7 +27,6 @@ #import #import #import -#import #import #import From b858b8eebae20299ccbbb8612210a7682ddf576d Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 17:48:23 +0200 Subject: [PATCH 56/90] Update NCKeychain.swift --- iOSClient/Utility/NCKeychain.swift | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index 7dd554074b..17f57b0f2d 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -28,13 +28,6 @@ import KeychainAccess let keychain = Keychain(service: "com.nextcloud.keychain") - // swiftlint:disable identifier_name - let E2E_certificate = "EndToEndCertificate_" - let E2E_PrivateKey = "EndToEndPrivateKey_" - let E2E_Passphrase = "EndToEndPassphrase_" - let E2E_PublicKey = "EndToEndPublicKeyServer_" - // swiftlint:enable identifier_name - override init() { super.init() } @@ -384,46 +377,46 @@ import KeychainAccess // MARK: - E2EE func getEndToEndCertificate(account: String) -> String? { - let key = E2E_certificate + account + let key = "EndToEndCertificate_" + account migrate(key: key) return try? keychain.get(key) } func setEndToEndCertificate(account: String, certificate: String?) { - let key = E2E_certificate + account + let key = "EndToEndCertificate_" + account keychain[key] = certificate } func getEndToEndPrivateKey(account: String) -> String? { - let key = E2E_PrivateKey + account + let key = "EndToEndPrivateKey_" + account migrate(key: key) return try? keychain.get(key) } func setEndToEndPrivateKey(account: String, privateKey: String?) { - let key = E2E_PrivateKey + account + let key = "EndToEndPrivateKey_" + account keychain[key] = privateKey } func getEndToEndPublicKey(account: String) -> String? { - let key = E2E_PublicKey + account + let key = "EndToEndPublicKeyServer_" + account migrate(key: key) return try? keychain.get(key) } func setEndToEndPublicKey(account: String, publicKey: String?) { - let key = E2E_PublicKey + account + let key = "EndToEndPublicKeyServer_" + account keychain[key] = publicKey } func getEndToEndPassphrase(account: String) -> String? { - let key = E2E_Passphrase + account + let key = "EndToEndPassphrase_" + account migrate(key: key) return try? keychain.get(key) } func setEndToEndPassphrase(account: String, passphrase: String?) { - let key = E2E_Passphrase + account + let key = "EndToEndPassphrase_" + account keychain[key] = passphrase } From 255f69a5ad32e4a91640e3c8bf2aa7d24f223a51 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Tue, 24 Oct 2023 18:04:57 +0200 Subject: [PATCH 57/90] Update NCKeychain.swift --- iOSClient/Utility/NCKeychain.swift | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index 17f57b0f2d..6efd6d3527 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -28,10 +28,6 @@ import KeychainAccess let keychain = Keychain(service: "com.nextcloud.keychain") - override init() { - super.init() - } - var typeFilterScanDocument: NCGlobal.TypeFilterScanDocument { get { if let rawValue = try? keychain.get("ScanDocumentTypeFilter"), let value = NCGlobal.TypeFilterScanDocument(rawValue: rawValue) { @@ -440,6 +436,7 @@ import KeychainAccess @objc func getPushNotificationPublicKey(account: String) -> Data? { let key = "PNPublicKey" + account + migrate(key: key) return try? keychain.getData(key) } @@ -448,18 +445,9 @@ import KeychainAccess keychain[data: key] = data } - @objc func getPushNotificationSubscribingPublicKey(account: String) -> String? { - let key = "PNSubscribingPublicKey" + account - return try? keychain.get(key) - } - - @objc func setPushNotificationSubscribingPublicKey(account: String, publicKey: String?) { - let key = "PNSubscribingPublicKey" + account - keychain[key] = publicKey - } - @objc func getPushNotificationPrivateKey(account: String) -> Data? { let key = "PNPrivateKey" + account + migrate(key: key) return try? keychain.getData(key) } @@ -468,8 +456,20 @@ import KeychainAccess keychain[data: key] = data } + @objc func getPushNotificationSubscribingPublicKey(account: String) -> String? { + let key = "PNSubscribingPublicKey" + account + migrate(key: key) + return try? keychain.get(key) + } + + @objc func setPushNotificationSubscribingPublicKey(account: String, publicKey: String?) { + let key = "PNSubscribingPublicKey" + account + keychain[key] = publicKey + } + @objc func getPushNotificationToken(account: String) -> String? { let key = "PNToken" + account + migrate(key: key) return try? keychain.get(key) } @@ -480,6 +480,7 @@ import KeychainAccess @objc func getPushNotificationDeviceIdentifier(account: String) -> String? { let key = "PNDeviceIdentifier" + account + migrate(key: key) return try? keychain.get(key) } @@ -490,6 +491,7 @@ import KeychainAccess @objc func getPushNotificationDeviceIdentifierSignature(account: String) -> String? { let key = "PNDeviceIdentifierSignature" + account + migrate(key: key) return try? keychain.get(key) } From bf73a0056f660df18466e4c3eac642170f0a5b10 Mon Sep 17 00:00:00 2001 From: Nextcloud bot Date: Wed, 25 Oct 2023 02:58:07 +0000 Subject: [PATCH 58/90] Fix(l10n): Update translations from Transifex Signed-off-by: Nextcloud bot --- .../mk.lproj/Localizable.strings | Bin 121664 -> 121666 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/iOSClient/Supporting Files/mk.lproj/Localizable.strings b/iOSClient/Supporting Files/mk.lproj/Localizable.strings index dc2542581de58f2f8af87a7ec712eed81dc6b02a..7cf158a2435ff383555c7f3546a0e9780586671e 100644 GIT binary patch delta 20 ccmX@Gjs4Iz_6_THGFmjR-MM}3PR7ZK0B#2g2mk;8 delta 18 acmX@Kjs3tj_6_THHgDLueZx-1Ns0hr&k583 From 1f5c16fd70c2186b2dba8040b9ad19a5b52c9d15 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Wed, 25 Oct 2023 11:20:33 +0200 Subject: [PATCH 59/90] directory --- .../FileProviderData.swift | 12 +++--- Share/NCShareExtension.swift | 4 +- Widget/Dashboard/DashboardData.swift | 10 ++--- Widget/Files/FilesData.swift | 5 +-- iOSClient/Activity/NCActivity.swift | 2 +- .../Activity/NCActivityCommentView.swift | 2 +- .../Activity/NCActivityTableViewCell.swift | 2 +- iOSClient/AppDelegate.swift | 8 ++-- iOSClient/Data/NCManageDatabase+Avatar.swift | 4 +- .../Login/NCViewCertificateDetails.swift | 2 +- .../NCCreateFormUploadDocuments.swift | 4 +- iOSClient/Networking/NCNetworking.swift | 6 +-- iOSClient/Networking/NCService.swift | 4 +- iOSClient/Notification/NCNotification.swift | 4 +- iOSClient/Settings/NCEndToEndInitialize.swift | 4 +- iOSClient/Share/NCShare.swift | 2 +- iOSClient/Share/NCShareUserCell.swift | 2 +- iOSClient/Utility/CCUtility.h | 6 --- iOSClient/Utility/NCUtility.swift | 4 +- iOSClient/Utility/NCUtilityFileSystem.swift | 38 +++++++++++++++++++ .../NCViewerRichdocument.swift | 4 +- 21 files changed, 76 insertions(+), 53 deletions(-) diff --git a/File Provider Extension/FileProviderData.swift b/File Provider Extension/FileProviderData.swift index 7cf0d8da92..de7ddbb03e 100644 --- a/File Provider Extension/FileProviderData.swift +++ b/File Provider Extension/FileProviderData.swift @@ -72,13 +72,11 @@ class fileProviderData: NSObject { } // LOG - if let pathDirectoryGroup = CCUtility.getDirectoryGroup()?.path { - NextcloudKit.shared.nkCommonInstance.pathLog = pathDirectoryGroup - 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)") - } + 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 if domain == nil { diff --git a/Share/NCShareExtension.swift b/Share/NCShareExtension.swift index c12dee8bbd..1d298a1502 100644 --- a/Share/NCShareExtension.swift +++ b/Share/NCShareExtension.swift @@ -116,9 +116,7 @@ class NCShareExtension: UIViewController { let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp()) 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 { NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Start Share session with level \(levelLog) " + versionNextcloudiOS + " (Simulator / TestFlight)") } else { diff --git a/Widget/Dashboard/DashboardData.swift b/Widget/Dashboard/DashboardData.swift index 555b2212c5..b5ab1ce406 100644 --- a/Widget/Dashboard/DashboardData.swift +++ b/Widget/Dashboard/DashboardData.swift @@ -90,7 +90,7 @@ func convertDataToImage(data: Data?, size: CGSize, fileNameToWrite: String?) -> } if let fileName = fileNameToWrite, let image = imageData { 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) } catch { } } @@ -147,9 +147,7 @@ func getDashboardDataEntry(configuration: DashboardIntent?, isPreview: Bool, dis let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp()) 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 { NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Start \(NCBrandOptions.shared.brand) dashboard widget session with level \(levelLog) " + versionNextcloudiOS + " (Simulator / TestFlight)") } else { @@ -162,7 +160,7 @@ func getDashboardDataEntry(configuration: DashboardIntent?, isPreview: Bool, dis var imagetmp = UIImage(named: "widget")! 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) { imagetmp = image.withTintColor(.label, renderingMode: .alwaysOriginal) } @@ -224,7 +222,7 @@ func getDashboardDataEntry(configuration: DashboardIntent?, isPreview: Bool, dis imageColor = UIColor(hex: colorString) icon = UIImage(systemName: "circle.fill")! } 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) { icon = image } else { diff --git a/Widget/Files/FilesData.swift b/Widget/Files/FilesData.swift index f438c815db..370249e36c 100644 --- a/Widget/Files/FilesData.swift +++ b/Widget/Files/FilesData.swift @@ -197,9 +197,8 @@ func getFilesDataEntry(configuration: AccountIntent?, isPreview: Bool, displaySi let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp()) 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 { NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Start \(NCBrandOptions.shared.brand) widget session with level \(levelLog) " + versionNextcloudiOS + " (Simulator / TestFlight)") } else { diff --git a/iOSClient/Activity/NCActivity.swift b/iOSClient/Activity/NCActivity.swift index 3569c9c551..4fe57f8d91 100644 --- a/iOSClient/Activity/NCActivity.swift +++ b/iOSClient/Activity/NCActivity.swift @@ -250,7 +250,7 @@ extension NCActivity: UITableViewDataSource { if !activity.icon.isEmpty { 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 let image = UIImage(contentsOfFile: fileNameLocalPath) { diff --git a/iOSClient/Activity/NCActivityCommentView.swift b/iOSClient/Activity/NCActivityCommentView.swift index 768006b135..054067a747 100644 --- a/iOSClient/Activity/NCActivityCommentView.swift +++ b/iOSClient/Activity/NCActivityCommentView.swift @@ -36,7 +36,7 @@ class NCActivityCommentView: UIView, UITextFieldDelegate { newCommentField.delegate = self 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) { imageItem.image = image } else { diff --git a/iOSClient/Activity/NCActivityTableViewCell.swift b/iOSClient/Activity/NCActivityTableViewCell.swift index dd25719b88..2b0537151d 100644 --- a/iOSClient/Activity/NCActivityTableViewCell.swift +++ b/iOSClient/Activity/NCActivityTableViewCell.swift @@ -187,7 +187,7 @@ extension NCActivityTableViewCell: UICollectionViewDataSource { 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) { cell.imageView.image = image diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index eb8ca33e6e..4e713d1379 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -98,9 +98,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD startTimerErrorNetworking() 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 { @@ -541,7 +539,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD host == currentHost else { return } - let certificateHostSavedPath = CCUtility.getDirectoryCerificates()! + "/" + host + ".der" + let certificateHostSavedPath = NCUtilityFileSystem.shared.directoryCertificates + "/" + host + ".der" var title = NSLocalizedString("_ssl_certificate_changed_", comment: "") if !FileManager.default.fileExists(atPath: certificateHostSavedPath) { @@ -659,7 +657,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD let name = account.alias.isEmpty ? account.displayName : account.alias let userBaseUrl = account.user + "-" + (URL(string: account.urlBase)?.host ?? "") let avatarFileName = userBaseUrl + "-\(account.user).png" - let pathAvatarFileName = String(CCUtility.getDirectoryUserData()) + "/" + avatarFileName + let pathAvatarFileName = NCUtilityFileSystem.shared.directoryUserData + "/" + avatarFileName let image = UIImage(contentsOfFile: pathAvatarFileName) accounts.append(NKShareAccounts.DataAccounts(withUrl: account.urlBase, user: account.user, name: name, image: image)) } diff --git a/iOSClient/Data/NCManageDatabase+Avatar.swift b/iOSClient/Data/NCManageDatabase+Avatar.swift index 6d6ce1cf9e..3687408f3a 100644 --- a/iOSClient/Data/NCManageDatabase+Avatar.swift +++ b/iOSClient/Data/NCManageDatabase+Avatar.swift @@ -89,7 +89,7 @@ extension NCManageDatabase { @discardableResult func setAvatarLoaded(fileName: String) -> UIImage? { - let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + fileName + let fileNameLocalPath = NCUtilityFileSystem.shared.directoryUserData + "/" + fileName var image: UIImage? do { @@ -113,7 +113,7 @@ extension NCManageDatabase { func getImageAvatarLoaded(fileName: String) -> UIImage? { - let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + fileName + let fileNameLocalPath = NCUtilityFileSystem.shared.directoryUserData + "/" + fileName do { let realm = try Realm() diff --git a/iOSClient/Login/NCViewCertificateDetails.swift b/iOSClient/Login/NCViewCertificateDetails.swift index bf9befd44c..07dca1b5f3 100644 --- a/iOSClient/Login/NCViewCertificateDetails.swift +++ b/iOSClient/Login/NCViewCertificateDetails.swift @@ -53,7 +53,7 @@ class NCViewCertificateDetails: UIViewController { buttonCancel.title = NSLocalizedString("_close_", comment: "") if fileNamePath.isEmpty { - fileNamePath = CCUtility.getDirectoryCerificates()! + "/" + host + ".txt" + fileNamePath = NCUtilityFileSystem.shared.directoryCertificates + "/" + host + ".txt" } if FileManager.default.fileExists(atPath: fileNamePath) { diff --git a/iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift b/iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift index 63f8a1f5c3..19097aee57 100644 --- a/iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift +++ b/iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift @@ -166,7 +166,7 @@ import XLForm // image let imagePreview = cell.viewWithTag(100) as? UIImageView 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) { let imageURL = URL(fileURLWithPath: fileNameLocalPath) if let image = UIImage(contentsOfFile: imageURL.path) { @@ -486,7 +486,7 @@ import XLForm 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 diff --git a/iOSClient/Networking/NCNetworking.swift b/iOSClient/Networking/NCNetworking.swift index 4764953e5b..0d91ccdf53 100644 --- a/iOSClient/Networking/NCNetworking.swift +++ b/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) { let protectionSpace: URLProtectionSpace = challenge.protectionSpace - let directoryCertificate = CCUtility.getDirectoryCerificates()! + let directoryCertificate = NCUtilityFileSystem.shared.directoryCertificates let host = challenge.protectionSpace.host let certificateSavedPath = directoryCertificate + "/" + host + ".der" var isTrusted: Bool @@ -215,7 +215,7 @@ class NCNetworking: NSObject, NKCommonDelegate { func writeCertificate(host: String) { - let directoryCertificate = CCUtility.getDirectoryCerificates()! + let directoryCertificate = NCUtilityFileSystem.shared.directoryCertificates let certificateAtPath = directoryCertificate + "/" + host + ".tmp" let certificateToPath = directoryCertificate + "/" + host + ".der" @@ -358,7 +358,7 @@ class NCNetworking: NSObject, NKCommonDelegate { #if !EXTENSION func downloadAvatar(user: String, dispalyName: String?, fileName: String, cell: NCCellProtocol, view: UIView?, cellImageView: UIImageView?) { 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) { cellImageView?.image = image diff --git a/iOSClient/Networking/NCService.swift b/iOSClient/Networking/NCService.swift index ff8461762d..a868ffb783 100644 --- a/iOSClient/Networking/NCService.swift +++ b/iOSClient/Networking/NCService.swift @@ -153,7 +153,7 @@ class NCService: NSObject { func getAvatar() { 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 NextcloudKit.shared.downloadAvatar(user: appDelegate.userId, @@ -269,7 +269,7 @@ class NCService: NSObject { } if let fileName = fileNameToWrite, let image = imageData { 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) } catch { } } diff --git a/iOSClient/Notification/NCNotification.swift b/iOSClient/Notification/NCNotification.swift index ecedbb8979..3a76500caf 100644 --- a/iOSClient/Notification/NCNotification.swift +++ b/iOSClient/Notification/NCNotification.swift @@ -125,7 +125,7 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty var image: UIImage? 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) } @@ -145,7 +145,7 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty cell.avatarLeadingMargin.constant = 50 let fileName = appDelegate.userBaseUrl + "-" + user + ".png" - let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + fileName + let fileNameLocalPath = NCUtilityFileSystem.shared.directoryUserData + "/" + fileName if let image = UIImage(contentsOfFile: fileNameLocalPath) { cell.avatar.image = image diff --git a/iOSClient/Settings/NCEndToEndInitialize.swift b/iOSClient/Settings/NCEndToEndInitialize.swift index 6f64ddf6a2..0363b89b1c 100644 --- a/iOSClient/Settings/NCEndToEndInitialize.swift +++ b/iOSClient/Settings/NCEndToEndInitialize.swift @@ -79,7 +79,7 @@ class NCEndToEndInitialize: NSObject { NCContentPresenter.shared.messageNotification("E2E get publicKey", error: error, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, priority: .max) 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") NCContentPresenter.shared.messageNotification("E2E Csr", error: error, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, priority: .max) @@ -255,7 +255,7 @@ class NCEndToEndInitialize: NSObject { 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") NCContentPresenter.shared.messageNotification("E2E privateKey", error: error, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, priority: .max) return diff --git a/iOSClient/Share/NCShare.swift b/iOSClient/Share/NCShare.swift index 88ac281538..9d2775cc49 100644 --- a/iOSClient/Share/NCShare.swift +++ b/iOSClient/Share/NCShare.swift @@ -166,7 +166,7 @@ class NCShare: UIViewController, NCShareNetworkingDelegate, NCSharePagingContent let fileName = appDelegate.userBaseUrl + "-" + metadata.ownerId + ".png" 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 NextcloudKit.shared.downloadAvatar( diff --git a/iOSClient/Share/NCShareUserCell.swift b/iOSClient/Share/NCShareUserCell.swift index 2e4efffdff..163b244ecd 100644 --- a/iOSClient/Share/NCShareUserCell.swift +++ b/iOSClient/Share/NCShareUserCell.swift @@ -171,7 +171,7 @@ class NCSearchUserDropDownCell: DropDownCell, NCCellProtocol { let fileName = baseUrl.userBaseUrl + "-" + sharee.shareWith + ".png" 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 NextcloudKit.shared.downloadAvatar( diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 38a58f3e4c..376a88611d 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -49,12 +49,6 @@ + (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; diff --git a/iOSClient/Utility/NCUtility.swift b/iOSClient/Utility/NCUtility.swift index 7b25ae9b68..8db357f402 100644 --- a/iOSClient/Utility/NCUtility.swift +++ b/iOSClient/Utility/NCUtility.swift @@ -55,7 +55,7 @@ class NCUtility: NSObject { fileNamePNG = iconURL.deletingPathExtension().lastPathComponent + ".png" } - let imageNamePath = CCUtility.getDirectoryUserData() + "/" + fileNamePNG + let imageNamePath = NCUtilityFileSystem.shared.directoryUserData + "/" + fileNamePNG if !FileManager.default.fileExists(atPath: imageNamePath) || rewrite == true { @@ -439,7 +439,7 @@ class NCUtility: NSObject { @objc func loadUserImage(for user: String, displayName: String?, userBaseUrl: NCUserBaseUrl) -> UIImage { let fileName = userBaseUrl.userBaseUrl + "-" + user + ".png" - let localFilePath = String(CCUtility.getDirectoryUserData()) + "/" + fileName + let localFilePath = NCUtilityFileSystem.shared.directoryUserData + "/" + fileName if let localImage = UIImage(contentsOfFile: localFilePath) { return createAvatar(image: localImage, size: 30) diff --git a/iOSClient/Utility/NCUtilityFileSystem.swift b/iOSClient/Utility/NCUtilityFileSystem.swift index 9bba457cd9..5a41db4977 100644 --- a/iOSClient/Utility/NCUtilityFileSystem.swift +++ b/iOSClient/Utility/NCUtilityFileSystem.swift @@ -32,6 +32,44 @@ class NCUtilityFileSystem: NSObject { let fileManager = FileManager.default + var directoryGroup: String { + return fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups)?.path ?? "" + } + + var directoryDocuments: String { + return NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first ?? "" + } + + var directoryCertificates: String { + if let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups) { + let path = directoryGroup.appendingPathComponent(NCGlobal.shared.appCertificates).path + if !fileManager.fileExists(atPath: path) { + do { + try fileManager.createDirectory(atPath: path, withIntermediateDirectories: true) + } catch { + return "" + } + } + return path + } + return "" + } + + var directoryUserData: String { + if let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups) { + let path = directoryGroup.appendingPathComponent(NCGlobal.shared.appUserData).path + if !fileManager.fileExists(atPath: path) { + do { + try fileManager.createDirectory(atPath: path, withIntermediateDirectories: true) + } catch { + return "" + } + } + return path + } + return "" + } + @objc func getFileSize(filePath: String) -> Int64 { do { diff --git a/iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift b/iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift index e07fa4eb7d..3d0790be7d 100644 --- a/iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift +++ b/iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift @@ -185,7 +185,7 @@ class NCViewerRichdocument: UIViewController, WKNavigationDelegate, WKScriptMess guard let type = values["Type"] as? String else { return } guard let urlString = values["URL"] as? String else { return } guard let url = URL(string: urlString) else { return } - let fileNameLocalPath = CCUtility.getDirectoryUserData() + "/" + (metadata.fileName as NSString).deletingPathExtension + let fileNameLocalPath = NCUtilityFileSystem.shared.directoryUserData + "/" + (metadata.fileName as NSString).deletingPathExtension if type == "slideshow" { @@ -221,7 +221,7 @@ class NCViewerRichdocument: UIViewController, WKNavigationDelegate, WKScriptMess if let disposition = allHeaderFields["Content-Disposition"] as? String { let components = disposition.components(separatedBy: "filename=") if let filename = components.last?.replacingOccurrences(of: "\"", with: "") { - item = CCUtility.getDirectoryUserData() + "/" + filename + item = NCUtilityFileSystem.shared.directoryUserData + "/" + filename _ = NCUtilityFileSystem.shared.moveFile(atPath: fileNameLocalPath, toPath: item) } } From 192454bef324405afdd9177cf2fef4cb564d72d9 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Wed, 25 Oct 2023 11:26:36 +0200 Subject: [PATCH 60/90] NCUtilityFileSystem.shared.directoryProviderStorage --- .../FileProviderExtension.swift | 2 +- iOSClient/AppDelegate.swift | 4 +--- iOSClient/Media/NCMediaCache.swift | 4 ++-- iOSClient/Settings/CCAdvanced.m | 2 +- iOSClient/Utility/CCUtility.h | 1 - iOSClient/Utility/NCUtilityFileSystem.swift | 15 +++++++++++++++ 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/File Provider Extension/FileProviderExtension.swift b/File Provider Extension/FileProviderExtension.swift index de89bb0598..9a87191bb9 100644 --- a/File Provider Extension/FileProviderExtension.swift +++ b/File Provider Extension/FileProviderExtension.swift @@ -60,7 +60,7 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate { super.init() // Create directory File Provider Storage - CCUtility.getDirectoryProviderStorage() + _ = NCUtilityFileSystem.shared.directoryProviderStorage // Configure URLSession _ = NCNetworking.shared.sessionManagerBackgroundExtension } diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index 4e713d1379..eaa7fd73fd 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -236,9 +236,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD // Clear older files let days = NCKeychain().cleanUpDay - if let directory = CCUtility.getDirectoryProviderStorage() { - NCUtilityFileSystem.shared.cleanUp(directory: directory, days: TimeInterval(days)) - } + NCUtilityFileSystem.shared.cleanUp(directory: NCUtilityFileSystem.shared.directoryProviderStorage, days: TimeInterval(days)) NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterApplicationWillResignActive) } diff --git a/iOSClient/Media/NCMediaCache.swift b/iOSClient/Media/NCMediaCache.swift index 8996fa7205..6e067acc7d 100644 --- a/iOSClient/Media/NCMediaCache.swift +++ b/iOSClient/Media/NCMediaCache.swift @@ -48,7 +48,7 @@ import NextcloudKit metadatas.removeAll() getMetadatasMedia(account: account) - guard !metadatas.isEmpty, let directory = CCUtility.getDirectoryProviderStorage() else { return } + guard !metadatas.isEmpty else { return } let ext = ".preview.ico" let manager = FileManager.default let resourceKeys = Set([.nameKey, .pathKey, .fileSizeKey, .creationDateKey]) @@ -64,7 +64,7 @@ import NextcloudKit 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) { let fileName = fileURL.lastPathComponent let ocId = fileURL.deletingLastPathComponent().lastPathComponent diff --git a/iOSClient/Settings/CCAdvanced.m b/iOSClient/Settings/CCAdvanced.m index a63268e19a..03a9df1781 100755 --- a/iOSClient/Settings/CCAdvanced.m +++ b/iOSClient/Settings/CCAdvanced.m @@ -430,7 +430,7 @@ - (void)clearAllCacheRequest:(XLFormRowDescriptor *)sender - (void)calculateSize { 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]; sectionSize.footerTitle = [NSString stringWithFormat:@"%@. (%@ %@)", NSLocalizedString(@"_clear_cache_footer_", nil), NSLocalizedString(@"_used_space_", nil), [CCUtility transformedSize:totalSize]]; diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 376a88611d..e27cde71fb 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -49,7 +49,6 @@ + (void)createDirectoryStandard; -+ (NSString *)getDirectoryProviderStorage; + (NSString *)getDirectoryProviderStorageOcId:(NSString *)ocId; + (NSString *)getDirectoryProviderStorageOcId:(NSString *)ocId fileNameView:(NSString *)fileNameView; + (NSString *)getDirectoryProviderStorageIconOcId:(NSString *)ocId etag:(NSString *)etag; diff --git a/iOSClient/Utility/NCUtilityFileSystem.swift b/iOSClient/Utility/NCUtilityFileSystem.swift index 5a41db4977..ece746733c 100644 --- a/iOSClient/Utility/NCUtilityFileSystem.swift +++ b/iOSClient/Utility/NCUtilityFileSystem.swift @@ -70,6 +70,21 @@ class NCUtilityFileSystem: NSObject { return "" } + @objc var directoryProviderStorage: String { + if let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups) { + let path = directoryGroup.appendingPathComponent(NCGlobal.shared.directoryProviderStorage).path + if !fileManager.fileExists(atPath: path) { + do { + try fileManager.createDirectory(atPath: path, withIntermediateDirectories: true) + } catch { + return "" + } + } + return path + } + return "" + } + @objc func getFileSize(filePath: String) -> Int64 { do { From 16331273726f3a3afdcbabc9fe3c56fe39da0b7c Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Wed, 25 Oct 2023 11:42:20 +0200 Subject: [PATCH 61/90] getDirectoryProviderStorageOcId --- .../FileProviderExtension+Actions.swift | 2 +- .../FileProviderExtension.swift | 6 ++-- .../FileProviderUtility.swift | 2 +- Share/NCShareExtension.swift | 3 +- iOSClient/AppDelegate.swift | 2 +- iOSClient/Main/NCActionCenter.swift | 2 +- .../E2EE/NCNetworkingE2EERename.swift | 4 +-- .../E2EE/NCNetworkingE2EEUpload.swift | 6 ++-- iOSClient/Networking/NCNetworking.swift | 36 +++++++++---------- .../NCNetworkingProcessUpload.swift | 3 +- iOSClient/Utility/CCUtility.h | 1 - iOSClient/Utility/NCUtilityFileSystem.swift | 15 +++++++- 12 files changed, 45 insertions(+), 37 deletions(-) diff --git a/File Provider Extension/FileProviderExtension+Actions.swift b/File Provider Extension/FileProviderExtension+Actions.swift index 548acc40fa..58dc51a06b 100644 --- a/File Provider Extension/FileProviderExtension+Actions.swift +++ b/File Provider Extension/FileProviderExtension+Actions.swift @@ -92,7 +92,7 @@ extension FileProviderExtension { if error == .success { // || error == kOCErrorServerPathNotFound { - let fileNamePath = CCUtility.getDirectoryProviderStorageOcId(itemIdentifier.rawValue)! + let fileNamePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(itemIdentifier.rawValue) do { try fileProviderUtility.shared.fileManager.removeItem(atPath: fileNamePath) } catch let error { diff --git a/File Provider Extension/FileProviderExtension.swift b/File Provider Extension/FileProviderExtension.swift index 9a87191bb9..8c9694c094 100644 --- a/File Provider Extension/FileProviderExtension.swift +++ b/File Provider Extension/FileProviderExtension.swift @@ -411,13 +411,13 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate { NCManageDatabase.shared.addLocalFile(metadata: metadata) // New file - if ocId != ocIdTemp { + if let ocId, ocId != ocIdTemp { NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", ocIdTemp)) // File system - let atPath = CCUtility.getDirectoryProviderStorageOcId(ocIdTemp) - let toPath = CCUtility.getDirectoryProviderStorageOcId(ocId) + let atPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocIdTemp) + let toPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId) CCUtility.copyFile(atPath: atPath, toPath: toPath) } diff --git a/File Provider Extension/FileProviderUtility.swift b/File Provider Extension/FileProviderUtility.swift index 6ba2c717c6..a0e482559a 100644 --- a/File Provider Extension/FileProviderUtility.swift +++ b/File Provider Extension/FileProviderUtility.swift @@ -53,7 +53,7 @@ class fileProviderUtility: NSObject { let itemIdentifier = getItemIdentifier(metadata: metadata) if metadata.directory { - CCUtility.getDirectoryProviderStorageOcId(itemIdentifier.rawValue) + _ = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(itemIdentifier.rawValue) } else { CCUtility.getDirectoryProviderStorageOcId(itemIdentifier.rawValue, fileNameView: metadata.fileNameView) } diff --git a/Share/NCShareExtension.swift b/Share/NCShareExtension.swift index 1d298a1502..2811145249 100644 --- a/Share/NCShareExtension.swift +++ b/Share/NCShareExtension.swift @@ -356,9 +356,8 @@ extension NCShareExtension { self.hud.progress = Float(fractionCompleted) } completion: { error in if error != .success { - let path = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId)! NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) - NCUtilityFileSystem.shared.deleteFile(filePath: path) + NCUtilityFileSystem.shared.deleteFile(filePath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) self.uploadErrors.append(metadata) } self.counterUploaded += 1 diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index eaa7fd73fd..34c824ecf9 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -613,7 +613,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD let results = NCManageDatabase.shared.getTableLocalFiles(predicate: NSPredicate(format: "account == %@", account), sorted: "ocId", ascending: false) for result in results { - CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(result.ocId)) + CCUtility.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(result.ocId)) } NCManageDatabase.shared.clearDatabase(account: account, removeAccount: true) diff --git a/iOSClient/Main/NCActionCenter.swift b/iOSClient/Main/NCActionCenter.swift index ce196437ac..cb6f36ca97 100644 --- a/iOSClient/Main/NCActionCenter.swift +++ b/iOSClient/Main/NCActionCenter.swift @@ -57,7 +57,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec // File do not exists on server, remove in local if error.errorCode == NCGlobal.shared.errorResourceNotFound || error.errorCode == NCGlobal.shared.errorBadServerResponse { do { - try FileManager.default.removeItem(atPath: CCUtility.getDirectoryProviderStorageOcId(ocId)) + try FileManager.default.removeItem(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId)) } catch { } NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", ocId)) NCManageDatabase.shared.deleteLocalFile(predicate: NSPredicate(format: "ocId == %@", ocId)) diff --git a/iOSClient/Networking/E2EE/NCNetworkingE2EERename.swift b/iOSClient/Networking/E2EE/NCNetworkingE2EERename.swift index 718c433bcb..d63ad47d36 100644 --- a/iOSClient/Networking/E2EE/NCNetworkingE2EERename.swift +++ b/iOSClient/Networking/E2EE/NCNetworkingE2EERename.swift @@ -77,8 +77,8 @@ class NCNetworkingE2EERename: NSObject { // 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 { try FileManager.default.moveItem(atPath: atPath, toPath: toPath) } catch { } diff --git a/iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift b/iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift index b24fe3a036..d0110955a2 100644 --- a/iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift +++ b/iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift @@ -66,7 +66,7 @@ class NCNetworkingE2EEUpload: NSObject { // 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: "")) } 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 { - CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId)) + CCUtility.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(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]) } else if resultsSendFile.error == .success, let ocId = resultsSendFile.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.etag = resultsSendFile.etag ?? "" diff --git a/iOSClient/Networking/NCNetworking.swift b/iOSClient/Networking/NCNetworking.swift index 0d91ccdf53..a8e4960af5 100644 --- a/iOSClient/Networking/NCNetworking.swift +++ b/iOSClient/Networking/NCNetworking.swift @@ -479,7 +479,7 @@ class NCNetworking: NSObject, NKCommonDelegate { progressHandler: @escaping (_ totalBytesExpected: Int64, _ totalBytes: Int64, _ fractionCompleted: Double) -> Void = { _, _, _ in }, completion: @escaping (_ account: String, _ file: NKFile?, _ afError: AFError?, _ error: NKError) -> Void) { - let directory = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId)! + let directory = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId) let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)! let chunkFolder = NCManageDatabase.shared.getChunkFolder(account: metadata.account, ocId: metadata.ocId) let filesChunk = NCManageDatabase.shared.getChunks(account: metadata.account, ocId: metadata.ocId) @@ -656,10 +656,10 @@ class NCNetworking: NSObject, NKCommonDelegate { NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", ocIdTemp)) 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) } else { - NCUtilityFileSystem.shared.deleteFile(filePath: CCUtility.getDirectoryProviderStorageOcId(ocIdTemp)) + NCUtilityFileSystem.shared.deleteFile(filePath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocIdTemp)) } 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 { - CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId)) + CCUtility.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(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]) @@ -679,13 +679,13 @@ class NCNetworking: NSObject, NKCommonDelegate { 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) 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) 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 - CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId)) + CCUtility.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(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]) })) @@ -787,12 +787,12 @@ class NCNetworking: NSObject, NKCommonDelegate { // DOWNLOAD for metadata in metadatasDownload { - CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId)) + CCUtility.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, session: "", sessionError: "", sessionSelector: "", sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusNormal, errorCode: 0) } // UPLOAD for metadata in metadatasUpload { - CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId)) + CCUtility.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) } @@ -800,7 +800,7 @@ class NCNetworking: NSObject, NKCommonDelegate { // BACKGROUND for metadata in metadatasUploadBackground { - CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId)) + CCUtility.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) } @@ -820,7 +820,7 @@ class NCNetworking: NSObject, NKCommonDelegate { func cancel(metadata: tableMetadata) async { let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)! - CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId)) + CCUtility.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) // No session found if metadata.session.isEmpty { @@ -1318,11 +1318,11 @@ class NCNetworking: NSObject, NKCommonDelegate { NCManageDatabase.shared.deleteVideo(metadata: metadata) NCManageDatabase.shared.deleteLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) - NCUtilityFileSystem.shared.deleteFile(filePath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId)) + NCUtilityFileSystem.shared.deleteFile(filePath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) if let metadataLivePhoto = NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata) { NCManageDatabase.shared.deleteLocalFile(predicate: NSPredicate(format: "ocId == %@", metadataLivePhoto.ocId)) - NCUtilityFileSystem.shared.deleteFile(filePath: CCUtility.getDirectoryProviderStorageOcId(metadataLivePhoto.ocId)) + NCUtilityFileSystem.shared.deleteFile(filePath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadataLivePhoto.ocId)) } } return NKError() @@ -1375,7 +1375,7 @@ class NCNetworking: NSObject, NKCommonDelegate { if result.error == .success || result.error.errorCode == NCGlobal.shared.errorResourceNotFound { do { - try FileManager.default.removeItem(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId)) + try FileManager.default.removeItem(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) } catch { } NCManageDatabase.shared.deleteVideo(metadata: metadata) @@ -1523,17 +1523,15 @@ class NCNetworking: NSObject, NKCommonDelegate { if ext != extNew { - if let path = CCUtility.getDirectoryProviderStorageOcId(ocId) { - NCUtilityFileSystem.shared.deleteFile(filePath: path) - } + NCUtilityFileSystem.shared.deleteFile(filePath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId)) NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSourceNetworkForced) } else { NCManageDatabase.shared.setLocalFile(ocId: ocId, fileName: fileNameNew, etag: nil) // 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 { try FileManager.default.moveItem(atPath: atPath, toPath: toPath) } catch { } diff --git a/iOSClient/Networking/NCNetworkingProcessUpload.swift b/iOSClient/Networking/NCNetworkingProcessUpload.swift index 511a9889ab..b25e91b2ce 100644 --- a/iOSClient/Networking/NCNetworkingProcessUpload.swift +++ b/iOSClient/Networking/NCNetworkingProcessUpload.swift @@ -271,9 +271,8 @@ class NCNetworkingProcessUpload: NSObject { // remove leaning upload share extension let metadatasUploadShareExtension = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "session == %@ AND sessionSelector == %@", NextcloudKit.shared.nkCommonInstance.sessionIdentifierUpload, NCGlobal.shared.selectorUploadFileShareExtension)) for metadata in metadatasUploadShareExtension { - let path = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId)! NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) - NCUtilityFileSystem.shared.deleteFile(filePath: path) + NCUtilityFileSystem.shared.deleteFile(filePath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) } // verify metadataStatusInUpload (BACKGROUND) diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index e27cde71fb..d6f9c016d7 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -49,7 +49,6 @@ + (void)createDirectoryStandard; -+ (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; diff --git a/iOSClient/Utility/NCUtilityFileSystem.swift b/iOSClient/Utility/NCUtilityFileSystem.swift index ece746733c..d02073bd91 100644 --- a/iOSClient/Utility/NCUtilityFileSystem.swift +++ b/iOSClient/Utility/NCUtilityFileSystem.swift @@ -85,6 +85,19 @@ class NCUtilityFileSystem: NSObject { return "" } + @objc func getDirectoryProviderStorageOcId(_ ocId: String) -> String { + + let path = directoryProviderStorage + "/" + ocId + if !fileManager.fileExists(atPath: path) { + do { + try fileManager.createDirectory(atPath: path, withIntermediateDirectories: true) + } catch { + return "" + } + } + return path + } + @objc func getFileSize(filePath: String) -> Int64 { do { @@ -316,7 +329,7 @@ class NCUtilityFileSystem: NSObject { if let directories = NCManageDatabase.shared.getTablesDirectory(predicate: NSPredicate(format: "offline == true"), sorted: "serverUrl", ascending: true) { for directory: tableDirectory in directories { - offlineDir.append(CCUtility.getDirectoryProviderStorageOcId(directory.ocId)) + offlineDir.append(NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(directory.ocId)) } } From 564cc3996706636ef34771aa31b05a12b1bcec8a Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Wed, 25 Oct 2023 11:57:08 +0200 Subject: [PATCH 62/90] getDirectoryProviderStorageOcId --- .../FileProviderExtension+Actions.swift | 2 +- .../FileProviderExtension.swift | 12 +++--- .../FileProviderUtility.swift | 2 +- Share/NCShareExtension.swift | 2 +- .../NCCreateFormUploadConflict.swift | 10 ++--- .../NCCreateFormUploadVoiceNote.swift | 2 +- .../Main/Create cloud/NCUploadAssets.swift | 2 +- iOSClient/Main/NCActionCenter.swift | 38 +++++++++---------- iOSClient/Main/NCPickerViewController.swift | 2 +- iOSClient/Menu/NCOperationSaveLivePhoto.swift | 4 +- .../Networking/E2EE/NCEndToEndEncryption.m | 2 +- .../E2EE/NCNetworkingE2EEUpload.swift | 2 +- iOSClient/Networking/NCNetworking.swift | 12 +++--- .../NCNetworkingProcessUpload.swift | 2 +- .../Scan document/NCUploadScanDocument.swift | 2 +- iOSClient/Utility/CCUtility.h | 1 - iOSClient/Utility/NCCameraRoll.swift | 6 +-- iOSClient/Utility/NCUtility+Exif.swift | 2 +- iOSClient/Utility/NCUtility+Image.swift | 2 +- iOSClient/Utility/NCUtility.swift | 4 +- iOSClient/Utility/NCUtilityFileSystem.swift | 15 +++++++- iOSClient/Viewer/NCViewer.swift | 4 +- .../NCPlayer/NCPlayerToolBar.swift | 4 +- .../Viewer/NCViewerMedia/NCViewerMedia.swift | 4 +- .../NCViewerMedia/NCViewerMediaPage.swift | 4 +- .../Viewer/NCViewerPDF/NCViewerPDF.swift | 2 +- .../Viewer/NCViewerProviderContextMenu.swift | 4 +- .../NCViewerQuickLook/NCViewerQuickLook.swift | 4 +- 28 files changed, 81 insertions(+), 71 deletions(-) diff --git a/File Provider Extension/FileProviderExtension+Actions.swift b/File Provider Extension/FileProviderExtension+Actions.swift index 58dc51a06b..7c5cef3297 100644 --- a/File Provider Extension/FileProviderExtension+Actions.swift +++ b/File Provider Extension/FileProviderExtension+Actions.swift @@ -201,7 +201,7 @@ extension FileProviderExtension { let itemIdentifier = fileProviderUtility.shared.getItemIdentifier(metadata: metadata) // 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)) diff --git a/File Provider Extension/FileProviderExtension.swift b/File Provider Extension/FileProviderExtension.swift index 8c9694c094..8e9a16bd51 100644 --- a/File Provider Extension/FileProviderExtension.swift +++ b/File Provider Extension/FileProviderExtension.swift @@ -209,7 +209,7 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate { } 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 NCManageDatabase.shared.setMetadataStatus(ocId: metadata.ocId, status: NCGlobal.shared.metadataStatusDownloading) @@ -274,8 +274,8 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate { // Temp ocId ? if outstandingOcIdTemp[ocId] != nil && outstandingOcIdTemp[ocId] != ocId { ocId = outstandingOcIdTemp[ocId]! - let atPath = CCUtility.getDirectoryProviderStorageOcId(itemIdentifier.rawValue, fileNameView: fileName) - let toPath = CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileName) + let atPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(itemIdentifier.rawValue, fileNameView: fileName) + let toPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId, fileNameView: fileName) CCUtility.copyFile(atPath: atPath, toPath: toPath) } guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) else { return } @@ -348,7 +348,7 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate { let ocIdTemp = NSUUID().uuidString.lowercased() 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() @@ -361,7 +361,7 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate { NCManageDatabase.shared.addMetadata(metadata) 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) { @@ -383,7 +383,7 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate { guard let metadataTemp = NCManageDatabase.shared.getMetadataFromOcId(ocIdTemp) else { return } 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) { self.outstandingSessionTasks.removeValue(forKey: url) } diff --git a/File Provider Extension/FileProviderUtility.swift b/File Provider Extension/FileProviderUtility.swift index a0e482559a..da3b6dc88d 100644 --- a/File Provider Extension/FileProviderUtility.swift +++ b/File Provider Extension/FileProviderUtility.swift @@ -55,7 +55,7 @@ class fileProviderUtility: NSObject { if metadata.directory { _ = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(itemIdentifier.rawValue) } else { - CCUtility.getDirectoryProviderStorageOcId(itemIdentifier.rawValue, fileNameView: metadata.fileNameView) + NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(itemIdentifier.rawValue, fileNameView: metadata.fileNameView) } } diff --git a/Share/NCShareExtension.swift b/Share/NCShareExtension.swift index 2811145249..48c37cb779 100644 --- a/Share/NCShareExtension.swift +++ b/Share/NCShareExtension.swift @@ -295,7 +295,7 @@ extension NCShareExtension { var conflicts: [tableMetadata] = [] for fileName in filesName { 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 } let metadata = NCManageDatabase.shared.createMetadata( account: activeAccount.account, user: activeAccount.user, userId: activeAccount.userId, diff --git a/iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift b/iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift index 92c61d6e6f..07cea701f3 100644 --- a/iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift +++ b/iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift @@ -248,7 +248,7 @@ class NCCreateFormUploadConflict: UIViewController { if fileNameExtension == "heic" && NCKeychain().formatCompatibility { 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) metadata.ocId = UUID().uuidString @@ -257,7 +257,7 @@ class NCCreateFormUploadConflict: UIViewController { // This is not an asset - [file] if metadata.assetLocalIdentifier.isEmpty || metadata.isExtractFile { - let newPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: newFileName) + let newPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: newFileName) CCUtility.moveFile(atPath: oldPath, toPath: newPath) } @@ -325,9 +325,9 @@ extension NCCreateFormUploadConflict: UITableViewDataSource { 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" { + } 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) { cell.imageAlreadyExistingFile.image = image } else { @@ -356,7 +356,7 @@ extension NCCreateFormUploadConflict: UITableViewDataSource { } else { 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 { let result = PHAsset.fetchAssets(withLocalIdentifiers: [metadataNewFile.assetLocalIdentifier], options: nil) diff --git a/iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift b/iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift index 5e0a23e980..635ae44e4c 100644 --- a/iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift +++ b/iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift @@ -256,7 +256,7 @@ class NCCreateFormUploadVoiceNote: XLFormViewController, NCSelectDelegate, AVAud func dismissAndUpload(_ metadata: tableMetadata) { - CCUtility.copyFile(atPath: self.fileNamePath, toPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)) + CCUtility.copyFile(atPath: self.fileNamePath, toPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)) NCNetworkingProcessUpload.shared.createProcessUploads(metadatas: [metadata], completion: { _ in }) diff --git a/iOSClient/Main/Create cloud/NCUploadAssets.swift b/iOSClient/Main/Create cloud/NCUploadAssets.swift index dbc7e2c12d..63b749dc1a 100644 --- a/iOSClient/Main/Create cloud/NCUploadAssets.swift +++ b/iOSClient/Main/Create cloud/NCUploadAssets.swift @@ -271,7 +271,7 @@ struct UploadAssetsView: View { metadata.fileName = 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 { try data.write(to: URL(fileURLWithPath: fileNamePath)) metadata.isExtractFile = true diff --git a/iOSClient/Main/NCActionCenter.swift b/iOSClient/Main/NCActionCenter.swift index cb6f36ca97..3d93d08016 100644 --- a/iOSClient/Main/NCActionCenter.swift +++ b/iOSClient/Main/NCActionCenter.swift @@ -70,7 +70,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec switch selector { 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 viewerQuickLook = NCViewerQuickLook(with: URL(fileURLWithPath: fileNameTemp), isEditingEnabled: true, metadata: metadata) if let image = UIImage(contentsOfFile: fileNamePath) { @@ -159,17 +159,15 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec var downloadRequest: DownloadRequest? 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) 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 { 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, 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?.presentOptionsMenu(from: mainTabBar.menuRect, in: mainTabBar, animated: true) @@ -310,7 +308,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec var downloadMetadata: [(tableMetadata, URL)] = [] for metadata in metadatas { - let fileURL = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)) + let fileURL = URL(fileURLWithPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)) if CCUtility.fileProviderStorageExists(metadata) { items.append(fileURL) } else { @@ -346,7 +344,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec func saveAsScan(metadata: tableMetadata) { 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 fileNamePathDestination = CCUtility.getDirectoryScan() + "/" + fileNameDestination @@ -364,7 +362,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec 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 printInfo = UIPrintInfo(dictionary: nil) @@ -403,7 +401,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec func saveAlbum(metadata: tableMetadata) { 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 guard hasPermission else { @@ -503,7 +501,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec } completionHandler: { account, ocId, etag, _, _, _, afError, error in NCNetworking.shared.uploadRequest.removeValue(forKey: fileNameLocalPath) 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) NCManageDatabase.shared.addLocalFile(account: account, etag: etag!, ocId: ocId!, fileName: fileName) NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSourceNetworkForced) @@ -526,7 +524,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec let fileName = results.name + "_" + NCKeychain().incrementalNumber + "." + results.ext let serverUrlFileName = serverUrl + "/" + fileName 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 } processor.execute { completion in uploadPastePasteboard(fileName: fileName, serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, serverUrl: serverUrl, completion: completion) @@ -699,7 +697,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec fileprivate extension tableMetadata { func toPasteBoardItem() -> [String: Any]? { // Get Data - let fileUrl = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView)) + let fileUrl = URL(fileURLWithPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView)) guard CCUtility.fileProviderStorageExists(self), let data = try? Data(contentsOf: fileUrl), let unmanagedFileUTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension as CFString, nil) diff --git a/iOSClient/Main/NCPickerViewController.swift b/iOSClient/Main/NCPickerViewController.swift index a2676a24e7..7b5361ee59 100644 --- a/iOSClient/Main/NCPickerViewController.swift +++ b/iOSClient/Main/NCPickerViewController.swift @@ -162,7 +162,7 @@ class NCDocumentPickerViewController: NSObject, UIDocumentPickerDelegate { let ocId = NSUUID().uuidString let fileName = urlIn.lastPathComponent - let toPath = CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileName)! + let toPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId, fileNameView: fileName) let urlOut = URL(fileURLWithPath: toPath) guard self.copySecurityScopedResource(url: urlIn, urlOut: urlOut) != nil else { continue } diff --git a/iOSClient/Menu/NCOperationSaveLivePhoto.swift b/iOSClient/Menu/NCOperationSaveLivePhoto.swift index 6bdda0015c..1f1cae293c 100644 --- a/iOSClient/Menu/NCOperationSaveLivePhoto.swift +++ b/iOSClient/Menu/NCOperationSaveLivePhoto.swift @@ -85,8 +85,8 @@ class NCOperationSaveLivePhoto: ConcurrentOperation { 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 { self.hud.textLabel.text = NSLocalizedString("_livephoto_save_", comment: "") diff --git a/iOSClient/Networking/E2EE/NCEndToEndEncryption.m b/iOSClient/Networking/E2EE/NCEndToEndEncryption.m index 6fb55970b0..bfaa52e514 100644 --- a/iOSClient/Networking/E2EE/NCEndToEndEncryption.m +++ b/iOSClient/Networking/E2EE/NCEndToEndEncryption.m @@ -564,7 +564,7 @@ - (BOOL)decryptFile:(NSString *)fileName fileNameView:(NSString *)fileNameView o NSData *initializationVectorData = [[NSData alloc] initWithBase64EncodedString:initializationVector 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]; } // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift b/iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift index d0110955a2..4da9dec712 100644 --- a/iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift +++ b/iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift @@ -212,7 +212,7 @@ class NCNetworkingE2EEUpload: NSObject { } 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 NCNetworking.shared.uploadFile(metadata: metadata, fileNameLocalPath: fileNameLocalPath, withUploadComplete: false, addCustomHeaders: ["e2e-token": e2eToken]) { #if !EXTENSION diff --git a/iOSClient/Networking/NCNetworking.swift b/iOSClient/Networking/NCNetworking.swift index a8e4960af5..b7a69563ef 100644 --- a/iOSClient/Networking/NCNetworking.swift +++ b/iOSClient/Networking/NCNetworking.swift @@ -299,7 +299,7 @@ class NCNetworking: NSObject, NKCommonDelegate { } 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 { NCManageDatabase.shared.addMetadata(tableMetadata.init(value: metadata)) @@ -412,7 +412,7 @@ class NCNetworking: NSObject, NKCommonDelegate { completion(error) } } 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 completion(error) } @@ -480,7 +480,7 @@ class NCNetworking: NSObject, NKCommonDelegate { completion: @escaping (_ account: String, _ file: NKFile?, _ afError: AFError?, _ error: NKError) -> Void) { let directory = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId) - let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)! + let fileNameLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) let chunkFolder = NCManageDatabase.shared.getChunkFolder(account: metadata.account, ocId: metadata.ocId) let filesChunk = NCManageDatabase.shared.getChunks(account: metadata.account, ocId: metadata.ocId) var uploadTask: URLSessionTask? @@ -582,7 +582,7 @@ class NCNetworking: NSObject, NKCommonDelegate { var session: URLSession? let metadata = tableMetadata.init(value: metadata) 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 { session = sessionManagerBackground @@ -819,7 +819,7 @@ class NCNetworking: NSObject, NKCommonDelegate { func cancel(metadata: tableMetadata) async { - let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)! + let fileNameLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) CCUtility.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) // No session found @@ -1623,7 +1623,7 @@ class NCNetworking: NSObject, NKCommonDelegate { completition(URL(string: metadata.url), true, .success) } } else if CCUtility.fileProviderStorageExists(metadata) { - completition(URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)), false, .success) + completition(URL(fileURLWithPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)), false, .success) } else { NextcloudKit.shared.getDirectDownload(fileId: metadata.fileId) { _, url, _, error in if error == .success && url != nil { diff --git a/iOSClient/Networking/NCNetworkingProcessUpload.swift b/iOSClient/Networking/NCNetworkingProcessUpload.swift index b25e91b2ce..4a1de619b2 100644 --- a/iOSClient/Networking/NCNetworkingProcessUpload.swift +++ b/iOSClient/Networking/NCNetworkingProcessUpload.swift @@ -324,7 +324,7 @@ class NCNetworkingProcessUpload: NSObject { NCNetworking.shared.transferInForegorund = nil } 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 { NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, session: nil, sessionError: "", sessionSelector: nil, sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusWaitUpload, errorCode: nil) } diff --git a/iOSClient/Scan document/NCUploadScanDocument.swift b/iOSClient/Scan document/NCUploadScanDocument.swift index 9493d10046..198dd19ce9 100644 --- a/iOSClient/Scan document/NCUploadScanDocument.swift +++ b/iOSClient/Scan document/NCUploadScanDocument.swift @@ -99,7 +99,7 @@ class NCUploadScanDocument: ObservableObject { func createPDF(metadata: tableMetadata, completion: @escaping (_ error: Bool) -> Void) { 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() if self.password.isEmpty { diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index d6f9c016d7..fe867ced47 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -49,7 +49,6 @@ + (void)createDirectoryStandard; -+ (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; diff --git a/iOSClient/Utility/NCCameraRoll.swift b/iOSClient/Utility/NCCameraRoll.swift index c769b4860b..b7a8494136 100644 --- a/iOSClient/Utility/NCCameraRoll.swift +++ b/iOSClient/Utility/NCCameraRoll.swift @@ -38,7 +38,7 @@ class NCCameraRoll: NSObject { guard !metadata.isExtractFile else { return completition([metadataSource]) } guard !metadataSource.assetLocalIdentifier.isEmpty else { - let filePath = CCUtility.getDirectoryProviderStorageOcId(metadataSource.ocId, fileNameView: metadataSource.fileName)! + let filePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadataSource.ocId, fileNameView: metadataSource.fileName) metadataSource.size = NCUtilityFileSystem.shared.getFileSize(filePath: filePath) let results = NextcloudKit.shared.nkCommonInstance.getInternalType(fileName: metadataSource.fileNameView, mimeType: metadataSource.contentType, directory: false) metadataSource.contentType = results.mimeType @@ -69,7 +69,7 @@ class NCCameraRoll: NSObject { extractImageVideoFromAssetLocalIdentifier(metadata: metadataSource, modifyMetadataForUpload: true, viewController: viewController, hud: hud) { metadata, fileNamePath, error in if let metadata = metadata, let fileNamePath = fileNamePath, !error { metadatas.append(metadata) - let toPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)! + let toPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) NCUtilityFileSystem.shared.moveFile(atPath: fileNamePath, toPath: toPath) let fetchAssets = PHAsset.fetchAssets(withLocalIdentifiers: [metadataSource.assetLocalIdentifier], options: nil) // swiftlint:disable empty_count @@ -254,7 +254,7 @@ class NCCameraRoll: NSObject { options.isNetworkAccessAllowed = true let ocId = NSUUID().uuidString let fileName = (metadata.fileName as NSString).deletingPathExtension + ".mov" - let fileNamePath = CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileName)! + let fileNamePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId, fileNameView: fileName) var chunkSize = NCGlobal.shared.chunkSizeMBCellular if NCNetworking.shared.networkReachability == NKCommon.TypeReachability.reachableEthernetOrWiFi { chunkSize = NCGlobal.shared.chunkSizeMBEthernetOrWiFi diff --git a/iOSClient/Utility/NCUtility+Exif.swift b/iOSClient/Utility/NCUtility+Exif.swift index 7d0da52504..fc32c0457d 100644 --- a/iOSClient/Utility/NCUtility+Exif.swift +++ b/iOSClient/Utility/NCUtility+Exif.swift @@ -76,7 +76,7 @@ extension NCUtility { print("Storage exists or file is not an image") } - let url = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)) + let url = URL(fileURLWithPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)) guard let originalSource = CGImageSourceCreateWithURL(url as CFURL, nil), let imageProperties = CGImageSourceCopyPropertiesAtIndex(originalSource, 0, nil) as NSDictionary? else { diff --git a/iOSClient/Utility/NCUtility+Image.swift b/iOSClient/Utility/NCUtility+Image.swift index 1443ad7b2a..2506caa590 100644 --- a/iOSClient/Utility/NCUtility+Image.swift +++ b/iOSClient/Utility/NCUtility+Image.swift @@ -58,7 +58,7 @@ extension NCUtility { if CCUtility.fileProviderStorageExists(metadata) && metadata.isImage { let previewPath = CCUtility.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)! - let imagePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)! + let imagePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) if ext == "GIF" { if !FileManager().fileExists(atPath: previewPath) { diff --git a/iOSClient/Utility/NCUtility.swift b/iOSClient/Utility/NCUtility.swift index 8db357f402..c6d5d00885 100644 --- a/iOSClient/Utility/NCUtility.swift +++ b/iOSClient/Utility/NCUtility.swift @@ -373,7 +373,7 @@ class NCUtility: NSObject { var originalImage, scaleImagePreview, scaleImageIcon: UIImage? - let fileNamePath = CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView)! + let fileNamePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView) let fileNamePathPreview = CCUtility.getDirectoryProviderStoragePreviewOcId(ocId, etag: etag)! let fileNamePathIcon = CCUtility.getDirectoryProviderStorageIconOcId(ocId, etag: etag)! @@ -676,7 +676,7 @@ class NCUtility: NSObject { func createFilePreviewImage(ocId: String, etag: String, fileNameView: String, classFile: String, status: Int, createPreviewMedia: Bool) -> UIImage? { var imagePreview: UIImage? - let filePath = CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView)! + let filePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView) let iconImagePath = CCUtility.getDirectoryProviderStorageIconOcId(ocId, etag: etag)! if FileManager().fileExists(atPath: iconImagePath) { diff --git a/iOSClient/Utility/NCUtilityFileSystem.swift b/iOSClient/Utility/NCUtilityFileSystem.swift index d02073bd91..4e98f51eb8 100644 --- a/iOSClient/Utility/NCUtilityFileSystem.swift +++ b/iOSClient/Utility/NCUtilityFileSystem.swift @@ -98,6 +98,19 @@ class NCUtilityFileSystem: NSObject { return path } + @objc func getDirectoryProviderStorageOcId(_ ocId: String, fileNameView: String) -> String { + + let path = directoryProviderStorage + "/" + ocId + "/" + fileNameView + if !fileManager.fileExists(atPath: path) { + do { + try fileManager.createDirectory(atPath: path, withIntermediateDirectories: true) + } catch { + return "" + } + } + return path + } + @objc func getFileSize(filePath: String) -> Int64 { do { @@ -335,7 +348,7 @@ class NCUtilityFileSystem: NSObject { let files = NCManageDatabase.shared.getTableLocalFiles(predicate: NSPredicate(format: "offline == true"), sorted: "fileName", ascending: true) for file: tableLocalFile in files { - offlineFiles.append(CCUtility.getDirectoryProviderStorageOcId(file.ocId, fileNameView: file.fileName)) + offlineFiles.append(NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(file.ocId, fileNameView: file.fileName)) } func meetsRequirement(date: Date) -> Bool { diff --git a/iOSClient/Viewer/NCViewer.swift b/iOSClient/Viewer/NCViewer.swift index 7c6de3796f..ffba4b4794 100644 --- a/iOSClient/Viewer/NCViewer.swift +++ b/iOSClient/Viewer/NCViewer.swift @@ -225,10 +225,10 @@ class NCViewer: NSObject { } // QLPreview - let item = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)) + let item = URL(fileURLWithPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)) if QLPreviewController.canPreview(item as QLPreviewItem) { let fileNamePath = NSTemporaryDirectory() + metadata.fileNameView - CCUtility.copyFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView), toPath: fileNamePath) + CCUtility.copyFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView), toPath: fileNamePath) let viewerQuickLook = NCViewerQuickLook(with: URL(fileURLWithPath: fileNamePath), isEditingEnabled: false, metadata: metadata) viewController.present(viewerQuickLook, animated: true) } else { diff --git a/iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayerToolBar.swift b/iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayerToolBar.swift index 2c8bdfac1a..a4cfccb1e8 100644 --- a/iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayerToolBar.swift +++ b/iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayerToolBar.swift @@ -463,7 +463,7 @@ extension NCPlayerToolBar: NCSelectDelegate { if let metadata = metadata, let viewerMediaPage = viewerMediaPage { 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 CCUtility.fileProviderStorageExists(metadata) { addPlaybackSlave(type: type, metadata: metadata) @@ -503,7 +503,7 @@ extension NCPlayerToolBar: NCSelectDelegate { func addPlaybackSlave(type: String, metadata: tableMetadata) { // swiftlint:enable inclusive_language - let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)! + let fileNameLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) if type == "subtitle" { self.ncplayer?.player.addPlaybackSlave(URL(fileURLWithPath: fileNameLocalPath), type: .subtitle, enforce: true) diff --git a/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift b/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift index c70ddcc042..8bb4f95dd0 100644 --- a/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift +++ b/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift @@ -186,7 +186,7 @@ class NCViewerMedia: UIViewController { if error == .success { hud.dismiss() if CCUtility.fileProviderStorageExists(self.metadata) { - let url = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(self.metadata.ocId, fileNameView: self.metadata.fileNameView)) + let url = URL(fileURLWithPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(self.metadata.ocId, fileNameView: self.metadata.fileNameView)) ncplayer.openAVPlayer(url: url, autoplay: autoplay) } } else { @@ -330,7 +330,7 @@ class NCViewerMedia: UIViewController { if CCUtility.fileProviderStorageExists(metadata) && metadata.isImage { let previewPath = CCUtility.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)! - let imagePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)! + let imagePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) if ext == "GIF" { if !FileManager().fileExists(atPath: previewPath) { diff --git a/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift b/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift index 825c518477..dfe72cb33d 100644 --- a/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift +++ b/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift @@ -305,7 +305,7 @@ class NCViewerMediaPage: UIViewController { metadata.isAudioOrVideo, CCUtility.fileProviderStorageExists(metadata), let ncplayer = currentViewController.ncplayer { - let url = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!) + let url = URL(fileURLWithPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)) if ncplayer.isPlay() { ncplayer.playerPause() DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { @@ -658,7 +658,7 @@ extension NCViewerMediaPage: UIGestureRecognizerDelegate { let fileName = (currentViewController.metadata.fileNameView as NSString).deletingPathExtension + ".mov" if let metadata = NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameView LIKE[c] %@", currentViewController.metadata.account, currentViewController.metadata.serverUrl, fileName)), CCUtility.fileProviderStorageExists(metadata) { AudioServicesPlaySystemSound(1519) // peek feedback - currentViewController.playLivePhoto(filePath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!) + currentViewController.playLivePhoto(filePath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)) } } else if gestureRecognizer.state == .ended { currentViewController.stopLivePhoto() diff --git a/iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift b/iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift index 4c28ceccc9..441a077fe3 100644 --- a/iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift +++ b/iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift @@ -71,7 +71,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate { if let url = self.url { pdfDocument = PDFDocument(url: url) } else if let metadata = self.metadata { - filePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)! + filePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) pdfDocument = PDFDocument(url: URL(fileURLWithPath: filePath)) navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named: "more")!.image(color: .label, size: 25), style: .plain, target: self, action: #selector(self.openMenuMore)) } diff --git a/iOSClient/Viewer/NCViewerProviderContextMenu.swift b/iOSClient/Viewer/NCViewerProviderContextMenu.swift index b2b3bd2187..2729b38d00 100644 --- a/iOSClient/Viewer/NCViewerProviderContextMenu.swift +++ b/iOSClient/Viewer/NCViewerProviderContextMenu.swift @@ -229,12 +229,12 @@ class NCViewerProviderContextMenu: UIViewController { var image: UIImage? - let filePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)! + let filePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) if metadata.contentType == "image/gif" { image = UIImage.animatedImage(withAnimatedGIFURL: URL(fileURLWithPath: filePath)) } else if metadata.contentType == "image/svg+xml" { - let imagePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)! + let imagePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) if let svgImage = SVGKImage(contentsOfFile: imagePath) { svgImage.size = CGSize(width: NCGlobal.shared.sizePreview, height: NCGlobal.shared.sizePreview) image = svgImage.uiImage diff --git a/iOSClient/Viewer/NCViewerQuickLook/NCViewerQuickLook.swift b/iOSClient/Viewer/NCViewerQuickLook/NCViewerQuickLook.swift index 761b0ccaa7..ddb6400faa 100644 --- a/iOSClient/Viewer/NCViewerQuickLook/NCViewerQuickLook.swift +++ b/iOSClient/Viewer/NCViewerQuickLook/NCViewerQuickLook.swift @@ -215,8 +215,8 @@ extension NCViewerQuickLook: QLPreviewControllerDataSource, QLPreviewControllerD metadata.fileNameView = fileName } - guard let fileNamePath = CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: metadata.fileNameView), - NCUtilityFileSystem.shared.copyFile(atPath: url.path, toPath: fileNamePath) else { return } + let fileNamePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId, fileNameView: metadata.fileNameView) + guard NCUtilityFileSystem.shared.copyFile(atPath: url.path, toPath: fileNamePath) else { return } let metadataForUpload = NCManageDatabase.shared.createMetadata( account: metadata.account, From 7f0603e4623fa02486dc25b028ad2f31369c650e Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Wed, 25 Oct 2023 12:05:40 +0200 Subject: [PATCH 63/90] getDirectoryProviderStorageIconOcId --- .../FileProviderExtension+Actions.swift | 2 +- .../FileProviderExtension+Thumbnail.swift | 2 +- Widget/Files/FilesData.swift | 2 +- .../Main/Collection Common/NCCollectionViewCommon.swift | 4 ++-- .../Main/Create cloud/NCCreateFormUploadConflict.swift | 4 ++-- iOSClient/Main/NCActionCenter.swift | 2 +- iOSClient/Media/NCMedia.swift | 6 +++--- iOSClient/Menu/NCTrash+Menu.swift | 2 +- iOSClient/Select/NCSelect.swift | 4 ++-- .../Share/Advanced/NCShareAdvancePermissionHeader.swift | 2 +- iOSClient/Share/NCSharePaging.swift | 4 ++-- iOSClient/Trash/NCTrash+CollectionView.swift | 4 ++-- iOSClient/Trash/NCTrash.swift | 2 +- iOSClient/Utility/CCUtility.h | 1 - iOSClient/Utility/NCUtility.swift | 4 ++-- iOSClient/Utility/NCUtilityFileSystem.swift | 9 +++++++++ iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift | 2 +- 17 files changed, 32 insertions(+), 24 deletions(-) diff --git a/File Provider Extension/FileProviderExtension+Actions.swift b/File Provider Extension/FileProviderExtension+Actions.swift index 7c5cef3297..dcc9f9709e 100644 --- a/File Provider Extension/FileProviderExtension+Actions.swift +++ b/File Provider Extension/FileProviderExtension+Actions.swift @@ -205,7 +205,7 @@ extension FileProviderExtension { _ = fileProviderUtility.shared.moveFile(CCUtility.getDirectoryProviderStoragePreviewOcId(itemIdentifier.rawValue, etag: metadata.etag), toPath: CCUtility.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) } diff --git a/File Provider Extension/FileProviderExtension+Thumbnail.swift b/File Provider Extension/FileProviderExtension+Thumbnail.swift index 48a4c1930a..4199d3751a 100644 --- a/File Provider Extension/FileProviderExtension+Thumbnail.swift +++ b/File Provider Extension/FileProviderExtension+Thumbnail.swift @@ -43,7 +43,7 @@ extension FileProviderExtension { 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 fileNameIconLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag) if let urlBase = metadata.urlBase.urlEncoded, let fileNamePath = fileNamePath.urlEncoded, diff --git a/Widget/Files/FilesData.swift b/Widget/Files/FilesData.swift index 370249e36c..23209f7451 100644 --- a/Widget/Files/FilesData.swift +++ b/Widget/Files/FilesData.swift @@ -237,7 +237,7 @@ func getFilesDataEntry(configuration: AccountIntent?, isPreview: Bool, displaySi } 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 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) if let image = imageIcon { imageRecent = image diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index ba6d1f23fd..9000b1cef9 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -1123,7 +1123,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate { } 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) { var metadatas: [tableMetadata] = [] @@ -1753,7 +1753,7 @@ class NCCollectionViewDownloadThumbnail: ConcurrentOperation { 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.fileNameIconLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag) } override func start() { diff --git a/iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift b/iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift index 07cea701f3..f337f6c527 100644 --- a/iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift +++ b/iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift @@ -323,8 +323,8 @@ extension NCCreateFormUploadConflict: UITableViewDataSource { // -----> Already Existing File 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)) + 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: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadataAlreadyExists.ocId, fileNameView: metadataAlreadyExists.fileNameView)) diff --git a/iOSClient/Main/NCActionCenter.swift b/iOSClient/Main/NCActionCenter.swift index 3d93d08016..d43bacf449 100644 --- a/iOSClient/Main/NCActionCenter.swift +++ b/iOSClient/Main/NCActionCenter.swift @@ -98,7 +98,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec self.openDocumentController(metadata: metadata) } else { 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) } } diff --git a/iOSClient/Media/NCMedia.swift b/iOSClient/Media/NCMedia.swift index ecfe0764ae..a6a72b8bfa 100644 --- a/iOSClient/Media/NCMedia.swift +++ b/iOSClient/Media/NCMedia.swift @@ -388,8 +388,8 @@ extension NCMedia: UICollectionViewDataSource { if let image = NCMediaCache.shared.getImage(ocId: metadata.ocId) { cell.imageItem.backgroundColor = nil 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.image = image NCMediaCache.shared.setImage(ocId: metadata.ocId, image: image) @@ -817,7 +817,7 @@ class NCMediaDownloadThumbnaill: ConcurrentOperation { 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.fileNameIconLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag) } override func start() { diff --git a/iOSClient/Menu/NCTrash+Menu.swift b/iOSClient/Menu/NCTrash+Menu.swift index cdd99e5dce..b7e06ccfc8 100644 --- a/iOSClient/Menu/NCTrash+Menu.swift +++ b/iOSClient/Menu/NCTrash+Menu.swift @@ -121,7 +121,7 @@ extension NCTrash { var actions: [NCMenuAction] = [] 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 } else { if tableTrash.directory { diff --git a/iOSClient/Select/NCSelect.swift b/iOSClient/Select/NCSelect.swift index 3de5f162b0..255c665585 100644 --- a/iOSClient/Select/NCSelect.swift +++ b/iOSClient/Select/NCSelect.swift @@ -298,8 +298,8 @@ extension NCSelect: UICollectionViewDataSource { // Thumbnail 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 { if metadata.iconName.isEmpty { (cell as? NCCellProtocol)?.filePreviewImageView?.image = NCBrandColor.cacheImages.file diff --git a/iOSClient/Share/Advanced/NCShareAdvancePermissionHeader.swift b/iOSClient/Share/Advanced/NCShareAdvancePermissionHeader.swift index e5291e8c2d..28e9c79b3b 100644 --- a/iOSClient/Share/Advanced/NCShareAdvancePermissionHeader.swift +++ b/iOSClient/Share/Advanced/NCShareAdvancePermissionHeader.swift @@ -30,7 +30,7 @@ class NCShareAdvancePermissionHeader: UIView { @IBOutlet weak var fullWidthImageView: UIImageView! 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.contentMode = .scaleAspectFill imageView.isHidden = true diff --git a/iOSClient/Share/NCSharePaging.swift b/iOSClient/Share/NCSharePaging.swift index 64bde1f20f..d3d24a865f 100644 --- a/iOSClient/Share/NCSharePaging.swift +++ b/iOSClient/Share/NCSharePaging.swift @@ -276,8 +276,8 @@ class NCSharePagingView: PagingView { dateFormatter.timeStyle = .short 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 { if metadata.directory { let image = metadata.e2eEncrypted ? UIImage(named: "folderEncrypted") : UIImage(named: "folder") diff --git a/iOSClient/Trash/NCTrash+CollectionView.swift b/iOSClient/Trash/NCTrash+CollectionView.swift index 48ba4202fc..36440a0de4 100644 --- a/iOSClient/Trash/NCTrash+CollectionView.swift +++ b/iOSClient/Trash/NCTrash+CollectionView.swift @@ -68,8 +68,8 @@ extension NCTrash: UICollectionViewDataSource { 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 { if tableTrash.hasPreview && !CCUtility.fileProviderStoragePreviewIconExists(tableTrash.fileId, etag: tableTrash.fileName) { downloadThumbnail(with: tableTrash, indexPath: indexPath) diff --git a/iOSClient/Trash/NCTrash.swift b/iOSClient/Trash/NCTrash.swift index 45c9eb9ac1..c6fa4e6445 100644 --- a/iOSClient/Trash/NCTrash.swift +++ b/iOSClient/Trash/NCTrash.swift @@ -348,7 +348,7 @@ extension NCTrash { 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 fileNameIconLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(tableTrash.fileId, etag: tableTrash.fileName) NextcloudKit.shared.downloadPreview(fileNamePathOrFileId: tableTrash.fileId, fileNamePreviewLocalPath: fileNamePreviewLocalPath, diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index fe867ced47..4f6b533c1b 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -49,7 +49,6 @@ + (void)createDirectoryStandard; -+ (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; diff --git a/iOSClient/Utility/NCUtility.swift b/iOSClient/Utility/NCUtility.swift index c6d5d00885..2d0b17b895 100644 --- a/iOSClient/Utility/NCUtility.swift +++ b/iOSClient/Utility/NCUtility.swift @@ -375,7 +375,7 @@ class NCUtility: NSObject { let fileNamePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView) let fileNamePathPreview = CCUtility.getDirectoryProviderStoragePreviewOcId(ocId, etag: etag)! - let fileNamePathIcon = CCUtility.getDirectoryProviderStorageIconOcId(ocId, etag: etag)! + let fileNamePathIcon = NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(ocId, etag: etag) if CCUtility.fileProviderStorageSize(ocId, fileNameView: fileNameView) > 0 && FileManager().fileExists(atPath: fileNamePathPreview) && FileManager().fileExists(atPath: fileNamePathIcon) { return } if classFile != NKCommon.TypeClassFile.image.rawValue && classFile != NKCommon.TypeClassFile.video.rawValue { return } @@ -677,7 +677,7 @@ class NCUtility: NSObject { var imagePreview: UIImage? let filePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView) - let iconImagePath = CCUtility.getDirectoryProviderStorageIconOcId(ocId, etag: etag)! + let iconImagePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(ocId, etag: etag) if FileManager().fileExists(atPath: iconImagePath) { imagePreview = UIImage(contentsOfFile: iconImagePath) diff --git a/iOSClient/Utility/NCUtilityFileSystem.swift b/iOSClient/Utility/NCUtilityFileSystem.swift index 4e98f51eb8..8a868c18d4 100644 --- a/iOSClient/Utility/NCUtilityFileSystem.swift +++ b/iOSClient/Utility/NCUtilityFileSystem.swift @@ -32,6 +32,8 @@ class NCUtilityFileSystem: NSObject { let fileManager = FileManager.default + // MARK: - + var directoryGroup: String { return fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups)?.path ?? "" } @@ -111,6 +113,13 @@ class NCUtilityFileSystem: NSObject { return path } + @objc func getDirectoryProviderStorageIconOcId(_ ocId: String, etag: String) -> String { + + return directoryProviderStorage + "/" + ocId + "/" + etag + ".small." + NCGlobal.shared.extensionPreview + } + + // MARK: - + @objc func getFileSize(filePath: String) -> Int64 { do { diff --git a/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift b/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift index dfe72cb33d..250e97d4d3 100644 --- a/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift +++ b/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift @@ -211,7 +211,7 @@ class NCViewerMediaPage: UIViewController { @objc private func openMenuMore() { - let imageIcon = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(currentViewController.metadata.ocId, etag: currentViewController.metadata.etag)) + let imageIcon = UIImage(contentsOfFile: NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(currentViewController.metadata.ocId, etag: currentViewController.metadata.etag)) NCViewer.shared.toggleMenu(viewController: self, metadata: currentViewController.metadata, webView: false, imageIcon: imageIcon) } From f5c59bc1a10552212dd3773ced995fc44f1b982f Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Wed, 25 Oct 2023 12:10:47 +0200 Subject: [PATCH 64/90] getDirectoryProviderStoragePreviewOcId --- .../FileProviderExtension+Actions.swift | 2 +- Widget/Files/FilesData.swift | 2 +- .../Main/Collection Common/NCCollectionViewCommon.swift | 2 +- iOSClient/Media/NCMedia.swift | 2 +- iOSClient/Trash/NCTrash.swift | 2 +- iOSClient/Utility/CCUtility.h | 1 - iOSClient/Utility/NCUtility+Image.swift | 6 ++---- iOSClient/Utility/NCUtility.swift | 2 +- iOSClient/Utility/NCUtilityFileSystem.swift | 7 ++++++- iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift | 2 +- iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift | 6 ++---- iOSClient/Viewer/NCViewerProviderContextMenu.swift | 2 +- 12 files changed, 18 insertions(+), 18 deletions(-) diff --git a/File Provider Extension/FileProviderExtension+Actions.swift b/File Provider Extension/FileProviderExtension+Actions.swift index dcc9f9709e..65c39d491e 100644 --- a/File Provider Extension/FileProviderExtension+Actions.swift +++ b/File Provider Extension/FileProviderExtension+Actions.swift @@ -203,7 +203,7 @@ extension FileProviderExtension { // rename file _ = 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(NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(itemIdentifier.rawValue, etag: metadata.etag), toPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(itemIdentifier.rawValue, etag: metadata.etag)) diff --git a/Widget/Files/FilesData.swift b/Widget/Files/FilesData.swift index 23209f7451..5b5194b776 100644 --- a/Widget/Files/FilesData.swift +++ b/Widget/Files/FilesData.swift @@ -236,7 +236,7 @@ func getFilesDataEntry(configuration: AccountIntent?, isPreview: Bool, displaySi imageRecent = image } 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 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) if let image = imageIcon { diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index 9000b1cef9..46d013d3ec 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -1752,7 +1752,7 @@ class NCCollectionViewDownloadThumbnail: ConcurrentOperation { self.cell = cell 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.fileNamePreviewLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag) self.fileNameIconLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag) } diff --git a/iOSClient/Media/NCMedia.swift b/iOSClient/Media/NCMedia.swift index a6a72b8bfa..70a0073950 100644 --- a/iOSClient/Media/NCMedia.swift +++ b/iOSClient/Media/NCMedia.swift @@ -816,7 +816,7 @@ class NCMediaDownloadThumbnaill: ConcurrentOperation { self.cell = cell 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.fileNamePreviewLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag) self.fileNameIconLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag) } diff --git a/iOSClient/Trash/NCTrash.swift b/iOSClient/Trash/NCTrash.swift index c6fa4e6445..70fcb1f452 100644 --- a/iOSClient/Trash/NCTrash.swift +++ b/iOSClient/Trash/NCTrash.swift @@ -347,7 +347,7 @@ extension NCTrash { func downloadThumbnail(with tableTrash: tableTrash, indexPath: IndexPath) { - let fileNamePreviewLocalPath = CCUtility.getDirectoryProviderStoragePreviewOcId(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, diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 4f6b533c1b..206b72efa8 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -49,7 +49,6 @@ + (void)createDirectoryStandard; -+ (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; diff --git a/iOSClient/Utility/NCUtility+Image.swift b/iOSClient/Utility/NCUtility+Image.swift index 2506caa590..6de426e886 100644 --- a/iOSClient/Utility/NCUtility+Image.swift +++ b/iOSClient/Utility/NCUtility+Image.swift @@ -37,9 +37,7 @@ extension NCUtility { } if CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag) { - if let imagePreviewPath = CCUtility.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag) { - return UIImage(contentsOfFile: imagePreviewPath) - } + return UIImage(contentsOfFile: NCUtilityFileSystem.shared.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)) } if metadata.isVideo { @@ -57,7 +55,7 @@ extension NCUtility { if CCUtility.fileProviderStorageExists(metadata) && metadata.isImage { - let previewPath = CCUtility.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)! + let previewPath = NCUtilityFileSystem.shared.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag) let imagePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) if ext == "GIF" { diff --git a/iOSClient/Utility/NCUtility.swift b/iOSClient/Utility/NCUtility.swift index 2d0b17b895..3118109730 100644 --- a/iOSClient/Utility/NCUtility.swift +++ b/iOSClient/Utility/NCUtility.swift @@ -374,7 +374,7 @@ class NCUtility: NSObject { var originalImage, scaleImagePreview, scaleImageIcon: UIImage? let fileNamePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView) - let fileNamePathPreview = CCUtility.getDirectoryProviderStoragePreviewOcId(ocId, etag: etag)! + let fileNamePathPreview = NCUtilityFileSystem.shared.getDirectoryProviderStoragePreviewOcId(ocId, etag: etag) let fileNamePathIcon = NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(ocId, etag: etag) if CCUtility.fileProviderStorageSize(ocId, fileNameView: fileNameView) > 0 && FileManager().fileExists(atPath: fileNamePathPreview) && FileManager().fileExists(atPath: fileNamePathIcon) { return } diff --git a/iOSClient/Utility/NCUtilityFileSystem.swift b/iOSClient/Utility/NCUtilityFileSystem.swift index 8a868c18d4..dd82240fb4 100644 --- a/iOSClient/Utility/NCUtilityFileSystem.swift +++ b/iOSClient/Utility/NCUtilityFileSystem.swift @@ -113,11 +113,16 @@ class NCUtilityFileSystem: NSObject { return path } - @objc func getDirectoryProviderStorageIconOcId(_ ocId: String, etag: String) -> String { + func getDirectoryProviderStorageIconOcId(_ ocId: String, etag: String) -> String { return directoryProviderStorage + "/" + ocId + "/" + etag + ".small." + NCGlobal.shared.extensionPreview } + func getDirectoryProviderStoragePreviewOcId(_ ocId: String, etag: String) -> String { + + return directoryProviderStorage + "/" + ocId + "/" + etag + ".preview." + NCGlobal.shared.extensionPreview + } + // MARK: - @objc func getFileSize(filePath: String) -> Int64 { diff --git a/iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift b/iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift index 80387f9c7c..7f11504470 100644 --- a/iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift +++ b/iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift @@ -137,7 +137,7 @@ class NCPlayer: NSObject { if metadata.isVideo { if position == 0 { - let fileNamePreviewLocalPath = CCUtility.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)! + let fileNamePreviewLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag) imageVideoContainer?.image = UIImage(contentsOfFile: fileNamePreviewLocalPath) } else { imageVideoContainer?.image = nil diff --git a/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift b/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift index 8bb4f95dd0..13f0036492 100644 --- a/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift +++ b/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift @@ -308,9 +308,7 @@ class NCViewerMedia: UIViewController { } if CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag) { - if let imagePreviewPath = CCUtility.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag) { - return UIImage(contentsOfFile: imagePreviewPath) - } + return UIImage(contentsOfFile: NCUtilityFileSystem.shared.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)) } if metadata.isAudio { @@ -329,7 +327,7 @@ class NCViewerMedia: UIViewController { if CCUtility.fileProviderStorageExists(metadata) && metadata.isImage { - let previewPath = CCUtility.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)! + let previewPath = NCUtilityFileSystem.shared.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag) let imagePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) if ext == "GIF" { diff --git a/iOSClient/Viewer/NCViewerProviderContextMenu.swift b/iOSClient/Viewer/NCViewerProviderContextMenu.swift index 2729b38d00..ca045220df 100644 --- a/iOSClient/Viewer/NCViewerProviderContextMenu.swift +++ b/iOSClient/Viewer/NCViewerProviderContextMenu.swift @@ -72,7 +72,7 @@ class NCViewerProviderContextMenu: UIViewController { // PREVIEW if CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag) { - if let image = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)) { + if let image = UIImage(contentsOfFile: NCUtilityFileSystem.shared.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)) { imageView.image = image imageView.frame = resize(image.size) } From 5bdaa3fc8d29b15afcaf50c50e96920958bc2d5d Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Wed, 25 Oct 2023 12:31:28 +0200 Subject: [PATCH 65/90] fileProviderStorageExists --- .../FileProviderExtension.swift | 2 +- .../FileProviderItem.swift | 2 +- .../NCCollectionViewCommon.swift | 4 +-- iOSClient/Main/NCActionCenter.swift | 6 ++--- .../Menu/NCCollectionViewCommon+Menu.swift | 4 +-- iOSClient/Menu/NCContextMenu.swift | 6 ++--- iOSClient/Menu/NCMenuAction.swift | 4 +-- iOSClient/Menu/NCViewer+Menu.swift | 8 +++--- iOSClient/Networking/NCNetworking.swift | 4 +-- iOSClient/Select/NCSelect.swift | 2 +- iOSClient/Utility/CCUtility.h | 1 - iOSClient/Utility/NCUtility+Exif.swift | 2 +- iOSClient/Utility/NCUtility+Image.swift | 2 +- iOSClient/Utility/NCUtilityFileSystem.swift | 27 +++++++++++++++++++ .../NCPlayer/NCPlayerToolBar.swift | 2 +- .../Viewer/NCViewerMedia/NCViewerMedia.swift | 10 +++---- .../NCViewerMediaDetailView.swift | 2 +- .../NCViewerMedia/NCViewerMediaPage.swift | 4 +-- .../Viewer/NCViewerProviderContextMenu.swift | 12 ++++----- 19 files changed, 65 insertions(+), 39 deletions(-) diff --git a/File Provider Extension/FileProviderExtension.swift b/File Provider Extension/FileProviderExtension.swift index 8e9a16bd51..aa045a4788 100644 --- a/File Provider Extension/FileProviderExtension.swift +++ b/File Provider Extension/FileProviderExtension.swift @@ -204,7 +204,7 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate { } 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) } diff --git a/File Provider Extension/FileProviderItem.swift b/File Provider Extension/FileProviderItem.swift index a6b3fc9df6..af03f660dc 100644 --- a/File Provider Extension/FileProviderItem.swift +++ b/File Provider Extension/FileProviderItem.swift @@ -105,7 +105,7 @@ class FileProviderItem: NSObject, NSFileProviderItem { if metadata.directory { return true } - if CCUtility.fileProviderStorageExists(metadata) { + if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) { return true } else { return false diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index 46d013d3ec..92c220f558 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -1136,7 +1136,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate { return } - if CCUtility.fileProviderStorageExists(metadata) { + if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) { NCViewer.shared.view(viewController: self, metadata: metadata, metadatas: [metadata], imageIcon: imageIcon) } else if NextcloudKit.shared.isNetworkReachable() { NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorLoadFileView) { _, _ in } @@ -1382,7 +1382,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { if NCManageDatabase.shared.getTableLocalFile(ocId: metadata.ocId) != nil { a11yValues.append(NSLocalizedString("_offline_", comment: "")) cell.fileLocalImage?.image = NCBrandColor.cacheImages.offlineFlag - } else if CCUtility.fileProviderStorageExists(metadata) { + } else if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) { cell.fileLocalImage?.image = NCBrandColor.cacheImages.local } } diff --git a/iOSClient/Main/NCActionCenter.swift b/iOSClient/Main/NCActionCenter.swift index d43bacf449..4267d7d2b5 100644 --- a/iOSClient/Main/NCActionCenter.swift +++ b/iOSClient/Main/NCActionCenter.swift @@ -309,7 +309,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec for metadata in metadatas { let fileURL = URL(fileURLWithPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)) - if CCUtility.fileProviderStorageExists(metadata) { + if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) { items.append(fileURL) } else { downloadMetadata.append((metadata, fileURL)) @@ -323,7 +323,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec } progressHandler: { progress in processor.hud?.progress = Float(progress.fractionCompleted) } completion: { _, _ in - if CCUtility.fileProviderStorageExists(metadata) { items.append(url) } + if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) { items.append(url) } completion() } } @@ -698,7 +698,7 @@ fileprivate extension tableMetadata { func toPasteBoardItem() -> [String: Any]? { // Get Data let fileUrl = URL(fileURLWithPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView)) - guard CCUtility.fileProviderStorageExists(self), + guard NCUtilityFileSystem.shared.fileProviderStorageExists(self), let data = try? Data(contentsOf: fileUrl), let unmanagedFileUTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension as CFString, nil) else { return nil } diff --git a/iOSClient/Menu/NCCollectionViewCommon+Menu.swift b/iOSClient/Menu/NCCollectionViewCommon+Menu.swift index e06cc952c8..40edcd81d2 100644 --- a/iOSClient/Menu/NCCollectionViewCommon+Menu.swift +++ b/iOSClient/Menu/NCCollectionViewCommon+Menu.swift @@ -286,7 +286,7 @@ extension NCCollectionViewCommon { icon: NCUtility.shared.loadImage(named: "viewfinder.circle"), order: 110, 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]) } else { 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"), order: 150, 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]) } else { NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorLoadFileQuickLook) { _, _ in } diff --git a/iOSClient/Menu/NCContextMenu.swift b/iOSClient/Menu/NCContextMenu.swift index 9775bde74c..ba08c049b7 100644 --- a/iOSClient/Menu/NCContextMenu.swift +++ b/iOSClient/Menu/NCContextMenu.swift @@ -70,7 +70,7 @@ class NCContextMenu: NSObject { let openIn = UIAction(title: NSLocalizedString("_open_in_", comment: ""), 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]) } else { hud.show(in: viewController.view) @@ -102,7 +102,7 @@ class NCContextMenu: NSObject { appDelegate.saveLivePhotoQueue.addOperation(NCOperationSaveLivePhoto(metadata: metadata, metadataMOV: metadataMOV)) } } else { - if CCUtility.fileProviderStorageExists(metadata) { + if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) { NCActionCenter.shared.saveAlbum(metadata: metadata) } else { hud.show(in: viewController.view) @@ -125,7 +125,7 @@ class NCContextMenu: NSObject { let modify = UIAction(title: NSLocalizedString("_modify_", comment: ""), 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]) } else { hud.show(in: viewController.view) diff --git a/iOSClient/Menu/NCMenuAction.swift b/iOSClient/Menu/NCMenuAction.swift index 7d4dc88400..310c825ec8 100644 --- a/iOSClient/Menu/NCMenuAction.swift +++ b/iOSClient/Menu/NCMenuAction.swift @@ -226,7 +226,7 @@ extension NCMenuAction { appDelegate.saveLivePhotoQueue.addOperation(NCOperationSaveLivePhoto(metadata: metadata, metadataMOV: metadataMOV)) } } else { - if CCUtility.fileProviderStorageExists(metadata) { + if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) { NCActionCenter.shared.saveAlbum(metadata: metadata) } else { 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"), order: order, 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]) } else { NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorPrint) { _, _ in } diff --git a/iOSClient/Menu/NCViewer+Menu.swift b/iOSClient/Menu/NCViewer+Menu.swift index 5775857c01..bc8961e0c5 100644 --- a/iOSClient/Menu/NCViewer+Menu.swift +++ b/iOSClient/Menu/NCViewer+Menu.swift @@ -110,7 +110,7 @@ extension NCViewer { title: NSLocalizedString("_print_", comment: ""), icon: NCUtility.shared.loadImage(named: "printer"), 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]) } else { NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorPrint) { _, _ in } @@ -157,7 +157,7 @@ extension NCViewer { title: NSLocalizedString("_save_as_scan_", comment: ""), icon: NCUtility.shared.loadImage(named: "viewfinder.circle"), 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]) } else { NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorSaveAsScan) { _, _ in } @@ -210,7 +210,7 @@ extension NCViewer { // // DOWNLOAD LOCALLY // - if !webView, metadata.session.isEmpty, !CCUtility.fileProviderStorageExists(metadata) { + if !webView, metadata.session.isEmpty, !NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) { actions.append( NCMenuAction( title: NSLocalizedString("_download_locally_", comment: ""), @@ -256,7 +256,7 @@ extension NCViewer { title: NSLocalizedString("_modify_", comment: ""), icon: NCUtility.shared.loadImage(named: "pencil.tip.crop.circle"), 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]) } else { NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorLoadFileQuickLook) { _, _ in } diff --git a/iOSClient/Networking/NCNetworking.swift b/iOSClient/Networking/NCNetworking.swift index b7a69563ef..fa59dc6d09 100644 --- a/iOSClient/Networking/NCNetworking.swift +++ b/iOSClient/Networking/NCNetworking.swift @@ -294,7 +294,7 @@ class NCNetworking: NSObject, NKCommonDelegate { completion: @escaping (_ afError: AFError?, _ error: NKError) -> Void) { guard !metadata.isInTransfer else { return completion(nil, NKError()) } - if checkfileProviderStorageExists, CCUtility.fileProviderStorageExists(metadata) { + if checkfileProviderStorageExists, NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) { return completion(nil, NKError()) } @@ -1622,7 +1622,7 @@ class NCNetworking: NSObject, NKCommonDelegate { } else { completition(URL(string: metadata.url), true, .success) } - } else if CCUtility.fileProviderStorageExists(metadata) { + } else if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) { completition(URL(fileURLWithPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)), false, .success) } else { NextcloudKit.shared.getDirectDownload(fileId: metadata.fileId) { _, url, _, error in diff --git a/iOSClient/Select/NCSelect.swift b/iOSClient/Select/NCSelect.swift index 255c665585..3d4d7903a8 100644 --- a/iOSClient/Select/NCSelect.swift +++ b/iOSClient/Select/NCSelect.swift @@ -396,7 +396,7 @@ extension NCSelect: UICollectionViewDataSource { // image local if NCManageDatabase.shared.getTableLocalFile(ocId: metadata.ocId) != nil { cell.imageLocal.image = NCBrandColor.cacheImages.offlineFlag - } else if CCUtility.fileProviderStorageExists(metadata) { + } else if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) { cell.imageLocal.image = NCBrandColor.cacheImages.local } } diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 206b72efa8..929467b35a 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -49,7 +49,6 @@ + (void)createDirectoryStandard; -+ (BOOL)fileProviderStorageExists:(tableMetadata *)metadata; + (int64_t)fileProviderStorageSize:(NSString *)ocId fileNameView:(NSString *)fileNameView; + (BOOL)fileProviderStoragePreviewIconExists:(NSString *)ocId etag:(NSString *)etag; diff --git a/iOSClient/Utility/NCUtility+Exif.swift b/iOSClient/Utility/NCUtility+Exif.swift index fc32c0457d..139a37d3e9 100644 --- a/iOSClient/Utility/NCUtility+Exif.swift +++ b/iOSClient/Utility/NCUtility+Exif.swift @@ -72,7 +72,7 @@ extension NCUtility { } } - if metadata.classFile != "image" || !CCUtility.fileProviderStorageExists(metadata) { + if metadata.classFile != "image" || !NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) { print("Storage exists or file is not an image") } diff --git a/iOSClient/Utility/NCUtility+Image.swift b/iOSClient/Utility/NCUtility+Image.swift index 6de426e886..0aff03eceb 100644 --- a/iOSClient/Utility/NCUtility+Image.swift +++ b/iOSClient/Utility/NCUtility+Image.swift @@ -53,7 +53,7 @@ extension NCUtility { let ext = CCUtility.getExtension(metadata.fileNameView) var image: UIImage? - if CCUtility.fileProviderStorageExists(metadata) && metadata.isImage { + if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) && metadata.isImage { let previewPath = NCUtilityFileSystem.shared.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag) let imagePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) diff --git a/iOSClient/Utility/NCUtilityFileSystem.swift b/iOSClient/Utility/NCUtilityFileSystem.swift index dd82240fb4..1e3a1af993 100644 --- a/iOSClient/Utility/NCUtilityFileSystem.swift +++ b/iOSClient/Utility/NCUtilityFileSystem.swift @@ -123,6 +123,33 @@ class NCUtilityFileSystem: NSObject { return directoryProviderStorage + "/" + ocId + "/" + etag + ".preview." + NCGlobal.shared.extensionPreview } + func fileProviderStorageExists(_ metadata: tableMetadata) -> Bool { + + let fileNamePath = getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileName) + let fileNameViewPath = getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) + + do { + let fileNameAttribute = try fileManager.attributesOfItem(atPath: fileNamePath) + let fileNameSize: UInt64 = fileNameAttribute[FileAttributeKey.size] as? UInt64 ?? 0 + let fileNameViewAttribute = try fileManager.attributesOfItem(atPath: fileNameViewPath) + let fileNameViewSize: UInt64 = fileNameViewAttribute[FileAttributeKey.size] as? UInt64 ?? 0 + + if metadata.isDirectoryE2EE == true { + if (fileNameSize == metadata.size || fileNameViewSize == metadata.size) && fileNameViewSize > 0 { + return true + } else { + return false + } + } else { + return fileNameViewSize == metadata.size + } + } catch { + print("Error: \(error)") + } + + return false + } + // MARK: - @objc func getFileSize(filePath: String) -> Int64 { diff --git a/iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayerToolBar.swift b/iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayerToolBar.swift index a4cfccb1e8..82e1d8505e 100644 --- a/iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayerToolBar.swift +++ b/iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayerToolBar.swift @@ -465,7 +465,7 @@ extension NCPlayerToolBar: NCSelectDelegate { let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName let fileNameLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) - if CCUtility.fileProviderStorageExists(metadata) { + if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) { addPlaybackSlave(type: type, metadata: metadata) } else { var downloadRequest: DownloadRequest? diff --git a/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift b/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift index 13f0036492..5832b819a9 100644 --- a/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift +++ b/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift @@ -185,7 +185,7 @@ class NCViewerMedia: UIViewController { } completion: { _, error in if error == .success { hud.dismiss() - if CCUtility.fileProviderStorageExists(self.metadata) { + if NCUtilityFileSystem.shared.fileProviderStorageExists(self.metadata) { let url = URL(fileURLWithPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(self.metadata.ocId, fileNameView: self.metadata.fileNameView)) ncplayer.openAVPlayer(url: url, autoplay: autoplay) } @@ -275,17 +275,17 @@ class NCViewerMedia: UIViewController { self.metadata = metadata // Download image - if !CCUtility.fileProviderStorageExists(metadata) && metadata.isImage && metadata.session.isEmpty { + if !NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) && metadata.isImage && metadata.session.isEmpty { if metadata.livePhoto { let fileName = (metadata.fileNameView as NSString).deletingPathExtension + ".mov" - if let metadata = NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameView LIKE[c] %@", metadata.account, metadata.serverUrl, fileName)), !CCUtility.fileProviderStorageExists(metadata) { + if let metadata = NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameView LIKE[c] %@", metadata.account, metadata.serverUrl, fileName)), !NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) { NCNetworking.shared.download(metadata: metadata, selector: "") { _, _ in } } } } - if metadata.isImage, metadata.fileExtension.lowercased() == "gif", !CCUtility.fileProviderStorageExists(metadata) { + if metadata.isImage, metadata.fileExtension.lowercased() == "gif", !NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) { downloadImage() } @@ -325,7 +325,7 @@ class NCViewerMedia: UIViewController { let ext = CCUtility.getExtension(metadata.fileNameView) var image: UIImage? - if CCUtility.fileProviderStorageExists(metadata) && metadata.isImage { + if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) && metadata.isImage { let previewPath = NCUtilityFileSystem.shared.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag) let imagePath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) diff --git a/iOSClient/Viewer/NCViewerMedia/NCViewerMediaDetailView.swift b/iOSClient/Viewer/NCViewerMedia/NCViewerMediaDetailView.swift index ce38e0597a..4ea4c5ca77 100644 --- a/iOSClient/Viewer/NCViewerMedia/NCViewerMediaDetailView.swift +++ b/iOSClient/Viewer/NCViewerMedia/NCViewerMediaDetailView.swift @@ -207,7 +207,7 @@ class NCViewerMediaDetailView: UIView { livePhotoImageView.isHidden = false } - if metadata.isImage && !CCUtility.fileProviderStorageExists(metadata) && metadata.session.isEmpty { + if metadata.isImage && !NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) && metadata.session.isEmpty { downloadImageButton.setTitle(NSLocalizedString("_try_download_full_resolution_", comment: ""), for: .normal) downloadImageLabel.text = NSLocalizedString("_full_resolution_image_info_", comment: "") downloadImageButtonContainer.isHidden = false diff --git a/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift b/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift index 250e97d4d3..d1f5f18804 100644 --- a/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift +++ b/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift @@ -303,7 +303,7 @@ class NCViewerMediaPage: UIViewController { if metadata.ocId == ocId, metadata.isAudioOrVideo, - CCUtility.fileProviderStorageExists(metadata), + NCUtilityFileSystem.shared.fileProviderStorageExists(metadata), let ncplayer = currentViewController.ncplayer { let url = URL(fileURLWithPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)) if ncplayer.isPlay() { @@ -656,7 +656,7 @@ extension NCViewerMediaPage: UIGestureRecognizerDelegate { if gestureRecognizer.state == .began { let fileName = (currentViewController.metadata.fileNameView as NSString).deletingPathExtension + ".mov" - if let metadata = NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameView LIKE[c] %@", currentViewController.metadata.account, currentViewController.metadata.serverUrl, fileName)), CCUtility.fileProviderStorageExists(metadata) { + if let metadata = NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameView LIKE[c] %@", currentViewController.metadata.account, currentViewController.metadata.serverUrl, fileName)), NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) { AudioServicesPlaySystemSound(1519) // peek feedback currentViewController.playLivePhoto(filePath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)) } diff --git a/iOSClient/Viewer/NCViewerProviderContextMenu.swift b/iOSClient/Viewer/NCViewerProviderContextMenu.swift index ca045220df..a9771e3149 100644 --- a/iOSClient/Viewer/NCViewerProviderContextMenu.swift +++ b/iOSClient/Viewer/NCViewerProviderContextMenu.swift @@ -79,12 +79,12 @@ class NCViewerProviderContextMenu: UIViewController { } // VIEW IMAGE - if metadata.isImage && CCUtility.fileProviderStorageExists(metadata) { + if metadata.isImage && NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) { viewImage(metadata: metadata) } // VIEW LIVE PHOTO - if let metadataLivePhoto = metadataLivePhoto, CCUtility.fileProviderStorageExists(metadataLivePhoto) { + if let metadataLivePhoto = metadataLivePhoto, NCUtilityFileSystem.shared.fileProviderStorageExists(metadataLivePhoto) { viewVideo(metadata: metadataLivePhoto) } @@ -104,7 +104,7 @@ class NCViewerProviderContextMenu: UIViewController { var maxDownload: UInt64 = 0 - if CCUtility.fileProviderStorageExists(metadata) { + if NCUtilityFileSystem.shared.fileProviderStorageExists(metadata) { viewVideo(metadata: metadata) @@ -125,7 +125,7 @@ class NCViewerProviderContextMenu: UIViewController { } // AUTO DOWNLOAD IMAGE GIF - if !CCUtility.fileProviderStorageExists(metadata), + if !NCUtilityFileSystem.shared.fileProviderStorageExists(metadata), metadata.contentType == "image/gif", let appDelegate = (UIApplication.shared.delegate as? AppDelegate), appDelegate.downloadQueue.operations.filter({ ($0 as? NCOperationDownload)?.metadata.ocId == metadata.ocId }).isEmpty { @@ -133,7 +133,7 @@ class NCViewerProviderContextMenu: UIViewController { } // AUTO DOWNLOAD IMAGE SVG - if !CCUtility.fileProviderStorageExists(metadata), + if !NCUtilityFileSystem.shared.fileProviderStorageExists(metadata), metadata.contentType == "image/svg+xml", let appDelegate = (UIApplication.shared.delegate as? AppDelegate), appDelegate.downloadQueue.operations.filter({ ($0 as? NCOperationDownload)?.metadata.ocId == metadata.ocId }).isEmpty { @@ -142,7 +142,7 @@ class NCViewerProviderContextMenu: UIViewController { // AUTO DOWNLOAD LIVE PHOTO if let metadataLivePhoto = self.metadataLivePhoto, - !CCUtility.fileProviderStorageExists(metadataLivePhoto), + !NCUtilityFileSystem.shared.fileProviderStorageExists(metadataLivePhoto), let appDelegate = (UIApplication.shared.delegate as? AppDelegate), appDelegate.downloadQueue.operations.filter({ ($0 as? NCOperationDownload)?.metadata.ocId == metadata.ocId }).isEmpty { appDelegate.downloadQueue.addOperation(NCOperationDownload(metadata: metadataLivePhoto, selector: "")) From e63ac4128b8415a00dd5a3bf844d1c6e48ca738d Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Wed, 25 Oct 2023 12:37:30 +0200 Subject: [PATCH 66/90] fileProviderStorageSize --- iOSClient/Data/NCManageDatabase+Metadata.swift | 2 +- iOSClient/Utility/CCUtility.h | 1 - iOSClient/Utility/NCUtility.swift | 2 +- iOSClient/Utility/NCUtilityFileSystem.swift | 16 +++++++++++++--- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/iOSClient/Data/NCManageDatabase+Metadata.swift b/iOSClient/Data/NCManageDatabase+Metadata.swift index 450d09c919..a520a27795 100644 --- a/iOSClient/Data/NCManageDatabase+Metadata.swift +++ b/iOSClient/Data/NCManageDatabase+Metadata.swift @@ -1148,7 +1148,7 @@ extension NCManageDatabase { func isDownloadMetadata(_ metadata: tableMetadata, download: Bool) -> Bool { 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) { return true } diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 929467b35a..024267535a 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -49,7 +49,6 @@ + (void)createDirectoryStandard; -+ (int64_t)fileProviderStorageSize:(NSString *)ocId fileNameView:(NSString *)fileNameView; + (BOOL)fileProviderStoragePreviewIconExists:(NSString *)ocId etag:(NSString *)etag; + (void)removeGroupApplicationSupport; diff --git a/iOSClient/Utility/NCUtility.swift b/iOSClient/Utility/NCUtility.swift index 3118109730..9da459f7f1 100644 --- a/iOSClient/Utility/NCUtility.swift +++ b/iOSClient/Utility/NCUtility.swift @@ -377,7 +377,7 @@ class NCUtility: NSObject { let fileNamePathPreview = NCUtilityFileSystem.shared.getDirectoryProviderStoragePreviewOcId(ocId, etag: etag) let fileNamePathIcon = NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(ocId, etag: etag) - if CCUtility.fileProviderStorageSize(ocId, fileNameView: fileNameView) > 0 && FileManager().fileExists(atPath: fileNamePathPreview) && FileManager().fileExists(atPath: fileNamePathIcon) { return } + if NCUtilityFileSystem.shared.fileProviderStorageSize(ocId, fileNameView: fileNameView) > 0 && FileManager().fileExists(atPath: fileNamePathPreview) && FileManager().fileExists(atPath: fileNamePathIcon) { return } if classFile != NKCommon.TypeClassFile.image.rawValue && classFile != NKCommon.TypeClassFile.video.rawValue { return } if classFile == NKCommon.TypeClassFile.image.rawValue { diff --git a/iOSClient/Utility/NCUtilityFileSystem.swift b/iOSClient/Utility/NCUtilityFileSystem.swift index 1e3a1af993..f70c39ffa0 100644 --- a/iOSClient/Utility/NCUtilityFileSystem.swift +++ b/iOSClient/Utility/NCUtilityFileSystem.swift @@ -143,13 +143,23 @@ class NCUtilityFileSystem: NSObject { } else { return fileNameViewSize == metadata.size } - } catch { - print("Error: \(error)") - } + } catch { print("Error: \(error)") } return false } + func fileProviderStorageSize(_ ocId: String, fileNameView: String) -> UInt64 { + + let fileNamePath = getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView) + do { + let fileNameAttribute = try fileManager.attributesOfItem(atPath: fileNamePath) + let fileNameSize: UInt64 = fileNameAttribute[FileAttributeKey.size] as? UInt64 ?? 0 + return fileNameSize + } catch { print("Error: \(error)") } + + return 0 + } + // MARK: - @objc func getFileSize(filePath: String) -> Int64 { From 85732bec0889b62b443f5e194414ffa53b986c19 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Wed, 25 Oct 2023 12:44:36 +0200 Subject: [PATCH 67/90] fileProviderStoragePreviewIconExists --- .../NCCollectionViewCommon.swift | 2 +- iOSClient/Media/NCMedia.swift | 2 +- iOSClient/Select/NCSelect.swift | 2 +- iOSClient/Trash/NCTrash+CollectionView.swift | 2 +- iOSClient/Utility/CCUtility.h | 1 - iOSClient/Utility/NCUtility+Image.swift | 2 +- iOSClient/Utility/NCUtilityFileSystem.swift | 21 +++++++++++++++++++ .../Viewer/NCViewerMedia/NCViewerMedia.swift | 2 +- .../Viewer/NCViewerProviderContextMenu.swift | 4 ++-- 9 files changed, 29 insertions(+), 9 deletions(-) diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index 92c220f558..e9c7c662c7 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -1204,7 +1204,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { } else { (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 } appDelegate.downloadThumbnailQueue.addOperation(NCCollectionViewDownloadThumbnail(metadata: metadata, cell: (cell as? NCCellProtocol), collectionView: collectionView)) } diff --git a/iOSClient/Media/NCMedia.swift b/iOSClient/Media/NCMedia.swift index 70a0073950..44ee8b8f41 100644 --- a/iOSClient/Media/NCMedia.swift +++ b/iOSClient/Media/NCMedia.swift @@ -395,7 +395,7 @@ extension NCMedia: UICollectionViewDataSource { NCMediaCache.shared.setImage(ocId: metadata.ocId, image: image) } } 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 { appDelegate.downloadThumbnailQueue.addOperation(NCMediaDownloadThumbnaill(metadata: metadata, cell: cell, collectionView: collectionView)) } diff --git a/iOSClient/Select/NCSelect.swift b/iOSClient/Select/NCSelect.swift index 3d4d7903a8..ff7544c987 100644 --- a/iOSClient/Select/NCSelect.swift +++ b/iOSClient/Select/NCSelect.swift @@ -306,7 +306,7 @@ extension NCSelect: UICollectionViewDataSource { } else { (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 } appDelegate.downloadThumbnailQueue.addOperation(NCCollectionViewDownloadThumbnail(metadata: metadata, cell: (cell as? NCCellProtocol), collectionView: collectionView)) } diff --git a/iOSClient/Trash/NCTrash+CollectionView.swift b/iOSClient/Trash/NCTrash+CollectionView.swift index 36440a0de4..6f2c7b184c 100644 --- a/iOSClient/Trash/NCTrash+CollectionView.swift +++ b/iOSClient/Trash/NCTrash+CollectionView.swift @@ -71,7 +71,7 @@ extension NCTrash: UICollectionViewDataSource { if FileManager().fileExists(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(tableTrash.fileId, etag: tableTrash.fileName)) { image = UIImage(contentsOfFile: NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(tableTrash.fileId, etag: tableTrash.fileName)) } 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) } } diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 024267535a..7046241a3d 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -49,7 +49,6 @@ + (void)createDirectoryStandard; -+ (BOOL)fileProviderStoragePreviewIconExists:(NSString *)ocId etag:(NSString *)etag; + (void)removeGroupApplicationSupport; + (void)removeGroupLibraryDirectory; diff --git a/iOSClient/Utility/NCUtility+Image.swift b/iOSClient/Utility/NCUtility+Image.swift index 0aff03eceb..2748f07120 100644 --- a/iOSClient/Utility/NCUtility+Image.swift +++ b/iOSClient/Utility/NCUtility+Image.swift @@ -36,7 +36,7 @@ extension NCUtility { NCUtility.shared.createImageFrom(fileNameView: metadata.fileNameView, ocId: metadata.ocId, etag: metadata.etag, classFile: metadata.classFile) } - if CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag) { + if NCUtilityFileSystem.shared.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag) { return UIImage(contentsOfFile: NCUtilityFileSystem.shared.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)) } diff --git a/iOSClient/Utility/NCUtilityFileSystem.swift b/iOSClient/Utility/NCUtilityFileSystem.swift index f70c39ffa0..8e18eba584 100644 --- a/iOSClient/Utility/NCUtilityFileSystem.swift +++ b/iOSClient/Utility/NCUtilityFileSystem.swift @@ -151,6 +151,7 @@ class NCUtilityFileSystem: NSObject { func fileProviderStorageSize(_ ocId: String, fileNameView: String) -> UInt64 { let fileNamePath = getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView) + do { let fileNameAttribute = try fileManager.attributesOfItem(atPath: fileNamePath) let fileNameSize: UInt64 = fileNameAttribute[FileAttributeKey.size] as? UInt64 ?? 0 @@ -160,6 +161,26 @@ class NCUtilityFileSystem: NSObject { return 0 } + func fileProviderStoragePreviewIconExists(_ ocId: String, etag: String) -> Bool { + + let fileNamePathPreview = getDirectoryProviderStoragePreviewOcId(ocId, etag: etag) + let fileNamePathIcon = getDirectoryProviderStorageIconOcId(ocId, etag: etag) + + do { + let fileNamePathPreviewAttribute = try fileManager.attributesOfItem(atPath: fileNamePathPreview) + let fileSizePreview: UInt64 = fileNamePathPreviewAttribute[FileAttributeKey.size] as? UInt64 ?? 0 + let fileNamePathIconAttribute = try fileManager.attributesOfItem(atPath: fileNamePathIcon) + let fileSizeIcon: UInt64 = fileNamePathIconAttribute[FileAttributeKey.size] as? UInt64 ?? 0 + if fileSizePreview > 0 && fileSizeIcon > 0 { + return true + } else { + return false + } + } catch { print("Error: \(error)") } + + return false + } + // MARK: - @objc func getFileSize(filePath: String) -> Int64 { diff --git a/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift b/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift index 5832b819a9..a4b95ad351 100644 --- a/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift +++ b/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift @@ -307,7 +307,7 @@ class NCViewerMedia: UIViewController { NCUtility.shared.createImageFrom(fileNameView: metadata.fileNameView, ocId: metadata.ocId, etag: metadata.etag, classFile: metadata.classFile) } - if CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag) { + if NCUtilityFileSystem.shared.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag) { return UIImage(contentsOfFile: NCUtilityFileSystem.shared.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)) } diff --git a/iOSClient/Viewer/NCViewerProviderContextMenu.swift b/iOSClient/Viewer/NCViewerProviderContextMenu.swift index a9771e3149..6d4ac9e208 100644 --- a/iOSClient/Viewer/NCViewerProviderContextMenu.swift +++ b/iOSClient/Viewer/NCViewerProviderContextMenu.swift @@ -70,7 +70,7 @@ class NCViewerProviderContextMenu: UIViewController { } // PREVIEW - if CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag) { + if NCUtilityFileSystem.shared.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag) { if let image = UIImage(contentsOfFile: NCUtilityFileSystem.shared.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)) { imageView.image = image @@ -90,7 +90,7 @@ class NCViewerProviderContextMenu: UIViewController { // VIEW VIDEO if metadata.isVideo { - if !CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag) { + if !NCUtilityFileSystem.shared.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag) { let newSize = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height) imageView.image = nil imageView.frame = newSize From 29fb22c0020bb2e246a8b7b69cdc792d0534766b Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Wed, 25 Oct 2023 14:45:38 +0200 Subject: [PATCH 68/90] lint --- iOSClient/Utility/CCUtility.h | 1 - iOSClient/Utility/CCUtility.m | 12 --- iOSClient/Utility/NCUtilityFileSystem.swift | 81 +++++++-------------- 3 files changed, 28 insertions(+), 66 deletions(-) diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 7046241a3d..84c6d7821e 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -40,7 +40,6 @@ + (NSString *)transformedSize:(int64_t)value; + (NSString *)removeForbiddenCharactersServer:(NSString *)fileName; -+ (NSString *)removeForbiddenCharactersFileSystem:(NSString *)fileName; + (NSString *)stringAppendServerUrl:(NSString *)serverUrl addFileName:(NSString *)addFileName; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 3d86dbcb83..ec836be420 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -110,18 +110,6 @@ + (NSString *)removeForbiddenCharactersServer:(NSString *)fileName return fileName; } -// Remove do not forbidden characters for File System Server -+ (NSString *)removeForbiddenCharactersFileSystem:(NSString *)fileName -{ - NSArray *arrayForbiddenCharacters = [NSArray arrayWithObjects:@"\\",@"<",@">",@":",@"\"",@"|",@"?",@"*",@"/", nil]; - - for (NSString *currentCharacter in arrayForbiddenCharacters) { - fileName = [fileName stringByReplacingOccurrencesOfString:currentCharacter withString:@""]; - } - - return fileName; -} - + (NSString*)stringAppendServerUrl:(NSString *)serverUrl addFileName:(NSString *)addFileName { NSString *result; diff --git a/iOSClient/Utility/NCUtilityFileSystem.swift b/iOSClient/Utility/NCUtilityFileSystem.swift index 8e18eba584..8590c7432a 100644 --- a/iOSClient/Utility/NCUtilityFileSystem.swift +++ b/iOSClient/Utility/NCUtilityFileSystem.swift @@ -43,97 +43,74 @@ class NCUtilityFileSystem: NSObject { } var directoryCertificates: String { - if let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups) { - let path = directoryGroup.appendingPathComponent(NCGlobal.shared.appCertificates).path - if !fileManager.fileExists(atPath: path) { - do { - try fileManager.createDirectory(atPath: path, withIntermediateDirectories: true) - } catch { - return "" - } - } - return path + guard let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups) else { return "" } + let path = directoryGroup.appendingPathComponent(NCGlobal.shared.appCertificates).path + if !fileManager.fileExists(atPath: path) { + do { + try fileManager.createDirectory(atPath: path, withIntermediateDirectories: true) + } catch { print("Error: \(error)") } } - return "" + return path } var directoryUserData: String { - if let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups) { - let path = directoryGroup.appendingPathComponent(NCGlobal.shared.appUserData).path - if !fileManager.fileExists(atPath: path) { - do { - try fileManager.createDirectory(atPath: path, withIntermediateDirectories: true) - } catch { - return "" - } - } - return path + guard let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups) else { return "" } + let path = directoryGroup.appendingPathComponent(NCGlobal.shared.appUserData).path + if !fileManager.fileExists(atPath: path) { + do { + try fileManager.createDirectory(atPath: path, withIntermediateDirectories: true) + } catch { print("Error: \(error)") } } - return "" + return path } @objc var directoryProviderStorage: String { - if let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups) { - let path = directoryGroup.appendingPathComponent(NCGlobal.shared.directoryProviderStorage).path - if !fileManager.fileExists(atPath: path) { - do { - try fileManager.createDirectory(atPath: path, withIntermediateDirectories: true) - } catch { - return "" - } - } - return path + guard let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups) else { return "" } + let path = directoryGroup.appendingPathComponent(NCGlobal.shared.directoryProviderStorage).path + if !fileManager.fileExists(atPath: path) { + do { + try fileManager.createDirectory(atPath: path, withIntermediateDirectories: true) + } catch { print("Error: \(error)") } } - return "" + return path } @objc func getDirectoryProviderStorageOcId(_ ocId: String) -> String { - let path = directoryProviderStorage + "/" + ocId if !fileManager.fileExists(atPath: path) { do { try fileManager.createDirectory(atPath: path, withIntermediateDirectories: true) - } catch { - return "" - } + } catch { print("Error: \(error)") } } return path } @objc func getDirectoryProviderStorageOcId(_ ocId: String, fileNameView: String) -> String { - let path = directoryProviderStorage + "/" + ocId + "/" + fileNameView if !fileManager.fileExists(atPath: path) { do { try fileManager.createDirectory(atPath: path, withIntermediateDirectories: true) - } catch { - return "" - } + } catch { print("Error: \(error)") } } return path } func getDirectoryProviderStorageIconOcId(_ ocId: String, etag: String) -> String { - return directoryProviderStorage + "/" + ocId + "/" + etag + ".small." + NCGlobal.shared.extensionPreview } func getDirectoryProviderStoragePreviewOcId(_ ocId: String, etag: String) -> String { - return directoryProviderStorage + "/" + ocId + "/" + etag + ".preview." + NCGlobal.shared.extensionPreview } func fileProviderStorageExists(_ metadata: tableMetadata) -> Bool { - let fileNamePath = getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileName) let fileNameViewPath = getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) - do { let fileNameAttribute = try fileManager.attributesOfItem(atPath: fileNamePath) let fileNameSize: UInt64 = fileNameAttribute[FileAttributeKey.size] as? UInt64 ?? 0 let fileNameViewAttribute = try fileManager.attributesOfItem(atPath: fileNameViewPath) let fileNameViewSize: UInt64 = fileNameViewAttribute[FileAttributeKey.size] as? UInt64 ?? 0 - if metadata.isDirectoryE2EE == true { if (fileNameSize == metadata.size || fileNameViewSize == metadata.size) && fileNameViewSize > 0 { return true @@ -144,28 +121,22 @@ class NCUtilityFileSystem: NSObject { return fileNameViewSize == metadata.size } } catch { print("Error: \(error)") } - return false } func fileProviderStorageSize(_ ocId: String, fileNameView: String) -> UInt64 { - let fileNamePath = getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView) - do { let fileNameAttribute = try fileManager.attributesOfItem(atPath: fileNamePath) let fileNameSize: UInt64 = fileNameAttribute[FileAttributeKey.size] as? UInt64 ?? 0 return fileNameSize } catch { print("Error: \(error)") } - return 0 } func fileProviderStoragePreviewIconExists(_ ocId: String, etag: String) -> Bool { - let fileNamePathPreview = getDirectoryProviderStoragePreviewOcId(ocId, etag: etag) let fileNamePathIcon = getDirectoryProviderStorageIconOcId(ocId, etag: etag) - do { let fileNamePathPreviewAttribute = try fileManager.attributesOfItem(atPath: fileNamePathPreview) let fileSizePreview: UInt64 = fileNamePathPreviewAttribute[FileAttributeKey.size] as? UInt64 ?? 0 @@ -177,10 +148,14 @@ class NCUtilityFileSystem: NSObject { return false } } catch { print("Error: \(error)") } - return false } + func createDirectoryStandard() { + + guard let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups) else { return } + } + // MARK: - @objc func getFileSize(filePath: String) -> Int64 { From 9bf1721fcda1531a800d8e7faf4b97e08c2d2f91 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Wed, 25 Oct 2023 15:48:44 +0200 Subject: [PATCH 69/90] coding --- Share/NCShareExtension+Files.swift | 2 +- iOSClient/AppDelegate.swift | 4 +- iOSClient/Main/NCActionCenter.swift | 2 +- .../Scan document/NCDocumentCamera.swift | 2 +- .../Scan document/NCScan+CollectionView.swift | 4 +- iOSClient/Scan document/NCScan.swift | 8 +- .../Scan document/NCUploadScanDocument.swift | 2 +- iOSClient/Settings/CCAdvanced.m | 18 +- .../Settings/NCSettingsBundleHelper.swift | 8 +- iOSClient/Utility/CCUtility.h | 12 - iOSClient/Utility/CCUtility.m | 249 ------------------ iOSClient/Utility/NCUtility.swift | 10 +- iOSClient/Utility/NCUtilityFileSystem.swift | 72 ++++- 13 files changed, 94 insertions(+), 299 deletions(-) diff --git a/Share/NCShareExtension+Files.swift b/Share/NCShareExtension+Files.swift index cff4fb2f86..28a7e7c6b8 100644 --- a/Share/NCShareExtension+Files.swift +++ b/Share/NCShareExtension+Files.swift @@ -99,7 +99,7 @@ class NCFilesExtensionHandler { @discardableResult init(items: [NSExtensionItem], completion: @escaping ([String]) -> Void) { - CCUtility.emptyTemporaryDirectory() + NCUtilityFileSystem.shared.emptyTemporaryDirectory() var counter = 0 self.itemsProvider = items.compactMap({ $0.attachments }).flatMap { $0.filter({ diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index 34c824ecf9..89aac303b1 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -84,8 +84,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD FirebaseApp.configure() } - CCUtility.createDirectoryStandard() - CCUtility.emptyTemporaryDirectory() + NCUtilityFileSystem.shared.createDirectoryStandard() + NCUtilityFileSystem.shared.emptyTemporaryDirectory() NCUtility.shared.clearCacheDirectory("com.limit-point.LivePhoto") // Activated singleton diff --git a/iOSClient/Main/NCActionCenter.swift b/iOSClient/Main/NCActionCenter.swift index 4267d7d2b5..9466aac71a 100644 --- a/iOSClient/Main/NCActionCenter.swift +++ b/iOSClient/Main/NCActionCenter.swift @@ -346,7 +346,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec 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 fileNamePathDestination = CCUtility.getDirectoryScan() + "/" + fileNameDestination + let fileNamePathDestination = NCUtilityFileSystem.shared.directoryScan + "/" + fileNameDestination NCUtilityFileSystem.shared.copyFile(atPath: fileNamePath, toPath: fileNamePathDestination) diff --git a/iOSClient/Scan document/NCDocumentCamera.swift b/iOSClient/Scan document/NCDocumentCamera.swift index 74489f3bb0..f0694d3962 100644 --- a/iOSClient/Scan document/NCDocumentCamera.swift +++ b/iOSClient/Scan document/NCDocumentCamera.swift @@ -54,7 +54,7 @@ class NCDocumentCamera: NSObject, VNDocumentCameraViewControllerDelegate { keyFileNameType: NCGlobal.shared.keyFileNameType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal, forcedNewFileName: true)! - let fileNamePath = CCUtility.getDirectoryScan() + "/" + fileName + let fileNamePath = NCUtilityFileSystem.shared.directoryScan + "/" + fileName let image = scan.imageOfPage(at: pageNumber) do { try image.pngData()?.write(to: NSURL.fileURL(withPath: fileNamePath)) diff --git a/iOSClient/Scan document/NCScan+CollectionView.swift b/iOSClient/Scan document/NCScan+CollectionView.swift index 6ae419f5ce..c234970c35 100644 --- a/iOSClient/Scan document/NCScan+CollectionView.swift +++ b/iOSClient/Scan document/NCScan+CollectionView.swift @@ -36,7 +36,7 @@ extension NCScan: UICollectionViewDataSource { 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 } @@ -55,7 +55,7 @@ extension NCScan: UICollectionViewDataSource { let buttonPosition: CGPoint = (sender as? UIButton)!.convert(.zero, to: self.collectionViewSource) if let indexPath = self.collectionViewSource.indexPathForItem(at: buttonPosition) { - let fileNameAtPath = CCUtility.getDirectoryScan() + "/" + self.itemsSource[indexPath.row] + let fileNameAtPath = NCUtilityFileSystem.shared.directoryScan + "/" + self.itemsSource[indexPath.row] CCUtility.removeFile(atPath: fileNameAtPath) self.itemsSource.remove(at: indexPath.row) diff --git a/iOSClient/Scan document/NCScan.swift b/iOSClient/Scan document/NCScan.swift index 7169d74bfb..c86e1bc7c2 100755 --- a/iOSClient/Scan document/NCScan.swift +++ b/iOSClient/Scan document/NCScan.swift @@ -191,7 +191,7 @@ class NCScan: UIViewController, NCScanCellCellDelegate { 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 } imagesDestination.append(image) @@ -228,7 +228,7 @@ class NCScan: UIViewController, NCScanCellCellDelegate { itemsSource.removeAll() do { - let atPath = CCUtility.getDirectoryScan()! + let atPath = NCUtilityFileSystem.shared.directoryScan let directoryContents = try FileManager.default.contentsOfDirectory(atPath: atPath) for fileName in directoryContents where fileName.first != "." { itemsSource.append(fileName) @@ -329,7 +329,7 @@ class NCScan: UIViewController, NCScanCellCellDelegate { if collectionView === collectionViewDestination { 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 } @@ -382,7 +382,7 @@ class NCScan: UIViewController, NCScanCellCellDelegate { keyFileNameType: NCGlobal.shared.keyFileNameType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal, forcedNewFileName: true)! - let fileNamePath = CCUtility.getDirectoryScan() + "/" + fileName + let fileNamePath = NCUtilityFileSystem.shared.directoryScan + "/" + fileName do { try image.pngData()?.write(to: NSURL.fileURL(withPath: fileNamePath), options: .atomic) diff --git a/iOSClient/Scan document/NCUploadScanDocument.swift b/iOSClient/Scan document/NCUploadScanDocument.swift index 198dd19ce9..1a622f5292 100644 --- a/iOSClient/Scan document/NCUploadScanDocument.swift +++ b/iOSClient/Scan document/NCUploadScanDocument.swift @@ -127,7 +127,7 @@ class NCUploadScanDocument: ObservableObject { metadata.size = NCUtilityFileSystem.shared.getFileSize(filePath: fileNamePath) NCNetworkingProcessUpload.shared.createProcessUploads(metadatas: [metadata], completion: { _ in }) if self.removeAllFiles { - let path = CCUtility.getDirectoryScan()! + let path = NCUtilityFileSystem.shared.directoryScan let filePaths = try FileManager.default.contentsOfDirectory(atPath: path) for filePath in filePaths { try FileManager.default.removeItem(atPath: path + "/" + filePath) diff --git a/iOSClient/Settings/CCAdvanced.m b/iOSClient/Settings/CCAdvanced.m index 03a9df1781..a9b7d517e9 100755 --- a/iOSClient/Settings/CCAdvanced.m +++ b/iOSClient/Settings/CCAdvanced.m @@ -376,13 +376,13 @@ - (void)clearCache:(NSString *)account [[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]; @@ -459,11 +459,11 @@ - (void)exitNextcloud:(XLFormRowDescriptor *)sender [[NSURLCache sharedURLCache] setMemoryCapacity: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]; [[[NCKeychain alloc] init] removeAll]; diff --git a/iOSClient/Settings/NCSettingsBundleHelper.swift b/iOSClient/Settings/NCSettingsBundleHelper.swift index 65aa11a3d9..b2f6c40d29 100644 --- a/iOSClient/Settings/NCSettingsBundleHelper.swift +++ b/iOSClient/Settings/NCSettingsBundleHelper.swift @@ -42,10 +42,10 @@ class NCSettingsBundleHelper: NSObject { URLCache.shared.memoryCapacity = 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() NCKeychain().removeAll() NCManageDatabase.shared.removeDB() diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 84c6d7821e..66f18c147c 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -46,16 +46,6 @@ + (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; -+ (void)createDirectoryStandard; - - -+ (void)removeGroupApplicationSupport; -+ (void)removeGroupLibraryDirectory; -+ (void)removeGroupDirectoryProviderStorage; -+ (void)removeDocumentsDirectory; -+ (void)removeTemporaryDirectory; -+ (void)emptyTemporaryDirectory; - + (NSString *)getTitleSectionDate:(NSDate *)date; + (void)moveFileAtPath:(NSString *)atPath toPath:(NSString *)toPath; @@ -66,8 +56,6 @@ + (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; // ===== Share Permissions ===== diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index ec836be420..ad5b480aa4 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -42,19 +42,6 @@ @implementation CCUtility #pragma mark ===== Various ===== #pragma -------------------------------------------------------------------------------------------- -+ (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL -{ - NSError *error = nil; - BOOL success = [URL setResourceValue:[NSNumber numberWithBool: YES] forKey: NSURLIsExcludedFromBackupKey error: &error]; - if(success) { - NSLog(@"Excluding %@ from backup", [URL lastPathComponent]); - } else { - NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error); - } - - return success; -} - + (NSString *)dateDiff:(NSDate *) convertedDate { NSDate *todayDate = [NSDate date]; @@ -251,233 +238,6 @@ + (NSString *)createFileName:(NSString *)fileName fileDate:(NSDate *)fileDate fi return fileName; } -+ (void)createDirectoryStandard -{ - NSString *path; - NSURL *dirGroup = [CCUtility getDirectoryGroup]; - - NSLog(@"[LOG] Dir Group"); - NSLog(@"%@", [dirGroup path]); - NSLog(@"[LOG] Program application "); - NSLog(@"%@", [[CCUtility getDirectoryDocuments] stringByDeletingLastPathComponent]); - - // create Directory Documents - path = [CCUtility getDirectoryDocuments]; - if (![[NSFileManager defaultManager] fileExistsAtPath: path]) - [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil]; - - // create Directory audio => Library, Application Support, audio - path = [CCUtility getDirectoryAudio]; - if (![[NSFileManager defaultManager] fileExistsAtPath: path]) - [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil]; - - // create Directory database Nextcloud - path = [[dirGroup URLByAppendingPathComponent:[[NCGlobal shared] appDatabaseNextcloud]] path]; - if (![[NSFileManager defaultManager] fileExistsAtPath:path]) - [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil]; - - // create Directory User Data - path = [[dirGroup URLByAppendingPathComponent:NCGlobal.shared.appUserData] path]; - if (![[NSFileManager defaultManager] fileExistsAtPath:path]) - [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil]; - - // create Directory Provider Storage - path = [CCUtility getDirectoryProviderStorage]; - if (![[NSFileManager defaultManager] fileExistsAtPath: path]) - [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil]; - - // create Directory Scan - path = [[dirGroup URLByAppendingPathComponent:NCGlobal.shared.appScan] path]; - if (![[NSFileManager defaultManager] fileExistsAtPath:path]) - [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil]; - - // create Directory Temp - path = NSTemporaryDirectory(); - if (![[NSFileManager defaultManager] fileExistsAtPath:path]) - [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil]; - - // Directory Excluded From Backup - [CCUtility addSkipBackupAttributeToItemAtURL:[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]]; - [CCUtility addSkipBackupAttributeToItemAtURL:[[CCUtility getDirectoryGroup] URLByAppendingPathComponent:NCGlobal.shared.directoryProviderStorage]]; - [CCUtility addSkipBackupAttributeToItemAtURL:[[CCUtility getDirectoryGroup] URLByAppendingPathComponent:NCGlobal.shared.appApplicationSupport]]; - - [CCUtility addSkipBackupAttributeToItemAtURL:[[CCUtility getDirectoryGroup] URLByAppendingPathComponent:NCGlobal.shared.appCertificates]]; - [CCUtility addSkipBackupAttributeToItemAtURL:[[CCUtility getDirectoryGroup] URLByAppendingPathComponent:NCGlobal.shared.appDatabaseNextcloud]]; - [CCUtility addSkipBackupAttributeToItemAtURL:[[CCUtility getDirectoryGroup] URLByAppendingPathComponent:NCGlobal.shared.appScan]]; - [CCUtility addSkipBackupAttributeToItemAtURL:[[CCUtility getDirectoryGroup] URLByAppendingPathComponent:NCGlobal.shared.appUserData]]; -} - -+ (NSURL *)getDirectoryGroup -{ - NSURL *path = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:[NCBrandOptions shared].capabilitiesGroups]; - return path; -} - -// Return the path of directory Documents -> NSDocumentDirectory -+ (NSString *)getDirectoryDocuments -{ - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); - - return [paths objectAtIndex:0]; -} - -+ (NSString *)getDirectoryReaderMetadata -{ - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); - - return [NSString stringWithFormat:@"%@/Reader Metadata", [paths objectAtIndex:0]]; -} - -// Return the path of directory Audio -+ (NSString *)getDirectoryAudio -{ - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); - - return [NSString stringWithFormat:@"%@/%@", [paths objectAtIndex:0], @"audio"]; -} - -// Return the path of directory Cetificates -+ (NSString *)getDirectoryCerificates -{ - NSString *path = [[[CCUtility getDirectoryGroup] URLByAppendingPathComponent:NCGlobal.shared.appCertificates] path]; - - if (![[NSFileManager defaultManager] fileExistsAtPath:path]) - [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil]; - - return path; -} - -+ (NSString *)getDirectoryUserData -{ - NSString *path = [[[CCUtility getDirectoryGroup] URLByAppendingPathComponent:NCGlobal.shared.appUserData] path]; - - if (![[NSFileManager defaultManager] fileExistsAtPath:path]) - [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil]; - - return path; -} - -+ (NSString *)getDirectoryProviderStorage -{ - NSString *path = [[[CCUtility getDirectoryGroup] URLByAppendingPathComponent:NCGlobal.shared.directoryProviderStorage] path]; - - if (![[NSFileManager defaultManager] fileExistsAtPath:path]) - [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil]; - - return path; -} - -+ (NSString *)getDirectoryProviderStorageOcId:(NSString *)ocId -{ - NSString *path = [NSString stringWithFormat:@"%@/%@", [self getDirectoryProviderStorage], ocId]; - - if (![[NSFileManager defaultManager] fileExistsAtPath:path]) - [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil]; - - return path; -} - -+ (NSString *)getDirectoryProviderStorageOcId:(NSString *)ocId fileNameView:(NSString *)fileNameView -{ - NSString *fileNamePath = [NSString stringWithFormat:@"%@/%@", [self getDirectoryProviderStorageOcId:ocId], fileNameView]; - - // if do not exists create file 0 length - // causes files with lenth 0 to never be downloaded, because already exist - // also makes it impossible to delete any file with length 0 (from cache) - if ([[NSFileManager defaultManager] fileExistsAtPath:fileNamePath] == NO) { - [[NSFileManager defaultManager] createFileAtPath:fileNamePath contents:nil attributes:nil]; - } - - return fileNamePath; -} - -+ (NSString *)getDirectoryProviderStorageIconOcId:(NSString *)ocId etag:(NSString *)etag -{ - return [NSString stringWithFormat:@"%@/%@.small.%@", [self getDirectoryProviderStorageOcId:ocId], etag, [NCGlobal shared].extensionPreview]; -} - -+ (NSString *)getDirectoryProviderStoragePreviewOcId:(NSString *)ocId etag:(NSString *)etag -{ - return [NSString stringWithFormat:@"%@/%@.preview.%@", [self getDirectoryProviderStorageOcId:ocId], etag, [NCGlobal shared].extensionPreview]; -} - -+ (BOOL)fileProviderStorageExists:(tableMetadata *)metadata -{ - NSString *fileNameViewPath = [self getDirectoryProviderStorageOcId:metadata.ocId fileNameView:metadata.fileNameView]; - NSString *fileNamePath = [self getDirectoryProviderStorageOcId:metadata.ocId fileNameView:metadata.fileName]; - - unsigned long long fileNameViewSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:fileNameViewPath error:nil] fileSize]; - unsigned long long fileNameSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:fileNamePath error:nil] fileSize]; - - if (metadata.isDirectoryE2EE == true) { - if ((fileNameSize == metadata.size || fileNameViewSize == metadata.size) && fileNameViewSize > 0) { - return true; - } else { - return false; - } - } else { - return fileNameViewSize == metadata.size; - } -} - -+ (int64_t)fileProviderStorageSize:(NSString *)ocId fileNameView:(NSString *)fileNameView -{ - NSString *fileNamePath = [self getDirectoryProviderStorageOcId:ocId fileNameView:fileNameView]; - - int64_t fileSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:fileNamePath error:nil] fileSize]; - - return fileSize; -} - -+ (BOOL)fileProviderStoragePreviewIconExists:(NSString *)ocId etag:(NSString *)etag -{ - NSString *fileNamePathPreview = [self getDirectoryProviderStoragePreviewOcId:ocId etag:etag]; - NSString *fileNamePathIcon = [self getDirectoryProviderStorageIconOcId:ocId etag:etag]; - - unsigned long long fileSizePreview = [[[NSFileManager defaultManager] attributesOfItemAtPath:fileNamePathPreview error:nil] fileSize]; - unsigned long long fileSizeIcon = [[[NSFileManager defaultManager] attributesOfItemAtPath:fileNamePathIcon error:nil] fileSize]; - - if (fileSizePreview > 0 && fileSizeIcon > 0) return true; - else return false; -} - -+ (void)removeGroupApplicationSupport -{ - NSURL *dirGroup = [CCUtility getDirectoryGroup]; - NSString *path = [[dirGroup URLByAppendingPathComponent:NCGlobal.shared.appApplicationSupport] path]; - - [[NSFileManager defaultManager] removeItemAtPath:path error:nil]; -} - -+ (void)removeGroupLibraryDirectory -{ - [[NSFileManager defaultManager] removeItemAtPath:[CCUtility getDirectoryScan] error:nil]; - [[NSFileManager defaultManager] removeItemAtPath:[CCUtility getDirectoryUserData] error:nil]; -} - -+ (void)removeGroupDirectoryProviderStorage -{ - [[NSFileManager defaultManager] removeItemAtPath:[CCUtility getDirectoryProviderStorage] error:nil]; -} - -+ (void)removeDocumentsDirectory -{ - [[NSFileManager defaultManager] removeItemAtPath:[CCUtility getDirectoryDocuments] error:nil]; -} - -+ (void)removeTemporaryDirectory -{ - [[NSFileManager defaultManager] removeItemAtPath:NSTemporaryDirectory() error:nil]; -} - -+ (void)emptyTemporaryDirectory -{ - NSArray* tmpDirectory = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL]; - for (NSString *file in tmpDirectory) { - [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), file] error:NULL]; - } -} - + (NSString *)getTitleSectionDate:(NSDate *)date { NSString *title; @@ -570,15 +330,6 @@ + (NSString *)getMimeType:(NSString *)fileNameView return returnFileUTI; } -+ (NSString *)getDirectoryScan -{ - NSString *path = [[[CCUtility getDirectoryGroup] URLByAppendingPathComponent:NCGlobal.shared.appScan] path]; - - if (![[NSFileManager defaultManager] fileExistsAtPath:path]) - [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil]; - - return path; -} #pragma -------------------------------------------------------------------------------------------- #pragma mark ===== Share Permissions ===== diff --git a/iOSClient/Utility/NCUtility.swift b/iOSClient/Utility/NCUtility.swift index 9da459f7f1..abf1ab8cfa 100644 --- a/iOSClient/Utility/NCUtility.swift +++ b/iOSClient/Utility/NCUtility.swift @@ -211,13 +211,13 @@ class NCUtility: NSObject { NCManageDatabase.shared.clearDatabase(account: nil, removeAccount: true) - 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() NCKeychain().removeAll() } diff --git a/iOSClient/Utility/NCUtilityFileSystem.swift b/iOSClient/Utility/NCUtilityFileSystem.swift index 8590c7432a..d793b245dc 100644 --- a/iOSClient/Utility/NCUtilityFileSystem.swift +++ b/iOSClient/Utility/NCUtilityFileSystem.swift @@ -64,6 +64,17 @@ class NCUtilityFileSystem: NSObject { return path } + var directoryScan: String { + guard let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups) else { return "" } + let path = directoryGroup.appendingPathComponent(NCGlobal.shared.appScan).path + if !fileManager.fileExists(atPath: path) { + do { + try fileManager.createDirectory(atPath: path, withIntermediateDirectories: true) + } catch { print("Error: \(error)") } + } + return path + } + @objc var directoryProviderStorage: String { guard let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups) else { return "" } let path = directoryGroup.appendingPathComponent(NCGlobal.shared.directoryProviderStorage).path @@ -86,21 +97,19 @@ class NCUtilityFileSystem: NSObject { } @objc func getDirectoryProviderStorageOcId(_ ocId: String, fileNameView: String) -> String { - let path = directoryProviderStorage + "/" + ocId + "/" + fileNameView + let path = getDirectoryProviderStorageOcId(ocId) + "/" + fileNameView if !fileManager.fileExists(atPath: path) { - do { - try fileManager.createDirectory(atPath: path, withIntermediateDirectories: true) - } catch { print("Error: \(error)") } + fileManager.createFile(atPath: path, contents: nil) } return path } func getDirectoryProviderStorageIconOcId(_ ocId: String, etag: String) -> String { - return directoryProviderStorage + "/" + ocId + "/" + etag + ".small." + NCGlobal.shared.extensionPreview + return getDirectoryProviderStorageOcId(ocId) + "/" + etag + ".small." + NCGlobal.shared.extensionPreview } func getDirectoryProviderStoragePreviewOcId(_ ocId: String, etag: String) -> String { - return directoryProviderStorage + "/" + ocId + "/" + etag + ".preview." + NCGlobal.shared.extensionPreview + return getDirectoryProviderStorageOcId(ocId) + "/" + etag + ".preview." + NCGlobal.shared.extensionPreview } func fileProviderStorageExists(_ metadata: tableMetadata) -> Bool { @@ -151,9 +160,56 @@ class NCUtilityFileSystem: NSObject { return false } - func createDirectoryStandard() { + @objc func createDirectoryStandard() { + guard let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups)?.path else { return } + if !fileManager.fileExists(atPath: directoryDocuments) { try? fileManager.createDirectory(atPath: directoryDocuments, withIntermediateDirectories: true) } + let appDatabaseNextcloud = directoryGroup + "/" + NCGlobal.shared.appDatabaseNextcloud + if !fileManager.fileExists(atPath: appDatabaseNextcloud) { try? fileManager.createDirectory(atPath: appDatabaseNextcloud, withIntermediateDirectories: true) } + if !fileManager.fileExists(atPath: directoryUserData) { try? fileManager.createDirectory(atPath: directoryUserData, withIntermediateDirectories: true) } + if !fileManager.fileExists(atPath: directoryProviderStorage) { try? fileManager.createDirectory(atPath: directoryProviderStorage, withIntermediateDirectories: true) } + let appScan = directoryGroup + "/" + NCGlobal.shared.appScan + if !fileManager.fileExists(atPath: appScan) { try? fileManager.createDirectory(atPath: appScan, withIntermediateDirectories: true) } + if !fileManager.fileExists(atPath: NSTemporaryDirectory()) { try? fileManager.createDirectory(atPath: NSTemporaryDirectory(), withIntermediateDirectories: true) } + // Directory Excluded From Backup + if let url = NSURL(string: directoryDocuments) { + try? url.setResourceValue(true, forKey: URLResourceKey.isExcludedFromBackupKey) + } + if let url = NSURL(string: directoryGroup) { + try? url.setResourceValue(true, forKey: URLResourceKey.isExcludedFromBackupKey) + } + } + + @objc func removeGroupApplicationSupport() { + let path = directoryGroup + "/" + NCGlobal.shared.appApplicationSupport + try? fileManager.removeItem(atPath: path) + } + + @objc func removeGroupLibraryDirectory() { + try? fileManager.removeItem(atPath: directoryScan) + try? fileManager.removeItem(atPath: directoryUserData) + } + + @objc func removeGroupDirectoryProviderStorage() { + try? fileManager.removeItem(atPath: directoryProviderStorage) + } + + @objc func removeDocumentsDirectory() { + try? fileManager.removeItem(atPath: directoryDocuments) + } + + @objc func removeTemporaryDirectory() { + try? fileManager.removeItem(atPath: NSTemporaryDirectory()) + } - guard let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups) else { return } + @objc func emptyTemporaryDirectory() { + do { + let files = try fileManager.contentsOfDirectory(atPath: NSTemporaryDirectory()) + for file in files { + do { + try fileManager.removeItem(atPath: NSTemporaryDirectory() + "/" + file) + } catch { print("Error: \(error)") } + } + } catch { print("Error: \(error)") } } // MARK: - From 8ce485f950662851ae224d637b7cd519cb04adf3 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Wed, 25 Oct 2023 15:55:21 +0200 Subject: [PATCH 70/90] Update CCUtility.m --- iOSClient/Utility/CCUtility.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index ad5b480aa4..5f3ce8441d 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -147,7 +147,7 @@ + (NSString *)createFileName:(NSString *)fileName fileDate:(NSDate *)fileDate fi NSString *numberFileName; if ([fileName length] > 8) numberFileName = [fileName substringWithRange:NSMakeRange(04, 04)]; - else numberFileName = [NCKeychain alloc].incrementalNumber; + else numberFileName = [[NCKeychain alloc] init].incrementalNumber; NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]]; From 84f8b0bcca889389c34c15906fd7ca8c2dd66b98 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Wed, 25 Oct 2023 16:14:52 +0200 Subject: [PATCH 71/90] coding --- .../FileProviderExtension.swift | 4 +-- Share/NCShareExtension.swift | 2 +- iOSClient/AppDelegate.swift | 6 ++-- iOSClient/Data/NCManageDatabase+Avatar.swift | 4 +-- iOSClient/Data/NCManageDatabase+Chunk.swift | 4 +-- .../NCCreateFormUploadConflict.swift | 2 +- .../NCCreateFormUploadVoiceNote.swift | 2 +- iOSClient/Main/NCActionCenter.swift | 2 +- .../E2EE/NCNetworkingE2EEUpload.swift | 2 +- iOSClient/Networking/NCNetworking.swift | 20 ++++++------ .../Scan document/NCScan+CollectionView.swift | 2 +- iOSClient/Utility/CCUtility.h | 8 ----- iOSClient/Utility/CCUtility.m | 31 ------------------- iOSClient/Utility/NCCameraRoll.swift | 6 ++-- iOSClient/Utility/NCUtilityFileSystem.swift | 4 +-- iOSClient/Viewer/NCViewer.swift | 2 +- 16 files changed, 31 insertions(+), 70 deletions(-) diff --git a/File Provider Extension/FileProviderExtension.swift b/File Provider Extension/FileProviderExtension.swift index aa045a4788..27859708af 100644 --- a/File Provider Extension/FileProviderExtension.swift +++ b/File Provider Extension/FileProviderExtension.swift @@ -276,7 +276,7 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate { ocId = outstandingOcIdTemp[ocId]! let atPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(itemIdentifier.rawValue, fileNameView: fileName) let toPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId, fileNameView: fileName) - CCUtility.copyFile(atPath: atPath, toPath: toPath) + NCUtilityFileSystem.shared.copyFile(atPath: atPath, toPath: toPath) } guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) else { return } @@ -418,7 +418,7 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate { // File system let atPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocIdTemp) let toPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId) - CCUtility.copyFile(atPath: atPath, toPath: toPath) + NCUtilityFileSystem.shared.copyFile(atPath: atPath, toPath: toPath) } fileProviderData.shared.signalEnumerator(ocId: metadata.ocId, update: true) diff --git a/Share/NCShareExtension.swift b/Share/NCShareExtension.swift index 48c37cb779..148b2c5e5a 100644 --- a/Share/NCShareExtension.swift +++ b/Share/NCShareExtension.swift @@ -357,7 +357,7 @@ extension NCShareExtension { } completion: { error in if error != .success { NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) - NCUtilityFileSystem.shared.deleteFile(filePath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) + NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) self.uploadErrors.append(metadata) } self.counterUploaded += 1 diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index 89aac303b1..548a728028 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -102,8 +102,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD 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 { @@ -613,7 +613,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD let results = NCManageDatabase.shared.getTableLocalFiles(predicate: NSPredicate(format: "account == %@", account), sorted: "ocId", ascending: false) for result in results { - CCUtility.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(result.ocId)) + NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(result.ocId)) } NCManageDatabase.shared.clearDatabase(account: account, removeAccount: true) diff --git a/iOSClient/Data/NCManageDatabase+Avatar.swift b/iOSClient/Data/NCManageDatabase+Avatar.swift index 3687408f3a..d3b2e2536d 100644 --- a/iOSClient/Data/NCManageDatabase+Avatar.swift +++ b/iOSClient/Data/NCManageDatabase+Avatar.swift @@ -120,7 +120,7 @@ extension NCManageDatabase { realm.refresh() let result = realm.objects(tableAvatar.self).filter("fileName == %@", fileName).first if result == nil { - NCUtilityFileSystem.shared.deleteFile(filePath: fileNameLocalPath) + NCUtilityFileSystem.shared.removeFile(atPath: fileNameLocalPath) return nil } else if result?.loaded == false { return nil @@ -130,7 +130,7 @@ extension NCManageDatabase { NextcloudKit.shared.nkCommonInstance.writeLog("Could not access database: \(error)") } - NCUtilityFileSystem.shared.deleteFile(filePath: fileNameLocalPath) + NCUtilityFileSystem.shared.removeFile(atPath: fileNameLocalPath) return nil } } diff --git a/iOSClient/Data/NCManageDatabase+Chunk.swift b/iOSClient/Data/NCManageDatabase+Chunk.swift index bc2bad06f3..72e216c32b 100644 --- a/iOSClient/Data/NCManageDatabase+Chunk.swift +++ b/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)) realm.delete(result) let filePath = directory + "/\(fileChunk.fileName)" - NCUtilityFileSystem.shared.deleteFile(filePath: filePath) + NCUtilityFileSystem.shared.removeFile(atPath: filePath) } } catch let 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)) for result in results { let filePath = directory + "/\(result.fileName)" - NCUtilityFileSystem.shared.deleteFile(filePath: filePath) + NCUtilityFileSystem.shared.removeFile(atPath: filePath) } realm.delete(results) } diff --git a/iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift b/iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift index f337f6c527..1c532f6d31 100644 --- a/iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift +++ b/iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift @@ -258,7 +258,7 @@ class NCCreateFormUploadConflict: UIViewController { // This is not an asset - [file] if metadata.assetLocalIdentifier.isEmpty || metadata.isExtractFile { let newPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: newFileName) - CCUtility.moveFile(atPath: oldPath, toPath: newPath) + NCUtilityFileSystem.shared.moveFile(atPath: oldPath, toPath: newPath) } metadatasNOConflict.append(metadata) diff --git a/iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift b/iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift index 635ae44e4c..6c06df5cda 100644 --- a/iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift +++ b/iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift @@ -256,7 +256,7 @@ class NCCreateFormUploadVoiceNote: XLFormViewController, NCSelectDelegate, AVAud func dismissAndUpload(_ metadata: tableMetadata) { - CCUtility.copyFile(atPath: self.fileNamePath, toPath: NCUtilityFileSystem.shared.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 }) diff --git a/iOSClient/Main/NCActionCenter.swift b/iOSClient/Main/NCActionCenter.swift index 9466aac71a..05dc7cdb93 100644 --- a/iOSClient/Main/NCActionCenter.swift +++ b/iOSClient/Main/NCActionCenter.swift @@ -85,7 +85,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec navigationController.modalPresentationStyle = .fullScreen appDelegate.window?.rootViewController?.present(navigationController, animated: true) } else { - CCUtility.copyFile(atPath: fileNamePath, toPath: fileNameTemp) + NCUtilityFileSystem.shared.copyFile(atPath: fileNamePath, toPath: fileNameTemp) appDelegate.window?.rootViewController?.present(viewerQuickLook, animated: true) } diff --git a/iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift b/iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift index 4da9dec712..fd46053c15 100644 --- a/iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift +++ b/iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift @@ -159,7 +159,7 @@ class NCNetworkingE2EEUpload: NSObject { if let afError = resultsSendFile.afError, afError.isExplicitlyCancelledError { - CCUtility.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) + NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(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]) diff --git a/iOSClient/Networking/NCNetworking.swift b/iOSClient/Networking/NCNetworking.swift index fa59dc6d09..f8dfc2d2c6 100644 --- a/iOSClient/Networking/NCNetworking.swift +++ b/iOSClient/Networking/NCNetworking.swift @@ -659,7 +659,7 @@ class NCNetworking: NSObject, NKCommonDelegate { NCUtilityFileSystem.shared.moveFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocIdTemp), toPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId)) NCManageDatabase.shared.addLocalFile(metadata: metadata) } else { - NCUtilityFileSystem.shared.deleteFile(filePath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocIdTemp)) + NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocIdTemp)) } 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 { - CCUtility.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) + NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(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]) @@ -685,7 +685,7 @@ class NCNetworking: NSObject, NKCommonDelegate { 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 - CCUtility.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) + NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(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]) })) @@ -787,12 +787,12 @@ class NCNetworking: NSObject, NKCommonDelegate { // DOWNLOAD for metadata in metadatasDownload { - CCUtility.removeFile(atPath: NCUtilityFileSystem.shared.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) } // UPLOAD for metadata in metadatasUpload { - CCUtility.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) + NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) } @@ -800,7 +800,7 @@ class NCNetworking: NSObject, NKCommonDelegate { // BACKGROUND for metadata in metadatasUploadBackground { - CCUtility.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) + NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) } @@ -820,7 +820,7 @@ class NCNetworking: NSObject, NKCommonDelegate { func cancel(metadata: tableMetadata) async { let fileNameLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) - CCUtility.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) + NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) // No session found if metadata.session.isEmpty { @@ -1318,11 +1318,11 @@ class NCNetworking: NSObject, NKCommonDelegate { NCManageDatabase.shared.deleteVideo(metadata: metadata) NCManageDatabase.shared.deleteLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) - NCUtilityFileSystem.shared.deleteFile(filePath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) + NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) if let metadataLivePhoto = NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata) { NCManageDatabase.shared.deleteLocalFile(predicate: NSPredicate(format: "ocId == %@", metadataLivePhoto.ocId)) - NCUtilityFileSystem.shared.deleteFile(filePath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadataLivePhoto.ocId)) + NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadataLivePhoto.ocId)) } } return NKError() @@ -1523,7 +1523,7 @@ class NCNetworking: NSObject, NKCommonDelegate { if ext != extNew { - NCUtilityFileSystem.shared.deleteFile(filePath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId)) + NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(ocId)) NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSourceNetworkForced) } else { diff --git a/iOSClient/Scan document/NCScan+CollectionView.swift b/iOSClient/Scan document/NCScan+CollectionView.swift index c234970c35..84a585897b 100644 --- a/iOSClient/Scan document/NCScan+CollectionView.swift +++ b/iOSClient/Scan document/NCScan+CollectionView.swift @@ -56,7 +56,7 @@ extension NCScan: UICollectionViewDataSource { if let indexPath = self.collectionViewSource.indexPathForItem(at: buttonPosition) { let fileNameAtPath = NCUtilityFileSystem.shared.directoryScan + "/" + self.itemsSource[indexPath.row] - CCUtility.removeFile(atPath: fileNameAtPath) + NCUtilityFileSystem.shared.removeFile(atPath: fileNameAtPath) self.itemsSource.remove(at: indexPath.row) self.collectionViewSource.deleteItems(at: [indexPath]) diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 66f18c147c..6137169f38 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -34,8 +34,6 @@ @interface CCUtility : NSObject -+ (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL; - + (NSString *)dateDiff:(NSDate *)convertedDate; + (NSString *)transformedSize:(int64_t)value; @@ -47,12 +45,6 @@ + (NSString *)createFileName:(NSString *)fileName fileDate:(NSDate *)fileDate fileType:(PHAssetMediaType)fileType keyFileName:(NSString *)keyFileName keyFileNameType:(NSString *)keyFileNameType keyFileNameOriginal:(NSString *)keyFileNameOriginal forcedNewFileName:(BOOL)forcedNewFileName; + (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; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 5f3ce8441d..f608baf375 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -28,14 +28,6 @@ #import #include - -#define INTRO_MessageType @"MessageType_" - -#define E2E_certificate @"EndToEndCertificate_" -#define E2E_PrivateKey @"EndToEndPrivateKey_" -#define E2E_Passphrase @"EndToEndPassphrase_" -#define E2E_PublicKey @"EndToEndPublicKeyServer_" - @implementation CCUtility #pragma -------------------------------------------------------------------------------------------- @@ -262,29 +254,6 @@ + (NSString *)getTitleSectionDate:(NSDate *)date return title; } -+ (void)moveFileAtPath:(NSString *)atPath toPath:(NSString *)toPath -{ - [[NSFileManager defaultManager] removeItemAtPath:toPath error:nil]; - [[NSFileManager defaultManager] copyItemAtPath:atPath toPath:toPath error:nil]; - [[NSFileManager defaultManager] removeItemAtPath:atPath error:nil]; -} - -+ (void)copyFileAtPath:(NSString *)atPath toPath:(NSString *)toPath -{ - [[NSFileManager defaultManager] removeItemAtPath:toPath error:nil]; - [[NSFileManager defaultManager] copyItemAtPath:atPath toPath:toPath error:nil]; -} - -+ (void)removeFileAtPath:(NSString *)atPath -{ - [[NSFileManager defaultManager] removeItemAtPath:atPath error:nil]; -} - -+ (void)createDirectoryAtPath:(NSString *)atPath -{ - [[NSFileManager defaultManager] createDirectoryAtPath:atPath withIntermediateDirectories:true attributes:nil error:nil]; -} - + (NSString *)returnPathfromServerUrl:(NSString *)serverUrl urlBase:(NSString *)urlBase userId:(NSString *)userId account:(NSString *)account { NSString *homeServer = [[NCUtilityFileSystem shared] getHomeServerWithUrlBase:urlBase userId:userId]; diff --git a/iOSClient/Utility/NCCameraRoll.swift b/iOSClient/Utility/NCCameraRoll.swift index b7a8494136..b84bf1dfc9 100644 --- a/iOSClient/Utility/NCCameraRoll.swift +++ b/iOSClient/Utility/NCCameraRoll.swift @@ -178,7 +178,7 @@ class NCCameraRoll: NSObject { guard let ciImage = CIImage(data: data), let colorSpace = ciImage.colorSpace, let dataJPEG = CIContext().jpegRepresentation(of: ciImage, colorSpace: colorSpace) else { return callCompletionWithError() } data = dataJPEG } - NCUtilityFileSystem.shared.deleteFile(filePath: fileNamePath) + NCUtilityFileSystem.shared.removeFile(atPath: fileNamePath) do { try data.write(to: URL(fileURLWithPath: fileNamePath), options: .atomic) } catch { return callCompletionWithError() } @@ -200,7 +200,7 @@ class NCCameraRoll: NSObject { PHImageManager.default().requestAVAsset(forVideo: asset, options: options) { asset, _, _ in if let asset = asset as? AVURLAsset { - NCUtilityFileSystem.shared.deleteFile(filePath: fileNamePath) + NCUtilityFileSystem.shared.removeFile(atPath: fileNamePath) do { try FileManager.default.copyItem(at: asset.url, to: URL(fileURLWithPath: fileNamePath)) metadata.creationDate = creationDate as NSDate @@ -268,7 +268,7 @@ class NCCameraRoll: NSObject { break } guard let videoResource = videoResource else { return completion(nil) } - NCUtilityFileSystem.shared.deleteFile(filePath: fileNamePath) + NCUtilityFileSystem.shared.removeFile(atPath: fileNamePath) PHAssetResourceManager.default().writeData(for: videoResource, toFile: URL(fileURLWithPath: fileNamePath), options: nil) { error in if error != nil { return completion(nil) } let metadataLivePhoto = NCManageDatabase.shared.createMetadata(account: metadata.account, diff --git a/iOSClient/Utility/NCUtilityFileSystem.swift b/iOSClient/Utility/NCUtilityFileSystem.swift index d793b245dc..78596ddf75 100644 --- a/iOSClient/Utility/NCUtilityFileSystem.swift +++ b/iOSClient/Utility/NCUtilityFileSystem.swift @@ -264,10 +264,10 @@ class NCUtilityFileSystem: NSObject { } } - @objc func deleteFile(filePath: String) { + @objc func removeFile(atPath: String) { do { - try FileManager.default.removeItem(atPath: filePath) + try FileManager.default.removeItem(atPath: atPath) } catch { print(error) } diff --git a/iOSClient/Viewer/NCViewer.swift b/iOSClient/Viewer/NCViewer.swift index ffba4b4794..8ea933e41e 100644 --- a/iOSClient/Viewer/NCViewer.swift +++ b/iOSClient/Viewer/NCViewer.swift @@ -228,7 +228,7 @@ class NCViewer: NSObject { let item = URL(fileURLWithPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)) if QLPreviewController.canPreview(item as QLPreviewItem) { let fileNamePath = NSTemporaryDirectory() + metadata.fileNameView - CCUtility.copyFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView), toPath: fileNamePath) + NCUtilityFileSystem.shared.copyFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView), toPath: fileNamePath) let viewerQuickLook = NCViewerQuickLook(with: URL(fileURLWithPath: fileNamePath), isEditingEnabled: false, metadata: metadata) viewController.present(viewerQuickLook, animated: true) } else { From 1af164f65fe4eacc5e707773e0e4d134d86c0ac0 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Wed, 25 Oct 2023 16:15:41 +0200 Subject: [PATCH 72/90] Update NCNetworkingProcessUpload.swift --- iOSClient/Networking/NCNetworkingProcessUpload.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iOSClient/Networking/NCNetworkingProcessUpload.swift b/iOSClient/Networking/NCNetworkingProcessUpload.swift index 4a1de619b2..14cebab08e 100644 --- a/iOSClient/Networking/NCNetworkingProcessUpload.swift +++ b/iOSClient/Networking/NCNetworkingProcessUpload.swift @@ -272,7 +272,7 @@ class NCNetworkingProcessUpload: NSObject { let metadatasUploadShareExtension = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "session == %@ AND sessionSelector == %@", NextcloudKit.shared.nkCommonInstance.sessionIdentifierUpload, NCGlobal.shared.selectorUploadFileShareExtension)) for metadata in metadatasUploadShareExtension { NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) - NCUtilityFileSystem.shared.deleteFile(filePath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) + NCUtilityFileSystem.shared.removeFile(atPath: NCUtilityFileSystem.shared.getDirectoryProviderStorageOcId(metadata.ocId)) } // verify metadataStatusInUpload (BACKGROUND) From acf40839f502399bd04b56ec70b4286b87344f35 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Wed, 25 Oct 2023 16:39:03 +0200 Subject: [PATCH 73/90] coding --- Share/NCShareCell.swift | 2 +- Widget/Files/FilesData.swift | 2 +- Widget/Lockscreen/LockscreenData.swift | 4 ++-- .../NCCollectionViewCommon.swift | 18 +++++++++--------- .../Main/Collection Common/NCGridCell.swift | 2 +- .../Main/Collection Common/NCListCell.swift | 2 +- .../NCCreateFormUploadConflict.swift | 8 ++++---- .../NCSectionHeaderMenu.swift | 4 ++-- iOSClient/More/NCMore.swift | 4 ++-- iOSClient/Select/NCSelect.swift | 2 +- iOSClient/Settings/CCAdvanced.m | 4 ++-- .../NCShareAdvancePermissionHeader.swift | 2 +- iOSClient/Share/NCSharePaging.swift | 2 +- iOSClient/Transfers/NCTransferCell.swift | 2 +- iOSClient/Transfers/NCTransfers.swift | 12 ++++++------ .../NCTrashListCell+NCTrashCellProtocol.swift | 2 +- iOSClient/Trash/NCTrash+CollectionView.swift | 4 ++-- iOSClient/Utility/CCUtility.h | 1 - iOSClient/Utility/CCUtility.m | 6 ------ iOSClient/Utility/NCUtilityFileSystem.swift | 6 ++++++ .../NCViewerMediaDetailView.swift | 2 +- 21 files changed, 45 insertions(+), 46 deletions(-) diff --git a/Share/NCShareCell.swift b/Share/NCShareCell.swift index 286ea4f729..39d68c4d15 100644 --- a/Share/NCShareCell.swift +++ b/Share/NCShareCell.swift @@ -59,7 +59,7 @@ class NCShareCell: UITableViewCell { fileNameCell?.text = 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) } diff --git a/Widget/Files/FilesData.swift b/Widget/Files/FilesData.swift index 5b5194b776..0e194469ca 100644 --- a/Widget/Files/FilesData.swift +++ b/Widget/Files/FilesData.swift @@ -218,7 +218,7 @@ func getFilesDataEntry(configuration: AccountIntent?, isPreview: Bool, displaySi guard !isLive(file: file, files: files) else { continue } // 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 guard var path = NCUtilityFileSystem.shared.getPath(path: file.path, user: file.user, fileName: file.fileName).urlEncoded else { continue } diff --git a/Widget/Lockscreen/LockscreenData.swift b/Widget/Lockscreen/LockscreenData.swift index 0689a466ba..9e5a8c7c34 100644 --- a/Widget/Lockscreen/LockscreenData.swift +++ b/Widget/Lockscreen/LockscreenData.swift @@ -82,7 +82,7 @@ func getLockscreenDataEntry(configuration: AccountIntent?, isPreview: Bool, fami if userProfile.quotaRelative > 0 { quotaRelative = Float(userProfile.quotaRelative) / 100 } - let quotaUsed: String = CCUtility.transformedSize(userProfile.quotaUsed) + let quotaUsed: String = NCUtilityFileSystem.shared.transformedSize(userProfile.quotaUsed) var quotaTotal: String = "" switch userProfile.quotaTotal { @@ -93,7 +93,7 @@ func getLockscreenDataEntry(configuration: AccountIntent?, isPreview: Bool, fami case -3: quotaTotal = "" 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)) } else { diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index e9c7c662c7..af116e94e9 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -539,12 +539,12 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS cell.fileProgressView?.progress = progressNumber.floatValue cell.setButtonMore(named: NCGlobal.shared.buttonMoreStop, image: NCBrandColor.cacheImages.buttonStop) 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 { if totalBytes > 0 { - cell.fileInfoLabel?.text = CCUtility.transformedSize(totalBytesExpected) + " - ↑ " + CCUtility.transformedSize(totalBytes) + cell.fileInfoLabel?.text = NCUtilityFileSystem.shared.transformedSize(totalBytesExpected) + " - ↑ " + NCUtilityFileSystem.shared.transformedSize(totalBytes) } else { - cell.fileInfoLabel?.text = CCUtility.transformedSize(totalBytesExpected) + " - ↑ …" + cell.fileInfoLabel?.text = NCUtilityFileSystem.shared.transformedSize(totalBytesExpected) + " - ↑ …" } } } @@ -1420,19 +1420,19 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { // Write status on Label Info switch metadata.status { 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: - 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: - cell.fileInfoLabel?.text = CCUtility.transformedSize(metadata.size) + " - ↓ …" + cell.fileInfoLabel?.text = NCUtilityFileSystem.shared.transformedSize(metadata.size) + " - ↓ …" 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 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 case NCGlobal.shared.metadataStatusUploading: - cell.fileInfoLabel?.text = CCUtility.transformedSize(metadata.size) + " - ↑ …" + cell.fileInfoLabel?.text = NCUtilityFileSystem.shared.transformedSize(metadata.size) + " - ↑ …" cell.fileLocalImage?.image = nil case NCGlobal.shared.metadataStatusUploadError: if metadata.sessionError.isEmpty { diff --git a/iOSClient/Main/Collection Common/NCGridCell.swift b/iOSClient/Main/Collection Common/NCGridCell.swift index d7f72b8724..5a25b29fb1 100644 --- a/iOSClient/Main/Collection Common/NCGridCell.swift +++ b/iOSClient/Main/Collection Common/NCGridCell.swift @@ -209,7 +209,7 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto dateFormatter.timeStyle = .none 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) { diff --git a/iOSClient/Main/Collection Common/NCListCell.swift b/iOSClient/Main/Collection Common/NCListCell.swift index af829f1959..93ef81e361 100755 --- a/iOSClient/Main/Collection Common/NCListCell.swift +++ b/iOSClient/Main/Collection Common/NCListCell.swift @@ -271,7 +271,7 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto } 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) { diff --git a/iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift b/iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift index 1c532f6d31..37b9ae6908 100644 --- a/iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift +++ b/iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift @@ -341,7 +341,7 @@ extension NCCreateFormUploadConflict: UITableViewDataSource { 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) { cell.switchAlreadyExistingFile.isOn = true @@ -380,7 +380,7 @@ extension NCCreateFormUploadConflict: UITableViewDataSource { let fileDictionary = try FileManager.default.attributesOfItem(atPath: fileNamePath) 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)") } @@ -404,7 +404,7 @@ extension NCCreateFormUploadConflict: UITableViewDataSource { 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)") } } } @@ -423,7 +423,7 @@ extension NCCreateFormUploadConflict: UITableViewDataSource { let fileDictionary = try FileManager.default.attributesOfItem(atPath: filePathNewFile) 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)") } diff --git a/iOSClient/Main/Section Header Footer/NCSectionHeaderMenu.swift b/iOSClient/Main/Section Header Footer/NCSectionHeaderMenu.swift index a682cc3944..2b8f0662aa 100644 --- a/iOSClient/Main/Section Header Footer/NCSectionHeaderMenu.swift +++ b/iOSClient/Main/Section Header Footer/NCSectionHeaderMenu.swift @@ -319,9 +319,9 @@ class NCSectionFooter: UICollectionReusableView, NCSectionFooterDelegate { } if files > 1 { - filesText = "\(files) " + NSLocalizedString("_files_", comment: "") + " " + CCUtility.transformedSize(size) + filesText = "\(files) " + NSLocalizedString("_files_", comment: "") + " " + NCUtilityFileSystem.shared.transformedSize(size) } else if files == 1 { - filesText = "1 " + NSLocalizedString("_file_", comment: "") + " " + CCUtility.transformedSize(size) + filesText = "1 " + NSLocalizedString("_file_", comment: "") + " " + NCUtilityFileSystem.shared.transformedSize(size) } if foldersText.isEmpty { diff --git a/iOSClient/More/NCMore.swift b/iOSClient/More/NCMore.swift index ef878a57d4..ef428e1cf3 100644 --- a/iOSClient/More/NCMore.swift +++ b/iOSClient/More/NCMore.swift @@ -208,10 +208,10 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource { case -3: quota = NSLocalizedString("_quota_space_unlimited_", comment: "") 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) } diff --git a/iOSClient/Select/NCSelect.swift b/iOSClient/Select/NCSelect.swift index ff7544c987..70661c7bda 100644 --- a/iOSClient/Select/NCSelect.swift +++ b/iOSClient/Select/NCSelect.swift @@ -391,7 +391,7 @@ extension NCSelect: UICollectionViewDataSource { } 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 if NCManageDatabase.shared.getTableLocalFile(ocId: metadata.ocId) != nil { diff --git a/iOSClient/Settings/CCAdvanced.m b/iOSClient/Settings/CCAdvanced.m index a9b7d517e9..dbe608391d 100755 --- a/iOSClient/Settings/CCAdvanced.m +++ b/iOSClient/Settings/CCAdvanced.m @@ -432,8 +432,8 @@ - (void)calculateSize dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSString *directory = [[NCUtilityFileSystem shared] directoryProviderStorage]; 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(), ^{ [self.tableView reloadData]; }); diff --git a/iOSClient/Share/Advanced/NCShareAdvancePermissionHeader.swift b/iOSClient/Share/Advanced/NCShareAdvancePermissionHeader.swift index 28e9c79b3b..f7d849c105 100644 --- a/iOSClient/Share/Advanced/NCShareAdvancePermissionHeader.swift +++ b/iOSClient/Share/Advanced/NCShareAdvancePermissionHeader.swift @@ -46,6 +46,6 @@ class NCShareAdvancePermissionHeader: UIView { fileName.text = metadata.fileNameView fileName.textColor = .label 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) } } diff --git a/iOSClient/Share/NCSharePaging.swift b/iOSClient/Share/NCSharePaging.swift index d3d24a865f..9cf4bc2543 100644 --- a/iOSClient/Share/NCSharePaging.swift +++ b/iOSClient/Share/NCSharePaging.swift @@ -297,7 +297,7 @@ class NCSharePagingView: PagingView { } else { 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.creation.text = NSLocalizedString("_creation_", comment: "") + " " + dateFormatter.string(from: metadata.creationDate as Date) headerView.creation.textColor = .systemGray diff --git a/iOSClient/Transfers/NCTransferCell.swift b/iOSClient/Transfers/NCTransferCell.swift index d761b1d3b6..4b764e9350 100755 --- a/iOSClient/Transfers/NCTransferCell.swift +++ b/iOSClient/Transfers/NCTransferCell.swift @@ -141,7 +141,7 @@ class NCTransferCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellP } 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) } } diff --git a/iOSClient/Transfers/NCTransfers.swift b/iOSClient/Transfers/NCTransfers.swift index 694de0d188..a60d188762 100644 --- a/iOSClient/Transfers/NCTransfers.swift +++ b/iOSClient/Transfers/NCTransfers.swift @@ -196,7 +196,7 @@ class NCTransfers: NCCollectionViewCommon, NCTransferCellDelegate { } else { 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 { cell.progressView.isHidden = false } else { @@ -206,22 +206,22 @@ class NCTransfers: NCCollectionViewCommon, NCTransferCellDelegate { switch metadata.status { case NCGlobal.shared.metadataStatusWaitDownload: 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: 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: 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: cell.labelStatus.text = NSLocalizedString("_status_wait_upload_", comment: "") cell.labelInfo.text = "" case NCGlobal.shared.metadataStatusInUpload: 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: 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: cell.labelStatus.text = NSLocalizedString("_status_upload_error_", comment: "") cell.labelInfo.text = metadata.sessionError diff --git a/iOSClient/Trash/Cell/NCTrashListCell+NCTrashCellProtocol.swift b/iOSClient/Trash/Cell/NCTrashListCell+NCTrashCellProtocol.swift index 145c6f103f..bbb65a20a6 100644 --- a/iOSClient/Trash/Cell/NCTrashListCell+NCTrashCellProtocol.swift +++ b/iOSClient/Trash/Cell/NCTrashListCell+NCTrashCellProtocol.swift @@ -162,7 +162,7 @@ extension NCTrashCellProtocol where Self: UICollectionViewCell { self.imageItem.image = NCBrandColor.cacheImages.folder } else { 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 ?? "") } diff --git a/iOSClient/Trash/NCTrash+CollectionView.swift b/iOSClient/Trash/NCTrash+CollectionView.swift index 6f2c7b184c..01df7bfd74 100644 --- a/iOSClient/Trash/NCTrash+CollectionView.swift +++ b/iOSClient/Trash/NCTrash+CollectionView.swift @@ -123,9 +123,9 @@ extension NCTrash: UICollectionViewDataSource { } if files > 1 { - filesText = "\(files) " + NSLocalizedString("_files_", comment: "") + " " + CCUtility.transformedSize(size) + filesText = "\(files) " + NSLocalizedString("_files_", comment: "") + " " + NCUtilityFileSystem.shared.transformedSize(size) } else if files == 1 { - filesText = "1 " + NSLocalizedString("_file_", comment: "") + " " + CCUtility.transformedSize(size) + filesText = "1 " + NSLocalizedString("_file_", comment: "") + " " + NCUtilityFileSystem.shared.transformedSize(size) } if foldersText.isEmpty { diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 6137169f38..314e19b986 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -35,7 +35,6 @@ @interface CCUtility : NSObject + (NSString *)dateDiff:(NSDate *)convertedDate; -+ (NSString *)transformedSize:(int64_t)value; + (NSString *)removeForbiddenCharactersServer:(NSString *)fileName; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index f608baf375..59c2259b57 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -71,12 +71,6 @@ + (NSString *)dateDiff:(NSDate *) convertedDate } } -+ (NSString *)transformedSize:(int64_t)value -{ - NSString *string = [NSByteCountFormatter stringFromByteCount:value countStyle:NSByteCountFormatterCountStyleBinary]; - return string; -} - // Remove do not forbidden characters for Nextcloud Server + (NSString *)removeForbiddenCharactersServer:(NSString *)fileName { diff --git a/iOSClient/Utility/NCUtilityFileSystem.swift b/iOSClient/Utility/NCUtilityFileSystem.swift index 78596ddf75..7d1fcb3dab 100644 --- a/iOSClient/Utility/NCUtilityFileSystem.swift +++ b/iOSClient/Utility/NCUtilityFileSystem.swift @@ -434,6 +434,12 @@ class NCUtilityFileSystem: NSObject { return totalSize } + @objc func transformedSize(_ bytes: Int64) -> String { + let formatter: ByteCountFormatter = ByteCountFormatter() + formatter.countStyle = .binary + return formatter.string(fromByteCount: bytes) + } + func cleanUp(directory: String, days: TimeInterval) { if days == 0 { return} diff --git a/iOSClient/Viewer/NCViewerMedia/NCViewerMediaDetailView.swift b/iOSClient/Viewer/NCViewerMedia/NCViewerMediaDetailView.swift index 4ea4c5ca77..955fa4df78 100644 --- a/iOSClient/Viewer/NCViewerMedia/NCViewerMediaDetailView.swift +++ b/iOSClient/Viewer/NCViewerMedia/NCViewerMediaDetailView.swift @@ -140,7 +140,7 @@ class NCViewerMediaDetailView: UIView { } nameLabel.text = (metadata.fileNameView as NSString).deletingPathExtension - sizeLabel.text = CCUtility.transformedSize(metadata.size) + sizeLabel.text = NCUtilityFileSystem.shared.transformedSize(metadata.size) if let shutterSpeedApex = exif.shutterSpeedApex { prepareLensInfoViewsForData() From 5bb0b24031769bd2037fb49398779881f24b1e42 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Wed, 25 Oct 2023 17:29:38 +0200 Subject: [PATCH 74/90] coding --- .../Extensions/UIAlertController+Extension.swift | 4 ++-- .../Create cloud/NCCreateFormUploadVoiceNote.swift | 4 ++-- .../E2EE/NCNetworkingE2EECreateFolder.swift | 2 +- iOSClient/Networking/NCNetworking.swift | 6 ++---- iOSClient/Settings/NCManageAutoUploadFileName.swift | 2 +- iOSClient/Utility/CCUtility.h | 6 ------ iOSClient/Utility/CCUtility.m | 12 ------------ iOSClient/Utility/NCUtility.swift | 12 ++++++++++++ 8 files changed, 20 insertions(+), 28 deletions(-) diff --git a/iOSClient/Extensions/UIAlertController+Extension.swift b/iOSClient/Extensions/UIAlertController+Extension.swift index 55cdcf96c2..8965e2dfbe 100644 --- a/iOSClient/Extensions/UIAlertController+Extension.swift +++ b/iOSClient/Extensions/UIAlertController+Extension.swift @@ -73,8 +73,8 @@ extension UIAlertController { forName: UITextField.textDidChangeNotification, object: alertController.textFields?.first, 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.removeForbiddenCharactersServer(text).trimmingCharacters(in: .whitespaces) okAction.isEnabled = !folderName.isEmpty && folderName != "." && folderName != ".." } diff --git a/iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift b/iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift index 6c06df5cda..290c974bc8 100644 --- a/iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift +++ b/iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift @@ -167,8 +167,8 @@ class NCCreateFormUploadVoiceNote: XLFormViewController, NCSelectDelegate, AVAud 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.removeForbiddenCharactersServer(fileNameNew) } formRow.value = self.fileName diff --git a/iOSClient/Networking/E2EE/NCNetworkingE2EECreateFolder.swift b/iOSClient/Networking/E2EE/NCNetworkingE2EECreateFolder.swift index a417f24998..3d5de155c0 100644 --- a/iOSClient/Networking/E2EE/NCNetworkingE2EECreateFolder.swift +++ b/iOSClient/Networking/E2EE/NCNetworkingE2EECreateFolder.swift @@ -32,7 +32,7 @@ class NCNetworkingE2EECreateFolder: NSObject { let fileNameIdentifier = NCNetworkingE2EE.shared.generateRandomIdentifier() let serverUrlFileName = serverUrl + "/" + fileNameIdentifier - let fileNameFolder = NCUtilityFileSystem.shared.createFileName(CCUtility.removeForbiddenCharactersServer(fileName)!, serverUrl: serverUrl, account: account) + let fileNameFolder = NCUtilityFileSystem.shared.createFileName(NCUtility.shared.removeForbiddenCharactersServer(fileName), serverUrl: serverUrl, account: account) if fileNameFolder.isEmpty { return NKError(errorCode: NCGlobal.shared.errorUnexpectedResponseFromDB, errorDescription: NSLocalizedString("_e2e_error_", comment: "")) } diff --git a/iOSClient/Networking/NCNetworking.swift b/iOSClient/Networking/NCNetworking.swift index f8dfc2d2c6..0c5f246aa6 100644 --- a/iOSClient/Networking/NCNetworking.swift +++ b/iOSClient/Networking/NCNetworking.swift @@ -1197,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) { - var fileNameFolder = CCUtility.removeForbiddenCharactersServer(fileName)! + var fileNameFolder = NCUtility.shared.removeForbiddenCharactersServer(fileName) if !overwrite { fileNameFolder = NCUtilityFileSystem.shared.createFileName(fileNameFolder, serverUrl: serverUrl, account: account) @@ -1490,9 +1490,7 @@ class NCNetworking: NSObject, NKCommonDelegate { if !metadata.permissions.isEmpty && !permission { 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.removeForbiddenCharactersServer(fileNameNew) if fileNameNew.isEmpty || fileNameNew == metadata.fileNameView { return completion(NKError()) } diff --git a/iOSClient/Settings/NCManageAutoUploadFileName.swift b/iOSClient/Settings/NCManageAutoUploadFileName.swift index df361c1451..f6e33c6814 100644 --- a/iOSClient/Settings/NCManageAutoUploadFileName.swift +++ b/iOSClient/Settings/NCManageAutoUploadFileName.swift @@ -156,7 +156,7 @@ class NCManageAutoUploadFileName: XLFormViewController { self.form.delegate = nil if let fileName = fileName { - formRow.value = CCUtility.removeForbiddenCharactersServer(fileName) + formRow.value = NCUtility.shared.removeForbiddenCharactersServer(fileName) } self.form.delegate = self diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 314e19b986..4c508212bb 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -35,18 +35,12 @@ @interface CCUtility : NSObject + (NSString *)dateDiff:(NSDate *)convertedDate; - -+ (NSString *)removeForbiddenCharactersServer:(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 *)getTitleSectionDate:(NSDate *)date; + (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 *)getMimeType:(NSString *)fileNameView; // ===== Share Permissions ===== diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 59c2259b57..5a81f25063 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -71,18 +71,6 @@ + (NSString *)dateDiff:(NSDate *) convertedDate } } -// Remove do not forbidden characters for Nextcloud Server -+ (NSString *)removeForbiddenCharactersServer:(NSString *)fileName -{ - NSArray *arrayForbiddenCharacters = [NSArray arrayWithObjects:@"/", nil]; - - for (NSString *currentCharacter in arrayForbiddenCharacters) { - fileName = [fileName stringByReplacingOccurrencesOfString:currentCharacter withString:@""]; - } - - return fileName; -} - + (NSString*)stringAppendServerUrl:(NSString *)serverUrl addFileName:(NSString *)addFileName { NSString *result; diff --git a/iOSClient/Utility/NCUtility.swift b/iOSClient/Utility/NCUtility.swift index abf1ab8cfa..477e1194aa 100644 --- a/iOSClient/Utility/NCUtility.swift +++ b/iOSClient/Utility/NCUtility.swift @@ -859,4 +859,16 @@ class NCUtility: NSObject { } } } + + func removeForbiddenCharactersServer(_ fileName: String) -> String { + + var fileName = fileName + let arrayForbiddenCharacters = ["/"]; + + for character in arrayForbiddenCharacters { + fileName = fileName.replacingOccurrences(of: character, with: "") + } + return fileName + } + } From d2a9b45da9d936fec21bd62c2c7d8b323a47eb7a Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Wed, 25 Oct 2023 17:32:16 +0200 Subject: [PATCH 75/90] fix --- iOSClient/AppDelegate.swift | 2 +- iOSClient/Utility/NCUtility.swift | 20 +------------------- iOSClient/Utility/NCUtilityFileSystem.swift | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index 548a728028..da62a52352 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -86,7 +86,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD NCUtilityFileSystem.shared.createDirectoryStandard() NCUtilityFileSystem.shared.emptyTemporaryDirectory() - NCUtility.shared.clearCacheDirectory("com.limit-point.LivePhoto") + NCUtilityFileSystem.shared.clearCacheDirectory("com.limit-point.LivePhoto") // Activated singleton _ = NCActionCenter.shared diff --git a/iOSClient/Utility/NCUtility.swift b/iOSClient/Utility/NCUtility.swift index 477e1194aa..5693ad8d49 100644 --- a/iOSClient/Utility/NCUtility.swift +++ b/iOSClient/Utility/NCUtility.swift @@ -842,28 +842,10 @@ class NCUtility: NSObject { return (usedmegabytes, totalmegabytes) } - func clearCacheDirectory(_ directory: String) { - if let cacheURL = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first { - do { - let directoryURL = cacheURL.appendingPathComponent(directory, isDirectory: true) - let directoryContents = try FileManager.default.contentsOfDirectory(at: directoryURL, includingPropertiesForKeys: nil, options: []) - for file in directoryContents { - do { - try FileManager.default.removeItem(at: file) - } catch let error as NSError { - debugPrint("Ooops! Something went wrong: \(error)") - } - } - } catch let error as NSError { - print(error.localizedDescription) - } - } - } - func removeForbiddenCharactersServer(_ fileName: String) -> String { var fileName = fileName - let arrayForbiddenCharacters = ["/"]; + let arrayForbiddenCharacters = ["/"] for character in arrayForbiddenCharacters { fileName = fileName.replacingOccurrences(of: character, with: "") diff --git a/iOSClient/Utility/NCUtilityFileSystem.swift b/iOSClient/Utility/NCUtilityFileSystem.swift index 7d1fcb3dab..46f1055c7b 100644 --- a/iOSClient/Utility/NCUtilityFileSystem.swift +++ b/iOSClient/Utility/NCUtilityFileSystem.swift @@ -491,4 +491,22 @@ class NCUtilityFileSystem: NSObject { } } } + + func clearCacheDirectory(_ directory: String) { + if let cacheURL = fileManager.urls(for: .cachesDirectory, in: .userDomainMask).first { + do { + let directoryURL = cacheURL.appendingPathComponent(directory, isDirectory: true) + let directoryContents = try fileManager.contentsOfDirectory(at: directoryURL, includingPropertiesForKeys: nil, options: []) + for file in directoryContents { + do { + try fileManager.removeItem(at: file) + } catch let error as NSError { + debugPrint("Ooops! Something went wrong: \(error)") + } + } + } catch let error as NSError { + print(error.localizedDescription) + } + } + } } From cc108a9c03aadd0310060f60a25e6b91f66615b1 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Wed, 25 Oct 2023 17:46:40 +0200 Subject: [PATCH 76/90] fix --- .../NCCollectionViewCommon.swift | 24 ++- iOSClient/Share/NCShare.swift | 9 +- iOSClient/Utility/NCUtility.swift | 184 ++---------------- .../NCViewerMedia/NCViewerMediaPage.swift | 26 ++- 4 files changed, 73 insertions(+), 170 deletions(-) diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index af116e94e9..3887f89e3b 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -1233,7 +1233,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { } 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" NCNetworking.shared.downloadAvatar(user: ownerId, dispalyName: nil, fileName: fileName, cell: cell, view: collectionView, cellImageView: cell.filePreviewImageView) } @@ -1455,7 +1455,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { cell.fileLocalImage?.image = nil cell.hideButtonShare(true) cell.hideButtonMore(true) - if let ownerId = NCUtility.shared.getAvatarFromIconUrl(metadata: metadata) { + if let ownerId = getAvatarFromIconUrl(metadata: metadata) { cell.fileUser = ownerId } } @@ -1703,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: - class NCOperationUnifiedSearch: ConcurrentOperation { diff --git a/iOSClient/Share/NCShare.swift b/iOSClient/Share/NCShare.swift index 9d2775cc49..b93e8ed9ae 100644 --- a/iOSClient/Share/NCShare.swift +++ b/iOSClient/Share/NCShare.swift @@ -204,8 +204,15 @@ class NCShare: UIViewController, NCShareNetworkingDelegate, NCSharePagingContent // MARK: - IBAction @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 } - if searchString.contains("@"), !NCUtility.shared.isValidEmail(searchString) { return } + if searchString.contains("@"), !isValidEmail(searchString) { return } networking?.getSharees(searchString: searchString) } diff --git a/iOSClient/Utility/NCUtility.swift b/iOSClient/Utility/NCUtility.swift index 5693ad8d49..a3bf1a39fc 100644 --- a/iOSClient/Utility/NCUtility.swift +++ b/iOSClient/Utility/NCUtility.swift @@ -121,21 +121,21 @@ class NCUtility: NSObject { } #endif - @objc func isSimulatorOrTestFlight() -> Bool { + func isSimulatorOrTestFlight() -> Bool { guard let path = Bundle.main.appStoreReceiptURL?.path else { return false } return path.contains("CoreSimulator") || path.contains("sandboxReceipt") } - @objc func isSimulator() -> Bool { + func isSimulator() -> Bool { guard let path = Bundle.main.appStoreReceiptURL?.path else { return false } return path.contains("CoreSimulator") } - @objc func isRichDocument(_ metadata: tableMetadata) -> Bool { + func isRichDocument(_ metadata: tableMetadata) -> Bool { guard let mimeType = CCUtility.getMimeType(metadata.fileNameView) else { return false @@ -164,7 +164,7 @@ class NCUtility: NSObject { return false } - @objc func isDirectEditing(account: String, contentType: String) -> [String] { + func isDirectEditing(account: String, contentType: String) -> [String] { var editor: [String] = [] @@ -195,11 +195,6 @@ class NCUtility: NSObject { } } - // HARDCODE - // if editor.count == 0 { - // editor.append(NCGlobal.shared.editorText) - // } - return Array(Set(editor)) } @@ -223,7 +218,7 @@ class NCUtility: NSObject { } #endif - @objc func permissionsContainsString(_ metadataPermissions: String, permissions: String) -> Bool { + func permissionsContainsString(_ metadataPermissions: String, permissions: String) -> Bool { for char in permissions { if metadataPermissions.contains(char) == false { @@ -233,7 +228,7 @@ class NCUtility: NSObject { return true } - @objc func getCustomUserAgentNCText() -> String { + func getCustomUserAgentNCText() -> String { if UIDevice.current.userInterfaceIdiom == .phone { // NOTE: Hardcoded (May 2022) // Tested for iPhone SE (1st), iOS 12 iPhone Pro Max, iOS 15.4 @@ -245,7 +240,7 @@ class NCUtility: NSObject { } } - @objc func getCustomUserAgentOnlyOffice() -> String { + func getCustomUserAgentOnlyOffice() -> String { let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString")! if UIDevice.current.userInterfaceIdiom == .pad { @@ -441,33 +436,22 @@ class NCUtility: NSObject { let fileName = userBaseUrl.userBaseUrl + "-" + user + ".png" let localFilePath = NCUtilityFileSystem.shared.directoryUserData + "/" + fileName - if let localImage = UIImage(contentsOfFile: localFilePath) { - return createAvatar(image: localImage, size: 30) + if var localImage = UIImage(contentsOfFile: localFilePath) { + let rect = CGRect(x: 0, y: 0, width: 30, height: 30) + UIGraphicsBeginImageContextWithOptions(rect.size, false, 3.0) + UIBezierPath(roundedRect: rect, cornerRadius: rect.size.height).addClip() + localImage.draw(in: rect) + localImage = UIGraphicsGetImageFromCurrentImageContext() ?? localImage + UIGraphicsEndImageContext() + return localImage } else if let loadedAvatar = NCManageDatabase.shared.getImageAvatarLoaded(fileName: fileName) { return loadedAvatar } else if let displayName = displayName, !displayName.isEmpty, let avatarImg = createAvatar(displayName: displayName, size: 30) { return avatarImg - } else { return getDefaultUserIcon() } - } - - func getDefaultUserIcon() -> UIImage { - - let config = UIImage.SymbolConfiguration(pointSize: 30) - return NCUtility.shared.loadImage(named: "person.crop.circle", symbolConfiguration: config) - } - - @objc func createAvatar(image: UIImage, size: CGFloat) -> UIImage { - - var avatarImage = image - let rect = CGRect(x: 0, y: 0, width: size, height: size) - - UIGraphicsBeginImageContextWithOptions(rect.size, false, 3.0) - UIBezierPath(roundedRect: rect, cornerRadius: rect.size.height).addClip() - avatarImage.draw(in: rect) - avatarImage = UIGraphicsGetImageFromCurrentImageContext() ?? image - UIGraphicsEndImageContext() - - return avatarImage + } else { + let config = UIImage.SymbolConfiguration(pointSize: 30) + return NCUtility.shared.loadImage(named: "person.crop.circle", symbolConfiguration: config) + } } func createAvatar(displayName: String, size: CGFloat) -> UIImage? { @@ -580,99 +564,6 @@ class NCUtility: NSObject { return isEqual } - func stringFromTime(_ time: CMTime) -> String { - - let interval = Int(CMTimeGetSeconds(time)) - - let seconds = interval % 60 - let minutes = (interval / 60) % 60 - let hours = (interval / 3600) - - if hours > 0 { - return String(format: "%02d:%02d:%02d", hours, minutes, seconds) - } else { - return String(format: "%02d:%02d", minutes, seconds) - } - } - - func colorNavigationController(_ navigationController: UINavigationController?, backgroundColor: UIColor, titleColor: UIColor, tintColor: UIColor?, withoutShadow: Bool) { - - let appearance = UINavigationBarAppearance() - appearance.titleTextAttributes = [.foregroundColor: titleColor] - appearance.largeTitleTextAttributes = [.foregroundColor: titleColor] - - if withoutShadow { - appearance.shadowColor = .clear - appearance.shadowImage = UIImage() - } - - if let tintColor = tintColor { - navigationController?.navigationBar.tintColor = tintColor - } - - navigationController?.view.backgroundColor = backgroundColor - navigationController?.navigationBar.barTintColor = titleColor - navigationController?.navigationBar.standardAppearance = appearance - navigationController?.navigationBar.compactAppearance = appearance - navigationController?.navigationBar.scrollEdgeAppearance = appearance - } - - func getEncondingDataType(data: Data) -> String.Encoding? { - if String(data: data, encoding: .utf8) != nil { return .utf8 } - if String(data: data, encoding: .ascii) != nil { return .ascii } - if String(data: data, encoding: .isoLatin1) != nil { return .isoLatin1 } - if String(data: data, encoding: .isoLatin2) != nil { return .isoLatin2 } - if String(data: data, encoding: .windowsCP1250) != nil { return .windowsCP1250 } - if String(data: data, encoding: .windowsCP1251) != nil { return .windowsCP1251 } - if String(data: data, encoding: .windowsCP1252) != nil { return .windowsCP1252 } - if String(data: data, encoding: .windowsCP1253) != nil { return .windowsCP1253 } - if String(data: data, encoding: .windowsCP1254) != nil { return .windowsCP1254 } - if String(data: data, encoding: .macOSRoman) != nil { return .macOSRoman } - if String(data: data, encoding: .japaneseEUC) != nil { return .japaneseEUC } - if String(data: data, encoding: .nextstep) != nil { return .nextstep } - if String(data: data, encoding: .nonLossyASCII) != nil { return .nonLossyASCII } - if String(data: data, encoding: .shiftJIS) != nil { return .shiftJIS } - if String(data: data, encoding: .symbol) != nil { return .symbol } - if String(data: data, encoding: .unicode) != nil { return .unicode } - if String(data: data, encoding: .utf16) != nil { return .utf16 } - if String(data: data, encoding: .utf16BigEndian) != nil { return .utf16BigEndian } - if String(data: data, encoding: .utf16LittleEndian) != nil { return .utf16LittleEndian } - if String(data: data, encoding: .utf32) != nil { return .utf32 } - if String(data: data, encoding: .utf32BigEndian) != nil { return .utf32BigEndian } - if String(data: data, encoding: .utf32LittleEndian) != nil { return .utf32LittleEndian } - return nil - } - - func SYSTEM_VERSION_LESS_THAN(version: String) -> Bool { - return UIDevice.current.systemVersion.compare(version, - options: NSString.CompareOptions.numeric) == ComparisonResult.orderedAscending - } - - 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 - } - - // 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) - } - func createFilePreviewImage(ocId: String, etag: String, fileNameView: String, classFile: String, status: Int, createPreviewMedia: Bool) -> UIImage? { var imagePreview: UIImage? @@ -752,43 +643,6 @@ class NCUtility: NSObject { return top } - func createViewImageAndText(image: UIImage, title: String? = nil) -> UIView { - - let imageView = UIImageView() - let titleView = UIView() - let label = UILabel() - - if let title = title { - label.text = title + " " - } else { - label.text = " " - } - label.sizeToFit() - label.center = titleView.center - label.textAlignment = NSTextAlignment.center - - imageView.image = image - - let imageAspect = (imageView.image?.size.width ?? 0) / (imageView.image?.size.height ?? 0) - let imageX = label.frame.origin.x - label.frame.size.height * imageAspect - let imageY = label.frame.origin.y - let imageWidth = label.frame.size.height * imageAspect - let imageHeight = label.frame.size.height - - if title != nil { - imageView.frame = CGRect(x: imageX, y: imageY, width: imageWidth, height: imageHeight) - titleView.addSubview(label) - } else { - imageView.frame = CGRect(x: imageX / 2, y: imageY, width: imageWidth, height: imageHeight) - } - imageView.contentMode = UIView.ContentMode.scaleAspectFit - - titleView.addSubview(imageView) - titleView.sizeToFit() - - return titleView - } - func getLocation(latitude: Double, longitude: Double, completion: @escaping (String?) -> Void) { let geocoder = CLGeocoder() let llocation = CLLocation(latitude: latitude, longitude: longitude) diff --git a/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift b/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift index d1f5f18804..74b0aa6306 100644 --- a/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift +++ b/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift @@ -237,12 +237,12 @@ class NCViewerMediaPage: UIViewController { } if metadata.isAudioOrVideo { - NCUtility.shared.colorNavigationController(navigationController, backgroundColor: .black, titleColor: .label, tintColor: nil, withoutShadow: false) + colorNavigationController(backgroundColor: .black, titleColor: .label, tintColor: nil, withoutShadow: false) currentViewController.playerToolBar?.show() view.backgroundColor = .black textColor = .white } else { - NCUtility.shared.colorNavigationController(navigationController, backgroundColor: .systemBackground, titleColor: .label, tintColor: nil, withoutShadow: false) + colorNavigationController(backgroundColor: .systemBackground, titleColor: .label, tintColor: nil, withoutShadow: false) view.backgroundColor = .systemGray6 textColor = .label } @@ -288,6 +288,28 @@ class NCViewerMediaPage: UIViewController { } } + func colorNavigationController(backgroundColor: UIColor, titleColor: UIColor, tintColor: UIColor?, withoutShadow: Bool) { + + let appearance = UINavigationBarAppearance() + appearance.titleTextAttributes = [.foregroundColor: titleColor] + appearance.largeTitleTextAttributes = [.foregroundColor: titleColor] + + if withoutShadow { + appearance.shadowColor = .clear + appearance.shadowImage = UIImage() + } + + if let tintColor = tintColor { + navigationController?.navigationBar.tintColor = tintColor + } + + navigationController?.view.backgroundColor = backgroundColor + navigationController?.navigationBar.barTintColor = titleColor + navigationController?.navigationBar.standardAppearance = appearance + navigationController?.navigationBar.compactAppearance = appearance + navigationController?.navigationBar.scrollEdgeAppearance = appearance + } + // MARK: - NotificationCenter @objc func downloadedFile(_ notification: NSNotification) { From a981df3722e3b797f533e05573ea30352b1fc401 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Wed, 25 Oct 2023 17:48:04 +0200 Subject: [PATCH 77/90] Update NCUtility.swift --- iOSClient/Utility/NCUtility.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iOSClient/Utility/NCUtility.swift b/iOSClient/Utility/NCUtility.swift index a3bf1a39fc..bd3638e6a9 100644 --- a/iOSClient/Utility/NCUtility.swift +++ b/iOSClient/Utility/NCUtility.swift @@ -121,7 +121,7 @@ class NCUtility: NSObject { } #endif - func isSimulatorOrTestFlight() -> Bool { + @objc func isSimulatorOrTestFlight() -> Bool { guard let path = Bundle.main.appStoreReceiptURL?.path else { return false } From f3d8df556a4e3ccc6227a47b40c27e5833d8ec9c Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Wed, 25 Oct 2023 18:01:03 +0200 Subject: [PATCH 78/90] coding --- .../FileProviderExtension+Actions.swift | 4 ++-- Share/NCShareExtension+DataSource.swift | 9 +++------ iOSClient/Data/NCManageDatabase+Account.swift | 3 +-- .../Collection Common/NCCollectionViewCommon.swift | 2 +- iOSClient/Networking/NCNetworking.swift | 8 ++++---- iOSClient/Select/NCSelect.swift | 2 +- iOSClient/Utility/CCUtility.h | 1 - iOSClient/Utility/CCUtility.m | 13 ------------- iOSClient/Utility/NCUtilityFileSystem.swift | 11 +++++++++++ 9 files changed, 23 insertions(+), 30 deletions(-) diff --git a/File Provider Extension/FileProviderExtension+Actions.swift b/File Provider Extension/FileProviderExtension+Actions.swift index 65c39d491e..0b01adbabe 100644 --- a/File Provider Extension/FileProviderExtension+Actions.swift +++ b/File Provider Extension/FileProviderExtension+Actions.swift @@ -100,8 +100,8 @@ extension FileProviderExtension { } 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)) diff --git a/Share/NCShareExtension+DataSource.swift b/Share/NCShareExtension+DataSource.swift index 6673c47725..2570dca9df 100644 --- a/Share/NCShareExtension+DataSource.swift +++ b/Share/NCShareExtension+DataSource.swift @@ -29,11 +29,8 @@ import NextcloudKit extension NCShareExtension: UICollectionViewDelegate { 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_") - } - + 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_") } @@ -138,7 +135,7 @@ extension NCShareExtension: UICollectionViewDataSource { 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)) // Local image: offline diff --git a/iOSClient/Data/NCManageDatabase+Account.swift b/iOSClient/Data/NCManageDatabase+Account.swift index 394d694e96..10b3b850dc 100644 --- a/iOSClient/Data/NCManageDatabase+Account.swift +++ b/iOSClient/Data/NCManageDatabase+Account.swift @@ -263,8 +263,7 @@ extension NCManageDatabase { let cameraFileName = self.getAccountAutoUploadFileName() 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 } diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index 3887f89e3b..0d9250e3ae 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -1052,7 +1052,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS 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 if let viewController = appDelegate.listFilesVC[serverUrlPush], viewController.isViewLoaded { diff --git a/iOSClient/Networking/NCNetworking.swift b/iOSClient/Networking/NCNetworking.swift index 0c5f246aa6..868a7676d1 100644 --- a/iOSClient/Networking/NCNetworking.swift +++ b/iOSClient/Networking/NCNetworking.swift @@ -1383,7 +1383,7 @@ class NCNetworking: NSObject, NKCommonDelegate { NCManageDatabase.shared.deleteLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) 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) } } @@ -1507,8 +1507,8 @@ class NCNetworking: NSObject, NKCommonDelegate { 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)) { NCManageDatabase.shared.setDirectory(serverUrl: serverUrl, serverUrlTo: serverUrlTo, etag: "", ocId: nil, fileId: nil, encrypted: directory.e2eEncrypted, richWorkspace: nil, account: metadata.account) @@ -1573,7 +1573,7 @@ class NCNetworking: NSObject, NKCommonDelegate { let result = await NextcloudKit.shared.moveFileOrFolder(serverUrlFileNameSource: serverUrlFileNameSource, serverUrlFileNameDestination: serverUrlFileNameDestination, overwrite: overwrite) if result.error == .success { 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) } diff --git a/iOSClient/Select/NCSelect.swift b/iOSClient/Select/NCSelect.swift index 70661c7bda..52922befe4 100644 --- a/iOSClient/Select/NCSelect.swift +++ b/iOSClient/Select/NCSelect.swift @@ -249,7 +249,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent 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 } self.serverUrlPush = serverUrlPush diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 4c508212bb..ef3b1ce9e8 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -35,7 +35,6 @@ @interface CCUtility : NSObject + (NSString *)dateDiff:(NSDate *)convertedDate; -+ (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 *)getTitleSectionDate:(NSDate *)date; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 5a81f25063..8819bd05a9 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -71,19 +71,6 @@ + (NSString *)dateDiff:(NSDate *) convertedDate } } -+ (NSString*)stringAppendServerUrl:(NSString *)serverUrl addFileName:(NSString *)addFileName -{ - NSString *result; - - if (serverUrl == nil || addFileName == nil) return nil; - if ([addFileName isEqualToString:@""]) return serverUrl; - - if ([serverUrl isEqualToString:@"/"]) result = [serverUrl stringByAppendingString:addFileName]; - else result = [NSString stringWithFormat:@"%@/%@", serverUrl, addFileName]; - - return result; -} - + (NSString *)createFileNameDate:(NSString *)fileName extension:(NSString *)extension { NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; diff --git a/iOSClient/Utility/NCUtilityFileSystem.swift b/iOSClient/Utility/NCUtilityFileSystem.swift index 46f1055c7b..4062255bba 100644 --- a/iOSClient/Utility/NCUtilityFileSystem.swift +++ b/iOSClient/Utility/NCUtilityFileSystem.swift @@ -367,6 +367,17 @@ class NCUtilityFileSystem: NSObject { return returnString } + func stringAppendServerUrl(_ serverUrl: String, addFileName: String) -> String { + + if addFileName.isEmpty { + return serverUrl + } else if serverUrl.last == "/" { + return serverUrl + addFileName + } else { + return serverUrl + "/" + addFileName + } + } + @objc func createFileName(_ fileName: String, serverUrl: String, account: String) -> String { var resultFileName = fileName From 58161cf431c5e6f9759977f897acd8b6d42c8f7f Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Wed, 25 Oct 2023 18:17:49 +0200 Subject: [PATCH 79/90] coding --- iOSClient/AppDelegate.swift | 2 +- iOSClient/Menu/AppDelegate+Menu.swift | 2 +- .../Scan document/NCUploadScanDocument.swift | 2 +- iOSClient/Utility/CCUtility.h | 1 - iOSClient/Utility/CCUtility.m | 26 ------------------- iOSClient/Utility/NCUtilityFileSystem.swift | 17 ++++++++++++ 6 files changed, 20 insertions(+), 30 deletions(-) diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index da62a52352..b39aa2d622 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -893,7 +893,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD NCAskAuthorization.shared.askAuthorizationAudioRecord(viewController: rootViewController) { hasPermission in 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 { viewController.delegate = self diff --git a/iOSClient/Menu/AppDelegate+Menu.swift b/iOSClient/Menu/AppDelegate+Menu.swift index 05e4531861..3fdf05ff2c 100644 --- a/iOSClient/Menu/AppDelegate+Menu.swift +++ b/iOSClient/Menu/AppDelegate+Menu.swift @@ -95,7 +95,7 @@ extension AppDelegate { 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 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 { viewController.delegate = self diff --git a/iOSClient/Scan document/NCUploadScanDocument.swift b/iOSClient/Scan document/NCUploadScanDocument.swift index 1a622f5292..c50a5ecd2e 100644 --- a/iOSClient/Scan document/NCUploadScanDocument.swift +++ b/iOSClient/Scan document/NCUploadScanDocument.swift @@ -344,7 +344,7 @@ extension NCUploadScanDocument: NCCreateFormUploadConflictDelegate { 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 isSecuredPassword: Bool = true @State var isTextRecognition: Bool = NCKeychain().textRecognitionStatus diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index ef3b1ce9e8..02ff38ffe8 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -35,7 +35,6 @@ @interface CCUtility : NSObject + (NSString *)dateDiff:(NSDate *)convertedDate; -+ (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 *)getTitleSectionDate:(NSDate *)date; + (NSString *)returnPathfromServerUrl:(NSString *)serverUrl urlBase:(NSString *)urlBase userId:(NSString *)userId account:(NSString *)account; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 8819bd05a9..3ff9835758 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -71,32 +71,6 @@ + (NSString *)dateDiff:(NSDate *) convertedDate } } -+ (NSString *)createFileNameDate:(NSString *)fileName extension:(NSString *)extension -{ - NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; - [formatter setDateFormat:@"yy-MM-dd HH-mm-ss"]; - NSString *fileNameDate = [formatter stringFromDate:[NSDate date]]; - NSString *returnFileName; - - if ([fileName isEqualToString:@""] && ![extension isEqualToString:@""]) { - returnFileName = [NSString stringWithFormat:@"%@.%@", fileNameDate, extension]; - } - - if (![fileName isEqualToString:@""] && [extension isEqualToString:@""]) { - returnFileName = [NSString stringWithFormat:@"%@ %@", fileName, fileNameDate]; - } - - if ([fileName isEqualToString:@""] && [extension isEqualToString:@""]) { - returnFileName = fileNameDate; - } - - if (![fileName isEqualToString:@""] && ![extension isEqualToString:@""]) { - returnFileName = [NSString stringWithFormat:@"%@ %@.%@", fileName, fileNameDate, extension]; - } - - return returnFileName; -} - + (NSString *)createFileName:(NSString *)fileName fileDate:(NSDate *)fileDate fileType:(PHAssetMediaType)fileType keyFileName:(NSString *)keyFileName keyFileNameType:(NSString *)keyFileNameType keyFileNameOriginal:(NSString *)keyFileNameOriginal forcedNewFileName:(BOOL)forcedNewFileName { BOOL addFileNameType = NO; diff --git a/iOSClient/Utility/NCUtilityFileSystem.swift b/iOSClient/Utility/NCUtilityFileSystem.swift index 4062255bba..9433976cf5 100644 --- a/iOSClient/Utility/NCUtilityFileSystem.swift +++ b/iOSClient/Utility/NCUtilityFileSystem.swift @@ -426,6 +426,23 @@ class NCUtilityFileSystem: NSObject { return resultFileName } + func createFileNameDate(_ fileName: String, ext: String) -> String { + + let formatter = DateFormatter() + formatter.dateFormat = "yy-MM-dd HH-mm-ss" + let fileNameDate = formatter.string(from: Date()) + + if fileName.isEmpty, !ext.isEmpty { + return fileNameDate + "." + ext + } else if !fileName.isEmpty, ext.isEmpty { + return fileName + " " + fileNameDate + } else if fileName.isEmpty, ext.isEmpty { + return fileNameDate + } else { + return fileName + " " + fileNameDate + "." + ext + } + } + @objc func getDirectorySize(directory: String) -> Int64 { let url = URL(fileURLWithPath: directory) From 2318ac2430ce453e89d40dd8631d856dff5f6c34 Mon Sep 17 00:00:00 2001 From: Nextcloud bot Date: Thu, 26 Oct 2023 02:42:02 +0000 Subject: [PATCH 80/90] Fix(l10n): Update translations from Transifex Signed-off-by: Nextcloud bot --- .../cs-CZ.lproj/Localizable.strings | Bin 124212 -> 124212 bytes .../tr.lproj/Localizable.strings | Bin 125004 -> 125012 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/iOSClient/Supporting Files/cs-CZ.lproj/Localizable.strings b/iOSClient/Supporting Files/cs-CZ.lproj/Localizable.strings index 3893e1ae8aea54111aec26b7d1e6ce6780ca5ff5..a918565f42c524f42af15d41b6e598fe0818ab61 100644 GIT binary patch delta 80 zcmdmTihau|_6;v0EyEZp8F(498B!Ut7)pSo0)w!E0z&~qBx5F!EMiDxC}SuE%7J8x Z!DJp#EQ6tF@#3x7s~(u diff --git a/iOSClient/Supporting Files/tr.lproj/Localizable.strings b/iOSClient/Supporting Files/tr.lproj/Localizable.strings index 9a1ca6ea74f89ce309b8cf333bca9e31018868fd..39c5f80afe566a90158bf5370ea475205108041f 100644 GIT binary patch delta 50 zcmV-20L}l*& Date: Thu, 26 Oct 2023 14:11:42 +0200 Subject: [PATCH 81/90] coding --- iOSClient/Extensions/UIAlertController+Extension.swift | 2 +- iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift | 2 +- iOSClient/Networking/E2EE/NCNetworkingE2EECreateFolder.swift | 2 +- iOSClient/Networking/NCNetworking.swift | 4 ++-- iOSClient/Settings/NCManageAutoUploadFileName.swift | 2 +- iOSClient/Utility/NCUtility.swift | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/iOSClient/Extensions/UIAlertController+Extension.swift b/iOSClient/Extensions/UIAlertController+Extension.swift index 8965e2dfbe..cae04e82f2 100644 --- a/iOSClient/Extensions/UIAlertController+Extension.swift +++ b/iOSClient/Extensions/UIAlertController+Extension.swift @@ -74,7 +74,7 @@ extension UIAlertController { object: alertController.textFields?.first, queue: .main) { _ in guard let text = alertController.textFields?.first?.text else { return } - let folderName = NCUtility.shared.removeForbiddenCharactersServer(text).trimmingCharacters(in: .whitespaces) + let folderName = NCUtility.shared.removeForbiddenCharacters(text).trimmingCharacters(in: .whitespaces) okAction.isEnabled = !folderName.isEmpty && folderName != "." && folderName != ".." } diff --git a/iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift b/iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift index 290c974bc8..7988d3f2a7 100644 --- a/iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift +++ b/iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift @@ -168,7 +168,7 @@ class NCCreateFormUploadVoiceNote: XLFormViewController, NCSelectDelegate, AVAud self.form.delegate = nil if let fileNameNew = formRow.value as? String { - self.fileName = NCUtility.shared.removeForbiddenCharactersServer(fileNameNew) + self.fileName = NCUtility.shared.removeForbiddenCharacters(fileNameNew) } formRow.value = self.fileName diff --git a/iOSClient/Networking/E2EE/NCNetworkingE2EECreateFolder.swift b/iOSClient/Networking/E2EE/NCNetworkingE2EECreateFolder.swift index 3d5de155c0..351df5be1f 100644 --- a/iOSClient/Networking/E2EE/NCNetworkingE2EECreateFolder.swift +++ b/iOSClient/Networking/E2EE/NCNetworkingE2EECreateFolder.swift @@ -32,7 +32,7 @@ class NCNetworkingE2EECreateFolder: NSObject { let fileNameIdentifier = NCNetworkingE2EE.shared.generateRandomIdentifier() let serverUrlFileName = serverUrl + "/" + fileNameIdentifier - let fileNameFolder = NCUtilityFileSystem.shared.createFileName(NCUtility.shared.removeForbiddenCharactersServer(fileName), serverUrl: serverUrl, account: account) + let fileNameFolder = NCUtilityFileSystem.shared.createFileName(NCUtility.shared.removeForbiddenCharacters(fileName), serverUrl: serverUrl, account: account) if fileNameFolder.isEmpty { return NKError(errorCode: NCGlobal.shared.errorUnexpectedResponseFromDB, errorDescription: NSLocalizedString("_e2e_error_", comment: "")) } diff --git a/iOSClient/Networking/NCNetworking.swift b/iOSClient/Networking/NCNetworking.swift index 868a7676d1..aab0faf98f 100644 --- a/iOSClient/Networking/NCNetworking.swift +++ b/iOSClient/Networking/NCNetworking.swift @@ -1197,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) { - var fileNameFolder = NCUtility.shared.removeForbiddenCharactersServer(fileName) + var fileNameFolder = NCUtility.shared.removeForbiddenCharacters(fileName) if !overwrite { fileNameFolder = NCUtilityFileSystem.shared.createFileName(fileNameFolder, serverUrl: serverUrl, account: account) @@ -1490,7 +1490,7 @@ class NCNetworking: NSObject, NKCommonDelegate { if !metadata.permissions.isEmpty && !permission { return completion(NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_no_permission_modify_file_")) } - let fileNameNew = NCUtility.shared.removeForbiddenCharactersServer(fileNameNew) + let fileNameNew = NCUtility.shared.removeForbiddenCharacters(fileNameNew) if fileNameNew.isEmpty || fileNameNew == metadata.fileNameView { return completion(NKError()) } diff --git a/iOSClient/Settings/NCManageAutoUploadFileName.swift b/iOSClient/Settings/NCManageAutoUploadFileName.swift index f6e33c6814..649de835eb 100644 --- a/iOSClient/Settings/NCManageAutoUploadFileName.swift +++ b/iOSClient/Settings/NCManageAutoUploadFileName.swift @@ -156,7 +156,7 @@ class NCManageAutoUploadFileName: XLFormViewController { self.form.delegate = nil if let fileName = fileName { - formRow.value = NCUtility.shared.removeForbiddenCharactersServer(fileName) + formRow.value = NCUtility.shared.removeForbiddenCharacters(fileName) } self.form.delegate = self diff --git a/iOSClient/Utility/NCUtility.swift b/iOSClient/Utility/NCUtility.swift index bd3638e6a9..41aa466682 100644 --- a/iOSClient/Utility/NCUtility.swift +++ b/iOSClient/Utility/NCUtility.swift @@ -696,7 +696,7 @@ class NCUtility: NSObject { return (usedmegabytes, totalmegabytes) } - func removeForbiddenCharactersServer(_ fileName: String) -> String { + func removeForbiddenCharacters(_ fileName: String) -> String { var fileName = fileName let arrayForbiddenCharacters = ["/"] From fddbe71e6a39dd7e5624e435dc509fed75f0dc73 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Thu, 26 Oct 2023 14:53:54 +0200 Subject: [PATCH 82/90] remove valueForKey: --- Widget/Dashboard/DashboardData.swift | 2 +- iOSClient/AppDelegate.swift | 33 +++++++++++----------------- iOSClient/Utility/CCUtility.h | 1 - iOSClient/Utility/CCUtility.m | 7 ------ 4 files changed, 14 insertions(+), 29 deletions(-) diff --git a/Widget/Dashboard/DashboardData.swift b/Widget/Dashboard/DashboardData.swift index b5ab1ce406..3b63e39778 100644 --- a/Widget/Dashboard/DashboardData.swift +++ b/Widget/Dashboard/DashboardData.swift @@ -204,7 +204,7 @@ func getDashboardDataEntry(configuration: DashboardIntent?, isPreview: Bool, dis if (pathComponents.last as? NSString)?.pathExtension.lowercased() == "svg" { imageTemplate = true } - if let item = CCUtility.value(forKey: "fileId", fromQueryItems: queryItems) { + if let item = queryItems?.filter({ $0.name == "fileId" }).first?.value { iconFileName = item } else if pathComponents.contains("avatar") { iconFileName = pathComponents[pathComponents.count - 2] diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index b39aa2d622..8ffb2df577 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -837,8 +837,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD 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" { @@ -846,16 +845,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD if let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) { 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 { 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) alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in })) window?.rootViewController?.present(alertController, animated: true, completion: { }) - return false } @@ -914,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" { @@ -923,19 +921,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD if let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) { 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 domain = URL(string: linkScheme)?.host else { return true } fileName = (pathScheme as NSString).lastPathComponent let message = String(format: NSLocalizedString("_account_not_available_", comment: ""), userScheme, domain, fileName) - let alertController = UIAlertController(title: NSLocalizedString("_info_", comment: ""), message: message, preferredStyle: .alert) alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in })) window?.rootViewController?.present(alertController, animated: true, completion: { }) - return false } @@ -955,22 +952,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD 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" { guard let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) else { return false } 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 getMatchedAccount(userId: userScheme, url: urlScheme) == nil { return false } - // Otherwise open the app and switch accounts return true } else { diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 02ff38ffe8..959d0c7134 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -56,7 +56,6 @@ + (NSString *)getExtension:(NSString*)fileName; + (NSDate *)datetimeWithOutTime:(NSDate *)datDate; -+ (NSString *)valueForKey:(NSString *)key fromQueryItems:(NSArray *)queryItems; + (NSDate *)getATime:(const char *)path; @end diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 3ff9835758..fc10bc4fa2 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -353,13 +353,6 @@ + (NSDate *)datetimeWithOutTime:(NSDate *)datDate return datDate; } -+ (NSString *)valueForKey:(NSString *)key fromQueryItems:(NSArray *)queryItems -{ - NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name=%@", key]; - NSURLQueryItem *queryItem = [[queryItems filteredArrayUsingPredicate:predicate] firstObject]; - return queryItem.value; -} - + (NSDate *)getATime:(const char *)path { struct stat st; From e5fa84af6ca8db2fdaa36d0af4e2b462c21a2f93 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Thu, 26 Oct 2023 15:56:17 +0200 Subject: [PATCH 83/90] cleaning --- iOSClient/NCGlobal.swift | 1 - iOSClient/Utility/NCKeychain.swift | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/iOSClient/NCGlobal.swift b/iOSClient/NCGlobal.swift index 73673ec41a..51d93927a8 100644 --- a/iOSClient/NCGlobal.swift +++ b/iOSClient/NCGlobal.swift @@ -79,7 +79,6 @@ class NCGlobal: NSObject { // Service // - @objc let serviceShareKeyChain = "Crypto Cloud" let metadataKeyedUnarchiver = "it.twsweb.nextcloud.metadata" let refreshTask = "com.nextcloud.refreshTask" let processingTask = "com.nextcloud.processingTask" diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index 6efd6d3527..30fb2dd56a 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -56,7 +56,7 @@ import KeychainAccess @objc var requestPasscodeAtStart: Bool { get { - let keychainOLD = Keychain(service: NCGlobal.shared.serviceShareKeyChain) + let keychainOLD = Keychain(service: "Crypto Cloud") if let value = keychainOLD["notPasscodeAtStart"], !value.isEmpty { if value == "true" { keychain["requestPasscodeAtStart"] = "false" @@ -310,7 +310,7 @@ import KeychainAccess // MARK: - private func migrate(key: String) { - let keychainOLD = Keychain(service: NCGlobal.shared.serviceShareKeyChain) + let keychainOLD = Keychain(service: "Crypto Cloud") if let value = keychainOLD[key], !value.isEmpty { keychain[key] = value keychainOLD[key] = nil @@ -321,6 +321,8 @@ import KeychainAccess try? keychain.removeAll() } + // MARK: - + @objc func getPassword(account: String) -> String { let key = "password" + account migrate(key: key) From 1fb414979bf8d3bb346ebbb3a373c9db1699bc8b Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Thu, 26 Oct 2023 16:17:17 +0200 Subject: [PATCH 84/90] coding --- iOSClient/Media/NCMedia.swift | 5 +++-- iOSClient/Settings/CCManageAutoUpload.m | 9 ++++++++- iOSClient/Utility/CCUtility.h | 1 - iOSClient/Utility/CCUtility.m | 7 ------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/iOSClient/Media/NCMedia.swift b/iOSClient/Media/NCMedia.swift index 44ee8b8f41..8c5ae77c1c 100644 --- a/iOSClient/Media/NCMedia.swift +++ b/iOSClient/Media/NCMedia.swift @@ -271,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) { 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 self.searchNewMedia() } diff --git a/iOSClient/Settings/CCManageAutoUpload.m b/iOSClient/Settings/CCManageAutoUpload.m index e7888eee6b..cbb2d98c33 100644 --- a/iOSClient/Settings/CCManageAutoUpload.m +++ b/iOSClient/Settings/CCManageAutoUpload.m @@ -399,7 +399,7 @@ - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInte sectionName = NSLocalizedString(@"_autoupload_description_", nil); break; 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 = @""; break; case 4: @@ -453,4 +453,11 @@ - (void)selectAutomaticUploadFolder }]; } +- (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 diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 959d0c7134..64ae623141 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -37,7 +37,6 @@ + (NSString *)dateDiff:(NSDate *)convertedDate; + (NSString *)createFileName:(NSString *)fileName fileDate:(NSDate *)fileDate fileType:(PHAssetMediaType)fileType keyFileName:(NSString *)keyFileName keyFileNameType:(NSString *)keyFileNameType keyFileNameOriginal:(NSString *)keyFileNameOriginal forcedNewFileName:(BOOL)forcedNewFileName; + (NSString *)getTitleSectionDate:(NSDate *)date; -+ (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 *)getMimeType:(NSString *)fileNameView; diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index fc10bc4fa2..4d48db98aa 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -197,13 +197,6 @@ + (NSString *)getTitleSectionDate:(NSDate *)date return title; } -+ (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; -} - + (NSString *)returnFileNamePathFromFileName:(NSString *)metadataFileName serverUrl:(NSString *)serverUrl urlBase:(NSString *)urlBase userId:(NSString *)userId account:(NSString *)account { if (metadataFileName == nil || serverUrl == nil || urlBase == nil) { From 663e32975b5eb8cb5f4b41a061c649a5e0a1ac95 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Thu, 26 Oct 2023 16:55:17 +0200 Subject: [PATCH 85/90] getFileNamePath --- .../FileProviderExtension+Actions.swift | 2 +- .../FileProviderExtension+Thumbnail.swift | 2 +- Widget/Files/FilesData.swift | 2 +- .../Collection Common/NCCollectionViewCommon.swift | 2 +- .../Create cloud/NCCreateFormUploadDocuments.swift | 4 ++-- iOSClient/Media/NCMedia.swift | 2 +- .../Networking/E2EE/NCNetworkingE2EERename.swift | 3 ++- iOSClient/Networking/NCNetworking.swift | 2 +- .../RichWorkspace/NCRichWorkspaceCommon.swift | 4 ++-- iOSClient/Share/NCShareNetworking.swift | 4 ++-- iOSClient/Utility/CCUtility.h | 1 - iOSClient/Utility/CCUtility.m | 14 -------------- iOSClient/Utility/NCUtilityFileSystem.swift | 10 ++++++++++ iOSClient/Viewer/NCViewer.swift | 2 +- .../NCViewerRichdocument.swift | 14 +++++++------- 15 files changed, 32 insertions(+), 36 deletions(-) diff --git a/File Provider Extension/FileProviderExtension+Actions.swift b/File Provider Extension/FileProviderExtension+Actions.swift index 0b01adbabe..02867648b3 100644 --- a/File Provider Extension/FileProviderExtension+Actions.swift +++ b/File Provider Extension/FileProviderExtension+Actions.swift @@ -245,7 +245,7 @@ extension FileProviderExtension { } 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 diff --git a/File Provider Extension/FileProviderExtension+Thumbnail.swift b/File Provider Extension/FileProviderExtension+Thumbnail.swift index 4199d3751a..fcc4e63e55 100644 --- a/File Provider Extension/FileProviderExtension+Thumbnail.swift +++ b/File Provider Extension/FileProviderExtension+Thumbnail.swift @@ -42,7 +42,7 @@ extension FileProviderExtension { if metadata.hasPreview { - 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 fileNameIconLocalPath = NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag) if let urlBase = metadata.urlBase.urlEncoded, diff --git a/Widget/Files/FilesData.swift b/Widget/Files/FilesData.swift index 0e194469ca..9fee549f12 100644 --- a/Widget/Files/FilesData.swift +++ b/Widget/Files/FilesData.swift @@ -235,7 +235,7 @@ 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) { imageRecent = image } else if file.hasPreview { - let fileNamePathOrFileId = CCUtility.returnFileNamePath(fromFileName: file.fileName, serverUrl: file.serverUrl, urlBase: file.urlBase, userId: file.userId, account: account.account)! + 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) diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index 0d9250e3ae..a637994edb 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -1771,7 +1771,7 @@ class NCCollectionViewDownloadThumbnail: ConcurrentOperation { self.metadata = tableMetadata.init(value: metadata) self.cell = cell self.collectionView = collectionView - self.fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId, account: metadata.account)! + 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) } diff --git a/iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift b/iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift index 19097aee57..60f71e05a4 100644 --- a/iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift +++ b/iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift @@ -276,7 +276,7 @@ import XLForm } 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)) } } @@ -285,7 +285,7 @@ import XLForm if let metadatas { 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) } else { DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { diff --git a/iOSClient/Media/NCMedia.swift b/iOSClient/Media/NCMedia.swift index 8c5ae77c1c..87f224fd52 100644 --- a/iOSClient/Media/NCMedia.swift +++ b/iOSClient/Media/NCMedia.swift @@ -816,7 +816,7 @@ class NCMediaDownloadThumbnaill: ConcurrentOperation { self.metadata = tableMetadata.init(value: metadata) self.cell = cell self.collectionView = collectionView - self.fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId, account: metadata.account)! + 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) } diff --git a/iOSClient/Networking/E2EE/NCNetworkingE2EERename.swift b/iOSClient/Networking/E2EE/NCNetworkingE2EERename.swift index d63ad47d36..67c2c6b021 100644 --- a/iOSClient/Networking/E2EE/NCNetworkingE2EERename.swift +++ b/iOSClient/Networking/E2EE/NCNetworkingE2EERename.swift @@ -55,7 +55,8 @@ class NCNetworkingE2EERename: NSObject { // 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 // diff --git a/iOSClient/Networking/NCNetworking.swift b/iOSClient/Networking/NCNetworking.swift index aab0faf98f..0d0e07fe17 100644 --- a/iOSClient/Networking/NCNetworking.swift +++ b/iOSClient/Networking/NCNetworking.swift @@ -1409,7 +1409,7 @@ class NCNetworking: NSObject, NKCommonDelegate { 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 ocId = metadata.ocId diff --git a/iOSClient/RichWorkspace/NCRichWorkspaceCommon.swift b/iOSClient/RichWorkspace/NCRichWorkspaceCommon.swift index 549139a4e1..870ff3933d 100644 --- a/iOSClient/RichWorkspace/NCRichWorkspaceCommon.swift +++ b/iOSClient/RichWorkspace/NCRichWorkspaceCommon.swift @@ -40,7 +40,7 @@ import NextcloudKit 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 NCActivityIndicator.shared.stop() @@ -75,7 +75,7 @@ import NextcloudKit 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 NCActivityIndicator.shared.stop() diff --git a/iOSClient/Share/NCShareNetworking.swift b/iOSClient/Share/NCShareNetworking.swift index f8adc2fab4..b0b92a010e 100644 --- a/iOSClient/Share/NCShareNetworking.swift +++ b/iOSClient/Share/NCShareNetworking.swift @@ -44,7 +44,7 @@ class NCShareNetworking: NSObject { 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) NextcloudKit.shared.readShares(parameters: parameter) { account, shares, _, error in @@ -80,7 +80,7 @@ class NCShareNetworking: NSObject { // https://github.com/nextcloud/ios-communication-library/pull/104 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 NCActivityIndicator.shared.stop() diff --git a/iOSClient/Utility/CCUtility.h b/iOSClient/Utility/CCUtility.h index 64ae623141..a8859b23c5 100644 --- a/iOSClient/Utility/CCUtility.h +++ b/iOSClient/Utility/CCUtility.h @@ -37,7 +37,6 @@ + (NSString *)dateDiff:(NSDate *)convertedDate; + (NSString *)createFileName:(NSString *)fileName fileDate:(NSDate *)fileDate fileType:(PHAssetMediaType)fileType keyFileName:(NSString *)keyFileName keyFileNameType:(NSString *)keyFileNameType keyFileNameOriginal:(NSString *)keyFileNameOriginal forcedNewFileName:(BOOL)forcedNewFileName; + (NSString *)getTitleSectionDate:(NSDate *)date; -+ (NSString *)returnFileNamePathFromFileName:(NSString *)metadataFileName serverUrl:(NSString *)serverUrl urlBase:(NSString *)urlBase userId:(NSString *)userId account:(NSString *)account; + (NSString *)getMimeType:(NSString *)fileNameView; // ===== Share Permissions ===== diff --git a/iOSClient/Utility/CCUtility.m b/iOSClient/Utility/CCUtility.m index 4d48db98aa..e5f8045b6d 100644 --- a/iOSClient/Utility/CCUtility.m +++ b/iOSClient/Utility/CCUtility.m @@ -197,20 +197,6 @@ + (NSString *)getTitleSectionDate:(NSDate *)date return title; } -+ (NSString *)returnFileNamePathFromFileName:(NSString *)metadataFileName serverUrl:(NSString *)serverUrl urlBase:(NSString *)urlBase userId:(NSString *)userId account:(NSString *)account -{ - if (metadataFileName == nil || serverUrl == nil || urlBase == nil) { - return @""; - } - - NSString *homeServer = [[NCUtilityFileSystem shared] getHomeServerWithUrlBase:urlBase userId:userId]; - NSString *fileName = [NSString stringWithFormat:@"%@/%@", [serverUrl stringByReplacingOccurrencesOfString:homeServer withString:@""], metadataFileName]; - - if ([fileName hasPrefix:@"/"]) fileName = [fileName substringFromIndex:1]; - - return fileName; -} - + (NSString *)getMimeType:(NSString *)fileNameView { CFStringRef fileUTI = nil; diff --git a/iOSClient/Utility/NCUtilityFileSystem.swift b/iOSClient/Utility/NCUtilityFileSystem.swift index 9433976cf5..f4d6c88f03 100644 --- a/iOSClient/Utility/NCUtilityFileSystem.swift +++ b/iOSClient/Utility/NCUtilityFileSystem.swift @@ -378,6 +378,16 @@ class NCUtilityFileSystem: NSObject { } } + @objc func getFileNamePath(_ fileName: String, serverUrl: String, urlBase: String, userId: String) -> String { + + let home = getHomeServer(urlBase: urlBase, userId: userId) + var fileNamePath = serverUrl.replacingOccurrences(of: home, with: "") + "/" + fileName + if fileNamePath.first == "/" { + fileNamePath.removeFirst() + } + return fileNamePath + } + @objc func createFileName(_ fileName: String, serverUrl: String, account: String) -> String { var resultFileName = fileName diff --git a/iOSClient/Viewer/NCViewer.swift b/iOSClient/Viewer/NCViewer.swift index 8ea933e41e..d460c58c20 100644 --- a/iOSClient/Viewer/NCViewer.swift +++ b/iOSClient/Viewer/NCViewer.swift @@ -168,7 +168,7 @@ class NCViewer: NSObject { if metadata.url.isEmpty { - 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) var options = NKRequestOptions() if editor == NCGlobal.shared.editorOnlyoffice { diff --git a/iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift b/iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift index 3d0790be7d..6c36b8ea2b 100644 --- a/iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift +++ b/iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift @@ -290,13 +290,13 @@ class NCViewerRichdocument: UIViewController, WKNavigationDelegate, WKScriptMess func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String, items: [Any], indexPath: [IndexPath], overwrite: Bool, copy: Bool, move: Bool) { - if serverUrl != nil && metadata != nil { + if let serverUrl, let metadata { - let path = CCUtility.returnFileNamePath(fromFileName: metadata!.fileName, serverUrl: serverUrl!, urlBase: appDelegate.urlBase, userId: appDelegate.userId, account: metadata!.account)! + let path = NCUtilityFileSystem.shared.getFileNamePath(metadata.fileName, serverUrl: serverUrl, urlBase: appDelegate.urlBase, userId: appDelegate.userId) NextcloudKit.shared.createAssetRichdocuments(path: path) { account, url, _, error in - if error == .success && account == self.appDelegate.account { - let functionJS = "OCA.RichDocuments.documentsMain.postAsset('\(metadata!.fileNameView)', '\(url!)')" + if error == .success, account == self.appDelegate.account, let url { + let functionJS = "OCA.RichDocuments.documentsMain.postAsset('\(metadata.fileNameView)', '\(url)')" self.webView.evaluateJavaScript(functionJS, completionHandler: { _, _ in }) } else if error != .success { NCContentPresenter.shared.showError(error: error) @@ -309,11 +309,11 @@ class NCViewerRichdocument: UIViewController, WKNavigationDelegate, WKScriptMess func select(_ metadata: tableMetadata!, serverUrl: String!) { - let path = CCUtility.returnFileNamePath(fromFileName: metadata!.fileName, serverUrl: serverUrl!, urlBase: appDelegate.urlBase, userId: appDelegate.userId, account: metadata!.account)! + let path = NCUtilityFileSystem.shared.getFileNamePath(metadata!.fileName, serverUrl: serverUrl!, urlBase: appDelegate.urlBase, userId: appDelegate.userId) NextcloudKit.shared.createAssetRichdocuments(path: path) { account, url, _, error in - if error == .success && account == self.appDelegate.account { - let functionJS = "OCA.RichDocuments.documentsMain.postAsset('\(metadata.fileNameView)', '\(url!)')" + if error == .success, account == self.appDelegate.account, let url { + let functionJS = "OCA.RichDocuments.documentsMain.postAsset('\(metadata.fileNameView)', '\(url)')" self.webView.evaluateJavaScript(functionJS, completionHandler: { _, _ in }) } else if error != .success { NCContentPresenter.shared.showError(error: error) From 7b868ece0d976b09322cd24ba746c280d7ba955d Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Thu, 26 Oct 2023 17:25:10 +0200 Subject: [PATCH 86/90] Build 6 --- Brand/Database.swift | 2 +- Nextcloud.xcodeproj/project.pbxproj | 4 ++-- iOSClient/Utility/NCKeychain.swift | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Brand/Database.swift b/Brand/Database.swift index ed6d77c874..677a635792 100644 --- a/Brand/Database.swift +++ b/Brand/Database.swift @@ -26,4 +26,4 @@ import Foundation // Database Realm // let databaseName = "nextcloud.realm" -let databaseSchemaVersion: UInt64 = 320 +let databaseSchemaVersion: UInt64 = 321 diff --git a/Nextcloud.xcodeproj/project.pbxproj b/Nextcloud.xcodeproj/project.pbxproj index 0c877aa8ea..c1599bd60c 100644 --- a/Nextcloud.xcodeproj/project.pbxproj +++ b/Nextcloud.xcodeproj/project.pbxproj @@ -4713,7 +4713,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 5; + CURRENT_PROJECT_VERSION = 6; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = NKUJUXUJ3B; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -4778,7 +4778,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 5; + CURRENT_PROJECT_VERSION = 6; DEVELOPMENT_TEAM = NKUJUXUJ3B; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index 30fb2dd56a..9f8d9e3c6b 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -311,7 +311,11 @@ import KeychainAccess private func migrate(key: String) { let keychainOLD = Keychain(service: "Crypto Cloud") - if let value = keychainOLD[key], !value.isEmpty { + if key.starts(with: "PNPublicKey") || key.starts(with: "PNPrivateKey") { + if let data = try? keychainOLD.getData(key), !data.isEmpty { + keychain[data: key] = data + } + } else if let value = keychainOLD[key], !value.isEmpty { keychain[key] = value keychainOLD[key] = nil } From 02764bb0a17e0839e6c6083e4ad0f521c8f6ac92 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Thu, 26 Oct 2023 17:42:17 +0200 Subject: [PATCH 87/90] Update NCKeychain.swift --- iOSClient/Utility/NCKeychain.swift | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/iOSClient/Utility/NCKeychain.swift b/iOSClient/Utility/NCKeychain.swift index 9f8d9e3c6b..97a44f3d42 100644 --- a/iOSClient/Utility/NCKeychain.swift +++ b/iOSClient/Utility/NCKeychain.swift @@ -311,11 +311,7 @@ import KeychainAccess private func migrate(key: String) { let keychainOLD = Keychain(service: "Crypto Cloud") - if key.starts(with: "PNPublicKey") || key.starts(with: "PNPrivateKey") { - if let data = try? keychainOLD.getData(key), !data.isEmpty { - keychain[data: key] = data - } - } else if let value = keychainOLD[key], !value.isEmpty { + if let value = keychainOLD[key], !value.isEmpty { keychain[key] = value keychainOLD[key] = nil } @@ -442,7 +438,6 @@ import KeychainAccess @objc func getPushNotificationPublicKey(account: String) -> Data? { let key = "PNPublicKey" + account - migrate(key: key) return try? keychain.getData(key) } @@ -453,7 +448,6 @@ import KeychainAccess @objc func getPushNotificationPrivateKey(account: String) -> Data? { let key = "PNPrivateKey" + account - migrate(key: key) return try? keychain.getData(key) } @@ -464,7 +458,6 @@ import KeychainAccess @objc func getPushNotificationSubscribingPublicKey(account: String) -> String? { let key = "PNSubscribingPublicKey" + account - migrate(key: key) return try? keychain.get(key) } @@ -475,7 +468,6 @@ import KeychainAccess @objc func getPushNotificationToken(account: String) -> String? { let key = "PNToken" + account - migrate(key: key) return try? keychain.get(key) } @@ -486,7 +478,6 @@ import KeychainAccess @objc func getPushNotificationDeviceIdentifier(account: String) -> String? { let key = "PNDeviceIdentifier" + account - migrate(key: key) return try? keychain.get(key) } @@ -497,7 +488,6 @@ import KeychainAccess @objc func getPushNotificationDeviceIdentifierSignature(account: String) -> String? { let key = "PNDeviceIdentifierSignature" + account - migrate(key: key) return try? keychain.get(key) } From ce97a2f88d2161a7d4fed9604b336da6e5510a59 Mon Sep 17 00:00:00 2001 From: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Date: Thu, 26 Oct 2023 17:48:25 +0200 Subject: [PATCH 88/90] Update project.pbxproj --- Nextcloud.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Nextcloud.xcodeproj/project.pbxproj b/Nextcloud.xcodeproj/project.pbxproj index c1599bd60c..a816fb5199 100644 --- a/Nextcloud.xcodeproj/project.pbxproj +++ b/Nextcloud.xcodeproj/project.pbxproj @@ -5092,8 +5092,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/nextcloud/NextcloudKit"; requirement = { - branch = develop; - kind = branch; + kind = exactVersion; + version = 2.9.0; }; }; F788ECC5263AAAF900ADC67F /* XCRemoteSwiftPackageReference "MarkdownKit" */ = { From a10cd41fbb8bbabb7dab43458d6b2dd96293eccd Mon Sep 17 00:00:00 2001 From: Nextcloud bot Date: Fri, 27 Oct 2023 02:40:55 +0000 Subject: [PATCH 89/90] Fix(l10n): Update translations from Transifex Signed-off-by: Nextcloud bot --- .../zh-Hans.lproj/Localizable.strings | Bin 92816 -> 89230 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/iOSClient/Supporting Files/zh-Hans.lproj/Localizable.strings b/iOSClient/Supporting Files/zh-Hans.lproj/Localizable.strings index 5eb6e8d0bedcfe7d40aa86afcf91b22db2f2072b..a9e8fe546682f10dc520d38c535570710d259324 100644 GIT binary patch delta 2426 zcmZuze^8U>9e^T=v_y%O zA1%~iK!T6(u$~j#yp74`Xx~n%xAX8$>7934=dHBev0dDmp5;1V=&XZU_I?vHZ@XRo zdOn};`+c70`~7^rPePw296g^f_Fg(3zDf(j>1k-?5?f+k*YjLu2DOEfQyKWwGf!j1 zPqo6La+=MeCI@R;pfk0N||q+ix$YX z-m$Vwn0fw;G%YdoRV78*yO!#PxegyxM40^Xal|Y&dj=pAAlSbz1E1ry_=ZfXahqXl zpn=j+YpHxnM@6?!D+oWK`zDy|Pq8t}RkeEiq-BKz4hdW8sO;zu&+Kpur*~wh;%|p! zvN$R%*uR!##d7O7&p>)>sdJT0w#?Y>^RR|&Iy3I=@IkJ`W%089ec>n7KQq@?z3Gy9 zBYdfIq*!k+j&`Hdg2PQZJbfsai2<7($KLv-D+*q0(cq6RE3rZ@6+$gHWlY4Iv_Has zRso6e>xC+O>~JoVQ12OtgTn2@c`}8yqKFIgr&}+#K%m%f=JsmA6PlLD!+eBa5`&{Q=U$W>ZtxoI7IP{bb=YOum zXQv7>;sL74v!VA78twV^{|y!LKU7^fDb6YVY}6Q;lNNVRkRe>vy;px@&zeG|wlCe8L{eG?x0N2c(H`9IOB z$5EY@JE67gwZ8B5&js{)uhSJ=}dFWxP5I{Y{ekNo|CGWMry>@=*Km(>Xcd)A4~ER8QmKU(>Q~=bQX@ zdtPcJ`5Td2^F{BR^Lr;q!3}Jtbw{~o-(tb$jL6m(P*po-3nG5Abef6z# zej^tX2(!GytSK{i^>$C~#o!7@j!l#Z1qLRrek0$M1qs;xf& zaX7qJO=d(^4Rb8QCbNt!Ce^=~!S-<43rZ4t5gF5@Wx#xCEp_IJBLs#G8OuXjviKs> z!!%FZAb$R^Ey4N&TXW-)TDx=ILDI4VnV1OwuJx)_6Z&1Sq=I}cB2g8<_K*-_vT?^P zH9lJ?1!gbItPwYiLL;ZuT@2Q@KBe2hb~&#EKB=1Tg>NLrw;dLOmCs{9}?CeMo$eikv&fi-=pUm>T>dm~T7Eq13)$Frmus?JFyOTfR#Wx&kQnvfi z+Z6tgmc_rr;RX#b1_pc`N6DGp$Rs=Mq55HS;+Bh^%q~Rhu=@pC1?5a(Ctll9H|azN zD0Y8Os~P&;pe9!f#eTP0X$>Gy5>fbj^4Lglhvzcvx^U=3e#>q$=`%zyNO1w4x9cCK`3XDr&6weOd$40T?hS{GW);LU>=IaRwX8RstUza1cEj zfcr<;36ahGZ}wW><(B`GtM~&AIa-1Ypl2GCf&rP0BQSD)wQ&zZ5*>x>IUPPTnGyXn zBVHR%Ur8Ac+0otvY&=5CRE|3#yR*baH09#eMMSD{+$DX3Bv6h{YT}c=h!Y=sw!P~O W%isHB-W>P45Y5QX^OY4bN&g!HNZMQg delta 5792 zcmbVQYiwLc6`t{9u@X0O{Km1iw`+HC7qfArs&bRqUdQXiiPG3zZ=$3W>c={^h3z$d zB@Pj8suqbRX&r`otf(N6P+Re%MY&O3_yq}q{3w;%LP3Zh7D6bhq7+b-O8F5u-<+Mj zyM81ovg}>YJ#*%q?|kPm_vK&a&;Kd^7Z*$NzW?>1r`*>{N@ZT~{O8^7yQO_O<)LF$ z$6lEE@~fYoE&T82XU|>y&Doo;E-vcjHd(6XD~k2aO|o3|JYS%1O6gN4D>}k$VnPgv zUNJ>~9r_&;{j@SG#?4BC){cv$7!e72HX+iQ+|MdL^wrFD)=j^^IK1%5nFr73G~E8? zTW84<((I!%X73H44*v^qim z4v0xQZH&H68B0!zVOp6Imui2NH)r=Ar^OMYWr&Q%hCccaW;{BAHLyT7>)ex;;5gls258 z|Gka))=x@C=x0{A^LtwPno+Obk+@+PbXY!{-Lak(H;N+;~mmqEpy10EZ9#!8&EGr0teyF#t4BN z_oL1c4~vL!e-~NFjddBr5gnKS%!kPdL?at-FP6h5e&Yno0KwBspCBaRZq|d28fouw zgYDt1PCKmtx(U(-$w~S-L2?rYOp^Tdj#BsJk-rp--rXw~O3Ic0#mB4L3|P>>oXQk(dtTgGPISC9v5#_vBsxE%Cr)whx zaD>&MtimP4>)wjpJ0IQ7*^Q(62}tIOjR)cmZUNpp1G86zz!31^5tvr)*8cf??lxM0 z0E!t3VP@4bLht|e=;o}HvIluM1RWh|kyUQ&p9$YlWM4vjjRKaWzknBf#i!RaY}WRY zm9P^PIkOO2exo`}q-w0{xmoMpy79-nqwpIv1&M6vINxCs@WXRp0Cd@c`>{u@{5w8( zm<;j&TR&NmZjeHxVWL;SxD#?vfvcA$Fq9h#ni0Np)=d(h*<956fZO?>KS*i}D9O`? z$;fHf`RujrvQ2+bBg?ih$I`GkEdhPKMg~%kYaP*La6uhFPM}62WXKF#FV%cm=~Adx zew-7J(&@Iy!7uiBZLz~M?q1nGdHKtQ4mq(@{T2CG?xrYh;QF%^56Me;+u&9vzn}?K zhj7xpVOds)H3QGSuz4_N8{p1qw0CJa&4}|=suE}Cg0PQn1VNC zkV%TLSUR^|hGfwLhjxv=8M`&`!c50R+u-!#(uWN)N2X_rOeS)oWRD^Y4X4ozd4b-6 zVu#@b_Mv0|S`FM{3hR)sphj5epY4=U8fmx_V%XrZ1l=6?B8Ml1zD-hdo%9rA2vUHb zx2B#uw2pMioW_6>v{{|^c9q8%u8=^>4uC1Yw$c%q6HJRxk*j_^ze@%i(O8iJTr@Z+ zC_Ee#e6DTFj-YWNaIv4X0&x{zBI z%jQ{Minn8it+qY#+1}V_t0j_}$IH8Az-0FSha*l$eP`aFpRK{tShVoCtkgM8vi>*<&&KJ4&cmaywcWNj z6n3N%YAISj-yFDL14ZPmZG%KLs;c_wCfVTcPHXfuG53)Zs^|CB`rRg3w=bUJ(%LDN zGtlDBc!R!7(@DxHct1=lR6NxyKPuC=nq)N8W)?WWJc-#ErOl8HDv)fHu6vthG`hAT zTL@N%*lQj(ORQ^pp;;a*X(b|a6Hb>|_4bvDIS+PRnV2YCWCl%8_`5x|n_hqDsJ z!j1?mhjo-xF1K9g!X&kyPUjHuU~O%44v;FSu}EesU~_DY8QVsZ=30%O!Bsv9^>8P` zN1{%F7hYyVHfeenj7RkNq6f}+4K^V#D4i?7g&Gr@UT%@mhPZJu4IAyZJ&lWuN+ z)|4zXuII~ue!W!&pV(`x=a6M55YJrPa8ask$Wx6(J#?c)|KuUO0C}`r-)WWgNA6$O z-P$=q<~d2>@7N=wn`4GnV7jBfu}4;Hv3(CI5*F&YCo1*jJ+gjtE18<2vidZ?B4}$3 z%+Bs5UMHl~UdF4OsRxVI{L_BDqfH(t#fc~v~CxSQ-@ z5hEV!XGm__exd?57O)izpD|F-z@^`AmrvGVO5t(V-Z40=e&bMEpimAi@euYkX#3XE8W0 WJ=Z1k3X8kNx9KoUBLl(=g5rO7)x^92 From 5aab90c887e4f862c341d644ce1241600ac65b34 Mon Sep 17 00:00:00 2001 From: Nextcloud bot Date: Sun, 29 Oct 2023 02:38:22 +0000 Subject: [PATCH 90/90] Fix(l10n): Update translations from Transifex Signed-off-by: Nextcloud bot --- .../uk.lproj/Localizable.strings | Bin 122680 -> 122712 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/iOSClient/Supporting Files/uk.lproj/Localizable.strings b/iOSClient/Supporting Files/uk.lproj/Localizable.strings index c236b89438144d26efc73971bfec37d53b8e19c8..6e38a2e68927d84222a40691cd64cb7fd42d3999 100644 GIT binary patch delta 133 zcmdn7kNw6z_J%Eti*`*eNMOmfVXu7F!@~1r${Qidus8=`biTfaI)zI;~lJfHX*#B~YC))I L+u3$A8mRyP^FJ5G delta 39 xcmV+?0NDT7z6ZFz2Y|EzqPmmN*a(*hx&b1W;-CQ>lbBEtlTJYfw;sCzIwWsX5JLa}