Marino Faggiana 8 жил өмнө
parent
commit
87f32827bc

+ 1 - 1
Libraries external/OCCommunicationLib/OCCommunicationLib/OCCommunication.h

@@ -461,7 +461,7 @@ typedef enum {
 
 
 
-- (void) search: (NSString *) fileName withUserSessionToken:(NSString *)token
+- (void) search: (NSString *) path fileName:(NSString *)fileName withUserSessionToken:(NSString *)token
     onCommunication:(OCCommunication *)sharedOCCommunication
      successRequest:(void(^)(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *token)) successRequest
      failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *token, NSString *redirectedServer)) failureRequest;

+ 2 - 2
Libraries external/OCCommunicationLib/OCCommunicationLib/OCCommunication.m

@@ -617,7 +617,7 @@
 ///-----------------------------------
 /// @name search
 ///-----------------------------------
-- (void) search: (NSString *) fileName withUserSessionToken:(NSString *)token
+- (void) search: (NSString *) path fileName:(NSString *)fileName withUserSessionToken:(NSString *)token
     onCommunication:(OCCommunication *)sharedOCCommunication
      successRequest:(void(^)(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *token)) successRequest
      failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *token, NSString *redirectedServer)) failureRequest{
@@ -631,7 +631,7 @@
     OCWebDAVClient *request = [OCWebDAVClient new];
     request = [self getRequestWithCredentials:request];
     
-    [request search:fileName onCommunication:sharedOCCommunication withUserSessionToken:token success:^(NSHTTPURLResponse *response, id responseObject, NSString *token) {
+    [request search:path fileName:fileName onCommunication:sharedOCCommunication withUserSessionToken:token success:^(NSHTTPURLResponse *response, id responseObject, NSString *token) {
         if (successRequest) {
             NSData *responseData = (NSData*) responseObject;
             

+ 1 - 1
Libraries external/OCCommunicationLib/OCCommunicationLib/OCWebDavClient/OCWebDAVClient.h

@@ -182,7 +182,7 @@ extern NSString * _Nullable OCWebDAVModificationDateKey;
 
 
 
-- (void)search:(NSString * _Nonnull)fileName
+- (void)search:(NSString * _Nonnull)path fileName:(NSString * _Nonnull)fileName
  onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication withUserSessionToken:(NSString * _Nonnull)token
          success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id  _Nonnull, NSString * _Nonnull token))success
          failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id  _Nullable responseObject, NSError * _Nonnull, NSString * _Nonnull token))failure;

+ 39 - 32
Libraries external/OCCommunicationLib/OCCommunicationLib/OCWebDavClient/OCWebDAVClient.m

@@ -258,6 +258,40 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
     [operation resume];
 }
 
+- (void)mr_search:(NSString *)patf fileName:(NSString *)fileName depth:(NSUInteger)depth withUserSessionToken:(NSString*)token onCommunication:
+(OCCommunication *)sharedOCCommunication
+            success:(void(^)(NSHTTPURLResponse *operation, id response, NSString *token))success
+            failure:(void(^)(NSHTTPURLResponse *response, id  _Nullable responseObject, NSError *, NSString *token))failure {
+    NSParameterAssert(success);
+    
+    _requestMethod = @"SEARCH";
+    NSMutableURLRequest *request = [self requestWithMethod:_requestMethod path:fileName parameters:nil];
+    /*
+     NSString *depthHeader = nil;
+     if (depth <= 0)
+     depthHeader = @"0";
+     else if (depth == 1)
+     depthHeader = @"1";
+     else
+     depthHeader = @"infinity";
+     [request setValue: depthHeader forHTTPHeaderField: @"Depth"];
+     
+     
+     [request setHTTPBody:[@"<?xml version=\"1.0\" encoding=\"UTF-8\"?><D:propfind xmlns:D=\"DAV:\"><D:prop><D:resourcetype/><D:getlastmodified/><size xmlns=\"http://owncloud.org/ns\"/><D:creationdate/><id xmlns=\"http://owncloud.org/ns\"/><D:getcontentlength/><D:displayname/><D:quota-available-bytes/><D:getetag/><permissions xmlns=\"http://owncloud.org/ns\"/><D:quota-used-bytes/><D:getcontenttype/></D:prop></D:propfind>" dataUsingEncoding:NSUTF8StringEncoding]];
+     */
+    
+    NSString *body = [NSString stringWithFormat:@"<?xml version=\"1.0\"?><d:searchrequest xmlns:d=\"DAV:\" xmlns:oc=\"http://owncloud.org/ns\"><d:basicsearch><d:select><d:prop><d:displayname/></d:prop></d:select><d:from><d:scope><d:href>/files/%@</d:href><d:depth>infinity</d:depth></d:scope></d:from><d:where><d:like><d:prop><d:displayname/></d:prop><d:literal>%@%%</d:literal></d:like></d:where></d:basicsearch></d:searchrequest>]",@"marino.faggiana",fileName];
+    
+    [request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];
+    
+    [request setValue:@"application/xml" forHTTPHeaderField:@"Content-Type"];
+    
+    
+    OCHTTPRequestOperation *operation = [self mr_operationWithRequest:request onCommunication:sharedOCCommunication withUserSessionToken:token success:success failure:failure];
+    [self setRedirectionBlockOnDatataskWithOCCommunication:sharedOCCommunication andSessionManager:sharedOCCommunication.networkSessionManager];
+    [operation resume];
+}
+
 - (void)propertiesOfPath:(NSString *)path
          onCommunication: (OCCommunication *)sharedOCCommunication
                  success:(void(^)(NSHTTPURLResponse *, id ))success
@@ -279,38 +313,11 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
     [self mr_listPath:path depth:1 withUserSessionToken:token onCommunication:sharedOCCommunication success:success failure:failure];
 }
 
-- (void)search:(NSString *)fileName depth:(NSUInteger)depth withUserSessionToken:(NSString*)token onCommunication:
-(OCCommunication *)sharedOCCommunication
-            success:(void(^)(NSHTTPURLResponse *operation, id response, NSString *token))success
-            failure:(void(^)(NSHTTPURLResponse *response, id  _Nullable responseObject, NSError *, NSString *token))failure {
-    NSParameterAssert(success);
-    
-    _requestMethod = @"SEARCH";
-    NSMutableURLRequest *request = [self requestWithMethod:_requestMethod path:fileName parameters:nil];
-    /*
-    NSString *depthHeader = nil;
-    if (depth <= 0)
-        depthHeader = @"0";
-    else if (depth == 1)
-        depthHeader = @"1";
-    else
-        depthHeader = @"infinity";
-    [request setValue: depthHeader forHTTPHeaderField: @"Depth"];
-    
-    
-    [request setHTTPBody:[@"<?xml version=\"1.0\" encoding=\"UTF-8\"?><D:propfind xmlns:D=\"DAV:\"><D:prop><D:resourcetype/><D:getlastmodified/><size xmlns=\"http://owncloud.org/ns\"/><D:creationdate/><id xmlns=\"http://owncloud.org/ns\"/><D:getcontentlength/><D:displayname/><D:quota-available-bytes/><D:getetag/><permissions xmlns=\"http://owncloud.org/ns\"/><D:quota-used-bytes/><D:getcontenttype/></D:prop></D:propfind>" dataUsingEncoding:NSUTF8StringEncoding]];
-    */
-    
-    NSString *body = [NSString stringWithFormat:@"<?xml version=\"1.0\"?><d:searchrequest xmlns:d=\"DAV:\" xmlns:oc=\"http://owncloud.org/ns\"><d:basicsearch><d:select><d:prop><d:displayname/></d:prop></d:select><d:from><d:scope><d:href>/files/%@</d:href><d:depth>infinity</d:depth></d:scope></d:from><d:where><d:like><d:prop><d:displayname/></d:prop><d:literal>%@%%</d:literal></d:like></d:where></d:basicsearch></d:searchrequest>]",@"marino.faggiana",fileName];
-    
-    [request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];
-    
-    [request setValue:@"application/xml" forHTTPHeaderField:@"Content-Type"];
-    
-    
-    OCHTTPRequestOperation *operation = [self mr_operationWithRequest:request onCommunication:sharedOCCommunication withUserSessionToken:token success:success failure:failure];
-    [self setRedirectionBlockOnDatataskWithOCCommunication:sharedOCCommunication andSessionManager:sharedOCCommunication.networkSessionManager];
-    [operation resume];
+- (void)search:(NSString *)path fileName:(NSString *)fileName
+ onCommunication:(OCCommunication *)sharedOCCommunication withUserSessionToken:(NSString *)token
+         success:(void(^)(NSHTTPURLResponse *, id, NSString *token))success
+         failure:(void(^)(NSHTTPURLResponse *, id  _Nullable responseObject, NSError *, NSString *token))failure {
+    [self mr_search:path fileName:fileName depth:1 withUserSessionToken:token onCommunication:sharedOCCommunication success:success failure:failure];
 }
 
 - (NSURLSessionDownloadTask *)downloadWithSessionPath:(NSString *)remoteSource toPath:(NSString *)localDestination defaultPriority:(BOOL)defaultPriority onCommunication:(OCCommunication *)sharedOCCommunication progress:(void(^)(NSProgress *progress))downloadProgress success:(void(^)(NSURLResponse *response, NSURL *filePath))success failure:(void(^)(NSURLResponse *response, NSError *error))failure{

+ 11 - 1
iOSClient/Actions/CCActions.swift

@@ -289,7 +289,7 @@ class CCActions: NSObject {
     
     func search(_ serverUrl : String?, fileName : String, delegate: AnyObject) {
         
-        if (serverUrl != nil) {
+        if (serverUrl == nil) {
             
             let metadataNet: CCMetadataNet = CCMetadataNet.init(account: appDelegate.activeAccount)
 
@@ -305,6 +305,16 @@ class CCActions: NSObject {
         } else {
             
             // Search DAV API
+            
+            let metadataNet: CCMetadataNet = CCMetadataNet.init(account: appDelegate.activeAccount)
+            
+            metadataNet.action = actionSearch
+            metadataNet.delegate = delegate
+            metadataNet.fileName = fileName
+            metadataNet.selector = selectorSearch
+            metadataNet.serverUrl = serverUrl!
+
+            appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
         }
     }
     

+ 6 - 1
iOSClient/Main/CCMain.m

@@ -1879,7 +1879,12 @@
     if (fileName.length >= k_minCharsSearch && [fileName isEqualToString:_searchFileName] == NO) {
         
         _searchFileName = fileName;
-        [[CCActions sharedInstance] search:_serverUrl fileName:_searchFileName delegate:self];
+        
+        if ([_serverUrl isEqualToString:[CCUtility getHomeServerUrlActiveUrl:app.activeUrl]])
+            [[CCActions sharedInstance] search:_serverUrl fileName:_searchFileName delegate:self];
+        else
+            [[CCActions sharedInstance] search:_serverUrl fileName:_searchFileName delegate:self];
+
     }
     
     if (_searchResultMetadatas.count == 0 && fileName.length == 0) {

+ 1 - 1
iOSClient/Networking/OCNetworking.m

@@ -422,7 +422,7 @@
     [communication setCredentialsWithUser:_activeUser andPassword:_activePassword];
     [communication setUserAgent:[CCUtility getUserAgent]];
     
-    [communication search:_metadataNet.fileName withUserSessionToken:nil onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *token) {
+    [communication search:_metadataNet.serverUrl fileName:_metadataNet.fileName withUserSessionToken:nil onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *token) {
         //
     } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *token, NSString *redirectedServer) {
         //