Fixed context-messages showing up even if logging is entirely disabled. Fixes #12577.
1.1 --- a/Source/DCMessageContextDisplayPlugin.m Tue Aug 16 22:17:08 2011 +0200
1.2 +++ b/Source/DCMessageContextDisplayPlugin.m Tue Aug 16 22:39:53 2011 +0200
1.3 @@ -73,11 +73,12 @@
1.4
1.5 //Setup our preferences
1.6 [adium.preferenceController registerDefaults:[NSDictionary dictionaryNamed:CONTEXT_DISPLAY_DEFAULTS
1.7 - forClass:[self class]]
1.8 - forGroup:PREF_GROUP_CONTEXT_DISPLAY];
1.9 + forClass:[self class]]
1.10 + forGroup:PREF_GROUP_CONTEXT_DISPLAY];
1.11
1.12 //Observe preference changes for whether or not to display message history
1.13 [adium.preferenceController registerPreferenceObserver:self forGroup:PREF_GROUP_CONTEXT_DISPLAY];
1.14 + [adium.preferenceController registerPreferenceObserver:self forGroup:PREF_GROUP_LOGGING];
1.15
1.16 sharedInstance = self;
1.17 }
1.18 @@ -94,17 +95,25 @@
1.19 - (void)preferencesChangedForGroup:(NSString *)group key:(NSString *)key
1.20 object:(AIListObject *)object preferenceDict:(NSDictionary *)prefDict firstTime:(BOOL)firstTime
1.21 {
1.22 - if (!object) {
1.23 - shouldDisplay = [[prefDict objectForKey:KEY_DISPLAY_CONTEXT] boolValue];
1.24 - linesToDisplay = [[prefDict objectForKey:KEY_DISPLAY_LINES] integerValue];
1.25 -
1.26 + if (!object) {
1.27 + if ([group isEqualToString:PREF_GROUP_LOGGING]) {
1.28 + shouldDisplay = [[prefDict objectForKey:KEY_LOGGER_ENABLE] boolValue]
1.29 + && [[adium.preferenceController preferenceForKey:KEY_DISPLAY_CONTEXT
1.30 + group:PREF_GROUP_CONTEXT_DISPLAY] boolValue];
1.31 + } else if ([group isEqualToString:PREF_GROUP_CONTEXT_DISPLAY]) {
1.32 + shouldDisplay = [[prefDict objectForKey:KEY_DISPLAY_CONTEXT] boolValue]
1.33 + && [[adium.preferenceController preferenceForKey:KEY_LOGGER_ENABLE
1.34 + group:PREF_GROUP_LOGGING] boolValue];
1.35 + linesToDisplay = [[prefDict objectForKey:KEY_DISPLAY_LINES] integerValue];
1.36 + }
1.37 +
1.38 if (shouldDisplay && linesToDisplay > 0 && !isObserving) {
1.39 //Observe new message windows only if we aren't already observing them
1.40 isObserving = YES;
1.41 [[NSNotificationCenter defaultCenter] addObserver:self
1.42 - selector:@selector(addContextDisplayToWindow:)
1.43 - name:Chat_DidOpen
1.44 - object:nil];
1.45 + selector:@selector(addContextDisplayToWindow:)
1.46 + name:Chat_DidOpen
1.47 + object:nil];
1.48
1.49 } else if (isObserving && (!shouldDisplay || linesToDisplay <= 0)) {
1.50 //Remove observer