Add %incomingColor% and %outgoingColor%, remove %senderColor% in headers. Fixes #12666.
This also should speed up significantly message display for styles that don't specify a custom set of colors, since we won't be querying the file for every message any longer.
1.1 --- a/Plugins/WebKit Message View/AIWebkitMessageViewStyle.h Thu Oct 29 11:44:17 2009 -0400
1.2 +++ b/Plugins/WebKit Message View/AIWebkitMessageViewStyle.h Thu Oct 29 12:57:14 2009 -0400
1.3 @@ -103,6 +103,9 @@
1.4 BOOL transparentDefaultBackground;
1.5 BOOL allowsUserIcons;
1.6 BOOL usingCustomTemplateHTML;
1.7 +
1.8 + BOOL checkedSenderColors;
1.9 + NSArray *validSenderColors;
1.10
1.11 //Behavior
1.12 NSDateFormatter *timeStampFormatter;
1.13 @@ -236,6 +239,11 @@
1.14 */
1.15 @property (readonly, nonatomic) BOOL allowsColors;
1.16
1.17 +/*!
1.18 + * @brief The style's sender colors
1.19 + */
1.20 +@property (readonly, nonatomic) NSArray *validSenderColors;
1.21 +
1.22 //Behavior
1.23 /*!
1.24 * @brief Set the format of dates/time stamps
2.1 --- a/Plugins/WebKit Message View/AIWebkitMessageViewStyle.m Thu Oct 29 11:44:17 2009 -0400
2.2 +++ b/Plugins/WebKit Message View/AIWebkitMessageViewStyle.m Thu Oct 29 12:57:14 2009 -0400
2.3 @@ -55,8 +55,6 @@
2.4 // We set back, when the user finishes editing, the correct topic, which wipes out the existance of the span before. We don't need to undo the dbl click action.
2.5 #define TOPIC_INDIVIDUAL_WRAPPER @"<span id=\"topicEdit\" ondblclick=\"this.setAttribute('contentEditable', true); this.focus();\">%@</span>"
2.6
2.7 -static NSArray *validSenderColors;
2.8 -
2.9 @interface NSMutableString (AIKeywordReplacementAdditions)
2.10 - (void) replaceKeyword:(NSString *)word withString:(NSString *)newWord;
2.11 - (void) safeReplaceCharactersInRange:(NSRange)range withString:(NSString *)newWord;
2.12 @@ -247,6 +245,21 @@
2.13
2.14 @synthesize allowsCustomBackground, allowsUserIcons, allowsColors, userIconMask;
2.15
2.16 +- (NSArray *)validSenderColors
2.17 +{
2.18 + if(!checkedSenderColors) {
2.19 + NSURL *url = [NSURL fileURLWithPath:[stylePath stringByAppendingPathComponent:@"Incoming/SenderColors.txt"]];
2.20 + NSString *senderColorsFile = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:NULL];
2.21 +
2.22 + if(senderColorsFile)
2.23 + validSenderColors = [[senderColorsFile componentsSeparatedByString:@":"] retain];
2.24 +
2.25 + checkedSenderColors = YES;
2.26 + }
2.27 +
2.28 + return validSenderColors;
2.29 +}
2.30 +
2.31 - (BOOL)isBackgroundTransparent
2.32 {
2.33 //Our custom background is only transparent if the user has set a custom color with an alpha component less than 1.0
2.34 @@ -776,15 +789,8 @@
2.35 [inString replaceKeyword:@"%messageClasses%"
2.36 withString:[(contentIsSimilar ? @"consecutive " : @"") stringByAppendingString:[[content displayClasses] componentsJoinedByString:@" "]]];
2.37
2.38 - if(!validSenderColors) {
2.39 - NSURL *url = [NSURL fileURLWithPath:[stylePath stringByAppendingPathComponent:@"Incoming/SenderColors.txt"]];
2.40 - NSString *senderColorsFile = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:NULL];
2.41 -
2.42 - if(senderColorsFile)
2.43 - validSenderColors = [[senderColorsFile componentsSeparatedByString:@":"] retain];
2.44 - }
2.45 [inString replaceKeyword:@"%senderColor%"
2.46 - withString:[NSColor representedColorForObject:contentSource.UID withValidColors:validSenderColors]];
2.47 + withString:[NSColor representedColorForObject:contentSource.UID withValidColors:self.validSenderColors]];
2.48
2.49 //HAX. The odd conditional here detects the rtl html that our html parser spits out.
2.50 [inString replaceKeyword:@"%messageDirection%"
2.51 @@ -1149,8 +1155,11 @@
2.52 AIListContact *listObject = chat.listObject;
2.53 NSString *iconPath = nil;
2.54
2.55 - [inString replaceKeyword:@"%senderColor%"
2.56 - withString:[NSColor representedColorForObject:listObject.UID withValidColors:validSenderColors]];
2.57 + [inString replaceKeyword:@"%incomingColor%"
2.58 + withString:[NSColor representedColorForObject:listObject.UID withValidColors:self.validSenderColors]];
2.59 +
2.60 + [inString replaceKeyword:@"%outgoingColor%"
2.61 + withString:[NSColor representedColorForObject:chat.account.UID withValidColors:self.validSenderColors]];
2.62
2.63 if (listObject) {
2.64 iconPath = [listObject valueForProperty:KEY_WEBKIT_USER_ICON];