# HG changeset patch # User William Ehlhardt # Date 1184630354 0 # Node ID b3acaf46d9ad5d75949a4c5b5da01b0bd6b0f2ce # Parent c3e80350c27095a573f8bac5769a0503605cf616 - Add pool_get_idlist / pool_destroy_idlist diff -r c3e80350c270 -r b3acaf46d9ad libpurple/certificate.c --- 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 */ }; diff -r c3e80350c270 -r b3acaf46d9ad libpurple/certificate.h --- 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); + /*@}*/ /*****************************************************************************/