Expose the package downloading to js. Todo: cancel support, status callbacks.

This commit is contained in:
Paul Chote
2010-11-19 11:17:47 +13:00
parent cb93955cc5
commit c3521a2490
6 changed files with 83 additions and 18 deletions

View File

@@ -40,7 +40,9 @@ static JSBridge *SharedInstance;
methods = [[NSDictionary dictionaryWithObjectsAndKeys:
@"launchMod", NSStringFromSelector(@selector(launchMod:)),
@"log", NSStringFromSelector(@selector(log:)),
@"installCncPackagesFromWeb", NSStringFromSelector(@selector(installCncPackagesFromWeb)),
@"fileExistsInMod", NSStringFromSelector(@selector(fileExists:inMod:)),
@"downloadFileToCache",NSStringFromSelector(@selector(downloadFile:intoCacheWithName:id:)),
nil] retain];
}
return self;
@@ -87,6 +89,13 @@ static JSBridge *SharedInstance;
return YES;
}
- (void)downloadFile:(NSString *)url intoCacheWithName:(NSString *)name id:(NSString *)did
{
NSLog(@"downloadFile:%@ intoCacheWithName:%@ id:%@",url,name,did);
// Disallow traversing directories; take only the last component
[controller downloadUrl:url intoCache:[name lastPathComponent] withId:did];
}
- (void)log:(NSString *)message
{
NSLog(@"js: %@",message);