LibreOffice Module desktop (master)  1
dp_gui_dialog2.hxx
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 #pragma once
21 
22 #include <vcl/timer.hxx>
23 #include <vcl/idle.hxx>
24 #include <vcl/locktoplevels.hxx>
25 #include <vcl/customweld.hxx>
26 #include <vcl/weld.hxx>
27 
28 #include <osl/mutex.hxx>
29 
30 #include <rtl/ustring.hxx>
31 
32 #include <cppuhelper/implbase.hxx>
33 #include <unotools/resmgr.hxx>
34 
35 #include <com/sun/star/deployment/XPackage.hpp>
36 #include <com/sun/star/uno/XComponentContext.hpp>
37 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
38 #include <com/sun/star/lang/XServiceInfo.hpp>
39 
40 struct ImplSVEvent;
41 
42 namespace dp_gui {
43 
44 class ExtBoxWithBtns_Impl;
45 class ExtensionBox_Impl;
46 class TheExtensionManager;
47 
49 {
50  css::uno::Reference< css::uno::XComponentContext > m_xContext;
54 
55 public:
56  DialogHelper(const css::uno::Reference< css::uno::XComponentContext > &,
57  weld::Window* pWindow);
58  virtual ~DialogHelper();
59 
60  void openWebBrowser(const OUString& rURL, const OUString& rTitle);
61  weld::Window* getFrameWeld() const { return m_pWindow; }
62  void PostUserEvent( const Link<void*,void>& rLink, void* pCaller );
63  void clearEventID() { m_nEventID = nullptr; }
64 
65  virtual void showProgress( bool bStart ) = 0;
66  virtual void updateProgress( const OUString &rText,
67  const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel) = 0;
68  virtual void updateProgress( const tools::Long nProgress ) = 0;
69 
70  virtual void updatePackageInfo( const css::uno::Reference< css::deployment::XPackage > &xPackage ) = 0;
71  virtual void addPackageToList( const css::uno::Reference< css::deployment::XPackage > &xPackage,
72  bool bLicenseMissing = false ) = 0;
73 
74  virtual void prepareChecking() = 0;
75  virtual void checkEntries() = 0;
76 
77  static bool IsSharedPkgMgr( const css::uno::Reference< css::deployment::XPackage > &);
78  bool continueOnSharedExtension( const css::uno::Reference< css::deployment::XPackage > &,
79  weld::Widget* pParent,
80  TranslateId pResID,
81  bool &bHadWarning );
82 
83  void incBusy() { m_aBusy.incBusy(m_pWindow); }
84  void decBusy() { m_aBusy.decBusy(); }
85  bool isBusy() const { return m_aBusy.isBusy(); }
86  bool installExtensionWarn(std::u16string_view rExtensionURL);
87  bool installForAllUsers(bool &bInstallForAll);
88 };
89 
91  , public DialogHelper
92 {
93  const OUString m_sAddPackages;
94  OUString m_sProgressText;
95  ::osl::Mutex m_aMutex;
103  bool m_bClosed;
107 
108  css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel;
109 
110  std::unique_ptr<ExtBoxWithBtns_Impl> m_xExtensionBox;
111  std::unique_ptr<weld::CustomWeld> m_xExtensionBoxWnd;
112  std::unique_ptr<weld::Button> m_xOptionsBtn;
113  std::unique_ptr<weld::Button> m_xAddBtn;
114  std::unique_ptr<weld::Button> m_xRemoveBtn;
115  std::unique_ptr<weld::Button> m_xEnableBtn;
116  std::unique_ptr<weld::Button> m_xUpdateBtn;
117  std::unique_ptr<weld::Button> m_xCloseBtn;
118  std::unique_ptr<weld::CheckButton> m_xBundledCbx;
119  std::unique_ptr<weld::CheckButton> m_xSharedCbx;
120  std::unique_ptr<weld::CheckButton> m_xUserCbx;
121  std::unique_ptr<weld::LinkButton> m_xGetExtensions;
122  std::unique_ptr<weld::Label> m_xProgressText;
123  std::unique_ptr<weld::ProgressBar> m_xProgressBar;
124  std::unique_ptr<weld::Button> m_xCancelBtn;
125  std::unique_ptr<weld::Entry> m_xSearchEntry;
126 
127  bool removeExtensionWarn(std::u16string_view rExtensionTitle);
128 
129  DECL_LINK( HandleOptionsBtn, weld::Button&, void );
130  DECL_LINK( HandleAddBtn, weld::Button&, void );
131  DECL_LINK( HandleRemoveBtn, weld::Button&, void );
132  DECL_LINK( HandleEnableBtn, weld::Button&, void );
133  DECL_LINK( HandleUpdateBtn, weld::Button&, void );
134  DECL_LINK( HandleCancelBtn, weld::Button&, void );
135  DECL_LINK( HandleCloseBtn, weld::Button&, void );
136  DECL_LINK( HandleExtTypeCbx, weld::Toggleable&, void );
137  DECL_LINK( HandleSearch, weld::Entry&, void );
138  DECL_LINK( TimeOutHdl, Timer *, void );
139  DECL_LINK( startProgress, void *, void );
140 
141 public:
142  ExtMgrDialog(weld::Window * pParent, TheExtensionManager *pManager);
143  virtual ~ExtMgrDialog() override;
144 
145  virtual void showProgress( bool bStart ) override;
146  virtual void updateProgress( const OUString &rText,
147  const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel) override;
148  virtual void updateProgress( const tools::Long nProgress ) override;
149 
150  virtual void updatePackageInfo( const css::uno::Reference< css::deployment::XPackage > &xPackage ) override;
151 
152  void setGetExtensionsURL( const OUString &rURL );
153  virtual void addPackageToList( const css::uno::Reference< css::deployment::XPackage > &,
154  bool bLicenseMissing = false ) override;
155  void enablePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage,
156  bool bEnable );
157  void removePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage );
158  void updatePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage );
159  bool acceptLicense(const css::uno::Reference< css::deployment::XPackage > &xPackage );
160 
161  void Close();
162 
164 
165  virtual void updateList();
166  virtual void prepareChecking() override;
167  virtual void checkEntries() override;
168 
169  css::uno::Sequence< OUString > raiseAddPicker();
170 
171  void enableOptionsButton( bool bEnable );
172  void enableRemoveButton( bool bEnable );
173  void enableEnableButton( bool bEnable );
174  /*
175  * Transform the button to "Enable", or to "Disable"
176  * based on the value of bEnable.
177  */
178  void enableButtontoEnable( bool bEnable );
179 };
180 
181 
183  , public DialogHelper
184 {
185  const OUString m_sCloseText;
186  OUString m_sProgressText;
187  ::osl::Mutex m_aMutex;
196 
197  css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel;
198 
199  std::unique_ptr<ExtensionBox_Impl> m_xExtensionBox;
200  std::unique_ptr<weld::CustomWeld> m_xExtensionBoxWnd;
201  std::unique_ptr<weld::Label> m_xUpdateNeeded;
202  std::unique_ptr<weld::Button> m_xUpdateBtn;
203  std::unique_ptr<weld::Button> m_xCloseBtn;
204  std::unique_ptr<weld::Button> m_xCancelBtn;
205  std::unique_ptr<weld::Label> m_xProgressText;
206  std::unique_ptr<weld::ProgressBar> m_xProgressBar;
207 
208  DECL_LINK( HandleUpdateBtn, weld::Button&, void );
209  DECL_LINK( HandleCloseBtn, weld::Button&, void );
210  DECL_LINK( HandleCancelBtn, weld::Button&, void );
211  DECL_LINK( TimeOutHdl, Timer *, void );
212  DECL_LINK( startProgress, void *, void );
213 
214  static bool isEnabled( const css::uno::Reference< css::deployment::XPackage > &xPackage );
215  static bool checkDependencies( const css::uno::Reference< css::deployment::XPackage > &xPackage );
216  bool hasActiveEntries();
217  void disableAllEntries();
218 
219 public:
221  virtual ~UpdateRequiredDialog() override;
222 
223  virtual short run() override;
224 
225  virtual void showProgress( bool bStart ) override;
226  virtual void updateProgress( const OUString &rText,
227  const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel) override;
228  virtual void updateProgress( const tools::Long nProgress ) override;
229 
230  virtual void updatePackageInfo( const css::uno::Reference< css::deployment::XPackage > &xPackage ) override;
231 
232  virtual void addPackageToList( const css::uno::Reference< css::deployment::XPackage > &,
233  bool bLicenseMissing = false ) override;
234 
235  virtual void prepareChecking() override;
236  virtual void checkEntries() override;
237 };
238 
239 
241 {
242  std::unique_ptr<weld::TextView> m_xLicenseText;
243 public:
244  ShowLicenseDialog(weld::Window * pParent, const css::uno::Reference< css::deployment::XPackage > &xPackage);
245  virtual ~ShowLicenseDialog() override;
246 };
247 
248 class UpdateRequiredDialogService : public ::cppu::WeakImplHelper< css::ui::dialogs::XExecutableDialog, css::lang::XServiceInfo >
249 {
250  css::uno::Reference< css::uno::XComponentContext > const m_xComponentContext;
251 public:
252  UpdateRequiredDialogService( css::uno::Sequence< css::uno::Any > const & args,
253  css::uno::Reference< css::uno::XComponentContext> const & xComponentContext );
254 
255  // XServiceInfo
256  virtual OUString SAL_CALL getImplementationName() override;
257  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
258  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
259 
260  // XExecutableDialog
261  virtual void SAL_CALL setTitle( OUString const & title ) override;
262  virtual sal_Int16 SAL_CALL execute() override;
263 };
264 
265 } // namespace dp_gui
266 
267 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void updateProgress(const OUString &rText, const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel)=0
UpdateRequiredDialog(weld::Window *pParent, TheExtensionManager *pManager)
virtual void addPackageToList(const css::uno::Reference< css::deployment::XPackage > &, bool bLicenseMissing=false) override
virtual ~ShowLicenseDialog() override
void setGetExtensionsURL(const OUString &rURL)
css::uno::Sequence< OUString > raiseAddPicker()
static bool isEnabled(const css::uno::Reference< css::deployment::XPackage > &xPackage)
virtual short run() override
css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel
TopLevelWindowLocker m_aBusy
virtual void prepareChecking() override
virtual ~UpdateRequiredDialog() override
std::unique_ptr< weld::CustomWeld > m_xExtensionBoxWnd
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
std::unique_ptr< weld::Button > m_xOptionsBtn
std::unique_ptr< weld::CheckButton > m_xSharedCbx
void PostUserEvent(const Link< void *, void > &rLink, void *pCaller)
virtual ~ExtMgrDialog() override
std::unique_ptr< weld::ProgressBar > m_xProgressBar
weld::Window * m_pWindow
std::unique_ptr< weld::CheckButton > m_xUserCbx
std::unique_ptr< weld::Button > m_xUpdateBtn
virtual void addPackageToList(const css::uno::Reference< css::deployment::XPackage > &xPackage, bool bLicenseMissing=false)=0
std::unique_ptr< weld::LinkButton > m_xGetExtensions
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void checkEntries()=0
std::unique_ptr< weld::Button > m_xEnableBtn
bool isBusy() const
ShowLicenseDialog(weld::Window *pParent, const css::uno::Reference< css::deployment::XPackage > &xPackage)
virtual void updatePackageInfo(const css::uno::Reference< css::deployment::XPackage > &xPackage) override
virtual void showProgress(bool bStart)=0
virtual void showProgress(bool bStart) override
virtual void prepareChecking()=0
std::unique_ptr< weld::Label > m_xUpdateNeeded
css::uno::Reference< css::uno::XComponentContext > m_xContext
void removePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage)
void enablePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage, bool bEnable)
css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel
std::unique_ptr< weld::Button > m_xUpdateBtn
void enableOptionsButton(bool bEnable)
ImplSVEvent * m_nEventID
DECL_LINK(HandleOptionsBtn, weld::Button &, void)
virtual void updateProgress(const OUString &rText, const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel) override
std::unique_ptr< weld::Button > m_xCloseBtn
std::unique_ptr< weld::ProgressBar > m_xProgressBar
DECL_LINK(HandleUpdateBtn, weld::Button &, void)
bool acceptLicense(const css::uno::Reference< css::deployment::XPackage > &xPackage)
std::unique_ptr< weld::Label > m_xProgressText
std::unique_ptr< weld::CustomWeld > m_xExtensionBoxWnd
std::unique_ptr< ExtensionBox_Impl > m_xExtensionBox
std::unique_ptr< weld::Entry > m_xSearchEntry
virtual void checkEntries() override
void openWebBrowser(const OUString &rURL, const OUString &rTitle)
void updatePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage)
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)
bool continueOnSharedExtension(const css::uno::Reference< css::deployment::XPackage > &, weld::Widget *pParent, TranslateId pResID, bool &bHadWarning)
virtual void updatePackageInfo(const css::uno::Reference< css::deployment::XPackage > &xPackage) override
std::unique_ptr< weld::Button > m_xAddBtn
virtual sal_Int16 SAL_CALL execute() override
bool removeExtensionWarn(std::u16string_view rExtensionTitle)
void enableButtontoEnable(bool bEnable)
bool installForAllUsers(bool &bInstallForAll)
TheExtensionManager * m_pManager
std::unique_ptr< weld::Button > m_xCancelBtn
std::unique_ptr< weld::Button > m_xCancelBtn
virtual void updateList()
std::unique_ptr< weld::Button > m_xCloseBtn
TheExtensionManager * getExtensionManager() const
std::unique_ptr< ExtBoxWithBtns_Impl > m_xExtensionBox
TheExtensionManager * m_pManager
weld::Window * getFrameWeld() const
std::unique_ptr< weld::Button > m_xRemoveBtn
const OUString m_sAddPackages
virtual void updatePackageInfo(const css::uno::Reference< css::deployment::XPackage > &xPackage)=0
std::unique_ptr< weld::Label > m_xProgressText
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
std::unique_ptr< weld::CheckButton > m_xBundledCbx
virtual void prepareChecking() override
std::unique_ptr< weld::TextView > m_xLicenseText
void enableRemoveButton(bool bEnable)
virtual void SAL_CALL setTitle(OUString const &title) override
void incBusy(const weld::Widget *pIgnore)
virtual void showProgress(bool bStart) override
static bool IsSharedPkgMgr(const css::uno::Reference< css::deployment::XPackage > &)
virtual void addPackageToList(const css::uno::Reference< css::deployment::XPackage > &, bool bLicenseMissing=false) override