changeset 19027:15d9031e03b2

- Add get_idlist support to tls_peers CertificatePool
author William Ehlhardt <williamehlhardt@gmail.com>
date Tue, 17 Jul 2007 00:10:11 +0000
parents b3acaf46d9ad
children 86403f33720b
files libpurple/certificate.c
diffstat 1 files changed, 31 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/certificate.c	Mon Jul 16 23:59:14 2007 +0000
+++ b/libpurple/certificate.c	Tue Jul 17 00:10:11 2007 +0000
@@ -520,6 +520,36 @@
 	return ret;
 }
 
+static GList *
+x509_tls_peers_get_idlist(void)
+{
+	GList *idlist = NULL;
+	GDir *dir;
+	const gchar *entry;
+	gchar *poolpath;
+
+	/* Get a handle on the pool directory */
+	poolpath = purple_certificate_pool_mkpath(&x509_tls_peers, NULL);
+	dir = g_dir_open(poolpath,
+			 0,     /* No flags */
+			 NULL); /* Not interested in what the error is */
+	g_free(poolpath);
+
+	g_return_val_if_fail(dir, NULL);
+
+	/* Traverse the directory listing and create an idlist */
+	while ( (entry = g_dir_read_name(dir)) != NULL ) {
+		/* Copy the entry name into our list (GLib owns the original
+		   string) */
+		idlist = g_list_prepend(idlist, g_strdup(entry));
+	}
+
+	/* Release the directory */
+	g_dir_close(dir);
+	
+	return idlist;
+}
+
 static PurpleCertificatePool x509_tls_peers = {
 	"x509",                       /* Scheme name */
 	"tls_peers",                  /* Pool name */
@@ -530,7 +560,7 @@
 	x509_tls_peers_cert_in_pool,  /* Certificate exists? */
 	x509_tls_peers_get_cert,      /* Cert retriever */
 	x509_tls_peers_put_cert,      /* Cert writer */
-	NULL                          /* idlist retriever */
+	x509_tls_peers_get_idlist     /* idlist retriever */
 };