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