ShareViewController.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. //
  2. // ShareViewController.m
  3. // Crypto Cloud Technology Nextcloud
  4. //
  5. // Created by Marino Faggiana on 26/01/16.
  6. // Copyright (c) 2014 TWS. All rights reserved.
  7. //
  8. // Author Marino Faggiana <m.faggiana@twsweb.it>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. #import "ShareViewController.h"
  24. #ifdef CUSTOM_BUILD
  25. #import "CustomSwiftShare.h"
  26. #else
  27. #import "Share-Swift.h"
  28. #endif
  29. @import MobileCoreServices;
  30. @interface ShareViewController ()
  31. {
  32. NSURL *dirGroup;
  33. NSUInteger totalSize;
  34. NSExtensionItem *inputItem;
  35. CCMetadata *saveMetadataPlist;
  36. UIColor *barTintColor;
  37. UIColor *tintColor;
  38. NSMutableArray *_filesSendCryptated;
  39. BOOL _isCryptoCloudMode;
  40. }
  41. @end
  42. @implementation ShareViewController
  43. #pragma --------------------------------------------------------------------------------------------
  44. #pragma mark ===== View =====
  45. #pragma --------------------------------------------------------------------------------------------
  46. -(void)viewDidLoad
  47. {
  48. dirGroup = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:k_capabilitiesGroups];
  49. [MagicalRecord setupCoreDataStackWithAutoMigratingSqliteStoreNamed:(id)[dirGroup URLByAppendingPathComponent:[appDatabase stringByAppendingPathComponent:@"cryptocloud"]]];
  50. [MagicalRecord setLoggingLevel:MagicalRecordLoggingLevelOff];
  51. TableAccount *recordAccount = [CCCoreData getActiveAccount];
  52. if (recordAccount == nil) {
  53. // close now
  54. [self performSelector:@selector(closeShareViewController) withObject:nil afterDelay:0.1];
  55. return;
  56. } else {
  57. _activeAccount = recordAccount.account;
  58. _activePassword = recordAccount.password;
  59. _activeUrl = recordAccount.url;
  60. _activeUser = recordAccount.user;
  61. _directoryUser = [CCUtility getDirectoryActiveUser:self.activeUser activeUrl:self.activeUrl];
  62. if ([[CCUtility getKeyChainPasscodeForUUID:[CCUtility getUUID]] length] == 0) {
  63. _isCryptoCloudMode = NO;
  64. } else {
  65. _isCryptoCloudMode = YES;
  66. }
  67. if ([_activeAccount isEqualToString:[CCUtility getActiveAccountShareExt]]) {
  68. // load
  69. _serverUrl = [CCUtility getServerUrlShareExt];
  70. _destinyFolderButton.title = [NSString stringWithFormat:NSLocalizedString(@"_destiny_folder_", nil), [CCUtility getTitleServerUrlShareExt]];
  71. if (_isCryptoCloudMode)
  72. _localCryptated = [CCUtility getCryptatedShareExt];
  73. } else {
  74. // Default settings
  75. [CCUtility setActiveAccountShareExt:self.activeAccount];
  76. _serverUrl = [CCUtility getHomeServerUrlActiveUrl:self.activeUrl];
  77. [CCUtility setServerUrlShareExt:_serverUrl];
  78. _destinyFolderButton.title = [NSString stringWithFormat:NSLocalizedString(@"_destiny_folder_", nil), NSLocalizedString(@"_home_", nil)];
  79. [CCUtility setTitleServerUrlShareExt:NSLocalizedString(@"_home_", nil)];
  80. _localCryptated = NO;
  81. [CCUtility setCryptatedShareExt:NO];
  82. }
  83. }
  84. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(triggerProgressTask:) name:@"NotificationProgressTask" object:nil];
  85. _filesName = [[NSMutableArray alloc] init];
  86. _filesSendCryptated = [[NSMutableArray alloc] init];
  87. _hud = [[CCHud alloc] initWithView:self.navigationController.view];
  88. _networkingOperationQueue = [NSOperationQueue new];
  89. _networkingOperationQueue.name = k_queue;
  90. _networkingOperationQueue.maxConcurrentOperationCount = 1;
  91. [[CCNetworking sharedNetworking] settingDelegate:self];
  92. [self.shareTable registerNib:[UINib nibWithNibName:@"CCCellShareExt" bundle:nil] forCellReuseIdentifier:@"ShareExtCell"];
  93. [self navigationBarToolBar];
  94. [self loadDataSwift];
  95. }
  96. // Apparirà
  97. - (void)viewWillAppear:(BOOL)animated
  98. {
  99. [super viewWillAppear:animated];
  100. if ([[CCUtility getBlockCode] length] > 0 && [CCUtility getOnlyLockDir] == NO)
  101. [self openBKPasscode];
  102. }
  103. - (void)didReceiveMemoryWarning
  104. {
  105. [super didReceiveMemoryWarning];
  106. // Dispose of any resources that can be recreated.
  107. }
  108. - (void)closeShareViewController
  109. {
  110. [self.extensionContext completeRequestReturningItems:@[] completionHandler:nil];
  111. }
  112. //
  113. // L'applicazione terminerà
  114. //
  115. - (void)applicationWillTerminate:(UIApplication *)application
  116. {
  117. NSLog(@"[LOG] bye bye, Crypto Cloud Share Extension!");
  118. }
  119. #pragma --------------------------------------------------------------------------------------------
  120. #pragma mark == Action ==
  121. #pragma --------------------------------------------------------------------------------------------
  122. - (void)navigationBarToolBar
  123. {
  124. UIBarButtonItem *rightButtonUpload, *rightButtonEncrypt, *leftButtonCancel;
  125. self.navigationController.navigationBar.barTintColor = COLOR_NAVIGATIONBAR;
  126. self.navigationController.navigationBar.tintColor = COLOR_NAVIGATIONBAR_TEXT;
  127. self.toolBar.barTintColor = COLOR_TABBAR;
  128. self.toolBar.tintColor = COLOR_TABBAR_TEXT;
  129. // Upload
  130. if (self.localCryptated && _isCryptoCloudMode) {
  131. rightButtonUpload = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"_save_encrypted_", nil) style:UIBarButtonItemStylePlain target:self action:@selector(selectPost)];
  132. [rightButtonUpload setTintColor:COLOR_CRYPTOCLOUD];
  133. } else {
  134. rightButtonUpload = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"_save_", nil) style:UIBarButtonItemStylePlain target:self action:@selector(selectPost)];
  135. }
  136. // Encrypt ICON
  137. if (_isCryptoCloudMode) {
  138. UIImage *icon = [[UIImage imageNamed:image_shareExtEncrypt] imageWithRenderingMode:UIImageRenderingModeAutomatic];
  139. rightButtonEncrypt = [[UIBarButtonItem alloc] initWithImage:icon style:UIBarButtonItemStylePlain target:self action:@selector(changeEncrypt)];
  140. if (self.localCryptated) [rightButtonEncrypt setTintColor:COLOR_CRYPTOCLOUD];
  141. }
  142. // Cancel
  143. leftButtonCancel = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIBarButtonItemStylePlain target:self action:@selector(cancelPost)];
  144. // Title
  145. [self.navigationController.navigationBar setTitleTextAttributes: @{NSForegroundColorAttributeName:self.navigationController.navigationBar.tintColor}];
  146. self.navigationItem.title = k_brand;
  147. self.navigationItem.leftBarButtonItem = leftButtonCancel;
  148. self.navigationItem.rightBarButtonItems = [[NSArray alloc] initWithObjects:rightButtonUpload, rightButtonEncrypt, nil];
  149. self.navigationItem.hidesBackButton = YES;
  150. }
  151. - (void)moveServerUrlTo:(NSString *)serverUrlTo title:(NSString *)title selectedMetadatas:(NSArray *)selectedMetadatas
  152. {
  153. if (serverUrlTo)
  154. _serverUrl = serverUrlTo;
  155. if (title) {
  156. self.destinyFolderButton.title = [NSString stringWithFormat:NSLocalizedString(@"_destiny_folder_", nil), title];
  157. [CCUtility setTitleServerUrlShareExt:title];
  158. } else {
  159. self.destinyFolderButton.title = [NSString stringWithFormat:NSLocalizedString(@"_destiny_folder_", nil), NSLocalizedString(@"_home_", nil)];
  160. [CCUtility setTitleServerUrlShareExt:NSLocalizedString(@"_home_", nil)];
  161. }
  162. [CCUtility setActiveAccountShareExt:self.activeAccount];
  163. [CCUtility setServerUrlShareExt:_serverUrl];
  164. }
  165. - (IBAction)destinyFolderButtonTapped:(UIBarButtonItem *)sender
  166. {
  167. UINavigationController* navigationController = [[UIStoryboard storyboardWithName:@"CCMove" bundle:nil] instantiateViewControllerWithIdentifier:@"CCMove"];
  168. CCMove *viewController = (CCMove *)navigationController.topViewController;
  169. viewController.delegate = self;
  170. viewController.move.title = NSLocalizedString(@"_select_", nil);
  171. viewController.tintColor = tintColor;
  172. viewController.barTintColor = barTintColor;
  173. viewController.tintColorTitle = tintColor;
  174. viewController.networkingOperationQueue = _networkingOperationQueue;
  175. [navigationController setModalPresentationStyle:UIModalPresentationFormSheet];
  176. [self presentViewController:navigationController animated:YES completion:nil];
  177. }
  178. - (void)selectPost
  179. {
  180. if ([self.filesName count] > 0) {
  181. NSString *fileName = [self.filesName objectAtIndex:0];
  182. CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:_activeAccount];
  183. metadataNet.action = actionUploadFile;
  184. metadataNet.cryptated = _localCryptated;
  185. metadataNet.fileName = fileName;
  186. metadataNet.fileNamePrint = fileName;
  187. metadataNet.serverUrl = _serverUrl;
  188. metadataNet.session = k_upload_session_foreground;
  189. metadataNet.taskStatus = k_taskStatusResume;
  190. [self addNetworkingQueue:metadataNet];
  191. [self.hud visibleHudTitle:NSLocalizedString(@"_uploading_", nil) mode:MBProgressHUDModeDeterminateHorizontalBar color:self.view.tintColor];
  192. [self.hud AddButtonCancelWithTarget:self selector:@"cancelTransfer"];
  193. }
  194. else
  195. [self closeShareViewController];
  196. }
  197. - (void)cancelPost
  198. {
  199. // rimuoviamo i file+ico
  200. for (NSString *fileName in self.filesName) {
  201. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", self.directoryUser, fileName] error:nil];
  202. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.ico", self.directoryUser, fileName] error:nil];
  203. }
  204. [self closeShareViewController];
  205. }
  206. - (void)changeEncrypt
  207. {
  208. if (self.localCryptated) self.localCryptated = NO;
  209. else self.localCryptated = YES;
  210. [CCUtility setCryptatedShareExt:self.localCryptated];
  211. [self navigationBarToolBar];
  212. }
  213. - (void)cancelTransfer
  214. {
  215. [_networkingOperationQueue cancelAllOperations];
  216. }
  217. #pragma --------------------------------------------------------------------------------------------
  218. #pragma mark ======================= NetWorking ==================================
  219. #pragma --------------------------------------------------------------------------------------------
  220. - (void)triggerProgressTask:(NSNotification *)notification
  221. {
  222. NSDictionary *dict = notification.userInfo;
  223. float progress = [[dict valueForKey:@"progress"] floatValue];
  224. [self.hud progress:progress];
  225. }
  226. - (void)uploadFileFailure:(CCMetadataNet *)metadataNet fileID:(NSString *)fileID serverUrl:(NSString *)serverUrl selector:(NSString *)selector message:(NSString *)message errorCode:(NSInteger)errorCode
  227. {
  228. [self.hud hideHud];
  229. // remove file
  230. [CCCoreData deleteMetadataWithPredicate:[NSPredicate predicateWithFormat:@"(fileID == %@) AND (account == %@)", fileID, _activeAccount]];
  231. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", _directoryUser, fileID] error:nil];
  232. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.ico", _directoryUser, fileID] error:nil];
  233. // message error
  234. if (errorCode != kCFURLErrorCancelled) {
  235. UIAlertController * alert= [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_", nil) message:message preferredStyle:UIAlertControllerStyleAlert];
  236. UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
  237. handler:^(UIAlertAction * action) {
  238. [alert dismissViewControllerAnimated:YES completion:nil];
  239. [self closeShareViewController];
  240. }];
  241. [alert addAction:ok];
  242. [self presentViewController:alert animated:YES completion:nil];
  243. }
  244. else
  245. [self closeShareViewController];
  246. }
  247. - (void)uploadFileSuccess:(CCMetadataNet *)metadataNet fileID:(NSString *)fileID serverUrl:(NSString *)serverUrl selector:(NSString *)selector selectorPost:(NSString *)selectorPost
  248. {
  249. [self.hud hideHud];
  250. CCMetadata *metadata = [CCCoreData getMetadataWithPreficate:[NSPredicate predicateWithFormat:@"(fileID == %@) AND (account == %@)", fileID, _activeAccount] context:nil];
  251. [self.filesName removeObject:metadata.fileNamePrint];
  252. [self.shareTable performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
  253. [self performSelector:@selector(selectPost) withObject:nil afterDelay:0.1];
  254. }
  255. - (void)addNetworkingQueue:(CCMetadataNet *)metadataNet
  256. {
  257. id operation;
  258. operation = [[OCnetworking alloc] initWithDelegate:self metadataNet:metadataNet withUser:_activeUser withPassword:_activePassword withUrl:_activeUrl isCryptoCloudMode:_isCryptoCloudMode];
  259. [operation setQueuePriority:metadataNet.priority];
  260. [_networkingOperationQueue addOperation:operation];
  261. }
  262. #pragma --------------------------------------------------------------------------------------------
  263. #pragma mark ===== Lock Password =====
  264. #pragma --------------------------------------------------------------------------------------------
  265. - (void)openBKPasscode
  266. {
  267. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  268. viewController.delegate = self;
  269. viewController.type = BKPasscodeViewControllerCheckPasscodeType;
  270. viewController.inputViewTitlePassword = YES;
  271. if ([CCUtility getSimplyBlockCode]) {
  272. viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
  273. viewController.passcodeInputView.maximumLength = 6;
  274. } else {
  275. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  276. viewController.passcodeInputView.maximumLength = 64;
  277. }
  278. BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:k_serviceShareKeyChain];
  279. touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
  280. viewController.touchIDManager = touchIDManager;
  281. viewController.title = k_brand;
  282. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  283. viewController.navigationItem.leftBarButtonItem.tintColor = COLOR_CRYPTOCLOUD;
  284. UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
  285. [self presentViewController:navController animated:YES completion:nil];
  286. }
  287. - (NSUInteger)passcodeViewControllerNumberOfFailedAttempts:(CCBKPasscode *)aViewController
  288. {
  289. return self.failedAttempts;
  290. }
  291. - (NSDate *)passcodeViewControllerLockUntilDate:(CCBKPasscode *)aViewController
  292. {
  293. return self.lockUntilDate;
  294. }
  295. - (void)passcodeViewCloseButtonPressed:(id)sender
  296. {
  297. [self dismissViewControllerAnimated:YES completion:^{
  298. [self performSelector:@selector(closeShareViewController) withObject:nil];
  299. }];
  300. }
  301. - (void)passcodeViewController:(CCBKPasscode *)aViewController authenticatePasscode:(NSString *)aPasscode resultHandler:(void (^)(BOOL))aResultHandler
  302. {
  303. if ([aPasscode isEqualToString:[CCUtility getBlockCode]]) {
  304. self.lockUntilDate = nil;
  305. self.failedAttempts = 0;
  306. aResultHandler(YES);
  307. } else aResultHandler(NO);
  308. }
  309. - (void)passcodeViewController:(CCBKPasscode *)aViewController didFinishWithPasscode:(NSString *)aPasscode
  310. {
  311. [aViewController dismissViewControllerAnimated:YES completion:nil];
  312. }
  313. #pragma --------------------------------------------------------------------------------------------
  314. #pragma mark ===== Swipe Table DELETE -> menu =====
  315. #pragma--------------------------------------------------------------------------------------------
  316. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
  317. {
  318. [self setEditing:NO animated:YES];
  319. NSString *fileName = [self.filesName objectAtIndex:indexPath.row];
  320. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", self.directoryUser, fileName] error:nil];
  321. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.ico", self.directoryUser, fileName] error:nil];
  322. [self.filesName removeObjectAtIndex:indexPath.row];
  323. if ([self.filesName count] == 0) [self closeShareViewController];
  324. else [self.shareTable performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
  325. }
  326. #pragma --------------------------------------------------------------------------------------------
  327. #pragma mark == Table ==
  328. #pragma --------------------------------------------------------------------------------------------
  329. - (void)loadDataSwift
  330. {
  331. CCloadItemData *loadItem = [[CCloadItemData alloc] init];
  332. [loadItem loadFiles:self.directoryUser extensionContext:self.extensionContext vc:self];
  333. }
  334. - (void)reloadData:(NSArray *)files
  335. {
  336. totalSize = 0;
  337. for (NSString *file in files) {
  338. NSUInteger fileSize = (NSInteger)[[[NSFileManager defaultManager] attributesOfItemAtPath:[NSString stringWithFormat:@"%@/%@", self.directoryUser, file] error:nil] fileSize];
  339. totalSize += fileSize;
  340. // creiamo l'ICO
  341. CFStringRef fileExtension = (__bridge CFStringRef)[file pathExtension];
  342. CFStringRef fileUTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension, NULL);
  343. if (fileSize > 0 && ((UTTypeConformsTo(fileUTI, kUTTypeImage)) || (UTTypeConformsTo(fileUTI, kUTTypeMovie)))) {
  344. NSString *typeFile;
  345. if (UTTypeConformsTo(fileUTI, kUTTypeImage)) typeFile = k_metadataTypeFile_image;
  346. if (UTTypeConformsTo(fileUTI, kUTTypeMovie)) typeFile = k_metadataTypeFile_video;
  347. [CCGraphics createNewImageFrom:file directoryUser:self.directoryUser fileNameTo:file fileNamePrint:nil size:@"m" imageForUpload:NO typeFile:typeFile writePreview:YES optimizedFileName:NO];
  348. }
  349. }
  350. if (totalSize > 0) {
  351. self.filesName = [[NSMutableArray alloc] initWithArray:files];
  352. [self.shareTable reloadData];
  353. } else {
  354. [self closeShareViewController];
  355. }
  356. }
  357. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  358. {
  359. return 80;
  360. }
  361. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  362. {
  363. return 1;
  364. }
  365. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  366. {
  367. return [self.filesName count];
  368. }
  369. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  370. {
  371. NSString *fileName = [self.filesName objectAtIndex:indexPath.row];
  372. UIImage *image = nil;
  373. CFStringRef fileExtension = (__bridge CFStringRef)[fileName pathExtension];
  374. CFStringRef fileUTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension, NULL);
  375. if (UTTypeConformsTo(fileUTI, kUTTypeZipArchive) && [(__bridge NSString *)fileUTI containsString:@"org.openxmlformats"] == NO) image = [UIImage imageNamed:image_file_compress];
  376. else if (UTTypeConformsTo(fileUTI, kUTTypeAudio)) image = [UIImage imageNamed:image_file_audio];
  377. else if ((UTTypeConformsTo(fileUTI, kUTTypeImage)) || (UTTypeConformsTo(fileUTI, kUTTypeMovie))) {
  378. image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.ico", self.directoryUser, fileName]];
  379. }
  380. else if (UTTypeConformsTo(fileUTI, kUTTypeContent)) {
  381. image = [UIImage imageNamed:image_document];
  382. NSString *typeFile = (__bridge NSString *)fileUTI;
  383. if ([typeFile isEqualToString:@"com.adobe.pdf"]) image = [UIImage imageNamed:image_file_pdf];
  384. if ([typeFile isEqualToString:@"org.openxmlformats.spreadsheetml.sheet"]) image = [UIImage imageNamed:image_file_xls];
  385. if ([typeFile isEqualToString:@"public.plain-text"]) image = [UIImage imageNamed:image_file_txt];
  386. }
  387. else image = [UIImage imageNamed:image_file];
  388. CCCellShareExt *cell = (CCCellShareExt *)[tableView dequeueReusableCellWithIdentifier:@"ShareExtCell" forIndexPath:indexPath];
  389. NSUInteger fileSize = (NSInteger)[[[NSFileManager defaultManager] attributesOfItemAtPath:[NSString stringWithFormat:@"%@/%@", self.directoryUser, fileName] error:nil] fileSize];
  390. cell.labelInformazioni.text = [NSString stringWithFormat:@"%@\r\r%@", fileName, [CCUtility transformedSize:fileSize]];
  391. cell.labelInformazioni.textColor = [UIColor blackColor];
  392. cell.fileImageView.image = image;
  393. return cell;
  394. }
  395. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  396. {
  397. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  398. }
  399. @end