Update ooo320-m1
[ooovba.git] / bridges / source / remote / urp / urp_propertyobject.hxx
blob92a104b5b9b41ed50aa88aebe6238c5fabb5d5c0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: urp_propertyobject.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include <stdio.h>
31 #include <osl/interlck.h>
32 #include <osl/mutex.hxx>
34 #ifndef _OSL_CONDITN_H_
35 #include <osl/conditn.h>
36 #endif
37 #include <rtl/string.hxx>
38 #include <uno/sequence2.h>
40 #ifndef _BRIDGES_REMOTE_REMOTE_H_
41 #include <bridges/remote/remote.h>
42 #endif
43 #include "urp_property.hxx"
45 namespace bridges_urp {
47 struct urp_BridgeImpl;
48 const sal_Char g_NameOfUrpProtocolPropertiesObject[] = "UrpProtocolProperties";
50 // helper functions
51 void assignFromStringToStruct( const ::rtl::OUString & sProps , struct Properties *pProps );
53 class PropertyObject : public remote_Interface
55 private:
56 ::osl::Mutex m_mutex;
57 oslCondition m_commitChangeCondition;
58 oslInterlockedCount m_nRefCount;
59 urp_BridgeImpl *m_pBridgeImpl;
60 struct Properties *m_pLocalSetting;
61 struct Properties m_propsToBeApplied;
63 uno_Environment *m_pEnvRemote;
64 sal_Int32 m_nRandomNumberOfRequest;
65 sal_Bool m_bRequestChangeHasBeenCalled;
66 sal_Bool m_bServerWaitingForCommit;
67 sal_Bool m_bApplyProperties;
69 public:
70 PropertyObject(
71 struct Properties *pLocalSetting , uno_Environment *pEnvRemote, urp_BridgeImpl *pImpl );
72 ~PropertyObject();
74 void SAL_CALL thisAcquire( )
76 osl_incrementInterlockedCount( &m_nRefCount );
79 void SAL_CALL thisRelease()
81 if( ! osl_decrementInterlockedCount( &m_nRefCount ) )
83 delete this;
87 void SAL_CALL thisDispatch( typelib_TypeDescription const * pMemberType,
88 void * pReturn,
89 void * pArgs[],
90 uno_Any ** ppException );
92 public: // local
93 sal_Int32 SAL_CALL localRequestChange( );
94 void SAL_CALL localCommitChange( const ::rtl::OUString &properties, sal_Bool *pbExceptionThrown );
95 void SAL_CALL localGetPropertiesFromRemote( struct Properties * );
97 // returns 0, if nothing was commited.
98 inline sal_Bool SAL_CALL changesHaveBeenCommited()
99 { return m_bApplyProperties; }
100 Properties SAL_CALL getCommitedChanges();
102 void SAL_CALL waitUntilChangesAreCommitted();
104 protected:
105 // these methods are called by thisDispatch
106 void SAL_CALL implGetProperties( uno_Sequence **ppReturnValue );
107 sal_Int32 SAL_CALL implRequestChange( sal_Int32 nRandomNumber, uno_Any **ppException );
108 void SAL_CALL implCommitChange( uno_Sequence *seqOfProperties, uno_Any **ppException );