## GMimePart

GMimePart — MIME parts

## Functions

GMimePart * | g_mime_part_new ()
GMimePart * | g_mime_part_new_with_type ()
gboolean | g_mime_part_is_attachment ()
void | g_mime_part_set_content_description ()
const char * | g_mime_part_get_content_description ()
void | g_mime_part_set_content_id ()
const char * | g_mime_part_get_content_id ()
void | g_mime_part_set_content_md5 ()
const char * | g_mime_part_get_content_md5 ()
gboolean | g_mime_part_verify_content_md5 ()
void | g_mime_part_set_content_location ()
const char * | g_mime_part_get_content_location ()
void | g_mime_part_set_content_encoding ()
GMimeContentEncoding | g_mime_part_get_content_encoding ()
GMimeContentEncoding | g_mime_part_get_best_content_encoding ()
void | g_mime_part_set_filename ()
const char * | g_mime_part_get_filename ()
GMimeDataWrapper * | g_mime_part_get_content ()
void | g_mime_part_set_content ()
GMimeOpenPGPData | g_mime_part_get_openpgp_data ()
void | g_mime_part_set_openpgp_data ()
gboolean | g_mime_part_openpgp_encrypt ()
GMimeDecryptResult * | g_mime_part_openpgp_decrypt ()
gboolean | g_mime_part_openpgp_sign ()
GMimeSignatureList * | g_mime_part_openpgp_verify ()

## Types and Values

struct | GMimePart

## Object Hierarchy

        GObject
        ╰── GMimeObject
            ╰── GMimePart
                ├── GMimeApplicationPkcs7Mime
                ├── GMimeMessagePartial
                ╰── GMimeTextPart

## Description

A GMimePart represents any MIME leaf part (meaning it has no sub-parts).

## Functions

### g_mime_part_new ()

    GMimePart *
    g_mime_part_new (void);

Creates a new MIME Part object with a default content-type of application/octet-stream.

#### Returns

an empty MIME Part object with a default content-type of application/octet-stream.

### g_mime_part_new_with_type ()

    GMimePart *
    g_mime_part_new_with_type (const char *type,
                               const char *subtype);

Creates a new MIME Part with a sepcified type.

#### Parameters

type | content-type string |
subtype | content-subtype string |

#### Returns

an empty MIME Part object with the specified content-type.

### g_mime_part_is_attachment ()

    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.

#### Parameters

mime_part | a GMimePart object |

#### Returns

`TRUE` if the part is an attachment, otherwise `FALSE`.

### g_mime_part_set_content_description ()

    void
    g_mime_part_set_content_description (GMimePart *mime_part,
                                         const char *description);

Set the content description for the specified mime part.

#### Parameters

mime_part | a GMimePart object |
description | content description |

### g_mime_part_get_content_description ()

    const char *
    g_mime_part_get_content_description (GMimePart *mime_part);

Gets the value of the Content-Description for the specified mime part if it exists or `NULL` otherwise.

#### Parameters

mime_part | a GMimePart object |

#### Returns

the content description for the specified mime part.

### g_mime_part_set_content_id ()

    void
    g_mime_part_set_content_id (GMimePart *mime_part,
                                const char *content_id);

Set the content id for the specified mime part.

#### Parameters

mime_part | a GMimePart object |
content_id | content id |

### g_mime_part_get_content_id ()

    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.

#### Parameters

mime_part | a GMimePart object |

#### Returns

the content id for the specified mime part.

### g_mime_part_set_content_md5 ()

    void
    g_mime_part_set_content_md5 (GMimePart *mime_part,
                                 const char *content_md5);

Set the content md5 for the specified mime part.

#### Parameters

mime_part | a GMimePart object |
content_md5 | content md5 or `NULL` to generate the md5 digest. |

### g_mime_part_get_content_md5 ()

    const char *
    g_mime_part_get_content_md5 (GMimePart *mime_part);

Gets the md5sum contained in the Content-Md5 header of the specified mime part if it exists, or `NULL` otherwise.

#### Parameters

mime_part | a GMimePart object |

#### Returns

the content md5 for the specified mime part.

### g_mime_part_verify_content_md5 ()

    gboolean
    g_mime_part_verify_content_md5 (GMimePart *mime_part);

Verify the content md5 for the specified mime part.

#### Parameters

mime_part | a GMimePart object |

#### Returns

`TRUE` if the md5 is valid or `FALSE` otherwise. Note: will return `FALSE` if the mime part does not contain a Content-MD5.

### g_mime_part_set_content_location ()

    void
    g_mime_part_set_content_location (GMimePart *mime_part,
                                      const char *content_location);

Set the content location for the specified mime part.

#### Parameters

mime_part | a GMimePart object |
content_location | content location |

### g_mime_part_get_content_location ()

    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.

#### Parameters

mime_part | a GMimePart object |

#### Returns

the content location for the specified mime part.

### g_mime_part_set_content_encoding ()

    void
    g_mime_part_set_content_encoding (GMimePart *mime_part,
                                      GMimeContentEncoding encoding);

Set the content encoding for the specified mime part.

#### Parameters

mime_part | a GMimePart object |
encoding | a GMimeContentEncoding |

### g_mime_part_get_content_encoding ()

    GMimeContentEncoding
    g_mime_part_get_content_encoding (GMimePart *mime_part);

Gets the content encoding of the mime part.

#### Parameters

mime_part | a GMimePart object |

#### Returns

the content encoding for the specified mime part.

### g_mime_part_get_best_content_encoding ()

    GMimeContentEncoding
    g_mime_part_get_best_content_encoding (GMimePart *mime_part,
                                           GMimeEncodingConstraint constraint);

Calculates the most efficient content encoding for the `mime_part` given the `constraint` .

#### Parameters

mime_part | a GMimePart object |
constraint | a GMimeEncodingConstraint |

#### Returns

the best content encoding for the specified mime part.

### g_mime_part_set_filename ()

    void
    g_mime_part_set_filename (GMimePart *mime_part,
                              const char *filename);

Sets the "filename" parameter on the Content-Disposition and also sets the "name" parameter on the Content-Type.

Note: The `filename` string should be in UTF-8.

#### Parameters

mime_part | a GMimePart object |
filename | the file name |

### g_mime_part_get_filename ()

    const char *
    g_mime_part_get_filename (GMimePart *mime_part);

Gets the filename of the specificed mime part, or `NULL` if the `mime_part` does not have the filename or name parameter set.

#### Parameters

mime_part | a GMimePart object |

#### Returns

the filename of the specified `mime_part` or `NULL` if neither of the parameters is set. If a file name is set, the returned string will be in UTF-8.

### g_mime_part_get_content ()

    GMimeDataWrapper *
    g_mime_part_get_content (GMimePart *mime_part);

Gets the internal data-wrapper of the specified mime part, or `NULL` on error.

#### Parameters

mime_part | a GMimePart object |

#### Returns

the data-wrapper for the mime part's contents.

[transfer none]

### g_mime_part_set_content ()

    void
    g_mime_part_set_content (GMimePart *mime_part,
                             GMimeDataWrapper *content);

Sets the content on the mime part.

#### Parameters

mime_part | a GMimePart object |
content | a GMimeDataWrapper content object |

### g_mime_part_get_openpgp_data ()

    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.

#### Parameters

mime_part | a GMimePart |

#### Returns

a GMimeOpenPGPData.

### g_mime_part_set_openpgp_data ()

    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.

#### Parameters

mime_part | a GMimePart |
data | a GMimeOpenPGPData |

### g_mime_part_openpgp_encrypt ()

    gboolean
    g_mime_part_openpgp_encrypt (GMimePart *mime_part,
                                 gboolean sign,
                                 const char *userid,
                                 GMimeEncryptFlags flags,
                                 GPtrArray *recipients,
                                 GError **err);

Encrypts (and optionally signs) the content of the `mime_part` and then replaces the content with the new, encrypted, content.

#### Parameters

mime_part | a GMimePart |
sign | `TRUE` if the content should also be signed; otherwise, `FALSE` |
userid | the key id (or email address) to use when signing (assuming `sign` is `TRUE`). | [nullable]
flags | a set of GMimeEncryptFlags |
recipients | an array of recipient key ids and/or email addresses. | [element-type utf8]
err | a GError |

#### Returns

`TRUE` on success or `FALSE` on error.

### g_mime_part_openpgp_decrypt ()

    GMimeDecryptResult *
    g_mime_part_openpgp_decrypt (GMimePart *mime_part,
                                 GMimeDecryptFlags flags,
                                 const char *session_key,
                                 GError **err);

Decrypts the content of the `mime_part` and then replaces the content with the new, decrypted, content.

#### Parameters

mime_part | a GMimePart |
flags | a set of GMimeDecryptFlags |
session_key | the session key to use or `NULL`. | [nullable]
err | a GError |

#### Returns

a GMimeDecryptResult on success or `NULL` on error.

[nullable][transfer full]

### g_mime_part_openpgp_sign ()

    gboolean
    g_mime_part_openpgp_sign (GMimePart *mime_part,
                              const char *userid,
                              GError **err);

Signs the content of the `mime_part` and then replaces the content with the new, signed, content.

#### Parameters

mime_part | a GMimePart |
userid | the key id (or email address) to use for signing |
err | a GError |

#### Returns

`TRUE` on success or `FALSE` on error.

### g_mime_part_openpgp_verify ()

    GMimeSignatureList *
    g_mime_part_openpgp_verify (GMimePart *mime_part,
                                GMimeVerifyFlags flags,
                                GError **err);

Verifies the OpenPGP signature of the `mime_part` and then replaces the content with the original, raw, content.

#### Parameters

mime_part | a GMimePart |
flags | a set of GMimeVerifyFlags |
err | a GError |

#### Returns

a GMimeSignatureList on success or `NULL` on error.

[nullable][transfer full]

## Types and Values

### struct GMimePart

    struct GMimePart;

A leaf-node MIME part object.

#### Members