Skip to content

Commit

Permalink
major oopsies fixed; log spew removed, prefs are honored immediately …
Browse files Browse the repository at this point in the history
…instead of upon next launch, fixed problems with sparkle updating and sIFR prefs not working
  • Loading branch information
Simone Manganelli authored and Simone Manganelli committed Jun 25, 2009
1 parent 030877d commit 488ee14
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 11 deletions.
1 change: 1 addition & 0 deletions Plugin/CTFPreferencesDictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

@interface CTFPreferencesDictionary : NSMutableDictionary {
NSMutableDictionary *realMutableDictionary;
BOOL hasInited;
}

@end
26 changes: 22 additions & 4 deletions Plugin/CTFPreferencesDictionary.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#import "CTFPreferencesDictionary.h"

static CTFPreferencesDictionary *sharedInstance = nil;

@implementation CTFPreferencesDictionary

Expand All @@ -21,19 +22,36 @@ + (id)dictionaryWithDictionary:(NSDictionary *)otherDictionary;
return [[CTFPreferencesDictionary alloc] initWithDictionary:otherDictionary];
}

+ (id)allocWithZone:(NSZone *)zone;
{
if (sharedInstance) {
return [sharedInstance retain];
} else {
return [super allocWithZone:zone];
}
}

- (id)init;
{
if ((self = [super init])) {
realMutableDictionary = [[NSMutableDictionary alloc] init];
if (! sharedInstance) {
if ((self = [super init])) {
realMutableDictionary = [[NSMutableDictionary alloc] init];
hasInited = YES;
}
}

return self;
}

- (id)initWithDictionary:(NSDictionary *)otherDictionary;
{
if ((self = [super init])) {
realMutableDictionary = [[NSMutableDictionary dictionaryWithDictionary:otherDictionary] retain];
if (! sharedInstance) {
if ((self = [super init])) {
realMutableDictionary = [[NSMutableDictionary dictionaryWithDictionary:otherDictionary] retain];
hasInited = YES;
}
} else {
[sharedInstance setDictionary:otherDictionary];
}

return self;
Expand Down
13 changes: 12 additions & 1 deletion Plugin/CTFUserDefaultsController.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ + (CTFUserDefaultsController *)standardUserDefaults;
return sharedInstance;
}

+ (id)allocWithZone:(NSZone *)zone;
{
if (sharedInstance) {
return [sharedInstance retain];
} else {
return [super allocWithZone:zone];
}
}

- (id)init;
{
if (! sharedInstance) {
Expand Down Expand Up @@ -56,7 +65,9 @@ - (CTFPreferencesDictionary *)values;
// and if that call detects that the user defaults dictionary hasn't
// been set up yet, it sets it up and *then* returns the values

if (! userDefaultsDict) [self setUpExternalPrefsDictionary];
if (! userDefaultsDict) {
[self setUpExternalPrefsDictionary];
}
return userDefaultsDict;
}

Expand Down
2 changes: 1 addition & 1 deletion Plugin/CTFsIFRSupport.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ of this software and associated documentation files (the "Software"), to deal
CTFSifrModeDeSifr = 2
} CTFSifrMode;

static NSString *sSifrModeDefaultsKey = @"ClickToFlash_sifrMode";
static NSString *sSifrModeDefaultsKey = @"sifrMode";

static NSString *sSifr2Test = @"sIFR != null && typeof sIFR == \"function\"";
static NSString *sSifr3Test = @"sIFR != null && typeof sIFR == \"object\"";
Expand Down
4 changes: 0 additions & 4 deletions Plugin/Plugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,11 @@ - (id) initWithArguments:(NSDictionary *)arguments
self = [super init];
if (self) {
[[NSUserDefaults standardUserDefaults] addSuiteNamed:@"com.github.rentzsch.clicktoflash"];
NSLog(@"ummmm0");
SparkleManager *sharedSparkleManager = [SparkleManager sharedManager];
NSWorkspace *sharedWorkspace = [NSWorkspace sharedWorkspace];
NSString *pathToRelaunch = [sharedWorkspace absolutePathForAppBundleWithIdentifier:[self launchedAppBundleIdentifier]];
[sharedSparkleManager setPathToRelaunch:pathToRelaunch];
[sharedSparkleManager startAutomaticallyCheckingForUpdates];
NSLog(@"ummmm");
if (![[CTFUserDefaultsController standardUserDefaults] objectForKey:sAutoLoadInvisibleFlashViewsKey]) {
// Default to auto-loading invisible flash views.
[[CTFUserDefaultsController standardUserDefaults] setBool:YES forKey:sAutoLoadInvisibleFlashViewsKey];
Expand All @@ -119,7 +117,6 @@ - (id) initWithArguments:(NSDictionary *)arguments
// Default to enable the plugin
[[CTFUserDefaultsController standardUserDefaults] setBool:YES forKey:sPluginEnabled];
}
NSLog(@"ummmm2");
[self setLaunchedAppBundleIdentifier:[self launchedAppBundleIdentifier]];

[self setWebView:[[[arguments objectForKey:WebPlugInContainerKey] webFrame] webView]];
Expand Down Expand Up @@ -384,7 +381,6 @@ - (void)_migratePrefsToExternalFile
unsigned int i;
for (i = 0; i < [parasiticDefaultsNameArray count]; i++) {
NSString *currentParasiticDefault = [parasiticDefaultsNameArray objectAtIndex:i];
NSLog(@"sending objectForKey: to a CTFUserDefaultsController");
id prefValue = [[NSUserDefaults standardUserDefaults] objectForKey:currentParasiticDefault];
if (prefValue) {
[externalFileDefaults setObject:prefValue forKey:[externalDefaultsNameArray objectAtIndex:i]];
Expand Down
2 changes: 1 addition & 1 deletion Plugin/SparkleManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ of this software and associated documentation files (the "Software"), to deal
#import "CTFPreferencesDictionary.h"

// NSUserDefaults keys
static NSString *sAutomaticallyCheckForUpdates = @"ClickToFlash_checkForUpdatesOnFirstLoad";
static NSString *sAutomaticallyCheckForUpdates = @"checkForUpdatesOnFirstLoad";

@implementation SparkleManager

Expand Down

0 comments on commit 488ee14

Please sign in to comment.