| 20 * along with this program; if not, write to the Free Software |
20 * along with this program; if not, write to the Free Software |
| 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 */ |
22 */ |
| 23 #include "internal.h" |
23 #include "internal.h" |
| 24 |
24 |
| |
25 #include "cipher.h" |
| 25 #include "conversation.h" |
26 #include "conversation.h" |
| 26 #include "core.h" |
27 #include "core.h" |
| 27 #include "debug.h" |
28 #include "debug.h" |
| 28 #include "notify.h" |
29 #include "notify.h" |
| 29 #include "prpl.h" |
30 #include "prpl.h" |
| 1399 !g_ascii_strncasecmp(c+3, " />", 3))) { |
1400 !g_ascii_strncasecmp(c+3, " />", 3))) { |
| 1400 c = strchr(c, '>') + 1; |
1401 c = strchr(c, '>') + 1; |
| 1401 xhtml = g_string_append(xhtml, "<br/>"); |
1402 xhtml = g_string_append(xhtml, "<br/>"); |
| 1402 if(*c != '\n') |
1403 if(*c != '\n') |
| 1403 plain = g_string_append_c(plain, '\n'); |
1404 plain = g_string_append_c(plain, '\n'); |
| |
1405 continue; |
| |
1406 } |
| |
1407 if(!g_ascii_strncasecmp(c, "<img", 4) && (*(c+4) == '>' || *(c+4) == ' ')) { |
| |
1408 const char *p = c; |
| |
1409 GString *src = NULL; |
| |
1410 struct purple_parse_tag *pt; |
| |
1411 while(*p && *p != '>') { |
| |
1412 if(!g_ascii_strncasecmp(p, "src=", strlen("src="))) { |
| |
1413 const char *q = p + strlen("src="); |
| |
1414 src = g_string_new(""); |
| |
1415 if(*q == '\'' || *q == '\"') |
| |
1416 q++; |
| |
1417 while(*q && *q != '\"' && *q != '\'' && *q != ' ') { |
| |
1418 src = g_string_append_c(src, *q); |
| |
1419 q++; |
| |
1420 } |
| |
1421 p = q; |
| |
1422 } |
| |
1423 p++; |
| |
1424 } |
| |
1425 if ((c = strchr(c, '>')) != NULL) |
| |
1426 c++; |
| |
1427 else |
| |
1428 c = p; |
| |
1429 pt = g_new0(struct purple_parse_tag, 1); |
| |
1430 pt->src_tag = "img"; |
| |
1431 pt->dest_tag = "img"; |
| |
1432 tags = g_list_prepend(tags, pt); |
| |
1433 if(src && src->len) |
| |
1434 g_string_append_printf(xhtml, "<img src='%s' alt=''>", g_strstrip(src->str)); |
| |
1435 else |
| |
1436 pt->ignore = TRUE; |
| |
1437 if (src) |
| |
1438 g_string_free(src, TRUE); |
| 1404 continue; |
1439 continue; |
| 1405 } |
1440 } |
| 1406 if(!g_ascii_strncasecmp(c, "<b>", 3) || !g_ascii_strncasecmp(c, "<bold>", strlen("<bold>"))) { |
1441 if(!g_ascii_strncasecmp(c, "<b>", 3) || !g_ascii_strncasecmp(c, "<bold>", strlen("<bold>"))) { |
| 1407 struct purple_parse_tag *pt = g_new0(struct purple_parse_tag, 1); |
1442 struct purple_parse_tag *pt = g_new0(struct purple_parse_tag, 1); |
| 1408 pt->src_tag = *(c+2) == '>' ? "b" : "bold"; |
1443 pt->src_tag = *(c+2) == '>' ? "b" : "bold"; |
| 2657 } |
2692 } |
| 2658 |
2693 |
| 2659 return "icon"; |
2694 return "icon"; |
| 2660 } |
2695 } |
| 2661 |
2696 |
| |
2697 char * |
| |
2698 purple_util_get_image_filename(gconstpointer image_data, size_t image_len) |
| |
2699 { |
| |
2700 PurpleCipherContext *context; |
| |
2701 gchar digest[41]; |
| |
2702 |
| |
2703 context = purple_cipher_context_new_by_name("sha1", NULL); |
| |
2704 if (context == NULL) |
| |
2705 { |
| |
2706 purple_debug_error("util", "Could not find sha1 cipher\n"); |
| |
2707 g_return_val_if_reached(NULL); |
| |
2708 } |
| |
2709 |
| |
2710 /* Hash the image data */ |
| |
2711 purple_cipher_context_append(context, image_data, image_len); |
| |
2712 if (!purple_cipher_context_digest_to_str(context, sizeof(digest), digest, NULL)) |
| |
2713 { |
| |
2714 purple_debug_error("util", "Failed to get SHA-1 digest.\n"); |
| |
2715 g_return_val_if_reached(NULL); |
| |
2716 } |
| |
2717 purple_cipher_context_destroy(context); |
| |
2718 |
| |
2719 /* Return the filename */ |
| |
2720 return g_strdup_printf("%s.%s", digest, |
| |
2721 purple_util_get_image_extension(image_data, image_len)); |
| |
2722 } |
| |
2723 |
| 2662 gboolean |
2724 gboolean |
| 2663 purple_program_is_valid(const char *program) |
2725 purple_program_is_valid(const char *program) |
| 2664 { |
2726 { |
| 2665 GError *error = NULL; |
2727 GError *error = NULL; |
| 2666 char **argv; |
2728 char **argv; |