diff options
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx | 49 | ||||
-rw-r--r-- | connectivity/source/drivers/evoab2/NResultSet.cxx | 68 |
2 files changed, 55 insertions, 62 deletions
diff --git a/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx b/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx index d0198e5f3040..8d0b8027c0e9 100644 --- a/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx +++ b/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx @@ -1075,6 +1075,15 @@ Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getColumns( return xResultSet; } // ------------------------------------------------------------------------- +static bool isSourceBackend( ESource *pSource, const char *backendname) +{ + if (!pSource || e_source_has_extension (pSource, "Address Book")) // E_SOURCE_EXTENSION_ADDRESS_BOOK + return false; + + gpointer extension = e_source_get_extension (pSource, "Address Book"); // E_SOURCE_EXTENSION_ADDRESS_BOOK + return extension && g_strcmp0 (e_source_backend_get_backend_name (extension), backendname) == 0; +} + Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTables( const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& /*tableNamePattern*/, const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException) @@ -1111,41 +1120,31 @@ Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTables( ODatabaseMetaDataResultSet::ORows aRows; - ESourceList *pSourceList; - if( !e_book_get_addressbooks (&pSourceList, NULL) ) - pSourceList = NULL; + GSList *pSources; + pSources = e_source_registry_list_sources (registry, "Address Book"); // E_SOURCE_EXTENSION_ADDRESS_BOOK - GSList *g; - for( g = e_source_list_peek_groups( pSourceList ); g; g = g->next) + GList *liter; + for( liter = pSources; liter; liter = liter->next) { - GSList *s; - const char *p = e_source_group_peek_base_uri(E_SOURCE_GROUP(g->data)); + ESource *pSource = E_SOURCE (liter->data); + bool can = false; switch (m_pConnection->getSDBCAddressType()) { case SDBCAddress::EVO_GWISE: - if ( !strncmp( "groupwise://", p, 11 )) - break; - else - continue; + can = isSourceBackend( pSource, "groupwise"); // not supported in evo/eds 3.6.x+, somehow + break; case SDBCAddress::EVO_LOCAL: - if ( !strncmp( "file://", p, 6 ) || - !strncmp( "local://", p, 6 ) ) - break; - else - continue; + can = isSourceBackend( pSource, "local"); + break; case SDBCAddress::EVO_LDAP: - if ( !strncmp( "ldap://", p, 6 )) - break; - else - continue; + can = isSourceBackend( pSource, "ldap"); + break; 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 ), + if (can) { + rtl::OUString aName = rtl::OStringToOUString( e_source_get_display_name( pSource ), RTL_TEXTENCODING_UTF8 ); ODatabaseMetaDataResultSet::ORow aRow(3); @@ -1153,10 +1152,12 @@ Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTables( aRow.push_back(new ORowSetValueDecorator(aName)); aRow.push_back(new ORowSetValueDecorator(aTable)); aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); + // add also e_source_get_uid (pSource) aRows.push_back(aRow); } } + g_slist_free_full (pSources, g_object_unref); pResult->setRows(aRows); return xRef; diff --git a/connectivity/source/drivers/evoab2/NResultSet.cxx b/connectivity/source/drivers/evoab2/NResultSet.cxx index 9b220dcd7090..589e58095c31 100644 --- a/connectivity/source/drivers/evoab2/NResultSet.cxx +++ b/connectivity/source/drivers/evoab2/NResultSet.cxx @@ -126,9 +126,11 @@ OEvoabResultSet::~OEvoabResultSet() // ------------------------------------------------------------------------- static ESource * -findSource( const char *name ) +findSource( const char *uid ) { - ESourceList *pSourceList = NULL; + //ideally as + return e_source_registry_ref_source (registry, uid); + /*ESourceList *pSourceList = NULL; g_return_val_if_fail (name != NULL, NULL); @@ -144,51 +146,48 @@ findSource( const char *name ) return pSource; } } - return NULL; + return NULL;*/ } -static EBook * +static EBookClient * openBook( const char *abname ) { ESource *pSource = findSource (abname); - EBook *pBook = NULL; + EBookClient *pBook = NULL; if (pSource) - pBook = e_book_new (pSource, NULL); + pBook = e_book_client_new (pSource, NULL); - if (pBook && !e_book_open (pBook, TRUE, NULL)) + if (pBook && !e_client_open_sync (pBook, TRUE, NULL, NULL)) { g_object_unref (G_OBJECT (pBook)); pBook = NULL; } + if (pSource) + g_object_unref (pSource); + return pBook; } -static bool isLDAP( EBook *pBook ) +static bool isBookBackend( EBookClient *pBook, const char *backendname) { - return pBook && !strncmp( "ldap://", e_book_get_uri( pBook ), 6 ); -} + ESource *pSource = e_client_get_source ((EClient *) pBook); -static bool isLocal( EBook *pBook ) -{ - return pBook && ( !strncmp( "file://", e_book_get_uri( pBook ), 6 ) || - !strncmp( "local:", e_book_get_uri( pBook ), 6 ) ); + if (!pSource || e_source_has_extension (pSource, "Address Book")) // E_SOURCE_EXTENSION_ADDRESS_BOOK + return false; + + gpointer extension = e_source_get_extension (pSource, "Address Book"); // E_SOURCE_EXTENSION_ADDRESS_BOOK + return extension && g_strcmp0 (e_source_backend_get_backend_name (extension), backendname) == 0; } -static bool isAuthRequired( EBook *pBook ) +static bool isLDAP( EBookClient *pBook ) { - return e_source_get_property( e_book_get_source( pBook ), - "auth" ) != NULL; + return pBook && isBookBackend( pBook, "ldap" ); } -static rtl::OString getUserName( EBook *pBook ) +static bool isLocal( EBookClient *pBook ) { - rtl::OString aName; - if( isLDAP( pBook ) ) - aName = e_source_get_property( e_book_get_source( pBook ), "binddn" ); - else - aName = e_source_get_property( e_book_get_source( pBook ), "user" ); - return aName; + return pBook && isBookBackend( pBook, "local" ); } static ::rtl::OUString @@ -210,24 +209,17 @@ valueToBool( GValue& _rValue ) } static bool -executeQuery (EBook* pBook, EBookQuery* pQuery, GList **ppList, +executeQuery (EBookClient* pBook, EBookQuery* pQuery, GList **ppList, rtl::OString &rPassword, GError **pError) { - ESource *pSource = e_book_get_source( pBook ); - bool bSuccess = false; - bool bAuthSuccess = true; + bool bSuccess; + char *sexp; *ppList = NULL; - if( isAuthRequired( pBook ) ) - { - rtl::OString aUser( getUserName( pBook ) ); - const char *pAuth = e_source_get_property( pSource, "auth" ); - bAuthSuccess = e_book_authenticate_user( pBook, aUser.getStr(), rPassword.getStr(), pAuth, pError ); - } - - if (bAuthSuccess) - bSuccess = e_book_get_contacts( pBook, pQuery, ppList, pError ); + sexp = e_book_query_to_string( pQuery ); + bSuccess = e_book_client_get_contacts_sync( pBook, sexp, ppList, pError ); + g_free (sexp); return bSuccess; } @@ -507,7 +499,7 @@ void OEvoabResultSet::construct( const QueryData& _rData ) { ENSURE_OR_THROW( _rData.getQuery(), "internal error: no EBookQuery" ); - EBook *pBook = openBook(::rtl::OUStringToOString(_rData.sTable, RTL_TEXTENCODING_UTF8).getStr()); + EBookClient *pBook = openBook(::rtl::OUStringToOString(_rData.sTable, RTL_TEXTENCODING_UTF8).getStr()); if ( !pBook ) m_pConnection->throwGenericSQLException( STR_CANNOT_OPEN_BOOK, *this ); |