diff options
author | Caolán McNamara <caolanm@redhat.com> | 2013-02-07 17:18:47 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-02-07 17:22:15 +0000 |
commit | 157d94d3d2c9af9b9db41b8adc6162019aef4ef9 (patch) | |
tree | dab87c959dc501d2a8c7c88d1118c6e0651a8c5e /connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx | |
parent | 0cf743b7921e88ed6ece7471daf121344fa78b3a (diff) |
make evolution-3.6 work with address book
Change-Id: Ieffe1a374f3f94991ca63b6ccfbfb7bdc43255d6
Diffstat (limited to 'connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx')
-rw-r--r-- | connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx | 121 |
1 files changed, 91 insertions, 30 deletions
diff --git a/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx b/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx index 8d0b8027c0e9..e5b504e2c6b3 100644 --- a/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx +++ b/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx @@ -1074,13 +1074,22 @@ Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getColumns( pResultSet->setRows( getColumnRows( columnNamePattern ) ); return xResultSet; } + +ESourceRegistry *get_e_source_registry() +{ + static ESourceRegistry *theInstance; + if (!theInstance) + theInstance = e_source_registry_new_sync(NULL, NULL); + return theInstance; +} + // ------------------------------------------------------------------------- -static bool isSourceBackend( ESource *pSource, const char *backendname) +bool isSourceBackend(ESource *pSource, const char *backendname) { - if (!pSource || e_source_has_extension (pSource, "Address Book")) // E_SOURCE_EXTENSION_ADDRESS_BOOK + if (!pSource || !e_source_has_extension (pSource, E_SOURCE_EXTENSION_ADDRESS_BOOK)) return false; - gpointer extension = e_source_get_extension (pSource, "Address Book"); // E_SOURCE_EXTENSION_ADDRESS_BOOK + gpointer extension = e_source_get_extension (pSource, E_SOURCE_EXTENSION_ADDRESS_BOOK); return extension && g_strcmp0 (e_source_backend_get_backend_name (extension), backendname) == 0; } @@ -1120,44 +1129,96 @@ Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTables( ODatabaseMetaDataResultSet::ORows aRows; - GSList *pSources; - pSources = e_source_registry_list_sources (registry, "Address Book"); // E_SOURCE_EXTENSION_ADDRESS_BOOK - - GList *liter; - for( liter = pSources; liter; liter = liter->next) + if (eds_check_version(3, 6, 0) == NULL) { - ESource *pSource = E_SOURCE (liter->data); - bool can = false; - - switch (m_pConnection->getSDBCAddressType()) { - case SDBCAddress::EVO_GWISE: - can = isSourceBackend( pSource, "groupwise"); // not supported in evo/eds 3.6.x+, somehow - break; - case SDBCAddress::EVO_LOCAL: - can = isSourceBackend( pSource, "local"); - break; - case SDBCAddress::EVO_LDAP: - can = isSourceBackend( pSource, "ldap"); - break; - case SDBCAddress::Unknown: - break; - } + fprintf(stderr, "OEvoabDatabaseMetaData::getTables\n"); + GList *pSources = e_source_registry_list_sources(get_e_source_registry(), E_SOURCE_EXTENSION_ADDRESS_BOOK); - if (can) { - rtl::OUString aName = rtl::OStringToOUString( e_source_get_display_name( pSource ), - RTL_TEXTENCODING_UTF8 ); + for (GList* liter = pSources; liter; liter = liter->next) + { + ESource *pSource = E_SOURCE (liter->data); + bool can = false; + switch (m_pConnection->getSDBCAddressType()) + { + case SDBCAddress::EVO_GWISE: + can = isSourceBackend( pSource, "groupwise"); // not supported in evo/eds 3.6.x+, somehow + break; + case SDBCAddress::EVO_LOCAL: + can = isSourceBackend( pSource, "local"); + break; + case SDBCAddress::EVO_LDAP: + can = isSourceBackend( pSource, "ldap"); + break; + case SDBCAddress::Unknown: + can = true; + break; + } + if (!can) + continue; ODatabaseMetaDataResultSet::ORow aRow(3); aRow.reserve(6); - aRow.push_back(new ORowSetValueDecorator(aName)); + OUString aUID = OStringToOUString( e_source_get_uid( pSource ), + RTL_TEXTENCODING_UTF8 ); + aRow.push_back(new ORowSetValueDecorator(aUID)); aRow.push_back(new ORowSetValueDecorator(aTable)); + OUString aHumanName = OStringToOUString( e_source_get_display_name( pSource ), + RTL_TEXTENCODING_UTF8 ); aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - // add also e_source_get_uid (pSource) aRows.push_back(aRow); } + + g_list_free_full (pSources, g_object_unref); + } + else + { + ESourceList *pSourceList; + if( !e_book_get_addressbooks (&pSourceList, NULL) ) + pSourceList = NULL; + + GSList *g; + for( g = e_source_list_peek_groups( pSourceList ); g; g = g->next) + { + GSList *s; + const char *p = e_source_group_peek_base_uri(E_SOURCE_GROUP(g->data)); + + switch (m_pConnection->getSDBCAddressType()) { + case SDBCAddress::EVO_GWISE: + if ( !strncmp( "groupwise://", p, 11 )) + break; + else + continue; + case SDBCAddress::EVO_LOCAL: + if ( !strncmp( "file://", p, 6 ) || + !strncmp( "local://", p, 6 ) ) + break; + else + continue; + case SDBCAddress::EVO_LDAP: + if ( !strncmp( "ldap://", p, 6 )) + break; + else + continue; + case SDBCAddress::Unknown: + break; + } + for (s = e_source_group_peek_sources (E_SOURCE_GROUP (g->data)); s; s = s->next) + { + ESource *pSource = E_SOURCE (s->data); + + rtl::OUString aName = rtl::OStringToOUString( e_source_peek_name( pSource ), + RTL_TEXTENCODING_UTF8 ); + + ODatabaseMetaDataResultSet::ORow aRow(3); + aRow.reserve(6); + aRow.push_back(new ORowSetValueDecorator(aName)); + aRow.push_back(new ORowSetValueDecorator(aTable)); + aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); + aRows.push_back(aRow); + } + } } - g_slist_free_full (pSources, g_object_unref); pResult->setRows(aRows); return xRef; |