Don't need the English form of these
[adiumx.git] / Source / AIContentController.h
blob6fe1f0e7c7b6e3f4d37c3546dbbd7d980b1e4dbd
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 Content_ContentObjectAdded @"Content_ContentObjectAdded"
18 #define Content_ChatDidFinishAddingUntrackedContent @"Content_ChatDidFinishAddingUntrackedContent"
19 #define Content_WillSendContent @"Content_WillSendContent"
20 #define Content_WillReceiveContent @"Content_WillReceiveContent"
22 //Not displayed, but used for internal identification of the encryption menu
23 #define ENCRYPTION_MENU_TITLE @"Encryption Menu"
25 @protocol AITextEntryView, AIEventHandler;
27 @class AIAccount, AIChat, AIListContact, AIListObject, AIContentObject, AdiumContentFiltering, AdiumChatEvents;
29 typedef enum {
30 AIFilterContent = 0, // Changes actual message and non-message content
31 AIFilterDisplay, // Changes only how non-message content is displayed locally (Profiles, aways, auto-replies, ...)
32 AIFilterMessageDisplay, // Changes only how messages are displayed locally
34 //A special content mode for AIM auto-replies that will only apply to bounced away messages. This allows us to
35 //filter %n,%t,... just like the official client. A small tumor in our otherwise beautiful filter system *cry*/
36 AIFilterAutoReplyContent
38 } AIFilterType;
39 #define FILTER_TYPE_COUNT 4
41 typedef enum {
42 AIFilterIncoming = 0, // Content we are receiving
43 AIFilterOutgoing // Content we are sending
44 } AIFilterDirection;
45 #define FILTER_DIRECTION_COUNT 2
47 //Observer which receives notifications of changes in chat status
48 @protocol AIChatObserver
49 - (NSSet *)updateChat:(AIChat *)inChat keys:(NSSet *)inModifiedKeys silent:(BOOL)silent;
50 @end
52 //Handles the display of a content type
53 @protocol AIContentHandler
54 @end
56 #define HIGHEST_FILTER_PRIORITY 0
57 #define HIGH_FILTER_PRIORITY 0.25
58 #define DEFAULT_FILTER_PRIORITY 0.5
59 #define LOW_FILTER_PRIORITY 0.75
60 #define LOWEST_FILTER_PRIORITY 1.0
62 //AIContentFilters have the opportunity to examine every attributed string. Non-attributed strings are not passed through these filters.
63 @protocol AIContentFilter
64 - (NSAttributedString *)filterAttributedString:(NSAttributedString *)inAttributedString context:(id)context;
65 - (float)filterPriority;
66 @end
68 //Delayed content filters return YES if they begin a delayed filter, NO if they don't.
69 @protocol AIDelayedContentFilter
70 - (BOOL)delayedFilterAttributedString:(NSAttributedString *)inAttributedString context:(id)context uniqueID:(unsigned long long)uniqueID;
71 - (float)filterPriority;
72 @end
74 @interface NSObject (AITextEntryFilter)
75 //required
76 - (void)didOpenTextEntryView:(NSText<AITextEntryView> *)inTextEntryView;
77 - (void)willCloseTextEntryView:(NSText<AITextEntryView> *)inTextEntryView;
78 //optional
79 - (void)stringAdded:(NSString *)inString toTextEntryView:(NSText<AITextEntryView> *)inTextEntryView; //keypress
80 - (void)contentsChangedInTextEntryView:(NSText<AITextEntryView> *)inTextEntryView; //delete,copy,paste,etc
81 @end
83 @interface AIContentController : NSObject <AIEventHandler> {
84 IBOutlet AIAdium *adium;
86 NSMutableArray *textEntryFilterArray;
87 NSMutableArray *textEntryContentFilterArray;
88 NSMutableArray *textEntryViews;
89 NSDictionary *defaultFormattingAttributes;
91 AdiumContentFiltering *adiumContentFiltering;
92 AdiumChatEvents *adiumChatEvents;
94 NSMutableSet *openChats;
95 NSMutableSet *objectsBeingReceived;
96 NSMutableArray *chatObserverArray;
98 AIChat *mostRecentChat;
100 NSArray *emoticonsArray;
101 NSArray *emoticonPacks;
103 NSMutableArray *contentFilter[FILTER_TYPE_COUNT][FILTER_DIRECTION_COUNT];
104 NSMutableArray *threadedContentFilter[FILTER_TYPE_COUNT][FILTER_DIRECTION_COUNT];
106 NSMenuItem *menuItem_ignore;
109 //Chats
110 - (NSSet *)allChatsWithContact:(AIListContact *)inContact;
111 - (AIChat *)openChatWithContact:(AIListContact *)inContact;
112 - (AIChat *)chatWithContact:(AIListContact *)inContact;
113 - (AIChat *)existingChatWithContact:(AIListContact *)inContact;
114 - (AIChat *)existingChatWithUniqueChatID:(NSString *)uniqueChatID;
115 - (AIChat *)chatWithName:(NSString *)inName onAccount:(AIAccount *)account chatCreationInfo:(NSDictionary *)chatCreationInfo;
116 - (AIChat *)existingChatWithName:(NSString *)inName onAccount:(AIAccount *)account;
117 - (void)openChat:(AIChat *)chat;
118 - (BOOL)closeChat:(AIChat *)inChat;
119 - (NSSet *)openChats;
120 - (AIChat *)mostRecentUnviewedChat;
121 - (void)switchChat:(AIChat *)chat toAccount:(AIAccount *)newAccount;
122 - (void)switchChat:(AIChat *)chat toListContact:(AIListContact *)inContact usingContactAccount:(BOOL)useContactAccount;
123 - (BOOL)contactIsInGroupChat:(AIListContact *)listContact;
125 //Status
126 - (void)registerChatObserver:(id <AIChatObserver>)inObserver;
127 - (void)unregisterChatObserver:(id <AIChatObserver>)inObserver;
128 - (void)chatStatusChanged:(AIChat *)inChat modifiedStatusKeys:(NSSet *)inModifiedKeys silent:(BOOL)silent;
129 - (void)updateAllChatsForObserver:(id <AIChatObserver>)observer;
131 //Unviewed Content Status
132 - (void)increaseUnviewedContentOfChat:(AIChat *)inChat;
133 - (void)clearUnviewedContentOfChat:(AIChat *)inChat;
135 //Sending / Receiving content
136 - (BOOL)availableForSendingContentType:(NSString *)inType toContact:(AIListContact *)inContact onAccount:(AIAccount *)inAccount;
137 - (void)receiveContentObject:(AIContentObject *)inObject;
138 - (BOOL)sendContentObject:(AIContentObject *)inObject;
139 - (void)displayStatusMessage:(NSString *)message ofType:(NSString *)type inChat:(AIChat *)inChat;
140 - (void)displayContentObject:(AIContentObject *)inObject;
141 - (void)displayContentObject:(AIContentObject *)inObject immediately:(BOOL)immediately;
142 - (void)displayContentObject:(AIContentObject *)inObject usingContentFilters:(BOOL)useContentFilters;
143 - (void)displayContentObject:(AIContentObject *)inObject usingContentFilters:(BOOL)useContentFilters immediately:(BOOL)immediately;
144 - (void)displayStatusMessage:(NSString *)message ofType:(NSString *)type inChat:(AIChat *)inChat;
146 //Filtering / Tracking text entry
147 - (void)registerTextEntryFilter:(id)inFilter;
148 - (void)unregisterTextEntryFilter:(id)inFilter;
149 - (NSArray *)openTextEntryViews;
150 - (void)stringAdded:(NSString *)inString toTextEntryView:(NSText<AITextEntryView> *)inTextEntryView;
151 - (void)contentsChangedInTextEntryView:(NSText<AITextEntryView> *)inTextEntryView;
152 - (void)didOpenTextEntryView:(NSText<AITextEntryView> *)inTextEntryView;
153 - (void)willCloseTextEntryView:(NSText<AITextEntryView> *)inTextEntryView;
154 - (void)setDefaultFormattingAttributes:(NSDictionary *)inDict;
155 - (NSDictionary *)defaultFormattingAttributes;
157 //Content Filtering
158 - (void)registerContentFilter:(id <AIContentFilter>)inFilter
159 ofType:(AIFilterType)type
160 direction:(AIFilterDirection)direction;
161 - (void)registerDelayedContentFilter:(id <AIDelayedContentFilter>)inFilter
162 ofType:(AIFilterType)type
163 direction:(AIFilterDirection)direction;;
164 - (void)unregisterContentFilter:(id <AIContentFilter>)inFilter;
165 - (void)registerFilterStringWhichRequiresPolling:(NSString *)inPollString;
166 - (BOOL)shouldPollToUpdateString:(NSString *)inString;
168 - (NSAttributedString *)filterAttributedString:(NSAttributedString *)attributedString
169 usingFilterType:(AIFilterType)type
170 direction:(AIFilterDirection)direction
171 context:(id)context;
172 - (void)filterAttributedString:(NSAttributedString *)attributedString
173 usingFilterType:(AIFilterType)type
174 direction:(AIFilterDirection)direction
175 filterContext:(id)filterContext
176 notifyingTarget:(id)target
177 selector:(SEL)selector
178 context:(id)context;
179 - (void)delayedFilterDidFinish:(NSAttributedString *)attributedString uniqueID:(unsigned long long)uniqueID;
182 //Content Source & Destination
183 - (NSArray *)sourceAccountsForSendingContentType:(NSString *)inType
184 toListObject:(AIListObject *)inObject
185 preferred:(BOOL)inPreferred;
186 - (NSArray *)destinationObjectsForContentType:(NSString *)inType
187 toListObject:(AIListObject *)inObject
188 preferred:(BOOL)inPreferred;
190 //Encryption
191 - (NSMenu *)encryptionMenuNotifyingTarget:(id)target withDefault:(BOOL)withDefault;
193 //Private
194 - (void)initController;
195 - (void)beginClosing;
196 - (void)closeController;
198 //Addition/removal of contacts to group chats
199 - (void)chat:(AIChat *)chat addedListContact:(AIListContact *)inContact notify:(BOOL)notify;
200 - (void)chat:(AIChat *)chat removedListContact:(AIListContact *)inContact;
202 @end