[evolution-data-server] CamelMultipartSigned cleanups.



commit 50eeffb5c026d0e88fd31a6fddbf34289adf1072
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed Oct 2 13:00:38 2013 -0400

    CamelMultipartSigned cleanups.
    
    Move the public struct members into the private section.
    
    New functions:
    
      camel_multipart_signed_set_content_stream()
      camel_multipart_signed_set_signature()

 camel/camel-gpg-context.c               |    8 +-
 camel/camel-multipart-signed.c          |  285 ++++++++++++++++---------------
 camel/camel-multipart-signed.h          |   47 ++---
 camel/camel-smime-context.c             |    6 +-
 docs/reference/camel/camel-sections.txt |    4 +
 5 files changed, 177 insertions(+), 173 deletions(-)
---
diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c
index fbb73b9..1b3c91c 100644
--- a/camel/camel-gpg-context.c
+++ b/camel/camel-gpg-context.c
@@ -1731,11 +1731,15 @@ gpg_sign_sync (CamelCipherContext *context,
        camel_content_type_unref (ct);
        camel_multipart_set_boundary ((CamelMultipart *) mps, NULL);
 
-       mps->signature = sigpart;
-       mps->contentraw = g_object_ref (istream);
+       camel_multipart_signed_set_signature (mps, sigpart);
+       camel_multipart_signed_set_content_stream (mps, istream);
+
+       g_object_unref (sigpart);
+
        g_seekable_seek (G_SEEKABLE (istream), 0, G_SEEK_SET, NULL, NULL);
 
        camel_medium_set_content ((CamelMedium *) opart, (CamelDataWrapper *) mps);
+
 fail:
        g_object_unref (ostream);
 
diff --git a/camel/camel-multipart-signed.c b/camel/camel-multipart-signed.c
index ffa7f34..fe7d186 100644
--- a/camel/camel-multipart-signed.c
+++ b/camel/camel-multipart-signed.c
@@ -41,9 +41,33 @@
 #include "camel-stream-filter.h"
 #include "camel-stream-mem.h"
 
-#define d(x) /* (printf("%s(%d): ", __FILE__, __LINE__),(x)) */
-
-G_DEFINE_TYPE (CamelMultipartSigned, camel_multipart_signed, CAMEL_TYPE_MULTIPART)
+#define CAMEL_MULTIPART_SIGNED_GET_PRIVATE(obj) \
+       (G_TYPE_INSTANCE_GET_PRIVATE \
+       ((obj), CAMEL_TYPE_MULTIPART_SIGNED, CamelMultipartSignedPrivate))
+
+struct _CamelMultipartSignedPrivate {
+       /* These are the client visible parts,
+        * decoded forms of our data wrapper content. */
+       CamelMimePart *content;
+       CamelMimePart *signature;
+
+       /* The raw content which must go over the wire, if we have
+        * generated it.
+        *
+        * XXX Perhaps this should just set data_wrapper->stream and
+        *     update start1/end1 accordingly, as it is done for other
+        *     parts, or visa versa? */
+       CamelStream *contentraw;
+
+       /* Offset pointers of start of boundary in content object. */
+       goffset start1, end1;
+       goffset start2, end2;
+};
+
+G_DEFINE_TYPE (
+       CamelMultipartSigned,
+       camel_multipart_signed,
+       CAMEL_TYPE_MULTIPART)
 
 static CamelStream *
 multipart_signed_clip_stream (CamelMultipartSigned *mps,
@@ -149,21 +173,21 @@ multipart_signed_parse_content (CamelMultipartSigned *mps)
        camel_mime_parser_init_with_stream (cmp, stream, NULL);
        camel_mime_parser_push_state (cmp, CAMEL_MIME_PARSER_STATE_MULTIPART, boundary);
 
-       mps->start1 = -1;
-       mps->end1 = -1;
-       mps->start2 = -1;
-       mps->end2 = -1;
+       mps->priv->start1 = -1;
+       mps->priv->end1 = -1;
+       mps->priv->start2 = -1;
+       mps->priv->end2 = -1;
 
        while ((state = camel_mime_parser_step (cmp, &buf, &len)) != CAMEL_MIME_PARSER_STATE_MULTIPART_END) {
-               if (mps->start1 == -1) {
-                       mps->start1 = camel_mime_parser_tell_start_headers (cmp);
-               } else if (mps->start2 == -1) {
-                       mps->start2 = camel_mime_parser_tell_start_headers (cmp);
-                       mps->end1 = camel_mime_parser_tell_start_boundary (cmp);
-                       if (mps->end1 > mps->start1 && byte_array->data[mps->end1 - 1] == '\n')
-                               mps->end1--;
-                       if (mps->end1 > mps->start1 && byte_array->data[mps->end1 - 1] == '\r')
-                               mps->end1--;
+               if (mps->priv->start1 == -1) {
+                       mps->priv->start1 = camel_mime_parser_tell_start_headers (cmp);
+               } else if (mps->priv->start2 == -1) {
+                       mps->priv->start2 = camel_mime_parser_tell_start_headers (cmp);
+                       mps->priv->end1 = camel_mime_parser_tell_start_boundary (cmp);
+                       if (mps->priv->end1 > mps->priv->start1 && byte_array->data[mps->priv->end1 - 1] == 
'\n')
+                               mps->priv->end1--;
+                       if (mps->priv->end1 > mps->priv->start1 && byte_array->data[mps->priv->end1 - 1] == 
'\r')
+                               mps->priv->end1--;
                } else {
                        g_warning ("multipart/signed has more than 2 parts, remaining parts ignored");
                        state = CAMEL_MIME_PARSER_STATE_MULTIPART_END;
@@ -175,7 +199,7 @@ multipart_signed_parse_content (CamelMultipartSigned *mps)
        }
 
        if (state == CAMEL_MIME_PARSER_STATE_MULTIPART_END) {
-               mps->end2 = camel_mime_parser_tell_start_boundary (cmp);
+               mps->priv->end2 = camel_mime_parser_tell_start_boundary (cmp);
 
                camel_multipart_set_preface (mp, camel_mime_parser_preface (cmp));
                camel_multipart_set_postface (mp, camel_mime_parser_postface (cmp));
@@ -184,9 +208,9 @@ multipart_signed_parse_content (CamelMultipartSigned *mps)
        g_object_unref (cmp);
        g_object_unref (stream);
 
-       if (mps->end2 == -1 || mps->start2 == -1) {
-               if (mps->end1 == -1)
-                       mps->start1 = -1;
+       if (mps->priv->end2 == -1 || mps->priv->start2 == -1) {
+               if (mps->priv->end1 == -1)
+                       mps->priv->start1 = -1;
 
                return -1;
        }
@@ -197,77 +221,26 @@ multipart_signed_parse_content (CamelMultipartSigned *mps)
 static void
 multipart_signed_dispose (GObject *object)
 {
-       CamelMultipartSigned *multipart;
-
-       multipart = CAMEL_MULTIPART_SIGNED (object);
-
-       if (multipart->signature != NULL) {
-               g_object_unref (multipart->signature);
-               multipart->signature = NULL;
-       }
+       CamelMultipartSignedPrivate *priv;
 
-       if (multipart->content != NULL) {
-               g_object_unref (multipart->content);
-               multipart->content = NULL;
-       }
+       priv = CAMEL_MULTIPART_SIGNED_GET_PRIVATE (object);
 
-       if (multipart->contentraw != NULL) {
-               g_object_unref (multipart->contentraw);
-               multipart->contentraw = NULL;
-       }
+       g_clear_object (&priv->content);
+       g_clear_object (&priv->signature);
+       g_clear_object (&priv->contentraw);
 
        /* Chain up to parent's dispose() method. */
        G_OBJECT_CLASS (camel_multipart_signed_parent_class)->dispose (object);
 }
 
-static void
-multipart_signed_finalize (GObject *object)
-{
-       CamelMultipartSigned *multipart;
-
-       multipart = CAMEL_MULTIPART_SIGNED (object);
-
-       g_free (multipart->protocol);
-       g_free (multipart->micalg);
-
-       /* Chain up to parent's finalize() method. */
-       G_OBJECT_CLASS (camel_multipart_signed_parent_class)->finalize (object);
-}
-
-static void
-multipart_signed_set_mime_type_field (CamelDataWrapper *data_wrapper,
-                                      CamelContentType *mime_type)
-{
-       CamelDataWrapperClass *data_wrapper_class;
-       CamelMultipartSigned *mps = (CamelMultipartSigned *) data_wrapper;
-
-       /* we snoop the mime type to get boundary and hash info */
-
-       /* Chain up to parent's set_mime_type_field() method. */
-       data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (camel_multipart_signed_parent_class);
-       data_wrapper_class->set_mime_type_field (data_wrapper, mime_type);
-
-       if (mime_type) {
-               const gchar *micalg, *protocol;
-
-               protocol = camel_content_type_param (mime_type, "protocol");
-               g_free (mps->protocol);
-               mps->protocol = g_strdup (protocol);
-
-               micalg = camel_content_type_param (mime_type, "micalg");
-               g_free (mps->micalg);
-               mps->micalg = g_strdup (micalg);
-       }
-}
-
 static gssize
 multipart_signed_write_to_stream_sync (CamelDataWrapper *data_wrapper,
                                        CamelStream *stream,
                                        GCancellable *cancellable,
                                        GError **error)
 {
-       CamelMultipartSigned *mps = (CamelMultipartSigned *) data_wrapper;
-       CamelMultipart *mp = (CamelMultipart *) mps;
+       CamelMultipartSignedPrivate *priv;
+       CamelMultipart *mp = (CamelMultipart *) data_wrapper;
        GByteArray *byte_array;
        const gchar *boundary;
        const gchar *preface;
@@ -276,6 +249,8 @@ multipart_signed_write_to_stream_sync (CamelDataWrapper *data_wrapper,
        gssize count;
        gchar *content;
 
+       priv = CAMEL_MULTIPART_SIGNED_GET_PRIVATE (data_wrapper);
+
        byte_array = camel_data_wrapper_get_byte_array (data_wrapper);
 
        /* we have 3 basic cases:
@@ -293,7 +268,7 @@ multipart_signed_write_to_stream_sync (CamelDataWrapper *data_wrapper,
        }
 
        /* 3 */
-       if (mps->contentraw == NULL) {
+       if (priv->contentraw == NULL) {
                g_set_error (
                        error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
                        _("No content available"));
@@ -301,7 +276,7 @@ multipart_signed_write_to_stream_sync (CamelDataWrapper *data_wrapper,
        }
 
        /* 3 */
-       if (mps->signature == NULL) {
+       if (priv->signature == NULL) {
                g_set_error (
                        error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
                        _("No signature available"));
@@ -334,9 +309,9 @@ multipart_signed_write_to_stream_sync (CamelDataWrapper *data_wrapper,
        /* XXX Both CamelGpgContext and CamelSMIMEContext set this
         *     to a memory stream, so assume it's always seekable. */
        g_seekable_seek (
-               G_SEEKABLE (mps->contentraw), 0, G_SEEK_SET, NULL, NULL);
+               G_SEEKABLE (priv->contentraw), 0, G_SEEK_SET, NULL, NULL);
        count = camel_stream_write_to_stream (
-               mps->contentraw, stream, cancellable, error);
+               priv->contentraw, stream, cancellable, error);
        if (count == -1)
                return -1;
        total += count;
@@ -352,7 +327,7 @@ multipart_signed_write_to_stream_sync (CamelDataWrapper *data_wrapper,
 
        /* signature */
        count = camel_data_wrapper_write_to_stream_sync (
-               CAMEL_DATA_WRAPPER (mps->signature),
+               CAMEL_DATA_WRAPPER (priv->signature),
                stream, cancellable, error);
        if (count == -1)
                return -1;
@@ -385,11 +360,11 @@ multipart_signed_construct_from_stream_sync (CamelDataWrapper *data_wrapper,
                                              GCancellable *cancellable,
                                              GError **error)
 {
+       CamelMultipartSignedPrivate *priv;
        CamelDataWrapperClass *parent_class;
-       CamelMultipartSigned *mps;
        gboolean success;
 
-       mps = CAMEL_MULTIPART_SIGNED (data_wrapper);
+       priv = CAMEL_MULTIPART_SIGNED_GET_PRIVATE (data_wrapper);
 
        /* Chain up to parent's construct_from_stream_sync() method. */
        parent_class = CAMEL_DATA_WRAPPER_CLASS (
@@ -398,19 +373,10 @@ multipart_signed_construct_from_stream_sync (CamelDataWrapper *data_wrapper,
                data_wrapper, stream, cancellable, error);
 
        if (success) {
-               mps->start1 = -1;
-               if (mps->content != NULL) {
-                       g_object_unref (mps->content);
-                       mps->content = NULL;
-               }
-               if (mps->contentraw != NULL) {
-                       g_object_unref (mps->contentraw);
-                       mps->contentraw = NULL;
-               }
-               if (mps->signature != NULL) {
-                       g_object_unref (mps->signature);
-                       mps->signature = NULL;
-               }
+               priv->start1 = -1;
+               g_clear_object (&priv->content);
+               g_clear_object (&priv->signature);
+               g_clear_object (&priv->contentraw);
        }
 
        return success;
@@ -427,48 +393,51 @@ static CamelMimePart *
 multipart_signed_get_part (CamelMultipart *multipart,
                            guint index)
 {
-       CamelMultipartSigned *mps = (CamelMultipartSigned *) multipart;
+       CamelMultipartSigned *mps;
        CamelDataWrapper *data_wrapper;
        CamelStream *stream;
        GByteArray *byte_array;
 
+       mps = CAMEL_MULTIPART_SIGNED (multipart);
+
        data_wrapper = CAMEL_DATA_WRAPPER (multipart);
        byte_array = camel_data_wrapper_get_byte_array (data_wrapper);
 
        switch (index) {
        case CAMEL_MULTIPART_SIGNED_CONTENT:
-               if (mps->content)
-                       return mps->content;
-               if (mps->contentraw) {
+               if (mps->priv->content != NULL)
+                       return mps->priv->content;
+               if (mps->priv->contentraw != NULL) {
                        g_return_val_if_fail (
-                               G_IS_SEEKABLE (mps->contentraw), NULL);
-                       stream = g_object_ref (mps->contentraw);
-               } else if (mps->start1 == -1
+                               G_IS_SEEKABLE (mps->priv->contentraw), NULL);
+                       stream = g_object_ref (mps->priv->contentraw);
+               } else if (mps->priv->start1 == -1
                           && multipart_signed_parse_content (mps) == -1
                           && byte_array->len == 0) {
                        g_warning ("Trying to get content on an invalid multipart/signed");
                        return NULL;
                } else if (byte_array->len == 0) {
                        return NULL;
-               } else if (mps->start1 == -1) {
+               } else if (mps->priv->start1 == -1) {
                        stream = camel_stream_mem_new ();
                        camel_stream_mem_set_byte_array (
                                CAMEL_STREAM_MEM (stream), byte_array);
                } else {
                        stream = multipart_signed_clip_stream (
-                               mps, mps->start1, mps->end1);
+                               mps, mps->priv->start1, mps->priv->end1);
                }
                g_seekable_seek (
                        G_SEEKABLE (stream), 0, G_SEEK_SET, NULL, NULL);
-               mps->content = camel_mime_part_new ();
+               mps->priv->content = camel_mime_part_new ();
                camel_data_wrapper_construct_from_stream_sync (
-                       CAMEL_DATA_WRAPPER (mps->content), stream, NULL, NULL);
+                       CAMEL_DATA_WRAPPER (mps->priv->content),
+                       stream, NULL, NULL);
                g_object_unref (stream);
-               return mps->content;
+               return mps->priv->content;
        case CAMEL_MULTIPART_SIGNED_SIGNATURE:
-               if (mps->signature)
-                       return mps->signature;
-               if (mps->start1 == -1
+               if (mps->priv->signature != NULL)
+                       return mps->priv->signature;
+               if (mps->priv->start1 == -1
                    && multipart_signed_parse_content (mps) == -1) {
                        g_warning ("Trying to get signature on invalid multipart/signed");
                        return NULL;
@@ -476,15 +445,15 @@ multipart_signed_get_part (CamelMultipart *multipart,
                        return NULL;
                }
                stream = multipart_signed_clip_stream (
-                       mps, mps->start2, mps->end2);
+                       mps, mps->priv->start2, mps->priv->end2);
                g_seekable_seek (
                        G_SEEKABLE (stream), 0, G_SEEK_SET, NULL, NULL);
-               mps->signature = camel_mime_part_new ();
+               mps->priv->signature = camel_mime_part_new ();
                camel_data_wrapper_construct_from_stream_sync (
-                       CAMEL_DATA_WRAPPER (mps->signature),
+                       CAMEL_DATA_WRAPPER (mps->priv->signature),
                        stream, NULL, NULL);
                g_object_unref (stream);
-               return mps->signature;
+               return mps->priv->signature;
        default:
                g_warning ("trying to get object out of bounds for multipart");
        }
@@ -504,10 +473,10 @@ multipart_signed_get_number (CamelMultipart *multipart)
 
        /* check what we have, so we return something reasonable */
 
-       if ((mps->content || mps->contentraw) && mps->signature)
+       if ((mps->priv->content || mps->priv->contentraw) && mps->priv->signature)
                return 2;
 
-       if (mps->start1 == -1 && multipart_signed_parse_content (mps) == -1) {
+       if (mps->priv->start1 == -1 && multipart_signed_parse_content (mps) == -1) {
                if (byte_array->len == 0)
                        return 0;
                else
@@ -521,14 +490,16 @@ static gint
 multipart_signed_construct_from_parser (CamelMultipart *multipart,
                                         CamelMimeParser *mp)
 {
+       CamelMultipartSignedPrivate *priv;
        gint err;
        CamelContentType *content_type;
-       CamelMultipartSigned *mps = (CamelMultipartSigned *) multipart;
        CamelDataWrapper *data_wrapper;
        GByteArray *byte_array;
        gchar *buf;
        gsize len;
 
+       priv = CAMEL_MULTIPART_SIGNED_GET_PRIVATE (multipart);
+
        /* we *must not* be in multipart state, otherwise the mime parser will
         * parse the headers which is a no no @#$ # stupid multipart/signed spec */
        g_assert (camel_mime_parser_state (mp) == CAMEL_MIME_PARSER_STATE_HEADER);
@@ -546,19 +517,10 @@ multipart_signed_construct_from_parser (CamelMultipart *multipart,
        while (camel_mime_parser_step (mp, &buf, &len) != CAMEL_MIME_PARSER_STATE_BODY_END)
                g_byte_array_append (byte_array, (guint8 *) buf, len);
 
-       mps->start1 = -1;
-       if (mps->content) {
-               g_object_unref (mps->content);
-               mps->content = NULL;
-       }
-       if (mps->contentraw) {
-               g_object_unref (mps->contentraw);
-               mps->contentraw = NULL;
-       }
-       if (mps->signature) {
-               g_object_unref (mps->signature);
-               mps->signature = NULL;
-       }
+       priv->start1 = -1;
+       g_clear_object (&priv->content);
+       g_clear_object (&priv->signature);
+       g_clear_object (&priv->contentraw);
 
        err = camel_mime_parser_errno (mp);
        if (err != 0) {
@@ -575,12 +537,12 @@ camel_multipart_signed_class_init (CamelMultipartSignedClass *class)
        CamelDataWrapperClass *data_wrapper_class;
        CamelMultipartClass *multipart_class;
 
+       g_type_class_add_private (class, sizeof (CamelMultipartSignedPrivate));
+
        object_class = G_OBJECT_CLASS (class);
        object_class->dispose = multipart_signed_dispose;
-       object_class->finalize = multipart_signed_finalize;
 
        data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (class);
-       data_wrapper_class->set_mime_type_field = multipart_signed_set_mime_type_field;
        data_wrapper_class->write_to_stream_sync = multipart_signed_write_to_stream_sync;
        data_wrapper_class->decode_to_stream_sync = multipart_signed_write_to_stream_sync;
        data_wrapper_class->construct_from_stream_sync = multipart_signed_construct_from_stream_sync;
@@ -595,10 +557,12 @@ camel_multipart_signed_class_init (CamelMultipartSignedClass *class)
 static void
 camel_multipart_signed_init (CamelMultipartSigned *multipart)
 {
+       multipart->priv = CAMEL_MULTIPART_SIGNED_GET_PRIVATE (multipart);
+
        camel_data_wrapper_set_mime_type (
                CAMEL_DATA_WRAPPER (multipart), "multipart/signed");
 
-       multipart->start1 = -1;
+       multipart->priv->start1 = -1;
 }
 
 /**
@@ -653,14 +617,14 @@ camel_multipart_signed_get_content_stream (CamelMultipartSigned *mps,
 
        /* we need to be able to verify stuff we just signed as well as stuff we loaded from a stream/parser 
*/
 
-       if (mps->contentraw) {
-               constream = g_object_ref (mps->contentraw);
+       if (mps->priv->contentraw) {
+               constream = g_object_ref (mps->priv->contentraw);
        } else {
                CamelStream *base_stream;
                CamelStream *filter_stream;
                CamelMimeFilter *canon_filter;
 
-               if (mps->start1 == -1 && multipart_signed_parse_content (mps) == -1) {
+               if (mps->priv->start1 == -1 && multipart_signed_parse_content (mps) == -1) {
                        g_set_error (
                                error, CAMEL_ERROR,
                                CAMEL_ERROR_GENERIC,
@@ -671,7 +635,7 @@ camel_multipart_signed_get_content_stream (CamelMultipartSigned *mps,
                /* first, prepare our parts */
 
                base_stream = multipart_signed_clip_stream (
-                       mps, mps->start1, mps->end1);
+                       mps, mps->priv->start1, mps->priv->end1);
 
                filter_stream = camel_stream_filter_new (base_stream);
 
@@ -697,3 +661,44 @@ camel_multipart_signed_get_content_stream (CamelMultipartSigned *mps,
 
        return constream;
 }
+
+/**
+ * camel_multipart_signed_set_content_stream:
+ * @mps: a #CamelMultipartSigned
+ * @content_stream: a #CamelStream
+ *
+ * Explicits sets the raw signed content stream of the multipart/signed
+ * MIME part.
+ *
+ * Since: 3.12
+ **/
+void
+camel_multipart_signed_set_content_stream (CamelMultipartSigned *mps,
+                                           CamelStream *content_stream)
+{
+       g_return_if_fail (CAMEL_IS_MULTIPART_SIGNED (mps));
+       g_return_if_fail (CAMEL_IS_STREAM (content_stream));
+
+       g_clear_object (&mps->priv->contentraw);
+       mps->priv->contentraw = g_object_ref (content_stream);
+}
+
+/**
+ * camel_multipart_signed_set_signature:
+ * @mps: a #CamelMultipartSigned
+ * @signature: a #CamelMimePart
+ *
+ * Explicitly sets the signature part of @mps.
+ *
+ * Since: 3.12
+ **/
+void
+camel_multipart_signed_set_signature (CamelMultipartSigned *mps,
+                                      CamelMimePart *signature)
+{
+       g_return_if_fail (CAMEL_IS_MULTIPART_SIGNED (mps));
+       g_return_if_fail (CAMEL_IS_MIME_PART (signature));
+
+       g_clear_object (&mps->priv->signature);
+       mps->priv->signature = g_object_ref (signature);
+}
diff --git a/camel/camel-multipart-signed.h b/camel/camel-multipart-signed.h
index b765ec4..34bcf07 100644
--- a/camel/camel-multipart-signed.h
+++ b/camel/camel-multipart-signed.h
@@ -61,41 +61,30 @@ enum {
 };
 
 typedef struct _CamelMultipartSigned CamelMultipartSigned;
+typedef struct _CamelMultipartSignedClass CamelMultipartSignedClass;
+typedef struct _CamelMultipartSignedPrivate CamelMultipartSignedPrivate;
 
-struct _CamelMultipartSigned
-{
+struct _CamelMultipartSigned {
        CamelMultipart parent;
-
-       /* these are the client visible parts, decoded forms of our data wrapper content */
-       CamelMimePart *content;
-       CamelMimePart *signature;
-
-       /* the raw content which must go over the wire, if we have generated it */
-       /* perhaps this should jsut set data_wrapper->stream and update start1/end1 accordingly, as it is done
-        * for other parts, or visa versa? */
-       CamelStream *contentraw;
-
-       /*int state;*/
-
-       /* just cache some info we use */
-       gchar *protocol;
-       gchar *micalg;
-
-       /* offset pointers of start of boundary in content object */
-       goffset start1, end1;
-       goffset start2, end2;
+       CamelMultipartSignedPrivate *priv;
 };
 
-typedef struct {
+struct _CamelMultipartSignedClass {
        CamelMultipartClass parent_class;
-} CamelMultipartSignedClass;
-
-GType camel_multipart_signed_get_type (void);
-
-/* public methods */
-CamelMultipartSigned *camel_multipart_signed_new           (void);
+};
 
-CamelStream *camel_multipart_signed_get_content_stream (CamelMultipartSigned *mps, GError **error);
+GType          camel_multipart_signed_get_type (void) G_GNUC_CONST;
+CamelMultipartSigned *
+               camel_multipart_signed_new      (void);
+CamelStream *  camel_multipart_signed_get_content_stream
+                                               (CamelMultipartSigned *mps,
+                                                GError **error);
+void           camel_multipart_signed_set_content_stream
+                                               (CamelMultipartSigned *mps,
+                                                CamelStream *content_stream);
+void           camel_multipart_signed_set_signature
+                                               (CamelMultipartSigned *mps,
+                                                CamelMimePart *signature);
 
 G_END_DECLS
 
diff --git a/camel/camel-smime-context.c b/camel/camel-smime-context.c
index 7701b5c..bd86013 100644
--- a/camel/camel-smime-context.c
+++ b/camel/camel-smime-context.c
@@ -902,8 +902,10 @@ smime_context_sign_sync (CamelCipherContext *context,
                camel_content_type_unref (ct);
                camel_multipart_set_boundary ((CamelMultipart *) mps, NULL);
 
-               mps->signature = sigpart;
-               mps->contentraw = g_object_ref (istream);
+               camel_multipart_signed_set_signature (mps, sigpart);
+               camel_multipart_signed_set_content_stream (mps, istream);
+
+               g_object_unref (sigpart);
 
                g_seekable_seek (
                        G_SEEKABLE (istream), 0,
diff --git a/docs/reference/camel/camel-sections.txt b/docs/reference/camel/camel-sections.txt
index 01401fc..e609caf 100644
--- a/docs/reference/camel/camel-sections.txt
+++ b/docs/reference/camel/camel-sections.txt
@@ -1776,6 +1776,8 @@ CamelMultipartEncryptedPrivate
 CamelMultipartSigned
 camel_multipart_signed_new
 camel_multipart_signed_get_content_stream
+camel_multipart_signed_set_content_stream
+camel_multipart_signed_set_signature
 <SUBSECTION Standard>
 CAMEL_MULTIPART_SIGNED
 CAMEL_IS_MULTIPART_SIGNED
@@ -1785,6 +1787,8 @@ CAMEL_IS_MULTIPART_SIGNED_CLASS
 CAMEL_MULTIPART_SIGNED_GET_CLASS
 CamelMultipartSignedClass
 camel_multipart_signed_get_type
+<SUBSECTION Private>
+CamelMultipartSignedPrivate
 </SECTION>
 
 <SECTION>


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