Changeset 49

Show
Ignore:
Timestamp:
05/10/05 11:08:59 (4 years ago)
Author:
kevin
Message:

Make UpdateController? thread-safe

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/SSHKeychain.xcode/project.pbxproj

    r46 r49  
    5050                        }; 
    5151                }; 
     52                0A3310650830A68B00A9B20E = { 
     53                        explicitFileType = text.xml; 
     54                        fileEncoding = 4; 
     55                        isa = PBXFileReference; 
     56                        path = version.plist; 
     57                        refType = 4; 
     58                        sourceTree = "<group>"; 
     59                }; 
     60                0A3310660830A68B00A9B20E = { 
     61                        fileRef = 0A3310650830A68B00A9B20E; 
     62                        isa = PBXBuildFile; 
     63                        settings = { 
     64                        }; 
     65                }; 
    5266                0A5AA8A0075F2CBD007668AB = { 
    5367                        fileEncoding = 4; 
     
    309323                                CCC9E27606A58DB600422E9E, 
    310324                                CCC9E27806A58DB600422E9E, 
     325                                0A3310650830A68B00A9B20E, 
    311326                                CCC9E27A06A58DB600422E9E, 
    312327                                CCC9E27C06A58DB600422E9E, 
     
    501516                                0A925563075F22B800B98A2B, 
    502517                                0A33105A0830A54500A9B20E, 
     518                                0A3310660830A68B00A9B20E, 
    503519                        ); 
    504520                        isa = PBXResourcesBuildPhase; 
  • trunk/UpdateController.m

    r42 r49  
    22 
    33#include "SSHKeychain_Prefix.pch" 
    4  
    5 NSString *RemoteVersionURL = @"http://www.sshkeychain.org/latestversion.xml"; 
    64 
    75UpdateController *sharedUpdateController; 
     
    4139- (void)_checkForUpdatesWithWarnings:(NSNumber *)warnings 
    4240{ 
     41        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
     42        NSString *versionPath = [[NSBundle mainBundle] pathForResource:@"version" ofType:@"plist"]; 
     43        NSDictionary *versionDict = [NSDictionary dictionaryWithContentsOfFile:versionPath]; 
     44        NSString *remoteVersionURL = [versionDict objectForKey:@"RemoteVersionURL"]; 
     45        NSDictionary *remoteVersionInfo; 
     46 
     47        remoteVersionInfo = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:remoteVersionURL]]; 
     48 
     49        NSMethodSignature *methodSig = [self methodSignatureForSelector:@selector(_processVersionInfo:withWarnings:)]; 
     50        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSig]; 
     51        [invocation setSelector:@selector(_processVersionInfo:withWarnings:)]; 
     52        [invocation setArgument:&remoteVersionInfo atIndex:2]; 
     53        [invocation setArgument:&warnings atIndex:3]; 
     54        [invocation retainArguments]; 
     55        [invocation performSelectorOnMainThread:@selector(invokeWithTarget:) withObject:self waitUntilDone:NO]; 
     56         
     57        [pool release]; 
     58} 
     59 
     60- (void)_processVersionInfo:(NSDictionary *)remoteVersionInfo withWarnings:(NSNumber *)warnings 
     61{ 
    4362        NSString *latestVersion, *currentVersion; 
    44         NSDictionary *remoteVersionInfo; 
    4563        NSURL *downloadURL, *changesURL; 
    4664        int r; 
    47         NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
    48  
    49         remoteVersionInfo = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:RemoteVersionURL]]; 
    50  
     65         
    5166        if(!remoteVersionInfo) 
    5267        { 
     
    5671                                 andMessage:local(@"FailedToRetrieveXMLVersionInfo")]; 
    5772                } 
    58  
    59                 [pool release]; 
    6073                return; 
    6174        } 
     
    107120        } 
    108121 
    109         [pool release]; 
    110  
    111122        return; 
    112123}