All pastes #979060 Raw Edit

Something

public text v1 · immutable
·published 2008-04-10 01:25 UTC
rendered paste body
;Copyright (C) 2004-2007 John T. Haller
;Copyright (C) 2007 Ryan McCue
;Copyright (C) 2008 Oliver Krystal

;Website: http://PortableApps.com/PNotesPortable

;This software is OSI Certified Open Source Software.
;OSI Certified is a certification mark of the Open Source Initiative.

;This program is free software; you can redistribute it and/or
;modify it under the terms of the GNU General Public License
;as published by the Free Software Foundation; either version 2
;of the License, or (at your option) any later version.

;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;GNU General Public License for more details.

;You should have received a copy of the GNU General Public License
;along with this program; if not, write to the Free Software
;Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
!define PORTABLEAPPNAME "PNotes Portable"
!define APPNAME "PNotes"
!define NAME "PnotesPortable"
!define VER "1.5.7.0"
!define WEBSITE "PortableApps.com/PNotesPortable"
!define DEFAULTEXE "PNotes.exe"
!define DEFAULTAPPDIR "PNotes"
!define DEFAULTSETTINGSDIR "settings"

;=== Program Details
Name "${PORTABLEAPPNAME}"
OutFile "..\..\${NAME}.exe"
Caption "${PORTABLEAPPNAME} | PortableApps.com"
VIProductVersion "${VER}"
VIAddVersionKey ProductName "${PORTABLEAPPNAME}"
VIAddVersionKey Comments "Allows ${APPNAME} to be run from a removable drive.  For additional details, visit ${WEBSITE}"
VIAddVersionKey CompanyName "PortableApps.com"
VIAddVersionKey LegalCopyright "PortableApps.com and contributers"
VIAddVersionKey FileDescription "${PORTABLEAPPNAME}"
VIAddVersionKey FileVersion "${VER}"
VIAddVersionKey ProductVersion "${VER}"
VIAddVersionKey InternalName "${PORTABLEAPPNAME}"
VIAddVersionKey LegalTrademarks "PortableApps.com is a Trademark of Rare Ideas, LLC."
VIAddVersionKey OriginalFilename "${NAME}.exe"

;=== Runtime Switches
CRCCheck On
WindowIcon Off
SilentInstall Silent
AutoCloseWindow True
RequestExecutionLevel user

; Best Compression
SetCompress Auto
SetCompressor /SOLID lzma
SetCompressorDictSize 32
SetDatablockOptimize On

;=== Program Icon
Icon "..\..\App\AppInfo\appicon.ico" ;defines the icon for the script

;=== Icon & Stye ===
!define MUI_ICON "..\..\App\AppInfo\appicon.ico"

;=== Include
!include "MUI.nsh" ;for multi language support
!insertmacro MUI_LANGUAGE "English"

;=== Languages

LangString LauncherFileNotFound ${LANG_ENGLISH} "${PORTABLEAPPNAME} cannot be started. You may wish to re-install to fix this issue. (ERROR: $MISSINGFILEORPATH could not be found)"
LangString LauncherAlreadyRunning ${LANG_ENGLISH} "Another instance of ${APPNAME} is already running. Please close other instances of ${APPNAME} before launching ${PORTABLEAPPNAME}."
LangString LauncherAskCopyLocal ${LANG_ENGLISH} "${PORTABLEAPPNAME} appears to be running from a location that is read-only. Would you like to temporarily copy it to the local hard drive and run it from there?$\n$\nPrivacy Note: If you say Yes, your personal data within ${PORTABLEAPPNAME} will be temporarily copied to a local drive. Although this copy of your data will be deleted when you close ${PORTABLEAPPNAME}, it may be possible for someone else to access your data later."
LangString LauncherNoReadOnly ${LANG_ENGLISH} "${PORTABLEAPPNAME} can not run directly from a read-only location and will now close."


Var PROGRAMDIRECTORY
Var SETTINGSDIRECTORY
Var EXECSTRING
Var WAITFORPROGRAM
Var PROGRAMEXECUTABLE
Var DISABLESPLASHSCREEN
Var ISDEFAULTDIRECTORY
Var APPLANGUAGE

Section "Main"

	
	;ReadINI:
		ReadINIStr $WAITFORPROGRAM "$EXEDIR\${NAME}.ini" "${PORTABLEAPPNAME}" "WaitFor${APPNAME}"
		ReadINIStr $DISABLESPLASHSCREEN "$EXEDIR\${NAME}.ini" "${NAME}" "DisableSplashScreen"

		;=== Any missing unrequired INI entries will be an empty string, ignore associated errors
		ClearErrors

		StrCpy "$PROGRAMEXECUTABLE" "${DEFAULTEXE}"

		IfFileExists "$EXEDIR\App\${DEFAULTAPPDIR}\${DEFAULTEXE}" "" NoProgramEXE
			StrCpy "$PROGRAMDIRECTORY" "$EXEDIR\App\${DEFAULTAPPDIR}"
			StrCpy "$SETTINGSDIRECTORY" "$EXEDIR\Data\${DEFAULTSETTINGSDIR}"
			StrCpy "$ISDEFAULTDIRECTORY" "true";
	
	;EndINI:
		IfFileExists "$PROGRAMDIRECTORY\$PROGRAMEXECUTABLE" FoundProgramEXE
	
	NoProgramEXE:
		;=== Program executable not where expected
		MessageBox MB_OK|MB_ICONEXCLAMATION `$PROGRAMEXECUTABLE was not found.  Please check your configuration`
		Abort
		
	FoundProgramEXE:
		StrCmp $DISABLESPLASHSCREEN "true" SkipSplashScreen
			;=== Show the splash screen before processing the files
			InitPluginsDir
			File /oname=$PLUGINSDIR\splash.jpg "${NAME}.jpg"
			newadvsplash::show /NOUNLOAD 2000 0 0 -1 /L $PLUGINSDIR\splash.jpg
			
	SkipSplashScreen:
		StrCpy $EXECSTRING `"$PROGRAMDIRECTORY\$PROGRAMEXECUTABLE" -conf "$SETTINGSDIRECTORY" "$SETTINGSDIRECTORY"`
		StrCmp $SETTINGSDIRECTORY "" SettingsNotFound
		IfFileExists "$SETTINGSDIRECTORY\*.*" LaunchNow
	
	SettingsNotFound:
		StrCmp $ISDEFAULTDIRECTORY "true" SetupDefaultSettings
		MessageBox MB_OK|MB_ICONEXCLAMATION `$SETTINGSDIRECTORY was not found.  Please check your configuration`
		Abort

	SetupDefaultSettings:
		CreateDirectory "$EXEDIR\Data\settings"
		GoTo GetAppLanguage
	
	GetAppLanguage:
		ReadEnvStr $APPLANGUAGE "PortableApps.comLanguageCode"
		StrCmp $APPLANGUAGE "" LaunchNow ;if not set, move on
		StrCmp $APPLANGUAGE "en-us" "" GetCurrentLanguage

	GetCurrentLanguage:
		StrCpy $0 "$EXEDIR\Data\settings\Notes.ini" "lang" "file"
		StrCmp "$APPLANGUAGE" $0 LaunchNow ;if the same, move on
		StrCmp $APPLANGUAGE "en-us" SetAppLanguage ;english is built in, so skip locale file check
		IfFileExists "$EXEDIR\PNotes\lang\$APPLANGUAGE.lng" SetAppLanguage LaunchNow

	SetAppLanguage:
		WriteINIStr "$EXEDIR\Data\settings\Notes.ini" "lang" "file" "$APPLANGUAGE.lng"
	
	LaunchNow:
		StrCmp $WAITFORPROGRAM "true" LaunchAndWait LaunchAndClose

	LaunchAndWait:
		ExecWait $EXECSTRING
		GoTo TheEnd

	LaunchAndClose:
		Exec $EXECSTRING
		Sleep 2000 ;=== allow the splash screen to show for at least 2 seconds after starting

	TheEnd:
		newadvsplash::stop /WAIT
SectionEnd