Oolite 1.91.0.7745-260117-205bce7
Loading...
Searching...
No Matches
OOOXZManager(NSURLConnectionDataDelegate) Category Reference

Instance Methods

(NSString *) - manifestPath
(NSString *) - downloadPath
(NSString *) - extractionBasePathForIdentifier:andVersion:
(NSString *) - dataURL
(NSString *) - humanSize:
(BOOL) - ensureInstallPath
(BOOL) - beginDownload:
(BOOL) - processDownloadedManifests
(BOOL) - processDownloadedOXZ
(OXZInstallableState- installableState:
(OOColor *) - colorForManifest:
(NSString *) - installStatusForManifest:
(BOOL) - validateFilter:
(void) - setOXZList:
(void) - setFilteredList:
(NSArray *) - applyCurrentFilter:
(void) - setCurrentDownload:withLabel:
(void) - setProgressStatus:
(BOOL) - installOXZ:
(BOOL) - updateAllOXZ
(BOOL) - removeOXZ:
(NSArray *) - installOptions
(NSArray *) - removeOptions
(NSString *) - extractOXZ:
(void) - connection:didFailWithError:
(void) - connection:didReceiveResponse:
(void) - connection:didReceiveData:
(void) - connectionDidFinishLoading:

Detailed Description

Definition at line 126 of file OOOXZManager.m.

Method Documentation

◆ applyCurrentFilter:

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

Extends class OOOXZManager.

Definition at line 414 of file OOOXZManager.m.

414 :(NSArray *)list
415{
416 SEL filterSelector = @selector(applyFilterByNoFilter:);
417 NSString *parameter = nil;
418 if ([_currentFilter isEqualToString:kOOOXZFilterUpdates])
419 {
420 filterSelector = @selector(applyFilterByUpdateRequired:);
421 }
422 else if ([_currentFilter isEqualToString:kOOOXZFilterInstallable])
423 {
424 filterSelector = @selector(applyFilterByInstallable:);
425 }
426 else if ([_currentFilter hasPrefix:kOOOXZFilterKeyword])
427 {
428 filterSelector = @selector(applyFilterByKeyword:keyword:);
429 parameter = [_currentFilter substringFromIndex:[kOOOXZFilterKeyword length]];
430 }
431 else if ([_currentFilter hasPrefix:kOOOXZFilterAuthor])
432 {
433 filterSelector = @selector(applyFilterByAuthor:author:);
434 parameter = [_currentFilter substringFromIndex:[kOOOXZFilterAuthor length]];
435 }
436 else if ([_currentFilter hasPrefix:kOOOXZFilterDays])
437 {
438 filterSelector = @selector(applyFilterByDays:days:);
439 parameter = [_currentFilter substringFromIndex:[kOOOXZFilterDays length]];
440 }
441 else if ([_currentFilter hasPrefix:kOOOXZFilterTag])
442 {
443 filterSelector = @selector(applyFilterByTag:tag:);
444 parameter = [_currentFilter substringFromIndex:[kOOOXZFilterTag length]];
445 }
446 else if ([_currentFilter hasPrefix:kOOOXZFilterCategory])
447 {
448 filterSelector = @selector(applyFilterByCategory:category:);
449 parameter = [_currentFilter substringFromIndex:[kOOOXZFilterCategory length]];
450 }
451
452 NSMutableArray *filteredList = [NSMutableArray arrayWithCapacity:[list count]];
453 NSDictionary *manifest = nil;
454 NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:filterSelector]];
455 [invocation setSelector:filterSelector];
456 [invocation setTarget:self];
457 if (parameter != nil)
458 {
459 [invocation setArgument:&parameter atIndex:3];
460 }
461
462 foreach(manifest, list)
463 {
464 [invocation setArgument:&manifest atIndex:2];
465 [invocation invoke];
466 BOOL filterAccepted = NO;
467 [invocation getReturnValue:&filterAccepted];
468 if (filterAccepted)
469 {
470 [filteredList addObject:manifest];
471 }
472 }
473 // any bad filter that gets this far is also treated as '*'
474 // so don't need to explicitly test for '*' or ''
475 return [[filteredList copy] autorelease];
476}
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

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

Referenced by OOOXZManager::gui, and OOOXZManager::showOptionsUpdate.

Here is the caller graph for this function:

◆ beginDownload:

- (BOOL) beginDownload: (NSMutableURLRequest *) request

Extends class OOOXZManager.

Definition at line 640 of file OOOXZManager.m.

640 :(NSMutableURLRequest *)request
641{
642 NSString *userAgent = [NSString stringWithFormat:@"Oolite/%@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]];
643 [request setValue:userAgent forHTTPHeaderField:@"User-Agent"];
644 NSURLConnection *download = [[NSURLConnection alloc] initWithRequest:request delegate:self];
645 if (download)
646 {
647 _downloadProgress = 0;
648 _downloadExpected = 0;
649 NSString *label = DESC(@"oolite-oxzmanager-download-label-list");
650 if (_interfaceState != OXZ_STATE_UPDATING)
651 {
652 NSDictionary *expectedManifest = nil;
653 expectedManifest = [_filteredList objectAtIndex:_item];
654
655 label = [expectedManifest oo_stringForKey:kOOManifestTitle defaultValue:DESC(@"oolite-oxzmanager-download-label-oxz")];
656 }
657
658 [self setCurrentDownload:download withLabel:label]; // retains it
659 [download release];
660 OOLog(kOOOXZDebugLog,@"Download request received, using %@ and downloading to %@",[request URL],[self downloadPath]);
661 return YES;
662 }
663 else
664 {
665 OOLog(kOOOXZErrorLog,@"Unable to start downloading file at %@",[request URL]);
666 _downloadStatus = OXZ_DOWNLOAD_ERROR;
667 return NO;
668 }
669}
#define OOLog(class, format,...)
Definition OOLogging.h:88
@ OXZ_STATE_UPDATING
@ OXZ_DOWNLOAD_ERROR
static NSString *const kOOOXZErrorLog
static NSString *const kOOOXZDebugLog
#define DESC(key)
Definition Universe.h:850

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

Referenced by installOXZ:, and OOOXZManager::updateManifests.

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

◆ colorForManifest:

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

Extends class OOOXZManager.

Definition at line 1104 of file OOOXZManager.m.

1104 :(NSDictionary *)manifest
1105{
1106 switch ([self installableState:manifest])
1107 {
1109 return [OOColor yellowColor];
1111 return [OOColor cyanColor];
1113 return [OOColor orangeColor];
1115 return [OOColor brownColor];
1117 return [OOColor whiteColor];
1119 return [OOColor redColor];
1121 return [OOColor grayColor];
1123 return [OOColor blueColor];
1124 }
1125 return [OOColor yellowColor]; // never
1126}
@ OXZ_INSTALLABLE_UPDATE
@ OXZ_INSTALLABLE_DEPENDENCIES
@ OXZ_INSTALLABLE_CONFLICTS
@ OXZ_INSTALLABLE_OKAY
@ OXZ_UNINSTALLABLE_VERSION
@ OXZ_UNINSTALLABLE_ALREADY
@ OXZ_UNINSTALLABLE_NOREMOTE
@ OXZ_UNINSTALLABLE_MANUAL
OOColor * cyanColor()
Definition OOColor.m:286
OOColor * orangeColor()
Definition OOColor.m:304
OOColor * redColor()
Definition OOColor.m:268
OOColor * blueColor()
Definition OOColor.m:280
OOColor * grayColor()
Definition OOColor.m:262
OOColor * whiteColor()
Definition OOColor.m:256
OOColor * brownColor()
Definition OOColor.m:316
OOColor * yellowColor()
Definition OOColor.m:292

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 OOOXZManager::showInstallOptions, and OOOXZManager::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 

Extends class OOOXZManager.

Definition at line 2389 of file OOOXZManager.m.

2389 :(NSURLConnection *)connection didFailWithError:(NSError *)error
2390{
2391 _downloadStatus = OXZ_DOWNLOAD_ERROR;
2392 OOLog(kOOOXZErrorLog,@"Error downloading file: %@",[error description]);
2393 [_fileWriter closeFile];
2394 DESTROY(_fileWriter);
2395 DESTROY(_currentDownload);
2396}
#define DESTROY(x)
Definition OOCocoa.h:85

References DESTROY, kOOOXZErrorLog, OOLog, and OXZ_DOWNLOAD_ERROR.

◆ connection:didReceiveData:

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

Extends class OOOXZManager.

Definition at line 2331 of file OOOXZManager.m.

2331 :(NSURLConnection *)connection didReceiveData:(NSData *)data
2332{
2333 OOLog(kOOOXZDebugLog,@"Downloaded %llu bytes",[data length]);
2334 [_fileWriter seekToEndOfFile];
2335 [_fileWriter writeData:data];
2336 _downloadProgress += [data length];
2337 [self gui]; // update GUI
2338#if OOLITE_WINDOWS
2339 /* Irritating fix to issue https://github.com/OoliteProject/oolite/issues/95
2340 *
2341 * The problem is that on MINGW, GNUStep makes all socket streams
2342 * blocking, which causes problems with the run loop. Calling this
2343 * method of the run loop forces it to execute all already
2344 * scheduled items with a time in the past, before any more items
2345 * are placed on it, which means that the main game update gets a
2346 * chance to run.
2347 *
2348 * This stops the interface freezing - and Oolite appearing to
2349 * have stopped responding to the OS - when downloading large
2350 * (>20Mb) OXZ files.
2351 *
2352 * CIM 6 July 2014
2353 */
2354 [[NSRunLoop currentRunLoop] limitDateForMode:NSDefaultRunLoopMode];
2355#endif
2356}

References OOOXZManager::gui, kOOOXZDebugLog, and OOLog.

Here is the call graph for this function:

◆ connection:didReceiveResponse:

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

Extends class OOOXZManager.

Definition at line 2313 of file OOOXZManager.m.

2313 :(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
2314{
2315 _downloadStatus = OXZ_DOWNLOAD_RECEIVING;
2316 OOLog(kOOOXZDebugLog, @"%@", @"Download receiving");
2317 _downloadExpected = [response expectedContentLength];
2318 _downloadProgress = 0;
2319 DESTROY(_fileWriter);
2320 [[NSFileManager defaultManager] createFileAtPath:[self downloadPath] contents:nil attributes:nil];
2321 _fileWriter = [[NSFileHandle fileHandleForWritingAtPath:[self downloadPath]] retain];
2322 if (_fileWriter == nil)
2323 {
2324 // file system is full or read-only or something
2325 OOLog(kOOOXZErrorLog, @"%@", @"Unable to create download file");
2326 [self cancelUpdate];
2327 }
2328}
@ OXZ_DOWNLOAD_RECEIVING

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

Here is the call graph for this function:

◆ connectionDidFinishLoading:

- (void) connectionDidFinishLoading: (NSURLConnection *) connection

Extends class OOOXZManager.

Definition at line 2359 of file OOOXZManager.m.

2359 :(NSURLConnection *)connection
2360{
2361 _downloadStatus = OXZ_DOWNLOAD_COMPLETE;
2362 OOLog(kOOOXZDebugLog, @"%@", @"Download complete");
2363 [_fileWriter synchronizeFile];
2364 [_fileWriter closeFile];
2365 DESTROY(_fileWriter);
2366 DESTROY(_currentDownload);
2367 if (_interfaceState == OXZ_STATE_UPDATING)
2368 {
2369 if (![self processDownloadedManifests])
2370 {
2371 _downloadStatus = OXZ_DOWNLOAD_ERROR;
2372 }
2373 }
2374 else if (_interfaceState == OXZ_STATE_INSTALLING)
2375 {
2376 if (![self processDownloadedOXZ])
2377 {
2378 _downloadStatus = OXZ_DOWNLOAD_ERROR;
2379 }
2380 }
2381 else
2382 {
2383 OOLog(kOOOXZErrorLog,@"Error: download completed in unexpected state %d. This is an internal error - please report it.",_interfaceState);
2384 _downloadStatus = OXZ_DOWNLOAD_ERROR;
2385 }
2386}
@ OXZ_STATE_INSTALLING
@ OXZ_DOWNLOAD_COMPLETE

References DESTROY, kOOOXZDebugLog, kOOOXZErrorLog, OOLog, OXZ_DOWNLOAD_COMPLETE, OXZ_DOWNLOAD_ERROR, OXZ_STATE_INSTALLING, OXZ_STATE_UPDATING, processDownloadedManifests, and processDownloadedOXZ.

Here is the call graph for this function:

◆ dataURL

- (NSString *) dataURL

Extends class OOOXZManager.

Definition at line 355 of file OOOXZManager.m.

356{
357 /* Not expected to be set in general, but might be useful for some users */
358 NSString *url = [[NSUserDefaults standardUserDefaults] stringForKey:kOOOXZDataConfig];
359 if (url != nil)
360 {
361 return url;
362 }
363 return kOOOXZDataURL;
364}
static NSString *const kOOOXZDataURL

References dataURL, kOOOXZDataURL, and nil.

Referenced by dataURL, and OOOXZManager::updateManifests.

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

◆ downloadPath

- (NSString *) downloadPath

Extends class OOOXZManager.

Definition at line 342 of file OOOXZManager.m.

343{
344 if (_interfaceState == OXZ_STATE_UPDATING)
345 {
346 return [[[OOCacheManager sharedCache] cacheDirectoryPathCreatingIfNecessary:YES] stringByAppendingPathComponent:kOOOXZTmpPlistPath];
347 }
348 else
349 {
350 return [[[OOCacheManager sharedCache] cacheDirectoryPathCreatingIfNecessary:YES] stringByAppendingPathComponent:kOOOXZTmpPath];
351 }
352}
NSString * cacheDirectoryPathCreatingIfNecessary:(BOOL create)
OOCacheManager * sharedCache()

References OOCacheManager::cacheDirectoryPathCreatingIfNecessary:, downloadPath, OXZ_STATE_UPDATING, and OOCacheManager::sharedCache.

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

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

◆ ensureInstallPath

- (BOOL) ensureInstallPath

Extends class OOOXZManager.

Definition at line 307 of file OOOXZManager.m.

308{
309 BOOL exists, directory;
310 NSFileManager *fmgr = [NSFileManager defaultManager];
311 NSString *path = [self installPath];
312
313 exists = [fmgr fileExistsAtPath:path isDirectory:&directory];
314
315 if (exists && !directory)
316 {
317 OOLog(kOOOXZErrorLog, @"Expected %@ to be a folder, but it is a file.", path);
318 return NO;
319 }
320 if (!exists)
321 {
322 if (![fmgr oo_createDirectoryAtPath:path attributes:nil])
323 {
324 OOLog(kOOOXZErrorLog, @"Could not create folder %@.", path);
325 return NO;
326 }
327 }
328
329 return YES;
330}

References ensureInstallPath, OOOXZManager::installPath, kOOOXZErrorLog, nil, and OOLog.

Referenced by ensureInstallPath, and processDownloadedOXZ.

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 

Extends class OOOXZManager.

Definition at line 297 of file OOOXZManager.m.

297 :(NSString *)identifier andVersion:(NSString *)version
298{
299 NSString *basePath = [[ResourceManager userRootPaths] lastObject];
300 NSString *rawMainDir = [NSString stringWithFormat:@"%@-%@.off",identifier,version];
301
302 NSCharacterSet *blacklist = [NSCharacterSet characterSetWithCharactersInString:@"'#%^&{}[]/~|\\?<,:\" "];
303 return [[[basePath stringByAppendingPathComponent:[[rawMainDir componentsSeparatedByCharactersInSet:blacklist] componentsJoinedByString:@""]] retain] autorelease];
304}
NSArray * userRootPaths()

References ResourceManager::userRootPaths.

Referenced by extractOXZ:, and OOOXZManager::gui.

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

◆ extractOXZ:

- (NSString *) extractOXZ: (NSUInteger) item

Extends class OOOXZManager.

Definition at line 2178 of file OOOXZManager.m.

2178 :(NSUInteger)item
2179{
2180 NSFileManager *fmgr = [NSFileManager defaultManager];
2181 NSMutableString *extractionLog = [[NSMutableString alloc] init];
2182 NSDictionary *manifest = [_filteredList oo_dictionaryAtIndex:item];
2183 NSString *version = [manifest oo_stringForKey:kOOManifestVersion];
2184 NSString *identifier = [manifest oo_stringForKey:kOOManifestIdentifier];
2185 NSString *path = [self extractionBasePathForIdentifier:identifier andVersion:version];
2186
2187 // OXZ errors should really never happen unless someone is messing
2188 // directly with the managed folder while Oolite is running, but
2189 // it's possible.
2190
2191 NSString *oxzfile = [manifest oo_stringForKey:kOOManifestFilePath];
2192 if (![fmgr fileExistsAtPath:oxzfile])
2193 {
2194 OOLog(kOOOXZErrorLog,@"OXZ %@ could not be found",oxzfile);
2195 [extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-no-original")];
2196 return [extractionLog autorelease];
2197 }
2198 const char* zipname = [oxzfile UTF8String];
2199 unzFile uf = NULL;
2200 uf = unzOpen64(zipname);
2201 if (uf == NULL)
2202 {
2203 OOLog(kOOOXZErrorLog,@"Could not open .oxz at %@ as zip file",path);
2204 [extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-bad-original")];
2205 return [extractionLog autorelease];
2206 }
2207
2208 if ([fmgr fileExistsAtPath:path])
2209 {
2210 OOLog(kOOOXZErrorLog,@"Path %@ already exists",path);
2211 [extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-main-exists")];
2212 unzClose(uf);
2213 return [extractionLog autorelease];
2214 }
2215 if (![fmgr oo_createDirectoryAtPath:path attributes:nil])
2216 {
2217 OOLog(kOOOXZErrorLog,@"Path %@ could not be created",path);
2218 [extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-main-unmakeable")];
2219 unzClose(uf);
2220 return [extractionLog autorelease];
2221 }
2222 [extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-main-created")];
2223 NSUInteger counter = 0;
2224 char rawComponentName[512];
2225 BOOL error = NO;
2226 unz_file_info64 file_info = {0};
2227 if (unzGoToFirstFile(uf) == UNZ_OK)
2228 {
2229 do
2230 {
2231 unzGetCurrentFileInfo64(uf, &file_info,
2232 rawComponentName, 512,
2233 NULL, 0,
2234 NULL, 0);
2235 NSString *componentName = [NSString stringWithUTF8String:rawComponentName];
2236 if ([componentName hasSuffix:@"/"])
2237 {
2238 // folder
2239 if (![fmgr oo_createDirectoryAtPath:[path stringByAppendingPathComponent:componentName] attributes:nil])
2240 {
2241 OOLog(kOOOXZErrorLog,@"Subpath %@ could not be created",componentName);
2242 [extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-sub-failed")];
2243 error = YES;
2244 break;
2245 }
2246 else
2247 {
2248 OOLog(kOOOXZDebugLog,@"Subpath %@ created OK",componentName);
2249 }
2250 }
2251 else
2252 {
2253 // file
2254 // usually folder must now exist, but just in case...
2255 NSString *folder = [[path stringByAppendingPathComponent:componentName] stringByDeletingLastPathComponent];
2256 if ([folder length] > 0 && ![fmgr fileExistsAtPath:folder] && ![fmgr oo_createDirectoryAtPath:folder attributes:nil])
2257 {
2258 OOLog(kOOOXZErrorLog,@"Subpath %@ could not be created",folder);
2259 [extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-sub-failed")];
2260 error = YES;
2261 break;
2262 }
2263
2264
2265 // This is less efficient in memory use than just
2266 // streaming out of the ZIP file onto disk
2267 // but it makes error handling easier
2268 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
2269 NSData *tmp = [NSData oo_dataWithOXZFile:[oxzfile stringByAppendingPathComponent:componentName]];
2270 if (tmp == nil)
2271 {
2272 OOLog(kOOOXZErrorLog,@"Sub file %@ could not be extracted from the OXZ",componentName);
2273 [extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-sub-failed")];
2274 error = YES;
2275 [pool release];
2276 break;
2277 }
2278 else
2279 {
2280 if (![tmp writeToFile:[path stringByAppendingPathComponent:componentName] atomically:YES])
2281 {
2282 OOLog(kOOOXZErrorLog,@"Sub file %@ could not be created",componentName);
2283 [extractionLog appendString:DESC(@"oolite-oxzmanager-extract-log-sub-failed")];
2284 error = YES;
2285 [pool release];
2286 break;
2287 }
2288 else
2289 {
2290 ++counter;
2291 }
2292 }
2293 [pool release];
2294
2295 }
2296 }
2297 while (unzGoToNextFile(uf) == UNZ_OK);
2298 }
2299 unzClose(uf);
2300
2301 if (!error)
2302 {
2303 [extractionLog appendFormat:DESC(@"oolite-oxzmanager-extract-log-num-u-extracted"),counter];
2304 [extractionLog appendFormat:DESC(@"oolite-oxzmanager-extract-log-extracted-to-@"),path];
2305 }
2306
2307 return [extractionLog autorelease];
2308}
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:1130
int ZEXPORT unzGoToFirstFile(unzFile file)
Definition unzip.c:1184
unzFile ZEXPORT unzOpen64(const void *path)
Definition unzip.c:801
int ZEXPORT unzGoToNextFile(unzFile file)
Definition unzip.c:1205
int ZEXPORT unzClose(unzFile file)
Definition unzip.c:811
struct unz_file_info64_s unz_file_info64
voidp unzFile
Definition unzip.h:70
#define UNZ_OK
Definition unzip.h:74

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

Referenced by OOOXZManager::processSelection.

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

◆ humanSize:

- (NSString *) humanSize: (NSUInteger) bytes

Extends class OOOXZManager.

Definition at line 367 of file OOOXZManager.m.

367 :(NSUInteger)bytes
368{
369 if (bytes == 0)
370 {
371 return DESC(@"oolite-oxzmanager-missing-field");
372 }
373 else if (bytes < 1024)
374 {
375 return @"<1 kB";
376 }
377 else if (bytes < 1024*1024)
378 {
379 return [NSString stringWithFormat:@"%llu kB",bytes>>10];
380 }
381 else
382 {
383 return [NSString stringWithFormat:@"%.2f MB",((float)(bytes>>10))/1024];
384 }
385}

References DESC.

Referenced by OOOXZManager::gui, and OOOXZManager::showInstallOptions.

Here is the caller graph for this function:

◆ installableState:

- (OXZInstallableState) installableState: (NSDictionary *) manifest

Extends class OOOXZManager.

Definition at line 1037 of file OOOXZManager.m.

1037 :(NSDictionary *)manifest
1038{
1039 NSString *title = [manifest oo_stringForKey:kOOManifestTitle defaultValue:nil];
1040 NSString *identifier = [manifest oo_stringForKey:kOOManifestIdentifier defaultValue:nil];
1041 /* Check Oolite version */
1042 if (![ResourceManager checkVersionCompatibility:manifest forOXP:title])
1043 {
1045 }
1046 /* Check for current automated install */
1047 NSDictionary *installed = [self installedManifestForIdentifier:identifier];
1048 if (installed == nil)
1049 {
1050 // check for manual install
1051 installed = [ResourceManager manifestForIdentifier:identifier];
1052 }
1053
1054 if (installed != nil)
1055 {
1056 if (![[installed oo_stringForKey:kOOManifestFilePath] hasPrefix:[self installPath]])
1057 {
1058 // installed manually
1060 }
1061 if ([[installed oo_stringForKey:kOOManifestVersion] isEqualToString:[manifest oo_stringForKey:kOOManifestAvailableVersion defaultValue:[manifest oo_stringForKey:kOOManifestVersion]]]
1062 && [[NSFileManager defaultManager] fileExistsAtPath:[installed oo_stringForKey:kOOManifestFilePath]])
1063 {
1064 // installed this exact version already, and haven't
1065 // uninstalled it since entering the manager, and it's
1066 // still available
1068 }
1069 else if ([installed oo_stringForKey:kOOManifestAvailableVersion defaultValue:nil] == nil)
1070 {
1071 // installed, but no remote copy is indexed any more
1073 }
1074 }
1075 /* Check for dependencies being met */
1076 if ([ResourceManager manifestHasConflicts:manifest logErrors:NO])
1077 {
1079 }
1080 if (installed != nil)
1081 {
1082 NSString *availableVersion = [manifest oo_stringForKey:kOOManifestAvailableVersion];
1083 if (availableVersion == nil)
1084 {
1085 availableVersion = [manifest oo_stringForKey:kOOManifestVersion];
1086 }
1087 NSString *installedVersion = [installed oo_stringForKey:kOOManifestVersion];
1088 OOLog(@"version.debug",@"%@ mv:%@ mav:%@",identifier,installedVersion,availableVersion);
1089 if (CompareVersions(ComponentsFromVersionString(installedVersion),ComponentsFromVersionString(availableVersion)) == NSOrderedDescending)
1090 {
1091 // the installed copy is more recent than the server copy
1093 }
1095 }
1096 if ([ResourceManager manifestHasMissingDependencies:manifest logErrors:NO])
1097 {
1099 }
1100 return OXZ_INSTALLABLE_OKAY;
1101}
static NSString *const kOOManifestAvailableVersion
static NSString *const kOOManifestVersion
static NSString *const kOOManifestFilePath
NSArray * ComponentsFromVersionString(NSString *string)
NSComparisonResult CompareVersions(NSArray *version1, NSArray *version2)
NSDictionary * manifestForIdentifier:(NSString *identifier)

References CompareVersions(), ComponentsFromVersionString(), OOOXZManager::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:

◆ installOptions

- (NSArray *) installOptions

Extends class OOOXZManager.

Definition at line 1757 of file OOOXZManager.m.

1758{
1759 NSUInteger start = _offset;
1760 if (start >= [_filteredList count])
1761 {
1762 start = 0;
1763 _offset = 0;
1764 }
1765 NSUInteger end = start + OXZ_GUI_NUM_LISTROWS;
1766 if (end > [_filteredList count])
1767 {
1768 end = [_filteredList count];
1769 }
1770 return [_filteredList subarrayWithRange:NSMakeRange(start,end-start)];
1771}
@ OXZ_GUI_NUM_LISTROWS
unsigned count

References count, installOptions, and OXZ_GUI_NUM_LISTROWS.

Referenced by installOptions, and OOOXZManager::showInstallOptions.

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

◆ installOXZ:

- (BOOL) installOXZ: (NSUInteger) item

Extends class OOOXZManager.

Definition at line 1689 of file OOOXZManager.m.

1689 :(NSUInteger)item
1690{
1691 NSArray *picklist = _filteredList;
1692
1693 if ([picklist count] <= item)
1694 {
1695 return NO;
1696 }
1697 NSDictionary *manifest = [picklist objectAtIndex:item];
1698 _item = item;
1699
1700 if ([self installableState:manifest] >= OXZ_UNINSTALLABLE_ALREADY)
1701 {
1702 OOLog(kOOOXZDebugLog,@"Cannot install %@",manifest);
1703 // can't be installed on this version of Oolite, or already is installed
1704 return NO;
1705 }
1706 NSString *url = [manifest objectForKey:kOOManifestDownloadURL];
1707 if (url == nil)
1708 {
1709 OOLog(kOOOXZErrorLog, @"%@", @"Manifest does not have a download URL - cannot install");
1710 return NO;
1711 }
1712 NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];
1713 [request setHTTPShouldHandleCookies:NO];
1714 if (_downloadStatus != OXZ_DOWNLOAD_NONE)
1715 {
1716 return NO;
1717 }
1718 _downloadStatus = OXZ_DOWNLOAD_STARTED;
1719 _interfaceState = OXZ_STATE_INSTALLING;
1720
1721 [self setProgressStatus:@""];
1722 return [self beginDownload:request];
1723}
@ OXZ_DOWNLOAD_STARTED
@ OXZ_DOWNLOAD_NONE

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

Referenced by OOOXZManager::processSelection, and updateAllOXZ.

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

◆ installStatusForManifest:

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

Extends class OOOXZManager.

Definition at line 1129 of file OOOXZManager.m.

1129 :(NSDictionary *)manifest
1130{
1131 switch ([self installableState:manifest])
1132 {
1134 return DESC(@"oolite-oxzmanager-installable-okay");
1136 return DESC(@"oolite-oxzmanager-installable-update");
1138 return DESC(@"oolite-oxzmanager-installable-depend");
1140 return DESC(@"oolite-oxzmanager-installable-conflicts");
1142 return DESC(@"oolite-oxzmanager-installable-already");
1144 return DESC(@"oolite-oxzmanager-installable-manual");
1146 return DESC(@"oolite-oxzmanager-installable-version");
1148 return DESC(@"oolite-oxzmanager-installable-noremote");
1149 }
1150 return nil; // never
1151}

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 OOOXZManager::showInstallOptions, and OOOXZManager::showRemoveOptions.

Here is the caller graph for this function:

◆ manifestPath

- (NSString *) manifestPath

Extends class OOOXZManager.

Definition at line 333 of file OOOXZManager.m.

334{
335 return [[[OOCacheManager sharedCache] cacheDirectoryPathCreatingIfNecessary:YES] stringByAppendingPathComponent:kOOOXZManifestCache];
336}

References OOCacheManager::cacheDirectoryPathCreatingIfNecessary:, manifestPath, and OOCacheManager::sharedCache.

Referenced by OOOXZManager::init, manifestPath, and processDownloadedManifests.

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

◆ processDownloadedManifests

- (BOOL) processDownloadedManifests

Extends class OOOXZManager.

Definition at line 761 of file OOOXZManager.m.

762{
763 if (_downloadStatus != OXZ_DOWNLOAD_COMPLETE)
764 {
765 return NO;
766 }
767 [self setOXZList:OOArrayFromFile([self downloadPath])];
768 if (_oxzList != nil)
769 {
770 [_oxzList writeToFile:[self manifestPath] atomically:YES];
771 // and clean up the temp file
772 [[NSFileManager defaultManager] oo_removeItemAtPath:[self downloadPath]];
773 // invalidate the managed list
774 DESTROY(_managedList);
775 _interfaceState = OXZ_STATE_TASKDONE;
776 [self gui];
777 return YES;
778 }
779 else
780 {
781 _downloadStatus = OXZ_DOWNLOAD_ERROR;
782 OOLog(kOOOXZErrorLog,@"Downloaded manifest was not a valid plist, has been left in %@",[self downloadPath]);
783 // revert to the old one
784 [self setOXZList:OOArrayFromFile([self manifestPath])];
785 _interfaceState = OXZ_STATE_TASKDONE;
786 [self gui];
787 return NO;
788 }
789}
@ OXZ_STATE_TASKDONE

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

Referenced by connectionDidFinishLoading:, and processDownloadedManifests.

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

◆ processDownloadedOXZ

- (BOOL) processDownloadedOXZ

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.

Extends class OOOXZManager.

Definition at line 792 of file OOOXZManager.m.

793{
794 if (_downloadStatus != OXZ_DOWNLOAD_COMPLETE)
795 {
796 return NO;
797 }
798
799 NSDictionary *downloadedManifest = OODictionaryFromFile([[self downloadPath] stringByAppendingPathComponent:@"manifest.plist"]);
800 if (downloadedManifest == nil)
801 {
802 _downloadStatus = OXZ_DOWNLOAD_ERROR;
803 OOLog(kOOOXZErrorLog,@"Downloaded OXZ does not contain a manifest.plist, has been left in %@",[self downloadPath]);
804 _interfaceState = OXZ_STATE_TASKDONE;
805 [self gui];
806 return NO;
807 }
808 NSDictionary *expectedManifest = nil;
809 expectedManifest = [_filteredList objectAtIndex:_item];
810
811 if (expectedManifest == nil ||
812 (![[downloadedManifest oo_stringForKey:kOOManifestIdentifier] isEqualToString:[expectedManifest oo_stringForKey:kOOManifestIdentifier]]) ||
813 (![[downloadedManifest oo_stringForKey:kOOManifestVersion] isEqualToString:[expectedManifest oo_stringForKey:kOOManifestAvailableVersion defaultValue:[expectedManifest oo_stringForKey:kOOManifestVersion]]])
814 )
815 {
816 _downloadStatus = OXZ_DOWNLOAD_ERROR;
817 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.");
818 _interfaceState = OXZ_STATE_TASKDONE;
819 [self gui];
820 return NO;
821 }
822 // this appears to be the OXZ we expected
823 // filename is going to be identifier.oxz
824 NSString *filename = [[downloadedManifest oo_stringForKey:kOOManifestIdentifier] stringByAppendingString:@".oxz"];
825
826 if (![self ensureInstallPath])
827 {
828 _downloadStatus = OXZ_DOWNLOAD_ERROR;
829 OOLog(kOOOXZErrorLog, @"%@", @"Unable to create installation folder.");
830 _interfaceState = OXZ_STATE_TASKDONE;
831 [self gui];
832 return NO;
833 }
834
835 // delete filename if it exists from OXZ folder
836 NSString *destination = [[self installPath] stringByAppendingPathComponent:filename];
837 [[NSFileManager defaultManager] oo_removeItemAtPath:destination];
838
839 // move the temp file on to it
840 if (![[NSFileManager defaultManager] oo_moveItemAtPath:[self downloadPath] toPath:destination])
841 {
842 _downloadStatus = OXZ_DOWNLOAD_ERROR;
843 OOLog(kOOOXZErrorLog, @"%@", @"Downloaded OXZ could not be installed.");
844 _interfaceState = OXZ_STATE_TASKDONE;
845 [self gui];
846 return NO;
847 }
848 _changesMade = YES;
849 DESTROY(_managedList); // will need updating
850 // do this now to cope with circular dependencies on download
852
865 NSArray *requires = [downloadedManifest oo_arrayForKey:kOOManifestRequiresOXPs defaultValue:nil];
866 if (requires == nil)
867 {
868 // just in case the requirements are only specified in the online copy
869 requires = [expectedManifest oo_arrayForKey:kOOManifestRequiresOXPs defaultValue:nil];
870 }
871 NSDictionary *requirement = nil;
872 NSMutableString *progress = [NSMutableString stringWithCapacity:2048];
873 OOLog(kOOOXZDebugLog,@"Dependency stack has %llu elements",[_dependencyStack count]);
874
875 if ([_dependencyStack count] > 0)
876 {
877 // will remove as iterate, so create a temp copy to iterate over
878 NSSet *tempStack = [NSSet setWithSet:_dependencyStack];
879 foreach (requirement, tempStack)
880 {
881 OOLog(kOOOXZDebugLog,@"Dependency stack: checking %@",[requirement oo_stringForKey:kOOManifestRelationIdentifier]);
882 if (![ResourceManager manifest:downloadedManifest HasUnmetDependency:requirement logErrors:NO]
883 && requires != nil && [requires containsObject:requirement])
884 {
885 // it was unmet, but now it's met
886 [progress appendFormat:DESC(@"oolite-oxzmanager-progress-now-has-@"),[requirement oo_stringForKey:kOOManifestRelationDescription defaultValue:[requirement oo_stringForKey:kOOManifestRelationIdentifier]]];
887 [_dependencyStack removeObject:requirement];
888 OOLog(kOOOXZDebugLog, @"%@", @"Dependency stack: requirement met");
889 } else if ([[requirement oo_stringForKey:kOOManifestRelationIdentifier] isEqualToString:[downloadedManifest oo_stringForKey:kOOManifestIdentifier]]) {
890 // remove the requirement for the just downloaded OXP
891 [_dependencyStack removeObject:requirement];
892 }
893 }
894 }
895 if (requires != nil)
896 {
897 foreach (requirement, requires)
898 {
899 if ([ResourceManager manifest:downloadedManifest HasUnmetDependency:requirement logErrors:NO])
900 {
901 OOLog(kOOOXZDebugLog,@"Dependency stack: adding %@",[requirement oo_stringForKey:kOOManifestRelationIdentifier]);
902 [_dependencyStack addObject:requirement];
903 [progress appendFormat:DESC(@"oolite-oxzmanager-progress-requires-@"),[requirement oo_stringForKey:kOOManifestRelationDescription defaultValue:[requirement oo_stringForKey:kOOManifestRelationIdentifier]]];
904 }
905 }
906 }
907 if ([_dependencyStack count] > 0)
908 {
909 // get an object from the requirements list, and download it
910 // if it can be found
911 BOOL undownloadedRequirement = NO;
912 NSDictionary *availableDownload = nil;
913 BOOL foundDownload = NO;
914 NSUInteger index = 0;
915 NSString *needsIdentifier = nil;
916
917 do
918 {
919 undownloadedRequirement = YES;
920 requirement = [_dependencyStack anyObject];
921 OOLog(kOOOXZDebugLog,@"Dependency stack: next is %@",[requirement oo_stringForKey:kOOManifestRelationIdentifier]);
922
923 if (!_downloadAllDependencies)
924 {
925 [progress appendString:DESC(@"oolite-oxzmanager-progress-get-required")];
926 }
927 needsIdentifier = [requirement oo_stringForKey:kOOManifestRelationIdentifier];
928
929 foreach (availableDownload, _oxzList)
930 {
931 if ([[availableDownload oo_stringForKey:kOOManifestIdentifier] isEqualToString:needsIdentifier])
932 {
933 if ([ResourceManager matchVersions:requirement withVersion:[availableDownload oo_stringForKey:kOOManifestVersion]])
934 {
935 OOLog(kOOOXZDebugLog, @"%@", @"Dependency stack: found download for next item");
936 foundDownload = YES;
937 index = [_oxzList indexOfObject:availableDownload];
938 break;
939 }
940 }
941 }
942
943 if (foundDownload)
944 {
945 if ([self installableState:[_oxzList objectAtIndex:index]] == OXZ_UNINSTALLABLE_ALREADY)
946 {
947 OOLog(kOOOXZDebugLog,@"Dependency stack: %@ is downloaded but not yet loadable, removing from list.",[requirement oo_stringForKey:kOOManifestRelationIdentifier]);
948 // then this has already been downloaded, but
949 // can't be configured yet presumably because
950 // another dependency is still to be loaded
951 [_dependencyStack removeObject:requirement];
952 if ([_dependencyStack count] > 0)
953 {
954 // try again
955 undownloadedRequirement = NO;
956 }
957 else
958 {
959 // this case should probably never happen
960 // is handled below just in case
961 foundDownload = NO;
962 }
963 }
964 }
965 }
966 while (!undownloadedRequirement);
967
968 if (foundDownload)
969 {
970 // must clear filters entirely at this point
971 [self setFilteredList:_oxzList];
972 // then download that item
973 _downloadStatus = OXZ_DOWNLOAD_NONE;
974 if (_downloadAllDependencies)
975 {
976 OOLog(kOOOXZDebugLog,@"Dependency stack: installing %llu from list",index);
977 if (![self installOXZ:index]) {
978 // if a required dependency is somehow uninstallable
979 // e.g. required+maximum version don't match this Oolite
980 [progress appendFormat:DESC(@"oolite-oxzmanager-progress-required-@-not-found"),[requirement oo_stringForKey:kOOManifestRelationDescription defaultValue:[requirement oo_stringForKey:kOOManifestRelationIdentifier]]];
981 [self setProgressStatus:progress];
982 OOLog(kOOOXZErrorLog,@"OXZ dependency %@ could not be found for automatic download.",needsIdentifier);
983 _downloadStatus = OXZ_DOWNLOAD_ERROR;
984 OOLog(kOOOXZErrorLog, @"%@", @"Downloaded OXZ could not be installed.");
985 _interfaceState = OXZ_STATE_TASKDONE;
986 [self gui];
987 return NO;
988 }
989 }
990 else
991 {
992 _interfaceState = OXZ_STATE_DEPENDENCIES;
993 _item = index;
994 }
995 [self setProgressStatus:progress];
996 [self gui];
997 return YES;
998 }
999 // this is probably always the case, see above
1000 else if ([_dependencyStack count] > 0)
1001 {
1002 [progress appendFormat:DESC(@"oolite-oxzmanager-progress-required-@-not-found"),[requirement oo_stringForKey:kOOManifestRelationDescription defaultValue:[requirement oo_stringForKey:kOOManifestRelationIdentifier]]];
1003 [self setProgressStatus:progress];
1004 OOLog(kOOOXZErrorLog,@"OXZ dependency %@ could not be found for automatic download.",needsIdentifier);
1005 _downloadStatus = OXZ_DOWNLOAD_ERROR;
1006 OOLog(kOOOXZErrorLog, @"%@", @"Downloaded OXZ could not be installed.");
1007 _interfaceState = OXZ_STATE_TASKDONE;
1008 [self gui];
1009 return NO;
1010 }
1011 }
1012
1013 [self setProgressStatus:@""];
1014 _interfaceState = OXZ_STATE_TASKDONE;
1015 [_dependencyStack removeAllObjects]; // just in case
1016 _downloadAllDependencies = NO;
1017 [self gui];
1018 return YES;
1019}
static NSString *const kOOManifestRelationIdentifier
static NSString *const kOOManifestIdentifier
@ OXZ_STATE_DEPENDENCIES
NSDictionary * OODictionaryFromFile(NSString *path)
void resetManifestKnowledgeForOXZManager()
const char * filename
Definition ioapi.h:133

References count, DESTROY, downloadPath, ensureInstallPath, OOOXZManager::gui, OOOXZManager::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, processDownloadedOXZ, ResourceManager::resetManifestKnowledgeForOXZManager, OOOXZManager::setFilteredList:, and OOOXZManager::setProgressStatus:.

Referenced by connectionDidFinishLoading:, and processDownloadedOXZ.

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

◆ removeOptions

- (NSArray *) removeOptions

Extends class OOOXZManager.

Definition at line 1978 of file OOOXZManager.m.

1979{
1980 NSArray *remList = _filteredList;
1981 if ([remList count] == 0)
1982 {
1983 return nil;
1984 }
1985 NSUInteger start = _offset;
1986 if (start >= [remList count])
1987 {
1988 start = 0;
1989 _offset = 0;
1990 }
1991 NSUInteger end = start + OXZ_GUI_NUM_LISTROWS;
1992 if (end > [remList count])
1993 {
1994 end = [remList count];
1995 }
1996 return [remList subarrayWithRange:NSMakeRange(start,end-start)];
1997}

References count, nil, OXZ_GUI_NUM_LISTROWS, and removeOptions.

Referenced by removeOptions, and OOOXZManager::showRemoveOptions.

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

◆ removeOXZ:

- (BOOL) removeOXZ: (NSUInteger) item

Extends class OOOXZManager.

Definition at line 1950 of file OOOXZManager.m.

1950 :(NSUInteger)item
1951{
1952 NSArray *remList = _filteredList;
1953 if ([remList count] <= item)
1954 {
1955 OOLog(kOOOXZDebugLog, @"Unable to remove item %lu as only %lu in list", (unsigned long)item, (unsigned long)[remList count]);
1956 return NO;
1957 }
1958 NSString *filename = [[remList objectAtIndex:item] oo_stringForKey:kOOManifestFilePath];
1959 if (filename == nil)
1960 {
1961 OOLog(kOOOXZDebugLog, @"Unable to remove item %lu as filename not found", (unsigned long)item);
1962 return NO;
1963 }
1964
1965 if (![[NSFileManager defaultManager] oo_removeItemAtPath:filename])
1966 {
1967 OOLog(kOOOXZErrorLog, @"Unable to remove file %@", filename);
1968 return NO;
1969 }
1970 _changesMade = YES;
1971 DESTROY(_managedList); // will need updating
1972 _interfaceState = OXZ_STATE_REMOVING;
1973 [self gui];
1974 return YES;
1975}
@ OXZ_STATE_REMOVING

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

Referenced by OOOXZManager::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 

Extends class OOOXZManager.

Definition at line 606 of file OOOXZManager.m.

606 :(NSURLConnection *)download withLabel:(NSString *)label
607{
608 if (_currentDownload != nil)
609 {
610 [_currentDownload cancel]; // releases via delegate
611 }
612 _currentDownload = [download retain];
613 DESTROY(_currentDownloadName);
614 _currentDownloadName = [label copy];
615}

References DESTROY, and nil.

Referenced by beginDownload:, and OOOXZManager::dealloc.

Here is the caller graph for this function:

◆ setFilteredList:

- (void) setFilteredList: (NSArray *) list

Extends class OOOXZManager.

Definition at line 400 of file OOOXZManager.m.

400 :(NSArray *)list
401{
402 DESTROY(_filteredList);
403 _filteredList = [list copy]; // copy retains
404}

References DESTROY.

Referenced by OOOXZManager::gui, processDownloadedOXZ, OOOXZManager::showOptionsUpdate, and updateAllOXZ.

Here is the caller graph for this function:

◆ setOXZList:

- (void) setOXZList: (NSArray *) list

Extends class OOOXZManager.

Definition at line 388 of file OOOXZManager.m.

388 :(NSArray *)list
389{
390 DESTROY(_oxzList);
391 if (list != nil)
392 {
393 _oxzList = [[list sortedArrayUsingFunction:oxzSort context:NULL] retain];
394 // needed for update to available versions
395 DESTROY(_managedList);
396 }
397}

References DESTROY, and nil.

Referenced by OOOXZManager::init, and processDownloadedManifests.

Here is the caller graph for this function:

◆ setProgressStatus:

- (void) setProgressStatus: (NSString *) newStatus

Extends class OOOXZManager.

Definition at line 618 of file OOOXZManager.m.

618 :(NSString *)new
619{
620 DESTROY(_progressStatus);
621 _progressStatus = [new copy];
622}

References DESTROY.

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

Here is the caller graph for this function:

◆ updateAllOXZ

- (BOOL) updateAllOXZ

Extends class OOOXZManager.

Definition at line 1726 of file OOOXZManager.m.

1727{
1728 [_dependencyStack removeAllObjects];
1729 _downloadAllDependencies = YES;
1730 [self setFilteredList:_oxzList];
1731 NSDictionary *manifest = nil;
1732
1733 foreach (manifest,_oxzList)
1734 {
1735 if ([self installableState:manifest] == OXZ_INSTALLABLE_UPDATE)
1736 {
1737 OOLog(kOOOXZDebugLog, @"Queuing in for update: %@", manifest);
1738 [_dependencyStack addObject:manifest];
1739 }
1740 }
1741 NSDictionary *first = [_dependencyStack anyObject];
1742 NSString* identifier = [first oo_stringForKey:kOOManifestRelationIdentifier];
1743 NSUInteger item = NSUIntegerMax;
1744 NSDictionary *availableDownload = nil;
1745 foreach (availableDownload, _oxzList)
1746 {
1747 if ([[availableDownload oo_stringForKey:kOOManifestIdentifier] isEqualToString:identifier])
1748 {
1749 item = [_oxzList indexOfObject:availableDownload];
1750 break;
1751 }
1752 }
1753 return [self installOXZ:item];
1754}

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

Referenced by OOOXZManager::processSelection, and updateAllOXZ.

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

◆ validateFilter:

- (BOOL) validateFilter: (NSString *) input

Extends class OOOXZManager.

Definition at line 585 of file OOOXZManager.m.

585 :(NSString *)input
586{
587 NSString *filter = [input lowercaseString];
588 if (([filter length] == 0) // empty is valid
589 || ([filter isEqualToString:kOOOXZFilterAll])
590 || ([filter isEqualToString:kOOOXZFilterUpdates])
591 || ([filter isEqualToString:kOOOXZFilterInstallable])
592 || ([filter hasPrefix:kOOOXZFilterKeyword] && [filter length] > [kOOOXZFilterKeyword length])
593 || ([filter hasPrefix:kOOOXZFilterAuthor] && [filter length] > [kOOOXZFilterAuthor length])
594 || ([filter hasPrefix:kOOOXZFilterDays] && [[filter substringFromIndex:[kOOOXZFilterDays length]] intValue] > 0)
595 || ([filter hasPrefix:kOOOXZFilterTag] && [filter length] > [kOOOXZFilterTag length])
596 || ([filter hasPrefix:kOOOXZFilterCategory] && [filter length] > [kOOOXZFilterCategory length])
597 )
598 {
599 return YES;
600 }
601
602 return NO;
603}
static NSString *const kOOOXZFilterAll

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


The documentation for this category was generated from the following file: