static void mime_part_set_header (GMimeObject *object, const char *header, const char *value) { if (!process_header (object, header, value)) GMIME_OBJECT_CLASS (parent_class)->set_header (object, header, value); else g_mime_header_list_set (object->headers, header, value); }
/** * g_mime_part_set_content_encoding: * @mime_part: a #GMimePart object * @encoding: a #GMimeContentEncoding * * Set the content encoding for the specified mime part. **/ void g_mime_part_set_content_encoding (GMimePart *mime_part, GMimeContentEncoding encoding) { g_return_if_fail (GMIME_IS_PART (mime_part)); mime_part->encoding = encoding; g_mime_header_list_set (GMIME_OBJECT (mime_part)->headers, "Content-Transfer-Encoding", g_mime_content_encoding_to_string (encoding)); }
/** * g_mime_part_set_content_location: * @mime_part: a #GMimePart object * @content_location: content location * * Set the content location for the specified mime part. **/ void g_mime_part_set_content_location (GMimePart *mime_part, const char *content_location) { g_return_if_fail (GMIME_IS_PART (mime_part)); if (mime_part->content_location == content_location) return; g_free (mime_part->content_location); mime_part->content_location = g_strdup (content_location); g_mime_header_list_set (GMIME_OBJECT (mime_part)->headers, "Content-Location", content_location); }
/** * g_mime_part_set_content_md5: * @mime_part: a #GMimePart object * @content_md5: content md5 or %NULL to generate the md5 digest. * * Set the content md5 for the specified mime part. **/ void g_mime_part_set_content_md5 (GMimePart *mime_part, const char *content_md5) { unsigned char digest[16], b64digest[32]; GMimeStreamFilter *filtered_stream; GMimeContentType *content_type; GMimeFilter *md5_filter; GMimeStream *stream; guint32 save = 0; int state = 0; size_t len; g_return_if_fail (GMIME_IS_PART (mime_part)); g_free (mime_part->content_md5); if (!content_md5) { /* compute a md5sum */ stream = g_mime_stream_null_new (); filtered_stream = (GMimeStreamFilter *) g_mime_stream_filter_new (stream); g_object_unref (stream); content_type = g_mime_object_get_content_type ((GMimeObject *) mime_part); if (g_mime_content_type_is_type (content_type, "text", "*")) { GMimeFilter *crlf_filter; crlf_filter = g_mime_filter_crlf_new (TRUE, FALSE); g_mime_stream_filter_add (filtered_stream, crlf_filter); g_object_unref (crlf_filter); } md5_filter = g_mime_filter_md5_new (); g_mime_stream_filter_add (filtered_stream, md5_filter); stream = (GMimeStream *) filtered_stream; g_mime_data_wrapper_write_to_stream (mime_part->content, stream); g_object_unref (stream); memset (digest, 0, 16); g_mime_filter_md5_get_digest ((GMimeFilterMd5 *) md5_filter, digest); g_object_unref (md5_filter); len = g_mime_encoding_base64_encode_close (digest, 16, b64digest, &state, &save); b64digest[len] = '\0'; g_strstrip ((char *) b64digest); content_md5 = (const char *) b64digest; } mime_part->content_md5 = g_strdup (content_md5); g_mime_header_list_set (GMIME_OBJECT (mime_part)->headers, "Content-Md5", content_md5); }
static void content_disposition_changed (GMimeContentDisposition *disposition, gpointer args, GMimeObject *object) { char *str; if (object->disposition) { str = g_mime_content_disposition_to_string (object->disposition, FALSE); g_mime_header_list_set (object->headers, "Content-Disposition", str); g_free (str); } else { g_mime_header_list_remove (object->headers, "Content-Disposition"); } }
static void content_type_changed (GMimeContentType *content_type, gpointer args, GMimeObject *object) { GMimeParam *params; GString *string; char *type, *p; string = g_string_new ("Content-Type: "); type = g_mime_content_type_to_string (content_type); g_string_append (string, type); g_free (type); if ((params = content_type->params)) g_mime_param_write_to_string (params, FALSE, string); p = string->str; g_string_free (string, FALSE); type = p + strlen ("Content-Type: "); g_mime_header_list_set (object->headers, "Content-Type", type); g_free (p); }