1*9b5730f6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9b5730f6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9b5730f6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9b5730f6SAndrew Rist  * distributed with this work for additional information
6*9b5730f6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9b5730f6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9b5730f6SAndrew Rist  * "License"); you may not use this file except in compliance
9*9b5730f6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9b5730f6SAndrew Rist  *
11*9b5730f6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9b5730f6SAndrew Rist  *
13*9b5730f6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9b5730f6SAndrew Rist  * software distributed under the License is distributed on an
15*9b5730f6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9b5730f6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9b5730f6SAndrew Rist  * specific language governing permissions and limitations
18*9b5730f6SAndrew Rist  * under the License.
19*9b5730f6SAndrew Rist  *
20*9b5730f6SAndrew Rist  *************************************************************/
21*9b5730f6SAndrew Rist 
22*9b5730f6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_connectivity.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef _CONNECTIVITY_ADO_GROUP_HXX_
28cdf0e10cSrcweir #include "ado/AGroup.hxx"
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #include "ado/AUsers.hxx"
31cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
32cdf0e10cSrcweir #include <comphelper/sequence.hxx>
33cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp>
34cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSet.hpp>
35cdf0e10cSrcweir #ifndef _CONNECTIVITY_ADO_BCONNECTION_HXX_
36cdf0e10cSrcweir #include "ado/AConnection.hxx"
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #include "TConnection.hxx"
39cdf0e10cSrcweir 
40cdf0e10cSrcweir using namespace connectivity::ado;
41cdf0e10cSrcweir using namespace com::sun::star::uno;
42cdf0e10cSrcweir using namespace com::sun::star::lang;
43cdf0e10cSrcweir using namespace com::sun::star::beans;
44cdf0e10cSrcweir using namespace com::sun::star::sdbc;
45cdf0e10cSrcweir using namespace com::sun::star::sdbcx;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir // -------------------------------------------------------------------------
Create()48cdf0e10cSrcweir void WpADOGroup::Create()
49cdf0e10cSrcweir {
50cdf0e10cSrcweir 	HRESULT         hr = -1;
51cdf0e10cSrcweir 	ADOGroup* pGroup = NULL;
52cdf0e10cSrcweir 	hr = CoCreateInstance(ADOS::CLSID_ADOGROUP_25,
53cdf0e10cSrcweir 						  NULL,
54cdf0e10cSrcweir 						  CLSCTX_INPROC_SERVER,
55cdf0e10cSrcweir 						  ADOS::IID_ADOGROUP_25,
56cdf0e10cSrcweir 						  (void**)&pGroup );
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 	if( !FAILED( hr ) )
60cdf0e10cSrcweir 	{
61cdf0e10cSrcweir 		operator=( pGroup );
62cdf0e10cSrcweir 		pGroup->Release();
63cdf0e10cSrcweir 	}
64cdf0e10cSrcweir }
65cdf0e10cSrcweir // -------------------------------------------------------------------------
OAdoGroup(OCatalog * _pParent,sal_Bool _bCase,ADOGroup * _pGroup)66cdf0e10cSrcweir OAdoGroup::OAdoGroup(OCatalog* _pParent,sal_Bool _bCase,	ADOGroup* _pGroup) : OGroup_ADO(_bCase),m_pCatalog(_pParent)
67cdf0e10cSrcweir {
68cdf0e10cSrcweir 	construct();
69cdf0e10cSrcweir 	if(_pGroup)
70cdf0e10cSrcweir 		m_aGroup = WpADOGroup(_pGroup);
71cdf0e10cSrcweir 	else
72cdf0e10cSrcweir 		m_aGroup.Create();
73cdf0e10cSrcweir 
74cdf0e10cSrcweir }
75cdf0e10cSrcweir // -------------------------------------------------------------------------
OAdoGroup(OCatalog * _pParent,sal_Bool _bCase,const::rtl::OUString & _Name)76cdf0e10cSrcweir OAdoGroup::OAdoGroup(OCatalog* _pParent,sal_Bool _bCase, const ::rtl::OUString& _Name) : OGroup_ADO(_Name,_bCase),m_pCatalog(_pParent)
77cdf0e10cSrcweir {
78cdf0e10cSrcweir 	construct();
79cdf0e10cSrcweir 	m_aGroup.Create();
80cdf0e10cSrcweir 	m_aGroup.put_Name(_Name);
81cdf0e10cSrcweir }
82cdf0e10cSrcweir // -------------------------------------------------------------------------
refreshUsers()83cdf0e10cSrcweir void OAdoGroup::refreshUsers()
84cdf0e10cSrcweir {
85cdf0e10cSrcweir 	TStringVector aVector;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 	WpADOUsers aUsers = m_aGroup.get_Users();
88cdf0e10cSrcweir 	aUsers.fillElementNames(aVector);
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 	if(m_pUsers)
91cdf0e10cSrcweir 		m_pUsers->reFill(aVector);
92cdf0e10cSrcweir 	else
93cdf0e10cSrcweir 		m_pUsers = new OUsers(m_pCatalog,m_aMutex,aVector,aUsers,isCaseSensitive());
94cdf0e10cSrcweir }
95cdf0e10cSrcweir //--------------------------------------------------------------------------
getUnoTunnelImplementationId()96cdf0e10cSrcweir Sequence< sal_Int8 > OAdoGroup::getUnoTunnelImplementationId()
97cdf0e10cSrcweir {
98cdf0e10cSrcweir 	static ::cppu::OImplementationId * pId = 0;
99cdf0e10cSrcweir 	if (! pId)
100cdf0e10cSrcweir 	{
101cdf0e10cSrcweir 		::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
102cdf0e10cSrcweir 		if (! pId)
103cdf0e10cSrcweir 		{
104cdf0e10cSrcweir 			static ::cppu::OImplementationId aId;
105cdf0e10cSrcweir 			pId = &aId;
106cdf0e10cSrcweir 		}
107cdf0e10cSrcweir 	}
108cdf0e10cSrcweir 	return pId->getImplementationId();
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir // com::sun::star::lang::XUnoTunnel
112cdf0e10cSrcweir //------------------------------------------------------------------
getSomething(const Sequence<sal_Int8> & rId)113cdf0e10cSrcweir sal_Int64 OAdoGroup::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
114cdf0e10cSrcweir {
115cdf0e10cSrcweir 	return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(),  rId.getConstArray(), 16 ) )
116cdf0e10cSrcweir 				? reinterpret_cast< sal_Int64 >( this )
117cdf0e10cSrcweir 				: OGroup_ADO::getSomething(rId);
118cdf0e10cSrcweir }
119cdf0e10cSrcweir 
120cdf0e10cSrcweir // -------------------------------------------------------------------------
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any & rValue)121cdf0e10cSrcweir void OAdoGroup::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception)
122cdf0e10cSrcweir {
123cdf0e10cSrcweir 	if(m_aGroup.IsValid())
124cdf0e10cSrcweir 	{
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 		switch(nHandle)
127cdf0e10cSrcweir 		{
128cdf0e10cSrcweir 			case PROPERTY_ID_NAME:
129cdf0e10cSrcweir 				{
130cdf0e10cSrcweir 					::rtl::OUString aVal;
131cdf0e10cSrcweir 					rValue >>= aVal;
132cdf0e10cSrcweir 					m_aGroup.put_Name(aVal);
133cdf0e10cSrcweir 				}
134cdf0e10cSrcweir 				break;
135cdf0e10cSrcweir 		}
136cdf0e10cSrcweir 	}
137cdf0e10cSrcweir }
138cdf0e10cSrcweir // -------------------------------------------------------------------------
getFastPropertyValue(Any & rValue,sal_Int32 nHandle) const139cdf0e10cSrcweir void OAdoGroup::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
140cdf0e10cSrcweir {
141cdf0e10cSrcweir 	if(m_aGroup.IsValid())
142cdf0e10cSrcweir 	{
143cdf0e10cSrcweir 		switch(nHandle)
144cdf0e10cSrcweir 		{
145cdf0e10cSrcweir 			case PROPERTY_ID_NAME:
146cdf0e10cSrcweir 				rValue <<= m_aGroup.get_Name();
147cdf0e10cSrcweir 				break;
148cdf0e10cSrcweir 		}
149cdf0e10cSrcweir 	}
150cdf0e10cSrcweir }
151cdf0e10cSrcweir // -------------------------------------------------------------------------
152cdf0e10cSrcweir 
getPrivileges(const::rtl::OUString & objName,sal_Int32 objType)153cdf0e10cSrcweir sal_Int32 SAL_CALL OAdoGroup::getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
154cdf0e10cSrcweir {
155cdf0e10cSrcweir 	return MapRight(m_aGroup.GetPermissions(objName,MapObjectType(objType)));
156cdf0e10cSrcweir }
157cdf0e10cSrcweir // -------------------------------------------------------------------------
getGrantablePrivileges(const::rtl::OUString & objName,sal_Int32 objType)158cdf0e10cSrcweir sal_Int32 SAL_CALL OAdoGroup::getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
159cdf0e10cSrcweir {
160cdf0e10cSrcweir 	RightsEnum eNum = m_aGroup.GetPermissions(objName,MapObjectType(objType));
161cdf0e10cSrcweir 	if(eNum & adRightWithGrant)
162cdf0e10cSrcweir 		return MapRight(eNum);
163cdf0e10cSrcweir 	return 0;
164cdf0e10cSrcweir }
165cdf0e10cSrcweir // -------------------------------------------------------------------------
grantPrivileges(const::rtl::OUString & objName,sal_Int32 objType,sal_Int32 objPrivileges)166cdf0e10cSrcweir void SAL_CALL OAdoGroup::grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
167cdf0e10cSrcweir {
168cdf0e10cSrcweir 	m_aGroup.SetPermissions(objName,MapObjectType(objType),adAccessGrant,Map2Right(objPrivileges));
169cdf0e10cSrcweir }
170cdf0e10cSrcweir // -------------------------------------------------------------------------
revokePrivileges(const::rtl::OUString & objName,sal_Int32 objType,sal_Int32 objPrivileges)171cdf0e10cSrcweir void SAL_CALL OAdoGroup::revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
172cdf0e10cSrcweir {
173cdf0e10cSrcweir 	m_aGroup.SetPermissions(objName,MapObjectType(objType),adAccessDeny,Map2Right(objPrivileges));
174cdf0e10cSrcweir }
175cdf0e10cSrcweir 
176cdf0e10cSrcweir // -----------------------------------------------------------------------------
acquire()177cdf0e10cSrcweir void SAL_CALL OAdoGroup::acquire() throw()
178cdf0e10cSrcweir {
179cdf0e10cSrcweir 	OGroup_ADO::acquire();
180cdf0e10cSrcweir }
181cdf0e10cSrcweir // -----------------------------------------------------------------------------
release()182cdf0e10cSrcweir void SAL_CALL OAdoGroup::release() throw()
183cdf0e10cSrcweir {
184cdf0e10cSrcweir 	OGroup_ADO::release();
185cdf0e10cSrcweir }
186cdf0e10cSrcweir // -----------------------------------------------------------------------------
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 
189