Now reads from Google's API instead of the Apache location due to the Apache location being deprecated.

This commit is contained in:
GRMrGecko 2011-09-15 20:54:40 -05:00
parent b2a45eef97
commit cd98c92b94
4 changed files with 1123 additions and 1053 deletions

View File

@ -43,6 +43,8 @@ extern NSString * const MGMQuitAfterLaunch;
NSMutableDictionary *channelRevisions; NSMutableDictionary *channelRevisions;
NSString *chromiumPath; NSString *chromiumPath;
NSMutableArray *revisionsArray;
IBOutlet NSPopUpButton *channelPopUp; IBOutlet NSPopUpButton *channelPopUp;
IBOutlet NSTextField *buildWarningField; IBOutlet NSTextField *buildWarningField;
IBOutlet NSPopUpButton *buildPopUp; IBOutlet NSPopUpButton *buildPopUp;

View File

@ -43,7 +43,8 @@ NSString * const MGMChromiumZip = @"chrome-mac.zip";
NSString * const MGMTMPPath = @"/tmp"; NSString * const MGMTMPPath = @"/tmp";
NSString * const MGMChannelsURL = @"http://omahaproxy.appspot.com/all.json?os=mac"; NSString * const MGMChannelsURL = @"http://omahaproxy.appspot.com/all.json?os=mac";
static NSString *MGMSnapshotURL = @"http://build.chromium.org/f/chromium/snapshots/Mac/"; static NSString *MGMSnapshotURL = @"https://commondatastorage.googleapis.com/chromium-browser-snapshots/";
NSString * const MGMSnapshotPrefix = @"Mac/";
NSString * const MGMSVNLogsURL = @"http://build.chromium.org/f/chromium/perf/dashboard/ui/changelog.html?url=/trunk/src&range=%@:%@&mode=html&os=mac"; NSString * const MGMSVNLogsURL = @"http://build.chromium.org/f/chromium/perf/dashboard/ui/changelog.html?url=/trunk/src&range=%@:%@&mode=html&os=mac";
NSString * const MGMCChannel = @"channel"; NSString * const MGMCChannel = @"channel";
@ -57,6 +58,27 @@ NSString * const MGMUBUpdate = @"Update";
NSString * const MGMUBInstall = @"Install"; NSString * const MGMUBInstall = @"Install";
NSString * const MGMUBCancel = @"Cancel"; NSString * const MGMUBCancel = @"Cancel";
@interface NSString (MGMAddonsSort)
- (NSComparisonResult)numberCompare:(id)theItem;
@end
@implementation NSString (MGMAddonsSort)
- (NSComparisonResult)numberCompare:(id)theItem {
unsigned int theNumber = 0;
unsigned int number = 0;
if ([theItem isKindOfClass:[NSString class]])
sscanf([theItem UTF8String], "%u", &theNumber);
sscanf([self UTF8String], "%u", &number);
if (number<theNumber)
return NSOrderedAscending;
else if (number>theNumber)
return NSOrderedDescending;
return NSOrderedSame;
}
@end
@interface NSOpenPanel (MGMIgnore) @interface NSOpenPanel (MGMIgnore)
- (void)setDirectoryURL:(NSURL *)url; - (void)setDirectoryURL:(NSURL *)url;
- (void)setDirectory:(NSString *)path; - (void)setDirectory:(NSString *)path;
@ -131,7 +153,9 @@ NSString * const MGMUBCancel = @"Cancel";
[handler setFailWithError:@selector(channels:didFailWithError:)]; [handler setFailWithError:@selector(channels:didFailWithError:)];
[handler setFinish:@selector(channelsFinished:)]; [handler setFinish:@selector(channelsFinished:)];
[connectionManager addHandler:handler]; [connectionManager addHandler:handler];
handler = [MGMURLBasicHandler handlerWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:MGMSnapshotURL]] delegate:self]; revisionsArray = [NSMutableArray new];
NSString *url = [MGMSnapshotURL stringByAppendingFormat:@"?delimiter=/&prefix=%@", MGMSnapshotPrefix];
handler = [MGMURLBasicHandler handlerWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]] delegate:self];
[handler setFailWithError:@selector(revisions:didFailWithError:)]; [handler setFailWithError:@selector(revisions:didFailWithError:)];
[handler setFinish:@selector(revisionsFinished:)]; [handler setFinish:@selector(revisionsFinished:)];
[connectionManager addHandler:handler]; [connectionManager addHandler:handler];
@ -192,42 +216,86 @@ NSString * const MGMUBCancel = @"Cancel";
[alert setMessageText:@"Error loading revisions"]; [alert setMessageText:@"Error loading revisions"];
[alert setInformativeText:[theError localizedDescription]]; [alert setInformativeText:[theError localizedDescription]];
[alert runModal]; [alert runModal];
}
- (void)revisionsFinished:(MGMURLBasicHandler *)theHandler {
NSString *returnedString = [theHandler string];
[buildPopUp removeAllItems];
[progress setDoubleValue:0.50];
NSMenu *items = [NSMenu new]; NSMenu *items = [NSMenu new];
unsigned long length = [returnedString length]; [revisionsArray sortUsingSelector:@selector(numberCompare:)];
NSRange range = NSMakeRange(0, length); for (unsigned int i=0; i<[revisionsArray count]; i++) {
while (range.location!=length) {
NSRange urlRange = [returnedString rangeOfString:@"/\">" options:0 range:range];
if (urlRange.location==NSNotFound)
break;
range.location = urlRange.location+urlRange.length;
range.length = length-range.location;
urlRange = [returnedString rangeOfString:@"</a>" options:0 range:range];
if (urlRange.location==NSNotFound)
continue;
NSRange revisionRange = NSMakeRange(range.location, urlRange.location-range.location);
range.location = urlRange.location+urlRange.length;
range.length = length-range.location;
urlRange = [returnedString rangeOfString:@"/" options:0 range:revisionRange];
if (urlRange.location==NSNotFound)
continue;
revisionRange.length -= 1;
NSMenuItem *item = [NSMenuItem new]; NSMenuItem *item = [NSMenuItem new];
[item setTitle:[returnedString substringWithRange:revisionRange]]; [item setTitle:[revisionsArray objectAtIndex:i]];
[items addItem:item]; [items addItem:item];
[item release]; [item release];
} }
[buildPopUp removeAllItems];
[buildPopUp setMenu:items]; [buildPopUp setMenu:items];
[items release]; [items release];
[revisionsArray release];
revisionsArray = nil;
[self channelSelect:self]; [self channelSelect:self];
} }
- (void)revisionsFinished:(MGMURLBasicHandler *)theHandler {
NSError *error = nil;
NSXMLDocument *xml = [[NSXMLDocument alloc] initWithData:[theHandler data] options:NSXMLDocumentTidyXML error:&error];
[progress setDoubleValue:0.50];
if (error!=nil) {
NSLog(@"%@", error);
NSAlert *alert = [[NSAlert new] autorelease];
[alert setMessageText:@"Error parsing revisions"];
[alert setInformativeText:[error localizedDescription]];
[alert runModal];
NSMenu *items = [NSMenu new];
[revisionsArray sortUsingSelector:@selector(numberCompare:)];
for (unsigned int i=0; i<[revisionsArray count]; i++) {
NSMenuItem *item = [NSMenuItem new];
[item setTitle:[revisionsArray objectAtIndex:i]];
[items addItem:item];
[item release];
}
[buildPopUp removeAllItems];
[buildPopUp setMenu:items];
[items release];
[revisionsArray release];
revisionsArray = nil;
[self channelSelect:self];
} else {
NSXMLElement *rootElement = [xml rootElement];
NSArray *isTruncated = [rootElement elementsForName:@"IsTruncated"];
NSArray *commonPrefixes = [rootElement elementsForName:@"CommonPrefixes"];
for (int i=0; i<[commonPrefixes count]; i++) {
NSArray *prefix = [[commonPrefixes objectAtIndex:i] elementsForName:@"Prefix"];
if ([prefix count]<1)
continue;
NSArray *parsed = [[[prefix objectAtIndex:0] stringValue] componentsSeparatedByString:@"/"];
if ([parsed count]<2)
continue;
[revisionsArray addObject:[parsed objectAtIndex:1]];
}
NSArray *nextMarkers = [rootElement elementsForName:@"NextMarker"];
if ([isTruncated count]>0 && [[[isTruncated objectAtIndex:0] stringValue] isEqual:@"true"] && [nextMarkers count]>0) {
NSString *nextMarker = [[nextMarkers objectAtIndex:0] stringValue];
NSString *url = [MGMSnapshotURL stringByAppendingFormat:@"?delimiter=/&prefix=%@&marker=%@", MGMSnapshotPrefix, nextMarker];
MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]] delegate:self];
[handler setFailWithError:@selector(revisions:didFailWithError:)];
[handler setFinish:@selector(revisionsFinished:)];
[connectionManager addHandler:handler];
} else {
NSMenu *items = [NSMenu new];
[revisionsArray sortUsingSelector:@selector(numberCompare:)];
for (unsigned int i=0; i<[revisionsArray count]; i++) {
NSMenuItem *item = [NSMenuItem new];
[item setTitle:[revisionsArray objectAtIndex:i]];
[items addItem:item];
[item release];
}
[buildPopUp removeAllItems];
[buildPopUp setMenu:items];
[items release];
[revisionsArray release];
revisionsArray = nil;
[self channelSelect:self];
}
}
[xml release];
}
- (IBAction)channelSelect:(id)sender { - (IBAction)channelSelect:(id)sender {
[[NSUserDefaults standardUserDefaults] setInteger:[channelPopUp indexOfSelectedItem] forKey:MGMChannel]; [[NSUserDefaults standardUserDefaults] setInteger:[channelPopUp indexOfSelectedItem] forKey:MGMChannel];
@ -247,7 +315,7 @@ NSString * const MGMUBCancel = @"Cancel";
if (itemIndex==NSNotFound) { if (itemIndex==NSNotFound) {
[buildWarningField setHidden:NO]; [buildWarningField setHidden:NO];
for (unsigned int i=0; i<[revisions count]; i++) { for (unsigned int i=0; i<[revisions count]; i++) {
if ([(NSString *)[revisions objectAtIndex:i] compare:revision]==NSOrderedDescending) { if ([(NSString *)[revisions objectAtIndex:i] numberCompare:revision]==NSOrderedDescending) {
itemIndex = i; itemIndex = i;
break; break;
} }
@ -263,7 +331,7 @@ NSString * const MGMUBCancel = @"Cancel";
[self buildSelect:self]; [self buildSelect:self];
} }
- (IBAction)buildSelect:(id)sender { - (IBAction)buildSelect:(id)sender {
NSURL *buildURL = [[[NSURL URLWithString:MGMSnapshotURL] appendPathComponent:[buildPopUp titleOfSelectedItem]] appendPathComponent:@"REVISIONS"]; NSURL *buildURL = [[[[NSURL URLWithString:MGMSnapshotURL] appendPathComponent:MGMSnapshotPrefix] appendPathComponent:[buildPopUp titleOfSelectedItem]] appendPathComponent:@"REVISIONS"];
MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:[NSURLRequest requestWithURL:buildURL] delegate:self]; MGMURLBasicHandler *handler = [MGMURLBasicHandler handlerWithRequest:[NSURLRequest requestWithURL:buildURL] delegate:self];
[handler setFailWithError:@selector(revision:didFailWithError:)]; [handler setFailWithError:@selector(revision:didFailWithError:)];
[handler setReceiveResponse:@selector(revision:didReceiveResponse:)]; [handler setReceiveResponse:@selector(revision:didReceiveResponse:)];
@ -397,7 +465,7 @@ NSString * const MGMUBCancel = @"Cancel";
NSString *revision1, *revision2, *tmp; NSString *revision1, *revision2, *tmp;
revision1 = [yourBuildField stringValue]; revision1 = [yourBuildField stringValue];
revision2 = [buildPopUp titleOfSelectedItem]; revision2 = [buildPopUp titleOfSelectedItem];
if ([revision1 compare:revision2]==NSOrderedDescending) { if ([revision1 numberCompare:revision2]==NSOrderedDescending) {
tmp = revision1; tmp = revision1;
revision1 = revision2; revision1 = revision2;
revision2 = tmp; revision2 = tmp;
@ -418,7 +486,7 @@ NSString * const MGMUBCancel = @"Cancel";
[progress startAnimation:self]; [progress startAnimation:self];
startTime = [[NSDate date] timeIntervalSince1970]; startTime = [[NSDate date] timeIntervalSince1970];
NSURL *url = [[[NSURL URLWithString:MGMSnapshotURL] appendPathComponent:[buildPopUp titleOfSelectedItem]] appendPathComponent:MGMChromiumZip]; NSURL *url = [[[[NSURL URLWithString:MGMSnapshotURL] appendPathComponent:MGMSnapshotPrefix] appendPathComponent:[buildPopUp titleOfSelectedItem]] appendPathComponent:MGMChromiumZip];
[updateHandler release]; [updateHandler release];
updateHandler = [[MGMURLBasicHandler handlerWithRequest:[NSURLRequest requestWithURL:url] delegate:self] retain]; updateHandler = [[MGMURLBasicHandler handlerWithRequest:[NSURLRequest requestWithURL:url] delegate:self] retain];
[updateHandler setFile:[MGMTMPPath stringByAppendingPathComponent:MGMChromiumZip]]; [updateHandler setFile:[MGMTMPPath stringByAppendingPathComponent:MGMChromiumZip]];

View File

@ -17,11 +17,11 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.2</string> <string>0.2.1</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>0.2</string> <string>0.2.1</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string> <string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>MGMGRBugsEmail</key> <key>MGMGRBugsEmail</key>
@ -37,7 +37,7 @@
<key>MGMGRTimeZone</key> <key>MGMGRTimeZone</key>
<string>CST</string> <string>CST</string>
<key>NSHumanReadableCopyright</key> <key>NSHumanReadableCopyright</key>
<string>Copyright (c) 2011 Mr. Gecko's Media (James Coleman). http://mrgeckosmedia.com/</string> <string>Copyright (c) 2011 Mr. Gecko&apos;s Media (James Coleman). http://mrgeckosmedia.com/</string>
<key>NSMainNibFile</key> <key>NSMainNibFile</key>
<string>MainMenu</string> <string>MainMenu</string>
<key>NSPrincipalClass</key> <key>NSPrincipalClass</key>

View File

@ -2,13 +2,13 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10"> <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data> <data>
<int key="IBDocument.SystemTarget">1050</int> <int key="IBDocument.SystemTarget">1050</int>
<string key="IBDocument.SystemVersion">10J869</string> <string key="IBDocument.SystemVersion">11B26</string>
<string key="IBDocument.InterfaceBuilderVersion">823</string> <string key="IBDocument.InterfaceBuilderVersion">851</string>
<string key="IBDocument.AppKitVersion">1038.35</string> <string key="IBDocument.AppKitVersion">1138</string>
<string key="IBDocument.HIToolboxVersion">461.00</string> <string key="IBDocument.HIToolboxVersion">566.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions"> <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">823</string> <string key="NS.object.0">851</string>
</object> </object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
@ -52,7 +52,7 @@
<object class="NSTextFieldCell" key="NSCell" id="967858895"> <object class="NSTextFieldCell" key="NSCell" id="967858895">
<int key="NSCellFlags">67239424</int> <int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">272629760</int> <int key="NSCellFlags2">272629760</int>
<string key="NSContents">The URL to check for new versions and get all revisions. This must be a apache directory URL, other wise it'll fail. After changing, close the Preferences and restart Chromatic to update.</string> <string key="NSContents">The URL to check for new versions and get all revisions. This must be a Google API directory URL, other wise it'll fail. After changing, close the Preferences and restart Chromatic to update.</string>
<object class="NSFont" key="NSSupport" id="870937857"> <object class="NSFont" key="NSSupport" id="870937857">
<string key="NSName">LucidaGrande</string> <string key="NSName">LucidaGrande</string>
<double key="NSSize">13</double> <double key="NSSize">13</double>
@ -65,7 +65,7 @@
<string key="NSColorName">controlColor</string> <string key="NSColorName">controlColor</string>
<object class="NSColor" key="NSColor"> <object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int> <int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC42NjY2NjY2ODY1AA</bytes> <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
</object> </object>
</object> </object>
<object class="NSColor" key="NSTextColor" id="457567397"> <object class="NSColor" key="NSTextColor" id="457567397">
@ -108,7 +108,7 @@
<object class="NSFont" key="NSSupport" id="288161355"> <object class="NSFont" key="NSSupport" id="288161355">
<string key="NSName">LucidaGrande</string> <string key="NSName">LucidaGrande</string>
<double key="NSSize">13</double> <double key="NSSize">13</double>
<int key="NSfFlags">1044</int> <int key="NSfFlags">1040</int>
</object> </object>
<reference key="NSControlView" ref="608728680"/> <reference key="NSControlView" ref="608728680"/>
<int key="NSButtonFlags">1215582719</int> <int key="NSButtonFlags">1215582719</int>
@ -153,7 +153,7 @@
<int key="NSCellFlags2">272630784</int> <int key="NSCellFlags2">272630784</int>
<string key="NSContents"/> <string key="NSContents"/>
<reference key="NSSupport" ref="288161355"/> <reference key="NSSupport" ref="288161355"/>
<string key="NSPlaceholderString">http://build.chromium.org/f/chromium/snapshots/Mac/</string> <string key="NSPlaceholderString">https://commondatastorage.googleapis.com/chromium-browser-snapshots/</string>
<reference key="NSControlView" ref="212680802"/> <reference key="NSControlView" ref="212680802"/>
<bool key="NSDrawsBackground">YES</bool> <bool key="NSDrawsBackground">YES</bool>
<object class="NSColor" key="NSBackgroundColor"> <object class="NSColor" key="NSBackgroundColor">
@ -387,7 +387,7 @@
</object> </object>
<object class="NSMutableArray" key="dict.values"> <object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<string>{{32, 250}, {487, 179}}</string> <string>{{329, 250}, {487, 179}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{628, 654}</string> <string>{628, 654}</string>
<string>{{217, 442}, {480, 272}}</string> <string>{{217, 442}, {480, 272}}</string>