Kaydet (Commit) 77e4adbe authored tarafından David Ostrovsky's avatar David Ostrovsky Kaydeden (comit) Miklos Vajna

mork driver implementation

This is a preparation for merge into master, feature/mork
branch is obsoslete and shouldn't be used any more. In
context of this change the usage of old mozilla based mork
driver depends on platform: all non windows platforms use
this new mork driver, windows still uses mozilla.

Because mozilla driver shipping was stripped on feature/mork
branch for all platforms, the corresponding commits were
changed prior to creating this change (the build file changes
are reverted now). So the build and shipping of different mork
driver implementation should be implemented from scratch:
mozilla on windows, new mork dirver on all other platforms.

Currently the new mork dirver is compiled (on all platforms),
but not used. It can be tested with mork_helper executable.

fdo#51004

Change-Id: Ib2413ab6856f163337aa311c4bf7b1182d6c6f63
Reviewed-on: https://gerrit.libreoffice.org/635Reviewed-by: 's avatarMiklos Vajna <vmiklos@suse.cz>
Tested-by: 's avatarMiklos Vajna <vmiklos@suse.cz>
üst a60c63fd
......@@ -45,6 +45,7 @@ $(eval $(call gb_Helper_register_executables,NONE, \
idxdict \
lngconvex \
localize \
mork_helper \
mkunroll \
osl_process_child \
pdf2xml \
......@@ -300,6 +301,7 @@ $(eval $(call gb_Helper_register_libraries,OOOLIBS, \
lwpft \
MacOSXSpell \
merged \
mork \
mozab2 \
mozabdrv \
msfilter \
......
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# 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/.
#
$(eval $(call gb_Configuration_Configuration,driver_mork))
$(eval $(call gb_Configuration_add_spool_modules,driver_mork,connectivity/registry/mork,\
org/openoffice/Office/DataAccess/Drivers-mork.xcu \
))
$(eval $(call gb_Configuration_add_localized_datas,driver_mork,connectivity/registry/mork,\
org/openoffice/Office/DataAccess/Drivers.xcu \
))
# vim: set noet sw=4 ts=4:
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# 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/.
#
$(eval $(call gb_Executable_Executable,mork_helper))
$(eval $(call gb_Executable_set_include,mork_helper,\
-I$(SRCDIR)/connectivity/source/inc \
$$(INCLUDE) \
))
$(eval $(call gb_Executable_use_sdk_api,mork_helper))
$(eval $(call gb_Executable_use_libraries,mork_helper,\
cppu \
cppuhelper \
mork \
sal \
))
$(eval $(call gb_Executable_add_exception_objects,mork_helper,\
connectivity/source/drivers/mork/mork_helper \
))
# vim:set shiftwidth=4 softtabstop=4 expandtab:
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# 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/.
#
$(eval $(call gb_Library_Library,mork))
$(eval $(call gb_Library_set_componentfile,mork,connectivity/source/drivers/mork/mork))
$(eval $(call gb_Library_add_defs,mork,\
-DLO_DLLIMPLEMENTATION_MORK \
))
$(eval $(call gb_Library_set_include,mork,\
-I$(SRCDIR)/connectivity/source/inc \
$$(INCLUDE) \
))
$(eval $(call gb_Library_use_libraries,mork, \
comphelper \
cppu \
cppuhelper \
dbtools \
sal \
salhelper \
$(gb_STDLIBS) \
))
$(eval $(call gb_Library_use_sdk_api,mork))
$(eval $(call gb_Library_add_exception_objects,mork, \
connectivity/source/drivers/mork/MColumns \
connectivity/source/drivers/mork/MConfigAccess \
connectivity/source/drivers/mork/MColumnAlias \
connectivity/source/drivers/mork/MNSFolders \
connectivity/source/drivers/mork/MNSINIParser \
connectivity/source/drivers/mork/MNSProfileDiscover \
connectivity/source/drivers/mork/MorkParser \
connectivity/source/drivers/mork/MCatalog \
connectivity/source/drivers/mork/MConnection \
connectivity/source/drivers/mork/MDatabaseMetaData \
connectivity/source/drivers/mork/MDatabaseMetaDataHelper \
connectivity/source/drivers/mork/MDriver \
connectivity/source/drivers/mork/MStatement \
connectivity/source/drivers/mork/MResultSet \
connectivity/source/drivers/mork/MResultSetMetaData \
connectivity/source/drivers/mork/MPreparedStatement \
connectivity/source/drivers/mork/MQueryHelper \
connectivity/source/drivers/mork/MServices \
connectivity/source/drivers/mork/MTable \
connectivity/source/drivers/mork/MTables \
))
# vim: set noet sw=4 ts=4:
......@@ -38,12 +38,14 @@ $(eval $(call gb_Module_add_targets,connectivity,\
Configuration_flat \
Configuration_mysql \
Configuration_odbc \
Executable_mork_helper \
Library_calc \
Library_dbase \
Library_dbpool2 \
Library_dbtools \
Library_file \
Library_flat \
Library_mork \
Library_mysql \
Library_odbc \
Library_odbcbase \
......
<?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 .
-->
<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:install="http://openoffice.org/2004/installation" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<node oor:name="Installed" install:module="mork">
<node oor:name="sdbc:address:mozilla:" oor:op="replace">
<prop oor:name="Driver">
<value>com.sun.star.comp.sdbc.MozabDriver</value>
</prop>
<prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
<value xml:lang="en-US">SeaMonkey Address Book</value>
</prop>
<node oor:name="Features">
<node oor:name="EscapeDateTime" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
</node>
<node oor:name="MetaData">
<node oor:name="SupportsBrowsing" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
</node>
</node>
<node oor:name="sdbc:address:thunderbird:" oor:op="replace">
<prop oor:name="Driver">
<value>com.sun.star.comp.sdbc.MorkDriver</value>
</prop>
<prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
<value xml:lang="en-US">Thunderbird/Icedove Address Book</value>
</prop>
<node oor:name="Features">
<node oor:name="EscapeDateTime" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
</node>
<node oor:name="MetaData">
<node oor:name="SupportsBrowsing" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
</node>
</node>
</node>
</oor:component-data>
/* -*- 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::mork;
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_incrementInterlockedCount( &m_refCount );
// refreshTables();
// refreshViews();
// refreshGroups();
// refreshUsers();
// osl_decrementInterlockedCount( &m_refCount );
}
// -------------------------------------------------------------------------
void OCatalog::refreshTables()
{
TStringVector aVector;
Sequence< ::rtl::OUString > aTypes(1);
aTypes[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%"));
Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%")),::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%")),aTypes);
if(xResult.is())
{
Reference< XRow > xRow(xResult,UNO_QUERY);
::rtl::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: */
/* -*- 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_MORK_CATALOG_HXX_
#define _CONNECTIVITY_MORK_CATALOG_HXX_
#include "connectivity/sdbcx/VCatalog.hxx"
namespace connectivity
{
namespace mork
{
// 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:
OCatalog(OConnection* _pCon);
OConnection* getConnection() const { return m_pConnection; }
sdbcx::OCollection* getPrivateTables() const { return m_pTables;}
sdbcx::OCollection* getPrivateViews() const { return m_pViews; }
};
}
}
#endif // _CONNECTIVITY_MORK_CATALOG_HXX_
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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::mork;
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[ ::rtl::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( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ColumnAliases")) ) >>= xAliasesNode;
OSL_ENSURE( xAliasesNode.is(), "OColumnAlias::setAlias: missing the aliases node!" );
// this is a set of string nodes
Sequence< ::rtl::OUString > aProgrammaticNames;
if ( xAliasesNode.is() )
aProgrammaticNames = xAliasesNode->getElementNames();
//.............................................................
// travel through all the set elements
const ::rtl::OUString* pProgrammaticNames = aProgrammaticNames.getConstArray();
const ::rtl::OUString* pProgrammaticNamesEnd = pProgrammaticNames + aProgrammaticNames.getLength();
::rtl::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;
::rtl::OString sAsciiProgrammaticName( ::rtl::OUStringToOString( *pProgrammaticNames, RTL_TEXTENCODING_ASCII_US ) );
//.............................................................
#if OSL_DEBUG_LEVEL > 0
bool bFound = false;
#endif
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;
#if OSL_DEBUG_LEVEL > 0
bFound = true;
#endif
break;
}
}
OSL_ENSURE( bFound, "OColumnAlias::setAlias: did not find a programmatic name which exists in the configuration!" );
}
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
}
}
//------------------------------------------------------------------
::rtl::OString OColumnAlias::getProgrammaticNameOrFallbackToUTF8Alias( const ::rtl::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 ::rtl::OUStringToOString( _rAlias, RTL_TEXTENCODING_UTF8 );
}
return pos->second.programmaticAsciiName;
}
//------------------------------------------------------------------
bool OColumnAlias::isColumnSearchable( const ::rtl::OUString _alias ) const
{
::rtl::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: */
/* -*- 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_MORK_COLUMNALIAS_HXX_
#define _CONNECTIVITY_MORK_COLUMNALIAS_HXX_
#include <unotools/confignode.hxx>
#include <osl/mutex.hxx>
#include <vector>
#include <boost/unordered_map.hpp>
namespace connectivity
{
namespace mork
{
class OColumnAlias
{
public:
struct AliasEntry
{
::rtl::OString programmaticAsciiName;
size_t columnPosition;
AliasEntry()
:programmaticAsciiName()
,columnPosition( 0 )
{
}
AliasEntry( const sal_Char* _programmaticAsciiName, size_t _columnPosition )
:programmaticAsciiName( _programmaticAsciiName )
,columnPosition( _columnPosition )
{
}
};
typedef ::boost::unordered_map< ::rtl::OUString, AliasEntry, ::rtl::OUStringHash > AliasMap;
private:
AliasMap m_aAliasMap;
public:
OColumnAlias( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & );
inline bool hasAlias( const ::rtl::OUString& _rAlias ) const
{
return m_aAliasMap.find( _rAlias ) != m_aAliasMap.end();
}
::rtl::OString getProgrammaticNameOrFallbackToUTF8Alias( const ::rtl::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 ::rtl::OUString _alias ) const;
private:
void initialize( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB );
};
}
}
#endif // _CONNECTIVITY_MORK_COLUMNALIAS_HXX_
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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::mork;
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 ::rtl::OUString& _rName)
{
Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns(Any(),
m_pTable->getSchema(),m_pTable->getTableName(),_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);
::rtl::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);
xRet = pRet;
break;
}
}
}
return xRet;
}
// -------------------------------------------------------------------------
void OColumns::impl_refresh() throw(RuntimeException)
{
m_pTable->refreshColumns();
}
// -----------------------------------------------------------------------------
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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_MORK_COLUMNS_HXX_
#define _CONNECTIVITY_MORK_COLUMNS_HXX_
#include "connectivity/sdbcx/VCollection.hxx"
#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
#include "connectivity/sdbcx/IRefreshable.hxx"
#include "MTable.hxx"
namespace connectivity
{
namespace mork
{
class OColumns : public sdbcx::OCollection
{
protected:
OTable* m_pTable;
virtual sdbcx::ObjectType createObject(const ::rtl::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 // _CONNECTIVITY_MORK_COLUMNS_HXX_
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
/* -*- 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_MORK_MCONFIGACCESS_HXX
#include <sal/types.h>
extern "C" const sal_Unicode* SAL_CALL getUserProfile( void );
extern "C" const sal_Char* SAL_CALL getPabDescription( void );
extern "C" const sal_Char* SAL_CALL getHisDescription( void );
#endif // CONNECTIVITY_MORK_MCONFIGACCESS_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef CONNECTIVITY_SCONNECTION_HXX
#define CONNECTIVITY_SCONNECTION_HXX
#include "connectivity/CommonTools.hxx"
#include "connectivity/OSubComponent.hxx"
#include "TConnection.hxx"
#include "MColumnAlias.hxx"
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/sdbc/SQLWarning.hpp>
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
#include <cppuhelper/weakref.hxx>
#include <memory>
// do we want here namespace too?
class MorkParser;
namespace connectivity
{
namespace mork
{
namespace css = com::sun::star;
class MorkDriver;
class ProfileAccess;
class ErrorDescriptor;
typedef connectivity::OMetaConnection OConnection_BASE; // implements basics and text encoding
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;
MorkDriver* m_pDriver; // Pointer to the owning
// driver object
OColumnAlias m_aColumnAlias;
// Profile Access
ProfileAccess* m_pProfileAccess;
// Mork Parser
MorkParser* m_pMork;
// Store Catalog
::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog;
public:
virtual void construct( const ::rtl::OUString& url,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info) throw(::com::sun::star::sdbc::SQLException);
OConnection(MorkDriver* const driver);
virtual ~OConnection();
MorkDriver* getDriver() {return m_pDriver;};
MorkParser* getMorkParser() {return m_pMork;};
void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException);
// OComponentHelper
virtual void SAL_CALL disposing(void);
// 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 ::rtl::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 ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::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 ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual ::rtl::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);
const OColumnAlias & getColumnAlias() const { return (m_aColumnAlias); }
static ::rtl::OUString getDriverImplementationName();
sal_Bool getForceLoadTables() {return true;}
// 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();
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 );
};
}
}
#endif // CONNECTIVITY_SCONNECTION_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "MDatabaseMetaDataHelper.hxx"
#include "FDatabaseMetaDataResultSet.hxx"
#include <connectivity/dbexception.hxx>
#include <comphelper/uno3.hxx>
#include <comphelper/sequence.hxx>
#include <osl/mutex.hxx>
#include <osl/conditn.hxx>
// do we need it?
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>
using namespace connectivity;
using namespace connectivity::mork;
// -------------------------------------------------------------------------
MDatabaseMetaDataHelper::MDatabaseMetaDataHelper()
{
SAL_INFO("connectivity.mork", "=> MDatabaseMetaDataHelper::MDatabaseMetaDataHelper()" );
}
// -------------------------------------------------------------------------
MDatabaseMetaDataHelper::~MDatabaseMetaDataHelper()
{
}
sal_Bool MDatabaseMetaDataHelper::getTableStrings( OConnection* _pCon,
::std::vector< ::rtl::OUString >& _rStrings)
{
::rtl::OUString sAbURI;
::rtl::OString sAbURIString;
SAL_INFO("connectivity.mork", "=> MDatabaseMetaDataHelper::getTableStrings()");
_pCon->getMorkParser();
// TODO: retrieve Tables from MorkParser
// only put for now the private adress book
rtl::OUString table = rtl::OUString::createFromAscii( "AddressBook");
_rStrings.push_back(table);
return( sal_True );
}
sal_Bool MDatabaseMetaDataHelper::getTables( OConnection* _pCon,
const ::rtl::OUString& tableNamePattern,
ODatabaseMetaDataResultSet::ORows& _rRows)
{
SAL_INFO("connectivity.mork", "=> MDatabaseMetaDataHelper::getTables()");
static ODatabaseMetaDataResultSet::ORows aRows;
SAL_INFO("connectivity.mork", "=> 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< ::rtl::OUString > tables;
// ::std::vector< ::rtl::OUString > tabletypes;
::rtl::OUString matchAny = rtl::OUString::createFromAscii("%");
if ( !getTableStrings( _pCon, tables ) )
return sal_False;
for ( size_t i = 0; i < tables.size(); i++ ) {
ODatabaseMetaDataResultSet::ORow aRow(3);
::rtl::OUString aTableName = tables[i];
//::rtl::OUString aTableType = tabletypes[i];
SAL_INFO("connectivity.mork", "TableName: " << aTableName );
// return tables to caller
if (match( tableNamePattern, aTableName, '\0' ))
#if 0
&&
0 != ::comphelper::findValue( types, aTableType, sal_True ).getLength() ||
0 != ::comphelper::findValue( types, matchAny, sal_True ).getLength()))
#endif
{
if ( aTableName.isEmpty() ) {
aTableName = rtl::OUString::createFromAscii("AddressBook");
}
SAL_INFO("connectivity.mork", "TableName: " << aTableName);
aRow.push_back( new ORowSetValueDecorator( aTableName ) ); // Table name
// aRow.push_back( new ORowSetValueDecorator( aTableType ) ); // Table type
aRow.push_back( new ORowSetValueDecorator( rtl::OUString::createFromAscii("TABLE") ) ); // Table type
aRow.push_back( ODatabaseMetaDataResultSet::getEmptyValue() ); // Remarks
aRows.push_back(aRow);
}
}
_rRows = aRows;
return(sal_True);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef CONNECTIVITY_MORK_DBMETADATAHELPER_HXX
#define CONNECTIVITY_MORK_DBMETADATAHELPER_HXX
#include <comphelper/proparrhlp.hxx>
#include <comphelper/propertycontainer.hxx>
#include "FDatabaseMetaDataResultSet.hxx"
#include "MErrorResource.hxx"
#include <MConnection.hxx>
#include <com/sun/star/uno/Sequence.hxx>
namespace connectivity
{
namespace mork
{
class MDatabaseMetaDataHelper
{
public:
MDatabaseMetaDataHelper();
~MDatabaseMetaDataHelper();
//
sal_Bool getTableStrings( OConnection* _pCon,
::std::vector< ::rtl::OUString >& _rStrings);
sal_Bool getTables( OConnection* _pCon,
const ::rtl::OUString& tableNamePattern,
ODatabaseMetaDataResultSet::ORows& _rRows);
};
}
}
#endif // CONNECTIVITY_MORK_DBMETADATAHELPER_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "MDriver.hxx"
#include "MConnection.hxx"
#include "MNSProfileDiscover.hxx"
#include "resource/mork_res.hrc"
#include "resource/common_res.hrc"
using namespace connectivity::mork;
namespace connectivity
{
namespace mork
{
css::uno::Reference< css::uno::XInterface > create(css::uno::Reference< css::uno::XComponentContext > const & context)
{
return static_cast< cppu::OWeakObject * >(new MorkDriver(context));
}
}
}
MorkDriver::MorkDriver(css::uno::Reference< css::uno::XComponentContext > const context):
context_(context),
m_xFactory(context_->getServiceManager(), css::uno::UNO_QUERY)
{
SAL_INFO("connectivity.mork", "=> MorkDriver::MorkDriver()" );
// css::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceFactory(;
m_ProfileAccess = new ProfileAccess();
assert(context.is());
}
// static ServiceInfo
//------------------------------------------------------------------------------
rtl::OUString MorkDriver::getImplementationName_Static( ) throw(css::uno::RuntimeException)
{
return rtl::OUString(MORK_DRIVER_IMPL_NAME);
}
//------------------------------------------------------------------------------
css::uno::Sequence< ::rtl::OUString > MorkDriver::getSupportedServiceNames_Static( ) throw (css::uno::RuntimeException)
{
css::uno::Sequence< ::rtl::OUString > aSNS(1);
aSNS[0] = ::rtl::OUString( "com.sun.star.sdbc.Driver");
return aSNS;
}
rtl::OUString SAL_CALL MorkDriver::getImplementationName()
throw (css::uno::RuntimeException)
{
return getImplementationName_Static();
}
sal_Bool SAL_CALL MorkDriver::supportsService(const rtl::OUString& serviceName)
throw (css::uno::RuntimeException)
{
css::uno::Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
const ::rtl::OUString* pSupported = aSupported.getConstArray();
const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
for (;pSupported != pEnd && !pSupported->equals(serviceName); ++pSupported)
;
return pSupported != pEnd;
}
css::uno::Sequence< rtl::OUString > MorkDriver::getSupportedServiceNames()
throw (css::uno::RuntimeException)
{
return getSupportedServiceNames_Static();
}
css::uno::Reference< css::sdbc::XConnection > MorkDriver::connect(
rtl::OUString const & url,
css::uno::Sequence< css::beans::PropertyValue > const & info)
throw (css::sdbc::SQLException, css::uno::RuntimeException)
{
SAL_INFO("connectivity.mork", "=> MorkDriver::connect()" );
(void) url; (void) info; // avoid warnings
css::uno::Reference< css::sdbc::XConnection > xCon;
OConnection* pCon = new OConnection(this);
xCon = pCon; // important here because otherwise the connection could be deleted inside (refcount goes -> 0)
pCon->construct(url, info);
return xCon;
}
sal_Bool MorkDriver::acceptsURL(rtl::OUString const & url)
throw (css::sdbc::SQLException, css::uno::RuntimeException)
{
SAL_INFO("connectivity.mork", "=> MorkDriver::acceptsURL()" );
//... TODO
(void) url; // avoid warnings
return true;
}
css::uno::Sequence< css::sdbc::DriverPropertyInfo > MorkDriver::getPropertyInfo(
rtl::OUString const & url,
css::uno::Sequence< css::beans::PropertyValue > const & info)
throw (css::sdbc::SQLException, css::uno::RuntimeException)
{
//... TODO
(void) url; (void) info; // avoid warnings
return css::uno::Sequence< css::sdbc::DriverPropertyInfo >();
}
sal_Int32 MorkDriver::getMajorVersion() throw (css::uno::RuntimeException) {
//... TODO
return 0;
}
sal_Int32 MorkDriver::getMinorVersion() throw (css::uno::RuntimeException) {
//... TODO
return 0;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_DRIVER_HXX
#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_DRIVER_HXX
#include "sal/config.h"
#include <cassert>
#include "boost/noncopyable.hpp"
#include "com/sun/star/beans/PropertyValue.hpp"
#include "com/sun/star/lang/XServiceInfo.hpp"
#include "com/sun/star/sdbc/DriverPropertyInfo.hpp"
#include "com/sun/star/sdbc/SQLException.hpp"
#include "com/sun/star/sdbc/XConnection.hpp"
#include "com/sun/star/sdbc/XDriver.hpp"
#include "com/sun/star/uno/Reference.hxx"
#include "com/sun/star/uno/RuntimeException.hpp"
#include "com/sun/star/uno/Sequence.hxx"
#include "com/sun/star/uno/XComponentContext.hpp"
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include "cppuhelper/implbase2.hxx"
#include "cppuhelper/weak.hxx"
#include "rtl/ustring.hxx"
#include "sal/types.h"
#define MORK_DRIVER_IMPL_NAME "com.sun.star.comp.sdbc.MorkDriver"
namespace com { namespace sun { namespace star {
namespace uno {
class XComponentContext;
class XInterface;
}
} } }
namespace rtl { class OUString; }
namespace connectivity { namespace mork {
class ProfileAccess;
namespace css = com::sun::star;
css::uno::Reference< css::uno::XInterface > SAL_CALL
create(css::uno::Reference< css::uno::XComponentContext > const &);
class MorkDriver:
public cppu::WeakImplHelper2< css::lang::XServiceInfo, css::sdbc::XDriver >,
private boost::noncopyable
{
public:
MorkDriver(css::uno::Reference< css::uno::XComponentContext > const context);
static ::rtl::OUString getImplementationName_Static()
throw(css::uno::RuntimeException);
static css::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static()
throw (css::uno::RuntimeException);
css::uno::Reference< com::sun::star::lang::XMultiServiceFactory > getFactory(){return m_xFactory;}
private:
ProfileAccess* m_ProfileAccess;
virtual ~MorkDriver() {}
virtual rtl::OUString SAL_CALL getImplementationName()
throw (css::uno::RuntimeException);
virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName)
throw (css::uno::RuntimeException);
virtual css::uno::Sequence< rtl::OUString > SAL_CALL
getSupportedServiceNames() throw (css::uno::RuntimeException);
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL connect(
rtl::OUString const & url,
css::uno::Sequence< css::beans::PropertyValue > const & info)
throw (css::sdbc::SQLException, css::uno::RuntimeException);
virtual sal_Bool SAL_CALL acceptsURL(
rtl::OUString const & url)
throw (css::sdbc::SQLException, css::uno::RuntimeException);
virtual css::uno::Sequence< css::sdbc::DriverPropertyInfo > SAL_CALL
getPropertyInfo(
rtl::OUString const & url,
css::uno::Sequence< css::beans::PropertyValue > const & info)
throw (css::sdbc::SQLException, css::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getMajorVersion()
throw (css::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getMinorVersion()
throw (css::uno::RuntimeException);
css::uno::Reference< css::uno::XComponentContext > context_;
css::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xFactory;
};
} }
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 CONNECITIVITY_MORK_ERROR_RESOURCE_HXX
#define CONNECITIVITY_MORK_ERROR_RESOURCE_HXX
#include <rtl/ustring.hxx>
namespace connectivity
{
namespace mork
{
class ErrorDescriptor
{
private:
sal_uInt16 m_nErrorResourceId;
sal_Int32 m_nErrorCondition;
::rtl::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 ::rtl::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 ::rtl::OUString& getParameter() const { return m_sParameter; }
inline bool is() const { return ( m_nErrorResourceId != 0 ) || ( m_nErrorCondition != 0 ); }
};
}
}
#endif // CONNECITIVITY_MORK_ERROR_RESOURCE_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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_MORK_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 mork
{
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
createDriverConfigNode( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB );
}
}
#endif // CONNECTIVITY_MORK_MEXTCONFIGACCESS_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 <MNSFolders.hxx>
#ifdef UNIX
#include <sys/types.h>
#include <strings.h>
#include <string.h>
#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>
#include <osl/thread.h>
using namespace ::com::sun::star::mozilla;
namespace
{
// -------------------------------------------------------------------
static ::rtl::OUString lcl_getUserDataDirectory()
{
::osl::Security aSecurity;
::rtl::OUString aConfigPath;
#if defined(XP_WIN) || defined(MACOSX)
aSecurity.getConfigDir( aConfigPath );
#else
//This is to find the dir under which .mozilla/.thunderbird is created.
//mozilla doesn't honour XDG_CONFIG_HOME, so raw home dir required here
//not xdg-config dir
aSecurity.getHomeDir( aConfigPath );
#endif
return aConfigPath + ::rtl::OUString("/");
}
// -------------------------------------------------------------------
const size_t NB_PRODUCTS = 3;
const size_t NB_CANDIDATES = 4;
static const char* DefaultProductDir[NB_PRODUCTS][NB_CANDIDATES] =
{
#if defined(XP_WIN)
{ "Mozilla/SeaMonkey/", NULL, NULL, NULL },
{ "Mozilla/Firefox/", NULL, NULL, NULL },
{ "Thunderbird/", "Mozilla/Thunderbird/", NULL, NULL }
#elif(MACOSX)
{ "../Mozilla/SeaMonkey/", NULL, NULL, NULL },
{ "Firefox/", NULL, NULL, NULL },
{ "../Thunderbird/", NULL, NULL, NULL }
#else
{ ".mozilla/seamonkey/", NULL, NULL, NULL },
{ ".mozilla/firefox/", NULL, NULL, NULL },
{ ".thunderbird/", ".mozilla-thunderbird/", ".mozilla/thunderbird/", ".icedove" }
#endif
};
static const char* ProductRootEnvironmentVariable[NB_PRODUCTS] =
{
"MOZILLA_PROFILE_ROOT",
"MOZILLA_FIREFOX_PROFILE_ROOT",
"MOZILLA_THUNDERBIRD_PROFILE_ROOT",
};
// -------------------------------------------------------------------
static ::rtl::OUString lcl_guessProfileRoot( MozillaProductType _product )
{
size_t productIndex = _product - 1;
static ::rtl::OUString s_productDirectories[NB_PRODUCTS];
if ( s_productDirectories[ productIndex ].isEmpty() )
{
::rtl::OUString sProductPath;
// check whether we have an anevironment variable which helps us
const char* pProfileByEnv = getenv( ProductRootEnvironmentVariable[ productIndex ] );
if ( pProfileByEnv )
{
sProductPath = ::rtl::OUString( pProfileByEnv, rtl_str_getLength( pProfileByEnv ), osl_getThreadTextEncoding() );
// asume that this is fine, no further checks
}
else
{
::rtl::OUString sProductDirCandidate;
const char* pProfileRegistry = "profiles.ini";
// check all possible candidates
for ( size_t i=0; i<NB_CANDIDATES; ++i )
{
if ( NULL == DefaultProductDir[ productIndex ][ i ] )
break;
sProductDirCandidate = lcl_getUserDataDirectory() +
::rtl::OUString::createFromAscii( DefaultProductDir[ productIndex ][ i ] );
// check existence
::osl::DirectoryItem aRegistryItem;
::osl::FileBase::RC result = ::osl::DirectoryItem::get( sProductDirCandidate + ::rtl::OUString::createFromAscii( pProfileRegistry ), aRegistryItem );
if ( result == ::osl::FileBase::E_None )
{
::osl::FileStatus aStatus( osl_FileStatus_Mask_Validate );
result = aRegistryItem.getFileStatus( aStatus );
if ( result == ::osl::FileBase::E_None )
{
// the registry file exists
break;
}
}
}
::osl::FileBase::getSystemPathFromFileURL( sProductDirCandidate, sProductPath );
}
s_productDirectories[ productIndex ] = sProductPath;
}
return s_productDirectories[ productIndex ];
}
}
// -----------------------------------------------------------------------
::rtl::OUString getRegistryDir(MozillaProductType product)
{
if (product == MozillaProductType_Default)
return ::rtl::OUString();
return lcl_guessProfileRoot( product );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 _MNSFOLDERS_HXX_
#define _MNSFOLDERS_HXX_
#include <sal/types.h>
#include <osl/diagnose.h>
#include <osl/conditn.hxx>
#include <com/sun/star/mozilla/MozillaProductType.hpp>
#include <rtl/ustring.hxx>
::rtl::OUString getRegistryDir(::com::sun::star::mozilla::MozillaProductType product);
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 <MNSINIParser.hxx>
#include <rtl/byteseq.hxx>
IniParser::IniParser(OUString const & rIniName) throw(com::sun::star::io::IOException )
{
OUString iniUrl;
if (osl_File_E_None != osl_getFileURLFromSystemPath(rIniName.pData, &iniUrl.pData))
return;
SAL_INFO("connectivity.mork", "IniParser: " << iniUrl);
oslFileHandle handle=NULL;
oslFileError fileError = osl_File_E_INVAL;
try{
if (!iniUrl.isEmpty())
fileError = osl_openFile(iniUrl.pData, &handle, osl_File_OpenFlag_Read);
}
catch(const ::com::sun::star::io::IOException&)
{
SAL_WARN("connectivity.mork", "IniParser -- couldn't open file: " << iniUrl);
return;
}
if (osl_File_E_None == fileError)
{
rtl::ByteSequence seq;
sal_uInt64 nSize = 0;
osl_getFileSize(handle, &nSize);
OUString sectionName( "no name section" );
while (true)
{
sal_uInt64 nPos;
if (osl_File_E_None != osl_getFilePos(handle, &nPos) || nPos >= nSize)
break;
if (osl_File_E_None != osl_readLine(handle , (sal_Sequence **) &seq))
break;
OString line( (const sal_Char *) seq.getConstArray(), seq.getLength() );
sal_Int32 nIndex = line.indexOf('=');
if (nIndex >= 1)
{
ini_Section *aSection = &mAllSection[sectionName];
struct ini_NameValue nameValue;
nameValue.sName = OStringToOUString(
line.copy(0,nIndex).trim(), RTL_TEXTENCODING_ASCII_US );
nameValue.sValue = OStringToOUString(
line.copy(nIndex+1).trim(), RTL_TEXTENCODING_UTF8 );
aSection->lList.push_back(nameValue);
}
else
{
sal_Int32 nIndexStart = line.indexOf('[');
sal_Int32 nIndexEnd = line.indexOf(']');
if ( nIndexEnd > nIndexStart && nIndexStart >=0)
{
sectionName = OStringToOUString(
line.copy(nIndexStart + 1,nIndexEnd - nIndexStart -1).trim(), RTL_TEXTENCODING_ASCII_US );
if (sectionName.isEmpty())
sectionName = OUString("no name section");
ini_Section *aSection = &mAllSection[sectionName];
aSection->sName = sectionName;
}
}
}
osl_closeFile(handle);
}
#if OSL_DEBUG_LEVEL > 0
else
{
SAL_WARN("connectivity.mork", "IniParser -- couldn't open file: " << iniUrl);
}
#endif
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 __MNSINIPARSER_HXX__
#define __MNSINIPARSER_HXX__
#include <rtl/ustring.hxx>
#include <com/sun/star/io/IOException.hpp>
#include <osl/process.h>
#include <map>
#include <list>
#if OSL_DEBUG_LEVEL > 0
#include <stdio.h>
#endif
using ::rtl::OUString;
using ::rtl::OString;
struct ini_NameValue
{
rtl::OUString sName;
rtl::OUString sValue;
inline ini_NameValue() SAL_THROW(())
{}
inline ini_NameValue(
OUString const & name, OUString const & value ) SAL_THROW(())
: sName( name ),
sValue( value )
{}
};
typedef std::list<
ini_NameValue
> NameValueList;
struct ini_Section
{
rtl::OUString sName;
NameValueList lList;
};
typedef std::map<rtl::OUString,
ini_Section
>IniSectionMap;
class IniParser
{
IniSectionMap mAllSection;
public:
IniSectionMap * getAllSection(){return &mAllSection;};
IniParser(OUString const & rIniName) throw(com::sun::star::io::IOException);
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 "MNSProfileDiscover.hxx"
#ifndef MAXPATHLEN
#define MAXPATHLEN 1024
#endif
#include <MNSFolders.hxx>
#include <MNSINIParser.hxx>
namespace connectivity
{
namespace mork
{
ProfileStruct::ProfileStruct(MozillaProductType aProduct,::rtl::OUString aProfileName,
const ::rtl::OUString& aProfilePath
)
{
product=aProduct;
profileName = aProfileName;
profilePath = aProfilePath;
}
::rtl::OUString ProfileStruct::getProfilePath()
{
return profilePath;
}
ProfileAccess::~ProfileAccess()
{
}
ProfileAccess::ProfileAccess()
{
LoadProductsInfo();
}
sal_Int32 ProfileAccess::LoadProductsInfo()
{
//load SeaMonkey 2 profiles to m_ProductProfileList
sal_Int32 count = LoadXPToolkitProfiles(MozillaProductType_Mozilla);
//load thunderbird profiles to m_ProductProfileList
count += LoadXPToolkitProfiles(MozillaProductType_Thunderbird);
//load firefox profiles to m_ProductProfileList
//firefox profile does not containt address book, but maybe others need them
count += LoadXPToolkitProfiles(MozillaProductType_Firefox);
return count;
}
//Thunderbird and firefox profiles are saved in profiles.ini
sal_Int32 ProfileAccess::LoadXPToolkitProfiles(MozillaProductType product)
{
sal_Int32 index=product;
ProductStruct &m_Product = m_ProductProfileList[index];
::rtl::OUString regDir = getRegistryDir(product);
::rtl::OUString profilesIni( regDir );
profilesIni += ::rtl::OUString("profiles.ini");
IniParser parser( profilesIni );
IniSectionMap &mAllSection = *(parser.getAllSection());
IniSectionMap::iterator iBegin = mAllSection.begin();
IniSectionMap::iterator iEnd = mAllSection.end();
for(;iBegin != iEnd;++iBegin)
{
ini_Section *aSection = &(*iBegin).second;
::rtl::OUString profileName;
::rtl::OUString profilePath;
::rtl::OUString sIsRelative;
::rtl::OUString sIsDefault;
for(NameValueList::iterator itor=aSection->lList.begin();
itor != aSection->lList.end();
++itor)
{
struct ini_NameValue * aValue = &(*itor);
if ( aValue->sName == "Name" )
{
profileName = aValue->sValue;
}
else if ( aValue->sName == "IsRelative" )
{
sIsRelative = aValue->sValue;
}
else if ( aValue->sName == "Path" )
{
profilePath = aValue->sValue;
}
else if ( aValue->sName == "Default" )
{
sIsDefault = aValue->sValue;
}
}
if (!(profileName.isEmpty() && profilePath.isEmpty()))
{
sal_Int32 isRelative = 0;
if (!sIsRelative.isEmpty())
{
isRelative = sIsRelative.toInt32();
}
rtl::OUString fullProfilePath;
if(isRelative)
{
fullProfilePath = regDir + profilePath;
}
else
{
fullProfilePath = profilePath;
}
ProfileStruct* profileItem = new ProfileStruct(product,profileName,
fullProfilePath
);
m_Product.mProfileList[profileName] = profileItem;
sal_Int32 isDefault = 0;
if (!sIsDefault.isEmpty())
{
isDefault = sIsDefault.toInt32();
}
if (isDefault)
m_Product.mCurrentProfileName = profileName;
}
}
return static_cast< ::sal_Int32 >(m_Product.mProfileList.size());
}
::rtl::OUString ProfileAccess::getProfilePath( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
{
sal_Int32 index=product;
ProductStruct &m_Product = m_ProductProfileList[index];
if (!m_Product.mProfileList.size() || m_Product.mProfileList.find(profileName) == m_Product.mProfileList.end())
{
//Profile not found
return ::rtl::OUString();
}
else
return m_Product.mProfileList[profileName]->getProfilePath();
}
::sal_Int32 ProfileAccess::getProfileCount( ::com::sun::star::mozilla::MozillaProductType product) throw (::com::sun::star::uno::RuntimeException)
{
sal_Int32 index=product;
ProductStruct &m_Product = m_ProductProfileList[index];
return static_cast< ::sal_Int32 >(m_Product.mProfileList.size());
}
::sal_Int32 ProfileAccess::getProfileList( ::com::sun::star::mozilla::MozillaProductType product, ::com::sun::star::uno::Sequence< ::rtl::OUString >& list ) throw (::com::sun::star::uno::RuntimeException)
{
sal_Int32 index=product;
ProductStruct &m_Product = m_ProductProfileList[index];
list.realloc(static_cast<sal_Int32>(m_Product.mProfileList.size()));
sal_Int32 i=0;
for(ProfileList::iterator itor=m_Product.mProfileList.begin();
itor != m_Product.mProfileList.end();
++itor)
{
ProfileStruct * aProfile = (*itor).second;
list[i] = aProfile->getProfileName();
i++;
}
return static_cast< ::sal_Int32 >(m_Product.mProfileList.size());
}
::rtl::OUString ProfileAccess::getDefaultProfile( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException)
{
sal_Int32 index=product;
ProductStruct &m_Product = m_ProductProfileList[index];
if (!m_Product.mCurrentProfileName.isEmpty())
{
//default profile setted in mozilla registry
return m_Product.mCurrentProfileName;
}
if (m_Product.mProfileList.empty())
{
//there are not any profiles
return ::rtl::OUString();
}
ProfileStruct * aProfile = (*m_Product.mProfileList.begin()).second;
return aProfile->getProfileName();
}
::sal_Bool ProfileAccess::isProfileLocked( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
{
(void)product; /* avoid warning about unused parameter */
(void)profileName; /* avoid warning about unused parameter */
return sal_True;
}
::sal_Bool ProfileAccess::getProfileExists( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
{
sal_Int32 index=product;
ProductStruct &m_Product = m_ProductProfileList[index];
if (!m_Product.mProfileList.size() || m_Product.mProfileList.find(profileName) == m_Product.mProfileList.end())
{
return sal_False;
}
else
return sal_True;
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 __MNSProfileDiscover_h___
#define __MNSProfileDiscover_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>
#include "dllapi.h"
using namespace com::sun::star::mozilla;
namespace connectivity
{
namespace mork
{
class ProfileStruct;
}
}
typedef ::std::map < ::rtl::OUString, ::connectivity::mork::ProfileStruct* > ProfileList;
namespace connectivity
{
namespace mork
{
class ProfileStruct
{
public:
ProfileStruct(MozillaProductType aProduct,::rtl::OUString aProfileName,
const ::rtl::OUString &aProfilePath
);
MozillaProductType getProductType() { return product;}
::rtl::OUString getProfileName(){ return profileName;}
::rtl::OUString getProfilePath() ;
protected:
MozillaProductType product;
::rtl::OUString profileName;
::rtl::OUString profilePath;
};
class ProductStruct
{
public:
void setCurrentProfile(::rtl::OUString aProfileName){mCurrentProfileName = aProfileName;}
::rtl::OUString mCurrentProfileName;
ProfileList mProfileList;
};
//Used to query profiles information
class LO_DLLPUBLIC_MORK ProfileAccess
{
public:
virtual ~ProfileAccess();
ProfileAccess();
::rtl::OUString getProfilePath( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
::sal_Int32 getProfileCount( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException);
::sal_Int32 getProfileList( ::com::sun::star::mozilla::MozillaProductType product, ::com::sun::star::uno::Sequence< ::rtl::OUString >& list ) throw (::com::sun::star::uno::RuntimeException);
::rtl::OUString getDefaultProfile( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException);
::sal_Bool SAL_CALL isProfileLocked( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
::sal_Bool SAL_CALL getProfileExists( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
protected:
ProductStruct m_ProductProfileList[4];
sal_Int32 LoadProductsInfo();
sal_Int32 LoadXPToolkitProfiles(MozillaProductType product);
};
}
}
#endif // __MNSProfileDiscover_h___
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
/* -*- 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_MORK_QUERYHELPER_HXX_
#define _CONNECTIVITY_MORK_QUERYHELPER_HXX_
#include <sal/types.h>
#include <rtl/ustring.hxx>
#include <osl/mutex.hxx>
#include <osl/conditn.hxx>
#include <comphelper/stl_types.hxx>
#include <osl/thread.hxx>
#include <connectivity/FValue.hxx>
#include <boost/unordered_map.hpp>
#include "MErrorResource.hxx"
namespace connectivity
{
namespace mork
{
class OConnection;
class MQueryHelper;
class ErrorDescriptor;
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 ) {}
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:
::rtl::OUString m_aName; // LHS
MQueryOp::cond_type m_aBooleanCondition;
::rtl::OUString m_aValue; // RHS
public:
MQueryExpressionString( ::rtl::OUString& lhs,
MQueryOp::cond_type cond,
::rtl::OUString rhs )
: MQueryExpressionBase( MQueryExpressionBase::StringExpr )
, m_aName( lhs )
, m_aBooleanCondition( cond )
, m_aValue( rhs )
{
}
MQueryExpressionString( ::rtl::OUString& lhs,
MQueryOp::cond_type cond )
: MQueryExpressionBase( MQueryExpressionBase::StringExpr )
, m_aName( lhs )
, m_aBooleanCondition( cond )
, m_aValue( ::rtl::OUString() )
{
}
const ::rtl::OUString& getName() const { return m_aName; }
MQueryOp::cond_type getCond() const { return m_aBooleanCondition; }
const ::rtl::OUString& getValue() const { return m_aValue; }
};
class MQueryExpression : public MQueryExpressionBase
{
friend class MQueryHelper;
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 MQueryHelperResultEntry
{
private:
typedef ::boost::unordered_map< ::rtl::OString, ::rtl::OUString, ::rtl::OStringHash > FieldMap;
mutable ::osl::Mutex m_aMutex;
FieldMap m_Fields;
public:
MQueryHelperResultEntry();
~MQueryHelperResultEntry();
void insert( const rtl::OString &key, rtl::OUString &value );
rtl::OUString getValue( const rtl::OString &key ) const;
void setValue( const rtl::OString &key, const rtl::OUString & rValue);
};
class MQueryHelper
{
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;
void append(MQueryHelperResultEntry* resEnt );
void clear_results();
OColumnAlias m_rColumnAlias;
ErrorDescriptor m_aError;
::rtl::OUString m_aAddressbook;
MQueryExpression m_aExpr;
/*
void clearResultOrComplete();
void notifyResultOrComplete();
sal_Bool waitForResultOrComplete( );
void getCardValues(nsIAbCard *card,sal_uInt32 rowIndex=0);
*/
public:
MQueryHelper(const OColumnAlias& _ca);
virtual ~MQueryHelper();
void reset();
MQueryHelperResultEntry* next();
MQueryHelperResultEntry* getByIndex( sal_uInt32 nRow );
sal_Bool isError() const;
sal_Bool queryComplete() const;
sal_Int32 getResultCount() const;
sal_Bool checkRowAvailable( sal_Int32 nDBRow );
sal_Bool getRowValue( ORowSetValue& rValue, sal_Int32 nDBRow,const rtl::OUString& aDBColumnName, sal_Int32 nType );
sal_Int32 executeQuery(OConnection* xConnection);
const OColumnAlias& getColumnAlias() const { return m_rColumnAlias; }
bool hadError() const { return m_aError.is(); }
inline const ErrorDescriptor& getError() const { return m_aError; }
void setAddressbook( ::rtl::OUString&);
void setExpression( MQueryExpression &_expr );
};
}
}
#endif // _CONNECTIVITY_MORK_QUERYHELPER_HXX_
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
This diff is collapsed.
/* -*- 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_SRESULSETMETADATA_HXX
#define CONNECTIVITY_SRESULSETMETADATA_HXX
#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
#include <cppuhelper/implbase1.hxx>
#include <vector>
#include <rtl/ref.hxx>
#include "MConnection.hxx"
#include "MTable.hxx"
namespace connectivity
{
namespace mork
{
//**************************************************************
//************ Class: ResultSetMetaData
//**************************************************************
typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData> OResultSetMetaData_BASE;
class OResultSetMetaData : public OResultSetMetaData_BASE
{
::rtl::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 ::rtl::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 ::rtl::OUString SAL_CALL getColumnLabel( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getColumnName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual ::rtl::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 ::rtl::OUString SAL_CALL getTableName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual ::rtl::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 ::rtl::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 ::rtl::OUString SAL_CALL getColumnServiceName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
};
}
}
#endif // CONNECTIVITY_SRESULSETMETADATA_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -24,6 +24,8 @@
// Mozilla driver resource ids
#define STR_MOZAB_BASE 1000
// either mozab or mork is actually used
#define STR_MORK_BASE 1000
// common resource ids
#define STR_COMMON_BASE 1200
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment