Prechádzať zdrojové kódy

split model layer server browsing logic into extra class which can be reused

Tobias Conradi 9 rokov pred
rodič
commit
00ac52e710

+ 60 - 0
SharedSources/ServerBrowsing/VLCServerBrowsingController.h

@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * VLC for iOS
+ *****************************************************************************
+ * Copyright (c) 2015 VideoLAN. All rights reserved.
+ * $Id$
+ *
+ * Authors: Tobias Conradi <videolan # tobias-conradi.de>
+ *
+ * Refer to the COPYING file of the official project for license.
+ *****************************************************************************/
+
+#import <UIKit/UIKit.h>
+#import "VLCNetworkServerBrowser-Protocol.h"
+
+#define DOWNLOAD_SUPPORTED TARGET_OS_IOS
+
+NS_ASSUME_NONNULL_BEGIN
+@protocol VLCServerBrowsingCell <NSObject>
+
+@property (nonatomic, nullable) NSString *title;
+@property (nonatomic, nullable) NSString *subtitle;
+@property (nonatomic, nullable) UIImage *thumbnailImage;
+@property (nonatomic, nullable) NSURL *thumbnailURL;
+@property (nonatomic) BOOL isDirectory;
+#if DOWNLOAD_SUPPORTED
+@property (nonatomic) BOOL isDownloadable;
+#endif
+@end
+
+
+@interface VLCServerBrowsingController : NSObject
+@property (nonatomic, nullable) NSByteCountFormatter *byteCountFormatter;
+@property (nonatomic, nullable) UIImage *folderImage;
+@property (nonatomic, nullable) UIImage *genericFileImage;
+
+#if DOWNLOAD_SUPPORTED
+@property (nonatomic) BOOL allowsFileDownload;
+#endif
+
+@property (nonatomic, readonly) id<VLCNetworkServerBrowser> serverBrowser;
+@property (nonatomic, weak, nullable, readonly) UIViewController *viewController;
+
+- (instancetype)initWithViewController:(UIViewController *)viewController serverBrowser:(id<VLCNetworkServerBrowser>)browser;
+
+- (void)configureCell:(id<VLCServerBrowsingCell>)cell withItem:(id<VLCNetworkServerBrowserItem>)item;
+
+#pragma mark - Subtitles
+- (void)configureSubtitlesInMediaList:(VLCMediaList *)mediaList;
+#pragma mark - Streaming
+- (void)streamFileForItem:(id<VLCNetworkServerBrowserItem>)item;
+- (void)streamMediaList:(VLCMediaList *)mediaList startingAtIndex:(NSInteger)startIndex;
+
+
+#if DOWNLOAD_SUPPORTED
+- (BOOL)triggerDownloadForItem:(id<VLCNetworkServerBrowserItem>)item;
+
+#endif
+@end
+NS_ASSUME_NONNULL_END
+

+ 244 - 0
SharedSources/ServerBrowsing/VLCServerBrowsingController.m

@@ -0,0 +1,244 @@
+/*****************************************************************************
+ * VLC for iOS
+ *****************************************************************************
+ * Copyright (c) 2015 VideoLAN. All rights reserved.
+ * $Id$
+ *
+ * Authors: Tobias Conradi <videolan # tobias-conradi.de>
+ *          Felix Paul Kühne <fkuehne # videolan.org>
+ *          Pierre SAGASPE <pierre.sagaspe # me.com>
+ * Refer to the COPYING file of the official project for license.
+ *****************************************************************************/
+
+#import "VLCServerBrowsingController.h"
+#import "NSString+SupportedMedia.h"
+#import "UIDevice+VLC.h"
+
+#import "VLCPlaybackController.h"
+
+
+#if DOWNLOAD_SUPPORTED
+#import "VLCDownloadViewController.h"
+#endif
+
+@implementation VLCServerBrowsingController
+
+- (instancetype)initWithViewController:(UIViewController *)viewController serverBrowser:(id<VLCNetworkServerBrowser>)browser
+{
+    self = [super init];
+    if (self) {
+        _viewController = viewController;
+        _serverBrowser = browser;
+    }
+    return self;
+}
+
+
+#pragma mark -
+- (NSByteCountFormatter *)byteCounterFormatter {
+    if (!_byteCountFormatter) {
+        _byteCountFormatter = [[NSByteCountFormatter alloc] init];
+    }
+    return _byteCountFormatter;
+}
+
+- (UIImage *)genericFileImage {
+    if (!_genericFileImage) {
+        _genericFileImage = [UIImage imageNamed:@"blank"];
+    }
+    return _genericFileImage;
+}
+
+- (UIImage *)folderImage {
+    if (!_folderImage) {
+        _folderImage = [UIImage imageNamed:@"folder"];
+    }
+    return _folderImage;
+}
+
+#pragma mark - cell configuration
+
+- (void)configureCell:(id<VLCServerBrowsingCell>)cell withItem:(id<VLCNetworkServerBrowserItem>)item {
+
+    cell.title = item.name;
+
+    if (item.isContainer) {
+        cell.isDirectory = YES;
+        cell.thumbnailImage = self.folderImage;
+    } else {
+        cell.isDirectory = NO;
+        cell.thumbnailImage = self.genericFileImage;
+
+        NSString *sizeString = item.fileSizeBytes ? [self.byteCounterFormatter stringFromByteCount:item.fileSizeBytes.longLongValue] : nil;
+
+        NSString *duration = nil;
+        if ([item respondsToSelector:@selector(duration)]) {
+            duration = item.duration;
+        }
+
+        NSString *subtitle = nil;
+        if (sizeString && duration) {
+            subtitle = [NSString stringWithFormat:@"%@ (%@)",sizeString, duration];
+        } else if (sizeString) {
+            subtitle = sizeString;
+        } else if (duration) {
+            subtitle = duration;
+        }
+        cell.subtitle = sizeString;
+#if DOWNLOAD_SUPPORTED
+        cell.isDownloadable = self.allowsFileDownload;
+#endif
+        NSURL *thumbnailURL = nil;
+        if ([item respondsToSelector:@selector(thumbnailURL)]) {
+            thumbnailURL = item.thumbnailURL;
+        }
+
+        if (thumbnailURL) {
+            [cell setThumbnailURL:thumbnailURL];
+        }
+    }
+}
+
+
+#pragma mark - subtitles
+
+- (NSArray<NSURL*> *)_searchSubtitle:(NSString *)url
+{
+    NSString *urlTemp = [[url lastPathComponent] stringByDeletingPathExtension];
+
+    NSMutableArray<NSURL*> *urls = [NSMutableArray arrayWithArray:[self.serverBrowser.items valueForKey:@"URL"]];
+
+    NSPredicate *namePredicate = [NSPredicate predicateWithFormat:@"SELF.path contains[c] %@", urlTemp];
+    [urls filterUsingPredicate:namePredicate];
+
+    NSPredicate *formatPrediate = [NSPredicate predicateWithBlock:^BOOL(NSURL *_Nonnull evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
+        return [evaluatedObject.path isSupportedSubtitleFormat];
+    }];
+    [urls filterUsingPredicate:formatPrediate];
+
+    return [NSArray arrayWithArray:urls];
+}
+
+- (NSString *)_getFileSubtitleFromServer:(NSURL *)subtitleURL
+{
+    NSString *FileSubtitlePath = nil;
+    NSData *receivedSub = [NSData dataWithContentsOfURL:subtitleURL]; // TODO: fix synchronous load
+
+    if (receivedSub.length < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
+        NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
+        NSString *directoryPath = searchPaths[0];
+        FileSubtitlePath = [directoryPath stringByAppendingPathComponent:[subtitleURL lastPathComponent]];
+
+        NSFileManager *fileManager = [NSFileManager defaultManager];
+        if (![fileManager fileExistsAtPath:FileSubtitlePath]) {
+            //create local subtitle file
+            [fileManager createFileAtPath:FileSubtitlePath contents:nil attributes:nil];
+            if (![fileManager fileExistsAtPath:FileSubtitlePath]) {
+                APLog(@"file creation failed, no data was saved");
+                return nil;
+            }
+        }
+        [receivedSub writeToFile:FileSubtitlePath atomically:YES];
+    } else {
+
+        [self.viewController vlc_showAlertWithTitle:NSLocalizedString(@"DISK_FULL", nil)
+                                            message:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), [subtitleURL lastPathComponent], [[UIDevice currentDevice] model]]
+                                        buttonTitle:NSLocalizedString(@"BUTTON_OK", nil)];
+    }
+
+    return FileSubtitlePath;
+}
+
+- (void)configureSubtitlesInMediaList:(VLCMediaList *)mediaList
+{
+    NSArray *items = self.serverBrowser.items;
+    id<VLCNetworkServerBrowserItem> loopItem;
+    [mediaList lock];
+    NSUInteger count = mediaList.count;
+    for (NSUInteger i = 0; i < count; i++) {
+        loopItem = items[i];
+        NSString *URLofSubtitle = nil;
+        NSURL *remoteSubtitleURL = nil;
+        if ([loopItem respondsToSelector:@selector(subtitleURL)]) {
+            [loopItem subtitleURL];
+        }
+        if (remoteSubtitleURL == nil) {
+            NSArray *subtitlesList = [self _searchSubtitle:loopItem.URL.lastPathComponent];
+            remoteSubtitleURL = subtitlesList.firstObject;
+        }
+
+        if(remoteSubtitleURL != nil) {
+            URLofSubtitle = [self _getFileSubtitleFromServer:remoteSubtitleURL];
+            if (URLofSubtitle != nil)
+                [[mediaList mediaAtIndex:i] addOptions:@{ kVLCSettingSubtitlesFilePath : URLofSubtitle }];
+        }
+    }
+    [mediaList unlock];
+}
+
+
+#pragma mark - File Streaming
+
+
+- (void)streamMediaList:(VLCMediaList *)mediaList startingAtIndex:(NSInteger)startIndex
+{
+    VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
+    [vpc playMediaList:mediaList firstIndex:startIndex];
+}
+
+- (void)streamFileForItem:(id<VLCNetworkServerBrowserItem>)item
+{
+    NSString *URLofSubtitle = nil;
+    NSURL *remoteSubtitleURL = nil;
+    if ([item respondsToSelector:@selector(subtitleURL)]) {
+        remoteSubtitleURL = [item subtitleURL];
+    }
+    if (!remoteSubtitleURL) {
+        NSArray *SubtitlesList = [self _searchSubtitle:item.URL.lastPathComponent];
+        remoteSubtitleURL = SubtitlesList.firstObject;
+    }
+
+    if(remoteSubtitleURL)
+        URLofSubtitle = [self _getFileSubtitleFromServer:remoteSubtitleURL];
+
+    NSURL *URLToPlay = item.URL;
+
+    VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
+    [vpc playURL:URLToPlay subtitlesFilePath:URLofSubtitle];
+}
+
+
+#pragma mark - Downloads
+#if DOWNLOAD_SUPPORTED
+- (BOOL)triggerDownloadForItem:(id<VLCNetworkServerBrowserItem>)item
+{
+    if (item.fileSizeBytes.longLongValue  < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
+        [self _downloadItem:item];
+        return YES;
+    } else {
+        NSString *title = NSLocalizedString(@"DISK_FULL", nil);
+        NSString *messsage = [NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), item.name, [[UIDevice currentDevice] model]];
+        NSString *button = NSLocalizedString(@"BUTTON_OK", nil);
+        [self.viewController vlc_showAlertWithTitle:title message:messsage buttonTitle:button];
+        return NO;
+    }
+}
+
+- (void)_downloadItem:(id<VLCNetworkServerBrowserItem>)item
+{
+    NSString *filename = item.name;
+    if (filename.pathExtension.length == 0) {
+        /* there are few crappy UPnP servers who don't reveal the correct file extension, so we use a generic fake (#11123) */
+        NSString *urlExtension = item.URL.pathExtension;
+        NSString *extension = urlExtension.length != 0 ? urlExtension : @"vlc";
+        filename = [filename stringByAppendingPathExtension:extension];
+    }
+    [[VLCDownloadViewController sharedInstance] addURLToDownloadList:item.URL
+                                                     fileNameOfMedia:filename];
+}
+
+
+
+#endif
+
+@end

+ 6 - 0
Sources/LocalNetworkConnectivity/VLCNetworkListCell.h

@@ -12,6 +12,7 @@
 
 #import <UIKit/UIKit.h>
 #import "VLCNetworkImageView.h"
+#import "VLCServerBrowsingController.h"
 
 @class VLCStatusLabel;
 
@@ -48,3 +49,8 @@
 - (void)triggerDownloadForCell:(VLCNetworkListCell *)cell;
 
 @end
+
+
+@interface VLCNetworkListCell (CellConfigurator) <VLCServerBrowsingCell>
+
+@end

+ 21 - 0
Sources/LocalNetworkConnectivity/VLCNetworkListCell.m

@@ -96,6 +96,9 @@
 
 - (void)prepareForReuse {
     [self.thumbnailView cancelLoading];
+    self.isDownloadable = NO;
+    self.subtitle = nil;
+    self.title = nil;
 }
 
 + (CGFloat)heightOfCell
@@ -107,3 +110,21 @@
 }
 
 @end
+
+
+
+@implementation VLCNetworkListCell (CellConfigurator)
+- (void)setThumbnailImage:(UIImage *)thumbnailImage {
+    self.icon = thumbnailImage;
+}
+- (UIImage *)thumbnailImage {
+    return self.icon;
+}
+- (void)setThumbnailURL:(NSURL *)thumbnailURL {
+    self.iconURL = thumbnailURL;
+}
+- (NSURL *)thumbnailURL {
+    return self.iconURL;
+}
+
+@end

+ 11 - 181
Sources/LocalNetworkConnectivity/VLCNetworkServerBrowserViewController.m

@@ -18,18 +18,17 @@
 #import "VLCStatusLabel.h"
 #import "VLCPlaybackController.h"
 #import "VLCDownloadViewController.h"
-#import "UIDevice+VLC.h"
-#import "NSString+SupportedMedia.h"
-#import "UIDevice+VLC.h"
+
 
 #import "VLCNetworkServerBrowser-Protocol.h"
+#import "VLCServerBrowsingController.h"
 
 @interface VLCNetworkServerBrowserViewController () <VLCNetworkServerBrowserDelegate,VLCNetworkListCellDelegate, UITableViewDataSource, UITableViewDelegate, UIActionSheetDelegate>
 {
     UIRefreshControl *_refreshControl;
 }
 @property (nonatomic) id<VLCNetworkServerBrowser> serverBrowser;
-@property (nonatomic) NSByteCountFormatter *byteCounterFormatter;
+@property (nonatomic) VLCServerBrowsingController *browsingController;
 @property (nonatomic) NSArray<id<VLCNetworkServerBrowserItem>> *searchArray;
 @end
 
@@ -41,6 +40,8 @@
     if (self) {
         _serverBrowser = browser;
         browser.delegate = self;
+        _browsingController = [[VLCServerBrowsingController alloc] init];
+        _browsingController.allowsFileDownload = YES;
     }
     return self;
 }
@@ -93,44 +94,9 @@
     [self update];
 }
 
-#pragma mark -
-- (NSByteCountFormatter *)byteCounterFormatter {
-    if (!_byteCounterFormatter) {
-        _byteCounterFormatter = [[NSByteCountFormatter alloc] init];
-    }
-    return _byteCounterFormatter;
-}
 
 #pragma mark - server browser item specifics
 
-- (void)_downloadItem:(id<VLCNetworkServerBrowserItem>)item
-{
-    NSString *filename = item.name;
-    if (filename.pathExtension.length == 0) {
-        /* there are few crappy UPnP servers who don't reveal the correct file extension, so we use a generic fake (#11123) */
-        NSString *urlExtension = item.URL.pathExtension;
-        NSString *extension = urlExtension.length != 0 ? urlExtension : @"vlc";
-        filename = [filename stringByAppendingPathExtension:extension];
-    }
-    [[VLCDownloadViewController sharedInstance] addURLToDownloadList:item.URL
-                                                     fileNameOfMedia:filename];
-}
-
-- (BOOL)triggerDownloadForItem:(id<VLCNetworkServerBrowserItem>)item
-{
-    if (item.fileSizeBytes.longLongValue  < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
-        [self _downloadItem:item];
-        return YES;
-    } else {
-        NSString *title = NSLocalizedString(@"DISK_FULL", nil);
-        NSString *messsage = [NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), item.name, [[UIDevice currentDevice] model]];
-        NSString *button = NSLocalizedString(@"BUTTON_OK", nil);
-        [self vlc_showAlertWithTitle:title message:messsage buttonTitle:button];
-        return NO;
-    }
-}
-
-
 
 - (void)didSelectItem:(id<VLCNetworkServerBrowserItem>)item index:(NSUInteger)index singlePlayback:(BOOL)singlePlayback
 {
@@ -139,117 +105,16 @@
         [self.navigationController pushViewController:targetViewController animated:YES];
     } else {
         if (singlePlayback) {
-            [self _streamFileForItem:item];
+            [self.browsingController streamFileForItem:item];
         } else {
             VLCMediaList *mediaList = self.serverBrowser.mediaList;
-            [self configureSubtitlesInMediaList:mediaList];
-            [self _streamMediaList:mediaList startingAtIndex:index];
-        }
-    }
-}
-
-
-- (void)configureSubtitlesInMediaList:(VLCMediaList *)mediaList {
-    NSArray *items = self.serverBrowser.items;
-    id<VLCNetworkServerBrowserItem> loopItem;
-    [mediaList lock];
-    NSUInteger count = mediaList.count;
-    for (NSUInteger i = 0; i < count; i++) {
-        loopItem = items[i];
-        NSString *URLofSubtitle = nil;
-        NSURL *remoteSubtitleURL = nil;
-        if ([loopItem respondsToSelector:@selector(subtitleURL)]) {
-            [loopItem subtitleURL];
-        }
-        if (remoteSubtitleURL == nil) {
-            NSArray *subtitlesList = [self _searchSubtitle:loopItem.URL.lastPathComponent];
-            remoteSubtitleURL = subtitlesList.firstObject;
-        }
-
-        if(remoteSubtitleURL != nil) {
-            URLofSubtitle = [self _getFileSubtitleFromServer:remoteSubtitleURL];
-            if (URLofSubtitle != nil)
-                [[mediaList mediaAtIndex:i] addOptions:@{ kVLCSettingSubtitlesFilePath : URLofSubtitle }];
+            [self.browsingController configureSubtitlesInMediaList:mediaList];
+            [self.browsingController streamMediaList:mediaList startingAtIndex:index];
         }
     }
-    [mediaList unlock];
 }
 
 
-- (NSString *)_getFileSubtitleFromServer:(NSURL *)subtitleURL
-{
-    NSString *FileSubtitlePath = nil;
-    NSData *receivedSub = [NSData dataWithContentsOfURL:subtitleURL]; // TODO: fix synchronous load
-
-    if (receivedSub.length < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
-        NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
-        NSString *directoryPath = searchPaths[0];
-        FileSubtitlePath = [directoryPath stringByAppendingPathComponent:[subtitleURL lastPathComponent]];
-
-        NSFileManager *fileManager = [NSFileManager defaultManager];
-        if (![fileManager fileExistsAtPath:FileSubtitlePath]) {
-            //create local subtitle file
-            [fileManager createFileAtPath:FileSubtitlePath contents:nil attributes:nil];
-            if (![fileManager fileExistsAtPath:FileSubtitlePath]) {
-                APLog(@"file creation failed, no data was saved");
-                return nil;
-            }
-        }
-        [receivedSub writeToFile:FileSubtitlePath atomically:YES];
-    } else {
-
-        [self vlc_showAlertWithTitle:NSLocalizedString(@"DISK_FULL", nil)
-                                            message:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), [subtitleURL lastPathComponent], [[UIDevice currentDevice] model]]
-                                        buttonTitle:NSLocalizedString(@"BUTTON_OK", nil)];
-    }
-    
-    return FileSubtitlePath;
-}
-
-- (void)_streamMediaList:(VLCMediaList *)mediaList startingAtIndex:(NSInteger)startIndex
-{
-    VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
-    [vpc playMediaList:mediaList firstIndex:startIndex];
-}
-
-- (void)_streamFileForItem:(id<VLCNetworkServerBrowserItem>)item
-{
-    NSString *URLofSubtitle = nil;
-    NSURL *remoteSubtitleURL = nil;
-    if ([item respondsToSelector:@selector(subtitleURL)]) {
-        remoteSubtitleURL = [item subtitleURL];
-    }
-    if (!remoteSubtitleURL) {
-        NSArray *SubtitlesList = [self _searchSubtitle:item.URL.lastPathComponent];
-        remoteSubtitleURL = SubtitlesList.firstObject;
-    }
-
-    if(remoteSubtitleURL)
-        URLofSubtitle = [self _getFileSubtitleFromServer:remoteSubtitleURL];
-
-    NSURL *URLToPlay = item.URL;
-
-    VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
-    [vpc playURL:URLToPlay subtitlesFilePath:URLofSubtitle];
-}
-
-- (NSArray<NSURL*> *)_searchSubtitle:(NSString *)url
-{
-    NSString *urlTemp = [[url lastPathComponent] stringByDeletingPathExtension];
-
-    NSMutableArray<NSURL*> *urls = [NSMutableArray arrayWithArray:[self.serverBrowser.items valueForKey:@"URL"]];
-
-    NSPredicate *namePredicate = [NSPredicate predicateWithFormat:@"SELF.path contains[c] %@", urlTemp];
-    [urls filterUsingPredicate:namePredicate];
-
-    NSPredicate *formatPrediate = [NSPredicate predicateWithBlock:^BOOL(NSURL *_Nonnull evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
-        return [evaluatedObject.path isSupportedSubtitleFormat];
-    }];
-    [urls filterUsingPredicate:formatPrediate];
-
-    return [NSArray arrayWithArray:urls];
-}
-
 
 #pragma mark - table view data source, for more see super
 
@@ -275,43 +140,9 @@
         item = self.serverBrowser.items[indexPath.row];
     }
 
-    cell.title = item.name;
-
-    if (item.isContainer) {
-        cell.isDirectory = YES;
-        cell.icon = [UIImage imageNamed:@"folder"];
-    } else {
-        cell.isDirectory = NO;
-        cell.icon = [UIImage imageNamed:@"blank"];
-
-        NSString *sizeString = item.fileSizeBytes ? [self.byteCounterFormatter stringFromByteCount:item.fileSizeBytes.longLongValue] : nil;
-
-        NSString *duration = nil;
-        if ([item respondsToSelector:@selector(duration)]) {
-            duration = item.duration;
-        }
-
-        NSString *subtitle = nil;
-        if (sizeString && duration) {
-            subtitle = [NSString stringWithFormat:@"%@ (%@)",sizeString, duration];
-        } else if (sizeString) {
-            subtitle = sizeString;
-        } else if (duration) {
-            subtitle = duration;
-        }
-        cell.subtitle = sizeString;
-        cell.isDownloadable = YES;
-        cell.delegate = self;
+    [self.browsingController configureCell:cell withItem:item];
 
-        NSURL *thumbnailURL = nil;
-        if ([item respondsToSelector:@selector(thumbnailURL)]) {
-            thumbnailURL = item.thumbnailURL;
-        }
-
-        if (thumbnailURL) {
-            [cell setIconURL:thumbnailURL];
-        }
-    }
+    cell.delegate = self;
 
     return cell;
 }
@@ -344,7 +175,6 @@
     [tableView deselectRowAtIndexPath:indexPath animated:NO];
 }
 
-
 #pragma mark - VLCNetworkListCell delegation
 - (void)triggerDownloadForCell:(VLCNetworkListCell *)cell
 {
@@ -354,7 +184,7 @@
     else
         item = self.serverBrowser.items[[self.tableView indexPathForCell:cell].row];
 
-    if ([self triggerDownloadForItem:item]) {
+    if ([self.browsingController triggerDownloadForItem:item]) {
         [cell.statusLabel showStatusMessage:NSLocalizedString(@"DOWNLOADING", nil)];
     }
 }

+ 1 - 0
VLC for Apple TV/TVPrefixHeader.pch

@@ -22,6 +22,7 @@
 
 #import "UIColor+Presets.h"
 #import "VLCTVConstants.h"
+#import "UIViewController+VLCAlert.h"
 
 #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[UIDevice currentDevice] systemVersion].floatValue >= [v floatValue])
 

+ 8 - 0
VLC for iOS.xcodeproj/project.pbxproj

@@ -281,6 +281,8 @@
 		DD3EABFD1BE14C4B003668DA /* UIViewController+VLCAlert.m in Sources */ = {isa = PBXBuildFile; fileRef = DD3EABFB1BE14C4B003668DA /* UIViewController+VLCAlert.m */; };
 		DD3EAC041BE153B4003668DA /* VLCNetworkImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = DD3EAC031BE153B4003668DA /* VLCNetworkImageView.m */; };
 		DD3EAC051BE153B4003668DA /* VLCNetworkImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = DD3EAC031BE153B4003668DA /* VLCNetworkImageView.m */; };
+		DD3EAC091BE2192A003668DA /* VLCServerBrowsingController.m in Sources */ = {isa = PBXBuildFile; fileRef = DD3EAC081BE2192A003668DA /* VLCServerBrowsingController.m */; };
+		DD3EAC0A1BE2192A003668DA /* VLCServerBrowsingController.m in Sources */ = {isa = PBXBuildFile; fileRef = DD3EAC081BE2192A003668DA /* VLCServerBrowsingController.m */; };
 		DD3EFEED1BDEBA3800B68579 /* VLCNetworkServerBrowserViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DD3EFEEA1BDEBA3800B68579 /* VLCNetworkServerBrowserViewController.m */; };
 		DD3EFEEE1BDEBA3800B68579 /* VLCServerListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DD3EFEEC1BDEBA3800B68579 /* VLCServerListViewController.m */; };
 		DD3EFF2D1BDEBCE500B68579 /* VLCLocalNetworkServiceBrowserFTP.m in Sources */ = {isa = PBXBuildFile; fileRef = DD3EFEF21BDEBCE500B68579 /* VLCLocalNetworkServiceBrowserFTP.m */; };
@@ -924,6 +926,8 @@
 		DD3EABFB1BE14C4B003668DA /* UIViewController+VLCAlert.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIViewController+VLCAlert.m"; path = "ServerBrowsing/UIViewController+VLCAlert.m"; sourceTree = "<group>"; };
 		DD3EAC021BE153B4003668DA /* VLCNetworkImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCNetworkImageView.h; path = "UI Elements/VLCNetworkImageView.h"; sourceTree = "<group>"; };
 		DD3EAC031BE153B4003668DA /* VLCNetworkImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCNetworkImageView.m; path = "UI Elements/VLCNetworkImageView.m"; sourceTree = "<group>"; };
+		DD3EAC071BE2192A003668DA /* VLCServerBrowsingController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCServerBrowsingController.h; sourceTree = "<group>"; };
+		DD3EAC081BE2192A003668DA /* VLCServerBrowsingController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCServerBrowsingController.m; sourceTree = "<group>"; };
 		DD3EFEE91BDEBA3800B68579 /* VLCNetworkServerBrowserViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCNetworkServerBrowserViewController.h; path = Sources/LocalNetworkConnectivity/VLCNetworkServerBrowserViewController.h; sourceTree = SOURCE_ROOT; };
 		DD3EFEEA1BDEBA3800B68579 /* VLCNetworkServerBrowserViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCNetworkServerBrowserViewController.m; path = Sources/LocalNetworkConnectivity/VLCNetworkServerBrowserViewController.m; sourceTree = SOURCE_ROOT; };
 		DD3EFEEB1BDEBA3800B68579 /* VLCServerListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCServerListViewController.h; path = Sources/LocalNetworkConnectivity/VLCServerListViewController.h; sourceTree = SOURCE_ROOT; };
@@ -2069,6 +2073,8 @@
 				DD3EFF2A1BDEBCE500B68579 /* VLCLocalServerDiscoveryController.h */,
 				DD3EFF2B1BDEBCE500B68579 /* VLCLocalServerDiscoveryController.m */,
 				DD3EFF2C1BDEBCE500B68579 /* VLCNetworkServerBrowser-Protocol.h */,
+				DD3EAC071BE2192A003668DA /* VLCServerBrowsingController.h */,
+				DD3EAC081BE2192A003668DA /* VLCServerBrowsingController.m */,
 			);
 			path = ServerBrowsing;
 			sourceTree = "<group>";
@@ -2700,6 +2706,7 @@
 				7D1329411BA1F10100BE647E /* main.m in Sources */,
 				7DC71D291BC83590001FACAA /* UIColor+Presets.m in Sources */,
 				7D4408591BDA8DCA0080FB42 /* VLCBoxController.m in Sources */,
+				DD3EAC0A1BE2192A003668DA /* VLCServerBrowsingController.m in Sources */,
 				DD3EFF341BDEBCE500B68579 /* VLCLocalNetworkServiceBrowserMediaDiscoverer.m in Sources */,
 				DD3EFF421BDEBCE500B68579 /* VLCNetworkServerBrowserSharedLibrary.m in Sources */,
 				7D5278E41BD7E37300D0CA0E /* VLCCloudStorageController.m in Sources */,
@@ -2809,6 +2816,7 @@
 				7D3784C8183A9972009EE944 /* NSString+SupportedMedia.m in Sources */,
 				DD3EFF5B1BDEBCE500B68579 /* VLCNetworkServerBrowserUPnP.m in Sources */,
 				DD3EABF81BE14BD6003668DA /* BasicUPnPDevice+VLC.m in Sources */,
+				DD3EAC091BE2192A003668DA /* VLCServerBrowsingController.m in Sources */,
 				7D3784C9183A9972009EE944 /* UIDevice+VLC.m in Sources */,
 				7D3784CC183A99BA009EE944 /* PAPasscodeViewController.m in Sources */,
 				DDEAECCD1BDECCB800756C83 /* VLCNetworkListViewController.m in Sources */,