GMime.AutocryptHeader

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

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

class

new_from_string (string)

clone (src)

compare (ah2)

get_address ()

get_address_as_string ()

get_effective_date ()

get_keydata ()

get_prefer_encrypt ()

is_complete ()

set_address (address)

set_address_from_string (address)

set_effective_date (effective_date)

set_keydata (keydata)

set_prefer_encrypt (pref)

to_string (gossip)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

address

GMime.InternetAddressMailbox

r

the GMime.InternetAddressMailbox associated with this Autocrypt header.

effective_date

GLib.DateTime

r

the date associated with the Autocrypt header in this message.

keydata

GLib.Bytes

r

the raw binary form of the encoded key.

parent_object

GObject.Object

r

parent GObject.Object

prefer_encrypt

GMime.AutocryptPreferEncrypt

r

a GMime.AutocryptPreferEncrypt value (defaults to GMime.AutocryptPreferEncrypt.NONE).

Class Details

class GMime.AutocryptHeader(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

GMime.AutocryptHeaderClass

An object containing Autocrypt information about a given e-mail address, as derived from a message header.

See https://autocrypt.org/ for details and motivation.

classmethod new()
Returns:

a new GMime.AutocryptHeader object.

Return type:

GMime.AutocryptHeader

Creates a new GMime.AutocryptHeader object.

classmethod new_from_string(string)
Parameters:

string (str) – The raw string value of an Autocrypt header

Returns:

a new GMime.AutocryptHeader object, or None on error.

Return type:

GMime.AutocryptHeader

Creates a new GMime.AutocryptHeader object based on the value of an Autocrypt: header.

Note that this will not have an effective_date set, since the effective_date is derived from the Date: line in the same block of e-mail headers, but cannot be extracted from the raw Autocrypt: header itself.

clone(src)
Parameters:

src (GMime.AutocryptHeader) – a GMime.AutocryptHeader object

If address and type already match between src and self, copy keydata, prefer_encrypt, effective_date from src to self.

compare(ah2)
Parameters:

ah2 (GMime.AutocryptHeader) – a GMime.AutocryptHeader object

Returns:

-1, 0, or 1 when self is less than, equal to, or greater than ah2.

Return type:

int

Compare two Autocrypt Headers. This is useful for comparison, as well as for sorting headers by:

  • address

  • effective_date

  • keydata

  • prefer_encrypt

get_address()
Returns:

the address associated with the Autocrypt header

Return type:

GMime.InternetAddressMailbox

Gets the internal address of the Autocrypt header, or None if not set.

get_address_as_string()
Returns:

the address associated with the Autocrypt header

Return type:

str

Gets the internal address of the Autocrypt header as a C string, or None if not set.

get_effective_date()
Returns:

the effective date associated with the Autocrypt header

Return type:

GLib.DateTime

Gets the effective date of the Autocrypt header, or None if not set.

get_keydata()
Returns:

the raw key data associated with the Autocrypt header

Return type:

GLib.Bytes

Gets the raw keydata of the Autocrypt header, or None if not set.

get_prefer_encrypt()
Returns:

the encryption preference associated with the Autocrypt header

Return type:

GMime.AutocryptPreferEncrypt

Gets the encryption preference stated by the Autocrypt header.

is_complete()
Returns:

True if the header is complete, or False if it is incomplete.

Return type:

bool

When dealing with Autocrypt headers derived from a message, some sender addresses will not have a legitimate/complete header associated with them. When a given sender address has no complete header of a specific type, it should “reset” the state of the associated address.

set_address(address)
Parameters:

address (GMime.InternetAddressMailbox) – a GMime.InternetAddressMailbox value

Set the address associated with the autocrypt_header.

set_address_from_string(address)
Parameters:

address (str) – a None-terminated string that is a raw e-mail address

Set the address associated with the autocrypt_header.

set_effective_date(effective_date)
Parameters:

effective_date (GLib.DateTime) – a GLib.DateTime object

Set the effective date associated with the Autocrypt header.

set_keydata(keydata)
Parameters:

keydata (GLib.Bytes) – a GLib.Bytes object

Set the raw key data associated with the Autocrypt header.

set_prefer_encrypt(pref)
Parameters:

pref (GMime.AutocryptPreferEncrypt) – a GMime.AutocryptPreferEncrypt value

Set the encryption preference associated with the Autocrypt header.

to_string(gossip)
Parameters:

gossip (bool) – a bool, indicating whether this header is for use with gossip

Returns:

the string representation of the Autocrypt header.

Return type:

str

Gets the string representation of the Autocrypt header, or None on error. For example, it might return:

prefer-encrypt=mutual; addr=bob\`example`.com; keydata=AAAB15BE…

If you are using this object to populate an Autocrypt-Gossip header, you should set gossip to True (this will suppress inclusion of prefer-encrypt).