Mercurial > pidgin
comparison libpurple/pounce.c @ 25894:a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
closes #7790
committer: Gary Kramlich <grim@reaperworld.com>
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Tue, 06 Jan 2009 03:39:51 +0000 |
parents | 5ebfa814b9e8 |
children | 32a707746454 |
comparison
equal
deleted
inserted
replaced
25893:991796129108 | 25894:a6e3cb32cdd2 |
---|---|
324 if (data->buffer != NULL) { | 324 if (data->buffer != NULL) { |
325 g_string_free(data->buffer, TRUE); | 325 g_string_free(data->buffer, TRUE); |
326 data->buffer = NULL; | 326 data->buffer = NULL; |
327 } | 327 } |
328 | 328 |
329 if (!strcmp(element_name, "pounce")) { | 329 if (purple_strequal(element_name, "pounce")) { |
330 const char *ui = g_hash_table_lookup(atts, "ui"); | 330 const char *ui = g_hash_table_lookup(atts, "ui"); |
331 | 331 |
332 if (ui == NULL) { | 332 if (ui == NULL) { |
333 purple_debug(PURPLE_DEBUG_ERROR, "pounce", | 333 purple_debug(PURPLE_DEBUG_ERROR, "pounce", |
334 "Unset 'ui' parameter for pounce!\n"); | 334 "Unset 'ui' parameter for pounce!\n"); |
336 else | 336 else |
337 data->ui_name = g_strdup(ui); | 337 data->ui_name = g_strdup(ui); |
338 | 338 |
339 data->events = 0; | 339 data->events = 0; |
340 } | 340 } |
341 else if (!strcmp(element_name, "account")) { | 341 else if (purple_strequal(element_name, "account")) { |
342 const char *protocol_id = g_hash_table_lookup(atts, "protocol"); | 342 const char *protocol_id = g_hash_table_lookup(atts, "protocol"); |
343 | 343 |
344 if (protocol_id == NULL) { | 344 if (protocol_id == NULL) { |
345 purple_debug(PURPLE_DEBUG_ERROR, "pounce", | 345 purple_debug(PURPLE_DEBUG_ERROR, "pounce", |
346 "Unset 'protocol' parameter for account!\n"); | 346 "Unset 'protocol' parameter for account!\n"); |
347 } | 347 } |
348 else | 348 else |
349 data->protocol_id = g_strdup(protocol_id); | 349 data->protocol_id = g_strdup(protocol_id); |
350 } | 350 } |
351 else if (!strcmp(element_name, "option")) { | 351 else if (purple_strequal(element_name, "option")) { |
352 const char *type = g_hash_table_lookup(atts, "type"); | 352 const char *type = g_hash_table_lookup(atts, "type"); |
353 | 353 |
354 if (type == NULL) { | 354 if (type == NULL) { |
355 purple_debug(PURPLE_DEBUG_ERROR, "pounce", | 355 purple_debug(PURPLE_DEBUG_ERROR, "pounce", |
356 "Unset 'type' parameter for option!\n"); | 356 "Unset 'type' parameter for option!\n"); |
357 } | 357 } |
358 else | 358 else |
359 data->option_type = g_strdup(type); | 359 data->option_type = g_strdup(type); |
360 } | 360 } |
361 else if (!strcmp(element_name, "event")) { | 361 else if (purple_strequal(element_name, "event")) { |
362 const char *type = g_hash_table_lookup(atts, "type"); | 362 const char *type = g_hash_table_lookup(atts, "type"); |
363 | 363 |
364 if (type == NULL) { | 364 if (type == NULL) { |
365 purple_debug(PURPLE_DEBUG_ERROR, "pounce", | 365 purple_debug(PURPLE_DEBUG_ERROR, "pounce", |
366 "Unset 'type' parameter for event!\n"); | 366 "Unset 'type' parameter for event!\n"); |
367 } | 367 } |
368 else | 368 else |
369 data->event_type = g_strdup(type); | 369 data->event_type = g_strdup(type); |
370 } | 370 } |
371 else if (!strcmp(element_name, "action")) { | 371 else if (purple_strequal(element_name, "action")) { |
372 const char *type = g_hash_table_lookup(atts, "type"); | 372 const char *type = g_hash_table_lookup(atts, "type"); |
373 | 373 |
374 if (type == NULL) { | 374 if (type == NULL) { |
375 purple_debug(PURPLE_DEBUG_ERROR, "pounce", | 375 purple_debug(PURPLE_DEBUG_ERROR, "pounce", |
376 "Unset 'type' parameter for action!\n"); | 376 "Unset 'type' parameter for action!\n"); |
377 } | 377 } |
378 else | 378 else |
379 data->action_name = g_strdup(type); | 379 data->action_name = g_strdup(type); |
380 } | 380 } |
381 else if (!strcmp(element_name, "param")) { | 381 else if (purple_strequal(element_name, "param")) { |
382 const char *param_name = g_hash_table_lookup(atts, "name"); | 382 const char *param_name = g_hash_table_lookup(atts, "name"); |
383 | 383 |
384 if (param_name == NULL) { | 384 if (param_name == NULL) { |
385 purple_debug(PURPLE_DEBUG_ERROR, "pounce", | 385 purple_debug(PURPLE_DEBUG_ERROR, "pounce", |
386 "Unset 'name' parameter for param!\n"); | 386 "Unset 'name' parameter for param!\n"); |
402 if (data->buffer != NULL) { | 402 if (data->buffer != NULL) { |
403 buffer = g_string_free(data->buffer, FALSE); | 403 buffer = g_string_free(data->buffer, FALSE); |
404 data->buffer = NULL; | 404 data->buffer = NULL; |
405 } | 405 } |
406 | 406 |
407 if (!strcmp(element_name, "account")) { | 407 if (purple_strequal(element_name, "account")) { |
408 char *tmp; | 408 char *tmp; |
409 g_free(data->account_name); | 409 g_free(data->account_name); |
410 data->account_name = g_strdup(buffer); | 410 data->account_name = g_strdup(buffer); |
411 tmp = data->protocol_id; | 411 tmp = data->protocol_id; |
412 data->protocol_id = g_strdup(_purple_oscar_convert(buffer, tmp)); | 412 data->protocol_id = g_strdup(_purple_oscar_convert(buffer, tmp)); |
413 g_free(tmp); | 413 g_free(tmp); |
414 } | 414 } |
415 else if (!strcmp(element_name, "pouncee")) { | 415 else if (purple_strequal(element_name, "pouncee")) { |
416 g_free(data->pouncee); | 416 g_free(data->pouncee); |
417 data->pouncee = g_strdup(buffer); | 417 data->pouncee = g_strdup(buffer); |
418 } | 418 } |
419 else if (!strcmp(element_name, "option")) { | 419 else if (purple_strequal(element_name, "option")) { |
420 if (!strcmp(data->option_type, "on-away")) | 420 if (purple_strequal(data->option_type, "on-away")) |
421 data->options |= PURPLE_POUNCE_OPTION_AWAY; | 421 data->options |= PURPLE_POUNCE_OPTION_AWAY; |
422 | 422 |
423 g_free(data->option_type); | 423 g_free(data->option_type); |
424 data->option_type = NULL; | 424 data->option_type = NULL; |
425 } | 425 } |
426 else if (!strcmp(element_name, "event")) { | 426 else if (purple_strequal(element_name, "event")) { |
427 if (!strcmp(data->event_type, "sign-on")) | 427 if (purple_strequal(data->event_type, "sign-on")) |
428 data->events |= PURPLE_POUNCE_SIGNON; | 428 data->events |= PURPLE_POUNCE_SIGNON; |
429 else if (!strcmp(data->event_type, "sign-off")) | 429 else if (purple_strequal(data->event_type, "sign-off")) |
430 data->events |= PURPLE_POUNCE_SIGNOFF; | 430 data->events |= PURPLE_POUNCE_SIGNOFF; |
431 else if (!strcmp(data->event_type, "away")) | 431 else if (purple_strequal(data->event_type, "away")) |
432 data->events |= PURPLE_POUNCE_AWAY; | 432 data->events |= PURPLE_POUNCE_AWAY; |
433 else if (!strcmp(data->event_type, "return-from-away")) | 433 else if (purple_strequal(data->event_type, "return-from-away")) |
434 data->events |= PURPLE_POUNCE_AWAY_RETURN; | 434 data->events |= PURPLE_POUNCE_AWAY_RETURN; |
435 else if (!strcmp(data->event_type, "idle")) | 435 else if (purple_strequal(data->event_type, "idle")) |
436 data->events |= PURPLE_POUNCE_IDLE; | 436 data->events |= PURPLE_POUNCE_IDLE; |
437 else if (!strcmp(data->event_type, "return-from-idle")) | 437 else if (purple_strequal(data->event_type, "return-from-idle")) |
438 data->events |= PURPLE_POUNCE_IDLE_RETURN; | 438 data->events |= PURPLE_POUNCE_IDLE_RETURN; |
439 else if (!strcmp(data->event_type, "start-typing")) | 439 else if (purple_strequal(data->event_type, "start-typing")) |
440 data->events |= PURPLE_POUNCE_TYPING; | 440 data->events |= PURPLE_POUNCE_TYPING; |
441 else if (!strcmp(data->event_type, "typed")) | 441 else if (purple_strequal(data->event_type, "typed")) |
442 data->events |= PURPLE_POUNCE_TYPED; | 442 data->events |= PURPLE_POUNCE_TYPED; |
443 else if (!strcmp(data->event_type, "stop-typing")) | 443 else if (purple_strequal(data->event_type, "stop-typing")) |
444 data->events |= PURPLE_POUNCE_TYPING_STOPPED; | 444 data->events |= PURPLE_POUNCE_TYPING_STOPPED; |
445 else if (!strcmp(data->event_type, "message-received")) | 445 else if (purple_strequal(data->event_type, "message-received")) |
446 data->events |= PURPLE_POUNCE_MESSAGE_RECEIVED; | 446 data->events |= PURPLE_POUNCE_MESSAGE_RECEIVED; |
447 | 447 |
448 g_free(data->event_type); | 448 g_free(data->event_type); |
449 data->event_type = NULL; | 449 data->event_type = NULL; |
450 } | 450 } |
451 else if (!strcmp(element_name, "action")) { | 451 else if (purple_strequal(element_name, "action")) { |
452 if (data->pounce != NULL) { | 452 if (data->pounce != NULL) { |
453 purple_pounce_action_register(data->pounce, data->action_name); | 453 purple_pounce_action_register(data->pounce, data->action_name); |
454 purple_pounce_action_set_enabled(data->pounce, data->action_name, TRUE); | 454 purple_pounce_action_set_enabled(data->pounce, data->action_name, TRUE); |
455 } | 455 } |
456 | 456 |
457 g_free(data->action_name); | 457 g_free(data->action_name); |
458 data->action_name = NULL; | 458 data->action_name = NULL; |
459 } | 459 } |
460 else if (!strcmp(element_name, "param")) { | 460 else if (purple_strequal(element_name, "param")) { |
461 if (data->pounce != NULL) { | 461 if (data->pounce != NULL) { |
462 purple_pounce_action_set_attribute(data->pounce, data->action_name, | 462 purple_pounce_action_set_attribute(data->pounce, data->action_name, |
463 data->param_name, buffer); | 463 data->param_name, buffer); |
464 } | 464 } |
465 | 465 |
466 g_free(data->param_name); | 466 g_free(data->param_name); |
467 data->param_name = NULL; | 467 data->param_name = NULL; |
468 } | 468 } |
469 else if (!strcmp(element_name, "events")) { | 469 else if (purple_strequal(element_name, "events")) { |
470 PurpleAccount *account; | 470 PurpleAccount *account; |
471 | 471 |
472 account = purple_accounts_find(data->account_name, data->protocol_id); | 472 account = purple_accounts_find(data->account_name, data->protocol_id); |
473 | 473 |
474 g_free(data->account_name); | 474 g_free(data->account_name); |
497 } | 497 } |
498 | 498 |
499 g_free(data->pouncee); | 499 g_free(data->pouncee); |
500 data->pouncee = NULL; | 500 data->pouncee = NULL; |
501 } | 501 } |
502 else if (!strcmp(element_name, "save")) { | 502 else if (purple_strequal(element_name, "save")) { |
503 if (data->pounce != NULL) | 503 if (data->pounce != NULL) |
504 purple_pounce_set_save(data->pounce, TRUE); | 504 purple_pounce_set_save(data->pounce, TRUE); |
505 } | 505 } |
506 else if (!strcmp(element_name, "pounce")) { | 506 else if (purple_strequal(element_name, "pounce")) { |
507 data->pounce = NULL; | 507 data->pounce = NULL; |
508 data->events = 0; | 508 data->events = 0; |
509 data->options = 0; | 509 data->options = 0; |
510 | 510 |
511 g_free(data->ui_name); | 511 g_free(data->ui_name); |
1021 GList *list = NULL, *iter; | 1021 GList *list = NULL, *iter; |
1022 g_return_val_if_fail(ui != NULL, NULL); | 1022 g_return_val_if_fail(ui != NULL, NULL); |
1023 | 1023 |
1024 for (iter = pounces; iter; iter = iter->next) { | 1024 for (iter = pounces; iter; iter = iter->next) { |
1025 PurplePounce *pounce = iter->data; | 1025 PurplePounce *pounce = iter->data; |
1026 if (pounce->ui_type && strcmp(pounce->ui_type, ui) == 0) | 1026 if (purple_strequal(pounce->ui_type, ui)) |
1027 list = g_list_prepend(list, pounce); | 1027 list = g_list_prepend(list, pounce); |
1028 } | 1028 } |
1029 list = g_list_reverse(list); | 1029 list = g_list_reverse(list); |
1030 return list; | 1030 return list; |
1031 } | 1031 } |