CCDetail.m 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016
  1. //
  2. // CCDetail.m
  3. // Nextcloud iOS
  4. //
  5. // Created by Marino Faggiana on 16/01/15.
  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 "CCDetail.h"
  24. #import "AppDelegate.h"
  25. #import "CCMain.h"
  26. #import "NCUchardet.h"
  27. #import "NCBridgeSwift.h"
  28. #import "NCBridgeSwift.h"
  29. #define TOOLBAR_HEIGHT 49.0f
  30. #define alertRequestPasswordPDF 1
  31. @interface CCDetail () <NCTextDelegate, UIDocumentInteractionControllerDelegate>
  32. {
  33. AppDelegate *appDelegate;
  34. UIDocumentInteractionController *docController;
  35. UIBarButtonItem *buttonModifyTxt;
  36. UIBarButtonItem *buttonShare;
  37. UIBarButtonItem *buttonDelete;
  38. NSInteger indexNowVisible;
  39. NSString *fileIDNowVisible;
  40. NSString *fileNameExtension;
  41. }
  42. @end
  43. @implementation CCDetail
  44. #pragma --------------------------------------------------------------------------------------------
  45. #pragma mark ===== init =====
  46. #pragma --------------------------------------------------------------------------------------------
  47. - (id)initWithCoder:(NSCoder *)aDecoder
  48. {
  49. if (self = [super initWithCoder:aDecoder]) {
  50. appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  51. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
  52. self.metadataDetail = [[tableMetadata alloc] init];
  53. self.photos = [[NSMutableArray alloc] init];
  54. self.photoDataSource = [NSMutableArray new];
  55. indexNowVisible = -1;
  56. fileIDNowVisible = nil;
  57. appDelegate.activeDetail = self;
  58. }
  59. return self;
  60. }
  61. #pragma --------------------------------------------------------------------------------------------
  62. #pragma mark ===== View =====
  63. #pragma --------------------------------------------------------------------------------------------
  64. - (void)viewDidLoad
  65. {
  66. [super viewDidLoad];
  67. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(insertGeocoderLocation:) name:@"insertGeocoderLocation" object:nil];
  68. self.imageBackground.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"logo"] multiplier:2 color:[[[NCBrandColor sharedInstance] brand] colorWithAlphaComponent:0.4]];
  69. // Change bar bottom line shadow and remove title back button <"title"
  70. self.navigationController.navigationBar.shadowImage = [CCGraphics generateSinglePixelImageWithColor:[NCBrandColor sharedInstance].brand];
  71. self.navigationController.navigationBar.topItem.title = @"";
  72. // Color Navigation Controller
  73. [appDelegate aspectNavigationControllerBar:self.navigationController.navigationBar online:[appDelegate.reachability isReachable] hidden:NO];
  74. // TabBar
  75. self.tabBarController.tabBar.hidden = YES;
  76. self.tabBarController.tabBar.translucent = YES;
  77. }
  78. - (void)viewWillAppear:(BOOL)animated
  79. {
  80. [super viewWillAppear:animated];
  81. self.tabBarController.tabBar.hidden = YES;
  82. self.tabBarController.tabBar.translucent = YES;
  83. // Open View
  84. if ([self.metadataDetail.fileNameView length] > 0 || [self.metadataDetail.serverUrl length] > 0 || [self.metadataDetail.fileID length] > 0) {
  85. // open view
  86. [self viewFile];
  87. }
  88. }
  89. - (void)viewWillDisappear:(BOOL)animated
  90. {
  91. [super viewWillDisappear:animated];
  92. [self.navigationController setNavigationBarHidden:false];
  93. }
  94. - (void)viewDidDisappear:(BOOL)animated
  95. {
  96. [super viewDidDisappear:animated];
  97. // If AVPlayer in play -> Stop
  98. if (appDelegate.player != nil && appDelegate.player.rate != 0) {
  99. [appDelegate.player pause];
  100. }
  101. // remove Observer AVPlayer
  102. if (self.isMediaObserver) {
  103. self.isMediaObserver = NO;
  104. @try{
  105. [[NCViewerMedia sharedInstance] removeObserver];
  106. }@catch(id anException) { }
  107. }
  108. }
  109. - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
  110. {
  111. [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
  112. [coordinator animateAlongsideTransition:nil completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
  113. if (self.imagemeter) {
  114. [self.imagemeter viewImagemeter];
  115. }
  116. }];
  117. }
  118. - (void)changeTheming
  119. {
  120. [appDelegate changeTheming:self];
  121. if (self.toolbar) {
  122. self.toolbar.barTintColor = [NCBrandColor sharedInstance].tabBar;
  123. self.toolbar.tintColor = [NCBrandColor sharedInstance].brandElement;
  124. }
  125. }
  126. - (void)changeToDisplayMode
  127. {
  128. if (_readerPDFViewController) {
  129. [self.readerPDFViewController updateContentViews];
  130. }
  131. if (self.imagemeter) {
  132. [self.imagemeter viewImagemeter];
  133. }
  134. }
  135. #pragma --------------------------------------------------------------------------------------------
  136. #pragma mark ===== View File =====
  137. #pragma --------------------------------------------------------------------------------------------
  138. - (void)viewFile
  139. {
  140. // Remove all subview except ..
  141. //for (UIView *view in self.view.superview.subviews) {
  142. // NSInteger tag = view.tag;
  143. //}
  144. // Title
  145. self.navigationController.navigationBar.topItem.title = _metadataDetail.fileNameView;
  146. // verifico se esiste l'icona e se la posso creare
  147. if ([[NSFileManager defaultManager] fileExistsAtPath:[CCUtility getDirectoryProviderStorageIconFileID:self.metadataDetail.fileID fileNameView:self.metadataDetail.fileNameView]] == NO) {
  148. [CCGraphics createNewImageFrom:self.metadataDetail.fileNameView fileID:self.metadataDetail.fileID extension:[self.metadataDetail.fileNameView pathExtension] filterGrayScale:NO typeFile:self.metadataDetail.typeFile writeImage:YES];
  149. }
  150. // remove Observer AVPlayer
  151. if (self.isMediaObserver) {
  152. self.isMediaObserver = NO;
  153. [[NCViewerMedia sharedInstance] removeObserver];
  154. }
  155. // IMAGE
  156. if ([self.metadataDetail.typeFile isEqualToString: k_metadataTypeFile_image]) {
  157. self.edgesForExtendedLayout = UIRectEdgeAll;
  158. [self viewImage];
  159. }
  160. // AUDIO VIDEO
  161. if ([self.metadataDetail.typeFile isEqualToString: k_metadataTypeFile_video] || [self.metadataDetail.typeFile isEqualToString: k_metadataTypeFile_audio]) {
  162. self.edgesForExtendedLayout = UIRectEdgeAll;
  163. [self createToolbar];
  164. [[NCViewerMedia sharedInstance] viewMedia:self.metadataDetail detail:self];
  165. }
  166. // DOCUMENT
  167. if ([self.metadataDetail.typeFile isEqualToString: k_metadataTypeFile_document]) {
  168. fileNameExtension = [[self.metadataDetail.fileNameView pathExtension] uppercaseString];
  169. if ([fileNameExtension isEqualToString:@"PDF"]) {
  170. self.edgesForExtendedLayout = UIRectEdgeBottom;
  171. [self createToolbar];
  172. [self viewPDF:@""];
  173. return;
  174. }
  175. // RichDocument
  176. if ([[NCViewerRichdocument sharedInstance] isRichDocument:self.metadataDetail]) {
  177. [[NCUtility sharedInstance] startActivityIndicatorWithView:self.view bottom:0];
  178. if ([self.metadataDetail.url isEqualToString:@""]) {
  179. [[OCNetworking sharedManager] createLinkRichdocumentsWithAccount:appDelegate.activeAccount fileID:self.metadataDetail.fileID completion:^(NSString *account, NSString *link, NSString *message, NSInteger errorCode) {
  180. if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
  181. [[NCViewerRichdocument sharedInstance] viewRichDocumentAt:link detail:self];
  182. } else {
  183. [[NCUtility sharedInstance] stopActivityIndicator];
  184. if (errorCode != 0) {
  185. [appDelegate messageNotification:@"_error_" description:message visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:errorCode];
  186. } else {
  187. NSLog(@"[LOG] It has been changed user during networking process, error.");
  188. }
  189. [self.navigationController popViewControllerAnimated:YES];
  190. }
  191. }];
  192. } else {
  193. [[NCViewerRichdocument sharedInstance] viewRichDocumentAt:self.metadataDetail.url detail:self];
  194. }
  195. return;
  196. }
  197. self.edgesForExtendedLayout = UIRectEdgeBottom;
  198. [self createToolbar];
  199. [[NCViewerDocumentWeb sharedInstance] viewDocumentWebAt:self.metadataDetail detail:self];
  200. }
  201. // IMI File
  202. if ([self.metadataDetail.typeFile isEqualToString: k_metadataTypeFile_imagemeter]) {
  203. self.imagemeter = [[NCViewerImagemeter alloc] initWithMetadata:self.metadataDetail detail:self];
  204. [self.imagemeter viewImagemeter];
  205. [self createToolbar];
  206. }
  207. }
  208. #pragma --------------------------------------------------------------------------------------------
  209. #pragma mark ===== Toolbar =====
  210. #pragma --------------------------------------------------------------------------------------------
  211. - (void)createToolbar
  212. {
  213. CGFloat safeAreaBottom = 0;
  214. if (@available(iOS 11, *)) {
  215. safeAreaBottom = [UIApplication sharedApplication].delegate.window.safeAreaInsets.bottom;
  216. }
  217. self.toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height - TOOLBAR_HEIGHT - safeAreaBottom, self.view.bounds.size.width, TOOLBAR_HEIGHT)];
  218. UIBarButtonItem *flexible = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
  219. UIBarButtonItem *fixedSpaceMini = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:self action:nil];
  220. fixedSpaceMini.width = 25;
  221. buttonModifyTxt = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"actionSheetModify"] style:UIBarButtonItemStylePlain target:self action:@selector(modifyTxtButtonPressed:)];
  222. if (![NCBrandOptions sharedInstance].disable_openin_file) {
  223. self.buttonAction = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"openFile"] style:UIBarButtonItemStylePlain target:self action:@selector(actionButtonPressed:)];
  224. }
  225. buttonShare = [[UIBarButtonItem alloc] initWithImage:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"share"] width:50 height:50 color:[NCBrandColor sharedInstance].icon] style:UIBarButtonItemStylePlain target:self action:@selector(shareButtonPressed:)];
  226. buttonDelete = [[UIBarButtonItem alloc] initWithImage:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"trash"] width:50 height:50 color:[NCBrandColor sharedInstance].icon] style:UIBarButtonItemStylePlain target:self action:@selector(deleteButtonPressed:)];
  227. if ([CCUtility isDocumentModifiableExtension:fileNameExtension]) {
  228. if ([CCUtility isFolderEncrypted:_metadataDetail.serverUrl account:appDelegate.activeAccount]) // E2EE
  229. [self.toolbar setItems:[NSArray arrayWithObjects: buttonModifyTxt, flexible, buttonDelete, fixedSpaceMini, self.buttonAction, nil]];
  230. else
  231. [self.toolbar setItems:[NSArray arrayWithObjects: buttonModifyTxt, flexible, buttonDelete, fixedSpaceMini, buttonShare, fixedSpaceMini, self.buttonAction, nil]];
  232. } else {
  233. if ([CCUtility isFolderEncrypted:_metadataDetail.serverUrl account:appDelegate.activeAccount]) // E2EE
  234. [self.toolbar setItems:[NSArray arrayWithObjects: flexible, buttonDelete, fixedSpaceMini, self.buttonAction, nil]];
  235. else
  236. [self.toolbar setItems:[NSArray arrayWithObjects: flexible, buttonDelete, fixedSpaceMini, buttonShare, fixedSpaceMini, self.buttonAction, nil]];
  237. }
  238. [self.toolbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin];
  239. self.toolbar.barTintColor = [NCBrandColor sharedInstance].tabBar;
  240. self.toolbar.tintColor = [NCBrandColor sharedInstance].brandElement;
  241. [self.view addSubview:self.toolbar];
  242. }
  243. #pragma --------------------------------------------------------------------------------------------
  244. #pragma mark ===== View Image =====
  245. #pragma --------------------------------------------------------------------------------------------
  246. - (void)viewImage
  247. {
  248. self.photoBrowser = [[MWPhotoBrowser alloc] initWithDelegate:self];
  249. indexNowVisible = -1;
  250. fileIDNowVisible = nil;
  251. [self.photos removeAllObjects];
  252. // if not images, exit
  253. if ([self.photoDataSource count] == 0)
  254. return;
  255. NSUInteger index = 0;
  256. for (tableMetadata *metadata in self.photoDataSource) {
  257. // start from here ?
  258. if (self.metadataDetail.fileID && [metadata.fileID isEqualToString:self.metadataDetail.fileID])
  259. [self.photoBrowser setCurrentPhotoIndex:index];
  260. [self.photos addObject:[MWPhoto photoWithImage:nil]];
  261. // add directory
  262. index++;
  263. }
  264. // PhotoBrowser
  265. if ([NCBrandOptions sharedInstance].disable_openin_file) {
  266. self.photoBrowser.displayActionButton = NO;
  267. } else {
  268. self.photoBrowser.displayActionButton = YES;
  269. }
  270. self.photoBrowser.displayDeleteButton = YES;
  271. if ([CCUtility isFolderEncrypted:_metadataDetail.serverUrl account:appDelegate.activeAccount]) // E2EE
  272. self.photoBrowser.displayShareButton = NO;
  273. else
  274. self.photoBrowser.displayShareButton = YES;
  275. self.photoBrowser.displayNavArrows = YES;
  276. self.photoBrowser.displaySelectionButtons = NO;
  277. self.photoBrowser.alwaysShowControls = NO;
  278. self.photoBrowser.zoomPhotosToFill = NO;
  279. self.photoBrowser.autoPlayOnAppear = NO;
  280. self.photoBrowser.delayToHideElements = 15;
  281. if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad)
  282. self.photoBrowser.enableSwipeToDismiss = NO;
  283. if (self.traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassCompact) {
  284. [self addChildViewController:self.photoBrowser];
  285. [self.view addSubview:self.photoBrowser.view];
  286. [self.photoBrowser didMoveToParentViewController:self];
  287. } else {
  288. [self.navigationController pushViewController:self.photoBrowser animated:NO];
  289. }
  290. }
  291. - (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser
  292. {
  293. return [self.photoDataSource count];
  294. }
  295. - (NSString *)photoBrowser:(MWPhotoBrowser *)photoBrowser titleForPhotoAtIndex:(NSUInteger)index
  296. {
  297. tableMetadata *metadata = [self.photoDataSource objectAtIndex:index];
  298. NSString *titleDir = metadata.fileNameView;
  299. self.title = titleDir;
  300. return titleDir;
  301. }
  302. - (void)photoBrowser:(MWPhotoBrowser *)photoBrowser didDisplayPhotoAtIndex:(NSUInteger)index
  303. {
  304. tableMetadata *metadata = [self.photoDataSource objectAtIndex:index];
  305. indexNowVisible = index;
  306. fileIDNowVisible = metadata.fileID;
  307. photoBrowser.toolbar.hidden = NO;
  308. // Download image ?
  309. if (metadata) {
  310. NSInteger status;
  311. tableMetadata *metadataDB = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", metadata.fileID]];
  312. if (metadataDB) {
  313. status = metadataDB.status;
  314. } else {
  315. status = k_metadataStatusNormal;
  316. }
  317. if ([CCUtility fileProviderStorageExists:metadata.fileID fileNameView:metadata.fileNameView] == NO && status == k_metadataStatusNormal) {
  318. if ([[NSFileManager defaultManager] fileExistsAtPath:[CCUtility getDirectoryProviderStorageIconFileID:metadata.fileID fileNameView:metadata.fileNameView]] == NO && metadata.hasPreview) {
  319. [CCGraphics addImageToTitle:NSLocalizedString(@"_...loading..._", nil) colorTitle:[NCBrandColor sharedInstance].brandText imageTitle:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"load"] multiplier:2 color:[NCBrandColor sharedInstance].brandText] imageRight:NO navigationItem:self.navigationItem];
  320. CGFloat width = [[NCUtility sharedInstance] getScreenWidthForPreview];
  321. CGFloat height = [[NCUtility sharedInstance] getScreenHeightForPreview];
  322. [[OCNetworking sharedManager] downloadPreviewWithAccount:appDelegate.activeAccount metadata:metadata withWidth:width andHeight:height completion:^(NSString *account, UIImage *image, NSString *message, NSInteger errorCode) {
  323. self.navigationItem.titleView = nil;
  324. self.title = metadata.fileNameView;
  325. if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
  326. [self.photoBrowser reloadData];
  327. }
  328. }];
  329. } else {
  330. [self downloadPhotoBrowser:metadata];
  331. }
  332. }
  333. }
  334. // Title
  335. if (metadata)
  336. self.title = metadata.fileNameView;
  337. }
  338. - (id <MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index
  339. {
  340. UIImage *image;
  341. tableMetadata *metadata = [self.photoDataSource objectAtIndex:index];
  342. if (index < self.photos.count) {
  343. if (metadata.fileID) {
  344. UIImage *imagePreview = [UIImage imageWithContentsOfFile:[CCUtility getDirectoryProviderStorageIconFileID:metadata.fileID fileNameView:metadata.fileNameView]];
  345. // if (!imagePreview) imagePreview = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"file_photo"] multiplier:3 color:[[NCBrandColor sharedInstance] icon]];
  346. if ([metadata.typeFile isEqualToString: k_metadataTypeFile_image]) {
  347. NSString *fileImage = [CCUtility getDirectoryProviderStorageFileID:metadata.fileID fileNameView:metadata.fileNameView];
  348. NSString *ext = [CCUtility getExtension:metadata.fileNameView];
  349. if ([ext isEqualToString:@"GIF"]) image = [UIImage animatedImageWithAnimatedGIFURL:[NSURL fileURLWithPath:fileImage]];
  350. else image = [UIImage imageWithContentsOfFile:fileImage];
  351. if (image) {
  352. MWPhoto *photo = [MWPhoto photoWithImage:image];
  353. // Location ??
  354. [self setLocationCaptionPhoto:photo fileID:metadata.fileID];
  355. [self.photos replaceObjectAtIndex:index withObject:photo];
  356. } else {
  357. if (metadata.status == k_metadataStatusDownloadError) {
  358. [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:[UIImage imageNamed:@"filePreviewError"]]];
  359. } else {
  360. if (imagePreview)
  361. [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:imagePreview]];
  362. }
  363. }
  364. }
  365. if ([metadata.typeFile isEqualToString: k_metadataTypeFile_video]) {
  366. if ([CCUtility fileProviderStorageExists:metadata.fileID fileNameView:metadata.fileNameView]) {
  367. NSURL *url = [NSURL fileURLWithPath:[CCUtility getDirectoryProviderStorageFileID:metadata.fileID fileNameView:metadata.fileNameView]];
  368. MWPhoto *video = [MWPhoto photoWithImage:[CCGraphics thumbnailImageForVideo:url atTime:1.0]];
  369. video.videoURL = url;
  370. [self.photos replaceObjectAtIndex:index withObject:video];
  371. } else {
  372. if (metadata.status == k_metadataStatusDownloadError) {
  373. [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:[UIImage imageNamed:@"filePreviewError"]]];
  374. } else {
  375. if (imagePreview)
  376. [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:imagePreview]];
  377. }
  378. }
  379. }
  380. if ([metadata.typeFile isEqualToString: k_metadataTypeFile_audio]) {
  381. if ([CCUtility fileProviderStorageExists:metadata.fileID fileNameView:metadata.fileNameView]) {
  382. MWPhoto *audio;
  383. UIImage *audioImage;
  384. NSURL *url = [NSURL fileURLWithPath:[CCUtility getDirectoryProviderStorageFileID:metadata.fileID fileNameView:metadata.fileNameView]];
  385. if ([[NSFileManager defaultManager] fileExistsAtPath:[CCUtility getDirectoryProviderStorageIconFileID:metadata.fileID fileNameView:metadata.fileNameView]]) {
  386. audioImage = [UIImage imageWithContentsOfFile:[CCUtility getDirectoryProviderStorageIconFileID:metadata.fileID fileNameView:metadata.fileNameView]];
  387. } else {
  388. audioImage = [UIImage imageNamed:@"notaMusic"]; //[CCGraphics scaleImage:[UIImage imageNamed:@"notaMusic"] toSize:CGSizeMake(200, 200) isAspectRation:YES];
  389. }
  390. audio = [MWPhoto photoWithImage:audioImage];
  391. audio.videoURL = url;
  392. [self.photos replaceObjectAtIndex:index withObject:audio];
  393. } else {
  394. if (metadata.status == k_metadataStatusDownloadError) {
  395. [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:[UIImage imageNamed:@"filePreviewError"]]];
  396. } else {
  397. if (imagePreview)
  398. [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:imagePreview]];
  399. }
  400. }
  401. }
  402. }
  403. // energy saving memory
  404. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  405. int iPrev = (int)index - 2;
  406. if (iPrev >= 0) {
  407. if ([self.photos objectAtIndex:iPrev] != nil)
  408. [self.photos replaceObjectAtIndex:iPrev withObject:[MWPhoto photoWithImage:nil]];
  409. }
  410. int iNext = (int)index + 2;
  411. if (iNext < _photos.count) {
  412. if ([self.photos objectAtIndex:iNext] != nil)
  413. [self.photos replaceObjectAtIndex:iNext withObject:[MWPhoto photoWithImage:nil]];
  414. }
  415. });
  416. return [self.photos objectAtIndex:index];
  417. }
  418. return nil;
  419. }
  420. - (void)photoBrowser:(MWPhotoBrowser *)photoBrowser actionButtonPressedForPhotoAtIndex:(NSUInteger)index
  421. {
  422. tableMetadata *metadata = [self.photoDataSource objectAtIndex:index];
  423. if (metadata == nil) return;
  424. docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:[CCUtility getDirectoryProviderStorageFileID:metadata.fileID fileNameView:metadata.fileNameView]]];
  425. docController.delegate = self;
  426. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
  427. [docController presentOptionsMenuFromRect:photoBrowser.view.frame inView:photoBrowser.view animated:YES];
  428. [docController presentOptionsMenuFromBarButtonItem:photoBrowser.actionButton animated:YES];
  429. }
  430. - (void)photoBrowser:(MWPhotoBrowser *)photoBrowser shareButtonPressedForPhotoAtIndex:(NSUInteger)index
  431. {
  432. tableMetadata *metadata = [self.photoDataSource objectAtIndex:index];
  433. [appDelegate.activeMain readShareWithAccount:appDelegate.activeAccount openWindow:YES metadata:metadata];
  434. }
  435. - (void)photoBrowser:(MWPhotoBrowser *)photoBrowser deleteButtonPressedForPhotoAtIndex:(NSUInteger)index deleteButton:(UIBarButtonItem *)deleteButton
  436. {
  437. tableMetadata *metadata = [self.photoDataSource objectAtIndex:index];
  438. if (metadata == nil || [CCUtility fileProviderStorageExists:metadata.fileID fileNameView:metadata.fileNameView] == NO) {
  439. [appDelegate messageNotification:@"_info_" description:@"_file_not_found_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeInfo errorCode:0];
  440. return;
  441. }
  442. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  443. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_delete_", nil)
  444. style:UIAlertActionStyleDestructive
  445. handler:^(UIAlertAction *action) {
  446. [self deleteFile:metadata];
  447. }]];
  448. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil)
  449. style:UIAlertActionStyleCancel
  450. handler:^(UIAlertAction *action) {
  451. }]];
  452. alertController.popoverPresentationController.barButtonItem = deleteButton;
  453. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
  454. [alertController.view layoutIfNeeded];
  455. [self.parentViewController presentViewController:alertController animated:YES completion:NULL];
  456. }
  457. - (void)photoBrowserDidFinishPresentation:(MWPhotoBrowser *)photoBrowser
  458. {
  459. [self.navigationController popViewControllerAnimated:YES];
  460. }
  461. - (void)downloadPhotoBrowserSuccessFailure:(tableMetadata *)metadata selector:(NSString *)selector errorCode:(NSInteger)errorCode
  462. {
  463. // if a message for a directory of these
  464. if (![metadata.fileID isEqualToString:fileIDNowVisible])
  465. return;
  466. // Title
  467. self.navigationItem.titleView = nil;
  468. self.title = metadata.fileNameView;
  469. if (errorCode == 0) {
  470. // verifico se esiste l'icona e se la posso creare
  471. if ([[NSFileManager defaultManager] fileExistsAtPath:[CCUtility getDirectoryProviderStorageIconFileID:metadata.fileID fileNameView:metadata.fileNameView]] == NO) {
  472. [CCGraphics createNewImageFrom:metadata.fileNameView fileID:metadata.fileID extension:[metadata.fileNameView pathExtension] filterGrayScale:NO typeFile:metadata.typeFile writeImage:YES];
  473. }
  474. [self.photoBrowser reloadData];
  475. } else {
  476. [appDelegate messageNotification:@"_download_selected_files_" description:@"_error_download_photobrowser_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:errorCode];
  477. [self.navigationController popViewControllerAnimated:YES];
  478. }
  479. }
  480. - (void)downloadPhotoBrowser:(tableMetadata *)metadata
  481. {
  482. tableMetadata *metadataForDownload = [[NCManageDatabase sharedInstance] initNewMetadata:metadata];
  483. metadataForDownload.session = k_download_session;
  484. metadataForDownload.sessionError = @"";
  485. metadataForDownload.sessionSelector = selectorLoadViewImage;
  486. metadataForDownload.status = k_metadataStatusWaitDownload;
  487. // Add Metadata for Download
  488. (void)[[NCManageDatabase sharedInstance] addMetadata:metadataForDownload];
  489. [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:metadata.serverUrl fileID:metadataForDownload.fileID action:k_action_MOD];
  490. [appDelegate startLoadAutoDownloadUpload];
  491. [CCGraphics addImageToTitle:NSLocalizedString(@"_...loading..._", nil) colorTitle:[NCBrandColor sharedInstance].brandText imageTitle:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"load"] multiplier:2 color:[NCBrandColor sharedInstance].brandText] imageRight:NO navigationItem:self.navigationItem];
  492. }
  493. - (void)insertGeocoderLocation:(NSNotification *)notification
  494. {
  495. if (notification.userInfo.count == 0)
  496. return;
  497. NSString *fileID = [[notification.userInfo allKeys] objectAtIndex:0];
  498. //NSDate *date = [[notification.userInfo allValues] objectAtIndex:0];
  499. // test [Chrash V 1.14,15]
  500. if (indexNowVisible >= [self.photos count])
  501. return;
  502. if ([fileID isEqualToString:fileIDNowVisible]) {
  503. MWPhoto *photo = [self.photos objectAtIndex:indexNowVisible];
  504. [self setLocationCaptionPhoto:photo fileID:fileID];
  505. [self.photoBrowser reloadData];
  506. }
  507. }
  508. - (void)setLocationCaptionPhoto:(MWPhoto *)photo fileID:(NSString *)fileID
  509. {
  510. tableLocalFile *localFile;
  511. // read Geocoder
  512. localFile = [[NCManageDatabase sharedInstance] getTableLocalFileWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", fileID]];
  513. if ([localFile.exifLatitude doubleValue] != 0 || [localFile.exifLongitude doubleValue] != 0) {
  514. // Fix BUG Geo latitude & longitude
  515. if ([localFile.exifLatitude doubleValue] == 9999 || [localFile.exifLongitude doubleValue] == 9999) {
  516. tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", fileID]];
  517. if (metadata) {
  518. [[CCExifGeo sharedInstance] setExifLocalTableEtag:metadata];
  519. }
  520. }
  521. [[CCExifGeo sharedInstance] setGeocoderEtag:fileID exifDate:localFile.exifDate latitude:localFile.exifLatitude longitude:localFile.exifLongitude];
  522. localFile = [[NCManageDatabase sharedInstance] getTableLocalFileWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", fileID]];
  523. if ([localFile.exifLatitude floatValue] != 0 || [localFile.exifLongitude floatValue] != 0) {
  524. NSString *location = [[NCManageDatabase sharedInstance] getLocationFromGeoLatitude:localFile.exifLatitude longitude:localFile.exifLongitude];
  525. if ([localFile.exifDate isEqualToDate:[NSDate distantPast]] == NO && location) {
  526. NSString *localizedDateTime = [NSDateFormatter localizedStringFromDate:localFile.exifDate dateStyle:NSDateFormatterFullStyle timeStyle:NSDateFormatterMediumStyle];
  527. photo.caption = [NSString stringWithFormat:NSLocalizedString(@"%@\n%@", nil), localizedDateTime, location];
  528. }
  529. }
  530. }
  531. }
  532. #pragma --------------------------------------------------------------------------------------------
  533. #pragma mark ===== View PDF =====
  534. #pragma --------------------------------------------------------------------------------------------
  535. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  536. {
  537. [alertView dismissWithClickedButtonIndex:buttonIndex animated:YES];
  538. [[alertView textFieldAtIndex:0] resignFirstResponder];
  539. if (alertView.tag == alertRequestPasswordPDF) [self performSelector:@selector(viewPDF:) withObject:[alertView textFieldAtIndex:0].text afterDelay:0.3];
  540. }
  541. - (void)viewPDF:(NSString *)password
  542. {
  543. // remove cache PDF
  544. NSString *filePlistReader = [NSString stringWithFormat:@"%@/%@.plist", [CCUtility getDirectoryReaderMetadata], self.metadataDetail.fileNameView.stringByDeletingPathExtension];
  545. [CCUtility removeFileAtPath:filePlistReader];
  546. NSString *fileNamePath = [CCUtility getDirectoryProviderStorageFileID:self.metadataDetail.fileID fileNameView:self.metadataDetail.fileNameView];
  547. if ([CCUtility fileProviderStorageExists:self.metadataDetail.fileID fileNameView:self.metadataDetail.fileNameView] == NO) {
  548. // read file error
  549. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_", nil) message:NSLocalizedString(@"_read_file_error_", nil) preferredStyle:UIAlertControllerStyleAlert];
  550. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
  551. [alertController addAction:okAction];
  552. [self presentViewController:alertController animated:YES completion:nil];
  553. }
  554. CGPDFDocumentRef pdf = CGPDFDocumentCreateWithURL((CFURLRef)[NSURL fileURLWithPath:fileNamePath]);
  555. if (pdf) {
  556. // Encrypted
  557. if (CGPDFDocumentIsEncrypted(pdf) == YES) {
  558. // Try a blank password first, per Apple's Quartz PDF example
  559. if (CGPDFDocumentUnlockWithPassword(pdf, "") == YES) {
  560. // blank password
  561. [self readerPDF:fileNamePath password:@""];
  562. } else {
  563. if ([password length] == 0) {
  564. // password request
  565. UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"_insert_password_pfd_",nil) message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"_ok_", nil), nil];
  566. [alertView setAlertViewStyle:UIAlertViewStylePlainTextInput];
  567. alertView.tag = alertRequestPasswordPDF;
  568. [alertView show];
  569. } else {
  570. const char *key = [password UTF8String];
  571. // failure
  572. if (CGPDFDocumentUnlockWithPassword(pdf, key) == NO) {
  573. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_", nil) message:NSLocalizedString(@"_password_pdf_error_", nil) preferredStyle:UIAlertControllerStyleAlert];
  574. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
  575. [alertController addAction:okAction];
  576. [self presentViewController:alertController animated:YES completion:nil];
  577. } else {
  578. // pdf with password
  579. [self readerPDF:fileNamePath password:password];
  580. }
  581. }
  582. }
  583. } else{
  584. // No password
  585. [self readerPDF:fileNamePath password:@""];
  586. }
  587. } else {
  588. // read file error
  589. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_", nil) message:NSLocalizedString(@"_read_file_error_", nil) preferredStyle:UIAlertControllerStyleAlert];
  590. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
  591. [alertController addAction:okAction];
  592. [self presentViewController:alertController animated:YES completion:nil];
  593. }
  594. }
  595. - (void)readerPDF:(NSString *)fileName password:(NSString *)password
  596. {
  597. ReaderDocument *documentPDF = [ReaderDocument withDocumentFilePath:fileName password:password];
  598. CGFloat safeAreaBottom = 0;
  599. if (@available(iOS 11, *)) {
  600. safeAreaBottom = [UIApplication sharedApplication].delegate.window.safeAreaInsets.bottom;
  601. }
  602. if (documentPDF != nil) {
  603. self.readerPDFViewController = [[ReaderViewController alloc] initWithReaderDocument:documentPDF];
  604. self.readerPDFViewController.delegate = self;
  605. self.readerPDFViewController.view.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height - TOOLBAR_HEIGHT - safeAreaBottom);
  606. [self.readerPDFViewController updateContentViews];
  607. [self addChildViewController:self.readerPDFViewController];
  608. [self.view addSubview:self.readerPDFViewController.view];
  609. [self.readerPDFViewController didMoveToParentViewController:self];
  610. } else {
  611. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_", nil) message:NSLocalizedString(@"_read_file_error_", nil) preferredStyle:UIAlertControllerStyleAlert];
  612. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
  613. [alertController addAction:okAction];
  614. [self presentViewController:alertController animated:YES completion:nil];
  615. }
  616. }
  617. - (void)handleSingleTapReader
  618. {
  619. UILayoutGuide *layoutGuide;
  620. CGFloat safeAreaTop = 0;
  621. CGFloat safeAreaBottom = 0;
  622. if (@available(iOS 11, *)) {
  623. layoutGuide = [UIApplication sharedApplication].delegate.window.safeAreaLayoutGuide;
  624. safeAreaTop = [UIApplication sharedApplication].delegate.window.safeAreaInsets.top;
  625. safeAreaBottom = [UIApplication sharedApplication].delegate.window.safeAreaInsets.bottom;
  626. }
  627. self.navigationController.navigationBarHidden = !self.navigationController.navigationBarHidden;
  628. self.toolbar.hidden = !self.toolbar.isHidden;
  629. if (self.toolbar.isHidden) {
  630. self.readerPDFViewController.view.frame = CGRectMake(0, safeAreaTop, self.view.bounds.size.width, self.view.bounds.size.height - safeAreaTop - safeAreaBottom);
  631. } else {
  632. self.readerPDFViewController.view.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height - TOOLBAR_HEIGHT - safeAreaBottom);
  633. }
  634. [self.readerPDFViewController updateContentViews];
  635. }
  636. - (void)handleSwipeUpDown
  637. {
  638. // REMOVE IT'S UNUSABLE
  639. /*
  640. self.navigationController.navigationBarHidden = false; // iOS App is unusable after swipe up or down with PDF in fullscreen #526
  641. [self removeAllView];
  642. [self.navigationController popViewControllerAnimated:YES];
  643. */
  644. }
  645. #pragma --------------------------------------------------------------------------------------------
  646. #pragma mark ===== Delete =====
  647. #pragma --------------------------------------------------------------------------------------------
  648. - (void)deleteFile:(tableMetadata *)metadata
  649. {
  650. tableDirectory *tableDirectory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND e2eEncrypted == 1 AND serverUrl == %@", appDelegate.activeAccount, metadata.serverUrl]];
  651. [[NCMainCommon sharedInstance ] deleteFileWithMetadatas:[[NSArray alloc] initWithObjects:metadata, nil] e2ee:tableDirectory.e2eEncrypted serverUrl:tableDirectory.serverUrl folderFileID:tableDirectory.fileID completion:^(NSInteger errorCode, NSString *message) {
  652. if (errorCode == 0) {
  653. // reload data source
  654. [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:tableDirectory.serverUrl fileID:metadata.fileID action:k_action_DEL];
  655. // Not image
  656. if ([self.metadataDetail.typeFile isEqualToString: k_metadataTypeFile_image] == NO) {
  657. // exit
  658. [self.navigationController popViewControllerAnimated:YES];
  659. } else {
  660. for (NSUInteger index=0; index < [self.photoDataSource count] && _photoBrowser; index++ ) {
  661. tableMetadata *metadataTemp = [self.photoDataSource objectAtIndex:index];
  662. if ([metadata isInvalidated] || [metadataTemp.fileID isEqualToString:metadata.fileID]) {
  663. [self.photoDataSource removeObjectAtIndex:index];
  664. [self.photos removeObjectAtIndex:index];
  665. [self.photoBrowser reloadData];
  666. // exit
  667. if ([self.photoDataSource count] == 0) {
  668. [self.navigationController popViewControllerAnimated:YES];
  669. }
  670. }
  671. }
  672. }
  673. } else {
  674. NSLog(@"[LOG] DeleteFileOrFolder failure error %d, %@", (int)errorCode, message);
  675. }
  676. }];
  677. }
  678. #pragma --------------------------------------------------------------------------------------------
  679. #pragma mark ===== ButtonPressed =====
  680. #pragma --------------------------------------------------------------------------------------------
  681. - (void)dismissTextView
  682. {
  683. if (self.webView) {
  684. NSString *fileNamePath = [NSTemporaryDirectory() stringByAppendingString:self.metadataDetail.fileNameView];
  685. [[NSFileManager defaultManager] removeItemAtPath:fileNamePath error:nil];
  686. [[NSFileManager defaultManager] linkItemAtPath:[CCUtility getDirectoryProviderStorageFileID:self.metadataDetail.fileID fileNameView:self.metadataDetail.fileNameView] toPath:fileNamePath error:nil];
  687. [self.webView reload];
  688. }
  689. }
  690. - (void)modifyTxtButtonPressed:(UIBarButtonItem *)sender
  691. {
  692. tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", self.metadataDetail.fileID]];
  693. if (metadata) {
  694. UINavigationController* navigationController = [[UIStoryboard storyboardWithName:@"NCText" bundle:nil] instantiateViewControllerWithIdentifier:@"NCText"];
  695. NCText *viewController = (NCText *)navigationController.topViewController;
  696. viewController.metadata = metadata;
  697. viewController.delegate = self;
  698. navigationController.modalPresentationStyle = UIModalPresentationPageSheet;
  699. navigationController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
  700. [self presentViewController:navigationController animated:YES completion:nil];
  701. }
  702. }
  703. - (void)actionButtonPressed:(UIBarButtonItem *)sender
  704. {
  705. if ([self.metadataDetail.fileNameView length] == 0) return;
  706. NSString *filePath = [CCUtility getDirectoryProviderStorageFileID:self.metadataDetail.fileID fileNameView:self.metadataDetail.fileNameView];
  707. docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];
  708. docController.delegate = self;
  709. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
  710. [docController presentOptionsMenuFromRect:self.view.frame inView:self.view animated:YES];
  711. [docController presentOptionsMenuFromBarButtonItem:sender animated:YES];
  712. }
  713. - (void)shareButtonPressed:(UIBarButtonItem *)sender
  714. {
  715. [appDelegate.activeMain readShareWithAccount:appDelegate.activeAccount openWindow:YES metadata:self.metadataDetail];
  716. }
  717. - (void)deleteButtonPressed:(UIBarButtonItem *)sender
  718. {
  719. if ([self.metadataDetail.fileNameView length] == 0) return;
  720. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  721. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_delete_", nil)
  722. style:UIAlertActionStyleDestructive
  723. handler:^(UIAlertAction *action) {
  724. [self deleteFile:self.metadataDetail];
  725. }]];
  726. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil)
  727. style:UIAlertActionStyleCancel
  728. handler:^(UIAlertAction *action) {
  729. [alertController dismissViewControllerAnimated:YES completion:nil];
  730. }]];
  731. alertController.popoverPresentationController.barButtonItem = buttonDelete;
  732. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
  733. [alertController.view layoutIfNeeded];
  734. [self presentViewController:alertController animated:YES completion:NULL];
  735. }
  736. @end