aboutsummaryrefslogtreecommitdiffstats
path: root/em-format/e-mail-part.h
blob: cb25cb302007b958d5564fbd3c2782af0784add1 (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
125
126
127
/*
 * e-mail-part.h
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) version 3.
 *
 * 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with the program; if not, see <http://www.gnu.org/licenses/>
 *
 */

#ifndef E_MAIL_PART_H
#define E_MAIL_PART_H

#include <camel/camel.h>
#include <webkit/webkitdom.h>

#include <e-util/e-util.h>

#define E_MAIL_PART_IS(p,s_t) \
        ((p != NULL) && (e_mail_part_get_instance_size (p) == sizeof (s_t)))
#define E_MAIL_PART(o) ((EMailPart *) o)

G_BEGIN_DECLS

typedef struct _EMailPart EMailPart;
typedef struct _EMailPartPrivate EMailPartPrivate;

typedef void    (*EMailPartDOMBindFunc) (EMailPart *part,
                     WebKitDOMElement *element);

typedef enum {
    E_MAIL_PART_VALIDITY_NONE      = 0,
    E_MAIL_PART_VALIDITY_PGP       = 1 << 0,
    E_MAIL_PART_VALIDITY_SMIME     = 1 << 1,
    E_MAIL_PART_VALIDITY_SIGNED    = 1 << 2,
    E_MAIL_PART_VALIDITY_ENCRYPTED = 1 << 3
} EMailPartValidityFlags;

typedef struct _EMailPartValidityPair EMailPartValidityPair;

struct _EMailPartValidityPair {
    EMailPartValidityFlags validity_type;
    CamelCipherValidity *validity;
};

struct _EMailPart {
    EMailPartPrivate *priv;

    EMailPartDOMBindFunc bind_func;

    CamelMimePart *part;
    gchar *id;
    gchar *cid;
    gchar *mime_type;

    GQueue validities;  /* element-type: EMailPartValidityPair */

    gint is_attachment: 1;

    /* Whether the part should be rendered or not.
     * This is used for example to prevent images
     * related to text/html parts from being
     * rendered as attachments. */
    gint is_hidden: 1;

    /* Force attachment to be expanded, even without
     * content-disposition: inline */
    gint force_inline: 1;

    /* Force attachment to be collapsed, even with
     * content-disposition: inline */
    gint force_collapse: 1;

    /* Does part contain an error message? */
    gint is_error: 1;
};

EMailPart * e_mail_part_new         (CamelMimePart *part,
                         const gchar *id);
EMailPart * e_mail_part_subclass_new    (CamelMimePart *part,
                         const gchar *id,
                         gsize size,
                         GFreeFunc free_func);

EMailPart * e_mail_part_ref         (EMailPart *part);
void        e_mail_part_unref       (EMailPart *part);

gsize       e_mail_part_get_instance_size   (EMailPart *part);

const gchar *   e_mail_part_get_id      (EMailPart *part);
const gchar *   e_mail_part_get_cid     (EMailPart *part);
void        e_mail_part_set_cid     (EMailPart *part,
                         const gchar *cid);
gboolean    e_mail_part_id_has_prefix   (EMailPart *part,
                         const gchar *prefix);
gboolean    e_mail_part_id_has_suffix   (EMailPart *part,
                         const gchar *suffix);
gboolean    e_mail_part_id_has_substr   (EMailPart *part,
                         const gchar *substr);
CamelMimePart * e_mail_part_ref_mime_part   (EMailPart *part);
const gchar *   e_mail_part_get_mime_type   (EMailPart *part);
void        e_mail_part_set_mime_type   (EMailPart *part,
                         const gchar *mime_type);
gboolean    e_mail_part_get_is_attachment   (EMailPart *part);
void        e_mail_part_set_is_attachment   (EMailPart *part,
                         gboolean is_attachment);
void        e_mail_part_update_validity (EMailPart *part,
                         CamelCipherValidity *validity,
                         guint32 validity_type);
CamelCipherValidity *
        e_mail_part_get_validity    (EMailPart *part,
                         guint32 validity_type);
gboolean    e_mail_part_has_validity    (EMailPart *part);
EMailPartValidityFlags
        e_mail_part_get_validity_flags  (EMailPart *part);

G_END_DECLS

#endif /* E_MAIL_PART_H */