Commit 59df44f9 authored by Felix Paul Kühne's avatar Felix Paul Kühne

local network: split FTP and UPnP code

parent c03198b8
/*****************************************************************************
* VLCLocalServerFolderListViewController.h
* VLCFTPServerListViewController
* VLC for iOS
*****************************************************************************
* Copyright (c) 2013 VideoLAN. All rights reserved.
* Copyright (c) 2013-2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
......@@ -10,15 +10,10 @@
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import <UIKit/UIKit.h>
#import "VLCLocalNetworkListViewController.h"
@class MediaServer1Device;
@interface VLCFTPServerListViewController : VLCLocalNetworkListViewController
@interface VLCLocalServerFolderListViewController : UIViewController
@property (nonatomic, strong) UITableView *tableView;
- (id)initWithUPNPDevice:(MediaServer1Device *)device header:(NSString *)header andRootID:(NSString *)rootID;
- (id)initWithFTPServer:(NSString *)serverAddress userName:(NSString *)username andPassword:(NSString *)password atPath:(NSString *)path;
@end
/*****************************************************************************
* VLCFTPServerListViewController.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2013-2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: 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 "VLCFTPServerListViewController.h"
#import "VLCLocalNetworkListCell.h"
#import "VLCAppDelegate.h"
#import "NSString+SupportedMedia.h"
#import "UIDevice+VLC.h"
#import "VLCStatusLabel.h"
#import "WhiteRaccoon.h"
@interface VLCFTPServerListViewController () <WRRequestDelegate, VLCLocalNetworkListCell>
{
NSString *_ftpServerAddress;
NSString *_ftpServerUserName;
NSString *_ftpServerPassword;
NSString *_ftpServerPath;
WRRequestListDirectory *_FTPListDirRequest;
NSArray *_objectList;
NSMutableArray *_searchData;
}
@end
@implementation VLCFTPServerListViewController
- (id)initWithFTPServer:(NSString *)serverAddress userName:(NSString *)username andPassword:(NSString *)password atPath:(NSString *)path
{
self = [super init];
if (self) {
_ftpServerAddress = serverAddress;
_ftpServerUserName = username;
_ftpServerPassword = password;
_ftpServerPath = path;
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
if ([_ftpServerPath isEqualToString:@"/"])
self.title = _ftpServerAddress;
else
self.title = [_ftpServerPath lastPathComponent];
[self _listFTPDirectory];
}
#pragma mark - ftp specifics
- (void)_listFTPDirectory
{
if (_FTPListDirRequest)
return;
_FTPListDirRequest = [[WRRequestListDirectory alloc] init];
_FTPListDirRequest.delegate = self;
_FTPListDirRequest.hostname = _ftpServerAddress;
_FTPListDirRequest.username = _ftpServerUserName;
_FTPListDirRequest.password = _ftpServerPassword;
_FTPListDirRequest.path = _ftpServerPath;
_FTPListDirRequest.passive = YES;
[(VLCAppDelegate*)[UIApplication sharedApplication].delegate networkActivityStarted];
[_FTPListDirRequest start];
}
- (NSString *)_credentials
{
NSString *cred;
if (_ftpServerUserName.length > 0) {
if (_ftpServerPassword.length > 0)
cred = [NSString stringWithFormat:@"%@:%@@", _ftpServerUserName, _ftpServerPassword];
else
cred = [NSString stringWithFormat:@"%@@", _ftpServerPassword];
} else
cred = @"";
return [cred stringByStandardizingPath];
}
- (void)_downloadFTPFile:(NSString *)fileName
{
NSURL *URLToQueue = [NSURL URLWithString:[[@"ftp" stringByAppendingFormat:@"://%@%@/%@/%@", [self _credentials], _ftpServerAddress, _ftpServerPath, fileName] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[(VLCAppDelegate*)[UIApplication sharedApplication].delegate downloadViewController] addURLToDownloadList:URLToQueue fileNameOfMedia:nil];
}
- (void)_streamFTPFile:(NSString *)fileName
{
NSString *URLofSubtitle = nil;
NSArray *SubtitlesList = [self _searchSubtitle:fileName];
if(SubtitlesList.count > 0)
URLofSubtitle = [self _getFileSubtitleFromFtpServer:SubtitlesList[0]];
NSURL *URLToPlay = [NSURL URLWithString:[[@"ftp" stringByAppendingFormat:@"://%@%@/%@/%@", [self _credentials], _ftpServerAddress, _ftpServerPath, fileName] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate openMovieWithExternalSubtitleFromURL:URLToPlay externalSubURL:URLofSubtitle];
}
- (NSArray *)_searchSubtitle:(NSString *)url
{
NSString *urlTemp = [[url lastPathComponent] stringByDeletingPathExtension];
NSMutableArray *ObjList = [[NSMutableArray alloc] init];
NSUInteger count = _objectList.count;
for (NSUInteger i = 0; i < count; i++)
[ObjList addObject:[_objectList[i] objectForKey:(id)kCFFTPResourceName]];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF contains[c] %@", urlTemp];
NSArray *results = [ObjList filteredArrayUsingPredicate:predicate];
[ObjList removeAllObjects];
count = results.count;
for (NSUInteger i = 0; i < count; i++) {
if ([results[i] isSupportedSubtitleFormat])
[ObjList addObject:results[i]];
}
return [NSArray arrayWithArray:ObjList];
}
- (NSString *)_getFileSubtitleFromFtpServer:(NSString *)fileName
{
NSURL *url = [NSURL URLWithString:[[@"ftp" stringByAppendingFormat:@"://%@%@/%@/%@", [self _credentials], _ftpServerAddress, _ftpServerPath, fileName] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSString *FileSubtitlePath = nil;
NSData *receivedSub = [NSData dataWithContentsOfURL:url];
if (receivedSub.length < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *directoryPath = searchPaths[0];
FileSubtitlePath = [directoryPath stringByAppendingPathComponent:[fileName 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");
}
[receivedSub writeToFile:FileSubtitlePath atomically:YES];
} else {
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"DISK_FULL", nil)
message:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), [fileName lastPathComponent], [[UIDevice currentDevice] model]]
delegate:self
cancelButtonTitle:NSLocalizedString(@"BUTTON_OK", nil)
otherButtonTitles:nil];
[alert show];
}
return FileSubtitlePath;
}
#pragma mark - table view data source, for more see super
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (tableView == self.searchDisplayController.searchResultsTableView)
return _searchData.count;
return _objectList.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"LocalNetworkCellDetail";
VLCLocalNetworkListCell *cell = (VLCLocalNetworkListCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
cell = [VLCLocalNetworkListCell cellWithReuseIdentifier:CellIdentifier];
NSDictionary *cellObject;
if (tableView == self.searchDisplayController.searchResultsTableView)
cellObject = _searchData[indexPath.row];
else
cellObject = _objectList[indexPath.row];
NSString *rawFileName = [cellObject objectForKey:(id)kCFFTPResourceName];
NSData *flippedData = [rawFileName dataUsingEncoding:[[[NSUserDefaults standardUserDefaults] objectForKey:kVLCSettingFTPTextEncoding] intValue] allowLossyConversion:YES];
cell.title = [[NSString alloc] initWithData:flippedData encoding:NSUTF8StringEncoding];
if ([cellObject[(id)kCFFTPResourceType] intValue] == 4) {
cell.isDirectory = YES;
cell.icon = [UIImage imageNamed:@"folder"];
} else {
cell.isDirectory = NO;
cell.icon = [UIImage imageNamed:@"blank"];
cell.subtitle = [NSString stringWithFormat:@"%0.2f MB", (float)([cellObject[(id)kCFFTPResourceSize] intValue] / 1e6)];
cell.isDownloadable = YES;
cell.delegate = self;
}
return cell;
}
#pragma mark - table view delegate, for more see super
- (void)tableView:(UITableView *)tableView willDisplayCell:(VLCLocalNetworkListCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
[super tableView:tableView willDisplayCell:cell forRowAtIndexPath:indexPath];
if([indexPath row] == ((NSIndexPath*)[[tableView indexPathsForVisibleRows] lastObject]).row)
[(VLCAppDelegate*)[UIApplication sharedApplication].delegate networkActivityStopped];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSDictionary *cellObject;
if (tableView == self.searchDisplayController.searchResultsTableView)
cellObject = _searchData[indexPath.row];
else
cellObject = _objectList[indexPath.row];
if ([cellObject[(id)kCFFTPResourceType] intValue] == 4) {
NSString *newPath = [NSString stringWithFormat:@"%@/%@", _ftpServerPath, cellObject[(id)kCFFTPResourceName]];
VLCFTPServerListViewController *targetViewController = [[VLCFTPServerListViewController alloc] initWithFTPServer:_ftpServerAddress userName:_ftpServerUserName andPassword:_ftpServerPassword atPath:newPath];
[self.navigationController pushViewController:targetViewController animated:YES];
} else {
NSString *rawObjectName = cellObject[(id)kCFFTPResourceName];
NSData *flippedData = [rawObjectName dataUsingEncoding:[[[NSUserDefaults standardUserDefaults] objectForKey:kVLCSettingFTPTextEncoding] intValue] allowLossyConversion:YES];
NSString *properObjectName = [[NSString alloc] initWithData:flippedData encoding:NSUTF8StringEncoding];
if (![properObjectName isSupportedFormat]) {
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"FILE_NOT_SUPPORTED", nil)
message:[NSString stringWithFormat:NSLocalizedString(@"FILE_NOT_SUPPORTED_LONG", nil), properObjectName]
delegate:self
cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", nil)
otherButtonTitles:nil];
[alert show];
} else
[self _streamFTPFile:properObjectName];
}
[tableView deselectRowAtIndexPath:indexPath animated:NO];
}
#pragma mark - VLCLocalNetworkListCell delegation
- (void)triggerDownloadForCell:(VLCLocalNetworkListCell *)cell
{
NSString *rawObjectName;
NSInteger size;
NSDictionary *cellObject;
if ([self.searchDisplayController isActive])
cellObject = _searchData[[self.searchDisplayController.searchResultsTableView indexPathForCell:cell].row];
else
cellObject = _objectList[[self.tableView indexPathForCell:cell].row];
rawObjectName = cellObject[(id)kCFFTPResourceName];
size = [cellObject[(id)kCFFTPResourceSize] intValue];
NSData *flippedData = [rawObjectName dataUsingEncoding:[[[NSUserDefaults standardUserDefaults] objectForKey:kVLCSettingFTPTextEncoding] intValue] allowLossyConversion:YES];
NSString *properObjectName = [[NSString alloc] initWithData:flippedData encoding:NSUTF8StringEncoding];
if (![properObjectName isSupportedFormat]) {
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"FILE_NOT_SUPPORTED", nil)
message:[NSString stringWithFormat:NSLocalizedString(@"FILE_NOT_SUPPORTED_LONG", nil), properObjectName]
delegate:self
cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", nil)
otherButtonTitles:nil];
[alert show];
} else {
if (size < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
[self _downloadFTPFile:properObjectName];
[cell.statusLabel showStatusMessage:NSLocalizedString(@"DOWNLOADING", nil)];
} else {
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"DISK_FULL", nil)
message:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), properObjectName, [[UIDevice currentDevice] model]]
delegate:self
cancelButtonTitle:NSLocalizedString(@"BUTTON_OK", nil)
otherButtonTitles:nil];
[alert show];
}
}
}
#pragma mark - white raccoon delegation
- (void)requestCompleted:(WRRequest *)request
{
if (request == _FTPListDirRequest) {
NSMutableArray *filteredList = [[NSMutableArray alloc] init];
NSArray *rawList = [(WRRequestListDirectory*)request filesInfo];
NSUInteger count = rawList.count;
for (NSUInteger x = 0; x < count; x++) {
if (![[rawList[x] objectForKey:(id)kCFFTPResourceName] hasPrefix:@"."])
[filteredList addObject:rawList[x]];
}
_objectList = [NSArray arrayWithArray:filteredList];
[self.tableView reloadData];
} else
APLog(@"unknown request %@ completed", request);
}
- (void)requestFailed:(WRRequest *)request
{
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"LOCAL_SERVER_CONNECTION_FAILED_TITLE", nil)
message:NSLocalizedString(@"LOCAL_SERVER_CONNECTION_FAILED_MESSAGE", nil)
delegate:self
cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", nil)
otherButtonTitles:nil];
[alert show];
APLog(@"request %@ failed with error %i", request, request.error.errorCode);
}
#pragma mark - search
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
NSInteger listCount = 0;
[_searchData removeAllObjects];
listCount = _objectList.count;
for (int i = 0; i < listCount; i++) {
NSRange nameRange;
NSString *rawObjectName = [_objectList[i] objectForKey:(id)kCFFTPResourceName];
NSData *flippedData = [rawObjectName dataUsingEncoding:[[[NSUserDefaults standardUserDefaults] objectForKey:kVLCSettingFTPTextEncoding] intValue] allowLossyConversion:YES];
NSString *properObjectName = [[NSString alloc] initWithData:flippedData encoding:NSUTF8StringEncoding];
nameRange = [properObjectName rangeOfString:searchString options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
[_searchData addObject:_objectList[i]];
}
return YES;
}
@end
/*****************************************************************************
* VLCLocalNetworkListViewController
* VLC for iOS
*****************************************************************************
* Copyright (c) 2015 VideoLAN. All rights reserved.
* $Id$
*
* Author: Felix Paul Kühne <fkuehne # videolan.org>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
@class VLCLocalNetworkListCell;
@interface VLCLocalNetworkListViewController : UIViewController
@property (nonatomic, strong) UITableView *tableView;
- (void)tableView:(UITableView *)tableView willDisplayCell:(VLCLocalNetworkListCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath;
@end
/*****************************************************************************
* VLCLocalNetworkListViewController
* VLC for iOS
*****************************************************************************
* Copyright (c) 2013-2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: 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 "VLCLocalNetworkListViewController.h"
#import "VLCLocalNetworkListCell.h"
#import "VLCAppDelegate.h"
@interface VLCLocalNetworkListViewController () <UITableViewDataSource, UITableViewDelegate, UISearchBarDelegate, UISearchDisplayDelegate, UIActionSheetDelegate>
{
NSMutableArray *_searchData;
UISearchBar *_searchBar;
UISearchDisplayController *_searchDisplayController;
}
@end
@implementation VLCLocalNetworkListViewController
- (void)loadView
{
_tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
_tableView.backgroundColor = [UIColor VLCDarkBackgroundColor];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.rowHeight = [VLCLocalNetworkListCell heightOfCell];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
self.view = _tableView;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.tableView.separatorColor = [UIColor VLCDarkBackgroundColor];
self.view.backgroundColor = [UIColor VLCDarkBackgroundColor];
_searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
UINavigationBar *navBar = self.navigationController.navigationBar;
_searchBar.barTintColor = navBar.barTintColor;
_searchBar.tintColor = navBar.tintColor;
_searchBar.translucent = navBar.translucent;
_searchBar.opaque = navBar.opaque;
_searchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:_searchBar contentsController:self];
_searchDisplayController.delegate = self;
_searchDisplayController.searchResultsDataSource = self;
_searchDisplayController.searchResultsDelegate = self;
_searchDisplayController.searchResultsTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_searchDisplayController.searchResultsTableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
_searchDisplayController.searchBar.searchBarStyle = UIBarStyleBlack;
_searchBar.delegate = self;
_searchBar.hidden = YES;
UITapGestureRecognizer *tapTwiceGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapTwiceGestureAction:)];
[tapTwiceGesture setNumberOfTapsRequired:2];
[self.navigationController.navigationBar addGestureRecognizer:tapTwiceGesture];
self.navigationItem.rightBarButtonItem = [UIBarButtonItem themedRevealMenuButtonWithTarget:self andSelector:@selector(menuButtonAction:)];
_searchData = [[NSMutableArray alloc] init];
[_searchData removeAllObjects];
}
- (BOOL)shouldAutorotate
{
UIInterfaceOrientation toInterfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
return NO;
return YES;
}
- (IBAction)menuButtonAction:(id)sender
{
[[(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController] toggleSidebar:![(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController].sidebarShowing duration:kGHRevealSidebarDefaultAnimationDuration];
if (self.isEditing)
[self setEditing:NO animated:YES];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
return nil;
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView willDisplayCell:(VLCLocalNetworkListCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
UIColor *color = (indexPath.row % 2 == 0)? [UIColor blackColor]: [UIColor VLCDarkBackgroundColor];
cell.contentView.backgroundColor = cell.titleLabel.backgroundColor = cell.folderTitleLabel.backgroundColor = cell.subtitleLabel.backgroundColor = color;
}
#pragma mark - Search Display Controller Delegate
- (void)searchDisplayController:(UISearchDisplayController *)controller didLoadSearchResultsTableView:(UITableView *)tableView
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
tableView.rowHeight = 80.0f;
else
tableView.rowHeight = 68.0f;
tableView.backgroundColor = [UIColor blackColor];
}
#pragma mark - Gesture Action
- (void)tapTwiceGestureAction:(UIGestureRecognizer *)recognizer
{
_searchBar.hidden = !_searchBar.hidden;
if (_searchBar.hidden)
self.tableView.tableHeaderView = nil;
else
self.tableView.tableHeaderView = _searchBar;
[self.tableView setContentOffset:CGPointMake(0.0f, -self.tableView.contentInset.top) animated:NO];
}
@end
......@@ -16,17 +16,25 @@
#import "VLCAppDelegate.h"
#import "UPnPManager.h"
#import "VLCLocalNetworkListCell.h"
#import "VLCLocalServerFolderListViewController.h"
#import "VLCLocalPlexFolderListViewController.h"
#import "VLCPlexConnectServerViewController.h"
#import "VLCFTPServerListViewController.h"
#import "VLCUPnPServerListViewController.h"
#import "VLCSharedLibraryListViewController.h"
#import "VLCSharedLibraryParser.h"
#import <QuartzCore/QuartzCore.h>
#import "GHRevealViewController.h"
#import "VLCNetworkLoginViewController.h"
#import "VLCPlaylistViewController.h"
#import "VLCHTTPUploaderController.h"
#import "Reachability.h"
#import "VLCNavigationController.h"
#define kPlexServiceType @"_plexmediasvr._tcp."
......@@ -382,7 +390,7 @@
BasicUPnPDevice *device = _filteredUPNPDevices[row];
if ([[device urn] isEqualToString:@"urn:schemas-upnp-org:device:MediaServer:1"]) {
MediaServer1Device *server = (MediaServer1Device*)device;
VLCLocalServerFolderListViewController *targetViewController = [[VLCLocalServerFolderListViewController alloc] initWithUPNPDevice:server header:[device friendlyName] andRootID:@"0"];
VLCUPnPServerListViewController *targetViewController = [[VLCUPnPServerListViewController alloc] initWithUPNPDevice:server header:[device friendlyName] andRootID:@"0"];
[self.navigationController pushViewController:targetViewController animated:YES];
}
} else if (section == 1) {
......@@ -429,7 +437,7 @@
portNumber:portNum];
[[self navigationController] pushViewController:targetViewController animated:YES];
} else if (section == 4) {
NSLog(@"DSM entry selected");
NSLog(@"DSM entry (type %lu) selected", (unsigned long)[[_dsmDiscoverer.discoveredMedia mediaAtIndex:row] mediaType]);
} else if (section == 5) {
VLCAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate openMovieFromURL:[[_sapDiscoverer.discoveredMedia mediaAtIndex:row] url]];
......@@ -473,7 +481,7 @@
{
if ([url.scheme isEqualToString:@"ftp"]) {
if (url.host.length > 0) {
VLCLocalServerFolderListViewController *targetViewController = [[VLCLocalServerFolderListViewController alloc] initWithFTPServer:url.host userName:username andPassword:password atPath:@"/"];
VLCFTPServerListViewController *targetViewController = [[VLCFTPServerListViewController alloc] initWithFTPServer:url.host userName:username andPassword:password atPath:@"/"];
[self.navigationController pushViewController:targetViewController animated:YES];
}
} else
......@@ -640,6 +648,7 @@
- (void)mediaList:(VLCMediaList *)aMediaList mediaAdded:(VLCMedia *)media atIndex:(NSInteger)index
{
NSLog(@"found media %@ of type %lu", media.url.lastPathComponent, media.mediaType);
[self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
}
......
/*****************************************************************************
* VLCUPnPServerListViewController.h
* VLC for iOS
*****************************************************************************
* Copyright (c) 2015 VideoLAN. All rights reserved.
* $Id$
*
* Author: Felix Paul Kühne <fkuehne # videolan.org>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import "VLCLocalNetworkListViewController.h"
@class MediaServer1Device;
@interface VLCUPnPServerListViewController : VLCLocalNetworkListViewController
- (id)initWithUPNPDevice:(MediaServer1Device *)device header:(NSString *)header andRootID:(NSString *)rootID;
@end
/*****************************************************************************
* VLCLocalServerFolderListViewController.m
* VLCUPnPServerListViewController.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2013 VideoLAN. All rights reserved.
* Copyright (c) 2013-2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
* Marc Etcheverry <marc@taplightsoftware.com>
* Pierre SAGASPE <pierre.sagaspe # me.com>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import "VLCLocalServerFolderListViewController.h"
#import "VLCUPnPServerListViewController.h"
#import "VLCLocalNetworkListCell.h"
#import "VLCAppDelegate.h"
#import "VLCStatusLabel.h"
#import "NSString+SupportedMedia.h"
#import "MediaServerBasicObjectParser.h"
#import "MediaServer1ItemObject.h"
#import "MediaServer1ContainerObject.h"
#import "MediaServer1Device.h"
#import "VLCLocalNetworkListCell.h"
#import "VLCAppDelegate.h"
#import "VLCPlaylistViewController.h"
#import "VLCDownloadViewController.h"
#import "WhiteRaccoon.h"
#import "NSString+SupportedMedia.h"
#import "VLCStatusLabel.h"
#import "BasicUPnPDevice+VLC.h"
#import "UIDevice+VLC.h"
#define kVLCServerTypeUPNP 0
#define kVLCServerTypeFTP 1
@interface VLCLocalServerFolderListViewController () <UITableViewDataSource, UITableViewDelegate, WRRequestDelegate, VLCLocalNetworkListCell, UISearchBarDelegate, UISearchDisplayDelegate, UIActionSheetDelegate>
@interface VLCUPnPServerListViewController () <VLCLocalNetworkListCell>
{
/* UI */
UIBarButtonItem *_menuButton;
/* generic data storage */
NSString *_listTitle;
NSArray *_objectList;
NSMutableArray *_mutableObjectList;
NSUInteger _serverType;
/* UPNP specifics */
MediaServer1Device *_UPNPdevice;
NSString *_UPNProotID;