| 1 | /** |
|---|
| 2 | * Global variables, already defined. |
|---|
| 3 | * |
|---|
| 4 | * If you add a global variable, declare it here as commented. |
|---|
| 5 | */ |
|---|
| 6 | ;!define PRODUCT_NAME "WengoPhone" |
|---|
| 7 | ;!define PRODUCT_VERSION "x.y.z" |
|---|
| 8 | ;!define PRODUCT_VERSION_1 "x" |
|---|
| 9 | ;!define PRODUCT_VERSION_2 "y" |
|---|
| 10 | ;!define PRODUCT_VERSION_3 "z" |
|---|
| 11 | ;!define PRODUCT_VERSION_4 "0" |
|---|
| 12 | ;!define DEBUG |
|---|
| 13 | ;!define BUILD_DIR "..\..\release-symbols\" |
|---|
| 14 | ;!define INSTALLER_NAME "WengoPhone-setup-0.13.exe" |
|---|
| 15 | ;!define QTDIR "C:\Qt\4.1.1\" |
|---|
| 16 | ;!define WITH_PDB |
|---|
| 17 | ;!define BINARY_NAME "qtwengophone" |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | !define PRODUCT_PUBLISHER "QuteCom" |
|---|
| 21 | !define PRODUCT_WEB_SITE "http://www.QuteCom.org" |
|---|
| 22 | !define PRODUCT_REGKEY "Software\${PRODUCT_NAME}" |
|---|
| 23 | !define PRODUCT_UNINSTALL_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" |
|---|
| 24 | |
|---|
| 25 | ; Version information for the installer executable |
|---|
| 26 | VIAddVersionKey ProductName "${PRODUCT_NAME}" |
|---|
| 27 | VIAddVersionKey ProductVersion "${PRODUCT_VERSION}" |
|---|
| 28 | VIAddVersionKey Comments "${PRODUCT_NAME}, a voice over Internet phone" |
|---|
| 29 | VIAddVersionKey CompanyName "${PRODUCT_PUBLISHER}" |
|---|
| 30 | VIAddVersionKey LegalCopyright "Copyright (C) 2004-2007 QuteCom" |
|---|
| 31 | VIAddVersionKey LegalTrademarks "QuteCom" |
|---|
| 32 | VIAddVersionKey FileDescription "${PRODUCT_NAME}" |
|---|
| 33 | VIAddVersionKey FileVersion "${PRODUCT_VERSION}" |
|---|
| 34 | VIAddVersionKey InternalName "${PRODUCT_NAME}" |
|---|
| 35 | VIAddVersionKey OriginalFilename "${INSTALLER_NAME}" |
|---|
| 36 | VIProductVersion "${PRODUCT_VERSION_1}.${PRODUCT_VERSION_2}.${PRODUCT_VERSION_3}.${PRODUCT_VERSION_4}" |
|---|
| 37 | |
|---|
| 38 | SetCompressor lzma |
|---|
| 39 | XPStyle on |
|---|
| 40 | |
|---|
| 41 | !macro LANG_STRING NAME VALUE |
|---|
| 42 | LangString "${NAME}" "${LANG_${LANG}}" "${VALUE}" |
|---|
| 43 | !macroend |
|---|
| 44 | |
|---|
| 45 | !macro LANG_UNSTRING NAME VALUE |
|---|
| 46 | !insertmacro LANG_STRING "un.${NAME}" "${VALUE}" |
|---|
| 47 | !macroend |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | ; Modern UI 1.67 compatible |
|---|
| 51 | !include "MUI.nsh" |
|---|
| 52 | |
|---|
| 53 | ; MUI Settings |
|---|
| 54 | !define MUI_ABORTWARNING |
|---|
| 55 | !define MUI_ICON "..\src\presentation\qt\win32\application.ico" |
|---|
| 56 | !define MUI_UNICON "..\src\presentation\qt\win32\application.ico" |
|---|
| 57 | |
|---|
| 58 | ; Language Selection Dialog Settings |
|---|
| 59 | ; Remember the installer language |
|---|
| 60 | !define MUI_LANGDLL_REGISTRY_ROOT "HKCU" |
|---|
| 61 | !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_REGKEY}" |
|---|
| 62 | !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language" |
|---|
| 63 | |
|---|
| 64 | ; Pages |
|---|
| 65 | !insertmacro MUI_PAGE_WELCOME |
|---|
| 66 | !insertmacro MUI_PAGE_LICENSE $(license) |
|---|
| 67 | !insertmacro MUI_PAGE_DIRECTORY |
|---|
| 68 | !insertmacro MUI_PAGE_INSTFILES |
|---|
| 69 | !define MUI_FINISHPAGE_RUN "$INSTDIR\${BINARY_NAME}.exe" |
|---|
| 70 | !insertmacro MUI_PAGE_FINISH |
|---|
| 71 | |
|---|
| 72 | !insertmacro MUI_UNPAGE_CONFIRM |
|---|
| 73 | !insertmacro MUI_UNPAGE_INSTFILES |
|---|
| 74 | !insertmacro MUI_UNPAGE_FINISH |
|---|
| 75 | |
|---|
| 76 | ; Language files, first language is the default language |
|---|
| 77 | !insertmacro MUI_LANGUAGE "English" |
|---|
| 78 | !insertmacro MUI_LANGUAGE "French" |
|---|
| 79 | |
|---|
| 80 | ; Loads license translation |
|---|
| 81 | LicenseLangString license ${LANG_ENGLISH} "..\COPYING" |
|---|
| 82 | LicenseLangString license ${LANG_FRENCH} "..\COPYING" |
|---|
| 83 | LicenseData $(license) |
|---|
| 84 | |
|---|
| 85 | ; Reserve files |
|---|
| 86 | !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS |
|---|
| 87 | |
|---|
| 88 | ; MUI end |
|---|
| 89 | |
|---|
| 90 | Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" |
|---|
| 91 | /** Installer name (e.g. WengoPhone-setup-0.13.exe). */ |
|---|
| 92 | OutFile "${INSTALLER_NAME}" |
|---|
| 93 | |
|---|
| 94 | !define WND_CLASS "QWidget" |
|---|
| 95 | !define WND_TITLE "WengoPhone" |
|---|
| 96 | !define TO_MS 2000 |
|---|
| 97 | !define SYNC_TERM 0x00100001 |
|---|
| 98 | |
|---|
| 99 | !macro TerminateApp |
|---|
| 100 | Push $0 |
|---|
| 101 | Push $1 |
|---|
| 102 | Push $2 |
|---|
| 103 | DetailPrint "Stopping ${WND_TITLE} Application" |
|---|
| 104 | FindWindow $0 '${WND_CLASS}' '${WND_TITLE}' |
|---|
| 105 | IntCmp $0 0 done |
|---|
| 106 | System::Call 'user32.dll::GetWindowThreadProcessId(i r0, *i .r1) i .r2' |
|---|
| 107 | System::Call 'kernel32.dll::OpenProcess(i ${SYNC_TERM}, i 0, i r1) i .r2' |
|---|
| 108 | SendMessage $0 ${WM_CLOSE} 0 0 /TIMEOUT=${TO_MS} |
|---|
| 109 | System::Call 'kernel32.dll::WaitForSingleObject(i r2, i ${TO_MS}) i .r1' |
|---|
| 110 | IntCmp $1 0 close |
|---|
| 111 | System::Call 'kernel32.dll::TerminateProcess(i r2, i 0) i .r1' |
|---|
| 112 | close: |
|---|
| 113 | System::Call 'kernel32.dll::CloseHandle(i r2) i .r1' |
|---|
| 114 | done: |
|---|
| 115 | Pop $2 |
|---|
| 116 | Pop $1 |
|---|
| 117 | Pop $0 |
|---|
| 118 | !macroend |
|---|
| 119 | |
|---|
| 120 | !include "functions.nsi" |
|---|
| 121 | Function .onInit |
|---|
| 122 | |
|---|
| 123 | !insertmacro TerminateApp |
|---|
| 124 | |
|---|
| 125 | /** For future use */ |
|---|
| 126 | /** TODO: just if an instance is detected */ |
|---|
| 127 | /** tells qtwengophone.exe to exit */ |
|---|
| 128 | ;push 685 |
|---|
| 129 | ;push "WengoPhone" |
|---|
| 130 | ;push "QWidget" |
|---|
| 131 | ;call SendMessage |
|---|
| 132 | |
|---|
| 133 | !insertmacro MUI_LANGDLL_DISPLAY |
|---|
| 134 | |
|---|
| 135 | Call IsSilent |
|---|
| 136 | Pop $0 |
|---|
| 137 | StrCmp $0 1 0 +2 |
|---|
| 138 | goto initDone |
|---|
| 139 | |
|---|
| 140 | Call isUserAdmin |
|---|
| 141 | Pop $R0 |
|---|
| 142 | StrCmp $R0 "true" isAdmin |
|---|
| 143 | ; Not an admin |
|---|
| 144 | StrCpy $INSTDIR "$DOCUMENTS\${PRODUCT_NAME}" |
|---|
| 145 | goto initDone |
|---|
| 146 | isAdmin: |
|---|
| 147 | ; User is admin |
|---|
| 148 | StrCpy $INSTDIR "$PROGRAMFILES\${PRODUCT_NAME}" |
|---|
| 149 | initDone: |
|---|
| 150 | FunctionEnd |
|---|
| 151 | |
|---|
| 152 | ; Gets installation folder from registry if available |
|---|
| 153 | InstallDirRegKey HKCU "${PRODUCT_REGKEY}" "" |
|---|
| 154 | |
|---|
| 155 | ShowInstDetails show |
|---|
| 156 | ShowUnInstDetails show |
|---|
| 157 | |
|---|
| 158 | Section BaseSection |
|---|
| 159 | !include "files_install.nsi" |
|---|
| 160 | |
|---|
| 161 | ;!ifdef MSVC80 |
|---|
| 162 | ;;;;Silent |
|---|
| 163 | ExecWait '$INSTDIR\vcredist_x86.exe /q:a /c:"VCREDI~3.EXE /q:a /c:""msiexec /i vcredist.msi /qn"" "' |
|---|
| 164 | ;;;;;;;;;; |
|---|
| 165 | ;; ExecWait '"$INSTDIR\Vcredist_x86.exe"' |
|---|
| 166 | ;!endif |
|---|
| 167 | |
|---|
| 168 | SectionEnd |
|---|
| 169 | |
|---|
| 170 | Section -AdditionalIcons |
|---|
| 171 | WriteIniStr "$INSTDIR\${PRODUCT_PUBLISHER}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}" |
|---|
| 172 | CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME} Website.lnk" "$INSTDIR\${PRODUCT_PUBLISHER}.url" |
|---|
| 173 | CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME} Uninstall.lnk" "$INSTDIR\uninstall.exe" |
|---|
| 174 | SectionEnd |
|---|
| 175 | |
|---|
| 176 | Section -Post |
|---|
| 177 | ; Stores installation folder |
|---|
| 178 | WriteRegStr HKCU "${PRODUCT_REGKEY}" "" $INSTDIR |
|---|
| 179 | |
|---|
| 180 | ; Creates uninstaller |
|---|
| 181 | WriteUninstaller "$INSTDIR\uninstall.exe" |
|---|
| 182 | |
|---|
| 183 | WriteRegStr HKLM "${PRODUCT_UNINSTALL_KEY}" "DisplayName" "$(^Name)" |
|---|
| 184 | WriteRegStr HKLM "${PRODUCT_UNINSTALL_KEY}" "UninstallString" "$INSTDIR\uninstall.exe" |
|---|
| 185 | WriteRegStr HKLM "${PRODUCT_UNINSTALL_KEY}" "DisplayIcon" "$INSTDIR\${BINARY_NAME}.exe" |
|---|
| 186 | WriteRegStr HKLM "${PRODUCT_UNINSTALL_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" |
|---|
| 187 | WriteRegStr HKLM "${PRODUCT_UNINSTALL_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}" |
|---|
| 188 | WriteRegStr HKLM "${PRODUCT_UNINSTALL_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" |
|---|
| 189 | SectionEnd |
|---|
| 190 | |
|---|
| 191 | Function un.onInit |
|---|
| 192 | !insertmacro MUI_UNGETLANGUAGE |
|---|
| 193 | FunctionEnd |
|---|
| 194 | |
|---|
| 195 | Section Uninstall |
|---|
| 196 | !include "files_uninstall.nsi" |
|---|
| 197 | SectionEnd |
|---|