CCMove.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. //
  2. // CCMove.m
  3. // Crypto Cloud Technology Nextcloud
  4. //
  5. // Created by Marino Faggiana on 04/09/14.
  6. // Copyright (c) 2017 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 "CCMove.h"
  24. #import "NCBridgeSwift.h"
  25. @interface CCMove ()
  26. {
  27. NSString *activeAccount;
  28. NSString *activePassword;
  29. NSString *activeUrl;
  30. NSString *activeUser;
  31. NSString *directoryUser;
  32. BOOL _isCryptoCloudMode;
  33. BOOL _loadingFolder;
  34. }
  35. @end
  36. @implementation CCMove
  37. // MARK: - View
  38. - (void)viewDidLoad
  39. {
  40. [super viewDidLoad];
  41. tableAccount *recordAccount = [[NCManageDatabase sharedInstance] getAccountActive];
  42. if (recordAccount) {
  43. activeAccount = recordAccount.account;
  44. activePassword = recordAccount.password;
  45. activeUrl = recordAccount.url;
  46. activeUser = recordAccount.user;
  47. directoryUser = [CCUtility getDirectoryActiveUser:activeUser activeUrl:activeUrl];
  48. // Crypto Mode
  49. if ([[CCUtility getKeyChainPasscodeForUUID:[CCUtility getUUID]] length] == 0) {
  50. _isCryptoCloudMode = NO;
  51. } else {
  52. _isCryptoCloudMode = YES;
  53. }
  54. } else {
  55. UIAlertController * alert= [UIAlertController alertControllerWithTitle:nil message:NSLocalizedString(@"_no_active_account_", nil) preferredStyle:UIAlertControllerStyleAlert];
  56. UIAlertAction* ok = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  57. [alert dismissViewControllerAnimated:YES completion:nil];
  58. }];
  59. [alert addAction:ok];
  60. [self presentViewController:alert animated:YES completion:nil];
  61. }
  62. [self.cancel setTitle:NSLocalizedString(@"_cancel_", nil)];
  63. [self.create setTitle:NSLocalizedString(@"_create_folder_", nil)];
  64. if (![_serverUrl length]) {
  65. _serverUrl = [CCUtility getHomeServerUrlActiveUrl:activeUrl];
  66. UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed: @"navigationLogo"]];
  67. [self.navigationController.navigationBar.topItem setTitleView:image];
  68. self.title = @"Home";
  69. } else {
  70. UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(0,0, self.navigationItem.titleView.frame.size.width, 40)];
  71. label.text = self.passMetadata.fileNamePrint;
  72. if (self.passMetadata.cryptated) label.textColor = NCBrandColor.sharedInstance.cryptocloud;
  73. else label.textColor = NCBrandColor.sharedInstance.navigationBarText;
  74. label.backgroundColor =[UIColor clearColor];
  75. label.textAlignment = NSTextAlignmentCenter;
  76. self.navigationItem.titleView=label;
  77. }
  78. // TableView : at the end of rows nothing
  79. self.tableView.tableFooterView = [UIView new];
  80. self.tableView.separatorColor = NCBrandColor.sharedInstance.seperator;
  81. self.tableView.emptyDataSetDelegate = self;
  82. self.tableView.emptyDataSetSource = self;
  83. // read file->folder
  84. [self readFileReloadFolder];
  85. }
  86. // Apparirà
  87. - (void)viewWillAppear:(BOOL)animated
  88. {
  89. [super viewWillAppear:animated];
  90. self.navigationController.navigationBar.barTintColor = NCBrandColor.sharedInstance.brand;
  91. self.navigationController.navigationBar.tintColor = NCBrandColor.sharedInstance.navigationBarText;
  92. self.navigationController.toolbar.barTintColor = NCBrandColor.sharedInstance.tabBar;
  93. self.navigationController.toolbar.tintColor = NCBrandColor.sharedInstance.brand;
  94. }
  95. #pragma --------------------------------------------------------------------------------------------
  96. #pragma mark ==== DZNEmptyDataSetSource ====
  97. #pragma --------------------------------------------------------------------------------------------
  98. - (BOOL)emptyDataSetShouldDisplay:(UIScrollView *)scrollView
  99. {
  100. if (_loadingFolder)
  101. return YES;
  102. else
  103. return NO;
  104. }
  105. - (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView
  106. {
  107. return NO;
  108. }
  109. - (UIColor *)backgroundColorForEmptyDataSet:(UIScrollView *)scrollView
  110. {
  111. return [UIColor whiteColor];
  112. }
  113. - (UIView *)customViewForEmptyDataSet:(UIScrollView *)scrollView
  114. {
  115. if (_loadingFolder) {
  116. UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
  117. activityView.transform = CGAffineTransformMakeScale(1.5f, 1.5f);
  118. activityView.color = [NCBrandColor sharedInstance].brand;
  119. [activityView startAnimating];
  120. return activityView;
  121. }
  122. return nil;
  123. }
  124. // MARK: - IBAction
  125. - (IBAction)cancel:(UIBarButtonItem *)sender
  126. {
  127. [self dismissViewControllerAnimated:YES completion:nil];
  128. }
  129. - (IBAction)move:(UIBarButtonItem *)sender
  130. {
  131. [_networkingOperationQueue cancelAllOperations];
  132. [self.delegate moveServerUrlTo:_serverUrl title:self.passMetadata.fileNamePrint];
  133. [self dismissViewControllerAnimated:YES completion:nil];
  134. }
  135. - (IBAction)create:(UIBarButtonItem *)sender
  136. {
  137. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_create_folder_",nil) message:@"" preferredStyle:UIAlertControllerStyleAlert];
  138. [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
  139. //textField.placeholder = NSLocalizedString(@"LoginPlaceholder", @"Login");
  140. textField.autocapitalizationType = UITextAutocapitalizationTypeWords;
  141. }];
  142. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_save_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  143. [self createFolder:alertController.textFields.firstObject.text];
  144. }]];
  145. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  146. }]];
  147. [self presentViewController:alertController animated:YES completion:nil];
  148. }
  149. // MARK: - BKPasscodeViewController
  150. - (void)passcodeViewController:(CCBKPasscode *)aViewController didFinishWithPasscode:(NSString *)aPasscode
  151. {
  152. [aViewController dismissViewControllerAnimated:YES completion:nil];
  153. [self performSegueDirectoryWithControlPasscode:false];
  154. }
  155. - (void)passcodeViewController:(BKPasscodeViewController *)aViewController authenticatePasscode:(NSString *)aPasscode resultHandler:(void (^)(BOOL))aResultHandler
  156. {
  157. if ([aPasscode isEqualToString:[CCUtility getBlockCode]]) {
  158. self.lockUntilDate = nil;
  159. self.failedAttempts = 0;
  160. aResultHandler(YES);
  161. } else {
  162. aResultHandler(NO);
  163. }
  164. }
  165. - (void)passcodeViewControllerDidFailAttempt:(BKPasscodeViewController *)aViewController
  166. {
  167. self.failedAttempts++;
  168. if (self.failedAttempts > 5) {
  169. NSTimeInterval timeInterval = 60;
  170. if (self.failedAttempts > 6) {
  171. NSUInteger multiplier = self.failedAttempts - 6;
  172. timeInterval = (5 * 60) * multiplier;
  173. if (timeInterval > 3600 * 24) {
  174. timeInterval = 3600 * 24;
  175. }
  176. }
  177. self.lockUntilDate = [NSDate dateWithTimeIntervalSinceNow:timeInterval];
  178. }
  179. }
  180. - (NSUInteger)passcodeViewControllerNumberOfFailedAttempts:(BKPasscodeViewController *)aViewController
  181. {
  182. return self.failedAttempts;
  183. }
  184. - (NSDate *)passcodeViewControllerLockUntilDate:(BKPasscodeViewController *)aViewController
  185. {
  186. return self.lockUntilDate;
  187. }
  188. - (void)passcodeViewCloseButtonPressed:(id)sender
  189. {
  190. [self dismissViewControllerAnimated:YES completion:nil];
  191. }
  192. // MARK: - NetWorking
  193. - (void)addNetworkingQueue:(CCMetadataNet *)metadataNet
  194. {
  195. OCnetworking *operation = [[OCnetworking alloc] initWithDelegate:self metadataNet:metadataNet withUser:activeUser withPassword:activePassword withUrl:activeUrl isCryptoCloudMode:_isCryptoCloudMode];
  196. _networkingOperationQueue.maxConcurrentOperationCount = k_maxConcurrentOperation;
  197. [_networkingOperationQueue addOperation:operation];
  198. }
  199. // MARK: - Download File
  200. - (void)downloadFileSuccess:(NSString *)fileID serverUrl:(NSString *)serverUrl selector:(NSString *)selector selectorPost:(NSString *)selectorPost
  201. {
  202. if ([selector isEqualToString:selectorLoadPlist]) {
  203. tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID = %@", fileID]];
  204. metadata = [CCUtility insertInformationPlist:metadata directoryUser:directoryUser];
  205. metadata = [[NCManageDatabase sharedInstance] updateMetadata:metadata activeUrl:activeUrl];
  206. // se è un template aggiorniamo anche nel FileSystem
  207. if ([metadata.type isEqualToString: k_metadataType_template]) {
  208. [[NCManageDatabase sharedInstance] setLocalFileWithFileID:metadata.fileID date:metadata.date exifDate:nil exifLatitude:nil exifLongitude:nil fileName:nil fileNamePrint:metadata.fileNamePrint];
  209. }
  210. [self.tableView reloadData];
  211. }
  212. }
  213. - (void)downloadFileFailure:(NSString *)fileID serverUrl:(NSString *)serverUrl selector:(NSString *)selector message:(NSString *)message errorCode:(NSInteger)errorCode
  214. {
  215. self.move.enabled = NO;
  216. }
  217. // MARK: - Read Folder
  218. - (void)readFileFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode
  219. {
  220. [self readFolder];
  221. }
  222. - (void)readFileSuccess:(CCMetadataNet *)metadataNet metadata:(tableMetadata *)metadata
  223. {
  224. if ([metadataNet.selector isEqualToString:selectorReadFileReloadFolder]) {
  225. tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account = %@ AND serverUrl = %@", metadataNet.account, metadataNet.serverUrl]];
  226. if ([metadata.etag isEqualToString:directory.etag] == NO) {
  227. [self readFolder];
  228. }
  229. }
  230. }
  231. - (void)readFileReloadFolder
  232. {
  233. CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:activeAccount];
  234. metadataNet.action = actionReadFile;
  235. metadataNet.priority = NSOperationQueuePriorityHigh;
  236. metadataNet.selector = selectorReadFileReloadFolder;
  237. metadataNet.serverUrl = _serverUrl;
  238. [self addNetworkingQueue:metadataNet];
  239. }
  240. // MARK: - Read Folder
  241. - (void)readFolderFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode
  242. {
  243. _loadingFolder = NO;
  244. self.move.enabled = NO;
  245. [self.tableView reloadData];
  246. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_",nil) message:message preferredStyle:UIAlertControllerStyleAlert];
  247. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  248. }]];
  249. [self presentViewController:alertController animated:YES completion:nil];
  250. }
  251. - (void)readFolderSuccess:(CCMetadataNet *)metadataNet metadataFolder:(tableMetadata *)metadataFolder metadatas:(NSArray *)metadatas
  252. {
  253. NSMutableArray *metadatasToInsertInDB = [NSMutableArray new];
  254. // Update directory etag
  255. [[NCManageDatabase sharedInstance] setDirectoryWithServerUrl:metadataNet.serverUrl serverUrlTo:nil etag:metadataFolder.etag];
  256. for (tableMetadata *metadata in metadatas) {
  257. // type of file
  258. NSInteger typeFilename = [CCUtility getTypeFileName:metadata.fileName];
  259. // do not insert crypto file
  260. if (typeFilename == k_metadataTypeFilenameCrypto) continue;
  261. // verify if the record encrypted has plist + crypto
  262. if (typeFilename == k_metadataTypeFilenamePlist && metadata.directory == NO) {
  263. BOOL isCryptoComplete = NO;
  264. NSString *fileNameCrypto = [CCUtility trasformedFileNamePlistInCrypto:metadata.fileName];
  265. for (tableMetadata *completeMetadata in metadatas) {
  266. if (completeMetadata.cryptated == NO) continue;
  267. else if ([completeMetadata.fileName isEqualToString:fileNameCrypto]) {
  268. isCryptoComplete = YES;
  269. break;
  270. }
  271. }
  272. if (isCryptoComplete == NO) continue;
  273. }
  274. // Insert in Array
  275. [metadatasToInsertInDB addObject:metadata];
  276. }
  277. // insert in Database
  278. metadatas = [[NCManageDatabase sharedInstance] addMetadatas:metadatasToInsertInDB activeUrl:activeUrl serverUrl:metadataNet.serverUrl];
  279. // Plist MULTI THREAD
  280. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
  281. for (tableMetadata *metadata in metadatas) {
  282. if ([CCUtility isCryptoPlistString:metadata.fileName] && [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@", directoryUser, metadata.fileName]] == NO) {
  283. CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:activeAccount];
  284. metadataNet.action = actionDownloadFile;
  285. metadataNet.downloadData = NO;
  286. metadataNet.downloadPlist = YES;
  287. metadataNet.fileID = metadata.fileID;
  288. metadataNet.selector = selectorLoadPlist;
  289. metadataNet.serverUrl = _serverUrl;
  290. metadataNet.session = k_download_session_foreground;
  291. metadataNet.taskStatus = k_taskStatusResume;
  292. [self addNetworkingQueue:metadataNet];
  293. }
  294. }
  295. });
  296. _loadingFolder = NO;
  297. [self.tableView reloadData];
  298. }
  299. - (void)readFolder
  300. {
  301. CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:activeAccount];
  302. metadataNet.action = actionReadFolder;
  303. metadataNet.serverUrl = _serverUrl;
  304. metadataNet.selector = selectorReadFolder;
  305. metadataNet.date = nil;
  306. [self addNetworkingQueue:metadataNet];
  307. //
  308. _loadingFolder = YES;
  309. [self.tableView reloadData];
  310. }
  311. // MARK: - Create Folder
  312. - (void)createFolderFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode
  313. {
  314. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_",nil) message:message preferredStyle:UIAlertControllerStyleAlert];
  315. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  316. }]];
  317. [self presentViewController:alertController animated:YES completion:nil];
  318. }
  319. - (void)createFolderSuccess:(CCMetadataNet *)metadataNet
  320. {
  321. (void)[[NCManageDatabase sharedInstance] addDirectoryWithServerUrl:[NSString stringWithFormat:@"%@/%@", metadataNet.serverUrl, metadataNet.fileName] permissions:@""];
  322. // Load Folder or the Datasource
  323. [self readFolder];
  324. }
  325. - (void)createFolder:(NSString *)fileNameFolder
  326. {
  327. CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:activeAccount];
  328. fileNameFolder = [CCUtility removeForbiddenCharactersServer:fileNameFolder];
  329. if (![fileNameFolder length]) return;
  330. metadataNet.action = actionCreateFolder;
  331. metadataNet.fileName = fileNameFolder;
  332. metadataNet.selector = selectorCreateFolder;
  333. metadataNet.selectorPost = selectorReadFolderForced;
  334. metadataNet.serverUrl = _serverUrl;
  335. [self addNetworkingQueue:metadataNet];
  336. }
  337. // MARK: - Table
  338. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  339. {
  340. return 1;
  341. }
  342. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  343. {
  344. NSString *directoryID = [[NCManageDatabase sharedInstance] getDirectoryID:_serverUrl];
  345. NSPredicate *predicate;
  346. if (self.onlyClearDirectory) predicate = [NSPredicate predicateWithFormat:@"account = %@ AND directoryID = %@ AND directory = true AND cryptated = false", activeAccount, directoryID];
  347. else predicate = [NSPredicate predicateWithFormat:@"account == %@ AND directoryID = %@ AND directory = true", activeAccount, directoryID];
  348. NSArray *result = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:predicate sorted:nil ascending:NO];
  349. if (result)
  350. return [result count];
  351. else
  352. return 0;
  353. }
  354. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  355. {
  356. NSPredicate *predicate;
  357. static NSString *CellIdentifier = @"MyCustomCell";
  358. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  359. if (cell == nil) {
  360. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
  361. }
  362. NSString *directoryID = [[NCManageDatabase sharedInstance] getDirectoryID:_serverUrl];
  363. if (self.onlyClearDirectory) predicate = [NSPredicate predicateWithFormat:@"account = %@ AND directoryID = %@ AND directory = true AND cryptated = false", activeAccount, directoryID];
  364. else predicate = [NSPredicate predicateWithFormat:@"account = %@ AND directoryID = %@ AND directory = true", activeAccount, directoryID];
  365. tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataAtIndexWithPredicate:predicate sorted:@"fileName" ascending:YES index:indexPath.row];
  366. // colors
  367. if (metadata.cryptated) {
  368. cell.textLabel.textColor = NCBrandColor.sharedInstance.cryptocloud;
  369. } else {
  370. cell.textLabel.textColor = [UIColor blackColor];
  371. }
  372. cell.detailTextLabel.text = @"";
  373. cell.imageView.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:metadata.iconName] color:[NCBrandColor sharedInstance].brand];
  374. cell.textLabel.text = metadata.fileNamePrint;
  375. return cell;
  376. }
  377. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  378. {
  379. [self performSegueDirectoryWithControlPasscode:YES];
  380. }
  381. // MARK: - Navigation
  382. - (void)performSegueDirectoryWithControlPasscode:(BOOL)controlPasscode
  383. {
  384. NSString *nomeDir;
  385. NSPredicate *predicate;
  386. NSIndexPath *index = [self.tableView indexPathForSelectedRow];
  387. NSString *directoryID = [[NCManageDatabase sharedInstance] getDirectoryID:_serverUrl];
  388. if (self.onlyClearDirectory) predicate = [NSPredicate predicateWithFormat:@"account = %@ AND directoryID = %@ AND directory = true AND cryptated = false", activeAccount, directoryID];
  389. else predicate = [NSPredicate predicateWithFormat:@"account = %@ AND directoryID == %@ AND directory = true", activeAccount, directoryID];
  390. tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataAtIndexWithPredicate:predicate sorted:@"fileName" ascending:YES index:index.row];
  391. if (metadata.errorPasscode == NO) {
  392. // lockServerUrl
  393. NSString *lockServerUrl = [CCUtility stringAppendServerUrl:_serverUrl addFileName:metadata.fileNameData];
  394. // Se siamo in presenza di una directory bloccata E è attivo il block E la sessione PASSWORD Lock è senza data ALLORA chiediamo la password per procedere
  395. tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account = %@ AND serverUrl = %@", activeAccount, lockServerUrl]];
  396. if (directory.lock && [[CCUtility getBlockCode] length] && controlPasscode) {
  397. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  398. viewController.delegate = self;
  399. //viewController.fromType = CCBKPasscodeFromLockDirectory;
  400. viewController.type = BKPasscodeViewControllerCheckPasscodeType;
  401. viewController.inputViewTitlePassword = YES;
  402. if ([CCUtility getSimplyBlockCode]) {
  403. viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
  404. viewController.passcodeInputView.maximumLength = 6;
  405. } else {
  406. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  407. viewController.passcodeInputView.maximumLength = 64;
  408. }
  409. BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:k_serviceShareKeyChain];
  410. touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
  411. viewController.touchIDManager = touchIDManager;
  412. viewController.title = NSLocalizedString(@"_folder_blocked_", nil);
  413. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  414. viewController.navigationItem.leftBarButtonItem.tintColor = NCBrandColor.sharedInstance.cryptocloud;
  415. UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
  416. [self presentViewController:navController animated:YES completion:nil];
  417. return;
  418. }
  419. if (metadata.cryptated) nomeDir = [metadata.fileName substringToIndex:[metadata.fileName length]-6];
  420. else nomeDir = metadata.fileName;
  421. CCMove *viewController = [[UIStoryboard storyboardWithName:@"CCMove" bundle:nil] instantiateViewControllerWithIdentifier:@"CCMoveVC"];
  422. viewController.delegate = self.delegate;
  423. viewController.onlyClearDirectory = self.onlyClearDirectory;
  424. viewController.move.title = self.move.title;
  425. viewController.networkingOperationQueue = _networkingOperationQueue;
  426. viewController.passMetadata = metadata;
  427. viewController.serverUrl = [CCUtility stringAppendServerUrl:_serverUrl addFileName:nomeDir];
  428. [self.navigationController pushViewController:viewController animated:YES];
  429. }
  430. }
  431. @end