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