[evolution-data-server] Bug 761346 - More Camel introspection fixes



commit e27fa9c97b80cb8c7b5f64e2e986f3349ffa5a17
Author: Corentin Noël <corentin elementary io>
Date:   Tue Feb 9 14:42:37 2016 +0100

    Bug 761346 - More Camel introspection fixes

 camel/camel-charset-map.c               |    4 +-
 camel/camel-cipher-context.c            |    5 +
 camel/camel-cipher-context.h            |    1 +
 camel/camel-folder-summary.c            |   16 ++--
 camel/camel-iconv.c                     |   30 +++---
 camel/camel-iconv.h                     |    7 +-
 camel/camel-mime-filter-tohtml.c        |    4 +-
 camel/camel-mime-utils.c                |  166 ++++++++-----------------------
 camel/camel-mime-utils.h                |   26 +----
 camel/camel-nntp-address.c              |   10 +-
 camel/camel-sasl-digest-md5.c           |    6 +-
 camel/camel-store.c                     |    5 +
 camel/camel-store.h                     |    1 +
 camel/camel-url-scanner.c               |   18 ++--
 camel/camel-url-scanner.h               |   22 ++--
 camel/tests/message/test2.c             |   14 ++--
 camel/tests/misc/test1.c                |   15 ++--
 configure.ac                            |    5 +-
 docs/reference/camel/camel-sections.txt |    6 -
 iconv-detect.c                          |   15 ++--
 20 files changed, 141 insertions(+), 235 deletions(-)
---
diff --git a/camel/camel-charset-map.c b/camel/camel-charset-map.c
index 8fa7ec1..59ab17e 100644
--- a/camel/camel-charset-map.c
+++ b/camel/camel-charset-map.c
@@ -133,7 +133,7 @@ gint main (gint argc, gchar **argv)
        gchar in[128];
        gint i, j, k;
        gint bytes;
-       iconv_t cd;
+       GIConv cd;
 
        /* dont count the terminator */
        bytes = (G_N_ELEMENTS (tables) + 7 - 1) / 8;
@@ -174,7 +174,7 @@ gint main (gint argc, gchar **argv)
        /* Mutibyte tables */
        for (; tables[j].name && tables[j].multibyte; j++) {
                cd = iconv_open (tables[j].name, UCS);
-               if (cd == (iconv_t) -1)
+               if (cd == (GIConv) -1)
                        continue;
 
                for (c = 128, i = 0; c < 65535 && i < 65535; c++) {
diff --git a/camel/camel-cipher-context.c b/camel/camel-cipher-context.c
index 9f4d7e9..4c0ee25 100644
--- a/camel/camel-cipher-context.c
+++ b/camel/camel-cipher-context.c
@@ -75,6 +75,11 @@ enum {
 
 G_DEFINE_TYPE (CamelCipherContext, camel_cipher_context, G_TYPE_OBJECT)
 
+G_DEFINE_BOXED_TYPE (CamelCipherValidity,
+               camel_cipher_validity,
+               camel_cipher_validity_clone,
+               camel_cipher_validity_free)
+
 static void
 async_context_free (AsyncContext *async_context)
 {
diff --git a/camel/camel-cipher-context.h b/camel/camel-cipher-context.h
index 71bd11e..966eafa 100644
--- a/camel/camel-cipher-context.h
+++ b/camel/camel-cipher-context.h
@@ -260,6 +260,7 @@ CamelCipherValidity *
                                                 GError **error);
 
 /* CamelCipherValidity utility functions */
+GType          camel_cipher_validity_get_type  (void);
 CamelCipherValidity *
                camel_cipher_validity_new       (void);
 void           camel_cipher_validity_init      (CamelCipherValidity *validity);
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 9c15582..235d9c5 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -3623,14 +3623,14 @@ message_info_new_from_header (CamelFolderSummary *summary,
                               struct _camel_header_raw *h)
 {
        const gchar *received, *date, *content, *charset = NULL;
-       struct _camel_header_references *refs, *irt, *scan;
+       GSList *refs, *irt, *scan;
        gchar *subject, *from, *to, *cc, *mlist;
        CamelContentType *ct = NULL;
        CamelMessageInfoBase *mi;
        guint8 *digest;
        gsize length;
        gchar *msgid;
-       gint count;
+       guint count;
 
        length = g_checksum_type_get_length (G_CHECKSUM_MD5);
        digest = g_alloca (length);
@@ -3691,7 +3691,7 @@ message_info_new_from_header (CamelFolderSummary *summary,
 
        /* decode our references and in-reply-to headers */
        refs = camel_header_references_decode (camel_header_raw_find (&h, "references", NULL));
-       irt = camel_header_references_inreplyto_decode (camel_header_raw_find (&h, "in-reply-to", NULL));
+       irt = camel_header_references_decode (camel_header_raw_find (&h, "in-reply-to", NULL));
        if (refs || irt) {
                if (irt) {
                        /* The References field is populated from the "References" and/or "In-Reply-To"
@@ -3704,24 +3704,22 @@ message_info_new_from_header (CamelFolderSummary *summary,
                        refs = irt;
                }
 
-               count = camel_header_references_list_size (&refs);
+               count = g_slist_length (refs);
                mi->references = g_malloc (sizeof (*mi->references) + ((count - 1) * sizeof 
(mi->references->references[0])));
                count = 0;
-               scan = refs;
-               while (scan) {
+               for (scan = refs; scan != NULL; scan = g_slist_next (scan)) {
                        GChecksum *checksum;
 
                        checksum = g_checksum_new (G_CHECKSUM_MD5);
-                       g_checksum_update (checksum, (guchar *) scan->id, -1);
+                       g_checksum_update (checksum, (guchar *) scan->data, -1);
                        g_checksum_get_digest (checksum, digest, &length);
                        g_checksum_free (checksum);
 
                        memcpy (mi->references->references[count].id.hash, digest, sizeof 
(mi->message_id.id.hash));
                        count++;
-                       scan = scan->next;
                }
                mi->references->size = count;
-               camel_header_references_list_clear (&refs);
+               g_slist_free_full (refs, g_free);
        }
 
        return (CamelMessageInfo *) mi;
diff --git a/camel/camel-iconv.c b/camel/camel-iconv.c
index 52ad895..d3ab956 100644
--- a/camel/camel-iconv.c
+++ b/camel/camel-iconv.c
@@ -45,7 +45,7 @@ struct _iconv_cache_node {
        struct _iconv_cache *parent;
 
        gint busy;
-       iconv_t ip;
+       GIConv ip;
 };
 
 struct _iconv_cache {
@@ -360,9 +360,9 @@ flush_entry (struct _iconv_cache *ic)
        struct _iconv_cache_node *in;
 
        while ((in = g_queue_pop_head (&ic->open)) != NULL) {
-               if (in->ip != (iconv_t) - 1) {
+               if (in->ip != (GIConv) -1) {
                        g_hash_table_remove (iconv_cache_open, in->ip);
-                       iconv_close (in->ip);
+                       g_iconv_close (in->ip);
                }
                g_free (in);
        }
@@ -372,7 +372,7 @@ flush_entry (struct _iconv_cache *ic)
 }
 
 /* This should run pretty quick, its called a lot */
-iconv_t
+GIConv
 camel_iconv_open (const gchar *oto,
                   const gchar *ofrom)
 {
@@ -382,11 +382,11 @@ camel_iconv_open (const gchar *oto,
        struct _iconv_cache *ic;
        struct _iconv_cache_node *in;
        gint errnosav;
-       iconv_t ip;
+       GIConv ip;
 
        if (oto == NULL || ofrom == NULL) {
                errno = EINVAL;
-               return (iconv_t) -1;
+               return (GIConv) -1;
        }
 
        to = camel_iconv_charset_name (oto);
@@ -436,7 +436,7 @@ camel_iconv_open (const gchar *oto,
        if (in != NULL && !in->busy) {
                cd (printf ("using existing iconv converter '%s'\n", ic->conv));
                ip = in->ip;
-               if (ip != (iconv_t) - 1) {
+               if (ip != (GIConv) -1) {
                        /* work around some broken iconv implementations
                         * that die if the length arguments are NULL
                         */
@@ -444,19 +444,19 @@ camel_iconv_open (const gchar *oto,
                        gchar *buggy_iconv_buf = NULL;
 
                        /* resets the converter */
-                       iconv (ip, &buggy_iconv_buf, &buggy_iconv_len, &buggy_iconv_buf, &buggy_iconv_len);
+                       g_iconv (ip, &buggy_iconv_buf, &buggy_iconv_len, &buggy_iconv_buf, &buggy_iconv_len);
                        in->busy = TRUE;
                        g_queue_remove (&ic->open, in);
                        g_queue_push_head (&ic->open, in);
                }
        } else {
                cd (printf ("creating new iconv converter '%s'\n", ic->conv));
-               ip = iconv_open (to, from);
+               ip = g_iconv_open (to, from);
                in = g_malloc (sizeof (*in));
                in->ip = ip;
                in->parent = ic;
                g_queue_push_head (&ic->open, in);
-               if (ip != (iconv_t) - 1) {
+               if (ip != (GIConv) -1) {
                        g_hash_table_insert (iconv_cache_open, ip, in);
                        in->busy = TRUE;
                } else {
@@ -473,21 +473,21 @@ camel_iconv_open (const gchar *oto,
 }
 
 gsize
-camel_iconv (iconv_t cd,
+camel_iconv (GIConv cd,
              const gchar **inbuf,
              gsize *inbytesleft,
              gchar **outbuf,
              gsize *outbytesleft)
 {
-       return iconv (cd, (gchar **) inbuf, inbytesleft, outbuf, outbytesleft);
+       return g_iconv (cd, (gchar **) inbuf, inbytesleft, outbuf, outbytesleft);
 }
 
 void
-camel_iconv_close (iconv_t ip)
+camel_iconv_close (GIConv ip)
 {
        struct _iconv_cache_node *in;
 
-       if (ip == (iconv_t) - 1)
+       if (ip == (GIConv) -1)
                return;
 
        G_LOCK (iconv);
@@ -499,7 +499,7 @@ camel_iconv_close (iconv_t ip)
                g_queue_push_tail (&in->parent->open, in);
        } else {
                g_warning ("trying to close iconv i dont know about: %p", ip);
-               iconv_close (ip);
+               g_iconv_close (ip);
        }
        G_UNLOCK (iconv);
 }
diff --git a/camel/camel-iconv.h b/camel/camel-iconv.h
index ce55bd2..d59d337 100644
--- a/camel/camel-iconv.h
+++ b/camel/camel-iconv.h
@@ -25,7 +25,6 @@
 #define CAMEL_ICONV_H
 
 #include <sys/types.h>
-#include <iconv.h>
 #include <glib.h>
 
 G_BEGIN_DECLS
@@ -36,14 +35,14 @@ const gchar *       camel_iconv_locale_language     (void);
 const gchar *  camel_iconv_charset_name        (const gchar *charset);
 const gchar *  camel_iconv_charset_language    (const gchar *charset);
 
-iconv_t                camel_iconv_open                (const gchar *to,
+GIConv         camel_iconv_open                (const gchar *to,
                                                 const gchar *from);
-gsize          camel_iconv                     (iconv_t cd,
+gsize          camel_iconv                     (GIConv cd,
                                                 const gchar **inbuf,
                                                 gsize *inleft,
                                                 gchar **outbuf,
                                                 gsize *outleft);
-void           camel_iconv_close               (iconv_t cd);
+void           camel_iconv_close               (GIConv cd);
 
 G_END_DECLS
 
diff --git a/camel/camel-mime-filter-tohtml.c b/camel/camel-mime-filter-tohtml.c
index 0979a0c..50c55ed 100644
--- a/camel/camel-mime-filter-tohtml.c
+++ b/camel/camel-mime-filter-tohtml.c
@@ -62,7 +62,7 @@ struct _CamelMimeFilterToHTMLPrivate {
 
 static struct {
        CamelMimeFilterToHTMLFlags mask;
-       urlpattern_t pattern;
+       CamelUrlPattern pattern;
 } patterns[] = {
        { CONVERT_WEB_URLS, { "file://",   "",        camel_url_file_start,     camel_url_file_end     } },
        { CONVERT_WEB_URLS, { "ftp://";,    "",        camel_url_web_start,      camel_url_web_end      } },
@@ -367,7 +367,7 @@ html_convert (CamelMimeFilter *mime_filter,
 #define CONVERT_URLS (CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES)
                if (priv->flags & CONVERT_URLS) {
                        gsize matchlen, len;
-                       urlmatch_t match;
+                       CamelUrlMatch match;
 
                        len = inptr - start;
 
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index 6736f7c..c53a11e 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -863,7 +863,7 @@ header_decode_lwsp (const gchar **in)
 }
 
 static gchar *
-camel_iconv_strndup (iconv_t cd,
+camel_iconv_strndup (GIConv cd,
                      const gchar *string,
                      gsize n)
 {
@@ -873,7 +873,7 @@ camel_iconv_strndup (iconv_t cd,
        gsize outlen;
        gint errnosav;
 
-       if (cd == (iconv_t) -1)
+       if (cd == (GIConv) -1)
                return g_strndup (string, n);
 
        outlen = n * 2 + 16;
@@ -887,7 +887,7 @@ camel_iconv_strndup (iconv_t cd,
                outbuf = out + converted;
                outleft = outlen - converted;
 
-               converted = iconv (cd, (gchar **) &inbuf, &inleft, &outbuf, &outleft);
+               converted = g_iconv (cd, (gchar **) &inbuf, &inleft, &outbuf, &outleft);
                if (converted == (gsize) -1) {
                        if (errno != E2BIG && errno != EINVAL)
                                goto fail;
@@ -915,7 +915,7 @@ camel_iconv_strndup (iconv_t cd,
         */
 
        /* flush the iconv conversion */
-       while (iconv (cd, NULL, NULL, &outbuf, &outleft) == (gsize) -1) {
+       while (g_iconv (cd, NULL, NULL, &outbuf, &outleft) == (gsize) -1) {
                if (errno != E2BIG)
                        break;
 
@@ -935,7 +935,7 @@ camel_iconv_strndup (iconv_t cd,
        memset (outbuf, 0, 4);
 
        /* reset the cd */
-       iconv (cd, NULL, NULL, NULL, NULL);
+       g_iconv (cd, NULL, NULL, NULL, NULL);
 
        return out;
 
@@ -948,7 +948,7 @@ camel_iconv_strndup (iconv_t cd,
        g_free (out);
 
        /* reset the cd */
-       iconv (cd, NULL, NULL, NULL, NULL);
+       g_iconv (cd, NULL, NULL, NULL, NULL);
 
        errno = errnosav;
 
@@ -967,7 +967,7 @@ decode_8bit (const gchar *text,
        const gchar *locale_charset, *best;
        gchar *out, *outbuf;
        const gchar *inbuf;
-       iconv_t cd;
+       GIConv cd;
        gint i = 1;
 
        if (default_charset && g_ascii_strcasecmp (default_charset, "UTF-8") != 0)
@@ -984,7 +984,7 @@ decode_8bit (const gchar *text,
        out = g_malloc (outlen + 1);
 
        for (i = 0; charsets[i]; i++) {
-               if ((cd = camel_iconv_open ("UTF-8", charsets[i])) == (iconv_t) -1)
+               if ((cd = camel_iconv_open ("UTF-8", charsets[i])) == (GIConv) -1)
                        continue;
 
                outleft = outlen;
@@ -994,7 +994,7 @@ decode_8bit (const gchar *text,
                n = 0;
 
                do {
-                       rc = iconv (cd, (gchar **) &inbuf, &inleft, &outbuf, &outleft);
+                       rc = g_iconv (cd, (gchar **) &inbuf, &inleft, &outbuf, &outleft);
                        if (rc == (gsize) -1) {
                                if (errno == EINVAL) {
                                        /* incomplete sequence at the end of the input buffer */
@@ -1016,7 +1016,7 @@ decode_8bit (const gchar *text,
                        }
                } while (inleft > 0);
 
-               while ((rc = iconv (cd, NULL, NULL, &outbuf, &outleft)) == (gsize) -1) {
+               while ((rc = g_iconv (cd, NULL, NULL, &outbuf, &outleft)) == (gsize) -1) {
                        if (errno != E2BIG)
                                break;
 
@@ -1044,7 +1044,7 @@ decode_8bit (const gchar *text,
         * try to find the one that fit the best and use that to convert what we can,
         * replacing any byte we can't convert with a '?' */
 
-       if ((cd = camel_iconv_open ("UTF-8", best)) == (iconv_t) -1) {
+       if ((cd = camel_iconv_open ("UTF-8", best)) == (GIConv) -1) {
                /* this shouldn't happen... but if we are here, then
                 * it did...  the only thing we can do at this point
                 * is replace the 8bit garbage and pray */
@@ -1071,7 +1071,7 @@ decode_8bit (const gchar *text,
        inbuf = text;
 
        do {
-               rc = iconv (cd, (gchar **) &inbuf, &inleft, &outbuf, &outleft);
+               rc = g_iconv (cd, (gchar **) &inbuf, &inleft, &outbuf, &outleft);
                if (rc == (gsize) -1) {
                        if (errno == EINVAL) {
                                /* incomplete sequence at the end of the input buffer */
@@ -1093,7 +1093,7 @@ decode_8bit (const gchar *text,
                }
        } while (inleft > 0);
 
-       while ((rc = iconv (cd, NULL, NULL, &outbuf, &outleft)) == (gsize) -1) {
+       while ((rc = g_iconv (cd, NULL, NULL, &outbuf, &outleft)) == (gsize) -1) {
                if (errno != E2BIG)
                        break;
 
@@ -1145,7 +1145,7 @@ rfc2047_decode_word (const gchar *in,
        gssize declen;
        gint state = 0;
        gsize len;
-       iconv_t cd;
+       GIConv cd;
        gchar *buf;
 
        /* skip over the charset */
@@ -1205,7 +1205,7 @@ rfc2047_decode_word (const gchar *in,
        if (charset[0])
                charset = camel_iconv_charset_name (charset);
 
-       if (!charset[0] || (cd = camel_iconv_open ("UTF-8", charset)) == (iconv_t) -1) {
+       if (!charset[0] || (cd = camel_iconv_open ("UTF-8", charset)) == (GIConv) -1) {
                w (g_warning (
                        "Cannot convert from %s to UTF-8, "
                        "header display may be corrupt: %s",
@@ -1260,10 +1260,10 @@ append_8bit (GString *out,
 {
        gchar *outbase, *outbuf;
        gsize outlen;
-       iconv_t ic;
+       GIConv ic;
 
        ic = camel_iconv_open ("UTF-8", charset);
-       if (ic == (iconv_t) -1)
+       if (ic == (GIConv) -1)
                return FALSE;
 
        outlen = inlen * 6 + 16;
@@ -1483,7 +1483,7 @@ rfc2047_encode_word (GString *outstring,
                      const gchar *type,
                      gushort safemask)
 {
-       iconv_t ic = (iconv_t) -1;
+       GIConv ic = (GIConv) -1;
        gchar *buffer, *out, *ascii;
        gsize inlen, outlen, enclen, bufflen;
        const gchar *inptr, *p;
@@ -1512,7 +1512,7 @@ rfc2047_encode_word (GString *outstring,
                out = buffer;
                outlen = bufflen;
 
-               if (ic == (iconv_t) -1) {
+               if (ic == (GIConv) -1) {
                        /* native encoding case, the easy one (?) */
                        /* we work out how much we can convert, and still be in length */
                        /* proclen will be the result of input characters that we can convert, to the nearest
@@ -1583,7 +1583,7 @@ rfc2047_encode_word (GString *outstring,
                }
        }
 
-       if (ic != (iconv_t) -1)
+       if (ic != (GIConv) -1)
                camel_iconv_close (ic);
 }
 
@@ -2239,12 +2239,12 @@ header_convert (const gchar *to,
                 const gchar *in,
                 gsize inlen)
 {
-       iconv_t ic;
+       GIConv ic;
        gsize outlen, ret;
        gchar *outbuf, *outbase, *result = NULL;
 
        ic = camel_iconv_open (to, from);
-       if (ic == (iconv_t) -1)
+       if (ic == (GIConv) -1)
                return NULL;
 
        outlen = inlen * 6 + 16;
@@ -3075,49 +3075,9 @@ camel_header_contentid_decode (const gchar *in)
        return buf;
 }
 
-void
-camel_header_references_list_append_asis (struct _camel_header_references **list,
-                                          gchar *ref)
-{
-       struct _camel_header_references *w = (struct _camel_header_references *) list, *n;
-       while (w->next)
-               w = w->next;
-       n = g_malloc (sizeof (*n));
-       n->id = ref;
-       n->next = NULL;
-       w->next = n;
-}
-
-gint
-camel_header_references_list_size (struct _camel_header_references **list)
-{
-       gint count = 0;
-       struct _camel_header_references *w = *list;
-       while (w) {
-               count++;
-               w = w->next;
-       }
-       return count;
-}
-
-void
-camel_header_references_list_clear (struct _camel_header_references **list)
-{
-       struct _camel_header_references *w = *list, *n;
-       while (w) {
-               n = w->next;
-               g_free (w->id);
-               g_free (w);
-               w = n;
-       }
-       *list = NULL;
-}
-
 static void
-header_references_decode_single (const gchar **in,
-                                 struct _camel_header_references **head)
+header_references_decode_single (const gchar **in, GSList **list)
 {
-       struct _camel_header_references *ref;
        const gchar *inptr = *in;
        gchar *id, *word;
 
@@ -3126,10 +3086,7 @@ header_references_decode_single (const gchar **in,
                if (*inptr == '<') {
                        id = header_msgid_decode_internal (&inptr);
                        if (id) {
-                               ref = g_malloc (sizeof (struct _camel_header_references));
-                               ref->next = *head;
-                               ref->id = id;
-                               *head = ref;
+                               *list = g_slist_prepend (*list, id);
                                break;
                        }
                } else {
@@ -3144,25 +3101,18 @@ header_references_decode_single (const gchar **in,
        *in = inptr;
 }
 
-/* TODO: why is this needed?  Can't the other interface also work? */
-struct _camel_header_references *
-camel_header_references_inreplyto_decode (const gchar *in)
-{
-       struct _camel_header_references *ref = NULL;
-
-       if (in == NULL || in[0] == '\0')
-               return NULL;
-
-       header_references_decode_single (&in, &ref);
-
-       return ref;
-}
-
-/* generate a list of references, from most recent up */
-struct _camel_header_references *
+/**
+ * camel_header_references_decode:
+ * @in:
+ *
+ * Generate a list of references, from most recent up.
+ *
+ * Returns: (element-type utf8) (transfer full):
+ **/
+GSList *
 camel_header_references_decode (const gchar *in)
 {
-       struct _camel_header_references *refs = NULL;
+       GSList *refs = NULL;
 
        if (in == NULL || in[0] == '\0')
                return NULL;
@@ -3173,21 +3123,6 @@ camel_header_references_decode (const gchar *in)
        return refs;
 }
 
-struct _camel_header_references *
-camel_header_references_dup (const struct _camel_header_references *list)
-{
-       struct _camel_header_references *new = NULL, *tmp;
-
-       while (list) {
-               tmp = g_new (struct _camel_header_references, 1);
-               tmp->next = new;
-               tmp->id = g_strdup (list->id);
-               new = tmp;
-               list = list->next;
-       }
-       return new;
-}
-
 CamelHeaderAddress *
 camel_header_mailbox_decode (const gchar *in,
                              const gchar *charset)
@@ -3237,44 +3172,31 @@ camel_header_address_decode (const gchar *in,
        return list;
 }
 
-struct _camel_header_newsgroup *
+/**
+ * camel_header_newsgroups_decode:
+ * @in:
+ *
+ * Returns: (element-type utf8) (transfer full):
+ **/
+GSList *
 camel_header_newsgroups_decode (const gchar *in)
 {
        const gchar *inptr = in;
        register gchar c;
-       struct _camel_header_newsgroup *head, *last, *ng;
+       GSList *list;
        const gchar *start;
 
-       head = NULL;
-       last = (struct _camel_header_newsgroup *) &head;
-
        do {
                header_decode_lwsp (&inptr);
                start = inptr;
                while ((c = *inptr++) && !camel_mime_is_lwsp (c) && c != ',')
                        ;
                if (start != inptr - 1) {
-                       ng = g_malloc (sizeof (*ng));
-                       ng->newsgroup = g_strndup (start, inptr - start - 1);
-                       ng->next = NULL;
-                       last->next = ng;
-                       last = ng;
+                       list = g_slist_prepend (list, g_strndup (start, inptr - start - 1));
                }
        } while (c);
 
-       return head;
-}
-
-void
-camel_header_newsgroups_free (struct _camel_header_newsgroup *ng)
-{
-       while (ng) {
-               struct _camel_header_newsgroup *nng = ng->next;
-
-               g_free (ng->newsgroup);
-               g_free (ng);
-               ng = nng;
-       }
+       return list;
 }
 
 /* this must be kept in sync with the header */
diff --git a/camel/camel-mime-utils.h b/camel/camel-mime-utils.h
index a07796a..f45769c 100644
--- a/camel/camel-mime-utils.h
+++ b/camel/camel-mime-utils.h
@@ -42,17 +42,11 @@
 
 G_BEGIN_DECLS
 
-/* a list of references for this message */
-struct _camel_header_references {
-       struct _camel_header_references *next;
-       gchar *id;
-};
-
-struct _camel_header_param {
+typedef struct _camel_header_param {
        struct _camel_header_param *next;
        gchar *name;
        gchar *value;
-};
+} CamelHeaderParam;
 
 /* describes a content-type */
 typedef struct {
@@ -94,12 +88,6 @@ typedef struct _camel_header_address {
        guint refcount;
 } CamelHeaderAddress;
 
-struct _camel_header_newsgroup {
-       struct _camel_header_newsgroup *next;
-
-       gchar *newsgroup;
-};
-
 /* Time utilities */
 time_t         camel_mktime_utc                (struct tm *tm);
 void           camel_localtime_with_offset     (time_t tt,
@@ -208,19 +196,13 @@ gchar *camel_header_contentid_decode (const gchar *in);
 gchar *camel_header_msgid_generate (const gchar *domain);
 
 /* decode a References or In-Reply-To header */
-struct _camel_header_references *camel_header_references_inreplyto_decode (const gchar *in);
-struct _camel_header_references *camel_header_references_decode (const gchar *in);
-void camel_header_references_list_clear (struct _camel_header_references **list);
-void camel_header_references_list_append_asis (struct _camel_header_references **list, gchar *ref);
-gint camel_header_references_list_size (struct _camel_header_references **list);
-struct _camel_header_references *camel_header_references_dup (const struct _camel_header_references *list);
+GSList *camel_header_references_decode (const gchar *in);
 
 /* decode content-location */
 gchar *camel_header_location_decode (const gchar *in);
 
 /* nntp stuff */
-struct _camel_header_newsgroup *camel_header_newsgroups_decode (const gchar *in);
-void camel_header_newsgroups_free (struct _camel_header_newsgroup *ng);
+GSList *camel_header_newsgroups_decode (const gchar *in);
 
 const gchar *camel_transfer_encoding_to_string (CamelTransferEncoding encoding);
 CamelTransferEncoding camel_transfer_encoding_from_string (const gchar *string);
diff --git a/camel/camel-nntp-address.c b/camel/camel-nntp-address.c
index 43ebe56..3e16a29 100644
--- a/camel/camel-nntp-address.c
+++ b/camel/camel-nntp-address.c
@@ -36,17 +36,15 @@ static gint
 nntp_address_decode (CamelAddress *address,
                      const gchar *raw)
 {
-       struct _camel_header_newsgroup *ha, *n;
+       GSList *ha, *n;
        gint count = address->addresses->len;
 
        ha = camel_header_newsgroups_decode (raw);
-       if (ha) {
-               for (n = ha; n; n = n->next)
-                       camel_nntp_address_add (
-                               CAMEL_NNTP_ADDRESS (address), n->newsgroup);
-               camel_header_newsgroups_free (ha);
+       for (n = ha; n != NULL; n = n->next) {
+               camel_nntp_address_add (CAMEL_NNTP_ADDRESS (address), n->data);
        }
 
+       g_slist_free_full (ha, g_free);
        return address->addresses->len - count;
 }
 
diff --git a/camel/camel-sasl-digest-md5.c b/camel/camel-sasl-digest-md5.c
index e27df12..b41d9da 100644
--- a/camel/camel-sasl-digest-md5.c
+++ b/camel/camel-sasl-digest-md5.c
@@ -662,7 +662,7 @@ digest_response (struct _DigestResponse *resp)
                const gchar *charset;
                gsize len, outlen;
                const gchar *inbuf;
-               iconv_t cd;
+               GIConv cd;
 
                charset = camel_iconv_locale_charset ();
                if (!charset)
@@ -675,7 +675,7 @@ digest_response (struct _DigestResponse *resp)
 
                outbuf = username = g_malloc0 (outlen + 1);
                inbuf = resp->username;
-               if (cd == (iconv_t) -1 || camel_iconv (cd, &inbuf, &len, &outbuf, &outlen) == (gsize) -1) {
+               if (cd == (GIConv) -1 || camel_iconv (cd, &inbuf, &len, &outbuf, &outlen) == (gsize) -1) {
                        /* We can't convert to UTF-8 - pretend we never got a charset param? */
                        g_free (resp->charset);
                        resp->charset = NULL;
@@ -685,7 +685,7 @@ digest_response (struct _DigestResponse *resp)
                        username = g_strdup (resp->username);
                }
 
-               if (cd != (iconv_t) -1)
+               if (cd != (GIConv) -1)
                        camel_iconv_close (cd);
 
                g_byte_array_append (buffer, (guint8 *) username, strlen (username));
diff --git a/camel/camel-store.c b/camel/camel-store.c
index fe42ad9..6ffee81 100644
--- a/camel/camel-store.c
+++ b/camel/camel-store.c
@@ -93,6 +93,11 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (
        G_IMPLEMENT_INTERFACE (
                G_TYPE_INITABLE, camel_store_initable_init))
 
+G_DEFINE_BOXED_TYPE (CamelFolderInfo,
+               camel_folder_info,
+               camel_folder_info_clone,
+               camel_folder_info_free)
+
 static void
 async_context_free (AsyncContext *async_context)
 {
diff --git a/camel/camel-store.h b/camel/camel-store.h
index ddc5f84..19d930e 100644
--- a/camel/camel-store.h
+++ b/camel/camel-store.h
@@ -236,6 +236,7 @@ void                camel_store_folder_renamed      (CamelStore *store,
                                                 const gchar *old_name,
                                                 CamelFolderInfo *folder_info);
 void           camel_store_folder_info_stale   (CamelStore *store);
+GType          camel_folder_info_get_type              (void);
 CamelFolderInfo *
                camel_folder_info_new           (void);
 void           camel_folder_info_free          (CamelFolderInfo *fi);
diff --git a/camel/camel-url-scanner.c b/camel/camel-url-scanner.c
index f209a17..773c6db 100644
--- a/camel/camel-url-scanner.c
+++ b/camel/camel-url-scanner.c
@@ -58,7 +58,7 @@ camel_url_scanner_free (CamelUrlScanner *scanner)
 
 void
 camel_url_scanner_add (CamelUrlScanner *scanner,
-                       urlpattern_t *pattern)
+                       CamelUrlPattern *pattern)
 {
        g_return_if_fail (scanner != NULL);
 
@@ -70,11 +70,11 @@ gboolean
 camel_url_scanner_scan (CamelUrlScanner *scanner,
                         const gchar *in,
                         gsize inlen,
-                        urlmatch_t *match)
+                        CamelUrlMatch *match)
 {
        const gchar *pos;
        const guchar *inptr, *inend;
-       urlpattern_t *pat;
+       CamelUrlPattern *pat;
        gint pattern;
 
        g_return_val_if_fail (scanner != NULL, FALSE);
@@ -199,7 +199,7 @@ gboolean
 camel_url_addrspec_start (const gchar *in,
                           const gchar *pos,
                           const gchar *inend,
-                          urlmatch_t *match)
+                          CamelUrlMatch *match)
 {
        register const gchar *inptr = pos;
 
@@ -236,7 +236,7 @@ gboolean
 camel_url_addrspec_end (const gchar *in,
                         const gchar *pos,
                         const gchar *inend,
-                        urlmatch_t *match)
+                        CamelUrlMatch *match)
 {
        const gchar *inptr = pos;
        gint parts = 0, digits;
@@ -300,7 +300,7 @@ gboolean
 camel_url_file_start (const gchar *in,
                       const gchar *pos,
                       const gchar *inend,
-                      urlmatch_t *match)
+                      CamelUrlMatch *match)
 {
        match->um_so = (pos - in);
 
@@ -311,7 +311,7 @@ gboolean
 camel_url_file_end (const gchar *in,
                     const gchar *pos,
                     const gchar *inend,
-                    urlmatch_t *match)
+                    CamelUrlMatch *match)
 {
        register const gchar *inptr = pos;
        gchar close_brace;
@@ -338,7 +338,7 @@ gboolean
 camel_url_web_start (const gchar *in,
                      const gchar *pos,
                      const gchar *inend,
-                     urlmatch_t *match)
+                     CamelUrlMatch *match)
 {
        if (pos > in && !strncmp (pos, "www", 3)) {
                /* make sure we aren't actually part of another word */
@@ -355,7 +355,7 @@ gboolean
 camel_url_web_end (const gchar *in,
                    const gchar *pos,
                    const gchar *inend,
-                   urlmatch_t *match)
+                   CamelUrlMatch *match)
 {
        register const gchar *inptr = pos;
        gboolean passwd = FALSE;
diff --git a/camel/camel-url-scanner.h b/camel/camel-url-scanner.h
index df21904..75fd82d 100644
--- a/camel/camel-url-scanner.h
+++ b/camel/camel-url-scanner.h
@@ -34,33 +34,33 @@ typedef struct {
        const gchar *prefix;
        goffset um_so;
        goffset um_eo;
-} urlmatch_t;
+} CamelUrlMatch;
 
-typedef gboolean (*CamelUrlScanFunc) (const gchar *in, const gchar *pos, const gchar *inend, urlmatch_t 
*match);
+typedef gboolean (*CamelUrlScanFunc) (const gchar *in, const gchar *pos, const gchar *inend, CamelUrlMatch 
*match);
 
 /* some default CamelUrlScanFunc's */
-gboolean camel_url_file_start (const gchar *in, const gchar *pos, const gchar *inend, urlmatch_t *match);
-gboolean camel_url_file_end (const gchar *in, const gchar *pos, const gchar *inend, urlmatch_t *match);
-gboolean camel_url_web_start (const gchar *in, const gchar *pos, const gchar *inend, urlmatch_t *match);
-gboolean camel_url_web_end (const gchar *in, const gchar *pos, const gchar *inend, urlmatch_t *match);
-gboolean camel_url_addrspec_start (const gchar *in, const gchar *pos, const gchar *inend, urlmatch_t *match);
-gboolean camel_url_addrspec_end (const gchar *in, const gchar *pos, const gchar *inend, urlmatch_t *match);
+gboolean camel_url_file_start (const gchar *in, const gchar *pos, const gchar *inend, CamelUrlMatch *match);
+gboolean camel_url_file_end (const gchar *in, const gchar *pos, const gchar *inend, CamelUrlMatch *match);
+gboolean camel_url_web_start (const gchar *in, const gchar *pos, const gchar *inend, CamelUrlMatch *match);
+gboolean camel_url_web_end (const gchar *in, const gchar *pos, const gchar *inend, CamelUrlMatch *match);
+gboolean camel_url_addrspec_start (const gchar *in, const gchar *pos, const gchar *inend, CamelUrlMatch 
*match);
+gboolean camel_url_addrspec_end (const gchar *in, const gchar *pos, const gchar *inend, CamelUrlMatch 
*match);
 
 typedef struct {
        const gchar *pattern;
        const gchar *prefix;
        CamelUrlScanFunc start;
        CamelUrlScanFunc end;
-} urlpattern_t;
+} CamelUrlPattern;
 
 typedef struct _CamelUrlScanner CamelUrlScanner;
 
 CamelUrlScanner *camel_url_scanner_new (void);
 void camel_url_scanner_free (CamelUrlScanner *scanner);
 
-void camel_url_scanner_add (CamelUrlScanner *scanner, urlpattern_t *pattern);
+void camel_url_scanner_add (CamelUrlScanner *scanner, CamelUrlPattern *pattern);
 
-gboolean camel_url_scanner_scan (CamelUrlScanner *scanner, const gchar *in, gsize inlen, urlmatch_t *match);
+gboolean camel_url_scanner_scan (CamelUrlScanner *scanner, const gchar *in, gsize inlen, CamelUrlMatch 
*match);
 
 G_END_DECLS
 
diff --git a/camel/tests/message/test2.c b/camel/tests/message/test2.c
index 54bea76..ada3c1d 100644
--- a/camel/tests/message/test2.c
+++ b/camel/tests/message/test2.c
@@ -27,12 +27,12 @@
 
 static gchar *convert (const gchar *in, const gchar *from, const gchar *to)
 {
-       iconv_t ic = iconv_open (to, from);
+       GIConv ic = g_iconv_open (to, from);
        gchar *out, *outp;
        const gchar *inp;
        gsize inlen, outlen;
 
-       if (ic == (iconv_t) - 1)
+       if (ic == (GIConv) -1)
                return g_strdup (in);
 
        inlen = strlen (in);
@@ -43,17 +43,17 @@ static gchar *convert (const gchar *in, const gchar *from, const gchar *to)
 
        if (iconv (ic, &inp, &inlen, &outp, &outlen) == -1) {
                test_free (out);
-               iconv_close (ic);
+               g_iconv_close (ic);
                return g_strdup (in);
        }
 
        if (iconv (ic, NULL, 0, &outp, &outlen) == -1) {
                test_free (out);
-               iconv_close (ic);
+               g_iconv_close (ic);
                return g_strdup (in);
        }
 
-       iconv_close (ic);
+       g_iconv_close (ic);
 
        *outp = 0;
 
@@ -61,9 +61,9 @@ static gchar *convert (const gchar *in, const gchar *from, const gchar *to)
        /* lets see if we can convert back again? */
        {
                gchar *nout, *noutp;
-               iconv_t ic = iconv_open (from, to);
+               GIConv ic = iconv_open (from, to);
 
-               if (ic == (iconv_t) - 1)
+               if (ic == (GIConv) -1)
                        goto fail;
 
                inp = out;
diff --git a/camel/tests/misc/test1.c b/camel/tests/misc/test1.c
index 40c1890..4b10f69 100644
--- a/camel/tests/misc/test1.c
+++ b/camel/tests/misc/test1.c
@@ -49,18 +49,17 @@ main (gint argc,
        camel_test_start ("references decoding");
 
        for (i = 0; i < G_N_ELEMENTS (test1); i++) {
-               struct _camel_header_references *head, *node;
+               GSList *list;
 
                camel_test_push ("references decoding[%d] '%s'", i, test1[i].header);
-               head = camel_header_references_decode (test1[i].header);
-               node = head;
+               list = camel_header_references_decode (test1[i].header);
                for (j = 0; test1[i].values[j]; j++) {
-                       check_msg (node != NULL, "didn't find all references");
-                       check (strcmp (test1[i].values[j], node->id) == 0);
-                       node = node->next;
+                       check_msg (list != NULL, "didn't find all references");
+                       check (strcmp (test1[i].values[j], list->data) == 0);
+                       list = g_slist_next (list);
                }
-               check_msg (node == NULL, "found more references than should have");
-               camel_header_references_list_clear (&head);
+               check_msg (list == NULL, "found more references than should have");
+               g_slist_free_full (list, g_free);
                camel_test_pull ();
        }
 
diff --git a/configure.ac b/configure.ac
index 9766405..9e6afcc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -136,7 +136,7 @@ LIBEBOOK_CONTACTS_CURRENT=2
 LIBEBOOK_CONTACTS_REVISION=0
 LIBEBOOK_CONTACTS_AGE=0
 
-LIBCAMEL_CURRENT=56
+LIBCAMEL_CURRENT=57
 LIBCAMEL_REVISION=0
 LIBCAMEL_AGE=0
 
@@ -786,7 +786,8 @@ if test "x$have_iconv" = "xno"; then
 fi
 AC_SUBST(ICONV_LIBS)
 
-CFLAGS="$CFLAGS -I$srcdir"
+CFLAGS="$CFLAGS -I$srcdir $GNOME_PLATFORM_CFLAGS"
+LIBS="$LIBS $ICONV_LIBS $GNOME_PLATFORM_LIBS"
 
 AC_MSG_CHECKING([preferred charset name formats for system iconv])
 AC_RUN_IFELSE([AC_LANG_SOURCE([[
diff --git a/docs/reference/camel/camel-sections.txt b/docs/reference/camel/camel-sections.txt
index e663a3a..bd04033 100644
--- a/docs/reference/camel/camel-sections.txt
+++ b/docs/reference/camel/camel-sections.txt
@@ -2852,15 +2852,9 @@ camel_header_format_date
 camel_header_msgid_decode
 camel_header_contentid_decode
 camel_header_msgid_generate
-camel_header_references_inreplyto_decode
 camel_header_references_decode
-camel_header_references_list_clear
-camel_header_references_list_append_asis
-camel_header_references_list_size
-camel_header_references_dup
 camel_header_location_decode
 camel_header_newsgroups_decode
-camel_header_newsgroups_free
 camel_transfer_encoding_to_string
 camel_transfer_encoding_from_string
 camel_header_mime_decode
diff --git a/iconv-detect.c b/iconv-detect.c
index d541e43..c9c69bc 100644
--- a/iconv-detect.c
+++ b/iconv-detect.c
@@ -17,6 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
+#include <glib.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <iconv.h>
@@ -91,7 +92,7 @@ int main (int argc, char **argv)
 {
        unsigned int iso8859, iso2022, iso10646;
        CharInfo *info;
-       iconv_t cd;
+       GIConv cd;
        FILE *fp;
        int i;
 
@@ -105,8 +106,8 @@ int main (int argc, char **argv)
        info = iso8859_tests;
        /*printf ("#define DEFAULT_ISO_FORMAT(iso,codepage)\t");*/
        for (i = 0; i < num_iso8859_tests; i++) {
-               cd = iconv_open (info[i].charset, "UTF-8");
-               if (cd != (iconv_t) -1) {
+               cd = g_iconv_open (info[i].charset, "UTF-8");
+               if (cd != (GIConv) -1) {
                        iconv_close (cd);
                        /*printf ("(\"%s\", (iso), (codepage))\n", info[i].format);*/
                        fprintf (stderr, "System prefers %s\n", info[i].charset);
@@ -130,8 +131,8 @@ int main (int argc, char **argv)
        /*printf ("#define ISO_2022_FORMAT(iso,codepage)\t");*/
        for (i = 0; i < num_iso2022_tests; i++) {
                cd = iconv_open (info[i].charset, "UTF-8");
-               if (cd != (iconv_t) -1) {
-                       iconv_close (cd);
+               if (cd != (GIConv) -1) {
+                       g_iconv_close (cd);
                        /*printf ("(\"%s\", (iso), (codepage))\n", info[i].format);*/
                        fprintf (stderr, "System prefers %s\n", info[i].charset);
                        iso2022 = info[i].id;
@@ -154,8 +155,8 @@ int main (int argc, char **argv)
        /*printf ("#define ISO_10646_FORMAT(iso,codepage)\t");*/
        for (i = 0; i < num_iso10646_tests; i++) {
                cd = iconv_open (info[i].charset, "UTF-8");
-               if (cd != (iconv_t) -1) {
-                       iconv_close (cd);
+               if (cd != (GIConv) -1) {
+                       g_iconv_close (cd);
                        /*if (info[i].id < ISO_DASH_D_LOWER)
                                printf ("(\"%s\", (iso), (codepage))\n", info[i].format);
                        else


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