update ooo310-m15
[ooovba.git] / applied_patches / 0264-session-management.diff
blob63ab35c3081023f35bdc877eb333286f6ff2d2eb
1 diff -rup vcl/inc/salsession.hxx vcl/inc/salsession.hxx
2 --- vcl/inc/vcl/salsession.hxx 2005-09-09 13:22:55.000000000 +0200
3 +++ vcl/inc/vcl/salsession.hxx 2006-02-20 17:10:26.000000000 +0100
4 @@ -109,11 +109,9 @@ public:
5 // query the session manager for a user interaction slot
6 virtual void queryInteraction() = 0;
7 // signal the session manager that we're done with user interaction
8 - virtual void interactionDone() = 0;
9 + virtual void interactionDone( bool bCancelShutdown ) = 0;
10 // signal that we're done saving
11 virtual void saveDone() = 0;
12 - // try to cancel the sutdown in progress
13 - virtual bool cancelShutdown() = 0;
16 #endif
17 diff -rup vcl/source/app/session.cxx vcl/source/app/session.cxx
18 --- vcl/source/app/session.cxx 2005-09-09 13:41:36.000000000 +0200
19 +++ vcl/source/app/session.cxx 2006-02-20 17:10:19.000000000 +0100
20 @@ -126,9 +126,8 @@ public:
21 virtual void SAL_CALL addSessionManagerListener( const Reference< XSessionManagerListener >& xListener ) throw( RuntimeException );
22 virtual void SAL_CALL removeSessionManagerListener( const Reference< XSessionManagerListener>& xListener ) throw( RuntimeException );
23 virtual void SAL_CALL queryInteraction( const Reference< XSessionManagerListener >& xListener ) throw( RuntimeException );
24 - virtual void SAL_CALL interactionDone( const Reference< XSessionManagerListener >& xListener ) throw( RuntimeException );
25 + virtual void SAL_CALL interactionDone( const Reference< XSessionManagerListener >& xListener, sal_Bool bCancelShutdown ) throw( RuntimeException );
26 virtual void SAL_CALL saveDone( const Reference< XSessionManagerListener >& xListener ) throw( RuntimeException );
27 - virtual sal_Bool SAL_CALL cancelShutdown() throw( RuntimeException );
30 VCLSession* VCLSession::pOneInstance = NULL;
31 @@ -208,7 +207,7 @@ void VCLSession::callInteractionGranted(
32 if( aListeners.empty() )
34 if( m_pSession )
35 - m_pSession->interactionDone();
36 + m_pSession->interactionDone( false );
37 return;
40 @@ -310,7 +309,7 @@ void SAL_CALL VCLSession::queryInteracti
44 -void SAL_CALL VCLSession::interactionDone( const Reference< XSessionManagerListener >& xListener ) throw( RuntimeException )
45 +void SAL_CALL VCLSession::interactionDone( const Reference< XSessionManagerListener >& xListener, sal_Bool bCancelShutdown ) throw( RuntimeException )
47 osl::MutexGuard aGuard( m_aMutex );
48 int nRequested = 0, nDone = 0;
49 @@ -329,7 +328,7 @@ void SAL_CALL VCLSession::interactionDon
51 m_bInteractionDone = true;
52 if( m_pSession )
53 - m_pSession->interactionDone();
54 + m_pSession->interactionDone( bCancelShutdown );
58 @@ -354,11 +353,6 @@ void SAL_CALL VCLSession::saveDone( cons
62 -sal_Bool SAL_CALL VCLSession::cancelShutdown() throw( RuntimeException )
64 - return m_pSession ? (sal_Bool)m_pSession->cancelShutdown() : sal_False;
67 // service implementation
69 OUString SAL_CALL vcl_session_getImplementationName()
70 diff -rup vcl/unx/inc/sm.hxx vcl/unx/inc/sm.hxx
71 --- vcl/unx/inc/sm.hxx 2006-03-14 12:28:47.000000000 +0100
72 +++ vcl/unx/inc/sm.hxx 2006-02-20 17:37:18.000000000 +0100
73 @@ -44,7 +44,8 @@ class SessionManagerClient
75 static SmcConn aSmcConnection;
76 static ByteString aClientID;
77 - static bool bDocSaveDone;
78 + static bool bDocSaveDone;
79 + static bool bSaveDoneSent;
81 static void SaveYourselfProc( SmcConn connection,
82 SmPointer client_data,
83 @@ -73,8 +74,8 @@ public:
85 static bool checkDocumentsSaved();
86 static bool queryInteraction();
87 - static void saveDone();
88 - static void interactionDone();
89 + static void saveDone( bool bSuccess = true );
90 + static void interactionDone( bool bCancelShutdown = false );
92 static String getExecName();
93 static VCL_DLLPUBLIC const ByteString& getSessionID();
94 @@ -89,9 +90,8 @@ public:
95 virtual ~IceSalSession();
97 virtual void queryInteraction();
98 - virtual void interactionDone();
99 + virtual void interactionDone( bool bCancelShutdown );
100 virtual void saveDone();
101 - virtual bool cancelShutdown();
103 static void handleOldX11SaveYourself( SalFrame* pFrame );
105 Only in vcl/unx/inc: sm.hxx.~1.9.~
106 diff -rup vcl/unx/source/app/sm.cxx vcl/unx/source/app/sm.cxx
107 --- vcl/unx/source/app/sm.cxx 2006-03-14 12:28:47.000000000 +0100
108 +++ vcl/unx/source/app/sm.cxx 2006-02-20 17:44:23.000000000 +0100
109 @@ -129,9 +129,9 @@ void IceSalSession::queryInteraction()
113 -void IceSalSession::interactionDone()
114 +void IceSalSession::interactionDone( bool bCancelShutdown )
116 - SessionManagerClient::interactionDone();
117 + SessionManagerClient::interactionDone( bCancelShutdown );
120 void IceSalSession::saveDone()
121 @@ -144,11 +144,6 @@ void IceSalSession::saveDone()
125 -bool IceSalSession::cancelShutdown()
127 - return false;
130 void IceSalSession::handleOldX11SaveYourself( SalFrame* pFrame )
132 // do this only once
133 @@ -201,6 +196,7 @@ int ICEConnectionObserver::nWakeupFi
134 // HACK
135 bool SessionManagerClient::bDocSaveDone = false;
137 +bool SessionManagerClient::bSaveDoneSent = false;
139 static SmProp* pSmProps = NULL;
140 static SmProp** ppSmProps = NULL;
141 @@ -269,12 +265,18 @@ bool SessionManagerClient::checkDocument
142 return bDocSaveDone;
145 +struct SaveYourselfArgs {
146 + bool bShutdown;
147 + bool bFast;
148 + int nInteractionStyle;
149 +} aSaveYourselfArg;
151 IMPL_STATIC_LINK( SessionManagerClient, SaveYourselfHdl, void*, EMPTYARG )
153 SMprintf( "posting save documents event shutdown = %s\n", (pThis!=0) ? "true" : "false" );
154 if( pOneInstance )
156 - SalSessionSaveRequestEvent aEvent( pThis != 0, false );
157 + SalSessionSaveRequestEvent aEvent( aSaveYourselfArg.bShutdown, aSaveYourselfArg.nInteractionStyle == SmInteractStyleAny && !aSaveYourselfArg.bFast );
158 pOneInstance->CallCallback( &aEvent );
160 else
161 @@ -286,12 +288,13 @@ IMPL_STATIC_LINK( SessionManagerClient,
162 IMPL_STATIC_LINK_NOINSTANCE( SessionManagerClient, InteractionHdl, void*, EMPTYARG )
164 SMprintf( "interaction link\n" );
165 - if( pOneInstance )
167 + if( pOneInstance )
169 SalSessionInteractionEvent aEvent( true );
170 pOneInstance->CallCallback( &aEvent );
174 return 0;
177 @@ -304,6 +307,9 @@ IMPL_STATIC_LINK( SessionManagerClient,
178 pOneInstance->CallCallback( &aEvent );
181 + if( !bSaveDoneSent )
182 + saveDone( false );
184 return 0;
187 @@ -317,7 +317,7 @@ void SessionManagerClient::SaveYourselfP
188 int save_type,
189 Bool shutdown,
190 int interact_style,
191 - Bool
192 + Bool fast
195 SMprintf( "Session: save yourself, save_type = %s, shutdown = %s, interact_style = %s, fast = %s\n",
196 @@ -324,8 +330,9 @@ void SessionManagerClient::SaveYourselfP
197 interact_style == SmInteractStyleNone ? "SmInteractStyleNone" :
198 ( interact_style == SmInteractStyleErrors ? "SmInteractStyleErrors" :
199 ( interact_style == SmInteractStyleAny ? "SmInteractStyleAny" : "<unknown>" ) ),
200 - false ? "true" : "false"
201 + fast ? "true" : "false"
203 + bSaveDoneSent = false;
204 BuildSmPropertyList();
205 #ifdef USE_SM_EXTENSION
206 bDocSaveDone = false;
207 @@ -340,7 +347,12 @@ void SessionManagerClient::SaveYourselfP
208 SessionManagerClient::saveDone();
209 return;
211 - Application::PostUserEvent( STATIC_LINK( (void*)(shutdown ? 0xffffffff : 0x0), SessionManagerClient, SaveYourselfHdl ) );
213 + aSaveYourselfArg.bShutdown = shutdown;
214 + aSaveYourselfArg.nInteractionStyle = interact_style;
215 + aSaveYourselfArg.bFast = fast;
216 + Application::PostUserEvent( STATIC_LINK( NULL, SessionManagerClient, SaveYourselfHdl ) );
218 SMprintf( "waiting for save yourself event to be processed\n" );
219 #endif
221 @@ -393,20 +405,21 @@ void SessionManagerClient::InteractProc(
222 Application::PostUserEvent( STATIC_LINK( NULL, SessionManagerClient, InteractionHdl ) );
225 -void SessionManagerClient::saveDone()
226 +void SessionManagerClient::saveDone( bool bSuccess )
228 if( aSmcConnection )
230 ICEConnectionObserver::lock();
231 - SmcSetProperties( aSmcConnection, nSmProps, ppSmProps );
232 - SmcSaveYourselfDone( aSmcConnection, True );
233 + if( bSuccess )
234 + SmcSetProperties( aSmcConnection, nSmProps, ppSmProps );
235 + SmcSaveYourselfDone( aSmcConnection, bSuccess );
236 SMprintf( "sent SaveYourselfDone\n" );
237 - bDocSaveDone = true;
238 + bDocSaveDone = bSuccess;
239 + bSaveDoneSent = true;
240 ICEConnectionObserver::unlock();
245 void SessionManagerClient::open()
247 static SmcCallbacks aCallbacks;
248 @@ -505,12 +518,12 @@ bool SessionManagerClient::queryInteract
249 return bRet;
252 -void SessionManagerClient::interactionDone()
253 +void SessionManagerClient::interactionDone( bool bCancelShutdown )
255 if( aSmcConnection )
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
282 - @returns
283 - <TRUE/> if shutdown was canceled,
284 - <FALSE/> else.
285 - */
286 - boolean cancelShutdown();
289 }; }; }; };
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 );
301 // restore handling
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
308 return m_bRestored;
311 +void SessionListener::_saveAutorecovery( sal_Bool bSessionSave )
313 + sal_Bool bDispatched = sal_False;
314 + ResetableGuard aGuard(m_aLock);
315 + try
317 + // ON session save
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);
326 + URL aURL;
327 + aURL.Complete = OUString::createFromAscii(bSessionSave
328 + ? "vnd.sun.star.autorecovery:/doSessionSave"
329 + : "vnd.sun.star.autorecovery:/doAutoSave");
330 + xURLTransformer->parseStrict(aURL);
331 + if( bSessionSave )
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)
351 if (bShutdown)
353 - sal_Bool bDispatched = sal_False;
354 - ResetableGuard aGuard(m_aLock);
355 - try
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);
363 - URL aURL;
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 );
380 + if (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 );
401 + } else
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 );