CCSettings.m 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957
  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:NSLocalizedString(@"_crypto_cloud_system_", nil)];
  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. rowVersionServer.value = [CCNetworking sharedNetworking].sharedOCCommunication.getCurrentServerVersion;
  286. rowUrlCloud.value = app.activeUrl;
  287. rowUserNameCloud.value = app.activeUser;
  288. NSString *quota = [CCUtility transformedSize:(app.quotaAvailable + app.quotaUsed)];
  289. NSString *quotaAvailable = [CCUtility transformedSize:(app.quotaAvailable)];
  290. rowQuota.value = [NSString stringWithFormat:@"%@ / %@ %@", quota, quotaAvailable, NSLocalizedString(@"_available_", nil)];
  291. // -----------------------------------------------------------------
  292. [self.tableView reloadData];
  293. self.form.delegate = self;
  294. }
  295. - (void)recalculateSize
  296. {
  297. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  298. self.form.delegate = nil;
  299. XLFormRowDescriptor *rowAzzeraCache = [self.form formRowWithTag:@"azzeracache"];
  300. //NSString *size = [CCUtility transformedSize:[[self getUserDirectorySize] longValue]];
  301. //rowAzzeraCache.title = [NSString stringWithFormat:NSLocalizedString(@"_clear_cache_", nil), size];
  302. rowAzzeraCache.title = NSLocalizedString(@"_clear_cache_no_size_", nil);
  303. [self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
  304. self.form.delegate = self;
  305. });
  306. }
  307. - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
  308. {
  309. [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
  310. if ([rowDescriptor.tag isEqualToString:@"onlylockdir"]) {
  311. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  312. [CCUtility setOnlyLockDir:true];
  313. } else {
  314. [CCUtility setOnlyLockDir:false];
  315. }
  316. }
  317. if ([rowDescriptor.tag isEqualToString:@"simplypasscode"]) {
  318. if ([[CCUtility getBlockCode] length] == 0)
  319. [CCUtility setSimplyBlockCode:[[rowDescriptor.value valueData] boolValue]];
  320. else
  321. [self changeSimplyPassword];
  322. }
  323. }
  324. - (void)checkEncryptPass:(XLFormRowDescriptor *)sender
  325. {
  326. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  327. viewController.delegate = self;
  328. viewController.fromType = CCBKPasscodeFromCheckCryptoKey;
  329. viewController.type = BKPasscodeViewControllerCheckPasscodeType;
  330. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  331. viewController.passcodeInputView.maximumLength = 64;
  332. viewController.title = NSLocalizedString(@"_check_key_aes_256_", nil);
  333. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  334. viewController.navigationItem.leftBarButtonItem.tintColor = COLOR_ENCRYPTED;
  335. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
  336. [self presentViewController:navigationController animated:YES completion:nil];
  337. }
  338. - (void)changeSimplyPassword
  339. {
  340. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  341. viewController.delegate = self;
  342. viewController.type = BKPasscodeViewControllerCheckPasscodeType;
  343. viewController.fromType = CCBKPasscodeFromSimply;
  344. viewController.title = NSLocalizedString(@"_change_simply_passcode_", nil);
  345. viewController.inputViewTitlePassword = YES;
  346. if ([CCUtility getSimplyBlockCode]) {
  347. viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
  348. viewController.passcodeInputView.maximumLength = 6;
  349. } else {
  350. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  351. viewController.passcodeInputView.maximumLength = 64;
  352. }
  353. BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:BKPasscodeKeychainServiceName];
  354. touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
  355. viewController.touchIDManager = touchIDManager;
  356. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  357. viewController.navigationItem.leftBarButtonItem.tintColor = COLOR_ENCRYPTED;
  358. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
  359. [self presentViewController:navigationController animated:YES completion:nil];
  360. }
  361. - (void)bloccoPassword
  362. {
  363. // ATTIVAZIONE LOCK PASSWORD
  364. if ([[CCUtility getBlockCode] length] == 0) {
  365. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  366. viewController.delegate = self;
  367. viewController.type = BKPasscodeViewControllerNewPasscodeType;
  368. viewController.fromType = CCBKPasscodeFromSettingsPasscode;
  369. viewController.inputViewTitlePassword = YES;
  370. if ([CCUtility getSimplyBlockCode]) {
  371. viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
  372. viewController.passcodeInputView.maximumLength = 6;
  373. } else {
  374. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  375. viewController.passcodeInputView.maximumLength = 64;
  376. }
  377. BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:BKPasscodeKeychainServiceName];
  378. touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
  379. viewController.touchIDManager = touchIDManager;
  380. viewController.title = NSLocalizedString(@"_passcode_activate_", nil);
  381. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  382. viewController.navigationItem.leftBarButtonItem.tintColor = COLOR_ENCRYPTED;
  383. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
  384. [self presentViewController:navigationController animated:YES completion:nil];
  385. } else {
  386. // OFF LOCK PASSWORD
  387. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  388. viewController.delegate = self;
  389. viewController.type = BKPasscodeViewControllerCheckPasscodeType;
  390. viewController.fromType = CCBKPasscodeFromSettingsPasscode;
  391. viewController.inputViewTitlePassword = YES;
  392. if ([CCUtility getSimplyBlockCode]) {
  393. viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
  394. viewController.passcodeInputView.maximumLength = 6;
  395. } else {
  396. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  397. viewController.passcodeInputView.maximumLength = 64;
  398. }
  399. BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:BKPasscodeKeychainServiceName];
  400. touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
  401. viewController.touchIDManager = touchIDManager;
  402. viewController.title = NSLocalizedString(@"_disabling_passcode_", nil);
  403. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  404. viewController.navigationItem.leftBarButtonItem.tintColor = COLOR_ENCRYPTED;
  405. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
  406. [self presentViewController:navigationController animated:YES completion:nil];
  407. }
  408. }
  409. - (void)esci:(XLFormRowDescriptor *)sender
  410. {
  411. [self deselectFormRow:sender];
  412. UIAlertView * alertView =[[UIAlertView alloc ] initWithTitle:[CCUtility localizableBrand:@"_exit_" table:nil]
  413. message:[CCUtility localizableBrand:@"_want_exit_" table:nil]
  414. delegate:self
  415. cancelButtonTitle:NSLocalizedString(@"_cancel_", nil)
  416. otherButtonTitles: nil];
  417. alertView.tag = alertViewEsci;
  418. [alertView addButtonWithTitle:NSLocalizedString(@"_proceed_", nil)];
  419. [alertView show];
  420. }
  421. - (void)azzeraCache:(XLFormRowDescriptor *)sender
  422. {
  423. [self deselectFormRow:sender];
  424. UIAlertView * alertView =[[UIAlertView alloc ] initWithTitle:NSLocalizedString(@"_delete_cache_",nil)
  425. message:NSLocalizedString(@"_want_delete_cache_", nil)
  426. delegate:self
  427. cancelButtonTitle:NSLocalizedString(@"_cancel_", nil)
  428. otherButtonTitles: nil];
  429. alertView.tag = alertViewAzzeraCache;
  430. [alertView addButtonWithTitle:NSLocalizedString(@"_proceed_", nil)];
  431. [alertView show];
  432. }
  433. #pragma --------------------------------------------------------------------------------------------
  434. #pragma mark === Mail ===
  435. #pragma --------------------------------------------------------------------------------------------
  436. - (void) mailComposeController:(MFMailComposeViewController *)vc didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
  437. {
  438. switch (result)
  439. {
  440. case MFMailComposeResultCancelled:
  441. [app messageNotification:@"_info_" description:@"_mail_deleted_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess];
  442. break;
  443. case MFMailComposeResultSaved:
  444. [app messageNotification:@"_info_" description:@"_mail_saved_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess];
  445. break;
  446. case MFMailComposeResultSent:
  447. [app messageNotification:@"_info_" description:@"_mail_sent_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess];
  448. break;
  449. case MFMailComposeResultFailed: {
  450. NSString *msg = [NSString stringWithFormat:NSLocalizedString(@"_mail_failure_", nil), [error localizedDescription]];
  451. [app messageNotification:@"_error_" description:msg visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError];
  452. }
  453. break;
  454. default:
  455. break;
  456. }
  457. // Close the Mail Interface
  458. [self dismissViewControllerAnimated:YES completion:NULL];
  459. }
  460. - (void)sendMail:(XLFormRowDescriptor *)sender
  461. {
  462. // Email Subject
  463. NSString *emailTitle = NSLocalizedString(@"_information_req_", nil);
  464. // Email Content
  465. NSString *messageBody;
  466. // Email Recipents
  467. NSArray *toRecipents;
  468. messageBody = [NSString stringWithFormat:@"\n\n\nNextcloud Version %@ (%@)", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
  469. toRecipents = [NSArray arrayWithObject:_mail_me_];
  470. MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
  471. mc.mailComposeDelegate = self;
  472. [mc setSubject:emailTitle];
  473. [mc setMessageBody:messageBody isHTML:NO];
  474. [mc setToRecipients:toRecipents];
  475. // Present mail view controller on screen
  476. [self presentViewController:mc animated:YES completion:NULL];
  477. }
  478. - (void)sendMailEncryptPass
  479. {
  480. [CCUtility sendMailEncryptPass:[CCUtility getEmail] validateEmail:NO form:self];
  481. }
  482. #pragma --------------------------------------------------------------------------------------------
  483. #pragma mark === AlertView ===
  484. #pragma --------------------------------------------------------------------------------------------
  485. - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
  486. {
  487. // Remove ALL
  488. if (buttonIndex == 1 && alertView.tag == alertViewEsci)
  489. {
  490. [self.hud visibleIndeterminateHud];
  491. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.01 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
  492. [app cancelAllOperations];
  493. [[CCNetworking sharedNetworking] settingSessionsDownload:YES upload:YES taskStatus:k_taskStatusCancel activeAccount:app.activeAccount activeUser:app.activeUser activeUrl:app.activeUrl];
  494. [[NSURLCache sharedURLCache] setMemoryCapacity:0];
  495. [[NSURLCache sharedURLCache] setDiskCapacity:0];
  496. [[CCNetworking sharedNetworking] invalidateAndCancelAllSession];
  497. [CCCoreData flushAllDatabase];
  498. [CCUtility deleteAllChainStore];
  499. [self emptyDocumentsDirectory];
  500. [self emptyLibraryDirectory];
  501. [self emptyGroupApplicationSupport];
  502. NSArray* tmpDirectory = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL];
  503. for (NSString *file in tmpDirectory)
  504. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), file] error:NULL];
  505. [self.hud hideHud];
  506. exit(0);
  507. });
  508. }
  509. // Clear Cache
  510. if (buttonIndex == 1 && alertView.tag == alertViewAzzeraCache)
  511. {
  512. [self.hud visibleHudTitle:NSLocalizedString(@"_remove_cache_", nil) mode:MBProgressHUDModeIndeterminate color:nil];
  513. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.01 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
  514. [app cancelAllOperations];
  515. [[CCNetworking sharedNetworking] settingSessionsDownload:YES upload:YES taskStatus:k_taskStatusCancel activeAccount:app.activeAccount activeUser:app.activeUser activeUrl:app.activeUrl];
  516. [[NSURLCache sharedURLCache] setMemoryCapacity:0];
  517. [[NSURLCache sharedURLCache] setDiskCapacity:0];
  518. [CCCoreData flushTableAutomaticUploadAccount:app.activeAccount selector:nil];
  519. [CCCoreData flushTableDirectoryAccount:app.activeAccount];
  520. [CCCoreData flushTableLocalFileAccount:app.activeAccount];
  521. [CCCoreData flushTableMetadataAccount:app.activeAccount];
  522. [self emptyUserDirectoryUser:app.activeUser url:app.activeUrl];
  523. [self emptyLocalDirectory];
  524. NSArray* tmpDirectory = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL];
  525. for (NSString *file in tmpDirectory)
  526. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), file] error:NULL];
  527. [self recalculateSize];
  528. // Inizialized home
  529. [[NSNotificationCenter defaultCenter] postNotificationName:@"initializeMain" object:nil];
  530. [self.hud hideHud];
  531. });
  532. }
  533. }
  534. #pragma --------------------------------------------------------------------------------------------
  535. #pragma mark === BKPasscodeViewController ===
  536. #pragma --------------------------------------------------------------------------------------------
  537. - (void)passcodeViewController:(CCBKPasscode *)aViewController didFinishWithPasscode:(NSString *)aPasscode
  538. {
  539. [aViewController dismissViewControllerAnimated:YES completion:nil];
  540. switch (aViewController.type) {
  541. case BKPasscodeViewControllerNewPasscodeType: {
  542. // enable passcode
  543. [CCUtility setBlockCode:aPasscode];
  544. }
  545. break;
  546. case BKPasscodeViewControllerCheckPasscodeType: {
  547. // disable passcode
  548. if (aViewController.fromType == CCBKPasscodeFromSettingsPasscode) {
  549. [CCUtility setBlockCode:@""];
  550. [CCCoreData setAllDirectoryUnLockForAccount:app.activeAccount];
  551. [app.activeMain.tableView reloadData];
  552. }
  553. // email Key EAS-256
  554. if (aViewController.fromType == CCBKPasscodeFromCheckCryptoKey)
  555. [self sendMailEncryptPass];
  556. // change simply
  557. if (aViewController.fromType == CCBKPasscodeFromSimply) {
  558. // disable passcode
  559. [CCUtility setBlockCode:@""];
  560. [CCCoreData setAllDirectoryUnLockForAccount:app.activeAccount];
  561. [app.activeMain.tableView reloadData];
  562. [CCUtility setSimplyBlockCode:![CCUtility getSimplyBlockCode]];
  563. // Call new passcode
  564. [self bloccoPassword];
  565. }
  566. }
  567. break;
  568. default:
  569. break;
  570. }
  571. [self reloadForm];
  572. }
  573. - (void)passcodeViewController:(CCBKPasscode *)aViewController authenticatePasscode:(NSString *)aPasscode resultHandler:(void (^)(BOOL))aResultHandler
  574. {
  575. if (aViewController.fromType == CCBKPasscodeFromCheckCryptoKey) {
  576. NSString *key = [CCUtility getKeyChainPasscodeForUUID:[CCUtility getUUID]];
  577. if ([aPasscode isEqualToString:key]) {
  578. self.lockUntilDate = nil;
  579. self.failedAttempts = 0;
  580. aResultHandler(YES);
  581. } else aResultHandler(NO);
  582. }
  583. if (aViewController.fromType == CCBKPasscodeFromSettingsPasscode || aViewController.fromType == CCBKPasscodeFromSimply) {
  584. if ([aPasscode isEqualToString:[CCUtility getBlockCode]]) {
  585. self.lockUntilDate = nil;
  586. self.failedAttempts = 0;
  587. aResultHandler(YES);
  588. } else aResultHandler(NO);
  589. }
  590. }
  591. - (void)passcodeViewControllerDidFailAttempt:(CCBKPasscode *)aViewController
  592. {
  593. self.failedAttempts++;
  594. if (self.failedAttempts > 5) {
  595. NSTimeInterval timeInterval = 60;
  596. if (self.failedAttempts > 6) {
  597. NSUInteger multiplier = self.failedAttempts - 6;
  598. timeInterval = (5 * 60) * multiplier;
  599. if (timeInterval > 3600 * 24) {
  600. timeInterval = 3600 * 24;
  601. }
  602. }
  603. self.lockUntilDate = [NSDate dateWithTimeIntervalSinceNow:timeInterval];
  604. }
  605. }
  606. - (NSUInteger)passcodeViewControllerNumberOfFailedAttempts:(CCBKPasscode *)aViewController
  607. {
  608. return self.failedAttempts;
  609. }
  610. - (NSDate *)passcodeViewControllerLockUntilDate:(CCBKPasscode *)aViewController
  611. {
  612. return self.lockUntilDate;
  613. }
  614. - (void)passcodeViewCloseButtonPressed:(id)sender
  615. {
  616. [self dismissViewControllerAnimated:YES completion:nil];
  617. }
  618. #pragma --------------------------------------------------------------------------------------------
  619. #pragma mark == Utility ==
  620. #pragma --------------------------------------------------------------------------------------------
  621. - (void)emptyGroupApplicationSupport
  622. {
  623. NSString *file;
  624. NSURL *dirGroup = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:k_capabilitiesGroups];
  625. NSString *dirIniziale = [[dirGroup URLByAppendingPathComponent:appApplicationSupport] path];
  626. NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
  627. while (file = [enumerator nextObject])
  628. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
  629. }
  630. - (void)emptyLibraryDirectory
  631. {
  632. NSString *file;
  633. NSString *dirIniziale;
  634. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
  635. dirIniziale = [paths objectAtIndex:0];
  636. NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
  637. while (file = [enumerator nextObject])
  638. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
  639. }
  640. - (void)emptyDocumentsDirectory
  641. {
  642. NSString *file;
  643. NSString *dirIniziale;
  644. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  645. dirIniziale = [paths objectAtIndex:0];
  646. NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
  647. while (file = [enumerator nextObject])
  648. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
  649. }
  650. - (void)emptyUserDirectoryUser:(NSString *)user url:(NSString *)url
  651. {
  652. NSString *file;
  653. NSString *dirIniziale;
  654. dirIniziale = [CCUtility getDirectoryActiveUser:user activeUrl:url];
  655. NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
  656. while (file = [enumerator nextObject]) {
  657. NSString *ext = [[file pathExtension] lowercaseString];
  658. // Do not remove ICO
  659. if ([ext isEqualToString:@"ico"])
  660. continue;
  661. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
  662. }
  663. }
  664. - (void)emptyLocalDirectory
  665. {
  666. NSString *file;
  667. NSString *dirIniziale;
  668. dirIniziale = [CCUtility getDirectoryLocal];
  669. NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
  670. while (file = [enumerator nextObject])
  671. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
  672. }
  673. - (NSNumber *)getUserDirectorySize
  674. {
  675. NSString *directoryUser = [CCUtility getDirectoryActiveUser:app.activeUser activeUrl:app.activeUrl];
  676. NSURL *directoryURL = [NSURL fileURLWithPath:directoryUser];
  677. unsigned long long count = 0;
  678. NSNumber *value = nil;
  679. if (! directoryURL) return 0;
  680. // Get dimension Document
  681. for (NSURL *url in [[NSFileManager defaultManager] enumeratorAtURL:directoryURL includingPropertiesForKeys:@[NSURLFileSizeKey] options:0 errorHandler:NULL]) {
  682. if ([url getResourceValue:&value forKey:NSURLFileSizeKey error:nil]) {
  683. count += [value longLongValue];
  684. } else {
  685. return nil;
  686. }
  687. }
  688. return @(count);
  689. }
  690. - (void)copyDirGroupToLocal:(XLFormRowDescriptor *)sender
  691. {
  692. [self deselectFormRow:sender];
  693. NSURL *dirGroup = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:k_capabilitiesGroups];
  694. dirGroup = [dirGroup URLByAppendingPathComponent:@"Library"];
  695. dirGroup = [dirGroup URLByAppendingPathComponent:@"Application Support"];
  696. dirGroup = [dirGroup URLByAppendingPathComponent:@"Crypto Cloud"];
  697. NSArray *paths = [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask];
  698. NSURL *destination = [[paths lastObject] URLByAppendingPathComponent:@"group"];
  699. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  700. dateFormatter.dateFormat = @"hh:mm:ss";
  701. [dateFormatter setTimeZone:[NSTimeZone systemTimeZone]];
  702. NSLog(@"[LOG] Open HUD %@",[dateFormatter stringFromDate:[NSDate date]]);
  703. [self.hud visibleIndeterminateHud];
  704. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.01 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void){
  705. NSLog(@"[LOG] Init copy %@",[dateFormatter stringFromDate:[NSDate date]]);
  706. [[NSFileManager defaultManager] removeItemAtURL:destination error:nil];
  707. NSError *copyError = nil;
  708. if (![[NSFileManager defaultManager] copyItemAtURL:dirGroup toURL:destination error:&copyError]) {
  709. NSLog(@"[LOG] Error copying files: %@", [copyError localizedDescription]);
  710. }
  711. NSLog(@"[LOG] Fine copy %@",[dateFormatter stringFromDate:[NSDate date]]);
  712. [self.hud hideHud];
  713. });
  714. }
  715. @end