Pārlūkot izejas kodu

Change Parser !!! [Finally]

marinofaggiana 6 gadi atpakaļ
vecāks
revīzija
142504bc5f

+ 10 - 20
Nextcloud.xcodeproj/project.pbxproj

@@ -39,10 +39,6 @@
 		F70022DB1EC4C9100080073F /* OCHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F70022841EC4C9100080073F /* OCHTTPRequestOperation.m */; };
 		F70022DD1EC4C9100080073F /* OCWebDAVClient.m in Sources */ = {isa = PBXBuildFile; fileRef = F70022861EC4C9100080073F /* OCWebDAVClient.m */; };
 		F70022DE1EC4C9100080073F /* OCWebDAVClient.m in Sources */ = {isa = PBXBuildFile; fileRef = F70022861EC4C9100080073F /* OCWebDAVClient.m */; };
-		F70022E01EC4C9100080073F /* OCXMLListParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F70022891EC4C9100080073F /* OCXMLListParser.m */; };
-		F70022E11EC4C9100080073F /* OCXMLListParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F70022891EC4C9100080073F /* OCXMLListParser.m */; };
-		F70022E31EC4C9100080073F /* OCXMLParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F700228B1EC4C9100080073F /* OCXMLParser.m */; };
-		F70022E41EC4C9100080073F /* OCXMLParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F700228B1EC4C9100080073F /* OCXMLParser.m */; };
 		F70022E61EC4C9100080073F /* OCXMLServerErrorsParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F700228D1EC4C9100080073F /* OCXMLServerErrorsParser.m */; };
 		F70022E71EC4C9100080073F /* OCXMLServerErrorsParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F700228D1EC4C9100080073F /* OCXMLServerErrorsParser.m */; };
 		F70022E91EC4C9100080073F /* OCXMLShareByLinkParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F700228F1EC4C9100080073F /* OCXMLShareByLinkParser.m */; };
@@ -194,8 +190,6 @@
 		F7434B4C20E2408300417916 /* NSDate+RFC1123.m in Sources */ = {isa = PBXBuildFile; fileRef = F70022821EC4C9100080073F /* NSDate+RFC1123.m */; };
 		F7434B4D20E2408600417916 /* OCHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F70022841EC4C9100080073F /* OCHTTPRequestOperation.m */; };
 		F7434B4E20E2408A00417916 /* OCWebDAVClient.m in Sources */ = {isa = PBXBuildFile; fileRef = F70022861EC4C9100080073F /* OCWebDAVClient.m */; };
-		F7434B4F20E2408E00417916 /* OCXMLListParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F70022891EC4C9100080073F /* OCXMLListParser.m */; };
-		F7434B5020E2409100417916 /* OCXMLParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F700228B1EC4C9100080073F /* OCXMLParser.m */; };
 		F7434B5120E2409500417916 /* OCXMLServerErrorsParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F700228D1EC4C9100080073F /* OCXMLServerErrorsParser.m */; };
 		F7434B5220E2409900417916 /* OCXMLShareByLinkParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F700228F1EC4C9100080073F /* OCXMLShareByLinkParser.m */; };
 		F7434B5320E2409E00417916 /* OCXMLSharedParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F70022911EC4C9100080073F /* OCXMLSharedParser.m */; };
@@ -488,6 +482,9 @@
 		F7CA1ED720E7E3FE002CC65E /* PKDownloadButton.m in Sources */ = {isa = PBXBuildFile; fileRef = F7CA1EC820E7E3FE002CC65E /* PKDownloadButton.m */; };
 		F7CA1ED820E7E3FE002CC65E /* PKBorderedButton.m in Sources */ = {isa = PBXBuildFile; fileRef = F7CA1ECA20E7E3FE002CC65E /* PKBorderedButton.m */; };
 		F7CA1ED920E7E3FE002CC65E /* NSLayoutConstraint+PKDownloadButton.m in Sources */ = {isa = PBXBuildFile; fileRef = F7CA1ECE20E7E3FE002CC65E /* NSLayoutConstraint+PKDownloadButton.m */; };
+		F7D2D127230804E000FD3ED7 /* NCXMLListParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F7D2D126230804E000FD3ED7 /* NCXMLListParser.m */; };
+		F7D2D128230804E000FD3ED7 /* NCXMLListParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F7D2D126230804E000FD3ED7 /* NCXMLListParser.m */; };
+		F7D2D129230804E000FD3ED7 /* NCXMLListParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F7D2D126230804E000FD3ED7 /* NCXMLListParser.m */; };
 		F7D423331F0596AC009C9782 /* AppIcon-076.png in Resources */ = {isa = PBXBuildFile; fileRef = F7D423161F0596AC009C9782 /* AppIcon-076.png */; };
 		F7D423341F0596AC009C9782 /* AppIcon-120.png in Resources */ = {isa = PBXBuildFile; fileRef = F7D423171F0596AC009C9782 /* AppIcon-120.png */; };
 		F7D423351F0596AC009C9782 /* AppIcon-152.png in Resources */ = {isa = PBXBuildFile; fileRef = F7D423181F0596AC009C9782 /* AppIcon-152.png */; };
@@ -700,10 +697,6 @@
 		F70022841EC4C9100080073F /* OCHTTPRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OCHTTPRequestOperation.m; sourceTree = "<group>"; };
 		F70022851EC4C9100080073F /* OCWebDAVClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCWebDAVClient.h; sourceTree = "<group>"; };
 		F70022861EC4C9100080073F /* OCWebDAVClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OCWebDAVClient.m; sourceTree = "<group>"; };
-		F70022881EC4C9100080073F /* OCXMLListParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCXMLListParser.h; sourceTree = "<group>"; };
-		F70022891EC4C9100080073F /* OCXMLListParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OCXMLListParser.m; sourceTree = "<group>"; };
-		F700228A1EC4C9100080073F /* OCXMLParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCXMLParser.h; sourceTree = "<group>"; };
-		F700228B1EC4C9100080073F /* OCXMLParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OCXMLParser.m; sourceTree = "<group>"; };
 		F700228C1EC4C9100080073F /* OCXMLServerErrorsParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCXMLServerErrorsParser.h; sourceTree = "<group>"; };
 		F700228D1EC4C9100080073F /* OCXMLServerErrorsParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OCXMLServerErrorsParser.m; sourceTree = "<group>"; };
 		F700228E1EC4C9100080073F /* OCXMLShareByLinkParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCXMLShareByLinkParser.h; sourceTree = "<group>"; };
@@ -1317,6 +1310,8 @@
 		F7D0E65E1BC5042E008D989A /* CCDetail.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = CCDetail.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
 		F7D0E65F1BC5042E008D989A /* CCDetail.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = CCDetail.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
 		F7D154271E2392A300202FD9 /* Nextcloud-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Nextcloud-Bridging-Header.h"; sourceTree = "<group>"; };
+		F7D2D125230804DF00FD3ED7 /* NCXMLListParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NCXMLListParser.h; sourceTree = "<group>"; };
+		F7D2D126230804E000FD3ED7 /* NCXMLListParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NCXMLListParser.m; sourceTree = "<group>"; };
 		F7D423161F0596AC009C9782 /* AppIcon-076.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "AppIcon-076.png"; sourceTree = "<group>"; };
 		F7D423171F0596AC009C9782 /* AppIcon-120.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "AppIcon-120.png"; sourceTree = "<group>"; };
 		F7D423181F0596AC009C9782 /* AppIcon-152.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "AppIcon-152.png"; sourceTree = "<group>"; };
@@ -1644,10 +1639,8 @@
 			children = (
 				F7B6ACD522FC2BD4008AB646 /* NCXMLCommentsParser.h */,
 				F7B6ACD422FC2BD3008AB646 /* NCXMLCommentsParser.m */,
-				F70022881EC4C9100080073F /* OCXMLListParser.h */,
-				F70022891EC4C9100080073F /* OCXMLListParser.m */,
-				F700228A1EC4C9100080073F /* OCXMLParser.h */,
-				F700228B1EC4C9100080073F /* OCXMLParser.m */,
+				F7D2D125230804DF00FD3ED7 /* NCXMLListParser.h */,
+				F7D2D126230804E000FD3ED7 /* NCXMLListParser.m */,
 				F700228C1EC4C9100080073F /* OCXMLServerErrorsParser.h */,
 				F700228D1EC4C9100080073F /* OCXMLServerErrorsParser.m */,
 				F700228E1EC4C9100080073F /* OCXMLShareByLinkParser.h */,
@@ -3541,10 +3534,9 @@
 				F70022D51EC4C9100080073F /* NSDate+ISO8601.m in Sources */,
 				F70022FC1EC4C9100080073F /* NSString+Encode.m in Sources */,
 				F7F878AF1FB9E3B900599E4F /* NCEndToEndMetadata.swift in Sources */,
-				F70022E41EC4C9100080073F /* OCXMLParser.m in Sources */,
 				F71459C91D12E3B700CAFEEC /* OCNetworking.m in Sources */,
 				F71459CD1D12E3B700CAFEEC /* AFViewShaker.m in Sources */,
-				F70022E11EC4C9100080073F /* OCXMLListParser.m in Sources */,
+				F7D2D128230804E000FD3ED7 /* NCXMLListParser.m in Sources */,
 				F74E432720B5547700C2E54C /* NCNetworkingEndToEnd.m in Sources */,
 				F73CC0791E813DFF006E3047 /* BKShiftingView.m in Sources */,
 				F71459D21D12E3B700CAFEEC /* CCUtility.m in Sources */,
@@ -3605,7 +3597,6 @@
 				F7434B5320E2409E00417916 /* OCXMLSharedParser.m in Sources */,
 				F7434B4320E2405900417916 /* OCShareUser.m in Sources */,
 				F771E3F920E239B500AFB62D /* FileProviderExtension+Network.swift in Sources */,
-				F7434B4F20E2408E00417916 /* OCXMLListParser.m in Sources */,
 				F7434B6120E2445C00417916 /* CCCertificate.m in Sources */,
 				F7434B5A20E241BB00417916 /* NCNetworkingEndToEnd.m in Sources */,
 				F76673EE22C901F6007ED366 /* FileProviderDomain.swift in Sources */,
@@ -3615,13 +3606,13 @@
 				F7434B5C20E241D500417916 /* NCEndToEndEncryption.m in Sources */,
 				F7434B3E20E2404700417916 /* OCFileDto.m in Sources */,
 				F7434B3D20E2404300417916 /* OCExternalSites.m in Sources */,
+				F7D2D129230804E000FD3ED7 /* NCXMLListParser.m in Sources */,
 				F7434B4420E2405C00417916 /* OCUserProfile.m in Sources */,
 				F7434B5E20E241EC00417916 /* CCGraphics.m in Sources */,
 				F771E3D320E2392D00AFB62D /* FileProviderExtension.swift in Sources */,
 				F7434B5B20E241D100417916 /* NCEndToEndMetadata.swift in Sources */,
 				F7B6ACDD22FC2D15008AB646 /* NCComments.m in Sources */,
 				F7434B5D20E241E800417916 /* CCUtility.m in Sources */,
-				F7434B5020E2409100417916 /* OCXMLParser.m in Sources */,
 				F7434B5220E2409900417916 /* OCXMLShareByLinkParser.m in Sources */,
 				F771E3D520E2392D00AFB62D /* FileProviderItem.swift in Sources */,
 				F7434B3620E23FE000417916 /* NCManageDatabase.swift in Sources */,
@@ -3752,7 +3743,6 @@
 				F76673ED22C901F6007ED366 /* FileProviderDomain.swift in Sources */,
 				F7D423891F0596C6009C9782 /* ReaderViewController.m in Sources */,
 				F70022E91EC4C9100080073F /* OCXMLShareByLinkParser.m in Sources */,
-				F70022E31EC4C9100080073F /* OCXMLParser.m in Sources */,
 				F77B0E311D118A16002130FE /* CCExifGeo.m in Sources */,
 				F73B4F0E1F470D9100BBEE4B /* nsMBCSGroupProber.cpp in Sources */,
 				F7D423831F0596C6009C9782 /* ReaderThumbFetch.m in Sources */,
@@ -3847,6 +3837,7 @@
 				F70022C21EC4C9100080073F /* OCNotifications.m in Sources */,
 				F70022BF1EC4C9100080073F /* OCFileDto.m in Sources */,
 				F7CA1ED020E7E3FE002CC65E /* UIImage+PKDownloadButton.m in Sources */,
+				F7D2D127230804E000FD3ED7 /* NCXMLListParser.m in Sources */,
 				F7DFB7F4219C5CA800680748 /* NCCreateFormUploadScanDocument.swift in Sources */,
 				F73B4F011F470D9100BBEE4B /* LangThaiModel.cpp in Sources */,
 				F70022DD1EC4C9100080073F /* OCWebDAVClient.m in Sources */,
@@ -3856,7 +3847,6 @@
 				F762CB031EACB66200B38484 /* XLFormStepCounterCell.m in Sources */,
 				F760F79321F21F61006B1A73 /* CropView.swift in Sources */,
 				F762CAF71EACB66200B38484 /* XLFormBaseCell.m in Sources */,
-				F70022E01EC4C9100080073F /* OCXMLListParser.m in Sources */,
 				F760F78A21F21F61006B1A73 /* UIImage+Size.swift in Sources */,
 				F70022B31EC4C9100080073F /* OCActivity.m in Sources */,
 				F734A8BF21B59137009DE2E8 /* WKCookieWebView.swift in Sources */,

+ 0 - 1
iOSClient/Library/OCCommunicationLib/OCCommunication.h

@@ -750,7 +750,6 @@ typedef enum {
  */
 - (void) searchUsersAndGroupsWith:(NSString *)searchString forPage:(NSInteger)page with:(NSInteger)resultsPerPage ofServer:(NSString*)serverPath onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSArray *itemList, NSString *redirectedServer)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest;
 
-- (void) getSharePermissionsFile:(NSString*)fileName onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSString *permissions, NSString *redirectedServer)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest;
 ///-----------------------------------
 /// @name Get the server capabilities
 ///-----------------------------------

+ 154 - 191
iOSClient/Library/OCCommunicationLib/OCCommunication.m

@@ -36,10 +36,8 @@
 #import "OCCommunication.h"
 #import "OCHTTPRequestOperation.h"
 #import "UtilsFramework.h"
-#import "OCXMLParser.h"
 #import "OCXMLSharedParser.h"
 #import "OCXMLServerErrorsParser.h"
-#import "OCXMLListParser.h"
 #import "NSString+Encode.h"
 #import "OCFrameworkConstants.h"
 #import "OCWebDAVClient.h"
@@ -56,6 +54,7 @@
 #import "NCRichDocumentTemplate.h"
 #import "HCFeatures.h"
 #import "NCXMLCommentsParser.h"
+#import "NCXMLListParser.h"
 
 @interface OCCommunication ()
 
@@ -448,12 +447,13 @@
 //            NSString* newStr = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
 //            NSLog(@"newStrReadFolder: %@", newStr);
             
-            OCXMLParser *parser = [[OCXMLParser alloc]init];
-            [parser initParserWithData:responseData];
-            NSMutableArray *directoryList = [parser.directoryList mutableCopy];
             
+            NCXMLListParser *parser = [NCXMLListParser new];
+            [parser initParserWithData:responseData controlFirstFileOfList:true];
+            NSMutableArray *list = [parser.list mutableCopy];
+
             //Return success
-            successRequest(response, directoryList, request.redirectedServer, token);
+            successRequest(response, list, request.redirectedServer, token);
         }
         
     } failure:^(NSHTTPURLResponse *response, id responseData, NSError *error, NSString *token) {
@@ -462,130 +462,6 @@
     }];
 }
 
-///-----------------------------------
-/// @name Download File Session
-///-----------------------------------
-
-
-
-- (NSURLSessionDownloadTask *) downloadFileSession:(NSString *)remotePath toDestiny:(NSString *)localPath defaultPriority:(BOOL)defaultPriority encode:(BOOL)encode onCommunication:(OCCommunication *)sharedOCCommunication progress:(void(^)(NSProgress *progress))downloadProgress successRequest:(void(^)(NSURLResponse *response, NSURL *filePath)) successRequest failureRequest:(void(^)(NSURLResponse *response, NSError *error)) failureRequest {
-    
-    OCWebDAVClient *request = [OCWebDAVClient new];
-    request = [self getRequestWithCredentials:request];
-    if (encode) remotePath = [remotePath encodeString:NSUTF8StringEncoding];
-    
-    NSURLSessionDownloadTask *downloadTask = [request downloadWithSessionPath:remotePath toPath:localPath defaultPriority:defaultPriority onCommunication:sharedOCCommunication progress:^(NSProgress *progress) {
-        downloadProgress(progress);
-    } success:^(NSURLResponse *response, NSURL *filePath) {
-        
-        [UtilsFramework addCookiesToStorageFromResponse:(NSURLResponse *) response andPath:[NSURL URLWithString:remotePath]];
-        successRequest(response,filePath);
-        
-    } failure:^(NSURLResponse *response, NSError *error) {
-        [UtilsFramework addCookiesToStorageFromResponse:(NSURLResponse *) response andPath:[NSURL URLWithString:remotePath]];
-        failureRequest(response,error);
-    }];
-    
-    return downloadTask;
-}
-
-
-///-----------------------------------
-/// @name Set Download Task Complete Block
-///-----------------------------------
-
-
-- (void)setDownloadTaskComleteBlock: (NSURL * (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block{
-    
-    [self.downloadSessionManager setDownloadTaskDidFinishDownloadingBlock:block];
-
-    
-}
-
-
-///-----------------------------------
-/// @name Set Download Task Did Get Body Data Block
-///-----------------------------------
-
-
-- (void) setDownloadTaskDidGetBodyDataBlock: (void(^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite)) block{
-    
-    [self.downloadSessionManager setDownloadTaskDidWriteDataBlock:^(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite) {
-        block(session,downloadTask,bytesWritten,totalBytesWritten,totalBytesExpectedToWrite);
-    }];
-    
-}
-
-///-----------------------------------
-/// @name Upload File Session
-///-----------------------------------
-
-- (NSURLSessionUploadTask *) uploadFileSession:(NSString *) localPath toDestiny:(NSString *) remotePath onCommunication:(OCCommunication *)sharedOCCommunication progress:(void(^)(NSProgress *progress))uploadProgress successRequest:(void(^)(NSURLResponse *response, NSString *redirectedServer)) successRequest failureRequest:(void(^)(NSURLResponse *response, NSString *redirectedServer, NSError *error)) failureRequest failureBeforeRequest:(void(^)(NSError *error)) failureBeforeRequest {
-    
-    OCWebDAVClient *request = [OCWebDAVClient new];
-    request = [self getRequestWithCredentials:request];
-    
-    
-    remotePath = [remotePath encodeString:NSUTF8StringEncoding];
-    
-    NSURLSessionUploadTask *uploadTask = [request putWithSessionLocalPath:localPath atRemotePath:remotePath onCommunication:sharedOCCommunication progress:^(NSProgress *progress) {
-            uploadProgress(progress);
-        } success:^(NSURLResponse *response, id responseObjec){
-            [UtilsFramework addCookiesToStorageFromResponse:(NSURLResponse *) response andPath:[NSURL URLWithString:remotePath]];
-            //TODO: The second parameter is the redirected server
-            successRequest(response, @"");
-        } failure:^(NSURLResponse *response, id responseObject, NSError *error) {
-            [UtilsFramework addCookiesToStorageFromResponse:(NSURLResponse *) response andPath:[NSURL URLWithString:remotePath]];
-            //TODO: The second parameter is the redirected server
-
-            NSData *responseData = (NSData*) responseObject;
-            
-            OCXMLServerErrorsParser *serverErrorParser = [OCXMLServerErrorsParser new];
-            
-            [serverErrorParser startToParseWithData:responseData withCompleteBlock:^(NSError *err) {
-                
-                if (err) {
-                    failureRequest(response, @"", err);
-                }else{
-                    failureRequest(response, @"", error);
-                }
-                
-            }];
-            
-        } failureBeforeRequest:^(NSError *error) {
-            failureBeforeRequest(error);
-        }];
-    
-    return uploadTask;
-}
-
-///-----------------------------------
-/// @name Set Task Did Complete Block
-///-----------------------------------
-
-- (void) setTaskDidCompleteBlock: (void(^)(NSURLSession *session, NSURLSessionTask *task, NSError *error)) block{
-    
-    [self.uploadSessionManager setTaskDidCompleteBlock:^(NSURLSession *session, NSURLSessionTask *task, NSError *error) {
-
-        block(session, task, error);
-    }];
-    
-}
-
-
-///-----------------------------------
-/// @name Set Task Did Send Body Data Block
-///-----------------------------------
-
-
-- (void) setTaskDidSendBodyDataBlock: (void(^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend)) block{
-    
-   [self.uploadSessionManager setTaskDidSendBodyDataBlock:^(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend) {
-       block(session, task, bytesSent, totalBytesSent, totalBytesExpectedToSend);
-   }];
-}
-
-
 ///-----------------------------------
 /// @name Read File
 ///-----------------------------------
@@ -605,15 +481,15 @@
         if (successRequest) {
             NSData *responseData = (NSData*) responseObject;
             
-//            NSString* newStr = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
-//            NSLog(@"newStrReadFile: %@", newStr);
-
-            OCXMLParser *parser = [[OCXMLParser alloc]init];
-            [parser initParserWithData:responseData];
-            NSMutableArray *directoryList = [parser.directoryList mutableCopy];
+            //            NSString* newStr = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
+            //            NSLog(@"newStrReadFile: %@", newStr);
+            
+            NCXMLListParser *parser = [NCXMLListParser new];
+            [parser initParserWithData:responseData controlFirstFileOfList:true];
+            NSMutableArray *list = [parser.list mutableCopy];
             
             //Return success
-            successRequest(response, directoryList, request.redirectedServer);
+            successRequest(response, list, request.redirectedServer);
         }
         
     } failure:^(NSHTTPURLResponse *response, NSData *responseData, NSError *error) {
@@ -642,16 +518,16 @@
         if (successRequest) {
             
             dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
-
+                
                 NSData *responseData = (NSData*) responseObject;
-            
-                OCXMLListParser *parser = [OCXMLListParser new];
-                [parser initParserWithData:responseData];
-                NSMutableArray *searchList = [parser.searchList mutableCopy];
-            
+                
+                NCXMLListParser *parser = [NCXMLListParser new];
+                [parser initParserWithData:responseData controlFirstFileOfList:false];
+                NSMutableArray *list = [parser.list mutableCopy];
+                
                 //Return success
                 dispatch_async(dispatch_get_main_queue(), ^{
-                    successRequest(response, searchList, request.redirectedServer, token);
+                    successRequest(response, list, request.redirectedServer, token);
                 });
             });
         }
@@ -678,11 +554,11 @@
             
             NSData *responseData = (NSData*) responseObject;
             
-            OCXMLListParser *parser = [OCXMLListParser new];
-            [parser initParserWithData:responseData];
-            NSMutableArray *searchList = [parser.searchList mutableCopy];
+            NCXMLListParser *parser = [NCXMLListParser new];
+            [parser initParserWithData:responseData controlFirstFileOfList:false];
+            NSMutableArray *list = [parser.list mutableCopy];
             
-            successRequest(response, searchList, request.redirectedServer, token);
+            successRequest(response, list, request.redirectedServer, token);
         }
     } failure:^(NSHTTPURLResponse *response, id responseData, NSError *error, NSString *token) {
         failureRequest(response, error, token, request.redirectedServer);
@@ -738,12 +614,12 @@
             
             NSData *responseData = (NSData*) responseObject;
             
-            OCXMLListParser *parser = [OCXMLListParser new];
-            [parser initParserWithData:responseData];
-            NSMutableArray *searchList = [parser.searchList mutableCopy];
+            NCXMLListParser *parser = [NCXMLListParser new];
+            [parser initParserWithData:responseData controlFirstFileOfList:false];
+            NSMutableArray *list = [parser.list mutableCopy];
             
             //Return success
-            successRequest(response, searchList, request.redirectedServer, token);
+            successRequest(response, list, request.redirectedServer, token);
         }
         
     } failure:^(NSHTTPURLResponse *response, id responseData, NSError *error, NSString *token) {
@@ -752,6 +628,129 @@
     }];
 }
 
+///-----------------------------------
+/// @name Download File Session
+///-----------------------------------
+
+
+
+- (NSURLSessionDownloadTask *) downloadFileSession:(NSString *)remotePath toDestiny:(NSString *)localPath defaultPriority:(BOOL)defaultPriority encode:(BOOL)encode onCommunication:(OCCommunication *)sharedOCCommunication progress:(void(^)(NSProgress *progress))downloadProgress successRequest:(void(^)(NSURLResponse *response, NSURL *filePath)) successRequest failureRequest:(void(^)(NSURLResponse *response, NSError *error)) failureRequest {
+    
+    OCWebDAVClient *request = [OCWebDAVClient new];
+    request = [self getRequestWithCredentials:request];
+    if (encode) remotePath = [remotePath encodeString:NSUTF8StringEncoding];
+    
+    NSURLSessionDownloadTask *downloadTask = [request downloadWithSessionPath:remotePath toPath:localPath defaultPriority:defaultPriority onCommunication:sharedOCCommunication progress:^(NSProgress *progress) {
+        downloadProgress(progress);
+    } success:^(NSURLResponse *response, NSURL *filePath) {
+        
+        [UtilsFramework addCookiesToStorageFromResponse:(NSURLResponse *) response andPath:[NSURL URLWithString:remotePath]];
+        successRequest(response,filePath);
+        
+    } failure:^(NSURLResponse *response, NSError *error) {
+        [UtilsFramework addCookiesToStorageFromResponse:(NSURLResponse *) response andPath:[NSURL URLWithString:remotePath]];
+        failureRequest(response,error);
+    }];
+    
+    return downloadTask;
+}
+
+
+///-----------------------------------
+/// @name Set Download Task Complete Block
+///-----------------------------------
+
+
+- (void)setDownloadTaskComleteBlock: (NSURL * (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block{
+    
+    [self.downloadSessionManager setDownloadTaskDidFinishDownloadingBlock:block];
+
+    
+}
+
+
+///-----------------------------------
+/// @name Set Download Task Did Get Body Data Block
+///-----------------------------------
+
+
+- (void) setDownloadTaskDidGetBodyDataBlock: (void(^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite)) block{
+    
+    [self.downloadSessionManager setDownloadTaskDidWriteDataBlock:^(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite) {
+        block(session,downloadTask,bytesWritten,totalBytesWritten,totalBytesExpectedToWrite);
+    }];
+    
+}
+
+///-----------------------------------
+/// @name Upload File Session
+///-----------------------------------
+
+- (NSURLSessionUploadTask *) uploadFileSession:(NSString *) localPath toDestiny:(NSString *) remotePath onCommunication:(OCCommunication *)sharedOCCommunication progress:(void(^)(NSProgress *progress))uploadProgress successRequest:(void(^)(NSURLResponse *response, NSString *redirectedServer)) successRequest failureRequest:(void(^)(NSURLResponse *response, NSString *redirectedServer, NSError *error)) failureRequest failureBeforeRequest:(void(^)(NSError *error)) failureBeforeRequest {
+    
+    OCWebDAVClient *request = [OCWebDAVClient new];
+    request = [self getRequestWithCredentials:request];
+    
+    
+    remotePath = [remotePath encodeString:NSUTF8StringEncoding];
+    
+    NSURLSessionUploadTask *uploadTask = [request putWithSessionLocalPath:localPath atRemotePath:remotePath onCommunication:sharedOCCommunication progress:^(NSProgress *progress) {
+            uploadProgress(progress);
+        } success:^(NSURLResponse *response, id responseObjec){
+            [UtilsFramework addCookiesToStorageFromResponse:(NSURLResponse *) response andPath:[NSURL URLWithString:remotePath]];
+            //TODO: The second parameter is the redirected server
+            successRequest(response, @"");
+        } failure:^(NSURLResponse *response, id responseObject, NSError *error) {
+            [UtilsFramework addCookiesToStorageFromResponse:(NSURLResponse *) response andPath:[NSURL URLWithString:remotePath]];
+            //TODO: The second parameter is the redirected server
+
+            NSData *responseData = (NSData*) responseObject;
+            
+            OCXMLServerErrorsParser *serverErrorParser = [OCXMLServerErrorsParser new];
+            
+            [serverErrorParser startToParseWithData:responseData withCompleteBlock:^(NSError *err) {
+                
+                if (err) {
+                    failureRequest(response, @"", err);
+                }else{
+                    failureRequest(response, @"", error);
+                }
+                
+            }];
+            
+        } failureBeforeRequest:^(NSError *error) {
+            failureBeforeRequest(error);
+        }];
+    
+    return uploadTask;
+}
+
+///-----------------------------------
+/// @name Set Task Did Complete Block
+///-----------------------------------
+
+- (void) setTaskDidCompleteBlock: (void(^)(NSURLSession *session, NSURLSessionTask *task, NSError *error)) block{
+    
+    [self.uploadSessionManager setTaskDidCompleteBlock:^(NSURLSession *session, NSURLSessionTask *task, NSError *error) {
+
+        block(session, task, error);
+    }];
+    
+}
+
+
+///-----------------------------------
+/// @name Set Task Did Send Body Data Block
+///-----------------------------------
+
+
+- (void) setTaskDidSendBodyDataBlock: (void(^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend)) block{
+    
+   [self.uploadSessionManager setTaskDidSendBodyDataBlock:^(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend) {
+       block(session, task, bytesSent, totalBytesSent, totalBytesExpectedToSend);
+   }];
+}
+
 #pragma mark - OC/NC API Calls
 
 - (NSString *) getCurrentServerVersion {
@@ -1238,42 +1237,6 @@
     }];
 }
 
-- (void)getSharePermissionsFile:(NSString *)fileName onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSString *permissions, NSString *redirectedServer)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest{
-    
-    fileName = [fileName encodeString:NSUTF8StringEncoding];
-    
-    OCWebDAVClient *request = [OCWebDAVClient new];
-    request = [self getRequestWithCredentials:request];
-    
-    [request getSharePermissionsFile:fileName onCommunication:sharedOCComunication success:^(NSHTTPURLResponse *response, id responseObject) {
-        
-        if (successRequest) {
-            
-            NSString *permissions;
-            NSData *responseData = (NSData *)responseObject;
-            
-            NSString *newStr = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
-            NSLog(@"newStrReadFolder: %@", newStr);
-            
-            OCXMLParser *parser = [[OCXMLParser alloc]init];
-            [parser initParserWithData:responseData];
-            NSMutableArray *directoryList = [parser.directoryList mutableCopy];
-            
-            if ([directoryList count] == 1) {
-                OCFileDto *file = [directoryList objectAtIndex:0];
-                permissions = file.permissions;
-            }
-            
-            //Return success
-            successRequest(response, permissions, request.redirectedServer);
-        }
-        
-    } failure:^(NSHTTPURLResponse *response, NSData *responseData, NSError *error) {
-        
-        failureRequest(response, error, request.redirectedServer);
-    }];
-}
-
 #pragma mark - Capabilities
 
 - (void) getCapabilitiesOfServer:(NSString*)serverPath onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, OCCapabilities *capabilities, NSString *redirectedServer)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest{
@@ -3083,9 +3046,9 @@
 
     [request listTrash:path depth:depth onCommunication:sharedOCCommunication success:^(NSHTTPURLResponse *response, id responseObject) {
         
-        OCXMLParser *parser = [OCXMLParser new];
-        [parser initParserWithData:responseObject];
-        NSMutableArray *list = [parser.directoryList mutableCopy];
+        NCXMLListParser *parser = [NCXMLListParser new];
+        [parser initParserWithData:responseObject controlFirstFileOfList:true];
+        NSMutableArray *list = [parser.list mutableCopy];
         
         successRequest(response, list, request.redirectedServer);
         

+ 12 - 0
iOSClient/Library/OCCommunicationLib/OCFileDto.h

@@ -43,6 +43,7 @@
 @property BOOL isDirectory;
 @property long size;
 @property long date;
+@property long creationDate;
 @property (nonatomic, copy) NSString *etag;
 @property (nonatomic, copy) NSString *permissions;
 @property (nonatomic, copy) NSString *ocId;
@@ -53,5 +54,16 @@
 @property (nonatomic, copy) NSString *trashbinOriginalLocation;
 @property long trashbinDeletionTime;
 @property int hasPreview;
+@property (nonatomic, copy) NSString *displayName;
+@property (nonatomic, copy) NSString *contentType;
+@property (nonatomic, copy) NSString *resourceType;
+@property long quotaUsedBytes;
+@property long quotaAvailableBytes;
+@property (nonatomic, copy) NSString *mountType;
+@property (nonatomic, copy) NSString *ownerId;
+@property (nonatomic, copy) NSString *ownerDisplayName;
+@property BOOL commentsUnread;
+@property (nonatomic, copy) NSString *note;
+@property (nonatomic, copy) NSString *sharees;
 
 @end

+ 8 - 0
iOSClient/Library/OCCommunicationLib/OCFileDto.m

@@ -43,6 +43,14 @@
         self.id = 0;
         self.trashbinFileName = @"";
         self.trashbinOriginalLocation = @"";
+        self.displayName = @"";
+        self.contentType = @"";
+        self.resourceType = @"";
+        self.mountType = @"";
+        self.ownerId = @"";
+        self.ownerDisplayName = @"";
+        self.note = @"";
+        self.sharees = @"";
     }
     
     return self;

+ 0 - 3
iOSClient/Library/OCCommunicationLib/OCWebDavClient/OCWebDAVClient.h

@@ -470,9 +470,6 @@ NS_ASSUME_NONNULL_END
                           success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success
                           failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id  _Nullable responseObject, NSError * _Nonnull error))failure;
 
-- (void) getSharePermissionsFile:(NSString * _Nonnull)fileName onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success
-                         failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id  _Nullable responseObject, NSError * _Nonnull error))failure;
-
 ///-----------------------------------
 /// @name Get the server capabilities
 ///-----------------------------------

+ 45 - 115
iOSClient/Library/OCCommunicationLib/OCWebDavClient/OCWebDAVClient.m

@@ -54,6 +54,32 @@ NSString const *OCWebDAVCTagKey				= @"getctag";
 NSString const *OCWebDAVCreationDateKey		= @"creationdate";
 NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
 
+NSString *const NCResource = @"<d:displayname/>"
+                              "<d:getcontenttype/>"
+                              "<d:resourcetype/>"
+                              "<d:getcontentlength/>"
+                              "<d:getlastmodified/>"
+                              "<d:creationdate/>"
+                              "<d:getetag/>"
+                              "<d:quota-used-bytes/>"
+                              "<d:quota-available-bytes/>"
+                              "<permissions xmlns=\"http://owncloud.org/ns\"/>"
+                              "<id xmlns=\"http://owncloud.org/ns\"/>"
+                              "<fileid xmlns=\"http://owncloud.org/ns\"/>"
+                              "<size xmlns=\"http://owncloud.org/ns\"/>"
+                              "<favorite xmlns=\"http://owncloud.org/ns\"/>"
+                              "<is-encrypted xmlns=\"http://nextcloud.org/ns\"/>"
+                              "<mount-type xmlns=\"http://nextcloud.org/ns\"/>"
+                              "<owner-id xmlns=\"http://owncloud.org/ns\"/>"
+                              "<owner-display-name xmlns=\"http://owncloud.org/ns\"/>"
+                              "<comments-unread xmlns=\"http://owncloud.org/ns\"/>"
+                              "<has-preview xmlns=\"http://nextcloud.org/ns\"/>"
+                              "<trashbin-filename xmlns=\"http://nextcloud.org/ns\"/>"
+                              "<trashbin-original-location xmlns=\"http://nextcloud.org/ns\"/>"
+                              "<trashbin-deletion-time xmlns=\"http://nextcloud.org/ns\"/>"
+                              "<note xmlns=\"http://nextcloud.org/ns\"/>"
+                              "<sharees xmlns=\"http://nextcloud.org/ns\"/>";
+
 @interface OCWebDAVClient()
 
 - (void)mr_listPath:(NSString *)path depth:(NSString *)depth onCommunication:
@@ -215,22 +241,10 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
 	NSMutableURLRequest *request = [self requestWithMethod:_requestMethod path:path parameters:nil timeout:k_timeout_webdav];
     
     [request setValue: depth forHTTPHeaderField: @"Depth"];
-    [request setHTTPBody:[@"<?xml version=\"1.0\" encoding=\"UTF-8\"?><D:propfind xmlns:D=\"DAV:\" xmlns:oc=\"http://owncloud.org/ns\" xmlns:nc=\"http://nextcloud.org/ns\">"
-                          "<D:prop>"
-                              "<D:resourcetype/>"
-                              "<D:getlastmodified/>"
-                              "<size xmlns=\"http://owncloud.org/ns\"/>"
-                              "<favorite xmlns=\"http://owncloud.org/ns\"/>"
-                              "<id xmlns=\"http://owncloud.org/ns\"/>"
-                              "<D:getcontentlength/>"
-                              "<D:getetag/>"
-                              "<oc:fileid/>"
-                              "<permissions xmlns=\"http://owncloud.org/ns\"/>"
-                              "<D:getcontenttype/>"
-                              "<nc:is-encrypted/>"
-                              "<nc:has-preview/>"
-                          "</D:prop>"
-                          "</D:propfind>" dataUsingEncoding:NSUTF8StringEncoding]];
+    NSString *body = @"<?xml version=\"1.0\" encoding=\"UTF-8\"?><d:propfind xmlns:d=\"DAV:\" xmlns:oc=\"http://owncloud.org/ns\" xmlns:nc=\"http://nextcloud.org/ns\"><d:prop>";
+    body = [body stringByAppendingString:NCResource];
+    body = [body stringByAppendingString:@"</d:prop></d:propfind>"];
+    [request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];
     [request setValue:@"application/xml" forHTTPHeaderField:@"Content-Type"];
     
     OCHTTPRequestOperation *operation = [self mr_operationWithRequest:request onCommunication:sharedOCCommunication success:success failure:failure];
@@ -248,22 +262,10 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
     NSMutableURLRequest *request = [self requestWithMethod:_requestMethod path:path parameters:nil timeout:k_timeout_webdav];
     
     [request setValue: depth forHTTPHeaderField: @"Depth"];
-    [request setHTTPBody:[@"<?xml version=\"1.0\" encoding=\"UTF-8\"?><D:propfind xmlns:D=\"DAV:\" xmlns:oc=\"http://owncloud.org/ns\" xmlns:nc=\"http://nextcloud.org/ns\">"
-                          "<D:prop>"
-                              "<D:resourcetype/>"
-                              "<D:getlastmodified/>"
-                              "<size xmlns=\"http://owncloud.org/ns\"/>"
-                              "<favorite xmlns=\"http://owncloud.org/ns\"/>"
-                              "<id xmlns=\"http://owncloud.org/ns\"/>"
-                              "<D:getcontentlength/>"
-                              "<D:getetag/>"
-                              "<oc:fileid/>"
-                              "<permissions xmlns=\"http://owncloud.org/ns\"/>"
-                              "<D:getcontenttype/>"
-                              "<nc:is-encrypted/>"
-                              "<nc:has-preview/>"
-                          "</D:prop>"
-                          "</D:propfind>" dataUsingEncoding:NSUTF8StringEncoding]];
+    NSString *body = @"<?xml version=\"1.0\" encoding=\"UTF-8\"?><d:propfind xmlns:d=\"DAV:\" xmlns:oc=\"http://owncloud.org/ns\" xmlns:nc=\"http://nextcloud.org/ns\"><d:prop>";
+    body = [body stringByAppendingString:NCResource];
+    body = [body stringByAppendingString:@"</d:prop></d:propfind>"];
+    [request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];
     [request setValue:@"application/xml" forHTTPHeaderField:@"Content-Type"];
     
     OCHTTPRequestOperation *operation = [self mr_operationWithRequest:request onCommunication:sharedOCCommunication withUserSessionToken:token success:success failure:failure];
@@ -312,18 +314,7 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
             "<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>"
@@ -342,7 +333,7 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
                         "<d:descending/>"
                     "</d:order>"
                 "</d:orderby>"
-                "<d:where><d:and><d:or>", userID, folder];
+                "<d:where><d:and><d:or>", NCResource, 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];
@@ -370,18 +361,7 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
             "<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>"
@@ -397,7 +377,7 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
                     "</d:like>"
                 "</d:where>"
             "</d:basicsearch>"
-        "</d:searchrequest>", userID, folder, fileName];
+        "</d:searchrequest>", NCResource, userID, folder, fileName];
     }
     
     [request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];
@@ -424,18 +404,7 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
                     "<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>"
             
@@ -478,8 +447,7 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
                         "</d:limit>"
                  */
                     "</d:basicsearch>"
-                "</d:searchrequest>"
-            ,userID, folder, fileName]; //, [@(numberOfItem) stringValue]];
+                "</d:searchrequest>", NCResource, userID, folder, fileName]; //, [@(numberOfItem) stringValue]];
     
     [request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];
     [request setValue:@"text/xml" forHTTPHeaderField:@"Content-Type"];
@@ -517,9 +485,7 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
 }
 
 - (void)listingFavorites:(NSString *)path folder:(NSString *)folder 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;
-    
+
     NSParameterAssert(success);
     
     _requestMethod = @"REPORT";
@@ -527,27 +493,10 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
     userID = [userID stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]];
     NSMutableURLRequest *request = [self requestWithMethod:_requestMethod path:[NSString stringWithFormat:@"%@/files/%@%@", path, userID, folder] parameters:nil timeout:k_timeout_webdav];
     
-    body = [NSString stringWithFormat: @""
-            "<?xml version=\"1.0\"?>"
-            "<oc:filter-files xmlns:d=\"DAV:\" xmlns:oc=\"http://owncloud.org/ns\" xmlns:nc=\"http://nextcloud.org/ns\">"
-                "<d:prop>"
-                    "<d:resourcetype/>"
-                    "<oc:fileid/>"
-                    "<d:getetag/>"
-                    "<d:getcontentlength/>"
-                    "<oc:size/>"
-                    "<d:getlastmodified/>"
-                    "<oc:id/>"
-                    "<oc:permissions/>"
-                    "<oc:favorite/>"
-                    "<nc:is-encrypted/>"
-                    "<nc:has-preview/>"
-                "</d:prop>"
-                "<oc:filter-rules>"
-                    "<oc:favorite>1</oc:favorite>"
-                "</oc:filter-rules>"
-            "</oc:filter-files>"];
-    
+    NSString *body = @"<?xml version=\"1.0\"?><oc:filter-files xmlns:d=\"DAV:\" xmlns:oc=\"http://owncloud.org/ns\" xmlns:nc=\"http://nextcloud.org/ns\"><d:prop>";
+    body = [body stringByAppendingString:NCResource];
+    body = [body stringByAppendingString:@"</d:prop><oc:filter-rules><oc:favorite>1</oc:favorite></oc:filter-rules></oc:filter-files>"];
+    [request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];
     [request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];
     [request setValue:@"text/xml" forHTTPHeaderField:@"Content-Type"];
     
@@ -873,25 +822,6 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
     [operation resume];
 }
 
-- (void)getSharePermissionsFile:(NSString*)fileName onCommunication:(OCCommunication *)sharedOCCommunication
-            success:(void(^)(NSHTTPURLResponse *, id))success
-            failure:(void(^)(NSHTTPURLResponse *, id  _Nullable responseObject, NSError *))failure {
-    
-    NSParameterAssert(success);
-    
-    _requestMethod = @"PROPFIND";
-    NSMutableURLRequest *request = [self requestWithMethod:_requestMethod path:fileName parameters:nil timeout:k_timeout_webdav];
-    
-    [request setHTTPBody:[@"<?xml version=\"1.0\" encoding=\"UTF-8\"?><a:propfind xmlns:a=\"DAV:\" xmlns:b=\"http://open-collaboration-services.org/ns\"><a:prop><b:share-permissions/></a:prop></a:propfind>" dataUsingEncoding:NSUTF8StringEncoding]];
-    
-    [request setValue:@"application/xml" forHTTPHeaderField:@"Content-Type"];
-    
-    OCHTTPRequestOperation *operation = [self mr_operationWithRequest:request onCommunication:sharedOCCommunication success:success failure:failure];
-    [self setRedirectionBlockOnDatataskWithOCCommunication:sharedOCCommunication andSessionManager:sharedOCCommunication.networkSessionManager];
-    
-    [operation resume];
-}
-
 - (void) getCapabilitiesOfServer:(NSString*)serverPath onCommunication:(OCCommunication *)sharedOCCommunication success:(void(^)(NSHTTPURLResponse *operation, id response))success failure:(void(^)(NSHTTPURLResponse *operation, id  _Nullable responseObject, NSError *error))failure{
     _requestMethod = @"GET";
     

+ 42 - 0
iOSClient/Library/OCCommunicationLib/OCWebDavClient/Parsers/NCXMLListParser.h

@@ -0,0 +1,42 @@
+//
+//  NCXMLListParser.h
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 17/08/19.
+//  Copyright © 2018 Marino Faggiana. All rights reserved.
+//
+//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
+#import <Foundation/Foundation.h>
+#import "OCFileDto.h"
+
+@interface NCXMLListParser : NSObject <NSXMLParserDelegate> {
+    
+    BOOL isNotFirstFileOfList;
+}
+
+@property BOOL controlFirstFileOfList;
+
+@property (nonatomic, strong) NSMutableArray *list;
+@property (nonatomic, strong) OCFileDto *currentFile;
+
+@property (nonatomic, strong) NSMutableString *xmlChars;
+@property (nonatomic, strong) NSString *status;
+
+- (void)initParserWithData:(NSData *)data controlFirstFileOfList:(BOOL)controlFirstFileOfList;
+
+@end

+ 243 - 0
iOSClient/Library/OCCommunicationLib/OCWebDavClient/Parsers/NCXMLListParser.m

@@ -0,0 +1,243 @@
+//
+//  NCXMLListParser.m
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 17/08/19.
+//  Copyright © 2018 Marino Faggiana. All rights reserved.
+//
+//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
+#import "NCXMLListParser.h"
+
+@implementation NCXMLListParser
+
+- (void)initParserWithData:(NSData *)data controlFirstFileOfList:(BOOL)controlFirstFileOfList {
+    
+    self.list = [NSMutableArray new];
+    self.controlFirstFileOfList = controlFirstFileOfList;
+    
+    NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
+    [parser setDelegate:self];
+    [parser parse];
+}
+
+#pragma mark - XML Parser Delegate Methods
+
+- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
+    
+    if (!self.xmlChars) {
+        self.xmlChars = [NSMutableString string];
+    }
+    
+    [self.xmlChars setString:@""];
+}
+
+- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
+    
+    if ([elementName isEqualToString:@"d:href"]) {
+        
+        if ([self.xmlChars hasPrefix:@"http"]) {
+            NSURL *junk = [NSURL URLWithString:self.xmlChars];
+            BOOL trailingSlash = [_xmlChars hasSuffix:@"/"];
+            [self.xmlChars setString:[junk path]];
+            if (trailingSlash) {
+                [self.xmlChars appendString:@"/"];
+            }
+        }
+        
+        if ([self.xmlChars length]) {
+            
+            self.xmlChars = (NSMutableString *)[_xmlChars stringByReplacingOccurrencesOfString:@"//" withString:@"/"];
+            
+            //Create FileDto
+            self.currentFile = [OCFileDto new];
+            self.currentFile.isDirectory = NO;
+            
+            NSArray *splitedUrl = [self.xmlChars componentsSeparatedByString:@"/"];
+            if([self.xmlChars hasSuffix:@"/"]) {
+                //It's a folder
+                NSInteger fileNameLenght = [((NSString *)[splitedUrl objectAtIndex:[splitedUrl count]-2]) length];
+                if ( fileNameLenght > 0) {
+                    self.currentFile.filePath = [self.xmlChars substringToIndex:[self.xmlChars length] - (fileNameLenght+1)];
+                } else {
+                    self.currentFile.filePath = @"/";
+                }
+            } else {
+                //It's a file
+                NSInteger fileNameLenght = [((NSString *)[splitedUrl objectAtIndex:[splitedUrl count]-1]) length];
+                if (fileNameLenght > 0) {
+                    self.currentFile.filePath = [self.xmlChars substringToIndex:[self.xmlChars length] - fileNameLenght];
+                }else {
+                    self.currentFile.filePath = @"/";
+                }
+            }
+            
+            NSArray *foo = [self.xmlChars componentsSeparatedByString: @"/"];
+            NSString *lastBit;
+            
+            if([self.xmlChars hasSuffix:@"/"]) {
+                lastBit = [foo objectAtIndex: [foo count]-2];
+                lastBit = [NSString stringWithFormat:@"%@/",lastBit];
+            } else {
+                lastBit = [foo objectAtIndex: [foo count]-1];
+            }
+            
+            if (self.controlFirstFileOfList) {
+                if (isNotFirstFileOfList) {
+                    self.currentFile.fileName = lastBit;
+                }
+            } else {
+                self.currentFile.fileName = lastBit;
+            }
+            
+            self.currentFile.fileName = [self.currentFile.fileName stringByRemovingPercentEncoding];
+            self.currentFile.filePath = [self.currentFile.filePath stringByRemovingPercentEncoding];
+            
+            isNotFirstFileOfList = true;
+        }
+        
+    } else if ([elementName isEqualToString:@"d:displayname"] && [self.xmlChars length]) {
+        
+        self.currentFile.displayName = [NSString stringWithString:self.xmlChars];
+
+    } else if ([elementName isEqualToString:@"d:getcontenttype"] && [self.xmlChars length]) {
+        
+        self.currentFile.contentType = [NSString stringWithString:self.xmlChars];
+
+    } else if ([elementName isEqualToString:@"d:resourcetype"] && [self.xmlChars length]) {
+        
+        self.currentFile.resourceType = [NSString stringWithString:self.xmlChars];
+
+    } else if ([elementName isEqualToString:@"d:getcontentlength"] && [self.xmlChars length]) {
+        
+        self.currentFile.size = (long)[self.xmlChars longLongValue];
+
+    } else if ([elementName isEqualToString:@"d:getlastmodified"] && [self.xmlChars length]) {
+        
+        NSDateFormatter *dateFormatter = [NSDateFormatter new];
+        [dateFormatter setDateFormat:@"EEE, dd MMM y HH:mm:ss zzz"];
+        [dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
+        NSDate *date = [dateFormatter dateFromString:[NSString stringWithString:self.xmlChars]];
+        if (date) {
+            self.currentFile.date =  [date timeIntervalSince1970];
+        }
+        
+    } else if ([elementName isEqualToString:@"d:creationdate"] && [self.xmlChars length]) {
+        
+        NSDateFormatter *dateFormatter = [NSDateFormatter new];
+        [dateFormatter setDateFormat:@"EEE, dd MMM y HH:mm:ss zzz"];
+        [dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
+        NSDate *date = [dateFormatter dateFromString:[NSString stringWithString:self.xmlChars]];
+        if (date) {
+            self.currentFile.creationDate =  [date timeIntervalSince1970];
+        }
+
+    } else if ([elementName isEqualToString:@"d:getetag"] && [self.xmlChars length]) {
+        
+        self.currentFile.etag = [[self.xmlChars stringByReplacingOccurrencesOfString:@"\"" withString:@""] lowercaseString];
+
+    } else if ([elementName isEqualToString:@"d:quota-used-bytes"] && [self.xmlChars length]) {
+        
+        self.currentFile.quotaUsedBytes = [self.xmlChars longLongValue];
+
+    } else if ([elementName isEqualToString:@"d:quota-available-bytes"] && [self.xmlChars length]) {
+        
+        self.currentFile.quotaAvailableBytes = [self.xmlChars longLongValue];
+
+    } else if ([elementName isEqualToString:@"oc:permissions"] && [self.xmlChars length]) {
+    
+        self.currentFile.permissions = [NSString stringWithString:self.xmlChars];
+    
+    } else if ([elementName isEqualToString:@"oc:id"] && [self.xmlChars length]) {
+        
+        self.currentFile.ocId = [NSString stringWithString:self.xmlChars];
+        
+    } else if ([elementName isEqualToString:@"oc:fileid"]  && [self.xmlChars length]) {
+        
+        self.currentFile.id = (double)[_xmlChars doubleValue];
+        
+    } else if ([elementName isEqualToString:@"oc:size"] && [self.xmlChars length]) {
+        
+        self.currentFile.size = [self.xmlChars longLongValue];
+
+    } else if ([elementName isEqualToString:@"oc:favorite"] && [self.xmlChars length]) {
+        
+        self.currentFile.isFavorite = [self.xmlChars boolValue];
+
+    } else if ([elementName isEqualToString:@"nc:is-encrypted"] && [self.xmlChars length]) {
+        
+        self.currentFile.isEncrypted = [self.xmlChars boolValue];
+
+    } else if ([elementName isEqualToString:@"nc:mount-type"] && [self.xmlChars length]) {
+        
+        self.currentFile.mountType = [NSString stringWithString:self.xmlChars];
+
+    } else if ([elementName isEqualToString:@"oc:owner-id"] && [self.xmlChars length]) {
+        
+        self.currentFile.ownerId = [NSString stringWithString:self.xmlChars];
+
+    } else if ([elementName isEqualToString:@"oc:owner-display-name"] && [self.xmlChars length]) {
+        
+        self.currentFile.ownerDisplayName = [NSString stringWithString:self.xmlChars];
+
+    } else if ([elementName isEqualToString:@"oc:comments-unread"] && [self.xmlChars length]) {
+        
+        self.currentFile.commentsUnread = [self.xmlChars boolValue];
+
+    } else if ([elementName isEqualToString:@"nc:has-preview"] && [self.xmlChars length]) {
+        
+        self.currentFile.hasPreview = [self.xmlChars boolValue];
+
+    } else if ([elementName isEqualToString:@"nc:trashbin-filename"] && [self.xmlChars length]) {
+        
+        self.currentFile.trashbinFileName = [NSString stringWithString:self.xmlChars];
+
+    } else if ([elementName isEqualToString:@"nc:trashbin-original-location"] && [self.xmlChars length]) {
+        
+        self.currentFile.trashbinOriginalLocation = [NSString stringWithString:self.xmlChars];
+
+    } else if ([elementName isEqualToString:@"nc:trashbin-deletion-time"] && [self.xmlChars length]) {
+        
+        self.currentFile.trashbinDeletionTime = [self.xmlChars longLongValue];
+
+    } else if ([elementName isEqualToString:@"nc:note"] && [self.xmlChars length]) {
+        
+        self.currentFile.note = [NSString stringWithString:self.xmlChars];
+
+    } else if ([elementName isEqualToString:@"nc:sharees"] && [self.xmlChars length]) {
+
+       self.currentFile.sharees = [NSString stringWithString:self.xmlChars];
+        
+    } else if ([elementName isEqualToString:@"d:collection"]) {
+        
+        self.currentFile.isDirectory = true;
+
+    } else if ([elementName isEqualToString:@"d:response"]) {
+    
+        [self.list addObject:self.currentFile];
+    }
+}
+
+- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
+    [self.xmlChars appendString:string];
+}
+
+- (void)parserDidEndDocument:(NSXMLParser *)parser {
+    NSLog(@"Finish xml directory list parse");
+}
+
+@end

+ 0 - 22
iOSClient/Library/OCCommunicationLib/OCWebDavClient/Parsers/OCXMLListParser.h

@@ -1,22 +0,0 @@
-
-
-#import <Foundation/Foundation.h>
-#import "OCFileDto.h"
-
-
-@interface OCXMLListParser : NSObject <NSXMLParserDelegate>{
-    
-    NSMutableString *_xmlChars;
-    NSMutableDictionary *_xmlBucket;
-    NSMutableArray *_searchList;
-    OCFileDto *_currentFile;
-    BOOL isNotFirstFileOfList;
-    
-}
-
-@property(nonatomic,strong) NSMutableArray *searchList;
-@property(nonatomic,strong) OCFileDto *currentFile;
-
-- (void)initParserWithData: (NSData*)data;
-
-@end

+ 0 - 219
iOSClient/Library/OCCommunicationLib/OCWebDavClient/Parsers/OCXMLListParser.m

@@ -1,219 +0,0 @@
-
-
-#import "OCXMLListParser.h"
-#import "NSString+Encode.h"
-
-@implementation OCXMLListParser
-
-@synthesize searchList=_searchList;
-@synthesize currentFile=_currentFile;
-
-/*
- * Method that init the parse with the xml data from the server
- * @data -> XML webDav data from the owncloud server
- */
-- (void)initParserWithData: (NSData*)data{
-    
-    _searchList = [NSMutableArray new];
-    
-    NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
-    [parser setDelegate:self];
-    [parser parse];
-    
-}
-
-
-#pragma mark - XML Parser Delegate Methods
-
-
-/*
- * Method that init parse process.
- */
-
-- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
-    
-    if (!_xmlChars) {
-        _xmlChars = [NSMutableString string];
-    }
-    
-    //NSLog(@"_xmlChars: %@", _xmlChars);
-    
-    [_xmlChars setString:@""];
-
-    if ([elementName isEqualToString:@"d:response"]) {
-        _xmlBucket = [NSMutableDictionary dictionary];
-    }
-}
-
-/*
- * Util method to make a NSDate object from a string from xml
- * @dateString -> Data string from xml
- */
-+ (NSDate*)parseDateString:(NSString*)dateString {
-    //Parse the date in all the formats
-    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
-    /*In most cases the best locale to choose is "en_US_POSIX", a locale that's specifically designed to yield US English results regardless of both user and system preferences. "en_US_POSIX" is also invariant in time (if the US, at some point in the future, changes the way it formats dates, "en_US" will change to reflect the new behaviour, but "en_US_POSIX" will not). It will behave consistently for all users.*/
-    [dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
-    //This is the format for the concret locale used
-    [dateFormatter setDateFormat:@"EEE, dd MMM y HH:mm:ss zzz"];
-    
-    NSDate *theDate = nil;
-    NSError *error = nil;
-    if (![dateFormatter getObjectValue:&theDate forString:dateString range:nil error:&error]) {
-        NSLog(@"Date '%@' could not be parsed: %@", dateString, error);
-    }
-    
-    return theDate;
-}
-
-
-- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
-    
-    // NSLog(@"elementName: %@:%@", elementName,_xmlChars);
-    
-    if ([elementName isEqualToString:@"d:href"]) {
-        
-        if ([_xmlChars hasPrefix:@"http"]) {
-            NSURL *junk = [NSURL URLWithString:_xmlChars];
-            BOOL trailingSlash = [_xmlChars hasSuffix:@"/"];
-            [_xmlChars setString:[junk path]];
-            if (trailingSlash) {
-                [_xmlChars appendString:@"/"];
-            }
-        }
-        
-        //If has lenght, there are an item
-        if ([_xmlChars length]) {
-            
-            //BUG ?? https://github.com/nextcloud/server/issues/6925
-            _xmlChars = (NSMutableString *)[_xmlChars stringByReplacingOccurrencesOfString:@"//" withString:@"/"];
-            
-            //Create FileDto
-            _currentFile = [OCFileDto new];
-             _currentFile.isDirectory = NO;
-            [_xmlBucket setObject:[_xmlChars copy] forKey:@"uri"];
-            
-            NSArray *splitedUrl = [_xmlChars componentsSeparatedByString:@"/"];
-            
-            //Check if the item is a folder or a file
-            if([_xmlChars hasSuffix:@"/"]) {
-                //It's a folder
-                NSInteger fileNameLenght = [((NSString *)[splitedUrl objectAtIndex:[splitedUrl count]-2]) length];
-                
-                if ( fileNameLenght > 0) {
-                    //FileDto filepath
-                    _currentFile.filePath = [_xmlChars substringToIndex:[_xmlChars length] - (fileNameLenght+1)];
-                } else {
-                    _currentFile.filePath = @"/";
-                }
-            } else {
-                //It's a file
-                NSInteger fileNameLenght = [((NSString *)[splitedUrl objectAtIndex:[splitedUrl count]-1]) length];
-                if (fileNameLenght > 0) {
-                    _currentFile.filePath = [_xmlChars substringToIndex:[_xmlChars length] - fileNameLenght];
-                }else {
-                    _currentFile.filePath = @"/";
-                }
-            }
-       
-            NSArray *foo = [_xmlChars componentsSeparatedByString: @"/"];
-            NSString *lastBit;
-        
-            if([_xmlChars hasSuffix:@"/"]) {
-                lastBit = [foo objectAtIndex: [foo count]-2];
-                lastBit = [NSString stringWithFormat:@"%@/",lastBit];
-            } else {
-                lastBit = [foo objectAtIndex: [foo count]-1];
-            }
-        
-        
-            [_xmlBucket setObject:lastBit forKey:@"href"];
-            _currentFile.fileName = lastBit;
-            
-            self.currentFile.fileName = [self.currentFile.fileName stringByRemovingPercentEncoding];
-            self.currentFile.filePath = [self.currentFile.filePath stringByRemovingPercentEncoding];
-        }
-        
-    } else if ([elementName isEqualToString:@"d:getlastmodified"]) {
-        
-        //DATE
-        // 'Thu, 30 Oct 2008 02:52:47 GMT'
-        // Monday, 12-Jan-98 09:25:56 GMT
-        // Value: HTTP-date  ; defined in section 3.3.1 of RFC2068
-        
-        if ([_xmlChars length]) {
-            NSDate *d = [[self class] parseDateString:_xmlChars];
-            
-            if (d) {
-                //FildeDto Date
-                _currentFile.date = [d timeIntervalSince1970];
-                NSInteger colIdx = [elementName rangeOfString:@":"].location;
-                [_xmlBucket setObject:d forKey:[elementName substringFromIndex:colIdx + 1]];
-            }
-            
-            else {
-                NSLog(@"Could not parse date string '%@' for '%@'", _xmlChars, elementName);
-            }
-        }
-        
-    } else if ([elementName isEqualToString:@"oc:id"]) {
-        _currentFile.ocId = _xmlChars;
-    } else if ([elementName isEqualToString:@"oc:fileid"]) {
-        _currentFile.id = (double)[_xmlChars doubleValue];
-    } else if ([elementName hasSuffix:@":getetag"] && [_xmlChars length]) {
-        
-        //ETAG
-        //NSLog(@"getetag: %@", _xmlChars);
-        
-        NSString *stringClean = _xmlChars;
-        stringClean = [_xmlChars stringByReplacingOccurrencesOfString:@"\"" withString:@""];
-        
-        _currentFile.etag = [stringClean lowercaseString];
-        
-    } else if ([elementName hasSuffix:@":getcontenttype"] && [_xmlChars length]) {
-        //CONTENT TYPE
-        [_xmlBucket setObject:[_xmlChars copy] forKey:@"contenttype"];
-        
-    } else if([elementName hasSuffix:@"d:getcontentlength"] && [_xmlChars length]) {
-        //SIZE
-        //FileDto current size
-        _currentFile.size = (long)[_xmlChars longLongValue];
-        
-    } else if ([elementName isEqualToString:@"oc:permissions"]) {
-        _currentFile.permissions = _xmlChars;
-        
-    } else if ([elementName isEqualToString:@"d:collection"]) {
-        _currentFile.isDirectory = YES;
-        
-    } else if ([elementName isEqualToString:@"d:response"]) {
-        
-        //Add to searchList
-        [_searchList addObject:_currentFile];
-        _currentFile = [OCFileDto new];
-
-        _xmlBucket = nil;
-    } else if ([elementName isEqualToString:@"oc:favorite"]) {
-        _currentFile.isFavorite = [_xmlChars boolValue];
-    } else if ([elementName isEqualToString:@"nc:is-encrypted"]) {
-        _currentFile.isEncrypted = [_xmlChars boolValue];
-    } else if ([elementName isEqualToString:@"nc:trashbin-filename"]) {
-        _currentFile.trashbinFileName = _xmlChars;
-    }else if ([elementName isEqualToString:@"nc:trashbin-original-location"]) {
-        _currentFile.trashbinOriginalLocation = _xmlChars;
-    }else if ([elementName isEqualToString:@"nc:trashbin-deletion-time"]) {
-        _currentFile.trashbinDeletionTime = (long)[_xmlChars longLongValue];
-    }else if ([elementName isEqualToString:@"nc:has-preview"] && [_xmlChars length]) {
-        _currentFile.hasPreview = [_xmlChars boolValue];
-    }
-}
-
-- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
-    [_xmlChars appendString:string];
-}
-
-- (void)parserDidEndDocument:(NSXMLParser *)parser{
-    
-    NSLog(@"Finish xml directory list parse");
-}
-
-@end

+ 0 - 45
iOSClient/Library/OCCommunicationLib/OCWebDavClient/Parsers/OCXMLParser.h

@@ -1,45 +0,0 @@
-//
-//  OCXMLParser.h
-//  webdav
-//
-// Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ )
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-#import <Foundation/Foundation.h>
-#import "OCFileDto.h"
-
-
-@interface OCXMLParser : NSObject <NSXMLParserDelegate>{
-    
-    NSMutableString *_xmlChars;
-    NSMutableDictionary *_xmlBucket;
-    NSMutableArray *_directoryList;
-    OCFileDto *_currentFile;
-    BOOL isNotFirstFileOfList;
-    
-}
-
-@property(nonatomic,strong) NSMutableArray *directoryList;
-@property(nonatomic,strong) OCFileDto *currentFile;
-
-- (void)initParserWithData: (NSData*)data;
-
-@end

+ 0 - 263
iOSClient/Library/OCCommunicationLib/OCWebDavClient/Parsers/OCXMLParser.m

@@ -1,263 +0,0 @@
-//
-//  OCXMLParser.m
-//  webdav
-//
-// Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ )
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-//
-//  Add Support for Quota
-//  quotaUsed and quotaAvailable
-//
-//  Add Support for Favorite
-//  isFavorite
-//
-//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
-//
-
-#import "OCXMLParser.h"
-#import "NSString+Encode.h"
-
-NSString *OCCWebDAVContentTypeKey   = @"contenttype";
-NSString *OCCWebDAVETagKey          = @"etag";
-NSString *OCCWebDAVHREFKey          = @"href";
-NSString *OCCWebDAVURIKey           = @"uri";
-
-@implementation OCXMLParser
-
-@synthesize directoryList=_directoryList;
-@synthesize currentFile=_currentFile;
-
-/*
- * Method that init the parse with the xml data from the server
- * @data -> XML webDav data from the owncloud server
- */
-- (void)initParserWithData: (NSData*)data{
-    
-    _directoryList = [[NSMutableArray alloc]init];
-    
-    NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
-    [parser setDelegate:self];
-    [parser parse];
-    
-}
-
-
-#pragma mark - XML Parser Delegate Methods
-
-
-/*
- * Method that init parse process.
- */
-
-- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
-    
-    if (!_xmlChars) {
-        _xmlChars = [NSMutableString string];
-    }
-    
-    //NSLog(@"_xmlChars: %@", _xmlChars);
-    
-    [_xmlChars setString:@""];
-
-    if ([elementName isEqualToString:@"d:response"]) {
-        _xmlBucket = [NSMutableDictionary dictionary];
-    }
-}
-
-/*
- * Util method to make a NSDate object from a string from xml
- * @dateString -> Data string from xml
- */
-+ (NSDate*)parseDateString:(NSString*)dateString {
-    //Parse the date in all the formats
-    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
-    /*In most cases the best locale to choose is "en_US_POSIX", a locale that's specifically designed to yield US English results regardless of both user and system preferences. "en_US_POSIX" is also invariant in time (if the US, at some point in the future, changes the way it formats dates, "en_US" will change to reflect the new behaviour, but "en_US_POSIX" will not). It will behave consistently for all users.*/
-    [dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
-    //This is the format for the concret locale used
-    [dateFormatter setDateFormat:@"EEE, dd MMM y HH:mm:ss zzz"];
-    
-    NSDate *theDate = nil;
-    NSError *error = nil;
-    if (![dateFormatter getObjectValue:&theDate forString:dateString range:nil error:&error]) {
-        NSLog(@"Date '%@' could not be parsed: %@", dateString, error);
-    }
-    
-    return theDate;
-}
-
-
-- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
-    
-    // NSLog(@"elementName: %@:%@", elementName,_xmlChars);
-    
-    if ([elementName isEqualToString:@"d:href"]) {
-        
-        if ([_xmlChars hasPrefix:@"http"]) {
-            NSURL *junk = [NSURL URLWithString:_xmlChars];
-            BOOL trailingSlash = [_xmlChars hasSuffix:@"/"];
-            [_xmlChars setString:[junk path]];
-            if (trailingSlash) {
-                [_xmlChars appendString:@"/"];
-            }
-        }
-        
-        //If has lenght, there are an item
-        if ([_xmlChars length]) {
-            //Create FileDto
-            _currentFile = [[OCFileDto alloc] init];
-             _currentFile.isDirectory = NO;
-            [_xmlBucket setObject:[_xmlChars copy] forKey:OCCWebDAVURIKey];
-            
-            NSArray *splitedUrl = [_xmlChars componentsSeparatedByString:@"/"];
-            
-            //Check if the item is a folder or a file
-            if([_xmlChars hasSuffix:@"/"]) {
-                //It's a folder
-                NSInteger fileNameLenght = [((NSString *)[splitedUrl objectAtIndex:[splitedUrl count]-2]) length];
-                
-                if ( fileNameLenght > 0) {
-                    //FileDto filepath
-                    _currentFile.filePath = [_xmlChars substringToIndex:[_xmlChars length] - (fileNameLenght+1)];
-                } else {
-                    _currentFile.filePath = @"/";
-                }
-            } else {
-                //It's a file
-                NSInteger fileNameLenght = [((NSString *)[splitedUrl objectAtIndex:[splitedUrl count]-1]) length];
-                if (fileNameLenght > 0) {
-                    _currentFile.filePath = [_xmlChars substringToIndex:[_xmlChars length] - fileNameLenght];
-                }else {
-                    _currentFile.filePath = @"/";
-                }
-            }
-       
-      
-    
-        NSArray *foo = [_xmlChars componentsSeparatedByString: @"/"];
-        NSString *lastBit;
-        
-        if([_xmlChars hasSuffix:@"/"]) {
-            lastBit = [foo objectAtIndex: [foo count]-2];
-            lastBit = [NSString stringWithFormat:@"%@/",lastBit];
-        } else {
-            lastBit = [foo objectAtIndex: [foo count]-1];
-        }
-        
-        //NSString *lastBit = [_xmlChars substringFromIndex:_uriLength];
-        //NSLog(@"lastBit:- %@",lastBit);
-        if (isNotFirstFileOfList == YES) {
-            [_xmlBucket setObject:lastBit forKey:OCCWebDAVHREFKey];
-            _currentFile.fileName = lastBit;
-        }
-            
-        self.currentFile.fileName = [self.currentFile.fileName stringByRemovingPercentEncoding];
-        self.currentFile.filePath = [self.currentFile.filePath stringByRemovingPercentEncoding];
-            
-        isNotFirstFileOfList = YES;
-
-//        //NSLog(@"1 _xmlBucked :- %@",_xmlBucket);
-     }
-    } else if ([elementName isEqualToString:@"d:getlastmodified"]) {
-        //DATE
-        // 'Thu, 30 Oct 2008 02:52:47 GMT'
-        // Monday, 12-Jan-98 09:25:56 GMT
-        // Value: HTTP-date  ; defined in section 3.3.1 of RFC2068
-        
-        if ([_xmlChars length]) {
-            NSDate *d = [[self class] parseDateString:_xmlChars];
-            
-            if (d) {
-                //FildeDto Date
-                _currentFile.date = [d timeIntervalSince1970];
-                NSInteger colIdx = [elementName rangeOfString:@":"].location;
-                [_xmlBucket setObject:d forKey:[elementName substringFromIndex:colIdx + 1]];
-            }
-            
-            else {
-                NSLog(@"Could not parse date string '%@' for '%@'", _xmlChars, elementName);
-            }
-        }
-        
-    } else if ([elementName isEqualToString:@"oc:id"]) {
-        _currentFile.ocId = _xmlChars;
-    } else if ([elementName isEqualToString:@"oc:fileid"]) {
-        _currentFile.id = (double)[_xmlChars doubleValue];
-    } else if ([elementName hasSuffix:@":getetag"] && [_xmlChars length]) {
-        
-        //ETAG
-        //NSLog(@"getetag: %@", _xmlChars);
-        
-        NSString *stringClean = _xmlChars;
-        stringClean = [_xmlChars stringByReplacingOccurrencesOfString:@"\"" withString:@""];
-        
-        _currentFile.etag = [stringClean lowercaseString];
-        
-    } else if ([elementName hasSuffix:@":getcontenttype"] && [_xmlChars length]) {
-        //CONTENT TYPE
-        [_xmlBucket setObject:[_xmlChars copy] forKey:OCCWebDAVContentTypeKey];
-        
-    } else if([elementName hasSuffix:@"d:getcontentlength"] && [_xmlChars length]) {
-        //SIZE
-        //FileDto current size
-        _currentFile.size = (long)[_xmlChars longLongValue];
-        
-    } else if ([elementName isEqualToString:@"oc:permissions"]) {
-        _currentFile.permissions = _xmlChars;
-        
-    } else if ([elementName isEqualToString:@"d:collection"]) {
-        _currentFile.isDirectory = YES;
-        
-    } else if ([elementName isEqualToString:@"d:response"]) {
-        //NSLog(@"2 _xmlBucked :- %@",_xmlBucket);
-        
-        //Add to directoryList
-        [_directoryList addObject:_currentFile];
-        _currentFile = [[OCFileDto alloc] init];
-
-        _xmlBucket = nil;
-    } else if ([elementName isEqualToString:@"oc:favorite"]) {
-        _currentFile.isFavorite = [_xmlChars boolValue];
-    } else if ([elementName isEqualToString:@"x1:share-permissions"]) {
-        _currentFile.permissions = _xmlChars;
-    } else if ([elementName isEqualToString:@"nc:is-encrypted"]) {
-        _currentFile.isEncrypted = [_xmlChars boolValue];
-    }else if ([elementName isEqualToString:@"nc:trashbin-filename"]) {
-        _currentFile.trashbinFileName = _xmlChars;
-    }else if ([elementName isEqualToString:@"nc:trashbin-original-location"]) {
-        _currentFile.trashbinOriginalLocation = _xmlChars;
-    }else if ([elementName isEqualToString:@"nc:trashbin-deletion-time"]) {
-        _currentFile.trashbinDeletionTime = (long)[_xmlChars longLongValue];
-    } else if ([elementName isEqualToString:@"nc:has-preview"] && [_xmlChars length]) {
-        _currentFile.hasPreview = [_xmlChars boolValue];
-    }
-}
-
-- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
-    [_xmlChars appendString:string];
-}
-
-- (void)parserDidEndDocument:(NSXMLParser *)parser{
-    
-    NSLog(@"Finish xml directory list parse");
-}
-
-@end

+ 1 - 1
iOSClient/Library/OCCommunicationLib/OCWebDavClient/Parsers/OCXMLSharedParser.h

@@ -27,7 +27,7 @@
 #import <Foundation/Foundation.h>
 #import "OCSharedDto.h"
 
-@interface OCXMLSharedParser :  NSObject <NSXMLParserDelegate>{
+@interface OCXMLSharedParser :  NSObject <NSXMLParserDelegate> {
     
     NSMutableString *_xmlChars;
     NSMutableDictionary *_xmlBucket;

+ 0 - 1
iOSClient/Networking/OCNetworking.h

@@ -76,7 +76,6 @@
 - (void)shareUpdateAccount:(NSString *)account shareID:(NSInteger)shareID password:(NSString *)password note:(NSString *)note permission:(NSInteger)permission expirationTime:(NSString *)expirationTime hideDownload:(BOOL)hideDownload completion:(void (^)(NSString *account, NSString *message, NSInteger errorCode))completion;
 - (void)unshareAccount:(NSString *)account shareID:(NSInteger)shareID completion:(void (^)(NSString *account, NSString *message, NSInteger errorCode))completion;
 - (void)getUserGroupWithAccount:(NSString *)account searchString:(NSString *)searchString completion:(void (^)(NSString *account, NSArray *item, NSString *message, NSInteger errorCode))completion;
-- (void)getSharePermissionsFileWithAccount:(NSString *)account fileNamePath:(NSString *)fileNamePath completion:(void (^)(NSString *account, NSString *permissions, NSString *message, NSInteger errorCode))completion;
 
 #pragma mark ===== API =====
 

+ 0 - 45
iOSClient/Networking/OCNetworking.m

@@ -1678,51 +1678,6 @@
     }];
 }
 
-- (void)getSharePermissionsFileWithAccount:(NSString *)account fileNamePath:(NSString *)fileNamePath completion:(void (^)(NSString *account, NSString *permissions, NSString *message, NSInteger errorCode))completion
-{
-    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", account]];
-    if (tableAccount == nil) {
-        completion(account, 0, NSLocalizedString(@"_error_user_not_available_", nil), k_CCErrorUserNotAvailble);
-    } else if ([CCUtility getPassword:account].length == 0) {
-        completion(account, 0, NSLocalizedString(@"_bad_username_password_", nil), kOCErrorServerUnauthorized);
-    } else if ([CCUtility getCertificateError:account]) {
-        completion(account, 0, NSLocalizedString(@"_ssl_certificate_untrusted_", nil), NSURLErrorServerCertificateUntrusted);
-    }
-    
-    OCCommunication *communication = [OCNetworking sharedManager].sharedOCCommunication;
-    
-    [communication setCredentialsWithUser:tableAccount.user andUserID:tableAccount.userID andPassword:[CCUtility getPassword:account]];
-    [communication setUserAgent:[CCUtility getUserAgent]];
-    [communication getSharePermissionsFile:fileNamePath onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *permissions, NSString *redirectedServer) {
-        
-        completion(account, permissions, 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 || errorCode == kOCErrorServerForbidden) {
-            [[OCNetworking sharedManager] checkRemoteWipe:account];
-        } 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 ===== VAR =====
 #pragma --------------------------------------------------------------------------------------------