42#import "MyOpenGLView.h"
51static NSString *
const kOOOXZDataURL =
@"http://addons.oolite.space/api/1.0/overview";
118NSComparisonResult
oxzSort(
id m1,
id m2,
void *context);
123#if OOLITE_MAC_OS_X_10_7
124@interface OOOXZManager (OOPrivate) <NSURLConnectionDataDelegate>
126@interface OOOXZManager (NSURLConnectionDataDelegate)
131- (NSString *) extractionBasePathForIdentifier:(NSString *)identifier andVersion:(NSString *)version;
133- (NSString *) humanSize:(NSUInteger)bytes;
137- (BOOL) beginDownload:(NSMutableURLRequest *)request;
142- (
OOColor *) colorForManifest:(NSDictionary *)manifest;
143- (NSString *) installStatusForManifest:(NSDictionary *)manifest;
145- (BOOL) validateFilter:(NSString *)input;
147- (void) setOXZList:(NSArray *)list;
148- (void) setFilteredList:(NSArray *)list;
149- (NSArray *) applyCurrentFilter:(NSArray *)list;
151- (void) setCurrentDownload:(NSURLConnection *)download withLabel:(NSString *)label;
152- (void) setProgressStatus:(NSString *)newStatus;
154- (BOOL) installOXZ:(NSUInteger)item;
156- (BOOL) removeOXZ:(NSUInteger)item;
160- (NSString *) extractOXZ:(NSUInteger)item;
163- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error;
164- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response;
165- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data;
166- (void)connectionDidFinishLoading:(NSURLConnection *)connection;
170@interface OOOXZManager (OOFilterRules)
171- (BOOL) applyFilterByNoFilter:(NSDictionary *)manifest;
172- (BOOL) applyFilterByUpdateRequired:(NSDictionary *)manifest;
173- (BOOL) applyFilterByInstallable:(NSDictionary *)manifest;
174- (BOOL) applyFilterByKeyword:(NSDictionary *)manifest keyword:(NSString *)keyword;
175- (BOOL) applyFilterByAuthor:(NSDictionary *)manifest author:(NSString *)author;
176- (BOOL) applyFilterByDays:(NSDictionary *)manifest days:(NSString *)days;
177- (BOOL) applyFilterByTag:(NSDictionary *)manifest tag:(NSString *)tag;
178- (BOOL) applyFilterByCategory:(NSDictionary *)manifest category:(NSString *)category;
234 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,NSUserDomainMask,YES);
235 NSString *appPath = [
paths objectAtIndex:0];
238 appPath = [
appPath stringByAppendingPathComponent:@"Oolite"];
240 appPath = [
appPath stringByAppendingPathComponent:@"Managed AddOns"];
245 appPath = [
appPath stringByAppendingPathComponent:@"ManagedAddOns"];
253- (NSString *) extractionBasePathForIdentifier:(NSString *)identifier andVersion:(NSString *)version
256 NSString *rawMainDir = [
NSString stringWithFormat:@"%@-%@.off",identifier,version];
258 NSCharacterSet *blacklist = [
NSCharacterSet characterSetWithCharactersInString:@"'#%^&{}[]/~|\\?<,:\" "];
259 return [[[
basePath stringByAppendingPathComponent:[[
rawMainDir componentsSeparatedByCharactersInSet:blacklist] componentsJoinedByString:@""]] retain] autorelease];
253- (NSString *) extractionBasePathForIdentifier:(NSString *)identifier andVersion:(NSString *)version {
…}
265 BOOL exists, directory;
269 exists = [
fmgr fileExistsAtPath:path isDirectory:&directory];
271 if (exists && !directory)
278 if (![fmgr oo_createDirectoryAtPath:path attributes:
nil])
314 NSString *url = [[
NSUserDefaults standardUserDefaults] stringForKey:kOOOXZDataConfig];
323- (NSString *) humanSize:(NSUInteger)bytes
327 return DESC(
@"oolite-oxzmanager-missing-field");
329 else if (bytes < 1024)
333 else if (bytes < 1024*1024)
335 return [
NSString stringWithFormat:@"%lu kB",bytes>>10];
339 return [
NSString stringWithFormat:@"%.2f MB",((float)(bytes>>10))/1024];
323- (NSString *) humanSize:(NSUInteger)bytes {
…}
344- (void) setOXZList:(NSArray *)list
349 _oxzList = [[
list sortedArrayUsingFunction:oxzSort context:NULL] retain];
344- (void) setOXZList:(NSArray *)list {
…}
356- (void) setFilteredList:(NSArray *)list
359 _filteredList = [
list copy];
356- (void) setFilteredList:(NSArray *)list {
…}
363- (void) setFilter:(NSString *)filter
363- (void) setFilter:(NSString *)filter {
…}
370- (NSArray *) applyCurrentFilter:(NSArray *)list
372 SEL filterSelector =
@selector(applyFilterByNoFilter:);
373 NSString *parameter =
nil;
376 filterSelector =
@selector(applyFilterByUpdateRequired:);
380 filterSelector =
@selector(applyFilterByInstallable:);
384 filterSelector =
@selector(applyFilterByKeyword:keyword:);
385 parameter = [
_currentFilter substringFromIndex:[kOOOXZFilterKeyword length]];
389 filterSelector =
@selector(applyFilterByAuthor:author:);
390 parameter = [
_currentFilter substringFromIndex:[kOOOXZFilterAuthor length]];
394 filterSelector =
@selector(applyFilterByDays:days:);
395 parameter = [
_currentFilter substringFromIndex:[kOOOXZFilterDays length]];
399 filterSelector =
@selector(applyFilterByTag:tag:);
400 parameter = [
_currentFilter substringFromIndex:[kOOOXZFilterTag length]];
404 filterSelector =
@selector(applyFilterByCategory:category:);
405 parameter = [
_currentFilter substringFromIndex:[kOOOXZFilterCategory length]];
409 NSDictionary *manifest =
nil;
410 NSInvocation *invocation = [
NSInvocation invocationWithMethodSignature:[[
self class] instanceMethodSignatureForSelector:filterSelector]];
413 if (parameter !=
nil)
415 [
invocation setArgument:¶meter atIndex:3];
418 foreach(manifest, list)
422 BOOL filterAccepted = NO;
370- (NSArray *) applyCurrentFilter:(NSArray *)list {
…}
436- (BOOL) applyFilterByNoFilter:(NSDictionary *)manifest
436- (BOOL) applyFilterByNoFilter:(NSDictionary *)manifest {
…}
442- (BOOL) applyFilterByUpdateRequired:(NSDictionary *)manifest
442- (BOOL) applyFilterByUpdateRequired:(NSDictionary *)manifest {
…}
448- (BOOL) applyFilterByInstallable:(NSDictionary *)manifest
448- (BOOL) applyFilterByInstallable:(NSDictionary *)manifest {
…}
454- (BOOL) applyFilterByKeyword:(NSDictionary *)manifest keyword:(NSString *)keyword
456 NSString *parameter =
nil;
457 NSArray *parameters = [
NSArray arrayWithObjects:kOOManifestTitle,kOOManifestDescription,kOOManifestCategory,nil];
460 keyword = [
keyword stringByTrimmingLeadingWhitespaceAndNewlineCharacters];
462 foreach (parameter,parameters)
464 if ([[manifest oo_stringForKey:parameter] rangeOfString:keyword options:NSCaseInsensitiveSearch].location != NSNotFound)
470 parameters = [
manifest oo_arrayForKey:kOOManifestTags];
471 foreach (parameter,parameters)
473 if ([parameter rangeOfString:keyword options:NSCaseInsensitiveSearch].location != NSNotFound)
454- (BOOL) applyFilterByKeyword:(NSDictionary *)manifest keyword:(NSString *)keyword {
…}
483- (BOOL) applyFilterByAuthor:(NSDictionary *)manifest author:(NSString *)author
486 author = [
author stringByTrimmingLeadingWhitespaceAndNewlineCharacters];
488 NSString *mAuth = [
manifest oo_stringForKey:kOOManifestAuthor];
489 return ([mAuth rangeOfString:author options:NSCaseInsensitiveSearch].location != NSNotFound);
483- (BOOL) applyFilterByAuthor:(NSDictionary *)manifest author:(NSString *)author {
…}
493- (BOOL) applyFilterByDays:(NSDictionary *)manifest days:(NSString *)days
495 NSInteger i = [
days integerValue];
502 NSUInteger updated = [
manifest oo_unsignedIntegerForKey:kOOManifestUploadDate];
503 NSUInteger now = (NSUInteger)[[NSDate date] timeIntervalSince1970];
504 return (updated + (86400 * i) > now);
493- (BOOL) applyFilterByDays:(NSDictionary *)manifest days:(NSString *)days {
…}
509- (BOOL) applyFilterByTag:(NSDictionary *)manifest tag:(NSString *)tag
511 NSString *parameter =
nil;
512 NSArray *parameters = [
manifest oo_arrayForKey:kOOManifestTags];
515 tag = [
tag stringByTrimmingLeadingWhitespaceAndNewlineCharacters];
517 foreach (parameter,parameters)
519 if ([parameter rangeOfString:tag options:NSCaseInsensitiveSearch].location != NSNotFound)
509- (BOOL) applyFilterByTag:(NSDictionary *)manifest tag:(NSString *)tag {
…}
529- (BOOL) applyFilterByCategory:(NSDictionary *)manifest category:(NSString *)category
532 category = [
category stringByTrimmingLeadingWhitespaceAndNewlineCharacters];
534 NSString *mCategory = [
manifest oo_stringForKey:kOOManifestCategory];
535 return ([mCategory rangeOfString:category options:NSCaseInsensitiveSearch].location != NSNotFound);
529- (BOOL) applyFilterByCategory:(NSDictionary *)manifest category:(NSString *)category {
…}
541- (BOOL) validateFilter:(NSString *)input
543 NSString *filter = [
input lowercaseString];
544 if (([filter length] == 0)
541- (BOOL) validateFilter:(NSString *)input {
…}
562- (void) setCurrentDownload:(NSURLConnection *)download withLabel:(NSString *)label
564 if (_currentDownload !=
nil)
568 _currentDownload = [
download retain];
570 _currentDownloadName = [
label copy];
562- (void) setCurrentDownload:(NSURLConnection *)download withLabel:(NSString *)label {
…}
574- (void) setProgressStatus:(NSString *)new
577 _progressStatus = [
new copy];
574- (void) setProgressStatus:(NSString *)new {
…}
595- (BOOL) beginDownload:(NSMutableURLRequest *)request
597 NSString *userAgent = [
NSString stringWithFormat:@"Oolite/%@", [[[
NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]];
598 [
request setValue:userAgent forHTTPHeaderField:@"User-Agent"];
599 NSURLConnection *download = [[
NSURLConnection alloc] initWithRequest:request delegate:
self];
602 _downloadProgress = 0;
603 _downloadExpected = 0;
604 NSString *label =
DESC(
@"oolite-oxzmanager-download-label-list");
607 NSDictionary *expectedManifest =
nil;
610 label = [
expectedManifest oo_stringForKey:kOOManifestTitle defaultValue:DESC(@"oolite-oxzmanager-download-label-oxz")];
595- (BOOL) beginDownload:(NSMutableURLRequest *)request {
…}
636 [_currentDownload cancel];
672 NSString *fullpath =
nil;
673 NSDictionary *manifest =
nil;
676 fullpath = [[
self installPath] stringByAppendingPathComponent:filename];
680 NSMutableDictionary *adjManifest = [
NSMutableDictionary dictionaryWithDictionary:manifest];
681 [
adjManifest setObject:fullpath forKey:kOOManifestFilePath];
683 NSDictionary *stored =
nil;
688 BOOL foundInstallable = NO;
693 if (foundInstallable == NO)
695 [
adjManifest setObject:[
stored oo_stringForKey:kOOManifestVersion] forKey:kOOManifestAvailableVersion];
696 [
adjManifest setObject:[
stored oo_stringForKey:kOOManifestDownloadURL] forKey:kOOManifestDownloadURL];
699 foundInstallable = YES;
705 [manifests addObject:adjManifest];
708 [manifests sortUsingFunction:oxzSort context:NULL];
755 if (downloadedManifest ==
nil)
763 NSDictionary *expectedManifest =
nil;
766 if (expectedManifest ==
nil ||
772 OOLog(
kOOOXZErrorLog,
@"%@",
@"Downloaded OXZ does not have the same identifer and version as expected. This might be due to your manifests list being out of date - try updating it.");
791 NSString *destination = [[
self installPath] stringByAppendingPathComponent:filename];
792 [[
NSFileManager defaultManager] oo_removeItemAtPath:destination];
795 if (![[NSFileManager defaultManager] oo_moveItemAtPath:[
self downloadPath] toPath:destination])
820 NSArray *
requires = [
downloadedManifest oo_arrayForKey:kOOManifestRequiresOXPs defaultValue:nil];
824 requires = [
expectedManifest oo_arrayForKey:kOOManifestRequiresOXPs defaultValue:nil];
826 NSDictionary *requirement =
nil;
830 if ([_dependencyStack
count] > 0)
833 NSSet *tempStack = [
NSSet setWithSet:_dependencyStack];
834 foreach (requirement, tempStack)
837 if (![
ResourceManager manifest:downloadedManifest HasUnmetDependency:requirement logErrors:NO]
838 &&
requires !=
nil && [
requires containsObject:requirement])
841 [
progress appendFormat:DESC(@"oolite-oxzmanager-progress-now-has-@"),[
requirement oo_stringForKey:kOOManifestRelationDescription defaultValue:[
requirement oo_stringForKey:kOOManifestRelationIdentifier]]];
852 foreach (requirement,
requires)
854 if ([
ResourceManager manifest:downloadedManifest HasUnmetDependency:requirement logErrors:NO])
858 [
progress appendFormat:DESC(@"oolite-oxzmanager-progress-requires-@"),[
requirement oo_stringForKey:kOOManifestRelationDescription defaultValue:[
requirement oo_stringForKey:kOOManifestRelationIdentifier]]];
862 if ([_dependencyStack
count] > 0)
866 BOOL undownloadedRequirement = NO;
867 NSDictionary *availableDownload =
nil;
868 BOOL foundDownload = NO;
869 NSUInteger index = 0;
870 NSString *needsIdentifier =
nil;
874 undownloadedRequirement = YES;
878 if (!_downloadAllDependencies)
880 [
progress appendString:DESC(@"oolite-oxzmanager-progress-get-required")];
882 needsIdentifier = [
requirement oo_stringForKey:kOOManifestRelationIdentifier];
884 foreach (availableDownload, _oxzList)
892 index = [
_oxzList indexOfObject:availableDownload];
907 if ([_dependencyStack
count] > 0)
910 undownloadedRequirement = NO;
921 while (!undownloadedRequirement);
929 if (_downloadAllDependencies)
932 if (![
self installOXZ:index]) {
935 [
progress appendFormat:DESC(@"oolite-oxzmanager-progress-required-@-not-found"),[
requirement oo_stringForKey:kOOManifestRelationDescription defaultValue:[
requirement oo_stringForKey:kOOManifestRelationIdentifier]]];
937 OOLog(
kOOOXZErrorLog,
@"OXZ dependency %@ could not be found for automatic download.",needsIdentifier);
955 else if ([_dependencyStack
count] > 0)
957 [
progress appendFormat:DESC(@"oolite-oxzmanager-progress-required-@-not-found"),[
requirement oo_stringForKey:kOOManifestRelationDescription defaultValue:[
requirement oo_stringForKey:kOOManifestRelationIdentifier]]];
959 OOLog(
kOOOXZErrorLog,
@"OXZ dependency %@ could not be found for automatic download.",needsIdentifier);
971 _downloadAllDependencies = NO;
977- (NSDictionary *) installedManifestForIdentifier:(NSString *)identifier
980 NSDictionary *manifest =
nil;
981 foreach (manifest,installed)
977- (NSDictionary *) installedManifestForIdentifier:(NSString *)identifier {
…}
994 NSString *title = [
manifest oo_stringForKey:kOOManifestTitle defaultValue:nil];
995 NSString *identifier = [
manifest oo_stringForKey:kOOManifestIdentifier defaultValue:nil];
997 if (![
ResourceManager checkVersionCompatibility:manifest forOXP:title])
1003 if (installed ==
nil)
1009 if (installed !=
nil)
1017 && [[NSFileManager defaultManager] fileExistsAtPath:[installed oo_stringForKey:
kOOManifestFilePath]])
1035 if (installed !=
nil)
1037 NSString *availableVersion = [
manifest oo_stringForKey:kOOManifestAvailableVersion];
1038 if (availableVersion ==
nil)
1040 availableVersion = [
manifest oo_stringForKey:kOOManifestVersion];
1042 NSString *installedVersion = [
installed oo_stringForKey:kOOManifestVersion];
1043 OOLog(
@"version.debug",
@"%@ mv:%@ mav:%@",identifier,installedVersion,availableVersion);
1051 if ([
ResourceManager manifestHasMissingDependencies:manifest logErrors:NO])
1059- (
OOColor *) colorForManifest:(NSDictionary *)manifest
1061 switch ([
self installableState:manifest])
1059- (
OOColor *) colorForManifest:(NSDictionary *)manifest {
…}
1084- (NSString *) installStatusForManifest:(NSDictionary *)manifest
1086 switch ([
self installableState:manifest])
1089 return DESC(
@"oolite-oxzmanager-installable-okay");
1091 return DESC(
@"oolite-oxzmanager-installable-update");
1093 return DESC(
@"oolite-oxzmanager-installable-depend");
1095 return DESC(
@"oolite-oxzmanager-installable-conflicts");
1097 return DESC(
@"oolite-oxzmanager-installable-already");
1099 return DESC(
@"oolite-oxzmanager-installable-manual");
1101 return DESC(
@"oolite-oxzmanager-installable-version");
1103 return DESC(
@"oolite-oxzmanager-installable-noremote");
1084- (NSString *) installStatusForManifest:(NSDictionary *)manifest {
…}
1119 [PLAYER destroySound];
1123 [gui
setTitle:DESC(@"oolite-oxzmanager-title")];
1130 [gui
setTitle:DESC(@"oolite-oxzmanager-title-setfilter")];
1131 [gui
setText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-currentfilter-is-@"),_currentFilter]
forRow:OXZ_GUI_ROW_FILTERCURRENT
align:GUI_ALIGN_LEFT];
1140 [gui
setText:DESC(@"oolite-oxzmanager-download-list")
forRow:OXZ_GUI_ROW_UPDATE
align:GUI_ALIGN_CENTER];
1149 [gui
setText:DESC(@"oolite-oxzmanager-download-noupdate")
forRow:OXZ_GUI_ROW_PROCEED
align:GUI_ALIGN_CENTER];
1152 [gui
setText:DESC(@"oolite-oxzmanager-update-list")
forRow:OXZ_GUI_ROW_UPDATE
align:GUI_ALIGN_CENTER];
1169 [gui
setText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-currentfilter-is-@-@"),OOExpand(@"[oolite_key_oxzmanager_setfilter]"),_currentFilter]
forRow:OXZ_GUI_ROW_LISTFILTER
align:GUI_ALIGN_LEFT];
1173 [gui
setText:DESC(@"oolite-oxzmanager-install")
forRow:OXZ_GUI_ROW_INSTALL
align:GUI_ALIGN_CENTER];
1175 [gui
setText:DESC(@"oolite-oxzmanager-installed")
forRow:OXZ_GUI_ROW_INSTALLED
align:GUI_ALIGN_CENTER];
1176 [gui
setKey:@"_INSTALLED"
forRow:OXZ_GUI_ROW_INSTALLED];
1177 [gui
setText:DESC(@"oolite-oxzmanager-remove")
forRow:OXZ_GUI_ROW_REMOVE
align:GUI_ALIGN_CENTER];
1179 [gui
setText:DESC(@"oolite-oxzmanager-update-list")
forRow:OXZ_GUI_ROW_UPDATE
align:GUI_ALIGN_CENTER];
1181 [gui
setText:DESC(@"oolite-oxzmanager-update-all")
forRow:OXZ_GUI_ROW_UPDATE_ALL
align:GUI_ALIGN_CENTER];
1182 [gui
setKey:@"_UPDATE_ALL"
forRow:OXZ_GUI_ROW_UPDATE_ALL];
1188 [gui
setTitle:DESC(@"oolite-oxzmanager-title-downloading")];
1194 [gui
setText:DESC(@"oolite-oxzmanager-cancel")
forRow:OXZ_GUI_ROW_CANCEL
align:GUI_ALIGN_CENTER];
1199 [gui
setTitle:DESC(@"oolite-oxzmanager-title-dependencies")];
1201 [gui
setText:DESC(@"oolite-oxzmanager-dependencies-decision")
forRow:OXZ_GUI_ROW_PROGRESS
align:GUI_ALIGN_LEFT];
1206 [gui
setText:DESC(@"oolite-oxzmanager-dependencies-yes-all")
forRow:OXZ_GUI_ROW_INSTALLED
align:GUI_ALIGN_CENTER];
1207 [gui
setKey:@"_PROCEED_ALL"
forRow:OXZ_GUI_ROW_INSTALLED];
1209 [gui
setText:DESC(@"oolite-oxzmanager-dependencies-yes")
forRow:OXZ_GUI_ROW_PROCEED
align:GUI_ALIGN_CENTER];
1212 [gui
setText:DESC(@"oolite-oxzmanager-dependencies-no")
forRow:OXZ_GUI_ROW_CANCEL
align:GUI_ALIGN_CENTER];
1218 [gui
setText:DESC(@"oolite-oxzmanager-acknowledge")
forRow:OXZ_GUI_ROW_UPDATE
align:GUI_ALIGN_CENTER];
1233 [gui
setText:DESC(@"oolite-oxzmanager-acknowledge")
forRow:OXZ_GUI_ROW_UPDATE
align:GUI_ALIGN_CENTER];
1239 NSDictionary *manifest = [_filteredList oo_dictionaryAtIndex:_item];
1240 NSString *title = [
manifest oo_stringForKey:kOOManifestTitle];
1241 NSString *version = [
manifest oo_stringForKey:kOOManifestVersion];
1242 NSString *identifier = [
manifest oo_stringForKey:kOOManifestIdentifier];
1243 [gui
setTitle:DESC(@"oolite-oxzmanager-title-extract")];
1244 [gui
setText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-infopage-title-@-version-@"),
1255 if ([[NSFileManager defaultManager] fileExistsAtPath:path])
1257 [gui
addLongText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-extract-@-already-exists"), path]
1260 [gui
setText:DESC(@"oolite-oxzmanager-extract-unavailable")
forRow:OXZ_GUI_ROW_PROCEED
align:GUI_ALIGN_CENTER];
1265 [gui
addLongText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-extract-to-@"), path]
1268 [gui
setText:DESC(@"oolite-oxzmanager-extract-proceed")
forRow:OXZ_GUI_ROW_PROCEED
align:GUI_ALIGN_CENTER];
1272 [gui
setText:DESC(@"oolite-oxzmanager-extract-cancel")
forRow:OXZ_GUI_ROW_CANCEL
align:GUI_ALIGN_CENTER];
1279 [gui
setText:DESC(@"oolite-oxzmanager-acknowledge")
forRow:OXZ_GUI_ROW_UPDATE
align:GUI_ALIGN_CENTER];
1288 [gui
setTitle:DESC(@"oolite-oxzmanager-title-install")];
1294 [gui
setTitle:DESC(@"oolite-oxzmanager-title-installed")];
1300 [gui
setTitle:DESC(@"oolite-oxzmanager-title-remove")];
1308 [gui
setText:DESC(@"oolite-oxzmanager-exit-restart")
forRow:OXZ_GUI_ROW_EXIT
align:GUI_ALIGN_CENTER];
1312 [gui
setText:DESC(@"oolite-oxzmanager-exit")
forRow:OXZ_GUI_ROW_EXIT
align:GUI_ALIGN_CENTER];
1339 [UNIVERSE reinitAndShowDemo:YES];
1360 [_dependencyStack removeAllObjects];
1369 [PLAYER setGuiToIntroFirstGo:YES];
1390 [_dependencyStack removeAllObjects];
1397 [_dependencyStack removeAllObjects];
1502- (void) processTextInput:(NSString *)input
1504 if ([
self validateFilter:input])
1506 if ([input length] > 0)
1502- (void) processTextInput:(NSString *)input {
…}
1517- (void) refreshTextInput:(NSString *)input
1520 [gui
setText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-text-prompt-@"), input]
forRow:OXZ_GUI_ROW_INPUT
align:GUI_ALIGN_LEFT];
1521 if ([
self validateFilter:input])
1517- (void) refreshTextInput:(NSString *)input {
…}
1541 [[UNIVERSE gameView] resetTypedString];
1576 NSDictionary *manifest = [_filteredList oo_dictionaryAtIndex:_item];
1580 [gui
setTitle:DESC(@"oolite-oxzmanager-title-infopage")];
1583 [gui
setText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-infopage-title-@-version-@"),
1584 [
manifest oo_stringForKey:kOOManifestTitle],
1585 [
manifest oo_stringForKey:kOOManifestVersion]]
1589 [gui
setText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-infopage-author-@"),
1590 [
manifest oo_stringForKey:kOOManifestAuthor]]
1594 [gui
addLongText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-infopage-license-@"),
1595 [
manifest oo_stringForKey:kOOManifestLicense]]
1599 [gui
addLongText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-infopage-tags-@"),[[
manifest oo_arrayForKey:kOOManifestTags] componentsJoinedByString: @", "]]
1602 [gui
addLongText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-infopage-description-@"),[
manifest oo_stringForKey:kOOManifestDescription]]
1606 NSString *infoURLString = [
manifest oo_stringForKey:kOOManifestInformationURL];
1607 [gui
setText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-infopage-infourl-@"),
1611 [[UNIVERSE gameView] stringToClipboard:infoURLString];
1614 [gui
setText:OOExpand(DESC(@"oolite-oxzmanager-infopage-return"))
forRow:27
align:GUI_ALIGN_CENTER];
1644- (BOOL) installOXZ:(NSUInteger)item
1646 NSArray *picklist = _filteredList;
1648 if ([picklist
count] <= item)
1652 NSDictionary *manifest = [
picklist objectAtIndex:item];
1661 NSString *url = [
manifest objectForKey:kOOManifestDownloadURL];
1644- (BOOL) installOXZ:(NSUInteger)item {
…}
1683 _downloadAllDependencies = YES;
1685 NSDictionary *manifest =
nil;
1687 foreach (manifest,_oxzList)
1696 NSString* identifier = [
first oo_stringForKey:kOOManifestRelationIdentifier];
1697 NSUInteger item = NSUIntegerMax;
1698 NSDictionary *availableDownload =
nil;
1699 foreach (availableDownload, _oxzList)
1703 item = [
_oxzList indexOfObject:availableDownload];
1713 NSUInteger start = _offset;
1714 if (start >= [_filteredList
count])
1720 if (end > [_filteredList
count])
1724 return [
_filteredList subarrayWithRange:NSMakeRange(start,end-start)];
1733 NSUInteger optCount = [_filteredList count];
1743 [gui
setArray:[
NSArray arrayWithObjects:DESC(@"oolite-oxzmanager-heading-category"),
1744 DESC(@"oolite-oxzmanager-heading-title"),
1745 DESC(@"oolite-oxzmanager-heading-installed"),
1746 DESC(@"oolite-oxzmanager-heading-downloadable"),
1747 nil]
forRow:OXZ_GUI_ROW_LISTHEAD];
1752 [gui
setArray:[
NSArray arrayWithObjects:DESC(@"gui-back"), @"",@"",@" <-- ", nil]
forRow:OXZ_GUI_ROW_LISTPREV];
1767 [gui
setArray:[
NSArray arrayWithObjects:DESC(@"gui-more"), @"",@"",@" --> ", nil]
forRow:OXZ_GUI_ROW_LISTNEXT];
1794 NSDictionary *manifest =
nil;
1795 BOOL oxzLineSelected = NO;
1797 foreach (manifest, options)
1800 NSString *localPath = [[[
self installPath] stringByAppendingPathComponent:[
manifest oo_stringForKey:kOOManifestIdentifier]] stringByAppendingPathExtension:@"oxz"];
1801 if (installed ==
nil)
1804 installed =
OODictionaryFromFile([localPath stringByAppendingPathComponent:
@"manifest.plist"]);
1809 if ([[NSFileManager defaultManager] fileExistsAtPath:localPath])
1812 installed =
OODictionaryFromFile([localPath stringByAppendingPathComponent:
@"manifest.plist"]);
1824 NSString *installedVersion =
DESC(
@"oolite-oxzmanager-version-none");
1825 if (installed !=
nil)
1827 installedVersion = [
installed oo_stringForKey:kOOManifestVersion defaultValue:DESC(@"oolite-oxzmanager-version-none")];
1833 [
manifest oo_stringForKey:kOOManifestCategory defaultValue:DESC(@"oolite-oxzmanager-missing-field")],
1834 [
manifest oo_stringForKey:kOOManifestTitle defaultValue:DESC(@"oolite-oxzmanager-missing-field")],
1836 [
manifest oo_stringForKey:kOOManifestAvailableVersion defaultValue:[
manifest oo_stringForKey:kOOManifestVersion defaultValue:DESC(@"oolite-oxzmanager-version-none")]],
1843 if (row == [
gui selectedRow])
1845 oxzLineSelected = YES;
1850 [gui
addLongText:[[[
manifest oo_stringForKey:kOOManifestDescription] componentsSeparatedByString:@"\n"] oo_stringAtIndex:0]
startingAtRow:OXZ_GUI_ROW_LISTDESC
align:GUI_ALIGN_LEFT];
1852 NSString *infoUrl = [
manifest oo_stringForKey:kOOManifestInformationURL];
1855 [gui
setArray:[
NSArray arrayWithObjects:DESC(@"oolite-oxzmanager-infoline-url"),infoUrl,nil]
forRow:OXZ_GUI_ROW_LISTINFO1];
1857 NSUInteger
size = [
manifest oo_unsignedIntForKey:kOOManifestFileSize defaultValue:0];
1858 NSString *updatedDesc =
nil;
1860 NSUInteger timestamp = [
manifest oo_unsignedIntegerForKey:kOOManifestUploadDate defaultValue:0];
1864 NSDate *updated = [
NSDate dateWithTimeIntervalSince1970:timestamp];
1867 updatedDesc = [[[
updated description] componentsSeparatedByString:@" "] oo_stringAtIndex:0];
1869 [gui
setArray:[
NSArray arrayWithObjects:DESC(@"oolite-oxzmanager-infoline-size"),[
self humanSize:size],DESC(@"oolite-oxzmanager-infoline-date"),updatedDesc,nil]
forRow:OXZ_GUI_ROW_LISTINFO2];
1884 if (!oxzLineSelected)
1904- (BOOL) removeOXZ:(NSUInteger)item
1906 NSArray *remList = _filteredList;
1907 if ([remList
count] <= item)
1909 OOLog(
kOOOXZDebugLog,
@"Unable to remove item %lu as only %lu in list", (
unsigned long)item, (
unsigned long)[remList
count]);
1912 NSString *
filename = [[
remList objectAtIndex:item] oo_stringForKey:kOOManifestFilePath];
1915 OOLog(
kOOOXZDebugLog,
@"Unable to remove item %lu as filename not found", (
unsigned long)item);
1919 if (![[NSFileManager defaultManager] oo_removeItemAtPath:
filename])
1904- (BOOL) removeOXZ:(NSUInteger)item {
…}
1934 NSArray *remList = _filteredList;
1935 if ([remList
count] == 0)
1939 NSUInteger start = _offset;
1940 if (start >= [remList
count])
1946 if (end > [remList
count])
1950 return [
remList subarrayWithRange:NSMakeRange(start,end-start)];
1972 [gui
setArray:[
NSArray arrayWithObjects:DESC(@"oolite-oxzmanager-heading-category"),
1973 DESC(@"oolite-oxzmanager-heading-title"),
1974 DESC(@"oolite-oxzmanager-heading-version"),
1975 nil]
forRow:OXZ_GUI_ROW_LISTHEAD];
1979 [gui
setArray:[
NSArray arrayWithObjects:DESC(@"gui-back"), @"",@" <-- ", nil]
forRow:OXZ_GUI_ROW_LISTPREV];
1994 [gui
setArray:[
NSArray arrayWithObjects:DESC(@"gui-more"), @"",@" --> ", nil]
forRow:OXZ_GUI_ROW_LISTNEXT];
2022 NSDictionary *manifest =
nil;
2023 BOOL oxzSelected = NO;
2025 foreach (manifest, options)
2029 [
manifest oo_stringForKey:kOOManifestCategory defaultValue:DESC(@"oolite-oxzmanager-missing-field")],
2030 [
manifest oo_stringForKey:kOOManifestTitle defaultValue:DESC(@"oolite-oxzmanager-missing-field")],
2031 [
manifest oo_stringForKey:kOOManifestVersion defaultValue:DESC(@"oolite-oxzmanager-missing-field")],
2033 NSString *identifier = [
manifest oo_stringForKey:kOOManifestIdentifier];
2038 if (row == [
gui selectedRow])
2043 [gui
addLongText:[[[
manifest oo_stringForKey:kOOManifestDescription] componentsSeparatedByString:@"\n"] oo_stringAtIndex:0]
startingAtRow:OXZ_GUI_ROW_LISTDESC
align:GUI_ALIGN_LEFT];
2132- (NSString *) extractOXZ:(NSUInteger)item
2136 NSDictionary *manifest = [
_filteredList oo_dictionaryAtIndex:item];
2137 NSString *version = [
manifest oo_stringForKey:kOOManifestVersion];
2138 NSString *identifier = [
manifest oo_stringForKey:kOOManifestIdentifier];
2145 NSString *oxzfile = [
manifest oo_stringForKey:kOOManifestFilePath];
2146 if (![fmgr fileExistsAtPath:oxzfile])
2149 [
extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-no-original")];
2152 const char* zipname = [
oxzfile UTF8String];
2158 [
extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-bad-original")];
2162 if ([fmgr fileExistsAtPath:path])
2165 [
extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-main-exists")];
2169 if (![fmgr oo_createDirectoryAtPath:path attributes:
nil])
2172 [
extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-main-unmakeable")];
2176 [
extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-main-created")];
2177 NSUInteger counter = 0;
2178 char rawComponentName[512];
2186 rawComponentName, 512,
2189 NSString *componentName = [
NSString stringWithUTF8String:rawComponentName];
2190 if ([componentName hasSuffix:
@"/"])
2193 if (![fmgr oo_createDirectoryAtPath:[path stringByAppendingPathComponent:componentName] attributes:
nil])
2196 [
extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-sub-failed")];
2209 NSString *folder = [[
path stringByAppendingPathComponent:componentName] stringByDeletingLastPathComponent];
2210 if ([folder length] > 0 && ![fmgr fileExistsAtPath:folder] && ![fmgr oo_createDirectoryAtPath:folder attributes:
nil])
2213 [
extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-sub-failed")];
2223 NSData *tmp = [
NSData oo_dataWithOXZFile:[
oxzfile stringByAppendingPathComponent:componentName]];
2227 [
extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-sub-failed")];
2234 if (![tmp writeToFile:[path stringByAppendingPathComponent:componentName] atomically:YES])
2237 [
extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-sub-failed")];
2257 [
extractionLog appendFormat:DESC(@"oolite-oxzmanager-extract-log-num-u-extracted"),counter];
2258 [
extractionLog appendFormat:DESC(@"oolite-oxzmanager-extract-log-extracted-to-@"),path];
2132- (NSString *) extractOXZ:(NSUInteger)item {
…}
2267- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
2271 _downloadExpected = [
response expectedContentLength];
2272 _downloadProgress = 0;
2276 if (_fileWriter ==
nil)
2267- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
…}
2285- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
2290 _downloadProgress += [
data length];
2308 [[
NSRunLoop currentRunLoop] limitDateForMode:NSDefaultRunLoopMode];
2285- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
…}
2313- (void)connectionDidFinishLoading:(NSURLConnection *)connection
2337 OOLog(
kOOOXZErrorLog,
@"Error: download completed in unexpected state %d. This is an internal error - please report it.",_interfaceState);
2313- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
…}
2343- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
2343- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
…}
2358NSComparisonResult
oxzSort(
id m1,
id m2,
void *context)
2360 NSComparisonResult result = [[m1 oo_stringForKey:kOOManifestCategory defaultValue:@"zz"] localizedCompare:[m2 oo_stringForKey:kOOManifestCategory defaultValue:@"zz"]];
2361 if (result == NSOrderedSame)
2363 result = [[m1 oo_stringForKey:kOOManifestTitle defaultValue:@"zz"] localizedCompare:[m2 oo_stringForKey:kOOManifestTitle defaultValue:@"zz"]];
2364 if (result == NSOrderedSame)
2366 result = [[m2 oo_stringForKey:kOOManifestVersion defaultValue:@"0"] localizedCompare:[m1 oo_stringForKey:kOOManifestVersion defaultValue:@"0"]];
2358NSComparisonResult
oxzSort(
id m1,
id m2,
void *context) {
…}
OOGUITabStop OOGUITabSettings[GUI_MAX_COLUMNS]
static OODebugMonitor * sSingleton
#define OOLog(class, format,...)
static NSString *const kOOManifestAvailableVersion
static NSString *const kOOManifestRelationIdentifier
static NSString *const kOOManifestIdentifier
static NSString *const kOOManifestVersion
static NSString *const kOOManifestFilePath
@ OXZ_STATE_PICK_INSTALLED
static NSString *const kOOOXZFilterDays
static NSString *const kOOOXZErrorLog
static NSString *const kOOOXZFilterTag
static NSString *const kOOOXZFilterKeyword
@ OXZ_INSTALLABLE_DEPENDENCIES
@ OXZ_INSTALLABLE_CONFLICTS
@ OXZ_UNINSTALLABLE_VERSION
@ OXZ_UNINSTALLABLE_ALREADY
@ OXZ_UNINSTALLABLE_NOREMOTE
@ OXZ_UNINSTALLABLE_MANUAL
@ OXZ_GUI_ROW_FILTERCURRENT
static NSString *const kOOOXZManifestCache
static NSString *const kOOOXZFilterUpdates
static NSString *const kOOOXZFilterAll
static NSString *const kOOOXZFilterCategory
static NSString *const kOOOXZFilterInstallable
static NSString *const kOOOXZTmpPlistPath
static NSString *const kOOOXZFilterAuthor
NSComparisonResult oxzSort(id m1, id m2, void *context)
static NSString *const kOOOXZDataURL
static NSString *const kOOOXZTmpPath
static NSString *const kOOOXZDataConfig
static NSString *const kOOOXZDebugLog
NSDictionary * OODictionaryFromFile(NSString *path)
NSArray * ComponentsFromVersionString(NSString *string)
NSComparisonResult CompareVersions(NSArray *version1, NSArray *version2)
BOOL processDownloadedOXZ()
NSString * downloadPath()
NSArray * installOptions()
BOOL processDownloadedManifests()
NSArray * removeOptions()
NSString * manifestPath()
BOOL setSelectedRow:(OOGUIRow row)
OOGUIRow addLongText:startingAtRow:align:(NSString *str,[startingAtRow] OOGUIRow row,[align] OOGUIAlignment alignment)
void setText:forRow:(NSString *str,[forRow] OOGUIRow row)
void setText:forRow:align:(NSString *str,[forRow] OOGUIRow row,[align] OOGUIAlignment alignment)
void clearAndKeepBackground:(BOOL keepBackground)
void setSelectableRange:(NSRange range)
void setColor:forRow:(OOColor *color,[forRow] OOGUIRow row)
void setTitle:(NSString *str)
void setTabStops:(OOGUITabSettings stops)
void setArray:forRow:(NSArray *arr,[forRow] OOGUIRow row)
void setKey:forRow:(NSString *str,[forRow] OOGUIRow row)
NSString * cacheDirectoryPathCreatingIfNecessary:(BOOL create)
OOCacheManager * sharedCache()
void setProgressStatus:(NSString *new)
BOOL _downloadAllDependencies
OOGUIRow showRemoveOptions()
NSArray * installOptions()
NSDictionary * installedManifestForIdentifier:(NSString *identifier)
NSURLConnection * _currentDownload
void setFilteredList:(NSArray *list)
NSArray * removeOptions()
void processOptionsNext()
NSString * extractOXZ:(NSUInteger item)
NSString * extractionBasePathForIdentifier:andVersion:(NSString *identifier, [andVersion] NSString *version)
void setFilter:(NSString *filter)
NSString * _currentFilter
OXZDownloadStatus _downloadStatus
NSString * manifestPath()
void setCurrentDownload:withLabel:(NSURLConnection *download, [withLabel] NSString *label)
NSArray * applyCurrentFilter:(NSArray *list)
NSString * humanSize:(NSUInteger bytes)
void processOptionsPrev()
BOOL installOXZ:(NSUInteger item)
BOOL _interfaceShowingOXZDetail
NSString * installStatusForManifest:(NSDictionary *manifest)
void setOXZList:(NSArray *list)
NSString * downloadPath()
OOColor * colorForManifest:(NSDictionary *manifest)
BOOL isAcceptingGUIInput()
NSMutableSet * _dependencyStack
OOOXZManager * sharedManager()
BOOL beginDownload:(NSMutableURLRequest *request)
OXZInterfaceState _interfaceState
BOOL removeOXZ:(NSUInteger item)
BOOL isAcceptingTextInput()
OOGUIRow showInstallOptions()
void processShowInfoKey()
void resetManifestKnowledgeForOXZManager()
NSDictionary * manifestForIdentifier:(NSString *identifier)
NSArray * userRootPaths()
int ZEXPORT unzGetCurrentFileInfo64(unzFile file, unz_file_info64 *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
int ZEXPORT unzGoToFirstFile(unzFile file)
unzFile ZEXPORT unzOpen64(const void *path)
int ZEXPORT unzGoToNextFile(unzFile file)
int ZEXPORT unzClose(unzFile file)
struct unz_file_info64_s unz_file_info64