comparison src/pounce.h @ 5032:cb700c07ee07

[gaim-migrate @ 5375] Rewrote the buddy pounce code. It's now core/UI split, and may allow for more advanced stuff later. Pounce actions are now a UI thing, and the backend logic for registering, unregistering, and activating pouncs is now in core. Also, the buddy pounce dialog was redesigned. Oh, and there are new pounce types. You can now choose from: * Sign on * Sign off * Away * Return from away * Idle * Return from idle * Buddy starts typing * Buddy stops typing Should work. I've been using it for some time. If you find a bug, though, let me know. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sat, 05 Apr 2003 10:14:21 +0000
parents 283fb289c510
children 4691c5936c01
comparison
equal deleted inserted replaced
5031:bc494c4a3991 5032:cb700c07ee07
1 /* 1 /**
2 * @file pounce.h Buddy pounce API
3 *
2 * gaim 4 * gaim
3 * 5 *
4 * Copyright (C) 1998-2003, Mark Spencer <markster@marko.net> 6 * Copyright (C) 2003, Christian Hammond <chipx86@gnupdate.org>
5 * 7 *
6 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version. 11 * (at your option) any later version.
10 * 12 *
16 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * 21 *
20 */ 22 */
21 23 #ifndef _GAIM_POUNCE_H_
22 #ifndef _POUNCE_H_ 24 #define _GAIM_POUNCE_H_
23 #define _POUNCE_H_ 25
24 26 /**
25 struct buddy_pounce { 27 * Events that trigger buddy pounces.
26 char name[80]; 28 */
27 char message[2048]; 29 typedef enum
28 char command[2048]; 30 {
29 char sound[2048]; 31 GAIM_POUNCE_NONE = 0x00, /**< No events. */
30 32 GAIM_POUNCE_SIGNON = 0x01, /**< The buddy signed on. */
31 char pouncer[80]; 33 GAIM_POUNCE_SIGNOFF = 0x02, /**< The buddy signed off. */
32 int protocol; 34 GAIM_POUNCE_AWAY = 0x04, /**< The buddy went away. */
33 35 GAIM_POUNCE_AWAY_RETURN = 0x08, /**< The buddy returned from away. */
34 int options; 36 GAIM_POUNCE_IDLE = 0x10, /**< The buddy became idle. */
37 GAIM_POUNCE_IDLE_RETURN = 0x20, /**< The buddy is no longer idle. */
38 GAIM_POUNCE_TYPING = 0x40, /**< The buddy started typing. */
39 GAIM_POUNCE_TYPING_STOPPED = 0x80 /**< The buddy stopped typing. */
40
41 } GaimPounceEvent;
42
43 struct gaim_pounce;
44
45 /** A pounce callback. */
46 typedef void (*gaim_pounce_cb)(struct gaim_pounce *, GaimPounceEvent, void *);
47
48 /**
49 * A buddy pounce structure.
50 *
51 * Buddy pounces are actions triggered by a buddy-related event. For
52 * example, a sound can be played or an IM window opened when a buddy
53 * signs on or returns from away. Such responses are handled in the
54 * UI. The events themselves are done in the core.
55 */
56 struct gaim_pounce
57 {
58 GaimPounceEvent events; /**< The event(s) to pounce on. */
59 struct gaim_account *pouncer; /**< The user who is pouncing. */
60
61 char *pouncee; /**< The buddy to pounce on. */
62
63 gaim_pounce_cb callback; /**< The callback function to call when the
64 event is triggered. */
65 void (*free)(void *data); /**< The data free function. */
66 void *data; /**< Pounce-specific data. */
35 }; 67 };
36 68
37 struct addbp { 69 /**
38 GtkWidget *window; 70 * Creates a new buddy pounce.
39 GtkWidget *nameentry; 71 *
40 GtkWidget *messentry; 72 * @param pouncer The account that will pounce.
41 GtkWidget *commentry; 73 * @param pouncee The buddy to pounce on.
42 GtkWidget *command; 74 * @param event The event(s) to pounce on.
43 GtkWidget *sendim; 75 * @param cb The callback function to call when the pounce is triggered.
44 GtkWidget *openwindow; 76 * @param data Pounce-specific data.
45 GtkWidget *popupnotify; 77 * @param free The function to free the pounce-specific data.
46 GtkWidget *p_signon; 78 *
47 GtkWidget *p_unaway; 79 * @return The new buddy pounce structure.
48 GtkWidget *p_unidle; 80 */
49 GtkWidget *p_typing; 81 struct gaim_pounce *gaim_pounce_new(struct gaim_account *pouncer,
50 GtkWidget *save; 82 const char *pouncee,
51 GtkWidget *menu; 83 GaimPounceEvent event,
52 GtkWidget *sound; 84 gaim_pounce_cb cb, void *data,
53 GtkWidget *soundentry; 85 void (*free)(void *));
54 86
55 struct gaim_account *account; 87 /**
56 struct buddy_pounce *buddy_pounce; 88 * Destroys a buddy pounce.
57 }; 89 *
58 90 * @param pounce The buddy pounce.
59 void rem_bp(GtkWidget *w, struct buddy_pounce *b); 91 */
60 92 void gaim_pounce_destroy(struct gaim_pounce *pounce);
61 void do_pounce(struct gaim_connection *gc, char *name, int when); 93
62 94 /**
63 void do_bp_menu(); 95 * Sets the events a pounce should watch for.
64 96 *
65 #endif /* _POUNCE_H_ */ 97 * @param pounce The buddy pounce.
98 * @param events The events to watch for.
99 */
100 void gaim_pounce_set_events(struct gaim_pounce *pounce,
101 GaimPounceEvent events);
102
103 /**
104 * Sets the account that will do the pouncing.
105 *
106 * @param pounce The buddy pounce.
107 * @param pouncer The account that will pounce.
108 */
109 void gaim_pounce_set_pouncer(struct gaim_pounce *pounce,
110 struct gaim_account *pouncer);
111
112 /**
113 * Sets the buddy a pounce should pounce on.
114 *
115 * @param pounce The buddy pounce.
116 * @param pouncee The buddy to pounce on.
117 */
118 void gaim_pounce_set_pouncee(struct gaim_pounce *pounce, const char *buddy);
119
120 /**
121 * Sets the callback function to call when the pounce event is triggered.
122 *
123 * @param pounce The buddy pounce.
124 * @param cb The callback function.
125 */
126 void gaim_pounce_set_callback(struct gaim_pounce *pounce, gaim_pounce_cb cb);
127
128 /**
129 * Sets the pounce-specific data.
130 *
131 * @param pounce The buddy pounce.
132 * @param data Data specific to the pounce.
133 */
134 void gaim_pounce_set_data(struct gaim_pounce *pounce, void *data);
135
136 /**
137 * Returns the events a pounce should watch for.
138 *
139 * @param pounce The buddy pounce.
140 *
141 * @return The events the pounce is watching for.
142 */
143 GaimPounceEvent gaim_pounce_get_events(const struct gaim_pounce *pounce);
144
145 /**
146 * Returns the account that will do the pouncing.
147 *
148 * @param pounce The buddy pounce.
149 *
150 * @return The account that will pounce.
151 */
152 struct gaim_account *gaim_pounce_get_pouncer(const struct gaim_pounce *pounce);
153
154 /**
155 * Returns the buddy a pounce should pounce on.
156 *
157 * @param pounce The buddy pounce.
158 *
159 * @return The buddy to pounce on.
160 */
161 const char *gaim_pounce_get_pouncee(const struct gaim_pounce *pounce);
162
163 /**
164 * Returns the pounce-specific data.
165 *
166 * @param pounce The buddy pounce.
167 *
168 * @return The data specific to a buddy pounce.
169 */
170 void *gaim_pounce_get_data(const struct gaim_pounce *pounce);
171
172 /**
173 * Executes a pounce with the specified pouncer, pouncee, and event type.
174 *
175 * @param pouncer The account that will do the pouncing.
176 * @param pouncee The buddy that is being pounced.
177 * @param events The events that triggered the pounce.
178 */
179 void gaim_pounce_execute(const struct gaim_account *pouncer,
180 const char *pouncee,
181 GaimPounceEvent events);
182
183 /**
184 * Finds a pounce with the specified event(s) and buddy.
185 *
186 * @param pouncer The account to match against.
187 * @param buddy The buddy to match against.
188 * @param events The event(s) to match against.
189 *
190 * @return The pounce if found, or @c NULL otherwise.
191 */
192 struct gaim_pounce *gaim_find_pounce(const struct gaim_account *pouncer,
193 const char *pouncee,
194 GaimPounceEvent events);
195
196 /**
197 * Returns a list of all registered buddy pounces.
198 *
199 * @return The list of buddy pounces.
200 */
201 GList *gaim_get_pounces(void);
202
203 #endif /* _GAIM_POUNCE_H_ */