Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / desktop / source / deployment / gui / dp_gui_dialog2.hxx
blob84a7556778433168c51bcb11fbb1e52dfb4ed940
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_GUI_DP_GUI_DIALOG2_HXX
21 #define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_GUI_DP_GUI_DIALOG2_HXX
23 #include <config_extensions.h>
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>
31 #include <osl/conditn.hxx>
32 #include <osl/mutex.hxx>
34 #include <rtl/ref.hxx>
35 #include <rtl/ustring.hxx>
37 #include <cppuhelper/implbase.hxx>
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>
45 #include <stack>
46 #include <vector>
48 namespace dp_gui {
51 class ExtBoxWithBtns_Impl;
52 class ExtensionBox_Impl;
53 class TheExtensionManager;
56 class DialogHelper
58 css::uno::Reference< css::uno::XComponentContext > m_xContext;
59 weld::Window* m_pWindow;
60 ImplSVEvent * m_nEventID;
61 TopLevelWindowLocker m_aBusy;
63 public:
64 DialogHelper(const css::uno::Reference< css::uno::XComponentContext > &,
65 weld::Window* pWindow);
66 virtual ~DialogHelper();
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; }
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;
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;
82 virtual void prepareChecking() = 0;
83 virtual void checkEntries() = 0;
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 );
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);
98 class ExtMgrDialog : public weld::GenericDialogController
99 , public DialogHelper
101 const OUString m_sAddPackages;
102 OUString m_sProgressText;
103 OUString m_sLastFolderURL;
104 ::osl::Mutex m_aMutex;
105 bool m_bHasProgress;
106 bool m_bProgressChanged;
107 bool m_bStartProgress;
108 bool m_bStopProgress;
109 bool m_bEnableWarning;
110 bool m_bDisableWarning;
111 bool m_bDeleteWarning;
112 bool m_bClosed;
113 long m_nProgress;
114 Idle m_aIdle;
115 TheExtensionManager *m_pManager;
117 css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel;
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;
135 bool removeExtensionWarn(const OUString &rExtensionTitle);
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 );
148 public:
149 ExtMgrDialog(weld::Window * pParent, TheExtensionManager *pManager);
150 virtual ~ExtMgrDialog() override;
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;
157 virtual void updatePackageInfo( const css::uno::Reference< css::deployment::XPackage > &xPackage ) override;
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 );
168 void Close();
170 TheExtensionManager* getExtensionManager() const { return m_pManager; }
172 virtual void prepareChecking() override;
173 virtual void checkEntries() override;
175 css::uno::Sequence< OUString > raiseAddPicker();
177 void enableOptionsButton( bool bEnable );
178 void enableRemoveButton( bool bEnable );
179 void enableEnableButton( bool bEnable );
181 * Transform the button to "Enable", or to "Disable"
182 * based on the value of bEnable.
184 void enableButtontoEnable( bool bEnable );
188 class UpdateRequiredDialog : public weld::GenericDialogController
189 , public DialogHelper
191 const OUString m_sCloseText;
192 OUString m_sProgressText;
193 ::osl::Mutex m_aMutex;
194 bool m_bHasProgress;
195 bool m_bProgressChanged;
196 bool m_bStartProgress;
197 bool m_bStopProgress;
198 bool m_bHasLockedEntries;
199 long m_nProgress;
200 Idle m_aIdle;
201 TheExtensionManager *m_pManager;
203 css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel;
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;
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 );
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();
225 public:
226 UpdateRequiredDialog(weld::Window * pParent, TheExtensionManager *pManager);
227 virtual ~UpdateRequiredDialog() override;
229 virtual short run() override;
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;
236 virtual void updatePackageInfo( const css::uno::Reference< css::deployment::XPackage > &xPackage ) override;
238 virtual void addPackageToList( const css::uno::Reference< css::deployment::XPackage > &,
239 bool bLicenseMissing = false ) override;
241 virtual void prepareChecking() override;
242 virtual void checkEntries() override;
246 class ShowLicenseDialog : public weld::GenericDialogController
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;
254 class UpdateRequiredDialogService : public ::cppu::WeakImplHelper< css::ui::dialogs::XExecutableDialog >
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 );
261 // XExecutableDialog
262 virtual void SAL_CALL setTitle( OUString const & title ) override;
263 virtual sal_Int16 SAL_CALL execute() override;
266 } // namespace dp_gui
268 #endif
270 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */