Files
atmosphere/installer/hooks.nsh
T
Christian a5c6c2503b Linked playlist folders, local API, installer agreement
- Add existing folders as playlists; they're never moved or deleted by Atmosphere
- Missing linked folders show Locate and Remove, and return when the drive reconnects
- Opt-in local API for other apps: loopback only, hashed token, per-permission access,
  browser and DNS-rebinding requests refused, lockout after repeated bad tokens
- Live now-playing events, library browsing, playback and queue control, links to Get
- API guide in docs/api.md
- Agreeing on the Windows installer's licence page counts as the rights agreement
- Drop the redundant DRM line from the welcome screen
2026-11-18 21:03:56 -05:00

52 lines
1.9 KiB
NSIS

; atmosphere · hooks.nsh · Installer hooks: record the rights agreement, offer a backup before removing data, and remove Atmosphere's own data only when asked
!define ATMO_TERMS_VERSION 1
!macro NSIS_HOOK_POSTINSTALL
${If} $PassiveMode <> 1
${AndIf} $UpdateMode <> 1
${AndIfNot} ${Silent}
FileOpen $R9 "$INSTDIR\rights-accepted" w
FileWrite $R9 "terms=${ATMO_TERMS_VERSION}"
FileClose $R9
${EndIf}
!macroend
!macro NSIS_HOOK_PREUNINSTALL
${If} $UpdateMode <> 1
${AndIf} $DeleteAppDataCheckboxState = 1
SetShellVarContext current
MessageBox MB_YESNO|MB_ICONQUESTION "Atmosphere will remove your settings, listening stats, liked songs and artist photos.$\r$\n$\r$\nSave a backup to your Documents folder first? You can restore it later from Settings, Storage.$\r$\n$\r$\nYour music files are never touched." /SD IDNO IDNO atmo_skip_backup
StrCpy $R0 "$DOCUMENTS\Atmosphere backup.zip"
StrCpy $R1 1
atmo_name_loop:
IfFileExists "$R0" 0 atmo_name_done
IntOp $R1 $R1 + 1
StrCpy $R0 "$DOCUMENTS\Atmosphere backup ($R1).zip"
Goto atmo_name_loop
atmo_name_done:
ExecWait '"$INSTDIR\${MAINBINARYNAME}.exe" --backup "$R0"' $R2
${If} $R2 = 0
${AndIf} ${FileExists} "$R0"
MessageBox MB_OK|MB_ICONINFORMATION "Backup saved to:$\r$\n$R0" /SD IDOK
${Else}
MessageBox MB_YESNO|MB_ICONEXCLAMATION "The backup couldn't be saved. Keep your Atmosphere data instead of removing it?" /SD IDYES IDNO atmo_skip_backup
StrCpy $DeleteAppDataCheckboxState 0
${EndIf}
atmo_skip_backup:
${EndIf}
!macroend
!macro NSIS_HOOK_POSTUNINSTALL
${If} $UpdateMode <> 1
Delete "$INSTDIR\rights-accepted"
RMDir "$INSTDIR"
${EndIf}
${If} $UpdateMode <> 1
${AndIf} $DeleteAppDataCheckboxState = 1
SetShellVarContext current
RmDir /r "$APPDATA\atmosphere"
RmDir /r "$LOCALAPPDATA\atmosphere"
${EndIf}
!macroend