CCSettings.m 42 KB

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