Skip to content

Commit

Permalink
whitelist table now auto-updates when a CtF view adds something to th…
Browse files Browse the repository at this point in the history
…e whitelist

Signed-off-by: Jonathan 'Wolf' Rentzsch <jwr.git@redshed.net>
  • Loading branch information
Simone Manganelli authored and rentzsch committed Jul 1, 2009
1 parent 2a7423a commit a87d6f3
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 33 deletions.
17 changes: 16 additions & 1 deletion Plugin/CTFUserDefaultsController.m
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ - (id)init;
return self;
}

- (id)initWithCoder:(NSCoder *)decoder;
{
if (! sharedInstance) {
if ((self = [super init])) {
hasInited = YES;
}
}

return self;
}

- (void)dealloc;
{
[userDefaultsDict release];
Expand All @@ -50,9 +61,11 @@ - (void)setUpExternalPrefsDictionary;
selector:@selector(pluginDefaultsDidChange:)
name:@"ClickToFlashPluginDefaultsDidChange"
object:nil];
[[NSUserDefaults standardUserDefaults] addSuiteNamed:@"com.github.rentzsch.clicktoflash"];
[self setValues:[CTFPreferencesDictionary dictionaryWithDictionary:
[[NSUserDefaults standardUserDefaults] persistentDomainForName:@"com.github.rentzsch.clicktoflash"]]
];
[[NSUserDefaults standardUserDefaults] removeSuiteNamed:@"com.github.rentzsch.clicktoflash"];
}

- (CTFPreferencesDictionary *)values;
Expand All @@ -78,9 +91,11 @@ - (CTFPreferencesDictionary *)dictionaryRepresentation;

- (void)setValues:(CTFPreferencesDictionary *)newUserDefaultsDict;
{
CTFPreferencesDictionary *newDictCopy = [newUserDefaultsDict copy];
if (! userDefaultsDict) userDefaultsDict = [[CTFPreferencesDictionary alloc] init];
[userDefaultsDict removeAllObjects];
[userDefaultsDict addEntriesFromDictionary:newUserDefaultsDict];
[userDefaultsDict addEntriesFromDictionary:newDictCopy];
[newDictCopy release];
}

- (void)pluginDefaultsDidChange:(NSNotification *)notification;
Expand Down
6 changes: 5 additions & 1 deletion Plugin/CTFWhitelist.m
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ - (void) _addHostToWhitelist
{
NSMutableArray *siteInfo = [self _mutableSiteInfo];
[siteInfo addObject: whitelistItemForSite([self host])];
[[CTFUserDefaultsController standardUserDefaults] setObject: siteInfo forKey: sHostSiteInfoDefaultsKey];

[[CTFUserDefaultsController standardUserDefaults] setValue:siteInfo forKeyPath:@"values.siteInfo"];
//[values setObject:siteInfo forKey:sHostSiteInfoDefaultsKey];
//[[CTFUserDefaultsController standardUserDefaults] setValues:values];

[[NSNotificationCenter defaultCenter] postNotificationName: sCTFWhitelistAdditionMade object: self];
}

Expand Down
62 changes: 31 additions & 31 deletions Plugin/English.lproj/WhitelistPanel.xib
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="9"/>
<integer value="12"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -1245,35 +1245,6 @@ dG8gdW5pbnN0YWxsIENsaWNrVG9GbGFzaC4</string>
</object>
<int key="connectionID">115</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">value: arrangedObjects.site</string>
<reference key="source" ref="360546441"/>
<reference key="destination" ref="258102979"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="360546441"/>
<reference key="NSDestination" ref="258102979"/>
<string key="NSLabel">value: arrangedObjects.site</string>
<string key="NSBinding">value</string>
<string key="NSKeyPath">arrangedObjects.site</string>
<object class="NSDictionary" key="NSOptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSAllowsEditingMultipleValuesSelection</string>
<string>NSNullPlaceholder</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="8"/>
<string>double-click to set</string>
</object>
</object>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">130</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">checkForUpdates:</string>
Expand Down Expand Up @@ -1490,6 +1461,35 @@ dG8gdW5pbnN0YWxsIENsaWNrVG9GbGFzaC4</string>
</object>
<int key="connectionID">251</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">value: arrangedObjects.site</string>
<reference key="source" ref="360546441"/>
<reference key="destination" ref="258102979"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="360546441"/>
<reference key="NSDestination" ref="258102979"/>
<string key="NSLabel">value: arrangedObjects.site</string>
<string key="NSBinding">value</string>
<string key="NSKeyPath">arrangedObjects.site</string>
<object class="NSDictionary" key="NSOptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSAllowsEditingMultipleValuesSelection</string>
<string>NSNullPlaceholder</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="6"/>
<string>double-click to set</string>
</object>
</object>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">256</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
Expand Down Expand Up @@ -2461,7 +2461,7 @@ dG8gdW5pbnN0YWxsIENsaWNrVG9GbGFzaC4</string>
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">252</int>
<int key="maxID">256</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand Down
2 changes: 2 additions & 0 deletions Plugin/Plugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ - (void) _migratePrefsToExternalFile

NSMutableDictionary *externalFileDefaults = [[CTFUserDefaultsController standardUserDefaults] dictionaryRepresentation];

[[NSUserDefaults standardUserDefaults] addSuiteNamed:@"com.github.rentzsch.clicktoflash"];
unsigned int i;
for (i = 0; i < [parasiticDefaultsNameArray count]; i++) {
NSString *currentParasiticDefault = [parasiticDefaultsNameArray objectAtIndex:i];
Expand All @@ -440,6 +441,7 @@ - (void) _migratePrefsToExternalFile
[[NSUserDefaults standardUserDefaults] removeObjectForKey:currentParasiticDefault];
}
}
[[NSUserDefaults standardUserDefaults] removeSuiteNamed:@"com.github.rentzsch.clicktoflash"];
}

- (void) _addApplicationWhitelistArrayToPrefsFile
Expand Down

0 comments on commit a87d6f3

Please sign in to comment.