Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / desktop / source / deployment / gui / dp_gui_dialog2.hxx
blobb235aed18589176a4aadd8e34a38c320611f019c
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 #pragma once
22 #include <vcl/timer.hxx>
23 #include <vcl/idle.hxx>
24 #include <vcl/locktoplevels.hxx>
25 #include <vcl/customweld.hxx>
26 #include <vcl/weld.hxx>
28 #include <mutex>
30 #include <rtl/ustring.hxx>
32 #include <cppuhelper/implbase.hxx>
33 #include <unotools/resmgr.hxx>
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 #include <com/sun/star/lang/XServiceInfo.hpp>
40 struct ImplSVEvent;
42 namespace dp_gui {
44 class ExtBoxWithBtns_Impl;
45 class ExtensionBox_Impl;
46 class TheExtensionManager;
48 class DialogHelper
50 css::uno::Reference< css::uno::XComponentContext > m_xContext;
51 weld::Window* m_pWindow;
52 ImplSVEvent * m_nEventID;
53 TopLevelWindowLocker m_aBusy;
55 public:
56 DialogHelper(const css::uno::Reference< css::uno::XComponentContext > &,
57 weld::Window* pWindow);
58 virtual ~DialogHelper();
60 void openWebBrowser(const OUString& rURL, const OUString& rTitle);
61 weld::Window* getFrameWeld() const { return m_pWindow; }
62 void PostUserEvent( const Link<void*,void>& rLink, void* pCaller );
63 void clearEventID() { m_nEventID = nullptr; }
65 virtual void showProgress( bool bStart ) = 0;
66 virtual void updateProgress( const OUString &rText,
67 const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel) = 0;
68 virtual void updateProgress( const tools::Long nProgress ) = 0;
70 virtual void updatePackageInfo( const css::uno::Reference< css::deployment::XPackage > &xPackage ) = 0;
71 virtual void addPackageToList( const css::uno::Reference< css::deployment::XPackage > &xPackage,
72 bool bLicenseMissing = false ) = 0;
74 virtual void prepareChecking() = 0;
75 virtual void checkEntries() = 0;
77 static bool IsSharedPkgMgr( const css::uno::Reference< css::deployment::XPackage > &);
78 bool continueOnSharedExtension( const css::uno::Reference< css::deployment::XPackage > &,
79 weld::Widget* pParent,
80 TranslateId pResID,
81 bool &bHadWarning );
83 void incBusy() { m_aBusy.incBusy(m_pWindow); }
84 void decBusy() { m_aBusy.decBusy(); }
85 bool isBusy() const { return m_aBusy.isBusy(); }
86 bool installExtensionWarn(std::u16string_view rExtensionURL);
87 bool installForAllUsers(bool &bInstallForAll);
90 class ExtMgrDialog : public weld::GenericDialogController
91 , public DialogHelper
93 const OUString m_sAddPackages;
94 OUString m_sProgressText;
95 std::mutex m_aMutex;
96 bool m_bHasProgress;
97 bool m_bProgressChanged;
98 bool m_bStartProgress;
99 bool m_bStopProgress;
100 bool m_bEnableWarning;
101 bool m_bDisableWarning;
102 bool m_bDeleteWarning;
103 bool m_bClosed;
104 tools::Long m_nProgress;
105 Idle m_aIdle;
106 TheExtensionManager *m_pManager;
108 css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel;
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 std::unique_ptr<weld::Entry> m_xSearchEntry;
127 bool removeExtensionWarn(std::u16string_view rExtensionTitle);
129 DECL_LINK( HandleOptionsBtn, weld::Button&, void );
130 DECL_LINK( HandleAddBtn, weld::Button&, void );
131 DECL_LINK( HandleRemoveBtn, weld::Button&, void );
132 DECL_LINK( HandleEnableBtn, weld::Button&, void );
133 DECL_LINK( HandleUpdateBtn, weld::Button&, void );
134 DECL_LINK( HandleCancelBtn, weld::Button&, void );
135 DECL_LINK( HandleCloseBtn, weld::Button&, void );
136 DECL_LINK( HandleExtTypeCbx, weld::Toggleable&, void );
137 DECL_LINK( HandleSearch, weld::Entry&, void );
138 DECL_LINK( TimeOutHdl, Timer *, void );
139 DECL_LINK( startProgress, void *, void );
141 public:
142 ExtMgrDialog(weld::Window * pParent, TheExtensionManager *pManager);
143 virtual ~ExtMgrDialog() override;
145 virtual void showProgress( bool bStart ) override;
146 virtual void updateProgress( const OUString &rText,
147 const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel) override;
148 virtual void updateProgress( const tools::Long nProgress ) override;
150 virtual void updatePackageInfo( const css::uno::Reference< css::deployment::XPackage > &xPackage ) override;
152 void setGetExtensionsURL( const OUString &rURL );
153 virtual void addPackageToList( const css::uno::Reference< css::deployment::XPackage > &,
154 bool bLicenseMissing = false ) override;
155 void enablePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage,
156 bool bEnable );
157 void removePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage );
158 void updatePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage );
159 bool acceptLicense(const css::uno::Reference< css::deployment::XPackage > &xPackage );
161 void Close();
163 TheExtensionManager* getExtensionManager() const { return m_pManager; }
165 void updateList();
166 virtual void prepareChecking() override;
167 virtual void checkEntries() override;
169 css::uno::Sequence< OUString > raiseAddPicker();
171 void enableOptionsButton( bool bEnable );
172 void enableRemoveButton( bool bEnable );
173 void enableEnableButton( bool bEnable );
175 * Transform the button to "Enable", or to "Disable"
176 * based on the value of bEnable.
178 void enableButtontoEnable( bool bEnable );
182 class UpdateRequiredDialog : public weld::GenericDialogController
183 , public DialogHelper
185 const OUString m_sCloseText;
186 OUString m_sProgressText;
187 std::mutex m_aMutex;
188 bool m_bHasProgress;
189 bool m_bProgressChanged;
190 bool m_bStartProgress;
191 bool m_bStopProgress;
192 bool m_bHasLockedEntries;
193 tools::Long m_nProgress;
194 Idle m_aIdle;
195 TheExtensionManager *m_pManager;
197 css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel;
199 std::unique_ptr<ExtensionBox_Impl> m_xExtensionBox;
200 std::unique_ptr<weld::CustomWeld> m_xExtensionBoxWnd;
201 std::unique_ptr<weld::Label> m_xUpdateNeeded;
202 std::unique_ptr<weld::Button> m_xUpdateBtn;
203 std::unique_ptr<weld::Button> m_xCloseBtn;
204 std::unique_ptr<weld::Button> m_xCancelBtn;
205 std::unique_ptr<weld::Label> m_xProgressText;
206 std::unique_ptr<weld::ProgressBar> m_xProgressBar;
208 DECL_LINK( HandleUpdateBtn, weld::Button&, void );
209 DECL_LINK( HandleCloseBtn, weld::Button&, void );
210 DECL_LINK( HandleCancelBtn, weld::Button&, void );
211 DECL_LINK( TimeOutHdl, Timer *, void );
212 DECL_LINK( startProgress, void *, void );
214 static bool isEnabled( const css::uno::Reference< css::deployment::XPackage > &xPackage );
215 static bool checkDependencies( const css::uno::Reference< css::deployment::XPackage > &xPackage );
216 bool hasActiveEntries();
217 void disableAllEntries();
219 public:
220 UpdateRequiredDialog(weld::Window * pParent, TheExtensionManager *pManager);
221 virtual ~UpdateRequiredDialog() override;
223 virtual short run() override;
225 virtual void showProgress( bool bStart ) override;
226 virtual void updateProgress( const OUString &rText,
227 const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel) override;
228 virtual void updateProgress( const tools::Long nProgress ) override;
230 virtual void updatePackageInfo( const css::uno::Reference< css::deployment::XPackage > &xPackage ) override;
232 virtual void addPackageToList( const css::uno::Reference< css::deployment::XPackage > &,
233 bool bLicenseMissing = false ) override;
235 virtual void prepareChecking() override;
236 virtual void checkEntries() override;
240 class ShowLicenseDialog : public weld::GenericDialogController
242 std::unique_ptr<weld::TextView> m_xLicenseText;
243 public:
244 ShowLicenseDialog(weld::Window * pParent, const css::uno::Reference< css::deployment::XPackage > &xPackage);
245 virtual ~ShowLicenseDialog() override;
248 class UpdateRequiredDialogService : public ::cppu::WeakImplHelper< css::ui::dialogs::XExecutableDialog, css::lang::XServiceInfo >
250 css::uno::Reference< css::uno::XComponentContext > const m_xComponentContext;
251 public:
252 UpdateRequiredDialogService( css::uno::Sequence< css::uno::Any > const & args,
253 css::uno::Reference< css::uno::XComponentContext> xComponentContext );
255 // XServiceInfo
256 virtual OUString SAL_CALL getImplementationName() override;
257 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
258 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
260 // XExecutableDialog
261 virtual void SAL_CALL setTitle( OUString const & title ) override;
262 virtual sal_Int16 SAL_CALL execute() override;
265 } // namespace dp_gui
267 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */