51static NSString*
const kOOOXZDataURL =
@"https://addons.oolite.space/api/1.0/overview";
114NSComparisonResult
oxzSort(
id m1,
id m2,
void* context);
119@interface OOOXZManager (NSURLConnectionDataDelegate)
123- (NSString*)extractionBasePathForIdentifier:(NSString*)identifier andVersion:(NSString*)version;
125- (NSString*)humanSize:(NSUInteger)bytes;
129- (BOOL)beginDownload:(NSMutableURLRequest*)request;
134- (
OOColor*)colorForManifest:(NSDictionary*)manifest;
135- (NSString*)installStatusForManifest:(NSDictionary*)manifest;
137- (BOOL)validateFilter:(NSString*)input;
139- (void)setOXZList:(NSArray*)list;
140- (void)setFilteredList:(NSArray*)list;
141- (NSArray*)applyCurrentFilter:(NSArray*)list;
143- (void)setCurrentDownload:(NSURLConnection*)download withLabel:(NSString*)label;
144- (void)setProgressStatus:(NSString*)newStatus;
146- (BOOL)installOXZ:(NSUInteger)item;
148- (BOOL)removeOXZ:(NSUInteger)item;
152- (NSString*)extractOXZ:(NSUInteger)item;
155- (void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error;
156- (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response;
157- (void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data;
158- (void)connectionDidFinishLoading:(NSURLConnection*)connection;
162@interface OOOXZManager (OOFilterRules)
163- (BOOL)applyFilterByNoFilter:(NSDictionary*)manifest;
164- (BOOL)applyFilterByUpdateRequired:(NSDictionary*)manifest;
165- (BOOL)applyFilterByInstallable:(NSDictionary*)manifest;
166- (BOOL)applyFilterByKeyword:(NSDictionary*)manifest keyword:(NSString*)keyword;
167- (BOOL)applyFilterByAuthor:(NSDictionary*)manifest author:(NSString*)author;
168- (BOOL)applyFilterByDays:(NSDictionary*)manifest days:(NSString*)days;
169- (BOOL)applyFilterByTag:(NSDictionary*)manifest tag:(NSString*)tag;
170- (BOOL)applyFilterByCategory:(NSDictionary*)manifest category:(NSString*)category;
222 const char* managedAddOnsEnv = SDL_getenv(
"OO_MANAGEDADDONSDIR");
224 if (managedAddOnsEnv) {
225 return [
NSString stringWithUTF8String:managedAddOnsEnv];
227 NSArray* paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
228 NSString* appPath = [
paths objectAtIndex:0];
229 if (appPath !=
nil) {
230 appPath = [
appPath stringByAppendingPathComponent:@"Oolite"];
232 appPath = [
appPath stringByAppendingPathComponent:@"Managed AddOns"];
237 appPath = [
appPath stringByAppendingPathComponent:@"ManagedAddOns"];
248 const char* addOnsExtractEnv = SDL_getenv(
"OO_ADDONSEXTRACTDIR");
250 if (addOnsExtractEnv) {
251 return [
NSString stringWithUTF8String:addOnsExtractEnv];
254#if OO_GAME_DATA_TO_USER_FOLDER
255 return [
NSString stringWithFormat:@"%s\\Oolite\\AddOns", SDL_getenv("LOCALAPPDATA")];
260 return [[
NSHomeDirectory() stringByAppendingPathComponent:@".Oolite"] stringByAppendingPathComponent:@"AddOns"];
268 const char* additionalAddOnsEnv = SDL_getenv(
"OO_ADDITIONALADDONSDIRS");
270 if (additionalAddOnsEnv) {
271 NSString* envStr = [
NSString stringWithUTF8String:additionalAddOnsEnv];
272 return [
envStr componentsSeparatedByString:@","];
277- (NSString*)extractionBasePathForIdentifier:(NSString*)identifier andVersion:(NSString*)version
280 NSString* rawMainDir = [
NSString stringWithFormat:@"%@-%@.off", identifier, version];
282 NSCharacterSet* blacklist = [
NSCharacterSet characterSetWithCharactersInString:@"'#%^&{}[]/~|\\?<,:\" "];
283 return [[[
basePath stringByAppendingPathComponent:[[
rawMainDir componentsSeparatedByCharactersInSet:blacklist] componentsJoinedByString:@""]] retain] autorelease];
288 BOOL exists, directory;
292 exists = [
fmgr fileExistsAtPath:path isDirectory:&directory];
294 if (exists && !directory) {
299 if (![fmgr oo_createDirectoryAtPath:path attributes:
nil]) {
328 NSString* url = [[
NSUserDefaults standardUserDefaults] stringForKey:kOOOXZDataConfig];
335- (NSString*)humanSize:(NSUInteger)bytes
338 return DESC(
@"oolite-oxzmanager-missing-field");
339 }
else if (bytes < 1024) {
341 }
else if (bytes < 1024 * 1024) {
342 return [
NSString stringWithFormat:@"%zu kB", bytes >> 10];
344 return [
NSString stringWithFormat:@"%.2f MB", ((float)(bytes >> 10)) / 1024];
348- (void)setOXZList:(NSArray*)list
352 _oxzList = [[
list sortedArrayUsingFunction:oxzSort context:NULL] retain];
358- (void)setFilteredList:(NSArray*)list
361 _filteredList = [
list copy];
364- (void)setFilter:(NSString*)filter
370- (void)setOXPURL:(NSString*)url
376- (NSArray*)applyCurrentFilter:(NSArray*)list
378 SEL filterSelector =
@selector(applyFilterByNoFilter:);
379 NSString* parameter =
nil;
381 filterSelector =
@selector(applyFilterByUpdateRequired:);
383 filterSelector =
@selector(applyFilterByInstallable:);
385 filterSelector =
@selector(applyFilterByKeyword:keyword:);
386 parameter = [
_currentFilter substringFromIndex:[kOOOXZFilterKeyword length]];
388 filterSelector =
@selector(applyFilterByAuthor:author:);
389 parameter = [
_currentFilter substringFromIndex:[kOOOXZFilterAuthor length]];
391 filterSelector =
@selector(applyFilterByDays:days:);
392 parameter = [
_currentFilter substringFromIndex:[kOOOXZFilterDays length]];
394 filterSelector =
@selector(applyFilterByTag:tag:);
395 parameter = [
_currentFilter substringFromIndex:[kOOOXZFilterTag length]];
397 filterSelector =
@selector(applyFilterByCategory:category:);
398 parameter = [
_currentFilter substringFromIndex:[kOOOXZFilterCategory length]];
402 NSDictionary* manifest =
nil;
403 NSInvocation* invocation = [
NSInvocation invocationWithMethodSignature:[[
self class] instanceMethodSignatureForSelector:filterSelector]];
406 if (parameter !=
nil) {
407 [
invocation setArgument:¶meter atIndex:3];
410 foreach (manifest, list) {
413 BOOL filterAccepted = NO;
415 if (filterAccepted) {
425- (BOOL)applyFilterByNoFilter:(NSDictionary*)manifest
430- (BOOL)applyFilterByUpdateRequired:(NSDictionary*)manifest
435- (BOOL)applyFilterByInstallable:(NSDictionary*)manifest
440- (BOOL)applyFilterByKeyword:(NSDictionary*)manifest keyword:(NSString*)keyword
442 NSString* parameter =
nil;
443 NSArray* parameters = [
NSArray arrayWithObjects:kOOManifestTitle, kOOManifestDescription, kOOManifestCategory, nil];
446 keyword = [
keyword stringByTrimmingLeadingWhitespaceAndNewlineCharacters];
448 foreach (parameter, parameters) {
449 if ([[manifest oo_stringForKey:parameter] rangeOfString:keyword options:NSCaseInsensitiveSearch].location != NSNotFound) {
454 parameters = [
manifest oo_arrayForKey:kOOManifestTags];
455 foreach (parameter, parameters) {
456 if ([parameter rangeOfString:keyword options:NSCaseInsensitiveSearch].location != NSNotFound) {
464- (BOOL)applyFilterByAuthor:(NSDictionary*)manifest author:(NSString*)author
467 author = [
author stringByTrimmingLeadingWhitespaceAndNewlineCharacters];
469 NSString* mAuth = [
manifest oo_stringForKey:kOOManifestAuthor];
470 return ([mAuth rangeOfString:author options:NSCaseInsensitiveSearch].location != NSNotFound);
473- (BOOL)applyFilterByDays:(NSDictionary*)manifest days:(NSString*)days
475 NSInteger i = [
days integerValue];
479 NSUInteger updated = [
manifest oo_unsignedIntegerForKey:kOOManifestUploadDate];
480 NSUInteger now = (NSUInteger)[[NSDate date] timeIntervalSince1970];
481 return (updated + (86400 * i) > now);
485- (BOOL)applyFilterByTag:(NSDictionary*)manifest tag:(NSString*)tag
487 NSString* parameter =
nil;
488 NSArray* parameters = [
manifest oo_arrayForKey:kOOManifestTags];
491 tag = [
tag stringByTrimmingLeadingWhitespaceAndNewlineCharacters];
493 foreach (parameter, parameters) {
494 if ([parameter rangeOfString:tag options:NSCaseInsensitiveSearch].location != NSNotFound) {
502- (BOOL)applyFilterByCategory:(NSDictionary*)manifest category:(NSString*)category
505 category = [
category stringByTrimmingLeadingWhitespaceAndNewlineCharacters];
507 NSString* mCategory = [
manifest oo_stringForKey:kOOManifestCategory];
508 return ([mCategory rangeOfString:category options:NSCaseInsensitiveSearch].location != NSNotFound);
513- (BOOL)validateFilter:(NSString*)input
515 NSString* filter = [
input lowercaseString];
516 if (([filter length] == 0)
531- (void)setCurrentDownload:(NSURLConnection*)download withLabel:(NSString*)label
533 if (_currentDownload !=
nil) {
536 _currentDownload = [
download retain];
538 _currentDownloadName = [
label copy];
541- (void)setProgressStatus:(NSString*)new
544 _progressStatus = [
new copy];
560- (BOOL)beginDownload:(NSMutableURLRequest*)request
562 NSString* userAgent = [
NSString stringWithFormat:@"Oolite/%@", [[[
NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]];
563 [
request setValue:userAgent forHTTPHeaderField:@"User-Agent"];
564 [
request setHTTPShouldHandleCookies:NO];
565 NSURLConnection* download = [[
NSURLConnection alloc] initWithRequest:request delegate:
self];
567 _downloadProgress = 0;
568 _downloadExpected = 0;
569 NSString* label =
DESC(
@"oolite-oxzmanager-download-label-list");
571 NSDictionary* expectedManifest =
nil;
574 label = [
expectedManifest oo_stringForKey:kOOManifestTitle defaultValue:DESC(@"oolite-oxzmanager-download-label-oxz")];
595 [_currentDownload cancel];
623 NSString* fullpath =
nil;
624 NSDictionary* manifest =
nil;
626 fullpath = [[
self installPath] stringByAppendingPathComponent:filename];
628 if (manifest !=
nil) {
629 NSMutableDictionary* adjManifest = [
NSMutableDictionary dictionaryWithDictionary:manifest];
630 [
adjManifest setObject:fullpath forKey:kOOManifestFilePath];
632 NSDictionary* stored =
nil;
637 BOOL foundInstallable = NO;
640 if (foundInstallable == NO) {
641 [
adjManifest setObject:[
stored oo_stringForKey:kOOManifestVersion] forKey:kOOManifestAvailableVersion];
642 [
adjManifest setObject:[
stored oo_stringForKey:kOOManifestDownloadURL] forKey:kOOManifestDownloadURL];
644 foundInstallable = YES;
650 [manifests addObject:adjManifest];
653 [manifests sortUsingFunction:oxzSort context:NULL];
666 if (_oxzList !=
nil) {
693 if (downloadedManifest ==
nil) {
700 NSDictionary* expectedManifest =
nil;
705 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.");
723 NSString* destination = [[
self installPath] stringByAppendingPathComponent:filename];
724 [[
NSFileManager defaultManager] oo_removeItemAtPath:destination];
727 if (![[NSFileManager defaultManager] oo_moveItemAtPath:[
self downloadPath] toPath:destination]) {
754 if (
requires ==
nil) {
756 requires = [
expectedManifest oo_arrayForKey:kOOManifestRequiresOXPs defaultValue:nil];
758 NSDictionary* requirement =
nil;
762 if ([_dependencyStack
count] > 0) {
764 NSSet* tempStack = [
NSSet setWithSet:_dependencyStack];
765 foreach (requirement, tempStack) {
767 if (![
ResourceManager manifest:downloadedManifest HasUnmetDependency:requirement logErrors:NO]
768 &&
requires !=
nil && [
requires containsObject:requirement]) {
770 [
progress appendFormat:DESC(@"oolite-oxzmanager-progress-now-has-@"), [
requirement oo_stringForKey:kOOManifestRelationDescription defaultValue:[
requirement oo_stringForKey:kOOManifestRelationIdentifier]]];
779 if (
requires !=
nil) {
780 foreach (requirement,
requires) {
781 if ([
ResourceManager manifest:downloadedManifest HasUnmetDependency:requirement logErrors:NO]) {
784 [
progress appendFormat:DESC(@"oolite-oxzmanager-progress-requires-@"), [
requirement oo_stringForKey:kOOManifestRelationDescription defaultValue:[
requirement oo_stringForKey:kOOManifestRelationIdentifier]]];
788 if ([_dependencyStack
count] > 0) {
791 BOOL undownloadedRequirement = NO;
792 NSDictionary* availableDownload =
nil;
793 BOOL foundDownload = NO;
794 NSUInteger index = 0;
795 NSString* needsIdentifier =
nil;
798 undownloadedRequirement = YES;
802 if (!_downloadAllDependencies) {
803 [
progress appendString:DESC(@"oolite-oxzmanager-progress-get-required")];
805 needsIdentifier = [
requirement oo_stringForKey:kOOManifestRelationIdentifier];
807 foreach (availableDownload, _oxzList) {
812 index = [
_oxzList indexOfObject:availableDownload];
825 if ([_dependencyStack
count] > 0) {
827 undownloadedRequirement = NO;
835 }
while (!undownloadedRequirement);
842 if (_downloadAllDependencies) {
844 if (![
self installOXZ:index]) {
847 [
progress appendFormat:DESC(@"oolite-oxzmanager-progress-required-@-not-found"), [
requirement oo_stringForKey:kOOManifestRelationDescription defaultValue:[
requirement oo_stringForKey:kOOManifestRelationIdentifier]]];
849 OOLog(
kOOOXZErrorLog,
@"OXZ dependency %@ could not be found for automatic download.", needsIdentifier);
865 else if ([_dependencyStack
count] > 0) {
866 [
progress appendFormat:DESC(@"oolite-oxzmanager-progress-required-@-not-found"), [
requirement oo_stringForKey:kOOManifestRelationDescription defaultValue:[
requirement oo_stringForKey:kOOManifestRelationIdentifier]]];
868 OOLog(
kOOOXZErrorLog,
@"OXZ dependency %@ could not be found for automatic download.", needsIdentifier);
880 _downloadAllDependencies = NO;
885- (NSDictionary*)installedManifestForIdentifier:(NSString*)identifier
888 NSDictionary* manifest =
nil;
889 foreach (manifest, installed) {
899 NSString* title = [
manifest oo_stringForKey:kOOManifestTitle defaultValue:nil];
900 NSString* identifier = [
manifest oo_stringForKey:kOOManifestIdentifier defaultValue:nil];
902 if (![
ResourceManager checkVersionCompatibility:manifest forOXP:title]) {
907 if (installed ==
nil) {
912 if (installed !=
nil) {
918 && [[NSFileManager defaultManager] fileExistsAtPath:[installed oo_stringForKey:
kOOManifestFilePath]]) {
932 if (installed !=
nil) {
933 NSString* availableVersion = [
manifest oo_stringForKey:kOOManifestAvailableVersion];
934 if (availableVersion ==
nil) {
935 availableVersion = [
manifest oo_stringForKey:kOOManifestVersion];
937 NSString* installedVersion = [
installed oo_stringForKey:kOOManifestVersion];
938 OOLog(
@"version.debug",
@"%@ mv:%@ mav:%@", identifier, installedVersion, availableVersion);
945 if ([
ResourceManager manifestHasMissingDependencies:manifest logErrors:NO]) {
951- (
OOColor*)colorForManifest:(NSDictionary*)manifest
953 switch ([
self installableState:manifest]) {
974- (NSString*)installStatusForManifest:(NSDictionary*)manifest
976 switch ([
self installableState:manifest]) {
978 return DESC(
@"oolite-oxzmanager-installable-okay");
980 return DESC(
@"oolite-oxzmanager-installable-update");
982 return DESC(
@"oolite-oxzmanager-installable-depend");
984 return DESC(
@"oolite-oxzmanager-installable-conflicts");
986 return DESC(
@"oolite-oxzmanager-installable-already");
988 return DESC(
@"oolite-oxzmanager-installable-manual");
990 return DESC(
@"oolite-oxzmanager-installable-version");
992 return DESC(
@"oolite-oxzmanager-installable-noremote");
1006 [PLAYER destroySound];
1010 [gui
setTitle:DESC(@"oolite-oxzmanager-title")];
1016 [gui
setTitle:DESC(@"oolite-oxzmanager-title-setfilter")];
1017 [gui
setText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-currentfilter-is-@"), _currentFilter]
forRow:OXZ_GUI_ROW_FILTERCURRENT
align:GUI_ALIGN_LEFT];
1024 [gui
setText:DESC(@"oolite-oxzmanager-download-list")
forRow:OXZ_GUI_ROW_UPDATE
align:GUI_ALIGN_CENTER];
1031 [gui
setText:DESC(@"oolite-oxzmanager-download-noupdate")
forRow:OXZ_GUI_ROW_PROCEED
align:GUI_ALIGN_CENTER];
1034 [gui
setText:DESC(@"oolite-oxzmanager-update-list")
forRow:OXZ_GUI_ROW_UPDATE
align:GUI_ALIGN_CENTER];
1050 [gui
setText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-currentfilter-is-@-@"), OOExpand(@"[oolite_key_oxzmanager_setfilter]"), _currentFilter]
forRow:OXZ_GUI_ROW_LISTFILTER
align:GUI_ALIGN_LEFT];
1054 [gui
setText:DESC(@"oolite-oxzmanager-install")
forRow:OXZ_GUI_ROW_INSTALL
align:GUI_ALIGN_CENTER];
1056 [gui
setText:DESC(@"oolite-oxzmanager-installed")
forRow:OXZ_GUI_ROW_INSTALLED
align:GUI_ALIGN_CENTER];
1057 [gui
setKey:@"_INSTALLED"
forRow:OXZ_GUI_ROW_INSTALLED];
1058 [gui
setText:DESC(@"oolite-oxzmanager-remove")
forRow:OXZ_GUI_ROW_REMOVE
align:GUI_ALIGN_CENTER];
1060 [gui
setText:DESC(@"oolite-oxzmanager-update-list")
forRow:OXZ_GUI_ROW_UPDATE
align:GUI_ALIGN_CENTER];
1062 [gui
setText:DESC(@"oolite-oxzmanager-update-all")
forRow:OXZ_GUI_ROW_UPDATE_ALL
align:GUI_ALIGN_CENTER];
1063 [gui
setKey:@"_UPDATE_ALL"
forRow:OXZ_GUI_ROW_UPDATE_ALL];
1069 [gui
setTitle:DESC(@"oolite-oxzmanager-title-downloading")];
1078 [gui
setText:DESC(@"oolite-oxzmanager-cancel")
forRow:OXZ_GUI_ROW_CANCEL
align:GUI_ALIGN_CENTER];
1083 [gui
setTitle:DESC(@"oolite-oxzmanager-title-dependencies")];
1085 [gui
setText:DESC(@"oolite-oxzmanager-dependencies-decision")
forRow:OXZ_GUI_ROW_PROGRESS
align:GUI_ALIGN_LEFT];
1090 [gui
setText:DESC(@"oolite-oxzmanager-dependencies-yes-all")
forRow:OXZ_GUI_ROW_INSTALLED
align:GUI_ALIGN_CENTER];
1091 [gui
setKey:@"_PROCEED_ALL"
forRow:OXZ_GUI_ROW_INSTALLED];
1093 [gui
setText:DESC(@"oolite-oxzmanager-dependencies-yes")
forRow:OXZ_GUI_ROW_PROCEED
align:GUI_ALIGN_CENTER];
1096 [gui
setText:DESC(@"oolite-oxzmanager-dependencies-no")
forRow:OXZ_GUI_ROW_CANCEL
align:GUI_ALIGN_CENTER];
1102 [gui
setText:DESC(@"oolite-oxzmanager-acknowledge")
forRow:OXZ_GUI_ROW_UPDATE
align:GUI_ALIGN_CENTER];
1114 [gui
setText:DESC(@"oolite-oxzmanager-acknowledge")
forRow:OXZ_GUI_ROW_UPDATE
align:GUI_ALIGN_CENTER];
1119 NSDictionary* manifest = [_filteredList oo_dictionaryAtIndex:_item];
1120 NSString* title = [
manifest oo_stringForKey:kOOManifestTitle];
1121 NSString* version = [
manifest oo_stringForKey:kOOManifestVersion];
1122 NSString* identifier = [
manifest oo_stringForKey:kOOManifestIdentifier];
1123 [gui
setTitle:DESC(@"oolite-oxzmanager-title-extract")];
1124 [gui
setText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-infopage-title-@-version-@"),
1128 align:GUI_ALIGN_LEFT];
1130#ifndef OO_DEBUG_MONITOR_ENABLED
1131 [gui
addLongText:DESC(@"oolite-oxzmanager-extract-releasebuild")
1133 align:GUI_ALIGN_LEFT];
1138 if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
1139 [gui
addLongText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-extract-@-already-exists"), path]
1141 align:GUI_ALIGN_LEFT];
1143 [gui
setText:DESC(@"oolite-oxzmanager-extract-unavailable")
forRow:OXZ_GUI_ROW_PROCEED
align:GUI_ALIGN_CENTER];
1146 [gui
addLongText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-extract-to-@"), path]
1148 align:GUI_ALIGN_LEFT];
1150 [gui
setText:DESC(@"oolite-oxzmanager-extract-proceed")
forRow:OXZ_GUI_ROW_PROCEED
align:GUI_ALIGN_CENTER];
1153 [gui
setText:DESC(@"oolite-oxzmanager-extract-cancel")
forRow:OXZ_GUI_ROW_CANCEL
align:GUI_ALIGN_CENTER];
1159 [gui
setText:DESC(@"oolite-oxzmanager-acknowledge")
forRow:OXZ_GUI_ROW_UPDATE
align:GUI_ALIGN_CENTER];
1166 [gui
setTitle:DESC(@"oolite-oxzmanager-title-install")];
1170 [gui
setTitle:DESC(@"oolite-oxzmanager-title-installed")];
1174 [gui
setTitle:DESC(@"oolite-oxzmanager-title-remove")];
1180 [gui
setText:DESC(@"oolite-oxzmanager-exit-restart")
forRow:OXZ_GUI_ROW_EXIT
align:GUI_ALIGN_CENTER];
1182 [gui
setText:DESC(@"oolite-oxzmanager-exit")
forRow:OXZ_GUI_ROW_EXIT
align:GUI_ALIGN_CENTER];
1201 [UNIVERSE reinitAndShowDemo:YES];
1218 [_dependencyStack removeAllObjects];
1224 [PLAYER setGuiToIntroFirstGo:YES];
1238 [_dependencyStack removeAllObjects];
1243 [_dependencyStack removeAllObjects];
1311- (void)processTextInput:(NSString*)input
1313 if ([
self validateFilter:input]) {
1314 if ([input length] > 0) {
1323- (void)refreshTextInput:(NSString*)input
1326 [gui
setText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-text-prompt-@"), input]
forRow:OXZ_GUI_ROW_INPUT
align:GUI_ALIGN_LEFT];
1327 if ([
self validateFilter:input]) {
1341 [[UNIVERSE gameView] resetTypedString];
1369 NSDictionary* manifest = [_filteredList oo_dictionaryAtIndex:_item];
1373 [gui
setTitle:DESC(@"oolite-oxzmanager-title-infopage")];
1376 [gui
setText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-infopage-title-@-version-@"),
1377 [
manifest oo_stringForKey:kOOManifestTitle],
1378 [
manifest oo_stringForKey:kOOManifestVersion]]
1380 align:GUI_ALIGN_LEFT];
1383 [gui
setText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-infopage-author-@"),
1384 [
manifest oo_stringForKey:kOOManifestAuthor]]
1386 align:GUI_ALIGN_LEFT];
1389 [gui
addLongText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-infopage-license-@"),
1390 [
manifest oo_stringForKey:kOOManifestLicense]]
1392 align:GUI_ALIGN_LEFT];
1395 [gui
addLongText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-infopage-tags-@"), [[
manifest oo_arrayForKey:kOOManifestTags] componentsJoinedByString:@", "]]
1397 align:GUI_ALIGN_LEFT];
1399 [gui
addLongText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-infopage-description-@"), [
manifest oo_stringForKey:kOOManifestDescription]]
1401 align:GUI_ALIGN_LEFT];
1404 NSString* infoURLString = [
manifest oo_stringForKey:kOOManifestInformationURL];
1405 [gui
setText:[
NSString stringWithFormat:DESC(@"oolite-oxzmanager-infopage-infourl-@"),
1408 align:GUI_ALIGN_LEFT];
1411 [gui
setText:OOExpand(DESC(@"oolite-oxzmanager-infopage-return"))
forRow:27
align:GUI_ALIGN_CENTER];
1424 [[UNIVERSE gameView] stringToClipboard:_currentOXPURL];
1434 NSDictionary* manifest = [_filteredList oo_dictionaryAtIndex:_item];
1436 NSString* infoURLString = [
manifest oo_stringForKey:kOOManifestInformationURL];
1438 [[UNIVERSE gameView] stringToClipboard:infoURLString];
1462- (BOOL)installOXZ:(NSUInteger)item
1464 NSArray* picklist = _filteredList;
1466 if ([picklist
count] <= item) {
1469 NSDictionary* manifest = [
picklist objectAtIndex:item];
1477 NSString* url = [
manifest objectForKey:kOOManifestDownloadURL];
1496 _downloadAllDependencies = YES;
1498 NSDictionary* manifest =
nil;
1500 foreach (manifest, _oxzList) {
1507 NSString* identifier = [
first oo_stringForKey:kOOManifestRelationIdentifier];
1508 NSUInteger item = NSUIntegerMax;
1509 NSDictionary* availableDownload =
nil;
1510 foreach (availableDownload, _oxzList) {
1512 item = [
_oxzList indexOfObject:availableDownload];
1521 NSUInteger start = _offset;
1522 if (start >= [_filteredList
count]) {
1527 if (end > [_filteredList
count]) {
1530 return [
_filteredList subarrayWithRange:NSMakeRange(start, end - start)];
1538 NSUInteger optCount = [_filteredList count];
1547 [gui
setArray:[
NSArray arrayWithObjects:DESC(@"oolite-oxzmanager-heading-category"),
1548 DESC(@"oolite-oxzmanager-heading-title"),
1549 DESC(@"oolite-oxzmanager-heading-installed"),
1550 DESC(@"oolite-oxzmanager-heading-downloadable"),
1552 forRow:OXZ_GUI_ROW_LISTHEAD];
1556 [gui
setArray:[
NSArray arrayWithObjects:DESC(@"gui-back"), @"", @"", @" <-- ", nil]
forRow:OXZ_GUI_ROW_LISTPREV];
1565 if (
_offset + 10 < optCount) {
1567 [gui
setArray:[
NSArray arrayWithObjects:DESC(@"gui-more"), @"", @"", @" --> ", nil]
forRow:OXZ_GUI_ROW_LISTNEXT];
1589 NSDictionary* manifest =
nil;
1590 BOOL oxzLineSelected = NO;
1592 foreach (manifest, options) {
1594 NSString* localPath = [[[
self installPath] stringByAppendingPathComponent:[
manifest oo_stringForKey:kOOManifestIdentifier]] stringByAppendingPathExtension:@"oxz"];
1595 if (installed ==
nil) {
1597 installed =
OODictionaryFromFile([localPath stringByAppendingPathComponent:
@"manifest.plist"]);
1600 if ([[NSFileManager defaultManager] fileExistsAtPath:localPath]) {
1602 installed =
OODictionaryFromFile([localPath stringByAppendingPathComponent:
@"manifest.plist"]);
1611 NSString* installedVersion =
DESC(
@"oolite-oxzmanager-version-none");
1612 if (installed !=
nil) {
1613 installedVersion = [
installed oo_stringForKey:kOOManifestVersion defaultValue:DESC(@"oolite-oxzmanager-version-none")];
1619 [
manifest oo_stringForKey:kOOManifestCategory
1620 defaultValue:DESC(@"oolite-oxzmanager-missing-field")],
1621 [
manifest oo_stringForKey:kOOManifestTitle
1622 defaultValue:DESC(@"oolite-oxzmanager-missing-field")],
1624 [
manifest oo_stringForKey:kOOManifestAvailableVersion
1625 defaultValue:[
manifest oo_stringForKey:kOOManifestVersion defaultValue:DESC(@"oolite-oxzmanager-version-none")]],
1633 if (row == [
gui selectedRow]) {
1634 oxzLineSelected = YES;
1639 [gui
addLongText:[[[
manifest oo_stringForKey:kOOManifestDescription] componentsSeparatedByString:@"\n"] oo_stringAtIndex:0]
startingAtRow:OXZ_GUI_ROW_LISTDESC
align:GUI_ALIGN_LEFT];
1641 NSString* infoUrl = [
manifest oo_stringForKey:kOOManifestInformationURL];
1642 if (infoUrl !=
nil) {
1643 [gui
setArray:[
NSArray arrayWithObjects:DESC(@"oolite-oxzmanager-infoline-url"), infoUrl, nil]
forRow:OXZ_GUI_ROW_LISTINFO1];
1645 NSUInteger
size = [
manifest oo_unsignedIntForKey:kOOManifestFileSize defaultValue:0];
1646 NSString* updatedDesc =
nil;
1648 NSUInteger timestamp = [
manifest oo_unsignedIntegerForKey:kOOManifestUploadDate defaultValue:0];
1649 if (timestamp > 0) {
1651 NSDate* updated = [
NSDate dateWithTimeIntervalSince1970:timestamp];
1654 updatedDesc = [[[
updated description] componentsSeparatedByString:@" "] oo_stringAtIndex:0];
1656 [gui
setArray:[
NSArray arrayWithObjects:DESC(@"oolite-oxzmanager-infoline-size"), [
self humanSize:size], DESC(@"oolite-oxzmanager-infoline-date"), updatedDesc, nil]
forRow:OXZ_GUI_ROW_LISTINFO2];
1657 }
else if (
size > 0) {
1666 if (!oxzLineSelected) {
1679- (BOOL)removeOXZ:(NSUInteger)item
1681 NSArray* remList = _filteredList;
1682 if ([remList
count] <= item) {
1686 NSString*
filename = [[
remList objectAtIndex:item] oo_stringForKey:kOOManifestFilePath];
1692 if (![[NSFileManager defaultManager] oo_removeItemAtPath:
filename]) {
1705 NSArray* remList = _filteredList;
1706 if ([remList
count] == 0) {
1709 NSUInteger start = _offset;
1710 if (start >= [remList
count]) {
1715 if (end > [remList
count]) {
1718 return [
remList subarrayWithRange:NSMakeRange(start, end - start)];
1727 if (options ==
nil) {
1738 [gui
setArray:[
NSArray arrayWithObjects:DESC(@"oolite-oxzmanager-heading-category"),
1739 DESC(@"oolite-oxzmanager-heading-title"),
1740 DESC(@"oolite-oxzmanager-heading-version"),
1742 forRow:OXZ_GUI_ROW_LISTHEAD];
1745 [gui
setArray:[
NSArray arrayWithObjects:DESC(@"gui-back"), @"", @" <-- ", nil]
forRow:OXZ_GUI_ROW_LISTPREV];
1756 [gui
setArray:[
NSArray arrayWithObjects:DESC(@"gui-more"), @"", @" --> ", nil]
forRow:OXZ_GUI_ROW_LISTNEXT];
1778 NSDictionary* manifest =
nil;
1779 BOOL oxzSelected = NO;
1781 foreach (manifest, options) {
1784 [
manifest oo_stringForKey:kOOManifestCategory
1785 defaultValue:DESC(@"oolite-oxzmanager-missing-field")],
1786 [
manifest oo_stringForKey:kOOManifestTitle
1787 defaultValue:DESC(@"oolite-oxzmanager-missing-field")],
1788 [
manifest oo_stringForKey:kOOManifestVersion
1789 defaultValue:DESC(@"oolite-oxzmanager-missing-field")],
1792 NSString* identifier = [
manifest oo_stringForKey:kOOManifestIdentifier];
1797 if (row == [
gui selectedRow]) {
1801 [gui
addLongText:[[[
manifest oo_stringForKey:kOOManifestDescription] componentsSeparatedByString:@"\n"] oo_stringAtIndex:0]
startingAtRow:OXZ_GUI_ROW_LISTDESC
align:GUI_ALIGN_LEFT];
1870- (NSString*)extractOXZ:(NSUInteger)item
1874 NSDictionary* manifest = [
_filteredList oo_dictionaryAtIndex:item];
1875 NSString* version = [
manifest oo_stringForKey:kOOManifestVersion];
1876 NSString* identifier = [
manifest oo_stringForKey:kOOManifestIdentifier];
1883 NSString* oxzfile = [
manifest oo_stringForKey:kOOManifestFilePath];
1884 if (![fmgr fileExistsAtPath:oxzfile]) {
1886 [
extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-no-original")];
1889 const char* zipname = [
oxzfile UTF8String];
1894 [
extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-bad-original")];
1898 if ([fmgr fileExistsAtPath:path]) {
1900 [
extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-main-exists")];
1904 if (![fmgr oo_createDirectoryAtPath:path attributes:
nil]) {
1906 [
extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-main-unmakeable")];
1910 [
extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-main-created")];
1911 NSUInteger counter = 0;
1912 char rawComponentName[512];
1918 rawComponentName, 512,
1921 NSString* componentName = [
NSString stringWithUTF8String:rawComponentName];
1922 if ([componentName hasSuffix:
@"/"]) {
1924 if (![fmgr oo_createDirectoryAtPath:[path stringByAppendingPathComponent:componentName] attributes:
nil]) {
1926 [
extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-sub-failed")];
1935 NSString* folder = [[
path stringByAppendingPathComponent:componentName] stringByDeletingLastPathComponent];
1936 if ([folder length] > 0 && ![fmgr fileExistsAtPath:folder] && ![fmgr oo_createDirectoryAtPath:folder attributes:
nil]) {
1938 [
extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-sub-failed")];
1947 NSData* tmp = [
NSData oo_dataWithOXZFile:[
oxzfile stringByAppendingPathComponent:componentName]];
1950 [
extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-sub-failed")];
1955 if (![tmp writeToFile:[path stringByAppendingPathComponent:componentName] atomically:YES]) {
1957 [
extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-sub-failed")];
1972 [
extractionLog appendFormat:DESC(@"oolite-oxzmanager-extract-log-num-u-extracted"), counter];
1973 [
extractionLog appendFormat:DESC(@"oolite-oxzmanager-extract-log-extracted-to-@"), path];
1979- (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response
1983 _downloadExpected = [
response expectedContentLength];
1984 _downloadProgress = 0;
1988 if (_fileWriter ==
nil) {
1995- (void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data
2000 _downloadProgress += [
data length];
2018 [[
NSRunLoop currentRunLoop] limitDateForMode:NSDefaultRunLoopMode];
2022- (void)connectionDidFinishLoading:(NSURLConnection*)connection
2039 OOLog(
kOOOXZErrorLog,
@"Error: download completed in unexpected state %d. This is an internal error - please report it.", _interfaceState);
2044- (void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error
2056NSComparisonResult
oxzSort(
id m1,
id m2,
void* context)
2058 NSComparisonResult result = [[m1 oo_stringForKey:kOOManifestCategory defaultValue:@"zz"] localizedCompare:[m2 oo_stringForKey:kOOManifestCategory defaultValue:@"zz"]];
2059 if (result == NSOrderedSame) {
2060 result = [[m1 oo_stringForKey:kOOManifestTitle defaultValue:@"zz"] localizedCompare:[m2 oo_stringForKey:kOOManifestTitle defaultValue:@"zz"]];
2061 if (result == NSOrderedSame) {
2062 result = [[m2 oo_stringForKey:kOOManifestVersion defaultValue:@"0"] localizedCompare:[m1 oo_stringForKey:kOOManifestVersion defaultValue:@"0"]];
OOGUITabStop OOGUITabSettings[GUI_MAX_COLUMNS]
#define OOLog(class, format,...)
static NSString *const kOOManifestAvailableVersion
static NSString *const kOOManifestRelationIdentifier
static NSString *const kOOManifestIdentifier
static NSString *const kOOManifestVersion
static NSString *const kOOManifestFilePath
static OONullTexture * sSingleton
@ 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)
void setOXPURL:(NSString *url)
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()
NSString * _currentOXPURL
OOColor * colorForManifest:(NSDictionary *manifest)
BOOL isAcceptingGUIInput()
NSString * extractAddOnsPath()
NSMutableSet * _dependencyStack
OOOXZManager * sharedManager()
BOOL beginDownload:(NSMutableURLRequest *request)
OXZInterfaceState _interfaceState
BOOL removeOXZ:(NSUInteger item)
BOOL isAcceptingTextInput()
OOGUIRow showInstallOptions()
void processShowInfoKey()
NSArray * additionalAddOnsPaths()
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