Mercurial > pidgin.yaz
changeset 18192:dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
author | William Ehlhardt <williamehlhardt@gmail.com> |
---|---|
date | Wed, 20 Jun 2007 01:47:55 +0000 |
parents | a4336814bfd4 |
children | 3298421a330e |
files | libpurple/certificate.c libpurple/certificate.h |
diffstat | 2 files changed, 61 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/certificate.c Tue Jun 19 18:27:07 2007 +0000 +++ b/libpurple/certificate.c Wed Jun 20 01:47:55 2007 +0000 @@ -29,9 +29,51 @@ #include <glib.h> #include "certificate.h" +#include "debug.h" /** List holding pointers to all registered certificate schemes */ -GList *cert_schemes = NULL; +static GList *cert_schemes = NULL; + +PurpleCertificateScheme * +purple_certificate_find_scheme(const gchar *name) +{ + PurpleCertificateScheme *scheme = NULL; + GList *l; + + g_return_val_if_fail(name, NULL); + + /* Traverse the list of registered schemes and locate the + one whose name matches */ + for(l = cert_schemes; l; l = l->next) { + scheme = (PurpleCertificateScheme *)(l->data); + + /* Name matches? that's our man */ + if(!g_ascii_strcasecmp(scheme->name, name)) + return scheme; + } + purple_debug_warning("certificate", + "CertificateScheme %s requested but not found.\n", + name); + /* TODO: Signalling and such? */ + + return NULL; +} +gboolean +purple_certificate_register_scheme(PurpleCertificateScheme *scheme) +{ + g_return_val_if_fail(scheme != NULL, FALSE); + + /* Make sure no scheme is registered with the same name */ + if (purple_certificate_find_scheme(scheme->name) != NULL) { + return FALSE; + } + + /* Okay, we're golden. Register it. */ + cert_schemes = g_list_append(cert_schemes, scheme); + + /* TODO: Signalling and such? */ + return TRUE; +}
--- a/libpurple/certificate.h Tue Jun 19 18:27:07 2007 +0000 +++ b/libpurple/certificate.h Wed Jun 20 01:47:55 2007 +0000 @@ -101,6 +101,24 @@ /*****************************************************************************/ /*@{*/ +/** Look up a registered CertificateScheme by name + * @param name The scheme name. Case insensitive. + * @return Pointer to the located Scheme, or NULL if it isn't found. + */ +PurpleCertificateScheme * +purple_certificate_find_scheme(const gchar *name); + +/** Register a CertificateScheme with libpurple + * + * No two schemes can be registered with the same name; this function enforces + * that. + * + * @param scheme Pointer to the scheme to register. + * @return TRUE if the scheme was successfully added, otherwise FALSE + */ +gboolean +purple_certificate_register_scheme(PurpleCertificateScheme *scheme); + /* TODO: ADD STUFF HERE */ /*@}*/