Browse Source

codingcoding

marinofaggiana 4 years ago
parent
commit
973128e50c

+ 8 - 8
Nextcloud.xcodeproj/project.pbxproj

@@ -2480,7 +2480,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 69;
+				CURRENT_PROJECT_VERSION = 70;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2531,7 +2531,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 69;
+				CURRENT_PROJECT_VERSION = 70;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2574,7 +2574,7 @@
 				CODE_SIGN_ENTITLEMENTS = iOSClient/Brand/Share.entitlements;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 69;
+				CURRENT_PROJECT_VERSION = 70;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2618,7 +2618,7 @@
 				CODE_SIGN_ENTITLEMENTS = iOSClient/Brand/Share.entitlements;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 69;
+				CURRENT_PROJECT_VERSION = 70;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2668,7 +2668,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 69;
+				CURRENT_PROJECT_VERSION = 70;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2718,7 +2718,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 69;
+				CURRENT_PROJECT_VERSION = 70;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2760,7 +2760,7 @@
 				CODE_SIGN_ENTITLEMENTS = iOSClient/Brand/iOSClient.entitlements;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 69;
+				CURRENT_PROJECT_VERSION = 70;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				ENABLE_BITCODE = YES;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2805,7 +2805,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 69;
+				CURRENT_PROJECT_VERSION = 70;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				ENABLE_BITCODE = YES;
 				FRAMEWORK_SEARCH_PATHS = (

+ 9 - 96
iOSClient/AppDelegate.m

@@ -66,18 +66,15 @@
     [[NCCommunicationCommon shared] setupWithDelegate:[NCNetworking shared]];
     [[NCCommunicationCommon shared] setupWithUserAgent:[CCUtility getUserAgent] capabilitiesGroup:[NCBrandOptions sharedInstance].capabilitiesGroups];
     
-    // Verify upgrade
-    if ([self upgrade]) {
-        // Set account, if no exists clear all
-        tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
-        if (tableAccount == nil) {
-            // remove all the keys Chain
-            [CCUtility deleteAllChainStore];
-            // remove all the App group key
-            [[NSUserDefaults standardUserDefaults] removePersistentDomainForName:[[NSBundle mainBundle] bundleIdentifier]];
-        } else {
-            [self settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:[CCUtility getPassword:tableAccount.account]];
-        }
+    // Set account, if no exists clear all
+    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
+    if (tableAccount == nil) {
+        // remove all the keys Chain
+        [CCUtility deleteAllChainStore];
+        // remove all the App group key
+        [[NSUserDefaults standardUserDefaults] removePersistentDomainForName:[[NSBundle mainBundle] bundleIdentifier]];
+    } else {
+        [self settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:[CCUtility getPassword:tableAccount.account]];
     }
     
     // UserDefaults
@@ -1571,88 +1568,4 @@
     self.maintenanceMode = mode;
 }
 
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark ===== UPGRADE =====
-#pragma --------------------------------------------------------------------------------------------
-
-- (BOOL)upgrade
-{
-    #ifdef DEBUG
-    //self.maintenanceMode = YES;
-    #endif
-    
-    NSString *actualVersion = [CCUtility getVersion];
-    NSString *actualBuild = [CCUtility getBuild];
-    
-    /* ---------------------- UPGRADE VERSION ----------------------- */
-    
-    // VERSION < 2.17.6
-
-    if (([actualVersion compare:@"2.17.6" options:NSNumericSearch] == NSOrderedAscending)) {
-        
-        // Remove All old Photo Library
-        [[NCManageDatabase sharedInstance] clearTable:[tablePhotoLibrary class] account:nil];
-    }
-    
-    // VERSION == 2.17.6
-    if ([actualVersion isEqualToString:@"2.17.6"]) {
-        
-        // Build < 10
-        if (([actualBuild compare:@"10" options:NSNumericSearch] == NSOrderedAscending) || actualBuild == nil) {
-            
-            // Remove All old Photo Library
-            //[[NCManageDatabase sharedInstance] clearTable:[tablePhotoLibrary class] account:nil];
-        }
-    }
-        
-    if (([actualVersion compare:@"2.19.1" options:NSNumericSearch] == NSOrderedAscending)) {
-
-        [[NCManageDatabase sharedInstance] clearTable:[tableMetadata class] account:nil];
-    }
-    
-    if (([actualVersion compare:@"2.22.0" options:NSNumericSearch] == NSOrderedAscending)) {
-     
-        NSArray *records = [[NCManageDatabase sharedInstance] getTableLocalFilesWithPredicate:[NSPredicate predicateWithFormat:@"#size > 0"] sorted:@"account" ascending:NO];
-        
-        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
-            
-            NSString *account = @"";
-            NSString *directoryUser = @"";
-            NSString *fileName;
-            
-            for (tableLocalFile *record in records) {
-                if (![account isEqualToString:record.account]) {
-                    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", record.account]];
-                    if (tableAccount) {
-                        directoryUser = [CCUtility getDirectoryActiveUser:tableAccount.user activeUrl:tableAccount.url];
-                        account = record.account;
-                    }
-                }
-                fileName = [NSString stringWithFormat:@"%@/%@", directoryUser, record.ocId];
-                if (![directoryUser isEqualToString:@""] && [[NSFileManager defaultManager] fileExistsAtPath:fileName]) {
-                    [CCUtility moveFileAtPath:fileName toPath:[CCUtility getDirectoryProviderStorageOcId:record.ocId fileNameView:record.fileName]];
-                }
-            }
-        });
-    }
-    
-    if ([actualVersion isEqualToString:@"2.22.9"]) {
-        if (([actualBuild compare:@"8" options:NSNumericSearch] == NSOrderedAscending) || actualBuild == nil) {
-            [[NCManageDatabase sharedInstance] clearTable:[tableActivity class] account:nil];
-            [[NCManageDatabase sharedInstance] clearTable:[tableActivitySubjectRich class] account:nil];
-            [[NCManageDatabase sharedInstance] clearTable:[tableActivityPreview class] account:nil];
-        }
-    }
-    
-    if (([actualVersion compare:@"2.23.4" options:NSNumericSearch] == NSOrderedAscending)) {
-        NSArray *records = [[NCManageDatabase sharedInstance] getAllAccount];
-        for (tableAccount *record in records) {
-            [CCUtility setPassword:record.account password:record.password];
-            [[NCManageDatabase sharedInstance] removePasswordAccount:record.account];
-        }
-    }
-
-    return YES;
-}
-
 @end

+ 1 - 1
iOSClient/Main/NCDetailViewController.swift

@@ -643,7 +643,7 @@ extension NCDetailViewController: NCViewerImageViewControllerDelegate, NCViewerI
         
         if index >= metadatas.count { return }
         let metadata = metadatas[index]
-        let isPreview = CCUtility.fileProviderStoragePreviewExists(metadata.ocId, fileNameView: metadata.fileNameView)
+        let isPreview = CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, fileNameView: metadata.fileNameView)
         let isImage = CCUtility.fileProviderStorageSize(metadata.ocId, fileNameView: metadata.fileNameView) > 0
         let ext = CCUtility.getExtension(metadata.fileNameView)
         let isFolderEncrypted = CCUtility.isFolderEncrypted(metadata.serverUrl, e2eEncrypted: metadata.e2eEncrypted, account: metadata.account)

+ 1 - 1
iOSClient/Networking/NCOperationQueue.swift

@@ -58,7 +58,7 @@ import NCCommunication
     
     // Download Thumbnail
     @objc func downloadThumbnail(metadata: tableMetadata, activeUrl: String, view: Any, indexPath: IndexPath) {
-        if metadata.hasPreview && (!CCUtility.fileProviderStoragePreviewExists(metadata.ocId, fileNameView: metadata.fileName) || metadata.typeFile == k_metadataTypeFile_document) {
+        if metadata.hasPreview && (!CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, fileNameView: metadata.fileName) || metadata.typeFile == k_metadataTypeFile_document) {
             
             for operation in  downloadThumbnailQueue.operations {
                 if (operation as! NCOperationDownloadThumbnail).metadata.ocId == metadata.ocId { return }

+ 1 - 1
iOSClient/PeekPop/CCPeekPop.m

@@ -49,7 +49,7 @@
     
     if (self.metadata.hasPreview) {
         
-        if ([CCUtility fileProviderStoragePreviewExists:self.metadata.ocId fileNameView:self.metadata.fileNameView]) {
+        if ([CCUtility fileProviderStoragePreviewIconExists:self.metadata.ocId fileNameView:self.metadata.fileNameView]) {
             
             UIImage *fullImage = [UIImage imageWithContentsOfFile:[CCUtility getDirectoryProviderStorageOcId:self.metadata.ocId fileNameView:self.metadata.fileNameView]];
             if (fullImage != nil) {

+ 2 - 2
iOSClient/Trash/NCTrash.swift

@@ -538,7 +538,7 @@ extension NCTrash: UICollectionViewDataSource {
         if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconOcId(tableTrash.fileId, fileNameView: tableTrash.fileName)) {
             image = UIImage.init(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(tableTrash.fileId, fileNameView: tableTrash.fileName))
         } else {
-            if tableTrash.hasPreview && !CCUtility.fileProviderStoragePreviewExists(tableTrash.fileId, fileNameView: tableTrash.fileName) {
+            if tableTrash.hasPreview && !CCUtility.fileProviderStoragePreviewIconExists(tableTrash.fileId, fileNameView: tableTrash.fileName) {
                 downloadThumbnail(with: tableTrash, indexPath: indexPath)
             }
         }
@@ -743,7 +743,7 @@ extension NCTrash {
     
     func downloadThumbnail(with tableTrash: tableTrash, indexPath: IndexPath) {
         
-        let fileNamePreviewLocalPath = CCUtility.getDirectoryProviderStorageIconOcId(tableTrash.fileId, fileNameView: tableTrash.fileName)!
+        let fileNamePreviewLocalPath = CCUtility.getDirectoryProviderStoragePreviewOcId(tableTrash.fileId, fileNameView: tableTrash.fileName)!
         let fileNameIconLocalPath = CCUtility.getDirectoryProviderStorageIconOcId(tableTrash.fileId, fileNameView: tableTrash.fileName)!
         
         NCCommunication.shared.downloadPreview(fileNamePathOrFileId: tableTrash.fileId, fileNamePreviewLocalPath: fileNamePreviewLocalPath, widthPreview: Int(k_sizePreview), heightPreview: Int(k_sizePreview), fileNameIconLocalPath: fileNameIconLocalPath, sizeIcon: Int(k_sizeIcon), endpointTrashbin: true) { (account, imagePreview, imageIcon, errorCode, errorDescription) in

+ 1 - 7
iOSClient/Utility/CCUtility.h

@@ -45,12 +45,6 @@
 + (void)deleteAllChainStore;
 + (void)storeAllChainInService;
 
-+ (NSString *)getVersion;
-+ (NSString *)setVersion;
-
-+ (NSString *)getBuild;
-+ (NSString *)setBuild;
-
 + (NSString *)getPasscode;
 + (void)setPasscode:(NSString *)passcode;
 
@@ -212,7 +206,7 @@
 + (NSString *)getDirectoryProviderStoragePreviewOcId:(NSString *)ocId fileNameView:(NSString *)fileNameView;
 + (BOOL)fileProviderStorageExists:(NSString *)ocId fileNameView:(NSString *)fileNameView;
 + (double)fileProviderStorageSize:(NSString *)ocId fileNameView:(NSString *)fileNameView;
-+ (BOOL)fileProviderStoragePreviewExists:(NSString *)ocId fileNameView:(NSString *)fileNameView;
++ (BOOL)fileProviderStoragePreviewIconExists:(NSString *)ocId fileNameView:(NSString *)fileNameView;
 
 + (void)removeGroupApplicationSupport;
 + (void)removeGroupLibraryDirectory;

+ 8 - 34
iOSClient/Utility/CCUtility.m

@@ -60,34 +60,6 @@
 
 #pragma ------------------------------ GET/SET
 
-+ (NSString *)getVersion
-{
-    return [UICKeyChainStore stringForKey:@"version" service:k_serviceShareKeyChain];
-}
-
-+ (NSString *)setVersion
-{
-    NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
-    
-    [UICKeyChainStore setString:version forKey:@"version" service:k_serviceShareKeyChain];
-    
-    return version;
-}
-
-+ (NSString *)getBuild
-{
-    return [UICKeyChainStore stringForKey:@"build" service:k_serviceShareKeyChain];
-}
-
-+ (NSString *)setBuild
-{
-    NSString *build = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];
-    
-    [UICKeyChainStore setString:build forKey:@"build" service:k_serviceShareKeyChain];
-    
-    return build;
-}
-
 + (NSString *)getPasscode
 {
     return [UICKeyChainStore stringForKey:@"passcodeBlock" service:k_serviceShareKeyChain];
@@ -1152,12 +1124,12 @@
 
 + (NSString *)getDirectoryProviderStorageIconOcId:(NSString *)ocId fileNameView:(NSString *)fileNameView
 {
-    return [NSString stringWithFormat:@"%@/%@.ico", [self getDirectoryProviderStorageOcId:ocId], fileNameView];
+    return [NSString stringWithFormat:@"%@/%@.small.ico", [self getDirectoryProviderStorageOcId:ocId], fileNameView];
 }
 
 + (NSString *)getDirectoryProviderStoragePreviewOcId:(NSString *)ocId fileNameView:(NSString *)fileNameView
 {
-    return [NSString stringWithFormat:@"%@/%@.preview", [self getDirectoryProviderStorageOcId:ocId], fileNameView];
+    return [NSString stringWithFormat:@"%@/%@.preview.ico", [self getDirectoryProviderStorageOcId:ocId], fileNameView];
 }
 
 + (BOOL)fileProviderStorageExists:(NSString *)ocId fileNameView:(NSString *)fileNameView
@@ -1189,13 +1161,15 @@
     else return false;
 }
 
-+ (BOOL)fileProviderStoragePreviewExists:(NSString *)ocId fileNameView:(NSString *)fileNameView
++ (BOOL)fileProviderStoragePreviewIconExists:(NSString *)ocId fileNameView:(NSString *)fileNameView
 {
-    NSString *fileNamePath = [self getDirectoryProviderStoragePreviewOcId:ocId fileNameView:fileNameView];
+    NSString *fileNamePathPreview = [self getDirectoryProviderStoragePreviewOcId:ocId fileNameView:fileNameView];
+    NSString *fileNamePathIcon = [self getDirectoryProviderStorageIconOcId:ocId fileNameView:fileNameView];
     
-    unsigned long long fileSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:fileNamePath error:nil] fileSize];
+    unsigned long long fileSizePreview = [[[NSFileManager defaultManager] attributesOfItemAtPath:fileNamePathPreview error:nil] fileSize];
+    unsigned long long fileSizeIcon = [[[NSFileManager defaultManager] attributesOfItemAtPath:fileNamePathIcon error:nil] fileSize];
     
-    if (fileSize > 0) return true;
+    if (fileSizePreview > 0 && fileSizeIcon > 0) return true;
     else return false;
 }
 

+ 1 - 1
iOSClient/Viewer/NCViewerImage/NCViewerImageCommon.swift

@@ -70,7 +70,7 @@ class NCViewerImageCommon: NSObject {
     
     func getThumbnailImage(metadata: tableMetadata) -> UIImage? {
         
-        if CCUtility.fileProviderStoragePreviewExists(metadata.ocId, fileNameView: metadata.fileNameView) {
+        if CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, fileNameView: metadata.fileNameView) {
             let imagePath = CCUtility.getDirectoryProviderStoragePreviewOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
             return UIImage.init(contentsOfFile: imagePath)
         }