Browse Source

clear code

Marino Faggiana 8 years ago
parent
commit
46151abe1b

+ 0 - 4
iOSClient/Actions/CCActions.swift

@@ -236,10 +236,6 @@ class CCActions: NSObject {
             metadataNet.session = k_upload_session_foreground
             metadataNet.taskStatus = Int(k_taskStatusResume)
             
-            if CCCoreData.isOfflineLocalEtag(metadata.fileID, activeAccount: appDelegate.activeAccount) {
-                metadataNet.selectorPost = selectorAddOffline
-            }
-            
             appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
             
             // delete file in filesystem

+ 0 - 1
iOSClient/CCGlobal.h

@@ -154,7 +154,6 @@ extern NSString *const urlBaseUploadDB;
 // Metadata.Net SELECTOR
 #define selectorAddFavorite                             @"addFavorite"
 #define selectorAddLocal                                @"addLocal"
-#define selectorAddOffline                              @"addOffline"
 #define selectorCreateFolder                            @"createFolder"
 #define selectorDecryptFile                             @"decryptFile"
 #define selectorDelete                                  @"delete"

+ 0 - 6
iOSClient/Favorites/CCSynchronize.m

@@ -427,12 +427,6 @@
         NSString *selector, *selectorPost;
         BOOL downloadData = NO, downloadPlist = NO;
         
-        // it's a offline ?
-        BOOL isOffline = [CCCoreData isOfflineLocalEtag:metadata.fileID activeAccount:app.activeAccount];
-        
-        if (isOffline)
-            selectorPost = selectorAddOffline;
-        
         if ([metadata.type isEqualToString: k_metadataType_file]) {
             downloadData = YES;
             selector = selectorDownloadSynchronize;

+ 2 - 0
iOSClient/FileSystem/CCCoreData.h

@@ -123,9 +123,11 @@
 + (NSArray *)getTableLocalFileWithPredicate:(NSPredicate *)predicate;
 
 // ===== Offline LocalFile =====
+/*
 + (void)setOfflineLocalEtag:(NSString *)fileID offline:(BOOL)offline activeAccount:(NSString *)activeAccount;
 + (BOOL)isOfflineLocalEtag:(NSString *)fileID activeAccount:(NSString *)activeAccount;
 + (NSArray *)getOfflineLocalFileActiveAccount:(NSString *)activeAccount directoryUser:(NSString *)directoryUser;
+*/
 
 // ===== GeoInformation =====
 

+ 0 - 53
iOSClient/FileSystem/CCCoreData.m

@@ -876,59 +876,6 @@
     return [TableLocalFile MR_findAllWithPredicate:predicate];
 }
 
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark ===== Offline LocalFile =====
-#pragma --------------------------------------------------------------------------------------------
-
-+ (void)setOfflineLocalEtag:(NSString *)fileID offline:(BOOL)offline activeAccount:(NSString *)activeAccount
-{
-    [MagicalRecord saveWithBlockAndWait:^(NSManagedObjectContext *localContext) {
-        
-        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(fileID == %@) AND (account == %@)", fileID, activeAccount];
-        TableLocalFile *record = [TableLocalFile MR_findFirstWithPredicate:predicate inContext:localContext];
-        
-        if (record)
-            record.offline = [NSNumber numberWithBool:offline];
-    }];
-}
-
-+ (BOOL)isOfflineLocalEtag:(NSString *)fileID activeAccount:(NSString *)activeAccount
-{
-    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(fileID == %@) AND (offline == 1) AND (account == %@)", fileID, activeAccount];
-    TableLocalFile *record = [TableLocalFile MR_findFirstWithPredicate:predicate];
-    
-    if (record) return YES;
-    else return NO;
-}
-
-+ (NSArray *)getOfflineLocalFileActiveAccount:(NSString *)activeAccount directoryUser:(NSString *)directoryUser
-{
-    NSMutableArray *metadatas = [NSMutableArray new];
-    NSArray *files = [self getTableLocalFileWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (offline == 1)", activeAccount] controlZombie:YES activeAccount:activeAccount directoryUser:directoryUser];
-    
-    for (TableLocalFile *file in files) {
-        
-        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(fileID == %@) AND (account == %@)", file.fileID, activeAccount];
-        //tableMetadata *metadata = [self getMetadataWithPreficate:predicate context:nil];
-        
-        tableMetadata *metadata =  [[NCManageDatabase sharedInstance] getMetadataWithPreficate:predicate];
-        
-        if (metadata) {
-            
-            // verify if is not on directory offline
-            
-            NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(directoryID == %@) AND (offline == 1) AND (account == %@)", metadata.directoryID, activeAccount];
-            
-            TableDirectory *directory = [TableDirectory MR_findFirstWithPredicate:predicate];
-            
-            if (!directory)
-                [metadatas addObject:metadata];
-        }
-    }
-
-    return metadatas;
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== GeoInformation =====
 #pragma --------------------------------------------------------------------------------------------

+ 1 - 47
iOSClient/Main/CCMain.m

@@ -1391,12 +1391,6 @@
         [[CCActions sharedInstance] settingFavorite:metadata favorite:YES delegate:self];
     }
     
-    // add Offline
-    if ([selector isEqualToString:selectorAddOffline]) {
-        [CCCoreData setOfflineLocalEtag:metadata.fileID offline:YES activeAccount:app.activeAccount];
-        [self reloadDatasource:serverUrl fileID:metadata.fileID selector:selector];
-    }
-    
     // encrypted file
     if ([selector isEqualToString:selectorEncryptFile]) {
         [self encryptedFile:metadata];
@@ -2180,9 +2174,6 @@
         metadataNet.session = k_upload_session_foreground;
         metadataNet.taskStatus = k_taskStatusResume;
         
-        if ([CCCoreData isOfflineLocalEtag:metadata.fileID activeAccount:app.activeAccount])
-            metadataNet.selectorPost = selectorAddOffline;
-        
         [app addNetworkingOperationQueue:app.netQueue delegate:self metadataNet:metadataNet];
     }
 }
@@ -3158,29 +3149,6 @@
     [[CCActions sharedInstance] settingFavorite:metadata favorite:NO delegate:self];
 }
 
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark ===== Offline =====
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)addOffline:(tableMetadata *)metadata
-{
-    NSString *serverUrl = [[NCManageDatabase sharedInstance] getServerUrl:metadata.directoryID];
-    
-    [[CCNetworking sharedNetworking] downloadFile:metadata.fileID serverUrl:serverUrl downloadData:YES downloadPlist:NO selector:selectorAddOffline selectorPost:nil session:k_download_session taskStatus:k_taskStatusResume delegate:self];
-    
-    NSIndexPath *indexPath = [_sectionDataSource.fileIDIndexPath objectForKey:metadata.fileID];
-    if (indexPath) [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationAutomatic];
-}
-
-- (void)removeOffline:(tableMetadata *)metadata
-{
-    [CCCoreData setOfflineLocalEtag:metadata.fileID offline:NO activeAccount:app.activeAccount];
-    
-    NSIndexPath *indexPath = [_sectionDataSource.fileIDIndexPath objectForKey:metadata.fileID];
-    if (indexPath) [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationAutomatic];
-}
-
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Local =====
 #pragma --------------------------------------------------------------------------------------------
@@ -4107,14 +4075,11 @@
     
     NSString *serverUrl = [[NCManageDatabase sharedInstance] getServerUrl:_metadata.directoryID];
     
-    NSString *titoloCriptaDecripta, *titoloOffline, *titoloLock, *titleFavorite;
+    NSString *titoloCriptaDecripta, *titoloLock, *titleFavorite;
     
     if (_metadata.cryptated) titoloCriptaDecripta = [NSString stringWithFormat:NSLocalizedString(@"_decrypt_", nil)];
     else titoloCriptaDecripta = [NSString stringWithFormat:NSLocalizedString(@"_encrypt_", nil)];
     
-    if ([CCCoreData isOfflineLocalEtag:_metadata.fileID activeAccount:app.activeAccount]) titoloOffline = [NSString stringWithFormat:NSLocalizedString(@"_remove_offline_", nil)];
-    else titoloOffline = [NSString stringWithFormat:NSLocalizedString(@"_add_offline_", nil)];
-    
     if (_metadata.favorite) {
         
         titleFavorite = [NSString stringWithFormat:NSLocalizedString(@"_remove_favorites_", nil)];
@@ -5087,17 +5052,6 @@
     if (metadata.directory && (directory.lock && [[CCUtility getBlockCode] length]))
         cell.statusImageView.image = [UIImage imageNamed:@"passcode"];
     
-    // ----------------------------------------------------------------------------------------------------------
-    // Offline
-    // ----------------------------------------------------------------------------------------------------------
-
-    BOOL isOfflineFile = [CCCoreData isOfflineLocalEtag:metadata.fileID activeAccount:app.activeAccount];
-    
-    if (isOfflineFile) {
-        
-        cell.offlineImageView.image = [UIImage imageNamed:@"offline"];
-    }
-    
     // ----------------------------------------------------------------------------------------------------------
     // Favorite
     // ----------------------------------------------------------------------------------------------------------