Warning, /graphics/digikam/project/bundles/vcpkg/installer/events_functions.nsh is written in an unsupported language. File is not indexed.
0001 ;; ============================================================ 0002 ; 0003 ; This file is a part of digiKam project 0004 ; https://www.digikam.org 0005 ; 0006 ; Date : 2005-01-01 0007 ; Description : Functions to catch NSIS events. 0008 ; Note: NSIS >= 3 is required to be compatible with Windows 10. 0009 ; 0010 ; SPDX-FileCopyrightText: 2010-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 ; 0012 ; SPDX-License-Identifier: GPL-2.0-or-later 0013 ; 0014 ; ============================================================ ;; 0015 0016 !ifndef EVENTS_FUNCTIONS_INCLUDED 0017 !define EVENTS_FUNCTIONS_INCLUDED 0018 0019 Function .onInit 0020 0021 ;Do not permit to install 64 bits to 32 bits. 0022 0023 ${IfNot} ${RunningX64} 0024 0025 MessageBox MB_OK|MB_ICONSTOP|MB_TOPMOST|MB_SETFOREGROUND "This is the 64 bits installer, and it cannot be installed to a 32 bits system." 0026 SetErrorLevel 2 0027 Quit 0028 0029 ${EndIf} 0030 0031 ;Default installation folder depending of target architecture. 0032 0033 ${If} $InstDir == "" ; Don't override setup.exe /D=c:\custom\dir 0034 StrCpy $InstDir "$PROGRAMFILES64\${MY_PRODUCT}" 0035 ${EndIf} 0036 0037 Push $0 0038 UserInfo::GetAccountType 0039 Pop $0 0040 0041 ${If} $0 != "admin" 0042 0043 ;Require admin rights on NT4+ 0044 0045 MessageBox MB_OK|MB_ICONSTOP|MB_TOPMOST|MB_SETFOREGROUND "Administrator privileges required!$\r$\n$\r$\nPlease restart the installer using an administrator account." 0046 SetErrorLevel 740 ; ERROR_ELEVATION_REQUIRED 0047 Quit 0048 0049 ${EndIf} 0050 0051 Pop $0 0052 0053 Push $R0 0054 Push $R1 0055 Push $R2 0056 0057 checkUninstallRequired: 0058 0059 ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MY_PRODUCT}" "UninstallString" 0060 ${StrRep} $R0 $R0 '"' "" ; Remove double-quotes so Delete and RMDir work properly and we can extract the path 0061 StrCmp $R0 "" done 0062 0063 ${IfNot} ${FileExists} $R0 0064 0065 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MY_PRODUCT}" 0066 Goto checkUninstallRequired 0067 0068 ${EndIf} 0069 0070 ;Get path 0071 0072 ${StrStrAdv} $R1 $R0 "\" "<" "<" "0" "0" "0" 0073 0074 ReadRegStr $R2 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MY_PRODUCT}" "DisplayName" ; DisplayName contains version 0075 0076 ;TODO: need to internationalize string (see VLC / clementine / etc) 0077 0078 MessageBox MB_YESNO|MB_ICONEXCLAMATION|MB_TOPMOST|MB_SETFOREGROUND "$R2 is currently installed but only a single instance of ${MY_PRODUCT} can be installed at any time.$\r$\n$\r$\n\ 0079 Note: only the application binary files will be removed from your system at this stage. Your collections and database files kept untouched.$\r$\n$\r$\n\ 0080 Important: database schemas can be upgraded between major releases, so it's recommended to backup all database files before to start a new digiKam session after this install.$\r$\n$\r$\n\ 0081 Do you want to uninstall the current instance of ${MY_PRODUCT} and continue installing ${MY_PRODUCT} ${VERSION}?" /SD IDYES IDNO noInstall 0082 0083 ;Run the uninstaller 0084 0085 ClearErrors 0086 0087 IfSilent 0 notSilent 0088 0089 ExecWait '"$R0" /S _?=$R1' ; Do not copy the uninstaller to a temp file 0090 Goto uninstDone 0091 0092 notSilent: 0093 0094 ExecWait '"$R0" _?=$R1' ; Do not copy the uninstaller to a temp file 0095 0096 uninstDone: 0097 0098 IfErrors checkUninstallRequired 0099 Delete "$R0" ; If uninstall successful, remove uninstaller 0100 RMDir "$R1" ; remove previous install directory 0101 Goto checkUninstallRequired 0102 0103 noInstall: 0104 Abort 0105 0106 done: 0107 Pop $R2 0108 Pop $R1 0109 Pop $R0 0110 0111 FunctionEnd 0112 0113 ;------------------------------------------- 0114 0115 Function .onInstSuccess 0116 0117 nsExec::ExecToLog /TIMEOUT=2000 '"$instdir\kbuildsycoca6.exe --noincremental"' 0118 0119 FunctionEnd 0120 0121 ;------------------------------------------------------------------------------------- 0122 0123 Function functionFinishRun 0124 0125 ; Execute the file with non-elevated rights. 0126 0127 Exec '"$WINDIR\explorer.exe" "$instdir\digikam.exe"' 0128 0129 FunctionEnd 0130 0131 !endif ;EVENTS_FUNCTIONS_INCLUDED