[gaim-migrate @ 6634]
[pidgin-git.git] / gaim-installer.nsi
blobfbdedfb32c50ca441103e8a5046e9408bd43ec81
1 ; Installer script for win32 Gaim
2 ; Herman Bloggs <hermanator12002@yahoo.com>
4 ; NOTE: this .NSI script is designed for NSIS v2.0b4+
6 ;--------------------------------
7 ;Configuration
9 ;General
10 !ifdef WITH_GTK
11 OutFile "gaim-${GAIM_VERSION}.exe"
12 !else
13 !ifdef DEBUG
14 OutFile "gaim-${GAIM_VERSION}-debug.exe"
15 !else
16 OutFile "gaim-${GAIM_VERSION}-no-gtk.exe"
17 !endif
18 !endif
19 SetCompressor bzip2
21 DirShow show
22 ShowInstDetails show
23 ShowUninstDetails show
24 SetDateSave on
26 ; $INSTDIR is set in .onInit function..
28 !include "MUI.nsh"
29 !include Sections.nsh
31 ;--------------------------------
32 ;Defines
34 !define MUI_PRODUCT "Gaim"
35 !define MUI_VERSION ${GAIM_VERSION}
37 !define MUI_ICON .\pixmaps\gaim-install.ico
38 !define MUI_UNICON .\pixmaps\gaim-install.ico
39 !define MUI_SPECIALBITMAP .\src\win32\nsis\gaim-intro.bmp
40 !define MUI_HEADERBITMAP .\src\win32\nsis\gaim-header.bmp
42 !define GAIM_NSIS_INCLUDE_PATH ".\src\win32\nsis"
44 !define GAIM_REG_KEY "SOFTWARE\gaim"
45 !define GAIM_UNINSTALL_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Gaim"
46 !define HKLM_APP_PATHS_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\gaim.exe"
47 !define GAIM_STARTUP_RUN_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
48 !define GAIM_UNINST_EXE "gaim-uninst.exe"
50 !define GTK_VERSION "2.2.1"
51 !define GTK_REG_KEY "SOFTWARE\GTK\2.0"
52 !define GTK_DEFAULT_INSTALL_PATH "$PROGRAMFILES\Common Files\GTK\2.0"
53 !define GTK_INSTALL_VERIFIER "lib\libgtk-win32-2.0-0.dll"
54 !define GTK_RUNTIME_INSTALLER "..\gtk_installer\gtk-runtime*.exe"
55 !define GTK_THEME_DIR "..\gtk_installer\gtk_themes"
56 !define GTK_DEFAULT_THEME_GTKRC_DIR "share\themes\Default\gtk-2.0"
57 !define GTK_DEFAULT_THEME_ENGINE_DIR "lib\gtk-2.0\2.2.0\engines"
59 ;--------------------------------
60 ;Modern UI Configuration
62 !define MUI_CUSTOMPAGECOMMANDS
64 !define MUI_WELCOMEPAGE
65 !define MUI_LICENSEPAGE
66 !define MUI_COMPONENTSPAGE
67 !define MUI_COMPONENTSPAGE_SMALLDESC
68 !define MUI_DIRECTORYPAGE
69 !define MUI_FINISHPAGE
71 !define MUI_ABORTWARNING
73 !define MUI_UNINSTALLER
74 !define MUI_UNCONFIRMPAGE
76 ;--------------------------------
77 ;Pages
79 !insertmacro MUI_PAGECOMMAND_WELCOME
80 !insertmacro MUI_PAGECOMMAND_LICENSE
81 !insertmacro MUI_PAGECOMMAND_COMPONENTS
82 Page custom ShowGtkInstallDirChooser GtkInstallDirVerify
83 !insertmacro MUI_PAGECOMMAND_DIRECTORY
84 !insertmacro MUI_PAGECOMMAND_INSTFILES
85 !insertmacro MUI_PAGECOMMAND_FINISH
87 ;--------------------------------
88 ;Languages
90 !insertmacro MUI_LANGUAGE "English"
92 ;--------------------------------
93 ;Language Strings
94 !ifndef WITH_GTK
95 LangString GTK_INSTALLER_NEEDED ${LANG_ENGLISH} \
96 "The GTK+ runtime environment is either missing or needs to be upgraded.$\r \
97 Please install v${GTK_VERSION} or higher of the GTK+ runtime"
98 !endif
99 ; Componants Page
100 LangString GAIM_SECTION_TITLE ${LANG_ENGLISH} \
101 "Gaim Instant Messenger (required)"
102 LangString GTK_SECTION_TITLE ${LANG_ENGLISH} \
103 "GTK+ Rutime Environment (required)"
104 LangString GTK_THEMES_SECTION_TITLE ${LANG_ENGLISH} \
105 "GTK+ Themes"
106 LangString GTK_NOTHEME_SECTION_TITLE ${LANG_ENGLISH} \
107 "No Theme"
108 LangString GTK_WIMP_SECTION_TITLE ${LANG_ENGLISH} \
109 "Wimp Theme"
110 LangString GTK_BLUECURVE_SECTION_TITLE ${LANG_ENGLISH} \
111 "Bluecurve Theme"
112 LangString GTK_LIGHTHOUSEBLUE_SECTION_TITLE ${LANG_ENGLISH} \
113 "Light House Blue Theme"
114 LangString GAIM_SECTION_DESCRIPTION ${LANG_ENGLISH} \
115 "Core Gaim files and dlls"
116 LangString GTK_SECTION_DESCRIPTION ${LANG_ENGLISH} \
117 "A multi-platform GUI toolkit, used by Gaim"
118 LangString GTK_THEMES_SECTION_DESCRIPTION ${LANG_ENGLISH} \
119 "GTK+ Themes can change the look and feel of GTK+ applications."
120 LangString GTK_NO_THEME_DESC ${LANG_ENGLISH} \
121 "Don't install a GTK+ theme"
122 LangString GTK_WIMP_THEME_DESC ${LANG_ENGLISH} \
123 "GTK-Wimp (Windows impersonator) is a GTK theme that blends well into the Windows desktop environment."
124 LangString GTK_BLUECURVE_THEME_DESC ${LANG_ENGLISH} \
125 "The Bluecurve theme."
126 LangString GTK_LIGHTHOUSEBLUE_THEME_DESC ${LANG_ENGLISH} \
127 "The Lighthouseblue theme."
129 ; Extra GTK+ Dir Selector Page
130 LangString GTK_PAGE_TITLE ${LANG_ENGLISH} \
131 "Choose Install Location"
132 LangString GTK_PAGE_SUBTITLE ${LANG_ENGLISH} \
133 "Choose the folder in which to install GTK+"
134 LangString GTK_PAGE_INSTALL_MSG1 ${LANG_ENGLISH} \
135 "Setup will install GTK+ in the following folder"
136 LangString GTK_PAGE_INSTALL_MSG2 ${LANG_ENGLISH} \
137 "To install in a different folder, click Browse and select \
138 another folder. Click Next to continue."
139 LangString GTK_PAGE_UPGRADE_MSG1 ${LANG_ENGLISH} \
140 "Setup will upgrade GTK+ found in the following folder"
141 LangString GTK_UPGRADE_PROMPT ${LANG_ENGLISH} \
142 "An old version of the GTK+ runtime was found. Do you wish to upgrade? $\r \
143 Note: Gaim may not work unless you do."
145 ; Gaim Section Prompts and Texts
146 LangString GAIM_UNINSTALL_DESC ${LANG_ENGLISH} \
147 "Gaim (remove only)"
148 LangString GAIM_PROMPT_WIPEOUT ${LANG_ENGLISH} \
149 "You're old Gaim directory is about to be deleted. Would you like to continue?$\r$\r \
150 Note: Any non-standard plugins that you may have installed will be deleted. $\r \
151 Gaim user settings will not be affected."
152 LangString GAIM_PROMPT_DIR_EXISTS ${LANG_ENGLISH} \
153 "The installation directory you specified already exists. Any contents $\r \
154 it may have will be deleted. Would you like to continue?"
156 ; GTK+ Section Prompts
157 LangString GTK_INSTALL_ERROR ${LANG_ENGLISH} \
158 "Error installing GTK+ runtime."
159 LangString GTK_BAD_INSTALL_PATH ${LANG_ENGLISH} \
160 "The path you entered can not be accessed or created."
161 LangString GTK_DLL_CONFLICT_PROMPT ${LANG_ENGLISH} \
162 "Duplicate GTK+ dlls were found in your Windows dll search path and will$\r \
163 likely conflict with your GTK+ runtime installation. $\r$\r \
164 $\r \
165 Would you like to rename these dlls to avoid any possible conflicts?$\r \
166 (E.G. somedll.dll to somedll.dll.prob)$\r \
167 $\r \
168 Note: Any applications relying on these dlls will no longer function.$\r \
169 It is suggested that you contact the authors of these applications$\r \
170 to notify them of this conflict."
171 LangString GTK_INSTALL_TO_GAIM_DIR ${LANG_ENGLISH} \
172 "Installing GTK+ runtime package to your Gaim installation directory.$\r \
173 (This will prevent Gaim from using any of the duplicate dlls found in $\r \
174 in your Windows dll search path)."
175 LangString GTK_CAN_NOT_RENAME_CONFLICT_DLL ${LANG_ENGLISH} \
176 "A duplicate GTK+ dll was found in your Windows dll search path and will$\r \
177 likely conflict with your GTK+ runtime installation. $\r$\r \
178 You do not have permission to rename this file. To avoid any possible dll$\r \
179 conflicts, you can install the GTK+ runtime files to the Gaim installation$\r \
180 directory. Do you wish to do so?$\r$\r \
181 Note: You may also resolve these conflicts by logging on with an Admin account$\r \
182 and running the Gaim installer once more. This will enable the Gaim installer to$\r \
183 rename the conflict dlls."
185 ; GTK+ Themes section
186 LangString GTK_NO_THEME_INSTALL_RIGHTS ${LANG_ENGLISH} \
187 "You do not have permission to install a GTK+ theme."
189 ; Uninstall Section Prompts
190 LangString un.GAIM_UNINSTALL_ERROR_1 ${LANG_ENGLISH} \
191 "The uninstaller could not find registry entries for Gaim.$\r \
192 It is likely that another user installed this application."
193 LangString un.GAIM_UNINSTALL_ERROR_2 ${LANG_ENGLISH} \
194 "You do not have permission to uninstall this application."
197 ;--------------------------------
198 ;Data
200 LicenseData "./COPYING"
202 ;--------------------------------
203 ;Reserve Files
204 ; Only need this if using bzip2 compression
206 ReserveFile "${GAIM_NSIS_INCLUDE_PATH}\gtkInstall.ini"
207 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
208 ReserveFile "${NSISDIR}\Plugins\AccessControl.dll"
209 ReserveFile "${NSISDIR}\Plugins\UserInfo.dll"
213 ;--------------------------------
214 ;Uninstall any old version of Gaim
216 Section -SecUninstallOldGaim
217 ; Check install rights..
218 Call CheckUserInstallRights
219 Pop $R0
221 StrCmp $R0 "HKLM" gaim_hklm
222 StrCmp $R0 "HKCU" gaim_hkcu done
224 gaim_hkcu:
225 ReadRegStr $R1 HKCU ${GAIM_REG_KEY} ""
226 ReadRegStr $R2 HKCU ${GAIM_REG_KEY} "Version"
227 ReadRegStr $R3 HKCU "${GAIM_UNINSTALL_KEY}" "UninstallString"
228 Goto try_uninstall
230 gaim_hklm:
231 ReadRegStr $R1 HKLM ${GAIM_REG_KEY} ""
232 ReadRegStr $R2 HKLM ${GAIM_REG_KEY} "Version"
233 ReadRegStr $R3 HKLM "${GAIM_UNINSTALL_KEY}" "UninstallString"
235 ; If previous version exists .. remove
236 try_uninstall:
237 StrCmp $R1 "" done
238 ; Version key started with 0.60a3. Prior versions can't be
239 ; automaticlly uninstalled.
240 StrCmp $R2 "" uninstall_problem
241 ; Check if we have uninstall string..
242 IfFileExists $R3 0 uninstall_problem
243 ; Have uninstall string.. go ahead and uninstall.
244 SetOverwrite on
245 ; Need to copy uninstaller outside of the install dir
246 ClearErrors
247 CopyFiles /SILENT $R3 "$TEMP\${GAIM_UNINST_EXE}"
248 SetOverwrite off
249 IfErrors uninstall_problem
250 ; Ready to uninstall..
251 ClearErrors
252 ExecWait '"$TEMP\${GAIM_UNINST_EXE}" /S _?=$R1'
253 IfErrors exec_error
254 Delete "$TEMP\${GAIM_UNINST_EXE}"
255 Goto done
257 exec_error:
258 Delete "$TEMP\${GAIM_UNINST_EXE}"
259 Goto uninstall_problem
261 uninstall_problem:
262 ; In this case just wipe out previous Gaim install dir..
263 ; We get here because versions 0.60a1 and 0.60a2 don't have versions set in the registry
264 ; and versions 0.60 and lower did not correctly set the uninstall reg string
265 ; (the string was set in quotes)
266 MessageBox MB_YESNO $(GAIM_PROMPT_WIPEOUT) IDYES do_wipeout IDNO cancel_install
267 cancel_install:
268 Quit
270 do_wipeout:
271 StrCmp $R0 "HKLM" gaim_del_lm_reg gaim_del_cu_reg
272 gaim_del_cu_reg:
273 DeleteRegKey HKCU ${GAIM_REG_KEY}
274 Goto uninstall_prob_cont
275 gaim_del_lm_reg:
276 DeleteRegKey HKLM ${GAIM_REG_KEY}
278 uninstall_prob_cont:
279 RMDir /r "$R1"
281 done:
282 SectionEnd
285 ;--------------------------------
286 ;GTK+ Runtime Install Section
288 !ifdef WITH_GTK
289 Section $(GTK_SECTION_TITLE) SecGtk
290 SectionIn 1 RO
292 Call CheckUserInstallRights
293 Pop $R1
295 SetOutPath $TEMP
296 SetOverwrite on
297 File /oname=gtk-runtime.exe ${GTK_RUNTIME_INSTALLER}
298 SetOverwrite off
300 ; This keeps track whether we install GTK+ or not..
301 StrCpy $R5 "0"
303 Call DoWeNeedGtk
304 Pop $R0
305 Pop $R6
307 StrCmp $R0 "0" have_gtk
308 StrCmp $R0 "1" upgrade_gtk
309 StrCmp $R0 "2" no_gtk no_gtk
311 no_gtk:
312 StrCmp $R1 "NONE" gtk_no_install_rights
313 !insertmacro MUI_INSTALLOPTIONS_READ $R2 "gtkInstall.ini" "Field 4" "State"
314 ClearErrors
315 ExecWait '"$TEMP\gtk-runtime.exe" /S /D=$R2'
316 Goto gtk_install_cont
318 upgrade_gtk:
319 MessageBox MB_YESNO $(GTK_UPGRADE_PROMPT) IDNO done
320 ClearErrors
321 ExecWait '"$TEMP\gtk-runtime.exe" /S'
322 Goto gtk_install_cont
324 gtk_install_cont:
325 IfErrors gtk_install_error
326 StrCpy $R5 "1" ; marker that says we installed...
327 Goto done
329 gtk_install_error:
330 Delete "$TEMP\gtk-runtime.exe"
331 MessageBox MB_OK $(GTK_INSTALL_ERROR) IDOK
332 Quit
334 have_gtk:
335 StrCpy $R2 $R6 ; Copy GTK+ path
336 StrCmp $R1 "NONE" done ; If we have no rights.. can't re-install..
337 ; Even if we have a sufficient version of GTK+, we give user choice to re-install.
338 ClearErrors
339 ExecWait '"$TEMP\gtk-runtime.exe" /S'
340 IfErrors gtk_install_error
341 Goto done
343 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
344 ; end got_install rights
346 gtk_no_install_rights:
347 ClearErrors
348 ExecWait '"$TEMP\gtk-runtime.exe" /S /D=$INSTDIR'
349 IfErrors gtk_install_error
350 SetOverwrite on
351 ClearErrors
352 CopyFiles /FILESONLY "$INSTDIR\lib\*.dll" $INSTDIR
353 SetOverwrite off
354 IfErrors gtk_install_error
355 Delete "$INSTDIR\lib\*.dll"
356 Goto done
357 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
358 ; end gtk_no_install_rights
360 done:
361 Delete "$TEMP\gtk-runtime.exe"
362 SectionEnd ; end of GTK+ section
363 !endif
365 ;--------------------------------
366 ;Gaim Install Section
368 Section $(GAIM_SECTION_TITLE) SecGaim
369 SectionIn 1 RO
371 ; Check install rights..
372 Call CheckUserInstallRights
373 Pop $R0
375 ; Get GTK+ lib dir if we have it..
377 StrCmp $R0 "NONE" gaim_none
378 StrCmp $R0 "HKLM" gaim_hklm gaim_hkcu
380 gaim_hklm:
381 ReadRegStr $R1 HKLM ${GTK_REG_KEY} "Path"
382 WriteRegStr HKLM "${HKLM_APP_PATHS_KEY}" "Path" "$R1\lib"
383 WriteRegStr HKLM ${GAIM_REG_KEY} "" "$INSTDIR"
384 WriteRegStr HKLM ${GAIM_REG_KEY} "Version" "${GAIM_VERSION}"
385 WriteRegStr HKLM "${GAIM_UNINSTALL_KEY}" "DisplayName" $(GAIM_UNINSTALL_DESC)
386 WriteRegStr HKLM "${GAIM_UNINSTALL_KEY}" "UninstallString" "$INSTDIR\${GAIM_UNINST_EXE}"
387 ; Sets scope of the desktop and Start Menu entries for all users.
388 SetShellVarContext "all"
389 Goto gaim_install_files
391 gaim_hkcu:
392 ReadRegStr $R1 HKCU ${GTK_REG_KEY} "Path"
393 StrCmp $R1 "" 0 gaim_hkcu1
394 ReadRegStr $R1 HKLM ${GTK_REG_KEY} "Path"
395 gaim_hkcu1:
396 WriteRegStr HKCU ${GAIM_REG_KEY} "" "$INSTDIR"
397 WriteRegStr HKCU ${GAIM_REG_KEY} "Version" "${GAIM_VERSION}"
398 WriteRegStr HKCU "${GAIM_UNINSTALL_KEY}" "DisplayName" $(GAIM_UNINSTALL_DESC)
399 WriteRegStr HKCU "${GAIM_UNINSTALL_KEY}" "UninstallString" "$INSTDIR\${GAIM_UNINST_EXE}"
400 Goto gaim_install_files
402 gaim_none:
403 ReadRegStr $R1 HKLM ${GTK_REG_KEY} "Path"
405 gaim_install_files:
406 SetOutPath "$INSTDIR"
407 ; Gaim files
408 SetOverwrite on
409 File /r .\win32-install-dir\*.*
410 !ifdef DEBUG
411 File ..\win32-dev\drmingw\exchndl.dll
412 !endif
414 ; If we don't have install rights and no hklm GTK install.. then Start in lnk property should
415 ; remain gaim dir.. otherwise it should be set to the GTK lib dir. (to avoid dll hell)
416 StrCmp $R0 "NONE" 0 startin_gtk
417 StrCmp $R1 "" startin_gaim
418 startin_gtk:
419 SetOutPath "$R1\lib"
420 startin_gaim:
421 CreateDirectory "$SMPROGRAMS\Gaim"
422 CreateShortCut "$SMPROGRAMS\Gaim\Gaim.lnk" "$INSTDIR\gaim.exe"
423 CreateShortCut "$DESKTOP\Gaim.lnk" "$INSTDIR\gaim.exe"
424 SetOutPath "$INSTDIR"
426 ; If we don't have install rights.. we're done
427 StrCmp $R0 "NONE" done
428 CreateShortCut "$SMPROGRAMS\Gaim\Uninstall.lnk" "$INSTDIR\${GAIM_UNINST_EXE}"
429 SetOverwrite off
431 ; write out uninstaller
432 SetOverwrite on
433 WriteUninstaller "$INSTDIR\${GAIM_UNINST_EXE}"
434 SetOverwrite off
436 done:
437 SectionEnd ; end of default Gaim section
439 ;--------------------------------
440 ;GTK+ Themes
442 SubSection /e $(GTK_THEMES_SECTION_TITLE) SecGtkThemes
443 Section $(GTK_NOTHEME_SECTION_TITLE) SecGtkNone
444 ; Do nothing..
445 SectionEnd
447 Section $(GTK_WIMP_SECTION_TITLE) SecGtkWimp
448 Call CanWeInstallATheme
449 Pop $R1
450 StrCmp $R1 "" done
452 SetOverwrite on
453 Rename $R1\${GTK_DEFAULT_THEME_GTKRC_DIR}\gtkrc $R1\${GTK_DEFAULT_THEME_GTKRC_DIR}\gtkrc.old
454 SetOutPath $R1\${GTK_DEFAULT_THEME_ENGINE_DIR}
455 File ${GTK_THEME_DIR}\engines\libwimp.dll
456 SetOutPath $R1\${GTK_DEFAULT_THEME_GTKRC_DIR}
457 File ${GTK_THEME_DIR}\themes\gtkrc.gtkwimp
458 File /oname=gtkrc ${GTK_THEME_DIR}\themes\gtkrc.gtkwimp
459 SetOverwrite off
461 done:
462 SectionEnd
464 Section $(GTK_BLUECURVE_SECTION_TITLE) SecGtkBluecurve
465 Call CanWeInstallATheme
466 Pop $R1
467 StrCmp $R1 "" done
469 SetOverwrite on
470 Rename $R1\${GTK_DEFAULT_THEME_GTKRC_DIR}\gtkrc $R1\${GTK_DEFAULT_THEME_GTKRC_DIR}\gtkrc.old
471 SetOutPath $R1\${GTK_DEFAULT_THEME_ENGINE_DIR}
472 File ${GTK_THEME_DIR}\engines\libbluecurve.dll
473 SetOutPath $R1\${GTK_DEFAULT_THEME_GTKRC_DIR}
474 File ${GTK_THEME_DIR}\themes\gtkrc.bluecurve
475 File /oname=gtkrc ${GTK_THEME_DIR}\themes\gtkrc.bluecurve
476 SetOverwrite off
478 done:
479 SectionEnd
481 Section $(GTK_LIGHTHOUSEBLUE_SECTION_TITLE) SecGtkLighthouseblue
482 Call CanWeInstallATheme
483 Pop $R1
484 StrCmp $R1 "" done
486 SetOverwrite on
487 Rename $R1\${GTK_DEFAULT_THEME_GTKRC_DIR}\gtkrc $R1\${GTK_DEFAULT_THEME_GTKRC_DIR}\gtkrc.old
488 SetOutPath $R1\${GTK_DEFAULT_THEME_ENGINE_DIR}
489 File ${GTK_THEME_DIR}\engines\liblighthouseblue.dll
490 SetOutPath $R1\${GTK_DEFAULT_THEME_GTKRC_DIR}
491 File ${GTK_THEME_DIR}\themes\gtkrc.lighthouseblue
492 File /oname=gtkrc ${GTK_THEME_DIR}\themes\gtkrc.lighthouseblue
493 SetOverwrite off
495 done:
496 SectionEnd
497 SubSectionEnd
499 ;--------------------------------
500 ;Uninstaller Section
503 Section Uninstall
504 Call un.CheckUserInstallRights
505 Pop $R0
506 StrCmp $R0 "NONE" no_rights
507 StrCmp $R0 "HKCU" try_hkcu try_hklm
509 try_hkcu:
510 ReadRegStr $R0 HKCU ${GAIM_REG_KEY} ""
511 StrCmp $R0 $INSTDIR 0 cant_uninstall
512 ; HKCU install path matches our INSTDIR.. so uninstall
513 DeleteRegKey HKCU ${GAIM_REG_KEY}
514 DeleteRegKey HKCU "${GAIM_UNINSTALL_KEY}"
515 Goto cont_uninstall
517 try_hklm:
518 ReadRegStr $R0 HKLM ${GAIM_REG_KEY} ""
519 StrCmp $R0 $INSTDIR 0 try_hkcu
520 ; HKLM install path matches our INSTDIR.. so uninstall
521 DeleteRegKey HKLM ${GAIM_REG_KEY}
522 DeleteRegKey HKLM "${GAIM_UNINSTALL_KEY}"
523 DeleteRegKey HKLM "${HKLM_APP_PATHS_KEY}"
524 ; Sets start menu and desktop scope to all users..
525 SetShellVarContext "all"
527 cont_uninstall:
528 ; The WinPrefs plugin may have left this behind..
529 DeleteRegValue HKCU "${GAIM_STARTUP_RUN_KEY}" "Gaim"
530 DeleteRegValue HKLM "${GAIM_STARTUP_RUN_KEY}" "Gaim"
532 RMDir /r "$INSTDIR\locale"
533 RMDir /r "$INSTDIR\pixmaps"
534 Delete "$INSTDIR\plugins\autorecon.dll"
535 Delete "$INSTDIR\plugins\iconaway.dll"
536 Delete "$INSTDIR\plugins\docklet.dll"
537 Delete "$INSTDIR\plugins\perl.dll"
538 Delete "$INSTDIR\plugins\libgg.dll"
539 Delete "$INSTDIR\plugins\libirc.dll"
540 Delete "$INSTDIR\plugins\libjabber.dll"
541 Delete "$INSTDIR\plugins\libmsn.dll"
542 Delete "$INSTDIR\plugins\liboscar.dll"
543 Delete "$INSTDIR\plugins\libtoc.dll"
544 Delete "$INSTDIR\plugins\libyahoo.dll"
545 Delete "$INSTDIR\plugins\spellchk.dll"
546 Delete "$INSTDIR\plugins\ticker.dll"
547 Delete "$INSTDIR\plugins\win2ktrans.dll"
548 Delete "$INSTDIR\plugins\winprefs.dll"
549 RMDir "$INSTDIR\plugins"
550 Delete "$INSTDIR\sounds\gaim\arrive.wav"
551 Delete "$INSTDIR\sounds\gaim\leave.wav"
552 Delete "$INSTDIR\sounds\gaim\receive.wav"
553 Delete "$INSTDIR\sounds\gaim\redalert.wav"
554 Delete "$INSTDIR\sounds\gaim\send.wav"
555 RMDir "$INSTDIR\sounds\gaim"
556 RMDir "$INSTDIR\sounds"
557 Delete "$INSTDIR\gaim.dll"
558 Delete "$INSTDIR\gaim.exe"
559 Delete "$INSTDIR\${GAIM_UNINST_EXE}"
560 Delete "$INSTDIR\idletrack.dll"
561 Delete "$INSTDIR\libgtkspell.dll"
562 Delete "$INSTDIR\perl56.dll"
563 ;Remove possible GTK+ files and folders..
564 RMDir \r "$INSTDIR\lib"
565 RMDir \r "$INSTDIR\share"
566 RMDir \r "$INSTDIR\locale"
567 RMDir \r "$INSTDIR\bin"
568 Delete "$INSTDIR\*.dll"
569 ;Try to remove Gaim install dir .. if empty
570 RMDir "$INSTDIR"
572 ; Shortcuts..
573 RMDir /r "$SMPROGRAMS\Gaim"
574 Delete "$DESKTOP\Gaim.lnk"
576 Goto done
578 cant_uninstall:
579 MessageBox MB_OK $(un.GAIM_UNINSTALL_ERROR_1) IDOK
580 Quit
582 no_rights:
583 MessageBox MB_OK $(un.GAIM_UNINSTALL_ERROR_2) IDOK
584 Quit
586 done:
587 ;Display the Finish header
588 !insertmacro MUI_UNFINISHHEADER
589 SectionEnd ; end of uninstall section
591 ;--------------------------------
592 ;Descriptions
593 !insertmacro MUI_FUNCTIONS_DESCRIPTION_BEGIN
594 !insertmacro MUI_DESCRIPTION_TEXT ${SecGaim} \
595 $(GAIM_SECTION_DESCRIPTION)
596 !ifdef WITH_GTK
597 !insertmacro MUI_DESCRIPTION_TEXT ${SecGtk} \
598 $(GTK_SECTION_DESCRIPTION)
599 !endif
600 !insertmacro MUI_DESCRIPTION_TEXT ${SecGtkThemes} \
601 $(GTK_THEMES_SECTION_DESCRIPTION)
602 !insertmacro MUI_DESCRIPTION_TEXT ${SecGtkNone} \
603 $(GTK_NO_THEME_DESC)
604 !insertmacro MUI_DESCRIPTION_TEXT ${SecGtkWimp} \
605 $(GTK_WIMP_THEME_DESC)
606 !insertmacro MUI_DESCRIPTION_TEXT ${SecGtkBluecurve} \
607 $(GTK_BLUECURVE_THEME_DESC)
608 !insertmacro MUI_DESCRIPTION_TEXT ${SecGtkLighthouseblue} \
609 $(GTK_LIGHTHOUSEBLUE_THEME_DESC)
610 !insertmacro MUI_FUNCTIONS_DESCRIPTION_END
612 ;--------------------------------
613 ;Functions
616 ; Usage:
618 ; Call CanWeInstallATheme
619 ; Pop $R0
621 ; Return:
622 ; "" - If no
623 ; "root path of GTK+ installation" - if yes
625 Function CanWeInstallATheme
626 Push $1
627 Push $0
629 ; Did we install GTK+ to the Gaim dir?
630 IfFileExists "$INSTDIR\lib" 0 check_keys
631 StrCpy $1 $INSTDIR
632 Goto done
634 check_keys:
635 ; First see if we can install a theme..
636 Call CheckUserInstallRights
637 Pop $0
639 StrCmp $0 "HKCU" hkcu
640 StrCmp $0 "HKLM" hklm no_rights
642 hkcu:
643 ReadRegStr $1 HKCU ${GTK_REG_KEY} "Path"
644 StrCmp $1 "" no_rights done
646 hklm:
647 ReadRegStr $1 HKLM ${GTK_REG_KEY} "Path"
648 StrCmp $1 "" no_rights done
650 no_rights:
651 MessageBox MB_OK $(GTK_NO_THEME_INSTALL_RIGHTS) IDOK done
652 StrCpy $1 ""
654 done:
655 Pop $0
656 Exch $1
657 FunctionEnd
660 Function CheckUserInstallRights
661 ClearErrors
662 UserInfo::GetName
663 IfErrors Win9x
664 Pop $0
665 UserInfo::GetAccountType
666 Pop $1
668 StrCmp $1 "Admin" 0 +3
669 StrCpy $1 "HKLM"
670 Goto done
671 StrCmp $1 "Power" 0 +3
672 StrCpy $1 "HKLM"
673 Goto done
674 StrCmp $1 "User" 0 +3
675 StrCpy $1 "HKCU"
676 Goto done
677 StrCmp $1 "Guest" 0 +3
678 StrCpy $1 "NONE"
679 Goto done
680 ; Unknown error
681 StrCpy $1 "NONE"
682 Goto done
684 Win9x:
685 StrCpy $1 "HKLM"
687 done:
688 Push $1
689 FunctionEnd
691 Function un.CheckUserInstallRights
692 ClearErrors
693 UserInfo::GetName
694 IfErrors Win9x
695 Pop $0
696 UserInfo::GetAccountType
697 Pop $1
698 StrCmp $1 "Admin" 0 +3
699 StrCpy $1 "HKLM"
700 Goto done
701 StrCmp $1 "Power" 0 +3
702 StrCpy $1 "HKLM"
703 Goto done
704 StrCmp $1 "User" 0 +3
705 StrCpy $1 "HKCU"
706 Goto done
707 StrCmp $1 "Guest" 0 +3
708 StrCpy $1 "NONE"
709 Goto done
710 ; Unknown error
711 StrCpy $1 "NONE"
712 Goto done
714 Win9x:
715 StrCpy $1 "HKLM"
717 done:
718 Push $1
719 FunctionEnd
722 ; Usage:
723 ; Push $0 ; Path string
724 ; Call VerifyDir
725 ; Pop $0 ; 0 - Bad path 1 - Good path
727 Function VerifyDir
728 Pop $0
729 Loop:
730 IfFileExists $0 dir_exists
731 StrCpy $1 $0 ; save last
732 Push $0
733 Call GetParent
734 Pop $0
735 StrLen $2 $0
736 ; IfFileExists "C:" on xp returns true and on win2k returns false
737 ; So we're done in such a case..
738 StrCmp $2 "2" loop_done
739 Goto Loop
741 loop_done:
742 StrCpy $1 "$0\GaImFooB"
743 ; Check if we can create dir on this drive..
744 ClearErrors
745 CreateDirectory $1
746 IfErrors DirBad DirGood
748 dir_exists:
749 ClearErrors
750 FileOpen $1 "$0\gaimfoo.bar" w
751 IfErrors PathBad PathGood
753 DirGood:
754 RMDir $1
755 Goto PathGood1
757 DirBad:
758 RMDir $1
759 Goto PathBad1
761 PathBad:
762 FileClose $1
763 Delete "$0\gaimfoo.bar"
764 PathBad1:
765 StrCpy $0 "0"
766 Push $0
767 Return
769 PathGood:
770 FileClose $1
771 Delete "$0\gaimfoo.bar"
772 PathGood1:
773 StrCpy $0 "1"
774 Push $0
775 FunctionEnd
777 Function .onVerifyInstDir
778 Push $INSTDIR
779 Call VerifyDir
780 Pop $0
781 StrCmp $0 "0" 0 dir_good
782 Abort
783 dir_good:
784 FunctionEnd
786 ; GetParent
787 ; input, top of stack (e.g. C:\Program Files\Poop)
788 ; output, top of stack (replaces, with e.g. C:\Program Files)
789 ; modifies no other variables.
791 ; Usage:
792 ; Push "C:\Program Files\Directory\Whatever"
793 ; Call GetParent
794 ; Pop $R0
795 ; ; at this point $R0 will equal "C:\Program Files\Directory"
796 Function GetParent
797 Exch $0 ; old $0 is on top of stack
798 Push $1
799 Push $2
800 StrCpy $1 -1
801 loop:
802 StrCpy $2 $0 1 $1
803 StrCmp $2 "" exit
804 StrCmp $2 "\" exit
805 IntOp $1 $1 - 1
806 Goto loop
807 exit:
808 StrCpy $0 $0 $1
809 Pop $2
810 Pop $1
811 Exch $0 ; put $0 on top of stack, restore $0 to original value
812 FunctionEnd
815 ; CheckGtkVersion
816 ; inputs: Push 2 GTK+ version strings to check. The major and minor values
817 ; need to be equal, for success. If the micro val to check is equal or greater
818 ; to the refrence micro value, then we have success.
820 ; Usage:
821 ; Push "2.2.0" ; Refrence version
822 ; Push "2.2.1" ; Version to check
823 ; Call CheckGtkVersion
824 ; Pop $R0
825 ; $R0 will now equal "0", because 2.2.0 is less than 2.2.1
827 Function CheckGtkVersion
828 ; Version we want to check
829 Pop $6
830 ; Reference version
831 Pop $8
833 ; Check that the string to check is at least 5 chars long (i.e. x.x.x)
834 StrLen $7 $6
835 IntCmp $7 5 0 bad_version
837 ; Major version check
838 StrCpy $7 $6 1
839 StrCpy $9 $8 1
840 IntCmp $7 $9 check_minor
841 Goto bad_version
843 check_minor:
844 StrCpy $7 $6 1 2
845 StrCpy $9 $8 1 2
846 IntCmp $7 $9 check_micro
847 Goto bad_version
849 check_micro:
850 StrCpy $7 $6 1 4
851 StrCpy $9 $8 1 4
852 IntCmp $7 $9 good_version bad_version good_version
854 bad_version:
855 StrCpy $6 "0"
856 Push $6
857 Goto done
859 good_version:
860 StrCpy $6 "1"
861 Push $6
862 done:
863 FunctionEnd
866 ; Usage:
867 ; Call DoWeNeedGtk
868 ; First Pop:
869 ; 0 - We have the correct version
870 ; Second Pop: Key where Version was found
871 ; 1 - We have an old version that needs to be upgraded
872 ; Second Pop: HKLM or HKCU depending on where GTK was found.
873 ; 2 - We don't have Gtk+ at all
874 ; Second Pop: "NONE, HKLM or HKCU" depending on our rights..
876 Function DoWeNeedGtk
877 ; Logic should be:
878 ; - Check what user rights we have (HKLM or HKCU)
879 ; - If HKLM rights..
880 ; - Only check HKLM key for GTK+
881 ; - If installed to HKLM, check it and return.
882 ; - If HKCU rights..
883 ; - First check HKCU key for GTK+
884 ; - if good or bad exists stop and ret.
885 ; - If no hkcu gtk+ install, check HKLM
886 ; - If HKLM ver exists but old, return as if no ver exits.
887 ; - If no rights
888 ; - Check HKLM
890 Call CheckUserInstallRights
891 Pop $3
892 StrCmp $3 "HKLM" check_hklm
893 StrCmp $3 "HKCU" check_hkcu check_hklm
894 check_hkcu:
895 ReadRegStr $0 HKCU ${GTK_REG_KEY} "Version"
896 StrCpy $5 "HKCU"
897 StrCmp $0 "" check_hklm have_gtk
899 check_hklm:
900 ReadRegStr $0 HKLM ${GTK_REG_KEY} "Version"
901 StrCpy $5 "HKLM"
902 StrCmp $0 "" no_gtk have_gtk
905 have_gtk:
906 ; GTK+ is already installed.. check version.
907 StrCpy $1 ${GTK_VERSION} ; Minimum GTK+ version needed
908 Push $1
909 Push $0
910 Call CheckGtkVersion
911 Pop $2
912 StrCmp $2 "1" good_version bad_version
913 bad_version:
914 ; Bad version. If hklm ver and we have hkcu or no rights.. return no gtk
915 StrCmp $3 "NONE" no_gtk ; if no rights.. can't upgrade
916 StrCmp $3 "HKCU" 0 upgrade_gtk ; if HKLM can upgrade..
917 StrCmp $5 "HKLM" no_gtk upgrade_gtk ; have hkcu rights.. if found hklm ver can't upgrade..
919 upgrade_gtk:
920 StrCpy $2 "1"
921 Push $5
922 Push $2
923 Goto done
925 good_version:
926 ; Just make sure we have it. There was a gtk+ uninstaller that
927 ; left behind reg entries after uninstalling..
928 StrCmp $5 "HKLM" have_hklm_gtk have_hkcu_gtk
929 have_hkcu_gtk:
930 ; Have HKCU version
931 ReadRegStr $4 HKCU ${GTK_REG_KEY} "Path"
932 StrCpy $1 "$4\${GTK_INSTALL_VERIFIER}"
933 IfFileExists $1 good_version_verified
934 DeleteRegKey HKCU ${GTK_REG_KEY}
935 Goto no_gtk
937 have_hklm_gtk:
938 ReadRegStr $4 HKLM ${GTK_REG_KEY} "Path"
939 StrCpy $1 "$4\${GTK_INSTALL_VERIFIER}"
940 IfFileExists $1 good_version_verified
941 DeleteRegKey HKLM ${GTK_REG_KEY}
942 Goto no_gtk
944 good_version_verified:
945 StrCpy $2 "0"
946 Push $4 ; The path to existing GTK+
947 Push $2
948 Goto done
950 no_gtk:
951 StrCpy $2 "2"
952 Push $3 ; our rights
953 Push $2
954 Goto done
956 done:
957 FunctionEnd
959 Function .onInit
960 ; If this installer dosn't have GTK, check whether we need it.
961 !ifndef WITH_GTK
962 Call DoWeNeedGtk
963 Pop $0
964 Pop $1
966 StrCmp $0 "0" have_gtk need_gtk
967 need_gtk:
968 MessageBox MB_OK $(GTK_INSTALLER_NEEDED) IDOK
969 Quit
970 have_gtk:
971 !else
972 ;Extract InstallOptions INI Files
973 !insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "${GAIM_NSIS_INCLUDE_PATH}\gtkInstall.ini" "gtkInstall.ini"
974 !endif
976 Call CheckUserInstallRights
977 Pop $0
979 StrCmp $0 "HKLM" 0 user_dir
980 StrCpy $INSTDIR "$PROGRAMFILES\Gaim"
981 Goto instdir_done
982 user_dir:
983 StrCpy $2 "$SMPROGRAMS"
984 Push $2
985 Call GetParent
986 Call GetParent
987 Pop $2
988 StrCpy $INSTDIR "$2\Gaim"
990 instdir_done:
992 ; Set up Theme sections..
993 StrCpy $1 ${SecGtkNone} ; Sets global to remember which theme is set.
994 !insertmacro SelectSection ${SecGtkNone}
995 !insertmacro UnselectSection ${SecGtkWimp}
996 !insertmacro UnselectSection ${SecGtkBluecurve}
997 !insertmacro UnselectSection ${SecGtkLighthouseblue}
999 FunctionEnd
1001 Function .onSelChange
1002 Push $0
1003 Push $2
1005 StrCpy $2 ${SF_SELECTED}
1006 SectionGetFlags ${SecGtkNone} $0
1007 IntOp $2 $2 & $0
1008 SectionGetFlags ${SecGtkWimp} $0
1009 IntOp $2 $2 & $0
1010 SectionGetFlags ${SecGtkBluecurve} $0
1011 IntOp $2 $2 & $0
1012 SectionGetFlags ${SecGtkLighthouseblue} $0
1013 IntOp $2 $2 & $0
1014 StrCmp $2 0 skip
1015 SectionSetFlags ${SecGtkNone} 0
1016 SectionSetFlags ${SecGtkWimp} 0
1017 SectionSetFlags ${SecGtkBluecurve} 0
1018 SectionSetFlags ${SecGtkLighthouseblue} 0
1019 skip:
1021 !insertmacro UnselectSection $1
1023 ; Remember old selection
1024 StrCpy $2 $1
1026 ; Now go through and see who is checked..
1027 SectionGetFlags ${SecGtkNone} $0
1028 IntOp $0 $0 & ${SF_SELECTED}
1029 IntCmp $0 ${SF_SELECTED} 0 +2 +2
1030 StrCpy $1 ${SecGtkNone}
1031 SectionGetFlags ${SecGtkWimp} $0
1032 IntOp $0 $0 & ${SF_SELECTED}
1033 IntCmp $0 ${SF_SELECTED} 0 +2 +2
1034 StrCpy $1 ${SecGtkWimp}
1035 SectionGetFlags ${SecGtkBluecurve} $0
1036 IntOp $0 $0 & ${SF_SELECTED}
1037 IntCmp $0 ${SF_SELECTED} 0 +2 +2
1038 StrCpy $1 ${SecGtkBluecurve}
1039 SectionGetFlags ${SecGtkLighthouseblue} $0
1040 IntOp $0 $0 & ${SF_SELECTED}
1041 IntCmp $0 ${SF_SELECTED} 0 +2 +2
1042 StrCpy $1 ${SecGtkLighthouseblue}
1044 StrCmp $2 $1 0 +2 ; selection hasn't changed
1045 !insertmacro SelectSection $1
1047 Pop $2
1048 Pop $0
1049 FunctionEnd
1051 Function ShowGtkInstallDirChooser
1052 Call DoWeNeedGtk
1053 Pop $0
1054 Pop $1
1056 StrCmp $0 "0" have_gtk
1057 StrCmp $0 "1" upgrade_gtk
1058 StrCmp $0 "2" no_gtk no_gtk
1060 ; Don't show dir selector.. Upgrades are done to existing path..
1061 have_gtk:
1062 upgrade_gtk:
1063 Abort
1065 no_gtk:
1066 StrCmp $1 "NONE" 0 no_gtk_cont
1067 ; Got no install rights..
1068 Abort
1069 no_gtk_cont:
1070 ; Suggest path..
1071 StrCmp $1 "HKCU" 0 hklm1
1072 StrCpy $2 "$SMPROGRAMS"
1073 Push $2
1074 Call GetParent
1075 Call GetParent
1076 Pop $2
1077 StrCpy $2 "$2\GTK\2.0"
1078 Goto got_path
1079 hklm1:
1080 StrCpy $2 "${GTK_DEFAULT_INSTALL_PATH}"
1082 got_path:
1083 !insertmacro MUI_INSTALLOPTIONS_WRITE "gtkInstall.ini" "Field 4" "State" $2
1085 !insertmacro MUI_INSTALLOPTIONS_WRITE "gtkInstall.ini" "Field 1" "Text" $(GTK_PAGE_INSTALL_MSG1)
1086 !insertmacro MUI_INSTALLOPTIONS_WRITE "gtkInstall.ini" "Field 2" "Text" $(GTK_PAGE_INSTALL_MSG2)
1087 !insertmacro MUI_HEADER_TEXT "$(GTK_PAGE_TITLE)" "$(GTK_PAGE_SUBTITLE)"
1088 !insertmacro MUI_INSTALLOPTIONS_DISPLAY "gtkInstall.ini"
1089 FunctionEnd
1091 Function GtkInstallDirVerify
1092 !insertmacro MUI_INSTALLOPTIONS_READ $0 "gtkInstall.ini" "Field 4" "State"
1093 Push $0
1094 Call VerifyDir
1095 Pop $0
1096 StrCmp $0 "0" 0 done
1097 MessageBox MB_OK $(GTK_BAD_INSTALL_PATH) IDOK
1098 Abort
1099 done:
1100 FunctionEnd