Browse Source

coding

Signed-off-by: marinofaggiana <marino.faggiana@nextcloud.com>
marinofaggiana 2 years ago
parent
commit
fc404aed05

+ 8 - 40
Nextcloud.xcodeproj/project.pbxproj

@@ -327,15 +327,10 @@
 		F783030528B4C50600B84583 /* SVGKit in Frameworks */ = {isa = PBXBuildFile; productRef = F783030428B4C50600B84583 /* SVGKit */; };
 		F783030628B4C51E00B84583 /* String+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7A0D1342591FBC5008F8A13 /* String+Extensions.swift */; };
 		F783030728B4C52800B84583 /* UIColor+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F70CEF5523E9C7E50007035B /* UIColor+Extensions.swift */; };
-		F783030928B4C57600B84583 /* NCCommunication in Frameworks */ = {isa = PBXBuildFile; productRef = F783030828B4C57600B84583 /* NCCommunication */; };
 		F783030B28B4C58600B84583 /* Queuer in Frameworks */ = {isa = PBXBuildFile; productRef = F783030A28B4C58600B84583 /* Queuer */; };
 		F783030D28B4C59A00B84583 /* SwiftEntryKit in Frameworks */ = {isa = PBXBuildFile; productRef = F783030C28B4C59A00B84583 /* SwiftEntryKit */; };
 		F783031228B4C8EC00B84583 /* CCUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = F7053E3D1C639DF500741EA5 /* CCUtility.m */; };
-		F783034228B511D200B84583 /* NextcloudKit in Frameworks */ = {isa = PBXBuildFile; productRef = F783034128B511D200B84583 /* NextcloudKit */; };
 		F783034428B5142B00B84583 /* NextcloudKit in Frameworks */ = {isa = PBXBuildFile; productRef = F783034328B5142B00B84583 /* NextcloudKit */; };
-		F783034628B5144B00B84583 /* NextcloudKit in Frameworks */ = {isa = PBXBuildFile; productRef = F783034528B5144B00B84583 /* NextcloudKit */; };
-		F783034828B5145600B84583 /* NextcloudKit in Frameworks */ = {isa = PBXBuildFile; productRef = F783034728B5145600B84583 /* NextcloudKit */; };
-		F783034A28B5146000B84583 /* NextcloudKit in Frameworks */ = {isa = PBXBuildFile; productRef = F783034928B5146000B84583 /* NextcloudKit */; };
 		F785EE9D246196DF00B3F945 /* NCNetworkingE2EE.swift in Sources */ = {isa = PBXBuildFile; fileRef = F785EE9C246196DF00B3F945 /* NCNetworkingE2EE.swift */; };
 		F785EE9E2461A09900B3F945 /* NCNetworking.swift in Sources */ = {isa = PBXBuildFile; fileRef = F75A9EE523796C6F0044CFCE /* NCNetworking.swift */; };
 		F785EEA42461A4A600B3F945 /* NCUtility.swift in Sources */ = {isa = PBXBuildFile; fileRef = F70BFC7320E0FA7C00C67599 /* NCUtility.swift */; };
@@ -391,6 +386,7 @@
 		F7A76DC8256A71CD00119AB3 /* UIImage+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7B7504A2397D38E004E13EC /* UIImage+Extensions.swift */; };
 		F7A76DCD256A71CE00119AB3 /* UIImage+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7B7504A2397D38E004E13EC /* UIImage+Extensions.swift */; };
 		F7AC1CB028AB94490032D99F /* Array+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7AC1CAF28AB94490032D99F /* Array+Extensions.swift */; };
+		F7AC9D0F28C2063500FD336E /* NCCommunication in Frameworks */ = {isa = PBXBuildFile; productRef = F7AC9D0E28C2063500FD336E /* NCCommunication */; };
 		F7AE00F5230D5F9E007ACF8A /* NCLoginWeb.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7AE00F4230D5F9E007ACF8A /* NCLoginWeb.swift */; };
 		F7AE00F8230E81CB007ACF8A /* NCBrowserWeb.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7AE00F7230E81CB007ACF8A /* NCBrowserWeb.swift */; };
 		F7AE00FA230E81EB007ACF8A /* NCBrowserWeb.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7AE00F9230E81EB007ACF8A /* NCBrowserWeb.storyboard */; };
@@ -1053,7 +1049,6 @@
 				F7EBCDD3277B821700A4EF67 /* UICKeyChainStore in Frameworks */,
 				F75E57C325BF0ED2002B72C2 /* SVGKit in Frameworks */,
 				F786D597253454D800E3DD7B /* NCCommunication in Frameworks */,
-				F783034A28B5146000B84583 /* NextcloudKit in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -1072,7 +1067,6 @@
 				F710FC80277B7D2700AA9FBF /* RealmSwift in Frameworks */,
 				F72CD01227A7E92400E59476 /* JGProgressHUD in Frameworks */,
 				F710FC7E277B7D2600AA9FBF /* Realm in Frameworks */,
-				F783034628B5144B00B84583 /* NextcloudKit in Frameworks */,
 				F73ADD2126554F8E0069EA0D /* SwiftEntryKit in Frameworks */,
 				F7EBCDCF277B81FF00A4EF67 /* UICKeyChainStore in Frameworks */,
 				F75E57BF25BF0EC8002B72C2 /* SVGKit in Frameworks */,
@@ -1094,8 +1088,8 @@
 				F7346E2928B0FFF2006CE2D2 /* RealmSwift in Frameworks */,
 				F783030D28B4C59A00B84583 /* SwiftEntryKit in Frameworks */,
 				F783030B28B4C58600B84583 /* Queuer in Frameworks */,
+				F7AC9D0F28C2063500FD336E /* NCCommunication in Frameworks */,
 				F7346E1228B0EF5B006CE2D2 /* WidgetKit.framework in Frameworks */,
-				F783030928B4C57600B84583 /* NCCommunication in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -1105,7 +1099,6 @@
 			files = (
 				F7EBCDD1277B820D00A4EF67 /* UICKeyChainStore in Frameworks */,
 				F75E57C125BF0ECD002B72C2 /* SVGKit in Frameworks */,
-				F783034828B5145600B84583 /* NextcloudKit in Frameworks */,
 				F7EBCDD7277B834400A4EF67 /* Queuer in Frameworks */,
 				F73ADD2426554FE20069EA0D /* SwiftEntryKit in Frameworks */,
 				F710FC82277B7D3500AA9FBF /* Realm in Frameworks */,
@@ -1136,7 +1129,6 @@
 				F70B86752642CE3B00ED5349 /* FirebaseCrashlytics in Frameworks */,
 				F76DA969277B77EA0082465B /* DropDown in Frameworks */,
 				F75EAED826D2552E00F4320E /* MarqueeLabel in Frameworks */,
-				F783034228B511D200B84583 /* NextcloudKit in Frameworks */,
 				F710FC7A277B7D0000AA9FBF /* Realm in Frameworks */,
 				F72DA9B425F53E4E00B87DB1 /* SwiftRichString in Frameworks */,
 				F74E7720277A2EF40013B958 /* XLForm in Frameworks */,
@@ -2110,7 +2102,6 @@
 				F710FC87277B7D3F00AA9FBF /* RealmSwift */,
 				F7EBCDD2277B821700A4EF67 /* UICKeyChainStore */,
 				F7EBCDD8277B834F00A4EF67 /* Queuer */,
-				F783034928B5146000B84583 /* NextcloudKit */,
 			);
 			productName = "Notification Service Extension";
 			productReference = 2C33C47F23E2C475005F963B /* Notification Service Extension.appex */;
@@ -2157,7 +2148,6 @@
 				F7EBCDCE277B81FF00A4EF67 /* UICKeyChainStore */,
 				F7EBCDD4277B82DE00A4EF67 /* Queuer */,
 				F72CD01127A7E92400E59476 /* JGProgressHUD */,
-				F783034528B5144B00B84583 /* NextcloudKit */,
 			);
 			productName = "Share Ext";
 			productReference = F7CE8AFB1DC1F8D8009CAE48 /* Share.appex */;
@@ -2181,10 +2171,10 @@
 				F7346E2628B0FFF2006CE2D2 /* Realm */,
 				F7346E2828B0FFF2006CE2D2 /* RealmSwift */,
 				F783030428B4C50600B84583 /* SVGKit */,
-				F783030828B4C57600B84583 /* NCCommunication */,
 				F783030A28B4C58600B84583 /* Queuer */,
 				F783030C28B4C59A00B84583 /* SwiftEntryKit */,
 				F783034328B5142B00B84583 /* NextcloudKit */,
+				F7AC9D0E28C2063500FD336E /* NCCommunication */,
 			);
 			productName = DashboardWidgetExtension;
 			productReference = F7346E1028B0EF5B006CE2D2 /* Widget.appex */;
@@ -2211,7 +2201,6 @@
 				F710FC83277B7D3500AA9FBF /* RealmSwift */,
 				F7EBCDD0277B820D00A4EF67 /* UICKeyChainStore */,
 				F7EBCDD6277B834400A4EF67 /* Queuer */,
-				F783034728B5145600B84583 /* NextcloudKit */,
 			);
 			productName = "File Provider Extension";
 			productReference = F771E3D020E2392D00AFB62D /* File Provider Extension.appex */;
@@ -2258,7 +2247,6 @@
 				F7BB7E4627A18C56009B9F29 /* Parchment */,
 				F758A01127A7F03E0069468B /* JGProgressHUD */,
 				F753BA92281FD8020015BFB6 /* EasyTipView */,
-				F783034128B511D200B84583 /* NextcloudKit */,
 			);
 			productName = "Crypto Cloud";
 			productReference = F7CE8AFA1DC1F8D8009CAE48 /* Nextcloud.app */;
@@ -3800,11 +3788,6 @@
 			package = F75E57A725BF0D61002B72C2 /* XCRemoteSwiftPackageReference "SVGKit" */;
 			productName = SVGKit;
 		};
-		F783030828B4C57600B84583 /* NCCommunication */ = {
-			isa = XCSwiftPackageProductDependency;
-			package = F786D58B253454BF00E3DD7B /* XCRemoteSwiftPackageReference "ios-communication-library" */;
-			productName = NCCommunication;
-		};
 		F783030A28B4C58600B84583 /* Queuer */ = {
 			isa = XCSwiftPackageProductDependency;
 			package = F76DA961277B760E0082465B /* XCRemoteSwiftPackageReference "Queuer" */;
@@ -3815,31 +3798,11 @@
 			package = F73ADD1A265546880069EA0D /* XCRemoteSwiftPackageReference "SwiftEntryKit" */;
 			productName = SwiftEntryKit;
 		};
-		F783034128B511D200B84583 /* NextcloudKit */ = {
-			isa = XCSwiftPackageProductDependency;
-			package = F783034028B511D200B84583 /* XCRemoteSwiftPackageReference "NextcloudKit" */;
-			productName = NextcloudKit;
-		};
 		F783034328B5142B00B84583 /* NextcloudKit */ = {
 			isa = XCSwiftPackageProductDependency;
 			package = F783034028B511D200B84583 /* XCRemoteSwiftPackageReference "NextcloudKit" */;
 			productName = NextcloudKit;
 		};
-		F783034528B5144B00B84583 /* NextcloudKit */ = {
-			isa = XCSwiftPackageProductDependency;
-			package = F783034028B511D200B84583 /* XCRemoteSwiftPackageReference "NextcloudKit" */;
-			productName = NextcloudKit;
-		};
-		F783034728B5145600B84583 /* NextcloudKit */ = {
-			isa = XCSwiftPackageProductDependency;
-			package = F783034028B511D200B84583 /* XCRemoteSwiftPackageReference "NextcloudKit" */;
-			productName = NextcloudKit;
-		};
-		F783034928B5146000B84583 /* NextcloudKit */ = {
-			isa = XCSwiftPackageProductDependency;
-			package = F783034028B511D200B84583 /* XCRemoteSwiftPackageReference "NextcloudKit" */;
-			productName = NextcloudKit;
-		};
 		F786D58C253454BF00E3DD7B /* NCCommunication */ = {
 			isa = XCSwiftPackageProductDependency;
 			package = F786D58B253454BF00E3DD7B /* XCRemoteSwiftPackageReference "ios-communication-library" */;
@@ -3865,6 +3828,11 @@
 			package = F788ECC5263AAAF900ADC67F /* XCRemoteSwiftPackageReference "MarkdownKit" */;
 			productName = MarkdownKit;
 		};
+		F7AC9D0E28C2063500FD336E /* NCCommunication */ = {
+			isa = XCSwiftPackageProductDependency;
+			package = F786D58B253454BF00E3DD7B /* XCRemoteSwiftPackageReference "ios-communication-library" */;
+			productName = NCCommunication;
+		};
 		F7BB7E4627A18C56009B9F29 /* Parchment */ = {
 			isa = XCSwiftPackageProductDependency;
 			package = F7BB7E4527A18C56009B9F29 /* XCRemoteSwiftPackageReference "Parchment" */;

+ 1 - 1
Widget/Dashboard/DashboardData.swift

@@ -22,7 +22,7 @@
 //
 
 import WidgetKit
-import NCCommunication
+import NextcloudKit
 
 struct DashboardData: Identifiable, Codable, Hashable {
     var id: Int

+ 20 - 21
Widget/Nextcloud/NextcloudData.swift

@@ -22,7 +22,7 @@
 //
 
 import WidgetKit
-import NCCommunication
+import NextcloudKit
 
 let imageSize:CGFloat = 30
 let spacingImageUpload:CGFloat = 10
@@ -61,7 +61,7 @@ func getDataEntry(isPreview: Bool, displaySize: CGSize, completion: @escaping (_
         return completion(NextcloudDataEntry(date: Date(), recentDatas: recentDatasTest, isPlaceholder: true, footerImage: "xmark.icloud", footerText: NSLocalizedString("_no_active_account_", value: "No account found", comment: "")))
     }
 
-    func isLive(file: NCCommunicationFile, files: [NCCommunicationFile]) -> Bool {
+    func isLive(file: NKFile, files: [NKFile]) -> Bool {
 
         if file.ext.lowercased() != "mov" { return false }
         if files.filter({ ($0.fileNameWithoutExt == file.fileNameWithoutExt) && ($0.ext.lowercased() == "jpg") }).first != nil {
@@ -72,16 +72,15 @@ func getDataEntry(isPreview: Bool, displaySize: CGSize, completion: @escaping (_
 
     // NETWORKING
     let password = CCUtility.getPassword(account.account)!
-    NCCommunicationCommon.shared.setup(
+    NKCommon.shared.setup(
         account: account.account,
         user: account.user,
         userId: account.userId,
         password: password,
         urlBase: account.urlBase,
         userAgent: CCUtility.getUserAgent(),
-        webDav: NCUtilityFileSystem.shared.getWebDAV(account: account.account),
         nextcloudVersion: 0,
-        delegate: NCNetworking.shared)
+        delegate: nil) // NCNetworking.shared
 
     let requestBodyRecent =
     """
@@ -156,38 +155,38 @@ func getDataEntry(isPreview: Bool, displaySize: CGSize, completion: @escaping (_
     let isSimulatorOrTestFlight = NCUtility.shared.isSimulatorOrTestFlight()
     let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp())
 
-    NCCommunicationCommon.shared.levelLog = levelLog
+    NKCommon.shared.levelLog = levelLog
     if let pathDirectoryGroup = CCUtility.getDirectoryGroup()?.path {
-        NCCommunicationCommon.shared.pathLog = pathDirectoryGroup
+        NKCommon.shared.pathLog = pathDirectoryGroup
     }
     if isSimulatorOrTestFlight {
-        NCCommunicationCommon.shared.writeLog("Start \(NCBrandOptions.shared.brand) widget session with level \(levelLog) " + versionNextcloudiOS + " (Simulator / TestFlight)")
+        NKCommon.shared.writeLog("Start \(NCBrandOptions.shared.brand) widget session with level \(levelLog) " + versionNextcloudiOS + " (Simulator / TestFlight)")
     } else {
-        NCCommunicationCommon.shared.writeLog("Start \(NCBrandOptions.shared.brand) widget session with level \(levelLog) " + versionNextcloudiOS)
+        NKCommon.shared.writeLog("Start \(NCBrandOptions.shared.brand) widget session with level \(levelLog) " + versionNextcloudiOS)
     }
-    NCCommunicationCommon.shared.writeLog("Start \(NCBrandOptions.shared.brand) widget [Auto upload]")
+    NKCommon.shared.writeLog("Start \(NCBrandOptions.shared.brand) widget [Auto upload]")
 
     NCAutoUpload.shared.initAutoUpload(viewController: nil) { _ in
-        NCCommunicationCommon.shared.writeLog("Completition \(NCBrandOptions.shared.brand) widget [Auto upload]")
-        NCCommunication.shared.searchBodyRequest(serverUrl: account.urlBase, requestBody: requestBody, showHiddenFiles: CCUtility.getShowHiddenFiles()) { _, files, errorCode, errorDescription in
+        NKCommon.shared.writeLog("Completition \(NCBrandOptions.shared.brand) widget [Auto upload]")
+        NextcloudKit.shared.searchBodyRequest(serverUrl: account.urlBase, requestBody: requestBody, showHiddenFiles: CCUtility.getShowHiddenFiles()) { _, files, error in
 
             // Get recent files
             var recentDatas: [RecentData] = []
             for file in files {
                 guard !file.directory else { continue }
                 guard !isLive(file: file, files: files) else { continue }
-                let metadata = NCManageDatabase.shared.convertNCFileToMetadata(file, isEncrypted: false, account: account.account)
-                let subTitle = CCUtility.dateDiff(metadata.date as Date) + " · " + CCUtility.transformedSize(metadata.size)
+                //let metadata = NCManageDatabase.shared.convertNCFileToMetadata(file, isEncrypted: false, account: account.account)
+                let subTitle = CCUtility.dateDiff(file.date as Date) + " · " + CCUtility.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: metadata.path, user: metadata.user, fileName: metadata.fileName).urlEncoded else { continue }
+                guard var path = NCUtilityFileSystem.shared.getPath(path: file.path, user: file.user, fileName: file.fileName).urlEncoded else { continue }
                 if path.first == "/" { path = String(path.dropFirst())}
-                guard let user = metadata.user.urlEncoded else { continue }
-                let link = metadata.urlBase + "/f/" + metadata.fileId
+                guard let user = file.user.urlEncoded else { continue }
+                let link = file.urlBase + "/f/" + file.fileId
                 let urlString = "nextcloud://open-file?path=\(path)&user=\(user)&link=\(link)"
                 guard let url = URL(string: urlString) else { continue }
                 // Recent Data
-                let image:UIImage = NCUtilityGUI.shared.createFilePreviewImage(metadata: metadata, size: imageSize * 3, createPreview: false) ?? UIImage(named: "file")!
-                let recentData = RecentData.init(id: metadata.ocId, image: image, title: metadata.fileName, subTitle: subTitle, url: url)
+                let image:UIImage = NCUtilityGUI.shared.createFilePreviewImage(ocId: file.ocId, etag: file.etag, fileNameView: file.fileName, classFile: file.classFile, iconName: file.iconName, status: 0, createPreview: false) ?? UIImage(named: "file")!
+                let recentData = RecentData.init(id: file.ocId, image: UIImage(), title: file.fileName, subTitle: subTitle, url: url)
                 recentDatas.append(recentData)
                 if recentDatas.count == 5 { break}
             }
@@ -197,8 +196,8 @@ func getDataEntry(isPreview: Bool, displaySize: CGSize, completion: @escaping (_
             let footerImage = (fileInUpload == 0) ? "checkmark.icloud" : "arrow.triangle.2.circlepath"
 
             // Completion
-            if errorCode != 0 {
-                completion(NextcloudDataEntry(date: Date(), recentDatas: recentDatasTest, isPlaceholder: true, footerImage: "xmark.icloud", footerText: errorDescription))
+            if error != .success {
+                completion(NextcloudDataEntry(date: Date(), recentDatas: recentDatasTest, isPlaceholder: true, footerImage: "xmark.icloud", footerText: error.errorDescription))
             } else if recentDatas.isEmpty {
                 completion(NextcloudDataEntry(date: Date(), recentDatas: recentDatasTest, isPlaceholder: true, footerImage: footerImage, footerText: footerText))
             } else {

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

@@ -1356,7 +1356,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
         // Thumbnail
         if !metadata.directory {
             if metadata.name == NCGlobal.shared.appName {
-                if let image = NCUtilityGUI.shared.createFilePreviewImage(metadata: metadata, size: CGFloat(NCGlobal.shared.sizeIcon), createPreview: !metadata.hasPreview) {
+                if let image = NCUtilityGUI.shared.createFilePreviewImage(ocId: metadata.ocId, etag: metadata.etag, fileNameView: metadata.fileNameView, classFile: metadata.classFile, iconName: metadata.iconName, status: metadata.status, createPreview: !metadata.hasPreview) {
                     (cell as! NCCellProtocol).filePreviewImageView?.image = image
                 } else {
                     NCOperationQueue.shared.downloadThumbnail(metadata: metadata, placeholder: true, cell: cell, view: collectionView)

+ 12 - 8
iOSClient/Networking/NCService.swift

@@ -243,20 +243,24 @@ class NCService: NSObject {
             }
 
             //TODO: Test DASHBOARD
-            NCCommunication.shared.getDashboard { request in
-            } completion: { dashboardResults, json, errorCode, errorDescription in
-                if let dashboardResults = dashboardResults {
-                    for result in dashboardResults {
-                        for entry in result.dashboardEntries ?? [] {
-                            if let url = URL(string: entry.iconUrl) {
-                                NCCommunication.shared.getPreview(url: url) { account, data, errorCode, errorDescription in
-                                    print("")
+            /*
+            if #available(iOS 15.0, *) {
+                NCCommunication.shared.getDashboard { request in
+                } completion: { dashboardResults, json, errorCode, errorDescription in
+                    if let dashboardResults = dashboardResults {
+                        for result in dashboardResults {
+                            for entry in result.dashboardEntries ?? [] {
+                                if let url = URL(string: entry.iconUrl) {
+                                    NCCommunication.shared.getPreview(url: url) { account, data, errorCode, errorDescription in
+
+                                    }
                                 }
                             }
                         }
                     }
                 }
             }
+            */
         }
     }
 

+ 1 - 1
iOSClient/Transfers/NCTransfers.swift

@@ -184,7 +184,7 @@ class NCTransfers: NCCollectionViewCommon, NCTransferCellDelegate {
         cell.labelPath.text = pathText
         cell.setButtonMore(named: NCGlobal.shared.buttonMoreStop, image: NCBrandColor.cacheImages.buttonStop)
         cell.progressView.progress = 0.0
-        cell.imageItem.image = NCUtilityGUI.shared.createFilePreviewImage(metadata: metadata, size: 40 * 3, createPreview: true) ?? UIImage(named: "file")
+        cell.imageItem.image = NCUtilityGUI.shared.createFilePreviewImage(ocId: metadata.ocId, etag: metadata.etag, fileNameView: metadata.fileNameView, classFile: metadata.classFile, iconName: metadata.iconName, status: metadata.status, createPreview: true) ?? UIImage(named: "file")
         cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date) + " · " + CCUtility.transformedSize(metadata.size)
         if metadata.status == NCGlobal.shared.metadataStatusDownloading || metadata.status == NCGlobal.shared.metadataStatusUploading {
             cell.progressView.isHidden = false

+ 7 - 7
iOSClient/Utility/NCUtilityGUI.swift

@@ -30,31 +30,31 @@ class NCUtilityGUI: NSObject {
         return instance
     }()
 
-    func createFilePreviewImage(metadata: tableMetadata, size: CGFloat, createPreview: Bool) -> UIImage? {
+    func createFilePreviewImage(ocId: String, etag: String, fileNameView: String, classFile: String, iconName: String, status: Int, size: CGFloat = CGFloat(NCGlobal.shared.sizeIcon), createPreview: Bool) -> UIImage? {
 
         autoreleasepool {
             var imagePreview: UIImage?
-            let filePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
-            let iconImagePath = CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)!
+            let filePath = CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView)!
+            let iconImagePath = CCUtility.getDirectoryProviderStorageIconOcId(ocId, etag: etag)!
 
             if FileManager().fileExists(atPath: iconImagePath) {
                 imagePreview = UIImage(contentsOfFile: iconImagePath)
-            } else if createPreview && metadata.status >= NCGlobal.shared.metadataStatusNormal && metadata.classFile == NCCommunicationCommon.typeClassFile.image.rawValue && FileManager().fileExists(atPath: filePath) {
+            } else if createPreview && status >= NCGlobal.shared.metadataStatusNormal && classFile == NCCommunicationCommon.typeClassFile.image.rawValue && FileManager().fileExists(atPath: filePath) {
                 if let image = UIImage(contentsOfFile: filePath), let image = image.resizeImage(size: CGSize(width: NCGlobal.shared.sizeIcon, height: NCGlobal.shared.sizeIcon), isAspectRation: true), let data = image.jpegData(compressionQuality: 0.5) {
                     do {
                         try data.write(to: URL.init(fileURLWithPath: iconImagePath), options: .atomic)
                         imagePreview = image
                     } catch { }
                 }
-            } else if createPreview && metadata.status >= NCGlobal.shared.metadataStatusNormal && metadata.classFile == NCCommunicationCommon.typeClassFile.video.rawValue && FileManager().fileExists(atPath: filePath) {
+            } else if createPreview && status >= NCGlobal.shared.metadataStatusNormal && classFile == NCCommunicationCommon.typeClassFile.video.rawValue && FileManager().fileExists(atPath: filePath) {
                 if let image = NCUtility.shared.imageFromVideo(url: URL(fileURLWithPath: filePath), at: 0), let image = image.resizeImage(size: CGSize(width: NCGlobal.shared.sizeIcon, height: NCGlobal.shared.sizeIcon), isAspectRation: true), let data = image.jpegData(compressionQuality: 0.5) {
                     do {
                         try data.write(to: URL.init(fileURLWithPath: iconImagePath), options: .atomic)
                         imagePreview = image
                     } catch { }
                 }
-            } else if !metadata.iconName.isEmpty {
-                imagePreview = UIImage(named: metadata.iconName)
+            } else if !iconName.isEmpty {
+                imagePreview = UIImage(named: iconName)
             }
 
             if let image = imagePreview {