GMime.Object¶
- Subclasses:
GMime.Message
,GMime.MessagePart
,GMime.Multipart
,GMime.Part
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
|
|
|
|
|
|
|
|
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
content_id |
r |
a Content-Id |
|
content_type |
r |
||
disposition |
r |
||
ensure_newline |
r |
||
headers |
r |
||
parent_object |
r |
parent |
Class Details¶
- class GMime.Object(**kwargs)¶
- Bases:
- Abstract:
Yes
- Structure:
Base class for all MIME parts.
- classmethod new(options, content_type)¶
- Parameters:
options (
GMime.ParserOptions
orNone
) – aGMime.ParserOptions
orNone
content_type (
GMime.ContentType
) – aGMime.ContentType
object
- Returns:
an appropriate
GMime.Object
registered to handle MIME parts appropriate for content_type.- Return type:
Performs a lookup of registered
GMime.Object
subclasses, registered usingGMime.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:
options (
GMime.ParserOptions
orNone
) – aGMime.ParserOptions
orNone
type (
str
) – mime typesubtype (
str
) – mime subtype
- Returns:
an appropriate
GMime.Object
registered to handle mime-types of type/subtype.- Return type:
Performs a lookup of registered
GMime.Object
subclasses, registered usingGMime.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 typesubtype (
str
) – mime subtypeobject_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)¶
-
Appends a new header to the header list.
- encode(constraint)¶
- Parameters:
constraint (
GMime.EncodingConstraint
) – aGMime.EncodingConstraint
Calculates and sets the most efficient Content-Transfer-Encoding for this
GMime.Object
and all child parts based on the constraint provided.
- get_autocrypt_headers(effective_date, matchheader, addresses, keep_incomplete)¶
- Parameters:
effective_date (
GLib.DateTime
) – aGLib.DateTime
objectmatchheader (
str
) – the header we want to matchaddresses (
GMime.InternetAddressList
) – aGMime.InternetAddressList
keep_incomplete (
bool
) –True
if the we should include incompletes
- Returns:
a new
GMime.AutocryptHeaderList
object, orNone
on error.- Return type:
Creates a new
GMime.AutocryptHeaderList
of relevant headers of the given type based on the addresses of an self.Each header in the returned list will:
have a valid address
be of the type requested
be complete
If no Autocrypt header is found for an address, no
GMime.AutocryptHeader
will be in the list associated with that e-mail address.Note that the following types of Autocrypt headers will not be returned by this function:
headers of an unrequested type
headers that do not match an address in “From:”
unparseable headers
headers with unknown critical attributes
duplicate valid headers for a given address
On error (e.g. if this version of GMime cannot handle the requested Autocrypt type, or if a parameter is missing or malformed), returns
None
The returned Autocrypt headers will have it effective_date set to effective_date
if keep_incomplete isn’t set, incompletes are removed
- get_content_disposition()¶
- Returns:
the
GMime.ContentDisposition
set on the MIME object.- Return type:
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:
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:
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:
Gets the
GMime.ContentType
object for the given MIME object orNone
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:
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
orGMime.DISPOSITION_INLINE
.- Return type:
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:
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:
Get the header list for self.
- get_headers(options)¶
- Parameters:
options (
GMime.FormatOptions
orNone
) – aGMime.FormatOptions
orNone
- Returns:
an allocated string containing all of the raw MIME headers.
Note: The returned string will not be suitable for display.
- Return type:
Allocates a string buffer containing all of the MIME object’s raw headers.
- prepend_header(header, value, charset)¶
-
Prepends a new header to the header list.
- remove_header(header)¶
- Parameters:
header (
str
) – header name- Returns:
True
if the header was removed orFalse
if it could not be found.- Return type:
Removed the specified header if it exists.
- set_content_disposition(disposition)¶
- Parameters:
disposition (
GMime.ContentDisposition
) – aGMime.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)¶
-
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
) – aGMime.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)¶
-
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
orGMime.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)¶
-
Sets a header to the specified value.
- to_string(options)¶
- Parameters:
options (
GMime.FormatOptions
orNone
) – aGMime.FormatOptions
orNone
- Returns:
an allocated string containing the contents of the mime object.
- Return type:
Allocates a string buffer containing the contents of self.
- write_content_to_stream(options, stream)¶
- Parameters:
options (
GMime.FormatOptions
orNone
) – aGMime.FormatOptions
orNone
stream (
GMime.Stream
) – stream
- Returns:
the number of bytes written or %-1 on fail.
- Return type:
Write only the content of the MIME object to stream.
- write_to_stream(options, stream)¶
- Parameters:
options (
GMime.FormatOptions
orNone
) – aGMime.FormatOptions
orNone
stream (
GMime.Stream
) – stream
- Returns:
the number of bytes written or %-1 on fail.
- Return type:
Write the headers and content of the MIME object to stream.
- do_encode(constraint) virtual¶
- Parameters:
constraint (
GMime.EncodingConstraint
) – aGMime.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
orNone
) – aGMime.FormatOptions
orNone
- Returns:
an allocated string containing all of the raw MIME headers.
Note: The returned string will not be suitable for display.
- Return type:
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
) – aGMime.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:
options (
GMime.FormatOptions
) –content_only (
bool
) –stream (
GMime.Stream
) –
- Return type: