changeset 18995:47b06daea9d1

- Add pool retrieve, contains, and store functions to certificate API - Minor doc clarification
author William Ehlhardt <williamehlhardt@gmail.com>
date Sun, 08 Jul 2007 00:42:01 +0000
parents bf23d58ec9c3
children 24fc5ca67afc
files libpurple/certificate.c libpurple/certificate.h
diffstat 2 files changed, 64 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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.                                           */
--- 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);
+
 /*@}*/
 
 /*****************************************************************************/