Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : :
21 : : #include <stdio.h>
22 : : #include "connectivity/sdbcx/VUser.hxx"
23 : : #include <com/sun/star/lang/DisposedException.hpp>
24 : : #include <com/sun/star/sdbcx/Privilege.hpp>
25 : : #include <com/sun/star/sdbcx/PrivilegeObject.hpp>
26 : : #include "TConnection.hxx"
27 : : #include "connectivity/sdbcx/VCollection.hxx"
28 : : #include <connectivity/dbexception.hxx>
29 : : #include <comphelper/sequence.hxx>
30 : :
31 : : // -------------------------------------------------------------------------
32 : : using namespace connectivity;
33 : : using namespace connectivity::sdbcx;
34 : : using namespace ::com::sun::star::sdbc;
35 : : using namespace ::com::sun::star::beans;
36 : : using namespace ::com::sun::star::uno;
37 : : using namespace ::com::sun::star::container;
38 : : using namespace ::com::sun::star::lang;
39 : :
40 [ # # ][ # # ]: 0 : IMPLEMENT_SERVICE_INFO(OUser,"com.sun.star.sdbcx.VUser","com.sun.star.sdbcx.User");
[ # # ][ # # ]
[ # # ][ # # ]
41 : : // -------------------------------------------------------------------------
42 : 0 : OUser::OUser(sal_Bool _bCase) : OUser_BASE(m_aMutex)
43 : : , ODescriptor(OUser_BASE::rBHelper,_bCase,sal_True)
44 [ # # ][ # # ]: 0 : , m_pGroups(NULL)
45 : : {
46 : 0 : }
47 : : // -------------------------------------------------------------------------
48 : 0 : OUser::OUser(const ::rtl::OUString& _Name,sal_Bool _bCase) : OUser_BASE(m_aMutex)
49 : : ,ODescriptor(OUser_BASE::rBHelper,_bCase)
50 [ # # ][ # # ]: 0 : ,m_pGroups(NULL)
51 : : {
52 : 0 : m_Name = _Name;
53 : 0 : }
54 : : // -------------------------------------------------------------------------
55 [ # # ][ # # ]: 0 : OUser::~OUser( )
[ # # ]
56 : : {
57 [ # # ][ # # ]: 0 : delete m_pGroups;
58 [ # # ]: 0 : }
59 : : // -------------------------------------------------------------------------
60 : 0 : void OUser::disposing(void)
61 : : {
62 [ # # ]: 0 : OPropertySetHelper::disposing();
63 [ # # ]: 0 : ::osl::MutexGuard aGuard(m_aMutex);
64 [ # # ]: 0 : if(m_pGroups)
65 [ # # ][ # # ]: 0 : m_pGroups->disposing();
66 : 0 : }
67 : : // -------------------------------------------------------------------------
68 : 0 : Any SAL_CALL OUser::queryInterface( const Type & rType ) throw(RuntimeException)
69 : : {
70 [ # # ]: 0 : Any aRet = ODescriptor::queryInterface( rType);
71 [ # # ][ # # ]: 0 : return aRet.hasValue() ? aRet : OUser_BASE::queryInterface( rType);
72 : : }
73 : : // -------------------------------------------------------------------------
74 : 0 : Sequence< Type > SAL_CALL OUser::getTypes( ) throw(RuntimeException)
75 : : {
76 [ # # ][ # # ]: 0 : return ::comphelper::concatSequences(ODescriptor::getTypes(),OUser_BASE::getTypes());
[ # # ]
77 : : }
78 : : // -------------------------------------------------------------------------
79 : 0 : ::cppu::IPropertyArrayHelper* OUser::createArrayHelper( ) const
80 : : {
81 [ # # ]: 0 : Sequence< Property > aProps;
82 [ # # ]: 0 : describeProperties(aProps);
83 [ # # ][ # # ]: 0 : return new ::cppu::OPropertyArrayHelper(aProps);
84 : :
85 : : }
86 : : // -------------------------------------------------------------------------
87 : 0 : ::cppu::IPropertyArrayHelper & OUser::getInfoHelper()
88 : : {
89 : 0 : return *const_cast<OUser*>(this)->getArrayHelper();
90 : : }
91 : : // -------------------------------------------------------------------------
92 : : // XUser
93 : 0 : void SAL_CALL OUser::changePassword( const ::rtl::OUString& /*objPassword*/, const ::rtl::OUString& /*newPassword*/ ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
94 : : {
95 [ # # ]: 0 : ::osl::MutexGuard aGuard(m_aMutex);
96 [ # # ]: 0 : checkDisposed(OUser_BASE::rBHelper.bDisposed);
97 [ # # ][ # # ]: 0 : ::dbtools::throwFeatureNotImplementedException( "XUser::changePassword", *this );
[ # # ]
98 : 0 : }
99 : : // -------------------------------------------------------------------------
100 : : // XGroupsSupplier
101 : 0 : Reference< XNameAccess > SAL_CALL OUser::getGroups( ) throw(RuntimeException)
102 : : {
103 [ # # ]: 0 : ::osl::MutexGuard aGuard(m_aMutex);
104 [ # # ]: 0 : checkDisposed(OUser_BASE::rBHelper.bDisposed);
105 : :
106 : : try
107 : : {
108 [ # # ]: 0 : if ( !m_pGroups )
109 [ # # ]: 0 : refreshGroups();
110 : : }
111 [ # # # ]: 0 : catch( const RuntimeException& )
112 : : {
113 : : // allowed to leave this method
114 : 0 : throw;
115 : : }
116 [ # # ]: 0 : catch( const Exception& )
117 : : {
118 : : // allowed
119 : : }
120 : :
121 [ # # ][ # # ]: 0 : return const_cast<OUser*>(this)->m_pGroups;
[ # # ]
122 : : }
123 : : // -------------------------------------------------------------------------
124 : : // -------------------------------------------------------------------------
125 : :
126 : 0 : sal_Int32 SAL_CALL OUser::getPrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
127 : : {
128 [ # # ]: 0 : ::osl::MutexGuard aGuard(m_aMutex);
129 [ # # ]: 0 : checkDisposed(OUser_BASE::rBHelper.bDisposed);
130 [ # # ][ # # ]: 0 : ::dbtools::throwFeatureNotImplementedException( "XAuthorizable::changePassword", *this );
131 [ # # ]: 0 : return 0;
132 : : }
133 : : // -------------------------------------------------------------------------
134 : 0 : sal_Int32 SAL_CALL OUser::getGrantablePrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
135 : : {
136 [ # # ]: 0 : ::osl::MutexGuard aGuard(m_aMutex);
137 [ # # ]: 0 : checkDisposed(OUser_BASE::rBHelper.bDisposed);
138 [ # # ][ # # ]: 0 : ::dbtools::throwFeatureNotImplementedException( "XAuthorizable::getGrantablePrivileges", *this );
139 [ # # ]: 0 : return 0;
140 : : }
141 : : // -------------------------------------------------------------------------
142 : 0 : void SAL_CALL OUser::grantPrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/, sal_Int32 /*objPrivileges*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
143 : : {
144 [ # # ]: 0 : ::osl::MutexGuard aGuard(m_aMutex);
145 [ # # ]: 0 : checkDisposed(OUser_BASE::rBHelper.bDisposed);
146 [ # # ][ # # ]: 0 : ::dbtools::throwFeatureNotImplementedException( "XAuthorizable::grantPrivileges", *this );
[ # # ]
147 : 0 : }
148 : : // -------------------------------------------------------------------------
149 : 0 : void SAL_CALL OUser::revokePrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/, sal_Int32 /*objPrivileges*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
150 : : {
151 [ # # ]: 0 : ::osl::MutexGuard aGuard(m_aMutex);
152 [ # # ]: 0 : checkDisposed(OUser_BASE::rBHelper.bDisposed);
153 [ # # ][ # # ]: 0 : ::dbtools::throwFeatureNotImplementedException( "XAuthorizable::revokePrivileges", *this );
[ # # ]
154 : 0 : }
155 : : // -----------------------------------------------------------------------------
156 : 0 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OUser::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
157 : : {
158 : 0 : return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
159 : : }
160 : : // -----------------------------------------------------------------------------
161 : 0 : ::rtl::OUString SAL_CALL OUser::getName( ) throw(::com::sun::star::uno::RuntimeException)
162 : : {
163 : 0 : return m_Name;
164 : : }
165 : : // -----------------------------------------------------------------------------
166 : 0 : void SAL_CALL OUser::setName( const ::rtl::OUString& /*aName*/ ) throw(::com::sun::star::uno::RuntimeException)
167 : : {
168 : : OSL_FAIL( "OUser::setName: not implemented!" );
169 : : // not allowed to throw an SQLException here ...
170 : 0 : }
171 : : // -----------------------------------------------------------------------------
172 : : // XInterface
173 : 0 : void SAL_CALL OUser::acquire() throw()
174 : : {
175 : 0 : OUser_BASE::acquire();
176 : 0 : }
177 : : // -----------------------------------------------------------------------------
178 : 0 : void SAL_CALL OUser::release() throw()
179 : : {
180 : 0 : OUser_BASE::release();
181 : 0 : }
182 : : // -----------------------------------------------------------------------------
183 : :
184 : :
185 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|