| Top |
GMimePart *
g_mime_part_new (void);
Creates a new MIME Part object with a default content-type of application/octet-stream.
GMimePart * g_mime_part_new_with_type (const char *type,const char *subtype);
Creates a new MIME Part with the specified type.
gboolean
g_mime_part_is_attachment (GMimePart *mime_part);
Determines whether or not the part is an attachment based on the value of the Content-Disposition header.
void g_mime_part_set_content_description (GMimePart *mime_part,const char *description);
Sets Content-Description, trimming surrounding ASCII linear whitespace
(SP, HTAB, CR and LF). Other whitespace is preserved.
Empty descriptions are allowed; NULL removes all matching headers.
Assigning the current cached value preserves raw headers and duplicates.
Assignment before the first read replaces matching duplicates even if
the first header already has the same value.
const char *
g_mime_part_get_content_description (GMimePart *mime_part);
Gets the first Content-Description value, trimming surrounding ASCII linear whitespace without changing the header. Matching header changes invalidate the cached value; duplicate headers do not override the first.
void g_mime_part_set_content_duration (GMimePart *mime_part,int duration);
Sets Content-Duration to a nonnegative decimal Int32 value, replacing matching duplicate headers. -1 removes all Content-Duration headers. Values below -1 are programming errors and leave the part unchanged.
Assigning the current cached value preserves raw headers and duplicates. Before the first read, even -1 removes malformed headers; after a read that returns -1, assigning -1 is a no-op until matching headers change.
int
g_mime_part_get_content_duration (GMimePart *mime_part);
Gets the duration in seconds from the first Content-Duration header. Only a complete nonnegative decimal Int32 value in the raw header with optional surrounding ASCII linear whitespace is accepted. Signs, comments, fractions, and overflow are invalid; an invalid first header does not fall back to duplicates. RFC 2047 encoded words are not decoded. Reads preserve raw headers. Matching header changes invalidate the cache.
void g_mime_part_set_content_id (GMimePart *mime_part,const char *content_id);
Sets the content ID, or removes all Content-Id headers if content_id
is
NULL. See g_mime_entity_set_content_id() for validation and normalization.
const char *
g_mime_part_get_content_id (GMimePart *mime_part);
Gets the content-id of the specified mime part if it exists, or
NULL otherwise.
void g_mime_part_set_content_md5 (GMimePart *mime_part,const char *content_md5);
Sets the Content-MD5 header, trimming leading and trailing ASCII linear
whitespace (SP, HTAB, CR and LF). Empty values are allowed. This does not
read the content or compute a digest; use
g_mime_part_compute_content_md5() separately.
Assigning the current cached value preserves raw headers and duplicates.
Before the first read, assignment replaces matching duplicates even if
the first header already has the same value. Comparison precedes trimming.
const char *
g_mime_part_get_content_md5 (GMimePart *mime_part);
Gets the first Content-MD5 value, trimming surrounding ASCII linear whitespace
without changing raw headers. Matching header changes invalidate the
cached value; later duplicates do not override the first header.
Missing headers return NULL; values empty after trimming return "".
char * g_mime_part_compute_content_md5 (GMimePart *mime_part,GError **error);
Computes the base64-encoded MD5 of the decoded content in canonical form. For text parts, bare LF bytes become CRLF without adding a final newline or converting the charset. Other media types are hashed verbatim. No headers, content objects or transfer encodings are changed.
The backing stream is rewound before reading and left at EOF on success,
without being closed. On failure, it is left at its current position.
A new computation rewinds again; concurrent use of the shared source
can interfere with reading, as described in g_mime_content_open().
Missing content or a missing backing stream reports
GMIME_ERROR_INVALID_OPERATION. Rewind and read failures report a
GMIME_ERROR using errno, or GMIME_ERROR_GENERAL if errno is unset.
A zero-byte read without EOF reports EIO instead of a partial digest.
gboolean g_mime_part_verify_content_md5 (GMimePart *mime_part,GError **error);
Compares the Content-MD5 value with an independently computed digest
using exact, case-sensitive equality. Missing or empty trimmed values and
missing content return FALSE without reading the source or setting
an error. Other failures follow g_mime_part_compute_content_md5().
void g_mime_part_set_content_location (GMimePart *mime_part,const char *content_location);
Sets the content location. See g_mime_entity_set_content_location() for
URI validation, duplicate-header handling, and removal with NULL.
const char *
g_mime_part_get_content_location (GMimePart *mime_part);
Gets the value of the Content-Location header if it exists, or
NULL otherwise.
void g_mime_part_set_content_encoding (GMimePart *mime_part,GMimeContentEncoding encoding);
Sets the desired transfer encoding using its canonical header name.
GMIME_CONTENT_ENCODING_UNSPECIFIED removes all matching headers.
Assigning the current cached value preserves raw headers and duplicates;
before the first read, assignment replaces or removes matching headers.
Values outside GMimeContentEncoding are programming errors and leave
the part unchanged. This does not change the backing content's encoding.
GMimeContentEncoding
g_mime_part_get_content_encoding (GMimePart *mime_part);
Gets the desired transfer encoding from the first matching header,
without rewriting raw headers. A missing or unrecognized first value
returns GMIME_CONTENT_ENCODING_UNSPECIFIED, without falling back to
later duplicates. Matching header edits invalidate the lazy cache.
The raw value is parsed without RFC 2047 decoding. The legacy 7-bit and
8-bit aliases remain supported.
GMimeContentEncoding g_mime_part_get_best_content_encoding (GMimePart *mime_part,GMimeEncodingConstraint constraint,GError **error);
Calculates the most efficient content encoding using a maximum line
length of 78, excluding CRLF. This is equivalent to calling
g_mime_part_get_best_content_encoding_with_max_line_length() with that
limit, including its content dispatch, positioning and error behavior.
GMimeContentEncoding g_mime_part_get_best_content_encoding_with_max_line_length (GMimePart *mime_part,GMimeEncodingConstraint constraint,guint max_line_length,GError **error);
Analyzes decoded text and message content without changing headers, content objects or transfer encodings. Missing text/message content returns 7bit. Other media types return binary for the binary constraint and base64 otherwise, without reading content. These fast paths do not validate the constraint or line limit, matching MimeKit.
Analysis calls g_mime_content_decode_to_stream(), honoring content write
and decode overrides. The default content implementation rewinds its source
before reading and again on success, leaving it open. I/O failures preserve
the failure position and report a GMIME_ERROR using errno, or
GMIME_ERROR_GENERAL if errno is unset. A missing backing stream reports
GMIME_ERROR_INVALID_OPERATION.
The line limit and constraint are validated after successful analysis;
invalid values report EINVAL. No encoding is returned for partial content
after an I/O error, even if a selection could otherwise be made.
mime_part |
a GMimePart object |
|
constraint |
||
max_line_length |
maximum line length, excluding CRLF, from 60 through 998 |
|
error |
return location for a GError, or |
void g_mime_part_set_filename (GMimePart *mime_part,const char *filename);
Sets both the Content-Disposition filename and Content-Type name
parameters without trimming their values. A non-NULL value creates an
attachment disposition if absent; existing dispositions are preserved.
An empty string is an explicit filename. NULL removes both parameters
without creating or removing a disposition.
Existing parameter objects and formatting metadata are preserved. Invalid UTF-8 is a programming error and leaves the part unchanged.
const char *
g_mime_part_get_filename (GMimePart *mime_part);
Gets the Content-Disposition filename, falling back to the Content-Type name only if the filename parameter is absent. Parameter values are preserved without trimming or changing the raw headers. Empty and all-whitespace filenames do not trigger the fallback.
The returned filename is untrusted and is not sanitized for filesystem use.
GMimeContent *
g_mime_part_get_content (GMimePart *mime_part);
Gets the content of the specified mime part, or NULL if no content
has been assigned.
void g_mime_part_set_content (GMimePart *mime_part,GMimeContent *content);
Sets the content on the mime part, or clears it when content
is NULL.
The part retains a reference to content
.
GMimeOpenPGPData
g_mime_part_get_openpgp_data (GMimePart *mime_part);
Gets whether or not (and what type) of OpenPGP data is contained within the GMimePart.
void g_mime_part_set_openpgp_data (GMimePart *mime_part,GMimeOpenPGPData data);
Sets whether or not (and what type) of OpenPGP data is contained within the GMimePart.
gboolean g_mime_part_openpgp_encrypt (GMimePart *mime_part,gpgme_ctx_t ctx,gboolean sign,gpgme_encrypt_flags_t flags,gpgme_key_t *recipients,gpgme_key_t *hidden_recipients,gpgme_encrypt_result_t *encrypt_result,gpgme_sign_result_t *sign_result,GError **err);
Encrypts (and optionally signs) the content of the mime_part
and then replaces
the content with the new, encrypted, content.
Hidden recipients receive the same content without exposing their key IDs.
See g_mime_gpgme_encrypt() for recipient-array and encryption-flag semantics.
[skip]
mime_part |
||
ctx |
a borrowed GPGME OpenPGP context |
|
sign |
|
|
flags |
native GPGME encryption flags |
|
recipients |
borrowed NULL-terminated recipient keys. |
[nullable] |
hidden_recipients |
borrowed NULL-terminated hidden recipient keys. |
[nullable] |
encrypt_result |
a retained encryption result. |
[out][optional] |
sign_result |
a retained signing result. |
[out][optional] |
err |
a GError |
gboolean g_mime_part_openpgp_decrypt (GMimePart *mime_part,gpgme_ctx_t ctx,gpgme_decrypt_result_t *decrypt_result,gpgme_verify_result_t *verify_result,GError **err);
Decrypts the content of the mime_part
and then replaces the content with
the new, decrypted, content.
[skip]
gboolean g_mime_part_openpgp_sign (GMimePart *mime_part,gpgme_ctx_t ctx,gpgme_sign_result_t *result,GError **err);
Signs the content of the mime_part
and then replaces the content with
the new, signed, content.
[skip]