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