[Gpg4win-commits] [git] Gpg4win - branch, master, updated. gpg4win-2.3.0-100-gb5ee6db

by Andre Heinecke cvs at cvs.gnupg.org
Mon Feb 29 15:01:49 CET 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG for Windows".

The branch, master has been updated
       via  b5ee6db6017547777c8178185e3e750b91757968 (commit)
       via  ef794973d575fa63dbe916605478fb46d45ef76c (commit)
      from  6582329a5227cef1a160047ab416b7899cdcb13d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b5ee6db6017547777c8178185e3e750b91757968
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Feb 29 14:52:11 2016 +0100

    Switch to MUI2 and add Run after Install
    
    MUI2 gives more flexibility in customizing pages.
    
    * src/installer-options.ini.in: Removed.
    * src/Makefile.am (installer-options.ini.in): Remove mentions.
     (g4wihelp.dll): Link with desktopshellrun.cpp
    * src/g4wihelp.c: Fix implicit stdio usages.
    * src/gpg4win-src.nsi, src/gpg4win.nsi (ABOUT_STR): MUI2 needs
      $\r$\n everywere.
      (Sections): Include Sections and Memento header.
      (installer.nsi): Include after sections.
    * src/inst-sections.nsi, src/installer.nsi: Move generic functions
     into installer.nsi
    * src/installer.nsi (FinishFunction): New. Conditional show run with
     correct Cert Manager. If not source installer.
      (RunAsUser): New. Use DesktopShellRun.
      (LICENSE_PAGE): Commented out.
      (MUI_UNIFINISHPAGE): Commented out.
    
    --
    
    The finish page now shows a Run GPA or Run Kleopatra depending
    on wether or not they are selected. If none is selected nothing
    is offered.
    
    License and finish page for uninstaller and source installer removed.

diff --git a/src/Makefile.am b/src/Makefile.am
index 0c92cc6..a1dc553 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -19,8 +19,9 @@
 
 EXTRA_DIST = pkg-config gpg4win.nsi gpg4win-src.nsi \
 	config.site config.nsi.in \
-        installer-options.ini.in libiconv.def libintl.def loreley.mid \
-        gpg4win-splash.wav exdll.h g4wihelp.c g4wihelp.nsi \
+        libiconv.def libintl.def loreley.mid \
+        gpg4win-splash.wav exdll.h g4wihelp.c desktopshellrun.cpp \
+        g4wihelp.nsi \
         inst-sections.nsi installer.nsi installer-finish.nsi  \
 	zlib.pc sha1sum.c mkportable.c     \
 	mkportable-vanilla.h mkportable-light.h mkportable-full.h \
@@ -97,10 +98,10 @@ HOWTO_files = $(addsuffix .txt, \
 foosum_exe = sha1sum.exe md5sum.exe sha256sum.exe mkportable.exe
 
 # Need to clean the dll because we bypassed automake.
-CLEANFILES = g4wihelp.dll versioninfo.txt $(README_files) $(HOWTO_files) \
-             installer-options.ini NEWS.tmp COMPONENTS-list.tmp \
-	     license.blurb cdversioninfo.tmp \
-	     $(foosum_exe)
+CLEANFILES = g4wihelp.dll desktopshellrun.o versioninfo.txt $(README_files) \
+			 $(HOWTO_files) NEWS.tmp COMPONENTS-list.tmp \
+			 license.blurb cdversioninfo.tmp \
+			 $(foosum_exe)
 
 # Supported source packages.
 gpg4win_spkgs = glib libffi gdk-pixbuf gtk+ \
@@ -538,10 +539,6 @@ COMPONENTS-list.tmp : $(top_srcdir)/NEWS
 	awk '/^~~~~~~~~~~~/ { ok++; next} ok==1 {print "    "$$0}' \
             < $(top_srcdir)/NEWS > COMPONENTS-list.tmp
 
-installer-options.ini : $(top_srcdir)/src/installer-options.ini.in
-	cat $(top_srcdir)/src/installer-options.ini.in >installer-options.ini
-
-
 # For some nut-crazy reason someone thought it would be a great idea
 # if makensis changed to the directory of the source file at startup.
 # So we have to pull a couple of strings to correct this.
@@ -549,7 +546,7 @@ installers/gpg4win-$(VERSION).exe: gpg4win.nsi $(common_nsi) stamps/stamp-final
                         g4wihelp.dll \
 		        $(foosum_exe) \
 			$(README_files) $(HOWTO_files) \
-	                license.blurb installer-options.ini versioninfo.txt
+	                license.blurb versioninfo.txt
 	$(MAKENSIS) -V3 -DBUILD_DIR=`pwd` -DTOP_SRCDIR=$(top_srcdir) \
            -DSRCDIR=$(srcdir) $(EXTRA_MAKENSIS_FLAGS) $(srcdir)/gpg4win.nsi && \
 		   mv gpg4win-$(VERSION).exe installers/gpg4win-$(VERSION).exe
@@ -558,7 +555,7 @@ installers/gpg4win-light-$(VERSION).exe: gpg4win.nsi $(common_nsi) stamps/stamp-
                         g4wihelp.dll \
 		        $(foosum_exe) \
 			$(README_files) $(HOWTO_files) \
-			license.blurb installer-options.ini versioninfo.txt
+			license.blurb versioninfo.txt
 	$(MAKENSIS) -V3 -DBUILD_DIR=`pwd` -DTOP_SRCDIR=$(top_srcdir) \
            -DSRCDIR=$(srcdir) $(EXTRA_MAKENSIS_FLAGS) \
            -DGPG4WIN_LIGHT=1 $(srcdir)/gpg4win.nsi && \
@@ -569,7 +566,7 @@ installers/gpg4win-vanilla-$(VERSION).exe: gpg4win.nsi $(common_nsi) stamps/stam
                         g4wihelp.dll  \
 		        $(foosum_exe) \
 			$(README_files) $(HOWTO_files) \
-		        license.blurb installer-options.ini versioninfo.txt
+		        license.blurb versioninfo.txt
 	$(MAKENSIS) -V3 -DBUILD_DIR=`pwd` -DTOP_SRCDIR=$(top_srcdir) \
            -DSRCDIR=$(srcdir) $(EXTRA_MAKENSIS_FLAGS) \
            -DGPG4WIN_VANILLA=1 $(srcdir)/gpg4win.nsi && \
@@ -622,9 +619,11 @@ installers/gpg4win-src-$(VERSION).exe: gpg4win-src.nsi $(common_nsii) \
 license.blurb: $(top_srcdir)/doc/license-page $(top_srcdir)/doc/GPLv3
 	cat $(top_srcdir)/doc/license-page $(top_srcdir)/doc/GPLv3 >$@
 
-g4wihelp.dll: g4wihelp.c exdll.h
+g4wihelp.dll: desktopshellrun.cpp g4wihelp.c exdll.h
+	$(CC) -I. -O2 -c -o desktopshellrun.o $(srcdir)/desktopshellrun.cpp
 	$(CC) -I. -shared -O2 -o g4wihelp.dll $(srcdir)/g4wihelp.c \
-	   -lwinmm -lgdi32
+	  desktopshellrun.o -lwinmm -lgdi32 -luserenv -lshell32 \
+	  -lole32 -loleaut32
 	$(STRIP) g4wihelp.dll
 
 sha1sum.exe: sha1sum.c
diff --git a/src/g4wihelp.c b/src/g4wihelp.c
index 204256d..7cb0679 100644
--- a/src/g4wihelp.c
+++ b/src/g4wihelp.c
@@ -29,6 +29,7 @@
  */
 
 #include <windows.h>
+#include <stdio.h>
 #include "exdll.h"
 
 static HINSTANCE g_hInstance; /* Our Instance. */
diff --git a/src/gpg4win-src.nsi b/src/gpg4win-src.nsi
index f7842b8..e614e7c 100644
--- a/src/gpg4win-src.nsi
+++ b/src/gpg4win-src.nsi
@@ -46,15 +46,27 @@
 !define WELCOME_TITLE_STR "$(T_WelcomeTitleGpg4winSrc)"
 
 !define ABOUT_STR "$(T_AboutGpg4winSrc) \
-	\r\n\r\n$_CLICK \r\n\r\n\r\n\r\n\r\n \
-        $(T_AboutGpg4winSrcVersion) \r\n \
-        $(T_AboutGpg4winSrcFileVersion) \r\n\r\n \
+	$\r$\n$\r$\n$_CLICK $\r$\n$\r$\n$\r$\n$\r$\n$\r$\n \
+        $(T_AboutGpg4winSrcVersion) $\r$\n \
+        $(T_AboutGpg4winSrcFileVersion) $\r$\n$\r$\n \
         $(T_AboutGpg4winSrcReleaseDate)"
 
 # The copyright license of the package.  Define only one of these.
 !define LICENSE_GPL
 # !define LICENSE_LGPL
 
+# Sections
+!include "Sections.nsh"
+
+# We use Memento to remember past installation choices.
+!include Memento.nsh
+!define MEMENTO_REGISTRY_ROOT HKLM
+!define MEMENTO_REGISTRY_KEY \
+  Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRETTY_PACKAGE_SHORT}
+# We need to know wether we are installing to 64 bit.
+!include "x64.nsh"
+
+
 
 # The installation directory.
 !define ipdir "playground/install/pkgs"
@@ -64,15 +76,13 @@
 # For source packages we use the standard zip method because it takes
 # ages to compress a large archive of already packed sources.
 SetCompressor zlib
-
-# Now include the generic parts.
-!include "installer.nsi"
-
-
 # Now include all the sections.
 !define SOURCES
 !include "inst-sections.nsi"
 
+# Now include the generic parts.
+!include "installer.nsi"
+
 # The WelcomeTitle is displayed on the first page.
 LangString T_WelcomeTitleGpg4winSrc ${LANG_ENGLISH} \
  "Welcome to the installation of the Gpg4win sources"
diff --git a/src/gpg4win.nsi b/src/gpg4win.nsi
index 0146157..2e22591 100644
--- a/src/gpg4win.nsi
+++ b/src/gpg4win.nsi
@@ -129,10 +129,8 @@
 !define WELCOME_TITLE_STR "$(T_WelcomeTitleGpg4win)"
 
 !define ABOUT_STR "$(T_AboutGpg4win) \
-	\r\n\r\n$_CLICK \r\n\r\n\r\n\r\n\r\n \
-	$(T_AboutGpg4winVersion) \r\n \
-        $(T_AboutGpg4winFileVersion) \r\n\r\n \
-	$(T_AboutGpg4winReleaseDate)"
+	$\r$\n$\r$\n$\r$\n$_CLICK $\r$\n$\r$\n$\r$\n \
+	$(T_AboutGpg4winVersion $\r$\n$(T_AboutGpg4winReleaseDate)"
 
 # The copyright license of the package.  Define only one of these.
 !define LICENSE_GPL
@@ -179,15 +177,24 @@ SetCompressor /SOLID lzma
 !include "uninst-claws-mail.nsi"
 !endif
 
-# Now include the generic parts.
-!define HAVE_STARTMENU
-!include "installer.nsi"
+# Sections
+!include "Sections.nsh"
 
+# We use Memento to remember past installation choices.
+!include Memento.nsh
+!define MEMENTO_REGISTRY_ROOT HKLM
+!define MEMENTO_REGISTRY_KEY \
+  Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRETTY_PACKAGE_SHORT}
+# We need to know wether we are installing to 64 bit.
+!include "x64.nsh"
 
 # Now include the sections.
 !define BINARIES
 !include "inst-sections.nsi"
 
+# Now include the generic parts.
+!define HAVE_STARTMENU
+!include "installer.nsi"
 
 # The WelcomeTitle is displayed on the first page.
 LangString T_WelcomeTitleGpg4win ${LANG_ENGLISH} \
diff --git a/src/inst-sections.nsi b/src/inst-sections.nsi
index 2f3c5db..5972bdc 100644
--- a/src/inst-sections.nsi
+++ b/src/inst-sections.nsi
@@ -16,9 +16,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-
-# Sections
-
 !include "inst-gpg4win.nsi"
 
 # The order of installation must be the same as the build order.  You
@@ -394,27 +391,8 @@
 
 ${MementoSectionDone}
 
-!include "Sections.nsh"
-
-
 Function CalcDefaults
 
-# The defaults for the installer-options.ini file.
-g4wihelp::config_fetch_bool "inst_start_menu"
-StrCmp $R0 "" +2
-!insertmacro MUI_INSTALLOPTIONS_WRITE "installer-options.ini" \
-	"Field 2" "State" $R0
-
-g4wihelp::config_fetch_bool "inst_desktop"
-StrCmp $R0 "" +2
-!insertmacro MUI_INSTALLOPTIONS_WRITE "installer-options.ini" \
-	"Field 3" "State" $R0
-
-g4wihelp::config_fetch_bool "inst_quick_launch_bar"
-StrCmp $R0 "" +2
-!insertmacro MUI_INSTALLOPTIONS_WRITE "installer-options.ini" \
-	"Field 4" "State" $R0
-
 !ifdef HAVE_PKG_KLEOPATRA
   g4wihelp::config_fetch_bool "inst_kleopatra"
   StrCmp $R0 "1" 0 calc_defaults_kleopatra_not_one
@@ -934,49 +912,6 @@ Function CalcDepends
 
 FunctionEnd
 
-
-Function .onInit
-  Call G4wRunOnce
-
-  SetOutPath $TEMP
-!ifdef SOURCES
-  File /oname=gpgspltmp.bmp "${TOP_SRCDIR}/doc/logo/gpg4win-logo-400px.bmp"
-  # We play the tune only for the source installer
-  File /oname=gpgspltmp.wav "${TOP_SRCDIR}/src/gpg4win-splash.wav"
-  g4wihelp::playsound $TEMP\gpgspltmp.wav
-  g4wihelp::showsplash 2500 $TEMP\gpgspltmp.bmp
-
-  Delete $TEMP\gpgspltmp.bmp
-  # Note that we delete gpgspltmp.wav in .onInst{Failed,Success}
-!endif
-
-  # Enable this to force a language selection dialog on every run (the
-  # preferred language is the default).  Otherwise, the preferred
-  # language is stored in the registry, and the installer does not ask
-  # on upgrades.
-!ifdef DEBUG
-!define MUI_LANGDLL_ALWAYSSHOW
-!endif
-  !insertmacro MUI_LANGDLL_DISPLAY
-
-  # We can't use TOP_SRCDIR dir as the name of the file needs to be
-  # the same while building and running the installer.  Thus we
-  # generate the file from a template.
-  !insertmacro MUI_INSTALLOPTIONS_EXTRACT "installer-options.ini"
-
-  ${MementoSectionRestore}
-  Call CalcDefaults
-  Call CalcDepends
-  Call CheckOtherGnuPGApps
-FunctionEnd
-
-
-Function un.onInit
-  # Remove the language preference.
-  !insertmacro MUI_UNGETLANGUAGE
-FunctionEnd
-
-
 Function .onInstFailed
   Delete $TEMP\gpgspltmp.wav
 FunctionEnd
@@ -1006,44 +941,6 @@ FunctionEnd
 #FunctionEnd
 
 
-# This must be in a central place.  Urgs.
-
-!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
-!ifdef HAVE_PKG_GNUPG_W32
-  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_gnupg_w32} $(DESC_SEC_gnupg_w32)
-!endif
-!ifdef HAVE_PKG_GPGOL
-  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_gpgol} $(DESC_SEC_gpgol)
-!endif
-!ifdef HAVE_PKG_GPGEX
-  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_gpgex} $(DESC_SEC_gpgex)
-!endif
-!ifdef HAVE_PKG_PAPERKEY
-  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_paperkey} $(DESC_SEC_paperkey)
-!endif
-!ifdef HAVE_PKG_GPA
-  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_gpa} $(DESC_SEC_gpa)
-!endif
-!ifdef HAVE_PKG_KLEOPATRA
-  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_kleopatra} $(DESC_SEC_kleopatra)
-!endif
-!ifdef HAVE_PKG_MAN_NOVICE_EN
-  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_man_novice_en} $(DESC_SEC_man_novice_en)
-!endif
-!ifdef HAVE_PKG_MAN_ADVANCED_EN
-  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_man_advanced_en} $(DESC_SEC_man_advanced_en)
-!endif
-!ifdef HAVE_PKG_COMPENDIUM
-  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_compendium} $(DESC_SEC_compendium)
-!endif
-!ifdef HAVE_PKG_MAN_NOVICE_DE
-  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_man_novice_de} $(DESC_SEC_man_novice_de)
-!endif
-!ifdef HAVE_PKG_MAN_ADVANCED_DE
-  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_man_advanced_de} $(DESC_SEC_man_advanced_de)
-!endif
-!insertmacro MUI_FUNCTION_DESCRIPTION_END
-
 
 # This also must be in a central place.  Also Urgs.
 
@@ -1059,9 +956,8 @@ Section "-startmenu"
   SetShellVarContext all
 
   # Check if the start menu entries where requested.
-  !insertmacro MUI_INSTALLOPTIONS_READ $R0 "installer-options.ini" \
-	"Field 2" "State"
-  IntCmp $R0 0 no_start_menu
+  g4wihelp::config_fetch_bool "inst_start_menu"
+  StrCmp $R0 "0" no_start_menu
 
 !ifdef HAVE_PKG_GPA
     SectionGetFlags ${SEC_gpa} $R0
@@ -1086,8 +982,8 @@ Section "-startmenu"
  no_start_menu:
 
   # Check if the desktop entries where requested.
-  !insertmacro MUI_INSTALLOPTIONS_READ $R0 "installer-options.ini" \
-	"Field 3" "State"
+  g4wihelp::config_fetch_bool "inst_desktop"
+  StrCmp $R0 "0" no_desktop
   IntCmp $R0 0 no_desktop
 
 !ifdef HAVE_PKG_GPA
diff --git a/src/installer-options.ini.in b/src/installer-options.ini.in
deleted file mode 100644
index 29797c7..0000000
--- a/src/installer-options.ini.in
+++ /dev/null
@@ -1,47 +0,0 @@
-[Settings]
-NumFields=5
-
-; The number of the fields here is known in installer.nsi.
-; The tags must be "[Field N]" with N=1..NumFields
-
-[Field 1]
-Type=Label
-Left=0
-Right=-1
-Top=0
-Bottom=20
-
-[Field 2]
-Type=Checkbox
-Left=0
-Right=-1
-Top=30
-Bottom=40
-;Text=Start Menu
-State=1
-
-[Field 3]
-Type=Checkbox
-Left=0
-Right=-1
-Top=50
-Bottom=60
-;Text=Desktop
-State=0
-
-[Field 4]
-Type=Checkbox
-Left=0
-Right=-1
-Top=70
-Bottom=80
-;Text=Quick Launch Bar
-State=0
-
-[Field 5]
-Type=Label
-Left=0
-Right=-1
-Top=90
-Bottom=130
-
diff --git a/src/installer.nsi b/src/installer.nsi
index 62f350b..fdc4298 100644
--- a/src/installer.nsi
+++ b/src/installer.nsi
@@ -39,18 +39,14 @@
 # !define Regkey_for_Env 'HKCU "Environment"'
 
 
-# We use Memento to remember past installation choices.
-!include Memento.nsh
-!define MEMENTO_REGISTRY_ROOT HKLM
-!define MEMENTO_REGISTRY_KEY \
-  Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRETTY_PACKAGE_SHORT}
-
-
-# We use the modern UI.
-!include "MUI.nsh"
-
-# We need to know wether we are installing to 64 bit.
-!include "x64.nsh"
+# We use the modern UI 2.
+!ifdef DEBUG
+!include "MUI2.nsh"
+!else
+!include "MUI2.nsh"
+# MUI2 defines debug
+!undef DEBUG
+!endif
 
 # Set the package name.  Note that this name should not be sufficed
 #  with the version because this would get displayed in the start menu.
@@ -147,10 +143,9 @@ Bitte die Sprache des Installations-Vorgangs angeben."
 
 !insertmacro MUI_PAGE_WELCOME
 
-!define MUI_LICENSEPAGE_BUTTON "$(^NextBtn)"
-!define MUI_PAGE_HEADER_SUBTEXT "$(T_GPLHeader)"
-!define MUI_LICENSEPAGE_TEXT_BOTTOM "$(T_GPLShort)"
-!insertmacro MUI_PAGE_LICENSE "license.blurb"
+#!define MUI_LICENSEPAGE_BUTTON "$(^NextBtn)"
+#!define MUI_PAGE_HEADER_SUBTEXT "$(T_GPLHeader)"
+#!insertmacro MUI_PAGE_LICENSE "license.blurb"
 
 !define MUI_PAGE_CUSTOMFUNCTION_SHOW PrintNonAdminWarning
 !insertmacro MUI_PAGE_COMPONENTS
@@ -163,23 +158,60 @@ Bitte die Sprache des Installations-Vorgangs angeben."
 !define MUI_PAGE_CUSTOMFUNCTION_PRE ShowFinalWarnings
 
 # Finish page
+!ifndef SOURCES
+!define MUI_PAGE_CUSTOMFUNCTION_SHOW FinishFunction
+!define MUI_FINISHPAGE_RUN
+!define MUI_FINISHPAGE_RUN_FUNCTION RunAsUser
 !define MUI_FINISHPAGE_SHOWREADME "share\gpg4win\README.$(T_LangCode).txt"
 !define MUI_FINISHPAGE_SHOWREADME_TEXT "$(T_ShowReadme)"
-#!define MUI_FINISHPAGE_RUN
-#!define MUI_FINISHPAGE_RUN_FUNCTION RunOnFinish
-#!define MUI_FINISHPAGE_RUN_TEXT "$(T_RunKeyManager)"
-#!define MUI_FINISHPAGE_RUN_NOTCHECKED
+!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
 !define MUI_FINISHPAGE_LINK "$(T_MoreInfo)"
 !define MUI_FINISHPAGE_LINK_LOCATION "$(T_MoreInfoURL)"
 !insertmacro MUI_PAGE_FINISH
 
+Function FinishFunction
+  IfSilent leave
+  Var /GLOBAL gpa_or_kleopatra
+  !insertmacro SectionFlagIsSet ${SEC_kleopatra} \
+        ${SF_SELECTED} have_kleo 0
+  !insertmacro SectionFlagIsSet ${SEC_gpa} \
+        ${SF_SELECTED} have_gpa 0
+  ShowWindow $mui.FinishPage.Run ${SW_HIDE}
+  goto leave
+have_kleo:
+  SendMessage $mui.FinishPage.Run.Text ${WM_SETTEXT} 0 "STR:$(T_RunKleopatra)"
+  goto leave
+have_gpa:
+  SendMessage $mui.FinishPage.Run.Text ${WM_SETTEXT} 0 "STR:$(T_RunGPA)"
+  StrCpy $gpa_or_kleopatra "GPA"
+leave:
+FunctionEnd
+
+Function RunAsUser
+  !insertmacro SectionFlagIsSet ${SEC_kleopatra} \
+        ${SF_SELECTED} 0 skip_kleo
+  g4wihelp::DesktopShellRun "$INSTDIR\bin\kleopatra.exe"
+  goto leave
+skip_kleo:
+  !insertmacro SectionFlagIsSet ${SEC_gpa} \
+        ${SF_SELECTED} 0 leave
+  g4wihelp::DesktopShellRun "$INSTDIR\bin\gpa.exe"
+leave:
+FunctionEnd
+
+LangString T_RunKleopatra ${LANG_ENGLISH} \
+   "Run Kleopatra"
+
+LangString T_RunGPA ${LANG_ENGLISH} \
+   "Run GPA"
+!endif # SOURCES
 
 # Uninstaller pages.
 
 !insertmacro MUI_UNPAGE_WELCOME
 !insertmacro MUI_UNPAGE_CONFIRM
 !insertmacro MUI_UNPAGE_INSTFILES
-!insertmacro MUI_UNPAGE_FINISH
+#!insertmacro MUI_UNPAGE_FINISH
 
 #Page license
 #Page components
@@ -206,7 +238,6 @@ Bitte die Sprache des Installations-Vorgangs angeben."
 !undef PO_HEADER
 
 !insertmacro MUI_RESERVEFILE_LANGDLL
-!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
 ReserveFile "${BUILD_DIR}\g4wihelp.dll"
 !ifdef SOURCES
 ReserveFile "${TOP_SRCDIR}\doc\logo\gpg4win-logo-400px.bmp"
@@ -230,9 +261,6 @@ LangString T_GPLShort ${LANG_ENGLISH} \
    You may distribute it as long as you give the recipients the same \
    rights you have received."
 
-LangString T_RunKeyManager ${LANG_ENGLISH} \
-   "Run the key manager"
-
 LangString T_MoreInfo ${LANG_ENGLISH} \
    "Click here for the project's homepage"
 LangString T_MoreInfoURL ${LANG_ENGLISH} "http://www.gpg4win.org"
@@ -261,28 +289,6 @@ LangString DESC_Desktop_manuals ${LANG_ENGLISH} \
 # Custom functions and macros for gpg4win.
 !include "g4wihelp.nsi"
 
-#
-# Control function for the Custom page to select special
-# install options.
-#
-Function CustomPageOptions
-  !insertmacro MUI_HEADER_TEXT "$(T_InstallOptions)" "$(T_InstallOptLinks)"
-
-  # Note that the default selection is done in the ini file.
-  !insertmacro MUI_INSTALLOPTIONS_WRITE "installer-options.ini" \
-	"Field 1" "Text"  "$(T_InstOptLabelA)"
-  !insertmacro MUI_INSTALLOPTIONS_WRITE "installer-options.ini" \
-	"Field 2" "Text"  "$(T_InstOptFieldA)"
-  !insertmacro MUI_INSTALLOPTIONS_WRITE "installer-options.ini" \
-	"Field 3" "Text"  "$(T_InstOptFieldB)"
-  !insertmacro MUI_INSTALLOPTIONS_WRITE "installer-options.ini" \
-	"Field 4" "Text"  "$(T_InstOptFieldC)"
-  !insertmacro MUI_INSTALLOPTIONS_WRITE "installer-options.ini" \
-	"Field 5" "Text"  "$(T_InstOptLabelB)"
-
-  !insertmacro MUI_INSTALLOPTIONS_DISPLAY "installer-options.ini"
-FunctionEnd
-
 # Display a warning if this is a Beta version.
 #Function PrintBetaWarning
 #   MessageBox MB_OK "$(T_BetaWarning)"
@@ -402,15 +408,6 @@ Function PrintNonAdminWarning
 FunctionEnd
 
 
-# Check whether the start menu is actually wanted.
-
-Function CheckIfStartMenuWanted
-  !insertmacro MUI_INSTALLOPTIONS_READ $R0 "installer-options.ini" \
-	"Field 2" "State"
-  IntCmp $R0 1 +2
-    Abort
-FunctionEnd
-
 # Check for claws mail installation which was shipped in Gpg4win
 # versions < 2.2.6
 Function CheckClawsUninstall
@@ -690,4 +687,77 @@ Function un.RemoveFromPath
   Pop $0
 FunctionEnd
 
+Function .onInit
+  Call G4wRunOnce
+
+  SetOutPath $TEMP
+!ifdef SOURCES
+  File /oname=gpgspltmp.bmp "${TOP_SRCDIR}/doc/logo/gpg4win-logo-400px.bmp"
+  # We play the tune only for the source installer
+  File /oname=gpgspltmp.wav "${TOP_SRCDIR}/src/gpg4win-splash.wav"
+  g4wihelp::playsound $TEMP\gpgspltmp.wav
+  g4wihelp::showsplash 2500 $TEMP\gpgspltmp.bmp
+
+  Delete $TEMP\gpgspltmp.bmp
+  # Note that we delete gpgspltmp.wav in .onInst{Failed,Success}
+!endif
+
+  # Enable this to force a language selection dialog on every run (the
+  # preferred language is the default).  Otherwise, the preferred
+  # language is stored in the registry, and the installer does not ask
+  # on upgrades.
+!ifdef DEBUG
+!define MUI_LANGDLL_ALWAYSSHOW
+!endif
+  !insertmacro MUI_LANGDLL_DISPLAY
+
+  ${MementoSectionRestore}
+  Call CalcDefaults
+  Call CalcDepends
+  Call CheckOtherGnuPGApps
+FunctionEnd
+
+
+Function un.onInit
+  # Remove the language preference.
+  !insertmacro MUI_UNGETLANGUAGE
+FunctionEnd
+
+# This must be in a central place.  Urgs.
+
+!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
+!ifdef HAVE_PKG_GNUPG_W32
+  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_gnupg_w32} $(DESC_SEC_gnupg_w32)
+!endif
+!ifdef HAVE_PKG_GPGOL
+  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_gpgol} $(DESC_SEC_gpgol)
+!endif
+!ifdef HAVE_PKG_GPGEX
+  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_gpgex} $(DESC_SEC_gpgex)
+!endif
+!ifdef HAVE_PKG_PAPERKEY
+  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_paperkey} $(DESC_SEC_paperkey)
+!endif
+!ifdef HAVE_PKG_GPA
+  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_gpa} $(DESC_SEC_gpa)
+!endif
+!ifdef HAVE_PKG_KLEOPATRA
+  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_kleopatra} $(DESC_SEC_kleopatra)
+!endif
+!ifdef HAVE_PKG_MAN_NOVICE_EN
+  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_man_novice_en} $(DESC_SEC_man_novice_en)
+!endif
+!ifdef HAVE_PKG_MAN_ADVANCED_EN
+  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_man_advanced_en} $(DESC_SEC_man_advanced_en)
+!endif
+!ifdef HAVE_PKG_COMPENDIUM
+  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_compendium} $(DESC_SEC_compendium)
+!endif
+!ifdef HAVE_PKG_MAN_NOVICE_DE
+  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_man_novice_de} $(DESC_SEC_man_novice_de)
+!endif
+!ifdef HAVE_PKG_MAN_ADVANCED_DE
+  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_man_advanced_de} $(DESC_SEC_man_advanced_de)
+!endif
+!insertmacro MUI_FUNCTION_DESCRIPTION_END
 

commit ef794973d575fa63dbe916605478fb46d45ef76c
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Feb 29 14:47:06 2016 +0100

    Add RunAsUser implementation.
    
    * src/desktopshellrun.cpp: New.
    
    --
    As it is impossible to fully drop privileges from an elevated
    token in UAC the approach is to look up the users shell and
    send a COM signal to spawn a process with the shell's access rights.

diff --git a/src/desktopshellrun.cpp b/src/desktopshellrun.cpp
new file mode 100644
index 0000000..76c4992
--- /dev/null
+++ b/src/desktopshellrun.cpp
@@ -0,0 +1,341 @@
+/* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
+ * Copyright (C) 2016 Intevation GmbH
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=2)
+ * and comes with ABSOLUTELY NO WARRANTY!
+ */
+
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <initguid.h>
+#include <mstask.h>
+#include <wchar.h>
+#include <ole2.h>
+#include <shldisp.h>
+#include <shobjidl.h>
+#include <exdisp.h>
+#include <shlguid.h>
+
+#include "exdll.h"
+#ifndef INITGUID
+#define INITGUID
+#endif
+
+/* Some declarations missing in mingw-w64 3.1.0 taken from msdn */
+
+__CRT_UUID_DECL(IShellWindows, 0x85CB6900, 0x4D95, 0x11CF,
+                0x96, 0x0C, 0x00, 0x80, 0xC7, 0xF4, 0xEE, 0x85);
+
+DEFINE_GUID(IID_IShellWindows,
+            0x85CB6900, 0x4D95, 0x11CF,
+            0x96, 0x0C, 0x00, 0x80, 0xC7, 0xF4, 0xEE, 0x85);
+DEFINE_GUID(CLSID_ShellWindows,
+            0x9BA05972, 0xF6A8, 0x11CF,
+            0xA4, 0x42, 0x00, 0xA0, 0xC9, 0x0A, 0x8F, 0x39);
+
+
+__CRT_UUID_DECL(IShellDispatch2, 0xA4C6892C, 0x3BA9, 0x11d2,
+                0x9D, 0xEA, 0x00, 0xC0, 0x4F, 0xB1, 0x61, 0x62);
+__CRT_UUID_DECL(IShellFolderViewDual,  0xe7a1af80, 0x4d96,
+                0x11cf, 0x96, 0x0c, 0x00, 0x80, 0xc7, 0xf4, 0xee, 0x85);
+
+#ifndef SWC_DESKTOP /* Will probably be addedd in future mingw */
+#define SWC_DESKTOP 0x00000008
+/* from http://msdn.microsoft.com/en-us/library/windows/desktop/cc836581%28v=vs.85%29.aspx */
+#endif
+
+#define UNUSED(x) (void)(x)
+#define ERRORPRINTF(fmt, ...) \
+  { \
+    char buf[512]; \
+    snprintf(buf, 511, "ERROR: " fmt, ##__VA_ARGS__); \
+    buf[511] = '\0'; \
+    OutputDebugStringA(buf); \
+  }
+
+/** @brief the actual execuation call on the shell dispatcher
+ *
+ * @param[in] disp The shell dispatcher to use for shell execute.
+ * @param[in] fName The file that should be exectued.
+ * @param[in] param Optinal parameters to add.
+ *
+ * @returns true on success.
+ */
+static bool
+shellexecute(IShellDispatch2 *disp, wchar_t *fName, wchar_t *param)
+{
+  BSTR bName = NULL,
+       bParam = NULL,
+       bDir = NULL,
+       bOp = NULL;
+  VARIANT vParams[4];
+  HRESULT hr;
+
+  if (!fName || !disp)
+    {
+      ERRORPRINTF ("Invalid call to shellexecute.");
+      return false;
+    }
+
+  bName = SysAllocString(fName);
+  bParam = SysAllocString(param ? param : L"");
+  bDir = SysAllocString(L"");
+  bOp = SysAllocString(L"");
+
+  if (!bName || !bParam || !bDir || !bOp)
+    {
+      /* Out of memory */
+      ERRORPRINTF ("Failed to allocate bstr values ");
+      return false;
+    }
+
+  vParams[0].vt = VT_BSTR;
+  vParams[0].bstrVal = bParam;
+  vParams[1].vt = VT_BSTR;
+  vParams[1].bstrVal = bDir;
+  vParams[2].vt = VT_BSTR;
+  vParams[2].bstrVal = bOp;
+  vParams[3].vt = VT_INT;
+  vParams[3].intVal = SW_SHOWNORMAL;
+
+  hr = disp->ShellExecute(bName, vParams[0], vParams[1], vParams[2], vParams[3]);
+
+  SysFreeString(bName);
+  SysFreeString(bParam);
+  SysFreeString(bOp);
+  SysFreeString(bDir);
+
+  if (FAILED(hr))
+    {
+      ERRORPRINTF ("Failed to execute.");
+      return false;
+    }
+  return true;
+}
+
+wchar_t
+*acp_to_wchar (const char *string, size_t len)
+{
+  int n, ilen;
+  wchar_t *result;
+
+  ilen = (int) len;
+  if (ilen < 0)
+    return NULL;
+
+  n = MultiByteToWideChar (CP_ACP, 0, string, ilen, NULL, 0);
+  if (n < 0 || n + 1 < 0)
+    return NULL;
+
+  result = (wchar_t *) malloc ((size_t)(n+1) * sizeof *result);
+  if (!result)
+    {
+      ERRORPRINTF("Out of core");
+      exit(1);
+    }
+  n = MultiByteToWideChar (CP_ACP, 0, string, ilen, result, n);
+  if (n < 0)
+    {
+      if (result)
+        free (result);
+      return NULL;
+    }
+  result[n] = 0;
+  return result;
+}
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @brief Execute a command with the current running shell.
+ *
+ * This function is intended to be called when you want to
+ * make sure that your application is not executed with higher
+ * privileges then the normal desktop session.
+ *
+ * The code is based on the idea:
+ * http://blogs.msdn.com/b/oldnewthing/archive/2013/11/18/10468726.aspx
+ *
+ * The function signature is explained by NSIS.
+ */
+void __declspec(dllexport) __cdecl DesktopShellRun(HWND hwndParent,
+                                                   int string_size,
+                                                   char *variables,
+                                                   stack_t **stacktop)
+{
+  UNUSED(hwndParent);
+  UNUSED(string_size);
+  HRESULT hr;
+  wchar_t *wbuf = NULL,
+          *params = NULL;
+  IShellWindows *shellWindows = NULL;
+  IShellBrowser *shellBrowser = NULL;
+  IShellView *shellView = NULL;
+  IShellFolderViewDual *folderView = NULL;
+  IShellDispatch2 *shellDispatch = NULL;
+  IServiceProvider *serviceProv = NULL;
+  HWND hwnd;
+  IDispatch *disp = NULL,
+             *bgDisp = NULL,
+              *sDisp = NULL;
+  VARIANT vEmpty = {};
+
+  if (!stacktop || !*stacktop || !(*stacktop)->text)
+    {
+      ERRORPRINTF ("Invalid call to exec :");
+      return;
+    }
+
+  /* Initialize com ctx */
+  hr = CoInitialize(NULL);
+  if(FAILED(hr))
+    {
+      ERRORPRINTF ("CoInitializeEx failed. error = 0x%lx.", hr);
+      return;
+    }
+
+  /* Get the shell interface */
+  hr = CoCreateInstance(CLSID_ShellWindows,
+                        NULL, CLSCTX_LOCAL_SERVER,
+                        IID_PPV_ARGS(&shellWindows));
+  if (FAILED(hr))
+    {
+      ERRORPRINTF ("Failed to get shell interface.");
+      goto done;
+    }
+
+  /* Get the desktop shell window */
+  hr = shellWindows->FindWindowSW(&vEmpty,
+                                  &vEmpty,
+                                  SWC_DESKTOP,
+                                  (long*)&hwnd,
+                                  SWFO_NEEDDISPATCH,
+                                  &disp);
+  if (FAILED(hr))
+    {
+      ERRORPRINTF ("Failed to find the desktop dispatcher.");
+      goto done;
+    }
+
+  hr = disp->QueryInterface(IID_PPV_ARGS(&serviceProv));
+
+  if (FAILED(hr))
+    {
+      ERRORPRINTF ("Failed to get the service provider.");
+      goto done;
+    }
+
+  /* Get the shell browser */
+  hr = serviceProv->QueryService(SID_STopLevelBrowser, IID_PPV_ARGS(&shellBrowser));
+  if (FAILED(hr))
+    {
+      ERRORPRINTF ("Failed to find the top level browser.");
+      goto done;
+    }
+
+  hr = shellBrowser->QueryActiveShellView(&shellView);
+
+  if (FAILED(hr))
+    {
+      ERRORPRINTF ("Failed to find the active view.");
+      goto done;
+    }
+
+  hr = shellView->GetItemObject(SVGIO_BACKGROUND, IID_PPV_ARGS(&bgDisp));
+
+  if (FAILED(hr))
+    {
+      ERRORPRINTF ("Failed to get the views background.");
+      goto done;
+    }
+
+  hr = bgDisp->QueryInterface(IID_PPV_ARGS(&folderView));
+
+  if (FAILED(hr))
+    {
+      ERRORPRINTF ("Failed to get the folder view.");
+      goto done;
+    }
+
+
+  hr = folderView->get_Application(&sDisp);
+
+  if (FAILED(hr))
+    {
+      ERRORPRINTF ("Failed to get the shell dispatch.");
+      goto done;
+    }
+
+  hr = sDisp->QueryInterface(IID_PPV_ARGS(&shellDispatch));
+
+  if (FAILED(hr))
+    {
+      ERRORPRINTF ("Failed to get the shell dispatch interface.");
+      goto done;
+    }
+
+  /* For unicodensis this has to be utf8 to wchar */
+
+  wbuf = acp_to_wchar((*stacktop)->text, strlen((*stacktop)->text));
+  if (!wbuf)
+    {
+      ERRORPRINTF ("Failed to convert argument to wchar. error = 0x%lx.", hr);
+      goto done;
+    }
+
+  if ((*stacktop)->next && (*stacktop)->next->text)
+    {
+      params = acp_to_wchar((*stacktop)->next->text, strlen((*stacktop)->next->text));
+    }
+
+  if (!shellexecute(shellDispatch, wbuf, params))
+    {
+      ERRORPRINTF ("Failed to execute.");
+    }
+  if (wbuf)
+    free(wbuf);
+  if (params)
+    free (params);
+done:
+  if (folderView)
+    {
+      folderView->Release();
+    }
+  if (disp)
+    {
+      disp->Release();
+    }
+  if (shellBrowser)
+    {
+      shellBrowser->Release();
+    }
+  if (shellWindows)
+    {
+      shellWindows->Release();
+    }
+  if (shellView)
+    {
+      shellView->Release();
+    }
+  if (sDisp)
+    {
+      sDisp->Release();
+    }
+  if (shellDispatch)
+    {
+      shellDispatch->Release();
+    }
+  if (serviceProv)
+    {
+      serviceProv->Release();
+    }
+  CoUninitialize();
+  return;
+}
+
+#ifdef __cplusplus
+}
+#endif

-----------------------------------------------------------------------

Summary of changes:
 src/Makefile.am              |  29 ++--
 src/desktopshellrun.cpp      | 341 +++++++++++++++++++++++++++++++++++++++++++
 src/g4wihelp.c               |   1 +
 src/gpg4win-src.nsi          |  26 +++-
 src/gpg4win.nsi              |  21 ++-
 src/inst-sections.nsi        | 112 +-------------
 src/installer-options.ini.in |  47 ------
 src/installer.nsi            | 182 ++++++++++++++++-------
 8 files changed, 518 insertions(+), 241 deletions(-)
 create mode 100644 src/desktopshellrun.cpp
 delete mode 100644 src/installer-options.ini.in


hooks/post-receive
-- 
GnuPG for Windows
http://git.gnupg.org



More information about the Gpg4win-commits mailing list