Bug 14807; handle WM_QUERYENDSESSION (Windows logoff/session) using -killAll; r=sgehani@netscape.com, sr=blaker@netscape.com
git-svn-id: svn://10.0.0.236/trunk@121585 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
3ff1450226
commit
501a96a7c3
@ -772,7 +772,7 @@ static nsresult HandleArbitraryStartup( nsICmdLineService* cmdLineArgs, nsIPref
|
||||
rv = LaunchApplicationWithArgs((const char *)(argv[i]),
|
||||
cmdLineArgs, command,
|
||||
height, width, windowOpened);
|
||||
if (rv == NS_ERROR_NOT_AVAILABLE) {
|
||||
if (rv == NS_ERROR_NOT_AVAILABLE || rv == NS_ERROR_ABORT) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
@ -927,6 +927,28 @@ struct MessageWindow {
|
||||
(void)nsNativeAppSupportWin::HandleRequest( (LPBYTE)"mozilla" );
|
||||
}
|
||||
return TRUE;
|
||||
} else if ( msg == WM_QUERYENDSESSION ) {
|
||||
// Invoke "-killAll" cmd line handler. That will close all open windows,
|
||||
// and display dialog asking whether to save/don't save/cancel. If the
|
||||
// user says cancel, then we pass that indicator along to the system
|
||||
// in order to stop the system shutdown/logoff.
|
||||
nsCOMPtr<nsICmdLineHandler>
|
||||
killAll( do_CreateInstance( "@mozilla.org/commandlinehandler/general-startup;1?type=killAll" ) );
|
||||
if ( killAll ) {
|
||||
nsXPIDLCString unused;
|
||||
// Note: "GetChromeUrlForTask" is a euphemism for
|
||||
// "ProcessYourCommandLineSwitch". The interface was written
|
||||
// presuming a less general-purpose role for command line
|
||||
// handlers than it ought to have.
|
||||
nsresult rv = killAll->GetChromeUrlForTask( getter_Copies( unused ) );
|
||||
if ( rv == NS_ERROR_ABORT ) {
|
||||
// User cancelled shutdown/logoff.
|
||||
return FALSE;
|
||||
} else {
|
||||
// Shutdown/logoff OK.
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return DefWindowProc( msgWindow, msg, wp, lp );
|
||||
}
|
||||
@ -1635,7 +1657,7 @@ nsNativeAppSupportWin::HandleRequest( LPBYTE request, PRBool newWindow ) {
|
||||
|
||||
// If a window was opened, then we're done.
|
||||
// Note that we keep on trying in the unlikely event of an error.
|
||||
if (rv == NS_ERROR_NOT_AVAILABLE || windowOpened) {
|
||||
if (rv == NS_ERROR_NOT_AVAILABLE || rv == NS_ERROR_ABORT || windowOpened) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -109,8 +109,8 @@ nsKillAll.prototype = {
|
||||
if (("tryToClose" in domWindow) && !domWindow.tryToClose()) {
|
||||
// user pressed cancel in response to dialog for closing an unsaved window
|
||||
nativeAppSupport.isServerMode = originalServerMode
|
||||
throw Components.results.NS_ERROR_NOT_AVAILABLE;
|
||||
// see comment below for why we throw NS_ERROR_NOT_AVAILABLE
|
||||
// Return NS_ERROR_ABORT to inform caller of the "cancel."
|
||||
throw Components.results.NS_ERROR_ABORT;
|
||||
}
|
||||
domWindow.close();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user