Add a "Default font remover" plugin. Refs #12906 (though really fixes it).
This restores our pre-Snow Leopard behavior of sending plaintext when our defualt default font is specified. This also removes the white background Snow Leopard gives us for the attributed string, which would cause it to be sent for every message as well.
The only 'gotcha' here is that, for example, Helvetica-Oblique (italics) is a different actual font than Helvetica. At this point I'm more or less okay with this behavior.
1.1 --- a/Adium.xcodeproj/project.pbxproj Wed Oct 28 03:09:37 2009 -0700
1.2 +++ b/Adium.xcodeproj/project.pbxproj Wed Oct 28 10:44:02 2009 -0400
1.3 @@ -56,6 +56,7 @@
1.4 0CD3C3AD0C43C8CC003E637C /* NSWindowScriptingAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CD3C3AB0C43C8CC003E637C /* NSWindowScriptingAdditions.m */; };
1.5 0CD41C710C2776550082F83B /* AICreateCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CD41C6F0C2776550082F83B /* AICreateCommand.m */; };
1.6 0CFA98C90D35C18000A077C6 /* NSDataAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CFA98C70D35C18000A077C6 /* NSDataAdditions.m */; };
1.7 + 11000D041098863B0096A1E2 /* AIDefaultFontRemovalPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 11000D031098863B0096A1E2 /* AIDefaultFontRemovalPlugin.m */; };
1.8 110763F608676CC9005987A5 /* RAFBlockEditorPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 110763F208676CC9005987A5 /* RAFBlockEditorPlugin.m */; };
1.9 110763F808676CC9005987A5 /* RAFBlockEditorWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 110763F408676CC9005987A5 /* RAFBlockEditorWindowController.m */; };
1.10 110763FA08676D05005987A5 /* BlockEditorWindow.nib in Resources */ = {isa = PBXBuildFile; fileRef = 110763F908676D04005987A5 /* BlockEditorWindow.nib */; };
1.11 @@ -1785,6 +1786,8 @@
1.12 0CD41C6F0C2776550082F83B /* AICreateCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AICreateCommand.m; path = Source/AICreateCommand.m; sourceTree = "<group>"; };
1.13 0CFA98C60D35C18000A077C6 /* NSDataAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NSDataAdditions.h; path = Source/NSDataAdditions.h; sourceTree = "<group>"; };
1.14 0CFA98C70D35C18000A077C6 /* NSDataAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NSDataAdditions.m; path = Source/NSDataAdditions.m; sourceTree = "<group>"; };
1.15 + 11000D021098863B0096A1E2 /* AIDefaultFontRemovalPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIDefaultFontRemovalPlugin.h; path = Source/AIDefaultFontRemovalPlugin.h; sourceTree = "<group>"; };
1.16 + 11000D031098863B0096A1E2 /* AIDefaultFontRemovalPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIDefaultFontRemovalPlugin.m; path = Source/AIDefaultFontRemovalPlugin.m; sourceTree = "<group>"; };
1.17 110763F108676CC9005987A5 /* RAFBlockEditorPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RAFBlockEditorPlugin.h; path = Source/RAFBlockEditorPlugin.h; sourceTree = "<group>"; };
1.18 110763F208676CC9005987A5 /* RAFBlockEditorPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RAFBlockEditorPlugin.m; path = Source/RAFBlockEditorPlugin.m; sourceTree = "<group>"; };
1.19 110763F308676CC9005987A5 /* RAFBlockEditorWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RAFBlockEditorWindowController.h; path = Source/RAFBlockEditorWindowController.h; sourceTree = "<group>"; };
1.20 @@ -4887,6 +4890,15 @@
1.21 name = Localized;
1.22 sourceTree = "<group>";
1.23 };
1.24 + 11000CFE109886010096A1E2 /* Removal of Helvetica@12 */ = {
1.25 + isa = PBXGroup;
1.26 + children = (
1.27 + 11000D021098863B0096A1E2 /* AIDefaultFontRemovalPlugin.h */,
1.28 + 11000D031098863B0096A1E2 /* AIDefaultFontRemovalPlugin.m */,
1.29 + );
1.30 + name = "Removal of Helvetica@12";
1.31 + sourceTree = "<group>";
1.32 + };
1.33 111E89030F93FE3B00A5F18B /* IRC */ = {
1.34 isa = PBXGroup;
1.35 children = (
1.36 @@ -5880,6 +5892,7 @@
1.37 F1D0C631051AC2380000000E /* Message Alias Support */,
1.38 6E5A43DC0611604B0078C342 /* Message History */,
1.39 F569E38102CA876501A8010A /* Message Window Interface */,
1.40 + 11000CFE109886010096A1E2 /* Removal of Helvetica@12 */,
1.41 343022240AB4763D0082CF7C /* Removal of NULs in Messages */,
1.42 34A65AF606A5A0C400898470 /* Safari Link Toolbar Item */,
1.43 34DFF46607A5EAC800B92233 /* Secure Messaging */,
1.44 @@ -10554,6 +10567,7 @@
1.45 1197F6710FCF8D180032F19B /* AITwitterStatusFollowup.m in Sources */,
1.46 112939100FD5AE1400FA8F53 /* AIConfirmationsAdvancedPreferences.m in Sources */,
1.47 11D915720FFC100700B39713 /* AIGenericMultipartImageUploader.m in Sources */,
1.48 + 11000D041098863B0096A1E2 /* AIDefaultFontRemovalPlugin.m in Sources */,
1.49 );
1.50 runOnlyForDeploymentPostprocessing = 0;
1.51 };
2.1 --- a/Source/AICoreComponentLoader.m Wed Oct 28 03:09:37 2009 -0700
2.2 +++ b/Source/AICoreComponentLoader.m Wed Oct 28 10:44:02 2009 -0400
2.3 @@ -142,6 +142,7 @@
2.4 @"OWSpellingPerContactPlugin",
2.5 @"GBQuestionHandlerPlugin",
2.6 @"AINulRemovalPlugin",
2.7 + @"AIDefaultFontRemovalPlugin",
2.8 @"AIAdvancedPreferencesPlugin",
2.9 @"GBImportPlugin",
2.10 @"AIMentionEventPlugin",
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/Source/AIDefaultFontRemovalPlugin.h Wed Oct 28 10:44:02 2009 -0400
3.3 @@ -0,0 +1,25 @@
3.4 +//
3.5 +// AIDefaultFontRemoval.h
3.6 +// Adium
3.7 +//
3.8 +// Created by Zachary West on 2009-10-28.
3.9 +// Copyright 2009 . All rights reserved.
3.10 +//
3.11 +
3.12 +#import <Adium/AIContentControllerProtocol.h>
3.13 +
3.14 +/*!
3.15 + * @class AIDefaultFontRemoval
3.16 + *
3.17 + * This class removes the default (as in, shipping with Adium) font attributes
3.18 + * for a given outgoing message. This restores a "plaintext" default for messages.
3.19 + *
3.20 + * The basic effect is that Helvetica sized 12 (set in FormattingDefaults.plist) is
3.21 + * stripped from outgoing messages, along with any background coloring if no foreground
3.22 + * is specified.
3.23 + */
3.24 +@interface AIDefaultFontRemovalPlugin : AIPlugin <AIContentFilter> {
3.25 + NSDictionary *defaultRemovedAttributes;
3.26 +}
3.27 +
3.28 +@end
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/Source/AIDefaultFontRemovalPlugin.m Wed Oct 28 10:44:02 2009 -0400
4.3 @@ -0,0 +1,78 @@
4.4 +//
4.5 +// AIDefaultFontRemoval.m
4.6 +// Adium
4.7 +//
4.8 +// Created by Zachary West on 2009-10-28.
4.9 +// Copyright 2009 . All rights reserved.
4.10 +//
4.11 +
4.12 +#import "AIDefaultFontRemovalPlugin.h"
4.13 +#import <AIUtilities/AIFontAdditions.h>
4.14 +#import <AIUtilities/AIColorAdditions.h>
4.15 +
4.16 +@implementation AIDefaultFontRemovalPlugin
4.17 +- (void)installPlugin
4.18 +{
4.19 + // We only monitor outgoing messages.
4.20 + [adium.contentController registerContentFilter:self ofType:AIFilterContent direction:AIFilterOutgoing];
4.21 +}
4.22 +
4.23 +- (void)uninstallPlugin
4.24 +{
4.25 + [adium.contentController unregisterContentFilter:self];
4.26 +}
4.27 +
4.28 +- (void)dealloc
4.29 +{
4.30 + [defaultRemovedAttributes release];
4.31 + [super dealloc];
4.32 +}
4.33 +
4.34 +- (NSAttributedString *)filterAttributedString:(NSAttributedString *)inAttributedString context:(id)context
4.35 +{
4.36 + if (!inAttributedString || ![inAttributedString length]) return inAttributedString;
4.37 +
4.38 + NSMutableAttributedString *mutableString = [inAttributedString mutableCopy];
4.39 +
4.40 + if (!defaultRemovedAttributes) {
4.41 + NSFont *defaultFont = [[adium.preferenceController defaultPreferenceForKey:KEY_FORMATTING_FONT
4.42 + group:PREF_GROUP_FORMATTING
4.43 + object:nil] representedFont];
4.44 +
4.45 + defaultRemovedAttributes = [[NSDictionary dictionaryWithObjectsAndKeys:
4.46 + defaultFont, NSFontAttributeName,
4.47 + [NSColor colorWithCalibratedRed:1.0 green:1.0 blue:1.0 alpha:1.0], NSBackgroundColorAttributeName,
4.48 + nil] retain];
4.49 + }
4.50 +
4.51 + for (NSString *attributeName in defaultRemovedAttributes.allKeys) {
4.52 + NSUInteger position = 0;
4.53 +
4.54 + while (position < mutableString.length) {
4.55 + NSRange attributeRange;
4.56 + id attributeValue = [mutableString attribute:attributeName
4.57 + atIndex:position
4.58 + effectiveRange:&attributeRange];
4.59 +
4.60 + if (attributeValue && [attributeValue isEqualTo:[defaultRemovedAttributes objectForKey:attributeName]]) {
4.61 + [mutableString removeAttribute:attributeName range:attributeRange];
4.62 + }
4.63 +
4.64 + position += attributeRange.length;
4.65 + }
4.66 + }
4.67 +
4.68 + return [mutableString autorelease];
4.69 +}
4.70 +
4.71 +/*!
4.72 + * @brief When should this run?
4.73 + *
4.74 + * We want this font removal to occur as early as possible, in case any other filters try and modify the fonts.
4.75 + */
4.76 +- (CGFloat)filterPriority
4.77 +{
4.78 + return HIGHEST_FILTER_PRIORITY;
4.79 +}
4.80 +
4.81 +@end