diff options
author | David Ostrovsky <david@ostrovsky.org> | 2012-07-26 19:36:35 +0200 |
---|---|---|
committer | David Ostrovsky <david@ostrovsky.org> | 2012-07-27 17:20:04 +0200 |
commit | 715c0e17dd4b381c654658af235a3f2e9e80561c (patch) | |
tree | 89b6e2864d54d49c28b8c6d0bc0cb712d1ad3eb9 | |
parent | 30583bca4b124bf45039beaa715607ae1494bbbb (diff) |
mork driver: more verbose output
Change-Id: I598490aa71b658844d912008c0cf14e225bda0db
-rw-r--r-- | connectivity/source/drivers/mork/MConnection.cxx | 12 | ||||
-rw-r--r-- | connectivity/source/drivers/mork/MNSINIParser.cxx | 15 | ||||
-rw-r--r-- | connectivity/source/drivers/mork/MNSProfileDiscover.hxx | 6 | ||||
-rw-r--r-- | connectivity/source/drivers/mork/MorkParser.cxx | 26 | ||||
-rw-r--r-- | connectivity/source/drivers/mork/MorkParser.hxx | 8 | ||||
-rw-r--r-- | connectivity/source/drivers/mork/dllapi.h | 25 | ||||
-rw-r--r-- | connectivity/source/drivers/mork/mork.xml | 85 | ||||
-rw-r--r-- | connectivity/source/drivers/mork/mork_helper.cxx | 77 |
8 files changed, 230 insertions, 24 deletions
diff --git a/connectivity/source/drivers/mork/MConnection.cxx b/connectivity/source/drivers/mork/MConnection.cxx index 2d1cde8bda68..a43665f8f4f0 100644 --- a/connectivity/source/drivers/mork/MConnection.cxx +++ b/connectivity/source/drivers/mork/MConnection.cxx @@ -69,7 +69,7 @@ void SAL_CALL OConnection::release() throw() void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info) throw(SQLException) { (void) info; // avoid warnings - SAL_INFO("mork", "IN OConnection::construct()" ); + SAL_INFO("connectvity.mork", "IN OConnection::construct()" ); // open file setURL(url); // @@ -103,8 +103,8 @@ void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyV sAdditionalInfo = aAddrbookURI.copy( nLen + 1 ); } - SAL_INFO("mork", "URI = " << ((OUtoCStr(aAddrbookURI)) ? (OUtoCStr(aAddrbookURI)):("NULL")) ); - SAL_INFO("mork", "Scheme = " << ((OUtoCStr(aAddrbookScheme)) ? (OUtoCStr(aAddrbookScheme)):("NULL")) ); + SAL_INFO("connectvity.mork", "URI = " << ((OUtoCStr(aAddrbookURI)) ? (OUtoCStr(aAddrbookURI)):("NULL")) ); + SAL_INFO("connectvity.mork", "Scheme = " << ((OUtoCStr(aAddrbookScheme)) ? (OUtoCStr(aAddrbookScheme)):("NULL")) ); } // XServiceInfo @@ -130,7 +130,7 @@ Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const :: ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OConnection_BASE::rBHelper.bDisposed); - SAL_INFO("mork", "OConnection::prepareStatement( " << OUtoCStr( _sSql ) << " )"); + SAL_INFO("connectvity.mork", "OConnection::prepareStatement( " << OUtoCStr( _sSql ) << " )"); return NULL; } // -------------------------------------------------------------------------------- @@ -138,7 +138,7 @@ Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const ::rtl:: { OSL_UNUSED( _sSql ); ::dbtools::throwFeatureNotImplementedException( "XConnection::prepareCall", *this ); - SAL_INFO("mork", "OConnection::prepareCall( " << OUtoCStr( _sSql ) << " )"); + SAL_INFO("connectvity.mork", "OConnection::prepareCall( " << OUtoCStr( _sSql ) << " )"); return NULL; } // -------------------------------------------------------------------------------- @@ -146,7 +146,7 @@ Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const ::rtl:: { ::osl::MutexGuard aGuard( m_aMutex ); // when you need to transform SQL92 to you driver specific you can do it here - SAL_INFO("OConnection::nativeSQL( %s )", OUtoCStr( _sSql ) ); + SAL_INFO("connectvity.mork", "OConnection::nativeSQL(" << _sSql << " )" ); return _sSql; } diff --git a/connectivity/source/drivers/mork/MNSINIParser.cxx b/connectivity/source/drivers/mork/MNSINIParser.cxx index 55e57f573401..c601213bd654 100644 --- a/connectivity/source/drivers/mork/MNSINIParser.cxx +++ b/connectivity/source/drivers/mork/MNSINIParser.cxx @@ -26,11 +26,7 @@ IniParser::IniParser(OUString const & rIniName) throw(com::sun::star::io::IOExce if (osl_File_E_None != osl_getFileURLFromSystemPath(rIniName.pData, &iniUrl.pData)) return; - -#if OSL_DEBUG_LEVEL > 0 - OString sFile = OUStringToOString(iniUrl, RTL_TEXTENCODING_ASCII_US); - OSL_TRACE(__FILE__" -- parser() - %s\n", sFile.getStr()); -#endif + SAL_INFO("connectivity.mork", "IniParser: " << iniUrl); oslFileHandle handle=NULL; oslFileError fileError = osl_File_E_INVAL; try{ @@ -39,10 +35,8 @@ IniParser::IniParser(OUString const & rIniName) throw(com::sun::star::io::IOExce } catch(const ::com::sun::star::io::IOException&) { -#if OSL_DEBUG_LEVEL > 0 - OString file_tmp = OUStringToOString(iniUrl, RTL_TEXTENCODING_ASCII_US); - OSL_TRACE( __FILE__" -- couldn't open file: %s", file_tmp.getStr() ); -#endif + SAL_WARN("connectivity.mork", "IniParser -- couldn't open file: " << iniUrl); + return; } if (osl_File_E_None == fileError) @@ -94,8 +88,7 @@ IniParser::IniParser(OUString const & rIniName) throw(com::sun::star::io::IOExce #if OSL_DEBUG_LEVEL > 0 else { - OString file_tmp = OUStringToOString(iniUrl, RTL_TEXTENCODING_ASCII_US); - OSL_TRACE( __FILE__" -- couldn't open file: %s", file_tmp.getStr() ); + SAL_WARN("connectivity.mork", "IniParser -- couldn't open file: " << iniUrl); } #endif } diff --git a/connectivity/source/drivers/mork/MNSProfileDiscover.hxx b/connectivity/source/drivers/mork/MNSProfileDiscover.hxx index 3e1468b9e1d6..1cb44cdcfeb8 100644 --- a/connectivity/source/drivers/mork/MNSProfileDiscover.hxx +++ b/connectivity/source/drivers/mork/MNSProfileDiscover.hxx @@ -31,11 +31,7 @@ #include <vector> #include <map> -#if defined LO_DLLIMPLEMENTATION_MORK -#define LO_DLLPUBLIC_MORK SAL_DLLPUBLIC_EXPORT -#else -#define LO_DLLPUBLIC_MORK SAL_DLLPUBLIC_IMPORT -#endif +#include "dllapi.h" using namespace com::sun::star::mozilla; namespace connectivity diff --git a/connectivity/source/drivers/mork/MorkParser.cxx b/connectivity/source/drivers/mork/MorkParser.cxx index 07be7d1b8cb8..bd37d66ff5c1 100644 --- a/connectivity/source/drivers/mork/MorkParser.cxx +++ b/connectivity/source/drivers/mork/MorkParser.cxx @@ -576,3 +576,29 @@ std::string &MorkParser::getColumn( int oid ) return foundIter->second; } + +void MorkParser::dumpColumns() +{ + for ( MorkDict::iterator cellsIter = columns_.begin(); + cellsIter != columns_.end(); cellsIter++ ) + { + char buffer[20]; + sprintf( buffer, "%d", cellsIter->first ); + std::string value = cellsIter->second; + //SAL_INFO("connectivity.mork", "dumpColumns: " << buffer << " => " << value); + std::cout << "dumpColumns: " << buffer << " => " << value << std::endl; + } +} + +void MorkParser::dumpValues() +{ + for ( MorkDict::iterator cellsIter = values_.begin(); + cellsIter != values_.end(); cellsIter++ ) + { + char buffer[20]; + sprintf( buffer, "%d", cellsIter->first ); + std::string value = cellsIter->second; + //SAL_INFO("connectivity.mork", "dumpValues: " << buffer << " => " << value); + std::cout << "dumpValues: " << buffer << " => " << value << std::endl; + } +} diff --git a/connectivity/source/drivers/mork/MorkParser.hxx b/connectivity/source/drivers/mork/MorkParser.hxx index dca413315cb1..e26bef53b658 100644 --- a/connectivity/source/drivers/mork/MorkParser.hxx +++ b/connectivity/source/drivers/mork/MorkParser.hxx @@ -34,9 +34,13 @@ #ifndef _MORK_PARSER_HXX_ #define _MORK_PARSER_HXX_ +#include <sal/types.h> + #include <string> #include <map> +#include "dllapi.h" + // Types typedef std::map< int, std::string > MorkDict; @@ -76,7 +80,7 @@ enum MorkTerm /// Class MorkParser -class MorkParser +class LO_DLLPUBLIC_MORK MorkParser { public: @@ -112,6 +116,8 @@ public: std::string &getColumn( int oid ); + void dumpColumns(); + void dumpValues(); protected: // Members diff --git a/connectivity/source/drivers/mork/dllapi.h b/connectivity/source/drivers/mork/dllapi.h new file mode 100644 index 000000000000..80f7cec756c8 --- /dev/null +++ b/connectivity/source/drivers/mork/dllapi.h @@ -0,0 +1,25 @@ + +/* -*- 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 _MORK_DLLAPI_H +#define _MORK_DLLAPI_H + +#include "sal/config.h" +#include "sal/types.h" + +#if defined LO_DLLIMPLEMENTATION_MORK +#define LO_DLLPUBLIC_MORK SAL_DLLPUBLIC_EXPORT +#else +#define LO_DLLPUBLIC_MORK SAL_DLLPUBLIC_IMPORT +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/mork.xml b/connectivity/source/drivers/mork/mork.xml new file mode 100644 index 000000000000..cb1ce0b47c1e --- /dev/null +++ b/connectivity/source/drivers/mork/mork.xml @@ -0,0 +1,85 @@ +<?xml version='1.0' encoding="UTF-8"?> +<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//W3C//DTD HTML 3.2//EN" "module-description.dtd"> +<!-- + * 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 . + --> +<module-description xmlns:xlink="http://www.w3.org/1999/xlink"> + <module-name> mork </module-name> + <component-description> + <Author>David Ostrovsky</Author> + <Name>com.sun.star.comp.sdbc.MorkDriver</Name> + <Description> + This is the implementation of the sdbc-mork bridge. + </Description> + <loader-name>com.sun.star.loader.SharedLibrary</loader-name> + <language>c++</language> + <status value="final"/> + <supported-service> com.sun.star.sdbc.Driver </supported-service> + <service-dependency> ... </service-dependency> + </component-description> + <project-build-dependency> cppuhelper </project-build-dependency> + <project-build-dependency> cppu </project-build-dependency> + <project-build-dependency> sal </project-build-dependency> + + <runtime-module-dependency> cppuhelper </runtime-module-dependency> + <runtime-module-dependency> cppu1 </runtime-module-dependency> + <runtime-module-dependency> sal1 </runtime-module-dependency> + + + + <type> com.sun.star.util.XCancellable </type> + <type> com.sun.star.util.XNumberFormatter </type> + <type> com.sun.star.uno.TypeClass </type> + <type> com.sun.star.uno.XWeak </type> + <type> com.sun.star.uno.XAggregation </type> + <type> com.sun.star.beans.XPropertyState </type> + <type> com.sun.star.beans.XPropertySet </type> + <type> com.sun.star.beans.PropertyValue </type> + <type> com.sun.star.beans.XMultiPropertySet </type> + <type> com.sun.star.beans.XFastPropertySet </type> + <type> com.sun.star.lang.XTypeProvider </type> + <type> com.sun.star.lang.EventObject </type> + <type> com.sun.star.lang.XComponent </type> + <type> com.sun.star.lang.IllegalArgumentException </type> + <type> com.sun.star.lang.XMultiServiceFactory </type> + <type> com.sun.star.java.XJavaThreadRegister_11 </type> + <type> com.sun.star.java.XJavaVM </type> + <type> com.sun.star.sdbc.XConnection </type> + <type> com.sun.star.sdbc.XStatement </type> + <type> com.sun.star.sdbc.XResultSet </type> + <type> com.sun.star.sdbc.XResultSetMetaDataSupplier</type> + <type> com.sun.star.sdbc.XColumnLocate </type> + <type> com.sun.star.sdbc.XResultSetUpdate </type> + <type> com.sun.star.sdbc.XWarningsSupplier </type> + <type> com.sun.star.sdbc.XRowUpdate </type> + <type> com.sun.star.sdbc.XMultipleResults </type> + <type> com.sun.star.sdbc.XBatchExecution </type> + <type> com.sun.star.sdbc.XPreparedBatchExecution </type> + <type> com.sun.star.sdbc.XParameters </type> + <type> com.sun.star.sdbc.XOutParameters </type> + <type> com.sun.star.sdbc.DriverPropertyInfo </type> + <type> com.sun.star.sdbc.XRow </type> + <type> com.sun.star.sdb.XColumnUpdate </type> + <type> com.sun.star.sdb.XColumn </type> + <type> com.sun.star.sdbc.XResultSetUpdate </type> + <type> com.sun.star.sdbc.XRowUpdate </type> + <type> com.sun.star.sdbcx.XRowLocate </type> + <type> com.sun.star.sdbcx.XDeleteRows </type> + +</module-description> + + diff --git a/connectivity/source/drivers/mork/mork_helper.cxx b/connectivity/source/drivers/mork/mork_helper.cxx index 560592ba159a..999d43ebdd33 100644 --- a/connectivity/source/drivers/mork/mork_helper.cxx +++ b/connectivity/source/drivers/mork/mork_helper.cxx @@ -1,12 +1,87 @@ #include "MNSProfileDiscover.hxx" +#include "MorkParser.hxx" + using namespace connectivity::mork; +bool openAddressBook(const std::string& path) +{ + MorkParser mork; + // Open and parse mork file + if (!mork.open(path)) + { + return false; + } + const int defaultScope = 0x80; + MorkTableMap *Tables = 0; + MorkTableMap::iterator tableIter; + MorkRowMap::iterator rowIter; + Tables = mork.getTables( defaultScope ); + if ( Tables ) + { + // Iterate all tables + for ( tableIter = Tables->begin(); tableIter != Tables->end(); tableIter++ ) + { + if ( 0 == tableIter->first ) continue; + SAL_INFO("connectivity.mork", "table->first : " << tableIter->first); + std::string column = mork.getColumn( tableIter->first ); + std::string value = mork.getValue( tableIter->first ); + SAL_INFO("connectivity.mork", "table.column : " << column); + SAL_INFO("connectivity.mork", "table.value : " << value); +#if 0 + MorkRowMap *Rows = 0; + // Get rows + Rows = mork.getRows( defaultScope, &tableIter->second ); + if ( Rows ) { + // Iterate all rows + for ( rowIter = Rows->begin(); rowIter != Rows->end(); rowIter++ ) + { + if ( 0 == rowIter->first ) continue; + RawAbeMap ram; + std::string column; + std::string value; + char buffer[20]; + sprintf( buffer, "%d", rowIter->first ); + abe.id = std::string( buffer ); + // Get cells + for ( MorkCells::iterator cellsIter = rowIter->second.begin(); + cellsIter != rowIter->second.end(); cellsIter++ ) + { + column = mork.getColumn( cellsIter->first ); + value = mork.getValue( cellsIter->second ); + ram[ column ] = value; + } + AbeMap::iterator abeIter; + abes_[ rowIter->first ] = abe; + abeIter = abes_.find( rowIter->first ); + addEntry( ram, abeIter->second ); + } + } +#endif + } + } + + mork.dumpColumns(); + mork.dumpValues(); + + return true; +} + int main( int argc, const char* argv[] ) { int x = argc; x++; argv++; ProfileAccess* access = new ProfileAccess(); - ::rtl::OUString profile = access->getDefaultProfile(::com::sun::star::mozilla::MozillaProductType_Thunderbird); + ::rtl::OUString defaultProfile = access->getDefaultProfile(::com::sun::star::mozilla::MozillaProductType_Thunderbird); + SAL_INFO("connectivity.mork", "DefaultProfile: " << defaultProfile); + + ::rtl::OUString profilePath = access->getProfilePath(::com::sun::star::mozilla::MozillaProductType_Thunderbird, defaultProfile); + SAL_INFO("connectivity.mork", "ProfilePath: " << profilePath); + + profilePath += rtl::OUString( "/abook.mab" ); + + SAL_INFO("connectivity.mork", "abook.mab: " << profilePath); + rtl::OString aOString = ::rtl::OUStringToOString( profilePath, RTL_TEXTENCODING_UTF8 ); + openAddressBook(aOString.getStr()); } |