CCManageCryptoCloud.m 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. //
  2. // CCManageCryptoCloud.m
  3. // Crypto Cloud Technology Nextcloud
  4. //
  5. // Created by Marino Faggiana on 13/02/17.
  6. // Copyright (c) 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 "CCManageCryptoCloud.h"
  24. #import "AppDelegate.h"
  25. @implementation CCManageCryptoCloud
  26. - (id)initWithCoder:(NSCoder *)aDecoder
  27. {
  28. self = [super initWithCoder:aDecoder];
  29. if (self) {
  30. [self initializeForm];
  31. }
  32. return self;
  33. }
  34. - (void)initializeForm
  35. {
  36. XLFormDescriptor *form ;
  37. XLFormSectionDescriptor *section;
  38. XLFormRowDescriptor *row;
  39. form = [XLFormDescriptor formDescriptorWithTitle:NSLocalizedString(@"Crypto Cloud", nil)];
  40. section = [XLFormSectionDescriptor formSection];
  41. [form addFormSection:section];
  42. if (!app.isCryptoCloudMode) {
  43. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"activate_cryptocloud" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_activation_crypto_cloud_", nil)];
  44. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  45. [row.cellConfig setObject:[UIImage imageNamed:image_settingsCryptoCloud] forKey:@"imageView.image"];
  46. row.action.formSelector = @selector(activateCryptoCloud:);
  47. [section addFormRow:row];
  48. }
  49. if (app.isCryptoCloudMode) {
  50. // Send aes-256 password via mail
  51. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"sendmailencryptpass" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_encryptpass_by_email_", nil)];
  52. [row.cellConfig setObject:@(NSTextAlignmentCenter) forKey:@"textLabel.textAlignment"];
  53. [row.cellConfig setObject:COLOR_ENCRYPTED forKey:@"textLabel.textColor"];
  54. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  55. [row.cellConfig setObject:[UIImage imageNamed:image_settingsKeyMail] forKey:@"imageView.image"];
  56. row.action.formSelector = @selector(checkEncryptPass:);
  57. [section addFormRow:row];
  58. }
  59. section = [XLFormSectionDescriptor formSection];
  60. [form addFormSection:section];
  61. self.form = form;
  62. }
  63. - (void)viewDidLoad
  64. {
  65. [super viewDidLoad];
  66. // Color
  67. [CCAspect aspectNavigationControllerBar:self.navigationController.navigationBar hidden:NO];
  68. [CCAspect aspectTabBar:self.tabBarController.tabBar hidden:NO];
  69. }
  70. // Apparirà
  71. - (void)viewWillAppear:(BOOL)animated
  72. {
  73. [super viewWillAppear:animated];
  74. // Color
  75. [CCAspect aspectNavigationControllerBar:self.navigationController.navigationBar hidden:NO];
  76. [CCAspect aspectTabBar:self.tabBarController.tabBar hidden:NO];
  77. }
  78. - (void)activateCryptoCloud:(XLFormRowDescriptor *)sender
  79. {
  80. [self deselectFormRow:sender];
  81. }
  82. - (void)checkEncryptPass:(XLFormRowDescriptor *)sender
  83. {
  84. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  85. viewController.delegate = self;
  86. viewController.fromType = CCBKPasscodeFromCheckCryptoKey;
  87. viewController.type = BKPasscodeViewControllerCheckPasscodeType;
  88. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  89. viewController.passcodeInputView.maximumLength = 64;
  90. viewController.title = NSLocalizedString(@"_check_key_aes_256_", nil);
  91. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  92. viewController.navigationItem.leftBarButtonItem.tintColor = COLOR_ENCRYPTED;
  93. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
  94. [self presentViewController:navigationController animated:YES completion:nil];
  95. }
  96. @end