[Libreoffice-commits] core.git: connectivity/source

David Ostrovsky david at ostrovsky.org
Fri Oct 4 07:43:41 PDT 2013


 connectivity/source/drivers/mork/MConnection.cxx             |   40 +++++++----
 connectivity/source/drivers/mork/MConnection.hxx             |    8 +-
 connectivity/source/drivers/mork/MDatabaseMetaDataHelper.cxx |   12 +--
 connectivity/source/drivers/mork/MQueryHelper.cxx            |   15 ++--
 4 files changed, 47 insertions(+), 28 deletions(-)

New commits:
commit b4e25bc4c1f71327002cfbbaae5b85fd05c0ac28
Author: David Ostrovsky <david at ostrovsky.org>
Date:   Mon Sep 23 20:30:19 2013 +0200

    fdo#64741 Thunderbird mork driver: implement collected addresses
    
    Change-Id: I5a8516a6cf4bd71cea2be916d5a7fcfb16b4e749
    Reviewed-on: https://gerrit.libreoffice.org/6020
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/connectivity/source/drivers/mork/MConnection.cxx b/connectivity/source/drivers/mork/MConnection.cxx
index 8e5e623..d9ea6a7 100644
--- a/connectivity/source/drivers/mork/MConnection.cxx
+++ b/connectivity/source/drivers/mork/MConnection.cxx
@@ -53,7 +53,8 @@ OConnection::OConnection(MorkDriver* _pDriver)
 {
     m_pDriver->acquire();
     m_pProfileAccess = new ProfileAccess();
-    m_pMork = new MorkParser();
+    m_pBook = new MorkParser();
+    m_pHistory = new MorkParser();
 }
 //-----------------------------------------------------------------------------
 OConnection::~OConnection()
@@ -64,7 +65,8 @@ OConnection::~OConnection()
     m_pDriver->release();
     m_pDriver = NULL;
     delete m_pProfileAccess;
-    delete m_pMork;
+    delete m_pBook;
+    delete m_pHistory;
 }
 //-----------------------------------------------------------------------------
 void SAL_CALL OConnection::release() throw()
@@ -113,7 +115,8 @@ void OConnection::construct(const OUString& url,const Sequence< PropertyValue >&
     SAL_INFO("connectivity.mork", "URI = " << aAddrbookURI );
     SAL_INFO("connectivity.mork", "Scheme = " << aAddrbookScheme );
 
-    OUString path;
+    OUString abook;
+    OUString history;
     const OUString UNITTEST_URL = "thunderbird:unittest:";
     sal_Int32 unittestIndex = url.indexOf(UNITTEST_URL);
 
@@ -121,29 +124,42 @@ void OConnection::construct(const OUString& url,const Sequence< PropertyValue >&
     if (unittestIndex == -1)
     {
         OUString defaultProfile = m_pProfileAccess->getDefaultProfile(::com::sun::star::mozilla::MozillaProductType_Thunderbird);
-        path = m_pProfileAccess->getProfilePath(::com::sun::star::mozilla::MozillaProductType_Thunderbird, defaultProfile);
+        OUString path = m_pProfileAccess->getProfilePath(::com::sun::star::mozilla::MozillaProductType_Thunderbird, defaultProfile);
         SAL_INFO("connectivity.mork", "DefaultProfile: " << defaultProfile);
         SAL_INFO("connectivity.mork", "ProfilePath: " << path);
-        path += OUString( "/abook.mab" );
+        abook = path + OUString( "/abook.mab" );
+        history = path + OUString( "/history.mab" );
+        SAL_INFO("connectivity.mork", "AdressbookPath (abook): " << abook);
+        SAL_INFO("connectivity.mork", "AdressbookPath (history): " << history);
     }
     else
     {
-        path = aAddrbookURI.replaceFirst(UNITTEST_URL, "");
+        abook = aAddrbookURI.replaceFirst(UNITTEST_URL, "");
+        SAL_INFO("connectivity.mork", "unit test: " << abook);
     }
 
-    SAL_INFO("connectivity.mork", "AdressbookPath: " << path);
-
-    OString strPath = OUStringToOString(path, RTL_TEXTENCODING_UTF8 );
+    OString strPath = OUStringToOString(abook, RTL_TEXTENCODING_UTF8);
 
     // Open and parse mork file
-    if (!m_pMork->open(strPath.getStr()))
+    if (!m_pBook->open(strPath.getStr()))
     {
-        SAL_WARN("connectivity.mork", "Can not parse mork file!");
+        SAL_WARN("connectivity.mork", "Can not parse abook mork file: " << strPath);
         throwGenericSQLException( STR_COULD_NOT_LOAD_FILE, *this );
     }
 
+    // read history only in production
+    if (unittestIndex == -1)
+    {
+        strPath = OUStringToOString(history, RTL_TEXTENCODING_UTF8);
+        if (!m_pHistory->open(strPath.getStr()))
+        {
+            SAL_WARN("connectivity.mork", "Can not parse history mork file: " << strPath);
+            throwGenericSQLException( STR_COULD_NOT_LOAD_FILE, *this );
+        }
+    }
+
     // check that we can retrieve the tables:
-    MorkTableMap *Tables = m_pMork->getTables( defaultScope );
+    MorkTableMap *Tables = m_pBook->getTables( defaultScope );
     MorkTableMap::iterator tableIter;
     if (Tables)
     {
diff --git a/connectivity/source/drivers/mork/MConnection.hxx b/connectivity/source/drivers/mork/MConnection.hxx
index 8043648..753a64c 100644
--- a/connectivity/source/drivers/mork/MConnection.hxx
+++ b/connectivity/source/drivers/mork/MConnection.hxx
@@ -52,8 +52,10 @@ namespace connectivity
             OColumnAlias    m_aColumnAlias;
             // Profile Access
             ProfileAccess* m_pProfileAccess;
-            // Mork Parser
-            MorkParser* m_pMork;
+            // Mork Parser (abook)
+            MorkParser* m_pBook;
+            // Mork Parser (history)
+            MorkParser* m_pHistory;
             // Store Catalog
             ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog;
 
@@ -63,7 +65,7 @@ namespace connectivity
             virtual ~OConnection();
 
             MorkDriver* getDriver() {return m_pDriver;};
-            MorkParser* getMorkParser() {return m_pMork;};
+            MorkParser* getMorkParser(const OString& t) {return t == "CollectedAddressBook" ? m_pHistory : m_pBook;};
             void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException);
 
             // OComponentHelper
diff --git a/connectivity/source/drivers/mork/MDatabaseMetaDataHelper.cxx b/connectivity/source/drivers/mork/MDatabaseMetaDataHelper.cxx
index 61760a4..9502919 100644
--- a/connectivity/source/drivers/mork/MDatabaseMetaDataHelper.cxx
+++ b/connectivity/source/drivers/mork/MDatabaseMetaDataHelper.cxx
@@ -47,18 +47,18 @@ MDatabaseMetaDataHelper::~MDatabaseMetaDataHelper()
 {
 }
 
-sal_Bool MDatabaseMetaDataHelper::getTableStrings( OConnection*                      _pCon,
+sal_Bool MDatabaseMetaDataHelper::getTableStrings( OConnection* _pCon,
                                                    ::std::vector< OUString >& _rStrings)
 {
     SAL_INFO("connectivity.mork", "=> MDatabaseMetaDataHelper::getTableStrings()");
 
-    /* add default table */
-    OUString table = "AddressBook";
-    _rStrings.push_back(table);
+    /* add default tables */
+    _rStrings.push_back("AddressBook");
+    _rStrings.push_back("CollectedAddressBook");
 
-    /* retrieve list table names */
+    /* retrieve list table names (not from collected ab) */
     std::set<std::string> lists;
-    _pCon->getMorkParser()->retrieveLists(lists);
+    _pCon->getMorkParser("AddressBook")->retrieveLists(lists);
     for (::std::set<std::string>::iterator iter = lists.begin(); iter != lists.end(); ++iter) {
         OUString groupTableName = OStringToOUString((*iter).c_str(), RTL_TEXTENCODING_UTF8);
         SAL_INFO("connectivity.mork", "add Table " << groupTableName);
diff --git a/connectivity/source/drivers/mork/MQueryHelper.cxx b/connectivity/source/drivers/mork/MQueryHelper.cxx
index 4bb1c0c..3cc5b93 100644
--- a/connectivity/source/drivers/mork/MQueryHelper.cxx
+++ b/connectivity/source/drivers/mork/MQueryHelper.cxx
@@ -213,23 +213,24 @@ sal_Bool MQueryHelper::getRowValue( ORowSetValue& rValue, sal_Int32 nDBRow,const
 
 sal_Int32 MQueryHelper::executeQuery(OConnection* xConnection)
 {
-    SAL_INFO("connectivity.mork", "MQueryHelper::executeQuery()" );
+    SAL_INFO("connectivity.mork", "MQueryHelper::executeQuery()");
     reset();
 
     OString oStringTable = OUStringToOString( m_aAddressbook, RTL_TEXTENCODING_UTF8 );
     std::set<int> listRecords;
     bool handleListTable = false;
+    MorkParser* xMork = xConnection->getMorkParser(oStringTable);
 
     // check if we are retrieving the default table
-    if (oStringTable != "AddressBook")
+    if (oStringTable != "AddressBook" && oStringTable != "CollectedAddressBook")
     {
         handleListTable = true;
         // retrieve row ids for that list table
         std::string listTable = oStringTable.getStr();
-        xConnection->getMorkParser()->getRecordKeysForListTable(listTable, listRecords);
+        xMork->getRecordKeysForListTable(listTable, listRecords);
     }
     MorkTableMap::iterator tableIter;
-    MorkTableMap *Tables = xConnection->getMorkParser()->getTables( 0x80 );
+    MorkTableMap *Tables = xMork->getTables( 0x80 );
     MorkRowMap *Rows = 0;
     MorkRowMap::iterator rowIter;
 
@@ -237,7 +238,7 @@ sal_Int32 MQueryHelper::executeQuery(OConnection* xConnection)
     for ( tableIter = Tables->begin(); tableIter != Tables->end(); ++tableIter )
     {
         if (tableIter->first != 1) break;
-        Rows = xConnection->getMorkParser()->getRows( 0x80, &tableIter->second );
+        Rows = xMork->getRows( 0x80, &tableIter->second );
         if ( Rows )
         {
             // Iterate all rows
@@ -260,8 +261,8 @@ sal_Int32 MQueryHelper::executeQuery(OConnection* xConnection)
                 for (MorkCells::iterator CellsIter = rowIter->second.begin();
                      CellsIter != rowIter->second.end(); ++CellsIter )
                 {
-                    std::string column = xConnection->getMorkParser()->getColumn(CellsIter->first);
-                    std::string value = xConnection->getMorkParser()->getValue(CellsIter->second);
+                    std::string column = xMork->getColumn(CellsIter->first);
+                    std::string value = xMork->getValue(CellsIter->second);
                     OString key(column.c_str(), static_cast<sal_Int32>(column.size()));
                     OString valueOString(value.c_str(), static_cast<sal_Int32>(value.size()));
                     OUString valueOUString = OStringToOUString( valueOString, RTL_TEXTENCODING_UTF8 );


More information about the Libreoffice-commits mailing list