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