Update ooo320-m1
[ooovba.git] / desktop / source / deployment / gui / dp_gui_updateinstalldialog.cxx
blobd58f74428618c9fce6b6de3934d013d1f9e33c18
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dp_gui_updateinstalldialog.cxx,v $
10 * $Revision: 1.9.76.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_desktop.hxx"
34 #include "dp_gui_updatedata.hxx"
36 #include "sal/config.h"
37 #include "osl/file.hxx"
38 #include "osl/conditn.hxx"
39 #include "cppuhelper/exc_hlp.hxx"
40 #include "tools/resid.hxx"
41 #include "tools/resmgr.hxx"
42 #include "tools/solar.h"
43 #include "tools/string.hxx"
44 #include "vcl/dialog.hxx"
45 #include "vcl/msgbox.hxx"
46 #include "vcl/svapp.hxx"
47 #include "vos/mutex.hxx"
48 #include "vcl/dialog.hxx"
49 #include "cppuhelper/implbase3.hxx"
51 #include "com/sun/star/beans/PropertyValue.hpp"
52 #include "com/sun/star/xml/dom/XElement.hpp"
53 #include "com/sun/star/xml/dom/XNode.hpp"
54 #include "com/sun/star/xml/dom/XNodeList.hpp"
55 #include "com/sun/star/ucb/NameClash.hpp"
56 #include "com/sun/star/ucb/InteractiveAugmentedIOException.hpp"
57 #include "com/sun/star/ucb/XCommandEnvironment.hpp"
58 #include "com/sun/star/ucb/XProgressHandler.hpp"
59 #include "com/sun/star/deployment/XPackageManager.hpp"
60 #include "com/sun/star/deployment/XUpdateInformationProvider.hpp"
61 #include "com/sun/star/deployment/DependencyException.hpp"
62 #include "com/sun/star/deployment/LicenseException.hpp"
63 #include "com/sun/star/deployment/VersionException.hpp"
64 #include "com/sun/star/deployment/ui/LicenseDialog.hpp"
65 #include "com/sun/star/task/XInteractionHandler.hpp"
66 #include "com/sun/star/ui/dialogs/XExecutableDialog.hpp"
67 #include "com/sun/star/ui/dialogs/ExecutableDialogResults.hpp"
68 #include "com/sun/star/task/XInteractionAbort.hpp"
69 #include "com/sun/star/task/XInteractionApprove.hpp"
71 #include "dp_descriptioninfoset.hxx"
72 #include "dp_gui.hrc"
73 #include "dp_gui_updateinstalldialog.hxx"
74 #include "dp_gui_shared.hxx"
75 #include "dp_gui_updatedata.hxx"
76 #include "dp_ucb.h"
77 #include "dp_misc.h"
78 #include "dp_version.hxx"
79 #include "dp_gui_thread.hxx"
80 #include "dp_gui_extensioncmdqueue.hxx"
81 #include "ucbhelper/content.hxx"
82 #include "osl/mutex.hxx"
83 #include "vos/mutex.hxx"
84 #include "rtl/ref.hxx"
85 #include "com/sun/star/uno/Sequence.h"
86 #include "comphelper/anytostring.hxx"
87 #include "toolkit/helper/vclunohelper.hxx"
89 #include <vector>
91 class Window;
93 namespace cssu = ::com::sun::star::uno;
94 namespace css = ::com::sun::star;
96 using ::rtl::OUString;
99 namespace dp_gui {
101 class UpdateInstallDialog::Thread: public dp_gui::Thread {
102 friend class UpdateCommandEnv;
103 public:
104 Thread(cssu::Reference< cssu::XComponentContext > ctx,
105 UpdateInstallDialog & dialog, std::vector< dp_gui::UpdateData > & aVecUpdateData);
107 void stop();
111 private:
112 Thread(Thread &); // not defined
113 void operator =(Thread &); // not defined
115 virtual ~Thread();
117 virtual void execute();
118 void downloadExtensions();
119 void download(::rtl::OUString const & aUrls, UpdateData & aUpdatData);
120 void installExtensions();
121 void removeTempDownloads();
123 UpdateInstallDialog & m_dialog;
124 cssu::Reference< css::deployment::XUpdateInformationProvider >
125 m_updateInformation;
127 // guarded by Application::GetSolarMutex():
128 cssu::Reference< css::task::XAbortChannel > m_abort;
129 cssu::Reference< cssu::XComponentContext > m_xComponentContext;
130 std::vector< dp_gui::UpdateData > & m_aVecUpdateData;
131 ::rtl::Reference<UpdateCommandEnv> m_updateCmdEnv;
133 //A folder which is created in the temp directory in which then the updates are downloaded
134 ::rtl::OUString m_sDownloadFolder;
136 bool m_stop;
140 class UpdateCommandEnv
141 : public ::cppu::WeakImplHelper3< css::ucb::XCommandEnvironment,
142 css::task::XInteractionHandler,
143 css::ucb::XProgressHandler >
145 friend class UpdateInstallDialog::Thread;
147 UpdateInstallDialog & m_updateDialog;
148 ::rtl::Reference<UpdateInstallDialog::Thread> m_installThread;
149 cssu::Reference< cssu::XComponentContext > m_xContext;
151 public:
152 virtual ~UpdateCommandEnv();
153 UpdateCommandEnv( cssu::Reference< cssu::XComponentContext > const & xCtx,
154 UpdateInstallDialog & updateDialog,
155 ::rtl::Reference<UpdateInstallDialog::Thread>const & thread);
157 // XCommandEnvironment
158 virtual cssu::Reference<css::task::XInteractionHandler > SAL_CALL
159 getInteractionHandler() throw (cssu::RuntimeException);
160 virtual cssu::Reference<css::ucb::XProgressHandler >
161 SAL_CALL getProgressHandler() throw (cssu::RuntimeException);
163 // XInteractionHandler
164 virtual void SAL_CALL handle(
165 cssu::Reference<css::task::XInteractionRequest > const & xRequest )
166 throw (cssu::RuntimeException);
168 // XProgressHandler
169 virtual void SAL_CALL push( cssu::Any const & Status )
170 throw (cssu::RuntimeException);
171 virtual void SAL_CALL update( cssu::Any const & Status )
172 throw (cssu::RuntimeException);
173 virtual void SAL_CALL pop() throw (cssu::RuntimeException);
177 UpdateInstallDialog::Thread::Thread(
178 cssu::Reference< cssu::XComponentContext> xCtx,
179 UpdateInstallDialog & dialog,
180 std::vector< dp_gui::UpdateData > & aVecUpdateData):
181 m_dialog(dialog),
182 m_xComponentContext(xCtx),
183 m_aVecUpdateData(aVecUpdateData),
184 m_updateCmdEnv(new UpdateCommandEnv(xCtx, m_dialog, this)),
185 m_stop(false)
188 void UpdateInstallDialog::Thread::stop() {
189 cssu::Reference< css::task::XAbortChannel > abort;
191 vos::OGuard g(Application::GetSolarMutex());
192 abort = m_abort;
193 m_stop = true;
195 if (abort.is()) {
196 abort->sendAbort();
200 UpdateInstallDialog::Thread::~Thread() {}
202 void UpdateInstallDialog::Thread::execute()
204 try {
205 downloadExtensions();
206 installExtensions();
208 catch (...)
212 //clean up the temp directories
213 try {
214 removeTempDownloads();
215 } catch( ... ) {
219 //make sure m_dialog is still alive
220 ::vos::OGuard g(Application::GetSolarMutex());
221 if (! m_stop)
222 m_dialog.updateDone();
224 //UpdateCommandEnv keeps a reference to Thread and prevents destruction. Therefore remove it.
225 m_updateCmdEnv->m_installThread.clear();
229 UpdateInstallDialog::UpdateInstallDialog(
230 Window * parent,
231 std::vector<dp_gui::UpdateData> & aVecUpdateData,
232 cssu::Reference< cssu::XComponentContext > const & xCtx):
233 ModalDialog(
234 parent,
235 DpGuiResId(RID_DLG_UPDATEINSTALL)),
237 m_thread(new Thread(xCtx, *this, aVecUpdateData)),
238 m_xComponentContext(xCtx),
239 m_bError(false),
240 m_bNoEntry(true),
241 m_bActivated(false),
242 m_sInstalling(String(DpGuiResId(RID_DLG_UPDATE_INSTALL_INSTALLING))),
243 m_sFinished(String(DpGuiResId(RID_DLG_UPDATE_INSTALL_FINISHED))),
244 m_sNoErrors(String(DpGuiResId(RID_DLG_UPDATE_INSTALL_NO_ERRORS))),
245 m_sErrorDownload(String(DpGuiResId(RID_DLG_UPDATE_INSTALL_ERROR_DOWNLOAD))),
246 m_sErrorInstallation(String(DpGuiResId(RID_DLG_UPDATE_INSTALL_ERROR_INSTALLATION))),
247 m_sErrorLicenseDeclined(String(DpGuiResId(RID_DLG_UPDATE_INSTALL_ERROR_LIC_DECLINED))),
248 m_sNoInstall(String(DpGuiResId(RID_DLG_UPDATE_INSTALL_EXTENSION_NOINSTALL))),
249 m_sThisErrorOccurred(String(DpGuiResId(RID_DLG_UPDATE_INSTALL_THIS_ERROR_OCCURRED))),
250 m_ft_action(this, DpGuiResId(RID_DLG_UPDATE_INSTALL_DOWNLOADING)),
251 m_statusbar(this,DpGuiResId(RID_DLG_UPDATE_INSTALL_STATUSBAR)),
252 m_ft_extension_name(this, DpGuiResId(RID_DLG_UPDATE_INSTALL_EXTENSION_NAME)),
253 m_ft_results(this, DpGuiResId(RID_DLG_UPDATE_INSTALL_RESULTS)),
254 m_mle_info(this, DpGuiResId(RID_DLG_UPDATE_INSTALL_INFO)),
255 m_line(this, DpGuiResId(RID_DLG_UPDATE_INSTALL_LINE)),
256 m_help(this, DpGuiResId(RID_DLG_UPDATE_INSTALL_HELP)),
257 m_ok(this, DpGuiResId(RID_DLG_UPDATE_INSTALL_OK)),
258 m_cancel(this, DpGuiResId(RID_DLG_UPDATE_INSTALL_ABORT))
260 FreeResource();
262 m_cancel.SetClickHdl(LINK(this, UpdateInstallDialog, cancelHandler));
263 m_mle_info.EnableCursor(FALSE);
264 if ( ! dp_misc::office_is_running())
265 m_help.Disable();
268 UpdateInstallDialog::~UpdateInstallDialog() {}
270 BOOL UpdateInstallDialog::Close()
272 m_thread->stop();
273 return ModalDialog::Close();
276 short UpdateInstallDialog::Execute()
278 m_thread->launch();
279 return ModalDialog::Execute();
283 // make sure the solar mutex is locked before calling
284 void UpdateInstallDialog::updateDone()
286 if (!m_bError)
287 m_mle_info.InsertText(m_sNoErrors);
288 m_ok.Enable();
289 m_ok.GrabFocus();
290 m_cancel.Disable();
292 // make sure the solar mutex is locked before calling
293 //sets an error message in the text area
294 void UpdateInstallDialog::setError(INSTALL_ERROR err, ::rtl::OUString const & sExtension,
295 OUString const & exceptionMessage)
297 String sError;
298 m_bError = true;
300 switch (err)
302 case ERROR_DOWNLOAD:
303 sError = m_sErrorDownload;
304 break;
305 case ERROR_INSTALLATION:
306 sError = m_sErrorInstallation;
307 break;
308 case ERROR_LICENSE_DECLINED:
309 sError = m_sErrorLicenseDeclined;
310 break;
312 default:
313 OSL_ASSERT(0);
316 sError.SearchAndReplace(String(OUSTR("%NAME")), String(sExtension), 0);
317 //We want to have an empty line between the error messages. However,
318 //there shall be no empty line after the last entry.
319 if (m_bNoEntry)
320 m_bNoEntry = false;
321 else
322 m_mle_info.InsertText(OUSTR("\n"));
323 m_mle_info.InsertText(sError);
324 //Insert more information about the error
325 if (exceptionMessage.getLength())
326 m_mle_info.InsertText(m_sThisErrorOccurred + exceptionMessage + OUSTR("\n"));
328 m_mle_info.InsertText(m_sNoInstall);
329 m_mle_info.InsertText(OUSTR("\n"));
332 void UpdateInstallDialog::setError(OUString const & exceptionMessage)
334 m_bError = true;
335 m_mle_info.InsertText(exceptionMessage + OUSTR("\n"));
338 IMPL_LINK(UpdateInstallDialog, cancelHandler, void *, EMPTYARG)
340 m_thread->stop();
341 EndDialog(RET_CANCEL);
342 return 0;
345 //------------------------------------------------------------------------------------------------
347 void UpdateInstallDialog::Thread::downloadExtensions()
349 try
351 //create the download directory in the temp folder
352 OUString sTempDir;
353 if (::osl::FileBase::getTempDirURL(sTempDir) != ::osl::FileBase::E_None)
354 throw cssu::Exception(OUSTR("Could not get URL for the temp directory. No extensions will be installed."), 0);
356 //create a unique name for the directory
357 OUString tempEntry, destFolder;
358 if (::osl::File::createTempFile(&sTempDir, 0, &tempEntry ) != ::osl::File::E_None)
359 throw cssu::Exception(OUSTR("Could not create a temporary file in ") + sTempDir +
360 OUSTR(". No extensions will be installed"), 0 );
362 tempEntry = tempEntry.copy( tempEntry.lastIndexOf( '/' ) + 1 );
364 destFolder = dp_misc::makeURL( sTempDir, tempEntry );
365 destFolder += OUSTR("_");
366 m_sDownloadFolder = destFolder;
367 try
369 dp_misc::create_folder(0, destFolder, m_updateCmdEnv.get(), true );
370 } catch (cssu::Exception & e)
372 throw cssu::Exception(e.Message + OUSTR(" No extensions will be installed."), 0);
376 sal_uInt16 count = 0;
377 typedef std::vector<UpdateData>::iterator It;
378 for (It i = m_aVecUpdateData.begin(); i != m_aVecUpdateData.end(); i++)
380 UpdateData & curData = *i;
382 OSL_ASSERT(curData.aUpdateInfo.is());
383 //We assume that m_aVecUpdateData contains only information about extensions which
384 //can be downloaded directly.
385 OSL_ASSERT(curData.sWebsiteURL.getLength() == 0);
387 if (!curData.aUpdateInfo.is())
388 continue;
389 //update the name of the extension which is to be downloaded
391 ::vos::OGuard g(Application::GetSolarMutex());
392 if (m_stop) {
393 return;
395 m_dialog.m_ft_extension_name.SetText(curData.aInstalledPackage->getDisplayName());
396 sal_uInt16 prog = (sal::static_int_cast<sal_uInt16>(100) * ++count) /
397 sal::static_int_cast<sal_uInt16>(m_aVecUpdateData.size());
398 m_dialog.m_statusbar.SetValue(prog);
400 dp_misc::DescriptionInfoset info(m_xComponentContext, curData.aUpdateInfo);
401 //remember occurring exceptions in case we need to print out error information
402 ::std::vector< ::std::pair<OUString, cssu::Exception> > vecExceptions;
403 cssu::Sequence<OUString> seqDownloadURLs = info.getUpdateDownloadUrls();
404 OSL_ENSURE(seqDownloadURLs.getLength() > 0, "No download URL provided!");
405 for (sal_Int32 j = 0; j < seqDownloadURLs.getLength(); j++)
407 try
409 OSL_ENSURE(seqDownloadURLs[j].getLength() > 0, "Download URL is empty!");
410 download(seqDownloadURLs[j], curData);
411 if (curData.sLocalURL.getLength() > 0)
412 break;
414 catch ( cssu::Exception & e )
416 vecExceptions.push_back( ::std::make_pair(seqDownloadURLs[j], e));
417 //There can be several different errors, for example, the URL is wrong, webserver cannot be reached,
418 //name cannot be resolved. The UCB helper API does not specify different special exceptions for these
419 //cases. Therefore ignore and continue.
420 continue;
423 //update the progress and display download error
425 ::vos::OGuard g(Application::GetSolarMutex());
426 if (m_stop) {
427 return;
429 if (curData.sLocalURL.getLength() == 0)
431 //Construct a string of all messages contained in the exceptions plus the respective download URLs
432 ::rtl::OUStringBuffer buf(256);
433 typedef ::std::vector< ::std::pair<OUString, cssu::Exception > >::const_iterator CIT;
434 for (CIT j = vecExceptions.begin(); j != vecExceptions.end(); j++)
436 if (j != vecExceptions.begin())
437 buf.appendAscii("\n");
438 buf.append(OUSTR("Could not download "));
439 buf.append(j->first);
440 buf.appendAscii(". ");
441 buf.append(j->second.Message);
443 m_dialog.setError(UpdateInstallDialog::ERROR_DOWNLOAD, curData.aInstalledPackage->getDisplayName(),
444 buf.makeStringAndClear());
450 catch (cssu::Exception & e)
452 ::vos::OGuard g(Application::GetSolarMutex());
453 if (m_stop) {
454 return;
456 m_dialog.setError(e.Message);
459 void UpdateInstallDialog::Thread::installExtensions()
461 //Update the fix text in the dialog to "Installing extensions..."
463 vos::OGuard g(Application::GetSolarMutex());
464 if (m_stop) {
465 return;
467 m_dialog.m_ft_action.SetText(m_dialog.m_sInstalling);
468 m_dialog.m_statusbar.SetValue(0);
471 sal_uInt16 count = 0;
472 typedef std::vector<UpdateData>::iterator It;
473 for (It i = m_aVecUpdateData.begin(); i != m_aVecUpdateData.end(); i++, count++)
475 //update the name of the extension which is to be installed
477 ::vos::OGuard g(Application::GetSolarMutex());
478 if (m_stop) {
479 return;
481 //we only show progress after an extension has been installed.
482 if (count > 0) {
483 m_dialog.m_statusbar.SetValue(
484 (sal::static_int_cast<sal_uInt16>(100) * count) /
485 sal::static_int_cast<sal_uInt16>(m_aVecUpdateData.size()));
487 m_dialog.m_ft_extension_name.SetText(i->aInstalledPackage->getDisplayName());
489 // TimeValue v = {1, 0};
490 // osl::Thread::wait(v);
491 bool bError = false;
492 bool bLicenseDeclined = false;
493 cssu::Reference<css::deployment::XPackage> xPackage;
494 UpdateData & curData = *i;
495 cssu::Exception exc;
498 if (curData.sLocalURL.getLength() == 0)
499 continue;
500 cssu::Reference< css::task::XAbortChannel > xAbortChannel(
501 curData.aPackageManager->createAbortChannel() );
503 vos::OGuard g(Application::GetSolarMutex());
504 if (m_stop) {
505 return;
507 m_abort = xAbortChannel;
509 xPackage = curData.aPackageManager->addPackage(
510 curData.sLocalURL, OUString(), xAbortChannel, m_updateCmdEnv.get());
512 catch (css::deployment::DeploymentException & de)
514 if (de.Cause.has<css::deployment::LicenseException>())
516 bLicenseDeclined = true;
518 else
520 exc = de.Cause.get<cssu::Exception>();
521 bError = true;
524 catch (cssu::Exception& e)
526 exc = e;
527 bError = true;
530 if (bLicenseDeclined)
532 ::vos::OGuard g(Application::GetSolarMutex());
533 if (m_stop) {
534 return;
536 m_dialog.setError(UpdateInstallDialog::ERROR_LICENSE_DECLINED,
537 curData.aInstalledPackage->getDisplayName(), OUString());
539 else if (!xPackage.is() || bError)
541 ::vos::OGuard g(Application::GetSolarMutex());
542 if (m_stop) {
543 return;
545 m_dialog.setError(UpdateInstallDialog::ERROR_INSTALLATION,
546 curData.aInstalledPackage->getDisplayName(), exc.Message);
550 vos::OGuard g(Application::GetSolarMutex());
551 if (m_stop) {
552 return;
554 m_dialog.m_statusbar.SetValue(100);
555 m_dialog.m_ft_extension_name.SetText(OUString());
556 m_dialog.m_ft_action.SetText(m_dialog.m_sFinished);
560 void UpdateInstallDialog::Thread::removeTempDownloads()
562 if (m_sDownloadFolder.getLength())
564 dp_misc::erase_path(m_sDownloadFolder,
565 cssu::Reference<css::ucb::XCommandEnvironment>(),false /* no throw: ignore errors */ );
566 //remove also the temp file which we have used to create the unique name
567 OUString tempFile = m_sDownloadFolder.copy(0, m_sDownloadFolder.getLength() - 1);
568 dp_misc::erase_path(tempFile, cssu::Reference<css::ucb::XCommandEnvironment>(),false);
569 m_sDownloadFolder = OUString();
574 void UpdateInstallDialog::Thread::download(OUString const & sDownloadURL, UpdateData & aUpdateData)
577 ::vos::OGuard g(Application::GetSolarMutex());
578 if (m_stop) {
579 return;
583 OSL_ASSERT(m_sDownloadFolder.getLength());
584 OUString destFolder, tempEntry;
585 if (::osl::File::createTempFile(
586 &m_sDownloadFolder,
587 0, &tempEntry ) != ::osl::File::E_None)
589 //ToDo feedback in window that download of this component failed
590 throw cssu::Exception(OUSTR("Could not create temporary file in folder ") + destFolder + OUSTR("."), 0);
592 tempEntry = tempEntry.copy( tempEntry.lastIndexOf( '/' ) + 1 );
594 destFolder = dp_misc::makeURL( m_sDownloadFolder, tempEntry );
595 destFolder += OUSTR("_");
597 ::ucbhelper::Content destFolderContent;
598 dp_misc::create_folder( &destFolderContent, destFolder, m_updateCmdEnv.get() );
600 ::ucbhelper::Content sourceContent;
601 dp_misc::create_ucb_content( &sourceContent, sDownloadURL, m_updateCmdEnv.get() );
603 const OUString sTitle(sourceContent.getPropertyValue(
604 dp_misc::StrTitle::get() ).get<OUString>() );
606 if (destFolderContent.transferContent(
607 sourceContent, ::ucbhelper::InsertOperation_COPY,
608 sTitle, css::ucb::NameClash::OVERWRITE ))
610 //the user may have cancelled the dialog because downloading took to long
612 ::vos::OGuard g(Application::GetSolarMutex());
613 if (m_stop) {
614 return;
616 //all errors should be handeld by the command environment.
617 aUpdateData.sLocalURL = destFolder + OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) + sTitle;
623 // -------------------------------------------------------------------------------------------------------
625 UpdateCommandEnv::UpdateCommandEnv( cssu::Reference< cssu::XComponentContext > const & xCtx,
626 UpdateInstallDialog & updateDialog,
627 ::rtl::Reference<UpdateInstallDialog::Thread>const & thread)
628 : m_updateDialog( updateDialog ),
629 m_installThread(thread),
630 m_xContext(xCtx)
634 UpdateCommandEnv::~UpdateCommandEnv()
639 // XCommandEnvironment
640 //______________________________________________________________________________
641 cssu::Reference<css::task::XInteractionHandler> UpdateCommandEnv::getInteractionHandler()
642 throw (cssu::RuntimeException)
644 return this;
647 //______________________________________________________________________________
648 cssu::Reference<css::ucb::XProgressHandler> UpdateCommandEnv::getProgressHandler()
649 throw (cssu::RuntimeException)
651 return this;
654 // XInteractionHandler
655 void UpdateCommandEnv::handle(
656 cssu::Reference< css::task::XInteractionRequest> const & xRequest )
657 throw (cssu::RuntimeException)
659 cssu::Any request( xRequest->getRequest() );
660 OSL_ASSERT( request.getValueTypeClass() == cssu::TypeClass_EXCEPTION );
661 dp_misc::TRACE(OUSTR("[dp_gui_cmdenv.cxx] incoming request:\n")
662 + ::comphelper::anyToString(request) + OUSTR("\n\n"));
664 css::deployment::VersionException verExc;
665 bool approve = false;
666 bool abort = false;
668 if (request >>= verExc)
669 { //We must catch the version exception during the update,
670 //because otherwise the user would be confronted with the dialogs, asking
671 //them if they want to replace an already installed version of the same extension.
672 //During an update we assume that we always want to replace the old version with the
673 //new version.
674 approve = true;
677 if (approve == false && abort == false)
679 //forward to interaction handler for main dialog.
680 handleInteractionRequest( m_xContext, xRequest );
682 else
684 // select:
685 cssu::Sequence< cssu::Reference< css::task::XInteractionContinuation > > conts(
686 xRequest->getContinuations() );
687 cssu::Reference< css::task::XInteractionContinuation > const * pConts =
688 conts.getConstArray();
689 sal_Int32 len = conts.getLength();
690 for ( sal_Int32 pos = 0; pos < len; ++pos )
692 if (approve) {
693 cssu::Reference< css::task::XInteractionApprove > xInteractionApprove(
694 pConts[ pos ], cssu::UNO_QUERY );
695 if (xInteractionApprove.is()) {
696 xInteractionApprove->select();
697 // don't query again for ongoing continuations:
698 approve = false;
701 else if (abort) {
702 cssu::Reference< css::task::XInteractionAbort > xInteractionAbort(
703 pConts[ pos ], cssu::UNO_QUERY );
704 if (xInteractionAbort.is()) {
705 xInteractionAbort->select();
706 // don't query again for ongoing continuations:
707 abort = false;
714 // XProgressHandler
715 void UpdateCommandEnv::push( cssu::Any const & /*Status*/ )
716 throw (cssu::RuntimeException)
721 void UpdateCommandEnv::update( cssu::Any const & /*Status */)
722 throw (cssu::RuntimeException)
726 void UpdateCommandEnv::pop() throw (cssu::RuntimeException)
731 } //end namespace dp_gui