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