|
@@ -189,74 +189,6 @@
|
|
}];
|
|
}];
|
|
}
|
|
}
|
|
|
|
|
|
-- (void)deleteEndToEndPublicKeyWithAccount:(NSString *)account completion:(void (^)(NSString *account, NSString *message, NSInteger errorCode))completion
|
|
|
|
-{
|
|
|
|
- tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", account]];
|
|
|
|
- if (tableAccount == nil) {
|
|
|
|
- completion(account, NSLocalizedString(@"_error_user_not_available_", nil), k_CCErrorUserNotAvailble);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- OCCommunication *communication = [OCNetworking sharedManager].sharedOCCommunication;
|
|
|
|
-
|
|
|
|
- [communication setCredentialsWithUser:tableAccount.user andUserID:tableAccount.userID andPassword:[CCUtility getPassword:account]];
|
|
|
|
- [communication setUserAgent:[CCUtility getUserAgent]];
|
|
|
|
-
|
|
|
|
- [communication deleteEndToEndPublicKey:[tableAccount.url stringByAppendingString:@"/"] onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
|
|
|
|
-
|
|
|
|
- completion(account, 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;
|
|
|
|
-
|
|
|
|
- // Error
|
|
|
|
- if (errorCode == 503) {
|
|
|
|
- message = NSLocalizedString(@"_server_error_retry_", nil);
|
|
|
|
- } else {
|
|
|
|
- message = [error.userInfo valueForKey:@"NSLocalizedDescription"];
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- completion(account, message, errorCode);
|
|
|
|
- }];
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-- (void)deleteEndToEndPrivateKeyWithAccount:(NSString *)account completion:(void (^)(NSString *account, NSString *message, NSInteger errorCode))completion
|
|
|
|
-{
|
|
|
|
- tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", account]];
|
|
|
|
- if (tableAccount == nil) {
|
|
|
|
- completion(account, NSLocalizedString(@"_error_user_not_available_", nil), k_CCErrorUserNotAvailble);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- OCCommunication *communication = [OCNetworking sharedManager].sharedOCCommunication;
|
|
|
|
-
|
|
|
|
- [communication setCredentialsWithUser:tableAccount.user andUserID:tableAccount.userID andPassword:[CCUtility getPassword:account]];
|
|
|
|
- [communication setUserAgent:[CCUtility getUserAgent]];
|
|
|
|
-
|
|
|
|
- [communication deleteEndToEndPrivateKey:[tableAccount.url stringByAppendingString:@"/"] onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
|
|
|
|
-
|
|
|
|
- completion(account, 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;
|
|
|
|
-
|
|
|
|
- // Error
|
|
|
|
- if (errorCode == 503) {
|
|
|
|
- message = NSLocalizedString(@"_server_error_retry_", nil);
|
|
|
|
- } else {
|
|
|
|
- message = [error.userInfo valueForKey:@"NSLocalizedDescription"];
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- completion(account, message, errorCode);
|
|
|
|
- }];
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
- (void)getEndToEndServerPublicKeyWithAccount:(NSString *)account completion:(void (^)(NSString *account, NSString *publicKey, NSString *message, NSInteger errorCode))completion
|
|
- (void)getEndToEndServerPublicKeyWithAccount:(NSString *)account completion:(void (^)(NSString *account, NSString *publicKey, NSString *message, NSInteger errorCode))completion
|
|
{
|
|
{
|
|
tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", account]];
|
|
tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", account]];
|