Changeset 58
- Timestamp:
- Jan 29, 2006, 10:01:08 PM (16 years ago)
- Location:
- trunk/macosx
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/Controller.h
r55 r58 70 70 NSArray * fFilenames; 71 71 NSTimer * fTimer; 72 NSTimer * fUpdateTimer; 72 73 73 74 IBOutlet NSPanel * fPrefsWindow; … … 77 78 BOOL fHasGrowl; 78 79 Badger * fBadger; 80 BOOL fCheckIsAutomatic; 79 81 } 80 82 … … 129 131 - (void) growlRegister: (id) sender; 130 132 133 - (void) checkForUpdate: (id) sender; 134 - (void) checkForUpdateTimer: (NSTimer *) timer; 135 - (void) checkForUpdateAuto: (BOOL) automatic; 136 131 137 @end 132 138 -
trunk/macosx/Controller.m
r55 r58 37 37 #define TOOLBAR_RESUME_ALL @"Toolbar Resume All" 38 38 39 #define WEBSITE_URL @"http://transmission.m0k.org/" 40 #define FORUM_URL @"http://transmission.m0k.org/forum/" 39 #define WEBSITE_URL @"http://transmission.m0k.org/" 40 #define FORUM_URL @"http://transmission.m0k.org/forum/" 41 #define VERSION_PLIST_URL @"http://transmission.m0k.org/version.plist" 41 42 42 43 #define GROWL_PATH @"/Library/PreferencePanes/Growl.prefPane/Contents/Resources/GrowlHelperApp.app" … … 143 144 fSeeding = 0; 144 145 fCompleted = 0; 145 146 146 fStat = nil; 147 147 fTimer = [NSTimer scheduledTimerWithTimeInterval: 0.5 target: self 148 148 selector: @selector( updateUI: ) userInfo: NULL repeats: YES]; 149 149 [[NSRunLoop currentRunLoop] addTimer: fTimer 150 forMode: NSModalPanelRunLoopMode]; 151 [[NSRunLoop currentRunLoop] addTimer: fTimer 150 152 forMode: NSEventTrackingRunLoopMode]; 153 154 [self checkForUpdateTimer: nil]; 155 fUpdateTimer = [NSTimer scheduledTimerWithTimeInterval: 60.0 156 target: self selector: @selector( checkForUpdateTimer: ) 157 userInfo: NULL repeats: YES]; 151 158 } 152 159 … … 215 222 // Stop updating the interface 216 223 [fTimer invalidate]; 224 [fUpdateTimer invalidate]; 217 225 218 226 // Save history and stop running torrents … … 1093 1101 } 1094 1102 1103 - (void) checkForUpdate: (id) sender 1104 { 1105 [self checkForUpdateAuto: NO]; 1106 } 1107 1108 - (void) checkForUpdateTimer: (NSTimer *) timer 1109 { 1110 NSString * check = [fDefaults stringForKey: @"VersionCheck"]; 1111 if( [check isEqualToString: @"Never"] ) 1112 return; 1113 1114 NSTimeInterval interval; 1115 if( [check isEqualToString: @"Daily"] ) 1116 interval = 24 * 3600; 1117 else if( [check isEqualToString: @"Weekly"] ) 1118 interval = 7 * 24 * 3600; 1119 else 1120 return; 1121 1122 id lastObject = [fDefaults objectForKey: @"VersionCheckLast"]; 1123 NSDate * lastDate = [lastObject isKindOfClass: [NSDate class]] ? 1124 lastObject : nil; 1125 if( lastDate ) 1126 { 1127 NSTimeInterval actualInterval = 1128 [[NSDate date] timeIntervalSinceDate: lastDate]; 1129 if( actualInterval > 0 && actualInterval < interval ) 1130 { 1131 return; 1132 } 1133 } 1134 1135 [self checkForUpdateAuto: YES]; 1136 [fDefaults setObject: [NSDate date] forKey: @"VersionCheckLast"]; 1137 } 1138 1139 - (void) checkForUpdateAuto: (BOOL) automatic 1140 { 1141 fCheckIsAutomatic = automatic; 1142 [[NSURL URLWithString: VERSION_PLIST_URL] 1143 loadResourceDataNotifyingClient: self usingCache: NO]; 1144 } 1145 1146 - (void) URLResourceDidFinishLoading: (NSURL *) sender 1147 { 1148 NSDictionary * dict = [NSPropertyListSerialization 1149 propertyListFromData: [sender resourceDataUsingCache: NO] 1150 mutabilityOption: NSPropertyListImmutable 1151 format: nil errorDescription: nil]; 1152 1153 //check if plist was actually found and contains a version 1154 NSString * webVersion = nil; 1155 if (dict) 1156 webVersion = [dict objectForKey: @"Version"]; 1157 if (!webVersion) 1158 { 1159 if (!fCheckIsAutomatic) 1160 { 1161 NSAlert * dialog = [[NSAlert alloc] init]; 1162 [dialog addButtonWithTitle: @"OK"]; 1163 [dialog setMessageText: @"Error checking for updates."]; 1164 [dialog setInformativeText: 1165 @"Transmission was not able to check the latest version available."]; 1166 [dialog setAlertStyle: NSInformationalAlertStyle]; 1167 1168 [dialog runModal]; 1169 [dialog release]; 1170 } 1171 return; 1172 } 1173 1174 NSString * currentVersion = [[[NSBundle mainBundle] infoDictionary] 1175 objectForKey: (NSString *)kCFBundleVersionKey]; 1176 1177 NSEnumerator * webEnum = [[webVersion componentsSeparatedByString: @"."] objectEnumerator], 1178 * currentEnum = [[currentVersion componentsSeparatedByString: @"."] objectEnumerator]; 1179 NSString * webSub, * currentSub; 1180 1181 BOOL webGreater = NO; 1182 NSComparisonResult result; 1183 while ((webSub = [webEnum nextObject])) 1184 { 1185 if (!(currentSub = [currentEnum nextObject])) 1186 { 1187 webGreater = YES; 1188 break; 1189 } 1190 1191 result = [currentSub compare: webSub options: NSNumericSearch]; 1192 if (result != NSOrderedSame) 1193 { 1194 if (result == NSOrderedAscending) 1195 webGreater = YES; 1196 break; 1197 } 1198 } 1199 1200 if (webGreater) 1201 { 1202 NSAlert * dialog = [[NSAlert alloc] init]; 1203 [dialog addButtonWithTitle: @"Go to Website"]; 1204 [dialog addButtonWithTitle:@"Cancel"]; 1205 [dialog setMessageText: @"New version is available!"]; 1206 [dialog setInformativeText: [NSString stringWithFormat: 1207 @"A newer version (%@) is available for download from the Transmission website.", webVersion]]; 1208 [dialog setAlertStyle: NSInformationalAlertStyle]; 1209 1210 if ([dialog runModal] == NSAlertFirstButtonReturn) 1211 [self linkHomepage: nil]; 1212 1213 [dialog release]; 1214 } 1215 else if (!fCheckIsAutomatic) 1216 { 1217 NSAlert * dialog = [[NSAlert alloc] init]; 1218 [dialog addButtonWithTitle: @"OK"]; 1219 [dialog setMessageText: @"No new versions are available."]; 1220 [dialog setInformativeText: [NSString stringWithFormat: 1221 @"You are running the most current version of Transmission (%@).", currentVersion]]; 1222 [dialog setAlertStyle: NSInformationalAlertStyle]; 1223 1224 [dialog runModal]; 1225 [dialog release]; 1226 } 1227 else; 1228 } 1229 1095 1230 @end -
trunk/macosx/Defaults.plist
r38 r58 35 35 <key>UseAdvancedBar</key> 36 36 <false/> 37 <key>Version StartupCheck</key>38 < true/>37 <key>VersionCheck</key> 38 <string>Weekly</string> 39 39 </dict> 40 40 </plist> -
trunk/macosx/English.lproj/MainMenu.nib/classes.nib
r57 r58 4 4 ACTIONS = { 5 5 advancedChanged = id; 6 checkForUpdate = id; 6 7 growlRegister = id; 7 8 linkForums = id; … … 66 67 setQuitMessage = id; 67 68 setRemoveMessage = id; 69 setUpdate = id; 68 70 setUploadLimit = id; 69 71 }; … … 82 84 fQuitCheck = NSButton; 83 85 fRemoveCheck = NSButton; 86 fUpdatePopUp = NSPopUpButton; 84 87 fUploadCheck = NSButton; 85 88 fUploadField = NSTextField; -
trunk/macosx/English.lproj/MainMenu.nib/info.nib
r57 r58 4 4 <dict> 5 5 <key>IBDocumentLocation</key> 6 <string>62 6 6426 365 0 0 1280 832 </string>6 <string>62 69 426 365 0 0 1280 832 </string> 7 7 <key>IBEditorPositions</key> 8 8 <dict> … … 16 16 <string>54 521 112 118 0 0 1152 842 </string> 17 17 <key>783</key> 18 <string>38 6 439 470 2310 0 1280 832 </string>18 <string>387 422 470 265 0 0 1280 832 </string> 19 19 <key>796</key> 20 20 <string>412 490 470 129 0 0 1280 832 </string> … … 26 26 <key>IBOldestOS</key> 27 27 <integer>3</integer> 28 <key>IBOpenObjects</key> 29 <array> 30 <integer>783</integer> 31 </array> 28 32 <key>IBSystem Version</key> 29 33 <string>8G32</string> -
trunk/macosx/PrefsController.h
r57 r58 41 41 IBOutlet NSButton * fBadgeDownloadRateCheck; 42 42 IBOutlet NSButton * fBadgeUploadRateCheck; 43 IBOutlet NSPopUpButton * fUpdatePopUp; 43 44 44 45 IBOutlet NSTextField * fPortField; … … 57 58 - (void) setRemoveMessage: (id) sender; 58 59 - (void) setBadge: (id) sender; 60 - (void) setUpdate: (id) sender; 59 61 - (void) setDownloadLocation: (id) sender; 60 62 - (void) folderSheetShow: (id) sender; -
trunk/macosx/PrefsController.m
r57 r58 30 30 #define DOWNLOAD_ASK 3 31 31 32 #define UPDATE_DAILY 0 33 #define UPDATE_WEEKLY 1 34 #define UPDATE_NEVER 2 35 32 36 #define TOOLBAR_GENERAL @"General" 33 37 #define TOOLBAR_NETWORK @"Network" … … 129 133 [fBadgeDownloadRateCheck setState: [fDefaults boolForKey: @"BadgeDownloadRate"]]; 130 134 [fBadgeUploadRateCheck setState: [fDefaults boolForKey: @"BadgeUploadRate"]]; 135 136 /* Check for update */ 137 NSString * versionCheck = [fDefaults stringForKey: @"VersionCheck"]; 138 if( [versionCheck isEqualToString: @"Daily"] ) 139 [fUpdatePopUp selectItemAtIndex: UPDATE_DAILY]; 140 else if( [versionCheck isEqualToString: @"Weekly"] ) 141 [fUpdatePopUp selectItemAtIndex: UPDATE_WEEKLY]; 142 else if( [versionCheck isEqualToString: @"Never"] ) 143 [fUpdatePopUp selectItemAtIndex: UPDATE_NEVER]; 144 else 145 { 146 [fDefaults setObject: @"Weekly" forKey: @"VersionCheck"]; 147 [fUpdatePopUp selectItemAtIndex: UPDATE_WEEKLY]; 148 } 131 149 } 132 150 … … 255 273 [fDefaults setBool: state forKey: @"BadgeUploadRate"]; 256 274 else; 275 } 276 277 - (void) setUpdate: (id) sender 278 { 279 switch( [fUpdatePopUp indexOfSelectedItem] ) 280 { 281 case UPDATE_DAILY: 282 [fDefaults setObject: @"Daily" forKey: @"VersionCheck"]; 283 break; 284 case UPDATE_WEEKLY: 285 [fDefaults setObject: @"Weekly" forKey: @"VersionCheck"]; 286 break; 287 case UPDATE_NEVER: 288 [fDefaults setObject: @"Never" forKey: @"VersionCheck"]; 289 break; 290 } 257 291 } 258 292
Note: See TracChangeset
for help on using the changeset viewer.