Skip to content

Commit 15f7221

Browse files
drafnelgitster
authored andcommitted
contrib/git-credential-gnome-keyring.c: support really ancient 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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5a3db11 commit 15f7221

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

contrib/credential/gnome-keyring/git-credential-gnome-keyring.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,45 @@ static const char* gnome_keyring_result_to_message(GnomeKeyringResult result)
8686
}
8787
}
8888

89+
/*
90+
* Support really ancient gnome-keyring, circ. RHEL 4.X.
91+
* Just a guess for the Glib version. Glib 2.8 was roughly Gnome 2.12 ?
92+
* Which was released with gnome-keyring 0.4.3 ??
93+
*/
94+
#if GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 8
95+
96+
static void gnome_keyring_done_cb(GnomeKeyringResult result, gpointer user_data)
97+
{
98+
gpointer *data = (gpointer*) user_data;
99+
int *done = (int*) data[0];
100+
GnomeKeyringResult *r = (GnomeKeyringResult*) data[1];
101+
102+
*r = result;
103+
*done = 1;
104+
}
105+
106+
static void wait_for_request_completion(int *done)
107+
{
108+
GMainContext *mc = g_main_context_default();
109+
while (!*done)
110+
g_main_context_iteration(mc, TRUE);
111+
}
112+
113+
static GnomeKeyringResult gnome_keyring_item_delete_sync(const char *keyring, guint32 id)
114+
{
115+
int done = 0;
116+
GnomeKeyringResult result;
117+
gpointer data[] = { &done, &result };
118+
119+
gnome_keyring_item_delete(keyring, id, gnome_keyring_done_cb, data,
120+
NULL);
121+
122+
wait_for_request_completion(&done);
123+
124+
return result;
125+
}
126+
127+
#endif
89128
#endif
90129

91130
/*

0 commit comments

Comments
 (0)