[libnma/lr/gcr-gtk4: 10/14] pkcs11: fix support for gcr git snapshot




commit 3c1bad98e723cd1075d1119f64667464ad777c05
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Tue Mar 8 19:08:13 2022 +0100

    pkcs11: fix support for gcr git snapshot
    
    The GCR main branch now seems to have Gtk4 support. Good.
    
    They seem to be somewhat frivolously breaking the API/ABI. As it was
    never guarranteed to be stable, let's just adjust to the changes so we
    can get libnma-gtk4 to build against it sooner rather than later.

 configure.ac                         | 12 ++++++++++--
 meson.build                          | 12 ++++++++++--
 src/nma-cert-chooser-button.c        |  7 ++++++-
 src/nma-pkcs11-cert-chooser-dialog.c | 14 ++++++++++----
 4 files changed, 36 insertions(+), 9 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b2add1eb..caa575c8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -190,13 +190,21 @@ else
                                         gboolean gck_session_login_finish (GckSession *self, GAsyncResult 
*result, GError **error);
                                         GckSlotInfo *gck_slot_get_info (GckSlot *self);
                                         GckTokenInfo *gck_slot_get_token_info (GckSlot *self);
+                                        #if GCR_CHECK_VERSION(3,90,0)
+                                        void gck_slot_open_session_async (GckSlot *self, GckSessionOptions 
options, GTlsInteraction *interaction,
+                                                                          GCancellable *cancellable, 
GAsyncReadyCallback callback,
+                                                                          gpointer user_data);
+                                        gchar *gck_uri_data_build (GckUriData *uri_data, GckUriFlags flags);
+                                        GckUriData *gck_uri_data_parse (const gchar *string, GckUriFlags 
flags, GError **error);
+                                        #else
                                         void gck_slot_open_session_async (GckSlot *self, GckSessionOptions 
options, GCancellable *cancellable,
                                                                           GAsyncReadyCallback callback, 
gpointer user_data);
+                                        gchar *gck_uri_build (GckUriData *uri_data, GckUriFlags flags);
+                                        GckUriData *gck_uri_parse (const gchar *string, GckUriFlags flags, 
GError **error);
+                                        #endif
                                         GckSession *gck_slot_open_session_finish (GckSlot *self, 
GAsyncResult *result, GError **error);
                                         void gck_token_info_free (GckTokenInfo *token_info);
-                                        gchar *gck_uri_build (GckUriData *uri_data, GckUriFlags flags);
                                         void gck_uri_data_free (GckUriData *uri_data);
-                                        GckUriData *gck_uri_parse (const gchar *string, GckUriFlags flags, 
GError **error);
                                         gchar *gcr_certificate_get_issuer_name (GcrCertificate *self);
                                         gchar *gcr_certificate_get_subject_name (GcrCertificate *self);
                                         GcrCertificate *gcr_simple_certificate_new (const guchar *data, 
gsize n_data);
diff --git a/meson.build b/meson.build
index befa0f20..2386b65d 100644
--- a/meson.build
+++ b/meson.build
@@ -240,13 +240,21 @@ if enable_gcr
     gboolean gck_session_login_finish (GckSession *self, GAsyncResult *result, GError **error);
     GckSlotInfo *gck_slot_get_info (GckSlot *self);
     GckTokenInfo *gck_slot_get_token_info (GckSlot *self);
+    #if GCR_CHECK_VERSION(3,90,0)
+    void gck_slot_open_session_async (GckSlot *self, GckSessionOptions options, GTlsInteraction *interaction,
+                                      GCancellable *cancellable, GAsyncReadyCallback callback,
+                                      gpointer user_data);
+    gchar *gck_uri_data_build (GckUriData *uri_data, GckUriFlags flags);
+    GckUriData *gck_uri_data_parse (const gchar *string, GckUriFlags flags, GError **error);
+    #else
     void gck_slot_open_session_async (GckSlot *self, GckSessionOptions options, GCancellable *cancellable,
                                       GAsyncReadyCallback callback, gpointer user_data);
+    gchar *gck_uri_build (GckUriData *uri_data, GckUriFlags flags);
+    GckUriData *gck_uri_parse (const gchar *string, GckUriFlags flags, GError **error);
+    #endif
     GckSession *gck_slot_open_session_finish (GckSlot *self, GAsyncResult *result, GError **error);
     void gck_token_info_free (GckTokenInfo *token_info);
-    gchar *gck_uri_build (GckUriData *uri_data, GckUriFlags flags);
     void gck_uri_data_free (GckUriData *uri_data);
-    GckUriData *gck_uri_parse (const gchar *string, GckUriFlags flags, GError **error);
     gchar *gcr_certificate_get_issuer_name (GcrCertificate *self);
     gchar *gcr_certificate_get_subject_name (GcrCertificate *self);
     GcrCertificate *gcr_simple_certificate_new (const guchar *data, gsize n_data);
diff --git a/src/nma-cert-chooser-button.c b/src/nma-cert-chooser-button.c
index 633985d8..c5f25d7a 100644
--- a/src/nma-cert-chooser-button.c
+++ b/src/nma-cert-chooser-button.c
@@ -15,6 +15,11 @@
 #if GTK_CHECK_VERSION(4,0,0) ? WITH_GCR_GTK4 : WITH_GCR
 #include "nma-pkcs11-cert-chooser-dialog.h"
 #include <gck/gck.h>
+#include <gcr/gcr.h>   // FIXME: Only here to detect GCK version
+                       // Remove once new GCK is released with version bumped
+#if !GCR_CHECK_VERSION(3,90,0)
+#define gck_uri_data_parse gck_uri_parse
+#endif
 #endif
 
 /**
@@ -165,7 +170,7 @@ title_from_pkcs11 (NMACertChooserButton *button)
        char *label = NULL;
        GckUriData *data;
 
-       data = gck_uri_parse (priv->uri, GCK_URI_FOR_ANY, &error);
+       data = gck_uri_data_parse (priv->uri, GCK_URI_FOR_ANY, &error);
        if (data) {
                if (!gck_attributes_find_string (data->attributes, CKA_LABEL, &label)) {
                        if (data->token_info) {
diff --git a/src/nma-pkcs11-cert-chooser-dialog.c b/src/nma-pkcs11-cert-chooser-dialog.c
index 2ec2ce1c..af8c8857 100644
--- a/src/nma-pkcs11-cert-chooser-dialog.c
+++ b/src/nma-pkcs11-cert-chooser-dialog.c
@@ -16,6 +16,12 @@
 #include <gck/gck.h>
 #include <gcr/gcr.h>
 
+#if !GCR_CHECK_VERSION(3,90,0)
+#define gck_slot_open_session_async(self, options, interaction, cancellable, callback, user_data) \
+       gck_slot_open_session_async(self, options, cancellable, callback, user_data)
+#define gck_uri_data_build gck_uri_build
+#endif
+
 /**
  * SECTION:nma-pkcs11-cert-chooser-dialog
  * @title: NMAPkcs11CertChooserDialog
@@ -343,7 +349,7 @@ login_clicked (GtkButton *button, gpointer user_data)
                priv->pin_length = 0;
                priv->pin_value =  g_memdup ("", 1);
                priv->remember_pin = TRUE;
-               gck_slot_open_session_async (priv->slot, GCK_SESSION_READ_ONLY, NULL, session_opened, self);
+               gck_slot_open_session_async (priv->slot, GCK_SESSION_READ_ONLY, NULL, NULL, session_opened, 
self);
                return;
        }
 
@@ -357,7 +363,7 @@ login_clicked (GtkButton *button, gpointer user_data)
                priv->pin_value = g_memdup (nma_pkcs11_token_login_dialog_get_pin_value 
(NMA_PKCS11_TOKEN_LOGIN_DIALOG (dialog)),
                                            priv->pin_length + 1);
                priv->remember_pin = nma_pkcs11_token_login_dialog_get_remember_pin 
(NMA_PKCS11_TOKEN_LOGIN_DIALOG (dialog));
-               gck_slot_open_session_async (priv->slot, GCK_SESSION_READ_ONLY, NULL, session_opened, self);
+               gck_slot_open_session_async (priv->slot, GCK_SESSION_READ_ONLY, NULL, NULL, session_opened, 
self);
        }
 
        gtk_window_destroy (GTK_WINDOW (dialog));
@@ -394,7 +400,7 @@ set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *p
                if ((token_info->flags & CKF_LOGIN_REQUIRED) == 0)
                        gtk_widget_set_sensitive (priv->login_button, FALSE);
                gck_token_info_free (token_info);
-               gck_slot_open_session_async (priv->slot, GCK_SESSION_READ_ONLY, NULL, session_opened, self);
+               gck_slot_open_session_async (priv->slot, GCK_SESSION_READ_ONLY, NULL, NULL, session_opened, 
self);
                break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -573,7 +579,7 @@ nma_pkcs11_cert_chooser_dialog_get_uri (NMAPkcs11CertChooserDialog *dialog)
 
        uri_data.attributes = gck_builder_end (builder);
        uri_data.token_info = gck_slot_get_token_info (priv->slot);
-       uri = gck_uri_build (&uri_data, GCK_URI_FOR_OBJECT_ON_TOKEN);
+       uri = gck_uri_data_build (&uri_data, GCK_URI_FOR_OBJECT_ON_TOKEN);
 
        gck_attributes_unref (uri_data.attributes);
        gck_attributes_unref (attrs);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]