!define SETUP_VERSION "1.0.0" !define NAME "KompoZer" !define YEAR "2007" !define VERSION "0.7.10" !define VERSION2 "0.7.10.0" !define PRODUCT_VERSION_PLUS "20070831" !define ADDRESS "http://kompozer.sourceforge.net/" !define GECKO_VERSION "1.7" !define PRODUCT_BUILD "${NAME} ${VERSION}" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" !define MOZILLA_REG_KEY "Software\Mozilla\${NAME}" !define CLASSNAME "#MozillaWindowClass" ;-------------------------------- ;Include Modern UI !include "MUI.nsh" !include "Sections.nsh" ;-------------------------------- ;General ;Default installation folder InstallDir "$PROGRAMFILES\${NAME}\" ;Get installation folder from registry if available InstallDirRegKey HKLM "${MOZILLA_REG_KEY}\bin" "PathToExe" SetCompressor /SOLID lzma SetDatablockOptimize on ShowInstDetails show AutoCloseWindow false SetOverwrite on BrandingText /TRIMRIGHT "${NAME} ${VERSION}" LicenseBkColor "ffffff" ;Name and file Name "${NAME} ${VERSION}" Caption $(INST_Caption) OutFile "${NAME}_${VERSION}.exe" ;-------------------------------- ;Version tab in properties VIProductVersion "${VERSION2}" VIAddVersionKey Comments "Installation de ${PRODUCT_BUILD}" VIAddVersionKey CompanyName "L'équipe de ${NAME}" VIAddVersionKey FileDescription "Installation de ${PRODUCT_BUILD}" VIAddVersionKey FileVersion "${PRODUCT_VERSION_PLUS}" VIAddVersionKey InternalName "${PRODUCT_BUILD}" VIAddVersionKey LegalCopyright "Copyright (C) ${YEAR} ${NAME} Team" VIAddVersionKey LegalTrademarks "${ADDRESS}" VIAddVersionKey Language "Français" VIAddVersionKey OriginalFilename "${NAME}${VERSION}.exe" VIAddVersionKey PrivateBuild "" VIAddVersionKey ProductName "${NAME}" VIAddVersionKey ProductVersion "${VERSION2}" VIAddVersionKey SpecialBuild "" ;---------------------------------------- ;Interface Settings !define MUI_ABORTWARNING !define MUI_ICON "${NAME}.ico" !define MUI_UNICON "uninstall.ico" !define MUI_CHECKBITMAP "${NSISDIR}\Contrib\Icons\modern.bmp" !define MUI_COMPONENTSPAGE_SMALLDESC !define MUI_NAME "${NAME} ${VERSION}" !define MUI_INSTALLCOLORS /windows !define MUI_PROGRESSBAR smooth !define MUI_INSTFILESPAGE_COLORS "000000 ffffff" ;Multiple settings ; Language Selection Dialog Settings !define MUI_LANGDLL_REGISTRY_ROOT HKLM !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}" !define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language" ; if the next line is uncommented, lang choice can be made manually ; !define MUI_LANGDLL_ALWAYSSHOW ;-------------------------------- ;Pages !define MUI_WELCOMEFINISHPAGE_BITMAP "${NAME}.bmp" !define MUI_UNWELCOMEFINISHPAGE_BITMAP "${NAME}.bmp" !define MUI_WELCOMEPAGE_TITLE $(INST_Welcome) !define MUI_WELCOMEPAGE_TEXT $(MUI_WELCOMEPAGE_TEXT) !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_LICENSE "license.txt" !insertmacro MUI_PAGE_COMPONENTS !define MUI_PAGE_CUSTOMFUNCTION_LEAVE DirectoryLeave !insertmacro MUI_PAGE_DIRECTORY !define MUI_PAGE_CUSTOMFUNCTION_LEAVE LangPackInstall !insertmacro MUI_PAGE_INSTFILES !define MUI_FINISHPAGE !define MUI_FINISHPAGE_NOAUTOCLOSE !define MUI_FINISHPAGE_RUN "$INSTDIR\${NAME}.exe" ;!define MUI_FINISHPAGE_RUN_PARAMETERS "$INSTDIR\readme.html" !insertmacro MUI_PAGE_FINISH !define MUI_UNINSTPAGE !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES ;-------------------------------- ; Language files ; !insertmacro MUI_LANGUAGE "English" ; !insertmacro MUI_LANGUAGE "German" ; !insertmacro MUI_LANGUAGE "Spanish" !insertmacro MUI_LANGUAGE "French" ;-------------------------------- ; Languages messages ; !include english.nlf !include french.nlf ; !include german.nlf ; !include spanish.nlf # ---------------------------------------------------------------------- Section ${NAME} SecMain SectionIn RO RMDir /r $INSTDIR SetOutPath "$INSTDIR" File /r .\kompoZer\*.* WriteRegStr HKLM ${MOZILLA_REG_KEY} "default" ${VERSION} WriteRegStr HKLM ${MOZILLA_REG_KEY} "GeckoVer" ${GECKO_VERSION} WriteRegStr HKLM "${MOZILLA_REG_KEY}\bin" "PathToExe" "$INSTDIR" WriteRegStr HKLM "${MOZILLA_REG_KEY}\Extensions" "Plugins" "$INSTDIR\Plugins" WriteRegStr HKLM "${MOZILLA_REG_KEY}\Extensions" "Components" "$INSTDIR\Components" WriteUninstaller $INSTDIR\uninstall.exe WriteRegStr HKLM ${PRODUCT_UNINST_KEY} "DisplayName" $(UN_Title) WriteRegStr HKLM ${PRODUCT_UNINST_KEY} "UninstallString" "$INSTDIR\uninstall.exe" WriteRegStr HKLM ${PRODUCT_UNINST_KEY} "DisplayIcon" "$INSTDIR\${NAME}.exe,0" WriteRegStr HKLM ${PRODUCT_UNINST_KEY} "DisplayVersion" "${VERSION}" WriteRegStr HKLM ${PRODUCT_UNINST_KEY} "InstallLocation" "$INSTDIR" WriteRegStr HKLM ${PRODUCT_UNINST_KEY} "NoModify" "1" WriteRegStr HKLM ${PRODUCT_UNINST_KEY} "NoRepair" "1" WriteRegStr HKLM ${PRODUCT_UNINST_KEY} "Publisher" "${NAME} Team" WriteRegStr HKLM ${PRODUCT_UNINST_KEY} "HelpLink" ${ADDRESS} WriteRegStr HKLM ${PRODUCT_UNINST_KEY} "URLInfoAbout" ${ADDRESS} WriteRegStr HKLM ${PRODUCT_UNINST_KEY} "URLUpdateInfo" ${ADDRESS} SectionEnd # ---------------------------------------------------------------------- Section $(SECT_ContextMenu) SecContextMenu ReadRegStr $0 HKCR ".html" "" WriteRegStr HKCR "$0\shell\edit" "" "$(EditTitle)" WriteRegStr HKCR "$0\shell\edit\command" "" '"$INSTDIR\${NAME}.exe" -edit "%1"' SectionEnd # ---------------------------------------------------------------------- SubSection /e $(SECT_CreateShortcut) SecShortcuts Section /o $(SECT_WSShortcut) SecDesktop CreateShortCut "$DESKTOP\${NAME}.lnk" "$INSTDIR\${NAME}.exe" "" "" 0 SectionEnd Section $(SECT_SMShortcut) SecStartMenu CreateDirectory "$SMPROGRAMS\${NAME}" CreateShortCut "$SMPROGRAMS\${NAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 CreateShortCut "$SMPROGRAMS\${NAME}\${NAME}.lnk" "$INSTDIR\${NAME}.exe" "" "$INSTDIR\${NAME}.exe" 0 SectionEnd Section /o $(SECT_QLShortcut) SecQuickLaunch CreateShortCut "$QUICKLAUNCH\${NAME}.lnk" "$INSTDIR\${NAME}.exe" "" "" 0 SectionEnd SubSectionEnd # ---------------------------------------------------------------------- UninstallText $(UN_confirm) Section Uninstall Call un.CloseKompoZer Sleep 1000 RMdir /r $INSTDIR DeleteRegKey HKLM ${PRODUCT_UNINST_KEY} DeleteRegKey HKLM ${MOZILLA_REG_KEY} Delete $DESKTOP\${NAME}.lnk RMDir /r $SMPROGRAMS\${NAME} Delete "$QUICKLAUNCH\${NAME}.lnk" SetShellVarContext all Delete $DESKTOP\${NAME}.lnk RMDir /r $SMPROGRAMS\${NAME} Delete "$QUICKLAUNCH\${NAME}.lnk" goto UnEnd UnEnd: SectionEnd ;-------------------------------- ; Search for text in file function, based on ; http://nsis.sourceforge.net/Search_for_text_in_file Function SimpleFileSearch Exch $R0 ;search for Exch Exch $R1 ; input file Push $R2 ; file handle Push $R3 ; current line Push $R4 ; search lenght Push $R5 ; position in line Push $R6 ; string to compare with input Push $R9 ; boolean : string found StrLen $R4 $R0 ; search lenght StrCpy $R9 0 ; string not found (yet) ClearErrors FileOpen $R2 $R1 r ; $r2 = file handle IfErrors Done LoopRead: ClearErrors FileRead $R2 $R3 ; $r3 = current line IfErrors DoneRead IntOp $R7 $R7 + 1 ; inc $r7 StrCpy $R5 -1 ; $r5 = -1 LoopParse: IntOp $R5 $R5 + 1 ; inc position in line (first value is 0) StrCpy $R6 $R3 $R4 $R5 ; $r6 = $r3[strlen, starting at position $r5] StrCmp $R6 "" 0 +2 ; if $r6 is empty, continue Goto LoopRead ; restart at next line StrCmp $R6 $R0 0 LoopParse ; if string found, continue, else go to next char StrCpy $R9 1 ; string found DoneRead: FileClose $R2 Done: StrCpy $R0 $R9 Pop $R9 Pop $R6 Pop $R5 Pop $R4 Pop $R3 Pop $R2 Pop $R1 Exch $R0 ; output found FunctionEnd ;-------------------------------- ; Slash to backslash converter ; http://nsis.sourceforge.net/Another_String_Replace_(and_Slash/BackSlash_Converter) Function StrSlash Exch $R3 ; $R3 = needle ("\" or "/") Exch Exch $R1 ; $R1 = String to replacement in (haystack) Push $R2 ; Replaced haystack Push $R4 ; $R4 = not $R3 ("/" or "\") Push $R6 Push $R7 ; Scratch reg StrCpy $R2 "" StrLen $R6 $R1 StrCpy $R4 "\" StrCmp $R3 "/" loop StrCpy $R4 "/" loop: StrCpy $R7 $R1 1 StrCpy $R1 $R1 $R6 1 StrCmp $R7 $R3 found StrCpy $R2 "$R2$R7" StrCmp $R1 "" done loop found: StrCpy $R2 "$R2$R4" StrCmp $R1 "" done loop done: StrCpy $R3 $R2 Pop $R7 Pop $R6 Pop $R4 Pop $R2 Pop $R1 Exch $R3 FunctionEnd ;-------------------------------- ; Close KompoZer Functions ; Don't works with Kompozer and all Mozilla products, because of the ; class name, and the window name structure. Function CloseKompoZer Push $0 loop1: FindWindow $0 "${CLASSNAME}" IntCmp $0 0 done SendMessage $0 16 0 0 Sleep 200 Goto loop1 done: Pop $0 FunctionEnd Function un.CloseKompoZer Push $0 un_loop1: FindWindow $0 "${CLASSNAME}" IntCmp $0 0 done SendMessage $0 16 0 0 Sleep 200 Goto un_loop1 done: Sleep 1000 Pop $0 FunctionEnd ;-------------------------------- Function .onInit ; !insertmacro MUI_LANGDLL_DISPLAY ; Uncomment for multi language installer ; !insertmacro MUI_INSTALLOPTIONS_EXTRACT "profpage.ini" FindWindow $0 "${CLASSNAME}" StrCmp $0 "0" NoKompoZerRunning 0 MessageBox MB_OKCANCEL|MB_ICONSTOP $(INIT_KompoZerRunning) IDCANCEL 0 IDOK CloseKompoZ Abort CloseKompoZ: Call CloseKompoZer NoKompoZerRunning: ; MessageBox MB_OK "${CLASSNAME}$\n$0" 0 0 ; MessageBox MB_OK "Aucune fenêtre de KompoZer n'a été trouvée,$\nCe qui est malheureusement le cas, même quand c'est faux!!$\n$\n A débugger ...$\n$\nVoir valeur de la constante $CLASSNAME" 0 0 Var /GLOBAL ProfilesIniDir ; Search for existing profiles.ini, first in Application Data, then in Local Settings\Application Data Push "$APPDATA\${NAME}" IfFileExists "$APPDATA\${NAME}\profiles.ini" ProfileExists 0 IfFileExists "$LOCALAPPDATA\${NAME}\profiles.ini" 0 NoProfile Pop $ProfilesIniDir Push "$LOCALAPPDATA\${NAME}" ProfileExists: Pop $ProfilesIniDir ;MessageBox MB_OK "profile.ini exists at $ProfilesIni." IfErrors 0 +2 MessageBox MB_OK "An error occured locating profiles.ini" ClearErrors ; reads profile information ReadINIStr $0 "$ProfilesIniDir\profiles.ini" "Profile0" "IsRelative" IfErrors 0 +2 MessageBox MB_OK "An error occured reading profiles.ini " StrCmp $0 "1" ProfileIsRelative StrCmp $0 "0" ProfileIsAbsolute ProfileError ProfileIsRelative: ;MessageBox MB_OK "Profile is relative." ReadINIStr $0 "$ProfilesIniDir\profiles.ini" "Profile0" "Path" IfFileExists "$ProfilesIniDir\$0\extensions\extensions.rdf" 0 ExtensionsRdfNotfound Push "$ProfilesIniDir\$0\extensions\Extensions.rdf" Goto CheckExtensionsRdf ProfileIsAbsolute: ;MessageBox MB_OK "Profile is absolute." ReadINIStr $0 "$ProfilesIniDir\profiles.ini" "Profile0" "Path" IfFileExists "$0\extensions\Extensions.rdf" 0 ExtensionsRdfNotfound Push "$0\extensions\extensions.rdf" CheckExtensionsRdf: ; Converts the slashes in backslashes in the file path Push "/" Call StrSlash ; searches for "frenchlocale" in the converted path (still on top of the stack) Push "frenchlocale" Call SimpleFileSearch Pop $0 ; says if the string was found StrCmp $0 1 LangPackFound NoLangPack ExtensionsRdfNotFound: MessageBox MB_OK "The file extensions.rdf does not exist" Goto NoLangPack ProfileError: MessageBox MB_OK "There was an error reading profile.ini (invalid or no value for IsRelative)" Goto NoLangPack LangPackFound: ; Display a message to warn about the necessity to uninstall langpacks before setting up. ; After, KompoZer ought to solve this problem. ; If KompoZer already exists in the installation directory, the user can still uninstall the langpack manually IfFileExists "$INSTDIR\${NAME}.exe" 0 ProfileButKzNotFound MessageBox MB_OKCANCEL|MB_ICONSTOP $(LangPack) IDCANCEL 0 IDOK NoLangPack FileOpen $1 "$INSTDIR\warning.html" "w" FileWrite $1 '' FileWriteByte $1 "13" FileWriteByte $1 "10" FileWrite $1 '' FileWriteByte $1 "13" FileWriteByte $1 "10" FileWrite $1 '
' FileWriteByte $1 "13" FileWriteByte $1 "10" FileWrite $1 '' FileWriteByte $1 "13" FileWriteByte $1 "10" FileWrite $1 '