Show
Ignore:
Timestamp:
07/29/08 16:35:01 (4 months ago)
Author:
astrange
Message:

Delete progress indicators from the prefpane, they're ugly and pointless.
Get rid of alert panels in the update checker and use IPC to show them in the prefpane instead.
Fix the update checker never cleaning up its locks.
Synchronize user defaults more often since it seems necessary.
Delete code for not running too often in the update checker, it's a duplicate of the same more-maintained code in Perian.

This requires merging the nib into release branch again...

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Update Checker Sources/UpdateCheckerAppDelegate.m

    r913 r917  
    3535        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
    3636        lastRunDate = [[defaults objectForKey:NEXT_RUN_KEY] retain]; 
    37         if (lastRunDate == nil || [lastRunDate laterDate:[NSDate date]] != lastRunDate) { 
    38                 //this means we should in fact run 
    39                 [defaults setObject:[NSDate dateWithTimeIntervalSinceNow:TIME_INTERVAL_TIL_NEXT_RUN] forKey:NEXT_RUN_KEY]; 
    40                 manualRun = [defaults boolForKey:MANUAL_RUN_KEY]; 
    41                 [defaults removeObjectForKey:MANUAL_RUN_KEY]; 
    42                 [self doUpdateCheck]; 
    43         } else { 
    44                 //another instance was already started and therefore we don't need to do this again 
    45                 [[NSApplication sharedApplication] terminate:self]; 
    46         } 
     37         
     38        [defaults setObject:[NSDate dateWithTimeIntervalSinceNow:TIME_INTERVAL_TIL_NEXT_RUN] forKey:NEXT_RUN_KEY]; 
     39        manualRun = [defaults boolForKey:MANUAL_RUN_KEY]; 
     40        [defaults removeObjectForKey:MANUAL_RUN_KEY]; 
     41        [defaults synchronize]; 
     42        [self doUpdateCheck]; 
    4743} 
    4844 
     
    5652        updateUrlString = [[updateUrlString substringToIndex:[updateUrlString length]-4] stringByAppendingFormat:@"-%@.xml", betaAppcastUrl]; 
    5753#endif 
     54        if(manualRun) 
     55                [[NSDistributedNotificationCenter defaultCenter] postNotificationName:UPDATE_STATUS_NOTIFICATION object:@"Starting"]; 
    5856         
    5957        SUAppcast *appcast = [[SUAppcast alloc] init]; 
     
    8179    NSString *panePath = [[[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] stringByDeletingLastPathComponent]; 
    8280        updateAvailable = (updateAvailable && (SUStandardVersionComparison([latest fileVersion], [[NSBundle bundleWithPath:panePath] objectForInfoDictionaryKey:@"CFBundleVersion"]) == NSOrderedAscending)); 
     81         
     82        if (![panePath isEqualToString:@"Perian.prefPane"]) { 
     83                NSLog(@"The update checker needs to be run from inside the preference pane, quitting..."); 
     84                updateAvailable = 0; 
     85        } 
     86         
    8387        NSString *skippedVersion = [[NSUserDefaults standardUserDefaults] objectForKey:SKIPPED_VERSION_KEY]; 
    8488        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
    8589        if (updateAvailable && (!skippedVersion ||  
    8690                (skippedVersion && ![skippedVersion isEqualToString:[latest versionString]]))) { 
     91                if(manualRun) 
     92                        [[NSDistributedNotificationCenter defaultCenter] postNotificationName:UPDATE_STATUS_NOTIFICATION object:@"YesUpdates"]; 
    8793                [self showUpdatePanelForItem:latest]; 
    8894        } else { 
    8995                if(manualRun) 
    90                         NSRunAlertPanel(SULocalizedString(@"No Update Found!", nil), SULocalizedString(@"Your copy of Perian is up to date", nil), nil, nil, nil)
     96                        [[NSDistributedNotificationCenter defaultCenter] postNotificationName:UPDATE_STATUS_NOTIFICATION object:@"NoUpdates"]
    9197                [[NSApplication sharedApplication] terminate:self]; 
    9298        } 
     
    99105        [self updateFailed]; 
    100106        if(manualRun) 
    101                 [self showUpdateErrorAlertWithInfo:SULocalizedString(@"An error occurred while trying to load Perian's version info. Please try again later.", nil)]; 
     107                [[NSDistributedNotificationCenter defaultCenter] postNotificationName:UPDATE_STATUS_NOTIFICATION object:@"Error"]; 
    102108    [appcast release]; 
    103109        [[NSApplication sharedApplication] terminate:self];