Plugins/WebKit Message View/AIWebKitMessageViewController.m
author Evan Schoenberg
Thu, 14 Nov 2019 19:44:51 -0500
branchadium-1.5.10.5
changeset 6008 651cb717da1b
parent 5345 8dd0d808e092
permissions -rw-r--r--
Finish merge
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 "AIWebKitMessageViewController.h"
6008
651cb717da1b Finish merge
Evan Schoenberg
parents: 5345
diff changeset
    18
#import "AIWebkitMessageViewStyle.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
    19
#import "AIWebKitMessageViewPlugin.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 "ESWebKitMessageViewPreferences.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 "AIWebKitDelegate.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 "ESFileTransferRequestPromptController.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 "ESWebView.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
    24
#import <Adium/AIContactControllerProtocol.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
    25
#import <Adium/AIContentControllerProtocol.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/AIMenuControllerProtocol.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/AIFileTransferControllerProtocol.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/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
    29
#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: 1240
diff changeset
    30
#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
    31
#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
    32
#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
    33
#import <Adium/AIContentEvent.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/AIEmoticon.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/AIListContact.h>
554
08137eb66729 More @classing
David Smith
parents: 529
diff changeset
    36
#import <Adium/AIMetaContact.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
    37
#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
    38
#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
    39
#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
    40
#import <Adium/ESTextAndButtonsWindowController.h>
1297
65f14165fb0b Changes to the topics: %message% is now replaced by an editable <span>?</span> with an id of "topicEdit", allowing us much easier access to its specific contents. Set up an editing delegate on the WebView to monitor editable text (so, you know, the topic). Currently it gets to the point where it knows what text to update. However, I need to abstract AIChat knowing its topic and a hook into the account to update topics, first.
Zachary West <zacw@adiumx.com>
parents: 1292
diff changeset
    41
#import <Adium/AIHTMLDecoder.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
    42
#import <AIUtilities/AIArrayAdditions.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
    43
#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
    44
#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
    45
#import <AIUtilities/AIFileManagerAdditions.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
    46
#import <AIUtilities/AIImageAdditions.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
    47
#import <AIUtilities/AIMenuAdditions.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
    48
#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
    49
#import <AIUtilities/AIPasteboardAdditions.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
    50
#import <AIUtilities/AIStringAdditions.h>
1301
fb82ac8f55ca Store the topic and topic setter in an AIChat. Add an accessor to AIAccount which determines if group chats can set topics (currently this only sets it to YES for IRC?I think XMPP supports it also, so in a future commit?). Adds a method to AIAccount to set the topic in a chat, which IRC implements in a very crude manner.
Zachary West <zacw@adiumx.com>
parents: 1298
diff changeset
    51
#import <AIUtilities/AIAttributedStringAdditions.h>
1534
c14fa8460138 Copy JVMarkedScroller from Colloquy, giving us the ability to mark arbitrary locations in the scroll bar. Right now we mark the location of mentions, but this is a little clunky and inexact; I need to play with it a bit more, add the ability to mark when we lose focus, and center the jump-to position when moving.
Zachary West <zacw@adiumx.com>
parents: 1488
diff changeset
    52
#import <AIUtilities/JVMarkedScroller.h>
2305
6c5abb8a67a4 Call me paranoid, but when Apple introduces a function like sel_isEqual(), I tend to assume there's some reason for it.
David Smith <catfish.man@gmail.com>
parents: 2182
diff changeset
    53
#import <objc/objc-runtime.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
    54
e22ad6bc8b46 svn 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
#define KEY_WEBKIT_CHATS_USING_CACHED_ICON @"WebKit:Chats Using Cached Icon"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    56
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    57
#define USE_FASTER_BUT_BUGGY_WEBKIT_PREFERENCE_CHANGE_HANDLING FALSE
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    58
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    59
#define TEMPORARY_FILE_PREFIX	@"TEMP"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    60
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: 79
diff changeset
    61
@interface AIWebKitMessageViewController ()
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
    62
- (id)initForChat:(AIChat *)inChat withPlugin:(AIWebKitMessageViewPlugin *)inPlugin;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    63
- (void)_initWebView;
e22ad6bc8b46 svn 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
- (void)_primeWebViewAndReprocessContent:(BOOL)reprocessContent;
e22ad6bc8b46 svn 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)_updateWebViewForCurrentPreferences;
e22ad6bc8b46 svn 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)_updateVariantWithoutPrimingView;
e22ad6bc8b46 svn 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
- (void)processQueuedContent;
e22ad6bc8b46 svn 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
- (void)_processContentObject:(AIContentObject *)content willAddMoreContentObjects:(BOOL)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
    69
- (void)_appendContent:(AIContentObject *)content similar:(BOOL)contentIsSimilar willAddMoreContentObjects:(BOOL)willAddMoreContentObjects replaceLastContent:(BOOL)replaceLastContent;
4646
8fc9e07216a8 We should add content to the WKMV after DOM is ready. Fixes #15377, Message History Only Shows on 1st Tab on Startup.
Adrian Godoroja <robotive@me.com>
parents: 4498
diff changeset
    70
- (void)_setDocumentReady;
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
    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
- (NSString *)_webKitBackgroundImagePathForUniqueID:(NSInteger)uniqueID;
e22ad6bc8b46 svn 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
- (NSString *)_webKitUserIconPathForObject:(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
    74
- (void)releaseCurrentWebKitUserIconForObject:(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
    75
- (void)releaseAllCachedIcons;
e22ad6bc8b46 svn 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
- (void)updateUserIconForObject:(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
    77
- (void)userIconForObjectDidChange:(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
    78
- (void)updateServiceIcon;
1487
1e40e4ee17ae We can't just push topics through the content controller, since it drops empty stringed messages (and removing this requirement causes a whole world of problems). Filter it ourselves, then display it.
Zachary West <zacw@adiumx.com>
parents: 1485
diff changeset
    79
- (void)updateTopic;
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
    80
e22ad6bc8b46 svn 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
- (void)participatingListObjectsChanged:(NSNotification *)notification;
e22ad6bc8b46 svn 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
- (void)sourceOrDestinationChanged:(NSNotification *)notification;
e22ad6bc8b46 svn 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
- (BOOL)shouldHandleDragWithPasteboard:(NSPasteboard *)pasteboard;
e22ad6bc8b46 svn 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
- (void)enqueueContentObject:(AIContentObject *)contentObject;
e22ad6bc8b46 svn 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
- (void)debugLog:(NSString *)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
    86
- (void)processQueuedContent;
e22ad6bc8b46 svn 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
- (NSString *)webviewSource;
e22ad6bc8b46 svn 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
- (void) setIsGroupChat:(BOOL) flag;
1534
c14fa8460138 Copy JVMarkedScroller from Colloquy, giving us the ability to mark arbitrary locations in the scroll bar. Right now we mark the location of mentions, but this is a little clunky and inexact; I need to play with it a bit more, add the ability to mark when we lose focus, and center the jump-to position when moving.
Zachary West <zacw@adiumx.com>
parents: 1488
diff changeset
    89
c14fa8460138 Copy JVMarkedScroller from Colloquy, giving us the ability to mark arbitrary locations in the scroll bar. Right now we mark the location of mentions, but this is a little clunky and inexact; I need to play with it a bit more, add the ability to mark when we lose focus, and center the jump-to position when moving.
Zachary West <zacw@adiumx.com>
parents: 1488
diff changeset
    90
- (void)setupMarkedScroller;
c14fa8460138 Copy JVMarkedScroller from Colloquy, giving us the ability to mark arbitrary locations in the scroll bar. Right now we mark the location of mentions, but this is a little clunky and inexact; I need to play with it a bit more, add the ability to mark when we lose focus, and center the jump-to position when moving.
Zachary West <zacw@adiumx.com>
parents: 1488
diff changeset
    91
- (JVMarkedScroller *)markedScroller;
1543
99d18b12a90c Add a new Main Menu item "Display" (we could potentially rename this; I can't really think of a better term, but it's almost too similar to View). Moves the "Toggle User List" menu item into it, and adds "Jump to (Previous, Next, Focus) Mark" and "Add Mark". Add Mark inserts a green mark.
Zachary West <zacw@adiumx.com>
parents: 1542
diff changeset
    92
- (NSNumber *)currentOffsetHeight;
1534
c14fa8460138 Copy JVMarkedScroller from Colloquy, giving us the ability to mark arbitrary locations in the scroll bar. Right now we mark the location of mentions, but this is a little clunky and inexact; I need to play with it a bit more, add the ability to mark when we lose focus, and center the jump-to position when moving.
Zachary West <zacw@adiumx.com>
parents: 1488
diff changeset
    93
- (void)markCurrentLocation;
3092
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3087
diff changeset
    94
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3087
diff changeset
    95
- (void)contentObjectAdded:(NSNotification *)notification;
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3087
diff changeset
    96
- (void)chatDidFinishAddingUntrackedContent:(NSNotification *)notification;
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3087
diff changeset
    97
- (void)customEmoticonUpdated:(NSNotification *)inNotification;
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3087
diff changeset
    98
- (void)listObjectAttributesChanged:(NSNotification *)notification;
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3087
diff changeset
    99
- (BOOL)zoomImage:(DOMHTMLImageElement *)img;
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
   100
@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
   101
e22ad6bc8b46 svn 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
static NSArray *draggedTypes = 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
   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
@implementation AIWebKitMessageViewController
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 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
+ (AIWebKitMessageViewController *)messageDisplayControllerForChat:(AIChat *)inChat withPlugin:(AIWebKitMessageViewPlugin *)inPlugin
e22ad6bc8b46 svn 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
{
e22ad6bc8b46 svn 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
    return [[[self alloc] initForChat:inChat withPlugin:inPlugin] 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
   109
}
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 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
- (id)initForChat:(AIChat *)inChat withPlugin:(AIWebKitMessageViewPlugin *)inPlugin
e22ad6bc8b46 svn 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
    //init
4308
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   114
    if ((self = [super init])) {
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
   115
		[self _initWebView];
e22ad6bc8b46 svn 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
		
e22ad6bc8b46 svn 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
		delegateProxy = [AIWebKitDelegate sharedWebKitDelegate];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   118
		
e22ad6bc8b46 svn 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
		chat = [inChat 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
   120
		plugin = [inPlugin 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
   121
		contentQueue = [[NSMutableArray 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
   122
		objectIconPathDict = [[NSMutableDictionary 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
   123
		objectsWithUserIconsArray = [[NSMutableArray alloc] init];
1231
2a7c18b7cd27 Going to have to play with the content objects later, reverting for now.
Zachary West <zacw@adiumx.com>
parents: 1230
diff changeset
   124
		shouldReflectPreferenceChanges = NO;
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
   125
		storedContentObjects = nil;
3152
61e07c6048df Default nextMessageFocus to YES in AIWebKitMessageViewController so that the first content received, if the chat isn't in focus, will still be known to be first. Fixes #13793
Evan Schoenberg
parents: 3144
diff changeset
   126
		/* If we receive content before gaining focus, we'll want to know the first content received is the first to be
61e07c6048df Default nextMessageFocus to YES in AIWebKitMessageViewController so that the first content received, if the chat isn't in focus, will still be known to be first. Fixes #13793
Evan Schoenberg
parents: 3144
diff changeset
   127
		 * classed as such.
61e07c6048df Default nextMessageFocus to YES in AIWebKitMessageViewController so that the first content received, if the chat isn't in focus, will still be known to be first. Fixes #13793
Evan Schoenberg
parents: 3144
diff changeset
   128
		 */
61e07c6048df Default nextMessageFocus to YES in AIWebKitMessageViewController so that the first content received, if the chat isn't in focus, will still be known to be first. Fixes #13793
Evan Schoenberg
parents: 3144
diff changeset
   129
		nextMessageFocus = YES;
3822
67a59959597d As requested by mathuaerknedam, also add a regainedFocus CSS class to the first message received after regaining focus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3770
diff changeset
   130
		nextMessageRegainedFocus = YES;
3152
61e07c6048df Default nextMessageFocus to YES in AIWebKitMessageViewController so that the first content received, if the chat isn't in focus, will still be known to be first. Fixes #13793
Evan Schoenberg
parents: 3144
diff changeset
   131
		
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
   132
		//Observe preference changes.
1205
100cfdc6946c Allow the user to specify preferences for group chats independently of those for regular chats. This includes styles, etc. There are now two separate preference groups, though the old one is renamed its value is still the same (i.e., old preferences carry over). The one for group chats, however, will begin fresh. Fixes #87.
Zachary West <zacw@adiumx.com>
parents: 1109
diff changeset
   133
		[adium.preferenceController registerPreferenceObserver:self forGroup:PREF_GROUP_WEBKIT_REGULAR_MESSAGE_DISPLAY];
100cfdc6946c Allow the user to specify preferences for group chats independently of those for regular chats. This includes styles, etc. There are now two separate preference groups, though the old one is renamed its value is still the same (i.e., old preferences carry over). The one for group chats, however, will begin fresh. Fixes #87.
Zachary West <zacw@adiumx.com>
parents: 1109
diff changeset
   134
		[adium.preferenceController registerPreferenceObserver:self forGroup:PREF_GROUP_WEBKIT_GROUP_MESSAGE_DISPLAY];
95
47acbc0cc17a Propertyize AIListObject and convert some more controller accesses to dot syntax
David Smith
parents: 84
diff changeset
   135
		[adium.preferenceController registerPreferenceObserver:self forGroup:PREF_GROUP_WEBKIT_BACKGROUND_IMAGES];
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
   136
		
1208
6253704bc78b Store the preference group in the message view controller, so that we can edit it based on a new preference which isn't yet hooked: use regular style for group chats. Need to think of a decent UI for displaying this.
Zachary West <zacw@adiumx.com>
parents: 1205
diff changeset
   137
		//Set ourselves up initially.
6253704bc78b Store the preference group in the message view controller, so that we can edit it based on a new preference which isn't yet hooked: use regular style for group chats. Need to think of a decent UI for displaying this.
Zachary West <zacw@adiumx.com>
parents: 1205
diff changeset
   138
		[self _updateWebViewForCurrentPreferences];
6253704bc78b Store the preference group in the message view controller, so that we can edit it based on a new preference which isn't yet hooked: use regular style for group chats. Need to think of a decent UI for displaying this.
Zachary West <zacw@adiumx.com>
parents: 1205
diff changeset
   139
		
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
   140
		//Observe participants list changes
1109
092c44a2cfbb Having a separate notification center for Adium leads to the possibility of accidentally using the wrong one, which has tripped me up on more than one occasion. This switches us over to using the default center.
David Smith
parents: 966
diff changeset
   141
		[[NSNotificationCenter defaultCenter] addObserver:self 
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
   142
									   selector:@selector(participatingListObjectsChanged:)
e22ad6bc8b46 svn 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
										   name:Chat_ParticipatingListObjectsChanged 
e22ad6bc8b46 svn 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
										 object:inChat];
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 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
		//Observe source/destination changes
1109
092c44a2cfbb Having a separate notification center for Adium leads to the possibility of accidentally using the wrong one, which has tripped me up on more than one occasion. This switches us over to using the default center.
David Smith
parents: 966
diff changeset
   147
		[[NSNotificationCenter defaultCenter] addObserver:self 
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
   148
									   selector:@selector(sourceOrDestinationChanged:)
e22ad6bc8b46 svn 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
										   name:Chat_SourceChanged 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   150
										 object:inChat];
1109
092c44a2cfbb Having a separate notification center for Adium leads to the possibility of accidentally using the wrong one, which has tripped me up on more than one occasion. This switches us over to using the default center.
David Smith
parents: 966
diff changeset
   151
		[[NSNotificationCenter defaultCenter] addObserver:self 
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
   152
									   selector:@selector(sourceOrDestinationChanged:)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   153
										   name:Chat_DestinationChanged 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   154
										 object:inChat];
e22ad6bc8b46 svn 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
		//Observe content additons
1109
092c44a2cfbb Having a separate notification center for Adium leads to the possibility of accidentally using the wrong one, which has tripped me up on more than one occasion. This switches us over to using the default center.
David Smith
parents: 966
diff changeset
   157
		[[NSNotificationCenter defaultCenter] addObserver:self 
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
   158
									   selector:@selector(contentObjectAdded:)
e22ad6bc8b46 svn 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
										   name:Content_ContentObjectAdded 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   160
										 object:inChat];
1109
092c44a2cfbb Having a separate notification center for Adium leads to the possibility of accidentally using the wrong one, which has tripped me up on more than one occasion. This switches us over to using the default center.
David Smith
parents: 966
diff changeset
   161
		[[NSNotificationCenter defaultCenter] addObserver:self 
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
   162
									   selector:@selector(chatDidFinishAddingUntrackedContent:)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   163
										   name:Content_ChatDidFinishAddingUntrackedContent 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   164
										 object:inChat];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   165
1109
092c44a2cfbb Having a separate notification center for Adium leads to the possibility of accidentally using the wrong one, which has tripped me up on more than one occasion. This switches us over to using the default center.
David Smith
parents: 966
diff changeset
   166
		[[NSNotificationCenter defaultCenter] addObserver:self
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
   167
									   selector:@selector(customEmoticonUpdated:)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   168
										   name:@"AICustomEmoticonUpdated"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   169
										 object:inChat];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   170
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   171
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   172
    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
   173
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   174
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   175
- (void)messageViewIsClosing
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   176
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   177
	[webView stopLoading: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
   178
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   179
	//Stop observing the webview, since it may attempt callbacks shortly after we 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
   180
	[delegateProxy removeDelegate: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
   181
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   182
	/* The windowScriptObject retained self when we set it as the client in -[AIWebKitMessageViewController _initWebView]...
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   183
	 * Unfortunately, (as of 10.4.9) it won't actually release self until the webView deallocates.  We'll do removeWebScriptKey:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   184
	 * now in case that works properly later, and do the release of webView here rather than in dealloc to work around the bug.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   185
	 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   186
	[[webView windowScriptObject] removeWebScriptKey:@"client"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   187
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   188
	//Release the web view
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   189
	[webView release]; webView = 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
   190
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   191
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   192
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   193
 * @brief Deallocate
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   194
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   195
- (void)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
   196
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   197
	[self releaseAllCachedIcons];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   198
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   199
	[plugin release]; plugin = 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
   200
	[objectsWithUserIconsArray release]; objectsWithUserIconsArray = 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
   201
	[objectIconPathDict release]; objectIconPathDict = 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
   202
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   203
	//Stop any delayed requests and remove all observers
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   204
	[NSObject cancelPreviousPerformRequestsWithTarget:self];
95
47acbc0cc17a Propertyize AIListObject and convert some more controller accesses to dot syntax
David Smith
parents: 84
diff changeset
   205
	[adium.preferenceController unregisterPreferenceObserver:self];
1109
092c44a2cfbb Having a separate notification center for Adium leads to the possibility of accidentally using the wrong one, which has tripped me up on more than one occasion. This switches us over to using the default center.
David Smith
parents: 966
diff changeset
   206
	[[NSNotificationCenter defaultCenter] removeObserver:self];
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
   207
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   208
	//Clean up style/variant info
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   209
	[messageStyle release]; messageStyle = 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
   210
	[activeStyle release]; activeStyle = nil;
1208
6253704bc78b Store the preference group in the message view controller, so that we can edit it based on a new preference which isn't yet hooked: use regular style for group chats. Need to think of a decent UI for displaying this.
Zachary West <zacw@adiumx.com>
parents: 1205
diff changeset
   211
	[preferenceGroup release]; preferenceGroup = 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
   212
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   213
	//Cleanup content processing
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   214
	[contentQueue release]; contentQueue = 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
   215
	[storedContentObjects release]; storedContentObjects = 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
   216
	[previousContent release]; previousContent = 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
   217
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   218
	//Release the 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
   219
	[chat release]; chat = nil;
1617
6f97091397c9 Don't leak marked scrollers; release them when the WKMV is deallocated.
Zachary West <zacw@adiumx.com>
parents: 1582
diff changeset
   220
	
6f97091397c9 Don't leak marked scrollers; release them when the WKMV is deallocated.
Zachary West <zacw@adiumx.com>
parents: 1582
diff changeset
   221
	//Release the marked scroller
6f97091397c9 Don't leak marked scrollers; release them when the WKMV is deallocated.
Zachary West <zacw@adiumx.com>
parents: 1582
diff changeset
   222
	[self.markedScroller 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
   223
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   224
	[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
   225
}
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 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
- (void)setShouldReflectPreferenceChanges:(BOOL)inValue
e22ad6bc8b46 svn 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
{
e22ad6bc8b46 svn 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
	shouldReflectPreferenceChanges = inValue;
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 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
	//We'll want to start storing content objects if we're needing to reflect preference changes
e22ad6bc8b46 svn 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
	if (shouldReflectPreferenceChanges) {
e22ad6bc8b46 svn 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
		if (!storedContentObjects) {
e22ad6bc8b46 svn 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
			storedContentObjects = [[NSMutableArray 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
   235
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   236
	} 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
   237
		[storedContentObjects release]; storedContentObjects = 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
   238
	}
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   241
- (void)adiumPrint:(id)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
   242
{	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   243
	WebPreferences* prefs = [webView preferences];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   244
	[prefs setShouldPrintBackgrounds: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
   245
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   246
	[[[[webView mainFrame] frameView] documentView] print: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
   247
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   248
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   249
//WebView --------------------------------------------------------------------------------------------------
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   250
#pragma mark WebView
2443
35f6b312d24c Synthesize a bunch of message view controller/message style methods
David Smith <catfish.man@gmail.com>
parents: 2305
diff changeset
   251
35f6b312d24c Synthesize a bunch of message view controller/message style methods
David Smith <catfish.man@gmail.com>
parents: 2305
diff changeset
   252
@synthesize messageStyle, messageView = webView;
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
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   254
- (NSView *)messageScrollView
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   255
{
e22ad6bc8b46 svn 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
	return [[webView mainFrame] frameView];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   257
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   258
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   259
/*!
e22ad6bc8b46 svn 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
 * @brief Apply preference changes to our webview
e22ad6bc8b46 svn 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
 */
e22ad6bc8b46 svn 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
- (void)preferencesChangedForGroup:(NSString *)group key:(NSString *)key object:(AIListObject *)object
e22ad6bc8b46 svn 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
					preferenceDict:(NSDictionary *)prefDict firstTime:(BOOL)firstTime
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   264
{
1230
7ca8d2b769d9 Set shouldReflectPreferenceChanges to YES by default. Programmatic access to content and dynamic style updating is a pretty good idea. I want to see how it works in practice. The former isn't there yet, and the latter breaks if you click "use regular styles for group chats".
Zachary West <zacw@adiumx.com>
parents: 1208
diff changeset
   265
	// First time won't occur because preferenceGroup is not yet set. Don't run on the assumption that it is, end early.
7ca8d2b769d9 Set shouldReflectPreferenceChanges to YES by default. Programmatic access to content and dynamic style updating is a pretty good idea. I want to see how it works in practice. The former isn't there yet, and the latter breaks if you click "use regular styles for group chats".
Zachary West <zacw@adiumx.com>
parents: 1208
diff changeset
   266
	if (!preferenceGroup)
7ca8d2b769d9 Set shouldReflectPreferenceChanges to YES by default. Programmatic access to content and dynamic style updating is a pretty good idea. I want to see how it works in practice. The former isn't there yet, and the latter breaks if you click "use regular styles for group chats".
Zachary West <zacw@adiumx.com>
parents: 1208
diff changeset
   267
		return;
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
   268
	
1208
6253704bc78b Store the preference group in the message view controller, so that we can edit it based on a new preference which isn't yet hooked: use regular style for group chats. Need to think of a decent UI for displaying this.
Zachary West <zacw@adiumx.com>
parents: 1205
diff changeset
   269
	if ([group isEqualToString:preferenceGroup]) {
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
   270
#if USE_FASTER_BUT_BUGGY_WEBKIT_PREFERENCE_CHANGE_HANDLING
e22ad6bc8b46 svn 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
		NSString		*variantKey = [plugin styleSpecificKey:@"Variant" forStyle:activeStyle];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   272
		//Variant changes we can apply immediately.  All other changes require us to reload the view
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   273
		if (!firstTime && [key isEqualToString:variantKey]) {
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: 2951
diff changeset
   274
			messageStyle.activeVariant = [prefDict objectForKey:variantKey];
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
   275
			[self _updateVariantWithoutPrimingView];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   276
			
1208
6253704bc78b Store the preference group in the message view controller, so that we can edit it based on a new preference which isn't yet hooked: use regular style for group chats. Need to think of a decent UI for displaying this.
Zachary West <zacw@adiumx.com>
parents: 1205
diff changeset
   277
		} else if (shouldReflectPreferenceChanges) {
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
   278
			//Ignore changes related to our background image cache.  These keys are used for storage only and aren't
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   279
			//something we need to update in response to.  All other display changes we update our view for.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   280
			if (![key isEqualToString:@"BackgroundCacheUniqueID"] &&
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   281
			    ![key isEqualToString:[plugin styleSpecificKey:@"BackgroundCachePath" forStyle:activeStyle]] &&
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   282
				![key isEqualToString:KEY_CURRENT_WEBKIT_STYLE_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
   283
				[self _updateWebViewForCurrentPreferences];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   284
			}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   285
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   286
#else
1208
6253704bc78b Store the preference group in the message view controller, so that we can edit it based on a new preference which isn't yet hooked: use regular style for group chats. Need to think of a decent UI for displaying this.
Zachary West <zacw@adiumx.com>
parents: 1205
diff changeset
   287
		if (shouldReflectPreferenceChanges) {
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
   288
			//Ignore changes related to our background image cache.  These keys are used for storage only and aren't
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   289
			//something we need to update in response to.  All other display changes we update our view for.
e22ad6bc8b46 svn 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
			if (![key isEqualToString:@"BackgroundCacheUniqueID"] &&
e22ad6bc8b46 svn 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
			    ![key isEqualToString:[plugin styleSpecificKey:@"BackgroundCachePath" forStyle:activeStyle]] &&
e22ad6bc8b46 svn 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
				(![key isEqualToString:KEY_CURRENT_WEBKIT_STYLE_PATH] || shouldReflectPreferenceChanges)) {
e22ad6bc8b46 svn 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
				if (!isUpdatingWebViewForCurrentPreferences) {
e22ad6bc8b46 svn 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
					[self _updateWebViewForCurrentPreferences];
e22ad6bc8b46 svn 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
		}
e22ad6bc8b46 svn 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
#endif
e22ad6bc8b46 svn 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
	}
e22ad6bc8b46 svn 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
	
e22ad6bc8b46 svn 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
	if (([group isEqualToString:PREF_GROUP_WEBKIT_BACKGROUND_IMAGES] && shouldReflectPreferenceChanges)) {
e22ad6bc8b46 svn 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
		//If the background image changes, wipe the cache and update for the new image
95
47acbc0cc17a Propertyize AIListObject and convert some more controller accesses to dot syntax
David Smith
parents: 84
diff changeset
   303
		[adium.preferenceController setPreference: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
   304
											 forKey:[plugin styleSpecificKey:@"BackgroundCachePath" forStyle:activeStyle]
1208
6253704bc78b Store the preference group in the message view controller, so that we can edit it based on a new preference which isn't yet hooked: use regular style for group chats. Need to think of a decent UI for displaying this.
Zachary West <zacw@adiumx.com>
parents: 1205
diff changeset
   305
											  group:preferenceGroup];	
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
   306
		if (!isUpdatingWebViewForCurrentPreferences) {
e22ad6bc8b46 svn 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
			[self _updateWebViewForCurrentPreferences];
e22ad6bc8b46 svn 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
	}	
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 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
 * @brief Initialiaze the web view
e22ad6bc8b46 svn 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
 */
e22ad6bc8b46 svn 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
- (void)_initWebView
e22ad6bc8b46 svn 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
{
e22ad6bc8b46 svn 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
	//Create our webview
e22ad6bc8b46 svn 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
	webView = [[ESWebView alloc] initWithFrame:NSMakeRect(0,0,100,100) //Arbitrary frame
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   319
									 frameName: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
   320
									 groupName: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
   321
	[webView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   322
	[delegateProxy addDelegate:self forView:webView];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   323
	[webView setMaintainsBackForwardList: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
   324
e22ad6bc8b46 svn 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
	if (!draggedTypes) {
e22ad6bc8b46 svn 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
		draggedTypes = [[NSArray alloc] initWithObjects:
e22ad6bc8b46 svn 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
			NSFilenamesPboardType,
e22ad6bc8b46 svn 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
			AIiTunesTrackPboardType,
e22ad6bc8b46 svn 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
			NSTIFFPboardType,
e22ad6bc8b46 svn 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
			NSPDFPboardType,
e22ad6bc8b46 svn 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
			NSHTMLPboardType,
e22ad6bc8b46 svn 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
			NSFileContentsPboardType,
e22ad6bc8b46 svn 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
			NSRTFPboardType,
e22ad6bc8b46 svn 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
			NSStringPboardType,
e22ad6bc8b46 svn 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
			NSPostScriptPboardType,
e22ad6bc8b46 svn 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
			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
   337
	}
e22ad6bc8b46 svn 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
	[webView registerForDraggedTypes:draggedTypes];
e22ad6bc8b46 svn 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
}
e22ad6bc8b46 svn 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
 * @brief Updates our webview to the current preferences, priming the view
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   343
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   344
- (void)_updateWebViewForCurrentPreferences
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   345
{
4335
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   346
	static dispatch_queue_t webViewUpdateQueue = nil;
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   347
	static dispatch_once_t onceToken;
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   348
	dispatch_once(&onceToken, ^{
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   349
		webViewUpdateQueue = dispatch_queue_create("im.adium.AIWebKitMessageViewController.webViewUpdateQueue", 0);
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   350
	});
4324
6e513a922a44 Correct strange behavior in the messages pref pane. Fixes #15670
Stephen Holt <sholt@adium.im>
parents: 4308
diff changeset
   351
	
4336
9fea67859bc8 More message view tweaks. Fix a deadlock. Refs #15377.
Stephen Holt <sholt@adium.im>
parents: 4335
diff changeset
   352
	isUpdatingWebViewForCurrentPreferences = YES;
4335
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   353
	dispatch_sync(webViewUpdateQueue, ^{
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   354
		NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   355
		//Cleanup first
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   356
		[messageStyle autorelease]; messageStyle = nil;
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   357
		[activeStyle release]; activeStyle = nil;
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   358
		
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   359
		//Load the message style
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   360
		messageStyle = [[plugin currentMessageStyleForChat:chat] retain];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   361
		activeStyle = [[[messageStyle bundle] bundleIdentifier] retain];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   362
		preferenceGroup = [[plugin preferenceGroupForChat:chat] retain];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   363
		
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   364
		[webView setPreferencesIdentifier:[NSString stringWithFormat:@"%@-%@",
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   365
										   activeStyle, preferenceGroup]];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   366
		
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   367
		//Get the prefered variant (or the default if a prefered is not available)
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   368
		NSString *activeVariant;
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   369
		activeVariant = [adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"Variant" forStyle:activeStyle]
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   370
															   group:preferenceGroup];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   371
		if (!activeVariant || ![[messageStyle availableVariants] containsObject:activeVariant])
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   372
			activeVariant = [messageStyle defaultVariant];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   373
		if (!activeVariant || ![[messageStyle availableVariants] containsObject:activeVariant]) {
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   374
			/* If the message style doesn't specify a default variant, choose the first one.
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   375
			 * Note: Old styles (styleVersion < 3) will always report a variant for defaultVariant.
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   376
			 */
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   377
			NSArray *availableVariants = [messageStyle availableVariants];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   378
			if ([availableVariants count]) {
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   379
				activeVariant = [availableVariants objectAtIndex:0];
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
			}
e22ad6bc8b46 svn 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
		}
4335
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   382
		messageStyle.activeVariant = activeVariant;
4308
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   383
		
4335
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   384
		NSDictionary *prefDict = [adium.preferenceController preferencesForGroup:preferenceGroup];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   385
		
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   386
		//Update message style behavior: XXX move this somewhere not per-chat
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   387
		[messageStyle setShowUserIcons:[[prefDict objectForKey:KEY_WEBKIT_SHOW_USER_ICONS] boolValue]];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   388
		[messageStyle setShowHeader:[[prefDict objectForKey:KEY_WEBKIT_SHOW_HEADER] boolValue]];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   389
		[messageStyle setUseCustomNameFormat:[[prefDict objectForKey:KEY_WEBKIT_USE_NAME_FORMAT] boolValue]];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   390
		[messageStyle setNameFormat:[[prefDict objectForKey:KEY_WEBKIT_NAME_FORMAT] intValue]];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   391
		[messageStyle setDateFormat:[prefDict objectForKey:KEY_WEBKIT_TIME_STAMP_FORMAT]];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   392
		[messageStyle setShowIncomingMessageColors:[[prefDict objectForKey:KEY_WEBKIT_SHOW_MESSAGE_COLORS] boolValue]];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   393
		[messageStyle setShowIncomingMessageFonts:[[prefDict objectForKey:KEY_WEBKIT_SHOW_MESSAGE_FONTS] boolValue]];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   394
		
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   395
		//Custom background image
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   396
		//Webkit wants to load these from disk, but we have it stuffed in a plist.  So we'll write it out as an image
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   397
		//into the cache and have webkit fetch from there.
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   398
		NSString	*cachePath = nil;
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   399
		if ([[adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"UseCustomBackground" forStyle:activeStyle]
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   400
													group:preferenceGroup] boolValue]) {
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   401
			cachePath = [adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"BackgroundCachePath" forStyle:activeStyle]
4308
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   402
															   group:preferenceGroup];
4335
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   403
			if (!cachePath || ![[NSFileManager defaultManager] fileExistsAtPath:cachePath]) {
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   404
				NSData	*backgroundImage = [adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"Background" forStyle:activeStyle]
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   405
																				 group:PREF_GROUP_WEBKIT_BACKGROUND_IMAGES];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   406
				
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   407
				if (backgroundImage) {
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   408
					//Generate a unique cache ID for this image
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   409
					NSInteger	uniqueID = [[adium.preferenceController preferenceForKey:@"BackgroundCacheUniqueID"
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   410
																				 group:preferenceGroup] integerValue] + 1;
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   411
					[adium.preferenceController setPreference:[NSNumber numberWithInteger:uniqueID]
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   412
													   forKey:@"BackgroundCacheUniqueID"
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   413
														group:preferenceGroup];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   414
					
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   415
					//Cache the image under that unique ID
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   416
					//Since we prefix the filename with TEMP, Adium will automatically clean it up on quit
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   417
					cachePath = [self _webKitBackgroundImagePathForUniqueID:uniqueID];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   418
					[backgroundImage writeToFile:cachePath atomically:YES];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   419
					
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   420
					//Remember where we cached it
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   421
					[adium.preferenceController setPreference:cachePath
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   422
													   forKey:[plugin styleSpecificKey:@"BackgroundCachePath" forStyle:activeStyle]
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   423
														group:preferenceGroup];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   424
				} else {
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   425
					cachePath = @""; //No custom image found
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   426
				}
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   427
			}
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   428
			
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   429
			[messageStyle setCustomBackgroundColor:[[adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"BackgroundColor" forStyle:activeStyle]
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   430
																						   group:preferenceGroup] representedColor]];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   431
		} else {
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   432
			[messageStyle setCustomBackgroundColor:nil];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   433
		}
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   434
		
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   435
		[messageStyle setCustomBackgroundPath:cachePath];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   436
		[messageStyle setCustomBackgroundType:[[adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"BackgroundType" forStyle:activeStyle]
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   437
																					  group:preferenceGroup] intValue]];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   438
		
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   439
		BOOL isBackgroundTransparent = [[self messageStyle] isBackgroundTransparent];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   440
		[webView setTransparent:isBackgroundTransparent];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   441
		NSWindow *win = [webView window];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   442
		if(win)
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   443
			[win setOpaque:!isBackgroundTransparent];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   444
		
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   445
		//Update webview font settings
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   446
		NSString	*fontFamily = [adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"FontFamily" forStyle:activeStyle]
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   447
																	  group:preferenceGroup];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   448
		[webView setFontFamily:(fontFamily ? fontFamily : [messageStyle defaultFontFamily])];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   449
		
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   450
		NSNumber	*fontSize = [adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"FontSize" forStyle:activeStyle]
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   451
																	group:preferenceGroup];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   452
		[[webView preferences] setDefaultFontSize:[(fontSize ? fontSize : [messageStyle defaultFontSize]) intValue]];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   453
		
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   454
		NSNumber	*minSize = [adium.preferenceController preferenceForKey:KEY_WEBKIT_MIN_FONT_SIZE
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   455
																   group:preferenceGroup];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   456
		[[webView preferences] setMinimumFontSize:(minSize ? [minSize intValue] : 1)];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   457
		[[webView preferences] setMinimumLogicalFontSize:(minSize ? [minSize intValue] : 1)];
e25448d743b3 Some more reworking of how the WebKit Message Views are configured. Fixes #15377
Stephen Holt <sholt@adium.im>
parents: 4324
diff changeset
   458
		
4308
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   459
		//Update our icons before doing any loading
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   460
		[self sourceOrDestinationChanged:nil];
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   461
		
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   462
		//Prime the webview with the new style/variant and settings, and re-insert all our content back into the view
4324
6e513a922a44 Correct strange behavior in the messages pref pane. Fixes #15670
Stephen Holt <sholt@adium.im>
parents: 4308
diff changeset
   463
		[self _primeWebViewAndReprocessContent:YES];
6e513a922a44 Correct strange behavior in the messages pref pane. Fixes #15670
Stephen Holt <sholt@adium.im>
parents: 4308
diff changeset
   464
		[pool release];
4336
9fea67859bc8 More message view tweaks. Fix a deadlock. Refs #15377.
Stephen Holt <sholt@adium.im>
parents: 4335
diff changeset
   465
		isUpdatingWebViewForCurrentPreferences = NO;
4308
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   466
	});
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
   467
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   468
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   469
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   470
 * @brief Updates our webview to the currently active varient without refreshing the view
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   471
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   472
- (void)_updateVariantWithoutPrimingView
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   473
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   474
	//We can only change the variant if the web view is ready.  If it's not ready we wait a bit and try again.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   475
	if (webViewIsReady) {
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: 2951
diff changeset
   476
		[webView stringByEvaluatingJavaScriptFromString:[messageStyle 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
   477
	} 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
   478
		[self performSelector:@selector(_updateVariantWithoutPrimingView) withObject:nil afterDelay:NEW_CONTENT_RETRY_DELAY];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   479
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   480
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   481
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   482
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   483
 *	@brief Clears the view from displayed messages
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   484
 *
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   485
 *	Implements the method defined in protocol AIMessageDisplayController
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   486
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   487
- (void)clearView
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   488
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   489
	[self _primeWebViewAndReprocessContent:NO];
1552
d3bf620c6a8c Remove all marks when clearing the display. Redisplay the shelf view when a tab item is selected, which fixes the "jump to previous?" not working on initial selection.
Zachary West <zacw@adiumx.com>
parents: 1543
diff changeset
   490
	[self.markedScroller removeAllMarks];
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
   491
	[previousContent 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
   492
	previousContent = nil;
2852
7ff6b3f336d6 Instead of inserting a <hr/> when we lose focus, which ends up breaking more than you'd expect, add a message class for the next message. Fixes #13300.
Zachary West <zacw@adium.im>
parents: 2532
diff changeset
   493
	nextMessageFocus = NO;
3822
67a59959597d As requested by mathuaerknedam, also add a regainedFocus CSS class to the first message received after regaining focus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3770
diff changeset
   494
	nextMessageRegainedFocus = NO;
529
d3c149870adf Patch from '''wixardy''' to clear unread count when clearing display. Fixes #10605.
Zachary West <zacw@adiumx.com>
parents: 493
diff changeset
   495
	[chat clearUnviewedContentCount];
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
   496
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   497
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   498
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   499
 * @brief Primes our webview to the currently active style and 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
   500
 *
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   501
 * The webview won't be ready right away, so we flag it as not ready and set ourself as the frame load delegate so
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   502
 * it will let us know when it's good to go.  If reprocessContent is NO, all content in the view will be lost.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   503
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   504
- (void)_primeWebViewAndReprocessContent:(BOOL)reprocessContent
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   505
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   506
	webViewIsReady = 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
   507
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   508
	//Hack: this will re-set us for all the delegates, but that shouldn't matter
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   509
	[delegateProxy addDelegate:self forView:webView];
3350
2b9eb5aee00b Pass a valid and custom baseURL to our WebView to fix permission errors when attempting to use HTML5 localStorage from a message style. Also set the localStorage path to inside the user directory.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3196
diff changeset
   510
	
2b9eb5aee00b Pass a valid and custom baseURL to our WebView to fix permission errors when attempting to use HTML5 localStorage from a message style. Also set the localStorage path to inside the user directory.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3196
diff changeset
   511
	// We need to pass a local URL to allow LocalStorage from the WebView.
2b9eb5aee00b Pass a valid and custom baseURL to our WebView to fix permission errors when attempting to use HTML5 localStorage from a message style. Also set the localStorage path to inside the user directory.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3196
diff changeset
   512
	// The hostname-part determines the namespace, which we seperate per style.
2b9eb5aee00b Pass a valid and custom baseURL to our WebView to fix permission errors when attempting to use HTML5 localStorage from a message style. Also set the localStorage path to inside the user directory.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3196
diff changeset
   513
	// The path-part may not end in a /, as directories don't get local permissions.
2b9eb5aee00b Pass a valid and custom baseURL to our WebView to fix permission errors when attempting to use HTML5 localStorage from a message style. Also set the localStorage path to inside the user directory.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3196
diff changeset
   514
	NSURL *baseURL = [NSURL URLWithString:[NSString stringWithFormat:@"adium://%@/adium", [messageStyle.bundle bundleIdentifier]]];
2b9eb5aee00b Pass a valid and custom baseURL to our WebView to fix permission errors when attempting to use HTML5 localStorage from a message style. Also set the localStorage path to inside the user directory.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3196
diff changeset
   515
	[[webView mainFrame] loadHTMLString:[messageStyle baseTemplateForChat:chat] baseURL:baseURL];
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
   516
1302
edfe39b2a0a0 Make the "does this chat support topics?" a per-chat toggle (though it just queries the account accessor).
Zachary West <zacw@adiumx.com>
parents: 1301
diff changeset
   517
	if(chat.isGroupChat && chat.supportsTopic) {
1301
fb82ac8f55ca Store the topic and topic setter in an AIChat. Add an accessor to AIAccount which determines if group chats can set topics (currently this only sets it to YES for IRC?I think XMPP supports it also, so in a future commit?). Adds a method to AIAccount to set the topic in a chat, which IRC implements in a very crude manner.
Zachary West <zacw@adiumx.com>
parents: 1298
diff changeset
   518
		// Force a topic update, so we set our topic appropriately.
1487
1e40e4ee17ae We can't just push topics through the content controller, since it drops empty stringed messages (and removing this requirement causes a whole world of problems). Filter it ourselves, then display it.
Zachary West <zacw@adiumx.com>
parents: 1485
diff changeset
   519
		[self updateTopic];
1301
fb82ac8f55ca Store the topic and topic setter in an AIChat. Add an accessor to AIAccount which determines if group chats can set topics (currently this only sets it to YES for IRC?I think XMPP supports it also, so in a future commit?). Adds a method to AIAccount to set the topic in a chat, which IRC implements in a very crude manner.
Zachary West <zacw@adiumx.com>
parents: 1298
diff changeset
   520
	}
fb82ac8f55ca Store the topic and topic setter in an AIChat. Add an accessor to AIAccount which determines if group chats can set topics (currently this only sets it to YES for IRC?I think XMPP supports it also, so in a future commit?). Adds a method to AIAccount to set the topic in a chat, which IRC implements in a very crude manner.
Zachary West <zacw@adiumx.com>
parents: 1298
diff changeset
   521
	
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
   522
	if (reprocessContent) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   523
		NSArray	*currentContentQueue;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   524
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   525
		//Keep the array of objects waiting to be added, if necessary, to append them after our currently displayed ones
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   526
		currentContentQueue = ([contentQueue count] ?
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   527
							   [contentQueue copy] :
e22ad6bc8b46 svn 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
							   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
   529
e22ad6bc8b46 svn 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
		//Start from an empty content queue
e22ad6bc8b46 svn 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
		[contentQueue removeAllObjects];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   532
e22ad6bc8b46 svn 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
		//Add our stored content objects to the content queue
e22ad6bc8b46 svn 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
		[contentQueue addObjectsFromArray:storedContentObjects];
e22ad6bc8b46 svn 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
		[storedContentObjects removeAllObjects];
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 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
		//Add the old content queue back in if necessary
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   538
		if (currentContentQueue) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   539
			[contentQueue addObjectsFromArray:currentContentQueue];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   540
			[currentContentQueue 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
   541
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   542
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   543
		//We're still holding onto the previousContent from before, which is no longer accurate. Release 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
   544
		[previousContent release]; previousContent = 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
   545
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   546
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   547
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   548
/*!
e22ad6bc8b46 svn 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
 * @brief Sets the class 'groupchat' on the #Chat element, to allow styles to modify their appearance based on whether we're in a groupchat
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   550
 *
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   551
 * If/when we support transforming chats to/from groupchats we'll need to observe that and call this as appropriate
e22ad6bc8b46 svn 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
 */
e22ad6bc8b46 svn 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
- (void) setIsGroupChat:(BOOL) flag
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   554
{
370
63c3facaa8de bdash points out that this method exists. How nice :)
David Smith
parents: 156
diff changeset
   555
	DOMHTMLElement *chatElement = (DOMHTMLElement *)[[webView mainFrameDocument] getElementById:@"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
   556
	NSMutableString *chatClassName = [[[chatElement className] mutableCopy] 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
   557
	if (flag == 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
   558
		[chatClassName replaceOccurrencesOfString:@" groupchat"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   559
									   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
   560
										  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
   561
											range:NSMakeRange(0, [chatClassName 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
   562
	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
   563
		[chatClassName appendString:@" groupchat"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   564
	[chatElement setClassName:chatClassName];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   565
}
e22ad6bc8b46 svn 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
4646
8fc9e07216a8 We should add content to the WKMV after DOM is ready. Fixes #15377, Message History Only Shows on 1st Tab on Startup.
Adrian Godoroja <robotive@me.com>
parents: 4498
diff changeset
   567
// Set document is ready (DOM ready)
8fc9e07216a8 We should add content to the WKMV after DOM is ready. Fixes #15377, Message History Only Shows on 1st Tab on Startup.
Adrian Godoroja <robotive@me.com>
parents: 4498
diff changeset
   568
- (void)_setDocumentReady
8fc9e07216a8 We should add content to the WKMV after DOM is ready. Fixes #15377, Message History Only Shows on 1st Tab on Startup.
Adrian Godoroja <robotive@me.com>
parents: 4498
diff changeset
   569
{
8fc9e07216a8 We should add content to the WKMV after DOM is ready. Fixes #15377, Message History Only Shows on 1st Tab on Startup.
Adrian Godoroja <robotive@me.com>
parents: 4498
diff changeset
   570
	documentIsReady = YES;
8fc9e07216a8 We should add content to the WKMV after DOM is ready. Fixes #15377, Message History Only Shows on 1st Tab on Startup.
Adrian Godoroja <robotive@me.com>
parents: 4498
diff changeset
   571
}
8fc9e07216a8 We should add content to the WKMV after DOM is ready. Fixes #15377, Message History Only Shows on 1st Tab on Startup.
Adrian Godoroja <robotive@me.com>
parents: 4498
diff changeset
   572
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
   573
//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
   574
#pragma mark 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
   575
/*!
e22ad6bc8b46 svn 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
 * @brief Append new content to our processing queue
e22ad6bc8b46 svn 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
 */
e22ad6bc8b46 svn 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
- (void)contentObjectAdded:(NSNotification *)notification
e22ad6bc8b46 svn 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
	AIContentObject	*contentObject = [[notification userInfo] objectForKey:@"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
   581
	[self enqueueContentObject:contentObject];
e22ad6bc8b46 svn 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
}
e22ad6bc8b46 svn 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
- (void)enqueueContentObject:(AIContentObject *)contentObject
e22ad6bc8b46 svn 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
{
e22ad6bc8b46 svn 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
	[contentQueue addObject:contentObject];
e22ad6bc8b46 svn 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
	/* Immediately update our display if the content requires 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
   589
	* This is NO, for example, when we receive an entire block of message history content so that we can avoid scrolling
e22ad6bc8b46 svn 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
	* after each 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
   591
	*/
e22ad6bc8b46 svn 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 ([contentObject displayContentImmediately]) {
e22ad6bc8b46 svn 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
		[self processQueuedContent];
e22ad6bc8b46 svn 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
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   595
}
e22ad6bc8b46 svn 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
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   598
 * @brief Our chat finished adding untracked 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
   599
 */
e22ad6bc8b46 svn 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
- (void)chatDidFinishAddingUntrackedContent:(NSNotification *)notification
e22ad6bc8b46 svn 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
{
e22ad6bc8b46 svn 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
	[self processQueuedContent];	
e22ad6bc8b46 svn 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
}
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 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
/*!
e22ad6bc8b46 svn 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
 * @brief Append new content to our processing queueProcess any content in the queuee
e22ad6bc8b46 svn 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
- (void)processQueuedContent
e22ad6bc8b46 svn 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
{
4308
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   610
	dispatch_async(dispatch_get_main_queue(), ^{
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   611
		NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   612
		/* If the webview isn't ready, assume we have at least one piece of content left to display */
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   613
		NSUInteger	contentQueueCount = 1;
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   614
		NSUInteger	objectsAdded = 0;
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   615
		
4646
8fc9e07216a8 We should add content to the WKMV after DOM is ready. Fixes #15377, Message History Only Shows on 1st Tab on Startup.
Adrian Godoroja <robotive@me.com>
parents: 4498
diff changeset
   616
		if (webViewIsReady && documentIsReady) {
4308
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   617
			contentQueueCount = contentQueue.count;
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
   618
			
4308
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   619
			while (contentQueueCount > 0) {
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   620
				BOOL willAddMoreContent = (contentQueueCount > 1);
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   621
				
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   622
				//Display the content
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   623
				AIContentObject *content = [contentQueue objectAtIndex:0];
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   624
				[self _processContentObject:content 
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   625
				  willAddMoreContentObjects:willAddMoreContent];
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   626
				
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   627
				//If we are going to reflect preference changes, store this content object
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   628
				if (shouldReflectPreferenceChanges) {
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   629
					[storedContentObjects addObject:content];
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   630
				}
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   631
				
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   632
				//Remove the content we just displayed from the queue
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   633
				[contentQueue removeObjectAtIndex:0];
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   634
				objectsAdded++;
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   635
				contentQueueCount--;
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
   636
			}
e22ad6bc8b46 svn 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
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   638
		
4308
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   639
		/* If we added two or more objects, we may want to scroll to the bottom now, having not done it as each object
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   640
		 * was added.
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   641
		 */
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   642
		if (objectsAdded > 1) {
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   643
			NSString	*scrollToBottomScript = [messageStyle scriptForScrollingAfterAddingMultipleContentObjects];
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   644
			
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   645
			if (scrollToBottomScript) {
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   646
				[webView stringByEvaluatingJavaScriptFromString:scrollToBottomScript];
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   647
			}
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
   648
		}
4308
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   649
		
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   650
		//If there is still content to process (the webview wasn't ready), we'll try again after a brief delay
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   651
		if (contentQueueCount) {
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   652
			double delayInSeconds = NEW_CONTENT_RETRY_DELAY;
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   653
			dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   654
			dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   655
				[self processQueuedContent];
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   656
			});
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   657
		}
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   658
		[pool release];
ef4f9d2b8336 Ensure that only one webView is being updated at a time. Resolves some issues with incomplete message context history displaying.
Stephen Holt <sholt@adium.im>
parents: 4283
diff changeset
   659
	});
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
   660
}
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 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
 * @brief Process and then append a content object
e22ad6bc8b46 svn 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
 */
e22ad6bc8b46 svn 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
- (void)_processContentObject:(AIContentObject *)content willAddMoreContentObjects:(BOOL)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
   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
	AIContentEvent	*dateSeparator = 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
   668
	BOOL			replaceLastContent = 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
   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
	/*
e22ad6bc8b46 svn 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
	 If the day has changed since our last message (or if there was no previous message and 
e22ad6bc8b46 svn 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
	 we are about to display context), insert a date line.
e22ad6bc8b46 svn 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
	if ((!previousContent && [content isKindOfClass:[AIContentContext 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
   675
	   (![content isFromSameDayAsContent:previousContent])) {
e22ad6bc8b46 svn 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
		
4356
a0d4ead5c91e Use a serial dispatch queue for all shared localized NSDateFormatter uses.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 4336
diff changeset
   677
		__block NSString *dateMessage;
a0d4ead5c91e Use a serial dispatch queue for all shared localized NSDateFormatter uses.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 4336
diff changeset
   678
		[NSDateFormatter withLocalizedDateFormatterPerform:^(NSDateFormatter *dateFormatter){
a0d4ead5c91e Use a serial dispatch queue for all shared localized NSDateFormatter uses.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 4336
diff changeset
   679
			dateMessage = [[dateFormatter stringFromDate:content.date] retain];
a0d4ead5c91e Use a serial dispatch queue for all shared localized NSDateFormatter uses.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 4336
diff changeset
   680
		}];
a0d4ead5c91e Use a serial dispatch queue for all shared localized NSDateFormatter uses.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 4336
diff changeset
   681
		[dateMessage 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
   682
		
812
3de38d362167 Propertyize
David Smith
parents: 806
diff changeset
   683
		dateSeparator = [AIContentEvent statusInChat:content.chat
3de38d362167 Propertyize
David Smith
parents: 806
diff changeset
   684
										  withSource:content.chat.listObject
3de38d362167 Propertyize
David Smith
parents: 806
diff changeset
   685
										 destination:content.chat.account
3de38d362167 Propertyize
David Smith
parents: 806
diff changeset
   686
												date:content.date
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
   687
											 message:[[[NSAttributedString alloc] initWithString:dateMessage
95
47acbc0cc17a Propertyize AIListObject and convert some more controller accesses to dot syntax
David Smith
parents: 84
diff changeset
   688
																					  attributes:[adium.contentController defaultFormattingAttributes]] autorelease]
629
de6016721ae8 Merged [25698]: Don't include 'history' in the %status% of a date separator in history; this should instead be included as a display class. Fixes #10174
Evan Schoenberg
parents: 599
diff changeset
   689
											withType:@"date_separator"];
de6016721ae8 Merged [25698]: Don't include 'history' in the %status% of a date separator in history; this should instead be included as a display class. Fixes #10174
Evan Schoenberg
parents: 599
diff changeset
   690
631
79f6b23a29d5 Merged [25700]: Now with less parentheses... take two.
Evan Schoenberg
parents: 629
diff changeset
   691
		if ([content isKindOfClass:[AIContentContext class]])
629
de6016721ae8 Merged [25698]: Don't include 'history' in the %status% of a date separator in history; this should instead be included as a display class. Fixes #10174
Evan Schoenberg
parents: 599
diff changeset
   692
			[dateSeparator addDisplayClass:@"history"];
de6016721ae8 Merged [25698]: Don't include 'history' in the %status% of a date separator in history; this should instead be included as a display class. Fixes #10174
Evan Schoenberg
parents: 599
diff changeset
   693
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
   694
		//Add the date header
e22ad6bc8b46 svn 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
		[self _appendContent:dateSeparator 
e22ad6bc8b46 svn 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
					 similar: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
   697
			willAddMoreContentObjects: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
   698
		  replaceLastContent: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
   699
		[previousContent release]; previousContent = [dateSeparator 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
   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
	BOOL similar = (previousContent && [content isSimilarToContent:previousContent] && ![content isKindOfClass:[ESFileTransfer 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
   703
	if ([previousContent isKindOfClass:[AIContentStatus class]] && [content isKindOfClass:[AIContentStatus 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
   704
		[[(AIContentStatus *)previousContent coalescingKey] isEqualToString:[(AIContentStatus *)content coalescingKey]]) {
2514
7d7e889ad3af Patch from mathuaerknedam. Fixes ticket #9689.
David Smith <catfish.man@gmail.com>
parents: 2443
diff changeset
   705
		similar = NO;
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
   706
		replaceLastContent = 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
   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
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: 1240
diff changeset
   709
	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: 1240
diff changeset
   710
		DOMHTMLElement *topicElement = (DOMHTMLElement *)[[webView mainFrameDocument] getElementById:@"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: 1240
diff changeset
   711
		
1488
ffe74d686e5b Support clearing the topic from the div. The content controller requires messages have a length larger than 0, or else it goes willy-nilly all over the place*. Set a fake message and add a flag to AIContentTopic to signify the topic should be cleared by it.
Zachary West <zacw@adiumx.com>
parents: 1487
diff changeset
   712
		if (((AIContentTopic *)content).actuallyBlank) {
ffe74d686e5b Support clearing the topic from the div. The content controller requires messages have a length larger than 0, or else it goes willy-nilly all over the place*. Set a fake message and add a flag to AIContentTopic to signify the topic should be cleared by it.
Zachary West <zacw@adiumx.com>
parents: 1487
diff changeset
   713
			content.message = [NSAttributedString stringWithString:@""];
ffe74d686e5b Support clearing the topic from the div. The content controller requires messages have a length larger than 0, or else it goes willy-nilly all over the place*. Set a fake message and add a flag to AIContentTopic to signify the topic should be cleared by it.
Zachary West <zacw@adiumx.com>
parents: 1487
diff changeset
   714
		}
ffe74d686e5b Support clearing the topic from the div. The content controller requires messages have a length larger than 0, or else it goes willy-nilly all over the place*. Set a fake message and add a flag to AIContentTopic to signify the topic should be cleared by it.
Zachary West <zacw@adiumx.com>
parents: 1487
diff changeset
   715
		
1344
60527d78ebaa Set the title on the topic <div> when changing its contents.
Zachary West <zacw@adiumx.com>
parents: 1302
diff changeset
   716
		[topicElement setTitle:content.message.string];
60527d78ebaa Set the title on the topic <div> when changing its contents.
Zachary West <zacw@adiumx.com>
parents: 1302
diff changeset
   717
		
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: 1240
diff changeset
   718
		[topicElement setInnerHTML:[messageStyle completedTemplateForContent:content similar:similar]];
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: 1240
diff changeset
   719
	} else {
2905
a432d0b79552 Don't base focus application on content tracking, since status messages aren't tracked. Base it on whether or not the content is post-processed (i.e., logged). Refs #13356.
Zachary West <zacw@adium.im>
parents: 2903
diff changeset
   720
		// Mark the current location (the start of this element) if it's a mention.
a432d0b79552 Don't base focus application on content tracking, since status messages aren't tracked. Base it on whether or not the content is post-processed (i.e., logged). Refs #13356.
Zachary West <zacw@adium.im>
parents: 2903
diff changeset
   721
		if (content.trackContent && [content.displayClasses containsObject:@"mention"]) {
a432d0b79552 Don't base focus application on content tracking, since status messages aren't tracked. Base it on whether or not the content is post-processed (i.e., logged). Refs #13356.
Zachary West <zacw@adium.im>
parents: 2903
diff changeset
   722
			[self markCurrentLocation];
a432d0b79552 Don't base focus application on content tracking, since status messages aren't tracked. Base it on whether or not the content is post-processed (i.e., logged). Refs #13356.
Zachary West <zacw@adium.im>
parents: 2903
diff changeset
   723
		}
a432d0b79552 Don't base focus application on content tracking, since status messages aren't tracked. Base it on whether or not the content is post-processed (i.e., logged). Refs #13356.
Zachary West <zacw@adium.im>
parents: 2903
diff changeset
   724
		
a432d0b79552 Don't base focus application on content tracking, since status messages aren't tracked. Base it on whether or not the content is post-processed (i.e., logged). Refs #13356.
Zachary West <zacw@adium.im>
parents: 2903
diff changeset
   725
		if (content.postProcessContent && adium.interfaceController.activeChat != content.chat) {
a432d0b79552 Don't base focus application on content tracking, since status messages aren't tracked. Base it on whether or not the content is post-processed (i.e., logged). Refs #13356.
Zachary West <zacw@adium.im>
parents: 2903
diff changeset
   726
			if (nextMessageFocus) {
a432d0b79552 Don't base focus application on content tracking, since status messages aren't tracked. Base it on whether or not the content is post-processed (i.e., logged). Refs #13356.
Zachary West <zacw@adium.im>
parents: 2903
diff changeset
   727
				[self.markedScroller addMarkAt:[self.currentOffsetHeight integerValue] withIdentifier:@"focus" withColor:[NSColor redColor]];
a432d0b79552 Don't base focus application on content tracking, since status messages aren't tracked. Base it on whether or not the content is post-processed (i.e., logged). Refs #13356.
Zachary West <zacw@adium.im>
parents: 2903
diff changeset
   728
				
3546
686439f896e2 Only display focus indicators within the message view itself for group chats. All chats will still have marked scrollers for focus (and mention) purposes.
Evan Schoenberg
parents: 3519
diff changeset
   729
				// Add a class for "first content to lose focus" if this is a group chat
686439f896e2 Only display focus indicators within the message view itself for group chats. All chats will still have marked scrollers for focus (and mention) purposes.
Evan Schoenberg
parents: 3519
diff changeset
   730
				if (content.chat.isGroupChat)
686439f896e2 Only display focus indicators within the message view itself for group chats. All chats will still have marked scrollers for focus (and mention) purposes.
Evan Schoenberg
parents: 3519
diff changeset
   731
					[content addDisplayClass:@"firstFocus"];
2905
a432d0b79552 Don't base focus application on content tracking, since status messages aren't tracked. Base it on whether or not the content is post-processed (i.e., logged). Refs #13356.
Zachary West <zacw@adium.im>
parents: 2903
diff changeset
   732
				
a432d0b79552 Don't base focus application on content tracking, since status messages aren't tracked. Base it on whether or not the content is post-processed (i.e., logged). Refs #13356.
Zachary West <zacw@adium.im>
parents: 2903
diff changeset
   733
				nextMessageFocus = NO;
3822
67a59959597d As requested by mathuaerknedam, also add a regainedFocus CSS class to the first message received after regaining focus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3770
diff changeset
   734
				nextMessageRegainedFocus = YES;
2853
a2f78c3401b9 Don't add a focus class for messages in the active chat. Refs #13300.
Zachary West <zacw@adium.im>
parents: 2852
diff changeset
   735
			}
2887
f046b16a0a17 Set the focus element for all elements when out of focus. Fixes #13356.
Zachary West <zacw@adium.im>
parents: 2853
diff changeset
   736
2905
a432d0b79552 Don't base focus application on content tracking, since status messages aren't tracked. Base it on whether or not the content is post-processed (i.e., logged). Refs #13356.
Zachary West <zacw@adium.im>
parents: 2903
diff changeset
   737
			// Add a class for "this content received while out of focus"
3770
1975426d1c02 Added lastFocus for the latest message received in a chat without focus, as requested by mathuaerknedam.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3682
diff changeset
   738
			if (content.chat.isGroupChat) {
3546
686439f896e2 Only display focus indicators within the message view itself for group chats. All chats will still have marked scrollers for focus (and mention) purposes.
Evan Schoenberg
parents: 3519
diff changeset
   739
				[content addDisplayClass:@"focus"];
3770
1975426d1c02 Added lastFocus for the latest message received in a chat without focus, as requested by mathuaerknedam.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3682
diff changeset
   740
				[content addDisplayClass:@"lastFocus"];
1975426d1c02 Added lastFocus for the latest message received in a chat without focus, as requested by mathuaerknedam.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3682
diff changeset
   741
				
3833
742a577f459c Fix focussing of messages:
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3822
diff changeset
   742
				// if there's something else already lastFocus, then unset it
3770
1975426d1c02 Added lastFocus for the latest message received in a chat without focus, as requested by mathuaerknedam.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3682
diff changeset
   743
				DOMNodeList *nodeList = [webView.mainFrameDocument querySelectorAll:@".lastFocus"];
1975426d1c02 Added lastFocus for the latest message received in a chat without focus, as requested by mathuaerknedam.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3682
diff changeset
   744
				DOMHTMLElement *node = nil; NSMutableArray *classes = nil;
1975426d1c02 Added lastFocus for the latest message received in a chat without focus, as requested by mathuaerknedam.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3682
diff changeset
   745
				for (unsigned i = 0; i < nodeList.length; i++)
1975426d1c02 Added lastFocus for the latest message received in a chat without focus, as requested by mathuaerknedam.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3682
diff changeset
   746
				{
1975426d1c02 Added lastFocus for the latest message received in a chat without focus, as requested by mathuaerknedam.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3682
diff changeset
   747
					node = (DOMHTMLElement *)[nodeList item:i];
1975426d1c02 Added lastFocus for the latest message received in a chat without focus, as requested by mathuaerknedam.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3682
diff changeset
   748
					classes = [[node.className componentsSeparatedByString:@" "] mutableCopy];
1975426d1c02 Added lastFocus for the latest message received in a chat without focus, as requested by mathuaerknedam.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3682
diff changeset
   749
					
1975426d1c02 Added lastFocus for the latest message received in a chat without focus, as requested by mathuaerknedam.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3682
diff changeset
   750
					[classes removeObject:@"lastFocus"];
1975426d1c02 Added lastFocus for the latest message received in a chat without focus, as requested by mathuaerknedam.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3682
diff changeset
   751
					
1975426d1c02 Added lastFocus for the latest message received in a chat without focus, as requested by mathuaerknedam.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3682
diff changeset
   752
					node.className = [classes componentsJoinedByString:@" "];
1975426d1c02 Added lastFocus for the latest message received in a chat without focus, as requested by mathuaerknedam.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3682
diff changeset
   753
					
1975426d1c02 Added lastFocus for the latest message received in a chat without focus, as requested by mathuaerknedam.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3682
diff changeset
   754
					[classes release];
1975426d1c02 Added lastFocus for the latest message received in a chat without focus, as requested by mathuaerknedam.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3682
diff changeset
   755
				}
1975426d1c02 Added lastFocus for the latest message received in a chat without focus, as requested by mathuaerknedam.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3682
diff changeset
   756
			}
2852
7ff6b3f336d6 Instead of inserting a <hr/> when we lose focus, which ends up breaking more than you'd expect, add a message class for the next message. Fixes #13300.
Zachary West <zacw@adium.im>
parents: 2532
diff changeset
   757
		}
7ff6b3f336d6 Instead of inserting a <hr/> when we lose focus, which ends up breaking more than you'd expect, add a message class for the next message. Fixes #13300.
Zachary West <zacw@adium.im>
parents: 2532
diff changeset
   758
		
3833
742a577f459c Fix focussing of messages:
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3822
diff changeset
   759
		/* Only if the message is a group chat message that should be postprocessed, and it's in the active chat
742a577f459c Fix focussing of messages:
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3822
diff changeset
   760
		 * with something already focussed (!nextMessageFocus) and nothing already regainedFocussed
742a577f459c Fix focussing of messages:
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3822
diff changeset
   761
		 * (nextMessageRegainedFocus), _then_ this message will be regainedFocus.
742a577f459c Fix focussing of messages:
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3822
diff changeset
   762
		 */
742a577f459c Fix focussing of messages:
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3822
diff changeset
   763
		if (content.postProcessContent && content.chat.isGroupChat && adium.interfaceController.activeChat == content.chat
742a577f459c Fix focussing of messages:
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3822
diff changeset
   764
			&& !nextMessageFocus && nextMessageRegainedFocus) {
742a577f459c Fix focussing of messages:
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3822
diff changeset
   765
			
3822
67a59959597d As requested by mathuaerknedam, also add a regainedFocus CSS class to the first message received after regaining focus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3770
diff changeset
   766
			nextMessageRegainedFocus = NO;
67a59959597d As requested by mathuaerknedam, also add a regainedFocus CSS class to the first message received after regaining focus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3770
diff changeset
   767
			[content addDisplayClass:@"regainedFocus"];
67a59959597d As requested by mathuaerknedam, also add a regainedFocus CSS class to the first message received after regaining focus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3770
diff changeset
   768
		}
67a59959597d As requested by mathuaerknedam, also add a regainedFocus CSS class to the first message received after regaining focus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3770
diff changeset
   769
		
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: 1240
diff changeset
   770
		//Add the content object
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: 1240
diff changeset
   771
		[self _appendContent:content 
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: 1240
diff changeset
   772
					 similar:similar
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: 1240
diff changeset
   773
   willAddMoreContentObjects:willAddMoreContentObjects
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: 1240
diff changeset
   774
		  replaceLastContent:replaceLastContent];
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: 1240
diff changeset
   775
	}
1536
04cbfac122f2 Mark the current location '''before''' inserting any elements, and use the body's height to do the location sticking. This way, we know for sure that we're getting the right location.
Zachary West <zacw@adiumx.com>
parents: 1535
diff changeset
   776
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
   777
	[previousContent release]; previousContent = [content 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
   778
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   779
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   780
/*!
e22ad6bc8b46 svn 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
 * @brief Append a content object
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   782
 */
e22ad6bc8b46 svn 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
- (void)_appendContent:(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
   784
{
e22ad6bc8b46 svn 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
	[webView stringByEvaluatingJavaScriptFromString:[messageStyle scriptForAppendingContent: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
   786
																					similar: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
   787
																  willAddMoreContentObjects: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
   788
																		 replaceLastContent: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
   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
	NSAccessibilityPostNotification(webView, NSAccessibilityValueChangedNotification);
e22ad6bc8b46 svn 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
}
e22ad6bc8b46 svn 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
1487
1e40e4ee17ae We can't just push topics through the content controller, since it drops empty stringed messages (and removing this requirement causes a whole world of problems). Filter it ourselves, then display it.
Zachary West <zacw@adiumx.com>
parents: 1485
diff changeset
   793
#pragma mark Topics
1e40e4ee17ae We can't just push topics through the content controller, since it drops empty stringed messages (and removing this requirement causes a whole world of problems). Filter it ourselves, then display it.
Zachary West <zacw@adiumx.com>
parents: 1485
diff changeset
   794
/*!
1e40e4ee17ae We can't just push topics through the content controller, since it drops empty stringed messages (and removing this requirement causes a whole world of problems). Filter it ourselves, then display it.
Zachary West <zacw@adiumx.com>
parents: 1485
diff changeset
   795
 * @brief Force a topic update.
1e40e4ee17ae We can't just push topics through the content controller, since it drops empty stringed messages (and removing this requirement causes a whole world of problems). Filter it ourselves, then display it.
Zachary West <zacw@adiumx.com>
parents: 1485
diff changeset
   796
 *
1e40e4ee17ae We can't just push topics through the content controller, since it drops empty stringed messages (and removing this requirement causes a whole world of problems). Filter it ourselves, then display it.
Zachary West <zacw@adiumx.com>
parents: 1485
diff changeset
   797
 * We have to filter this ourself because, if the topic is blank, the content controller will never show it to us.
1e40e4ee17ae We can't just push topics through the content controller, since it drops empty stringed messages (and removing this requirement causes a whole world of problems). Filter it ourselves, then display it.
Zachary West <zacw@adiumx.com>
parents: 1485
diff changeset
   798
 */
1e40e4ee17ae We can't just push topics through the content controller, since it drops empty stringed messages (and removing this requirement causes a whole world of problems). Filter it ourselves, then display it.
Zachary West <zacw@adiumx.com>
parents: 1485
diff changeset
   799
- (void)updateTopic
1e40e4ee17ae We can't just push topics through the content controller, since it drops empty stringed messages (and removing this requirement causes a whole world of problems). Filter it ourselves, then display it.
Zachary West <zacw@adiumx.com>
parents: 1485
diff changeset
   800
{
3651
3e6ee7b5e497 Properly clean up the topic, and update it on the bookmark when rejoining a chat.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3650
diff changeset
   801
	NSAttributedString *topic = [NSAttributedString stringWithString:([chat valueForProperty:KEY_TOPIC] ?: @"")];
1487
1e40e4ee17ae We can't just push topics through the content controller, since it drops empty stringed messages (and removing this requirement causes a whole world of problems). Filter it ourselves, then display it.
Zachary West <zacw@adiumx.com>
parents: 1485
diff changeset
   802
	
1e40e4ee17ae We can't just push topics through the content controller, since it drops empty stringed messages (and removing this requirement causes a whole world of problems). Filter it ourselves, then display it.
Zachary West <zacw@adiumx.com>
parents: 1485
diff changeset
   803
	AIContentTopic *contentTopic = [AIContentTopic topicInChat:chat
3650
50dc6de6048f Use the topic of an multi-user bookmark as the status.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3546
diff changeset
   804
													withSource:[chat valueForProperty:KEY_TOPIC_SETTER]
1487
1e40e4ee17ae We can't just push topics through the content controller, since it drops empty stringed messages (and removing this requirement causes a whole world of problems). Filter it ourselves, then display it.
Zachary West <zacw@adiumx.com>
parents: 1485
diff changeset
   805
												   destination:nil
1e40e4ee17ae We can't just push topics through the content controller, since it drops empty stringed messages (and removing this requirement causes a whole world of problems). Filter it ourselves, then display it.
Zachary West <zacw@adiumx.com>
parents: 1485
diff changeset
   806
														  date:[NSDate date]
1e40e4ee17ae We can't just push topics through the content controller, since it drops empty stringed messages (and removing this requirement causes a whole world of problems). Filter it ourselves, then display it.
Zachary West <zacw@adiumx.com>
parents: 1485
diff changeset
   807
													   message:topic];
1e40e4ee17ae We can't just push topics through the content controller, since it drops empty stringed messages (and removing this requirement causes a whole world of problems). Filter it ourselves, then display it.
Zachary West <zacw@adiumx.com>
parents: 1485
diff changeset
   808
	
1e40e4ee17ae We can't just push topics through the content controller, since it drops empty stringed messages (and removing this requirement causes a whole world of problems). Filter it ourselves, then display it.
Zachary West <zacw@adiumx.com>
parents: 1485
diff changeset
   809
	// In case this topic is blank, we have to filter this ourself; the content controller will drop it.
1e40e4ee17ae We can't just push topics through the content controller, since it drops empty stringed messages (and removing this requirement causes a whole world of problems). Filter it ourselves, then display it.
Zachary West <zacw@adiumx.com>
parents: 1485
diff changeset
   810
	contentTopic.message = [adium.contentController filterAttributedString:topic usingFilterType:AIFilterDisplay direction:AIFilterIncoming context:contentTopic];
1e40e4ee17ae We can't just push topics through the content controller, since it drops empty stringed messages (and removing this requirement causes a whole world of problems). Filter it ourselves, then display it.
Zachary West <zacw@adiumx.com>
parents: 1485
diff changeset
   811
	
1e40e4ee17ae We can't just push topics through the content controller, since it drops empty stringed messages (and removing this requirement causes a whole world of problems). Filter it ourselves, then display it.
Zachary West <zacw@adiumx.com>
parents: 1485
diff changeset
   812
	[self enqueueContentObject:contentTopic];
1e40e4ee17ae We can't just push topics through the content controller, since it drops empty stringed messages (and removing this requirement causes a whole world of problems). Filter it ourselves, then display it.
Zachary West <zacw@adiumx.com>
parents: 1485
diff changeset
   813
}
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
   814
e22ad6bc8b46 svn 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
//WebView Delegates ----------------------------------------------------------------------------------------------------
e22ad6bc8b46 svn 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
#pragma mark Webview delegates
e22ad6bc8b46 svn 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
- (void)webViewIsReady{
e22ad6bc8b46 svn 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
	webViewIsReady = YES;
1534
c14fa8460138 Copy JVMarkedScroller from Colloquy, giving us the ability to mark arbitrary locations in the scroll bar. Right now we mark the location of mentions, but this is a little clunky and inexact; I need to play with it a bit more, add the ability to mark when we lose focus, and center the jump-to position when moving.
Zachary West <zacw@adiumx.com>
parents: 1488
diff changeset
   820
	[self setupMarkedScroller];
428
e10face4301d More dots, now with bonus for(in) action!
David Smith
parents: 426
diff changeset
   821
	[self setIsGroupChat:chat.isGroupChat];
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
   822
	[self processQueuedContent];
4283
fe00cfadb2b2 Fixed issue where window shadows were not initially rendered with transparent message view backgrounds
Stephen Holt <sholt@adium.im>
parents: 4049
diff changeset
   823
	
fe00cfadb2b2 Fixed issue where window shadows were not initially rendered with transparent message view backgrounds
Stephen Holt <sholt@adium.im>
parents: 4049
diff changeset
   824
	// force the window to redisplay, otherwise the shadow will not draw properly with transparent message views 
fe00cfadb2b2 Fixed issue where window shadows were not initially rendered with transparent message view backgrounds
Stephen Holt <sholt@adium.im>
parents: 4049
diff changeset
   825
	NSWindow *win = [webView window];
fe00cfadb2b2 Fixed issue where window shadows were not initially rendered with transparent message view backgrounds
Stephen Holt <sholt@adium.im>
parents: 4049
diff changeset
   826
	[win invalidateShadow];
fe00cfadb2b2 Fixed issue where window shadows were not initially rendered with transparent message view backgrounds
Stephen Holt <sholt@adium.im>
parents: 4049
diff changeset
   827
	[win display];
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
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   830
- (void)openImage:(id)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
   831
{
e22ad6bc8b46 svn 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
	NSURL	*imageURL = [sender representedObject];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   833
	[[NSWorkspace sharedWorkspace] openFile:[imageURL 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
   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
e22ad6bc8b46 svn 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
- (void)saveImageAs:(id)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
   837
{
e22ad6bc8b46 svn 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
	NSURL		*imageURL = [sender representedObject];
e22ad6bc8b46 svn 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
	NSString	*path = [imageURL 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
   840
	
e22ad6bc8b46 svn 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
	NSSavePanel *savePanel = [NSSavePanel savePanel];
4498
192f90d29d23 Deprecation removal for open and save panels.
Frank Dowsett <wixardy@adium.im>
parents: 4356
diff changeset
   842
	savePanel.nameFieldStringValue = [path lastPathComponent];
192f90d29d23 Deprecation removal for open and save panels.
Frank Dowsett <wixardy@adium.im>
parents: 4356
diff changeset
   843
	[savePanel beginSheetModalForWindow:[webView window] completionHandler:^(NSInteger result) {
192f90d29d23 Deprecation removal for open and save panels.
Frank Dowsett <wixardy@adium.im>
parents: 4356
diff changeset
   844
		if (result ==  NSFileHandlingPanelOKButton) {
192f90d29d23 Deprecation removal for open and save panels.
Frank Dowsett <wixardy@adium.im>
parents: 4356
diff changeset
   845
			[[NSFileManager defaultManager] copyItemAtURL:imageURL
192f90d29d23 Deprecation removal for open and save panels.
Frank Dowsett <wixardy@adium.im>
parents: 4356
diff changeset
   846
													toURL:savePanel.URL
192f90d29d23 Deprecation removal for open and save panels.
Frank Dowsett <wixardy@adium.im>
parents: 4356
diff changeset
   847
													error:nil];
192f90d29d23 Deprecation removal for open and save panels.
Frank Dowsett <wixardy@adium.im>
parents: 4356
diff changeset
   848
		}
192f90d29d23 Deprecation removal for open and save panels.
Frank Dowsett <wixardy@adium.im>
parents: 4356
diff changeset
   849
	}];
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
   850
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   851
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   852
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   853
 * @brief Append our own menu items to the webview's contextual menus
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   854
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   855
- (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   856
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   857
	NSMutableArray *webViewMenuItems = [[defaultMenuItems mutableCopy] autorelease];
2132
551c9646dacb Use the meta contact for the WKMV context menu.
Zachary West <zacw@adium.im>
parents: 2098
diff changeset
   858
	AIListContact	*chatListObject = chat.listObject.parentContact;
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
   859
	NSMenuItem		*menuItem;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   860
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   861
	//Remove default items we don't want
e22ad6bc8b46 svn 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
	if (webViewMenuItems) {
e22ad6bc8b46 svn 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
75
eb2d4c6c53c6 Preliminary conversion to using fast enumeration; caveats: variable declarations were not moved into loop headers. In *most* cases it should be safe to move them, but make sure the variable is not needed later on in the method. Also, AIContactController was not converted, because the conversion tool freaked out
David Smith
parents: 0
diff changeset
   864
		for (menuItem in defaultMenuItems) {
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
   865
			NSInteger tag = [menuItem tag];
e22ad6bc8b46 svn 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
			if ((tag == WebMenuItemTagOpenLinkInNewWindow) ||
e22ad6bc8b46 svn 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
				(tag == WebMenuItemTagDownloadLinkToDisk) ||
e22ad6bc8b46 svn 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
				(tag == WebMenuItemTagOpenImageInNewWindow) ||
e22ad6bc8b46 svn 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
				(tag == WebMenuItemTagDownloadImageToDisk) ||
e22ad6bc8b46 svn 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
				(tag == WebMenuItemTagOpenFrameInNewWindow) ||
e22ad6bc8b46 svn 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
				(tag == WebMenuItemTagStop) ||
e22ad6bc8b46 svn 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
				(tag == WebMenuItemTagReload)) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   873
				[webViewMenuItems removeObjectIdenticalTo:menuItem];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   874
			} else {
5345
8dd0d808e092 Backport 87047401414b for #16101. References #16101.
Robert Vehse <robertvehse@fastmail.fm>
parents: 4667
diff changeset
   875
				//This isn't as nice; there's no tag available. Use the localization from WebKit/WebCore, where it seems to be for some other people (#16101), to look at the title.
8dd0d808e092 Backport 87047401414b for #16101. References #16101.
Robert Vehse <robertvehse@fastmail.fm>
parents: 4667
diff changeset
   876
				if ([[menuItem title] isEqualToString:NSLocalizedStringFromTableInBundle(@"Open Link", nil, [NSBundle bundleForClass:[WebView class]], nil)] ||
8dd0d808e092 Backport 87047401414b for #16101. References #16101.
Robert Vehse <robertvehse@fastmail.fm>
parents: 4667
diff changeset
   877
					[[menuItem title] isEqualToString:NSLocalizedStringFromTableInBundle(@"Open Link", nil, [NSBundle bundleWithIdentifier:@"com.apple.WebCore"], nil)])
8dd0d808e092 Backport 87047401414b for #16101. References #16101.
Robert Vehse <robertvehse@fastmail.fm>
parents: 4667
diff changeset
   878
					[webViewMenuItems removeObjectIdenticalTo:menuItem];
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
   879
			}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   880
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   881
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   882
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   883
	NSURL	*imageURL;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   884
	if ((imageURL = [element objectForKey:WebElementImageURLKey])) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   885
		//This is an image		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   886
		if (!webViewMenuItems) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   887
			webViewMenuItems = [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
   888
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   889
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   890
		menuItem = [[NSMenuItem alloc] initWithTitle:AILocalizedString(@"Open Image", 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
   891
											  target: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
   892
											  action:@selector(openImage:)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   893
									   keyEquivalent:@""
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   894
								   representedObject:imageURL];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   895
		[webViewMenuItems addObject:menuItem];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   896
		[menuItem 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
   897
		menuItem = [[NSMenuItem alloc] initWithTitle:[AILocalizedString(@"Save Image As", nil) stringByAppendingEllipsis]
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   898
											  target: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
   899
											  action:@selector(saveImageAs:)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   900
									   keyEquivalent:@""
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   901
								   representedObject:imageURL];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   902
		[webViewMenuItems addObject:menuItem];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   903
		[menuItem 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
   904
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   905
		/*
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   906
		NSString *imgClass = [img className];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   907
		//being very careful to only get user icons... a better way would be to put a class "usericon" on the img, but I haven't worked out how to do that, so we test for the name of the person in the src, and that it's not an emoticon or direct connect image.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   908
		if([[img getAttribute:@"src"] rangeOfString:internalObjectID].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
   909
		   [imgClass rangeOfString:@"emoticon"].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
   910
		   [imgClass rangeOfString:@"fullSizeImage"].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
   911
		   [imgClass rangeOfString:@"scaledToFitImage"].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
   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
			
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   914
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   915
1711
3dbf96553123 And immediately after checking that in, a little bird chirped at me "hey, nice job exceeding the bounds when the array has no entries.".
Zachary West <zacw@adiumx.com>
parents: 1710
diff changeset
   916
	if (webViewMenuItems) {		
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
   917
		//Add a separator item if items already exist in webViewMenuItems
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   918
		if ([webViewMenuItems count]) {
1711
3dbf96553123 And immediately after checking that in, a little bird chirped at me "hey, nice job exceeding the bounds when the array has no entries.".
Zachary West <zacw@adiumx.com>
parents: 1710
diff changeset
   919
			// If the first item is a separator item, remove it.
3dbf96553123 And immediately after checking that in, a little bird chirped at me "hey, nice job exceeding the bounds when the array has no entries.".
Zachary West <zacw@adiumx.com>
parents: 1710
diff changeset
   920
			if ([[webViewMenuItems objectAtIndex:0] isSeparatorItem]) {
3dbf96553123 And immediately after checking that in, a little bird chirped at me "hey, nice job exceeding the bounds when the array has no entries.".
Zachary West <zacw@adiumx.com>
parents: 1710
diff changeset
   921
				[webViewMenuItems removeObjectAtIndex:0];
3dbf96553123 And immediately after checking that in, a little bird chirped at me "hey, nice job exceeding the bounds when the array has no entries.".
Zachary West <zacw@adiumx.com>
parents: 1710
diff changeset
   922
			}
3dbf96553123 And immediately after checking that in, a little bird chirped at me "hey, nice job exceeding the bounds when the array has no entries.".
Zachary West <zacw@adiumx.com>
parents: 1710
diff changeset
   923
			
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
   924
			[webViewMenuItems addObject:[NSMenuItem separatorItem]];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   925
		}
e22ad6bc8b46 svn 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
	} 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
   927
		webViewMenuItems = [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
   928
	}
e22ad6bc8b46 svn 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
806
0996f531c4b4 Allow an account to specify menu items for a chat, and provide a "Force Refresh" menu item for Twitter chats.
Zachary West <zacw@adiumx.com>
parents: 715
diff changeset
   930
	NSMenu *originalMenu = nil;
0996f531c4b4 Allow an account to specify menu items for a chat, and provide a "Force Refresh" menu item for Twitter chats.
Zachary West <zacw@adiumx.com>
parents: 715
diff changeset
   931
	
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
   932
	if (chatListObject) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   933
		NSArray *locations;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   934
		if ([chatListObject isIntentionallyNotAStranger]) {
e22ad6bc8b46 svn 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
			locations = [NSArray arrayWithObjects:
e22ad6bc8b46 svn 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
				[NSNumber numberWithInteger:Context_Contact_Manage],
e22ad6bc8b46 svn 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
				[NSNumber numberWithInteger:Context_Contact_Action],
e22ad6bc8b46 svn 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
				[NSNumber numberWithInteger:Context_Contact_NegativeAction],
e22ad6bc8b46 svn 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
				[NSNumber numberWithInteger:Context_Contact_ChatAction],
e22ad6bc8b46 svn 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
				[NSNumber numberWithInteger:Context_Contact_Additions], 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
   941
		} 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
   942
			locations = [NSArray arrayWithObjects:
e22ad6bc8b46 svn 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
				[NSNumber numberWithInteger:Context_Contact_Manage],
e22ad6bc8b46 svn 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
				[NSNumber numberWithInteger:Context_Contact_Action],
e22ad6bc8b46 svn 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
				[NSNumber numberWithInteger:Context_Contact_NegativeAction],
e22ad6bc8b46 svn 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
				[NSNumber numberWithInteger:Context_Contact_ChatAction],
e22ad6bc8b46 svn 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
				[NSNumber numberWithInteger:Context_Contact_Stranger_ChatAction],
e22ad6bc8b46 svn 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
				[NSNumber numberWithInteger:Context_Contact_Additions], 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
   949
		}
e22ad6bc8b46 svn 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
		
806
0996f531c4b4 Allow an account to specify menu items for a chat, and provide a "Force Refresh" menu item for Twitter chats.
Zachary West <zacw@adiumx.com>
parents: 715
diff changeset
   951
		originalMenu = [adium.menuController contextualMenuWithLocations:locations
2098
6fcd0b1bef55 Make the WKMV use original menu items instead of copies. Reference the chat we're creating the context menu for.
Zachary West <zacw@adium.im>
parents: 1820
diff changeset
   952
														   forListObject:chatListObject
6fcd0b1bef55 Make the WKMV use original menu items instead of copies. Reference the chat we're creating the context menu for.
Zachary West <zacw@adium.im>
parents: 1820
diff changeset
   953
																  inChat:chat];
806
0996f531c4b4 Allow an account to specify menu items for a chat, and provide a "Force Refresh" menu item for Twitter chats.
Zachary West <zacw@adiumx.com>
parents: 715
diff changeset
   954
	} else if(chat.isGroupChat) {
1232
15eec822e095 Create a context menu location for group chats. Only validate "add bookmark" when we don't already have a bookmark. Adds a menu item for "Add Bookmark" to the context menu for group chats. Refs #11805.
Zachary West <zacw@adiumx.com>
parents: 1231
diff changeset
   955
		originalMenu = [adium.menuController contextualMenuWithLocations:[NSArray arrayWithObjects:
1240
9efa7b2b7f16 Add the "Toggle Userlist" menu item to the context for group chats, and create a new section for it and the add bookmark. Fixes #11805.
Zachary West <zacw@adiumx.com>
parents: 1232
diff changeset
   956
																		  [NSNumber numberWithInteger:Context_GroupChat_Manage],
9efa7b2b7f16 Add the "Toggle Userlist" menu item to the context for group chats, and create a new section for it and the add bookmark. Fixes #11805.
Zachary West <zacw@adiumx.com>
parents: 1232
diff changeset
   957
																		  [NSNumber numberWithInteger:Context_GroupChat_Action], nil]
911
504dfcc87b3f Correctly let the menu controller provide a context menu for locations + a chat, instead of just a chat. I don't know why I didn't do this the first time. Adds said context menu to the tab context menu for group chats.
Zachary West <zacw@adiumx.com>
parents: 892
diff changeset
   958
																 forChat:chat];
806
0996f531c4b4 Allow an account to specify menu items for a chat, and provide a "Force Refresh" menu item for Twitter chats.
Zachary West <zacw@adiumx.com>
parents: 715
diff changeset
   959
	}
0996f531c4b4 Allow an account to specify menu items for a chat, and provide a "Force Refresh" menu item for Twitter chats.
Zachary West <zacw@adiumx.com>
parents: 715
diff changeset
   960
	
2098
6fcd0b1bef55 Make the WKMV use original menu items instead of copies. Reference the chat we're creating the context menu for.
Zachary West <zacw@adium.im>
parents: 1820
diff changeset
   961
	[webViewMenuItems addObjectsFromArray:originalMenu.itemArray];
6fcd0b1bef55 Make the WKMV use original menu items instead of copies. Reference the chat we're creating the context menu for.
Zachary West <zacw@adium.im>
parents: 1820
diff changeset
   962
	[originalMenu removeAllItems];
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
   963
892
cc2cf1948134 Patch from '''wixardy''' to prevent a duplicate separator item in group chat context menus. Fixes #11674.
Zachary West <zacw@adiumx.com>
parents: 854
diff changeset
   964
	if (webViewMenuItems.count > 0 && ![[webViewMenuItems objectAtIndex:webViewMenuItems.count-1] isSeparatorItem])
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
   965
		[webViewMenuItems addObject:[NSMenuItem separatorItem]];
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 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
	//Present an option to clear the display
e22ad6bc8b46 svn 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
	menuItem = [[NSMenuItem alloc] initWithTitle:AILocalizedString(@"Clear Display", "Clears the display window for the currently open message window")
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   969
										  target: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
   970
										  action:@selector(clearView)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   971
								   keyEquivalent:@""];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   972
	[webViewMenuItems addObject:menuItem];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   973
	[menuItem 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
   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
	return webViewMenuItems;
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   978
/*!
4647
c8f4e9819f53 Because some/lots of message styles override our Template.html, we inject the event listener, instead of having it in the default Template.html. Refs #15377.
Adrian Godoroja <robotive@me.com>
parents: 4646
diff changeset
   979
 * @brief Add ourself to the window script object bridge when it's safe to do so. Also injects custom javascript.
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
   980
 */
471
b107820cd607 More deprecation removal
David Smith
parents: 428
diff changeset
   981
- (void)webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)windowObject forFrame:(WebFrame *)frame
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
   982
{
e22ad6bc8b46 svn 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
    [[webView windowScriptObject] setValue:self forKey:@"client"];
4647
c8f4e9819f53 Because some/lots of message styles override our Template.html, we inject the event listener, instead of having it in the default Template.html. Refs #15377.
Adrian Godoroja <robotive@me.com>
parents: 4646
diff changeset
   984
	
c8f4e9819f53 Because some/lots of message styles override our Template.html, we inject the event listener, instead of having it in the default Template.html. Refs #15377.
Adrian Godoroja <robotive@me.com>
parents: 4646
diff changeset
   985
	// Add an event listener for DOM ready and notify back our controller
c8f4e9819f53 Because some/lots of message styles override our Template.html, we inject the event listener, instead of having it in the default Template.html. Refs #15377.
Adrian Godoroja <robotive@me.com>
parents: 4646
diff changeset
   986
	[[webView windowScriptObject] evaluateWebScript:@"document.addEventListener(\"DOMContentLoaded\", function() {window.client.$_setDocumentReady()}, false);"];
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
   987
}
e22ad6bc8b46 svn 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
//Dragging delegate ----------------------------------------------------------------------------------------------------
e22ad6bc8b46 svn 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
#pragma mark Dragging delegate
e22ad6bc8b46 svn 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
/*!
e22ad6bc8b46 svn 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
 * @brief If possible, return the first NSTextView in the message view's responder chain
e22ad6bc8b46 svn 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
 *
e22ad6bc8b46 svn 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
 * This is used for drag and drop 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
   995
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   996
- (NSTextView *)textView
e22ad6bc8b46 svn 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
	id	responder = [webView nextResponder];
e22ad6bc8b46 svn 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
	
e22ad6bc8b46 svn 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
	//Walkin the responder chain looking for an NSTextView
e22ad6bc8b46 svn 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
	while (responder &&
e22ad6bc8b46 svn 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
		  ![responder isKindOfClass:[NSTextView 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
  1003
		responder = [responder nextResponder];
e22ad6bc8b46 svn 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
	}
e22ad6bc8b46 svn 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
	
e22ad6bc8b46 svn 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
	return responder;
e22ad6bc8b46 svn 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
}
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 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
/*!
e22ad6bc8b46 svn 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
 * @brief Dragging entered
e22ad6bc8b46 svn 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
 */
e22ad6bc8b46 svn 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
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)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
  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
	NSPasteboard	*pasteboard = [sender draggingPasteboard];
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 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
	return ([pasteboard availableTypeFromArray:draggedTypes] ?
e22ad6bc8b46 svn 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
		   NSDragOperationCopy :
e22ad6bc8b46 svn 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
		   NSDragOperationNone);
e22ad6bc8b46 svn 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
}
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 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
/*!
e22ad6bc8b46 svn 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
* @brief Dragging updated
e22ad6bc8b46 svn 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
 */
e22ad6bc8b46 svn 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
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)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
  1025
{
e22ad6bc8b46 svn 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
	return [self draggingEntered: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
  1027
}
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 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
/*!
e22ad6bc8b46 svn 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
 * @brief Handle a drag onto the webview
e22ad6bc8b46 svn 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
 * 
e22ad6bc8b46 svn 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
 * If we're getting a non-image file, we can handle it immediately.  Otherwise, the drag is the textView's problem.
e22ad6bc8b46 svn 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
 */
e22ad6bc8b46 svn 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
- (BOOL)performDragOperation:(id <NSDraggingInfo>)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
  1035
{
e22ad6bc8b46 svn 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
	NSPasteboard	*pasteboard = [sender draggingPasteboard];
e22ad6bc8b46 svn 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
	BOOL			success = 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
  1038
	
e22ad6bc8b46 svn 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
	if ([self shouldHandleDragWithPasteboard:pasteboard]) {
e22ad6bc8b46 svn 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
		
e22ad6bc8b46 svn 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
		//Not an image but it is a file - send it immediately as a file transfer
e22ad6bc8b46 svn 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
		NSArray			*files = [pasteboard propertyListForType:NSFilenamesPboardType];