Commit 8b8923ba authored by Tobias's avatar Tobias

inject server browser classes to discovery controller

parent f7c024d9
......@@ -12,7 +12,7 @@
*****************************************************************************/
#import <Foundation/Foundation.h>
#import "VLCLocalNetworkService.h"
#import "VLCLocalNetworkService-Protocol.h"
@protocol VLCLocalServerDiscoveryControllerDelegate <NSObject>
- (void)discoveryFoundSomethingNew;
......@@ -21,6 +21,9 @@
@interface VLCLocalServerDiscoveryController : NSObject
@property (nonatomic, readwrite, weak) id delegate;
// array of classes conforming to VLCLocalNetworkServiceBrowser
- (instancetype)initWithServiceBrowserClasses:(NSArray<Class> *)serviceBrowserClasses;
- (NSUInteger)numberOfSections;
- (NSString *)titleForSection:(NSUInteger)section;
- (NSUInteger)numberOfItemsInSection:(NSUInteger)section;
......
......@@ -27,8 +27,7 @@
@implementation VLCLocalServerDiscoveryController
- (instancetype)init
- (instancetype)initWithServiceBrowserClasses:(NSArray<Class> *)serviceBrowserClasses
{
self = [super init];
if (!self)
......@@ -46,15 +45,14 @@
name:UIApplicationDidBecomeActiveNotification
object:[UIApplication sharedApplication]];
_serviceBrowsers = @[
[[VLCLocalNetworkServiceBrowserManualConnect alloc] init],
[[VLCLocalNetworkServiceBrowserUPnP alloc] init],
[[VLCLocalNetworkServiceBrowserPlex alloc] init],
[[VLCLocalNetworkServiceBrowserFTP alloc] init],
[[VLCLocalNetworkServiceBrowserHTTP alloc] init],
[[VLCLocalNetworkServiceBrowserSAP alloc] init],
[[VLCLocalNetworkServiceBrowserDSM alloc] init],
];
NSMutableArray *serviceBrowsers = [NSMutableArray new];
for (Class browserClass in serviceBrowserClasses) {
if ([browserClass conformsToProtocol:@protocol(VLCLocalNetworkServiceBrowser)]) {
[serviceBrowsers addObject:[[browserClass alloc] init]];
}
}
_serviceBrowsers = [serviceBrowsers copy];
[_serviceBrowsers enumerateObjectsUsingBlock:^(id<VLCLocalNetworkServiceBrowser> _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
obj.delegate = self;
......
......@@ -21,10 +21,20 @@
#import "VLCNetworkLoginViewController.h"
#import "VLCNetworkServerBrowserViewController.h"
#import "VLCNetworkServerLoginInformation.h"
#import "VLCNetworkServerBrowserFTP.h"
#import "VLCNetworkServerBrowserVLCMedia.h"
#import "VLCNetworkServerBrowserPlex.h"
#import "VLCLocalNetworkServiceBrowserManualConnect.h"
#import "VLCLocalNetworkServiceBrowserPlex.h"
#import "VLCLocalNetworkServiceBrowserFTP.h"
#import "VLCLocalNetworkServiceBrowserUPnP.h"
#import "VLCLocalNetworkServiceBrowserHTTP.h"
#import "VLCLocalNetworkServiceBrowserSAP.h"
#import "VLCLocalNetworkServiceBrowserDSM.h"
@interface VLCServerListViewController () <UITableViewDataSource, UITableViewDelegate, VLCLocalServerDiscoveryControllerDelegate>
{
VLCLocalServerDiscoveryController *_discoveryController;
......@@ -64,7 +74,17 @@
{
[super viewDidLoad];
_discoveryController = [[VLCLocalServerDiscoveryController alloc] init];
NSArray *browserClasses = @[
[VLCLocalNetworkServiceBrowserManualConnect class],
[VLCLocalNetworkServiceBrowserUPnP class],
[VLCLocalNetworkServiceBrowserPlex class],
[VLCLocalNetworkServiceBrowserFTP class],
[VLCLocalNetworkServiceBrowserHTTP class],
[VLCLocalNetworkServiceBrowserSAP class],
[VLCLocalNetworkServiceBrowserDSM class],
];
_discoveryController = [[VLCLocalServerDiscoveryController alloc] initWithServiceBrowserClasses:browserClasses];
_discoveryController.delegate = self;
_backToMenuButton = [UIBarButtonItem themedRevealMenuButtonWithTarget:self andSelector:@selector(goBack:)];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment