Tag: cws_src680_kabrefine User: fs Date: 06/01/09 01:14:08 Modified: /dba/connectivity/source/drivers/kab/ KDEInit.cxx, KDEInit.h, KDriver.cxx, KDriver.hxx
Log: #i60062# configuration setting determining whether to disable the check for a maximum version File Changes: Directory: /dba/connectivity/source/drivers/kab/ ================================================ File [changed]: KDEInit.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/kab/KDEInit.cxx?r1=1.1.2.6&r2=1.1.2.7 Delta lines: +11 -5 -------------------- --- KDEInit.cxx 6 Jan 2006 15:09:23 -0000 1.1.2.6 +++ KDEInit.cxx 9 Jan 2006 09:14:03 -0000 1.1.2.7 @@ -4,9 +4,9 @@ * * $RCSfile: KDEInit.cxx,v $ * - * $Revision: 1.1.2.6 $ + * $Revision: 1.1.2.7 $ * - * last change: $Author: fs $ $Date: 2006/01/06 15:09:23 $ + * last change: $Author: fs $ $Date: 2006/01/09 09:14:03 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -62,6 +62,7 @@ private: /// KDE application if we own it static KApplication* s_pKApplication; + static bool s_bDidInsertCatalogue; public: static void Init(); @@ -70,6 +71,7 @@ // --------------------------------------------------------------- KApplication* KDEInit::s_pKApplication = NULL; + bool KDEInit::s_bDidInsertCatalogue = false; // --------------------------------------------------------------- void KDEInit::Init() @@ -99,11 +101,15 @@ // load KDE address book's localized messages KGlobal::locale()->insertCatalogue("kaddressbook"); + s_bDidInsertCatalogue = true; } // --------------------------------------------------------------- void KDEInit::Shutdown() { + if ( s_bDidInsertCatalogue ) + // this guard is necessary, since KDE 3.3 seems to crash if we remove a catalogue + // which we did not previously insert KGlobal::locale()->removeCatalogue("kaddressbook"); if ( s_pKApplication != NULL ) File [changed]: KDEInit.h Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/kab/KDEInit.h?r1=1.1.2.4&r2=1.1.2.5 Delta lines: +3 -3 ------------------- --- KDEInit.h 6 Jan 2006 15:09:24 -0000 1.1.2.4 +++ KDEInit.h 9 Jan 2006 09:14:04 -0000 1.1.2.5 @@ -4,9 +4,9 @@ * * $RCSfile: KDEInit.h,v $ * - * $Revision: 1.1.2.4 $ + * $Revision: 1.1.2.5 $ * - * last change: $Author: fs $ $Date: 2006/01/06 15:09:24 $ + * last change: $Author: fs $ $Date: 2006/01/09 09:14:04 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -41,7 +41,7 @@ #define MIN_KDE_VERSION_MINOR 2 #define MAX_KDE_VERSION_MAJOR 3 -#define MAX_KDE_VERSION_MINOR 5 +#define MAX_KDE_VERSION_MINOR 6 #endif // CONNECTIVITY_KAB_KDEINIT_H File [changed]: KDriver.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/kab/KDriver.cxx?r1=1.2.10.5&r2=1.2.10.6 Delta lines: +115 -26 ---------------------- --- KDriver.cxx 6 Jan 2006 15:16:46 -0000 1.2.10.5 +++ KDriver.cxx 9 Jan 2006 09:14:04 -0000 1.2.10.6 @@ -4,9 +4,9 @@ * * $RCSfile: KDriver.cxx,v $ * - * $Revision: 1.2.10.5 $ + * $Revision: 1.2.10.6 $ * - * last change: $Author: fs $ $Date: 2006/01/06 15:16:46 $ + * last change: $Author: fs $ $Date: 2006/01/09 09:14:04 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -38,17 +38,27 @@ #ifndef CONNECTIVITY_KAB_KDEINIT_H #include "KDEInit.h" #endif - #ifndef _CONNECTIVITY_KAB_CONNECTION_HXX_ #include "KConnection.hxx" #endif +/** === begin UNO includes === **/ +#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_ +#include <com/sun/star/sdb/SQLContext.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_NULLPOINTEREXCEPTION_HPP_ +#include <com/sun/star/lang/NullPointerException.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XDESKTOP_HPP_ +#include <com/sun/star/frame/XDesktop.hpp> +#endif +/** === end UNO includes === **/ + #ifndef _RTL_USTRBUF_HXX_ #include <rtl/ustrbuf.hxx> #endif - -#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_ -#include <com/sun/star/sdb/SQLContext.hpp> +#ifndef TOOLS_DIAGNOSE_EX_H +#include <tools/diagnose_ex.h> #endif using namespace com::sun::star::uno; @@ -56,14 +66,16 @@ using namespace com::sun::star::beans; using namespace com::sun::star::sdbc; using namespace com::sun::star::sdb; +using namespace com::sun::star::frame; using namespace connectivity::kab; // ======================================================================= // = KabImplModule // ======================================================================= // -------------------------------------------------------------------------------- -KabImplModule::KabImplModule() - :m_hConnectorModule(NULL) +KabImplModule::KabImplModule( const Reference< XMultiServiceFactory >& _rxFactory ) + :m_xORB(_rxFactory) + ,m_hConnectorModule(NULL) ,m_bAttemptedLoadModule(false) ,m_bAttemptedInitialize(false) ,m_pConnectionFactoryFunc(NULL) @@ -71,6 +83,8 @@ ,m_pApplicationShutdownFunc(NULL) ,m_pKDEVersionCheckFunc(NULL) { + if ( !m_xORB.is() ) + throw NullPointerException(); } // -------------------------------------------------------------------------------- @@ -83,9 +97,9 @@ } // -------------------------------------------------------------------------------- -KabImplModule::KDEVersionType KabImplModule::isKDEVersionSupported() +KabImplModule::KDEVersionType KabImplModule::matchKDEVersion() { - OSL_PRECOND( m_pKDEVersionCheckFunc, "KabImplModule::isKDEVersionSupported: module not loaded!" ); + OSL_PRECOND( m_pKDEVersionCheckFunc, "KabImplModule::matchKDEVersion: module not loaded!" ); int nVersionInfo = (*m_pKDEVersionCheckFunc)(); if ( nVersionInfo < 0 ) @@ -169,7 +183,7 @@ impl_throwNoKdeException(); // if we're not running on a supported version, throw - KabImplModule::KDEVersionType eKDEVersion= isKDEVersionSupported(); + KabImplModule::KDEVersionType eKDEVersion = matchKDEVersion(); if ( eKDEVersion == eTooOld ) impl_throwKdeTooOldException(); @@ -187,7 +201,33 @@ // -------------------------------------------------------------------------------- bool KabImplModule::impl_doAllowNewKDEVersion() { - // TODO + try + { + Reference< XMultiServiceFactory > xConfigProvider( + m_xORB->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ) ), + UNO_QUERY_THROW ); + Sequence< Any > aCreationArgs(1); + aCreationArgs[0] <<= PropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) ), + 0, + makeAny( KabDriver::impl_getConfigurationSettingsPath() ), + PropertyState_DIRECT_VALUE ); + Reference< XPropertySet > xSettings( xConfigProvider->createInstanceWithArguments( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationAccess" ) ), + aCreationArgs ), + UNO_QUERY_THROW ); + + sal_Bool bDisableCheck = sal_False; + xSettings->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableKDEMaximumVersionCheck" ) ) ) >>= bDisableCheck; + + fprintf( stderr, "---- disable: %i", (int)bDisableCheck ); + fflush( stderr ); + return bDisableCheck != sal_False; + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } return false; } @@ -238,7 +278,19 @@ SQLContext aDetails; aMessage.appendAscii( "If you are sure that your KDE version works, " ); aMessage.appendAscii( "you might execute the following Basic macro to disable this version check:\n\n" ); - aMessage.appendAscii( "\n\n---- TODO ----" ); + + aMessage.appendAscii( "Sub disableKDEMaxVersionCheck\n" ); + aMessage.appendAscii( " BasicLibraries.LoadLibrary( \"Tools\" )\n" ); + + aMessage.appendAscii( " Dim configNode as Object\n" ); + aMessage.appendAscii( " configNode = GetRegistryKeyContent( \"" ); + aMessage.append( KabDriver::impl_getConfigurationSettingsPath() ); + aMessage.appendAscii( "\", true )\n" ); + + aMessage.appendAscii( " configNode.DisableKDEMaximumVersionCheck = TRUE\n" ); + aMessage.appendAscii( " configNode.commitChanges\n" ); + aMessage.appendAscii( "End Sub\n" ); + aDetails.Message = aMessage.makeStringAndClear(); aError.NextException <<= aDetails; @@ -276,8 +328,25 @@ KabDriver::KabDriver( const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) : KDriver_BASE(m_aMutex), - m_xMSFactory(_rxFactory) + m_xMSFactory(_rxFactory), + m_aImplModule(_rxFactory) { + if ( !m_xMSFactory.is() ) + throw NullPointerException(); + + osl_incrementInterlockedCount( &m_refCount ); + try + { + Reference< XDesktop > xDesktop( + m_xMSFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ) ), + UNO_QUERY_THROW ); + xDesktop->addTerminateListener( this ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + osl_decrementInterlockedCount( &m_refCount ); } // -------------------------------------------------------------------------------- void KabDriver::disposing() @@ -293,23 +362,13 @@ } m_xConnections.clear(); - KDriver_BASE::disposing(); - - // m_aImplModule.shutdown(); - // do not do this. Since a css.sdbc.Driver is a singleton class, it is disposed when the - // whole process terminates. At this point in time, we cannot reliably know the state of - // the KApplication. In particular, other libraries which the KApplication relies on might - // already have been unloaded. - // Not doing the shutdown at this point should not have side effects: Since we only come - // to here when OOo is shutting down itself, it doesn't matter ... + WeakComponentImplHelperBase::disposing(); } // static ServiceInfo //------------------------------------------------------------------------------ rtl::OUString KabDriver::getImplementationName_Static( ) throw(RuntimeException) { - return rtl::OUString::createFromAscii("com.sun.star.comp.sdbc.kab.Driver"); - // this name is referenced in the configuration and in the kab.xml - // Please be careful when changing it. + return rtl::OUString::createFromAscii( impl_getAsciiImplementationName() ); } //------------------------------------------------------------------------------ Sequence< ::rtl::OUString > KabDriver::getSupportedServiceNames_Static( ) throw (RuntimeException) @@ -394,6 +453,36 @@ { // version 0.1 return 1; +} +// -------------------------------------------------------------------------------- +void SAL_CALL KabDriver::queryTermination( const EventObject& Event ) throw (TerminationVetoException, RuntimeException) +{ + // nothing to do, nothing to veto +} +// -------------------------------------------------------------------------------- +void SAL_CALL KabDriver::notifyTermination( const EventObject& Event ) throw (RuntimeException) +{ + m_aImplModule.shutdown(); +} +// -------------------------------------------------------------------------------- +void SAL_CALL KabDriver::disposing( const EventObject& Source ) throw (RuntimeException) +{ + // not interested in (this is the disposing of the desktop, if any) +} +// -------------------------------------------------------------------------------- +const sal_Char* KabDriver::impl_getAsciiImplementationName() +{ + return "com.sun.star.comp.sdbc.kab.Driver"; + // this name is referenced in the configuration and in the kab.xml + // Please be careful when changing it. +} +// -------------------------------------------------------------------------------- +::rtl::OUString KabDriver::impl_getConfigurationSettingsPath() +{ + ::rtl::OUStringBuffer aPath; + aPath.appendAscii( "/org.openoffice.Office.DataAccess/DriverSettings/" ); + aPath.appendAscii( "com.sun.star.comp.sdbc.kab.Driver" ); + return aPath.makeStringAndClear(); } // -------------------------------------------------------------------------------- Reference< XInterface > SAL_CALL KabDriver::Create( const Reference< XMultiServiceFactory >& _rxFactory ) throw( Exception ) File [changed]: KDriver.hxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/kab/KDriver.hxx?r1=1.2.10.4&r2=1.2.10.5 Delta lines: +33 -9 -------------------- --- KDriver.hxx 6 Jan 2006 15:09:24 -0000 1.2.10.4 +++ KDriver.hxx 9 Jan 2006 09:14:05 -0000 1.2.10.5 @@ -4,9 +4,9 @@ * * $RCSfile: KDriver.hxx,v $ * - * $Revision: 1.2.10.4 $ + * $Revision: 1.2.10.5 $ * - * last change: $Author: fs $ $Date: 2006/01/06 15:09:24 $ + * last change: $Author: fs $ $Date: 2006/01/09 09:14:05 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -36,15 +36,20 @@ #ifndef _CONNECTIVITY_KAB_DRIVER_HXX_ #define _CONNECTIVITY_KAB_DRIVER_HXX_ +/** === begin UNO includes === **/ #ifndef _COM_SUN_STAR_SDBC_XDRIVER_HPP_ #include <com/sun/star/sdbc/XDriver.hpp> #endif #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ #include <com/sun/star/lang/XServiceInfo.hpp> #endif +#ifndef _COM_SUN_STAR_FRAME_XTERMINATELISTENER_HPP_ +#include <com/sun/star/frame/XTerminateListener.hpp> +#endif +/** === end UNO includes === **/ -#ifndef _CPPUHELPER_COMPBASE2_HXX_ -#include <cppuhelper/compbase2.hxx> +#ifndef _CPPUHELPER_COMPBASE3_HXX_ +#include <cppuhelper/compbase3.hxx> #endif #ifndef _OSL_MODULE_H_ @@ -71,6 +76,9 @@ class KabImplModule { private: + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > + m_xORB; + /// Did we already attempt to load the module and to retrieve the symbols? bool m_bAttemptedLoadModule; /// Did we already check the KDE version and initialize the impl module (or at least attempted to)? @@ -83,7 +91,7 @@ KDEVersionCheckFunction m_pKDEVersionCheckFunc; public: - KabImplModule(); + KabImplModule( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory ); /** determines whether there is a KDE present in the environment */ @@ -99,7 +107,7 @@ @precond the module is loaded, i.e impl_loadModule has successfully been called */ - KDEVersionType isKDEVersionSupported(); + KDEVersionType matchKDEVersion(); /** initializes the implementation module. @@ -163,8 +171,9 @@ // =============================================================== // = KabDriver // =============================================================== - typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::sdbc::XDriver, - ::com::sun::star::lang::XServiceInfo > KDriver_BASE; + typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XDriver, + ::com::sun::star::lang::XServiceInfo, + ::com::sun::star::frame::XTerminateListener > KDriver_BASE; class KabDriver : public KDriver_BASE { protected: @@ -185,6 +194,14 @@ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& getMSFactory() const { return m_xMSFactory; } + /** returns the driver's implementation name (being pure ASCII) for reference in various places + */ + static const sal_Char* impl_getAsciiImplementationName(); + + /** returns the path of our configuration settings + */ + static ::rtl::OUString impl_getConfigurationSettingsPath(); + protected: KabDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory); @@ -202,6 +219,13 @@ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual sal_Int32 SAL_CALL getMajorVersion() throw(::com::sun::star::uno::RuntimeException); virtual sal_Int32 SAL_CALL getMinorVersion() throw(::com::sun::star::uno::RuntimeException); + + // XTerminateListener + virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException); + + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); private: /** shuts down the library which contains the real implementations --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
