12722ceddSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 32722ceddSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 42722ceddSAndrew Rist * or more contributor license agreements. See the NOTICE file 52722ceddSAndrew Rist * distributed with this work for additional information 62722ceddSAndrew Rist * regarding copyright ownership. The ASF licenses this file 72722ceddSAndrew Rist * to you under the Apache License, Version 2.0 (the 82722ceddSAndrew Rist * "License"); you may not use this file except in compliance 92722ceddSAndrew Rist * with the License. You may obtain a copy of the License at 102722ceddSAndrew Rist * 112722ceddSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 122722ceddSAndrew Rist * 132722ceddSAndrew Rist * Unless required by applicable law or agreed to in writing, 142722ceddSAndrew Rist * software distributed under the License is distributed on an 152722ceddSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 162722ceddSAndrew Rist * KIND, either express or implied. See the License for the 172722ceddSAndrew Rist * specific language governing permissions and limitations 182722ceddSAndrew Rist * under the License. 192722ceddSAndrew Rist * 202722ceddSAndrew Rist *************************************************************/ 212722ceddSAndrew Rist 222722ceddSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_desktop.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include "sal/config.h" 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include <cstddef> 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include "com/sun/star/beans/PropertyValue.hpp" 35cdf0e10cSrcweir #include "com/sun/star/beans/NamedValue.hpp" 36cdf0e10cSrcweir 37cdf0e10cSrcweir #include "com/sun/star/deployment/DependencyException.hpp" 38cdf0e10cSrcweir #include "com/sun/star/deployment/LicenseException.hpp" 39cdf0e10cSrcweir #include "com/sun/star/deployment/VersionException.hpp" 40cdf0e10cSrcweir #include "com/sun/star/deployment/InstallException.hpp" 41cdf0e10cSrcweir #include "com/sun/star/deployment/PlatformException.hpp" 42cdf0e10cSrcweir 43cdf0e10cSrcweir #include "com/sun/star/deployment/ui/LicenseDialog.hpp" 44cdf0e10cSrcweir #include "com/sun/star/deployment/DeploymentException.hpp" 45cdf0e10cSrcweir #include "com/sun/star/deployment/UpdateInformationProvider.hpp" 46cdf0e10cSrcweir #include "com/sun/star/deployment/XPackage.hpp" 47cdf0e10cSrcweir 48cdf0e10cSrcweir #include "com/sun/star/task/XAbortChannel.hpp" 49cdf0e10cSrcweir #include "com/sun/star/task/XInteractionAbort.hpp" 50cdf0e10cSrcweir #include "com/sun/star/task/XInteractionApprove.hpp" 51cdf0e10cSrcweir 52cdf0e10cSrcweir #include "com/sun/star/ucb/CommandAbortedException.hpp" 53cdf0e10cSrcweir #include "com/sun/star/ucb/CommandFailedException.hpp" 54cdf0e10cSrcweir #include "com/sun/star/ucb/XCommandEnvironment.hpp" 55cdf0e10cSrcweir 56cdf0e10cSrcweir #include "com/sun/star/ui/dialogs/ExecutableDialogResults.hpp" 57cdf0e10cSrcweir 58cdf0e10cSrcweir #include "com/sun/star/uno/Reference.hxx" 59cdf0e10cSrcweir #include "com/sun/star/uno/RuntimeException.hpp" 60cdf0e10cSrcweir #include "com/sun/star/uno/Sequence.hxx" 61cdf0e10cSrcweir #include "com/sun/star/uno/XInterface.hpp" 62cdf0e10cSrcweir #include "com/sun/star/uno/TypeClass.hpp" 63cdf0e10cSrcweir #include "osl/diagnose.h" 64cdf0e10cSrcweir #include "osl/mutex.hxx" 65cdf0e10cSrcweir #include "rtl/ref.hxx" 66cdf0e10cSrcweir #include "rtl/ustring.h" 67cdf0e10cSrcweir #include "rtl/ustring.hxx" 68cdf0e10cSrcweir #include "sal/types.h" 69cdf0e10cSrcweir #include "ucbhelper/content.hxx" 70cdf0e10cSrcweir #include "cppuhelper/exc_hlp.hxx" 71cdf0e10cSrcweir #include "cppuhelper/implbase3.hxx" 72cdf0e10cSrcweir #include "comphelper/anytostring.hxx" 73cdf0e10cSrcweir #include "vcl/msgbox.hxx" 74cdf0e10cSrcweir #include "toolkit/helper/vclunohelper.hxx" 75cdf0e10cSrcweir #include "comphelper/processfactory.hxx" 76cdf0e10cSrcweir 77cdf0e10cSrcweir #include "dp_gui.h" 78cdf0e10cSrcweir #include "dp_gui_thread.hxx" 79cdf0e10cSrcweir #include "dp_gui_extensioncmdqueue.hxx" 80cdf0e10cSrcweir #include "dp_gui_dependencydialog.hxx" 81cdf0e10cSrcweir #include "dp_gui_dialog2.hxx" 82cdf0e10cSrcweir #include "dp_gui_shared.hxx" 83cdf0e10cSrcweir #include "dp_gui_theextmgr.hxx" 84cdf0e10cSrcweir #include "dp_gui_updatedialog.hxx" 85cdf0e10cSrcweir #include "dp_gui_updateinstalldialog.hxx" 86cdf0e10cSrcweir #include "dp_dependencies.hxx" 87cdf0e10cSrcweir #include "dp_identifier.hxx" 88cdf0e10cSrcweir #include "dp_version.hxx" 89*281431dbSOliver-Rainer Wittmann #include <dp_gui_handleversionexception.hxx> 90cdf0e10cSrcweir 91cdf0e10cSrcweir #include <queue> 92cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 93cdf0e10cSrcweir 94cdf0e10cSrcweir #if (defined(_MSC_VER) && (_MSC_VER < 1400)) 95cdf0e10cSrcweir #define _WIN32_WINNT 0x0400 96cdf0e10cSrcweir #endif 97cdf0e10cSrcweir 98cdf0e10cSrcweir #ifdef WNT 99cdf0e10cSrcweir #include "tools/prewin.h" 100cdf0e10cSrcweir #include <objbase.h> 101cdf0e10cSrcweir #include "tools/postwin.h" 102cdf0e10cSrcweir #endif 103cdf0e10cSrcweir 104cdf0e10cSrcweir 105cdf0e10cSrcweir using namespace ::com::sun::star; 106cdf0e10cSrcweir using ::rtl::OUString; 107cdf0e10cSrcweir 108cdf0e10cSrcweir namespace { 109cdf0e10cSrcweir 110cdf0e10cSrcweir OUString getVersion( OUString const & sVersion ) 111cdf0e10cSrcweir { 112cdf0e10cSrcweir return ( sVersion.getLength() == 0 ) ? OUString( RTL_CONSTASCII_USTRINGPARAM( "0" ) ) : sVersion; 113cdf0e10cSrcweir } 114cdf0e10cSrcweir 115cdf0e10cSrcweir OUString getVersion( const uno::Reference< deployment::XPackage > &rPackage ) 116cdf0e10cSrcweir { 117cdf0e10cSrcweir return getVersion( rPackage->getVersion()); 118cdf0e10cSrcweir } 119cdf0e10cSrcweir } 120cdf0e10cSrcweir 121cdf0e10cSrcweir 122cdf0e10cSrcweir namespace dp_gui { 123cdf0e10cSrcweir 124cdf0e10cSrcweir //============================================================================== 125cdf0e10cSrcweir 126cdf0e10cSrcweir class ProgressCmdEnv 127cdf0e10cSrcweir : public ::cppu::WeakImplHelper3< ucb::XCommandEnvironment, 128cdf0e10cSrcweir task::XInteractionHandler, 129cdf0e10cSrcweir ucb::XProgressHandler > 130cdf0e10cSrcweir { 131cdf0e10cSrcweir uno::Reference< task::XInteractionHandler> m_xHandler; 132cdf0e10cSrcweir uno::Reference< uno::XComponentContext > m_xContext; 133cdf0e10cSrcweir uno::Reference< task::XAbortChannel> m_xAbortChannel; 134cdf0e10cSrcweir 135cdf0e10cSrcweir DialogHelper *m_pDialogHelper; 136cdf0e10cSrcweir OUString m_sTitle; 137cdf0e10cSrcweir bool m_bAborted; 138cdf0e10cSrcweir bool m_bWarnUser; 139cdf0e10cSrcweir sal_Int32 m_nCurrentProgress; 140cdf0e10cSrcweir 141cdf0e10cSrcweir void updateProgress(); 142cdf0e10cSrcweir 143cdf0e10cSrcweir void update_( uno::Any const & Status ) throw ( uno::RuntimeException ); 144cdf0e10cSrcweir 145cdf0e10cSrcweir public: 146cdf0e10cSrcweir virtual ~ProgressCmdEnv(); 147cdf0e10cSrcweir 148cdf0e10cSrcweir /** When param bAskWhenInstalling = true, then the user is asked if he 149cdf0e10cSrcweir agrees to install this extension. In case this extension is already installed 150cdf0e10cSrcweir then the user is also notified and asked if he wants to replace that existing 151cdf0e10cSrcweir extension. In first case an interaction request with an InstallException 152cdf0e10cSrcweir will be handled and in the second case a VersionException will be handled. 153cdf0e10cSrcweir */ 154cdf0e10cSrcweir 155cdf0e10cSrcweir ProgressCmdEnv( const uno::Reference< uno::XComponentContext > rContext, 156cdf0e10cSrcweir DialogHelper *pDialogHelper, 157cdf0e10cSrcweir const OUString &rTitle ) 158cdf0e10cSrcweir : m_xContext( rContext ), 159cdf0e10cSrcweir m_pDialogHelper( pDialogHelper ), 160cdf0e10cSrcweir m_sTitle( rTitle ), 161cdf0e10cSrcweir m_bAborted( false ), 162cdf0e10cSrcweir m_bWarnUser( false ) 163cdf0e10cSrcweir {} 164cdf0e10cSrcweir 165cdf0e10cSrcweir Dialog * activeDialog() { return m_pDialogHelper ? m_pDialogHelper->getWindow() : NULL; } 166cdf0e10cSrcweir 167cdf0e10cSrcweir void setTitle( const OUString& rNewTitle ) { m_sTitle = rNewTitle; } 168cdf0e10cSrcweir void startProgress(); 169cdf0e10cSrcweir void stopProgress(); 170cdf0e10cSrcweir void progressSection( const OUString &rText, 171cdf0e10cSrcweir const uno::Reference< task::XAbortChannel > &xAbortChannel = 0 ); 172cdf0e10cSrcweir inline bool isAborted() const { return m_bAborted; } 173cdf0e10cSrcweir inline void setWarnUser( bool bNewVal ) { m_bWarnUser = bNewVal; } 174cdf0e10cSrcweir 175cdf0e10cSrcweir // XCommandEnvironment 176cdf0e10cSrcweir virtual uno::Reference< task::XInteractionHandler > SAL_CALL getInteractionHandler() 177cdf0e10cSrcweir throw ( uno::RuntimeException ); 178cdf0e10cSrcweir virtual uno::Reference< ucb::XProgressHandler > SAL_CALL getProgressHandler() 179cdf0e10cSrcweir throw ( uno::RuntimeException ); 180cdf0e10cSrcweir 181cdf0e10cSrcweir // XInteractionHandler 182cdf0e10cSrcweir virtual void SAL_CALL handle( uno::Reference< task::XInteractionRequest > const & xRequest ) 183cdf0e10cSrcweir throw ( uno::RuntimeException ); 184cdf0e10cSrcweir 185cdf0e10cSrcweir // XProgressHandler 186cdf0e10cSrcweir virtual void SAL_CALL push( uno::Any const & Status ) 187cdf0e10cSrcweir throw ( uno::RuntimeException ); 188cdf0e10cSrcweir virtual void SAL_CALL update( uno::Any const & Status ) 189cdf0e10cSrcweir throw ( uno::RuntimeException ); 190cdf0e10cSrcweir virtual void SAL_CALL pop() throw ( uno::RuntimeException ); 191cdf0e10cSrcweir }; 192cdf0e10cSrcweir 193cdf0e10cSrcweir //------------------------------------------------------------------------------ 194cdf0e10cSrcweir struct ExtensionCmd 195cdf0e10cSrcweir { 196cdf0e10cSrcweir enum E_CMD_TYPE { ADD, ENABLE, DISABLE, REMOVE, CHECK_FOR_UPDATES, ACCEPT_LICENSE }; 197cdf0e10cSrcweir 198cdf0e10cSrcweir E_CMD_TYPE m_eCmdType; 199cdf0e10cSrcweir bool m_bWarnUser; 200cdf0e10cSrcweir OUString m_sExtensionURL; 201cdf0e10cSrcweir OUString m_sRepository; 202cdf0e10cSrcweir uno::Reference< deployment::XPackage > m_xPackage; 203cdf0e10cSrcweir std::vector< uno::Reference< deployment::XPackage > > m_vExtensionList; 204cdf0e10cSrcweir 205cdf0e10cSrcweir ExtensionCmd( const E_CMD_TYPE eCommand, 206cdf0e10cSrcweir const OUString &rExtensionURL, 207cdf0e10cSrcweir const OUString &rRepository, 208cdf0e10cSrcweir const bool bWarnUser ) 209cdf0e10cSrcweir : m_eCmdType( eCommand ), 210cdf0e10cSrcweir m_bWarnUser( bWarnUser ), 211cdf0e10cSrcweir m_sExtensionURL( rExtensionURL ), 212cdf0e10cSrcweir m_sRepository( rRepository ) {}; 213cdf0e10cSrcweir ExtensionCmd( const E_CMD_TYPE eCommand, 214cdf0e10cSrcweir const uno::Reference< deployment::XPackage > &rPackage ) 215cdf0e10cSrcweir : m_eCmdType( eCommand ), 216cdf0e10cSrcweir m_bWarnUser( false ), 217cdf0e10cSrcweir m_xPackage( rPackage ) {}; 218cdf0e10cSrcweir ExtensionCmd( const E_CMD_TYPE eCommand, 219cdf0e10cSrcweir const std::vector<uno::Reference<deployment::XPackage > > &vExtensionList ) 220cdf0e10cSrcweir : m_eCmdType( eCommand ), 221cdf0e10cSrcweir m_bWarnUser( false ), 222cdf0e10cSrcweir m_vExtensionList( vExtensionList ) {}; 223cdf0e10cSrcweir }; 224cdf0e10cSrcweir 225cdf0e10cSrcweir typedef ::boost::shared_ptr< ExtensionCmd > TExtensionCmd; 226cdf0e10cSrcweir 227cdf0e10cSrcweir //------------------------------------------------------------------------------ 228cdf0e10cSrcweir class ExtensionCmdQueue::Thread: public dp_gui::Thread 229cdf0e10cSrcweir { 230cdf0e10cSrcweir public: 231cdf0e10cSrcweir Thread( DialogHelper *pDialogHelper, 232cdf0e10cSrcweir TheExtensionManager *pManager, 233cdf0e10cSrcweir const uno::Reference< uno::XComponentContext > & rContext ); 234cdf0e10cSrcweir 235cdf0e10cSrcweir void addExtension( const OUString &rExtensionURL, 236cdf0e10cSrcweir const OUString &rRepository, 237cdf0e10cSrcweir const bool bWarnUser ); 238cdf0e10cSrcweir void removeExtension( const uno::Reference< deployment::XPackage > &rPackage ); 239cdf0e10cSrcweir void enableExtension( const uno::Reference< deployment::XPackage > &rPackage, 240cdf0e10cSrcweir const bool bEnable ); 241cdf0e10cSrcweir void checkForUpdates( const std::vector<uno::Reference<deployment::XPackage > > &vExtensionList ); 242cdf0e10cSrcweir void acceptLicense( const uno::Reference< deployment::XPackage > &rPackage ); 243cdf0e10cSrcweir void stop(); 244cdf0e10cSrcweir bool isBusy(); 245cdf0e10cSrcweir 246cdf0e10cSrcweir static OUString searchAndReplaceAll( const OUString &rSource, 247cdf0e10cSrcweir const OUString &rWhat, 248cdf0e10cSrcweir const OUString &rWith ); 249cdf0e10cSrcweir private: 250cdf0e10cSrcweir Thread( Thread & ); // not defined 251cdf0e10cSrcweir void operator =( Thread & ); // not defined 252cdf0e10cSrcweir 253cdf0e10cSrcweir virtual ~Thread(); 254cdf0e10cSrcweir 255cdf0e10cSrcweir virtual void execute(); 256cdf0e10cSrcweir virtual void SAL_CALL onTerminated(); 257cdf0e10cSrcweir 258cdf0e10cSrcweir void _addExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, 259cdf0e10cSrcweir const OUString &rPackageURL, 260cdf0e10cSrcweir const OUString &rRepository, 261cdf0e10cSrcweir const bool bWarnUser ); 262cdf0e10cSrcweir void _removeExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, 263cdf0e10cSrcweir const uno::Reference< deployment::XPackage > &xPackage ); 264cdf0e10cSrcweir void _enableExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, 265cdf0e10cSrcweir const uno::Reference< deployment::XPackage > &xPackage ); 266cdf0e10cSrcweir void _disableExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, 267cdf0e10cSrcweir const uno::Reference< deployment::XPackage > &xPackage ); 268cdf0e10cSrcweir void _checkForUpdates( const std::vector<uno::Reference<deployment::XPackage > > &vExtensionList ); 269cdf0e10cSrcweir void _acceptLicense( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, 270cdf0e10cSrcweir const uno::Reference< deployment::XPackage > &xPackage ); 271cdf0e10cSrcweir 272cdf0e10cSrcweir enum Input { NONE, START, STOP }; 273cdf0e10cSrcweir 274cdf0e10cSrcweir uno::Reference< uno::XComponentContext > m_xContext; 275cdf0e10cSrcweir std::queue< TExtensionCmd > m_queue; 276cdf0e10cSrcweir 277cdf0e10cSrcweir DialogHelper *m_pDialogHelper; 278cdf0e10cSrcweir TheExtensionManager *m_pManager; 279cdf0e10cSrcweir 280cdf0e10cSrcweir const OUString m_sEnablingPackages; 281cdf0e10cSrcweir const OUString m_sDisablingPackages; 282cdf0e10cSrcweir const OUString m_sAddingPackages; 283cdf0e10cSrcweir const OUString m_sRemovingPackages; 284cdf0e10cSrcweir const OUString m_sDefaultCmd; 285cdf0e10cSrcweir const OUString m_sAcceptLicense; 286cdf0e10cSrcweir osl::Condition m_wakeup; 287cdf0e10cSrcweir osl::Mutex m_mutex; 288cdf0e10cSrcweir Input m_eInput; 289cdf0e10cSrcweir bool m_bTerminated; 290cdf0e10cSrcweir bool m_bStopped; 291cdf0e10cSrcweir bool m_bWorking; 292cdf0e10cSrcweir }; 293cdf0e10cSrcweir 294cdf0e10cSrcweir //------------------------------------------------------------------------------ 295cdf0e10cSrcweir void ProgressCmdEnv::startProgress() 296cdf0e10cSrcweir { 297cdf0e10cSrcweir m_nCurrentProgress = 0; 298cdf0e10cSrcweir 299cdf0e10cSrcweir if ( m_pDialogHelper ) 300cdf0e10cSrcweir m_pDialogHelper->showProgress( true ); 301cdf0e10cSrcweir } 302cdf0e10cSrcweir 303cdf0e10cSrcweir //------------------------------------------------------------------------------ 304cdf0e10cSrcweir void ProgressCmdEnv::stopProgress() 305cdf0e10cSrcweir { 306cdf0e10cSrcweir if ( m_pDialogHelper ) 307cdf0e10cSrcweir m_pDialogHelper->showProgress( false ); 308cdf0e10cSrcweir } 309cdf0e10cSrcweir 310cdf0e10cSrcweir //------------------------------------------------------------------------------ 311cdf0e10cSrcweir void ProgressCmdEnv::progressSection( const OUString &rText, 312cdf0e10cSrcweir const uno::Reference< task::XAbortChannel > &xAbortChannel ) 313cdf0e10cSrcweir { 314cdf0e10cSrcweir m_xAbortChannel = xAbortChannel; 315cdf0e10cSrcweir if (! m_bAborted) 316cdf0e10cSrcweir { 317cdf0e10cSrcweir m_nCurrentProgress = 0; 318cdf0e10cSrcweir if ( m_pDialogHelper ) 319cdf0e10cSrcweir { 320cdf0e10cSrcweir m_pDialogHelper->updateProgress( rText, xAbortChannel ); 321cdf0e10cSrcweir m_pDialogHelper->updateProgress( 5 ); 322cdf0e10cSrcweir } 323cdf0e10cSrcweir } 324cdf0e10cSrcweir } 325cdf0e10cSrcweir 326cdf0e10cSrcweir //------------------------------------------------------------------------------ 327cdf0e10cSrcweir void ProgressCmdEnv::updateProgress() 328cdf0e10cSrcweir { 329cdf0e10cSrcweir if ( ! m_bAborted ) 330cdf0e10cSrcweir { 331cdf0e10cSrcweir long nProgress = ((m_nCurrentProgress*5) % 100) + 5; 332cdf0e10cSrcweir if ( m_pDialogHelper ) 333cdf0e10cSrcweir m_pDialogHelper->updateProgress( nProgress ); 334cdf0e10cSrcweir } 335cdf0e10cSrcweir } 336cdf0e10cSrcweir 337cdf0e10cSrcweir //------------------------------------------------------------------------------ 338cdf0e10cSrcweir ProgressCmdEnv::~ProgressCmdEnv() 339cdf0e10cSrcweir { 340cdf0e10cSrcweir // TODO: stop all threads and wait 341cdf0e10cSrcweir } 342cdf0e10cSrcweir 343cdf0e10cSrcweir 344cdf0e10cSrcweir //------------------------------------------------------------------------------ 345cdf0e10cSrcweir // XCommandEnvironment 346cdf0e10cSrcweir //------------------------------------------------------------------------------ 347cdf0e10cSrcweir uno::Reference< task::XInteractionHandler > ProgressCmdEnv::getInteractionHandler() 348cdf0e10cSrcweir throw ( uno::RuntimeException ) 349cdf0e10cSrcweir { 350cdf0e10cSrcweir return this; 351cdf0e10cSrcweir } 352cdf0e10cSrcweir 353cdf0e10cSrcweir //------------------------------------------------------------------------------ 354cdf0e10cSrcweir uno::Reference< ucb::XProgressHandler > ProgressCmdEnv::getProgressHandler() 355cdf0e10cSrcweir throw ( uno::RuntimeException ) 356cdf0e10cSrcweir { 357cdf0e10cSrcweir return this; 358cdf0e10cSrcweir } 359cdf0e10cSrcweir 360cdf0e10cSrcweir //------------------------------------------------------------------------------ 361cdf0e10cSrcweir // XInteractionHandler 362cdf0e10cSrcweir //------------------------------------------------------------------------------ 363*281431dbSOliver-Rainer Wittmann bool handleVersionException( 364*281431dbSOliver-Rainer Wittmann com::sun::star::deployment::VersionException verExc, 365*281431dbSOliver-Rainer Wittmann DialogHelper* pDialogHelper ) 366*281431dbSOliver-Rainer Wittmann { 367*281431dbSOliver-Rainer Wittmann bool bApprove = false; 368*281431dbSOliver-Rainer Wittmann 369*281431dbSOliver-Rainer Wittmann sal_uInt32 id; 370*281431dbSOliver-Rainer Wittmann switch (dp_misc::compareVersions( 371*281431dbSOliver-Rainer Wittmann verExc.NewVersion, verExc.Deployed->getVersion() )) 372*281431dbSOliver-Rainer Wittmann { 373*281431dbSOliver-Rainer Wittmann case dp_misc::LESS: 374*281431dbSOliver-Rainer Wittmann id = RID_WARNINGBOX_VERSION_LESS; 375*281431dbSOliver-Rainer Wittmann break; 376*281431dbSOliver-Rainer Wittmann case dp_misc::EQUAL: 377*281431dbSOliver-Rainer Wittmann id = RID_WARNINGBOX_VERSION_EQUAL; 378*281431dbSOliver-Rainer Wittmann break; 379*281431dbSOliver-Rainer Wittmann default: // dp_misc::GREATER 380*281431dbSOliver-Rainer Wittmann id = RID_WARNINGBOX_VERSION_GREATER; 381*281431dbSOliver-Rainer Wittmann break; 382*281431dbSOliver-Rainer Wittmann } 383*281431dbSOliver-Rainer Wittmann OSL_ASSERT( verExc.Deployed.is() ); 384*281431dbSOliver-Rainer Wittmann const bool bEqualNames = verExc.NewDisplayName.equals( 385*281431dbSOliver-Rainer Wittmann verExc.Deployed->getDisplayName()); 386*281431dbSOliver-Rainer Wittmann { 387*281431dbSOliver-Rainer Wittmann vos::OGuard guard(Application::GetSolarMutex()); 388*281431dbSOliver-Rainer Wittmann WarningBox box( pDialogHelper ? pDialogHelper->getWindow() : NULL, ResId(id, *DeploymentGuiResMgr::get())); 389*281431dbSOliver-Rainer Wittmann String s; 390*281431dbSOliver-Rainer Wittmann if (bEqualNames) 391*281431dbSOliver-Rainer Wittmann { 392*281431dbSOliver-Rainer Wittmann s = box.GetMessText(); 393*281431dbSOliver-Rainer Wittmann } 394*281431dbSOliver-Rainer Wittmann else if (id == RID_WARNINGBOX_VERSION_EQUAL) 395*281431dbSOliver-Rainer Wittmann { 396*281431dbSOliver-Rainer Wittmann //hypothetical: requires two instances of an extension with the same 397*281431dbSOliver-Rainer Wittmann //version to have different display names. Probably the developer forgot 398*281431dbSOliver-Rainer Wittmann //to change the version. 399*281431dbSOliver-Rainer Wittmann s = String(ResId(RID_STR_WARNINGBOX_VERSION_EQUAL_DIFFERENT_NAMES, *DeploymentGuiResMgr::get())); 400*281431dbSOliver-Rainer Wittmann } 401*281431dbSOliver-Rainer Wittmann else if (id == RID_WARNINGBOX_VERSION_LESS) 402*281431dbSOliver-Rainer Wittmann { 403*281431dbSOliver-Rainer Wittmann s = String(ResId(RID_STR_WARNINGBOX_VERSION_LESS_DIFFERENT_NAMES, *DeploymentGuiResMgr::get())); 404*281431dbSOliver-Rainer Wittmann } 405*281431dbSOliver-Rainer Wittmann else if (id == RID_WARNINGBOX_VERSION_GREATER) 406*281431dbSOliver-Rainer Wittmann { 407*281431dbSOliver-Rainer Wittmann s = String(ResId(RID_STR_WARNINGBOX_VERSION_GREATER_DIFFERENT_NAMES, *DeploymentGuiResMgr::get())); 408*281431dbSOliver-Rainer Wittmann } 409*281431dbSOliver-Rainer Wittmann s.SearchAndReplaceAllAscii( "$NAME", verExc.NewDisplayName); 410*281431dbSOliver-Rainer Wittmann s.SearchAndReplaceAllAscii( "$OLDNAME", verExc.Deployed->getDisplayName()); 411*281431dbSOliver-Rainer Wittmann s.SearchAndReplaceAllAscii( "$NEW", getVersion(verExc.NewVersion) ); 412*281431dbSOliver-Rainer Wittmann s.SearchAndReplaceAllAscii( "$DEPLOYED", getVersion(verExc.Deployed) ); 413*281431dbSOliver-Rainer Wittmann box.SetMessText(s); 414*281431dbSOliver-Rainer Wittmann bApprove = box.Execute() == RET_OK; 415*281431dbSOliver-Rainer Wittmann } 416*281431dbSOliver-Rainer Wittmann 417*281431dbSOliver-Rainer Wittmann return bApprove; 418*281431dbSOliver-Rainer Wittmann } 419*281431dbSOliver-Rainer Wittmann 420cdf0e10cSrcweir void ProgressCmdEnv::handle( uno::Reference< task::XInteractionRequest > const & xRequest ) 421cdf0e10cSrcweir throw ( uno::RuntimeException ) 422cdf0e10cSrcweir { 423cdf0e10cSrcweir uno::Any request( xRequest->getRequest() ); 424cdf0e10cSrcweir OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION ); 425cdf0e10cSrcweir dp_misc::TRACE( OUSTR("[dp_gui_cmdenv.cxx] incoming request:\n") 426cdf0e10cSrcweir + ::comphelper::anyToString(request) + OUSTR("\n")); 427cdf0e10cSrcweir 428cdf0e10cSrcweir lang::WrappedTargetException wtExc; 429cdf0e10cSrcweir deployment::DependencyException depExc; 430cdf0e10cSrcweir deployment::LicenseException licExc; 431cdf0e10cSrcweir deployment::VersionException verExc; 432cdf0e10cSrcweir deployment::InstallException instExc; 433cdf0e10cSrcweir deployment::PlatformException platExc; 434cdf0e10cSrcweir 435cdf0e10cSrcweir // selections: 436cdf0e10cSrcweir bool approve = false; 437cdf0e10cSrcweir bool abort = false; 438cdf0e10cSrcweir 439cdf0e10cSrcweir if (request >>= wtExc) { 440cdf0e10cSrcweir // handable deployment error signalled, e.g. 441cdf0e10cSrcweir // bundle item registration failed, notify cause only: 442cdf0e10cSrcweir uno::Any cause; 443cdf0e10cSrcweir deployment::DeploymentException dpExc; 444cdf0e10cSrcweir if (wtExc.TargetException >>= dpExc) 445cdf0e10cSrcweir cause = dpExc.Cause; 446cdf0e10cSrcweir else { 447cdf0e10cSrcweir ucb::CommandFailedException cfExc; 448cdf0e10cSrcweir if (wtExc.TargetException >>= cfExc) 449cdf0e10cSrcweir cause = cfExc.Reason; 450cdf0e10cSrcweir else 451cdf0e10cSrcweir cause = wtExc.TargetException; 452cdf0e10cSrcweir } 453cdf0e10cSrcweir update_( cause ); 454cdf0e10cSrcweir 455cdf0e10cSrcweir // ignore intermediate errors of legacy packages, i.e. 456cdf0e10cSrcweir // former pkgchk behaviour: 457cdf0e10cSrcweir const uno::Reference< deployment::XPackage > xPackage( wtExc.Context, uno::UNO_QUERY ); 458cdf0e10cSrcweir OSL_ASSERT( xPackage.is() ); 459cdf0e10cSrcweir if ( xPackage.is() ) 460cdf0e10cSrcweir { 461cdf0e10cSrcweir const uno::Reference< deployment::XPackageTypeInfo > xPackageType( xPackage->getPackageType() ); 462cdf0e10cSrcweir OSL_ASSERT( xPackageType.is() ); 463cdf0e10cSrcweir if (xPackageType.is()) 464cdf0e10cSrcweir { 465cdf0e10cSrcweir approve = ( xPackage->isBundle() && 466cdf0e10cSrcweir xPackageType->getMediaType().matchAsciiL( 467cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( 468cdf0e10cSrcweir "application/" 469cdf0e10cSrcweir "vnd.sun.star.legacy-package-bundle") )); 470cdf0e10cSrcweir } 471cdf0e10cSrcweir } 472cdf0e10cSrcweir abort = !approve; 473cdf0e10cSrcweir } 474cdf0e10cSrcweir else if (request >>= depExc) 475cdf0e10cSrcweir { 476cdf0e10cSrcweir std::vector< rtl::OUString > deps; 477cdf0e10cSrcweir for (sal_Int32 i = 0; i < depExc.UnsatisfiedDependencies.getLength(); 478cdf0e10cSrcweir ++i) 479cdf0e10cSrcweir { 480cdf0e10cSrcweir deps.push_back( 481cdf0e10cSrcweir dp_misc::Dependencies::getErrorText( depExc.UnsatisfiedDependencies[i]) ); 482cdf0e10cSrcweir } 483cdf0e10cSrcweir { 484cdf0e10cSrcweir vos::OGuard guard(Application::GetSolarMutex()); 485cdf0e10cSrcweir short n = DependencyDialog( m_pDialogHelper? m_pDialogHelper->getWindow() : NULL, deps ).Execute(); 486cdf0e10cSrcweir // Distinguish between closing the dialog and programatically 487cdf0e10cSrcweir // canceling the dialog (headless VCL): 488cdf0e10cSrcweir approve = n == RET_OK 489cdf0e10cSrcweir || (n == RET_CANCEL && !Application::IsDialogCancelEnabled()); 490cdf0e10cSrcweir } 491cdf0e10cSrcweir } 492cdf0e10cSrcweir else if (request >>= licExc) 493cdf0e10cSrcweir { 494cdf0e10cSrcweir uno::Reference< ui::dialogs::XExecutableDialog > xDialog( 495cdf0e10cSrcweir deployment::ui::LicenseDialog::create( 496cdf0e10cSrcweir m_xContext, VCLUnoHelper::GetInterface( m_pDialogHelper? m_pDialogHelper->getWindow() : NULL ), 497cdf0e10cSrcweir licExc.ExtensionName, licExc.Text ) ); 498cdf0e10cSrcweir sal_Int16 res = xDialog->execute(); 499cdf0e10cSrcweir if ( res == ui::dialogs::ExecutableDialogResults::CANCEL ) 500cdf0e10cSrcweir abort = true; 501cdf0e10cSrcweir else if ( res == ui::dialogs::ExecutableDialogResults::OK ) 502cdf0e10cSrcweir approve = true; 503cdf0e10cSrcweir else 504cdf0e10cSrcweir { 505cdf0e10cSrcweir OSL_ASSERT(0); 506cdf0e10cSrcweir } 507cdf0e10cSrcweir } 508cdf0e10cSrcweir else if (request >>= verExc) 509cdf0e10cSrcweir { 510*281431dbSOliver-Rainer Wittmann approve = handleVersionException( verExc, m_pDialogHelper ); 511*281431dbSOliver-Rainer Wittmann abort = !approve; 512cdf0e10cSrcweir } 513cdf0e10cSrcweir else if (request >>= instExc) 514cdf0e10cSrcweir { 515cdf0e10cSrcweir if ( ! m_bWarnUser ) 516cdf0e10cSrcweir { 517cdf0e10cSrcweir approve = true; 518cdf0e10cSrcweir } 519cdf0e10cSrcweir else 520cdf0e10cSrcweir { 521cdf0e10cSrcweir if ( m_pDialogHelper ) 522cdf0e10cSrcweir { 523cdf0e10cSrcweir vos::OGuard guard(Application::GetSolarMutex()); 524cdf0e10cSrcweir 525cdf0e10cSrcweir approve = m_pDialogHelper->installExtensionWarn( instExc.displayName ); 526cdf0e10cSrcweir } 527cdf0e10cSrcweir else 528cdf0e10cSrcweir approve = false; 529cdf0e10cSrcweir abort = !approve; 530cdf0e10cSrcweir } 531cdf0e10cSrcweir } 532cdf0e10cSrcweir else if (request >>= platExc) 533cdf0e10cSrcweir { 534cdf0e10cSrcweir vos::OGuard guard( Application::GetSolarMutex() ); 535cdf0e10cSrcweir String sMsg( ResId( RID_STR_UNSUPPORTED_PLATFORM, *DeploymentGuiResMgr::get() ) ); 536cdf0e10cSrcweir sMsg.SearchAndReplaceAllAscii( "%Name", platExc.package->getDisplayName() ); 537cdf0e10cSrcweir ErrorBox box( m_pDialogHelper? m_pDialogHelper->getWindow() : NULL, WB_OK, sMsg ); 538cdf0e10cSrcweir box.Execute(); 539cdf0e10cSrcweir approve = true; 540cdf0e10cSrcweir } 541cdf0e10cSrcweir 542cdf0e10cSrcweir if (approve == false && abort == false) 543cdf0e10cSrcweir { 544cdf0e10cSrcweir // forward to UUI handler: 545cdf0e10cSrcweir if (! m_xHandler.is()) { 546cdf0e10cSrcweir // late init: 547cdf0e10cSrcweir uno::Sequence< uno::Any > handlerArgs( 1 ); 548cdf0e10cSrcweir handlerArgs[ 0 ] <<= beans::PropertyValue( 549cdf0e10cSrcweir OUSTR("Context"), -1, uno::Any( m_sTitle ), 550cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE ); 551cdf0e10cSrcweir m_xHandler.set( m_xContext->getServiceManager() 552cdf0e10cSrcweir ->createInstanceWithArgumentsAndContext( 553cdf0e10cSrcweir OUSTR("com.sun.star.uui.InteractionHandler"), 554cdf0e10cSrcweir handlerArgs, m_xContext ), uno::UNO_QUERY_THROW ); 555cdf0e10cSrcweir } 556cdf0e10cSrcweir m_xHandler->handle( xRequest ); 557cdf0e10cSrcweir } 558cdf0e10cSrcweir else 559cdf0e10cSrcweir { 560cdf0e10cSrcweir // select: 561cdf0e10cSrcweir uno::Sequence< uno::Reference< task::XInteractionContinuation > > conts( 562cdf0e10cSrcweir xRequest->getContinuations() ); 563cdf0e10cSrcweir uno::Reference< task::XInteractionContinuation > const * pConts = conts.getConstArray(); 564cdf0e10cSrcweir sal_Int32 len = conts.getLength(); 565cdf0e10cSrcweir for ( sal_Int32 pos = 0; pos < len; ++pos ) 566cdf0e10cSrcweir { 567cdf0e10cSrcweir if (approve) { 568cdf0e10cSrcweir uno::Reference< task::XInteractionApprove > xInteractionApprove( pConts[ pos ], uno::UNO_QUERY ); 569cdf0e10cSrcweir if (xInteractionApprove.is()) { 570cdf0e10cSrcweir xInteractionApprove->select(); 571cdf0e10cSrcweir // don't query again for ongoing continuations: 572cdf0e10cSrcweir approve = false; 573cdf0e10cSrcweir } 574cdf0e10cSrcweir } 575cdf0e10cSrcweir else if (abort) { 576cdf0e10cSrcweir uno::Reference< task::XInteractionAbort > xInteractionAbort( pConts[ pos ], uno::UNO_QUERY ); 577cdf0e10cSrcweir if (xInteractionAbort.is()) { 578cdf0e10cSrcweir xInteractionAbort->select(); 579cdf0e10cSrcweir // don't query again for ongoing continuations: 580cdf0e10cSrcweir abort = false; 581cdf0e10cSrcweir } 582cdf0e10cSrcweir } 583cdf0e10cSrcweir } 584cdf0e10cSrcweir } 585cdf0e10cSrcweir } 586cdf0e10cSrcweir 587cdf0e10cSrcweir //------------------------------------------------------------------------------ 588cdf0e10cSrcweir // XProgressHandler 589cdf0e10cSrcweir //------------------------------------------------------------------------------ 590cdf0e10cSrcweir void ProgressCmdEnv::push( uno::Any const & rStatus ) 591cdf0e10cSrcweir throw( uno::RuntimeException ) 592cdf0e10cSrcweir { 593cdf0e10cSrcweir update_( rStatus ); 594cdf0e10cSrcweir } 595cdf0e10cSrcweir 596cdf0e10cSrcweir //------------------------------------------------------------------------------ 597cdf0e10cSrcweir void ProgressCmdEnv::update_( uno::Any const & rStatus ) 598cdf0e10cSrcweir throw( uno::RuntimeException ) 599cdf0e10cSrcweir { 600cdf0e10cSrcweir OUString text; 601cdf0e10cSrcweir if ( rStatus.hasValue() && !( rStatus >>= text) ) 602cdf0e10cSrcweir { 603cdf0e10cSrcweir if ( rStatus.getValueTypeClass() == uno::TypeClass_EXCEPTION ) 604cdf0e10cSrcweir text = static_cast< uno::Exception const *>( rStatus.getValue() )->Message; 605cdf0e10cSrcweir if ( text.getLength() == 0 ) 606cdf0e10cSrcweir text = ::comphelper::anyToString( rStatus ); // fallback 607cdf0e10cSrcweir 608cdf0e10cSrcweir const ::vos::OGuard aGuard( Application::GetSolarMutex() ); 609cdf0e10cSrcweir const ::std::auto_ptr< ErrorBox > aBox( new ErrorBox( m_pDialogHelper? m_pDialogHelper->getWindow() : NULL, WB_OK, text ) ); 610cdf0e10cSrcweir aBox->Execute(); 611cdf0e10cSrcweir } 612cdf0e10cSrcweir ++m_nCurrentProgress; 613cdf0e10cSrcweir updateProgress(); 614cdf0e10cSrcweir } 615cdf0e10cSrcweir 616cdf0e10cSrcweir //------------------------------------------------------------------------------ 617cdf0e10cSrcweir void ProgressCmdEnv::update( uno::Any const & rStatus ) 618cdf0e10cSrcweir throw( uno::RuntimeException ) 619cdf0e10cSrcweir { 620cdf0e10cSrcweir update_( rStatus ); 621cdf0e10cSrcweir } 622cdf0e10cSrcweir 623cdf0e10cSrcweir //------------------------------------------------------------------------------ 624cdf0e10cSrcweir void ProgressCmdEnv::pop() 625cdf0e10cSrcweir throw( uno::RuntimeException ) 626cdf0e10cSrcweir { 627cdf0e10cSrcweir update_( uno::Any() ); // no message 628cdf0e10cSrcweir } 629cdf0e10cSrcweir 630cdf0e10cSrcweir //------------------------------------------------------------------------------ 631cdf0e10cSrcweir ExtensionCmdQueue::Thread::Thread( DialogHelper *pDialogHelper, 632cdf0e10cSrcweir TheExtensionManager *pManager, 633cdf0e10cSrcweir const uno::Reference< uno::XComponentContext > & rContext ) : 634cdf0e10cSrcweir m_xContext( rContext ), 635cdf0e10cSrcweir m_pDialogHelper( pDialogHelper ), 636cdf0e10cSrcweir m_pManager( pManager ), 637cdf0e10cSrcweir m_sEnablingPackages( DialogHelper::getResourceString( RID_STR_ENABLING_PACKAGES ) ), 638cdf0e10cSrcweir m_sDisablingPackages( DialogHelper::getResourceString( RID_STR_DISABLING_PACKAGES ) ), 639cdf0e10cSrcweir m_sAddingPackages( DialogHelper::getResourceString( RID_STR_ADDING_PACKAGES ) ), 640cdf0e10cSrcweir m_sRemovingPackages( DialogHelper::getResourceString( RID_STR_REMOVING_PACKAGES ) ), 641cdf0e10cSrcweir m_sDefaultCmd( DialogHelper::getResourceString( RID_STR_ADD_PACKAGES ) ), 642cdf0e10cSrcweir m_sAcceptLicense( DialogHelper::getResourceString( RID_STR_ACCEPT_LICENSE ) ), 643cdf0e10cSrcweir m_eInput( NONE ), 644cdf0e10cSrcweir m_bTerminated( false ), 645cdf0e10cSrcweir m_bStopped( false ), 646cdf0e10cSrcweir m_bWorking( false ) 647cdf0e10cSrcweir { 648cdf0e10cSrcweir OSL_ASSERT( pDialogHelper ); 649cdf0e10cSrcweir } 650cdf0e10cSrcweir 651cdf0e10cSrcweir //------------------------------------------------------------------------------ 652cdf0e10cSrcweir void ExtensionCmdQueue::Thread::addExtension( const ::rtl::OUString &rExtensionURL, 653cdf0e10cSrcweir const ::rtl::OUString &rRepository, 654cdf0e10cSrcweir const bool bWarnUser ) 655cdf0e10cSrcweir { 656cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_mutex ); 657cdf0e10cSrcweir 658cdf0e10cSrcweir //If someone called stop then we do not add the extension -> game over! 659cdf0e10cSrcweir if ( m_bStopped ) 660cdf0e10cSrcweir return; 661cdf0e10cSrcweir 662cdf0e10cSrcweir if ( rExtensionURL.getLength() ) 663cdf0e10cSrcweir { 664cdf0e10cSrcweir TExtensionCmd pEntry( new ExtensionCmd( ExtensionCmd::ADD, rExtensionURL, rRepository, bWarnUser ) ); 665cdf0e10cSrcweir 666cdf0e10cSrcweir m_queue.push( pEntry ); 667cdf0e10cSrcweir m_eInput = START; 668cdf0e10cSrcweir m_wakeup.set(); 669cdf0e10cSrcweir } 670cdf0e10cSrcweir } 671cdf0e10cSrcweir 672cdf0e10cSrcweir //------------------------------------------------------------------------------ 673cdf0e10cSrcweir void ExtensionCmdQueue::Thread::removeExtension( const uno::Reference< deployment::XPackage > &rPackage ) 674cdf0e10cSrcweir { 675cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_mutex ); 676cdf0e10cSrcweir 677cdf0e10cSrcweir //If someone called stop then we do not remove the extension -> game over! 678cdf0e10cSrcweir if ( m_bStopped ) 679cdf0e10cSrcweir return; 680cdf0e10cSrcweir 681cdf0e10cSrcweir if ( rPackage.is() ) 682cdf0e10cSrcweir { 683cdf0e10cSrcweir TExtensionCmd pEntry( new ExtensionCmd( ExtensionCmd::REMOVE, rPackage ) ); 684cdf0e10cSrcweir 685cdf0e10cSrcweir m_queue.push( pEntry ); 686cdf0e10cSrcweir m_eInput = START; 687cdf0e10cSrcweir m_wakeup.set(); 688cdf0e10cSrcweir } 689cdf0e10cSrcweir } 690cdf0e10cSrcweir 691cdf0e10cSrcweir //------------------------------------------------------------------------------ 692cdf0e10cSrcweir void ExtensionCmdQueue::Thread::acceptLicense( const uno::Reference< deployment::XPackage > &rPackage ) 693cdf0e10cSrcweir { 694cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_mutex ); 695cdf0e10cSrcweir 696cdf0e10cSrcweir //If someone called stop then we do not remove the extension -> game over! 697cdf0e10cSrcweir if ( m_bStopped ) 698cdf0e10cSrcweir return; 699cdf0e10cSrcweir 700cdf0e10cSrcweir if ( rPackage.is() ) 701cdf0e10cSrcweir { 702cdf0e10cSrcweir TExtensionCmd pEntry( new ExtensionCmd( ExtensionCmd::ACCEPT_LICENSE, rPackage ) ); 703cdf0e10cSrcweir 704cdf0e10cSrcweir m_queue.push( pEntry ); 705cdf0e10cSrcweir m_eInput = START; 706cdf0e10cSrcweir m_wakeup.set(); 707cdf0e10cSrcweir } 708cdf0e10cSrcweir } 709cdf0e10cSrcweir 710cdf0e10cSrcweir //------------------------------------------------------------------------------ 711cdf0e10cSrcweir void ExtensionCmdQueue::Thread::enableExtension( const uno::Reference< deployment::XPackage > &rPackage, 712cdf0e10cSrcweir const bool bEnable ) 713cdf0e10cSrcweir { 714cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_mutex ); 715cdf0e10cSrcweir 716cdf0e10cSrcweir //If someone called stop then we do not remove the extension -> game over! 717cdf0e10cSrcweir if ( m_bStopped ) 718cdf0e10cSrcweir return; 719cdf0e10cSrcweir 720cdf0e10cSrcweir if ( rPackage.is() ) 721cdf0e10cSrcweir { 722cdf0e10cSrcweir TExtensionCmd pEntry( new ExtensionCmd( bEnable ? ExtensionCmd::ENABLE : 723cdf0e10cSrcweir ExtensionCmd::DISABLE, 724cdf0e10cSrcweir rPackage ) ); 725cdf0e10cSrcweir m_queue.push( pEntry ); 726cdf0e10cSrcweir m_eInput = START; 727cdf0e10cSrcweir m_wakeup.set(); 728cdf0e10cSrcweir } 729cdf0e10cSrcweir } 730cdf0e10cSrcweir 731cdf0e10cSrcweir //------------------------------------------------------------------------------ 732cdf0e10cSrcweir void ExtensionCmdQueue::Thread::checkForUpdates( 733cdf0e10cSrcweir const std::vector<uno::Reference<deployment::XPackage > > &vExtensionList ) 734cdf0e10cSrcweir { 735cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_mutex ); 736cdf0e10cSrcweir 737cdf0e10cSrcweir //If someone called stop then we do not update the extension -> game over! 738cdf0e10cSrcweir if ( m_bStopped ) 739cdf0e10cSrcweir return; 740cdf0e10cSrcweir 741cdf0e10cSrcweir TExtensionCmd pEntry( new ExtensionCmd( ExtensionCmd::CHECK_FOR_UPDATES, vExtensionList ) ); 742cdf0e10cSrcweir m_queue.push( pEntry ); 743cdf0e10cSrcweir m_eInput = START; 744cdf0e10cSrcweir m_wakeup.set(); 745cdf0e10cSrcweir } 746cdf0e10cSrcweir 747cdf0e10cSrcweir //------------------------------------------------------------------------------ 748cdf0e10cSrcweir //Stopping this thread will not abort the installation of extensions. 749cdf0e10cSrcweir void ExtensionCmdQueue::Thread::stop() 750cdf0e10cSrcweir { 751cdf0e10cSrcweir osl::MutexGuard aGuard( m_mutex ); 752cdf0e10cSrcweir m_bStopped = true; 753cdf0e10cSrcweir m_eInput = STOP; 754cdf0e10cSrcweir m_wakeup.set(); 755cdf0e10cSrcweir } 756cdf0e10cSrcweir 757cdf0e10cSrcweir //------------------------------------------------------------------------------ 758cdf0e10cSrcweir bool ExtensionCmdQueue::Thread::isBusy() 759cdf0e10cSrcweir { 760cdf0e10cSrcweir osl::MutexGuard aGuard( m_mutex ); 761cdf0e10cSrcweir return m_bWorking; 762cdf0e10cSrcweir } 763cdf0e10cSrcweir 764cdf0e10cSrcweir //------------------------------------------------------------------------------ 765cdf0e10cSrcweir ExtensionCmdQueue::Thread::~Thread() {} 766cdf0e10cSrcweir 767cdf0e10cSrcweir //------------------------------------------------------------------------------ 768cdf0e10cSrcweir void ExtensionCmdQueue::Thread::execute() 769cdf0e10cSrcweir { 770cdf0e10cSrcweir #ifdef WNT 771cdf0e10cSrcweir //Needed for use of the service "com.sun.star.system.SystemShellExecute" in 772cdf0e10cSrcweir //DialogHelper::openWebBrowser 773cdf0e10cSrcweir CoUninitialize(); 774cdf0e10cSrcweir HRESULT r = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); 775cdf0e10cSrcweir #endif 776cdf0e10cSrcweir for (;;) 777cdf0e10cSrcweir { 778cdf0e10cSrcweir if ( m_wakeup.wait() != osl::Condition::result_ok ) 779cdf0e10cSrcweir { 780cdf0e10cSrcweir dp_misc::TRACE( "dp_gui::ExtensionCmdQueue::Thread::run: ignored " 781cdf0e10cSrcweir "osl::Condition::wait failure\n" ); 782cdf0e10cSrcweir } 783cdf0e10cSrcweir m_wakeup.reset(); 784cdf0e10cSrcweir 785cdf0e10cSrcweir int nSize; 786cdf0e10cSrcweir Input eInput; 787cdf0e10cSrcweir { 788cdf0e10cSrcweir osl::MutexGuard aGuard( m_mutex ); 789cdf0e10cSrcweir eInput = m_eInput; 790cdf0e10cSrcweir m_eInput = NONE; 791cdf0e10cSrcweir nSize = m_queue.size(); 792cdf0e10cSrcweir m_bWorking = false; 793cdf0e10cSrcweir } 794cdf0e10cSrcweir 795cdf0e10cSrcweir // If this thread has been woken up by anything else except start, stop 796cdf0e10cSrcweir // then input is NONE and we wait again. 797cdf0e10cSrcweir // We only install the extension which are currently in the queue. 798cdf0e10cSrcweir // The progressbar will be set to show the progress of the current number 799cdf0e10cSrcweir // of extensions. If we allowed to add extensions now then the progressbar may 800cdf0e10cSrcweir // have reached the end while we still install newly added extensions. 801cdf0e10cSrcweir if ( ( eInput == NONE ) || ( nSize == 0 ) ) 802cdf0e10cSrcweir continue; 803cdf0e10cSrcweir if ( eInput == STOP ) 804cdf0e10cSrcweir break; 805cdf0e10cSrcweir 806cdf0e10cSrcweir ::rtl::Reference< ProgressCmdEnv > currentCmdEnv( new ProgressCmdEnv( m_xContext, m_pDialogHelper, m_sDefaultCmd ) ); 807cdf0e10cSrcweir 808cdf0e10cSrcweir // Do not lock the following part with addExtension. addExtension may be called in the main thread. 809cdf0e10cSrcweir // If the message box "Do you want to install the extension (or similar)" is shown and then 810cdf0e10cSrcweir // addExtension is called, which then blocks the main thread, then we deadlock. 811cdf0e10cSrcweir bool bStartProgress = true; 812cdf0e10cSrcweir 813cdf0e10cSrcweir while ( !currentCmdEnv->isAborted() && --nSize >= 0 ) 814cdf0e10cSrcweir { 815cdf0e10cSrcweir { 816cdf0e10cSrcweir osl::MutexGuard aGuard( m_mutex ); 817cdf0e10cSrcweir m_bWorking = true; 818cdf0e10cSrcweir } 819cdf0e10cSrcweir 820cdf0e10cSrcweir try 821cdf0e10cSrcweir { 822cdf0e10cSrcweir TExtensionCmd pEntry; 823cdf0e10cSrcweir { 824cdf0e10cSrcweir ::osl::MutexGuard queueGuard( m_mutex ); 825cdf0e10cSrcweir pEntry = m_queue.front(); 826cdf0e10cSrcweir m_queue.pop(); 827cdf0e10cSrcweir } 828cdf0e10cSrcweir 829cdf0e10cSrcweir if ( bStartProgress && ( pEntry->m_eCmdType != ExtensionCmd::CHECK_FOR_UPDATES ) ) 830cdf0e10cSrcweir { 831cdf0e10cSrcweir currentCmdEnv->startProgress(); 832cdf0e10cSrcweir bStartProgress = false; 833cdf0e10cSrcweir } 834cdf0e10cSrcweir 835cdf0e10cSrcweir switch ( pEntry->m_eCmdType ) { 836cdf0e10cSrcweir case ExtensionCmd::ADD : 837cdf0e10cSrcweir _addExtension( currentCmdEnv, pEntry->m_sExtensionURL, pEntry->m_sRepository, pEntry->m_bWarnUser ); 838cdf0e10cSrcweir break; 839cdf0e10cSrcweir case ExtensionCmd::REMOVE : 840cdf0e10cSrcweir _removeExtension( currentCmdEnv, pEntry->m_xPackage ); 841cdf0e10cSrcweir break; 842cdf0e10cSrcweir case ExtensionCmd::ENABLE : 843cdf0e10cSrcweir _enableExtension( currentCmdEnv, pEntry->m_xPackage ); 844cdf0e10cSrcweir break; 845cdf0e10cSrcweir case ExtensionCmd::DISABLE : 846cdf0e10cSrcweir _disableExtension( currentCmdEnv, pEntry->m_xPackage ); 847cdf0e10cSrcweir break; 848cdf0e10cSrcweir case ExtensionCmd::CHECK_FOR_UPDATES : 849cdf0e10cSrcweir _checkForUpdates( pEntry->m_vExtensionList ); 850cdf0e10cSrcweir break; 851cdf0e10cSrcweir case ExtensionCmd::ACCEPT_LICENSE : 852cdf0e10cSrcweir _acceptLicense( currentCmdEnv, pEntry->m_xPackage ); 853cdf0e10cSrcweir break; 854cdf0e10cSrcweir } 855cdf0e10cSrcweir } 856cdf0e10cSrcweir //catch ( deployment::DeploymentException &) 857cdf0e10cSrcweir //{ 858cdf0e10cSrcweir //} 859cdf0e10cSrcweir //catch ( lang::IllegalArgumentException &) 860cdf0e10cSrcweir //{ 861cdf0e10cSrcweir //} 862cdf0e10cSrcweir catch ( ucb::CommandAbortedException & ) 863cdf0e10cSrcweir { 864cdf0e10cSrcweir //This exception is thrown when the user clicks cancel on the progressbar. 865cdf0e10cSrcweir //Then we cancel the installation of all extensions and remove them from 866cdf0e10cSrcweir //the queue. 867cdf0e10cSrcweir { 868cdf0e10cSrcweir ::osl::MutexGuard queueGuard2(m_mutex); 869cdf0e10cSrcweir while ( --nSize >= 0 ) 870cdf0e10cSrcweir m_queue.pop(); 871cdf0e10cSrcweir } 872cdf0e10cSrcweir break; 873cdf0e10cSrcweir } 874cdf0e10cSrcweir catch ( ucb::CommandFailedException & ) 875cdf0e10cSrcweir { 876cdf0e10cSrcweir //This exception is thrown when a user clicked cancel in the messagebox which was 877cdf0e10cSrcweir //startet by the interaction handler. For example the user will be asked if he/she 878cdf0e10cSrcweir //really wants to install the extension. 879cdf0e10cSrcweir //These interaction are run for exectly one extension at a time. Therefore we continue 880cdf0e10cSrcweir //with installing the remaining extensions. 881cdf0e10cSrcweir continue; 882cdf0e10cSrcweir } 883cdf0e10cSrcweir catch ( uno::Exception & ) 884cdf0e10cSrcweir { 885cdf0e10cSrcweir //Todo display the user an error 886cdf0e10cSrcweir //see also DialogImpl::SyncPushButton::Click() 887cdf0e10cSrcweir uno::Any exc( ::cppu::getCaughtException() ); 888cdf0e10cSrcweir OUString msg; 889cdf0e10cSrcweir deployment::DeploymentException dpExc; 890cdf0e10cSrcweir if ((exc >>= dpExc) && 891cdf0e10cSrcweir dpExc.Cause.getValueTypeClass() == uno::TypeClass_EXCEPTION) 892cdf0e10cSrcweir { 893cdf0e10cSrcweir // notify error cause only: 894cdf0e10cSrcweir msg = reinterpret_cast< uno::Exception const * >( dpExc.Cause.getValue() )->Message; 895cdf0e10cSrcweir } 896cdf0e10cSrcweir if (msg.getLength() == 0) // fallback for debugging purposes 897cdf0e10cSrcweir msg = ::comphelper::anyToString(exc); 898cdf0e10cSrcweir 899cdf0e10cSrcweir const ::vos::OGuard guard( Application::GetSolarMutex() ); 900cdf0e10cSrcweir ::std::auto_ptr<ErrorBox> box( 901cdf0e10cSrcweir new ErrorBox( currentCmdEnv->activeDialog(), WB_OK, msg ) ); 902cdf0e10cSrcweir if ( m_pDialogHelper ) 903cdf0e10cSrcweir box->SetText( m_pDialogHelper->getWindow()->GetText() ); 904cdf0e10cSrcweir box->Execute(); 905cdf0e10cSrcweir //Continue with installation of the remaining extensions 906cdf0e10cSrcweir } 907cdf0e10cSrcweir { 908cdf0e10cSrcweir osl::MutexGuard aGuard( m_mutex ); 909cdf0e10cSrcweir m_bWorking = false; 910cdf0e10cSrcweir } 911cdf0e10cSrcweir } 912cdf0e10cSrcweir 913cdf0e10cSrcweir { 914cdf0e10cSrcweir // when leaving the while loop with break, we should set working to false, too 915cdf0e10cSrcweir osl::MutexGuard aGuard( m_mutex ); 916cdf0e10cSrcweir m_bWorking = false; 917cdf0e10cSrcweir } 918cdf0e10cSrcweir 919cdf0e10cSrcweir if ( !bStartProgress ) 920cdf0e10cSrcweir currentCmdEnv->stopProgress(); 921cdf0e10cSrcweir } 922cdf0e10cSrcweir //end for 923cdf0e10cSrcweir //enable all buttons 924cdf0e10cSrcweir // m_pDialog->m_bAddingExtensions = false; 925cdf0e10cSrcweir // m_pDialog->updateButtonStates(); 926cdf0e10cSrcweir #ifdef WNT 927cdf0e10cSrcweir CoUninitialize(); 928cdf0e10cSrcweir #endif 929cdf0e10cSrcweir } 930cdf0e10cSrcweir 931cdf0e10cSrcweir //------------------------------------------------------------------------------ 932cdf0e10cSrcweir void ExtensionCmdQueue::Thread::_addExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, 933cdf0e10cSrcweir const OUString &rPackageURL, 934cdf0e10cSrcweir const OUString &rRepository, 935cdf0e10cSrcweir const bool bWarnUser ) 936cdf0e10cSrcweir { 937cdf0e10cSrcweir //check if we have a string in anyTitle. For example "unopkg gui \" caused anyTitle to be void 938cdf0e10cSrcweir //and anyTitle.get<OUString> throws as RuntimeException. 939cdf0e10cSrcweir uno::Any anyTitle; 940cdf0e10cSrcweir try 941cdf0e10cSrcweir { 942cdf0e10cSrcweir anyTitle = ::ucbhelper::Content( rPackageURL, rCmdEnv.get() ).getPropertyValue( OUSTR("Title") ); 943cdf0e10cSrcweir } 944cdf0e10cSrcweir catch ( uno::Exception & ) 945cdf0e10cSrcweir { 946cdf0e10cSrcweir return; 947cdf0e10cSrcweir } 948cdf0e10cSrcweir 949cdf0e10cSrcweir OUString sName; 950cdf0e10cSrcweir if ( ! (anyTitle >>= sName) ) 951cdf0e10cSrcweir { 952cdf0e10cSrcweir OSL_ENSURE(0, "Could not get file name for extension."); 953cdf0e10cSrcweir return; 954cdf0e10cSrcweir } 955cdf0e10cSrcweir 956cdf0e10cSrcweir rCmdEnv->setWarnUser( bWarnUser ); 957cdf0e10cSrcweir uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); 958cdf0e10cSrcweir uno::Reference< task::XAbortChannel > xAbortChannel( xExtMgr->createAbortChannel() ); 959cdf0e10cSrcweir OUString sTitle = searchAndReplaceAll( m_sAddingPackages, OUSTR("%EXTENSION_NAME"), sName ); 960cdf0e10cSrcweir rCmdEnv->progressSection( sTitle, xAbortChannel ); 961cdf0e10cSrcweir 962cdf0e10cSrcweir try 963cdf0e10cSrcweir { 964cdf0e10cSrcweir xExtMgr->addExtension(rPackageURL, uno::Sequence<beans::NamedValue>(), 965cdf0e10cSrcweir rRepository, xAbortChannel, rCmdEnv.get() ); 966cdf0e10cSrcweir } 967cdf0e10cSrcweir catch ( ucb::CommandFailedException & ) 968cdf0e10cSrcweir { 969cdf0e10cSrcweir // When the extension is already installed we'll get a dialog asking if we want to overwrite. If we then press 970cdf0e10cSrcweir // cancel this exception is thrown. 971cdf0e10cSrcweir } 972cdf0e10cSrcweir catch ( ucb::CommandAbortedException & ) 973cdf0e10cSrcweir { 974cdf0e10cSrcweir // User clicked the cancel button 975cdf0e10cSrcweir // TODO: handle cancel 976cdf0e10cSrcweir } 977cdf0e10cSrcweir rCmdEnv->setWarnUser( false ); 978cdf0e10cSrcweir } 979cdf0e10cSrcweir 980cdf0e10cSrcweir //------------------------------------------------------------------------------ 981cdf0e10cSrcweir void ExtensionCmdQueue::Thread::_removeExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, 982cdf0e10cSrcweir const uno::Reference< deployment::XPackage > &xPackage ) 983cdf0e10cSrcweir { 984cdf0e10cSrcweir uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); 985cdf0e10cSrcweir uno::Reference< task::XAbortChannel > xAbortChannel( xExtMgr->createAbortChannel() ); 986cdf0e10cSrcweir OUString sTitle = searchAndReplaceAll( m_sRemovingPackages, OUSTR("%EXTENSION_NAME"), xPackage->getDisplayName() ); 987cdf0e10cSrcweir rCmdEnv->progressSection( sTitle, xAbortChannel ); 988cdf0e10cSrcweir 989cdf0e10cSrcweir OUString id( dp_misc::getIdentifier( xPackage ) ); 990cdf0e10cSrcweir try 991cdf0e10cSrcweir { 992cdf0e10cSrcweir xExtMgr->removeExtension( id, xPackage->getName(), xPackage->getRepositoryName(), xAbortChannel, rCmdEnv.get() ); 993cdf0e10cSrcweir } 994cdf0e10cSrcweir catch ( deployment::DeploymentException & ) 995cdf0e10cSrcweir {} 996cdf0e10cSrcweir catch ( ucb::CommandFailedException & ) 997cdf0e10cSrcweir {} 998cdf0e10cSrcweir catch ( ucb::CommandAbortedException & ) 999cdf0e10cSrcweir {} 1000cdf0e10cSrcweir 1001cdf0e10cSrcweir // Check, if there are still updates to be notified via menu bar icon 1002cdf0e10cSrcweir uno::Sequence< uno::Sequence< rtl::OUString > > aItemList; 1003cdf0e10cSrcweir UpdateDialog::createNotifyJob( false, aItemList ); 1004cdf0e10cSrcweir } 1005cdf0e10cSrcweir 1006cdf0e10cSrcweir //------------------------------------------------------------------------------ 1007cdf0e10cSrcweir void ExtensionCmdQueue::Thread::_checkForUpdates( 1008cdf0e10cSrcweir const std::vector<uno::Reference<deployment::XPackage > > &vExtensionList ) 1009cdf0e10cSrcweir { 1010cdf0e10cSrcweir UpdateDialog* pUpdateDialog; 1011cdf0e10cSrcweir std::vector< UpdateData > vData; 1012cdf0e10cSrcweir 1013cdf0e10cSrcweir const ::vos::OGuard guard( Application::GetSolarMutex() ); 1014cdf0e10cSrcweir 1015cdf0e10cSrcweir pUpdateDialog = new UpdateDialog( m_xContext, m_pDialogHelper? m_pDialogHelper->getWindow() : NULL, vExtensionList, &vData ); 1016cdf0e10cSrcweir 1017cdf0e10cSrcweir pUpdateDialog->notifyMenubar( true, false ); // prepare the checking, if there updates to be notified via menu bar icon 1018cdf0e10cSrcweir 1019cdf0e10cSrcweir if ( ( pUpdateDialog->Execute() == RET_OK ) && !vData.empty() ) 1020cdf0e10cSrcweir { 1021cdf0e10cSrcweir // If there is at least one directly downloadable dialog then we 1022cdf0e10cSrcweir // open the install dialog. 1023cdf0e10cSrcweir ::std::vector< UpdateData > dataDownload; 1024cdf0e10cSrcweir int countWebsiteDownload = 0; 1025cdf0e10cSrcweir typedef std::vector< dp_gui::UpdateData >::const_iterator cit; 1026cdf0e10cSrcweir 1027cdf0e10cSrcweir for ( cit i = vData.begin(); i < vData.end(); i++ ) 1028cdf0e10cSrcweir { 1029cdf0e10cSrcweir if ( i->sWebsiteURL.getLength() > 0 ) 1030cdf0e10cSrcweir countWebsiteDownload ++; 1031cdf0e10cSrcweir else 1032cdf0e10cSrcweir dataDownload.push_back( *i ); 1033cdf0e10cSrcweir } 1034cdf0e10cSrcweir 1035cdf0e10cSrcweir short nDialogResult = RET_OK; 1036cdf0e10cSrcweir if ( !dataDownload.empty() ) 1037cdf0e10cSrcweir { 1038cdf0e10cSrcweir nDialogResult = UpdateInstallDialog( m_pDialogHelper? m_pDialogHelper->getWindow() : NULL, dataDownload, m_xContext ).Execute(); 1039cdf0e10cSrcweir pUpdateDialog->notifyMenubar( false, true ); // Check, if there are still pending updates to be notified via menu bar icon 1040cdf0e10cSrcweir } 1041cdf0e10cSrcweir else 1042cdf0e10cSrcweir pUpdateDialog->notifyMenubar( false, false ); // Check, if there are pending updates to be notified via menu bar icon 1043cdf0e10cSrcweir 1044cdf0e10cSrcweir //Now start the webbrowser and navigate to the websites where we get the updates 1045cdf0e10cSrcweir if ( RET_OK == nDialogResult ) 1046cdf0e10cSrcweir { 1047cdf0e10cSrcweir for ( cit i = vData.begin(); i < vData.end(); i++ ) 1048cdf0e10cSrcweir { 1049cdf0e10cSrcweir if ( m_pDialogHelper && ( i->sWebsiteURL.getLength() > 0 ) ) 1050cdf0e10cSrcweir m_pDialogHelper->openWebBrowser( i->sWebsiteURL, m_pDialogHelper->getWindow()->GetText() ); 1051cdf0e10cSrcweir } 1052cdf0e10cSrcweir } 1053cdf0e10cSrcweir } 1054cdf0e10cSrcweir else 1055cdf0e10cSrcweir pUpdateDialog->notifyMenubar( false, false ); // check if there updates to be notified via menu bar icon 1056cdf0e10cSrcweir 1057cdf0e10cSrcweir delete pUpdateDialog; 1058cdf0e10cSrcweir } 1059cdf0e10cSrcweir 1060cdf0e10cSrcweir //------------------------------------------------------------------------------ 1061cdf0e10cSrcweir void ExtensionCmdQueue::Thread::_enableExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, 1062cdf0e10cSrcweir const uno::Reference< deployment::XPackage > &xPackage ) 1063cdf0e10cSrcweir { 1064cdf0e10cSrcweir if ( !xPackage.is() ) 1065cdf0e10cSrcweir return; 1066cdf0e10cSrcweir 1067cdf0e10cSrcweir uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); 1068cdf0e10cSrcweir uno::Reference< task::XAbortChannel > xAbortChannel( xExtMgr->createAbortChannel() ); 1069cdf0e10cSrcweir OUString sTitle = searchAndReplaceAll( m_sEnablingPackages, OUSTR("%EXTENSION_NAME"), xPackage->getDisplayName() ); 1070cdf0e10cSrcweir rCmdEnv->progressSection( sTitle, xAbortChannel ); 1071cdf0e10cSrcweir 1072cdf0e10cSrcweir try 1073cdf0e10cSrcweir { 1074cdf0e10cSrcweir xExtMgr->enableExtension( xPackage, xAbortChannel, rCmdEnv.get() ); 1075cdf0e10cSrcweir if ( m_pDialogHelper ) 1076cdf0e10cSrcweir m_pDialogHelper->updatePackageInfo( xPackage ); 1077cdf0e10cSrcweir } 1078cdf0e10cSrcweir catch ( ::ucb::CommandAbortedException & ) 1079cdf0e10cSrcweir {} 1080cdf0e10cSrcweir } 1081cdf0e10cSrcweir 1082cdf0e10cSrcweir //------------------------------------------------------------------------------ 1083cdf0e10cSrcweir void ExtensionCmdQueue::Thread::_disableExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, 1084cdf0e10cSrcweir const uno::Reference< deployment::XPackage > &xPackage ) 1085cdf0e10cSrcweir { 1086cdf0e10cSrcweir if ( !xPackage.is() ) 1087cdf0e10cSrcweir return; 1088cdf0e10cSrcweir 1089cdf0e10cSrcweir uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); 1090cdf0e10cSrcweir uno::Reference< task::XAbortChannel > xAbortChannel( xExtMgr->createAbortChannel() ); 1091cdf0e10cSrcweir OUString sTitle = searchAndReplaceAll( m_sDisablingPackages, OUSTR("%EXTENSION_NAME"), xPackage->getDisplayName() ); 1092cdf0e10cSrcweir rCmdEnv->progressSection( sTitle, xAbortChannel ); 1093cdf0e10cSrcweir 1094cdf0e10cSrcweir try 1095cdf0e10cSrcweir { 1096cdf0e10cSrcweir xExtMgr->disableExtension( xPackage, xAbortChannel, rCmdEnv.get() ); 1097cdf0e10cSrcweir if ( m_pDialogHelper ) 1098cdf0e10cSrcweir m_pDialogHelper->updatePackageInfo( xPackage ); 1099cdf0e10cSrcweir } 1100cdf0e10cSrcweir catch ( ::ucb::CommandAbortedException & ) 1101cdf0e10cSrcweir {} 1102cdf0e10cSrcweir } 1103cdf0e10cSrcweir 1104cdf0e10cSrcweir //------------------------------------------------------------------------------ 1105cdf0e10cSrcweir void ExtensionCmdQueue::Thread::_acceptLicense( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, 1106cdf0e10cSrcweir const uno::Reference< deployment::XPackage > &xPackage ) 1107cdf0e10cSrcweir { 1108cdf0e10cSrcweir if ( !xPackage.is() ) 1109cdf0e10cSrcweir return; 1110cdf0e10cSrcweir 1111cdf0e10cSrcweir uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); 1112cdf0e10cSrcweir uno::Reference< task::XAbortChannel > xAbortChannel( xExtMgr->createAbortChannel() ); 1113cdf0e10cSrcweir OUString sTitle = searchAndReplaceAll( m_sAcceptLicense, OUSTR("%EXTENSION_NAME"), xPackage->getDisplayName() ); 1114cdf0e10cSrcweir rCmdEnv->progressSection( sTitle, xAbortChannel ); 1115cdf0e10cSrcweir 1116cdf0e10cSrcweir try 1117cdf0e10cSrcweir { 1118cdf0e10cSrcweir xExtMgr->checkPrerequisitesAndEnable( xPackage, xAbortChannel, rCmdEnv.get() ); 1119cdf0e10cSrcweir if ( m_pDialogHelper ) 1120cdf0e10cSrcweir m_pDialogHelper->updatePackageInfo( xPackage ); 1121cdf0e10cSrcweir } 1122cdf0e10cSrcweir catch ( ::ucb::CommandAbortedException & ) 1123cdf0e10cSrcweir {} 1124cdf0e10cSrcweir } 1125cdf0e10cSrcweir 1126cdf0e10cSrcweir //------------------------------------------------------------------------------ 1127cdf0e10cSrcweir void ExtensionCmdQueue::Thread::onTerminated() 1128cdf0e10cSrcweir { 1129cdf0e10cSrcweir ::osl::MutexGuard g(m_mutex); 1130cdf0e10cSrcweir m_bTerminated = true; 1131cdf0e10cSrcweir } 1132cdf0e10cSrcweir 1133cdf0e10cSrcweir //------------------------------------------------------------------------------ 1134cdf0e10cSrcweir OUString ExtensionCmdQueue::Thread::searchAndReplaceAll( const OUString &rSource, 1135cdf0e10cSrcweir const OUString &rWhat, 1136cdf0e10cSrcweir const OUString &rWith ) 1137cdf0e10cSrcweir { 1138cdf0e10cSrcweir OUString aRet( rSource ); 1139cdf0e10cSrcweir sal_Int32 nLen = rWhat.getLength(); 1140cdf0e10cSrcweir 1141cdf0e10cSrcweir if ( !nLen ) 1142cdf0e10cSrcweir return aRet; 1143cdf0e10cSrcweir 1144cdf0e10cSrcweir sal_Int32 nIndex = rSource.indexOf( rWhat ); 1145cdf0e10cSrcweir while ( nIndex != -1 ) 1146cdf0e10cSrcweir { 1147cdf0e10cSrcweir aRet = aRet.replaceAt( nIndex, nLen, rWith ); 1148cdf0e10cSrcweir nIndex = aRet.indexOf( rWhat, nIndex + rWith.getLength() ); 1149cdf0e10cSrcweir } 1150cdf0e10cSrcweir return aRet; 1151cdf0e10cSrcweir } 1152cdf0e10cSrcweir 1153cdf0e10cSrcweir 1154cdf0e10cSrcweir //------------------------------------------------------------------------------ 1155cdf0e10cSrcweir //------------------------------------------------------------------------------ 1156cdf0e10cSrcweir //------------------------------------------------------------------------------ 1157cdf0e10cSrcweir ExtensionCmdQueue::ExtensionCmdQueue( DialogHelper * pDialogHelper, 1158cdf0e10cSrcweir TheExtensionManager *pManager, 1159cdf0e10cSrcweir const uno::Reference< uno::XComponentContext > &rContext ) 1160cdf0e10cSrcweir : m_thread( new Thread( pDialogHelper, pManager, rContext ) ) 1161cdf0e10cSrcweir { 1162cdf0e10cSrcweir m_thread->launch(); 1163cdf0e10cSrcweir } 1164cdf0e10cSrcweir 1165cdf0e10cSrcweir ExtensionCmdQueue::~ExtensionCmdQueue() { 1166cdf0e10cSrcweir stop(); 1167cdf0e10cSrcweir } 1168cdf0e10cSrcweir 1169cdf0e10cSrcweir void ExtensionCmdQueue::addExtension( const ::rtl::OUString & extensionURL, 1170cdf0e10cSrcweir const ::rtl::OUString & repository, 1171cdf0e10cSrcweir const bool bWarnUser ) 1172cdf0e10cSrcweir { 1173cdf0e10cSrcweir m_thread->addExtension( extensionURL, repository, bWarnUser ); 1174cdf0e10cSrcweir } 1175cdf0e10cSrcweir 1176cdf0e10cSrcweir void ExtensionCmdQueue::removeExtension( const uno::Reference< deployment::XPackage > &rPackage ) 1177cdf0e10cSrcweir { 1178cdf0e10cSrcweir m_thread->removeExtension( rPackage ); 1179cdf0e10cSrcweir } 1180cdf0e10cSrcweir 1181cdf0e10cSrcweir void ExtensionCmdQueue::enableExtension( const uno::Reference< deployment::XPackage > &rPackage, 1182cdf0e10cSrcweir const bool bEnable ) 1183cdf0e10cSrcweir { 1184cdf0e10cSrcweir m_thread->enableExtension( rPackage, bEnable ); 1185cdf0e10cSrcweir } 1186cdf0e10cSrcweir 1187cdf0e10cSrcweir void ExtensionCmdQueue::checkForUpdates( const std::vector<uno::Reference<deployment::XPackage > > &vExtensionList ) 1188cdf0e10cSrcweir { 1189cdf0e10cSrcweir m_thread->checkForUpdates( vExtensionList ); 1190cdf0e10cSrcweir } 1191cdf0e10cSrcweir 1192cdf0e10cSrcweir void ExtensionCmdQueue::acceptLicense( const uno::Reference< deployment::XPackage > &rPackage ) 1193cdf0e10cSrcweir { 1194cdf0e10cSrcweir m_thread->acceptLicense( rPackage ); 1195cdf0e10cSrcweir } 1196cdf0e10cSrcweir 1197cdf0e10cSrcweir void ExtensionCmdQueue::syncRepositories( const uno::Reference< uno::XComponentContext > &xContext ) 1198cdf0e10cSrcweir { 1199cdf0e10cSrcweir dp_misc::syncRepositories( new ProgressCmdEnv( xContext, NULL, OUSTR("Extension Manager") ) ); 1200cdf0e10cSrcweir } 1201cdf0e10cSrcweir 1202cdf0e10cSrcweir void ExtensionCmdQueue::stop() 1203cdf0e10cSrcweir { 1204cdf0e10cSrcweir m_thread->stop(); 1205cdf0e10cSrcweir } 1206cdf0e10cSrcweir 1207cdf0e10cSrcweir bool ExtensionCmdQueue::isBusy() 1208cdf0e10cSrcweir { 1209cdf0e10cSrcweir return m_thread->isBusy(); 1210cdf0e10cSrcweir } 1211cdf0e10cSrcweir 1212cdf0e10cSrcweir void handleInteractionRequest( const uno::Reference< uno::XComponentContext > & xContext, 1213cdf0e10cSrcweir const uno::Reference< task::XInteractionRequest > & xRequest ) 1214cdf0e10cSrcweir { 1215cdf0e10cSrcweir ::rtl::Reference< ProgressCmdEnv > xCmdEnv( new ProgressCmdEnv( xContext, NULL, OUSTR("Extension Manager") ) ); 1216cdf0e10cSrcweir xCmdEnv->handle( xRequest ); 1217cdf0e10cSrcweir } 1218cdf0e10cSrcweir 1219cdf0e10cSrcweir } //namespace dp_gui 1220cdf0e10cSrcweir 1221