1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_connectivity.hxx" 30 31 #ifndef _CONNECTIVITY_ADO_GROUP_HXX_ 32 #include "ado/AGroup.hxx" 33 #endif 34 #include "ado/AUsers.hxx" 35 #include <cppuhelper/typeprovider.hxx> 36 #include <comphelper/sequence.hxx> 37 #include <com/sun/star/sdbc/XRow.hpp> 38 #include <com/sun/star/sdbc/XResultSet.hpp> 39 #ifndef _CONNECTIVITY_ADO_BCONNECTION_HXX_ 40 #include "ado/AConnection.hxx" 41 #endif 42 #include "TConnection.hxx" 43 44 using namespace connectivity::ado; 45 using namespace com::sun::star::uno; 46 using namespace com::sun::star::lang; 47 using namespace com::sun::star::beans; 48 using namespace com::sun::star::sdbc; 49 using namespace com::sun::star::sdbcx; 50 51 // ------------------------------------------------------------------------- 52 void WpADOGroup::Create() 53 { 54 HRESULT hr = -1; 55 ADOGroup* pGroup = NULL; 56 hr = CoCreateInstance(ADOS::CLSID_ADOGROUP_25, 57 NULL, 58 CLSCTX_INPROC_SERVER, 59 ADOS::IID_ADOGROUP_25, 60 (void**)&pGroup ); 61 62 63 if( !FAILED( hr ) ) 64 { 65 operator=( pGroup ); 66 pGroup->Release(); 67 } 68 } 69 // ------------------------------------------------------------------------- 70 OAdoGroup::OAdoGroup(OCatalog* _pParent,sal_Bool _bCase, ADOGroup* _pGroup) : OGroup_ADO(_bCase),m_pCatalog(_pParent) 71 { 72 construct(); 73 if(_pGroup) 74 m_aGroup = WpADOGroup(_pGroup); 75 else 76 m_aGroup.Create(); 77 78 } 79 // ------------------------------------------------------------------------- 80 OAdoGroup::OAdoGroup(OCatalog* _pParent,sal_Bool _bCase, const ::rtl::OUString& _Name) : OGroup_ADO(_Name,_bCase),m_pCatalog(_pParent) 81 { 82 construct(); 83 m_aGroup.Create(); 84 m_aGroup.put_Name(_Name); 85 } 86 // ------------------------------------------------------------------------- 87 void OAdoGroup::refreshUsers() 88 { 89 TStringVector aVector; 90 91 WpADOUsers aUsers = m_aGroup.get_Users(); 92 aUsers.fillElementNames(aVector); 93 94 if(m_pUsers) 95 m_pUsers->reFill(aVector); 96 else 97 m_pUsers = new OUsers(m_pCatalog,m_aMutex,aVector,aUsers,isCaseSensitive()); 98 } 99 //-------------------------------------------------------------------------- 100 Sequence< sal_Int8 > OAdoGroup::getUnoTunnelImplementationId() 101 { 102 static ::cppu::OImplementationId * pId = 0; 103 if (! pId) 104 { 105 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); 106 if (! pId) 107 { 108 static ::cppu::OImplementationId aId; 109 pId = &aId; 110 } 111 } 112 return pId->getImplementationId(); 113 } 114 115 // com::sun::star::lang::XUnoTunnel 116 //------------------------------------------------------------------ 117 sal_Int64 OAdoGroup::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) 118 { 119 return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) 120 ? reinterpret_cast< sal_Int64 >( this ) 121 : OGroup_ADO::getSomething(rId); 122 } 123 124 // ------------------------------------------------------------------------- 125 void OAdoGroup::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception) 126 { 127 if(m_aGroup.IsValid()) 128 { 129 130 switch(nHandle) 131 { 132 case PROPERTY_ID_NAME: 133 { 134 ::rtl::OUString aVal; 135 rValue >>= aVal; 136 m_aGroup.put_Name(aVal); 137 } 138 break; 139 } 140 } 141 } 142 // ------------------------------------------------------------------------- 143 void OAdoGroup::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const 144 { 145 if(m_aGroup.IsValid()) 146 { 147 switch(nHandle) 148 { 149 case PROPERTY_ID_NAME: 150 rValue <<= m_aGroup.get_Name(); 151 break; 152 } 153 } 154 } 155 // ------------------------------------------------------------------------- 156 157 sal_Int32 SAL_CALL OAdoGroup::getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) 158 { 159 return MapRight(m_aGroup.GetPermissions(objName,MapObjectType(objType))); 160 } 161 // ------------------------------------------------------------------------- 162 sal_Int32 SAL_CALL OAdoGroup::getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) 163 { 164 RightsEnum eNum = m_aGroup.GetPermissions(objName,MapObjectType(objType)); 165 if(eNum & adRightWithGrant) 166 return MapRight(eNum); 167 return 0; 168 } 169 // ------------------------------------------------------------------------- 170 void SAL_CALL OAdoGroup::grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) 171 { 172 m_aGroup.SetPermissions(objName,MapObjectType(objType),adAccessGrant,Map2Right(objPrivileges)); 173 } 174 // ------------------------------------------------------------------------- 175 void SAL_CALL OAdoGroup::revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) 176 { 177 m_aGroup.SetPermissions(objName,MapObjectType(objType),adAccessDeny,Map2Right(objPrivileges)); 178 } 179 180 // ----------------------------------------------------------------------------- 181 void SAL_CALL OAdoGroup::acquire() throw() 182 { 183 OGroup_ADO::acquire(); 184 } 185 // ----------------------------------------------------------------------------- 186 void SAL_CALL OAdoGroup::release() throw() 187 { 188 OGroup_ADO::release(); 189 } 190 // ----------------------------------------------------------------------------- 191 192 193