Plugins/WebKit Message View/AIWebkitMessageViewStyle.m
author Thijs Alkemade <me@thijsalkema.de>
Wed, 30 Oct 2013 18:34:07 +0100
branchadium-1.5.9
changeset 5749 1521cab508bf
parent 5722 4ae85ad012cd
child 5754 d605bb303e32
permissions -rw-r--r--
Fix Adium not storing timestamps with messages. Setting NSDateFormatterBehavior10_4 was not the solution, all included time format strings are now 10.4 style.

Message styles can still contain old style format strings, causing _NSDateFormatter_Log_New_Methods_On_Old_Formatters to be hit. We probably need to update the included ones and deprecate their usage in Adium.
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     1
/* 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     2
 * Adium is the legal property of its developers, whose names are listed in the copyright file included
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     3
 * with this source distribution.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     4
 * 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     6
 * General Public License as published by the Free Software Foundation; either version 2 of the License,
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     7
 * or (at your option) any later version.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     8
 * 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    10
 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    11
 * Public License for more details.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    12
 * 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    13
 * You should have received a copy of the GNU General Public License along with this program; if not,
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    14
 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    15
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    16
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    17
#import "AIWebkitMessageViewStyle.h"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    18
#import <AIUtilities/AIColorAdditions.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    19
#import <AIUtilities/AIStringAdditions.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    20
#import <AIUtilities/AIDateFormatterAdditions.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    21
#import <AIUtilities/AIMutableStringAdditions.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    22
#import <Adium/AIAccount.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    23
#import <Adium/AIChat.h>
1292
761b05dfd208 Add a Topic template for message styles, which gets added into a <div> with id "topic" in group chats. Authors should do something like: <div contentEditable>%message%</div> (or span, or whatever) so that (in a future commit) topics can be edited. The substitutions are the same for AIContentMessages. %sender% could be nil, however, on initial join.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
    24
#import <Adium/AIContentTopic.h>
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    25
#import <Adium/AIContentContext.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    26
#import <Adium/AIContentMessage.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    27
#import <Adium/AIContentNotification.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    28
#import <Adium/AIContentObject.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    29
#import <Adium/AIContentStatus.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    30
#import <Adium/AIHTMLDecoder.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    31
#import <Adium/AIListObject.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    32
#import <Adium/AIListContact.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    33
#import <Adium/AIService.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    34
#import <Adium/ESFileTransfer.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    35
#import <Adium/AIServiceIcons.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    36
#import <Adium/AIContentControllerProtocol.h>
547
2cd9451c7831 Rather than importing the semi-frequently-updated AIStatus.h in AIListObject.h, use @class and only import AIStatusDefines.h
David Smith
parents: 524
diff changeset
    37
#import <Adium/AIStatusIcons.h>
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    38
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    39
//
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    40
#define LEGACY_VERSION_THRESHOLD		3	//Styles older than this version are considered legacy
3632
c7323a40d94f Added a MessageViewVersion_MinimumCompatible key to message style Info.plist keys. If set, Adium will refuse to load the style if it has a minimum version greater than its latest known version. This way, a message style which depends upon a hypothetical future version 5 message style can gracefully fail to load in Adium 1.4.2 which knows nothing of it; however, a message style using version 5 which is backwards compatible with version 4 can still be loaded. Fixes #7438 (for future iterations of the problem; nothing can be done for the described historical incompatibility).
Evan Schoenberg
parents: 3579
diff changeset
    41
#define MAX_KNOWN_WEBKIT_VERSION        4   //Styles newer than this version are unknown entities
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    42
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    43
//
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    44
#define KEY_WEBKIT_VERSION				@"MessageViewVersion"
3632
c7323a40d94f Added a MessageViewVersion_MinimumCompatible key to message style Info.plist keys. If set, Adium will refuse to load the style if it has a minimum version greater than its latest known version. This way, a message style which depends upon a hypothetical future version 5 message style can gracefully fail to load in Adium 1.4.2 which knows nothing of it; however, a message style using version 5 which is backwards compatible with version 4 can still be loaded. Fixes #7438 (for future iterations of the problem; nothing can be done for the described historical incompatibility).
Evan Schoenberg
parents: 3579
diff changeset
    45
#define KEY_WEBKIT_VERSION_MIN			@"MessageViewVersion_MinimumCompatible"
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    46
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    47
//BOM scripts for appending content.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    48
#define APPEND_MESSAGE_WITH_SCROLL		@"checkIfScrollToBottomIsNeeded(); appendMessage(\"%@\"); scrollToBottomIfNeeded();"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    49
#define APPEND_NEXT_MESSAGE_WITH_SCROLL	@"checkIfScrollToBottomIsNeeded(); appendNextMessage(\"%@\"); scrollToBottomIfNeeded();"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    50
#define APPEND_MESSAGE					@"appendMessage(\"%@\");"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    51
#define APPEND_NEXT_MESSAGE				@"appendNextMessage(\"%@\");"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    52
#define APPEND_MESSAGE_NO_SCROLL		@"appendMessageNoScroll(\"%@\");"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    53
#define	APPEND_NEXT_MESSAGE_NO_SCROLL	@"appendNextMessageNoScroll(\"%@\");"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    54
#define REPLACE_LAST_MESSAGE			@"replaceLastMessage(\"%@\");"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    55
1309
fc6e64704263 Only insert the topic <div> if the chat supports it. Change the "show header" option in the group chats prefpane to "show topic" and it does exactly what you think.
Zachary West <zacw@adiumx.com>
parents: 1308
diff changeset
    56
#define TOPIC_MAIN_DIV					@"<div id=\"topic\"></div>"
1484
07e08b4edcd1 Edit the topic on double click, not on single click. When we finish topic editing, we clear out this old span, so the new one that gets inserted won't be editable.
Zachary West <zacw@adiumx.com>
parents: 1452
diff changeset
    57
// 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.
07e08b4edcd1 Edit the topic on double click, not on single click. When we finish topic editing, we clear out this old span, so the new one that gets inserted won't be editable.
Zachary West <zacw@adiumx.com>
parents: 1452
diff changeset
    58
#define TOPIC_INDIVIDUAL_WRAPPER		@"<span id=\"topicEdit\" ondblclick=\"this.setAttribute('contentEditable', true); this.focus();\">%@</span>"
1292
761b05dfd208 Add a Topic template for message styles, which gets added into a <div> with id "topic" in group chats. Authors should do something like: <div contentEditable>%message%</div> (or span, or whatever) so that (in a future commit) topics can be edited. The substitutions are the same for AIContentMessages. %sender% could be nil, however, on initial join.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
    59
3092
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3087
diff changeset
    60
@interface NSString (NewSnowLeopardMethods)
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3087
diff changeset
    61
- (NSComparisonResult)localizedStandardCompare:(NSString *)string;
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3087
diff changeset
    62
@end
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3087
diff changeset
    63
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    64
@interface NSMutableString (AIKeywordReplacementAdditions)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    65
- (void) replaceKeyword:(NSString *)word withString:(NSString *)newWord;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    66
- (void) safeReplaceCharactersInRange:(NSRange)range withString:(NSString *)newWord;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    67
@end
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    68
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    69
@implementation NSMutableString (AIKeywordReplacementAdditions)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    70
- (void) replaceKeyword:(NSString *)keyWord withString:(NSString *)newWord
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    71
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    72
	if(!keyWord) return;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    73
	if(!newWord) newWord = @"";
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    74
	[self replaceOccurrencesOfString:keyWord
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    75
						  withString:newWord
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    76
							 options:NSLiteralSearch
3087
30703336e5b6 Resolve implicit 64->32 bit castings in Adium.app
Stephen Holt <sholt@adium.im>
parents: 3006
diff changeset
    77
							   range:NSMakeRange(0.0f, [self length])];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    78
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    79
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    80
- (void) safeReplaceCharactersInRange:(NSRange)range withString:(NSString *)newWord
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    81
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    82
	if (range.location == NSNotFound || range.length == 0) return;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    83
	if (!newWord) [self deleteCharactersInRange:range];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    84
	else [self replaceCharactersInRange:range withString:newWord];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    85
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    86
@end
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    87
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    88
//The old code built the paths itself, which follows the filesystem's case sensitivity, so some noobs named stuff wrong. 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    89
//NSBundle is always case sensitive, so those styles broke (they were already broken on case sensitive hfsx)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    90
//These methods only check for the all-lowercase variant, so are not suitable for general purpose use.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    91
@interface NSBundle (StupidCompatibilityHack)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    92
- (NSString *)semiCaseInsensitivePathForResource:(NSString *)res ofType:(NSString *)type;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    93
- (NSString *)semiCaseInsensitivePathForResource:(NSString *)res ofType:(NSString *)type inDirectory:(NSString *)dirpath;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    94
@end
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    95
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    96
@implementation NSBundle (StupidCompatibilityHack)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    97
- (NSString *)semiCaseInsensitivePathForResource:(NSString *)res ofType:(NSString *)type
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    98
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    99
	NSString *path = [self pathForResource:res ofType:type];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   100
	if(!path)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   101
		path = [self pathForResource:[res lowercaseString] ofType:type];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   102
	return path;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   103
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   104
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   105
- (NSString *)semiCaseInsensitivePathForResource:(NSString *)res ofType:(NSString *)type inDirectory:(NSString *)dirpath
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   106
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   107
	NSString *path = [self pathForResource:res ofType:type inDirectory:dirpath];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   108
	if(!path)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   109
		path = [self pathForResource:[res lowercaseString] ofType:type inDirectory:dirpath];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   110
	return path;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   111
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   112
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   113
@end
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   114
84
3b5f51e77592 Switch all of our private method categories over to the new objc way of doing it (documented at http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_4_section_5.html#//apple_ref/doc/uid/TP30001163-CH20-SW2). This enforces having implementations for them, and in the process turned up a vast number of methods we had deleted the impl for but not the declaration. loc -= 198;
David Smith
parents: 45
diff changeset
   115
@interface AIWebkitMessageViewStyle ()
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   116
- (id)initWithBundle:(NSBundle *)inBundle;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   117
- (void)_loadTemplates;
2440
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   118
- (void)releaseResources;
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   119
- (NSMutableString *)_escapeStringForPassingToScript:(NSMutableString *)inString;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   120
- (NSString *)noVariantName;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   121
- (NSString *)iconPathForFileTransfer:(ESFileTransfer *)inObject;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   122
- (NSString *)statusIconPathForListObject:(AIListObject *)inObject;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   123
@end
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   124
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   125
@implementation AIWebkitMessageViewStyle
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   126
2954
31f6f4c62d78 Added a `%variant%` keyword for message styles, and rearranged code a bit so that an AIWebkitMessageViewStyle keeps track of its active variant rather than AIWebKitMessageViewController doing so and passing it back to the activeStyle with various invocations.
Evan Schoenberg
parents: 2939
diff changeset
   127
@synthesize activeVariant;
31f6f4c62d78 Added a `%variant%` keyword for message styles, and rearranged code a bit so that an AIWebkitMessageViewStyle keeps track of its active variant rather than AIWebKitMessageViewController doing so and passing it back to the activeStyle with various invocations.
Evan Schoenberg
parents: 2939
diff changeset
   128
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   129
+ (id)messageViewStyleFromBundle:(NSBundle *)inBundle
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   130
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   131
	return [[[self alloc] initWithBundle:inBundle] autorelease];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   132
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   133
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   134
+ (id)messageViewStyleFromPath:(NSString *)path
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   135
{
3363
731004b1c10d Use `-[NSString(AIStringAdditions) stringByExpandingBundlePath]` and `-[NSString(AIStringAdditions) stringByCollapsingBundlePath]` so that our cached path to the active message style is app-bundle-relative if one of our shipping style is being used. This, in turn, fixes various subtle problems which could occur particularly if the user had multiple copies of Adium in differing versions installed.
Evan Schoenberg
parents: 3191
diff changeset
   136
	NSBundle *styleBundle = [NSBundle bundleWithPath:[path stringByExpandingBundlePath]];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   137
	if(styleBundle)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   138
		return [[[self alloc] initWithBundle:styleBundle] autorelease];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   139
	return nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   140
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   141
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   142
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   143
 *	@brief Initialize
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   144
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   145
- (id)initWithBundle:(NSBundle *)inBundle
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   146
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   147
	if ((self = [super init])) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   148
		styleBundle = [inBundle retain];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   149
		stylePath = [[styleBundle resourcePath] retain];
3632
c7323a40d94f Added a MessageViewVersion_MinimumCompatible key to message style Info.plist keys. If set, Adium will refuse to load the style if it has a minimum version greater than its latest known version. This way, a message style which depends upon a hypothetical future version 5 message style can gracefully fail to load in Adium 1.4.2 which knows nothing of it; however, a message style using version 5 which is backwards compatible with version 4 can still be loaded. Fixes #7438 (for future iterations of the problem; nothing can be done for the described historical incompatibility).
Evan Schoenberg
parents: 3579
diff changeset
   150
        
c7323a40d94f Added a MessageViewVersion_MinimumCompatible key to message style Info.plist keys. If set, Adium will refuse to load the style if it has a minimum version greater than its latest known version. This way, a message style which depends upon a hypothetical future version 5 message style can gracefully fail to load in Adium 1.4.2 which knows nothing of it; however, a message style using version 5 which is backwards compatible with version 4 can still be loaded. Fixes #7438 (for future iterations of the problem; nothing can be done for the described historical incompatibility).
Evan Schoenberg
parents: 3579
diff changeset
   151
		if ([self reloadStyle] == FALSE) {
c7323a40d94f Added a MessageViewVersion_MinimumCompatible key to message style Info.plist keys. If set, Adium will refuse to load the style if it has a minimum version greater than its latest known version. This way, a message style which depends upon a hypothetical future version 5 message style can gracefully fail to load in Adium 1.4.2 which knows nothing of it; however, a message style using version 5 which is backwards compatible with version 4 can still be loaded. Fixes #7438 (for future iterations of the problem; nothing can be done for the described historical incompatibility).
Evan Schoenberg
parents: 3579
diff changeset
   152
            [self release];
c7323a40d94f Added a MessageViewVersion_MinimumCompatible key to message style Info.plist keys. If set, Adium will refuse to load the style if it has a minimum version greater than its latest known version. This way, a message style which depends upon a hypothetical future version 5 message style can gracefully fail to load in Adium 1.4.2 which knows nothing of it; however, a message style using version 5 which is backwards compatible with version 4 can still be loaded. Fixes #7438 (for future iterations of the problem; nothing can be done for the described historical incompatibility).
Evan Schoenberg
parents: 3579
diff changeset
   153
            return nil;
c7323a40d94f Added a MessageViewVersion_MinimumCompatible key to message style Info.plist keys. If set, Adium will refuse to load the style if it has a minimum version greater than its latest known version. This way, a message style which depends upon a hypothetical future version 5 message style can gracefully fail to load in Adium 1.4.2 which knows nothing of it; however, a message style using version 5 which is backwards compatible with version 4 can still be loaded. Fixes #7438 (for future iterations of the problem; nothing can be done for the described historical incompatibility).
Evan Schoenberg
parents: 3579
diff changeset
   154
        }
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   155
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   156
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   157
	return self;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   158
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   159
3632
c7323a40d94f Added a MessageViewVersion_MinimumCompatible key to message style Info.plist keys. If set, Adium will refuse to load the style if it has a minimum version greater than its latest known version. This way, a message style which depends upon a hypothetical future version 5 message style can gracefully fail to load in Adium 1.4.2 which knows nothing of it; however, a message style using version 5 which is backwards compatible with version 4 can still be loaded. Fixes #7438 (for future iterations of the problem; nothing can be done for the described historical incompatibility).
Evan Schoenberg
parents: 3579
diff changeset
   160
- (BOOL) reloadStyle
2440
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   161
{
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   162
	[self releaseResources];
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   163
	
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   164
	/* Our styles are versioned so we can change how they work without breaking compatibility.
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   165
	 *
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   166
	 * Version 0: Initial Webkit Version
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   167
	 * Version 1: Template.html now handles all scroll-to-bottom functionality.  It is no longer required to call the
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   168
	 *            scrollToBottom functions when inserting content.
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   169
	 * Version 2: No significant changes
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   170
	 * Version 3: main.css is no longer a separate style, it now serves as the base stylesheet and is imported by default.
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   171
	 *            The default variant is now a separate file in /variants like all other variants.
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   172
	 *			  Template.html now includes appendMessageNoScroll() and appendNextMessageNoScroll() which behave
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   173
	 *				the same as appendMessage() and appendNextMessage() in Versions 1 and 2 but without scrolling.
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   174
	 * Version 4: Template.html now includes replaceLastMessage()
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   175
	 *            Template.html now defines actionMessageUserName and actionMessageBody for display of /me (actions).
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   176
	 *				 If the style provides a custom Template.html, these classes must be defined.
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   177
	 *				 CSS can be used to customize the appearance of actions.
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   178
	 *			  HTML filters in are now supported in Adium's content filter system; filters can assume Version 4 or later.
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   179
	 */
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   180
	styleVersion = [[styleBundle objectForInfoDictionaryKey:KEY_WEBKIT_VERSION] integerValue];
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   181
	
3632
c7323a40d94f Added a MessageViewVersion_MinimumCompatible key to message style Info.plist keys. If set, Adium will refuse to load the style if it has a minimum version greater than its latest known version. This way, a message style which depends upon a hypothetical future version 5 message style can gracefully fail to load in Adium 1.4.2 which knows nothing of it; however, a message style using version 5 which is backwards compatible with version 4 can still be loaded. Fixes #7438 (for future iterations of the problem; nothing can be done for the described historical incompatibility).
Evan Schoenberg
parents: 3579
diff changeset
   182
    /* Refuse to load a version whose minimum compatible version is greater than the latest version we know about; that
c7323a40d94f Added a MessageViewVersion_MinimumCompatible key to message style Info.plist keys. If set, Adium will refuse to load the style if it has a minimum version greater than its latest known version. This way, a message style which depends upon a hypothetical future version 5 message style can gracefully fail to load in Adium 1.4.2 which knows nothing of it; however, a message style using version 5 which is backwards compatible with version 4 can still be loaded. Fixes #7438 (for future iterations of the problem; nothing can be done for the described historical incompatibility).
Evan Schoenberg
parents: 3579
diff changeset
   183
     * indicates this is a style FROM THE FUTURE, and we can't risk corrupting our own timeline.
c7323a40d94f Added a MessageViewVersion_MinimumCompatible key to message style Info.plist keys. If set, Adium will refuse to load the style if it has a minimum version greater than its latest known version. This way, a message style which depends upon a hypothetical future version 5 message style can gracefully fail to load in Adium 1.4.2 which knows nothing of it; however, a message style using version 5 which is backwards compatible with version 4 can still be loaded. Fixes #7438 (for future iterations of the problem; nothing can be done for the described historical incompatibility).
Evan Schoenberg
parents: 3579
diff changeset
   184
     */
c7323a40d94f Added a MessageViewVersion_MinimumCompatible key to message style Info.plist keys. If set, Adium will refuse to load the style if it has a minimum version greater than its latest known version. This way, a message style which depends upon a hypothetical future version 5 message style can gracefully fail to load in Adium 1.4.2 which knows nothing of it; however, a message style using version 5 which is backwards compatible with version 4 can still be loaded. Fixes #7438 (for future iterations of the problem; nothing can be done for the described historical incompatibility).
Evan Schoenberg
parents: 3579
diff changeset
   185
    NSInteger minimumCompatibleVersion = [[styleBundle objectForInfoDictionaryKey:KEY_WEBKIT_VERSION_MIN] integerValue];
c7323a40d94f Added a MessageViewVersion_MinimumCompatible key to message style Info.plist keys. If set, Adium will refuse to load the style if it has a minimum version greater than its latest known version. This way, a message style which depends upon a hypothetical future version 5 message style can gracefully fail to load in Adium 1.4.2 which knows nothing of it; however, a message style using version 5 which is backwards compatible with version 4 can still be loaded. Fixes #7438 (for future iterations of the problem; nothing can be done for the described historical incompatibility).
Evan Schoenberg
parents: 3579
diff changeset
   186
    if (minimumCompatibleVersion && (minimumCompatibleVersion > MAX_KNOWN_WEBKIT_VERSION)) {
c7323a40d94f Added a MessageViewVersion_MinimumCompatible key to message style Info.plist keys. If set, Adium will refuse to load the style if it has a minimum version greater than its latest known version. This way, a message style which depends upon a hypothetical future version 5 message style can gracefully fail to load in Adium 1.4.2 which knows nothing of it; however, a message style using version 5 which is backwards compatible with version 4 can still be loaded. Fixes #7438 (for future iterations of the problem; nothing can be done for the described historical incompatibility).
Evan Schoenberg
parents: 3579
diff changeset
   187
        return NO;
c7323a40d94f Added a MessageViewVersion_MinimumCompatible key to message style Info.plist keys. If set, Adium will refuse to load the style if it has a minimum version greater than its latest known version. This way, a message style which depends upon a hypothetical future version 5 message style can gracefully fail to load in Adium 1.4.2 which knows nothing of it; however, a message style using version 5 which is backwards compatible with version 4 can still be loaded. Fixes #7438 (for future iterations of the problem; nothing can be done for the described historical incompatibility).
Evan Schoenberg
parents: 3579
diff changeset
   188
    }
c7323a40d94f Added a MessageViewVersion_MinimumCompatible key to message style Info.plist keys. If set, Adium will refuse to load the style if it has a minimum version greater than its latest known version. This way, a message style which depends upon a hypothetical future version 5 message style can gracefully fail to load in Adium 1.4.2 which knows nothing of it; however, a message style using version 5 which is backwards compatible with version 4 can still be loaded. Fixes #7438 (for future iterations of the problem; nothing can be done for the described historical incompatibility).
Evan Schoenberg
parents: 3579
diff changeset
   189
c7323a40d94f Added a MessageViewVersion_MinimumCompatible key to message style Info.plist keys. If set, Adium will refuse to load the style if it has a minimum version greater than its latest known version. This way, a message style which depends upon a hypothetical future version 5 message style can gracefully fail to load in Adium 1.4.2 which knows nothing of it; however, a message style using version 5 which is backwards compatible with version 4 can still be loaded. Fixes #7438 (for future iterations of the problem; nothing can be done for the described historical incompatibility).
Evan Schoenberg
parents: 3579
diff changeset
   190
    //Default behavior
c7323a40d94f Added a MessageViewVersion_MinimumCompatible key to message style Info.plist keys. If set, Adium will refuse to load the style if it has a minimum version greater than its latest known version. This way, a message style which depends upon a hypothetical future version 5 message style can gracefully fail to load in Adium 1.4.2 which knows nothing of it; however, a message style using version 5 which is backwards compatible with version 4 can still be loaded. Fixes #7438 (for future iterations of the problem; nothing can be done for the described historical incompatibility).
Evan Schoenberg
parents: 3579
diff changeset
   191
	allowTextBackgrounds = YES;
c7323a40d94f Added a MessageViewVersion_MinimumCompatible key to message style Info.plist keys. If set, Adium will refuse to load the style if it has a minimum version greater than its latest known version. This way, a message style which depends upon a hypothetical future version 5 message style can gracefully fail to load in Adium 1.4.2 which knows nothing of it; however, a message style using version 5 which is backwards compatible with version 4 can still be loaded. Fixes #7438 (for future iterations of the problem; nothing can be done for the described historical incompatibility).
Evan Schoenberg
parents: 3579
diff changeset
   192
2440
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   193
	//Pre-fetch our templates
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   194
	[self _loadTemplates];
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   195
	
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   196
	//Style flags
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   197
	allowsCustomBackground = ![[styleBundle objectForInfoDictionaryKey:@"DisableCustomBackground"] boolValue];
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   198
	transparentDefaultBackground = [[styleBundle objectForInfoDictionaryKey:@"DefaultBackgroundIsTransparent"] boolValue];
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   199
	
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   200
	combineConsecutive = ![[styleBundle objectForInfoDictionaryKey:@"DisableCombineConsecutive"] boolValue];
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   201
	
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   202
	NSNumber *tmpNum = [styleBundle objectForInfoDictionaryKey:@"ShowsUserIcons"];
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   203
	allowsUserIcons = (tmpNum ? [tmpNum boolValue] : YES);
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   204
	
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   205
	//User icon masking
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   206
	NSString *tmpName = [styleBundle objectForInfoDictionaryKey:KEY_WEBKIT_USER_ICON_MASK];
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   207
	if (tmpName) userIconMask = [[NSImage alloc] initWithContentsOfFile:[stylePath stringByAppendingPathComponent:tmpName]];
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   208
	
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   209
	NSNumber *allowsColorsNumber = [styleBundle objectForInfoDictionaryKey:@"AllowTextColors"];
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   210
	allowsColors = (allowsColorsNumber ? [allowsColorsNumber boolValue] : YES);
3632
c7323a40d94f Added a MessageViewVersion_MinimumCompatible key to message style Info.plist keys. If set, Adium will refuse to load the style if it has a minimum version greater than its latest known version. This way, a message style which depends upon a hypothetical future version 5 message style can gracefully fail to load in Adium 1.4.2 which knows nothing of it; however, a message style using version 5 which is backwards compatible with version 4 can still be loaded. Fixes #7438 (for future iterations of the problem; nothing can be done for the described historical incompatibility).
Evan Schoenberg
parents: 3579
diff changeset
   211
    
c7323a40d94f Added a MessageViewVersion_MinimumCompatible key to message style Info.plist keys. If set, Adium will refuse to load the style if it has a minimum version greater than its latest known version. This way, a message style which depends upon a hypothetical future version 5 message style can gracefully fail to load in Adium 1.4.2 which knows nothing of it; however, a message style using version 5 which is backwards compatible with version 4 can still be loaded. Fixes #7438 (for future iterations of the problem; nothing can be done for the described historical incompatibility).
Evan Schoenberg
parents: 3579
diff changeset
   212
    return YES;
2440
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   213
}
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   214
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   215
/*!
2440
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   216
 *  @brief release everything we loaded from the style bundle
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   217
 */
2440
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   218
- (void)releaseResources
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   219
{
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   220
	//Templates
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   221
	[headerHTML release];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   222
	[footerHTML release];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   223
	[baseHTML release];
252
a8986f7b7814 Patch from mathuaerknedam. Add fallbacks to root level files for Status.html and Content.html. Closes #10868.
Colin Barrett
parents: 166
diff changeset
   224
	[contentHTML release];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   225
	[contentInHTML release];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   226
	[nextContentInHTML release];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   227
	[contextInHTML release];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   228
	[nextContextInHTML release];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   229
	[contentOutHTML release];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   230
	[nextContentOutHTML release];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   231
	[contextOutHTML release];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   232
	[nextContextOutHTML release];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   233
	[statusHTML release];	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   234
	[fileTransferHTML release];
1292
761b05dfd208 Add a Topic template for message styles, which gets added into a <div> with id "topic" in group chats. Authors should do something like: <div contentEditable>%message%</div> (or span, or whatever) so that (in a future commit) topics can be edited. The substitutions are the same for AIContentMessages. %sender% could be nil, however, on initial join.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
   235
	[topicHTML release];
2440
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   236
		
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   237
	[customBackgroundPath release];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   238
	[customBackgroundColor release];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   239
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   240
	[userIconMask release];
2440
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   241
}
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   242
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   243
/*!
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   244
 *	@brief Deallocate
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   245
 */
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   246
- (void)dealloc
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   247
{	
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   248
	[styleBundle release];
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   249
	[stylePath release];
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   250
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   251
	[self releaseResources];
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   252
	[timeStampFormatter release];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   253
	
3180
6583a9ec00ef Cache NSDateFormatters in WKMV.
Colin Barrett <colin@springsandstruts.com>
parents: 3092
diff changeset
   254
	[[NSDistributedNotificationCenter defaultCenter] removeObserver: self];
6583a9ec00ef Cache NSDateFormatters in WKMV.
Colin Barrett <colin@springsandstruts.com>
parents: 3092
diff changeset
   255
	
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   256
	[statusIconPathCache release];
3180
6583a9ec00ef Cache NSDateFormatters in WKMV.
Colin Barrett <colin@springsandstruts.com>
parents: 3092
diff changeset
   257
	[timeFormatterCache release];
2954
31f6f4c62d78 Added a `%variant%` keyword for message styles, and rearranged code a bit so that an AIWebkitMessageViewStyle keeps track of its active variant rather than AIWebKitMessageViewController doing so and passing it back to the activeStyle with various invocations.
Evan Schoenberg
parents: 2939
diff changeset
   258
31f6f4c62d78 Added a `%variant%` keyword for message styles, and rearranged code a bit so that an AIWebkitMessageViewStyle keeps track of its active variant rather than AIWebKitMessageViewController doing so and passing it back to the activeStyle with various invocations.
Evan Schoenberg
parents: 2939
diff changeset
   259
	self.activeVariant = nil;
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   260
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   261
	[super dealloc];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   262
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   263
2443
35f6b312d24c Synthesize a bunch of message view controller/message style methods
David Smith <catfish.man@gmail.com>
parents: 2440
diff changeset
   264
@synthesize bundle = styleBundle;
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   265
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   266
- (BOOL)isLegacy
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   267
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   268
	return styleVersion < LEGACY_VERSION_THRESHOLD;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   269
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   270
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   271
#pragma mark Settings
2440
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   272
df64e5f551ef Reload message style resources if the bundle has been updated since the last time we loaded a style
David Smith <catfish.man@gmail.com>
parents: 2225
diff changeset
   273
@synthesize allowsCustomBackground, allowsUserIcons, allowsColors, userIconMask;
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   274
2807
e0421b510067 Add %incomingColor% and %outgoingColor%, remove %senderColor% in headers. Fixes #12666.
Zachary West <zacw@adium.im>
parents: 2799
diff changeset
   275
- (NSArray *)validSenderColors
e0421b510067 Add %incomingColor% and %outgoingColor%, remove %senderColor% in headers. Fixes #12666.
Zachary West <zacw@adium.im>
parents: 2799
diff changeset
   276
{
e0421b510067 Add %incomingColor% and %outgoingColor%, remove %senderColor% in headers. Fixes #12666.
Zachary West <zacw@adium.im>
parents: 2799
diff changeset
   277
	if(!checkedSenderColors) {
e0421b510067 Add %incomingColor% and %outgoingColor%, remove %senderColor% in headers. Fixes #12666.
Zachary West <zacw@adium.im>
parents: 2799
diff changeset
   278
		NSURL *url = [NSURL fileURLWithPath:[stylePath stringByAppendingPathComponent:@"Incoming/SenderColors.txt"]];
e0421b510067 Add %incomingColor% and %outgoingColor%, remove %senderColor% in headers. Fixes #12666.
Zachary West <zacw@adium.im>
parents: 2799
diff changeset
   279
		NSString *senderColorsFile = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:NULL];
e0421b510067 Add %incomingColor% and %outgoingColor%, remove %senderColor% in headers. Fixes #12666.
Zachary West <zacw@adium.im>
parents: 2799
diff changeset
   280
		
e0421b510067 Add %incomingColor% and %outgoingColor%, remove %senderColor% in headers. Fixes #12666.
Zachary West <zacw@adium.im>
parents: 2799
diff changeset
   281
		if(senderColorsFile)
e0421b510067 Add %incomingColor% and %outgoingColor%, remove %senderColor% in headers. Fixes #12666.
Zachary West <zacw@adium.im>
parents: 2799
diff changeset
   282
			validSenderColors = [[senderColorsFile componentsSeparatedByString:@":"] retain];
e0421b510067 Add %incomingColor% and %outgoingColor%, remove %senderColor% in headers. Fixes #12666.
Zachary West <zacw@adium.im>
parents: 2799
diff changeset
   283
		
e0421b510067 Add %incomingColor% and %outgoingColor%, remove %senderColor% in headers. Fixes #12666.
Zachary West <zacw@adium.im>
parents: 2799
diff changeset
   284
		checkedSenderColors = YES;
e0421b510067 Add %incomingColor% and %outgoingColor%, remove %senderColor% in headers. Fixes #12666.
Zachary West <zacw@adium.im>
parents: 2799
diff changeset
   285
	}
e0421b510067 Add %incomingColor% and %outgoingColor%, remove %senderColor% in headers. Fixes #12666.
Zachary West <zacw@adium.im>
parents: 2799
diff changeset
   286
	
e0421b510067 Add %incomingColor% and %outgoingColor%, remove %senderColor% in headers. Fixes #12666.
Zachary West <zacw@adium.im>
parents: 2799
diff changeset
   287
	return validSenderColors;
e0421b510067 Add %incomingColor% and %outgoingColor%, remove %senderColor% in headers. Fixes #12666.
Zachary West <zacw@adium.im>
parents: 2799
diff changeset
   288
}
e0421b510067 Add %incomingColor% and %outgoingColor%, remove %senderColor% in headers. Fixes #12666.
Zachary West <zacw@adium.im>
parents: 2799
diff changeset
   289
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   290
- (BOOL)isBackgroundTransparent
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   291
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   292
	//Our custom background is only transparent if the user has set a custom color with an alpha component less than 1.0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   293
	return ((!customBackgroundColor && transparentDefaultBackground) ||
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   294
		   (customBackgroundColor && [customBackgroundColor alphaComponent] < 0.99));
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   295
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   296
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   297
- (NSString *)defaultFontFamily
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   298
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   299
	NSString *defaultFontFamily = [styleBundle objectForInfoDictionaryKey:KEY_WEBKIT_DEFAULT_FONT_FAMILY];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   300
	if (!defaultFontFamily) defaultFontFamily = [[NSFont systemFontOfSize:0] familyName];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   301
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   302
	return defaultFontFamily;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   303
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   304
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   305
- (NSNumber *)defaultFontSize
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   306
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   307
	NSNumber *defaultFontSize = [styleBundle objectForInfoDictionaryKey:KEY_WEBKIT_DEFAULT_FONT_SIZE];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   308
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   309
	if (!defaultFontSize) defaultFontSize = [NSNumber numberWithInteger:[[NSFont systemFontOfSize:0] pointSize]];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   310
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   311
	return defaultFontSize;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   312
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   313
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   314
- (BOOL)hasHeader
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   315
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   316
	return headerHTML && [headerHTML length];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   317
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   318
1309
fc6e64704263 Only insert the topic <div> if the chat supports it. Change the "show header" option in the group chats prefpane to "show topic" and it does exactly what you think.
Zachary West <zacw@adiumx.com>
parents: 1308
diff changeset
   319
- (BOOL)hasTopic
fc6e64704263 Only insert the topic <div> if the chat supports it. Change the "show header" option in the group chats prefpane to "show topic" and it does exactly what you think.
Zachary West <zacw@adiumx.com>
parents: 1308
diff changeset
   320
{
fc6e64704263 Only insert the topic <div> if the chat supports it. Change the "show header" option in the group chats prefpane to "show topic" and it does exactly what you think.
Zachary West <zacw@adiumx.com>
parents: 1308
diff changeset
   321
	return topicHTML && [topicHTML length];
fc6e64704263 Only insert the topic <div> if the chat supports it. Change the "show header" option in the group chats prefpane to "show topic" and it does exactly what you think.
Zachary West <zacw@adiumx.com>
parents: 1308
diff changeset
   322
}
fc6e64704263 Only insert the topic <div> if the chat supports it. Change the "show header" option in the group chats prefpane to "show topic" and it does exactly what you think.
Zachary West <zacw@adiumx.com>
parents: 1308
diff changeset
   323
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   324
#pragma mark Behavior
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   325
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   326
- (void)setDateFormat:(NSString *)format
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   327
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   328
	if (!format || [format length] == 0) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   329
		format = [NSDateFormatter localizedDateFormatStringShowingSeconds:NO showingAMorPM:NO];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   330
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   331
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   332
	[timeStampFormatter release];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   333
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   334
	if ([format rangeOfString:@"%"].location != NSNotFound) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   335
		/* Support strftime-style format strings, which old message styles may use */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   336
		timeStampFormatter = [[NSDateFormatter alloc] initWithDateFormat:format allowNaturalLanguage:NO];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   337
	} else {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   338
		timeStampFormatter = [[NSDateFormatter alloc] init];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   339
		[timeStampFormatter setDateFormat:format];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   340
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   341
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   342
3180
6583a9ec00ef Cache NSDateFormatters in WKMV.
Colin Barrett <colin@springsandstruts.com>
parents: 3092
diff changeset
   343
- (void) flushTimeFormatterCache:(id)dummy {
6583a9ec00ef Cache NSDateFormatters in WKMV.
Colin Barrett <colin@springsandstruts.com>
parents: 3092
diff changeset
   344
	[timeFormatterCache removeAllObjects];
6583a9ec00ef Cache NSDateFormatters in WKMV.
Colin Barrett <colin@springsandstruts.com>
parents: 3092
diff changeset
   345
}
6583a9ec00ef Cache NSDateFormatters in WKMV.
Colin Barrett <colin@springsandstruts.com>
parents: 3092
diff changeset
   346
2443
35f6b312d24c Synthesize a bunch of message view controller/message style methods
David Smith <catfish.man@gmail.com>
parents: 2440
diff changeset
   347
@synthesize allowTextBackgrounds, customBackgroundType, customBackgroundColor, showIncomingMessageColors=showIncomingColors, showIncomingMessageFonts=showIncomingFonts, customBackgroundPath, nameFormat, useCustomNameFormat, showHeader, showUserIcons;
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   348
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   349
//Templates ------------------------------------------------------------------------------------------------------------
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   350
#pragma mark Templates
2954
31f6f4c62d78 Added a `%variant%` keyword for message styles, and rearranged code a bit so that an AIWebkitMessageViewStyle keeps track of its active variant rather than AIWebKitMessageViewController doing so and passing it back to the activeStyle with various invocations.
Evan Schoenberg
parents: 2939
diff changeset
   351
- (NSString *)baseTemplateForChat:(AIChat *)chat
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   352
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   353
	NSMutableString	*templateHTML;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   354
1292
761b05dfd208 Add a Topic template for message styles, which gets added into a <div> with id "topic" in group chats. Authors should do something like: <div contentEditable>%message%</div> (or span, or whatever) so that (in a future commit) topics can be edited. The substitutions are the same for AIContentMessages. %sender% could be nil, however, on initial join.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
   355
	// If this is a group chat, we want to include a topic.
761b05dfd208 Add a Topic template for message styles, which gets added into a <div> with id "topic" in group chats. Authors should do something like: <div contentEditable>%message%</div> (or span, or whatever) so that (in a future commit) topics can be edited. The substitutions are the same for AIContentMessages. %sender% could be nil, however, on initial join.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
   356
	// Otherwise, if the header is shown, use it.
761b05dfd208 Add a Topic template for message styles, which gets added into a <div> with id "topic" in group chats. Authors should do something like: <div contentEditable>%message%</div> (or span, or whatever) so that (in a future commit) topics can be edited. The substitutions are the same for AIContentMessages. %sender% could be nil, however, on initial join.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
   357
	NSString *headerContent = @"";
1309
fc6e64704263 Only insert the topic <div> if the chat supports it. Change the "show header" option in the group chats prefpane to "show topic" and it does exactly what you think.
Zachary West <zacw@adiumx.com>
parents: 1308
diff changeset
   358
	if (showHeader) {
fc6e64704263 Only insert the topic <div> if the chat supports it. Change the "show header" option in the group chats prefpane to "show topic" and it does exactly what you think.
Zachary West <zacw@adiumx.com>
parents: 1308
diff changeset
   359
		if (chat.isGroupChat) {
fc6e64704263 Only insert the topic <div> if the chat supports it. Change the "show header" option in the group chats prefpane to "show topic" and it does exactly what you think.
Zachary West <zacw@adiumx.com>
parents: 1308
diff changeset
   360
			headerContent = (chat.supportsTopic ? TOPIC_MAIN_DIV : @"");
fc6e64704263 Only insert the topic <div> if the chat supports it. Change the "show header" option in the group chats prefpane to "show topic" and it does exactly what you think.
Zachary West <zacw@adiumx.com>
parents: 1308
diff changeset
   361
		} else if (headerHTML) {
fc6e64704263 Only insert the topic <div> if the chat supports it. Change the "show header" option in the group chats prefpane to "show topic" and it does exactly what you think.
Zachary West <zacw@adiumx.com>
parents: 1308
diff changeset
   362
			headerContent = headerHTML;
fc6e64704263 Only insert the topic <div> if the chat supports it. Change the "show header" option in the group chats prefpane to "show topic" and it does exactly what you think.
Zachary West <zacw@adiumx.com>
parents: 1308
diff changeset
   363
		}
1292
761b05dfd208 Add a Topic template for message styles, which gets added into a <div> with id "topic" in group chats. Authors should do something like: <div contentEditable>%message%</div> (or span, or whatever) so that (in a future commit) topics can be edited. The substitutions are the same for AIContentMessages. %sender% could be nil, however, on initial join.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
   364
	}
761b05dfd208 Add a Topic template for message styles, which gets added into a <div> with id "topic" in group chats. Authors should do something like: <div contentEditable>%message%</div> (or span, or whatever) so that (in a future commit) topics can be edited. The substitutions are the same for AIContentMessages. %sender% could be nil, however, on initial join.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
   365
	
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   366
	//Old styles may be using an old custom 4 parameter baseHTML.  Styles version 3 and higher should
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   367
	//be using the bundled (or a custom) 5 parameter baseHTML.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   368
	if ((styleVersion < 3) && usingCustomTemplateHTML) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   369
		templateHTML = [NSMutableString stringWithFormat:baseHTML,						//Template
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   370
			[[NSURL fileURLWithPath:stylePath] absoluteString],							//Base path
2954
31f6f4c62d78 Added a `%variant%` keyword for message styles, and rearranged code a bit so that an AIWebkitMessageViewStyle keeps track of its active variant rather than AIWebKitMessageViewController doing so and passing it back to the activeStyle with various invocations.
Evan Schoenberg
parents: 2939
diff changeset
   371
			[self pathForVariant:self.activeVariant],									//Variant path
1292
761b05dfd208 Add a Topic template for message styles, which gets added into a <div> with id "topic" in group chats. Authors should do something like: <div contentEditable>%message%</div> (or span, or whatever) so that (in a future commit) topics can be edited. The substitutions are the same for AIContentMessages. %sender% could be nil, however, on initial join.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
   372
			headerContent,
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   373
			(footerHTML ? footerHTML : @"")];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   374
	} else {		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   375
		templateHTML = [NSMutableString stringWithFormat:baseHTML,						//Template
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   376
			[[NSURL fileURLWithPath:stylePath] absoluteString],							//Base path
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   377
			styleVersion < 3 ? @"" : @"@import url( \"main.css\" );",					//Import main.css for new enough styles
2954
31f6f4c62d78 Added a `%variant%` keyword for message styles, and rearranged code a bit so that an AIWebkitMessageViewStyle keeps track of its active variant rather than AIWebKitMessageViewController doing so and passing it back to the activeStyle with various invocations.
Evan Schoenberg
parents: 2939
diff changeset
   378
			[self pathForVariant:self.activeVariant],									//Variant path
1292
761b05dfd208 Add a Topic template for message styles, which gets added into a <div> with id "topic" in group chats. Authors should do something like: <div contentEditable>%message%</div> (or span, or whatever) so that (in a future commit) topics can be edited. The substitutions are the same for AIContentMessages. %sender% could be nil, however, on initial join.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
   379
			headerContent,
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   380
			(footerHTML ? footerHTML : @"")];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   381
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   382
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   383
	return [self fillKeywordsForBaseTemplate:templateHTML chat:chat];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   384
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   385
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   386
- (NSString *)templateForContent:(AIContentObject *)content similar:(BOOL)contentIsSimilar
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   387
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   388
	NSString	*template;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   389
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   390
	//Get the correct template for what we're inserting
1452
0b16ba1861c3 Make notifications use status.html. mathuaerknedam says they should. Fixes #11528
David Smith
parents: 1451
diff changeset
   391
	if ([[content type] isEqualToString:CONTENT_MESSAGE_TYPE]) {
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   392
		if ([content isOutgoing]) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   393
			template = (contentIsSimilar ? nextContentOutHTML : contentOutHTML);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   394
		} else {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   395
			template = (contentIsSimilar ? nextContentInHTML : contentInHTML);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   396
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   397
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   398
	} else if ([[content type] isEqualToString:CONTENT_CONTEXT_TYPE]) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   399
		if ([content isOutgoing]) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   400
			template = (contentIsSimilar ? nextContextOutHTML : contextOutHTML);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   401
		} else {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   402
			template = (contentIsSimilar ? nextContextInHTML : contextInHTML);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   403
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   404
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   405
	} else if([[content type] isEqualToString:CONTENT_FILE_TRANSFER_TYPE]) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   406
		template = [[fileTransferHTML mutableCopy] autorelease];
1292
761b05dfd208 Add a Topic template for message styles, which gets added into a <div> with id "topic" in group chats. Authors should do something like: <div contentEditable>%message%</div> (or span, or whatever) so that (in a future commit) topics can be edited. The substitutions are the same for AIContentMessages. %sender% could be nil, however, on initial join.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
   407
	} else if ([[content type] isEqualToString:CONTENT_TOPIC_TYPE]) {
761b05dfd208 Add a Topic template for message styles, which gets added into a <div> with id "topic" in group chats. Authors should do something like: <div contentEditable>%message%</div> (or span, or whatever) so that (in a future commit) topics can be edited. The substitutions are the same for AIContentMessages. %sender% could be nil, however, on initial join.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
   408
		template = topicHTML;
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   409
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   410
	else {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   411
		template = statusHTML;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   412
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   413
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   414
	return template;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   415
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   416
1292
761b05dfd208 Add a Topic template for message styles, which gets added into a <div> with id "topic" in group chats. Authors should do something like: <div contentEditable>%message%</div> (or span, or whatever) so that (in a future commit) topics can be edited. The substitutions are the same for AIContentMessages. %sender% could be nil, however, on initial join.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
   417
- (NSString *)completedTemplateForContent:(AIContentObject *)content similar:(BOOL)contentIsSimilar
761b05dfd208 Add a Topic template for message styles, which gets added into a <div> with id "topic" in group chats. Authors should do something like: <div contentEditable>%message%</div> (or span, or whatever) so that (in a future commit) topics can be edited. The substitutions are the same for AIContentMessages. %sender% could be nil, however, on initial join.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
   418
{
761b05dfd208 Add a Topic template for message styles, which gets added into a <div> with id "topic" in group chats. Authors should do something like: <div contentEditable>%message%</div> (or span, or whatever) so that (in a future commit) topics can be edited. The substitutions are the same for AIContentMessages. %sender% could be nil, however, on initial join.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
   419
	NSMutableString *mutableTemplate = [[self templateForContent:content similar:contentIsSimilar] mutableCopy];
761b05dfd208 Add a Topic template for message styles, which gets added into a <div> with id "topic" in group chats. Authors should do something like: <div contentEditable>%message%</div> (or span, or whatever) so that (in a future commit) topics can be edited. The substitutions are the same for AIContentMessages. %sender% could be nil, however, on initial join.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
   420
	
3464
9374609f7600 Remove an assignment which just confuses the picture (and throws a clang warning)
Evan Schoenberg
parents: 3363
diff changeset
   421
	if (mutableTemplate)
9374609f7600 Remove an assignment which just confuses the picture (and throws a clang warning)
Evan Schoenberg
parents: 3363
diff changeset
   422
		[self fillKeywords:mutableTemplate forContent:content similar:contentIsSimilar];
1292
761b05dfd208 Add a Topic template for message styles, which gets added into a <div> with id "topic" in group chats. Authors should do something like: <div contentEditable>%message%</div> (or span, or whatever) so that (in a future commit) topics can be edited. The substitutions are the same for AIContentMessages. %sender% could be nil, however, on initial join.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
   423
	
761b05dfd208 Add a Topic template for message styles, which gets added into a <div> with id "topic" in group chats. Authors should do something like: <div contentEditable>%message%</div> (or span, or whatever) so that (in a future commit) topics can be edited. The substitutions are the same for AIContentMessages. %sender% could be nil, however, on initial join.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
   424
	return [mutableTemplate autorelease];
761b05dfd208 Add a Topic template for message styles, which gets added into a <div> with id "topic" in group chats. Authors should do something like: <div contentEditable>%message%</div> (or span, or whatever) so that (in a future commit) topics can be edited. The substitutions are the same for AIContentMessages. %sender% could be nil, however, on initial join.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
   425
}
761b05dfd208 Add a Topic template for message styles, which gets added into a <div> with id "topic" in group chats. Authors should do something like: <div contentEditable>%message%</div> (or span, or whatever) so that (in a future commit) topics can be edited. The substitutions are the same for AIContentMessages. %sender% could be nil, however, on initial join.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
   426
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   427
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   428
 *	@brief Pre-fetch all the style templates
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   429
 *
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   430
 *	This needs to be called before either baseTemplate or templateForContent is called
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   431
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   432
- (void)_loadTemplates
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   433
{		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   434
	//Load the style's templates
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   435
	//We can't use NSString's initWithContentsOfFile here.  HTML files are interpreted in the defaultCEncoding
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   436
	//(which varies by system) when read that way.  We want to always interpret the files as UTF8.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   437
	headerHTML = [[NSString stringWithContentsOfUTF8File:[styleBundle semiCaseInsensitivePathForResource:@"Header" ofType:@"html"]] retain];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   438
	footerHTML = [[NSString stringWithContentsOfUTF8File:[styleBundle semiCaseInsensitivePathForResource:@"Footer" ofType:@"html"]] retain];
1292
761b05dfd208 Add a Topic template for message styles, which gets added into a <div> with id "topic" in group chats. Authors should do something like: <div contentEditable>%message%</div> (or span, or whatever) so that (in a future commit) topics can be edited. The substitutions are the same for AIContentMessages. %sender% could be nil, however, on initial join.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
   439
	topicHTML = [[NSString stringWithContentsOfUTF8File:[styleBundle semiCaseInsensitivePathForResource:@"Topic" ofType:@"html"]] retain];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   440
	baseHTML = [NSString stringWithContentsOfUTF8File:[styleBundle semiCaseInsensitivePathForResource:@"Template" ofType:@"html"]];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   441
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   442
	//Starting with version 1, styles can choose to not include template.html.  If the template is not included 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   443
	//Adium's default will be used.  This is preferred since any future template updates will apply to the style
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   444
	if ((!baseHTML || [baseHTML length] == 0) && styleVersion >= 1) {		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   445
		baseHTML = [NSString stringWithContentsOfUTF8File:[[NSBundle bundleForClass:[self class]] semiCaseInsensitivePathForResource:@"Template" ofType:@"html"]];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   446
		usingCustomTemplateHTML = NO;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   447
	} else {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   448
		usingCustomTemplateHTML = YES;
673
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   449
		
4585
6c1dd8c3ee4a Avoid a lot of false positives of the static analyzer.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 4356
diff changeset
   450
		NSAssert(baseHTML != nil, @"The impossible happened!");
6c1dd8c3ee4a Avoid a lot of false positives of the static analyzer.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 4356
diff changeset
   451
		
673
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   452
		if ([baseHTML rangeOfString:@"function imageCheck()" options:NSLiteralSearch].location != NSNotFound) {
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   453
			/* This doesn't quite fix image swapping on styles with broken image swapping due to custom HTML templates,
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   454
			 * but it improves it. For some reason, the result of using our normal template.html functions is that 
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   455
			 * clicking works once, then the text doesn't allow a return click. This is an improvement compared
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   456
			 * to fully broken behavior in which the return click shows a missing-image placeholder.
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   457
			 */
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   458
			NSMutableString *imageSwapFixedBaseHTML = [[baseHTML mutableCopy] autorelease];
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   459
			[imageSwapFixedBaseHTML replaceOccurrencesOfString:
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   460
			 @"		function imageCheck() {\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   461
			 "			node = event.target;\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   462
			 "			if(node.tagName == 'IMG' && node.alt) {\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   463
			 "				a = document.createElement('a');\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   464
			 "				a.setAttribute('onclick', 'imageSwap(this)');\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   465
			 "				a.setAttribute('src', node.src);\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   466
			 "				text = document.createTextNode(node.alt);\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   467
			 "				a.appendChild(text);\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   468
			 "				node.parentNode.replaceChild(a, node);\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   469
			 "			}\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   470
			 "		}"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   471
													withString:
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   472
			 @"		function imageCheck() {\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   473
			 "			var node = event.target;\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   474
			 "			if(node.tagName.toLowerCase() == 'img' && !client.zoomImage(node) && node.alt) {\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   475
			 "				var a = document.createElement('a');\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   476
			 "				a.setAttribute('onclick', 'imageSwap(this)');\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   477
			 "				a.setAttribute('src', node.getAttribute('src'));\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   478
			 "				a.className = node.className;\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   479
			 "				var text = document.createTextNode(node.alt);\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   480
			 "				a.appendChild(text);\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   481
			 "				node.parentNode.replaceChild(a, node);\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   482
			 "			}\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   483
			 "		}"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   484
													   options:NSLiteralSearch];
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   485
			[imageSwapFixedBaseHTML replaceOccurrencesOfString:
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   486
			 @"		function imageSwap(node) {\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   487
			 "			img = document.createElement('img');\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   488
			 "			img.setAttribute('src', node.src);\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   489
			 "			img.setAttribute('alt', node.firstChild.nodeValue);\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   490
			 "			node.parentNode.replaceChild(img, node);\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   491
			 "			alignChat();\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   492
			 "		}"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   493
													withString:
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   494
			 @"		function imageSwap(node) {\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   495
			 "			var shouldScroll = nearBottom();\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   496
			 "			//Swap the image/text\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   497
			 "			var img = document.createElement('img');\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   498
			 "			img.setAttribute('src', node.getAttribute('src'));\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   499
			 "			img.setAttribute('alt', node.firstChild.nodeValue);\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   500
			 "			img.className = node.className;\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   501
			 "			node.parentNode.replaceChild(img, node);\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   502
			 "			\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   503
			 "			alignChat(shouldScroll);\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   504
			 "		}"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   505
													   options:NSLiteralSearch];
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   506
			/* Now for ones which don't call alignChat() */
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   507
			[imageSwapFixedBaseHTML replaceOccurrencesOfString:
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   508
			 @"		function imageSwap(node) {\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   509
			 "			img = document.createElement('img');\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   510
			 "			img.setAttribute('src', node.src);\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   511
			 "			img.setAttribute('alt', node.firstChild.nodeValue);\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   512
			 "			node.parentNode.replaceChild(img, node);\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   513
			 "		}"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   514
													withString:
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   515
			 @"		function imageSwap(node) {\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   516
			 "			var shouldScroll = nearBottom();\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   517
			 "			//Swap the image/text\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   518
			 "			var img = document.createElement('img');\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   519
			 "			img.setAttribute('src', node.getAttribute('src'));\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   520
			 "			img.setAttribute('alt', node.firstChild.nodeValue);\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   521
			 "			img.className = node.className;\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   522
			 "			node.parentNode.replaceChild(img, node);\n"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   523
			 "		}"
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   524
													   options:NSLiteralSearch];
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   525
			baseHTML = imageSwapFixedBaseHTML;
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   526
		}
b86591ffccad Improve (but don't fix) the emoticon/alt image switching in certain styles with custom template.html files. Please see #10659 for all the details. Refs #10659
Evan Schoenberg
parents: 547
diff changeset
   527
		
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   528
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   529
	[baseHTML retain];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   530
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   531
	//Content Templates
252
a8986f7b7814 Patch from mathuaerknedam. Add fallbacks to root level files for Status.html and Content.html. Closes #10868.
Colin Barrett
parents: 166
diff changeset
   532
	contentHTML = [[NSString stringWithContentsOfUTF8File:[styleBundle semiCaseInsensitivePathForResource:@"Content" ofType:@"html"]] retain];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   533
	contentInHTML = [[NSString stringWithContentsOfUTF8File:[styleBundle semiCaseInsensitivePathForResource:@"Content" ofType:@"html" inDirectory:@"Incoming"]] retain];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   534
	nextContentInHTML = [[NSString stringWithContentsOfUTF8File:[styleBundle semiCaseInsensitivePathForResource:@"NextContent" ofType:@"html" inDirectory:@"Incoming"]] retain];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   535
	contentOutHTML = [[NSString stringWithContentsOfUTF8File:[styleBundle semiCaseInsensitivePathForResource:@"Content" ofType:@"html" inDirectory:@"Outgoing"]] retain];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   536
	nextContentOutHTML = [[NSString stringWithContentsOfUTF8File:[styleBundle semiCaseInsensitivePathForResource:@"NextContent" ofType:@"html" inDirectory:@"Outgoing"]] retain];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   537
	
289
54969de66dbd Fixed fallback of a missing context HTML file to match the documentation. Patch from '''mathuaerknedam''', thanks :) Fixes #11026
Evan Schoenberg
parents: 252
diff changeset
   538
	//Message history
54969de66dbd Fixed fallback of a missing context HTML file to match the documentation. Patch from '''mathuaerknedam''', thanks :) Fixes #11026
Evan Schoenberg
parents: 252
diff changeset
   539
	contextInHTML = [[NSString stringWithContentsOfUTF8File:[styleBundle semiCaseInsensitivePathForResource:@"Context" ofType:@"html" inDirectory:@"Incoming"]] retain];
54969de66dbd Fixed fallback of a missing context HTML file to match the documentation. Patch from '''mathuaerknedam''', thanks :) Fixes #11026
Evan Schoenberg
parents: 252
diff changeset
   540
	nextContextInHTML = [[NSString stringWithContentsOfUTF8File:[styleBundle semiCaseInsensitivePathForResource:@"NextContext" ofType:@"html" inDirectory:@"Incoming"]] retain];
54969de66dbd Fixed fallback of a missing context HTML file to match the documentation. Patch from '''mathuaerknedam''', thanks :) Fixes #11026
Evan Schoenberg
parents: 252
diff changeset
   541
	contextOutHTML = [[NSString stringWithContentsOfUTF8File:[styleBundle semiCaseInsensitivePathForResource:@"Context" ofType:@"html" inDirectory:@"Outgoing"]] retain];
54969de66dbd Fixed fallback of a missing context HTML file to match the documentation. Patch from '''mathuaerknedam''', thanks :) Fixes #11026
Evan Schoenberg
parents: 252
diff changeset
   542
	nextContextOutHTML = [[NSString stringWithContentsOfUTF8File:[styleBundle semiCaseInsensitivePathForResource:@"NextContext" ofType:@"html" inDirectory:@"Outgoing"]] retain];
252
a8986f7b7814 Patch from mathuaerknedam. Add fallbacks to root level files for Status.html and Content.html. Closes #10868.
Colin Barrett
parents: 166
diff changeset
   543
	
2507
89182b77f6ad Patch from mathuaerknedam, fixes #12448
David Smith <catfish.man@gmail.com>
parents: 2506
diff changeset
   544
	//Fall back to Resources/Content.html if Incoming isn't present
89182b77f6ad Patch from mathuaerknedam, fixes #12448
David Smith <catfish.man@gmail.com>
parents: 2506
diff changeset
   545
	if (!contentInHTML) contentInHTML = [contentHTML retain];
89182b77f6ad Patch from mathuaerknedam, fixes #12448
David Smith <catfish.man@gmail.com>
parents: 2506
diff changeset
   546
	
312
13f4d9bb346e Updated patch from '''mathuaerknedam''' to fix #11074. Fixes #11026. Fixes #11074.
Evan Schoenberg
parents: 289
diff changeset
   547
	//Fall back to Content if NextContent doesn't need to use different HTML
13f4d9bb346e Updated patch from '''mathuaerknedam''' to fix #11074. Fixes #11026. Fixes #11074.
Evan Schoenberg
parents: 289
diff changeset
   548
	if (!nextContentInHTML) nextContentInHTML = [contentInHTML retain];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   549
	
312
13f4d9bb346e Updated patch from '''mathuaerknedam''' to fix #11074. Fixes #11026. Fixes #11074.
Evan Schoenberg
parents: 289
diff changeset
   550
	//Fall back to Content if Context isn't present
13f4d9bb346e Updated patch from '''mathuaerknedam''' to fix #11074. Fixes #11026. Fixes #11074.
Evan Schoenberg
parents: 289
diff changeset
   551
	if (!nextContextInHTML) nextContextInHTML = [nextContentInHTML retain];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   552
	if (!contextInHTML) contextInHTML = [contentInHTML retain];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   553
	
312
13f4d9bb346e Updated patch from '''mathuaerknedam''' to fix #11074. Fixes #11026. Fixes #11074.
Evan Schoenberg
parents: 289
diff changeset
   554
	//Fall back to Content if Context isn't present
13f4d9bb346e Updated patch from '''mathuaerknedam''' to fix #11074. Fixes #11026. Fixes #11074.
Evan Schoenberg
parents: 289
diff changeset
   555
	if (!nextContextOutHTML && nextContentOutHTML) nextContextOutHTML = [nextContentOutHTML retain];
13f4d9bb346e Updated patch from '''mathuaerknedam''' to fix #11074. Fixes #11026. Fixes #11074.
Evan Schoenberg
parents: 289
diff changeset
   556
	if (!contextOutHTML && contentOutHTML) contextOutHTML = [contentOutHTML retain];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   557
	
312
13f4d9bb346e Updated patch from '''mathuaerknedam''' to fix #11074. Fixes #11026. Fixes #11074.
Evan Schoenberg
parents: 289
diff changeset
   558
	//Fall back to Content if Context isn't present
13f4d9bb346e Updated patch from '''mathuaerknedam''' to fix #11074. Fixes #11026. Fixes #11074.
Evan Schoenberg
parents: 289
diff changeset
   559
	if (!nextContextOutHTML) nextContextOutHTML = [nextContextInHTML retain];
13f4d9bb346e Updated patch from '''mathuaerknedam''' to fix #11074. Fixes #11026. Fixes #11074.
Evan Schoenberg
parents: 289
diff changeset
   560
	if (!contextOutHTML) contextOutHTML = [contextInHTML retain];
13f4d9bb346e Updated patch from '''mathuaerknedam''' to fix #11074. Fixes #11026. Fixes #11074.
Evan Schoenberg
parents: 289
diff changeset
   561
	
13f4d9bb346e Updated patch from '''mathuaerknedam''' to fix #11074. Fixes #11026. Fixes #11074.
Evan Schoenberg
parents: 289
diff changeset
   562
	//Fall back to Incoming if Outgoing doesn't need to be different
13f4d9bb346e Updated patch from '''mathuaerknedam''' to fix #11074. Fixes #11026. Fixes #11074.
Evan Schoenberg
parents: 289
diff changeset
   563
	if (!contentOutHTML) contentOutHTML = [contentInHTML retain];
13f4d9bb346e Updated patch from '''mathuaerknedam''' to fix #11074. Fixes #11026. Fixes #11074.
Evan Schoenberg
parents: 289
diff changeset
   564
	if (!nextContentOutHTML) nextContentOutHTML = [nextContentInHTML retain];
13f4d9bb346e Updated patch from '''mathuaerknedam''' to fix #11074. Fixes #11026. Fixes #11074.
Evan Schoenberg
parents: 289
diff changeset
   565
	
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   566
	//Status
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   567
	statusHTML = [[NSString stringWithContentsOfUTF8File:[styleBundle semiCaseInsensitivePathForResource:@"Status" ofType:@"html"]] retain];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   568
	
312
13f4d9bb346e Updated patch from '''mathuaerknedam''' to fix #11074. Fixes #11026. Fixes #11074.
Evan Schoenberg
parents: 289
diff changeset
   569
	//Fall back to Resources/Incoming/Content.html if Status isn't present
13f4d9bb346e Updated patch from '''mathuaerknedam''' to fix #11074. Fixes #11026. Fixes #11074.
Evan Schoenberg
parents: 289
diff changeset
   570
	if (!statusHTML) statusHTML = [contentInHTML retain];
252
a8986f7b7814 Patch from mathuaerknedam. Add fallbacks to root level files for Status.html and Content.html. Closes #10868.
Colin Barrett
parents: 166
diff changeset
   571
	
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   572
	//TODO: make a generic Request message, rather than having this ft specific one
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   573
	NSMutableString *fileTransferHTMLTemplate;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   574
	fileTransferHTMLTemplate = [[NSString stringWithContentsOfUTF8File:[styleBundle semiCaseInsensitivePathForResource:@"FileTransferRequest" ofType:@"html"]] mutableCopy];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   575
	if(!fileTransferHTMLTemplate) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   576
		fileTransferHTMLTemplate = [contentInHTML mutableCopy];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   577
		[fileTransferHTMLTemplate replaceKeyword:@"%message%"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   578
									  withString:@"<p><img src=\"%fileIconPath%\" style=\"width:32px; height:32px; vertical-align:middle;\"></img><input type=\"button\" onclick=\"%saveFileAsHandler%\" value=\"Download %fileName%\"></p>"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   579
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   580
	[fileTransferHTMLTemplate replaceKeyword:@"Download %fileName%"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   581
						  withString:[NSString stringWithFormat:AILocalizedString(@"Download %@", "%@ will be a file name"), @"%fileName%"]];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   582
	fileTransferHTML = fileTransferHTMLTemplate;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   583
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   584
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   585
#pragma mark Scripts
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   586
- (NSString *)scriptForAppendingContent:(AIContentObject *)content similar:(BOOL)contentIsSimilar willAddMoreContentObjects:(BOOL)willAddMoreContentObjects replaceLastContent:(BOOL)replaceLastContent
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   587
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   588
	NSMutableString	*newHTML;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   589
	NSString		*script;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   590
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   591
	//If combining of consecutive messages has been disabled, we treat all content as non-similar
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   592
	if (!combineConsecutive) contentIsSimilar = NO;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   593
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   594
	//Fetch the correct template and substitute keywords for the passed content
1292
761b05dfd208 Add a Topic template for message styles, which gets added into a <div> with id "topic" in group chats. Authors should do something like: <div contentEditable>%message%</div> (or span, or whatever) so that (in a future commit) topics can be edited. The substitutions are the same for AIContentMessages. %sender% could be nil, however, on initial join.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
   595
	newHTML = [[[self completedTemplateForContent:content similar:contentIsSimilar] mutableCopy] autorelease];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   596
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   597
	//BOM scripts vary by style version
2515
69ca5de45e99 Make mvv3 not coalesce, as originally intended. Nice catch mathuaerknedam
David Smith <catfish.man@gmail.com>
parents: 2507
diff changeset
   598
	if (!usingCustomTemplateHTML && styleVersion >= 4) {
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   599
		/* If we're using the built-in template HTML, we know that it supports our most modern scripts */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   600
		if (replaceLastContent)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   601
			script = REPLACE_LAST_MESSAGE;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   602
		else if (willAddMoreContentObjects) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   603
			script = (contentIsSimilar ? APPEND_NEXT_MESSAGE_NO_SCROLL : APPEND_MESSAGE_NO_SCROLL);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   604
		} else {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   605
			script = (contentIsSimilar ? APPEND_NEXT_MESSAGE : APPEND_MESSAGE);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   606
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   607
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   608
	} else  if (styleVersion >= 3) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   609
		if (willAddMoreContentObjects) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   610
			script = (contentIsSimilar ? APPEND_NEXT_MESSAGE_NO_SCROLL : APPEND_MESSAGE_NO_SCROLL);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   611
		} else {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   612
			script = (contentIsSimilar ? APPEND_NEXT_MESSAGE : APPEND_MESSAGE);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   613
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   614
	} else if (styleVersion >= 1) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   615
		script = (contentIsSimilar ? APPEND_NEXT_MESSAGE : APPEND_MESSAGE);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   616
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   617
	} else {
524
7eb74cc87340 For version 0 message styles with a custom template.html, such as Sharp, use APPEND_MESSAGE_WITH_SCROLL for consecutive status messages so they will be properly displayed. Fixes #10921
Evan Schoenberg
parents: 459
diff changeset
   618
		if (usingCustomTemplateHTML && [content isKindOfClass:[AIContentStatus class]]) {
7eb74cc87340 For version 0 message styles with a custom template.html, such as Sharp, use APPEND_MESSAGE_WITH_SCROLL for consecutive status messages so they will be properly displayed. Fixes #10921
Evan Schoenberg
parents: 459
diff changeset
   619
			/* Old styles with a custom template.html had Status.html files without 'insert' divs coupled 
7eb74cc87340 For version 0 message styles with a custom template.html, such as Sharp, use APPEND_MESSAGE_WITH_SCROLL for consecutive status messages so they will be properly displayed. Fixes #10921
Evan Schoenberg
parents: 459
diff changeset
   620
			 * with a APPEND_NEXT_MESSAGE_WITH_SCROLL script which assumes one exists.
7eb74cc87340 For version 0 message styles with a custom template.html, such as Sharp, use APPEND_MESSAGE_WITH_SCROLL for consecutive status messages so they will be properly displayed. Fixes #10921
Evan Schoenberg
parents: 459
diff changeset
   621
			 */
7eb74cc87340 For version 0 message styles with a custom template.html, such as Sharp, use APPEND_MESSAGE_WITH_SCROLL for consecutive status messages so they will be properly displayed. Fixes #10921
Evan Schoenberg
parents: 459
diff changeset
   622
			script = APPEND_MESSAGE_WITH_SCROLL;
7eb74cc87340 For version 0 message styles with a custom template.html, such as Sharp, use APPEND_MESSAGE_WITH_SCROLL for consecutive status messages so they will be properly displayed. Fixes #10921
Evan Schoenberg
parents: 459
diff changeset
   623
		} else {
7eb74cc87340 For version 0 message styles with a custom template.html, such as Sharp, use APPEND_MESSAGE_WITH_SCROLL for consecutive status messages so they will be properly displayed. Fixes #10921
Evan Schoenberg
parents: 459
diff changeset
   624
			script = (contentIsSimilar ? APPEND_NEXT_MESSAGE_WITH_SCROLL : APPEND_MESSAGE_WITH_SCROLL);
7eb74cc87340 For version 0 message styles with a custom template.html, such as Sharp, use APPEND_MESSAGE_WITH_SCROLL for consecutive status messages so they will be properly displayed. Fixes #10921
Evan Schoenberg
parents: 459
diff changeset
   625
		}
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   626
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   627
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   628
	return [NSString stringWithFormat:script, [self _escapeStringForPassingToScript:newHTML]]; 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   629
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   630
2954
31f6f4c62d78 Added a `%variant%` keyword for message styles, and rearranged code a bit so that an AIWebkitMessageViewStyle keeps track of its active variant rather than AIWebKitMessageViewController doing so and passing it back to the activeStyle with various invocations.
Evan Schoenberg
parents: 2939
diff changeset
   631
- (NSString *)scriptForChangingVariant
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   632
{
2954
31f6f4c62d78 Added a `%variant%` keyword for message styles, and rearranged code a bit so that an AIWebkitMessageViewStyle keeps track of its active variant rather than AIWebKitMessageViewController doing so and passing it back to the activeStyle with various invocations.
Evan Schoenberg
parents: 2939
diff changeset
   633
	return [NSString stringWithFormat:@"setStylesheet(\"mainStyle\",\"%@\");",[self pathForVariant:self.activeVariant]];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   634
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   635
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   636
- (NSString *)scriptForScrollingAfterAddingMultipleContentObjects
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   637
{
674
bbf95622b54b Fixed scrolling to the bottom of the chat when it loads for message styles version 0 through 2 which don't include a custom template.html. Fixes #10541
Evan Schoenberg
parents: 673
diff changeset
   638
	if ((styleVersion >= 3) || !usingCustomTemplateHTML) {
4705
a8725815a3d7 Fixed message view content not scrolled to bottom when opening and not scrolling when new content is added.
Adrian Godoroja <robotive@me.com>
parents: 4651
diff changeset
   639
		return @"if (this.AI_viewScrolledOnLoad != undefined) {alignChat(nearBottom());} else {this.AI_viewScrolledOnLoad = true; alignChat(true);}";
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   640
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   641
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   642
	return nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   643
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   644
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   645
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   646
 *	@brief Escape a string for passing to our BOM scripts
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   647
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   648
- (NSMutableString *)_escapeStringForPassingToScript:(NSMutableString *)inString
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   649
{	
4705
a8725815a3d7 Fixed message view content not scrolled to bottom when opening and not scrolling when new content is added.
Adrian Godoroja <robotive@me.com>
parents: 4651
diff changeset
   650
	// We need to escape a few things to get our string to the javascript without trouble
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   651
	[inString replaceOccurrencesOfString:@"\\" 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   652
							  withString:@"\\\\" 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   653
								 options:NSLiteralSearch];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   654
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   655
	[inString replaceOccurrencesOfString:@"\"" 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   656
							  withString:@"\\\"" 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   657
								 options:NSLiteralSearch];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   658
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   659
	[inString replaceOccurrencesOfString:@"\n" 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   660
							  withString:@"" 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   661
								 options:NSLiteralSearch];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   662
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   663
	[inString replaceOccurrencesOfString:@"\r" 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   664
							  withString:@"<br>" 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   665
								 options:NSLiteralSearch];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   666
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   667
	return inString;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   668
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   669
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   670
#pragma mark Variants
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   671
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   672
- (NSArray *)availableVariants
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   673
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   674
	NSMutableArray	*availableVariants = [NSMutableArray array];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   675
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   676
	//Build an array of all variant names
166
a43b4310ef2a Updated most of our enumerations to fast enumerations, and did some paramaterization.
Evan Schoenberg
parents: 95
diff changeset
   677
	for (NSString *path in [styleBundle pathsForResourcesOfType:@"css" inDirectory:@"Variants"]) {
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   678
		[availableVariants addObject:[[path lastPathComponent] stringByDeletingPathExtension]];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   679
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   680
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   681
	//Style versions before 3 stored the default variant in a separate location.  They also allowed for this
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   682
	//varient name to not be specified, and would substitute a localized string in its place.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   683
	if (styleVersion < 3) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   684
		[availableVariants addObject:[self noVariantName]];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   685
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   686
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   687
	//Alphabetize the variants
3839
379c5cf7138a Remove some 10.5-compatibility code.
Robert Vehse
parents: 3633
diff changeset
   688
	[availableVariants sortUsingSelector:@selector(localizedStandardCompare:)];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   689
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   690
	return availableVariants;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   691
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   692
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   693
- (NSString *)pathForVariant:(NSString *)variant
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   694
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   695
	//Styles before version 3 stored the default variant in main.css, and not in the variants folder.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   696
	if (styleVersion < 3 && [variant isEqualToString:[self noVariantName]]) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   697
		return @"main.css";
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   698
	} else {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   699
		return [NSString stringWithFormat:@"Variants/%@.css",variant];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   700
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   701
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   702
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   703
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   704
 *	@brief Base variant name for styles before version 2
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   705
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   706
- (NSString *)noVariantName
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   707
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   708
	NSString	*noVariantName = [styleBundle objectForInfoDictionaryKey:@"DisplayNameForNoVariant"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   709
	return noVariantName ? noVariantName : AILocalizedString(@"Normal","Normal style variant menu item");
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   710
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   711
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   712
+ (NSString *)noVariantNameForBundle:(NSBundle *)inBundle
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   713
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   714
	NSString	*noVariantName = [inBundle objectForInfoDictionaryKey:@"DisplayNameForNoVariant"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   715
	return noVariantName ? noVariantName : AILocalizedString(@"Normal","Normal style variant menu item");	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   716
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   717
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   718
- (NSString *)defaultVariant
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   719
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   720
	return styleVersion < 3 ? [self noVariantName] : [styleBundle objectForInfoDictionaryKey:@"DefaultVariant"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   721
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   722
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   723
+ (NSString *)defaultVariantForBundle:(NSBundle *)inBundle
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   724
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   725
	return [[inBundle objectForInfoDictionaryKey:KEY_WEBKIT_VERSION] integerValue] < 3 ? 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   726
		   [self noVariantNameForBundle:inBundle] : 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   727
		   [inBundle objectForInfoDictionaryKey:@"DefaultVariant"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   728
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   729
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   730
#pragma mark Keyword replacement
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   731
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   732
- (NSMutableString *)fillKeywords:(NSMutableString *)inString forContent:(AIContentObject *)content similar:(BOOL)contentIsSimilar
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   733
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   734
	NSDate			*date = nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   735
	NSRange			range;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   736
	AIListObject	*contentSource = [content source];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   737
	AIListObject	*theSource = ([contentSource isKindOfClass:[AIListContact class]] ?
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   738
								  [(AIListContact *)contentSource parentContact] :
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   739
								  contentSource);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   740
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   741
	/*
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   742
		htmlEncodedMessage is only encoded correctly for AIContentMessages
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   743
		but we do it up here so that we can check for RTL/LTR text below without
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   744
		having to encode the message twice. This is less than ideal 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   745
	 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   746
	NSString		*htmlEncodedMessage = [AIHTMLDecoder encodeHTML:[content message]
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   747
															headers:NO 
2789
d70bc57935ad Address a few font issues that have cropped up recently. Fixes #12906.
Zachary West <zacw@adium.im>
parents: 2771
diff changeset
   748
														   fontTags:showIncomingFonts
2842
62024fb15685 Only add color tags if a style supports colors. Fixes #13286.
Zachary West <zacw@adium.im>
parents: 2807
diff changeset
   749
												 includingColorTags:(allowsColors && showIncomingColors)
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   750
													  closeFontTags:YES
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   751
														  styleTags:YES
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   752
										 closeStyleTagsOnFontChange:YES
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   753
													 encodeNonASCII:YES
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   754
													   encodeSpaces:YES
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   755
														 imagesPath:NSTemporaryDirectory()
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   756
												  attachmentsAsText:NO
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   757
										  onlyIncludeOutgoingImages:NO
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   758
													 simpleTagsOnly:NO
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   759
													 bodyBackground:NO
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   760
										        allowJavascriptURLs:NO];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   761
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   762
	if (styleVersion >= 4)
95
47acbc0cc17a Propertyize AIListObject and convert some more controller accesses to dot syntax
David Smith
parents: 84
diff changeset
   763
		htmlEncodedMessage = [adium.contentController filterHTMLString:htmlEncodedMessage
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   764
															   direction:[content isOutgoing] ? AIFilterOutgoing : AIFilterIncoming
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   765
																 content:content];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   766
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   767
	//date
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   768
	if ([content respondsToSelector:@selector(date)])
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   769
		date = [(AIContentMessage *)content date];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   770
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   771
	//Replacements applicable to any AIContentObject
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   772
	[inString replaceKeyword:@"%time%" 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   773
				  withString:(date ? [timeStampFormatter stringFromDate:date] : @"")];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   774
4356
a0d4ead5c91e Use a serial dispatch queue for all shared localized NSDateFormatter uses.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 4328
diff changeset
   775
	__block NSString *shortTimeString;
a0d4ead5c91e Use a serial dispatch queue for all shared localized NSDateFormatter uses.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 4328
diff changeset
   776
	[NSDateFormatter withLocalizedDateFormatterShowingSeconds:NO showingAMorPM:NO perform:^(NSDateFormatter *dateFormatter){
a0d4ead5c91e Use a serial dispatch queue for all shared localized NSDateFormatter uses.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 4328
diff changeset
   777
		shortTimeString = (date ? [[dateFormatter stringFromDate:date] retain] : @"");
a0d4ead5c91e Use a serial dispatch queue for all shared localized NSDateFormatter uses.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 4328
diff changeset
   778
	}];
a0d4ead5c91e Use a serial dispatch queue for all shared localized NSDateFormatter uses.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 4328
diff changeset
   779
	[shortTimeString autorelease];
a0d4ead5c91e Use a serial dispatch queue for all shared localized NSDateFormatter uses.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 4328
diff changeset
   780
	
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   781
	[inString replaceKeyword:@"%shortTime%"
2225
f5e11f50e7b9 Add a workaround for #11981. Refs #11981
David Smith <catfish.man@gmail.com>
parents: 1927
diff changeset
   782
				  withString:shortTimeString];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   783
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   784
	if ([inString rangeOfString:@"%senderStatusIcon%"].location != NSNotFound) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   785
		//Only cache the status icon to disk if the message style will actually use it
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   786
		[inString replaceKeyword:@"%senderStatusIcon%"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   787
					  withString:[self statusIconPathForListObject:theSource]];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   788
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   789
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   790
	//Replaces %localized{x}% with a a localized version of x, searching the style's localizations, and then Adium's localizations
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   791
	do{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   792
		range = [inString rangeOfString:@"%localized{"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   793
		if (range.location != NSNotFound) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   794
			NSRange endRange;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   795
			endRange = [inString rangeOfString:@"}%" options:NSLiteralSearch range:NSMakeRange(NSMaxRange(range), [inString length] - NSMaxRange(range))];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   796
			if (endRange.location != NSNotFound && endRange.location > NSMaxRange(range)) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   797
				NSString *untranslated = [inString substringWithRange:NSMakeRange(NSMaxRange(range), (endRange.location - NSMaxRange(range)))];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   798
				
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   799
				NSString *translated = [styleBundle localizedStringForKey:untranslated
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   800
																	value:untranslated
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   801
																	table:nil];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   802
				if (!translated || [translated length] == 0) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   803
					translated = [[NSBundle bundleForClass:[self class]] localizedStringForKey:untranslated
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   804
																						 value:untranslated
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   805
																						 table:nil];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   806
					if (!translated || [translated length] == 0) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   807
						translated = [[NSBundle mainBundle] localizedStringForKey:untranslated
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   808
																			value:untranslated
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   809
																			table:nil];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   810
					}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   811
				}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   812
				
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   813
				
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   814
				[inString safeReplaceCharactersInRange:NSUnionRange(range, endRange) 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   815
											withString:translated];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   816
			}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   817
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   818
	} while (range.location != NSNotFound);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   819
2565
bf1f209eea72 Patch from '''mathuaerknedam''' which adds a message style keyword `%userIcons%` which is replaced by `showIcons` if user icons are enabled in the Messages preferences and `hideIcons` if they aren't. This lets him do some CSS voodoo of some sort :) Fixes #11874
Evan Schoenberg
parents: 2564
diff changeset
   820
	[inString replaceKeyword:@"%userIcons%"
bf1f209eea72 Patch from '''mathuaerknedam''' which adds a message style keyword `%userIcons%` which is replaced by `showIcons` if user icons are enabled in the Messages preferences and `hideIcons` if they aren't. This lets him do some CSS voodoo of some sort :) Fixes #11874
Evan Schoenberg
parents: 2564
diff changeset
   821
				  withString:(showUserIcons ? @"showIcons" : @"hideIcons")];
bf1f209eea72 Patch from '''mathuaerknedam''' which adds a message style keyword `%userIcons%` which is replaced by `showIcons` if user icons are enabled in the Messages preferences and `hideIcons` if they aren't. This lets him do some CSS voodoo of some sort :) Fixes #11874
Evan Schoenberg
parents: 2564
diff changeset
   822
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   823
	[inString replaceKeyword:@"%messageClasses%"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   824
				  withString:[(contentIsSimilar ? @"consecutive " : @"") stringByAppendingString:[[content displayClasses] componentsJoinedByString:@" "]]];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   825
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   826
	[inString replaceKeyword:@"%senderColor%"
2807
e0421b510067 Add %incomingColor% and %outgoingColor%, remove %senderColor% in headers. Fixes #12666.
Zachary West <zacw@adium.im>
parents: 2799
diff changeset
   827
				  withString:[NSColor representedColorForObject:contentSource.UID withValidColors:self.validSenderColors]];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   828
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   829
	//HAX. The odd conditional here detects the rtl html that our html parser spits out.
3633
e06b74c6f7fd The RTL check must look at the encoded message, not the template, to determine if the encoded message contains RTL text. Fixes #10403
Evan Schoenberg
parents: 3632
diff changeset
   830
	BOOL isRTL = ([htmlEncodedMessage rangeOfString:@"<div dir=\"rtl\">"
e06b74c6f7fd The RTL check must look at the encoded message, not the template, to determine if the encoded message contains RTL text. Fixes #10403
Evan Schoenberg
parents: 3632
diff changeset
   831
                                            options:(NSCaseInsensitiveSearch | NSLiteralSearch)].location != NSNotFound);
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   832
	[inString replaceKeyword:@"%messageDirection%"
3579
b00b8bac3f80 When checking to see if the HTML includes an RTL div, do a case-insensitive search. This check had been broken by changes in AIHTMLDecoder; it's significantly less fragile if case insensitive. Fixes #10403 I believe, though I have not tested it.
Evan Schoenberg
parents: 3464
diff changeset
   833
				  withString:(isRTL ? @"rtl" : @"ltr")];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   834
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   835
	//Replaces %time{x}% with a timestamp formatted like x (using NSDateFormatter)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   836
	do{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   837
		range = [inString rangeOfString:@"%time{"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   838
		if (range.location != NSNotFound) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   839
			NSRange endRange;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   840
			endRange = [inString rangeOfString:@"}%" options:NSLiteralSearch range:NSMakeRange(NSMaxRange(range), [inString length] - NSMaxRange(range))];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   841
			if (endRange.location != NSNotFound && endRange.location > NSMaxRange(range)) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   842
				if (date) {
3180
6583a9ec00ef Cache NSDateFormatters in WKMV.
Colin Barrett <colin@springsandstruts.com>
parents: 3092
diff changeset
   843
					if (!timeFormatterCache) {
6583a9ec00ef Cache NSDateFormatters in WKMV.
Colin Barrett <colin@springsandstruts.com>
parents: 3092
diff changeset
   844
						timeFormatterCache = [[NSMutableDictionary alloc] init];
6583a9ec00ef Cache NSDateFormatters in WKMV.
Colin Barrett <colin@springsandstruts.com>
parents: 3092
diff changeset
   845
						[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(flushTimeFormatterCache:) name:@"AppleDatePreferencesChangedNotification" object:nil];
6583a9ec00ef Cache NSDateFormatters in WKMV.
Colin Barrett <colin@springsandstruts.com>
parents: 3092
diff changeset
   846
						[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(flushTimeFormatterCache:) name:@"AppleTimePreferencesChangedNotification" object:nil];
6583a9ec00ef Cache NSDateFormatters in WKMV.
Colin Barrett <colin@springsandstruts.com>
parents: 3092
diff changeset
   847
					}
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   848
					NSString *timeFormat = [inString substringWithRange:NSMakeRange(NSMaxRange(range), (endRange.location - NSMaxRange(range)))];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   849
					
3180
6583a9ec00ef Cache NSDateFormatters in WKMV.
Colin Barrett <colin@springsandstruts.com>
parents: 3092
diff changeset
   850
					NSDateFormatter *dateFormatter = [timeFormatterCache objectForKey:timeFormat];
6583a9ec00ef Cache NSDateFormatters in WKMV.
Colin Barrett <colin@springsandstruts.com>
parents: 3092
diff changeset
   851
					if (!dateFormatter) {
6583a9ec00ef Cache NSDateFormatters in WKMV.
Colin Barrett <colin@springsandstruts.com>
parents: 3092
diff changeset
   852
						if ([timeFormat rangeOfString:@"%"].location != NSNotFound) {
6583a9ec00ef Cache NSDateFormatters in WKMV.
Colin Barrett <colin@springsandstruts.com>
parents: 3092
diff changeset
   853
							/* Support strftime-style format strings, which old message styles may use */
6583a9ec00ef Cache NSDateFormatters in WKMV.
Colin Barrett <colin@springsandstruts.com>
parents: 3092
diff changeset
   854
							dateFormatter = [[NSDateFormatter alloc] initWithDateFormat:timeFormat allowNaturalLanguage:NO];
6583a9ec00ef Cache NSDateFormatters in WKMV.
Colin Barrett <colin@springsandstruts.com>
parents: 3092
diff changeset
   855
						} else {
6583a9ec00ef Cache NSDateFormatters in WKMV.
Colin Barrett <colin@springsandstruts.com>
parents: 3092
diff changeset
   856
							dateFormatter = [[NSDateFormatter alloc] init];
6583a9ec00ef Cache NSDateFormatters in WKMV.
Colin Barrett <colin@springsandstruts.com>
parents: 3092
diff changeset
   857
							[dateFormatter setDateFormat:timeFormat];
6583a9ec00ef Cache NSDateFormatters in WKMV.
Colin Barrett <colin@springsandstruts.com>
parents: 3092
diff changeset
   858
						}
6583a9ec00ef Cache NSDateFormatters in WKMV.
Colin Barrett <colin@springsandstruts.com>
parents: 3092
diff changeset
   859
						[timeFormatterCache setObject:dateFormatter forKey:timeFormat];
6583a9ec00ef Cache NSDateFormatters in WKMV.
Colin Barrett <colin@springsandstruts.com>
parents: 3092
diff changeset
   860
						[dateFormatter release];
11
1f14de003569 If the message style overrides the time stamp format with `%time{xyz}%`, guess whether it's Unicode or calendar format. Refs #10682.
Ryan Govostes
parents: 0
diff changeset
   861
					}
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   862
					
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   863
					[inString safeReplaceCharactersInRange:NSUnionRange(range, endRange) 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   864
												withString:[dateFormatter stringFromDate:date]];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   865
					
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   866
				} else
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   867
					[inString deleteCharactersInRange:NSUnionRange(range, endRange)];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   868
				
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   869
			}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   870
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   871
	} while (range.location != NSNotFound);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   872
	
1450
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   873
	do{
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   874
		range = [inString rangeOfString:@"%userIconPath%"];
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   875
		if (range.location != NSNotFound) {
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   876
			NSString    *userIconPath;
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   877
			NSString	*replacementString;
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   878
			
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   879
			userIconPath = [theSource valueForProperty:KEY_WEBKIT_USER_ICON];
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   880
			if (!userIconPath) {
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   881
				userIconPath = [theSource valueForProperty:@"UserIconPath"];
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   882
			}
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   883
			
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   884
			if (showUserIcons && userIconPath) {
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   885
				replacementString = [NSString stringWithFormat:@"file://%@", userIconPath];
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   886
				
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   887
			} else {
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   888
				replacementString = ([content isOutgoing]
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   889
									 ? @"Outgoing/buddy_icon.png" 
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   890
									 : @"Incoming/buddy_icon.png");
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   891
			}
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   892
			
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   893
			[inString safeReplaceCharactersInRange:range withString:replacementString];
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   894
		}
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   895
	} while (range.location != NSNotFound);
68908f1b8217 Tentative fix for #7508. aerk, please let me know if this works. Refs #7508
David Smith
parents: 1449
diff changeset
   896
	
1699
8bafbaf0f9be Add %service% to all WKMV templates. Fixes #11872. We use the chat's account's service instead of the source's because it is likely for statuses that the source does not exist. I don't see any other keywords which could potentially be used between status and message; the remaining are all rather specific to the type of content (sender, mostly, really). Fixes #11872.
Zachary West <zacw@adiumx.com>
parents: 1484
diff changeset
   897
	[inString replaceKeyword:@"%service%" 
8bafbaf0f9be Add %service% to all WKMV templates. Fixes #11872. We use the chat's account's service instead of the source's because it is likely for statuses that the source does not exist. I don't see any other keywords which could potentially be used between status and message; the remaining are all rather specific to the type of content (sender, mostly, really). Fixes #11872.
Zachary West <zacw@adiumx.com>
parents: 1484
diff changeset
   898
				  withString:[content.chat.account.service shortDescription]];
8bafbaf0f9be Add %service% to all WKMV templates. Fixes #11872. We use the chat's account's service instead of the source's because it is likely for statuses that the source does not exist. I don't see any other keywords which could potentially be used between status and message; the remaining are all rather specific to the type of content (sender, mostly, really). Fixes #11872.
Zachary West <zacw@adiumx.com>
parents: 1484
diff changeset
   899
	
2744
666f93364bb5 Replace %serviceIconPath% in all messages, and in the header. Fixes #12665 (though not quite the same).
Zachary West <zacw@adium.im>
parents: 2731
diff changeset
   900
	[inString replaceKeyword:@"%serviceIconPath%"
666f93364bb5 Replace %serviceIconPath% in all messages, and in the header. Fixes #12665 (though not quite the same).
Zachary West <zacw@adium.im>
parents: 2731
diff changeset
   901
				  withString:[AIServiceIcons pathForServiceIconForServiceID:content.chat.account.service.serviceID
666f93364bb5 Replace %serviceIconPath% in all messages, and in the header. Fixes #12665 (though not quite the same).
Zachary West <zacw@adium.im>
parents: 2731
diff changeset
   902
																	   type:AIServiceIconLarge]];
2954
31f6f4c62d78 Added a `%variant%` keyword for message styles, and rearranged code a bit so that an AIWebkitMessageViewStyle keeps track of its active variant rather than AIWebKitMessageViewController doing so and passing it back to the activeStyle with various invocations.
Evan Schoenberg
parents: 2939
diff changeset
   903
3191
41a9e7637f5b Don't allow spaces in the variant name when replacing %variant% keywords; replace them with an underscore (_). Fixes #12702
Evan Schoenberg
parents: 3180
diff changeset
   904
	if ([inString rangeOfString:@"%variant%"].location != NSNotFound) {
41a9e7637f5b Don't allow spaces in the variant name when replacing %variant% keywords; replace them with an underscore (_). Fixes #12702
Evan Schoenberg
parents: 3180
diff changeset
   905
		/* Per #12702, don't allow spaces in the variant name, as otherwise it becomes multiple css classes */
41a9e7637f5b Don't allow spaces in the variant name when replacing %variant% keywords; replace them with an underscore (_). Fixes #12702
Evan Schoenberg
parents: 3180
diff changeset
   906
		[inString replaceKeyword:@"%variant%"
41a9e7637f5b Don't allow spaces in the variant name when replacing %variant% keywords; replace them with an underscore (_). Fixes #12702
Evan Schoenberg
parents: 3180
diff changeset
   907
					  withString:[self.activeVariant stringByReplacingOccurrencesOfString:@" " withString:@"_"]];
41a9e7637f5b Don't allow spaces in the variant name when replacing %variant% keywords; replace them with an underscore (_). Fixes #12702
Evan Schoenberg
parents: 3180
diff changeset
   908
	}
2954
31f6f4c62d78 Added a `%variant%` keyword for message styles, and rearranged code a bit so that an AIWebkitMessageViewStyle keeps track of its active variant rather than AIWebKitMessageViewController doing so and passing it back to the activeStyle with various invocations.
Evan Schoenberg
parents: 2939
diff changeset
   909
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   910
	//message stuff
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   911
	if ([content isKindOfClass:[AIContentMessage class]]) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   912
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   913
		//Use [content source] directly rather than the potentially-metaContact theSource
1407
4b851ac0cb54 For display (WKMV), use the alias in chat as formatted UID and the display name in the chat as display name. For logging, set the <message>'s alias to the display name in the chat.
Zachary West <zacw@adiumx.com>
parents: 1309
diff changeset
   914
		NSString *formattedUID = nil;
4b851ac0cb54 For display (WKMV), use the alias in chat as formatted UID and the display name in the chat as display name. For logging, set the <message>'s alias to the display name in the chat.
Zachary West <zacw@adiumx.com>
parents: 1309
diff changeset
   915
		if ([content.chat aliasForContact:contentSource]) {
4b851ac0cb54 For display (WKMV), use the alias in chat as formatted UID and the display name in the chat as display name. For logging, set the <message>'s alias to the display name in the chat.
Zachary West <zacw@adiumx.com>
parents: 1309
diff changeset
   916
			formattedUID = [content.chat aliasForContact:contentSource];
4b851ac0cb54 For display (WKMV), use the alias in chat as formatted UID and the display name in the chat as display name. For logging, set the <message>'s alias to the display name in the chat.
Zachary West <zacw@adiumx.com>
parents: 1309
diff changeset
   917
		} else {
4b851ac0cb54 For display (WKMV), use the alias in chat as formatted UID and the display name in the chat as display name. For logging, set the <message>'s alias to the display name in the chat.
Zachary West <zacw@adiumx.com>
parents: 1309
diff changeset
   918
			formattedUID = contentSource.formattedUID;
4b851ac0cb54 For display (WKMV), use the alias in chat as formatted UID and the display name in the chat as display name. For logging, set the <message>'s alias to the display name in the chat.
Zachary West <zacw@adiumx.com>
parents: 1309
diff changeset
   919
		}
4b851ac0cb54 For display (WKMV), use the alias in chat as formatted UID and the display name in the chat as display name. For logging, set the <message>'s alias to the display name in the chat.
Zachary West <zacw@adiumx.com>
parents: 1309
diff changeset
   920
4b851ac0cb54 For display (WKMV), use the alias in chat as formatted UID and the display name in the chat as display name. For logging, set the <message>'s alias to the display name in the chat.
Zachary West <zacw@adiumx.com>
parents: 1309
diff changeset
   921
		NSString *displayName = [content.chat displayNameForContact:contentSource];
4b851ac0cb54 For display (WKMV), use the alias in chat as formatted UID and the display name in the chat as display name. For logging, set the <message>'s alias to the display name in the chat.
Zachary West <zacw@adiumx.com>
parents: 1309
diff changeset
   922
		
2731
0cd78c81e7bd Patch from mathuaerknedam to replace status keywords in messages with blanks, and vice versa. Fixes #11872.
Zachary West <zacw@adium.im>
parents: 2565
diff changeset
   923
		[inString replaceKeyword:@"%status%"
0cd78c81e7bd Patch from mathuaerknedam to replace status keywords in messages with blanks, and vice versa. Fixes #11872.
Zachary West <zacw@adium.im>
parents: 2565
diff changeset
   924
					  withString:@""];
0cd78c81e7bd Patch from mathuaerknedam to replace status keywords in messages with blanks, and vice versa. Fixes #11872.
Zachary West <zacw@adium.im>
parents: 2565
diff changeset
   925
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   926
		[inString replaceKeyword:@"%senderScreenName%" 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   927
					  withString:[(formattedUID ?
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   928
								   formattedUID :
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   929
								   displayName) stringByEscapingForXMLWithEntities:nil]];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   930
		 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   931
        
1700
b586b027de42 Adds the keyword %senderPrefix% which is substituted by the textual representation of the sender's current status in a chat (@ for op, + for voice, % for halfop, . for founder, and an empty string if none). Fixes #11882.
Zachary West <zacw@adiumx.com>
parents: 1699
diff changeset
   932
		[inString replaceKeyword:@"%senderPrefix%"
b586b027de42 Adds the keyword %senderPrefix% which is substituted by the textual representation of the sender's current status in a chat (@ for op, + for voice, % for halfop, . for founder, and an empty string if none). Fixes #11882.
Zachary West <zacw@adiumx.com>
parents: 1699
diff changeset
   933
					  withString:((AIContentMessage *)content).senderPrefix];
b586b027de42 Adds the keyword %senderPrefix% which is substituted by the textual representation of the sender's current status in a chat (@ for op, + for voice, % for halfop, . for founder, and an empty string if none). Fixes #11882.
Zachary West <zacw@adiumx.com>
parents: 1699
diff changeset
   934
		
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   935
		do{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   936
			range = [inString rangeOfString:@"%sender%"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   937
			if (range.location != NSNotFound) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   938
				NSString		*senderDisplay = nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   939
				if (useCustomNameFormat) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   940
			 		if (formattedUID && ![displayName isEqualToString:formattedUID]) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   941
						switch (nameFormat) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   942
							case AIDefaultName:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   943
								break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   944
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   945
							case AIDisplayName:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   946
								senderDisplay = displayName;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   947
								break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   948
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   949
							case AIDisplayName_ScreenName:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   950
								senderDisplay = [NSString stringWithFormat:@"%@ (%@)",displayName,formattedUID];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   951
								break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   952
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   953
							case AIScreenName_DisplayName:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   954
								senderDisplay = [NSString stringWithFormat:@"%@ (%@)",formattedUID,displayName];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   955
								break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   956
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   957
							case AIScreenName:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   958
								senderDisplay = formattedUID;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   959
								break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   960
						}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   961
					}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   962
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   963
					//Test both displayName and formattedUID for nil-ness. If they're both nil, the assertion will trip.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   964
					if (!senderDisplay) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   965
						senderDisplay = displayName;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   966
						if (!senderDisplay) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   967
							senderDisplay = formattedUID;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   968
							if (!senderDisplay) {
3006
ce8a17cc6a79 If we don't have a content's source, avoid completely destroying Adium's state with an assertion.
Zachary West <zacw@adium.im>
parents: 2954
diff changeset
   969
								AILog(@"XXX we don't have a sender for %@ (%@)", content, [content message]);
ce8a17cc6a79 If we don't have a content's source, avoid completely destroying Adium's state with an assertion.
Zachary West <zacw@adium.im>
parents: 2954
diff changeset
   970
								NSLog(@"Enormous error: we don't have a sender for %@ (%@)", content, [content message]);
ce8a17cc6a79 If we don't have a content's source, avoid completely destroying Adium's state with an assertion.
Zachary West <zacw@adium.im>
parents: 2954
diff changeset
   971
								
ce8a17cc6a79 If we don't have a content's source, avoid completely destroying Adium's state with an assertion.
Zachary West <zacw@adium.im>
parents: 2954
diff changeset
   972
								// This shouldn't happen.
ce8a17cc6a79 If we don't have a content's source, avoid completely destroying Adium's state with an assertion.
Zachary West <zacw@adium.im>
parents: 2954
diff changeset
   973
								senderDisplay = @"(unknown)";
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   974
							}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   975
						}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   976
					}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   977
				} else {
1407
4b851ac0cb54 For display (WKMV), use the alias in chat as formatted UID and the display name in the chat as display name. For logging, set the <message>'s alias to the display name in the chat.
Zachary West <zacw@adiumx.com>
parents: 1309
diff changeset
   978
					senderDisplay = displayName;
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   979
				}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   980
				
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   981
				if ([(AIContentMessage *)content isAutoreply]) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   982
					senderDisplay = [NSString stringWithFormat:@"%@ %@",senderDisplay,AILocalizedString(@"(Autoreply)","Short word inserted after the sender's name when displaying a message which was an autoresponse")];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   983
				}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   984
					
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   985
				[inString safeReplaceCharactersInRange:range withString:[senderDisplay stringByEscapingForXMLWithEntities:nil]];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   986
			}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   987
		} while (range.location != NSNotFound);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   988
        
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   989
		do {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   990
			range = [inString rangeOfString:@"%senderDisplayName%"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   991
			if (range.location != NSNotFound) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   992
				NSString *serversideDisplayName = ([theSource isKindOfClass:[AIListContact class]] ?
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   993
												   [(AIListContact *)theSource serversideDisplayName] :
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   994
												   nil);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   995
				if (!serversideDisplayName) {
837
ea0e003be6c6 Dot syntax. Lots of it.
David Smith
parents: 715
diff changeset
   996
					serversideDisplayName = theSource.displayName;
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   997
				}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   998
				
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   999
				[inString safeReplaceCharactersInRange:range
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1000
											withString:[serversideDisplayName stringByEscapingForXMLWithEntities:nil]];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1001
			}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1002
		} while (range.location != NSNotFound);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1003
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1004
		//Blatantly stealing the date code for the background color script.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1005
		do{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1006
			range = [inString rangeOfString:@"%textbackgroundcolor{"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1007
			if (range.location != NSNotFound) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1008
				NSRange endRange;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1009
				endRange = [inString rangeOfString:@"}%" options:NSLiteralSearch range:NSMakeRange(NSMaxRange(range), [inString length] - NSMaxRange(range))];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1010
				if (endRange.location != NSNotFound && endRange.location > NSMaxRange(range)) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1011
					NSString *transparency = [inString substringWithRange:NSMakeRange(NSMaxRange(range),
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1012
																					  (endRange.location - NSMaxRange(range)))];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1013
					
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1014
					if (allowTextBackgrounds && showIncomingColors) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1015
						NSString *thisIsATemporaryString;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1016
						unsigned rgb = 0, red, green, blue;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1017
						NSScanner *hexcode;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1018
						thisIsATemporaryString = [AIHTMLDecoder encodeHTML:[content message] headers:NO 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1019
																  fontTags:NO
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1020
														includingColorTags:NO
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1021
															 closeFontTags:NO
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1022
																 styleTags:NO
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1023
												closeStyleTagsOnFontChange:NO
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1024
															encodeNonASCII:NO
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1025
															  encodeSpaces:NO
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1026
																imagesPath:NSTemporaryDirectory()
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1027
														 attachmentsAsText:NO
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1028
												 onlyIncludeOutgoingImages:NO
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1029
															simpleTagsOnly:NO
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1030
															bodyBackground:YES
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1031
													   allowJavascriptURLs:NO];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1032
						hexcode = [NSScanner scannerWithString:thisIsATemporaryString];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1033
						[hexcode scanHexInt:&rgb];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1034
						if (![thisIsATemporaryString length] && rgb == 0) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1035
							[inString deleteCharactersInRange:NSUnionRange(range, endRange)];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1036
						} else {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1037
							red = (rgb & 0xff0000) >> 16;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1038
							green = (rgb & 0x00ff00) >> 8;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1039
							blue = rgb & 0x0000ff;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1040
							[inString safeReplaceCharactersInRange:NSUnionRange(range, endRange)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1041
														withString:[NSString stringWithFormat:@"rgba(%d, %d, %d, %@)", red, green, blue, transparency]];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1042
						}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1043
					} else {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1044
						[inString deleteCharactersInRange:NSUnionRange(range, endRange)];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1045
					}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1046
				} else if (endRange.location == NSMaxRange(range)) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1047
					if (allowTextBackgrounds && showIncomingColors) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1048
						NSString *thisIsATemporaryString;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1049
						
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1050
						thisIsATemporaryString = [AIHTMLDecoder encodeHTML:[content message] headers:NO 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1051
																  fontTags:NO
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1052
														includingColorTags:NO
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1053
															 closeFontTags:NO
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents: