/* -*- 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/. * * 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 .
*/
// OOdbcEnumeration bool OOdbcEnumeration::allocEnv()
{
OSL_ENSURE(isLoaded(), "OOdbcEnumeration::allocEnv: not loaded!"); if (!isLoaded()) returnfalse;
#ifdef HAVE_ODBC_SUPPORT if (m_pImpl->hEnvironment) // nothing to do returntrue;
SQLRETURN nResult = (*reinterpret_cast<TSQLAllocHandle>(m_pAllocHandle))(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &m_pImpl->hEnvironment); if (SQL_SUCCESS != nResult) // can't do anything without environment returnfalse;
void OOdbcEnumeration::getDatasourceNames(std::set<OUString>& _rNames)
{
OSL_ENSURE(isLoaded(), "OOdbcEnumeration::getDatasourceNames: not loaded!"); if (!isLoaded()) return;
if (!allocEnv())
{
OSL_FAIL("OOdbcEnumeration::getDatasourceNames: could not allocate an ODBC environment!"); return;
}
#ifdef HAVE_ODBC_SUPPORT // now that we have an environment collect the data source names
UCHAR szDSN[SQL_MAX_DSN_LENGTH+1];
SWORD pcbDSN;
UCHAR szDescription[1024+1];
SWORD pcbDescription;
SQLRETURN nResult = SQL_SUCCESS;
rtl_TextEncoding nTextEncoding = osl_getThreadTextEncoding();
void disableCallback()
{ // if finished event not posted yet, disable by turning it to a no-op Link
m_aFinishHdl = Link<void*, void>(); if (m_nEventId)
{ // already posted, remove it
Application::RemoveUserEvent(m_nEventId);
m_nEventId = nullptr;
}
}
OOdbcManagement::~OOdbcManagement()
{ // wait for our thread to be finished if ( m_pProcessWait )
m_pProcessWait->join();
}
bool OOdbcManagement::manageDataSources_async()
{
OSL_PRECOND( !isRunning(), "OOdbcManagement::manageDataSources_async: still running from the previous call!" ); if ( isRunning() ) returnfalse;
// this is done in an external process, due to #i78733# // (and note this whole functionality is supported on Windows only, ATM)
OUString sExecutableName( "$BRAND_BASE_DIR/" LIBO_LIBEXEC_FOLDER "/odbcconfig.exe" );
::rtl::Bootstrap::expandMacros( sExecutableName ); //TODO: detect failure
oslProcess hProcessHandle(nullptr);
oslProcessError eError = osl_executeProcess( sExecutableName.pData, nullptr, 0, 0, nullptr, nullptr, nullptr, 0, &hProcessHandle ); if ( eError != osl_Process_E_None ) returnfalse;
m_pProcessWait.reset( new ProcessTerminationWait( hProcessHandle, m_aAsyncFinishCallback ) );
m_pProcessWait->create(); returntrue;
}
void OOdbcManagement::disableCallback()
{ if (m_pProcessWait)
m_pProcessWait->disableCallback();
}
void OOdbcManagement::receivedCallback()
{ if (m_pProcessWait)
m_pProcessWait->receivedCallback();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.