1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_desktop.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "com/sun/star/deployment/VersionException.hpp" 32*cdf0e10cSrcweir #include "com/sun/star/deployment/LicenseException.hpp" 33*cdf0e10cSrcweir #include "com/sun/star/deployment/InstallException.hpp" 34*cdf0e10cSrcweir #include "com/sun/star/deployment/DependencyException.hpp" 35*cdf0e10cSrcweir #include "com/sun/star/deployment/PlatformException.hpp" 36*cdf0e10cSrcweir #include "com/sun/star/task/XInteractionApprove.hpp" 37*cdf0e10cSrcweir #include "com/sun/star/task/XInteractionAbort.hpp" 38*cdf0e10cSrcweir #include "com/sun/star/task/XInteractionHandler.hpp" 39*cdf0e10cSrcweir #include "com/sun/star/ucb/XCommandEnvironment.hpp" 40*cdf0e10cSrcweir #include "com/sun/star/uno/XComponentContext.hpp" 41*cdf0e10cSrcweir #include "dp_commandenvironments.hxx" 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir namespace deployment = com::sun::star::deployment; 44*cdf0e10cSrcweir namespace lang = com::sun::star::lang; 45*cdf0e10cSrcweir namespace task = com::sun::star::task; 46*cdf0e10cSrcweir namespace ucb = com::sun::star::ucb; 47*cdf0e10cSrcweir namespace uno = com::sun::star::uno; 48*cdf0e10cSrcweir namespace css = com::sun::star; 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir #define OUSTR(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 53*cdf0e10cSrcweir using ::rtl::OUString; 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir namespace dp_manager { 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir BaseCommandEnv::BaseCommandEnv() 58*cdf0e10cSrcweir { 59*cdf0e10cSrcweir } 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir BaseCommandEnv::BaseCommandEnv( 62*cdf0e10cSrcweir Reference< task::XInteractionHandler> const & handler) 63*cdf0e10cSrcweir : m_forwardHandler(handler) 64*cdf0e10cSrcweir { 65*cdf0e10cSrcweir } 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir BaseCommandEnv::~BaseCommandEnv() 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir } 70*cdf0e10cSrcweir // XCommandEnvironment 71*cdf0e10cSrcweir //______________________________________________________________________________ 72*cdf0e10cSrcweir Reference<task::XInteractionHandler> BaseCommandEnv::getInteractionHandler() 73*cdf0e10cSrcweir throw (uno::RuntimeException) 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir return this; 76*cdf0e10cSrcweir } 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir //______________________________________________________________________________ 79*cdf0e10cSrcweir Reference<ucb::XProgressHandler> BaseCommandEnv::getProgressHandler() 80*cdf0e10cSrcweir throw (uno::RuntimeException) 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir return this; 83*cdf0e10cSrcweir } 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir void BaseCommandEnv::handle( 86*cdf0e10cSrcweir Reference< task::XInteractionRequest> const & /*xRequest*/ ) 87*cdf0e10cSrcweir throw (uno::RuntimeException) 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir } 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir void BaseCommandEnv::handle_(bool approve, bool abort, 92*cdf0e10cSrcweir Reference< task::XInteractionRequest> const & xRequest ) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir if (approve == false && abort == false) 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir //not handled so far -> forwarding 97*cdf0e10cSrcweir if (m_forwardHandler.is()) 98*cdf0e10cSrcweir m_forwardHandler->handle(xRequest); 99*cdf0e10cSrcweir else 100*cdf0e10cSrcweir return; //cannot handle 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir else 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir // select: 105*cdf0e10cSrcweir uno::Sequence< Reference< task::XInteractionContinuation > > conts( 106*cdf0e10cSrcweir xRequest->getContinuations() ); 107*cdf0e10cSrcweir Reference< task::XInteractionContinuation > const * pConts = 108*cdf0e10cSrcweir conts.getConstArray(); 109*cdf0e10cSrcweir sal_Int32 len = conts.getLength(); 110*cdf0e10cSrcweir for ( sal_Int32 pos = 0; pos < len; ++pos ) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir if (approve) { 113*cdf0e10cSrcweir Reference< task::XInteractionApprove > xInteractionApprove( 114*cdf0e10cSrcweir pConts[ pos ], uno::UNO_QUERY ); 115*cdf0e10cSrcweir if (xInteractionApprove.is()) { 116*cdf0e10cSrcweir xInteractionApprove->select(); 117*cdf0e10cSrcweir // don't query again for ongoing continuations: 118*cdf0e10cSrcweir approve = false; 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir else if (abort) { 122*cdf0e10cSrcweir Reference< task::XInteractionAbort > xInteractionAbort( 123*cdf0e10cSrcweir pConts[ pos ], uno::UNO_QUERY ); 124*cdf0e10cSrcweir if (xInteractionAbort.is()) { 125*cdf0e10cSrcweir xInteractionAbort->select(); 126*cdf0e10cSrcweir // don't query again for ongoing continuations: 127*cdf0e10cSrcweir abort = false; 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir // XProgressHandler 136*cdf0e10cSrcweir void BaseCommandEnv::push( uno::Any const & /*Status*/ ) 137*cdf0e10cSrcweir throw (uno::RuntimeException) 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir void BaseCommandEnv::update( uno::Any const & /*Status */) 143*cdf0e10cSrcweir throw (uno::RuntimeException) 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir void BaseCommandEnv::pop() throw (uno::RuntimeException) 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir //============================================================================== 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir TmpRepositoryCommandEnv::TmpRepositoryCommandEnv() 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir TmpRepositoryCommandEnv::TmpRepositoryCommandEnv( 157*cdf0e10cSrcweir css::uno::Reference< css::task::XInteractionHandler> const & handler): 158*cdf0e10cSrcweir BaseCommandEnv(handler) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir // XInteractionHandler 162*cdf0e10cSrcweir void TmpRepositoryCommandEnv::handle( 163*cdf0e10cSrcweir Reference< task::XInteractionRequest> const & xRequest ) 164*cdf0e10cSrcweir throw (uno::RuntimeException) 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir uno::Any request( xRequest->getRequest() ); 167*cdf0e10cSrcweir OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION ); 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir deployment::VersionException verExc; 170*cdf0e10cSrcweir deployment::LicenseException licExc; 171*cdf0e10cSrcweir deployment::InstallException instExc; 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir bool approve = false; 174*cdf0e10cSrcweir bool abort = false; 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir if ((request >>= verExc) 177*cdf0e10cSrcweir || (request >>= licExc) 178*cdf0e10cSrcweir || (request >>= instExc)) 179*cdf0e10cSrcweir { 180*cdf0e10cSrcweir approve = true; 181*cdf0e10cSrcweir } 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir handle_(approve, abort, xRequest); 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir //================================================================================ 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir LicenseCommandEnv::LicenseCommandEnv( 188*cdf0e10cSrcweir css::uno::Reference< css::task::XInteractionHandler> const & handler, 189*cdf0e10cSrcweir bool bSuppressLicense, 190*cdf0e10cSrcweir OUString const & repository): 191*cdf0e10cSrcweir BaseCommandEnv(handler), m_repository(repository), 192*cdf0e10cSrcweir m_bSuppressLicense(bSuppressLicense) 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir // XInteractionHandler 196*cdf0e10cSrcweir void LicenseCommandEnv::handle( 197*cdf0e10cSrcweir Reference< task::XInteractionRequest> const & xRequest ) 198*cdf0e10cSrcweir throw (uno::RuntimeException) 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir uno::Any request( xRequest->getRequest() ); 201*cdf0e10cSrcweir OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION ); 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir deployment::LicenseException licExc; 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir bool approve = false; 207*cdf0e10cSrcweir bool abort = false; 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir if (request >>= licExc) 210*cdf0e10cSrcweir { 211*cdf0e10cSrcweir if (m_bSuppressLicense 212*cdf0e10cSrcweir || m_repository.equals(OUSTR("bundled")) 213*cdf0e10cSrcweir || licExc.AcceptBy.equals(OUSTR("admin"))) 214*cdf0e10cSrcweir { 215*cdf0e10cSrcweir //always approve in bundled case, because we do not support 216*cdf0e10cSrcweir //showing licenses anyway. 217*cdf0e10cSrcweir //The "admin" already accepted the license when installing the 218*cdf0e10cSrcweir // shared extension 219*cdf0e10cSrcweir approve = true; 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir } 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir handle_(approve, abort, xRequest); 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir //================================================================================ 227*cdf0e10cSrcweir //================================================================================ 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir NoLicenseCommandEnv::NoLicenseCommandEnv( 230*cdf0e10cSrcweir css::uno::Reference< css::task::XInteractionHandler> const & handler): 231*cdf0e10cSrcweir BaseCommandEnv(handler) 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir // XInteractionHandler 235*cdf0e10cSrcweir void NoLicenseCommandEnv::handle( 236*cdf0e10cSrcweir Reference< task::XInteractionRequest> const & xRequest ) 237*cdf0e10cSrcweir throw (uno::RuntimeException) 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir uno::Any request( xRequest->getRequest() ); 240*cdf0e10cSrcweir OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION ); 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir deployment::LicenseException licExc; 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir bool approve = false; 246*cdf0e10cSrcweir bool abort = false; 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir if (request >>= licExc) 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir approve = true; 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir handle_(approve, abort, xRequest); 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir // SilentCheckPrerequisitesCommandEnv::SilentCheckPrerequisitesCommandEnv( 256*cdf0e10cSrcweir // css::uno::Reference< css::task::XInteractionHandler> const & handler): 257*cdf0e10cSrcweir // BaseCommandEnv(handler) 258*cdf0e10cSrcweir // { 259*cdf0e10cSrcweir // } 260*cdf0e10cSrcweir SilentCheckPrerequisitesCommandEnv::SilentCheckPrerequisitesCommandEnv() 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir } 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir void SilentCheckPrerequisitesCommandEnv::handle( 265*cdf0e10cSrcweir Reference< task::XInteractionRequest> const & xRequest ) 266*cdf0e10cSrcweir throw (uno::RuntimeException) 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir uno::Any request( xRequest->getRequest() ); 269*cdf0e10cSrcweir OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION ); 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir deployment::LicenseException licExc; 272*cdf0e10cSrcweir deployment::PlatformException platformExc; 273*cdf0e10cSrcweir deployment::DependencyException depExc; 274*cdf0e10cSrcweir bool approve = false; 275*cdf0e10cSrcweir bool abort = false; 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir if (request >>= licExc) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir approve = true; 280*cdf0e10cSrcweir handle_(approve, abort, xRequest); 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir else if ((request >>= platformExc) 283*cdf0e10cSrcweir || (request >>= depExc)) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir m_Exception = request; 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir else 288*cdf0e10cSrcweir { 289*cdf0e10cSrcweir m_UnknownException = request; 290*cdf0e10cSrcweir } 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir // NoExceptionCommandEnv::NoExceptionCommandEnv( 293*cdf0e10cSrcweir // css::uno::Reference< css::task::XInteractionHandler> const & handler, 294*cdf0e10cSrcweir // css::uno::Type const & type): 295*cdf0e10cSrcweir // BaseCommandEnv(handler), 296*cdf0e10cSrcweir // m_type(type) 297*cdf0e10cSrcweir // { 298*cdf0e10cSrcweir // } 299*cdf0e10cSrcweir // // XInteractionHandler 300*cdf0e10cSrcweir // void NoExceptionCommandEnv::handle( 301*cdf0e10cSrcweir // Reference< task::XInteractionRequest> const & xRequest ) 302*cdf0e10cSrcweir // throw (uno::RuntimeException) 303*cdf0e10cSrcweir // { 304*cdf0e10cSrcweir // uno::Any request( xRequest->getRequest() ); 305*cdf0e10cSrcweir // OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION ); 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir // deployment::LicenseException licExc; 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir // bool approve = false; 311*cdf0e10cSrcweir // bool abort = false; 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir // if (request.getValueType() == m_type) 314*cdf0e10cSrcweir // { 315*cdf0e10cSrcweir // approve = true; 316*cdf0e10cSrcweir // } 317*cdf0e10cSrcweir // handle_(approve, abort, xRequest); 318*cdf0e10cSrcweir // } 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir } // namespace dp_manager 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir 325