From 84f958c5c84bb1459cb3e5a73853017375e38cf9 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 16 Jun 2008 19:51:40 -0400 Subject: [PATCH] Adding a *real* version checking system * English.lproj/MainMenu.xib: Adding the version update window * Source/AppDelegate.h: Adding IBOs for the updater window and the update information string * Source/AppDelegate.m: (init): Run the version check method (versionCheck:): New method (openUpdateInformation:): New method --- English.lproj/MainMenu.xib | 272 ++++++++++++++++++++++++++++++++++++- Source/AppDelegate.h | 5 + Source/AppDelegate.m | 39 ++++++ 3 files changed, 315 insertions(+), 1 deletion(-) diff --git a/English.lproj/MainMenu.xib b/English.lproj/MainMenu.xib index 1884d6e..57c1df8 100644 --- a/English.lproj/MainMenu.xib +++ b/English.lproj/MainMenu.xib @@ -8,6 +8,7 @@ 352.00 YES + @@ -639,6 +640,123 @@ AppDelegate + + 1 + 2 + {{196, 357}, {480, 153}} + 603979776 + New Version Avaliable! + NSWindow + + {3.40282e+38, 3.40282e+38} + + + 256 + + YES + + + 268 + {{17, 48}, {446, 60}} + + YES + + 67239424 + 272629760 + Version %@ of MacGDBp is now avaliable for download. Please download it at your earliest convenience. + + LucidaGrande + 1.300000e+01 + 1044 + + + + 6 + System + controlColor + + 3 + MC42NjY2NjY2OQA + + + + 6 + System + controlTextColor + + 3 + MAA + + + + + + + 268 + {{17, 116}, {440, 17}} + + YES + + 67239488 + 272630784 + There is a new version of MacGDBp Avaliable + + LucidaGrande-Bold + 1.300000e+01 + 16 + + + + + + + + + 268 + {{299, 12}, {167, 32}} + + YES + + -2080244224 + 134217728 + More information... + + + -2038284033 + 129 + + DQ + 200 + 25 + + + + + 268 + {{153, 12}, {146, 32}} + + YES + + 67239424 + 134217728 + Remind Me Later + + + -2038284033 + 129 + + + 200 + 25 + + + + {480, 153} + + + {{0, 0}, {1440, 878}} + {3.40282e+38, 3.40282e+38} + @@ -875,6 +993,38 @@ 269 + + + orderOut: + + + + 280 + + + + openUpdateInformation: + + + + 281 + + + + updateWindow + + + + 282 + + + + updateString + + + + 283 + @@ -1361,6 +1511,83 @@ + + 270 + + + YES + + + + + + 271 + + + YES + + + + + + + + + 272 + + + YES + + + + + + 273 + + + YES + + + + + + 274 + + + YES + + + + + + 275 + + + YES + + + + + + 276 + + + + + 277 + + + + + 278 + + + + + 279 + + + @@ -1476,6 +1703,20 @@ 264.IBPluginDependency 265.IBPluginDependency 268.IBPluginDependency + 270.IBEditorWindowLastContentRect + 270.IBPluginDependency + 270.IBWindowTemplateEditedContentRect + 270.NSWindowTemplate.visibleAtLaunch + 270.editorWindowContentRectSynchronizationRect + 271.IBPluginDependency + 272.IBPluginDependency + 273.IBPluginDependency + 274.IBPluginDependency + 275.IBPluginDependency + 276.IBPluginDependency + 277.IBPluginDependency + 278.IBPluginDependency + 279.IBPluginDependency 29.IBEditorWindowLastContentRect 29.IBPluginDependency 29.ImportedFromIB2 @@ -1602,6 +1843,20 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + {{382, 522}, {480, 153}} + com.apple.InterfaceBuilder.CocoaPlugin + {{382, 522}, {480, 153}} + + {{466, 471}, {480, 153}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin {{63, 745}, {317, 20}} com.apple.InterfaceBuilder.CocoaPlugin @@ -1638,7 +1893,7 @@ - 269 + 283 @@ -1650,6 +1905,7 @@ YES YES + openUpdateInformation: showBreakpointWindow: showDebuggerWindow: @@ -1657,6 +1913,20 @@ YES id id + id + + + + YES + + YES + updateString + updateWindow + + + YES + NSTextField + NSWindow diff --git a/Source/AppDelegate.h b/Source/AppDelegate.h index 5cb7b4d..6018bc5 100644 --- a/Source/AppDelegate.h +++ b/Source/AppDelegate.h @@ -22,6 +22,9 @@ { DebuggerWindowController *debugger; BreakpointWindowController *breakpoint; + + IBOutlet NSWindow *updateWindow; + IBOutlet NSTextField *updateString; } @property(readonly) DebuggerWindowController *debugger; @@ -30,4 +33,6 @@ - (IBAction)showDebuggerWindow:(id)sender; - (IBAction)showBreakpointWindow:(id)sender; +- (IBAction)openUpdateInformation:(id)sender; + @end diff --git a/Source/AppDelegate.m b/Source/AppDelegate.m index f870804..6e074f9 100644 --- a/Source/AppDelegate.m +++ b/Source/AppDelegate.m @@ -40,6 +40,7 @@ // TODO: use preference values debugger = [[DebuggerWindowController alloc] initWithPort:9000 session:@"macgdbp"]; breakpoint = [[BreakpointWindowController alloc] init]; + [NSThread detachNewThreadSelector:@selector(versionCheck:) toTarget:self withObject:self]; } /** @@ -58,4 +59,42 @@ [[breakpoint window] makeKeyAndOrderFront:self]; } +#pragma mark Version Checking + +/** + * Checks and sees if the current version is the most up-to-date one + */ +- (void)versionCheck:(id)sender +{ + NSMutableString *version = [NSMutableString stringWithString:[[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleShortVersionString"]]; + [version replaceOccurrencesOfString:@" " withString:@"-" options:NSLiteralSearch range:NSMakeRange(0, [version length])]; + + NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.bluestatic.org/versioncheck.php?prod=macgdbp&ver=%@", version]]; + NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10]; + NSURLResponse *response; + NSData *result = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:nil]; + + if (result == nil) + { + return; + } + + NSXMLDocument *xml = [[NSXMLDocument alloc] initWithData:result options:0 error:nil]; + NSXMLNode *comp = [[xml rootElement] childAtIndex:0]; + if ([[comp name] isEqualToString:@"update"]) + { + [updateString setStringValue:[NSString stringWithFormat:[updateString stringValue], [comp stringValue]]]; + [updateWindow makeKeyAndOrderFront:self]; + } +} + + +/** + * Opens the URL to the download page + */ +- (IBAction)openUpdateInformation:(id)sender +{ + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.bluestatic.org/software/macgdbp/"]]; +} + @end -- 2.22.5