root/Trunk/Adium.framework/Versions/A/Headers/AIContentControllerProtocol.h @ 2

Revision 2, 11.3 KB (checked in by jon, 16 years ago)

Initial commit of skeletal project.

Line 
1/*
2 *  AIContentControllerProtocol.h
3 *  Adium
4 *
5 *  Created by Evan Schoenberg on 7/31/06.
6 *
7 */
8
9#import <Adium/AIControllerProtocol.h>
10#import <Adium/AIListContact.h>
11
12#define Content_ContentObjectAdded                                      @"Content_ContentObjectAdded"
13#define Content_ChatDidFinishAddingUntrackedContent     @"Content_ChatDidFinishAddingUntrackedContent"
14#define Content_WillSendContent                                         @"Content_WillSendContent"
15#define Content_WillReceiveContent                                      @"Content_WillReceiveContent"
16
17//XXX - This is really UI, but it can live here for now
18#define PREF_GROUP_FORMATTING                           @"Formatting"
19#define KEY_FORMATTING_FONT                                     @"Default Font"
20#define KEY_FORMATTING_TEXT_COLOR                       @"Default Text Color"
21#define KEY_FORMATTING_BACKGROUND_COLOR         @"Default Background Color"
22
23//Not displayed, but used for internal identification of the encryption menu
24#define ENCRYPTION_MENU_TITLE                                           @"Encryption Menu"
25
26typedef enum {
27        AIFilterContent = 0,            // Changes actual message and non-message content
28        AIFilterDisplay,                        // Changes only how non-message content is displayed locally (Profiles, aways, auto-replies, ...)
29        AIFilterMessageDisplay,         // Changes only how messages are displayed locally
30        AIFilterTooltips,                       // Changes only information displayed in contact tooltips
31        AIFilterContactList,            // Changes only information in statuses displayed in the contact list
32        /* A special content mode for AIM auto-replies that will only apply to bounced away messages.  This allows us to
33         * filter %n,%t,... just like the official client.  A small tumor in our otherwise beautiful filter system *cry*
34         */
35        AIFilterAutoReplyContent
36       
37} AIFilterType;
38#define FILTER_TYPE_COUNT 6
39
40typedef enum {
41        AIFilterIncoming = 0,   // Content we are receiving
42        AIFilterOutgoing                // Content we are sending
43} AIFilterDirection;
44#define FILTER_DIRECTION_COUNT 2
45
46#define HIGHEST_FILTER_PRIORITY 0
47#define HIGH_FILTER_PRIORITY 0.25
48#define DEFAULT_FILTER_PRIORITY 0.5
49#define LOW_FILTER_PRIORITY 0.75
50#define LOWEST_FILTER_PRIORITY 1.0
51
52@protocol AIContentFilter, AIDelayedContentFilter, AIHTMLContentFilter;
53@protocol AdiumMessageEncryptor;
54
55@class AIAccount, AIChat, AIListContact, AIListObject, AIContentObject;
56@class AIContentMessage;
57
58@protocol AIContentController <AIController>
59//Typing
60- (void)userIsTypingContentForChat:(AIChat *)chat hasEnteredText:(BOOL)hasEnteredText;
61
62        //Formatting
63- (NSDictionary *)defaultFormattingAttributes;
64
65        //Content Filtering
66- (void)registerContentFilter:(id <AIContentFilter>)inFilter
67                                           ofType:(AIFilterType)type
68                                        direction:(AIFilterDirection)direction;
69- (void)registerDelayedContentFilter:(id <AIDelayedContentFilter>)inFilter
70                                                          ofType:(AIFilterType)type
71                                                   direction:(AIFilterDirection)direction;
72- (void)registerHTMLContentFilter:(id <AIHTMLContentFilter>)inFilter
73                                                direction:(AIFilterDirection)direction;
74- (void)unregisterContentFilter:(id <AIContentFilter>)inFilter;
75- (void)unregisterDelayedContentFilter:(id <AIDelayedContentFilter>)inFilter;
76- (void)unregisterHTMLContentFilter:(id <AIHTMLContentFilter>)inFilter;
77- (void)registerFilterStringWhichRequiresPolling:(NSString *)inPollString;
78- (BOOL)shouldPollToUpdateString:(NSString *)inString;
79
80- (NSAttributedString *)filterAttributedString:(NSAttributedString *)attributedString
81                                                           usingFilterType:(AIFilterType)type
82                                                                         direction:(AIFilterDirection)direction
83                                                                           context:(id)context;
84- (void)filterAttributedString:(NSAttributedString *)attributedString
85                           usingFilterType:(AIFilterType)type
86                                         direction:(AIFilterDirection)direction
87                                 filterContext:(id)filterContext
88                           notifyingTarget:(id)target
89                                          selector:(SEL)selector
90                                           context:(id)context;
91- (void)delayedFilterDidFinish:(NSAttributedString *)attributedString uniqueID:(unsigned long long)uniqueID;
92- (NSString *)filterHTMLString:(NSString *)htmlString
93                                         direction:(AIFilterDirection)direction
94                                           content:(AIContentObject*)content;
95
96        //Sending / Receiving content
97- (BOOL)availableForSendingContentType:(NSString *)inType toContact:(AIListContact *)inContact onAccount:(AIAccount *)inAccount;
98- (void)receiveContentObject:(AIContentObject *)inObject;
99- (BOOL)sendContentObject:(AIContentObject *)inObject;
100- (void)sendRawMessage:(NSString *)inString toContact:(AIListContact *)inContact;
101/*!
102 * @brief Display content, optionally using content filters
103 *
104 * This should only be used for content which is not being sent or received but only displayed, such as message history. If you
105 *
106 * The ability to force filtering to be completed immediately exists for message history, which needs to put its display
107 * in before the first message; otherwise, the use of delayed filtering would mean that message history showed up after the first message.
108 *
109 * @param inObject The object to display
110 * @param useContentFilters Should filters be used?
111 * @param immediately If YES, only immediate filters will be used, and inObject will have its message set before we return.
112 *                                        If NO, immediate and delayed filters will be used, and inObject will be filtered over the course of some number of future run loops.
113 */
114- (void)displayContentObject:(AIContentObject *)inObject usingContentFilters:(BOOL)useContentFilters immediately:(BOOL)immediately;
115- (void)displayEvent:(NSString *)message ofType:(NSString *)type inChat:(AIChat *)inChat;
116
117        //Encryption
118- (NSAttributedString *)decodedIncomingMessage:(NSString *)inString
119                                                                   fromContact:(AIListContact *)inListContact
120                                                                         onAccount:(AIAccount *)inAccount;
121- (NSString *)decryptedIncomingMessage:(NSString *)inString
122                                                   fromContact:(AIListContact *)inListContact
123                                                         onAccount:(AIAccount *)inAccount;
124
125- (NSMenu *)encryptionMenuNotifyingTarget:(id)target withDefault:(BOOL)withDefault;
126
127- (BOOL)chatIsReceivingContent:(AIChat *)chat;
128
129        //OTR
130- (void)setEncryptor:(id<AdiumMessageEncryptor>)inEncryptor;
131- (void)requestSecureOTRMessaging:(BOOL)inSecureMessaging inChat:(AIChat *)inChat;
132- (void)promptToVerifyEncryptionIdentityInChat:(AIChat *)inChat;
133@end
134
135
136/*!
137 * @protocol AIContentFilter
138 * @brief Protocol to be implemented by regular content filter objects
139 *
140 * See registerContentFilter:ofType:direction: for registration
141 */
142@protocol AIContentFilter
143/*!
144 * @brief Filter an attributed string
145 *
146 * Given an attributed string, the filtering object makes any desired changes and returns the resulting string.
147 * If no changes are made, the original attributed string should be returned.
148 * If after handling the attributed string it should be discarded rather than used (e.g. processing a message's
149 *              attributed string led to an action, and the message itself should no longer be sent), return nil.
150 *
151 * @param inAttributedString NSAttributedString to filter
152 * @param context An object, such as an AIListContact or an AIAccount, potentially relevant to filtration. May be anything, so check its class as needed.
153 * @result The filtered attributed string, which may be the same as attributedString, or nil if the attributed string should be discared.
154 */
155- (NSAttributedString *)filterAttributedString:(NSAttributedString *)inAttributedString context:(id)context;
156
157/*!
158 * @brief The priority for this filter
159 *
160 * This is a float between 0.0 and 1.0.  Lower numbers indicate a higher priority.
161 * Filter priority determines the order in which filters are executed on a given string.
162 * DEFAULT_FILTER_PRIORITY should be used unless you have a reason to care that your filter happen earlier or later.
163 *
164 * @result A float between 0.0 and 1.0, with (HIGHEST_FILTER_PRIORITY == 0.0) and (LOWEST_FILTER_PRIORITY == 1.0)
165 */
166- (float)filterPriority;
167@end
168
169/*!
170 * @protocol AIHTMLContentFilter
171 * @brief Protocol to be implemented by HTML content filter objects
172 *
173 * See registerHTMLContentFilter:direction: for registration
174 * AIHTMLContentFilters only see strings just as the WKMV is about to display them. This allows outputting custom html for display
175 */
176@protocol AIHTMLContentFilter
177/*!
178 * @brief Filter an HTML string
179 *
180 * Given an HTML string, the filtering object makes any desired changes and returns the resulting string.
181 * If no changes are made, the original HTML string should be returned.
182 * This filtration occurs immediately before the HTML is displayed to the user in the WebKit Message View
183 *
184 * @param inHTMLString HTML to filter
185 * @param content The AIContentObject associated with this HTML, allowing access to the source and destination for the message
186 * @result The filtered HTML string, which may be the same as inHTMLString
187 */
188- (NSString *)filterHTMLString:(NSString *)inHTMLString content:(AIContentObject*)content;
189
190/*!
191 * @brief The priority for this filter
192 *
193 * This is a float between 0.0 and 1.0.  Lower numbers indicate a higher priority.
194 * Filter priority determines the order in which filters are executed on a given string.
195 * DEFAULT_FILTER_PRIORITY should be used unless you have a reason to care that your filter happen earlier or later.
196 *
197 * @result A float between 0.0 and 1.0, with (HIGHEST_FILTER_PRIORITY == 0.0) and (LOWEST_FILTER_PRIORITY == 1.0)
198 */
199- (float)filterPriority;
200@end
201
202/*!
203 * @protocol AIDelayedContentFilter
204 * @brief Protocol to be implemented by delayed content filter objects
205 *
206 * A delayed content filter is able to begin working on filtering an attributed string and then
207 * return its results an unspecified amount of time later.  This allows nonblocking filtration.
208 *
209 * This should only be used if the expected time for execution is nontrivial. Use AIContentFilter if
210 * the filtration occurs quickly.
211 *
212 * See registerDelayedContentFilter:ofType:direction: for registration
213 */
214@protocol AIDelayedContentFilter
215/*!
216 * @brief Filter an attributed string over an unspecified period of time
217 *
218 * Given an attributed string, the filtering object may begin working on the result of its filter
219 *
220 * [[adium contentController] delayedFilterDidFinish:uniqueID:] should be called with the eventual result if this method returns YES.
221 * If the filter eventually fails, this method MUST be called with the original inAttributedString.
222 *
223 * @param inAttributedString NSAttributedString to filter
224 * @param context An object, such as an AIListContact or an AIAccount, potentially relevant to filtration. May be anything, so check its class as needed.
225 * @param uniqueID A uniqueID which will be passed back to [[adium contentController] delayedFilterDidFinish:uniqueID:] when this filtration is complete.
226 *
227 * @result YES if a delayed filtration process began; NO if no changes are to be made.
228 */
229- (BOOL)delayedFilterAttributedString:(NSAttributedString *)inAttributedString context:(id)context uniqueID:(unsigned long long)uniqueID;
230
231/*!
232 * @brief The priority for this filter
233 *
234 * This is a float between 0.0 and 1.0.  Lower numbers indicate a higher priority.
235 * Filter priority determines the order in which filters are executed on a given string.
236 * DEFAULT_FILTER_PRIORITY should be used unless you have a reason to care that your filter happen earlier or later.
237 *
238 * @result A float between 0.0 and 1.0, with (HIGHEST_FILTER_PRIORITY == 0.0) and (LOWEST_FILTER_PRIORITY == 1.0)
239 */
240- (float)filterPriority;
241@end
242
243@protocol AdiumMessageEncryptor <NSObject>
244- (void)willSendContentMessage:(AIContentMessage *)inContentMessage;
245- (NSString *)decryptIncomingMessage:(NSString *)inString fromContact:(AIListContact *)inListContact onAccount:(AIAccount *)inAccount;
246
247- (void)requestSecureOTRMessaging:(BOOL)inSecureMessaging inChat:(AIChat *)inChat;
248- (void)promptToVerifyEncryptionIdentityInChat:(AIChat *)inChat;
249@end
Note: See TracBrowser for help on using the browser.