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