aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-cms-context.h
blob: b68547e8b05676dd598af30265106cd7fcc4c6a2 (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
128
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 *  Authors: Jeffrey Stedfast <fejj@ximian.com>
 *
 *  Copyright 2001 Ximian, Inc. (www.ximian.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 Street #330, Boston, MA 02111-1307, USA.
 *
 */

#ifndef CAMEL_CMS_CONTEXT_H
#define CAMEL_CMS_CONTEXT_H

#include <camel/camel-session.h>
#include <camel/camel-stream.h>
#include <camel/camel-exception.h>
#include <camel/camel-mime-message.h>

#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */

#define CAMEL_CMS_CONTEXT_TYPE     (camel_cms_context_get_type ())
#define CAMEL_CMS_CONTEXT(obj)     (CAMEL_CHECK_CAST((obj), CAMEL_CMS_CONTEXT_TYPE, CamelCMSContext))
#define CAMEL_CMS_CONTEXT_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_CMS_CONTEXT_TYPE, CamelCMSContextClass))
#define CAMEL_IS_CMS_CONTEXT(o)    (CAMEL_CHECK_TYPE((o), CAMEL_CMS_CONTEXT_TYPE))

typedef enum {
    CAMEL_CMS_TYPE_DATA,
    CAMEL_CMS_TYPE_SIGNED,
    CAMEL_CMS_TYPE_ENVELOPED,
    CAMEL_CMS_TYPE_ENCRYPTED
} CamelCMSType;

typedef struct _CamelCMSSigner {
    struct _CamelCMSSigner *next;
    char *signercn;
    char *status;
} CamelCMSSigner;

typedef struct _CamelCMSValidityInfo {
    struct _CamelCMSValidityInfo *next;
    CamelCMSType type;
    CamelCMSSigner *signers;
} CamelCMSValidityInfo;


typedef struct _CamelCMSContext {
    CamelObject parent_object;
    
    struct _CamelCMSContextPrivate *priv;
    
    CamelSession *session;
} CamelCMSContext;

typedef struct _CamelCMSContextClass {
    CamelObjectClass parent_class;
    
    CamelMimeMessage *(*sign)       (CamelCMSContext *ctx, CamelMimeMessage *message,
                     const char *userid, gboolean signing_time,
                     gboolean detached, CamelException *ex);
    
    CamelMimeMessage *(*certsonly)  (CamelCMSContext *ctx, CamelMimeMessage *message,
                     const char *userid, GPtrArray *recipients,
                     CamelException *ex);
    
    CamelMimeMessage *(*encrypt)    (CamelCMSContext *ctx, CamelMimeMessage *message,
                     const char *userid, GPtrArray *recipients, 
                     CamelException *ex);
    
    CamelMimeMessage *(*envelope)   (CamelCMSContext *ctx, CamelMimeMessage *message,
                     const char *userid, GPtrArray *recipients, 
                     CamelException *ex);
    
    CamelMimeMessage *(*decode)     (CamelCMSContext *ctx, CamelMimeMessage *message,
                     CamelCMSValidityInfo **info, CamelException *ex);
    
} CamelCMSContextClass;

CamelType         camel_cms_context_get_type (void);

CamelCMSContext  *camel_cms_context_new (CamelSession *session);

void              camel_cms_context_construct (CamelCMSContext *context, CamelSession *session);

/* cms routines */
CamelMimeMessage *camel_cms_sign      (CamelCMSContext *ctx, CamelMimeMessage *message,
                       const char *userid, gboolean signing_time,
                       gboolean detached, CamelException *ex);

CamelMimeMessage *camel_cms_certsonly (CamelCMSContext *ctx, CamelMimeMessage *message,
                       const char *userid, GPtrArray *recipients,
                       CamelException *ex);

CamelMimeMessage *camel_cms_encrypt   (CamelCMSContext *ctx, CamelMimeMessage *message,
                       const char *userid, GPtrArray *recipients, 
                       CamelException *ex);

CamelMimeMessage *camel_cms_envelope  (CamelCMSContext *ctx, CamelMimeMessage *message,
                       const char *userid, GPtrArray *recipients, 
                       CamelException *ex);

CamelMimeMessage *camel_cms_decode    (CamelCMSContext *ctx, CamelMimeMessage *message,
                       CamelCMSValidityInfo **info, CamelException *ex);


void              camel_cms_signer_free        (CamelCMSSigner *signer);

void              camel_cms_validity_info_free (CamelCMSValidityInfo *info);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* CAMEL_CMS_CONTEXT_H */