annotate libpurple/certificate.c @ 18926:8c4d52bc0319

- Add unregister_scheme
author William Ehlhardt <williamehlhardt@gmail.com>
date Thu, 21 Jun 2007 00:28:31 +0000
parents dc7e7b8bdc8c
children 425f494bd1ec
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17910
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
1 /**
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
2 * @file certificate.h Public-Key Certificate API
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
3 * @ingroup core
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
4 */
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
5
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
6 /*
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
7 *
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
8 * purple
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
9 *
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
10 * Purple is the legal property of its developers, whose names are too numerous
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
11 * to list here. Please refer to the COPYRIGHT file distributed with this
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
12 * source distribution.
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
13 *
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
14 * This program is free software; you can redistribute it and/or modify
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
15 * it under the terms of the GNU General Public License as published by
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
16 * the Free Software Foundation; either version 2 of the License, or
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
17 * (at your option) any later version.
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
18 *
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
19 * This program is distributed in the hope that it will be useful,
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
22 * GNU General Public License for more details.
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
23 *
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
24 * You should have received a copy of the GNU General Public License
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
25 * along with this program; if not, write to the Free Software
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
27 */
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
28
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
29 #include <glib.h>
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
30
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
31 #include "certificate.h"
18192
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
32 #include "debug.h"
17910
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
33
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
34 /** List holding pointers to all registered certificate schemes */
18192
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
35 static GList *cert_schemes = NULL;
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
36
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
37 PurpleCertificateScheme *
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
38 purple_certificate_find_scheme(const gchar *name)
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
39 {
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
40 PurpleCertificateScheme *scheme = NULL;
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
41 GList *l;
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
42
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
43 g_return_val_if_fail(name, NULL);
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
44
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
45 /* Traverse the list of registered schemes and locate the
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
46 one whose name matches */
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
47 for(l = cert_schemes; l; l = l->next) {
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
48 scheme = (PurpleCertificateScheme *)(l->data);
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
49
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
50 /* Name matches? that's our man */
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
51 if(!g_ascii_strcasecmp(scheme->name, name))
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
52 return scheme;
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
53 }
17910
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
54
18192
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
55 purple_debug_warning("certificate",
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
56 "CertificateScheme %s requested but not found.\n",
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
57 name);
17910
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
58
18192
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
59 /* TODO: Signalling and such? */
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
60
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
61 return NULL;
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
62 }
17910
668a294f9a72 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
63
18192
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
64 gboolean
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
65 purple_certificate_register_scheme(PurpleCertificateScheme *scheme)
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
66 {
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
67 g_return_val_if_fail(scheme != NULL, FALSE);
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
68
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
69 /* Make sure no scheme is registered with the same name */
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
70 if (purple_certificate_find_scheme(scheme->name) != NULL) {
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
71 return FALSE;
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
72 }
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
73
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
74 /* Okay, we're golden. Register it. */
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
75 cert_schemes = g_list_append(cert_schemes, scheme);
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
76
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
77 /* TODO: Signalling and such? */
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
78 return TRUE;
dc7e7b8bdc8c - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
79 }
18926
8c4d52bc0319 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18192
diff changeset
80
8c4d52bc0319 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18192
diff changeset
81 gboolean
8c4d52bc0319 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18192
diff changeset
82 purple_certificate_unregister_scheme(PurpleCertificateScheme *scheme)
8c4d52bc0319 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18192
diff changeset
83 {
8c4d52bc0319 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18192
diff changeset
84 if (NULL == scheme) {
8c4d52bc0319 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18192
diff changeset
85 purple_debug_warning("certificate",
8c4d52bc0319 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18192
diff changeset
86 "Attempting to unregister NULL scheme");
8c4d52bc0319 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18192
diff changeset
87 }
8c4d52bc0319 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18192
diff changeset
88
8c4d52bc0319 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18192
diff changeset
89 /* TODO: signalling? */
8c4d52bc0319 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18192
diff changeset
90
8c4d52bc0319 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18192
diff changeset
91 /* TODO: unregister all CertificatePools for this scheme! */
8c4d52bc0319 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18192
diff changeset
92 cert_schemes = g_list_remove(cert_schemes, scheme);
8c4d52bc0319 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18192
diff changeset
93
8c4d52bc0319 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18192
diff changeset
94 return TRUE;
8c4d52bc0319 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18192
diff changeset
95 }