[gmime: 17/23] Autocrypt: add g_mime_message_get_autocrypt_gossip_headers()
- From: Jeffrey Stedfast <fejj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gmime: 17/23] Autocrypt: add g_mime_message_get_autocrypt_gossip_headers()
- Date: Sun, 29 Oct 2017 14:17:05 +0000 (UTC)
commit 45f5304019dd1ebaf14221c7f08cb274004a0480
Author: Daniel Kahn Gillmor <dkg fifthhorseman net>
Date: Mon Oct 23 15:40:41 2017 -0400
Autocrypt: add g_mime_message_get_autocrypt_gossip_headers()
This introduces a simple API for getting gossiped headers from a
message.
docs/reference/gmime-sections.txt | 1 +
gmime/gmime-message.c | 55 +++++++++++++++++++++++++++++++++---
gmime/gmime-message.h | 1 +
3 files changed, 52 insertions(+), 5 deletions(-)
---
diff --git a/docs/reference/gmime-sections.txt b/docs/reference/gmime-sections.txt
index 3586ad2..e79a28e 100644
--- a/docs/reference/gmime-sections.txt
+++ b/docs/reference/gmime-sections.txt
@@ -1002,6 +1002,7 @@ g_mime_message_get_mime_part
g_mime_message_foreach
g_mime_message_get_body
g_mime_message_get_autocrypt_headers
+g_mime_message_get_autocrypt_gossip_headers
<SUBSECTION Private>
g_mime_message_get_type
diff --git a/gmime/gmime-message.c b/gmime/gmime-message.c
index ece367c..cdbb98d 100644
--- a/gmime/gmime-message.c
+++ b/gmime/gmime-message.c
@@ -1232,7 +1232,56 @@ g_mime_message_get_autocrypt_headers (GMimeMessage *message, gint actype, GDateT
return _get_autocrypt_headers (message, actype, now, "autocrypt",
message->addrlists[GMIME_ADDRESS_TYPE_FROM], TRUE);
}
-
+
+/**
+ * g_mime_message_get_autocrypt_gossip_headers:
+ * @message: a #GMimeMessage object.
+ * @actype: the desired version of autocrypt headers
+ * @now: a #GDateTime object, or %NULL
+ *
+ * Creates a new #GMimeAutocryptHeaderList of relevant headers of the
+ * given type based on the recipient(s) of an e-mail message.
+ *
+ * Each header in the list will:
+ *
+ * - have a valid address
+ * - be of the type requested
+ * - be complete
+ *
+ * If no Autocrypt header is found for a recipient, no
+ * #GMimeAutocryptHeader 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), returns %NULL
+ *
+ * The returned Autocrypt headers will have their effective_date set
+ * to the earliest of either:
+ *
+ * - the Date: header of the message or
+ * - @now (or the current time, if @now is %NULL)
+ *
+ * Returns: (transfer full): a new #GMimeAutocryptHeaderList object
+ **/
+GMimeAutocryptHeaderList *
+g_mime_message_get_autocrypt_gossip_headers (GMimeMessage *message, gint actype, GDateTime *now)
+{
+ g_return_val_if_fail (GMIME_IS_MESSAGE (message), NULL);
+ InternetAddressList *addresses = g_mime_message_get_all_recipients (message);
+ GMimeAutocryptHeaderList *ret = _get_autocrypt_headers (message, actype, now, "autocrypt-gossip",
addresses, FALSE);
+ g_object_unref (addresses);
+ return ret;
+}
+
+
static GMimeAutocryptHeaderList *
_get_autocrypt_headers (GMimeMessage *message, gint actype, GDateTime *now, const char *matchheader,
InternetAddressList *addresses, gboolean keep_incomplete)
@@ -1297,7 +1346,3 @@ _get_autocrypt_headers (GMimeMessage *message, gint actype, GDateTime *now, cons
g_date_time_unref (newnow);
return ret;
}
-
-
-/* TODO: Autocrypt: a function that produces a list of
- Autocrypt-Gossip headers from a message */
diff --git a/gmime/gmime-message.h b/gmime/gmime-message.h
index 7357242..5125a37 100644
--- a/gmime/gmime-message.h
+++ b/gmime/gmime-message.h
@@ -124,6 +124,7 @@ GMimeObject *g_mime_message_get_mime_part (GMimeMessage *message);
void g_mime_message_set_mime_part (GMimeMessage *message, GMimeObject *mime_part);
GMimeAutocryptHeaderList *g_mime_message_get_autocrypt_headers (GMimeMessage *part, gint actype, GDateTime
*now);
+GMimeAutocryptHeaderList *g_mime_message_get_autocrypt_gossip_headers (GMimeMessage *part, gint actype,
GDateTime *now);
/* convenience functions */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]