ShareViewController.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  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 "Share_Ext_Nextcloud_Custom-Swift.h"
  26. #else
  27. #import "Share_Ext_Nextcloud-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. _filesName = [[NSMutableArray alloc] init];
  85. _filesSendCryptated = [[NSMutableArray alloc] init];
  86. _hud = [[CCHud alloc] initWithView:self.navigationController.view];
  87. _networkingOperationQueue = [NSOperationQueue new];
  88. _networkingOperationQueue.name = k_netQueueName;
  89. _networkingOperationQueue.maxConcurrentOperationCount = 1;
  90. [[CCNetworking sharedNetworking] settingDelegate:self];
  91. [self.shareTable registerNib:[UINib nibWithNibName:@"CCCellShareExt" bundle:nil] forCellReuseIdentifier:@"ShareExtCell"];
  92. [self navigationBarToolBar];
  93. [self loadDataSwift];
  94. }
  95. // Apparirà
  96. - (void)viewWillAppear:(BOOL)animated
  97. {
  98. [super viewWillAppear:animated];
  99. if ([[CCUtility getBlockCode] length] > 0 && [CCUtility getOnlyLockDir] == NO)
  100. [self openBKPasscode];
  101. }
  102. - (void)didReceiveMemoryWarning
  103. {
  104. [super didReceiveMemoryWarning];
  105. // Dispose of any resources that can be recreated.
  106. }
  107. - (void)closeShareViewController
  108. {
  109. [self.extensionContext completeRequestReturningItems:@[] completionHandler:nil];
  110. }
  111. //
  112. // L'applicazione terminerà
  113. //
  114. - (void)applicationWillTerminate:(UIApplication *)application
  115. {
  116. NSLog(@"[LOG] bye bye, Crypto Cloud Share Extension!");
  117. }
  118. #pragma --------------------------------------------------------------------------------------------
  119. #pragma mark == Action ==
  120. #pragma --------------------------------------------------------------------------------------------
  121. - (void)navigationBarToolBar
  122. {
  123. UIBarButtonItem *rightButtonUpload, *rightButtonEncrypt, *leftButtonCancel;
  124. self.navigationController.navigationBar.barTintColor = COLOR_NAVIGATIONBAR;
  125. self.navigationController.navigationBar.tintColor = COLOR_NAVIGATIONBAR_TEXT;
  126. self.toolBar.barTintColor = COLOR_TABBAR;
  127. self.toolBar.tintColor = COLOR_TABBAR_TEXT;
  128. // Upload
  129. if (self.localCryptated && _isCryptoCloudMode) {
  130. rightButtonUpload = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"_save_encrypted_", nil) style:UIBarButtonItemStylePlain target:self action:@selector(selectPost)];
  131. [rightButtonUpload setTintColor:COLOR_CRYPTOCLOUD];
  132. } else {
  133. rightButtonUpload = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"_save_", nil) style:UIBarButtonItemStylePlain target:self action:@selector(selectPost)];
  134. }
  135. // Encrypt ICON
  136. if (_isCryptoCloudMode) {
  137. UIImage *icon = [[UIImage imageNamed:image_shareExtEncrypt] imageWithRenderingMode:UIImageRenderingModeAutomatic];
  138. rightButtonEncrypt = [[UIBarButtonItem alloc] initWithImage:icon style:UIBarButtonItemStylePlain target:self action:@selector(changeEncrypt)];
  139. if (self.localCryptated) [rightButtonEncrypt setTintColor:COLOR_CRYPTOCLOUD];
  140. }
  141. // Cancel
  142. leftButtonCancel = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIBarButtonItemStylePlain target:self action:@selector(cancelPost)];
  143. // Title
  144. [self.navigationController.navigationBar setTitleTextAttributes: @{NSForegroundColorAttributeName:self.navigationController.navigationBar.tintColor}];
  145. self.navigationItem.title = @"Nextcloud";
  146. self.navigationItem.leftBarButtonItem = leftButtonCancel;
  147. self.navigationItem.rightBarButtonItems = [[NSArray alloc] initWithObjects:rightButtonUpload, rightButtonEncrypt, nil];
  148. self.navigationItem.hidesBackButton = YES;
  149. }
  150. - (void)moveServerUrlTo:(NSString *)serverUrlTo title:(NSString *)title selectedMetadatas:(NSArray *)selectedMetadatas
  151. {
  152. if (serverUrlTo)
  153. _serverUrl = serverUrlTo;
  154. if (title) {
  155. self.destinyFolderButton.title = [NSString stringWithFormat:NSLocalizedString(@"_destiny_folder_", nil), title];
  156. [CCUtility setTitleServerUrlShareExt:title];
  157. } else {
  158. self.destinyFolderButton.title = [NSString stringWithFormat:NSLocalizedString(@"_destiny_folder_", nil), NSLocalizedString(@"_home_", nil)];
  159. [CCUtility setTitleServerUrlShareExt:NSLocalizedString(@"_home_", nil)];
  160. }
  161. [CCUtility setActiveAccountShareExt:self.activeAccount];
  162. [CCUtility setServerUrlShareExt:_serverUrl];
  163. }
  164. - (IBAction)destinyFolderButtonTapped:(UIBarButtonItem *)sender
  165. {
  166. UINavigationController* navigationController = [[UIStoryboard storyboardWithName:@"CCMove" bundle:nil] instantiateViewControllerWithIdentifier:@"CCMove"];
  167. CCMove *viewController = (CCMove *)navigationController.topViewController;
  168. viewController.delegate = self;
  169. viewController.move.title = NSLocalizedString(@"_select_", nil);
  170. viewController.tintColor = tintColor;
  171. viewController.barTintColor = barTintColor;
  172. viewController.tintColorTitle = tintColor;
  173. viewController.networkingOperationQueue = _networkingOperationQueue;
  174. [navigationController setModalPresentationStyle:UIModalPresentationFormSheet];
  175. [self presentViewController:navigationController animated:YES completion:nil];
  176. }
  177. - (void)selectPost
  178. {
  179. if ([self.filesName count] > 0) {
  180. NSString *fileName = [self.filesName objectAtIndex:0];
  181. CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:_activeAccount];
  182. metadataNet.action = actionUploadFile;
  183. metadataNet.cryptated = _localCryptated;
  184. metadataNet.fileName = fileName;
  185. metadataNet.fileNamePrint = fileName;
  186. metadataNet.serverUrl = _serverUrl;
  187. metadataNet.session = k_upload_session_foreground;
  188. metadataNet.taskStatus = k_taskStatusResume;
  189. [self addNetworkingQueue:metadataNet];
  190. [self.hud visibleHudTitle:NSLocalizedString(@"_uploading_", nil) mode:MBProgressHUDModeDeterminateHorizontalBar color:self.view.tintColor];
  191. [self.hud AddButtonCancelWithTarget:self selector:@"cancelTransfer"];
  192. }
  193. else
  194. [self closeShareViewController];
  195. }
  196. - (void)cancelPost
  197. {
  198. // rimuoviamo i file+ico
  199. for (NSString *fileName in self.filesName) {
  200. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", self.directoryUser, fileName] error:nil];
  201. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.ico", self.directoryUser, fileName] error:nil];
  202. }
  203. [self closeShareViewController];
  204. }
  205. - (void)changeEncrypt
  206. {
  207. if (self.localCryptated) self.localCryptated = NO;
  208. else self.localCryptated = YES;
  209. [CCUtility setCryptatedShareExt:self.localCryptated];
  210. [self navigationBarToolBar];
  211. }
  212. - (void)cancelTransfer
  213. {
  214. [_networkingOperationQueue cancelAllOperations];
  215. }
  216. #pragma --------------------------------------------------------------------------------------------
  217. #pragma mark ======================= NetWorking ==================================
  218. #pragma --------------------------------------------------------------------------------------------
  219. - (void)progressTask:(NSString *)fileID serverUrl:(NSString *)serverUrl cryptated:(BOOL)cryptated progress:(float)progress
  220. {
  221. [self.hud progress:progress];
  222. }
  223. - (void)uploadFileFailure:(CCMetadataNet *)metadataNet fileID:(NSString *)fileID serverUrl:(NSString *)serverUrl selector:(NSString *)selector message:(NSString *)message errorCode:(NSInteger)errorCode
  224. {
  225. [self.hud hideHud];
  226. // remove file
  227. [CCCoreData deleteMetadataWithPredicate:[NSPredicate predicateWithFormat:@"(fileID == %@) AND (account == %@)", fileID, _activeAccount]];
  228. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", _directoryUser, fileID] error:nil];
  229. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.ico", _directoryUser, fileID] error:nil];
  230. // message error
  231. if (errorCode != kCFURLErrorCancelled) {
  232. UIAlertController * alert= [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_", nil) message:message preferredStyle:UIAlertControllerStyleAlert];
  233. UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
  234. handler:^(UIAlertAction * action) {
  235. [alert dismissViewControllerAnimated:YES completion:nil];
  236. [self closeShareViewController];
  237. }];
  238. [alert addAction:ok];
  239. [self presentViewController:alert animated:YES completion:nil];
  240. }
  241. else
  242. [self closeShareViewController];
  243. }
  244. - (void)uploadFileSuccess:(CCMetadataNet *)metadataNet fileID:(NSString *)fileID serverUrl:(NSString *)serverUrl selector:(NSString *)selector selectorPost:(NSString *)selectorPost
  245. {
  246. [self.hud hideHud];
  247. CCMetadata *metadata = [CCCoreData getMetadataWithPreficate:[NSPredicate predicateWithFormat:@"(fileID == %@) AND (account == %@)", fileID, _activeAccount] context:nil];
  248. [self.filesName removeObject:metadata.fileNamePrint];
  249. [self.shareTable performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
  250. [self performSelector:@selector(selectPost) withObject:nil afterDelay:0.1];
  251. }
  252. - (void)addNetworkingQueue:(CCMetadataNet *)metadataNet
  253. {
  254. id operation;
  255. operation = [[OCnetworking alloc] initWithDelegate:self metadataNet:metadataNet withUser:_activeUser withPassword:_activePassword withUrl:_activeUrl isCryptoCloudMode:_isCryptoCloudMode];
  256. [operation setQueuePriority:metadataNet.priority];
  257. [_networkingOperationQueue addOperation:operation];
  258. }
  259. #pragma --------------------------------------------------------------------------------------------
  260. #pragma mark ===== Lock Password =====
  261. #pragma --------------------------------------------------------------------------------------------
  262. - (void)openBKPasscode
  263. {
  264. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  265. viewController.delegate = self;
  266. viewController.type = BKPasscodeViewControllerCheckPasscodeType;
  267. viewController.inputViewTitlePassword = YES;
  268. if ([CCUtility getSimplyBlockCode]) {
  269. viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
  270. viewController.passcodeInputView.maximumLength = 6;
  271. } else {
  272. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  273. viewController.passcodeInputView.maximumLength = 64;
  274. }
  275. BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:BKPasscodeKeychainServiceName];
  276. touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
  277. viewController.touchIDManager = touchIDManager;
  278. viewController.title = @"Nextcloud";
  279. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  280. viewController.navigationItem.leftBarButtonItem.tintColor = COLOR_CRYPTOCLOUD;
  281. UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
  282. [self presentViewController:navController animated:YES completion:nil];
  283. }
  284. - (NSUInteger)passcodeViewControllerNumberOfFailedAttempts:(CCBKPasscode *)aViewController
  285. {
  286. return self.failedAttempts;
  287. }
  288. - (NSDate *)passcodeViewControllerLockUntilDate:(CCBKPasscode *)aViewController
  289. {
  290. return self.lockUntilDate;
  291. }
  292. - (void)passcodeViewCloseButtonPressed:(id)sender
  293. {
  294. [self dismissViewControllerAnimated:YES completion:^{
  295. [self performSelector:@selector(closeShareViewController) withObject:nil];
  296. }];
  297. }
  298. - (void)passcodeViewController:(CCBKPasscode *)aViewController authenticatePasscode:(NSString *)aPasscode resultHandler:(void (^)(BOOL))aResultHandler
  299. {
  300. if ([aPasscode isEqualToString:[CCUtility getBlockCode]]) {
  301. self.lockUntilDate = nil;
  302. self.failedAttempts = 0;
  303. aResultHandler(YES);
  304. } else aResultHandler(NO);
  305. }
  306. - (void)passcodeViewController:(CCBKPasscode *)aViewController didFinishWithPasscode:(NSString *)aPasscode
  307. {
  308. [aViewController dismissViewControllerAnimated:YES completion:nil];
  309. }
  310. #pragma --------------------------------------------------------------------------------------------
  311. #pragma mark ===== Swipe Table DELETE -> menu =====
  312. #pragma--------------------------------------------------------------------------------------------
  313. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
  314. {
  315. [self setEditing:NO animated:YES];
  316. NSString *fileName = [self.filesName objectAtIndex:indexPath.row];
  317. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", self.directoryUser, fileName] error:nil];
  318. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.ico", self.directoryUser, fileName] error:nil];
  319. [self.filesName removeObjectAtIndex:indexPath.row];
  320. if ([self.filesName count] == 0) [self closeShareViewController];
  321. else [self.shareTable performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
  322. }
  323. #pragma --------------------------------------------------------------------------------------------
  324. #pragma mark == Table ==
  325. #pragma --------------------------------------------------------------------------------------------
  326. - (void)loadDataSwift
  327. {
  328. CCloadItemData *loadItem = [[CCloadItemData alloc] init];
  329. [loadItem loadFiles:self.directoryUser extensionContext:self.extensionContext vc:self];
  330. }
  331. - (void)reloadData:(NSArray *)files
  332. {
  333. totalSize = 0;
  334. for (NSString *file in files) {
  335. NSUInteger fileSize = (NSInteger)[[[NSFileManager defaultManager] attributesOfItemAtPath:[NSString stringWithFormat:@"%@/%@", self.directoryUser, file] error:nil] fileSize];
  336. totalSize += fileSize;
  337. // creiamo l'ICO
  338. CFStringRef fileExtension = (__bridge CFStringRef)[file pathExtension];
  339. CFStringRef fileUTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension, NULL);
  340. if (fileSize > 0 && ((UTTypeConformsTo(fileUTI, kUTTypeImage)) || (UTTypeConformsTo(fileUTI, kUTTypeMovie)))) {
  341. NSString *typeFile;
  342. if (UTTypeConformsTo(fileUTI, kUTTypeImage)) typeFile = k_metadataTypeFile_image;
  343. if (UTTypeConformsTo(fileUTI, kUTTypeMovie)) typeFile = k_metadataTypeFile_video;
  344. [CCGraphics createNewImageFrom:file directoryUser:self.directoryUser fileNameTo:file fileNamePrint:nil size:@"m" imageForUpload:NO typeFile:typeFile writePreview:YES optimizedFileName:NO];
  345. }
  346. }
  347. if (totalSize > 0) {
  348. self.filesName = [[NSMutableArray alloc] initWithArray:files];
  349. [self.shareTable reloadData];
  350. } else {
  351. [self closeShareViewController];
  352. }
  353. }
  354. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  355. {
  356. return 80;
  357. }
  358. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  359. {
  360. return 1;
  361. }
  362. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  363. {
  364. return [self.filesName count];
  365. }
  366. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  367. {
  368. NSString *fileName = [self.filesName objectAtIndex:indexPath.row];
  369. UIImage *image = nil;
  370. CFStringRef fileExtension = (__bridge CFStringRef)[fileName pathExtension];
  371. CFStringRef fileUTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension, NULL);
  372. if (UTTypeConformsTo(fileUTI, kUTTypeZipArchive) && [(__bridge NSString *)fileUTI containsString:@"org.openxmlformats"] == NO) image = [UIImage imageNamed:image_typeFileCompress];
  373. else if (UTTypeConformsTo(fileUTI, kUTTypeAudio)) image = [UIImage imageNamed:image_audio];
  374. else if ((UTTypeConformsTo(fileUTI, kUTTypeImage)) || (UTTypeConformsTo(fileUTI, kUTTypeMovie))) {
  375. image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.ico", self.directoryUser, fileName]];
  376. }
  377. else if (UTTypeConformsTo(fileUTI, kUTTypeContent)) {
  378. image = [UIImage imageNamed:image_document];
  379. NSString *typeFile = (__bridge NSString *)fileUTI;
  380. if ([typeFile isEqualToString:@"com.adobe.pdf"]) image = [UIImage imageNamed:image_pdf];
  381. if ([typeFile isEqualToString:@"org.openxmlformats.spreadsheetml.sheet"]) image = [UIImage imageNamed:image_xls];
  382. if ([typeFile isEqualToString:@"public.plain-text"]) image = [UIImage imageNamed:image_txt];
  383. }
  384. else image = [UIImage imageNamed:image_file];
  385. CCCellShareExt *cell = (CCCellShareExt *)[tableView dequeueReusableCellWithIdentifier:@"ShareExtCell" forIndexPath:indexPath];
  386. NSUInteger fileSize = (NSInteger)[[[NSFileManager defaultManager] attributesOfItemAtPath:[NSString stringWithFormat:@"%@/%@", self.directoryUser, fileName] error:nil] fileSize];
  387. cell.labelInformazioni.text = [NSString stringWithFormat:@"%@\r\r%@", fileName, [CCUtility transformedSize:fileSize]];
  388. cell.labelInformazioni.textColor = [UIColor blackColor];
  389. cell.fileImageView.image = image;
  390. return cell;
  391. }
  392. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  393. {
  394. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  395. }
  396. @end