Oolite
Loading...
Searching...
No Matches
OOOXZManager.m
Go to the documentation of this file.
1/*
2
3OOOXZManager.m
4
5Responsible for installing and uninstalling OXZs
6
7Oolite
8Copyright (C) 2004-2013 Giles C Williams and contributors
9
10This program is free software; you can redistribute it and/or
11modify it under the terms of the GNU General Public License
12as published by the Free Software Foundation; either version 2
13of the License, or (at your option) any later version.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23MA 02110-1301, USA.
24
25*/
26
27#import "OOOXZManager.h"
28#import "GuiDisplayGen.h"
29#import "MyOpenGLView.h"
33#import "OOCacheManager.h"
35#import "OOColor.h"
36#import "OOPListParsing.h"
37#import "OOStringExpander.h"
38#import "OOStringParsing.h"
39#import "PlayerEntity.h"
40#import "PlayerEntitySound.h"
41#import "ResourceManager.h"
42#import "Universe.h"
43
44#import "unzip.h"
45
47
48/* The URL for the manifest.plist array. */
49/* switching (temporarily maybe) to oolite.space - Nikos 20230507 */
50/*static NSString * const kOOOXZDataURL = @"http://addons.oolite.org/api/1.0/overview";*/
51static NSString* const kOOOXZDataURL = @"https://addons.oolite.space/api/1.0/overview";
52/* The config parameter to use a non-default URL at runtime */
53static NSString* const kOOOXZDataConfig = @"oxz-index-url";
54/* The filename to store the downloaded manifest.plist array */
55static NSString* const kOOOXZManifestCache = @"Oolite-manifests.plist";
56/* The filename to temporarily store the downloaded OXZ. Has an OXZ extension since we might want to read its manifest.plist out of it; */
57static NSString* const kOOOXZTmpPath = @"Oolite-download.oxz";
58/* The filename to temporarily store the downloaded plists. */
59static NSString* const kOOOXZTmpPlistPath = @"Oolite-download.plist";
60
61/* Log file record types */
62static NSString* const kOOOXZErrorLog = @"oxz.manager.error";
63static NSString* const kOOOXZDebugLog = @"oxz.manager.debug";
64
65/* Filter components */
66static NSString* const kOOOXZFilterAll = @"*";
67static NSString* const kOOOXZFilterUpdates = @"u";
68static NSString* const kOOOXZFilterInstallable = @"i";
69static NSString* const kOOOXZFilterKeyword = @"k:";
70static NSString* const kOOOXZFilterAuthor = @"a:";
71static NSString* const kOOOXZFilterCategory = @"c:";
72static NSString* const kOOOXZFilterDays = @"d:";
73static NSString* const kOOOXZFilterTag = @"t:";
74
75typedef enum {
80 // for things to work, _ALREADY must be the first UNINSTALLABLE state
81 // and all the INSTALLABLE ones must be before all the UNINSTALLABLE ones
87
88enum {
112};
113
114NSComparisonResult oxzSort(id m1, id m2, void* context);
115
117
118// protocol was only formalised in 10.7
119@interface OOOXZManager (NSURLConnectionDataDelegate)
120
121- (NSString*)manifestPath;
122- (NSString*)downloadPath;
123- (NSString*)extractionBasePathForIdentifier:(NSString*)identifier andVersion:(NSString*)version;
124- (NSString*)dataURL;
125- (NSString*)humanSize:(NSUInteger)bytes;
126
127- (BOOL)ensureInstallPath;
128
129- (BOOL)beginDownload:(NSMutableURLRequest*)request;
132
133- (OXZInstallableState)installableState:(NSDictionary*)manifest;
134- (OOColor*)colorForManifest:(NSDictionary*)manifest;
135- (NSString*)installStatusForManifest:(NSDictionary*)manifest;
136
137- (BOOL)validateFilter:(NSString*)input;
138
139- (void)setOXZList:(NSArray*)list;
140- (void)setFilteredList:(NSArray*)list;
141- (NSArray*)applyCurrentFilter:(NSArray*)list;
142
143- (void)setCurrentDownload:(NSURLConnection*)download withLabel:(NSString*)label;
144- (void)setProgressStatus:(NSString*)newStatus;
145
146- (BOOL)installOXZ:(NSUInteger)item;
147- (BOOL)updateAllOXZ;
148- (BOOL)removeOXZ:(NSUInteger)item;
149- (NSArray*)installOptions;
150- (NSArray*)removeOptions;
151
152- (NSString*)extractOXZ:(NSUInteger)item;
153
154/* Delegates for URL downloader */
155- (void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error;
156- (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response;
157- (void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data;
158- (void)connectionDidFinishLoading:(NSURLConnection*)connection;
159
160@end
161
162@interface OOOXZManager (OOFilterRules)
163- (BOOL)applyFilterByNoFilter:(NSDictionary*)manifest;
164- (BOOL)applyFilterByUpdateRequired:(NSDictionary*)manifest;
165- (BOOL)applyFilterByInstallable:(NSDictionary*)manifest;
166- (BOOL)applyFilterByKeyword:(NSDictionary*)manifest keyword:(NSString*)keyword;
167- (BOOL)applyFilterByAuthor:(NSDictionary*)manifest author:(NSString*)author;
168- (BOOL)applyFilterByDays:(NSDictionary*)manifest days:(NSString*)days;
169- (BOOL)applyFilterByTag:(NSDictionary*)manifest tag:(NSString*)tag;
170- (BOOL)applyFilterByCategory:(NSDictionary*)manifest category:(NSString*)category;
171
172@end
173
174@implementation OOOXZManager
175
177{
178 // NOTE: assumes single-threaded first access.
179 if (sSingleton == nil)
180 sSingleton = [[self alloc] init];
181 return sSingleton;
182}
183
184- (id)init
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}
203
204- (void)dealloc
205{
206 if (sSingleton == self)
207 sSingleton = nil;
208
209 [self setCurrentDownload:nil withLabel:nil];
213
214 [super dealloc];
215}
216
217/* The install path for OXZs downloaded by
218 * Oolite. Library/ApplicationSupport seems to be the most appropriate
219 * location. */
220- (NSString*)installPath
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}
244
245/* The extract path for OXZs . */
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}
264
265/* Add additional AddOns paths */
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}
276
277- (NSString*)extractionBasePathForIdentifier:(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}
285
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}
307
308- (NSString*)manifestPath
309{
310 return [[[OOCacheManager sharedCache] cacheDirectoryPathCreatingIfNecessary:YES] stringByAppendingPathComponent:kOOOXZManifestCache];
311}
312
313/* Download mechanism could destroy a correct file if it failed
314 * half-way and was downloaded on top of the old one. So this loads it
315 * off to the side a bit */
316- (NSString*)downloadPath
317{
318 if (_interfaceState == OXZ_STATE_UPDATING) {
319 return [[[OOCacheManager sharedCache] cacheDirectoryPathCreatingIfNecessary:YES] stringByAppendingPathComponent:kOOOXZTmpPlistPath];
320 } else {
321 return [[[OOCacheManager sharedCache] cacheDirectoryPathCreatingIfNecessary:YES] stringByAppendingPathComponent:kOOOXZTmpPath];
322 }
323}
324
325- (NSString*)dataURL
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}
334
335- (NSString*)humanSize:(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}
347
348- (void)setOXZList:(NSArray*)list
349{
350 DESTROY(_oxzList);
351 if (list != nil) {
352 _oxzList = [[list sortedArrayUsingFunction:oxzSort context:NULL] retain];
353 // needed for update to available versions
354 DESTROY(_managedList);
355 }
356}
357
358- (void)setFilteredList:(NSArray*)list
359{
360 DESTROY(_filteredList);
361 _filteredList = [list copy]; // copy retains
362}
363
364- (void)setFilter:(NSString*)filter
365{
367 _currentFilter = [[filter lowercaseString] copy]; // copy retains
368}
369
370- (void)setOXPURL:(NSString*)url
371{
373 _currentOXPURL = [[url lowercaseString] copy]; // copy retains
374}
375
376- (NSArray*)applyCurrentFilter:(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}
423
424/*** Start filters ***/
425- (BOOL)applyFilterByNoFilter:(NSDictionary*)manifest
426{
427 return YES;
428}
429
430- (BOOL)applyFilterByUpdateRequired:(NSDictionary*)manifest
431{
432 return ([self installableState:manifest] == OXZ_INSTALLABLE_UPDATE);
433}
434
435- (BOOL)applyFilterByInstallable:(NSDictionary*)manifest
436{
437 return ([self installableState:manifest] < OXZ_UNINSTALLABLE_ALREADY);
438}
439
440- (BOOL)applyFilterByKeyword:(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}
463
464- (BOOL)applyFilterByAuthor:(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}
472
473- (BOOL)applyFilterByDays:(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}
484
485- (BOOL)applyFilterByTag:(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}
501
502- (BOOL)applyFilterByCategory:(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}
510
511/*** End filters ***/
512
513- (BOOL)validateFilter:(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}
530
531- (void)setCurrentDownload:(NSURLConnection*)download withLabel:(NSString*)label
532{
533 if (_currentDownload != nil) {
534 [_currentDownload cancel]; // releases via delegate
535 }
536 _currentDownload = [download retain];
537 DESTROY(_currentDownloadName);
538 _currentDownloadName = [label copy];
539}
540
541- (void)setProgressStatus:(NSString*)new
542{
543 DESTROY(_progressStatus);
544 _progressStatus = [new copy];
545}
546
548{
549 NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[self dataURL]]];
551 return NO;
552 }
555 [self setProgressStatus:@""];
556
557 return [self beginDownload:request];
558}
559
560- (BOOL)beginDownload:(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) {
567 _downloadProgress = 0;
568 _downloadExpected = 0;
569 NSString* label = DESC(@"oolite-oxzmanager-download-label-list");
570 if (_interfaceState != OXZ_STATE_UPDATING) {
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]);
583 _downloadStatus = OXZ_DOWNLOAD_ERROR;
584 return NO;
585 }
586}
587
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}
609
610- (NSArray*)manifests
611{
612 return _oxzList;
613}
614
615- (NSArray*)managedOXZs
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}
659
661{
662 if (_downloadStatus != OXZ_DOWNLOAD_COMPLETE) {
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
671 DESTROY(_managedList);
672 _interfaceState = OXZ_STATE_TASKDONE;
673 [self gui];
674 return YES;
675 } else {
676 _downloadStatus = OXZ_DOWNLOAD_ERROR;
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])];
680 _interfaceState = OXZ_STATE_TASKDONE;
681 [self gui];
682 return NO;
683 }
684}
685
687{
688 if (_downloadStatus != OXZ_DOWNLOAD_COMPLETE) {
689 return NO;
690 }
691
692 NSDictionary* downloadedManifest = OODictionaryFromFile([[self downloadPath] stringByAppendingPathComponent:@"manifest.plist"]);
693 if (downloadedManifest == nil) {
694 _downloadStatus = OXZ_DOWNLOAD_ERROR;
695 OOLog(kOOOXZErrorLog, @"Downloaded OXZ does not contain a manifest.plist, has been left in %@", [self downloadPath]);
696 _interfaceState = OXZ_STATE_TASKDONE;
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]]])) {
704 _downloadStatus = OXZ_DOWNLOAD_ERROR;
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.");
706 _interfaceState = OXZ_STATE_TASKDONE;
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]) {
715 _downloadStatus = OXZ_DOWNLOAD_ERROR;
716 OOLog(kOOOXZErrorLog, @"%@", @"Unable to create installation folder.");
717 _interfaceState = OXZ_STATE_TASKDONE;
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]) {
728 _downloadStatus = OXZ_DOWNLOAD_ERROR;
729 OOLog(kOOOXZErrorLog, @"%@", @"Downloaded OXZ could not be installed.");
730 _interfaceState = OXZ_STATE_TASKDONE;
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
802 if (!_downloadAllDependencies) {
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
841 _downloadStatus = OXZ_DOWNLOAD_NONE;
842 if (_downloadAllDependencies) {
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);
850 _downloadStatus = OXZ_DOWNLOAD_ERROR;
851 OOLog(kOOOXZErrorLog, @"%@", @"Downloaded OXZ could not be installed.");
852 _interfaceState = OXZ_STATE_TASKDONE;
853 [self gui];
854 return NO;
855 }
856 } else {
857 _interfaceState = OXZ_STATE_DEPENDENCIES;
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);
869 _downloadStatus = OXZ_DOWNLOAD_ERROR;
870 OOLog(kOOOXZErrorLog, @"%@", @"Downloaded OXZ could not be installed.");
871 _interfaceState = OXZ_STATE_TASKDONE;
872 [self gui];
873 return NO;
874 }
875 }
876
877 [self setProgressStatus:@""];
878 _interfaceState = OXZ_STATE_TASKDONE;
879 [_dependencyStack removeAllObjects]; // just in case
880 _downloadAllDependencies = NO;
881 [self gui];
882 return YES;
883}
884
885- (NSDictionary*)installedManifestForIdentifier:(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}
896
897- (OXZInstallableState)installableState:(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}
950
951- (OOColor*)colorForManifest:(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}
973
974- (NSString*)installStatusForManifest:(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}
996
997- (void)gui
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}
1194
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}
1210
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}
1300
1302{
1304}
1305
1307{
1309}
1310
1311- (void)processTextInput:(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}
1322
1323- (void)refreshTextInput:(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}
1333
1335{
1338 }
1341 [[UNIVERSE gameView] resetTypedString];
1342 [self gui];
1343 }
1344 // else this key does nothing
1345}
1346
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}
1416
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}
1442
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}
1461
1462- (BOOL)installOXZ:(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]];
1483 if (_downloadStatus != OXZ_DOWNLOAD_NONE) {
1484 return NO;
1485 }
1486 _downloadStatus = OXZ_DOWNLOAD_STARTED;
1487 _interfaceState = OXZ_STATE_INSTALLING;
1488
1489 [self setProgressStatus:@""];
1490 return [self beginDownload:request];
1491}
1492
1494{
1495 [_dependencyStack removeAllObjects];
1496 _downloadAllDependencies = YES;
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}
1518
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}
1532
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}
1678
1679- (BOOL)removeOXZ:(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
1698 _interfaceState = OXZ_STATE_REMOVING;
1699 [self gui];
1700 return YES;
1701}
1702
1703- (NSArray*)removeOptions
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}
1720
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}
1814
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}
1830
1832{
1833 GuiDisplayGen* gui = [UNIVERSE gui];
1835 if ([gui selectedRow] == OXZ_GUI_ROW_LISTPREV) {
1836 [self processSelection];
1837 }
1838 }
1839}
1840
1842{
1844 _offset = 0;
1845 } else {
1847 }
1848 [self showOptionsUpdate];
1849}
1850
1852{
1855 }
1856 [self showOptionsUpdate];
1857 return;
1858}
1859
1861{
1862 GuiDisplayGen* gui = [UNIVERSE gui];
1864 if ([gui selectedRow] == OXZ_GUI_ROW_LISTNEXT) {
1865 [self processSelection];
1866 }
1867 }
1868}
1869
1870- (NSString*)extractOXZ:(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}
1978
1979- (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response
1980{
1981 _downloadStatus = OXZ_DOWNLOAD_RECEIVING;
1982 OOLog(kOOOXZDebugLog, @"%@", @"Download receiving");
1983 _downloadExpected = [response expectedContentLength];
1984 _downloadProgress = 0;
1985 DESTROY(_fileWriter);
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}
1994
1995- (void)connection:(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}
2021
2022- (void)connectionDidFinishLoading:(NSURLConnection*)connection
2023{
2024 _downloadStatus = OXZ_DOWNLOAD_COMPLETE;
2025 OOLog(kOOOXZDebugLog, @"%@", @"Download complete");
2026 [_fileWriter synchronizeFile];
2027 [_fileWriter closeFile];
2028 DESTROY(_fileWriter);
2029 DESTROY(_currentDownload);
2030 if (_interfaceState == OXZ_STATE_UPDATING) {
2031 if (![self processDownloadedManifests]) {
2032 _downloadStatus = OXZ_DOWNLOAD_ERROR;
2033 }
2034 } else if (_interfaceState == OXZ_STATE_INSTALLING) {
2035 if (![self processDownloadedOXZ]) {
2036 _downloadStatus = OXZ_DOWNLOAD_ERROR;
2037 }
2038 } else {
2039 OOLog(kOOOXZErrorLog, @"Error: download completed in unexpected state %d. This is an internal error - please report it.", _interfaceState);
2040 _downloadStatus = OXZ_DOWNLOAD_ERROR;
2041 }
2042}
2043
2044- (void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error
2045{
2046 _downloadStatus = OXZ_DOWNLOAD_ERROR;
2047 OOLog(kOOOXZErrorLog, @"Error downloading file: %@", [error description]);
2048 [_fileWriter closeFile];
2049 DESTROY(_fileWriter);
2050 DESTROY(_currentDownload);
2051}
2052
2053@end
2054
2055/* Sort by category, then title, then version - and that should be unique */
2056NSComparisonResult oxzSort(id m1, id m2, void* context)
2057{
2058 NSComparisonResult result = [[m1 oo_stringForKey:kOOManifestCategory defaultValue:@"zz"] localizedCompare:[m2 oo_stringForKey:kOOManifestCategory defaultValue:@"zz"]];
2059 if (result == NSOrderedSame) {
2060 result = [[m1 oo_stringForKey:kOOManifestTitle defaultValue:@"zz"] localizedCompare:[m2 oo_stringForKey:kOOManifestTitle defaultValue:@"zz"]];
2061 if (result == NSOrderedSame) {
2062 result = [[m2 oo_stringForKey:kOOManifestVersion defaultValue:@"0"] localizedCompare:[m1 oo_stringForKey:kOOManifestVersion defaultValue:@"0"]];
2063 }
2064 }
2065 return result;
2066}
OOGUITabStop OOGUITabSettings[GUI_MAX_COLUMNS]
NSInteger OOGUIRow
#define DESTROY(x)
#define EXPECT_NOT(x)
#define OOLog(class, format,...)
Definition OOLogging.h:84
static NSString *const kOOManifestAvailableVersion
static NSString *const kOOManifestRelationIdentifier
static NSString *const kOOManifestIdentifier
static NSString *const kOOManifestVersion
static NSString *const kOOManifestFilePath
static OONullTexture * sSingleton
@ OXZ_STATE_UPDATING
@ OXZ_STATE_INSTALLING
@ 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_INSTALL
@ OXZ_STATE_PICK_REMOVE
@ OXZ_STATE_EXTRACTDONE
@ OXZ_STATE_MAIN
@ OXZ_STATE_EXTRACT
@ OXZ_DOWNLOAD_RECEIVING
@ OXZ_DOWNLOAD_COMPLETE
@ OXZ_DOWNLOAD_STARTED
@ OXZ_DOWNLOAD_NONE
@ OXZ_DOWNLOAD_ERROR
static NSString *const kOOOXZFilterDays
static NSString *const kOOOXZErrorLog
static NSString *const kOOOXZFilterTag
static NSString *const kOOOXZFilterKeyword
OXZInstallableState
@ OXZ_INSTALLABLE_UPDATE
@ OXZ_INSTALLABLE_DEPENDENCIES
@ OXZ_INSTALLABLE_CONFLICTS
@ OXZ_INSTALLABLE_OKAY
@ OXZ_UNINSTALLABLE_VERSION
@ OXZ_UNINSTALLABLE_ALREADY
@ OXZ_UNINSTALLABLE_NOREMOTE
@ OXZ_UNINSTALLABLE_MANUAL
@ OXZ_GUI_ROW_CANCEL
@ OXZ_GUI_ROW_PROGRESS
@ OXZ_GUI_ROW_FILTERHELP
@ OXZ_GUI_ROW_FIRSTRUN
@ OXZ_GUI_NUM_LISTROWS
@ OXZ_GUI_ROW_LISTINFO2
@ OXZ_GUI_ROW_REMOVE
@ OXZ_GUI_ROW_LISTFILTER
@ OXZ_GUI_ROW_EXIT
@ OXZ_GUI_ROW_INSTALL
@ OXZ_GUI_ROW_FILTERCURRENT
@ OXZ_GUI_ROW_LISTSTATUS
@ OXZ_GUI_ROW_INSTALLED
@ OXZ_GUI_ROW_LISTINFO1
@ OXZ_GUI_ROW_LISTDESC
@ OXZ_GUI_ROW_INPUT
@ OXZ_GUI_ROW_UPDATE_ALL
@ OXZ_GUI_ROW_PROCEED
@ OXZ_GUI_ROW_LISTHEAD
@ OXZ_GUI_ROW_LISTSTART
@ OXZ_GUI_ROW_LISTPREV
@ OXZ_GUI_ROW_LISTNEXT
@ OXZ_GUI_ROW_UPDATE
static NSString *const kOOOXZManifestCache
static NSString *const kOOOXZFilterUpdates
static NSString *const kOOOXZFilterAll
static NSString *const kOOOXZFilterCategory
static NSString *const kOOOXZFilterInstallable
static NSString *const kOOOXZTmpPlistPath
static NSString *const kOOOXZFilterAuthor
NSComparisonResult oxzSort(id m1, id m2, void *context)
static NSString *const kOOOXZDataURL
static NSString *const kOOOXZTmpPath
static NSString *const kOOOXZDataConfig
static NSString *const kOOOXZDebugLog
NSDictionary * OODictionaryFromFile(NSString *path)
unsigned count
return nil
NSArray * ComponentsFromVersionString(NSString *string)
NSComparisonResult CompareVersions(NSArray *version1, NSArray *version2)
#define DESC(key)
Definition Universe.h:832
BOOL setSelectedRow:(OOGUIRow row)
OOGUIRow addLongText:startingAtRow:align:(NSString *str,[startingAtRow] OOGUIRow row,[align] OOGUIAlignment alignment)
void setText:forRow:(NSString *str,[forRow] OOGUIRow row)
void setText:forRow:align:(NSString *str,[forRow] OOGUIRow row,[align] OOGUIAlignment alignment)
void clearAndKeepBackground:(BOOL keepBackground)
OOGUIRow selectedRow
void setSelectableRange:(NSRange range)
void setColor:forRow:(OOColor *color,[forRow] OOGUIRow row)
void setTitle:(NSString *str)
void setTabStops:(OOGUITabSettings stops)
void setArray:forRow:(NSArray *arr,[forRow] OOGUIRow row)
void setKey:forRow:(NSString *str,[forRow] OOGUIRow row)
NSString * cacheDirectoryPathCreatingIfNecessary:(BOOL create)
OOCacheManager * sharedCache()
OOColor * cyanColor()
Definition OOColor.m:274
OOColor * orangeColor()
Definition OOColor.m:289
OOColor * redColor()
Definition OOColor.m:259
OOColor * greenColor()
Definition OOColor.m:264
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
void setProgressStatus:(NSString *new)
NSUInteger _item
NSArray * _managedList
BOOL _downloadAllDependencies
OOGUIRow showRemoveOptions()
NSArray * installOptions()
NSDictionary * installedManifestForIdentifier:(NSString *identifier)
NSURLConnection * _currentDownload
void setFilteredList:(NSArray *list)
NSArray * removeOptions()
void processOptionsNext()
NSString * extractOXZ:(NSUInteger item)
NSUInteger _offset
void processCopyUrlKey()
NSArray * managedOXZs()
NSString * extractionBasePathForIdentifier:andVersion:(NSString *identifier, [andVersion] NSString *version)
void setFilter:(NSString *filter)
void processFilterKey()
void setOXPURL:(NSString *url)
NSArray * _filteredList
void processSelection()
NSString * installPath()
NSString * _currentFilter
OXZDownloadStatus _downloadStatus
NSString * manifestPath()
void setCurrentDownload:withLabel:(NSURLConnection *download, [withLabel] NSString *label)
void showOptionsUpdate()
NSArray * applyCurrentFilter:(NSArray *list)
NSArray * manifests()
NSString * humanSize:(NSUInteger bytes)
BOOL updateManifests()
void processOptionsPrev()
BOOL installOXZ:(NSUInteger item)
BOOL _interfaceShowingOXZDetail
NSString * installStatusForManifest:(NSDictionary *manifest)
void setOXZList:(NSArray *list)
NSString * downloadPath()
NSString * _currentOXPURL
OOColor * colorForManifest:(NSDictionary *manifest)
BOOL isAcceptingGUIInput()
void processExtractKey()
NSString * extractAddOnsPath()
NSMutableSet * _dependencyStack
OOOXZManager * sharedManager()
BOOL beginDownload:(NSMutableURLRequest *request)
OXZInterfaceState _interfaceState
BOOL removeOXZ:(NSUInteger item)
NSString * dataURL()
BOOL isAcceptingTextInput()
OOGUIRow showInstallOptions()
void processShowInfoKey()
NSArray * additionalAddOnsPaths()
NSArray * _oxzList
void resetManifestKnowledgeForOXZManager()
NSDictionary * manifestForIdentifier:(NSString *identifier)
NSArray * userRootPaths()
voidpf void uLong size
Definition ioapi.h:126
const char * filename
Definition ioapi.h:125
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