diff options
Diffstat (limited to 'connectivity')
11 files changed, 90 insertions, 271 deletions
diff --git a/connectivity/source/drivers/evoab2/EApi.cxx b/connectivity/source/drivers/evoab2/EApi.cxx index 56a957fabb63..e5ce60e659e6 100644 --- a/connectivity/source/drivers/evoab2/EApi.cxx +++ b/connectivity/source/drivers/evoab2/EApi.cxx @@ -23,16 +23,7 @@ static const char *eBookLibNames[] = { "libebook-1.2.so.20", // evolution-data-server 3.33.2+ "libebook-1.2.so.19", // evolution-data-server 3.24+ - "libebook-1.2.so.16", - "libebook-1.2.so.15", - "libebook-1.2.so.14", // bumped again (evolution-3.6) - "libebook-1.2.so.13", // bumped again (evolution-3.4) - "libebook-1.2.so.12", // bumped again - "libebook-1.2.so.10", // bumped again - "libebook-1.2.so.9", // evolution-2.8 - "libebook-1.2.so.5", // evolution-2.4 and 2.6+ - "libebook-1.2.so.3", // evolution-2.2 - "libebook.so.8" // evolution-2.0 + "libebook-1.2.so.16" }; typedef void (*SymbolFunc) (); @@ -71,20 +62,6 @@ const ApiMap aCommonApiMap[] = SYM_MAP( e_book_query_field_exists ) }; -//< 3.6 api -const ApiMap aOldApiMap[] = -{ - SYM_MAP( e_book_get_addressbooks ), - SYM_MAP( e_book_get_uri ), - SYM_MAP( e_book_authenticate_user ), - SYM_MAP( e_source_group_peek_base_uri), - SYM_MAP( e_source_peek_name ), - SYM_MAP( e_source_get_property ), - SYM_MAP( e_source_list_peek_groups ), - SYM_MAP( e_source_group_peek_sources ) -}; - -//>= 3.6 api const ApiMap aNewApiMap[] = { SYM_MAP( e_source_registry_list_sources ), @@ -101,12 +78,6 @@ const ApiMap aNewApiMap[] = SYM_MAP( e_client_util_free_object_slist ) }; -//== indirect read access (3.6 only) -const ApiMap aClientApiMap36[] = -{ - SYM_MAP( e_book_client_new ) -}; - //>= direct read access API (>= 3.8) const ApiMap aClientApiMap38[] = { @@ -144,33 +115,14 @@ bool EApiInit() if (tryLink( aModule, eBookLibNames[ j ], aCommonApiMap)) { - if (eds_check_version( 3, 6, 0 ) != nullptr) + if (tryLink( aModule, eBookLibNames[ j ], aNewApiMap)) { - if (tryLink( aModule, eBookLibNames[ j ], aOldApiMap)) + if (tryLink( aModule, eBookLibNames[ j ], aClientApiMap38)) { aModule.release(); return true; } } - else if (tryLink( aModule, eBookLibNames[ j ], aNewApiMap)) - { - if (eds_check_version( 3, 7, 6 ) != nullptr) - { - if (tryLink( aModule, eBookLibNames[ j ], aClientApiMap36)) - { - aModule.release(); - return true; - } - } - else - { - if (tryLink( aModule, eBookLibNames[ j ], aClientApiMap38)) - { - aModule.release(); - return true; - } - } - } } } fprintf( stderr, "Can find no compliant libebook client libraries\n" ); diff --git a/connectivity/source/drivers/evoab2/EApi.h b/connectivity/source/drivers/evoab2/EApi.h index 4d17922aab30..9a2138eb2a26 100644 --- a/connectivity/source/drivers/evoab2/EApi.h +++ b/connectivity/source/drivers/evoab2/EApi.h @@ -146,7 +146,7 @@ EAPI_EXTERN const gchar* (*eds_check_version) (guint required_major, guint requi EAPI_EXTERN const gchar* (*e_source_get_uid) (ESource *source); EAPI_EXTERN ESource* (*e_source_registry_ref_source) (ESourceRegistry *registry, const gchar *uid); EAPI_EXTERN EBookClient* (*e_book_client_new) (ESource *source, GError **error); -EAPI_EXTERN EBookClient* (*e_book_client_connect_direct_sync) (ESourceRegistry *registry, ESource *source, GCancellable *cancellable, GError **error); +EAPI_EXTERN EBookClient* (*e_book_client_connect_direct_sync) (ESourceRegistry *registry, ESource *source, guint32 wait_for_connected_seconds, GCancellable *cancellable, GError **error); EAPI_EXTERN gboolean (*e_client_open_sync) (EClient *client, gboolean only_if_exists, GCancellable *cancellable, GError **error); EAPI_EXTERN ESource* (*e_client_get_source) (EClient *client); EAPI_EXTERN gboolean (*e_book_client_get_contacts_sync) (EBookClient *client, const gchar *sexp, GSList **contacts, GCancellable *cancellable, GError **error); diff --git a/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx b/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx index 6c798e5a166c..6b6ff6553b53 100644 --- a/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx +++ b/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx @@ -989,7 +989,7 @@ Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTableTypes( ) // here we fill the rows which should be visible when ask for data from the resultset returned here auto nNbTypes = SAL_N_ELEMENTS(sTableTypes); - ODatabaseMetaDataResultSet::ORows aRows(nNbTypes); + ODatabaseMetaDataResultSet::ORows aRows; for(std::size_t i=0;i < nNbTypes;++i) { // bound row @@ -1010,7 +1010,7 @@ Reference< XResultSet > OEvoabDatabaseMetaData::impl_getTypeInfo_throw( ) static ODatabaseMetaDataResultSet::ORows aRows = []() { - ODatabaseMetaDataResultSet::ORows tmp(2); + ODatabaseMetaDataResultSet::ORows tmp; ODatabaseMetaDataResultSet::ORow aRow { ODatabaseMetaDataResultSet::getEmptyValue() , @@ -1102,105 +1102,50 @@ Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTables( ODatabaseMetaDataResultSet::ORows aRows; - if (eds_check_version(3, 6, 0) == nullptr) - { - GList *pSources = e_source_registry_list_sources(get_e_source_registry(), E_SOURCE_EXTENSION_ADDRESS_BOOK); - - 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; - - OUString aHumanName = OStringToOUString( e_source_get_display_name( pSource ), - RTL_TEXTENCODING_UTF8 ); - OUString aUID = OStringToOUString( e_source_get_uid( pSource ), - RTL_TEXTENCODING_UTF8 ); - ODatabaseMetaDataResultSet::ORow aRow{ - ORowSetValueDecoratorRef(), - ORowSetValueDecoratorRef(), - ORowSetValueDecoratorRef(), - new ORowSetValueDecorator(aHumanName), //tablename - new ORowSetValueDecorator(ORowSetValue(aTable)), - new ORowSetValueDecorator(aUID)}; //comment - //I'd prefer to swap the comment and the human name and - //just use e_source_registry_ref_source(get_e_source_registry(), aUID); - //in open book rather than search for the name again - aRows.push_back(aRow); - } + GList *pSources = e_source_registry_list_sources(get_e_source_registry(), E_SOURCE_EXTENSION_ADDRESS_BOOK); - g_list_foreach (pSources, reinterpret_cast<GFunc>(g_object_unref), nullptr); - g_list_free (pSources); - } - else + for (GList* liter = pSources; liter; liter = liter->next) { - ESourceList *pSourceList; - if( !e_book_get_addressbooks (&pSourceList, nullptr) ) - pSourceList = nullptr; - - GSList *g; - for( g = e_source_list_peek_groups( pSourceList ); g; g = g->next) + ESource *pSource = E_SOURCE (liter->data); + bool can = false; + switch (m_pConnection->getSDBCAddressType()) { - 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; + 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: + can = true; break; - } - for (s = e_source_group_peek_sources (E_SOURCE_GROUP (g->data)); s; s = s->next) - { - ESource *pSource = E_SOURCE (s->data); - - OUString aName = OStringToOUString( e_source_peek_name( pSource ), - RTL_TEXTENCODING_UTF8 ); - - aRows.push_back( - { - ORowSetValueDecoratorRef(), - ORowSetValueDecoratorRef(), - ORowSetValueDecoratorRef(), - new ORowSetValueDecorator(aName), - new ORowSetValueDecorator(ORowSetValue(aTable)), - ODatabaseMetaDataResultSet::getEmptyValue() - } - ); - } } + if (!can) + continue; + + OUString aHumanName = OStringToOUString( e_source_get_display_name( pSource ), + RTL_TEXTENCODING_UTF8 ); + OUString aUID = OStringToOUString( e_source_get_uid( pSource ), + RTL_TEXTENCODING_UTF8 ); + ODatabaseMetaDataResultSet::ORow aRow{ + ORowSetValueDecoratorRef(), + ORowSetValueDecoratorRef(), + ORowSetValueDecoratorRef(), + new ORowSetValueDecorator(aHumanName), //tablename + new ORowSetValueDecorator(ORowSetValue(aTable)), + new ORowSetValueDecorator(aUID)}; //comment + //I'd prefer to swap the comment and the human name and + //just use e_source_registry_ref_source(get_e_source_registry(), aUID); + //in open book rather than search for the name again + aRows.push_back(aRow); } + g_list_foreach (pSources, reinterpret_cast<GFunc>(g_object_unref), nullptr); + g_list_free (pSources); + pResult->setRows(aRows); return pResult; diff --git a/connectivity/source/drivers/evoab2/NResultSet.cxx b/connectivity/source/drivers/evoab2/NResultSet.cxx index 9c9e1f302a05..fffe281a0bf8 100644 --- a/connectivity/source/drivers/evoab2/NResultSet.cxx +++ b/connectivity/source/drivers/evoab2/NResultSet.cxx @@ -476,123 +476,7 @@ class OEvoabVersion38Helper : public OEvoabVersion36Helper protected: virtual EBookClient * createClient( ESource *pSource ) override { - return e_book_client_connect_direct_sync (get_e_source_registry (), pSource, nullptr, nullptr); - } -}; - -ESource * findSource( const char *id ) -{ - ESourceList *pSourceList = nullptr; - - g_return_val_if_fail (id != nullptr, nullptr); - - if (!e_book_get_addressbooks (&pSourceList, nullptr)) - pSourceList = nullptr; - - for ( GSList *g = e_source_list_peek_groups (pSourceList); g; g = g->next) - { - for (GSList *s = e_source_group_peek_sources (E_SOURCE_GROUP (g->data)); s; s = s->next) - { - ESource *pSource = E_SOURCE (s->data); - if (!strcmp (e_source_peek_name (pSource), id)) - return pSource; - } - } - return nullptr; -} - -bool isAuthRequired( EBook *pBook ) -{ - return e_source_get_property( e_book_get_source( pBook ), - "auth" ) != nullptr; -} - -class OEvoabVersion35Helper : public OEvoabVersionHelper -{ -private: - GList *m_pContacts; - -public: - OEvoabVersion35Helper() - : m_pContacts(nullptr) - { - } - - virtual ~OEvoabVersion35Helper() override - { - freeContacts(); - } - - virtual EBook* openBook(const char *abname) override - { - ESource *pSource = findSource (abname); - EBook *pBook = pSource ? e_book_new (pSource, nullptr) : nullptr; - if (pBook && !e_book_open (pBook, true, nullptr)) - { - g_object_unref (G_OBJECT (pBook)); - pBook = nullptr; - } - return pBook; - } - - virtual bool isLDAP( EBook *pBook ) override - { - return pBook && !strncmp( "ldap://", e_book_get_uri( pBook ), 6 ); - } - - virtual bool isLocal( EBook *pBook ) override - { - return pBook && ( !strncmp( "file://", e_book_get_uri( pBook ), 6 ) || - !strncmp( "local:", e_book_get_uri( pBook ), 6 ) ); - } - - virtual void freeContacts() override final - { - g_list_free(m_pContacts); - m_pContacts = nullptr; - } - - virtual void executeQuery (EBook* pBook, EBookQuery* pQuery, OString &rPassword) override - { - freeContacts(); - - ESource *pSource = e_book_get_source( pBook ); - bool bAuthSuccess = true; - - if( isAuthRequired( pBook ) ) - { - OString aUser( getUserName( pBook ) ); - const char *pAuth = e_source_get_property( pSource, "auth" ); - bAuthSuccess = e_book_authenticate_user( pBook, aUser.getStr(), rPassword.getStr(), pAuth, nullptr ); - } - - if (bAuthSuccess) - e_book_get_contacts( pBook, pQuery, &m_pContacts, nullptr ); - } - - virtual EContact *getContact(sal_Int32 nIndex) override - { - gpointer pData = g_list_nth_data (m_pContacts, nIndex); - return pData ? E_CONTACT (pData) : nullptr; - } - - virtual sal_Int32 getNumContacts() override - { - return g_list_length( m_pContacts ); - } - - virtual bool hasContacts() override - { - return m_pContacts != nullptr; - } - - virtual void sortContacts( const ComparisonData& _rCompData ) override - { - OSL_ENSURE( !_rCompData.rSortOrder.empty(), "sortContacts: no need to call this without any sort order!" ); - ENSURE_OR_THROW( _rCompData.aIntlWrapper.getCaseCollator(), "no collator for comparing strings" ); - - m_pContacts = g_list_sort_with_data( m_pContacts, &CompareContacts, - const_cast< gpointer >( static_cast< gconstpointer >( &_rCompData ) ) ); + return e_book_client_connect_direct_sync (get_e_source_registry (), pSource, 10, nullptr, nullptr); } }; @@ -611,12 +495,7 @@ OEvoabResultSet::OEvoabResultSet( OCommonStatement* pStmt, OEvoabConnection *pCo ,m_nIndex(-1) ,m_nLength(0) { - if (eds_check_version( 3, 7, 6 ) == nullptr) - m_pVersionHelper = std::make_unique<OEvoabVersion38Helper>(); - else if (eds_check_version( 3, 6, 0 ) == nullptr) - m_pVersionHelper = std::make_unique<OEvoabVersion36Helper>(); - else - m_pVersionHelper = std::make_unique<OEvoabVersion35Helper>(); + m_pVersionHelper = std::make_unique<OEvoabVersion38Helper>(); #define REGISTER_PROP( id, member ) \ registerProperty( \ diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx index 3b5511518957..db49ad2e4d8d 100644 --- a/connectivity/source/drivers/firebird/PreparedStatement.cxx +++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx @@ -264,6 +264,12 @@ void SAL_CALL OPreparedStatement::setString(sal_Int32 nParameterIndex, setBoolean(nParameterIndex, boolValue); break; } + case SQL_NULL: + { + // See https://www.firebirdsql.org/file/documentation/html/en/refdocs/fblangref25/firebird-25-language-reference.html#fblangref25-datatypes-special-sqlnull + pVar->sqldata = nullptr; + break; + } default: ::dbtools::throwSQLException( "Incorrect type for setString", diff --git a/connectivity/source/drivers/firebird/Util.cxx b/connectivity/source/drivers/firebird/Util.cxx index 6cc70b4270f4..2d8d6b80a888 100644 --- a/connectivity/source/drivers/firebird/Util.cxx +++ b/connectivity/source/drivers/firebird/Util.cxx @@ -342,8 +342,9 @@ void firebird::mallocSQLVAR(XSQLDA* pSqlda) case SQL_BOOLEAN: pVar->sqldata = static_cast<char *>(malloc(sizeof(sal_Bool))); break; + // See https://www.firebirdsql.org/file/documentation/html/en/refdocs/fblangref25/firebird-25-language-reference.html#fblangref25-datatypes-special-sqlnull case SQL_NULL: - assert(false); // TODO: implement + pVar->sqldata = nullptr; break; case SQL_QUAD: assert(false); // TODO: implement @@ -388,7 +389,8 @@ void firebird::freeSQLVAR(XSQLDA* pSqlda) } break; case SQL_NULL: - assert(false); // TODO: implement + // See SQL_NULL case in mallocSQLVAR + assert(pVar->sqldata == nullptr); break; case SQL_QUAD: assert(false); // TODO: implement diff --git a/connectivity/source/drivers/flat/EDatabaseMetaData.cxx b/connectivity/source/drivers/flat/EDatabaseMetaData.cxx index 0170c67ed3b0..d166ba58b304 100644 --- a/connectivity/source/drivers/flat/EDatabaseMetaData.cxx +++ b/connectivity/source/drivers/flat/EDatabaseMetaData.cxx @@ -53,7 +53,7 @@ Reference< XResultSet > OFlatDatabaseMetaData::impl_getTypeInfo_throw( ) static ODatabaseMetaDataResultSet::ORows aRows = [&]() { - ODatabaseMetaDataResultSet::ORows tmp(10); + ODatabaseMetaDataResultSet::ORows tmp; ODatabaseMetaDataResultSet::ORow aRow { ODatabaseMetaDataResultSet::getEmptyValue() , diff --git a/connectivity/source/drivers/mysqlc/mysqlc_general.cxx b/connectivity/source/drivers/mysqlc/mysqlc_general.cxx index 878efdc3be24..c56bef962c7d 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_general.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_general.cxx @@ -163,6 +163,9 @@ sal_Int32 mysqlToOOOType(int eType, int charsetnr) noexcept return css::sdbc::DataType::VARCHAR; case MYSQL_TYPE_BLOB: + case MYSQL_TYPE_TINY_BLOB: + case MYSQL_TYPE_MEDIUM_BLOB: + case MYSQL_TYPE_LONG_BLOB: if (charsetnr == 63) return css::sdbc::DataType::LONGVARBINARY; return css::sdbc::DataType::LONGVARCHAR; diff --git a/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx b/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx index 22f5499ea9a2..0c4dba0559d5 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx @@ -106,12 +106,24 @@ bool OPreparedResultSet::fetchResult() } for (sal_Int32 i = 0; i < m_nColumnCount; ++i) { + bool bIsBlobType = false; + switch (m_aFields[i].type) + { + case MYSQL_TYPE_BLOB: + case MYSQL_TYPE_TINY_BLOB: + case MYSQL_TYPE_MEDIUM_BLOB: + case MYSQL_TYPE_LONG_BLOB: + bIsBlobType = true; + break; + default: + bIsBlobType = false; + } m_aMetaData[i].is_null = false; m_aMetaData[i].length = 0l; m_aMetaData[i].error = false; m_aData[i].is_null = &m_aMetaData[i].is_null; - m_aData[i].buffer_length = m_aFields[i].type == MYSQL_TYPE_BLOB ? 0 : m_aFields[i].length; + m_aData[i].buffer_length = bIsBlobType ? 0 : m_aFields[i].length; m_aData[i].length = &m_aMetaData[i].length; m_aData[i].error = &m_aMetaData[i].error; m_aData[i].buffer = nullptr; @@ -303,8 +315,21 @@ template <> OUString OPreparedResultSet::retrieveValue(sal_Int32 column) { // redirect call to the appropriate method if needed // BLOB can be simply read out as string + bool bIsBlobType = false; + switch (m_aFields[column - 1].type) + { + case MYSQL_TYPE_BLOB: + case MYSQL_TYPE_TINY_BLOB: + case MYSQL_TYPE_MEDIUM_BLOB: + case MYSQL_TYPE_LONG_BLOB: + bIsBlobType = true; + break; + default: + bIsBlobType = false; + } + if (getTypeFromMysqlType(m_aFields[column - 1].type) != std::type_index(typeid(OUString)) - && m_aFields[column - 1].type != MYSQL_TYPE_BLOB) + && !bIsBlobType) return getRowSetValue(column); const char* sStr = static_cast<const char*>(m_aData[column - 1].buffer); @@ -341,6 +366,9 @@ ORowSetValue OPreparedResultSet::getRowSetValue(sal_Int32 nColumnIndex) case MYSQL_TYPE_NEWDECIMAL: return getString(nColumnIndex); case MYSQL_TYPE_BLOB: + case MYSQL_TYPE_TINY_BLOB: + case MYSQL_TYPE_MEDIUM_BLOB: + case MYSQL_TYPE_LONG_BLOB: throw SQLException("Column with type BLOB cannot be converted", *this, "22000", 1, Any()); default: diff --git a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx index 8f2021608830..8940d08011d6 100644 --- a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx +++ b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx @@ -1229,7 +1229,7 @@ namespace OUString valueB; a[0] >>= valueA; b[0] >>= valueB; - return compare_schema(valueA, valueB); + return compare_schema(valueA, valueB) < 0; } }; } diff --git a/connectivity/source/inc/java/tools.hxx b/connectivity/source/inc/java/tools.hxx index bc9759fa9a88..44a35ecee3f9 100644 --- a/connectivity/source/inc/java/tools.hxx +++ b/connectivity/source/inc/java/tools.hxx @@ -19,6 +19,10 @@ #pragma once +#include <sal/config.h> + +#include <memory> + #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/uno/Sequence.h> |