Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef INCLUDED_DP_GUI_DIALOG2_HXX
30 : : #define INCLUDED_DP_GUI_DIALOG2_HXX
31 : :
32 : : #include "vcl/dialog.hxx"
33 : : #include "vcl/button.hxx"
34 : : #include "vcl/fixed.hxx"
35 : : #include "vcl/timer.hxx"
36 : :
37 : : #include "svtools/fixedhyper.hxx"
38 : : #include "svtools/prgsbar.hxx"
39 : : #include "svtools/svmedit.hxx"
40 : :
41 : : #include "osl/conditn.hxx"
42 : : #include "osl/mutex.hxx"
43 : :
44 : : #include "rtl/ref.hxx"
45 : : #include "rtl/ustring.hxx"
46 : :
47 : : #include "cppuhelper/implbase1.hxx"
48 : :
49 : : #include "com/sun/star/awt/XWindow.hpp"
50 : : #include "com/sun/star/deployment/XPackage.hpp"
51 : : #include "com/sun/star/uno/XComponentContext.hpp"
52 : : #include "com/sun/star/ui/dialogs/XExecutableDialog.hpp"
53 : : #include "com/sun/star/util/XModifyListener.hpp"
54 : :
55 : : namespace dp_gui {
56 : :
57 : : //==============================================================================
58 : : class ExtBoxWithBtns_Impl;
59 : : class ExtensionBox_Impl;
60 : : class TheExtensionManager;
61 : :
62 : : //==============================================================================
63 : : class DialogHelper
64 : : {
65 : : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
66 : : Dialog* m_pVCLWindow;
67 : : sal_uLong m_nEventID;
68 : : bool m_bIsBusy;
69 : :
70 : : public:
71 : : DialogHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &,
72 : : Dialog *pWindow );
73 : : virtual ~DialogHelper();
74 : :
75 : : void openWebBrowser( const ::rtl::OUString & sURL, const ::rtl::OUString & sTitle ) const;
76 : 0 : Dialog* getWindow() const { return m_pVCLWindow; };
77 : : void PostUserEvent( const Link& rLink, void* pCaller );
78 : 0 : void clearEventID() { m_nEventID = 0; }
79 : :
80 : : virtual void showProgress( bool bStart ) = 0;
81 : : virtual void updateProgress( const ::rtl::OUString &rText,
82 : : const ::com::sun::star::uno::Reference< ::com::sun::star::task::XAbortChannel > &xAbortChannel) = 0;
83 : : virtual void updateProgress( const long nProgress ) = 0;
84 : :
85 : : virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) = 0;
86 : : virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage,
87 : : bool bLicenseMissing = false ) = 0;
88 : :
89 : : virtual void prepareChecking() = 0;
90 : : virtual void checkEntries() = 0;
91 : :
92 : : static ResId getResId( sal_uInt16 nId );
93 : : static String getResourceString( sal_uInt16 id );
94 : : static bool IsSharedPkgMgr( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &);
95 : : static bool continueOnSharedExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &,
96 : : Window *pParent,
97 : : const sal_uInt16 nResID,
98 : : bool &bHadWarning );
99 : :
100 : 0 : void setBusy( const bool bBusy ) { m_bIsBusy = bBusy; }
101 : 0 : bool isBusy() const { return m_bIsBusy; }
102 : : bool installExtensionWarn( const ::rtl::OUString &rExtensionURL ) const;
103 : : bool installForAllUsers( bool &bInstallForAll ) const;
104 : : };
105 : :
106 : : //==============================================================================
107 : : class ExtMgrDialog : public ModelessDialog,
108 : : public DialogHelper
109 : : {
110 : : ExtBoxWithBtns_Impl *m_pExtensionBox;
111 : : PushButton m_aAddBtn;
112 : : PushButton m_aUpdateBtn;
113 : : OKButton m_aCloseBtn;
114 : : HelpButton m_aHelpBtn;
115 : : FixedLine m_aDivider;
116 : : FixedLine m_aDivider2;
117 : : FixedText m_aTypeOfExtTxt;
118 : : CheckBox m_aBundledCbx;
119 : : CheckBox m_aSharedCbx;
120 : : CheckBox m_aUserCbx;
121 : : svt::FixedHyperlink m_aGetExtensions;
122 : : FixedText m_aProgressText;
123 : : ProgressBar m_aProgressBar;
124 : : CancelButton m_aCancelBtn;
125 : : const String m_sAddPackages;
126 : : String m_sProgressText;
127 : : String m_sLastFolderURL;
128 : : ::osl::Mutex m_aMutex;
129 : : bool m_bHasProgress;
130 : : bool m_bProgressChanged;
131 : : bool m_bStartProgress;
132 : : bool m_bStopProgress;
133 : : bool m_bUpdateWarning;
134 : : bool m_bEnableWarning;
135 : : bool m_bDisableWarning;
136 : : bool m_bDeleteWarning;
137 : : long m_nProgress;
138 : : Timer m_aTimeoutTimer;
139 : : TheExtensionManager *m_pManager;
140 : :
141 : : ::com::sun::star::uno::Reference< ::com::sun::star::task::XAbortChannel > m_xAbortChannel;
142 : :
143 : : bool removeExtensionWarn( const ::rtl::OUString &rExtensionTitle ) const;
144 : :
145 : : DECL_DLLPRIVATE_LINK( HandleAddBtn, void * );
146 : : DECL_DLLPRIVATE_LINK( HandleUpdateBtn, void * );
147 : : DECL_DLLPRIVATE_LINK( HandleCancelBtn, void * );
148 : : DECL_DLLPRIVATE_LINK( HandleExtTypeCbx, void * );
149 : : DECL_DLLPRIVATE_LINK( HandleHyperlink, svt::FixedHyperlink * );
150 : : DECL_DLLPRIVATE_LINK(TimeOutHdl, void *);
151 : : DECL_DLLPRIVATE_LINK( startProgress, void * );
152 : :
153 : : public:
154 : : ExtMgrDialog( Window * pParent, TheExtensionManager *pManager );
155 : : virtual ~ExtMgrDialog();
156 : :
157 : : virtual void Resize();
158 : : virtual long Notify( NotifyEvent& rNEvt );
159 : : virtual sal_Bool Close();
160 : :
161 : : virtual void showProgress( bool bStart );
162 : : virtual void updateProgress( const ::rtl::OUString &rText,
163 : : const ::com::sun::star::uno::Reference< ::com::sun::star::task::XAbortChannel > &xAbortChannel);
164 : : virtual void updateProgress( const long nProgress );
165 : :
166 : : virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
167 : :
168 : : void setGetExtensionsURL( const ::rtl::OUString &rURL );
169 : : virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &,
170 : : bool bLicenseMissing = false );
171 : : bool enablePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage,
172 : : bool bEnable );
173 : : bool removePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
174 : : bool updatePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
175 : : bool acceptLicense(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
176 : :
177 : : virtual void prepareChecking();
178 : : virtual void checkEntries();
179 : :
180 : : ::com::sun::star::uno::Sequence< ::rtl::OUString > raiseAddPicker();
181 : : };
182 : :
183 : : //==============================================================================
184 : : class UpdateRequiredDialog : public ModalDialog,
185 : : public DialogHelper
186 : : {
187 : : ExtensionBox_Impl *m_pExtensionBox;
188 : : FixedText m_aUpdateNeeded;
189 : : PushButton m_aUpdateBtn;
190 : : PushButton m_aCloseBtn;
191 : : HelpButton m_aHelpBtn;
192 : : CancelButton m_aCancelBtn;
193 : : FixedLine m_aDivider;
194 : : FixedText m_aProgressText;
195 : : ProgressBar m_aProgressBar;
196 : : const String m_sAddPackages;
197 : : const String m_sCloseText;
198 : : String m_sProgressText;
199 : : ::osl::Mutex m_aMutex;
200 : : bool m_bHasProgress;
201 : : bool m_bProgressChanged;
202 : : bool m_bStartProgress;
203 : : bool m_bStopProgress;
204 : : bool m_bUpdateWarning;
205 : : bool m_bDisableWarning;
206 : : bool m_bHasLockedEntries;
207 : : long m_nProgress;
208 : : Timer m_aTimeoutTimer;
209 : : TheExtensionManager *m_pManager;
210 : :
211 : : ::com::sun::star::uno::Reference< ::com::sun::star::task::XAbortChannel > m_xAbortChannel;
212 : :
213 : : DECL_DLLPRIVATE_LINK( HandleUpdateBtn, void * );
214 : : DECL_DLLPRIVATE_LINK( HandleCloseBtn, void * );
215 : : DECL_DLLPRIVATE_LINK( HandleCancelBtn, void * );
216 : : DECL_DLLPRIVATE_LINK(TimeOutHdl, void *);
217 : : DECL_DLLPRIVATE_LINK( startProgress, void * );
218 : : DECL_DLLPRIVATE_LINK( HandleHyperlink, svt::FixedHyperlink * );
219 : :
220 : : bool isEnabled( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) const;
221 : : bool checkDependencies( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) const;
222 : : bool hasActiveEntries();
223 : : void disableAllEntries();
224 : :
225 : : public:
226 : : UpdateRequiredDialog( Window * pParent, TheExtensionManager *pManager );
227 : : virtual ~UpdateRequiredDialog();
228 : :
229 : : virtual short Execute();
230 : : virtual void Resize();
231 : : virtual sal_Bool Close();
232 : :
233 : : virtual void showProgress( bool bStart );
234 : : virtual void updateProgress( const ::rtl::OUString &rText,
235 : : const ::com::sun::star::uno::Reference< ::com::sun::star::task::XAbortChannel > &xAbortChannel);
236 : : virtual void updateProgress( const long nProgress );
237 : :
238 : : virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
239 : :
240 : : void selectEntry( long nPos );
241 : : virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &,
242 : : bool bLicenseMissing = false );
243 : : bool enablePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, bool bEnable );
244 : : bool updatePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
245 : :
246 : : virtual void prepareChecking();
247 : : virtual void checkEntries();
248 : :
249 : : ::com::sun::star::uno::Sequence< ::rtl::OUString > raiseAddPicker();
250 : :
251 : : bool installForAllUsers( bool &bInstallForAll ) const;
252 : : bool installExtensionWarn( const ::rtl::OUString &rExtensionURL ) const;
253 : : };
254 : :
255 : : //==============================================================================
256 : : class ShowLicenseDialog : public ModalDialog
257 : : {
258 : : MultiLineEdit m_aLicenseText;
259 : : OKButton m_aCloseBtn;
260 : :
261 : : public:
262 : : ShowLicenseDialog( Window * pParent,
263 : : const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
264 : : virtual ~ShowLicenseDialog();
265 : :
266 : : virtual void Resize();
267 : : };
268 : :
269 : : //==============================================================================
270 : 0 : class UpdateRequiredDialogService : public ::cppu::WeakImplHelper1< ::com::sun::star::ui::dialogs::XExecutableDialog >
271 : : {
272 : : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const m_xComponentContext;
273 : : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xParent;
274 : : ::rtl::OUString m_sInitialTitle;
275 : :
276 : : public:
277 : : UpdateRequiredDialogService( ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > const & args,
278 : : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> const & xComponentContext );
279 : :
280 : : // XExecutableDialog
281 : : virtual void SAL_CALL setTitle( rtl::OUString const & title ) throw ( ::com::sun::star::uno::RuntimeException );
282 : : virtual sal_Int16 SAL_CALL execute() throw ( ::com::sun::star::uno::RuntimeException );
283 : : };
284 : :
285 : : } // namespace dp_gui
286 : :
287 : : #endif
288 : :
289 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|