comparison libpurple/pounce.h @ 15373:5fe8042783c1

Rename gtk/ and libgaim/ to pidgin/ and libpurple/
author Sean Egan <seanegan@gmail.com>
date Sat, 20 Jan 2007 02:32:10 +0000
parents
children 32c366eeeb99
comparison
equal deleted inserted replaced
15372:f79e0f4df793 15373:5fe8042783c1
1 /**
2 * @file pounce.h Buddy Pounce API
3 * @ingroup core
4 *
5 * gaim
6 *
7 * Gaim is the legal property of its developers, whose names are too numerous
8 * to list here. Please refer to the COPYRIGHT file distributed with this
9 * source distribution.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25 #ifndef _GAIM_POUNCE_H_
26 #define _GAIM_POUNCE_H_
27
28 typedef struct _GaimPounce GaimPounce;
29
30 #include <glib.h>
31 #include "account.h"
32
33 /**
34 * Events that trigger buddy pounces.
35 */
36 typedef enum
37 {
38 GAIM_POUNCE_NONE = 0x000, /**< No events. */
39 GAIM_POUNCE_SIGNON = 0x001, /**< The buddy signed on. */
40 GAIM_POUNCE_SIGNOFF = 0x002, /**< The buddy signed off. */
41 GAIM_POUNCE_AWAY = 0x004, /**< The buddy went away. */
42 GAIM_POUNCE_AWAY_RETURN = 0x008, /**< The buddy returned from away. */
43 GAIM_POUNCE_IDLE = 0x010, /**< The buddy became idle. */
44 GAIM_POUNCE_IDLE_RETURN = 0x020, /**< The buddy is no longer idle. */
45 GAIM_POUNCE_TYPING = 0x040, /**< The buddy started typing. */
46 GAIM_POUNCE_TYPED = 0x080, /**< The buddy has entered text. */
47 GAIM_POUNCE_TYPING_STOPPED = 0x100, /**< The buddy stopped typing. */
48 GAIM_POUNCE_MESSAGE_RECEIVED = 0x200 /**< The buddy sent a message */
49
50 } GaimPounceEvent;
51
52 typedef enum
53 {
54 GAIM_POUNCE_OPTION_NONE = 0x00, /**< No Option */
55 GAIM_POUNCE_OPTION_AWAY = 0x01 /**< Pounce only when away */
56 } GaimPounceOption;
57
58 /** A pounce callback. */
59 typedef void (*GaimPounceCb)(GaimPounce *, GaimPounceEvent, void *);
60
61 /**
62 * A buddy pounce structure.
63 *
64 * Buddy pounces are actions triggered by a buddy-related event. For
65 * example, a sound can be played or an IM window opened when a buddy
66 * signs on or returns from away. Such responses are handled in the
67 * UI. The events themselves are done in the core.
68 */
69 struct _GaimPounce
70 {
71 char *ui_type; /**< The type of UI. */
72
73 GaimPounceEvent events; /**< The event(s) to pounce on. */
74 GaimPounceOption options; /**< The pounce options */
75 GaimAccount *pouncer; /**< The user who is pouncing. */
76
77 char *pouncee; /**< The buddy to pounce on. */
78
79 GHashTable *actions; /**< The registered actions. */
80
81 gboolean save; /**< Whether or not the pounce should
82 be saved after activation. */
83 void *data; /**< Pounce-specific data. */
84 };
85
86 #ifdef __cplusplus
87 extern "C" {
88 #endif
89
90 /**************************************************************************/
91 /** @name Buddy Pounce API */
92 /**************************************************************************/
93 /*@{*/
94
95 /**
96 * Creates a new buddy pounce.
97 *
98 * @param ui_type The type of UI the pounce is for.
99 * @param pouncer The account that will pounce.
100 * @param pouncee The buddy to pounce on.
101 * @param event The event(s) to pounce on.
102 * @param option Pounce options.
103 *
104 * @return The new buddy pounce structure.
105 */
106 GaimPounce *gaim_pounce_new(const char *ui_type, GaimAccount *pouncer,
107 const char *pouncee, GaimPounceEvent event,
108 GaimPounceOption option);
109
110 /**
111 * Destroys a buddy pounce.
112 *
113 * @param pounce The buddy pounce.
114 */
115 void gaim_pounce_destroy(GaimPounce *pounce);
116
117 /**
118 * Destroys all buddy pounces for the account
119 *
120 * @param account The account to remove all pounces from.
121 */
122 void gaim_pounce_destroy_all_by_account(GaimAccount *account);
123
124 /**
125 * Sets the events a pounce should watch for.
126 *
127 * @param pounce The buddy pounce.
128 * @param events The events to watch for.
129 */
130 void gaim_pounce_set_events(GaimPounce *pounce, GaimPounceEvent events);
131
132 /**
133 * Sets the options for a pounce.
134 *
135 * @param pounce The buddy pounce.
136 * @param options The options for the pounce.
137 */
138 void gaim_pounce_set_options(GaimPounce *pounce, GaimPounceOption options);
139
140 /**
141 * Sets the account that will do the pouncing.
142 *
143 * @param pounce The buddy pounce.
144 * @param pouncer The account that will pounce.
145 */
146 void gaim_pounce_set_pouncer(GaimPounce *pounce, GaimAccount *pouncer);
147
148 /**
149 * Sets the buddy a pounce should pounce on.
150 *
151 * @param pounce The buddy pounce.
152 * @param pouncee The buddy to pounce on.
153 */
154 void gaim_pounce_set_pouncee(GaimPounce *pounce, const char *pouncee);
155
156 /**
157 * Sets whether or not the pounce should be saved after execution.
158 *
159 * @param pounce The buddy pounce.
160 * @param save @c TRUE if the pounce should be saved, or @c FALSE otherwise.
161 */
162 void gaim_pounce_set_save(GaimPounce *pounce, gboolean save);
163
164 /**
165 * Registers an action type for the pounce.
166 *
167 * @param pounce The buddy pounce.
168 * @param name The action name.
169 */
170 void gaim_pounce_action_register(GaimPounce *pounce, const char *name);
171
172 /**
173 * Enables or disables an action for a pounce.
174 *
175 * @param pounce The buddy pounce.
176 * @param action The name of the action.
177 * @param enabled The enabled state.
178 */
179 void gaim_pounce_action_set_enabled(GaimPounce *pounce, const char *action,
180 gboolean enabled);
181
182 /**
183 * Sets a value for an attribute in an action.
184 *
185 * If @a value is @c NULL, the value will be unset.
186 *
187 * @param pounce The buddy pounce.
188 * @param action The action name.
189 * @param attr The attribute name.
190 * @param value The value.
191 */
192 void gaim_pounce_action_set_attribute(GaimPounce *pounce, const char *action,
193 const char *attr, const char *value);
194
195 /**
196 * Sets the pounce-specific data.
197 *
198 * @param pounce The buddy pounce.
199 * @param data Data specific to the pounce.
200 */
201 void gaim_pounce_set_data(GaimPounce *pounce, void *data);
202
203 /**
204 * Returns the events a pounce should watch for.
205 *
206 * @param pounce The buddy pounce.
207 *
208 * @return The events the pounce is watching for.
209 */
210 GaimPounceEvent gaim_pounce_get_events(const GaimPounce *pounce);
211
212 /**
213 * Returns the options for a pounce.
214 *
215 * @param pounce The buddy pounce.
216 *
217 * @return The options for the pounce.
218 */
219 GaimPounceOption gaim_pounce_get_options(const GaimPounce *pounce);
220
221 /**
222 * Returns the account that will do the pouncing.
223 *
224 * @param pounce The buddy pounce.
225 *
226 * @return The account that will pounce.
227 */
228 GaimAccount *gaim_pounce_get_pouncer(const GaimPounce *pounce);
229
230 /**
231 * Returns the buddy a pounce should pounce on.
232 *
233 * @param pounce The buddy pounce.
234 *
235 * @return The buddy to pounce on.
236 */
237 const char *gaim_pounce_get_pouncee(const GaimPounce *pounce);
238
239 /**
240 * Returns whether or not the pounce should save after execution.
241 *
242 * @param pounce The buddy pounce.
243 *
244 * @return @c TRUE if the pounce should be saved after execution, or
245 * @c FALSE otherwise.
246 */
247 gboolean gaim_pounce_get_save(const GaimPounce *pounce);
248
249 /**
250 * Returns whether or not an action is enabled.
251 *
252 * @param pounce The buddy pounce.
253 * @param action The action name.
254 *
255 * @return @c TRUE if the action is enabled, or @c FALSE otherwise.
256 */
257 gboolean gaim_pounce_action_is_enabled(const GaimPounce *pounce,
258 const char *action);
259
260 /**
261 * Returns the value for an attribute in an action.
262 *
263 * @param pounce The buddy pounce.
264 * @param action The action name.
265 * @param attr The attribute name.
266 *
267 * @return The attribute value, if it exists, or @c NULL.
268 */
269 const char *gaim_pounce_action_get_attribute(const GaimPounce *pounce,
270 const char *action,
271 const char *attr);
272
273 /**
274 * Returns the pounce-specific data.
275 *
276 * @param pounce The buddy pounce.
277 *
278 * @return The data specific to a buddy pounce.
279 */
280 void *gaim_pounce_get_data(const GaimPounce *pounce);
281
282 /**
283 * Executes a pounce with the specified pouncer, pouncee, and event type.
284 *
285 * @param pouncer The account that will do the pouncing.
286 * @param pouncee The buddy that is being pounced.
287 * @param events The events that triggered the pounce.
288 */
289 void gaim_pounce_execute(const GaimAccount *pouncer, const char *pouncee,
290 GaimPounceEvent events);
291
292 /*@}*/
293
294 /**************************************************************************/
295 /** @name Buddy Pounce Subsystem API */
296 /**************************************************************************/
297 /*@{*/
298
299 /**
300 * Finds a pounce with the specified event(s) and buddy.
301 *
302 * @param pouncer The account to match against.
303 * @param pouncee The buddy to match against.
304 * @param events The event(s) to match against.
305 *
306 * @return The pounce if found, or @c NULL otherwise.
307 */
308 GaimPounce *gaim_find_pounce(const GaimAccount *pouncer,
309 const char *pouncee, GaimPounceEvent events);
310
311
312 /**
313 * Loads the pounces.
314 *
315 * @return @c TRUE if the pounces could be loaded.
316 */
317 gboolean gaim_pounces_load(void);
318
319 /**
320 * Registers a pounce handler for a UI.
321 *
322 * @param ui The UI name.
323 * @param cb The callback function.
324 * @param new_pounce The function called when a pounce is created.
325 * @param free_pounce The function called when a pounce is freed.
326 */
327 void gaim_pounces_register_handler(const char *ui, GaimPounceCb cb,
328 void (*new_pounce)(GaimPounce *pounce),
329 void (*free_pounce)(GaimPounce *pounce));
330
331 /**
332 * Unregisters a pounce handle for a UI.
333 *
334 * @param ui The UI name.
335 */
336 void gaim_pounces_unregister_handler(const char *ui);
337
338 /**
339 * Returns a list of all registered buddy pounces.
340 *
341 * @return The list of buddy pounces.
342 */
343 GList *gaim_pounces_get_all(void);
344
345 /**
346 * Returns the buddy pounce subsystem handle.
347 *
348 * @return The subsystem handle.
349 */
350 void *gaim_pounces_get_handle(void);
351
352 /**
353 * Initializes the pounces subsystem.
354 */
355 void gaim_pounces_init(void);
356
357 /**
358 * Uninitializes the pounces subsystem.
359 */
360 void gaim_pounces_uninit(void);
361
362 /*@}*/
363
364 #ifdef __cplusplus
365 }
366 #endif
367
368 #endif /* _GAIM_POUNCE_H_ */