1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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>
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>
44 class ExtBoxWithBtns_Impl
;
45 class ExtensionBox_Impl
;
46 class TheExtensionManager
;
50 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
51 weld::Window
* m_pWindow
;
52 ImplSVEvent
* m_nEventID
;
53 TopLevelWindowLocker m_aBusy
;
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
,
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
93 const OUString m_sAddPackages
;
94 OUString m_sProgressText
;
96 bool m_bProgressChanged
;
97 bool m_bStartProgress
;
99 bool m_bEnableWarning
;
100 bool m_bDisableWarning
;
101 bool m_bDeleteWarning
;
103 tools::Long m_nProgress
;
105 TheExtensionManager
*m_pManager
;
107 css::uno::Reference
< css::task::XAbortChannel
> m_xAbortChannel
;
109 std::unique_ptr
<ExtBoxWithBtns_Impl
> m_xExtensionBox
;
110 std::unique_ptr
<weld::CustomWeld
> m_xExtensionBoxWnd
;
111 std::unique_ptr
<weld::Button
> m_xOptionsBtn
;
112 std::unique_ptr
<weld::Button
> m_xAddBtn
;
113 std::unique_ptr
<weld::Button
> m_xRemoveBtn
;
114 std::unique_ptr
<weld::Button
> m_xEnableBtn
;
115 std::unique_ptr
<weld::Button
> m_xUpdateBtn
;
116 std::unique_ptr
<weld::Button
> m_xCloseBtn
;
117 std::unique_ptr
<weld::CheckButton
> m_xBundledCbx
;
118 std::unique_ptr
<weld::CheckButton
> m_xSharedCbx
;
119 std::unique_ptr
<weld::CheckButton
> m_xUserCbx
;
120 std::unique_ptr
<weld::LinkButton
> m_xGetExtensions
;
121 std::unique_ptr
<weld::Label
> m_xProgressText
;
122 std::unique_ptr
<weld::ProgressBar
> m_xProgressBar
;
123 std::unique_ptr
<weld::Button
> m_xCancelBtn
;
124 std::unique_ptr
<weld::Entry
> m_xSearchEntry
;
126 bool removeExtensionWarn(std::u16string_view rExtensionTitle
);
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::Toggleable
&, void );
136 DECL_LINK( HandleSearch
, weld::Entry
&, void );
137 DECL_LINK( TimeOutHdl
, Timer
*, void );
138 DECL_LINK( startProgress
, void *, void );
141 ExtMgrDialog(weld::Window
* pParent
, TheExtensionManager
*pManager
);
142 virtual ~ExtMgrDialog() override
;
144 virtual void showProgress( bool bStart
) override
;
145 virtual void updateProgress( const OUString
&rText
,
146 const css::uno::Reference
< css::task::XAbortChannel
> &xAbortChannel
) override
;
147 virtual void updateProgress( const tools::Long nProgress
) override
;
149 virtual void updatePackageInfo( const css::uno::Reference
< css::deployment::XPackage
> &xPackage
) override
;
151 void setGetExtensionsURL( const OUString
&rURL
);
152 virtual void addPackageToList( const css::uno::Reference
< css::deployment::XPackage
> &,
153 bool bLicenseMissing
= false ) override
;
154 void enablePackage(const css::uno::Reference
< css::deployment::XPackage
> &xPackage
,
156 void removePackage(const css::uno::Reference
< css::deployment::XPackage
> &xPackage
);
157 void updatePackage(const css::uno::Reference
< css::deployment::XPackage
> &xPackage
);
158 bool acceptLicense(const css::uno::Reference
< css::deployment::XPackage
> &xPackage
);
162 TheExtensionManager
* getExtensionManager() const { return m_pManager
; }
165 virtual void prepareChecking() override
;
166 virtual void checkEntries() override
;
168 css::uno::Sequence
< OUString
> raiseAddPicker();
170 void enableOptionsButton( bool bEnable
);
171 void enableRemoveButton( bool bEnable
);
172 void enableEnableButton( bool bEnable
);
174 * Transform the button to "Enable", or to "Disable"
175 * based on the value of bEnable.
177 void enableButtontoEnable( bool bEnable
);
181 class UpdateRequiredDialog
: public weld::GenericDialogController
182 , public DialogHelper
184 const OUString m_sCloseText
;
185 OUString m_sProgressText
;
187 bool m_bProgressChanged
;
188 bool m_bStartProgress
;
189 bool m_bStopProgress
;
190 bool m_bHasLockedEntries
;
191 tools::Long m_nProgress
;
193 TheExtensionManager
*m_pManager
;
195 css::uno::Reference
< css::task::XAbortChannel
> m_xAbortChannel
;
197 std::unique_ptr
<ExtensionBox_Impl
> m_xExtensionBox
;
198 std::unique_ptr
<weld::CustomWeld
> m_xExtensionBoxWnd
;
199 std::unique_ptr
<weld::Label
> m_xUpdateNeeded
;
200 std::unique_ptr
<weld::Button
> m_xUpdateBtn
;
201 std::unique_ptr
<weld::Button
> m_xCloseBtn
;
202 std::unique_ptr
<weld::Button
> m_xCancelBtn
;
203 std::unique_ptr
<weld::Label
> m_xProgressText
;
204 std::unique_ptr
<weld::ProgressBar
> m_xProgressBar
;
206 DECL_LINK( HandleUpdateBtn
, weld::Button
&, void );
207 DECL_LINK( HandleCloseBtn
, weld::Button
&, void );
208 DECL_LINK( HandleCancelBtn
, weld::Button
&, void );
209 DECL_LINK( TimeOutHdl
, Timer
*, void );
210 DECL_LINK( startProgress
, void *, void );
212 static bool isEnabled( const css::uno::Reference
< css::deployment::XPackage
> &xPackage
);
213 static bool checkDependencies( const css::uno::Reference
< css::deployment::XPackage
> &xPackage
);
214 bool hasActiveEntries();
215 void disableAllEntries();
218 UpdateRequiredDialog(weld::Window
* pParent
, TheExtensionManager
*pManager
);
219 virtual ~UpdateRequiredDialog() override
;
221 virtual short run() override
;
223 virtual void showProgress( bool bStart
) override
;
224 virtual void updateProgress( const OUString
&rText
,
225 const css::uno::Reference
< css::task::XAbortChannel
> &xAbortChannel
) override
;
226 virtual void updateProgress( const tools::Long nProgress
) override
;
228 virtual void updatePackageInfo( const css::uno::Reference
< css::deployment::XPackage
> &xPackage
) override
;
230 virtual void addPackageToList( const css::uno::Reference
< css::deployment::XPackage
> &,
231 bool bLicenseMissing
= false ) override
;
233 virtual void prepareChecking() override
;
234 virtual void checkEntries() override
;
238 class ShowLicenseDialog
: public weld::GenericDialogController
240 std::unique_ptr
<weld::TextView
> m_xLicenseText
;
242 ShowLicenseDialog(weld::Window
* pParent
, const css::uno::Reference
< css::deployment::XPackage
> &xPackage
);
243 virtual ~ShowLicenseDialog() override
;
246 class UpdateRequiredDialogService
: public ::cppu::WeakImplHelper
< css::ui::dialogs::XExecutableDialog
, css::lang::XServiceInfo
>
248 css::uno::Reference
< css::uno::XComponentContext
> const m_xComponentContext
;
250 UpdateRequiredDialogService( css::uno::Sequence
< css::uno::Any
> const & args
,
251 css::uno::Reference
< css::uno::XComponentContext
> xComponentContext
);
254 virtual OUString SAL_CALL
getImplementationName() override
;
255 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
256 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
259 virtual void SAL_CALL
setTitle( OUString
const & title
) override
;
260 virtual sal_Int16 SAL_CALL
execute() override
;
263 } // namespace dp_gui
265 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */