|
@@ -2194,7 +2194,7 @@
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
-- (void)geTemplatesRichdocumentsWithAccount:(NSString *)account typeTemplate:(NSString *)typeTemplate completion:(void(^)(NSString *account, NSArray *listOfTemplate, NSString *message, NSInteger errorCode))completion
|
|
|
+- (void)getTemplatesRichdocumentsWithAccount:(NSString *)account typeTemplate:(NSString *)typeTemplate completion:(void(^)(NSString *account, NSArray *listOfTemplate, NSString *message, NSInteger errorCode))completion
|
|
|
{
|
|
|
tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", account]];
|
|
|
if (tableAccount == nil) {
|
|
@@ -2209,7 +2209,7 @@
|
|
|
|
|
|
[communication setCredentialsWithUser:tableAccount.user andUserID:tableAccount.userID andPassword:[CCUtility getPassword:account]];
|
|
|
[communication setUserAgent:[CCUtility getUserAgent]];
|
|
|
- [communication geTemplatesRichdocuments:[tableAccount.url stringByAppendingString:@"/"] typeTemplate:typeTemplate onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *listOfTemplate, NSString *redirectedServer) {
|
|
|
+ [communication getTemplatesRichdocuments:[tableAccount.url stringByAppendingString:@"/"] typeTemplate:typeTemplate onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *listOfTemplate, NSString *redirectedServer) {
|
|
|
|
|
|
completion(account, listOfTemplate, nil, 0);
|
|
|
|
|
@@ -2328,6 +2328,56 @@
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
+#pragma --------------------------------------------------------------------------------------------
|
|
|
+#pragma mark ===== Full Text Search =====
|
|
|
+#pragma --------------------------------------------------------------------------------------------
|
|
|
+
|
|
|
+- (void)fullTextSearchWithAccount:(NSString *)account text:(NSString *)text page:(NSInteger)page completion:(void(^)(NSString *account, NSArray *items, NSString *message, NSInteger errorCode))completion
|
|
|
+{
|
|
|
+ tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", account]];
|
|
|
+ if (tableAccount == nil) {
|
|
|
+ completion(account, nil, NSLocalizedString(@"_error_user_not_available_", nil), k_CCErrorUserNotAvailble);
|
|
|
+ } else if ([CCUtility getPassword:account].length == 0) {
|
|
|
+ completion(account, nil, NSLocalizedString(@"_bad_username_password_", nil), kOCErrorServerUnauthorized);
|
|
|
+ } else if ([CCUtility getCertificateError:account]) {
|
|
|
+ completion(account, nil, NSLocalizedString(@"_ssl_certificate_untrusted_", nil), NSURLErrorServerCertificateUntrusted);
|
|
|
+ }
|
|
|
+
|
|
|
+ NSString *options = [NSString stringWithFormat:@"\"files_within_dir\": \"\", \"files_local\": \"\", \"files_extension\": \"\""];
|
|
|
+
|
|
|
+ OCCommunication *communication = [OCNetworking sharedManager].sharedOCCommunication;
|
|
|
+
|
|
|
+ [communication setCredentialsWithUser:tableAccount.user andUserID:tableAccount.userID andPassword:[CCUtility getPassword:account]];
|
|
|
+ [communication setUserAgent:[CCUtility getUserAgent]];
|
|
|
+ [communication fullTextSearch:[tableAccount.url stringByAppendingString:@"/"] providers:@"files" text:text page:page options:options size:20 onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer) {
|
|
|
+
|
|
|
+ completion(account, items, nil, 0);
|
|
|
+
|
|
|
+ } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
+
|
|
|
+ NSString *message;
|
|
|
+ NSInteger errorCode = response.statusCode;
|
|
|
+
|
|
|
+ if (errorCode == 0 || (errorCode >= 200 && errorCode < 300))
|
|
|
+ errorCode = error.code;
|
|
|
+
|
|
|
+ // Server Unauthorized
|
|
|
+ if (errorCode == kOCErrorServerUnauthorized) {
|
|
|
+ [CCUtility setPassword:account password:nil];
|
|
|
+ } else if (errorCode == NSURLErrorServerCertificateUntrusted) {
|
|
|
+ [CCUtility setCertificateError:account error:YES];
|
|
|
+ }
|
|
|
+
|
|
|
+ // Error
|
|
|
+ if (errorCode == 503)
|
|
|
+ message = NSLocalizedString(@"_server_error_retry_", nil);
|
|
|
+ else
|
|
|
+ message = [error.userInfo valueForKey:@"NSLocalizedDescription"];
|
|
|
+
|
|
|
+ completion(account, nil, message, errorCode);
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
#pragma --------------------------------------------------------------------------------------------
|
|
|
#pragma mark ===== Trash =====
|
|
|
#pragma --------------------------------------------------------------------------------------------
|