Changeset 917

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/CPFPerianPrefPaneController.h

    r792 r917  
    5656        IBOutlet NSButton                                       *button_install; 
    5757        IBOutlet NSTextField                            *textField_installStatus; 
    58         IBOutlet NSProgressIndicator            *progress_install; 
    5958         
    6059        IBOutlet NSTextField                            *textField_currentVersion; 
     60        IBOutlet NSTextField                            *textField_updateStatus; 
    6161        IBOutlet NSButton                                       *button_updateCheck; 
    62         IBOutlet NSProgressIndicator            *progress_updateCheck; 
    6362        IBOutlet NSButton                                       *button_autoUpdateCheck; 
    6463         
  • trunk/CPFPerianPrefPaneController.m

    r909 r917  
    401401 
    402402- (void) dealloc { 
     403        [[NSDistributedNotificationCenter defaultCenter] removeObserver:self name:UPDATE_STATUS_NOTIFICATION object:nil]; 
    403404        [perianForumURL release]; 
    404405        [perianDonateURL release]; 
     
    654655                auth = nil; 
    655656         
    656         int tag = 0; 
    657657        componentPath = [[self quickTimeComponentDir:userInstalled] stringByAppendingPathComponent:@"Perian.component"]; 
    658658        if(auth != nil && !userInstalled) 
     
    685685- (IBAction)installUninstall:(id)sender 
    686686{ 
    687         [progress_install startAnimation:sender]; 
    688687        if(installStatus == InstallStatusInstalled) 
    689688                [NSThread detachNewThreadSelector:@selector(uninstall:) toTarget:self withObject:nil]; 
     
    694693- (void)installComplete:(id)sender 
    695694{ 
    696         [progress_install stopAnimation:sender]; 
    697695        [self checkForInstallation]; 
    698696} 
    699697 
    700698#pragma mark Check Updates 
     699- (void)updateCheckStatusChanged:(NSNotification*)notification 
     700{ 
     701        NSString *status = [notification object]; 
     702         
     703        //FIXME localize these 
     704        if ([status isEqualToString:@"Starting"]) { 
     705                [textField_updateStatus setStringValue:@"Checking..."]; 
     706        } else if ([status isEqualToString:@"Error"]) { 
     707                [textField_updateStatus setStringValue:@"Couldn't reach the update server."]; 
     708        } else if ([status isEqualToString:@"NoUpdates"]) { 
     709                [textField_updateStatus setStringValue:@"There are no updates."]; 
     710        } else if ([status isEqualToString:@"NoUpdates"]) { 
     711                [textField_updateStatus setStringValue:@"Updates found!"]; 
     712        } 
     713} 
     714 
    701715- (IBAction)updateCheck:(id)sender  
    702716{ 
    703717        FSRef updateCheckRef; 
    704718         
     719        [[NSDistributedNotificationCenter defaultCenter] removeObserver:self name:UPDATE_STATUS_NOTIFICATION object:nil]; 
     720        [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(updateCheckStatusChanged:) name:UPDATE_STATUS_NOTIFICATION object:nil]; 
    705721        CFPreferencesSetAppValue((CFStringRef)NEXT_RUN_KEY, NULL, perianAppID); 
    706722        CFPreferencesSetAppValue((CFStringRef)MANUAL_RUN_KEY, [NSNumber numberWithBool:YES], perianAppID); 
  • trunk/PerianPrefPane.nib/classes.nib

    r792 r917  
    7373                                <key>popup_outputMode</key> 
    7474                                <string>NSPopUpButton</string> 
    75                                 <key>progress_install</key> 
    76                                 <string>NSProgressIndicator</string> 
    77                                 <key>progress_updateCheck</key> 
    78                                 <string>NSProgressIndicator</string> 
    7975                                <key>slider_ac3DynamicRangeSlider</key> 
    8076                                <string>NSSlider</string> 
     
    8480                                <string>NSTextField</string> 
    8581                                <key>textField_installStatus</key> 
     82                                <string>NSTextField</string> 
     83                                <key>textField_updateStatus</key> 
    8684                                <string>NSTextField</string> 
    8785                                <key>textView_about</key> 
  • trunk/PerianPrefPane.nib/info.nib

    r889 r917  
    44<dict> 
    55        <key>IBFramework Version</key> 
    6         <string>629</string> 
     6        <string>670</string> 
    77        <key>IBLastKnownRelativeProjectPath</key> 
    8         <string>../Perian.xcodeproj</string> 
     8        <string>Perian.xcodeproj</string> 
    99        <key>IBOldestOS</key> 
    1010        <integer>5</integer> 
    1111        <key>IBOpenObjects</key> 
    1212        <array> 
    13                 <integer>133</integer> 
     13                <integer>32</integer> 
    1414        </array> 
    1515        <key>IBSystem Version</key> 
    16         <string>9B18</string> 
     16        <string>9E17</string> 
    1717        <key>targetFramework</key> 
    1818        <string>IBCocoaFramework</string> 
  • trunk/Update Checker Sources/UpdateCheckerAppDelegate.h

    r624 r917  
    1818#define UPDATE_URL_KEY @"UpdateFeedURL" 
    1919#define SKIPPED_VERSION_KEY @"SkippedVersion" 
     20#define UPDATE_STATUS_NOTIFICATION @"org.perian.UpdateCheckStatus" 
    2021#define TIME_INTERVAL_TIL_NEXT_RUN 7*24*60*60 
    2122 
  • 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];      
  • trunk/Update Checker Sources/main.m

    r913 r917  
    1313#define lockPath "/tmp/PerianUpdateLock" 
    1414 
     15static int fp = -1; 
     16 
     17static void deleteLock() 
     18{ 
     19        close(fp); 
     20        unlink(lockPath); 
     21} 
     22 
    1523int main(int argc, char *argv[]) 
    1624{ 
    17         int fp = open(lockPath, O_CREAT | O_EXCL); 
     25        fp = open(lockPath, O_CREAT | O_EXCL); 
    1826        if(fp == -1) 
    1927        { 
     
    3139        if(fp == -1) 
    3240                return 0; 
     41         
     42        atexit(deleteLock); 
    3343 
    3444        int ret = NSApplicationMain(argc,  (const char **) argv); 
    3545         
    36     close(fp); 
    37         unlink(lockPath); 
    38          
    3946        return ret; 
    4047}