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_DP_GUI_DIALOG2_HXX
21 : #define INCLUDED_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 ::rtl::OUString & sURL, const ::rtl::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 ::rtl::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 String 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 ::rtl::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 : PushButton *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 String m_sAddPackages;
113 : String m_sProgressText;
114 : String 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 ::rtl::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 long Notify( NotifyEvent& rNEvt );
145 : virtual sal_Bool Close();
146 :
147 : virtual void showProgress( bool bStart );
148 : virtual void updateProgress( const ::rtl::OUString &rText,
149 : const ::com::sun::star::uno::Reference< ::com::sun::star::task::XAbortChannel > &xAbortChannel);
150 : virtual void updateProgress( const long nProgress );
151 :
152 : virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
153 :
154 : void setGetExtensionsURL( const ::rtl::OUString &rURL );
155 : virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &,
156 : bool bLicenseMissing = false );
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();
166 : virtual void checkEntries();
167 :
168 : ::com::sun::star::uno::Sequence< ::rtl::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 String m_sAddPackages;
185 : const String m_sCloseText;
186 : String 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();
218 : virtual void Resize();
219 : virtual sal_Bool Close();
220 :
221 : virtual void showProgress( bool bStart );
222 : virtual void updateProgress( const ::rtl::OUString &rText,
223 : const ::com::sun::star::uno::Reference< ::com::sun::star::task::XAbortChannel > &xAbortChannel);
224 : virtual void updateProgress( const long nProgress );
225 :
226 : virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
227 :
228 : void selectEntry( long nPos );
229 : virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &,
230 : bool bLicenseMissing = false );
231 : bool enablePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, bool bEnable );
232 : bool updatePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
233 :
234 : virtual void prepareChecking();
235 : virtual void checkEntries();
236 :
237 : ::com::sun::star::uno::Sequence< ::rtl::OUString > raiseAddPicker();
238 :
239 : bool installForAllUsers( bool &bInstallForAll ) const;
240 : bool installExtensionWarn( const ::rtl::OUString &rExtensionURL ) const;
241 : };
242 :
243 : //==============================================================================
244 : class ShowLicenseDialog : public ModalDialog
245 : {
246 : MultiLineEdit m_aLicenseText;
247 : OKButton m_aCloseBtn;
248 :
249 : public:
250 : ShowLicenseDialog( Window * pParent,
251 : const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
252 : virtual ~ShowLicenseDialog();
253 :
254 : virtual void Resize();
255 : };
256 :
257 : //==============================================================================
258 0 : class UpdateRequiredDialogService : public ::cppu::WeakImplHelper1< ::com::sun::star::ui::dialogs::XExecutableDialog >
259 : {
260 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const m_xComponentContext;
261 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xParent;
262 : ::rtl::OUString m_sInitialTitle;
263 :
264 : public:
265 : UpdateRequiredDialogService( ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > const & args,
266 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> const & xComponentContext );
267 :
268 : // XExecutableDialog
269 : virtual void SAL_CALL setTitle( rtl::OUString const & title ) throw ( ::com::sun::star::uno::RuntimeException );
270 : virtual sal_Int16 SAL_CALL execute() throw ( ::com::sun::star::uno::RuntimeException );
271 : };
272 :
273 : } // namespace dp_gui
274 :
275 : #endif
276 :
277 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|