Explorar o código

server browsing: correctly implement 'isDownloadable' flag for shares browsed by VLC

(cherry picked from commit 4e900e8013ee8e298a55b9710e97d6f54f30d1cf)
Felix Paul Kühne %!s(int64=9) %!d(string=hai) anos
pai
achega
3e2294fac2

+ 3 - 0
SharedSources/ServerBrowsing/General/VLCNetworkServerBrowserVLCMedia.h

@@ -20,6 +20,9 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface VLCNetworkServerBrowserItemVLCMedia : NSObject <VLCNetworkServerBrowserItem>
 - (instancetype)initWithMedia:(VLCMedia *)media options:(NSDictionary *)mediaOptions;
+
+@property (nonatomic, getter=isDownloadable, readonly) BOOL downloadable;
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 2 - 2
SharedSources/ServerBrowsing/General/VLCNetworkServerBrowserVLCMedia.m

@@ -123,7 +123,7 @@
 
 @end
 @implementation VLCNetworkServerBrowserItemVLCMedia
-@synthesize name = _name, container = _container, fileSizeBytes = _fileSizeBytes, URL = _URL, media = _media;
+@synthesize name = _name, container = _container, fileSizeBytes = _fileSizeBytes, URL = _URL, media = _media, downloadable = _downloadable;
 
 - (instancetype)initWithMedia:(VLCMedia *)media options:(NSDictionary *)mediaOptions;
 {
@@ -144,7 +144,7 @@
         _name = title;
         _URL = media.url;
         _mediaOptions = [mediaOptions copy];
-//        _downloadable = NO; //TODO: add property for downloadable?
+        _downloadable = NO;
     }
     return self;
 }

+ 4 - 1
SharedSources/ServerBrowsing/VLCServerBrowsingController.m

@@ -96,7 +96,10 @@
         }
         cell.subtitle = subtitle;
 #if DOWNLOAD_SUPPORTED
-        cell.isDownloadable = self.allowsFileDownload;
+        if ([item respondsToSelector:@selector(isDownloadable)])
+            cell.isDownloadable = item.isDownloadable;
+        else
+            cell.isDownloadable = NO;
 #endif
     }
     cell.title = item.name;