marinofaggiana 4 years ago
parent
commit
001f70d2d2

+ 3 - 0
iOSClient/AppDelegate.m

@@ -436,6 +436,9 @@
     
     
     [[NCNetworking sharedInstance] setupWithAccount:activeAccount delegate:nil];
     [[NCNetworking sharedInstance] setupWithAccount:activeAccount delegate:nil];
     [[NCCommunicationCommon sharedInstance] setupWithUser:activeUser userId:activeUserID password:activePassword url:activeUrl userAgent:[CCUtility getUserAgent] capabilitiesGroup:[NCBrandOptions sharedInstance].capabilitiesGroups nextcloudVersion:capabilities.versionMajor delegate:[NCNetworking sharedInstance]];
     [[NCCommunicationCommon sharedInstance] setupWithUser:activeUser userId:activeUserID password:activePassword url:activeUrl userAgent:[CCUtility getUserAgent] capabilitiesGroup:[NCBrandOptions sharedInstance].capabilitiesGroups nextcloudVersion:capabilities.versionMajor delegate:[NCNetworking sharedInstance]];
+    
+    OCCommunication *communication = [OCNetworking sharedManager].sharedOCCommunication;
+    [communication setupNextcloudVersion:[[NCManageDatabase sharedInstance] getServerVersionWithAccount:activeAccount]];
 }
 }
 
 
 - (void)settingWebDavRoot:(NSString *)webdavRoot
 - (void)settingWebDavRoot:(NSString *)webdavRoot

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

@@ -85,7 +85,7 @@ typedef enum {
 /* This flag indicate if the server handling forbidden characters */
 /* This flag indicate if the server handling forbidden characters */
 @property BOOL isForbiddenCharactersAvailable;
 @property BOOL isForbiddenCharactersAvailable;
 
 
-
+@property NSInteger nextcloudVersion;
 
 
 ///-----------------------------------
 ///-----------------------------------
 /// @name Init with Upload Session Manager
 /// @name Init with Upload Session Manager
@@ -168,6 +168,8 @@ typedef enum {
  */
  */
 - (id) getRequestWithCredentials:(id) request;
 - (id) getRequestWithCredentials:(id) request;
 
 
+- (void) setupNextcloudVersion:(NSInteger) version;
+
 
 
 #pragma mark - Network operations
 #pragma mark - Network operations
 
 

+ 16 - 4
iOSClient/Library/OCCommunicationLib/OCCommunication.m

@@ -194,6 +194,12 @@
     self.password = token;
     self.password = token;
 }
 }
 
 
+- (void) setupNextcloudVersion:(NSInteger) version
+{
+    self.nextcloudVersion = version;
+}
+
+
 ///-----------------------------------
 ///-----------------------------------
 /// @name getRequestWithCredentials
 /// @name getRequestWithCredentials
 ///-----------------------------------
 ///-----------------------------------
@@ -2558,10 +2564,13 @@
 
 
 - (void)lockEndToEndFolderEncrypted:(NSString*)serverPath ocId:(NSString *)ocId token:(NSString *)token onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSString *token, NSString *redirectedServer)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest {
 - (void)lockEndToEndFolderEncrypted:(NSString*)serverPath ocId:(NSString *)ocId token:(NSString *)token onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSString *token, NSString *redirectedServer)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest {
     
     
+    NSString *tokenParameter = @"token";
+    if (self.nextcloudVersion == k_nextcloud_version_19_0) { tokenParameter = @"e2e-token"; }
+    
     serverPath = [serverPath stringByAppendingString:k_url_client_side_encryption];
     serverPath = [serverPath stringByAppendingString:k_url_client_side_encryption];
     serverPath = [NSString stringWithFormat:@"%@/lock/%@", serverPath, ocId];
     serverPath = [NSString stringWithFormat:@"%@/lock/%@", serverPath, ocId];
     if (token) {
     if (token) {
-        serverPath = [NSString stringWithFormat:@"%@?e2e-token=%@", serverPath, token];
+        serverPath = [NSString stringWithFormat:@"%@?%@=%@", serverPath, tokenParameter, token];
         serverPath = [serverPath stringByAppendingString:@"&format=json"];
         serverPath = [serverPath stringByAppendingString:@"&format=json"];
     } else {
     } else {
         serverPath = [serverPath stringByAppendingString:@"?format=json"];
         serverPath = [serverPath stringByAppendingString:@"?format=json"];
@@ -2590,9 +2599,9 @@
             
             
             if (statusCode == kOCUserProfileAPISuccessful) {
             if (statusCode == kOCUserProfileAPISuccessful) {
                 
                 
-                if ([data valueForKey:@"e2e-token"] && ![[data valueForKey:@"e2e-token"] isKindOfClass:[NSNull class]]) {
+                if ([data valueForKey:tokenParameter] && ![[data valueForKey:tokenParameter] isKindOfClass:[NSNull class]]) {
                     
                     
-                    token = [data valueForKey:@"e2e-token"];
+                    token = [data valueForKey:tokenParameter];
                     successRequest(response, token, request.redirectedServer);
                     successRequest(response, token, request.redirectedServer);
                     
                     
                 } else {
                 } else {
@@ -2753,11 +2762,14 @@
 
 
 - (void)updateEndToEndMetadata:(NSString*)serverPath ocId:(NSString *)ocId encryptedMetadata:(NSString *)encryptedMetadata token:(NSString *)token onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSString *encryptedMetadata, NSString *redirectedServer))successRequest  failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest {
 - (void)updateEndToEndMetadata:(NSString*)serverPath ocId:(NSString *)ocId encryptedMetadata:(NSString *)encryptedMetadata token:(NSString *)token onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSString *encryptedMetadata, NSString *redirectedServer))successRequest  failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest {
     
     
+    NSString *tokenParameter = @"token";
+    if (self.nextcloudVersion == k_nextcloud_version_19_0) { tokenParameter = @"e2e-token"; }
+    
     encryptedMetadata = [encryptedMetadata encodeString:NSUTF8StringEncoding];
     encryptedMetadata = [encryptedMetadata encodeString:NSUTF8StringEncoding];
 
 
     serverPath = [serverPath stringByAppendingString:k_url_client_side_encryption];
     serverPath = [serverPath stringByAppendingString:k_url_client_side_encryption];
     serverPath = [NSString stringWithFormat:@"%@/meta-data/%@", serverPath, ocId];
     serverPath = [NSString stringWithFormat:@"%@/meta-data/%@", serverPath, ocId];
-    serverPath = [NSString stringWithFormat:@"%@?e2e-token=%@", serverPath, token];
+    serverPath = [NSString stringWithFormat:@"%@?%@=%@", serverPath, tokenParameter, token];
     serverPath = [serverPath stringByAppendingString:@"&format=json"];
     serverPath = [serverPath stringByAppendingString:@"&format=json"];
     
     
     OCWebDAVClient *request = [[OCWebDAVClient alloc] init];
     OCWebDAVClient *request = [[OCWebDAVClient alloc] init];