diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2014-04-21 09:42:53 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2014-04-21 09:42:53 +0000 |
commit | 1a0a35b8f463cf73b6cc3808b6b9ec35deadfb70 (patch) | |
tree | da5b5a061e1ffc1a665b086828ab9ca901e72798 /src/passphrase.c | |
parent | d696272192e69a7c7c48fd8686886d3c00b1d40c (diff) |
use gpgme_io_writen() if available (fixes freeze when entering passphrase on Windows).
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@3392 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src/passphrase.c')
-rw-r--r-- | src/passphrase.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/passphrase.c b/src/passphrase.c index f0630888..20447c14 100644 --- a/src/passphrase.c +++ b/src/passphrase.c @@ -285,13 +285,16 @@ gpgmegtk_passphrase_cb(void *opaque, const char *uid_hint, const char *passphrase_hint, int prev_bad, int fd) { const char *pass; -#ifdef G_OS_WIN32 +#if defined(G_OS_WIN32) && !defined(HAVE_GPGME_IO_WRITEN) HANDLE hd = (HANDLE)fd; DWORD n; #endif if (prefs_common.store_passphrase && last_pass != NULL && !prev_bad) { -#ifdef G_OS_WIN32 +#ifdef HAVE_GPGME_IO_WRITEN + gpgme_io_writen(fd, last_pass, strlen(last_pass)); + gpgme_io_writen(fd, "\n", 1); +#elif defined(G_OS_WIN32) WriteFile(hd, last_pass, strlen(last_pass), &n, NULL); WriteFile(hd, "\n", 1, &n, NULL); #else @@ -306,7 +309,9 @@ gpgmegtk_passphrase_cb(void *opaque, const char *uid_hint, gpgmegtk_free_passphrase(); if (!pass) { debug_print ("%% cancel passphrase entry\n"); -#ifdef G_OS_WIN32 +#ifdef HAVE_GPGME_IO_WRITEN + gpgme_io_writen(fd, "\n", 1); +#elif defined(G_OS_WIN32) WriteFile(hd, "\n", 1, &n, NULL); CloseHandle(hd); /* somehow it will block without this */ #else @@ -328,7 +333,10 @@ gpgmegtk_passphrase_cb(void *opaque, const char *uid_hint, } debug_print ("%% sending passphrase\n"); } -#ifdef G_OS_WIN32 +#ifdef HAVE_GPGME_IO_WRITEN + gpgme_io_writen(fd, pass, strlen(pass)); + gpgme_io_writen(fd, "\n", 1); +#elif defined(G_OS_WIN32) WriteFile(hd, pass, strlen(pass), &n, NULL); WriteFile(hd, "\n", 1, &n, NULL); #else |