GMime.Object

g GMime.Object GMime.Object GObject.Object GObject.Object GObject.Object->GMime.Object

Subclasses:

GMime.Message, GMime.MessagePart, GMime.Multipart, GMime.Part

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (options, content_type)

class

new_type (options, type, subtype)

class

register_type (type, subtype, object_type)

class

type_registry_init ()

class

type_registry_shutdown ()

append_header (header, value, charset)

encode (constraint)

get_content_disposition ()

get_content_disposition_parameter (name)

get_content_id ()

get_content_type ()

get_content_type_parameter (name)

get_disposition ()

get_header (header)

get_header_list ()

get_headers (options)

prepend_header (header, value, charset)

remove_header (header)

set_content_disposition (disposition)

set_content_disposition_parameter (name, value)

set_content_id (content_id)

set_content_type (content_type)

set_content_type_parameter (name, value)

set_disposition (disposition)

set_header (header, value, charset)

to_string (options)

write_content_to_stream (options, stream)

write_to_stream (options, stream)

Virtual Methods

Inherited:

GObject.Object (7)

do_encode (constraint)

do_get_headers (options)

do_header_added (header)

do_header_changed (header)

do_header_removed (header)

do_headers_cleared ()

do_set_content_type (content_type)

do_write_to_stream (options, content_only, stream)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

content_id

str

r

a Content-Id

content_type

GMime.ContentType

r

a GMime.ContentType

disposition

GMime.ContentDisposition

r

a GMime.ContentDisposition

ensure_newline

bool

r

headers

GMime.HeaderList

r

a GMime.HeaderList

parent_object

GObject.Object

r

parent GObject.Object

Class Details

class GMime.Object(**kwargs)
Bases:

GObject.Object

Abstract:

Yes

Structure:

GMime.ObjectClass

Base class for all MIME parts.

classmethod new(options, content_type)
Parameters:
Returns:

an appropriate GMime.Object registered to handle MIME parts appropriate for content_type.

Return type:

GMime.Object

Performs a lookup of registered GMime.Object subclasses, registered using GMime.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, GMime.Part.

classmethod new_type(options, type, subtype)
Parameters:
Returns:

an appropriate GMime.Object registered to handle mime-types of type/subtype.

Return type:

GMime.Object

Performs a lookup of registered GMime.Object subclasses, registered using GMime.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, GMime.Part.

classmethod register_type(type, subtype, object_type)
Parameters:
  • type (str) – mime type

  • subtype (str) – mime subtype

  • object_type (GObject.GType) – object type

Registers the object type object_type for use with the GMime.Object.new_type() convenience function.

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

classmethod type_registry_init()
classmethod type_registry_shutdown()
append_header(header, value, charset)
Parameters:
  • header (str) – header name

  • value (str) – header value

  • charset (str) – a charset

Appends a new header to the header list.

encode(constraint)
Parameters:

constraint (GMime.EncodingConstraint) – a GMime.EncodingConstraint

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

get_content_disposition()
Returns:

the GMime.ContentDisposition set on the MIME object.

Return type:

GMime.ContentDisposition

Gets the GMime.ContentDisposition for the specified MIME object.

get_content_disposition_parameter(name)
Parameters:

name (str) – parameter name

Returns:

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

Return type:

str

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

get_content_id()
Returns:

a const pointer to the Content-Id header.

Return type:

str

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

get_content_type()
Returns:

the content-type object for the specified MIME object.

Return type:

GMime.ContentType

Gets the GMime.ContentType object for the given MIME object or None on fail.

get_content_type_parameter(name)
Parameters:

name (str) – param name

Returns:

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

Return type:

str

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

get_disposition()
Returns:

the disposition string which is probably one of GMime.DISPOSITION_ATTACHMENT or GMime.DISPOSITION_INLINE.

Return type:

str

Gets the MIME object’s disposition if set or None otherwise.

get_header(header)
Parameters:

header (str) – header name

Returns:

the value of the requested header if it exists or None otherwise.

Return type:

str

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

get_header_list()
Returns:

the GMime.HeaderList for self. Do not free this pointer when you are done with it.

Return type:

GMime.HeaderList

Get the header list for self.

get_headers(options)
Parameters:

options (GMime.FormatOptions or None) – a GMime.FormatOptions or None

Returns:

an allocated string containing all of the raw MIME headers.

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

Return type:

str

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

prepend_header(header, value, charset)
Parameters:
  • header (str) – header name

  • value (str) – header value

  • charset (str) – a charset

Prepends a new header to the header list.

remove_header(header)
Parameters:

header (str) – header name

Returns:

True if the header was removed or False if it could not be found.

Return type:

bool

Removed the specified header if it exists.

set_content_disposition(disposition)
Parameters:

disposition (GMime.ContentDisposition) – a GMime.ContentDisposition object

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

set_content_disposition_parameter(name, value)
Parameters:
  • name (str) – parameter name

  • value (str) – parameter 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.

set_content_id(content_id)
Parameters:

content_id (str) – content-id (addr-spec portion)

Sets the Content-Id of the MIME object.

set_content_type(content_type)
Parameters:

content_type (GMime.ContentType) – a GMime.ContentType object

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

set_content_type_parameter(name, value)
Parameters:
  • name (str) – param name

  • value (str) – param 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.

set_disposition(disposition)
Parameters:

disposition (str) – disposition (“attachment” or “inline”)

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.

set_header(header, value, charset)
Parameters:
  • header (str) – header name

  • value (str) – header value

  • charset (str) – a charset

Sets a header to the specified value.

to_string(options)
Parameters:

options (GMime.FormatOptions or None) – a GMime.FormatOptions or None

Returns:

an allocated string containing the contents of the mime object.

Return type:

str

Allocates a string buffer containing the contents of self.

write_content_to_stream(options, stream)
Parameters:
Returns:

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

Return type:

int

Write only the content of the MIME object to stream.

write_to_stream(options, stream)
Parameters:
Returns:

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

Return type:

int

Write the headers and content of the MIME object to stream.

do_encode(constraint) virtual
Parameters:

constraint (GMime.EncodingConstraint) – a GMime.EncodingConstraint

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

do_get_headers(options) virtual
Parameters:

options (GMime.FormatOptions or None) – a GMime.FormatOptions or None

Returns:

an allocated string containing all of the raw MIME headers.

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

Return type:

str

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

do_header_added(header) virtual
Parameters:

header (GMime.Header) –

do_header_changed(header) virtual
Parameters:

header (GMime.Header) –

do_header_removed(header) virtual
Parameters:

header (GMime.Header) –

do_headers_cleared() virtual
do_set_content_type(content_type) virtual
Parameters:

content_type (GMime.ContentType) – a GMime.ContentType object

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

do_write_to_stream(options, content_only, stream) virtual
Parameters:
Return type:

int