From: Brian S. <xue...@us...> - 2007-10-14 17:21:57
|
Update of /cvsroot/popfile/windows In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18029 Added Files: Tag: b0_22_2 getparser.nsh Log Message: Contains macro-based sections and functions for use by the installer and uninstaller when handling the selection and installation of the Nihongo (Japanese) parser. The files required for the Kakasi and internal parsers are contained in the installer/uninstaller but the MeCab files have to be downloaded (at ~13 MB they are too big to include in it). --- NEW FILE: getparser.nsh --- #-------------------------------------------------------------------------- # # getparser.nsh --- Japanese (Nihongo) text does not use spaces between words so # POPFile uses a 'Nihongo Parser' to split the text into words # to allow the text to be analysed properly. POPFile 0.22.5 # (and earlier) only supported the 'Kakasi' parser. The 1.0.0 # release offers a choice of three parsers (Kakasi, MeCab and # internal. To make it easier to change the Nihongo Parser # the 1.0.0 release creates a "Change" option in the "Add/Remove # Programs" entry for POPFile. This new option is handled by the # POPFile uninstaller. # # The 'MeCab' parser is too big (about 13 MB) to include in the # installer so it is downloaded from the Internet when the user # selects this parser. # # Since the installer and uninstaller both need to offer a choice # of Nihongo Parser and may need to download the MeCab files, this # INCLUDE file contains macro-based SECTION and FUNCTION definitions # to make future maintenance easier. # # Copyright (c) 2007 John Graham-Cumming # # This file is part of POPFile # # POPFile is free software; you can redistribute it and/or modify it # under the terms of version 2 of the GNU General Public License as # published by the Free Software Foundation. # # POPFile is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with POPFile; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # #-------------------------------------------------------------------------- ;------------------------------------------------ ; This script requires the 'Inetc' NSIS plugin ;------------------------------------------------ ; This script uses a special NSIS plugin (inetc) to download the SSL files. This plugin ; has much better proxy support than the standard NSISdl plugin shipped with NSIS. ; ; The 'NSIS Wiki' page for the 'Inetc' plugin (description, example and download links): ; http://nsis.sourceforge.net/Inetc_plug-in ; ; To compile this script, copy the 'inetc.dll' file to the standard NSIS plugins folder ; (${NSISDIR}\Plugins\). The 'Inetc' documentation, example & source files can be unzipped ; to the appropriate ${NSISDIR} sub-folders if you wish, but this step is entirely optional. ; ; Tested with the inetc.dll plugin timestamped 11 August 2007 19:06:24 ;------------------------------------------------ ; This script requires the 'md5dll' NSIS plugin ;------------------------------------------------ ; This script uses a special NSIS plugin (md5dll) to calculate the MD5 sum for a file. ; ; The 'NSIS Wiki' page for the 'md5dll' plugin (description, example and download links): ; http://nsis.sourceforge.net/MD5_plugin ; ; Alternative download links can be found at the 'md5dll' author's site: ; http://www.darklogic.org/win32/nsis/plugins/md5dll/ ; ; To compile this script, copy the 'md5dll.dll' file to the standard NSIS plugins folder ; (${NSISDIR}\Plugins\). The 'md5dll' source and example files can be unzipped to the ; appropriate ${NSISDIR} sub-folders if you wish, but this step is entirely optional. ; ; Tested with version 0.4 of the 'md5dll' plugin. ;------------------------------------------------ ; This script requires the 'untgz' NSIS plugin ;------------------------------------------------ ; This script uses a special NSIS plugin (untgz) to extract files from the *.tar.gz archives. ; ; The 'NSIS Wiki' page for the 'untgz' plugin (description, example and download links): ; http://nsis.sourceforge.net/UnTGZ_plug-in ; ; Alternative download links can be found at the 'untgz' author's site: ; http://www.darklogic.org/win32/nsis/plugins/ ; ; To compile this script, copy the 'untgz.dll' file to the standard NSIS plugins folder ; (${NSISDIR}\Plugins\). The 'untgz' documentation, example & source files can be unzipped ; to the appropriate ${NSISDIR} sub-folders if you wish, but this step is entirely optional. ; ; Tested with versions 1.0.5, 1.0.6, 1.0.7 and 1.0.8 of the 'untgz' plugin. #-------------------------------------------------------------------------- # URLs used to download the 'MeCab' parser support files from the POPFile # website (the Perl package, Windows binaries and the large dictionary files # are to big to include in the POPFile installer) #-------------------------------------------------------------------------- ; Temporarily use the "downloads" directory on the project's "new" server: !define C_NPD_MECAB_PERL "http://h1212143.stratoserver.net/downloads/MeCab.tar.gz" !define C_NPD_MECAB_DICT "http://h1212143.stratoserver.net/downloads/mecab-ipadic.zip" ;; !define C_NPD_MECAB_PERL "http://getpopfile.org/parser/MeCab.tar.gz" ;; !define C_NPD_MECAB_DICT "http://getpopfile.org/parser/mecab-ipadic.zip" #-------------------------------------------------------------------------- # User Registers (Global) #-------------------------------------------------------------------------- Var G_MECAB_FILEURL ; full URL used to download a MeCab file Var G_PLS_FIELD_2 ; used to customise translated text strings #============================================================================================== # # Macro-based Sections which may be used by the installer and uninstaller # # Macro: SECTION_NIHONGO_PARSER # Installer Section: Section "Nihongo Parser" SecParser # Uninstaller Section: un.Section "Nihongo Parser" un.SecParser # # Macro: SECTION_KAKASI # Installer Section: Section "-Kakasi" SecKakasi # Uninstaller Section: un.Section "-Kakasi" un.SecKakasi # # Macro: SECTION_MECAB # Installer Section: Section "-MeCab" SecMeCab # Uninstaller Section: un.Section "-MeCab" un.SecMeCab # # Macro: SECTION_INTERNALPARSER # Installer Section: Section "-Internal" SecInternalParser # Uninstaller Section: un.Section "-Internal" un.SecInternalParser # #============================================================================================== #-------------------------------------------------------------------------- # Macro: SECTION_NIHONGO_PARSER # # The installation process and the uninstall process both need a 'Nihongo Parser' # section which is listed on the COMPONENTS page when the Nihongo (Japanese) language # has been selected, otherwise it is hidden by the 'ShowOrHideNihongoParser' function # (or the equivalent uninstaller function). This macro makes maintenance easier by # ensuring that both processes do the same thing. # # If an English-only build of the installer or uninstaller is used then this section # must appear in the COMPONENTS page in case the user needs to install a parser. # # Note that this section must always be executed and must always come before # the sections for the 'Kakasi', 'MeCab' and 'Internal' Nihongo parsers as # it performs some essential initialisation. # #-------------------------------------------------------------------------- !macro SECTION_NIHONGO_PARSER UN Section "${UN}Nihongo Parser" ${UN}SecParser !if '${UN}' == 'un.' StrCmp $G_UNINST_MODE "uninstall" skip_section !endif SectionIn RO !insertmacro SECTIONLOG_ENTER "Nihongo Parser" DeleteRegValue HKLM "Software\POPFile Project\${C_PFI_PRODUCT}\MRI" "NihongoParser" DetailPrint "Removed the 'NihongoParser' setting from the registry (HKLM)" !insertmacro SECTIONLOG_EXIT "Nihongo Parser" !if '${UN}' == 'un.' skip_section: !endif SectionEnd !macroend #-------------------------------------------------------------------------- # Macro: SECTION_KAKASI # # The installation process and the uninstall process both need a section which # installs the 'Kakasi' parser, one of the three parsers supported by POPFile. # This macro makes maintenance easier by ensuring that both processes do the # same thing. # # Although the COMPONENTS page will show a 'Nihongo Parser' component when the # installer language is set to 'Nihongo' (or when an English-only build of the # installer or uninstaller is used), the individual parser components are never # shown on the COMPONENTS page. #-------------------------------------------------------------------------- !macro SECTION_KAKASI UN Section "-${UN}Kakasi" ${UN}SecKakasi !if '${UN}' == 'un.' StrCmp $G_UNINST_MODE "uninstall" skip_section !endif !insertmacro SECTIONLOG_ENTER "Kakasi" StrCmp $G_PARSER "kakasi" 0 do_nothing !define L_RESERVED $0 ; used in system.dll call Push ${L_RESERVED} ;-------------------------------------------------------------------------- ; Install Kakasi package ;-------------------------------------------------------------------------- SetOutPath "$G_ROOTDIR" File /r "${C_KAKASI_DIR}\kakasi" ; Add Environment Variables for Kakasi Push "ITAIJIDICTPATH" Push "$G_ROOTDIR\kakasi\share\kakasi\itaijidict" StrCmp $G_WINUSERTYPE "Admin" all_users_1 Call ${UN}PFI_WriteEnvStr Goto next_var all_users_1: Call ${UN}PFI_WriteEnvStrNTAU next_var: Push "KANWADICTPATH" Push "$G_ROOTDIR\kakasi\share\kakasi\kanwadict" StrCmp $G_WINUSERTYPE "Admin" all_users_2 Call ${UN}PFI_WriteEnvStr Goto set_env all_users_2: Call ${UN}PFI_WriteEnvStrNTAU set_env: IfRebootFlag set_vars_now ; Running on a non-Win9x system which already has the correct Kakasi environment data ; or running on a non-Win9x system Call ${UN}PFI_IsNT Pop ${L_RESERVED} StrCmp ${L_RESERVED} "0" continue ; Running on a non-Win9x system so we ensure the Kakasi environment variables ; are updated to match this installation set_vars_now: System::Call 'Kernel32::SetEnvironmentVariableA(t, t) \ i("ITAIJIDICTPATH", "$G_ROOTDIR\kakasi\share\kakasi\itaijidict").r0' StrCmp ${L_RESERVED} 0 0 itaiji_set_ok MessageBox MB_OK|MB_ICONSTOP "$(PFI_LANG_CONVERT_ENVNOTSET) (ITAIJIDICTPATH)" itaiji_set_ok: System::Call 'Kernel32::SetEnvironmentVariableA(t, t) \ i("KANWADICTPATH", "$G_ROOTDIR\kakasi\share\kakasi\kanwadict").r0' StrCmp ${L_RESERVED} 0 0 continue MessageBox MB_OK|MB_ICONSTOP "$(PFI_LANG_CONVERT_ENVNOTSET) (KANWADICTPATH)" continue: ;-------------------------------------------------------------------------- ; Install Perl modules: base.pm, bytes.pm, the Encode collection and Text::Kakasi ; (the requirement for bytes_heavy.pl was added when the minimal Perl was updated ; to use ActivePerl 5.8.7 components) ;-------------------------------------------------------------------------- SetOutPath "$G_MPLIBDIR" File "${C_PERL_DIR}\lib\base.pm" File "${C_PERL_DIR}\lib\bytes.pm" File "${C_PERL_DIR}\lib\bytes_heavy.pl" File "${C_PERL_DIR}\lib\Encode.pm" SetOutPath "$G_MPLIBDIR\Encode" File /r "${C_PERL_DIR}\lib\Encode\*" SetOutPath "$G_MPLIBDIR\auto\Encode" File /r "${C_PERL_DIR}\lib\auto\Encode\*" SetOutPath "$G_MPLIBDIR\Text" File "${C_PERL_DIR}\site\lib\Text\Kakasi.pm" SetOutPath "$G_MPLIBDIR\auto\Text\Kakasi" File "${C_PERL_DIR}\site\lib\auto\Text\Kakasi\*" WriteRegStr HKLM "Software\POPFile Project\${C_PFI_PRODUCT}\MRI" "NihongoParser" "$G_PARSER" Pop ${L_RESERVED} !undef L_RESERVED do_nothing: !insertmacro SECTIONLOG_EXIT "Kakasi" !if '${UN}' == 'un.' skip_section: !endif SectionEnd !macroend #-------------------------------------------------------------------------- # Macro: SECTION_MECAB # # The installation process and the uninstall process both need a section which # downloads and installs the 'MeCab' parser, one of the three parsers supported # by POPFile. This macro makes maintenance easier by ensuring that both processes # do the same thing. # # Although the COMPONENTS page will show a 'Nihongo Parser' component when the # installer language is set to 'Nihongo' (or when an English-only build of the # installer or uninstaller is used), the individual parser components are never # shown on the COMPONENTS page. #-------------------------------------------------------------------------- !macro SECTION_MECAB UN Section "-${UN}MeCab" ${UN}SecMeCab !if '${UN}' == 'un.' StrCmp $G_UNINST_MODE "uninstall" skip_section !endif !insertmacro SECTIONLOG_ENTER "MeCab" StrCmp $G_PARSER "mecab" 0 do_nothing ; The main installer does not contain the MeCab support files so we provide an estimate ; which includes a slack space allowance (based upon the development system's statistics) AddSize 43000 !define L_RESERVED $0 ; used in system.dll call !define L_RESULT $R0 ; result from 'GetSSLFile' function or the 'untgz' plugin ; WARNING: The 'untgz' plugin is hard-coded to use $R0 !define L_DLG_ITEM $R1 ; used to disable/enable the "Show Details" button !define L_LISTSIZE $R2 ; number of patches to be applied Push ${L_RESERVED} Push ${L_RESULT} Push ${L_DLG_ITEM} Push ${L_LISTSIZE} ; Unlike the NSISdl plugin shipped with NSIS, the Inetc plugin leaves the "Show Details" ; button in view so we temporarily disable it during the download to avoid a messy display ; (if the user has already clicked the button then they'll just need to put up with the mess) ; ; In order to avoid screen flicker effects as a result of downloading several files, we ; disable the button "for the duration" instead of disabling/enabling it for every transfer FindWindow ${L_DLG_ITEM} "#32770" "" $HWNDPARENT GetDlgItem ${L_DLG_ITEM} ${L_DLG_ITEM} 0x403 EnableWindow ${L_DLG_ITEM} 0 ; Download the MeCab archives Push "${C_NPD_MECAB_PERL}" Call ${UN}GetMeCabFile Pop ${L_RESULT} StrCmp ${L_RESULT} "OK" 0 installer_error_exit Push "${C_NPD_MECAB_DICT}" Call ${UN}GetMeCabFile Pop ${L_RESULT} StrCmp ${L_RESULT} "OK" 0 installer_error_exit ; Now install the files required for the MeCab parser StrCpy $G_PLS_FIELD_1 "$G_ROOTDIR\lib" DetailPrint "" CreateDirectory $G_PLS_FIELD_1 SetDetailsPrint both StrCpy $G_PLS_FIELD_2 "MeCab.tar.gz" DetailPrint "$(PFI_LANG_PROG_FILEEXTRACT)" SetDetailsPrint listonly untgz::extractFile -j -d "$G_PLS_FIELD_1" "$PLUGINSDIR\MeCab.tar.gz" "MeCab.pm" StrCmp ${L_RESULT} "success" 0 error_exit DetailPrint "" StrCpy $G_PLS_FIELD_1 "$G_ROOTDIR\lib\auto\MeCab" DetailPrint "" CreateDirectory $G_PLS_FIELD_1 SetDetailsPrint both StrCpy $G_PLS_FIELD_2 "MeCab.tar.gz" DetailPrint "$(PFI_LANG_PROG_FILEEXTRACT)" SetDetailsPrint listonly untgz::extractV -j -d "$G_PLS_FIELD_1" "$PLUGINSDIR\MeCab.tar.gz" -i "MeCab.bs" "MeCab.dll" -- StrCmp ${L_RESULT} "success" check_bs_file error_exit: SetDetailsPrint listonly DetailPrint "" SetDetailsPrint both DetailPrint "$(PFI_LANG_MB_UNPACKFAIL)" SetDetailsPrint listonly DetailPrint "" MessageBox MB_OK|MB_ICONSTOP "$(PFI_LANG_MB_UNPACKFAIL)" ; Enable the "Show Details" button now that we have stopped downloading files EnableWindow ${L_DLG_ITEM} 1 installer_error_exit: Push $R1 ; No need to preserve $R0 here as it is known as ${L_RESULT} in this 'Section' ; The first system call gets the full pathname (returned in $R0) and the second call ; extracts the filename (and possibly the extension) part (returned in $R1) System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024)' System::Call 'comdlg32::GetFileTitleA(t R0, t .R1, i 1024)' StrCpy $G_PLS_FIELD_1 $R1 MessageBox MB_OK|MB_ICONEXCLAMATION "${C_NPLS_REPEATMECAB}" Pop $R1 Goto exit check_bs_file: ; 'untgz' versions earlier than 1.0.6 (released 28 November 2004) are unable to extract ; empty files so this script creates the empty 'MeCab.bs' file if necessary IfFileExists "$G_PLS_FIELD_1\MeCab.bs" unpack_dictionaries File "/oname=$G_PLS_FIELD_1\MeCab.bs" "zerobyte.file" unpack_dictionaries: DetailPrint "" ZipDLL::extractall "$PLUGINSDIR\mecab-ipadic.zip" "$G_ROOTDIR" Pop ${L_RESULT} DetailPrint "" DetailPrint "Unzip result = ${L_RESULT}" ; Add the Environment Variable for MeCab Push "MECABRC" Push "$G_ROOTDIR\mecab\etc\mecabrc" StrCmp $G_WINUSERTYPE "Admin" all_users_1 Call ${UN}PFI_WriteEnvStr Goto set_env all_users_1: Call ${UN}PFI_WriteEnvStrNTAU set_env: IfRebootFlag set_vars_now ; Running on a non-Win9x system which already has the correct MeCab environment data ; or running on a non-Win9x system Call ${UN}PFI_IsNT Pop ${L_RESERVED} StrCmp ${L_RESERVED} "0" update_minPerl ; Running on a non-Win9x system so we ensure the MeCab environment variable ; is updated to match this installation set_vars_now: System::Call 'Kernel32::SetEnvironmentVariableA(t, t) \ i("MECABRC", "$G_ROOTDIR\mecab\etc\mecabrc").r0' StrCmp ${L_RESERVED} 0 0 update_minPerl MessageBox MB_OK|MB_ICONSTOP "$(PFI_LANG_CONVERT_ENVNOTSET) (MECABRC)" update_minPerl: ;-------------------------------------------------------------------------- ; Install additional Perl modules: base.pm, bytes.pm and the Encode collection ;-------------------------------------------------------------------------- SetOutPath "$G_MPLIBDIR" File "${C_PERL_DIR}\lib\base.pm" File "${C_PERL_DIR}\lib\bytes.pm" File "${C_PERL_DIR}\lib\bytes_heavy.pl" File "${C_PERL_DIR}\lib\Encode.pm" SetOutPath "$G_MPLIBDIR\Encode" File /r "${C_PERL_DIR}\lib\Encode\*" SetOutPath "$G_MPLIBDIR\auto\Encode" File /r "${C_PERL_DIR}\lib\auto\Encode\*" WriteRegStr HKLM "Software\POPFile Project\${C_PFI_PRODUCT}\MRI" "NihongoParser" "$G_PARSER" exit: SetDetailsPrint textonly DetailPrint "$(PFI_LANG_INST_PROG_ENDSEC)" SetDetailsPrint listonly Pop ${L_LISTSIZE} Pop ${L_DLG_ITEM} Pop ${L_RESULT} Pop ${L_RESERVED} !undef L_RESERVED !undef L_RESULT !undef L_DLG_ITEM !undef L_LISTSIZE do_nothing: !insertmacro SECTIONLOG_EXIT "MeCab" !if '${UN}' == 'un.' skip_section: !endif SectionEnd !macroend #-------------------------------------------------------------------------- # Macro: SECTION_INTERNALPARSER # # The installation process and the uninstall process both need a section which # installs the 'Internal' parser, one of the three parsers supported by POPFile. # This macro makes maintenance easier by ensuring that both processes do the # same thing. # # Although the COMPONENTS page will show a 'Nihongo Parser' component when the # installer language is set to 'Nihongo' (or when an English-only build of the # installer or uninstaller is used), the individual parser components are never # shown on the COMPONENTS page. #-------------------------------------------------------------------------- !macro SECTION_INTERNALPARSER UN Section "-${UN}Internal" ${UN}SecInternalParser !if '${UN}' == 'un.' StrCmp $G_UNINST_MODE "uninstall" skip_section !endif !insertmacro SECTIONLOG_ENTER "Internal Parser" StrCmp $G_PARSER "internal" 0 do_nothing SetDetailsPrint textonly DetailPrint "Internal parser selected during installation" SetDetailsPrint listonly ;-------------------------------------------------------------------------- ; Install Perl modules: base.pm, bytes.pm and the Encode collection ;-------------------------------------------------------------------------- SetOutPath "$G_MPLIBDIR" File "${C_PERL_DIR}\lib\base.pm" File "${C_PERL_DIR}\lib\bytes.pm" File "${C_PERL_DIR}\lib\bytes_heavy.pl" File "${C_PERL_DIR}\lib\Encode.pm" SetOutPath "$G_MPLIBDIR\Encode" File /r "${C_PERL_DIR}\lib\Encode\*" SetOutPath "$G_MPLIBDIR\auto\Encode" File /r "${C_PERL_DIR}\lib\auto\Encode\*" WriteRegStr HKLM "Software\POPFile Project\${C_PFI_PRODUCT}\MRI" "NihongoParser" "$G_PARSER" SetDetailsPrint textonly DetailPrint "$(PFI_LANG_INST_PROG_ENDSEC)" SetDetailsPrint listonly do_nothing: !insertmacro SECTIONLOG_EXIT "Internal Parser" !if '${UN}' == 'un.' skip_section: !endif SectionEnd !macroend #============================================================================================== # # Macro-based Functions which may be used by the installer and uninstaller # # Macro: FUNCTION_GETMECABFILE # Installer Function: GetMeCabFile # Uninstaller Function: un.GetMeCabFile # # Macro: FUNCTION_SHOW_OR_HIDE_NIHONGO_PARSER # Installer Function: ShowOrHideNihongoParser # Uninstaller Function: un.ShowOrHideNihongoParser # # Macro: FUNCTION_CHOOSEPARSER # Installer Function: ChooseParser # Uninstaller Function: un.ChooseParser # # Macro: FUNCTION_HANDLE_PARSER_SELECTION # Installer Function: HandleParserSelection # Uninstaller Function: un.HandleParserSelection # #============================================================================================== #-------------------------------------------------------------------------- # Macro: FUNCTION_GETMECABFILE # # The installation process and the uninstall process may both need a function which # downloads a single MeCab support file from the POPFile website. This macro makes # maintenance easier by ensuring that both processes use identical functions, with # the only difference being their names. # # Inputs: # (top of stack) - full URL used to download the MeCab file # # Outputs: # (top of stack) - status returned by the download plugin # # Usage (after macro has been 'inserted'): # # Push "http://www.example.com/download/MeCab.zip" # Call GetMeCabFile # Pop $0 # # ($R0 at this point is "OK" if the file was downloaded without any errors being detected) # #-------------------------------------------------------------------------- !define C_NSISDL_TRANSLATIONS "/TRANSLATE '$(PFI_LANG_NSISDL_DOWNLOADING)' '$(PFI_LANG_NSISDL_CONNECTING)' '$(PFI_LANG_NSISDL_SECOND)' '$(PFI_LANG_NSISDL_MINUTE)' '$(PFI_LANG_NSISDL_HOUR)' '$(PFI_LANG_NSISDL_PLURAL)' '$(PFI_LANG_NSISDL_PROGRESS)' '$(PFI_LANG_NSISDL_REMAINING)'" !macro FUNCTION_GETMECABFILE UN Function ${UN}GetMeCabFile Pop $G_MECAB_FILEURL StrCpy $G_PLS_FIELD_1 $G_MECAB_FILEURL Push $G_PLS_FIELD_1 Call ${UN}PFI_StrBackSlash Call ${UN}PFI_GetParent Pop $G_PLS_FIELD_2 StrLen $G_PLS_FIELD_2 $G_PLS_FIELD_2 IntOp $G_PLS_FIELD_2 $G_PLS_FIELD_2 + 1 StrCpy $G_PLS_FIELD_1 "$G_PLS_FIELD_1" "" $G_PLS_FIELD_2 StrCpy $G_PLS_FIELD_2 "$G_MECAB_FILEURL" $G_PLS_FIELD_2 DetailPrint "" DetailPrint "$(PFI_LANG_PROG_STARTDOWNLOAD)" inetc::get /CAPTION "Internet Download" /RESUME "${C_NPLS_CHECKINTERNET}" ${C_NSISDL_TRANSLATIONS} "$G_MECAB_FILEURL" "$PLUGINSDIR\$G_PLS_FIELD_1" /END Pop $G_PLS_FIELD_2 StrCmp $G_PLS_FIELD_2 "OK" file_received SetDetailsPrint both DetailPrint "$(PFI_LANG_MB_NSISDLFAIL_1)" SetDetailsPrint listonly DetailPrint "$(PFI_LANG_MB_NSISDLFAIL_2)" MessageBox MB_OK|MB_ICONEXCLAMATION "$(PFI_LANG_MB_NSISDLFAIL_1)${MB_NL}$(PFI_LANG_MB_NSISDLFAIL_2)" SetDetailsPrint listonly DetailPrint "" file_received: Push $G_PLS_FIELD_2 FunctionEnd !macroend #-------------------------------------------------------------------------- # Macro: FUNCTION_SHOW_OR_HIDE_NIHONGO_PARSER # # Called by 'PFIGUIInit', our custom '.onGUIInit' function (or 'un.PFIGUIInit', # our custom 'un.onGUIInit' function). # # The installation process and the uninstall process may both need a function which # ensures that when 'Nihongo' (Japanese) has been selected as the language for the # installer, 'Nihongo Parser' appears in the list of components. # # If any other language is selected, this component is hidden from view and the # three parser sections are disabled (i.e. unselected so nothing gets installed). # # The default parser is 'Kakasi', as used by POPFile 0.22.5 and earlier releases, # and this default is set up here, including the initial state of the three # radio buttons used on the "Choose Parser" custom page. # # Note that the 'Nihongo Parser' section is _always_ executed, even if the user # does not select the 'Nihongo' language. # # Note also that when an English-only build of the installer or uninstaller is # used then 'Nihongo Parser' must appear in the COMPONENTS page. # # This macro makes maintenance easier by ensuring that both processes use identical # functions, with the only difference being their names. #-------------------------------------------------------------------------- !macro FUNCTION_SHOW_OR_HIDE_NIHONGO_PARSER UN Function ${UN}ShowOrHideNihongoParser !ifndef ENGLISH_MODE StrCmp $LANGUAGE ${LANG_JAPANESE} select_default_parser ; The user has not selected 'Nihongo' language for this installation so there ; is no need to install a Nihongo parser. Make the 'Nihongo Parser' component ; invisible and disable the three sections used to install the Nihongo parsers. StrCpy $G_PARSER "" SectionSetText ${${UN}SecParser} "" ; this makes the component invisible !insertmacro UnselectSection ${${UN}SecKakasi} Goto deselect_other_parsers select_default_parser: !endif StrCpy $G_PARSER "kakasi" !insertmacro SelectSection ${${UN}SecKakasi} !insertmacro MUI_INSTALLOPTIONS_WRITE "ioP.ini" "Field 1" "State" "1" !ifndef ENGLISH_MODE deselect_other_parsers: !endif !insertmacro UnselectSection ${${UN}SecMeCab} !insertmacro MUI_INSTALLOPTIONS_WRITE "ioP.ini" "Field 2" "State" "0" !insertmacro UnselectSection ${${UN}SecInternalParser} !insertmacro MUI_INSTALLOPTIONS_WRITE "ioP.ini" "Field 3" "State" "0" FunctionEnd !macroend #-------------------------------------------------------------------------- # Macro: FUNCTION_CHOOSEPARSER # # Unlike English and many other languages, Japanese text does not use spaces to separate # the words so POPFile has to use a parser in order to analyse the words in a Japanese # message. The 1.0.0 release of POPFile is the first to offer a choice of parser (previous # releases of POPFile always used the "Kakasi" parser). # # Three parsers are currently supported: Internal, Kakasi and MeCab. The installer contains # all of the files needed for the first two but the MeCab parser uses a large dictionary # (a 12 MB download) which will be downloaded during installation if MeCab is selected. # # This macro makes maintenance easier by ensuring that the installer and uninstaller use # identical functions, with the only difference being their names. #-------------------------------------------------------------------------- !macro FUNCTION_CHOOSEPARSER UN Function ${UN}ChooseParser !ifndef ENGLISH_MODE ; If 'Nihongo' (Japanese) has been selected then we need to let the user choose which parser to install StrCmp $LANGUAGE ${LANG_JAPANESE} choose_parser StrCpy $G_PARSER "" Goto exit choose_parser: !endif StrCmp $G_SSL_ONLY "1" exit ; if we are only installing SSL support there is no need to display this page !insertmacro MUI_INSTALLOPTIONS_WRITE "ioP.ini" "Field 1" "Text" "${C_NPLS_Option_Kakasi}" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioP.ini" "Field 2" "Text" "${C_NPLS_Option_MeCab}" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioP.ini" "Field 3" "Text" "${C_NPLS_Option_Internal}" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioP.ini" "Field 5" "Text" "${C_NPLS_Note}" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioP.ini" "Field 6" "Text" "${C_NPLS_Link}" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioP.ini" "Field 6" "State" "${C_NPLS_Link}" Push '"${C_NPLS_DESC_Kakasi}"' Call ${UN}NSIS2IO Pop $G_PLS_FIELD_1 !insertmacro MUI_INSTALLOPTIONS_WRITE "ioP.ini" "Field 4" "State" "$G_PLS_FIELD_1" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioP.ini" "Field 4" "Flags" "${C_NPLS_DESC_Flags}" !insertmacro MUI_HEADER_TEXT "${C_NPLS_HEADER_ChooseParser}" "${C_NPLS_DESC_ChooseParser}" !insertmacro MUI_INSTALLOPTIONS_DISPLAY "ioP.ini" StrCmp $G_PARSER "kakasi" enable_Kakasi StrCmp $G_PARSER "mecab" enable_MeCab StrCmp $G_PARSER "internal" enable_Internal MessageBox MB_OK|MB_ICONEXCLAMATION "Internal Error:\ ${MB_NL}${MB_NL}\ Unexpected $$G_PARSER value ('$G_PARSER')\ ${MB_NL}${MB_NL}\ Defaulting to 'Kakasi' parser" StrCpy $G_PARSER "kakasi" Goto enable_Kakasi enable_Internal: !insertmacro UnselectSection ${${UN}SecKakasi} !insertmacro UnselectSection ${${UN}SecMeCab} !insertmacro SelectSection ${${UN}SecInternalParser} Goto exit enable_Kakasi: !insertmacro SelectSection ${${UN}SecKakasi} !insertmacro UnselectSection ${${UN}SecMeCab} !insertmacro UnselectSection ${${UN}SecInternalParser} Goto exit enable_MeCab: !insertmacro UnselectSection ${${UN}SecKakasi} !insertmacro SelectSection ${${UN}SecMeCab} !insertmacro UnselectSection ${${UN}SecInternalParser} exit: FunctionEnd !macroend #-------------------------------------------------------------------------- # Macro: FUNCTION_HANDLE_PARSER_SELECTION # # (the "leave" function for the Nihongo Parser selection page) # # Used to handle user input on the Nihongo Parser selection page. # # This macro makes maintenance easier by ensuring that the installer and # uninstaller use identical functions, with the only difference being their # names. #-------------------------------------------------------------------------- !macro FUNCTION_HANDLE_PARSER_SELECTION UN Function ${UN}HandleParserSelection !define L_SELECTION $R9 Push ${L_SELECTION} !insertmacro MUI_INSTALLOPTIONS_READ ${L_SELECTION} "ioP.ini" "Settings" "State" StrCmp ${L_SELECTION} 0 done ; "Next" button clicked !insertmacro MUI_INSTALLOPTIONS_READ $G_DLGITEM "ioP.ini" "Field 4" "HWND" StrCmp ${L_SELECTION} 1 kakasi StrCmp ${L_SELECTION} 2 mecab StrCmp ${L_SELECTION} 3 internal Goto return_to_page kakasi: StrCpy $G_PARSER "kakasi" SendMessage $G_DLGITEM ${WM_SETTEXT} 1 "STR:${C_NPLS_DESC_Kakasi}" Goto return_to_page mecab: StrCpy $G_PARSER "mecab" SendMessage $G_DLGITEM ${WM_SETTEXT} 1 "STR:${C_NPLS_DESC_MeCab}" Goto return_to_page internal: StrCpy $G_PARSER "internal" SendMessage $G_DLGITEM ${WM_SETTEXT} 1 "STR:${C_NPLS_DESC_Internal}" return_to_page: Pop ${L_SELECTION} Abort done: Pop ${L_SELECTION} !undef L_SELECTION FunctionEnd !macroend #-------------------------------------------------------------------------- # End of 'getparser.nsh' #-------------------------------------------------------------------------- |