瀏覽代碼

Download Controller: increase protection against unsupported downloads

Felix Paul Kühne 12 年之前
父節點
當前提交
2b8d1c8510
共有 1 個文件被更改,包括 11 次插入5 次删除
  1. 11 5
      AspenProject/VLCDownloadViewController.m

+ 11 - 5
AspenProject/VLCDownloadViewController.m

@@ -13,6 +13,7 @@
 #import "VLCAppDelegate.h"
 #import "UIBarButtonItem+Theme.h"
 #import "WhiteRaccoon.h"
+#import "NSString+SupportedMedia.h"
 
 #define kVLCDownloadViaHTTP 1
 #define kVLCDownloadViaFTP 2
@@ -75,11 +76,16 @@
     if ([self.urlField.text length] > 0) {
         NSURL *URLtoSave = [NSURL URLWithString:self.urlField.text];
         if (([URLtoSave.scheme isEqualToString:@"http"] || [URLtoSave.scheme isEqualToString:@"https"] || [URLtoSave.scheme isEqualToString:@"ftp"]) && ![URLtoSave.lastPathComponent.pathExtension isEqualToString:@""]) {
-            [_currentDownloads addObject:URLtoSave];
-            self.urlField.text = @"";
-            [self.downloadsTable reloadData];
-
-            [self _triggerNextDownload];
+            if ([URLtoSave.lastPathComponent isSupportedFormat]) {
+                [_currentDownloads addObject:URLtoSave];
+                self.urlField.text = @"";
+                [self.downloadsTable reloadData];
+
+                [self _triggerNextDownload];
+            } else {
+                UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"FILE_NOT_SUPPORTED", @"") message:[NSString stringWithFormat:NSLocalizedString(@"FILE_NOT_SUPPORTED", @""), URLtoSave.lastPathComponent] delegate:self cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", @"") otherButtonTitles:nil];
+                [alert show];
+            }
         }
     }
 }