1 /*
2 * e-mail-part-audio.c
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18 #include "e-mail-part-audio.h"
19
20 #define E_MAIL_PART_AUDIO_GET_PRIVATE(obj) \
21 (G_TYPE_INSTANCE_GET_PRIVATE \
22 ((obj), E_TYPE_MAIL_PART_AUDIO, EMailPartAudioPrivate))
23
G_DEFINE_TYPE(EMailPartAudio,e_mail_part_audio,E_TYPE_MAIL_PART)24 G_DEFINE_TYPE (
25 EMailPartAudio,
26 e_mail_part_audio,
27 E_TYPE_MAIL_PART)
28
29 static void
30 mail_part_audio_constructed (GObject *object)
31 {
32 EMailPart *part;
33 CamelMimePart *mime_part;
34 CamelContentType *content_type;
35
36 part = E_MAIL_PART (object);
37
38 /* Chain up to parent's constructed() method. */
39 G_OBJECT_CLASS (e_mail_part_audio_parent_class)->constructed (object);
40
41 e_mail_part_set_is_attachment (part, TRUE);
42
43 mime_part = e_mail_part_ref_mime_part (part);
44
45 content_type = camel_mime_part_get_content_type (mime_part);
46
47 if (content_type != NULL) {
48 gchar *mime_type;
49
50 mime_type = camel_content_type_simple (content_type);
51 e_mail_part_set_mime_type (part, mime_type);
52 g_free (mime_type);
53 } else {
54 e_mail_part_set_mime_type (part, "audio/*");
55 }
56
57 g_object_unref (mime_part);
58 }
59
60 static void
e_mail_part_audio_class_init(EMailPartAudioClass * class)61 e_mail_part_audio_class_init (EMailPartAudioClass *class)
62 {
63 GObjectClass *object_class;
64
65 object_class = G_OBJECT_CLASS (class);
66 object_class->constructed = mail_part_audio_constructed;
67 }
68
69 static void
e_mail_part_audio_init(EMailPartAudio * part)70 e_mail_part_audio_init (EMailPartAudio *part)
71 {
72 }
73
74 EMailPart *
e_mail_part_audio_new(CamelMimePart * mime_part,const gchar * id)75 e_mail_part_audio_new (CamelMimePart *mime_part,
76 const gchar *id)
77 {
78 g_return_val_if_fail (id != NULL, NULL);
79
80 return g_object_new (
81 E_TYPE_MAIL_PART_AUDIO,
82 "id", id, "mime-part", mime_part, NULL);
83 }
84
85