|
@@ -380,6 +380,76 @@ NSString const *OCWebDAVModificationDateKey = @"modificationdate";
|
|
|
[operation resume];
|
|
|
}
|
|
|
|
|
|
+- (void)search:(NSString *)path folder:(NSString *)folder startWith:(NSString *)startWith dateLastModified:(NSString *)dateLastModified user:(NSString *)user userID:(NSString *)userID onCommunication:(OCCommunication *)sharedOCCommunication withUserSessionToken:(NSString *)token success:(void(^)(NSHTTPURLResponse *, id, NSString *token))success failure:(void(^)(NSHTTPURLResponse *, id _Nullable responseObject, NSError *, NSString *token))failure {
|
|
|
+
|
|
|
+ NSString *body = @"";
|
|
|
+ NSString *whereType = @"";
|
|
|
+ NSString *whereDate = @"";
|
|
|
+
|
|
|
+ NSParameterAssert(success);
|
|
|
+
|
|
|
+ _requestMethod = @"SEARCH";
|
|
|
+
|
|
|
+ NSMutableURLRequest *request = [self requestWithMethod:_requestMethod path:path parameters:nil timeout:k_timeout_search];
|
|
|
+
|
|
|
+
|
|
|
+ body = [NSString stringWithFormat: @""
|
|
|
+ "<?xml version=\"1.0\"?>"
|
|
|
+ "<d:searchrequest xmlns:d=\"DAV:\" xmlns:oc=\"http://owncloud.org/ns\" xmlns:nc=\"http://nextcloud.org/ns\">"
|
|
|
+ "<d:basicsearch>"
|
|
|
+ "<d:select>"
|
|
|
+ "<d:prop>"
|
|
|
+ "<d:getlastmodified />"
|
|
|
+ "<d:getetag />"
|
|
|
+ "<d:getcontenttype />"
|
|
|
+ "<d:resourcetype/>"
|
|
|
+ "<d:getcontentlength />"
|
|
|
+ "<oc:fileid/>"
|
|
|
+ "<oc:id/>"
|
|
|
+ "<oc:permissions />"
|
|
|
+ "<oc:size />"
|
|
|
+ "<oc:favorite/>"
|
|
|
+ "<nc:is-encrypted/>"
|
|
|
+ "<nc:has-preview/>"
|
|
|
+ "</d:prop>"
|
|
|
+ "</d:select>"
|
|
|
+ "<d:from>"
|
|
|
+ "<d:scope>"
|
|
|
+ "<d:href>/files/%@%@</d:href>"
|
|
|
+ "<d:depth>infinity</d:depth>"
|
|
|
+ "</d:scope>"
|
|
|
+ "</d:from>"
|
|
|
+ "<d:orderby>"
|
|
|
+ "<d:order>"
|
|
|
+ "<d:prop><d:getlastmodified/></d:prop>"
|
|
|
+ "<d:descending/>"
|
|
|
+ "</d:order>"
|
|
|
+ "<d:order>"
|
|
|
+ "<d:prop><d:displayname/></d:prop>"
|
|
|
+ "<d:descending/>"
|
|
|
+ "</d:order>"
|
|
|
+ "</d:orderby>"
|
|
|
+ "<d:where><d:and><d:or>", userID, folder];
|
|
|
+
|
|
|
+ /*
|
|
|
+ for (NSString *type in contentType) {
|
|
|
+ whereType = [NSString stringWithFormat: @"%@<d:like><d:prop><d:getcontenttype/></d:prop><d:literal>%@</d:literal></d:like>", whereType, type];
|
|
|
+ }
|
|
|
+ */
|
|
|
+
|
|
|
+ body = [NSString stringWithFormat: @"%@%@</d:or><d:or>", body, whereType];
|
|
|
+
|
|
|
+ whereDate = [NSString stringWithFormat: @"%@<d:gte><d:prop><d:getlastmodified/></d:prop><d:literal>%@</d:literal></d:gte>", whereDate, dateLastModified];
|
|
|
+
|
|
|
+ body = [NSString stringWithFormat: @"%@%@</d:or></d:and></d:where></d:basicsearch></d:searchrequest>", body, whereDate];
|
|
|
+
|
|
|
+ [request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];
|
|
|
+ [request setValue:@"text/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)settingFavorite:(NSString * _Nonnull)path favorite:(BOOL)favorite onCommunication:(OCCommunication *)sharedOCCommunication withUserSessionToken:(NSString *)token success:(void(^)(NSHTTPURLResponse *, id, NSString *token))success failure:(void(^)(NSHTTPURLResponse *, id _Nullable responseObject, NSError *, NSString *token))failure {
|
|
|
|
|
|
NSParameterAssert(success);
|