Handle download errors
This commit is contained in:
@@ -49,6 +49,7 @@ static JSBridge *SharedInstance;
|
||||
@"startDownload", NSStringFromSelector(@selector(startDownload:)),
|
||||
@"cancelDownload", NSStringFromSelector(@selector(cancelDownload:)),
|
||||
@"downloadStatus", NSStringFromSelector(@selector(downloadStatus:)),
|
||||
@"downloadError", NSStringFromSelector(@selector(downloadError:)),
|
||||
@"bytesCompleted", NSStringFromSelector(@selector(bytesCompleted:)),
|
||||
@"bytesTotal", NSStringFromSelector(@selector(bytesTotal:)),
|
||||
nil] retain];
|
||||
@@ -67,12 +68,6 @@ static JSBridge *SharedInstance;
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)notifyDownloadProgress:(Download *)download
|
||||
{
|
||||
[[[controller webView] windowScriptObject] evaluateWebScript:
|
||||
[NSString stringWithFormat:@"downloadProgressed('%@')",[download key]]];
|
||||
}
|
||||
|
||||
#pragma mark JS API methods
|
||||
|
||||
- (BOOL)launchMod:(NSString *)aMod
|
||||
@@ -119,6 +114,15 @@ static JSBridge *SharedInstance;
|
||||
return [d status];
|
||||
}
|
||||
|
||||
- (NSString *)downloadError:(NSString *)key
|
||||
{
|
||||
Download *d = [controller downloadWithKey:key];
|
||||
if (d == nil)
|
||||
return @"";
|
||||
|
||||
return [d error];
|
||||
}
|
||||
|
||||
- (BOOL)startDownload:(NSString *)key
|
||||
{
|
||||
Download *d = [controller downloadWithKey:key];
|
||||
@@ -143,6 +147,13 @@ static JSBridge *SharedInstance;
|
||||
return (d == nil) ? -1 : [d bytesTotal];
|
||||
}
|
||||
|
||||
- (void)notifyDownloadProgress:(Download *)download
|
||||
{
|
||||
[[[controller webView] windowScriptObject] evaluateWebScript:
|
||||
[NSString stringWithFormat:@"downloadProgressed('%@')",[download key]]];
|
||||
}
|
||||
|
||||
|
||||
- (void)log:(NSString *)message
|
||||
{
|
||||
NSLog(@"js: %@",message);
|
||||
|
||||
Reference in New Issue
Block a user