CCDetail.m 44 KB

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