changeset 19026:b3acaf46d9ad

- Add pool_get_idlist / pool_destroy_idlist
author William Ehlhardt <williamehlhardt@gmail.com>
date Mon, 16 Jul 2007 23:59:14 +0000
parents c3e80350c270
children 15d9031e03b2
files libpurple/certificate.c libpurple/certificate.h
diffstat 2 files changed, 46 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/certificate.c	Sun Jul 15 06:28:08 2007 +0000
+++ b/libpurple/certificate.c	Mon Jul 16 23:59:14 2007 +0000
@@ -322,6 +322,29 @@
 	return (pool->put_cert)(id, crt);
 }	
 
+GList *
+purple_certificate_pool_get_idlist(PurpleCertificatePool *pool)
+{
+	g_return_val_if_fail(pool, NULL);
+	g_return_val_if_fail(pool->get_idlist, NULL);
+
+	return (pool->get_idlist)();
+}
+
+void
+purple_certificate_pool_destroy_idlist(GList *idlist)
+{
+	GList *l;
+	
+	/* Iterate through and free them strings */
+	for ( l = idlist; l; l = l->next ) {
+		g_free(l->data);
+	}
+
+	g_list_free(idlist);
+}
+
+
 /****************************************************************************/
 /* Builtin Verifiers, Pools, etc.                                           */
 /****************************************************************************/
@@ -506,7 +529,8 @@
 	NULL,                         /* uninit not required */
 	x509_tls_peers_cert_in_pool,  /* Certificate exists? */
 	x509_tls_peers_get_cert,      /* Cert retriever */
-	x509_tls_peers_put_cert       /* Cert writer */
+	x509_tls_peers_put_cert,      /* Cert writer */
+	NULL                          /* idlist retriever */
 };
 
 
--- a/libpurple/certificate.h	Sun Jul 15 06:28:08 2007 +0000
+++ b/libpurple/certificate.h	Mon Jul 16 23:59:14 2007 +0000
@@ -118,6 +118,9 @@
 	 *  @return TRUE if the operation succeeded, otherwise FALSE
 	 */
 	gboolean (* put_cert)(const gchar *id, PurpleCertificate *crt);
+
+	/** Returns a list of IDs stored in the pool */
+	GList * (* get_idlist)(void);
 };
 
 /** A certificate type
@@ -522,6 +525,24 @@
 gboolean
 purple_certificate_pool_store(PurpleCertificatePool *pool, const gchar *id, PurpleCertificate *crt);
 
+/**
+ * Get the list of IDs currently in the pool.
+ *
+ * @param pool   Pool to enumerate
+ * @return GList pointing to newly-allocated id strings. Free using
+ *         purple_certificate_pool_destroy_idlist()
+ */
+GList *
+purple_certificate_pool_get_idlist(PurpleCertificatePool *pool);
+
+/**
+ * Destroys the result given by purple_certificate_pool_get_idlist()
+ *
+ * @param idlist ID List to destroy
+ */
+void
+purple_certificate_pool_destroy_idlist(GList *idlist);
+
 /*@}*/
 
 /*****************************************************************************/