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