File: guifications-installer.nsi

package info (click to toggle)
guifications 2.16-2
  • links: PTS
  • area: main
  • in suites: bullseye, buster, jessie, jessie-kfreebsd, sid, stretch, wheezy
  • size: 3,368 kB
  • ctags: 1,094
  • sloc: ansic: 9,991; sh: 8,958; xml: 1,153; makefile: 185
file content (446 lines) | stat: -rw-r--r-- 12,721 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
; NSIS Script For Guifications Plugin
; Author Daniel A. Atallah
; Based on the Pidgin installer by Herman Bloggs and the Pidgin-Encryption installer by Bill Tompkins
; Uses NSIS v2.0

;--------------------------------
;Include Modern UI
  !include "MUI.nsh"

!include "FileFunc.nsh"
!insertmacro GetParameters
!insertmacro GetOptions


;--------------------------------
;General
  Name "Pidgin Guifications ${GUIFICATIONS_VERSION}"

  ;Do A CRC Check
  CRCCheck On

  ;Output File Name
  OutFile "pidgin-guifications-${GUIFICATIONS_VERSION}.exe"

  ;The Default Installation Directory
  InstallDir "$PROGRAMFILES\pidgin"
  InstallDirRegKey HKLM SOFTWARE\pidgin ""

  ShowInstDetails show
  ShowUnInstDetails show
  SetCompressor /SOLID lzma

;Reserve files used in .onInit for faster start-up
!insertmacro MUI_RESERVEFILE_LANGDLL

  !define GUIFICATIONS_UNINST_EXE     "pidgin-guifications-uninst.exe"
  !define GUIFICATIONS_DLL            "guifications.dll"
  !define GUIFICATIONS_UNINSTALL_LNK  "Guifications Uninstall.lnk"

;--------------------------------
; Registry keys:
  !define GUIFICATIONS_REG_KEY        "SOFTWARE\pidgin-guifications"
  !define GUIFICATIONS_UNINSTALL_KEY  "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\pidgin-guifications"

;-------------------------------
; Pidgin Plugin installer helper stuff
  !addincludedir "${PIDGIN_TREE_TOP}\pidgin\win32\nsis"
  !include "pidgin-plugin.nsh"

;--------------------------------
; Modern UI Configuration
  !define MUI_ICON .\nsis\install.ico
  !define MUI_UNICON .\nsis\install.ico
  !define MUI_HEADERIMAGE
  !define MUI_HEADERIMAGE_BITMAP "nsis\header.bmp"
  !define MUI_CUSTOMFUNCTION_GUIINIT gf_checkPidginVersion
  !define MUI_ABORTWARNING

  !define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
  !define MUI_LANGDLL_REGISTRY_KEY ${GUIFICATIONS_REG_KEY}
  !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"

;--------------------------------
; Pages
  ;Welcome Page
  !define MUI_WELCOMEPAGE_TITLE $(WELCOME_TITLE)
  !define MUI_WELCOMEPAGE_TEXT $(WELCOME_TEXT)
  !insertmacro MUI_PAGE_WELCOME

  ;License Page
  !define MUI_LICENSEPAGE_RADIOBUTTONS
  !insertmacro MUI_PAGE_LICENSE  ".\COPYING"

  ;Directory Page
  !define MUI_DIRECTORYPAGE_TEXT_TOP $(DIR_SUBTITLE)
  !define MUI_DIRECTORYPAGE_TEXT_DESTINATION $(DIR_INNERTEXT)
  !insertmacro MUI_PAGE_DIRECTORY

  ;Installation Page
  !insertmacro MUI_PAGE_INSTFILES

  ;Finish Page
  !define MUI_FINISHPAGE_TITLE $(FINISH_TITLE)
  !define MUI_FINISHPAGE_TEXT $(FINISH_TEXT)
  !insertmacro MUI_PAGE_FINISH


;--------------------------------
; Languages
  !insertmacro MUI_LANGUAGE "English"
  !insertmacro MUI_LANGUAGE "French"
  !insertmacro MUI_LANGUAGE "Italian"
  !insertmacro MUI_LANGUAGE "Spanish"

  ;Translations
  !include "nsis\translations\english.nsh"
  !include "nsis\translations\french.nsh"
  !include "nsis\translations\italian.nsh"
  !include "nsis\translations\spanish.nsh"

; Uninstall the previous version if it exists
Section -SecUninstallOldPlugin
  ; Check install rights..
  Call CheckUserInstallRights
  Pop $R0

  StrCmp $R0 "HKLM" rights_hklm
  StrCmp $R0 "HKCU" rights_hkcu done

  rights_hkcu:
    ReadRegStr $R1 HKCU "${GUIFICATIONS_REG_KEY}" ""
    ReadRegStr $R2 HKCU "${GUIFICATIONS_REG_KEY}" "Version"
    ReadRegStr $R3 HKCU "${GUIFICATIONS_UNINSTALL_KEY}" "UninstallString"
    Goto try_uninstall

  rights_hklm:
    ReadRegStr $R1 HKLM "${GUIFICATIONS_REG_KEY}" ""
    ReadRegStr $R2 HKLM "${GUIFICATIONS_REG_KEY}" "Version"
    ReadRegStr $R3 HKLM "${GUIFICATIONS_UNINSTALL_KEY}" "UninstallString"

  ; If previous version exists .. remove
  try_uninstall:
    StrCmp $R1 "" done
      StrCmp $R2 "" uninstall_problem
        IfFileExists $R3 0 uninstall_problem
          ; Have uninstall string.. go ahead and uninstall.
          SetOverwrite on
          ; Need to copy uninstaller outside of the install dir
          ClearErrors
          CopyFiles /SILENT $R3 "$TEMP\${GUIFICATIONS_UNINST_EXE}"
          SetOverwrite off
          IfErrors uninstall_problem
            ; Ready to uninstall..
            ClearErrors
            ExecWait '"$TEMP\${GUIFICATIONS_UNINST_EXE}" /S _?=$R1'
            IfErrors exec_error
              Delete "$TEMP\${GUIFICATIONS_UNINST_EXE}"
              Goto done

            exec_error:
              Delete "$TEMP\${GUIFICATIONS_UNINST_EXE}"
              Goto uninstall_problem

        uninstall_problem:
          ; Just delete the plugin and uninstaller, and remove Registry key
          MessageBox MB_YESNO $(GUIFICATIONS_PROMPT_WIPEOUT) IDYES do_wipeout IDNO cancel_install
        cancel_install:
          Quit

        do_wipeout:
          StrCmp $R0 "HKLM" del_lm_reg del_cu_reg
          del_cu_reg:
            DeleteRegKey HKCU ${GUIFICATIONS_REG_KEY}
            Goto uninstall_prob_cont
          del_lm_reg:
            DeleteRegKey HKLM ${GUIFICATIONS_REG_KEY}

        uninstall_prob_cont:
          ; plugin DLL
          Delete "$R1\plugins\${GUIFICATIONS_DLL}"
          ; pixmaps
          RMDir /r "$R1\pixmaps\pidgin\guifications"
          Delete "$R3"

  done:
SectionEnd

!macro INSTALL_GMO LANG
    SetOutPath "$INSTDIR\locale\${LANG}\LC_MESSAGES"
    File /oname=guifications.mo po\${LANG}.gmo
!macroend

Section "Install"
  Call CheckUserInstallRights
  Pop $R0

  StrCmp $R0 "NONE" instrights_none
  StrCmp $R0 "HKLM" instrights_hklm instrights_hkcu

  instrights_hklm:
    ; Write the version registry keys:
    WriteRegStr HKLM ${GUIFICATIONS_REG_KEY} "" "$INSTDIR"
    WriteRegStr HKLM ${GUIFICATIONS_REG_KEY} "Version" "${GUIFICATIONS_VERSION}"

    ; Write the uninstall keys for Windows
    WriteRegStr HKLM ${GUIFICATIONS_UNINSTALL_KEY} "DisplayName" "$(GUIFICATIONS_UNINSTALL_DESC)"
    WriteRegStr HKLM ${GUIFICATIONS_UNINSTALL_KEY} "UninstallString" "$INSTDIR\${GUIFICATIONS_UNINST_EXE}"
    SetShellVarContext "all"
    Goto install_files

  instrights_hkcu:
    ; Write the version registry keys:
    WriteRegStr HKCU ${GUIFICATIONS_REG_KEY} "" "$INSTDIR"
    WriteRegStr HKCU ${GUIFICATIONS_REG_KEY} "Version" "${GUIFICATIONS_VERSION}"

    ; Write the uninstall keys for Windows
    WriteRegStr HKCU ${GUIFICATIONS_UNINSTALL_KEY} "DisplayName" "$(GUIFICATIONS_UNINSTALL_DESC)"
    WriteRegStr HKCU ${GUIFICATIONS_UNINSTALL_KEY} "UninstallString" "$INSTDIR\${GUIFICATIONS_UNINST_EXE}"
    Goto install_files

  instrights_none:
    ; No registry keys for us...

  install_files:
    SetOutPath "$INSTDIR\plugins"
    SetCompress Auto
    SetOverwrite on
    File "src\${GUIFICATIONS_DLL}"

    SetOutPath "$INSTDIR\pixmaps\pidgin\guifications\conf"
    File "pixmaps\*.png"

    SetOutPath "$INSTDIR\pixmaps\pidgin\guifications\themes\default"
    File "themes\default\theme.xml"
    File "themes\default\background.png"
    SetOutPath "$INSTDIR\pixmaps\pidgin\guifications\themes\mini"
    File "themes\mini\theme.xml"
    File "themes\mini\background.png"
    SetOutPath "$INSTDIR\pixmaps\pidgin\guifications\themes\Penguins"
    File "themes\Penguins\theme.xml"
    File "themes\Penguins\penguin.png"

    ; translations - if there is a way to automate this, i can't find it
    !insertmacro INSTALL_GMO "bn"
    !insertmacro INSTALL_GMO "cs"
    !insertmacro INSTALL_GMO "de"
    !insertmacro INSTALL_GMO "en_AU"
    !insertmacro INSTALL_GMO "en_GB"
    !insertmacro INSTALL_GMO "es"
    !insertmacro INSTALL_GMO "fr"
    !insertmacro INSTALL_GMO "gl"
    !insertmacro INSTALL_GMO "he"
    !insertmacro INSTALL_GMO "hu"
    !insertmacro INSTALL_GMO "it"
    !insertmacro INSTALL_GMO "ja"
    !insertmacro INSTALL_GMO "mk"
    !insertmacro INSTALL_GMO "nl"
    !insertmacro INSTALL_GMO "no"
    !insertmacro INSTALL_GMO "pt"
    !insertmacro INSTALL_GMO "pt_BR"
    !insertmacro INSTALL_GMO "ru"
    !insertmacro INSTALL_GMO "sk"
    !insertmacro INSTALL_GMO "sr"
    !insertmacro INSTALL_GMO "sr@Latn"
    !insertmacro INSTALL_GMO "sv"
    !insertmacro INSTALL_GMO "uk"
    !insertmacro INSTALL_GMO "zh_CN"
    !insertmacro INSTALL_GMO "zh_TW"

    StrCmp $R0 "NONE" done
    CreateShortCut "$SMPROGRAMS\Pidgin\${GUIFICATIONS_UNINSTALL_LNK}" "$INSTDIR\${GUIFICATIONS_UNINST_EXE}"
    WriteUninstaller "$INSTDIR\${GUIFICATIONS_UNINST_EXE}"
    SetOverWrite off

  done:
SectionEnd

Section Uninstall
  Call un.CheckUserInstallRights
  Pop $R0
  StrCmp $R0 "NONE" no_rights
  StrCmp $R0 "HKCU" try_hkcu try_hklm

  try_hkcu:
    ReadRegStr $R0 HKCU "${GUIFICATIONS_REG_KEY}" ""
    StrCmp $R0 $INSTDIR 0 cant_uninstall
      ; HKCU install path matches our INSTDIR.. so uninstall
      DeleteRegKey HKCU "${GUIFICATIONS_REG_KEY}"
      DeleteRegKey HKCU "${GUIFICATIONS_UNINSTALL_KEY}"
      Goto cont_uninstall

  try_hklm:
    ReadRegStr $R0 HKLM "${GUIFICATIONS_REG_KEY}" ""
    StrCmp $R0 $INSTDIR 0 try_hkcu
      ; HKLM install path matches our INSTDIR.. so uninstall
      DeleteRegKey HKLM "${GUIFICATIONS_REG_KEY}"
      DeleteRegKey HKLM "${GUIFICATIONS_UNINSTALL_KEY}"
      ; Sets start menu and desktop scope to all users..
      SetShellVarContext "all"

  cont_uninstall:
    ; plugin
    Delete "$INSTDIR\plugins\${GUIFICATIONS_DLL}"
    ; pixmaps
    RMDir /r "$INSTDIR\pixmaps\pidgin\guifications"

    ; translations
    ; loop through locale dirs and try to delete any guifications translations
    ClearErrors
    FindFirst $R1 $R2 "$INSTDIR\locale\*"
    IfErrors doneFindingTranslations

    processCurrentTranslationDir:
      ;Ignore "." and ".."
      StrCmp $R2 "." readNextTranslationDir
      StrCmp $R2 ".." readNextTranslationDir
      IfFileExists "$INSTDIR\locale\$R2\LC_MESSAGES\guifications.mo" +1 readNextTranslationDir
      Delete "$INSTDIR\locale\$R2\LC_MESSAGES\guifications.mo"
      RMDir  "$INSTDIR\locale\$R2\LC_MESSAGES"
      RMDir  "$INSTDIR\locale\$R2"
      ClearErrors
    readNextTranslationDir:
      FindNext $R1 $R2
    IfErrors doneFindingTranslations processCurrentTranslationDir

    doneFindingTranslations:
    FindClose $R1
    RMDir  "$INSTDIR\locale"

    ; uninstaller
    Delete "$INSTDIR\${GUIFICATIONS_UNINST_EXE}"
    ; uninstaller shortcut
    Delete "$SMPROGRAMS\Pidgin\${GUIFICATIONS_UNINSTALL_LNK}"

    ; try to delete the Pidgin directories, in case it has already uninstalled
    RMDir "$INSTDIR\plugins"
    RMDir "$INSTDIR"
    RMDir "$SMPROGRAMS\Pidgin"

    Goto done

  cant_uninstall:
    MessageBox MB_OK $(un.GUIFICATIONS_UNINSTALL_ERROR_1) IDOK
    Quit

  no_rights:
    MessageBox MB_OK $(un.GUIFICATIONS_UNINSTALL_ERROR_2) IDOK
    Quit

  done:
SectionEnd

Function .onInit
  ${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:

FunctionEnd

Function un.onInit
  ; Get stored language preference
  !insertmacro MUI_UNGETLANGUAGE
FunctionEnd


; Check that the selected installation dir contains pidgin.exe
Function .onVerifyInstDir
  IfFileExists $INSTDIR\pidgin.exe +2
    Abort
FunctionEnd

; Check that the currently installed pidgin version is compatible with the version of guifications we are installing
Function gf_checkPidginVersion
  Push $R0

  Push ${PIDGIN_VERSION}
  Call CheckPidginVersion
  Pop $R0

  StrCmp $R0 ${PIDGIN_VERSION_OK} gf_checkPidginVersion_OK
  StrCmp $R0 ${PIDGIN_VERSION_INCOMPATIBLE} +1 +6
    Call GetPidginVersion
    IfErrors +3
    Pop $R0
    MessageBox MB_OK|MB_ICONSTOP "$(BAD_PIDGIN_VERSION_1) $R0 $(BAD_PIDGIN_VERSION_2)"
    goto +2
    MessageBox MB_OK|MB_ICONSTOP "$(NO_PIDGIN_VERSION)"
    Quit

  gf_checkPidginVersion_OK:
  Pop $R0
FunctionEnd

Function CheckUserInstallRights
  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:
  Push $1
FunctionEnd

; This is necessary because the uninstaller doesn't have access to installer functions
; (it is identical to CheckUserInstallRights)
Function un.CheckUserInstallRights
  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:
  Push $1
FunctionEnd