comparison src/pounce.c @ 6719:3cc4d5e55a69

[gaim-migrate @ 7246] Screennames in buddy pounces are now normalized before comparison. This fixes issues such as screennames with spaces in them. Thanks SimGuy. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Wed, 03 Sep 2003 04:49:24 +0000
parents 601c2a52d74a
children f098765ac919
comparison
equal deleted inserted replaced
6718:37af5dea14d1 6719:3cc4d5e55a69
363 GaimPounceEvent events) 363 GaimPounceEvent events)
364 { 364 {
365 GaimPounce *pounce; 365 GaimPounce *pounce;
366 GaimPounceHandler *handler; 366 GaimPounceHandler *handler;
367 GList *l, *l_next; 367 GList *l, *l_next;
368 char *norm_pouncee;
368 369
369 g_return_if_fail(pouncer != NULL); 370 g_return_if_fail(pouncer != NULL);
370 g_return_if_fail(pouncee != NULL); 371 g_return_if_fail(pouncee != NULL);
371 g_return_if_fail(events != GAIM_POUNCE_NONE); 372 g_return_if_fail(events != GAIM_POUNCE_NONE);
372 373
373 for (l = gaim_pounces_get_all(); l != NULL; l = l_next) { 374 norm_pouncee = g_strdup(normalize(pouncee));
375
376 for (l = gaim_pounces_get_all(); l != NULL; l = l_next)
377 {
374 pounce = (GaimPounce *)l->data; 378 pounce = (GaimPounce *)l->data;
375 l_next = l->next; 379 l_next = l->next;
376 380
377 if ((gaim_pounce_get_events(pounce) & events) && 381 if ((gaim_pounce_get_events(pounce) & events) &&
378 (gaim_pounce_get_pouncer(pounce) == pouncer) && 382 (gaim_pounce_get_pouncer(pounce) == pouncer) &&
379 !gaim_utf8_strcasecmp(gaim_pounce_get_pouncee(pounce), pouncee)) { 383 !gaim_utf8_strcasecmp(normalize(gaim_pounce_get_pouncee(pounce)),
380 384 norm_pouncee))
385 {
381 handler = g_hash_table_lookup(pounce_handlers, pounce->ui_type); 386 handler = g_hash_table_lookup(pounce_handlers, pounce->ui_type);
382 387
383 if (handler != NULL && handler->cb != NULL) { 388 if (handler != NULL && handler->cb != NULL)
389 {
384 handler->cb(pounce, events, gaim_pounce_get_data(pounce)); 390 handler->cb(pounce, events, gaim_pounce_get_data(pounce));
385 391
386 if (!gaim_pounce_get_save(pounce)) 392 if (!gaim_pounce_get_save(pounce))
387 gaim_pounce_destroy(pounce); 393 gaim_pounce_destroy(pounce);
388 } 394 }
389 } 395 }
390 } 396 }
397
398 g_free(norm_pouncee);
391 } 399 }
392 400
393 GaimPounce * 401 GaimPounce *
394 gaim_find_pounce(const GaimAccount *pouncer, const char *pouncee, 402 gaim_find_pounce(const GaimAccount *pouncer, const char *pouncee,
395 GaimPounceEvent events) 403 GaimPounceEvent events)
396 { 404 {
397 GaimPounce *pounce; 405 GaimPounce *pounce = NULL;
398 GList *l; 406 GList *l;
407 char *norm_pouncee;
399 408
400 g_return_val_if_fail(pouncer != NULL, NULL); 409 g_return_val_if_fail(pouncer != NULL, NULL);
401 g_return_val_if_fail(pouncee != NULL, NULL); 410 g_return_val_if_fail(pouncee != NULL, NULL);
402 g_return_val_if_fail(events != GAIM_POUNCE_NONE, NULL); 411 g_return_val_if_fail(events != GAIM_POUNCE_NONE, NULL);
403 412
404 for (l = gaim_pounces_get_all(); l != NULL; l = l->next) { 413 norm_pouncee = g_strdup(pouncee);
414
415 for (l = gaim_pounces_get_all(); l != NULL; l = l->next)
416 {
405 pounce = (GaimPounce *)l->data; 417 pounce = (GaimPounce *)l->data;
406 418
407 if ((gaim_pounce_get_events(pounce) & events) && 419 if ((gaim_pounce_get_events(pounce) & events) &&
408 (gaim_pounce_get_pouncer(pounce) == pouncer) && 420 (gaim_pounce_get_pouncer(pounce) == pouncer) &&
409 !gaim_utf8_strcasecmp(gaim_pounce_get_pouncee(pounce), pouncee)) { 421 !gaim_utf8_strcasecmp(normalize(gaim_pounce_get_pouncee(pounce)),
410 422 norm_pouncee))
411 return pounce; 423 {
424 break;
412 } 425 }
413 } 426
414 427 pounce = NULL;
415 return NULL; 428 }
429
430 g_free(norm_pouncee);
431
432 return pounce;
416 } 433 }
417 434
418 /* XML Stuff */ 435 /* XML Stuff */
419 static void 436 static void
420 free_parser_data(gpointer user_data) 437 free_parser_data(gpointer user_data)