Don't post a notification when the stream gives us a meaningless change that won't show up in the notification. Fixes GrowlTunes spamming the user when iTunes is playing a Live365 stream.
authorPeter Hosey <hg@boredzo.org>
Fri Aug 14 10:55:41 2009 -0700 (2009-08-14)
changeset 42885f22e70ed081
parent 4287 c6a0bfc2f06a
child 4289 f3197c12c013
Don't post a notification when the stream gives us a meaningless change that won't show up in the notification. Fixes GrowlTunes spamming the user when iTunes is playing a Live365 stream.
Extras/GrowlTunes/GrowlTunesController.h
Extras/GrowlTunes/GrowlTunesController.m
     1.1 --- a/Extras/GrowlTunes/GrowlTunesController.h	Fri Aug 14 10:27:40 2009 -0700
     1.2 +++ b/Extras/GrowlTunes/GrowlTunesController.h	Fri Aug 14 10:55:41 2009 -0700
     1.3 @@ -58,6 +58,7 @@
     1.4  	double				pollInterval;
     1.5  	int					trackID;
     1.6  	NSString			*trackURL;		//The file location of the last-known track in iTunes, @"" for none
     1.7 +	NSString			*lastPostedDescription;
     1.8  	int					trackRating;
     1.9  }
    1.10  
     2.1 --- a/Extras/GrowlTunes/GrowlTunesController.m	Fri Aug 14 10:27:40 2009 -0700
     2.2 +++ b/Extras/GrowlTunes/GrowlTunesController.m	Fri Aug 14 10:55:41 2009 -0700
     2.3 @@ -504,7 +504,10 @@
     2.4  			nil];
     2.5  		[displayString release];
     2.6  
     2.7 -		if (![newTrackURL isEqualToString:trackURL] || [newTrackURL hasPrefix:@"http://"]) { // this is different from previous notification, or it's a stream
     2.8 +		BOOL URLChanged = [newTrackURL isEqualToString:trackURL];
     2.9 +		BOOL isStream = [newTrackURL hasPrefix:@"http://"];
    2.10 +		BOOL descriptionChanged = !(lastPostedDescription && [lastPostedDescription isEqualToString:displayString]);
    2.11 +		if (URLChanged || (isStream && descriptionChanged)) {
    2.12  			// Tell Growl
    2.13  			[GrowlApplicationBridge notifyWithDictionary:noteDict];
    2.14  
    2.15 @@ -521,6 +524,8 @@
    2.16  		state = newState;
    2.17  		[trackURL release];
    2.18  		trackURL = [newTrackURL retain];
    2.19 +		[lastPostedDescription release];
    2.20 +		lastPostedDescription = [displayString retain];
    2.21  	}
    2.22  }
    2.23