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 <svtools/svmedit.hxx>
36 
37 #include <osl/conditn.hxx>
38 #include <osl/mutex.hxx>
39 
40 #include <rtl/ref.hxx>
41 #include <rtl/ustring.hxx>
42 
43 #include <cppuhelper/implbase.hxx>
44 
45 #include <com/sun/star/awt/XWindow.hpp>
46 #include <com/sun/star/deployment/XPackage.hpp>
47 #include <com/sun/star/uno/XComponentContext.hpp>
48 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
49 #include <com/sun/star/util/XModifyListener.hpp>
50 
51 #include <stack>
52 #include <vector>
53 
54 namespace dp_gui {
55 
56 
57 class ExtBoxWithBtns_Impl;
58 class ExtensionBox_Impl;
59 class TheExtensionManager;
60 
61 
63 {
64  css::uno::Reference< css::uno::XComponentContext > m_xContext;
68 
69 public:
70  DialogHelper( const css::uno::Reference< css::uno::XComponentContext > &,
71  Dialog *pWindow );
72  virtual ~DialogHelper();
73 
74  void openWebBrowser(const OUString& rURL, const OUString& rTitle);
75  Dialog* getWindow() const { return m_xVCLWindow; };
76  weld::Window* getFrameWeld() const { return m_xVCLWindow ? m_xVCLWindow->GetFrameWeld() : nullptr; }
77  void PostUserEvent( const Link<void*,void>& rLink, void* pCaller );
78  void clearEventID() { m_nEventID = nullptr; }
79 
80  virtual void showProgress( bool bStart ) = 0;
81  virtual void updateProgress( const OUString &rText,
82  const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel) = 0;
83  virtual void updateProgress( const long nProgress ) = 0;
84 
85  virtual void updatePackageInfo( const css::uno::Reference< css::deployment::XPackage > &xPackage ) = 0;
86  virtual void addPackageToList( const css::uno::Reference< css::deployment::XPackage > &xPackage,
87  bool bLicenseMissing = false ) = 0;
88 
89  virtual void prepareChecking() = 0;
90  virtual void checkEntries() = 0;
91 
92  static bool IsSharedPkgMgr( const css::uno::Reference< css::deployment::XPackage > &);
93  bool continueOnSharedExtension( const css::uno::Reference< css::deployment::XPackage > &,
94  weld::Widget* pParent,
95  const char* pResID,
96  bool &bHadWarning );
97 
98  void incBusy() { m_aBusy.incBusy(m_xVCLWindow); }
99  void decBusy() { m_aBusy.decBusy(); }
100  bool isBusy() const { return m_aBusy.isBusy(); }
101  bool installExtensionWarn(const OUString &rExtensionURL);
102  bool installForAllUsers(bool &bInstallForAll);
103 };
104 
106  public DialogHelper
107 {
123  const OUString m_sAddPackages;
124  OUString m_sProgressText;
126  ::osl::Mutex m_aMutex;
134  bool m_bClosed;
138 
139  css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel;
140 
141  bool removeExtensionWarn(const OUString &rExtensionTitle);
142 
143  DECL_LINK( HandleOptionsBtn, Button*, void );
144  DECL_LINK( HandleAddBtn, Button*, void );
145  DECL_LINK( HandleRemoveBtn, Button*, void );
146  DECL_LINK( HandleEnableBtn, Button*, void );
147  DECL_LINK( HandleUpdateBtn, Button*, void );
148  DECL_LINK( HandleCancelBtn, Button*, void );
149  DECL_LINK( HandleCloseBtn, Button*, void );
150  DECL_LINK( HandleExtTypeCbx, Button*, void );
151  DECL_LINK( TimeOutHdl, Timer *, void );
152  DECL_LINK( startProgress, void *, void );
153  DECL_STATIC_LINK( ExtMgrDialog, Restart, void *, void );
154 
155 public:
157  virtual ~ExtMgrDialog() override;
158  virtual void dispose() override;
159 
160  virtual bool EventNotify( NotifyEvent& rNEvt ) override;
161  virtual bool Close() override;
162 
163  virtual void showProgress( bool bStart ) override;
164  virtual void updateProgress( const OUString &rText,
165  const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel) override;
166  virtual void updateProgress( const long nProgress ) override;
167 
168  virtual void updatePackageInfo( const css::uno::Reference< css::deployment::XPackage > &xPackage ) override;
169 
170  void setGetExtensionsURL( const OUString &rURL );
171  virtual void addPackageToList( const css::uno::Reference< css::deployment::XPackage > &,
172  bool bLicenseMissing = false ) override;
173  void enablePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage,
174  bool bEnable );
175  void removePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage );
176  void updatePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage );
177  bool acceptLicense(const css::uno::Reference< css::deployment::XPackage > &xPackage );
178 
180 
181  virtual void prepareChecking() override;
182  virtual void checkEntries() override;
183 
184  css::uno::Sequence< OUString > raiseAddPicker();
185 
186  void enableOptionsButton( bool bEnable );
187  void enableRemoveButton( bool bEnable );
188  void enableEnableButton( bool bEnable );
189  /*
190  * Transform the button to "Enable", or to "Disable"
191  * based on the value of bEnable.
192  */
193  void enableButtontoEnable( bool bEnable );
194 };
195 
196 
198  public DialogHelper
199 {
207  const OUString m_sCloseText;
208  OUString m_sProgressText;
209  ::osl::Mutex m_aMutex;
218 
219  css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel;
220 
221  DECL_LINK( HandleUpdateBtn, Button*, void );
222  DECL_LINK( HandleCloseBtn, Button*, void );
223  DECL_LINK( HandleCancelBtn, Button*, void );
224  DECL_LINK( TimeOutHdl, Timer *, void );
225  DECL_LINK( startProgress, void *, void );
226 
227  static bool isEnabled( const css::uno::Reference< css::deployment::XPackage > &xPackage );
228  static bool checkDependencies( const css::uno::Reference< css::deployment::XPackage > &xPackage );
229  bool hasActiveEntries();
230  void disableAllEntries();
231 
232 public:
233  UpdateRequiredDialog( vcl::Window * pParent, TheExtensionManager *pManager );
234  virtual ~UpdateRequiredDialog() override;
235  virtual void dispose() override;
236 
237  virtual short Execute() override;
238  virtual bool Close() override;
239 
240  virtual void showProgress( bool bStart ) override;
241  virtual void updateProgress( const OUString &rText,
242  const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel) override;
243  virtual void updateProgress( const long nProgress ) override;
244 
245  virtual void updatePackageInfo( const css::uno::Reference< css::deployment::XPackage > &xPackage ) override;
246 
247  virtual void addPackageToList( const css::uno::Reference< css::deployment::XPackage > &,
248  bool bLicenseMissing = false ) override;
249 
250  virtual void prepareChecking() override;
251  virtual void checkEntries() override;
252 };
253 
254 
256 {
257  std::unique_ptr<weld::TextView> m_xLicenseText;
258 public:
259  ShowLicenseDialog(weld::Window * pParent, const css::uno::Reference< css::deployment::XPackage > &xPackage);
260  virtual ~ShowLicenseDialog() override;
261 };
262 
263 class UpdateRequiredDialogService : public ::cppu::WeakImplHelper< css::ui::dialogs::XExecutableDialog >
264 {
265  css::uno::Reference< css::uno::XComponentContext > const m_xComponentContext;
266 public:
267  UpdateRequiredDialogService( css::uno::Sequence< css::uno::Any > const & args,
268  css::uno::Reference< css::uno::XComponentContext> const & xComponentContext );
269 
270  // XExecutableDialog
271  virtual void SAL_CALL setTitle( OUString const & title ) override;
272  virtual sal_Int16 SAL_CALL execute() override;
273 };
274 
275 } // namespace dp_gui
276 
277 #endif
278 
279 /* 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)
void incBusy(const vcl::Window *pIgnore)
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 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:60
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