Эх сурвалжийг харах

add deletemarkEndToEndFolderEncrypted

Marino Faggiana 7 жил өмнө
parent
commit
f250cac16e

+ 23 - 0
iOSClient/Images.xcassets/encrypted_empty.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "encrypted_empty.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "encrypted_empty@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "encrypted_empty@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
iOSClient/Images.xcassets/encrypted_empty.imageset/encrypted_empty.png


BIN
iOSClient/Images.xcassets/encrypted_empty.imageset/encrypted_empty@2x.png


BIN
iOSClient/Images.xcassets/encrypted_empty.imageset/encrypted_empty@3x.png


+ 34 - 30
iOSClient/Main/CCMain.m

@@ -3888,12 +3888,12 @@
         NSString *autoUploadFileName = [[NCManageDatabase sharedInstance] getAccountAutoUploadFileName];
         NSString *autoUploadDirectory = [[NCManageDatabase sharedInstance] getAccountAutoUploadDirectory:app.activeUrl];
         
-        [actionSheet addButtonWithTitle: _metadata.fileName
-                                  image: [CCGraphics changeThemingColorImage:[UIImage imageNamed:_metadata.iconName] color:[NCBrandColor sharedInstance].brand]
-                        backgroundColor: [NCBrandColor sharedInstance].tabBar
-                                 height: 50.0
-                                   type: AHKActionSheetButtonTypeDisabled
-                                handler: nil
+        [actionSheet addButtonWithTitle:_metadata.fileName
+                                  image:[CCGraphics changeThemingColorImage:[UIImage imageNamed:_metadata.iconName] color:[NCBrandColor sharedInstance].brand]
+                        backgroundColor:[NCBrandColor sharedInstance].tabBar
+                                 height:50.0
+                                   type:AHKActionSheetButtonTypeDisabled
+                                handler:nil
         ];
         
         if (!lockDirectory) {
@@ -3901,7 +3901,7 @@
             [actionSheet addButtonWithTitle:NSLocalizedString(@"_share_", nil)
                                       image:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"actionSheetShare"] color:[NCBrandColor sharedInstance].brand]
                             backgroundColor:[UIColor whiteColor]
-                                     height: 50.0
+                                     height:50.0
                                        type:AHKActionSheetButtonTypeDefault
                                     handler:^(AHKActionSheet *as) {
                                         
@@ -3914,7 +3914,7 @@
             [actionSheet addButtonWithTitle:NSLocalizedString(@"_rename_", nil)
                                       image:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"actionSheetRename"] color:[NCBrandColor sharedInstance].brand]
                             backgroundColor:[UIColor whiteColor]
-                                     height: 50.0
+                                     height:50.0
                                        type:AHKActionSheetButtonTypeDefault
                                     handler:^(AHKActionSheet *as) {
                                         
@@ -3952,7 +3952,7 @@
             [actionSheet addButtonWithTitle:NSLocalizedString(@"_move_", nil)
                                       image:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"actionSheetMove"] color:[NCBrandColor sharedInstance].brand]
                             backgroundColor:[UIColor whiteColor]
-                                     height: 50.0
+                                     height:50.0
                                        type:AHKActionSheetButtonTypeDefault
                                     handler:^(AHKActionSheet *as) {
                                         
@@ -3965,7 +3965,7 @@
             [actionSheet addButtonWithTitle:NSLocalizedString(@"_folder_automatic_upload_", nil)
                                       image:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"folderphotocamera"] color:[NCBrandColor sharedInstance].brand]
                             backgroundColor:[UIColor whiteColor]
-                                     height: 50.0
+                                     height:50.0
                                        type:AHKActionSheetButtonTypeDefault
                                     handler:^(AHKActionSheet *as) {
                                         
@@ -3990,48 +3990,52 @@
                                     }];
         }
 
-#ifdef DEBUG
-        if ([CCUtility isEndToEndEnabled:app.activeAccount]) {
+        if (!([_metadata.fileName isEqualToString:autoUploadFileName] == YES && [serverUrl isEqualToString:autoUploadDirectory] == YES)) {
             
-            [actionSheet addButtonWithTitle:@"Mark as encrypted"
-                                      image:[UIImage imageNamed:@"actionSheetCrypto"]
+            [actionSheet addButtonWithTitle:titoloLock
+                                      image:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"settingsPasscodeYES"] color:[NCBrandColor sharedInstance].brand]
                             backgroundColor:[UIColor whiteColor]
-                                     height: 50.0
-                                       type:AHKActionSheetButtonTypeEncrypted
+                                     height:50.0
+                                       type:AHKActionSheetButtonTypeDefault
                                     handler:^(AHKActionSheet *as) {
                                         
-                                        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
-                                            [app.endToEndInterface markEndToEndFolderEncrypted:app.activeUrl fileID:_metadata.fileID token:nil];
-                                        });
+                                        [self performSelector:@selector(comandoLockPassword) withObject:nil];
                                     }];
         }
         
-        if ([CCUtility isEndToEndEnabled:app.activeAccount]) {
+#ifdef DEBUG
+        if ([CCUtility isEndToEndEnabled:app.activeAccount] && !_metadata.encrypted) {
             
-            [actionSheet addButtonWithTitle:@"Delete mark as encrypted"
-                                      image:[UIImage imageNamed:@"actionSheetCrypto"]
+            [actionSheet addButtonWithTitle:NSLocalizedString(@"_e2e_set_folder_encrypted_", nil)
+                                      image:[UIImage imageNamed:@"encrypted_empty"]
                             backgroundColor:[UIColor whiteColor]
-                                     height: 50.0
+                                     height:50.0
                                        type:AHKActionSheetButtonTypeEncrypted
                                     handler:^(AHKActionSheet *as) {
                                         
-                                        [app.endToEndInterface deletemarkEndToEndFolderEncrypted:_metadata];
+                                        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
+                                           if ([app.endToEndInterface markEndToEndFolderEncrypted:app.activeUrl fileID:_metadata.fileID token:nil])
+                                               [self readFolder:self.serverUrl];
+                                        });
                                     }];
         }
-#endif
         
-        if (!([_metadata.fileName isEqualToString:autoUploadFileName] == YES && [serverUrl isEqualToString:autoUploadDirectory] == YES)) {
+        if ([CCUtility isEndToEndEnabled:app.activeAccount] && _metadata.encrypted) {
             
-            [actionSheet addButtonWithTitle:titoloLock
-                                      image:[UIImage imageNamed:@"actionSheetLock"]
+            [actionSheet addButtonWithTitle:NSLocalizedString(@"_e2e_remove_folder_encrypted_", nil)
+                                      image:[UIImage imageNamed:@"encrypted_empty"]
                             backgroundColor:[UIColor whiteColor]
-                                     height: 50.0
+                                     height:50.0
                                        type:AHKActionSheetButtonTypeEncrypted
                                     handler:^(AHKActionSheet *as) {
                                         
-                                        [self performSelector:@selector(comandoLockPassword) withObject:nil];
+                                        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
+                                            if ([app.endToEndInterface deletemarkEndToEndFolderEncrypted:app.activeUrl fileID:_metadata.fileID token:nil])
+                                                [self readFolder:self.serverUrl];
+                                        });
                                     }];
         }
+#endif
         
         [actionSheet show];
     }

+ 33 - 6
iOSClient/Security/NCEntoToEndInterface.swift

@@ -340,7 +340,7 @@ class NCEntoToEndInterface : NSObject, OCNetworkingDelegate  {
     // MARK: Mark/Delete Encrypted Folder
     // --------------------------------------------------------------------------------------------
     
-    @objc func markEndToEndFolderEncrypted(_ url: String, fileID: String, token: String?) {
+    @objc func markEndToEndFolderEncrypted(_ url: String, fileID: String, token: String?) -> Bool {
         
         var token : NSString? = token as NSString?
 
@@ -348,25 +348,52 @@ class NCEntoToEndInterface : NSObject, OCNetworkingDelegate  {
             
             appDelegate.messageNotification("_error_", description: error.localizedDescription+" code \(error.code)", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: error.code)
             
-            return
+            return false
         }
         
         if let error = NCNetworkingSync.sharedManager().markEnd(toEndFolderEncrypted: appDelegate.activeUser, userID: appDelegate.activeUserID, password: appDelegate.activePassword, url: url, fileID: fileID) as NSError? {
             
             appDelegate.messageNotification("_error_", description: error.localizedDescription+" code \(error.code)", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: error.code)
             
-            return
+            return false
         }
         
         if let error = NCNetworkingSync.sharedManager().unlockEnd(toEndFolderEncrypted: appDelegate.activeUser, userID: appDelegate.activeUserID, password: appDelegate.activePassword, url: url, fileID: fileID, token: token! as String) as NSError? {
             
             appDelegate.messageNotification("_error_", description: error.localizedDescription+" code \(error.code)", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: error.code)
             
-            return
-        }            
+            return false
+        }
+        
+        return true
     }
     
-    @objc func deletemarkEndToEndFolderEncrypted(_ metadata: tableMetadata) {        
+    @objc func deletemarkEndToEndFolderEncrypted(_ url: String, fileID: String, token: String?) -> Bool {
+        
+        var token : NSString? = token as NSString?
+        
+        if let error = NCNetworkingSync.sharedManager().lockEnd(toEndFolderEncrypted: appDelegate.activeUser, userID: appDelegate.activeUserID, password: appDelegate.activePassword, url: url , fileID: fileID, token: &token) as NSError? {
+            
+            appDelegate.messageNotification("_error_", description: error.localizedDescription+" code \(error.code)", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: error.code)
+            
+            return false
+        }
+        
+        if let error = NCNetworkingSync.sharedManager().deletemarkEnd(toEndFolderEncrypted: appDelegate.activeUser, userID: appDelegate.activeUserID, password: appDelegate.activePassword, url: url, fileID: fileID) as NSError? {
+            
+            appDelegate.messageNotification("_error_", description: error.localizedDescription+" code \(error.code)", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: error.code)
+            
+            return false
+        }
+        
+        if let error = NCNetworkingSync.sharedManager().unlockEnd(toEndFolderEncrypted: appDelegate.activeUser, userID: appDelegate.activeUserID, password: appDelegate.activePassword, url: url, fileID: fileID, token: token! as String) as NSError? {
+            
+            appDelegate.messageNotification("_error_", description: error.localizedDescription+" code \(error.code)", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: error.code)
+            
+            return false
+        }
+        
+        return true
     }
     
     // --------------------------------------------------------------------------------------------

+ 2 - 0
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -504,3 +504,5 @@
 "_e2e_passphrase_request_message_"  = "Insert the 12 words";
 "_e2e_settings_remove_"             = "Remove the encryption locally";
 "_e2e_settings_remove_message_"     = "Confirm removing encryption along with the passphrase.";
+"_e2e_set_folder_encrypted_"        = "Set as encrypted";
+"_e2e_remove_folder_encrypted_"     = "Remove as encrypted";