Warning, /graphics/digikam/project/bundles/mxe/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     ${If} ${TARGETARCH} == "64"
0024     ${AndIfNot} ${RunningX64}
0025 
0026         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."
0027         SetErrorLevel 2
0028         Quit
0029 
0030     ${EndIf}
0031 
0032     ;Default installation folder depending of target architecture.
0033 
0034     ${If} $InstDir == "" ; Don't override setup.exe /D=c:\custom\dir
0035         ${If} ${TARGETARCH} == "64"
0036                 StrCpy $InstDir "$PROGRAMFILES64\${MY_PRODUCT}"
0037         ${Else}
0038                 StrCpy $InstDir "$PROGRAMFILES32\${MY_PRODUCT}"
0039         ${EndIf}
0040     ${EndIf}
0041 
0042     Push $0
0043     UserInfo::GetAccountType
0044     Pop $0
0045 
0046     ${If} $0 != "admin"
0047 
0048         ;Require admin rights on NT4+
0049 
0050         MessageBox MB_OK|MB_ICONSTOP|MB_TOPMOST|MB_SETFOREGROUND "Administrator privileges required!$\r$\n$\r$\nPlease restart the installer using an administrator account."
0051         SetErrorLevel 740 ; ERROR_ELEVATION_REQUIRED
0052         Quit
0053 
0054     ${EndIf}
0055 
0056     Pop $0
0057 
0058     Push $R0
0059     Push $R1
0060     Push $R2
0061 
0062     checkUninstallRequired:
0063 
0064     ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MY_PRODUCT}" "UninstallString"
0065     ${StrRep} $R0 $R0 '"' "" ; Remove double-quotes so Delete and RMDir work properly and we can extract the path
0066     StrCmp $R0 "" done
0067 
0068     ${IfNot} ${FileExists} $R0
0069 
0070         DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MY_PRODUCT}"
0071         Goto checkUninstallRequired
0072 
0073     ${EndIf}
0074 
0075     ;Get path
0076 
0077     ${StrStrAdv} $R1 $R0 "\" "<" "<" "0" "0" "0"
0078 
0079     ReadRegStr $R2 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MY_PRODUCT}" "DisplayName" ; DisplayName contains version
0080 
0081     ;TODO: need to internationalize string (see VLC / clementine / etc)
0082 
0083     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\
0084         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\
0085         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\
0086         Do you want to uninstall the current instance of ${MY_PRODUCT} and continue installing ${MY_PRODUCT} ${VERSION}?" /SD IDYES IDNO noInstall
0087 
0088     ;Run the uninstaller
0089 
0090     ClearErrors
0091 
0092     IfSilent 0 notSilent
0093 
0094     ExecWait '"$R0" /S _?=$R1' ; Do not copy the uninstaller to a temp file
0095     Goto uninstDone
0096 
0097     notSilent:
0098 
0099         ExecWait '"$R0" _?=$R1' ; Do not copy the uninstaller to a temp file
0100 
0101     uninstDone:
0102 
0103         IfErrors checkUninstallRequired
0104         Delete "$R0" ; If uninstall successful, remove uninstaller
0105         RMDir "$R1" ; remove previous install directory
0106         Goto checkUninstallRequired
0107 
0108     noInstall:
0109         Abort
0110 
0111     done:
0112         Pop $R2
0113         Pop $R1
0114         Pop $R0
0115 
0116 FunctionEnd
0117 
0118 ;-------------------------------------------
0119 
0120 Function .onInstSuccess
0121 
0122     nsExec::ExecToLog /TIMEOUT=2000 '"$instdir\kbuildsycoca5.exe --noincremental"'
0123 
0124 FunctionEnd
0125 
0126 ;-------------------------------------------------------------------------------------
0127 
0128 Function functionFinishRun
0129 
0130     ; Execute the file with non-elevated rights.
0131 
0132     Exec '"$WINDIR\explorer.exe" "$instdir\digikam.exe"'
0133 
0134 FunctionEnd
0135 
0136 !endif ;EVENTS_FUNCTIONS_INCLUDED