NCManageEndToEndEncryption.m 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //
  2. // NCManageEndToEndEncryption.m
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 13/10/17.
  6. // Copyright © 2017 TWS. All rights reserved.
  7. //
  8. // Author Marino Faggiana <m.faggiana@twsweb.it>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. #import "NCManageEndToEndEncryption.h"
  24. #import "AppDelegate.h"
  25. #import "CCNetworking.h"
  26. #import "NCBridgeSwift.h"
  27. @implementation NCManageEndToEndEncryption
  28. -(id)init
  29. {
  30. XLFormDescriptor *form ;
  31. XLFormSectionDescriptor *section;
  32. XLFormRowDescriptor *row;
  33. form = [XLFormDescriptor formDescriptorWithTitle:NSLocalizedString(@"_e2e_settings_encryption_", nil)];
  34. // Section INITIALIZE -------------------------------------------------
  35. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_e2e_settings_encryption_initialize_", nil)];
  36. [form addFormSection:section];
  37. // Inizializze e2e
  38. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"initE2E" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_e2e_settings_encryption_initialize_", nil)];
  39. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  40. [row.cellConfig setObject:[UIColor blackColor] forKey:@"textLabel.textColor"];
  41. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  42. row.action.formSelector = @selector(initE2E:);
  43. [section addFormRow:row];
  44. #ifdef DEBUGH
  45. // Section DELETE KEYS -------------------------------------------------
  46. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"Delete", nil)];
  47. [form addFormSection:section];
  48. // Delete publicKey
  49. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"deletePublicKey" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_e2e_settings_encryption_delete_publicKey_", nil)];
  50. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  51. [row.cellConfig setObject:[UIColor blackColor] forKey:@"textLabel.textColor"];
  52. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  53. row.action.formSelector = @selector(deletePublicKey:);
  54. [section addFormRow:row];
  55. // Delete privateKey
  56. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"deletePrivateKey" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_e2e_settings_encryption_delete_privateKey_", nil)];
  57. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  58. [row.cellConfig setObject:[UIColor blackColor] forKey:@"textLabel.textColor"];
  59. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  60. row.action.formSelector = @selector(deletePrivateKey:);
  61. [section addFormRow:row];
  62. #endif
  63. return [super initWithForm:form];
  64. }
  65. - (void)deletePublicKey:(XLFormRowDescriptor *)sender
  66. {
  67. [self deselectFormRow:sender];
  68. CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:app.activeAccount];
  69. metadataNet.action = actionDeleteEndToEndPublicKey;
  70. [app addNetworkingOperationQueue:app.netQueue delegate:app.endToEndInterface metadataNet:metadataNet];
  71. }
  72. - (void)deletePrivateKey:(XLFormRowDescriptor *)sender
  73. {
  74. [self deselectFormRow:sender];
  75. CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:app.activeAccount];
  76. metadataNet.action = actionDeleteEndToEndPrivateKey;
  77. [app addNetworkingOperationQueue:app.netQueue delegate:app.endToEndInterface metadataNet:metadataNet];
  78. }
  79. - (void)initE2E:(XLFormRowDescriptor *)sender
  80. {
  81. [CCUtility initEndToEnd:app.activeAccount];
  82. [app.endToEndInterface initEndToEndEncryption];
  83. }
  84. @end