zephyr: Remove unused defines and headers.
[pidgin-git.git] / libpurple / pounce.h
blob463880be77267ba2388babbbf97d50aaf84031f9
1 /* purple
3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
5 * source distribution.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 #ifndef PURPLE_POUNCE_H
23 #define PURPLE_POUNCE_H
24 /**
25 * SECTION:pounce
26 * @section_id: libpurple-pounce
27 * @short_description: <filename>pounce.h</filename>
28 * @title: Buddy Pounce API
31 typedef struct _PurplePounce PurplePounce;
33 #include <glib.h>
34 #include "account.h"
36 /**
37 * PurplePounceEvent:
38 * @PURPLE_POUNCE_NONE: No events.
39 * @PURPLE_POUNCE_SIGNON: The buddy signed on.
40 * @PURPLE_POUNCE_SIGNOFF: The buddy signed off.
41 * @PURPLE_POUNCE_AWAY: The buddy went away.
42 * @PURPLE_POUNCE_AWAY_RETURN: The buddy returned from away.
43 * @PURPLE_POUNCE_IDLE: The buddy became idle.
44 * @PURPLE_POUNCE_IDLE_RETURN: The buddy is no longer idle.
45 * @PURPLE_POUNCE_TYPING: The buddy started typing.
46 * @PURPLE_POUNCE_TYPED: The buddy has entered text.
47 * @PURPLE_POUNCE_TYPING_STOPPED: The buddy stopped typing.
48 * @PURPLE_POUNCE_MESSAGE_RECEIVED: The buddy sent a message.
50 * Events that trigger buddy pounces.
52 typedef enum
54 PURPLE_POUNCE_NONE = 0x000,
55 PURPLE_POUNCE_SIGNON = 0x001,
56 PURPLE_POUNCE_SIGNOFF = 0x002,
57 PURPLE_POUNCE_AWAY = 0x004,
58 PURPLE_POUNCE_AWAY_RETURN = 0x008,
59 PURPLE_POUNCE_IDLE = 0x010,
60 PURPLE_POUNCE_IDLE_RETURN = 0x020,
61 PURPLE_POUNCE_TYPING = 0x040,
62 PURPLE_POUNCE_TYPED = 0x080,
63 PURPLE_POUNCE_TYPING_STOPPED = 0x100,
64 PURPLE_POUNCE_MESSAGE_RECEIVED = 0x200
66 } PurplePounceEvent;
68 /**
69 * PurplePounceOption:
70 * @PURPLE_POUNCE_OPTION_NONE: No Option
71 * @PURPLE_POUNCE_OPTION_AWAY: Pounce only when away
73 typedef enum
75 PURPLE_POUNCE_OPTION_NONE = 0x00,
76 PURPLE_POUNCE_OPTION_AWAY = 0x01
77 } PurplePounceOption;
79 /**
80 * PurplePounceCb:
81 * @pounce: The #PurplePounce.
82 * @event: The #PurplePounceEvent.
83 * @data: user-data.
85 * A pounce callback.
87 typedef void (*PurplePounceCb)(PurplePounce *pounce, PurplePounceEvent event, void *data);
89 G_BEGIN_DECLS
91 /**************************************************************************/
92 /* Buddy Pounce API */
93 /**************************************************************************/
95 /**
96 * purple_pounce_new:
97 * @ui_type: The type of UI the pounce is for.
98 * @pouncer: The account that will pounce.
99 * @pouncee: The buddy to pounce on.
100 * @event: The event(s) to pounce on.
101 * @option: Pounce options.
103 * Creates a new buddy pounce.
105 * Returns: The new buddy pounce structure.
107 PurplePounce *purple_pounce_new(const char *ui_type, PurpleAccount *pouncer,
108 const char *pouncee, PurplePounceEvent event,
109 PurplePounceOption option);
112 * purple_pounce_destroy:
113 * @pounce: The buddy pounce.
115 * Destroys a buddy pounce.
117 void purple_pounce_destroy(PurplePounce *pounce);
120 * purple_pounce_destroy_all_by_account:
121 * @account: The account to remove all pounces from.
123 * Destroys all buddy pounces for the account
125 void purple_pounce_destroy_all_by_account(PurpleAccount *account);
128 * purple_pounce_destroy_all_by_buddy:
129 * @buddy: The buddy whose pounces are to be removed
131 * Destroys all buddy pounces for a buddy
133 void purple_pounce_destroy_all_by_buddy(PurpleBuddy *buddy);
136 * purple_pounce_set_events:
137 * @pounce: The buddy pounce.
138 * @events: The events to watch for.
140 * Sets the events a pounce should watch for.
142 void purple_pounce_set_events(PurplePounce *pounce, PurplePounceEvent events);
145 * purple_pounce_set_options:
146 * @pounce: The buddy pounce.
147 * @options: The options for the pounce.
149 * Sets the options for a pounce.
151 void purple_pounce_set_options(PurplePounce *pounce, PurplePounceOption options);
154 * purple_pounce_set_pouncer:
155 * @pounce: The buddy pounce.
156 * @pouncer: The account that will pounce.
158 * Sets the account that will do the pouncing.
160 void purple_pounce_set_pouncer(PurplePounce *pounce, PurpleAccount *pouncer);
163 * purple_pounce_set_pouncee:
164 * @pounce: The buddy pounce.
165 * @pouncee: The buddy to pounce on.
167 * Sets the buddy a pounce should pounce on.
169 void purple_pounce_set_pouncee(PurplePounce *pounce, const char *pouncee);
172 * purple_pounce_set_save:
173 * @pounce: The buddy pounce.
174 * @save: %TRUE if the pounce should be saved, or %FALSE otherwise.
176 * Sets whether or not the pounce should be saved after execution.
178 void purple_pounce_set_save(PurplePounce *pounce, gboolean save);
181 * purple_pounce_action_register:
182 * @pounce: The buddy pounce.
183 * @name: The action name.
185 * Registers an action type for the pounce.
187 void purple_pounce_action_register(PurplePounce *pounce, const char *name);
190 * purple_pounce_action_set_enabled:
191 * @pounce: The buddy pounce.
192 * @action: The name of the action.
193 * @enabled: The enabled state.
195 * Enables or disables an action for a pounce.
197 void purple_pounce_action_set_enabled(PurplePounce *pounce, const char *action,
198 gboolean enabled);
201 * purple_pounce_action_set_attribute:
202 * @pounce: The buddy pounce.
203 * @action: The action name.
204 * @attr: The attribute name.
205 * @value: The value.
207 * Sets a value for an attribute in an action.
209 * If @value is %NULL, the value will be unset.
211 void purple_pounce_action_set_attribute(PurplePounce *pounce, const char *action,
212 const char *attr, const char *value);
215 * purple_pounce_set_data:
216 * @pounce: The buddy pounce.
217 * @data: Data specific to the pounce.
219 * Sets the pounce-specific data.
221 void purple_pounce_set_data(PurplePounce *pounce, void *data);
224 * purple_pounce_get_events:
225 * @pounce: The buddy pounce.
227 * Returns the events a pounce should watch for.
229 * Returns: The events the pounce is watching for.
231 PurplePounceEvent purple_pounce_get_events(const PurplePounce *pounce);
234 * purple_pounce_get_options:
235 * @pounce: The buddy pounce.
237 * Returns the options for a pounce.
239 * Returns: The options for the pounce.
241 PurplePounceOption purple_pounce_get_options(const PurplePounce *pounce);
244 * purple_pounce_get_pouncer:
245 * @pounce: The buddy pounce.
247 * Returns the account that will do the pouncing.
249 * Returns: (transfer none): The account that will pounce.
251 PurpleAccount *purple_pounce_get_pouncer(const PurplePounce *pounce);
254 * purple_pounce_get_pouncee:
255 * @pounce: The buddy pounce.
257 * Returns the buddy a pounce should pounce on.
259 * Returns: The buddy to pounce on.
261 const char *purple_pounce_get_pouncee(const PurplePounce *pounce);
264 * purple_pounce_get_save:
265 * @pounce: The buddy pounce.
267 * Returns whether or not the pounce should save after execution.
269 * Returns: %TRUE if the pounce should be saved after execution, or
270 * %FALSE otherwise.
272 gboolean purple_pounce_get_save(const PurplePounce *pounce);
275 * purple_pounce_action_is_enabled:
276 * @pounce: The buddy pounce.
277 * @action: The action name.
279 * Returns whether or not an action is enabled.
281 * Returns: %TRUE if the action is enabled, or %FALSE otherwise.
283 gboolean purple_pounce_action_is_enabled(const PurplePounce *pounce,
284 const char *action);
287 * purple_pounce_action_get_attribute:
288 * @pounce: The buddy pounce.
289 * @action: The action name.
290 * @attr: The attribute name.
292 * Returns the value for an attribute in an action.
294 * Returns: The attribute value, if it exists, or %NULL.
296 const char *purple_pounce_action_get_attribute(const PurplePounce *pounce,
297 const char *action,
298 const char *attr);
301 * purple_pounce_get_data:
302 * @pounce: The buddy pounce.
304 * Returns the pounce-specific data.
306 * Returns: The data specific to a buddy pounce.
308 void *purple_pounce_get_data(const PurplePounce *pounce);
311 * purple_pounce_execute:
312 * @pouncer: The account that will do the pouncing.
313 * @pouncee: The buddy that is being pounced.
314 * @events: The events that triggered the pounce.
316 * Executes a pounce with the specified pouncer, pouncee, and event type.
318 void purple_pounce_execute(PurpleAccount *pouncer, const char *pouncee,
319 PurplePounceEvent events);
321 /**************************************************************************/
322 /* Buddy Pounce Subsystem API */
323 /**************************************************************************/
326 * purple_find_pounce:
327 * @pouncer: The account to match against.
328 * @pouncee: The buddy to match against.
329 * @events: The event(s) to match against.
331 * Finds a pounce with the specified event(s) and buddy.
333 * Returns: The pounce if found, or %NULL otherwise.
335 PurplePounce *purple_find_pounce(PurpleAccount *pouncer,
336 const char *pouncee, PurplePounceEvent events);
339 * purple_pounces_register_handler:
340 * @ui: The UI name.
341 * @cb: (scope call): The callback function.
342 * @new_pounce: The function called when a pounce is created.
343 * @free_pounce: The function called when a pounce is freed.
345 * Registers a pounce handler for a UI.
347 void purple_pounces_register_handler(const char *ui, PurplePounceCb cb,
348 void (*new_pounce)(PurplePounce *pounce),
349 void (*free_pounce)(PurplePounce *pounce));
352 * purple_pounces_unregister_handler:
353 * @ui: The UI name.
355 * Unregisters a pounce handle for a UI.
357 void purple_pounces_unregister_handler(const char *ui);
360 * purple_pounces_get_all:
362 * Returns a list of all registered buddy pounces.
364 * Returns: (element-type PurplePounce) (transfer none): The list of buddy pounces.
366 GList *purple_pounces_get_all(void);
369 * purple_pounces_get_all_for_ui:
370 * @ui: The ID of the UI using the core.
372 * Returns a list of registered buddy pounces for the ui-type.
374 * Returns: (element-type PurplePounce) (transfer container): The list of buddy pounces.
376 GList *purple_pounces_get_all_for_ui(const char *ui);
379 * purple_pounces_get_handle:
381 * Returns the buddy pounce subsystem handle.
383 * Returns: The subsystem handle.
385 void *purple_pounces_get_handle(void);
388 * purple_pounces_init:
390 * Initializes the pounces subsystem.
392 void purple_pounces_init(void);
395 * purple_pounces_uninit:
397 * Uninitializes the pounces subsystem.
399 void purple_pounces_uninit(void);
401 G_END_DECLS
403 #endif /* PURPLE_POUNCE_H */