📄 pidgin-installer.nsi
字号:
!insertmacro MUI_DESCRIPTION_TEXT ${SecSpellCheckGreek} \ "$(PIDGIN_SPELLCHECK_GREEK) (7.1Mb)" !insertmacro MUI_DESCRIPTION_TEXT ${SecSpellCheckEnglish} \ "$(PIDGIN_SPELLCHECK_ENGLISH) (2.3Mb)" !insertmacro MUI_DESCRIPTION_TEXT ${SecSpellCheckEsperanto} \ "$(PIDGIN_SPELLCHECK_ESPERANTO) (5.7Mb)" !insertmacro MUI_DESCRIPTION_TEXT ${SecSpellCheckSpanish} \ "$(PIDGIN_SPELLCHECK_SPANISH) (7.0Mb)" !insertmacro MUI_DESCRIPTION_TEXT ${SecSpellCheckFaroese} \ "$(PIDGIN_SPELLCHECK_FAROESE) (913kb)" !insertmacro MUI_DESCRIPTION_TEXT ${SecSpellCheckFrench} \ "$(PIDGIN_SPELLCHECK_FRENCH) (9.3Mb)" !insertmacro MUI_DESCRIPTION_TEXT ${SecSpellCheckItalian} \ "$(PIDGIN_SPELLCHECK_ITALIAN) (770kb)" !insertmacro MUI_DESCRIPTION_TEXT ${SecSpellCheckDutch} \ "$(PIDGIN_SPELLCHECK_DUTCH) (3.7Mb)" !insertmacro MUI_DESCRIPTION_TEXT ${SecSpellCheckNorwegian} \ "$(PIDGIN_SPELLCHECK_NORWEGIAN) (3.2Mb)" !insertmacro MUI_DESCRIPTION_TEXT ${SecSpellCheckPolish} \ "$(PIDGIN_SPELLCHECK_POLISH) (9.3Mb)" !insertmacro MUI_DESCRIPTION_TEXT ${SecSpellCheckPortuguese} \ "$(PIDGIN_SPELLCHECK_PORTUGUESE) (5.5Mb)" !insertmacro MUI_DESCRIPTION_TEXT ${SecSpellCheckRomanian} \ "$(PIDGIN_SPELLCHECK_ROMANIAN) (906kb)" !insertmacro MUI_DESCRIPTION_TEXT ${SecSpellCheckRussian} \ "$(PIDGIN_SPELLCHECK_RUSSIAN) (11Mb)" !insertmacro MUI_DESCRIPTION_TEXT ${SecSpellCheckSlovak} \ "$(PIDGIN_SPELLCHECK_SLOVAK) (8.0Mb)" !insertmacro MUI_DESCRIPTION_TEXT ${SecSpellCheckSwedish} \ "$(PIDGIN_SPELLCHECK_SWEDISH) (2.2Mb)" !insertmacro MUI_DESCRIPTION_TEXT ${SecSpellCheckUkrainian} \ "$(PIDGIN_SPELLCHECK_UKRAINIAN) (12Mb)"!insertmacro MUI_FUNCTION_DESCRIPTION_END;--------------------------------;Functions; Default the URI handler checkboxes if Pidgin is the current handler or if there is no handlerFunction SelectURIHandlerSelections Push $R0 Push $R1 Push $R2 Push $R3 ; Start with the first URI handler IntOp $R0 ${SecURIHandlers} + 1 start: ; If it is the end of the section group, stop SectionGetFlags $R0 $R1 IntOp $R2 $R1 & ${SF_SECGRPEND} IntCmp $R2 ${SF_SECGRPEND} done SectionGetText $R0 $R2 ;Strip the trailing ':' StrLen $R3 $R2 IntOp $R3 $R3 - 1 StrCpy $R2 $R2 $R3 ClearErrors ReadRegStr $R3 HKCR "$R2" "" IfErrors default_on ;there is no current handler ; Check if Pidgin is the current handler ClearErrors ReadRegStr $R3 HKCR "$R2\shell\Open\command" "" IfErrors end_loop ${WordFind} "$R3" "pidgin.exe" "E+1{" $R3 IfErrors end_loop default_on ;We default the URI handler checkbox on default_on: IntOp $R1 $R1 | ${SF_SELECTED} ; Select SectionSetFlags $R0 $R1 end_loop: IntOp $R0 $R0 + 1 ;Advance to the next section Goto start done: Pop $R3 Pop $R2 Pop $R1 Pop $R0FunctionEnd ;SelectURIHandlerSectionsFunction RegisterURIHandler Exch $R0 DeleteRegKey HKCR "$R0" WriteRegStr HKCR "$R0" "" "URL:$R0" WriteRegStr HKCR "$R0" "URL Protocol" "" WriteRegStr HKCR "$R0\DefaultIcon" "" "$INSTDIR\pidgin.exe" WriteRegStr HKCR "$R0\shell" "" "" WriteRegStr HKCR "$R0\shell\Open" "" "" WriteRegStr HKCR "$R0\shell\Open\command" "" "$INSTDIR\pidgin.exe --protocolhandler=%1" Pop $R0FunctionEnd!macro CheckUserInstallRightsMacro UNFunction ${UN}CheckUserInstallRights Push $0 Push $1 ClearErrors UserInfo::GetName IfErrors Win9x Pop $0 UserInfo::GetAccountType Pop $1 StrCmp $1 "Admin" 0 +3 StrCpy $1 "HKLM" Goto done StrCmp $1 "Power" 0 +3 StrCpy $1 "HKLM" Goto done StrCmp $1 "User" 0 +3 StrCpy $1 "HKCU" Goto done StrCmp $1 "Guest" 0 +3 StrCpy $1 "NONE" Goto done ; Unknown error StrCpy $1 "NONE" Goto done Win9x: StrCpy $1 "HKLM" done: Exch $1 Exch Pop $0FunctionEnd!macroend!insertmacro CheckUserInstallRightsMacro ""!insertmacro CheckUserInstallRightsMacro "un.";; Usage:; Push $0 ; Path string; Call VerifyDir; Pop $0 ; 0 - Bad path 1 - Good path;Function VerifyDir Exch $0 Push $1 Push $2 Loop: IfFileExists $0 dir_exists StrCpy $1 $0 ; save last ${GetParent} $0 $0 StrLen $2 $0 ; IfFileExists "C:" on xp returns true and on win2k returns false ; So we're done in such a case.. IntCmp $2 2 loop_done ; GetParent of "C:" returns "" IntCmp $2 0 loop_done Goto Loop loop_done: StrCpy $1 "$0\GaImFooB" ; Check if we can create dir on this drive.. ClearErrors CreateDirectory $1 IfErrors DirBad DirGood dir_exists: ClearErrors FileOpen $1 "$0\pidginfoo.bar" w IfErrors PathBad PathGood DirGood: RMDir $1 Goto PathGood1 DirBad: RMDir $1 Goto PathBad1 PathBad: FileClose $1 Delete "$0\pidginfoo.bar" PathBad1: StrCpy $0 "0" Push $0 Goto done PathGood: FileClose $1 Delete "$0\pidginfoo.bar" PathGood1: StrCpy $0 "1" Push $0 done: Exch 3 ; The top of the stack contains the output variable Pop $0 Pop $2 Pop $1FunctionEndFunction .onVerifyInstDir Push $0 Push $INSTDIR Call VerifyDir Pop $0 StrCmp $0 "0" 0 dir_good Pop $0 Abort dir_good: Pop $0FunctionEnd;; Usage:; Call DoWeNeedGtk; First Pop:; 0 - We have the correct version; Second Pop: Key where Version was found; 1 - We have an old version that should work, prompt user for optional upgrade; Second Pop: HKLM or HKCU depending on where GTK was found.; 2 - We have an old version that needs to be upgraded; Second Pop: HKLM or HKCU depending on where GTK was found.; 3 - We don't have Gtk+ at all; Second Pop: "NONE, HKLM or HKCU" depending on our rights..;Function DoWeNeedGtk ; Logic should be: ; - Check what user rights we have (HKLM or HKCU) ; - If HKLM rights.. ; - Only check HKLM key for GTK+ ; - If installed to HKLM, check it and return. ; - If HKCU rights.. ; - First check HKCU key for GTK+ ; - if good or bad exists stop and ret. ; - If no hkcu gtk+ install, check HKLM ; - If HKLM ver exists but old, return as if no ver exits. ; - If no rights ; - Check HKLM Push $0 Push $1 Push $2 Push $3 Call CheckUserInstallRights Pop $1 StrCmp $1 "HKLM" check_hklm StrCmp $1 "HKCU" check_hkcu check_hklm check_hkcu: ReadRegStr $0 HKCU ${GTK_REG_KEY} "Version" StrCpy $2 "HKCU" StrCmp $0 "" check_hklm have_gtk check_hklm: ReadRegStr $0 HKLM ${GTK_REG_KEY} "Version" StrCpy $2 "HKLM" StrCmp $0 "" no_gtk have_gtk have_gtk: ; GTK+ is already installed; check version. ; Change this to not even run the GTK installer if this version is already installed. ${VersionCompare} ${GTK_INSTALL_VERSION} $0 $3 IntCmp $3 1 +1 good_version good_version ${VersionCompare} ${GTK_MIN_VERSION} $0 $3 ; Bad version. If hklm ver and we have hkcu or no rights.. return no gtk StrCmp $1 "NONE" no_gtk ; if no rights.. can't upgrade StrCmp $1 "HKCU" 0 +2 ; if HKLM can upgrade.. StrCmp $2 "HKLM" no_gtk ; have hkcu rights.. if found hklm ver can't upgrade.. Push $2 IntCmp $3 1 +3 Push "1" ; Optional Upgrade Goto done Push "2" ; Mandatory Upgrade Goto done good_version: StrCmp $2 "HKLM" have_hklm_gtk have_hkcu_gtk have_hkcu_gtk: ; Have HKCU version ReadRegStr $0 HKCU ${GTK_REG_KEY} "Path" Goto good_version_cont have_hklm_gtk: ReadRegStr $0 HKLM ${GTK_REG_KEY} "Path" Goto good_version_cont good_version_cont: Push $0 ; The path to existing GTK+ Push "0" Goto done no_gtk: Push $1 ; our rights Push "3" Goto done done: ; The top two items on the stack are what we want to return Exch 4 Pop $1 Exch 4 Pop $0 Pop $3 Pop $2FunctionEnd!macro RunCheckMacro UNFunction ${UN}RunCheck Push $R0 System::Call 'kernel32::OpenMutex(i 2031617, b 0, t "pidgin_is_running") i .R0' IntCmp $R0 0 done MessageBox MB_OK|MB_ICONEXCLAMATION $(PIDGIN_IS_RUNNING) /SD IDOK Abort done: Pop $R0FunctionEnd!macroend!insertmacro RunCheckMacro ""!insertmacro RunCheckMacro "un."Function .onInit Push $R0 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "pidgin_installer_running") i .r1 ?e' Pop $R0 StrCmp $R0 0 +3 MessageBox MB_OK|MB_ICONEXCLAMATION $(INSTALLER_IS_RUNNING) /SD IDOK Abort Call RunCheck StrCpy $name "Pidgin ${PIDGIN_VERSION}" StrCpy $SPELLCHECK_SEL "" ;Try to copy the old Gaim installer Lang Reg. key ClearErrors ReadRegStr $R0 HKCU "${PIDGIN_REG_KEY}" "Installer Language" IfErrors 0 +5 ClearErrors ReadRegStr $R0 HKCU "SOFTWARE\gaim" "Installer Language" IfErrors +2 WriteRegStr HKCU "${PIDGIN_REG_KEY}" "Installer Language" "$R0" !insertmacro SetSectionFlag ${SecSpellCheck} ${SF_RO} !insertmacro UnselectSection ${SecSpellCheck} ;Mark the dictionaries that are already installed as readonly Call SelectAndDisableInstalledDictionaries ;Preselect the URI handlers as appropriate Call SelectURIHandlerSelections StrCpy $ISSILENT "/NOUI" ; GTK installer has two silent states.. one with Message boxes, one without ; If pidgin installer was run silently, we want to supress gtk installer msg boxes. IfSilent 0 set_gtk_normal StrCpy $ISSILENT "/S" set_gtk_normal: ${GetParameters} $R0 ClearErrors ${GetOptions} $R0 "/L=" $R0 IfErrors +3 StrCpy $LANGUAGE $R0 Goto skip_lang ; Select Language ; Display Language selection dialog !insertmacro MUI_LANGDLL_DISPLAY skip_lang: ; If install path was set on the command, use it. StrCmp $INSTDIR "" 0 instdir_done ; If pidgin or gaim is currently installed, we should default to where it is currently installed ClearErrors ReadRegStr $INSTDIR HKCU "${PIDGIN_REG_KEY}" "" IfErrors +2 StrCmp $INSTDIR "" 0 instdir_done ClearErrors ReadRegStr $INSTDIR HKLM "${PIDGIN_REG_KEY}" "" IfErrors +2 StrCmp $INSTDIR "" 0 instdir_done ;If we wanted to reuse the previous gaim installation dir, this would be the way to do it: ;ClearErrors ;ReadRegStr $INSTDIR HKCU "${OLD_GAIM_REG_KEY}" "" ;IfErrors +2 ;StrCmp $INSTDIR "" 0 instdir_done ;ClearErrors ;ReadRegStr $INSTDIR HKLM "${OLD_GAIM_REG_KEY}" "" ;IfErrors +2 ;StrCmp $INSTDIR "" 0 instdir_done Call CheckUserInstallRights Pop $R0 StrCmp $R0 "HKLM" 0 user_dir StrCpy $INSTDIR "$PROGRAMFILES\Pidgin" Goto instdir_done user_dir: Push $SMPROGRAMS ${GetParent} $SMPROGRAMS $R2 ${GetParent} $R2 $R2 StrCpy $INSTDIR "$R2\Pidgin"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -