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

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

Initial commit of skeletal project.

Line 
1/*
2 *  AIContactAlertsControllerProtocol.h
3 *  Adium
4 *
5 *  Created by Evan Schoenberg on 7/31/06.
6 *
7 */
8
9#import <Adium/AIControllerProtocol.h>
10
11@class AIListObject, AIModularPane;
12
13@protocol AIEventHandler, AIActionHandler;
14
15//Event preferences
16#define PREF_GROUP_CONTACT_ALERTS       @"Contact Alerts"
17#define KEY_CONTACT_ALERTS                      @"Contact Alerts"
18#define KEY_DEFAULT_EVENT_ID            @"Default Event ID"
19#define KEY_DEFAULT_ACTION_ID           @"Default Action ID"
20
21//Event Dictionary keys
22#define KEY_EVENT_ID                            @"EventID"
23#define KEY_ACTION_ID                           @"ActionID"
24#define KEY_ACTION_DETAILS                      @"ActionDetails"
25#define KEY_ONE_TIME_ALERT                      @"OneTime"
26
27typedef enum {
28        AIContactsEventHandlerGroup = 0,
29        AIMessageEventHandlerGroup,
30        AIAccountsEventHandlerGroup,
31        AIFileTransferEventHandlerGroup,
32        AIOtherEventHandlerGroup
33} AIEventHandlerGroupType;
34#define EVENT_HANDLER_GROUP_COUNT 5
35
36@protocol AIContactAlertsController <AIController>
37/*!
38 * @brief Register an event
39 *
40 * An event must have a unique eventID. handler is responsible for providing information
41 * about the event, such as short and long descriptions. The group determines how the event will be displayed in the events
42 * preferences; events in the same group are displayed together.
43 *
44 * @param eventID Unique event ID
45 * @param handler The handler, which must conform to AIEventHandler
46 * @param inGroup The group
47 * @param global If YES, the event will only be displayed in the global Events preferences; if NO, the event is available for contacts and groups via Get Info, as well.
48 */
49- (void)registerEventID:(NSString *)eventID withHandler:(id <AIEventHandler>)handler inGroup:(AIEventHandlerGroupType)inGroup globalOnly:(BOOL)global;
50
51/*!
52 * @brief Generate an event, returning a set of the actionIDs which were performed.
53 *
54 * This should be called when eventID occurs; it triggers all associated actions.
55 *
56 * @param eventID The event which occurred
57 * @param listObject The object for which the event occurred
58 * @param userInfo Event-specific user info
59 * @param previouslyPerformedActionIDs If non-nil, a set of actionIDs which should be treated as if they had already been performed in this invocation.
60 *
61 * @result The set of actions which were performed, suitable for being passed back in for another event generation via previouslyPerformedActionIDs
62 */
63- (NSSet *)generateEvent:(NSString *)eventID forListObject:(AIListObject *)listObject userInfo:(id)userInfo previouslyPerformedActionIDs:(NSSet *)previouslyPerformedActionIDs;
64
65/*!
66 * @brief Return all event IDs
67 */
68- (NSArray *)allEventIDs;
69
70/*!
71 * @brief Return all event IDs for groups/contacts (but not global ones)
72 */
73- (NSArray *)nonGlobalEventIDs;
74
75/*!
76 * @brief Returns a menu of all events
77 *
78 * A menu item's represented object is the dictionary describing the event it represents
79 *
80 * @param target The target on which @selector(selectEvent:) will be called on selection.
81 * @param global If YES, the events listed will include global ones (such as Error Occurred) in addition to contact-specific ones.
82 * @result An NSMenu of the events
83 */
84- (NSMenu *)menuOfEventsWithTarget:(id)target forGlobalMenu:(BOOL)global;
85
86/*!
87 * @brief Sort an array of event IDs
88 *
89 * Given an array of various event IDs, this sorts them by category.
90 *
91 * @brief inArray The array of eventIDs to sort
92 * @return Sorted version of inArray
93 */
94- (NSArray *)sortedArrayOfEventIDsFromArray:(NSArray *)inArray;
95
96/*!
97 * @brief Return the default event ID for a new alert
98 */
99- (NSString *)defaultEventID;
100
101#pragma mark Descriptions
102
103/*!
104 * @brief Find the eventID associated with an English name
105 *
106 * This exists for compatibility with old AdiumXtras...
107 */
108- (NSString*)eventIDForEnglishDisplayName:(NSString *)displayName;
109
110/*!
111 * @brief Return a short description to describe eventID when considered globally
112 */
113- (NSString *)globalShortDescriptionForEventID:(NSString *)eventID;
114
115/*!
116 * @brief Return a description to describe eventID; this is more verbose than the short description
117 * @param listObject The object for which the eventID should be described. If nil, it will be described globally.
118 */
119- (NSString *)longDescriptionForEventID:(NSString *)eventID forListObject:(AIListObject *)listObject;
120
121/*!
122 * @brief Return a natural language, localized description for an event
123 *
124 * This will be suitable for display to the user such as in a message window or a Growl notification
125 *
126 * @param eventID The event
127 * @param listObject The object for which the event occurred
128 * @param userInfo Event-specific userInfo
129 * @param includeSubject If YES, the return value is a complete sentence. If NO, the return value is suitable for display after a name or other identifier.
130 * @result The natural language description
131 */
132- (NSString *)naturalLanguageDescriptionForEventID:(NSString *)eventID
133                                                                                listObject:(AIListObject *)listObject
134                                                                                  userInfo:(id)userInfo
135                                                                        includeSubject:(BOOL)includeSubject;
136
137/*!
138 * @brief Return the image associated with an event
139 */
140- (NSImage *)imageForEventID:(NSString *)eventID;
141
142#pragma mark Event types
143/*!
144 * @brief Is the passed event a message event?
145 *
146 * Examples of messages events are "message sent" and "message received."
147 *
148 * @result YES if it is a message event
149 */
150- (BOOL)isMessageEvent:(NSString *)eventID;
151
152/*!
153 * @brief Is the passed event a contact status event?
154 *
155 * Examples of messages events are "contact signed on" and "contact went away."
156 *
157 * @result YES if it is a contact status event
158 */
159- (BOOL)isContactStatusEvent:(NSString *)eventID;
160
161#pragma mark Actions
162/*!
163 * @brief Register an actionID and its handler
164 *
165 * When an event occurs -- that is, when the event is generated via
166 * -[id<AIContactAlertsController> generateEvent:forListObject:userInfo:] -- the handler for each action
167 * associated with that event within the appropriate list object's heirarchy (object -> containing group -> global)
168 * will be called as per the AIActionHandler protocol.
169 *
170 * @param actionID The actionID
171 * @param handler The handler, which must conform to the AIActionHandler protocol
172 */
173- (void)registerActionID:(NSString *)actionID withHandler:(id <AIActionHandler>)handler;
174
175/*!
176 * @brief Return a dictionary whose keys are action IDs and whose objects are objects conforming to AIActionHandler
177 */
178- (NSDictionary *)actionHandlers;
179
180/*!
181 * @brief Returns a menu of all actions
182 *
183 * A menu item's represented object is the dictionary describing the action it represents
184 *
185 * @param target The target on which @selector(selectAction:) will be called on selection
186 * @result The NSMenu, which does not send validateMenuItem: messages
187 */
188- (NSMenu *)menuOfActionsWithTarget:(id)target;
189
190/*!
191 * @brief Return the default action ID for a new alert
192 */
193- (NSString *)defaultActionID;
194
195#pragma mark Alerts
196/*!
197 * @brief Returns an array of all the alerts of a given list object
198 *
199 * This calls alertsForListObject:withEventID:actionID with nil for eventID and actionID.
200 *
201 * @param listObject The object
202 */
203- (NSArray *)alertsForListObject:(AIListObject *)listObject;
204
205/*!
206 * @brief Return an array of all alerts for a list object with filtering
207 *
208 * @param listObject The object, or nil for global
209 * @param eventID If specified, only return events matching eventID. If nil, don't filter based on events.
210 * @param actionID If specified, only return actions matching actionID. If nil, don't filter based on actionID.
211 */
212- (NSArray *)alertsForListObject:(AIListObject *)listObject withEventID:(NSString *)eventID actionID:(NSString *)actionID;
213
214/*!
215 * @brief Add an alert (passed as a dictionary) to a list object
216 *
217 * @param newAlert The alert to add
218 * @param listObject The object to which to add, or nil for global
219 * @param setAsNewDefaults YES to make the type and details of newAlert be the new default for new alerts
220 */
221- (void)addAlert:(NSDictionary *)alert toListObject:(AIListObject *)listObject setAsNewDefaults:(BOOL)setAsNewDefaults;
222
223/*!
224 * @brief Add an alert at the global level
225 */
226- (void)addGlobalAlert:(NSDictionary *)newAlert;
227
228/*!
229 * @brief Remove an alert from a listObject
230 *
231 * @param victimAlert The alert to remove; it will be tested against existing alerts using isEqual: so must be identical
232 * @param listObject The object (or nil, for global) from which to remove victimAlert
233 */
234- (void)removeAlert:(NSDictionary *)victimAlert fromListObject:(AIListObject *)listObject;
235
236/*!
237 * @brief Remove all current global alerts and replace them with the alerts in allGlobalAlerts
238 *
239 * Used for setting a preset of events
240 */
241- (void)setAllGlobalAlerts:(NSArray *)allGlobalAlerts;
242
243/*!
244 * @brief Remove all global (root-level) alerts with a given action ID
245 */
246- (void)removeAllGlobalAlertsWithActionID:(NSString *)actionID;
247
248/*!
249 * @brief Move all contact alerts from oldObject to newObject
250 *
251 * This is useful when adding oldObject to the metaContact newObject so that any existing contact alerts for oldObject
252 * are applied at the contact-general level, displayed and handled properly for the new, combined contact.
253 *
254 * @param oldObject The object from which to move contact alerts
255 * @param newObject The object to which to we want to add the moved contact alerts
256 */
257- (void)mergeAndMoveContactAlertsFromListObject:(AIListObject *)oldObject intoListObject:(AIListObject *)newObject;
258@end
259
260/*!
261 * @protocol AIEventHandler
262 * @brief Protocol for a class which posts and supplies information about an Event
263 *
264 * Example Events are Account Connected, Contact Signed On, New Message Received
265 */
266@protocol AIEventHandler <NSObject>
267/*!
268 * @brief Short description
269 * @result A short localized description of the passed event
270 */
271- (NSString *)shortDescriptionForEventID:(NSString *)eventID;
272
273/*!
274 * @brief Global short description for an event
275 * @result A short localized description of the passed event in the case that it is not associated with an object
276 */
277- (NSString *)globalShortDescriptionForEventID:(NSString *)eventID;
278
279/*!
280 * @brief English, non-translated global short description for an event
281 *
282 * This exists because old X(tras) relied upon matching the description of event IDs, and I don't feel like making
283 * a converter for old packs.  If anyone wants to fix this situation, please feel free :)
284 *
285 * @result English global short description which should only be used internally
286 */
287- (NSString *)englishGlobalShortDescriptionForEventID:(NSString *)eventID;
288
289/*!
290 * @brief Long description for an event
291 * @result A localized description of an event, for listObject if passed, which is more verbose than the short description.
292 */
293- (NSString *)longDescriptionForEventID:(NSString *)eventID forListObject:(AIListObject *)listObject;
294
295/*!
296 * @brief Natural language description for an event
297 *
298 * @param eventID The event identifier
299 * @param listObject The listObject triggering the event
300 * @param userInfo Event-specific userInfo
301 * @param includeSubject If YES, return a full sentence.  If not, return a fragment.
302 * @result The natural language description.
303 */
304- (NSString *)naturalLanguageDescriptionForEventID:(NSString *)eventID
305                                                                                listObject:(AIListObject *)listObject
306                                                                                  userInfo:(id)userInfo
307                                                                        includeSubject:(BOOL)includeSubject;
308
309/*!
310 * @brief Return an image icon for the specified eventID.
311 */
312- (NSImage *)imageForEventID:(NSString *)eventID;
313@end
314
315/*!
316 * @protocol AIActionHandler
317 * @brief Protocol for an Action which can be taken in response to an Event
318 *
319 * An action may optionally supply a details pane.  If it does, it can store information in a details dictionary
320 * which will be passed back to the action when it is triggered as well as when it is queried for a  long description.
321 *
322 * Example Actions are Play Sound, Speak Event, Display Growl Notification
323 */
324@protocol AIActionHandler <NSObject>
325/*!
326 * @brief Short description
327 * @result A short localized description of the action
328 */
329- (NSString *)shortDescriptionForActionID:(NSString *)actionID;
330
331/*!
332 * @brief Long description
333 * @result A longer localized description of the action which should take into account the details dictionary as appropraite.
334 */
335- (NSString *)longDescriptionForActionID:(NSString *)actionID withDetails:(NSDictionary *)details;
336
337/*!
338 * @brief Image
339 */
340- (NSImage *)imageForActionID:(NSString *)actionID;
341
342/*!
343 * @brief Details pane
344 * @result An <tt>AIModularPane</tt> to use for configuring this action, or nil if no configuration is possible.
345 */
346- (AIModularPane *)detailsPaneForActionID:(NSString *)actionID;
347
348/*!
349 * @brief Perform an action
350 *
351 * @param actionID The ID of the action to perform
352 * @param listObject The listObject associated with the event triggering the action. It may be nil
353 * @param details If set by the details pane when the action was created, the details dictionary for this particular action
354 * @param eventID The eventID which triggered this action
355 * @param userInfo Additional information associated with the event; userInfo's type will vary with the actionID.
356 *
357 * @result YES if the action was performed successfully.  If NO, other actions of the same type will be attempted even if allowMultipleActionsWithID: returns NO for eventID.
358 */
359- (BOOL)performActionID:(NSString *)actionID forListObject:(AIListObject *)listObject withDetails:(NSDictionary *)details triggeringEventID:(NSString *)eventID userInfo:(id)userInfo;
360
361/*!
362 * @brief Allow multiple actions?
363 *
364 * If this method returns YES, every one of this action associated with the triggering event will be executed.
365 * If this method returns NO, only the first will be.
366 *
367 * Example of relevance: An action which plays a sound may return NO so that if the user has sound actions associated
368 * with the "Message Received (Initial)" and "Message Received" events will hear the "Message Received (Initial)"
369 * sound [which is triggered first] and not the "Message Received" sound when an initial message is received. If this
370 * method returned YES, both sounds would be played.
371 */
372- (BOOL)allowMultipleActionsWithID:(NSString *)actionID;
373@end
Note: See TracBrowser for help on using the browser.