MbedTLS: Use mbedtls_md5_ret() instead of mbedtls_md5()
[privoxy.git] / windows / privoxy_winthreads.nsi
1 ;
2 ; File:
3 ;   $Source: /cvsroot/ijbswa/winsetup/privoxy_winthreads.nsi,v $
4 ;
5 ; Purpose:
6 ;   NSIS script to make the Privoxy installer
7 ;
8 ;   This .NSI script is designed for NSIS v2.24+
9 ;
10 ;   Get NSIS from:  http://www.nullsoft.com/free/nsis/
11 ;
12 ; Copyright:
13 ;   Written by and Copyright (C) 2007-2009 the Privoxy team.
14 ;   https://www.privoxy.org/
15 ;
16 ;   This script originally written by and Copyright (C) 2002
17 ;   Jonathan Foster
18 ;
19 ;   This program is free software; you can redistribute it 
20 ;   and/or modify it under the terms of the GNU General
21 ;   Public License as published by the Free Software
22 ;   Foundation; either version 2 of the License, or (at
23 ;   your option) any later version.
24 ;
25 ;   This program is distributed in the hope that it will
26 ;   be useful, but WITHOUT ANY WARRANTY; without even the
27 ;   implied warranty of MERCHANTABILITY or FITNESS FOR A
28 ;   PARTICULAR PURPOSE.  See the GNU General Public
29 ;   License for more details.
30 ;
31 ;   The GNU General Public License should be included with
32 ;   this file.  If not, you can view it at
33 ;   http://www.gnu.org/copyleft/gpl.html
34 ;   or write to the Free Software Foundation, Inc., 59
35 ;   Temple Place - Suite 330, Boston, MA  02111-1307, USA.
36 ;
37
38 !include WinMessages.nsh ; to send close message to Privoxy process
39
40 !define NL "$\r$\n"
41
42 Var /GLOBAL UpdateExisting
43
44 ;win7 RequestExecutionLevel admin
45
46
47 ; Close Privoxy and wait for termination
48 ;
49 !macro ClosePrivoxy
50         ;Close privoxy.exe
51         FindWindow $R0 "PrivoxyLogOwner"
52         IntCmpU $R0 0 NoPrivoxyRunning 0 0
53         SendMessage $R0 ${WM_CLOSE} 0 0
54         ; wait for close
55         StrCpy $R1 0
56 CheckWindowClosed:
57         Sleep 200 ; avoid file in use error
58         FindWindow $R0 "PrivoxyLogOwner"
59         IntCmpU $R0 0 NoPrivoxyRunning 0 0
60         IntOp $R1 $R1 + 1
61         IntCmp $R1 20 0 CheckWindowClosed 0
62         Sleep 200 ; avoid file in use error
63 NoPrivoxyRunning:
64 !macroend
65
66
67 ; create a backup file if file exists, set $UpdateExisting on existing files
68 ;
69 !macro BackupOLD Name BackupName
70         !define UniqueID ${__LINE__}
71
72         IfFileExists "$INSTDIR\${Name}"  0 skip_${UniqueID}
73         StrCpy $UpdateExisting 1
74         delete "$INSTDIR\${BackupName}"
75         rename "$INSTDIR\${Name}" "$INSTDIR\${BackupName}"
76 skip_${UniqueID}:
77
78         !undef UniqueID
79 !macroend
80
81
82 ; check file, write new one to different target there is one, set $UpdateExisting on existing files
83 ;
84 !macro KeepCur Name DefaultName SrcDir
85         !define UniqueID ${__LINE__}
86
87         IfFileExists "$INSTDIR\${Name}" 0 new_${UniqueID}
88         StrCpy $UpdateExisting 1
89         delete "$INSTDIR\${DefaultName}"
90         File "/oname=${DefaultName}" "${SrcDir}${Name}"
91         goto done_${UniqueID}
92
93 new_${UniqueID}:
94         File "${SrcDir}${Name}"
95
96 done_${UniqueID}:
97
98         !undef UniqueID
99 !macroend
100
101
102 Name "Privoxy"
103 OutFile "privoxy_setup.exe"
104
105 BGGradient off
106
107 ; Some default compiler settings (uncomment and change at will):
108 SetCompress auto ; (can be off or force)
109 SetCompressor /FINAL /SOLID lzma
110 SetDatablockOptimize on
111 CRCCheck on
112 AutoCloseWindow true ; (can be true for the window go away automatically at end)
113 ShowInstDetails nevershow ; (can be show to have them shown, or nevershow to disable)
114 SetDateSave on ; (can be on to have files restored to their orginal date)
115 ; SetOverwrite ifnewer ; (files are only overwritten if the existing file is older than the new file)
116 SetOverwrite on  ; install package files over-write existing files regardless of date
117
118 Icon "privoxy.ico"
119 UninstallIcon "uninstall_privoxy.ico"
120
121 #LicenseText "Privoxy is distributed under the GNU General Public License.  Please read it before you install."
122 #LicenseData "build/LICENSE.txt"
123
124 InstallDir "$PROGRAMFILES\Privoxy"
125 ;InstallDirRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Privoxy.org\Privoxy" ""
126 ;DirShow show ; (make this hide to not let the user change it)
127 ;DirShow doesn't currently work.
128 DirText "Select the directory to install Privoxy in:"
129
130 ComponentText "Please select how you want to start Privoxy:"
131
132 Section "" ; (default section)
133         StrCpy $UpdateExisting 0
134
135         ; Close privoxy.exe if it is running (user is upgrading) to prevent in-use errors.
136         !insertmacro ClosePrivoxy
137
138         ; add files / whatever that need to be installed here.
139         SetOutPath "$INSTDIR"
140
141         ; save files the user might have changed
142         ;   config.txt  match-all.action  trust.txt
143         ;
144         !insertmacro BackupOLD "config.txt" "old_config.txt"
145         !insertmacro BackupOLD "match-all.action" "old_match-all.action";
146         !insertmacro BackupOLD "trust.txt" "old_trust.txt"
147
148         ;File /r build\*.*
149
150         ; leave user.action and user.filter alone if they exist
151         ;
152         !insertmacro KeepCur "user.action" "clean_user.action" "build\"
153         !insertmacro KeepCur "user.filter" "clean_user.filter" "build\"
154         ; exclude all files handled by KeepCur
155         File /r /x CVS /x user.action /x user.filter build\*.*
156
157         ;WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Privoxy.org\Privoxy" "" "$INSTDIR"
158         WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\Privoxy" "DisplayName" "Privoxy (remove only)"
159         WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\Privoxy" "UninstallString" '"$INSTDIR\privoxy_uninstall.exe"'
160
161         WriteRegStr HKEY_CLASSES_ROOT "PrivoxyActionFile\shell\open\command" "" 'Notepad.exe "%1"'
162         WriteRegStr HKEY_CLASSES_ROOT ".action" "" "PrivoxyActionFile"
163         WriteRegStr HKEY_CLASSES_ROOT "PrivoxyFilterFile\shell\open\command" "" 'Notepad.exe "%1"'
164         WriteRegStr HKEY_CLASSES_ROOT ".filter" "" "PrivoxyFilterFile"
165
166         WriteUninstaller "privoxy_uninstall.exe"
167 SectionEnd
168
169 Section "Add to Start Menu"
170         SetShellVarContext all ; (Add to "All Users" Start Menu if possible)
171         RMDir /r "$SMPROGRAMS\Privoxy"
172         CreateDirectory "$SMPROGRAMS\Privoxy"
173         CreateShortCut "$SMPROGRAMS\Privoxy\Privoxy.lnk" "$INSTDIR\privoxy.exe"
174         WriteINIStr "$SMPROGRAMS\Privoxy\Web-based Configuration.url" "InternetShortcut" "URL" "http://config.privoxy.org/"
175         CreateShortCut "$SMPROGRAMS\Privoxy\Web-based Feedback.lnk" "$INSTDIR\doc\user-manual\contact.html"
176         CreateDirectory "$SMPROGRAMS\Privoxy\Edit Config"
177         CreateShortCut "$SMPROGRAMS\Privoxy\Edit Config\Main Configuration.lnk" "Notepad.exe" '"$INSTDIR\config.txt"'
178         CreateShortCut "$SMPROGRAMS\Privoxy\Edit Config\Default Actions.lnk" "Notepad.exe" '"$INSTDIR\default.action"'
179         CreateShortCut "$SMPROGRAMS\Privoxy\Edit Config\User Actions.lnk" "Notepad.exe" '"$INSTDIR\user.action"'
180         CreateShortCut "$SMPROGRAMS\Privoxy\Edit Config\Filters.lnk" "Notepad.exe" '"$INSTDIR\default.filter"'
181         CreateShortCut "$SMPROGRAMS\Privoxy\Edit Config\Trust list.lnk" "Notepad.exe" '"$INSTDIR\trust.txt"'
182         CreateDirectory "$SMPROGRAMS\Privoxy\Documentation"
183         CreateShortCut "$SMPROGRAMS\Privoxy\Documentation\User Manual.lnk" "$INSTDIR\doc\user-manual\index.html"
184         CreateShortCut "$SMPROGRAMS\Privoxy\Documentation\Frequently Asked Questions.lnk" "$INSTDIR\doc\faq\index.html"
185         CreateShortCut "$SMPROGRAMS\Privoxy\Documentation\Credits.lnk" "Notepad.exe" '"$INSTDIR\AUTHORS.txt"'
186         CreateShortCut "$SMPROGRAMS\Privoxy\Documentation\License.lnk" "Notepad.exe" '"$INSTDIR\LICENSE.txt"'
187         CreateShortCut "$SMPROGRAMS\Privoxy\Documentation\ReadMe file.lnk" "Notepad.exe" '"$INSTDIR\README.txt"'
188         WriteINIStr "$SMPROGRAMS\Privoxy\Documentation\Web Site.url" "InternetShortcut" "URL" "http://privoxy.org/"
189         CreateShortCut "$SMPROGRAMS\Privoxy\Uninstall Privoxy.lnk" "$INSTDIR\privoxy_uninstall.exe"
190 SectionEnd
191
192
193 Section "Run automatically at startup"
194         CreateShortCut "$SMSTARTUP\Privoxy.lnk" "$INSTDIR\privoxy.exe" "" "" 0 SW_SHOWMINIMIZED
195 SectionEnd
196
197
198 Function .onInstSuccess
199         ; on successful install, show message then start it
200         IntCmp $UpdateExisting 0  0 updated updated
201         MessageBox MB_YESNO|MB_DEFBUTTON1|MB_ICONQUESTION "Privoxy has been installed.${NL}${NL}Start Privoxy now?" /SD IDNO IDYES execprivoxy IDNO done
202         goto done
203 updated:
204         MessageBox MB_YESNO|MB_DEFBUTTON1|MB_ICONEXCLAMATION "Privoxy has been updated.${NL}Don't forget to convert configuration from the 'old*' files!${NL}${NL}Start Privoxy now?" /SD IDNO IDYES execprivoxy IDNO done
205         goto done
206 execprivoxy:
207         ; run privoxy after installation
208         SetOutPath "$INSTDIR"
209
210         Exec "$INSTDIR\privoxy.exe"
211 done:
212 FunctionEnd
213
214
215 ; begin uninstall settings/section. The UninstallText line must be before the Section header.
216 ;
217 UninstallText "This will uninstall Privoxy from your system"
218 Section Uninstall
219         SetShellVarContext all ; (Remove from "All Users" Start Menu if possible)
220         
221         ;DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Privoxy.org\Privoxy"
222         DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Privoxy"
223
224         DeleteRegKey HKEY_CLASSES_ROOT ".action"
225         DeleteRegKey HKEY_CLASSES_ROOT "PrivoxyActionFile"
226         DeleteRegKey HKEY_CLASSES_ROOT ".filter"
227         DeleteRegKey HKEY_CLASSES_ROOT "PrivoxyFilterFile"
228
229         Delete "$SMSTARTUP\Privoxy.lnk"
230
231         !insertmacro ClosePrivoxy
232
233         RMDir /r "$SMPROGRAMS\Privoxy"
234         RMDir /r "$INSTDIR"
235 SectionEnd
236
237 ; eof