Oolite
Loading...
Searching...
No Matches
OOOXZManager Class Reference

#include <OOOXZManager.h>

Inheritance diagram for OOOXZManager:
Collaboration diagram for OOOXZManager:

Instance Methods

(NSString *) - installPath
(NSString *) - extractAddOnsPath
(NSArray *) - additionalAddOnsPaths
(BOOL) - updateManifests
(BOOL) - cancelUpdate
(NSArray *) - manifests
(NSArray *) - managedOXZs
(void) - gui
(BOOL) - isRestarting
(BOOL) - isAcceptingTextInput
(BOOL) - isAcceptingGUIInput
(void) - processSelection
(void) - processTextInput:
(void) - refreshTextInput:
(void) - processFilterKey
(void) - processShowInfoKey
(void) - processCopyUrlKey
(void) - processExtractKey
(OOGUIRow) - showInstallOptions
(OOGUIRow) - showRemoveOptions
(void) - showOptionsUpdate
(void) - showOptionsPrev
(void) - showOptionsNext
(void) - processOptionsPrev
(void) - processOptionsNext
(id) - init [implementation]
(void) - dealloc [implementation]
(NSString *) - extractionBasePathForIdentifier:andVersion: [implementation]
(BOOL) - ensureInstallPath [implementation]
(NSString *) - manifestPath [implementation]
(NSString *) - downloadPath [implementation]
(NSString *) - dataURL [implementation]
(NSString *) - humanSize: [implementation]
(void) - setOXZList: [implementation]
(void) - setFilteredList: [implementation]
(void) - setFilter: [implementation]
(void) - setOXPURL: [implementation]
(NSArray *) - applyCurrentFilter: [implementation]
(BOOL) - applyFilterByNoFilter: [implementation]
(BOOL) - applyFilterByUpdateRequired: [implementation]
(BOOL) - applyFilterByInstallable: [implementation]
(BOOL) - applyFilterByKeyword:keyword: [implementation]
(BOOL) - applyFilterByAuthor:author: [implementation]
(BOOL) - applyFilterByDays:days: [implementation]
(BOOL) - applyFilterByTag:tag: [implementation]
(BOOL) - applyFilterByCategory:category: [implementation]
(BOOL) - validateFilter: [implementation]
(void) - setCurrentDownload:withLabel: [implementation]
(void) - setProgressStatus: [implementation]
(BOOL) - beginDownload: [implementation]
(BOOL) - processDownloadedManifests [implementation]
(BOOL) - processDownloadedOXZ [implementation]
(NSDictionary *) - installedManifestForIdentifier: [implementation]
(OXZInstallableState) - installableState: [implementation]
(OOColor *) - colorForManifest: [implementation]
(NSString *) - installStatusForManifest: [implementation]
(BOOL) - installOXZ: [implementation]
(BOOL) - updateAllOXZ [implementation]
(NSArray *) - installOptions [implementation]
(BOOL) - removeOXZ: [implementation]
(NSArray *) - removeOptions [implementation]
(NSString *) - extractOXZ: [implementation]
(void) - connection:didReceiveResponse: [implementation]
(void) - connection:didReceiveData: [implementation]
(void) - connectionDidFinishLoading: [implementation]
(void) - connection:didFailWithError: [implementation]

Class Methods

(OOOXZManager *) + sharedManager

Private Attributes

NSArray * _oxzList
NSArray * _managedList
NSArray * _filteredList
NSString * _currentFilter
NSString * _currentOXPURL
OXZInterfaceState _interfaceState
BOOL _interfaceShowingOXZDetail
BOOL _changesMade
NSURLConnection * _currentDownload
NSString * _currentDownloadName
OXZDownloadStatus _downloadStatus
NSUInteger _downloadProgress
NSUInteger _downloadExpected
NSFileHandle * _fileWriter
NSUInteger _item
BOOL _downloadAllDependencies
NSUInteger _offset
NSString * _progressStatus
NSMutableSet * _dependencyStack

Detailed Description

Definition at line 58 of file OOOXZManager.h.

Method Documentation

◆ additionalAddOnsPaths

- (NSArray *) additionalAddOnsPaths

Definition at line 266 of file OOOXZManager.m.

267{
268 const char* additionalAddOnsEnv = SDL_getenv("OO_ADDITIONALADDONSDIRS");
269
270 if (additionalAddOnsEnv) {
271 NSString* envStr = [NSString stringWithUTF8String:additionalAddOnsEnv];
272 return [envStr componentsSeparatedByString:@","];
273 }
274 return [NSArray array];
275}

References additionalAddOnsPaths.

Referenced by additionalAddOnsPaths, and ResourceManager::userRootPaths.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyCurrentFilter:

- (NSArray *) applyCurrentFilter: (NSArray*) list
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 376 of file OOOXZManager.m.

376 :(NSArray*)list
377{
378 SEL filterSelector = @selector(applyFilterByNoFilter:);
379 NSString* parameter = nil;
380 if ([_currentFilter isEqualToString:kOOOXZFilterUpdates]) {
381 filterSelector = @selector(applyFilterByUpdateRequired:);
382 } else if ([_currentFilter isEqualToString:kOOOXZFilterInstallable]) {
383 filterSelector = @selector(applyFilterByInstallable:);
384 } else if ([_currentFilter hasPrefix:kOOOXZFilterKeyword]) {
385 filterSelector = @selector(applyFilterByKeyword:keyword:);
386 parameter = [_currentFilter substringFromIndex:[kOOOXZFilterKeyword length]];
387 } else if ([_currentFilter hasPrefix:kOOOXZFilterAuthor]) {
388 filterSelector = @selector(applyFilterByAuthor:author:);
389 parameter = [_currentFilter substringFromIndex:[kOOOXZFilterAuthor length]];
390 } else if ([_currentFilter hasPrefix:kOOOXZFilterDays]) {
391 filterSelector = @selector(applyFilterByDays:days:);
392 parameter = [_currentFilter substringFromIndex:[kOOOXZFilterDays length]];
393 } else if ([_currentFilter hasPrefix:kOOOXZFilterTag]) {
394 filterSelector = @selector(applyFilterByTag:tag:);
395 parameter = [_currentFilter substringFromIndex:[kOOOXZFilterTag length]];
396 } else if ([_currentFilter hasPrefix:kOOOXZFilterCategory]) {
397 filterSelector = @selector(applyFilterByCategory:category:);
398 parameter = [_currentFilter substringFromIndex:[kOOOXZFilterCategory length]];
399 }
400
401 NSMutableArray* filteredList = [NSMutableArray arrayWithCapacity:[list count]];
402 NSDictionary* manifest = nil;
403 NSInvocation* invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:filterSelector]];
404 [invocation setSelector:filterSelector];
405 [invocation setTarget:self];
406 if (parameter != nil) {
407 [invocation setArgument:&parameter atIndex:3];
408 }
409
410 foreach (manifest, list) {
411 [invocation setArgument:&manifest atIndex:2];
412 [invocation invoke];
413 BOOL filterAccepted = NO;
414 [invocation getReturnValue:&filterAccepted];
415 if (filterAccepted) {
416 [filteredList addObject:manifest];
417 }
418 }
419 // any bad filter that gets this far is also treated as '*'
420 // so don't need to explicitly test for '*' or ''
421 return [[filteredList copy] autorelease];
422}
static NSString *const kOOOXZFilterDays
static NSString *const kOOOXZFilterTag
static NSString *const kOOOXZFilterKeyword
static NSString *const kOOOXZFilterUpdates
static NSString *const kOOOXZFilterCategory
static NSString *const kOOOXZFilterInstallable
static NSString *const kOOOXZFilterAuthor
return nil
NSString * _currentFilter

References kOOOXZFilterAuthor, kOOOXZFilterCategory, kOOOXZFilterDays, kOOOXZFilterInstallable, kOOOXZFilterKeyword, kOOOXZFilterTag, kOOOXZFilterUpdates, and nil.

Referenced by gui, and showOptionsUpdate.

Here is the caller graph for this function:

◆ applyFilterByAuthor:author:

- (BOOL) applyFilterByAuthor: (NSDictionary*) manifest
author: (NSString*) author 
implementation

Provided by category OOOXZManager(OOFilterRules).

Definition at line 464 of file OOOXZManager.m.

464 :(NSDictionary*)manifest author:(NSString*)author
465{
466 // trim any eventual leading whitespace from input string
467 author = [author stringByTrimmingLeadingWhitespaceAndNewlineCharacters];
468
469 NSString* mAuth = [manifest oo_stringForKey:kOOManifestAuthor];
470 return ([mAuth rangeOfString:author options:NSCaseInsensitiveSearch].location != NSNotFound);
471}

◆ applyFilterByCategory:category:

- (BOOL) applyFilterByCategory: (NSDictionary*) manifest
category: (NSString*) category 
implementation

Provided by category OOOXZManager(OOFilterRules).

Definition at line 502 of file OOOXZManager.m.

502 :(NSDictionary*)manifest category:(NSString*)category
503{
504 // trim any eventual leading whitespace from input string
505 category = [category stringByTrimmingLeadingWhitespaceAndNewlineCharacters];
506
507 NSString* mCategory = [manifest oo_stringForKey:kOOManifestCategory];
508 return ([mCategory rangeOfString:category options:NSCaseInsensitiveSearch].location != NSNotFound);
509}

◆ applyFilterByDays:days:

- (BOOL) applyFilterByDays: (NSDictionary*) manifest
days: (NSString*) days 
implementation

Provided by category OOOXZManager(OOFilterRules).

Definition at line 473 of file OOOXZManager.m.

473 :(NSDictionary*)manifest days:(NSString*)days
474{
475 NSInteger i = [days integerValue];
476 if (i < 1) {
477 return NO;
478 } else {
479 NSUInteger updated = [manifest oo_unsignedIntegerForKey:kOOManifestUploadDate];
480 NSUInteger now = (NSUInteger)[[NSDate date] timeIntervalSince1970];
481 return (updated + (86400 * i) > now);
482 }
483}

◆ applyFilterByInstallable:

- (BOOL) applyFilterByInstallable: (NSDictionary*) manifest
implementation

Provided by category OOOXZManager(OOFilterRules).

Definition at line 435 of file OOOXZManager.m.

435 :(NSDictionary*)manifest
436{
437 return ([self installableState:manifest] < OXZ_UNINSTALLABLE_ALREADY);
438}
@ OXZ_UNINSTALLABLE_ALREADY

References OXZ_UNINSTALLABLE_ALREADY.

◆ applyFilterByKeyword:keyword:

- (BOOL) applyFilterByKeyword: (NSDictionary*) manifest
keyword: (NSString*) keyword 
implementation

Provided by category OOOXZManager(OOFilterRules).

Definition at line 440 of file OOOXZManager.m.

440 :(NSDictionary*)manifest keyword:(NSString*)keyword
441{
442 NSString* parameter = nil;
443 NSArray* parameters = [NSArray arrayWithObjects:kOOManifestTitle, kOOManifestDescription, kOOManifestCategory, nil];
444
445 // trim any eventual leading whitespace from input string
446 keyword = [keyword stringByTrimmingLeadingWhitespaceAndNewlineCharacters];
447
448 foreach (parameter, parameters) {
449 if ([[manifest oo_stringForKey:parameter] rangeOfString:keyword options:NSCaseInsensitiveSearch].location != NSNotFound) {
450 return YES;
451 }
452 }
453 // tags are slightly different
454 parameters = [manifest oo_arrayForKey:kOOManifestTags];
455 foreach (parameter, parameters) {
456 if ([parameter rangeOfString:keyword options:NSCaseInsensitiveSearch].location != NSNotFound) {
457 return YES;
458 }
459 }
460
461 return NO;
462}

References nil.

◆ applyFilterByNoFilter:

- (BOOL) applyFilterByNoFilter: (NSDictionary*) manifest
implementation

Provided by category OOOXZManager(OOFilterRules).

Definition at line 425 of file OOOXZManager.m.

425 :(NSDictionary*)manifest
426{
427 return YES;
428}

◆ applyFilterByTag:tag:

- (BOOL) applyFilterByTag: (NSDictionary*) manifest
tag: (NSString*) tag 
implementation

Provided by category OOOXZManager(OOFilterRules).

Definition at line 485 of file OOOXZManager.m.

485 :(NSDictionary*)manifest tag:(NSString*)tag
486{
487 NSString* parameter = nil;
488 NSArray* parameters = [manifest oo_arrayForKey:kOOManifestTags];
489
490 // trim any eventual leading whitespace from input string
491 tag = [tag stringByTrimmingLeadingWhitespaceAndNewlineCharacters];
492
493 foreach (parameter, parameters) {
494 if ([parameter rangeOfString:tag options:NSCaseInsensitiveSearch].location != NSNotFound) {
495 return YES;
496 }
497 }
498
499 return NO;
500}

References nil.

◆ applyFilterByUpdateRequired:

- (BOOL) applyFilterByUpdateRequired: (NSDictionary*) manifest
implementation

Provided by category OOOXZManager(OOFilterRules).

Definition at line 430 of file OOOXZManager.m.

430 :(NSDictionary*)manifest
431{
432 return ([self installableState:manifest] == OXZ_INSTALLABLE_UPDATE);
433}
@ OXZ_INSTALLABLE_UPDATE

References OXZ_INSTALLABLE_UPDATE.

◆ beginDownload:

- (BOOL) beginDownload: (NSMutableURLRequest*) request
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 560 of file OOOXZManager.m.

560 :(NSMutableURLRequest*)request
561{
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];
566 if (download) {
569 NSString* label = DESC(@"oolite-oxzmanager-download-label-list");
571 NSDictionary* expectedManifest = nil;
572 expectedManifest = [_filteredList objectAtIndex:_item];
573
574 label = [expectedManifest oo_stringForKey:kOOManifestTitle defaultValue:DESC(@"oolite-oxzmanager-download-label-oxz")];
575 }
576
577 [self setCurrentDownload:download withLabel:label]; // retains it
578 [download release];
579 OOLog(kOOOXZDebugLog, @"Download request received, using %@ and downloading to %@", [request URL], [self downloadPath]);
580 return YES;
581 } else {
582 OOLog(kOOOXZErrorLog, @"Unable to start downloading file at %@", [request URL]);
584 return NO;
585 }
586}
#define OOLog(class, format,...)
Definition OOLogging.h:84
@ OXZ_STATE_UPDATING
@ OXZ_DOWNLOAD_ERROR
static NSString *const kOOOXZErrorLog
static NSString *const kOOOXZDebugLog
#define DESC(key)
Definition Universe.h:832
OXZDownloadStatus _downloadStatus
NSUInteger _downloadExpected
NSString * downloadPath()
OXZInterfaceState _interfaceState
NSUInteger _downloadProgress

References DESC, OOOXZManager(NSURLConnectionDataDelegate)::downloadPath, kOOOXZDebugLog, kOOOXZErrorLog, nil, OOLog, OXZ_DOWNLOAD_ERROR, OXZ_STATE_UPDATING, and setCurrentDownload:withLabel:.

Referenced by OOOXZManager(NSURLConnectionDataDelegate)::installOXZ:, and updateManifests.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cancelUpdate

- (BOOL) cancelUpdate

Definition at line 588 of file OOOXZManager.m.

589{
591 return NO;
592 }
593 OOLog(kOOOXZDebugLog, @"%@", @"Trying to cancel file download");
594 if (_currentDownload != nil) {
595 [_currentDownload cancel];
597 NSString* path = [self downloadPath];
598 [[NSFileManager defaultManager] oo_removeItemAtPath:path];
599 }
603 } else {
605 }
606 [self gui];
607 return YES;
608}
@ OXZ_STATE_INSTALLING
@ OXZ_STATE_PICK_INSTALL
@ OXZ_STATE_MAIN
@ OXZ_DOWNLOAD_COMPLETE
@ OXZ_DOWNLOAD_NONE
NSURLConnection * _currentDownload

References _currentDownload, _downloadStatus, _interfaceState, cancelUpdate, downloadPath, gui, kOOOXZDebugLog, nil, OOLog, OXZ_DOWNLOAD_COMPLETE, OXZ_DOWNLOAD_NONE, OXZ_STATE_INSTALLING, OXZ_STATE_MAIN, OXZ_STATE_PICK_INSTALL, and OXZ_STATE_UPDATING.

Referenced by cancelUpdate, OOOXZManager(NSURLConnectionDataDelegate)::connection:didReceiveResponse:, and processSelection.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ colorForManifest:

- (OOColor *) colorForManifest: (NSDictionary*) manifest
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 951 of file OOOXZManager.m.

951 :(NSDictionary*)manifest
952{
953 switch ([self installableState:manifest]) {
955 return [OOColor yellowColor];
957 return [OOColor cyanColor];
959 return [OOColor orangeColor];
961 return [OOColor brownColor];
963 return [OOColor whiteColor];
965 return [OOColor redColor];
967 return [OOColor grayColor];
969 return [OOColor blueColor];
970 }
971 return [OOColor yellowColor]; // never
972}
@ OXZ_INSTALLABLE_DEPENDENCIES
@ OXZ_INSTALLABLE_CONFLICTS
@ OXZ_INSTALLABLE_OKAY
@ OXZ_UNINSTALLABLE_VERSION
@ OXZ_UNINSTALLABLE_NOREMOTE
@ OXZ_UNINSTALLABLE_MANUAL
OOColor * cyanColor()
Definition OOColor.m:274
OOColor * orangeColor()
Definition OOColor.m:289
OOColor * redColor()
Definition OOColor.m:259
OOColor * blueColor()
Definition OOColor.m:269
OOColor * grayColor()
Definition OOColor.m:254
OOColor * whiteColor()
Definition OOColor.m:249
OOColor * brownColor()
Definition OOColor.m:299
OOColor * yellowColor()
Definition OOColor.m:279

References OOColor::blueColor, OOColor::brownColor, OOColor::cyanColor, OOColor::grayColor, OOColor::orangeColor, OXZ_INSTALLABLE_CONFLICTS, OXZ_INSTALLABLE_DEPENDENCIES, OXZ_INSTALLABLE_OKAY, OXZ_INSTALLABLE_UPDATE, OXZ_UNINSTALLABLE_ALREADY, OXZ_UNINSTALLABLE_MANUAL, OXZ_UNINSTALLABLE_NOREMOTE, OXZ_UNINSTALLABLE_VERSION, OOColor::redColor, OOColor::whiteColor, and OOColor::yellowColor.

Referenced by showInstallOptions, and showRemoveOptions.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ connection:didFailWithError:

- (void) connection: (NSURLConnection*) connection
didFailWithError: (NSError*) error 
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 2044 of file OOOXZManager.m.

2044 :(NSURLConnection*)connection didFailWithError:(NSError*)error
2045{
2047 OOLog(kOOOXZErrorLog, @"Error downloading file: %@", [error description]);
2048 [_fileWriter closeFile];
2051}
#define DESTROY(x)
NSFileHandle * _fileWriter

References DESTROY, kOOOXZErrorLog, OOLog, and OXZ_DOWNLOAD_ERROR.

◆ connection:didReceiveData:

- (void) connection: (NSURLConnection*) connection
didReceiveData: (NSData*) data 
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 1995 of file OOOXZManager.m.

1995 :(NSURLConnection*)connection didReceiveData:(NSData*)data
1996{
1997 OOLog(kOOOXZDebugLog, @"Downloaded %zu bytes", [data length]);
1998 [_fileWriter seekToEndOfFile];
1999 [_fileWriter writeData:data];
2000 _downloadProgress += [data length];
2001 [self gui]; // update GUI
2002#if OOLITE_WINDOWS
2003 /* Irritating fix to issue https://github.com/OoliteProject/oolite/issues/95
2004 *
2005 * The problem is that on MINGW, GNUStep makes all socket streams
2006 * blocking, which causes problems with the run loop. Calling this
2007 * method of the run loop forces it to execute all already
2008 * scheduled items with a time in the past, before any more items
2009 * are placed on it, which means that the main game update gets a
2010 * chance to run.
2011 *
2012 * This stops the interface freezing - and Oolite appearing to
2013 * have stopped responding to the OS - when downloading large
2014 * (>20Mb) OXZ files.
2015 *
2016 * CIM 6 July 2014
2017 */
2018 [[NSRunLoop currentRunLoop] limitDateForMode:NSDefaultRunLoopMode];
2019#endif
2020}

References gui, kOOOXZDebugLog, and OOLog.

Here is the call graph for this function:

◆ connection:didReceiveResponse:

- (void) connection: (NSURLConnection*) connection
didReceiveResponse: (NSURLResponse*) response 
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 1979 of file OOOXZManager.m.

1979 :(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response
1980{
1982 OOLog(kOOOXZDebugLog, @"%@", @"Download receiving");
1983 _downloadExpected = [response expectedContentLength];
1986 [[NSFileManager defaultManager] createFileAtPath:[self downloadPath] contents:nil attributes:nil];
1987 _fileWriter = [[NSFileHandle fileHandleForWritingAtPath:[self downloadPath]] retain];
1988 if (_fileWriter == nil) {
1989 // file system is full or read-only or something
1990 OOLog(kOOOXZErrorLog, @"%@", @"Unable to create download file");
1991 [self cancelUpdate];
1992 }
1993}
@ OXZ_DOWNLOAD_RECEIVING

References cancelUpdate, DESTROY, downloadPath, kOOOXZDebugLog, kOOOXZErrorLog, nil, OOLog, and OXZ_DOWNLOAD_RECEIVING.

Here is the call graph for this function:

◆ connectionDidFinishLoading:

- (void) connectionDidFinishLoading: (NSURLConnection*) connection
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 2022 of file OOOXZManager.m.

2022 :(NSURLConnection*)connection
2023{
2025 OOLog(kOOOXZDebugLog, @"%@", @"Download complete");
2026 [_fileWriter synchronizeFile];
2027 [_fileWriter closeFile];
2031 if (![self processDownloadedManifests]) {
2033 }
2034 } else if (_interfaceState == OXZ_STATE_INSTALLING) {
2035 if (![self processDownloadedOXZ]) {
2037 }
2038 } else {
2039 OOLog(kOOOXZErrorLog, @"Error: download completed in unexpected state %d. This is an internal error - please report it.", _interfaceState);
2041 }
2042}
BOOL processDownloadedOXZ()
BOOL processDownloadedManifests()

References DESTROY, kOOOXZDebugLog, kOOOXZErrorLog, OOLog, OXZ_DOWNLOAD_COMPLETE, OXZ_DOWNLOAD_ERROR, OXZ_STATE_INSTALLING, OXZ_STATE_UPDATING, OOOXZManager(NSURLConnectionDataDelegate)::processDownloadedManifests, and OOOXZManager(NSURLConnectionDataDelegate)::processDownloadedOXZ.

Here is the call graph for this function:

◆ dataURL

- (NSString *) dataURL
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 325 of file OOOXZManager.m.

326{
327 /* Not expected to be set in general, but might be useful for some users */
328 NSString* url = [[NSUserDefaults standardUserDefaults] stringForKey:kOOOXZDataConfig];
329 if (url != nil) {
330 return url;
331 }
332 return kOOOXZDataURL;
333}
static NSString *const kOOOXZDataURL

References OOOXZManager(NSURLConnectionDataDelegate)::dataURL, kOOOXZDataURL, and nil.

Referenced by OOOXZManager(NSURLConnectionDataDelegate)::dataURL, and updateManifests.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dealloc

- (void) dealloc
implementation

Definition at line 204 of file OOOXZManager.m.

205{
206 if (sSingleton == self)
207 sSingleton = nil;
208
209 [self setCurrentDownload:nil withLabel:nil];
213
214 [super dealloc];
215}
static OONullTexture * sSingleton
NSArray * _managedList
NSArray * _filteredList
NSArray * _oxzList

References _filteredList, _managedList, _oxzList, dealloc, DESTROY, nil, setCurrentDownload:withLabel:, and sSingleton.

Referenced by dealloc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ downloadPath

- (NSString *) downloadPath
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 316 of file OOOXZManager.m.

317{
319 return [[[OOCacheManager sharedCache] cacheDirectoryPathCreatingIfNecessary:YES] stringByAppendingPathComponent:kOOOXZTmpPlistPath];
320 } else {
321 return [[[OOCacheManager sharedCache] cacheDirectoryPathCreatingIfNecessary:YES] stringByAppendingPathComponent:kOOOXZTmpPath];
322 }
323}
NSString * cacheDirectoryPathCreatingIfNecessary:(BOOL create)
OOCacheManager * sharedCache()

References OOCacheManager::cacheDirectoryPathCreatingIfNecessary:, OOOXZManager(NSURLConnectionDataDelegate)::downloadPath, OXZ_STATE_UPDATING, and OOCacheManager::sharedCache.

Referenced by OOOXZManager(NSURLConnectionDataDelegate)::beginDownload:, cancelUpdate, OOOXZManager(NSURLConnectionDataDelegate)::connection:didReceiveResponse:, OOOXZManager(NSURLConnectionDataDelegate)::downloadPath, OOOXZManager(NSURLConnectionDataDelegate)::processDownloadedManifests, and OOOXZManager(NSURLConnectionDataDelegate)::processDownloadedOXZ.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ensureInstallPath

- (BOOL) ensureInstallPath
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 286 of file OOOXZManager.m.

287{
288 BOOL exists, directory;
289 NSFileManager* fmgr = [NSFileManager defaultManager];
290 NSString* path = [self installPath];
291
292 exists = [fmgr fileExistsAtPath:path isDirectory:&directory];
293
294 if (exists && !directory) {
295 OOLog(kOOOXZErrorLog, @"Expected %@ to be a folder, but it is a file.", path);
296 return NO;
297 }
298 if (!exists) {
299 if (![fmgr oo_createDirectoryAtPath:path attributes:nil]) {
300 OOLog(kOOOXZErrorLog, @"Could not create folder %@.", path);
301 return NO;
302 }
303 }
304
305 return YES;
306}

References OOOXZManager(NSURLConnectionDataDelegate)::ensureInstallPath, installPath, kOOOXZErrorLog, nil, and OOLog.

Referenced by OOOXZManager(NSURLConnectionDataDelegate)::ensureInstallPath, and OOOXZManager(NSURLConnectionDataDelegate)::processDownloadedOXZ.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extractAddOnsPath

- (NSString *) extractAddOnsPath

Definition at line 246 of file OOOXZManager.m.

247{
248 const char* addOnsExtractEnv = SDL_getenv("OO_ADDONSEXTRACTDIR");
249
250 if (addOnsExtractEnv) {
251 return [NSString stringWithUTF8String:addOnsExtractEnv];
252 } else {
253#if OOLITE_WINDOWS
254#if OO_GAME_DATA_TO_USER_FOLDER
255 return [NSString stringWithFormat:@"%s\\Oolite\\AddOns", SDL_getenv("LOCALAPPDATA")];
256#else
257 return @"../AddOns";
258#endif
259#else
260 return [[NSHomeDirectory() stringByAppendingPathComponent:@".Oolite"] stringByAppendingPathComponent:@"AddOns"];
261#endif
262 }
263}

References extractAddOnsPath.

Referenced by extractAddOnsPath, and ResourceManager::userRootPaths.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extractionBasePathForIdentifier:andVersion:

- (NSString *) extractionBasePathForIdentifier: (NSString*) identifier
andVersion: (NSString*) version 
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 277 of file OOOXZManager.m.

277 :(NSString*)identifier andVersion:(NSString*)version
278{
279 NSString* basePath = [[ResourceManager userRootPaths] lastObject];
280 NSString* rawMainDir = [NSString stringWithFormat:@"%@-%@.off", identifier, version];
281
282 NSCharacterSet* blacklist = [NSCharacterSet characterSetWithCharactersInString:@"'#%^&{}[]/~|\\?<,:\" "];
283 return [[[basePath stringByAppendingPathComponent:[[rawMainDir componentsSeparatedByCharactersInSet:blacklist] componentsJoinedByString:@""]] retain] autorelease];
284}
NSArray * userRootPaths()

References ResourceManager::userRootPaths.

Referenced by OOOXZManager(NSURLConnectionDataDelegate)::extractOXZ:, and gui.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extractOXZ:

- (NSString *) extractOXZ: (NSUInteger) item
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 1870 of file OOOXZManager.m.

1870 :(NSUInteger)item
1871{
1872 NSFileManager* fmgr = [NSFileManager defaultManager];
1873 NSMutableString* extractionLog = [[NSMutableString alloc] init];
1874 NSDictionary* manifest = [_filteredList oo_dictionaryAtIndex:item];
1875 NSString* version = [manifest oo_stringForKey:kOOManifestVersion];
1876 NSString* identifier = [manifest oo_stringForKey:kOOManifestIdentifier];
1877 NSString* path = [self extractionBasePathForIdentifier:identifier andVersion:version];
1878
1879 // OXZ errors should really never happen unless someone is messing
1880 // directly with the managed folder while Oolite is running, but
1881 // it's possible.
1882
1883 NSString* oxzfile = [manifest oo_stringForKey:kOOManifestFilePath];
1884 if (![fmgr fileExistsAtPath:oxzfile]) {
1885 OOLog(kOOOXZErrorLog, @"OXZ %@ could not be found", oxzfile);
1886 [extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-no-original")];
1887 return [extractionLog autorelease];
1888 }
1889 const char* zipname = [oxzfile UTF8String];
1890 unzFile uf = NULL;
1891 uf = unzOpen64(zipname);
1892 if (uf == NULL) {
1893 OOLog(kOOOXZErrorLog, @"Could not open .oxz at %@ as zip file", path);
1894 [extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-bad-original")];
1895 return [extractionLog autorelease];
1896 }
1897
1898 if ([fmgr fileExistsAtPath:path]) {
1899 OOLog(kOOOXZErrorLog, @"Path %@ already exists", path);
1900 [extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-main-exists")];
1901 unzClose(uf);
1902 return [extractionLog autorelease];
1903 }
1904 if (![fmgr oo_createDirectoryAtPath:path attributes:nil]) {
1905 OOLog(kOOOXZErrorLog, @"Path %@ could not be created", path);
1906 [extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-main-unmakeable")];
1907 unzClose(uf);
1908 return [extractionLog autorelease];
1909 }
1910 [extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-main-created")];
1911 NSUInteger counter = 0;
1912 char rawComponentName[512];
1913 BOOL error = NO;
1914 unz_file_info64 file_info = { 0 };
1915 if (unzGoToFirstFile(uf) == UNZ_OK) {
1916 do {
1917 unzGetCurrentFileInfo64(uf, &file_info,
1918 rawComponentName, 512,
1919 NULL, 0,
1920 NULL, 0);
1921 NSString* componentName = [NSString stringWithUTF8String:rawComponentName];
1922 if ([componentName hasSuffix:@"/"]) {
1923 // folder
1924 if (![fmgr oo_createDirectoryAtPath:[path stringByAppendingPathComponent:componentName] attributes:nil]) {
1925 OOLog(kOOOXZErrorLog, @"Subpath %@ could not be created", componentName);
1926 [extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-sub-failed")];
1927 error = YES;
1928 break;
1929 } else {
1930 OOLog(kOOOXZDebugLog, @"Subpath %@ created OK", componentName);
1931 }
1932 } else {
1933 // file
1934 // usually folder must now exist, but just in case...
1935 NSString* folder = [[path stringByAppendingPathComponent:componentName] stringByDeletingLastPathComponent];
1936 if ([folder length] > 0 && ![fmgr fileExistsAtPath:folder] && ![fmgr oo_createDirectoryAtPath:folder attributes:nil]) {
1937 OOLog(kOOOXZErrorLog, @"Subpath %@ could not be created", folder);
1938 [extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-sub-failed")];
1939 error = YES;
1940 break;
1941 }
1942
1943 // This is less efficient in memory use than just
1944 // streaming out of the ZIP file onto disk
1945 // but it makes error handling easier
1946 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
1947 NSData* tmp = [NSData oo_dataWithOXZFile:[oxzfile stringByAppendingPathComponent:componentName]];
1948 if (tmp == nil) {
1949 OOLog(kOOOXZErrorLog, @"Sub file %@ could not be extracted from the OXZ", componentName);
1950 [extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-sub-failed")];
1951 error = YES;
1952 [pool release];
1953 break;
1954 } else {
1955 if (![tmp writeToFile:[path stringByAppendingPathComponent:componentName] atomically:YES]) {
1956 OOLog(kOOOXZErrorLog, @"Sub file %@ could not be created", componentName);
1957 [extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-sub-failed")];
1958 error = YES;
1959 [pool release];
1960 break;
1961 } else {
1962 ++counter;
1963 }
1964 }
1965 [pool release];
1966 }
1967 } while (unzGoToNextFile(uf) == UNZ_OK);
1968 }
1969 unzClose(uf);
1970
1971 if (!error) {
1972 [extractionLog appendFormat:DESC(@"oolite-oxzmanager-extract-log-num-u-extracted"), counter];
1973 [extractionLog appendFormat:DESC(@"oolite-oxzmanager-extract-log-extracted-to-@"), path];
1974 }
1975
1976 return [extractionLog autorelease];
1977}
int ZEXPORT unzGetCurrentFileInfo64(unzFile file, unz_file_info64 *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
Definition unzip.c:1058
int ZEXPORT unzGoToFirstFile(unzFile file)
Definition unzip.c:1109
unzFile ZEXPORT unzOpen64(const void *path)
Definition unzip.c:758
int ZEXPORT unzGoToNextFile(unzFile file)
Definition unzip.c:1130
int ZEXPORT unzClose(unzFile file)
Definition unzip.c:768
struct unz_file_info64_s unz_file_info64
voidp unzFile
Definition unzip.h:72
#define UNZ_OK
Definition unzip.h:75

References extractionBasePathForIdentifier:andVersion:, kOOOXZDebugLog, kOOOXZErrorLog, nil, OOLog, UNZ_OK, unzClose(), unzGetCurrentFileInfo64(), unzGoToFirstFile(), unzGoToNextFile(), and unzOpen64().

Referenced by processSelection.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gui

- (void) gui

Definition at line 997 of file OOOXZManager.m.

998{
999 GuiDisplayGen* gui = [UNIVERSE gui];
1000 OOGUIRow startRow = OXZ_GUI_ROW_EXIT;
1001
1002#if OOLITE_WINDOWS
1003 /* unlock OXZs ahead of potential changes by making sure sound
1004 * files aren't being held open */
1006 [PLAYER destroySound];
1007#endif
1008
1009 [gui clearAndKeepBackground:YES];
1010 [gui setTitle:DESC(@"oolite-oxzmanager-title")];
1011
1012 /* This switch will give warnings unless all states are
1013 * covered. */
1014 switch (_interfaceState) {
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];
1018 [gui addLongText:DESC(@"oolite-oxzmanager-filterhelp") startingAtRow:OXZ_GUI_ROW_FILTERHELP align:GUI_ALIGN_LEFT];
1019
1020 return; // don't do normal row selection stuff
1021 case OXZ_STATE_NODATA:
1022 if (_oxzList == nil) {
1023 [gui addLongText:DESC(@"oolite-oxzmanager-firstrun") startingAtRow:OXZ_GUI_ROW_FIRSTRUN align:GUI_ALIGN_LEFT];
1024 [gui setText:DESC(@"oolite-oxzmanager-download-list") forRow:OXZ_GUI_ROW_UPDATE align:GUI_ALIGN_CENTER];
1025 [gui setKey:@"_UPDATE" forRow:OXZ_GUI_ROW_UPDATE];
1026
1027 startRow = OXZ_GUI_ROW_UPDATE;
1028 } else {
1029 // update data
1030 [gui addLongText:DESC(@"oolite-oxzmanager-secondrun") startingAtRow:OXZ_GUI_ROW_FIRSTRUN align:GUI_ALIGN_LEFT];
1031 [gui setText:DESC(@"oolite-oxzmanager-download-noupdate") forRow:OXZ_GUI_ROW_PROCEED align:GUI_ALIGN_CENTER];
1032 [gui setKey:@"_MAIN" forRow:OXZ_GUI_ROW_PROCEED];
1033
1034 [gui setText:DESC(@"oolite-oxzmanager-update-list") forRow:OXZ_GUI_ROW_UPDATE align:GUI_ALIGN_CENTER];
1035 [gui setKey:@"_UPDATE" forRow:OXZ_GUI_ROW_UPDATE];
1036
1037 startRow = OXZ_GUI_ROW_PROCEED;
1038 }
1039 break;
1041 [gui addLongText:DESC(@"oolite-oxzmanager-restart") startingAtRow:OXZ_GUI_ROW_FIRSTRUN align:GUI_ALIGN_LEFT];
1042 return; // yes, return, not break: controls are pointless here
1043 case OXZ_STATE_MAIN:
1044 [gui addLongText:DESC(@"oolite-oxzmanager-intro") startingAtRow:OXZ_GUI_ROW_FIRSTRUN align:GUI_ALIGN_LEFT];
1045 // fall through
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];
1051 [gui setColor:[OOColor greenColor] forRow:OXZ_GUI_ROW_LISTFILTER];
1052 }
1053
1054 [gui setText:DESC(@"oolite-oxzmanager-install") forRow:OXZ_GUI_ROW_INSTALL align:GUI_ALIGN_CENTER];
1055 [gui setKey:@"_INSTALL" forRow:OXZ_GUI_ROW_INSTALL];
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];
1059 [gui setKey:@"_REMOVE" forRow:OXZ_GUI_ROW_REMOVE];
1060 [gui setText:DESC(@"oolite-oxzmanager-update-list") forRow:OXZ_GUI_ROW_UPDATE align:GUI_ALIGN_CENTER];
1061 [gui setKey:@"_UPDATE" forRow:OXZ_GUI_ROW_UPDATE];
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];
1064
1065 startRow = OXZ_GUI_ROW_INSTALL;
1066 break;
1067 case OXZ_STATE_UPDATING:
1069 [gui setTitle:DESC(@"oolite-oxzmanager-title-downloading")];
1070
1072 [gui addLongText:OOExpandKey(@"oolite-oxzmanager-progress-error") startingAtRow:OXZ_GUI_ROW_PROGRESS align:GUI_ALIGN_LEFT];
1073 } else {
1074 [gui addLongText:[NSString stringWithFormat:DESC(@"oolite-oxzmanager-progress-@-is-@-of-@"), _currentDownloadName, [self humanSize:_downloadProgress], [self humanSize:_downloadExpected]] startingAtRow:OXZ_GUI_ROW_PROGRESS align:GUI_ALIGN_LEFT];
1075 }
1076 [gui addLongText:_progressStatus startingAtRow:OXZ_GUI_ROW_PROGRESS + 2 align:GUI_ALIGN_LEFT];
1077
1078 [gui setText:DESC(@"oolite-oxzmanager-cancel") forRow:OXZ_GUI_ROW_CANCEL align:GUI_ALIGN_CENTER];
1079 [gui setKey:@"_CANCEL" forRow:OXZ_GUI_ROW_CANCEL];
1080 startRow = OXZ_GUI_ROW_UPDATE;
1081 break;
1083 [gui setTitle:DESC(@"oolite-oxzmanager-title-dependencies")];
1084
1085 [gui setText:DESC(@"oolite-oxzmanager-dependencies-decision") forRow:OXZ_GUI_ROW_PROGRESS align:GUI_ALIGN_LEFT];
1086
1087 [gui addLongText:_progressStatus startingAtRow:OXZ_GUI_ROW_PROGRESS + 2 align:GUI_ALIGN_LEFT];
1088
1089 startRow = OXZ_GUI_ROW_INSTALLED;
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];
1092
1093 [gui setText:DESC(@"oolite-oxzmanager-dependencies-yes") forRow:OXZ_GUI_ROW_PROCEED align:GUI_ALIGN_CENTER];
1094 [gui setKey:@"_PROCEED" forRow:OXZ_GUI_ROW_PROCEED];
1095
1096 [gui setText:DESC(@"oolite-oxzmanager-dependencies-no") forRow:OXZ_GUI_ROW_CANCEL align:GUI_ALIGN_CENTER];
1097 [gui setKey:@"_CANCEL" forRow:OXZ_GUI_ROW_CANCEL];
1098 break;
1099
1100 case OXZ_STATE_REMOVING:
1101 [gui addLongText:DESC(@"oolite-oxzmanager-removal-done") startingAtRow:OXZ_GUI_ROW_PROGRESS align:GUI_ALIGN_LEFT];
1102 [gui setText:DESC(@"oolite-oxzmanager-acknowledge") forRow:OXZ_GUI_ROW_UPDATE align:GUI_ALIGN_CENTER];
1103 [gui setKey:@"_ACK" forRow:OXZ_GUI_ROW_UPDATE];
1104 startRow = OXZ_GUI_ROW_UPDATE;
1105 break;
1106 case OXZ_STATE_TASKDONE:
1108 [gui addLongText:[NSString stringWithFormat:DESC(@"oolite-oxzmanager-progress-done-%u-%u"), [_oxzList count], [[self managedOXZs] count]] startingAtRow:OXZ_GUI_ROW_PROGRESS align:GUI_ALIGN_LEFT];
1109 } else {
1110 [gui addLongText:OOExpandKey(@"oolite-oxzmanager-progress-error") startingAtRow:OXZ_GUI_ROW_PROGRESS align:GUI_ALIGN_LEFT];
1111 }
1112 [gui addLongText:_progressStatus startingAtRow:OXZ_GUI_ROW_PROGRESS + 4 align:GUI_ALIGN_LEFT];
1113
1114 [gui setText:DESC(@"oolite-oxzmanager-acknowledge") forRow:OXZ_GUI_ROW_UPDATE align:GUI_ALIGN_CENTER];
1115 [gui setKey:@"_ACK" forRow:OXZ_GUI_ROW_UPDATE];
1116 startRow = OXZ_GUI_ROW_UPDATE;
1117 break;
1118 case OXZ_STATE_EXTRACT: {
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-@"),
1125 title,
1126 version]
1127 forRow:0
1128 align:GUI_ALIGN_LEFT];
1129 [gui addLongText:DESC(@"oolite-oxzmanager-extract-info") startingAtRow:2 align:GUI_ALIGN_LEFT];
1130#ifndef OO_DEBUG_MONITOR_ENABLED
1131 [gui addLongText:DESC(@"oolite-oxzmanager-extract-releasebuild")
1133 align:GUI_ALIGN_LEFT];
1134 [gui setColor:[OOColor orangeColor] forRow:7];
1135 [gui setColor:[OOColor orangeColor] forRow:8];
1136#endif
1137 NSString* path = [self extractionBasePathForIdentifier:identifier andVersion:version];
1138 if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
1139 [gui addLongText:[NSString stringWithFormat:DESC(@"oolite-oxzmanager-extract-@-already-exists"), path]
1140 startingAtRow:10
1141 align:GUI_ALIGN_LEFT];
1142 startRow = OXZ_GUI_ROW_CANCEL;
1143 [gui setText:DESC(@"oolite-oxzmanager-extract-unavailable") forRow:OXZ_GUI_ROW_PROCEED align:GUI_ALIGN_CENTER];
1144 [gui setColor:[OOColor grayColor] forRow:OXZ_GUI_ROW_PROCEED];
1145 } else {
1146 [gui addLongText:[NSString stringWithFormat:DESC(@"oolite-oxzmanager-extract-to-@"), path]
1147 startingAtRow:10
1148 align:GUI_ALIGN_LEFT];
1149 startRow = OXZ_GUI_ROW_PROCEED;
1150 [gui setText:DESC(@"oolite-oxzmanager-extract-proceed") forRow:OXZ_GUI_ROW_PROCEED align:GUI_ALIGN_CENTER];
1151 [gui setKey:@"_PROCEED" forRow:OXZ_GUI_ROW_PROCEED];
1152 }
1153 [gui setText:DESC(@"oolite-oxzmanager-extract-cancel") forRow:OXZ_GUI_ROW_CANCEL align:GUI_ALIGN_CENTER];
1154 [gui setKey:@"_CANCEL" forRow:OXZ_GUI_ROW_CANCEL];
1155
1156 } break;
1158 [gui addLongText:_progressStatus startingAtRow:1 align:GUI_ALIGN_LEFT];
1159 [gui setText:DESC(@"oolite-oxzmanager-acknowledge") forRow:OXZ_GUI_ROW_UPDATE align:GUI_ALIGN_CENTER];
1160 [gui setKey:@"_ACK" forRow:OXZ_GUI_ROW_UPDATE];
1161 startRow = OXZ_GUI_ROW_UPDATE;
1162 break;
1163 }
1164
1166 [gui setTitle:DESC(@"oolite-oxzmanager-title-install")];
1167 [self setFilteredList:[self applyCurrentFilter:_oxzList]];
1168 startRow = [self showInstallOptions];
1170 [gui setTitle:DESC(@"oolite-oxzmanager-title-installed")];
1171 [self setFilteredList:[self applyCurrentFilter:[self managedOXZs]]];
1172 startRow = [self showInstallOptions];
1173 } else if (_interfaceState == OXZ_STATE_PICK_REMOVE) {
1174 [gui setTitle:DESC(@"oolite-oxzmanager-title-remove")];
1175 [self setFilteredList:[self applyCurrentFilter:[self managedOXZs]]];
1176 startRow = [self showRemoveOptions];
1177 }
1178
1179 if (_changesMade) {
1180 [gui setText:DESC(@"oolite-oxzmanager-exit-restart") forRow:OXZ_GUI_ROW_EXIT align:GUI_ALIGN_CENTER];
1181 } else {
1182 [gui setText:DESC(@"oolite-oxzmanager-exit") forRow:OXZ_GUI_ROW_EXIT align:GUI_ALIGN_CENTER];
1183 }
1184 [gui setKey:@"_EXIT" forRow:OXZ_GUI_ROW_EXIT];
1185 [gui setSelectableRange:NSMakeRange(startRow, 2 + (OXZ_GUI_ROW_EXIT - startRow))];
1186 if (startRow < OXZ_GUI_ROW_INSTALL) {
1187 [gui setSelectedRow:OXZ_GUI_ROW_INSTALL];
1188 } else if (_interfaceState == OXZ_STATE_NODATA) {
1189 [gui setSelectedRow:OXZ_GUI_ROW_UPDATE];
1190 } else {
1191 [gui setSelectedRow:startRow];
1192 }
1193}
NSInteger OOGUIRow
@ OXZ_STATE_PICK_INSTALLED
@ OXZ_STATE_RESTARTING
@ OXZ_STATE_SETFILTER
@ OXZ_STATE_NODATA
@ OXZ_STATE_TASKDONE
@ OXZ_STATE_DEPENDENCIES
@ OXZ_STATE_REMOVING
@ OXZ_STATE_PICK_REMOVE
@ OXZ_STATE_EXTRACTDONE
@ OXZ_STATE_EXTRACT
@ OXZ_GUI_ROW_CANCEL
@ OXZ_GUI_ROW_EXIT
@ OXZ_GUI_ROW_INSTALL
@ OXZ_GUI_ROW_INSTALLED
@ OXZ_GUI_ROW_PROCEED
@ OXZ_GUI_ROW_UPDATE
BOOL setSelectedRow:(OOGUIRow row)
OOGUIRow addLongText:startingAtRow:align:(NSString *str,[startingAtRow] OOGUIRow row,[align] OOGUIAlignment alignment)
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 setKey:forRow:(NSString *str,[forRow] OOGUIRow row)
OOColor * greenColor()
Definition OOColor.m:264

References _changesMade, _downloadStatus, _interfaceState, _oxzList, GuiDisplayGen::addLongText:startingAtRow:align:, applyCurrentFilter:, GuiDisplayGen::clearAndKeepBackground:, ResourceManager::clearCaches, extractionBasePathForIdentifier:andVersion:, OOColor::grayColor, OOColor::greenColor, gui, humanSize:, managedOXZs, nil, OOColor::orangeColor, OXZ_DOWNLOAD_COMPLETE, OXZ_DOWNLOAD_ERROR, OXZ_GUI_ROW_CANCEL, OXZ_GUI_ROW_EXIT, OXZ_GUI_ROW_INSTALL, OXZ_GUI_ROW_INSTALLED, OXZ_GUI_ROW_PROCEED, OXZ_GUI_ROW_UPDATE, OXZ_STATE_DEPENDENCIES, OXZ_STATE_EXTRACT, OXZ_STATE_EXTRACTDONE, OXZ_STATE_INSTALLING, OXZ_STATE_MAIN, OXZ_STATE_NODATA, OXZ_STATE_PICK_INSTALL, OXZ_STATE_PICK_INSTALLED, OXZ_STATE_PICK_REMOVE, OXZ_STATE_REMOVING, OXZ_STATE_RESTARTING, OXZ_STATE_SETFILTER, OXZ_STATE_TASKDONE, OXZ_STATE_UPDATING, GuiDisplayGen::setColor:forRow:, setFilteredList:, GuiDisplayGen::setKey:forRow:, GuiDisplayGen::setSelectableRange:, GuiDisplayGen::setSelectedRow:, GuiDisplayGen::setText:forRow:align:, GuiDisplayGen::setTitle:, showInstallOptions, and showRemoveOptions.

Referenced by cancelUpdate, OOOXZManager(NSURLConnectionDataDelegate)::connection:didReceiveData:, gui, processCopyUrlKey, OOOXZManager(NSURLConnectionDataDelegate)::processDownloadedManifests, OOOXZManager(NSURLConnectionDataDelegate)::processDownloadedOXZ, processExtractKey, processFilterKey, processSelection, processShowInfoKey, processTextInput:, refreshTextInput:, OOOXZManager(NSURLConnectionDataDelegate)::removeOXZ:, PlayerEntity::setGuiToOXZManager, showInstallOptions, showOptionsNext, showOptionsPrev, and showRemoveOptions.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ humanSize:

- (NSString *) humanSize: (NSUInteger) bytes
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 335 of file OOOXZManager.m.

335 :(NSUInteger)bytes
336{
337 if (bytes == 0) {
338 return DESC(@"oolite-oxzmanager-missing-field");
339 } else if (bytes < 1024) {
340 return @"<1 kB";
341 } else if (bytes < 1024 * 1024) {
342 return [NSString stringWithFormat:@"%zu kB", bytes >> 10];
343 } else {
344 return [NSString stringWithFormat:@"%.2f MB", ((float)(bytes >> 10)) / 1024];
345 }
346}

References DESC.

Referenced by gui, and showInstallOptions.

Here is the caller graph for this function:

◆ init

- (id) init
implementation

Definition at line 184 of file OOOXZManager.m.

185{
186 self = [super init];
187 if (self != nil) {
189 // if the file has not been downloaded, this will be nil
190 [self setOXZList:OOArrayFromFile([self manifestPath])];
191 OOLog(kOOOXZDebugLog, @"Initialised with %@", _oxzList);
193 _currentFilter = @"*";
194
196 _changesMade = NO;
198 _dependencyStack = [[NSMutableSet alloc] initWithCapacity:8];
199 [self setProgressStatus:@""];
200 }
201 return self;
202}
BOOL _downloadAllDependencies
BOOL _interfaceShowingOXZDetail
NSMutableSet * _dependencyStack

References _changesMade, _currentFilter, _dependencyStack, _downloadAllDependencies, _downloadStatus, _interfaceShowingOXZDetail, _interfaceState, _oxzList, init, kOOOXZDebugLog, manifestPath, nil, OOLog, OXZ_DOWNLOAD_NONE, OXZ_STATE_NODATA, setOXZList:, and setProgressStatus:.

Referenced by init.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ installableState:

- (OXZInstallableState) installableState: (NSDictionary*) manifest
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 897 of file OOOXZManager.m.

897 :(NSDictionary*)manifest
898{
899 NSString* title = [manifest oo_stringForKey:kOOManifestTitle defaultValue:nil];
900 NSString* identifier = [manifest oo_stringForKey:kOOManifestIdentifier defaultValue:nil];
901 /* Check Oolite version */
902 if (![ResourceManager checkVersionCompatibility:manifest forOXP:title]) {
904 }
905 /* Check for current automated install */
906 NSDictionary* installed = [self installedManifestForIdentifier:identifier];
907 if (installed == nil) {
908 // check for manual install
909 installed = [ResourceManager manifestForIdentifier:identifier];
910 }
911
912 if (installed != nil) {
913 if (![[installed oo_stringForKey:kOOManifestFilePath] hasPrefix:[self installPath]]) {
914 // installed manually
916 }
917 if ([[installed oo_stringForKey:kOOManifestVersion] isEqualToString:[manifest oo_stringForKey:kOOManifestAvailableVersion defaultValue:[manifest oo_stringForKey:kOOManifestVersion]]]
918 && [[NSFileManager defaultManager] fileExistsAtPath:[installed oo_stringForKey:kOOManifestFilePath]]) {
919 // installed this exact version already, and haven't
920 // uninstalled it since entering the manager, and it's
921 // still available
923 } else if ([installed oo_stringForKey:kOOManifestAvailableVersion defaultValue:nil] == nil) {
924 // installed, but no remote copy is indexed any more
926 }
927 }
928 /* Check for dependencies being met */
929 if ([ResourceManager manifestHasConflicts:manifest logErrors:NO]) {
931 }
932 if (installed != nil) {
933 NSString* availableVersion = [manifest oo_stringForKey:kOOManifestAvailableVersion];
934 if (availableVersion == nil) {
935 availableVersion = [manifest oo_stringForKey:kOOManifestVersion];
936 }
937 NSString* installedVersion = [installed oo_stringForKey:kOOManifestVersion];
938 OOLog(@"version.debug", @"%@ mv:%@ mav:%@", identifier, installedVersion, availableVersion);
939 if (CompareVersions(ComponentsFromVersionString(installedVersion), ComponentsFromVersionString(availableVersion)) == NSOrderedDescending) {
940 // the installed copy is more recent than the server copy
942 }
944 }
945 if ([ResourceManager manifestHasMissingDependencies:manifest logErrors:NO]) {
947 }
949}
static NSString *const kOOManifestAvailableVersion
static NSString *const kOOManifestVersion
static NSString *const kOOManifestFilePath
NSArray * ComponentsFromVersionString(NSString *string)
NSComparisonResult CompareVersions(NSArray *version1, NSArray *version2)
NSString * installPath()
NSDictionary * manifestForIdentifier:(NSString *identifier)

References CompareVersions(), ComponentsFromVersionString(), installedManifestForIdentifier:, kOOManifestAvailableVersion, kOOManifestFilePath, kOOManifestVersion, ResourceManager::manifestForIdentifier:, nil, OOLog, OXZ_INSTALLABLE_CONFLICTS, OXZ_INSTALLABLE_DEPENDENCIES, OXZ_INSTALLABLE_OKAY, OXZ_INSTALLABLE_UPDATE, OXZ_UNINSTALLABLE_ALREADY, OXZ_UNINSTALLABLE_MANUAL, OXZ_UNINSTALLABLE_NOREMOTE, and OXZ_UNINSTALLABLE_VERSION.

Here is the call graph for this function:

◆ installedManifestForIdentifier:

- (NSDictionary *) installedManifestForIdentifier: (NSString*) identifier
implementation

Definition at line 885 of file OOOXZManager.m.

885 :(NSString*)identifier
886{
887 NSArray* installed = [self managedOXZs];
888 NSDictionary* manifest = nil;
889 foreach (manifest, installed) {
890 if ([[manifest oo_stringForKey:kOOManifestIdentifier] isEqualToString:identifier]) {
891 return manifest;
892 }
893 }
894 return nil;
895}
static NSString *const kOOManifestIdentifier

References kOOManifestIdentifier, managedOXZs, and nil.

Referenced by OOOXZManager(NSURLConnectionDataDelegate)::installableState:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ installOptions

- (NSArray *) installOptions
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 1519 of file OOOXZManager.m.

1520{
1521 NSUInteger start = _offset;
1522 if (start >= [_filteredList count]) {
1523 start = 0;
1524 _offset = 0;
1525 }
1526 NSUInteger end = start + OXZ_GUI_NUM_LISTROWS;
1527 if (end > [_filteredList count]) {
1528 end = [_filteredList count];
1529 }
1530 return [_filteredList subarrayWithRange:NSMakeRange(start, end - start)];
1531}
@ OXZ_GUI_NUM_LISTROWS
unsigned count
NSUInteger _offset

References count, OOOXZManager(NSURLConnectionDataDelegate)::installOptions, and OXZ_GUI_NUM_LISTROWS.

Referenced by OOOXZManager(NSURLConnectionDataDelegate)::installOptions, and showInstallOptions.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ installOXZ:

- (BOOL) installOXZ: (NSUInteger) item
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 1462 of file OOOXZManager.m.

1462 :(NSUInteger)item
1463{
1464 NSArray* picklist = _filteredList;
1465
1466 if ([picklist count] <= item) {
1467 return NO;
1468 }
1469 NSDictionary* manifest = [picklist objectAtIndex:item];
1470 _item = item;
1471
1472 if ([self installableState:manifest] >= OXZ_UNINSTALLABLE_ALREADY) {
1473 OOLog(kOOOXZDebugLog, @"Cannot install %@", manifest);
1474 // can't be installed on this version of Oolite, or already is installed
1475 return NO;
1476 }
1477 NSString* url = [manifest objectForKey:kOOManifestDownloadURL];
1478 if (url == nil) {
1479 OOLog(kOOOXZErrorLog, @"%@", @"Manifest does not have a download URL - cannot install");
1480 return NO;
1481 }
1482 NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];
1484 return NO;
1485 }
1488
1489 [self setProgressStatus:@""];
1490 return [self beginDownload:request];
1491}
@ OXZ_DOWNLOAD_STARTED
NSUInteger _item

References beginDownload:, count, kOOOXZDebugLog, kOOOXZErrorLog, nil, OOLog, OXZ_DOWNLOAD_NONE, OXZ_DOWNLOAD_STARTED, OXZ_STATE_INSTALLING, OXZ_UNINSTALLABLE_ALREADY, and setProgressStatus:.

Referenced by processSelection, and OOOXZManager(NSURLConnectionDataDelegate)::updateAllOXZ.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ installPath

- (NSString *) installPath

Definition at line 220 of file OOOXZManager.m.

221{
222 const char* managedAddOnsEnv = SDL_getenv("OO_MANAGEDADDONSDIR");
223
224 if (managedAddOnsEnv) {
225 return [NSString stringWithUTF8String:managedAddOnsEnv];
226 } else {
227 NSArray* paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
228 NSString* appPath = [paths objectAtIndex:0];
229 if (appPath != nil) {
230 appPath = [appPath stringByAppendingPathComponent:@"Oolite"];
231#if OOLITE_MAC_OS_X
232 appPath = [appPath stringByAppendingPathComponent:@"Managed AddOns"];
233#else
234 /* GNUStep uses "ApplicationSupport" rather than "Application
235 * Support" so match convention by not putting a space in the
236 * path either */
237 appPath = [appPath stringByAppendingPathComponent:@"ManagedAddOns"];
238#endif
239 return appPath;
240 }
241 }
242 return nil;
243}

References installPath, and nil.

Referenced by OOOXZManager(NSURLConnectionDataDelegate)::ensureInstallPath, installPath, managedOXZs, OOOXZManager(NSURLConnectionDataDelegate)::processDownloadedOXZ, ResourceManager::rootPaths, and showInstallOptions.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ installStatusForManifest:

- (NSString *) installStatusForManifest: (NSDictionary*) manifest
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 974 of file OOOXZManager.m.

974 :(NSDictionary*)manifest
975{
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");
993 }
994 return nil; // never
995}

References DESC, nil, OXZ_INSTALLABLE_CONFLICTS, OXZ_INSTALLABLE_DEPENDENCIES, OXZ_INSTALLABLE_OKAY, OXZ_INSTALLABLE_UPDATE, OXZ_UNINSTALLABLE_ALREADY, OXZ_UNINSTALLABLE_MANUAL, OXZ_UNINSTALLABLE_NOREMOTE, and OXZ_UNINSTALLABLE_VERSION.

Referenced by showInstallOptions, and showRemoveOptions.

Here is the caller graph for this function:

◆ isAcceptingGUIInput

- (BOOL) isAcceptingGUIInput

Definition at line 1306 of file OOOXZManager.m.

1307{
1309}

References _interfaceShowingOXZDetail, and isAcceptingGUIInput.

Referenced by isAcceptingGUIInput.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isAcceptingTextInput

- (BOOL) isAcceptingTextInput

Definition at line 1301 of file OOOXZManager.m.

1302{
1304}

References _interfaceState, isAcceptingTextInput, and OXZ_STATE_SETFILTER.

Referenced by isAcceptingTextInput.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isRestarting

- (BOOL) isRestarting

Definition at line 1195 of file OOOXZManager.m.

1196{
1197 // for the restart
1199 // Rebuilds OXP search
1201 [UNIVERSE reinitAndShowDemo:YES];
1202 _changesMade = NO;
1204 _downloadStatus = OXZ_DOWNLOAD_NONE; // clear error state
1205 return YES;
1206 } else {
1207 return NO;
1208 }
1209}
#define EXPECT_NOT(x)

References _changesMade, _downloadStatus, _interfaceState, EXPECT_NOT, isRestarting, OXZ_DOWNLOAD_NONE, OXZ_STATE_MAIN, OXZ_STATE_RESTARTING, and ResourceManager::reset.

Referenced by isRestarting.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ managedOXZs

- (NSArray *) managedOXZs

Definition at line 615 of file OOOXZManager.m.

616{
617 if (_managedList == nil) {
618 // if this list is being reset, also reset the current install list
620 NSArray* managedOXZs = [[NSFileManager defaultManager] oo_directoryContentsAtPath:[self installPath]];
621 NSMutableArray* manifests = [NSMutableArray arrayWithCapacity:[managedOXZs count]];
622 NSString* filename = nil;
623 NSString* fullpath = nil;
624 NSDictionary* manifest = nil;
625 foreach (filename, managedOXZs) {
626 fullpath = [[self installPath] stringByAppendingPathComponent:filename];
627 manifest = OODictionaryFromFile([fullpath stringByAppendingPathComponent:@"manifest.plist"]);
628 if (manifest != nil) {
629 NSMutableDictionary* adjManifest = [NSMutableDictionary dictionaryWithDictionary:manifest];
630 [adjManifest setObject:fullpath forKey:kOOManifestFilePath];
631
632 NSDictionary* stored = nil;
633 /* The list is already sorted to put the latest
634 * versions first. This flag means that it stops
635 * checking the list for versions once it finds one
636 * that is plausibly installable */
637 BOOL foundInstallable = NO;
638 foreach (stored, _oxzList) {
639 if ([[stored oo_stringForKey:kOOManifestIdentifier] isEqualToString:[manifest oo_stringForKey:kOOManifestIdentifier]]) {
640 if (foundInstallable == NO) {
641 [adjManifest setObject:[stored oo_stringForKey:kOOManifestVersion] forKey:kOOManifestAvailableVersion];
642 [adjManifest setObject:[stored oo_stringForKey:kOOManifestDownloadURL] forKey:kOOManifestDownloadURL];
643 if ([ResourceManager checkVersionCompatibility:manifest forOXP:nil]) {
644 foundInstallable = YES;
645 }
646 }
647 }
648 }
649
650 [manifests addObject:adjManifest];
651 }
652 }
653 [manifests sortUsingFunction:oxzSort context:NULL];
654
655 _managedList = [manifests copy];
656 }
657 return _managedList;
658}
NSDictionary * OODictionaryFromFile(NSString *path)
NSArray * managedOXZs()
NSArray * manifests()
void resetManifestKnowledgeForOXZManager()
const char * filename
Definition ioapi.h:125

References _managedList, _oxzList, installPath, kOOManifestIdentifier, managedOXZs, manifests, nil, OODictionaryFromFile(), and ResourceManager::resetManifestKnowledgeForOXZManager.

Referenced by gui, installedManifestForIdentifier:, managedOXZs, showOptionsUpdate, and showRemoveOptions.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ manifestPath

- (NSString *) manifestPath
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 308 of file OOOXZManager.m.

309{
310 return [[[OOCacheManager sharedCache] cacheDirectoryPathCreatingIfNecessary:YES] stringByAppendingPathComponent:kOOOXZManifestCache];
311}

References OOCacheManager::cacheDirectoryPathCreatingIfNecessary:, OOOXZManager(NSURLConnectionDataDelegate)::manifestPath, and OOCacheManager::sharedCache.

Referenced by init, OOOXZManager(NSURLConnectionDataDelegate)::manifestPath, and OOOXZManager(NSURLConnectionDataDelegate)::processDownloadedManifests.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ manifests

- (NSArray *) manifests

Definition at line 610 of file OOOXZManager.m.

611{
612 return _oxzList;
613}

References _oxzList, and manifests.

Referenced by managedOXZs, and manifests.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processCopyUrlKey

- (void) processCopyUrlKey

Definition at line 1417 of file OOOXZManager.m.

1418{
1419
1421 GuiDisplayGen* gui = [UNIVERSE gui];
1422
1424 [[UNIVERSE gameView] stringToClipboard:_currentOXPURL];
1425 } else {
1426 OOGUIRow selection = [gui selectedRow];
1427
1428 if (selection < OXZ_GUI_ROW_LISTSTART || selection >= OXZ_GUI_ROW_LISTSTART + OXZ_GUI_NUM_LISTROWS) {
1429 // not on an OXZ
1430 return;
1431 }
1432 _item = _offset + selection - OXZ_GUI_ROW_LISTSTART;
1433
1434 NSDictionary* manifest = [_filteredList oo_dictionaryAtIndex:_item];
1435 // infoURL
1436 NSString* infoURLString = [manifest oo_stringForKey:kOOManifestInformationURL];
1437 // copy url info text to clipboard automatically once we are in the oxz info page
1438 [[UNIVERSE gameView] stringToClipboard:infoURLString];
1439 }
1440 }
1441}
@ OXZ_GUI_ROW_LISTSTART
OOGUIRow selectedRow

References _interfaceShowingOXZDetail, _interfaceState, _item, _offset, gui, OXZ_GUI_NUM_LISTROWS, OXZ_GUI_ROW_LISTSTART, OXZ_STATE_PICK_INSTALL, OXZ_STATE_PICK_INSTALLED, OXZ_STATE_PICK_REMOVE, processCopyUrlKey, and GuiDisplayGen::selectedRow.

Referenced by PlayerEntity(OOControlsPrivate)::pollDemoControls:, and processCopyUrlKey.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processDownloadedManifests

- (BOOL) processDownloadedManifests
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 660 of file OOOXZManager.m.

661{
663 return NO;
664 }
665 [self setOXZList:OOArrayFromFile([self downloadPath])];
666 if (_oxzList != nil) {
667 [_oxzList writeToFile:[self manifestPath] atomically:YES];
668 // and clean up the temp file
669 [[NSFileManager defaultManager] oo_removeItemAtPath:[self downloadPath]];
670 // invalidate the managed list
673 [self gui];
674 return YES;
675 } else {
677 OOLog(kOOOXZErrorLog, @"Downloaded manifest was not a valid plist, has been left in %@", [self downloadPath]);
678 // revert to the old one
679 [self setOXZList:OOArrayFromFile([self manifestPath])];
681 [self gui];
682 return NO;
683 }
684}

References DESTROY, downloadPath, OOOXZManager(NSURLConnectionDataDelegate)::downloadPath, gui, kOOOXZErrorLog, manifestPath, nil, OOLog, OXZ_DOWNLOAD_COMPLETE, OXZ_DOWNLOAD_ERROR, OXZ_STATE_TASKDONE, OOOXZManager(NSURLConnectionDataDelegate)::processDownloadedManifests, and setOXZList:.

Referenced by OOOXZManager(NSURLConnectionDataDelegate)::connectionDidFinishLoading:, and OOOXZManager(NSURLConnectionDataDelegate)::processDownloadedManifests.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processDownloadedOXZ

- (BOOL) processDownloadedOXZ
implementation

If downloadedManifest is in _dependencyStack, remove it Get downloadedManifest requires_oxp list Add entries ones to _dependencyStack If _dependencyStack has contents, update _progressStatus ...and start the download of the 'first' item in _dependencyStack ...which isn't already installed (_dependencyStack is unordered ...so 'first' isn't really defined)

...if the item in _dependencyStack is not findable (e.g. wrong ...version) then stop here.

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 686 of file OOOXZManager.m.

687{
689 return NO;
690 }
691
692 NSDictionary* downloadedManifest = OODictionaryFromFile([[self downloadPath] stringByAppendingPathComponent:@"manifest.plist"]);
693 if (downloadedManifest == nil) {
695 OOLog(kOOOXZErrorLog, @"Downloaded OXZ does not contain a manifest.plist, has been left in %@", [self downloadPath]);
697 [self gui];
698 return NO;
699 }
700 NSDictionary* expectedManifest = nil;
701 expectedManifest = [_filteredList objectAtIndex:_item];
702
703 if (expectedManifest == nil || (![[downloadedManifest oo_stringForKey:kOOManifestIdentifier] isEqualToString:[expectedManifest oo_stringForKey:kOOManifestIdentifier]]) || (![[downloadedManifest oo_stringForKey:kOOManifestVersion] isEqualToString:[expectedManifest oo_stringForKey:kOOManifestAvailableVersion defaultValue:[expectedManifest oo_stringForKey:kOOManifestVersion]]])) {
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.");
707 [self gui];
708 return NO;
709 }
710 // this appears to be the OXZ we expected
711 // filename is going to be identifier.oxz
712 NSString* filename = [[downloadedManifest oo_stringForKey:kOOManifestIdentifier] stringByAppendingString:@".oxz"];
713
714 if (![self ensureInstallPath]) {
716 OOLog(kOOOXZErrorLog, @"%@", @"Unable to create installation folder.");
718 [self gui];
719 return NO;
720 }
721
722 // delete filename if it exists from OXZ folder
723 NSString* destination = [[self installPath] stringByAppendingPathComponent:filename];
724 [[NSFileManager defaultManager] oo_removeItemAtPath:destination];
725
726 // move the temp file on to it
727 if (![[NSFileManager defaultManager] oo_moveItemAtPath:[self downloadPath] toPath:destination]) {
729 OOLog(kOOOXZErrorLog, @"%@", @"Downloaded OXZ could not be installed.");
731 [self gui];
732 return NO;
733 }
734 _changesMade = YES;
735 DESTROY(_managedList); // will need updating
736 // do this now to cope with circular dependencies on download
738
751 NSArray*
752 requires
753 = [downloadedManifest oo_arrayForKey:kOOManifestRequiresOXPs defaultValue:nil];
754 if (requires == nil) {
755 // just in case the requirements are only specified in the online copy
756 requires = [expectedManifest oo_arrayForKey:kOOManifestRequiresOXPs defaultValue:nil];
757 }
758 NSDictionary* requirement = nil;
759 NSMutableString* progress = [NSMutableString stringWithCapacity:2048];
760 OOLog(kOOOXZDebugLog, @"Dependency stack has %zu elements", [_dependencyStack count]);
761
762 if ([_dependencyStack count] > 0) {
763 // will remove as iterate, so create a temp copy to iterate over
764 NSSet* tempStack = [NSSet setWithSet:_dependencyStack];
765 foreach (requirement, tempStack) {
766 OOLog(kOOOXZDebugLog, @"Dependency stack: checking %@", [requirement oo_stringForKey:kOOManifestRelationIdentifier]);
767 if (![ResourceManager manifest:downloadedManifest HasUnmetDependency:requirement logErrors:NO]
768 && requires != nil && [requires containsObject:requirement]) {
769 // it was unmet, but now it's met
770 [progress appendFormat:DESC(@"oolite-oxzmanager-progress-now-has-@"), [requirement oo_stringForKey:kOOManifestRelationDescription defaultValue:[requirement oo_stringForKey:kOOManifestRelationIdentifier]]];
771 [_dependencyStack removeObject:requirement];
772 OOLog(kOOOXZDebugLog, @"%@", @"Dependency stack: requirement met");
773 } else if ([[requirement oo_stringForKey:kOOManifestRelationIdentifier] isEqualToString:[downloadedManifest oo_stringForKey:kOOManifestIdentifier]]) {
774 // remove the requirement for the just downloaded OXP
775 [_dependencyStack removeObject:requirement];
776 }
777 }
778 }
779 if (requires != nil) {
780 foreach (requirement, requires) {
781 if ([ResourceManager manifest:downloadedManifest HasUnmetDependency:requirement logErrors:NO]) {
782 OOLog(kOOOXZDebugLog, @"Dependency stack: adding %@", [requirement oo_stringForKey:kOOManifestRelationIdentifier]);
783 [_dependencyStack addObject:requirement];
784 [progress appendFormat:DESC(@"oolite-oxzmanager-progress-requires-@"), [requirement oo_stringForKey:kOOManifestRelationDescription defaultValue:[requirement oo_stringForKey:kOOManifestRelationIdentifier]]];
785 }
786 }
787 }
788 if ([_dependencyStack count] > 0) {
789 // get an object from the requirements list, and download it
790 // if it can be found
791 BOOL undownloadedRequirement = NO;
792 NSDictionary* availableDownload = nil;
793 BOOL foundDownload = NO;
794 NSUInteger index = 0;
795 NSString* needsIdentifier = nil;
796
797 do {
798 undownloadedRequirement = YES;
799 requirement = [_dependencyStack anyObject];
800 OOLog(kOOOXZDebugLog, @"Dependency stack: next is %@", [requirement oo_stringForKey:kOOManifestRelationIdentifier]);
801
803 [progress appendString:DESC(@"oolite-oxzmanager-progress-get-required")];
804 }
805 needsIdentifier = [requirement oo_stringForKey:kOOManifestRelationIdentifier];
806
807 foreach (availableDownload, _oxzList) {
808 if ([[availableDownload oo_stringForKey:kOOManifestIdentifier] isEqualToString:needsIdentifier]) {
809 if ([ResourceManager matchVersions:requirement withVersion:[availableDownload oo_stringForKey:kOOManifestVersion]]) {
810 OOLog(kOOOXZDebugLog, @"%@", @"Dependency stack: found download for next item");
811 foundDownload = YES;
812 index = [_oxzList indexOfObject:availableDownload];
813 break;
814 }
815 }
816 }
817
818 if (foundDownload) {
819 if ([self installableState:[_oxzList objectAtIndex:index]] == OXZ_UNINSTALLABLE_ALREADY) {
820 OOLog(kOOOXZDebugLog, @"Dependency stack: %@ is downloaded but not yet loadable, removing from list.", [requirement oo_stringForKey:kOOManifestRelationIdentifier]);
821 // then this has already been downloaded, but
822 // can't be configured yet presumably because
823 // another dependency is still to be loaded
824 [_dependencyStack removeObject:requirement];
825 if ([_dependencyStack count] > 0) {
826 // try again
827 undownloadedRequirement = NO;
828 } else {
829 // this case should probably never happen
830 // is handled below just in case
831 foundDownload = NO;
832 }
833 }
834 }
835 } while (!undownloadedRequirement);
836
837 if (foundDownload) {
838 // must clear filters entirely at this point
839 [self setFilteredList:_oxzList];
840 // then download that item
843 OOLog(kOOOXZDebugLog, @"Dependency stack: installing %zu from list", index);
844 if (![self installOXZ:index]) {
845 // if a required dependency is somehow uninstallable
846 // e.g. required+maximum version don't match this Oolite
847 [progress appendFormat:DESC(@"oolite-oxzmanager-progress-required-@-not-found"), [requirement oo_stringForKey:kOOManifestRelationDescription defaultValue:[requirement oo_stringForKey:kOOManifestRelationIdentifier]]];
848 [self setProgressStatus:progress];
849 OOLog(kOOOXZErrorLog, @"OXZ dependency %@ could not be found for automatic download.", needsIdentifier);
851 OOLog(kOOOXZErrorLog, @"%@", @"Downloaded OXZ could not be installed.");
853 [self gui];
854 return NO;
855 }
856 } else {
858 _item = index;
859 }
860 [self setProgressStatus:progress];
861 [self gui];
862 return YES;
863 }
864 // this is probably always the case, see above
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]]];
867 [self setProgressStatus:progress];
868 OOLog(kOOOXZErrorLog, @"OXZ dependency %@ could not be found for automatic download.", needsIdentifier);
870 OOLog(kOOOXZErrorLog, @"%@", @"Downloaded OXZ could not be installed.");
872 [self gui];
873 return NO;
874 }
875 }
876
877 [self setProgressStatus:@""];
879 [_dependencyStack removeAllObjects]; // just in case
881 [self gui];
882 return YES;
883}
static NSString *const kOOManifestRelationIdentifier
BOOL ensureInstallPath()

References count, DESTROY, OOOXZManager(NSURLConnectionDataDelegate)::downloadPath, OOOXZManager(NSURLConnectionDataDelegate)::ensureInstallPath, gui, installPath, kOOManifestAvailableVersion, kOOManifestIdentifier, kOOManifestRelationIdentifier, kOOManifestVersion, kOOOXZDebugLog, kOOOXZErrorLog, nil, OODictionaryFromFile(), OOLog, OXZ_DOWNLOAD_COMPLETE, OXZ_DOWNLOAD_ERROR, OXZ_DOWNLOAD_NONE, OXZ_STATE_DEPENDENCIES, OXZ_STATE_TASKDONE, OXZ_UNINSTALLABLE_ALREADY, OOOXZManager(NSURLConnectionDataDelegate)::processDownloadedOXZ, ResourceManager::resetManifestKnowledgeForOXZManager, setFilteredList:, and setProgressStatus:.

Referenced by OOOXZManager(NSURLConnectionDataDelegate)::connectionDidFinishLoading:, and OOOXZManager(NSURLConnectionDataDelegate)::processDownloadedOXZ.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processExtractKey

- (void) processExtractKey

Definition at line 1443 of file OOOXZManager.m.

1444{
1445 // TODO: Extraction functionality - converts an installed OXZ to
1446 // an OXP in the main AddOns folder if it's safe to do so.
1448 GuiDisplayGen* gui = [UNIVERSE gui];
1449 OOGUIRow selection = [gui selectedRow];
1450
1451 if (selection < OXZ_GUI_ROW_LISTSTART || selection >= OXZ_GUI_ROW_LISTSTART + OXZ_GUI_NUM_LISTROWS) {
1452 // not on an OXZ
1453 return;
1454 }
1455
1456 _item = _offset + selection - OXZ_GUI_ROW_LISTSTART;
1458 [self gui];
1459 }
1460}

References _interfaceShowingOXZDetail, _interfaceState, _item, _offset, gui, OXZ_GUI_NUM_LISTROWS, OXZ_GUI_ROW_LISTSTART, OXZ_STATE_EXTRACT, OXZ_STATE_PICK_INSTALLED, OXZ_STATE_PICK_REMOVE, processExtractKey, and GuiDisplayGen::selectedRow.

Referenced by PlayerEntity(OOControlsPrivate)::pollDemoControls:, and processExtractKey.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processFilterKey

- (void) processFilterKey

Definition at line 1334 of file OOOXZManager.m.

1335{
1338 }
1341 [[UNIVERSE gameView] resetTypedString];
1342 [self gui];
1343 }
1344 // else this key does nothing
1345}

References _interfaceShowingOXZDetail, _interfaceState, gui, OXZ_STATE_MAIN, OXZ_STATE_PICK_INSTALL, OXZ_STATE_PICK_INSTALLED, OXZ_STATE_PICK_REMOVE, OXZ_STATE_SETFILTER, and processFilterKey.

Referenced by PlayerEntity(OOControlsPrivate)::pollDemoControls:, and processFilterKey.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processOptionsNext

- (void) processOptionsNext

Definition at line 1851 of file OOOXZManager.m.

1852{
1855 }
1856 [self showOptionsUpdate];
1857 return;
1858}

References _filteredList, _offset, count, OXZ_GUI_NUM_LISTROWS, processOptionsNext, and showOptionsUpdate.

Referenced by PlayerEntity(OOControlsPrivate)::pollDemoControls:, processOptionsNext, and processSelection.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processOptionsPrev

- (void) processOptionsPrev

Definition at line 1841 of file OOOXZManager.m.

1842{
1844 _offset = 0;
1845 } else {
1847 }
1848 [self showOptionsUpdate];
1849}

References _offset, OXZ_GUI_NUM_LISTROWS, processOptionsPrev, and showOptionsUpdate.

Referenced by PlayerEntity(OOControlsPrivate)::pollDemoControls:, processOptionsPrev, and processSelection.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processSelection

- (void) processSelection

Definition at line 1211 of file OOOXZManager.m.

1212{
1213 GuiDisplayGen* gui = [UNIVERSE gui];
1214 OOGUIRow selection = [gui selectedRow];
1215
1216 if (selection == OXZ_GUI_ROW_EXIT) {
1217 [self cancelUpdate]; // doesn't hurt if no update in progress
1218 [_dependencyStack removeAllObjects]; // cleanup
1220 _downloadStatus = OXZ_DOWNLOAD_NONE; // clear error state
1221 if (_changesMade) {
1223 } else {
1224 [PLAYER setGuiToIntroFirstGo:YES];
1225 if (_oxzList != nil) {
1227 } else {
1229 }
1230 return;
1231 }
1232 } else if (selection == OXZ_GUI_ROW_UPDATE) // also == _CANCEL
1233 {
1238 [_dependencyStack removeAllObjects];
1242 } else if (_interfaceState == OXZ_STATE_EXTRACTDONE) {
1243 [_dependencyStack removeAllObjects];
1248 [self cancelUpdate]; // sets interface state and download status
1249 } else if (_interfaceState == OXZ_STATE_EXTRACT) {
1251 } else {
1252 [self updateManifests];
1253 }
1254 } else if (selection == OXZ_GUI_ROW_INSTALL) {
1256 } else if (selection == OXZ_GUI_ROW_INSTALLED) {
1257 if (_interfaceState == OXZ_STATE_DEPENDENCIES) // also == _PROCEED_ALL
1258 {
1260 [self installOXZ:_item];
1261 } else {
1263 }
1264 } else if (selection == OXZ_GUI_ROW_REMOVE) // also == _PROCEED
1265 {
1267 [self installOXZ:_item];
1268 } else if (_interfaceState == OXZ_STATE_NODATA) {
1270 } else if (_interfaceState == OXZ_STATE_EXTRACT) {
1271 [self setProgressStatus:[self extractOXZ:_item]];
1273 } else {
1275 }
1276 } else if (selection == OXZ_GUI_ROW_UPDATE_ALL) {
1277 OOLog(kOOOXZDebugLog, @"%@", @"Trying to update all managed OXPs");
1278 [self updateAllOXZ];
1279 } else if (selection == OXZ_GUI_ROW_LISTPREV) {
1280 [self processOptionsPrev];
1281 return;
1282 } else if (selection == OXZ_GUI_ROW_LISTNEXT) {
1283 [self processOptionsNext];
1284 return;
1285 } else {
1286 NSUInteger item = _offset + selection - OXZ_GUI_ROW_LISTSTART;
1288 [self removeOXZ:item];
1290 OOLog(kOOOXZDebugLog, @"Trying to install index %zu", item);
1291 [self installOXZ:item];
1293 OOLog(kOOOXZDebugLog, @"Trying to install index %zu", item);
1294 [self installOXZ:item];
1295 }
1296 }
1297
1298 [self gui]; // update GUI
1299}
@ OXZ_GUI_ROW_REMOVE
@ OXZ_GUI_ROW_UPDATE_ALL
@ OXZ_GUI_ROW_LISTPREV
@ OXZ_GUI_ROW_LISTNEXT

References _changesMade, _downloadAllDependencies, _downloadStatus, _interfaceState, _offset, _oxzList, cancelUpdate, extractOXZ:, gui, installOXZ:, kOOOXZDebugLog, nil, OOLog, OXZ_DOWNLOAD_NONE, OXZ_GUI_ROW_EXIT, OXZ_GUI_ROW_INSTALL, OXZ_GUI_ROW_INSTALLED, OXZ_GUI_ROW_LISTNEXT, OXZ_GUI_ROW_LISTPREV, OXZ_GUI_ROW_LISTSTART, OXZ_GUI_ROW_REMOVE, OXZ_GUI_ROW_UPDATE, OXZ_GUI_ROW_UPDATE_ALL, OXZ_STATE_DEPENDENCIES, OXZ_STATE_EXTRACT, OXZ_STATE_EXTRACTDONE, OXZ_STATE_INSTALLING, OXZ_STATE_MAIN, OXZ_STATE_NODATA, OXZ_STATE_PICK_INSTALL, OXZ_STATE_PICK_INSTALLED, OXZ_STATE_PICK_REMOVE, OXZ_STATE_REMOVING, OXZ_STATE_RESTARTING, OXZ_STATE_TASKDONE, OXZ_STATE_UPDATING, processOptionsNext, processOptionsPrev, processSelection, removeOXZ:, GuiDisplayGen::selectedRow, setProgressStatus:, updateAllOXZ, and updateManifests.

Referenced by PlayerEntity(OOControlsPrivate)::pollDemoControls:, processSelection, showOptionsNext, and showOptionsPrev.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processShowInfoKey

- (void) processShowInfoKey

Definition at line 1347 of file OOOXZManager.m.

1348{
1350 GuiDisplayGen* gui = [UNIVERSE gui];
1351
1354 [self gui]; // restore screen
1355 // reset list selection position
1356 [gui setSelectedRow:(_item - _offset + OXZ_GUI_ROW_LISTSTART)];
1357 // and do the GUI again with the correct positions
1358 [self showOptionsUpdate]; // restore screen
1359 } else {
1360 OOGUIRow selection = [gui selectedRow];
1361
1362 if (selection < OXZ_GUI_ROW_LISTSTART || selection >= OXZ_GUI_ROW_LISTSTART + OXZ_GUI_NUM_LISTROWS) {
1363 // not on an OXZ
1364 return;
1365 }
1366
1367 _item = _offset + selection - OXZ_GUI_ROW_LISTSTART;
1368
1369 NSDictionary* manifest = [_filteredList oo_dictionaryAtIndex:_item];
1371
1372 [gui clearAndKeepBackground:YES];
1373 [gui setTitle:DESC(@"oolite-oxzmanager-title-infopage")];
1374
1375 // title, version
1376 [gui setText:[NSString stringWithFormat:DESC(@"oolite-oxzmanager-infopage-title-@-version-@"),
1377 [manifest oo_stringForKey:kOOManifestTitle],
1378 [manifest oo_stringForKey:kOOManifestVersion]]
1379 forRow:0
1380 align:GUI_ALIGN_LEFT];
1381
1382 // author
1383 [gui setText:[NSString stringWithFormat:DESC(@"oolite-oxzmanager-infopage-author-@"),
1384 [manifest oo_stringForKey:kOOManifestAuthor]]
1385 forRow:1
1386 align:GUI_ALIGN_LEFT];
1387
1388 // license
1389 [gui addLongText:[NSString stringWithFormat:DESC(@"oolite-oxzmanager-infopage-license-@"),
1390 [manifest oo_stringForKey:kOOManifestLicense]]
1392 align:GUI_ALIGN_LEFT];
1393 // tags
1394
1395 [gui addLongText:[NSString stringWithFormat:DESC(@"oolite-oxzmanager-infopage-tags-@"), [[manifest oo_arrayForKey:kOOManifestTags] componentsJoinedByString:@", "]]
1397 align:GUI_ALIGN_LEFT];
1398 // description
1399 [gui addLongText:[NSString stringWithFormat:DESC(@"oolite-oxzmanager-infopage-description-@"), [manifest oo_stringForKey:kOOManifestDescription]]
1401 align:GUI_ALIGN_LEFT];
1402
1403 // infoURL
1404 NSString* infoURLString = [manifest oo_stringForKey:kOOManifestInformationURL];
1405 [gui setText:[NSString stringWithFormat:DESC(@"oolite-oxzmanager-infopage-infourl-@"),
1406 infoURLString]
1407 forRow:25
1408 align:GUI_ALIGN_LEFT];
1409 [self setOXPURL:infoURLString];
1410 // instructions
1411 [gui setText:OOExpand(DESC(@"oolite-oxzmanager-infopage-return")) forRow:27 align:GUI_ALIGN_CENTER];
1412 [gui setColor:[OOColor greenColor] forRow:27];
1413 }
1414 }
1415}

References _interfaceShowingOXZDetail, _interfaceState, _item, _offset, GuiDisplayGen::addLongText:startingAtRow:align:, GuiDisplayGen::clearAndKeepBackground:, OOColor::greenColor, gui, OXZ_GUI_NUM_LISTROWS, OXZ_GUI_ROW_LISTSTART, OXZ_STATE_PICK_INSTALL, OXZ_STATE_PICK_INSTALLED, OXZ_STATE_PICK_REMOVE, processShowInfoKey, GuiDisplayGen::selectedRow, GuiDisplayGen::setColor:forRow:, setOXPURL:, GuiDisplayGen::setSelectedRow:, GuiDisplayGen::setText:forRow:align:, GuiDisplayGen::setTitle:, and showOptionsUpdate.

Referenced by PlayerEntity(OOControlsPrivate)::pollDemoControls:, and processShowInfoKey.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processTextInput:

- (void) processTextInput: (NSString*) input

Definition at line 1311 of file OOOXZManager.m.

1311 :(NSString*)input
1312{
1313 if ([self validateFilter:input]) {
1314 if ([input length] > 0) {
1315 [self setFilter:input];
1316 } // else keep previous filter
1318 [self gui];
1319 }
1320 // else nothing
1321}

References _interfaceState, gui, OXZ_STATE_PICK_INSTALL, and setFilter:.

Referenced by PlayerEntity(OOControlsPrivate)::pollDemoControls:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ refreshTextInput:

- (void) refreshTextInput: (NSString*) input

Definition at line 1323 of file OOOXZManager.m.

1323 :(NSString*)input
1324{
1325 GuiDisplayGen* gui = [UNIVERSE gui];
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]) {
1328 [gui setColor:[OOColor cyanColor] forRow:OXZ_GUI_ROW_INPUT];
1329 } else {
1330 [gui setColor:[OOColor orangeColor] forRow:OXZ_GUI_ROW_INPUT];
1331 }
1332}

References OOColor::cyanColor, gui, OOColor::orangeColor, GuiDisplayGen::setColor:forRow:, and GuiDisplayGen::setText:forRow:align:.

Referenced by PlayerEntity(OOControlsPrivate)::pollDemoControls:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeOptions

- (NSArray *) removeOptions
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 1703 of file OOOXZManager.m.

1704{
1705 NSArray* remList = _filteredList;
1706 if ([remList count] == 0) {
1707 return nil;
1708 }
1709 NSUInteger start = _offset;
1710 if (start >= [remList count]) {
1711 start = 0;
1712 _offset = 0;
1713 }
1714 NSUInteger end = start + OXZ_GUI_NUM_LISTROWS;
1715 if (end > [remList count]) {
1716 end = [remList count];
1717 }
1718 return [remList subarrayWithRange:NSMakeRange(start, end - start)];
1719}

References count, nil, OXZ_GUI_NUM_LISTROWS, and OOOXZManager(NSURLConnectionDataDelegate)::removeOptions.

Referenced by OOOXZManager(NSURLConnectionDataDelegate)::removeOptions, and showRemoveOptions.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeOXZ:

- (BOOL) removeOXZ: (NSUInteger) item
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 1679 of file OOOXZManager.m.

1679 :(NSUInteger)item
1680{
1681 NSArray* remList = _filteredList;
1682 if ([remList count] <= item) {
1683 OOLog(kOOOXZDebugLog, @"Unable to remove item %zu as only %zu in list", item, [remList count]);
1684 return NO;
1685 }
1686 NSString* filename = [[remList objectAtIndex:item] oo_stringForKey:kOOManifestFilePath];
1687 if (filename == nil) {
1688 OOLog(kOOOXZDebugLog, @"Unable to remove item %zu as filename not found", item);
1689 return NO;
1690 }
1691
1692 if (![[NSFileManager defaultManager] oo_removeItemAtPath:filename]) {
1693 OOLog(kOOOXZErrorLog, @"Unable to remove file %@", filename);
1694 return NO;
1695 }
1696 _changesMade = YES;
1697 DESTROY(_managedList); // will need updating
1699 [self gui];
1700 return YES;
1701}

References count, DESTROY, gui, kOOOXZDebugLog, kOOOXZErrorLog, nil, OOLog, and OXZ_STATE_REMOVING.

Referenced by processSelection.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setCurrentDownload:withLabel:

- (void) setCurrentDownload: (NSURLConnection*) download
withLabel: (NSString*) label 
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 531 of file OOOXZManager.m.

531 :(NSURLConnection*)download withLabel:(NSString*)label
532{
533 if (_currentDownload != nil) {
534 [_currentDownload cancel]; // releases via delegate
535 }
536 _currentDownload = [download retain];
538 _currentDownloadName = [label copy];
539}
NSString * _currentDownloadName

References DESTROY, and nil.

Referenced by OOOXZManager(NSURLConnectionDataDelegate)::beginDownload:, and dealloc.

Here is the caller graph for this function:

◆ setFilter:

- (void) setFilter: (NSString*) filter
implementation

Definition at line 364 of file OOOXZManager.m.

364 :(NSString*)filter
365{
367 _currentFilter = [[filter lowercaseString] copy]; // copy retains
368}

References _currentFilter, and DESTROY.

Referenced by processTextInput:.

Here is the caller graph for this function:

◆ setFilteredList:

- (void) setFilteredList: (NSArray*) list
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 358 of file OOOXZManager.m.

358 :(NSArray*)list
359{
361 _filteredList = [list copy]; // copy retains
362}

References DESTROY.

Referenced by gui, OOOXZManager(NSURLConnectionDataDelegate)::processDownloadedOXZ, showOptionsUpdate, and OOOXZManager(NSURLConnectionDataDelegate)::updateAllOXZ.

Here is the caller graph for this function:

◆ setOXPURL:

- (void) setOXPURL: (NSString*) url
implementation

Definition at line 370 of file OOOXZManager.m.

370 :(NSString*)url
371{
373 _currentOXPURL = [[url lowercaseString] copy]; // copy retains
374}
NSString * _currentOXPURL

References _currentOXPURL, and DESTROY.

Referenced by processShowInfoKey.

Here is the caller graph for this function:

◆ setOXZList:

- (void) setOXZList: (NSArray*) list
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 348 of file OOOXZManager.m.

348 :(NSArray*)list
349{
351 if (list != nil) {
352 _oxzList = [[list sortedArrayUsingFunction:oxzSort context:NULL] retain];
353 // needed for update to available versions
355 }
356}

References DESTROY, and nil.

Referenced by init, and OOOXZManager(NSURLConnectionDataDelegate)::processDownloadedManifests.

Here is the caller graph for this function:

◆ setProgressStatus:

- (void) setProgressStatus: (NSString*) new
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 541 of file OOOXZManager.m.

541 :(NSString*)new
542{
544 _progressStatus = [new copy];
545}
NSString * _progressStatus

References DESTROY.

Referenced by init, OOOXZManager(NSURLConnectionDataDelegate)::installOXZ:, OOOXZManager(NSURLConnectionDataDelegate)::processDownloadedOXZ, processSelection, and updateManifests.

Here is the caller graph for this function:

◆ sharedManager

+ (OOOXZManager *) sharedManager

Definition at line 176 of file OOOXZManager.m.

177{
178 // NOTE: assumes single-threaded first access.
179 if (sSingleton == nil)
180 sSingleton = [[self alloc] init];
181 return sSingleton;
182}

References nil, sharedManager, and sSingleton.

Referenced by GameController::applicationDidFinishLaunching:, PlayerEntity(OOControlsPrivate)::pollDemoControls:, ResourceManager::rootPaths, PlayerEntity::setGuiToOXZManager, sharedManager, and ResourceManager::userRootPaths.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ showInstallOptions

- (OOGUIRow) showInstallOptions

Definition at line 1533 of file OOOXZManager.m.

1534{
1535 // shows the current installation options page
1536 OOGUIRow startRow = OXZ_GUI_ROW_LISTPREV;
1537 NSArray* options = [self installOptions];
1538 NSUInteger optCount = [_filteredList count];
1539 GuiDisplayGen* gui = [UNIVERSE gui];
1540 OOGUITabSettings tab_stops;
1541 tab_stops[0] = 0;
1542 tab_stops[1] = 100;
1543 tab_stops[2] = 320;
1544 tab_stops[3] = 400;
1545 [gui setTabStops:tab_stops];
1546
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"),
1551 nil]
1552 forRow:OXZ_GUI_ROW_LISTHEAD];
1553
1554 if (_offset > 0) {
1555 [gui setColor:[OOColor greenColor] forRow:OXZ_GUI_ROW_LISTPREV];
1556 [gui setArray:[NSArray arrayWithObjects:DESC(@"gui-back"), @"", @"", @" <-- ", nil] forRow:OXZ_GUI_ROW_LISTPREV];
1557 [gui setKey:@"_BACK" forRow:OXZ_GUI_ROW_LISTPREV];
1558 } else {
1559 if ([gui selectedRow] == OXZ_GUI_ROW_LISTPREV) {
1560 [gui setSelectedRow:OXZ_GUI_ROW_LISTSTART];
1561 }
1562 [gui setText:@"" forRow:OXZ_GUI_ROW_LISTPREV align:GUI_ALIGN_LEFT];
1563 [gui setKey:GUI_KEY_SKIP forRow:OXZ_GUI_ROW_LISTPREV];
1564 }
1565 if (_offset + 10 < optCount) {
1566 [gui setColor:[OOColor greenColor] forRow:OXZ_GUI_ROW_LISTNEXT];
1567 [gui setArray:[NSArray arrayWithObjects:DESC(@"gui-more"), @"", @"", @" --> ", nil] forRow:OXZ_GUI_ROW_LISTNEXT];
1568 [gui setKey:@"_NEXT" forRow:OXZ_GUI_ROW_LISTNEXT];
1569 } else {
1570 if ([gui selectedRow] == OXZ_GUI_ROW_LISTNEXT) {
1571 [gui setSelectedRow:OXZ_GUI_ROW_LISTSTART];
1572 }
1573 [gui setText:@"" forRow:OXZ_GUI_ROW_LISTNEXT align:GUI_ALIGN_LEFT];
1574 [gui setKey:GUI_KEY_SKIP forRow:OXZ_GUI_ROW_LISTNEXT];
1575 }
1576
1577 // clear any previous longtext
1578 for (NSUInteger i = OXZ_GUI_ROW_LISTSTATUS; i < OXZ_GUI_ROW_INSTALL - 1; i++) {
1579 [gui setText:@"" forRow:i align:GUI_ALIGN_LEFT];
1580 [gui setKey:GUI_KEY_SKIP forRow:i];
1581 }
1582 // and any previous listed entries
1583 for (NSUInteger i = OXZ_GUI_ROW_LISTSTART; i < OXZ_GUI_ROW_LISTNEXT; i++) {
1584 [gui setText:@"" forRow:i align:GUI_ALIGN_LEFT];
1585 [gui setKey:GUI_KEY_SKIP forRow:i];
1586 }
1587
1589 NSDictionary* manifest = nil;
1590 BOOL oxzLineSelected = NO;
1591
1592 foreach (manifest, options) {
1593 NSDictionary* installed = [ResourceManager manifestForIdentifier:[manifest oo_stringForKey:kOOManifestIdentifier]];
1594 NSString* localPath = [[[self installPath] stringByAppendingPathComponent:[manifest oo_stringForKey:kOOManifestIdentifier]] stringByAppendingPathExtension:@"oxz"];
1595 if (installed == nil) {
1596 // check that there's not one just been downloaded
1597 installed = OODictionaryFromFile([localPath stringByAppendingPathComponent:@"manifest.plist"]);
1598 } else {
1599 // check for a more recent download
1600 if ([[NSFileManager defaultManager] fileExistsAtPath:localPath]) {
1601
1602 installed = OODictionaryFromFile([localPath stringByAppendingPathComponent:@"manifest.plist"]);
1603 } else {
1604 // check if this was a managed OXZ which has been deleted
1605 if ([[installed oo_stringForKey:kOOManifestFilePath] hasPrefix:[self installPath]]) {
1606 installed = nil;
1607 }
1608 }
1609 }
1610
1611 NSString* installedVersion = DESC(@"oolite-oxzmanager-version-none");
1612 if (installed != nil) {
1613 installedVersion = [installed oo_stringForKey:kOOManifestVersion defaultValue:DESC(@"oolite-oxzmanager-version-none")];
1614 }
1615
1616 /* If the filter is in use, the available_version key will
1617 * contain the version which can be downloaded. */
1618 [gui setArray:[NSArray arrayWithObjects:
1619 [manifest oo_stringForKey:kOOManifestCategory
1620 defaultValue:DESC(@"oolite-oxzmanager-missing-field")],
1621 [manifest oo_stringForKey:kOOManifestTitle
1622 defaultValue:DESC(@"oolite-oxzmanager-missing-field")],
1623 installedVersion,
1624 [manifest oo_stringForKey:kOOManifestAvailableVersion
1625 defaultValue:[manifest oo_stringForKey:kOOManifestVersion defaultValue:DESC(@"oolite-oxzmanager-version-none")]],
1626 nil]
1627 forRow:row];
1628
1629 [gui setKey:[manifest oo_stringForKey:kOOManifestIdentifier] forRow:row];
1630 /* yellow for installable, orange for dependency issues, grey and unselectable for version issues, white and unselectable for already installed (manually or otherwise) at the current version, red and unselectable for already installed manually at a different version. */
1631 [gui setColor:[self colorForManifest:manifest] forRow:row];
1632
1633 if (row == [gui selectedRow]) {
1634 oxzLineSelected = YES;
1635
1636 [gui setText:[self installStatusForManifest:manifest] forRow:OXZ_GUI_ROW_LISTSTATUS];
1637 [gui setColor:[OOColor greenColor] forRow:OXZ_GUI_ROW_LISTSTATUS];
1638
1639 [gui addLongText:[[[manifest oo_stringForKey:kOOManifestDescription] componentsSeparatedByString:@"\n"] oo_stringAtIndex:0] startingAtRow:OXZ_GUI_ROW_LISTDESC align:GUI_ALIGN_LEFT];
1640
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];
1644 }
1645 NSUInteger size = [manifest oo_unsignedIntForKey:kOOManifestFileSize defaultValue:0];
1646 NSString* updatedDesc = nil;
1647
1648 NSUInteger timestamp = [manifest oo_unsignedIntegerForKey:kOOManifestUploadDate defaultValue:0];
1649 if (timestamp > 0) {
1650 // list of installable OXZs
1651 NSDate* updated = [NSDate dateWithTimeIntervalSince1970:timestamp];
1652
1653 // keep only the first part of the date string description, which should be in YYYY-MM-DD format
1654 updatedDesc = [[[updated description] componentsSeparatedByString:@" "] oo_stringAtIndex:0];
1655
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) {
1658 // list of installed/removable OXZs
1659 [gui setArray:[NSArray arrayWithObjects:DESC(@"oolite-oxzmanager-infoline-size"), [self humanSize:size], nil] forRow:OXZ_GUI_ROW_LISTINFO2];
1660 }
1661 }
1662
1663 row++;
1664 }
1665
1666 if (!oxzLineSelected) {
1668 // installeD
1669 [gui addLongText:OOExpand(DESC(@"oolite-oxzmanager-installed-nonepicked")) startingAtRow:OXZ_GUI_ROW_LISTDESC align:GUI_ALIGN_LEFT];
1670 } else {
1671 // installeR
1672 [gui addLongText:OOExpand(DESC(@"oolite-oxzmanager-installer-nonepicked")) startingAtRow:OXZ_GUI_ROW_LISTDESC align:GUI_ALIGN_LEFT];
1673 }
1674 }
1675
1676 return startRow;
1677}
OOGUITabStop OOGUITabSettings[GUI_MAX_COLUMNS]
@ OXZ_GUI_ROW_LISTSTATUS
void setText:forRow:(NSString *str,[forRow] OOGUIRow row)
void setTabStops:(OOGUITabSettings stops)
void setArray:forRow:(NSArray *arr,[forRow] OOGUIRow row)
voidpf void uLong size
Definition ioapi.h:126

References _interfaceState, _offset, GuiDisplayGen::addLongText:startingAtRow:align:, colorForManifest:, DESC, OOColor::greenColor, gui, humanSize:, installOptions, installPath, installStatusForManifest:, kOOManifestFilePath, ResourceManager::manifestForIdentifier:, nil, OODictionaryFromFile(), OXZ_GUI_ROW_INSTALL, OXZ_GUI_ROW_LISTNEXT, OXZ_GUI_ROW_LISTPREV, OXZ_GUI_ROW_LISTSTART, OXZ_GUI_ROW_LISTSTATUS, OXZ_STATE_PICK_INSTALLED, GuiDisplayGen::setArray:forRow:, GuiDisplayGen::setColor:forRow:, GuiDisplayGen::setKey:forRow:, GuiDisplayGen::setSelectedRow:, GuiDisplayGen::setTabStops:, GuiDisplayGen::setText:forRow:, GuiDisplayGen::setText:forRow:align:, and showInstallOptions.

Referenced by gui, showInstallOptions, and showOptionsUpdate.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ showOptionsNext

- (void) showOptionsNext

Definition at line 1860 of file OOOXZManager.m.

1861{
1862 GuiDisplayGen* gui = [UNIVERSE gui];
1864 if ([gui selectedRow] == OXZ_GUI_ROW_LISTNEXT) {
1865 [self processSelection];
1866 }
1867 }
1868}

References _interfaceState, gui, OXZ_GUI_ROW_LISTNEXT, OXZ_STATE_PICK_INSTALL, OXZ_STATE_PICK_INSTALLED, OXZ_STATE_PICK_REMOVE, processSelection, and showOptionsNext.

Referenced by showOptionsNext.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ showOptionsPrev

- (void) showOptionsPrev

Definition at line 1831 of file OOOXZManager.m.

1832{
1833 GuiDisplayGen* gui = [UNIVERSE gui];
1835 if ([gui selectedRow] == OXZ_GUI_ROW_LISTPREV) {
1836 [self processSelection];
1837 }
1838 }
1839}

References _interfaceState, gui, OXZ_GUI_ROW_LISTPREV, OXZ_STATE_PICK_INSTALL, OXZ_STATE_PICK_INSTALLED, OXZ_STATE_PICK_REMOVE, processSelection, and showOptionsPrev.

Referenced by showOptionsPrev.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ showOptionsUpdate

- (void) showOptionsUpdate

Definition at line 1815 of file OOOXZManager.m.

1816{
1817
1819 [self setFilteredList:[self applyCurrentFilter:_oxzList]];
1820 [self showInstallOptions];
1822 [self setFilteredList:[self applyCurrentFilter:[self managedOXZs]]];
1823 [self showInstallOptions];
1824 } else if (_interfaceState == OXZ_STATE_PICK_REMOVE) {
1825 [self setFilteredList:[self applyCurrentFilter:[self managedOXZs]]];
1826 [self showRemoveOptions];
1827 }
1828 // else nothing necessary
1829}

References _interfaceState, applyCurrentFilter:, managedOXZs, OXZ_STATE_PICK_INSTALL, OXZ_STATE_PICK_INSTALLED, OXZ_STATE_PICK_REMOVE, setFilteredList:, showInstallOptions, showOptionsUpdate, and showRemoveOptions.

Referenced by PlayerEntity(OOControlsPrivate)::pollDemoControls:, processOptionsNext, processOptionsPrev, processShowInfoKey, and showOptionsUpdate.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ showRemoveOptions

- (OOGUIRow) showRemoveOptions

Definition at line 1721 of file OOOXZManager.m.

1722{
1723 // shows the current installation options page
1724 OOGUIRow startRow = OXZ_GUI_ROW_LISTPREV;
1725 NSArray* options = [self removeOptions];
1726 GuiDisplayGen* gui = [UNIVERSE gui];
1727 if (options == nil) {
1728 [gui addLongText:DESC(@"oolite-oxzmanager-nothing-removable") startingAtRow:OXZ_GUI_ROW_PROGRESS align:GUI_ALIGN_LEFT];
1729 return startRow;
1730 }
1731
1732 OOGUITabSettings tab_stops;
1733 tab_stops[0] = 0;
1734 tab_stops[1] = 100;
1735 tab_stops[2] = 400;
1736 [gui setTabStops:tab_stops];
1737
1738 [gui setArray:[NSArray arrayWithObjects:DESC(@"oolite-oxzmanager-heading-category"),
1739 DESC(@"oolite-oxzmanager-heading-title"),
1740 DESC(@"oolite-oxzmanager-heading-version"),
1741 nil]
1742 forRow:OXZ_GUI_ROW_LISTHEAD];
1743 if (_offset > 0) {
1744 [gui setColor:[OOColor greenColor] forRow:OXZ_GUI_ROW_LISTPREV];
1745 [gui setArray:[NSArray arrayWithObjects:DESC(@"gui-back"), @"", @" <-- ", nil] forRow:OXZ_GUI_ROW_LISTPREV];
1746 [gui setKey:@"_BACK" forRow:OXZ_GUI_ROW_LISTPREV];
1747 } else {
1748 if ([gui selectedRow] == OXZ_GUI_ROW_LISTPREV) {
1749 [gui setSelectedRow:OXZ_GUI_ROW_LISTSTART];
1750 }
1751 [gui setText:@"" forRow:OXZ_GUI_ROW_LISTPREV align:GUI_ALIGN_LEFT];
1752 [gui setKey:GUI_KEY_SKIP forRow:OXZ_GUI_ROW_LISTPREV];
1753 }
1754 if (_offset + OXZ_GUI_NUM_LISTROWS < [[self managedOXZs] count]) {
1755 [gui setColor:[OOColor greenColor] forRow:OXZ_GUI_ROW_LISTNEXT];
1756 [gui setArray:[NSArray arrayWithObjects:DESC(@"gui-more"), @"", @" --> ", nil] forRow:OXZ_GUI_ROW_LISTNEXT];
1757 [gui setKey:@"_NEXT" forRow:OXZ_GUI_ROW_LISTNEXT];
1758 } else {
1759 if ([gui selectedRow] == OXZ_GUI_ROW_LISTNEXT) {
1760 [gui setSelectedRow:OXZ_GUI_ROW_LISTSTART];
1761 }
1762 [gui setText:@"" forRow:OXZ_GUI_ROW_LISTNEXT align:GUI_ALIGN_LEFT];
1763 [gui setKey:GUI_KEY_SKIP forRow:OXZ_GUI_ROW_LISTNEXT];
1764 }
1765
1766 // clear any previous longtext
1767 for (NSUInteger i = OXZ_GUI_ROW_LISTDESC; i < OXZ_GUI_ROW_INSTALL - 1; i++) {
1768 [gui setText:@"" forRow:i align:GUI_ALIGN_LEFT];
1769 [gui setKey:GUI_KEY_SKIP forRow:i];
1770 }
1771 // and any previous listed entries
1772 for (NSUInteger i = OXZ_GUI_ROW_LISTSTART; i < OXZ_GUI_ROW_LISTNEXT; i++) {
1773 [gui setText:@"" forRow:i align:GUI_ALIGN_LEFT];
1774 [gui setKey:GUI_KEY_SKIP forRow:i];
1775 }
1776
1778 NSDictionary* manifest = nil;
1779 BOOL oxzSelected = NO;
1780
1781 foreach (manifest, options) {
1782
1783 [gui setArray:[NSArray arrayWithObjects:
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")],
1790 nil]
1791 forRow:row];
1792 NSString* identifier = [manifest oo_stringForKey:kOOManifestIdentifier];
1793 [gui setKey:identifier forRow:row];
1794
1795 [gui setColor:[self colorForManifest:manifest] forRow:row];
1796
1797 if (row == [gui selectedRow]) {
1798 [gui setText:[self installStatusForManifest:manifest] forRow:OXZ_GUI_ROW_LISTSTATUS];
1799 [gui setColor:[OOColor greenColor] forRow:OXZ_GUI_ROW_LISTSTATUS];
1800
1801 [gui addLongText:[[[manifest oo_stringForKey:kOOManifestDescription] componentsSeparatedByString:@"\n"] oo_stringAtIndex:0] startingAtRow:OXZ_GUI_ROW_LISTDESC align:GUI_ALIGN_LEFT];
1802
1803 oxzSelected = YES;
1804 }
1805 row++;
1806 }
1807
1808 if (!oxzSelected) {
1809 [gui addLongText:DESC(@"oolite-oxzmanager-remover-nonepicked") startingAtRow:OXZ_GUI_ROW_LISTDESC align:GUI_ALIGN_LEFT];
1810 }
1811
1812 return startRow;
1813}
@ OXZ_GUI_ROW_LISTDESC

References _offset, GuiDisplayGen::addLongText:startingAtRow:align:, colorForManifest:, count, OOColor::greenColor, gui, installStatusForManifest:, managedOXZs, nil, OXZ_GUI_NUM_LISTROWS, OXZ_GUI_ROW_INSTALL, OXZ_GUI_ROW_LISTDESC, OXZ_GUI_ROW_LISTNEXT, OXZ_GUI_ROW_LISTPREV, OXZ_GUI_ROW_LISTSTART, removeOptions, GuiDisplayGen::setArray:forRow:, GuiDisplayGen::setColor:forRow:, GuiDisplayGen::setKey:forRow:, GuiDisplayGen::setSelectedRow:, GuiDisplayGen::setTabStops:, GuiDisplayGen::setText:forRow:, GuiDisplayGen::setText:forRow:align:, and showRemoveOptions.

Referenced by gui, showOptionsUpdate, and showRemoveOptions.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateAllOXZ

- (BOOL) updateAllOXZ
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 1493 of file OOOXZManager.m.

1494{
1495 [_dependencyStack removeAllObjects];
1497 [self setFilteredList:_oxzList];
1498 NSDictionary* manifest = nil;
1499
1500 foreach (manifest, _oxzList) {
1501 if ([self installableState:manifest] == OXZ_INSTALLABLE_UPDATE) {
1502 OOLog(kOOOXZDebugLog, @"Queuing in for update: %@", manifest);
1503 [_dependencyStack addObject:manifest];
1504 }
1505 }
1506 NSDictionary* first = [_dependencyStack anyObject];
1507 NSString* identifier = [first oo_stringForKey:kOOManifestRelationIdentifier];
1508 NSUInteger item = NSUIntegerMax;
1509 NSDictionary* availableDownload = nil;
1510 foreach (availableDownload, _oxzList) {
1511 if ([[availableDownload oo_stringForKey:kOOManifestIdentifier] isEqualToString:identifier]) {
1512 item = [_oxzList indexOfObject:availableDownload];
1513 break;
1514 }
1515 }
1516 return [self installOXZ:item];
1517}

References installOXZ:, kOOManifestIdentifier, kOOOXZDebugLog, nil, OOLog, OXZ_INSTALLABLE_UPDATE, setFilteredList:, and OOOXZManager(NSURLConnectionDataDelegate)::updateAllOXZ.

Referenced by processSelection, and OOOXZManager(NSURLConnectionDataDelegate)::updateAllOXZ.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateManifests

- (BOOL) updateManifests

Definition at line 547 of file OOOXZManager.m.

548{
549 NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[self dataURL]]];
551 return NO;
552 }
555 [self setProgressStatus:@""];
556
557 return [self beginDownload:request];
558}

References _downloadStatus, _interfaceState, beginDownload:, dataURL, OXZ_DOWNLOAD_NONE, OXZ_DOWNLOAD_STARTED, OXZ_STATE_UPDATING, setProgressStatus:, and updateManifests.

Referenced by processSelection, and updateManifests.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ validateFilter:

- (BOOL) validateFilter: (NSString*) input
implementation

Provided by category OOOXZManager(NSURLConnectionDataDelegate).

Definition at line 513 of file OOOXZManager.m.

513 :(NSString*)input
514{
515 NSString* filter = [input lowercaseString];
516 if (([filter length] == 0) // empty is valid
517 || ([filter isEqualToString:kOOOXZFilterAll])
518 || ([filter isEqualToString:kOOOXZFilterUpdates])
519 || ([filter isEqualToString:kOOOXZFilterInstallable])
520 || ([filter hasPrefix:kOOOXZFilterKeyword] && [filter length] > [kOOOXZFilterKeyword length])
521 || ([filter hasPrefix:kOOOXZFilterAuthor] && [filter length] > [kOOOXZFilterAuthor length])
522 || ([filter hasPrefix:kOOOXZFilterDays] && [[filter substringFromIndex:[kOOOXZFilterDays length]] intValue] > 0)
523 || ([filter hasPrefix:kOOOXZFilterTag] && [filter length] > [kOOOXZFilterTag length])
524 || ([filter hasPrefix:kOOOXZFilterCategory] && [filter length] > [kOOOXZFilterCategory length])) {
525 return YES;
526 }
527
528 return NO;
529}
static NSString *const kOOOXZFilterAll

References kOOOXZFilterAll, kOOOXZFilterAuthor, kOOOXZFilterCategory, kOOOXZFilterDays, kOOOXZFilterInstallable, kOOOXZFilterKeyword, kOOOXZFilterTag, and kOOOXZFilterUpdates.

Member Data Documentation

◆ _changesMade

- (BOOL) _changesMade
private

Definition at line 68 of file OOOXZManager.h.

Referenced by gui, init, isRestarting, and processSelection.

◆ _currentDownload

- (NSURLConnection*) _currentDownload
private

Definition at line 70 of file OOOXZManager.h.

Referenced by cancelUpdate.

◆ _currentDownloadName

- (NSString*) _currentDownloadName
private

Definition at line 71 of file OOOXZManager.h.

◆ _currentFilter

- (NSString*) _currentFilter
private

Definition at line 63 of file OOOXZManager.h.

Referenced by init, and setFilter:.

◆ _currentOXPURL

- (NSString*) _currentOXPURL
private

Definition at line 64 of file OOOXZManager.h.

Referenced by setOXPURL:.

◆ _dependencyStack

- (NSMutableSet*) _dependencyStack
private

Definition at line 84 of file OOOXZManager.h.

Referenced by init.

◆ _downloadAllDependencies

- (BOOL) _downloadAllDependencies
private

Definition at line 79 of file OOOXZManager.h.

Referenced by init, and processSelection.

◆ _downloadExpected

- (NSUInteger) _downloadExpected
private

Definition at line 75 of file OOOXZManager.h.

◆ _downloadProgress

- (NSUInteger) _downloadProgress
private

Definition at line 74 of file OOOXZManager.h.

◆ _downloadStatus

- (OXZDownloadStatus) _downloadStatus
private

Definition at line 73 of file OOOXZManager.h.

Referenced by cancelUpdate, gui, init, isRestarting, processSelection, and updateManifests.

◆ _fileWriter

- (NSFileHandle*) _fileWriter
private

Definition at line 76 of file OOOXZManager.h.

◆ _filteredList

- (NSArray*) _filteredList
private

Definition at line 62 of file OOOXZManager.h.

Referenced by dealloc, and processOptionsNext.

◆ _interfaceShowingOXZDetail

- (BOOL) _interfaceShowingOXZDetail
private

◆ _interfaceState

◆ _item

- (NSUInteger) _item
private

Definition at line 77 of file OOOXZManager.h.

Referenced by processCopyUrlKey, processExtractKey, and processShowInfoKey.

◆ _managedList

- (NSArray*) _managedList
private

Definition at line 61 of file OOOXZManager.h.

Referenced by dealloc, and managedOXZs.

◆ _offset

◆ _oxzList

- (NSArray*) _oxzList
private

Definition at line 60 of file OOOXZManager.h.

Referenced by dealloc, gui, init, managedOXZs, manifests, and processSelection.

◆ _progressStatus

- (NSString*) _progressStatus
private

Definition at line 83 of file OOOXZManager.h.


The documentation for this class was generated from the following files: