[gnome-keyring: 1/2] gcr: Add _gcr_display_view_append_hex() function.
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keyring: 1/2] gcr: Add _gcr_display_view_append_hex() function.
- Date: Tue, 24 May 2011 07:35:50 +0000 (UTC)
commit e037705a72287f48218d62c4c198bf77f04f8e8d
Author: Stef Walter <stefw collabora co uk>
Date: Wed Apr 6 13:11:16 2011 +0200
gcr: Add _gcr_display_view_append_hex() function.
Displays value as a hex string, rather than just converting to hex
everywhere and duplicating the same code.
https://bugzilla.gnome.org/show_bug.cgi?id=646901
gcr/gcr-certificate-renderer.c | 31 ++++++++-----------------------
gcr/gcr-display-view.c | 16 ++++++++++++----
gcr/gcr-display-view.h | 6 ++++++
gcr/gcr-key-renderer.c | 2 --
4 files changed, 26 insertions(+), 29 deletions(-)
---
diff --git a/gcr/gcr-certificate-renderer.c b/gcr/gcr-certificate-renderer.c
index f0ffcef..f553048 100644
--- a/gcr/gcr-certificate-renderer.c
+++ b/gcr/gcr-certificate-renderer.c
@@ -105,7 +105,6 @@ append_extension (GcrCertificateRenderer *self, GcrDisplayView *view,
GcrRenderer *renderer = GCR_RENDERER (self);
GNode *node;
GQuark oid;
- gchar *display;
gsize n_value;
const guchar *value;
const gchar *text;
@@ -132,9 +131,7 @@ append_extension (GcrCertificateRenderer *self, GcrDisplayView *view,
value = egg_asn1x_get_raw_value (egg_asn1x_node (node, "extnValue", NULL), &n_value);
/* TODO: Parsing of extensions that we understand */
- display = egg_hex_encode_full (value, n_value, TRUE, ' ', 1);
- _gcr_display_view_append_value (view, renderer, _("Value"), display, TRUE);
- g_free (display);
+ _gcr_display_view_append_hex (view, renderer, _("Value"), value, n_value);
/* Critical */
@@ -472,9 +469,7 @@ gcr_certificate_renderer_render (GcrRenderer *renderer, GcrViewer *viewer)
raw = egg_asn1x_get_integer_as_raw (egg_asn1x_node (asn, "tbsCertificate", "serialNumber", NULL), NULL, &n_raw);
g_return_if_fail (raw);
- display = egg_hex_encode_full (raw, n_raw, TRUE, ' ', 1);
- _gcr_display_view_append_value (view, renderer, _("Serial Number"), display, TRUE);
- g_free (display);
+ _gcr_display_view_append_hex (view, renderer, _("Serial Number"), raw, n_raw);
g_free (raw);
display = g_malloc0 (128);
@@ -498,17 +493,12 @@ gcr_certificate_renderer_render (GcrRenderer *renderer, GcrViewer *viewer)
_gcr_display_view_append_value (view, renderer, _("Signature Algorithm"), text, FALSE);
value = egg_asn1x_get_raw_element (egg_asn1x_node (asn, "signatureAlgorithm", "parameters", NULL), &n_value);
- if (value && n_value) {
- display = egg_hex_encode_full (value, n_value, TRUE, ' ', 1);
- _gcr_display_view_append_value (view, renderer, _("Signature Parameters"), display, TRUE);
- g_free (display);
- }
+ if (value && n_value)
+ _gcr_display_view_append_hex (view, renderer, _("Signature Parameters"), value, n_value);
raw = egg_asn1x_get_bits_as_raw (egg_asn1x_node (asn, "signature", NULL), NULL, &bits);
g_return_if_fail (raw);
- display = egg_hex_encode_full (raw, bits / 8, TRUE, ' ', 1);
- _gcr_display_view_append_value (view, renderer, _("Signature"), display, TRUE);
- g_free (display);
+ _gcr_display_view_append_hex (view, renderer, _("Signature"), raw, bits / 8);
g_free (raw);
/* Public Key Info */
@@ -521,11 +511,8 @@ gcr_certificate_renderer_render (GcrRenderer *renderer, GcrViewer *viewer)
value = egg_asn1x_get_raw_element (egg_asn1x_node (asn, "tbsCertificate", "subjectPublicKeyInfo",
"algorithm", "parameters", NULL), &n_value);
- if (value && n_value) {
- display = egg_hex_encode_full (value, n_value, TRUE, ' ', 1);
- _gcr_display_view_append_value (view, renderer, _("Key Parameters"), display, TRUE);
- g_free (display);
- }
+ if (value && n_value)
+ _gcr_display_view_append_hex (view, renderer, _("Key Parameters"), value, n_value);
bits = gcr_certificate_get_key_size (cert);
if (bits > 0) {
@@ -537,9 +524,7 @@ gcr_certificate_renderer_render (GcrRenderer *renderer, GcrViewer *viewer)
raw = egg_asn1x_get_bits_as_raw (egg_asn1x_node (asn, "tbsCertificate", "subjectPublicKeyInfo",
"subjectPublicKey", NULL), NULL, &bits);
g_return_if_fail (raw);
- display = egg_hex_encode_full (raw, bits / 8, TRUE, ' ', 1);
- _gcr_display_view_append_value (view, renderer, _("Public Key"), display, TRUE);
- g_free (display);
+ _gcr_display_view_append_hex (view, renderer, _("Public Key"), raw, bits / 8);
g_free (raw);
/* Fingerprints */
diff --git a/gcr/gcr-display-view.c b/gcr/gcr-display-view.c
index 6c5fb61..bf7b606 100644
--- a/gcr/gcr-display-view.c
+++ b/gcr/gcr-display-view.c
@@ -889,6 +889,17 @@ _gcr_display_view_append_value (GcrDisplayView *self, GcrRenderer *renderer, con
}
void
+_gcr_display_view_append_hex (GcrDisplayView *self, GcrRenderer *renderer,
+ const gchar *field, gconstpointer value, gsize n_value)
+{
+ gchar *display;
+
+ display = egg_hex_encode_full (value, n_value, TRUE, ' ', 1);
+ _gcr_display_view_append_value (self, renderer, field, display, TRUE);
+ g_free (display);
+}
+
+void
_gcr_display_view_append_title (GcrDisplayView *self, GcrRenderer *renderer, const gchar *title)
{
GcrDisplayItem *item;
@@ -939,7 +950,6 @@ _gcr_display_view_append_fingerprint (GcrDisplayView *self, GcrRenderer *rendere
GChecksum *checksum;
guint8 *buffer;
gsize n_buffer;
- gchar *display;
g_return_if_fail (GCR_IS_DISPLAY_VIEW (self));
@@ -954,9 +964,7 @@ _gcr_display_view_append_fingerprint (GcrDisplayView *self, GcrRenderer *rendere
g_checksum_get_digest (checksum, buffer, &n_buffer);
g_checksum_free (checksum);
- display = egg_hex_encode_full (buffer, n_buffer, TRUE, ' ', 1);
- _gcr_display_view_append_value (self, renderer, name, display, TRUE);
- g_free (display);
+ _gcr_display_view_append_hex (self, renderer, name, buffer, n_buffer);
g_free (buffer);
}
diff --git a/gcr/gcr-display-view.h b/gcr/gcr-display-view.h
index be237bb..5bd85d3 100644
--- a/gcr/gcr-display-view.h
+++ b/gcr/gcr-display-view.h
@@ -62,6 +62,12 @@ void _gcr_display_view_append_value (GcrDisplayView *
const gchar *value,
gboolean monospace);
+void _gcr_display_view_append_hex (GcrDisplayView *self,
+ GcrRenderer *renderer,
+ const gchar *field,
+ gconstpointer value,
+ gsize n_value);
+
void _gcr_display_view_append_title (GcrDisplayView *self,
GcrRenderer *renderer,
const gchar *title);
diff --git a/gcr/gcr-key-renderer.c b/gcr/gcr-key-renderer.c
index 0dcc87b..bf3934c 100644
--- a/gcr/gcr-key-renderer.c
+++ b/gcr/gcr-key-renderer.c
@@ -25,8 +25,6 @@
#include "gcr-renderer.h"
#include "gcr-viewer.h"
-#include "egg/egg-hex.h"
-
#include "gck/gck.h"
#include <gdk/gdk.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]