Line data Source code
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_extension_update.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 :
33 : #include <svtools/svmedit.hxx>
34 :
35 : #include <osl/conditn.hxx>
36 : #include <osl/mutex.hxx>
37 :
38 : #include <rtl/ref.hxx>
39 : #include <rtl/ustring.hxx>
40 :
41 : #include <cppuhelper/implbase1.hxx>
42 :
43 : #include <com/sun/star/awt/XWindow.hpp>
44 : #include <com/sun/star/deployment/XPackage.hpp>
45 : #include <com/sun/star/uno/XComponentContext.hpp>
46 : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
47 : #include <com/sun/star/util/XModifyListener.hpp>
48 :
49 : namespace dp_gui {
50 :
51 :
52 : class ExtBoxWithBtns_Impl;
53 : class ExtensionBox_Impl;
54 : class TheExtensionManager;
55 :
56 :
57 : class DialogHelper
58 : {
59 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
60 : VclPtr<Dialog> m_pVCLWindow;
61 : ImplSVEvent * m_nEventID;
62 : bool m_bIsBusy;
63 :
64 : public:
65 : DialogHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &,
66 : Dialog *pWindow );
67 : virtual ~DialogHelper();
68 :
69 : void openWebBrowser( const OUString & sURL, const OUString & sTitle ) const;
70 0 : Dialog* getWindow() const { return m_pVCLWindow; };
71 : void PostUserEvent( const Link<>& rLink, void* pCaller, bool bReferenceLink = false );
72 0 : void clearEventID() { m_nEventID = 0; }
73 :
74 : virtual void showProgress( bool bStart ) = 0;
75 : virtual void updateProgress( const OUString &rText,
76 : const ::com::sun::star::uno::Reference< ::com::sun::star::task::XAbortChannel > &xAbortChannel) = 0;
77 : virtual void updateProgress( const long nProgress ) = 0;
78 :
79 : virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) = 0;
80 : virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage,
81 : bool bLicenseMissing = false ) = 0;
82 :
83 : virtual void prepareChecking() = 0;
84 : virtual void checkEntries() = 0;
85 :
86 : static ResId getResId( sal_uInt16 nId );
87 : static OUString getResourceString( sal_uInt16 id );
88 : static bool IsSharedPkgMgr( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &);
89 : static bool continueOnSharedExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &,
90 : vcl::Window *pParent,
91 : const sal_uInt16 nResID,
92 : bool &bHadWarning );
93 :
94 0 : void setBusy( const bool bBusy ) { m_bIsBusy = bBusy; }
95 0 : bool isBusy() const { return m_bIsBusy; }
96 : bool installExtensionWarn( const OUString &rExtensionURL ) const;
97 : bool installForAllUsers( bool &bInstallForAll ) const;
98 : };
99 :
100 :
101 : class ExtMgrDialog : public ModelessDialog,
102 : public DialogHelper
103 : {
104 : VclPtr<ExtBoxWithBtns_Impl> m_pExtensionBox;
105 : VclPtr<PushButton> m_pAddBtn;
106 : VclPtr<PushButton> m_pUpdateBtn;
107 : VclPtr<CloseButton> m_pCloseBtn;
108 : VclPtr<CheckBox> m_pBundledCbx;
109 : VclPtr<CheckBox> m_pSharedCbx;
110 : VclPtr<CheckBox> m_pUserCbx;
111 : VclPtr<FixedHyperlink> m_pGetExtensions;
112 : VclPtr<FixedText> m_pProgressText;
113 : VclPtr<ProgressBar> m_pProgressBar;
114 : VclPtr<CancelButton> m_pCancelBtn;
115 : const OUString m_sAddPackages;
116 : OUString m_sProgressText;
117 : OUString m_sLastFolderURL;
118 : ::osl::Mutex m_aMutex;
119 : bool m_bHasProgress;
120 : bool m_bProgressChanged;
121 : bool m_bStartProgress;
122 : bool m_bStopProgress;
123 : bool m_bEnableWarning;
124 : bool m_bDisableWarning;
125 : bool m_bDeleteWarning;
126 : long m_nProgress;
127 : Idle m_aIdle;
128 : TheExtensionManager *m_pManager;
129 :
130 : ::com::sun::star::uno::Reference< ::com::sun::star::task::XAbortChannel > m_xAbortChannel;
131 :
132 : bool removeExtensionWarn( const OUString &rExtensionTitle ) const;
133 :
134 : DECL_DLLPRIVATE_LINK( HandleAddBtn, void * );
135 : DECL_DLLPRIVATE_LINK( HandleUpdateBtn, void * );
136 : DECL_DLLPRIVATE_LINK( HandleCancelBtn, void * );
137 : DECL_DLLPRIVATE_LINK( HandleCloseBtn, void * );
138 : DECL_DLLPRIVATE_LINK( HandleExtTypeCbx, void * );
139 : DECL_DLLPRIVATE_LINK( HandleHyperlink, FixedHyperlink * );
140 : DECL_DLLPRIVATE_LINK_TYPED(TimeOutHdl, Idle *, void);
141 : DECL_DLLPRIVATE_LINK( startProgress, void * );
142 :
143 : public:
144 : ExtMgrDialog( vcl::Window * pParent, TheExtensionManager *pManager, Dialog::InitFlag eFlag = Dialog::InitFlag::Default );
145 : virtual ~ExtMgrDialog();
146 : virtual void dispose() SAL_OVERRIDE;
147 :
148 : virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
149 : virtual bool Close() SAL_OVERRIDE;
150 :
151 : virtual void showProgress( bool bStart ) SAL_OVERRIDE;
152 : virtual void updateProgress( const OUString &rText,
153 : const ::com::sun::star::uno::Reference< ::com::sun::star::task::XAbortChannel > &xAbortChannel) SAL_OVERRIDE;
154 : virtual void updateProgress( const long nProgress ) SAL_OVERRIDE;
155 :
156 : virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) SAL_OVERRIDE;
157 :
158 : void setGetExtensionsURL( const OUString &rURL );
159 : virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &,
160 : bool bLicenseMissing = false ) SAL_OVERRIDE;
161 : bool enablePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage,
162 : bool bEnable );
163 : bool removePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
164 : bool updatePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
165 : bool acceptLicense(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
166 :
167 0 : TheExtensionManager* getExtensionManager() const { return m_pManager; }
168 :
169 : virtual void prepareChecking() SAL_OVERRIDE;
170 : virtual void checkEntries() SAL_OVERRIDE;
171 :
172 : ::com::sun::star::uno::Sequence< OUString > raiseAddPicker();
173 : };
174 :
175 :
176 : class UpdateRequiredDialog : public ModalDialog,
177 : public DialogHelper
178 : {
179 : VclPtr<ExtensionBox_Impl> m_pExtensionBox;
180 : VclPtr<FixedText> m_pUpdateNeeded;
181 : VclPtr<PushButton> m_pUpdateBtn;
182 : VclPtr<PushButton> m_pCloseBtn;
183 : VclPtr<CancelButton> m_pCancelBtn;
184 : VclPtr<FixedText> m_pProgressText;
185 : VclPtr<ProgressBar> m_pProgressBar;
186 : const OUString m_sAddPackages;
187 : const OUString m_sCloseText;
188 : OUString m_sProgressText;
189 : ::osl::Mutex m_aMutex;
190 : bool m_bHasProgress;
191 : bool m_bProgressChanged;
192 : bool m_bStartProgress;
193 : bool m_bStopProgress;
194 : bool m_bUpdateWarning;
195 : bool m_bDisableWarning;
196 : bool m_bHasLockedEntries;
197 : long m_nProgress;
198 : Idle m_aIdle;
199 : TheExtensionManager *m_pManager;
200 :
201 : ::com::sun::star::uno::Reference< ::com::sun::star::task::XAbortChannel > m_xAbortChannel;
202 :
203 : DECL_DLLPRIVATE_LINK( HandleUpdateBtn, void * );
204 : DECL_DLLPRIVATE_LINK( HandleCloseBtn, void * );
205 : DECL_DLLPRIVATE_LINK( HandleCancelBtn, void * );
206 : DECL_DLLPRIVATE_LINK_TYPED(TimeOutHdl, Idle *, void);
207 : DECL_DLLPRIVATE_LINK( startProgress, void * );
208 : DECL_DLLPRIVATE_LINK( HandleHyperlink, FixedHyperlink * );
209 :
210 : static bool isEnabled( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
211 : static bool checkDependencies( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
212 : bool hasActiveEntries();
213 : void disableAllEntries();
214 :
215 : public:
216 : UpdateRequiredDialog( vcl::Window * pParent, TheExtensionManager *pManager );
217 : virtual ~UpdateRequiredDialog();
218 : virtual void dispose() SAL_OVERRIDE;
219 :
220 : virtual short Execute() SAL_OVERRIDE;
221 : virtual bool Close() SAL_OVERRIDE;
222 :
223 : virtual void showProgress( bool bStart ) SAL_OVERRIDE;
224 : virtual void updateProgress( const OUString &rText,
225 : const ::com::sun::star::uno::Reference< ::com::sun::star::task::XAbortChannel > &xAbortChannel) SAL_OVERRIDE;
226 : virtual void updateProgress( const long nProgress ) SAL_OVERRIDE;
227 :
228 : virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) SAL_OVERRIDE;
229 :
230 : virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &,
231 : bool bLicenseMissing = false ) SAL_OVERRIDE;
232 : bool enablePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, bool bEnable );
233 : bool updatePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
234 :
235 : virtual void prepareChecking() SAL_OVERRIDE;
236 : virtual void checkEntries() SAL_OVERRIDE;
237 :
238 : ::com::sun::star::uno::Sequence< OUString > raiseAddPicker();
239 :
240 : bool installForAllUsers( bool &bInstallForAll ) const;
241 : bool installExtensionWarn( const OUString &rExtensionURL ) const;
242 : };
243 :
244 :
245 : class ShowLicenseDialog : public ModalDialog
246 : {
247 : VclPtr<VclMultiLineEdit> m_pLicenseText;
248 : public:
249 : ShowLicenseDialog(vcl::Window * pParent, const css::uno::Reference< css::deployment::XPackage > &xPackage);
250 : virtual ~ShowLicenseDialog();
251 : virtual void dispose() SAL_OVERRIDE;
252 : };
253 :
254 :
255 1 : class UpdateRequiredDialogService : public ::cppu::WeakImplHelper1< ::com::sun::star::ui::dialogs::XExecutableDialog >
256 : {
257 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const m_xComponentContext;
258 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xParent;
259 : public:
260 : UpdateRequiredDialogService( ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > const & args,
261 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> const & xComponentContext );
262 :
263 : // XExecutableDialog
264 : virtual void SAL_CALL setTitle( OUString const & title ) throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
265 : virtual sal_Int16 SAL_CALL execute() throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
266 : };
267 :
268 : } // namespace dp_gui
269 :
270 : #endif
271 :
272 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|