CCMove.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  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. if ([self.delegate respondsToSelector:@selector(dismissMove)])
  128. [self.delegate dismissMove];
  129. [self dismissViewControllerAnimated:YES completion:nil];
  130. }
  131. - (IBAction)move:(UIBarButtonItem *)sender
  132. {
  133. [_networkingOperationQueue cancelAllOperations];
  134. if ([self.delegate respondsToSelector:@selector(dismissMove)])
  135. [self.delegate dismissMove];
  136. [self.delegate moveServerUrlTo:_serverUrl title:self.passMetadata.fileNamePrint];
  137. [self dismissViewControllerAnimated:YES completion:nil];
  138. }
  139. - (IBAction)create:(UIBarButtonItem *)sender
  140. {
  141. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_create_folder_",nil) message:@"" preferredStyle:UIAlertControllerStyleAlert];
  142. [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
  143. //textField.placeholder = NSLocalizedString(@"LoginPlaceholder", @"Login");
  144. textField.autocapitalizationType = UITextAutocapitalizationTypeWords;
  145. }];
  146. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_save_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  147. [self createFolder:alertController.textFields.firstObject.text];
  148. }]];
  149. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  150. }]];
  151. [self presentViewController:alertController animated:YES completion:nil];
  152. }
  153. // MARK: - BKPasscodeViewController
  154. - (void)passcodeViewController:(CCBKPasscode *)aViewController didFinishWithPasscode:(NSString *)aPasscode
  155. {
  156. [aViewController dismissViewControllerAnimated:YES completion:nil];
  157. [self performSegueDirectoryWithControlPasscode:false];
  158. }
  159. - (void)passcodeViewController:(BKPasscodeViewController *)aViewController authenticatePasscode:(NSString *)aPasscode resultHandler:(void (^)(BOOL))aResultHandler
  160. {
  161. if ([aPasscode isEqualToString:[CCUtility getBlockCode]]) {
  162. self.lockUntilDate = nil;
  163. self.failedAttempts = 0;
  164. aResultHandler(YES);
  165. } else {
  166. aResultHandler(NO);
  167. }
  168. }
  169. - (void)passcodeViewControllerDidFailAttempt:(BKPasscodeViewController *)aViewController
  170. {
  171. self.failedAttempts++;
  172. if (self.failedAttempts > 5) {
  173. NSTimeInterval timeInterval = 60;
  174. if (self.failedAttempts > 6) {
  175. NSUInteger multiplier = self.failedAttempts - 6;
  176. timeInterval = (5 * 60) * multiplier;
  177. if (timeInterval > 3600 * 24) {
  178. timeInterval = 3600 * 24;
  179. }
  180. }
  181. self.lockUntilDate = [NSDate dateWithTimeIntervalSinceNow:timeInterval];
  182. }
  183. }
  184. - (NSUInteger)passcodeViewControllerNumberOfFailedAttempts:(BKPasscodeViewController *)aViewController
  185. {
  186. return self.failedAttempts;
  187. }
  188. - (NSDate *)passcodeViewControllerLockUntilDate:(BKPasscodeViewController *)aViewController
  189. {
  190. return self.lockUntilDate;
  191. }
  192. - (void)passcodeViewCloseButtonPressed:(id)sender
  193. {
  194. [self dismissViewControllerAnimated:YES completion:nil];
  195. }
  196. // MARK: - NetWorking
  197. - (void)addNetworkingQueue:(CCMetadataNet *)metadataNet
  198. {
  199. OCnetworking *operation = [[OCnetworking alloc] initWithDelegate:self metadataNet:metadataNet withUser:activeUser withPassword:activePassword withUrl:activeUrl isCryptoCloudMode:_isCryptoCloudMode];
  200. _networkingOperationQueue.maxConcurrentOperationCount = k_maxConcurrentOperation;
  201. [_networkingOperationQueue addOperation:operation];
  202. }
  203. // MARK: - Download File
  204. - (void)downloadFileSuccess:(NSString *)fileID serverUrl:(NSString *)serverUrl selector:(NSString *)selector selectorPost:(NSString *)selectorPost
  205. {
  206. if ([selector isEqualToString:selectorLoadPlist]) {
  207. tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID = %@", fileID]];
  208. metadata = [CCUtility insertInformationPlist:metadata directoryUser:directoryUser];
  209. metadata = [[NCManageDatabase sharedInstance] updateMetadata:metadata activeUrl:activeUrl];
  210. // se è un template aggiorniamo anche nel FileSystem
  211. if ([metadata.type isEqualToString: k_metadataType_template]) {
  212. [[NCManageDatabase sharedInstance] setLocalFileWithFileID:metadata.fileID date:metadata.date exifDate:nil exifLatitude:nil exifLongitude:nil fileName:nil fileNamePrint:metadata.fileNamePrint];
  213. }
  214. [self.tableView reloadData];
  215. }
  216. }
  217. - (void)downloadFileFailure:(NSString *)fileID serverUrl:(NSString *)serverUrl selector:(NSString *)selector message:(NSString *)message errorCode:(NSInteger)errorCode
  218. {
  219. self.move.enabled = NO;
  220. }
  221. // MARK: - Read Folder
  222. - (void)readFileFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode
  223. {
  224. [self readFolder];
  225. }
  226. - (void)readFileSuccess:(CCMetadataNet *)metadataNet metadata:(tableMetadata *)metadata
  227. {
  228. if ([metadataNet.selector isEqualToString:selectorReadFileReloadFolder]) {
  229. tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account = %@ AND serverUrl = %@", metadataNet.account, metadataNet.serverUrl]];
  230. if ([metadata.etag isEqualToString:directory.etag] == NO) {
  231. [self readFolder];
  232. }
  233. }
  234. }
  235. - (void)readFileReloadFolder
  236. {
  237. CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:activeAccount];
  238. metadataNet.action = actionReadFile;
  239. metadataNet.priority = NSOperationQueuePriorityHigh;
  240. metadataNet.selector = selectorReadFileReloadFolder;
  241. metadataNet.serverUrl = _serverUrl;
  242. [self addNetworkingQueue:metadataNet];
  243. }
  244. // MARK: - Read Folder
  245. - (void)readFolderFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode
  246. {
  247. _loadingFolder = NO;
  248. self.move.enabled = NO;
  249. [self.tableView reloadData];
  250. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_",nil) message:message preferredStyle:UIAlertControllerStyleAlert];
  251. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  252. }]];
  253. [self presentViewController:alertController animated:YES completion:nil];
  254. }
  255. - (void)readFolderSuccess:(CCMetadataNet *)metadataNet metadataFolder:(tableMetadata *)metadataFolder metadatas:(NSArray *)metadatas
  256. {
  257. NSMutableArray *metadatasToInsertInDB = [NSMutableArray new];
  258. // Update directory etag
  259. [[NCManageDatabase sharedInstance] setDirectoryWithServerUrl:metadataNet.serverUrl serverUrlTo:nil etag:metadataFolder.etag];
  260. for (tableMetadata *metadata in metadatas) {
  261. // type of file
  262. NSInteger typeFilename = [CCUtility getTypeFileName:metadata.fileName];
  263. // do not insert crypto file
  264. if (typeFilename == k_metadataTypeFilenameCrypto) continue;
  265. // verify if the record encrypted has plist + crypto
  266. if (typeFilename == k_metadataTypeFilenamePlist && metadata.directory == NO) {
  267. BOOL isCryptoComplete = NO;
  268. NSString *fileNameCrypto = [CCUtility trasformedFileNamePlistInCrypto:metadata.fileName];
  269. for (tableMetadata *completeMetadata in metadatas) {
  270. if (completeMetadata.cryptated == NO) continue;
  271. else if ([completeMetadata.fileName isEqualToString:fileNameCrypto]) {
  272. isCryptoComplete = YES;
  273. break;
  274. }
  275. }
  276. if (isCryptoComplete == NO) continue;
  277. }
  278. // Insert in Array
  279. [metadatasToInsertInDB addObject:metadata];
  280. }
  281. // insert in Database
  282. metadatas = [[NCManageDatabase sharedInstance] addMetadatas:metadatasToInsertInDB activeUrl:activeUrl serverUrl:metadataNet.serverUrl];
  283. // Plist MULTI THREAD
  284. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
  285. for (tableMetadata *metadata in metadatas) {
  286. if ([CCUtility isCryptoPlistString:metadata.fileName] && [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@", directoryUser, metadata.fileName]] == NO) {
  287. CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:activeAccount];
  288. metadataNet.action = actionDownloadFile;
  289. metadataNet.downloadData = NO;
  290. metadataNet.downloadPlist = YES;
  291. metadataNet.fileID = metadata.fileID;
  292. metadataNet.selector = selectorLoadPlist;
  293. metadataNet.serverUrl = _serverUrl;
  294. metadataNet.session = k_download_session_foreground;
  295. metadataNet.taskStatus = k_taskStatusResume;
  296. [self addNetworkingQueue:metadataNet];
  297. }
  298. }
  299. });
  300. _loadingFolder = NO;
  301. [self.tableView reloadData];
  302. }
  303. - (void)readFolder
  304. {
  305. CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:activeAccount];
  306. metadataNet.action = actionReadFolder;
  307. metadataNet.serverUrl = _serverUrl;
  308. metadataNet.selector = selectorReadFolder;
  309. metadataNet.date = nil;
  310. [self addNetworkingQueue:metadataNet];
  311. //
  312. _loadingFolder = YES;
  313. [self.tableView reloadData];
  314. }
  315. // MARK: - Create Folder
  316. - (void)createFolderFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode
  317. {
  318. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_",nil) message:message preferredStyle:UIAlertControllerStyleAlert];
  319. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  320. }]];
  321. [self presentViewController:alertController animated:YES completion:nil];
  322. }
  323. - (void)createFolderSuccess:(CCMetadataNet *)metadataNet
  324. {
  325. (void)[[NCManageDatabase sharedInstance] addDirectoryWithServerUrl:[NSString stringWithFormat:@"%@/%@", metadataNet.serverUrl, metadataNet.fileName] permissions:@""];
  326. // Load Folder or the Datasource
  327. [self readFolder];
  328. }
  329. - (void)createFolder:(NSString *)fileNameFolder
  330. {
  331. CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:activeAccount];
  332. fileNameFolder = [CCUtility removeForbiddenCharactersServer:fileNameFolder];
  333. if (![fileNameFolder length]) return;
  334. metadataNet.action = actionCreateFolder;
  335. metadataNet.fileName = fileNameFolder;
  336. metadataNet.selector = selectorCreateFolder;
  337. metadataNet.selectorPost = selectorReadFolderForced;
  338. metadataNet.serverUrl = _serverUrl;
  339. [self addNetworkingQueue:metadataNet];
  340. }
  341. // MARK: - Table
  342. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  343. {
  344. return 1;
  345. }
  346. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  347. {
  348. NSString *directoryID = [[NCManageDatabase sharedInstance] getDirectoryID:_serverUrl];
  349. NSPredicate *predicate;
  350. if (self.onlyClearDirectory) predicate = [NSPredicate predicateWithFormat:@"account = %@ AND directoryID = %@ AND directory = true AND cryptated = false", activeAccount, directoryID];
  351. else predicate = [NSPredicate predicateWithFormat:@"account == %@ AND directoryID = %@ AND directory = true", activeAccount, directoryID];
  352. NSArray *result = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:predicate sorted:nil ascending:NO];
  353. if (result)
  354. return [result count];
  355. else
  356. return 0;
  357. }
  358. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  359. {
  360. NSPredicate *predicate;
  361. static NSString *CellIdentifier = @"MyCustomCell";
  362. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  363. if (cell == nil) {
  364. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
  365. }
  366. NSString *directoryID = [[NCManageDatabase sharedInstance] getDirectoryID:_serverUrl];
  367. if (self.onlyClearDirectory) predicate = [NSPredicate predicateWithFormat:@"account = %@ AND directoryID = %@ AND directory = true AND cryptated = false", activeAccount, directoryID];
  368. else predicate = [NSPredicate predicateWithFormat:@"account = %@ AND directoryID = %@ AND directory = true", activeAccount, directoryID];
  369. tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataAtIndexWithPredicate:predicate sorted:@"fileName" ascending:YES index:indexPath.row];
  370. // colors
  371. if (metadata.cryptated) {
  372. cell.textLabel.textColor = NCBrandColor.sharedInstance.cryptocloud;
  373. } else {
  374. cell.textLabel.textColor = [UIColor blackColor];
  375. }
  376. cell.detailTextLabel.text = @"";
  377. cell.imageView.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:metadata.iconName] color:[NCBrandColor sharedInstance].brand];
  378. cell.textLabel.text = metadata.fileNamePrint;
  379. return cell;
  380. }
  381. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  382. {
  383. [self performSegueDirectoryWithControlPasscode:YES];
  384. }
  385. // MARK: - Navigation
  386. - (void)performSegueDirectoryWithControlPasscode:(BOOL)controlPasscode
  387. {
  388. NSString *nomeDir;
  389. NSPredicate *predicate;
  390. NSIndexPath *index = [self.tableView indexPathForSelectedRow];
  391. NSString *directoryID = [[NCManageDatabase sharedInstance] getDirectoryID:_serverUrl];
  392. if (self.onlyClearDirectory) predicate = [NSPredicate predicateWithFormat:@"account = %@ AND directoryID = %@ AND directory = true AND cryptated = false", activeAccount, directoryID];
  393. else predicate = [NSPredicate predicateWithFormat:@"account = %@ AND directoryID == %@ AND directory = true", activeAccount, directoryID];
  394. tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataAtIndexWithPredicate:predicate sorted:@"fileName" ascending:YES index:index.row];
  395. if (metadata.errorPasscode == NO) {
  396. // lockServerUrl
  397. NSString *lockServerUrl = [CCUtility stringAppendServerUrl:_serverUrl addFileName:metadata.fileNameData];
  398. // 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
  399. tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account = %@ AND serverUrl = %@", activeAccount, lockServerUrl]];
  400. if (directory.lock && [[CCUtility getBlockCode] length] && controlPasscode) {
  401. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  402. viewController.delegate = self;
  403. //viewController.fromType = CCBKPasscodeFromLockDirectory;
  404. viewController.type = BKPasscodeViewControllerCheckPasscodeType;
  405. viewController.inputViewTitlePassword = YES;
  406. if ([CCUtility getSimplyBlockCode]) {
  407. viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
  408. viewController.passcodeInputView.maximumLength = 6;
  409. } else {
  410. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  411. viewController.passcodeInputView.maximumLength = 64;
  412. }
  413. BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:k_serviceShareKeyChain];
  414. touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
  415. viewController.touchIDManager = touchIDManager;
  416. viewController.title = NSLocalizedString(@"_folder_blocked_", nil);
  417. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  418. viewController.navigationItem.leftBarButtonItem.tintColor = NCBrandColor.sharedInstance.cryptocloud;
  419. UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
  420. [self presentViewController:navController animated:YES completion:nil];
  421. return;
  422. }
  423. if (metadata.cryptated) nomeDir = [metadata.fileName substringToIndex:[metadata.fileName length]-6];
  424. else nomeDir = metadata.fileName;
  425. CCMove *viewController = [[UIStoryboard storyboardWithName:@"CCMove" bundle:nil] instantiateViewControllerWithIdentifier:@"CCMoveVC"];
  426. viewController.delegate = self.delegate;
  427. viewController.onlyClearDirectory = self.onlyClearDirectory;
  428. viewController.move.title = self.move.title;
  429. viewController.networkingOperationQueue = _networkingOperationQueue;
  430. viewController.passMetadata = metadata;
  431. viewController.serverUrl = [CCUtility stringAppendServerUrl:_serverUrl addFileName:nomeDir];
  432. [self.navigationController pushViewController:viewController animated:YES];
  433. }
  434. }
  435. @end