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.
24 #ifndef __CAMEL_CERTDB_H__
25 #define __CAMEL_CERTDB_H__
28 #include <camel/camel-object.h>
30 #define CAMEL_CERTDB_TYPE (camel_certdb_get_type ())
31 #define CAMEL_CERTDB(obj) (CAMEL_CHECK_CAST (obj, camel_certdb_get_type (), CamelCertDB))
32 #define CAMEL_CERTDB_CLASS(klass) (CAMEL_CHECK_CLASS_CAST (klass, camel_certdb_get_type (), CamelCertDBClass))
33 #define CAMEL_IS_CERTDB(obj) (CAMEL_CHECK_TYPE (obj, camel_certdb_get_type ()))
37 typedef struct _CamelCertDB CamelCertDB;
38 typedef struct _CamelCertDBClass CamelCertDBClass;
41 CAMEL_CERTDB_DIRTY = (1 << 0),
45 CAMEL_CERT_STRING_ISSUER,
46 CAMEL_CERT_STRING_SUBJECT,
47 CAMEL_CERT_STRING_HOSTNAME,
48 CAMEL_CERT_STRING_FINGERPRINT,
52 CAMEL_CERT_TRUST_UNKNOWN,
53 CAMEL_CERT_TRUST_NEVER,
54 CAMEL_CERT_TRUST_MARGINAL,
55 CAMEL_CERT_TRUST_FULLY,
56 CAMEL_CERT_TRUST_ULTIMATE,
72 CamelObject parent_object;
73 struct _CamelCertDBPrivate *priv;
82 struct _EMemChunk *cert_chunks;
85 GHashTable *cert_hash;
88 struct _CamelCertDBClass {
89 CamelObjectClass parent_class;
91 int (*header_load) (CamelCertDB *certdb, FILE *istream);
92 int (*header_save) (CamelCertDB *certdb, FILE *ostream);
94 CamelCert * (*cert_load) (CamelCertDB *certdb, FILE *istream);
95 int (*cert_save) (CamelCertDB *certdb, CamelCert *cert, FILE *ostream);
97 CamelCert * (*cert_new) (CamelCertDB *certdb);
98 void (*cert_free) (CamelCertDB *certdb, CamelCert *cert);
100 const char * (*cert_get_string) (CamelCertDB *certdb, CamelCert *cert, int string);
101 void (*cert_set_string) (CamelCertDB *certdb, CamelCert *cert, int string, const char *value);
105 CamelType camel_certdb_get_type (void);
107 CamelCertDB *camel_certdb_new (void);
109 void camel_certdb_set_default (CamelCertDB *certdb);
110 CamelCertDB *camel_certdb_get_default (void);
112 void camel_certdb_set_filename (CamelCertDB *certdb, const char *filename);
114 int camel_certdb_load (CamelCertDB *certdb);
115 int camel_certdb_save (CamelCertDB *certdb);
117 void camel_certdb_touch (CamelCertDB *certdb);
119 CamelCert *camel_certdb_get_cert (CamelCertDB *certdb, const char *fingerprint);
121 void camel_certdb_add (CamelCertDB *certdb, CamelCert *cert);
122 void camel_certdb_remove (CamelCertDB *certdb, CamelCert *cert);
124 CamelCert *camel_certdb_cert_new (CamelCertDB *certdb);
125 void camel_certdb_cert_ref (CamelCertDB *certdb, CamelCert *cert);
126 void camel_certdb_cert_unref (CamelCertDB *certdb, CamelCert *cert);
128 void camel_certdb_clear (CamelCertDB *certdb);
131 const char *camel_cert_get_string (CamelCertDB *certdb, CamelCert *cert, int string);
132 void camel_cert_set_string (CamelCertDB *certdb, CamelCert *cert, int string, const char *value);
134 #define camel_cert_get_issuer(certdb,cert) camel_cert_get_string (certdb, cert, CAMEL_CERT_STRING_ISSUER)
135 #define camel_cert_get_subject(certdb,cert) camel_cert_get_string (certdb, cert, CAMEL_CERT_STRING_SUBJECT)
136 #define camel_cert_get_hostname(certdb,cert) camel_cert_get_string (certdb, cert, CAMEL_CERT_STRING_HOSTNAME)
137 #define camel_cert_get_fingerprint(certdb,cert) camel_cert_get_string (certdb, cert, CAMEL_CERT_STRING_FINGERPRINT)
139 #define camel_cert_set_issuer(certdb,cert,issuer) camel_cert_set_string (certdb, cert, CAMEL_CERT_STRING_ISSUER, issuer)
140 #define camel_cert_set_subject(certdb,cert,subject) camel_cert_set_string (certdb, cert, CAMEL_CERT_STRING_SUBJECT, subject)
141 #define camel_cert_set_hostname(certdb,cert,hostname) camel_cert_set_string (certdb, cert, CAMEL_CERT_STRING_HOSTNAME, hostname)
142 #define camel_cert_set_fingerprint(certdb,cert,fingerprint) camel_cert_set_string (certdb, cert, CAMEL_CERT_STRING_FINGERPRINT, fingerprint)
144 CamelCertTrust camel_cert_get_trust (CamelCertDB *certdb, CamelCert *cert);
145 void camel_cert_set_trust (CamelCertDB *certdb, CamelCert *cert, CamelCertTrust trust);
149 #endif /* __CAMEL_CERTDB_H__ */