1*b5088357SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b5088357SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b5088357SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b5088357SAndrew Rist  * distributed with this work for additional information
6*b5088357SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b5088357SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b5088357SAndrew Rist  * "License"); you may not use this file except in compliance
9*b5088357SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*b5088357SAndrew Rist  *
11*b5088357SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*b5088357SAndrew Rist  *
13*b5088357SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b5088357SAndrew Rist  * software distributed under the License is distributed on an
15*b5088357SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b5088357SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b5088357SAndrew Rist  * specific language governing permissions and limitations
18*b5088357SAndrew Rist  * under the License.
19*b5088357SAndrew Rist  *
20*b5088357SAndrew Rist  *************************************************************/
21*b5088357SAndrew Rist 
22*b5088357SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_unotools.hxx"
26cdf0e10cSrcweir #ifndef GCC
27cdf0e10cSrcweir #endif
28cdf0e10cSrcweir 
29cdf0e10cSrcweir //_________________________________________________________________________________________________________________
30cdf0e10cSrcweir //	includes
31cdf0e10cSrcweir //_________________________________________________________________________________________________________________
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <unotools/workingsetoptions.hxx>
34cdf0e10cSrcweir #include <unotools/configmgr.hxx>
35cdf0e10cSrcweir #include <unotools/configitem.hxx>
36cdf0e10cSrcweir #include <tools/debug.hxx>
37cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
38cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include <itemholder1.hxx>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir //_________________________________________________________________________________________________________________
43cdf0e10cSrcweir //	namespaces
44cdf0e10cSrcweir //_________________________________________________________________________________________________________________
45cdf0e10cSrcweir 
46cdf0e10cSrcweir using namespace ::utl					;
47cdf0e10cSrcweir using namespace ::rtl					;
48cdf0e10cSrcweir using namespace ::osl					;
49cdf0e10cSrcweir using namespace ::com::sun::star::uno	;
50cdf0e10cSrcweir 
51cdf0e10cSrcweir //_________________________________________________________________________________________________________________
52cdf0e10cSrcweir //	const
53cdf0e10cSrcweir //_________________________________________________________________________________________________________________
54cdf0e10cSrcweir 
55cdf0e10cSrcweir #define	ROOTNODE_WORKINGSET				OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/WorkingSet"))
56cdf0e10cSrcweir #define	DEFAULT_WINDOWLIST				Sequence< OUString >()
57cdf0e10cSrcweir 
58cdf0e10cSrcweir #define	PROPERTYNAME_WINDOWLIST			OUString(RTL_CONSTASCII_USTRINGPARAM("WindowList"		))
59cdf0e10cSrcweir 
60cdf0e10cSrcweir #define	PROPERTYHANDLE_WINDOWLIST		0
61cdf0e10cSrcweir 
62cdf0e10cSrcweir #define	PROPERTYCOUNT					1
63cdf0e10cSrcweir 
64cdf0e10cSrcweir //_________________________________________________________________________________________________________________
65cdf0e10cSrcweir //	private declarations!
66cdf0e10cSrcweir //_________________________________________________________________________________________________________________
67cdf0e10cSrcweir 
68cdf0e10cSrcweir class SvtWorkingSetOptions_Impl : public ConfigItem
69cdf0e10cSrcweir {
70cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
71cdf0e10cSrcweir 	//	public methods
72cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 	public:
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
77cdf0e10cSrcweir 		//	constructor / destructor
78cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 		 SvtWorkingSetOptions_Impl();
81cdf0e10cSrcweir 		~SvtWorkingSetOptions_Impl();
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
84cdf0e10cSrcweir 		//	overloaded methods of baseclass
85cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 		/*-****************************************************************************************************//**
88cdf0e10cSrcweir 			@short		called for notify of configmanager
89cdf0e10cSrcweir 			@descr		These method is called from the ConfigManager before application ends or from the
90cdf0e10cSrcweir 			 			PropertyChangeListener if the sub tree broadcasts changes. You must update your
91cdf0e10cSrcweir 						internal values.
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 			@seealso	baseclass ConfigItem
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 			@param		"seqPropertyNames" is the list of properties which should be updated.
96cdf0e10cSrcweir 			@return		-
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 			@onerror	-
99cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
100cdf0e10cSrcweir 
101cdf0e10cSrcweir     	virtual void Notify( const Sequence< OUString >& seqPropertyNames );
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 		/*-****************************************************************************************************//**
104cdf0e10cSrcweir 			@short		write changes to configuration
105cdf0e10cSrcweir 			@descr		These method writes the changed values into the sub tree
106cdf0e10cSrcweir 						and should always called in our destructor to guarantee consistency of config data.
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 			@seealso	baseclass ConfigItem
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 			@param		-
111cdf0e10cSrcweir 			@return		-
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 			@onerror	-
114cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     	virtual void Commit();
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
119cdf0e10cSrcweir 		//	public interface
120cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 		/*-****************************************************************************************************//**
123cdf0e10cSrcweir 			@short		access method to get internal values
124cdf0e10cSrcweir 			@descr		These method give us a chance to regulate acces to ouer internal values.
125cdf0e10cSrcweir 						It's not used in the moment - but it's possible for the feature!
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 			@seealso	-
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 			@param		-
130cdf0e10cSrcweir 			@return		-
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 			@onerror	-
133cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 		Sequence< OUString >	GetWindowList(												) const	;
136cdf0e10cSrcweir 		void					SetWindowList( const Sequence< OUString >&	seqWindowList	)		;
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
139cdf0e10cSrcweir 	//	private methods
140cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 	private:
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 		/*-****************************************************************************************************//**
145cdf0e10cSrcweir 			@short		return list of key names of ouer configuration management which represent oue module tree
146cdf0e10cSrcweir 			@descr		These methods return a static const list of key names. We need it to get needed values from our
147cdf0e10cSrcweir 						configuration management.
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 			@seealso	-
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 			@param		-
152cdf0e10cSrcweir 			@return		A list of needed configuration keys is returned.
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 			@onerror	-
155cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 		static Sequence< OUString > GetPropertyNames();
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
160cdf0e10cSrcweir 	//	private member
161cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	private:
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 		Sequence< OUString >	m_seqWindowList		;
166cdf0e10cSrcweir };
167cdf0e10cSrcweir 
168cdf0e10cSrcweir //_________________________________________________________________________________________________________________
169cdf0e10cSrcweir //	definitions
170cdf0e10cSrcweir //_________________________________________________________________________________________________________________
171cdf0e10cSrcweir 
172cdf0e10cSrcweir //*****************************************************************************************************************
173cdf0e10cSrcweir //	constructor
174cdf0e10cSrcweir //*****************************************************************************************************************
175cdf0e10cSrcweir SvtWorkingSetOptions_Impl::SvtWorkingSetOptions_Impl()
176cdf0e10cSrcweir 	// Init baseclasses first
177cdf0e10cSrcweir     :	ConfigItem			( ROOTNODE_WORKINGSET	)
178cdf0e10cSrcweir 	// Init member then.
179cdf0e10cSrcweir 	,	m_seqWindowList		( DEFAULT_WINDOWLIST	)
180cdf0e10cSrcweir {
181cdf0e10cSrcweir 	// Use our static list of configuration keys to get his values.
182cdf0e10cSrcweir 	Sequence< OUString >	seqNames	= GetPropertyNames	(			);
183cdf0e10cSrcweir 	Sequence< Any >			seqValues	= GetProperties		( seqNames	);
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 	// Safe impossible cases.
186cdf0e10cSrcweir 	// We need values from ALL configuration keys.
187cdf0e10cSrcweir 	// Follow assignment use order of values in relation to our list of key names!
188cdf0e10cSrcweir 	DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtWorkingSetOptions_Impl::SvtWorkingSetOptions_Impl()\nI miss some values of configuration keys!\n" );
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 	// Copy values from list in right order to ouer internal member.
191cdf0e10cSrcweir 	sal_Int32 nPropertyCount = seqValues.getLength();
192cdf0e10cSrcweir 	for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
193cdf0e10cSrcweir 	{
194cdf0e10cSrcweir 		// Safe impossible cases.
195cdf0e10cSrcweir 		// Check any for valid value.
196cdf0e10cSrcweir 		DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtWorkingSetOptions_Impl::SvtWorkingSetOptions_Impl()\nInvalid property value detected!\n" );
197cdf0e10cSrcweir         switch( nProperty )
198cdf0e10cSrcweir         {
199cdf0e10cSrcweir             case PROPERTYHANDLE_WINDOWLIST		:	{
200cdf0e10cSrcweir 														DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_SEQUENCE), "SvtWorkingSetOptions_Impl::SvtWorkingSetOptions_Impl()\nWho has changed the value type of \"Office.Common\\WorkingSet\\WindowList\"?" );
201cdf0e10cSrcweir 														seqValues[nProperty] >>= m_seqWindowList;
202cdf0e10cSrcweir 													}
203cdf0e10cSrcweir 													break;
204cdf0e10cSrcweir         }
205cdf0e10cSrcweir 	}
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 	// Enable notification mechanism of ouer baseclass.
208cdf0e10cSrcweir 	// We need it to get information about changes outside these class on ouer used configuration keys!
209cdf0e10cSrcweir 	EnableNotification( seqNames );
210cdf0e10cSrcweir }
211cdf0e10cSrcweir 
212cdf0e10cSrcweir //*****************************************************************************************************************
213cdf0e10cSrcweir //	destructor
214cdf0e10cSrcweir //*****************************************************************************************************************
215cdf0e10cSrcweir SvtWorkingSetOptions_Impl::~SvtWorkingSetOptions_Impl()
216cdf0e10cSrcweir {
217cdf0e10cSrcweir 	// We must save our current values .. if user forget it!
218cdf0e10cSrcweir 	if( IsModified() == sal_True )
219cdf0e10cSrcweir 	{
220cdf0e10cSrcweir 		Commit();
221cdf0e10cSrcweir 	}
222cdf0e10cSrcweir }
223cdf0e10cSrcweir 
224cdf0e10cSrcweir //*****************************************************************************************************************
225cdf0e10cSrcweir //	public method
226cdf0e10cSrcweir //*****************************************************************************************************************
227cdf0e10cSrcweir void SvtWorkingSetOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNames )
228cdf0e10cSrcweir {
229cdf0e10cSrcweir 	// Use given list of updated properties to get his values from configuration directly!
230cdf0e10cSrcweir 	Sequence< Any > seqValues = GetProperties( seqPropertyNames );
231cdf0e10cSrcweir 	// Safe impossible cases.
232cdf0e10cSrcweir 	// We need values from ALL notified configuration keys.
233cdf0e10cSrcweir 	DBG_ASSERT( !(seqPropertyNames.getLength()!=seqValues.getLength()), "SvtWorkingSetOptions_Impl::Notify()\nI miss some values of configuration keys!\n" );
234cdf0e10cSrcweir 	// Step over list of property names and get right value from coreesponding value list to set it on internal members!
235cdf0e10cSrcweir 	sal_Int32 nCount = seqPropertyNames.getLength();
236cdf0e10cSrcweir 	for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
237cdf0e10cSrcweir 	{
238cdf0e10cSrcweir 		if( seqPropertyNames[nProperty] == PROPERTYNAME_WINDOWLIST )
239cdf0e10cSrcweir 		{
240cdf0e10cSrcweir 			DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_SEQUENCE), "SvtWorkingSetOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\WorkingSet\\WindowList\"?" );
241cdf0e10cSrcweir 			seqValues[nProperty] >>= m_seqWindowList;
242cdf0e10cSrcweir 		}
243cdf0e10cSrcweir         #if OSL_DEBUG_LEVEL > 1
244cdf0e10cSrcweir 		else DBG_ASSERT( sal_False, "SvtWorkingSetOptions_Impl::Notify()\nUnkown property detected ... I can't handle these!\n" );
245cdf0e10cSrcweir 		#endif
246cdf0e10cSrcweir 	}
247cdf0e10cSrcweir }
248cdf0e10cSrcweir 
249cdf0e10cSrcweir //*****************************************************************************************************************
250cdf0e10cSrcweir //	public method
251cdf0e10cSrcweir //*****************************************************************************************************************
252cdf0e10cSrcweir void SvtWorkingSetOptions_Impl::Commit()
253cdf0e10cSrcweir {
254cdf0e10cSrcweir 	// Get names of supported properties, create a list for values and copy current values to it.
255cdf0e10cSrcweir 	Sequence< OUString >	seqNames	= GetPropertyNames	();
256cdf0e10cSrcweir 	sal_Int32				nCount		= seqNames.getLength();
257cdf0e10cSrcweir 	Sequence< Any >			seqValues	( nCount );
258cdf0e10cSrcweir 	for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
259cdf0e10cSrcweir 	{
260cdf0e10cSrcweir         switch( nProperty )
261cdf0e10cSrcweir         {
262cdf0e10cSrcweir             case PROPERTYHANDLE_WINDOWLIST		:	{
263cdf0e10cSrcweir                 										seqValues[nProperty] <<= m_seqWindowList;
264cdf0e10cSrcweir 													}
265cdf0e10cSrcweir                 									break;
266cdf0e10cSrcweir         }
267cdf0e10cSrcweir 	}
268cdf0e10cSrcweir 	// Set properties in configuration.
269cdf0e10cSrcweir 	PutProperties( seqNames, seqValues );
270cdf0e10cSrcweir }
271cdf0e10cSrcweir 
272cdf0e10cSrcweir //*****************************************************************************************************************
273cdf0e10cSrcweir //	public method
274cdf0e10cSrcweir //*****************************************************************************************************************
275cdf0e10cSrcweir Sequence< OUString > SvtWorkingSetOptions_Impl::GetWindowList() const
276cdf0e10cSrcweir {
277cdf0e10cSrcweir 	return m_seqWindowList;
278cdf0e10cSrcweir }
279cdf0e10cSrcweir 
280cdf0e10cSrcweir //*****************************************************************************************************************
281cdf0e10cSrcweir //	public method
282cdf0e10cSrcweir //*****************************************************************************************************************
283cdf0e10cSrcweir void SvtWorkingSetOptions_Impl::SetWindowList( const Sequence< OUString >& seqWindowList )
284cdf0e10cSrcweir {
285cdf0e10cSrcweir 	m_seqWindowList = seqWindowList;
286cdf0e10cSrcweir 	SetModified();
287cdf0e10cSrcweir }
288cdf0e10cSrcweir 
289cdf0e10cSrcweir //*****************************************************************************************************************
290cdf0e10cSrcweir //	private method
291cdf0e10cSrcweir //*****************************************************************************************************************
292cdf0e10cSrcweir Sequence< OUString > SvtWorkingSetOptions_Impl::GetPropertyNames()
293cdf0e10cSrcweir {
294cdf0e10cSrcweir 	// Build static list of configuration key names.
295cdf0e10cSrcweir 	static const OUString pProperties[] =
296cdf0e10cSrcweir 	{
297cdf0e10cSrcweir 		PROPERTYNAME_WINDOWLIST	,
298cdf0e10cSrcweir 	};
299cdf0e10cSrcweir 	// Initialize return sequence with these list ...
300cdf0e10cSrcweir 	static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
301cdf0e10cSrcweir 	// ... and return it.
302cdf0e10cSrcweir 	return seqPropertyNames;
303cdf0e10cSrcweir }
304cdf0e10cSrcweir 
305cdf0e10cSrcweir //*****************************************************************************************************************
306cdf0e10cSrcweir //	initialize static member
307cdf0e10cSrcweir //	DON'T DO IT IN YOUR HEADER!
308cdf0e10cSrcweir //	see definition for further informations
309cdf0e10cSrcweir //*****************************************************************************************************************
310cdf0e10cSrcweir SvtWorkingSetOptions_Impl*	SvtWorkingSetOptions::m_pDataContainer	= NULL	;
311cdf0e10cSrcweir sal_Int32					SvtWorkingSetOptions::m_nRefCount		= 0		;
312cdf0e10cSrcweir 
313cdf0e10cSrcweir //*****************************************************************************************************************
314cdf0e10cSrcweir //	constructor
315cdf0e10cSrcweir //*****************************************************************************************************************
316cdf0e10cSrcweir SvtWorkingSetOptions::SvtWorkingSetOptions()
317cdf0e10cSrcweir {
318cdf0e10cSrcweir     // Global access, must be guarded (multithreading!).
319cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
320cdf0e10cSrcweir 	// Increase ouer refcount ...
321cdf0e10cSrcweir 	++m_nRefCount;
322cdf0e10cSrcweir 	// ... and initialize ouer data container only if it not already exist!
323cdf0e10cSrcweir     if( m_pDataContainer == NULL )
324cdf0e10cSrcweir 	{
325cdf0e10cSrcweir         m_pDataContainer = new SvtWorkingSetOptions_Impl;
326cdf0e10cSrcweir 		ItemHolder1::holdConfigItem(E_WORKINGSETOPTIONS);
327cdf0e10cSrcweir 	}
328cdf0e10cSrcweir }
329cdf0e10cSrcweir 
330cdf0e10cSrcweir //*****************************************************************************************************************
331cdf0e10cSrcweir //	destructor
332cdf0e10cSrcweir //*****************************************************************************************************************
333cdf0e10cSrcweir SvtWorkingSetOptions::~SvtWorkingSetOptions()
334cdf0e10cSrcweir {
335cdf0e10cSrcweir     // Global access, must be guarded (multithreading!)
336cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
337cdf0e10cSrcweir 	// Decrease ouer refcount.
338cdf0e10cSrcweir 	--m_nRefCount;
339cdf0e10cSrcweir 	// If last instance was deleted ...
340cdf0e10cSrcweir 	// we must destroy ouer static data container!
341cdf0e10cSrcweir     if( m_nRefCount <= 0 )
342cdf0e10cSrcweir 	{
343cdf0e10cSrcweir 		delete m_pDataContainer;
344cdf0e10cSrcweir 		m_pDataContainer = NULL;
345cdf0e10cSrcweir 	}
346cdf0e10cSrcweir }
347cdf0e10cSrcweir 
348cdf0e10cSrcweir //*****************************************************************************************************************
349cdf0e10cSrcweir //	public method
350cdf0e10cSrcweir //*****************************************************************************************************************
351cdf0e10cSrcweir Sequence< OUString > SvtWorkingSetOptions::GetWindowList() const
352cdf0e10cSrcweir {
353cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
354cdf0e10cSrcweir 	return m_pDataContainer->GetWindowList();
355cdf0e10cSrcweir }
356cdf0e10cSrcweir 
357cdf0e10cSrcweir //*****************************************************************************************************************
358cdf0e10cSrcweir //	public method
359cdf0e10cSrcweir //*****************************************************************************************************************
360cdf0e10cSrcweir void SvtWorkingSetOptions::SetWindowList( const Sequence< OUString >& seqWindowList )
361cdf0e10cSrcweir {
362cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
363cdf0e10cSrcweir 	m_pDataContainer->SetWindowList( seqWindowList );
364cdf0e10cSrcweir }
365cdf0e10cSrcweir 
366cdf0e10cSrcweir //*****************************************************************************************************************
367cdf0e10cSrcweir //	private method
368cdf0e10cSrcweir //*****************************************************************************************************************
369cdf0e10cSrcweir Mutex& SvtWorkingSetOptions::GetOwnStaticMutex()
370cdf0e10cSrcweir {
371cdf0e10cSrcweir 	// Initialize static mutex only for one time!
372cdf0e10cSrcweir     static Mutex* pMutex = NULL;
373cdf0e10cSrcweir 	// If these method first called (Mutex not already exist!) ...
374cdf0e10cSrcweir     if( pMutex == NULL )
375cdf0e10cSrcweir     {
376cdf0e10cSrcweir 		// ... we must create a new one. Protect follow code with the global mutex -
377cdf0e10cSrcweir 		// It must be - we create a static variable!
378cdf0e10cSrcweir         MutexGuard aGuard( Mutex::getGlobalMutex() );
379cdf0e10cSrcweir 		// We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
380cdf0e10cSrcweir         if( pMutex == NULL )
381cdf0e10cSrcweir         {
382cdf0e10cSrcweir 			// Create the new mutex and set it for return on static variable.
383cdf0e10cSrcweir             static Mutex aMutex;
384cdf0e10cSrcweir             pMutex = &aMutex;
385cdf0e10cSrcweir         }
386cdf0e10cSrcweir     }
387cdf0e10cSrcweir 	// Return new created or already existing mutex object.
388cdf0e10cSrcweir     return *pMutex;
389cdf0e10cSrcweir }
390