diff options
author | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-08-19 13:58:55 +0100 |
---|---|---|
committer | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-08-20 21:37:50 +0100 |
commit | 6b184f638d5027eab0166a11506c59fa6194dd62 (patch) | |
tree | 00278f69a7097b8e393ffdb03ecfe86648a41fb8 | |
parent | b71c35216c5fb775aa578a0ada0406f6baad8487 (diff) |
Add skeleton sdbcx Users/User implementation. (firebird-sdbc)
Change-Id: I8a64f9776a618691fa61aa0e71067a0eb6176811
-rw-r--r-- | connectivity/Library_firebird_sdbc.mk | 2 | ||||
-rw-r--r-- | connectivity/source/drivers/firebird/User.cxx | 38 | ||||
-rw-r--r-- | connectivity/source/drivers/firebird/User.hxx | 49 | ||||
-rw-r--r-- | connectivity/source/drivers/firebird/Users.cxx | 110 | ||||
-rw-r--r-- | connectivity/source/drivers/firebird/Users.hxx | 65 |
5 files changed, 264 insertions, 0 deletions
diff --git a/connectivity/Library_firebird_sdbc.mk b/connectivity/Library_firebird_sdbc.mk index 577c169e9ef5..1f78608214b5 100644 --- a/connectivity/Library_firebird_sdbc.mk +++ b/connectivity/Library_firebird_sdbc.mk @@ -51,6 +51,8 @@ $(eval $(call gb_Library_add_exception_objects,firebird_sdbc,\ connectivity/source/drivers/firebird/StatementCommonBase \ connectivity/source/drivers/firebird/Table \ connectivity/source/drivers/firebird/Tables \ + connectivity/source/drivers/firebird/User \ + connectivity/source/drivers/firebird/Users \ connectivity/source/drivers/firebird/Util \ )) diff --git a/connectivity/source/drivers/firebird/User.cxx b/connectivity/source/drivers/firebird/User.cxx new file mode 100644 index 000000000000..885ecffe3908 --- /dev/null +++ b/connectivity/source/drivers/firebird/User.cxx @@ -0,0 +1,38 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "User.hxx" + +using namespace ::connectivity; +using namespace ::connectivity::firebird; +using namespace ::connectivity::sdbcx; + +using namespace ::rtl; + +using namespace ::com::sun::star; +using namespace ::com::sun::star::sdbc; + +User::User(const uno::Reference< XConnection >& rConnection): + OUser(sal_True) // Case Sensitive +{ + (void) rConnection; +} + +User::User(const uno::Reference< XConnection >& rConnection, const OUString& rName): + OUser(rName, + sal_True) // Case Sensitive +{ + (void) rConnection; +} + +//----- IRefreshableGroups ---------------------------------------------------- +void User::refreshGroups() +{ + // TODO: implement. +}
\ No newline at end of file diff --git a/connectivity/source/drivers/firebird/User.hxx b/connectivity/source/drivers/firebird/User.hxx new file mode 100644 index 000000000000..8ae8bd488d26 --- /dev/null +++ b/connectivity/source/drivers/firebird/User.hxx @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef CONNECTIVITY_FIREBIRD_USER_HXX +#define CONNECTIVITY_FIREBIRD_USER_HXX + +#include <connectivity/sdbcx/VUser.hxx> + +#include <com/sun/star/sdbc/XConnection.hpp> + +namespace connectivity +{ + namespace firebird + { + + /** + * This implements com.sun.star.sdbcx.Container. + */ + class User: public ::connectivity::sdbcx::OUser + { + + public: + /** + * Create a "new" descriptor, which isn't yet in the database. + */ + User(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& rConnection); + /** + * For a user that already exists in the db. + */ + User(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& rConnection, + const ::rtl::OUString& rName); + + // IRefreshableGroups:: + virtual void refreshGroups(); + }; + + } // namespace firebird +} // namespace connectivity + + +#endif // CONNECTIVITY_FIREBIRD_USER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file diff --git a/connectivity/source/drivers/firebird/Users.cxx b/connectivity/source/drivers/firebird/Users.cxx new file mode 100644 index 000000000000..75073a7cf8ae --- /dev/null +++ b/connectivity/source/drivers/firebird/Users.cxx @@ -0,0 +1,110 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "User.hxx" +#include "Users.hxx" + +#include <connectivity/dbtools.hxx> + +#include <com/sun/star/sdbc/XRow.hpp> + +using namespace ::connectivity; +using namespace ::connectivity::firebird; +using namespace ::connectivity::sdbcx; +using namespace ::cppu; +using namespace ::osl; +using namespace ::rtl; + +using namespace ::com::sun::star; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::uno; + + +Users::Users(const uno::Reference< XDatabaseMetaData >& rMetaData, + OWeakObject& rParent, + Mutex& rMutex, + TStringVector& rNames) : + OCollection(rParent, + sal_True, + rMutex, + rNames), + m_rMutex(rMutex), + m_xMetaData(rMetaData) +{ +} + +//----- OCollection ----------------------------------------------------------- +void Users::impl_refresh() + throw(RuntimeException) +{ + // TODO: IMPLEMENT ME +} + +ObjectType Users::createObject(const OUString& rName) +{ + (void) rName; + // TODO: set query string + OUString sSql; + uno::Reference< XResultSet > xUsers = m_xMetaData->getConnection() + ->createStatement()->executeQuery(sSql); + + if (!xUsers.is()) + throw RuntimeException(); + + uno::Reference< XRow > xRow(xUsers,UNO_QUERY); + + if (!xRow.is() || !xUsers->next()) + throw RuntimeException(); + + ObjectType xRet(new User(m_xMetaData->getConnection(), + xRow->getString(1))); // Name + + if (xUsers->next()) + throw RuntimeException(); // Only one user should be returned + + return xRet; +} + +uno::Reference< XPropertySet > Users::createDescriptor() +{ + // There is some internal magic so that the same class can be used as either + // a descriptor or as a normal user. See VUser.cxx for the details. In our + // case we just need to ensure we use the correct constructor. + return new User(m_xMetaData->getConnection()); +} + +//----- XAppend --------------------------------------------------------------- +ObjectType Users::appendObject(const OUString& rName, + const uno::Reference< XPropertySet >& rDescriptor) +{ + // TODO: set sSql as appropriate + (void) rName; + (void) rDescriptor; + OUString sSql; + m_xMetaData->getConnection()->createStatement()->execute(sSql); + + return createObject(rName); +} + +//----- XDrop ----------------------------------------------------------------- +void Users::dropObject(sal_Int32 nPosition, const OUString sName) +{ + uno::Reference< XPropertySet > xUser(getObject(nPosition)); + + if (!ODescriptor::isNew(xUser)) + { + (void) sName; + // TODO: drop me + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file diff --git a/connectivity/source/drivers/firebird/Users.hxx b/connectivity/source/drivers/firebird/Users.hxx new file mode 100644 index 000000000000..12f2ef3434bf --- /dev/null +++ b/connectivity/source/drivers/firebird/Users.hxx @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef CONNECTIVITY_FIREBIRD_USERS_HXX +#define CONNECTIVITY_FIREBIRD_USERS_HXX + +#include "DatabaseMetaData.hxx" + +#include <connectivity/sdbcx/VCollection.hxx> + +namespace connectivity +{ + namespace firebird + { + + /** + * This implements com.sun.star.sdbcx.Container. + */ + class Users: public ::connectivity::sdbcx::OCollection + { + private: + ::osl::Mutex& m_rMutex; + + protected: + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > + m_xMetaData; + + // OCollection + virtual void impl_refresh() + throw(::com::sun::star::uno::RuntimeException); + virtual ::connectivity::sdbcx::ObjectType createObject( + const ::rtl::OUString& rName); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > + createDescriptor(); + virtual ::connectivity::sdbcx::ObjectType appendObject( + const OUString& rName, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rDescriptor); + + public: + Users(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& rMetaData, + ::cppu::OWeakObject& rParent, + ::osl::Mutex& rMutex, + ::connectivity::TStringVector& rNames); + + // TODO: we should also implement XDataDescriptorFactory, XRefreshable, + // XAppend, etc., but all are optional. + + // XDrop + virtual void dropObject(sal_Int32 nPosition, const ::rtl::OUString rName); + + }; + + } // namespace firebird +} // namespace connectivity + + +#endif // CONNECTIVITY_FIREBIRD_USERS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file |