Merged [13632]: Patch from Gayle Laakmann to not append @gmail.com if @googlemail...
[adiumx.git] / Source / AIInterfaceController.h
blob50910c068d31ac7f48d37b62c38d0e3d59d3e915
1 /*
2 * Adium is the legal property of its developers, whose names are listed in the copyright file included
3 * with this source distribution.
4 *
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6 * General Public License as published by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
10 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11 * Public License for more details.
13 * You should have received a copy of the GNU General Public License along with this program; if not,
14 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 #define Interface_ContactSelectionChanged @"Interface_ContactSelectionChanged"
18 #define Interface_SendEnteredMessage @"Interface_SendEnteredMessage"
19 #define Interface_WillSendEnteredMessage @"Interface_WillSendEnteredMessage"
20 #define Interface_DidSendEnteredMessage @"Interface_DidSendEnteredMessage"
21 #define Interface_ShouldClearTextEntryView @"Interface_ShouldClearTextEntryView"
22 #define Interface_ShouldDisplayErrorMessage @"Interface_ShouldDisplayErrorMessage"
23 #define Interface_ContactListDidBecomeMain @"Interface_ContactListDidBecomeMain"
24 #define Interface_ContactListDidResignMain @"Interface_contactListDidResignMain"
25 #define Interface_ContactListDidClose @"Interface_contactListDidClose"
26 #define Interface_TabArrangingPreferenceChanged @"Interface_TabArrangingPreferenceChanged"
27 #define AIViewDesiredSizeDidChangeNotification @"AIViewDesiredSizeDidChangeNotification"
29 #define PREF_GROUP_INTERFACE @"Interface"
30 #define KEY_TABBED_CHATTING @"Tabbed Chatting"
31 #define KEY_SORT_CHATS @"Sort Chats"
32 #define KEY_GROUP_CHATS_BY_GROUP @"Group Chats By Group"
34 #define PREF_GROUP_CONTACT_LIST @"Contact List"
35 #define KEY_CL_WINDOW_LEVEL @"Window Level"
36 #define KEY_CL_HIDE @"Hide While in Background"
37 #define KEY_CL_FLASH_UNVIEWED_CONTENT @"Flash Unviewed Content"
38 #define KEY_CL_SHOW_TRANSITIONS @"Show Transitions"
39 #define KEY_CL_SHOW_TOOLTIPS @"Show Tooltips"
40 #define KEY_CL_SHOW_TOOLTIPS_IN_BACKGROUND @"Show Tooltips in Background"
41 #define KEY_CL_WINDOW_HAS_SHADOW @"Window Has Shadow"
43 #define CONTACT_LIST_TITLE AILocalizedString(@"Contact List","Name of the window which lists contacts")
45 @class AIMenuController , AIChat, AIListObject;
47 //Sends Interface_ViewDesiredSizeDidChange notifications
48 @protocol AIAutoSizingView
49 - (NSSize)desiredSize;
50 @end
52 //Controls a contact list view
53 @protocol AIContactListViewController <NSObject>
54 - (NSView *)contactListView;
55 @end
57 @protocol AIMessageViewController <NSObject>
58 - (NSView *)messageView;
59 - (NSView *)messageScrollView;
60 @end
62 //Manages contact list view controllers
63 @protocol AIContactListViewPlugin <NSObject>
64 - (id <AIContactListViewController>)contactListViewController;
65 @end
67 //manages message view controllers
68 @protocol AIMessageViewPlugin <NSObject>
69 - (id <AIMessageViewController>)messageViewControllerForChat:(AIChat *)inChat;
70 @end
72 @protocol AIContactListTooltipEntry <NSObject>
73 - (NSString *)labelForObject:(AIListObject *)inObject;
74 - (NSAttributedString *)entryForObject:(AIListObject *)inObject;
75 @end
77 @protocol AIFlashObserver <NSObject>
78 - (void)flash:(int)value;
79 @end
81 //Handles any attributed text entry
82 @protocol AITextEntryView
83 - (NSAttributedString *)attributedString;
84 - (void)setAttributedString:(NSAttributedString *)inAttributedString;
85 - (void)setTypingAttributes:(NSDictionary *)attrs;
86 - (BOOL)availableForSending;
87 - (BOOL)isSendingContent;
88 - (AIChat *)chat;
89 @end
91 @protocol AIInterfaceController <NSObject>
92 - (void)openInterface;
93 - (void)closeInterface;
94 - (id)openChat:(AIChat *)chat inContainerWithID:(NSString *)containerName atIndex:(int)index;
95 - (void)closeChat:(AIChat *)chat;
96 - (AIChat *)activeChat;
97 - (void)setActiveChat:(AIChat *)inChat;
98 - (void)moveChat:(AIChat *)chat toContainerWithID:(NSString *)containerID index:(int)index;
99 - (NSArray *)openContainersAndChats;
100 - (NSArray *)openContainers;
101 - (NSArray *)openChats;
102 - (NSArray *)openChatsInContainerWithID:(NSString *)containerID;
103 - (NSString *)containerIDForChat:(AIChat *)chat;
104 - (NSWindow *)windowForChat:(AIChat *)chat;
105 @end
107 @protocol AIContactListController <NSObject>
108 - (void)showContactListAndBringToFront:(BOOL)bringToFront;
109 - (BOOL)contactListIsVisibleAndMain;
110 - (void)closeContactList;
111 @end
113 typedef enum {
114 AINormalWindowLevel = 0,
115 AIFloatingWindowLevel = 1,
116 AIDesktopWindowLevel = 2
117 } AIWindowLevel;
119 //Identifiers for the various message views
120 typedef enum {
121 DCStandardMessageView = 1, //10.2 only, unless webkit is not available
122 DCWebkitMessageView //Preferred message view
123 } DCMessageViewType;
125 @interface AIInterfaceController : NSObject {
126 IBOutlet AIMenuController *menuController;
127 IBOutlet AIAdium *adium;
129 IBOutlet NSMenuItem *menuItem_close;
130 IBOutlet NSMenuItem *menuItem_closeChat;
132 IBOutlet NSMenuItem *menuItem_paste;
133 IBOutlet NSMenuItem *menuItem_pasteFormatted;
135 IBOutlet NSMenuItem *menuItem_bold;
136 IBOutlet NSMenuItem *menuItem_italic;
138 IBOutlet NSMenuItem *menuItem_showToolbar;
139 IBOutlet NSMenuItem *menuItem_customizeToolbar;
141 IBOutlet NSMenuItem *menuItem_print;
143 NSMutableArray *contactListViewArray;
144 NSMutableArray *messageViewArray;
145 NSMutableArray *interfaceArray;
146 NSMutableArray *contactListTooltipEntryArray;
147 NSMutableArray *contactListTooltipSecondaryEntryArray;
148 float maxLabelWidth;
150 NSMutableArray *flashObserverArray;
151 NSTimer *flashTimer;
152 int flashState;
153 AIListObject *tooltipListObject;
154 NSMutableAttributedString *tooltipBody;
155 NSMutableAttributedString *tooltipTitle;
156 NSImage *tooltipImage;
158 NSString *errorTitle;
159 NSString *errorDesc;
162 BOOL closeMenuConfiguredForChat;
164 NSArray *_cachedOpenChats;
166 NSMutableArray *windowMenuArray;
168 AIChat *activeChat;
169 AIChat *mostRecentActiveChat;
171 BOOL tabbedChatting;
173 id <AIInterfaceController> interfacePlugin;
174 id <AIContactListController> contactListPlugin;
176 BOOL groupChatsByContactGroup;
177 BOOL arrangeChats;
180 - (void)registerInterfaceController:(id <AIInterfaceController>)inController;
181 - (void)registerContactListController:(id <AIContactListController>)inController;
182 - (BOOL)handleReopenWithVisibleWindows:(BOOL)visibleWindows;
184 //Contact List
185 - (IBAction)toggleContactList:(id)sender;
186 - (IBAction)showContactList:(id)sender;
187 - (IBAction)showContactListAndBringToFront:(id)sender;
188 - (IBAction)closeContactList:(id)sender;
190 //Messaging
191 - (void)openChat:(AIChat *)inChat;
192 - (void)closeChat:(AIChat *)inChat;
193 - (void)consolidateChats;
194 - (void)setActiveChat:(AIChat *)inChat;
195 - (AIChat *)activeChat;
196 - (NSArray *)openChats;
197 - (NSArray *)openChatsInContainerWithID:(NSString *)containerID;
198 - (BOOL)allowChatOrdering;
199 - (int)indexForInsertingChat:(AIChat *)chat intoContainerWithID:(NSString *)containerID;
201 //Interface plugin callbacks
202 - (void)chatDidOpen:(AIChat *)inChat;
203 - (void)chatDidBecomeActive:(AIChat *)inChat;
204 - (void)chatDidBecomeVisible:(AIChat *)inChat inWindow:(NSWindow *)inWindow;
205 - (void)chatDidClose:(AIChat *)inChat;
206 - (void)chatOrderDidChange;
207 - (void)clearUnviewedContentOfChat:(AIChat *)inChat;
208 - (NSWindow *)windowForChat:(AIChat *)inChat;
210 //Chat close menus
211 - (IBAction)closeMenu:(id)sender;
212 - (IBAction)closeChatMenu:(id)sender;
213 - (void)updateCloseMenuKeys;
215 //Window Menu
216 - (IBAction)showChatWindow:(id)sender;
217 - (void)updateActiveWindowMenuItem;
218 - (void)buildWindowMenu;
220 //Chat Cycling
221 - (IBAction)nextMessage:(id)sender;
222 - (IBAction)previousMessage:(id)sender;
224 //Message View
225 - (void)registerMessageViewPlugin:(id <AIMessageViewPlugin>)inPlugin;
226 - (id <AIMessageViewController>)messageViewControllerForChat:(AIChat *)inChat;
228 //Error Display
229 - (void)handleErrorMessage:(NSString *)inTitle withDescription:(NSString *)inDesc;
230 - (void)handleMessage:(NSString *)inTitle withDescription:(NSString *)inDesc withWindowTitle:(NSString *)inWindowTitle;
232 //Synchronized Flashing
233 - (void)registerFlashObserver:(id <AIFlashObserver>)inObserver;
234 - (void)unregisterFlashObserver:(id <AIFlashObserver>)inObserver;
235 - (void)flashTimer:(NSTimer *)inTimer;
236 - (int)flashState;
238 //Tooltips
239 - (void)registerContactListTooltipEntry:(id <AIContactListTooltipEntry>)inEntry secondaryEntry:(BOOL)isSecondary;
240 - (void)showTooltipForListObject:(AIListObject *)object atScreenPoint:(NSPoint)point onWindow:(NSWindow *)inWindow;
242 //Custom pasting
243 - (IBAction)paste:(id)sender;
244 - (IBAction)pasteFormatted:(id)sender;
246 //Custom printing
247 - (IBAction)adiumPrint:(id)sender;
249 //Custom Dimming menu items
250 - (IBAction)toggleFontTrait:(id)sender;
251 - (void)toggleToolbarShown:(id)sender;
252 - (void)runToolbarCustomizationPalette:(id)sender;
254 //Window levels menu
255 - (NSMenu *)menuForWindowLevelsNotifyingTarget:(id)target;
257 //Private
258 - (void)initController;
259 - (void)finishIniting;
260 - (void)closeController;
262 @end
264 //Custom printing informal protocol
265 @interface NSObject (AdiumPrinting)
266 - (void)adiumPrint:(id)sender;
267 @end