From 38666b34948f5ba0ab4c9b08aadc96461b7894cb Mon Sep 17 00:00:00 2001 From: Kurt Zenker Date: Tue, 24 Feb 2009 14:03:07 +0000 Subject: CWS-TOOLING: integrate CWS tkr18_OOO310 2009-01-27 19:56:17 +0100 tkr r267017 : #i98521# remove -fast switch for solaris build 2009-01-23 07:44:53 +0100 tkr r266766 : #i98223# cought exception while loading gvfs ucp 2009-01-16 16:32:58 +0100 kso r266434 : i98053# - support for XInteractionHandler2n 2009-01-16 16:29:41 +0100 kso r266433 : i98053# - new interface: XInteractionHandler2 2009-01-14 12:48:17 +0100 tkr r266288 : #i98053# install new configuation file for InteractionHandler 2009-01-14 08:16:57 +0100 tkr r266264 : #i98053# new configuation file for InteractionHandler 2009-01-14 08:14:20 +0100 tkr r266263 : #i98053# deligate InteractionHandlerRequest if office cannot handle it --- desktop/source/app/appinit.cxx | 58 +++--- .../org/openoffice/ucb/InteractionHandler.xcs | 67 ++++++ .../registry/schema/org/openoffice/ucb/makefile.mk | 1 + uui/source/iahndl.cxx | 228 +++++++++++++++++---- uui/source/iahndl.hxx | 26 ++- 5 files changed, 312 insertions(+), 68 deletions(-) create mode 100644 officecfg/registry/schema/org/openoffice/ucb/InteractionHandler.xcs diff --git a/desktop/source/app/appinit.cxx b/desktop/source/app/appinit.cxx index 768d033ac1..a477eb2ad4 100644 --- a/desktop/source/app/appinit.cxx +++ b/desktop/source/app/appinit.cxx @@ -154,21 +154,26 @@ static bool configureUcb(bool bServer, rtl::OUString const & rPortalConnect) Reference xCPM = cb->getContentProviderManagerInterface(); #if 0 + try + { - Reference xCPF( - xServiceFactory->createInstance( - rtl::OUString::createFromAscii( - "com.sun.star.ucb.ContentProviderProxyFactory")), - UNO_QUERY); - if(xCPF.is()) - xCPM->registerContentProvider( - xCPF->createContentProvider( + Reference xCPF( + xServiceFactory->createInstance( rtl::OUString::createFromAscii( - "com.sun.star.ucb.GnomeVFSContentProvider" - ) - ), - rtl::OUString::createFromAscii(".*"), - false); + "com.sun.star.ucb.ContentProviderProxyFactory")), + UNO_QUERY); + if(xCPF.is()) + xCPM->registerContentProvider( + xCPF->createContentProvider( + rtl::OUString::createFromAscii( + "com.sun.star.ucb.GnomeVFSContentProvider" + ) + ), + rtl::OUString::createFromAscii(".*"), + false); + } catch (...) + { + } #else // Workaround for P1 #124597#. Instanciate GNOME-VFS-UCP in the thread that initialized @@ -176,18 +181,23 @@ static bool configureUcb(bool bServer, rtl::OUString const & rPortalConnect) // a different thread. The latter may happen when calling the Office remotely via UNO. // THIS IS NOT A FIX, JUST A WORKAROUND! - Reference xCP( - xServiceFactory->createInstance( - rtl::OUString::createFromAscii( - "com.sun.star.ucb.GnomeVFSContentProvider")), - UNO_QUERY); - if(xCP.is()) - xCPM->registerContentProvider( - xCP, - rtl::OUString::createFromAscii(".*"), - false); -#endif + try + { + Reference xCP( + xServiceFactory->createInstance( + rtl::OUString::createFromAscii( + "com.sun.star.ucb.GnomeVFSContentProvider")), + UNO_QUERY); + if(xCP.is()) + xCPM->registerContentProvider( + xCP, + rtl::OUString::createFromAscii(".*"), + false); + } catch (...) + { + } } +#endif } } catch (RuntimeException e) { } diff --git a/officecfg/registry/schema/org/openoffice/ucb/InteractionHandler.xcs b/officecfg/registry/schema/org/openoffice/ucb/InteractionHandler.xcs new file mode 100644 index 0000000000..6cf0a994c8 --- /dev/null +++ b/officecfg/registry/schema/org/openoffice/ucb/InteractionHandler.xcs @@ -0,0 +1,67 @@ + + + + + TKR + Contains components and templates used for InteractionHandler configuration related data. + + + + + Contains the Service name of the custom InteractionHandler. The listed InteractionHandlers will be called after the "build-in" InteractionHandler sequently. + + + + Specifies the name of the UNO service to be used to instantiate the InteractionHandler. The type should be com.sun.star.task.XInteractionHandler. + + + + + + + + Contains a root entry for InteractionHandler configurations. + + + + + + + + + + + + + + + + diff --git a/officecfg/registry/schema/org/openoffice/ucb/makefile.mk b/officecfg/registry/schema/org/openoffice/ucb/makefile.mk index df7b005529..269bdded29 100644 --- a/officecfg/registry/schema/org/openoffice/ucb/makefile.mk +++ b/officecfg/registry/schema/org/openoffice/ucb/makefile.mk @@ -42,6 +42,7 @@ PACKAGE=org.openoffice.ucb XCSFILES= \ Configuration.xcs \ Hierarchy.xcs \ + InteractionHandler.xcs \ Store.xcs .INCLUDE : target.mk diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx index 4110284e29..f98b56750a 100644 --- a/uui/source/iahndl.cxx +++ b/uui/source/iahndl.cxx @@ -40,6 +40,7 @@ #include "com/sun/star/beans/XPropertyAccess.hpp" #include "com/sun/star/configuration/backend/MergeRecoveryRequest.hpp" #include "com/sun/star/configuration/backend/StratumCreationException.hpp" +#include #include "com/sun/star/container/XContainerQuery.hpp" #include "com/sun/star/container/XNameAccess.hpp" #include "com/sun/star/container/XNameContainer.hpp" @@ -59,6 +60,8 @@ #include "com/sun/star/lang/XMultiServiceFactory.hpp" #include "com/sun/star/script/ModuleSizeExceededRequest.hpp" #include "com/sun/star/sync2/BadPartnershipException.hpp" +#include "com/sun/star/task/XInteractionHandler.hpp" +#include "com/sun/star/task/XInteractionHandler2.hpp" #include "com/sun/star/task/DocumentPasswordRequest.hpp" #include "com/sun/star/task/ErrorCodeIOException.hpp" #include "com/sun/star/task/ErrorCodeRequest.hpp" @@ -99,6 +102,7 @@ #include "com/sun/star/xforms/InvalidDataOnSubmitException.hpp" #include + #include "vos/mutex.hxx" #include "tools/rcid.h" #include "vcl/svapp.hxx" @@ -141,6 +145,9 @@ using ::com::sun::star::task::XInteractionApprove; using ::com::sun::star::task::XInteractionAskLater; using ::com::sun::star::task::FutureDocumentVersionProductUpdateRequest; + +#define CONFIG_INTERACTIONHANDLERS_KEY "/org.openoffice.ucb.InteractionHandler/InteractionHandlers" + namespace { class CookieList: public List @@ -526,7 +533,7 @@ UUIInteractionHelper::getStringFromRequest( return getStringFromRequest_impl(rRequest); } -void UUIInteractionHelper::handleMessageboxRequests( +bool UUIInteractionHelper::handleMessageboxRequests( star::uno::Reference< star::task::XInteractionRequest > const & rRequest, bool bObtainErrorStringOnly, bool & bHasErrorString, @@ -560,7 +567,7 @@ void UUIInteractionHelper::handleMessageboxRequests( bObtainErrorStringOnly, bHasErrorString, rErrorString); - return; + return true; } star::ucb::NameClashException aNCException; @@ -582,7 +589,7 @@ void UUIInteractionHelper::handleMessageboxRequests( bObtainErrorStringOnly, bHasErrorString, rErrorString); - return; + return true; } star::ucb::UnsupportedNameClashException aUORequest; @@ -608,7 +615,7 @@ void UUIInteractionHelper::handleMessageboxRequests( bHasErrorString, rErrorString); } - return; + return true; } star::document::BrokenPackageRequest aBrokenPackageRequest; @@ -624,7 +631,7 @@ void UUIInteractionHelper::handleMessageboxRequests( bObtainErrorStringOnly, bHasErrorString, rErrorString); - return; + return true; } star::ucb::InteractiveIOException aIoException; @@ -846,7 +853,7 @@ void UUIInteractionHelper::handleMessageboxRequests( bObtainErrorStringOnly, bHasErrorString, rErrorString); - return; + return true; } star::ucb::InteractiveAppException aAppException; @@ -860,6 +867,7 @@ void UUIInteractionHelper::handleMessageboxRequests( bObtainErrorStringOnly, bHasErrorString, rErrorString); + return true; } star::ucb::InteractiveNetworkException aNetworkException; @@ -905,7 +913,7 @@ void UUIInteractionHelper::handleMessageboxRequests( bObtainErrorStringOnly, bHasErrorString, rErrorString); - return; + return true; } star::ucb::InteractiveCHAOSException aChaosException; @@ -928,7 +936,7 @@ void UUIInteractionHelper::handleMessageboxRequests( bObtainErrorStringOnly, bHasErrorString, rErrorString); - return; + return true; } star::ucb::InteractiveWrongMediumException aWrongMediumException; @@ -945,7 +953,7 @@ void UUIInteractionHelper::handleMessageboxRequests( bObtainErrorStringOnly, bHasErrorString, rErrorString); - return; + return true; } star::java::WrongJavaVersionException aWrongJavaVersionException; @@ -988,7 +996,7 @@ void UUIInteractionHelper::handleMessageboxRequests( bObtainErrorStringOnly, bHasErrorString, rErrorString); - return; + return true; } star::sync2::BadPartnershipException aBadPartnershipException; @@ -1010,7 +1018,7 @@ void UUIInteractionHelper::handleMessageboxRequests( bObtainErrorStringOnly, bHasErrorString, rErrorString); - return; + return true; } star::configuration::backend::MergeRecoveryRequest aMergeRecoveryRequest; @@ -1030,7 +1038,7 @@ void UUIInteractionHelper::handleMessageboxRequests( bObtainErrorStringOnly, bHasErrorString, rErrorString); - return; + return true; } star::configuration::backend::StratumCreationException @@ -1054,7 +1062,7 @@ void UUIInteractionHelper::handleMessageboxRequests( bObtainErrorStringOnly, bHasErrorString, rErrorString); - return; + return true; } star::xforms::InvalidDataOnSubmitException aInvalidDataOnSubmitException; @@ -1071,10 +1079,13 @@ void UUIInteractionHelper::handleMessageboxRequests( bObtainErrorStringOnly, bHasErrorString, rErrorString); + return true; } + + return false; } -void UUIInteractionHelper::handleDialogRequests( +bool UUIInteractionHelper::handleDialogRequests( star::uno::Reference< star::task::XInteractionRequest > const & rRequest) { star::uno::Any aAnyRequest(rRequest->getRequest()); @@ -1084,7 +1095,7 @@ void UUIInteractionHelper::handleDialogRequests( { handleAuthenticationRequest(aAuthenticationRequest, rRequest->getContinuations()); - return; + return true; } star::ucb::CertificateValidationRequest aCertificateValidationRequest; @@ -1092,7 +1103,7 @@ void UUIInteractionHelper::handleDialogRequests( { handleCertificateValidationRequest(aCertificateValidationRequest, rRequest->getContinuations()); - return; + return true; } // @@@ Todo #i29340#: activate! @@ -1109,7 +1120,7 @@ void UUIInteractionHelper::handleDialogRequests( { handleMasterPasswordRequest(aMasterPasswordRequest.Mode, rRequest->getContinuations()); - return; + return true; } star::task::DocumentPasswordRequest aDocumentPasswordRequest; @@ -1118,7 +1129,7 @@ void UUIInteractionHelper::handleDialogRequests( handlePasswordRequest(aDocumentPasswordRequest.Mode, rRequest->getContinuations(), aDocumentPasswordRequest.Name); - return; + return true; } star::task::PasswordRequest aPasswordRequest; @@ -1126,7 +1137,7 @@ void UUIInteractionHelper::handleDialogRequests( { handlePasswordRequest(aPasswordRequest.Mode, rRequest->getContinuations()); - return; + return true; } star::ucb::HandleCookiesRequest aCookiesRequest; @@ -1134,7 +1145,7 @@ void UUIInteractionHelper::handleDialogRequests( { handleCookiesRequest(aCookiesRequest, rRequest->getContinuations()); - return; + return true; } star::document::NoSuchFilterRequest aNoSuchFilterRequest; @@ -1142,7 +1153,7 @@ void UUIInteractionHelper::handleDialogRequests( { handleNoSuchFilterRequest(aNoSuchFilterRequest, rRequest->getContinuations()); - return; + return true; } star::document::AmbigousFilterRequest aAmbigousFilterRequest; @@ -1150,7 +1161,7 @@ void UUIInteractionHelper::handleDialogRequests( { handleAmbigousFilterRequest(aAmbigousFilterRequest, rRequest->getContinuations()); - return; + return true; } star::document::FilterOptionsRequest aFilterOptionsRequest; @@ -1158,7 +1169,7 @@ void UUIInteractionHelper::handleDialogRequests( { handleFilterOptionsRequest(aFilterOptionsRequest, rRequest->getContinuations()); - return; + return true; } star::document::LockedDocumentRequest aLockedDocumentRequest; @@ -1168,7 +1179,7 @@ void UUIInteractionHelper::handleDialogRequests( aLockedDocumentRequest.UserInfo, rRequest->getContinuations(), UUI_DOC_LOAD_LOCK ); - return; + return true; } star::document::OwnLockOnDocumentRequest aOwnLockOnDocumentRequest; @@ -1204,9 +1215,11 @@ void UUIInteractionHelper::handleDialogRequests( handleLockFileIgnoreRequest( rRequest->getContinuations() ); return; } + + return false; } -void UUIInteractionHelper::handleErrorHandlerRequests( +bool UUIInteractionHelper::handleErrorHandlerRequests( star::uno::Reference< star::task::XInteractionRequest > const & rRequest, bool bObtainErrorStringOnly, bool & bHasErrorString, @@ -1222,7 +1235,7 @@ void UUIInteractionHelper::handleErrorHandlerRequests( bObtainErrorStringOnly, bHasErrorString, rErrorString); - return; + return true; } star::task::DocumentMacroConfirmationRequest aMacroConfirmRequest; @@ -1232,7 +1245,7 @@ void UUIInteractionHelper::handleErrorHandlerRequests( aMacroConfirmRequest, rRequest->getContinuations() ); - return; + return true; } FutureDocumentVersionProductUpdateRequest aProductUpdateRequest; @@ -1242,7 +1255,7 @@ void UUIInteractionHelper::handleErrorHandlerRequests( aProductUpdateRequest, rRequest->getContinuations() ); - return; + return true; } star::task::ErrorCodeIOException aErrorCodeIOException; @@ -1253,8 +1266,10 @@ void UUIInteractionHelper::handleErrorHandlerRequests( bObtainErrorStringOnly, bHasErrorString, rErrorString); - return; + return true; } + + return false; } void @@ -1272,17 +1287,43 @@ UUIInteractionHelper::handle_impl( //////////////////////////////////////////////////////////// bool bDummy = false; rtl::OUString aDummy; - handleMessageboxRequests(rRequest, false, bDummy, aDummy); - - //////////////////////////////////////////////////////////// - // Use ErrorHandler::HandleError - //////////////////////////////////////////////////////////// - handleErrorHandlerRequests(rRequest, false, bDummy, aDummy); - - //////////////////////////////////////////////////////////// - // Display Special Dialog - //////////////////////////////////////////////////////////// - handleDialogRequests(rRequest); + if (! handleMessageboxRequests(rRequest, false, bDummy, aDummy)) + { + //////////////////////////////////////////////////////////// + // Use ErrorHandler::HandleError + //////////////////////////////////////////////////////////// + if (!handleErrorHandlerRequests(rRequest, false, bDummy, aDummy)) + { + //////////////////////////////////////////////////////////// + // Display Special Dialog + //////////////////////////////////////////////////////////// + if (!handleDialogRequests(rRequest)) + { + //////////////////////////////////////////////////////////// + // Use customized InteractionHandler from configuration + //////////////////////////////////////////////////////////// + InteractionHandlerDataList dataList; + + GetInteractionHandlerList(dataList); + + InteractionHandlerDataList::const_iterator aEnd(dataList.end()); + for (InteractionHandlerDataList::const_iterator aIt(dataList.begin()); + aIt != aEnd; ++aIt) + { + Reference< uno::XInterface > xIfc = + m_xServiceFactory->createInstance(aIt->ServiceName); + + Reference< com::sun::star::task::XInteractionHandler2 > xInteractionHandler = + Reference< com::sun::star::task::XInteractionHandler2 >( xIfc, UNO_QUERY ); + + OSL_ENSURE( xInteractionHandler.is(), "Custom Interactionhandler does not implement mandatory interface XInteractionHandler2!" ); + if (xInteractionHandler.is()) + if (xInteractionHandler->handleInteractionRequest(rRequest)) + break; + } + } + } + } } catch (std::bad_alloc const &) { @@ -1292,6 +1333,113 @@ UUIInteractionHelper::handle_impl( } } +void UUIInteractionHelper::GetInteractionHandlerList(InteractionHandlerDataList &rdataList) +{ + uno::Reference< lang::XMultiServiceFactory > xConfigProv( + m_xServiceFactory->createInstance( + rtl::OUString::createFromAscii( + "com.sun.star.configuration.ConfigurationProvider" ) ), + uno::UNO_QUERY ); + + if ( !xConfigProv.is() ) + { + OSL_ENSURE( false, + "GetInteractionHandlerList - No config provider!" ); + return; + } + + rtl::OUStringBuffer aFullPath; + aFullPath.appendAscii( CONFIG_INTERACTIONHANDLERS_KEY ); + + uno::Sequence< uno::Any > aArguments( 1 ); + beans::PropertyValue aProperty; + aProperty.Name + = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) ); + aProperty.Value <<= aFullPath.makeStringAndClear(); + aArguments[ 0 ] <<= aProperty; + + uno::Reference< uno::XInterface > xInterface( + xConfigProv->createInstanceWithArguments( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.configuration.ConfigurationAccess" ) ), + aArguments ) ); + + if ( !xInterface.is() ) + { + OSL_ENSURE( false, + "GetInteractionHandlerList - No config access!" ); + return; + } + + uno::Reference< container::XNameAccess > xNameAccess( + xInterface, uno::UNO_QUERY ); + + if ( !xNameAccess.is() ) + { + OSL_ENSURE( false, + "GetInteractionHandlerList - No XNameAccess!" ); + return; + } + + uno::Sequence< rtl::OUString > aElems = xNameAccess->getElementNames(); + const rtl::OUString* pElems = aElems.getConstArray(); + sal_Int32 nCount = aElems.getLength(); + + if ( nCount > 0 ) + { + uno::Reference< container::XHierarchicalNameAccess > + xHierNameAccess( xInterface, uno::UNO_QUERY ); + + if ( !xHierNameAccess.is() ) + { + OSL_ENSURE( false, + "GetInteractionHandlerList - " + "No XHierarchicalNameAccess!" ); + return; + } + + // Iterate over children. + for ( sal_Int32 n = 0; n < nCount; ++n ) + { + rtl::OUStringBuffer aElemBuffer; + aElemBuffer.appendAscii( "['" ); + aElemBuffer.append( pElems[ n ] ); + + try + { + InteractionHandlerData aInfo; + + // Obtain service name. + rtl::OUStringBuffer aKeyBuffer = aElemBuffer; + aKeyBuffer.appendAscii( "']/ServiceName" ); + + rtl::OUString aValue; + if ( !( xHierNameAccess->getByHierarchicalName( + aKeyBuffer.makeStringAndClear() ) >>= aValue ) ) + { + OSL_ENSURE( false, + "GetInteractionHandlerList - " + "Error getting item value!" ); + continue; + } + + aInfo.ServiceName = aValue; + + // Append info to list. + rdataList.push_back( aInfo ); + } + catch ( container::NoSuchElementException& ) + { + // getByHierarchicalName + + OSL_ENSURE( false, + "GetInteractionHandlerList - " + "caught NoSuchElementException!" ); + } + } + } +} + Window * UUIInteractionHelper::getParentProperty() SAL_THROW(()) { osl::MutexGuard aGuard(m_aPropertyMutex); diff --git a/uui/source/iahndl.hxx b/uui/source/iahndl.hxx index a5856032f5..f173f59778 100644 --- a/uui/source/iahndl.hxx +++ b/uui/source/iahndl.hxx @@ -65,6 +65,22 @@ struct CntHTTPCookieRequest; #define UUI_DOC_SAVE_LOCK 2 #define UUI_DOC_OWN_SAVE_LOCK 3 +//============================================================================ +/** Information about a InteractionHandler + */ +struct InteractionHandlerData +{ + /** The UNO service name to use to instanciate the content provider. + */ + rtl::OUString ServiceName; + + InteractionHandlerData() {}; + InteractionHandlerData( const rtl::OUString & rService) + : ServiceName( rService ){} +}; + +typedef std::vector< InteractionHandlerData > InteractionHandlerDataList; + namespace cssu = com::sun::star::uno; namespace dcss = ::com::sun::star; @@ -139,7 +155,9 @@ private: rRequest) throw (com::sun::star::uno::RuntimeException); - + void + GetInteractionHandlerList(InteractionHandlerDataList &rdataList); + sal_Bool isDomainMatch( rtl::OUString hostName, rtl::OUString certHostName); static long @@ -356,7 +374,7 @@ private: rtl::OUString & rErrorString) SAL_THROW((::com::sun::star::uno::RuntimeException)); - void handleMessageboxRequests( + bool handleMessageboxRequests( ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest > const & rRequest, @@ -364,12 +382,12 @@ private: bool & bHasErrorString, rtl::OUString & rErrorString); - void handleDialogRequests( + bool handleDialogRequests( ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest > const & rRequest); - void handleErrorHandlerRequests( + bool handleErrorHandlerRequests( ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest > const & rRequest, -- cgit v1.2.3