summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon Casey <drafnel@gmail.com>2013-09-23 11:49:17 -0700
committerJunio C Hamano <gitster@pobox.com>2013-10-16 09:35:33 -0700
commit15f7221686eac053902b906c278680b485c865ce (patch)
tree5e1abd2d9f54ad3345dc3a5809588ce79b620b5a
parent5a3db110533b3b58002a03da837aa38fdc4bfc56 (diff)
downloadgit-15f7221686eac053902b906c278680b485c865ce.tar.gz
contrib/git-credential-gnome-keyring.c: support really ancient gnome-keyringbc/gnome-keyring
The gnome-keyring lib (0.4) distributed with RHEL 4.X is really ancient and does not provide most of the synchronous functions that even ancient releases do. Thankfully, we're only using one function that is missing. Let's emulate gnome_keyring_item_delete_sync() by calling the asynchronous function and then triggering the event loop processing until our callback is called. Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--contrib/credential/gnome-keyring/git-credential-gnome-keyring.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c
index e1bc3face4..635c96bc56 100644
--- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c
+++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c
@@ -86,6 +86,45 @@ static const char* gnome_keyring_result_to_message(GnomeKeyringResult result)
}
}
+/*
+ * Support really ancient gnome-keyring, circ. RHEL 4.X.
+ * Just a guess for the Glib version. Glib 2.8 was roughly Gnome 2.12 ?
+ * Which was released with gnome-keyring 0.4.3 ??
+ */
+#if GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 8
+
+static void gnome_keyring_done_cb(GnomeKeyringResult result, gpointer user_data)
+{
+ gpointer *data = (gpointer*) user_data;
+ int *done = (int*) data[0];
+ GnomeKeyringResult *r = (GnomeKeyringResult*) data[1];
+
+ *r = result;
+ *done = 1;
+}
+
+static void wait_for_request_completion(int *done)
+{
+ GMainContext *mc = g_main_context_default();
+ while (!*done)
+ g_main_context_iteration(mc, TRUE);
+}
+
+static GnomeKeyringResult gnome_keyring_item_delete_sync(const char *keyring, guint32 id)
+{
+ int done = 0;
+ GnomeKeyringResult result;
+ gpointer data[] = { &done, &result };
+
+ gnome_keyring_item_delete(keyring, id, gnome_keyring_done_cb, data,
+ NULL);
+
+ wait_for_request_completion(&done);
+
+ return result;
+}
+
+#endif
#endif
/*