summaryrefslogtreecommitdiff
path: root/gcr
diff options
context:
space:
mode:
authorNiels De Graef <nielsdegraef@gmail.com>2022-07-15 13:11:24 +0200
committerNiels De Graef <nielsdegraef@gmail.com>2022-07-15 13:11:24 +0200
commit7ea633f385545e46a329e42d535abb23991c6bd5 (patch)
tree6c21e43add8b3bd784fa4755b16b89973f1a9415 /gcr
parentabcede862f2d96eec1ea7b3bf52f9aee7e9ea372 (diff)
downloadgcr-7ea633f385545e46a329e42d535abb23991c6bd5.tar.gz
gcr: Drop the GcrComparable interface
We aren't using it for anything nor is anybody create a custom comparable interface. Applications that want to do sorting problably have a better idea on how they want to sort things (and might want to deal with it differently, like extending `GtkSorter` for example)
Diffstat (limited to 'gcr')
-rw-r--r--gcr/Gcr-4.metadata2
-rw-r--r--gcr/gcr-certificate.c72
-rw-r--r--gcr/gcr-certificate.h9
-rw-r--r--gcr/gcr-comparable.c106
-rw-r--r--gcr/gcr-comparable.h49
-rw-r--r--gcr/gcr-pkcs11-certificate.c1
-rw-r--r--gcr/gcr-simple-certificate.c2
-rw-r--r--gcr/meson.build2
-rw-r--r--gcr/test-certificate-chain.c1
9 files changed, 1 insertions, 243 deletions
diff --git a/gcr/Gcr-4.metadata b/gcr/Gcr-4.metadata
index c7647fb..ab4b858 100644
--- a/gcr/Gcr-4.metadata
+++ b/gcr/Gcr-4.metadata
@@ -6,5 +6,3 @@ Certificate
.subject_name nullable=true
.issuer_name nullable=true
.expiry_date nullable=true
-Comparable
- .memcmp skip=false
diff --git a/gcr/gcr-certificate.c b/gcr/gcr-certificate.c
index f0d6d66..fc2d9e0 100644
--- a/gcr/gcr-certificate.c
+++ b/gcr/gcr-certificate.c
@@ -21,7 +21,6 @@
#include "gcr-certificate.h"
#include "gcr-certificate-extensions.h"
-#include "gcr-comparable.h"
#include "gcr-internal.h"
#include "gcr-subject-public-key.h"
@@ -54,10 +53,6 @@
* You can use a mixin to implement these properties if desired. See the
* gcr_certificate_mixin_class_init() and gcr_certificate_mixin_get_property()
* functions.
- *
- * All certificates are comparable. If implementing a #GcrCertificate, you can
- * use GCR_CERTIFICATE_MIXIN_IMPLEMENT_COMPARABLE() to implement the #GcrComparable
- * interface.
*/
/**
@@ -243,50 +238,12 @@ gcr_certificate_default_init (GcrCertificateIface *iface)
typedef GcrCertificateIface GcrCertificateInterface;
-G_DEFINE_INTERFACE (GcrCertificate, gcr_certificate, GCR_TYPE_COMPARABLE);
+G_DEFINE_INTERFACE (GcrCertificate, gcr_certificate, G_TYPE_OBJECT);
/* -----------------------------------------------------------------------------
* PUBLIC
*/
-/**
- * gcr_certificate_compare:
- * @first: (nullable): the certificate to compare
- * @other: (nullable): 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);
-}
-
/**
* gcr_certificate_get_der_data: (virtual get_der_data)
@@ -904,19 +861,6 @@ gcr_certificate_get_basic_constraints (GcrCertificate *self,
*/
/**
- * GCR_CERTIFICATE_MIXIN_IMPLEMENT_COMPARABLE:
- *
- * Implement the GcrComparable interface. Use this macro like this:
- *
- * <informalexample><programlisting>
- * G_DEFINE_TYPE_WITH_CODE (MyCertificate, my_certificate, G_TYPE_OBJECT,
- * GCR_CERTIFICATE_MIXIN_IMPLEMENT_COMPARABLE ();
- * G_IMPLEMENT_INTERFACE (GCR_TYPE_CERTIFICATE, my_certificate_iface_init);
- * );
- * </programlisting></informalexample>
- */
-
-/**
* gcr_certificate_mixin_emit_notify:
* @self: the #GcrCertificate
*
@@ -939,20 +883,6 @@ gcr_certificate_mixin_emit_notify (GcrCertificate *self)
}
/**
- * gcr_certificate_mixin_comparable_init: (skip)
- * @iface: The interface
- *
- * Initialize a #GcrComparableIface to compare the current certificate.
- * In general it's easier to use the GCR_CERTIFICATE_MIXIN_IMPLEMENT_COMPARABLE()
- * macro instead of this function.
- */
-void
-gcr_certificate_mixin_comparable_init (GcrComparableInterface *iface)
-{
- iface->compare = gcr_certificate_compare;
-}
-
-/**
* gcr_certificate_mixin_class_init: (skip)
* @object_class: The GObjectClass for this class
*
diff --git a/gcr/gcr-certificate.h b/gcr/gcr-certificate.h
index 9f7a1f2..f0df372 100644
--- a/gcr/gcr-certificate.h
+++ b/gcr/gcr-certificate.h
@@ -25,7 +25,6 @@
#endif
#include "gcr-types.h"
-#include "gcr-comparable.h"
#include <glib-object.h>
#include <gio/gio.h>
@@ -72,9 +71,6 @@ GType gcr_certificate_get_type (void);
const guint8 * gcr_certificate_get_der_data (GcrCertificate *self,
gsize *n_data);
-gint gcr_certificate_compare (GcrComparable *first,
- GcrComparable *other);
-
gchar * gcr_certificate_get_issuer_name (GcrCertificate *self);
gchar* gcr_certificate_get_issuer_cn (GcrCertificate *self);
@@ -124,13 +120,8 @@ gboolean gcr_certificate_get_basic_constraints (GcrCertificate *self
gboolean *is_ca,
gint *path_len);
-#define GCR_CERTIFICATE_MIXIN_IMPLEMENT_COMPARABLE() \
- G_IMPLEMENT_INTERFACE (GCR_TYPE_COMPARABLE, gcr_certificate_mixin_comparable_init)
-
void gcr_certificate_mixin_emit_notify (GcrCertificate *self);
-void gcr_certificate_mixin_comparable_init (GcrComparableInterface *iface);
-
void gcr_certificate_mixin_class_init (GObjectClass *object_class);
void gcr_certificate_mixin_get_property (GObject *obj,
diff --git a/gcr/gcr-comparable.c b/gcr/gcr-comparable.c
deleted file mode 100644
index 4572dd1..0000000
--- a/gcr/gcr-comparable.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * gnome-keyring
- *
- * Copyright (C) 2010 Stefan Walter
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#include "gcr-comparable.h"
-
-#include <string.h>
-
-/**
- * GcrComparable:
- *
- * An interface for comparing objects
- */
-
-/**
- * GcrComparableInterface:
- * @parent: type interface
- * @compare: Compare whether tow objects represent the same thing.
- *
- * The interface to implement for [iface@Comparable]
- */
-
-G_DEFINE_INTERFACE (GcrComparable, gcr_comparable, G_TYPE_OBJECT);
-
-static void
-gcr_comparable_default_init (GcrComparableInterface *iface)
-{
-
-}
-
-
-/**
- * gcr_comparable_compare:
- * @self: The comparable object
- * @other: (nullable): Another comparable object
- *
- * Compare whether two objects represent the same thing. The return value can
- * also be used to sort the objects.
- *
- * Returns: Zero if the two objects represent the same thing, non-zero if not.
- */
-gint
-gcr_comparable_compare (GcrComparable *self, GcrComparable *other)
-{
- g_return_val_if_fail (GCR_IS_COMPARABLE (self), -1);
- g_return_val_if_fail (GCR_COMPARABLE_GET_IFACE (self)->compare, -1);
- g_return_val_if_fail (G_IS_OBJECT (self), -1);
- return GCR_COMPARABLE_GET_IFACE (self)->compare (self, other);
-}
-
-/**
- * gcr_comparable_memcmp: (skip)
- * @mem1: (array length=size1) (element-type guint8): First block of memory
- * @size1: Length of first block
- * @mem2: (array length=size2) (element-type guint8): Second block of memory
- * @size2: Length of second block
- *
- * Compare two blocks of memory. The return value can be used to sort
- * the blocks of memory.
- *
- * Returns: Zero if the blocks are identical, negative if first
- * less than secend, possitive otherwise.
- */
-gint
-gcr_comparable_memcmp (gconstpointer mem1,
- gsize size1,
- gconstpointer mem2,
- gsize size2)
-{
- gint result;
-
- if (mem1 == mem2 && size1 == size2)
- return 0;
-
- if (!mem1)
- return 1;
- if (!mem2)
- return -1;
-
- result = memcmp (mem1, mem2, MIN (size1, size2));
- if (result != 0)
- return result;
-
- if (size1 == size2)
- return 0;
- if (size1 < size2)
- return -1;
- return 1;
-}
diff --git a/gcr/gcr-comparable.h b/gcr/gcr-comparable.h
deleted file mode 100644
index 8e1fb65..0000000
--- a/gcr/gcr-comparable.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * gnome-keyring
- *
- * Copyright (C) 2010 Stefan Walter
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __GCR_COMPARABLE_H__
-#define __GCR_COMPARABLE_H__
-
-#if !defined (__GCR_INSIDE_HEADER__) && !defined (GCR_COMPILATION)
-#error "Only <gcr/gcr.h> can be included directly."
-#endif
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define GCR_TYPE_COMPARABLE gcr_comparable_get_type ()
-G_DECLARE_INTERFACE (GcrComparable, gcr_comparable, GCR, COMPARABLE, GObject)
-
-struct _GcrComparableInterface {
- GTypeInterface parent;
- gint (*compare) (GcrComparable *self, GcrComparable *other);
-};
-
-gint gcr_comparable_compare (GcrComparable *self,
- GcrComparable *other);
-
-gint gcr_comparable_memcmp (gconstpointer mem1,
- gsize size1,
- gconstpointer mem2,
- gsize size2);
-
-G_END_DECLS
-
-#endif /* __GCR_COMPARABLE_H__ */
diff --git a/gcr/gcr-pkcs11-certificate.c b/gcr/gcr-pkcs11-certificate.c
index db35aba..8c19dca 100644
--- a/gcr/gcr-pkcs11-certificate.c
+++ b/gcr/gcr-pkcs11-certificate.c
@@ -56,7 +56,6 @@ struct _GcrPkcs11CertificatePrivate {
static void gcr_certificate_iface (GcrCertificateIface *iface);
G_DEFINE_TYPE_WITH_CODE (GcrPkcs11Certificate, gcr_pkcs11_certificate, GCK_TYPE_OBJECT,
G_ADD_PRIVATE (GcrPkcs11Certificate);
- GCR_CERTIFICATE_MIXIN_IMPLEMENT_COMPARABLE ();
G_IMPLEMENT_INTERFACE (GCR_TYPE_CERTIFICATE, gcr_certificate_iface);
);
diff --git a/gcr/gcr-simple-certificate.c b/gcr/gcr-simple-certificate.c
index 59bf633..65de22f 100644
--- a/gcr/gcr-simple-certificate.c
+++ b/gcr/gcr-simple-certificate.c
@@ -20,7 +20,6 @@
#include "config.h"
#include "gcr-certificate.h"
-#include "gcr-comparable.h"
#include "gcr-internal.h"
#include "gcr-simple-certificate.h"
@@ -45,7 +44,6 @@ static void gcr_simple_certificate_iface_init (GcrCertificateIface *iface);
G_DEFINE_TYPE_WITH_CODE (GcrSimpleCertificate, gcr_simple_certificate, G_TYPE_OBJECT,
G_ADD_PRIVATE (GcrSimpleCertificate);
- GCR_CERTIFICATE_MIXIN_IMPLEMENT_COMPARABLE ();
G_IMPLEMENT_INTERFACE (GCR_TYPE_CERTIFICATE, gcr_simple_certificate_iface_init);
);
diff --git a/gcr/meson.build b/gcr/meson.build
index 414e5c2..6a1dd74 100644
--- a/gcr/meson.build
+++ b/gcr/meson.build
@@ -5,7 +5,6 @@ gcr_public_sources = files(
'gcr-certificate.c',
'gcr-certificate-chain.c',
'gcr-certificate-request.c',
- 'gcr-comparable.c',
'gcr-fingerprint.c',
'gcr-importer.c',
'gcr-import-interaction.c',
@@ -45,7 +44,6 @@ gcr_headers = files(
'gcr-certificate.h',
'gcr-certificate-chain.h',
'gcr-certificate-request.h',
- 'gcr-comparable.h',
'gcr-fingerprint.h',
'gcr-importer.h',
'gcr-import-interaction.h',
diff --git a/gcr/test-certificate-chain.c b/gcr/test-certificate-chain.c
index 0d8d07f..1b5ebf0 100644
--- a/gcr/test-certificate-chain.c
+++ b/gcr/test-certificate-chain.c
@@ -62,7 +62,6 @@ typedef struct _MockCertificateClass {
static void mock_certificate_iface (GcrCertificateIface *iface);
G_DEFINE_TYPE_WITH_CODE (MockCertificate, mock_certificate, G_TYPE_OBJECT,
- GCR_CERTIFICATE_MIXIN_IMPLEMENT_COMPARABLE ();
G_IMPLEMENT_INTERFACE (GCR_TYPE_CERTIFICATE, mock_certificate_iface);
);