aboutsummaryrefslogtreecommitdiffstats
path: root/g10/photoid.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2019-05-17 10:31:11 +0000
committerWerner Koch <[email protected]>2019-05-17 10:47:13 +0000
commit7e5847da0f3d715cb59d05adcd9107b460b6411b (patch)
treed76a31b021d2cd0fa25111e3fba2eef90357c362 /g10/photoid.c
parentkbx: Fix an endless loop under Windows due to an incomplete fix. (diff)
downloadgnupg-7e5847da0f3d715cb59d05adcd9107b460b6411b.tar.gz
gnupg-7e5847da0f3d715cb59d05adcd9107b460b6411b.zip
gpg: Improve the photo image viewer selection.
* g10/exec.c (w32_system): Add "!ShellExecute" special. * g10/photoid.c (get_default_photo_command): Use the new ShellExecute under Windows and fallbac to 'display' and 'xdg-open' in the Unix case. (show_photos): Flush stdout so that the output is shown before the image pops up. -- For Unix this basically syncs the code with what we have in gpg 1.4. Note that xdg-open may not be used when running as root which we support here. For Windows we now use ShellExecute as this seems to be preferred over "cmd /c start"; however this does not solve the actual problem we had in the bug report. To solve that problem we resort to a wait parameter which defaults to 400ms. This works on my Windows-10 virtualized test box. If we can figure out which simple viewers are commonly installed on Windows we should enhance this patch to test for them. GnuPG-bug-id: 4334 Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/photoid.c')
-rw-r--r--g10/photoid.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/g10/photoid.c b/g10/photoid.c
index bcea64fbf..f9720d329 100644
--- a/g10/photoid.c
+++ b/g10/photoid.c
@@ -262,7 +262,8 @@ char *image_type_to_string(byte type,int style)
}
#if !defined(FIXED_PHOTO_VIEWER) && !defined(DISABLE_PHOTO_VIEWER)
-static const char *get_default_photo_command(void)
+static const char *
+get_default_photo_command(void)
{
#if defined(_WIN32)
OSVERSIONINFO osvi;
@@ -274,14 +275,21 @@ static const char *get_default_photo_command(void)
if(osvi.dwPlatformId==VER_PLATFORM_WIN32_WINDOWS)
return "start /w %i";
else
- return "cmd /c start /w %i";
+ return "!ShellExecute 400 %i";
#elif defined(__APPLE__)
/* OS X. This really needs more than just __APPLE__. */
return "open %I";
#elif defined(__riscos__)
return "Filer_Run %I";
#else
- return "xloadimage -fork -quiet -title 'KeyID 0x%k' stdin";
+ if (!path_access ("xloadimage", X_OK))
+ return "xloadimage -fork -quiet -title 'KeyID 0x%k' stdin";
+ else if (!path_access ("display",X_OK))
+ return "display -title 'KeyID 0x%k' %i";
+ else if (getuid () && !path_access ("xdg-open", X_OK))
+ return "xdg-open %i";
+ else
+ return "/bin/true";
#endif
}
#endif
@@ -312,6 +320,8 @@ show_photos (ctrl_t ctrl, const struct user_attribute *attrs, int count,
if (pk)
keyid_from_pk (pk, kid);
+ es_fflush (es_stdout);
+
for(i=0;i<count;i++)
if(attrs[i].type==ATTRIB_IMAGE &&
parse_image_header(&attrs[i],&args.imagetype,&len))