CCSettings.m 41 KB

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