Changeset 0c9b2d28611409caa44eafff14e701168785fe99
- Timestamp:
- 25/02/08 01:28:43 (8 months ago)
- git-parent:
- Files:
-
- extras/package/macosx/Resources/English.lproj/Update.nib/classes.nib (modified) (1 diff)
- extras/package/macosx/Resources/English.lproj/Update.nib/info.nib (modified) (2 diffs)
- extras/package/macosx/Resources/English.lproj/Update.nib/keyedobjects.nib (modified) (previous)
- modules/gui/macosx/intf.m (modified) (4 diffs)
- modules/gui/macosx/update.h (modified) (5 diffs)
- modules/gui/macosx/update.m (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
extras/package/macosx/Resources/English.lproj/Update.nib/classes.nib
r2e888fd r0c9b2d2 1 { 2 IBClasses = ( 3 {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, 4 { 5 ACTIONS = {changeCheckUpdateOnStartup = id; download = id; okay = id; }; 6 CLASS = VLCUpdate; 7 LANGUAGE = ObjC; 8 OUTLETS = { 9 "o_bar_checking" = id; 10 "o_btn_DownloadNow" = id; 11 "o_btn_okay" = id; 12 "o_chk_updateOnStartup" = id; 13 "o_fld_currentVersionAndSize" = id; 14 "o_fld_releaseNote" = id; 15 "o_fld_status" = id; 16 "o_update_window" = id; 17 }; 18 SUPERCLASS = NSObject; 19 } 20 ); 21 IBVersion = 1; 22 } 1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 3 <plist version="1.0"> 4 <dict> 5 <key>IBClasses</key> 6 <array> 7 <dict> 8 <key>CLASS</key> 9 <string>FirstResponder</string> 10 <key>LANGUAGE</key> 11 <string>ObjC</string> 12 <key>SUPERCLASS</key> 13 <string>NSObject</string> 14 </dict> 15 <dict> 16 <key>ACTIONS</key> 17 <dict> 18 <key>changeCheckUpdateOnStartup</key> 19 <string>id</string> 20 <key>download</key> 21 <string>id</string> 22 <key>okay</key> 23 <string>id</string> 24 </dict> 25 <key>CLASS</key> 26 <string>VLCUpdate</string> 27 <key>LANGUAGE</key> 28 <string>ObjC</string> 29 <key>OUTLETS</key> 30 <dict> 31 <key>o_bar_checking</key> 32 <string>id</string> 33 <key>o_btn_DownloadNow</key> 34 <string>id</string> 35 <key>o_btn_okay</key> 36 <string>id</string> 37 <key>o_chk_updateOnStartup</key> 38 <string>id</string> 39 <key>o_fld_currentVersion</key> 40 <string>id</string> 41 <key>o_fld_releaseNote</key> 42 <string>id</string> 43 <key>o_fld_status</key> 44 <string>id</string> 45 <key>o_update_window</key> 46 <string>id</string> 47 </dict> 48 <key>SUPERCLASS</key> 49 <string>NSObject</string> 50 </dict> 51 </array> 52 <key>IBVersion</key> 53 <string>1</string> 54 </dict> 55 </plist> extras/package/macosx/Resources/English.lproj/Update.nib/info.nib
r2e888fd r0c9b2d2 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">2 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 3 3 <plist version="1.0"> 4 4 <dict> 5 <key>IBDocumentLocation</key>6 <string>16 51 356 240 0 0 1280 778 </string>7 5 <key>IBFramework Version</key> 8 <string>446.1</string> 6 <string>629</string> 7 <key>IBOldestOS</key> 8 <integer>5</integer> 9 9 <key>IBOpenObjects</key> 10 10 <array> … … 12 12 </array> 13 13 <key>IBSystem Version</key> 14 <string>8P2137</string> 14 <string>9C31</string> 15 <key>targetFramework</key> 16 <string>IBCocoaFramework</string> 15 17 </dict> 16 18 </plist> modules/gui/macosx/intf.m
rf46398c r0c9b2d2 32 32 #include <string.h> 33 33 #include <vlc_keys.h> 34 35 #ifdef HAVE_CONFIG_H 36 # include "config.h" 37 #endif 34 38 35 39 #import "intf.h" … … 421 425 o_sfilters = nil; 422 426 #ifdef UPDATE_CHECK 423 //FIXMEo_update = [[VLCUpdate alloc] init];427 o_update = [[VLCUpdate alloc] init]; 424 428 #endif 425 429 … … 866 870 nib_update_loaded = [NSBundle loadNibNamed:@"Update" owner:self]; 867 871 868 // FIXME 869 //if([o_update shouldCheckForUpdate]) 870 // [NSThread detachNewThreadSelector:@selector(checkForUpdate) toTarget:o_update withObject:NULL]; 872 if([o_update shouldCheckForUpdate]) 873 [NSThread detachNewThreadSelector:@selector(checkForUpdate) toTarget:o_update withObject:NULL]; 871 874 #endif 872 875 … … 2020 2023 if( !nib_update_loaded ) 2021 2024 nib_update_loaded = [NSBundle loadNibNamed:@"Update" owner:self]; 2022 2023 2025 [o_update showUpdateWindow]; 2026 #else 2027 msg_Err( VLCIntf, "Updates checking was not enabled in this build" ); 2024 2028 #endif 2025 2029 } modules/gui/macosx/update.h
r48c2ac8 r0c9b2d2 2 2 * update.h: MacOS X Check-For-Update window 3 3 ***************************************************************************** 4 * Copyright (C) 2005-2007the VideoLAN team4 * Copyright © 2005-2008 the VideoLAN team 5 5 * $Id$ 6 6 * 7 7 * Authors: Felix Kühne <fkuehne@users.sf.net> 8 * Rafaël Carré <funman@videolanorg> 8 9 * 9 10 * This program is free software; you can redistribute it and/or modify … … 22 23 *****************************************************************************/ 23 24 25 #ifdef HAVE_CONFIG_H 26 # include "config.h" 27 #endif 28 24 29 #ifdef UPDATE_CHECK 25 30 #import <Cocoa/Cocoa.h> … … 31 36 IBOutlet id o_btn_okay; 32 37 IBOutlet id o_fld_releaseNote; 33 IBOutlet id o_fld_source; 34 IBOutlet id o_fld_currentVersionAndSize; 38 IBOutlet id o_fld_currentVersion; 35 39 IBOutlet id o_fld_status; 36 40 IBOutlet id o_update_window; … … 38 42 IBOutlet id o_chk_updateOnStartup; 39 43 40 NSString * o_urlOfBinary;41 44 update_t * p_u; 42 intf_thread_t * p_intf;45 vlc_bool_t b_checked; 43 46 } 44 47 … … 50 53 51 54 - (void)showUpdateWindow; 52 - (void)initInterface;53 55 - (void)checkForUpdate; 56 - (void)updateManagement: (vlc_bool_t) b_success; 54 57 - (void)performDownload:(NSString *)path; 55 58 modules/gui/macosx/update.m
r48c2ac8 r0c9b2d2 2 2 * update.m: MacOS X Check-For-Update window 3 3 ***************************************************************************** 4 * Copyright (C) 2005-2007the VideoLAN team4 * Copyright © 2005-2008 the VideoLAN team 5 5 * $Id$ 6 6 * 7 7 * Authors: Felix Kühne <fkuehne@users.sf.net> 8 * Rafaël Carré <funman@videolanorg> 8 9 * 9 10 * This program is free software; you can redistribute it and/or modify … … 22 23 *****************************************************************************/ 23 24 24 25 /***************************************************************************** 26 * Note: the code used to communicate with VLC's core was inspired by 27 * ../wxwidgets/dialogs/updatevlc.cpp, written by Antoine Cellerier. 28 *****************************************************************************/ 25 #ifdef HAVE_CONFIG_H 26 # include "config.h" 27 #endif 29 28 30 29 #ifdef UPDATE_CHECK … … 58 57 } else { 59 58 _o_sharedInstance = [super init]; 59 b_checked = VLC_FALSE; 60 61 /* clean the interface */ 62 [o_fld_releaseNote setString: @""]; 63 [o_fld_currentVersion setString: @""]; 64 /* translate strings to the user's language */ 65 [o_update_window setTitle: _NS("Check for Updates")]; 66 [o_btn_DownloadNow setTitle: _NS("Download now")]; 67 [o_btn_okay setTitle: _NS("OK")]; 68 [o_chk_updateOnStartup setTitle: _NS("Automatically check for updates")]; 60 69 } 61 70 … … 65 74 - (void)awakeFromNib 66 75 { 67 /* get up */ 68 p_intf = VLCIntf; 69 70 /* clean the interface */ 71 [o_fld_releaseNote setString: @""]; 72 73 [self initInterface]; 74 } 75 76 - (void)dealloc 77 { 78 if( o_urlOfBinary ) 79 [o_urlOfBinary release]; 80 81 [super dealloc]; 82 } 83 84 - (void)initInterface 85 { 86 /* translate strings to the user's language */ 87 [o_update_window setTitle: _NS("Check for Updates")]; 88 [o_btn_DownloadNow setTitle: _NS("Download now")]; 89 [o_btn_okay setTitle: _NS("OK")]; 90 [o_chk_updateOnStartup setTitle: _NS("Automatically check for updates")]; 91 /* we don't use - (BOOL)shouldCheckUpdateOnStartup because we don't want the Alert 92 * panel to pop up at this time */ 76 /* we don't use - (BOOL)shouldCheckUpdateOnStartup because we don't want 77 * the Alert panel to pop up at this time */ 93 78 [o_chk_updateOnStartup setState: [[NSUserDefaults standardUserDefaults] boolForKey: kPrefUpdateOnStartup]]; 94 79 } … … 130 115 { 131 116 /* show the window and check for a potential update */ 132 [o_fld_status setStringValue: _NS("Checking for Updates...")];133 [o_fld_currentVersionAndSize setStringValue: @""];134 [o_fld_releaseNote setString: @""];135 136 117 [o_update_window center]; 137 118 [o_update_window displayIfNeeded]; 138 119 [o_update_window makeKeyAndOrderFront:nil]; 139 120 140 [o_bar_checking startAnimation: self]; 141 [self checkForUpdate]; 142 [o_bar_checking stopAnimation: self]; 121 if( !b_checked ) 122 { 123 [o_bar_checking startAnimation: self]; 124 [self checkForUpdate]; 125 b_checked = VLC_TRUE; 126 [o_bar_checking stopAnimation: self]; 127 } 143 128 } 144 129 … … 148 133 SEL sel = @selector(getLocationForSaving:returnCode:contextInfo:); 149 134 NSSavePanel * saveFilePanel = [[NSSavePanel alloc] init]; 150 135 151 136 [saveFilePanel setRequiredFileType: @"dmg"]; 152 137 [saveFilePanel setCanSelectHiddenExtension: YES]; 153 138 [saveFilePanel setCanCreateDirectories: YES]; 154 139 [saveFilePanel beginSheetForDirectory:nil file: 155 [[ o_urlOfBinarycomponentsSeparatedByString:@"/"] lastObject]140 [[[NSString stringWithUTF8String: p_u->release.psz_url] componentsSeparatedByString:@"/"] lastObject] 156 141 modalForWindow: o_update_window 157 142 modalDelegate:self … … 174 159 - (IBAction)okay:(id)sender 175 160 { 176 /* just closethe window */177 [o_update_window close];161 /* just hides the window */ 162 [o_update_window orderOut: self]; 178 163 } 179 164 … … 183 168 } 184 169 170 - (void)updateManagement:(vlc_bool_t)b_success 171 { 172 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 173 174 if( !b_success || 175 update_CompareReleaseToCurrent( p_u ) != UpdateReleaseStatusNewer ) 176 { 177 [o_fld_status setStringValue: _NS("This version of VLC is the latest available.")]; 178 [o_btn_DownloadNow setEnabled: NO]; 179 } 180 else 181 { 182 [o_fld_releaseNote setString: [NSString stringWithUTF8String: (p_u->release.psz_desc)]]; 183 [o_fld_status setStringValue: _NS("This version of VLC is outdated.")]; 184 [o_fld_currentVersion setStringValue: [NSString stringWithFormat: 185 _NS("The current release is %d.%d.%d%c."), p_u->release.i_major, 186 p_u->release.i_minor, p_u->release.i_revision, p_u->release.extra]]; 187 [o_btn_DownloadNow setEnabled: YES]; 188 /* Make sure the update window is showed in case we have something */ 189 [o_update_window center]; 190 [o_update_window displayIfNeeded]; 191 [o_update_window makeKeyAndOrderFront: self]; 192 } 193 194 [pool release]; 195 } 196 197 static void updateCallback( void * p_data, vlc_bool_t b_success ) 198 { 199 [(id)p_data updateManagement: b_success]; 200 } 201 185 202 - (void)checkForUpdate 186 203 { 187 /* We may not run on first thread */ 188 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 189 p_u = update_New( p_intf ); 190 update_Check( p_u, VLC_FALSE ); 191 update_iterator_t *p_uit = update_iterator_New( p_u ); 192 BOOL releaseChecked = NO; 193 BOOL gettingReleaseNote = NO; 194 int x = 0; 195 NSString * pathToReleaseNote; 196 pathToReleaseNote = [NSString stringWithFormat: 197 @"/tmp/vlc_releasenote_%d.tmp", mdate()]; 204 p_u = update_New( VLCIntf ); 205 if( !p_u ) 206 return; 207 update_Check( p_u, updateCallback, self ); 198 208 199 209 [[NSUserDefaults standardUserDefaults] setObject: [NSDate date] forKey: kPrefUpdateLastTimeChecked]; 200 201 if( p_uit )202 {203 p_uit->i_rs = UPDATE_RELEASE_STATUS_NEWER;204 p_uit->i_t = UPDATE_FILE_TYPE_ALL;205 update_iterator_Action( p_uit, UPDATE_MIRROR );206 207 while( update_iterator_Action( p_uit, UPDATE_FILE) != UPDATE_FAIL )208 {209 msg_Dbg( p_intf, "parsing available updates, run %i", x );210 /* if the announced item is of the type "binary", keep it and display211 * its details to the user. Do similar stuff on "info". Do both212 * only if the file is announced as stable */213 if( p_uit->release.i_type == UPDATE_RELEASE_TYPE_STABLE )214 {215 if( p_uit->file.i_type == UPDATE_FILE_TYPE_INFO )216 {217 msg_Dbg( p_intf, "release note found, desc = %s",218 p_uit->file.psz_description );219 [o_fld_releaseNote setString:220 [NSString stringWithUTF8String:221 (p_uit->file.psz_description)]];222 /* download our release note223 * We will read the temp file after this loop */224 update_download( p_uit, (char *)[pathToReleaseNote UTF8String] );225 gettingReleaseNote = YES;226 }227 else if( p_uit->file.i_type == UPDATE_FILE_TYPE_BINARY )228 {229 msg_Dbg( p_intf, "binary found, version = %s, "230 "url=%s, size=%i MB", p_uit->release.psz_version,231 p_uit->file.psz_url,232 (int)((p_uit->file.l_size / 1024) / 1024) );233 [o_fld_currentVersionAndSize setStringValue:234 [NSString stringWithFormat:235 _NS("The latest VLC media player release "236 "is %s (%i MB to download)."),237 p_uit->release.psz_version, ((p_uit->file.l_size238 / 1024) / 1024)]];239 240 if( o_urlOfBinary )241 [o_urlOfBinary release];242 o_urlOfBinary = [[NSString alloc] initWithUTF8String:243 p_uit->file.psz_url];244 }245 if( p_uit->release.i_status == UPDATE_RELEASE_STATUS_NEWER &&246 !releaseChecked )247 {248 /* our version is outdated, let the user download the new249 * release */250 [o_fld_status setStringValue: _NS("This version of VLC "251 "is outdated.")];252 [o_btn_DownloadNow setEnabled: YES];253 msg_Dbg( p_intf, "this version of VLC is outdated" );254 /* put the mirror information */255 msg_Dbg( p_intf, "used mirror: %s, %s [%s]",256 p_uit->mirror.psz_name, p_uit->mirror.psz_location,\257 p_uit->mirror.psz_type );258 /* make sure that we perform this check only once */259 releaseChecked = YES;260 /* Make sure the update window is showed in case we have something */261 [o_update_window center];262 [o_update_window displayIfNeeded];263 [o_update_window makeKeyAndOrderFront: self];264 265 }266 else if(! releaseChecked )267 {268 [o_fld_status setStringValue: _NS("This version of VLC "269 "is the latest available.")];270 [o_btn_DownloadNow setEnabled: NO];271 msg_Dbg( p_intf, "current version is up-to-date" );272 releaseChecked = YES;273 }274 }275 x += 1;276 }277 278 update_iterator_Delete( p_uit );279 280 /* wait for our release notes if necessary, since the download is done281 * by another thread -- this does usually take 300000 to 500000 ms */282 if( gettingReleaseNote )283 {284 int i = 0;285 while( [[NSFileManager defaultManager] fileExistsAtPath: pathToReleaseNote] == NO )286 {287 msleep( 100000 );288 i += 1;289 if( i == 150 )290 {291 /* if this takes more than 15 sec, exit */292 msg_Warn( p_intf, "download took more than 15 sec, exiting" );293 break;294 }295 }296 msg_Dbg( p_intf, "waited %i ms for the release notes", (i * 100000) );297 msleep( 500000 );298 299 /* let's open our cached release note and display it300 * we can't use NSString stringWithContentsOfFile:encoding:error:301 * since it is Tiger only */302 NSString * releaseNote = [[NSString alloc] initWithData:303 [NSData dataWithContentsOfFile: pathToReleaseNote]304 encoding: NSISOLatin1StringEncoding];305 if( releaseNote )306 [o_fld_releaseNote setString: releaseNote];307 308 /* delete the file since it isn't needed anymore */309 BOOL myBOOL = NO;310 myBOOL = [[NSFileManager defaultManager] removeFileAtPath:311 pathToReleaseNote handler: nil];312 }313 else314 {315 /* don't confuse the user, but make her happy */316 [o_fld_status setStringValue: _NS("This version of VLC "317 "is the latest available.")];318 [o_btn_DownloadNow setEnabled: NO];319 msg_Dbg( p_intf, "current version is up-to-date" );320 }321 }322 [pool release];323 210 } 324 211 325 212 - (void)performDownload:(NSString *)path 326 213 { 327 update_iterator_t *p_uit = update_iterator_New( p_u ); 328 if( p_uit ) 329 { 330 update_iterator_Action( p_uit, UPDATE_MIRROR ); 331 332 while( update_iterator_Action( p_uit, UPDATE_FILE) != UPDATE_FAIL ) 333 { 334 if( p_uit->release.i_type == UPDATE_RELEASE_TYPE_STABLE && 335 p_uit->release.i_status == UPDATE_RELEASE_STATUS_NEWER && 336 p_uit->file.i_type == UPDATE_FILE_TYPE_BINARY ) 337 { 338 /* put the mirror information */ 339 msg_Dbg( p_intf, "used mirror: %s, %s [%s]", 340 p_uit->mirror.psz_name, p_uit->mirror.psz_location, 341 p_uit->mirror.psz_type ); 342 343 /* that's our binary */ 344 update_download( p_uit, (char *)[path UTF8String] ); 345 } 346 } 347 348 update_iterator_Delete( p_uit ); 349 } 350 351 [o_update_window close]; 214 update_Download( p_u, (char*)[path UTF8String] ); 215 [o_btn_DownloadNow setEnabled: NO]; 216 [o_update_window orderOut: self]; 217 update_Delete( p_u ); 352 218 } 353 219
