Beispiel #1
0
static void
on_parser_parsed (GcrParser *parser, gpointer user_data)
{
	GcrSimpleCollection *collection = user_data;
	GcrSimpleCollection *testcol;
	GcrRenderer *renderer;
	gchar *group;

	renderer = gcr_renderer_create (gcr_parser_get_parsed_label (parser),
	                                gcr_parser_get_parsed_attributes (parser));
	if (renderer == NULL)
		return;

	if (GCR_IS_CERTIFICATE (renderer))
		group = gcr_certificate_get_subject_part (GCR_CERTIFICATE (renderer), "O");
	else
		group = g_strdup (G_OBJECT_TYPE_NAME (renderer));


	testcol = test_collection_instance (group);
	if (!gcr_simple_collection_contains (collection, G_OBJECT (testcol)))
		gcr_simple_collection_add (collection, G_OBJECT (testcol));

	gcr_simple_collection_add (GCR_SIMPLE_COLLECTION (testcol), G_OBJECT (renderer));
	g_object_unref (renderer);
	g_object_unref (testcol);
	g_free (group);
}
Beispiel #2
0
/**
 * gcr_certificate_mixin_get_property: (skip)
 * @obj: The object
 * @prop_id: The property id
 * @value: The value to fill in.
 * @pspec: The param specification.
 *
 * Implementation to get various required certificate properties. This should
 * be called from your derived class get_property function, or used as a
 * get_property virtual function.
 *
 * Example of use as called from derived class get_property function:
 *
 * <informalexample><programlisting>
 * static void
 * my_get_property (GObject *obj, guint prop_id, GValue *value, GParamSpec *pspec)
 * {
 * 	switch (prop_id) {
 *
 * 	...
 *
 * 	default:
 * 		gcr_certificate_mixin_get_property (obj, prop_id, value, pspec);
 * 		break;
 * 	}
 *}
 * </programlisting></informalexample>
 *
 * Example of use as get_property function:
 *
 * <informalexample><programlisting>
 * static void
 * my_class_init (MyClass *klass)
 * {
 * 	GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
 * 	gobject_class->get_property = gcr_certificate_mixin_get_property;
 *
 * 	...
 * }
 * </programlisting></informalexample>

 */
void
gcr_certificate_mixin_get_property (GObject *obj, guint prop_id,
                                    GValue *value, GParamSpec *pspec)
{
	GcrCertificate *cert = GCR_CERTIFICATE (obj);

	switch (prop_id) {
	case PROP_LABEL:
		g_value_take_string (value, gcr_certificate_get_subject_name (cert));
		break;
	case PROP_SUBJECT:
		g_value_take_string (value, gcr_certificate_get_subject_name (cert));
		break;
	case PROP_ICON:
		g_value_set_object (value, gcr_certificate_get_icon (cert));
		break;
	case PROP_DESCRIPTION:
		g_value_set_string (value, _("Certificate"));
		break;
	case PROP_MARKUP:
		g_value_take_string (value, calculate_markup (cert));
		break;
	case PROP_ISSUER:
		g_value_take_string (value, gcr_certificate_get_issuer_name (cert));
		break;
	case PROP_EXPIRY:
		g_value_take_boxed (value, gcr_certificate_get_expiry_date (cert));
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
		break;
	}
}
static GcrCertificate*
mock_certificate_new (gconstpointer data, gsize n_data)
{
	MockCertificate *self = g_object_new (mock_certificate_get_type (), NULL);
	self->data = g_memdup (data, n_data);
	self->n_data = n_data;
	g_assert (self->created_on == g_thread_self ());
	return GCR_CERTIFICATE (self);
}
Beispiel #4
0
/**
 * gcr_certificate_compare:
 * @first: (allow-none): the certificate to compare
 * @other: (allow-none): the certificate to compare against
 *
 * Compare one certificate against another. If the certificates are equal
 * then zero is returned. If one certificate is %NULL or not a certificate,
 * then a non-zero value is returned.
 *
 * The return value is useful in a stable sort, but has no user logical
 * meaning.
 *
 * Returns: zero if the certificates match, non-zero otherwise.
 */
gint
gcr_certificate_compare (GcrComparable *first, GcrComparable *other)
{
	gconstpointer data1, data2;
	gsize size1, size2;

	if (!GCR_IS_CERTIFICATE (first))
		first = NULL;
	if (!GCR_IS_CERTIFICATE (other))
		other = NULL;

	if (first == other)
		return TRUE;
	if (!first)
		return 1;
	if (!other)
		return -1;

	data1 = gcr_certificate_get_der_data (GCR_CERTIFICATE (first), &size1);
	data2 = gcr_certificate_get_der_data (GCR_CERTIFICATE (other), &size2);

	return gcr_comparable_memcmp (data1, size1, data2, size2);
}
GcrCertificate*
gcr_simple_certificate_new (const guchar *data, gsize n_data)
{
	GcrSimpleCertificate *cert;
	
	g_return_val_if_fail (data, NULL);
	g_return_val_if_fail (n_data, NULL);
	
	cert = g_object_new (GCR_TYPE_SIMPLE_CERTIFICATE, NULL);
	
	cert->pv->owned_data = g_memdup (data, n_data);
	cert->pv->n_owned_data = n_data;
	return GCR_CERTIFICATE (cert);
}