|
From: <xue...@us...> - 2003-08-06 16:34:35
|
Update of /cvsroot/popfile/windows
In directory sc8-pr-cvs1:/tmp/cvs-serv29651
Modified Files:
installer.nsi pfi-library.nsh
Log Message:
Handle message history in the same way as corpus data. Simple 'sleep' delays replaced by more intelligent file monitoring when shutting down POPFile.
Index: installer.nsi
===================================================================
RCS file: /cvsroot/popfile/windows/installer.nsi,v
retrieving revision 1.99
retrieving revision 1.100
diff -C2 -d -r1.99 -r1.100
*** installer.nsi 3 Aug 2003 00:47:21 -0000 1.99
--- installer.nsi 6 Aug 2003 16:34:32 -0000 1.100
***************
*** 109,127 ****
!define C_RELEASE_NOTES "..\engine\${C_README}"
! ;-----------------------------------------
! ; Root directory for the Perl files used to build the installer
! ;-----------------------------------------
!define C_PERL_DIR "C:\Perl"
-
- ;-----------------------------------------
- ; Delay (in milliseconds) used after issuing a POPFile 'shutdown' request
- ;-----------------------------------------
-
- !define C_SHUTDOWN_DELAY 1500
! ;-----------------------------------------
; Define PFI_VERBOSE to get more compiler output
! ;-----------------------------------------
# !define PFI_VERBOSE
--- 109,145 ----
!define C_RELEASE_NOTES "..\engine\${C_README}"
! ;----------------------------------------------------------------------
! ; Root directory for the Perl files (used when building the installer)
! ;----------------------------------------------------------------------
!define C_PERL_DIR "C:\Perl"
! ;--------------------------------------------------------------------------------
! ; Constants for the timeout loop used after issuing a POPFile 'shutdown' request
! ;--------------------------------------------------------------------------------
!
! ; Timeout loop counter start value (counts down to 0)
!
! !define C_SHUTDOWN_LIMIT 10
!
! ; Delay (in milliseconds) used inside the timeout loop
!
! !define C_SHUTDOWN_DELAY 500
!
! ;-------------------------------------------------------------------------------
! ; Constants for the timeout loop used after issuing a POPFile 'startup' request
! ;-------------------------------------------------------------------------------
!
! ; Timeout loop counter start value (counts down to 0)
!
! !define C_STARTUP_LIMIT 10
!
! ; Delay (in milliseconds) used inside the timeout loop
!
! !define C_STARTUP_DELAY 500
!
! ;------------------------------------------------
; Define PFI_VERBOSE to get more compiler output
! ;------------------------------------------------
# !define PFI_VERBOSE
***************
*** 321,332 ****
; Same "Language selection" dialog is used for the installer and the uninstaller
; so we override the standard "Installer Language" title to avoid confusion.
!
!define MUI_TEXT_LANGDLL_WINDOWTITLE "Language Selection"
!
; Always show the language selection dialog, even if a language has been stored in the
; registry (the language stored in the registry will be selected as the default language)
!define MUI_LANGDLL_ALWAYSSHOW
!
; Remember user's language selection and offer this as the default when re-installing
; (uninstaller also uses this setting to determine which language is to be used)
--- 339,350 ----
; Same "Language selection" dialog is used for the installer and the uninstaller
; so we override the standard "Installer Language" title to avoid confusion.
!
!define MUI_TEXT_LANGDLL_WINDOWTITLE "Language Selection"
!
; Always show the language selection dialog, even if a language has been stored in the
; registry (the language stored in the registry will be selected as the default language)
!define MUI_LANGDLL_ALWAYSSHOW
!
; Remember user's language selection and offer this as the default when re-installing
; (uninstaller also uses this setting to determine which language is to be used)
***************
*** 878,909 ****
!define L_CFG $R9 ; file handle
! !define L_NEW_GUI $R8
! !define L_OLD_GUI $R7
! !define L_RESULT $R6
Push ${L_CFG}
Push ${L_NEW_GUI}
Push ${L_OLD_GUI}
Push ${L_RESULT}
- ; A quick test ignoring fact that popfile.cfg may specify a non-default location for PID file
-
- IfFileExists "$INSTDIR\popfile.pid" attempt_shutdown
-
; If we are about to overwrite an existing version which is still running,
; then one of the EXE files will be 'locked' which means we have to shutdown POPFile
! IfFileExists "$INSTDIR\wperl.exe" 0 other_perl
! SetFileAttributes "$INSTDIR\wperl.exe" NORMAL
ClearErrors
! FileOpen ${L_CFG} "$INSTDIR\wperl.exe" a
FileClose ${L_CFG}
IfErrors attempt_shutdown
other_perl:
! IfFileExists "$INSTDIR\perl.exe" 0 exit_now
! SetFileAttributes "$INSTDIR\perl.exe" NORMAL
ClearErrors
! FileOpen ${L_CFG} "$INSTDIR\perl.exe" a
FileClose ${L_CFG}
IfErrors 0 exit_now
--- 896,927 ----
!define L_CFG $R9 ; file handle
! !define L_EXE $R8 ; name of EXE file to be monitored
! !define L_NEW_GUI $R7
! !define L_OLD_GUI $R6
! !define L_RESULT $R5
Push ${L_CFG}
+ Push ${L_EXE}
Push ${L_NEW_GUI}
Push ${L_OLD_GUI}
Push ${L_RESULT}
; If we are about to overwrite an existing version which is still running,
; then one of the EXE files will be 'locked' which means we have to shutdown POPFile
! StrCpy ${L_EXE} "$INSTDIR\wperl.exe"
! IfFileExists "${L_EXE}" 0 other_perl
! SetFileAttributes "${L_EXE}" NORMAL
ClearErrors
! FileOpen ${L_CFG} "${L_EXE}" a
FileClose ${L_CFG}
IfErrors attempt_shutdown
other_perl:
! StrCpy ${L_EXE} "$INSTDIR\perl.exe"
! IfFileExists "${L_EXE}" 0 exit_now
! SetFileAttributes "${L_EXE}" NORMAL
ClearErrors
! FileOpen ${L_CFG} "${L_EXE}" a
FileClose ${L_CFG}
IfErrors 0 exit_now
***************
*** 920,926 ****
DetailPrint "$(PFI_LANG_INST_LOG_1) ${L_OLD_GUI}"
NSISdl::download_quiet http://127.0.0.1:${L_OLD_GUI}/shutdown "$PLUGINSDIR\shutdown.htm"
- Sleep ${C_SHUTDOWN_DELAY}
Pop ${L_RESULT}
! StrCmp ${L_RESULT} "success" exit_now
try_other_port:
--- 938,943 ----
DetailPrint "$(PFI_LANG_INST_LOG_1) ${L_OLD_GUI}"
NSISdl::download_quiet http://127.0.0.1:${L_OLD_GUI}/shutdown "$PLUGINSDIR\shutdown.htm"
Pop ${L_RESULT}
! StrCmp ${L_RESULT} "success" check_exe
try_other_port:
***************
*** 928,945 ****
Call StrCheckDecimal
Pop ${L_NEW_GUI}
! StrCmp ${L_NEW_GUI} "" exit_now
DetailPrint "$(PFI_LANG_INST_LOG_1) ${L_NEW_GUI}"
NSISdl::download_quiet http://127.0.0.1:${L_NEW_GUI}/shutdown "$PLUGINSDIR\shutdown.htm"
- Sleep ${C_SHUTDOWN_DELAY}
Pop ${L_RESULT} ; Ignore the result
exit_now:
Pop ${L_RESULT}
Pop ${L_OLD_GUI}
Pop ${L_NEW_GUI}
Pop ${L_CFG}
!undef L_CFG
!undef L_NEW_GUI
!undef L_OLD_GUI
--- 945,967 ----
Call StrCheckDecimal
Pop ${L_NEW_GUI}
! StrCmp ${L_NEW_GUI} "" check_exe
DetailPrint "$(PFI_LANG_INST_LOG_1) ${L_NEW_GUI}"
NSISdl::download_quiet http://127.0.0.1:${L_NEW_GUI}/shutdown "$PLUGINSDIR\shutdown.htm"
Pop ${L_RESULT} ; Ignore the result
+ check_exe:
+ Push ${L_EXE}
+ Call WaitUntilUnlocked
+
exit_now:
Pop ${L_RESULT}
Pop ${L_OLD_GUI}
Pop ${L_NEW_GUI}
+ Pop ${L_EXE}
Pop ${L_CFG}
!undef L_CFG
+ !undef L_EXE
!undef L_NEW_GUI
!undef L_OLD_GUI
***************
*** 1019,1023 ****
StrCpy ${L_CMPRE} ${L_LNE} 8
StrCmp ${L_CMPRE} "ui_port " got_ui_port
!
StrCmp ${L_STRIPLANG} "" transfer
--- 1041,1045 ----
StrCpy ${L_CMPRE} ${L_LNE} 8
StrCmp ${L_CMPRE} "ui_port " got_ui_port
!
StrCmp ${L_STRIPLANG} "" transfer
***************
*** 1178,1184 ****
; Ensure custom page shows the "Shutdown" warning message box.
!
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioA.ini" "Settings" "NumFields" "7"
!
IfFileExists "$INSTDIR\popfile.pl" 0 continue
--- 1200,1206 ----
; Ensure custom page shows the "Shutdown" warning message box.
!
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioA.ini" "Settings" "NumFields" "7"
!
IfFileExists "$INSTDIR\popfile.pl" 0 continue
***************
*** 1602,1606 ****
!insertmacro PFI_IO_TEXT "ioC.ini" "3" "$(PFI_LANG_LAUNCH_IO_DOSBOX)"
!insertmacro PFI_IO_TEXT "ioC.ini" "4" "$(PFI_LANG_LAUNCH_IO_BCKGRND)"
!
!insertmacro PFI_IO_TEXT "ioC.ini" "6" "$(PFI_LANG_LAUNCH_IO_NOTE_1)"
!insertmacro PFI_IO_TEXT "ioC.ini" "7" "$(PFI_LANG_LAUNCH_IO_NOTE_2)"
--- 1624,1628 ----
!insertmacro PFI_IO_TEXT "ioC.ini" "3" "$(PFI_LANG_LAUNCH_IO_DOSBOX)"
!insertmacro PFI_IO_TEXT "ioC.ini" "4" "$(PFI_LANG_LAUNCH_IO_BCKGRND)"
!
!insertmacro PFI_IO_TEXT "ioC.ini" "6" "$(PFI_LANG_LAUNCH_IO_NOTE_1)"
!insertmacro PFI_IO_TEXT "ioC.ini" "7" "$(PFI_LANG_LAUNCH_IO_NOTE_2)"
***************
*** 1636,1643 ****
Function CheckLaunchOptions
! !define L_RESULT $R9
! !define L_TEMP $R8
! Push ${L_RESULT}
Push ${L_TEMP}
--- 1658,1667 ----
Function CheckLaunchOptions
! !define L_CFG $R9 ; file handle
! !define L_EXE $R8 ; full path of perl EXE to be monitored
! !define L_TEMP $R7
! Push ${L_CFG}
! Push ${L_EXE}
Push ${L_TEMP}
***************
*** 1650,1653 ****
--- 1674,1685 ----
StrCmp ${L_TEMP} "" exit_without_banner
StrCmp ${L_TEMP} "no" exit_without_banner
+ StrCmp ${L_TEMP} "background" background_to_no
+ StrCpy ${L_EXE} "$INSTDIR\perl.exe"
+ Goto lastaction_no
+
+ background_to_no:
+ StrCpy ${L_EXE} "$INSTDIR\wperl.exe"
+
+ lastaction_no:
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioC.ini" "Run Status" "LastAction" "no"
***************
*** 1655,1664 ****
NSISdl::download_quiet http://127.0.0.1:${G_GUI}/shutdown "$PLUGINSDIR\shutdown.htm"
! Pop ${L_RESULT} ; Get the return value (and ignore it)
! Sleep ${C_SHUTDOWN_DELAY}
! goto exit_without_banner
run_popfile:
; Field 4 = 'Run POPFile in background' radio button
--- 1687,1701 ----
NSISdl::download_quiet http://127.0.0.1:${G_GUI}/shutdown "$PLUGINSDIR\shutdown.htm"
! Pop ${L_TEMP} ; Get the return value (and ignore it)
! Push ${L_EXE}
! Call WaitUntilUnlocked
! Goto exit_without_banner
run_popfile:
+ ; Set ${L_EXE} to "" as we do not yet know if we are going to monitor a file in $INSTDIR
+
+ StrCpy ${L_EXE} ""
+
; Field 4 = 'Run POPFile in background' radio button
***************
*** 1670,1673 ****
--- 1707,1714 ----
!insertmacro MUI_INSTALLOPTIONS_READ ${L_TEMP} "ioC.ini" "Run Status" "LastAction"
StrCmp ${L_TEMP} "DOS-box" exit_without_banner
+ StrCmp ${L_TEMP} "no" lastaction_DOS_box
+ StrCpy ${L_EXE} "$INSTDIR\wperl.exe"
+
+ lastaction_DOS_box:
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioC.ini" "Run Status" "LastAction" "DOS-box"
***************
*** 1678,1684 ****
NSISdl::download_quiet http://127.0.0.1:${G_GUI}/shutdown "$PLUGINSDIR\shutdown.htm"
! Pop ${L_RESULT} ; Get the return value (and ignore it)
! Sleep ${C_SHUTDOWN_DELAY}
!
ExecShell "open" "$SMPROGRAMS\POPFile\Run POPFile.lnk"
goto wait_for_popfile
--- 1719,1725 ----
NSISdl::download_quiet http://127.0.0.1:${G_GUI}/shutdown "$PLUGINSDIR\shutdown.htm"
! Pop ${L_TEMP} ; Get the return value (and ignore it)
! Push ${L_EXE}
! Call WaitUntilUnlocked
ExecShell "open" "$SMPROGRAMS\POPFile\Run POPFile.lnk"
goto wait_for_popfile
***************
*** 1690,1693 ****
--- 1731,1738 ----
!insertmacro MUI_INSTALLOPTIONS_READ ${L_TEMP} "ioC.ini" "Run Status" "LastAction"
StrCmp ${L_TEMP} "background" exit_without_banner
+ StrCmp ${L_TEMP} "no" lastaction_background
+ StrCpy ${L_EXE} "$INSTDIR\perl.exe"
+
+ lastaction_background:
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioC.ini" "Run Status" "LastAction" "background"
***************
*** 1698,1704 ****
NSISdl::download_quiet http://127.0.0.1:${G_GUI}/shutdown "$PLUGINSDIR\shutdown.htm"
! Pop ${L_RESULT} ; Get the return value (and ignore it)
! Sleep ${C_SHUTDOWN_DELAY}
!
ExecShell "open" "$SMPROGRAMS\POPFile\Run POPFile in background.lnk"
--- 1743,1749 ----
NSISdl::download_quiet http://127.0.0.1:${G_GUI}/shutdown "$PLUGINSDIR\shutdown.htm"
! Pop ${L_TEMP} ; Get the return value (and ignore it)
! Push ${L_EXE}
! Call WaitUntilUnlocked
ExecShell "open" "$SMPROGRAMS\POPFile\Run POPFile in background.lnk"
***************
*** 1707,1717 ****
; Wait until POPFile is ready to display the UI (may take a second or so)
! StrCpy ${L_TEMP} 10 ; Timeout limit to avoid an infinite loop
check_if_ready:
NSISdl::download_quiet http://127.0.0.1:${G_GUI} "$PLUGINSDIR\ui.htm"
! Pop ${L_RESULT} ; Did POPFile return an HTML page?
! StrCmp ${L_RESULT} "success" remove_banner
! Sleep 500 ; milliseconds
IntOp ${L_TEMP} ${L_TEMP} - 1
IntCmp ${L_TEMP} 0 remove_banner remove_banner check_if_ready
--- 1752,1762 ----
; Wait until POPFile is ready to display the UI (may take a second or so)
! StrCpy ${L_TEMP} ${C_STARTUP_LIMIT} ; Timeout limit to avoid an infinite loop
check_if_ready:
NSISdl::download_quiet http://127.0.0.1:${G_GUI} "$PLUGINSDIR\ui.htm"
! Pop ${L_TEMP} ; Did POPFile return an HTML page?
! StrCmp ${L_TEMP} "success" remove_banner
! Sleep ${C_STARTUP_DELAY}
IntOp ${L_TEMP} ${L_TEMP} - 1
IntCmp ${L_TEMP} 0 remove_banner remove_banner check_if_ready
***************
*** 1723,1729 ****
Pop ${L_TEMP}
! Pop ${L_RESULT}
! !undef L_RESULT
!undef L_TEMP
--- 1768,1776 ----
Pop ${L_TEMP}
! Pop ${L_EXE}
! Pop ${L_CFG}
! !undef L_CFG
! !undef L_EXE
!undef L_TEMP
***************
*** 1828,1833 ****
!define L_UPGRADE $R3 ; "yes" if this is an upgrade, "no" if we are just uninstalling
!define L_CORPUS $R2 ; holds full path to the POPFile corpus data
! !define L_SUBFOLDER $R1 ; "yes" if corpus is in a subfolder of $INSTDIR, otherwise "no"
!define L_OLDUI $R0 ; holds old-style UI port (if previous POPFile is an old version)
; When a normal uninstall is performed, the uninstaller is copied to a uniquely named
--- 1875,1883 ----
!define L_UPGRADE $R3 ; "yes" if this is an upgrade, "no" if we are just uninstalling
!define L_CORPUS $R2 ; holds full path to the POPFile corpus data
! !define L_SUBCORPUS $R1 ; "yes" if corpus is in a subfolder of $INSTDIR, otherwise "no"
!define L_OLDUI $R0 ; holds old-style UI port (if previous POPFile is an old version)
+ !define L_HISTORY $9 ; holds full path to the message history data
+ !define L_SUBHISTORY $8 ; "yes" if history data in subfolder of $INSTDIR, otherwise "no"
+ !define L_EXE $7 ; full path of the EXE to be monitored
; When a normal uninstall is performed, the uninstaller is copied to a uniquely named
***************
*** 1855,1859 ****
skip_confirmation:
! StrCpy ${L_SUBFOLDER} "yes"
Push $INSTDIR
--- 1905,1909 ----
skip_confirmation:
! StrCpy ${L_SUBCORPUS} "yes"
Push $INSTDIR
***************
*** 1864,1869 ****
Call un.StrStr
Pop ${L_TEMP}
StrCmp ${L_TEMP} "" 0 check_if_running
! StrCpy ${L_SUBFOLDER} "no"
check_if_running:
--- 1914,1932 ----
Call un.StrStr
Pop ${L_TEMP}
+ StrCmp ${L_TEMP} "" 0 check_msg_folder
+ StrCpy ${L_SUBCORPUS} "no"
+
+ check_msg_folder:
+ StrCpy ${L_SUBHISTORY} "yes"
+
+ Push $INSTDIR
+ Call un.GetHistoryPath
+ Pop ${L_HISTORY}
+ Push ${L_HISTORY}
+ Push $INSTDIR
+ Call un.StrStr
+ Pop ${L_TEMP}
StrCmp ${L_TEMP} "" 0 check_if_running
! StrCpy ${L_SUBHISTORY} "no"
check_if_running:
***************
*** 1873,1894 ****
SetDetailsPrint listonly
- ; A quick test ignoring fact that popfile.cfg may specify a non-default location for PID file
-
- IfFileExists "$INSTDIR\popfile.pid" attempt_shutdown
-
; If the POPFile we are to uninstall is still running, one of the EXE files will be 'locked'
! IfFileExists "$INSTDIR\wperl.exe" 0 other_perl
! SetFileAttributes "$INSTDIR\wperl.exe" NORMAL
ClearErrors
! FileOpen ${L_CFG} "$INSTDIR\wperl.exe" a
FileClose ${L_CFG}
IfErrors attempt_shutdown
other_perl:
! IfFileExists "$INSTDIR\perl.exe" 0 remove_shortcuts
! SetFileAttributes "$INSTDIR\perl.exe" NORMAL
ClearErrors
! FileOpen ${L_CFG} "$INSTDIR\perl.exe" a
FileClose ${L_CFG}
IfErrors 0 remove_shortcuts
--- 1936,1955 ----
SetDetailsPrint listonly
; If the POPFile we are to uninstall is still running, one of the EXE files will be 'locked'
! StrCpy ${L_EXE} "$INSTDIR\wperl.exe"
! IfFileExists "${L_EXE}" 0 other_perl
! SetFileAttributes "${L_EXE}" NORMAL
ClearErrors
! FileOpen ${L_CFG} "${L_EXE}" a
FileClose ${L_CFG}
IfErrors attempt_shutdown
other_perl:
! StrCpy ${L_EXE} "$INSTDIR\perl.exe"
! IfFileExists "${L_EXE}" 0 remove_shortcuts
! SetFileAttributes "${L_EXE}" NORMAL
ClearErrors
! FileOpen ${L_CFG} "${L_EXE}" a
FileClose ${L_CFG}
IfErrors 0 remove_shortcuts
***************
*** 1897,1903 ****
StrCpy ${G_GUI} ""
StrCpy ${L_OLDUI} ""
!
ClearErrors
! FileOpen ${L_CFG} $INSTDIR\popfile.cfg r
loop:
--- 1958,1964 ----
StrCpy ${G_GUI} ""
StrCpy ${L_OLDUI} ""
!
ClearErrors
! FileOpen ${L_CFG} "$INSTDIR\popfile.cfg" r
loop:
***************
*** 1907,1911 ****
StrCpy ${L_TEMP} ${L_LNE} 10
StrCmp ${L_TEMP} "html_port " got_html_port
!
StrCpy ${L_TEMP} ${L_LNE} 8
StrCmp ${L_TEMP} "ui_port " got_ui_port
--- 1968,1972 ----
StrCpy ${L_TEMP} ${L_LNE} 10
StrCmp ${L_TEMP} "html_port " got_html_port
!
StrCpy ${L_TEMP} ${L_LNE} 8
StrCmp ${L_TEMP} "ui_port " got_ui_port
***************
*** 1919,1926 ****
StrCpy ${L_OLDUI} ${L_LNE} 5 8
Goto loop
!
ui_port_done:
FileClose ${L_CFG}
!
StrCmp ${G_GUI} "" use_other_port
Push ${G_GUI}
--- 1980,1987 ----
StrCpy ${L_OLDUI} ${L_LNE} 5 8
Goto loop
!
ui_port_done:
FileClose ${L_CFG}
!
StrCmp ${G_GUI} "" use_other_port
Push ${G_GUI}
***************
*** 1932,1938 ****
NSISdl::download_quiet http://127.0.0.1:${G_GUI}/shutdown "$PLUGINSDIR\shutdown.htm"
Pop ${L_TEMP}
! Sleep ${C_SHUTDOWN_DELAY}
! Goto remove_shortcuts
!
use_other_port:
Push ${L_OLDUI}
--- 1993,1998 ----
NSISdl::download_quiet http://127.0.0.1:${G_GUI}/shutdown "$PLUGINSDIR\shutdown.htm"
Pop ${L_TEMP}
! Goto check_shutdown
!
use_other_port:
Push ${L_OLDUI}
***************
*** 1944,1951 ****
NSISdl::download_quiet http://127.0.0.1:${L_OLDUI}/shutdown "$PLUGINSDIR\shutdown.htm"
Pop ${L_TEMP}
- Sleep ${C_SHUTDOWN_DELAY}
! remove_shortcuts:
SetDetailsPrint textonly
DetailPrint "$(un.PFI_LANG_PROGRESS_2)"
--- 2004,2013 ----
NSISdl::download_quiet http://127.0.0.1:${L_OLDUI}/shutdown "$PLUGINSDIR\shutdown.htm"
Pop ${L_TEMP}
! check_shutdown:
! Push ${L_EXE}
! Call un.WaitUntilUnlocked
+ remove_shortcuts:
SetDetailsPrint textonly
DetailPrint "$(un.PFI_LANG_PROGRESS_2)"
***************
*** 2066,2070 ****
StrCmp ${L_UPGRADE} "yes" remove_perl
! !insertmacro SafeRecursiveRMDir "$INSTDIR\messages"
remove_perl:
--- 2128,2132 ----
StrCmp ${L_UPGRADE} "yes" remove_perl
! RMDir /r "${L_HISTORY}"
remove_perl:
***************
*** 2115,2120 ****
!undef L_UPGRADE
!undef L_CORPUS
! !undef L_SUBFOLDER
!undef L_OLDUI
SectionEnd
--- 2177,2185 ----
!undef L_UPGRADE
!undef L_CORPUS
! !undef L_SUBCORPUS
!undef L_OLDUI
+ !undef L_HISTORY
+ !undef L_SUBHISTORY
+ !undef L_EXE
SectionEnd
Index: pfi-library.nsh
===================================================================
RCS file: /cvsroot/popfile/windows/pfi-library.nsh,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** pfi-library.nsh 1 Aug 2003 00:29:12 -0000 1.7
--- pfi-library.nsh 6 Aug 2003 16:34:32 -0000 1.8
***************
*** 97,101 ****
#--------------------------------------------------------------------------
#
! # Macro used by the uninstaller (guards against unexpectedly removing the corpus)
#
#--------------------------------------------------------------------------
--- 97,102 ----
#--------------------------------------------------------------------------
#
! # Macro used by the uninstaller
! # (guards against unexpectedly removing the corpus or message history)
#
#--------------------------------------------------------------------------
***************
*** 103,118 ****
!macro SafeRecursiveRMDir PATH
! ; if corpus is not in a subfolder, no precautions are needed
!
! StrCmp ${L_SUBFOLDER} "no" +6
Push ${L_CORPUS}
Push "${PATH}"
Call un.StrStr
! POP ${L_TEMP}
!
! ; if we are about to remove the path containing the corpus, skip the command
! StrCmp ${L_TEMP} "" 0 +2
RMDir /r "${PATH}"
!macroend
--- 104,127 ----
!macro SafeRecursiveRMDir PATH
! StrCmp ${L_SUBCORPUS} "no" +6 ; if "no" then goto pseudo-label A
Push ${L_CORPUS}
Push "${PATH}"
Call un.StrStr
! Pop ${L_TEMP}
! StrCmp ${L_TEMP} "" 0 +8 ; if not "" then goto pseudo-label C
! ; pseudo-label A
! StrCmp ${L_SUBHISTORY} "no" +6 ; if "no" then goto pseudo-label B
! Push ${L_HISTORY}
! Push "${PATH}"
! Call un.StrStr
! Pop ${L_TEMP}
! StrCmp ${L_TEMP} "" 0 +2 ; if not "" then goto pseudo-label C
!
! ; pseudo-label B
RMDir /r "${PATH}"
+
+ ; pseudo-label C
+
!macroend
***************
*** 212,219 ****
#
# This function is used by the uninstaller when uninstalling a previous version of POPFile.
! # It uses the 'corpus' parameter in 'popfile.cfg' file to determine the full path of the
! # directory where the corpus files are stored. By default POPFile stores the corpus in the
! # '$INSTDIR\corpus' directory but the 'popfile.cfg' file can define a different location, using
! # a variety of paths (eg relative, absolute, local or even remote).
#
# If 'popfile.cfg' is found in the specified folder, we use the corpus parameter (if present)
--- 221,228 ----
#
# This function is used by the uninstaller when uninstalling a previous version of POPFile.
! # It uses 'popfile.cfg' file to determine the full path of the directory where the corpus files
! # are stored. By default POPFile stores the corpus in the '$INSTDIR\corpus' directory but the
! # 'popfile.cfg' file can define a different location, using a variety of paths (eg relative,
! # absolute, local or even remote).
#
# If 'popfile.cfg' is found in the specified folder, we use the corpus parameter (if present)
***************
*** 242,246 ****
!define L_TEMP $R5
! Exch ${L_SOURCE} ; where we are supposed to look for the corpus data
Push ${L_RESULT}
Exch
--- 251,255 ----
!define L_TEMP $R5
! Exch ${L_SOURCE} ; where we are supposed to look for the 'popfile.cfg' file
Push ${L_RESULT}
Exch
***************
*** 305,308 ****
--- 314,424 ----
#--------------------------------------------------------------------------
+ # Function: un.GetHistoryPath
+ #
+ # This function is used by the uninstaller when uninstalling a previous version of POPFile.
+ # It uses 'popfile.cfg' file to determine the full path of the directory where the message
+ # history files are stored. By default POPFile stores these files in the '$INSTDIR\messages'
+ # directory but the 'popfile.cfg' file can define a different location, using a variety of
+ # paths (eg relative, absolute, local or even remote).
+ #
+ # If 'popfile.cfg' is found in the specified folder, we use the history parameter (if present)
+ # otherwise we assume the default location is to be used (the sub-folder called 'messages').
+ #
+ # Note that the path specified in 'popfile.cfg' uses a trailing slash (which we do not return)
+ #
+ # Inputs:
+ # (top of stack) - the path where 'popfile.cfg' is to be found
+ #
+ # Outputs:
+ # (top of stack) - string containing full (unambiguous) path to message history
+ #
+ # Usage Example:
+ # Push $INSTDIR
+ # Call un.GetHistoryPath
+ # Pop $R0
+ #
+ # ($R0 will be "C:\Program Files\POPFile\messages" if POPFile is installed in default
+ # location and if the history parameter in 'popfile.cfg' is set to 'messages/')
+ #--------------------------------------------------------------------------
+
+ Function un.GetHistoryPath
+
+ !define L_FILE_HANDLE $R9
+ !define L_HISTORY $R8
+ !define L_RESULT $R7
+ !define L_SOURCE $R6
+ !define L_TEMP $R5
+
+ Exch ${L_SOURCE} ; where we are supposed to look for the 'popfile.cfg' file
+ Push ${L_RESULT}
+ Exch
+ Push ${L_HISTORY}
+ Push ${L_FILE_HANDLE}
+ Push ${L_TEMP}
+
+ StrCpy ${L_HISTORY} ""
+
+ IfFileExists "${L_SOURCE}\popfile.cfg" 0 use_default_locn
+ ClearErrors
+ FileOpen ${L_FILE_HANDLE} "${L_SOURCE}\popfile.cfg" r
+
+ loop:
+ FileRead ${L_FILE_HANDLE} ${L_TEMP}
+ IfErrors cfg_file_done
+ StrCpy ${L_RESULT} ${L_TEMP} 7
+ StrCmp ${L_RESULT} "msgdir " got_old_msgdir
+ StrCpy ${L_RESULT} ${L_TEMP} 14
+ StrCmp ${L_RESULT} "GLOBAL_msgdir " got_new_msgdir
+ Goto loop
+
+ got_old_msgdir:
+ StrCpy ${L_HISTORY} ${L_TEMP} "" 7
+ Goto loop
+
+ got_new_msgdir:
+ StrCpy ${L_HISTORY} ${L_TEMP} "" 14
+ Goto loop
+
+ cfg_file_done:
+ FileClose ${L_FILE_HANDLE}
+ Push ${L_HISTORY}
+ Call un.TrimNewlines
+ Pop ${L_HISTORY}
+ StrCmp ${L_HISTORY} "" use_default_locn use_cfg_data
+
+ use_default_locn:
+ StrCpy ${L_RESULT} "${L_SOURCE}\messages"
+ Goto got_result
+
+ use_cfg_data:
+ StrCpy ${L_TEMP} ${L_HISTORY} 1 -1
+ StrCmp ${L_TEMP} "/" strip_slash no_trailing_slash
+ StrCmp ${L_TEMP} "\" 0 no_trailing_slash
+
+ strip_slash:
+ StrCpy ${L_HISTORY} ${L_HISTORY} -1
+
+ no_trailing_slash:
+ Push ${L_SOURCE}
+ Push ${L_HISTORY}
+ Call un.GetDataPath
+ Pop ${L_RESULT}
+
+ got_result:
+ Pop ${L_TEMP}
+ Pop ${L_FILE_HANDLE}
+ Pop ${L_HISTORY}
+ Pop ${L_SOURCE}
+ Exch ${L_RESULT} ; place full path of 'messages' directory on top of the stack
+
+ !undef L_FILE_HANDLE
+ !undef L_HISTORY
+ !undef L_RESULT
+ !undef L_SOURCE
+ !undef L_TEMP
+
+ FunctionEnd
+
+ #--------------------------------------------------------------------------
# Function: un.GetDataPath
#
***************
*** 311,315 ****
# 'C:\Program Files\POPFile' and 'corpus' into 'C:\Program Files\POPFile\corpus'.
#
! # It is assumed that the 'base directory' is in standard Windows format.
#
# The 'data folder' may be supplied in a variety of different formats, for example:
--- 427,431 ----
# 'C:\Program Files\POPFile' and 'corpus' into 'C:\Program Files\POPFile\corpus'.
#
! # It is assumed that the 'base directory' is in standard Windows format with no trailing slash.
#
# The 'data folder' may be supplied in a variety of different formats, for example:
***************
*** 362,365 ****
--- 478,482 ----
slashconversion:
+ StrCmp ${L_DATA} "." source_folder
Push ${L_DATA}
Call un.StrBackSlash ; ensure parameter uses backslashes
***************
*** 384,387 ****
--- 501,508 ----
Goto got_path
+ source_folder:
+ StrCpy ${L_DATA} ${L_BASEDIR}
+ Goto got_path
+
sub_folder:
StrCpy ${L_DATA} ${L_DATA} "" 2
***************
*** 538,542 ****
# (top of stack) - string starting with the match, if any
#
! # Usage:
# Push "this is a long string"
# Push "long"
--- 659,664 ----
# (top of stack) - string starting with the match, if any
#
! # Usage (after macro has been 'inserted'):
! #
# Push "this is a long string"
# Push "long"
***************
*** 618,622 ****
# (top of stack) - the input string (if valid) or "" (if invalid)
#
! # Usage:
# Push "12345"
# Call un.StrCheckDecimal
--- 740,745 ----
# (top of stack) - the input string (if valid) or "" (if invalid)
#
! # Usage (after macro has been 'inserted'):
! #
# Push "12345"
# Call un.StrCheckDecimal
***************
*** 707,711 ****
# (top of stack) - the input string with the trailing newlines (if any) removed
#
! # Usage:
# Push "whatever$\r$\n"
# Call un.TrimNewlines
--- 830,835 ----
# (top of stack) - the input string with the trailing newlines (if any) removed
#
! # Usage (after macro has been 'inserted'):
! #
# Push "whatever$\r$\n"
# Call un.TrimNewlines
***************
*** 753,756 ****
--- 877,953 ----
!insertmacro TrimNewlines "un."
+
+
+ #--------------------------------------------------------------------------
+ # Macro: WaitUntilUnlocked
+ #
+ # The installation process and the uninstall process both use a function which checks if
+ # either '$INSTDIR\wperl.exe' or $INSTDIR\perl.exe' is being used. It may take a little
+ # while for POPFile to shutdown so the installer/uninstaller calls this function which
+ # waits in a loop until the specified EXE file is no longer in use. A timeout counter
+ # is used to avoid an infinite loop.
+ #
+ # Inputs:
+ # (top of stack) - the full path of the EXE file to be checked
+ #
+ # Outputs:
+ # (none)
+ #
+ # Usage (after macro has been 'inserted'):
+ #
+ # Push "$INSTDIR\wperl.exe"
+ # Call WaitUntilUnlocked
+ #
+ #--------------------------------------------------------------------------
+
+ !macro WaitUntilUnlocked UN
+ Function ${UN}WaitUntilUnlocked
+ !define L_EXE $R9 ; full path to the EXE file which is to be monitored
+ !define L_FILE_HANDLE $R8
+ !define L_TIMEOUT $R7 ; used to avoid an infinite loop
+
+ Exch ${L_EXE}
+ Push ${L_FILE_HANDLE}
+ Push ${L_TIMEOUT}
+
+ IfFileExists "${L_EXE}" 0 exit_now
+ SetFileAttributes "${L_EXE}" NORMAL
+ StrCpy ${L_TIMEOUT} ${C_SHUTDOWN_LIMIT}
+
+ check_if_unlocked:
+ Sleep ${C_SHUTDOWN_DELAY}
+ ClearErrors
+ FileOpen ${L_FILE_HANDLE} "${L_EXE}" a
+ FileClose ${L_FILE_HANDLE}
+ IfErrors 0 exit_now
+ IntOp ${L_TIMEOUT} ${L_TIMEOUT} - 1
+ IntCmp ${L_TIMEOUT} 0 exit_now exit_now check_if_unlocked
+
+ exit_now:
+ Pop ${L_TIMEOUT}
+ Pop ${L_FILE_HANDLE}
+ Exch ${L_EXE}
+
+ !undef L_EXE
+ !undef L_FILE_HANDLE
+ !undef L_TIMEOUT
+ FunctionEnd
+ !macroend
+
+ #--------------------------------------------------------------------------
+ # Installer Function: WaitUntilUnlocked
+ #
+ # This function is used during the installation process
+ #--------------------------------------------------------------------------
+
+ !insertmacro WaitUntilUnlocked ""
+
+ #--------------------------------------------------------------------------
+ # Uninstaller Function: un.WaitUntilUnlocked
+ #
+ # This function is used during the uninstall process
+ #--------------------------------------------------------------------------
+
+ !insertmacro WaitUntilUnlocked "un."
#--------------------------------------------------------------------------
|