CCSettings.m 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959
  1. //
  2. // CCSettings.m
  3. // Crypto Cloud Technology Nextcloud
  4. //
  5. // Created by Marino Faggiana on 24/11/14.
  6. // Copyright (c) 2014 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 "CCSettings.h"
  24. #import "AppDelegate.h"
  25. #import "CCMain.h"
  26. #define alertViewEsci 1
  27. #define alertViewAzzeraCache 2
  28. @implementation CCSettings
  29. - (id)initWithCoder:(NSCoder *)aDecoder
  30. {
  31. self = [super initWithCoder:aDecoder];
  32. if (self) {
  33. [self initializeForm];
  34. app.activeSettings = self;
  35. }
  36. return self;
  37. }
  38. - (void)initializeForm
  39. {
  40. XLFormDescriptor *form;
  41. XLFormSectionDescriptor *section;
  42. XLFormRowDescriptor *row;
  43. form = [XLFormDescriptor formDescriptorWithTitle:NSLocalizedString(@"_settings_", nil)];
  44. form.rowNavigationOptions = XLFormRowNavigationOptionNone;
  45. // Section : PASSWORD --------------------------------------------------------------
  46. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_passcode_", nil)];
  47. [form addFormSection:section];
  48. // Passcode
  49. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"bloccopasscode" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_lock_not_active_", nil)];
  50. [row.cellConfig setObject:[UIImage imageNamed:image_settingsPasscodeNO] forKey:@"imageView.image"];
  51. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  52. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  53. [row.cellConfig setObject:@(UITableViewCellAccessoryDisclosureIndicator) forKey:@"accessoryType"];
  54. row.action.formSelector = @selector(bloccoPassword);
  55. [section addFormRow:row];
  56. // Passcode simply
  57. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"simplypasscode" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_lock_protection_simply_", nil)];
  58. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  59. [section addFormRow:row];
  60. // Passcode only directory
  61. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"onlylockdir" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_lock_protection_folder_", nil)];
  62. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  63. [section addFormRow:row];
  64. // Section : CLOUD ACCOUNT --------------------------------------------------------------
  65. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_cloud_account_", nil)];
  66. [form addFormSection:section];
  67. // version
  68. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"versionserver" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_version_server_", nil)];
  69. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  70. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  71. [section addFormRow:row];
  72. // Url
  73. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"urlcloud" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_url_", nil)];
  74. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  75. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  76. [section addFormRow:row];
  77. // username
  78. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"usernamecloud" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_username_", nil)];
  79. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  80. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  81. [section addFormRow:row];
  82. // quota
  83. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"quota" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_quota_", nil)];
  84. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  85. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  86. [section addFormRow:row];
  87. // Change Account
  88. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"changecredentials" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_change_credentials_", nil)];
  89. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  90. [row.cellConfig setObject:[UIImage imageNamed:image_settingsCredentials] forKey:@"imageView.image"];
  91. row.action.formSegueIdentifier = @"CCManageAccountSegue";
  92. [section addFormRow:row];
  93. // Section --------------------------------------------------------------
  94. section = [XLFormSectionDescriptor formSection];
  95. [form addFormSection:section];
  96. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"cameraupload" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_uploading_from_camera_", nil)];
  97. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  98. [row.cellConfig setObject:[UIImage imageNamed:image_settingsCameraUpload] forKey:@"imageView.image"];
  99. row.action.formSegueIdentifier = @"CCManageCameraUploadSegue";
  100. [section addFormRow:row];
  101. // Section --------------------------------------------------------------
  102. section = [XLFormSectionDescriptor formSection];
  103. [form addFormSection:section];
  104. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"optimizations" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_optimizations_", nil)];
  105. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  106. [row.cellConfig setObject:[UIImage imageNamed:image_settingsOptimizations] forKey:@"imageView.image"];
  107. row.action.formSegueIdentifier = @"CCManageOptimizationsSegue";
  108. [section addFormRow:row];
  109. // Section --------------------------------------------------------------
  110. section = [XLFormSectionDescriptor formSection];
  111. [form addFormSection:section];
  112. // Crypto Cloud
  113. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"cryptocloud" rowType:XLFormRowDescriptorTypeButton title:@"Crypto Cloud"];
  114. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  115. [row.cellConfig setObject:[UIImage imageNamed:image_settingsCryptoCloud] forKey:@"imageView.image"];
  116. row.action.formSegueIdentifier = @"CCManageCryptoCloudSegue";
  117. [section addFormRow:row];
  118. // Section : INFORMATION --------------------------------------------------------------
  119. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_information_", nil)];
  120. [form addFormSection:section];
  121. section.footerTitle = @"Nextcloud © 2017 T.W.S. Inc.";
  122. // Acknowledgements
  123. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"buttonLeftAligned" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_acknowledgements_", nil)];
  124. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  125. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  126. [row.cellConfig setObject:[UIImage imageNamed:image_settingsAcknowledgements] forKey:@"imageView.image"];
  127. [row.cellConfig setObject:@(UITableViewCellAccessoryDisclosureIndicator) forKey:@"accessoryType"];
  128. row.action.formBlock = ^(XLFormRowDescriptor * sender){
  129. [self performSegueWithIdentifier:@"AcknowledgementsSegue" sender:sender];
  130. [self deselectFormRow:sender];
  131. };
  132. [section addFormRow:row];
  133. // Help
  134. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"help" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_help_", nil)];
  135. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  136. [row.cellConfig setObject:[UIImage imageNamed:image_settingsHelp] forKey:@"imageView.image"];
  137. row.action.formSegueIdentifier = @"CCManageHelpSegue";
  138. [section addFormRow:row];
  139. // Contact us mail
  140. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"sendmail" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_contact_by_email_", nil)];
  141. [row.cellConfig setObject:COLOR_BRAND forKey:@"textLabel.textColor"];
  142. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  143. [row.cellConfig setObject:[UIImage imageNamed:image_settingsMail] forKey:@"imageView.image"];
  144. row.action.formSelector = @selector(sendMail:);
  145. [section addFormRow:row];
  146. // Version
  147. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"versioneapplicazione" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_app_version_", nil)];
  148. row.value = [NSString stringWithFormat:@"%@ (%@)", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
  149. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  150. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  151. [section addFormRow:row];
  152. // Section --------------------------------------------------------------
  153. section = [XLFormSectionDescriptor formSection];
  154. [form addFormSection:section];
  155. // Clear cache
  156. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"azzeracache" rowType:XLFormRowDescriptorTypeButton title:@""];
  157. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  158. [row.cellConfig setObject:[UIImage imageNamed:image_settingsClearCache] forKey:@"imageView.image"];
  159. row.action.formSelector = @selector(azzeraCache:);
  160. [section addFormRow:row];
  161. // Section --------------------------------------------------------------
  162. section = [XLFormSectionDescriptor formSection];
  163. [form addFormSection:section];
  164. // Exit
  165. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"esci" rowType:XLFormRowDescriptorTypeButton title:[CCUtility localizableBrand:@"_exit_" table:nil]];
  166. [row.cellConfig setObject:[UIColor redColor] forKey:@"textLabel.textColor"];
  167. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  168. [row.cellConfig setObject:[UIImage imageNamed:image_settingsExit] forKey:@"imageView.image"];
  169. row.action.formSelector = @selector(esci:);
  170. [section addFormRow:row];
  171. section = [XLFormSectionDescriptor formSection];
  172. [form addFormSection:section];
  173. #ifdef DEBUG
  174. // Section : debug
  175. section = [XLFormSectionDescriptor formSectionWithTitle:@"Debug"];
  176. [form addFormSection:section];
  177. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"adminRemoveVersionIntro" rowType:XLFormRowDescriptorTypeButton title:@"Remove self-Version Intro"];
  178. [row.cellConfig setObject:[UIColor redColor] forKey:@"textLabel.textColor"];
  179. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  180. [row.cellConfig setObject:[UIImage imageNamed:image_settingsAdmin] forKey:@"imageView.image"];
  181. row.action.formSelector = @selector(adminRemoveVersionIntro:);
  182. [section addFormRow:row];
  183. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"adminRemovePasscode" rowType:XLFormRowDescriptorTypeButton title:@"Remove Passcode"];
  184. [row.cellConfig setObject:[UIColor redColor] forKey:@"textLabel.textColor"];
  185. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  186. [row.cellConfig setObject:[UIImage imageNamed:image_settingsAdmin] forKey:@"imageView.image"];
  187. row.action.formSelector = @selector(adminRemovePasscode:);
  188. [section addFormRow:row];
  189. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"adminRemoveVersion" rowType:XLFormRowDescriptorTypeButton title:@"Remove Version"];
  190. [row.cellConfig setObject:[UIColor redColor] forKey:@"textLabel.textColor"];
  191. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  192. [row.cellConfig setObject:[UIImage imageNamed:image_settingsAdmin] forKey:@"imageView.image"];
  193. row.action.formSelector = @selector(adminRemoveVersion:);
  194. [section addFormRow:row];
  195. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"copyGroupLocal" rowType:XLFormRowDescriptorTypeButton title:@"Copy Group to Local"];
  196. [row.cellConfig setObject:[UIColor redColor] forKey:@"textLabel.textColor"];
  197. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  198. [row.cellConfig setObject:[UIImage imageNamed:image_settingsAdmin] forKey:@"imageView.image"];
  199. row.action.formSelector = @selector(copyDirGroupToLocal:);
  200. [section addFormRow:row];
  201. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"quickActionPhotos" rowType:XLFormRowDescriptorTypeButton title:@"Quick Action Photos"];
  202. [row.cellConfig setObject:[UIColor redColor] forKey:@"textLabel.textColor"];
  203. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  204. [row.cellConfig setObject:[UIImage imageNamed:image_settingsAdmin] forKey:@"imageView.image"];
  205. row.action.formSelector = @selector(quickActionPhotos:);
  206. [section addFormRow:row];
  207. #endif
  208. self.form = form;
  209. }
  210. - (void)viewDidLoad
  211. {
  212. [super viewDidLoad];
  213. self.hud = [[CCHud alloc] initWithView:[[[UIApplication sharedApplication] delegate] window]];
  214. self.title = NSLocalizedString(@"_settings_", nil);
  215. // Color
  216. [CCAspect aspectNavigationControllerBar:self.navigationController.navigationBar hidden:NO];
  217. [CCAspect aspectTabBar:self.tabBarController.tabBar hidden:NO];
  218. }
  219. // Apparirà
  220. - (void)viewWillAppear:(BOOL)animated
  221. {
  222. [super viewWillAppear:animated];
  223. // Color
  224. [CCAspect aspectNavigationControllerBar:self.navigationController.navigationBar hidden:NO];
  225. [CCAspect aspectTabBar:self.tabBarController.tabBar hidden:NO];
  226. [self reloadForm];
  227. [self recalculateSize];
  228. }
  229. // E' apparsa
  230. - (void)viewDidAppear:(BOOL)animated
  231. {
  232. [super viewDidAppear:animated];
  233. }
  234. #pragma --------------------------------------------------------------------------------------------
  235. #pragma mark === Admin ===
  236. #pragma --------------------------------------------------------------------------------------------
  237. - (void)adminRemoveVersionIntro:(XLFormRowDescriptor *)sender
  238. {
  239. [self deselectFormRow:sender];
  240. [CCUtility adminRemoveIntro];
  241. exit(0);
  242. }
  243. - (void)adminRemovePasscode:(XLFormRowDescriptor *)sender
  244. {
  245. [self deselectFormRow:sender];
  246. [CCUtility adminRemovePasscode];
  247. app.isCryptoCloudMode = NO;
  248. }
  249. - (void)adminRemoveVersion:(XLFormRowDescriptor *)sender
  250. {
  251. [self deselectFormRow:sender];
  252. [CCUtility adminRemoveVersion];
  253. exit(0);
  254. }
  255. - (void)quickActionPhotos:(XLFormRowDescriptor *)sender
  256. {
  257. NSString *bundleId = [NSBundle mainBundle].bundleIdentifier;
  258. UIApplicationShortcutItem *shortcutPhotos = [[UIApplicationShortcutItem alloc] initWithType:[NSString stringWithFormat:@"%@.photos", bundleId] localizedTitle:@"" localizedSubtitle:nil icon:nil userInfo:nil];
  259. [app handleShortCutItem:shortcutPhotos];
  260. }
  261. #pragma --------------------------------------------------------------------------------------------
  262. #pragma mark === Chiamate dal Form ===
  263. #pragma --------------------------------------------------------------------------------------------
  264. - (void)reloadForm
  265. {
  266. self.form.delegate = nil;
  267. // ----------------------
  268. XLFormRowDescriptor *rowBloccoPasscode = [self.form formRowWithTag:@"bloccopasscode"];
  269. XLFormRowDescriptor *rowSimplyPasscode = [self.form formRowWithTag:@"simplypasscode"];
  270. XLFormRowDescriptor *rowOnlyLockDir = [self.form formRowWithTag:@"onlylockdir"];
  271. XLFormRowDescriptor *rowVersionServer = [self.form formRowWithTag:@"versionserver"];
  272. XLFormRowDescriptor *rowUrlCloud = [self.form formRowWithTag:@"urlcloud"];
  273. XLFormRowDescriptor *rowUserNameCloud = [self.form formRowWithTag:@"usernamecloud"];
  274. XLFormRowDescriptor *rowQuota = [self.form formRowWithTag:@"quota"];
  275. // ------------------------------------------------------------------
  276. if ([[CCUtility getBlockCode] length]) {
  277. rowBloccoPasscode.title = NSLocalizedString(@"_lock_active_", nil);
  278. [rowBloccoPasscode.cellConfig setObject:[UIImage imageNamed:image_settingsPasscodeYES] forKey:@"imageView.image"];
  279. } else {
  280. rowBloccoPasscode.title = NSLocalizedString(@"_lock_not_active_", nil);
  281. [rowBloccoPasscode.cellConfig setObject:[UIImage imageNamed:image_settingsPasscodeNO] forKey:@"imageView.image"];
  282. }
  283. if ([CCUtility getSimplyBlockCode]) [rowSimplyPasscode setValue:@1]; else [rowSimplyPasscode setValue:@0];
  284. if ([CCUtility getOnlyLockDir]) [rowOnlyLockDir setValue:@1]; else [rowOnlyLockDir setValue:@0];
  285. if ([app.typeCloud isEqualToString:typeCloudOwnCloud] || [app.typeCloud isEqualToString:typeCloudNextcloud])
  286. rowVersionServer.value = [CCNetworking sharedNetworking].sharedOCCommunication.getCurrentServerVersion;
  287. rowUrlCloud.value = app.activeUrl;
  288. rowUserNameCloud.value = app.activeUser;
  289. NSString *quota = [CCUtility transformedSize:(app.quotaAvailable + app.quotaUsed)];
  290. NSString *quotaAvailable = [CCUtility transformedSize:(app.quotaAvailable)];
  291. rowQuota.value = [NSString stringWithFormat:@"%@ / %@ %@", quota, quotaAvailable, NSLocalizedString(@"_available_", nil)];
  292. // -----------------------------------------------------------------
  293. [self.tableView reloadData];
  294. self.form.delegate = self;
  295. }
  296. - (void)recalculateSize
  297. {
  298. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  299. self.form.delegate = nil;
  300. XLFormRowDescriptor *rowAzzeraCache = [self.form formRowWithTag:@"azzeracache"];
  301. //NSString *size = [CCUtility transformedSize:[[self getUserDirectorySize] longValue]];
  302. //rowAzzeraCache.title = [NSString stringWithFormat:NSLocalizedString(@"_clear_cache_", nil), size];
  303. rowAzzeraCache.title = NSLocalizedString(@"_clear_cache_no_size_", nil);
  304. [self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
  305. self.form.delegate = self;
  306. });
  307. }
  308. - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
  309. {
  310. [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
  311. if ([rowDescriptor.tag isEqualToString:@"onlylockdir"]) {
  312. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  313. [CCUtility setOnlyLockDir:true];
  314. } else {
  315. [CCUtility setOnlyLockDir:false];
  316. }
  317. }
  318. if ([rowDescriptor.tag isEqualToString:@"simplypasscode"]) {
  319. if ([[CCUtility getBlockCode] length] == 0)
  320. [CCUtility setSimplyBlockCode:[[rowDescriptor.value valueData] boolValue]];
  321. else
  322. [self changeSimplyPassword];
  323. }
  324. }
  325. - (void)checkEncryptPass:(XLFormRowDescriptor *)sender
  326. {
  327. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  328. viewController.delegate = self;
  329. viewController.fromType = CCBKPasscodeFromCheckCryptoKey;
  330. viewController.type = BKPasscodeViewControllerCheckPasscodeType;
  331. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  332. viewController.passcodeInputView.maximumLength = 64;
  333. viewController.title = NSLocalizedString(@"_check_key_aes_256_", nil);
  334. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  335. viewController.navigationItem.leftBarButtonItem.tintColor = COLOR_ENCRYPTED;
  336. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
  337. [self presentViewController:navigationController animated:YES completion:nil];
  338. }
  339. - (void)changeSimplyPassword
  340. {
  341. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  342. viewController.delegate = self;
  343. viewController.type = BKPasscodeViewControllerCheckPasscodeType;
  344. viewController.fromType = CCBKPasscodeFromSimply;
  345. viewController.title = NSLocalizedString(@"_change_simply_passcode_", nil);
  346. viewController.inputViewTitlePassword = YES;
  347. if ([CCUtility getSimplyBlockCode]) {
  348. viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
  349. viewController.passcodeInputView.maximumLength = 6;
  350. } else {
  351. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  352. viewController.passcodeInputView.maximumLength = 64;
  353. }
  354. BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:BKPasscodeKeychainServiceName];
  355. touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
  356. viewController.touchIDManager = touchIDManager;
  357. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  358. viewController.navigationItem.leftBarButtonItem.tintColor = COLOR_ENCRYPTED;
  359. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
  360. [self presentViewController:navigationController animated:YES completion:nil];
  361. }
  362. - (void)bloccoPassword
  363. {
  364. // ATTIVAZIONE LOCK PASSWORD
  365. if ([[CCUtility getBlockCode] length] == 0) {
  366. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  367. viewController.delegate = self;
  368. viewController.type = BKPasscodeViewControllerNewPasscodeType;
  369. viewController.fromType = CCBKPasscodeFromSettingsPasscode;
  370. viewController.inputViewTitlePassword = YES;
  371. if ([CCUtility getSimplyBlockCode]) {
  372. viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
  373. viewController.passcodeInputView.maximumLength = 6;
  374. } else {
  375. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  376. viewController.passcodeInputView.maximumLength = 64;
  377. }
  378. BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:BKPasscodeKeychainServiceName];
  379. touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
  380. viewController.touchIDManager = touchIDManager;
  381. viewController.title = NSLocalizedString(@"_passcode_activate_", nil);
  382. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  383. viewController.navigationItem.leftBarButtonItem.tintColor = COLOR_ENCRYPTED;
  384. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
  385. [self presentViewController:navigationController animated:YES completion:nil];
  386. } else {
  387. // OFF LOCK PASSWORD
  388. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  389. viewController.delegate = self;
  390. viewController.type = BKPasscodeViewControllerCheckPasscodeType;
  391. viewController.fromType = CCBKPasscodeFromSettingsPasscode;
  392. viewController.inputViewTitlePassword = YES;
  393. if ([CCUtility getSimplyBlockCode]) {
  394. viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
  395. viewController.passcodeInputView.maximumLength = 6;
  396. } else {
  397. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  398. viewController.passcodeInputView.maximumLength = 64;
  399. }
  400. BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:BKPasscodeKeychainServiceName];
  401. touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
  402. viewController.touchIDManager = touchIDManager;
  403. viewController.title = NSLocalizedString(@"_disabling_passcode_", nil);
  404. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  405. viewController.navigationItem.leftBarButtonItem.tintColor = COLOR_ENCRYPTED;
  406. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
  407. [self presentViewController:navigationController animated:YES completion:nil];
  408. }
  409. }
  410. - (void)esci:(XLFormRowDescriptor *)sender
  411. {
  412. [self deselectFormRow:sender];
  413. UIAlertView * alertView =[[UIAlertView alloc ] initWithTitle:[CCUtility localizableBrand:@"_exit_" table:nil]
  414. message:[CCUtility localizableBrand:@"_want_exit_" table:nil]
  415. delegate:self
  416. cancelButtonTitle:NSLocalizedString(@"_cancel_", nil)
  417. otherButtonTitles: nil];
  418. alertView.tag = alertViewEsci;
  419. [alertView addButtonWithTitle:NSLocalizedString(@"_proceed_", nil)];
  420. [alertView show];
  421. }
  422. - (void)azzeraCache:(XLFormRowDescriptor *)sender
  423. {
  424. [self deselectFormRow:sender];
  425. UIAlertView * alertView =[[UIAlertView alloc ] initWithTitle:NSLocalizedString(@"_delete_cache_",nil)
  426. message:NSLocalizedString(@"_want_delete_cache_", nil)
  427. delegate:self
  428. cancelButtonTitle:NSLocalizedString(@"_cancel_", nil)
  429. otherButtonTitles: nil];
  430. alertView.tag = alertViewAzzeraCache;
  431. [alertView addButtonWithTitle:NSLocalizedString(@"_proceed_", nil)];
  432. [alertView show];
  433. }
  434. #pragma --------------------------------------------------------------------------------------------
  435. #pragma mark === Mail ===
  436. #pragma --------------------------------------------------------------------------------------------
  437. - (void) mailComposeController:(MFMailComposeViewController *)vc didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
  438. {
  439. switch (result)
  440. {
  441. case MFMailComposeResultCancelled:
  442. [app messageNotification:@"_info_" description:@"_mail_deleted_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess];
  443. break;
  444. case MFMailComposeResultSaved:
  445. [app messageNotification:@"_info_" description:@"_mail_saved_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess];
  446. break;
  447. case MFMailComposeResultSent:
  448. [app messageNotification:@"_info_" description:@"_mail_sent_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess];
  449. break;
  450. case MFMailComposeResultFailed: {
  451. NSString *msg = [NSString stringWithFormat:NSLocalizedString(@"_mail_failure_", nil), [error localizedDescription]];
  452. [app messageNotification:@"_error_" description:msg visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError];
  453. }
  454. break;
  455. default:
  456. break;
  457. }
  458. // Close the Mail Interface
  459. [self dismissViewControllerAnimated:YES completion:NULL];
  460. }
  461. - (void)sendMail:(XLFormRowDescriptor *)sender
  462. {
  463. // Email Subject
  464. NSString *emailTitle = NSLocalizedString(@"_information_req_", nil);
  465. // Email Content
  466. NSString *messageBody;
  467. // Email Recipents
  468. NSArray *toRecipents;
  469. messageBody = [NSString stringWithFormat:@"\n\n\nNextcloud Version %@ (%@)", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
  470. toRecipents = [NSArray arrayWithObject:_mail_me_];
  471. MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
  472. mc.mailComposeDelegate = self;
  473. [mc setSubject:emailTitle];
  474. [mc setMessageBody:messageBody isHTML:NO];
  475. [mc setToRecipients:toRecipents];
  476. // Present mail view controller on screen
  477. [self presentViewController:mc animated:YES completion:NULL];
  478. }
  479. - (void)sendMailEncryptPass
  480. {
  481. [CCUtility sendMailEncryptPass:[CCUtility getEmail] validateEmail:NO form:self];
  482. }
  483. #pragma --------------------------------------------------------------------------------------------
  484. #pragma mark === AlertView ===
  485. #pragma --------------------------------------------------------------------------------------------
  486. - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
  487. {
  488. // Remove ALL
  489. if (buttonIndex == 1 && alertView.tag == alertViewEsci)
  490. {
  491. [self.hud visibleIndeterminateHud];
  492. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.01 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
  493. [app cancelAllOperations];
  494. [[CCNetworking sharedNetworking] settingSessionsDownload:YES upload:YES taskStatus:k_taskStatusCancel activeAccount:app.activeAccount activeUser:app.activeUser activeUrl:app.activeUrl];
  495. [[NSURLCache sharedURLCache] setMemoryCapacity:0];
  496. [[NSURLCache sharedURLCache] setDiskCapacity:0];
  497. [[CCNetworking sharedNetworking] invalidateAndCancelAllSession];
  498. [CCCoreData flushAllDatabase];
  499. [CCUtility deleteAllChainStore];
  500. [self emptyDocumentsDirectory];
  501. [self emptyLibraryDirectory];
  502. [self emptyGroupApplicationSupport];
  503. NSArray* tmpDirectory = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL];
  504. for (NSString *file in tmpDirectory)
  505. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), file] error:NULL];
  506. [self.hud hideHud];
  507. exit(0);
  508. });
  509. }
  510. // Clear Cache
  511. if (buttonIndex == 1 && alertView.tag == alertViewAzzeraCache)
  512. {
  513. [self.hud visibleHudTitle:NSLocalizedString(@"_remove_cache_", nil) mode:MBProgressHUDModeIndeterminate color:nil];
  514. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.01 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
  515. [app cancelAllOperations];
  516. [[CCNetworking sharedNetworking] settingSessionsDownload:YES upload:YES taskStatus:k_taskStatusCancel activeAccount:app.activeAccount activeUser:app.activeUser activeUrl:app.activeUrl];
  517. [[NSURLCache sharedURLCache] setMemoryCapacity:0];
  518. [[NSURLCache sharedURLCache] setDiskCapacity:0];
  519. [CCCoreData flushTableAutomaticUploadAccount:app.activeAccount selector:nil];
  520. [CCCoreData flushTableDirectoryAccount:app.activeAccount];
  521. [CCCoreData flushTableLocalFileAccount:app.activeAccount];
  522. [CCCoreData flushTableMetadataAccount:app.activeAccount];
  523. [self emptyUserDirectoryUser:app.activeUser url:app.activeUrl];
  524. [self emptyLocalDirectory];
  525. NSArray* tmpDirectory = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL];
  526. for (NSString *file in tmpDirectory)
  527. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), file] error:NULL];
  528. [self recalculateSize];
  529. // Inizialized home
  530. [[NSNotificationCenter defaultCenter] postNotificationName:@"initializeMain" object:nil];
  531. [self.hud hideHud];
  532. });
  533. }
  534. }
  535. #pragma --------------------------------------------------------------------------------------------
  536. #pragma mark === BKPasscodeViewController ===
  537. #pragma --------------------------------------------------------------------------------------------
  538. - (void)passcodeViewController:(CCBKPasscode *)aViewController didFinishWithPasscode:(NSString *)aPasscode
  539. {
  540. [aViewController dismissViewControllerAnimated:YES completion:nil];
  541. switch (aViewController.type) {
  542. case BKPasscodeViewControllerNewPasscodeType: {
  543. // enable passcode
  544. [CCUtility setBlockCode:aPasscode];
  545. }
  546. break;
  547. case BKPasscodeViewControllerCheckPasscodeType: {
  548. // disable passcode
  549. if (aViewController.fromType == CCBKPasscodeFromSettingsPasscode) {
  550. [CCUtility setBlockCode:@""];
  551. [CCCoreData setAllDirectoryUnLockForAccount:app.activeAccount];
  552. [app.activeMain.tableView reloadData];
  553. }
  554. // email Key EAS-256
  555. if (aViewController.fromType == CCBKPasscodeFromCheckCryptoKey)
  556. [self sendMailEncryptPass];
  557. // change simply
  558. if (aViewController.fromType == CCBKPasscodeFromSimply) {
  559. // disable passcode
  560. [CCUtility setBlockCode:@""];
  561. [CCCoreData setAllDirectoryUnLockForAccount:app.activeAccount];
  562. [app.activeMain.tableView reloadData];
  563. [CCUtility setSimplyBlockCode:![CCUtility getSimplyBlockCode]];
  564. // Call new passcode
  565. [self bloccoPassword];
  566. }
  567. }
  568. break;
  569. default:
  570. break;
  571. }
  572. [self reloadForm];
  573. }
  574. - (void)passcodeViewController:(CCBKPasscode *)aViewController authenticatePasscode:(NSString *)aPasscode resultHandler:(void (^)(BOOL))aResultHandler
  575. {
  576. if (aViewController.fromType == CCBKPasscodeFromCheckCryptoKey) {
  577. NSString *key = [CCUtility getKeyChainPasscodeForUUID:[CCUtility getUUID]];
  578. if ([aPasscode isEqualToString:key]) {
  579. self.lockUntilDate = nil;
  580. self.failedAttempts = 0;
  581. aResultHandler(YES);
  582. } else aResultHandler(NO);
  583. }
  584. if (aViewController.fromType == CCBKPasscodeFromSettingsPasscode || aViewController.fromType == CCBKPasscodeFromSimply) {
  585. if ([aPasscode isEqualToString:[CCUtility getBlockCode]]) {
  586. self.lockUntilDate = nil;
  587. self.failedAttempts = 0;
  588. aResultHandler(YES);
  589. } else aResultHandler(NO);
  590. }
  591. }
  592. - (void)passcodeViewControllerDidFailAttempt:(CCBKPasscode *)aViewController
  593. {
  594. self.failedAttempts++;
  595. if (self.failedAttempts > 5) {
  596. NSTimeInterval timeInterval = 60;
  597. if (self.failedAttempts > 6) {
  598. NSUInteger multiplier = self.failedAttempts - 6;
  599. timeInterval = (5 * 60) * multiplier;
  600. if (timeInterval > 3600 * 24) {
  601. timeInterval = 3600 * 24;
  602. }
  603. }
  604. self.lockUntilDate = [NSDate dateWithTimeIntervalSinceNow:timeInterval];
  605. }
  606. }
  607. - (NSUInteger)passcodeViewControllerNumberOfFailedAttempts:(CCBKPasscode *)aViewController
  608. {
  609. return self.failedAttempts;
  610. }
  611. - (NSDate *)passcodeViewControllerLockUntilDate:(CCBKPasscode *)aViewController
  612. {
  613. return self.lockUntilDate;
  614. }
  615. - (void)passcodeViewCloseButtonPressed:(id)sender
  616. {
  617. [self dismissViewControllerAnimated:YES completion:nil];
  618. }
  619. #pragma --------------------------------------------------------------------------------------------
  620. #pragma mark == Utility ==
  621. #pragma --------------------------------------------------------------------------------------------
  622. - (void)emptyGroupApplicationSupport
  623. {
  624. NSString *file;
  625. NSURL *dirGroup = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:k_capabilitiesGroups];
  626. NSString *dirIniziale = [[dirGroup URLByAppendingPathComponent:appApplicationSupport] path];
  627. NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
  628. while (file = [enumerator nextObject])
  629. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
  630. }
  631. - (void)emptyLibraryDirectory
  632. {
  633. NSString *file;
  634. NSString *dirIniziale;
  635. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
  636. dirIniziale = [paths objectAtIndex:0];
  637. NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
  638. while (file = [enumerator nextObject])
  639. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
  640. }
  641. - (void)emptyDocumentsDirectory
  642. {
  643. NSString *file;
  644. NSString *dirIniziale;
  645. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  646. dirIniziale = [paths objectAtIndex:0];
  647. NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
  648. while (file = [enumerator nextObject])
  649. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
  650. }
  651. - (void)emptyUserDirectoryUser:(NSString *)user url:(NSString *)url
  652. {
  653. NSString *file;
  654. NSString *dirIniziale;
  655. dirIniziale = [CCUtility getDirectoryActiveUser:user activeUrl:url];
  656. NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
  657. while (file = [enumerator nextObject]) {
  658. NSString *ext = [[file pathExtension] lowercaseString];
  659. // Do not remove ICO
  660. if ([ext isEqualToString:@"ico"])
  661. continue;
  662. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
  663. }
  664. }
  665. - (void)emptyLocalDirectory
  666. {
  667. NSString *file;
  668. NSString *dirIniziale;
  669. dirIniziale = [CCUtility getDirectoryLocal];
  670. NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
  671. while (file = [enumerator nextObject])
  672. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
  673. }
  674. - (NSNumber *)getUserDirectorySize
  675. {
  676. NSString *directoryUser = [CCUtility getDirectoryActiveUser:app.activeUser activeUrl:app.activeUrl];
  677. NSURL *directoryURL = [NSURL fileURLWithPath:directoryUser];
  678. unsigned long long count = 0;
  679. NSNumber *value = nil;
  680. if (! directoryURL) return 0;
  681. // Get dimension Document
  682. for (NSURL *url in [[NSFileManager defaultManager] enumeratorAtURL:directoryURL includingPropertiesForKeys:@[NSURLFileSizeKey] options:0 errorHandler:NULL]) {
  683. if ([url getResourceValue:&value forKey:NSURLFileSizeKey error:nil]) {
  684. count += [value longLongValue];
  685. } else {
  686. return nil;
  687. }
  688. }
  689. return @(count);
  690. }
  691. - (void)copyDirGroupToLocal:(XLFormRowDescriptor *)sender
  692. {
  693. [self deselectFormRow:sender];
  694. NSURL *dirGroup = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:k_capabilitiesGroups];
  695. dirGroup = [dirGroup URLByAppendingPathComponent:@"Library"];
  696. dirGroup = [dirGroup URLByAppendingPathComponent:@"Application Support"];
  697. dirGroup = [dirGroup URLByAppendingPathComponent:@"Crypto Cloud"];
  698. NSArray *paths = [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask];
  699. NSURL *destination = [[paths lastObject] URLByAppendingPathComponent:@"group"];
  700. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  701. dateFormatter.dateFormat = @"hh:mm:ss";
  702. [dateFormatter setTimeZone:[NSTimeZone systemTimeZone]];
  703. NSLog(@"[LOG] Open HUD %@",[dateFormatter stringFromDate:[NSDate date]]);
  704. [self.hud visibleIndeterminateHud];
  705. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.01 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void){
  706. NSLog(@"[LOG] Init copy %@",[dateFormatter stringFromDate:[NSDate date]]);
  707. [[NSFileManager defaultManager] removeItemAtURL:destination error:nil];
  708. NSError *copyError = nil;
  709. if (![[NSFileManager defaultManager] copyItemAtURL:dirGroup toURL:destination error:&copyError]) {
  710. NSLog(@"[LOG] Error copying files: %@", [copyError localizedDescription]);
  711. }
  712. NSLog(@"[LOG] Fine copy %@",[dateFormatter stringFromDate:[NSDate date]]);
  713. [self.hud hideHud];
  714. });
  715. }
  716. @end