changeset 19018:d6f902265076

- Add purple_certificate_copy and associated machinery
author William Ehlhardt <williamehlhardt@gmail.com>
date Fri, 13 Jul 2007 08:38:21 +0000
parents e6558bae2bc6
children e179e7e6ded7
files libpurple/certificate.c libpurple/certificate.h libpurple/plugins/ssl/ssl-gnutls.c
diffstat 3 files changed, 29 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/certificate.c	Fri Jul 13 08:10:33 2007 +0000
+++ b/libpurple/certificate.c	Fri Jul 13 08:38:21 2007 +0000
@@ -98,6 +98,15 @@
 	g_free(vrq);
 }
 
+PurpleCertificate *
+purple_certificate_copy(PurpleCertificate *crt)
+{
+	g_return_val_if_fail(crt, NULL);
+	g_return_val_if_fail(crt->scheme, NULL);
+	g_return_val_if_fail(crt->scheme->copy_certificate, NULL);
+
+	return (crt->scheme->copy_certificate)(crt);
+}
 
 void
 purple_certificate_destroy (PurpleCertificate *crt)
--- a/libpurple/certificate.h	Fri Jul 13 08:10:33 2007 +0000
+++ b/libpurple/certificate.h	Fri Jul 13 08:38:21 2007 +0000
@@ -162,6 +162,16 @@
 	 */
 	gboolean (* export_certificate)(const gchar *filename, PurpleCertificate *crt);
 
+	/**
+	 * Duplicates a certificate
+	 *
+	 * Certificates are generally assumed to be read-only, so feel free to
+	 * do any sort of reference-counting magic you want here. If this ever
+	 * changes, please remember to change the magic accordingly.
+	 * @return Reference to the new copy
+	 */
+	PurpleCertificate * (* copy_certificate)(PurpleCertificate *crt);
+
 	/** Destroys and frees a Certificate structure
 	 *
 	 *  Destroys a Certificate's internal data structures and calls
@@ -360,6 +370,15 @@
 /*@{*/
 
 /**
+ * Makes a duplicate of a certificate
+ *
+ * @param crt        Instance to duplicate
+ * @return Pointer to new instance
+ */
+PurpleCertificate *
+purple_certificate_copy(PurpleCertificate *crt);
+
+/**
  * Destroys and free()'s a Certificate
  *
  * @param crt        Instance to destroy. May be NULL.
--- a/libpurple/plugins/ssl/ssl-gnutls.c	Fri Jul 13 08:10:33 2007 +0000
+++ b/libpurple/plugins/ssl/ssl-gnutls.c	Fri Jul 13 08:38:21 2007 +0000
@@ -799,6 +799,7 @@
 	N_("X.509 Certificates"),        /* User-visible scheme name */
 	x509_import_from_file,           /* Certificate import function */
 	x509_export_certificate,         /* Certificate export function */
+	NULL,                            /* Copy */
 	x509_destroy_certificate,        /* Destroy cert */
 	x509_sha1sum,                    /* SHA1 fingerprint */
 	NULL,                            /* Unique ID */