marinofaggiana 5 жил өмнө
parent
commit
13cd7468f8

+ 2 - 0
iOSClient/Library/OCCommunicationLib/OCCommunication.h

@@ -472,6 +472,8 @@ typedef enum {
 
 - (void)search:(NSString *)path folder:(NSString *)folder fileName:(NSString *)fileName depth:(NSString *)depth lteDateLastModified:(NSString *)lteDateLastModified gteDateLastModified:(NSString *)gteDateLastModified contentType:(NSArray *)contentType 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;
 
+- (void)search:(NSString *)path folderStartWith:(NSString *)folderStartWith dateLastModified:(NSString *)dateLastModified numberOfItem:(NSInteger)numberOfItem 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;
+
 ///-----------------------------------
 /// @name Setting favorite
 ///-----------------------------------

+ 27 - 0
iOSClient/Library/OCCommunicationLib/OCCommunication.m

@@ -661,6 +661,33 @@
     }];
 }
 
+- (void)search:(NSString *)path folderStartWith:(NSString *)folderStartWith dateLastModified:(NSString *)dateLastModified numberOfItem:(NSInteger)numberOfItem 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 {
+    
+    if (!token){
+        token = @"no token";
+    }
+    
+    path = [path encodeString:NSUTF8StringEncoding];
+    
+    OCWebDAVClient *request = [OCWebDAVClient new];
+    request = [self getRequestWithCredentials:request];
+    
+    [request search:path folderStartWith:folderStartWith dateLastModified:dateLastModified numberOfItem:numberOfItem userID:_userID onCommunication:sharedOCCommunication withUserSessionToken:token success:^(NSHTTPURLResponse *response, id responseObject, NSString *token) {
+        if (successRequest) {
+            
+            NSData *responseData = (NSData*) responseObject;
+            
+            OCXMLListParser *parser = [OCXMLListParser new];
+            [parser initParserWithData:responseData];
+            NSMutableArray *searchList = [parser.searchList mutableCopy];
+            
+            successRequest(response, searchList, request.redirectedServer, token);
+        }
+    } failure:^(NSHTTPURLResponse *response, id responseData, NSError *error, NSString *token) {
+        failureRequest(response, error, token, request.redirectedServer);
+    }];
+}
+
 ///-----------------------------------
 /// @name Setting favorite
 ///-----------------------------------