Kaydet (Commit) 6b184f63 authored tarafından Andrzej J.R. Hunt's avatar Andrzej J.R. Hunt

Add skeleton sdbcx Users/User implementation. (firebird-sdbc)

Change-Id: I8a64f9776a618691fa61aa0e71067a0eb6176811
üst b71c3521
...@@ -51,6 +51,8 @@ $(eval $(call gb_Library_add_exception_objects,firebird_sdbc,\ ...@@ -51,6 +51,8 @@ $(eval $(call gb_Library_add_exception_objects,firebird_sdbc,\
connectivity/source/drivers/firebird/StatementCommonBase \ connectivity/source/drivers/firebird/StatementCommonBase \
connectivity/source/drivers/firebird/Table \ connectivity/source/drivers/firebird/Table \
connectivity/source/drivers/firebird/Tables \ connectivity/source/drivers/firebird/Tables \
connectivity/source/drivers/firebird/User \
connectivity/source/drivers/firebird/Users \
connectivity/source/drivers/firebird/Util \ connectivity/source/drivers/firebird/Util \
)) ))
......
/* -*- 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
/* -*- 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
/* -*- 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
/* -*- 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment