comparison libpurple/util.c @ 23142:dea8b856466e

propagate from branch 'im.pidgin.pidgin.custom_smiley' (head c134ff23eba5faac09c13e731e792fa612c91a9a) to branch 'im.pidgin.pidgin.next.minor' (head 4d2d20241c7dac5915e142f0aa9811c9eab40111)
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Mon, 12 May 2008 23:17:48 +0000
parents 8dadddab10ed 48e33e3673e2
children 228d576a7dd7 774ef2a2e7f8
comparison
equal deleted inserted replaced
23114:d53f72735830 23142:dea8b856466e
937 else if(IS_ENTITY("&reg;")) 937 else if(IS_ENTITY("&reg;"))
938 pln = "\302\256"; /* or use g_unichar_to_utf8(0xae); */ 938 pln = "\302\256"; /* or use g_unichar_to_utf8(0xae); */
939 else if(IS_ENTITY("&apos;")) 939 else if(IS_ENTITY("&apos;"))
940 pln = "\'"; 940 pln = "\'";
941 else if(*(text+1) == '#' && 941 else if(*(text+1) == '#' &&
942 (sscanf(text, "&#%u%1[;]", &pound, temp) == 2 || sscanf(text, "&#x%x%1[;]", &pound, temp) == 2) && 942 (sscanf(text, "&#%u%1[;]", &pound, temp) == 2 ||
943 sscanf(text, "&#x%x%1[;]", &pound, temp) == 2) &&
943 pound != 0) { 944 pound != 0) {
944 static char buf[7]; 945 static char buf[7];
945 int buflen = g_unichar_to_utf8((gunichar)pound, buf); 946 int buflen = g_unichar_to_utf8((gunichar)pound, buf);
946 buf[buflen] = '\0'; 947 buf[buflen] = '\0';
947 pln = buf; 948 pln = buf;
2887 2888
2888 return "icon"; 2889 return "icon";
2889 } 2890 }
2890 2891
2891 char * 2892 char *
2892 purple_util_get_image_filename(gconstpointer image_data, size_t image_len) 2893 purple_util_get_image_checksum(gconstpointer image_data, size_t image_len)
2893 { 2894 {
2894 PurpleCipherContext *context; 2895 PurpleCipherContext *context;
2895 gchar digest[41]; 2896 gchar digest[41];
2896 2897
2897 context = purple_cipher_context_new_by_name("sha1", NULL); 2898 context = purple_cipher_context_new_by_name("sha1", NULL);
2908 purple_debug_error("util", "Failed to get SHA-1 digest.\n"); 2909 purple_debug_error("util", "Failed to get SHA-1 digest.\n");
2909 g_return_val_if_reached(NULL); 2910 g_return_val_if_reached(NULL);
2910 } 2911 }
2911 purple_cipher_context_destroy(context); 2912 purple_cipher_context_destroy(context);
2912 2913
2914 return g_strdup(digest);
2915 }
2916
2917 char *
2918 purple_util_get_image_filename(gconstpointer image_data, size_t image_len)
2919 {
2913 /* Return the filename */ 2920 /* Return the filename */
2914 return g_strdup_printf("%s.%s", digest, 2921 char *checksum = purple_util_get_image_checksum(image_data, image_len);
2922 char *filename = g_strdup_printf("%s.%s", checksum,
2915 purple_util_get_image_extension(image_data, image_len)); 2923 purple_util_get_image_extension(image_data, image_len));
2924 g_free(checksum);
2925 return filename;
2916 } 2926 }
2917 2927
2918 gboolean 2928 gboolean
2919 purple_program_is_valid(const char *program) 2929 purple_program_is_valid(const char *program)
2920 { 2930 {