diff --git a/admin/win/nsi/tomahawk.nsi b/admin/win/nsi/tomahawk.nsi index e7f1ce251..e724d3df9 100644 --- a/admin/win/nsi/tomahawk.nsi +++ b/admin/win/nsi/tomahawk.nsi @@ -4,7 +4,7 @@ ; Some installer script options (comment-out options not required) ;----------------------------------------------------------------------------- ;!define OPTION_LICENSE_AGREEMENT -;!define OPTION_UAC_PLUGIN_ENHANCED +!define OPTION_UAC_PLUGIN_ENHANCED !define OPTION_SECTION_SC_START_MENU !define OPTION_SECTION_SC_DESKTOP !define OPTION_SECTION_SC_QUICK_LAUNCH @@ -58,17 +58,10 @@ InstType Full InstType Minimal CRCCheck On SetCompressor /SOLID lzma +RequestExecutionLevel user ;Now using the UAC plugin. ReserveFile tomahawk.ini ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll" -;The UAC plugin provides an elevated user. -;Otherwise request admin level here. -!ifdef OPTION_UAC_PLUGIN_ENHANCED - RequestExecutionLevel user -!else - RequestExecutionLevel admin -!endif - ;----------------------------------------------------------------------------- ; Include some required header files. ;----------------------------------------------------------------------------- @@ -79,9 +72,7 @@ ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll" !include Memento.nsh ;Remember user selections. !include WinVer.nsh ;Windows version detection. !include WordFunc.nsh ;Used by VersionCompare macro function. -!ifdef OPTION_UAC_PLUGIN_ENHANCED - !include UAC.nsh ;Used by the UAC elevation to install as user or admin. -!endif +!include UAC.nsh ;Used by the UAC elevation to install as user or admin. ;----------------------------------------------------------------------------- ; Memento selections stored in registry. @@ -146,18 +137,12 @@ UninstPage custom un.UnPageUserAppData un.UnPageUserAppDataLeave ############################################################################## Function LaunchTomahawk - !ifdef OPTION_UAC_PLUGIN_ENHANCED - ${UAC.CallFunctionAsUser} LaunchTomahawkAsUser - !else - Exec "$INSTDIR\tomahawk.exe" - !endif + ${UAC.CallFunctionAsUser} LaunchTomahawkAsUser FunctionEnd -!ifdef OPTION_UAC_PLUGIN_ENHANCED Function LaunchTomahawkAsUser Exec "$INSTDIR\tomahawk.exe" FunctionEnd -!endif ############################################################################## # # @@ -260,12 +245,10 @@ Function PageLeaveReinstall Delete $R1 RMDir $INSTDIR no_remove_uninstaller: - StrCmp $R0 "2" +2 0 + StrCmp $R0 "2" 0 +3 + UAC::Unload + Quit BringToFront - !ifdef OPTION_UAC_PLUGIN_ENHANCED - UAC::Unload - Quit - !endif reinst_done: FunctionEnd @@ -380,7 +363,7 @@ SectionGroup "Shortcuts" CreateShortCut "$SMPROGRAMS\Tomahawk\LICENSE.lnk" "$INSTDIR\LICENSE.txt" CreateShortCut "$SMPROGRAMS\Tomahawk\Tomahawk.lnk" "$INSTDIR\tomahawk.exe" CreateShortCut "$SMPROGRAMS\Tomahawk\Release notes.lnk" "$INSTDIR\NOTES.txt" - CreateShortCut "$SMPROGRAMS\Tomahawk\Uninstall.lnk" "$INSTDIR\Uninstall.exe" + CreateShortCut "$SMPROGRAMS\Tomahawk\Uninstall.lnk" "$INSTDIR\uninstall.exe" SetShellVarContext current ${MementoSectionEnd} !endif @@ -424,7 +407,7 @@ Section -post SetDetailsPrint textonly DetailPrint "Writing Uninstaller" SetDetailsPrint listonly - WriteUninstaller $INSTDIR\Uninstall.exe + WriteUninstaller $INSTDIR\uninstall.exe ;Registry keys required for installer version handling and uninstaller. SetDetailsPrint textonly @@ -568,27 +551,25 @@ Function .onInit ${MementoSectionRestore} - !ifdef OPTION_UAC_PLUGIN_ENHANCED - UAC_Elevate: - UAC::RunElevated - StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user? - StrCmp 0 $0 0 UAC_Err ; Error? - StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper? - Quit + UAC_Elevate: + UAC::RunElevated + StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user? + StrCmp 0 $0 0 UAC_Err ; Error? + StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper? + Quit - UAC_Err: - MessageBox MB_ICONSTOP "Unable to elevate, error $0" - Abort + UAC_Err: + MessageBox MB_ICONSTOP "Unable to elevate, error $0" + Abort - UAC_ElevationAborted: - Abort + UAC_ElevationAborted: + Abort - UAC_Success: - StrCmp 1 $3 +4 ;Admin? - StrCmp 3 $1 0 UAC_ElevationAborted ;Try again? - MessageBox MB_ICONSTOP "This installer requires admin access, try again" - goto UAC_Elevate - !endif + UAC_Success: + StrCmp 1 $3 +4 ;Admin? + StrCmp 3 $1 0 UAC_ElevationAborted ;Try again? + MessageBox MB_ICONSTOP "This installer requires admin access, try again" + goto UAC_Elevate ;Prevent multiple instances. System::Call 'kernel32::CreateMutexA(i 0, i 0, t "tomahawkInstaller") i .r1 ?e' @@ -610,15 +591,11 @@ FunctionEnd Function .onInstSuccess ${MementoSectionSave} - !ifdef OPTION_UAC_PLUGIN_ENHANCED - UAC::Unload ;Must call unload! - !endif + UAC::Unload ;Must call unload! FunctionEnd Function .onInstFailed - !ifdef OPTION_UAC_PLUGIN_ENHANCED - UAC::Unload ;Must call unload! - !endif + UAC::Unload ;Must call unload! FunctionEnd ############################################################################## @@ -628,27 +605,25 @@ FunctionEnd ############################################################################## Function un.onInit - !ifdef OPTION_UAC_PLUGIN_ENHANCED - UAC_Elevate: - UAC::RunElevated - StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user? - StrCmp 0 $0 0 UAC_Err ; Error? - StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper? - Quit + UAC_Elevate: + UAC::RunElevated + StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user? + StrCmp 0 $0 0 UAC_Err ; Error? + StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper? + Quit - UAC_Err: - MessageBox MB_ICONSTOP "Unable to elevate, error $0" - Abort + UAC_Err: + MessageBox MB_ICONSTOP "Unable to elevate, error $0" + Abort - UAC_ElevationAborted: - Abort + UAC_ElevationAborted: + Abort - UAC_Success: - StrCmp 1 $3 +4 ;Admin? - StrCmp 3 $1 0 UAC_ElevationAborted ;Try again? - MessageBox MB_ICONSTOP "This uninstaller requires admin access, try again" - goto UAC_Elevate - !endif + UAC_Success: + StrCmp 1 $3 +4 ;Admin? + StrCmp 3 $1 0 UAC_ElevationAborted ;Try again? + MessageBox MB_ICONSTOP "This uninstaller requires admin access, try again" + goto UAC_Elevate ;Prevent multiple instances. System::Call 'kernel32::CreateMutexA(i 0, i 0, t "tomahawkUninstaller") i .r1 ?e' @@ -659,13 +634,9 @@ Function un.onInit FunctionEnd Function un.onUnInstSuccess - !ifdef OPTION_UAC_PLUGIN_ENHANCED - UAC::Unload ;Must call unload! - !endif + UAC::Unload ;Must call unload! FunctionEnd Function un.onUnInstFailed - !ifdef OPTION_UAC_PLUGIN_ENHANCED - UAC::Unload ;Must call unload! - !endif + UAC::Unload ;Must call unload! FunctionEnd diff --git a/src/main.cpp b/src/main.cpp index 415be1d15..3a6d6936e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -38,8 +38,8 @@ main( int argc, char *argv[] ) // used for url handler AEEventHandlerUPP h = AEEventHandlerUPP( appleEventHandler ); AEInstallEventHandler( 'GURL', 'GURL', h, 0, false ); - #endif + TomahawkApp a( argc, argv ); KDSingleApplicationGuard guard( &a, KDSingleApplicationGuard::AutoKillOtherInstances ); QObject::connect( &guard, SIGNAL( instanceStarted( KDSingleApplicationGuard::Instance ) ), &a, SLOT( instanceStarted( KDSingleApplicationGuard::Instance ) ) );