## GMimeObject GMimeObject — Abstract MIME objects |

## Functions

void | (*GMimeObjectForeachFunc) ()
void | g_mime_object_register_type ()
GMimeObject * | g_mime_object_new ()
GMimeObject * | g_mime_object_new_type ()
void | g_mime_object_set_content_type ()
GMimeContentType * | g_mime_object_get_content_type ()
void | g_mime_object_set_content_type_parameter ()
const char * | g_mime_object_get_content_type_parameter ()
void | g_mime_object_set_disposition ()
const char * | g_mime_object_get_disposition ()
void | g_mime_object_set_content_disposition ()
GMimeContentDisposition * | g_mime_object_get_content_disposition ()
void | g_mime_object_set_content_disposition_parameter ()
const char * | g_mime_object_get_content_disposition_parameter ()
void | g_mime_object_set_content_id ()
const char * | g_mime_object_get_content_id ()
void | g_mime_object_prepend_header ()
void | g_mime_object_append_header ()
gboolean | g_mime_object_remove_header ()
void | g_mime_object_set_header ()
const char * | g_mime_object_get_header ()
char * | g_mime_object_get_headers ()
GMimeHeaderList * | g_mime_object_get_header_list ()
ssize_t | g_mime_object_write_to_stream ()
char * | g_mime_object_to_string ()
void | g_mime_object_encode ()

## Types and Values

struct | GMimeObject

## Object Hierarchy

        GObject
        ╰── GMimeObject
            ├── GMimeMessage
            ├── GMimePart
            ├── GMimeMultipart
            ╰── GMimeMessagePart

## Description

GMimeObject is an abstract class from which all message and MIME parts are derived.

## Functions

### GMimeObjectForeachFunc ()

    void
    (*GMimeObjectForeachFunc) (GMimeObject *parent,
                               GMimeObject *part,
                               gpointer user_data);

The function signature for a callback to `g_mime_message_foreach()` and `g_mime_multipart_foreach()`.

#### Parameters

parent | parent GMimeObject |
part | a GMimeObject |
user_data | User-supplied callback data. |

### g_mime_object_register_type ()

    void
    g_mime_object_register_type (const char *type,
                                 const char *subtype,
                                 GType object_type);

Registers the object type `object_type` for use with the `g_mime_object_new_type()` convenience function.

Note: You may use the wildcard "*" to match any type and/or subtype.

#### Parameters

type | mime type |
subtype | mime subtype |
object_type | object type |

### g_mime_object_new ()

    GMimeObject *
    g_mime_object_new (GMimeParserOptions *options,
                       GMimeContentType *content_type);

Performs a lookup of registered GMimeObject subclasses, registered using `g_mime_object_register_type()`, to find an appropriate class capable of handling MIME parts of the specified Content-Type. If no class has been registered to handle that type, it looks for a registered class that can handle `content_type` 's media type. If that also fails, then it will use the generic part class, GMimePart.

#### Parameters

options | a GMimeParserOptions or `NULL`. | [nullable]
content_type | a GMimeContentType object |

#### Returns

an appropriate GMimeObject registered to handle MIME parts appropriate for `content_type` .

### g_mime_object_new_type ()

    GMimeObject *
    g_mime_object_new_type (GMimeParserOptions *options,
                            const char *type,
                            const char *subtype);

Performs a lookup of registered GMimeObject subclasses, registered using `g_mime_object_register_type()`, to find an appropriate class capable of handling MIME parts of type `type` /`subtype` . If no class has been registered to handle that type, it looks for a registered class that can handle `type` . If that also fails, then it will use the generic part class, GMimePart.

#### Parameters

options | a GMimeParserOptions or `NULL`. | [nullable]
type | mime type |
subtype | mime subtype |

#### Returns

an appropriate GMimeObject registered to handle mime-types of `type` /`subtype` .

### g_mime_object_set_content_type ()

    void
    g_mime_object_set_content_type (GMimeObject *object,
                                    GMimeContentType *content_type);

Sets the content-type for the specified MIME object and then serializes it to the Content-Type header field.

#### Parameters

object | a GMimeObject |
content_type | a GMimeContentType object |

### g_mime_object_get_content_type ()

    GMimeContentType *
    g_mime_object_get_content_type (GMimeObject *object);

Gets the GMimeContentType object for the given MIME object or `NULL` on fail.

#### Parameters

object | a GMimeObject |

#### Returns

the content-type object for the specified MIME object.

[transfer none]

### g_mime_object_set_content_type_parameter ()

    void
    g_mime_object_set_content_type_parameter
                                   (GMimeObject *object,
                                    const char *name,
                                    const char *value);

Sets the content-type param `name` to the value `value` .

Note: The `name` string should be in US-ASCII while the `value` string should be in UTF-8.

#### Parameters

object | a GMimeObject |
name | param name |
value | param value |

### g_mime_object_get_content_type_parameter ()

    const char *
    g_mime_object_get_content_type_parameter
                                   (GMimeObject *object,
                                    const char *name);

Gets the value of the content-type param `name` set on the MIME part `object` .

#### Parameters

object | a GMimeObject |
name | param name |

#### Returns

the value of the requested content-type param or `NULL` if the param doesn't exist. If the param is set, the returned string will be in UTF-8.

### g_mime_object_set_disposition ()

    void
    g_mime_object_set_disposition (GMimeObject *object,
                                   const char *disposition);

Sets the disposition to `disposition` which may be one of GMIME_DISPOSITION_ATTACHMENT or GMIME_DISPOSITION_INLINE or, by your choice, any other string which would indicate how the MIME part should be displayed by the MUA.

#### Parameters

object | a GMimeObject |
disposition | disposition ("attachment" or "inline") |

### g_mime_object_get_disposition ()

    const char *
    g_mime_object_get_disposition (GMimeObject *object);

Gets the MIME object's disposition if set or `NULL` otherwise.

#### Parameters

object | a GMimeObject |

#### Returns

the disposition string which is probably one of GMIME_DISPOSITION_ATTACHMENT or GMIME_DISPOSITION_INLINE.

### g_mime_object_set_content_disposition ()

    void
    g_mime_object_set_content_disposition (GMimeObject *object,
                                           GMimeContentDisposition *disposition);

Set the content disposition for the specified mime part and then serializes it to the Content-Disposition header field.

#### Parameters

object | a GMimeObject |
disposition | a GMimeContentDisposition object |

### g_mime_object_get_content_disposition ()

    GMimeContentDisposition *
    g_mime_object_get_content_disposition (GMimeObject *object);

Gets the GMimeContentDisposition for the specified MIME object.

#### Parameters

object | a GMimeObject |

#### Returns

the GMimeContentDisposition set on the MIME object.

[transfer none]

### g_mime_object_set_content_disposition_parameter ()

    void
    g_mime_object_set_content_disposition_parameter
                                   (GMimeObject *object,
                                    const char *name,
                                    const char *value);

Add a content-disposition parameter to the specified mime part.

Note: The `name` string should be in US-ASCII while the `value` string should be in UTF-8.

#### Parameters

object | a GMimeObject |
name | parameter name |
value | parameter value |

### g_mime_object_get_content_disposition_parameter ()

    const char *
    g_mime_object_get_content_disposition_parameter
                                   (GMimeObject *object,
                                    const char *name);

Gets the value of the Content-Disposition parameter specified by `name` , or `NULL` if the parameter does not exist.

#### Parameters

object | a GMimeObject |
name | parameter name |

#### Returns

the value of the requested content-disposition param or `NULL` if the param doesn't exist. If the param is set, the returned string will be in UTF-8.

### g_mime_object_set_content_id ()

    void
    g_mime_object_set_content_id (GMimeObject *object,
                                  const char *content_id);

Sets the Content-Id of the MIME object.

#### Parameters

object | a GMimeObject |
content_id | content-id (addr-spec portion) |

### g_mime_object_get_content_id ()

    const char *
    g_mime_object_get_content_id (GMimeObject *object);

Gets the Content-Id of the MIME object or NULL if one is not set.

#### Parameters

object | a GMimeObject |

#### Returns

a const pointer to the Content-Id header.

### g_mime_object_prepend_header ()

    void
    g_mime_object_prepend_header (GMimeObject *object,
                                  const char *header,
                                  const char *value,
                                  const char *charset);

Prepends a new header to the header list.

#### Parameters

object | a GMimeObject |
header | header name |
value | header value |
charset | a charset |

### g_mime_object_append_header ()

    void
    g_mime_object_append_header (GMimeObject *object,
                                 const char *header,
                                 const char *value,
                                 const char *charset);

Appends a new header to the header list.

#### Parameters

object | a GMimeObject |
header | header name |
value | header value |
charset | a charset |

### g_mime_object_remove_header ()

    gboolean
    g_mime_object_remove_header (GMimeObject *object,
                                 const char *header);

Removed the specified header if it exists.

#### Parameters

object | a GMimeObject |
header | header name |

#### Returns

`TRUE` if the header was removed or `FALSE` if it could not be found.

### g_mime_object_set_header ()

    void
    g_mime_object_set_header (GMimeObject *object,
                              const char *header,
                              const char *value,
                              const char *charset);

Sets a header to the specified value.

#### Parameters

object | a GMimeObject |
header | header name |
value | header value |
charset | a charset |

### g_mime_object_get_header ()

    const char *
    g_mime_object_get_header (GMimeObject *object,
                              const char *header);

Gets the value of the first header with the specified name.

#### Parameters

object | a GMimeObject |
header | header name |

#### Returns

the value of the requested header if it exists or `NULL` otherwise.

### g_mime_object_get_headers ()

    char *
    g_mime_object_get_headers (GMimeObject *object,
                               GMimeFormatOptions *options);

Allocates a string buffer containing all of the MIME object's raw headers.

#### Parameters

object | a GMimeObject |
options | a GMimeFormatOptions or `NULL`. | [nullable]

#### Returns

an allocated string containing all of the raw MIME headers.

Note: The returned string will not be suitable for display.

### g_mime_object_get_header_list ()

    GMimeHeaderList *
    g_mime_object_get_header_list (GMimeObject *object);

Get the header list for `object` .

#### Parameters

object | a GMimeObject |

#### Returns

the GMimeHeaderList for `object` . Do not free this pointer when you are done with it.

[transfer none]

### g_mime_object_write_to_stream ()

    ssize_t
    g_mime_object_write_to_stream (GMimeObject *object,
                                   GMimeFormatOptions *options,
                                   GMimeStream *stream);

Write the contents of the MIME object to `stream` .

#### Parameters

object | a GMimeObject |
options | a GMimeFormatOptions or `NULL`. | [nullable]
stream | stream |

#### Returns

the number of bytes written or `-1` on fail.

### g_mime_object_to_string ()

    char *
    g_mime_object_to_string (GMimeObject *object,
                             GMimeFormatOptions *options);

Allocates a string buffer containing the contents of `object` .

#### Parameters

object | a GMimeObject |
options | a GMimeFormatOptions or `NULL`. | [nullable]

#### Returns

an allocated string containing the contents of the mime object.

### g_mime_object_encode ()

    void
    g_mime_object_encode (GMimeObject *object,
                          GMimeEncodingConstraint constraint);

Calculates and sets the most efficient Content-Transfer-Encoding for this GMimeObject and all child parts based on the `constraint` provided.

#### Parameters

object | a GMimeObject |
constraint | a GMimeEncodingConstraint |

## Types and Values

### struct GMimeObject

    struct GMimeObject;

Base class for all MIME parts.

#### Members