1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Authors: Jeffrey Stedfast <fejj@ximian.com>
5 * Copyright 2002 Ximian, Inc. (www.ximian.com)
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
32 #include <glib/gi18n-lib.h>
34 #include "camel-mime-filter-crlf.h"
35 #include "camel-mime-part.h"
36 #include "camel-mime-utils.h"
37 #include "camel-multipart-encrypted.h"
38 #include "camel-stream-filter.h"
39 #include "camel-stream-fs.h"
40 #include "camel-stream-mem.h"
42 static void camel_multipart_encrypted_class_init (CamelMultipartEncryptedClass *klass);
43 static void camel_multipart_encrypted_init (gpointer object, gpointer klass);
44 static void camel_multipart_encrypted_finalize (CamelObject *object);
46 static void set_mime_type_field (CamelDataWrapper *data_wrapper, CamelContentType *mime_type);
49 static CamelMultipartClass *parent_class = NULL;
53 camel_multipart_encrypted_get_type (void)
55 static CamelType type = CAMEL_INVALID_TYPE;
57 if (type == CAMEL_INVALID_TYPE) {
58 type = camel_type_register (camel_multipart_get_type (),
59 "CamelMultipartEncrypted",
60 sizeof (CamelMultipartEncrypted),
61 sizeof (CamelMultipartEncryptedClass),
62 (CamelObjectClassInitFunc) camel_multipart_encrypted_class_init,
64 (CamelObjectInitFunc) camel_multipart_encrypted_init,
65 (CamelObjectFinalizeFunc) camel_multipart_encrypted_finalize);
73 camel_multipart_encrypted_class_init (CamelMultipartEncryptedClass *klass)
75 CamelDataWrapperClass *camel_data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (klass);
77 parent_class = (CamelMultipartClass *) camel_multipart_get_type ();
79 /* virtual method overload */
80 camel_data_wrapper_class->set_mime_type_field = set_mime_type_field;
84 camel_multipart_encrypted_init (gpointer object, gpointer klass)
86 CamelMultipartEncrypted *multipart = (CamelMultipartEncrypted *) object;
88 camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (multipart), "multipart/encrypted");
90 multipart->decrypted = NULL;
94 camel_multipart_encrypted_finalize (CamelObject *object)
96 CamelMultipartEncrypted *mpe = (CamelMultipartEncrypted *) object;
98 g_free (mpe->protocol);
101 camel_object_unref (mpe->decrypted);
104 /* we snoop the mime type to get the protocol */
106 set_mime_type_field (CamelDataWrapper *data_wrapper, CamelContentType *mime_type)
108 CamelMultipartEncrypted *mpe = (CamelMultipartEncrypted *) data_wrapper;
111 const char *protocol;
113 protocol = camel_content_type_param (mime_type, "protocol");
114 g_free (mpe->protocol);
115 mpe->protocol = g_strdup (protocol);
118 ((CamelDataWrapperClass *) parent_class)->set_mime_type_field (data_wrapper, mime_type);
123 * camel_multipart_encrypted_new:
125 * Create a new #CamelMultipartEncrypted object.
127 * A MultipartEncrypted should be used to store and create parts of
128 * type "multipart/encrypted".
130 * Returns a new #CamelMultipartEncrypted object
132 CamelMultipartEncrypted *
133 camel_multipart_encrypted_new (void)
135 CamelMultipartEncrypted *multipart;
137 multipart = (CamelMultipartEncrypted *) camel_object_new (CAMEL_MULTIPART_ENCRYPTED_TYPE);