Commits

evands  committed a571d8d

Patch from Ben Willmore which fixes GrowlSafari for Safari 3.0+. Thanks!

  • Participants
  • Parent commits ff0d1aa
  • Branches default

Comments (0)

Files changed (3)

File Extras/GrowlSafari/GrowlSafari.h

 - (int) downloadStage;
 - (NSString *) filename;
 - (NSString *) downloadPath;
+- (NSString *) currentPath;
 @end
 
 @interface NSObject (GrowlSafariPatch)
 - (void) mySetDownloadStage:(int)stage;
 - (void) myUpdateDiskImageStatus:(NSDictionary *)status;
 - (id) myInitWithDownload:(id)fp8 mayOpenWhenDone:(BOOL)fp12 allowOverwrite:(BOOL)fp16;
+- (NSString *) gsDownloadPath;
 @end

File Extras/GrowlSafari/GrowlSafari.m

 
 
 #define SAFARI_VERSION_2_0	412
+#define SAFARI_VERSION_3_0  523
 
 // How long should we wait (in seconds) before it's a long download?
 static double longDownload = 15.0;
 		// Register ourselves as a Growl delegate
 		[GrowlApplicationBridge setGrowlDelegate:self];
 
+		safariVersion = [[[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey] intValue];
+		//  NSLog(@"%d",safariVersion);
+
 		//	NSLog(@"Patching DownloadProgressEntry...");
 		Class class = NSClassFromString(@"DownloadProgressEntry");
 		PerformSwizzle(class, @selector(setDownloadStage:), @selector(mySetDownloadStage:), YES);
-		PerformSwizzle(class, @selector(updateDiskImageStatus:), @selector(myUpdateDiskImageStatus:), YES);
+				
+		if (safariVersion<SAFARI_VERSION_3_0) 
+			PerformSwizzle(class, @selector(updateDiskImageStatus:), @selector(myUpdateDiskImageStatus:), YES);
+		else
+			PerformSwizzle(class, @selector(_updateDiskImageStatus:), @selector(myUpdateDiskImageStatus:), YES);
+		
 		PerformSwizzle(class, @selector(initWithDownload:mayOpenWhenDone:allowOverwrite:),
 					   @selector(myInitWithDownload:mayOpenWhenDone:allowOverwrite:),
 					   YES);
 	} else {
 		NSLog(@"Could not load Growl.framework, GrowlSafari disabled");
 	}
-
-	safariVersion = [[[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey] intValue];
+	
 }
 
 #pragma mark GrowlApplicationBridge delegate methods
 
 + (void) notifyRSSUpdate:(WebBookmark *)bookmark newEntries:(int)newEntries {
 	NSBundle *bundle = [GrowlSafari bundle];
-	NSImage *icon = [bookmark icon];
 	NSMutableString	*description = [[NSMutableString alloc]
 		initWithFormat:newEntries == 1 ? NSLocalizedStringFromTableInBundle(@"%d new entry", nil, bundle, @"") : NSLocalizedStringFromTableInBundle(@"%d new entries", nil, bundle, @""),
 		newEntries,
 		[bookmark unreadRSSCount]];
 	if (newEntries != [bookmark unreadRSSCount])
 		[description appendFormat:NSLocalizedStringFromTableInBundle(@" (%d unread)", nil, bundle, @""), [bookmark unreadRSSCount]];
-	if (![icon isKindOfClass:[NSImage class]])
-		icon = nil;
 
 	NSString *title = [bookmark title];
 	[GrowlApplicationBridge notifyWithTitle:(title ? title : [bookmark URLString])
 								description:description
 						   notificationName:NSLocalizedStringFromTableInBundle(@"New feed entry", nil, bundle, @"")
-								   iconData:[icon TIFFRepresentation]
+								   iconData:nil
 								   priority:0
 								   isSticky:NO
 							   clickContext:[bookmark URLString]];
 @implementation NSObject (GrowlSafariPatch)
 - (void) mySetDownloadStage:(int)stage {
 	int oldStage = [self downloadStage];
+	
 	//NSLog(@"mySetDownloadStage:%d -> %d", oldStage, stage);
 	[self mySetDownloadStage:stage];
 	if (dateStarted(self)) {
-		if (stage == 2) {
+		if ( (safariVersion < SAFARI_VERSION_3_0 && stage == 2) || (safariVersion >= SAFARI_VERSION_3_0 && stage == 1) ) {
 			NSBundle *bundle = [GrowlSafari bundle];
 			NSString *description = [[NSString alloc] initWithFormat:
-				NSLocalizedStringFromTableInBundle(@"%@ decompression started", nil, bundle, @""),
-				[[self downloadPath] lastPathComponent]];
+				NSLocalizedStringFromTableInBundle(@"%@", nil, bundle, @""),
+				[[self gsDownloadPath] lastPathComponent]];
 			[GrowlApplicationBridge notifyWithTitle:NSLocalizedStringFromTableInBundle(@"Decompressing File", nil, bundle, @"")
 										description:description
 								   notificationName:NSLocalizedStringFromTableInBundle(@"Compression Status", nil, bundle, @"")
 										   isSticky:NO
 									   clickContext:nil];
 			[description release];
-		} else if (stage == 9 && oldStage != 9) {
+		} else if ( (safariVersion < SAFARI_VERSION_3_0 && stage == 9 && oldStage != 9) || 
+			        (safariVersion >= SAFARI_VERSION_3_0 && stage == 8 && oldStage != 8) ) {
 			NSBundle *bundle = [GrowlSafari bundle];
 			NSString *description = [[NSString alloc] initWithFormat:
-				NSLocalizedStringFromTableInBundle(@"Copying application from %@", nil, bundle, @""),
-				[[self downloadPath] lastPathComponent]];
+				NSLocalizedStringFromTableInBundle(@"%@", nil, bundle, @""),
+				[[self gsDownloadPath] lastPathComponent]];
 			[GrowlApplicationBridge notifyWithTitle:NSLocalizedStringFromTableInBundle(@"Copying Disk Image", nil, bundle, @"")
 										description:description
 								   notificationName:NSLocalizedStringFromTableInBundle(@"Disk Image Status", nil, bundle, @"")
 										   isSticky:NO
 									   clickContext:nil];
 			[description release];
-		} else if ((safariVersion < SAFARI_VERSION_2_0 && stage == 13) || (safariVersion >= SAFARI_VERSION_2_0 && stage == 15)) {
+		} else if ( (safariVersion < SAFARI_VERSION_2_0 && stage == 13) || 
+		            ((safariVersion >= SAFARI_VERSION_2_0 && safariVersion < SAFARI_VERSION_3_0) && stage == 15) ||
+				    (safariVersion >= SAFARI_VERSION_3_0 && stage == 13) ) {
 			NSBundle *bundle = [GrowlSafari bundle];
 			NSString *notificationName = isLongDownload(self) ? NSLocalizedStringFromTableInBundle(@"Download Complete", nil, bundle, @"") : NSLocalizedStringFromTableInBundle(@"Short Download Complete", nil, bundle, @"");
 			setDownloadFinished(self);
 			NSString *description = [[NSString alloc] initWithFormat:
-				NSLocalizedStringFromTableInBundle(@"%@ download complete", nil, bundle, "Message shown when a download is complete, where %@ becomes the filename"),
+				NSLocalizedStringFromTableInBundle(@"%@", nil, bundle, "Message shown when a download is complete, where %@ becomes the filename"),
 				[self filename]];
 			[GrowlApplicationBridge notifyWithTitle:NSLocalizedStringFromTableInBundle(@"Download Complete", nil, bundle, @"")
 										description:description
 	//NSLog(@"myUpdateDiskImageStatus:%@ stage=%d -> %d", status, oldStage, [self downloadStage]);
 
 	if (dateStarted(self)
-			&& oldStage == 3
+			&& ( (safariVersion < SAFARI_VERSION_3_0 && oldStage == 3) || (safariVersion >= SAFARI_VERSION_3_0 && oldStage == 7) )
 			&& [self downloadStage] == 8
 			&& [[status objectForKey:@"status-stage"] isEqualToString:@"attach"]) {
 		NSBundle *bundle = [GrowlSafari bundle];
 		NSString *description = [[NSString alloc] initWithFormat:
-			NSLocalizedStringFromTableInBundle(@"Mounting %@", nil, bundle, @""),
-			[[self downloadPath] lastPathComponent]];
+			NSLocalizedStringFromTableInBundle(@"%@", nil, bundle, @""),
+			[[self gsDownloadPath] lastPathComponent]];
 		[GrowlApplicationBridge notifyWithTitle:NSLocalizedStringFromTableInBundle(@"Mounting Disk Image", nil, bundle, @"")
 									description:description
 							   notificationName:NSLocalizedStringFromTableInBundle(@"Disk Image Status", nil, bundle, @"")
 	setDownloadStarted(self);
 	return retval;
 }
+
+- (NSString*) gsDownloadPath {
+	if (safariVersion<SAFARI_VERSION_3_0)
+		return [self downloadPath];
+	else
+		return [self currentPath];
+}
+
 @end

File Extras/GrowlSafari/GrowlSafari.xcodeproj/project.pbxproj

 				95AE27A2085C451A00271F5F /* GrowlHelperApp.app */,
 				95AE27A4085C451A00271F5F /* GrowlMenu.app */,
 				95AE27A6085C451A00271F5F /* Growl.framework */,
-				34CD98990C87C93F0040C77F /* Growl.dylib.dylib */,
+				34CD98990C87C93F0040C77F /* Growl.dylib */,
 				95AE27A8085C451A00271F5F /* Growl-WithInstaller.framework */,
 				95AE27AA085C451A00271F5F /* Speech.growlView */,
 				95AE27AC085C451A00271F5F /* Brushed.growlView */,
 /* End PBXProject section */
 
 /* Begin PBXReferenceProxy section */
-		34CD98990C87C93F0040C77F /* Growl.dylib.dylib */ = {
+		34CD98990C87C93F0040C77F /* Growl.dylib */ = {
 			isa = PBXReferenceProxy;
 			fileType = "compiled.mach-o.dylib";
-			path = Growl.dylib.dylib;
+			path = Growl.dylib;
 			remoteRef = 34CD98980C87C93F0040C77F /* PBXContainerItemProxy */;
 			sourceTree = BUILT_PRODUCTS_DIR;
 		};
 					ppc,
 					i386,
 				);
+				GCC_ENABLE_OBJC_GC = YES;
 				MACOSX_DEPLOYMENT_TARGET = 10.4;
 				SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
 			};