1 diff --git vcl/inc/vcl/salsession.hxx vcl/inc/vcl/salsession.hxx
2 index 13ec237..bff9626 100644
3 --- vcl/inc/vcl/salsession.hxx
4 +++ vcl/inc/vcl/salsession.hxx
5 @@ -102,11 +102,9 @@ public:
6 // query the session manager for a user interaction slot
7 virtual void queryInteraction() = 0;
8 // signal the session manager that we're done with user interaction
9 - virtual void interactionDone() = 0;
10 + virtual void interactionDone( bool bCancelShutdown ) = 0;
11 // signal that we're done saving
12 virtual void saveDone() = 0;
13 - // try to cancel the sutdown in progress
14 - virtual bool cancelShutdown() = 0;
18 diff --git vcl/source/app/session.cxx vcl/source/app/session.cxx
19 index e1ebe1e..7c1f14a 100644
20 --- vcl/source/app/session.cxx
21 +++ vcl/source/app/session.cxx
22 @@ -88,9 +88,8 @@ public:
23 virtual void SAL_CALL addSessionManagerListener( const Reference< XSessionManagerListener >& xListener ) throw( RuntimeException );
24 virtual void SAL_CALL removeSessionManagerListener( const Reference< XSessionManagerListener>& xListener ) throw( RuntimeException );
25 virtual void SAL_CALL queryInteraction( const Reference< XSessionManagerListener >& xListener ) throw( RuntimeException );
26 - virtual void SAL_CALL interactionDone( const Reference< XSessionManagerListener >& xListener ) throw( RuntimeException );
27 + virtual void SAL_CALL interactionDone( const Reference< XSessionManagerListener >& xListener, sal_Bool bCancelShutdown ) throw( RuntimeException );
28 virtual void SAL_CALL saveDone( const Reference< XSessionManagerListener >& xListener ) throw( RuntimeException );
29 - virtual sal_Bool SAL_CALL cancelShutdown() throw( RuntimeException );
32 VCLSession* VCLSession::pOneInstance = NULL;
33 @@ -170,7 +169,7 @@ void VCLSession::callInteractionGranted( bool bInteractionGranted )
34 if( aListeners.empty() )
37 - m_pSession->interactionDone();
38 + m_pSession->interactionDone( false );
42 @@ -272,7 +271,7 @@ void SAL_CALL VCLSession::queryInteraction( const Reference<XSessionManagerListe
46 -void SAL_CALL VCLSession::interactionDone( const Reference< XSessionManagerListener >& xListener ) throw( RuntimeException )
47 +void SAL_CALL VCLSession::interactionDone( const Reference< XSessionManagerListener >& xListener, sal_Bool bCancelShutdown ) throw( RuntimeException )
49 osl::MutexGuard aGuard( m_aMutex );
50 int nRequested = 0, nDone = 0;
51 @@ -291,7 +290,7 @@ void SAL_CALL VCLSession::interactionDone( const Reference< XSessionManagerListe
53 m_bInteractionDone = true;
55 - m_pSession->interactionDone();
56 + m_pSession->interactionDone( bCancelShutdown );
60 @@ -316,11 +315,6 @@ void SAL_CALL VCLSession::saveDone( const Reference< XSessionManagerListener >&
64 -sal_Bool SAL_CALL VCLSession::cancelShutdown() throw( RuntimeException )
66 - return m_pSession ? (sal_Bool)m_pSession->cancelShutdown() : sal_False;
69 // service implementation
71 OUString SAL_CALL vcl_session_getImplementationName()
72 diff --git vcl/unx/inc/sm.hxx vcl/unx/inc/sm.hxx
73 index 998b8ec..03646ba 100644
74 --- vcl/unx/inc/sm.hxx
75 +++ vcl/unx/inc/sm.hxx
76 @@ -39,7 +39,8 @@ class SessionManagerClient
78 static SmcConn aSmcConnection;
79 static ByteString aClientID;
80 - static bool bDocSaveDone;
81 + static bool bDocSaveDone;
82 + static bool bSaveDoneSent;
84 static void SaveYourselfProc( SmcConn connection,
85 SmPointer client_data,
86 @@ -68,8 +69,8 @@ public:
88 static bool checkDocumentsSaved();
89 static bool queryInteraction();
90 - static void saveDone();
91 - static void interactionDone();
92 + static void saveDone( bool bSuccess = true );
93 + static void interactionDone( bool bCancelShutdown = false );
95 static String getExecName();
96 static VCL_DLLPUBLIC const ByteString& getSessionID();
97 @@ -84,9 +85,8 @@ public:
98 virtual ~IceSalSession();
100 virtual void queryInteraction();
101 - virtual void interactionDone();
102 + virtual void interactionDone( bool bCancelShutdown );
103 virtual void saveDone();
104 - virtual bool cancelShutdown();
106 static void handleOldX11SaveYourself( SalFrame* pFrame );
108 diff --git vcl/unx/source/app/sm.cxx vcl/unx/source/app/sm.cxx
109 index c5c25a4..b9ed5ed 100644
110 --- vcl/unx/source/app/sm.cxx
111 +++ vcl/unx/source/app/sm.cxx
112 @@ -112,9 +112,9 @@ void IceSalSession::queryInteraction()
116 -void IceSalSession::interactionDone()
117 +void IceSalSession::interactionDone( bool bCancelShutdown )
119 - SessionManagerClient::interactionDone();
120 + SessionManagerClient::interactionDone( bCancelShutdown );
123 void IceSalSession::saveDone()
124 @@ -127,11 +127,6 @@ void IceSalSession::saveDone()
128 -bool IceSalSession::cancelShutdown()
133 void IceSalSession::handleOldX11SaveYourself( SalFrame* pFrame )
136 @@ -184,6 +179,7 @@ int ICEConnectionObserver::nWakeupFiles[2] = { 0, 0 };
138 bool SessionManagerClient::bDocSaveDone = false;
140 +bool SessionManagerClient::bSaveDoneSent = false;
142 static SmProp* pSmProps = NULL;
143 static SmProp** ppSmProps = NULL;
144 @@ -265,6 +261,12 @@ bool SessionManagerClient::checkDocumentsSaved()
148 +struct SaveYourselfArgs {
151 + int nInteractionStyle;
154 IMPL_STATIC_LINK( SessionManagerClient, SaveYourselfHdl, void*, EMPTYARG )
156 SMprintf( "posting save documents event shutdown = %s\n", (pThis!=0) ? "true" : "false" );
157 @@ -295,7 +297,7 @@ IMPL_STATIC_LINK( SessionManagerClient, SaveYourselfHdl, void*, EMPTYARG )
161 - SalSessionSaveRequestEvent aEvent( pThis != 0, false );
162 + SalSessionSaveRequestEvent aEvent( aSaveYourselfArg.bShutdown, aSaveYourselfArg.nInteractionStyle == SmInteractStyleAny && !aSaveYourselfArg.bFast );
163 pOneInstance->CallCallback( &aEvent );
166 @@ -307,12 +309,13 @@ IMPL_STATIC_LINK( SessionManagerClient, SaveYourselfHdl, void*, EMPTYARG )
167 IMPL_STATIC_LINK_NOINSTANCE( SessionManagerClient, InteractionHdl, void*, EMPTYARG )
169 SMprintf( "interaction link\n" );
174 SalSessionInteractionEvent aEvent( true );
175 pOneInstance->CallCallback( &aEvent );
182 @@ -325,6 +328,9 @@ IMPL_STATIC_LINK_NOINSTANCE( SessionManagerClient, ShutDownCancelHdl, void*, EMP
183 pOneInstance->CallCallback( &aEvent );
186 + if( !bSaveDoneSent )
192 @@ -334,7 +340,7 @@ void SessionManagerClient::SaveYourselfProc(
200 SMprintf( "Session: save yourself, save_type = %s, shutdown = %s, interact_style = %s, fast = %s\n",
201 @@ -345,8 +351,9 @@ void SessionManagerClient::SaveYourselfProc(
202 interact_style == SmInteractStyleNone ? "SmInteractStyleNone" :
203 ( interact_style == SmInteractStyleErrors ? "SmInteractStyleErrors" :
204 ( interact_style == SmInteractStyleAny ? "SmInteractStyleAny" : "<unknown>" ) ),
205 - false ? "true" : "false"
206 + fast ? "true" : "false"
208 + bSaveDoneSent = false;
209 BuildSmPropertyList();
210 #ifdef USE_SM_EXTENSION
211 bDocSaveDone = false;
212 @@ -361,7 +368,12 @@ void SessionManagerClient::SaveYourselfProc(
213 SessionManagerClient::saveDone();
216 - Application::PostUserEvent( STATIC_LINK( (void*)(shutdown ? 0xffffffff : 0x0), SessionManagerClient, SaveYourselfHdl ) );
218 + aSaveYourselfArg.bShutdown = shutdown;
219 + aSaveYourselfArg.nInteractionStyle = interact_style;
220 + aSaveYourselfArg.bFast = fast;
221 + Application::PostUserEvent( STATIC_LINK( NULL, SessionManagerClient, SaveYourselfHdl ) );
223 SMprintf( "waiting for save yourself event to be processed\n" );
226 @@ -414,15 +426,17 @@ void SessionManagerClient::InteractProc(
227 Application::PostUserEvent( STATIC_LINK( NULL, SessionManagerClient, InteractionHdl ) );
230 -void SessionManagerClient::saveDone()
231 +void SessionManagerClient::saveDone( bool bSuccess )
235 ICEConnectionObserver::lock();
236 - SmcSetProperties( aSmcConnection, nSmProps, ppSmProps );
237 - SmcSaveYourselfDone( aSmcConnection, True );
239 + SmcSetProperties( aSmcConnection, nSmProps, ppSmProps );
240 + SmcSaveYourselfDone( aSmcConnection, bSuccess );
241 SMprintf( "sent SaveYourselfDone SmRestartHint of %d\n", *pSmRestartHint );
242 - bDocSaveDone = true;
243 + bDocSaveDone = bSuccess;
244 + bSaveDoneSent = true;
245 ICEConnectionObserver::unlock();
248 @@ -526,12 +540,12 @@ bool SessionManagerClient::queryInteraction()
252 -void SessionManagerClient::interactionDone()
253 +void SessionManagerClient::interactionDone( bool bCancelShutdown )
257 ICEConnectionObserver::lock();
258 - SmcInteractDone( aSmcConnection, False );
259 + SmcInteractDone( aSmcConnection, bCancelShutdown );
260 ICEConnectionObserver::unlock();
263 diff -rup offapi/com/sun/star/frame/XSessionManagerClient.idl offapi/com/sun/star/frame/XSessionManagerClient.idl
264 --- offapi/com/sun/star/frame/XSessionManagerClient.idl 2005-09-08 03:25:36.000000000 +0200
265 +++ offapi/com/sun/star/frame/XSessionManagerClient.idl 2006-02-20 17:09:58.000000000 +0100
266 @@ -88,7 +88,7 @@ module com { module sun { module star
268 @see XSessionManagerListener
270 - [oneway] void interactionDone( [in] XSessionManagerListener xListener );
271 + [oneway] void interactionDone( [in] XSessionManagerListener xListener, [in] boolean bCancelShutdown );
273 /** saveDone signals that a listener has processed a save request
275 @@ -98,14 +98,6 @@ module com { module sun { module star
276 @see XSessionManagerListener
278 [oneway] void saveDone( [in] XSessionManagerListener xListener );
280 - /** Call cancelShutdown to try to cancel a desktop shutdown in progress
283 - <TRUE/> if shutdown was canceled,
286 - boolean cancelShutdown();
290 diff -rup framework-m188/inc/services/sessionlistener.hxx framework/inc/services/sessionlistener.hxx
291 --- framework-m188/inc/services/sessionlistener.hxx 2006-10-31 13:13:27.000000000 +0100
292 +++ framework/inc/services/sessionlistener.hxx 2006-10-31 18:14:09.000000000 +0100
293 @@ -161,6 +161,10 @@ class SessionListener : // interfaces
295 css::uno::Reference< css::frame::XSessionManagerClient > m_rSessionManager;
297 + void _requestInteraction();
298 + void _finishInteraction( sal_Bool bCancelShutdown );
299 + void _saveAutorecovery( sal_Bool bSessionSave );
302 sal_Bool m_bRestored;
304 diff -rup framework-m188/source/services/sessionlistener.cxx framework/source/services/sessionlistener.cxx
305 --- framework-m188/source/services/sessionlistener.cxx 2006-10-31 13:13:29.000000000 +0100
306 +++ framework/source/services/sessionlistener.cxx 2006-11-01 13:08:26.000000000 +0100
307 @@ -249,38 +249,50 @@ sal_Bool SAL_CALL SessionListener::doRes
311 +void SessionListener::_saveAutorecovery( sal_Bool bSessionSave )
313 + sal_Bool bDispatched = sal_False;
314 + ResetableGuard aGuard(m_aLock);
318 + // xd create SERVICENAME_AUTORECOVERY -> XDispatch
319 + // xd->dispatch("vnd.sun.star.autorecovery:/doSessionSave, async=true
320 + // on stop event m_rSessionManager->saveDone(this);
321 + // ON autosave ( bSessionSave == false)
322 + // xd->dispatch("vnd.sun.star.autorecovery:/doAutoSave, async=false
324 + css::uno::Reference< XDispatch > xDispatch(m_xSMGR->createInstance(SERVICENAME_AUTORECOVERY), UNO_QUERY_THROW);
325 + css::uno::Reference< XURLTransformer > xURLTransformer(m_xSMGR->createInstance(SERVICENAME_URLTRANSFORMER), UNO_QUERY_THROW);
327 + aURL.Complete = OUString::createFromAscii(bSessionSave
328 + ? "vnd.sun.star.autorecovery:/doSessionSave"
329 + : "vnd.sun.star.autorecovery:/doAutoSave");
330 + xURLTransformer->parseStrict(aURL);
332 + xDispatch->addStatusListener(this, aURL);
333 + Sequence< PropertyValue > args(1);
334 + args[0] = PropertyValue(OUString::createFromAscii("DispatchAsynchron"),-1,makeAny(bSessionSave),PropertyState_DIRECT_VALUE);
335 + xDispatch->dispatch(aURL, args);
336 + bDispatched = sal_True;
337 + // on stop event set call m_rSessionManager->saveDone(this);
338 + } catch (com::sun::star::uno::Exception& e) {
339 + OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8);
340 + OSL_ENSURE(sal_False, aMsg.getStr());
341 + // save failed, but tell manager to go on if we havent yet dispatched the request
342 + if (m_rSessionManager.is() && !bDispatched && bSessionSave)
343 + m_rSessionManager->saveDone(this);
347 -void SAL_CALL SessionListener::doSave( sal_Bool bShutdown, sal_Bool /*bCancelable*/ )
348 +void SAL_CALL SessionListener::doSave( sal_Bool bShutdown, sal_Bool bCancelable )
349 throw (RuntimeException)
353 - sal_Bool bDispatched = sal_False;
354 - ResetableGuard aGuard(m_aLock);
357 - // xd create SERVICENAME_AUTORECOVERY -> XDispatch
358 - // xd->dispatch("vnd.sun.star.autorecovery:/doSessionSave, async=true
359 - // on stop event m_rSessionManager->saveDone(this);
361 - css::uno::Reference< XDispatch > xDispatch(m_xSMGR->createInstance(SERVICENAME_AUTORECOVERY), UNO_QUERY_THROW);
362 - css::uno::Reference< XURLTransformer > xURLTransformer(m_xSMGR->createInstance(SERVICENAME_URLTRANSFORMER), UNO_QUERY_THROW);
364 - aURL.Complete = OUString::createFromAscii("vnd.sun.star.autorecovery:/doSessionSave");
365 - xURLTransformer->parseStrict(aURL);
366 - xDispatch->addStatusListener(this, aURL);
367 - Sequence< PropertyValue > args(1);
368 - args[0] = PropertyValue(OUString::createFromAscii("DispatchAsynchron"),-1,makeAny(sal_True),PropertyState_DIRECT_VALUE);
369 - xDispatch->dispatch(aURL, args);
370 - bDispatched = sal_True;
371 - // on stop event set call m_rSessionManager->saveDone(this);
372 - } catch (com::sun::star::uno::Exception& e) {
373 - OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8);
374 - OSL_ENSURE(sal_False, aMsg.getStr());
375 - // save failed, but tell manager to go on if we havent yet dispatched the request
376 - if (m_rSessionManager.is() && !bDispatched)
377 - m_rSessionManager->saveDone(this);
379 + _saveAutorecovery( !bCancelable );
381 + _requestInteraction();
383 // we don't have anything to do so tell the session manager we're done
384 else if( m_rSessionManager.is() )
385 @@ -289,12 +301,32 @@ void SAL_CALL SessionListener::doSave( s
389 -void SAL_CALL SessionListener::approveInteraction( sal_Bool /*bInteractionGranted*/ )
390 +void SAL_CALL SessionListener::approveInteraction( sal_Bool bInteractionGranted )
391 throw (RuntimeException)
394 + if( bInteractionGranted ) {
395 + bool bExit = GetpApp()->QueryExit();
397 + if( m_rSessionManager.is() )
398 + m_rSessionManager->saveDone( this );
400 + _finishInteraction( !bExit );
402 + _saveAutorecovery( sal_True );
405 void SessionListener::shutdownCanceled()
406 throw (RuntimeException)
409 +void SessionListener::_requestInteraction()
411 + m_rSessionManager->queryInteraction(Reference<XSessionManagerListener>(this));
414 +void SessionListener::_finishInteraction( sal_Bool bCancelShutdown )
416 + m_rSessionManager->interactionDone(Reference< XSessionManagerListener >(this), bCancelShutdown );