xref: /AOO41X/main/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx (revision 2722ceddc26af33ca9ed6a22fc3c4dfb805171c3)
1*2722ceddSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2722ceddSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2722ceddSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2722ceddSAndrew Rist  * distributed with this work for additional information
6*2722ceddSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2722ceddSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2722ceddSAndrew Rist  * "License"); you may not use this file except in compliance
9*2722ceddSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*2722ceddSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*2722ceddSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2722ceddSAndrew Rist  * software distributed under the License is distributed on an
15*2722ceddSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2722ceddSAndrew Rist  * KIND, either express or implied.  See the License for the
17*2722ceddSAndrew Rist  * specific language governing permissions and limitations
18*2722ceddSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*2722ceddSAndrew Rist  *************************************************************/
21*2722ceddSAndrew Rist 
22*2722ceddSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_desktop.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "dp_gui_updatedata.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "sal/config.h"
30cdf0e10cSrcweir #include "osl/file.hxx"
31cdf0e10cSrcweir #include "osl/conditn.hxx"
32cdf0e10cSrcweir #include "cppuhelper/exc_hlp.hxx"
33cdf0e10cSrcweir #include "tools/resid.hxx"
34cdf0e10cSrcweir #include "tools/resmgr.hxx"
35cdf0e10cSrcweir #include "tools/solar.h"
36cdf0e10cSrcweir #include "tools/string.hxx"
37cdf0e10cSrcweir #include "vcl/dialog.hxx"
38cdf0e10cSrcweir #include "vcl/msgbox.hxx"
39cdf0e10cSrcweir #include "vcl/svapp.hxx"
40cdf0e10cSrcweir #include "vos/mutex.hxx"
41cdf0e10cSrcweir #include "vcl/dialog.hxx"
42cdf0e10cSrcweir #include "cppuhelper/implbase3.hxx"
43cdf0e10cSrcweir 
44cdf0e10cSrcweir #include "com/sun/star/beans/PropertyValue.hpp"
45cdf0e10cSrcweir #include "com/sun/star/beans/NamedValue.hpp"
46cdf0e10cSrcweir #include "com/sun/star/xml/dom/XElement.hpp"
47cdf0e10cSrcweir #include "com/sun/star/xml/dom/XNode.hpp"
48cdf0e10cSrcweir #include "com/sun/star/xml/dom/XNodeList.hpp"
49cdf0e10cSrcweir #include "com/sun/star/ucb/NameClash.hpp"
50cdf0e10cSrcweir #include "com/sun/star/ucb/InteractiveAugmentedIOException.hpp"
51cdf0e10cSrcweir #include "com/sun/star/ucb/XCommandEnvironment.hpp"
52cdf0e10cSrcweir #include "com/sun/star/ucb/XProgressHandler.hpp"
53cdf0e10cSrcweir #include "com/sun/star/deployment/XExtensionManager.hpp"
54cdf0e10cSrcweir #include "com/sun/star/deployment/ExtensionManager.hpp"
55cdf0e10cSrcweir #include "com/sun/star/deployment/XUpdateInformationProvider.hpp"
56cdf0e10cSrcweir #include "com/sun/star/deployment/DependencyException.hpp"
57cdf0e10cSrcweir #include "com/sun/star/deployment/LicenseException.hpp"
58cdf0e10cSrcweir #include "com/sun/star/deployment/VersionException.hpp"
59cdf0e10cSrcweir #include "com/sun/star/deployment/ui/LicenseDialog.hpp"
60cdf0e10cSrcweir #include "com/sun/star/task/XInteractionHandler.hpp"
61cdf0e10cSrcweir #include "com/sun/star/ui/dialogs/XExecutableDialog.hpp"
62cdf0e10cSrcweir #include "com/sun/star/ui/dialogs/ExecutableDialogResults.hpp"
63cdf0e10cSrcweir #include "com/sun/star/task/XInteractionAbort.hpp"
64cdf0e10cSrcweir #include "com/sun/star/task/XInteractionApprove.hpp"
65cdf0e10cSrcweir 
66cdf0e10cSrcweir #include "dp_descriptioninfoset.hxx"
67cdf0e10cSrcweir #include "dp_gui.hrc"
68cdf0e10cSrcweir #include "dp_gui_updateinstalldialog.hxx"
69cdf0e10cSrcweir #include "dp_gui_shared.hxx"
70cdf0e10cSrcweir #include "dp_gui_updatedata.hxx"
71cdf0e10cSrcweir #include "dp_ucb.h"
72cdf0e10cSrcweir #include "dp_misc.h"
73cdf0e10cSrcweir #include "dp_version.hxx"
74cdf0e10cSrcweir #include "dp_gui_thread.hxx"
75cdf0e10cSrcweir #include "dp_gui_extensioncmdqueue.hxx"
76cdf0e10cSrcweir #include "ucbhelper/content.hxx"
77cdf0e10cSrcweir #include "osl/mutex.hxx"
78cdf0e10cSrcweir #include "vos/mutex.hxx"
79cdf0e10cSrcweir #include "rtl/ref.hxx"
80cdf0e10cSrcweir #include "com/sun/star/uno/Sequence.h"
81cdf0e10cSrcweir #include "comphelper/anytostring.hxx"
82cdf0e10cSrcweir #include "toolkit/helper/vclunohelper.hxx"
83cdf0e10cSrcweir 
84cdf0e10cSrcweir #include <vector>
85cdf0e10cSrcweir 
86cdf0e10cSrcweir class Window;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir namespace cssu = ::com::sun::star::uno;
89cdf0e10cSrcweir namespace css = ::com::sun::star;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir using ::rtl::OUString;
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 
94cdf0e10cSrcweir namespace dp_gui {
95cdf0e10cSrcweir 
96cdf0e10cSrcweir class UpdateInstallDialog::Thread: public dp_gui::Thread {
97cdf0e10cSrcweir     friend class UpdateCommandEnv;
98cdf0e10cSrcweir public:
99cdf0e10cSrcweir     Thread(cssu::Reference< cssu::XComponentContext > ctx,
100cdf0e10cSrcweir         UpdateInstallDialog & dialog, std::vector< dp_gui::UpdateData > & aVecUpdateData);
101cdf0e10cSrcweir 
102cdf0e10cSrcweir     void stop();
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 
106cdf0e10cSrcweir private:
107cdf0e10cSrcweir     Thread(Thread &); // not defined
108cdf0e10cSrcweir     void operator =(Thread &); // not defined
109cdf0e10cSrcweir 
110cdf0e10cSrcweir     virtual ~Thread();
111cdf0e10cSrcweir 
112cdf0e10cSrcweir     virtual void execute();
113cdf0e10cSrcweir     void downloadExtensions();
114cdf0e10cSrcweir     void download(::rtl::OUString const & aUrls, UpdateData & aUpdatData);
115cdf0e10cSrcweir     void installExtensions();
116cdf0e10cSrcweir     void removeTempDownloads();
117cdf0e10cSrcweir 
118cdf0e10cSrcweir     UpdateInstallDialog & m_dialog;
119cdf0e10cSrcweir     cssu::Reference< css::deployment::XUpdateInformationProvider >
120cdf0e10cSrcweir         m_updateInformation;
121cdf0e10cSrcweir 
122cdf0e10cSrcweir     // guarded by Application::GetSolarMutex():
123cdf0e10cSrcweir     cssu::Reference< css::task::XAbortChannel > m_abort;
124cdf0e10cSrcweir     cssu::Reference< cssu::XComponentContext > m_xComponentContext;
125cdf0e10cSrcweir     std::vector< dp_gui::UpdateData > & m_aVecUpdateData;
126cdf0e10cSrcweir     ::rtl::Reference<UpdateCommandEnv> m_updateCmdEnv;
127cdf0e10cSrcweir 
128cdf0e10cSrcweir     //A folder which is created in the temp directory in which then the updates are downloaded
129cdf0e10cSrcweir     ::rtl::OUString m_sDownloadFolder;
130cdf0e10cSrcweir 
131cdf0e10cSrcweir     bool m_stop;
132cdf0e10cSrcweir 
133cdf0e10cSrcweir };
134cdf0e10cSrcweir 
135cdf0e10cSrcweir class UpdateCommandEnv
136cdf0e10cSrcweir     : public ::cppu::WeakImplHelper3< css::ucb::XCommandEnvironment,
137cdf0e10cSrcweir                                       css::task::XInteractionHandler,
138cdf0e10cSrcweir                                       css::ucb::XProgressHandler >
139cdf0e10cSrcweir {
140cdf0e10cSrcweir     friend class UpdateInstallDialog::Thread;
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     UpdateInstallDialog & m_updateDialog;
143cdf0e10cSrcweir     ::rtl::Reference<UpdateInstallDialog::Thread> m_installThread;
144cdf0e10cSrcweir     cssu::Reference< cssu::XComponentContext > m_xContext;
145cdf0e10cSrcweir 
146cdf0e10cSrcweir public:
147cdf0e10cSrcweir     virtual ~UpdateCommandEnv();
148cdf0e10cSrcweir     UpdateCommandEnv( cssu::Reference< cssu::XComponentContext > const & xCtx,
149cdf0e10cSrcweir         UpdateInstallDialog & updateDialog,
150cdf0e10cSrcweir         ::rtl::Reference<UpdateInstallDialog::Thread>const & thread);
151cdf0e10cSrcweir 
152cdf0e10cSrcweir     // XCommandEnvironment
153cdf0e10cSrcweir     virtual cssu::Reference<css::task::XInteractionHandler > SAL_CALL
154cdf0e10cSrcweir     getInteractionHandler() throw (cssu::RuntimeException);
155cdf0e10cSrcweir     virtual cssu::Reference<css::ucb::XProgressHandler >
156cdf0e10cSrcweir     SAL_CALL getProgressHandler() throw (cssu::RuntimeException);
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     // XInteractionHandler
159cdf0e10cSrcweir     virtual void SAL_CALL handle(
160cdf0e10cSrcweir         cssu::Reference<css::task::XInteractionRequest > const & xRequest )
161cdf0e10cSrcweir         throw (cssu::RuntimeException);
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     // XProgressHandler
164cdf0e10cSrcweir     virtual void SAL_CALL push( cssu::Any const & Status )
165cdf0e10cSrcweir         throw (cssu::RuntimeException);
166cdf0e10cSrcweir     virtual void SAL_CALL update( cssu::Any const & Status )
167cdf0e10cSrcweir         throw (cssu::RuntimeException);
168cdf0e10cSrcweir     virtual void SAL_CALL pop() throw (cssu::RuntimeException);
169cdf0e10cSrcweir };
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 
Thread(cssu::Reference<cssu::XComponentContext> xCtx,UpdateInstallDialog & dialog,std::vector<dp_gui::UpdateData> & aVecUpdateData)172cdf0e10cSrcweir UpdateInstallDialog::Thread::Thread(
173cdf0e10cSrcweir     cssu::Reference< cssu::XComponentContext> xCtx,
174cdf0e10cSrcweir     UpdateInstallDialog & dialog,
175cdf0e10cSrcweir     std::vector< dp_gui::UpdateData > & aVecUpdateData):
176cdf0e10cSrcweir     m_dialog(dialog),
177cdf0e10cSrcweir     m_xComponentContext(xCtx),
178cdf0e10cSrcweir     m_aVecUpdateData(aVecUpdateData),
179cdf0e10cSrcweir     m_updateCmdEnv(new UpdateCommandEnv(xCtx, m_dialog, this)),
180cdf0e10cSrcweir     m_stop(false)
181cdf0e10cSrcweir {}
182cdf0e10cSrcweir 
stop()183cdf0e10cSrcweir void UpdateInstallDialog::Thread::stop() {
184cdf0e10cSrcweir     cssu::Reference< css::task::XAbortChannel > abort;
185cdf0e10cSrcweir     {
186cdf0e10cSrcweir         vos::OGuard g(Application::GetSolarMutex());
187cdf0e10cSrcweir         abort = m_abort;
188cdf0e10cSrcweir         m_stop = true;
189cdf0e10cSrcweir     }
190cdf0e10cSrcweir     if (abort.is()) {
191cdf0e10cSrcweir         abort->sendAbort();
192cdf0e10cSrcweir     }
193cdf0e10cSrcweir }
194cdf0e10cSrcweir 
~Thread()195cdf0e10cSrcweir UpdateInstallDialog::Thread::~Thread() {}
196cdf0e10cSrcweir 
execute()197cdf0e10cSrcweir void UpdateInstallDialog::Thread::execute()
198cdf0e10cSrcweir {
199cdf0e10cSrcweir     try {
200cdf0e10cSrcweir         downloadExtensions();
201cdf0e10cSrcweir         installExtensions();
202cdf0e10cSrcweir     }
203cdf0e10cSrcweir     catch (...)
204cdf0e10cSrcweir     {
205cdf0e10cSrcweir     }
206cdf0e10cSrcweir 
207cdf0e10cSrcweir     //clean up the temp directories
208cdf0e10cSrcweir     try {
209cdf0e10cSrcweir         removeTempDownloads();
210cdf0e10cSrcweir     } catch( ... ) {
211cdf0e10cSrcweir     }
212cdf0e10cSrcweir 
213cdf0e10cSrcweir     {
214cdf0e10cSrcweir         //make sure m_dialog is still alive
215cdf0e10cSrcweir         ::vos::OGuard g(Application::GetSolarMutex());
216cdf0e10cSrcweir         if (! m_stop)
217cdf0e10cSrcweir              m_dialog.updateDone();
218cdf0e10cSrcweir     }
219cdf0e10cSrcweir     //UpdateCommandEnv keeps a reference to Thread and prevents destruction. Therefore remove it.
220cdf0e10cSrcweir     m_updateCmdEnv->m_installThread.clear();
221cdf0e10cSrcweir }
222cdf0e10cSrcweir 
223cdf0e10cSrcweir 
UpdateInstallDialog(Window * parent,std::vector<dp_gui::UpdateData> & aVecUpdateData,cssu::Reference<cssu::XComponentContext> const & xCtx)224cdf0e10cSrcweir UpdateInstallDialog::UpdateInstallDialog(
225cdf0e10cSrcweir     Window * parent,
226cdf0e10cSrcweir     std::vector<dp_gui::UpdateData> & aVecUpdateData,
227cdf0e10cSrcweir     cssu::Reference< cssu::XComponentContext > const & xCtx):
228cdf0e10cSrcweir     ModalDialog(
229cdf0e10cSrcweir         parent,
230cdf0e10cSrcweir         DpGuiResId(RID_DLG_UPDATEINSTALL)),
231cdf0e10cSrcweir 
232cdf0e10cSrcweir         m_thread(new Thread(xCtx, *this, aVecUpdateData)),
233cdf0e10cSrcweir         m_xComponentContext(xCtx),
234cdf0e10cSrcweir         m_bError(false),
235cdf0e10cSrcweir         m_bNoEntry(true),
236cdf0e10cSrcweir         m_bActivated(false),
237cdf0e10cSrcweir         m_sInstalling(String(DpGuiResId(RID_DLG_UPDATE_INSTALL_INSTALLING))),
238cdf0e10cSrcweir         m_sFinished(String(DpGuiResId(RID_DLG_UPDATE_INSTALL_FINISHED))),
239cdf0e10cSrcweir         m_sNoErrors(String(DpGuiResId(RID_DLG_UPDATE_INSTALL_NO_ERRORS))),
240cdf0e10cSrcweir         m_sErrorDownload(String(DpGuiResId(RID_DLG_UPDATE_INSTALL_ERROR_DOWNLOAD))),
241cdf0e10cSrcweir         m_sErrorInstallation(String(DpGuiResId(RID_DLG_UPDATE_INSTALL_ERROR_INSTALLATION))),
242cdf0e10cSrcweir         m_sErrorLicenseDeclined(String(DpGuiResId(RID_DLG_UPDATE_INSTALL_ERROR_LIC_DECLINED))),
243cdf0e10cSrcweir         m_sNoInstall(String(DpGuiResId(RID_DLG_UPDATE_INSTALL_EXTENSION_NOINSTALL))),
244cdf0e10cSrcweir         m_sThisErrorOccurred(String(DpGuiResId(RID_DLG_UPDATE_INSTALL_THIS_ERROR_OCCURRED))),
245cdf0e10cSrcweir         m_ft_action(this, DpGuiResId(RID_DLG_UPDATE_INSTALL_DOWNLOADING)),
246cdf0e10cSrcweir         m_statusbar(this,DpGuiResId(RID_DLG_UPDATE_INSTALL_STATUSBAR)),
247cdf0e10cSrcweir         m_ft_extension_name(this, DpGuiResId(RID_DLG_UPDATE_INSTALL_EXTENSION_NAME)),
248cdf0e10cSrcweir         m_ft_results(this, DpGuiResId(RID_DLG_UPDATE_INSTALL_RESULTS)),
249cdf0e10cSrcweir         m_mle_info(this, DpGuiResId(RID_DLG_UPDATE_INSTALL_INFO)),
250cdf0e10cSrcweir         m_line(this, DpGuiResId(RID_DLG_UPDATE_INSTALL_LINE)),
251cdf0e10cSrcweir         m_help(this, DpGuiResId(RID_DLG_UPDATE_INSTALL_HELP)),
252cdf0e10cSrcweir         m_ok(this, DpGuiResId(RID_DLG_UPDATE_INSTALL_OK)),
253cdf0e10cSrcweir         m_cancel(this, DpGuiResId(RID_DLG_UPDATE_INSTALL_ABORT))
254cdf0e10cSrcweir {
255cdf0e10cSrcweir     FreeResource();
256cdf0e10cSrcweir 
257cdf0e10cSrcweir     m_xExtensionManager = css::deployment::ExtensionManager::get( xCtx );
258cdf0e10cSrcweir 
259cdf0e10cSrcweir     m_cancel.SetClickHdl(LINK(this, UpdateInstallDialog, cancelHandler));
260cdf0e10cSrcweir     m_mle_info.EnableCursor(sal_False);
261cdf0e10cSrcweir     if ( ! dp_misc::office_is_running())
262cdf0e10cSrcweir         m_help.Disable();
263cdf0e10cSrcweir }
264cdf0e10cSrcweir 
~UpdateInstallDialog()265cdf0e10cSrcweir UpdateInstallDialog::~UpdateInstallDialog() {}
266cdf0e10cSrcweir 
Close()267cdf0e10cSrcweir sal_Bool UpdateInstallDialog::Close()
268cdf0e10cSrcweir {
269cdf0e10cSrcweir     m_thread->stop();
270cdf0e10cSrcweir     return ModalDialog::Close();
271cdf0e10cSrcweir }
272cdf0e10cSrcweir 
Execute()273cdf0e10cSrcweir short UpdateInstallDialog::Execute()
274cdf0e10cSrcweir {
275cdf0e10cSrcweir     m_thread->launch();
276cdf0e10cSrcweir     return ModalDialog::Execute();
277cdf0e10cSrcweir }
278cdf0e10cSrcweir 
279cdf0e10cSrcweir 
280cdf0e10cSrcweir // make sure the solar mutex is locked before calling
updateDone()281cdf0e10cSrcweir void UpdateInstallDialog::updateDone()
282cdf0e10cSrcweir {
283cdf0e10cSrcweir     if (!m_bError)
284cdf0e10cSrcweir         m_mle_info.InsertText(m_sNoErrors);
285cdf0e10cSrcweir     m_ok.Enable();
286cdf0e10cSrcweir     m_ok.GrabFocus();
287cdf0e10cSrcweir     m_cancel.Disable();
288cdf0e10cSrcweir }
289cdf0e10cSrcweir // make sure the solar mutex is locked before calling
290cdf0e10cSrcweir //sets an error message in the text area
setError(INSTALL_ERROR err,::rtl::OUString const & sExtension,OUString const & exceptionMessage)291cdf0e10cSrcweir void UpdateInstallDialog::setError(INSTALL_ERROR err, ::rtl::OUString const & sExtension,
292cdf0e10cSrcweir     OUString const & exceptionMessage)
293cdf0e10cSrcweir {
294cdf0e10cSrcweir     String sError;
295cdf0e10cSrcweir     m_bError = true;
296cdf0e10cSrcweir 
297cdf0e10cSrcweir     switch (err)
298cdf0e10cSrcweir     {
299cdf0e10cSrcweir     case ERROR_DOWNLOAD:
300cdf0e10cSrcweir         sError = m_sErrorDownload;
301cdf0e10cSrcweir         break;
302cdf0e10cSrcweir     case ERROR_INSTALLATION:
303cdf0e10cSrcweir         sError = m_sErrorInstallation;
304cdf0e10cSrcweir         break;
305cdf0e10cSrcweir     case ERROR_LICENSE_DECLINED:
306cdf0e10cSrcweir         sError = m_sErrorLicenseDeclined;
307cdf0e10cSrcweir         break;
308cdf0e10cSrcweir 
309cdf0e10cSrcweir     default:
310cdf0e10cSrcweir         OSL_ASSERT(0);
311cdf0e10cSrcweir     }
312cdf0e10cSrcweir 
313cdf0e10cSrcweir     sError.SearchAndReplace(String(OUSTR("%NAME")), String(sExtension), 0);
314cdf0e10cSrcweir     //We want to have an empty line between the error messages. However,
315cdf0e10cSrcweir     //there shall be no empty line after the last entry.
316cdf0e10cSrcweir     if (m_bNoEntry)
317cdf0e10cSrcweir         m_bNoEntry = false;
318cdf0e10cSrcweir     else
319cdf0e10cSrcweir         m_mle_info.InsertText(OUSTR("\n"));
320cdf0e10cSrcweir     m_mle_info.InsertText(sError);
321cdf0e10cSrcweir     //Insert more information about the error
322cdf0e10cSrcweir     if (exceptionMessage.getLength())
323cdf0e10cSrcweir         m_mle_info.InsertText(m_sThisErrorOccurred + exceptionMessage + OUSTR("\n"));
324cdf0e10cSrcweir 
325cdf0e10cSrcweir     m_mle_info.InsertText(m_sNoInstall);
326cdf0e10cSrcweir     m_mle_info.InsertText(OUSTR("\n"));
327cdf0e10cSrcweir }
328cdf0e10cSrcweir 
setError(OUString const & exceptionMessage)329cdf0e10cSrcweir void UpdateInstallDialog::setError(OUString const & exceptionMessage)
330cdf0e10cSrcweir {
331cdf0e10cSrcweir     m_bError = true;
332cdf0e10cSrcweir     m_mle_info.InsertText(exceptionMessage + OUSTR("\n"));
333cdf0e10cSrcweir }
334cdf0e10cSrcweir 
IMPL_LINK(UpdateInstallDialog,cancelHandler,void *,EMPTYARG)335cdf0e10cSrcweir IMPL_LINK(UpdateInstallDialog, cancelHandler, void *, EMPTYARG)
336cdf0e10cSrcweir {
337cdf0e10cSrcweir     m_thread->stop();
338cdf0e10cSrcweir     EndDialog(RET_CANCEL);
339cdf0e10cSrcweir     return 0;
340cdf0e10cSrcweir }
341cdf0e10cSrcweir 
342cdf0e10cSrcweir //------------------------------------------------------------------------------------------------
343cdf0e10cSrcweir 
downloadExtensions()344cdf0e10cSrcweir void UpdateInstallDialog::Thread::downloadExtensions()
345cdf0e10cSrcweir {
346cdf0e10cSrcweir     try
347cdf0e10cSrcweir     {
348cdf0e10cSrcweir         //create the download directory in the temp folder
349cdf0e10cSrcweir         OUString sTempDir;
350cdf0e10cSrcweir         if (::osl::FileBase::getTempDirURL(sTempDir) != ::osl::FileBase::E_None)
351cdf0e10cSrcweir             throw cssu::Exception(OUSTR("Could not get URL for the temp directory. No extensions will be installed."), 0);
352cdf0e10cSrcweir 
353cdf0e10cSrcweir         //create a unique name for the directory
354cdf0e10cSrcweir         OUString tempEntry, destFolder;
355cdf0e10cSrcweir         if (::osl::File::createTempFile(&sTempDir, 0, &tempEntry ) != ::osl::File::E_None)
356cdf0e10cSrcweir             throw cssu::Exception(OUSTR("Could not create a temporary file in ") + sTempDir +
357cdf0e10cSrcweir              OUSTR(". No extensions will be installed"), 0 );
358cdf0e10cSrcweir 
359cdf0e10cSrcweir         tempEntry = tempEntry.copy( tempEntry.lastIndexOf( '/' ) + 1 );
360cdf0e10cSrcweir 
361cdf0e10cSrcweir         destFolder = dp_misc::makeURL( sTempDir, tempEntry );
362cdf0e10cSrcweir         destFolder += OUSTR("_");
363cdf0e10cSrcweir         m_sDownloadFolder = destFolder;
364cdf0e10cSrcweir         try
365cdf0e10cSrcweir         {
366cdf0e10cSrcweir             dp_misc::create_folder(0, destFolder, m_updateCmdEnv.get(), true );
367cdf0e10cSrcweir         } catch (cssu::Exception & e)
368cdf0e10cSrcweir         {
369cdf0e10cSrcweir             throw cssu::Exception(e.Message + OUSTR(" No extensions will be installed."), 0);
370cdf0e10cSrcweir         }
371cdf0e10cSrcweir 
372cdf0e10cSrcweir 
373cdf0e10cSrcweir         sal_uInt16 count = 0;
374cdf0e10cSrcweir         typedef std::vector<UpdateData>::iterator It;
375cdf0e10cSrcweir         for (It i = m_aVecUpdateData.begin(); i != m_aVecUpdateData.end(); i++)
376cdf0e10cSrcweir         {
377cdf0e10cSrcweir             UpdateData & curData = *i;
378cdf0e10cSrcweir 
379cdf0e10cSrcweir             if (!curData.aUpdateInfo.is() || curData.aUpdateSource.is())
380cdf0e10cSrcweir                 continue;
381cdf0e10cSrcweir             //We assume that m_aVecUpdateData contains only information about extensions which
382cdf0e10cSrcweir             //can be downloaded directly.
383cdf0e10cSrcweir             OSL_ASSERT(curData.sWebsiteURL.getLength() == 0);
384cdf0e10cSrcweir 
385cdf0e10cSrcweir 			//update the name of the extension which is to be downloaded
386cdf0e10cSrcweir             {
387cdf0e10cSrcweir                 ::vos::OGuard g(Application::GetSolarMutex());
388cdf0e10cSrcweir                 if (m_stop) {
389cdf0e10cSrcweir                     return;
390cdf0e10cSrcweir                 }
391cdf0e10cSrcweir                 m_dialog.m_ft_extension_name.SetText(curData.aInstalledPackage->getDisplayName());
392cdf0e10cSrcweir                 sal_uInt16 prog = (sal::static_int_cast<sal_uInt16>(100) * ++count) /
393cdf0e10cSrcweir                     sal::static_int_cast<sal_uInt16>(m_aVecUpdateData.size());
394cdf0e10cSrcweir                 m_dialog.m_statusbar.SetValue(prog);
395cdf0e10cSrcweir             }
396cdf0e10cSrcweir             dp_misc::DescriptionInfoset info(m_xComponentContext, curData.aUpdateInfo);
397cdf0e10cSrcweir             //remember occurring exceptions in case we need to print out error information
398cdf0e10cSrcweir             ::std::vector< ::std::pair<OUString, cssu::Exception> > vecExceptions;
399cdf0e10cSrcweir             cssu::Sequence<OUString> seqDownloadURLs = info.getUpdateDownloadUrls();
400cdf0e10cSrcweir             OSL_ENSURE(seqDownloadURLs.getLength() > 0, "No download URL provided!");
401cdf0e10cSrcweir             for (sal_Int32 j = 0; j < seqDownloadURLs.getLength(); j++)
402cdf0e10cSrcweir             {
403cdf0e10cSrcweir                 try
404cdf0e10cSrcweir                 {
405cdf0e10cSrcweir                     OSL_ENSURE(seqDownloadURLs[j].getLength() > 0, "Download URL is empty!");
406cdf0e10cSrcweir                     download(seqDownloadURLs[j], curData);
407cdf0e10cSrcweir                     if (curData.sLocalURL.getLength() > 0)
408cdf0e10cSrcweir                         break;
409cdf0e10cSrcweir                 }
410cdf0e10cSrcweir                 catch ( cssu::Exception & e )
411cdf0e10cSrcweir                 {
412cdf0e10cSrcweir                     vecExceptions.push_back( ::std::make_pair(seqDownloadURLs[j], e));
413cdf0e10cSrcweir                     //There can be several different errors, for example, the URL is wrong, webserver cannot be reached,
414cdf0e10cSrcweir                     //name cannot be resolved. The UCB helper API does not specify different special exceptions for these
415cdf0e10cSrcweir                     //cases. Therefore ignore and continue.
416cdf0e10cSrcweir                     continue;
417cdf0e10cSrcweir                 }
418cdf0e10cSrcweir             }
419cdf0e10cSrcweir             //update the progress and display download error
420cdf0e10cSrcweir             {
421cdf0e10cSrcweir                 ::vos::OGuard g(Application::GetSolarMutex());
422cdf0e10cSrcweir                 if (m_stop) {
423cdf0e10cSrcweir                     return;
424cdf0e10cSrcweir                 }
425cdf0e10cSrcweir                 if (curData.sLocalURL.getLength() == 0)
426cdf0e10cSrcweir                 {
427cdf0e10cSrcweir                     //Construct a string of all messages contained in the exceptions plus the respective download URLs
428cdf0e10cSrcweir                     ::rtl::OUStringBuffer buf(256);
429cdf0e10cSrcweir                     typedef ::std::vector< ::std::pair<OUString, cssu::Exception > >::const_iterator CIT;
430cdf0e10cSrcweir                     for (CIT j = vecExceptions.begin(); j != vecExceptions.end(); j++)
431cdf0e10cSrcweir                     {
432cdf0e10cSrcweir                         if (j != vecExceptions.begin())
433cdf0e10cSrcweir                             buf.appendAscii("\n");
434cdf0e10cSrcweir                         buf.append(OUSTR("Could not download "));
435cdf0e10cSrcweir                         buf.append(j->first);
436cdf0e10cSrcweir                         buf.appendAscii(". ");
437cdf0e10cSrcweir                         buf.append(j->second.Message);
438cdf0e10cSrcweir                     }
439cdf0e10cSrcweir                     m_dialog.setError(UpdateInstallDialog::ERROR_DOWNLOAD, curData.aInstalledPackage->getDisplayName(),
440cdf0e10cSrcweir                         buf.makeStringAndClear());
441cdf0e10cSrcweir                 }
442cdf0e10cSrcweir             }
443cdf0e10cSrcweir 
444cdf0e10cSrcweir         }
445cdf0e10cSrcweir     }
446cdf0e10cSrcweir     catch (cssu::Exception & e)
447cdf0e10cSrcweir     {
448cdf0e10cSrcweir         ::vos::OGuard g(Application::GetSolarMutex());
449cdf0e10cSrcweir         if (m_stop) {
450cdf0e10cSrcweir             return;
451cdf0e10cSrcweir         }
452cdf0e10cSrcweir         m_dialog.setError(e.Message);
453cdf0e10cSrcweir     }
454cdf0e10cSrcweir }
installExtensions()455cdf0e10cSrcweir void UpdateInstallDialog::Thread::installExtensions()
456cdf0e10cSrcweir {
457cdf0e10cSrcweir     //Update the fix text in the dialog to "Installing extensions..."
458cdf0e10cSrcweir     {
459cdf0e10cSrcweir         vos::OGuard g(Application::GetSolarMutex());
460cdf0e10cSrcweir         if (m_stop) {
461cdf0e10cSrcweir             return;
462cdf0e10cSrcweir         }
463cdf0e10cSrcweir         m_dialog.m_ft_action.SetText(m_dialog.m_sInstalling);
464cdf0e10cSrcweir         m_dialog.m_statusbar.SetValue(0);
465cdf0e10cSrcweir     }
466cdf0e10cSrcweir 
467cdf0e10cSrcweir     sal_uInt16 count = 0;
468cdf0e10cSrcweir     typedef std::vector<UpdateData>::iterator It;
469cdf0e10cSrcweir     for (It i = m_aVecUpdateData.begin(); i != m_aVecUpdateData.end(); i++, count++)
470cdf0e10cSrcweir     {
471cdf0e10cSrcweir         //update the name of the extension which is to be installed
472cdf0e10cSrcweir         {
473cdf0e10cSrcweir             ::vos::OGuard g(Application::GetSolarMutex());
474cdf0e10cSrcweir             if (m_stop) {
475cdf0e10cSrcweir                 return;
476cdf0e10cSrcweir             }
477cdf0e10cSrcweir             //we only show progress after an extension has been installed.
478cdf0e10cSrcweir             if (count > 0) {
479cdf0e10cSrcweir                 m_dialog.m_statusbar.SetValue(
480cdf0e10cSrcweir                 (sal::static_int_cast<sal_uInt16>(100) * count) /
481cdf0e10cSrcweir                 sal::static_int_cast<sal_uInt16>(m_aVecUpdateData.size()));
482cdf0e10cSrcweir              }
483cdf0e10cSrcweir             m_dialog.m_ft_extension_name.SetText(i->aInstalledPackage->getDisplayName());
484cdf0e10cSrcweir         }
485cdf0e10cSrcweir //         TimeValue v = {1, 0};
486cdf0e10cSrcweir //       osl::Thread::wait(v);
487cdf0e10cSrcweir         bool bError = false;
488cdf0e10cSrcweir         bool bLicenseDeclined = false;
489cdf0e10cSrcweir         cssu::Reference<css::deployment::XPackage> xExtension;
490cdf0e10cSrcweir         UpdateData & curData = *i;
491cdf0e10cSrcweir         cssu::Exception exc;
492cdf0e10cSrcweir         try
493cdf0e10cSrcweir         {
494cdf0e10cSrcweir             cssu::Reference< css::task::XAbortChannel > xAbortChannel(
495cdf0e10cSrcweir                 curData.aInstalledPackage->createAbortChannel() );
496cdf0e10cSrcweir             {
497cdf0e10cSrcweir                 vos::OGuard g(Application::GetSolarMutex());
498cdf0e10cSrcweir                 if (m_stop) {
499cdf0e10cSrcweir                     return;
500cdf0e10cSrcweir                 }
501cdf0e10cSrcweir                 m_abort = xAbortChannel;
502cdf0e10cSrcweir             }
503cdf0e10cSrcweir             if (!curData.aUpdateSource.is() && curData.sLocalURL.getLength())
504cdf0e10cSrcweir             {
505cdf0e10cSrcweir                 css::beans::NamedValue prop(OUSTR("EXTENSION_UPDATE"), css::uno::makeAny(OUSTR("1")));
506cdf0e10cSrcweir                 if (!curData.bIsShared)
507cdf0e10cSrcweir                     xExtension = m_dialog.getExtensionManager()->addExtension(
508cdf0e10cSrcweir                         curData.sLocalURL, css::uno::Sequence<css::beans::NamedValue>(&prop, 1),
509cdf0e10cSrcweir                         OUSTR("user"), xAbortChannel, m_updateCmdEnv.get());
510cdf0e10cSrcweir                 else
511cdf0e10cSrcweir                     xExtension = m_dialog.getExtensionManager()->addExtension(
512cdf0e10cSrcweir                         curData.sLocalURL, css::uno::Sequence<css::beans::NamedValue>(&prop, 1),
513cdf0e10cSrcweir                         OUSTR("shared"), xAbortChannel, m_updateCmdEnv.get());
514cdf0e10cSrcweir             }
515cdf0e10cSrcweir             else if (curData.aUpdateSource.is())
516cdf0e10cSrcweir             {
517cdf0e10cSrcweir                 OSL_ASSERT(curData.aUpdateSource.is());
518cdf0e10cSrcweir                 //I am not sure if we should obtain the install properties and pass them into
519cdf0e10cSrcweir                 //add extension. Currently it contains only "SUPPRESS_LICENSE". So it it could happen
520cdf0e10cSrcweir                 //that a license is displayed when updating from the shared repository, although the
521cdf0e10cSrcweir                 //shared extension was installed using "SUPPRESS_LICENSE".
522cdf0e10cSrcweir                 css::beans::NamedValue prop(OUSTR("EXTENSION_UPDATE"), css::uno::makeAny(OUSTR("1")));
523cdf0e10cSrcweir                 if (!curData.bIsShared)
524cdf0e10cSrcweir                     xExtension = m_dialog.getExtensionManager()->addExtension(
525cdf0e10cSrcweir                         curData.aUpdateSource->getURL(), css::uno::Sequence<css::beans::NamedValue>(&prop, 1),
526cdf0e10cSrcweir                         OUSTR("user"), xAbortChannel, m_updateCmdEnv.get());
527cdf0e10cSrcweir                 else
528cdf0e10cSrcweir                     xExtension = m_dialog.getExtensionManager()->addExtension(
529cdf0e10cSrcweir                         curData.aUpdateSource->getURL(), css::uno::Sequence<css::beans::NamedValue>(&prop, 1),
530cdf0e10cSrcweir                         OUSTR("shared"), xAbortChannel, m_updateCmdEnv.get());
531cdf0e10cSrcweir             }
532cdf0e10cSrcweir         }
533cdf0e10cSrcweir         catch (css::deployment::DeploymentException & de)
534cdf0e10cSrcweir         {
535cdf0e10cSrcweir             if (de.Cause.has<css::deployment::LicenseException>())
536cdf0e10cSrcweir             {
537cdf0e10cSrcweir                 bLicenseDeclined = true;
538cdf0e10cSrcweir             }
539cdf0e10cSrcweir             else
540cdf0e10cSrcweir             {
541cdf0e10cSrcweir                 exc = de.Cause.get<cssu::Exception>();
542cdf0e10cSrcweir                 bError = true;
543cdf0e10cSrcweir             }
544cdf0e10cSrcweir         }
545cdf0e10cSrcweir         catch (cssu::Exception& e)
546cdf0e10cSrcweir         {
547cdf0e10cSrcweir             exc = e;
548cdf0e10cSrcweir             bError = true;
549cdf0e10cSrcweir         }
550cdf0e10cSrcweir 
551cdf0e10cSrcweir         if (bLicenseDeclined)
552cdf0e10cSrcweir         {
553cdf0e10cSrcweir             ::vos::OGuard g(Application::GetSolarMutex());
554cdf0e10cSrcweir             if (m_stop) {
555cdf0e10cSrcweir                 return;
556cdf0e10cSrcweir             }
557cdf0e10cSrcweir             m_dialog.setError(UpdateInstallDialog::ERROR_LICENSE_DECLINED,
558cdf0e10cSrcweir                 curData.aInstalledPackage->getDisplayName(), OUString());
559cdf0e10cSrcweir         }
560cdf0e10cSrcweir         else if (!xExtension.is() || bError)
561cdf0e10cSrcweir         {
562cdf0e10cSrcweir             ::vos::OGuard g(Application::GetSolarMutex());
563cdf0e10cSrcweir             if (m_stop) {
564cdf0e10cSrcweir                 return;
565cdf0e10cSrcweir             }
566cdf0e10cSrcweir             m_dialog.setError(UpdateInstallDialog::ERROR_INSTALLATION,
567cdf0e10cSrcweir                 curData.aInstalledPackage->getDisplayName(), exc.Message);
568cdf0e10cSrcweir         }
569cdf0e10cSrcweir     }
570cdf0e10cSrcweir     {
571cdf0e10cSrcweir         vos::OGuard g(Application::GetSolarMutex());
572cdf0e10cSrcweir         if (m_stop) {
573cdf0e10cSrcweir             return;
574cdf0e10cSrcweir         }
575cdf0e10cSrcweir         m_dialog.m_statusbar.SetValue(100);
576cdf0e10cSrcweir         m_dialog.m_ft_extension_name.SetText(OUString());
577cdf0e10cSrcweir         m_dialog.m_ft_action.SetText(m_dialog.m_sFinished);
578cdf0e10cSrcweir     }
579cdf0e10cSrcweir }
580cdf0e10cSrcweir 
removeTempDownloads()581cdf0e10cSrcweir void UpdateInstallDialog::Thread::removeTempDownloads()
582cdf0e10cSrcweir {
583cdf0e10cSrcweir     if (m_sDownloadFolder.getLength())
584cdf0e10cSrcweir     {
585cdf0e10cSrcweir         dp_misc::erase_path(m_sDownloadFolder,
586cdf0e10cSrcweir             cssu::Reference<css::ucb::XCommandEnvironment>(),false /* no throw: ignore errors */ );
587cdf0e10cSrcweir         //remove also the temp file which we have used to create the unique name
588cdf0e10cSrcweir         OUString tempFile = m_sDownloadFolder.copy(0, m_sDownloadFolder.getLength() - 1);
589cdf0e10cSrcweir         dp_misc::erase_path(tempFile, cssu::Reference<css::ucb::XCommandEnvironment>(),false);
590cdf0e10cSrcweir         m_sDownloadFolder = OUString();
591cdf0e10cSrcweir     }
592cdf0e10cSrcweir }
593cdf0e10cSrcweir 
594cdf0e10cSrcweir 
download(OUString const & sDownloadURL,UpdateData & aUpdateData)595cdf0e10cSrcweir void UpdateInstallDialog::Thread::download(OUString const & sDownloadURL, UpdateData & aUpdateData)
596cdf0e10cSrcweir {
597cdf0e10cSrcweir     {
598cdf0e10cSrcweir         ::vos::OGuard g(Application::GetSolarMutex());
599cdf0e10cSrcweir         if (m_stop) {
600cdf0e10cSrcweir             return;
601cdf0e10cSrcweir         }
602cdf0e10cSrcweir     }
603cdf0e10cSrcweir 
604cdf0e10cSrcweir     OSL_ASSERT(m_sDownloadFolder.getLength());
605cdf0e10cSrcweir     OUString destFolder, tempEntry;
606cdf0e10cSrcweir     if (::osl::File::createTempFile(
607cdf0e10cSrcweir         &m_sDownloadFolder,
608cdf0e10cSrcweir         0, &tempEntry ) != ::osl::File::E_None)
609cdf0e10cSrcweir     {
610cdf0e10cSrcweir         //ToDo feedback in window that download of this component failed
611cdf0e10cSrcweir         throw cssu::Exception(OUSTR("Could not create temporary file in folder ") + destFolder + OUSTR("."), 0);
612cdf0e10cSrcweir     }
613cdf0e10cSrcweir     tempEntry = tempEntry.copy( tempEntry.lastIndexOf( '/' ) + 1 );
614cdf0e10cSrcweir 
615cdf0e10cSrcweir     destFolder = dp_misc::makeURL( m_sDownloadFolder, tempEntry );
616cdf0e10cSrcweir     destFolder += OUSTR("_");
617cdf0e10cSrcweir 
618cdf0e10cSrcweir     ::ucbhelper::Content destFolderContent;
619cdf0e10cSrcweir     dp_misc::create_folder( &destFolderContent, destFolder, m_updateCmdEnv.get() );
620cdf0e10cSrcweir 
621cdf0e10cSrcweir     ::ucbhelper::Content sourceContent;
622cdf0e10cSrcweir     dp_misc::create_ucb_content( &sourceContent, sDownloadURL, m_updateCmdEnv.get() );
623cdf0e10cSrcweir 
624cdf0e10cSrcweir 	const OUString sTitle(sourceContent.getPropertyValue(
625cdf0e10cSrcweir 		                  dp_misc::StrTitle::get() ).get<OUString>() );
626cdf0e10cSrcweir 
627cdf0e10cSrcweir 	if (destFolderContent.transferContent(
628cdf0e10cSrcweir             sourceContent, ::ucbhelper::InsertOperation_COPY,
629cdf0e10cSrcweir             sTitle, css::ucb::NameClash::OVERWRITE ))
630cdf0e10cSrcweir     {
631cdf0e10cSrcweir         //the user may have cancelled the dialog because downloading took to long
632cdf0e10cSrcweir         {
633cdf0e10cSrcweir             ::vos::OGuard g(Application::GetSolarMutex());
634cdf0e10cSrcweir             if (m_stop) {
635cdf0e10cSrcweir                 return;
636cdf0e10cSrcweir             }
637cdf0e10cSrcweir             //all errors should be handeld by the command environment.
638cdf0e10cSrcweir             aUpdateData.sLocalURL = destFolder + OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) + sTitle;
639cdf0e10cSrcweir         }
640cdf0e10cSrcweir     }
641cdf0e10cSrcweir }
642cdf0e10cSrcweir 
643cdf0e10cSrcweir 
644cdf0e10cSrcweir // -------------------------------------------------------------------------------------------------------
645cdf0e10cSrcweir 
UpdateCommandEnv(cssu::Reference<cssu::XComponentContext> const & xCtx,UpdateInstallDialog & updateDialog,::rtl::Reference<UpdateInstallDialog::Thread> const & thread)646cdf0e10cSrcweir UpdateCommandEnv::UpdateCommandEnv( cssu::Reference< cssu::XComponentContext > const & xCtx,
647cdf0e10cSrcweir     UpdateInstallDialog & updateDialog,
648cdf0e10cSrcweir     ::rtl::Reference<UpdateInstallDialog::Thread>const & thread)
649cdf0e10cSrcweir     : m_updateDialog( updateDialog ),
650cdf0e10cSrcweir     m_installThread(thread),
651cdf0e10cSrcweir     m_xContext(xCtx)
652cdf0e10cSrcweir {
653cdf0e10cSrcweir }
654cdf0e10cSrcweir 
~UpdateCommandEnv()655cdf0e10cSrcweir UpdateCommandEnv::~UpdateCommandEnv()
656cdf0e10cSrcweir {
657cdf0e10cSrcweir }
658cdf0e10cSrcweir 
659cdf0e10cSrcweir 
660cdf0e10cSrcweir // XCommandEnvironment
661cdf0e10cSrcweir //______________________________________________________________________________
getInteractionHandler()662cdf0e10cSrcweir cssu::Reference<css::task::XInteractionHandler> UpdateCommandEnv::getInteractionHandler()
663cdf0e10cSrcweir throw (cssu::RuntimeException)
664cdf0e10cSrcweir {
665cdf0e10cSrcweir     return this;
666cdf0e10cSrcweir }
667cdf0e10cSrcweir 
668cdf0e10cSrcweir //______________________________________________________________________________
getProgressHandler()669cdf0e10cSrcweir cssu::Reference<css::ucb::XProgressHandler> UpdateCommandEnv::getProgressHandler()
670cdf0e10cSrcweir throw (cssu::RuntimeException)
671cdf0e10cSrcweir {
672cdf0e10cSrcweir     return this;
673cdf0e10cSrcweir }
674cdf0e10cSrcweir 
675cdf0e10cSrcweir // XInteractionHandler
handle(cssu::Reference<css::task::XInteractionRequest> const & xRequest)676cdf0e10cSrcweir void UpdateCommandEnv::handle(
677cdf0e10cSrcweir     cssu::Reference< css::task::XInteractionRequest> const & xRequest )
678cdf0e10cSrcweir     throw (cssu::RuntimeException)
679cdf0e10cSrcweir {
680cdf0e10cSrcweir     cssu::Any request( xRequest->getRequest() );
681cdf0e10cSrcweir     OSL_ASSERT( request.getValueTypeClass() == cssu::TypeClass_EXCEPTION );
682cdf0e10cSrcweir     dp_misc::TRACE(OUSTR("[dp_gui_cmdenv.cxx] incoming request:\n")
683cdf0e10cSrcweir         + ::comphelper::anyToString(request) + OUSTR("\n\n"));
684cdf0e10cSrcweir 
685cdf0e10cSrcweir     css::deployment::VersionException verExc;
686cdf0e10cSrcweir     bool approve = false;
687cdf0e10cSrcweir     bool abort = false;
688cdf0e10cSrcweir 
689cdf0e10cSrcweir     if (request >>= verExc)
690cdf0e10cSrcweir     {   //We must catch the version exception during the update,
691cdf0e10cSrcweir         //because otherwise the user would be confronted with the dialogs, asking
692cdf0e10cSrcweir         //them if they want to replace an already installed version of the same extension.
693cdf0e10cSrcweir         //During an update we assume that we always want to replace the old version with the
694cdf0e10cSrcweir         //new version.
695cdf0e10cSrcweir         approve = true;
696cdf0e10cSrcweir     }
697cdf0e10cSrcweir 
698cdf0e10cSrcweir     if (approve == false && abort == false)
699cdf0e10cSrcweir     {
700cdf0e10cSrcweir         //forward to interaction handler for main dialog.
701cdf0e10cSrcweir         handleInteractionRequest( m_xContext, xRequest );
702cdf0e10cSrcweir     }
703cdf0e10cSrcweir     else
704cdf0e10cSrcweir 	{
705cdf0e10cSrcweir 	    // select:
706cdf0e10cSrcweir         cssu::Sequence< cssu::Reference< css::task::XInteractionContinuation > > conts(
707cdf0e10cSrcweir             xRequest->getContinuations() );
708cdf0e10cSrcweir         cssu::Reference< css::task::XInteractionContinuation > const * pConts =
709cdf0e10cSrcweir             conts.getConstArray();
710cdf0e10cSrcweir         sal_Int32 len = conts.getLength();
711cdf0e10cSrcweir         for ( sal_Int32 pos = 0; pos < len; ++pos )
712cdf0e10cSrcweir         {
713cdf0e10cSrcweir             if (approve) {
714cdf0e10cSrcweir                 cssu::Reference< css::task::XInteractionApprove > xInteractionApprove(
715cdf0e10cSrcweir                     pConts[ pos ], cssu::UNO_QUERY );
716cdf0e10cSrcweir                 if (xInteractionApprove.is()) {
717cdf0e10cSrcweir                     xInteractionApprove->select();
718cdf0e10cSrcweir                     // don't query again for ongoing continuations:
719cdf0e10cSrcweir                     approve = false;
720cdf0e10cSrcweir                 }
721cdf0e10cSrcweir             }
722cdf0e10cSrcweir             else if (abort) {
723cdf0e10cSrcweir                 cssu::Reference< css::task::XInteractionAbort > xInteractionAbort(
724cdf0e10cSrcweir                     pConts[ pos ], cssu::UNO_QUERY );
725cdf0e10cSrcweir                 if (xInteractionAbort.is()) {
726cdf0e10cSrcweir                     xInteractionAbort->select();
727cdf0e10cSrcweir                     // don't query again for ongoing continuations:
728cdf0e10cSrcweir                     abort = false;
729cdf0e10cSrcweir                 }
730cdf0e10cSrcweir             }
731cdf0e10cSrcweir         }
732cdf0e10cSrcweir 	}
733cdf0e10cSrcweir }
734cdf0e10cSrcweir 
735cdf0e10cSrcweir // XProgressHandler
push(cssu::Any const &)736cdf0e10cSrcweir void UpdateCommandEnv::push( cssu::Any const & /*Status*/ )
737cdf0e10cSrcweir throw (cssu::RuntimeException)
738cdf0e10cSrcweir {
739cdf0e10cSrcweir }
740cdf0e10cSrcweir 
741cdf0e10cSrcweir 
update(cssu::Any const &)742cdf0e10cSrcweir void UpdateCommandEnv::update( cssu::Any const & /*Status */)
743cdf0e10cSrcweir throw (cssu::RuntimeException)
744cdf0e10cSrcweir {
745cdf0e10cSrcweir }
746cdf0e10cSrcweir 
pop()747cdf0e10cSrcweir void UpdateCommandEnv::pop() throw (cssu::RuntimeException)
748cdf0e10cSrcweir {
749cdf0e10cSrcweir }
750cdf0e10cSrcweir 
751cdf0e10cSrcweir 
752cdf0e10cSrcweir } //end namespace dp_gui
753