Sfoglia il codice sorgente

#2236

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 anni fa
parent
commit
384432664e

+ 7 - 0
iOSClient/Settings/NCEndToEndInitialize.swift

@@ -51,6 +51,13 @@ class NCEndToEndInitialize: NSObject {
         self.getPublicKey()
         self.getPublicKey()
     }
     }
 
 
+    @objc func statusOfService(completion: @escaping (_ error: NKError?) -> Void) {
+
+        NextcloudKit.shared.getE2EECertificate { account, certificate, data, error in
+            completion(error)
+        }
+    }
+
     func getPublicKey() {
     func getPublicKey() {
 
 
         NextcloudKit.shared.getE2EECertificate { account, certificate, data, error in
         NextcloudKit.shared.getE2EECertificate { account, certificate, data, error in

+ 15 - 31
iOSClient/Settings/NCManageEndToEndEncryption.m

@@ -38,7 +38,7 @@
 
 
 @implementation NCManageEndToEndEncryption
 @implementation NCManageEndToEndEncryption
 
 
-- (void)initializeForm
+- (void)initializeForm:(NKError *)error
 {
 {
     XLFormDescriptor *form = [XLFormDescriptor formDescriptor];
     XLFormDescriptor *form = [XLFormDescriptor formDescriptor];
     XLFormSectionDescriptor *section;
     XLFormSectionDescriptor *section;
@@ -52,32 +52,6 @@
         [[NCContentPresenter shared] messageNotification:@"_error_e2ee_" error:error delay:[[NCGlobal shared] dismissAfterSecond] type:messageTypeError];
         [[NCContentPresenter shared] messageNotification:@"_error_e2ee_" error:error delay:[[NCGlobal shared] dismissAfterSecond] type:messageTypeError];
     }
     }
 
 
-    /*
-    if (isE2EEEnabled == NO || ![versionE2EE isEqual:[[NCGlobal shared] e2eeVersion]]) {
-        
-        // Section SERVICE NOT AVAILABLE -------------------------------------------------
-        
-        section = [XLFormSectionDescriptor formSection];
-        if (isE2EEEnabled) {
-            section.footerTitle = [NSString stringWithFormat:@"End-to-End Encryption %@", versionE2EE];
-        }
-        [form addFormSection:section];
-        
-        row = [XLFormRowDescriptor formRowDescriptorWithTag:@"serviceActivated" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_e2e_settings_not_available_", nil)];
-        row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
-        [row.cellConfig setObject:[[UIImage imageNamed:@"closeCircle"] imageWithColor:[UIColor redColor] size:25] forKey:@"imageView.image"];
-        [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
-        [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
-        [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
-        [section addFormRow:row];
-        
-        self.tableView.showsVerticalScrollIndicator = NO;
-        self.form = form;
-
-        return;
-    }
-    */
-    
     if ([CCUtility isEndToEndEnabled:appDelegate.account]) {
     if ([CCUtility isEndToEndEnabled:appDelegate.account]) {
         
         
         // Section SERVICE ACTIVATED -------------------------------------------------
         // Section SERVICE ACTIVATED -------------------------------------------------
@@ -129,6 +103,13 @@
         // Section START E2E -------------------------------------------------
         // Section START E2E -------------------------------------------------
 
 
         section = [XLFormSectionDescriptor formSection];
         section = [XLFormSectionDescriptor formSection];
+        if (error == nil) {
+            section.footerTitle = NSLocalizedString(@"_status_in_progress_", nil);
+        } else if (error.errorCode == 0) {
+            section.footerTitle = NSLocalizedString(@"_status_e2ee_on_server_", nil);
+        } else {
+            section.footerTitle = NSLocalizedString(@"_status_e2ee_not_setup_", nil);
+        }
         [form addFormSection:section];
         [form addFormSection:section];
     
     
         // Start e2e
         // Start e2e
@@ -189,8 +170,7 @@
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackground) name:NCGlobal.shared.notificationCenterApplicationDidEnterBackground object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackground) name:NCGlobal.shared.notificationCenterApplicationDidEnterBackground object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(initialize) name:NCGlobal.shared.notificationCenterInitialize object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(initialize) name:NCGlobal.shared.notificationCenterInitialize object:nil];
 
 
-    [self initializeForm];
-
+    [self initializeForm:nil];
     /*
     /*
     NKRequestOptions *options = [[NKRequestOptions alloc] initWithEndpoint:nil customHeader:nil customUserAgent:nil contentType:nil e2eToken: nil timeout:30 queue:dispatch_get_main_queue()];
     NKRequestOptions *options = [[NKRequestOptions alloc] initWithEndpoint:nil customHeader:nil customUserAgent:nil contentType:nil e2eToken: nil timeout:30 queue:dispatch_get_main_queue()];
     [[NextcloudKit shared] getE2EECertificateWithOptions:options completionHandler:^(NSString* account, NSString *certificate, NSData *data, NKError *error) {
     [[NextcloudKit shared] getE2EECertificateWithOptions:options completionHandler:^(NSString* account, NSString *certificate, NSData *data, NKError *error) {
@@ -204,6 +184,10 @@
     [super viewWillAppear:animated];
     [super viewWillAppear:animated];
     
     
     appDelegate.activeViewController = self;
     appDelegate.activeViewController = self;
+
+    [[NCEndToEndInitialize alloc] statusOfServiceWithCompletion:^(NKError * error) {
+        [self initializeForm:error];
+    }];
 }
 }
 
 
 #pragma mark - NotificationCenter
 #pragma mark - NotificationCenter
@@ -370,7 +354,7 @@
         
         
         UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_remove_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
         UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_remove_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
             [CCUtility clearAllKeysEndToEnd:appDelegate.account];
             [CCUtility clearAllKeysEndToEnd:appDelegate.account];
-            [self initializeForm];
+            [self initializeForm:nil];
         }];
         }];
         
         
         UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_",nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {}];
         UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_",nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {}];
@@ -419,7 +403,7 @@
     // Reload All Datasource
     // Reload All Datasource
     [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:NCGlobal.shared.notificationCenterReloadDataSource object:nil];
     [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:NCGlobal.shared.notificationCenterReloadDataSource object:nil];
 
 
-    [self initializeForm];
+    [self initializeForm:nil];
 }
 }
 
 
 #pragma mark -
 #pragma mark -

+ 2 - 2
iOSClient/Settings/NCSettings.m

@@ -118,8 +118,8 @@
         [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
         [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
         [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
         [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
         [row.cellConfig setObject:[[UIImage imageNamed:@"lock"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
         [row.cellConfig setObject:[[UIImage imageNamed:@"lock"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
-        row.action.formSelector = @selector(manageE2EE:);
-        //row.action.viewControllerClass = [NCManageEndToEndEncryption class];
+        //row.action.formSelector = @selector(manageE2EE:);
+        row.action.viewControllerClass = [NCManageEndToEndEncryption class];
         [section addFormRow:row];
         [section addFormRow:row];
     }
     }
 
 

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

@@ -903,6 +903,9 @@
 "_exporting_video_"         = "Exporting video … Tap to cancel.";
 "_exporting_video_"         = "Exporting video … Tap to cancel.";
 "_talk_detect_"             = "Detected Nextcloud Talk";
 "_talk_detect_"             = "Detected Nextcloud Talk";
 "_talk_add_account_"        = "Nextcloud Talk has been detected, do you want to add an existing account ?";
 "_talk_add_account_"        = "Nextcloud Talk has been detected, do you want to add an existing account ?";
+"_status_in_progress_"      = "Status reading in progress …";
+"_status_e2ee_on_server_"   = "The End-toEnd encryption is already configured in the server but not yet enabled on this device";
+"_status_e2ee_not_setup_"   = "The End-toEnd encryption is not yet configured on the server";
 
 
 // Video
 // Video
 "_select_trace_"            = "Select the trace";
 "_select_trace_"            = "Select the trace";