CCAdvanced.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. //
  2. // CCManageHelp.m
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 06/11/15.
  6. // Copyright (c) 2015 Marino Faggiana. All rights reserved.
  7. //
  8. // Author Marino Faggiana <marino.faggiana@nextcloud.com>
  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 "CCAdvanced.h"
  24. #import "CCUtility.h"
  25. #import "NSNotificationCenter+MainThread.h"
  26. #import <KTVHTTPCache/KTVHTTPCache.h>
  27. #import "NCBridgeSwift.h"
  28. @interface CCAdvanced ()
  29. {
  30. AppDelegate *appDelegate;
  31. CCHud *_hud;
  32. }
  33. @end
  34. @implementation CCAdvanced
  35. - (void)initializeForm
  36. {
  37. XLFormDescriptor *form = [XLFormDescriptor formDescriptor];
  38. XLFormSectionDescriptor *section;
  39. XLFormRowDescriptor *row;
  40. // Section HIDDEN FILES -------------------------------------------------
  41. section = [XLFormSectionDescriptor formSection];
  42. [form addFormSection:section];
  43. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"showHiddenFiles" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_show_hidden_files_", nil)];
  44. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.backgroundCell;
  45. if ([CCUtility getShowHiddenFiles]) row.value = @"1";
  46. else row.value = @"0";
  47. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  48. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  49. [section addFormRow:row];
  50. // Format Compatibility + Live Photo
  51. section = [XLFormSectionDescriptor formSection];
  52. [form addFormSection:section];
  53. section.footerTitle = [NSString stringWithFormat:@"%@\n%@", NSLocalizedString(@"_format_compatibility_footer_", nil), NSLocalizedString(@"_upload_mov_livephoto_footer_", nil)];
  54. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"formatCompatibility" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_format_compatibility_", nil)];
  55. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.backgroundCell;
  56. if ([CCUtility getFormatCompatibility]) row.value = @"1";
  57. else row.value = @"0";
  58. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  59. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  60. [section addFormRow:row];
  61. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"livePhoto" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_upload_mov_livephoto_", nil)];
  62. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.backgroundCell;
  63. if ([CCUtility getLivePhoto]) row.value = @"1";
  64. else row.value = @"0";
  65. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  66. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  67. [section addFormRow:row];
  68. // Disable Local Cache After Upload
  69. section = [XLFormSectionDescriptor formSection];
  70. [form addFormSection:section];
  71. section.footerTitle = NSLocalizedString(@"_disableLocalCacheAfterUpload_footer_", nil);
  72. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"disableLocalCacheAfterUpload" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_disableLocalCacheAfterUpload_", nil)];
  73. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.backgroundCell;
  74. if ([CCUtility getDisableLocalCacheAfterUpload]) row.value = @"1";
  75. else row.value = @"0";
  76. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  77. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  78. [section addFormRow:row];
  79. // Automatic download image
  80. section = [XLFormSectionDescriptor formSection];
  81. [form addFormSection:section];
  82. section.footerTitle = NSLocalizedString(@"_automatic_Download_Image_footer_", nil);
  83. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"automaticDownloadImage" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_automatic_Download_Image_", nil)];
  84. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.backgroundCell;
  85. if ([CCUtility getAutomaticDownloadImage]) row.value = @"1";
  86. else row.value = @"0";
  87. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  88. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  89. [section addFormRow:row];
  90. // Section : Files App --------------------------------------------------------------
  91. if (![NCBrandOptions shared].disable_openin_file) {
  92. section = [XLFormSectionDescriptor formSection];
  93. [form addFormSection:section];
  94. section.footerTitle = NSLocalizedString(@"_disable_files_app_footer_", nil);
  95. // Disable Files App
  96. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"disablefilesapp" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_disable_files_app_", nil)];
  97. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.backgroundCell;
  98. if ([CCUtility getDisableFilesApp]) row.value = @"1";
  99. else row.value = @"0";
  100. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  101. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  102. [section addFormRow:row];
  103. }
  104. // Section : Privacy --------------------------------------------------------------
  105. if (!NCBrandOptions.shared.disable_crash_service) {
  106. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_privacy_", nil)];
  107. [form addFormSection:section];
  108. section.footerTitle = NSLocalizedString(@"_privacy_footer_", nil);
  109. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"crashservice" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_crashservice_title_", nil)];
  110. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.backgroundCell;
  111. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  112. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  113. [row.cellConfig setObject:[[UIImage imageNamed:@"crashservice"] imageWithColor:NCBrandColor.shared.icon size:25] forKey:@"imageView.image"];
  114. if ([CCUtility getDisableCrashservice]) row.value = @"1";
  115. else row.value = @"0";
  116. [section addFormRow:row];
  117. }
  118. // Section DIAGNOSTICS -------------------------------------------------
  119. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_diagnostics_", nil)];
  120. [form addFormSection:section];
  121. if ([[NSFileManager defaultManager] fileExistsAtPath:NCCommunicationCommon.shared.filenamePathLog]) {
  122. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"log" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_view_log_", nil)];
  123. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.backgroundCell;
  124. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  125. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  126. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  127. [row.cellConfig setObject:[[UIImage imageNamed:@"log"] imageWithColor:NCBrandColor.shared.icon size:25] forKey:@"imageView.image"];
  128. row.action.formBlock = ^(XLFormRowDescriptor * sender) {
  129. [self deselectFormRow:sender];
  130. NCViewerQuickLook *viewerQuickLook = [NCViewerQuickLook new];
  131. [viewerQuickLook quickLookWithUrl:[NSURL fileURLWithPath:NCCommunicationCommon.shared.filenamePathLog]];
  132. };
  133. [section addFormRow:row];
  134. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"clearlog" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_clear_log_", nil)];
  135. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.backgroundCell;
  136. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  137. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  138. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  139. [row.cellConfig setObject:[[UIImage imageNamed:@"clear"] imageWithColor:NCBrandColor.shared.icon size:25] forKey:@"imageView.image"];
  140. row.action.formBlock = ^(XLFormRowDescriptor * sender) {
  141. [self deselectFormRow:sender];
  142. [[NCCommunicationCommon shared] clearFileLog];
  143. NSInteger logLevel = [CCUtility getLogLevel];
  144. BOOL isSimulatorOrTestFlight = [[NCUtility shared] isSimulatorOrTestFlight];
  145. NSString *versionNextcloudiOS = [NSString stringWithFormat:[NCBrandOptions shared].textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp];
  146. if (isSimulatorOrTestFlight) {
  147. [[NCCommunicationCommon shared] writeLog:[NSString stringWithFormat:@"Clear log with level %lu %@ (Simulator / TestFlight)", (unsigned long)logLevel, versionNextcloudiOS]];
  148. } else {
  149. [[NCCommunicationCommon shared] writeLog:[NSString stringWithFormat:@"Clear log with level %lu %@", (unsigned long)logLevel, versionNextcloudiOS]];
  150. }
  151. };
  152. [section addFormRow:row];
  153. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"logLevel" rowType:XLFormRowDescriptorTypeSlider title:NSLocalizedString(@"_level_log_", nil)];
  154. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.backgroundCell;
  155. [row.cellConfig setObject:@(NSTextAlignmentCenter) forKey:@"textLabel.textAlignment"];
  156. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  157. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  158. NSInteger logLevel = [CCUtility getLogLevel];
  159. row.value = @(logLevel);
  160. [row.cellConfigAtConfigure setObject:@(2) forKey:@"slider.maximumValue"];
  161. [row.cellConfigAtConfigure setObject:@(0) forKey:@"slider.minimumValue"];
  162. [row.cellConfigAtConfigure setObject:@(2) forKey:@"steps"];
  163. [section addFormRow:row];
  164. }
  165. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"capabilities" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_capabilities_", nil)];
  166. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.backgroundCell;
  167. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  168. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  169. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  170. [row.cellConfig setObject:[[UIImage imageNamed:@"capabilities"] imageWithColor:NCBrandColor.shared.icon size:25] forKey:@"imageView.image"];
  171. row.action.formBlock = ^(XLFormRowDescriptor * sender) {
  172. [self deselectFormRow:sender];
  173. NCCapabilitiesViewController *capabilities = [[UIStoryboard storyboardWithName:@"NCCapabilitiesViewController" bundle:nil] instantiateInitialViewController];
  174. [self presentViewController:capabilities animated:YES completion:nil];
  175. };
  176. [section addFormRow:row];
  177. // Section CLEAR CACHE -------------------------------------------------
  178. section = [XLFormSectionDescriptor formSection];
  179. [form addFormSection:section];
  180. section.footerTitle = NSLocalizedString(@"_clear_cache_footer_", nil);
  181. // Clear cache
  182. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"azzeracache" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_clear_cache_", nil)];
  183. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.backgroundCell;
  184. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  185. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  186. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  187. [row.cellConfig setObject:[[UIImage imageNamed:@"trash"] imageWithColor:NCBrandColor.shared.icon size:25] forKey:@"imageView.image"];
  188. row.action.formSelector = @selector(clearCacheRequest:);
  189. [section addFormRow:row];
  190. // Section EXIT --------------------------------------------------------
  191. section = [XLFormSectionDescriptor formSection];
  192. [form addFormSection:section];
  193. section.footerTitle = NSLocalizedString(@"_exit_footer_", nil);
  194. // Exit
  195. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"esci" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_exit_", nil)];
  196. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.backgroundCell;
  197. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  198. [row.cellConfig setObject:[UIColor redColor] forKey:@"textLabel.textColor"];
  199. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  200. [row.cellConfig setObject:[[UIImage imageNamed:@"exit"] imageWithColor:[UIColor redColor] size:25] forKey:@"imageView.image"];
  201. row.action.formSelector = @selector(exitNextcloud:);
  202. [section addFormRow:row];
  203. self.tableView.showsVerticalScrollIndicator = NO;
  204. self.form = form;
  205. }
  206. - (void)viewDidLoad
  207. {
  208. [super viewDidLoad];
  209. self.title = NSLocalizedString(@"_advanced_", nil);
  210. appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  211. _hud = [[CCHud alloc] initWithView:[[[UIApplication sharedApplication] delegate] window]];
  212. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:NCGlobal.shared.notificationCenterChangeTheming object:nil];
  213. [self changeTheming];
  214. }
  215. - (void)changeTheming
  216. {
  217. self.view.backgroundColor = NCBrandColor.shared.backgroundForm;
  218. self.tableView.backgroundColor = NCBrandColor.shared.backgroundForm;
  219. [self.tableView reloadData];
  220. [self initializeForm];
  221. }
  222. - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
  223. {
  224. [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
  225. if ([rowDescriptor.tag isEqualToString:@"showHiddenFiles"]) {
  226. [CCUtility setShowHiddenFiles:[[rowDescriptor.value valueData] boolValue]];
  227. }
  228. if ([rowDescriptor.tag isEqualToString:@"formatCompatibility"]) {
  229. [CCUtility setFormatCompatibility:[[rowDescriptor.value valueData] boolValue]];
  230. }
  231. if ([rowDescriptor.tag isEqualToString:@"livePhoto"]) {
  232. [CCUtility setLivePhoto:[[rowDescriptor.value valueData] boolValue]];
  233. }
  234. if ([rowDescriptor.tag isEqualToString:@"disableLocalCacheAfterUpload"]) {
  235. [CCUtility setDisableLocalCacheAfterUpload:[[rowDescriptor.value valueData] boolValue]];
  236. }
  237. if ([rowDescriptor.tag isEqualToString:@"automaticDownloadImage"]) {
  238. [CCUtility setAutomaticDownloadImage:[[rowDescriptor.value valueData] boolValue]];
  239. }
  240. if ([rowDescriptor.tag isEqualToString:@"disablefilesapp"]) {
  241. [CCUtility setDisableFilesApp:[[rowDescriptor.value valueData] boolValue]];
  242. }
  243. if ([rowDescriptor.tag isEqualToString:@"crashservice"]) {
  244. [CCUtility setDisableCrashservice:[[rowDescriptor.value valueData] boolValue]];
  245. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_crashservice_title_", nil) message:NSLocalizedString(@"_crashservice_alert_", nil) preferredStyle:UIAlertControllerStyleAlert];
  246. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  247. exit(0);
  248. }];
  249. [alertController addAction:okAction];
  250. [self presentViewController:alertController animated:YES completion:nil];
  251. }
  252. if ([rowDescriptor.tag isEqualToString:@"logLevel"]) {
  253. NSInteger levelLog = [[rowDescriptor.value valueData] intValue];
  254. [CCUtility setLogLevel:levelLog];
  255. [[NCCommunicationCommon shared] setLevelLog:levelLog];
  256. }
  257. }
  258. #pragma --------------------------------------------------------------------------------------------
  259. #pragma mark === Clear Cache ===
  260. #pragma --------------------------------------------------------------------------------------------
  261. - (void)clearCache
  262. {
  263. [[NCNetworking shared] cancelAllTransferWithAccount:appDelegate.account completion:^{ }];
  264. [[NCOperationQueue shared] cancelAllQueue];
  265. [[NSURLCache sharedURLCache] setMemoryCapacity:0];
  266. [[NSURLCache sharedURLCache] setDiskCapacity:0];
  267. [KTVHTTPCache cacheDeleteAllCaches];
  268. [[NCManageDatabase shared] clearDatabaseWithAccount:appDelegate.account removeAccount:false];
  269. [CCUtility removeGroupDirectoryProviderStorage];
  270. [CCUtility removeGroupLibraryDirectory];
  271. [CCUtility removeDocumentsDirectory];
  272. [CCUtility removeTemporaryDirectory];
  273. [CCUtility createDirectoryStandard];
  274. [[NCAutoUpload shared] alignPhotoLibraryWithViewController:self];
  275. // Inizialized home
  276. [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:NCGlobal.shared.notificationCenterInitializeMain object:nil userInfo:nil];
  277. // Clear Media
  278. [appDelegate.activeMedia reloadDataSource];
  279. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
  280. [_hud hideHud];
  281. });
  282. }
  283. - (void)clearCacheRequest:(XLFormRowDescriptor *)sender
  284. {
  285. [self deselectFormRow:sender];
  286. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"_want_delete_cache_", nil) preferredStyle:UIAlertControllerStyleActionSheet];
  287. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_yes_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  288. [_hud visibleHudTitle:NSLocalizedString(@"_wait_", nil) mode:MBProgressHUDModeIndeterminate color:nil];
  289. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
  290. [self clearCache];
  291. });
  292. }]];
  293. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  294. }]];
  295. alertController.popoverPresentationController.sourceView = self.view;
  296. NSIndexPath *indexPath = [self.form indexPathOfFormRow:sender];
  297. CGRect cellRect = [self.tableView rectForRowAtIndexPath:indexPath];
  298. alertController.popoverPresentationController.sourceRect = CGRectOffset(cellRect, -self.tableView.contentOffset.x, -self.tableView.contentOffset.y);
  299. [self presentViewController:alertController animated:YES completion:nil];
  300. }
  301. #pragma --------------------------------------------------------------------------------------------
  302. #pragma mark == Exit Nextcloud ==
  303. #pragma --------------------------------------------------------------------------------------------
  304. - (void)exitNextcloud:(XLFormRowDescriptor *)sender
  305. {
  306. [self deselectFormRow:sender];
  307. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"_want_exit_", nil) preferredStyle:UIAlertControllerStyleActionSheet];
  308. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  309. [[NSURLCache sharedURLCache] setMemoryCapacity:0];
  310. [[NSURLCache sharedURLCache] setDiskCapacity:0];
  311. [KTVHTTPCache cacheDeleteAllCaches];
  312. [CCUtility removeGroupDirectoryProviderStorage];
  313. [CCUtility removeGroupApplicationSupport];
  314. [CCUtility removeDocumentsDirectory];
  315. [CCUtility removeTemporaryDirectory];
  316. [CCUtility deleteAllChainStore];
  317. [[NCManageDatabase shared] removeDB];
  318. exit(0);
  319. }]];
  320. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  321. }]];
  322. alertController.popoverPresentationController.sourceView = self.view;
  323. NSIndexPath *indexPath = [self.form indexPathOfFormRow:sender];
  324. CGRect cellRect = [self.tableView rectForRowAtIndexPath:indexPath];
  325. alertController.popoverPresentationController.sourceRect = CGRectOffset(cellRect, -self.tableView.contentOffset.x, -self.tableView.contentOffset.y);
  326. [self presentViewController:alertController animated:YES completion:nil];
  327. }
  328. @end