Browse Source

clear code

Marino Faggiana 6 years ago
parent
commit
df12f9c14d
3 changed files with 30 additions and 43 deletions
  1. 0 39
      iOSClient/Actions/CCActions.swift
  2. 16 3
      iOSClient/Main/CCMain.m
  3. 14 1
      iOSClient/Media/CCMedia.m

+ 0 - 39
iOSClient/Actions/CCActions.swift

@@ -29,11 +29,6 @@ import Foundation
     func renameMoveFileOrFolderFailure(_ metadataNet: CCMetadataNet, message: NSString, errorCode: NSInteger)
 }
 
-@objc protocol CCActionsSearchDelegate {
-    
-    func searchSuccessFailure(_ metadataNet: CCMetadataNet, metadatas: [Any], message: NSString, errorCode: NSInteger)
-}
-
 class CCActions: NSObject {
     
     //MARK: Shared Instance
@@ -166,40 +161,6 @@ class CCActions: NSObject {
         
         metadataNet.delegate?.renameMoveFileOrFolderFailure(metadataNet, message: message as NSString, errorCode: errorCode)
     }
-    
-    // --------------------------------------------------------------------------------------------
-    // MARK: Search
-    // --------------------------------------------------------------------------------------------
-    
-    @objc func search(_ serverUrl: String, fileName: String, etag: String, depth: String, date: Date?, contenType: [String]?, selector: String, delegate: AnyObject) {
-        
-        guard let directoryID = NCManageDatabase.sharedInstance.getDirectoryID(serverUrl) else {
-            return
-        }
-        
-        // Search DAV API
-            
-        let metadataNet: CCMetadataNet = CCMetadataNet.init(account: appDelegate.activeAccount)
-        
-        metadataNet.action = actionSearch
-        metadataNet.contentType = contenType
-        metadataNet.date = date
-        metadataNet.delegate = delegate
-        metadataNet.directoryID = directoryID
-        metadataNet.fileName = fileName
-        metadataNet.etag = etag
-        metadataNet.depth = depth
-        metadataNet.priority = Operation.QueuePriority.high.rawValue
-        metadataNet.selector = selector
-        metadataNet.serverUrl = serverUrl
-
-        appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
-    }
-    
-    @objc func searchSuccessFailure(_ metadataNet: CCMetadataNet, metadatas: [tableMetadata], message: NSString, errorCode: NSInteger) {
-        
-        metadataNet.delegate?.searchSuccessFailure(metadataNet, metadatas: metadatas, message: message, errorCode: errorCode)
-    }
 }
 
 

+ 16 - 3
iOSClient/Main/CCMain.m

@@ -37,7 +37,7 @@
 #import "NCNetworkingEndToEnd.h"
 #import "PKDownloadButton.h"
 
-@interface CCMain () <CCActionsRenameDelegate, CCActionsSearchDelegate, UITextViewDelegate, createFormUploadAssetsDelegate, MGSwipeTableCellDelegate, CCLoginDelegate, CCLoginDelegateWeb>
+@interface CCMain () <CCActionsRenameDelegate, UITextViewDelegate, createFormUploadAssetsDelegate, MGSwipeTableCellDelegate, CCLoginDelegate, CCLoginDelegateWeb>
 {
     AppDelegate *appDelegate;
         
@@ -1447,8 +1447,21 @@
 {
     NSString *startDirectory = [CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl];
     
-    [[CCActions sharedInstance] search:startDirectory fileName:_searchFileName etag:@"" depth:@"infinity" date:nil contenType:nil selector:selectorSearchFiles delegate:self];
-
+    CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:appDelegate.activeAccount];
+    
+    metadataNet.action = actionSearch;
+    metadataNet.contentType = nil;
+    metadataNet.date = nil;
+    metadataNet.directoryID = [[NCManageDatabase sharedInstance] getDirectoryID:startDirectory];
+    metadataNet.fileName = _searchFileName;
+    metadataNet.etag = @"";
+    metadataNet.depth = @"infinity";
+    metadataNet.priority = NSOperationQueuePriorityHigh;
+    metadataNet.selector = selectorSearchFiles;
+    metadataNet.serverUrl = startDirectory;
+    
+    [appDelegate addNetworkingOperationQueue:appDelegate.netQueue delegate:self metadataNet:metadataNet];
+    
     _noFilesSearchTitle = @"";
     _noFilesSearchDescription = NSLocalizedString(@"_search_in_progress_", nil);
     

+ 14 - 1
iOSClient/Media/CCMedia.m

@@ -711,7 +711,20 @@
             isSearchMode = YES;
             [self editingModeNO];
             
-            [[CCActions sharedInstance] search:startDirectory fileName:@"" etag:metadata.etag depth:@"infinity" date:[NSDate distantPast] contenType:@[@"image/%", @"video/%"] selector:selectorSearchContentType delegate:self];
+            CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:appDelegate.activeAccount];
+            
+            metadataNet.action = actionSearch;
+            metadataNet.contentType = @[@"image/%", @"video/%"];
+            metadataNet.date = [NSDate distantPast];
+            metadataNet.directoryID = [[NCManageDatabase sharedInstance] getDirectoryID:startDirectory];
+            metadataNet.fileName = @"";
+            metadataNet.etag = metadata.etag;
+            metadataNet.depth = @"infinity";
+            metadataNet.priority = NSOperationQueuePriorityHigh;
+            metadataNet.selector = selectorSearchContentType;
+            metadataNet.serverUrl = startDirectory;
+            
+            [appDelegate addNetworkingOperationQueue:appDelegate.netQueue delegate:self metadataNet:metadataNet];
             
         } else {
             [self reloadDatasource:nil action:k_action_NULL];