Mercurial > pidgin.yaz
comparison libpurple/protocols/silc/util.c @ 22800:67a4c8c46f78
Cleanup allocations/frees to match and plug some leaks.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Sat, 03 May 2008 07:13:58 +0000 |
parents | b630d1d4d64f |
children | e0bcb8cfda74 |
comparison
equal
deleted
inserted
replaced
22799:fc1e708ddf92 | 22800:67a4c8c46f78 |
---|---|
336 SilcSILCPublicKey silc_pubkey; | 336 SilcSILCPublicKey silc_pubkey; |
337 char *fingerprint, *babbleprint; | 337 char *fingerprint, *babbleprint; |
338 unsigned char *pk; | 338 unsigned char *pk; |
339 SilcUInt32 pk_len, key_len = 0; | 339 SilcUInt32 pk_len, key_len = 0; |
340 GString *s; | 340 GString *s; |
341 char *buf; | |
342 | 341 |
343 /* We support showing only SILC public keys for now */ | 342 /* We support showing only SILC public keys for now */ |
344 if (silc_pkcs_get_type(public_key) != SILC_PKCS_SILC) | 343 if (silc_pkcs_get_type(public_key) != SILC_PKCS_SILC) |
345 return; | 344 return; |
346 | 345 |
378 g_string_append_printf(s, _("Version: \t%s\n"), ident->version); | 377 g_string_append_printf(s, _("Version: \t%s\n"), ident->version); |
379 g_string_append_printf(s, "\n"); | 378 g_string_append_printf(s, "\n"); |
380 g_string_append_printf(s, _("Public Key Fingerprint:\n%s\n\n"), fingerprint); | 379 g_string_append_printf(s, _("Public Key Fingerprint:\n%s\n\n"), fingerprint); |
381 g_string_append_printf(s, _("Public Key Babbleprint:\n%s"), babbleprint); | 380 g_string_append_printf(s, _("Public Key Babbleprint:\n%s"), babbleprint); |
382 | 381 |
383 buf = g_string_free(s, FALSE); | |
384 | |
385 purple_request_action(sg->gc, _("Public Key Information"), | 382 purple_request_action(sg->gc, _("Public Key Information"), |
386 _("Public Key Information"), | 383 _("Public Key Information"), |
387 buf, 0, purple_connection_get_account(sg->gc), | 384 s->str, 0, purple_connection_get_account(sg->gc), |
388 NULL, NULL, context, 1, _("Close"), callback); | 385 NULL, NULL, context, 1, _("Close"), callback); |
389 | 386 |
390 g_free(buf); | 387 g_string_free(s, TRUE); |
391 silc_free(fingerprint); | 388 silc_free(fingerprint); |
392 silc_free(babbleprint); | 389 silc_free(babbleprint); |
393 silc_free(pk); | 390 silc_free(pk); |
394 } | 391 } |
395 | 392 |
543 g_string_append_printf(s, "[%s] ", _("Excited")); | 540 g_string_append_printf(s, "[%s] ", _("Excited")); |
544 if (mood & SILC_ATTRIBUTE_MOOD_ANXIOUS) | 541 if (mood & SILC_ATTRIBUTE_MOOD_ANXIOUS) |
545 g_string_append_printf(s, "[%s] ", _("Anxious")); | 542 g_string_append_printf(s, "[%s] ", _("Anxious")); |
546 } | 543 } |
547 if (strlen(s->str)) { | 544 if (strlen(s->str)) { |
548 *moodstr = s->str; | 545 *moodstr = g_string_free(s, FALSE); |
549 g_string_free(s, FALSE); | |
550 g_strchomp(*moodstr); | 546 g_strchomp(*moodstr); |
551 } else | 547 } else |
552 g_string_free(s, TRUE); | 548 g_string_free(s, TRUE); |
553 | 549 |
554 attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_STATUS_FREETEXT); | 550 attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_STATUS_FREETEXT); |
573 g_string_append_printf(s, "[%s] ", _("MMS")); | 569 g_string_append_printf(s, "[%s] ", _("MMS")); |
574 if (contact & SILC_ATTRIBUTE_CONTACT_VIDEO) | 570 if (contact & SILC_ATTRIBUTE_CONTACT_VIDEO) |
575 g_string_append_printf(s, "[%s] ", _("Video Conferencing")); | 571 g_string_append_printf(s, "[%s] ", _("Video Conferencing")); |
576 } | 572 } |
577 if (strlen(s->str)) { | 573 if (strlen(s->str)) { |
578 *contactstr = s->str; | 574 *contactstr = g_string_free(s, FALSE); |
579 g_string_free(s, FALSE); | |
580 g_strchomp(*contactstr); | 575 g_strchomp(*contactstr); |
581 } else | 576 } else |
582 g_string_free(s, TRUE); | 577 g_string_free(s, TRUE); |
583 | 578 |
584 attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_PREFERRED_LANGUAGE); | 579 attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_PREFERRED_LANGUAGE); |
602 device.manufacturer ? device.manufacturer : "", | 597 device.manufacturer ? device.manufacturer : "", |
603 device.version ? device.version : "", | 598 device.version ? device.version : "", |
604 device.model ? device.model : "", | 599 device.model ? device.model : "", |
605 device.language ? device.language : ""); | 600 device.language ? device.language : ""); |
606 } | 601 } |
607 if (strlen(s->str)) { | 602 if (strlen(s->str)) |
608 *devicestr = s->str; | 603 *devicestr = g_string_free(s, FALSE); |
609 g_string_free(s, FALSE); | 604 else |
610 } else | |
611 g_string_free(s, TRUE); | 605 g_string_free(s, TRUE); |
612 | 606 |
613 attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_TIMEZONE); | 607 attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_TIMEZONE); |
614 memset(tmp, 0, sizeof(tmp)); | 608 memset(tmp, 0, sizeof(tmp)); |
615 if (attr && silc_attribute_get_object(attr, tmp, sizeof(tmp))) | 609 if (attr && silc_attribute_get_object(attr, tmp, sizeof(tmp))) |
633 | 627 |
634 ct = strrchr(filename, '.'); | 628 ct = strrchr(filename, '.'); |
635 if (!ct) | 629 if (!ct) |
636 return NULL; | 630 return NULL; |
637 else if (!g_ascii_strcasecmp(".png", ct)) | 631 else if (!g_ascii_strcasecmp(".png", ct)) |
638 return strdup("image/png"); | 632 return g_strdup("image/png"); |
639 else if (!g_ascii_strcasecmp(".jpg", ct)) | 633 else if (!g_ascii_strcasecmp(".jpg", ct)) |
640 return strdup("image/jpeg"); | 634 return g_strdup("image/jpeg"); |
641 else if (!g_ascii_strcasecmp(".jpeg", ct)) | 635 else if (!g_ascii_strcasecmp(".jpeg", ct)) |
642 return strdup("image/jpeg"); | 636 return g_strdup("image/jpeg"); |
643 else if (!g_ascii_strcasecmp(".gif", ct)) | 637 else if (!g_ascii_strcasecmp(".gif", ct)) |
644 return strdup("image/gif"); | 638 return g_strdup("image/gif"); |
645 else if (!g_ascii_strcasecmp(".tiff", ct)) | 639 else if (!g_ascii_strcasecmp(".tiff", ct)) |
646 return strdup("image/tiff"); | 640 return g_strdup("image/tiff"); |
647 | 641 |
648 return NULL; | 642 return NULL; |
649 } | 643 } |
650 | 644 |
651 /* Checks if message has images, and assembles MIME message if it has. | 645 /* Checks if message has images, and assembles MIME message if it has. |
703 g_datalist_clear(&attribs); | 697 g_datalist_clear(&attribs); |
704 last = end + 1; | 698 last = end + 1; |
705 continue; | 699 continue; |
706 } | 700 } |
707 silc_mime_add_field(p, "Content-Type", type); | 701 silc_mime_add_field(p, "Content-Type", type); |
708 silc_free(type); | 702 g_free(type); |
709 | 703 |
710 /* Add content transfer encoding */ | 704 /* Add content transfer encoding */ |
711 silc_mime_add_field(p, "Content-Transfer-Encoding", "binary"); | 705 silc_mime_add_field(p, "Content-Transfer-Encoding", "binary"); |
712 | 706 |
713 /* Add image data */ | 707 /* Add image data */ |