Browse Source

network: add discovery VC stub to list SMB shares

Felix Paul Kühne 10 years ago
parent
commit
8ba6961cab

+ 15 - 0
Sources/VLCDiscoveryListViewController.h

@@ -0,0 +1,15 @@
+//
+//  VLCDiscoveryListViewController.h
+//  VLC for iOS
+//
+//  Created by Felix Paul Kühne on 15/06/15.
+//  Copyright © 2015 VideoLAN. All rights reserved.
+//
+
+#import "VLCNetworkListViewController.h"
+
+@interface VLCDiscoveryListViewController : VLCNetworkListViewController
+
+- (instancetype)initWithMedia:(VLCMedia*)media;
+
+@end

+ 91 - 0
Sources/VLCDiscoveryListViewController.m

@@ -0,0 +1,91 @@
+//
+//  VLCDiscoveryListViewController.m
+//  VLC for iOS
+//
+//  Created by Felix Paul Kühne on 15/06/15.
+//  Copyright © 2015 VideoLAN. All rights reserved.
+//
+
+#import "VLCDiscoveryListViewController.h"
+#import "VLCNetworkListCell.h"
+
+@interface VLCDiscoveryListViewController () <VLCNetworkListCellDelegate, UITableViewDataSource, UITableViewDelegate, VLCMediaDelegate>
+{
+    VLCMediaList *_mediaList;
+    VLCMedia *rootMedia;
+}
+
+@end
+
+@implementation VLCDiscoveryListViewController
+
+- (instancetype)initWithMedia:(VLCMedia *)media
+{
+    self = [super init];
+
+    if (!self)
+        return self;
+
+    _mediaList = [media subitems];
+    self.title = [media metadataForKey:VLCMetaInformationTitle];
+
+    NSLog(@"media meta %@", media.metaDictionary);
+
+    NSLog(@"count %lu", _mediaList.count);
+
+    rootMedia = media;
+
+    return self;
+}
+
+- (void)viewWillAppear:(BOOL)animated
+{
+    [self.tableView reloadData];
+
+    [rootMedia setDelegate:self];
+    [rootMedia parseWithOptions:VLCMediaParseNetwork | VLCMediaFetchNetwork];
+}
+
+#pragma mark - media delegate
+
+- (void)mediaDidFinishParsing:(VLCMedia *)aMedia
+{
+    NSLog(@"finished parsing %@, sub items %@", aMedia, [aMedia subitems]);
+}
+
+- (void)mediaMetaDataDidChange:(VLCMedia *)aMedia
+{
+    NSLog(@"metadata changed %@, meta %@", aMedia, [aMedia metaDictionary]);
+}
+
+#pragma mark - table view data source, for more see super
+
+- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+    return _mediaList.count;
+}
+
+- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath
+{
+    static NSString *CellIdentifier = @"DiscoveryCell";
+
+    VLCNetworkListCell *cell = (VLCNetworkListCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier
+                                                                                     forIndexPath:indexPath];
+    if (cell == nil)
+        cell = [VLCNetworkListCell cellWithReuseIdentifier:CellIdentifier];
+
+    VLCMedia *cellObject = [_mediaList mediaAtIndex:indexPath.row];
+    cell.isDirectory = cellObject.mediaType == VLCMediaTypeDirectory;
+    cell.isDownloadable = NO;
+    cell.title = [cellObject metadataForKey:VLCMetaInformationTitle];
+    cell.subtitle = cellObject.url.absoluteString;
+
+    return cell;
+}
+
+- (void)triggerDownloadForCell:(VLCNetworkListCell *)cell
+{
+    NSLog(@"downloads not implemented");
+}
+
+@end

+ 14 - 7
Sources/VLCServerListViewController.m

@@ -22,6 +22,7 @@
 
 #import "VLCFTPServerListViewController.h"
 #import "VLCUPnPServerListViewController.h"
+#import "VLCDiscoveryListViewController.h"
 
 #import "VLCSharedLibraryListViewController.h"
 #import "VLCSharedLibraryParser.h"
@@ -134,7 +135,7 @@
                           name:VLCSharedLibraryParserDeterminedNetserviceAsVLCInstance
                         object:nil];
 
-    _sectionHeaderTexts = @[@"Universal Plug'n'Play (UPnP)", @"Plex Media Server (via Bonjour)", @"File Transfer Protocol (FTP)", NSLocalizedString(@"SHARED_VLC_IOS_LIBRARY", nil), NSLocalizedString(@"SMB_CIFS_FILE_SERVERS", nil)];
+    _sectionHeaderTexts = @[@"Universal Plug'n'Play (UPnP)", @"Plex Media Server (via Bonjour)", @"File Transfer Protocol (FTP)", NSLocalizedString(@"SHARED_VLC_IOS_LIBRARY", nil), NSLocalizedString(@"SMB_CIFS_FILE_SERVERS", nil), @"SAP"];
 
     _backToMenuButton = [UIBarButtonItem themedRevealMenuButtonWithTarget:self andSelector:@selector(goBack:)];
     self.navigationItem.leftBarButtonItem = _backToMenuButton;
@@ -214,6 +215,7 @@
 
 - (void)_startUPNPDiscovery
 {
+    return;
     if (_reachability.currentReachabilityStatus != ReachableViaWiFi)
         return;
 
@@ -424,10 +426,19 @@
                                                                     portNumber:portNum];
         [[self navigationController] pushViewController:targetViewController animated:YES];
     } else if (section == 4) {
-        NSLog(@"DSM entry (type %lu) selected", (unsigned long)[[_dsmDiscoverer.discoveredMedia mediaAtIndex:row] mediaType]);
+        VLCMedia *cellMedia = [_dsmDiscoverer.discoveredMedia mediaAtIndex:row];
+        if (cellMedia.mediaType != VLCMediaTypeDirectory)
+            return;
+
+        VLCDiscoveryListViewController *targetViewController = [[VLCDiscoveryListViewController alloc]
+                                                                initWithMedia:cellMedia];
+        [[self navigationController] pushViewController:targetViewController animated:YES];
     } else if (section == 5) {
         VLCAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
-        [appDelegate openMovieFromURL:[[_sapDiscoverer.discoveredMedia mediaAtIndex:row] url]];
+        VLCMedia *cellMedia = [_sapDiscoverer.discoveredMedia mediaAtIndex:row];
+        VLCMediaType mediaType = cellMedia.mediaType;
+        if (mediaType != VLCMediaTypeDirectory && mediaType != VLCMediaTypeDisc)
+            [appDelegate openMovieFromURL:[[_sapDiscoverer.discoveredMedia mediaAtIndex:row] url]];
     }
 }
 
@@ -617,8 +628,6 @@
 
 - (void)_startSAPDiscovery
 {
-    return;
-
     if (_reachability.currentReachabilityStatus != ReachableViaWiFi)
         return;
 
@@ -629,8 +638,6 @@
 
 - (void)_stopSAPDiscovery
 {
-    return;
-
     [_sapDiscoverer stopDiscoverer];
     _sapDiscoverer = nil;
 }

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

@@ -162,6 +162,7 @@
 		7DAE0C311B2EDFD600C53996 /* VLCUPnPServerListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DAE0C301B2EDFD600C53996 /* VLCUPnPServerListViewController.m */; };
 		7DAE0C341B2EE0C200C53996 /* VLCFTPServerListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DAE0C331B2EE0C200C53996 /* VLCFTPServerListViewController.m */; };
 		7DAE0C371B2EF85B00C53996 /* VLCSidebarController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DAE0C361B2EF85B00C53996 /* VLCSidebarController.m */; };
+		7DAE0C3A1B2F085F00C53996 /* VLCDiscoveryListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DAE0C391B2F085F00C53996 /* VLCDiscoveryListViewController.m */; };
 		7DB638AB185BC0890003887C /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7DB638AA185BC0890003887C /* Images.xcassets */; };
 		7DB847D71A5871570002DC30 /* VLCOneDriveObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DB847D61A5871570002DC30 /* VLCOneDriveObject.m */; };
 		7DBBF182183AB3B80009A339 /* VLCAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DBBF181183AB3B80009A339 /* VLCAppDelegate.m */; };
@@ -597,6 +598,8 @@
 		7DAE0C331B2EE0C200C53996 /* VLCFTPServerListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCFTPServerListViewController.m; path = Sources/VLCFTPServerListViewController.m; sourceTree = SOURCE_ROOT; };
 		7DAE0C351B2EF85B00C53996 /* VLCSidebarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCSidebarController.h; path = Sources/VLCSidebarController.h; sourceTree = SOURCE_ROOT; };
 		7DAE0C361B2EF85B00C53996 /* VLCSidebarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCSidebarController.m; path = Sources/VLCSidebarController.m; sourceTree = SOURCE_ROOT; };
+		7DAE0C381B2F085F00C53996 /* VLCDiscoveryListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCDiscoveryListViewController.h; path = Sources/VLCDiscoveryListViewController.h; sourceTree = SOURCE_ROOT; };
+		7DAE0C391B2F085F00C53996 /* VLCDiscoveryListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCDiscoveryListViewController.m; path = Sources/VLCDiscoveryListViewController.m; sourceTree = SOURCE_ROOT; };
 		7DB2486E18EA1D6D0097ADD2 /* ro */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ro; path = ro.lproj/Localizable.strings; sourceTree = "<group>"; };
 		7DB638AA185BC0890003887C /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = "vlc-ios/Images.xcassets"; sourceTree = "<group>"; };
 		7DB847D51A5871570002DC30 /* VLCOneDriveObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCOneDriveObject.h; path = Sources/VLCOneDriveObject.h; sourceTree = SOURCE_ROOT; };
@@ -1043,6 +1046,8 @@
 				7DAE0C301B2EDFD600C53996 /* VLCUPnPServerListViewController.m */,
 				7DAE0C321B2EE0C200C53996 /* VLCFTPServerListViewController.h */,
 				7DAE0C331B2EE0C200C53996 /* VLCFTPServerListViewController.m */,
+				7DAE0C381B2F085F00C53996 /* VLCDiscoveryListViewController.h */,
+				7DAE0C391B2F085F00C53996 /* VLCDiscoveryListViewController.m */,
 				7D30F3D5183AB2F100FFC021 /* VLCServerListViewController.h */,
 				7D30F3D6183AB2F100FFC021 /* VLCServerListViewController.m */,
 				7D30F3DA183AB2F900FFC021 /* VLCNetworkLoginViewController.h */,
@@ -1930,6 +1935,7 @@
 				DD8F84311B00EB3B0009138A /* VLCPlaybackController+MediaLibrary.m in Sources */,
 				7D37849A183A98D1009EE944 /* VLCPlaylistTableViewCell.m in Sources */,
 				7D37849B183A98D1009EE944 /* VLCPlaylistViewController.m in Sources */,
+				7DAE0C3A1B2F085F00C53996 /* VLCDiscoveryListViewController.m in Sources */,
 				7D37849E183A98DD009EE944 /* VLCThumbnailsCache.m in Sources */,
 				7D3784A1183A98EB009EE944 /* VLCBugreporter.m in Sources */,
 				7D3784A6183A98F5009EE944 /* VLCAboutViewController.m in Sources */,