diff options
Diffstat (limited to 'connectivity/source')
74 files changed, 10 insertions, 14609 deletions
diff --git a/connectivity/source/drivers/mozab/MCatalog.cxx b/connectivity/source/drivers/mozab/MCatalog.cxx deleted file mode 100644 index 8fae349bfe70..000000000000 --- a/connectivity/source/drivers/mozab/MCatalog.cxx +++ /dev/null @@ -1,111 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "MCatalog.hxx" -#include "MConnection.hxx" -#include "MTables.hxx" -#include <com/sun/star/sdbc/XRow.hpp> -#include <com/sun/star/sdbc/XResultSet.hpp> -#include <cppuhelper/interfacecontainer.h> - - -using namespace connectivity::mozab; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; -using namespace ::cppu; - - -OCatalog::OCatalog(OConnection* _pCon) : connectivity::sdbcx::OCatalog(_pCon) - ,m_pConnection(_pCon) - ,m_xMetaData(m_pConnection->getMetaData( )) -{ -// osl_atomic_increment( &m_refCount ); -// refreshTables(); -// refreshViews(); -// refreshGroups(); -// refreshUsers(); -// osl_atomic_decrement( &m_refCount ); -} - -void OCatalog::refreshTables() -{ - TStringVector aVector; - Sequence< OUString > aTypes(1); - aTypes[0] = "%"; - Reference< XResultSet > xResult = m_xMetaData->getTables(Any(), - OUString("%"),OUString("%"),aTypes); - - if(xResult.is()) - { - Reference< XRow > xRow(xResult,UNO_QUERY); - OUString aName; - while(xResult->next()) - { - aName = xRow->getString(3); - aVector.push_back(aName); - } - } - if(m_pTables) - m_pTables->reFill(aVector); - else - m_pTables = new OTables(m_xMetaData,*this,m_aMutex,aVector); -} - -void OCatalog::refreshViews() -{ -} - -void OCatalog::refreshGroups() -{ -} - -void OCatalog::refreshUsers() -{ -} - - -// XTablesSupplier -Reference< XNameAccess > SAL_CALL OCatalog::getTables( ) throw(RuntimeException) -{ - ::osl::MutexGuard aGuard(m_aMutex); - checkDisposed(rBHelper.bDisposed); - - try - { - if(!m_pTables || m_pConnection->getForceLoadTables()) - refreshTables(); - } - catch( const RuntimeException& ) - { - // allowed to leave this method - throw; - } - catch( const Exception& ) - { - // allowed - } - - return const_cast<OCatalog*>(this)->m_pTables; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MCatalog.hxx b/connectivity/source/drivers/mozab/MCatalog.hxx deleted file mode 100644 index 3df1ab852f83..000000000000 --- a/connectivity/source/drivers/mozab/MCatalog.hxx +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MCATALOG_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MCATALOG_HXX - -#include <connectivity/sdbcx/VCatalog.hxx> - -namespace connectivity -{ - namespace mozab - { - // please don't name the class the same name as in an other namespaces - // some compilers have problems with this task as I noticed on windows - class OConnection; - class OCatalog : public connectivity::sdbcx::OCatalog - { - OConnection* m_pConnection; // used to get the metadata - ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; // just to make things easier - - public: - // implementation of the pure virtual methods - virtual void refreshTables(); - virtual void refreshViews() ; - virtual void refreshGroups(); - virtual void refreshUsers() ; - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTables( ) throw(::com::sun::star::uno::RuntimeException); - public: - explicit OCatalog(OConnection* _pCon); - - OConnection* getConnection() const { return m_pConnection; } - sdbcx::OCollection* getPrivateTables() const { return m_pTables;} - sdbcx::OCollection* getPrivateViews() const { return m_pViews; } - - }; - } -} -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MCATALOG_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MColumnAlias.cxx b/connectivity/source/drivers/mozab/MColumnAlias.cxx deleted file mode 100644 index f3ba63e75684..000000000000 --- a/connectivity/source/drivers/mozab/MColumnAlias.cxx +++ /dev/null @@ -1,180 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <sal/macros.h> -#include "MColumnAlias.hxx" -#include "MConnection.hxx" -#include "MExtConfigAccess.hxx" - -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/container/XNameAccess.hpp> - -#include <tools/diagnose_ex.h> - -#include <algorithm> -#include <functional> - -using namespace ::connectivity; -using namespace ::connectivity::mozab; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; - - -OColumnAlias::OColumnAlias( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB ) -{ - static const sal_Char* s_pProgrammaticNames[] = - { - "FirstName", - "LastName", - "DisplayName", - "NickName", - "PrimaryEmail", - "SecondEmail", - "PreferMailFormat", - "WorkPhone", - "HomePhone", - "FaxNumber", - "PagerNumber", - "CellularNumber", - "HomeAddress", - "HomeAddress2", - "HomeCity", - "HomeState", - "HomeZipCode", - "HomeCountry", - "WorkAddress", - "WorkAddress2", - "WorkCity", - "WorkState", - "WorkZipCode", - "WorkCountry", - "JobTitle", - "Department", - "Company", - "WebPage1", - "WebPage2", - "BirthYear", - "BirthMonth", - "BirthDay", - "Custom1", - "Custom2", - "Custom3", - "Custom4", - "Notes", - }; - - for ( size_t i = 0; i < sizeof( s_pProgrammaticNames ) / sizeof( s_pProgrammaticNames[0] ); ++i ) - m_aAliasMap[ OUString::createFromAscii( s_pProgrammaticNames[i] ) ] = AliasEntry( s_pProgrammaticNames[i], i ); - - initialize( _rxORB ); -} - - -void OColumnAlias::initialize( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB ) -{ - // open our driver settings config node - - // the config path for our own driver's settings - Reference< XPropertySet > xDriverNode = createDriverConfigNode( _rxORB ); - if ( xDriverNode.is() ) - { - try - { - - Reference< XNameAccess > xAliasesNode; - xDriverNode->getPropertyValue("ColumnAliases") >>= xAliasesNode; - OSL_ENSURE( xAliasesNode.is(), "OColumnAlias::setAlias: missing the aliases node!" ); - - // this is a set of string nodes - Sequence< OUString > aProgrammaticNames; - if ( xAliasesNode.is() ) - aProgrammaticNames = xAliasesNode->getElementNames(); - - - // travel through all the set elements - const OUString* pProgrammaticNames = aProgrammaticNames.getConstArray(); - const OUString* pProgrammaticNamesEnd = pProgrammaticNames + aProgrammaticNames.getLength(); - OUString sAssignedAlias; - - for ( ; pProgrammaticNames < pProgrammaticNamesEnd; ++pProgrammaticNames ) - { - OSL_VERIFY( xAliasesNode->getByName( *pProgrammaticNames ) >>= sAssignedAlias ); - - // normalize in case the config data is corrupted - // (what we really don't need is an empty alias ...) - if ( sAssignedAlias.isEmpty() ) - sAssignedAlias = *pProgrammaticNames; - - OString sAsciiProgrammaticName( OUStringToOString( *pProgrammaticNames, RTL_TEXTENCODING_ASCII_US ) ); - - bool bFound = false; - for ( AliasMap::iterator search = m_aAliasMap.begin(); - ( search != m_aAliasMap.end() ); - ++search - ) - { - if ( search->second.programmaticAsciiName.equals( sAsciiProgrammaticName ) ) - { - AliasEntry entry( search->second ); - m_aAliasMap.erase( search ); - m_aAliasMap[ sAssignedAlias ] = entry; - - bFound = true; - - break; - } - } - - OSL_ENSURE( bFound, "OColumnAlias::setAlias: did not find a programmatic name which exists in the configuration!" ); - } - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - } -} - - -OString OColumnAlias::getProgrammaticNameOrFallbackToUTF8Alias( const OUString& _rAlias ) const -{ - AliasMap::const_iterator pos = m_aAliasMap.find( _rAlias ); - if ( pos == m_aAliasMap.end() ) - { - OSL_FAIL( "OColumnAlias::getProgrammaticNameOrFallbackToUTF8Alias: no programmatic name for this alias!" ); - return OUStringToOString( _rAlias, RTL_TEXTENCODING_UTF8 ); - } - return pos->second.programmaticAsciiName; -} - - -bool OColumnAlias::isColumnSearchable( const OUString _alias ) const -{ - OString sProgrammatic = getProgrammaticNameOrFallbackToUTF8Alias( _alias ); - - return ( !sProgrammatic.equals( "HomeCountry" ) - && !sProgrammatic.equals( "WorkCountry" ) - ); - // for those, we know that they're not searchable in the Mozilla/LDAP implementation. - // There might be more ... -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MColumnAlias.hxx b/connectivity/source/drivers/mozab/MColumnAlias.hxx deleted file mode 100644 index 807cb112862a..000000000000 --- a/connectivity/source/drivers/mozab/MColumnAlias.hxx +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MCOLUMNALIAS_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MCOLUMNALIAS_HXX - -#include <unotools/confignode.hxx> - -#include <osl/mutex.hxx> -#include <unordered_map> -#include <vector> - -namespace connectivity -{ - namespace mozab - { - class OColumnAlias - { - public: - struct AliasEntry - { - OString programmaticAsciiName; - size_t columnPosition; - - AliasEntry() - :programmaticAsciiName() - ,columnPosition( 0 ) - { - } - AliasEntry( const sal_Char* _programmaticAsciiName, size_t _columnPosition ) - :programmaticAsciiName( _programmaticAsciiName ) - ,columnPosition( _columnPosition ) - { - } - }; - typedef std::unordered_map< OUString, AliasEntry, OUStringHash > AliasMap; - - private: - AliasMap m_aAliasMap; - - public: - explicit OColumnAlias( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & ); - - inline bool hasAlias( const OUString& _rAlias ) const - { - return m_aAliasMap.find( _rAlias ) != m_aAliasMap.end(); - } - OString getProgrammaticNameOrFallbackToUTF8Alias( const OUString& _rAlias ) const; - - inline AliasMap::const_iterator begin() const { return m_aAliasMap.begin(); } - inline AliasMap::const_iterator end() const { return m_aAliasMap.end(); } - - bool isColumnSearchable( const OUString _alias ) const; - - private: - void initialize( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB ); - }; - } -} -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MCOLUMNALIAS_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MColumns.cxx b/connectivity/source/drivers/mozab/MColumns.cxx deleted file mode 100644 index a59b9ca1fcf9..000000000000 --- a/connectivity/source/drivers/mozab/MColumns.cxx +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "MColumns.hxx" -#include <connectivity/sdbcx/VColumn.hxx> -#include <com/sun/star/sdbc/XRow.hpp> -#include <com/sun/star/sdbc/XResultSet.hpp> -#include <com/sun/star/sdbc/DataType.hpp> -#include <com/sun/star/sdbc/ColumnValue.hpp> -#include "MTable.hxx" -#include "MTables.hxx" -#include "MCatalog.hxx" -#include <comphelper/types.hxx> -#include <connectivity/dbtools.hxx> - -using namespace ::comphelper; - - -using namespace connectivity::mozab; -using namespace connectivity::sdbcx; -using namespace connectivity; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; - -sdbcx::ObjectType OColumns::createObject(const OUString& _rName) -{ - const Any aCatalog; - const OUString sCatalogName; - const OUString sSchemaName(m_pTable->getSchema()); - const OUString sTableName(m_pTable->getTableName()); - Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns( - aCatalog, sSchemaName, sTableName, _rName); - - sdbcx::ObjectType xRet = NULL; - if(xResult.is()) - { - Reference< XRow > xRow(xResult,UNO_QUERY); - while(xResult->next()) - { - if(xRow->getString(4) == _rName) - { - sal_Int32 nType = xRow->getInt(5); - OUString sTypeName = xRow->getString(6); - sal_Int32 nPrec = xRow->getInt(7); - - OColumn* pRet = new OColumn(_rName, - sTypeName, - xRow->getString(13), - xRow->getString(12), - xRow->getInt(11), - nPrec, - xRow->getInt(9), - nType, - sal_False,sal_False,sal_False,sal_True, - sCatalogName, - sSchemaName, - sTableName); - xRet = pRet; - break; - } - } - } - - return xRet; -} - - -void OColumns::impl_refresh() throw(RuntimeException) -{ - m_pTable->refreshColumns(); -} - - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MColumns.hxx b/connectivity/source/drivers/mozab/MColumns.hxx deleted file mode 100644 index af685ee912b2..000000000000 --- a/connectivity/source/drivers/mozab/MColumns.hxx +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MCOLUMNS_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MCOLUMNS_HXX - -#include <connectivity/sdbcx/VCollection.hxx> -#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> -#include <connectivity/sdbcx/IRefreshable.hxx> -#include "MTable.hxx" - -namespace connectivity -{ - namespace mozab - { - class OColumns : public sdbcx::OCollection - { - protected: - OTable* m_pTable; - - virtual sdbcx::ObjectType createObject(const OUString& _rName); - virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); - public: - OColumns( OTable* _pTable, - ::osl::Mutex& _rMutex, - const TStringVector &_rVector - ) : sdbcx::OCollection(*_pTable,sal_True,_rMutex,_rVector) - ,m_pTable(_pTable) - {} - }; - } -} -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MCOLUMNS_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MConfigAccess.cxx b/connectivity/source/drivers/mozab/MConfigAccess.cxx deleted file mode 100644 index 8c5f8ba7c09b..000000000000 --- a/connectivity/source/drivers/mozab/MConfigAccess.cxx +++ /dev/null @@ -1,258 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <com/sun/star/configuration/theDefaultProvider.hpp> -#include <comphelper/processfactory.hxx> - -#include "MConfigAccess.hxx" -#include "MExtConfigAccess.hxx" -#include "MConnection.hxx" - -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::beans; - - -namespace connectivity -{ - namespace mozab - { - - Reference< XPropertySet > createDriverConfigNode( Reference< XMultiServiceFactory > _rxORB ) - { - Reference< XPropertySet > xNode; - try - { - - // create the config provider - Reference< XMultiServiceFactory > xConfigProvider( - com::sun::star::configuration::theDefaultProvider::get( - comphelper::getComponentContext( _rxORB ) ) ); - - OUString sCompleteNodePath( "/org.openoffice.Office.DataAccess/DriverSettings/" ); - sCompleteNodePath += OConnection::getDriverImplementationName(); - - - // arguments for creating the config access - Sequence< Any > aArguments(2); - // the path to the node to open - aArguments[0] <<= PropertyValue( - OUString("nodepath"), - 0, - makeAny( sCompleteNodePath ), - PropertyState_DIRECT_VALUE - ); - // the depth: -1 means unlimited - aArguments[1] <<= PropertyValue( - OUString("depth"), - 0, - makeAny( (sal_Int32)-1 ), - PropertyState_DIRECT_VALUE - ); - - - // create the access - Reference< XInterface > xAccess = xConfigProvider->createInstanceWithArguments( - OUString("com.sun.star.configuration.ConfigurationAccess" ), - aArguments - ); - OSL_ENSURE( xAccess.is(), "createDriverConfigNode: invalid access returned (should throw an exception instead)!" ); - - xNode = xNode.query( xAccess ); - } - catch( const Exception& ) - { - OSL_FAIL( "createDriverConfigNode: caught an exception while accessing the driver's config node!" ); - } - - // outta here - return xNode; - } - - - namespace - { - // a private helper to accessing the point where we store the reference - // to the factory - Reference< XMultiServiceFactory >& accessFactoryStorage( ) - { - static Reference< XMultiServiceFactory > xMozabServiceFactory; - return xMozabServiceFactory; - } - } - - - void setMozabServiceFactory( const Reference< XMultiServiceFactory >& _rxFactory ) - { - accessFactoryStorage( ) = _rxFactory; - } - - - const Reference< XMultiServiceFactory >& getMozabServiceFactory( ) - { - return accessFactoryStorage( ); - } - - - OUString getDescription(const sal_Char* sNode,const OUString & sDefault) - { - OUString sPreferredName; - OUString sDescription; - - Reference< XMultiServiceFactory > xFactory = getMozabServiceFactory(); - OSL_ENSURE( xFactory.is(), "getPreferredProfileName: invalid service factory!" ); - if ( xFactory.is() ) - { - try - { - Reference< XPropertySet > xDriverNode = createDriverConfigNode( xFactory ); - Reference< XPropertySet > xMozPrefsNode; - if ( xDriverNode.is() ) - xDriverNode->getPropertyValue("MozillaPreferences") >>= xMozPrefsNode; - OSL_ENSURE( xMozPrefsNode.is(), "getPreferredProfileName: could not access the node for the mozilla preferences!" ); - if ( xMozPrefsNode.is() ) - xMozPrefsNode->getPropertyValue("ProfileName") >>= sPreferredName; - if ( xMozPrefsNode.is() ) - xMozPrefsNode->getPropertyValue( OUString::createFromAscii(sNode) ) >>= sDescription; - if (sDescription.getLength() == 0) - sDescription = sDefault; - } - catch( const Exception& ) - { - OSL_FAIL( "getDescription: caught an exception!" ); - } - } - if (sDescription.getLength() == 0) - sDescription = sDefault; - return sDescription; - } - - OUString getPreferredProfileName( ) - { - OUString sPreferredName; - - Reference< XMultiServiceFactory > xFactory = getMozabServiceFactory(); - OSL_ENSURE( xFactory.is(), "getPreferredProfileName: invalid service factory!" ); - if ( xFactory.is() ) - { - try - { - Reference< XPropertySet > xDriverNode = createDriverConfigNode( xFactory ); - Reference< XPropertySet > xMozPrefsNode; - if ( xDriverNode.is() ) - xDriverNode->getPropertyValue("MozillaPreferences") >>= xMozPrefsNode; - OSL_ENSURE( xMozPrefsNode.is(), "getPreferredProfileName: could not access the node for the mozilla preferences!" ); - if ( xMozPrefsNode.is() ) - xMozPrefsNode->getPropertyValue("ProfileName") >>= sPreferredName; - } - catch( const Exception& ) - { - OSL_FAIL( "getPreferredProfileName: caught an exception!" ); - } - } - return sPreferredName; - } - } -} - - - - -extern "C" const sal_Unicode* SAL_CALL getUserProfile() -{ - static sal_Bool bReadConfig = sal_False; - static OUString sUserProfile; - if ( !bReadConfig ) - { - sUserProfile = ::connectivity::mozab::getPreferredProfileName( ); - bReadConfig = sal_True; - } - - return sUserProfile.getStr(); -} - -extern "C" const sal_Char* SAL_CALL getPabDescription() -{ - static sal_Bool bReadConfig = sal_False; - static OUString usPabDescription; - static OString sPabDescription; - - if ( !bReadConfig ) - { - usPabDescription = ::connectivity::mozab::getDescription( - "PabDescription" , - OUString("Personal Address Book" )); - sPabDescription = OUStringToOString( usPabDescription, - RTL_TEXTENCODING_UTF8); - bReadConfig = sal_True; - } - - return sPabDescription.getStr(); -} - - -extern "C" const sal_Char* SAL_CALL getHisDescription() -{ - static sal_Bool bReadConfig = sal_False; - static OUString usHisDescription; - static OString sHisDescription; - - if ( !bReadConfig ) - { - usHisDescription = ::connectivity::mozab::getDescription( - "HisDescription" , - OUString("Collected Addresses" )); - sHisDescription = OUStringToOString( usHisDescription, - RTL_TEXTENCODING_UTF8); - bReadConfig = sal_True; - } - - return sHisDescription.getStr(); -} - - -// MConfigAccess was invented to allow non-UNO parts access to the configuration. -// Unfortunately, configuration access requires a XMultiServiceFactory - which the -// mozilla side does not have. -// So we create a "library-local" service factory here: Every need for a service -// factory can be fulfilled by this factory (similar to the get/setProcessServiceFactory -// in comphelper). -// This is halfway valid, as usually, the mozabdrv library is invoked from the mozab library -// only. The latter contains the driver class (and only this class and nothing more), and -// the driver class is a singleton. The driver itself is created with a service factory, -// which (by definition) can and should be used for all subsequent service requests. -// And this is exactly what we're allowing with the following functions .... - -/** _pFactory must point to an XMultiServiceFactory, which must be acquired once - for purpose of safely transferring it. The callee will release this interface - when it has stored the pointer somewhere else. -*/ -extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL setMozabServiceFactory( - void* _pFactory ) -{ - Reference< XMultiServiceFactory > xFactory = static_cast< XMultiServiceFactory* >( _pFactory ); - ::connectivity::mozab::setMozabServiceFactory( xFactory ); - - // by definition, the object behind the interface pointer has been acquired once for purpose - // of safely transporting it - xFactory->release(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MConfigAccess.hxx b/connectivity/source/drivers/mozab/MConfigAccess.hxx deleted file mode 100644 index 25c1fc3e0f13..000000000000 --- a/connectivity/source/drivers/mozab/MConfigAccess.hxx +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MCONFIGACCESS_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MCONFIGACCESS_HXX - -#include <sal/types.h> - -extern "C" const sal_Unicode* SAL_CALL getUserProfile(); - -extern "C" const sal_Char* SAL_CALL getPabDescription(); - -extern "C" const sal_Char* SAL_CALL getHisDescription(); - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MCONFIGACCESS_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MConnection.cxx b/connectivity/source/drivers/mozab/MConnection.cxx deleted file mode 100644 index c3381eca99bd..000000000000 --- a/connectivity/source/drivers/mozab/MConnection.cxx +++ /dev/null @@ -1,594 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "MConnection.hxx" -#include "MDatabaseMetaData.hxx" -#include "MDriver.hxx" -#include "MColumnAlias.hxx" -#include "MStatement.hxx" -#include "MPreparedStatement.hxx" - -#include <connectivity/dbcharset.hxx> -#include <connectivity/dbexception.hxx> -#include <connectivity/sqlerror.hxx> - -#include "resource/mozab_res.hrc" -#include "resource/common_res.hrc" - -#include <com/sun/star/sdbc/ColumnValue.hpp> -#include <com/sun/star/sdbc/XRow.hpp> -#include <com/sun/star/sdbc/TransactionIsolation.hpp> - -#include <comphelper/officeresourcebundle.hxx> -#include <comphelper/processfactory.hxx> - -#if OSL_DEBUG_LEVEL > 0 -# define OUtoCStr( x ) ( OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr()) -#else /* OSL_DEBUG_LEVEL */ -# define OUtoCStr( x ) ("dummy") -#endif /* OSL_DEBUG_LEVEL */ - -extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL OMozabConnection_CreateInstance( - void* _pDriver) -{ - return (new connectivity::mozab::OConnection( reinterpret_cast<connectivity::mozab::MozabDriver*>(_pDriver) )); -} - -using namespace dbtools; - - -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::beans; -using namespace com::sun::star::sdbc; -using namespace com::sun::star::sdbcx; - - -namespace connectivity { namespace mozab { - - -// = ConnectionImplData - -struct ConnectionImplData -{ - std::shared_ptr< ::comphelper::OfficeResourceBundle > pResourceBundle; -}; - - -#ifdef __MINGW32__ -extern "C" -#endif -const sal_Char* getSdbcScheme( SdbcScheme _eScheme ) -{ - switch ( _eScheme ) - { - case SDBC_MOZILLA: return "mozilla"; - case SDBC_THUNDERBIRD: return "thunderbird"; - case SDBC_LDAP: return "ldap"; - case SDBC_OUTLOOK_MAPI: return "outlook"; - case SDBC_OUTLOOK_EXPRESS: return "outlookexp"; - } - return NULL; -} - -OUString OConnection::getDriverImplementationName() -{ - return OUString(MOZAB_DRIVER_IMPL_NAME); -} - - -const sal_Char* getSchemeURI( MozillaScheme _eScheme ) -{ - switch ( _eScheme ) - { - case SCHEME_MOZILLA : return "moz-abdirectory://"; - case SCHEME_MOZILLA_MDB : return "moz-abmdbdirectory://"; - case SCHEME_LDAP : return "moz-abldapdirectory://"; - case SCHEME_OUTLOOK_MAPI : return "moz-aboutlookdirectory://op/"; - case SCHEME_OUTLOOK_EXPRESS : return "moz-aboutlookdirectory://oe/"; - } - return NULL; -} - - - -OConnection::OConnection(MozabDriver* _pDriver) - :OSubComponent<OConnection, OConnection_BASE>((::cppu::OWeakObject*)_pDriver, this) - ,m_pDriver(_pDriver) - ,m_pImplData( new ConnectionImplData ) - ,m_aColumnAlias( _pDriver->getMSFactory() ) - ,m_nMaxResultRecords( -1 ) - ,m_aNameMapper(NULL) - ,m_eSDBCAddressType(SDBCAddress::Unknown) - ,m_bForceLoadTable(false) -{ - m_pDriver->acquire(); - -} - -OConnection::~OConnection() -{ - acquire(); - if(!isClosed()) - close(); - m_pDriver->release(); - m_pDriver = NULL; -} - -void SAL_CALL OConnection::release() throw() -{ - relase_ChildImpl(); -} - - -void OConnection::construct(const OUString& url,const Sequence< PropertyValue >& info) throw(SQLException) -{ - OSL_TRACE("IN OConnection::construct()" ); - // open file - setURL(url); - - // Skip 'sdbc:mozab: part of URL - - sal_Int32 nLen = url.indexOf(':'); - nLen = url.indexOf(':',nLen+1); - OSL_ENSURE( url.copy( 0, nLen ) == "sdbc:address", "OConnection::construct: invalid start of the URI - should never have survived XDriver::acceptsURL!" ); - - OUString aAddrbookURI(url.copy(nLen+1)); - // Get Scheme - nLen = aAddrbookURI.indexOf(':'); - OUString aAddrbookScheme; - OUString sAdditionalInfo; - if ( nLen == -1 ) - { - // There isn't any subschema: - but could be just subschema - if ( !aAddrbookURI.isEmpty() ) - { - aAddrbookScheme= aAddrbookURI; - } - else - { - OSL_TRACE( "No subschema given!!!"); - throwSQLException( STR_URI_SYNTAX_ERROR, *this ); - } - } - else - { - aAddrbookScheme = aAddrbookURI.copy(0, nLen); - sAdditionalInfo = aAddrbookURI.copy( nLen + 1 ); - } - - OSL_TRACE("URI = %s", ((OUtoCStr(aAddrbookURI)) ? (OUtoCStr(aAddrbookURI)):("NULL")) ); - OSL_TRACE("Scheme = %s\n", ((OUtoCStr(aAddrbookScheme)) ? (OUtoCStr(aAddrbookScheme)):("NULL")) ); - - // - // Now we have a URI convert it to a MozillaURI - // - // The Mapping being used is: - // - // * for Mozilla - // "sdbc:address:mozilla:" -> abdirectory:// - // * for LDAP - // "sdbc:address:ldap:" -> abldapdirectory:// - // * for Outlook (using MAPI API) - // "sdbc:address:outlook:" -> aboutlookdirectory://op/ - // * for windows system address book - // "sdbc:address:outlookexp:" -> aboutlookdirectory://oe/ - // - m_sBindDN = ""; - m_sPassword = ""; - m_bUseSSL = sal_False; - - if ( aAddrbookScheme.equalsAscii( getSdbcScheme( SDBC_MOZILLA ) ) ) { - m_sMozillaURI = OUString::createFromAscii( getSchemeURI( SCHEME_MOZILLA ) ); - m_eSDBCAddressType = SDBCAddress::Mozilla; - if(!sAdditionalInfo.isEmpty()) - m_sMozillaProfile = sAdditionalInfo; - } - else - if ( aAddrbookScheme.equalsAscii( getSdbcScheme( SDBC_THUNDERBIRD ) ) ) { - //Yes. I am sure it is SCHEME_MOZILLA - m_sMozillaURI = OUString::createFromAscii( getSchemeURI( SCHEME_MOZILLA ) ); - m_eSDBCAddressType = SDBCAddress::ThunderBird; - if(!sAdditionalInfo.isEmpty()) - m_sMozillaProfile = sAdditionalInfo; - } - else if ( aAddrbookScheme.equalsAscii( getSdbcScheme( SDBC_LDAP ) ) ) { - OUString sBaseDN; - sal_Int32 nPortNumber = -1; - - m_sMozillaURI = OUString::createFromAscii( getSchemeURI( SCHEME_LDAP ) ); - m_eSDBCAddressType = SDBCAddress::LDAP; - - if ( m_sHostName.isEmpty() ) - { - // see whether the URI contains a hostname/port - if ( !sAdditionalInfo.isEmpty() ) - { - sal_Int32 nPortSeparator = sAdditionalInfo.indexOf( ':' ); - if ( nPortSeparator == -1 ) - m_sHostName = sAdditionalInfo; - else - { - m_sHostName = sAdditionalInfo.copy( 0, nPortSeparator ); - nPortNumber = sAdditionalInfo.copy( nPortSeparator + 1 ).toInt32(); - OSL_ENSURE( nPortNumber != 0, "OConnection::construct: invalid LDAP port number in the URL!" ); - if ( nPortNumber == 0 ) - nPortNumber = -1; - } - } - } - - const PropertyValue* pInfo = info.getConstArray(); - const PropertyValue* pInfoEnd = pInfo + info.getLength(); - - for (; pInfo != pInfoEnd; ++pInfo) - { - OSL_TRACE( "info[%d].Name = %s", pInfo - info.getConstArray(), OUtoCStr( pInfo->Name ) ); - - if ( pInfo->Name.equalsAscii("HostName") ) - { - pInfo->Value >>= m_sHostName; - } - else if ( pInfo->Name.equalsAscii("BaseDN") ) - { - pInfo->Value >>= sBaseDN; - } - else if ( pInfo->Name.equalsAscii("user") ) - { - pInfo->Value >>= m_sBindDN; - } - else if ( pInfo->Name.equalsAscii("password") ) - { - pInfo->Value >>= m_sPassword; - } - else if ( pInfo->Name.equalsAscii("UseSSL") ) - { - pInfo->Value >>= m_bUseSSL; - } - else if ( pInfo->Name.equalsAscii("PortNumber") ) - { - OSL_VERIFY( pInfo->Value >>= nPortNumber ); - } - else if ( pInfo->Name.equalsAscii("MaxRowCount") ) - { - pInfo->Value >>= m_nMaxResultRecords; - } - } - - if ( !m_sHostName.isEmpty() ) { - m_sMozillaURI += m_sHostName; - } - else - throwSQLException( STR_NO_HOSTNAME, *this ); - - if ( nPortNumber > 0 ) { - m_sMozillaURI += ":"; - m_sMozillaURI += OUString::number( nPortNumber ); - } - - if ( !sBaseDN.isEmpty() ) { - m_sMozillaURI += "/"; - m_sMozillaURI += sBaseDN; - } - else - throwSQLException( STR_NO_BASEDN, *this ); - - // Addition of a fake query to enable the Mozilla LDAP directory to work correctly. - m_sMozillaURI += "?(or(DisplayName,=,DontDoThisAtHome)))"; - - } - else if ( aAddrbookScheme.equalsAscii( getSdbcScheme( SDBC_OUTLOOK_MAPI ) ) ) { - m_sMozillaURI = OUString::createFromAscii( getSchemeURI( SCHEME_OUTLOOK_MAPI ) ); - m_eSDBCAddressType = SDBCAddress::Outlook; - } - else if ( aAddrbookScheme.equalsAscii( getSdbcScheme( SDBC_OUTLOOK_EXPRESS ) ) ) { - m_sMozillaURI = OUString::createFromAscii( getSchemeURI( SCHEME_OUTLOOK_EXPRESS ) ); - m_eSDBCAddressType = SDBCAddress::OutlookExp; - } - else - { - OSL_TRACE("Invalid subschema given!!!"); - throwSQLException( STR_URI_SYNTAX_ERROR, *this ); - } - - OSL_TRACE("Moz URI = %s, %s", ((OUtoCStr(m_sMozillaURI)) ? (OUtoCStr(m_sMozillaURI)):("NULL")), usesFactory() ? "uses factory" : "no factory"); - OSL_TRACE( "\tOUT OConnection::construct()\n" ); - - MDatabaseMetaDataHelper _aDbHelper; - - // The creation of the nsIAbDirectory i/f for LDAP doesn't actually test - // the validity of the connection, it's normally delayed until the query - // is executed, but it's a bit late then to fail... - if ( isLDAP() ) - { - if ( !_aDbHelper.testLDAPConnection( this ) ) - { - OSL_TRACE("testLDAPConnection : FAILED" ); - throwSQLException( _aDbHelper.getError(), *this ); - } - else - { - OSL_TRACE("testLDAPConnection : SUCCESS" ); - } - } - - // Test connection by getting to get the Table Names - ::std::vector< OUString > tables; - ::std::vector< OUString > types; - if ( !_aDbHelper.getTableStrings( this, tables, types ) ) - { - throwSQLException( _aDbHelper.getError(), *this ); - } - -} -// XServiceInfo - -IMPLEMENT_SERVICE_INFO(OConnection, "com.sun.star.sdbc.drivers.mozab.OConnection", "com.sun.star.sdbc.Connection") - - -Reference< XStatement > SAL_CALL OConnection::createStatement( ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OConnection_BASE::rBHelper.bDisposed); - - // create a statement - // the statement can only be executed once - Reference< XStatement > xReturn = new OStatement(this); - m_aStatements.push_back(WeakReferenceHelper(xReturn)); - return xReturn; -} - -Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const OUString& _sSql ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OConnection_BASE::rBHelper.bDisposed); - - OSL_TRACE("OConnection::prepareStatement( %s )", OUtoCStr( _sSql ) ); - // the pre - // create a statement - // the statement can only be executed more than once - OPreparedStatement* pPrepared = new OPreparedStatement(this,_sSql); - Reference< XPreparedStatement > xReturn = pPrepared; - pPrepared->lateInit(); - - m_aStatements.push_back(WeakReferenceHelper(xReturn)); - return xReturn; -} - -Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const OUString& _sSql ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XConnection::prepareCall", *this ); - OSL_TRACE("OConnection::prepareCall( %s )", OUtoCStr( _sSql ) ); - return NULL; -} - -OUString SAL_CALL OConnection::nativeSQL( const OUString& _sSql ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - // when you need to transform SQL92 to you driver specific you can do it here - OSL_TRACE("OConnection::nativeSQL( %s )", OUtoCStr( _sSql ) ); - - return _sSql; -} - -void SAL_CALL OConnection::setAutoCommit( sal_Bool /*autoCommit*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XConnection::setAutoCommit", *this ); -} - -sal_Bool SAL_CALL OConnection::getAutoCommit( ) throw(SQLException, RuntimeException) -{ - // you have to distinguish which if you are in autocommit mode or not - // at normal case true should be fine here - - return sal_True; -} - -void SAL_CALL OConnection::commit( ) throw(SQLException, RuntimeException) -{ - // when you database does support transactions you should commit here -} - -void SAL_CALL OConnection::rollback( ) throw(SQLException, RuntimeException) -{ - // same as commit but for the other case -} - -sal_Bool SAL_CALL OConnection::isClosed( ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - // just simple -> we are close when we are disposed that means someone called dispose(); (XComponent) - return OConnection_BASE::rBHelper.bDisposed; -} - -Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData( ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OConnection_BASE::rBHelper.bDisposed); - - // here we have to create the class with biggest interface - // The answer is 42 :-) - Reference< XDatabaseMetaData > xMetaData = m_xMetaData; - if(!xMetaData.is()) - { - xMetaData = new ODatabaseMetaData(this); // need the connection because it can return it - m_xMetaData = xMetaData; - } - - return xMetaData; -} - -void SAL_CALL OConnection::setReadOnly( sal_Bool /*readOnly*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XConnection::setReadOnly", *this ); -} - -sal_Bool SAL_CALL OConnection::isReadOnly( ) throw(SQLException, RuntimeException) -{ - // return if your connection to readonly - return sal_False; -} - -void SAL_CALL OConnection::setCatalog( const OUString& /*catalog*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XConnection::setCatalog", *this ); -} - -OUString SAL_CALL OConnection::getCatalog( ) throw(SQLException, RuntimeException) -{ - // return your current catalog - return OUString(); -} - -void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 /*level*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XConnection::setTransactionIsolation", *this ); -} - -sal_Int32 SAL_CALL OConnection::getTransactionIsolation( ) throw(SQLException, RuntimeException) -{ - // please have a look at @see com.sun.star.sdbc.TransactionIsolation - return TransactionIsolation::NONE; -} - -Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OConnection::getTypeMap( ) throw(SQLException, RuntimeException) -{ - // if your driver has special database types you can return it here - return NULL; -} - -void SAL_CALL OConnection::setTypeMap( const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XConnection::setTypeMap", *this ); -} - -// XCloseable -void SAL_CALL OConnection::close( ) throw(SQLException, RuntimeException) -{ - // we just dispose us - { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OConnection_BASE::rBHelper.bDisposed); - - } - dispose(); -} - -// XWarningsSupplier -Any SAL_CALL OConnection::getWarnings( ) throw(SQLException, RuntimeException) -{ - // when you collected some warnings -> return it - return Any(); -} - -void SAL_CALL OConnection::clearWarnings( ) throw(SQLException, RuntimeException) -{ - // you should clear your collected warnings here -} - -void OConnection::disposing() -{ - // we noticed that we should be destroied in near future so we have to dispose our statements - ::osl::MutexGuard aGuard(m_aMutex); - - m_pImplData->pResourceBundle.reset(); - - OConnection_BASE::disposing(); - if ( m_aNameMapper ) { - MQuery::FreeNameMapper( m_aNameMapper ); - m_aNameMapper = NULL; - } - - dispose_ChildImpl(); -} - - -Reference< XTablesSupplier > SAL_CALL OConnection::createCatalog() -{ - OSL_TRACE("IN OConnection::createCatalog()" ); - ::osl::MutexGuard aGuard( m_aMutex ); - Reference< XTablesSupplier > xTab = m_xCatalog; - if(!m_xCatalog.is()) - { - OCatalog *pCat = new OCatalog(this); - xTab = pCat; - m_xCatalog = xTab; - } - OSL_TRACE( "\tOUT OConnection::createCatalog()" ); - return xTab; -} - - -MNameMapper* OConnection::getNameMapper () -{ - if (m_aNameMapper==NULL) - m_aNameMapper = MQuery::CreateNameMapper(); - - return m_aNameMapper; -} - - -void OConnection::throwSQLException( const ErrorDescriptor& _rError, const Reference< XInterface >& _rxContext ) -{ - if ( _rError.getResId() != 0 ) - { - OSL_ENSURE( ( _rError.getErrorCondition() == 0 ), - "OConnection::throwSQLException: unsupported error code combination!" ); - - OUString sParameter( _rError.getParameter() ); - if ( !sParameter.isEmpty() ) - { - const OUString sError( getResources().getResourceStringWithSubstitution( - _rError.getResId(), - "$1$", sParameter - ) ); - ::dbtools::throwGenericSQLException( sError, _rxContext ); - OSL_FAIL( "OConnection::throwSQLException: unreachable (1)!" ); - } - - throwGenericSQLException( _rError.getResId(), _rxContext ); - OSL_FAIL( "OConnection::throwSQLException: unreachable (2)!" ); - } - - if ( _rError.getErrorCondition() != 0 ) - { - SQLError aErrorHelper( comphelper::getComponentContext(getDriver()->getMSFactory()) ); - OUString sParameter( _rError.getParameter() ); - if ( !sParameter.isEmpty() ) - aErrorHelper.raiseException( _rError.getErrorCondition(), _rxContext, sParameter ); - else - aErrorHelper.raiseException( _rError.getErrorCondition(), _rxContext); - OSL_FAIL( "OConnection::throwSQLException: unreachable (3)!" ); - } - - throwGenericSQLException( STR_UNSPECIFIED_ERROR, _rxContext ); -} - - -void OConnection::throwSQLException( const sal_uInt16 _nErrorResourceId, const Reference< XInterface >& _rxContext ) -{ - ErrorDescriptor aError; - aError.setResId( _nErrorResourceId ); - throwSQLException( aError, _rxContext ); -} - -} } // namespace connectivity::mozab - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MConnection.hxx b/connectivity/source/drivers/mozab/MConnection.hxx deleted file mode 100644 index 11db44567959..000000000000 --- a/connectivity/source/drivers/mozab/MConnection.hxx +++ /dev/null @@ -1,225 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MCONNECTION_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MCONNECTION_HXX - -#include <connectivity/CommonTools.hxx> - -#include "MCatalog.hxx" -#include "MColumnAlias.hxx" -#include <connectivity/OSubComponent.hxx> -#include "TConnection.hxx" - -#include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/mozilla/MozillaProductType.hpp> -#include <com/sun/star/sdbc/SQLWarning.hpp> -#include <com/sun/star/sdbcx/XTablesSupplier.hpp> - -#include <cppuhelper/weakref.hxx> - -#include <memory> - -namespace connectivity -{ - namespace mozab - { - - class MozabDriver; - class MNameMapper; - class ErrorDescriptor; - - namespace SDBCAddress { - typedef enum { - Unknown = 0, - Mozilla = 1, - ThunderBird = 2, - LDAP = 3, - Outlook = 4, - OutlookExp = 5 - } sdbc_address_type; - } - - // For the moment, we will connect the Mozilla address book to the Mozilla - // top-level address book which will display whatever is in the preferences - // file of Mozilla. - enum MozillaScheme - { - // This one is a base uri which will be completed with the connection data. - SCHEME_MOZILLA, - // This one is for mozilla native address book - SCHEME_MOZILLA_MDB, - // This one is for LDAP address book - SCHEME_LDAP, - // These two uris will be used to obtain directory factories to access all - // address books of the given type. - SCHEME_OUTLOOK_MAPI, - SCHEME_OUTLOOK_EXPRESS - }; - const sal_Char* getSchemeURI( MozillaScheme _eScheme ); - - enum SdbcScheme - { - SDBC_MOZILLA, - SDBC_THUNDERBIRD, - SDBC_LDAP, - SDBC_OUTLOOK_MAPI, - SDBC_OUTLOOK_EXPRESS - }; -#ifdef __MINGW32__ - extern "C" -#endif - const sal_Char* getSdbcScheme( SdbcScheme _eScheme ); - - typedef connectivity::OMetaConnection OConnection_BASE; // implements basics and text encoding - - struct ConnectionImplData; - class OConnection : public OConnection_BASE, - public connectivity::OSubComponent<OConnection, OConnection_BASE> - { - friend class connectivity::OSubComponent<OConnection, OConnection_BASE>; - - protected: - - // Data attributes - - ::com::sun::star::sdbc::SQLWarning m_aLastWarning; // Last SQLWarning generated by - // an operation - MozabDriver* m_pDriver; // Pointer to the owning - // driver object - ::std::unique_ptr< ConnectionImplData > m_pImplData; - // This is to be able to hold a std::shared_ptr. If we would hold it as member, it would - // not compile the mozillasrc directory, since this directory is compiled without RTTI support - // and boost seems to require RTTI on some platforms. - // Store Catalog - ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog; - // Start of Additions from the land of mozilla - OColumnAlias m_aColumnAlias; - OUString m_sMozillaURI; - OUString m_sMozillaProfile; - sal_Int32 m_nMaxResultRecords; - MNameMapper* m_aNameMapper; - //LDAP only - OUString m_sHostName; - sal_Bool m_bUseSSL; - OUString m_sBindDN; - OUString m_sUser; // the user name - OUString m_sPassword; - - SDBCAddress::sdbc_address_type m_eSDBCAddressType; - - sal_Bool m_bForceLoadTable; - - public: - virtual void construct( const OUString& url,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info) throw(::com::sun::star::sdbc::SQLException); - explicit OConnection(MozabDriver* _pDriver); - virtual ~OConnection(); - - void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException); - - // OComponentHelper - virtual void SAL_CALL disposing(); - // XInterface - virtual void SAL_CALL release() throw(); - - // XServiceInfo - DECLARE_SERVICE_INFO(); - // XConnection - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL nativeSQL( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setCatalog( const OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - // XCloseable - virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - // XWarningsSupplier - virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - - MozabDriver* getDriver() const { return m_pDriver;} - - // Added to enable me to use SQLInterpreter which requires an - // XNameAccess i/f to access tables. - ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL createCatalog(); - - - // Additions from the land of mozilla - OUString getMozURI() const { return m_sMozillaURI; } - OUString getMozProfile() const { return m_sMozillaProfile; } - void setMozProfile(OUString &aNewProfile) { m_sMozillaProfile = aNewProfile; } - - ::com::sun::star::mozilla::MozillaProductType getProduct() - { - if (m_eSDBCAddressType == SDBCAddress::ThunderBird) - return ::com::sun::star::mozilla::MozillaProductType_Thunderbird; - return ::com::sun::star::mozilla::MozillaProductType_Mozilla; - } - - // Get Ldap BindDN (user name) - OUString getBindDN() const { return m_sBindDN; } - // Get Ldap Password - OUString getPassword() const { return m_sPassword; } - // Get Ldap Host name - OUString getHost() const { return m_sHostName; } - // Get whether use ssl to connect to ldap - sal_Bool getUseSSL() const {return m_bUseSSL;} - - sal_Bool usesFactory() const { return (m_eSDBCAddressType == SDBCAddress::Outlook) || (m_eSDBCAddressType == SDBCAddress::OutlookExp); } - sal_Bool isLDAP() const { return m_eSDBCAddressType == SDBCAddress::LDAP; } - sal_Bool isThunderbird() const { return m_eSDBCAddressType == SDBCAddress::ThunderBird; } - - sal_Bool isOutlookExpress() const { return m_eSDBCAddressType == SDBCAddress::OutlookExp;} - sal_Int32 getMaxResultRecords() const { return m_nMaxResultRecords; } - - SDBCAddress::sdbc_address_type getSDBCAddressType() const { return m_eSDBCAddressType;} - - const OColumnAlias & getColumnAlias() const { return m_aColumnAlias; } - - static OUString getDriverImplementationName(); - - MNameMapper* getNameMapper(); - void setForceLoadTables(sal_Bool aForce){ m_bForceLoadTable = aForce;} - sal_Bool getForceLoadTables() { return m_bForceLoadTable;} - - void throwSQLException( const ErrorDescriptor& _rError, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext ); - void throwSQLException( const sal_uInt16 _nErrorResourceId, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext ); - - private: - // make this private - clients should use throwSQLException instead - using OConnection_BASE::throwGenericSQLException; - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MCONNECTION_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MDatabaseMetaData.cxx b/connectivity/source/drivers/mozab/MDatabaseMetaData.cxx deleted file mode 100644 index 6a0b27ba069e..000000000000 --- a/connectivity/source/drivers/mozab/MDatabaseMetaData.cxx +++ /dev/null @@ -1,1019 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "MDatabaseMetaData.hxx" -#include "FDatabaseMetaDataResultSet.hxx" -#include <com/sun/star/sdbc/DataType.hpp> -#include <com/sun/star/sdbc/ResultSetType.hpp> -#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> -#include <com/sun/star/sdbc/TransactionIsolation.hpp> -#include <connectivity/dbexception.hxx> -#include <connectivity/FValue.hxx> -#include <com/sun/star/sdbc/ColumnValue.hpp> -#include <com/sun/star/sdbc/ColumnSearch.hpp> -#include "resource/common_res.hrc" -#include <vector> - -#if OSL_DEBUG_LEVEL > 0 -# define OUtoCStr( x ) ( OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr()) -#else /* OSL_DEBUG_LEVEL */ -# define OUtoCStr( x ) ("dummy") -#endif /* OSL_DEBUG_LEVEL */ - -using namespace connectivity::mozab; -using namespace connectivity; -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::beans; -using namespace com::sun::star::sdbc; -using namespace com::sun::star::sdbcx; - - -namespace connectivity -{ - namespace mozab - { - static sal_Int32 const s_nCOLUMN_SIZE = 256; - static sal_Int32 const s_nDECIMAL_DIGITS = 0; - static sal_Int32 const s_nNULLABLE = 1; - static sal_Int32 const s_nCHAR_OCTET_LENGTH = 65535; - } -} - - -ODatabaseMetaData::ODatabaseMetaData(OConnection* _pCon) - : ::connectivity::ODatabaseMetaDataBase(_pCon,_pCon->getConnectionInfo()) - ,m_pConnection(_pCon) -{ - OSL_ENSURE(m_pConnection,"ODatabaseMetaData::ODatabaseMetaData: No connection set!"); - m_pDbMetaDataHelper = new MDatabaseMetaDataHelper(); -} - -ODatabaseMetaData::~ODatabaseMetaData() -{ - delete m_pDbMetaDataHelper; -} - - -ODatabaseMetaDataResultSet::ORows& SAL_CALL ODatabaseMetaData::getColumnRows( - const OUString& tableNamePattern, - const OUString& columnNamePattern ) throw(SQLException) -{ - static ODatabaseMetaDataResultSet::ORows aRows; - ODatabaseMetaDataResultSet::ORow aRow(19); - aRows.clear(); - - ::osl::MutexGuard aGuard( m_aMutex ); - - ::std::vector< OUString > tables; - ::std::vector< OUString > types; - if ( !m_pDbMetaDataHelper->getTableStrings( m_pConnection, tables, types) ) { - getOwnConnection()->throwSQLException( m_pDbMetaDataHelper->getError(), *this ); - } - - // **************************************************** - // Some entries in a row never change, so set them now - // **************************************************** - - // Catalog - aRow[1] = new ORowSetValueDecorator(OUString("")); - // Schema - aRow[2] = new ORowSetValueDecorator(OUString("")); - // DATA_TYPE - aRow[5] = new ORowSetValueDecorator(static_cast<sal_Int16>(DataType::VARCHAR)); - // TYPE_NAME, not used - aRow[6] = new ORowSetValueDecorator(OUString("VARCHAR")); - // COLUMN_SIZE - aRow[7] = new ORowSetValueDecorator(s_nCOLUMN_SIZE); - // BUFFER_LENGTH, not used - aRow[8] = ODatabaseMetaDataResultSet::getEmptyValue(); - // DECIMAL_DIGITS. - aRow[9] = new ORowSetValueDecorator(s_nDECIMAL_DIGITS); - // NUM_PREC_RADIX - aRow[10] = new ORowSetValueDecorator((sal_Int32)10); - // NULLABLE - aRow[11] = new ORowSetValueDecorator(s_nNULLABLE); - // REMARKS - aRow[12] = ODatabaseMetaDataResultSet::getEmptyValue(); - // COULUMN_DEF, not used - aRow[13] = ODatabaseMetaDataResultSet::getEmptyValue(); - // SQL_DATA_TYPE, not used - aRow[14] = ODatabaseMetaDataResultSet::getEmptyValue(); - // SQL_DATETIME_SUB, not used - aRow[15] = ODatabaseMetaDataResultSet::getEmptyValue(); - // CHAR_OCTET_LENGTH, refer to [5] - aRow[16] = new ORowSetValueDecorator(s_nCHAR_OCTET_LENGTH); - // IS_NULLABLE - aRow[18] = new ORowSetValueDecorator(OUString("YES")); - - const OColumnAlias& colNames = m_pConnection->getColumnAlias(); - - // Iterate over all tables - for(size_t j = 0; j < tables.size(); j++ ) { - if(match(tableNamePattern, tables[j],'\0')) { - // TABLE_NAME - aRow[3] = new ORowSetValueDecorator( tables[j] ); - - OSL_TRACE( "\t\tTableName = %s;",OUtoCStr( tables[j] )); - - // Iterate over all collumns in the table. - for ( OColumnAlias::AliasMap::const_iterator compare = colNames.begin(); - compare != colNames.end(); - ++compare - ) - { - if ( match( columnNamePattern, compare->first, '\0' ) ) - { - OSL_TRACE( "\t\t\tColumnName = %s;", OUtoCStr( compare->first ) ); - // COLUMN_NAME - aRow[4] = new ORowSetValueDecorator( compare->first ); - // ORDINAL_POSITION - aRow[17] = new ORowSetValueDecorator( static_cast< sal_Int32 >( compare->second.columnPosition ) + 1 ); - aRows.push_back(aRow); - } - } - } - } - return aRows; -} - -OUString ODatabaseMetaData::impl_getCatalogSeparator_throw( ) -{ - return OUString(); -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException) -{ - sal_Int32 nValue = 65535; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException) -{ - sal_Int32 nValue = 254; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException) -{ - sal_Int32 nValue = 20; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 ODatabaseMetaData::impl_getMaxStatements_throw( ) -{ - return 0; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 ODatabaseMetaData::impl_getMaxTablesInSelect_throw( ) -{ - // We only support a single table - return 1; -} - - -sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -bool ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -bool ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( ) -{ - return false; -} - -bool ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( ) -{ - return false; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException) -{ - OUString aVal; - return aVal; -} - -OUString ODatabaseMetaData::impl_getIdentifierQuoteString_throw( ) -{ - // normally this is " - return OUString("\""); -} - -OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException) -{ - OUString aVal; - return aVal; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException) -{ - return sal_True; -} - -bool ODatabaseMetaData::impl_isCatalogAtStart_throw( ) -{ - return true; -} - -sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException) -{ - return sal_True; -} - -sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException) -{ - return sal_True; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException) -{ - //We support create table - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 /*level*/ ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -bool ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException) -{ - return sal_True; // should be supported at least -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -bool ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( ) -{ - return false; -} - -bool ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -bool ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException) -{ - return 0;// 0 means no limit -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException) -{ - // We allow you to select from any table. - return sal_True; -} - -sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException) -{ - //we support insert/update/delete now - //But we have to set this to return sal_True otherwise the UI will add create "table/edit table" - //entry to the popup menu. We should avoid them. - return sal_True; -} - -sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException) -{ - // Support added for this. - return sal_True; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 /*fromType*/, sal_Int32 /*toType*/ ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException) -{ - return sal_True; -} - -bool ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( ) -{ - // Any case may be used - return true; -} - -sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException) -{ - return sal_True; -} - -sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException) -{ - return sal_True; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -OUString SAL_CALL ODatabaseMetaData::getURL( ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - return m_pConnection->getURL(); -} - -OUString SAL_CALL ODatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException) -{ - OUString aValue; - return aValue; -} - -OUString SAL_CALL ODatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException) -{ - OUString aValue; - return aValue; -} - -OUString SAL_CALL ODatabaseMetaData::getDriverVersion() throw(SQLException, RuntimeException) -{ - return OUString( "1" ); -} - -OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException) -{ - return OUString( "0" ); -} - -OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException) -{ - OUString aValue; - return aValue; -} - -OUString SAL_CALL ODatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException) -{ - OUString aValue; - return aValue; -} - -OUString SAL_CALL ODatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException) -{ - OUString aValue; - return aValue; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException) -{ - return 1; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException) -{ - return TransactionIsolation::NONE; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException) -{ - return 0; -} - -OUString SAL_CALL ODatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException) -{ - OUString aValue; - return aValue; -} - -OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException) -{ - OUString aValue; - return aValue; -} - -OUString SAL_CALL ODatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException) -{ - return OUString(); -} - -OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException) -{ - return OUString(); -} - -OUString SAL_CALL ODatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException) -{ - return OUString(); -} - -OUString SAL_CALL ODatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException) -{ - return OUString(); -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException) -{ - return sal_True; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 /*setType*/, sal_Int32 /*concurrency*/ ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException) -{ - return sal_True; -} - -sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException) -{ - return sal_True; -} - -sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException) -{ - return sal_True; -} - -sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException) -{ - return sal_True; -} - -sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException) -{ - return sal_True; -} - -sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException) -{ - return sal_True; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -// here follow all methods which return a resultset -// the first methods is an example implementation how to use this resultset -// of course you could implement it on your and you should do this because -// the general way is more memory expensive - -Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException) -{ - // there exists no possibility to get table types so we have to check - static OUString sTableTypes[] = - { - OUString("TABLE"), - OUString("VIEW") - // Currently we only support a 'TABLE' and 'VIEW' nothing more complex - // - // OUString("SYSTEM TABLE"), - // OUString("GLOBAL TEMPORARY"), - // OUString("LOCAL TEMPORARY"), - // OUString("ALIAS"), - // OUString("SYNONYM") - }; - ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes); - Reference< XResultSet > xRef = pResult; - - // here we fill the rows which should be visible when ask for data from the resultset returned here - const sal_Int32 nSize = sizeof(sTableTypes) / sizeof(OUString); - ODatabaseMetaDataResultSet::ORows aRows; - for(sal_Int32 i=0;i < nSize;++i) - { - ODatabaseMetaDataResultSet::ORow aRow; - aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(new ORowSetValueDecorator(sTableTypes[i])); - // bound row - aRows.push_back(aRow); - } - // here we set the rows at the resultset - pResult->setRows(aRows); - return xRef; -} - -Reference< XResultSet > ODatabaseMetaData::impl_getTypeInfo_throw( ) -{ - // this returns an empty resultset where the column-names are already set - // in special the metadata of the resultset already returns the right columns - ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo); - Reference< XResultSet > xResultSet = pResultSet; - static ODatabaseMetaDataResultSet::ORows aRows; - - if(aRows.empty()) - { - ODatabaseMetaDataResultSet::ORow aRow; - aRow.reserve(19); - aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(new ORowSetValueDecorator(OUString("VARCHAR"))); - aRow.push_back(new ORowSetValueDecorator(DataType::VARCHAR)); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)s_nCHAR_OCTET_LENGTH)); - aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); - aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); - aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - // aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE)); - aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); - aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::CHAR)); - aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); - aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); - aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); - aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); - aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); - aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)10)); - - aRows.push_back(aRow); - - } - pResultSet->setRows(aRows); - return xResultSet; -} - -Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns( - const Any& /*catalog*/, const OUString& /*schemaPattern*/, const OUString& tableNamePattern, - const OUString& columnNamePattern ) throw(SQLException, RuntimeException) -{ - // this returns an empty resultset where the column-names are already set - // in special the metadata of the resultset already returns the right columns - ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eColumns); - Reference< XResultSet > xResultSet = pResultSet; - pResultSet->setRows( getColumnRows( tableNamePattern, columnNamePattern )); - return xResultSet; -} - -Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables( - const Any& /*catalog*/, const OUString& /*schemaPattern*/, - const OUString& tableNamePattern, const Sequence< OUString >& types ) throw(SQLException, RuntimeException) -{ - // this returns an empty resultset where the column-names are already set - // in special the metadata of the resultset already returns the right columns - ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables); - Reference< XResultSet > xResultSet = pResultSet; - - // ODatabaseMetaDataResultSet::ORows aRows; - // aRows = m_pDbMetaDataHelper->getTables( m_pConnection, tableNamePattern ); - // pResultSet->setRows( aRows ); - ODatabaseMetaDataResultSet::ORows _rRows; - if ( !m_pDbMetaDataHelper->getTables( m_pConnection, tableNamePattern, types,_rRows ) ) { - getOwnConnection()->throwSQLException( m_pDbMetaDataHelper->getError(), *this ); - } - pResultSet->setRows( _rRows ); - - return xResultSet; -} - -Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges( - const Any& /*catalog*/, const OUString& /*schemaPattern*/, const OUString& tableNamePattern ) throw(SQLException, RuntimeException) -{ - ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTablePrivileges); - - Reference< XResultSet > xRef = pResult; - - ::std::vector< OUString > tables; - ::std::vector< OUString > types; - if ( !m_pDbMetaDataHelper->getTableStrings( m_pConnection, tables, types ) ) - getOwnConnection()->throwSQLException( m_pDbMetaDataHelper->getError(), *this ); - - ::connectivity::ODatabaseMetaDataResultSet::ORows aRows; - ::connectivity::ODatabaseMetaDataResultSet::ORow aRow(8); - aRows.reserve(8); - aRow[0] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[1] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[3] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[4] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[5] = new ::connectivity::ORowSetValueDecorator(getUserName()); - aRow[7] = new ::connectivity::ORowSetValueDecorator(OUString("NO")); - - - // Iterate over all tables - for(size_t j = 0; j < tables.size(); j++ ) { - if(match(tableNamePattern, tables[j],'\0')) - { - // TABLE_NAME - aRow[2] = new ORowSetValueDecorator( tables[j] ); - - OSL_TRACE( "\t\tTableName = %s;",OUtoCStr( tables[j] )); - - aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getSelectValue(); - aRows.push_back(aRow); - aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getInsertValue(); - aRows.push_back(aRow); - aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getDeleteValue(); - aRows.push_back(aRow); - aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getUpdateValue(); - aRows.push_back(aRow); - aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getCreateValue(); - aRows.push_back(aRow); - aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getReadValue(); - aRows.push_back(aRow); - aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getAlterValue(); - aRows.push_back(aRow); - aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getDropValue(); - aRows.push_back(aRow); - } - } - pResult->setRows(aRows); - return xRef; - -} - -Reference< XResultSet > SAL_CALL ODatabaseMetaData::getUDTs( const Any& /*catalog*/, const OUString& /*schemaPattern*/, const OUString& /*typeNamePattern*/, const Sequence< sal_Int32 >& /*types*/ ) throw(SQLException, RuntimeException) -{ - return NULL; -} - - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MDatabaseMetaData.hxx b/connectivity/source/drivers/mozab/MDatabaseMetaData.hxx deleted file mode 100644 index 4c9410517bf8..000000000000 --- a/connectivity/source/drivers/mozab/MDatabaseMetaData.hxx +++ /dev/null @@ -1,200 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MDATABASEMETADATA_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MDATABASEMETADATA_HXX - -#include "MConnection.hxx" -#include "mozillasrc/MDatabaseMetaDataHelper.hxx" -#include "TDatabaseMetaDataBase.hxx" - -namespace connectivity -{ - namespace mozab - { - - //************ Class: ODatabaseMetaData - - - class ODatabaseMetaData : public ODatabaseMetaDataBase - { - OConnection* m_pConnection; - MDatabaseMetaDataHelper* m_pDbMetaDataHelper; - - ODatabaseMetaDataResultSet::ORows& SAL_CALL getColumnRows( const OUString& tableNamePattern, const OUString& columnNamePattern ) throw( ::com::sun::star::sdbc::SQLException ); - - protected: - virtual ~ODatabaseMetaData(); - public: - - inline OConnection* getOwnConnection() const { return m_pConnection; } - - explicit ODatabaseMetaData(OConnection* _pCon); - - private: - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > impl_getTypeInfo_throw(); - // cached database information - virtual OUString impl_getIdentifierQuoteString_throw( ); - virtual bool impl_isCatalogAtStart_throw( ); - virtual OUString impl_getCatalogSeparator_throw( ); - virtual bool impl_supportsCatalogsInTableDefinitions_throw( ); - virtual bool impl_supportsSchemasInTableDefinitions_throw( ) ; - virtual bool impl_supportsCatalogsInDataManipulation_throw( ); - virtual bool impl_supportsSchemasInDataManipulation_throw( ) ; - virtual bool impl_supportsMixedCaseQuotedIdentifiers_throw( ) ; - virtual bool impl_supportsAlterTableWithAddColumn_throw( ); - virtual bool impl_supportsAlterTableWithDropColumn_throw( ); - virtual sal_Int32 impl_getMaxStatements_throw( ); - virtual sal_Int32 impl_getMaxTablesInSelect_throw( ); - virtual bool impl_storesMixedCaseQuotedIdentifiers_throw( ); - - // as I mentioned before this interface is really BIG - // XDatabaseMetaData - virtual sal_Bool SAL_CALL allProceduresAreCallable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL allTablesAreSelectable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getURL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getUserName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL nullsAreSortedHigh( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL nullsAreSortedLow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL nullsAreSortedAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL nullsAreSortedAtEnd( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getDatabaseProductName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getDatabaseProductVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getDriverName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getDriverVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getDriverMajorVersion( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getDriverMinorVersion( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL usesLocalFiles( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL usesLocalFilePerTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL storesUpperCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL storesLowerCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL storesMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL storesUpperCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL storesLowerCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getSQLKeywords( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getNumericFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getStringFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getSystemFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getTimeDateFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getSearchStringEscape( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getExtraNameCharacters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsColumnAliasing( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL nullPlusNonNullIsNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsTypeConversion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsDifferentTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsExpressionsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsOrderByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsGroupByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsGroupByBeyondSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsLikeEscapeClause( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsMultipleResultSets( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsMultipleTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsNonNullableColumns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsMinimumSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsCoreSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsExtendedSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsANSI92EntryLevelSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsANSI92IntermediateSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsANSI92FullSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsIntegrityEnhancementFacility( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsFullOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsLimitedOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getSchemaTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getProcedureTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getCatalogTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsSchemasInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsSchemasInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsSchemasInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsCatalogsInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsCatalogsInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsCatalogsInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsPositionedDelete( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsPositionedUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsSelectForUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsStoredProcedures( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsSubqueriesInComparisons( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsSubqueriesInExists( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsSubqueriesInIns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsSubqueriesInQuantifieds( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsCorrelatedSubqueries( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsUnion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsUnionAll( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getMaxBinaryLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getMaxCharLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getMaxColumnNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getMaxColumnsInGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getMaxColumnsInIndex( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getMaxColumnsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getMaxColumnsInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getMaxColumnsInTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getMaxConnections( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getMaxCursorNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getMaxIndexLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getMaxSchemaNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getMaxProcedureNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getMaxCatalogNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getMaxRowSize( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL doesMaxRowSizeIncludeBlobs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getMaxStatementLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getMaxTableNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getMaxUserNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getDefaultTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsTransactionIsolationLevel( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsDataDefinitionAndDataManipulationTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsDataManipulationTransactionsOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL dataDefinitionCausesTransactionCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL dataDefinitionIgnoredInTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTables( const ::com::sun::star::uno::Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern, const ::com::sun::star::uno::Sequence< OUString >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTableTypes( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTablePrivileges( const ::com::sun::star::uno::Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumns( const ::com::sun::star::uno::Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern, const OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - - virtual sal_Bool SAL_CALL supportsResultSetType( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL ownUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL ownDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL ownInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL othersUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL othersDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL othersInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL updatesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL deletesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL insertsAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsBatchUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getUDTs( const ::com::sun::star::uno::Any& catalog, const OUString& schemaPattern, const OUString& typeNamePattern, const ::com::sun::star::uno::Sequence< sal_Int32 >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MDATABASEMETADATA_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MDriver.cxx b/connectivity/source/drivers/mozab/MDriver.cxx deleted file mode 100644 index 5158191ed8f0..000000000000 --- a/connectivity/source/drivers/mozab/MDriver.cxx +++ /dev/null @@ -1,319 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <sal/macros.h> -#include "MDriver.hxx" -#include "MConnection.hxx" -#include <connectivity/dbexception.hxx> -#include <cppuhelper/supportsservice.hxx> -#include "resource/mozab_res.hrc" -#include "resource/common_res.hrc" - -#include <tools/solar.h> -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::beans; -using namespace com::sun::star::sdbc; -using namespace connectivity::mozab; - -namespace connectivity -{ - namespace mozab - { - - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL MozabDriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception ) - { - return *(new MozabDriver( _rxFactory )); - } - } -} - -MozabDriver::MozabDriver( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) - : ODriver_BASE(m_aMutex), m_xMSFactory( _rxFactory ) - ,m_hModule(NULL) - ,m_pCreationFunc(NULL) -{ -} - -MozabDriver::~MozabDriver() -{ -} - -void MozabDriver::disposing() -{ - ::osl::MutexGuard aGuard(m_aMutex); - - // when driver will be destroied so all our connections have to be destroied as well - for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i) - { - Reference< XComponent > xComp(i->get(), UNO_QUERY); - if (xComp.is()) - xComp->dispose(); - } - m_xConnections.clear(); - connectivity::OWeakRefArray().swap(m_xConnections); // this really clears - - ODriver_BASE::disposing(); - if(m_hModule) - { - m_pCreationFunc = NULL; - osl_unloadModule(m_hModule); - m_hModule = NULL; - } -} - -// static ServiceInfo - -OUString MozabDriver::getImplementationName_Static( ) throw(RuntimeException) -{ - return OUString(MOZAB_DRIVER_IMPL_NAME); - // this name is referenced in the configuration and in the mozab.xml - // Please take care when changing it. -} - -Sequence< OUString > MozabDriver::getSupportedServiceNames_Static( ) throw (RuntimeException) -{ - // which service is supported - // for more information @see com.sun.star.sdbc.Driver - Sequence< OUString > aSNS( 1 ); - aSNS[0] = "com.sun.star.sdbc.Driver"; - return aSNS; -} - - -OUString SAL_CALL MozabDriver::getImplementationName( ) throw(RuntimeException) -{ - return getImplementationName_Static(); -} - -sal_Bool SAL_CALL MozabDriver::supportsService( const OUString& _rServiceName ) throw(RuntimeException) -{ - return cppu::supportsService(this, _rServiceName); -} - - -Sequence< OUString > SAL_CALL MozabDriver::getSupportedServiceNames( ) throw(RuntimeException) -{ - return getSupportedServiceNames_Static(); -} - - -Reference< XConnection > SAL_CALL MozabDriver::connect( const OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException) -{ - if ( !ensureInit() ) - return NULL; - - if ( ! acceptsURL( url ) ) - return NULL; - // create a new connection with the given properties and append it to our vector - Reference< XConnection > xCon; - if (m_pCreationFunc) - { - ::osl::MutexGuard aGuard(m_aMutex); - //We must make sure we create an com.sun.star.mozilla.MozillaBootstrap before call any mozilla codes - Reference<XInterface> xInstance = m_xMSFactory->createInstance("com.sun.star.mozilla.MozillaBootstrap"); - OSL_ENSURE( xInstance.is(), "failed to create instance" ); - - OConnection* pCon = reinterpret_cast<OConnection*>((*m_pCreationFunc)(this)); - xCon = pCon; // important here because otherwise the connection could be deleted inside (refcount goes -> 0) - pCon->construct(url,info); // late constructor call which can throw exception and allows a correct dtor call when so - m_xConnections.push_back(WeakReferenceHelper(*pCon)); - - } - else - { - ::connectivity::SharedResources aResources; - const OUString sError( aResources.getResourceStringWithSubstitution( - STR_COULD_NOT_LOAD_LIB, - "$libname$", OUString( SVLIBRARY( "mozabdrv" ) ) - ) ); - - ::dbtools::throwGenericSQLException(sError,*this); - } - - return xCon; -} - -sal_Bool SAL_CALL MozabDriver::acceptsURL( const OUString& url ) - throw(SQLException, RuntimeException) -{ - if ( !ensureInit() ) - return sal_False; - - // here we have to look if we support this url format - return impl_classifyURL(url) != Unknown; -} - -Sequence< DriverPropertyInfo > SAL_CALL MozabDriver::getPropertyInfo( const OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException) -{ - if ( !ensureInit() ) - return Sequence< DriverPropertyInfo >(); - - if ( acceptsURL(url) ) - { - if ( impl_classifyURL(url) != LDAP ) - return Sequence< DriverPropertyInfo >(); - - ::std::vector< DriverPropertyInfo > aDriverInfo; - aDriverInfo.push_back(DriverPropertyInfo( - OUString("BaseDN") - ,OUString("Base DN.") - ,sal_False - ,OUString() - ,Sequence< OUString >()) - ); - aDriverInfo.push_back(DriverPropertyInfo( - OUString("MaxRowCount") - ,OUString("Records (max.)") - ,sal_False - ,OUString("100") - ,Sequence< OUString >()) - ); - return Sequence< DriverPropertyInfo >(&aDriverInfo[0],aDriverInfo.size()); - } - ::connectivity::SharedResources aResources; - const OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR); - ::dbtools::throwGenericSQLException(sMessage ,*this); - // if you have something special to say return it here :-) - return Sequence< DriverPropertyInfo >(); -} - -sal_Int32 SAL_CALL MozabDriver::getMajorVersion( ) throw(RuntimeException) -{ - return 1; // depends on you -} - -sal_Int32 SAL_CALL MozabDriver::getMinorVersion( ) throw(RuntimeException) -{ - return 0; // depends on you -} - -EDriverType MozabDriver::impl_classifyURL( const OUString& url ) -{ - // Skip 'sdbc:mozab: part of URL - - sal_Int32 nLen = url.indexOf(':'); - nLen = url.indexOf(':',nLen+1); - OUString aAddrbookURI(url.copy(nLen+1)); - // Get Scheme - nLen = aAddrbookURI.indexOf(':'); - OUString aAddrbookScheme; - if ( nLen == -1 ) - { - // There isn't any subschema: - but could be just subschema - if ( !aAddrbookURI.isEmpty() ) - aAddrbookScheme= aAddrbookURI; - else if(url == "sdbc:address:" ) - return Unknown; // TODO check - else - return Unknown; - } - else - aAddrbookScheme = aAddrbookURI.copy(0, nLen); - - struct __scheme_map - { - EDriverType eType; - const sal_Char* pScheme; - } aSchemeMap[] = - { -#if defined(WNT) - { Outlook, "outlook" }, - { OutlookExpress, "outlookexp" }, -#endif - { Mozilla, "mozilla" }, - { ThunderBird, "thunderbird" }, - { LDAP, "ldap" } - }; - - for ( size_t i=0; i < sizeof( aSchemeMap ) / sizeof( aSchemeMap[0] ); ++i ) - { - if ( aAddrbookScheme.equalsAscii( aSchemeMap[i].pScheme ) ) - return aSchemeMap[i].eType; - } - - return Unknown; -} - - -namespace -{ - template< typename FUNCTION > - void lcl_getFunctionFromModuleOrUnload( oslModule& _rModule, const sal_Char* _pAsciiSymbolName, FUNCTION& _rFunction ) - { - _rFunction = NULL; - if ( _rModule ) - { - const OUString sSymbolName = OUString::createFromAscii( _pAsciiSymbolName ); - _rFunction = (FUNCTION)( osl_getFunctionSymbol( _rModule, sSymbolName.pData ) ); - - if ( !_rFunction ) - { // did not find the symbol - OUStringBuffer aBuf; - aBuf.append( "lcl_getFunctionFromModuleOrUnload: could not find the symbol " ); - aBuf.append( sSymbolName ); - OSL_FAIL( aBuf.makeStringAndClear().getStr() ); - osl_unloadModule( _rModule ); - _rModule = NULL; - } - } - } -} - - -extern "C" { static void SAL_CALL thisModule() {} } - -bool MozabDriver::ensureInit() -{ - if ( m_hModule ) - return true; - - OSL_ENSURE(NULL == m_pCreationFunc, "MozabDriver::ensureInit: inconsistence: already have a factory function!"); - - const OUString sModuleName(SVLIBRARY( "mozabdrv" )); - - // load the mozabdrv library - m_hModule = osl_loadModuleRelative(&thisModule, sModuleName.pData, 0); - OSL_ENSURE(NULL != m_hModule, "MozabDriver::ensureInit: could not load the mozabdrv library!"); - if ( !m_hModule ) - return false; - - OSetMozabServiceFactory pSetFactoryFunc( NULL ); - - lcl_getFunctionFromModuleOrUnload( m_hModule, "setMozabServiceFactory", pSetFactoryFunc ); - lcl_getFunctionFromModuleOrUnload( m_hModule, "OMozabConnection_CreateInstance", m_pCreationFunc ); - - if ( !m_hModule ) - // one of the symbols did not exist - return false; - - if ( m_xMSFactory.is() ) - { - // for purpose of transfer safety, the interface needs to be acquired once - // (will be release by the callee) - m_xMSFactory->acquire(); - ( *pSetFactoryFunc )( m_xMSFactory.get() ); - } - - return true; -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MDriver.hxx b/connectivity/source/drivers/mozab/MDriver.hxx deleted file mode 100644 index 5b3d89f8fe9b..000000000000 --- a/connectivity/source/drivers/mozab/MDriver.hxx +++ /dev/null @@ -1,106 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MDRIVER_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MDRIVER_HXX - -#include <com/sun/star/sdbc/XDriver.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <cppuhelper/compbase.hxx> -#include <connectivity/CommonTools.hxx> -#include <osl/module.h> - - -#define MOZAB_DRIVER_IMPL_NAME "com.sun.star.comp.sdbc.MozabDriver" - -namespace connectivity -{ - namespace mozab - { - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL MozabDriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception ); - - typedef void* (SAL_CALL * OMozabConnection_CreateInstanceFunction)(void* _pDriver ); - typedef void (SAL_CALL * OSetMozabServiceFactory)( void* _pFactory ); - typedef const void* (SAL_CALL * OGetSdbcScheme_Function)( short ); - - - typedef ::cppu::WeakComponentImplHelper< ::com::sun::star::sdbc::XDriver, - ::com::sun::star::lang::XServiceInfo > ODriver_BASE; - - enum EDriverType - { - Mozilla, - ThunderBird, - LDAP, - Outlook, - OutlookExpress, - Unknown - }; - - class MozabDriver : public ODriver_BASE - { - protected: - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xMSFactory; - - ::osl::Mutex m_aMutex; // mutex is need to control member access - connectivity::OWeakRefArray m_xConnections; // vector containing a list - // of all the Connection objects - // for this Driver - oslModule m_hModule; - OMozabConnection_CreateInstanceFunction m_pCreationFunc; - OGetSdbcScheme_Function m_pSchemeFunction; - - bool ensureInit(); - virtual ~MozabDriver(); - public: - - explicit MozabDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory); - - // OComponentHelper - virtual void SAL_CALL disposing(); - // XInterface - static OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException); - static ::com::sun::star::uno::Sequence< OUString > getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException); - - // XServiceInfo - virtual OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); - - // XDriver - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect( const OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL acceptsURL( const OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getMajorVersion( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getMinorVersion( ) throw(::com::sun::star::uno::RuntimeException); - - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > - & getMSFactory() const { return m_xMSFactory; } - - private: - EDriverType impl_classifyURL( const OUString& url ); - }; - } - -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MDRIVER_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MExtConfigAccess.hxx b/connectivity/source/drivers/mozab/MExtConfigAccess.hxx deleted file mode 100644 index 6eed9519a35e..000000000000 --- a/connectivity/source/drivers/mozab/MExtConfigAccess.hxx +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MEXTCONFIGACCESS_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MEXTCONFIGACCESS_HXX - -// This is the extended version (for use on the SO side of the driver) of MConfigAccess -// (which is for use on the mozilla side only) - -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> - -namespace connectivity -{ - namespace mozab - { - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > - createDriverConfigNode( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB ); - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MEXTCONFIGACCESS_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MPreparedStatement.cxx b/connectivity/source/drivers/mozab/MPreparedStatement.cxx deleted file mode 100644 index c4a8abfc5274..000000000000 --- a/connectivity/source/drivers/mozab/MPreparedStatement.cxx +++ /dev/null @@ -1,526 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <osl/diagnose.h> -#include <connectivity/sdbcx/VColumn.hxx> -#include "MPreparedStatement.hxx" -#include <com/sun/star/sdbc/DataType.hpp> -#include "MResultSetMetaData.hxx" -#include <cppuhelper/typeprovider.hxx> -#include <comphelper/sequence.hxx> -#include <com/sun/star/lang/DisposedException.hpp> -#include <connectivity/dbexception.hxx> -#include <connectivity/dbtools.hxx> -#include <comphelper/types.hxx> -#include <com/sun/star/sdbc/ColumnValue.hpp> - -#if OSL_DEBUG_LEVEL > 0 -# define OUtoCStr( x ) ( OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr()) -#else /* OSL_DEBUG_LEVEL */ -# define OUtoCStr( x ) ("dummy") -#endif /* OSL_DEBUG_LEVEL */ - -using namespace ::comphelper; -using namespace connectivity; -using namespace connectivity::mozab; -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::beans; -using namespace com::sun::star::sdbc; -using namespace com::sun::star::sdbcx; -using namespace com::sun::star::container; -using namespace com::sun::star::io; -using namespace com::sun::star::util; - -IMPLEMENT_SERVICE_INFO(OPreparedStatement,"com.sun.star.sdbcx.mozab.PreparedStatement","com.sun.star.sdbc.PreparedStatement"); - - -OPreparedStatement::OPreparedStatement( OConnection* _pConnection,const OUString& sql) - :OCommonStatement(_pConnection) - ,m_nNumParams(0) - ,m_sSqlStatement(sql) - ,m_bPrepared(sal_False) - ,m_pResultSet() -{ -} - -OPreparedStatement::~OPreparedStatement() -{ -} - -void OPreparedStatement::lateInit() -{ - if ( eSelect != parseSql( m_sSqlStatement ) ) - throw SQLException(); -} - -void SAL_CALL OPreparedStatement::disposing() -{ - ::osl::MutexGuard aGuard(m_aMutex); - - OCommonStatement::disposing(); - - m_xMetaData.clear(); - if(m_aParameterRow.is()) - { - m_aParameterRow->get().clear(); - m_aParameterRow = NULL; - } - m_xParamColumns = NULL; -} - - -OCommonStatement::StatementType OPreparedStatement::parseSql( const OUString& sql , sal_Bool bAdjusted ) - throw ( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException ) -{ - StatementType eStatementType = OCommonStatement::parseSql( sql, bAdjusted ); - if ( eStatementType != eSelect ) - return eStatementType; - - m_xParamColumns = new OSQLColumns(); - - // describe all parameters need for the resultset - describeParameter(); - - Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY); - OResultSet::setBoundedColumns( m_aRow, m_xParamColumns, xNames, sal_False, m_xDBMetaData, m_aColMapping ); - - return eStatementType; -} - - -void OPreparedStatement::initializeResultSet( OResultSet* _pResult ) -{ - OCommonStatement::initializeResultSet( _pResult ); - _pResult->setParameterColumns( m_xParamColumns ); - _pResult->setParameterRow( m_aParameterRow ); -} - - -void OPreparedStatement::clearCachedResultSet() -{ - OCommonStatement::clearCachedResultSet(); - m_pResultSet.clear(); - m_xMetaData.clear(); -} - -void OPreparedStatement::cacheResultSet( const ::rtl::Reference< OResultSet >& _pResult ) -{ - OCommonStatement::cacheResultSet( _pResult ); - OSL_PRECOND( m_pResultSet == NULL, "OPreparedStatement::parseSql: you should call clearCachedResultSet before!" ); - m_pResultSet = _pResult; -} - - -void SAL_CALL OPreparedStatement::acquire() throw() -{ - OCommonStatement::acquire(); -} - -void SAL_CALL OPreparedStatement::release() throw() -{ - OCommonStatement::release(); -} - -Any SAL_CALL OPreparedStatement::queryInterface( const Type & rType ) throw(RuntimeException) -{ - Any aRet = OCommonStatement::queryInterface(rType); - if(!aRet.hasValue()) - aRet = OPreparedStatement_BASE::queryInterface(rType); - return aRet; -} - -::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OPreparedStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException) -{ - return ::comphelper::concatSequences(OPreparedStatement_BASE::getTypes(),OCommonStatement::getTypes()); -} - - -Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData( ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); - - sal_Bool bReadOnly = sal_True; - if ( m_pResultSet.is() ) - bReadOnly = m_pResultSet->determineReadOnly(); - // if we do not have a result set, then we have not been executed, yet. In this case, assuming readonly=true is - // okay, /me thinks. - - if ( !m_xMetaData.is() ) - m_xMetaData = new OResultSetMetaData( m_pSQLIterator->getSelectColumns(), m_pSQLIterator->getTables().begin()->first ,m_pTable,bReadOnly ); - - return m_xMetaData; -} - - -sal_Bool SAL_CALL OPreparedStatement::execute( ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); - - Reference< XResultSet> xResult = executeQuery(); - return xResult.is(); -} - - -sal_Int32 SAL_CALL OPreparedStatement::executeUpdate( ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XStatement::executeUpdate", *this ); - return 0; -} - - -void SAL_CALL OPreparedStatement::setString( sal_Int32 parameterIndex, const OUString& x ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); - - OSL_TRACE("prepStmt::setString( %s )", OUtoCStr( x ) ); - setParameter( parameterIndex, x ); -} - - -Reference< XConnection > SAL_CALL OPreparedStatement::getConnection( ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); - - return (Reference< XConnection >)m_pConnection; -} - - -Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - OSL_TRACE("In: OPreparedStatement::executeQuery" ); - checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); - - // our statement has already been parsed in lateInit, no need to do all this (potentially expensive) - // stuff again. Just execute. - return impl_executeCurrentQuery(); -} - - -void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 /*parameterIndex*/, sal_Bool /*x*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setBoolean", *this ); -} - -void SAL_CALL OPreparedStatement::setByte( sal_Int32 /*parameterIndex*/, sal_Int8 /*x*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setByte", *this ); -} - - -void SAL_CALL OPreparedStatement::setDate( sal_Int32 /*parameterIndex*/, const Date& /*aData*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setDate", *this ); -} - - - -void SAL_CALL OPreparedStatement::setTime( sal_Int32 /*parameterIndex*/, const css::util::Time& /*aVal*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setTime", *this ); -} - - -void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 /*parameterIndex*/, const DateTime& /*aVal*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setTimestamp", *this ); -} - - -void SAL_CALL OPreparedStatement::setDouble( sal_Int32 /*parameterIndex*/, double /*x*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setDouble", *this ); -} - - - -void SAL_CALL OPreparedStatement::setFloat( sal_Int32 /*parameterIndex*/, float /*x*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setFloat", *this ); -} - - -void SAL_CALL OPreparedStatement::setInt( sal_Int32 /*parameterIndex*/, sal_Int32 /*x*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setInt", *this ); -} - - -void SAL_CALL OPreparedStatement::setLong( sal_Int32 /*parameterIndex*/, sal_Int64 /*aVal*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setLong", *this ); -} - - -void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 /*sqlType*/ ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); - - checkAndResizeParameters(parameterIndex); - - (m_aParameterRow->get())[parameterIndex].setNull(); -} - - -void SAL_CALL OPreparedStatement::setClob( sal_Int32 /*parameterIndex*/, const Reference< XClob >& /*x*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setClob", *this ); -} - - -void SAL_CALL OPreparedStatement::setBlob( sal_Int32 /*parameterIndex*/, const Reference< XBlob >& /*x*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setBlob", *this ); -} - - -void SAL_CALL OPreparedStatement::setArray( sal_Int32 /*parameterIndex*/, const Reference< XArray >& /*x*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setArray", *this ); -} - - -void SAL_CALL OPreparedStatement::setRef( sal_Int32 /*parameterIndex*/, const Reference< XRef >& /*x*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setRef", *this ); -} - - -void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 /*parameterIndex*/, const Any& /*x*/, sal_Int32 /*sqlType*/, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setObjectWithInfo", *this ); -} - - -void SAL_CALL OPreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString& /*typeName*/ ) throw(SQLException, RuntimeException) -{ - setNull(parameterIndex,sqlType); -} - - -void SAL_CALL OPreparedStatement::setObject( sal_Int32 parameterIndex, const Any& x ) throw(SQLException, RuntimeException) -{ - ::dbtools::implSetObject(this,parameterIndex,x); -} - - -void SAL_CALL OPreparedStatement::setShort( sal_Int32 /*parameterIndex*/, sal_Int16 /*x*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setShort", *this ); -} - - -void SAL_CALL OPreparedStatement::setBytes( sal_Int32 /*parameterIndex*/, const Sequence< sal_Int8 >& /*x*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setBytes", *this ); -} - - - -void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 /*parameterIndex*/, const Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setCharacterStream", *this ); -} - - -void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 /*parameterIndex*/, const Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setBinaryStream", *this ); -} - - -void SAL_CALL OPreparedStatement::clearParameters( ) throw(SQLException, RuntimeException) -{ -} - -void OPreparedStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception) -{ - switch(nHandle) - { - case PROPERTY_ID_RESULTSETCONCURRENCY: - break; - case PROPERTY_ID_RESULTSETTYPE: - break; - case PROPERTY_ID_FETCHDIRECTION: - break; - case PROPERTY_ID_USEBOOKMARKS: - break; - default: - OCommonStatement::setFastPropertyValue_NoBroadcast(nHandle,rValue); - } -} - - -void OPreparedStatement::checkAndResizeParameters(sal_Int32 parameterIndex) -{ - ::connectivity::checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); - - if ( !m_aParameterRow.is() ) { - m_aParameterRow = new OValueVector(); - m_aParameterRow->get().push_back(sal_Int32(0)); - } - - if ((sal_Int32)(m_aParameterRow->get()).size() <= parameterIndex) - (m_aParameterRow->get()).resize(parameterIndex+1); -} - -void OPreparedStatement::setParameter(sal_Int32 parameterIndex, const -ORowSetValue& x) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkAndResizeParameters(parameterIndex); - - OSL_TRACE("setParameter( %d, '%s')", parameterIndex, OUtoCStr(x) ); - (m_aParameterRow->get())[parameterIndex] = x; -} - - -size_t OPreparedStatement::AddParameter(OSQLParseNode * pParameter, const Reference<XPropertySet>& _xCol) -{ - // Count of the newly added Parameters - size_t nParameter = m_xParamColumns->get().size()+1; - - OSL_ENSURE(SQL_ISRULE(pParameter,parameter),"OResultSet::AddParameter: Argument is not a Parameter"); - OSL_ENSURE(pParameter->count() > 0,"OResultSet: error in parse tree"); - - OUString sParameterName; - - // set up Parameter-Column: - sal_Int32 eType = DataType::VARCHAR; - sal_uInt32 nPrecision = 255; - sal_Int32 nScale = 0; - sal_Int32 nNullable = ColumnValue::NULLABLE; - - if (_xCol.is()) - { - // Type, Precision, Scale ... utilize the selected Columns, - // then this Column will get the value assigned or with this - // Column will the value be compared. - eType = getINT32(_xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))); - nPrecision = getINT32(_xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))); - nScale = getINT32(_xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE))); - nNullable = getINT32(_xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE))); - _xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= sParameterName; - } - - Reference<XPropertySet> xParaColumn = new connectivity::sdbcx::OColumn(sParameterName - ,OUString() - ,OUString() - ,OUString() - ,nNullable - ,nPrecision - ,nScale - ,eType - ,sal_False - ,sal_False - ,sal_False - ,m_pSQLIterator->isCaseSensitive() - ,OUString() - ,OUString() - ,OUString()); - m_xParamColumns->get().push_back(xParaColumn); - return nParameter; -} - -void OPreparedStatement::describeColumn(OSQLParseNode* -_pParameter,OSQLParseNode* _pNode,const OSQLTable& _xTable) -{ - Reference<XPropertySet> xProp; - if(SQL_ISRULE(_pNode,column_ref)) - { - OUString sColumnName,sTableRange; - m_pSQLIterator->getColumnRange(_pNode,sColumnName,sTableRange); - if(!sColumnName.isEmpty()) - { - Reference<XNameAccess> xNameAccess = _xTable->getColumns(); - if(xNameAccess->hasByName(sColumnName)) - xNameAccess->getByName(sColumnName) >>= xProp; - AddParameter(_pParameter,xProp); - } - } - // else - // AddParameter(_pParameter,xProp); -} - -void OPreparedStatement::describeParameter() -{ - ::std::vector< OSQLParseNode*> aParseNodes; - scanParameter(m_pParseTree,aParseNodes); - if(!aParseNodes.empty()) - { - m_xParamColumns = new OSQLColumns(); - const OSQLTables& xTabs = m_pSQLIterator->getTables(); - if(xTabs.size()) - { - OSQLTable xTable = xTabs.begin()->second; - ::std::vector< OSQLParseNode*>::const_iterator aIter = -aParseNodes.begin(); - for (;aIter != aParseNodes.end();++aIter ) - { - describeColumn(*aIter,(*aIter)->getParent()->getChild(0),xTable); - } - } - } -} - - -void OPreparedStatement::scanParameter(OSQLParseNode* pParseNode,::std::vector< OSQLParseNode*>& _rParaNodes) -{ - OSL_ENSURE(pParseNode != NULL,"OResultSet: internal error: invalid ParseNode"); - - // Parameter Name-Row found? - if (SQL_ISRULE(pParseNode,parameter)) - { - OSL_ENSURE(pParseNode->count() >= 1,"OResultSet: Faulty Parse Tree"); - OSL_ENSURE(pParseNode->getChild(0)->getNodeType() == SQL_NODE_PUNCTUATION,"OResultSet: Faulty Parse Tree"); - - _rParaNodes.push_back(pParseNode); - // further search isn't necessary - return; - } - - // Search on in Parse Tree - for (sal_uInt32 i = 0; i < pParseNode->count(); i++) - scanParameter(pParseNode->getChild(i),_rParaNodes); -} - -::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL OPreparedStatement::getResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - return NULL; -} - -sal_Int32 SAL_CALL OPreparedStatement::getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - return 0; -} - -sal_Bool SAL_CALL OPreparedStatement::getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - return sal_False; -} - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MPreparedStatement.hxx b/connectivity/source/drivers/mozab/MPreparedStatement.hxx deleted file mode 100644 index 94d3bc88a6f4..000000000000 --- a/connectivity/source/drivers/mozab/MPreparedStatement.hxx +++ /dev/null @@ -1,157 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MPREPAREDSTATEMENT_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MPREPAREDSTATEMENT_HXX - -#include "MResultSet.hxx" -#include "MStatement.hxx" -#include <com/sun/star/sdbc/XPreparedStatement.hpp> -#include <com/sun/star/sdbc/XParameters.hpp> -#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> -#include <com/sun/star/io/XInputStream.hpp> -#include <com/sun/star/sdbc/XMultipleResults.hpp> -#include <cppuhelper/compbase4.hxx> - -namespace connectivity -{ - namespace mozab - { - - typedef ::cppu::ImplHelper4< ::com::sun::star::sdbc::XPreparedStatement, - ::com::sun::star::sdbc::XParameters, - ::com::sun::star::sdbc::XResultSetMetaDataSupplier, - ::com::sun::star::lang::XServiceInfo> OPreparedStatement_BASE; - - class OPreparedStatement : public OCommonStatement, - public OPreparedStatement_BASE - { - protected: - struct Parameter - { - ::com::sun::star::uno::Any aValue; - sal_Int32 nDataType; - - Parameter(const ::com::sun::star::uno::Any& rValue, - sal_Int32 rDataType) : aValue(rValue),nDataType(rDataType) - { - } - - }; - - ::std::vector< Parameter> m_aParameters; - - // Data attributes - - sal_Int32 m_nNumParams; // Number of parameter markers for the prepared statement - - OUString m_sSqlStatement; - ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xMetaData; - sal_Bool m_bPrepared; - ::rtl::Reference< OResultSet > m_pResultSet; - ::rtl::Reference<connectivity::OSQLColumns> m_xParamColumns; // the parameter columns - OValueRow m_aParameterRow; - - protected: - virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue) - throw (::com::sun::star::uno::Exception); - virtual ~OPreparedStatement(); - - virtual void SAL_CALL disposing(); - - // OCommonStatement overridables - virtual StatementType - parseSql( const OUString& sql , sal_Bool bAdjusted = sal_False) throw ( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException ); - virtual void initializeResultSet( OResultSet* _pResult ); - virtual void clearCachedResultSet(); - virtual void cacheResultSet( const ::rtl::Reference< OResultSet >& _pResult ); - - - void checkAndResizeParameters(sal_Int32 parameterIndex); - void setParameter(sal_Int32 parameterIndex, const ORowSetValue& x); - - size_t AddParameter(connectivity::OSQLParseNode * pParameter, - const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xCol); - void scanParameter(OSQLParseNode* pParseNode,::std::vector< OSQLParseNode*>& _rParaNodes); - void describeColumn(OSQLParseNode* _pParameter,OSQLParseNode* _pNode,const OSQLTable& _xTable); - void describeParameter(); - - public: - DECLARE_SERVICE_INFO(); - // A ctor need for returning the object - OPreparedStatement( OConnection* _pConnection,const OUString& sql); - void lateInit(); - - //XInterface - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL acquire() throw(); - virtual void SAL_CALL release() throw(); - //XTypeProvider - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - - // XPreparedStatement - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL executeUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL execute( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - // XParameters - virtual void SAL_CALL setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString& typeName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setFloat( sal_Int32 parameterIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setDouble( sal_Int32 parameterIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setString( sal_Int32 parameterIndex, const OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setBytes( sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setBinaryStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setCharacterStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setObject( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setObjectWithInfo( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setRef( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setBlob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setClob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setArray( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL clearParameters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - // XResultSetMetaDataSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - // XMultipleResults - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - - public: - using OCommonStatement::executeQuery; - using OCommonStatement::executeUpdate; - using OCommonStatement::execute; - protected: - using OPropertySetHelper::getFastPropertyValue; - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MPREPAREDSTATEMENT_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MResultSet.cxx b/connectivity/source/drivers/mozab/MResultSet.cxx deleted file mode 100644 index 874cbe1de781..000000000000 --- a/connectivity/source/drivers/mozab/MResultSet.cxx +++ /dev/null @@ -1,1966 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <com/sun/star/sdbc/DataType.hpp> -#include <com/sun/star/beans/PropertyAttribute.hpp> -#include <comphelper/property.hxx> -#include <comphelper/sequence.hxx> -#include <cppuhelper/typeprovider.hxx> -#include <cppuhelper/supportsservice.hxx> -#include <comphelper/extract.hxx> -#include <com/sun/star/lang/DisposedException.hpp> -#include <com/sun/star/sdbc/ResultSetType.hpp> -#include <com/sun/star/sdbc/FetchDirection.hpp> -#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> -#include <com/sun/star/sdbcx/CompareBookmark.hpp> -#include <comphelper/types.hxx> -#include <connectivity/dbexception.hxx> -#include <connectivity/dbtools.hxx> - -#include <TSortIndex.hxx> -#include <rtl/string.hxx> -#include <vector> -#include <algorithm> -#include "MResultSet.hxx" -#include "MResultSetMetaData.hxx" -#include "FDatabaseMetaDataResultSet.hxx" -#include "resource/mozab_res.hrc" -#include "resource/common_res.hrc" -#include "sqlbison.hxx" - -#if OSL_DEBUG_LEVEL > 0 -# define OUtoCStr( x ) ( OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr()) -#else /* OSL_DEBUG_LEVEL */ -# define OUtoCStr( x ) ("dummy") -#endif /* OSL_DEBUG_LEVEL */ - -using namespace ::comphelper; -using namespace connectivity; -using namespace connectivity::mozab; -using namespace ::cppu; -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::beans; -using namespace com::sun::star::sdbc; -using namespace com::sun::star::sdbcx; -using namespace com::sun::star::container; -using namespace com::sun::star::io; -using namespace com::sun::star::util; - - -// IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.OResultSet","com.sun.star.sdbc.ResultSet"); -OUString SAL_CALL OResultSet::getImplementationName( ) throw ( RuntimeException) \ -{ - return OUString("com.sun.star.sdbcx.mozab.ResultSet"); -} - - Sequence< OUString > SAL_CALL OResultSet::getSupportedServiceNames( ) throw( RuntimeException) -{ - ::com::sun::star::uno::Sequence< OUString > aSupported(2); - aSupported[0] = "com.sun.star.sdbc.ResultSet"; - aSupported[1] = "com.sun.star.sdbcx.ResultSet"; - return aSupported; -} - -sal_Bool SAL_CALL OResultSet::supportsService( const OUString& _rServiceName ) throw( RuntimeException) -{ - return cppu::supportsService(this, _rServiceName); -} - - -OResultSet::OResultSet(OCommonStatement* pStmt, const std::shared_ptr< connectivity::OSQLParseTreeIterator >& _pSQLIterator ) - : OResultSet_BASE(m_aMutex) - ,OPropertySetHelper(OResultSet_BASE::rBHelper) - ,m_pStatement(pStmt) - ,m_xStatement(*pStmt) - ,m_xMetaData(NULL) - ,m_nRowPos(0) - ,m_nOldRowPos(0) - ,m_nFetchSize(0) - ,m_nResultSetType(ResultSetType::SCROLL_INSENSITIVE) - ,m_nFetchDirection(FetchDirection::FORWARD) - ,m_nResultSetConcurrency(ResultSetConcurrency::UPDATABLE) - ,m_pSQLIterator( _pSQLIterator ) - ,m_pParseTree( _pSQLIterator->getParseTree() ) - ,m_aQuery( pStmt->getOwnConnection()->getColumnAlias() ) - ,m_pTable(NULL) - ,m_CurrentRowCount(0) - ,m_nParamIndex(0) - ,m_bIsAlwaysFalseQuery(sal_False) - ,m_pKeySet(NULL) - ,m_nNewRow(0) - ,m_nUpdatedRow(0) - ,m_RowStates(0) - ,m_bIsReadOnly(-1) -{ - - m_aQuery.setMaxNrOfReturns(pStmt->getOwnConnection()->getMaxResultRecords()); -} - -OResultSet::~OResultSet() -{ -} - - -void OResultSet::disposing() -{ - OPropertySetHelper::disposing(); - - ::osl::MutexGuard aGuard(m_aMutex); - - m_xStatement.clear(); - m_xMetaData.clear(); - m_pParseTree = NULL; - m_xColumns = NULL; - m_xParamColumns = NULL; - m_pKeySet = NULL; - if(m_pTable) - { - m_pTable->release(); - m_pTable = NULL; - } -} - -Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException) -{ - Any aRet = OPropertySetHelper::queryInterface(rType); - if(!aRet.hasValue()) - aRet = OResultSet_BASE::queryInterface(rType); - return aRet; -} - - Sequence< Type > SAL_CALL OResultSet::getTypes( ) throw( RuntimeException) -{ - OTypeCollection aTypes( cppu::UnoType<com::sun::star::beans::XMultiPropertySet>::get(), - cppu::UnoType<com::sun::star::beans::XFastPropertySet>::get(), - cppu::UnoType<com::sun::star::beans::XPropertySet>::get()); - - return ::comphelper::concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes()); -} - -void OResultSet::methodEntry() -{ - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if ( !m_pTable ) - { - OSL_FAIL( "OResultSet::methodEntry: looks like we're disposed, but how is this possible?" ); - throw DisposedException( OUString(), *this ); - } -} - - -sal_Int32 SAL_CALL OResultSet::findColumn( const OUString& columnName ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - - // find the first column with the name columnName - Reference< XResultSetMetaData > xMeta = getMetaData(); - sal_Int32 nLen = xMeta->getColumnCount(); - sal_Int32 i = 1; - for(;i<=nLen;++i) - { - if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) : - columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i))) - return i; - } - - ::dbtools::throwInvalidColumnException( columnName, *this ); - assert(false); - return 0; // Never reached -} - -Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) -{ - return NULL; -} - -Reference< XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) -{ - return NULL; -} - - -sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - m_bWasNull = sal_True; - return sal_False; -} - - -sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - return 0; -} - - -Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - return Sequence< sal_Int8 >(); -} - - -Date SAL_CALL OResultSet::getDate( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - return Date(); -} - - -double SAL_CALL OResultSet::getDouble( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - return 0.0; -} - - -float SAL_CALL OResultSet::getFloat( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - return 0; -} - - -sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - return 0; -} - - -sal_Int32 SAL_CALL OResultSet::getRow( ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - - OSL_TRACE("In/Out: OResultSet::getRow, return = %u", m_nRowPos ); - return m_nRowPos; -} - - -sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - return sal_Int64(); -} - - -Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData( ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - - if(!m_xMetaData.is()) - m_xMetaData = new OResultSetMetaData( - m_pSQLIterator->getSelectColumns(), m_pSQLIterator->getTables().begin()->first ,m_pTable,determineReadOnly()); - return m_xMetaData; -} - -Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) -{ - return NULL; -} - - - -Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) -{ - return NULL; -} - -Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) -{ - return NULL; -} - - -Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) -{ - return NULL; -} - - -Any SAL_CALL OResultSet::getObject( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException) -{ - return Any(); -} - - -sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) -{ - return 0; -} - - -void OResultSet::checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException) -{ - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->get().size()) - ::dbtools::throwInvalidIndexException(*this); -} - -sal_uInt32 OResultSet::currentRowCount() -{ - if ( m_bIsAlwaysFalseQuery ) - return 0; - return m_aQuery.getRealRowCount() - deletedCount(); -} - - - -sal_Bool OResultSet::fetchCurrentRow( ) throw(SQLException, RuntimeException) -{ - OSL_TRACE("fetchCurrentRow, m_nRowPos = %u", m_nRowPos ); - return fetchRow(getCurrentCardNumber()); -} - - -sal_Bool OResultSet::pushCard(sal_uInt32 cardNumber) throw(SQLException, RuntimeException) -{ - if (cardNumber == 0) - return sal_True; - // Check whether we are storing the updated row - if ( (m_aRow->get())[0].isNull() || (sal_Int32)(m_aRow->get())[0] != (sal_Int32)cardNumber ) - return sal_False; - - sal_Int32 nCount = m_aColumnNames.getLength(); - m_aQuery.setRowStates(cardNumber,m_RowStates); - for( sal_Int32 i = 1; i <= nCount; i++ ) - { - if ( (m_aRow->get())[i].isBound() ) - { - - // Everything in the addressbook is a string! - - if ( !m_aQuery.setRowValue( (m_aRow->get())[i], cardNumber, m_aColumnNames[i-1], DataType::VARCHAR )) - { - m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this ); - } - } - } - return sal_True; - -} - -sal_Bool OResultSet::fetchRow(sal_Int32 cardNumber,sal_Bool bForceReload) throw(SQLException, RuntimeException) -{ - OSL_TRACE("fetchRow, cardNumber = %u", cardNumber ); - if (!bForceReload) - { - // Check whether we've already fetched the row... - if ( !(m_aRow->get())[0].isNull() && (sal_Int32)(m_aRow->get())[0] == (sal_Int32)cardNumber ) - return sal_True; - //Check whether the old row has been changed - if (cardNumber == m_nUpdatedRow) - { - //write back the changes first - if (!pushCard(cardNumber)) //error write back the changes - throw SQLException(); - } - } - else - m_aQuery.resyncRow(cardNumber); - - if ( validRow( cardNumber ) == sal_False ) - return sal_False; - - (m_aRow->get())[0] = (sal_Int32)cardNumber; - sal_Int32 nCount = m_aColumnNames.getLength(); - m_RowStates = m_aQuery.getRowStates(cardNumber); - for( sal_Int32 i = 1; i <= nCount; i++ ) - { - if ( (m_aRow->get())[i].isBound() ) - { - - // Everything in the addressbook is a string! - - if ( !m_aQuery.getRowValue( (m_aRow->get())[i], cardNumber, m_aColumnNames[i-1], DataType::VARCHAR )) - { - m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this ); - } - } - } - return sal_True; -} - - -const ORowSetValue& OResultSet::getValue(sal_Int32 cardNumber, sal_Int32 columnIndex ) throw(SQLException, RuntimeException) -{ - if ( fetchRow( cardNumber ) == sal_False ) - { - OSL_FAIL("fetchRow() returned False" ); - m_bWasNull = sal_True; - return *ODatabaseMetaDataResultSet::getEmptyValue(); - } - - m_bWasNull = (m_aRow->get())[columnIndex].isNull(); - return (m_aRow->get())[columnIndex]; - -} - - - -OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - - OSL_ENSURE(m_xColumns.is(), "Need the Columns!!"); - OSL_ENSURE(columnIndex <= (sal_Int32)m_xColumns->get().size(), "Trying to access invalid columns number"); - checkIndex( columnIndex ); - - // If this query was sorted then we should have a valid KeySet, so use it - return getValue(getCurrentCardNumber(), mapColumn( columnIndex ) ); - -} - - -Time SAL_CALL OResultSet::getTime( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - return Time(); -} - - - -DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - return DateTime(); -} - - -sal_Bool SAL_CALL OResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - - // here you have to implement your movements - // return true means there is no data - OSL_TRACE("In/Out: OResultSet::isBeforeFirst" ); - return( m_nRowPos < 1 ); -} - -sal_Bool SAL_CALL OResultSet::isAfterLast( ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - - OSL_TRACE("In/Out: OResultSet::isAfterLast" ); - return m_nRowPos > currentRowCount() && m_aQuery.queryComplete(); -} - -sal_Bool SAL_CALL OResultSet::isFirst( ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - - OSL_TRACE("In/Out: OResultSet::isFirst" ); - return m_nRowPos == 1; -} - -sal_Bool SAL_CALL OResultSet::isLast( ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - - OSL_TRACE("In/Out: OResultSet::isLast" ); - return m_nRowPos == currentRowCount() && m_aQuery.queryComplete(); -} - -void SAL_CALL OResultSet::beforeFirst( ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - - // move before the first row so that isBeforeFirst returns false - OSL_TRACE("In/Out: OResultSet::beforeFirst" ); - if ( first() ) - previous(); -} - -void SAL_CALL OResultSet::afterLast( ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - OSL_TRACE("In/Out: OResultSet::afterLast" ); - - if(last()) - next(); -} - - -void SAL_CALL OResultSet::close( ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - OSL_TRACE("In/Out: OResultSet::close" ); - dispose(); -} - - -sal_Bool SAL_CALL OResultSet::first( ) throw(SQLException, RuntimeException) -{ - OSL_TRACE("In/Out: OResultSet::first" ); - return seekRow( FIRST_POS ); -} - - -sal_Bool SAL_CALL OResultSet::last( ) throw(SQLException, RuntimeException) -{ - OSL_TRACE("In/Out: OResultSet::last" ); - return seekRow( LAST_POS ); -} - -sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException) -{ - OSL_TRACE("In/Out: OResultSet::absolute" ); - return seekRow( ABSOLUTE_POS, row ); -} - -sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException) -{ - OSL_TRACE("In/Out: OResultSet::relative" ); - return seekRow( RELATIVE_POS, row ); -} - -sal_Bool SAL_CALL OResultSet::previous( ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - OSL_TRACE("In/Out: OResultSet::previous" ); - return seekRow( PRIOR_POS ); -} - -Reference< XInterface > SAL_CALL OResultSet::getStatement( ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - - OSL_TRACE("In/Out: OResultSet::getStatement" ); - return m_xStatement; -} - - -sal_Bool SAL_CALL OResultSet::rowDeleted( ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - OSL_TRACE("In/Out: OResultSet::rowDeleted, m_RowStates=%u",m_RowStates ); - return ((m_RowStates & RowStates_Deleted) == RowStates_Deleted) ; -} - -sal_Bool SAL_CALL OResultSet::rowInserted( ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - OSL_TRACE("In/Out: OResultSet::rowInserted,m_RowStates=%u",m_RowStates ); - return ((m_RowStates & RowStates_Inserted) == RowStates_Inserted); -} - -sal_Bool SAL_CALL OResultSet::rowUpdated( ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - OSL_TRACE("In/Out: OResultSet::rowUpdated,m_RowStates=%u",m_RowStates ); - return ((m_RowStates & RowStates_Updated) == RowStates_Updated) ; -} - - -sal_Bool SAL_CALL OResultSet::next( ) throw(SQLException, RuntimeException) -{ - return seekRow( NEXT_POS ); -} - - -sal_Bool SAL_CALL OResultSet::wasNull( ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - - return m_bWasNull; -} - - -void SAL_CALL OResultSet::cancel( ) throw(RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - OSL_TRACE("In/Out: OResultSet::cancel" ); - -} - -void SAL_CALL OResultSet::clearWarnings( ) throw(SQLException, RuntimeException) -{ - OSL_TRACE("In/Out: OResultSet::clearWarnings" ); -} - -Any SAL_CALL OResultSet::getWarnings( ) throw(SQLException, RuntimeException) -{ - OSL_TRACE("In/Out: OResultSet::getWarnings" ); - return Any(); -} - -void SAL_CALL OResultSet::refreshRow( ) throw(SQLException, RuntimeException) -{ - OSL_TRACE("In/Out: OResultSet::refreshRow" ); - if (fetchRow(getCurrentCardNumber(),sal_True)) //force fetch current row will cause we lose all change to the current row - m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_REFRESH_ROW, *this ); -} - -IPropertyArrayHelper* OResultSet::createArrayHelper( ) const -{ - Sequence< Property > aProps(5); - Property* pProperties = aProps.getArray(); - sal_Int32 nPos = 0; - pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), - PROPERTY_ID_FETCHDIRECTION, cppu::UnoType<sal_Int32>::get(), 0); - - pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), - PROPERTY_ID_FETCHSIZE, cppu::UnoType<sal_Int32>::get(), 0); - - pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE), - PROPERTY_ID_ISBOOKMARKABLE, cppu::UnoType<bool>::get(), PropertyAttribute::READONLY); - - pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), - PROPERTY_ID_RESULTSETCONCURRENCY, cppu::UnoType<sal_Int32>::get(), PropertyAttribute::READONLY); - - pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), - PROPERTY_ID_RESULTSETTYPE, cppu::UnoType<sal_Int32>::get(), PropertyAttribute::READONLY); - - return new OPropertyArrayHelper(aProps); -} - -IPropertyArrayHelper & OResultSet::getInfoHelper() -{ - return *const_cast<OResultSet*>(this)->getArrayHelper(); -} - -sal_Bool OResultSet::convertFastPropertyValue( - Any & /*rConvertedValue*/, - Any & /*rOldValue*/, - sal_Int32 nHandle, - const Any& /*rValue*/ ) - throw (::com::sun::star::lang::IllegalArgumentException) -{ - OSL_FAIL( "OResultSet::convertFastPropertyValue: not implemented!" ); - switch(nHandle) - { - case PROPERTY_ID_ISBOOKMARKABLE: - case PROPERTY_ID_RESULTSETCONCURRENCY: - case PROPERTY_ID_RESULTSETTYPE: - throw ::com::sun::star::lang::IllegalArgumentException(); - case PROPERTY_ID_FETCHDIRECTION: - case PROPERTY_ID_FETCHSIZE: - default: - ; - } - return sal_False; -} - -void OResultSet::setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, - const Any& /*rValue*/ - ) - throw (Exception) -{ - OSL_FAIL( "OResultSet::setFastPropertyValue_NoBroadcast: not implemented!" ); - switch(nHandle) - { - case PROPERTY_ID_ISBOOKMARKABLE: - case PROPERTY_ID_RESULTSETCONCURRENCY: - case PROPERTY_ID_RESULTSETTYPE: - throw Exception(); - case PROPERTY_ID_FETCHDIRECTION: - break; - case PROPERTY_ID_FETCHSIZE: - break; - default: - ; - } -} - -void OResultSet::getFastPropertyValue( - Any& rValue, - sal_Int32 nHandle - ) const -{ - switch(nHandle) - { - case PROPERTY_ID_RESULTSETCONCURRENCY: - rValue <<= (sal_Int32)m_nResultSetConcurrency; - break; - case PROPERTY_ID_RESULTSETTYPE: - rValue <<= m_nResultSetType; - break; - case PROPERTY_ID_FETCHDIRECTION: - rValue <<= m_nFetchDirection; - break; - case PROPERTY_ID_FETCHSIZE: - rValue <<= m_nFetchSize; - break; - case PROPERTY_ID_ISBOOKMARKABLE: - const_cast< OResultSet* >( this )->determineReadOnly(); - rValue <<= !m_bIsReadOnly; - break; - } -} - -void SAL_CALL OResultSet::acquire() throw() -{ - OResultSet_BASE::acquire(); -} - -void SAL_CALL OResultSet::release() throw() -{ - OResultSet_BASE::release(); -} - -::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) -{ - return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); -} - - -void OResultSet::parseParameter( const OSQLParseNode* pNode, OUString& rMatchString ) -{ - OSL_ENSURE(pNode->count() > 0,"Error parsing parameter in Parse Tree"); - OSQLParseNode *pMark = pNode->getChild(0); - - // Initialize to empty string - rMatchString = ""; - - OUString aParameterName; - if (SQL_ISPUNCTUATION(pMark,"?")) { - aParameterName = "?"; - } - else if (SQL_ISPUNCTUATION(pMark,":")) { - aParameterName = pNode->getChild(1)->getTokenValue(); - } - // XXX - Now we know name, what's value???? - m_nParamIndex ++; - OSL_TRACE("Parameter name [%d]: %s", m_nParamIndex,OUtoCStr(aParameterName) ); - - if ( m_aParameterRow.is() ) { - OSL_ENSURE( m_nParamIndex < (sal_Int32)m_aParameterRow->get().size() + 1, "More parameters than values found" ); - rMatchString = (m_aParameterRow->get())[(sal_uInt16)m_nParamIndex]; -#if OSL_DEBUG_LEVEL > 0 - OSL_TRACE("Prop Value : %s", OUtoCStr( rMatchString ) ); -#endif - } -#if OSL_DEBUG_LEVEL > 0 - else { - OSL_TRACE("Prop Value : Invalid ParameterRow!" ); - } -#endif -} - -#define WILDCARD "%" -#define ALT_WILDCARD "*" -static const sal_Unicode MATCHCHAR = '_'; - -void OResultSet::analyseWhereClause( const OSQLParseNode* parseTree, - MQueryExpression &queryExpression) -{ - OUString columnName; - MQueryOp::cond_type op( MQueryOp::Is ); - OUString matchString; - - if ( parseTree == NULL ) - return; - - if ( m_pSQLIterator->getParseTree() != NULL ) { - ::rtl::Reference<OSQLColumns> xColumns = m_pSQLIterator->getParameters(); - if(xColumns.is()) - { - OUString aColName, aParameterValue; - OSQLColumns::Vector::iterator aIter = xColumns->get().begin(); - sal_Int32 i = 1; - for(;aIter != xColumns->get().end();++aIter) - { - (*aIter)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName; - OSL_TRACE("Prop Column Name : %s", OUtoCStr( aColName ) ); - if ( m_aParameterRow.is() ) { - aParameterValue = (m_aParameterRow->get())[(sal_uInt16)i]; -#if OSL_DEBUG_LEVEL > 0 - OSL_TRACE("Prop Value : %s", OUtoCStr( aParameterValue ) ); -#endif - } -#if OSL_DEBUG_LEVEL > 0 - else { - OSL_TRACE("Prop Value : Invalid ParameterRow!" ); - } -#endif - i++; - } - } - - } - - if ( SQL_ISRULE(parseTree,where_clause) ) - { - OSL_TRACE("analyseSQL : Got WHERE clause"); - // Reset Parameter Counter - resetParameters(); - analyseWhereClause( parseTree->getChild( 1 ), queryExpression ); - } - else if ( parseTree->count() == 3 && // Handle ()'s - SQL_ISPUNCTUATION(parseTree->getChild(0),"(") && - SQL_ISPUNCTUATION(parseTree->getChild(2),")")) - { - - OSL_TRACE("analyseSQL : Got Punctuation ()"); - MQueryExpression *subExpression = new MQueryExpression(); - analyseWhereClause( parseTree->getChild( 1 ), *subExpression ); - queryExpression.getExpressions().push_back( subExpression ); - } - else if ((SQL_ISRULE(parseTree,search_condition) || (SQL_ISRULE(parseTree,boolean_term))) - && parseTree->count() == 3) // Handle AND/OR - { - - OSL_TRACE("analyseSQL : Got AND/OR clause"); - - // TODO - Need to take care or AND, for now match is always OR - analyseWhereClause( parseTree->getChild( 0 ), queryExpression ); - analyseWhereClause( parseTree->getChild( 2 ), queryExpression ); - - if (SQL_ISTOKEN(parseTree->getChild(1),OR)) { // OR-Operator - queryExpression.setExpressionCondition( MQueryExpression::OR ); - } - else if (SQL_ISTOKEN(parseTree->getChild(1),AND)) { // AND-Operator - queryExpression.setExpressionCondition( MQueryExpression::AND ); - } - else { - OSL_FAIL("analyseSQL: Error in Parse Tree"); - } - } - else if (SQL_ISRULE(parseTree,comparison_predicate)) - { - OSL_ENSURE(parseTree->count() == 3, "Error parsing COMPARE predicate"); - if (!(SQL_ISRULE(parseTree->getChild(0),column_ref) || - parseTree->getChild(2)->getNodeType() == SQL_NODE_STRING || - parseTree->getChild(2)->getNodeType() == SQL_NODE_INTNUM || - parseTree->getChild(2)->getNodeType() == SQL_NODE_APPROXNUM || - SQL_ISTOKEN(parseTree->getChild(2),TRUE) || - SQL_ISTOKEN(parseTree->getChild(2),FALSE) || - SQL_ISRULE(parseTree->getChild(2),parameter) || - // odbc date - (SQL_ISRULE(parseTree->getChild(2),set_fct_spec) && SQL_ISPUNCTUATION(parseTree->getChild(2)->getChild(0),"{")))) - { - m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this ); - } - - OSQLParseNode *pPrec = parseTree->getChild(1); - if (pPrec->getNodeType() == SQL_NODE_EQUAL) - op = MQueryOp::Is; - else if (pPrec->getNodeType() == SQL_NODE_NOTEQUAL) - op = MQueryOp::IsNot; - - OUString sTableRange; - if(SQL_ISRULE(parseTree->getChild(0),column_ref)) - m_pSQLIterator->getColumnRange(parseTree->getChild(0),columnName,sTableRange); - else if(parseTree->getChild(0)->isToken()) - columnName = parseTree->getChild(0)->getTokenValue(); - - if ( SQL_ISRULE(parseTree->getChild(2),parameter) ) { - parseParameter( parseTree->getChild(2), matchString ); - } - else { - matchString = parseTree->getChild(2)->getTokenValue(); - } - - if ( columnName.equalsAscii("0") && op == MQueryOp::Is && - matchString.equalsAscii("1") ) { - OSL_TRACE("Query always evaluates to FALSE"); - m_bIsAlwaysFalseQuery = sal_True; - } - queryExpression.getExpressions().push_back( new MQueryExpressionString( columnName, op, matchString )); - } - else if (SQL_ISRULE(parseTree,like_predicate)) - { - OSL_ENSURE(parseTree->count() == 2, "Error parsing LIKE predicate"); - - OSL_TRACE("analyseSQL : Got LIKE rule"); - - if ( !(SQL_ISRULE(parseTree->getChild(0), column_ref)) ) - { - m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_INVALID_LIKE_COLUMN, *this ); - } - - - OSQLParseNode *pColumn; - OSQLParseNode *pAtom; - OSQLParseNode *pOptEscape; - const OSQLParseNode* pPart2 = parseTree->getChild(1); - pColumn = parseTree->getChild(0); // Match Item - pAtom = pPart2->getChild(static_cast<sal_uInt32>(pPart2->count()-2)); // Match String - pOptEscape = pPart2->getChild(static_cast<sal_uInt32>(pPart2->count()-1)); // Opt Escape Rule - (void)pOptEscape; - const bool bNot = SQL_ISTOKEN(pPart2->getChild(0), NOT); - - if (!(pAtom->getNodeType() == SQL_NODE_STRING || - pAtom->getNodeType() == SQL_NODE_NAME || - SQL_ISRULE(pAtom,parameter) || - ( pAtom->getChild(0) && pAtom->getChild(0)->getNodeType() == SQL_NODE_NAME ) || - ( pAtom->getChild(0) && pAtom->getChild(0)->getNodeType() == SQL_NODE_STRING ) - ) ) - { - OSL_TRACE("analyseSQL : pAtom->count() = %d", pAtom->count() ); - - m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_INVALID_LIKE_STRING, *this ); - } - - OUString sTableRange; - if(SQL_ISRULE(pColumn,column_ref)) - m_pSQLIterator->getColumnRange(pColumn,columnName,sTableRange); - - OSL_TRACE("ColumnName = %s", OUtoCStr( columnName ) ); - - if ( SQL_ISRULE(pAtom,parameter) ) { - parseParameter( pAtom, matchString ); - // Replace all '*' with '%' : UI Usually does this but not with - // Parameters for some reason. - matchString = matchString.replaceAll( ALT_WILDCARD, WILDCARD ); - } - else - { - matchString = pAtom->getTokenValue(); - } - - // Determine where '%' character is... - - if ( matchString.equals( WILDCARD ) ) - { - // String containing only a '%' and nothing else - op = MQueryOp::Exists; - // Will be ignored for Exists case, but clear anyway. - matchString = ""; - } - else if ( matchString.indexOf ( WILDCARD ) == -1 && - matchString.indexOf ( MATCHCHAR ) == -1 ) - { - // Simple string , eg. "to match" - if ( bNot ) - op = MQueryOp::DoesNotContain; - else - op = MQueryOp::Contains; - } - else if ( matchString.startsWith( WILDCARD ) - && matchString.endsWith( WILDCARD ) - && matchString.indexOf ( WILDCARD, 1 ) == matchString.lastIndexOf ( WILDCARD ) - && matchString.indexOf( MATCHCHAR ) == -1 - ) - { - // Relatively simple "%string%" - ie, contains... - // Cut '%' from front and rear - matchString = matchString.replaceAt( 0, 1, OUString() ); - matchString = matchString.replaceAt( matchString.getLength() -1 , 1, OUString() ); - - if (bNot) - op = MQueryOp::DoesNotContain; - else - op = MQueryOp::Contains; - } - else if ( bNot ) - { - // We currently can't handle a 'NOT LIKE' when there are '%' or - // '_' dispersed throughout - m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_NOT_LIKE_TOO_COMPLEX, *this ); - } - else - { - if ( (matchString.indexOf ( WILDCARD ) == matchString.lastIndexOf ( WILDCARD )) - && matchString.indexOf( MATCHCHAR ) == -1 - ) - { - // One occurrence of '%' - no '_' matches... - if ( matchString.startsWith( WILDCARD ) ) - { - op = MQueryOp::EndsWith; - matchString = matchString.replaceAt( 0, 1, OUString()); - } - else if ( matchString.endsWith( WILDCARD ) ) - { - op = MQueryOp::BeginsWith; - matchString = matchString.replaceAt( matchString.getLength() -1, 1, OUString() ); - } - else - { - sal_Int32 pos = matchString.indexOf ( WILDCARD ); - matchString = matchString.replaceAt( pos, 1, ".*" ); - op = MQueryOp::RegExp; - } - - } - else - { - // Most Complex, need to use an RE - sal_Int32 pos; - while ( (pos = matchString.indexOf ( WILDCARD )) != -1 ) - { - matchString = matchString.replaceAt( pos, 1, ".*" ); - } - - while ( (pos = matchString.indexOf( MATCHCHAR )) != -1 ) - { - matchString = matchString.replaceAt( pos, 1, "." ); - } - - op = MQueryOp::RegExp; - } - } - - queryExpression.getExpressions().push_back( new MQueryExpressionString( columnName, op, matchString )); - } - else if (SQL_ISRULE(parseTree,test_for_null)) - { - OSL_ENSURE(parseTree->count() == 2,"Error in ParseTree"); - const OSQLParseNode* pPart2 = parseTree->getChild(1); - OSL_ENSURE(SQL_ISTOKEN(pPart2->getChild(0),IS),"Error in ParseTree"); - - if (!SQL_ISRULE(parseTree->getChild(0),column_ref)) - { - m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_INVALID_IS_NULL_COLUMN, *this ); - } - - if (SQL_ISTOKEN(pPart2->getChild(1),NOT)) - { - op = MQueryOp::Exists; - } - else - op = MQueryOp::DoesNotExist; - - OUString sTableRange; - m_pSQLIterator->getColumnRange(parseTree->getChild(0),columnName,sTableRange); - - queryExpression.getExpressions().push_back( new MQueryExpressionString( columnName, op )); - } - else - { - OSL_TRACE( "Unexpected statement!!!" ); - - m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this ); - } -} - - - - -void OResultSet::fillRowData() - throw( ::com::sun::star::sdbc::SQLException ) -{ - OSL_ENSURE( m_pStatement, "Require a statement" ); - - MQueryExpression queryExpression; - - OConnection* xConnection = static_cast<OConnection*>(m_pStatement->getConnection().get()); - m_xColumns = m_pSQLIterator->getSelectColumns(); - - OSL_ENSURE(m_xColumns.is(), "Need the Columns!!"); - - OSQLColumns::Vector::const_iterator aIter = m_xColumns->get().begin(); - const OUString sProprtyName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME); - OUString sName; - m_aAttributeStrings.clear(); - m_aAttributeStrings.reserve(m_xColumns->get().size()); - for (sal_Int32 i = 1; aIter != m_xColumns->get().end();++aIter, i++) - { - (*aIter)->getPropertyValue(sProprtyName) >>= sName; -#if OSL_DEBUG_LEVEL > 0 - OSL_TRACE("Query Columns : (%d) %s", i, OUtoCStr(sName) ); -#endif - m_aAttributeStrings.push_back( sName ); - } - - - // Generate Match Conditions for Query - const OSQLParseNode* pParseTree = m_pSQLIterator->getWhereTree(); - - // const OSQLParseNode* pParseTree = NULL; - - m_bIsAlwaysFalseQuery = sal_False; - if ( pParseTree != NULL ) - { - // Extract required info - - OSL_TRACE("\tHave a Where Clause"); - - analyseWhereClause( pParseTree, queryExpression ); - } - else - { - OSL_TRACE("\tDon't have a Where Clause"); - - MQueryExpression::ExprVector eVector; - - // LDAP does not allow a query without restriction, so we add a dummy - // for PrimaryEmail - // For other types we stick to the old behaviour of using - // card:nsIAbCard. - OSL_ENSURE(m_pStatement, "Cannot determine Parent Statement"); - OUString aStr; - if (xConnection->isLDAP()) - aStr = "PrimaryEmail"; - else - aStr = "card:nsIAbCard"; - eVector.push_back( new MQueryExpressionString(aStr, MQueryOp::Exists) ); - - queryExpression.setExpressions( eVector ); - } - - // If the query is a 0=1 then set Row count to 0 and return - if ( m_bIsAlwaysFalseQuery ) - { - m_bIsReadOnly = 1; - return; - } - - m_aQuery.setExpression( queryExpression ); - - OUString aStr( m_pTable->getName() ); - m_aQuery.setAddressbook( aStr ); - - sal_Int32 rv = m_aQuery.executeQuery(xConnection); - if ( rv == -1 ) { - m_pStatement->getOwnConnection()->throwSQLException( STR_ERR_EXECUTING_QUERY, *this ); - } - //determine whether the address book is readonly - determineReadOnly(); - -#if OSL_DEBUG_LEVEL > 0 - OSL_TRACE( "executeQuery returned %d", rv ); - - OSL_TRACE( "\tOUT OResultSet::fillRowData()" ); -#endif -} - - -static sal_Bool matchRow( OValueRow& row1, OValueRow& row2 ) -{ - OValueVector::Vector::iterator row1Iter = row1->get().begin(); - OValueVector::Vector::iterator row2Iter = row2->get().begin(); - for ( ++row1Iter,++row2Iter; // the first column is the bookmark column - row1Iter != row1->get().end(); ++row1Iter,++row2Iter) - { - if ( row1Iter->isBound()) - { - // Compare values, if at anytime there's a mismatch return false - if ( !( (*row1Iter) == (*row2Iter) ) ) - return sal_False; - } - } - - // If we get to here the rows match - return sal_True; -} -sal_Int32 OResultSet::getRowForCardNumber(sal_Int32 nCardNum) -{ - OSL_TRACE("In/Out: OResultSet::getRowForCardNumber, nCardNum = %u", nCardNum ); - - if ( m_pKeySet.is() ) - { - sal_Int32 nPos; - for(nPos=0;nPos < (sal_Int32)m_pKeySet->get().size();nPos++) - { - if (nCardNum == (m_pKeySet->get())[nPos]) - { - OSL_TRACE("In/Out: OResultSet::getRowForCardNumber, return = %u", nPos+1 ); - return nPos+1; - } - } - } - - m_pStatement->getOwnConnection()->throwSQLException( STR_INVALID_BOOKMARK, *this ); - return 0; -} - - -void SAL_CALL OResultSet::executeQuery() throw( ::com::sun::star::sdbc::SQLException, - ::com::sun::star::uno::RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - - OSL_ENSURE( m_pTable, "Need a Table object"); - if(!m_pTable) - { - const OSQLTables& xTabs = m_pSQLIterator->getTables(); - if ((xTabs.begin() == xTabs.end()) || !xTabs.begin()->second.is()) - m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this ); - - m_pTable = static_cast< OTable* > ((xTabs.begin()->second).get()); - - } - - m_nRowPos = 0; - - fillRowData(); - - OSL_ENSURE(m_xColumns.is(), "Need the Columns!!"); - - switch( m_pSQLIterator->getStatementType() ) - { - case SQL_STATEMENT_SELECT: - { - if(m_bIsAlwaysFalseQuery) { - break; - } - else if(isCount()) - { - m_pStatement->getOwnConnection()->throwSQLException( STR_NO_COUNT_SUPPORT, *this ); - } - else - { - sal_Bool bDistinct = sal_False; - OSQLParseNode *pDistinct = m_pParseTree->getChild(1); - if (pDistinct && pDistinct->getTokenID() == SQL_TOKEN_DISTINCT) - { - if(!IsSorted()) - { - m_aOrderbyColumnNumber.push_back(m_aColMapping[1]); - m_aOrderbyAscending.push_back(SQL_DESC); - } - bDistinct = sal_True; - } - - OSortIndex::TKeyTypeVector eKeyType(m_aOrderbyColumnNumber.size()); - ::std::vector<sal_Int32>::iterator aOrderByIter = m_aOrderbyColumnNumber.begin(); - for ( ::std::vector<sal_Int16>::size_type i = 0; aOrderByIter != m_aOrderbyColumnNumber.end(); ++aOrderByIter,++i) - { - OSL_ENSURE((sal_Int32)m_aRow->get().size() > *aOrderByIter,"Invalid Index"); - switch ((m_aRow->get().begin()+*aOrderByIter)->getTypeKind()) - { - case DataType::CHAR: - case DataType::VARCHAR: - eKeyType[i] = SQL_ORDERBYKEY_STRING; - break; - - case DataType::OTHER: - case DataType::TINYINT: - case DataType::SMALLINT: - case DataType::INTEGER: - case DataType::DECIMAL: - case DataType::NUMERIC: - case DataType::REAL: - case DataType::DOUBLE: - case DataType::DATE: - case DataType::TIME: - case DataType::TIMESTAMP: - case DataType::BIT: - eKeyType[i] = SQL_ORDERBYKEY_DOUBLE; - break; - - // Other types aren't implemented (so they are always FALSE) - default: - eKeyType[i] = SQL_ORDERBYKEY_NONE; - OSL_FAIL("MResultSet::executeQuery: Order By Data Type not implemented"); - break; - } - } - - if (IsSorted()) - { - // Implement Sorting - - // So that we can sort we need to wait until the executed - // query to the mozilla addressbooks has returned all - // values. - - OSL_TRACE("Query is to be sorted"); - if( ! m_aQuery.queryComplete() ) - if ( !m_aQuery.waitForQueryComplete() ) - { - m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this ); - } - - OSL_ENSURE( m_aQuery.queryComplete(), "Query not complete!!"); - - m_pSortIndex = new OSortIndex(eKeyType,m_aOrderbyAscending); - - OSL_TRACE("OrderbyColumnNumber->size() = %d",m_aOrderbyColumnNumber.size()); -#if OSL_DEBUG_LEVEL > 0 - for ( ::std::vector<sal_Int32>::size_type i = 0; i < m_aColMapping.size(); i++ ) - OSL_TRACE("Mapped: %d -> %d", i, m_aColMapping[i] ); -#endif - for ( sal_Int32 nRow = 1; nRow <= m_aQuery.getRowCount(); nRow++ ) { - - OKeyValue* pKeyValue = OKeyValue::createKeyValue((nRow)); - - ::std::vector<sal_Int32>::iterator aIter = m_aOrderbyColumnNumber.begin(); - for (;aIter != m_aOrderbyColumnNumber.end(); ++aIter) - { - const ORowSetValue& value = getValue(nRow, *aIter); - - OSL_TRACE( "Adding Value: (%d,%d) : %s", nRow, *aIter,OUtoCStr( value )); - - pKeyValue->pushKey(new ORowSetValueDecorator(value)); - } - - m_pSortIndex->AddKeyValue( pKeyValue ); - } - - m_pKeySet = m_pSortIndex->CreateKeySet(); - m_CurrentRowCount = static_cast<sal_Int32>(m_pKeySet->get().size()); -#if OSL_DEBUG_LEVEL > 0 - for( OKeySet::Vector::size_type i = 0; i < m_pKeySet->get().size(); i++ ) - OSL_TRACE("Sorted: %d -> %d", i, (m_pKeySet->get())[i] ); -#endif - - m_pSortIndex = NULL; - beforeFirst(); // Go back to start - } - else //we always need m_pKeySet now - m_pKeySet = new OKeySet(); - - // Handle the DISTINCT case - if ( bDistinct && m_pKeySet.is() ) - { - OValueRow aSearchRow = new OValueVector( m_aRow->get().size() ); - - for( OKeySet::Vector::size_type i = 0; i < m_pKeySet->get().size(); i++ ) - { - fetchRow( (m_pKeySet->get())[i] ); // Fills m_aRow - if ( matchRow( m_aRow, aSearchRow ) ) - { - (m_pKeySet->get())[i] = 0; // Marker for later to be removed - } - else - { - // They don't match, so it's not a duplicate. - // Use the current Row as the next one to match against - *aSearchRow = *m_aRow; - } - } - // Now remove any keys marked with a 0 - m_pKeySet->get().erase(::std::remove_if(m_pKeySet->get().begin(),m_pKeySet->get().end() - ,::std::bind2nd(::std::equal_to<sal_Int32>(),0)) - ,m_pKeySet->get().end()); - - } - } - } break; - - case SQL_STATEMENT_UPDATE: - case SQL_STATEMENT_DELETE: - case SQL_STATEMENT_INSERT: - break; - default: - m_pStatement->getOwnConnection()->throwSQLException( STR_STMT_TYPE_NOT_SUPPORTED, *this ); - break; - } -} - - - -void OResultSet::setBoundedColumns(const OValueRow& _rRow, - const ::rtl::Reference<connectivity::OSQLColumns>& _rxColumns, - const Reference<XIndexAccess>& _xNames, - sal_Bool _bSetColumnMapping, - const Reference<XDatabaseMetaData>& _xMetaData, - ::std::vector<sal_Int32>& _rColMapping) -{ - ::comphelper::UStringMixEqual aCase(_xMetaData->supportsMixedCaseQuotedIdentifiers()); - - Reference<XPropertySet> xTableColumn; - OUString sTableColumnName, sSelectColumnRealName; - - const OUString sName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME); - const OUString sRealName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME); - - ::std::vector< OUString> aColumnNames; - aColumnNames.reserve(_rxColumns->get().size()); - OValueVector::Vector::iterator aRowIter = _rRow->get().begin()+1; - for (sal_Int32 i=0; // the first column is the bookmark column - aRowIter != _rRow->get().end(); - ++i, ++aRowIter - ) - { - try - { - // get the table column and its name - _xNames->getByIndex(i) >>= xTableColumn; - OSL_ENSURE(xTableColumn.is(), "OResultSet::setBoundedColumns: invalid table column!"); - if (xTableColumn.is()) - xTableColumn->getPropertyValue(sName) >>= sTableColumnName; - else - sTableColumnName = ""; - - // look if we have such a select column - // TODO: would like to have a O(log n) search here ... - sal_Int32 nColumnPos = 0; - for ( OSQLColumns::Vector::iterator aIter = _rxColumns->get().begin(); - aIter != _rxColumns->get().end(); - ++aIter,++nColumnPos - ) - { - if ( nColumnPos < (sal_Int32)aColumnNames.size() ) - sSelectColumnRealName = aColumnNames[nColumnPos]; - else - { - if((*aIter)->getPropertySetInfo()->hasPropertyByName(sRealName)) - (*aIter)->getPropertyValue(sRealName) >>= sSelectColumnRealName; - else - (*aIter)->getPropertyValue(sName) >>= sSelectColumnRealName; - aColumnNames.push_back(sSelectColumnRealName); - } - - if (aCase(sTableColumnName, sSelectColumnRealName)) - { - if(_bSetColumnMapping) - { - sal_Int32 nSelectColumnPos = static_cast<sal_Int32>(aIter - _rxColumns->get().begin() + 1); - // the getXXX methods are 1-based ... - sal_Int32 nTableColumnPos = i + 1; - // get first table column is the bookmark column - -#if OSL_DEBUG_LEVEL > 0 - OSL_TRACE("Set Col Mapping: %d -> %d", nSelectColumnPos, nTableColumnPos ); -#endif - _rColMapping[nSelectColumnPos] = nTableColumnPos; - } - - aRowIter->setBound(sal_True); - aRowIter->setTypeKind(DataType::VARCHAR); - } - } - } - catch (Exception&) - { - OSL_FAIL("OResultSet::setBoundedColumns: caught an Exception!"); - } - } -} - - - -sal_Bool OResultSet::isCount() const -{ - return (m_pParseTree && - m_pParseTree->count() > 2 && - SQL_ISRULE(m_pParseTree->getChild(2),scalar_exp_commalist) && - SQL_ISRULE(m_pParseTree->getChild(2)->getChild(0),derived_column) && - SQL_ISRULE(m_pParseTree->getChild(2)->getChild(0)->getChild(0),general_set_fct) && - m_pParseTree->getChild(2)->getChild(0)->getChild(0)->count() == 4 - ); -} - - - -// Check for valid row in m_aQuery - -sal_Bool OResultSet::validRow( sal_uInt32 nRow ) -{ - sal_Int32 nNumberOfRecords = m_aQuery.getRealRowCount(); - - while ( nRow > (sal_uInt32)nNumberOfRecords && !m_aQuery.queryComplete() ) { -#if OSL_DEBUG_LEVEL > 0 - OSL_TRACE("validRow: waiting..."); -#endif - m_aQuery.checkRowAvailable( nRow ); - if ( m_aQuery.hadError() ) - { - m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this ); - } - nNumberOfRecords = m_aQuery.getRealRowCount(); - } - - if (( nRow == 0 ) || - ( nRow > (sal_uInt32)nNumberOfRecords && m_aQuery.queryComplete()) ){ - OSL_TRACE("validRow(%u): return False", nRow); - return sal_False; - } -#if OSL_DEBUG_LEVEL > 0 - OSL_TRACE("validRow(%u): return True", nRow); -#endif - return sal_True; -} -sal_Bool OResultSet::fillKeySet(sal_Int32 nMaxCardNumber) -{ - impl_ensureKeySet(); - if (m_CurrentRowCount < nMaxCardNumber) - { - sal_Int32 nKeyValue; - if ( (sal_Int32)m_pKeySet->get().capacity() < nMaxCardNumber ) - m_pKeySet->get().reserve(nMaxCardNumber + 20 ); - - for (nKeyValue = m_CurrentRowCount+1; nKeyValue <= nMaxCardNumber; nKeyValue ++) - m_pKeySet->get().push_back( nKeyValue ); - m_CurrentRowCount = nMaxCardNumber; - } - return sal_True; -} - -sal_Int32 OResultSet::deletedCount() -{ - impl_ensureKeySet(); - return m_CurrentRowCount - static_cast<sal_Int32>(m_pKeySet->get().size()); - -} - -sal_Bool OResultSet::seekRow( eRowPosition pos, sal_Int32 nOffset ) -{ - ResultSetEntryGuard aGuard( *this ); - if ( !m_pKeySet.is() ) - m_pStatement->getOwnConnection()->throwSQLException( STR_ILLEGAL_MOVEMENT, *this ); - - sal_Int32 nNumberOfRecords = m_aQuery.getRealRowCount(); - sal_Int32 nRetrievedRows = currentRowCount(); - sal_Int32 nCurPos = m_nRowPos; - - OSL_TRACE("seekRow: nCurPos = %d", nCurPos ); - switch( pos ) { - case NEXT_POS: - OSL_TRACE("seekRow: NEXT"); - nCurPos++; - break; - case PRIOR_POS: - OSL_TRACE("seekRow: PRIOR"); - if ( nCurPos > 0 ) - nCurPos--; - break; - - case FIRST_POS: - OSL_TRACE("seekRow: FIRST"); - nCurPos = 1; - break; - - case LAST_POS: - OSL_TRACE("seekRow: LAST"); - nCurPos = nRetrievedRows; - break; - case ABSOLUTE_POS: - OSL_TRACE("seekRow: ABSOLUTE : %d", nOffset); - nCurPos = nOffset; - break; - case RELATIVE_POS: - OSL_TRACE("seekRow: RELATIVE : %d", nOffset); - nCurPos += sal_uInt32( nOffset ); - break; - } - - if ( nCurPos <= 0 ) { - m_nRowPos = 0; - OSL_TRACE("seekRow: return False, m_nRowPos = %u", m_nRowPos ); - return sal_False; - } - sal_Int32 nCurCard = nCurPos; - if ( nCurPos < (sal_Int32)m_pKeySet->get().size() ) //The requested row is exist in m_pKeySet, so we just use it - { - nCurCard = (m_pKeySet->get())[nCurPos-1]; - } - else //The requested row has not been retrieved until now. We should get the right card for it. - nCurCard = nCurPos + deletedCount(); - - while ( nCurCard > nNumberOfRecords && !m_aQuery.queryComplete() ) { - m_aQuery.checkRowAvailable( nCurCard ); - if ( m_aQuery.hadError() ) - { - m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this ); - } - nNumberOfRecords = m_aQuery.getRealRowCount(); - } - - if ( nCurCard > nNumberOfRecords && m_aQuery.queryComplete()) { - fillKeySet(nNumberOfRecords); - m_nRowPos = static_cast<sal_uInt32>(m_pKeySet->get().size() + 1); - OSL_TRACE("seekRow: return False, m_nRowPos = %u", m_nRowPos ); - return sal_False; - } - //Insert new retrieved items for later use - fillKeySet(nNumberOfRecords); - m_nRowPos = (sal_uInt32)nCurPos; - OSL_TRACE("seekRow: return True, m_nRowPos = %u", m_nRowPos ); - fetchCurrentRow(); - return sal_True; -} - -void OResultSet::setColumnMapping(const ::std::vector<sal_Int32>& _aColumnMapping) -{ - m_aColMapping = _aColumnMapping; -#if OSL_DEBUG_LEVEL > 0 - for ( sal_uInt32 i = 0; i < m_aColMapping.size(); i++ ) - OSL_TRACE("Set Mapped: %d -> %d", i, m_aColMapping[i] ); -#endif -} - - -::com::sun::star::uno::Any OResultSet::getBookmark( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - OSL_TRACE("getBookmark, m_nRowPos = %u", m_nRowPos ); - ResultSetEntryGuard aGuard( *this ); - if ( fetchCurrentRow() == sal_False ) - m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW, *this ); - - OSL_ENSURE((!m_aRow->isDeleted()),"getBookmark called for deleted row"); - return makeAny((sal_Int32)(m_aRow->get())[0]); -} -sal_Bool OResultSet::moveToBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - OSL_TRACE("moveToBookmark, bookmark = %u", comphelper::getINT32(bookmark) ); - sal_Int32 nCardNum = comphelper::getINT32(bookmark); - m_nRowPos = getRowForCardNumber(nCardNum); - fetchCurrentRow(); - return sal_True; -} -sal_Bool OResultSet::moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - OSL_TRACE("moveRelativeToBookmark, bookmark = %u rows= %u", comphelper::getINT32(bookmark),rows ); - sal_Int32 nCardNum = comphelper::getINT32(bookmark); - m_nRowPos = getRowForCardNumber(nCardNum); - return seekRow(RELATIVE_POS,rows ); -} -sal_Int32 OResultSet::compareBookmarks( const ::com::sun::star::uno::Any& lhs, const ::com::sun::star::uno::Any& rhs ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - OSL_TRACE("compareBookmarks, m_nRowPos = %u", m_nRowPos ); - sal_Int32 nFirst=0; - sal_Int32 nSecond=0; - sal_Int32 nResult=0; - - if ( !( lhs >>= nFirst ) || !( rhs >>= nSecond ) ) - m_pStatement->getOwnConnection()->throwSQLException( STR_INVALID_BOOKMARK, *this ); - - if(nFirst < nSecond) - nResult = CompareBookmark::LESS; - else if(nFirst > nSecond) - nResult = CompareBookmark::GREATER; - else - nResult = CompareBookmark::EQUAL; - - return nResult; -} -sal_Bool OResultSet::hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - OSL_TRACE("hasOrderedBookmarks, m_nRowPos = %u", m_nRowPos ); - return sal_True; -} -sal_Int32 OResultSet::hashBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - OSL_TRACE("hashBookmark, m_nRowPos = %u", m_nRowPos ); - return comphelper::getINT32(bookmark); -} - -sal_Int32 OResultSet::getCurrentCardNumber() -{ - if ( ( m_nRowPos == 0 ) || !m_pKeySet.is() ) - return 0; - if (m_pKeySet->get().size() < m_nRowPos) - return 0; - return (m_pKeySet->get())[m_nRowPos-1]; -} -void OResultSet::checkPendingUpdate() throw(SQLException, RuntimeException) -{ - OSL_TRACE("checkPendingUpdate, m_nRowPos = %u", m_nRowPos ); - const sal_Int32 nCurrentRow = getCurrentCardNumber(); - - if ((m_nNewRow && nCurrentRow != m_nNewRow) - || ( m_nUpdatedRow && m_nUpdatedRow != nCurrentRow)) - { - const OUString sError( m_pStatement->getOwnConnection()->getResources().getResourceStringWithSubstitution( - STR_COMMIT_ROW, - "$position$", OUString::number(nCurrentRow) - ) ); - ::dbtools::throwGenericSQLException(sError,*this); - } - -} -void OResultSet::updateValue(sal_Int32 columnIndex ,const ORowSetValue& x) throw(SQLException, RuntimeException) -{ - OSL_TRACE("updateValue, m_nRowPos = %u", m_nRowPos ); - ResultSetEntryGuard aGuard( *this ); - if ( fetchCurrentRow() == sal_False ) - m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW, *this ); - - - checkPendingUpdate(); - - checkIndex(columnIndex ); - columnIndex = mapColumn(columnIndex); - - (m_aRow->get())[columnIndex].setBound(sal_True); - (m_aRow->get())[columnIndex] = x; - m_nUpdatedRow = getCurrentCardNumber(); - m_RowStates = m_RowStates | RowStates_Updated; -} - - -void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) -{ - OSL_TRACE("updateNull, m_nRowPos = %u", m_nRowPos ); - ResultSetEntryGuard aGuard( *this ); - if ( fetchCurrentRow() == sal_False ) - m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW, *this ); - - checkPendingUpdate(); - checkIndex(columnIndex ); - columnIndex = mapColumn(columnIndex); - - (m_aRow->get())[columnIndex].setBound(sal_True); - (m_aRow->get())[columnIndex].setNull(); - m_nUpdatedRow = getCurrentCardNumber(); - m_RowStates = m_RowStates | RowStates_Updated; -} - - -void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException) -{ - updateValue(columnIndex, static_cast<bool>(x)); -} - -void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException) -{ - updateValue(columnIndex,x); -} - - -void SAL_CALL OResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(SQLException, RuntimeException) -{ - updateValue(columnIndex,x); -} - -void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(SQLException, RuntimeException) -{ - updateValue(columnIndex,x); -} - -void SAL_CALL OResultSet::updateLong( sal_Int32 /*columnIndex*/, sal_Int64 /*x*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XRowUpdate::updateLong", *this ); -} - -void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQLException, RuntimeException) -{ - updateValue(columnIndex,x); -} - - -void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(SQLException, RuntimeException) -{ - updateValue(columnIndex,x); -} - -void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const OUString& x ) throw(SQLException, RuntimeException) -{ - updateValue(columnIndex,x); -} - -void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException) -{ - updateValue(columnIndex,x); -} - -void SAL_CALL OResultSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException) -{ - updateValue(columnIndex,x); -} - - -void SAL_CALL OResultSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException) -{ - updateValue(columnIndex,x); -} - - -void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException) -{ - updateValue(columnIndex,x); -} - - -void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - - if(!x.is()) - ::dbtools::throwFunctionSequenceException(*this); - - Sequence<sal_Int8> aSeq; - x->readBytes(aSeq,length); - updateValue(columnIndex,aSeq); -} - -void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) -{ - updateBinaryStream(columnIndex,x,length); -} - -void SAL_CALL OResultSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException) -{ - if (!::dbtools::implUpdateObject(this, columnIndex, x)) - { - const OUString sError( m_pStatement->getOwnConnection()->getResources().getResourceStringWithSubstitution( - STR_COLUMN_NOT_UPDATEABLE, - "$position$", OUString::number(columnIndex) - ) ); - ::dbtools::throwGenericSQLException(sError,*this); - } // if (!::dbtools::implUpdateObject(this, columnIndex, x)) - } - - -void SAL_CALL OResultSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException) -{ - if (!::dbtools::implUpdateObject(this, columnIndex, x)) - { - const OUString sError( m_pStatement->getOwnConnection()->getResources().getResourceStringWithSubstitution( - STR_COLUMN_NOT_UPDATEABLE, - "$position$", OUString::number(columnIndex) - ) ); - ::dbtools::throwGenericSQLException(sError,*this); - } -} - -// XResultSetUpdate - -void SAL_CALL OResultSet::insertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - OSL_TRACE("insertRow in, m_nRowPos = %u", m_nRowPos ); - m_RowStates = RowStates_Inserted; - updateRow(); - m_nOldRowPos = 0; - m_nNewRow = 0; - m_aQuery.setRowStates(getCurrentCardNumber(),m_RowStates); - OSL_TRACE("insertRow out, m_nRowPos = %u", m_nRowPos ); -} - -void SAL_CALL OResultSet::updateRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - OSL_TRACE("updateRow in, m_nRowPos = %u", m_nRowPos ); - ResultSetEntryGuard aGuard( *this ); - impl_ensureKeySet(); - - if (!m_nRowPos || m_pKeySet->get().size() < m_nRowPos ) - m_pStatement->getOwnConnection()->throwSQLException( STR_INVALID_ROW_UPDATE, *this ); - - const sal_Int32 nCurrentCard = getCurrentCardNumber(); - - if (!pushCard(nCurrentCard)) - { - m_RowStates = RowStates_Error; - m_pStatement->getOwnConnection()->throwSQLException( STR_ROW_CAN_NOT_SAVE, *this ); - } - - if (!m_aQuery.commitRow(nCurrentCard)) - { - m_RowStates = RowStates_Error; - m_nUpdatedRow = 0; - m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this ); - } - - m_nUpdatedRow = 0; - fetchCurrentRow(); - OSL_TRACE("updateRow out, m_nRowPos = %u", m_nRowPos ); -} - -void SAL_CALL OResultSet::deleteRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - OSL_TRACE("deleteRow, m_nRowPos = %u", m_nRowPos ); - ResultSetEntryGuard aGuard( *this ); - if (rowDeleted()) - m_pStatement->getOwnConnection()->throwSQLException( STR_ROW_ALREADY_DELETED, *this ); - - const sal_Int32 nCurrentRow = getCurrentCardNumber(); - //fetchRow(nCurrentRow); - if (!nCurrentRow) - m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW, *this ); - - sal_Bool m_bRowDeleted = ( m_aQuery.deleteRow( nCurrentRow ) > 0 ); - if (!m_bRowDeleted) - m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this ); - - m_aQuery.setRowStates(nCurrentRow,RowStates_Deleted); - m_pKeySet->get().erase(m_pKeySet->get().begin() + m_nRowPos -1); - m_RowStates = RowStates_Deleted; - OSL_TRACE("deleteRow out, m_nRowPos = %u", m_nRowPos ); -} - -void SAL_CALL OResultSet::cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - OSL_TRACE("cancelRowUpdates, m_nRowPos = %u", m_nRowPos ); - if (fetchRow(getCurrentCardNumber(),sal_True)) //force fetch current row will cause we lose all change to the current row - m_pStatement->getOwnConnection()->throwSQLException( STR_CAN_NOT_CANCEL_ROW_UPDATE, *this ); -} - -void SAL_CALL OResultSet::moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - OSL_TRACE("moveToInsertRow in, m_nRowPos = %u", m_nRowPos ); - ResultSetEntryGuard aGuard( *this ); - m_nOldRowPos = m_nRowPos; - - if (!m_nNewRow) //no new row now, insert one - { - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - checkPendingUpdate(); - if (rowUpdated()) - { - if (m_nRowPos && !pushCard(getCurrentCardNumber())) - throw SQLException(); - } - m_nNewRow = m_aQuery.createNewCard(); - if (!m_nNewRow) - m_pStatement->getOwnConnection()->throwSQLException( STR_CAN_NOT_CREATE_ROW, *this ); - - m_RowStates = RowStates_Normal; - fillKeySet(m_nNewRow); - } - else - m_nUpdatedRow = 0; - - m_nRowPos = static_cast<sal_uInt32>(m_pKeySet->get().size()); - fetchCurrentRow(); - OSL_TRACE("moveToInsertRow out, m_nRowPos = %u", m_nRowPos ); -} - -void SAL_CALL OResultSet::moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - ResultSetEntryGuard aGuard( *this ); - OSL_TRACE("moveToCurrentRow, m_nRowPos = %u", m_nRowPos ); - if (rowInserted()) - { - m_nRowPos = m_nOldRowPos; - fetchCurrentRow(); - } -} - -sal_Bool OResultSet::determineReadOnly() -{ - if (m_bIsReadOnly == -1) - { - OConnection* xConnection = static_cast<OConnection*>(m_pStatement->getConnection().get()); - m_bIsReadOnly = !m_aQuery.isWritable(xConnection) || m_bIsAlwaysFalseQuery; - } - - return m_bIsReadOnly != 0; -} - -void OResultSet::setTable(OTable* _rTable) -{ - OSL_TRACE("In : setTable"); - m_pTable = _rTable; - m_pTable->acquire(); - m_xTableColumns = m_pTable->getColumns(); - if(m_xTableColumns.is()) - m_aColumnNames = m_xTableColumns->getElementNames(); - OSL_TRACE("Out : setTable"); -} - -void OResultSet::setOrderByColumns(const ::std::vector<sal_Int32>& _aColumnOrderBy) -{ - m_aOrderbyColumnNumber = _aColumnOrderBy; -} - -void OResultSet::setOrderByAscending(const ::std::vector<TAscendingOrder>& _aOrderbyAsc) -{ - m_aOrderbyAscending = _aOrderbyAsc; -} -Sequence< sal_Int32 > SAL_CALL OResultSet::deleteRows( const Sequence< Any >& /*rows*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XDeleteRows::deleteRows", *this ); - return Sequence< sal_Int32 >(); -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MResultSet.hxx b/connectivity/source/drivers/mozab/MResultSet.hxx deleted file mode 100644 index e4f2e07310d6..000000000000 --- a/connectivity/source/drivers/mozab/MResultSet.hxx +++ /dev/null @@ -1,359 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MRESULTSET_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MRESULTSET_HXX - -#include <com/sun/star/sdbc/XResultSet.hpp> -#include <com/sun/star/sdbc/XRow.hpp> -#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> -#include <com/sun/star/sdbc/XCloseable.hpp> -#include <com/sun/star/sdbc/XColumnLocate.hpp> -#include <com/sun/star/util/XCancellable.hpp> -#include <com/sun/star/sdbc/XWarningsSupplier.hpp> -#include <com/sun/star/sdbc/XResultSetUpdate.hpp> -#include <com/sun/star/sdbcx/XRowLocate.hpp> -#include <com/sun/star/sdbcx/XDeleteRows.hpp> -#include <com/sun/star/sdbc/XRowUpdate.hpp> -#include <cppuhelper/compbase.hxx> -#include <comphelper/proparrhlp.hxx> -#include "MStatement.hxx" -#include <connectivity/CommonTools.hxx> -#include <connectivity/FValue.hxx> -#include <connectivity/sqliterator.hxx> -#include "TSortIndex.hxx" -#include "mozillasrc/MQuery.hxx" - - -namespace connectivity -{ - namespace mozab - { - - /* - ** java_sql_ResultSet - */ - typedef ::cppu::WeakComponentImplHelper< ::com::sun::star::sdbc::XResultSet, - ::com::sun::star::sdbc::XRow, - ::com::sun::star::sdbc::XResultSetMetaDataSupplier, - ::com::sun::star::util::XCancellable, - ::com::sun::star::sdbc::XWarningsSupplier, - ::com::sun::star::sdbc::XCloseable, - ::com::sun::star::sdbc::XColumnLocate, - ::com::sun::star::sdbc::XResultSetUpdate, - ::com::sun::star::sdbc::XRowUpdate, - ::com::sun::star::sdbcx::XRowLocate, - ::com::sun::star::sdbcx::XDeleteRows, - ::com::sun::star::lang::XServiceInfo> OResultSet_BASE; - - - typedef sal_Int64 TVoidPtr; - typedef ::std::allocator< TVoidPtr > TVoidAlloc; - typedef ::std::vector<TVoidPtr> TVoidVector; - - class OResultSet : public comphelper::OBaseMutex, - public OResultSet_BASE, - public ::cppu::OPropertySetHelper, - public ::comphelper::OPropertyArrayUsageHelper<OResultSet> - { - protected: - OCommonStatement* m_pStatement; - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> m_xStatement; - ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData; - sal_uInt32 m_nRowPos; - sal_uInt32 m_nOldRowPos; - sal_Bool m_bWasNull; - sal_Int32 m_nFetchSize; - sal_Int32 m_nResultSetType; - sal_Int32 m_nFetchDirection; - sal_Int32 m_nResultSetConcurrency; - - - - std::shared_ptr< ::connectivity::OSQLParseTreeIterator > - m_pSQLIterator; - const connectivity::OSQLParseNode* m_pParseTree; - - // OPropertyArrayUsageHelper - virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; - // OPropertySetHelper - virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); - - virtual sal_Bool SAL_CALL convertFastPropertyValue( - ::com::sun::star::uno::Any & rConvertedValue, - ::com::sun::star::uno::Any & rOldValue, - sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue ) - throw (::com::sun::star::lang::IllegalArgumentException); - virtual void SAL_CALL setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue - ) - throw (::com::sun::star::uno::Exception); - virtual void SAL_CALL getFastPropertyValue( - ::com::sun::star::uno::Any& rValue, - sal_Int32 nHandle - ) const; - - // you can't delete objects of this type - virtual ~OResultSet(); - public: - DECLARE_SERVICE_INFO(); - - OResultSet(OCommonStatement* pStmt, const std::shared_ptr< ::connectivity::OSQLParseTreeIterator >& _pSQLIterator ); - - - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > operator *() - { - return ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(*(OResultSet_BASE*)this); - } - - // ::cppu::OComponentHelper - virtual void SAL_CALL disposing(); - // XInterface - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL acquire() throw(); - virtual void SAL_CALL release() throw(); - //XTypeProvider - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - // XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - // XResultSet - virtual sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL isBeforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL isAfterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL isFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL isLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL beforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL afterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL last( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL previous( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL refreshRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL rowUpdated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL rowInserted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL rowDeleted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - // XRow - virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - // XResultSetMetaDataSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - // XCancellable - virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException); - // XCloseable - virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - // XWarningsSupplier - virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - // XColumnLocate - virtual sal_Int32 SAL_CALL findColumn( const OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - - // XResultSetUpdate - virtual void SAL_CALL insertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL updateRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL deleteRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - // XRowUpdate - virtual void SAL_CALL updateNull( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL updateString( sal_Int32 columnIndex, const OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL updateBytes( sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - // XRowLocate - virtual ::com::sun::star::uno::Any SAL_CALL getBookmark( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL moveToBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL compareBookmarks( const ::com::sun::star::uno::Any& first, const ::com::sun::star::uno::Any& second ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL hashBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - // XDeleteRows - virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL deleteRows( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - -protected: - MQuery m_aQuery; - OTable* m_pTable; - sal_Int32 m_CurrentRowCount; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > - m_xTableColumns; - - ::std::vector<sal_Int32> m_aColMapping; // pos 0 is unused so we don't have to decrement 1 every time - ::std::vector<sal_Int32> m_aOrderbyColumnNumber; - ::std::vector<TAscendingOrder> m_aOrderbyAscending; - ::com::sun::star::uno::Sequence< OUString> m_aColumnNames; - OValueRow m_aRow; - OValueRow m_aParameterRow; - ::std::vector< OUString> m_aAttributeStrings; - sal_Int32 m_nParamIndex; - sal_Bool m_bIsAlwaysFalseQuery; - ::rtl::Reference<OKeySet> m_pKeySet; - OSortIndex* m_pSortIndex; - sal_Int32 m_nNewRow; //inserted row - sal_Int32 m_nUpdatedRow; //updated row - sal_Int32 m_RowStates; - sal_Int32 m_bIsReadOnly; - inline void resetParameters() { m_nParamIndex = 0; } - - ::rtl::Reference<connectivity::OSQLColumns> m_xColumns; // this are the select columns - ::rtl::Reference<connectivity::OSQLColumns> m_xParamColumns; - - void parseParameter( const OSQLParseNode* pNode, OUString& rMatchString ); - void fillRowData() throw( ::com::sun::star::sdbc::SQLException ); - void analyseWhereClause( const OSQLParseNode* parseTree, - MQueryExpression &queryExpression); - - sal_Bool isCount() const; - - sal_Bool IsSorted() const { return !m_aOrderbyColumnNumber.empty(); } - - enum eRowPosition { - NEXT_POS, PRIOR_POS, FIRST_POS, LAST_POS, ABSOLUTE_POS, RELATIVE_POS - }; - - sal_uInt32 currentRowCount(); - - sal_Bool fetchRow(sal_Int32 rowIndex,sal_Bool bForceReload=sal_False) throw( ::com::sun::star::sdbc::SQLException, - ::com::sun::star::uno::RuntimeException); - sal_Bool fetchCurrentRow() throw( ::com::sun::star::sdbc::SQLException, - ::com::sun::star::uno::RuntimeException); - sal_Bool pushCard(sal_uInt32 rowIndex) throw( ::com::sun::star::sdbc::SQLException, - ::com::sun::star::uno::RuntimeException); - sal_Bool validRow( sal_uInt32 nRow ); - sal_Bool seekRow( eRowPosition pos, sal_Int32 nOffset = 0 ); - sal_Int32 deletedCount(); - sal_Bool fillKeySet(sal_Int32 nMaxCardNumber); //When we get new rows, fill the m_pKeySet items for them - sal_Int32 getRowForCardNumber(sal_Int32 nCardNum); - const ORowSetValue& getValue(sal_Int32 rowIndex, sal_Int32 columnIndex) - throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - - void updateValue(sal_Int32 columnIndex,const ORowSetValue& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - void checkPendingUpdate() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - sal_Int32 getCurrentCardNumber(); - -public: - sal_Bool determineReadOnly(); - // MozAddressbook Specific methods - void SAL_CALL executeQuery() throw( ::com::sun::star::sdbc::SQLException, - ::com::sun::star::uno::RuntimeException); - - void setTable(OTable* _rTable); - - void setParameterRow(const OValueRow& _rParaRow) - { m_aParameterRow = _rParaRow; } - - void setParameterColumns(const ::rtl::Reference<connectivity::OSQLColumns>& _xParamColumns) - { m_xParamColumns = _xParamColumns; } - - void setBindingRow(const OValueRow& _aRow) - { m_aRow = _aRow; } - - void setColumnMapping(const ::std::vector<sal_Int32>& _aColumnMapping); - - void setOrderByColumns(const ::std::vector<sal_Int32>& _aColumnOrderBy); - - void setOrderByAscending(const ::std::vector<TAscendingOrder>& _aOrderbyAsc); - - inline sal_Int32 mapColumn(sal_Int32 column); - - void checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException); - - static void setBoundedColumns( - const OValueRow& _rRow, - const ::rtl::Reference<connectivity::OSQLColumns>& _rxColumns, - const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xNames, - sal_Bool _bSetColumnMapping, - const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& _xMetaData, - ::std::vector<sal_Int32>& _rColMapping); - - ::osl::Mutex& getMutex() { return m_aMutex; } - void methodEntry(); - - private: - inline void impl_ensureKeySet() - { - if ( !m_pKeySet.is() ) - m_pKeySet = new OKeySet(); - } - - protected: - using OPropertySetHelper::getFastPropertyValue; - }; - - inline sal_Int32 OResultSet::mapColumn(sal_Int32 column) - { - sal_Int32 map = column; - - OSL_ENSURE(column > 0, "OResultSet::mapColumn: invalid column index!"); - // the first column (index 0) is for convenience only. The - // first real select column is no 1. - if ((column > 0) && (column < (sal_Int32)m_aColMapping.size())) - map = m_aColMapping[column]; - - return map; - } - - class ResultSetEntryGuard : public ::osl::MutexGuard - { - public: - explicit ResultSetEntryGuard( OResultSet& _rRS ) : ::osl::MutexGuard( _rRS.getMutex() ) - { - _rRS.methodEntry(); - } - }; - - } -} -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MRESULTSET_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MResultSetMetaData.cxx b/connectivity/source/drivers/mozab/MResultSetMetaData.cxx deleted file mode 100644 index cc2f2539f77b..000000000000 --- a/connectivity/source/drivers/mozab/MResultSetMetaData.cxx +++ /dev/null @@ -1,203 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <connectivity/dbexception.hxx> -#include <connectivity/dbtools.hxx> -#include <comphelper/types.hxx> -#include <comphelper/extract.hxx> -#include <cppuhelper/typeprovider.hxx> -#include <tools/diagnose_ex.h> -#include "MResultSetMetaData.hxx" -#include <com/sun/star/sdbc/DataType.hpp> - -using namespace connectivity::mozab; -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::sdbc; -using namespace com::sun::star::beans; -using namespace ::dbtools; -using namespace ::comphelper; - - -OResultSetMetaData::~OResultSetMetaData() -{ - m_xColumns = NULL; -} - - -void OResultSetMetaData::checkColumnIndex(sal_Int32 column) throw(SQLException, RuntimeException) -{ - if(column <= 0 || column > (sal_Int32)(sal_Int32)m_xColumns->get().size()) - throwInvalidIndexException(*this); -} - -sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - return getPrecision(column); -} - - -sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException) -{ - return DataType::VARCHAR; // at the moment there exists only this type -} - - -sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException) -{ - return static_cast<sal_Int32>((m_xColumns->get()).size()); -} - - -sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - - -OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException) -{ - return OUString(); -} - - -OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - checkColumnIndex(column); - - OUString sColumnName; - try - { - Reference< XPropertySet > xColumnProps( (m_xColumns->get())[column-1], UNO_QUERY_THROW ); - OSL_VERIFY( xColumnProps->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_NAME ) ) >>= sColumnName ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - return sColumnName; -} - -OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException) -{ - return m_aTableName; -} - -OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException) -{ - return OUString(); -} - -OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - checkColumnIndex(column); - return getString((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME))); -} - -OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - return getColumnName(column); -} - -OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException) -{ - return OUString(); -} - - -sal_Bool SAL_CALL OResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - checkColumnIndex(column); - return getBOOL((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY))); -} - - -sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException) -{ - return sal_False; -} - -sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - checkColumnIndex(column); - return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))); -} - -sal_Int32 SAL_CALL OResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - checkColumnIndex(column); - return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE))); -} - - -sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - checkColumnIndex(column); - return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE))); -} - - -sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - OUString sColumnName( getColumnName( column ) ); - - if ( !m_pTable || !m_pTable->getConnection() ) - { - OSL_FAIL( "OResultSetMetaData::isSearchable: suspicious: called without table or connection!" ); - return sal_False; - } - - if ( m_pTable->getConnection()->isLDAP() ) - { - const OColumnAlias& aAliases( m_pTable->getConnection()->getColumnAlias() ); - if ( !aAliases.isColumnSearchable( sColumnName ) ) - return sal_False; - } - - return sal_True; -} - - -sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - checkColumnIndex(column); - sal_Bool bReadOnly = (m_xColumns->get())[column-1]->getPropertySetInfo()->hasPropertyByName(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION)) && - ::cppu::any2bool((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION))); - - return m_bReadOnly || bReadOnly || m_pTable->isReadOnly(); -} - - -sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - return !isReadOnly(column); -} - -sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - return !isReadOnly(column); -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MResultSetMetaData.hxx b/connectivity/source/drivers/mozab/MResultSetMetaData.hxx deleted file mode 100644 index d62e42c4c277..000000000000 --- a/connectivity/source/drivers/mozab/MResultSetMetaData.hxx +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MRESULTSETMETADATA_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MRESULTSETMETADATA_HXX - -#include <com/sun/star/sdbc/XResultSetMetaData.hpp> -#include <cppuhelper/implbase.hxx> -#include <vector> -#include <rtl/ref.hxx> -#include "MConnection.hxx" -#include "MTable.hxx" - -namespace connectivity -{ - namespace mozab - { - - //************ Class: ResultSetMetaData - - typedef ::cppu::WeakImplHelper< ::com::sun::star::sdbc::XResultSetMetaData> OResultSetMetaData_BASE; - - class OResultSetMetaData : public OResultSetMetaData_BASE - { - OUString m_aTableName; - ::rtl::Reference<connectivity::OSQLColumns> m_xColumns; - OTable* m_pTable; - sal_Bool m_bReadOnly; - - protected: - virtual ~OResultSetMetaData(); - public: - // a constructor that is needed to return the object: - // OResultSetMetaData(OConnection* _pConnection) : m_pConnection(_pConnection){} - OResultSetMetaData(const ::rtl::Reference<connectivity::OSQLColumns>& _rxColumns, - const OUString& _aTableName,OTable* _pTable,sal_Bool aReadOnly - ) - :m_aTableName(_aTableName) - ,m_xColumns(_rxColumns) - ,m_pTable(_pTable) - ,m_bReadOnly(aReadOnly) - {} - - - /// Avoid ambigous cast error from the compiler. - inline operator ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > () throw() - { return this; } - - void checkColumnIndex(sal_Int32 column) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getColumnCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getColumnLabel( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getColumnName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getSchemaName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getTableName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getCatalogName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getColumnTypeName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getColumnServiceName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MRESULTSETMETADATA_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MServices.cxx b/connectivity/source/drivers/mozab/MServices.cxx deleted file mode 100644 index cbe2f70fee1c..000000000000 --- a/connectivity/source/drivers/mozab/MServices.cxx +++ /dev/null @@ -1,148 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include "MDriver.hxx" -#include <cppuhelper/factory.hxx> -#include <osl/diagnose.h> -#include <com/sun/star/mozilla/XMozillaBootstrap.hpp> -#include "bootstrap/MMozillaBootstrap.hxx" -#include <tools/solar.h> - -using namespace connectivity::mozab; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; -using ::com::sun::star::lang::XSingleServiceFactory; -using ::com::sun::star::lang::XMultiServiceFactory; -using ::com::sun::star::mozilla::XMozillaBootstrap; - -typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc) - ( - const Reference< XMultiServiceFactory > & rServiceManager, - const OUString & rComponentName, - ::cppu::ComponentInstantiation pCreateFunction, - const Sequence< OUString > & rServiceNames, - rtl_ModuleCount* - ); - - -struct ProviderRequest -{ - Reference< XSingleServiceFactory > xRet; - Reference< XMultiServiceFactory > const xServiceManager; - OUString const sImplementationName; - - ProviderRequest( - void* pServiceManager, - sal_Char const* pImplementationName - ) - : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager)) - , sImplementationName(OUString::createFromAscii(pImplementationName)) - { - } - - inline - sal_Bool CREATE_PROVIDER( - const OUString& Implname, - const Sequence< OUString > & Services, - ::cppu::ComponentInstantiation Factory, - createFactoryFunc creator - ) - { - if (!xRet.is() && (Implname == sImplementationName)) - try - { - xRet = creator( xServiceManager, sImplementationName,Factory, Services,0); - } - catch(...) - { - } - return xRet.is(); - } - - void* getProvider() const { return xRet.get(); } -}; - - -typedef void* (SAL_CALL * OMozillaBootstrap_CreateInstanceFunction)(const Reference< XMultiServiceFactory >& _rxFactory ); -::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createMozillaBootstrap(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception ) -{ - const OUString sModuleName(SVLIBRARY( "mozabdrv" )); - - // load the dbtools library - oslModule s_hModule = osl_loadModuleRelative( - reinterpret_cast< oslGenericFunction >(&createMozillaBootstrap), - sModuleName.pData, 0); - OSL_ENSURE(NULL != s_hModule, "MozabDriver::registerClient: could not load the dbtools library!"); - if (NULL != s_hModule) - { - - // get the symbol for the method creating the factory - const OUString sFactoryCreationFunc = "OMozillaBootstrap_CreateInstance"; - // reinterpret_cast<OMozabConnection_CreateInstanceFunction> removed GNU C - OMozillaBootstrap_CreateInstanceFunction s_pCreationFunc = (OMozillaBootstrap_CreateInstanceFunction)osl_getFunctionSymbol(s_hModule, sFactoryCreationFunc.pData); - - if (NULL == s_pCreationFunc) - { // did not find the symbol - OSL_FAIL("MozabDriver::registerClient: could not find the symbol for creating the factory!"); - osl_unloadModule(s_hModule); - s_hModule = NULL; - } - MozillaBootstrap * pBootstrap = reinterpret_cast<MozillaBootstrap*>((*s_pCreationFunc)(_rxFactory)); - return *pBootstrap; - } - return NULL; -} - -extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL mozab_component_getFactory( - const sal_Char* pImplementationName, - void* pServiceManager, - void* /*pRegistryKey*/) -{ - void* pRet = 0; - if (pServiceManager) - { - OUString aImplName( OUString::createFromAscii( pImplementationName ) ); - ProviderRequest aReq(pServiceManager,pImplementationName); - if (aImplName.equals( MozabDriver::getImplementationName_Static() )) - { - aReq.CREATE_PROVIDER( - MozabDriver::getImplementationName_Static(), - MozabDriver::getSupportedServiceNames_Static(), - MozabDriver_CreateInstance, ::cppu::createSingleFactory); - } - else if ( aImplName == "com.sun.star.comp.mozilla.MozillaBootstrap" ) - { - Sequence< OUString > aSNS( 1 ); - aSNS[0] = "com.sun.star.mozilla.MozillaBootstrap"; - aReq.CREATE_PROVIDER( - aImplName, - aSNS, - createMozillaBootstrap, ::cppu::createSingleFactory); - } - if(aReq.xRet.is()) - aReq.xRet->acquire(); - pRet = aReq.getProvider(); - } - - return pRet; -}; - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MStatement.cxx b/connectivity/source/drivers/mozab/MStatement.cxx deleted file mode 100644 index 251ec0a765ba..000000000000 --- a/connectivity/source/drivers/mozab/MStatement.cxx +++ /dev/null @@ -1,563 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <osl/diagnose.h> -#include <comphelper/property.hxx> -#include <comphelper/uno3.hxx> -#include <osl/thread.h> -#include <tools/diagnose_ex.h> -#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> -#include <com/sun/star/sdbc/ResultSetType.hpp> -#include <com/sun/star/sdbc/FetchDirection.hpp> -#include <com/sun/star/lang/DisposedException.hpp> -#include <comphelper/sequence.hxx> -#include <cppuhelper/typeprovider.hxx> -#include <cppuhelper/queryinterface.hxx> -#include <comphelper/extract.hxx> -#include <comphelper/types.hxx> -#include <comphelper/processfactory.hxx> -#include <connectivity/dbexception.hxx> -#include <com/sun/star/container/XIndexAccess.hpp> - -#include <algorithm> - -#include "MDriver.hxx" -#include "MStatement.hxx" -#include "MConnection.hxx" -#include "MResultSet.hxx" -#include "MDatabaseMetaData.hxx" -#include "resource/mozab_res.hrc" -#include "resource/common_res.hrc" -#include "sqlbison.hxx" - -#if OSL_DEBUG_LEVEL > 0 -# define OUtoCStr( x ) ( OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr()) -#else /* OSL_DEBUG_LEVEL */ -# define OUtoCStr( x ) ("dummy") -#endif /* OSL_DEBUG_LEVEL */ - -static ::osl::Mutex m_ThreadMutex; - -using namespace ::comphelper; -using namespace connectivity::mozab; -using namespace connectivity; - -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::beans; -using namespace com::sun::star::sdbc; -using namespace com::sun::star::container; -using namespace com::sun::star::io; -using namespace com::sun::star::util; - -OCommonStatement::OCommonStatement(OConnection* _pConnection ) - :OCommonStatement_IBASE(m_aMutex) - ,OPropertySetHelper(OCommonStatement_IBASE::rBHelper) - ,OCommonStatement_SBASE((::cppu::OWeakObject*)_pConnection, this) - ,m_xDBMetaData(_pConnection->getMetaData()) - ,m_pTable(NULL) - ,m_pConnection(_pConnection) - ,m_aParser(::comphelper::getComponentContext( - _pConnection->getDriver()->getMSFactory())) - ,m_pSQLIterator( new OSQLParseTreeIterator( _pConnection, _pConnection->createCatalog()->getTables(), m_aParser, NULL ) ) - ,m_pParseTree(NULL) - ,rBHelper(OCommonStatement_IBASE::rBHelper) -{ - m_pConnection->acquire(); - OSL_TRACE("In/Out: OCommonStatement::OCommonStatement" ); -} - -OCommonStatement::~OCommonStatement() -{ -} - - -void OCommonStatement::disposing() -{ - ::osl::MutexGuard aGuard(m_aMutex); - - clearWarnings(); - clearCachedResultSet(); - - if (m_pConnection) - m_pConnection->release(); - m_pConnection = NULL; - - m_pSQLIterator->dispose(); - delete m_pParseTree; - - dispose_ChildImpl(); - OCommonStatement_IBASE::disposing(); -} - -Any SAL_CALL OCommonStatement::queryInterface( const Type & rType ) throw(RuntimeException) -{ - Any aRet = OCommonStatement_IBASE::queryInterface(rType); - if(!aRet.hasValue()) - aRet = OPropertySetHelper::queryInterface(rType); - return aRet; -} - -Sequence< Type > SAL_CALL OCommonStatement::getTypes( ) throw(RuntimeException) -{ - ::cppu::OTypeCollection aTypes( cppu::UnoType<XMultiPropertySet>::get(), - cppu::UnoType<XFastPropertySet>::get(), - cppu::UnoType<XPropertySet>::get()); - - return ::comphelper::concatSequences(aTypes.getTypes(),OCommonStatement_IBASE::getTypes()); -} - -void SAL_CALL OCommonStatement::close( ) throw(SQLException, RuntimeException) -{ - { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); - } - dispose(); -} - - - -void OCommonStatement::createTable( ) throw ( SQLException, RuntimeException ) -{ - if(m_pParseTree) - { - ::rtl::Reference<connectivity::OSQLColumns> xCreateColumn; - if (m_pSQLIterator->getStatementType() == SQL_STATEMENT_CREATE_TABLE) - { - const OSQLTables& xTabs = m_pSQLIterator->getTables(); - OSL_ENSURE( !xTabs.empty(), "Need a Table"); - OUString ouTableName=xTabs.begin()->first; - xCreateColumn = m_pSQLIterator->getCreateColumns(); - OSL_ENSURE(xCreateColumn.is(), "Need the Columns!!"); - - const OColumnAlias& aColumnAlias = m_pConnection->getColumnAlias(); - - OSQLColumns::Vector::const_iterator aIter = xCreateColumn->get().begin(); - const OUString sProprtyName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME); - OUString sName; - for (sal_Int32 i = 1; aIter != xCreateColumn->get().end();++aIter, i++) - { - (*aIter)->getPropertyValue(sProprtyName) >>= sName; - if ( !aColumnAlias.hasAlias( sName ) ) - { - - const OUString sError( getOwnConnection()->getResources().getResourceStringWithSubstitution( - STR_INVALID_COLUMNNAME, - "$columnname$", sName - ) ); - ::dbtools::throwGenericSQLException(sError,*this); - } - } - MDatabaseMetaDataHelper _aDbHelper; - if (!_aDbHelper.NewAddressBook(m_pConnection,ouTableName)) - { - getOwnConnection()->throwSQLException( _aDbHelper.getError(), *this ); - } - m_pSQLIterator.reset( new ::connectivity::OSQLParseTreeIterator( - m_pConnection, m_pConnection->createCatalog()->getTables(), m_aParser, NULL ) ); - } - - } - else - getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this ); -} - -OCommonStatement::StatementType OCommonStatement::parseSql( const OUString& sql , sal_Bool bAdjusted) - throw ( SQLException, RuntimeException ) -{ - OUString aErr; - - m_pParseTree = m_aParser.parseTree(aErr,sql); - -#if OSL_DEBUG_LEVEL > 0 - { - OSL_TRACE("ParseSQL: %s", OUtoCStr( sql ) ); - } -#endif // OSL_DEBUG_LEVEL - - if(m_pParseTree) - { - m_pSQLIterator->setParseTree(m_pParseTree); - m_pSQLIterator->traverseAll(); - const OSQLTables& xTabs = m_pSQLIterator->getTables(); - if(xTabs.empty()) - getOwnConnection()->throwSQLException( STR_QUERY_AT_LEAST_ONE_TABLES, *this ); - -#if OSL_DEBUG_LEVEL > 0 - OSQLTables::const_iterator citer; - for( citer = xTabs.begin(); citer != xTabs.end(); ++citer ) { - OSL_TRACE("SELECT Table : %s", OUtoCStr(citer->first) ); - } -#endif - - Reference<XIndexAccess> xNames; - switch(m_pSQLIterator->getStatementType()) - { - case SQL_STATEMENT_SELECT: - - // at this moment we support only one table per select statement - - OSL_ENSURE( xTabs.begin() != xTabs.end(), "Need a Table"); - - m_pTable = static_cast< OTable* > (xTabs.begin()->second.get()); - m_xColNames = m_pTable->getColumns(); - xNames = Reference<XIndexAccess>(m_xColNames,UNO_QUERY); - // set the binding of the resultrow - m_aRow = new OValueVector(xNames->getCount()); - (m_aRow->get())[0].setBound(sal_True); - ::std::for_each(m_aRow->get().begin()+1,m_aRow->get().end(),TSetBound(sal_False)); - // create the column mapping - createColumnMapping(); - - analyseSQL(); - return eSelect; - - case SQL_STATEMENT_CREATE_TABLE: - createTable(); - return eCreateTable; - - default: - break; - } - } - else if(!bAdjusted) //Our sql parser does not support a statement like "create table foo" - // So we append ("E-mail" varchar) to the last of it to make it work - { - return parseSql(sql + "(""E-mail"" character)",sal_True); - } - - getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this ); - OSL_FAIL( "OCommonStatement::parseSql: unreachable!" ); - return eSelect; - -} - -Reference< XResultSet > OCommonStatement::impl_executeCurrentQuery() -{ - clearCachedResultSet(); - - ::rtl::Reference< OResultSet > pResult( new OResultSet( this, m_pSQLIterator ) ); - initializeResultSet( pResult.get() ); - - pResult->executeQuery(); - cacheResultSet( pResult ); // only cache if we survived the execution - - return pResult.get(); - -} - - -void OCommonStatement::initializeResultSet( OResultSet* _pResult ) -{ - ENSURE_OR_THROW( _pResult, "invalid result set" ); - - _pResult->setColumnMapping(m_aColMapping); - _pResult->setOrderByColumns(m_aOrderbyColumnNumber); - _pResult->setOrderByAscending(m_aOrderbyAscending); - _pResult->setBindingRow(m_aRow); - _pResult->setTable(m_pTable); -} - - -void OCommonStatement::clearCachedResultSet() -{ - Reference< XResultSet > xResultSet( m_xResultSet.get(), UNO_QUERY ); - if ( !xResultSet.is() ) - return; - - try - { - Reference< XCloseable > xCloseable( xResultSet, UNO_QUERY_THROW ); - xCloseable->close(); - } - catch( const DisposedException& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - - m_xResultSet.clear(); -} - - -void OCommonStatement::cacheResultSet( const ::rtl::Reference< OResultSet >& _pResult ) -{ - ENSURE_OR_THROW( _pResult.is(), "invalid result set" ); - m_xResultSet = Reference< XResultSet >( _pResult.get() ); -} - - -sal_Bool SAL_CALL OCommonStatement::execute( const OUString& sql ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); - - OSL_TRACE("Statement::execute( %s )", OUtoCStr( sql ) ); - - Reference< XResultSet > xRS = executeQuery( sql ); - // returns true when a resultset is available - return xRS.is(); -} - - -Reference< XResultSet > SAL_CALL OCommonStatement::executeQuery( const OUString& sql ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_ThreadMutex ); - checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); - - OSL_TRACE("Statement::executeQuery( %s )", OUtoCStr( sql ) ); - - // parse the statement - StatementType eStatementType = parseSql( sql ); - if ( eStatementType != eSelect ) - return NULL; - - return impl_executeCurrentQuery(); -} - - -Reference< XConnection > SAL_CALL OCommonStatement::getConnection( ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); - - // just return our connection here - return (Reference< XConnection >)m_pConnection; -} - -Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException) -{ - Any aRet = ::cppu::queryInterface(rType,static_cast< XServiceInfo*> (this)); - if(!aRet.hasValue()) - aRet = OCommonStatement::queryInterface(rType); - return aRet; -} - -sal_Int32 SAL_CALL OCommonStatement::executeUpdate( const OUString& /*sql*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XStatement::executeUpdate", *this ); - return 0; - -} - -Any SAL_CALL OCommonStatement::getWarnings( ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); - - return makeAny(m_aLastWarning); -} - - - -void SAL_CALL OCommonStatement::clearWarnings( ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); - - - m_aLastWarning = SQLWarning(); -} - -::cppu::IPropertyArrayHelper* OCommonStatement::createArrayHelper( ) const -{ - // this properties are define by the service resultset - // they must in alphabetic order - Sequence< Property > aProps(9); - Property* pProperties = aProps.getArray(); - sal_Int32 nPos = 0; - pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CURSORNAME), - PROPERTY_ID_CURSORNAME, cppu::UnoType<OUString>::get(), 0); - pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ESCAPEPROCESSING), - PROPERTY_ID_ESCAPEPROCESSING, cppu::UnoType<bool>::get(), 0); - pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), - PROPERTY_ID_FETCHDIRECTION, cppu::UnoType<sal_Int32>::get(), 0); - pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), - PROPERTY_ID_FETCHSIZE, cppu::UnoType<sal_Int32>::get(), 0); - pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MAXFIELDSIZE), - PROPERTY_ID_MAXFIELDSIZE, cppu::UnoType<sal_Int32>::get(), 0); - pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MAXROWS), - PROPERTY_ID_MAXROWS, cppu::UnoType<sal_Int32>::get(), 0); - pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_QUERYTIMEOUT), - PROPERTY_ID_QUERYTIMEOUT, cppu::UnoType<sal_Int32>::get(), 0); - pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), - PROPERTY_ID_RESULTSETCONCURRENCY, cppu::UnoType<sal_Int32>::get(), 0); - pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), - PROPERTY_ID_RESULTSETTYPE, cppu::UnoType<sal_Int32>::get(), 0); - - return new ::cppu::OPropertyArrayHelper(aProps); -} - - -::cppu::IPropertyArrayHelper & OCommonStatement::getInfoHelper() -{ - return *const_cast<OCommonStatement*>(this)->getArrayHelper(); -} - -sal_Bool OCommonStatement::convertFastPropertyValue( - Any & /*rConvertedValue*/, - Any & /*rOldValue*/, - sal_Int32 /*nHandle*/, - const Any& /*rValue*/ ) - throw (::com::sun::star::lang::IllegalArgumentException) -{ - sal_Bool bConverted = sal_False; - // here we have to try to convert - return bConverted; -} - -void OCommonStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& /*rValue*/) throw (Exception) -{ - // set the value to whatever is necessary - switch(nHandle) - { - case PROPERTY_ID_QUERYTIMEOUT: - case PROPERTY_ID_MAXFIELDSIZE: - case PROPERTY_ID_MAXROWS: - case PROPERTY_ID_RESULTSETCONCURRENCY: - case PROPERTY_ID_RESULTSETTYPE: - case PROPERTY_ID_FETCHDIRECTION: - case PROPERTY_ID_FETCHSIZE: - case PROPERTY_ID_ESCAPEPROCESSING: - default: - ; - } -} - -void OCommonStatement::getFastPropertyValue(Any& /*rValue*/,sal_Int32 nHandle) const -{ - switch(nHandle) - { - case PROPERTY_ID_QUERYTIMEOUT: - case PROPERTY_ID_MAXFIELDSIZE: - case PROPERTY_ID_MAXROWS: - case PROPERTY_ID_RESULTSETCONCURRENCY: - case PROPERTY_ID_RESULTSETTYPE: - case PROPERTY_ID_FETCHDIRECTION: - case PROPERTY_ID_FETCHSIZE: - case PROPERTY_ID_ESCAPEPROCESSING: - default: - ; - } -} - -IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbcx.OStatement","com.sun.star.sdbc.Statement"); - -void SAL_CALL OCommonStatement::acquire() throw() -{ - OCommonStatement_IBASE::acquire(); -} - -void SAL_CALL OCommonStatement::release() throw() -{ - relase_ChildImpl(); -} - -void SAL_CALL OStatement::acquire() throw() -{ - OCommonStatement::acquire(); -} - -void SAL_CALL OStatement::release() throw() -{ - OCommonStatement::release(); -} - -Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OCommonStatement::getPropertySetInfo( ) throw(RuntimeException) -{ - return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); -} - -void OCommonStatement::createColumnMapping() -{ - size_t i; - - // initialize the column index map (mapping select columns to table columns) - ::rtl::Reference<connectivity::OSQLColumns> xColumns = m_pSQLIterator->getSelectColumns(); - m_aColMapping.resize(xColumns->get().size() + 1); - for (i=0; i<m_aColMapping.size(); ++i) - m_aColMapping[i] = static_cast<sal_Int32>(i); - - Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY); - // now check which columns are bound -#if OSL_DEBUG_LEVEL > 0 - for ( i = 0; i < m_aColMapping.size(); i++ ) - OSL_TRACE("BEFORE Mapped: %d -> %d", i, m_aColMapping[i] ); -#endif - OResultSet::setBoundedColumns(m_aRow,xColumns,xNames,sal_True,m_xDBMetaData,m_aColMapping); -#if OSL_DEBUG_LEVEL > 0 - for ( i = 0; i < m_aColMapping.size(); i++ ) - OSL_TRACE("AFTER Mapped: %d -> %d", i, m_aColMapping[i] ); -#endif -} - - -void OCommonStatement::analyseSQL() -{ - const OSQLParseNode* pOrderbyClause = m_pSQLIterator->getOrderTree(); - if(pOrderbyClause) - { - OSQLParseNode * pOrderingSpecCommalist = pOrderbyClause->getChild(2); - OSL_ENSURE(SQL_ISRULE(pOrderingSpecCommalist,ordering_spec_commalist),"OResultSet: Fehler im Parse Tree"); - - for (sal_uInt32 m = 0; m < pOrderingSpecCommalist->count(); m++) - { - OSQLParseNode * pOrderingSpec = pOrderingSpecCommalist->getChild(m); - OSL_ENSURE(SQL_ISRULE(pOrderingSpec,ordering_spec),"OResultSet: Fehler im Parse Tree"); - OSL_ENSURE(pOrderingSpec->count() == 2,"OResultSet: Fehler im Parse Tree"); - - OSQLParseNode * pColumnRef = pOrderingSpec->getChild(0); - if(!SQL_ISRULE(pColumnRef,column_ref)) - { - throw SQLException(); - } - OSQLParseNode * pAscendingDescending = pOrderingSpec->getChild(1); - setOrderbyColumn(pColumnRef,pAscendingDescending); - } - } -} - -void OCommonStatement::setOrderbyColumn( OSQLParseNode* pColumnRef, - OSQLParseNode* pAscendingDescending) -{ - OUString aColumnName; - if (pColumnRef->count() == 1) - aColumnName = pColumnRef->getChild(0)->getTokenValue(); - else if (pColumnRef->count() == 3) - { - pColumnRef->getChild(2)->parseNodeToStr( aColumnName, getOwnConnection(), NULL, sal_False, sal_False ); - } - else - { - throw SQLException(); - } - - Reference<XColumnLocate> xColLocate(m_xColNames,UNO_QUERY); - if(!xColLocate.is()) - return; - - m_aOrderbyColumnNumber.push_back(xColLocate->findColumn(aColumnName)); - - // Ascending or Descending? - m_aOrderbyAscending.push_back((SQL_ISTOKEN(pAscendingDescending,DESC)) ? SQL_DESC : SQL_ASC); -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MStatement.hxx b/connectivity/source/drivers/mozab/MStatement.hxx deleted file mode 100644 index 1a9a35a3e29d..000000000000 --- a/connectivity/source/drivers/mozab/MStatement.hxx +++ /dev/null @@ -1,204 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MSTATEMENT_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MSTATEMENT_HXX - -#include <com/sun/star/sdbc/XStatement.hpp> -#include <com/sun/star/sdbc/XWarningsSupplier.hpp> -#include <com/sun/star/sdbc/XBatchExecution.hpp> -#include <com/sun/star/sdbc/XCloseable.hpp> -#include <com/sun/star/sdbc/SQLWarning.hpp> -#include <comphelper/proparrhlp.hxx> -#include <cppuhelper/compbase.hxx> -#include <comphelper/uno3.hxx> -#include <connectivity/CommonTools.hxx> -#include <list> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <comphelper/broadcasthelper.hxx> -#include <connectivity/sqliterator.hxx> -#include <connectivity/sqlparse.hxx> -#include <connectivity/FValue.hxx> -#include "TSortIndex.hxx" -#include "MConnection.hxx" -#include "MTable.hxx" - -#include <memory> - -namespace connectivity -{ - namespace mozab - { - class OResultSet; - - typedef ::cppu::WeakComponentImplHelper< ::com::sun::star::sdbc::XStatement, - ::com::sun::star::sdbc::XWarningsSupplier, - ::com::sun::star::sdbc::XCloseable> OCommonStatement_IBASE; - - - //************ Class: OCommonStatement - // is a base class for the normal statement and for the prepared statement - - class OCommonStatement; - typedef ::connectivity::OSubComponent< OCommonStatement, OCommonStatement_IBASE > OCommonStatement_SBASE; - - class OCommonStatement :public comphelper::OBaseMutex - ,public OCommonStatement_IBASE - ,public ::cppu::OPropertySetHelper - ,public ::comphelper::OPropertyArrayUsageHelper< OCommonStatement > - ,public OCommonStatement_SBASE - { - friend class ::connectivity::OSubComponent< OCommonStatement, OCommonStatement_IBASE >; - - private: - ::com::sun::star::sdbc::SQLWarning m_aLastWarning; - - protected: - ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet > m_xResultSet; - ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> m_xDBMetaData; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xColNames; // table columns - - // for this Statement - - ::std::list< OUString> m_aBatchList; - - OTable* m_pTable; - OConnection* m_pConnection; // The owning Connection object - - OValueRow m_aRow; - - connectivity::OSQLParser m_aParser; - std::shared_ptr< ::connectivity::OSQLParseTreeIterator > - m_pSQLIterator; - - connectivity::OSQLParseNode* m_pParseTree; - - ::std::vector<sal_Int32> m_aColMapping; - ::std::vector<sal_Int32> m_aOrderbyColumnNumber; - ::std::vector<TAscendingOrder> m_aOrderbyAscending; - - ::cppu::OBroadcastHelper& rBHelper; - - protected: - - // OPropertyArrayUsageHelper - virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; - // OPropertySetHelper - virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); - virtual sal_Bool SAL_CALL convertFastPropertyValue( - ::com::sun::star::uno::Any & rConvertedValue, - ::com::sun::star::uno::Any & rOldValue, - sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue ) - throw (::com::sun::star::lang::IllegalArgumentException); - virtual void SAL_CALL setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception); - virtual void SAL_CALL getFastPropertyValue( - ::com::sun::star::uno::Any& rValue, - sal_Int32 nHandle) const; - virtual ~OCommonStatement(); - - protected: - - // Driver Internal Methods - - enum StatementType { eSelect, eCreateTable }; - /** called to do the parsing of a to-be-executed SQL statement, and set all members as needed - */ - virtual StatementType - parseSql( const OUString& sql , sal_Bool bAdjusted = sal_False) throw ( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException ); - /** called to initialize a result set, according to a previously parsed SQL statement - */ - virtual void initializeResultSet( OResultSet* _pResult ); - /** called when a possible cached instance of our last result set should be cleared - */ - virtual void clearCachedResultSet(); - /** caches a result set which has just been created by an execution of an SQL statement - */ - virtual void cacheResultSet( const ::rtl::Reference< OResultSet >& _pResult ); - - - /** executes the current query (the one which has been passed to the last parseSql call) - */ - ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > - impl_executeCurrentQuery(); - - void createColumnMapping(); - void analyseSQL(); - void setOrderbyColumn( connectivity::OSQLParseNode* pColumnRef, - connectivity::OSQLParseNode* pAscendingDescending); - virtual void createTable( ) throw ( - ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException ); - - public: - // other methods - OConnection* getOwnConnection() const { return m_pConnection;} - - explicit OCommonStatement(OConnection* _pConnection ); - using OCommonStatement_IBASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >; - - // OComponentHelper - virtual void SAL_CALL disposing(); - - // XInterface - virtual void SAL_CALL release() throw(); - virtual void SAL_CALL acquire() throw(); - // XInterface - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); - //XTypeProvider - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - - // XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - // XStatement - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; - virtual sal_Int32 SAL_CALL executeUpdate( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; - virtual sal_Bool SAL_CALL execute( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; - // XWarningsSupplier - virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - // XCloseable - virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - - protected: - using OPropertySetHelper::getFastPropertyValue; - }; - - class OStatement : public OCommonStatement, - public ::com::sun::star::lang::XServiceInfo - { - protected: - ~OStatement(){} - public: - // a constructor, for when the object needs to be returned: - explicit OStatement( OConnection* _pConnection) : OCommonStatement( _pConnection){} - DECLARE_SERVICE_INFO(); - - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL acquire() throw(); - virtual void SAL_CALL release() throw(); - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MSTATEMENT_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MTable.cxx b/connectivity/source/drivers/mozab/MTable.cxx deleted file mode 100644 index 52052a4b65d6..000000000000 --- a/connectivity/source/drivers/mozab/MTable.cxx +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "MTable.hxx" -#include "MTables.hxx" -#include "MColumns.hxx" -#include <com/sun/star/sdbc/XRow.hpp> -#include <com/sun/star/sdbc/XResultSet.hpp> -#include <com/sun/star/sdbcx/KeyType.hpp> -#include <com/sun/star/sdbc/KeyRule.hpp> -#include <cppuhelper/typeprovider.hxx> -#include <com/sun/star/lang/DisposedException.hpp> -#include <com/sun/star/sdbc/ColumnValue.hpp> -#include <comphelper/sequence.hxx> -#include <comphelper/extract.hxx> -#include <comphelper/types.hxx> -#include <connectivity/dbtools.hxx> -#include <connectivity/TKeys.hxx> -#include <connectivity/TIndexes.hxx> -#include "MCatalog.hxx" - - -using namespace ::comphelper; -using namespace connectivity::mozab; -using namespace connectivity; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; - - -OTable::OTable( sdbcx::OCollection* _pTables, OConnection* _pConnection, - const OUString& _Name, const OUString& _Type, const OUString& _Description ) - :OTable_Base(_pTables, _pConnection, sal_True, _Name, _Type, _Description ) - ,m_pConnection( _pConnection ) -{ - construct(); -} - - -sdbcx::OCollection* OTable::createColumns( const TStringVector& _rNames ) -{ - return new OColumns( this, m_aMutex, _rNames ); -} - - -sdbcx::OCollection* OTable::createKeys(const TStringVector& _rNames) -{ - return new OKeysHelper( this, m_aMutex, _rNames ); -} - - -sdbcx::OCollection* OTable::createIndexes(const TStringVector& _rNames) -{ - return new OIndexesHelper( this, m_aMutex, _rNames ); -} - - - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MTable.hxx b/connectivity/source/drivers/mozab/MTable.hxx deleted file mode 100644 index 94f0c54b0dfb..000000000000 --- a/connectivity/source/drivers/mozab/MTable.hxx +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MTABLE_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MTABLE_HXX - -#include <connectivity/TTableHelper.hxx> -#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> -#include "MConnection.hxx" - -namespace connectivity -{ - namespace mozab - { - typedef ::connectivity::OTableHelper OTable_Base; - - class OTable : public OTable_Base - { - OConnection* m_pConnection; - - public: - OTable( sdbcx::OCollection* _pTables, - OConnection* _pConnection, - const OUString& _Name, - const OUString& _Type, - const OUString& _Description ); - - OConnection* getConnection() { return m_pConnection;} - - sal_Bool isReadOnly() const { return sal_False; } - - OUString getTableName() const { return m_Name; } - OUString getSchema() const { return m_SchemaName; } - - // OTableHelper overridables - virtual sdbcx::OCollection* createColumns( const TStringVector& _rNames ); - virtual sdbcx::OCollection* createKeys(const TStringVector& _rNames); - virtual sdbcx::OCollection* createIndexes(const TStringVector& _rNames); - private: - using OTable_Base::getConnection; - }; - } -} -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MTABLE_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MTables.cxx b/connectivity/source/drivers/mozab/MTables.cxx deleted file mode 100644 index 129c84dd493f..000000000000 --- a/connectivity/source/drivers/mozab/MTables.cxx +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "MTables.hxx" -#include "MTable.hxx" -#include <com/sun/star/sdbc/XRow.hpp> -#include <com/sun/star/sdbc/XResultSet.hpp> -#include <com/sun/star/sdbc/ColumnValue.hpp> -#include <com/sun/star/sdbc/KeyRule.hpp> -#include <com/sun/star/sdbcx/KeyType.hpp> -#include "MCatalog.hxx" -#include "MConnection.hxx" -#include <comphelper/extract.hxx> -#include <connectivity/dbtools.hxx> -#include <connectivity/dbexception.hxx> -#include <cppuhelper/interfacecontainer.h> -#include <comphelper/types.hxx> - -using namespace ::comphelper; -using namespace connectivity; -using namespace ::cppu; -using namespace connectivity::mozab; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; -using namespace dbtools; - -sdbcx::ObjectType OTables::createObject(const OUString& _rName) -{ - OUString aName,aSchema; - aSchema = "%"; - aName = _rName; - - Sequence< OUString > aTypes(1); - aTypes[0] = "%"; - - Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),aSchema,aName,aTypes); - - sdbcx::ObjectType xRet = NULL; - if(xResult.is()) - { - Reference< XRow > xRow(xResult,UNO_QUERY); - if(xResult->next()) // there can be only one table with this name - { - OTable* pRet = new OTable( this, static_cast<OCatalog&>(m_rParent).getConnection(), - aName,xRow->getString(4),xRow->getString(5)); - xRet = pRet; - } - } - ::comphelper::disposeComponent(xResult); - - return xRet; -} - -void OTables::impl_refresh( ) throw(RuntimeException) -{ - static_cast<OCatalog&>(m_rParent).refreshTables(); -} - -void OTables::disposing() -{ -m_xMetaData.clear(); - OCollection::disposing(); -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/MTables.hxx b/connectivity/source/drivers/mozab/MTables.hxx deleted file mode 100644 index dbd694b3ef73..000000000000 --- a/connectivity/source/drivers/mozab/MTables.hxx +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MTABLES_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MTABLES_HXX - -#include <connectivity/sdbcx/VCollection.hxx> -#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> -namespace connectivity -{ - namespace mozab - { - class OTables : public sdbcx::OCollection - { - ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; - // OCatalog* m_pParent; - protected: - virtual sdbcx::ObjectType createObject(const OUString& _rName); - virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); - public: - OTables(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rMetaData,::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, - const TStringVector &_rVector) : sdbcx::OCollection(_rParent,sal_True,_rMutex,_rVector) - ,m_xMetaData(_rMetaData) - {} - - // only the name is identical to ::cppu::OComponentHelper - virtual void SAL_CALL disposing(); - }; - } -} -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MTABLES_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx index a7586fbc47a0..8505d48cb8cf 100644 --- a/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx +++ b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx @@ -18,20 +18,21 @@ */ #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <cppuhelper/factory.hxx> #include <cppuhelper/supportsservice.hxx> #include "MMozillaBootstrap.hxx" +#include "MNSFolders.hxx" +#include "MNSProfileDiscover.hxx" using namespace com::sun::star::uno; using namespace com::sun::star::lang; using namespace com::sun::star::mozilla; using namespace connectivity::mozab; -#include "MNSFolders.hxx" -#include "MNSProfileDiscover.hxx" -#ifndef MINIMAL_PROFILEDISCOVER -# include "MNSProfileManager.hxx" -# include "MNSRunnable.hxx" -#endif -#include "MNSInit.hxx" + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::lang::XSingleServiceFactory; +using ::com::sun::star::lang::XMultiServiceFactory; static MozillaBootstrap *pMozillaBootstrap=NULL; static Reference<XMozillaBootstrap> xMozillaBootstrap; @@ -61,14 +62,7 @@ void MozillaBootstrap::Init() { bool aProfileExists=false; -#ifndef MINIMAL_PROFILEDISCOVER - //This must be call before any mozilla code - MNS_Init(aProfileExists); - - m_ProfileManager = new ProfileManager(); -#else (void)aProfileExists; /* avoid warning about unused parameter */ -#endif m_ProfileAccess = new ProfileAccess(); bootupProfile(::com::sun::star::mozilla::MozillaProductType_Mozilla,OUString()); } @@ -143,85 +137,40 @@ sal_Bool SAL_CALL MozillaBootstrap::getProfileExists( ::com::sun::star::mozilla: // XProfileManager ::sal_Int32 SAL_CALL MozillaBootstrap::bootupProfile( ::com::sun::star::mozilla::MozillaProductType product, const OUString& profileName ) throw (::com::sun::star::uno::RuntimeException, std::exception) { -#ifndef MINIMAL_PROFILEDISCOVER - return m_ProfileManager->bootupProfile(product,profileName); -#else (void)product; /* avoid warning about unused parameter */ (void)profileName; /* avoid warning about unused parameter */ return -1; -#endif } ::sal_Int32 SAL_CALL MozillaBootstrap::shutdownProfile( ) throw (::com::sun::star::uno::RuntimeException, std::exception) { -#ifndef MINIMAL_PROFILEDISCOVER - return m_ProfileManager->shutdownProfile(); -#else return -1; -#endif } ::com::sun::star::mozilla::MozillaProductType SAL_CALL MozillaBootstrap::getCurrentProduct( ) throw (::com::sun::star::uno::RuntimeException, std::exception) { -#ifndef MINIMAL_PROFILEDISCOVER - return m_ProfileManager->getCurrentProduct(); -#else return ::com::sun::star::mozilla::MozillaProductType_Default; -#endif } OUString SAL_CALL MozillaBootstrap::getCurrentProfile( ) throw (::com::sun::star::uno::RuntimeException, std::exception) { -#ifndef MINIMAL_PROFILEDISCOVER - return m_ProfileManager->getCurrentProfile(); -#else return OUString(); -#endif } sal_Bool SAL_CALL MozillaBootstrap::isCurrentProfileLocked( ) throw (::com::sun::star::uno::RuntimeException, std::exception) { -#ifndef MINIMAL_PROFILEDISCOVER - return isProfileLocked(getCurrentProduct(),m_ProfileManager->getCurrentProfile()); -#else return true; -#endif } OUString SAL_CALL MozillaBootstrap::setCurrentProfile( ::com::sun::star::mozilla::MozillaProductType product, const OUString& profileName ) throw (::com::sun::star::uno::RuntimeException, std::exception) { -#ifndef MINIMAL_PROFILEDISCOVER - return m_ProfileManager->setCurrentProfile(product,profileName); -#else (void)product; /* avoid warning about unused parameter */ (void)profileName; /* avoid warning about unused parameter */ return OUString(); -#endif } // XProxyRunner ::sal_Int32 SAL_CALL MozillaBootstrap::Run( const ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XCodeProxy >& aCode ) throw (::com::sun::star::uno::RuntimeException, std::exception) { -#ifndef MINIMAL_PROFILEDISCOVER - OUString profileName = aCode->getProfileName(); - OUString currProfileName = getCurrentProfile(); - ::com::sun::star::mozilla::MozillaProductType currProduct = getCurrentProduct(); - - //if client provides a profileName, we will use it - if (!profileName.isEmpty() - && ( aCode->getProductType() != currProduct || !profileName.equals(currProfileName)) ) - setCurrentProfile(aCode->getProductType(),profileName); - MNSRunnable xRunnable; - - return xRunnable.StartProxy(aCode); -#else (void)aCode; /* avoid warning about unused parameter */ return -1; -#endif } -#ifdef MINIMAL_PROFILEDISCOVER -#include <cppuhelper/factory.hxx> -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; -using ::com::sun::star::lang::XSingleServiceFactory; -using ::com::sun::star::lang::XMultiServiceFactory; - static Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& rServiceManager ) { MozillaBootstrap * pBootstrap = static_cast<MozillaBootstrap*>(OMozillaBootstrap_CreateInstance(rServiceManager)); @@ -258,6 +207,5 @@ extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL mozbootstrap_component_getFactory return pRet; }; -#endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSFolders.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSFolders.cxx index 0abfad7f8918..d9aae76d7fc4 100644 --- a/connectivity/source/drivers/mozab/bootstrap/MNSFolders.cxx +++ b/connectivity/source/drivers/mozab/bootstrap/MNSFolders.cxx @@ -26,12 +26,10 @@ #endif // End UNIX #ifdef WNT -#include "pre_include_windows.h" #include <windows.h> #include <stdlib.h> #include <shlobj.h> #include <objidl.h> -#include "post_include_windows.h" #endif // End WNT #include <osl/security.hxx> #include <osl/file.hxx> diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSInit.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSInit.cxx deleted file mode 100644 index d06aedc0d5ce..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSInit.cxx +++ /dev/null @@ -1,329 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "mozillasrc/MNSInclude.hxx" - -#include "mozilla_nsinit.h" - -#include "MNSInit.hxx" - -#include <sal/types.h> -#include <osl/diagnose.h> -#include <osl/conditn.hxx> -#include <osl/file.hxx> -#include <rtl/bootstrap.hxx> - -#include "MConfigAccess.hxx" -#include "mozillasrc/MNSDeclares.hxx" -#include <osl/thread.hxx> -#include "mozillasrc/MNSTerminateListener.hxx" - -static nsIServiceManager* sServiceManager = nsnull; -static sal_Int32 sInitCounter = 0; -static bool s_bProfilePresentAfterInitialized = false; - -static NS_DEFINE_CID(kProfileCID, NS_PROFILE_CID); -static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); - -static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); -static PRBool aLive=1; -static ::osl::Condition m_aUI_Thread_Condition; - -#define HACK_AROUND_THREADING_ISSUES -#define HACK_AROUND_NONREENTRANT_INITXPCOM - -#ifdef HACK_AROUND_NONREENTRANT_INITXPCOM -// XXX hack class to clean up XPCOM when this module is unloaded -static PRBool sXPCOMInitializedFlag = PR_FALSE; -#endif - - -extern "C" void NS_SetupRegistry(); - - const PRUnichar* determineProfile( PRUnichar const* const* _pValidProfiles, const PRUint32 _nValidProfiles ) -{ - // the fallback for the to-be-used user profile: the first profile - const PRUnichar* pUsedProfile = *_pValidProfiles; - - // have a look what the configuration suggests as preferred profile - // PRUnichar != sal_Unicode in mingw - const PRUnichar* pPreferredProfile = reinterpret_cast_mingw_only< const PRUnichar* >( getUserProfile( ) ); - if ( pPreferredProfile && *pPreferredProfile ) - { - PRUnichar const* const* pLoop = _pValidProfiles; - PRUnichar const* const* pLoopEnd = pLoop + _nValidProfiles; - for ( ; pLoop != pLoopEnd; ++pLoop ) - { - // compare the current and the preferred profile - // (by looping through the characters) - const PRUnichar* pCurrent = *pLoop; - const PRUnichar* pPref = pPreferredProfile; - while ( *pCurrent && ( *pCurrent == *pPref ) ) // testing one of them against 0 is enough because of the second clause - { - ++pCurrent; - ++pPref; - } - if ( *pCurrent == *pPref ) - // the are equal - break; - } - - if ( pLoop != pLoopEnd ) - pUsedProfile = *pLoop; - return pUsedProfile; - } - else - return NULL; -} - - -bool MNS_InitXPCOM(bool* aProfileExists) -{ - nsresult rv; - OSL_TRACE( "IN : MNS_InitXPCOM()" ); - // Reentrant calls to this method do nothing except increment a counter - -#ifdef HACK_AROUND_NONREENTRANT_INITXPCOM - // The first time, add another increment so that it'll be left until exit - // for the final cleanup to happen - sInitCounter++; -#endif // HACK_AROUND_NONREENTRANT_INITXPCOM - - // Initialise XPCOM -#ifdef HACK_AROUND_NONREENTRANT_INITXPCOM - // Can't call NS_InitXPCom more than once or things go boom! - if (!sXPCOMInitializedFlag) -#endif - { - nsCOMPtr<nsILocalFile> binDir; - // Note: if path3 construction fails, mozilla will default to using MOZILLA_FIVE_HOME in the NS_InitXPCOM2() - OUString path1("$BRAND_BASE_DIR/program"); - rtl::Bootstrap::expandMacros(path1); - OString path2; - if ((osl::FileBase::getSystemPathFromFileURL(path1, path1) == - osl::FileBase::E_None) && - path1.convertToString( - &path2, osl_getThreadTextEncoding(), - (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR | - RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR))) - { - nsDependentCString sPath(path2.getStr()); - rv = NS_NewNativeLocalFile(sPath, PR_TRUE, getter_AddRefs(binDir)); - if (NS_FAILED(rv)) - return false; - } - - - - // Initialise XPCOM - NS_InitXPCOM2(&sServiceManager, binDir, NULL); - -// if (!sServiceManager) -// return false; - -#ifdef HACK_AROUND_NONREENTRANT_INITXPCOM - sXPCOMInitializedFlag = PR_TRUE; -#endif - } - - - // Create the Event Queue for the UI thread... - - // If an event queue already exists for the thread, then - // CreateThreadEventQueue(...) will fail... - // CreateThread0ueue(...) will fail... - nsCOMPtr<nsIEventQueueService> eventQService( - do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv)); - if (NS_FAILED(rv)) - return NS_SUCCEEDED( rv ) ? true : false; - - eventQService->CreateThreadEventQueue(); - -// nsCOMPtr<nsIObserver> mStartupNotifier = do_CreateInstance(NS_APPSTARTUPNOTIFIER_CONTRACTID, &rv); -// if(NS_FAILED(rv)) -// return rv; -// mStartupNotifier->Observe(nsnull, APPSTARTUP_TOPIC, nsnull); - -#ifdef HACK_AROUND_THREADING_ISSUES - // XXX force certain objects to be created on the main thread - nsCOMPtr<nsIStringBundleService> sBundleService; - sBundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv); - if (NS_SUCCEEDED(rv)) - { - nsCOMPtr<nsIStringBundle> stringBundle; - const char* propertyURL = "chrome://necko/locale/necko.properties"; - rv = sBundleService->CreateBundle(propertyURL, - getter_AddRefs(stringBundle)); - } -#endif - - // Need to create a Pref Service - nsCOMPtr< nsIPref > thePref = do_GetService( kPrefCID, &rv ); - if (NS_SUCCEEDED(rv) ) - { - OSL_TRACE("Created an nsIPref i/f"); - thePref->ReadUserPrefs( nsnull ); - *aProfileExists = true; - s_bProfilePresentAfterInitialized = true; - } - OSL_TRACE( "OUT : MNS_InitXPCOM() - XPCOM Init" ); - - return true; -} - -void MNS_XPCOM_EventLoop() -{ - OSL_TRACE( "IN : MNS_XPCOM_EventLoop()" ); - nsresult rv; - nsCOMPtr<nsIEventQueue> eventQ; - nsCOMPtr<nsIEventQueueService> eventQService; - rv=nsServiceManager::GetService(kEventQueueServiceCID, - NS_GET_IID(nsIEventQueueService), - getter_AddRefs(eventQService)); - - if (NS_SUCCEEDED(rv)) - { - rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD , getter_AddRefs(eventQ)); - if (NS_FAILED(rv)) - { - rv = eventQService->CreateThreadEventQueue(); - if (NS_FAILED(rv)) - return ; - else - rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(eventQ)); - } - } - - if (NS_FAILED(rv)) return ; - - PLEvent* event = nsnull; - m_aUI_Thread_Condition.set(); //we are ready to receive event - do - { - rv = eventQ->GetEvent(&event); - if (NS_FAILED(rv)) - return ; - if (event) - eventQ->HandleEvent(event); - }while ( PR_SUCCESS == PR_Sleep( PR_MillisecondsToInterval(20)) && aLive ); - - eventQ->ProcessPendingEvents(); - OSL_TRACE( "OUT : MNS_XPCOM_EventLoop()" ); -} - -extern "C" void MNS_Mozilla_UI_Thread( void *arg ) -{ - osl_setThreadName("MNS_Mozilla_UI_Thread"); - - aLive=1; - OSL_TRACE( "IN : MNS_Mozilla_UI_Thread()" ); - UI_Thread_ARGS * args = (UI_Thread_ARGS*) arg; - bool* aProfileExists=args->bProfileExists; - delete args; - args=NULL; - - //Init xpcom - if (!MNS_InitXPCOM(aProfileExists)) - { - m_aUI_Thread_Condition.set(); // error happened - return; - } - - //do the mozilla event loop - MNS_XPCOM_EventLoop(); - //we are interrupted - - if (sServiceManager) - { - NS_RELEASE(sServiceManager); - - // Terminate XPCOM & cleanup -#ifndef HACK_AROUND_NONREENTRANT_INITXPCOM - NS_ShutdownXPCOM(sServiceManager); -#endif - } - - m_aUI_Thread_Condition.set(); //release all blocks - - OSL_TRACE( "OUT : MNS_Mozilla_UI_Thread()" ); - -} - - -bool MNS_Init(bool& aProfileExists) -{ - aProfileExists = false; - - OSL_TRACE( "IN : MNS_Init()" ); - // Reentrant calls to this method do nothing except increment a counter - sInitCounter++; - if (sInitCounter > 1) { - OSL_TRACE( "IN : MNS_Init() wait for xpcom to be initted" ); - //wait for xpcom to be initted - m_aUI_Thread_Condition.wait(); - - OSL_TRACE( "OUT : MNS_Init() : counter = %d", sInitCounter ); - aProfileExists = s_bProfilePresentAfterInitialized; - return true; - } - - UI_Thread_ARGS * args = new UI_Thread_ARGS; - args->bProfileExists = &aProfileExists; - - m_aUI_Thread_Condition.reset(); - if (osl_createThread(MNS_Mozilla_UI_Thread, (void*)args) == 0) - { - return false; - } - - //wait for xpcom to be initted - m_aUI_Thread_Condition.wait(); - - //Add Terminate Listener to XDesktop to get application exit event - MNSTerminateListener::addTerminateListener(); - - OSL_TRACE( "OUT : MNS_Init() - First Init" ); - - return true; -} - -bool MNS_Term(bool aForce) -{ - // Reentrant calls to this method do nothing except decrement a counter - OSL_TRACE( "IN : MNS_Term()" ); - if (!aForce && sInitCounter > 1) - { - --sInitCounter; - OSL_TRACE( "OUT : MNS_Term() : counter = %d", sInitCounter ); - return true; - } - sInitCounter = 0; - - aLive=0; - - //wait for xpcom to be finished - TimeValue timeValue = { 1, 0 }; - m_aUI_Thread_Condition.wait(&timeValue); - - - OSL_TRACE( "OUT : MNS_Term() - Final Term" ); - return true; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSInit.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSInit.hxx deleted file mode 100644 index ca8a3344e4af..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSInit.hxx +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSINIT_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSINIT_HXX -#include "mozillasrc/MNSDeclares.hxx" - -#include <sal/types.h> - -bool MNS_Init(bool& aProfileExists); -bool MNS_Term(bool aForce = false); - -bool MNS_InitXPCOM(bool* aProfileExists); - -typedef struct UI_Thread_ARGS -{ - bool* bProfileExists; -} UI_Thread_ARGS; - -void MNS_XPCOM_EventLoop(); - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSINIT_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfile.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfile.cxx deleted file mode 100644 index e6b66ae735db..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSProfile.cxx +++ /dev/null @@ -1,624 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include "MNSProfile.hxx" -#include "MNSProfileDirServiceProvider.hxx" - -#include <com/sun/star/uno/Reference.hxx> -#include <com/sun/star/uno/Sequence.hxx> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <comphelper/processfactory.hxx> -#include <com/sun/star/mozilla/XMozillaBootstrap.hpp> -#include <osl/diagnose.h> - -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::mozilla; - - -// Interfaces Needed - -static Reference<XMozillaBootstrap> xMozillaBootstrap; - - -static PRInt32 gInstanceCount = 0; - -// Profile database to remember which profile has been -// created with UILocale and contentLocale on profileManager -static nsProfileDirServiceProvider *gDirServiceProvider = nsnull; - - - - -/* - * Constructor/Destructor - */ -nsProfile::nsProfile() -{ - mStartingUp = PR_FALSE; - mCurrentProfileAvailable = PR_FALSE; - - mShutdownProfileToreDownNetwork = PR_FALSE; - - mProfileChangeVetoed = PR_FALSE; - mProfileChangeFailed = PR_FALSE; - Reference<XMultiServiceFactory> xFactory = ::comphelper::getProcessServiceFactory(); - OSL_ENSURE( xFactory.is(), "can't get service factory" ); - - Reference<XInterface> xInstance = xFactory->createInstance("com.sun.star.mozilla.MozillaBootstrap"); - OSL_ENSURE( xInstance.is(), "failed to create instance" ); - xMozillaBootstrap = Reference<XMozillaBootstrap>(xInstance,UNO_QUERY); - - -} - -nsProfile::~nsProfile() -{ -} - - -nsresult -nsProfile::Init() -{ - nsresult rv = NS_OK; - RegisterProfileManager(this); - if (gInstanceCount++ == 0) { - rv = NS_NewProfileDirServiceProvider( &gDirServiceProvider); - if (NS_SUCCEEDED(rv)) - rv = gDirServiceProvider->Register(); - } - return rv; -} - -/* - * nsISupports Implementation - */ -NS_IMPL_THREADSAFE_ADDREF(nsProfile) -NS_IMPL_THREADSAFE_RELEASE(nsProfile) - -NS_INTERFACE_MAP_BEGIN(nsProfile) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIProfile) - NS_INTERFACE_MAP_ENTRY(nsIProfile) - NS_INTERFACE_MAP_ENTRY(nsIProfileInternal) - NS_INTERFACE_MAP_ENTRY(nsIProfileChangeStatus) - NS_INTERFACE_MAP_ENTRY(nsIFactory) -NS_INTERFACE_MAP_END - -/* - * nsIProfileChangeStatus Implementation - */ - -NS_IMETHODIMP nsProfile::VetoChange() -{ - mProfileChangeVetoed = PR_TRUE; - return NS_OK; -} - -NS_IMETHODIMP nsProfile::ChangeFailed() -{ - mProfileChangeFailed = PR_TRUE; - return NS_OK; -} -/* - * nsIProfile Implementation - */ - -NS_IMETHODIMP nsProfile::GetProfileCount(PRInt32 *numProfiles) -{ - NS_ENSURE_ARG_POINTER(numProfiles); - - *numProfiles = 0; - - *numProfiles = xMozillaBootstrap->getProfileCount(xMozillaBootstrap->getCurrentProduct()); - return NS_OK; -} -NS_IMETHODIMP nsProfile::GetProfileList(PRUint32 *length, PRUnichar ***profileNames) -{ - NS_ENSURE_ARG_POINTER(length); - NS_ENSURE_ARG_POINTER(profileNames); - *profileNames = nsnull; - - ::com::sun::star::uno::Sequence< OUString > list; - - *length = xMozillaBootstrap->getProfileList(xMozillaBootstrap->getCurrentProduct(),list); - - const OUString * pArray = list.getConstArray(); - - nsresult rv = NS_OK; - PRInt32 count = list.getLength(); - PRUnichar **outArray, **next; - - next = outArray = (PRUnichar **)nsMemory::Alloc(count * sizeof(PRUnichar *)); - if (!outArray) - return NS_ERROR_OUT_OF_MEMORY; - - for (PRInt32 index=0; index < count; index++) - { - *next = (PRUnichar *)nsMemory::Clone(pArray[index].getStr(),(pArray[index].getLength()+1) * sizeof(PRUnichar )); - if (*next == nsnull) - { - rv = NS_ERROR_OUT_OF_MEMORY; - break; - } - next++; - } - *profileNames = outArray; - return rv; -} -NS_IMETHODIMP nsProfile::ProfileExists(const PRUnichar *profileName, PRBool *exists) -{ - NS_ENSURE_ARG_POINTER(profileName); - NS_ENSURE_ARG_POINTER(exists); - - // PRUnichar != sal_Unicode in mingw - *exists = xMozillaBootstrap->getProfileExists(xMozillaBootstrap->getCurrentProduct(),reinterpret_cast_mingw_only<const sal_Unicode *>(profileName)); - return NS_OK; -} -// Returns the name of the current profile i.e., the last used profile -NS_IMETHODIMP -nsProfile::GetCurrentProfile(PRUnichar **profileName) -{ - NS_ENSURE_ARG_POINTER(profileName); - *profileName = nsnull; - - if (mCurrentProfileName.Length()) - *profileName = (PRUnichar *)nsMemory::Clone(mCurrentProfileName.get(),(mCurrentProfileName.Length() + 1) * sizeof(PRUnichar )); - else - { - OUString profile = xMozillaBootstrap->getDefaultProfile(xMozillaBootstrap->getCurrentProduct()); - *profileName = (PRUnichar *)nsMemory::Clone(profile.getStr(),( profile.getLength() + 1) * sizeof(PRUnichar )); - SetCurrentProfile(*profileName); - } - - return (*profileName == nsnull) ? NS_ERROR_FAILURE : NS_OK; -} - -NS_IMETHODIMP -nsProfile::SetCurrentProfile(const PRUnichar * aCurrentProfile) -{ - NS_ENSURE_ARG(aCurrentProfile); - - nsresult rv; - nsCOMPtr<nsIFile> profileDir; - PRBool exists; - - // Ensure that the profile exists and its directory too. - rv = GetProfileDir(aCurrentProfile, getter_AddRefs(profileDir)); - if (NS_FAILED(rv)) return rv; - rv = profileDir->Exists(&exists); - if (NS_FAILED(rv)) return rv; - if (!exists) return NS_ERROR_FILE_NOT_FOUND; - - PRBool isSwitch = PRBool(); - - if (mCurrentProfileAvailable) - { - nsXPIDLString currProfileName; - rv = GetCurrentProfile(getter_Copies(currProfileName)); - if (NS_FAILED(rv)) return rv; - if (nsCRT::strcmp(aCurrentProfile, currProfileName.get()) == 0) - return NS_OK; - else - isSwitch = PR_TRUE; - } - else - isSwitch = PR_FALSE; - - - nsCOMPtr<nsIObserverService> observerService = - do_GetService("@mozilla.org/observer-service;1", &rv); - NS_ENSURE_TRUE(observerService, NS_ERROR_FAILURE); - - nsISupports *subject = (nsISupports *)((nsIProfile *)this); - NS_NAMED_LITERAL_STRING(switchString, "switch"); - NS_NAMED_LITERAL_STRING(startupString, "startup"); - const nsAFlatString& context = isSwitch ? switchString : startupString; - - if (isSwitch) - { - rv = ShutDownCurrentProfile(nsIProfile::SHUTDOWN_PERSIST); - if (NS_FAILED(rv)) return NS_ERROR_ABORT; - - // Phase 1: See if anybody objects to the profile being changed. - mProfileChangeVetoed = PR_FALSE; - observerService->NotifyObservers(subject, "profile-approve-change", context.get()); - if (mProfileChangeVetoed) - return NS_OK; - - // Phase 2a: Send the network teardown notification - observerService->NotifyObservers(subject, "profile-change-net-teardown", context.get()); - mShutdownProfileToreDownNetwork = PR_TRUE; - - // Phase 2b: Send the "teardown" notification - observerService->NotifyObservers(subject, "profile-change-teardown", context.get()); - if (mProfileChangeVetoed) - { - // Notify we will not proceed with changing the profile - observerService->NotifyObservers(subject, "profile-change-teardown-veto", context.get()); - - // Bring network back online and return - observerService->NotifyObservers(subject, "profile-change-net-restore", context.get()); - return NS_OK; - } - - // Phase 3: Notify observers of a profile change - observerService->NotifyObservers(subject, "profile-before-change", context.get()); - if (mProfileChangeFailed) - return NS_ERROR_ABORT; - - } - - -// // Do the profile switch - gDirServiceProvider->SetProfileDir(profileDir); - mCurrentProfileName.Assign(aCurrentProfile); -// gProfileDataAccess->SetCurrentProfile(aCurrentProfile); - - if (NS_FAILED(rv)) return rv; - mCurrentProfileAvailable = PR_TRUE; - - if (!isSwitch) - { - // Ensure that the prefs service exists so it can respond to - // the notifications we're about to send around. It needs to. - nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv); - NS_ASSERTION(NS_SUCCEEDED(rv), "Could not get prefs service"); - } - - if (mShutdownProfileToreDownNetwork) - { - // Bring network back online - observerService->NotifyObservers(subject, "profile-change-net-restore", context.get()); - mShutdownProfileToreDownNetwork = PR_FALSE; - if (mProfileChangeFailed) - return NS_ERROR_ABORT; - } - - // Phase 4: Notify observers that the profile has changed - Here they respond to new profile - observerService->NotifyObservers(subject, "profile-do-change", context.get()); - if (mProfileChangeFailed) - return NS_ERROR_ABORT; - - // Phase 5: Now observers can respond to something another observer did in phase 4 - observerService->NotifyObservers(subject, "profile-after-change", context.get()); - if (mProfileChangeFailed) - return NS_ERROR_ABORT; - - // Phase 6: One last notification after the new profile is established - observerService->NotifyObservers(subject, "profile-initial-state", context.get()); - if (mProfileChangeFailed) - return NS_ERROR_ABORT; - - return NS_OK; -} -/* void shutDownCurrentProfile (in unsigned long shutDownType); */ -NS_IMETHODIMP nsProfile::ShutDownCurrentProfile(PRUint32 shutDownType) -{ - nsresult rv; - - // if shutDownType is not a well know value, skip the notifications - // see DoOnShutdown() in nsAppRunner.cpp for where we use this behaviour to our benefit - if (shutDownType == (PRUint32)SHUTDOWN_PERSIST || shutDownType == (PRUint32)SHUTDOWN_CLEANSE ) { - nsCOMPtr<nsIObserverService> observerService = - do_GetService("@mozilla.org/observer-service;1", &rv); - NS_ENSURE_TRUE(observerService, NS_ERROR_FAILURE); - - nsISupports *subject = (nsISupports *)((nsIProfile *)this); - - NS_NAMED_LITERAL_STRING(cleanseString, "shutdown-cleanse"); - NS_NAMED_LITERAL_STRING(persistString, "shutdown-persist"); - const nsAFlatString& context = (shutDownType == (PRUint32)SHUTDOWN_CLEANSE) ? cleanseString : persistString; - - // Phase 1: See if anybody objects to the profile being changed. - mProfileChangeVetoed = PR_FALSE; - observerService->NotifyObservers(subject, "profile-approve-change", context.get()); - if (mProfileChangeVetoed) - return NS_OK; - - // Phase 2a: Send the network teardown notification - observerService->NotifyObservers(subject, "profile-change-net-teardown", context.get()); - mShutdownProfileToreDownNetwork = PR_TRUE; - - // Phase 2b: Send the "teardown" notification - observerService->NotifyObservers(subject, "profile-change-teardown", context.get()); - - - // Phase 3: Notify observers of a profile change - observerService->NotifyObservers(subject, "profile-before-change", context.get()); - } - - - gDirServiceProvider->SetProfileDir(nsnull); - mCurrentProfileAvailable = PR_FALSE; - mCurrentProfileName.Truncate(0); - - return NS_OK; -} -/* void createNewProfile (in wstring profileName, in wstring nativeProfileDir, in wstring langcode, in boolean useExistingDir); */ -NS_IMETHODIMP nsProfile::CreateNewProfile(const PRUnichar* /*profileName*/, const PRUnichar* /*nativeProfileDir*/, const PRUnichar* /*langcode*/, PRBool /*useExistingDir*/) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void renameProfile (in wstring oldName, in wstring newName); */ -NS_IMETHODIMP nsProfile::RenameProfile(const PRUnichar* /*oldName*/, const PRUnichar* /*newName*/) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void deleteProfile (in wstring name, in boolean canDeleteFiles); */ -NS_IMETHODIMP nsProfile::DeleteProfile(const PRUnichar* /*name*/, PRBool /*canDeleteFiles*/) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void cloneProfile (in wstring profileName); */ -NS_IMETHODIMP nsProfile::CloneProfile(const PRUnichar* /*profileName*/) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} -//nsIProfileInternal Implementation - -/* [noscript] void startupWithArgs (in nsICmdLineService cmdLine, in boolean canInteract); */ -class nsICmdLineService; - -NS_IMETHODIMP nsProfile::StartupWithArgs(nsICmdLineService* /*cmdLineArgs*/, PRBool /*canInteract*/) -{ - Init(); - return NS_OK; -} - -/* [noscript] readonly attribute boolean isStartingUp; */ -NS_IMETHODIMP nsProfile::GetIsStartingUp(PRBool *aIsStartingUp) -{ - NS_ENSURE_ARG_POINTER(aIsStartingUp); - *aIsStartingUp = mStartingUp; - return NS_OK; -} - -/* long get4xProfileCount (); */ -NS_IMETHODIMP nsProfile::Get4xProfileCount(PRInt32* /*_retval*/) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void getProfileListX (in unsigned long which, out unsigned long length, [array, size_is (length), retval] out wstring profileNames); */ -NS_IMETHODIMP nsProfile::GetProfileListX(PRUint32 /*whichKind*/, PRUint32* /*length*/, PRUnichar*** /*profileNames*/) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void migrateProfileInfo (); */ -NS_IMETHODIMP nsProfile::MigrateProfileInfo() -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void migrateAllProfiles (); */ -NS_IMETHODIMP nsProfile::MigrateAllProfiles() -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void migrateProfile (in wstring profileName); */ -NS_IMETHODIMP nsProfile::MigrateProfile(const PRUnichar* /*profileName*/) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void remigrateProfile (in wstring profileName); */ -NS_IMETHODIMP nsProfile::RemigrateProfile(const PRUnichar* /*profileName*/) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void forgetCurrentProfile (); */ -NS_IMETHODIMP nsProfile::ForgetCurrentProfile() -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void createDefaultProfile (); */ -NS_IMETHODIMP nsProfile::CreateDefaultProfile() -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* nsIFile getProfileDir (in wstring profileName); */ -// Gets the profiles directory for a given profile -// Sets the given profile to be a current profile -NS_IMETHODIMP nsProfile::GetProfileDir(const PRUnichar *profileName, nsIFile **profileDir) -{ - NS_ENSURE_ARG(profileName); - NS_ENSURE_ARG_POINTER(profileDir); - *profileDir = nsnull; - - // PRUnichar != sal_Unicode in mingw - OUString path = xMozillaBootstrap->getProfilePath(xMozillaBootstrap->getCurrentProduct(),reinterpret_cast_mingw_only<const sal_Unicode *>(profileName)); - - nsCOMPtr<nsILocalFile> localFile; - // PRUnichar != sal_Unicode in mingw - nsAutoString filePath(reinterpret_cast_mingw_only<const PRUnichar *>(path.getStr())); - - nsresult rv = NS_NewLocalFile(filePath, PR_TRUE, - getter_AddRefs(localFile)); - if (localFile && NS_SUCCEEDED(rv)) - return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)profileDir); - return rv; -} - -/* wstring getProfilePath (in wstring profileName); */ -NS_IMETHODIMP nsProfile::GetProfilePath(const PRUnichar* /*profileName*/, PRUnichar** /*_retval*/) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* nsILocalFile getOriginalProfileDir (in wstring profileName); */ -NS_IMETHODIMP nsProfile::GetOriginalProfileDir(const PRUnichar* /*profileName*/, nsILocalFile** /*originalDir*/) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* PRInt64 getProfileLastModTime (in wstring profileName); */ -NS_IMETHODIMP nsProfile::GetProfileLastModTime(const PRUnichar* /*profileName*/, PRInt64* /*_retval*/) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* attribute boolean automigrate; */ -NS_IMETHODIMP nsProfile::GetAutomigrate(PRBool* /*aAutomigrate*/) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} -NS_IMETHODIMP nsProfile::SetAutomigrate(PRBool /*aAutomigrate*/) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* readonly attribute nsIFile defaultProfileParentDir; */ -NS_IMETHODIMP nsProfile::GetDefaultProfileParentDir(nsIFile** /*aDefaultProfileParentDir*/) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* readonly attribute wstring firstProfile; */ -NS_IMETHODIMP nsProfile::GetFirstProfile(PRUnichar **profileName) -{ - NS_ENSURE_ARG_POINTER(profileName); - - return GetCurrentProfile(profileName); -} - -/* attribute boolean startWithLastUsedProfile; */ -NS_IMETHODIMP nsProfile::GetStartWithLastUsedProfile(PRBool* /*aStartWithLastUsedProfile*/) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} -NS_IMETHODIMP nsProfile::SetStartWithLastUsedProfile(PRBool /*aStartWithLastUsedProfile*/) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* [noscript] void updateRegistry (in nsIFile regName); */ -NS_IMETHODIMP nsProfile::UpdateRegistry(nsIFile* /*regName*/) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* [noscript] void getRegStrings (in wstring profileName, out wstring regString, out wstring regName, out wstring regEmail, out wstring regOption); */ -NS_IMETHODIMP nsProfile::GetRegStrings(const PRUnichar* /*profileName*/, PRUnichar** /*regString*/, PRUnichar** /*regName*/, PRUnichar** /*regEmail*/, PRUnichar** /*regOption*/) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* [noscript] void setRegStrings (in wstring profileName, in wstring regString, in wstring regName, in wstring regEmail, in wstring regOption); */ -NS_IMETHODIMP nsProfile::SetRegStrings(const PRUnichar* /*profileName*/, const PRUnichar* /*regString*/, const PRUnichar* /*regName*/, const PRUnichar* /*regEmail*/, const PRUnichar* /*regOption*/) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* [noscript] string isRegStringSet (in wstring profileName); */ -NS_IMETHODIMP nsProfile::IsRegStringSet(const PRUnichar* /*profileName*/, char** /*_retval*/) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void createNewProfileWithLocales (in wstring profileName, in wstring nativeProfileDir, in wstring UILocale, in wstring contentLocale, in boolean useExistingDir); */ -NS_IMETHODIMP nsProfile::CreateNewProfileWithLocales(const PRUnichar* /*profileName*/, const PRUnichar* /*nativeProfileDir*/, const PRUnichar* /*UILocale*/, const PRUnichar* /*contentLocale*/, PRBool /*useExistingDir*/) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* boolean isCurrentProfileAvailable (); */ -NS_IMETHODIMP nsProfile::IsCurrentProfileAvailable(PRBool *available) -{ - NS_ENSURE_ARG_POINTER(available); - - *available = mCurrentProfileAvailable; - return NS_OK; -} - -/* [noscript] void getCurrentProfileDir (out nsIFile profileDir); */ -// Returns the name of the current profile directory -NS_IMETHODIMP nsProfile::GetCurrentProfileDir(nsIFile **profileDir) -{ - NS_ENSURE_ARG_POINTER(profileDir); - nsresult rv; - - nsXPIDLString profileName; - rv = GetCurrentProfile(getter_Copies(profileName)); - if (NS_FAILED(rv)) return rv; - - rv = GetProfileDir(profileName, profileDir); - if (NS_FAILED(rv)) return rv; - - return NS_OK; -} - -//Implementation nsIFactory -NS_IMETHODIMP -nsProfile::LockFactory(PRBool /*aVal*/) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsProfile::CreateInstance(nsISupports* aOuter, const nsID& aIID, - void** aResult) -{ - if (aOuter) - return NS_ERROR_NO_AGGREGATION; - // return this object - return QueryInterface(aIID, aResult); -} - -//Register profile manager -#include "pre_include_mozilla.h" -#include "nsIComponentManager.h" -#include "nsIComponentRegistrar.h" -#include "post_include_mozilla.h" - -static const nsCID kProfileManagerCID = NS_PROFILE_CID; - -#define NS_PROFILE_CONTRACTID \ - "@mozilla.org/profile/manager;1" - -nsresult -nsProfile::RegisterProfileManager(nsIProfile* aProfileService) -{ - nsCOMPtr<nsIServiceManager> mgr; - NS_GetServiceManager(getter_AddRefs(mgr)); - - NS_ASSERTION(mgr, "Not initialized!"); - - nsCOMPtr<nsIFactory> factory = do_QueryInterface(aProfileService); - NS_ASSERTION(factory, "Supposed to be an nsIFactory!"); - - nsCOMPtr<nsIComponentRegistrar> reg (do_QueryInterface(mgr)); - if (!reg) - return NS_ERROR_NO_INTERFACE; - - return reg->RegisterFactory(kProfileManagerCID, - "Profile Manager", - NS_PROFILE_CONTRACTID, - factory); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfile.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfile.hxx deleted file mode 100644 index 7d9e5bdba2ea..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSProfile.hxx +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSPROFILE_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSPROFILE_HXX - -#include "mozilla_nsprofile.h" - - -class nsProfile: public nsIProfileInternal, - public nsIProfileChangeStatus, - public nsIFactory -{ - NS_DECL_ISUPPORTS - NS_DECL_NSIPROFILE - NS_DECL_NSIPROFILEINTERNAL - NS_DECL_NSIPROFILECHANGESTATUS - NS_DECL_NSIFACTORY - -private: - PRBool mStartingUp; - PRBool mProfileChangeVetoed; - PRBool mProfileChangeFailed; - - nsString mCurrentProfileName; - PRBool mCurrentProfileAvailable; - - PRBool mIsContentLocaleSpecified; - nsCString mContentLocaleName; - - PRBool mShutdownProfileToreDownNetwork; - nsresult Init(); - -public: - nsProfile(); - virtual ~nsProfile(); - -public: - //We register a factory for Mozilla profile service, its CID and CONTRACTID are NS_PROFILE_CID and NS_PROFILE_CONTRACTID - //After that, we do not need profile.dll/libprofile.so any more. Our profile service is different from the original one in - //these areas: - //1. We do not lock Mozilla Profile, - //2. We do not change Mozilla Profile settings. We do not change default profile, do not create new profiles and - // do not write changes back to profile register - //3. We can load both Thunderbird profile and Mozilla profile - static nsresult RegisterProfileManager(nsIProfile* aProfileService); - -}; - -extern nsresult ConvertStringToUnicode(nsCString& aCharset, const char* inString, nsAString& outString); -extern nsresult GetPlatformCharset(nsCString& aCharset); - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSPROFILE_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.cxx deleted file mode 100644 index 1b251e0f9aa7..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.cxx +++ /dev/null @@ -1,232 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#if defined _MSC_VER - #pragma warning(disable:4710) -#endif - -#include "pre_include_mozilla.h" -#include "MNSProfileDirServiceProvider.hxx" -#include "nsIAtom.h" -#include "nsStaticAtom.h" -#include "nsILocalFile.h" -#include "nsDirectoryServiceDefs.h" -#include "nsAppDirectoryServiceDefs.h" -#include "nsISupportsUtils.h" -#include "post_include_mozilla.h" - - - -#define PREFS_FILE_50_NAME NS_LITERAL_CSTRING("prefs.js") - - -nsIAtom* nsProfileDirServiceProvider::sApp_PrefsDirectory50; -nsIAtom* nsProfileDirServiceProvider::sApp_PreferencesFile50; -nsIAtom* nsProfileDirServiceProvider::sApp_UserProfileDirectory50; - - - -// nsProfileDirServiceProvider::nsProfileDirServiceProvider - - -nsProfileDirServiceProvider::nsProfileDirServiceProvider() -{ -} - - -nsProfileDirServiceProvider::~nsProfileDirServiceProvider() -{ -} - -nsresult -nsProfileDirServiceProvider::SetProfileDir(nsIFile* aProfileDir) -{ - if (mProfileDir) { - PRBool isEqual; - if (aProfileDir && - NS_SUCCEEDED(aProfileDir->Equals(mProfileDir, &isEqual)) && isEqual) { - NS_WARNING("Setting profile dir to same as current"); - return NS_OK; - } - UndefineFileLocations(); - } - mProfileDir = aProfileDir; - if (!mProfileDir) - return NS_OK; - - nsresult rv = EnsureProfileFileExists(mProfileDir); - return rv; - -} - -nsresult -nsProfileDirServiceProvider::Register() -{ - nsCOMPtr<nsIDirectoryService> directoryService = - do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID); - if (!directoryService) - return NS_ERROR_FAILURE; - return directoryService->RegisterProvider(this); -} - -nsresult -nsProfileDirServiceProvider::Shutdown() -{ - nsCOMPtr<nsIDirectoryService> directoryService = - do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID); - if (!directoryService) - return NS_ERROR_FAILURE; - return directoryService->UnregisterProvider(this); -} - -// nsProfileDirServiceProvider::nsISupports - -NS_IMPL_THREADSAFE_ISUPPORTS1(nsProfileDirServiceProvider, - nsIDirectoryServiceProvider) - -// nsProfileDirServiceProvider::nsIDirectoryServiceProvider - -NS_IMETHODIMP -nsProfileDirServiceProvider::GetFile(const char *prop, PRBool *persistent, nsIFile **_retval) -{ - NS_ENSURE_ARG(prop); - NS_ENSURE_ARG_POINTER(persistent); - NS_ENSURE_ARG_POINTER(_retval); - - if (!mProfileDir) - return NS_ERROR_FAILURE; - - *persistent = PR_TRUE; - nsIFile* domainDir = mProfileDir; - - - nsCOMPtr<nsIFile> localFile; - nsresult rv = NS_ERROR_FAILURE; - - nsIAtom* inAtom = NS_NewAtom(prop); - NS_ENSURE_TRUE(inAtom, NS_ERROR_OUT_OF_MEMORY); - - if (inAtom == sApp_PrefsDirectory50) { - rv = domainDir->Clone(getter_AddRefs(localFile)); - } - else if (inAtom == sApp_PreferencesFile50) { - rv = domainDir->Clone(getter_AddRefs(localFile)); - if (NS_SUCCEEDED(rv)) - rv = localFile->AppendNative(PREFS_FILE_50_NAME); - } - else if (inAtom == sApp_UserProfileDirectory50) { - rv = domainDir->Clone(getter_AddRefs(localFile)); - } - - NS_RELEASE(inAtom); - - if (localFile && NS_SUCCEEDED(rv)) - return CallQueryInterface(localFile, _retval); - - return rv; -} - - -// Protected methods - - -nsresult -nsProfileDirServiceProvider::Initialize() -{ - - static const nsStaticAtom provider_atoms[] = { - { NS_APP_PREFS_50_DIR, &sApp_PrefsDirectory50 }, - { NS_APP_PREFS_50_FILE, &sApp_PreferencesFile50 }, - { NS_APP_USER_PROFILE_50_DIR, &sApp_UserProfileDirectory50 }, - { NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR, nsnull }, - }; - - // Register our directory atoms - NS_RegisterStaticAtoms(provider_atoms, NS_ARRAY_LENGTH(provider_atoms)); - - return NS_OK; -} - -nsresult -nsProfileDirServiceProvider::EnsureProfileFileExists(nsIFile *aFile) -{ - nsresult rv; - PRBool exists; - - rv = aFile->Exists(&exists); - if (NS_FAILED(rv)) - return rv; - if (exists) - return NS_OK; - - nsCOMPtr<nsIFile> defaultsFile; - - // Attempt first to get the localized subdir of the defaults - rv = NS_GetSpecialDirectory(NS_APP_PROFILE_DEFAULTS_50_DIR, getter_AddRefs(defaultsFile)); - if (NS_FAILED(rv)) { - // If that has not been defined, use the top level of the defaults - rv = NS_GetSpecialDirectory(NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR, getter_AddRefs(defaultsFile)); - if (NS_FAILED(rv)) - return rv; - } - - mProfileDir = defaultsFile; - return rv; -} - - -nsresult -nsProfileDirServiceProvider::UndefineFileLocations() -{ - nsresult rv; - - nsCOMPtr<nsIProperties> directoryService = - do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv); - NS_ENSURE_TRUE(directoryService, NS_ERROR_FAILURE); - - (void) directoryService->Undefine(NS_APP_PREFS_50_DIR); - (void) directoryService->Undefine(NS_APP_PREFS_50_FILE); - (void) directoryService->Undefine(NS_APP_USER_PROFILE_50_DIR); - - return NS_OK; -} - - -// Global creation function - - -nsresult NS_NewProfileDirServiceProvider(nsProfileDirServiceProvider** aProvider) -{ - NS_ENSURE_ARG_POINTER(aProvider); - *aProvider = nsnull; - - nsProfileDirServiceProvider *prov = new nsProfileDirServiceProvider(); - if (!prov) - return NS_ERROR_OUT_OF_MEMORY; - nsresult rv = prov->Initialize(); - if (NS_FAILED(rv)) { - delete prov; - return rv; - } - NS_ADDREF(*aProvider = prov); - return NS_OK; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.hxx deleted file mode 100644 index 1dc526b515bf..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.hxx +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSPROFILEDIRSERVICEPROVIDER_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSPROFILEDIRSERVICEPROVIDER_HXX - -#include "mozilla_nsprofiledirserviceprovider.h" - -// Forward Declarations -class nsIAtom; - - -// nsProfileDirServiceProvider - The nsIDirectoryServiceProvider implementation used for -// profile-relative file locations. - - -class nsProfileDirServiceProvider: public nsIDirectoryServiceProvider -{ - NS_DECL_ISUPPORTS - NS_DECL_NSIDIRECTORYSERVICEPROVIDER - - friend nsresult NS_NewProfileDirServiceProvider( nsProfileDirServiceProvider**); - -public: - - virtual nsresult SetProfileDir(nsIFile* aProfileDir); - virtual nsresult Register(); - virtual nsresult Shutdown(); - -protected: - nsProfileDirServiceProvider(); - virtual ~nsProfileDirServiceProvider(); - - nsresult Initialize(); - nsresult EnsureProfileFileExists(nsIFile* profileDir); - nsresult UndefineFileLocations(); - -protected: - - // Atoms for file locations - static nsIAtom* sApp_PrefsDirectory50; - static nsIAtom* sApp_PreferencesFile50; - static nsIAtom* sApp_UserProfileDirectory50; - - nsCOMPtr<nsIFile> mProfileDir; - -}; - - - - -/** - * Global method to create an instance of nsProfileDirServiceProvider - * - * @param aNotifyObservers If true, will send out profile startup - * notifications when the profile directory is set. - * See nsIProfileChangeStatus. - */ - -nsresult NS_NewProfileDirServiceProvider( nsProfileDirServiceProvider** aProvider); - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSPROFILEDIRSERVICEPROVIDER_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx index df2012e39c5a..3e68f1321170 100644 --- a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx +++ b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx @@ -19,65 +19,6 @@ #include "MNSProfileDiscover.hxx" -#ifndef MINIMAL_PROFILEDISCOVER -#include "MNSProfile.hxx" - -#include "pratom.h" -#include "prmem.h" -#include "plstr.h" -#include "prenv.h" - -#include "nsIEnumerator.h" -#include "prprf.h" -#include "nsCOMPtr.h" -#include "nsIComponentManager.h" -#include "nsEscape.h" -#include "nsDirectoryServiceDefs.h" -#include "nsAppDirectoryServiceDefs.h" -#include "nsILocalFile.h" -#include "nsReadableUtils.h" - - -#if defined(XP_MAC) || defined(XP_MACOSX) -#include <Processes.h> -#include <CFBundle.h> -#include "nsILocalFileMac.h" -#endif - -#ifdef XP_UNIX -#include <unistd.h> -#include <fcntl.h> -#include <errno.h> -#include <signal.h> -#include "prnetdb.h" -#include "prsystem.h" -#endif - -#ifdef VMS -#include <rmsdef.h> -#endif - -#include "pre_include_mozilla.h" -#include "nsICharsetConverterManager.h" -#include "nsIPlatformCharset.h" -#include "post_include_mozilla.h" - -#if defined (XP_UNIX) -# define USER_ENVIRONMENT_VARIABLE "USER" -# define LOGNAME_ENVIRONMENT_VARIABLE "LOGNAME" -# define HOME_ENVIRONMENT_VARIABLE "HOME" -# define PROFILE_NAME_ENVIRONMENT_VARIABLE "PROFILE_NAME" -# define PROFILE_HOME_ENVIRONMENT_VARIABLE "PROFILE_HOME" -# define DEFAULT_UNIX_PROFILE_NAME "default" -# ifndef XP_MACOSX /* Don't use symlink-based locking on OS X */ -# define USE_SYMLINK_LOCKING -# endif -#endif - -// IID and CIDs of all the services needed -static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID); -#endif - #include "MNSFolders.hxx" #include "MNSINIParser.hxx" @@ -86,11 +27,7 @@ namespace connectivity namespace mozab { ProfileStruct::ProfileStruct(MozillaProductType aProduct, const OUString& aProfileName, -#ifdef MINIMAL_PROFILEDISCOVER const OUString& aProfilePath -#else - nsILocalFile * aProfilePath -#endif ) { product=aProduct; @@ -99,20 +36,7 @@ namespace connectivity } OUString ProfileStruct::getProfilePath() { -#ifdef MINIMAL_PROFILEDISCOVER return profilePath; -#else - if (profilePath) - { - nsAutoString path; - nsresult rv = profilePath->GetPath(path); - NS_ENSURE_SUCCESS(rv, OUString()); - // PRUnichar != sal_Unicode in mingw - return OUString(reinterpret_cast_mingw_only<const sal_Unicode *>(path.get())); - } - else - return OUString(); -#endif } ProfileAccess::~ProfileAccess() @@ -143,9 +67,6 @@ namespace connectivity sal_Int32 index=product; ProductStruct &m_Product = m_ProductProfileList[index]; -#ifndef MINIMAL_PROFILEDISCOVER - nsresult rv; -#endif OUString regDir = getRegistryDir(product); OUString profilesIni = regDir + "profiles.ini"; IniParser parser( profilesIni ); @@ -191,28 +112,6 @@ namespace connectivity isRelative = sIsRelative.toInt32(); } -#ifndef MINIMAL_PROFILEDISCOVER - nsCOMPtr<nsILocalFile> rootDir; - rv = NS_NewLocalFile(EmptyString(), PR_TRUE, - getter_AddRefs(rootDir)); - if (NS_FAILED(rv)) continue; - - OString sPath = OUStringToOString(profilePath, RTL_TEXTENCODING_UTF8); - nsCAutoString filePath(sPath.getStr()); - - if (isRelative) { - // PRUnichar != sal_Unicode in mingw - nsAutoString registryDir( reinterpret_cast_mingw_only<const PRUnichar *>(regDir.getStr()) ); - nsCOMPtr<nsILocalFile> mAppData; - rv = NS_NewLocalFile(registryDir, PR_TRUE, - getter_AddRefs(mAppData)); - if (NS_FAILED(rv)) continue; - rv = rootDir->SetRelativeDescriptor(mAppData, filePath); - } else { - rv = rootDir->SetPersistentDescriptor(filePath); - } - if (NS_FAILED(rv)) continue; -#else OUString fullProfilePath; if(isRelative) { @@ -222,14 +121,9 @@ namespace connectivity { fullProfilePath = profilePath; } -#endif ProfileStruct* profileItem = new ProfileStruct(product,profileName, -#ifdef MINIMAL_PROFILEDISCOVER fullProfilePath -#else - rootDir -#endif ); m_Product.mProfileList[profileName] = profileItem; @@ -301,98 +195,11 @@ namespace connectivity ProfileStruct * aProfile = (*m_Product.mProfileList.begin()).second; return aProfile->getProfileName(); } -#ifndef MINIMAL_PROFILEDISCOVER - nsresult ProfileAccess::isExistFileOrSymlink(nsILocalFile* aFile,PRBool *bExist) - { - nsresult rv; - nsAutoString path; - aFile->GetPath(path); - rv = aFile->Exists(bExist); - NS_ENSURE_SUCCESS(rv, rv); - if (!*bExist) - { - rv = aFile->IsSymlink(bExist); - NS_ENSURE_SUCCESS(rv, rv); - } - return rv; - } - nsresult ProfileAccess::isLockExist(nsILocalFile* aFile) - { -#if defined (XP_MACOSX) - NS_NAMED_LITERAL_STRING(LOCKFILE_NAME, ".parentlock"); - NS_NAMED_LITERAL_STRING(OLD_LOCKFILE_NAME, "parent.lock"); -#elif defined (XP_UNIX) - NS_ConvertASCIItoUTF16 OLD_LOCKFILE_NAME("lock"); - NS_ConvertASCIItoUTF16 LOCKFILE_NAME(".parentlock"); -#else - NS_NAMED_LITERAL_STRING(OLD_LOCKFILE_NAME, "parent.lock"); - NS_NAMED_LITERAL_STRING(LOCKFILE_NAME, "parent.lock"); -#endif - - nsresult rv; - - PRBool isDir; - rv = aFile->IsDirectory(&isDir); - NS_ENSURE_SUCCESS(rv, rv); - if (!isDir) - return NS_ERROR_FILE_NOT_DIRECTORY; - - nsCOMPtr<nsILocalFile> lockFile; - rv = aFile->Clone((nsIFile **)((void **)getter_AddRefs(lockFile))); - NS_ENSURE_SUCCESS(rv, rv); - - rv = lockFile->Append(LOCKFILE_NAME); - NS_ENSURE_SUCCESS(rv, rv); - PRBool nExist=PR_FALSE; - rv = isExistFileOrSymlink(lockFile,&nExist); - NS_ENSURE_SUCCESS(rv, rv); - if (!nExist) // Check OLD_LOCKFILE_NAME - { - nsCOMPtr<nsILocalFile> oldlockFile; - rv = aFile->Clone((nsIFile **)((void **)getter_AddRefs(oldlockFile))); - NS_ENSURE_SUCCESS(rv, rv); - - rv = oldlockFile->Append(OLD_LOCKFILE_NAME); - NS_ENSURE_SUCCESS(rv, rv); - rv = isExistFileOrSymlink(oldlockFile,&nExist); - NS_ENSURE_SUCCESS(rv, rv); - } - return nExist; - } - -#endif bool ProfileAccess::isProfileLocked( ::com::sun::star::mozilla::MozillaProductType product, const OUString& profileName ) throw (::com::sun::star::uno::RuntimeException) { -#ifdef MINIMAL_PROFILEDISCOVER (void)product; /* avoid warning about unused parameter */ (void)profileName; /* avoid warning about unused parameter */ return true; -#else - OUString path = getProfilePath(product,profileName); - if (path.isEmpty()) - return sal_True; - - // PRUnichar != sal_Unicode in mingw - nsAutoString filePath(reinterpret_cast_mingw_only<const PRUnichar *>(path.getStr())); - - nsresult rv; - nsCOMPtr<nsILocalFile> localFile; - rv = NS_NewLocalFile(filePath, PR_TRUE, - getter_AddRefs(localFile)); - NS_ENSURE_SUCCESS(rv,sal_True); - - PRBool exists = PR_FALSE; - rv = localFile->Exists(&exists); - NS_ENSURE_SUCCESS(rv, sal_True); - if (!exists) - return sal_True; - - // If the profile is locked, we return true - rv = isLockExist(localFile); - if (rv) - return sal_True; - return sal_False; -#endif } bool ProfileAccess::getProfileExists( ::com::sun::star::mozilla::MozillaProductType product, const OUString& profileName ) throw (::com::sun::star::uno::RuntimeException) diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx index 6883c5615acf..3f9ad6980268 100644 --- a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx +++ b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx @@ -20,10 +20,6 @@ #ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSPROFILEDISCOVER_HXX #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSPROFILEDISCOVER_HXX -#ifndef MINIMAL_PROFILEDISCOVER -#include "mozilla_profile_discover.h" -#endif - #include <sal/types.h> #include <osl/diagnose.h> #include <osl/conditn.hxx> @@ -52,25 +48,13 @@ namespace connectivity { public: ProfileStruct(MozillaProductType aProduct, const OUString& aProfileName, -#ifdef MINIMAL_PROFILEDISCOVER - const OUString &aProfilePath -#else - nsILocalFile * aProfilePath -#endif - ); + const OUString &aProfilePath); OUString getProfileName(){ return profileName;} OUString getProfilePath() ; -#ifndef MINIMAL_PROFILEDISCOVER - nsILocalFile *getProfileLocal(){ return profilePath;} -#endif protected: MozillaProductType product; OUString profileName; -#ifdef MINIMAL_PROFILEDISCOVER OUString profilePath; -#else - nsCOMPtr<nsILocalFile> profilePath; -#endif }; class ProductStruct @@ -97,11 +81,6 @@ namespace connectivity ProductStruct m_ProductProfileList[4]; sal_Int32 LoadProductsInfo(); sal_Int32 LoadXPToolkitProfiles(MozillaProductType product); -#ifndef MINIMAL_PROFILEDISCOVER - //used by isProfileLocked - nsresult isExistFileOrSymlink(nsILocalFile* aFile,PRBool *bExist); - nsresult isLockExist(nsILocalFile* aFile); -#endif }; } diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.cxx deleted file mode 100644 index 5480699abb50..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.cxx +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include "MNSProfileManager.hxx" -#include "MNSProfile.hxx" - -#ifndef MAXPATHLEN -#define MAXPATHLEN 1024 -#endif -#include "MNSFolders.hxx" -#include "MNSINIParser.hxx" - -static ::sal_Int32 nInitCounter=0; -namespace connectivity -{ - namespace mozab - { - - ProfileManager::~ProfileManager() - { - } - ProfileManager::ProfileManager() - :m_CurrentProduct(MozillaProductType_Mozilla) - ,aProfile(NULL) - { - } - ::sal_Int32 ProfileManager::bootupProfile( ::com::sun::star::mozilla::MozillaProductType product, const OUString& profileName ) throw (::com::sun::star::uno::RuntimeException) - { - if (!aProfile) - { - aProfile=new nsProfile(); - aProfile->StartupWithArgs(NULL,sal_False); - } - - setCurrentProfile(product,profileName); - return ++nInitCounter; - } - ::sal_Int32 ProfileManager::shutdownProfile( ) throw (::com::sun::star::uno::RuntimeException) - { - return --nInitCounter; - } - ::com::sun::star::mozilla::MozillaProductType ProfileManager::getCurrentProduct( ) throw (::com::sun::star::uno::RuntimeException) - { - return m_CurrentProduct; - } - OUString ProfileManager::getCurrentProfile( ) throw (::com::sun::star::uno::RuntimeException) - { - nsresult rv; - nsCOMPtr<nsIProfile> theProfile(do_GetService(NS_PROFILE_CONTRACTID,&rv)); - if (NS_FAILED(rv)) return OUString(); - nsXPIDLString currentProfileStr; - //call GetCurrentProfile before call SetCurrentProfile will get the default profile - rv = theProfile->GetCurrentProfile(getter_Copies(currentProfileStr)); - if (NS_FAILED(rv) || currentProfileStr.get() == nsnull) - return OUString(); - // PRUnichar != sal_Unicode in mingw - return OUString(reinterpret_cast_mingw_only<const sal_Unicode *>(currentProfileStr.get())); - } - OUString ProfileManager::setCurrentProfile( ::com::sun::star::mozilla::MozillaProductType product, const OUString& profileName ) throw (::com::sun::star::uno::RuntimeException) - { - OUString currentProfile = getCurrentProfile(); - //if profileName not given, then skip and return current profile - if (profileName.isEmpty() && m_CurrentProduct == product) - return currentProfile; - - if (m_CurrentProduct == product && profileName.equals(currentProfile)) - return currentProfile; - //set current product - m_CurrentProduct = product; - - //get profile mozilla profile service - nsresult rv; - nsCOMPtr<nsIProfile> theProfile(do_GetService(NS_PROFILE_CONTRACTID,&rv)); - if (NS_FAILED(rv)) return OUString(); - - // PRUnichar != sal_Unicode in mingw - const PRUnichar* pUsedProfile = reinterpret_cast_mingw_only<const PRUnichar *>(profileName.getStr()); - //set current profile - rv = theProfile->SetCurrentProfile( pUsedProfile ); - if (NS_FAILED(rv)) return OUString(); - return currentProfile; - } - - - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.hxx deleted file mode 100644 index c102805baf9d..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.hxx +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSPROFILEMANAGER_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSPROFILEMANAGER_HXX - -#include "mozilla_profilemanager.h" - -#include <sal/types.h> -#include <osl/diagnose.h> -#include <osl/conditn.hxx> -#include <com/sun/star/mozilla/MozillaProductType.hpp> -#include <com/sun/star/uno/RuntimeException.hpp> -#include <com/sun/star/uno/Sequence.hxx> - -#include <rtl/ustring.hxx> -#include <vector> -#include <map> - -using namespace com::sun::star::mozilla; -class nsProfile; -namespace connectivity -{ - namespace mozab - { - class ProfileManager - { - public: - - virtual ~ProfileManager(); - ProfileManager(); - - ::sal_Int32 SAL_CALL bootupProfile( ::com::sun::star::mozilla::MozillaProductType product, const OUString& profileName ) throw (::com::sun::star::uno::RuntimeException) ; - ::sal_Int32 SAL_CALL shutdownProfile( ) throw (::com::sun::star::uno::RuntimeException) ; - ::com::sun::star::mozilla::MozillaProductType SAL_CALL getCurrentProduct( ) throw (::com::sun::star::uno::RuntimeException) ; - OUString SAL_CALL getCurrentProfile( ) throw (::com::sun::star::uno::RuntimeException) ; - OUString SAL_CALL setCurrentProfile( ::com::sun::star::mozilla::MozillaProductType product, const OUString& profileName ) throw (::com::sun::star::uno::RuntimeException) ; - - protected: - ::com::sun::star::mozilla::MozillaProductType m_CurrentProduct; - nsProfile *aProfile; - }; - - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSPROFILEMANAGER_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSRunnable.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSRunnable.cxx deleted file mode 100644 index f53f422ee841..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSRunnable.cxx +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "MNSRunnable.hxx" -#include "mozillasrc/MDatabaseMetaDataHelper.hxx" -#include "mozillasrc/MQuery.hxx" -#include <osl/mutex.hxx> -#include <osl/conditn.hxx> -#include <osl/thread.hxx> - -#include "pre_include_mozilla.h" -#include <nsIProxyObjectManager.h> -// More Mozilla includes for LDAP Connection Test -#include "prprf.h" -#include "nsILDAPURL.h" -#include "nsILDAPMessage.h" -#include "nsILDAPMessageListener.h" -#include "nsILDAPErrors.h" -#include "nsILDAPConnection.h" -#include "nsILDAPOperation.h" -#include "post_include_mozilla.h" - -using namespace connectivity::mozab; - -/* Implementation file */ -NS_IMPL_ISUPPORTS1(MNSRunnable, nsIRunnable) - -static ::osl::Mutex m_aThreadMutex; - -nsIRunnable * MNSRunnable::ProxiedObject() -{ - if (!_ProxiedObject) - { - - nsresult rv = NS_GetProxyForObject(NS_UI_THREAD_EVENTQ, - NS_GET_IID(nsIRunnable), - this, - PROXY_SYNC, - (void**)&_ProxiedObject); - (void)rv; - - _ProxiedObject->AddRef(); - } - return _ProxiedObject; -} - -MNSRunnable::MNSRunnable() -{ - NS_INIT_ISUPPORTS(); - _ProxiedObject=NULL; -#if OSL_DEBUG_LEVEL > 0 - m_oThreadID = osl::Thread::getCurrentIdentifier(); -#endif - AddRef(); -} - -MNSRunnable::~MNSRunnable() -{ -} -sal_Int32 MNSRunnable::StartProxy(const ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XCodeProxy >& aCode) -{ - OSL_TRACE( "IN : MNSRunnable::StartProxy()" ); - ::osl::MutexGuard aGuard(m_aThreadMutex); - xCode = aCode; - return ProxiedObject()->Run(); -} - - -NS_IMETHODIMP MNSRunnable::Run() -{ - return static_cast<nsresult>(xCode->run()); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSRunnable.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSRunnable.hxx deleted file mode 100644 index 88f6f102a225..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSRunnable.hxx +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSRUNNABLE_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSRUNNABLE_HXX - -#include "mozillasrc/MNSDeclares.hxx" -#include <osl/thread.hxx> - -#include "mozillasrc/MNSInclude.hxx" -#include <com/sun/star/uno/Reference.hxx> -#include <com/sun/star/mozilla/XCodeProxy.hpp> - - -using namespace com::sun::star::uno; -using namespace com::sun::star::mozilla; - -namespace connectivity -{ - namespace mozab - { - class MNSRunnable : public nsIRunnable - { - public: - nsIRunnable * ProxiedObject(); - MNSRunnable(); - virtual ~MNSRunnable(); - NS_DECL_ISUPPORTS - NS_DECL_NSIRUNNABLE - - public: - sal_Int32 StartProxy(const ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XCodeProxy >& aCode); //Call this to start proxy - - private: - nsIRunnable* _ProxiedObject; - Reference<XCodeProxy> xCode; -#if OSL_DEBUG_LEVEL > 0 - oslThreadIdentifier m_oThreadID; -#endif - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSRUNNABLE_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/mozilla_nsinit.h b/connectivity/source/drivers/mozab/bootstrap/mozilla_nsinit.h deleted file mode 100644 index 0311aa830e73..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/mozilla_nsinit.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "pre_include_mozilla.h" - -#include "nsIServiceManager.h" -#include "nsIEventQueueService.h" -#include "nsIChromeRegistry.h" - -#include "nsIStringBundle.h" - -#include "nsIDirectoryService.h" -#include "nsIProfile.h" -#include "nsIProfileInternal.h" -#include "nsIPref.h" -#include "nsXPIDLString.h" - -#include "nsString.h" - -#include "nsDirectoryService.h" - -#include "post_include_mozilla.h" - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofile.h b/connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofile.h deleted file mode 100644 index 6cf4e4d9f395..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofile.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "pre_include_mozilla.h" - -#include "nscore.h" -#include "nsIPrefService.h" -#include "nsIPrefBranch.h" - -#include "pratom.h" -#include "prmem.h" -#include "plstr.h" -#include "prenv.h" - -#include "nsIFactory.h" -#include "nsIComponentManager.h" -#include "nsIEnumerator.h" -#include "nsXPIDLString.h" -#include "nsEscape.h" -#include "nsIURL.h" - -#include "prprf.h" - -#include "nsIProfile.h" -#include "nsIProfileInternal.h" -#include "nsIProfileStartupListener.h" -#include "nsIProfileChangeStatus.h" -#include "nsCOMPtr.h" -#include "nsISupports.h" -#include "nsIRegistry.h" -#include "nsString.h" -#include "nsIInterfaceRequestor.h" -#include "nsIInterfaceRequestorUtils.h" -#include "nsIDirectoryService.h" - -#include "nsIIOService.h" -#include "nsNetUtil.h" -#include "nsFileStream.h" -#include "nsIStreamListener.h" -#include "nsIServiceManager.h" -#include "nsIModule.h" -#include "nsIGenericFactory.h" -#include "nsICategoryManager.h" -#include "nsXPCOM.h" -#include "nsISupportsPrimitives.h" -#include "nsDirectoryServiceDefs.h" -#include "nsAppDirectoryServiceDefs.h" -#include "nsIChromeRegistry.h" -#include "nsIStringBundle.h" -#include "nsIObserverService.h" -#include "nsHashtable.h" -#include "nsIAtom.h" -#include "nsCRT.h" - -#include "post_include_mozilla.h" - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofiledirserviceprovider.h b/connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofiledirserviceprovider.h deleted file mode 100644 index 432ec63712a3..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofiledirserviceprovider.h +++ /dev/null @@ -1,28 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "pre_include_mozilla.h" - -#include "nsIDirectoryService.h" -#include "nsILocalFile.h" -#include "nsString.h" - -#include "post_include_mozilla.h" - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/mozilla_profile_discover.h b/connectivity/source/drivers/mozab/bootstrap/mozilla_profile_discover.h deleted file mode 100644 index 4bd051175087..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/mozilla_profile_discover.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "pre_include_mozilla.h" - -#include "nsCOMPtr.h" -#include "nsISupports.h" -#include "nsString.h" -#include "nsIRegistry.h" -#include "nsXPIDLString.h" -#include "nsVoidArray.h" -#include "nsIFile.h" -#include "nsILocalFile.h" - -#include "post_include_mozilla.h" - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/mozilla_profilemanager.h b/connectivity/source/drivers/mozab/bootstrap/mozilla_profilemanager.h deleted file mode 100644 index ff0310422b9d..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/mozilla_profilemanager.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "pre_include_mozilla.h" - -#include "nsCOMPtr.h" -#include "nsISupports.h" -#include "nsString.h" -#include "nsIRegistry.h" -#include "nsXPIDLString.h" -#include "nsVoidArray.h" -#include "nsIFile.h" -#include "nsILocalFile.h" - -#include "pratom.h" -#include "prmem.h" -#include "plstr.h" -#include "prenv.h" - -#include "nsIEnumerator.h" -#include "prprf.h" -#include "nsIComponentManager.h" -#include "nsEscape.h" -#include "nsDirectoryServiceDefs.h" -#include "nsAppDirectoryServiceDefs.h" -#include "nsReadableUtils.h" - - -#if defined(XP_MAC) || defined(XP_MACOSX) -#include <Processes.h> -#include <CFBundle.h> -#include "nsILocalFileMac.h" -#endif - -#ifdef XP_UNIX -#include <unistd.h> -#include <fcntl.h> -#include <errno.h> -#include <signal.h> -#include "prnetdb.h" -#include "prsystem.h" -#endif - -#ifdef VMS -#include <rmsdef.h> -#endif - -#include "nsIPlatformCharset.h" -#include "MNSInit.hxx" - -#include "post_include_mozilla.h" - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/post_include_windows.h b/connectivity/source/drivers/mozab/bootstrap/post_include_windows.h deleted file mode 100644 index bd49753b7bd7..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/post_include_windows.h +++ /dev/null @@ -1,24 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifdef _MSC_VER - #pragma warning(pop) -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/pre_include_windows.h b/connectivity/source/drivers/mozab/bootstrap/pre_include_windows.h deleted file mode 100644 index 7d68ce298f9e..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/pre_include_windows.h +++ /dev/null @@ -1,25 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifdef _MSC_VER - #pragma warning(push,1) - #pragma warning(disable:4668 4917) -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/mozab.component b/connectivity/source/drivers/mozab/mozab.component deleted file mode 100644 index 77375695d1cc..000000000000 --- a/connectivity/source/drivers/mozab/mozab.component +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - --> - -<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - prefix="mozab" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.comp.mozilla.MozillaBootstrap"> - <service name="com.sun.star.mozilla.MozillaBootstrap"/> - </implementation> - <implementation name="com.sun.star.comp.sdbc.MozabDriver"> - <service name="com.sun.star.sdbc.Driver"/> - </implementation> -</component> diff --git a/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.cxx b/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.cxx deleted file mode 100644 index c3ac8f6a25f2..000000000000 --- a/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.cxx +++ /dev/null @@ -1,777 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -// Mozilla includes. -#include "MNSInclude.hxx" - -#include "resource/mozab_res.hrc" -#include "MDatabaseMetaDataHelper.hxx" -#include "MTypeConverter.hxx" -#include "MConfigAccess.hxx" -#include <connectivity/dbexception.hxx> -#include <comphelper/uno3.hxx> -#include <comphelper/sequence.hxx> -#include <osl/mutex.hxx> -#include <osl/conditn.hxx> - -#include "pre_include_mozilla.h" -#include <nsIAbDirFactoryService.h> -#include "post_include_mozilla.h" - -#include "bootstrap/MNSInit.hxx" -#include "MNameMapper.hxx" -#include "MNSMozabProxy.hxx" -#include "MNSDeclares.hxx" - -static ::osl::Mutex m_aMetaMutex; - -#include <osl/diagnose.h> -#include <com/sun/star/uno/Reference.hxx> -#include <com/sun/star/uno/Sequence.hxx> -#include <com/sun/star/uno/XInterface.hpp> -#include <com/sun/star/uno/Exception.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/beans/Property.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/beans/XPropertySetInfo.hpp> -#include <com/sun/star/beans/PropertyAttribute.hpp> -#include <com/sun/star/sdb/ErrorCondition.hpp> -#include <comphelper/processfactory.hxx> -#include <com/sun/star/mozilla/XMozillaBootstrap.hpp> - - -#if OSL_DEBUG_LEVEL > 0 -# define OUtoCStr( x ) ( OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr()) -#else /* OSL_DEBUG_LEVEL */ -# define OUtoCStr( x ) ("dummy") -#endif /* OSL_DEBUG_LEVEL */ - - -static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); -static NS_DEFINE_CID(kAbDirFactoryServiceCID, NS_ABDIRFACTORYSERVICE_CID); -static NS_DEFINE_CID(kAddrBookSessionCID, NS_ADDRBOOKSESSION_CID); - -using namespace connectivity::mozab; -using namespace connectivity; -using namespace ::com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbc; -using namespace com::sun::star::mozilla; -using namespace com::sun::star::sdb; - -namespace connectivity -{ - namespace mozab - { - static const char * const s_pADDRESSBOOKROOTDIR = "moz-abdirectory://"; - } -} - -extern sal_Bool MNS_Init(sal_Bool& aProfileExists); - - -MDatabaseMetaDataHelper::MDatabaseMetaDataHelper() - :m_bProfileExists(sal_False) -{ - OSL_TRACE( "IN MDatabaseMetaDataHelper::MDatabaseMetaDataHelper()" ); - - OSL_TRACE( "\tOUT MDatabaseMetaDataHelper::MDatabaseMetaDataHelper()" ); - -} - -MDatabaseMetaDataHelper::~MDatabaseMetaDataHelper() -{ - m_aTableNames.clear(); - m_aTableTypes.clear(); - - if (m_bProfileExists) - { - Reference<XMozillaBootstrap> xMozillaBootstrap; - Reference<XMultiServiceFactory> xFactory = ::comphelper::getProcessServiceFactory(); - OSL_ENSURE( xFactory.is(), "can't get service factory" ); - - Reference<XInterface> xInstance = xFactory->createInstance("com.sun.star.mozilla.MozillaBootstrap"); - OSL_ENSURE( xInstance.is(), "failed to create instance" ); - xMozillaBootstrap = Reference<XMozillaBootstrap>(xInstance,UNO_QUERY); - m_bProfileExists = xMozillaBootstrap->shutdownProfile() > 0; - } - - OSL_TRACE( "IN/OUT MDatabaseMetaDataHelper::~MDatabaseMetaDataHelper()" ); -} - -static nsresult enumSubs(nsISimpleEnumerator * subDirs,nsISupportsArray * array); -//enum all sub folders -static nsresult enumSubs(nsIAbDirectory * parentDir,nsISupportsArray * array) -{ - nsCOMPtr<nsISimpleEnumerator> subDirectories; - nsresult rv = parentDir->GetChildNodes(getter_AddRefs(subDirectories)); - if (NS_FAILED(rv)) { return rv; } - - rv = enumSubs(subDirectories,array); - return rv; -} - -#include <prmem.h> -static nsresult insertPABDescription() -{ - nsresult rv = NS_OK ; - // mozilla loads the descriptions of pab and history from a file named addressbook.properties - // we never deliver it with OOo,so mozab does not auto load personal addressbook and Collected addresses - // If we want to deliver addressbook.properties with OOo,we have to deal with hole mozilla chrome mechanism. - // So I insert the descriptiones as user prefs, they will cover the default value. - - //"Personal Address Book" "Collected Addresses" are loaded from officecfg - nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - nsCAutoString pabPrefName(NS_LITERAL_CSTRING("ldap_2.servers.pab.description")); - - sal_Bool bSetted=sal_False; - char *value = nsnull; - if (0 == prefs->CopyCharPref(pabPrefName.get(), &value)) - { - if (!(value == nsnull || value[0] == 0)) - { - bSetted = sal_True; - } - } - PR_FREEIF (value); - value=nsnull; - if (bSetted == sal_True) - { - const char* pPabDescription = static_cast< const char* >( getPabDescription( ) ); - rv = prefs->SetCharPref (pabPrefName.get(), pPabDescription); - NS_ENSURE_SUCCESS(rv, rv); - } - - nsCAutoString hisPrefName(NS_LITERAL_CSTRING("ldap_2.servers.history.description")); - - bSetted=sal_False; - if (0 == prefs->CopyCharPref(hisPrefName.get(), &value)) - { - if (!(value == nsnull || value[0] == 0)) - { - bSetted = sal_True; - } - } - PR_FREEIF (value); - if (bSetted == sal_True) - { - const char* pHisDescription = static_cast< const char* >( getHisDescription( ) ); - - rv = prefs->SetCharPref (hisPrefName.get(), pHisDescription); - NS_ENSURE_SUCCESS(rv, rv); - } - return rv; -} - -// nsAbDirectoryDataSource - -#define NS_RDF_CONTRACTID "@mozilla.org/rdf" -#define NS_RDF_DATASOURCE_CONTRACTID NS_RDF_CONTRACTID "/datasource;1" -#define NS_RDF_DATASOURCE_CONTRACTID_PREFIX NS_RDF_DATASOURCE_CONTRACTID "?name=" - - -// Case where we get a parent uri, and need to list its children. -static nsresult getSubsFromParent(const OString& aParent, nsIEnumerator **aSubs) -{ - - if (aSubs == nsnull) { return NS_ERROR_NULL_POINTER ; } - *aSubs = nsnull ; - nsCOMPtr<nsISupportsArray> array ; - - NS_NewISupportsArray(getter_AddRefs(array)) ; - - nsresult retCode = insertPABDescription(); - NS_ENSURE_SUCCESS(retCode, retCode) ; - - nsCOMPtr<nsIRDFService> rdfService(do_GetService(kRDFServiceCID, &retCode)) ; - NS_ENSURE_SUCCESS(retCode, retCode) ; - nsCOMPtr<nsIRDFResource> rdfResource ; - - OSL_TRACE("uri: %s\n", aParent.getStr()) ; - retCode = rdfService->GetResource(nsDependentCString(aParent.getStr(),aParent.getLength()), getter_AddRefs(rdfResource)) ; - NS_ENSURE_SUCCESS(retCode, retCode) ; - nsCOMPtr<nsIAbDirectory> directory = do_QueryInterface(rdfResource, &retCode) ; - nsCOMPtr<nsISimpleEnumerator> tempEnum ; - - NS_ENSURE_SUCCESS(retCode, retCode) ; - retCode = directory->GetChildNodes(getter_AddRefs(tempEnum)) ; - NS_ENSURE_SUCCESS(retCode, retCode) ; - - PRBool hasMore = PR_TRUE ; - while (NS_SUCCEEDED(tempEnum->HasMoreElements(&hasMore)) && hasMore) { - nsCOMPtr<nsIAbDirectory> element ; - retCode = tempEnum->GetNext(getter_AddRefs(element)) ; - if (NS_SUCCEEDED(retCode)) - { - array->AppendElement(element) ; - enumSubs(element,array); - } - } - - array->Enumerate(aSubs) ; - return retCode ; -} - -static nsresult enumSubs(nsISimpleEnumerator * subDirs,nsISupportsArray * array) -{ - PRBool hasMore = PR_TRUE ; - nsresult rv = NS_OK ; - while (NS_SUCCEEDED(subDirs->HasMoreElements(&hasMore)) && hasMore) { - nsCOMPtr<nsISupports> newDirSupports ; - - rv = subDirs->GetNext(getter_AddRefs(newDirSupports)) ; - NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr<nsIAbDirectory> childDir = do_QueryInterface(newDirSupports, &rv) ; - NS_ENSURE_SUCCESS(rv, rv); - array->AppendElement(childDir); - - rv = enumSubs(childDir,array); - } - return rv; -} - -// Case where we get a factory uri and need to have it build the directories. -static nsresult getSubsFromFactory(const OString& aFactory, nsIEnumerator **aSubs) -{ - if (aSubs == nsnull) { return NS_ERROR_NULL_POINTER ; } - *aSubs = nsnull ; - nsresult retCode = NS_OK ; - - nsCOMPtr<nsIAbDirFactoryService> dirFactoryService = do_GetService(NS_ABDIRFACTORYSERVICE_CONTRACTID, &retCode); - NS_ENSURE_SUCCESS(retCode, retCode) ; - nsCOMPtr<nsIAbDirFactory> dirFactory ; - - retCode = dirFactoryService->GetDirFactory(aFactory.getStr(), getter_AddRefs(dirFactory)) ; - NS_ENSURE_SUCCESS (retCode, retCode) ; - nsCOMPtr <nsIAbDirectoryProperties> properties; - properties = do_CreateInstance(NS_ABDIRECTORYPROPERTIES_CONTRACTID, &retCode); - NS_ENSURE_SUCCESS(retCode, retCode) ; - - retCode = properties->SetURI(aFactory.getStr()); - NS_ENSURE_SUCCESS(retCode,retCode); - - nsCOMPtr<nsISimpleEnumerator> subDirs ; - retCode = dirFactory->CreateDirectory(properties, getter_AddRefs(subDirs)); - NS_ENSURE_SUCCESS(retCode, retCode) ; - nsCOMPtr<nsISupportsArray> array ; - - NS_NewISupportsArray(getter_AddRefs(array)) ; - retCode = enumSubs(subDirs,array); - NS_ENSURE_SUCCESS(retCode, retCode) ; - array->Enumerate(aSubs) ; - return retCode ; -} - -// Case where the uri itself is the directory we're looking for. -static nsresult getSubsFromURI(const OString& aUri, nsIEnumerator **aSubs) -{ - if (aSubs == nsnull) { return NS_ERROR_NULL_POINTER ; } - *aSubs = nsnull ; - nsresult retCode = NS_OK ; - - nsCOMPtr<nsIRDFService> rdfService(do_GetService(kRDFServiceCID, &retCode)) ; - NS_ENSURE_SUCCESS(retCode, retCode) ; - nsCOMPtr<nsIRDFResource> rdfResource ; - - retCode = rdfService->GetResource(nsDependentCString(aUri.getStr(),aUri.getLength()), getter_AddRefs(rdfResource)) ; - NS_ENSURE_SUCCESS(retCode, retCode) ; - retCode = rdfService->UnregisterResource(rdfResource) ; - NS_ENSURE_SUCCESS(retCode, retCode) ; - - nsCOMPtr<nsIAbDirectory> directory = do_QueryInterface(rdfResource, &retCode) ; - - NS_ENSURE_SUCCESS(retCode, retCode) ; - nsAutoString nameAB ; - - nameAB.AssignWithConversion("LDAP Directory") ; - directory->SetDirName(nameAB.get()) ; - nsCOMPtr<nsISupportsArray> array ; - - NS_NewISupportsArray(getter_AddRefs(array)) ; - array->AppendElement(directory) ; - array->Enumerate(aSubs) ; - return retCode ; -} - -namespace -{ - static void lcl_setNoAddressBookFoundError( ErrorDescriptor& _rError, OConnection& _rCon, MozillaProductType _eProductType, - sal_Bool bGivenURI ) - { - sal_uInt16 nAddressBookNameRes = 0; - if ( !bGivenURI && _eProductType == MozillaProductType_Mozilla) - { - nAddressBookNameRes = STR_MOZILLA_ADDRESSBOOKS; - } - else - { - if ( _eProductType == MozillaProductType_Thunderbird ) - { - nAddressBookNameRes = STR_THUNDERBIRD_ADDRESSBOOKS; - } - else - { - if ( _rCon.usesFactory() ) - { - if ( _rCon.isOutlookExpress() ) - { - nAddressBookNameRes = STR_OE_ADDRESSBOOK; - } - else - { - nAddressBookNameRes = STR_OUTLOOK_MAPI_ADDRESSBOOK; - } - } - else - { - OSL_ENSURE( !_rCon.isLDAP(), "lcl_setNoAddressBookFoundError: not to be called for LDAP connections!" ); - nAddressBookNameRes = STR_MOZILLA_ADDRESSBOOKS; - } - } - } - _rError.set( 0, ErrorCondition::AB_ADDRESSBOOK_NOT_FOUND, _rCon.getResources().getResourceString( nAddressBookNameRes ) ); - } -} - -nsresult getTableStringsProxied(const sal_Char* sAbURI, sal_Int32 *nDirectoryType,MNameMapper *nmap, - ::std::vector< OUString >* _rStrings, - ::std::vector< OUString >* _rTypes, - sal_Int32* pErrorId ) -{ - if (!sAbURI || !nmap || !_rStrings || !_rTypes || !pErrorId) - { - return NS_ERROR_NULL_POINTER; - } - OSL_TRACE("Using URI %s to getTables()",sAbURI ); - - // Get the mozilla addressbooks from the base directory. - nsresult rv = NS_OK; - nsCOMPtr<nsIEnumerator> subDirectories; - - switch(*nDirectoryType) - { - case SDBCAddress::Mozilla: - rv = getSubsFromParent(sAbURI, getter_AddRefs(subDirectories)) ; - break; - case SDBCAddress::Outlook: - case SDBCAddress::OutlookExp: - rv = getSubsFromFactory(sAbURI, getter_AddRefs(subDirectories)) ; - break; - case SDBCAddress::LDAP: - rv = getSubsFromURI(sAbURI, getter_AddRefs(subDirectories)) ; - break; - default: - rv = getSubsFromParent(sAbURI, getter_AddRefs(subDirectories)); - } - NS_ENSURE_SUCCESS(rv, rv); - - // At this point we have a list containing the nsIAbDirectory we need to map as tables - rv = subDirectories -> First(); - NS_ENSURE_SUCCESS(rv, rv); - - PRUnichar *name = nsnull; - PRBool bIsMailList = PR_FALSE; - - OUString aTableName; - nsCOMPtr<nsIRDFService> rdfService(do_GetService(kRDFServiceCID, &rv)) ; - NS_ENSURE_SUCCESS(rv, rv) ; - - nmap->reset(); - do { - nsCOMPtr<nsIAbDirectory> subDirectory; - - nsCOMPtr<nsISupports> item; - rv = subDirectories -> CurrentItem(getter_AddRefs(item)); - if ( NS_FAILED( rv ) ) - { - *pErrorId = STR_COULD_NOT_RETRIEVE_AB_ENTRY; - return NS_ERROR_FAILURE; - } - - subDirectory = do_QueryInterface(item, &rv); - - subDirectory -> GetIsMailList(&bIsMailList); - // For now we're not interested in mailing lists. - rv = subDirectory -> GetDirName(&name); - if ( NS_FAILED( rv ) ) { - *pErrorId = STR_COULD_NOT_GET_DIRECTORY_NAME; - return NS_ERROR_FAILURE; - } - MTypeConverter::prUnicharToOUString(name, aTableName); - OSL_TRACE("TableName = >%s<", OUtoCStr( aTableName ) ); - - ODatabaseMetaDataResultSet::ORow aRow(3); - - // Insert table into map - if ( aTableName.isEmpty() ) - aTableName = "AddressBook"; - - OSL_TRACE("TableName = >%s<", OUtoCStr( aTableName ) ); - - rv = nmap->add( aTableName, subDirectory); - nsCOMPtr<nsIRDFResource> rdfResource = do_QueryInterface(subDirectory, &rv) ; - if (!NS_FAILED(rv)) - rdfService->UnregisterResource(rdfResource); - - if (!NS_FAILED(rv)) //failed means we have added this directory - { - //map mailing lists as views - _rStrings->push_back( aTableName ); // Table name - if (!bIsMailList) { - OUString aTableType("TABLE"); - _rTypes->push_back( aTableType ); // Table type - } - else - { - OUString aTableType("VIEW"); - _rTypes->push_back( aTableType ); // Table type - } - } - rv = subDirectories -> Next(); - } while ( rv == NS_OK); - - return NS_OK; -} -sal_Bool MDatabaseMetaDataHelper::getTableStrings( OConnection* _pCon, - ::std::vector< OUString >& _rStrings, - ::std::vector< OUString >& _rTypes) -{ - sal_Bool bGivenURI; - OUString sAbURI; - OString sAbURIString; - - OSL_TRACE( "IN MDatabaseMetaDataHelper::getTableStrings( 0x%08X, %s)", _pCon, _pCon->getForceLoadTables()?"True":"False" ); - - ::osl::MutexGuard aGuard( m_aMetaMutex ); - // Only do the query if we have to - performance degrades otherwise - if ( ! _pCon->getForceLoadTables() && m_aTableNames.size() > 0 ) { - _rStrings = m_aTableNames; - _rTypes = m_aTableTypes; - return sal_True; - } - - m_aTableNames.clear(); - m_aTableTypes.clear(); - - sAbURI = _pCon->getMozURI(); - - OSL_TRACE("AbURI = %s", OUtoCStr( sAbURI ) ); - if ( sAbURI.isEmpty() ) - bGivenURI = sal_False; - else { - sAbURIString = OUStringToOString( sAbURI, - RTL_TEXTENCODING_ASCII_US); - bGivenURI = sal_True; - } - - if ( bGivenURI ) - OSL_TRACE("Using URI %s to getTables()", sAbURIString.getStr() ); - else - OSL_TRACE("Using URI of ROOTDIR to getTables()"); - - // Get the mozilla addressbooks from the base directory. - nsresult rv = NS_OK; - nsCOMPtr<nsIEnumerator> subDirectories; - sal_Int32 nDirectoryType=0; - m_ProductType = MozillaProductType_Mozilla; - m_ProfileName = _pCon->getMozProfile(); - - - if (_pCon->isThunderbird()) - { - if (!bGivenURI) - sAbURIString = s_pADDRESSBOOKROOTDIR; - nDirectoryType = SDBCAddress::ThunderBird; - m_ProductType = MozillaProductType_Thunderbird; - } - else if (!bGivenURI) - { - sAbURIString = s_pADDRESSBOOKROOTDIR; - nDirectoryType = SDBCAddress::Mozilla; - } - else - { - if (_pCon->usesFactory()) - { - nDirectoryType = SDBCAddress::Outlook; - } - else - { - if (_pCon->isLDAP()) - { - nDirectoryType = SDBCAddress::LDAP; - } - else - { - sAbURIString = s_pADDRESSBOOKROOTDIR; - nDirectoryType = SDBCAddress::Mozilla; - } - } - } - - if ( !_pCon->isLDAP() && !m_bProfileExists ) - { // no need to boot up a Mozilla profile for an LDAP connection - Reference<XMozillaBootstrap> xMozillaBootstrap; - Reference<XMultiServiceFactory> xFactory = ::comphelper::getProcessServiceFactory(); - OSL_ENSURE( xFactory.is(), "can't get service factory" ); - Reference<XInterface> xInstance = xFactory->createInstance("com.sun.star.mozilla.MozillaBootstrap"); - OSL_ENSURE( xInstance.is(), "failed to create instance" ); - xMozillaBootstrap = Reference<XMozillaBootstrap>(xInstance,UNO_QUERY); - m_bProfileExists = sal_False; - //If there are no profiles for this product - //Or the given profile name does not found - //We will raise a "No Addressbook Directories Exist" error - if ( xMozillaBootstrap->getProfileCount(m_ProductType) == 0 || - ( !m_ProfileName.isEmpty() && xMozillaBootstrap->getProfilePath(m_ProductType,m_ProfileName).isEmpty())) - m_bProfileExists = sal_False; - else - if (xMozillaBootstrap->bootupProfile(m_ProductType,m_ProfileName) > 0) - m_bProfileExists = sal_True; - - } - if ( !m_bProfileExists - && !_pCon->isLDAP() - && ( ( nDirectoryType == SDBCAddress::Mozilla ) - || ( nDirectoryType == SDBCAddress::ThunderBird ) - ) - ) - { - lcl_setNoAddressBookFoundError( m_aError, *_pCon, m_ProductType, bGivenURI ); - return sal_False; - } - - MNameMapper *nmap = _pCon->getNameMapper(); - nmap->reset(); - - sal_Int32 nErrorResourceId( 0 ); - - MNSMozabProxy xMProxy; - RunArgs args; - args.funcIndex = ProxiedFunc::FUNC_GET_TABLE_STRINGS; - args.argCount = 6; - args.arg1 = (void*)sAbURIString.getStr(); - args.arg2 = (void*)&nDirectoryType; - args.arg3 = (void*)nmap; - args.arg4 = (void*)&m_aTableNames; - args.arg5 = (void*)&m_aTableTypes; - args.arg6 = (void*)&nErrorResourceId; - rv = xMProxy.StartProxy(&args,m_ProductType,m_ProfileName); - m_aError.setResId( static_cast<sal_uInt16>(nErrorResourceId) ); - - if (NS_FAILED(rv)) - { - if ( nErrorResourceId == 0 ) - m_aError.setResId( STR_UNSPECIFIED_ERROR ); - return sal_False; - } - OSL_TRACE( "\tOUT MDatabaseMetaDataHelper::getTableStrings()" ); - _rStrings = m_aTableNames; - _rTypes = m_aTableTypes; - - _pCon->setForceLoadTables(sal_False); - return sal_True; -} - -sal_Bool MDatabaseMetaDataHelper::getTables( OConnection* _pCon, - const OUString& tableNamePattern, - const Sequence< OUString >& types, - ODatabaseMetaDataResultSet::ORows& _rRows) -{ - - static ODatabaseMetaDataResultSet::ORows aRows; - - OSL_TRACE( "IN MDatabaseMetaDataHelper::getTables()" ); - ::osl::MutexGuard aGuard( m_aMetaMutex ); - - ODatabaseMetaDataResultSet::ORows().swap(aRows); // this makes real clear where memory is freed as well - aRows.clear(); - - ::std::vector< OUString > tables; - ::std::vector< OUString > tabletypes; - OUString matchAny = "%"; - - if ( !getTableStrings( _pCon, tables,tabletypes ) ) - return sal_False; - - for ( size_t i = 0; i < tables.size(); i++ ) { - ODatabaseMetaDataResultSet::ORow aRow(3); - - OUString aTableName = tables[i]; - OUString aTableType = tabletypes[i]; - OSL_TRACE("TableName = >%s<", OUtoCStr( aTableName ) ); - - - // return tables to caller - if (match( tableNamePattern, aTableName, '\0' ) && - ( 0 == types.getLength() || //types is null or types include aTableType or types include "%" - 0 != ::comphelper::findValue( types, aTableType, sal_True ).getLength() || - 0 != ::comphelper::findValue( types, matchAny, sal_True ).getLength())) { - if ( aTableName.isEmpty() ) { - aTableName = "AddressBook"; - } - - OSL_TRACE( "TableName = %s ; TableType = %s", OUtoCStr(aTableName), OUtoCStr(aTableType) ); - - aRow.push_back( new ORowSetValueDecorator( aTableName ) ); // Table name - aRow.push_back( new ORowSetValueDecorator( aTableType ) ); // Table type - aRow.push_back( ODatabaseMetaDataResultSet::getEmptyValue() ); // Remarks - aRows.push_back(aRow); - } - } - - OSL_TRACE( "\tOUT MDatabaseMetaDataHelper::getTables()" ); - _rRows = aRows; - return sal_True; -} - - -sal_Bool -MDatabaseMetaDataHelper::testLDAPConnection( OConnection* _pCon ) -{ - const sal_Unicode QUERY_CHAR = '?'; - const sal_Char* MOZ_SCHEMA = "moz-abldapdirectory://"; - - OString sAbURI; - OUString sAbBindDN; - OUString sAbPassword; - sal_Bool useSSL = _pCon->getUseSSL(); - - nsresult rv(0); - - sAbURI = OUStringToOString( _pCon->getMozURI(), RTL_TEXTENCODING_ASCII_US ); - sAbBindDN = _pCon->getBindDN(); - sAbPassword = _pCon->getPassword(); - - - sal_Int32 pos = sAbURI.indexOf( MOZ_SCHEMA ); - if ( pos != -1 ) { - const sal_Char* LDAP_SCHEMA = "ldap://"; - sAbURI = sAbURI.replaceAt (pos, rtl_str_getLength( MOZ_SCHEMA ), OString(LDAP_SCHEMA) ); - } - - pos = sAbURI.indexOf( QUERY_CHAR ); - if ( pos != -1 ) { - sal_Int32 len = sAbURI.getLength(); - sAbURI = sAbURI.replaceAt( pos, len - pos, OString("") ); - } - const sal_Unicode* bindDN=nsnull; - if (!sAbBindDN.isEmpty()) - { - bindDN = sAbBindDN.getStr(); - } - - RunArgs args; - args.funcIndex = ProxiedFunc::FUNC_TESTLDAP_INIT_LDAP; - args.argCount = 4; - args.arg1 = (void*)sAbURI.getStr(); - args.arg2 = (void*)bindDN; - args.arg3 = (void*)sAbPassword.getStr(); - args.arg4 = (void*)&useSSL; - - MNSMozabProxy xMProxy; - rv = xMProxy.StartProxy( &args, m_ProductType, OUString() ); - if ( NS_SUCCEEDED( rv ) ) //Init LDAP,pass OUString() to StarProxy to ignore profile switch - { - args.funcIndex = ProxiedFunc::FUNC_TESTLDAP_IS_LDAP_CONNECTED; - TimeValue timeValue = { 1, 0 }; // 1 * 30 Seconds timeout - sal_Int32 times=0; - while ( times++ < 30 ) - { - rv = xMProxy.StartProxy( &args, m_ProductType, OUString() ); - if ( NS_SUCCEEDED( rv ) ) - // connected successfully - break; - - if ( rv == (nsresult)PR_NOT_CONNECTED_ERROR ) - // connection failed - break; - - // not yet decided - continue waiting - osl_waitThread( &timeValue ); - } - } - m_aError.setResId( STR_COULD_NOT_CONNECT_LDAP ); - return NS_SUCCEEDED( rv ) ? sal_True : sal_False; -} - -sal_Bool MDatabaseMetaDataHelper::NewAddressBook(OConnection* _pCon,const OUString & aTableName) -{ - sal_Bool bIsMozillaAB; - - bIsMozillaAB = !_pCon->usesFactory() && ! _pCon->isLDAP(); - - if ( !bIsMozillaAB ) - { - m_aError.setResId( STR_NO_TABLE_CREATION_SUPPORT ); - return sal_False; - } - else - OSL_TRACE("Create table"); - - // Get the mozilla addressbooks from the base directory. - MNSMozabProxy xMProxy; - RunArgs args; - args.funcIndex = ProxiedFunc::FUNC_NEW_ADDRESS_BOOK; - args.argCount = 1; - args.arg1 = (void*)&aTableName; - nsresult rv = xMProxy.StartProxy(&args,m_ProductType,m_ProfileName); - - _pCon->setForceLoadTables(sal_True); //force reload table next time - if (rv == NS_ERROR_FILE_IS_LOCKED) - { - m_aError.setResId( STR_MOZILLA_IS_RUNNING ); - } - else if (NS_FAILED(rv)) - { - m_aError.set( STR_COULD_NOT_CREATE_ADDRESSBOOK, 0, OUString::number( sal_Int32(rv), 16 ) ); - } - OSL_TRACE( "OUT MDatabaseMetaDataHelper::NewAddressBook()" ); - return NS_SUCCEEDED(rv) ? sal_True : sal_False; -} -nsresult NewAddressBook(const OUString * aName) -{ - if (isProfileLocked(NULL)) - return NS_ERROR_FILE_IS_LOCKED; - nsresult rv; - nsCOMPtr<nsIAbDirectoryProperties> aProperties = do_CreateInstance(NS_ABDIRECTORYPROPERTIES_CONTRACTID, &rv); - NS_ENSURE_ARG_POINTER(aProperties); - const OUString& uName = *aName; - nsString nsName; - MTypeConverter::ouStringToNsString(uName,nsName); - aProperties->SetDescription(nsName); - - nsCOMPtr<nsIRDFService> rdfService = do_GetService (kRDFServiceCID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr<nsIRDFResource> parentResource; - rv = rdfService->GetResource(NS_LITERAL_CSTRING(kAllDirectoryRoot), getter_AddRefs(parentResource)); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr<nsIAbDirectory> parentDir = do_QueryInterface(parentResource, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - rv = parentDir->CreateNewDirectory(aProperties); - return rv; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.hxx b/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.hxx deleted file mode 100644 index 1cdb1bd588b9..000000000000 --- a/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.hxx +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MDATABASEMETADATAHELPER_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MDATABASEMETADATAHELPER_HXX - -#include "MErrorResource.hxx" -#include <comphelper/proparrhlp.hxx> -#include <comphelper/propertycontainer.hxx> -#include "FDatabaseMetaDataResultSet.hxx" - -#include <MConnection.hxx> -#include <com/sun/star/uno/Sequence.hxx> -#include <com/sun/star/mozilla/MozillaProductType.hpp> - -namespace connectivity -{ - namespace mozab - { - class MDatabaseMetaDataHelper - { - private: - sal_Bool m_bProfileExists ; - ::std::vector< OUString > m_aTableNames; - ::std::vector< OUString > m_aTableTypes; - ::com::sun::star::mozilla::MozillaProductType m_ProductType; - OUString m_ProfileName; - ErrorDescriptor m_aError; - - public: - MDatabaseMetaDataHelper(); - ~MDatabaseMetaDataHelper(); - - - sal_Bool getTableStrings( OConnection* _pCon, - ::std::vector< OUString >& _rStrings, - ::std::vector< OUString >& _rTypes); - - sal_Bool getTables( OConnection* _pCon, - const OUString& tableNamePattern, - const ::com::sun::star::uno::Sequence< OUString >& types, - ODatabaseMetaDataResultSet::ORows& _rRows); - sal_Bool testLDAPConnection( OConnection* _pCon ); - sal_Bool NewAddressBook( OConnection* _pCon,const OUString & aTableName); - - inline const ErrorDescriptor& getError() const { return m_aError; } - }; - } - -} -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MDATABASEMETADATAHELPER_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/mozillasrc/MErrorResource.hxx b/connectivity/source/drivers/mozab/mozillasrc/MErrorResource.hxx deleted file mode 100644 index cc5cec5ea6c1..000000000000 --- a/connectivity/source/drivers/mozab/mozillasrc/MErrorResource.hxx +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MERRORRESOURCE_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MERRORRESOURCE_HXX - -#include <rtl/ustring.hxx> - -namespace connectivity -{ - namespace mozab - { - class ErrorDescriptor - { - private: - sal_uInt16 m_nErrorResourceId; - sal_Int32 m_nErrorCondition; - OUString m_sParameter; - - public: - ErrorDescriptor() - :m_nErrorResourceId(0) - ,m_nErrorCondition(0) - ,m_sParameter() - { - } - - inline void set( const sal_uInt16 _nErrorResourceId, const sal_Int32 _nErrorCondition, const OUString& _rParam ) - { - m_nErrorResourceId = _nErrorResourceId; - m_nErrorCondition = _nErrorCondition; - m_sParameter = _rParam; - } - inline void setResId( const sal_uInt16 _nErrorResourceId ) - { - m_nErrorResourceId = _nErrorResourceId; - } - inline void reset() - { - m_nErrorResourceId = 0; - m_nErrorCondition = 0; - } - - inline sal_uInt16 getResId() const { return m_nErrorResourceId; } - inline sal_Int32 getErrorCondition() const { return m_nErrorCondition; } - inline const OUString& getParameter() const { return m_sParameter; } - - inline bool is() const { return ( m_nErrorResourceId != 0 ) || ( m_nErrorCondition != 0 ); } - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MERRORRESOURCE_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/mozillasrc/MLdapAttributeMap.cxx b/connectivity/source/drivers/mozab/mozillasrc/MLdapAttributeMap.cxx deleted file mode 100644 index 2b39a6e2ed1b..000000000000 --- a/connectivity/source/drivers/mozab/mozillasrc/MLdapAttributeMap.cxx +++ /dev/null @@ -1,432 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <rtl/strbuf.hxx> - // keep this include at the beginning. Some of the other includes seems to inject a symbol "l" into the - // global namespace, which leads to a compiler warning in strbuf.hxx, about some parameters named "l" - // hiding objects "in an outer scope". - -#include "MLdapAttributeMap.hxx" -#include "MTypeConverter.hxx" -#include "MQueryHelper.hxx" - -#include <tools/diagnose_ex.h> - -#include <unordered_map> - -namespace connectivity { namespace mozab { - - namespace - { - typedef NS_STDCALL_FUNCPROTO(nsresult, CardPropertyGetter, nsIAbCard, GetFirstName, (PRUnichar**)); - typedef NS_STDCALL_FUNCPROTO(nsresult, CardPropertySetter, nsIAbCard, SetFirstName, (const PRUnichar*)); - struct CardPropertyData - { - const sal_Char* pLDAPAttributeList; - CardPropertyGetter PropGetter; - CardPropertySetter PropSetter; - - CardPropertyData() - :pLDAPAttributeList( NULL ) - ,PropGetter( NULL ) - ,PropSetter( NULL ) - { - } - CardPropertyData( const sal_Char* _pLDAPAttributeList, CardPropertyGetter _PropGetter, CardPropertySetter _PropSetter ) - :pLDAPAttributeList( _pLDAPAttributeList ) - ,PropGetter( _PropGetter ) - ,PropSetter( _PropSetter ) - { - } - }; - - typedef std::unordered_map< OString, CardPropertyData, OStringHash > MapPropertiesToAttributes; - - #define DEF_CARD_ACCESS( PropertyName ) \ - &nsIAbCard::Get##PropertyName, &nsIAbCard::Set##PropertyName - - static const MapPropertiesToAttributes& lcl_getPropertyMap() - { - static MapPropertiesToAttributes aMap; - if ( aMap.empty() ) - { - struct MapEntry - { - const sal_Char* pAsciiPropertyName; - const sal_Char* pAsciiAttrributeList; - CardPropertyGetter PropGetter; - CardPropertySetter PropSetter; - }; - const MapEntry aEntries[] = { - { "FirstName", "givenname", DEF_CARD_ACCESS( FirstName ) }, - { "LastName", "sn,surnname", DEF_CARD_ACCESS( LastName ) }, - { "DisplayName", "cn,commonname,displayname", DEF_CARD_ACCESS( DisplayName ) }, - { "NickName", "xmozillanickname", DEF_CARD_ACCESS( NickName ) }, - { "PrimaryEmail", "mail", DEF_CARD_ACCESS( PrimaryEmail ) }, - { "SecondEmail", "xmozillasecondemail", DEF_CARD_ACCESS( SecondEmail ) }, - { "WorkPhone", "telephonenumber", DEF_CARD_ACCESS( WorkPhone ) }, - { "HomePhone", "homephone", DEF_CARD_ACCESS( HomePhone ) }, - { "FaxNumber", "fax,facsimiletelephonenumber", DEF_CARD_ACCESS( FaxNumber ) }, - { "PagerNumber", "pager,pagerphone", DEF_CARD_ACCESS( PagerNumber ) }, - { "CellularNumber", "mobile,cellphone,carphone", DEF_CARD_ACCESS( CellularNumber ) }, - { "HomeAddress", "homepostaladdress,mozillaHomeStreet", DEF_CARD_ACCESS( HomeAddress ) }, - { "HomeAddress2", "mozillaHomeStreet2", DEF_CARD_ACCESS( HomeAddress2 ) }, - { "HomeCity", "homelocality,mozillaHomeLocalityName", DEF_CARD_ACCESS( HomeCity ) }, - { "HomeState", "homeregion,mozillaHomeState", DEF_CARD_ACCESS( HomeState ) }, - { "HomeZipCode", "homepostalcode,mozillaHomePostalCode", DEF_CARD_ACCESS( HomeZipCode ) }, - { "HomeCountry", "homecountryname,mozillaHomeCountryName", DEF_CARD_ACCESS( HomeCountry ) }, - { "WorkAddress", "postofficebox,streetaddress,streetaddress1", DEF_CARD_ACCESS( WorkAddress ) }, - { "WorkAddress2", "streetaddress2", DEF_CARD_ACCESS( WorkAddress2 ) }, - { "WorkCity", "l,locality", DEF_CARD_ACCESS( WorkCity ) }, - { "WorkState", "st,region", DEF_CARD_ACCESS( WorkState ) }, - { "WorkZipCode", "postalcode,zip", DEF_CARD_ACCESS( WorkZipCode ) }, - { "WorkCountry", "countryname", DEF_CARD_ACCESS( WorkCountry ) }, - { "JobTitle", "title", DEF_CARD_ACCESS( JobTitle ) }, - { "Department", "ou,orgunit,department,departmentnumber", DEF_CARD_ACCESS( Department ) }, - { "Company", "o,company", DEF_CARD_ACCESS( Company ) }, - { "WebPage1", "workurl", DEF_CARD_ACCESS( WebPage1 ) }, - { "WebPage2", "homeurl", DEF_CARD_ACCESS( WebPage2 ) }, - { "BirthYear", "birthyear", DEF_CARD_ACCESS( BirthYear ) }, - { "BirthMonth", "birthmonth", DEF_CARD_ACCESS( BirthMonth ) }, - { "BirthDay", "birthday", DEF_CARD_ACCESS( BirthDay ) }, - { "Custom1", "custom1", DEF_CARD_ACCESS( Custom1 ) }, - { "Custom2", "custom2", DEF_CARD_ACCESS( Custom2 ) }, - { "Custom3", "custom3", DEF_CARD_ACCESS( Custom3 ) }, - { "Custom4", "custom4", DEF_CARD_ACCESS( Custom4 ) }, - { "Notes", "notes,description", DEF_CARD_ACCESS( Notes ) }, - { "PreferMailFormat", "xmozillausehtmlmail", NULL, NULL }, - { NULL, NULL, NULL, NULL } - }; - const MapEntry* loop = aEntries; - while ( loop->pAsciiPropertyName ) - { - aMap[ OString( loop->pAsciiPropertyName ) ] = - CardPropertyData( loop->pAsciiAttrributeList, loop->PropGetter, loop->PropSetter ); - ++loop; - } - } - return aMap; - } - } - - - struct AttributeMap_Data - { - }; - - MLdapAttributeMap::MLdapAttributeMap() - :m_pData( new AttributeMap_Data ) - { - } - - - MLdapAttributeMap::~MLdapAttributeMap() - { - } - - - NS_IMPL_THREADSAFE_ISUPPORTS1( MLdapAttributeMap, nsIAbLDAPAttributeMap ) - - - NS_IMETHODIMP MLdapAttributeMap::GetAttributeList(const nsACString & aProperty, nsACString & _retval) - { - OString sProperty( MTypeConverter::nsACStringToOString( aProperty ) ); - - const MapPropertiesToAttributes& rPropertyMap( lcl_getPropertyMap() ); - MapPropertiesToAttributes::const_iterator pos = rPropertyMap.find( sProperty ); - - if ( pos == rPropertyMap.end() ) - { - _retval.SetIsVoid( PR_TRUE ); - } - else - { - MTypeConverter::asciiToNsACString( pos->second.pLDAPAttributeList, _retval ); - } - - return NS_OK; - } - - - NS_IMETHODIMP MLdapAttributeMap::GetAttributes(const nsACString & aProperty, PRUint32* aCount, char*** aAttrs) - { - OSL_FAIL( "MLdapAttributeMap::GetAttributes: not implemented!" ); - (void)aProperty; - (void)aCount; - (void)aAttrs; - return NS_ERROR_NOT_IMPLEMENTED; - } - - - NS_IMETHODIMP MLdapAttributeMap::GetFirstAttribute(const nsACString & aProperty, nsACString & _retval) - { - OString sProperty( MTypeConverter::nsACStringToOString( aProperty ) ); - - const MapPropertiesToAttributes& rPropertyMap( lcl_getPropertyMap() ); - MapPropertiesToAttributes::const_iterator pos = rPropertyMap.find( sProperty ); - - if ( pos == rPropertyMap.end() ) - { - _retval.SetIsVoid( PR_TRUE ); - } - else - { - sal_Int32 tokenPos(0); - OString sAttributeList( pos->second.pLDAPAttributeList ); - MTypeConverter::asciiToNsACString( sAttributeList.getToken( 0, ',', tokenPos ).getStr(), _retval ); - } - - return NS_OK; - } - - - NS_IMETHODIMP MLdapAttributeMap::SetAttributeList(const nsACString & aProperty, const nsACString & aAttributeList, PRBool allowInconsistencies) - { - OSL_FAIL( "MLdapAttributeMap::SetAttributeList: not implemented!" ); - (void)aProperty; - (void)aAttributeList; - (void)allowInconsistencies; - return NS_ERROR_NOT_IMPLEMENTED; - } - - - NS_IMETHODIMP MLdapAttributeMap::GetProperty(const nsACString & aAttribute, nsACString & _retval) - { - OSL_FAIL( "MLdapAttributeMap::GetProperty: not implemented!" ); - (void)aAttribute; - (void)_retval; - return NS_ERROR_NOT_IMPLEMENTED; - } - - - NS_IMETHODIMP MLdapAttributeMap::GetAllCardAttributes(nsACString & _retval) - { - const MapPropertiesToAttributes& rPropertyMap( lcl_getPropertyMap() ); - - OStringBuffer aAllAttributes; - for ( MapPropertiesToAttributes::const_iterator loop = rPropertyMap.begin(); - loop != rPropertyMap.end(); - ++loop - ) - { - aAllAttributes.append( loop->second.pLDAPAttributeList ); - if ( loop != rPropertyMap.end() ) - aAllAttributes.append( ',' ); - } - - MTypeConverter::asciiToNsACString( aAllAttributes.getStr(), _retval ); - return NS_OK; - } - - - NS_IMETHODIMP MLdapAttributeMap::CheckState() - { - // we do not allow modifying the map, so we're always in a valid state - return NS_OK; - } - - - NS_IMETHODIMP MLdapAttributeMap::SetFromPrefs(const nsACString & aPrefBranchName) - { - OSL_FAIL( "MLdapAttributeMap::SetFromPrefs: not implemented!" ); - (void)aPrefBranchName; - return NS_ERROR_NOT_IMPLEMENTED; - } - - - NS_IMETHODIMP MLdapAttributeMap::SetCardPropertiesFromLDAPMessage(nsILDAPMessage* aMessage, nsIAbCard* aCard) - { - NS_ENSURE_ARG_POINTER( aMessage ); - NS_ENSURE_ARG_POINTER( aCard ); - - // in case that's not present in the LDAP message: set the "preferred mail format" to "none" - aCard->SetPreferMailFormat( nsIAbPreferMailFormat::unknown ); - - const MapPropertiesToAttributes& rPropertyMap( lcl_getPropertyMap() ); - for ( MapPropertiesToAttributes::const_iterator prop = rPropertyMap.begin(); - prop != rPropertyMap.end(); - ++prop - ) - { - // split the list of attributes for the current property - OString sAttributeList( prop->second.pLDAPAttributeList ); - OString sAttribute; - - sal_Int32 tokenPos = 0; - while ( tokenPos != -1 ) - { - sAttribute = sAttributeList.getToken( 0, ',', tokenPos ); - - // retrieve the values for the current attribute - PRUint32 valueCount = 0; - PRUnichar** values = NULL; - nsresult rv = aMessage->GetValues( sAttribute.getStr(), &valueCount, &values ); - if ( NS_FAILED( rv ) ) - // try the next attribute - continue; - - if ( valueCount ) - { - CardPropertySetter propSetter = prop->second.PropSetter; - OSL_ENSURE( propSetter, - "MLdapAttributeMap::SetCardPropertiesFromLDAPMessage: " - "unexpected: could retrieve an attribute value, but have no setter for it!" ); - if ( propSetter ) - { - (aCard->*propSetter)( values[0] ); - } - - // we're done with this property - no need to handle the remaining attributes which - // map to it - break; - } - } - } - return NS_OK; - } - - - namespace - { - struct PreferMailFormatType - { - const sal_Char* description; - PRUint32 formatType; - - PreferMailFormatType() - :description( NULL ) - ,formatType( nsIAbPreferMailFormat::unknown ) - { - } - - PreferMailFormatType( const sal_Char* _description, PRUint32 _formatType ) - :description( _description ) - ,formatType( _formatType ) - { - } - }; - - static const PreferMailFormatType* lcl_getMailFormatTypes() - { - static const PreferMailFormatType aMailFormatTypes[] = - { - PreferMailFormatType( "text/plain", nsIAbPreferMailFormat::plaintext ), - PreferMailFormatType( "text/html", nsIAbPreferMailFormat::html ), - PreferMailFormatType( "unknown", nsIAbPreferMailFormat::unknown ), - PreferMailFormatType() - }; - return aMailFormatTypes; - } - } - - - void MLdapAttributeMap::fillCardFromResult( nsIAbCard& _card, const MQueryHelperResultEntry& _result ) - { - _card.SetPreferMailFormat( nsIAbPreferMailFormat::unknown ); - - OUString resultValue; - - const MapPropertiesToAttributes& rPropertyMap( lcl_getPropertyMap() ); - for ( MapPropertiesToAttributes::const_iterator prop = rPropertyMap.begin(); - prop != rPropertyMap.end(); - ++prop - ) - { - resultValue = _result.getValue( prop->first ); - - CardPropertySetter propSetter = prop->second.PropSetter; - if ( propSetter ) - { - // PRUnichar != sal_Unicode in mingw - (_card.*propSetter)( reinterpret_cast_mingw_only<const PRUnichar *>(resultValue.getStr()) ); - } - else - { - if ( prop->first.equals( "PreferMailFormat" ) ) - { - unsigned int format = nsIAbPreferMailFormat::unknown; - const PreferMailFormatType* pMailFormatType = lcl_getMailFormatTypes(); - while ( pMailFormatType->description ) - { - if ( resultValue.equalsAscii( pMailFormatType->description ) ) - { - format = pMailFormatType->formatType; - break; - } - ++pMailFormatType; - } - _card.SetPreferMailFormat(format); - } - else - OSL_FAIL( "MLdapAttributeMap::fillCardFromResult: unexpected property without default setters!" ); - } - } - } - - - void MLdapAttributeMap::fillResultFromCard( MQueryHelperResultEntry& _result, nsIAbCard& _card ) - { - nsXPIDLString value; - OUString resultValue; - - const MapPropertiesToAttributes& rPropertyMap( lcl_getPropertyMap() ); - for ( MapPropertiesToAttributes::const_iterator prop = rPropertyMap.begin(); - prop != rPropertyMap.end(); - ++prop - ) - { - CardPropertyGetter propGetter = prop->second.PropGetter; - if ( propGetter ) - { - (_card.*propGetter)( getter_Copies( value ) ); - - nsAutoString temp( value ); - MTypeConverter::nsStringToOUString( temp, resultValue ); - } - else - { - if ( prop->first.equals( "PreferMailFormat" ) ) - { - unsigned int format = nsIAbPreferMailFormat::unknown; - _card.GetPreferMailFormat( &format ); - const PreferMailFormatType* pMailFormatType = lcl_getMailFormatTypes(); - while ( pMailFormatType->description ) - { - if ( format == pMailFormatType->formatType ) - { - resultValue = OUString::createFromAscii( pMailFormatType->description ); - break; - } - ++pMailFormatType; - } - } - else - OSL_FAIL( "MLdapAttributeMap::fillResultFromCard: unexpected property without default getters!" ); - } - - _result.insert( prop->first, resultValue ); - } - } - - -} } // namespace connectivity::mozab - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/mozillasrc/MLdapAttributeMap.hxx b/connectivity/source/drivers/mozab/mozillasrc/MLdapAttributeMap.hxx deleted file mode 100644 index 0562eccbf54a..000000000000 --- a/connectivity/source/drivers/mozab/mozillasrc/MLdapAttributeMap.hxx +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MLDAPATTRIBUTEMAP_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MLDAPATTRIBUTEMAP_HXX - -#include "MNSInclude.hxx" - -#include <memory> - - -namespace connectivity { namespace mozab { - - - struct AttributeMap_Data; - class MQueryHelperResultEntry; - - /** implements the nsIAbLDAPAttributeMap interface - - Somewhere between Mozilla 1.7.5 and SeaMonkey 1.1.12, the LDAP address book - implementation was changed to take the attribute mapping (from LDAP attributes - to address book properties) not directly from the preferences. Instead, this mapping - is now delivered by a dedicated implementation (supporting the nsIAbLDAPAttributeMap - interface). - - */ - class MLdapAttributeMap : public nsIAbLDAPAttributeMap - { - public: - MLdapAttributeMap(); - - NS_DECL_ISUPPORTS - NS_DECL_NSIABLDAPATTRIBUTEMAP - - static void fillCardFromResult( nsIAbCard& _card, const MQueryHelperResultEntry& _result ); - static void fillResultFromCard( MQueryHelperResultEntry& _result, nsIAbCard& _card ); - - protected: - virtual ~MLdapAttributeMap(); - - private: - ::std::unique_ptr< AttributeMap_Data > m_pData; - }; - - -} } // namespace connectivity::mozab - - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MLDAPATTRIBUTEMAP_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNSDeclares.hxx b/connectivity/source/drivers/mozab/mozillasrc/MNSDeclares.hxx deleted file mode 100644 index 203af67fd6b5..000000000000 --- a/connectivity/source/drivers/mozab/mozillasrc/MNSDeclares.hxx +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MNSDECLARES_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MNSDECLARES_HXX - -#include <sal/types.h> - - -const sal_Int32 RowStates_Normal = 0; -const sal_Int32 RowStates_Inserted = 1; -const sal_Int32 RowStates_Updated = 2; -const sal_Int32 RowStates_Deleted = 4; -const sal_Int32 RowStates_Error = 32; - -namespace connectivity{ - namespace mozab{ - class OConnection; - } -} - -bool isProfileLocked(connectivity::mozab::OConnection* _pCon); - -class nsIAbDirectory; -sal_Int32 getDirectoryType(const nsIAbDirectory* directory); - - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MNSDECLARES_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNSInclude.hxx b/connectivity/source/drivers/mozab/mozillasrc/MNSInclude.hxx deleted file mode 100644 index c2ad93c47787..000000000000 --- a/connectivity/source/drivers/mozab/mozillasrc/MNSInclude.hxx +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MNSINCLUDE_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MNSINCLUDE_HXX - - -// Only include Mozilla include files once and using this file... - - -// moved this here and in first position due to "long l;" unxsoli4 warning -#include <rtl/ustrbuf.hxx> - -#include "pre_include_mozilla.h" - -#include <nsDebug.h> - -#include <nsCOMPtr.h> -#include <nsISupportsArray.h> -#include <nsString.h> - -#include <nsMemory.h> -#include <prtypes.h> -#include <nsRDFCID.h> -#include <nsXPIDLString.h> -#include <nsIRDFService.h> -#include <nsIRDFResource.h> -#include <nsReadableUtils.h> -#include <msgCore.h> -#include <nsIServiceManager.h> -#include <nsIAbCard.h> -#include <nsAbBaseCID.h> -#include <nsAbAddressCollecter.h> -#include <nsIPref.h> -#include <nsIAddrBookSession.h> -#include <nsIMsgHeaderParser.h> -#include <nsIAbDirectory.h> -#include <nsAbDirectoryQuery.h> -#include <nsIAbDirectoryQuery.h> -#include <nsIAbDirectoryQueryProxy.h> -#include <nsIAbDirFactory.h> -#include <nsIRunnable.h> -#include <nsIAbLDAPAttributeMap.h> -#include <nsILDAPMessage.h> - -#include <prerr.h> - -#include "post_include_mozilla.h" - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MNSINCLUDE_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNSMozabProxy.cxx b/connectivity/source/drivers/mozab/mozillasrc/MNSMozabProxy.cxx deleted file mode 100644 index 5afbc95bdb51..000000000000 --- a/connectivity/source/drivers/mozab/mozillasrc/MNSMozabProxy.cxx +++ /dev/null @@ -1,395 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "MNSMozabProxy.hxx" - -#include "resource/mozab_res.hrc" -#include "MDatabaseMetaDataHelper.hxx" -#include "MQuery.hxx" -#include <osl/mutex.hxx> -#include <osl/conditn.hxx> -#include <osl/thread.hxx> - -#include "pre_include_mozilla.h" -#include <nsIProxyObjectManager.h> -// More Mozilla includes for LDAP Connection Test -#include "prprf.h" -#include "nsILDAPURL.h" -#include "nsILDAPMessage.h" -#include "nsILDAPMessageListener.h" -#include "nsILDAPErrors.h" -#include "nsILDAPConnection.h" -#include "nsILDAPOperation.h" -#include "post_include_mozilla.h" -#include "MQueryHelper.hxx" -#include <com/sun/star/uno/Reference.hxx> -#include <comphelper/processfactory.hxx> -#include <com/sun/star/mozilla/XProxyRunner.hpp> - -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::mozilla; - - -#define TYPEASSERT(value,type) if (value != type) return !NS_OK; - -using namespace connectivity::mozab; - -/* Implementation file */ - -static ::osl::Mutex m_aThreadMutex; -extern nsresult NewAddressBook(const OUString * aName); - - -MNSMozabProxy::MNSMozabProxy() -{ - m_Args = NULL; -#if OSL_DEBUG_LEVEL > 0 - m_oThreadID = osl::Thread::getCurrentIdentifier(); -#endif - acquire(); -} - -MNSMozabProxy::~MNSMozabProxy() -{ -} - -sal_Int32 MNSMozabProxy::StartProxy(RunArgs * args,::com::sun::star::mozilla::MozillaProductType aProduct,const OUString &aProfile) -{ - OSL_TRACE( "IN : MNSMozabProxy::StartProxy()" ); - ::osl::MutexGuard aGuard(m_aThreadMutex); - m_Product = aProduct; - m_Profile = aProfile; - m_Args = args; - if (!xRunner.is()) - { - Reference<XMultiServiceFactory> xFactory = ::comphelper::getProcessServiceFactory(); - OSL_ENSURE( xFactory.is(), "can't get service factory" ); - ::com::sun::star::uno::Reference<XInterface> xInstance = xFactory->createInstance("com.sun.star.mozilla.MozillaBootstrap"); - OSL_ENSURE( xInstance.is(), "failed to create instance" ); - xRunner = ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XProxyRunner >(xInstance,UNO_QUERY); - } - const ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XCodeProxy > aCode(this); - return xRunner->Run(aCode); -} - -extern nsresult getTableStringsProxied(const sal_Char* sAbURI, sal_Int32 *nDirectoryType,MNameMapper *nmap, - ::std::vector< OUString >* _rStrings, - ::std::vector< OUString >* _rTypes, - sal_Int32* pErrorId ); - -::com::sun::star::mozilla::MozillaProductType SAL_CALL MNSMozabProxy::getProductType( ) throw (::com::sun::star::uno::RuntimeException) -{ - return m_Product; -} -OUString SAL_CALL MNSMozabProxy::getProfileName( ) throw (::com::sun::star::uno::RuntimeException) -{ - return m_Profile; -} - -sal_Int32 SAL_CALL MNSMozabProxy::run( ) throw (::com::sun::star::uno::RuntimeException) -{ -#if OSL_DEBUG_LEVEL > 0 - OSL_TRACE( "IN : MNSMozabProxy::Run() Caller thread :%4d" , m_oThreadID ); -#else - OSL_TRACE( "IN : MNSMozabProxy::Run()" ); -#endif - nsresult rv = NS_ERROR_INVALID_ARG; - if (m_Args == NULL) - return NS_ERROR_INVALID_ARG; - switch(m_Args->funcIndex) - { - case ProxiedFunc::FUNC_TESTLDAP_INIT_LDAP: - case ProxiedFunc::FUNC_TESTLDAP_IS_LDAP_CONNECTED: - case ProxiedFunc::FUNC_TESTLDAP_RELEASE_RESOURCE: - rv = testLDAPConnection(); - break; - case ProxiedFunc::FUNC_GET_TABLE_STRINGS: - rv = getTableStringsProxied((const sal_Char*)m_Args->arg1, - (sal_Int32 *)m_Args->arg2, - (MNameMapper *)m_Args->arg3, - (::std::vector< OUString >*)m_Args->arg4, - (::std::vector< OUString >*)m_Args->arg5, - (sal_Int32 *)m_Args->arg6); - break; - case ProxiedFunc::FUNC_EXECUTE_QUERY: - if (m_Args->arg1 && m_Args->arg2) - { - rv = ((MQuery*)m_Args->arg1)->executeQueryProxied((OConnection*)m_Args->arg2); - } - break; - case ProxiedFunc::FUNC_QUERYHELPER_CREATE_NEW_CARD: - case ProxiedFunc::FUNC_QUERYHELPER_DELETE_CARD: - case ProxiedFunc::FUNC_QUERYHELPER_COMMIT_CARD: - case ProxiedFunc::FUNC_QUERYHELPER_RESYNC_CARD: - if (m_Args->arg1) - { - rv = QueryHelperStub(); - } - break; - case ProxiedFunc::FUNC_NEW_ADDRESS_BOOK: - if (m_Args->arg1) - { - rv = NewAddressBook((const OUString*)m_Args->arg1 ); - } - break; - default: - return NS_ERROR_INVALID_ARG; - } - return rv; -} - -nsresult MNSMozabProxy::QueryHelperStub() -{ - nsresult rv = NS_ERROR_INVALID_ARG; - MQueryHelper * mHelper=(MQueryHelper*) m_Args->arg1; - switch(m_Args->funcIndex) - { - case ProxiedFunc::FUNC_QUERYHELPER_CREATE_NEW_CARD: - if (m_Args->arg2 ) //m_Args->arg2 used to return cord number - { - *((sal_Int32*)m_Args->arg2) = mHelper->createNewCard(); - rv = NS_OK; - } - break; - case ProxiedFunc::FUNC_QUERYHELPER_DELETE_CARD: - if (m_Args->arg2 && m_Args->arg3 ) //m_Args->arg2 used to get the cord number - { - rv = mHelper->deleteCard(*((sal_uInt32*)m_Args->arg2),(nsIAbDirectory*)m_Args->arg3); - } - break; - case ProxiedFunc::FUNC_QUERYHELPER_COMMIT_CARD: - if (m_Args->arg2 && m_Args->arg3 ) //m_Args->arg2 used to get the cord number - { - rv = mHelper->commitCard(*((sal_uInt32*)m_Args->arg2),(nsIAbDirectory*)m_Args->arg3); - } - break; - case ProxiedFunc::FUNC_QUERYHELPER_RESYNC_CARD: - if (m_Args->arg2) //m_Args->arg2 used to get the cord number - { - rv = mHelper->resyncRow(*((sal_uInt32*)m_Args->arg2)); - } - break; - default: - break; - } - return rv; -} - - -#define NS_LDAPCONNECTION_CONTRACTID "@mozilla.org/network/ldap-connection;1" -#define NS_LDAPOPERATION_CONTRACTID "@mozilla.org/network/ldap-operation;1" -#define NS_LDAPURL_CONTRACTID "@mozilla.org/network/ldap-url;1" - -namespace connectivity { - namespace mozab { - class MLDAPMessageListener : public nsILDAPMessageListener - { - NS_DECL_ISUPPORTS - NS_DECL_NSILDAPMESSAGELISTENER - - MLDAPMessageListener(); - virtual ~MLDAPMessageListener(); - - sal_Bool initialized() const; - sal_Bool goodConnection() const { return initialized() && m_GoodConnection; } - - protected: - - ::osl::Mutex m_aMutex; - ::osl::Condition m_aCondition; - - sal_Bool m_IsComplete; - sal_Bool m_GoodConnection; - - void setConnectionStatus( sal_Bool _good ); - }; - } -} - -NS_IMPL_THREADSAFE_ISUPPORTS1(MLDAPMessageListener, nsILDAPMessageListener) - -MLDAPMessageListener::MLDAPMessageListener() - : mRefCnt( 0 ) - , m_IsComplete( sal_False ) - , m_GoodConnection( sal_False ) -{ - m_aCondition.reset(); -} - -MLDAPMessageListener::~MLDAPMessageListener() -{ -} - -sal_Bool MLDAPMessageListener::initialized() const -{ - return const_cast< MLDAPMessageListener* >( this )->m_aCondition.check(); -} - -void MLDAPMessageListener::setConnectionStatus( sal_Bool _good ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - m_IsComplete = sal_True; - m_GoodConnection = _good; - - m_aCondition.set(); -} - -NS_IMETHODIMP MLDAPMessageListener::OnLDAPInit(nsILDAPConnection* /*aConn*/, nsresult aStatus ) -{ - setConnectionStatus( NS_SUCCEEDED( aStatus ) ? sal_True : sal_False ); - return aStatus; -} - -NS_IMETHODIMP MLDAPMessageListener::OnLDAPMessage( nsILDAPMessage* aMessage ) -{ - nsresult rv; - - PRInt32 messageType; - rv = aMessage->GetType(&messageType); - NS_ENSURE_SUCCESS(rv, rv); - PRInt32 errCode; - switch (messageType) - { - case nsILDAPMessage::RES_BIND: - rv = aMessage->GetErrorCode(&errCode); - // if the login failed - if (errCode != (PRInt32)nsILDAPErrors::SUCCESS) { - setConnectionStatus( sal_False ); - } - else - setConnectionStatus( sal_True ); - break; - case nsILDAPMessage::RES_SEARCH_RESULT: - setConnectionStatus( sal_True ); - break; - default: - break; - } - - return NS_OK; -} - - - -nsresult -MNSMozabProxy::testLDAPConnection( ) -{ - nsresult rv=NS_ERROR_INVALID_ARG; - switch(m_Args->funcIndex) - { - case ProxiedFunc::FUNC_TESTLDAP_INIT_LDAP: - if (m_Args->arg1 && m_Args->arg4 ) - { - rv = InitLDAP((sal_Char*)m_Args->arg1,(sal_Unicode*)m_Args->arg2,(sal_Unicode*)m_Args->arg3,(sal_Bool*)m_Args->arg4); - } - break; - case ProxiedFunc::FUNC_TESTLDAP_IS_LDAP_CONNECTED: - if (m_Args->arg5) - { - const MLDAPMessageListener* pListener( static_cast< const MLDAPMessageListener* >( m_Args->arg5 ) ); - if ( pListener->initialized() ) - rv = pListener->goodConnection() ? 0 : (nsresult)PR_NOT_CONNECTED_ERROR; - else - rv = (nsresult)PR_CONNECT_TIMEOUT_ERROR; - } - break; - case ProxiedFunc::FUNC_TESTLDAP_RELEASE_RESOURCE: - if (m_Args->arg5) - { - ((MLDAPMessageListener*)m_Args->arg5)->Release(); - delete (MLDAPMessageListener*)m_Args->arg5; - m_Args->arg5 = NULL; - rv = 0; - } - break; - default: - return NS_ERROR_INVALID_ARG; - } - return rv; -} -nsresult -MNSMozabProxy::InitLDAP(sal_Char* sUri, sal_Unicode* sBindDN, sal_Unicode* pPasswd,sal_Bool * nUseSSL) -{ - sal_Bool useSSL = *nUseSSL; - nsresult rv; - - nsCOMPtr<nsILDAPURL> url; - url = do_CreateInstance(NS_LDAPURL_CONTRACTID, &rv); - if ( NS_FAILED(rv) ) - return NS_ERROR_INVALID_ARG; - - rv = url->SetSpec( nsDependentCString(sUri) ); - NS_ENSURE_SUCCESS(rv, rv); - - nsCAutoString host; - rv = url->GetAsciiHost(host); - NS_ENSURE_SUCCESS(rv, rv); - - PRInt32 port; - rv = url->GetPort(&port); - NS_ENSURE_SUCCESS(rv, rv); - - nsCString dn; - rv = url->GetDn(dn); - NS_ENSURE_SUCCESS(rv, rv); - - - - // Get the ldap connection - nsCOMPtr<nsILDAPConnection> ldapConnection; - ldapConnection = do_CreateInstance(NS_LDAPCONNECTION_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - MLDAPMessageListener* messageListener = - new MLDAPMessageListener ( ); - if (messageListener == NULL) - return NS_ERROR_INVALID_ARG; - - messageListener->AddRef(); - - nsCAutoString nsBind; - // PRUnichar != sal_Unicode in mingw - nsBind.AssignWithConversion(reinterpret_cast_mingw_only<const PRUnichar *>(sBindDN)); - - // Now lets initialize the LDAP connection properly. - rv = ldapConnection->Init(host.get(), port, useSSL, nsBind, - messageListener,NULL,nsILDAPConnection::VERSION3); - // Initiate the LDAP operation - nsCOMPtr<nsILDAPOperation> ldapOperation = - do_CreateInstance(NS_LDAPOPERATION_CONTRACTID, &rv); - - rv = ldapOperation->Init(ldapConnection, messageListener, nsnull); - if (NS_FAILED(rv)) - return NS_ERROR_UNEXPECTED; // this should never happen - - if ( pPasswd && *pPasswd ) - { - nsCAutoString nsPassword; - // PRUnichar != sal_Unicode in mingw - nsPassword.AssignWithConversion(reinterpret_cast_mingw_only<const PRUnichar *>(pPasswd)); - rv = ldapOperation->SimpleBind(nsPassword); - } - - if (NS_SUCCEEDED(rv)) - m_Args->arg5 = messageListener; - return rv; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNSMozabProxy.hxx b/connectivity/source/drivers/mozab/mozillasrc/MNSMozabProxy.hxx deleted file mode 100644 index c74d2d5a1b4c..000000000000 --- a/connectivity/source/drivers/mozab/mozillasrc/MNSMozabProxy.hxx +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MNSMOZABPROXY_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MNSMOZABPROXY_HXX -#include "MNSDeclares.hxx" -#include <osl/thread.hxx> - -#include "MNSInclude.hxx" -#include <cppuhelper/implbase.hxx> -#include <com/sun/star/mozilla/XCodeProxy.hpp> -#include <com/sun/star/mozilla/XProxyRunner.hpp> - -namespace connectivity -{ - namespace mozab - { - namespace ProxiedFunc - { - enum - { - FUNC_TESTLDAP_INIT_LDAP=1, - FUNC_TESTLDAP_IS_LDAP_CONNECTED, - FUNC_TESTLDAP_RELEASE_RESOURCE, - FUNC_GET_TABLE_STRINGS, - FUNC_EXECUTE_QUERY, - FUNC_QUERYHELPER_CREATE_NEW_CARD, - FUNC_QUERYHELPER_DELETE_CARD, - FUNC_QUERYHELPER_COMMIT_CARD, - FUNC_QUERYHELPER_RESYNC_CARD, - FUNC_NEW_ADDRESS_BOOK - }; - } - - struct RunArgs - { - sal_Int32 funcIndex; //Function Index - sal_Int32 argCount; //parameter count - void * arg1; - void * arg2; - void * arg3; - void * arg4; - void * arg5; - void * arg6; - RunArgs() - { - arg1 = NULL; - arg2 = NULL; - arg3 = NULL; - arg4 = NULL; - arg5 = NULL; - arg6 = NULL; - } - }; - typedef RunArgs RunArgs; - typedef ::cppu::WeakImplHelper< ::com::sun::star::mozilla::XCodeProxy > MNSMozabProxy_BASE; - - - class MNSMozabProxy : public MNSMozabProxy_BASE - { - public: - MNSMozabProxy(); - virtual ~MNSMozabProxy(); - - //XCodeProxy - virtual sal_Int32 SAL_CALL run( ) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::mozilla::MozillaProductType SAL_CALL getProductType( ) throw (::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getProfileName( ) throw (::com::sun::star::uno::RuntimeException); - - public: - sal_Int32 StartProxy(RunArgs * args,::com::sun::star::mozilla::MozillaProductType aProduct,const OUString &aProfile); //Call this to start proxy - - protected: - nsresult testLDAPConnection(); - nsresult InitLDAP(sal_Char* sUri, sal_Unicode* sBindDN, sal_Unicode* sPasswd,sal_Bool * nUseSSL); - nsresult QueryHelperStub(); - private: - ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XProxyRunner > xRunner; - - RunArgs * m_Args; - ::com::sun::star::mozilla::MozillaProductType m_Product; - OUString m_Profile; -#if OSL_DEBUG_LEVEL > 0 - oslThreadIdentifier m_oThreadID; -#endif - }; - } -} -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MNSMOZABPROXY_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNSTerminateListener.cxx b/connectivity/source/drivers/mozab/mozillasrc/MNSTerminateListener.cxx deleted file mode 100644 index 4325f4e31892..000000000000 --- a/connectivity/source/drivers/mozab/mozillasrc/MNSTerminateListener.cxx +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "MNSTerminateListener.hxx" -#include <comphelper/processfactory.hxx> -#include <com/sun/star/frame/Desktop.hpp> -#include "bootstrap/MNSInit.hxx" - - -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::frame; -::com::sun::star::uno::Reference< ::com::sun::star::frame::XTerminateListener> MNSTerminateListener::mxTerminateListener = new MNSTerminateListener(); - - -// - MNSTerminateListener - - - -MNSTerminateListener::MNSTerminateListener( ) -{ -} - - - -MNSTerminateListener::~MNSTerminateListener() -{ -} - - - -void SAL_CALL MNSTerminateListener::disposing( const EventObject& /*Source*/ ) throw( RuntimeException ) -{ -} - - - -void SAL_CALL MNSTerminateListener::queryTermination( const EventObject& /*aEvent*/ ) throw( TerminationVetoException, RuntimeException ) -{ -} - - - -void SAL_CALL MNSTerminateListener::notifyTermination( const EventObject& /*aEvent*/ ) throw( RuntimeException ) -{ - MNS_Term(sal_True); //Force XPCOM to shutdown -} - -void MNSTerminateListener::addTerminateListener() -{ - Reference< XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() ); - xDesktop->addTerminateListener(mxTerminateListener); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNSTerminateListener.hxx b/connectivity/source/drivers/mozab/mozillasrc/MNSTerminateListener.hxx deleted file mode 100644 index c79498cf5510..000000000000 --- a/connectivity/source/drivers/mozab/mozillasrc/MNSTerminateListener.hxx +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MNSTERMINATELISTENER_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MNSTERMINATELISTENER_HXX - -#include <cppuhelper/implbase.hxx> -#include <com/sun/star/frame/XTerminateListener.hpp> -#include <com/sun/star/lang/XUnoTunnel.hpp> - -//class to implement the XTerminateListener interface -class MNSTerminateListener : public ::cppu::WeakImplHelper< ::com::sun::star::frame::XTerminateListener > -{ - -private: - - // XEventListener - virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw( ::com::sun::star::uno::RuntimeException ); - - // XTerminateListener - virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& aEvent ) throw( ::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent ) throw( ::com::sun::star::uno::RuntimeException ); - - -public: - MNSTerminateListener(); - virtual ~MNSTerminateListener(); -public: - static ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTerminateListener> mxTerminateListener; - static void addTerminateListener(); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNameMapper.cxx b/connectivity/source/drivers/mozab/mozillasrc/MNameMapper.cxx deleted file mode 100644 index 2479a3fc994f..000000000000 --- a/connectivity/source/drivers/mozab/mozillasrc/MNameMapper.cxx +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "MNameMapper.hxx" -#include <osl/diagnose.h> - -#if OSL_DEBUG_LEVEL > 0 -# define OUtoCStr( x ) ( OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr()) -#else /* OSL_DEBUG_LEVEL */ -# define OUtoCStr( x ) ("dummy") -#endif /* OSL_DEBUG_LEVEL */ - - -using namespace connectivity::mozab; - -bool -MNameMapper::ltstr::operator()( const OUString &s1, const OUString &s2) const -{ - return s1.compareTo(s2) < 0; -} - -MNameMapper::MNameMapper() -{ - mDirMap = new MNameMapper::dirMap; - mUriMap = new MNameMapper::uriMap; -} -MNameMapper::~MNameMapper() -{ - clear(); -} - -void MNameMapper::reset() -{ - clear(); - mDirMap = new MNameMapper::dirMap; - mUriMap = new MNameMapper::uriMap; -} -void MNameMapper::clear() -{ - if ( mUriMap != NULL ) { - delete mUriMap; - } - if ( mDirMap != NULL ) { - MNameMapper::dirMap::iterator iter; - for (iter = mDirMap -> begin(); iter != mDirMap -> end(); ++iter) { - NS_IF_RELEASE(((*iter).second)); - } - delete mDirMap; - } -} -const char * getURI(const nsIAbDirectory* directory) -{ - nsresult retCode; - nsCOMPtr<nsIRDFResource> rdfResource = do_QueryInterface((nsISupports *)directory, &retCode) ; - if (NS_FAILED(retCode)) { return NULL; } - const char * uri; - retCode=rdfResource->GetValueConst(&uri); - if (NS_FAILED(retCode)) { return NULL; } - return uri; -} - -// May modify the name passed in so that it's unique -nsresult -MNameMapper::add( OUString& str, nsIAbDirectory* abook ) -{ - MNameMapper::dirMap::iterator iter; - - OSL_TRACE( "IN MNameMapper::add()" ); - - if ( abook == NULL ) { - OSL_TRACE( "\tOUT MNameMapper::add() called with null abook" ); - return NS_ERROR_NULL_POINTER; - } - - OUString ouUri=OUString::createFromAscii(getURI(abook)); - if ( mUriMap->find (ouUri) != mUriMap->end() ) //There's already an entry with same uri - { - return NS_ERROR_FILE_NOT_FOUND; - } - mUriMap->insert( MNameMapper::uriMap::value_type( ouUri, abook ) ); - - OUString tempStr=str; - long count =1; - while ( mDirMap->find( tempStr ) != mDirMap->end() ) { - - tempStr = str + OUString::number(count); - count ++; - } - str = tempStr; - NS_IF_ADDREF(abook); - mDirMap->insert( MNameMapper::dirMap::value_type( str, abook ) ); - OSL_TRACE( "\tOUT MNameMapper::add()" ); - return 0; -} - -bool -MNameMapper::getDir( const OUString& str, nsIAbDirectory* *abook ) -{ - MNameMapper::dirMap::iterator iter; - - OSL_TRACE( "IN MNameMapper::getDir( %s )", OUtoCStr(str)?OUtoCStr(str):"NULL" ); - - if ( (iter = mDirMap->find( str )) != mDirMap->end() ) { - *abook = (*iter).second; - NS_IF_ADDREF(*abook); - } else { - *abook = NULL; - } - - OSL_TRACE( "\tOUT MNameMapper::getDir() : %s", (*abook)?"True":"False" ); - - return( (*abook) != NULL ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNameMapper.hxx b/connectivity/source/drivers/mozab/mozillasrc/MNameMapper.hxx deleted file mode 100644 index 821579e596b1..000000000000 --- a/connectivity/source/drivers/mozab/mozillasrc/MNameMapper.hxx +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MNAMEMAPPER_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MNAMEMAPPER_HXX - -#include <map> - -// Mozilla includes -#include "MNSInclude.hxx" - -// Star Includes -#include <rtl/ustring.hxx> - -namespace connectivity -{ - namespace mozab - { - class MNameMapper - { - private: - - struct ltstr - { - bool operator()( const OUString &s1, const OUString &s2) const; - }; - - - typedef ::std::multimap< OUString, nsIAbDirectory *, ltstr > dirMap; - typedef ::std::multimap< OUString, nsIAbDirectory *, ltstr > uriMap; - - static MNameMapper *instance; - dirMap *mDirMap; - uriMap *mUriMap; - - //clear dirs - void clear(); - - public: - static MNameMapper* getInstance(); - - MNameMapper(); - ~MNameMapper(); - - // May modify the name passed in so that it's unique - nsresult add( OUString& str, nsIAbDirectory* abook ); - - //reset dirs - void reset(); - - // Get the directory corresponding to str - bool getDir( const OUString& str, nsIAbDirectory* *abook ); - - }; - - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MNAMEMAPPER_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/mozillasrc/MQuery.cxx b/connectivity/source/drivers/mozab/mozillasrc/MQuery.cxx deleted file mode 100644 index cb9a9c4c8ca8..000000000000 --- a/connectivity/source/drivers/mozab/mozillasrc/MQuery.cxx +++ /dev/null @@ -1,765 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include "MQueryHelper.hxx" -#include "MNameMapper.hxx" -#include <MConnection.hxx> -#include <connectivity/dbexception.hxx> -#include "MQuery.hxx" -#include "MLdapAttributeMap.hxx" -#include "MTypeConverter.hxx" -#include "MNSMozabProxy.hxx" -#include <com/sun/star/uno/Reference.hxx> -#include <comphelper/processfactory.hxx> -#include <com/sun/star/mozilla/XMozillaBootstrap.hpp> -#include <osl/thread.hxx> - -#if OSL_DEBUG_LEVEL > 0 -# define OUtoCStr( x ) ( OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr()) -#else /* OSL_DEBUG_LEVEL */ -# define OUtoCStr( x ) ("dummy") -#endif /* OSL_DEBUG_LEVEL */ - -static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); -static NS_DEFINE_CID(kAbDirectoryQueryArgumentsCID, NS_ABDIRECTORYQUERYARGUMENTS_CID); -static NS_DEFINE_CID(kBooleanConditionStringCID, NS_BOOLEANCONDITIONSTRING_CID); -static NS_DEFINE_CID(kBooleanExpressionCID, NS_BOOLEANEXPRESSION_CID); -static NS_DEFINE_CID(kAbDirectoryQueryProxyCID, NS_ABDIRECTORYQUERYPROXY_CID); -static NS_DEFINE_CID(kAbLDAPAttributeMap, NS_IABLDAPATTRIBUTEMAP_IID); - -using namespace connectivity::mozab; -using namespace connectivity; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbc; -using namespace connectivity; - - -// Used to store an nsIAbDirectoryQuery member without the need to use Mozilla -// types in the MQuery.hxx file. - -namespace connectivity { - namespace mozab { - struct MQueryDirectory { - nsCOMPtr<nsIAbDirectory> directory; - nsCOMPtr<nsIAbDirectoryQuery> directoryQuery; - PRInt32 contextId; - MQueryDirectory() : contextId(-1) {} - }; - } -} - - -MQuery::MQuery( const OColumnAlias& _ca ) - :m_rColumnAlias( _ca ) -{ - OSL_TRACE( "IN MQuery::MQuery( ca )" ); - - construct(); - -#if OSL_DEBUG_LEVEL > 0 - m_oThreadID = osl::Thread::getCurrentIdentifier(); -#endif - - OSL_TRACE( "\tOUT MQuery::MQuery( ca )" ); -} - -MQuery::~MQuery() -{ - OSL_TRACE("IN MQuery::~MQuery()"); - - // MQueryHelper is reference counted, so we need to decrement the - // count here. - - if ( m_aQueryDirectory->contextId != -1 && m_aQueryDirectory->directoryQuery != - NULL ) - m_aQueryDirectory->directoryQuery->StopQuery(m_aQueryDirectory->contextId); - - delete m_aQueryDirectory; - - NS_IF_RELEASE( m_aQueryHelper); - - OSL_TRACE("\tOUT MQuery::~MQuery()"); -} - -void MQuery::construct() -{ - // Set default values. (For now just as a reminder). - m_aError.reset(); - m_bQuerySubDirs = sal_True; // LDAP Queries require this to be set! - m_nMaxNrOfReturns = -1; // Unlimited number of returns. - - m_aQueryDirectory = new MQueryDirectory(); - // MQueryHelper is reference counted, so we need to add to the - // count here to prevent accidental deletion else where... - - m_aQueryHelper = new MQueryHelper(); - NS_IF_ADDREF( m_aQueryHelper); -} - -void MQuery::setAddressbook(OUString &ab) -{ - OSL_TRACE("IN MQuery::setAddressbook()"); - ::osl::MutexGuard aGuard(m_aMutex); - - m_aAddressbook = ab; - - OSL_TRACE("\tOUT MQuery::setAddressbook()"); -} - -void MQuery::setMaxNrOfReturns(const sal_Int32 mnr) -{ - OSL_TRACE( "IN MQuery::setMaxNrOfReturns()" ); - ::osl::MutexGuard aGuard(m_aMutex); - - m_nMaxNrOfReturns = mnr; - OSL_TRACE("\tOUT MQuery::setMaxNrOfReturns()" ); -} - -void MQuery::setExpression( MQueryExpression &_expr ) -{ - OSL_TRACE("IN MQuery::setExpression()"); - ::osl::MutexGuard aGuard(m_aMutex); - - m_aExpr = _expr; - - OSL_TRACE("\tOUT MQuery::setExpression()"); -} - -static sal_Int32 generateExpression( MQuery* _aQuery, MQueryExpression* _aExpr, - nsIAbBooleanExpression* queryExpression ) -{ - nsresult rv; // Store return values. - // Array that holds all matchItems, to be passed to DoQuery(). - nsCOMPtr<nsISupportsArray> matchItems; - NS_NewISupportsArray(getter_AddRefs(matchItems)); - - // Add every individual boolString to matchItems array. - nsString matchValue; - // Initialise the matchItems container. - MQueryExpression::ExprVector::iterator evIter; - for( evIter = _aExpr->getExpressions().begin(); - evIter != _aExpr->getExpressions().end(); - ++evIter ) - { - if ( (*evIter)->isStringExpr() ) { - nsCOMPtr<nsIAbBooleanConditionString> boolString = do_CreateInstance (kBooleanConditionStringCID, &rv); - NS_ENSURE_SUCCESS( rv, rv ); - - MQueryExpressionString* evStr = static_cast<MQueryExpressionString*> (*evIter); - - // Set the 'name' property of the boolString. - // Check if it's an alias first... - OString attrName = _aQuery->getColumnAlias().getProgrammaticNameOrFallbackToUTF8Alias( evStr->getName() ); - boolString->SetName( strdup( attrName.getStr() ) ); - OSL_TRACE("Name = %s ;", attrName.getStr() ); - // Set the 'matchType' property of the boolString. Check for equal length. - sal_Bool requiresValue = sal_True; - switch(evStr->getCond()) { - case MQueryOp::Exists: - OSL_TRACE("MQueryOp::Exists; "); - boolString->SetCondition(nsIAbBooleanConditionTypes::Exists); - requiresValue = sal_False; - break; - case MQueryOp::DoesNotExist: - OSL_TRACE("MQueryOp::DoesNotExist; "); - boolString->SetCondition(nsIAbBooleanConditionTypes::DoesNotExist); - requiresValue = sal_False; - break; - case MQueryOp::Contains: - OSL_TRACE("MQueryOp::Contains; "); - boolString->SetCondition(nsIAbBooleanConditionTypes::Contains); - break; - case MQueryOp::DoesNotContain: - OSL_TRACE("MQueryOp::DoesNotContain; "); - boolString->SetCondition(nsIAbBooleanConditionTypes::DoesNotContain); - break; - case MQueryOp::Is: - OSL_TRACE("MQueryOp::Is; "); - boolString->SetCondition(nsIAbBooleanConditionTypes::Is); - break; - case MQueryOp::IsNot: - OSL_TRACE("MQueryOp::IsNot; "); - boolString->SetCondition(nsIAbBooleanConditionTypes::IsNot); - break; - case MQueryOp::BeginsWith: - OSL_TRACE("MQueryOp::BeginsWith; "); - boolString->SetCondition(nsIAbBooleanConditionTypes::BeginsWith); - break; - case MQueryOp::EndsWith: - OSL_TRACE("MQueryOp::EndsWith; "); - boolString->SetCondition(nsIAbBooleanConditionTypes::EndsWith); - break; - case MQueryOp::SoundsLike: - OSL_TRACE("MQueryOp::SoundsLike; "); - boolString->SetCondition(nsIAbBooleanConditionTypes::SoundsLike); - break; - case MQueryOp::RegExp: - OSL_TRACE("MQueryOp::RegExp; "); - boolString->SetCondition(nsIAbBooleanConditionTypes::RegExp); - break; - default: - OSL_TRACE("(default) MQueryOp::Is; "); - boolString->SetCondition(nsIAbBooleanConditionTypes::Is); - break; - } - // Set the 'matchValue' property of the boolString. Value returned in unicode. - if ( requiresValue ) - { - OSL_TRACE("Value = %s", OUtoCStr( evStr->getValue() ) ); - MTypeConverter::ouStringToNsString( evStr->getValue(), matchValue); - boolString->SetValue(matchValue.get ()); - } - // Add the individual boolString to the container of matchItems. - matchItems->AppendElement(boolString); - } - else if ( (*evIter)->isExpr() ) { - nsCOMPtr< nsIAbBooleanExpression > subQueryExpr = do_CreateInstance( kBooleanExpressionCID , &rv); - NS_ENSURE_SUCCESS( rv, rv ); - rv = generateExpression( _aQuery, static_cast< MQueryExpression* >(*evIter), - subQueryExpr ); - NS_ENSURE_SUCCESS( rv, rv ); - matchItems->AppendElement(subQueryExpr); - } - else { - // Should never see this... - OSL_FAIL("Unknown Expression Type!"); - return NS_ERROR_UNEXPECTED; - } - } - - queryExpression->SetExpressions(matchItems); - if ( _aExpr->getExpressionCondition() == MQueryExpression::AND ) - queryExpression->SetOperation(nsIAbBooleanOperationTypes::AND); - else - queryExpression->SetOperation(nsIAbBooleanOperationTypes::OR); - - return NS_OK; -} -sal_uInt32 MQuery::InsertLoginInfo(OConnection* _pCon) -{ - nsresult rv; // Store return values. - - OUString nameAB = _pCon->getHost().replace('.','_'); - OUString bindDN = _pCon->getBindDN(); - OUString password = _pCon->getPassword(); - sal_Bool useSSL = _pCon->getUseSSL(); - - nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - // create the ldap maxHits entry for the preferences file. - // Note: maxHits is applicable to LDAP only in mozilla. - nsCAutoString prefName(NS_LITERAL_CSTRING("ldap_2.servers.")); - const char *pAddressBook = MTypeConverter::ouStringToCCharStringAscii(nameAB.getStr()); - prefName.Append(pAddressBook); - - if (!bindDN.isEmpty()) - { - nsCAutoString bindPrefName=prefName; - bindPrefName.Append(NS_LITERAL_CSTRING(".auth.dn")); - rv = prefs->SetCharPref (bindPrefName.get(), - MTypeConverter::ouStringToCCharStringAscii( bindDN.getStr() ) ); - NS_ENSURE_SUCCESS(rv, rv); - - nsCAutoString pwdPrefName=prefName; - pwdPrefName.Append(NS_LITERAL_CSTRING(".auth.pwd")); - rv = prefs->SetCharPref (pwdPrefName.get(), - MTypeConverter::ouStringToCCharStringAscii( password.getStr() ) ); - NS_ENSURE_SUCCESS(rv, rv); - } - if (useSSL) - { - nsCAutoString sslPrefName=prefName; - sslPrefName.Append(NS_LITERAL_CSTRING(".UseSSL")); - rv = prefs->SetBoolPref (sslPrefName.get(),useSSL); - NS_ENSURE_SUCCESS(rv, rv); - } - return rv; -} - -//determine whether current profile is locked,any error will lead to return true -bool isProfileLocked(OConnection* _pCon) -{ - ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XMozillaBootstrap > xMozillaBootstrap; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); - OSL_ENSURE( xFactory.is(), "can't get service factory" ); - - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xInstance = xFactory->createInstance("com.sun.star.mozilla.MozillaBootstrap"); - OSL_ENSURE( xInstance.is(), "failed to create instance" ); - xMozillaBootstrap = ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XMozillaBootstrap >(xInstance,::com::sun::star::uno::UNO_QUERY); - if (_pCon) - return xMozillaBootstrap->isProfileLocked(_pCon->getProduct(),_pCon->getMozProfile()); - else - return xMozillaBootstrap->isCurrentProfileLocked(); -} - - - -sal_Int32 getDirectoryType(const nsIAbDirectory* directory) -{ - nsresult retCode; - nsCOMPtr<nsIRDFResource> rdfResource = do_QueryInterface((nsISupports *)directory, &retCode) ; - if (NS_FAILED(retCode)) { return SDBCAddress::Unknown; } - const char * uri; - retCode=rdfResource->GetValueConst(&uri); - if (NS_FAILED(retCode)) { return SDBCAddress::Unknown; } - const sal_Char *sUriPrefix = ::connectivity::mozab::getSchemeURI( ::connectivity::mozab::SCHEME_LDAP ); - if (strncmp(uri,sUriPrefix,strlen(sUriPrefix)) == 0) - { - return SDBCAddress::LDAP; - } - sUriPrefix = ::connectivity::mozab::getSchemeURI( ::connectivity::mozab::SCHEME_MOZILLA ); - if (strncmp(uri,sUriPrefix,strlen(sUriPrefix)) == 0) - { - return SDBCAddress::Mozilla; - } - sUriPrefix = ::connectivity::mozab::getSchemeURI( ::connectivity::mozab::SCHEME_MOZILLA_MDB ); - if (strncmp(uri,sUriPrefix,strlen(sUriPrefix)) == 0) - { - return SDBCAddress::Mozilla; - } - sUriPrefix = ::connectivity::mozab::getSchemeURI( ::connectivity::mozab::SCHEME_OUTLOOK_EXPRESS ); - if (strncmp(uri,sUriPrefix,strlen(sUriPrefix)) == 0) - { - return SDBCAddress::OutlookExp; - } - sUriPrefix = ::connectivity::mozab::getSchemeURI( ::connectivity::mozab::SCHEME_OUTLOOK_MAPI ); - if (strncmp(uri,sUriPrefix,strlen(sUriPrefix)) == 0) - { - return SDBCAddress::Outlook; - } - return SDBCAddress::Unknown; - -} - -sal_Bool isForceQueryProxyUsed(const nsIAbDirectory* directory) -{ - sal_Int32 nType = getDirectoryType(directory); - if (nType == SDBCAddress::Outlook || nType == SDBCAddress::OutlookExp) - return sal_True; - return sal_False; -} - -sal_Int32 MQuery::commitRow(const sal_Int32 rowIndex) -{ - if (!m_aQueryHelper || !m_aQueryDirectory || !m_aQueryDirectory->directoryQuery) - return sal_False; - MNSMozabProxy xMProxy; - RunArgs args; - args.funcIndex = ProxiedFunc::FUNC_QUERYHELPER_COMMIT_CARD; - args.argCount = 3; - args.arg1 = (void*)m_aQueryHelper; - args.arg2 = (void*)&rowIndex; - args.arg3 = (void*)m_aQueryDirectory->directory; - nsresult rv = xMProxy.StartProxy(&args,m_Product,m_Profile); - m_aError = m_aQueryHelper->getError(); - return rv; -} - - -sal_Int32 MQuery::deleteRow(const sal_Int32 rowIndex) -{ - if (!m_aQueryHelper || !m_aQueryDirectory || !m_aQueryDirectory->directoryQuery) - return sal_False; - MNSMozabProxy xMProxy; - RunArgs args; - args.funcIndex = ProxiedFunc::FUNC_QUERYHELPER_DELETE_CARD; - args.argCount = 3; - args.arg1 = (void*)m_aQueryHelper; - args.arg2 = (void*)&rowIndex; - args.arg3 = (void*)m_aQueryDirectory->directory; - nsresult rv = xMProxy.StartProxy(&args,m_Product,m_Profile); - m_aError = m_aQueryHelper->getError(); - return rv; - -} - - -sal_Int32 MQuery::executeQuery(OConnection* _pCon) -{ - ::osl::MutexGuard aGuard(m_aMutex); - OSL_TRACE("IN MQuery::executeQuery()"); - m_Product = _pCon->getProduct(); - m_Profile = _pCon->getMozProfile(); - - nsresult rv; - MNSMozabProxy xMProxy; - RunArgs args; - args.funcIndex = ProxiedFunc::FUNC_EXECUTE_QUERY; - args.argCount = 2; - args.arg1 = (void*)this; - args.arg2 = (void*)_pCon; - rv = xMProxy.StartProxy(&args,m_Product,m_Profile); - return rv; -} - -sal_Int32 MQuery::executeQueryProxied(OConnection* _pCon) -{ -#if OSL_DEBUG_LEVEL > 0 - OSL_TRACE("IN MQuery::executeQueryProxied() Caller thread: %4d", m_oThreadID); -#endif - - nsresult rv; // Store return values. - // MTypeConverter aTypeConverter; - // Create a nsIAbDirectory object to initialise the nsIAbDirectoryQuery object. - nsCOMPtr<nsIRDFService> rdfService(do_GetService(kRDFServiceCID, &rv)) ; - if (NS_FAILED(rv)) - return -1; - - nsCOMPtr<nsIAbDirectory> directory; - MNameMapper *nmap = _pCon->getNameMapper(); - - - if ( nmap->getDir( m_aAddressbook, getter_AddRefs( directory ) ) == sal_False ) - return -1; - - - //insert ldap bind info to mozilla profile(in memory, none saved), so we can use it in mozilla part codes - if (_pCon->isLDAP()) - { - rv = InsertLoginInfo(_pCon); - NS_ENSURE_SUCCESS(rv, rv); - - } - // Since Outlook Express and Outlook in OCL mode support a very limited query capability, - // we use the following bool to judge whether we need bypass any use of a DirectoryQuery - // interface and instead force the use of the QueryProxy. - sal_Bool forceQueryProxyUse = isForceQueryProxyUsed(directory); - - m_aQueryDirectory->directory = directory; - // Initialize directory in cases of LDAP and Mozilla - if (!forceQueryProxyUse) m_aQueryDirectory->directoryQuery = do_QueryInterface(directory, &rv); - - if ( NS_FAILED(rv) || forceQueryProxyUse) - { - // Create a nsIAbDirectoryQuery object which eventually will execute - // the query by calling DoQuery(). - nsCOMPtr< nsIAbDirectoryQueryProxy > directoryQueryProxy = do_CreateInstance( kAbDirectoryQueryProxyCID, &rv); - - // Need to turn this off for anything using the Query Proxy since it - // treats Mailing Lists as directories! - - m_bQuerySubDirs = sal_False; - - rv = directoryQueryProxy->Initiate (directory); - NS_ENSURE_SUCCESS(rv, rv); - - m_aQueryDirectory->directoryQuery = do_QueryInterface (directoryQueryProxy, &rv); - NS_ENSURE_SUCCESS(rv, rv); - OSL_TRACE("Using the directoryQueryProxy"); - } -#if OSL_DEBUG_LEVEL > 0 - else - OSL_TRACE("Not using a Query Proxy, Query i/f supported by directory"); -#endif /* OSL_DEBUG_LEVEL */ - - /* - // The problem here is that an LDAP Address Book may exist as - // a Mozilla Address Book. So we need to limit the number of - // records returned by the Server: - // 1. Determine if this is an LDAP Address Book - // [LDAP overrides the default operations(write|read|search) of all types with search only]. - // 2. Determine if the limit is already set by us. - // 3. Use the mozilla preferences to see if this value is set. - // 4. Use value or else default to 100. - */ - PRBool isWriteable; - rv = directory->GetOperations (&isWriteable); - NS_ENSURE_SUCCESS(rv, rv); - if (!(isWriteable & nsIAbDirectory::opWrite)) - { - if(m_nMaxNrOfReturns == -1) - { - // Determine if the limit maxHits has been set in the mozilla preferences - // if set, then use the value otherwise default to 100 - nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - // create the ldap maxHits entry for the preferences file. - // Note: maxHits is applicable to LDAP only in mozilla. - nsCAutoString prefName(NS_LITERAL_CSTRING("ldap_2.servers.")); - const char *pAddressBook = MTypeConverter::ouStringToCCharStringAscii(m_aAddressbook); - prefName.Append(pAddressBook); - prefName.Append(NS_LITERAL_CSTRING(".maxHits")); - - PRInt32 maxHits; - rv = prefs->GetIntPref(prefName.get(), &maxHits); - if (NS_FAILED(rv)) - m_nMaxNrOfReturns = 100; - else - m_nMaxNrOfReturns = maxHits; - } - } - - - nsCOMPtr< nsIAbBooleanExpression > queryExpression = do_CreateInstance( kBooleanExpressionCID , &rv); - NS_ENSURE_SUCCESS( rv, rv ); - rv = generateExpression( this, &m_aExpr, queryExpression ); - NS_ENSURE_SUCCESS( rv, rv ); - - // Use the nsIAbCard to return the card properties. - const char *returnProperties[] = {"card:nsIAbCard"}; - PRInt32 count=1; - - nsCOMPtr< nsIAbDirectoryQueryArguments > arguments = do_CreateInstance( kAbDirectoryQueryArgumentsCID, &rv); - NS_ENSURE_SUCCESS( rv, rv ); - - rv = arguments->SetExpression(queryExpression); - NS_ENSURE_SUCCESS( rv, rv ); - - rv = arguments->SetReturnProperties(count, returnProperties); - NS_ENSURE_SUCCESS( rv, rv ); - - rv = arguments->SetQuerySubDirectories(m_bQuerySubDirs); - NS_ENSURE_SUCCESS( rv, rv ); - - nsCOMPtr< nsIAbLDAPAttributeMap > attributeMap( new MLdapAttributeMap ); - rv = arguments->SetTypeSpecificArg( attributeMap ); - NS_ENSURE_SUCCESS( rv, rv ); - - // Execute the query. - OSL_TRACE( "****** calling DoQuery"); - - m_aError.reset(); - - m_aQueryHelper->reset(); - - rv = m_aQueryDirectory->directoryQuery->DoQuery(arguments, m_aQueryHelper, m_nMaxNrOfReturns, -1, &m_aQueryDirectory->contextId); - - - if (NS_FAILED(rv)) { - m_aQueryDirectory->contextId = -1; - OSL_TRACE( "****** DoQuery failed"); - OSL_TRACE("\tOUT MQuery::executeQueryProxied()\n"); - m_aQueryHelper->notifyQueryError() ; - return -1; - } -#if OSL_DEBUG_LEVEL > 0 - else { - OSL_TRACE( "****** DoQuery succeeded"); - } -#endif - - OSL_TRACE("\tOUT MQuery::executeQueryProxied()"); - - return 0; -} - - - - -// If the query executed is being done asynchronously then this may return -// -1 as the count, ie. it's undetermined. - -sal_Int32 -MQuery::getRowCount() -{ - return m_aQueryHelper->getResultCount(); -} - - - - -// As opposed to getRowCount() this returns the actual number of rows fetched -// so far (if is an async query) - -sal_uInt32 -MQuery::getRealRowCount() -{ - return m_aQueryHelper->getRealCount(); -} - - -// If the query executed is being done asynchronously then this may be -// false - -sal_Bool -MQuery::queryComplete() -{ - return hadError() || m_aQueryHelper->queryComplete(); -} - -sal_Bool -MQuery::waitForQueryComplete() -{ - if( m_aQueryHelper->waitForQueryComplete( ) ) - return sal_True; - m_aError = m_aQueryHelper->getError(); - return sal_False; -} - - - -sal_Bool -MQuery::checkRowAvailable( sal_Int32 nDBRow ) -{ - while( !queryComplete() && m_aQueryHelper->getRealCount() <= (sal_uInt32)nDBRow ) - if ( !m_aQueryHelper->waitForRow( nDBRow ) ) { - m_aError = m_aQueryHelper->getError(); - return sal_False; - } - - return getRowCount() > nDBRow; -} - -sal_Bool -MQuery::setRowValue( ORowSetValue& rValue, sal_Int32 nDBRow,const OUString& aDBColumnName, sal_Int32 nType ) const -{ - MQueryHelperResultEntry* xResEntry = m_aQueryHelper->getByIndex( nDBRow ); - - OSL_ENSURE( xResEntry != NULL, "xResEntry == NULL"); - if (xResEntry == NULL ) - { - const_cast< MQuery* >( this )->m_aError = m_aQueryHelper->getError(); - return sal_False; - } - switch ( nType ) - { - case DataType::VARCHAR: - xResEntry->setValue( m_rColumnAlias.getProgrammaticNameOrFallbackToUTF8Alias( aDBColumnName ), rValue.getString() ); - break; - default: - OSL_FAIL( "invalid data type!" ); - break; - } - - return sal_True; -} - - -sal_Bool -MQuery::getRowValue( ORowSetValue& rValue, sal_Int32 nDBRow,const OUString& aDBColumnName, sal_Int32 nType ) const -{ - MQueryHelperResultEntry* xResEntry = m_aQueryHelper->getByIndex( nDBRow ); - - OSL_ENSURE( xResEntry != NULL, "xResEntry == NULL"); - if (xResEntry == NULL ) - { - const_cast< MQuery* >( this )->m_aError = m_aQueryHelper->getError(); - rValue.setNull(); - return sal_False; - } - switch ( nType ) - { - case DataType::VARCHAR: - rValue = xResEntry->getValue( m_rColumnAlias.getProgrammaticNameOrFallbackToUTF8Alias( aDBColumnName ) ); - break; - - default: - rValue.setNull(); - break; - } - - return sal_True; -} - -sal_Int32 -MQuery::getRowStates(sal_Int32 nDBRow) -{ - MQueryHelperResultEntry* xResEntry = m_aQueryHelper->getByIndex( nDBRow ); - - OSL_ENSURE( xResEntry != NULL, "xResEntry == NULL"); - if (xResEntry == NULL ) - { - m_aError = m_aQueryHelper->getError(); - return RowStates_Error; - } - return xResEntry->getRowStates(); -} -sal_Bool -MQuery::setRowStates(sal_Int32 nDBRow,sal_Int32 aState) -{ - MQueryHelperResultEntry* xResEntry = m_aQueryHelper->getByIndex( nDBRow ); - - OSL_ENSURE( xResEntry != NULL, "xResEntry == NULL"); - if (xResEntry == NULL ) - { - m_aError = m_aQueryHelper->getError(); - return sal_False; - } - return xResEntry->setRowStates(aState); -} - -sal_Bool -MQuery::resyncRow(sal_Int32 nDBRow) -{ - MNSMozabProxy xMProxy; - RunArgs args; - args.funcIndex = ProxiedFunc::FUNC_QUERYHELPER_RESYNC_CARD; - args.argCount = 2; - args.arg1 = (void*)m_aQueryHelper; - args.arg2 = (void*)&nDBRow; - nsresult rv = xMProxy.StartProxy(&args,m_Product,m_Profile); - m_aError = m_aQueryHelper->getError(); - return NS_SUCCEEDED( rv ) ? sal_True : sal_False; -} - -sal_Int32 -MQuery::createNewCard() -{ - sal_Int32 nNumber = 0; - MNSMozabProxy xMProxy; - RunArgs args; - args.funcIndex = ProxiedFunc::FUNC_QUERYHELPER_CREATE_NEW_CARD; - args.argCount = 2; - args.arg1 = (void*)m_aQueryHelper; - args.arg2 = (void*)&nNumber; - nsresult rv = xMProxy.StartProxy(&args,m_Product,m_Profile); - - m_aError = m_aQueryHelper->getError(); - NS_ENSURE_SUCCESS(rv,0); - return nNumber; -} - - -MNameMapper* -MQuery::CreateNameMapper() -{ - return new MNameMapper(); -} - - -void -MQuery::FreeNameMapper( MNameMapper* _ptr ) -{ - delete _ptr; -} - -sal_Bool MQuery::isWritable(OConnection* _pCon) -{ - if ( !m_aQueryDirectory ) - return sal_False; - - nsresult rv; // Store return values. - nsCOMPtr<nsIAbDirectory> directory = do_QueryInterface(m_aQueryDirectory->directory, &rv);; - if (NS_FAILED(rv)) - return sal_False; - if (getDirectoryType(directory) == SDBCAddress::Mozilla && isProfileLocked(_pCon)) - return sal_False; - - PRBool isWriteable; - rv = directory->GetOperations (&isWriteable); - if (NS_FAILED(rv)) - return sal_False; - sal_Bool bWritable = ( isWriteable & nsIAbDirectory::opWrite ) == nsIAbDirectory::opWrite; - return bWritable; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/mozillasrc/MQuery.hxx b/connectivity/source/drivers/mozab/mozillasrc/MQuery.hxx deleted file mode 100644 index 523e37628af6..000000000000 --- a/connectivity/source/drivers/mozab/mozillasrc/MQuery.hxx +++ /dev/null @@ -1,267 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MQUERY_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MQUERY_HXX - -#include "MColumnAlias.hxx" -#include "MErrorResource.hxx" -#include <connectivity/FValue.hxx> -#include "MNSDeclares.hxx" -#include <osl/thread.hxx> -#include <com/sun/star/mozilla/MozillaProductType.hpp> - -namespace connectivity -{ - namespace mozab - { - - class MQueryHelper; - struct MQueryDirectory; - - namespace MQueryOp { - typedef enum { - Exists = 0, - DoesNotExist = 1, - Contains = 2, - DoesNotContain = 3, - Is = 4, - IsNot = 5, - BeginsWith = 6, - EndsWith = 7, - SoundsLike = 8, - RegExp = 9 - } cond_type; - } - - class MQueryExpressionBase { - public: - typedef enum { - Unknown, - StringExpr, - Expr - } node_type; - - protected: - node_type m_eNodeType; - - MQueryExpressionBase() : m_eNodeType( Unknown ) {} - explicit MQueryExpressionBase( node_type _eNodeType ) : m_eNodeType( _eNodeType ) {} - - public: - sal_Bool isUnknown( ) const { return m_eNodeType == Unknown; } - sal_Bool isStringExpr( ) const { return m_eNodeType == StringExpr; } - sal_Bool isExpr( ) const { return m_eNodeType == Expr; } - }; - - class MQueryExpressionString : public MQueryExpressionBase { - protected: - OUString m_aName; // LHS - MQueryOp::cond_type m_aBooleanCondition; - OUString m_aValue; // RHS - - public: - - MQueryExpressionString( OUString& lhs, - MQueryOp::cond_type cond, - OUString rhs ) - : MQueryExpressionBase( MQueryExpressionBase::StringExpr ) - , m_aName( lhs ) - , m_aBooleanCondition( cond ) - , m_aValue( rhs ) - { - } - - MQueryExpressionString( OUString& lhs, - MQueryOp::cond_type cond ) - : MQueryExpressionBase( MQueryExpressionBase::StringExpr ) - , m_aName( lhs ) - , m_aBooleanCondition( cond ) - , m_aValue( OUString() ) - { - } - - const OUString& getName() const { return m_aName; } - MQueryOp::cond_type getCond() const { return m_aBooleanCondition; } - const OUString& getValue() const { return m_aValue; } - }; - - class MQuery; - - class MQueryExpression : public MQueryExpressionBase - { - friend class MQuery; - - public: - typedef ::std::vector< MQueryExpressionBase* > ExprVector; - - typedef enum { - AND, - OR - } bool_cond; - - void setExpressions( ExprVector& _exprVector ) - { m_aExprVector = _exprVector; } - - // All expressions on a peer level use same condition operator - void setExpressionCondition( bool_cond _cond ) - { m_aExprCondType = _cond; } - - ExprVector& getExpressions( ) - { return m_aExprVector; } - - // All expressions on a peer level use same condition operator - bool_cond getExpressionCondition( ) const - { return m_aExprCondType; } - - MQueryExpression() : MQueryExpressionBase( MQueryExpressionBase::Expr ), - m_aExprCondType( OR ) - { m_aExprVector.clear(); } - - - protected: - ExprVector m_aExprVector; - bool_cond m_aExprCondType; - - }; - - - class MQuery - { - /* - * A query resultset with a maximum limit of - * m_nMaxNrOfReturns return items, is created from - * the following SQL statement: - * - * ------------------------------------------------- - * SELECT m_aAttributes FROM m_aAddressbook - * WHERE m_aMatchItems SQL_OPR m_aMatchValue - * ------------------------------------------------- - * - * We are\are not, depending on boolean m_bQuerySubDirs, - * interested in querying the sub-directories of the - * addressbook directory, if any. - * - * SQL_OPR: - * m_aSqlOppr contains the SQL operations for every - * attribute in m_aAttributes. - * This member must be initialised together with - * m_aAttributes. - * - * The SQL operations defined for 'SQL_OPR' are: - * matchExists = 0, - * matchDoesNotExist = 1, - * matchContains = 2, - * matchDoesNotContain = 3, - * matchIs = 4, - * matchIsNot = 5, - * matchBeginsWith = 6, - * matchEndsWith = 7, - * matchSoundsLike = 8, - * matchRegExp = 9. - * There must be mapping to one of these values. - * - * The following members MUST be initialised before - * a query is executed: - * m_Attributes, m_aMapAttrOppr, m_aAddressbook, - * m_aMatchItems and m_aMatchValue. - * - * m_bQuerySubDirs and m_nMaxNrReturns are set to a - * default value in the constructor which can be - * overridden. If (element of) m_aSqlOppr is not set, - * the default SQL operation is 'matchIs'. - * - */ - private: - MQueryDirectory *m_aQueryDirectory; - MQueryHelper *m_aQueryHelper; - OUString m_aAddressbook; - sal_Int32 m_nMaxNrOfReturns; - sal_Bool m_bQuerySubDirs; - MQueryExpression m_aExpr; - const OColumnAlias& m_rColumnAlias; - ::com::sun::star::mozilla::MozillaProductType - m_Product; - OUString m_Profile; - ErrorDescriptor m_aError; - - void construct(); - protected: - ::osl::Mutex m_aMutex; -#if OSL_DEBUG_LEVEL > 0 - oslThreadIdentifier m_oThreadID; -#endif - - public: - /* - * - Contains accessors to the members of this class. - * - executeQuery() initiates a non-blocking query. - */ - sal_Int32 executeQuery(OConnection* _pCon); - sal_Int32 executeQueryProxied(OConnection* _pCon); //Used only by MNSMozabProxy - - sal_Int32 createNewCard(); //return Row count number - sal_Int32 deleteRow(const sal_Int32 rowIndex); - sal_Int32 commitRow(const sal_Int32 rowIndex); - sal_Bool resyncRow(sal_Int32 nDBRow); - - sal_Bool isWritable(OConnection* _pCon); - - sal_uInt32 InsertLoginInfo(OConnection* _pCon); - - void setAddressbook( OUString&); - - const OColumnAlias& getColumnAlias() const { return m_rColumnAlias; } - - void setExpression( MQueryExpression &_expr ); - - void setMaxNrOfReturns( const sal_Int32); - - sal_Int32 getRowCount(); - sal_uInt32 getRealRowCount(); - sal_Bool queryComplete(); - sal_Bool waitForQueryComplete(); - sal_Bool checkRowAvailable( sal_Int32 nDBRow ); - sal_Bool getRowValue( connectivity::ORowSetValue& rValue, - sal_Int32 nDBRow, - const OUString& aDBColumnName, - sal_Int32 nType ) const; - sal_Bool setRowValue( connectivity::ORowSetValue& rValue, - sal_Int32 nDBRow, - const OUString& aDBColumnName, - sal_Int32 nType ) const; - sal_Int32 getRowStates(sal_Int32 nDBRow); - sal_Bool setRowStates(sal_Int32 nDBRow,sal_Int32 aState); - - bool hadError() const { return m_aError.is(); } - inline const ErrorDescriptor& getError() const { return m_aError; } - - public: - explicit MQuery( const OColumnAlias& _ca ); - virtual ~MQuery(); - static MNameMapper* CreateNameMapper(); - static void FreeNameMapper( MNameMapper* _ptr ); - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MQUERY_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.cxx b/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.cxx deleted file mode 100644 index b71e880c9bb7..000000000000 --- a/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.cxx +++ /dev/null @@ -1,605 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include "MQueryHelper.hxx" -#include "MTypeConverter.hxx" -#include "MConnection.hxx" -#include "MNSDeclares.hxx" -#include "MLdapAttributeMap.hxx" - -#include <connectivity/dbexception.hxx> -#include <osl/thread.hxx> - -#include "resource/mozab_res.hrc" - -using namespace connectivity::mozab; - - -NS_IMPL_THREADSAFE_ISUPPORTS1(connectivity::mozab::MQueryHelper,nsIAbDirectoryQueryResultListener) - - -// class MQueryHelperResultEntry - - - -MQueryHelperResultEntry::MQueryHelperResultEntry() -{ - m_Card = NULL; - m_RowStates = 0; -} - -MQueryHelperResultEntry::~MQueryHelperResultEntry() -{ - OSL_TRACE("IN MQueryHelperResultEntry::~MQueryHelperResultEntry()"); - OSL_TRACE("OUT MQueryHelperResultEntry::~MQueryHelperResultEntry()\n"); - -} -void -MQueryHelperResultEntry::setCard(nsIAbCard *card) -{ - m_Card = card; -} -nsIAbCard * -MQueryHelperResultEntry::getCard() -{ - return m_Card; -} -void MQueryHelperResultEntry::insert( const OString &key, OUString &value ) -{ - m_Fields[ key ] = value; -} - -OUString MQueryHelperResultEntry::getValue( const OString &key ) const -{ - FieldMap::const_iterator iter = m_Fields.find( key ); - if ( iter == m_Fields.end() ) - { - return OUString(); - } - else - { - return iter->second; - } -} - -void MQueryHelperResultEntry::setValue( const OString &key, const OUString & rValue) -{ - m_Fields[ key ] = rValue; -} - -// class MQueryHelper - -MQueryHelper::MQueryHelper() - :m_nIndex( 0 ) - ,m_bHasMore( sal_True ) - ,m_bAtEnd( sal_False ) - ,m_bErrorCondition( sal_False ) - ,m_bQueryComplete( sal_False ) - ,mRefCnt( 0 ) // NSISUPPORTS - Initialize RefCnt to 0 -{ - m_aResults.clear(); -#if OSL_DEBUG_LEVEL > 0 - m_oThreadID = osl::Thread::getCurrentIdentifier(); -#endif -} - -MQueryHelper::~MQueryHelper() -{ - OSL_TRACE("IN MQueryHelper::~MQueryHelper()"); - clear_results(); - OSL_TRACE("OUT MQueryHelper::~MQueryHelper()"); -} - -void -MQueryHelper::append(MQueryHelperResultEntry* resEnt ) -{ - if ( resEnt != NULL ) { - m_aResults.push_back( resEnt ); - m_bAtEnd = sal_False; - } -} - -void -MQueryHelper::clear_results() -{ - resultsArray::iterator iter = m_aResults.begin(); - while ( iter != m_aResults.end() ) { - delete (*iter); - ++iter; - } - m_aResults.clear(); -} - -void -MQueryHelper::reset() -{ - m_nIndex = 0; - m_bHasMore = sal_True; - m_bQueryComplete = sal_False; - m_bAtEnd = sal_False; - m_bErrorCondition = sal_False; - clear_results(); -} - -void -MQueryHelper::clearResultOrComplete() -{ - // Don't use a Mutex, it should be called by a method already holding it. - OSL_TRACE("In/Out : clearResultOrComplete()"); - m_aCondition.reset(); -} - -void -MQueryHelper::notifyResultOrComplete() -{ - OSL_TRACE("In/Out : notifyResultOrComplete()"); - m_aCondition.set(); -} - -sal_Bool -MQueryHelper::waitForResultOrComplete( ) -{ - TimeValue timeValue = { 1, 0 }; // 20 Seconds 0 NanoSecond timeout - sal_Int32 times=0; - osl::Condition::Result rv = ::osl::Condition::result_ok; - - OSL_TRACE("In : waitForResultOrComplete()"); - // Can't hold mutex or condition would never get set... - while( (m_aCondition.check() == sal_False || rv == ::osl::Condition::result_error) && times < 20) { - rv = m_aCondition.wait( &timeValue ); - times ++; - } - if (times >= 20 && rv == ::osl::Condition::result_timeout ) { - OSL_TRACE("waitForResultOrComplete() : Timeout!"); - m_aError.setResId( STR_TIMEOUT_WAITING ); - return sal_False; - } - - if ( isError() ) { - OSL_TRACE("waitForResultOrComplete() : Error returned!"); - m_aError.setResId( STR_ERR_EXECUTING_QUERY ); - return sal_False; - } - m_aError.reset(); - OSL_TRACE(" Out : waitForResultOrComplete()"); - return sal_True; -} - - -MQueryHelperResultEntry* -MQueryHelper::next( ) -{ - MQueryHelperResultEntry* result; - sal_uInt32 index; - - m_aMutex.acquire(); - index = m_nIndex; - m_aMutex.release(); - - result = getByIndex( index + 1) ; // Add 1 as Row is numbered from 1 to N - - if ( result ) { - m_aMutex.acquire(); - m_nIndex++; - m_aMutex.release(); - } - - return result; -} - -MQueryHelperResultEntry* -MQueryHelper::getByIndex( sal_uInt32 nRow ) -{ - // Row numbers are from 1 to N, need to ensure this, and then - // subtract 1 - if ( nRow < 1 ) { - return NULL; - } - - do { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - if ( nRow > m_aResults.size() ) - { - if ( m_bQueryComplete ) - { - m_bAtEnd = sal_True; - return NULL; - } - else - { - clearResultOrComplete(); - aGuard.clear(); - if ( !waitForResultOrComplete( ) ) - return NULL; - } - } - else - { - return m_aResults[ nRow -1 ]; - } - } while ( true ); -} - -sal_Bool -MQueryHelper::isError() const -{ - return m_bErrorCondition; -} - -sal_Bool -MQueryHelper::queryComplete() const -{ - return m_bQueryComplete; -} - -sal_Bool -MQueryHelper::waitForQueryComplete( ) -{ - m_aMutex.acquire(); - - OSL_TRACE("In : waitForQueryComplete()"); - if ( ! m_bQueryComplete ) { - do - { - m_aMutex.release(); - clearResultOrComplete(); - if ( !waitForResultOrComplete( ) ) - return sal_False; - m_aMutex.acquire(); - } - while ( !m_bQueryComplete ); - } - - m_aMutex.release(); - OSL_TRACE("Out : waitForQueryComplete()"); - return sal_True; -} - -sal_Bool -MQueryHelper::waitForRow( sal_Int32 rowNum ) -{ - m_aMutex.acquire(); - do - { - m_aMutex.release(); - clearResultOrComplete(); - if ( !waitForResultOrComplete() ) - return sal_False; - m_aMutex.acquire(); - } - while ( !m_bQueryComplete && m_aResults.size() < (size_t)rowNum ); - - m_aMutex.release(); - return sal_True; -} - - - -sal_Int32 -MQueryHelper::getResultCount() const -{ - OSL_TRACE( "IN MQueryHelper::getResultCount()" ); - if ( !m_bQueryComplete ) - { - OSL_TRACE( "\tOUT MQueryHelper::getResultCount() = -1"); - return -1; - } - else - { - OSL_TRACE( "\tOUT MQueryHelper::getResultCount() = %d", m_aResults.size() ); - return static_cast<sal_Int32>(m_aResults.size()); - } -} - - - -sal_uInt32 -MQueryHelper::getRealCount() const -{ - OSL_TRACE( "IN/OUT MQueryHelper::getRealCount() = %d", m_aResults.size() ); - return static_cast<sal_Int32>(m_aResults.size()); -} - - -NS_IMETHODIMP MQueryHelper::OnQueryItem(nsIAbDirectoryQueryResult *result) -{ - ::osl::MutexGuard aGuard( m_aMutex ); -#if OSL_DEBUG_LEVEL > 0 - OSL_TRACE( "IN MQueryHelper::OnQueryItem() Caller thread: %4d",m_oThreadID ); -#endif - nsresult rv; - PRInt32 resultType; - - if ( result == NULL ) { - OSL_TRACE("\tresult ptr is NULL"); - return NS_OK; - } - - // Get return status of executeQuery() call. - rv = result -> GetType(&resultType); - NS_ENSURE_SUCCESS(rv, rv); - - // Check for errors of the executeQuery() call. - switch ( resultType ) { - case nsIAbDirectoryQueryResult::queryResultError: - OSL_TRACE("\tresultType == nsIAbDirectoryQueryResult::queryResultError"); - m_bQueryComplete = sal_True; - m_bErrorCondition = sal_True; - notifyResultOrComplete(); - return NS_OK; - case nsIAbDirectoryQueryResult::queryResultStopped: - OSL_TRACE("\tresultType == nsIAbDirectoryQueryResult::queryResultStopped"); - m_bQueryComplete = sal_True; - notifyResultOrComplete(); - return NS_OK; - case nsIAbDirectoryQueryResult::queryResultComplete: - OSL_TRACE("\tresultType == nsIAbDirectoryQueryResult::queryResultComplete"); - m_bQueryComplete = sal_True; - notifyResultOrComplete(); - return NS_OK; - case nsIAbDirectoryQueryResult::queryResultMatch: - OSL_TRACE("IN MQueryHelper::OnQueryItem --> queryResultMatch"); - // Don't return, continues onto rest of method. - break; - default: - OSL_TRACE("\t******** Unexpected : resultType"); - m_bQueryComplete = sal_True; - return NS_OK; - } - - // Initialise an array that holds the resultset of the query. - nsCOMPtr<nsISupportsArray> properties; - rv = result -> GetResult(getter_AddRefs (properties)); - NS_ENSURE_SUCCESS(rv, rv); - - - nsCOMPtr<nsISupports> item; - rv = properties -> GetElementAt(0, getter_AddRefs(item)); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr<nsIAbDirectoryQueryPropertyValue> property(do_QueryInterface(item, &rv)); - NS_ENSURE_SUCCESS(rv, rv); - - char *name; - rv = property -> GetName(&name); - NS_ENSURE_SUCCESS(rv, rv); - if ( !strcmp(name,"card:nsIAbCard") ) - { - nsCOMPtr<nsISupports> cardSupports; - property->GetValueISupports (getter_AddRefs (cardSupports)); - nsCOMPtr<nsIAbCard> card(do_QueryInterface(cardSupports, &rv)); - NS_ENSURE_SUCCESS(rv, rv); - - getCardValues(card); - } - nsMemory::Free(name); - - OSL_TRACE( "\tOUT MQueryHelper::OnQueryItem()" ); - - notifyResultOrComplete(); - - return NS_OK; -} - - -void MQueryHelper::notifyQueryError() -{ - m_bQueryComplete = sal_True ; - notifyResultOrComplete() ; -} - -const char * getAddrURI(const nsIAbDirectory* directory) -{ - nsresult retCode; - nsCOMPtr<nsIRDFResource> rdfResource = do_QueryInterface((nsISupports *)directory, &retCode) ; - if (NS_FAILED(retCode)) { return NULL; } - const char * uri; - retCode=rdfResource->GetValueConst(&uri); - if (NS_FAILED(retCode)) { return NULL; } - return uri; - } - -#define ENSURE_GETUPDATECARD(x) \ - if (NS_FAILED(retCode)) \ - { \ - OSL_TRACE( x ); \ - return card; \ - } -static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); - -//Some address book does not support query uri on card -//In this case, we can't resync the cards, we just return the old cards -nsIAbCard * getUpdatedCard( nsIAbCard* card) -{ - OSL_ENSURE(card != NULL, "getUpdatedCard for NULL"); - nsresult retCode; - nsCOMPtr<nsIRDFResource> rdfResource = do_QueryInterface((nsISupports *)card, &retCode) ; - ENSURE_GETUPDATECARD( "IN getUpdatedCard: Card does not support nsIRDFResource\n" ); - - const char * uri; - retCode=rdfResource->GetValueConst(&uri); - ENSURE_GETUPDATECARD( "IN getUpdatedCard: Card does not has a uri\n" ); - - nsCOMPtr<nsIRDFService> rdfService (do_GetService(kRDFServiceCID, &retCode)) ; - ENSURE_GETUPDATECARD( "IN getUpdatedCard: Card does not has a uri\n" ); - - nsCOMPtr<nsIRDFResource> rdfCard; - - retCode = rdfService->GetResource(nsDependentCString(uri), getter_AddRefs(rdfCard)) ; - ENSURE_GETUPDATECARD( "IN getUpdatedCard: Can not get the updated card\n" ); - - nsCOMPtr<nsIAbCard> aNewCard=do_QueryInterface((nsISupports *)rdfCard, &retCode); - ENSURE_GETUPDATECARD( "IN getUpdatedCard: Error in get new card\n" ); - - return aNewCard; - } - -#define ENSURE_MOZAB_PROFILE_NOT_LOOKED(directory) \ - if (getDirectoryType(directory) == SDBCAddress::Mozilla && isProfileLocked(NULL)) \ - { \ - m_aError.setResId( STR_MOZILLA_IS_RUNNIG_NO_CHANGES ); \ - return sal_False; \ - } - -sal_Int32 MQueryHelper::commitCard(const sal_uInt32 rowIndex,nsIAbDirectory * directory) -{ - ENSURE_MOZAB_PROFILE_NOT_LOOKED(directory); - - MQueryHelperResultEntry *resEntry = getByIndex(rowIndex); - if (!resEntry) - { - return sal_False; - } - nsIAbCard *card=resEntry->getCard(); - if (!card) - { - return sal_False; - } - nsresult rv; - PRBool hasCard; - rv = directory->HasCard(card,&hasCard); - if (setCardValues(rowIndex) != sal_True) - return sal_False; - - if (!NS_FAILED(rv) && hasCard) - { - rv = card->EditCardToDatabase(getAddrURI(directory)); - } - else - { - nsIAbCard *addedCard=NULL; - rv = directory->AddCard(card,&addedCard); - if (!NS_FAILED(rv)) - resEntry->setCard(addedCard); - } - //We return NS_ERROR_FILE_ACCESS_DENIED in the case the mozillaAB has been changed out side of our process - if (rv == NS_ERROR_FILE_ACCESS_DENIED ) - m_aError.setResId( STR_FOREIGN_PROCESS_CHANGED_AB ); - - return !(NS_FAILED(rv)); -} - -sal_Int32 MQueryHelper::deleteCard(const sal_uInt32 rowIndex,nsIAbDirectory * directory) -{ - ENSURE_MOZAB_PROFILE_NOT_LOOKED(directory); - MQueryHelperResultEntry *resEntry = getByIndex(rowIndex); - if (!resEntry) - { - return sal_False; - } - nsIAbCard *card=resEntry->getCard(); - if (!card) - { - return sal_False; - } - nsresult rv; - PRBool hasCard; - if (resEntry->getRowStates() == RowStates_Inserted) - { - rv = 0; - hasCard = sal_True; - } - else - rv = directory->HasCard(card,&hasCard); - - if (!NS_FAILED(rv) && hasCard) - { - nsCOMPtr <nsISupportsArray> cardsToDelete; - rv = NS_NewISupportsArray(getter_AddRefs(cardsToDelete)); - if (NS_SUCCEEDED(rv)) - { - nsCOMPtr<nsISupports> supports = do_QueryInterface(card, &rv); - if (NS_SUCCEEDED(rv)) - { - rv = cardsToDelete->AppendElement(supports); - if (NS_SUCCEEDED(rv)) - rv = directory->DeleteCards(cardsToDelete); - } - } - } - - if (NS_SUCCEEDED(rv)) - resEntry->setRowStates(RowStates_Deleted); - //We return NS_ERROR_FILE_ACCESS_DENIED in the case the mozillaAB has been changed out side of our process - if (rv == NS_ERROR_FILE_ACCESS_DENIED ) - m_aError.setResId( STR_FOREIGN_PROCESS_CHANGED_AB ); - return !(NS_FAILED(rv)); -} - -sal_Bool MQueryHelper::setCardValues(const sal_uInt32 rowIndex) -{ - MQueryHelperResultEntry *resEntry = getByIndex(rowIndex); - if (!resEntry) - { - m_aError.setResId( STR_CANT_FIND_ROW ); - return sal_False; - } - nsIAbCard *card=resEntry->getCard(); - if (!card) - { - m_aError.setResId( STR_CANT_FIND_CARD_FOR_ROW ); - return sal_False; - } - - MLdapAttributeMap::fillCardFromResult( *card, *resEntry ); - return sal_True; -} - -void MQueryHelper::getCardValues(nsIAbCard *card,sal_uInt32 rowIndex) -{ - MQueryHelperResultEntry *resEntry; - if (rowIndex>0) - { - resEntry = getByIndex(rowIndex); - } - else - resEntry = new MQueryHelperResultEntry(); - - MLdapAttributeMap::fillResultFromCard( *resEntry, *card ); - resEntry->setCard(card); - if (!rowIndex) - append( resEntry ); -} -sal_Bool MQueryHelper::resyncRow(sal_uInt32 rowIndex) -{ - - MQueryHelperResultEntry *resEntry = getByIndex(rowIndex); - if (!resEntry) - { - m_aError.setResId( STR_CANT_FIND_ROW ); - return sal_False; - } - nsIAbCard *card=resEntry->getCard(); - card = getUpdatedCard(card); - getCardValues(card,rowIndex); - return sal_True; -} - -sal_Int32 MQueryHelper::createNewCard() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - nsresult rv; - nsCOMPtr <nsIAbCard> card = do_CreateInstance(NS_ABCARDPROPERTY_CONTRACTID, &rv); - //set default values - getCardValues(card); - return static_cast<sal_Int32>(m_aResults.size()); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.hxx b/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.hxx deleted file mode 100644 index a492ca674a18..000000000000 --- a/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.hxx +++ /dev/null @@ -1,128 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MQUERYHELPER_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MQUERYHELPER_HXX - -#include <sal/config.h> - -#include <vector> - -#include "MNSInclude.hxx" -#include "MErrorResource.hxx" -#include <sal/types.h> -#include <rtl/ustring.hxx> -#include <osl/mutex.hxx> -#include <osl/conditn.hxx> -#include <osl/thread.hxx> - -#include <unordered_map> - -namespace connectivity -{ - namespace mozab - { - class MQueryHelperResultEntry - { - private: - typedef std::unordered_map< OString, OUString, OStringHash > FieldMap; - - mutable ::osl::Mutex m_aMutex; - FieldMap m_Fields; - nsCOMPtr<nsIAbCard> m_Card; - sal_Int32 m_RowStates; - - public: - MQueryHelperResultEntry(); - ~MQueryHelperResultEntry(); - - void insert( const OString &key, OUString &value ); - OUString getValue( const OString &key ) const; - void setValue( const OString &key, const OUString & rValue); - - void setCard(nsIAbCard *card); - nsIAbCard *getCard(); - sal_Bool setRowStates(sal_Int32 state){m_RowStates = state; return sal_True;}; - sal_Int32 getRowStates() const { return m_RowStates;}; - }; - - class MQueryHelper : public nsIAbDirectoryQueryResultListener - { - private: - typedef std::vector< MQueryHelperResultEntry* > resultsArray; - - mutable ::osl::Mutex m_aMutex; - ::osl::Condition m_aCondition; - resultsArray m_aResults; - sal_uInt32 m_nIndex; - sal_Bool m_bHasMore; - sal_Bool m_bAtEnd; - sal_Bool m_bErrorCondition; - sal_Bool m_bQueryComplete; - ErrorDescriptor m_aError; - - void append(MQueryHelperResultEntry* resEnt ); - - void clear_results(); - - void clearResultOrComplete(); - void notifyResultOrComplete(); - sal_Bool waitForResultOrComplete( ); - void getCardValues(nsIAbCard *card,sal_uInt32 rowIndex=0); -#if OSL_DEBUG_LEVEL > 0 - oslThreadIdentifier m_oThreadID; -#endif - - public: - NS_DECL_ISUPPORTS - NS_DECL_NSIABDIRECTORYQUERYRESULTLISTENER - - MQueryHelper(); - virtual ~MQueryHelper(); - - void reset(); - - MQueryHelperResultEntry* next( ); - - MQueryHelperResultEntry* getByIndex( sal_uInt32 nRow ); - - const ErrorDescriptor& getError() const { return m_aError; } - - sal_Bool isError() const; - - sal_Bool queryComplete() const; - - sal_Bool waitForQueryComplete( ); - sal_Bool waitForRow( sal_Int32 rowNum ); - - sal_Int32 getResultCount() const; - sal_uInt32 getRealCount() const; - sal_Int32 createNewCard(); //return Row count number - sal_Bool resyncRow(sal_uInt32 rowIndex); - - void notifyQueryError() ; - sal_Bool setCardValues(const sal_uInt32 rowIndex); - sal_Int32 commitCard(const sal_uInt32 rowIndex, nsIAbDirectory * directory); - sal_Int32 deleteCard(const sal_uInt32 rowIndex, nsIAbDirectory * directory); - }; - } -} -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MQUERYHELPER_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/mozillasrc/MTypeConverter.cxx b/connectivity/source/drivers/mozab/mozillasrc/MTypeConverter.cxx deleted file mode 100644 index 937b928a97d0..000000000000 --- a/connectivity/source/drivers/mozab/mozillasrc/MTypeConverter.cxx +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include "MNSInclude.hxx" -#include "MTypeConverter.hxx" -#include <ucbhelper/content.hxx> - -using namespace connectivity::mozab; - - -void MTypeConverter::ouStringToNsString(OUString const &ous, nsString &nss) -{ - // Convert to OString (utf-8 encoding). - OString os(OUStringToOString(ous, RTL_TEXTENCODING_UTF8)); - - const char *cs = os.getStr(); - PRUint32 csLen = os.getLength(); - - NS_ConvertUTF8toUCS2 mozString(cs, csLen); - //const PRUnichar* uniMozString = (const PRUnichar*) mozString; - nss = mozString; // temp. -} - -OString MTypeConverter::nsACStringToOString( const nsACString& _source ) -{ - const char* buffer = _source.BeginReading(); - const char* bufferEnd = _source.EndReading(); - return OString( buffer, static_cast<sal_Int32>(bufferEnd - buffer) ); -} - -void MTypeConverter::asciiToNsACString( const sal_Char* _asciiString, nsACString& _dest ) -{ - _dest.Truncate(); - _dest.AppendASCII( _asciiString ); -} - -void MTypeConverter::nsStringToOUString(nsString const &nss, OUString &ous) -{ - // Get clone of buffer. - PRUnichar *uc = ToNewUnicode(nss); - sal_Int32 nssLen = nss.Length(); - - // TODO check if this is ok. - // PRUnichar != sal_Unicode in mingw - OUString _ous(reinterpret_cast_mingw_only<sal_Unicode *>(uc), nssLen); - ous = _ous; - - nsMemory::Free(uc); -} - -void MTypeConverter::prUnicharToOUString(PRUnichar const *pru, OUString &ous) -{ - // TODO, specify length. - // PRUnichar != sal_Unicode in mingw - OUString _ous(reinterpret_cast_mingw_only<const sal_Unicode *>(pru)); - ous = _ous; -} - -char *MTypeConverter::ouStringToCCharStringAscii(OUString const &ous) -{ - // Convert OUString to OString, - OString os(OUStringToOString(ous, RTL_TEXTENCODING_ASCII_US)); - - return(strdup(os.getStr())); -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/mozillasrc/MTypeConverter.hxx b/connectivity/source/drivers/mozab/mozillasrc/MTypeConverter.hxx deleted file mode 100644 index 198bd9b36991..000000000000 --- a/connectivity/source/drivers/mozab/mozillasrc/MTypeConverter.hxx +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MTYPECONVERTER_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MTYPECONVERTER_HXX - -#include <rtl/ustring.hxx> - -#include <string> - -namespace connectivity -{ - namespace mozab - { - class MTypeConverter - { - public: - static void ouStringToNsString(const OUString&, nsString&); - static void nsStringToOUString(const nsString&, OUString&); - static void prUnicharToOUString(const PRUnichar*, OUString&); - // Use free() for the following 3 calls. - static char *ouStringToCCharStringAscii(const OUString&); - static char *nsStringToCCharStringAscii(const nsString&); - static char *ouStringToCCharStringUtf8(const OUString&); - // Convert to stl-string. - static ::std::string ouStringToStlString(const OUString&); - static ::std::string nsStringToStlString(const nsString&); - - static OString nsACStringToOString( const nsACString& _source ); - static void asciiToNsACString( const sal_Char* _asciiString, nsACString& _dest ); - - private: - MTypeConverter() {}; - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MTYPECONVERTER_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/post_include_mozilla.h b/connectivity/source/drivers/mozab/post_include_mozilla.h deleted file mode 100644 index 1570b011f0e7..000000000000 --- a/connectivity/source/drivers/mozab/post_include_mozilla.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#if defined __GNUC__ && !defined __clang__ -#pragma GCC diagnostic pop -#elif defined _MSC_VER -#pragma warning(pop) -#endif - -#ifdef MOZ_BOOL -# undef BOOL -# undef Bool -#endif - -#ifdef DEBUG_WAS_DEFINED - #define DEBUG DEBUG_WAS_DEFINED -#endif - -#ifdef _DEBUG_WAS_DEFINED - #define _DEBUG _DEBUG_WAS_DEFINED -#endif - -#ifndef _CONNECTIVITY_MOZILLA_REINTERPRET_CAST_MINGW_ONLY_ -#define _CONNECTIVITY_MOZILLA_REINTERPRET_CAST_MINGW_ONLY_ - -#ifdef __cplusplus -#ifdef __MINGW32__ -template<class T1, class T2> T1 inline reinterpret_cast_mingw_only(T2 p) { return reinterpret_cast<T1>(p); } -#else -template<class T1, class T2> T1 inline reinterpret_cast_mingw_only(T2 p) { return p; } -#endif -#endif - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/pre_include_mozilla.h b/connectivity/source/drivers/mozab/pre_include_mozilla.h deleted file mode 100644 index 50afe572b309..000000000000 --- a/connectivity/source/drivers/mozab/pre_include_mozilla.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <sal/config.h> - -#ifndef MINIMAL_PROFILEDISCOVER - // Turn off DEBUG Assertions - #ifdef _DEBUG - #define _DEBUG_WAS_DEFINED _DEBUG - #ifndef MOZILLA_ENABLE_DEBUG - #undef _DEBUG - #endif - #else - #undef _DEBUG_WAS_DEFINED - #ifdef MOZILLA_ENABLE_DEBUG - #define _DEBUG 1 - #endif - #endif - - // and turn off the additional virtual methods which are part of some interfaces when compiled - // with debug - #ifdef DEBUG - #define DEBUG_WAS_DEFINED DEBUG - #ifndef MOZILLA_ENABLE_DEBUG - #undef DEBUG - #endif - #else - #undef DEBUG_WAS_DEFINED - #ifdef MOZILLA_ENABLE_DEBUG - #define DEBUG 1 - #endif - #endif -#endif - -#if defined __GNUC__ && !defined __clang__ - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" -#elif defined _MSC_VER - #pragma warning(push, 1) - #pragma warning(disable:4946 4710) -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/resource/mork_res.hrc b/connectivity/source/inc/resource/mork_res.hrc index cd8cf9e3121d..bafeaf753d8b 100644 --- a/connectivity/source/inc/resource/mork_res.hrc +++ b/connectivity/source/inc/resource/mork_res.hrc @@ -26,8 +26,6 @@ #define STR_MOZILLA_ADDRESSBOOKS ( STR_MORK_BASE + 0 ) #define STR_THUNDERBIRD_ADDRESSBOOKS ( STR_MORK_BASE + 1 ) -#define STR_OE_ADDRESSBOOK ( STR_MORK_BASE + 2 ) -#define STR_OUTLOOK_MAPI_ADDRESSBOOK ( STR_MORK_BASE + 3 ) // FREE #define STR_NO_TABLE_CREATION_SUPPORT ( STR_MORK_BASE + 5 ) #define STR_MOZILLA_IS_RUNNING ( STR_MORK_BASE + 6 ) diff --git a/connectivity/source/inc/resource/mozab_res.hrc b/connectivity/source/inc/resource/mozab_res.hrc deleted file mode 100644 index 909a303f310f..000000000000 --- a/connectivity/source/inc/resource/mozab_res.hrc +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef CONNECTIVITY_RESOURCE_MOZAB_HRC -#define CONNECTIVITY_RESOURCE_MOZAB_HRC - -#include "resource/conn_shared_res.hrc" - -// = the mozab driver's resource strings - -#define STR_MOZILLA_ADDRESSBOOKS ( STR_MOZAB_BASE + 0 ) -#define STR_THUNDERBIRD_ADDRESSBOOKS ( STR_MOZAB_BASE + 1 ) -#define STR_OE_ADDRESSBOOK ( STR_MOZAB_BASE + 2 ) -#define STR_OUTLOOK_MAPI_ADDRESSBOOK ( STR_MOZAB_BASE + 3 ) - // FREE -#define STR_NO_TABLE_CREATION_SUPPORT ( STR_MOZAB_BASE + 5 ) -#define STR_MOZILLA_IS_RUNNING ( STR_MOZAB_BASE + 6 ) -#define STR_COULD_NOT_RETRIEVE_AB_ENTRY ( STR_MOZAB_BASE + 7 ) -#define STR_COULD_NOT_GET_DIRECTORY_NAME ( STR_MOZAB_BASE + 8 ) -#define STR_TIMEOUT_WAITING ( STR_MOZAB_BASE + 9 ) -#define STR_ERR_EXECUTING_QUERY ( STR_MOZAB_BASE + 10 ) -#define STR_MOZILLA_IS_RUNNIG_NO_CHANGES ( STR_MOZAB_BASE + 11 ) -#define STR_FOREIGN_PROCESS_CHANGED_AB ( STR_MOZAB_BASE + 12 ) -#define STR_CANT_FIND_ROW ( STR_MOZAB_BASE + 13 ) -#define STR_CANT_FIND_CARD_FOR_ROW ( STR_MOZAB_BASE + 14 ) -#define STR_QUERY_INVALID_IS_NULL_COLUMN ( STR_MOZAB_BASE + 15 ) -#define STR_NO_HOSTNAME ( STR_MOZAB_BASE + 16 ) -#define STR_NO_BASEDN ( STR_MOZAB_BASE + 17 ) -#define STR_COULD_NOT_CONNECT_LDAP ( STR_MOZAB_BASE + 18 ) -#define STR_ERROR_REFRESH_ROW ( STR_MOZAB_BASE + 19 ) -#define STR_ILLEGAL_MOVEMENT ( STR_MOZAB_BASE + 20 ) -#define STR_ERROR_GET_ROW ( STR_MOZAB_BASE + 21 ) -#define STR_COMMIT_ROW ( STR_MOZAB_BASE + 22 ) -#define STR_INVALID_ROW_UPDATE ( STR_MOZAB_BASE + 23 ) -#define STR_ROW_CAN_NOT_SAVE ( STR_MOZAB_BASE + 24 ) -#define STR_CAN_NOT_CANCEL_ROW_UPDATE ( STR_MOZAB_BASE + 25 ) -#define STR_CAN_NOT_CREATE_ROW ( STR_MOZAB_BASE + 26 ) -#define STR_QUERY_AT_LEAST_ONE_TABLES ( STR_MOZAB_BASE + 27 ) -#define STR_NO_COUNT_SUPPORT ( STR_MOZAB_BASE + 28 ) -#define STR_STMT_TYPE_NOT_SUPPORTED ( STR_MOZAB_BASE + 29 ) -#define STR_COULD_NOT_LOAD_LIB ( STR_MOZAB_BASE + 30 ) -#define STR_UNSPECIFIED_ERROR ( STR_MOZAB_BASE + 31 ) -#define STR_COULD_NOT_CREATE_ADDRESSBOOK ( STR_MOZAB_BASE + 32 ) - -#endif // CONNECTIVITY_RESOURCE_MOZAB_HRC - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/resource/conn_shared_res.src b/connectivity/source/resource/conn_shared_res.src index 23c7db11c634..38b0e9afec0f 100644 --- a/connectivity/source/resource/conn_shared_res.src +++ b/connectivity/source/resource/conn_shared_res.src @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "resource/mozab_res.hrc" +#include "resource/mork_res.hrc" #include "resource/macab_res.hrc" #include "resource/calc_res.hrc" #include "resource/ado_res.hrc" @@ -43,16 +43,6 @@ String STR_THUNDERBIRD_ADDRESSBOOKS "Thunderbird profile in the system."; }; -String STR_OE_ADDRESSBOOK -{ - Text [ en-US ] = "Outlook Express Address Book"; -}; - -String STR_OUTLOOK_MAPI_ADDRESSBOOK -{ - Text [ en-US ] = "Outlook (MAPI) Address Book"; -}; - String STR_NO_TABLE_CREATION_SUPPORT { Text [ en-US ] = "Creating tables is not supported for this kind of address books."; |