|
Evan@653
|
1 |
/** |
|
Evan@653
|
2 |
* @file pounce.h Buddy Pounce API |
|
Evan@653
|
3 |
* @ingroup core |
|
Evan@653
|
4 |
*/ |
|
Evan@653
|
5 |
|
|
Evan@653
|
6 |
/* purple |
|
Evan@653
|
7 |
* |
|
Evan@653
|
8 |
* Purple is the legal property of its developers, whose names are too numerous |
|
Evan@653
|
9 |
* to list here. Please refer to the COPYRIGHT file distributed with this |
|
Evan@653
|
10 |
* source distribution. |
|
Evan@653
|
11 |
* |
|
Evan@653
|
12 |
* This program is free software; you can redistribute it and/or modify |
|
Evan@653
|
13 |
* it under the terms of the GNU General Public License as published by |
|
Evan@653
|
14 |
* the Free Software Foundation; either version 2 of the License, or |
|
Evan@653
|
15 |
* (at your option) any later version. |
|
Evan@653
|
16 |
* |
|
Evan@653
|
17 |
* This program is distributed in the hope that it will be useful, |
|
Evan@653
|
18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
Evan@653
|
19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
Evan@653
|
20 |
* GNU General Public License for more details. |
|
Evan@653
|
21 |
* |
|
Evan@653
|
22 |
* You should have received a copy of the GNU General Public License |
|
Evan@653
|
23 |
* along with this program; if not, write to the Free Software |
|
Evan@653
|
24 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
Evan@653
|
25 |
*/ |
|
Evan@653
|
26 |
#ifndef _PURPLE_POUNCE_H_ |
|
Evan@653
|
27 |
#define _PURPLE_POUNCE_H_ |
|
Evan@653
|
28 |
|
|
Evan@653
|
29 |
typedef struct _PurplePounce PurplePounce; |
|
Evan@653
|
30 |
|
|
Evan@653
|
31 |
#include <glib.h> |
|
Evan@653
|
32 |
#include "account.h" |
|
Evan@653
|
33 |
|
|
Evan@653
|
34 |
/** |
|
Evan@653
|
35 |
* Events that trigger buddy pounces. |
|
Evan@653
|
36 |
*/ |
|
Evan@653
|
37 |
typedef enum |
|
Evan@653
|
38 |
{ |
|
Evan@653
|
39 |
PURPLE_POUNCE_NONE = 0x000, /**< No events. */ |
|
Evan@653
|
40 |
PURPLE_POUNCE_SIGNON = 0x001, /**< The buddy signed on. */ |
|
Evan@653
|
41 |
PURPLE_POUNCE_SIGNOFF = 0x002, /**< The buddy signed off. */ |
|
Evan@653
|
42 |
PURPLE_POUNCE_AWAY = 0x004, /**< The buddy went away. */ |
|
Evan@653
|
43 |
PURPLE_POUNCE_AWAY_RETURN = 0x008, /**< The buddy returned from away. */ |
|
Evan@653
|
44 |
PURPLE_POUNCE_IDLE = 0x010, /**< The buddy became idle. */ |
|
Evan@653
|
45 |
PURPLE_POUNCE_IDLE_RETURN = 0x020, /**< The buddy is no longer idle. */ |
|
Evan@653
|
46 |
PURPLE_POUNCE_TYPING = 0x040, /**< The buddy started typing. */ |
|
Evan@653
|
47 |
PURPLE_POUNCE_TYPED = 0x080, /**< The buddy has entered text. */ |
|
Evan@653
|
48 |
PURPLE_POUNCE_TYPING_STOPPED = 0x100, /**< The buddy stopped typing. */ |
|
Evan@653
|
49 |
PURPLE_POUNCE_MESSAGE_RECEIVED = 0x200 /**< The buddy sent a message */ |
|
Evan@653
|
50 |
|
|
Evan@653
|
51 |
} PurplePounceEvent; |
|
Evan@653
|
52 |
|
|
Evan@653
|
53 |
typedef enum |
|
Evan@653
|
54 |
{ |
|
Evan@653
|
55 |
PURPLE_POUNCE_OPTION_NONE = 0x00, /**< No Option */ |
|
Evan@653
|
56 |
PURPLE_POUNCE_OPTION_AWAY = 0x01 /**< Pounce only when away */ |
|
Evan@653
|
57 |
} PurplePounceOption; |
|
Evan@653
|
58 |
|
|
Evan@653
|
59 |
/** A pounce callback. */ |
|
Evan@653
|
60 |
typedef void (*PurplePounceCb)(PurplePounce *, PurplePounceEvent, void *); |
|
Evan@653
|
61 |
|
|
Evan@653
|
62 |
/** |
|
Evan@653
|
63 |
* A buddy pounce structure. |
|
Evan@653
|
64 |
* |
|
Evan@653
|
65 |
* Buddy pounces are actions triggered by a buddy-related event. For |
|
Evan@653
|
66 |
* example, a sound can be played or an IM window opened when a buddy |
|
Evan@653
|
67 |
* signs on or returns from away. Such responses are handled in the |
|
Evan@653
|
68 |
* UI. The events themselves are done in the core. |
|
Evan@653
|
69 |
*/ |
|
Evan@653
|
70 |
struct _PurplePounce |
|
Evan@653
|
71 |
{ |
|
Evan@653
|
72 |
char *ui_type; /**< The type of UI. */ |
|
Evan@653
|
73 |
|
|
Evan@653
|
74 |
PurplePounceEvent events; /**< The event(s) to pounce on. */ |
|
Evan@653
|
75 |
PurplePounceOption options; /**< The pounce options */ |
|
Evan@653
|
76 |
PurpleAccount *pouncer; /**< The user who is pouncing. */ |
|
Evan@653
|
77 |
|
|
Evan@653
|
78 |
char *pouncee; /**< The buddy to pounce on. */ |
|
Evan@653
|
79 |
|
|
Evan@653
|
80 |
GHashTable *actions; /**< The registered actions. */ |
|
Evan@653
|
81 |
|
|
Evan@653
|
82 |
gboolean save; /**< Whether or not the pounce should |
|
Evan@653
|
83 |
be saved after activation. */ |
|
Evan@653
|
84 |
void *data; /**< Pounce-specific data. */ |
|
Evan@653
|
85 |
}; |
|
Evan@653
|
86 |
|
|
Evan@653
|
87 |
#ifdef __cplusplus |
|
Evan@653
|
88 |
extern "C" { |
|
Evan@653
|
89 |
#endif |
|
Evan@653
|
90 |
|
|
Evan@653
|
91 |
/**************************************************************************/ |
|
Evan@653
|
92 |
/** @name Buddy Pounce API */ |
|
Evan@653
|
93 |
/**************************************************************************/ |
|
Evan@653
|
94 |
/*@{*/ |
|
Evan@653
|
95 |
|
|
Evan@653
|
96 |
/** |
|
Evan@653
|
97 |
* Creates a new buddy pounce. |
|
Evan@653
|
98 |
* |
|
Evan@653
|
99 |
* @param ui_type The type of UI the pounce is for. |
|
Evan@653
|
100 |
* @param pouncer The account that will pounce. |
|
Evan@653
|
101 |
* @param pouncee The buddy to pounce on. |
|
Evan@653
|
102 |
* @param event The event(s) to pounce on. |
|
Evan@653
|
103 |
* @param option Pounce options. |
|
Evan@653
|
104 |
* |
|
Evan@653
|
105 |
* @return The new buddy pounce structure. |
|
Evan@653
|
106 |
*/ |
|
Evan@653
|
107 |
PurplePounce *purple_pounce_new(const char *ui_type, PurpleAccount *pouncer, |
|
Evan@653
|
108 |
const char *pouncee, PurplePounceEvent event, |
|
Evan@653
|
109 |
PurplePounceOption option); |
|
Evan@653
|
110 |
|
|
Evan@653
|
111 |
/** |
|
Evan@653
|
112 |
* Destroys a buddy pounce. |
|
Evan@653
|
113 |
* |
|
Evan@653
|
114 |
* @param pounce The buddy pounce. |
|
Evan@653
|
115 |
*/ |
|
Evan@653
|
116 |
void purple_pounce_destroy(PurplePounce *pounce); |
|
Evan@653
|
117 |
|
|
Evan@653
|
118 |
/** |
|
Evan@653
|
119 |
* Destroys all buddy pounces for the account |
|
Evan@653
|
120 |
* |
|
Evan@653
|
121 |
* @param account The account to remove all pounces from. |
|
Evan@653
|
122 |
*/ |
|
Evan@653
|
123 |
void purple_pounce_destroy_all_by_account(PurpleAccount *account); |
|
Evan@653
|
124 |
|
|
Evan@653
|
125 |
/** |
|
Evan@653
|
126 |
* Sets the events a pounce should watch for. |
|
Evan@653
|
127 |
* |
|
Evan@653
|
128 |
* @param pounce The buddy pounce. |
|
Evan@653
|
129 |
* @param events The events to watch for. |
|
Evan@653
|
130 |
*/ |
|
Evan@653
|
131 |
void purple_pounce_set_events(PurplePounce *pounce, PurplePounceEvent events); |
|
Evan@653
|
132 |
|
|
Evan@653
|
133 |
/** |
|
Evan@653
|
134 |
* Sets the options for a pounce. |
|
Evan@653
|
135 |
* |
|
Evan@653
|
136 |
* @param pounce The buddy pounce. |
|
Evan@653
|
137 |
* @param options The options for the pounce. |
|
Evan@653
|
138 |
*/ |
|
Evan@653
|
139 |
void purple_pounce_set_options(PurplePounce *pounce, PurplePounceOption options); |
|
Evan@653
|
140 |
|
|
Evan@653
|
141 |
/** |
|
Evan@653
|
142 |
* Sets the account that will do the pouncing. |
|
Evan@653
|
143 |
* |
|
Evan@653
|
144 |
* @param pounce The buddy pounce. |
|
Evan@653
|
145 |
* @param pouncer The account that will pounce. |
|
Evan@653
|
146 |
*/ |
|
Evan@653
|
147 |
void purple_pounce_set_pouncer(PurplePounce *pounce, PurpleAccount *pouncer); |
|
Evan@653
|
148 |
|
|
Evan@653
|
149 |
/** |
|
Evan@653
|
150 |
* Sets the buddy a pounce should pounce on. |
|
Evan@653
|
151 |
* |
|
Evan@653
|
152 |
* @param pounce The buddy pounce. |
|
Evan@653
|
153 |
* @param pouncee The buddy to pounce on. |
|
Evan@653
|
154 |
*/ |
|
Evan@653
|
155 |
void purple_pounce_set_pouncee(PurplePounce *pounce, const char *pouncee); |
|
Evan@653
|
156 |
|
|
Evan@653
|
157 |
/** |
|
Evan@653
|
158 |
* Sets whether or not the pounce should be saved after execution. |
|
Evan@653
|
159 |
* |
|
Evan@653
|
160 |
* @param pounce The buddy pounce. |
|
Evan@653
|
161 |
* @param save @c TRUE if the pounce should be saved, or @c FALSE otherwise. |
|
Evan@653
|
162 |
*/ |
|
Evan@653
|
163 |
void purple_pounce_set_save(PurplePounce *pounce, gboolean save); |
|
Evan@653
|
164 |
|
|
Evan@653
|
165 |
/** |
|
Evan@653
|
166 |
* Registers an action type for the pounce. |
|
Evan@653
|
167 |
* |
|
Evan@653
|
168 |
* @param pounce The buddy pounce. |
|
Evan@653
|
169 |
* @param name The action name. |
|
Evan@653
|
170 |
*/ |
|
Evan@653
|
171 |
void purple_pounce_action_register(PurplePounce *pounce, const char *name); |
|
Evan@653
|
172 |
|
|
Evan@653
|
173 |
/** |
|
Evan@653
|
174 |
* Enables or disables an action for a pounce. |
|
Evan@653
|
175 |
* |
|
Evan@653
|
176 |
* @param pounce The buddy pounce. |
|
Evan@653
|
177 |
* @param action The name of the action. |
|
Evan@653
|
178 |
* @param enabled The enabled state. |
|
Evan@653
|
179 |
*/ |
|
Evan@653
|
180 |
void purple_pounce_action_set_enabled(PurplePounce *pounce, const char *action, |
|
Evan@653
|
181 |
gboolean enabled); |
|
Evan@653
|
182 |
|
|
Evan@653
|
183 |
/** |
|
Evan@653
|
184 |
* Sets a value for an attribute in an action. |
|
Evan@653
|
185 |
* |
|
Evan@653
|
186 |
* If @a value is @c NULL, the value will be unset. |
|
Evan@653
|
187 |
* |
|
Evan@653
|
188 |
* @param pounce The buddy pounce. |
|
Evan@653
|
189 |
* @param action The action name. |
|
Evan@653
|
190 |
* @param attr The attribute name. |
|
Evan@653
|
191 |
* @param value The value. |
|
Evan@653
|
192 |
*/ |
|
Evan@653
|
193 |
void purple_pounce_action_set_attribute(PurplePounce *pounce, const char *action, |
|
Evan@653
|
194 |
const char *attr, const char *value); |
|
Evan@653
|
195 |
|
|
Evan@653
|
196 |
/** |
|
Evan@653
|
197 |
* Sets the pounce-specific data. |
|
Evan@653
|
198 |
* |
|
Evan@653
|
199 |
* @param pounce The buddy pounce. |
|
Evan@653
|
200 |
* @param data Data specific to the pounce. |
|
Evan@653
|
201 |
*/ |
|
Evan@653
|
202 |
void purple_pounce_set_data(PurplePounce *pounce, void *data); |
|
Evan@653
|
203 |
|
|
Evan@653
|
204 |
/** |
|
Evan@653
|
205 |
* Returns the events a pounce should watch for. |
|
Evan@653
|
206 |
* |
|
Evan@653
|
207 |
* @param pounce The buddy pounce. |
|
Evan@653
|
208 |
* |
|
Evan@653
|
209 |
* @return The events the pounce is watching for. |
|
Evan@653
|
210 |
*/ |
|
Evan@653
|
211 |
PurplePounceEvent purple_pounce_get_events(const PurplePounce *pounce); |
|
Evan@653
|
212 |
|
|
Evan@653
|
213 |
/** |
|
Evan@653
|
214 |
* Returns the options for a pounce. |
|
Evan@653
|
215 |
* |
|
Evan@653
|
216 |
* @param pounce The buddy pounce. |
|
Evan@653
|
217 |
* |
|
Evan@653
|
218 |
* @return The options for the pounce. |
|
Evan@653
|
219 |
*/ |
|
Evan@653
|
220 |
PurplePounceOption purple_pounce_get_options(const PurplePounce *pounce); |
|
Evan@653
|
221 |
|
|
Evan@653
|
222 |
/** |
|
Evan@653
|
223 |
* Returns the account that will do the pouncing. |
|
Evan@653
|
224 |
* |
|
Evan@653
|
225 |
* @param pounce The buddy pounce. |
|
Evan@653
|
226 |
* |
|
Evan@653
|
227 |
* @return The account that will pounce. |
|
Evan@653
|
228 |
*/ |
|
Evan@653
|
229 |
PurpleAccount *purple_pounce_get_pouncer(const PurplePounce *pounce); |
|
Evan@653
|
230 |
|
|
Evan@653
|
231 |
/** |
|
Evan@653
|
232 |
* Returns the buddy a pounce should pounce on. |
|
Evan@653
|
233 |
* |
|
Evan@653
|
234 |
* @param pounce The buddy pounce. |
|
Evan@653
|
235 |
* |
|
Evan@653
|
236 |
* @return The buddy to pounce on. |
|
Evan@653
|
237 |
*/ |
|
Evan@653
|
238 |
const char *purple_pounce_get_pouncee(const PurplePounce *pounce); |
|
Evan@653
|
239 |
|
|
Evan@653
|
240 |
/** |
|
Evan@653
|
241 |
* Returns whether or not the pounce should save after execution. |
|
Evan@653
|
242 |
* |
|
Evan@653
|
243 |
* @param pounce The buddy pounce. |
|
Evan@653
|
244 |
* |
|
Evan@653
|
245 |
* @return @c TRUE if the pounce should be saved after execution, or |
|
Evan@653
|
246 |
* @c FALSE otherwise. |
|
Evan@653
|
247 |
*/ |
|
Evan@653
|
248 |
gboolean purple_pounce_get_save(const PurplePounce *pounce); |
|
Evan@653
|
249 |
|
|
Evan@653
|
250 |
/** |
|
Evan@653
|
251 |
* Returns whether or not an action is enabled. |
|
Evan@653
|
252 |
* |
|
Evan@653
|
253 |
* @param pounce The buddy pounce. |
|
Evan@653
|
254 |
* @param action The action name. |
|
Evan@653
|
255 |
* |
|
Evan@653
|
256 |
* @return @c TRUE if the action is enabled, or @c FALSE otherwise. |
|
Evan@653
|
257 |
*/ |
|
Evan@653
|
258 |
gboolean purple_pounce_action_is_enabled(const PurplePounce *pounce, |
|
Evan@653
|
259 |
const char *action); |
|
Evan@653
|
260 |
|
|
Evan@653
|
261 |
/** |
|
Evan@653
|
262 |
* Returns the value for an attribute in an action. |
|
Evan@653
|
263 |
* |
|
Evan@653
|
264 |
* @param pounce The buddy pounce. |
|
Evan@653
|
265 |
* @param action The action name. |
|
Evan@653
|
266 |
* @param attr The attribute name. |
|
Evan@653
|
267 |
* |
|
Evan@653
|
268 |
* @return The attribute value, if it exists, or @c NULL. |
|
Evan@653
|
269 |
*/ |
|
Evan@653
|
270 |
const char *purple_pounce_action_get_attribute(const PurplePounce *pounce, |
|
Evan@653
|
271 |
const char *action, |
|
Evan@653
|
272 |
const char *attr); |
|
Evan@653
|
273 |
|
|
Evan@653
|
274 |
/** |
|
Evan@653
|
275 |
* Returns the pounce-specific data. |
|
Evan@653
|
276 |
* |
|
Evan@653
|
277 |
* @param pounce The buddy pounce. |
|
Evan@653
|
278 |
* |
|
Evan@653
|
279 |
* @return The data specific to a buddy pounce. |
|
Evan@653
|
280 |
*/ |
|
Evan@653
|
281 |
void *purple_pounce_get_data(const PurplePounce *pounce); |
|
Evan@653
|
282 |
|
|
Evan@653
|
283 |
/** |
|
Evan@653
|
284 |
* Executes a pounce with the specified pouncer, pouncee, and event type. |
|
Evan@653
|
285 |
* |
|
Evan@653
|
286 |
* @param pouncer The account that will do the pouncing. |
|
Evan@653
|
287 |
* @param pouncee The buddy that is being pounced. |
|
Evan@653
|
288 |
* @param events The events that triggered the pounce. |
|
Evan@653
|
289 |
*/ |
|
Evan@653
|
290 |
void purple_pounce_execute(const PurpleAccount *pouncer, const char *pouncee, |
|
Evan@653
|
291 |
PurplePounceEvent events); |
|
Evan@653
|
292 |
|
|
Evan@653
|
293 |
/*@}*/ |
|
Evan@653
|
294 |
|
|
Evan@653
|
295 |
/**************************************************************************/ |
|
Evan@653
|
296 |
/** @name Buddy Pounce Subsystem API */ |
|
Evan@653
|
297 |
/**************************************************************************/ |
|
Evan@653
|
298 |
/*@{*/ |
|
Evan@653
|
299 |
|
|
Evan@653
|
300 |
/** |
|
Evan@653
|
301 |
* Finds a pounce with the specified event(s) and buddy. |
|
Evan@653
|
302 |
* |
|
Evan@653
|
303 |
* @param pouncer The account to match against. |
|
Evan@653
|
304 |
* @param pouncee The buddy to match against. |
|
Evan@653
|
305 |
* @param events The event(s) to match against. |
|
Evan@653
|
306 |
* |
|
Evan@653
|
307 |
* @return The pounce if found, or @c NULL otherwise. |
|
Evan@653
|
308 |
*/ |
|
Evan@653
|
309 |
PurplePounce *purple_find_pounce(const PurpleAccount *pouncer, |
|
Evan@653
|
310 |
const char *pouncee, PurplePounceEvent events); |
|
Evan@653
|
311 |
|
|
Evan@653
|
312 |
|
|
Evan@653
|
313 |
/** |
|
Evan@653
|
314 |
* Loads the pounces. |
|
Evan@653
|
315 |
* |
|
Evan@653
|
316 |
* @return @c TRUE if the pounces could be loaded. |
|
Evan@653
|
317 |
*/ |
|
Evan@653
|
318 |
gboolean purple_pounces_load(void); |
|
Evan@653
|
319 |
|
|
Evan@653
|
320 |
/** |
|
Evan@653
|
321 |
* Registers a pounce handler for a UI. |
|
Evan@653
|
322 |
* |
|
Evan@653
|
323 |
* @param ui The UI name. |
|
Evan@653
|
324 |
* @param cb The callback function. |
|
Evan@653
|
325 |
* @param new_pounce The function called when a pounce is created. |
|
Evan@653
|
326 |
* @param free_pounce The function called when a pounce is freed. |
|
Evan@653
|
327 |
*/ |
|
Evan@653
|
328 |
void purple_pounces_register_handler(const char *ui, PurplePounceCb cb, |
|
Evan@653
|
329 |
void (*new_pounce)(PurplePounce *pounce), |
|
Evan@653
|
330 |
void (*free_pounce)(PurplePounce *pounce)); |
|
Evan@653
|
331 |
|
|
Evan@653
|
332 |
/** |
|
Evan@653
|
333 |
* Unregisters a pounce handle for a UI. |
|
Evan@653
|
334 |
* |
|
Evan@653
|
335 |
* @param ui The UI name. |
|
Evan@653
|
336 |
*/ |
|
Evan@653
|
337 |
void purple_pounces_unregister_handler(const char *ui); |
|
Evan@653
|
338 |
|
|
Evan@653
|
339 |
/** |
|
Evan@653
|
340 |
* Returns a list of all registered buddy pounces. |
|
Evan@653
|
341 |
* |
|
Evan@653
|
342 |
* @constreturn The list of buddy pounces. |
|
Evan@653
|
343 |
*/ |
|
Evan@653
|
344 |
GList *purple_pounces_get_all(void); |
|
Evan@653
|
345 |
|
|
Evan@653
|
346 |
/** |
|
Evan@653
|
347 |
* Returns a list of registered buddy pounces for the ui-type. |
|
Evan@653
|
348 |
* |
|
Evan@653
|
349 |
* @param ui The ID of the UI using the core. |
|
Evan@653
|
350 |
* |
|
Evan@653
|
351 |
* @return The list of buddy pounces. The list should be freed by |
|
Evan@653
|
352 |
* the caller when it's no longer used. |
|
Evan@653
|
353 |
* @since 2.1.0 |
|
Evan@653
|
354 |
*/ |
|
Evan@653
|
355 |
GList *purple_pounces_get_all_for_ui(const char *ui); |
|
Evan@653
|
356 |
|
|
Evan@653
|
357 |
/** |
|
Evan@653
|
358 |
* Returns the buddy pounce subsystem handle. |
|
Evan@653
|
359 |
* |
|
Evan@653
|
360 |
* @return The subsystem handle. |
|
Evan@653
|
361 |
*/ |
|
Evan@653
|
362 |
void *purple_pounces_get_handle(void); |
|
Evan@653
|
363 |
|
|
Evan@653
|
364 |
/** |
|
Evan@653
|
365 |
* Initializes the pounces subsystem. |
|
Evan@653
|
366 |
*/ |
|
Evan@653
|
367 |
void purple_pounces_init(void); |
|
Evan@653
|
368 |
|
|
Evan@653
|
369 |
/** |
|
Evan@653
|
370 |
* Uninitializes the pounces subsystem. |
|
Evan@653
|
371 |
*/ |
|
Evan@653
|
372 |
void purple_pounces_uninit(void); |
|
Evan@653
|
373 |
|
|
Evan@653
|
374 |
/*@}*/ |
|
Evan@653
|
375 |
|
|
Evan@653
|
376 |
#ifdef __cplusplus |
|
Evan@653
|
377 |
} |
|
Evan@653
|
378 |
#endif |
|
Evan@653
|
379 |
|
|
Evan@653
|
380 |
#endif /* _PURPLE_POUNCE_H_ */ |