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