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 <vcl/timer.hxx>
24 #include <vcl/idle.hxx>
25 #include <vcl/waitobj.hxx>
26 #include <vcl/customweld.hxx>
27 #include <vcl/weld.hxx>
28 
29 #include <osl/mutex.hxx>
30 
31 #include <rtl/ustring.hxx>
32 
33 #include <cppuhelper/implbase.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 
39 namespace dp_gui {
40 
41 
42 class ExtBoxWithBtns_Impl;
43 class ExtensionBox_Impl;
44 class TheExtensionManager;
45 
46 
48 {
49  css::uno::Reference< css::uno::XComponentContext > m_xContext;
53 
54 public:
55  DialogHelper(const css::uno::Reference< css::uno::XComponentContext > &,
56  weld::Window* pWindow);
57  virtual ~DialogHelper();
58 
59  void openWebBrowser(const OUString& rURL, const OUString& rTitle);
60  weld::Window* getFrameWeld() const { return m_pWindow; }
61  void PostUserEvent( const Link<void*,void>& rLink, void* pCaller );
62  void clearEventID() { m_nEventID = nullptr; }
63 
64  virtual void showProgress( bool bStart ) = 0;
65  virtual void updateProgress( const OUString &rText,
66  const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel) = 0;
67  virtual void updateProgress( const long nProgress ) = 0;
68 
69  virtual void updatePackageInfo( const css::uno::Reference< css::deployment::XPackage > &xPackage ) = 0;
70  virtual void addPackageToList( const css::uno::Reference< css::deployment::XPackage > &xPackage,
71  bool bLicenseMissing = false ) = 0;
72 
73  virtual void prepareChecking() = 0;
74  virtual void checkEntries() = 0;
75 
76  static bool IsSharedPkgMgr( const css::uno::Reference< css::deployment::XPackage > &);
77  bool continueOnSharedExtension( const css::uno::Reference< css::deployment::XPackage > &,
78  weld::Widget* pParent,
79  const char* pResID,
80  bool &bHadWarning );
81 
82  void incBusy() { m_aBusy.incBusy(m_pWindow); }
83  void decBusy() { m_aBusy.decBusy(); }
84  bool isBusy() const { return m_aBusy.isBusy(); }
85  bool installExtensionWarn(const OUString &rExtensionURL);
86  bool installForAllUsers(bool &bInstallForAll);
87 };
88 
90  , public DialogHelper
91 {
92  const OUString m_sAddPackages;
93  OUString m_sProgressText;
94  OUString m_sLastFolderURL;
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 
126  bool removeExtensionWarn(const OUString &rExtensionTitle);
127 
128  DECL_LINK( HandleOptionsBtn, weld::Button&, void );
129  DECL_LINK( HandleAddBtn, weld::Button&, void );
130  DECL_LINK( HandleRemoveBtn, weld::Button&, void );
131  DECL_LINK( HandleEnableBtn, weld::Button&, void );
132  DECL_LINK( HandleUpdateBtn, weld::Button&, void );
133  DECL_LINK( HandleCancelBtn, weld::Button&, void );
134  DECL_LINK( HandleCloseBtn, weld::Button&, void );
135  DECL_LINK( HandleExtTypeCbx, weld::Button&, void );
136  DECL_LINK( TimeOutHdl, Timer *, void );
137  DECL_LINK( startProgress, void *, void );
138 
139 public:
140  ExtMgrDialog(weld::Window * pParent, TheExtensionManager *pManager);
141  virtual ~ExtMgrDialog() override;
142 
143  virtual void showProgress( bool bStart ) override;
144  virtual void updateProgress( const OUString &rText,
145  const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel) override;
146  virtual void updateProgress( const long nProgress ) override;
147 
148  virtual void updatePackageInfo( const css::uno::Reference< css::deployment::XPackage > &xPackage ) override;
149 
150  void setGetExtensionsURL( const OUString &rURL );
151  virtual void addPackageToList( const css::uno::Reference< css::deployment::XPackage > &,
152  bool bLicenseMissing = false ) override;
153  void enablePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage,
154  bool bEnable );
155  void removePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage );
156  void updatePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage );
157  bool acceptLicense(const css::uno::Reference< css::deployment::XPackage > &xPackage );
158 
159  void Close();
160 
162 
163  virtual void prepareChecking() override;
164  virtual void checkEntries() override;
165 
166  css::uno::Sequence< OUString > raiseAddPicker();
167 
168  void enableOptionsButton( bool bEnable );
169  void enableRemoveButton( bool bEnable );
170  void enableEnableButton( bool bEnable );
171  /*
172  * Transform the button to "Enable", or to "Disable"
173  * based on the value of bEnable.
174  */
175  void enableButtontoEnable( bool bEnable );
176 };
177 
178 
180  , public DialogHelper
181 {
182  const OUString m_sCloseText;
183  OUString m_sProgressText;
184  ::osl::Mutex m_aMutex;
193 
194  css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel;
195 
196  std::unique_ptr<ExtensionBox_Impl> m_xExtensionBox;
197  std::unique_ptr<weld::CustomWeld> m_xExtensionBoxWnd;
198  std::unique_ptr<weld::Label> m_xUpdateNeeded;
199  std::unique_ptr<weld::Button> m_xUpdateBtn;
200  std::unique_ptr<weld::Button> m_xCloseBtn;
201  std::unique_ptr<weld::Button> m_xCancelBtn;
202  std::unique_ptr<weld::Label> m_xProgressText;
203  std::unique_ptr<weld::ProgressBar> m_xProgressBar;
204 
205  DECL_LINK( HandleUpdateBtn, weld::Button&, void );
206  DECL_LINK( HandleCloseBtn, weld::Button&, void );
207  DECL_LINK( HandleCancelBtn, weld::Button&, void );
208  DECL_LINK( TimeOutHdl, Timer *, void );
209  DECL_LINK( startProgress, void *, void );
210 
211  static bool isEnabled( const css::uno::Reference< css::deployment::XPackage > &xPackage );
212  static bool checkDependencies( const css::uno::Reference< css::deployment::XPackage > &xPackage );
213  bool hasActiveEntries();
214  void disableAllEntries();
215 
216 public:
218  virtual ~UpdateRequiredDialog() override;
219 
220  virtual short run() override;
221 
222  virtual void showProgress( bool bStart ) override;
223  virtual void updateProgress( const OUString &rText,
224  const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel) override;
225  virtual void updateProgress( const long nProgress ) override;
226 
227  virtual void updatePackageInfo( const css::uno::Reference< css::deployment::XPackage > &xPackage ) override;
228 
229  virtual void addPackageToList( const css::uno::Reference< css::deployment::XPackage > &,
230  bool bLicenseMissing = false ) override;
231 
232  virtual void prepareChecking() override;
233  virtual void checkEntries() override;
234 };
235 
236 
238 {
239  std::unique_ptr<weld::TextView> m_xLicenseText;
240 public:
241  ShowLicenseDialog(weld::Window * pParent, const css::uno::Reference< css::deployment::XPackage > &xPackage);
242  virtual ~ShowLicenseDialog() override;
243 };
244 
245 class UpdateRequiredDialogService : public ::cppu::WeakImplHelper< css::ui::dialogs::XExecutableDialog >
246 {
247  css::uno::Reference< css::uno::XComponentContext > const m_xComponentContext;
248 public:
249  UpdateRequiredDialogService( css::uno::Sequence< css::uno::Any > const & args,
250  css::uno::Reference< css::uno::XComponentContext> const & xComponentContext );
251 
252  // XExecutableDialog
253  virtual void SAL_CALL setTitle( OUString const & title ) override;
254  virtual sal_Int16 SAL_CALL execute() override;
255 };
256 
257 } // namespace dp_gui
258 
259 #endif
260 
261 /* 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:23
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