libpurple/certificate.c

branch
soc.2007.certmgr
changeset 18251
41e00264c49d
parent 17509
fa009823dbfd
child 18446
3e79caab7088
equal deleted inserted replaced
18250:d7663374e33d 18251:41e00264c49d
27 */ 27 */
28 28
29 #include <glib.h> 29 #include <glib.h>
30 30
31 #include "certificate.h" 31 #include "certificate.h"
32 #include "debug.h"
32 33
33 /** List holding pointers to all registered certificate schemes */ 34 /** List holding pointers to all registered certificate schemes */
34 GList *cert_schemes = NULL; 35 static GList *cert_schemes = NULL;
35 36
37 PurpleCertificateScheme *
38 purple_certificate_find_scheme(const gchar *name)
39 {
40 PurpleCertificateScheme *scheme = NULL;
41 GList *l;
36 42
43 g_return_val_if_fail(name, NULL);
37 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 }

mercurial