Ver código fonte

remove old code

marinofaggiana 4 anos atrás
pai
commit
aadda59df8

+ 1 - 1
iOSClient/Networking/OCNetworking.h

@@ -42,7 +42,7 @@
 
 #pragma mark ===== Download / Upload =====
 
-- (NSURLSessionTask *)downloadWithAccount:(NSString *)account fileNameServerUrl:(NSString *)fileNameServerUrl fileNameLocalPath:(NSString *)fileNameLocalPath encode:(BOOL)encode communication:(OCCommunication *)communication completion:(void (^)(NSString *account, int64_t length, NSString *etag, NSDate *date, NSString *message, NSInteger errorCode))completion;
+
 - (NSURLSessionTask *)downloadWithAccount:(NSString *)account url:(NSString *)url fileNameLocalPath:(NSString *)fileNameLocalPath encode:(BOOL)encode completion:(void (^)(NSString *account, NSString *message, NSInteger errorCode))completion;
 
 

+ 0 - 77
iOSClient/Networking/OCNetworking.m

@@ -186,83 +186,6 @@
 #pragma mark ===== download / upload =====
 #pragma --------------------------------------------------------------------------------------------
 
-- (NSURLSessionTask *)downloadWithAccount:(NSString *)account fileNameServerUrl:(NSString *)fileNameServerUrl fileNameLocalPath:(NSString *)fileNameLocalPath encode:(BOOL)encode communication:(OCCommunication *)communication completion:(void (^)(NSString *account, int64_t length, NSString *etag, NSDate *date, NSString *message, NSInteger errorCode))completion
-{
-    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", account]];
-    if (tableAccount == nil) {
-        completion(account, 0, nil, nil, NSLocalizedString(@"_error_user_not_available_", nil), k_CCErrorUserNotAvailble);
-    } else if ([CCUtility getPassword:account].length == 0) {
-        completion(account, 0, nil, nil, NSLocalizedString(@"_bad_username_password_", nil), kOCErrorServerUnauthorized);
-    } else if ([CCUtility getCertificateError:account]) {
-        completion(account, 0, nil, nil, NSLocalizedString(@"_ssl_certificate_untrusted_", nil), NSURLErrorServerCertificateUntrusted);
-    }
-    
-    [communication setCredentialsWithUser:tableAccount.user andUserID:tableAccount.userID andPassword:[CCUtility getPassword:account]];
-    [communication setUserAgent:[CCUtility getUserAgent]];
-    
-    NSURLSessionTask *sessionTask = [communication downloadFileSession:fileNameServerUrl toDestiny:fileNameLocalPath defaultPriority:YES encode:encode onCommunication:communication progress:^(NSProgress *progress) {
-        //float percent = roundf (progress.fractionCompleted * 100);
-    } successRequest:^(NSURLResponse *response, NSURL *filePath) {
-
-        int64_t totalUnitCount = 0;
-        NSDate *date = [NSDate date];
-        NSDateFormatter *dateFormatter = [NSDateFormatter new];
-        NSLocale *enUSPOSIXLocale = [NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"];
-        [dateFormatter setLocale:enUSPOSIXLocale];
-        [dateFormatter setDateFormat:@"EEE, dd MMM y HH:mm:ss zzz"];
-        NSError *error;
-        
-        NSDictionary *fields = [(NSHTTPURLResponse*)response allHeaderFields];
-
-        NSString *contentLength = [fields objectForKey:@"Content-Length"];
-        if(contentLength) {
-            totalUnitCount = (int64_t) [contentLength longLongValue];
-        }
-        NSString *dateString = [fields objectForKey:@"Date"];
-        if (dateString) {
-            if (![dateFormatter getObjectValue:&date forString:dateString range:nil error:&error]) {
-                date = [NSDate date];
-            }
-        } else {
-            date = [NSDate date];
-        }
-        
-        NSString *etag = [CCUtility removeForbiddenCharactersFileSystem:[fields objectForKey:@"OC-ETag"]];
-        if (etag == nil) {
-            completion(account, 0, nil, nil, NSLocalizedString(@"Internal error", nil), k_CCErrorInternalError);
-        } else {
-            completion(account, totalUnitCount, etag, date, nil, 0);
-        }
-        
-    } failureRequest:^(NSURLResponse *response, NSError *error) {
-        
-        NSString *message;
-        NSInteger errorCode = ((NSHTTPURLResponse*)response).statusCode;
-        
-        if (errorCode == 0 || (errorCode >= 200 && errorCode < 300))
-            errorCode = error.code;
-        
-        // Server Unauthorized
-        if (errorCode == kOCErrorServerUnauthorized || errorCode == kOCErrorServerForbidden) {
-#ifndef EXTENSION
-                [[NCNetworkingCheckRemoteUser shared] checkRemoteUserWithAccount:account];
-#endif
-        } 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, 0, nil, nil, message, errorCode);
-    }];
-    
-    return sessionTask;
-}
-
 - (NSURLSessionTask *)downloadWithAccount:(NSString *)account url:(NSString *)url fileNameLocalPath:(NSString *)fileNameLocalPath encode:(BOOL)encode completion:(void (^)(NSString *account, NSString *message, NSInteger errorCode))completion
 {
     tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", account]];