comparison libpurple/pounce.c @ 15822:32c366eeeb99

sed -ie 's/gaim/purple/g'
author Sean Egan <seanegan@gmail.com>
date Mon, 19 Mar 2007 07:01:17 +0000
parents 6d8728fd3dda
children f2d8658b3a86
comparison
equal deleted inserted replaced
15821:84b0f9b23ede 15822:32c366eeeb99
1 /** 1 /**
2 * @file pounce.c Buddy Pounce API 2 * @file pounce.c Buddy Pounce API
3 * @ingroup core 3 * @ingroup core
4 * 4 *
5 * gaim 5 * purple
6 * 6 *
7 * Gaim is the legal property of its developers, whose names are too numerous 7 * Purple 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 8 * to list here. Please refer to the COPYRIGHT file distributed with this
9 * source distribution. 9 * source distribution.
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 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 12 * it under the terms of the GNU General Public License as published by
33 33
34 typedef struct 34 typedef struct
35 { 35 {
36 GString *buffer; 36 GString *buffer;
37 37
38 GaimPounce *pounce; 38 PurplePounce *pounce;
39 GaimPounceEvent events; 39 PurplePounceEvent events;
40 GaimPounceOption options; 40 PurplePounceOption options;
41 41
42 char *ui_name; 42 char *ui_name;
43 char *pouncee; 43 char *pouncee;
44 char *protocol_id; 44 char *protocol_id;
45 char *event_type; 45 char *event_type;
56 56
57 gboolean enabled; 57 gboolean enabled;
58 58
59 GHashTable *atts; 59 GHashTable *atts;
60 60
61 } GaimPounceActionData; 61 } PurplePounceActionData;
62 62
63 typedef struct 63 typedef struct
64 { 64 {
65 char *ui; 65 char *ui;
66 GaimPounceCb cb; 66 PurplePounceCb cb;
67 void (*new_pounce)(GaimPounce *); 67 void (*new_pounce)(PurplePounce *);
68 void (*free_pounce)(GaimPounce *); 68 void (*free_pounce)(PurplePounce *);
69 69
70 } GaimPounceHandler; 70 } PurplePounceHandler;
71 71
72 72
73 static GHashTable *pounce_handlers = NULL; 73 static GHashTable *pounce_handlers = NULL;
74 static GList *pounces = NULL; 74 static GList *pounces = NULL;
75 static guint save_timer = 0; 75 static guint save_timer = 0;
78 78
79 /********************************************************************* 79 /*********************************************************************
80 * Private utility functions * 80 * Private utility functions *
81 *********************************************************************/ 81 *********************************************************************/
82 82
83 static GaimPounceActionData * 83 static PurplePounceActionData *
84 find_action_data(const GaimPounce *pounce, const char *name) 84 find_action_data(const PurplePounce *pounce, const char *name)
85 { 85 {
86 GaimPounceActionData *action; 86 PurplePounceActionData *action;
87 87
88 g_return_val_if_fail(pounce != NULL, NULL); 88 g_return_val_if_fail(pounce != NULL, NULL);
89 g_return_val_if_fail(name != NULL, NULL); 89 g_return_val_if_fail(name != NULL, NULL);
90 90
91 action = g_hash_table_lookup(pounce->actions, name); 91 action = g_hash_table_lookup(pounce->actions, name);
94 } 94 }
95 95
96 static void 96 static void
97 free_action_data(gpointer data) 97 free_action_data(gpointer data)
98 { 98 {
99 GaimPounceActionData *action_data = data; 99 PurplePounceActionData *action_data = data;
100 100
101 g_free(action_data->name); 101 g_free(action_data->name);
102 102
103 g_hash_table_destroy(action_data->atts); 103 g_hash_table_destroy(action_data->atts);
104 104
127 127
128 static void 128 static void
129 action_parameter_list_to_xmlnode(gpointer key, gpointer value, gpointer user_data) 129 action_parameter_list_to_xmlnode(gpointer key, gpointer value, gpointer user_data)
130 { 130 {
131 const char *action; 131 const char *action;
132 GaimPounceActionData *action_data; 132 PurplePounceActionData *action_data;
133 xmlnode *node, *child; 133 xmlnode *node, *child;
134 134
135 action = (const char *)key; 135 action = (const char *)key;
136 action_data = (GaimPounceActionData *)value; 136 action_data = (PurplePounceActionData *)value;
137 node = (xmlnode *)user_data; 137 node = (xmlnode *)user_data;
138 138
139 if (!action_data->enabled) 139 if (!action_data->enabled)
140 return; 140 return;
141 141
162 child = xmlnode_new_child(node, "option"); 162 child = xmlnode_new_child(node, "option");
163 xmlnode_set_attrib(child, "type", type); 163 xmlnode_set_attrib(child, "type", type);
164 } 164 }
165 165
166 static xmlnode * 166 static xmlnode *
167 pounce_to_xmlnode(GaimPounce *pounce) 167 pounce_to_xmlnode(PurplePounce *pounce)
168 { 168 {
169 xmlnode *node, *child; 169 xmlnode *node, *child;
170 GaimAccount *pouncer; 170 PurpleAccount *pouncer;
171 GaimPounceEvent events; 171 PurplePounceEvent events;
172 GaimPounceOption options; 172 PurplePounceOption options;
173 173
174 pouncer = gaim_pounce_get_pouncer(pounce); 174 pouncer = purple_pounce_get_pouncer(pounce);
175 events = gaim_pounce_get_events(pounce); 175 events = purple_pounce_get_events(pounce);
176 options = gaim_pounce_get_options(pounce); 176 options = purple_pounce_get_options(pounce);
177 177
178 node = xmlnode_new("pounce"); 178 node = xmlnode_new("pounce");
179 xmlnode_set_attrib(node, "ui", pounce->ui_type); 179 xmlnode_set_attrib(node, "ui", pounce->ui_type);
180 180
181 child = xmlnode_new_child(node, "account"); 181 child = xmlnode_new_child(node, "account");
182 xmlnode_set_attrib(child, "protocol", pouncer->protocol_id); 182 xmlnode_set_attrib(child, "protocol", pouncer->protocol_id);
183 xmlnode_insert_data(child, gaim_account_get_username(pouncer), -1); 183 xmlnode_insert_data(child, purple_account_get_username(pouncer), -1);
184 184
185 child = xmlnode_new_child(node, "pouncee"); 185 child = xmlnode_new_child(node, "pouncee");
186 xmlnode_insert_data(child, gaim_pounce_get_pouncee(pounce), -1); 186 xmlnode_insert_data(child, purple_pounce_get_pouncee(pounce), -1);
187 187
188 /* Write pounce options */ 188 /* Write pounce options */
189 child = xmlnode_new_child(node, "options"); 189 child = xmlnode_new_child(node, "options");
190 if (options & GAIM_POUNCE_OPTION_AWAY) 190 if (options & PURPLE_POUNCE_OPTION_AWAY)
191 add_option_to_xmlnode(child, "on-away"); 191 add_option_to_xmlnode(child, "on-away");
192 192
193 /* Write pounce events */ 193 /* Write pounce events */
194 child = xmlnode_new_child(node, "events"); 194 child = xmlnode_new_child(node, "events");
195 if (events & GAIM_POUNCE_SIGNON) 195 if (events & PURPLE_POUNCE_SIGNON)
196 add_event_to_xmlnode(child, "sign-on"); 196 add_event_to_xmlnode(child, "sign-on");
197 if (events & GAIM_POUNCE_SIGNOFF) 197 if (events & PURPLE_POUNCE_SIGNOFF)
198 add_event_to_xmlnode(child, "sign-off"); 198 add_event_to_xmlnode(child, "sign-off");
199 if (events & GAIM_POUNCE_AWAY) 199 if (events & PURPLE_POUNCE_AWAY)
200 add_event_to_xmlnode(child, "away"); 200 add_event_to_xmlnode(child, "away");
201 if (events & GAIM_POUNCE_AWAY_RETURN) 201 if (events & PURPLE_POUNCE_AWAY_RETURN)
202 add_event_to_xmlnode(child, "return-from-away"); 202 add_event_to_xmlnode(child, "return-from-away");
203 if (events & GAIM_POUNCE_IDLE) 203 if (events & PURPLE_POUNCE_IDLE)
204 add_event_to_xmlnode(child, "idle"); 204 add_event_to_xmlnode(child, "idle");
205 if (events & GAIM_POUNCE_IDLE_RETURN) 205 if (events & PURPLE_POUNCE_IDLE_RETURN)
206 add_event_to_xmlnode(child, "return-from-idle"); 206 add_event_to_xmlnode(child, "return-from-idle");
207 if (events & GAIM_POUNCE_TYPING) 207 if (events & PURPLE_POUNCE_TYPING)
208 add_event_to_xmlnode(child, "start-typing"); 208 add_event_to_xmlnode(child, "start-typing");
209 if (events & GAIM_POUNCE_TYPED) 209 if (events & PURPLE_POUNCE_TYPED)
210 add_event_to_xmlnode(child, "typed"); 210 add_event_to_xmlnode(child, "typed");
211 if (events & GAIM_POUNCE_TYPING_STOPPED) 211 if (events & PURPLE_POUNCE_TYPING_STOPPED)
212 add_event_to_xmlnode(child, "stop-typing"); 212 add_event_to_xmlnode(child, "stop-typing");
213 if (events & GAIM_POUNCE_MESSAGE_RECEIVED) 213 if (events & PURPLE_POUNCE_MESSAGE_RECEIVED)
214 add_event_to_xmlnode(child, "message-received"); 214 add_event_to_xmlnode(child, "message-received");
215 215
216 /* Write pounce actions */ 216 /* Write pounce actions */
217 child = xmlnode_new_child(node, "actions"); 217 child = xmlnode_new_child(node, "actions");
218 g_hash_table_foreach(pounce->actions, action_parameter_list_to_xmlnode, child); 218 g_hash_table_foreach(pounce->actions, action_parameter_list_to_xmlnode, child);
219 219
220 if (gaim_pounce_get_save(pounce)) 220 if (purple_pounce_get_save(pounce))
221 child = xmlnode_new_child(node, "save"); 221 child = xmlnode_new_child(node, "save");
222 222
223 return node; 223 return node;
224 } 224 }
225 225
230 GList *cur; 230 GList *cur;
231 231
232 node = xmlnode_new("pounces"); 232 node = xmlnode_new("pounces");
233 xmlnode_set_attrib(node, "version", "1.0"); 233 xmlnode_set_attrib(node, "version", "1.0");
234 234
235 for (cur = gaim_pounces_get_all(); cur != NULL; cur = cur->next) 235 for (cur = purple_pounces_get_all(); cur != NULL; cur = cur->next)
236 { 236 {
237 child = pounce_to_xmlnode(cur->data); 237 child = pounce_to_xmlnode(cur->data);
238 xmlnode_insert_child(node, child); 238 xmlnode_insert_child(node, child);
239 } 239 }
240 240
247 xmlnode *node; 247 xmlnode *node;
248 char *data; 248 char *data;
249 249
250 if (!pounces_loaded) 250 if (!pounces_loaded)
251 { 251 {
252 gaim_debug_error("pounce", "Attempted to save buddy pounces before " 252 purple_debug_error("pounce", "Attempted to save buddy pounces before "
253 "they were read!\n"); 253 "they were read!\n");
254 return; 254 return;
255 } 255 }
256 256
257 node = pounces_to_xmlnode(); 257 node = pounces_to_xmlnode();
258 data = xmlnode_to_formatted_str(node, NULL); 258 data = xmlnode_to_formatted_str(node, NULL);
259 gaim_util_write_data_to_file("pounces.xml", data, -1); 259 purple_util_write_data_to_file("pounces.xml", data, -1);
260 g_free(data); 260 g_free(data);
261 xmlnode_free(node); 261 xmlnode_free(node);
262 } 262 }
263 263
264 static gboolean 264 static gboolean
271 271
272 static void 272 static void
273 schedule_pounces_save(void) 273 schedule_pounces_save(void)
274 { 274 {
275 if (save_timer == 0) 275 if (save_timer == 0)
276 save_timer = gaim_timeout_add(5000, save_cb, NULL); 276 save_timer = purple_timeout_add(5000, save_cb, NULL);
277 } 277 }
278 278
279 279
280 /********************************************************************* 280 /*********************************************************************
281 * Reading from disk * 281 * Reading from disk *
326 326
327 if (!strcmp(element_name, "pounce")) { 327 if (!strcmp(element_name, "pounce")) {
328 const char *ui = g_hash_table_lookup(atts, "ui"); 328 const char *ui = g_hash_table_lookup(atts, "ui");
329 329
330 if (ui == NULL) { 330 if (ui == NULL) {
331 gaim_debug(GAIM_DEBUG_ERROR, "pounce", 331 purple_debug(PURPLE_DEBUG_ERROR, "pounce",
332 "Unset 'ui' parameter for pounce!\n"); 332 "Unset 'ui' parameter for pounce!\n");
333 } 333 }
334 else 334 else
335 data->ui_name = g_strdup(ui); 335 data->ui_name = g_strdup(ui);
336 336
338 } 338 }
339 else if (!strcmp(element_name, "account")) { 339 else if (!strcmp(element_name, "account")) {
340 const char *protocol_id = g_hash_table_lookup(atts, "protocol"); 340 const char *protocol_id = g_hash_table_lookup(atts, "protocol");
341 341
342 if (protocol_id == NULL) { 342 if (protocol_id == NULL) {
343 gaim_debug(GAIM_DEBUG_ERROR, "pounce", 343 purple_debug(PURPLE_DEBUG_ERROR, "pounce",
344 "Unset 'protocol' parameter for account!\n"); 344 "Unset 'protocol' parameter for account!\n");
345 } 345 }
346 else 346 else
347 data->protocol_id = g_strdup(protocol_id); 347 data->protocol_id = g_strdup(protocol_id);
348 } 348 }
349 else if (!strcmp(element_name, "option")) { 349 else if (!strcmp(element_name, "option")) {
350 const char *type = g_hash_table_lookup(atts, "type"); 350 const char *type = g_hash_table_lookup(atts, "type");
351 351
352 if (type == NULL) { 352 if (type == NULL) {
353 gaim_debug(GAIM_DEBUG_ERROR, "pounce", 353 purple_debug(PURPLE_DEBUG_ERROR, "pounce",
354 "Unset 'type' parameter for option!\n"); 354 "Unset 'type' parameter for option!\n");
355 } 355 }
356 else 356 else
357 data->option_type = g_strdup(type); 357 data->option_type = g_strdup(type);
358 } 358 }
359 else if (!strcmp(element_name, "event")) { 359 else if (!strcmp(element_name, "event")) {
360 const char *type = g_hash_table_lookup(atts, "type"); 360 const char *type = g_hash_table_lookup(atts, "type");
361 361
362 if (type == NULL) { 362 if (type == NULL) {
363 gaim_debug(GAIM_DEBUG_ERROR, "pounce", 363 purple_debug(PURPLE_DEBUG_ERROR, "pounce",
364 "Unset 'type' parameter for event!\n"); 364 "Unset 'type' parameter for event!\n");
365 } 365 }
366 else 366 else
367 data->event_type = g_strdup(type); 367 data->event_type = g_strdup(type);
368 } 368 }
369 else if (!strcmp(element_name, "action")) { 369 else if (!strcmp(element_name, "action")) {
370 const char *type = g_hash_table_lookup(atts, "type"); 370 const char *type = g_hash_table_lookup(atts, "type");
371 371
372 if (type == NULL) { 372 if (type == NULL) {
373 gaim_debug(GAIM_DEBUG_ERROR, "pounce", 373 purple_debug(PURPLE_DEBUG_ERROR, "pounce",
374 "Unset 'type' parameter for action!\n"); 374 "Unset 'type' parameter for action!\n");
375 } 375 }
376 else 376 else
377 data->action_name = g_strdup(type); 377 data->action_name = g_strdup(type);
378 } 378 }
379 else if (!strcmp(element_name, "param")) { 379 else if (!strcmp(element_name, "param")) {
380 const char *param_name = g_hash_table_lookup(atts, "name"); 380 const char *param_name = g_hash_table_lookup(atts, "name");
381 381
382 if (param_name == NULL) { 382 if (param_name == NULL) {
383 gaim_debug(GAIM_DEBUG_ERROR, "pounce", 383 purple_debug(PURPLE_DEBUG_ERROR, "pounce",
384 "Unset 'name' parameter for param!\n"); 384 "Unset 'name' parameter for param!\n");
385 } 385 }
386 else 386 else
387 data->param_name = g_strdup(param_name); 387 data->param_name = g_strdup(param_name);
388 } 388 }
405 if (!strcmp(element_name, "account")) { 405 if (!strcmp(element_name, "account")) {
406 char *tmp; 406 char *tmp;
407 g_free(data->account_name); 407 g_free(data->account_name);
408 data->account_name = g_strdup(buffer); 408 data->account_name = g_strdup(buffer);
409 tmp = data->protocol_id; 409 tmp = data->protocol_id;
410 data->protocol_id = g_strdup(_gaim_oscar_convert(buffer, tmp)); 410 data->protocol_id = g_strdup(_purple_oscar_convert(buffer, tmp));
411 g_free(tmp); 411 g_free(tmp);
412 } 412 }
413 else if (!strcmp(element_name, "pouncee")) { 413 else if (!strcmp(element_name, "pouncee")) {
414 g_free(data->pouncee); 414 g_free(data->pouncee);
415 data->pouncee = g_strdup(buffer); 415 data->pouncee = g_strdup(buffer);
416 } 416 }
417 else if (!strcmp(element_name, "option")) { 417 else if (!strcmp(element_name, "option")) {
418 if (!strcmp(data->option_type, "on-away")) 418 if (!strcmp(data->option_type, "on-away"))
419 data->options |= GAIM_POUNCE_OPTION_AWAY; 419 data->options |= PURPLE_POUNCE_OPTION_AWAY;
420 420
421 g_free(data->option_type); 421 g_free(data->option_type);
422 data->option_type = NULL; 422 data->option_type = NULL;
423 } 423 }
424 else if (!strcmp(element_name, "event")) { 424 else if (!strcmp(element_name, "event")) {
425 if (!strcmp(data->event_type, "sign-on")) 425 if (!strcmp(data->event_type, "sign-on"))
426 data->events |= GAIM_POUNCE_SIGNON; 426 data->events |= PURPLE_POUNCE_SIGNON;
427 else if (!strcmp(data->event_type, "sign-off")) 427 else if (!strcmp(data->event_type, "sign-off"))
428 data->events |= GAIM_POUNCE_SIGNOFF; 428 data->events |= PURPLE_POUNCE_SIGNOFF;
429 else if (!strcmp(data->event_type, "away")) 429 else if (!strcmp(data->event_type, "away"))
430 data->events |= GAIM_POUNCE_AWAY; 430 data->events |= PURPLE_POUNCE_AWAY;
431 else if (!strcmp(data->event_type, "return-from-away")) 431 else if (!strcmp(data->event_type, "return-from-away"))
432 data->events |= GAIM_POUNCE_AWAY_RETURN; 432 data->events |= PURPLE_POUNCE_AWAY_RETURN;
433 else if (!strcmp(data->event_type, "idle")) 433 else if (!strcmp(data->event_type, "idle"))
434 data->events |= GAIM_POUNCE_IDLE; 434 data->events |= PURPLE_POUNCE_IDLE;
435 else if (!strcmp(data->event_type, "return-from-idle")) 435 else if (!strcmp(data->event_type, "return-from-idle"))
436 data->events |= GAIM_POUNCE_IDLE_RETURN; 436 data->events |= PURPLE_POUNCE_IDLE_RETURN;
437 else if (!strcmp(data->event_type, "start-typing")) 437 else if (!strcmp(data->event_type, "start-typing"))
438 data->events |= GAIM_POUNCE_TYPING; 438 data->events |= PURPLE_POUNCE_TYPING;
439 else if (!strcmp(data->event_type, "typed")) 439 else if (!strcmp(data->event_type, "typed"))
440 data->events |= GAIM_POUNCE_TYPED; 440 data->events |= PURPLE_POUNCE_TYPED;
441 else if (!strcmp(data->event_type, "stop-typing")) 441 else if (!strcmp(data->event_type, "stop-typing"))
442 data->events |= GAIM_POUNCE_TYPING_STOPPED; 442 data->events |= PURPLE_POUNCE_TYPING_STOPPED;
443 else if (!strcmp(data->event_type, "message-received")) 443 else if (!strcmp(data->event_type, "message-received"))
444 data->events |= GAIM_POUNCE_MESSAGE_RECEIVED; 444 data->events |= PURPLE_POUNCE_MESSAGE_RECEIVED;
445 445
446 g_free(data->event_type); 446 g_free(data->event_type);
447 data->event_type = NULL; 447 data->event_type = NULL;
448 } 448 }
449 else if (!strcmp(element_name, "action")) { 449 else if (!strcmp(element_name, "action")) {
450 if (data->pounce != NULL) { 450 if (data->pounce != NULL) {
451 gaim_pounce_action_register(data->pounce, data->action_name); 451 purple_pounce_action_register(data->pounce, data->action_name);
452 gaim_pounce_action_set_enabled(data->pounce, data->action_name, TRUE); 452 purple_pounce_action_set_enabled(data->pounce, data->action_name, TRUE);
453 } 453 }
454 454
455 g_free(data->action_name); 455 g_free(data->action_name);
456 data->action_name = NULL; 456 data->action_name = NULL;
457 } 457 }
458 else if (!strcmp(element_name, "param")) { 458 else if (!strcmp(element_name, "param")) {
459 if (data->pounce != NULL) { 459 if (data->pounce != NULL) {
460 gaim_pounce_action_set_attribute(data->pounce, data->action_name, 460 purple_pounce_action_set_attribute(data->pounce, data->action_name,
461 data->param_name, buffer); 461 data->param_name, buffer);
462 } 462 }
463 463
464 g_free(data->param_name); 464 g_free(data->param_name);
465 data->param_name = NULL; 465 data->param_name = NULL;
466 } 466 }
467 else if (!strcmp(element_name, "events")) { 467 else if (!strcmp(element_name, "events")) {
468 GaimAccount *account; 468 PurpleAccount *account;
469 469
470 account = gaim_accounts_find(data->account_name, data->protocol_id); 470 account = purple_accounts_find(data->account_name, data->protocol_id);
471 471
472 g_free(data->account_name); 472 g_free(data->account_name);
473 g_free(data->protocol_id); 473 g_free(data->protocol_id);
474 474
475 data->account_name = NULL; 475 data->account_name = NULL;
476 data->protocol_id = NULL; 476 data->protocol_id = NULL;
477 477
478 if (account == NULL) { 478 if (account == NULL) {
479 gaim_debug(GAIM_DEBUG_ERROR, "pounce", 479 purple_debug(PURPLE_DEBUG_ERROR, "pounce",
480 "Account for pounce not found!\n"); 480 "Account for pounce not found!\n");
481 /* 481 /*
482 * This pounce has effectively been removed, so make 482 * This pounce has effectively been removed, so make
483 * sure that we save the changes to pounces.xml 483 * sure that we save the changes to pounces.xml
484 */ 484 */
485 schedule_pounces_save(); 485 schedule_pounces_save();
486 } 486 }
487 else { 487 else {
488 gaim_debug(GAIM_DEBUG_INFO, "pounce", 488 purple_debug(PURPLE_DEBUG_INFO, "pounce",
489 "Creating pounce: %s, %s\n", data->ui_name, 489 "Creating pounce: %s, %s\n", data->ui_name,
490 data->pouncee); 490 data->pouncee);
491 491
492 data->pounce = gaim_pounce_new(data->ui_name, account, 492 data->pounce = purple_pounce_new(data->ui_name, account,
493 data->pouncee, data->events, 493 data->pouncee, data->events,
494 data->options); 494 data->options);
495 } 495 }
496 496
497 g_free(data->pouncee); 497 g_free(data->pouncee);
498 data->pouncee = NULL; 498 data->pouncee = NULL;
499 } 499 }
500 else if (!strcmp(element_name, "save")) { 500 else if (!strcmp(element_name, "save")) {
501 if (data->pounce != NULL) 501 if (data->pounce != NULL)
502 gaim_pounce_set_save(data->pounce, TRUE); 502 purple_pounce_set_save(data->pounce, TRUE);
503 } 503 }
504 else if (!strcmp(element_name, "pounce")) { 504 else if (!strcmp(element_name, "pounce")) {
505 data->pounce = NULL; 505 data->pounce = NULL;
506 data->events = 0; 506 data->events = 0;
507 data->options = 0; 507 data->options = 0;
548 NULL, 548 NULL,
549 NULL 549 NULL
550 }; 550 };
551 551
552 gboolean 552 gboolean
553 gaim_pounces_load(void) 553 purple_pounces_load(void)
554 { 554 {
555 gchar *filename = g_build_filename(gaim_user_dir(), "pounces.xml", NULL); 555 gchar *filename = g_build_filename(purple_user_dir(), "pounces.xml", NULL);
556 gchar *contents = NULL; 556 gchar *contents = NULL;
557 gsize length; 557 gsize length;
558 GMarkupParseContext *context; 558 GMarkupParseContext *context;
559 GError *error = NULL; 559 GError *error = NULL;
560 PounceParserData *parser_data; 560 PounceParserData *parser_data;
563 pounces_loaded = TRUE; 563 pounces_loaded = TRUE;
564 return FALSE; 564 return FALSE;
565 } 565 }
566 566
567 if (!g_file_get_contents(filename, &contents, &length, &error)) { 567 if (!g_file_get_contents(filename, &contents, &length, &error)) {
568 gaim_debug(GAIM_DEBUG_ERROR, "pounce", 568 purple_debug(PURPLE_DEBUG_ERROR, "pounce",
569 "Error reading pounces: %s\n", error->message); 569 "Error reading pounces: %s\n", error->message);
570 570
571 g_free(filename); 571 g_free(filename);
572 g_error_free(error); 572 g_error_free(error);
573 573
589 589
590 return FALSE; 590 return FALSE;
591 } 591 }
592 592
593 if (!g_markup_parse_context_end_parse(context, NULL)) { 593 if (!g_markup_parse_context_end_parse(context, NULL)) {
594 gaim_debug(GAIM_DEBUG_ERROR, "pounce", "Error parsing %s\n", 594 purple_debug(PURPLE_DEBUG_ERROR, "pounce", "Error parsing %s\n",
595 filename); 595 filename);
596 596
597 g_markup_parse_context_free(context); 597 g_markup_parse_context_free(context);
598 g_free(contents); 598 g_free(contents);
599 g_free(filename); 599 g_free(filename);
610 610
611 return TRUE; 611 return TRUE;
612 } 612 }
613 613
614 614
615 GaimPounce * 615 PurplePounce *
616 gaim_pounce_new(const char *ui_type, GaimAccount *pouncer, 616 purple_pounce_new(const char *ui_type, PurpleAccount *pouncer,
617 const char *pouncee, GaimPounceEvent event, 617 const char *pouncee, PurplePounceEvent event,
618 GaimPounceOption option) 618 PurplePounceOption option)
619 { 619 {
620 GaimPounce *pounce; 620 PurplePounce *pounce;
621 GaimPounceHandler *handler; 621 PurplePounceHandler *handler;
622 622
623 g_return_val_if_fail(ui_type != NULL, NULL); 623 g_return_val_if_fail(ui_type != NULL, NULL);
624 g_return_val_if_fail(pouncer != NULL, NULL); 624 g_return_val_if_fail(pouncer != NULL, NULL);
625 g_return_val_if_fail(pouncee != NULL, NULL); 625 g_return_val_if_fail(pouncee != NULL, NULL);
626 g_return_val_if_fail(event != 0, NULL); 626 g_return_val_if_fail(event != 0, NULL);
627 627
628 pounce = g_new0(GaimPounce, 1); 628 pounce = g_new0(PurplePounce, 1);
629 629
630 pounce->ui_type = g_strdup(ui_type); 630 pounce->ui_type = g_strdup(ui_type);
631 pounce->pouncer = pouncer; 631 pounce->pouncer = pouncer;
632 pounce->pouncee = g_strdup(pouncee); 632 pounce->pouncee = g_strdup(pouncee);
633 pounce->events = event; 633 pounce->events = event;
647 647
648 return pounce; 648 return pounce;
649 } 649 }
650 650
651 void 651 void
652 gaim_pounce_destroy(GaimPounce *pounce) 652 purple_pounce_destroy(PurplePounce *pounce)
653 { 653 {
654 GaimPounceHandler *handler; 654 PurplePounceHandler *handler;
655 655
656 g_return_if_fail(pounce != NULL); 656 g_return_if_fail(pounce != NULL);
657 657
658 handler = g_hash_table_lookup(pounce_handlers, pounce->ui_type); 658 handler = g_hash_table_lookup(pounce_handlers, pounce->ui_type);
659 659
671 671
672 schedule_pounces_save(); 672 schedule_pounces_save();
673 } 673 }
674 674
675 void 675 void
676 gaim_pounce_destroy_all_by_account(GaimAccount *account) 676 purple_pounce_destroy_all_by_account(PurpleAccount *account)
677 { 677 {
678 GaimAccount *pouncer; 678 PurpleAccount *pouncer;
679 GaimPounce *pounce; 679 PurplePounce *pounce;
680 GList *l, *l_next; 680 GList *l, *l_next;
681 681
682 g_return_if_fail(account != NULL); 682 g_return_if_fail(account != NULL);
683 683
684 for (l = gaim_pounces_get_all(); l != NULL; l = l_next) 684 for (l = purple_pounces_get_all(); l != NULL; l = l_next)
685 { 685 {
686 pounce = (GaimPounce *)l->data; 686 pounce = (PurplePounce *)l->data;
687 l_next = l->next; 687 l_next = l->next;
688 688
689 pouncer = gaim_pounce_get_pouncer(pounce); 689 pouncer = purple_pounce_get_pouncer(pounce);
690 if (pouncer == account) 690 if (pouncer == account)
691 gaim_pounce_destroy(pounce); 691 purple_pounce_destroy(pounce);
692 } 692 }
693 } 693 }
694 694
695 void 695 void
696 gaim_pounce_set_events(GaimPounce *pounce, GaimPounceEvent events) 696 purple_pounce_set_events(PurplePounce *pounce, PurplePounceEvent events)
697 { 697 {
698 g_return_if_fail(pounce != NULL); 698 g_return_if_fail(pounce != NULL);
699 g_return_if_fail(events != GAIM_POUNCE_NONE); 699 g_return_if_fail(events != PURPLE_POUNCE_NONE);
700 700
701 pounce->events = events; 701 pounce->events = events;
702 702
703 schedule_pounces_save(); 703 schedule_pounces_save();
704 } 704 }
705 705
706 void 706 void
707 gaim_pounce_set_options(GaimPounce *pounce, GaimPounceOption options) 707 purple_pounce_set_options(PurplePounce *pounce, PurplePounceOption options)
708 { 708 {
709 g_return_if_fail(pounce != NULL); 709 g_return_if_fail(pounce != NULL);
710 710
711 pounce->options = options; 711 pounce->options = options;
712 712
713 schedule_pounces_save(); 713 schedule_pounces_save();
714 } 714 }
715 715
716 void 716 void
717 gaim_pounce_set_pouncer(GaimPounce *pounce, GaimAccount *pouncer) 717 purple_pounce_set_pouncer(PurplePounce *pounce, PurpleAccount *pouncer)
718 { 718 {
719 g_return_if_fail(pounce != NULL); 719 g_return_if_fail(pounce != NULL);
720 g_return_if_fail(pouncer != NULL); 720 g_return_if_fail(pouncer != NULL);
721 721
722 pounce->pouncer = pouncer; 722 pounce->pouncer = pouncer;
723 723
724 schedule_pounces_save(); 724 schedule_pounces_save();
725 } 725 }
726 726
727 void 727 void
728 gaim_pounce_set_pouncee(GaimPounce *pounce, const char *pouncee) 728 purple_pounce_set_pouncee(PurplePounce *pounce, const char *pouncee)
729 { 729 {
730 g_return_if_fail(pounce != NULL); 730 g_return_if_fail(pounce != NULL);
731 g_return_if_fail(pouncee != NULL); 731 g_return_if_fail(pouncee != NULL);
732 732
733 g_free(pounce->pouncee); 733 g_free(pounce->pouncee);
735 735
736 schedule_pounces_save(); 736 schedule_pounces_save();
737 } 737 }
738 738
739 void 739 void
740 gaim_pounce_set_save(GaimPounce *pounce, gboolean save) 740 purple_pounce_set_save(PurplePounce *pounce, gboolean save)
741 { 741 {
742 g_return_if_fail(pounce != NULL); 742 g_return_if_fail(pounce != NULL);
743 743
744 pounce->save = save; 744 pounce->save = save;
745 745
746 schedule_pounces_save(); 746 schedule_pounces_save();
747 } 747 }
748 748
749 void 749 void
750 gaim_pounce_action_register(GaimPounce *pounce, const char *name) 750 purple_pounce_action_register(PurplePounce *pounce, const char *name)
751 { 751 {
752 GaimPounceActionData *action_data; 752 PurplePounceActionData *action_data;
753 753
754 g_return_if_fail(pounce != NULL); 754 g_return_if_fail(pounce != NULL);
755 g_return_if_fail(name != NULL); 755 g_return_if_fail(name != NULL);
756 756
757 if (g_hash_table_lookup(pounce->actions, name) != NULL) 757 if (g_hash_table_lookup(pounce->actions, name) != NULL)
758 return; 758 return;
759 759
760 action_data = g_new0(GaimPounceActionData, 1); 760 action_data = g_new0(PurplePounceActionData, 1);
761 761
762 action_data->name = g_strdup(name); 762 action_data->name = g_strdup(name);
763 action_data->enabled = FALSE; 763 action_data->enabled = FALSE;
764 action_data->atts = g_hash_table_new_full(g_str_hash, g_str_equal, 764 action_data->atts = g_hash_table_new_full(g_str_hash, g_str_equal,
765 g_free, g_free); 765 g_free, g_free);
768 768
769 schedule_pounces_save(); 769 schedule_pounces_save();
770 } 770 }
771 771
772 void 772 void
773 gaim_pounce_action_set_enabled(GaimPounce *pounce, const char *action, 773 purple_pounce_action_set_enabled(PurplePounce *pounce, const char *action,
774 gboolean enabled) 774 gboolean enabled)
775 { 775 {
776 GaimPounceActionData *action_data; 776 PurplePounceActionData *action_data;
777 777
778 g_return_if_fail(pounce != NULL); 778 g_return_if_fail(pounce != NULL);
779 g_return_if_fail(action != NULL); 779 g_return_if_fail(action != NULL);
780 780
781 action_data = find_action_data(pounce, action); 781 action_data = find_action_data(pounce, action);
786 786
787 schedule_pounces_save(); 787 schedule_pounces_save();
788 } 788 }
789 789
790 void 790 void
791 gaim_pounce_action_set_attribute(GaimPounce *pounce, const char *action, 791 purple_pounce_action_set_attribute(PurplePounce *pounce, const char *action,
792 const char *attr, const char *value) 792 const char *attr, const char *value)
793 { 793 {
794 GaimPounceActionData *action_data; 794 PurplePounceActionData *action_data;
795 795
796 g_return_if_fail(pounce != NULL); 796 g_return_if_fail(pounce != NULL);
797 g_return_if_fail(action != NULL); 797 g_return_if_fail(action != NULL);
798 g_return_if_fail(attr != NULL); 798 g_return_if_fail(attr != NULL);
799 799
809 809
810 schedule_pounces_save(); 810 schedule_pounces_save();
811 } 811 }
812 812
813 void 813 void
814 gaim_pounce_set_data(GaimPounce *pounce, void *data) 814 purple_pounce_set_data(PurplePounce *pounce, void *data)
815 { 815 {
816 g_return_if_fail(pounce != NULL); 816 g_return_if_fail(pounce != NULL);
817 817
818 pounce->data = data; 818 pounce->data = data;
819 819
820 schedule_pounces_save(); 820 schedule_pounces_save();
821 } 821 }
822 822
823 GaimPounceEvent 823 PurplePounceEvent
824 gaim_pounce_get_events(const GaimPounce *pounce) 824 purple_pounce_get_events(const PurplePounce *pounce)
825 { 825 {
826 g_return_val_if_fail(pounce != NULL, GAIM_POUNCE_NONE); 826 g_return_val_if_fail(pounce != NULL, PURPLE_POUNCE_NONE);
827 827
828 return pounce->events; 828 return pounce->events;
829 } 829 }
830 830
831 GaimPounceOption 831 PurplePounceOption
832 gaim_pounce_get_options(const GaimPounce *pounce) 832 purple_pounce_get_options(const PurplePounce *pounce)
833 { 833 {
834 g_return_val_if_fail(pounce != NULL, GAIM_POUNCE_OPTION_NONE); 834 g_return_val_if_fail(pounce != NULL, PURPLE_POUNCE_OPTION_NONE);
835 835
836 return pounce->options; 836 return pounce->options;
837 } 837 }
838 838
839 GaimAccount * 839 PurpleAccount *
840 gaim_pounce_get_pouncer(const GaimPounce *pounce) 840 purple_pounce_get_pouncer(const PurplePounce *pounce)
841 { 841 {
842 g_return_val_if_fail(pounce != NULL, NULL); 842 g_return_val_if_fail(pounce != NULL, NULL);
843 843
844 return pounce->pouncer; 844 return pounce->pouncer;
845 } 845 }
846 846
847 const char * 847 const char *
848 gaim_pounce_get_pouncee(const GaimPounce *pounce) 848 purple_pounce_get_pouncee(const PurplePounce *pounce)
849 { 849 {
850 g_return_val_if_fail(pounce != NULL, NULL); 850 g_return_val_if_fail(pounce != NULL, NULL);
851 851
852 return pounce->pouncee; 852 return pounce->pouncee;
853 } 853 }
854 854
855 gboolean 855 gboolean
856 gaim_pounce_get_save(const GaimPounce *pounce) 856 purple_pounce_get_save(const PurplePounce *pounce)
857 { 857 {
858 g_return_val_if_fail(pounce != NULL, FALSE); 858 g_return_val_if_fail(pounce != NULL, FALSE);
859 859
860 return pounce->save; 860 return pounce->save;
861 } 861 }
862 862
863 gboolean 863 gboolean
864 gaim_pounce_action_is_enabled(const GaimPounce *pounce, const char *action) 864 purple_pounce_action_is_enabled(const PurplePounce *pounce, const char *action)
865 { 865 {
866 GaimPounceActionData *action_data; 866 PurplePounceActionData *action_data;
867 867
868 g_return_val_if_fail(pounce != NULL, FALSE); 868 g_return_val_if_fail(pounce != NULL, FALSE);
869 g_return_val_if_fail(action != NULL, FALSE); 869 g_return_val_if_fail(action != NULL, FALSE);
870 870
871 action_data = find_action_data(pounce, action); 871 action_data = find_action_data(pounce, action);
874 874
875 return action_data->enabled; 875 return action_data->enabled;
876 } 876 }
877 877
878 const char * 878 const char *
879 gaim_pounce_action_get_attribute(const GaimPounce *pounce, 879 purple_pounce_action_get_attribute(const PurplePounce *pounce,
880 const char *action, const char *attr) 880 const char *action, const char *attr)
881 { 881 {
882 GaimPounceActionData *action_data; 882 PurplePounceActionData *action_data;
883 883
884 g_return_val_if_fail(pounce != NULL, NULL); 884 g_return_val_if_fail(pounce != NULL, NULL);
885 g_return_val_if_fail(action != NULL, NULL); 885 g_return_val_if_fail(action != NULL, NULL);
886 g_return_val_if_fail(attr != NULL, NULL); 886 g_return_val_if_fail(attr != NULL, NULL);
887 887
891 891
892 return g_hash_table_lookup(action_data->atts, attr); 892 return g_hash_table_lookup(action_data->atts, attr);
893 } 893 }
894 894
895 void * 895 void *
896 gaim_pounce_get_data(const GaimPounce *pounce) 896 purple_pounce_get_data(const PurplePounce *pounce)
897 { 897 {
898 g_return_val_if_fail(pounce != NULL, NULL); 898 g_return_val_if_fail(pounce != NULL, NULL);
899 899
900 return pounce->data; 900 return pounce->data;
901 } 901 }
902 902
903 void 903 void
904 gaim_pounce_execute(const GaimAccount *pouncer, const char *pouncee, 904 purple_pounce_execute(const PurpleAccount *pouncer, const char *pouncee,
905 GaimPounceEvent events) 905 PurplePounceEvent events)
906 { 906 {
907 GaimPounce *pounce; 907 PurplePounce *pounce;
908 GaimPounceHandler *handler; 908 PurplePounceHandler *handler;
909 GaimPresence *presence; 909 PurplePresence *presence;
910 GList *l, *l_next; 910 GList *l, *l_next;
911 char *norm_pouncee; 911 char *norm_pouncee;
912 912
913 g_return_if_fail(pouncer != NULL); 913 g_return_if_fail(pouncer != NULL);
914 g_return_if_fail(pouncee != NULL); 914 g_return_if_fail(pouncee != NULL);
915 g_return_if_fail(events != GAIM_POUNCE_NONE); 915 g_return_if_fail(events != PURPLE_POUNCE_NONE);
916 916
917 norm_pouncee = g_strdup(gaim_normalize(pouncer, pouncee)); 917 norm_pouncee = g_strdup(purple_normalize(pouncer, pouncee));
918 918
919 for (l = gaim_pounces_get_all(); l != NULL; l = l_next) 919 for (l = purple_pounces_get_all(); l != NULL; l = l_next)
920 { 920 {
921 pounce = (GaimPounce *)l->data; 921 pounce = (PurplePounce *)l->data;
922 l_next = l->next; 922 l_next = l->next;
923 923
924 presence = gaim_account_get_presence(pouncer); 924 presence = purple_account_get_presence(pouncer);
925 925
926 if ((gaim_pounce_get_events(pounce) & events) && 926 if ((purple_pounce_get_events(pounce) & events) &&
927 (gaim_pounce_get_pouncer(pounce) == pouncer) && 927 (purple_pounce_get_pouncer(pounce) == pouncer) &&
928 !gaim_utf8_strcasecmp(gaim_normalize(pouncer, gaim_pounce_get_pouncee(pounce)), 928 !purple_utf8_strcasecmp(purple_normalize(pouncer, purple_pounce_get_pouncee(pounce)),
929 norm_pouncee) && 929 norm_pouncee) &&
930 (pounce->options == GAIM_POUNCE_OPTION_NONE || 930 (pounce->options == PURPLE_POUNCE_OPTION_NONE ||
931 (pounce->options & GAIM_POUNCE_OPTION_AWAY && 931 (pounce->options & PURPLE_POUNCE_OPTION_AWAY &&
932 !gaim_presence_is_available(presence)))) 932 !purple_presence_is_available(presence))))
933 { 933 {
934 handler = g_hash_table_lookup(pounce_handlers, pounce->ui_type); 934 handler = g_hash_table_lookup(pounce_handlers, pounce->ui_type);
935 935
936 if (handler != NULL && handler->cb != NULL) 936 if (handler != NULL && handler->cb != NULL)
937 { 937 {
938 handler->cb(pounce, events, gaim_pounce_get_data(pounce)); 938 handler->cb(pounce, events, purple_pounce_get_data(pounce));
939 939
940 if (!gaim_pounce_get_save(pounce)) 940 if (!purple_pounce_get_save(pounce))
941 gaim_pounce_destroy(pounce); 941 purple_pounce_destroy(pounce);
942 } 942 }
943 } 943 }
944 } 944 }
945 945
946 g_free(norm_pouncee); 946 g_free(norm_pouncee);
947 } 947 }
948 948
949 GaimPounce * 949 PurplePounce *
950 gaim_find_pounce(const GaimAccount *pouncer, const char *pouncee, 950 purple_find_pounce(const PurpleAccount *pouncer, const char *pouncee,
951 GaimPounceEvent events) 951 PurplePounceEvent events)
952 { 952 {
953 GaimPounce *pounce = NULL; 953 PurplePounce *pounce = NULL;
954 GList *l; 954 GList *l;
955 char *norm_pouncee; 955 char *norm_pouncee;
956 956
957 g_return_val_if_fail(pouncer != NULL, NULL); 957 g_return_val_if_fail(pouncer != NULL, NULL);
958 g_return_val_if_fail(pouncee != NULL, NULL); 958 g_return_val_if_fail(pouncee != NULL, NULL);
959 g_return_val_if_fail(events != GAIM_POUNCE_NONE, NULL); 959 g_return_val_if_fail(events != PURPLE_POUNCE_NONE, NULL);
960 960
961 norm_pouncee = g_strdup(gaim_normalize(pouncer, pouncee)); 961 norm_pouncee = g_strdup(purple_normalize(pouncer, pouncee));
962 962
963 for (l = gaim_pounces_get_all(); l != NULL; l = l->next) 963 for (l = purple_pounces_get_all(); l != NULL; l = l->next)
964 { 964 {
965 pounce = (GaimPounce *)l->data; 965 pounce = (PurplePounce *)l->data;
966 966
967 if ((gaim_pounce_get_events(pounce) & events) && 967 if ((purple_pounce_get_events(pounce) & events) &&
968 (gaim_pounce_get_pouncer(pounce) == pouncer) && 968 (purple_pounce_get_pouncer(pounce) == pouncer) &&
969 !gaim_utf8_strcasecmp(gaim_normalize(pouncer, gaim_pounce_get_pouncee(pounce)), 969 !purple_utf8_strcasecmp(purple_normalize(pouncer, purple_pounce_get_pouncee(pounce)),
970 norm_pouncee)) 970 norm_pouncee))
971 { 971 {
972 break; 972 break;
973 } 973 }
974 974
979 979
980 return pounce; 980 return pounce;
981 } 981 }
982 982
983 void 983 void
984 gaim_pounces_register_handler(const char *ui, GaimPounceCb cb, 984 purple_pounces_register_handler(const char *ui, PurplePounceCb cb,
985 void (*new_pounce)(GaimPounce *pounce), 985 void (*new_pounce)(PurplePounce *pounce),
986 void (*free_pounce)(GaimPounce *pounce)) 986 void (*free_pounce)(PurplePounce *pounce))
987 { 987 {
988 GaimPounceHandler *handler; 988 PurplePounceHandler *handler;
989 989
990 g_return_if_fail(ui != NULL); 990 g_return_if_fail(ui != NULL);
991 g_return_if_fail(cb != NULL); 991 g_return_if_fail(cb != NULL);
992 992
993 handler = g_new0(GaimPounceHandler, 1); 993 handler = g_new0(PurplePounceHandler, 1);
994 994
995 handler->ui = g_strdup(ui); 995 handler->ui = g_strdup(ui);
996 handler->cb = cb; 996 handler->cb = cb;
997 handler->new_pounce = new_pounce; 997 handler->new_pounce = new_pounce;
998 handler->free_pounce = free_pounce; 998 handler->free_pounce = free_pounce;
999 999
1000 g_hash_table_insert(pounce_handlers, g_strdup(ui), handler); 1000 g_hash_table_insert(pounce_handlers, g_strdup(ui), handler);
1001 } 1001 }
1002 1002
1003 void 1003 void
1004 gaim_pounces_unregister_handler(const char *ui) 1004 purple_pounces_unregister_handler(const char *ui)
1005 { 1005 {
1006 g_return_if_fail(ui != NULL); 1006 g_return_if_fail(ui != NULL);
1007 1007
1008 g_hash_table_remove(pounce_handlers, ui); 1008 g_hash_table_remove(pounce_handlers, ui);
1009 } 1009 }
1010 1010
1011 GList * 1011 GList *
1012 gaim_pounces_get_all(void) 1012 purple_pounces_get_all(void)
1013 { 1013 {
1014 return pounces; 1014 return pounces;
1015 } 1015 }
1016 1016
1017 static void 1017 static void
1018 free_pounce_handler(gpointer user_data) 1018 free_pounce_handler(gpointer user_data)
1019 { 1019 {
1020 GaimPounceHandler *handler = (GaimPounceHandler *)user_data; 1020 PurplePounceHandler *handler = (PurplePounceHandler *)user_data;
1021 1021
1022 g_free(handler->ui); 1022 g_free(handler->ui);
1023 g_free(handler); 1023 g_free(handler);
1024 } 1024 }
1025 1025
1026 static void 1026 static void
1027 buddy_state_cb(GaimBuddy *buddy, GaimPounceEvent event) 1027 buddy_state_cb(PurpleBuddy *buddy, PurplePounceEvent event)
1028 { 1028 {
1029 gaim_pounce_execute(buddy->account, buddy->name, event); 1029 purple_pounce_execute(buddy->account, buddy->name, event);
1030 } 1030 }
1031 1031
1032 static void 1032 static void
1033 buddy_status_changed_cb(GaimBuddy *buddy, GaimStatus *old_status, 1033 buddy_status_changed_cb(PurpleBuddy *buddy, PurpleStatus *old_status,
1034 GaimStatus *status) 1034 PurpleStatus *status)
1035 { 1035 {
1036 gboolean old_available, available; 1036 gboolean old_available, available;
1037 1037
1038 available = gaim_status_is_available(status); 1038 available = purple_status_is_available(status);
1039 old_available = gaim_status_is_available(old_status); 1039 old_available = purple_status_is_available(old_status);
1040 1040
1041 if (available && !old_available) 1041 if (available && !old_available)
1042 gaim_pounce_execute(buddy->account, buddy->name, 1042 purple_pounce_execute(buddy->account, buddy->name,
1043 GAIM_POUNCE_AWAY_RETURN); 1043 PURPLE_POUNCE_AWAY_RETURN);
1044 else if (!available && old_available) 1044 else if (!available && old_available)
1045 gaim_pounce_execute(buddy->account, buddy->name, 1045 purple_pounce_execute(buddy->account, buddy->name,
1046 GAIM_POUNCE_AWAY); 1046 PURPLE_POUNCE_AWAY);
1047 } 1047 }
1048 1048
1049 static void 1049 static void
1050 buddy_idle_changed_cb(GaimBuddy *buddy, gboolean old_idle, gboolean idle) 1050 buddy_idle_changed_cb(PurpleBuddy *buddy, gboolean old_idle, gboolean idle)
1051 { 1051 {
1052 if (idle && !old_idle) 1052 if (idle && !old_idle)
1053 gaim_pounce_execute(buddy->account, buddy->name, 1053 purple_pounce_execute(buddy->account, buddy->name,
1054 GAIM_POUNCE_IDLE); 1054 PURPLE_POUNCE_IDLE);
1055 else if (!idle && old_idle) 1055 else if (!idle && old_idle)
1056 gaim_pounce_execute(buddy->account, buddy->name, 1056 purple_pounce_execute(buddy->account, buddy->name,
1057 GAIM_POUNCE_IDLE_RETURN); 1057 PURPLE_POUNCE_IDLE_RETURN);
1058 } 1058 }
1059 1059
1060 static void 1060 static void
1061 buddy_typing_cb(GaimAccount *account, const char *name, void *data) 1061 buddy_typing_cb(PurpleAccount *account, const char *name, void *data)
1062 { 1062 {
1063 GaimConversation *conv; 1063 PurpleConversation *conv;
1064 1064
1065 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, account); 1065 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, name, account);
1066 if (conv != NULL) 1066 if (conv != NULL)
1067 { 1067 {
1068 GaimTypingState state; 1068 PurpleTypingState state;
1069 GaimPounceEvent event; 1069 PurplePounceEvent event;
1070 1070
1071 state = gaim_conv_im_get_typing_state(GAIM_CONV_IM(conv)); 1071 state = purple_conv_im_get_typing_state(PURPLE_CONV_IM(conv));
1072 if (state == GAIM_TYPED) 1072 if (state == PURPLE_TYPED)
1073 event = GAIM_POUNCE_TYPED; 1073 event = PURPLE_POUNCE_TYPED;
1074 else if (state == GAIM_NOT_TYPING) 1074 else if (state == PURPLE_NOT_TYPING)
1075 event = GAIM_POUNCE_TYPING_STOPPED; 1075 event = PURPLE_POUNCE_TYPING_STOPPED;
1076 else 1076 else
1077 event = GAIM_POUNCE_TYPING; 1077 event = PURPLE_POUNCE_TYPING;
1078 1078
1079 gaim_pounce_execute(account, name, event); 1079 purple_pounce_execute(account, name, event);
1080 } 1080 }
1081 } 1081 }
1082 1082
1083 static void 1083 static void
1084 received_message_cb(GaimAccount *account, const char *name, void *data) 1084 received_message_cb(PurpleAccount *account, const char *name, void *data)
1085 { 1085 {
1086 gaim_pounce_execute(account, name, GAIM_POUNCE_MESSAGE_RECEIVED); 1086 purple_pounce_execute(account, name, PURPLE_POUNCE_MESSAGE_RECEIVED);
1087 } 1087 }
1088 1088
1089 void * 1089 void *
1090 gaim_pounces_get_handle(void) 1090 purple_pounces_get_handle(void)
1091 { 1091 {
1092 static int pounce_handle; 1092 static int pounce_handle;
1093 1093
1094 return &pounce_handle; 1094 return &pounce_handle;
1095 } 1095 }
1096 1096
1097 void 1097 void
1098 gaim_pounces_init(void) 1098 purple_pounces_init(void)
1099 { 1099 {
1100 void *handle = gaim_pounces_get_handle(); 1100 void *handle = purple_pounces_get_handle();
1101 void *blist_handle = gaim_blist_get_handle(); 1101 void *blist_handle = purple_blist_get_handle();
1102 void *conv_handle = gaim_conversations_get_handle(); 1102 void *conv_handle = purple_conversations_get_handle();
1103 1103
1104 pounce_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, 1104 pounce_handlers = g_hash_table_new_full(g_str_hash, g_str_equal,
1105 g_free, free_pounce_handler); 1105 g_free, free_pounce_handler);
1106 1106
1107 gaim_signal_connect(blist_handle, "buddy-idle-changed", 1107 purple_signal_connect(blist_handle, "buddy-idle-changed",
1108 handle, GAIM_CALLBACK(buddy_idle_changed_cb), NULL); 1108 handle, PURPLE_CALLBACK(buddy_idle_changed_cb), NULL);
1109 gaim_signal_connect(blist_handle, "buddy-status-changed", 1109 purple_signal_connect(blist_handle, "buddy-status-changed",
1110 handle, GAIM_CALLBACK(buddy_status_changed_cb), NULL); 1110 handle, PURPLE_CALLBACK(buddy_status_changed_cb), NULL);
1111 gaim_signal_connect(blist_handle, "buddy-signed-on", 1111 purple_signal_connect(blist_handle, "buddy-signed-on",
1112 handle, GAIM_CALLBACK(buddy_state_cb), 1112 handle, PURPLE_CALLBACK(buddy_state_cb),
1113 GINT_TO_POINTER(GAIM_POUNCE_SIGNON)); 1113 GINT_TO_POINTER(PURPLE_POUNCE_SIGNON));
1114 gaim_signal_connect(blist_handle, "buddy-signed-off", 1114 purple_signal_connect(blist_handle, "buddy-signed-off",
1115 handle, GAIM_CALLBACK(buddy_state_cb), 1115 handle, PURPLE_CALLBACK(buddy_state_cb),
1116 GINT_TO_POINTER(GAIM_POUNCE_SIGNOFF)); 1116 GINT_TO_POINTER(PURPLE_POUNCE_SIGNOFF));
1117 1117
1118 gaim_signal_connect(conv_handle, "buddy-typing", 1118 purple_signal_connect(conv_handle, "buddy-typing",
1119 handle, GAIM_CALLBACK(buddy_typing_cb), NULL); 1119 handle, PURPLE_CALLBACK(buddy_typing_cb), NULL);
1120 gaim_signal_connect(conv_handle, "buddy-typed", 1120 purple_signal_connect(conv_handle, "buddy-typed",
1121 handle, GAIM_CALLBACK(buddy_typing_cb), NULL); 1121 handle, PURPLE_CALLBACK(buddy_typing_cb), NULL);
1122 gaim_signal_connect(conv_handle, "buddy-typing-stopped", 1122 purple_signal_connect(conv_handle, "buddy-typing-stopped",
1123 handle, GAIM_CALLBACK(buddy_typing_cb), NULL); 1123 handle, PURPLE_CALLBACK(buddy_typing_cb), NULL);
1124 1124
1125 gaim_signal_connect(conv_handle, "received-im-msg", 1125 purple_signal_connect(conv_handle, "received-im-msg",
1126 handle, GAIM_CALLBACK(received_message_cb), NULL); 1126 handle, PURPLE_CALLBACK(received_message_cb), NULL);
1127 } 1127 }
1128 1128
1129 void 1129 void
1130 gaim_pounces_uninit() 1130 purple_pounces_uninit()
1131 { 1131 {
1132 if (save_timer != 0) 1132 if (save_timer != 0)
1133 { 1133 {
1134 gaim_timeout_remove(save_timer); 1134 purple_timeout_remove(save_timer);
1135 save_timer = 0; 1135 save_timer = 0;
1136 sync_pounces(); 1136 sync_pounces();
1137 } 1137 }
1138 1138
1139 gaim_signals_disconnect_by_handle(gaim_pounces_get_handle()); 1139 purple_signals_disconnect_by_handle(purple_pounces_get_handle());
1140 } 1140 }