Source/AIInterfaceController.m
author Evan Schoenberg
Thu, 14 Nov 2019 21:09:06 -0500
branchadium-1.5.11
changeset 6016 325e2ab3406f
parent 4897 5ea3bd51010d
permissions -rw-r--r--
Fixed a bunch of warnings
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
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    18
#import "AIInterfaceController.h"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    19
e22ad6bc8b46 svn 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 <Adium/AIAccountControllerProtocol.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 <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
    22
#import <Adium/AIChatControllerProtocol.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    23
#import <Adium/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
    24
#import <Adium/AIMenuControllerProtocol.h>
1260
e1e0ac181ad3 Only kill off the auth requests window if it doesn't have any pending responses. Add a menu item to the file transfer / log viewer area in the Window menu which opens the auth request window.
Zachary West <zacw@adiumx.com>
parents: 1244
diff changeset
    25
#import <Adium/AIAuthorizationRequestsWindowController.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
    26
#import <AIUtilities/AIAttributedStringAdditions.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 <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
    28
#import <AIUtilities/AIFontAdditions.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 <AIUtilities/AIImageDrawingAdditions.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    30
#import <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
    31
#import <AIUtilities/AIStringAdditions.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    32
#import <AIUtilities/AITooltipUtilities.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 <AIUtilities/AIWindowAdditions.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 <AIUtilities/AITextAttributes.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 <AIUtilities/AIWindowControllerAdditions.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    36
#import <Adium/AIChat.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
    37
#import <Adium/AIListContact.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    38
#import <Adium/AIListGroup.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/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
    40
#import <Adium/AIMetaContact.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
    41
#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
    42
#import <Adium/AIServiceIcons.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    43
#import <Adium/AISortController.h>
4021
f5412548f2f3 Resolved several dozen warnings
Evan Schoenberg
parents: 3893
diff changeset
    44
#import "AIMessageWindowController.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
    45
#import "AIMessageTabViewItem.h"
1894
df033cc40f2d Disable the 'always search user paths' option (it's only enabled by default for backwards compatibility with gcc3) and fix the resulting errors.
David Smith <catfish.man@gmail.com>
parents: 1689
diff changeset
    46
#import "KNShelfSplitview.h"
52
54c2435615e8 Add a new subclass of AIListGroup to represent contact lists. The idea here is that contact lists are the only remaining place where we have groups inside groups, and so was forcing us to maintain nested group code in places. Parts of this are a work in progress; for example, with 'show groups' turned off, AIContactList should enforce that only AIListContacts can be added, but doing that will require rewriting how the show groups system works.
David Smith
parents: 3
diff changeset
    47
#import <Adium/AIContactList.h>
3092
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3088
diff changeset
    48
#import "AIListOutlineView.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
    49
e22ad6bc8b46 svn 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 "AIMessageViewController.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
    51
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    52
#define ERROR_MESSAGE_WINDOW_TITLE		AILocalizedString(@"Adium : Error","Error message window title")
3087
30703336e5b6 Resolve implicit 64->32 bit castings in Adium.app
Stephen Holt <sholt@adium.im>
parents: 2914
diff changeset
    53
#define LABEL_ENTRY_SPACING				4.0f
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
#define DISPLAY_IMAGE_ON_RIGHT			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
    55
e22ad6bc8b46 svn 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
#define PREF_GROUP_FORMATTING			@"Formatting"
e22ad6bc8b46 svn 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 KEY_FORMATTING_FONT				@"Default Font"
e22ad6bc8b46 svn 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 MESSAGES_WINDOW_MENU_TITLE		AILocalizedString(@"Chats","Title for the messages window menu item")
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    60
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    61
//#define	LOG_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
    62
3092
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3088
diff changeset
    63
@interface NSObject (AIInterfaceController_WindowPrefsTarget)
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3088
diff changeset
    64
- (void)selectedWindowLevel:(id)sender;
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3088
diff changeset
    65
@end
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3088
diff changeset
    66
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: 81
diff changeset
    67
@interface AIInterfaceController ()
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
    68
- (void)_resetOpenChatsCache;
e22ad6bc8b46 svn 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)_addItemToMainMenuAndDock:(NSMenuItem *)item;
4021
f5412548f2f3 Resolved several dozen warnings
Evan Schoenberg
parents: 3893
diff changeset
    70
- (NSMutableAttributedString *)_tooltipTitleForObject:(AIListObject *)object;
f5412548f2f3 Resolved several dozen warnings
Evan Schoenberg
parents: 3893
diff changeset
    71
- (NSMutableAttributedString *)_tooltipBodyForObject:(AIListObject *)object;
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
    72
- (void)_pasteWithPreferredSelector:(SEL)preferredSelector sender:(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
    73
- (void)updateCloseMenuKeys;
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 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)saveContainers;
e22ad6bc8b46 svn 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)restoreSavedContainers;
3092
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3088
diff changeset
    77
- (void)saveContainersOnQuit:(NSNotification *)notification;
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3088
diff changeset
    78
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3088
diff changeset
    79
- (void)toggleUserlist:(id)sender;
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3088
diff changeset
    80
- (void)toggleUserlistSide:(id)sender;
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3088
diff changeset
    81
- (void)clearDisplay:(id)sender;
4568
87a0f0ebd59a Fixed a bunch of warnings.
Adrian Godoroja <robotive@me.com>
parents: 4056
diff changeset
    82
- (IBAction)closeContextualChat:(id)sender;
3092
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3088
diff changeset
    83
- (void)openAuthorizationWindow:(id)sender;
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3088
diff changeset
    84
- (void)didReceiveContent:(NSNotification *)notification;
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3088
diff changeset
    85
- (void)adiumDidFinishLoading:(NSNotification *)inNotification;
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3088
diff changeset
    86
- (void)flashTimer:(NSTimer *)inTimer;
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
    87
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    88
//Window Menu
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    89
- (void)updateActiveWindowMenuItem;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    90
- (void)buildWindowMenu;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    91
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    92
- (AIChat *)mostRecentActiveChat;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    93
@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
    94
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    95
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    96
 * @class AIInterfaceController
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    97
 * @brief Interface controller
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    98
 *
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    99
 * Chat window related requests, such as opening and closing chats, are routed through the interface controller
e22ad6bc8b46 svn 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
 * to the appropriate component. The interface controller keeps track of the most recently active chat, handles 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
   101
 * cycling (switching between chats), chat sorting, and so on.  The interface controller also handles switching to
e22ad6bc8b46 svn 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
 * an appropriate window or chat when the dock icon is clicked for a 'reopen' event.
e22ad6bc8b46 svn 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
 * Contact list window requests, such as toggling window visibilty are routed to the contact list controller component.
e22ad6bc8b46 svn 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
 * Error messages are routed through the interface controller.
e22ad6bc8b46 svn 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
 * Tooltips, such as seen on hover in the contact list are generated and displayed here.  Tooltip display components 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
   109
 * plugins register with the interface controller to be queried for contact information when a tooltip is displayed.
e22ad6bc8b46 svn 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
 * When displays in Adium flash, such as in the dock or the contact list for unviewed content, the interface controller
e22ad6bc8b46 svn 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
 * manages keeping the flashing synchronized.
e22ad6bc8b46 svn 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
 *
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   114
 * Finally, the interface controller manages many menu items, providing better menu item validation and target routing
e22ad6bc8b46 svn 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
 * than the responder chain alone would do.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   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
@implementation AIInterfaceController
e22ad6bc8b46 svn 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
- (id)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
   120
{
e22ad6bc8b46 svn 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
	if ((self = [super init])) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   122
		contactListViewArray = [[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
   123
		messageViewArray = [[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
   124
		contactListTooltipEntryArray = [[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
   125
		contactListTooltipSecondaryEntryArray = [[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
   126
		closeMenuConfiguredForChat = 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
   127
		_cachedOpenChats = 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
   128
		mostRecentActiveChat = 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
   129
		activeChat = 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
   130
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   131
		tooltipListObject = 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
   132
		tooltipTitle = 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
   133
		tooltipBody = 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
   134
		tooltipImage = 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
   135
		flashObserverArray = 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
   136
		flashTimer = 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
   137
		flashState = 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
   138
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   139
		windowMenuArray = nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   140
		
3277
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   141
		recentlyClosedChats = [[NSMutableArray alloc] init];
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   142
		
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
   143
#ifdef LOG_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
   144
		[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(reportResponderChain:) userInfo:nil repeats: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
   145
#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
   146
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   147
	
e22ad6bc8b46 svn 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
	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
   149
}
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   151
#ifdef LOG_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
   152
//Can be called by a timer to periodically log the 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
   153
//[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(reportResponderChain:) userInfo:nil repeats: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
   154
- (void)reportResponderChain:(NSTimer *)inTimer
e22ad6bc8b46 svn 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
	NSMutableString	*responderChain = [NSMutableString string];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   157
	
3088
86d1432abf47 Remove shadowing varibles in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3087
diff changeset
   158
	NSWindow	*keyWin = [[NSApplication sharedApplication] keyWindow];
3
f0cc4d307eb8 Merge 64 bit branch to trunk. Fingers crossed, and I have been testing it some, but expect fallout from this. 11,000 line diffs are rarely without consequence ;)
David Smith
parents: 0
diff changeset
   159
#warning 64BIT: Check formatting arguments
3088
86d1432abf47 Remove shadowing varibles in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3087
diff changeset
   160
	[responderChain appendFormat:@"%@ (%i): ",keyWin,[keyWin respondsToSelector:@selector(print:)]];
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
   161
	
3088
86d1432abf47 Remove shadowing varibles in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3087
diff changeset
   162
	NSResponder	*responder = [keyWin firstResponder];
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
   163
	
e22ad6bc8b46 svn 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
	//First, walk down the responder chain looking for a responder which can handle the preferred selector
e22ad6bc8b46 svn 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
	while (responder) {
3
f0cc4d307eb8 Merge 64 bit branch to trunk. Fingers crossed, and I have been testing it some, but expect fallout from this. 11,000 line diffs are rarely without consequence ;)
David Smith
parents: 0
diff changeset
   166
#warning 64BIT: Check formatting arguments
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
		[responderChain appendFormat:@"%@ (%i)",responder,[responder respondsToSelector:@selector(print:)]];
e22ad6bc8b46 svn 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
		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
   169
		if (responder) [responderChain appendString:@" -> "];
e22ad6bc8b46 svn 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
	NSLog(responderChain);
e22ad6bc8b46 svn 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
#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
   175
e22ad6bc8b46 svn 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
- (void)controllerDidLoad
e22ad6bc8b46 svn 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
{
e22ad6bc8b46 svn 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
    //Load the interface
e22ad6bc8b46 svn 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
    [interfacePlugin openInterface];
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 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
	//Open the contact list 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
   182
    [self showContactList: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
   183
	
e22ad6bc8b46 svn 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
	//Userlist show/hide item
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   185
	menuItem_toggleUserlist = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:AILocalizedString(@"Toggle User List", 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
   186
																							 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
   187
																							 action:@selector(toggleUserlist:)
872
35bc05062677 Set a shortcut of Command+Option+/ for the "Toggle User List" menu item.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
   188
																					  keyEquivalent:@"/"];
35bc05062677 Set a shortcut of Command+Option+/ for the "Toggle User List" menu item.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
   189
	[menuItem_toggleUserlist setKeyEquivalentModifierMask:(NSCommandKeyMask | NSAlternateKeyMask)];
35bc05062677 Set a shortcut of Command+Option+/ for the "Toggle User List" menu item.
Zachary West <zacw@adiumx.com>
parents: 837
diff changeset
   190
	
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: 1370
diff changeset
   191
	[adium.menuController addMenuItem:menuItem_toggleUserlist toLocation:LOC_Display_General];
1587
638be358254c Add "Toggle User List Side" to the Display menu. Unlike the user list toggle, this is a global preference change.
Zachary West <zacw@adiumx.com>
parents: 1543
diff changeset
   192
	
638be358254c Add "Toggle User List Side" to the Display menu. Unlike the user list toggle, this is a global preference change.
Zachary West <zacw@adiumx.com>
parents: 1543
diff changeset
   193
	menuItem_toggleUserlistSide = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:AILocalizedString(@"Toggle User List Side", nil)
638be358254c Add "Toggle User List Side" to the Display menu. Unlike the user list toggle, this is a global preference change.
Zachary West <zacw@adiumx.com>
parents: 1543
diff changeset
   194
																				   target:self
638be358254c Add "Toggle User List Side" to the Display menu. Unlike the user list toggle, this is a global preference change.
Zachary West <zacw@adiumx.com>
parents: 1543
diff changeset
   195
																				   action:@selector(toggleUserlistSide:)
638be358254c Add "Toggle User List Side" to the Display menu. Unlike the user list toggle, this is a global preference change.
Zachary West <zacw@adiumx.com>
parents: 1543
diff changeset
   196
																			keyEquivalent:@""];
638be358254c Add "Toggle User List Side" to the Display menu. Unlike the user list toggle, this is a global preference change.
Zachary West <zacw@adiumx.com>
parents: 1543
diff changeset
   197
	
638be358254c Add "Toggle User List Side" to the Display menu. Unlike the user list toggle, this is a global preference change.
Zachary West <zacw@adiumx.com>
parents: 1543
diff changeset
   198
	[adium.menuController addMenuItem:menuItem_toggleUserlistSide toLocation:LOC_Display_General];
1244
07bb943f5b46 Fix the group chat context menu's items not working correctly when Adium isn't active or the chat wasn't active.
Zachary West <zacw@adiumx.com>
parents: 1240
diff changeset
   199
07bb943f5b46 Fix the group chat context menu's items not working correctly when Adium isn't active or the chat wasn't active.
Zachary West <zacw@adiumx.com>
parents: 1240
diff changeset
   200
	NSMenuItem *menuItem = [[[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:AILocalizedString(@"Toggle User List", nil)
07bb943f5b46 Fix the group chat context menu's items not working correctly when Adium isn't active or the chat wasn't active.
Zachary West <zacw@adiumx.com>
parents: 1240
diff changeset
   201
																				target:self
1689
b569c874613c Fix the "Toggle User List" context menu item.
Zachary West <zacw@adiumx.com>
parents: 1588
diff changeset
   202
																				action:@selector(toggleUserlist:)
1244
07bb943f5b46 Fix the group chat context menu's items not working correctly when Adium isn't active or the chat wasn't active.
Zachary West <zacw@adiumx.com>
parents: 1240
diff changeset
   203
																		 keyEquivalent:@""] autorelease];
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: 1109
diff changeset
   204
	
1244
07bb943f5b46 Fix the group chat context menu's items not working correctly when Adium isn't active or the chat wasn't active.
Zachary West <zacw@adiumx.com>
parents: 1240
diff changeset
   205
	[adium.menuController addContextualMenuItem:menuItem toLocation:Context_GroupChat_Action];
1588
49fe97b40727 Expose the chat container -> message view controller link. Add a "Clear Display" menu item to the Display menu.
Zachary West <zacw@adiumx.com>
parents: 1587
diff changeset
   206
	
49fe97b40727 Expose the chat container -> message view controller link. Add a "Clear Display" menu item to the Display menu.
Zachary West <zacw@adiumx.com>
parents: 1587
diff changeset
   207
	// Clear display
49fe97b40727 Expose the chat container -> message view controller link. Add a "Clear Display" menu item to the Display menu.
Zachary West <zacw@adiumx.com>
parents: 1587
diff changeset
   208
	menuItem_clearDisplay = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:AILocalizedString(@"Clear Display", nil)
49fe97b40727 Expose the chat container -> message view controller link. Add a "Clear Display" menu item to the Display menu.
Zachary West <zacw@adiumx.com>
parents: 1587
diff changeset
   209
																				 target:self
49fe97b40727 Expose the chat container -> message view controller link. Add a "Clear Display" menu item to the Display menu.
Zachary West <zacw@adiumx.com>
parents: 1587
diff changeset
   210
																				 action:@selector(clearDisplay:)
49fe97b40727 Expose the chat container -> message view controller link. Add a "Clear Display" menu item to the Display menu.
Zachary West <zacw@adiumx.com>
parents: 1587
diff changeset
   211
																		  keyEquivalent:@""];
49fe97b40727 Expose the chat container -> message view controller link. Add a "Clear Display" menu item to the Display menu.
Zachary West <zacw@adiumx.com>
parents: 1587
diff changeset
   212
	[adium.menuController addMenuItem:menuItem_clearDisplay toLocation:LOC_Display_MessageControl];
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
   213
																			  
e22ad6bc8b46 svn 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
	//Contact list menu item
1244
07bb943f5b46 Fix the group chat context menu's items not working correctly when Adium isn't active or the chat wasn't active.
Zachary West <zacw@adiumx.com>
parents: 1240
diff changeset
   215
	menuItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:AILocalizedString(@"Contact List","Name of the window which lists contacts")
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
   216
																				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
   217
																				action:@selector(toggleContactList:)
e22ad6bc8b46 svn 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
																		 keyEquivalent:@"/"];
100
68210ab2807a sed is evil. All [adium *Controller]s are now adium.*Controller.
David Smith
parents: 95
diff changeset
   219
	[adium.menuController addMenuItem:menuItem toLocation:LOC_Window_Fixed];
68210ab2807a sed is evil. All [adium *Controller]s are now adium.*Controller.
David Smith
parents: 95
diff changeset
   220
	[adium.menuController addMenuItem:[[menuItem copy] autorelease] toLocation:LOC_Dock_Status];
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
   221
	[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
   222
	
e22ad6bc8b46 svn 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
	menuItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:AILocalizedString(@"Close Chat","Title for the close chat menu item")
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   224
																	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
   225
																	action:@selector(closeContextualChat:)
e22ad6bc8b46 svn 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
															 keyEquivalent:@""];
100
68210ab2807a sed is evil. All [adium *Controller]s are now adium.*Controller.
David Smith
parents: 95
diff changeset
   227
	[adium.menuController addContextualMenuItem:menuItem toLocation:Context_Tab_Action];
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
   228
	[menuItem release];
1260
e1e0ac181ad3 Only kill off the auth requests window if it doesn't have any pending responses. Add a menu item to the file transfer / log viewer area in the Window menu which opens the auth request window.
Zachary West <zacw@adiumx.com>
parents: 1244
diff changeset
   229
	
e1e0ac181ad3 Only kill off the auth requests window if it doesn't have any pending responses. Add a menu item to the file transfer / log viewer area in the Window menu which opens the auth request window.
Zachary West <zacw@adiumx.com>
parents: 1244
diff changeset
   230
	// Authorization requests menu item
2820
9493e70f3fe0 Grab the "Authorization Requests" localized string from the right bundle. Refs #13275.
Zachary West <zacw@adium.im>
parents: 2131
diff changeset
   231
	menuItem = [[NSMenuItem alloc] initWithTitle:AILocalizedStringFromTableInBundle(@"Authorization Requests",nil, [NSBundle bundleForClass:[AIAuthorizationRequestsWindowController class]], nil)
9493e70f3fe0 Grab the "Authorization Requests" localized string from the right bundle. Refs #13275.
Zachary West <zacw@adium.im>
parents: 2131
diff changeset
   232
										  target:self
9493e70f3fe0 Grab the "Authorization Requests" localized string from the right bundle. Refs #13275.
Zachary West <zacw@adium.im>
parents: 2131
diff changeset
   233
										  action:@selector(openAuthorizationWindow:)
9493e70f3fe0 Grab the "Authorization Requests" localized string from the right bundle. Refs #13275.
Zachary West <zacw@adium.im>
parents: 2131
diff changeset
   234
								   keyEquivalent:@""];
1260
e1e0ac181ad3 Only kill off the auth requests window if it doesn't have any pending responses. Add a menu item to the file transfer / log viewer area in the Window menu which opens the auth request window.
Zachary West <zacw@adiumx.com>
parents: 1244
diff changeset
   235
	
e1e0ac181ad3 Only kill off the auth requests window if it doesn't have any pending responses. Add a menu item to the file transfer / log viewer area in the Window menu which opens the auth request window.
Zachary West <zacw@adiumx.com>
parents: 1244
diff changeset
   236
	[adium.menuController addMenuItem:menuItem toLocation:LOC_Window_Auxiliary];
e1e0ac181ad3 Only kill off the auth requests window if it doesn't have any pending responses. Add a menu item to the file transfer / log viewer area in the Window menu which opens the auth request window.
Zachary West <zacw@adiumx.com>
parents: 1244
diff changeset
   237
	[menuItem 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
   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
    //Observe content so we can open chats as necessary
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: 1061
diff changeset
   240
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveContent:) 
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
   241
									   name:CONTENT_MESSAGE_RECEIVED object:nil];
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: 1061
diff changeset
   242
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveContent:) 
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
   243
									   name:CONTENT_MESSAGE_RECEIVED_GROUP object: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
   244
	
e22ad6bc8b46 svn 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
	//Observe Adium finishing loading so we can do things which may require other components or plugins
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: 1061
diff changeset
   246
	[[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
   247
								   selector:@selector(adiumDidFinishLoading:)
e22ad6bc8b46 svn 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
									   name:AIApplicationDidFinishLoadingNotification
e22ad6bc8b46 svn 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
									 object: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
   250
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   251
	//Observe quits so we can save containers.
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: 1061
diff changeset
   252
	[[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
   253
								   selector:@selector(saveContainersOnQuit:)
e22ad6bc8b46 svn 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
									   name:AIAppWillTerminateNotification
e22ad6bc8b46 svn 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
									 object: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
   256
}
e22ad6bc8b46 svn 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
- (void)controllerWillClose
e22ad6bc8b46 svn 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
    [contactListPlugin closeContactList];
e22ad6bc8b46 svn 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
    [interfacePlugin closeInterface];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   262
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   263
e22ad6bc8b46 svn 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
// 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
   265
- (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
   266
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   267
    [contactListViewArray release]; contactListViewArray = 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
   268
    [messageViewArray release]; messageViewArray = 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
   269
    [interfaceArray release]; interfaceArray = 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
   270
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   271
    [tooltipListObject release]; tooltipListObject = 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
   272
	[tooltipTitle release]; tooltipTitle = 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
   273
	[tooltipBody release]; tooltipBody = 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
   274
	[tooltipImage release]; tooltipImage = 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
   275
	
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: 1061
diff changeset
   276
	[[NSNotificationCenter defaultCenter] removeObserver:self];
95
47acbc0cc17a Propertyize AIListObject and convert some more controller accesses to dot syntax
David Smith
parents: 89
diff changeset
   277
	[adium.preferenceController unregisterPreferenceObserver: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
   278
	
3277
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   279
	[recentlyClosedChats release]; recentlyClosedChats = nil;
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   280
	
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
   281
    [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
   282
}
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 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
- (void)adiumDidFinishLoading:(NSNotification *)inNotification
e22ad6bc8b46 svn 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
	//Observe preference changes. This will also restore saved containers if appropriate.
95
47acbc0cc17a Propertyize AIListObject and convert some more controller accesses to dot syntax
David Smith
parents: 89
diff changeset
   287
	[adium.preferenceController registerPreferenceObserver:self forGroup:PREF_GROUP_INTERFACE];
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
	
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: 1061
diff changeset
   289
	[[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
   290
										  name:AIApplicationDidFinishLoadingNotification
e22ad6bc8b46 svn 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
										object: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
   292
}
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 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
//Registers code to handle the interface
e22ad6bc8b46 svn 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
- (void)registerInterfaceController:(id <AIInterfaceComponent>)inController
e22ad6bc8b46 svn 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
	if (!interfacePlugin) interfacePlugin = [inController 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
   298
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   299
e22ad6bc8b46 svn 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
//Register code to handle the contact list
4021
f5412548f2f3 Resolved several dozen warnings
Evan Schoenberg
parents: 3893
diff changeset
   301
- (void)registerContactListController:(id <AIMultiContactListComponent>)inController
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
   302
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   303
	if (!contactListPlugin) contactListPlugin = [inController 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
   304
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   305
e22ad6bc8b46 svn 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
//Preferences changed
e22ad6bc8b46 svn 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
- (void)preferencesChangedForGroup:(NSString *)group key:(NSString *)key
e22ad6bc8b46 svn 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
							object:(AIListObject *)object 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
   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
	if (!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
   311
		//Update prefs
e22ad6bc8b46 svn 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
		tabbedChatting = [[prefDict objectForKey:KEY_TABBED_CHATTING] boolValue];
e22ad6bc8b46 svn 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
		groupChatsByContactGroup = [[prefDict objectForKey:KEY_GROUP_CHATS_BY_GROUP] boolValue];
e22ad6bc8b46 svn 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
		saveContainers = [[prefDict objectForKey:KEY_SAVE_CONTAINERS] boolValue];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   315
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   316
		if (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
   317
			if (saveContainers) {
e22ad6bc8b46 svn 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
				//Restore saved containers
3310
72ccf4b32d4d Open restored chats in the next run loop.
Zachary West <zacw@adium.im>
parents: 3277
diff changeset
   319
				[self performSelector:@selector(restoreSavedContainers) withObject:nil afterDelay:0.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
   320
			} else if ([prefDict objectForKey:KEY_CONTAINERS]) {
e22ad6bc8b46 svn 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
				/* We've loaded without wanting to save containers; clear any saved
e22ad6bc8b46 svn 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
				 * from a previous session.
e22ad6bc8b46 svn 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
				 */
95
47acbc0cc17a Propertyize AIListObject and convert some more controller accesses to dot syntax
David Smith
parents: 89
diff changeset
   324
				[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
   325
													 forKey:KEY_CONTAINERS
e22ad6bc8b46 svn 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
													  group:PREF_GROUP_INTERFACE];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   327
			}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   328
		}
e22ad6bc8b46 svn 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
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   330
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   331
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   332
//Handle a reopen/dock icon click
e22ad6bc8b46 svn 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
- (BOOL)handleReopenWithVisibleWindows:(BOOL)visibleWindows
e22ad6bc8b46 svn 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
{
e22ad6bc8b46 svn 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
	if (![self contactListIsVisibleAndMain] && [[interfacePlugin openContainerIDs] 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
   336
		//The contact list is not visible, and there are no chat windows. Make the contact list visible.
e22ad6bc8b46 svn 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
		[self showContactList: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
   338
e22ad6bc8b46 svn 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
	} 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
   340
		AIChat	*mostRecentUnviewedChat;
e22ad6bc8b46 svn 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
		//If windows are open, try switching to a chat with unviewed content
95
47acbc0cc17a Propertyize AIListObject and convert some more controller accesses to dot syntax
David Smith
parents: 89
diff changeset
   343
		if ((mostRecentUnviewedChat = [adium.chatController mostRecentUnviewedChat])) {
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
   344
			if ([mostRecentActiveChat unviewedContentCount]) {
e22ad6bc8b46 svn 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
				//If the most recently active chat has unviewed content, ensure it is in the front
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   346
				[self setActiveChat:mostRecentActiveChat];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   347
			} 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
   348
				//Otherwise, switch to the chat which most recently received 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
   349
				[self setActiveChat:mostRecentUnviewedChat];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   350
			}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   351
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   352
		} else {
166
a43b4310ef2a Updated most of our enumerations to fast enumerations, and did some paramaterization.
Evan Schoenberg
parents: 100
diff changeset
   353
			NSWindow *targetWindow = nil;
a43b4310ef2a Updated most of our enumerations to fast enumerations, and did some paramaterization.
Evan Schoenberg
parents: 100
diff changeset
   354
			BOOL	 unMinimizedWindows = 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
   355
			
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   356
			//If there was no unviewed content, ensure that atleast one of Adium's windows is unminimized
166
a43b4310ef2a Updated most of our enumerations to fast enumerations, and did some paramaterization.
Evan Schoenberg
parents: 100
diff changeset
   357
			for (NSWindow *window in [NSApp windows]) {
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
   358
				//Check stylemask to rule out the system menu's window (Which reports itself as visible like a real 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
   359
				if (([window styleMask] & (NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask))) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   360
					if (!targetWindow) targetWindow = 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
   361
					if (![window isMiniaturized]) unMinimizedWindows++;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   362
				}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   363
			}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   364
			
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   365
			//If there are no unminimized windows, unminimize the last 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
   366
			if (unMinimizedWindows == 0 && targetWindow) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   367
				[targetWindow deminiaturize: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
   368
			}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   369
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   370
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   371
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   372
	return 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
   373
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   374
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   375
//Contact List ---------------------------------------------------------------------------------------------------------
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   376
#pragma mark Contact list
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   377
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   378
 * @brief Toggles contact list between visible and hiden
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   379
 */
e22ad6bc8b46 svn 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
- (IBAction)toggleContactList:(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
   381
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   382
    if ([self contactListIsVisibleAndMain]) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   383
		[self closeContactList: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
   384
    } 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
   385
		[[NSApplication sharedApplication] activateIgnoringOtherApps: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
   386
		[self showContactList: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
   387
    } 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   388
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   389
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   390
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   391
 * @brief Brings contact list to the front
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   392
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   393
- (IBAction)showContactList:(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
   394
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   395
	[contactListPlugin showContactListAndBringToFront: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
   396
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   397
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   398
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   399
 * @brief Show the contact list window and bring Adium to the front
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   400
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   401
- (IBAction)showContactListAndBringToFront:(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
   402
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   403
	[contactListPlugin showContactListAndBringToFront: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
   404
	[[NSApplication sharedApplication] activateIgnoringOtherApps: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
   405
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   406
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   407
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   408
 * @brief Close the contact list 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
   409
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   410
- (IBAction)closeContactList:(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
   411
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   412
	[contactListPlugin closeContactList];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   413
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   414
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   415
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   416
 * @returns YES if contact list is visible and selected, otherwise 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
   417
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   418
- (BOOL)contactListIsVisibleAndMain
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   419
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   420
	return [contactListPlugin contactListIsVisibleAndMain];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   421
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   422
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   423
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   424
* @returns YES if contact list is visible, otherwise 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
   425
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   426
- (BOOL)contactListIsVisible
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   427
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   428
	return [contactListPlugin contactListIsVisible];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   429
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   430
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   431
//Detachable Contact List ----------------------------------------------------------------------------------------------
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   432
#pragma mark Detachable Contact List
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   433
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   434
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   435
 * @returns Created contact list controller for detached contact list
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   436
 */
52
54c2435615e8 Add a new subclass of AIListGroup to represent contact lists. The idea here is that contact lists are the only remaining place where we have groups inside groups, and so was forcing us to maintain nested group code in places. Parts of this are a work in progress; for example, with 'show groups' turned off, AIContactList should enforce that only AIListContacts can be added, but doing that will require rewriting how the show groups system works.
David Smith
parents: 3
diff changeset
   437
- (AIListWindowController *)detachContactList:(AIContactList *)aContactList
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
   438
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   439
	return [contactListPlugin detachContactList:aContactList];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   440
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   441
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   442
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   443
#pragma mark Container Saving
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   444
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   445
 * @brief Restores containers saved from a previous session
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   446
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   447
- (void)restoreSavedContainers
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   448
{
95
47acbc0cc17a Propertyize AIListObject and convert some more controller accesses to dot syntax
David Smith
parents: 89
diff changeset
   449
	NSData				*savedData = [adium.preferenceController preferenceForKey:KEY_CONTAINERS
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
   450
																	group:PREF_GROUP_INTERFACE];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   451
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   452
	// If there's no data, we can't restore anything.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   453
	if (!savedData)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   454
		return;
166
a43b4310ef2a Updated most of our enumerations to fast enumerations, and did some paramaterization.
Evan Schoenberg
parents: 100
diff changeset
   455
3462
7d0bea3cf8f4 Small optimization: use delayListObjectNotifications as we restore chats. This provides a tiny speed boost if a bunch of chats are being restored
Evan Schoenberg
parents: 3380
diff changeset
   456
	[[AIContactObserverManager sharedManager] delayListObjectNotifications];
7d0bea3cf8f4 Small optimization: use delayListObjectNotifications as we restore chats. This provides a tiny speed boost if a bunch of chats are being restored
Evan Schoenberg
parents: 3380
diff changeset
   457
166
a43b4310ef2a Updated most of our enumerations to fast enumerations, and did some paramaterization.
Evan Schoenberg
parents: 100
diff changeset
   458
	for (NSDictionary *dict in [NSKeyedUnarchiver unarchiveObjectWithData:savedData]) {
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
   459
		AIMessageWindowController *windowController = [self openContainerWithID:[dict objectForKey:@"ID"]
3310
72ccf4b32d4d Open restored chats in the next run loop.
Zachary West <zacw@adium.im>
parents: 3277
diff changeset
   460
																		   name:[dict objectForKey:@"Name"]];
166
a43b4310ef2a Updated most of our enumerations to fast enumerations, and did some paramaterization.
Evan Schoenberg
parents: 100
diff changeset
   461
		AIChat *containerActiveChat = 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
   462
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   463
		// Position the container where it was last saved (using -savedFrameFromString: to prevent going offscreen)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   464
		[[windowController window] setFrame:[windowController savedFrameFromString:[dict objectForKey:@"Frame"]] display: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
   465
		
166
a43b4310ef2a Updated most of our enumerations to fast enumerations, and did some paramaterization.
Evan Schoenberg
parents: 100
diff changeset
   466
		for (NSDictionary *chatDict in [dict objectForKey:@"Content"]) {
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
			AIChat			*chat = nil;
95
47acbc0cc17a Propertyize AIListObject and convert some more controller accesses to dot syntax
David Smith
parents: 89
diff changeset
   468
			AIService		*service = [adium.accountController firstServiceWithServiceID:[chatDict objectForKey:@"serviceID"]];
47acbc0cc17a Propertyize AIListObject and convert some more controller accesses to dot syntax
David Smith
parents: 89
diff changeset
   469
			AIAccount		*account = [adium.accountController accountWithInternalObjectID:[chatDict objectForKey:@"AccountID"]];
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
   470
					
e22ad6bc8b46 svn 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
			if ([[chatDict objectForKey:@"IsGroupChat"] boolValue]) {
95
47acbc0cc17a Propertyize AIListObject and convert some more controller accesses to dot syntax
David Smith
parents: 89
diff changeset
   472
				chat = [adium.chatController chatWithName:[chatDict objectForKey:@"Name"]
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
   473
												 identifier: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
   474
												  onAccount:account
3893
a56e7a4f0f4f Use "ChatCreationInfo" here instead of "chatCreationInfo", to remain compatible with 1.4 if "Reopen chats from last time" is enabled.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3578
diff changeset
   475
										   chatCreationInfo:[chatDict objectForKey:@"ChatCreationInfo"]];
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
   476
			} else {
89
a9e58c43be6c Propertyize, synthesize, and use fast enumeration in a few places
David Smith
parents: 84
diff changeset
   477
				AIListContact		*contact = [adium.contactController contactWithService:service
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
   478
																					account:account
e22ad6bc8b46 svn 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
																						UID:[chatDict objectForKey:@"UID"]];
e22ad6bc8b46 svn 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
				
95
47acbc0cc17a Propertyize AIListObject and convert some more controller accesses to dot syntax
David Smith
parents: 89
diff changeset
   481
				chat = [adium.chatController chatWithContact:contact];
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
   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
			
e22ad6bc8b46 svn 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
			// Tag the chat as restored.
e22ad6bc8b46 svn 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
			[chat setValue:[NSNumber numberWithBool: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
   486
			   forProperty:@"Restored 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
   487
					notify:NotifyNow];
e22ad6bc8b46 svn 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
			if ([[chatDict objectForKey:@"ActiveChat"] boolValue]) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   490
				containerActiveChat = 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
   491
			}
e22ad6bc8b46 svn 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
					
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   493
			// Open the chat into the container we've created above.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   494
			[self openChat:chat inContainerWithID:[dict objectForKey:@"ID"] atIndex:-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
   495
		}
e22ad6bc8b46 svn 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
		if (containerActiveChat)
e22ad6bc8b46 svn 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
			[self setActiveChat:containerActiveChat];
e22ad6bc8b46 svn 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
	}
3462
7d0bea3cf8f4 Small optimization: use delayListObjectNotifications as we restore chats. This provides a tiny speed boost if a bunch of chats are being restored
Evan Schoenberg
parents: 3380
diff changeset
   500
	
7d0bea3cf8f4 Small optimization: use delayListObjectNotifications as we restore chats. This provides a tiny speed boost if a bunch of chats are being restored
Evan Schoenberg
parents: 3380
diff changeset
   501
	[[AIContactObserverManager sharedManager] endListObjectNotificationsDelay];
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
   502
}
e22ad6bc8b46 svn 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
/*!
e22ad6bc8b46 svn 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
 * @brief Saves open container information with their content when Adium quits
e22ad6bc8b46 svn 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
 */
e22ad6bc8b46 svn 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
- (void)saveContainersOnQuit:(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
   508
{
e22ad6bc8b46 svn 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
	[self saveContainers];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   510
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   511
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   512
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   513
 * @brief Save opened containers and windows
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   514
 *
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   515
 * @param withContent Save the current buffer of the window to restore at a later point
e22ad6bc8b46 svn 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
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   517
- (void)saveContainers
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   518
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   519
	if (!saveContainers) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   520
		// Don't save anything if we're not set to.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   521
		return;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   522
	}
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 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
	// Save active containers.
e22ad6bc8b46 svn 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
	NSMutableArray		*savedContainers = [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
   526
	
166
a43b4310ef2a Updated most of our enumerations to fast enumerations, and did some paramaterization.
Evan Schoenberg
parents: 100
diff changeset
   527
	for (NSDictionary *dict in [interfacePlugin openContainersAndChats]) {
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   528
		NSMutableArray		*containerContents = [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
   529
		
166
a43b4310ef2a Updated most of our enumerations to fast enumerations, and did some paramaterization.
Evan Schoenberg
parents: 100
diff changeset
   530
		for (AIChat *chat in [dict objectForKey:@"Content"]) {
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
   531
			NSMutableDictionary		*newContainerDict = [NSMutableDictionary dictionary];
e22ad6bc8b46 svn 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
428
e10face4301d More dots, now with bonus for(in) action!
David Smith
parents: 426
diff changeset
   533
			[newContainerDict setObject:chat.account.internalObjectID forKey:@"AccountID"];
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
   534
			
e22ad6bc8b46 svn 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
			// Save chat-specific information.
166
a43b4310ef2a Updated most of our enumerations to fast enumerations, and did some paramaterization.
Evan Schoenberg
parents: 100
diff changeset
   536
			if (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
   537
				// -chatCreationDictionary may be nil, so put it last.
e22ad6bc8b46 svn 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
				[newContainerDict addEntriesFromDictionary:[NSDictionary dictionaryWithObjectsAndKeys:
e22ad6bc8b46 svn 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
															[NSNumber numberWithBool:YES], @"IsGroupChat",
e22ad6bc8b46 svn 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
															[NSNumber numberWithBool:([dict objectForKey:@"ActiveChat"] == chat)], @"ActiveChat",
721
7a01f7df42eb Propertyize + build fix
David Smith
parents: 715
diff changeset
   541
															chat.name, @"Name",
3893
a56e7a4f0f4f Use "ChatCreationInfo" here instead of "chatCreationInfo", to remain compatible with 1.4 if "Reopen chats from last time" is enabled.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3578
diff changeset
   542
															[chat chatCreationDictionary], @"ChatCreationInfo",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
   543
			} 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
   544
				[newContainerDict addEntriesFromDictionary:[NSDictionary dictionaryWithObjectsAndKeys:
e22ad6bc8b46 svn 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
															[NSNumber numberWithBool:([dict objectForKey:@"ActiveChat"] == chat)], @"ActiveChat",
426
837e43c8d35d I was hungry and didn't feel like working on hard stuff, so I did a bunch of propertyizing instead.
David Smith
parents: 231
diff changeset
   546
															chat.listObject.UID, @"UID",
715
13cd227e6284 Propertyize a bunch of stuff, and remove some API on AIListObject that was just a passthrough to AIService
David Smith
parents: 594
diff changeset
   547
															chat.account.service.serviceID, @"serviceID",
426
837e43c8d35d I was hungry and didn't feel like working on hard stuff, so I did a bunch of propertyizing instead.
David Smith
parents: 231
diff changeset
   548
															chat.account.internalObjectID, @"AccountID",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
   549
			}
e22ad6bc8b46 svn 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
			[containerContents addObject:newContainerDict];
e22ad6bc8b46 svn 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
		
e22ad6bc8b46 svn 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
		// Replace the "Content" key in -openContainersAndChats with our version of the 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
   555
		// Remove the ActiveChat reference
e22ad6bc8b46 svn 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
		// We use the same keys otherwise that -openContainersAndChats provides (Name, ID, 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
   557
		NSMutableDictionary *saveDict = [[dict 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
   558
e22ad6bc8b46 svn 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
		[saveDict removeObjectForKey:@"ActiveChat"];
e22ad6bc8b46 svn 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
		
e22ad6bc8b46 svn 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
		[saveDict setObject:containerContents
e22ad6bc8b46 svn 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
					 forKey:@"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
   563
		
e22ad6bc8b46 svn 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
		[savedContainers addObject:saveDict];
e22ad6bc8b46 svn 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
	
95
47acbc0cc17a Propertyize AIListObject and convert some more controller accesses to dot syntax
David Smith
parents: 89
diff changeset
   567
	[adium.preferenceController setPreference:[NSKeyedArchiver archivedDataWithRootObject:savedContainers]
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
   568
										 forKey:KEY_CONTAINERS
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   569
										  group:PREF_GROUP_INTERFACE];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   570
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   571
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   572
//Messaging ------------------------------------------------------------------------------------------------------------
e22ad6bc8b46 svn 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
//Methods for instructing the interface to provide a representation of chats, and to determine which chat has user focus
e22ad6bc8b46 svn 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 Messaging
e22ad6bc8b46 svn 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
/*!
e22ad6bc8b46 svn 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
 * @brief Opens window for 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
   578
 */
e22ad6bc8b46 svn 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
- (void)openChat:(AIChat *)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
   580
{
e22ad6bc8b46 svn 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
	NSArray		*containerIDs = [interfacePlugin openContainerIDs];
e22ad6bc8b46 svn 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
	NSString	*containerID = 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
   583
	NSString	*containerName = 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
   584
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   585
	//Determine the correct container for this 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
   586
	
e22ad6bc8b46 svn 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
	if (!tabbedChatting) {
e22ad6bc8b46 svn 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
		//We're not using tabs; each chat starts in its own container, based on the destination object or the chat name
e22ad6bc8b46 svn 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
		if ([inChat listObject]) {
426
837e43c8d35d I was hungry and didn't feel like working on hard stuff, so I did a bunch of propertyizing instead.
David Smith
parents: 231
diff changeset
   590
			containerID = inChat.listObject.internalObjectID;
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
   591
		} else {
426
837e43c8d35d I was hungry and didn't feel like working on hard stuff, so I did a bunch of propertyizing instead.
David Smith
parents: 231
diff changeset
   592
			containerID = inChat.name;
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
   593
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   594
		
e22ad6bc8b46 svn 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
	} else if (groupChatsByContactGroup) {
426
837e43c8d35d I was hungry and didn't feel like working on hard stuff, so I did a bunch of propertyizing instead.
David Smith
parents: 231
diff changeset
   596
		if (inChat.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
   597
			containerID = AILocalizedString(@"Group Chats",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
   598
			
e22ad6bc8b46 svn 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
		} else {
594
c4751f3845b9 A bunch more contacts in multiple groups stuff. Also the offline group should work again
David Smith
parents: 428
diff changeset
   600
			//XXX multiple containers: this is "correct" but maybe not desirable, as it is non-deterministic
c4751f3845b9 A bunch more contacts in multiple groups stuff. Also the offline group should work again
David Smith
parents: 428
diff changeset
   601
			AIListGroup	*group = inChat.listObject.parentContact.groups.anyObject;
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
   602
			
e22ad6bc8b46 svn 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
			//If the contact is in the contact list root, we don't have a group
52
54c2435615e8 Add a new subclass of AIListGroup to represent contact lists. The idea here is that contact lists are the only remaining place where we have groups inside groups, and so was forcing us to maintain nested group code in places. Parts of this are a work in progress; for example, with 'show groups' turned off, AIContactList should enforce that only AIListContacts can be added, but doing that will require rewriting how the show groups system works.
David Smith
parents: 3
diff changeset
   604
			if (group && ![group isKindOfClass:[AIContactList class]]) {
426
837e43c8d35d I was hungry and didn't feel like working on hard stuff, so I did a bunch of propertyizing instead.
David Smith
parents: 231
diff changeset
   605
				containerID = group.displayName;
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   606
			}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   607
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   608
		
e22ad6bc8b46 svn 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
		containerName = containerID;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   610
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   611
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   612
	if (!containerID) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   613
		//Open new chats into the first container (if not available, create a new 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
   614
		if ([containerIDs 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
   615
			containerID = [containerIDs objectAtIndex: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
   616
		} 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
   617
			containerID = 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
   618
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   619
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   620
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   621
	//Determine the correct placement for this chat within the container
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   622
	[interfacePlugin openChat:inChat inContainerWithID:containerID withName:containerName atIndex:-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
   623
	if (![inChat isOpen]) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   624
		[inChat setIsOpen: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
   625
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   626
		//Post the notification last, so observers receive a chat whose isOpen flag is yes.
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: 1061
diff changeset
   627
		[[NSNotificationCenter defaultCenter] postNotificationName:Chat_DidOpen object:inChat userInfo: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
   628
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   629
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   630
3088
86d1432abf47 Remove shadowing varibles in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3087
diff changeset
   631
- (id)openChat:(AIChat *)inChat inContainerWithID:(NSString *)containerID atIndex:(NSUInteger)idx
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   632
{	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   633
	NSArray		*openContainerIDs = [interfacePlugin openContainerIDs];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   634
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   635
	if (!containerID) {
e22ad6bc8b46 svn 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
		//Open new chats into the first container (if not available, create a new 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
   637
		if ([openContainerIDs 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
   638
			containerID = [openContainerIDs objectAtIndex: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
   639
		} 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
   640
			containerID = AILocalizedString(@"Chats",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
   641
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   642
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   643
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   644
	//Determine the correct placement for this chat within the container
3088
86d1432abf47 Remove shadowing varibles in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3087
diff changeset
   645
	id tabViewItem = [interfacePlugin openChat:inChat inContainerWithID:containerID withName:nil atIndex:idx];
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
   646
	if (![inChat isOpen]) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   647
		[inChat setIsOpen: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
   648
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   649
		//Post the notification last, so observers receive a chat whose isOpen flag is yes.
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: 1061
diff changeset
   650
		[[NSNotificationCenter defaultCenter] postNotificationName:Chat_DidOpen object:inChat userInfo: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
   651
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   652
	return tabViewItem;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   653
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   654
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   655
/**
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   656
 * @brief Opens a container with a specific ID
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   657
 *
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   658
 * Asks the interfacePlugin to openContainerWithID:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   659
 */
e22ad6bc8b46 svn 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
- (AIMessageWindowController *)openContainerWithID:(NSString *)containerID name:(NSString *)containerName
e22ad6bc8b46 svn 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
	return [interfacePlugin openContainerWithID:containerID name:containerName];
e22ad6bc8b46 svn 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
}
e22ad6bc8b46 svn 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
/*!
e22ad6bc8b46 svn 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
 * @brief Close the interface for a 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
   667
 *
e22ad6bc8b46 svn 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
 * Tell the interface plugin to close 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
   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
- (void)closeChat:(AIChat *)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
   671
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   672
	if (inChat) {
95
47acbc0cc17a Propertyize AIListObject and convert some more controller accesses to dot syntax
David Smith
parents: 89
diff changeset
   673
		if ([adium.chatController closeChat:inChat]) {
3277
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   674
			
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   675
			NSMutableDictionary *newRecentlyClosedChat = [NSMutableDictionary dictionary];
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   676
			
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   677
			[newRecentlyClosedChat setObject:inChat.account.internalObjectID forKey:@"AccountID"];
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   678
			
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   679
			if (inChat.isGroupChat) {
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   680
				// -chatCreationDictionary may be nil, so put it last.
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   681
				[newRecentlyClosedChat addEntriesFromDictionary:[NSDictionary dictionaryWithObjectsAndKeys:
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   682
																 [NSNumber numberWithBool:YES], @"IsGroupChat",
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   683
																 inChat.name, @"Name",
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   684
																 [inChat chatCreationDictionary], @"ChatCreationInfo",nil]];
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   685
			} else {
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   686
				[newRecentlyClosedChat addEntriesFromDictionary:[NSDictionary dictionaryWithObjectsAndKeys:
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   687
																 inChat.listObject.UID, @"UID",
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   688
																 inChat.account.service.serviceID, @"serviceID",
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   689
																 inChat.account.internalObjectID, @"AccountID",nil]];
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   690
			}
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   691
			
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   692
			[recentlyClosedChats insertObject:newRecentlyClosedChat atIndex:0];
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   693
			
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   694
			// this sounds like a sensible limit: no-one will remember what chat they had in the closed tab beyond these
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   695
			while (recentlyClosedChats.count > 16) {
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   696
				[recentlyClosedChats removeLastObject];
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   697
			}
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   698
			
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
   699
			[interfacePlugin closeChat: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
   700
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   701
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   702
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   703
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   704
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   705
 * @brief Consolidate chats into a single container
e22ad6bc8b46 svn 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
 */
e22ad6bc8b46 svn 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
- (void)consolidateChats
e22ad6bc8b46 svn 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
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   709
	//We work with copies of these arrays, since moving chats may change their contents
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   710
	NSArray			*openContainerIDs = [[interfacePlugin openContainerIDs] 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
   711
	NSEnumerator	*containerEnumerator = [openContainerIDs objectEnumerator];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   712
	NSString		*firstContainerID = [containerEnumerator nextObject];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   713
	NSString		*containerID;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   714
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   715
	//For all containers but the first, move the chats they contain to the first container
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   716
	while ((containerID = [containerEnumerator nextObject])) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   717
		NSArray			*openChats = [[interfacePlugin openChatsInContainerWithID:containerID] copy];
4897
5ea3bd51010d I messed up with branching adium-1.5.3. I should've branched it from adium-1.5.2, but used default. This meant many extra changes (new preferences, etc.) got in unintentionally.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 4790
diff changeset
   718
		NSEnumerator	*chatEnumerator = [openChats objectEnumerator];
5ea3bd51010d I messed up with branching adium-1.5.3. I should've branched it from adium-1.5.2, but used default. This meant many extra changes (new preferences, etc.) got in unintentionally.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 4790
diff changeset
   719
		AIChat			*chat;
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   720
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   721
		//Move all the chats, providing a target index if chat sorting is enabled
4897
5ea3bd51010d I messed up with branching adium-1.5.3. I should've branched it from adium-1.5.2, but used default. This meant many extra changes (new preferences, etc.) got in unintentionally.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 4790
diff changeset
   722
		while ((chat = [chatEnumerator nextObject])) {
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
   723
			[interfacePlugin moveChat: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
   724
					toContainerWithID:firstContainerID
3092
ffb42621b742 Resolving most* undeclared selectors in Adium.app.
Stephen Holt <sholt@adium.im>
parents: 3088
diff changeset
   725
								index:-1];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   726
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   727
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   728
		[openChats 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
   729
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   730
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   731
	[self chatOrderDidChange];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   732
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   733
	[openContainerIDs 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
   734
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   735
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   736
- (void)moveChatToNewContainer:(AIChat *)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
   737
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   738
	[interfacePlugin moveChatToNewContainer: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
   739
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   740
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   741
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   742
 * @returns Active 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
   743
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   744
- (AIChat *)activeChat
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   745
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   746
	return activeChat;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   747
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   748
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   749
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   750
 * @brief Set the active chat 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
   751
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   752
- (void)setActiveChat:(AIChat *)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
   753
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   754
	[interfacePlugin setActiveChat: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
   755
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   756
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   757
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   758
 * @returns Last chat to be active, nil if not chat is open
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   759
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   760
- (AIChat *)mostRecentActiveChat
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   761
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   762
	return mostRecentActiveChat;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   763
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   764
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   765
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   766
 * @brief Sets active chat window based on 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
   767
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   768
- (void)setMostRecentActiveChat:(AIChat *)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
   769
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   770
	[self setActiveChat: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
   771
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   772
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   773
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   774
 * @returns Array of open chats (cached, so call as frequently as desired)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   775
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   776
- (NSArray *)openChats
e22ad6bc8b46 svn 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
{
e22ad6bc8b46 svn 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
	if (!_cachedOpenChats) {
e22ad6bc8b46 svn 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
		_cachedOpenChats = [[interfacePlugin openChats] 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
   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
	
e22ad6bc8b46 svn 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
	return _cachedOpenChats;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   783
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   784
e22ad6bc8b46 svn 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
- (NSArray *)openContainerIDs
e22ad6bc8b46 svn 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
{
e22ad6bc8b46 svn 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
	return [interfacePlugin openContainerIDs];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   788
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   789
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   790
/*!
e22ad6bc8b46 svn 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
 * @param containerID ID for chat 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
   792
 *
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   793
 * @returns Array of all chats in chat 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
   794
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   795
- (NSArray *)openChatsInContainerWithID:(NSString *)containerID
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   796
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   797
	return [interfacePlugin openChatsInContainerWithID:containerID];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   798
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   799
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   800
/*!
2914
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
   801
 * @brief The container ID for a chat
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
   802
 *
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
   803
 * @param chat The chat to look up
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
   804
 * @returns The container ID for the container the chat is in.
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
   805
 */
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
   806
- (NSString *)containerIDForChat:(AIChat *)chat
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
   807
{
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
   808
	return [interfacePlugin containerIDForChat:chat];
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
   809
}
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
   810
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
   811
/*!
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
   812
 * @brief Resets the cache of open chats
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   813
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   814
- (void)_resetOpenChatsCache
e22ad6bc8b46 svn 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
{
e22ad6bc8b46 svn 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
	[_cachedOpenChats release]; _cachedOpenChats = 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
   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
3277
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   819
- (IBAction)reopenChat:(id)sender
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   820
{
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   821
	if (recentlyClosedChats.count == 0) {
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   822
		AILogWithSignature(@"Can't open recently closed tab: no recently closed tabs!");
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   823
		return;
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   824
	}
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   825
	
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   826
	NSDictionary *chatDict = [[[recentlyClosedChats objectAtIndex:0] retain] autorelease];
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   827
	[recentlyClosedChats removeObjectAtIndex:0];
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   828
	
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   829
	AIChat			*chat = nil;
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   830
	AIService		*service = [adium.accountController firstServiceWithServiceID:[chatDict objectForKey:@"serviceID"]];
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   831
	AIAccount		*account = [adium.accountController accountWithInternalObjectID:[chatDict objectForKey:@"AccountID"]];
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   832
	
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   833
	if ([[chatDict objectForKey:@"IsGroupChat"] boolValue]) {
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   834
		chat = [adium.chatController chatWithName:[chatDict objectForKey:@"Name"]
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   835
									   identifier:nil
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   836
										onAccount:account
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   837
								 chatCreationInfo:[chatDict objectForKey:@"ChatCreationInfo"]];
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   838
	} else {
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   839
		AIListContact *contact = [adium.contactController contactWithService:service
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   840
																	 account:account
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   841
																		 UID:[chatDict objectForKey:@"UID"]];
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   842
		
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   843
		if (contact) chat = [adium.chatController chatWithContact:contact];
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   844
	}
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   845
	
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   846
	if (!chat) {
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   847
		NSRunAlertPanel(AILocalizedString(@"Restoring chat failed", nil),
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   848
						AILocalizedString(@"Restoring the last closed tab failed. Perhaps the account not exist anymore?", nil),
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   849
						AILocalizedString(@"OK", nil),
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   850
						nil,
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   851
						nil);
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   852
		return;
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   853
	}
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   854
	
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   855
	// Tag the chat as restored.
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   856
	[chat setValue:[NSNumber numberWithBool:YES]
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   857
	   forProperty:@"Restored Chat"
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   858
			notify:NotifyNow];
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   859
	
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   860
	[self openChat:chat inContainerWithID:nil atIndex:-1];
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   861
	[self setActiveChat:chat];
21ab21e877e0 Add a Reopen Closed Tab menu item to the File menu that will restore the most recently closed tab, similar to Chrome. Fixes #12537
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3092
diff changeset
   862
}
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
   863
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   864
e22ad6bc8b46 svn 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
//Interface plugin callbacks -------------------------------------------------------------------------------------------
e22ad6bc8b46 svn 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
//These methods are called by the interface to let us know what's going on.  We're informed of chats opening, closing,
e22ad6bc8b46 svn 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
//changing order, etc.
e22ad6bc8b46 svn 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
#pragma mark Interface plugin callbacks
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   869
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   870
 * @brief A chat window did open: rebuild our window menu to show the new 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
   871
 *
e22ad6bc8b46 svn 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
 * This should be called by the interface plugin (e.g. AIDualWindowInterfacePlugin) after a chat opens
e22ad6bc8b46 svn 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
 *
e22ad6bc8b46 svn 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
 * @param inChat Newly created 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
   875
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   876
- (void)chatDidOpen:(AIChat *)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
   877
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   878
	[self _resetOpenChatsCache];
e22ad6bc8b46 svn 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
	[self buildWindowMenu];
e22ad6bc8b46 svn 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
	[self saveContainers];
e22ad6bc8b46 svn 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
/*!
e22ad6bc8b46 svn 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
 * @brief A chat has become active: update our chat closing keys and flag this chat as selected in the window menu
e22ad6bc8b46 svn 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
 *
e22ad6bc8b46 svn 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
 * @param inChat Chat which has become active
e22ad6bc8b46 svn 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
 */
e22ad6bc8b46 svn 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
- (void)chatDidBecomeActive:(AIChat *)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
   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
	AIChat	*previouslyActiveChat = activeChat;
e22ad6bc8b46 svn 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
	
e22ad6bc8b46 svn 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
	activeChat = [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
   893
	
e22ad6bc8b46 svn 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
	[self updateCloseMenuKeys];
e22ad6bc8b46 svn 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
	[self updateActiveWindowMenuItem];
e22ad6bc8b46 svn 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
	
e22ad6bc8b46 svn 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
	if (inChat && (inChat != mostRecentActiveChat)) {
e22ad6bc8b46 svn 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
		[mostRecentActiveChat release]; mostRecentActiveChat = 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
   899
		mostRecentActiveChat = [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
   900
	}
e22ad6bc8b46 svn 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
	
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: 1061
diff changeset
   902
	[[NSNotificationCenter defaultCenter] postNotificationName:Chat_BecameActive
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
   903
											  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
   904
											userInfo:(previouslyActiveChat ?
e22ad6bc8b46 svn 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
													  [NSDictionary dictionaryWithObject:previouslyActiveChat
e22ad6bc8b46 svn 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
																				  forKey:@"PreviouslyActiveChat"] :
e22ad6bc8b46 svn 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
													  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
   908
	
e22ad6bc8b46 svn 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
	if (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
   910
		/* Clear the unviewed content on the next event loop so other methods have a chance to react to the chat becoming
e22ad6bc8b46 svn 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
		* active. Specifically, this lets the handleReopenWithVisibleWindows: method have a chance to know that this 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
   912
		* had unviewed 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
   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
		[inChat performSelector:@selector(clearUnviewedContentCount)
e22ad6bc8b46 svn 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
					 withObject: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
   916
					 afterDelay: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
	}
e22ad6bc8b46 svn 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
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   919
	[previouslyActiveChat 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
   920
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   921
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   922
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   923
 * @brief A chat has become visible: send out a notification for components and plugins to take 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
   924
 *
e22ad6bc8b46 svn 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
 * @param inChat Chat that has become active
e22ad6bc8b46 svn 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
 * @param nWindow Containing chat 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
   927
 */
e22ad6bc8b46 svn 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
- (void)chatDidBecomeVisible:(AIChat *)inChat inWindow:(NSWindow *)inWindow
e22ad6bc8b46 svn 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
{
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: 1061
diff changeset
   930
	[[NSNotificationCenter defaultCenter] postNotificationName:@"AIChatDidBecomeVisible"
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
   931
											  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
   932
											userInfo:[NSDictionary dictionaryWithObject:inWindow
e22ad6bc8b46 svn 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
																				 forKey:@"NSWindow"]];
e22ad6bc8b46 svn 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
}
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 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
/*!
e22ad6bc8b46 svn 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
 * @brief Find the window currently displaying a 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
   938
 *
e22ad6bc8b46 svn 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
 * @returns Window for chat otherwise if the chat is not in any window, or is not visible in any window, returns 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
   940
 */
e22ad6bc8b46 svn 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
- (NSWindow *)windowForChat:(AIChat *)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
   942
{
e22ad6bc8b46 svn 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
	return [interfacePlugin windowForChat: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
   944
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   945
e22ad6bc8b46 svn 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
/*!
e22ad6bc8b46 svn 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
 * @brief Find the chat active in a 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
   948
 *
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   949
 * If the window does not have an active chat, nil is returned
e22ad6bc8b46 svn 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
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   951
- (AIChat *)activeChatInWindow:(NSWindow *)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
   952
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   953
	return [interfacePlugin activeChatInWindow: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
   954
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   955
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   956
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   957
 * @brief A chat window did close: rebuild our window menu to remove 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
   958
 * 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   959
 * @param inChat Chat that closed
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   960
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   961
- (void)chatDidClose:(AIChat *)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
   962
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   963
	[self _resetOpenChatsCache];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   964
	[inChat clearUnviewedContentCount];
e22ad6bc8b46 svn 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
	[self buildWindowMenu];
e22ad6bc8b46 svn 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
	
426
837e43c8d35d I was hungry and didn't feel like working on hard stuff, so I did a bunch of propertyizing instead.
David Smith
parents: 231
diff changeset
   967
	if (!adium.isQuitting) {
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
   968
		// Don't save containers when the chats are closed while quitting
e22ad6bc8b46 svn 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
		[self saveContainers];
e22ad6bc8b46 svn 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
	}
e22ad6bc8b46 svn 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
	
e22ad6bc8b46 svn 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
	if (inChat == activeChat) {
e22ad6bc8b46 svn 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
		[activeChat release]; activeChat = 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
   974
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   975
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   976
	if (inChat == mostRecentActiveChat) {
e22ad6bc8b46 svn 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
		[mostRecentActiveChat release]; mostRecentActiveChat = 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
   978
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   979
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   980
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   981
/*!
e22ad6bc8b46 svn 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
 * @brief The order of chats has changed: rebuild our window menu to reflect the new order
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   983
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   984
- (void)chatOrderDidChange
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   985
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   986
	[self _resetOpenChatsCache];
e22ad6bc8b46 svn 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
	[self buildWindowMenu];
e22ad6bc8b46 svn 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
426
837e43c8d35d I was hungry and didn't feel like working on hard stuff, so I did a bunch of propertyizing instead.
David Smith
parents: 231
diff changeset
   989
	if (!adium.isQuitting) {
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
   990
		// Don't save containers when the chats are closed while quitting
e22ad6bc8b46 svn 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
		[self saveContainers];
e22ad6bc8b46 svn 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
	}
e22ad6bc8b46 svn 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
	
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: 1061
diff changeset
   994
	[[NSNotificationCenter defaultCenter] postNotificationName:Chat_OrderDidChange object:nil userInfo: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
   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
}
e22ad6bc8b46 svn 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
#pragma mark Unviewed 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
   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
/*!
e22ad6bc8b46 svn 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
 * @breif Content was received, increase the unviewed content count of the chat (if it's not currently active)
e22ad6bc8b46 svn 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
 */
e22ad6bc8b46 svn 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
- (void)didReceiveContent:(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
  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
	AIChat		*chat = [[notification userInfo] objectForKey:@"AIChat"];
e22ad6bc8b46 svn 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
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1007
	if (chat != activeChat) {
e22ad6bc8b46 svn 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
		[chat incrementUnviewedContentCount];
e22ad6bc8b46 svn 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
}
e22ad6bc8b46 svn 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
e22ad6bc8b46 svn 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
//Chat close 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
  1014
#pragma mark Chat close 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
  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
/*!
e22ad6bc8b46 svn 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
 * @brief Closes currently active 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
  1018
 */
e22ad6bc8b46 svn 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
- (IBAction)closeMenu:(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
  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
    [[[NSApplication sharedApplication] keyWindow] performClose: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
  1022
}
e22ad6bc8b46 svn 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
/*!
e22ad6bc8b46 svn 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
 * @brief Closes currently active chat (if there is an active 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
  1026
 */
e22ad6bc8b46 svn 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
- (IBAction)closeChatMenu:(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
  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
	if (activeChat) [self closeChat:activeChat];
e22ad6bc8b46 svn 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
}
e22ad6bc8b46 svn 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
/*!
e22ad6bc8b46 svn 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
 * @brief Closes currently selected chat based on current chat contextual menu
e22ad6bc8b46 svn 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
 */
e22ad6bc8b46 svn 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
- (IBAction)closeContextualChat:(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
  1036
{
100
68210ab2807a sed is evil. All [adium *Controller]s are now adium.*Controller.
David Smith
parents: 95
diff changeset
  1037
	[self closeChat:[adium.menuController currentContextMenuChat]];
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
  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
e22ad6bc8b46 svn 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
 * @brief Loop through open chats and close them
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1042
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1043
- (IBAction)closeAllChats:(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
  1044
{
426
837e43c8d35d I was hungry and didn't feel like working on hard stuff, so I did a bunch of propertyizing instead.
David Smith
parents: 231
diff changeset
  1045
	for (AIChat *chatToClose in [[interfacePlugin.openChats copy] 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
  1046
		[self closeChat:chatToClose];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1047
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1048
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1049
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1050
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1051
 * @brief Updates the key equivalents on 'close' and 'close chat' (dynamically changed to make cmd-w less destructive)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1052
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1053
- (void)updateCloseMenuKeys
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1054
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1055
	if (activeChat && !closeMenuConfiguredForChat) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1056
        [menuItem_close setKeyEquivalent:@"W"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1057
        [menuItem_closeChat setKeyEquivalent:@"w"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1058
		closeMenuConfiguredForChat = 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
  1059
	} else if (!activeChat && closeMenuConfiguredForChat) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1060
        [menuItem_close setKeyEquivalent:@"w"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1061
		[menuItem_closeChat removeKeyEquivalent];		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1062
		closeMenuConfiguredForChat = 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
  1063
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1064
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1065
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1066
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1067
//Window Menu ----------------------------------------------------------------------------------------------------------
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1068
#pragma mark Window Menu
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1069
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1070
/*!
1260
e1e0ac181ad3 Only kill off the auth requests window if it doesn't have any pending responses. Add a menu item to the file transfer / log viewer area in the Window menu which opens the auth request window.
Zachary West <zacw@adiumx.com>
parents: 1244
diff changeset
  1071
 * @brief Open the authorization requests window.
e1e0ac181ad3 Only kill off the auth requests window if it doesn't have any pending responses. Add a menu item to the file transfer / log viewer area in the Window menu which opens the auth request window.
Zachary West <zacw@adiumx.com>
parents: 1244
diff changeset
  1072
 */
e1e0ac181ad3 Only kill off the auth requests window if it doesn't have any pending responses. Add a menu item to the file transfer / log viewer area in the Window menu which opens the auth request window.
Zachary West <zacw@adiumx.com>
parents: 1244
diff changeset
  1073
- (void)openAuthorizationWindow:(id)sender
e1e0ac181ad3 Only kill off the auth requests window if it doesn't have any pending responses. Add a menu item to the file transfer / log viewer area in the Window menu which opens the auth request window.
Zachary West <zacw@adiumx.com>
parents: 1244
diff changeset
  1074
{
e1e0ac181ad3 Only kill off the auth requests window if it doesn't have any pending responses. Add a menu item to the file transfer / log viewer area in the Window menu which opens the auth request window.
Zachary West <zacw@adiumx.com>
parents: 1244
diff changeset
  1075
	[[AIAuthorizationRequestsWindowController sharedController] showWindow:nil];
e1e0ac181ad3 Only kill off the auth requests window if it doesn't have any pending responses. Add a menu item to the file transfer / log viewer area in the Window menu which opens the auth request window.
Zachary West <zacw@adiumx.com>
parents: 1244
diff changeset
  1076
}
e1e0ac181ad3 Only kill off the auth requests window if it doesn't have any pending responses. Add a menu item to the file transfer / log viewer area in the Window menu which opens the auth request window.
Zachary West <zacw@adiumx.com>
parents: 1244
diff changeset
  1077
e1e0ac181ad3 Only kill off the auth requests window if it doesn't have any pending responses. Add a menu item to the file transfer / log viewer area in the Window menu which opens the auth request window.
Zachary West <zacw@adiumx.com>
parents: 1244
diff changeset
  1078
/*!
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
  1079
 * @brief Make a chat window active
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1080
 * 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1081
 * Invoked by a selection in the window menu
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1082
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1083
- (IBAction)showChatWindow:(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
  1084
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1085
	[self setActiveChat:[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
  1086
    [[NSApplication sharedApplication] activateIgnoringOtherApps: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
  1087
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1088
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1089
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1090
 * @brief Updates the 'check' icon so it's next to the active 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
  1091
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1092
- (void)updateActiveWindowMenuItem
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1093
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1094
    NSMenuItem		*item;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1095
76
dc34164c3439 A few more, including AIContactController now
David Smith
parents: 69
diff changeset
  1096
    for (item in windowMenuArray) {
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
  1097
		if ([item representedObject]) [item setState:([item representedObject] == activeChat ? NSOnState : NSOffState)];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1098
    }
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1099
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1100
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1101
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1102
 * @brief Builds the window menu
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1103
 * 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1104
 * This function gets called whenever chats are opened, closed, or re-ordered - so improvements and optimizations here
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1105
 * would probably be helpful
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1106
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1107
- (void)buildWindowMenu
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1108
{	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1109
    NSMenuItem				*item;
3
f0cc4d307eb8 Merge 64 bit branch to trunk. Fingers crossed, and I have been testing it some, but expect fallout from this. 11,000 line diffs are rarely without consequence ;)
David Smith
parents: 0
diff changeset
  1110
    NSInteger						windowKey = 1;
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1111
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1112
    //Remove any existing menus
76
dc34164c3439 A few more, including AIContactController now
David Smith
parents: 69
diff changeset
  1113
    for (item in windowMenuArray) {
100
68210ab2807a sed is evil. All [adium *Controller]s are now adium.*Controller.
David Smith
parents: 95
diff changeset
  1114
        [adium.menuController removeMenuItem:item];
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
  1115
    }
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1116
    [windowMenuArray release]; windowMenuArray = [[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
  1117
	
166
a43b4310ef2a Updated most of our enumerations to fast enumerations, and did some paramaterization.
Evan Schoenberg
parents: 100
diff changeset
  1118
    //Messages window and any open messasges	
a43b4310ef2a Updated most of our enumerations to fast enumerations, and did some paramaterization.
Evan Schoenberg
parents: 100
diff changeset
  1119
	for (NSDictionary *containerDict in [interfacePlugin openContainersAndChats]) {
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
  1120
		NSString		*containerName = [containerDict objectForKey:@"Name"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1121
		NSArray			*contentArray = [containerDict objectForKey:@"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
  1122
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1123
		//Add a menu item for the container
166
a43b4310ef2a Updated most of our enumerations to fast enumerations, and did some paramaterization.
Evan Schoenberg
parents: 100
diff changeset
  1124
		if (contentArray.count > 1) {
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1125
			item = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:([containerName length] ? containerName : AILocalizedString(@"Chats", 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
  1126
																		target: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
  1127
																		action: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
  1128
																 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
  1129
			[self _addItemToMainMenuAndDock:item];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1130
			[item 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
  1131
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1132
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1133
		//Add items for the chats it contains
166
a43b4310ef2a Updated most of our enumerations to fast enumerations, and did some paramaterization.
Evan Schoenberg
parents: 100
diff changeset
  1134
		for (AIChat *chat in [contentArray objectEnumerator]) {
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
  1135
			NSString		*windowKeyString;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1136
			
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1137
			//Prepare a key equivalent for the controller
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1138
			if (windowKey < 10) {
166
a43b4310ef2a Updated most of our enumerations to fast enumerations, and did some paramaterization.
Evan Schoenberg
parents: 100
diff changeset
  1139
				windowKeyString = [NSString stringWithFormat:@"%ld", (windowKey)];
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
  1140
			} else if (windowKey == 10) {
4754
799391dbde28 "Using 'stringWithString:' with a literal is redundant"
Frank Dowsett <wixardy@adium.im>
parents: 4676
diff changeset
  1141
				windowKeyString = @"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
  1142
			} else {
4754
799391dbde28 "Using 'stringWithString:' with a literal is redundant"
Frank Dowsett <wixardy@adium.im>
parents: 4676
diff changeset
  1143
				windowKeyString = @"";
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
  1144
			}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1145
			
166
a43b4310ef2a Updated most of our enumerations to fast enumerations, and did some paramaterization.
Evan Schoenberg
parents: 100
diff changeset
  1146
			item = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:chat.displayName
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1147
																		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
  1148
																		action:@selector(showChatWindow:)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1149
																 keyEquivalent:windowKeyString];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1150
			if ([contentArray count] > 1) [item setIndentationLevel: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
  1151
			[item setRepresentedObject:chat];
166
a43b4310ef2a Updated most of our enumerations to fast enumerations, and did some paramaterization.
Evan Schoenberg
parents: 100
diff changeset
  1152
			[item setImage:chat.chatMenuImage];
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
  1153
			[self _addItemToMainMenuAndDock:item];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1154
			[item 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
  1155
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1156
			windowKey++;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1157
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1158
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1159
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1160
	[self updateActiveWindowMenuItem];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1161
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1162
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1163
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1164
 * brief Adds a menu item to the internal array, dock menu, and main menu
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1165
 *
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1166
 * Should be used for adding a new window to the window menu (and dock menu)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1167
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1168
- (void)_addItemToMainMenuAndDock:(NSMenuItem *)item
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1169
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1170
	//Add to main menu first
100
68210ab2807a sed is evil. All [adium *Controller]s are now adium.*Controller.
David Smith
parents: 95
diff changeset
  1171
	[adium.menuController addMenuItem:item toLocation:LOC_Window_Fixed];
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
  1172
	[windowMenuArray addObject:item];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1173
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1174
	//Make a copy, and add to the dock
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1175
	item = [item 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
  1176
	[item setKeyEquivalent:@""];
100
68210ab2807a sed is evil. All [adium *Controller]s are now adium.*Controller.
David Smith
parents: 95
diff changeset
  1177
	[adium.menuController addMenuItem:item toLocation:LOC_Dock_Status];
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
  1178
	[windowMenuArray addObject:item];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1179
	[item 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
  1180
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1181
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1182
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1183
//Chat Cycling ---------------------------------------------------------------------------------------------------------
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1184
#pragma mark Chat Cycling
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1185
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1186
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1187
 * @brief Cycles to the next active 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
  1188
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1189
- (void)nextChat:(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
  1190
{
2914
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
  1191
	if (!activeChat) return;
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
  1192
	
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
  1193
	NSString *containerID = [self containerIDForChat:activeChat];
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
  1194
	NSArray *chats = [self openChatsInContainerWithID:containerID];
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
  1195
2914
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
  1196
	NSInteger nextChat = [chats indexOfObject:activeChat] + 1;
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
  1197
	
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
  1198
	if (nextChat >= chats.count)
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
  1199
		nextChat = 0;
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
  1200
	
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
  1201
	[self setActiveChat:[chats objectAtIndex:nextChat]];
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
  1202
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1203
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1204
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1205
 * @brief Cycles to the previus active 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
  1206
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1207
- (void)previousChat:(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
  1208
{
2914
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
  1209
	if (!activeChat) 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
  1210
	
2914
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
  1211
	NSString *containerID = [self containerIDForChat:activeChat];
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
  1212
	NSArray *chats = [self openChatsInContainerWithID:containerID];
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
  1213
	
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
  1214
	NSInteger nextChat = [chats indexOfObject:activeChat] - 1;
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
  1215
	
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
  1216
	if (nextChat < 0)
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
  1217
		nextChat = chats.count - 1;
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
  1218
	
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 2874
diff changeset
  1219
	[self setActiveChat:[chats objectAtIndex:nextChat]];