diff options
Diffstat (limited to 'mail/em-utils.c')
-rw-r--r-- | mail/em-utils.c | 128 |
1 files changed, 0 insertions, 128 deletions
diff --git a/mail/em-utils.c b/mail/em-utils.c index 45f54abbcf..2a7ce74c70 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1628,52 +1628,6 @@ em_utils_get_proxy_uri (const char *pUri) } /** - * em_utils_part_to_html: - * @part: - * - * Converts a mime part's contents into html text. If @credits is given, - * then it will be used as an attribution string, and the - * content will be cited. Otherwise no citation or attribution - * will be performed. - * - * Return Value: The part in displayable html format. - **/ -char * -em_utils_part_to_html(CamelMimePart *part, ssize_t *len, EMFormat *source) -{ - EMFormatQuote *emfq; - CamelStreamMem *mem; - GByteArray *buf; - char *text; - - buf = g_byte_array_new (); - mem = (CamelStreamMem *) camel_stream_mem_new (); - camel_stream_mem_set_byte_array (mem, buf); - - emfq = em_format_quote_new(NULL, (CamelStream *)mem, 0); - ((EMFormat *) emfq)->composer = TRUE; - if (source) { - /* copy over things we can, other things are internal, perhaps need different api than 'clone' */ - if (source->default_charset) - em_format_set_default_charset((EMFormat *)emfq, source->default_charset); - if (source->charset) - em_format_set_default_charset((EMFormat *)emfq, source->charset); - } - em_format_part((EMFormat *) emfq, (CamelStream *)mem, part); - g_object_unref(emfq); - - camel_stream_write((CamelStream *) mem, "", 1); - camel_object_unref(mem); - - text = (char *)buf->data; - if (len) - *len = buf->len-1; - g_byte_array_free (buf, FALSE); - - return text; -} - -/** * em_utils_message_to_html: * @message: * @credits: @@ -2328,88 +2282,6 @@ em_utils_contact_photo (struct _CamelInternetAddress *cia, gboolean local) return part; } -/** - * em_utils_snoop_type: - * @part: - * - * Tries to snoop the mime type of a part. - * - * Return value: NULL if unknown (more likely application/octet-stream). - **/ -const char * -em_utils_snoop_type(CamelMimePart *part) -{ - /* cache is here only to be able still return const char * */ - static GHashTable *types_cache = NULL; - - const char *filename; - char *name_type = NULL, *magic_type = NULL, *res, *tmp; - CamelDataWrapper *dw; - - filename = camel_mime_part_get_filename (part); - if (filename != NULL) - name_type = e_util_guess_mime_type (filename, FALSE); - - dw = camel_medium_get_content_object((CamelMedium *)part); - if (!camel_data_wrapper_is_offline(dw)) { - CamelStreamMem *mem = (CamelStreamMem *)camel_stream_mem_new(); - - if (camel_data_wrapper_decode_to_stream(dw, (CamelStream *)mem) > 0) { - char *ct = g_content_type_guess (filename, mem->buffer->data, mem->buffer->len, NULL); - - if (ct) - magic_type = g_content_type_get_mime_type (ct); - - g_free (ct); - } - camel_object_unref(mem); - } - - d(printf("snooped part, magic_type '%s' name_type '%s'\n", magic_type, name_type)); - - /* If gvfs doesn't recognize the data by magic, but it - * contains English words, it will call it text/plain. If the - * filename-based check came up with something different, use - * that instead and if it returns "application/octet-stream" - * try to do better with the filename check. - */ - - if (magic_type) { - if (name_type - && (!strcmp(magic_type, "text/plain") - || !strcmp(magic_type, "application/octet-stream"))) - res = name_type; - else - res = magic_type; - } else - res = name_type; - - - if (res != name_type) - g_free (name_type); - - if (res != magic_type) - g_free (magic_type); - - if (!types_cache) - types_cache = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) NULL); - - if (res) { - tmp = g_hash_table_lookup (types_cache, res); - if (tmp) { - g_free (res); - res = tmp; - } else { - g_hash_table_insert (types_cache, res, res); - } - } - - return res; - - /* We used to load parts to check their type, we dont anymore, - see bug #11778 for some discussion */ -} - void em_utils_clear_get_password_canceled_accounts_flag (void) { |