'From Pharo0.1 of 16 May 2008 [Latest update: #10373] on 28 August 2009 at 4:27:27 pm'! Object subclass: #SessionManager instanceVariableNames: 'sessionStart' classVariableNames: 'Current' poolDictionaries: '' category: 'Dolphincompatibility-Idioms'! !SessionManager commentStamp: 'Bill Schwab 8/28/2009 09:38' prior: 0! Dolphin session managers do as advertised. Among other things, they fire off events to manage startup and shutdown, and unlike Squeak, those happen when the image loads and closes respectively. Recreate this basic behavior for Pharo. ! !Object methodsFor: '*dolphincompatibility-idioms' stamp: 'Bill Schwab 8/28/2009 15:55'! trigger:anObject ^self triggerEvent:anObject. ! ! !KernelLibrary methodsFor: 'as yet unclassified' stamp: 'Bill Schwab 8/28/2009 16:15'! outputDebugString:aString "8-09 - for Windows" OSPlatform current platformFamily = #Windows ifTrue:[ ^self windowsOutputDebugString:aString. ]. ! ! !KernelLibrary methodsFor: 'as yet unclassified' stamp: 'Bill Schwab 8/28/2009 16:15'! windowsOutputDebugString:aString "8-09 - for Windows" ^self externalCallFailed. ! ! !KernelLibrary class methodsFor: 'as yet unclassified' stamp: 'Bill Schwab 8/28/2009 15:49'! current ^self default. ! ! !SessionManager methodsFor: 'as yet unclassified' stamp: 'Bill Schwab 8/28/2009 15:51'! shutDown "8-09 - hopefully this is called only when a session ends vs. on every snapshot." sessionStart isNil ifTrue:[ Transcript nextPutAll:'Shutdown with no time set.'; cr. ] ifFalse:[ sessionStart := nil. ]. KernelLibrary default outputDebugString:'Trigger #sessionStopped.'. self trigger:#sessionStopped. ! ! !SessionManager methodsFor: 'as yet unclassified' stamp: 'Bill Schwab 8/28/2009 16:10'! startUp "8-09 - hopefully this is called only when a session begins vs. on every snapshot." sessionStart notNil ifTrue:[ Transcript nextPutAll:'Startup with time set.'; cr. ] ifFalse:[ sessionStart := TimeStamp current. ]. KernelLibrary default outputDebugString:'Trigger #sessionStarted.'. self trigger:#sessionStarted. "8-09 - Sorry, but I see NO reason for this not to be done somewhere on startup." Socket initializeNetwork. ! ! !SessionManager class methodsFor: 'as yet unclassified' stamp: 'Bill Schwab 8/28/2009 09:29'! current "8-09 - lazily create a session manager. This seems like a class variable vs. class instance variable problem, because there should be one of these things regardless of (in the future) which subclass gets the duty. Runtime/deployed, development and console are the likely players." Current isNil ifTrue:[ Current := self new. ]. ^Current. ! ! !SessionManager class methodsFor: 'as yet unclassified' stamp: 'Bill Schwab 8/28/2009 15:52'! initialize "8-09 - these lists are mis-named as the evens are fired around a snapshot. Try make a working session manager that behave as in Dolphin. SessionManager initialize. " Smalltalk addToStartUpList: self. Smalltalk addToShutDownList: self. ! ! !SessionManager class methodsFor: 'as yet unclassified' stamp: 'Bill Schwab 8/28/2009 11:05'! shutDown:quitting "8-09 - see Behavior>>shutDown: which forwards this to #startup regardless of the boolean state. Try to do better here so the notices go out only on a true shutdown. Trigger off of the current session manager." quitting ifTrue:[ self current shutDown. ]. ! ! !SessionManager class methodsFor: 'as yet unclassified' stamp: 'Bill Schwab 8/28/2009 11:05'! startUp:resuming "8-09 - see Behavior>>startup: which forwards this to #startup regardless of the boolean state. Try to do better here so the notices go out only on a true session start. Trigger off of the current session manager." "8-09 - I *think* resuming means loading an image from disk." resuming ifTrue:[ self current startUp. ]. ! ! SessionManager initialize! SessionManager removeSelector: #shutDown:! SessionManager removeSelector: #startUp:! KernelLibrary removeSelector: #basicOutputDebugString:!