# HG changeset patch # User William Ehlhardt # Date 1183855321 0 # Node ID 47b06daea9d1db7d6389e888fb544017ae3468b6 # Parent bf23d58ec9c3b4a00e4a2ff2508ffdcbcf979c5c - Add pool retrieve, contains, and store functions to certificate API - Minor doc clarification diff -r bf23d58ec9c3 -r 47b06daea9d1 libpurple/certificate.c --- a/libpurple/certificate.c Sun Jul 08 00:25:11 2007 +0000 +++ b/libpurple/certificate.c Sun Jul 08 00:42:01 2007 +0000 @@ -204,6 +204,38 @@ return path; } +gboolean +purple_certificate_pool_contains(PurpleCertificatePool *pool, const gchar *id) +{ + g_return_val_if_fail(pool, FALSE); + g_return_val_if_fail(id, FALSE); + g_return_val_if_fail(pool->cert_in_pool, FALSE); + + return (pool->cert_in_pool)(id); +} + +PurpleCertificate * +purple_certificate_pool_retrieve(PurpleCertificatePool *pool, const gchar *id) +{ + g_return_val_if_fail(pool, NULL); + g_return_val_if_fail(id, NULL); + g_return_val_if_fail(pool->get_cert, NULL); + + return (pool->get_cert)(id); +} + +gboolean +purple_certificate_pool_store(PurpleCertificatePool *pool, const gchar *id, PurpleCertificate *crt) +{ + g_return_val_if_fail(pool, FALSE); + g_return_val_if_fail(id, FALSE); + g_return_val_if_fail(pool->put_cert, FALSE); + + /* TODO: Should we check about scheme matches here or make that + someone else's problem? */ + + return (pool->put_cert)(id, crt); +} /****************************************************************************/ /* Builtin Verifiers, Pools, etc. */ diff -r bf23d58ec9c3 -r 47b06daea9d1 libpurple/certificate.h --- a/libpurple/certificate.h Sun Jul 08 00:25:11 2007 +0000 +++ b/libpurple/certificate.h Sun Jul 08 00:42:01 2007 +0000 @@ -73,7 +73,7 @@ /** * Database for retrieval or storage of Certificates * - * More or less a hash table; all lookups and writes are performed by a string + * More or less a hash table; all lookups and writes are controlled by a string * key. */ struct _PurpleCertificatePool @@ -438,6 +438,37 @@ gchar * purple_certificate_pool_mkpath(PurpleCertificatePool *pool, const gchar *id); +/** + * Check for presence of an ID in a pool. + * @param pool Pool to look in + * @param id ID to look for + * @return TRUE if the ID is in the pool, else FALSE + */ +gboolean +purple_certificate_pool_contains(PurpleCertificatePool *pool, const gchar *id); + +/** + * Retrieve a certificate from a pool. + * @param pool Pool to fish in + * @param id ID to look up + * @return Retrieved certificate, or NULL if it wasn't there + */ +PurpleCertificate * +purple_certificate_pool_retrieve(PurpleCertificatePool *pool, const gchar *id); + +/** + * Add a certificate to a pool + * + * Any pre-existing certificate of the same ID will be overwritten. + * + * @param pool Pool to add to + * @param id ID to store the certificate with + * @param crt Certificate to store + * @return TRUE if the operation succeeded, otherwise FALSE + */ +gboolean +purple_certificate_pool_store(PurpleCertificatePool *pool, const gchar *id, PurpleCertificate *crt); + /*@}*/ /*****************************************************************************/