LibreOffice Module desktop (master)  1
dp_gui_dialog2.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <config_extensions.h>
21 
22 #include <strings.hrc>
23 #include <helpids.h>
24 
25 #include "dp_gui.h"
26 #include "dp_gui_dialog2.hxx"
27 #include "dp_gui_extlistbox.hxx"
28 #include <dp_shared.hxx>
29 #include "dp_gui_theextmgr.hxx"
31 #include <dp_misc.h>
32 #include <dp_update.hxx>
33 #include <dp_identifier.hxx>
34 
35 #include <fpicker/strings.hrc>
36 
37 #include <vcl/commandevent.hxx>
38 #include <vcl/svapp.hxx>
39 
40 #include <osl/mutex.hxx>
41 #include <sal/log.hxx>
42 #include <rtl/ustrbuf.hxx>
43 
45 
46 #include <sfx2/filedlghelper.hxx>
47 #include <sfx2/sfxdlg.hxx>
48 
50 #include <cppuhelper/exc_hlp.hxx>
51 
53 #include <tools/diagnose_ex.h>
54 #include <unotools/configmgr.hxx>
55 
56 #include <com/sun/star/deployment/DeploymentException.hpp>
57 #include <com/sun/star/lang/IllegalArgumentException.hpp>
58 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
59 #include <com/sun/star/system/SystemShellExecute.hpp>
60 
61 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
62 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
63 #include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
64 
65 #include <officecfg/Office/ExtensionManager.hxx>
66 
67 #include <map>
68 #include <memory>
69 #include <vector>
70 
71 using namespace ::com::sun::star;
72 using namespace ::com::sun::star::system;
73 
74 
75 namespace dp_gui {
76 
77 #define USER_PACKAGE_MANAGER "user"
78 #define SHARED_PACKAGE_MANAGER "shared"
79 #define BUNDLED_PACKAGE_MANAGER "bundled"
80 
81 namespace {
82 
83 struct StrAllFiles : public rtl::StaticWithInit< OUString, StrAllFiles >
84 {
85  OUString operator () () {
86  const SolarMutexGuard guard;
87  std::locale loc = Translate::Create("fps");
88  return Translate::get(STR_FILTERNAME_ALL, loc);
89  }
90 };
91 
92 }
93 
94 // ExtBoxWithBtns_Impl
96 {
98 
100 
101  void SetButtonStatus( const TEntry_Impl& rEntry );
102  OString ShowPopupMenu( const Point &rPos, const long nPos );
103 
104 public:
105  explicit ExtBoxWithBtns_Impl(std::unique_ptr<weld::ScrolledWindow> xScroll);
106 
107  void InitFromDialog(ExtMgrDialog *pParentDialog);
108 
109  virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
110  virtual bool Command( const CommandEvent& rCEvt ) override;
111 
112  virtual void RecalcAll() override;
113  virtual void selectEntry( const long nPos ) override;
114 
115  void enableButtons( bool bEnable );
116 };
117 
118 ExtBoxWithBtns_Impl::ExtBoxWithBtns_Impl(std::unique_ptr<weld::ScrolledWindow> xScroll)
119  : ExtensionBox_Impl(std::move(xScroll))
120  , m_bInterfaceLocked(false)
121  , m_pParent(nullptr)
122 {
123 }
124 
126 {
127  setExtensionManager(pParentDialog->getExtensionManager());
128 
129  m_pParent = pParentDialog;
130 }
131 
133 {
134  const sal_Int32 nActive = getSelIndex();
135 
136  if ( nActive != ExtensionBox_Impl::ENTRY_NOTFOUND )
137  {
138  SetButtonStatus( GetEntryData( nActive) );
139  }
140  else
141  {
142  m_pParent->enableOptionsButton( false );
143  m_pParent->enableRemoveButton( false );
144  m_pParent->enableEnableButton( false );
145  }
146 
148 }
149 
150 
151 //This function may be called with nPos < 0
152 void ExtBoxWithBtns_Impl::selectEntry( const long nPos )
153 {
154  if ( HasActive() && ( nPos == getSelIndex() ) )
155  return;
156 
158 }
159 
161 {
162  bool bShowOptionBtn = true;
163 
164  rEntry->m_bHasButtons = false;
165  if ( ( rEntry->m_eState == REGISTERED ) || ( rEntry->m_eState == NOT_AVAILABLE ) )
166  {
168  }
169  else
170  {
172  bShowOptionBtn = false;
173  }
174 
175  if ( ( !rEntry->m_bUser || ( rEntry->m_eState == NOT_AVAILABLE ) || rEntry->m_bMissingDeps )
176  && !rEntry->m_bMissingLic )
177  {
178  m_pParent->enableEnableButton( false );
179  }
180  else
181  {
182  m_pParent->enableEnableButton( !rEntry->m_bLocked );
183  rEntry->m_bHasButtons = true;
184  }
185 
186  if ( rEntry->m_bHasOptions && bShowOptionBtn )
187  {
189  rEntry->m_bHasButtons = true;
190  }
191  else
192  {
193  m_pParent->enableOptionsButton( false );
194  }
195 
196  if ( rEntry->m_bUser || rEntry->m_bShared )
197  {
198  m_pParent->enableRemoveButton( !rEntry->m_bLocked );
199  rEntry->m_bHasButtons = true;
200  }
201  else
202  {
203  m_pParent->enableRemoveButton( false );
204  }
205 }
206 
208 {
209  if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
210  return ExtensionBox_Impl::Command(rCEvt);
211 
212  const Point aMousePos(rCEvt.GetMousePosPixel());
213  const auto nPos = PointToPos(aMousePos);
214  OString sCommand = ShowPopupMenu(aMousePos, nPos);
215 
216  if (sCommand == "CMD_ENABLE")
217  m_pParent->enablePackage( GetEntryData( nPos )->m_xPackage, true );
218  else if (sCommand == "CMD_DISABLE")
219  m_pParent->enablePackage( GetEntryData( nPos )->m_xPackage, false );
220  else if (sCommand == "CMD_UPDATE")
222  else if (sCommand == "CMD_REMOVE")
224  else if (sCommand == "CMD_SHOW_LICENSE")
225  {
226  m_pParent->incBusy();
227  ShowLicenseDialog aLicenseDlg(m_pParent->getDialog(), GetEntryData(nPos)->m_xPackage);
228  aLicenseDlg.run();
229  m_pParent->decBusy();
230  }
231 
232  return true;
233 }
234 
235 OString ExtBoxWithBtns_Impl::ShowPopupMenu( const Point & rPos, const long nPos )
236 {
237  if ( nPos >= static_cast<long>(getItemCount()) )
238  return "CMD_NONE";
239 
240  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(nullptr, "desktop/ui/extensionmenu.ui"));
241  std::unique_ptr<weld::Menu> xPopup(xBuilder->weld_menu("menu"));
242 
243 #if ENABLE_EXTENSION_UPDATE
244  xPopup->append("CMD_UPDATE", DpResId( RID_CTX_ITEM_CHECK_UPDATE ) );
245 #endif
246 
247  if ( ! GetEntryData( nPos )->m_bLocked )
248  {
249  if ( GetEntryData( nPos )->m_bUser )
250  {
251  if ( GetEntryData( nPos )->m_eState == REGISTERED )
252  xPopup->append("CMD_DISABLE", DpResId(RID_CTX_ITEM_DISABLE));
253  else if ( GetEntryData( nPos )->m_eState != NOT_AVAILABLE )
254  xPopup->append("CMD_ENABLE", DpResId(RID_CTX_ITEM_ENABLE));
255  }
256  if (!officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionRemoval::get())
257  {
258  xPopup->append("CMD_REMOVE", DpResId(RID_CTX_ITEM_REMOVE));
259  }
260  }
261 
262  if ( !GetEntryData( nPos )->m_sLicenseText.isEmpty() )
263  xPopup->append("CMD_SHOW_LICENSE", DpResId(RID_STR_SHOW_LICENSE_CMD));
264 
265  return xPopup->popup_at_rect(GetDrawingArea(), tools::Rectangle(rPos, Size(1, 1)));
266 }
267 
269 {
270  if (m_bInterfaceLocked)
271  return false;
273 }
274 
276 {
277  m_bInterfaceLocked = ! bEnable;
278 
279  if ( bEnable )
280  {
281  sal_Int32 nIndex = getSelIndex();
282  if ( nIndex != ExtensionBox_Impl::ENTRY_NOTFOUND )
283  SetButtonStatus( GetEntryData( nIndex ) );
284  }
285  else
286  {
287  m_pParent->enableEnableButton( false );
288  m_pParent->enableOptionsButton( false );
289  m_pParent->enableRemoveButton( false );
290  }
291 }
292 
293 // DialogHelper
294 
295 DialogHelper::DialogHelper(const uno::Reference< uno::XComponentContext > &xContext,
296  weld::Window* pWindow)
297  : m_pWindow(pWindow)
298  , m_nEventID(nullptr)
299 {
301 }
302 
304 {
305  if ( m_nEventID )
307 }
308 
309 
310 bool DialogHelper::IsSharedPkgMgr( const uno::Reference< deployment::XPackage > &xPackage )
311 {
312  return xPackage->getRepositoryName() == SHARED_PACKAGE_MANAGER;
313 }
314 
315 bool DialogHelper::continueOnSharedExtension( const uno::Reference< deployment::XPackage > &xPackage,
316  weld::Widget* pParent,
317  const char* pResID,
318  bool &bHadWarning )
319 {
320  if ( !bHadWarning && IsSharedPkgMgr( xPackage ) )
321  {
322  const SolarMutexGuard guard;
323  incBusy();
324  std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent,
325  VclMessageType::Warning, VclButtonsType::OkCancel, DpResId(pResID)));
326  bHadWarning = true;
327 
328  bool bRet = RET_OK == xBox->run();
329  xBox.reset();
330  decBusy();
331  return bRet;
332  }
333  else
334  return true;
335 }
336 
337 void DialogHelper::openWebBrowser(const OUString& sURL, const OUString& sTitle)
338 {
339  if ( sURL.isEmpty() ) // Nothing to do, when the URL is empty
340  return;
341 
342  try
343  {
344  uno::Reference< XSystemShellExecute > xSystemShellExecute(
346  //throws css::lang::IllegalArgumentException, css::system::SystemShellExecuteException
347  xSystemShellExecute->execute( sURL, OUString(), SystemShellExecuteFlags::URIS_ONLY );
348  }
349  catch ( const uno::Exception& )
350  {
352  OUString msg( ::comphelper::anyToString( exc ) );
353  const SolarMutexGuard guard;
354  incBusy();
355  std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(getFrameWeld(),
356  VclMessageType::Warning, VclButtonsType::Ok, msg));
357  xErrorBox->set_title(sTitle);
358  xErrorBox->run();
359  xErrorBox.reset();
360  decBusy();
361  }
362 }
363 
364 bool DialogHelper::installExtensionWarn(const OUString &rExtensionName)
365 {
366  const SolarMutexGuard guard;
367 
368  // Check if extension installation is disabled in the expert configurations
369  if (officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionInstallation::get())
370  {
371  incBusy();
372  std::unique_ptr<weld::MessageDialog> xWarnBox(Application::CreateMessageDialog(getFrameWeld(),
373  VclMessageType::Warning, VclButtonsType::Ok,
374  DpResId(RID_STR_WARNING_INSTALL_EXTENSION_DISABLED)));
375  xWarnBox->run();
376  xWarnBox.reset();
377  decBusy();
378 
379  return false;
380  }
381 
382  incBusy();
383  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(getFrameWeld(),
384  VclMessageType::Warning, VclButtonsType::OkCancel,
385  DpResId(RID_STR_WARNING_INSTALL_EXTENSION)));
386  OUString sText(xInfoBox->get_primary_text());
387  sText = sText.replaceAll("%NAME", rExtensionName);
388  xInfoBox->set_primary_text(sText);
389 
390  bool bRet = RET_OK == xInfoBox->run();
391  xInfoBox.reset();
392  decBusy();
393  return bRet;
394 }
395 
396 bool DialogHelper::installForAllUsers(bool &bInstallForAll)
397 {
398  const SolarMutexGuard guard;
399  incBusy();
400  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(getFrameWeld(), "desktop/ui/installforalldialog.ui"));
401  std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog("InstallForAllDialog"));
402  short nRet = xQuery->run();
403  xQuery.reset();
404  decBusy();
405  if (nRet == RET_CANCEL)
406  return false;
407 
408  bInstallForAll = ( nRet == RET_NO );
409  return true;
410 }
411 
412 void DialogHelper::PostUserEvent( const Link<void*,void>& rLink, void* pCaller )
413 {
414  if ( m_nEventID )
416 
417  m_nEventID = Application::PostUserEvent(rLink, pCaller);
418 }
419 
420 // ExtMgrDialog
422  : GenericDialogController(pParent, "desktop/ui/extensionmanager.ui", "ExtensionManagerDialog")
423  , DialogHelper(pManager->getContext(), m_xDialog.get())
424  , m_sAddPackages(DpResId(RID_STR_ADD_PACKAGES))
425  , m_bHasProgress(false)
426  , m_bProgressChanged(false)
427  , m_bStartProgress(false)
428  , m_bStopProgress(false)
429  , m_bEnableWarning(false)
430  , m_bDisableWarning(false)
431  , m_bDeleteWarning(false)
432  , m_bClosed(false)
433  , m_nProgress(0)
434  , m_pManager(pManager)
435  , m_xExtensionBox(new ExtBoxWithBtns_Impl(m_xBuilder->weld_scrolled_window("scroll")))
436  , m_xExtensionBoxWnd(new weld::CustomWeld(*m_xBuilder, "extensions", *m_xExtensionBox))
437  , m_xOptionsBtn(m_xBuilder->weld_button("optionsbtn"))
438  , m_xAddBtn(m_xBuilder->weld_button("addbtn"))
439  , m_xRemoveBtn(m_xBuilder->weld_button("removebtn"))
440  , m_xEnableBtn(m_xBuilder->weld_button("enablebtn"))
441  , m_xUpdateBtn(m_xBuilder->weld_button("updatebtn"))
442  , m_xCloseBtn(m_xBuilder->weld_button("close"))
443  , m_xBundledCbx(m_xBuilder->weld_check_button("bundled"))
444  , m_xSharedCbx(m_xBuilder->weld_check_button("shared"))
445  , m_xUserCbx(m_xBuilder->weld_check_button("user"))
446  , m_xGetExtensions(m_xBuilder->weld_link_button("getextensions"))
447  , m_xProgressText(m_xBuilder->weld_label("progressft"))
448  , m_xProgressBar(m_xBuilder->weld_progress_bar("progressbar"))
449  , m_xCancelBtn(m_xBuilder->weld_button("cancel"))
450 {
451  m_xExtensionBox->InitFromDialog(this);
452 
454 
455  m_xOptionsBtn->connect_clicked( LINK( this, ExtMgrDialog, HandleOptionsBtn ) );
456  m_xAddBtn->connect_clicked( LINK( this, ExtMgrDialog, HandleAddBtn ) );
457  m_xRemoveBtn->connect_clicked( LINK( this, ExtMgrDialog, HandleRemoveBtn ) );
458  m_xEnableBtn->connect_clicked( LINK( this, ExtMgrDialog, HandleEnableBtn ) );
459  m_xCloseBtn->connect_clicked( LINK( this, ExtMgrDialog, HandleCloseBtn ) );
460 
461  m_xCancelBtn->connect_clicked( LINK( this, ExtMgrDialog, HandleCancelBtn ) );
462 
463  m_xBundledCbx->connect_clicked( LINK( this, ExtMgrDialog, HandleExtTypeCbx ) );
464  m_xSharedCbx->connect_clicked( LINK( this, ExtMgrDialog, HandleExtTypeCbx ) );
465  m_xUserCbx->connect_clicked( LINK( this, ExtMgrDialog, HandleExtTypeCbx ) );
466 
467  m_xBundledCbx->set_active(true);
468  m_xSharedCbx->set_active(true);
469  m_xUserCbx->set_active(true);
470 
471  m_xProgressBar->hide();
472 
473 #if ENABLE_EXTENSION_UPDATE
474  m_xUpdateBtn->connect_clicked( LINK( this, ExtMgrDialog, HandleUpdateBtn ) );
475  m_xUpdateBtn->set_sensitive(false);
476 #else
477  m_xUpdateBtn->hide();
478 #endif
479 
480  if (officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionInstallation::get())
481  {
482  m_xAddBtn->set_sensitive(false);
483  m_xAddBtn->set_tooltip_text(DpResId(RID_STR_WARNING_INSTALL_EXTENSION_DISABLED));
484  }
485  if (officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionRemoval::get())
486  {
487  m_xRemoveBtn->set_sensitive(false);
488  m_xRemoveBtn->set_tooltip_text(DpResId(RID_STR_WARNING_REMOVE_EXTENSION_DISABLED));
489  }
490 
491  m_aIdle.SetPriority(TaskPriority::LOWEST);
492  m_aIdle.SetDebugName( "ExtMgrDialog m_aIdle TimeOutHdl" );
493  m_aIdle.SetInvokeHandler( LINK( this, ExtMgrDialog, TimeOutHdl ) );
494 }
495 
497 {
498  m_aIdle.Stop();
499 }
500 
501 void ExtMgrDialog::setGetExtensionsURL( const OUString &rURL )
502 {
503  m_xGetExtensions->set_uri( rURL );
504 }
505 
506 void ExtMgrDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage,
507  bool bLicenseMissing )
508 {
509  const SolarMutexGuard aGuard;
510  m_xUpdateBtn->set_sensitive(true);
511 
512  if (m_xBundledCbx->get_active() && (xPackage->getRepositoryName() == BUNDLED_PACKAGE_MANAGER) )
513  {
514  m_xExtensionBox->addEntry( xPackage, bLicenseMissing );
515  }
516  else if (m_xSharedCbx->get_active() && (xPackage->getRepositoryName() == SHARED_PACKAGE_MANAGER) )
517  {
518  m_xExtensionBox->addEntry( xPackage, bLicenseMissing );
519  }
520  else if (m_xUserCbx->get_active() && (xPackage->getRepositoryName() == USER_PACKAGE_MANAGER ))
521  {
522  m_xExtensionBox->addEntry( xPackage, bLicenseMissing );
523  }
524 }
525 
527 {
528  m_xExtensionBox->prepareChecking();
529 }
530 
532 {
533  const SolarMutexGuard guard;
534  m_xExtensionBox->checkEntries();
535 }
536 
537 bool ExtMgrDialog::removeExtensionWarn(const OUString &rExtensionName)
538 {
539  const SolarMutexGuard guard;
540  incBusy();
541  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(),
542  VclMessageType::Warning, VclButtonsType::OkCancel,
543  DpResId(RID_STR_WARNING_REMOVE_EXTENSION)));
544 
545  OUString sText(xInfoBox->get_primary_text());
546  sText = sText.replaceAll("%NAME", rExtensionName);
547  xInfoBox->set_primary_text(sText);
548 
549  bool bRet = RET_OK == xInfoBox->run();
550  xInfoBox.reset();
551  decBusy();
552 
553  return bRet;
554 }
555 
556 void ExtMgrDialog::enablePackage( const uno::Reference< deployment::XPackage > &xPackage,
557  bool bEnable )
558 {
559  if ( !xPackage.is() )
560  return;
561 
562  if ( bEnable )
563  {
564  if (!continueOnSharedExtension(xPackage, m_xDialog.get(), RID_STR_WARNING_ENABLE_SHARED_EXTENSION, m_bEnableWarning))
565  return;
566  }
567  else
568  {
569  if (!continueOnSharedExtension(xPackage, m_xDialog.get(), RID_STR_WARNING_DISABLE_SHARED_EXTENSION, m_bDisableWarning))
570  return;
571  }
572 
573  m_pManager->getCmdQueue()->enableExtension( xPackage, bEnable );
574 }
575 
576 
577 void ExtMgrDialog::removePackage( const uno::Reference< deployment::XPackage > &xPackage )
578 {
579  if ( !xPackage.is() )
580  return;
581 
582  if ( !IsSharedPkgMgr( xPackage ) || m_bDeleteWarning )
583  {
584  if ( ! removeExtensionWarn( xPackage->getDisplayName() ) )
585  return;
586  }
587 
588  if (!continueOnSharedExtension(xPackage, m_xDialog.get(), RID_STR_WARNING_REMOVE_SHARED_EXTENSION, m_bDeleteWarning))
589  return;
590 
591  m_pManager->getCmdQueue()->removeExtension( xPackage );
592 }
593 
594 
595 void ExtMgrDialog::updatePackage( const uno::Reference< deployment::XPackage > &xPackage )
596 {
597  if ( !xPackage.is() )
598  return;
599 
600  // get the extension with highest version
601  uno::Sequence<uno::Reference<deployment::XPackage> > seqExtensions =
602  m_pManager->getExtensionManager()->getExtensionsWithSameIdentifier(
603  dp_misc::getIdentifier(xPackage), xPackage->getName(), uno::Reference<ucb::XCommandEnvironment>());
604  uno::Reference<deployment::XPackage> extension =
606  OSL_ASSERT(extension.is());
607  std::vector< css::uno::Reference< css::deployment::XPackage > > vEntries;
608  vEntries.push_back(extension);
609 
610  m_pManager->getCmdQueue()->checkForUpdates( vEntries );
611 }
612 
613 
614 bool ExtMgrDialog::acceptLicense( const uno::Reference< deployment::XPackage > &xPackage )
615 {
616  if ( !xPackage.is() )
617  return false;
618 
619  m_pManager->getCmdQueue()->acceptLicense( xPackage );
620 
621  return true;
622 }
623 
624 
625 uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker()
626 {
627  sfx2::FileDialogHelper aDlgHelper(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, m_xDialog.get());
628  const uno::Reference<ui::dialogs::XFilePicker3>& xFilePicker = aDlgHelper.GetFilePicker();
629  xFilePicker->setTitle( m_sAddPackages );
630 
631  if ( !m_sLastFolderURL.isEmpty() )
632  xFilePicker->setDisplayDirectory( m_sLastFolderURL );
633 
634  // collect and set filter list:
635  typedef std::map< OUString, OUString > t_string2string;
636  t_string2string title2filter;
637  OUString sDefaultFilter( StrAllFiles::get() );
638 
639  const uno::Sequence< uno::Reference< deployment::XPackageTypeInfo > > packageTypes(
640  m_pManager->getExtensionManager()->getSupportedPackageTypes() );
641 
642  for ( sal_Int32 pos = 0; pos < packageTypes.getLength(); ++pos )
643  {
644  uno::Reference< deployment::XPackageTypeInfo > const & xPackageType = packageTypes[ pos ];
645  const OUString filter( xPackageType->getFileFilter() );
646  if (!filter.isEmpty())
647  {
648  const OUString title( xPackageType->getShortDescription() );
649  const std::pair< t_string2string::iterator, bool > insertion(
650  title2filter.emplace( title, filter ) );
651  if ( ! insertion.second )
652  { // already existing, append extensions:
653  OUStringBuffer buf;
654  buf.append( insertion.first->second );
655  buf.append( ';' );
656  buf.append( filter );
657  insertion.first->second = buf.makeStringAndClear();
658  }
659  if ( xPackageType->getMediaType() == "application/vnd.sun.star.package-bundle" )
660  sDefaultFilter = title;
661  }
662  }
663 
664  // All files at top:
665  xFilePicker->appendFilter( StrAllFiles::get(), "*.*" );
666  // then supported ones:
667  for (auto const& elem : title2filter)
668  {
669  try
670  {
671  xFilePicker->appendFilter( elem.first, elem.second );
672  }
673  catch (const lang::IllegalArgumentException &)
674  {
675  TOOLS_WARN_EXCEPTION( "desktop", "" );
676  }
677  }
678  xFilePicker->setCurrentFilter( sDefaultFilter );
679 
680  if ( xFilePicker->execute() != ui::dialogs::ExecutableDialogResults::OK )
681  return uno::Sequence<OUString>(); // cancelled
682 
683  m_sLastFolderURL = xFilePicker->getDisplayDirectory();
684  uno::Sequence< OUString > files( xFilePicker->getSelectedFiles() );
685  OSL_ASSERT( files.hasElements() );
686  return files;
687 }
688 
690 {
691  m_xOptionsBtn->set_sensitive( bEnable );
692 }
693 
695 {
696  m_xRemoveBtn->set_sensitive( bEnable && !officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionRemoval::get());
697 
698  if (officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionRemoval::get())
699  {
700  m_xRemoveBtn->set_tooltip_text(DpResId(RID_STR_WARNING_REMOVE_EXTENSION_DISABLED));
701  }
702  else
703  {
704  m_xRemoveBtn->set_tooltip_text("");
705  }
706 }
707 
709 {
710  m_xEnableBtn->set_sensitive( bEnable );
711 }
712 
714 {
715  if (bEnable)
716  {
717  m_xEnableBtn->set_label( DpResId( RID_CTX_ITEM_ENABLE ) );
719  }
720  else
721  {
722  m_xEnableBtn->set_label( DpResId( RID_CTX_ITEM_DISABLE ) );
724  }
725 }
726 
727 IMPL_LINK_NOARG(ExtMgrDialog, HandleCancelBtn, weld::Button&, void)
728 {
729  if ( m_xAbortChannel.is() )
730  {
731  try
732  {
733  m_xAbortChannel->sendAbort();
734  }
735  catch ( const uno::RuntimeException & )
736  {
737  OSL_FAIL( "### unexpected RuntimeException!" );
738  }
739  }
740 }
741 
742 IMPL_LINK_NOARG(ExtMgrDialog, HandleCloseBtn, weld::Button&, void)
743 {
744  bool bCallClose = true;
745 
746  //only suggest restart if modified and this is the first close attempt
747  if (!m_bClosed && m_pManager->isModified())
748  {
749  m_pManager->clearModified();
750 
751  //only suggest restart if we're actually running, e.g. not from standalone unopkg gui
753  {
754  SolarMutexGuard aGuard;
755  bCallClose = !::svtools::executeRestartDialog(comphelper::getProcessComponentContext(),
756  m_xDialog.get(),
758  }
759  }
760 
761  if (bCallClose)
762  m_xDialog->response(RET_CANCEL);
763 }
764 
765 IMPL_LINK( ExtMgrDialog, startProgress, void*, _bLockInterface, void )
766 {
767  ::osl::MutexGuard aGuard( m_aMutex );
768  bool bLockInterface = static_cast<bool>(_bLockInterface);
769 
770  if ( m_bStartProgress && !m_bHasProgress )
771  m_aIdle.Start();
772 
773  if ( m_bStopProgress )
774  {
775  if ( m_xProgressBar->get_visible() )
776  m_xProgressBar->set_percentage( 100 );
777  m_xAbortChannel.clear();
778 
779  SAL_INFO( "desktop.deployment", " startProgress handler: stop" );
780  }
781  else
782  {
783  SAL_INFO( "desktop.deployment", " startProgress handler: start" );
784  }
785 
786  m_xCancelBtn->set_sensitive( bLockInterface );
787  m_xAddBtn->set_sensitive( !bLockInterface && !officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionInstallation::get());
788  if (officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionInstallation::get())
789  {
790  m_xAddBtn->set_tooltip_text(DpResId(RID_STR_WARNING_INSTALL_EXTENSION_DISABLED));
791  }
792  else
793  {
794  m_xAddBtn->set_tooltip_text("");
795  }
796 
797  m_xUpdateBtn->set_sensitive( !bLockInterface && m_xExtensionBox->getItemCount() );
798  m_xExtensionBox->enableButtons( !bLockInterface );
799 
800  clearEventID();
801 }
802 
803 
804 void ExtMgrDialog::showProgress( bool _bStart )
805 {
806  ::osl::MutexGuard aGuard( m_aMutex );
807 
808  bool bStart = _bStart;
809 
810  if ( bStart )
811  {
812  m_nProgress = 0;
813  m_bStartProgress = true;
814  SAL_INFO( "desktop.deployment", "showProgress start" );
815  }
816  else
817  {
818  m_nProgress = 100;
819  m_bStopProgress = true;
820  SAL_INFO( "desktop.deployment", "showProgress stop!" );
821  }
822 
823  DialogHelper::PostUserEvent( LINK( this, ExtMgrDialog, startProgress ), reinterpret_cast<void*>(bStart) );
824  m_aIdle.Start();
825 }
826 
827 
828 void ExtMgrDialog::updateProgress( const long nProgress )
829 {
830  if ( m_nProgress != nProgress )
831  {
832  ::osl::MutexGuard aGuard( m_aMutex );
833  m_nProgress = nProgress;
834  m_aIdle.Start();
835  }
836 }
837 
838 
839 void ExtMgrDialog::updateProgress( const OUString &rText,
840  const uno::Reference< task::XAbortChannel > &xAbortChannel)
841 {
842  ::osl::MutexGuard aGuard( m_aMutex );
843 
844  m_xAbortChannel = xAbortChannel;
845  m_sProgressText = rText;
846  m_bProgressChanged = true;
847  m_aIdle.Start();
848 }
849 
850 
851 void ExtMgrDialog::updatePackageInfo( const uno::Reference< deployment::XPackage > &xPackage )
852 {
853  const SolarMutexGuard aGuard;
854  m_xExtensionBox->updateEntry( xPackage );
855 }
856 
857 IMPL_LINK_NOARG(ExtMgrDialog, HandleOptionsBtn, weld::Button&, void)
858 {
859  const sal_Int32 nActive = m_xExtensionBox->getSelIndex();
860 
861  if ( nActive != ExtensionBox_Impl::ENTRY_NOTFOUND )
862  {
864 
865  OUString sExtensionId = m_xExtensionBox->GetEntryData( nActive )->m_xPackage->getIdentifier().Value;
866  ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateOptionsDialog(m_xDialog.get(), sExtensionId));
867 
868  pDlg->Execute();
869  }
870 }
871 
873 {
874  incBusy();
875 
876  uno::Sequence< OUString > aFileList = raiseAddPicker();
877 
878  if ( aFileList.hasElements() )
879  {
880  m_pManager->installPackage( aFileList[0] );
881  }
882 
883  decBusy();
884 }
885 
886 IMPL_LINK_NOARG(ExtMgrDialog, HandleRemoveBtn, weld::Button&, void)
887 {
888  const sal_Int32 nActive = m_xExtensionBox->getSelIndex();
889 
890  if ( nActive != ExtensionBox_Impl::ENTRY_NOTFOUND )
891  {
892  TEntry_Impl pEntry = m_xExtensionBox->GetEntryData( nActive );
893  removePackage( pEntry->m_xPackage );
894  }
895 }
896 
897 IMPL_LINK_NOARG(ExtMgrDialog, HandleEnableBtn, weld::Button&, void)
898 {
899  const sal_Int32 nActive = m_xExtensionBox->getSelIndex();
900 
901  if ( nActive != ExtensionBox_Impl::ENTRY_NOTFOUND )
902  {
903  TEntry_Impl pEntry = m_xExtensionBox->GetEntryData( nActive );
904 
905  if ( pEntry->m_bMissingLic )
906  acceptLicense( pEntry->m_xPackage );
907  else
908  {
909  const bool bEnable( pEntry->m_eState != REGISTERED );
910  enablePackage( pEntry->m_xPackage, bEnable );
911  }
912  }
913 }
914 
915 IMPL_LINK_NOARG(ExtMgrDialog, HandleExtTypeCbx, weld::Button&, void)
916 {
917  // re-creates the list of packages with addEntry selecting the packages
918  prepareChecking();
919  m_pManager->createPackageList();
920  checkEntries();
921 }
922 
923 IMPL_LINK_NOARG(ExtMgrDialog, HandleUpdateBtn, weld::Button&, void)
924 {
925 #if ENABLE_EXTENSION_UPDATE
926  m_pManager->checkUpdates();
927 #else
928  (void) this;
929 #endif
930 }
931 
932 IMPL_LINK_NOARG(ExtMgrDialog, TimeOutHdl, Timer *, void)
933 {
934  if ( m_bStopProgress )
935  {
936  m_bHasProgress = false;
937  m_bStopProgress = false;
938  m_xProgressText->hide();
939  m_xProgressBar->hide();
940  m_xCancelBtn->hide();
941  }
942  else
943  {
944  if ( m_bProgressChanged )
945  {
946  m_bProgressChanged = false;
947  m_xProgressText->set_label(m_sProgressText);
948  }
949 
950  if ( m_bStartProgress )
951  {
952  m_bStartProgress = false;
953  m_bHasProgress = true;
954  m_xProgressBar->show();
955  m_xProgressText->show();
956  m_xCancelBtn->set_sensitive(true);
957  m_xCancelBtn->show();
958  }
959 
960  if ( m_xProgressBar->get_visible() )
961  m_xProgressBar->set_percentage( static_cast<sal_uInt16>(m_nProgress) );
962  }
963 }
964 
966 {
968  m_bClosed = true;
969 }
970 
971 //UpdateRequiredDialog
973  : GenericDialogController(pParent, "desktop/ui/updaterequireddialog.ui", "UpdateRequiredDialog")
974  , DialogHelper(pManager->getContext(), m_xDialog.get())
975  , m_sCloseText(DpResId(RID_STR_CLOSE_BTN))
976  , m_bHasProgress(false)
977  , m_bProgressChanged(false)
978  , m_bStartProgress(false)
979  , m_bStopProgress(false)
980  , m_bHasLockedEntries(false)
981  , m_nProgress(0)
982  , m_pManager(pManager)
983  , m_xExtensionBox(new ExtensionBox_Impl(m_xBuilder->weld_scrolled_window("scroll")))
984  , m_xExtensionBoxWnd(new weld::CustomWeld(*m_xBuilder, "extensions", *m_xExtensionBox))
985  , m_xUpdateNeeded(m_xBuilder->weld_label("updatelabel"))
986  , m_xUpdateBtn(m_xBuilder->weld_button("ok"))
987  , m_xCloseBtn(m_xBuilder->weld_button("disable"))
988  , m_xCancelBtn(m_xBuilder->weld_button("cancel"))
989  , m_xProgressText(m_xBuilder->weld_label("progresslabel"))
990  , m_xProgressBar(m_xBuilder->weld_progress_bar("progress"))
991 {
992  m_xExtensionBox->setExtensionManager(pManager);
993 
994  m_xUpdateBtn->connect_clicked( LINK( this, UpdateRequiredDialog, HandleUpdateBtn ) );
995  m_xCloseBtn->connect_clicked( LINK( this, UpdateRequiredDialog, HandleCloseBtn ) );
996  m_xCancelBtn->connect_clicked( LINK( this, UpdateRequiredDialog, HandleCancelBtn ) );
997 
998  OUString aText = m_xUpdateNeeded->get_label();
999  aText = aText.replaceAll(
1000  "%PRODUCTNAME", utl::ConfigManager::getProductName());
1001  m_xUpdateNeeded->set_label(aText);
1002 
1003  m_xProgressBar->hide();
1004  m_xUpdateBtn->set_sensitive( false );
1005  m_xCloseBtn->grab_focus();
1006 
1007  m_aIdle.SetPriority( TaskPriority::LOWEST );
1008  m_aIdle.SetDebugName( "UpdateRequiredDialog m_aIdle TimeOutHdl" );
1009  m_aIdle.SetInvokeHandler( LINK( this, UpdateRequiredDialog, TimeOutHdl ) );
1010 }
1011 
1013 {
1014  m_aIdle.Stop();
1015 }
1016 
1017 void UpdateRequiredDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage,
1018  bool bLicenseMissing )
1019 {
1020  // We will only add entries to the list with unsatisfied dependencies
1021  if ( !bLicenseMissing && !checkDependencies( xPackage ) )
1022  {
1023  m_bHasLockedEntries |= m_pManager->isReadOnly( xPackage );
1024  const SolarMutexGuard aGuard;
1025  m_xUpdateBtn->set_sensitive(true);
1026  m_xExtensionBox->addEntry( xPackage );
1027  }
1028 }
1029 
1030 
1032 {
1033  m_xExtensionBox->prepareChecking();
1034 }
1035 
1036 
1038 {
1039  const SolarMutexGuard guard;
1040  m_xExtensionBox->checkEntries();
1041 
1042  if ( ! hasActiveEntries() )
1043  {
1044  m_xCloseBtn->set_label( m_sCloseText );
1045  m_xCloseBtn->grab_focus();
1046  }
1047 }
1048 
1049 
1051 {
1052  if ( m_xAbortChannel.is() )
1053  {
1054  try
1055  {
1056  m_xAbortChannel->sendAbort();
1057  }
1058  catch ( const uno::RuntimeException & )
1059  {
1060  OSL_FAIL( "### unexpected RuntimeException!" );
1061  }
1062  }
1063 }
1064 
1065 
1066 IMPL_LINK( UpdateRequiredDialog, startProgress, void*, _bLockInterface, void )
1067 {
1068  ::osl::MutexGuard aGuard( m_aMutex );
1069  bool bLockInterface = static_cast<bool>(_bLockInterface);
1070 
1071  if ( m_bStartProgress && !m_bHasProgress )
1072  m_aIdle.Start();
1073 
1074  if ( m_bStopProgress )
1075  {
1076  if ( m_xProgressBar->get_visible() )
1077  m_xProgressBar->set_percentage( 100 );
1078  m_xAbortChannel.clear();
1079  SAL_INFO( "desktop.deployment", " startProgress handler: stop" );
1080  }
1081  else
1082  {
1083  SAL_INFO( "desktop.deployment", " startProgress handler: start" );
1084  }
1085 
1086  m_xCancelBtn->set_sensitive( bLockInterface );
1087  m_xUpdateBtn->set_sensitive( false );
1088  clearEventID();
1089 }
1090 
1091 
1093 {
1094  ::osl::MutexGuard aGuard( m_aMutex );
1095 
1096  bool bStart = _bStart;
1097 
1098  if ( bStart )
1099  {
1100  m_nProgress = 0;
1101  m_bStartProgress = true;
1102  SAL_INFO( "desktop.deployment", "showProgress start" );
1103  }
1104  else
1105  {
1106  m_nProgress = 100;
1107  m_bStopProgress = true;
1108  SAL_INFO( "desktop.deployment", "showProgress stop!" );
1109  }
1110 
1111  DialogHelper::PostUserEvent( LINK( this, UpdateRequiredDialog, startProgress ), reinterpret_cast<void*>(bStart) );
1112  m_aIdle.Start();
1113 }
1114 
1115 
1116 void UpdateRequiredDialog::updateProgress( const long nProgress )
1117 {
1118  if ( m_nProgress != nProgress )
1119  {
1120  ::osl::MutexGuard aGuard( m_aMutex );
1121  m_nProgress = nProgress;
1122  m_aIdle.Start();
1123  }
1124 }
1125 
1126 
1127 void UpdateRequiredDialog::updateProgress( const OUString &rText,
1128  const uno::Reference< task::XAbortChannel > &xAbortChannel)
1129 {
1130  ::osl::MutexGuard aGuard( m_aMutex );
1131 
1132  m_xAbortChannel = xAbortChannel;
1133  m_sProgressText = rText;
1134  m_bProgressChanged = true;
1135  m_aIdle.Start();
1136 }
1137 
1138 
1139 void UpdateRequiredDialog::updatePackageInfo( const uno::Reference< deployment::XPackage > &xPackage )
1140 {
1141  // We will remove all updated packages with satisfied dependencies, but
1142  // we will show all disabled entries so the user sees the result
1143  // of the 'disable all' button
1144  const SolarMutexGuard aGuard;
1145  if ( isEnabled( xPackage ) && checkDependencies( xPackage ) )
1146  m_xExtensionBox->removeEntry( xPackage );
1147  else
1148  m_xExtensionBox->updateEntry( xPackage );
1149 
1150  if ( ! hasActiveEntries() )
1151  {
1152  m_xCloseBtn->set_label( m_sCloseText );
1153  m_xCloseBtn->grab_focus();
1154  }
1155 }
1156 
1157 
1159 {
1160  ::osl::ClearableMutexGuard aGuard( m_aMutex );
1161 
1162  std::vector< uno::Reference< deployment::XPackage > > vUpdateEntries;
1163  sal_Int32 nCount = m_xExtensionBox->GetEntryCount();
1164 
1165  for ( sal_Int32 i = 0; i < nCount; ++i )
1166  {
1167  TEntry_Impl pEntry = m_xExtensionBox->GetEntryData( i );
1168  vUpdateEntries.push_back( pEntry->m_xPackage );
1169  }
1170 
1171  aGuard.clear();
1172 
1173  m_pManager->getCmdQueue()->checkForUpdates( vUpdateEntries );
1174 }
1175 
1176 
1178 {
1179  ::osl::MutexGuard aGuard( m_aMutex );
1180 
1181  if ( !isBusy() )
1182  {
1183  if ( m_bHasLockedEntries )
1184  m_xDialog->response(-1);
1185  else if ( hasActiveEntries() )
1186  disableAllEntries();
1187  else
1188  m_xDialog->response(RET_CANCEL);
1189  }
1190 }
1191 
1192 
1194 {
1195  if ( m_bStopProgress )
1196  {
1197  m_bHasProgress = false;
1198  m_bStopProgress = false;
1199  m_xProgressText->hide();
1200  m_xProgressBar->hide();
1201  m_xCancelBtn->hide();
1202  }
1203  else
1204  {
1205  if ( m_bProgressChanged )
1206  {
1207  m_bProgressChanged = false;
1208  m_xProgressText->set_label( m_sProgressText );
1209  }
1210 
1211  if ( m_bStartProgress )
1212  {
1213  m_bStartProgress = false;
1214  m_bHasProgress = true;
1215  m_xProgressBar->show();
1216  m_xProgressText->show();
1217  m_xCancelBtn->set_sensitive(true);
1218  m_xCancelBtn->show();
1219  }
1220 
1221  if (m_xProgressBar->get_visible())
1222  m_xProgressBar->set_percentage(m_nProgress);
1223  }
1224 }
1225 
1226 // VCL::Dialog
1228 {
1229  //ToDo
1230  //I believe m_bHasLockedEntries was used to prevent showing extensions which cannot
1231  //be disabled because they are in a read only repository. However, disabling extensions
1232  //is now always possible because the registration data of all repositories
1233  //are in the user installation.
1234  //Therefore all extensions could be displayed and all the handling around m_bHasLockedEntries
1235  //could be removed.
1236  if ( m_bHasLockedEntries )
1237  {
1238  // Set other text, disable update btn, remove not shared entries from list;
1239  m_xUpdateNeeded->set_label( DpResId( RID_STR_NO_ADMIN_PRIVILEGE ) );
1240  m_xCloseBtn->set_label( DpResId( RID_STR_EXIT_BTN ) );
1241  m_xUpdateBtn->set_sensitive( false );
1242  m_xExtensionBox->RemoveUnlocked();
1243  }
1244 
1245  return GenericDialogController::run();
1246 }
1247 
1248 // Check dependencies of all packages
1249 
1250 bool UpdateRequiredDialog::isEnabled( const uno::Reference< deployment::XPackage > &xPackage )
1251 {
1252  bool bRegistered = false;
1253  try {
1254  beans::Optional< beans::Ambiguous< sal_Bool > > option( xPackage->isRegistered( uno::Reference< task::XAbortChannel >(),
1255  uno::Reference< ucb::XCommandEnvironment >() ) );
1256  if ( option.IsPresent )
1257  {
1258  ::beans::Ambiguous< sal_Bool > const & reg = option.Value;
1259  if ( reg.IsAmbiguous )
1260  bRegistered = false;
1261  else
1262  bRegistered = reg.Value;
1263  }
1264  else
1265  bRegistered = false;
1266  }
1267  catch ( const uno::RuntimeException & ) { throw; }
1268  catch (const uno::Exception & ) {
1269  TOOLS_WARN_EXCEPTION( "desktop", "" );
1270  bRegistered = false;
1271  }
1272 
1273  return bRegistered;
1274 }
1275 
1276 // Checks the dependencies no matter if the extension is enabled or disabled!
1277 bool UpdateRequiredDialog::checkDependencies( const uno::Reference< deployment::XPackage > &xPackage )
1278 {
1279  bool bDependenciesValid = false;
1280  try {
1281  bDependenciesValid = xPackage->checkDependencies( uno::Reference< ucb::XCommandEnvironment >() );
1282  }
1283  catch ( const deployment::DeploymentException & ) {}
1284  return bDependenciesValid;
1285 }
1286 
1287 
1289 {
1290  ::osl::MutexGuard aGuard( m_aMutex );
1291 
1292  bool bRet = false;
1293  long nCount = m_xExtensionBox->GetEntryCount();
1294  for ( long nIndex = 0; nIndex < nCount; nIndex++ )
1295  {
1296  TEntry_Impl pEntry = m_xExtensionBox->GetEntryData( nIndex );
1297 
1298  if ( isEnabled(pEntry->m_xPackage) && !checkDependencies( pEntry->m_xPackage ) )
1299  {
1300  bRet = true;
1301  break;
1302  }
1303  }
1304 
1305  return bRet;
1306 }
1307 
1308 
1310 {
1311  ::osl::MutexGuard aGuard( m_aMutex );
1312 
1313  incBusy();
1314 
1315  long nCount = m_xExtensionBox->GetEntryCount();
1316  for ( long nIndex = 0; nIndex < nCount; nIndex++ )
1317  {
1318  TEntry_Impl pEntry = m_xExtensionBox->GetEntryData( nIndex );
1319  m_pManager->getCmdQueue()->enableExtension( pEntry->m_xPackage, false );
1320  }
1321 
1322  decBusy();
1323 
1324  if ( ! hasActiveEntries() )
1325  m_xCloseBtn->set_label( m_sCloseText );
1326 }
1327 
1328 // ShowLicenseDialog
1330  const uno::Reference< deployment::XPackage> &xPackage)
1331  : GenericDialogController(pParent, "desktop/ui/showlicensedialog.ui", "ShowLicenseDialog")
1332  , m_xLicenseText(m_xBuilder->weld_text_view("textview"))
1333 {
1334  m_xLicenseText->set_size_request(m_xLicenseText->get_approximate_digit_width() * 72,
1335  m_xLicenseText->get_height_rows(21));
1336  m_xLicenseText->set_text(xPackage->getLicenseText());
1337 }
1338 
1340 {
1341 }
1342 
1343 // UpdateRequiredDialogService
1344 
1345 UpdateRequiredDialogService::UpdateRequiredDialogService( SAL_UNUSED_PARAMETER uno::Sequence< uno::Any > const&,
1346  uno::Reference< uno::XComponentContext > const& xComponentContext )
1347  : m_xComponentContext( xComponentContext )
1348 {
1349 }
1350 
1351 
1352 // XExecutableDialog
1353 
1355 {
1356 }
1357 
1358 
1360 {
1363  xManager->createDialog( true );
1364  sal_Int16 nRet = xManager->execute();
1365 
1366  return nRet;
1367 }
1368 
1369 
1370 } //namespace dp_gui
1371 
1372 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
std::shared_ptr< weld::Dialog > m_xDialog
TEntry_Impl const & GetEntryData(long nPos)
UpdateRequiredDialog(weld::Window *pParent, TheExtensionManager *pManager)
sal_Int32 nIndex
bool installExtensionWarn(const OUString &rExtensionURL)
virtual void addPackageToList(const css::uno::Reference< css::deployment::XPackage > &, bool bLicenseMissing=false) override
virtual ~ShowLicenseDialog() override
void setGetExtensionsURL(const OUString &rURL)
osl::Mutex m_aMutex
css::uno::Sequence< OUString > raiseAddPicker()
static SfxAbstractDialogFactory * Create()
static bool isEnabled(const css::uno::Reference< css::deployment::XPackage > &xPackage)
#define SHARED_PACKAGE_MANAGER
virtual short run() override
css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel
virtual void prepareChecking() override
virtual ~UpdateRequiredDialog() override
RESTART_REASON_EXTENSION_INSTALL
void setExtensionManager(TheExtensionManager *pManager)
DialogHelper(const css::uno::Reference< css::uno::XComponentContext > &, weld::Window *pWindow)
virtual void updateProgress(const OUString &rText, const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel) override
const css::uno::Reference< css::deployment::XExtensionManager > & getExtensionManager() const
std::unique_ptr< weld::Button > m_xOptionsBtn
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
std::unique_ptr< weld::CheckButton > m_xSharedCbx
void PostUserEvent(const Link< void *, void > &rLink, void *pCaller)
bool office_is_running()
Definition: dp_misc.cxx:333
virtual ~ExtMgrDialog() override
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
std::unique_ptr< weld::ProgressBar > m_xProgressBar
virtual short Execute()=0
std::unique_ptr< weld::CheckButton > m_xUserCbx
std::unique_ptr< weld::Button > m_xUpdateBtn
virtual Dialog * getDialog() override
RET_CANCEL
css::uno::Reference< css::deployment::XPackageRegistry > create(css::uno::Reference< css::deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)
IMPL_LINK_NOARG(ExtMgrDialog, HandleCancelBtn, weld::Button &, void)
virtual bool Command(const CommandEvent &rCEvt) override
std::unique_ptr< weld::LinkButton > m_xGetExtensions
virtual VclPtr< VclAbstractDialog > CreateOptionsDialog(weld::Window *pParent, const OUString &rExtensionId)=0
std::unique_ptr< weld::Button > m_xEnableBtn
ShowLicenseDialog(weld::Window *pParent, const css::uno::Reference< css::deployment::XPackage > &xPackage)
virtual void updatePackageInfo(const css::uno::Reference< css::deployment::XPackage > &xPackage) override
RET_NO
static::rtl::Reference< TheExtensionManager > get(css::uno::Reference< css::uno::XComponentContext > const &xContext, css::uno::Reference< css::awt::XWindow > const &xParent=nullptr, OUString const &view=OUString())
virtual void selectEntry(const long nPos)
virtual void showProgress(bool bStart) override
std::locale Create(const char *pPrefixName, const LanguageTag &rLocale)
JCOPY_OPTION option
std::unique_ptr< weld::Label > m_xUpdateNeeded
void SetButtonStatus(const TEntry_Impl &rEntry)
css::uno::Reference< css::uno::XComponentContext > m_xContext
bool removeExtensionWarn(const OUString &rExtensionTitle)
Any SAL_CALL getCaughtException()
size_t pos
void removePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage)
int nCount
void enablePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage, bool bEnable)
virtual void Start() override
long PointToPos(const Point &rPos)
css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel
void removeExtension(const css::uno::Reference< css::deployment::XPackage > &rPackage)
std::unique_ptr< weld::Button > m_xUpdateBtn
void enableOptionsButton(bool bEnable)
ImplSVEvent * m_nEventID
void SetDebugName(const char *pDebugName)
Reference< XComponentContext > const m_xComponentContext
virtual void updateProgress(const OUString &rText, const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel) override
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
std::unique_ptr< weld::Button > m_xCloseBtn
std::unique_ptr< weld::ProgressBar > m_xProgressBar
#define TOOLS_WARN_EXCEPTION(area, stream)
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
int i
static OUString getProductName()
bool acceptLicense(const css::uno::Reference< css::deployment::XPackage > &xPackage)
void checkForUpdates(const std::vector< css::uno::Reference< css::deployment::XPackage > > &vList)
bool isReadOnly(const css::uno::Reference< css::deployment::XPackage > &xPackage) const
std::unique_ptr< ExtensionBox_Impl > m_xExtensionBox
virtual void checkEntries() override
void openWebBrowser(const OUString &rURL, const OUString &rTitle)
virtual void selectEntry(const long nPos) override
void updatePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage)
CommandEventId GetCommand() const
static bool checkDependencies(const css::uno::Reference< css::deployment::XPackage > &xPackage)
ExtMgrDialog(weld::Window *pParent, TheExtensionManager *pManager)
void enableEnableButton(bool bEnable)
virtual void updatePackageInfo(const css::uno::Reference< css::deployment::XPackage > &xPackage) override
std::unique_ptr< weld::Button > m_xAddBtn
virtual sal_Int16 SAL_CALL execute() override
#define BUNDLED_PACKAGE_MANAGER
sal_Int32 getSelIndex() const
const Point & GetMousePosPixel() const
static uno::Reference< css::uno::XComponentContext > xContext
Definition: init.cxx:2094
void enableButtontoEnable(bool bEnable)
bool installForAllUsers(bool &bInstallForAll)
void acceptLicense(const css::uno::Reference< css::deployment::XPackage > &rPackage)
weld::DrawingArea * GetDrawingArea() const
OString ShowPopupMenu(const Point &rPos, const long nPos)
TheExtensionManager * m_pManager
sal_Int32 getItemCount() const
void Stop()
std::unique_ptr< weld::Button > m_xCancelBtn
void enableExtension(const css::uno::Reference< css::deployment::XPackage > &rPackage, const bool bEnable)
std::unique_ptr< weld::Button > m_xCancelBtn
ExtBoxWithBtns_Impl(std::unique_ptr< weld::ScrolledWindow > xScroll)
#define HID_EXTENSION_MANAGER_LISTBOX_DISABLE
Definition: helpids.h:24
ExtensionCmdQueue * getCmdQueue() const
#define SAL_INFO(area, stream)
virtual void RecalcAll() override
std::unique_ptr< weld::Button > m_xCloseBtn
TheExtensionManager * getExtensionManager() const
RET_OK
#define USER_PACKAGE_MANAGER
std::unique_ptr< ExtBoxWithBtns_Impl > m_xExtensionBox
uno::Reference< deployment::XPackage > m_xPackage
TheExtensionManager * m_pManager
bool continueOnSharedExtension(const css::uno::Reference< css::deployment::XPackage > &, weld::Widget *pParent, const char *pResID, bool &bHadWarning)
weld::Window * getFrameWeld() const
Reference< XExecutableDialog > m_xDialog
virtual short run()
std::unique_ptr< weld::Button > m_xRemoveBtn
Reference< XComponentContext > getProcessComponentContext()
void SetInvokeHandler(const Link< Timer *, void > &rLink)
const OUString m_sAddPackages
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage)
void enableButtons(bool bEnable)
static weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIFile)
OUString DpResId(const char *pId)
Definition: dp_shared.hxx:37
void SetPriority(TaskPriority ePriority)
OUString get(const char *pContextAndId, const std::locale &loc)
virtual void checkEntries() override
UpdateRequiredDialogService(css::uno::Sequence< css::uno::Any > const &args, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)
css::uno::Reference< css::uno::XComponentContext > const m_xComponentContext
Definition: dp_gui.h:23
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString getIdentifier(css::uno::Reference< css::deployment::XPackage > const &package)
Gets the identifier of a package.
const css::uno::Reference< css::ui::dialogs::XFilePicker3 > & GetFilePicker() const
virtual bool Command(const CommandEvent &)
std::unique_ptr< weld::CheckButton > m_xBundledCbx
void InitFromDialog(ExtMgrDialog *pParentDialog)
virtual void prepareChecking() override
std::unique_ptr< weld::TextView > m_xLicenseText
#define HID_EXTENSION_MANAGER_LISTBOX_ENABLE
Definition: helpids.h:23
void enableRemoveButton(bool bEnable)
virtual void SAL_CALL setTitle(OUString const &title) override
sal_uInt16 nPos
std::shared_ptr< Entry_Impl > TEntry_Impl
virtual void showProgress(bool bStart) override
OUString anyToString(uno::Any const &value)
IMPL_LINK(ExtMgrDialog, startProgress, void *, _bLockInterface, void)
static bool IsSharedPkgMgr(const css::uno::Reference< css::deployment::XPackage > &)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC css::uno::Reference< css::deployment::XPackage > getExtensionWithHighestVersion(css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > const &seqExtensionsWithSameId)
virtual void addPackageToList(const css::uno::Reference< css::deployment::XPackage > &, bool bLicenseMissing=false) override
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo