changeset 19012:b1090cbfc286

- Add expiration/activation functions for Certificates
author William Ehlhardt <williamehlhardt@gmail.com>
date Thu, 12 Jul 2007 01:10:04 +0000
parents b4207894b534
children 5157ebe90b93
files libpurple/certificate.c libpurple/certificate.h
diffstat 2 files changed, 40 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/certificate.c	Thu Jul 12 00:55:35 2007 +0000
+++ b/libpurple/certificate.c	Thu Jul 12 01:10:04 2007 +0000
@@ -203,6 +203,34 @@
 	return (scheme->check_subject_name)(crt, name);
 }
 
+gboolean
+purple_certificate_get_times(PurpleCertificate *crt, time_t *activation, time_t *expiration)
+{
+	PurpleCertificateScheme *scheme;
+
+	g_return_val_if_fail(crt, FALSE);
+
+	scheme = crt->scheme;
+	
+	g_return_val_if_fail(scheme, FALSE);
+
+	/* If both provided references are NULL, what are you doing calling
+	   this? */
+	g_return_val_if_fail( (activation != NULL) || (expiration != NULL), FALSE);
+
+	/* Fulfill the caller's requests, if possible */
+	if (activation) {
+		g_return_val_if_fail(scheme->get_activation, FALSE);
+		*activation = scheme->get_activation(crt);
+	}
+	if (expiration) {
+		g_return_val_if_fail(scheme->get_expiration, FALSE);
+		*expiration = scheme->get_expiration(crt);
+	}
+
+	return TRUE;
+}
+
 
 gchar *
 purple_certificate_pool_mkpath(PurpleCertificatePool *pool, const gchar *id)
--- a/libpurple/certificate.h	Thu Jul 12 00:55:35 2007 +0000
+++ b/libpurple/certificate.h	Thu Jul 12 01:10:04 2007 +0000
@@ -429,6 +429,18 @@
 gboolean
 purple_certificate_check_subject_name(PurpleCertificate *crt, const gchar *name);
 
+/**
+ * Get the expiration/activation times.
+ *
+ * @param crt          Certificate instance
+ * @param activation   Reference to store the activation time at. May be NULL
+ *                     if you don't actually want it.
+ * @param expiration   Reference to store the expiration time at. May be NULL
+ *                     if you don't actually want it.
+ * @return TRUE if the requested values were obtained, otherwise FALSE.
+ */
+gboolean
+purple_certificate_get_times(PurpleCertificate *crt, time_t *activation, time_t *expiration);
 
 /*@}*/