CCMove.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  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. NSString *autoUploadFileName = [[NCManageDatabase sharedInstance] getAccountAutoUploadFileName];
  208. NSString *autoUploadDirectory = [[NCManageDatabase sharedInstance] getAccountAutoUploadDirectory:activeUrl];
  209. tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID = %@", fileID]];
  210. metadata = [CCUtility insertInformationPlist:metadata directoryUser:directoryUser];
  211. metadata = [CCUtility insertTypeFileIconName:metadata serverUrl:serverUrl autoUploadFileName:autoUploadFileName autoUploadDirectory:autoUploadDirectory];
  212. metadata = [[NCManageDatabase sharedInstance] updateMetadata:metadata];
  213. // se è un template aggiorniamo anche nel FileSystem
  214. if ([metadata.type isEqualToString: k_metadataType_template]) {
  215. [[NCManageDatabase sharedInstance] setLocalFileWithFileID:metadata.fileID date:metadata.date exifDate:nil exifLatitude:nil exifLongitude:nil fileName:nil fileNamePrint:metadata.fileNamePrint];
  216. }
  217. [self.tableView reloadData];
  218. }
  219. }
  220. - (void)downloadFileFailure:(NSString *)fileID serverUrl:(NSString *)serverUrl selector:(NSString *)selector message:(NSString *)message errorCode:(NSInteger)errorCode
  221. {
  222. self.move.enabled = NO;
  223. }
  224. // MARK: - Read Folder
  225. - (void)readFileFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode
  226. {
  227. [self readFolder];
  228. }
  229. - (void)readFileSuccess:(CCMetadataNet *)metadataNet metadata:(tableMetadata *)metadata
  230. {
  231. if ([metadataNet.selector isEqualToString:selectorReadFileReloadFolder]) {
  232. tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account = %@ AND serverUrl = %@", metadataNet.account, metadataNet.serverUrl]];
  233. if ([metadata.etag isEqualToString:directory.etag] == NO) {
  234. [self readFolder];
  235. }
  236. }
  237. }
  238. - (void)readFileReloadFolder
  239. {
  240. CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:activeAccount];
  241. metadataNet.action = actionReadFile;
  242. metadataNet.priority = NSOperationQueuePriorityHigh;
  243. metadataNet.selector = selectorReadFileReloadFolder;
  244. metadataNet.serverUrl = _serverUrl;
  245. [self addNetworkingQueue:metadataNet];
  246. }
  247. // MARK: - Read Folder
  248. - (void)readFolderFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode
  249. {
  250. _loadingFolder = NO;
  251. self.move.enabled = NO;
  252. [self.tableView reloadData];
  253. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_",nil) message:message preferredStyle:UIAlertControllerStyleAlert];
  254. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  255. }]];
  256. [self presentViewController:alertController animated:YES completion:nil];
  257. }
  258. - (void)readFolderSuccess:(CCMetadataNet *)metadataNet metadataFolder:(tableMetadata *)metadataFolder metadatas:(NSArray *)metadatas
  259. {
  260. NSMutableArray *metadatasToInsertInDB = [NSMutableArray new];
  261. // Update directory etag
  262. [[NCManageDatabase sharedInstance] setDirectoryWithServerUrl:metadataNet.serverUrl serverUrlTo:nil etag:metadataFolder.etag];
  263. for (tableMetadata *metadata in metadatas) {
  264. // type of file
  265. NSInteger typeFilename = [CCUtility getTypeFileName:metadata.fileName];
  266. // do not insert crypto file
  267. if (typeFilename == k_metadataTypeFilenameCrypto) continue;
  268. // verify if the record encrypted has plist + crypto
  269. if (typeFilename == k_metadataTypeFilenamePlist && metadata.directory == NO) {
  270. BOOL isCryptoComplete = NO;
  271. NSString *fileNameCrypto = [CCUtility trasformedFileNamePlistInCrypto:metadata.fileName];
  272. for (tableMetadata *completeMetadata in metadatas) {
  273. if (completeMetadata.cryptated == NO) continue;
  274. else if ([completeMetadata.fileName isEqualToString:fileNameCrypto]) {
  275. isCryptoComplete = YES;
  276. break;
  277. }
  278. }
  279. if (isCryptoComplete == NO) continue;
  280. }
  281. // Insert in Array
  282. [metadatasToInsertInDB addObject:metadata];
  283. }
  284. // insert in Database
  285. metadatas = [[NCManageDatabase sharedInstance] addMetadatas:metadatasToInsertInDB serverUrl:metadataNet.serverUrl];
  286. // Plist MULTI THREAD
  287. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
  288. for (tableMetadata *metadata in metadatas) {
  289. if ([CCUtility isCryptoPlistString:metadata.fileName] && [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@", directoryUser, metadata.fileName]] == NO) {
  290. [[CCNetworking sharedNetworking] downloadFile:metadata.fileID serverUrl:_serverUrl downloadData:NO downloadPlist:YES selector:selectorLoadPlist selectorPost:nil session:k_download_session_foreground taskStatus:k_taskStatusResume delegate:self];
  291. }
  292. }
  293. });
  294. _loadingFolder = NO;
  295. [self.tableView reloadData];
  296. }
  297. - (void)readFolder
  298. {
  299. CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:activeAccount];
  300. metadataNet.action = actionReadFolder;
  301. metadataNet.date = nil;
  302. metadataNet.depth = @"1";
  303. metadataNet.selector = selectorReadFolder;
  304. metadataNet.serverUrl = _serverUrl;
  305. [self addNetworkingQueue:metadataNet];
  306. //
  307. _loadingFolder = YES;
  308. [self.tableView reloadData];
  309. }
  310. // MARK: - Create Folder
  311. - (void)createFolderFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode
  312. {
  313. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_",nil) message:message preferredStyle:UIAlertControllerStyleAlert];
  314. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  315. }]];
  316. [self presentViewController:alertController animated:YES completion:nil];
  317. }
  318. - (void)createFolderSuccess:(CCMetadataNet *)metadataNet
  319. {
  320. (void)[[NCManageDatabase sharedInstance] addDirectoryWithServerUrl:[NSString stringWithFormat:@"%@/%@", metadataNet.serverUrl, metadataNet.fileName] permissions:nil];
  321. // Load Folder or the Datasource
  322. [self readFolder];
  323. }
  324. - (void)createFolder:(NSString *)fileNameFolder
  325. {
  326. CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:activeAccount];
  327. fileNameFolder = [CCUtility removeForbiddenCharactersServer:fileNameFolder];
  328. if (![fileNameFolder length]) return;
  329. metadataNet.action = actionCreateFolder;
  330. metadataNet.fileName = fileNameFolder;
  331. metadataNet.selector = selectorCreateFolder;
  332. metadataNet.selectorPost = selectorReadFolderForced;
  333. metadataNet.serverUrl = _serverUrl;
  334. [self addNetworkingQueue:metadataNet];
  335. }
  336. // MARK: - Table
  337. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  338. {
  339. return 1;
  340. }
  341. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  342. {
  343. NSString *directoryID = [[NCManageDatabase sharedInstance] getDirectoryID:_serverUrl];
  344. if (!directoryID) return 0;
  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 (!directoryID)
  364. return cell;
  365. if (self.onlyClearDirectory) predicate = [NSPredicate predicateWithFormat:@"account = %@ AND directoryID = %@ AND directory = true AND cryptated = false", activeAccount, directoryID];
  366. else predicate = [NSPredicate predicateWithFormat:@"account = %@ AND directoryID = %@ AND directory = true", activeAccount, directoryID];
  367. tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataAtIndexWithPredicate:predicate sorted:@"fileNamePrint" ascending:YES index:indexPath.row];
  368. // colors
  369. if (metadata.cryptated) {
  370. cell.textLabel.textColor = NCBrandColor.sharedInstance.cryptocloud;
  371. } else {
  372. cell.textLabel.textColor = [UIColor blackColor];
  373. }
  374. cell.detailTextLabel.text = @"";
  375. cell.imageView.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:metadata.iconName] color:[NCBrandColor sharedInstance].brand];
  376. cell.textLabel.text = metadata.fileNamePrint;
  377. return cell;
  378. }
  379. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  380. {
  381. [self performSegueDirectoryWithControlPasscode:YES];
  382. }
  383. // MARK: - Navigation
  384. - (void)performSegueDirectoryWithControlPasscode:(BOOL)controlPasscode
  385. {
  386. NSString *nomeDir;
  387. NSPredicate *predicate;
  388. NSIndexPath *index = [self.tableView indexPathForSelectedRow];
  389. NSString *directoryID = [[NCManageDatabase sharedInstance] getDirectoryID:_serverUrl];
  390. if (!directoryID) return;
  391. if (self.onlyClearDirectory) predicate = [NSPredicate predicateWithFormat:@"account = %@ AND directoryID = %@ AND directory = true AND cryptated = false", activeAccount, directoryID];
  392. else predicate = [NSPredicate predicateWithFormat:@"account = %@ AND directoryID == %@ AND directory = true", activeAccount, directoryID];
  393. tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataAtIndexWithPredicate:predicate sorted:@"fileNamePrint" ascending:YES index:index.row];
  394. if (metadata.errorPasscode == NO) {
  395. // lockServerUrl
  396. NSString *lockServerUrl = [CCUtility stringAppendServerUrl:_serverUrl addFileName:metadata.fileNameData];
  397. // 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
  398. tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account = %@ AND serverUrl = %@", activeAccount, lockServerUrl]];
  399. if (directory.lock && [[CCUtility getBlockCode] length] && controlPasscode) {
  400. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  401. viewController.delegate = self;
  402. //viewController.fromType = CCBKPasscodeFromLockDirectory;
  403. viewController.type = BKPasscodeViewControllerCheckPasscodeType;
  404. viewController.inputViewTitlePassword = YES;
  405. if ([CCUtility getSimplyBlockCode]) {
  406. viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
  407. viewController.passcodeInputView.maximumLength = 6;
  408. } else {
  409. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  410. viewController.passcodeInputView.maximumLength = 64;
  411. }
  412. BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:k_serviceShareKeyChain];
  413. touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
  414. viewController.touchIDManager = touchIDManager;
  415. viewController.title = NSLocalizedString(@"_folder_blocked_", nil);
  416. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  417. viewController.navigationItem.leftBarButtonItem.tintColor = NCBrandColor.sharedInstance.cryptocloud;
  418. UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
  419. [self presentViewController:navController animated:YES completion:nil];
  420. return;
  421. }
  422. if (metadata.cryptated) nomeDir = [metadata.fileName substringToIndex:[metadata.fileName length]-6];
  423. else nomeDir = metadata.fileName;
  424. CCMove *viewController = [[UIStoryboard storyboardWithName:@"CCMove" bundle:nil] instantiateViewControllerWithIdentifier:@"CCMoveVC"];
  425. viewController.delegate = self.delegate;
  426. viewController.onlyClearDirectory = self.onlyClearDirectory;
  427. viewController.move.title = self.move.title;
  428. viewController.networkingOperationQueue = _networkingOperationQueue;
  429. viewController.passMetadata = metadata;
  430. viewController.serverUrl = [CCUtility stringAppendServerUrl:_serverUrl addFileName:nomeDir];
  431. [self.navigationController pushViewController:viewController animated:YES];
  432. }
  433. }
  434. @end