pounce.h
Go to the documentation of this file.
1
6 /* purple
7 *
8 * Purple is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
25 */
26 #ifndef _PURPLE_POUNCE_H_
27 #define _PURPLE_POUNCE_H_
28
29 typedef struct _PurplePounce PurplePounce;
30
31 #include <glib.h>
32 #include "account.h"
33
37 typedef enum
38 {
39 PURPLE_POUNCE_NONE = 0x000,
40 PURPLE_POUNCE_SIGNON = 0x001,
41 PURPLE_POUNCE_SIGNOFF = 0x002,
42 PURPLE_POUNCE_AWAY = 0x004,
43 PURPLE_POUNCE_AWAY_RETURN = 0x008,
44 PURPLE_POUNCE_IDLE = 0x010,
45 PURPLE_POUNCE_IDLE_RETURN = 0x020,
46 PURPLE_POUNCE_TYPING = 0x040,
47 PURPLE_POUNCE_TYPED = 0x080,
48 PURPLE_POUNCE_TYPING_STOPPED = 0x100,
49 PURPLE_POUNCE_MESSAGE_RECEIVED = 0x200
51 } PurplePounceEvent;
52
53 typedef enum
54 {
55 PURPLE_POUNCE_OPTION_NONE = 0x00,
56 PURPLE_POUNCE_OPTION_AWAY = 0x01
57 } PurplePounceOption;
58
60 typedef void (*PurplePounceCb)(PurplePounce *, PurplePounceEvent, void *);
61
70 struct _PurplePounce
71 {
72 char *ui_type;
74 PurplePounceEvent events;
75 PurplePounceOption options;
76 PurpleAccount *pouncer;
78 char *pouncee;
80 GHashTable *actions;
82 gboolean save;
84 void *data;
85 };
86
87 #ifdef __cplusplus
88 extern "C" {
89 #endif
90
91 /**************************************************************************/
93 /**************************************************************************/
107 PurplePounce *purple_pounce_new(const char *ui_type, PurpleAccount *pouncer,
108 const char *pouncee, PurplePounceEvent event,
109 PurplePounceOption option);
110
116 void purple_pounce_destroy(PurplePounce *pounce);
117
123 void purple_pounce_destroy_all_by_account(PurpleAccount *account);
124
132 void purple_pounce_destroy_all_by_buddy(PurpleBuddy *buddy);
133
140 void purple_pounce_set_events(PurplePounce *pounce, PurplePounceEvent events);
141
148 void purple_pounce_set_options(PurplePounce *pounce, PurplePounceOption options);
149
156 void purple_pounce_set_pouncer(PurplePounce *pounce, PurpleAccount *pouncer);
157
164 void purple_pounce_set_pouncee(PurplePounce *pounce, const char *pouncee);
165
172 void purple_pounce_set_save(PurplePounce *pounce, gboolean save);
173
180 void purple_pounce_action_register(PurplePounce *pounce, const char *name);
181
189 void purple_pounce_action_set_enabled(PurplePounce *pounce, const char *action,
190 gboolean enabled);
191
202 void purple_pounce_action_set_attribute(PurplePounce *pounce, const char *action,
203 const char *attr, const char *value);
204
211 void purple_pounce_set_data(PurplePounce *pounce, void *data);
212
220 PurplePounceEvent purple_pounce_get_events(const PurplePounce *pounce);
221
229 PurplePounceOption purple_pounce_get_options(const PurplePounce *pounce);
230
238 PurpleAccount *purple_pounce_get_pouncer(const PurplePounce *pounce);
239
247 const char *purple_pounce_get_pouncee(const PurplePounce *pounce);
248
257 gboolean purple_pounce_get_save(const PurplePounce *pounce);
258
267 gboolean purple_pounce_action_is_enabled(const PurplePounce *pounce,
268 const char *action);
269
279 const char *purple_pounce_action_get_attribute(const PurplePounce *pounce,
280 const char *action,
281 const char *attr);
282
290 void *purple_pounce_get_data(const PurplePounce *pounce);
291
299 void purple_pounce_execute(const PurpleAccount *pouncer, const char *pouncee,
300 PurplePounceEvent events);
301
304 /**************************************************************************/
306 /**************************************************************************/
318 PurplePounce *purple_find_pounce(const PurpleAccount *pouncer,
319 const char *pouncee, PurplePounceEvent events);
320
321
327 gboolean purple_pounces_load(void);
328
337 void purple_pounces_register_handler(const char *ui, PurplePounceCb cb,
338 void (*new_pounce)(PurplePounce *pounce),
339 void (*free_pounce)(PurplePounce *pounce));
340
346 void purple_pounces_unregister_handler(const char *ui);
347
353 GList *purple_pounces_get_all(void);
354
364 GList *purple_pounces_get_all_for_ui(const char *ui);
365
371 void *purple_pounces_get_handle(void);
372
376 void purple_pounces_init(void);
377
381 void purple_pounces_uninit(void);
382
385 #ifdef __cplusplus
386 }
387 #endif
388
389 #endif /* _PURPLE_POUNCE_H_ */
PurplePounceEvent
PurplePounceEvent
Events that trigger buddy pounces.
Definition: pounce.h:37
_PurplePounce::pouncer
PurpleAccount * pouncer
The user who is pouncing.
Definition: pounce.h:76
purple_pounce_new
PurplePounce * purple_pounce_new(const char *ui_type, PurpleAccount *pouncer, const char *pouncee, PurplePounceEvent event, PurplePounceOption option)
Creates a new buddy pounce.
PURPLE_POUNCE_MESSAGE_RECEIVED
The buddy sent a message.
Definition: pounce.h:49
purple_pounces_get_all_for_ui
GList * purple_pounces_get_all_for_ui(const char *ui)
Returns a list of registered buddy pounces for the ui-type.
_PurplePounce::options
PurplePounceOption options
The pounce options.
Definition: pounce.h:75
purple_pounce_set_pouncer
void purple_pounce_set_pouncer(PurplePounce *pounce, PurpleAccount *pouncer)
Sets the account that will do the pouncing.
_PurplePounce
A buddy pounce structure.
Definition: pounce.h:70
purple_pounce_get_data
void * purple_pounce_get_data(const PurplePounce *pounce)
Returns the pounce-specific data.
purple_pounces_load
gboolean purple_pounces_load(void)
Loads the pounces.
PURPLE_POUNCE_TYPING
The buddy started typing.
Definition: pounce.h:46
purple_pounce_get_save
gboolean purple_pounce_get_save(const PurplePounce *pounce)
Returns whether or not the pounce should save after execution.
PURPLE_POUNCE_TYPING_STOPPED
The buddy stopped typing.
Definition: pounce.h:48
purple_pounce_action_is_enabled
gboolean purple_pounce_action_is_enabled(const PurplePounce *pounce, const char *action)
Returns whether or not an action is enabled.
_PurpleAccount
Structure representing an account.
Definition: account.h:169
purple_pounce_destroy_all_by_buddy
void purple_pounce_destroy_all_by_buddy(PurpleBuddy *buddy)
Destroys all buddy pounces for a buddy.
PURPLE_POUNCE_NONE
No events.
Definition: pounce.h:39
purple_pounce_set_save
void purple_pounce_set_save(PurplePounce *pounce, gboolean save)
Sets whether or not the pounce should be saved after execution.
_PurplePounce::save
gboolean save
Whether or not the pounce should be saved after activation.
Definition: pounce.h:82
purple_pounce_get_options
PurplePounceOption purple_pounce_get_options(const PurplePounce *pounce)
Returns the options for a pounce.
purple_pounce_get_pouncer
PurpleAccount * purple_pounce_get_pouncer(const PurplePounce *pounce)
Returns the account that will do the pouncing.
option
Definition: finch/getopt.h:84
PURPLE_POUNCE_IDLE
The buddy became idle.
Definition: pounce.h:44
purple_pounces_unregister_handler
void purple_pounces_unregister_handler(const char *ui)
Unregisters a pounce handle for a UI.
PURPLE_POUNCE_TYPED
The buddy has entered text.
Definition: pounce.h:47
purple_pounce_get_pouncee
const char * purple_pounce_get_pouncee(const PurplePounce *pounce)
Returns the buddy a pounce should pounce on.
purple_pounce_action_set_attribute
void purple_pounce_action_set_attribute(PurplePounce *pounce, const char *action, const char *attr, const char *value)
Sets a value for an attribute in an action.
PURPLE_POUNCE_OPTION_AWAY
Pounce only when away.
Definition: pounce.h:56
purple_pounce_set_data
void purple_pounce_set_data(PurplePounce *pounce, void *data)
Sets the pounce-specific data.
_PurplePounce::data
void * data
Pounce-specific data.
Definition: pounce.h:84
purple_pounces_get_all
GList * purple_pounces_get_all(void)
Returns a list of all registered buddy pounces.
purple_pounce_destroy_all_by_account
void purple_pounce_destroy_all_by_account(PurpleAccount *account)
Destroys all buddy pounces for the account.
purple_pounces_get_handle
void * purple_pounces_get_handle(void)
Returns the buddy pounce subsystem handle.
purple_pounces_init
void purple_pounces_init(void)
Initializes the pounces subsystem.
PURPLE_POUNCE_SIGNON
The buddy signed on.
Definition: pounce.h:40
purple_pounce_action_register
void purple_pounce_action_register(PurplePounce *pounce, const char *name)
Registers an action type for the pounce.
PURPLE_POUNCE_AWAY_RETURN
The buddy returned from away.
Definition: pounce.h:43
PurplePounceCb
void(* PurplePounceCb)(PurplePounce *, PurplePounceEvent, void *)
A pounce callback.
Definition: pounce.h:60
PURPLE_POUNCE_IDLE_RETURN
The buddy is no longer idle.
Definition: pounce.h:45
purple_pounces_register_handler
void purple_pounces_register_handler(const char *ui, PurplePounceCb cb, void(*new_pounce)(PurplePounce *pounce), void(*free_pounce)(PurplePounce *pounce))
Registers a pounce handler for a UI.
purple_pounce_action_set_enabled
void purple_pounce_action_set_enabled(PurplePounce *pounce, const char *action, gboolean enabled)
Enables or disables an action for a pounce.
account.h
Account API.
purple_pounce_set_pouncee
void purple_pounce_set_pouncee(PurplePounce *pounce, const char *pouncee)
Sets the buddy a pounce should pounce on.
PURPLE_POUNCE_SIGNOFF
The buddy signed off.
Definition: pounce.h:41
purple_pounce_execute
void purple_pounce_execute(const PurpleAccount *pouncer, const char *pouncee, PurplePounceEvent events)
Executes a pounce with the specified pouncer, pouncee, and event type.
purple_find_pounce
PurplePounce * purple_find_pounce(const PurpleAccount *pouncer, const char *pouncee, PurplePounceEvent events)
Finds a pounce with the specified event(s) and buddy.
purple_pounce_action_get_attribute
const char * purple_pounce_action_get_attribute(const PurplePounce *pounce, const char *action, const char *attr)
Returns the value for an attribute in an action.
PURPLE_POUNCE_AWAY
The buddy went away.
Definition: pounce.h:42
purple_pounce_set_options
void purple_pounce_set_options(PurplePounce *pounce, PurplePounceOption options)
Sets the options for a pounce.
PurplePounceOption
PurplePounceOption
Definition: pounce.h:53
_PurplePounce::actions
GHashTable * actions
The registered actions.
Definition: pounce.h:80
_PurplePounce::pouncee
char * pouncee
The buddy to pounce on.
Definition: pounce.h:78
_PurpleBuddy
A buddy.
Definition: blist.h:138
purple_pounce_get_events
PurplePounceEvent purple_pounce_get_events(const PurplePounce *pounce)
Returns the events a pounce should watch for.
_PurplePounce::events
PurplePounceEvent events
The event(s) to pounce on.
Definition: pounce.h:74
_PurplePounce::ui_type
char * ui_type
The type of UI.
Definition: pounce.h:72
purple_pounces_uninit
void purple_pounces_uninit(void)
Uninitializes the pounces subsystem.
purple_pounce_destroy
void purple_pounce_destroy(PurplePounce *pounce)
Destroys a buddy pounce.
purple_pounce_set_events
void purple_pounce_set_events(PurplePounce *pounce, PurplePounceEvent events)
Sets the events a pounce should watch for.
PURPLE_POUNCE_OPTION_NONE
No Option.
Definition: pounce.h:55