Marino Faggiana 8 жил өмнө
parent
commit
203aafcb39

+ 15 - 14
Libraries external/OCCommunicationLib/OCCommunicationLib/OCCommunication.m

@@ -64,7 +64,7 @@
         
         
         [self setSecurityPolicyManagers:[self createSecurityPolicy]];
         [self setSecurityPolicyManagers:[self createSecurityPolicy]];
         
         
-        self.isCookiesAvailable = NO;
+        self.isCookiesAvailable = YES;
         self.isForbiddenCharactersAvailable = NO;
         self.isForbiddenCharactersAvailable = NO;
         
         
 #ifdef UNIT_TEST
 #ifdef UNIT_TEST
@@ -106,7 +106,7 @@
 }
 }
 
 
 -(id) initWithUploadSessionManager:(AFURLSessionManager *) uploadSessionManager {
 -(id) initWithUploadSessionManager:(AFURLSessionManager *) uploadSessionManager {
-
+    
     self = [super init];
     self = [super init];
     
     
     if (self) {
     if (self) {
@@ -114,7 +114,7 @@
         //Init the Donwload queue array
         //Init the Donwload queue array
         self.downloadTaskNetworkQueueArray = [NSMutableArray new];
         self.downloadTaskNetworkQueueArray = [NSMutableArray new];
         
         
-        self.isCookiesAvailable = NO;
+        self.isCookiesAvailable = YES;
         self.isForbiddenCharactersAvailable = NO;
         self.isForbiddenCharactersAvailable = NO;
         
         
         //Credentials not set yet
         //Credentials not set yet
@@ -261,11 +261,12 @@
 /// @name Check Server
 /// @name Check Server
 ///-----------------------------------
 ///-----------------------------------
 - (void) checkServer: (NSString *) path
 - (void) checkServer: (NSString *) path
-      onCommunication:(OCCommunication *)sharedOCCommunication
-       successRequest:(void(^)(NSHTTPURLResponse *response, NSString *redirectedServer)) successRequest
-       failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest {
-
+     onCommunication:(OCCommunication *)sharedOCCommunication
+      successRequest:(void(^)(NSHTTPURLResponse *response, NSString *redirectedServer)) successRequest
+      failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest {
+    
     OCWebDAVClient *request = [OCWebDAVClient new];
     OCWebDAVClient *request = [OCWebDAVClient new];
+    request = [self getRequestWithCredentials:request];
     
     
     if (self.userAgent) {
     if (self.userAgent) {
         [request setUserAgent:self.userAgent];
         [request setUserAgent:self.userAgent];
@@ -274,13 +275,13 @@
     path = [path encodeString:NSUTF8StringEncoding];
     path = [path encodeString:NSUTF8StringEncoding];
     
     
     [request checkServer:path onCommunication:sharedOCCommunication
     [request checkServer:path onCommunication:sharedOCCommunication
-                    success:^(NSHTTPURLResponse *response, id responseObject) {
-                        if (successRequest) {
-                            successRequest(response, request.redirectedServer);
-                        }
-                    } failure:^(NSHTTPURLResponse *response, NSData *responseData, NSError *error) {
-                        failureRequest(response, error, request.redirectedServer);
-                    }];
+                 success:^(NSHTTPURLResponse *response, id responseObject) {
+                     if (successRequest) {
+                         successRequest(response, request.redirectedServer);
+                     }
+                 } failure:^(NSHTTPURLResponse *response, NSData *responseData, NSError *error) {
+                     failureRequest(response, error, request.redirectedServer);
+                 }];
 }
 }
 
 
 ///-----------------------------------
 ///-----------------------------------

+ 18 - 11
Libraries external/OCCommunicationLib/OCCommunicationLib/OCWebDavClient/OCWebDAVClient.m

@@ -313,10 +313,11 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
 
 
 - (void)checkServer:(NSString *)path onCommunication:
 - (void)checkServer:(NSString *)path onCommunication:
 (OCCommunication *)sharedOCCommunication
 (OCCommunication *)sharedOCCommunication
-               success:(void(^)(NSHTTPURLResponse *, id))success
-               failure:(void(^)(NSHTTPURLResponse *, id  _Nullable responseObject, NSError *))failure {
+            success:(void(^)(NSHTTPURLResponse *, id))success
+            failure:(void(^)(NSHTTPURLResponse *, id  _Nullable responseObject, NSError *))failure {
     _requestMethod = @"HEAD";
     _requestMethod = @"HEAD";
     NSMutableURLRequest *request = [self requestWithMethod:_requestMethod path:path parameters:nil];
     NSMutableURLRequest *request = [self requestWithMethod:_requestMethod path:path parameters:nil];
+    request.HTTPShouldHandleCookies = false;
     OCHTTPRequestOperation *operation = [self mr_operationWithRequest:request onCommunication:sharedOCCommunication success:success failure:failure];
     OCHTTPRequestOperation *operation = [self mr_operationWithRequest:request onCommunication:sharedOCCommunication success:success failure:failure];
     [self setRedirectionBlockOnDatataskWithOCCommunication:sharedOCCommunication andSessionManager:sharedOCCommunication.networkSessionManager];
     [self setRedirectionBlockOnDatataskWithOCCommunication:sharedOCCommunication andSessionManager:sharedOCCommunication.networkSessionManager];
     [operation resume];
     [operation resume];
@@ -406,14 +407,16 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
 
 
 - (void) getStatusOfTheServer:(NSString *)serverPath onCommunication:
 - (void) getStatusOfTheServer:(NSString *)serverPath onCommunication:
 (OCCommunication *)sharedOCCommunication success:(void(^)(NSHTTPURLResponse *operation, id responseObject))success
 (OCCommunication *)sharedOCCommunication success:(void(^)(NSHTTPURLResponse *operation, id responseObject))success
-                            failure:(void(^)(NSHTTPURLResponse *operation, id  _Nullable responseObject, NSError *error))failure  {
+                      failure:(void(^)(NSHTTPURLResponse *operation, id  _Nullable responseObject, NSError *error))failure  {
     
     
     NSString *urlString = [NSString stringWithFormat:@"%@%@", serverPath, k_server_information_json];
     NSString *urlString = [NSString stringWithFormat:@"%@%@", serverPath, k_server_information_json];
     
     
     _requestMethod = @"GET";
     _requestMethod = @"GET";
     
     
     NSMutableURLRequest *request = [self sharedRequestWithMethod:_requestMethod path: urlString parameters: nil];
     NSMutableURLRequest *request = [self sharedRequestWithMethod:_requestMethod path: urlString parameters: nil];
-
+    
+    request.HTTPShouldHandleCookies = false;
+    
     OCHTTPRequestOperation *operation = [self mr_operationWithRequest:request onCommunication:sharedOCCommunication success:success failure:failure];
     OCHTTPRequestOperation *operation = [self mr_operationWithRequest:request onCommunication:sharedOCCommunication success:success failure:failure];
     [self setRedirectionBlockOnDatataskWithOCCommunication:sharedOCCommunication andSessionManager:sharedOCCommunication.networkSessionManager];
     [self setRedirectionBlockOnDatataskWithOCCommunication:sharedOCCommunication andSessionManager:sharedOCCommunication.networkSessionManager];
     [operation resume];
     [operation resume];
@@ -656,6 +659,11 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
     
     
     [sessionManager setTaskWillPerformHTTPRedirectionBlock:^NSURLRequest * _Nonnull(NSURLSession * _Nonnull session, NSURLSessionTask * _Nonnull task, NSURLResponse * _Nonnull response, NSURLRequest * _Nonnull request) {
     [sessionManager setTaskWillPerformHTTPRedirectionBlock:^NSURLRequest * _Nonnull(NSURLSession * _Nonnull session, NSURLSessionTask * _Nonnull task, NSURLResponse * _Nonnull response, NSURLRequest * _Nonnull request) {
         
         
+        if (response == nil) {
+            // needed to handle fake redirects to canonical addresses, as explained in https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/URLLoadingSystem/Articles/RequestChanges.html
+            return request;
+        }
+        
         NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
         NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
         NSDictionary *dict = [httpResponse allHeaderFields];
         NSDictionary *dict = [httpResponse allHeaderFields];
         //Server path of redirected server
         //Server path of redirected server
@@ -667,6 +675,10 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
                 //We set the redirectedServer in case SAML or is a permanent redirection
                 //We set the redirectedServer in case SAML or is a permanent redirection
                 self.redirectedServer = responseURLString;
                 self.redirectedServer = responseURLString;
                 
                 
+                if ([UtilsFramework isURLWithSamlFragment:responseURLString]) {
+                    // if SAML request, we don't want to follow it; WebView takes care, not here -> nil to NO FOLLOW
+                    return nil;
+                }
             }
             }
             
             
             NSMutableURLRequest *requestRedirect = [request mutableCopy];
             NSMutableURLRequest *requestRedirect = [request mutableCopy];
@@ -681,16 +693,11 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
                 [requestRedirect setHTTPBody:[_postStringForShare dataUsingEncoding:NSUTF8StringEncoding]];
                 [requestRedirect setHTTPBody:[_postStringForShare dataUsingEncoding:NSUTF8StringEncoding]];
             }
             }
             
             
-            if (sharedOCCommunication.isCookiesAvailable) {
-                //We add the cookies of that URL
-                request = [UtilsFramework getRequestWithCookiesByRequest:requestRedirect andOriginalUrlServer:self.originalUrlServer];
-            } else {
-                [UtilsFramework deleteAllCookies];
-            }
             return requestRedirect;
             return requestRedirect;
             
             
         } else {
         } else {
-            return request;
+            // no location to redirect -> nil to NO FOLLOW
+            return nil;
         }
         }
         
         
     }];
     }];

+ 26 - 12
iOSClient/Notification/CCNotification.swift

@@ -50,6 +50,16 @@ class CCNotification: UITableViewController {
         }
         }
     }
     }
     
     
+    func getSataSourceAt(indexPath: IndexPath) -> OCNotifications {
+        
+        let idsNotification: [String] = appDelegate.listOfNotifications.allKeys as! [String]
+        
+        let idNotification : String! = idsNotification[indexPath.row]
+        let notification = appDelegate.listOfNotifications[idNotification] as! OCNotifications
+        
+        return notification
+    }
+    
     override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
     override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
         return true
         return true
     }
     }
@@ -57,20 +67,17 @@ class CCNotification: UITableViewController {
    
    
     override func tableView(_ tableView: UITableView, editActionsForRowAt: IndexPath) -> [UITableViewRowAction]? {
     override func tableView(_ tableView: UITableView, editActionsForRowAt: IndexPath) -> [UITableViewRowAction]? {
         
         
-        let idsNotification: [String] = appDelegate.listOfNotifications.allKeys as! [String]
+        let notification = self.getSataSourceAt(indexPath: editActionsForRowAt)
         
         
-        let idNotification : String! = idsNotification[editActionsForRowAt.row]
-        let notification = appDelegate.listOfNotifications[idNotification] as! OCNotifications
-
         // No Action request
         // No Action request
         if notification.actions.count == 0 {
         if notification.actions.count == 0 {
             
             
-            let delete = UITableViewRowAction(style: .normal, title: NSLocalizedString("_delete_", comment: "")) { action, index in
+            let cancel = UITableViewRowAction(style: .normal, title: NSLocalizedString("_cancel_", comment: "")) { action, index in
                 print("delete button tapped")
                 print("delete button tapped")
             }
             }
-            delete.backgroundColor = .red
+            cancel.backgroundColor = .red
             
             
-            return [delete]
+            return [cancel]
             
             
         } else {
         } else {
         // Action request
         // Action request
@@ -102,7 +109,17 @@ class CCNotification: UITableViewController {
     }
     }
     
     
     override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
     override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
-        return 120
+        
+        let notification = self.getSataSourceAt(indexPath: indexPath)
+        
+        if notification.message.characters.count > 0 {
+            
+            return 120
+            
+        } else {
+            
+            return 80
+        }
     }
     }
     
     
     override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
     override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
@@ -123,10 +140,7 @@ class CCNotification: UITableViewController {
             
             
         } else {
         } else {
             
             
-            let idsNotification: [String] = appDelegate.listOfNotifications.allKeys as! [String]
-
-            let idNotification : String! = idsNotification[indexPath.row]
-            let notification = appDelegate.listOfNotifications[idNotification] as! OCNotifications
+            let notification = self.getSataSourceAt(indexPath: indexPath)
             
             
             let urlIcon = URL(string: notification.icon)!
             let urlIcon = URL(string: notification.icon)!
             let pathFileName = (appDelegate.directoryUser) + "/" + urlIcon.lastPathComponent
             let pathFileName = (appDelegate.directoryUser) + "/" + urlIcon.lastPathComponent