CCTransfers.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. //
  2. // CCTransfers.m
  3. // Nextcloud iOS
  4. //
  5. // Created by Marino Faggiana on 12/04/17.
  6. // Copyright (c) 2017 Marino Faggiana. All rights reserved.
  7. //
  8. // Author Marino Faggiana <marino.faggiana@nextcloud.com>
  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 "CCTransfers.h"
  24. #import "AppDelegate.h"
  25. #import "CCMain.h"
  26. #import "CCDetail.h"
  27. #import "CCSection.h"
  28. #import "CCCellMainTransfer.h"
  29. #import "NCBridgeSwift.h"
  30. #define download 1
  31. #define downloadwwan 2
  32. #define upload 3
  33. #define uploadwwan 4
  34. @interface CCTransfers ()
  35. {
  36. AppDelegate *appDelegate;
  37. // Datasource
  38. CCSectionDataSourceMetadata *sectionDataSource;
  39. }
  40. @end
  41. @implementation CCTransfers
  42. #pragma --------------------------------------------------------------------------------------------
  43. #pragma mark ===== Init =====
  44. #pragma --------------------------------------------------------------------------------------------
  45. - (id)initWithCoder:(NSCoder *)aDecoder
  46. {
  47. if (self = [super initWithCoder:aDecoder]) {
  48. appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  49. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(triggerProgressTask:) name:@"NotificationProgressTask" object:nil];
  50. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
  51. appDelegate.activeTransfers = self;
  52. }
  53. return self;
  54. }
  55. - (void)viewDidLoad {
  56. [super viewDidLoad];
  57. // Custom Cell
  58. [self.tableView registerNib:[UINib nibWithNibName:@"CCCellMain" bundle:nil] forCellReuseIdentifier:@"CellMain"];
  59. [self.tableView registerNib:[UINib nibWithNibName:@"CCCellMainTransfer" bundle:nil] forCellReuseIdentifier:@"CellMainTransfer"];
  60. self.tableView.delegate = self;
  61. self.tableView.dataSource = self;
  62. self.tableView.emptyDataSetDelegate = self;
  63. self.tableView.emptyDataSetSource = self;
  64. self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  65. self.tableView.backgroundColor = [NCBrandColor sharedInstance].backgroundView;
  66. self.title = NSLocalizedString(@"_transfers_", nil);
  67. [self reloadDatasource:nil action:k_action_NULL];
  68. }
  69. - (void)viewDidAppear:(BOOL)animated
  70. {
  71. [super viewDidAppear:animated];
  72. // Color
  73. [appDelegate aspectNavigationControllerBar:self.navigationController.navigationBar online:[appDelegate.reachability isReachable] hidden:NO];
  74. [appDelegate aspectTabBar:self.tabBarController.tabBar hidden:NO];
  75. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.001 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
  76. [self reloadDatasource:nil action:k_action_NULL];
  77. });
  78. }
  79. - (void)changeTheming
  80. {
  81. if (self.isViewLoaded && self.view.window)
  82. [appDelegate changeTheming:self];
  83. }
  84. #pragma --------------------------------------------------------------------------------------------
  85. #pragma mark ==== DZNEmptyDataSetSource ====
  86. #pragma --------------------------------------------------------------------------------------------
  87. - (CGFloat)spaceHeightForEmptyDataSet:(UIScrollView *)scrollView
  88. {
  89. return 0.0f;
  90. }
  91. - (UIColor *)backgroundColorForEmptyDataSet:(UIScrollView *)scrollView
  92. {
  93. return [UIColor whiteColor];
  94. }
  95. - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView
  96. {
  97. return [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"loadNoRecord"] multiplier:2 color:[NCBrandColor sharedInstance].graySoft];
  98. }
  99. - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView
  100. {
  101. NSString *text = [NSString stringWithFormat:@"%@", NSLocalizedString(@"_no_transfer_", nil)];
  102. NSDictionary *attributes = @{NSFontAttributeName:[UIFont boldSystemFontOfSize:20.0f], NSForegroundColorAttributeName:[UIColor lightGrayColor]};
  103. return [[NSAttributedString alloc] initWithString:text attributes:attributes];
  104. }
  105. - (NSAttributedString *)descriptionForEmptyDataSet:(UIScrollView *)scrollView
  106. {
  107. NSString *text = [NSString stringWithFormat:@"%@", NSLocalizedString(@"_no_transfer_sub_", nil)];
  108. NSMutableParagraphStyle *paragraph = [NSMutableParagraphStyle new];
  109. paragraph.lineBreakMode = NSLineBreakByWordWrapping;
  110. paragraph.alignment = NSTextAlignmentCenter;
  111. NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:14.0], NSForegroundColorAttributeName: [UIColor lightGrayColor], NSParagraphStyleAttributeName: paragraph};
  112. return [[NSAttributedString alloc] initWithString:text attributes:attributes];
  113. }
  114. #pragma --------------------------------------------------------------------------------------------
  115. #pragma mark - ===== Progress & Task Button =====
  116. #pragma --------------------------------------------------------------------------------------------
  117. - (void)triggerProgressTask:(NSNotification *)notification
  118. {
  119. [[NCMainCommon sharedInstance] triggerProgressTask:notification sectionDataSourceFileIDIndexPath:sectionDataSource.fileIDIndexPath tableView:self.tableView viewController:self serverUrlViewController:nil];
  120. }
  121. - (void)cancelTaskButton:(id)sender withEvent:(UIEvent *)event
  122. {
  123. UITouch * touch = [[event allTouches] anyObject];
  124. CGPoint location = [touch locationInView:self.tableView];
  125. NSIndexPath * indexPath = [self.tableView indexPathForRowAtPoint:location];
  126. if (indexPath) {
  127. NSString *fileID = [[sectionDataSource.sectionArrayRow objectForKey:[sectionDataSource.sections objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row];
  128. tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID = %@", fileID]];
  129. if (metadata)
  130. [[NCMainCommon sharedInstance] cancelTransferMetadata:metadata reloadDatasource:true];
  131. }
  132. }
  133. - (void)cancelAllTask:(id)sender
  134. {
  135. CGPoint location = [sender locationInView:self.tableView];
  136. NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:location];
  137. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  138. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_all_task_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  139. [[NCMainCommon sharedInstance] cancelAllTransferWithView:self.view];
  140. }]];
  141. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { }]];
  142. alertController.popoverPresentationController.sourceView = self.tableView;
  143. alertController.popoverPresentationController.sourceRect = [self.tableView rectForRowAtIndexPath:indexPath];
  144. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
  145. [alertController.view layoutIfNeeded];
  146. [self presentViewController:alertController animated:YES completion:nil];
  147. }
  148. #pragma --------------------------------------------------------------------------------------------
  149. #pragma mark - ==== Datasource ====
  150. #pragma --------------------------------------------------------------------------------------------
  151. - (void)reloadDatasource:(NSString *)fileID action:(NSInteger)action
  152. {
  153. // test
  154. if (appDelegate.activeAccount.length == 0 || self.view.window == nil)
  155. return;
  156. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  157. NSArray *recordsTableMetadata = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"(session CONTAINS 'upload') OR (session CONTAINS 'download')"] sorted:nil ascending:NO];
  158. CCSectionDataSourceMetadata *sectionDataSourceTemp = [CCSectionDataSourceMetadata new];
  159. sectionDataSourceTemp = [CCSectionMetadata creataDataSourseSectionMetadata:recordsTableMetadata listProgressMetadata:appDelegate.listProgressMetadata groupByField:@"session" filterFileID:appDelegate.filterFileID filterTypeFileImage:NO filterTypeFileVideo:NO sorted:@"sessionTaskIdentifier" ascending:NO activeAccount:appDelegate.activeAccount];
  160. dispatch_async(dispatch_get_main_queue(), ^{
  161. sectionDataSource = sectionDataSourceTemp;
  162. [self.tableView reloadData];
  163. });
  164. });
  165. }
  166. #pragma --------------------------------------------------------------------------------------------
  167. #pragma mark - ==== Table ====
  168. #pragma --------------------------------------------------------------------------------------------
  169. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  170. {
  171. return 60;
  172. }
  173. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  174. {
  175. return [[sectionDataSource.sectionArrayRow allKeys] count];
  176. }
  177. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  178. {
  179. return [[sectionDataSource.sectionArrayRow objectForKey:[sectionDataSource.sections objectAtIndex:section]] count];
  180. }
  181. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  182. {
  183. return 13.0f;
  184. }
  185. -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  186. {
  187. UIVisualEffectView *visualEffectView;
  188. NSString *titleSection, *numberTitle;
  189. NSInteger typeOfSession = 0;
  190. NSInteger queueDownload = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@ OR session == %@", k_download_session, k_download_session_foreground] sorted:nil ascending:NO] count];
  191. NSInteger queueDownloadWWan = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@", k_download_session_wwan] sorted:nil ascending:NO] count];
  192. NSInteger queueUpload = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@ OR session == %@", k_upload_session, k_upload_session_foreground] sorted:nil ascending:NO] count];
  193. NSInteger queueUploadWWan = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@", k_upload_session_wwan] sorted:nil ascending:NO] count];
  194. if ([[sectionDataSource.sections objectAtIndex:section] isKindOfClass:[NSString class]]) titleSection = [sectionDataSource.sections objectAtIndex:section];
  195. if ([[sectionDataSource.sections objectAtIndex:section] isKindOfClass:[NSDate class]]) titleSection = [CCUtility getTitleSectionDate:[sectionDataSource.sections objectAtIndex:section]];
  196. NSArray *metadatas = [sectionDataSource.sectionArrayRow objectForKey:[sectionDataSource.sections objectAtIndex:section]];
  197. NSUInteger rowsCount = [metadatas count];
  198. visualEffectView = [[UIVisualEffectView alloc] init];
  199. visualEffectView.backgroundColor = [UIColor clearColor];
  200. // title section
  201. if ([titleSection isEqualToString:@"_none_"]) {
  202. titleSection = @"";
  203. } else if ([titleSection containsString:@"download"] && ![titleSection containsString:@"wwan"]) {
  204. typeOfSession = download;
  205. titleSection = NSLocalizedString(@"_title_section_download_",nil);
  206. } else if ([titleSection containsString:@"download"] && [titleSection containsString:@"wwan"]) {
  207. typeOfSession = downloadwwan;
  208. titleSection = [NSLocalizedString(@"_title_section_download_",nil) stringByAppendingString:@" Wi-Fi"];
  209. } else if ([titleSection containsString:@"upload"] && ![titleSection containsString:@"wwan"]) {
  210. typeOfSession = upload;
  211. titleSection = NSLocalizedString(@"_title_section_upload_",nil);
  212. } else if ([titleSection containsString:@"upload"] && [titleSection containsString:@"wwan"]) {
  213. typeOfSession = uploadwwan;
  214. titleSection = [NSLocalizedString(@"_title_section_upload_",nil) stringByAppendingString:@" Wi-Fi"];
  215. } else {
  216. titleSection = NSLocalizedString(titleSection,nil);
  217. }
  218. // title label on left
  219. UILabel *titleLabel=[[UILabel alloc]initWithFrame:CGRectMake(8, 3, 0, 13)];
  220. titleLabel.textColor = [UIColor blackColor];
  221. titleLabel.font = [UIFont systemFontOfSize:9];
  222. titleLabel.textAlignment = NSTextAlignmentLeft;
  223. titleLabel.text = titleSection;
  224. titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  225. [visualEffectView.contentView addSubview:titleLabel];
  226. // element (s) on right
  227. UILabel *elementLabel=[[UILabel alloc]initWithFrame:CGRectMake(-8, 3, 0, 13)];
  228. elementLabel.textColor = [UIColor blackColor];
  229. elementLabel.font = [UIFont systemFontOfSize:9];
  230. elementLabel.textAlignment = NSTextAlignmentRight;
  231. elementLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  232. if ((typeOfSession == download && queueDownload > rowsCount) || (typeOfSession == downloadwwan && queueDownloadWWan > rowsCount) ||
  233. (typeOfSession == upload && queueUpload > rowsCount) || (typeOfSession == uploadwwan && queueUploadWWan > rowsCount)) {
  234. numberTitle = [NSString stringWithFormat:@"%lu+", (unsigned long)rowsCount];
  235. } else {
  236. numberTitle = [NSString stringWithFormat:@"%lu", (unsigned long)rowsCount];
  237. }
  238. if (rowsCount > 1)
  239. elementLabel.text = [NSString stringWithFormat:@"%@ %@", numberTitle, NSLocalizedString(@"_elements_",nil)];
  240. else
  241. elementLabel.text = [NSString stringWithFormat:@"%@ %@", numberTitle, NSLocalizedString(@"_element_",nil)];
  242. // view
  243. [visualEffectView.contentView addSubview:elementLabel];
  244. return visualEffectView;
  245. }
  246. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
  247. {
  248. NSString *titleSection;
  249. NSString *element_s;
  250. if ([[sectionDataSource.sections objectAtIndex:section] isKindOfClass:[NSString class]]) titleSection = [sectionDataSource.sections objectAtIndex:section];
  251. // Prepare view for title in footer
  252. UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
  253. UILabel *titleFooterLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 18)];
  254. titleFooterLabel.textColor = [UIColor blackColor];
  255. titleFooterLabel.font = [UIFont systemFontOfSize:12];
  256. titleFooterLabel.textAlignment = NSTextAlignmentCenter;
  257. // Footer Download
  258. if ([titleSection containsString:@"download"] && ![titleSection containsString:@"wwan"] && titleSection != nil) {
  259. NSInteger queueDownload = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@ OR session == %@", k_download_session, k_download_session_foreground] sorted:nil ascending:NO] count];
  260. // element or elements ?
  261. if (queueDownload > 1) element_s = NSLocalizedString(@"_elements_",nil);
  262. else element_s = NSLocalizedString(@"_element_",nil);
  263. // Num record to upload
  264. NSMutableAttributedString *stringFooter= [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:NSLocalizedString(@"_tite_footer_download_", nil), queueDownload, element_s]];
  265. titleFooterLabel.attributedText = stringFooter;
  266. [view addSubview:titleFooterLabel];
  267. return view;
  268. }
  269. // Footer Download WWAN
  270. if ([titleSection containsString:@"download"] && [titleSection containsString:@"wwan"] && titleSection != nil) {
  271. NSInteger queueDownloadWWan = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@", k_download_session_wwan] sorted:nil ascending:NO] count];
  272. // element or elements ?
  273. if (queueDownloadWWan > 1) element_s = NSLocalizedString(@"_elements_",nil);
  274. else element_s = NSLocalizedString(@"_element_",nil);
  275. // Add the symbol WiFi and Num record
  276. NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
  277. attachment.image = [UIImage imageNamed:@"WiFiSmall"];
  278. NSAttributedString *attachmentString = [NSAttributedString attributedStringWithAttachment:attachment];
  279. NSMutableAttributedString *stringFooter= [[NSMutableAttributedString alloc] initWithString:[@" " stringByAppendingString:[NSString stringWithFormat:NSLocalizedString(@"_tite_footer_download_wwan_", nil), queueDownloadWWan, element_s]]];
  280. [stringFooter insertAttributedString:attachmentString atIndex:0];
  281. titleFooterLabel.attributedText = stringFooter;
  282. [view addSubview:titleFooterLabel];
  283. return view;
  284. }
  285. // Footer Upload
  286. if ([titleSection containsString:@"upload"] && ![titleSection containsString:@"wwan"] && titleSection != nil) {
  287. NSInteger queueUpload = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@ OR session == %@", k_upload_session, k_upload_session_foreground] sorted:nil ascending:NO] count];
  288. // element or elements ?
  289. if (queueUpload > 1) element_s = NSLocalizedString(@"_elements_",nil);
  290. else element_s = NSLocalizedString(@"_element_",nil);
  291. // Num record to upload
  292. NSMutableAttributedString *stringFooter= [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:NSLocalizedString(@"_tite_footer_upload_", nil), queueUpload, element_s]];
  293. titleFooterLabel.attributedText = stringFooter;
  294. [view addSubview:titleFooterLabel];
  295. return view;
  296. }
  297. // Footer Upload WWAN
  298. if ([titleSection containsString:@"upload"] && [titleSection containsString:@"wwan"] && titleSection != nil) {
  299. NSInteger queueUploadWWan = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"session == %@", k_upload_session_wwan] sorted:nil ascending:NO] count];
  300. // element or elements ?
  301. if (queueUploadWWan > 1) element_s = NSLocalizedString(@"_elements_",nil);
  302. else element_s = NSLocalizedString(@"_element_",nil);
  303. // Add the symbol WiFi and Num record
  304. NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
  305. attachment.image = [UIImage imageNamed:@"WiFiSmall"];
  306. NSAttributedString *attachmentString = [NSAttributedString attributedStringWithAttachment:attachment];
  307. NSMutableAttributedString *stringFooter= [[NSMutableAttributedString alloc] initWithString:[@" " stringByAppendingString:[NSString stringWithFormat:NSLocalizedString(@"_tite_footer_upload_wwan_", nil), queueUploadWWan,element_s]]];
  308. [stringFooter insertAttributedString:attachmentString atIndex:0];
  309. titleFooterLabel.attributedText = stringFooter;
  310. [view addSubview:titleFooterLabel];
  311. return view;
  312. }
  313. return nil;
  314. }
  315. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  316. {
  317. //NSString *titleSection;
  318. //if ([[_sectionDataSource.sections objectAtIndex:section] isKindOfClass:[NSString class]])
  319. // titleSection = [_sectionDataSource.sections objectAtIndex:section];
  320. //if ([titleSection rangeOfString:@"upload"].location != NSNotFound && [titleSection rangeOfString:@"wwan"].location != NSNotFound && titleSection != nil) return 18.0f;
  321. //else return 0.0f;
  322. return 18.0f;
  323. }
  324. - (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
  325. {
  326. return [sectionDataSource.sections indexOfObject:title];
  327. }
  328. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  329. {
  330. NSString *fileID = [[sectionDataSource.sectionArrayRow objectForKey:[sectionDataSource.sections objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row];
  331. tableMetadata *metadata = [sectionDataSource.allRecordsDataSource objectForKey:fileID];
  332. if (metadata == nil || [[NCManageDatabase sharedInstance] isTableInvalidated:metadata]) {
  333. return [CCCellMainTransfer new];
  334. }
  335. tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", metadata.account, metadata.serverUrl]];
  336. if (directory == nil) {
  337. return [CCCellMainTransfer new];
  338. }
  339. tableMetadata *metadataFolder = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", directory.fileID]];
  340. UITableViewCell *cell = [[NCMainCommon sharedInstance] cellForRowAtIndexPath:indexPath tableView:tableView metadata:metadata metadataFolder:metadataFolder serverUrl:metadata.serverUrl autoUploadFileName:@"" autoUploadDirectory:@""];
  341. // TRANSFER
  342. if ([cell isKindOfClass:[CCCellMainTransfer class]]) {
  343. // gesture Transfer
  344. [((CCCellMainTransfer *)cell).transferButton.stopButton addTarget:self action:@selector(cancelTaskButton:withEvent:) forControlEvents:UIControlEventTouchUpInside];
  345. UILongPressGestureRecognizer *stopLongGesture = [UILongPressGestureRecognizer new];
  346. [stopLongGesture addTarget:self action:@selector(cancelAllTask:)];
  347. [((CCCellMainTransfer *)cell).transferButton.stopButton addGestureRecognizer:stopLongGesture];
  348. }
  349. return cell;
  350. }
  351. @end