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 #ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_GUI_DP_GUI_DIALOG2_HXX
21 #define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_GUI_DP_GUI_DIALOG2_HXX
22 
23 #include <config_extensions.h>
24 
25 #include <vcl/dialog.hxx>
26 #include <vcl/button.hxx>
27 #include <vcl/fixed.hxx>
28 #include <vcl/fixedhyper.hxx>
29 #include <vcl/prgsbar.hxx>
30 #include <vcl/timer.hxx>
31 #include <vcl/idle.hxx>
32 #include <vcl/waitobj.hxx>
33 #include <vcl/weld.hxx>
34 
35 #include <osl/conditn.hxx>
36 #include <osl/mutex.hxx>
37 
38 #include <rtl/ref.hxx>
39 #include <rtl/ustring.hxx>
40 
41 #include <cppuhelper/implbase.hxx>
42 
43 #include <com/sun/star/awt/XWindow.hpp>
44 #include <com/sun/star/deployment/XPackage.hpp>
45 #include <com/sun/star/uno/XComponentContext.hpp>
46 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
47 #include <com/sun/star/util/XModifyListener.hpp>
48 
49 #include <stack>
50 #include <vector>
51 
52 namespace dp_gui {
53 
54 
55 class ExtBoxWithBtns_Impl;
56 class ExtensionBox_Impl;
57 class TheExtensionManager;
58 
59 
61 {
62  css::uno::Reference< css::uno::XComponentContext > m_xContext;
66 
67 public:
68  DialogHelper( const css::uno::Reference< css::uno::XComponentContext > &,
69  Dialog *pWindow );
70  virtual ~DialogHelper();
71 
72  void openWebBrowser(const OUString& rURL, const OUString& rTitle);
73  Dialog* getWindow() const { return m_xVCLWindow; };
74  weld::Window* getFrameWeld() const { return m_xVCLWindow ? m_xVCLWindow->GetFrameWeld() : nullptr; }
75  void PostUserEvent( const Link<void*,void>& rLink, void* pCaller );
76  void clearEventID() { m_nEventID = nullptr; }
77 
78  virtual void showProgress( bool bStart ) = 0;
79  virtual void updateProgress( const OUString &rText,
80  const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel) = 0;
81  virtual void updateProgress( const long nProgress ) = 0;
82 
83  virtual void updatePackageInfo( const css::uno::Reference< css::deployment::XPackage > &xPackage ) = 0;
84  virtual void addPackageToList( const css::uno::Reference< css::deployment::XPackage > &xPackage,
85  bool bLicenseMissing = false ) = 0;
86 
87  virtual void prepareChecking() = 0;
88  virtual void checkEntries() = 0;
89 
90  static bool IsSharedPkgMgr( const css::uno::Reference< css::deployment::XPackage > &);
91  bool continueOnSharedExtension( const css::uno::Reference< css::deployment::XPackage > &,
92  weld::Widget* pParent,
93  const char* pResID,
94  bool &bHadWarning );
95 
96  void incBusy() { m_aBusy.incBusy(m_xVCLWindow->GetFrameWeld()); }
97  void decBusy() { m_aBusy.decBusy(); }
98  bool isBusy() const { return m_aBusy.isBusy(); }
99  bool installExtensionWarn(const OUString &rExtensionURL);
100  bool installForAllUsers(bool &bInstallForAll);
101 };
102 
104  public DialogHelper
105 {
121  const OUString m_sAddPackages;
122  OUString m_sProgressText;
124  ::osl::Mutex m_aMutex;
132  bool m_bClosed;
136 
137  css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel;
138 
139  bool removeExtensionWarn(const OUString &rExtensionTitle);
140 
141  DECL_LINK( HandleOptionsBtn, Button*, void );
142  DECL_LINK( HandleAddBtn, Button*, void );
143  DECL_LINK( HandleRemoveBtn, Button*, void );
144  DECL_LINK( HandleEnableBtn, Button*, void );
145  DECL_LINK( HandleUpdateBtn, Button*, void );
146  DECL_LINK( HandleCancelBtn, Button*, void );
147  DECL_LINK( HandleCloseBtn, Button*, void );
148  DECL_LINK( HandleExtTypeCbx, Button*, void );
149  DECL_LINK( TimeOutHdl, Timer *, void );
150  DECL_LINK( startProgress, void *, void );
151  DECL_STATIC_LINK( ExtMgrDialog, Restart, void *, void );
152 
153 public:
155  virtual ~ExtMgrDialog() override;
156  virtual void dispose() override;
157 
158  virtual bool EventNotify( NotifyEvent& rNEvt ) override;
159  virtual bool Close() override;
160 
161  virtual void showProgress( bool bStart ) override;
162  virtual void updateProgress( const OUString &rText,
163  const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel) override;
164  virtual void updateProgress( const long nProgress ) override;
165 
166  virtual void updatePackageInfo( const css::uno::Reference< css::deployment::XPackage > &xPackage ) override;
167 
168  void setGetExtensionsURL( const OUString &rURL );
169  virtual void addPackageToList( const css::uno::Reference< css::deployment::XPackage > &,
170  bool bLicenseMissing = false ) override;
171  void enablePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage,
172  bool bEnable );
173  void removePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage );
174  void updatePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage );
175  bool acceptLicense(const css::uno::Reference< css::deployment::XPackage > &xPackage );
176 
178 
179  virtual void prepareChecking() override;
180  virtual void checkEntries() override;
181 
182  css::uno::Sequence< OUString > raiseAddPicker();
183 
184  void enableOptionsButton( bool bEnable );
185  void enableRemoveButton( bool bEnable );
186  void enableEnableButton( bool bEnable );
187  /*
188  * Transform the button to "Enable", or to "Disable"
189  * based on the value of bEnable.
190  */
191  void enableButtontoEnable( bool bEnable );
192 };
193 
194 
196  public DialogHelper
197 {
205  const OUString m_sCloseText;
206  OUString m_sProgressText;
207  ::osl::Mutex m_aMutex;
216 
217  css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel;
218 
219  DECL_LINK( HandleUpdateBtn, Button*, void );
220  DECL_LINK( HandleCloseBtn, Button*, void );
221  DECL_LINK( HandleCancelBtn, Button*, void );
222  DECL_LINK( TimeOutHdl, Timer *, void );
223  DECL_LINK( startProgress, void *, void );
224 
225  static bool isEnabled( const css::uno::Reference< css::deployment::XPackage > &xPackage );
226  static bool checkDependencies( const css::uno::Reference< css::deployment::XPackage > &xPackage );
227  bool hasActiveEntries();
228  void disableAllEntries();
229 
230 public:
231  UpdateRequiredDialog( vcl::Window * pParent, TheExtensionManager *pManager );
232  virtual ~UpdateRequiredDialog() override;
233  virtual void dispose() override;
234 
235  virtual short Execute() override;
236  virtual bool Close() override;
237 
238  virtual void showProgress( bool bStart ) override;
239  virtual void updateProgress( const OUString &rText,
240  const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel) override;
241  virtual void updateProgress( const long nProgress ) override;
242 
243  virtual void updatePackageInfo( const css::uno::Reference< css::deployment::XPackage > &xPackage ) override;
244 
245  virtual void addPackageToList( const css::uno::Reference< css::deployment::XPackage > &,
246  bool bLicenseMissing = false ) override;
247 
248  virtual void prepareChecking() override;
249  virtual void checkEntries() override;
250 };
251 
252 
254 {
255  std::unique_ptr<weld::TextView> m_xLicenseText;
256 public:
257  ShowLicenseDialog(weld::Window * pParent, const css::uno::Reference< css::deployment::XPackage > &xPackage);
258  virtual ~ShowLicenseDialog() override;
259 };
260 
261 class UpdateRequiredDialogService : public ::cppu::WeakImplHelper< css::ui::dialogs::XExecutableDialog >
262 {
263  css::uno::Reference< css::uno::XComponentContext > const m_xComponentContext;
264 public:
265  UpdateRequiredDialogService( css::uno::Sequence< css::uno::Any > const & args,
266  css::uno::Reference< css::uno::XComponentContext> const & xComponentContext );
267 
268  // XExecutableDialog
269  virtual void SAL_CALL setTitle( OUString const & title ) override;
270  virtual sal_Int16 SAL_CALL execute() override;
271 };
272 
273 } // namespace dp_gui
274 
275 #endif
276 
277 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void updateProgress(const OUString &rText, const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel)=0
VclPtr< FixedText > m_pProgressText
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)
css::uno::Sequence< OUString > raiseAddPicker()
static bool isEnabled(const css::uno::Reference< css::deployment::XPackage > &xPackage)
VclPtr< vcl::Window > m_xRestartParent
css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel
TopLevelWindowLocker m_aBusy
virtual void prepareChecking() override
virtual ~UpdateRequiredDialog() override
virtual void updateProgress(const OUString &rText, const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel) override
VclPtr< FixedText > m_pProgressText
void PostUserEvent(const Link< void *, void > &rLink, void *pCaller)
virtual ~ExtMgrDialog() override
DECL_LINK(HandleOptionsBtn, Button *, void)
virtual void addPackageToList(const css::uno::Reference< css::deployment::XPackage > &xPackage, bool bLicenseMissing=false)=0
DECL_STATIC_LINK(ExtMgrDialog, Restart, void *, void)
virtual void checkEntries()=0
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
VclPtr< PushButton > m_pCloseBtn
VclPtr< PushButton > m_pRemoveBtn
virtual void showProgress(bool bStart)=0
weld::Window * GetFrameWeld() const
VclPtr< ProgressBar > m_pProgressBar
DECL_LINK(HandleUpdateBtn, Button *, void)
virtual void showProgress(bool bStart) override
VclPtr< FixedText > m_pUpdateNeeded
VclPtr< Dialog > m_xVCLWindow
VclPtr< PushButton > m_pEnableBtn
virtual void prepareChecking()=0
css::uno::Reference< css::uno::XComponentContext > m_xContext
bool removeExtensionWarn(const OUString &rExtensionTitle)
void removePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage)
void enablePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage, bool bEnable)
Dialog * getWindow() const
css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel
VclPtr< CheckBox > m_pBundledCbx
VclPtr< PushButton > m_pAddBtn
VclPtr< ExtBoxWithBtns_Impl > m_pExtensionBox
void enableOptionsButton(bool bEnable)
ImplSVEvent * m_nEventID
virtual void updateProgress(const OUString &rText, const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel) override
VclPtr< PushButton > m_pOptionsBtn
bool acceptLicense(const css::uno::Reference< css::deployment::XPackage > &xPackage)
VclPtr< FixedHyperlink > m_pGetExtensions
virtual void checkEntries() override
VclPtr< CancelButton > m_pCancelBtn
void openWebBrowser(const OUString &rURL, const OUString &rTitle)
void updatePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage)
virtual bool Close() override
static bool checkDependencies(const css::uno::Reference< css::deployment::XPackage > &xPackage)
void enableEnableButton(bool bEnable)
VclPtr< CheckBox > m_pUserCbx
virtual void updatePackageInfo(const css::uno::Reference< css::deployment::XPackage > &xPackage) override
VclPtr< ProgressBar > m_pProgressBar
VclPtr< CheckBox > m_pSharedCbx
VclPtr< CloseButton > m_pCloseBtn
virtual bool Close() override
VclPtr< ExtensionBox_Impl > m_pExtensionBox
virtual sal_Int16 SAL_CALL execute() override
virtual short Execute() override
virtual void dispose() override
UpdateRequiredDialog(vcl::Window *pParent, TheExtensionManager *pManager)
void incBusy(const weld::Window *pIgnore)
void enableButtontoEnable(bool bEnable)
bool installForAllUsers(bool &bInstallForAll)
TheExtensionManager * m_pManager
virtual void dispose() override
VclPtr< PushButton > m_pUpdateBtn
DialogHelper(const css::uno::Reference< css::uno::XComponentContext > &, Dialog *pWindow)
TheExtensionManager * getExtensionManager() const
TheExtensionManager * m_pManager
bool continueOnSharedExtension(const css::uno::Reference< css::deployment::XPackage > &, weld::Widget *pParent, const char *pResID, bool &bHadWarning)
weld::Window * getFrameWeld() const
const OUString m_sAddPackages
VclPtr< PushButton > m_pUpdateBtn
VclPtr< CancelButton > m_pCancelBtn
virtual void updatePackageInfo(const css::uno::Reference< css::deployment::XPackage > &xPackage)=0
ExtMgrDialog(vcl::Window *pParent, TheExtensionManager *pManager, Dialog::InitFlag eFlag=Dialog::InitFlag::Default)
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:59
virtual bool EventNotify(NotifyEvent &rNEvt) override
virtual void prepareChecking() override
std::unique_ptr< weld::TextView > m_xLicenseText
void enableRemoveButton(bool bEnable)
virtual void SAL_CALL setTitle(OUString const &title) override
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