Tag: cws_src680_dba23b User: fs Date: 2007-07-04 10:33:38+0000 Modified: dba/dbaccess/source/ui/dlg/odbcconfig.cxx dba/dbaccess/source/ui/dlg/odbcconfig.hxx
Log: #i78733# managing data sources now done by an external process File Changes: Directory: /dba/dbaccess/source/ui/dlg/ ======================================= File [changed]: odbcconfig.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/dlg/odbcconfig.cxx?r1=1.17&r2=1.17.88.1 Delta lines: +73 -31 --------------------- --- odbcconfig.cxx 2006-10-12 13:37:54+0000 1.17 +++ odbcconfig.cxx 2007-07-04 10:33:35+0000 1.17.88.1 @@ -4,9 +4,9 @@ * * $RCSfile: odbcconfig.cxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.17.88.1 $ * - * last change: $Author: obo $ $Date: 2006/10/12 13:37:54 $ + * last change: $Author: fs $ $Date: 2007/07/04 10:33:35 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -48,9 +48,18 @@ #ifndef _OSL_DIAGNOSE_H_ #include <osl/diagnose.h> #endif +#ifndef _OSL_PROCESS_H_ +#include <osl/process.h> +#endif +#ifndef _THREAD_HXX_ +#include <osl/thread.hxx> +#endif #ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> #endif +#ifndef _SV_SVAPP_HXX +#include <vcl/svapp.hxx> +#endif #ifdef HAVE_ODBC_SUPPORT @@ -277,13 +286,13 @@ //------------------------------------------------------------------------- void OOdbcEnumeration::getDatasourceNames(StringBag& _rNames) { - OSL_ENSURE(isLoaded(), "OOdbcManagement::getDatasourceNames: not loaded!"); + OSL_ENSURE(isLoaded(), "OOdbcEnumeration::getDatasourceNames: not loaded!"); if (!isLoaded()) return; if (!allocEnv()) { - OSL_ENSURE(sal_False, "OOdbcManagement::getDatasourceNames: could not allocate an ODBC environment!"); + OSL_ENSURE(sal_False, "OOdbcEnumeration::getDatasourceNames: could not allocate an ODBC environment!"); return; } @@ -312,44 +321,77 @@ #endif } +#ifdef HAVE_ODBC_ADMINISTRATION + //========================================================================= -//= OOdbcManagement +//= ProcessTerminationWait //========================================================================= -//------------------------------------------------------------------------- -OOdbcManagement::OOdbcManagement() -#ifdef HAVE_ODBC_SUPPORT -:m_pSQLManageDataSource(NULL) -#endif +class ProcessTerminationWait : public ::osl::Thread { - sal_Bool bLoaded = load(ODBC_UI_LIBRARY); -#ifdef ODBC_UI_LIBRARY_1 - if ( !bLoaded ) - bLoaded = load(ODBC_UI_LIBRARY_1); -#endif - if ( bLoaded ) + oslProcess m_hProcessHandle; + Link m_aFinishHdl; + +public: + ProcessTerminationWait( oslProcess _hProcessHandle, const Link& _rFinishHdl ) + :m_hProcessHandle( _hProcessHandle ) + ,m_aFinishHdl( _rFinishHdl ) { -#ifdef HAVE_ODBC_SUPPORT - m_pSQLManageDataSource = loadSymbol("SQLManageDataSources"); - if (!m_pSQLManageDataSource) - unload(); -#endif // HAVE_ODBC_SUPPORT } + +protected: + virtual void SAL_CALL run() + { + osl_joinProcess( m_hProcessHandle ); + Application::PostUserEvent( m_aFinishHdl ); + } +}; + +//========================================================================= +//= OOdbcManagement +//========================================================================= +//------------------------------------------------------------------------- +OOdbcManagement::OOdbcManagement( const Link& _rAsyncFinishCallback ) + :m_pProcessWait( NULL ) + ,m_aAsyncFinishCallback( _rAsyncFinishCallback ) +{ } //------------------------------------------------------------------------- -void OOdbcManagement::manageDataSources(void* _pParentSysWindowHandle) +OOdbcManagement::~OOdbcManagement() { - OSL_ENSURE(isLoaded(), "OOdbcManagement::manageDataSources: not loaded!"); - OSL_ENSURE(_pParentSysWindowHandle, "OOdbcManagement::manageDataSources: invalid parent window!"); - if (!isLoaded()) - return; + // wait for our thread to be finished + if ( m_pProcessWait.get() ) + m_pProcessWait->join(); +} -#ifdef HAVE_ODBC_SUPPORT - NSQLManageDataSource(_pParentSysWindowHandle); -#endif // HAVE_ODBC_SUPPORT +//------------------------------------------------------------------------- +bool OOdbcManagement::manageDataSources_async() +{ + OSL_PRECOND( !isRunning(), "OOdbcManagement::manageDataSources_async: still running from the previous call!" ); + if ( isRunning() ) + return false; + + // this is done in an external process, due to #i78733# + // (and note this whole functionality is supported on Windows only, ATM) + ::rtl::OUString sExecutableName( RTL_CONSTASCII_USTRINGPARAM( "odbcconfig.exe" ) ); + oslProcess hProcessHandle(0); + oslProcessError eError = osl_executeProcess( sExecutableName.pData, NULL, 0, 0, NULL, NULL, NULL, 0, &hProcessHandle ); + if ( eError != osl_Process_E_None ) + return false; + + m_pProcessWait.reset( new ProcessTerminationWait( hProcessHandle, m_aAsyncFinishCallback ) ); + m_pProcessWait->create(); + return true; +} + +//------------------------------------------------------------------------- +bool OOdbcManagement::isRunning() const +{ + return ( m_pProcessWait.get() && m_pProcessWait->isRunning() ); } +#endif HAVE_ODBC_ADMINISTRATION + //......................................................................... } // namespace dbaui //......................................................................... - File [changed]: odbcconfig.hxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/dlg/odbcconfig.hxx?r1=1.6&r2=1.6.152.1 Delta lines: +20 -20 --------------------- --- odbcconfig.hxx 2006-06-20 03:09:04+0000 1.6 +++ odbcconfig.hxx 2007-07-04 10:33:35+0000 1.6.152.1 @@ -4,9 +4,9 @@ * * $RCSfile: odbcconfig.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.6.152.1 $ * - * last change: $Author: hr $ $Date: 2006/06/20 03:09:04 $ + * last change: $Author: fs $ $Date: 2007/07/04 10:33:35 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -36,19 +36,20 @@ #ifndef _DBAUI_ODBC_CONFIG_HXX_ #define _DBAUI_ODBC_CONFIG_HXX_ +#include "commontypes.hxx" + #if defined(WIN) || defined(WNT) || defined (UNX) #define HAVE_ODBC_SUPPORT #endif + #if ( defined(WIN) || defined(WNT) ) && defined(HAVE_ODBC_SUPPORT) #define HAVE_ODBC_ADMINISTRATION #endif -#ifndef _OSL_MODULE_H_ +#include <tools/link.hxx> #include <osl/module.h> -#endif -#ifndef _DBAUI_COMMON_TYPES_HXX_ -#include "commontypes.hxx" -#endif + +#include <memory> //......................................................................... namespace dbaui @@ -122,22 +123,21 @@ //========================================================================= //= OOdbcManagement //========================================================================= -class OOdbcManagement : public OOdbcLibWrapper +#ifdef HAVE_ODBC_ADMINISTRATION +class ProcessTerminationWait; +class OOdbcManagement { -#ifdef HAVE_ODBC_SUPPORT - // entry points for ODBC administration - oslGenericFunction m_pSQLManageDataSource; - oslModule m_pOdbcLib; - - OdbcTypesImpl* m_pImpl; - // needed because we can't have a member of type SQLHANDLE: this would require us to include the respective - // ODBC file, which would lead to a lot of conflicts with other includes -#endif + ::std::auto_ptr< ProcessTerminationWait > m_pProcessWait; + Link m_aAsyncFinishCallback; public: - OOdbcManagement(); - void manageDataSources(void* _pParentSysWindowHandle); + OOdbcManagement( const Link& _rAsyncFinishCallback ); + ~OOdbcManagement(); + + bool manageDataSources_async(); + bool isRunning() const; }; +#endif //......................................................................... } // namespace dbaui --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
