Browse Source

Move automaticCreateFolder in OCNetworking

Marino Faggiana 8 years ago
parent
commit
f964231174
2 changed files with 8 additions and 47 deletions
  1. 4 2
      iOSClient/Main/CCMain.m
  2. 4 45
      iOSClient/PhotosCameraUpload/CCPhotosCameraUpload.m

+ 4 - 2
iOSClient/Main/CCMain.m

@@ -1603,10 +1603,12 @@
     NSString *folderPhotos = [CCCoreData getCameraUploadFolderNamePathActiveAccount:app.activeAccount activeUrl:app.activeUrl];
     NSString *directoryID = [CCCoreData getDirectoryIDFromServerUrl:serverUrl activeAccount:app.activeAccount];
     
+    OCnetworking *ocNetworking = [[OCnetworking alloc] initWithDelegate:nil metadataNet:nil withUser:app.activeUser withPassword:app.activePassword withUrl:app.activeUrl isCryptoCloudMode:NO];
+
     // Create if request the folder for Photos
     if ((useSubFolder || [serverUrl isEqualToString:folderPhotos]) && [_serverUrl isEqualToString:serverUrl] == NO){
         
-        if(![app.activePhotosCameraUpload automaticCreateFolder:folderPhotos]) {
+        if(![ocNetworking automaticCreateFolderSync:folderPhotos]) {
             
             [app messageNotification:@"_error_" description:@"_error_createsubfolders_upload_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeInfo];
             
@@ -1619,7 +1621,7 @@
         
         for (NSString *dateSubFolder in [CCUtility createNameSubFolder:assets]) {
                 
-            if(![app.activePhotosCameraUpload automaticCreateFolder:[NSString stringWithFormat:@"%@/%@", folderPhotos, dateSubFolder]]) {
+            if(![ocNetworking automaticCreateFolderSync:[NSString stringWithFormat:@"%@/%@", folderPhotos, dateSubFolder]]) {
                 
                 [app messageNotification:@"_error_" description:@"_error_createsubfolders_upload_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeInfo];
                     

+ 4 - 45
iOSClient/PhotosCameraUpload/CCPhotosCameraUpload.m

@@ -1144,6 +1144,8 @@
     NSString *folderPhotos = [CCCoreData getCameraUploadFolderNamePathActiveAccount:app.activeAccount activeUrl:app.activeUrl];
     BOOL createSubfolders = [CCCoreData getCameraUploadCreateSubfolderActiveAccount:app.activeAccount];
     
+    OCnetworking *ocNetworking = [[OCnetworking alloc] initWithDelegate:nil metadataNet:nil withUser:app.activeUser withPassword:app.activePassword withUrl:app.activeUrl isCryptoCloudMode:NO];
+    
     // Conversion from ALAsset -to-> PHAsset
     for (ALAsset *asset in newItemsToUpload) {
         
@@ -1154,7 +1156,7 @@
     }
     
     // verify/create folder Camera Upload, if error exit
-    if(![self automaticCreateFolder:folderPhotos]) {
+    if(![ocNetworking automaticCreateFolderSync:folderPhotos]) {
         
         NSString *description = NSLocalizedStringFromTable(@"_not_possible_create_folder_", @"Error", nil);
         
@@ -1176,7 +1178,7 @@
         
         for (NSString *dateSubFolder in [CCUtility createNameSubFolder:newItemsPHAssetToUpload]) {
             
-            if (![self automaticCreateFolder:[NSString stringWithFormat:@"%@/%@", folderPhotos, dateSubFolder]]) {
+            if (![ocNetworking automaticCreateFolderSync:[NSString stringWithFormat:@"%@/%@", folderPhotos, dateSubFolder]]) {
                 
                 [self endLoadingAssets];
                 
@@ -1263,49 +1265,6 @@
     [app updateApplicationIconBadgeNumber];
 }
 
-/*
-- (BOOL)automaticCreateFolder:(NSString *)folderPathName
-{
-    OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
-    __block BOOL noError = YES;
-        
-    dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
-        
-    [communication setCredentialsWithUser:app.activeUser andPassword:app.activePassword];
-    [communication setUserAgent:[CCUtility getUserAgent]];
-        
-    [communication readFile:folderPathName onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer) {
-            
-        dispatch_semaphore_signal(semaphore);
-            
-    } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
-        
-        [communication createFolder:folderPathName onCommunication:communication withForbiddenCharactersSupported:app.hasServerForbiddenCharactersSupport successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
-            
-            [CCCoreData clearDateReadAccount:app.activeAccount serverUrl:[CCUtility deletingLastPathComponentFromServerUrl:folderPathName] directoryID:nil];
-                        
-            dispatch_semaphore_signal(semaphore);
-            
-        } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
-            
-            noError = NO;
-            
-            dispatch_semaphore_signal(semaphore);
-            
-        } errorBeforeRequest:^(NSError *error) {
-            
-            noError = NO;
-            dispatch_semaphore_signal(semaphore);
-        }];
-    }];
-        
-    while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_NOW))
-        [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:k_timeout_webdav]];
-    
-    return noError;
-}
-*/
-
 -(void)endLoadingAssets
 {
     [_hud hideHud];