bump product version to 6.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / postgresql / pq_xuser.cxx
blobe37d71ea062abba34f220517b0d8749b8d154e1f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * Effective License of whole file:
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License version 2.1, as published by the Free Software Foundation.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18 * MA 02111-1307 USA
20 * Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
22 * The Contents of this file are made available subject to the terms of
23 * the GNU Lesser General Public License Version 2.1
25 * Copyright: 2000 by Sun Microsystems, Inc.
27 * Contributor(s): Joerg Budischewski
29 * All parts contributed on or after August 2011:
31 * This Source Code Form is subject to the terms of the Mozilla Public
32 * License, v. 2.0. If a copy of the MPL was not distributed with this
33 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
35 ************************************************************************/
37 #include <rtl/ustrbuf.hxx>
39 #include <cppuhelper/typeprovider.hxx>
40 #include <cppuhelper/queryinterface.hxx>
42 #include <com/sun/star/beans/PropertyAttribute.hpp>
43 #include <com/sun/star/sdbc/SQLException.hpp>
45 #include "pq_xuser.hxx"
46 #include "pq_tools.hxx"
47 #include "pq_statics.hxx"
49 using com::sun::star::uno::Reference;
50 using com::sun::star::uno::Sequence;
51 using com::sun::star::uno::Any;
52 using com::sun::star::uno::Type;
54 using com::sun::star::beans::XPropertySet;
56 using com::sun::star::sdbc::XStatement;
57 using com::sun::star::sdbc::SQLException;
59 namespace pq_sdbc_driver
62 User::User( const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
63 const Reference< css::sdbc::XConnection > & connection,
64 ConnectionSettings *pSettings )
65 : ReflectionBase(
66 getStatics().refl.user.implName,
67 getStatics().refl.user.serviceNames,
68 refMutex,
69 connection,
70 pSettings,
71 * getStatics().refl.user.pProps )
74 Reference< XPropertySet > User::createDataDescriptor( )
76 UserDescriptor * pUser = new UserDescriptor( m_xMutex, m_conn, m_pSettings );
77 pUser->copyValuesFrom( this );
79 return Reference< XPropertySet > ( pUser );
83 Sequence<Type > User::getTypes()
85 static cppu::OTypeCollection collection(
86 cppu::UnoType<css::sdbcx::XUser>::get(),
87 ReflectionBase::getTypes());
89 return collection.getTypes();
92 Sequence< sal_Int8> User::getImplementationId()
94 return css::uno::Sequence<sal_Int8>();
97 Any User::queryInterface( const Type & reqType )
99 Any ret = ReflectionBase::queryInterface( reqType );
100 if( ! ret.hasValue() )
101 ret = ::cppu::queryInterface(
102 reqType,
103 static_cast< css::sdbcx::XUser * > ( this ) );
104 return ret;
108 void User::changePassword(
109 const OUString&, const OUString& newPassword )
111 OUStringBuffer buf(128);
112 buf.append( "ALTER USER " );
113 bufferQuoteIdentifier( buf, extractStringProperty( this, getStatics().NAME ), m_pSettings );
114 buf.append( " PASSWORD " );
115 bufferQuoteConstant( buf, newPassword, m_pSettings );
116 Reference< XStatement > stmt = m_conn->createStatement();
117 DisposeGuard guard( stmt );
118 stmt->executeUpdate( buf.makeStringAndClear() );
121 sal_Int32 User::getPrivileges( const OUString& objName, sal_Int32 objType )
123 if (isLog(m_pSettings, LogLevel::Info))
125 Statics & st = getStatics();
127 OUStringBuffer buf( 128 );
128 buf.append( "User::getPrivileges[" ).append( extractStringProperty( this, st.NAME ) )
129 .append( "] got called for " ).append( objName ).append( "(type=" )
130 .append( OUString::number(objType) ).append(")");
131 log(m_pSettings, LogLevel::Info, buf.makeStringAndClear());
133 // all privileges
134 return 0xffffffff;
137 sal_Int32 User::getGrantablePrivileges( const OUString&, sal_Int32 )
139 // all privileges
140 return 0xffffffff;
143 void User::grantPrivileges( const OUString&, sal_Int32, sal_Int32 )
145 throw css::sdbc::SQLException("pq_driver: privilege change not implemented yet",
146 *this, OUString(), 1, Any() );
149 void User::revokePrivileges( const OUString&, sal_Int32, sal_Int32 )
151 throw css::sdbc::SQLException("pq_driver: privilege change not implemented yet",
152 *this, OUString(), 1, Any() );
156 UserDescriptor::UserDescriptor(
157 const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
158 const Reference< css::sdbc::XConnection > & connection,
159 ConnectionSettings *pSettings )
160 : ReflectionBase(
161 getStatics().refl.userDescriptor.implName,
162 getStatics().refl.userDescriptor.serviceNames,
163 refMutex,
164 connection,
165 pSettings,
166 * getStatics().refl.userDescriptor.pProps )
169 Reference< XPropertySet > UserDescriptor::createDataDescriptor( )
171 UserDescriptor * pUser = new UserDescriptor( m_xMutex, m_conn, m_pSettings );
172 pUser->copyValuesFrom( this );
174 return Reference< XPropertySet > ( pUser );
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */