aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-mime-body-part.c
blob: 988d530fcb893a105f3a3954927bbdb15f5c3344 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-mime-body-part.c : Abstract class for a mime body part */


/* 
 *
 * Author : 
 *  Bertrand Guiheneuf <bertrand@helixcode.com>
 *
 * Copyright 1999, 2000 Helix Code, Inc. (http://www.helixcode.com)
 *
 * This program is free software; you can redistribute it and/or 
 * modify it under the terms of the GNU General Public License as 
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */
#include <config.h>
#include "camel-mime-body-part.h"


static void _set_parent (CamelMimeBodyPart *mime_body_part, CamelMultipart *multipart);
static const CamelMultipart *_get_parent (CamelMimeBodyPart *mime_body_part);


static CamelMimePartClass *parent_class=NULL;

/* Returns the class for a CamelMimeBodyPart */
#define CMBP_CLASS(so) CAMEL_MIME_BODY_PART_CLASS (GTK_OBJECT(so)->klass)



static void
camel_mime_body_part_class_init (CamelMimeBodyPartClass *camel_mime_body_part_class)
{
    parent_class = gtk_type_class (camel_mime_part_get_type ());
        
    /* virtual method definition */
    camel_mime_body_part_class->set_parent = _set_parent;
    camel_mime_body_part_class->get_parent = _get_parent;
}

static void
camel_mime_body_part_init (gpointer   object,  gpointer   klass)
{
    camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (object), "mime/body-part");
}




GtkType
camel_mime_body_part_get_type (void)
{
    static GtkType camel_mime_body_part_type = 0;
    
    if (!camel_mime_body_part_type) {
        GtkTypeInfo camel_mime_body_part_info = 
        {
            "CamelMimeBodyPart",
            sizeof (CamelMimeBodyPart),
            sizeof (CamelMimeBodyPartClass),
            (GtkClassInitFunc) camel_mime_body_part_class_init,
            (GtkObjectInitFunc) camel_mime_body_part_init,
                /* reserved_1 */ NULL,
                /* reserved_2 */ NULL,
            (GtkClassInitFunc) NULL,
        };
        
        camel_mime_body_part_type = gtk_type_unique (camel_mime_part_get_type (), &camel_mime_body_part_info);
    }
    
    return camel_mime_body_part_type;
}

CamelMimeBodyPart *
camel_mime_body_part_new (void)
{
    CamelMimeBodyPart *mime_body_part;
    
    mime_body_part = (CamelMimeBodyPart *)gtk_type_new (CAMEL_MIME_BODY_PART_TYPE);
    return mime_body_part;
}


static void 
_set_parent (CamelMimeBodyPart *mime_body_part, CamelMultipart *multipart)
{
    if (mime_body_part->parent) gtk_object_unref (GTK_OBJECT (mime_body_part->parent));
    mime_body_part->parent = multipart;
    if (multipart) gtk_object_ref (GTK_OBJECT (multipart));
}


void 
camel_mime_body_part_set_parent (CamelMimeBodyPart *mime_body_part, CamelMultipart *multipart)
{
    CMBP_CLASS (mime_body_part)->set_parent (mime_body_part, multipart);
}


static const CamelMultipart *
_get_parent (CamelMimeBodyPart *mime_body_part)
{
    return mime_body_part->parent;
}


const CamelMultipart *
camel_mime_body_part_get_parent (CamelMimeBodyPart *mime_body_part)
{
    return CMBP_CLASS (mime_body_part)->get_parent (mime_body_part);
}