[gmime] Documentation and minor code cleanup



commit 3d1ec05bf628fd10d47cc0212d5ec8385f4adbaf
Author: Jeffrey Stedfast <fejj gnome org>
Date:   Wed Dec 20 11:48:47 2017 -0500

    Documentation and minor code cleanup

 docs/reference/gmime-docs.sgml    |    2 +
 docs/reference/gmime-sections.txt |    7 +-
 gmime/gmime-autocrypt.c           |  151 ++++++++++++++++++++----------------
 gmime/gmime-autocrypt.h           |   12 ++--
 gmime/gmime-certificate.c         |    2 +-
 gmime/gmime-header.h              |    3 +-
 gmime/gmime-message.h             |    2 +-
 gmime/gmime-stream.h              |    2 +-
 8 files changed, 101 insertions(+), 80 deletions(-)
---
diff --git a/docs/reference/gmime-docs.sgml b/docs/reference/gmime-docs.sgml
index 8626d9f..69c9f05 100644
--- a/docs/reference/gmime-docs.sgml
+++ b/docs/reference/gmime-docs.sgml
@@ -3,6 +3,7 @@
                "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"; [
 <!ENTITY gmime-Init SYSTEM "xml/gmime.xml">
 <!ENTITY GMimeApplicationPkcs7Mime SYSTEM "xml/gmime-application-pkcs7-mime.xml">
+<!ENTITY GMimeAutocrypt SYSTEM "xml/gmime-autocrypt.xml">
 <!ENTITY GMimeParam SYSTEM "xml/gmime-param.xml">
 <!ENTITY GMimeHeader SYSTEM "xml/gmime-header.xml">
 <!ENTITY GMimeContentType SYSTEM "xml/gmime-content-type.xml">
@@ -183,6 +184,7 @@ string utilities, file utilities, a main loop abstraction, and so on.
     &gmime-utils;
     &GMimeReferences;
     &GMimeFormatOptions;
+    &GMimeAutocrypt;
   </part>
 
   <part id="classes">
diff --git a/docs/reference/gmime-sections.txt b/docs/reference/gmime-sections.txt
index 5808c62..fed5340 100644
--- a/docs/reference/gmime-sections.txt
+++ b/docs/reference/gmime-sections.txt
@@ -196,6 +196,8 @@ GMIME_STREAM_MEM_GET_CLASS
 GMimeStreamMmap
 g_mime_stream_mmap_new
 g_mime_stream_mmap_new_with_bounds
+g_mime_stream_mmap_get_owner
+g_mime_stream_mmap_set_owner
 
 <SUBSECTION Private>
 g_mime_stream_mmap_get_type
@@ -481,6 +483,7 @@ GMIME_FILTER_HTML_GET_CLASS
 GMimeFilterChecksum
 g_mime_filter_checksum_new
 g_mime_filter_checksum_get_digest
+g_mime_filter_checksum_get_string
 
 <SUBSECTION Private>
 g_mime_filter_checksum_get_type
@@ -504,7 +507,7 @@ GMimeFilterOpenPGP
 g_mime_filter_openpgp_new
 g_mime_filter_openpgp_get_data_type
 g_mime_filter_openpgp_get_begin_offset
-g_mime_filter_openpgp_get_enbd_offset
+g_mime_filter_openpgp_get_end_offset
 
 <SUBSECTION Private>
 g_mime_filter_openpgp_get_type
@@ -1134,7 +1137,6 @@ GMIME_TYPE_REFERENCES
 
 <SECTION>
 <FILE>gmime-utils</FILE>
-GMimeReferences
 g_mime_utils_header_decode_date
 g_mime_utils_header_format_date
 g_mime_utils_generate_message_id
@@ -1621,7 +1623,6 @@ GMIME_PKCS7_CONTEXT_GET_CLASS
 GMimePkcs7ContextClass
 </SECTION>
 
-
 <SECTION>
 <FILE>gmime-autocrypt</FILE>
 GMimeAutocryptPreferEncrypt
diff --git a/gmime/gmime-autocrypt.c b/gmime/gmime-autocrypt.c
index de10dd1..2b2f970 100644
--- a/gmime/gmime-autocrypt.c
+++ b/gmime/gmime-autocrypt.c
@@ -582,7 +582,7 @@ g_mime_autocrypt_header_clone (GMimeAutocryptHeader *dst, GMimeAutocryptHeader *
 
 
 static void g_mime_autocrypt_header_list_class_init (GMimeAutocryptHeaderListClass *klass);
-static void g_mime_autocrypt_header_list_init (GMimeAutocryptHeaderList *ahl, GMimeAutocryptHeaderListClass 
*klass);
+static void g_mime_autocrypt_header_list_init (GMimeAutocryptHeaderList *list, GMimeAutocryptHeaderListClass 
*klass);
 static void g_mime_autocrypt_header_list_finalize (GObject *object);
 
 static GObjectClass *ahl_parent_class = NULL;
@@ -623,17 +623,18 @@ g_mime_autocrypt_header_list_class_init (GMimeAutocryptHeaderListClass *klass)
 }
 
 static void
-g_mime_autocrypt_header_list_init (GMimeAutocryptHeaderList *ahl, GMimeAutocryptHeaderListClass *klass)
+g_mime_autocrypt_header_list_init (GMimeAutocryptHeaderList *list, GMimeAutocryptHeaderListClass *klass)
 {
-       ahl->array = g_ptr_array_new_with_free_func (g_object_unref);
+       list->array = g_ptr_array_new_with_free_func (g_object_unref);
 }
 
 static void
 g_mime_autocrypt_header_list_finalize (GObject *object)
 {
-       GMimeAutocryptHeaderList *ahl = (GMimeAutocryptHeaderList *) object;
-
-       g_ptr_array_unref (ahl->array);
+       GMimeAutocryptHeaderList *list = (GMimeAutocryptHeaderList *) object;
+       
+       g_ptr_array_unref (list->array);
+       
        G_OBJECT_CLASS (ahl_parent_class)->finalize (object);
 }
 
@@ -654,7 +655,7 @@ g_mime_autocrypt_header_list_new (void)
 
 /**
  * g_mime_autocrypt_header_list_add_missing_addresses:
- * @acheaders: a #GMimeAutocryptHeaderList object
+ * @list: a #GMimeAutocryptHeaderList object
  * @addresses: an #InternetAddressList object
  *
  * Adds a new incomplete #GMimeAutocryptHeader object for each
@@ -663,130 +664,146 @@ g_mime_autocrypt_header_list_new (void)
  * Returns: the number of addresses added
  **/
 guint
-g_mime_autocrypt_header_list_add_missing_addresses (GMimeAutocryptHeaderList *acheaders, InternetAddressList 
*list)
+g_mime_autocrypt_header_list_add_missing_addresses (GMimeAutocryptHeaderList *list, InternetAddressList 
*addresses)
 {
-       g_return_val_if_fail (GMIME_IS_AUTOCRYPT_HEADER_LIST (acheaders), 0);
-       guint ret = 0;
+       guint count = 0;
        guint i;
-       for (i = 0; i < internet_address_list_length (list); i++) {
-               InternetAddress *a = internet_address_list_get_address (list, i);
-               if (INTERNET_ADDRESS_IS_GROUP(a)) {
-                       ret += g_mime_autocrypt_header_list_add_missing_addresses (acheaders, 
internet_address_group_get_members (INTERNET_ADDRESS_GROUP (a)));
-               } else if (INTERNET_ADDRESS_IS_MAILBOX(a)) {
-                       InternetAddressMailbox *m = INTERNET_ADDRESS_MAILBOX (a);
-                       GMimeAutocryptHeader *ah = g_mime_autocrypt_header_list_get_header_for_address 
(acheaders, m);
-                       if (ah == NULL) {
+       
+       g_return_val_if_fail (GMIME_IS_AUTOCRYPT_HEADER_LIST (list), 0);
+       g_return_val_if_fail (IS_INTERNET_ADDRESS_LIST (addresses), 0);
+       
+       for (i = 0; i < internet_address_list_length (addresses); i++) {
+               InternetAddress *address = internet_address_list_get_address (addresses, i);
+               
+               if (INTERNET_ADDRESS_IS_GROUP (address)) {
+                       InternetAddressGroup *group = (InternetAddressGroup *) address;
+                       
+                       count += g_mime_autocrypt_header_list_add_missing_addresses (list, 
internet_address_group_get_members (group));
+               } else {
+                       InternetAddressMailbox *mailbox = (InternetAddressMailbox *) address;
+                       GMimeAutocryptHeader *ah;
+                       
+                       if (!(ah = g_mime_autocrypt_header_list_get_header_for_address (list, mailbox))) {
                                ah = g_mime_autocrypt_header_new ();
-                               g_mime_autocrypt_header_set_address (ah, m);
-                               g_mime_autocrypt_header_list_add (acheaders, ah);
-                               ret += 1;
+                               g_mime_autocrypt_header_set_address (ah, mailbox);
+                               g_mime_autocrypt_header_list_add (list, ah);
+                               count++;
                        }
-               } else {
-                       /* FIXME: what do we do here?  what is this
-                          thing if it's neither mailbox nor group?
-                          It should be safe to just ignore it. */
                }
        }
-       return ret;
+       
+       return count;
 }
 
 
 /**
  * g_mime_autocrypt_header_list_add:
- * @acheaders: a #GMimeAutocryptHeaderList object
- * @ah: a #GMimeAutocryptHeader object
+ * @list: a #GMimeAutocryptHeaderList object
+ * @header: a #GMimeAutocryptHeader object
  *
  * Adds a the passed #GMimeAutocryptHeader to the list.
  **/
 void
-g_mime_autocrypt_header_list_add (GMimeAutocryptHeaderList *acheaders, GMimeAutocryptHeader *ah)
+g_mime_autocrypt_header_list_add (GMimeAutocryptHeaderList *list, GMimeAutocryptHeader *header)
 {
-       g_return_if_fail (GMIME_IS_AUTOCRYPT_HEADER_LIST (acheaders));
-       g_return_if_fail (GMIME_IS_AUTOCRYPT_HEADER (ah));
-
-       g_object_ref (ah);
-       g_ptr_array_add (acheaders->array, ah);
+       g_return_if_fail (GMIME_IS_AUTOCRYPT_HEADER_LIST (list));
+       g_return_if_fail (GMIME_IS_AUTOCRYPT_HEADER (header));
+       
+       g_object_ref (header);
+       
+       g_ptr_array_add (list->array, header);
 }
 
+
 /**
  * g_mime_autocrypt_header_list_get_count:
- * @acheaders: a #GMimeAutocryptHeaderList object
+ * @list: a #GMimeAutocryptHeaderList object
  *
  * See how many Autocrypt headers are in the list.
  * 
  * Returns: the number of available Autocrypt headers
  **/
 guint
-g_mime_autocrypt_header_list_get_count (GMimeAutocryptHeaderList *acheaders)
+g_mime_autocrypt_header_list_get_count (GMimeAutocryptHeaderList *list)
 {
-       g_return_val_if_fail (GMIME_IS_AUTOCRYPT_HEADER_LIST (acheaders), 0);
-
-       return acheaders->array->len;
+       g_return_val_if_fail (GMIME_IS_AUTOCRYPT_HEADER_LIST (list), 0);
+       
+       return list->array->len;
 }
 
+
 /**
  * g_mime_autocrypt_header_list_get_header_at:
- * @acheaders: a #GMimeAutocryptHeaderList object
- * @n: an index into the list
+ * @list: a #GMimeAutocryptHeaderList object
+ * @index: an index into the list
  *
- * Get the Nth header in the list (returns %NULL on error, or if n is out of bounds)
+ * Get the Nth header in the list (returns %NULL on error, or if @index is out of bounds)
  * 
  * Returns: (transfer none): a pointer to the Nth header in the list.
  **/
 GMimeAutocryptHeader *
-g_mime_autocrypt_header_list_get_header_at (GMimeAutocryptHeaderList *acheaders, guint n)
+g_mime_autocrypt_header_list_get_header_at (GMimeAutocryptHeaderList *list, guint index)
 {
-       g_return_val_if_fail (GMIME_IS_AUTOCRYPT_HEADER_LIST (acheaders), NULL);
-
-       if (n < acheaders->array->len)
-               return (GMimeAutocryptHeader*)(acheaders->array->pdata[n]);
-
-       return NULL;
+       g_return_val_if_fail (GMIME_IS_AUTOCRYPT_HEADER_LIST (list), NULL);
+       
+       if (index >= list->array->len)
+               return NULL;
+       
+       return (GMimeAutocryptHeader *) list->array->pdata[index];
 }
 
+
 /**
  * g_mime_autocrypt_header_list_get_header_for_address:
- * @acheaders: a #GMimeAutocryptHeaderList object
- * @addr: an #InternetAddressMailbox object
+ * @list: a #GMimeAutocryptHeaderList object
+ * @mailbox: an #InternetAddressMailbox object
  *
- * returns an Autocrypt header corresponding to the given
- * InternetAddressMailbox.
+ * Gets the Autocrypt header corresponding to the given @mailbox.
  * 
  * Returns: (transfer none): a pointer to the header in the list which
  * matches the requested address, or %NULL if no such header exists in
  * the list.
  **/
 GMimeAutocryptHeader *
-g_mime_autocrypt_header_list_get_header_for_address (GMimeAutocryptHeaderList *acheaders, 
InternetAddressMailbox *addr)
+g_mime_autocrypt_header_list_get_header_for_address (GMimeAutocryptHeaderList *list, InternetAddressMailbox 
*mailbox)
 {
-       g_return_val_if_fail (GMIME_IS_AUTOCRYPT_HEADER_LIST (acheaders), NULL);
-       g_return_val_if_fail (INTERNET_ADDRESS_IS_MAILBOX (addr), NULL);
-
+       const char *idn;
        guint i;
-       for (i = 0; i < acheaders->array->len; i++) {
-               GMimeAutocryptHeader* ah = (GMimeAutocryptHeader*)(acheaders->array->pdata[i]);
-               if (g_strcmp0 (internet_address_mailbox_get_idn_addr (addr), 
internet_address_mailbox_get_idn_addr (ah->address)) == 0)
+       
+       g_return_val_if_fail (GMIME_IS_AUTOCRYPT_HEADER_LIST (list), NULL);
+       g_return_val_if_fail (INTERNET_ADDRESS_IS_MAILBOX (mailbox), NULL);
+       
+       idn = internet_address_mailbox_get_idn_addr (mailbox);
+       
+       for (i = 0; i < list->array->len; i++) {
+               GMimeAutocryptHeader *ah = (GMimeAutocryptHeader *) list->array->pdata[i];
+               const char *addr = internet_address_mailbox_get_idn_addr (ah->address);
+               
+               if (!g_strcmp0 (idn, addr))
                        return ah;
        }
+       
        return NULL;
 }
 
 /**
  * g_mime_autocrypt_header_list_remove_incomplete:
- * @acheaders: a #GMimeAutocryptHeaderList object
+ * @list: a #GMimeAutocryptHeaderList object
  *
  * Remove all incomplete Autocrypt headers from the list.
  **/
 void
-g_mime_autocrypt_header_list_remove_incomplete (GMimeAutocryptHeaderList *acheaders)
+g_mime_autocrypt_header_list_remove_incomplete (GMimeAutocryptHeaderList *list)
 {
-       g_return_if_fail (GMIME_IS_AUTOCRYPT_HEADER_LIST (acheaders));
-
        guint i;
-       for (i = 0; i < acheaders->array->len; i++) {
-               GMimeAutocryptHeader* ah = (GMimeAutocryptHeader*)(acheaders->array->pdata[i]);
+       
+       g_return_if_fail (GMIME_IS_AUTOCRYPT_HEADER_LIST (list));
+       
+       for (i = 0; i < list->array->len; i++) {
+               GMimeAutocryptHeader *ah = (GMimeAutocryptHeader *) list->array->pdata[i];
+               
                if (!g_mime_autocrypt_header_is_complete (ah)) {
-                       g_ptr_array_remove_index (acheaders->array, i);
+                       g_ptr_array_remove_index (list->array, i);
                        i--;
                }
        }
diff --git a/gmime/gmime-autocrypt.h b/gmime/gmime-autocrypt.h
index c6b9297..8826d72 100644
--- a/gmime/gmime-autocrypt.h
+++ b/gmime/gmime-autocrypt.h
@@ -134,13 +134,13 @@ struct _GMimeAutocryptHeaderListClass {
 GType g_mime_autocrypt_header_list_get_type (void);
 
 GMimeAutocryptHeaderList *g_mime_autocrypt_header_list_new (void);
-guint g_mime_autocrypt_header_list_add_missing_addresses (GMimeAutocryptHeaderList *ahl, InternetAddressList 
*list);
-void g_mime_autocrypt_header_list_add (GMimeAutocryptHeaderList *ahl, GMimeAutocryptHeader *ah);
+guint g_mime_autocrypt_header_list_add_missing_addresses (GMimeAutocryptHeaderList *list, 
InternetAddressList *addresses);
+void g_mime_autocrypt_header_list_add (GMimeAutocryptHeaderList *list, GMimeAutocryptHeader *header);
 
-guint g_mime_autocrypt_header_list_get_count (GMimeAutocryptHeaderList *acheaders);
-GMimeAutocryptHeader *g_mime_autocrypt_header_list_get_header_at (GMimeAutocryptHeaderList *acheaders, guint 
n);
-GMimeAutocryptHeader *g_mime_autocrypt_header_list_get_header_for_address (GMimeAutocryptHeaderList 
*acheaders, InternetAddressMailbox *addr);
-void g_mime_autocrypt_header_list_remove_incomplete (GMimeAutocryptHeaderList *acheaders);
+guint g_mime_autocrypt_header_list_get_count (GMimeAutocryptHeaderList *list);
+GMimeAutocryptHeader *g_mime_autocrypt_header_list_get_header_at (GMimeAutocryptHeaderList *list, guint 
index);
+GMimeAutocryptHeader *g_mime_autocrypt_header_list_get_header_for_address (GMimeAutocryptHeaderList *list, 
InternetAddressMailbox *mailbox);
+void g_mime_autocrypt_header_list_remove_incomplete (GMimeAutocryptHeaderList *list);
 
 
 G_END_DECLS
diff --git a/gmime/gmime-certificate.c b/gmime/gmime-certificate.c
index 32913b2..2d60b99 100644
--- a/gmime/gmime-certificate.c
+++ b/gmime/gmime-certificate.c
@@ -451,7 +451,7 @@ g_mime_certificate_get_name (GMimeCertificate *cert)
 /**
  * g_mime_certificate_set_user_id:
  * @cert: a #GMimeCertificate
- * @name: the full User ID for a certificate
+ * @user_id: the full User ID for a certificate
  *
  * Set the certificate's full User ID.  By convention, this is usually
  * a mail name-addr as described in RFC 5322.  (e.g. "Jane Doe
diff --git a/gmime/gmime-header.h b/gmime/gmime-header.h
index 52275da..4ec9b59 100644
--- a/gmime/gmime-header.h
+++ b/gmime/gmime-header.h
@@ -81,11 +81,12 @@ char *g_mime_header_format_default (GMimeHeader *header, GMimeFormatOptions *opt
  * A message or mime-part header.
  **/
 struct _GMimeHeader {
+       /* <private> */
        GObject parent_object;
        
        char *name, *value;
        
-       /* < private > */
+       /* <private> */
        GMimeHeaderRawValueFormatter formatter;
        GMimeParserOptions *options;
        gboolean reformat;
diff --git a/gmime/gmime-message.h b/gmime/gmime-message.h
index 657eb07..217065f 100644
--- a/gmime/gmime-message.h
+++ b/gmime/gmime-message.h
@@ -87,7 +87,7 @@ struct _GMimeMessage {
        GDateTime *date;
        char *subject;
        
-       /* < private > */
+       /* <private> */
        char *marker;
 };
 
diff --git a/gmime/gmime-stream.h b/gmime/gmime-stream.h
index 99e3022..9e57197 100644
--- a/gmime/gmime-stream.h
+++ b/gmime/gmime-stream.h
@@ -77,9 +77,9 @@ typedef struct {
  * Abstract I/O stream class.
  **/
 struct _GMimeStream {
+       /* <private> */
        GObject parent_object;
        
-       /* <private> */
        GMimeStream *super_stream;
        
        gint64 position;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]