12a97ec55SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
32a97ec55SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
42a97ec55SAndrew Rist * or more contributor license agreements. See the NOTICE file
52a97ec55SAndrew Rist * distributed with this work for additional information
62a97ec55SAndrew Rist * regarding copyright ownership. The ASF licenses this file
72a97ec55SAndrew Rist * to you under the Apache License, Version 2.0 (the
82a97ec55SAndrew Rist * "License"); you may not use this file except in compliance
92a97ec55SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
112a97ec55SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
132a97ec55SAndrew Rist * Unless required by applicable law or agreed to in writing,
142a97ec55SAndrew Rist * software distributed under the License is distributed on an
152a97ec55SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162a97ec55SAndrew Rist * KIND, either express or implied. See the License for the
172a97ec55SAndrew Rist * specific language governing permissions and limitations
182a97ec55SAndrew Rist * under the License.
19cdf0e10cSrcweir *
202a97ec55SAndrew Rist *************************************************************/
212a97ec55SAndrew Rist
222a97ec55SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_extensions.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "updatehdl.hxx"
28cdf0e10cSrcweir #include "update.hrc"
29cdf0e10cSrcweir
30cdf0e10cSrcweir #include "osl/diagnose.h"
31cdf0e10cSrcweir #include "osl/thread.hxx"
32cdf0e10cSrcweir #include "osl/file.hxx"
33cdf0e10cSrcweir #include "rtl/ustring.hxx"
34cdf0e10cSrcweir #include "rtl/bootstrap.hxx"
35cdf0e10cSrcweir
36cdf0e10cSrcweir #include "com/sun/star/uno/Sequence.h"
37cdf0e10cSrcweir
38cdf0e10cSrcweir #include <com/sun/star/style/VerticalAlignment.hpp>
39cdf0e10cSrcweir
40cdf0e10cSrcweir #include "com/sun/star/awt/ActionEvent.hpp"
41cdf0e10cSrcweir #include "com/sun/star/awt/PushButtonType.hpp"
42cdf0e10cSrcweir #include "com/sun/star/awt/VclWindowPeerAttribute.hpp"
43cdf0e10cSrcweir #include "com/sun/star/awt/WindowAttribute.hpp"
44cdf0e10cSrcweir #include "com/sun/star/awt/XButton.hpp"
45cdf0e10cSrcweir #include "com/sun/star/awt/XControl.hpp"
46cdf0e10cSrcweir #include "com/sun/star/awt/XControlContainer.hpp"
47cdf0e10cSrcweir #include "com/sun/star/awt/XMessageBox.hpp"
48cdf0e10cSrcweir #include "com/sun/star/awt/XAnimation.hpp"
49cdf0e10cSrcweir #include "com/sun/star/awt/XTopWindow.hpp"
50cdf0e10cSrcweir #include "com/sun/star/awt/XVclWindowPeer.hpp"
51cdf0e10cSrcweir #include "com/sun/star/awt/XVclContainer.hpp"
52cdf0e10cSrcweir #include "com/sun/star/awt/XWindow.hpp"
53cdf0e10cSrcweir #include "com/sun/star/awt/XWindow2.hpp"
54cdf0e10cSrcweir
55cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
56cdf0e10cSrcweir #include "com/sun/star/beans/XPropertySet.hpp"
57cdf0e10cSrcweir
58cdf0e10cSrcweir #include "com/sun/star/container/XNameContainer.hpp"
59cdf0e10cSrcweir
60cdf0e10cSrcweir #include "com/sun/star/frame/XDesktop.hpp"
61cdf0e10cSrcweir
62cdf0e10cSrcweir #include "com/sun/star/lang/XMultiServiceFactory.hpp"
63cdf0e10cSrcweir #include "com/sun/star/task/InteractionRequestStringResolver.hpp"
64cdf0e10cSrcweir
65cdf0e10cSrcweir #include <com/sun/star/resource/XResourceBundleLoader.hpp>
66cdf0e10cSrcweir
67cdf0e10cSrcweir #include "updatehdl.hrc"
68cdf0e10cSrcweir #include <tools/urlobj.hxx>
69cdf0e10cSrcweir
70*a2db8daaSArrigo Marchiori #include <vcl/svapp.hxx>
71*a2db8daaSArrigo Marchiori #include <vos/mutex.hxx>
72*a2db8daaSArrigo Marchiori
73cdf0e10cSrcweir #define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
74cdf0e10cSrcweir
75cdf0e10cSrcweir #define COMMAND_CLOSE UNISTRING("close")
76cdf0e10cSrcweir
77cdf0e10cSrcweir #define CTRL_THROBBER UNISTRING("throbber")
78cdf0e10cSrcweir #define CTRL_PROGRESS UNISTRING("progress")
79cdf0e10cSrcweir
80cdf0e10cSrcweir #define TEXT_STATUS UNISTRING("text_status")
81cdf0e10cSrcweir #define TEXT_PERCENT UNISTRING("text_percent")
82cdf0e10cSrcweir #define TEXT_DESCRIPTION UNISTRING("text_description")
83cdf0e10cSrcweir
84cdf0e10cSrcweir #define FIXED_LINE_MODEL UNISTRING("com.sun.star.awt.UnoControlFixedLineModel")
85cdf0e10cSrcweir #define FIXED_TEXT_MODEL UNISTRING("com.sun.star.awt.UnoControlFixedTextModel")
86cdf0e10cSrcweir #define EDIT_FIELD_MODEL UNISTRING("com.sun.star.awt.UnoControlEditModel")
87cdf0e10cSrcweir #define BUTTON_MODEL UNISTRING("com.sun.star.awt.UnoControlButtonModel")
88cdf0e10cSrcweir #define GROUP_BOX_MODEL UNISTRING("com.sun.star.awt.UnoControlGroupBoxModel")
89cdf0e10cSrcweir
90cdf0e10cSrcweir using namespace com::sun::star;
91cdf0e10cSrcweir
92cdf0e10cSrcweir //--------------------------------------------------------------------
UpdateHandler(const uno::Reference<uno::XComponentContext> & rxContext,const rtl::Reference<IActionListener> & rxActionListener)93cdf0e10cSrcweir UpdateHandler::UpdateHandler( const uno::Reference< uno::XComponentContext > & rxContext,
94cdf0e10cSrcweir const rtl::Reference< IActionListener > & rxActionListener ) :
95cdf0e10cSrcweir mxContext( rxContext ),
96cdf0e10cSrcweir mxActionListener( rxActionListener ),
97cdf0e10cSrcweir meCurState( UPDATESTATES_COUNT ),
98cdf0e10cSrcweir meLastState( UPDATESTATES_COUNT ),
99cdf0e10cSrcweir mnPercent( 0 ),
100cdf0e10cSrcweir mnLastCtrlState( -1 ),
101cdf0e10cSrcweir mbDownloadBtnHasDots( false ),
102cdf0e10cSrcweir mbVisible( false ),
103cdf0e10cSrcweir mbStringsLoaded( false ),
104cdf0e10cSrcweir mbMinimized( false ),
105cdf0e10cSrcweir mbListenerAdded(false),
106cdf0e10cSrcweir mbShowsMessageBox(false)
107cdf0e10cSrcweir {
108cdf0e10cSrcweir }
109cdf0e10cSrcweir
110cdf0e10cSrcweir //--------------------------------------------------------------------
~UpdateHandler()111cdf0e10cSrcweir UpdateHandler::~UpdateHandler()
112cdf0e10cSrcweir {
113cdf0e10cSrcweir mxContext = NULL;
114cdf0e10cSrcweir mxUpdDlg = NULL;
115cdf0e10cSrcweir mxInteractionHdl = NULL;
116cdf0e10cSrcweir mxActionListener = NULL;
117cdf0e10cSrcweir }
118cdf0e10cSrcweir
119cdf0e10cSrcweir //--------------------------------------------------------------------
enableControls(short nCtrlState)120cdf0e10cSrcweir void UpdateHandler::enableControls( short nCtrlState )
121cdf0e10cSrcweir {
122cdf0e10cSrcweir osl::MutexGuard aGuard( maMutex );
123cdf0e10cSrcweir
124cdf0e10cSrcweir if ( nCtrlState == mnLastCtrlState )
125cdf0e10cSrcweir return;
126cdf0e10cSrcweir
127cdf0e10cSrcweir bool bEnableControl;
128cdf0e10cSrcweir
129cdf0e10cSrcweir short nCurStateVal = nCtrlState;
130cdf0e10cSrcweir short nOldStateVal = mnLastCtrlState;
131cdf0e10cSrcweir
132cdf0e10cSrcweir // the help button should always be the last button in the
133cdf0e10cSrcweir // enum list und must never be disabled
134cdf0e10cSrcweir for ( int i=0; i<HELP_BUTTON; i++ )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir nCurStateVal = (short)(nCtrlState >> i);
137cdf0e10cSrcweir nOldStateVal = (short)(mnLastCtrlState >> i);
138cdf0e10cSrcweir if ( ( nCurStateVal & 0x01 ) != ( nOldStateVal & 0x01 ) )
139cdf0e10cSrcweir {
140cdf0e10cSrcweir bEnableControl = ( ( nCurStateVal & 0x01 ) == 0x01 );
141cdf0e10cSrcweir setControlProperty( msButtonIDs[i], UNISTRING("Enabled"), uno::Any( bEnableControl ) );
142cdf0e10cSrcweir }
143cdf0e10cSrcweir }
144cdf0e10cSrcweir
145cdf0e10cSrcweir mnLastCtrlState = nCtrlState;
146cdf0e10cSrcweir }
147cdf0e10cSrcweir
148cdf0e10cSrcweir //--------------------------------------------------------------------
setDownloadBtnLabel(bool bAppendDots)149cdf0e10cSrcweir void UpdateHandler::setDownloadBtnLabel( bool bAppendDots )
150cdf0e10cSrcweir {
151cdf0e10cSrcweir osl::MutexGuard aGuard( maMutex );
152cdf0e10cSrcweir
153cdf0e10cSrcweir if ( mbDownloadBtnHasDots != bAppendDots )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir rtl::OUString aLabel( msDownload );
156cdf0e10cSrcweir
157cdf0e10cSrcweir if ( bAppendDots )
158cdf0e10cSrcweir aLabel += UNISTRING( "..." );
159cdf0e10cSrcweir
160cdf0e10cSrcweir setControlProperty( msButtonIDs[DOWNLOAD_BUTTON], UNISTRING("Label"), uno::Any( aLabel ) );
161cdf0e10cSrcweir setControlProperty( msButtonIDs[DOWNLOAD_BUTTON], UNISTRING("HelpURL"), uno::Any( UNISTRING( INET_HID_SCHEME ) + rtl::OUString::createFromAscii( HID_CHECK_FOR_UPD_DOWNLOAD2 ) ) );
162cdf0e10cSrcweir
163cdf0e10cSrcweir mbDownloadBtnHasDots = bAppendDots;
164cdf0e10cSrcweir }
165cdf0e10cSrcweir }
166cdf0e10cSrcweir
167cdf0e10cSrcweir //--------------------------------------------------------------------
setState(UpdateState eState)168cdf0e10cSrcweir void UpdateHandler::setState( UpdateState eState )
169cdf0e10cSrcweir {
170cdf0e10cSrcweir osl::MutexGuard aGuard( maMutex );
171cdf0e10cSrcweir
172cdf0e10cSrcweir meCurState = eState;
173cdf0e10cSrcweir
174cdf0e10cSrcweir if ( mxUpdDlg.is() && mbVisible )
175cdf0e10cSrcweir updateState( meCurState );
176cdf0e10cSrcweir }
177cdf0e10cSrcweir
178cdf0e10cSrcweir //--------------------------------------------------------------------
isVisible() const179cdf0e10cSrcweir bool UpdateHandler::isVisible() const
180cdf0e10cSrcweir {
181cdf0e10cSrcweir if ( !mxUpdDlg.is() ) return false;
182cdf0e10cSrcweir
183*a2db8daaSArrigo Marchiori ::vos::OGuard aGuard( Application::GetSolarMutex() );
184cdf0e10cSrcweir uno::Reference< awt::XWindow2 > xWindow( mxUpdDlg, uno::UNO_QUERY );
185cdf0e10cSrcweir
186cdf0e10cSrcweir if ( xWindow.is() )
187cdf0e10cSrcweir return xWindow->isVisible();
188cdf0e10cSrcweir else
189cdf0e10cSrcweir return false;
190cdf0e10cSrcweir }
191cdf0e10cSrcweir
192cdf0e10cSrcweir //--------------------------------------------------------------------
setVisible(bool bVisible)193cdf0e10cSrcweir void UpdateHandler::setVisible( bool bVisible )
194cdf0e10cSrcweir {
195cdf0e10cSrcweir osl::MutexGuard aGuard( maMutex );
196cdf0e10cSrcweir
197cdf0e10cSrcweir mbVisible = bVisible;
198cdf0e10cSrcweir
199cdf0e10cSrcweir if ( bVisible )
200cdf0e10cSrcweir {
201cdf0e10cSrcweir if ( !mxUpdDlg.is() )
202cdf0e10cSrcweir createDialog();
203cdf0e10cSrcweir
204cdf0e10cSrcweir // this should never happen, but if it happens we better return here
205cdf0e10cSrcweir if ( !mxUpdDlg.is() )
206cdf0e10cSrcweir return;
207cdf0e10cSrcweir
208cdf0e10cSrcweir updateState( meCurState );
209cdf0e10cSrcweir
210*a2db8daaSArrigo Marchiori ::vos::OGuard aGuard( Application::GetSolarMutex() );
211cdf0e10cSrcweir uno::Reference< awt::XWindow > xWindow( mxUpdDlg, uno::UNO_QUERY );
212cdf0e10cSrcweir
213cdf0e10cSrcweir if ( xWindow.is() )
214cdf0e10cSrcweir xWindow->setVisible( bVisible );
215cdf0e10cSrcweir
216cdf0e10cSrcweir uno::Reference< awt::XTopWindow > xTopWindow( mxUpdDlg, uno::UNO_QUERY );
217cdf0e10cSrcweir if ( xTopWindow.is() )
218cdf0e10cSrcweir {
219cdf0e10cSrcweir xTopWindow->toFront();
220cdf0e10cSrcweir if ( !mbListenerAdded )
221cdf0e10cSrcweir {
222cdf0e10cSrcweir xTopWindow->addTopWindowListener( this );
223cdf0e10cSrcweir mbListenerAdded = true;
224cdf0e10cSrcweir }
225cdf0e10cSrcweir }
226cdf0e10cSrcweir }
227cdf0e10cSrcweir else if ( mxUpdDlg.is() )
228cdf0e10cSrcweir {
229*a2db8daaSArrigo Marchiori ::vos::OGuard aGuard( Application::GetSolarMutex() );
230cdf0e10cSrcweir uno::Reference< awt::XWindow > xWindow( mxUpdDlg, uno::UNO_QUERY );
231cdf0e10cSrcweir
232cdf0e10cSrcweir if ( xWindow.is() )
233cdf0e10cSrcweir xWindow->setVisible( bVisible );
234cdf0e10cSrcweir }
235cdf0e10cSrcweir }
236cdf0e10cSrcweir
237cdf0e10cSrcweir //--------------------------------------------------------------------
setProgress(sal_Int32 nPercent)238cdf0e10cSrcweir void UpdateHandler::setProgress( sal_Int32 nPercent )
239cdf0e10cSrcweir {
240cdf0e10cSrcweir if ( nPercent > 100 )
241cdf0e10cSrcweir nPercent = 100;
242cdf0e10cSrcweir else if ( nPercent < 0 )
243cdf0e10cSrcweir nPercent = 0;
244cdf0e10cSrcweir
245cdf0e10cSrcweir if ( nPercent != mnPercent )
246cdf0e10cSrcweir {
247cdf0e10cSrcweir osl::MutexGuard aGuard( maMutex );
248cdf0e10cSrcweir
249cdf0e10cSrcweir mnPercent = nPercent;
250cdf0e10cSrcweir setControlProperty( CTRL_PROGRESS, UNISTRING("ProgressValue"), uno::Any( nPercent ) );
251cdf0e10cSrcweir setControlProperty( TEXT_PERCENT, UNISTRING("Text"), uno::Any( substVariables(msPercent) ) );
252cdf0e10cSrcweir }
253cdf0e10cSrcweir }
254cdf0e10cSrcweir
255cdf0e10cSrcweir //--------------------------------------------------------------------
setErrorMessage(const rtl::OUString & rErrorMsg)256cdf0e10cSrcweir void UpdateHandler::setErrorMessage( const rtl::OUString& rErrorMsg )
257cdf0e10cSrcweir {
258cdf0e10cSrcweir setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( rErrorMsg ) );
259cdf0e10cSrcweir }
260cdf0e10cSrcweir
261cdf0e10cSrcweir //--------------------------------------------------------------------
setDownloadFile(const rtl::OUString & rFilePath)262cdf0e10cSrcweir void UpdateHandler::setDownloadFile( const rtl::OUString& rFilePath )
263cdf0e10cSrcweir {
264cdf0e10cSrcweir sal_Int32 nLast = rFilePath.lastIndexOf( '/' );
265cdf0e10cSrcweir if ( nLast != -1 )
266cdf0e10cSrcweir {
267cdf0e10cSrcweir msDownloadFile = rFilePath.copy( nLast+1 );
268cdf0e10cSrcweir const rtl::OUString aDownloadURL = rFilePath.copy( 0, nLast );
269cdf0e10cSrcweir osl::FileBase::getSystemPathFromFileURL( aDownloadURL, msDownloadPath );
270cdf0e10cSrcweir }
271cdf0e10cSrcweir }
272cdf0e10cSrcweir
273cdf0e10cSrcweir //--------------------------------------------------------------------
getBubbleText(UpdateState eState)274cdf0e10cSrcweir rtl::OUString UpdateHandler::getBubbleText( UpdateState eState )
275cdf0e10cSrcweir {
276cdf0e10cSrcweir osl::MutexGuard aGuard( maMutex );
277cdf0e10cSrcweir
278cdf0e10cSrcweir rtl::OUString sText;
279cdf0e10cSrcweir sal_Int32 nIndex = (sal_Int32) eState;
280cdf0e10cSrcweir
281cdf0e10cSrcweir loadStrings();
282cdf0e10cSrcweir
283cdf0e10cSrcweir if ( ( UPDATESTATE_UPDATE_AVAIL <= nIndex ) && ( nIndex < UPDATESTATES_COUNT ) )
284cdf0e10cSrcweir sText = substVariables( msBubbleTexts[ nIndex - UPDATESTATE_UPDATE_AVAIL ] );
285cdf0e10cSrcweir
286cdf0e10cSrcweir return sText;
287cdf0e10cSrcweir }
288cdf0e10cSrcweir
289cdf0e10cSrcweir //--------------------------------------------------------------------
getBubbleTitle(UpdateState eState)290cdf0e10cSrcweir rtl::OUString UpdateHandler::getBubbleTitle( UpdateState eState )
291cdf0e10cSrcweir {
292cdf0e10cSrcweir osl::MutexGuard aGuard( maMutex );
293cdf0e10cSrcweir
294cdf0e10cSrcweir rtl::OUString sText;
295cdf0e10cSrcweir sal_Int32 nIndex = (sal_Int32) eState;
296cdf0e10cSrcweir
297cdf0e10cSrcweir loadStrings();
298cdf0e10cSrcweir
299cdf0e10cSrcweir if ( ( UPDATESTATE_UPDATE_AVAIL <= nIndex ) && ( nIndex < UPDATESTATES_COUNT ) )
300cdf0e10cSrcweir sText = substVariables( msBubbleTitles[ nIndex - UPDATESTATE_UPDATE_AVAIL] );
301cdf0e10cSrcweir
302cdf0e10cSrcweir return sText;
303cdf0e10cSrcweir }
304cdf0e10cSrcweir
305cdf0e10cSrcweir //--------------------------------------------------------------------
getDefaultInstErrMsg()306cdf0e10cSrcweir rtl::OUString UpdateHandler::getDefaultInstErrMsg()
307cdf0e10cSrcweir {
308cdf0e10cSrcweir osl::MutexGuard aGuard( maMutex );
309cdf0e10cSrcweir
310cdf0e10cSrcweir loadStrings();
311cdf0e10cSrcweir
312cdf0e10cSrcweir return substVariables( msInstallError );
313cdf0e10cSrcweir }
314cdf0e10cSrcweir
315cdf0e10cSrcweir // XActionListener
316cdf0e10cSrcweir //--------------------------------------------------------------------
disposing(const lang::EventObject & rEvt)317cdf0e10cSrcweir void SAL_CALL UpdateHandler::disposing( const lang::EventObject& rEvt )
318cdf0e10cSrcweir throw( uno::RuntimeException )
319cdf0e10cSrcweir {
320cdf0e10cSrcweir if ( rEvt.Source == mxUpdDlg )
321cdf0e10cSrcweir mxUpdDlg.clear();
322cdf0e10cSrcweir }
323cdf0e10cSrcweir
324cdf0e10cSrcweir //--------------------------------------------------------------------
actionPerformed(awt::ActionEvent const & rEvent)325cdf0e10cSrcweir void SAL_CALL UpdateHandler::actionPerformed( awt::ActionEvent const & rEvent )
326cdf0e10cSrcweir throw( uno::RuntimeException )
327cdf0e10cSrcweir {
328cdf0e10cSrcweir DialogControls eButton = BUTTON_COUNT;
329cdf0e10cSrcweir for ( int i = 0; i < BUTTON_COUNT; i++ )
330cdf0e10cSrcweir {
331cdf0e10cSrcweir if ( rEvent.ActionCommand.equals( msButtonIDs[i] ) )
332cdf0e10cSrcweir {
333cdf0e10cSrcweir eButton = (DialogControls) i;
334cdf0e10cSrcweir break;
335cdf0e10cSrcweir }
336cdf0e10cSrcweir }
337cdf0e10cSrcweir
338cdf0e10cSrcweir if ( rEvent.ActionCommand.equals( COMMAND_CLOSE ) )
339cdf0e10cSrcweir {
340cdf0e10cSrcweir if ( ( mnLastCtrlState & ( 1 << CLOSE_BUTTON ) ) == ( 1 << CLOSE_BUTTON ) )
341cdf0e10cSrcweir eButton = CLOSE_BUTTON;
342cdf0e10cSrcweir else
343cdf0e10cSrcweir eButton = CANCEL_BUTTON;
344cdf0e10cSrcweir }
345cdf0e10cSrcweir
346cdf0e10cSrcweir switch ( eButton ) {
347cdf0e10cSrcweir case CANCEL_BUTTON:
348cdf0e10cSrcweir {
349cdf0e10cSrcweir bool bCancel = true;
350cdf0e10cSrcweir
351cdf0e10cSrcweir if ( ( meCurState == UPDATESTATE_DOWNLOADING ) ||
352cdf0e10cSrcweir ( meCurState == UPDATESTATE_DOWNLOAD_PAUSED ) ||
353cdf0e10cSrcweir ( meCurState == UPDATESTATE_ERROR_DOWNLOADING ) )
354cdf0e10cSrcweir bCancel = showWarning( msCancelMessage );
355cdf0e10cSrcweir
356cdf0e10cSrcweir if ( bCancel )
357cdf0e10cSrcweir {
358cdf0e10cSrcweir mxActionListener->cancel();
359cdf0e10cSrcweir setVisible( false );
360cdf0e10cSrcweir }
361cdf0e10cSrcweir break;
362cdf0e10cSrcweir }
363cdf0e10cSrcweir case CLOSE_BUTTON:
364cdf0e10cSrcweir setVisible( false );
365cdf0e10cSrcweir if ( meCurState == UPDATESTATE_ERROR_CHECKING )
366cdf0e10cSrcweir mxActionListener->closeAfterFailure();
367cdf0e10cSrcweir break;
368cdf0e10cSrcweir case DOWNLOAD_BUTTON:
369cdf0e10cSrcweir mxActionListener->download();
370cdf0e10cSrcweir break;
371cdf0e10cSrcweir case INSTALL_BUTTON:
372cdf0e10cSrcweir if ( showWarning( msInstallMessage ) )
373cdf0e10cSrcweir mxActionListener->install();
374cdf0e10cSrcweir break;
375cdf0e10cSrcweir case PAUSE_BUTTON:
376cdf0e10cSrcweir mxActionListener->pause();
377cdf0e10cSrcweir break;
378cdf0e10cSrcweir case RESUME_BUTTON:
379cdf0e10cSrcweir mxActionListener->resume();
380cdf0e10cSrcweir break;
381cdf0e10cSrcweir case HELP_BUTTON:
382cdf0e10cSrcweir break;
383cdf0e10cSrcweir default:
384cdf0e10cSrcweir OSL_ENSURE( false, "UpdateHandler::actionPerformed: unknown command!" );
385cdf0e10cSrcweir }
386cdf0e10cSrcweir }
387cdf0e10cSrcweir
388cdf0e10cSrcweir // XTopWindowListener
389cdf0e10cSrcweir //--------------------------------------------------------------------
windowOpened(const lang::EventObject &)390cdf0e10cSrcweir void SAL_CALL UpdateHandler::windowOpened( const lang::EventObject& )
391cdf0e10cSrcweir throw( uno::RuntimeException )
392cdf0e10cSrcweir {
393cdf0e10cSrcweir }
394cdf0e10cSrcweir
395cdf0e10cSrcweir //--------------------------------------------------------------------
windowClosing(const lang::EventObject & e)396cdf0e10cSrcweir void SAL_CALL UpdateHandler::windowClosing( const lang::EventObject& e )
397cdf0e10cSrcweir throw( uno::RuntimeException )
398cdf0e10cSrcweir {
399*a2db8daaSArrigo Marchiori ::vos::OGuard aGuard( Application::GetSolarMutex() );
400cdf0e10cSrcweir awt::ActionEvent aActionEvt;
401cdf0e10cSrcweir aActionEvt.ActionCommand = COMMAND_CLOSE;
402cdf0e10cSrcweir aActionEvt.Source = e.Source;
403cdf0e10cSrcweir
404cdf0e10cSrcweir actionPerformed( aActionEvt );
405cdf0e10cSrcweir }
406cdf0e10cSrcweir
407cdf0e10cSrcweir //--------------------------------------------------------------------
windowClosed(const lang::EventObject &)408cdf0e10cSrcweir void SAL_CALL UpdateHandler::windowClosed( const lang::EventObject& )
409cdf0e10cSrcweir throw( uno::RuntimeException )
410cdf0e10cSrcweir {
411cdf0e10cSrcweir }
412cdf0e10cSrcweir
413cdf0e10cSrcweir //--------------------------------------------------------------------
windowMinimized(const lang::EventObject &)414cdf0e10cSrcweir void SAL_CALL UpdateHandler::windowMinimized( const lang::EventObject& )
415cdf0e10cSrcweir throw( uno::RuntimeException )
416cdf0e10cSrcweir {
417cdf0e10cSrcweir mbMinimized = true;
418cdf0e10cSrcweir }
419cdf0e10cSrcweir
420cdf0e10cSrcweir //--------------------------------------------------------------------
windowNormalized(const lang::EventObject &)421cdf0e10cSrcweir void SAL_CALL UpdateHandler::windowNormalized( const lang::EventObject& )
422cdf0e10cSrcweir throw( uno::RuntimeException )
423cdf0e10cSrcweir {
424cdf0e10cSrcweir mbMinimized = false;
425cdf0e10cSrcweir }
426cdf0e10cSrcweir
427cdf0e10cSrcweir //--------------------------------------------------------------------
windowActivated(const lang::EventObject &)428cdf0e10cSrcweir void SAL_CALL UpdateHandler::windowActivated( const lang::EventObject& )
429cdf0e10cSrcweir throw( uno::RuntimeException )
430cdf0e10cSrcweir {
431cdf0e10cSrcweir }
432cdf0e10cSrcweir
433cdf0e10cSrcweir //--------------------------------------------------------------------
windowDeactivated(const lang::EventObject &)434cdf0e10cSrcweir void SAL_CALL UpdateHandler::windowDeactivated( const lang::EventObject& )
435cdf0e10cSrcweir throw( uno::RuntimeException )
436cdf0e10cSrcweir {
437cdf0e10cSrcweir }
438cdf0e10cSrcweir
439cdf0e10cSrcweir // XInteractionHandler
440cdf0e10cSrcweir //------------------------------------------------------------------------------
handle(uno::Reference<task::XInteractionRequest> const & rRequest)441cdf0e10cSrcweir void SAL_CALL UpdateHandler::handle( uno::Reference< task::XInteractionRequest > const & rRequest)
442cdf0e10cSrcweir throw (uno::RuntimeException)
443cdf0e10cSrcweir {
444cdf0e10cSrcweir if ( !mxInteractionHdl.is() )
445cdf0e10cSrcweir {
446cdf0e10cSrcweir if( !mxContext.is() )
447cdf0e10cSrcweir throw uno::RuntimeException( UNISTRING( "UpdateHandler:: empty component context" ), *this );
448cdf0e10cSrcweir
449cdf0e10cSrcweir uno::Reference< lang::XMultiComponentFactory > xServiceManager(mxContext->getServiceManager());
450cdf0e10cSrcweir
451cdf0e10cSrcweir if( !xServiceManager.is() )
452cdf0e10cSrcweir throw uno::RuntimeException( UNISTRING( "UpdateHandler: unable to obtain service manager from component context" ), *this );
453cdf0e10cSrcweir
454cdf0e10cSrcweir mxInteractionHdl = uno::Reference<task::XInteractionHandler> (
455cdf0e10cSrcweir xServiceManager->createInstanceWithContext(
456cdf0e10cSrcweir UNISTRING( "com.sun.star.task.InteractionHandler" ),
457cdf0e10cSrcweir mxContext),
458cdf0e10cSrcweir uno::UNO_QUERY_THROW);
459cdf0e10cSrcweir if( !mxInteractionHdl.is() )
460cdf0e10cSrcweir throw uno::RuntimeException( UNISTRING( "UpdateHandler:: could not get default interaction handler" ), *this );
461cdf0e10cSrcweir }
462cdf0e10cSrcweir uno::Reference< task::XInteractionRequestStringResolver > xStrResolver =
463cdf0e10cSrcweir task::InteractionRequestStringResolver::create( mxContext );
464cdf0e10cSrcweir beans::Optional< ::rtl::OUString > aErrorText = xStrResolver->getStringFromInformationalRequest( rRequest );
465cdf0e10cSrcweir if ( aErrorText.IsPresent )
466cdf0e10cSrcweir {
467cdf0e10cSrcweir setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( aErrorText.Value ) );
468cdf0e10cSrcweir
469cdf0e10cSrcweir uno::Sequence< uno::Reference< task::XInteractionContinuation > > xContinuations = rRequest->getContinuations();
470cdf0e10cSrcweir if ( xContinuations.getLength() == 1 )
471cdf0e10cSrcweir {
472cdf0e10cSrcweir if ( meCurState == UPDATESTATE_CHECKING )
473cdf0e10cSrcweir setState( UPDATESTATE_ERROR_CHECKING );
474cdf0e10cSrcweir else if ( meCurState == UPDATESTATE_DOWNLOADING )
475cdf0e10cSrcweir setState( UPDATESTATE_ERROR_DOWNLOADING );
476cdf0e10cSrcweir
477cdf0e10cSrcweir xContinuations[0]->select();
478cdf0e10cSrcweir }
479cdf0e10cSrcweir else
480cdf0e10cSrcweir mxInteractionHdl->handle( rRequest );
481cdf0e10cSrcweir }
482cdf0e10cSrcweir else
483cdf0e10cSrcweir mxInteractionHdl->handle( rRequest );
484cdf0e10cSrcweir }
485cdf0e10cSrcweir
486cdf0e10cSrcweir //------------------------------------------------------------------------------
487cdf0e10cSrcweir // XTerminateListener
488cdf0e10cSrcweir //------------------------------------------------------------------------------
queryTermination(const lang::EventObject &)489cdf0e10cSrcweir void SAL_CALL UpdateHandler::queryTermination( const lang::EventObject& )
490cdf0e10cSrcweir throw ( frame::TerminationVetoException, uno::RuntimeException )
491cdf0e10cSrcweir {
492cdf0e10cSrcweir if ( mbShowsMessageBox )
493cdf0e10cSrcweir {
494*a2db8daaSArrigo Marchiori ::vos::OGuard aGuard( Application::GetSolarMutex() );
495cdf0e10cSrcweir uno::Reference< awt::XTopWindow > xTopWindow( mxUpdDlg, uno::UNO_QUERY );
496cdf0e10cSrcweir if ( xTopWindow.is() )
497cdf0e10cSrcweir xTopWindow->toFront();
498cdf0e10cSrcweir
499cdf0e10cSrcweir throw frame::TerminationVetoException(
500cdf0e10cSrcweir UNISTRING("The office cannot be closed while displaying a warning!"),
501cdf0e10cSrcweir uno::Reference<XInterface>(static_cast<frame::XTerminateListener*>(this), uno::UNO_QUERY));
502cdf0e10cSrcweir }
503cdf0e10cSrcweir else
504cdf0e10cSrcweir setVisible( false );
505cdf0e10cSrcweir }
506cdf0e10cSrcweir
507cdf0e10cSrcweir //------------------------------------------------------------------------------
notifyTermination(const lang::EventObject &)508cdf0e10cSrcweir void SAL_CALL UpdateHandler::notifyTermination( const lang::EventObject& )
509cdf0e10cSrcweir throw ( uno::RuntimeException )
510cdf0e10cSrcweir {
511cdf0e10cSrcweir osl::MutexGuard aGuard( maMutex );
512cdf0e10cSrcweir
513cdf0e10cSrcweir if ( mxUpdDlg.is() )
514cdf0e10cSrcweir {
515*a2db8daaSArrigo Marchiori ::vos::OGuard aGuard( Application::GetSolarMutex() );
516cdf0e10cSrcweir uno::Reference< awt::XTopWindow > xTopWindow( mxUpdDlg, uno::UNO_QUERY );
517cdf0e10cSrcweir if ( xTopWindow.is() )
518cdf0e10cSrcweir xTopWindow->removeTopWindowListener( this );
519cdf0e10cSrcweir
520cdf0e10cSrcweir uno::Reference< lang::XComponent > xComponent( mxUpdDlg, uno::UNO_QUERY );
521cdf0e10cSrcweir if ( xComponent.is() )
522cdf0e10cSrcweir xComponent->dispose();
523cdf0e10cSrcweir
524cdf0e10cSrcweir mxUpdDlg.clear();
525cdf0e10cSrcweir }
526cdf0e10cSrcweir }
527cdf0e10cSrcweir
528cdf0e10cSrcweir //--------------------------------------------------------------------
529cdf0e10cSrcweir //--------------------------------------------------------------------
530cdf0e10cSrcweir //--------------------------------------------------------------------
updateState(UpdateState eState)531cdf0e10cSrcweir void UpdateHandler::updateState( UpdateState eState )
532cdf0e10cSrcweir {
533cdf0e10cSrcweir if ( meLastState == eState )
534cdf0e10cSrcweir return;
535cdf0e10cSrcweir
536cdf0e10cSrcweir if ( isVisible() )
537cdf0e10cSrcweir {} // ToTop();
538cdf0e10cSrcweir
539cdf0e10cSrcweir rtl::OUString sText;
540cdf0e10cSrcweir
541cdf0e10cSrcweir switch ( eState )
542cdf0e10cSrcweir {
543cdf0e10cSrcweir case UPDATESTATE_CHECKING:
544cdf0e10cSrcweir showControls( (1<<CANCEL_BUTTON) + (1<<THROBBER_CTRL) );
545cdf0e10cSrcweir enableControls( 1<<CANCEL_BUTTON );
546cdf0e10cSrcweir setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msChecking) ) );
547cdf0e10cSrcweir setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( rtl::OUString() ) );
548cdf0e10cSrcweir focusControl( CANCEL_BUTTON );
549cdf0e10cSrcweir break;
550cdf0e10cSrcweir case UPDATESTATE_ERROR_CHECKING:
551cdf0e10cSrcweir showControls( 0 );
552cdf0e10cSrcweir enableControls( 1 << CLOSE_BUTTON );
553cdf0e10cSrcweir setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msCheckingError) ) );
554cdf0e10cSrcweir focusControl( CLOSE_BUTTON );
555cdf0e10cSrcweir break;
556cdf0e10cSrcweir case UPDATESTATE_UPDATE_AVAIL:
557cdf0e10cSrcweir showControls( 0 );
558cdf0e10cSrcweir enableControls( ( 1 << CLOSE_BUTTON ) + ( 1 << DOWNLOAD_BUTTON ) );
559cdf0e10cSrcweir setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msUpdFound) ) );
560cdf0e10cSrcweir
561cdf0e10cSrcweir sText = substVariables(msDownloadWarning);
562cdf0e10cSrcweir if ( msDescriptionMsg.getLength() )
563cdf0e10cSrcweir sText += UNISTRING("\n\n") + msDescriptionMsg;
564cdf0e10cSrcweir setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( sText ) );
565cdf0e10cSrcweir
566cdf0e10cSrcweir setDownloadBtnLabel( false );
567cdf0e10cSrcweir focusControl( DOWNLOAD_BUTTON );
568cdf0e10cSrcweir break;
569cdf0e10cSrcweir case UPDATESTATE_UPDATE_NO_DOWNLOAD:
570cdf0e10cSrcweir showControls( 0 );
571cdf0e10cSrcweir enableControls( ( 1 << CLOSE_BUTTON ) + ( 1 << DOWNLOAD_BUTTON ) );
572cdf0e10cSrcweir setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msUpdFound) ) );
573cdf0e10cSrcweir
574cdf0e10cSrcweir sText = substVariables(msDownloadNotAvail);
575cdf0e10cSrcweir if ( msDescriptionMsg.getLength() )
576cdf0e10cSrcweir sText += UNISTRING("\n\n") + msDescriptionMsg;
577cdf0e10cSrcweir setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( sText ) );
578cdf0e10cSrcweir
579cdf0e10cSrcweir setDownloadBtnLabel( true );
580cdf0e10cSrcweir focusControl( DOWNLOAD_BUTTON );
581cdf0e10cSrcweir break;
582cdf0e10cSrcweir case UPDATESTATE_NO_UPDATE_AVAIL:
583cdf0e10cSrcweir case UPDATESTATE_EXT_UPD_AVAIL: // will only be set, when there are no office updates avail
584cdf0e10cSrcweir showControls( 0 );
585cdf0e10cSrcweir enableControls( 1 << CLOSE_BUTTON );
586cdf0e10cSrcweir setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msNoUpdFound) ) );
587cdf0e10cSrcweir setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( rtl::OUString() ) );
588cdf0e10cSrcweir focusControl( CLOSE_BUTTON );
589cdf0e10cSrcweir break;
590cdf0e10cSrcweir case UPDATESTATE_DOWNLOADING:
591cdf0e10cSrcweir showControls( (1<<PROGRESS_CTRL) + (1<<CANCEL_BUTTON) + (1<<PAUSE_BUTTON) + (1<<RESUME_BUTTON) );
592cdf0e10cSrcweir enableControls( (1<<CLOSE_BUTTON) + (1<<CANCEL_BUTTON) + (1<<PAUSE_BUTTON) );
593cdf0e10cSrcweir setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msDownloading) ) );
594cdf0e10cSrcweir setControlProperty( TEXT_PERCENT, UNISTRING("Text"), uno::Any( substVariables(msPercent) ) );
595cdf0e10cSrcweir setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( substVariables(msDownloadWarning) ) );
596cdf0e10cSrcweir setControlProperty( CTRL_PROGRESS, UNISTRING("ProgressValue"), uno::Any( mnPercent ) );
597cdf0e10cSrcweir focusControl( CLOSE_BUTTON );
598cdf0e10cSrcweir break;
599cdf0e10cSrcweir case UPDATESTATE_DOWNLOAD_PAUSED:
600cdf0e10cSrcweir showControls( (1<<PROGRESS_CTRL) + (1<<CANCEL_BUTTON) + (1<<PAUSE_BUTTON) + (1<<RESUME_BUTTON) );
601cdf0e10cSrcweir enableControls( (1<<CLOSE_BUTTON) + (1<<CANCEL_BUTTON) + (1<<RESUME_BUTTON) );
602cdf0e10cSrcweir setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msDownloadPause) ) );
603cdf0e10cSrcweir setControlProperty( TEXT_PERCENT, UNISTRING("Text"), uno::Any( substVariables(msPercent) ) );
604cdf0e10cSrcweir setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( substVariables(msDownloadWarning) ) );
605cdf0e10cSrcweir setControlProperty( CTRL_PROGRESS, UNISTRING("ProgressValue"), uno::Any( mnPercent ) );
606cdf0e10cSrcweir focusControl( CLOSE_BUTTON );
607cdf0e10cSrcweir break;
608cdf0e10cSrcweir case UPDATESTATE_ERROR_DOWNLOADING:
609cdf0e10cSrcweir showControls( (1<<PROGRESS_CTRL) + (1<<CANCEL_BUTTON) + (1<<PAUSE_BUTTON) + (1<<RESUME_BUTTON) );
610cdf0e10cSrcweir enableControls( (1<<CLOSE_BUTTON) + (1<<CANCEL_BUTTON) );
611cdf0e10cSrcweir setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msDownloadError) ) );
612cdf0e10cSrcweir focusControl( CLOSE_BUTTON );
613cdf0e10cSrcweir break;
614cdf0e10cSrcweir case UPDATESTATE_DOWNLOAD_AVAIL:
615cdf0e10cSrcweir showControls( 0 );
616cdf0e10cSrcweir enableControls( (1<<CLOSE_BUTTON) + (1<<INSTALL_BUTTON) );
617cdf0e10cSrcweir setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msReady2Install) ) );
618cdf0e10cSrcweir setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( substVariables(msDownloadDescr) ) );
619cdf0e10cSrcweir focusControl( INSTALL_BUTTON );
620cdf0e10cSrcweir break;
621cdf0e10cSrcweir case UPDATESTATE_AUTO_START:
622cdf0e10cSrcweir case UPDATESTATES_COUNT:
623cdf0e10cSrcweir //do nothing, only count!
624cdf0e10cSrcweir break;
625cdf0e10cSrcweir }
626cdf0e10cSrcweir
627cdf0e10cSrcweir meLastState = eState;
628cdf0e10cSrcweir }
629cdf0e10cSrcweir
630cdf0e10cSrcweir //--------------------------------------------------------------------
searchAndReplaceAll(rtl::OUString & rText,const rtl::OUString & rWhat,const rtl::OUString & rWith) const631cdf0e10cSrcweir void UpdateHandler::searchAndReplaceAll( rtl::OUString &rText,
632cdf0e10cSrcweir const rtl::OUString &rWhat,
633cdf0e10cSrcweir const rtl::OUString &rWith ) const
634cdf0e10cSrcweir {
635cdf0e10cSrcweir sal_Int32 nIndex = rText.indexOf( rWhat );
636cdf0e10cSrcweir
637cdf0e10cSrcweir while ( nIndex != -1 )
638cdf0e10cSrcweir {
639cdf0e10cSrcweir rText = rText.replaceAt( nIndex, rWhat.getLength(), rWith );
640cdf0e10cSrcweir nIndex = rText.indexOf( rWhat, nIndex );
641cdf0e10cSrcweir }
642cdf0e10cSrcweir }
643cdf0e10cSrcweir
644cdf0e10cSrcweir //--------------------------------------------------------------------
loadString(const uno::Reference<resource::XResourceBundle> xBundle,sal_Int32 nResourceId) const645cdf0e10cSrcweir rtl::OUString UpdateHandler::loadString( const uno::Reference< resource::XResourceBundle > xBundle,
646cdf0e10cSrcweir sal_Int32 nResourceId ) const
647cdf0e10cSrcweir {
648cdf0e10cSrcweir rtl::OUString sString;
649cdf0e10cSrcweir rtl::OUString sKey = UNISTRING( "string:" ) + rtl::OUString::valueOf( nResourceId );
650cdf0e10cSrcweir
651cdf0e10cSrcweir try
652cdf0e10cSrcweir {
653cdf0e10cSrcweir OSL_VERIFY( xBundle->getByName( sKey ) >>= sString );
654cdf0e10cSrcweir }
655cdf0e10cSrcweir catch( const uno::Exception& )
656cdf0e10cSrcweir {
657cdf0e10cSrcweir OSL_ENSURE( false, "UpdateHandler::loadString: caught an exception!" );
658cdf0e10cSrcweir sString = UNISTRING("Missing ") + sKey;
659cdf0e10cSrcweir }
660cdf0e10cSrcweir
661cdf0e10cSrcweir return sString;
662cdf0e10cSrcweir }
663cdf0e10cSrcweir
substVariables(const rtl::OUString & rSource) const664cdf0e10cSrcweir rtl::OUString UpdateHandler::substVariables( const rtl::OUString &rSource ) const
665cdf0e10cSrcweir {
666cdf0e10cSrcweir rtl::OUString sString( rSource );
667cdf0e10cSrcweir
668cdf0e10cSrcweir searchAndReplaceAll( sString, UNISTRING( "%NEXTVERSION" ), msNextVersion );
669cdf0e10cSrcweir searchAndReplaceAll( sString, UNISTRING( "%DOWNLOAD_PATH" ), msDownloadPath );
670cdf0e10cSrcweir searchAndReplaceAll( sString, UNISTRING( "%FILE_NAME" ), msDownloadFile );
671cdf0e10cSrcweir searchAndReplaceAll( sString, UNISTRING( "%PERCENT" ), rtl::OUString::valueOf( mnPercent ) );
672cdf0e10cSrcweir
673cdf0e10cSrcweir return sString;
674cdf0e10cSrcweir }
675cdf0e10cSrcweir
676cdf0e10cSrcweir //--------------------------------------------------------------------
loadStrings()677cdf0e10cSrcweir void UpdateHandler::loadStrings()
678cdf0e10cSrcweir {
679cdf0e10cSrcweir if ( mbStringsLoaded )
680cdf0e10cSrcweir return;
681cdf0e10cSrcweir else
682cdf0e10cSrcweir mbStringsLoaded = true;
683cdf0e10cSrcweir
684cdf0e10cSrcweir uno::Reference< resource::XResourceBundleLoader > xLoader;
685cdf0e10cSrcweir try
686cdf0e10cSrcweir {
687cdf0e10cSrcweir uno::Any aValue( mxContext->getValueByName(
688cdf0e10cSrcweir UNISTRING( "/singletons/com.sun.star.resource.OfficeResourceLoader" ) ) );
689cdf0e10cSrcweir OSL_VERIFY( aValue >>= xLoader );
690cdf0e10cSrcweir }
691cdf0e10cSrcweir catch( const uno::Exception& )
692cdf0e10cSrcweir {
693cdf0e10cSrcweir OSL_ENSURE( false, "UpdateHandler::loadStrings: could not create the resource loader!" );
694cdf0e10cSrcweir }
695cdf0e10cSrcweir
696cdf0e10cSrcweir if ( !xLoader.is() ) return;
697cdf0e10cSrcweir
698cdf0e10cSrcweir uno::Reference< resource::XResourceBundle > xBundle;
699cdf0e10cSrcweir
700cdf0e10cSrcweir try
701cdf0e10cSrcweir {
702cdf0e10cSrcweir xBundle = xLoader->loadBundle_Default( UNISTRING( "upd" ) );
703cdf0e10cSrcweir }
704cdf0e10cSrcweir catch( const resource::MissingResourceException& )
705cdf0e10cSrcweir {
706cdf0e10cSrcweir OSL_ENSURE( false, "UpdateHandler::loadStrings: missing the resource bundle!" );
707cdf0e10cSrcweir }
708cdf0e10cSrcweir
709cdf0e10cSrcweir if ( !xBundle.is() ) return;
710cdf0e10cSrcweir
711cdf0e10cSrcweir msChecking = loadString( xBundle, RID_UPDATE_STR_CHECKING );
712cdf0e10cSrcweir msCheckingError = loadString( xBundle, RID_UPDATE_STR_CHECKING_ERR );
713cdf0e10cSrcweir msNoUpdFound = loadString( xBundle, RID_UPDATE_STR_NO_UPD_FOUND );
714cdf0e10cSrcweir
715cdf0e10cSrcweir msUpdFound = loadString( xBundle, RID_UPDATE_STR_UPD_FOUND );
716cdf0e10cSrcweir setFullVersion( msUpdFound );
717cdf0e10cSrcweir
718cdf0e10cSrcweir msDlgTitle = loadString( xBundle, RID_UPDATE_STR_DLG_TITLE );
719cdf0e10cSrcweir msDownloadPause = loadString( xBundle, RID_UPDATE_STR_DOWNLOAD_PAUSE );
720cdf0e10cSrcweir msDownloadError = loadString( xBundle, RID_UPDATE_STR_DOWNLOAD_ERR );
721cdf0e10cSrcweir msDownloadWarning = loadString( xBundle, RID_UPDATE_STR_DOWNLOAD_WARN );
722cdf0e10cSrcweir msDownloadDescr = loadString( xBundle, RID_UPDATE_STR_DOWNLOAD_DESCR );
723cdf0e10cSrcweir msDownloadNotAvail = loadString( xBundle, RID_UPDATE_STR_DOWNLOAD_UNAVAIL );
724cdf0e10cSrcweir msDownloading = loadString( xBundle, RID_UPDATE_STR_DOWNLOADING );
725cdf0e10cSrcweir msReady2Install = loadString( xBundle, RID_UPDATE_STR_READY_INSTALL );
726cdf0e10cSrcweir msCancelTitle = loadString( xBundle, RID_UPDATE_STR_CANCEL_TITLE );
727cdf0e10cSrcweir msCancelMessage = loadString( xBundle, RID_UPDATE_STR_CANCEL_DOWNLOAD );
728cdf0e10cSrcweir msInstallMessage = loadString( xBundle, RID_UPDATE_STR_BEGIN_INSTALL );
729cdf0e10cSrcweir msInstallNow = loadString( xBundle, RID_UPDATE_STR_INSTALL_NOW );
730cdf0e10cSrcweir msInstallLater = loadString( xBundle, RID_UPDATE_STR_INSTALL_LATER );
731cdf0e10cSrcweir msInstallError = loadString( xBundle, RID_UPDATE_STR_INSTALL_ERROR );
732cdf0e10cSrcweir msOverwriteWarning = loadString( xBundle, RID_UPDATE_STR_OVERWRITE_WARNING );
733cdf0e10cSrcweir msPercent = loadString( xBundle, RID_UPDATE_STR_PERCENT );
734cdf0e10cSrcweir msReloadWarning = loadString( xBundle, RID_UPDATE_STR_RELOAD_WARNING );
735cdf0e10cSrcweir msReloadReload = loadString( xBundle, RID_UPDATE_STR_RELOAD_RELOAD );
736cdf0e10cSrcweir msReloadContinue = loadString( xBundle, RID_UPDATE_STR_RELOAD_CONTINUE );
737cdf0e10cSrcweir
738cdf0e10cSrcweir msStatusFL = loadString( xBundle, RID_UPDATE_FT_STATUS );
739cdf0e10cSrcweir msDescription = loadString( xBundle, RID_UPDATE_FT_DESCRIPTION );
740cdf0e10cSrcweir
741cdf0e10cSrcweir msClose = loadString( xBundle, RID_UPDATE_BTN_CLOSE );
742cdf0e10cSrcweir msDownload = loadString( xBundle, RID_UPDATE_BTN_DOWNLOAD );
743cdf0e10cSrcweir msInstall = loadString( xBundle, RID_UPDATE_BTN_INSTALL );
744cdf0e10cSrcweir msPauseBtn = loadString( xBundle, RID_UPDATE_BTN_PAUSE );
745cdf0e10cSrcweir msResumeBtn = loadString( xBundle, RID_UPDATE_BTN_RESUME );
746cdf0e10cSrcweir msCancelBtn = loadString( xBundle, RID_UPDATE_BTN_CANCEL );
747cdf0e10cSrcweir
748cdf0e10cSrcweir // all update states before UPDATESTATE_UPDATE_AVAIL don't have a bubble
749cdf0e10cSrcweir // so we can ignore them
750cdf0e10cSrcweir for ( int i=0; i < (int)(UPDATESTATES_COUNT - UPDATESTATE_UPDATE_AVAIL); i++ )
751cdf0e10cSrcweir {
752cdf0e10cSrcweir msBubbleTexts[ i ] = loadString( xBundle, RID_UPDATE_BUBBLE_TEXT_START + i );
753cdf0e10cSrcweir msBubbleTitles[ i ] = loadString( xBundle, RID_UPDATE_BUBBLE_T_TEXT_START + i );
754cdf0e10cSrcweir }
755cdf0e10cSrcweir
756cdf0e10cSrcweir for ( int i=0; i < BUTTON_COUNT; i++ )
757cdf0e10cSrcweir {
758cdf0e10cSrcweir msButtonIDs[ i ] = UNISTRING("BUTTON_") + rtl::OUString::valueOf( (sal_Int32) i );
759cdf0e10cSrcweir }
760cdf0e10cSrcweir }
761cdf0e10cSrcweir
762cdf0e10cSrcweir
763cdf0e10cSrcweir //--------------------------------------------------------------------
startThrobber(bool bStart)764cdf0e10cSrcweir void UpdateHandler::startThrobber( bool bStart )
765cdf0e10cSrcweir {
766*a2db8daaSArrigo Marchiori ::vos::OGuard aGuard( Application::GetSolarMutex() );
767cdf0e10cSrcweir uno::Reference< awt::XControlContainer > xContainer( mxUpdDlg, uno::UNO_QUERY );
768cdf0e10cSrcweir uno::Reference< awt::XAnimation > xThrobber( xContainer->getControl( CTRL_THROBBER ), uno::UNO_QUERY );
769cdf0e10cSrcweir
770cdf0e10cSrcweir if ( xThrobber.is() )
771cdf0e10cSrcweir {
772cdf0e10cSrcweir if ( bStart )
773cdf0e10cSrcweir xThrobber->startAnimation();
774cdf0e10cSrcweir else
775cdf0e10cSrcweir xThrobber->stopAnimation();
776cdf0e10cSrcweir }
777cdf0e10cSrcweir
778cdf0e10cSrcweir uno::Reference< awt::XWindow > xWindow( xContainer->getControl( CTRL_THROBBER ), uno::UNO_QUERY );
779cdf0e10cSrcweir if (xWindow.is() )
780cdf0e10cSrcweir xWindow->setVisible( bStart );
781cdf0e10cSrcweir }
782cdf0e10cSrcweir
783cdf0e10cSrcweir //--------------------------------------------------------------------
setControlProperty(const rtl::OUString & rCtrlName,const rtl::OUString & rPropName,const uno::Any & rPropValue)784cdf0e10cSrcweir void UpdateHandler::setControlProperty( const rtl::OUString &rCtrlName,
785cdf0e10cSrcweir const rtl::OUString &rPropName,
786cdf0e10cSrcweir const uno::Any &rPropValue )
787cdf0e10cSrcweir {
788cdf0e10cSrcweir if ( !mxUpdDlg.is() ) return;
789cdf0e10cSrcweir
790*a2db8daaSArrigo Marchiori ::vos::OGuard aGuard( Application::GetSolarMutex() );
791cdf0e10cSrcweir uno::Reference< awt::XControlContainer > xContainer( mxUpdDlg, uno::UNO_QUERY );
792cdf0e10cSrcweir uno::Reference< awt::XControl > xControl( xContainer->getControl( rCtrlName ), uno::UNO_QUERY_THROW );
793cdf0e10cSrcweir uno::Reference< awt::XControlModel > xControlModel( xControl->getModel(), uno::UNO_QUERY_THROW );
794cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY_THROW );
795cdf0e10cSrcweir
796cdf0e10cSrcweir try {
797cdf0e10cSrcweir xPropSet->setPropertyValue( rPropName, rPropValue );
798cdf0e10cSrcweir }
799cdf0e10cSrcweir catch( const beans::UnknownPropertyException& )
800cdf0e10cSrcweir {
801cdf0e10cSrcweir OSL_ENSURE( false, "UpdateHandler::setControlProperty: caught an exception!" );
802cdf0e10cSrcweir }
803cdf0e10cSrcweir }
804cdf0e10cSrcweir
805cdf0e10cSrcweir //--------------------------------------------------------------------
showControl(const rtl::OUString & rCtrlName,bool bShow)806cdf0e10cSrcweir void UpdateHandler::showControl( const rtl::OUString &rCtrlName, bool bShow )
807cdf0e10cSrcweir {
808*a2db8daaSArrigo Marchiori ::vos::OGuard aGuard( Application::GetSolarMutex() );
809cdf0e10cSrcweir uno::Reference< awt::XControlContainer > xContainer( mxUpdDlg, uno::UNO_QUERY );
810cdf0e10cSrcweir
811cdf0e10cSrcweir if ( !xContainer.is() )
812cdf0e10cSrcweir {
813cdf0e10cSrcweir OSL_ENSURE( false, "UpdateHandler::showControl: could not get control container!" );
814cdf0e10cSrcweir return;
815cdf0e10cSrcweir }
816cdf0e10cSrcweir
817cdf0e10cSrcweir uno::Reference< awt::XWindow > xWindow( xContainer->getControl( rCtrlName ), uno::UNO_QUERY );
818cdf0e10cSrcweir if ( xWindow.is() )
819cdf0e10cSrcweir xWindow->setVisible( bShow );
820cdf0e10cSrcweir }
821cdf0e10cSrcweir
822cdf0e10cSrcweir //--------------------------------------------------------------------
focusControl(DialogControls eID)823cdf0e10cSrcweir void UpdateHandler::focusControl( DialogControls eID )
824cdf0e10cSrcweir {
825*a2db8daaSArrigo Marchiori ::vos::OGuard aGuard( Application::GetSolarMutex() );
826cdf0e10cSrcweir uno::Reference< awt::XControlContainer > xContainer( mxUpdDlg, uno::UNO_QUERY );
827cdf0e10cSrcweir
828cdf0e10cSrcweir if ( !xContainer.is() )
829cdf0e10cSrcweir {
830cdf0e10cSrcweir OSL_ENSURE( false, "UpdateHandler::focusControl: could not get control container!" );
831cdf0e10cSrcweir return;
832cdf0e10cSrcweir }
833cdf0e10cSrcweir
834cdf0e10cSrcweir OSL_ENSURE( (eID < BUTTON_COUNT), "UpdateHandler::focusControl: id to big!" );
835cdf0e10cSrcweir
836cdf0e10cSrcweir uno::Reference< awt::XWindow > xWindow( xContainer->getControl( msButtonIDs[(short)eID] ), uno::UNO_QUERY );
837cdf0e10cSrcweir if ( xWindow.is() )
838cdf0e10cSrcweir xWindow->setFocus();
839cdf0e10cSrcweir }
840cdf0e10cSrcweir
841cdf0e10cSrcweir //--------------------------------------------------------------------
842*a2db8daaSArrigo Marchiori // Requires the Solar Mutex to be locked
insertControlModel(uno::Reference<awt::XControlModel> & rxDialogModel,rtl::OUString const & rServiceName,rtl::OUString const & rControlName,awt::Rectangle const & rPosSize,uno::Sequence<beans::NamedValue> const & rProps)843cdf0e10cSrcweir void UpdateHandler::insertControlModel( uno::Reference< awt::XControlModel > & rxDialogModel,
844cdf0e10cSrcweir rtl::OUString const & rServiceName,
845cdf0e10cSrcweir rtl::OUString const & rControlName,
846cdf0e10cSrcweir awt::Rectangle const & rPosSize,
847cdf0e10cSrcweir uno::Sequence< beans::NamedValue > const & rProps )
848cdf0e10cSrcweir {
849cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xFactory (rxDialogModel, uno::UNO_QUERY_THROW);
850cdf0e10cSrcweir uno::Reference< awt::XControlModel > xModel (xFactory->createInstance (rServiceName), uno::UNO_QUERY_THROW);
851cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPropSet (xModel, uno::UNO_QUERY_THROW);
852cdf0e10cSrcweir
853cdf0e10cSrcweir for (sal_Int32 i = 0, n = rProps.getLength(); i < n; i++)
854cdf0e10cSrcweir {
855cdf0e10cSrcweir xPropSet->setPropertyValue (rProps[i].Name, rProps[i].Value);
856cdf0e10cSrcweir }
857cdf0e10cSrcweir
858cdf0e10cSrcweir // @see awt/UnoControlDialogElement.idl
859cdf0e10cSrcweir xPropSet->setPropertyValue( UNISTRING("Name"), uno::Any (rControlName) );
860cdf0e10cSrcweir xPropSet->setPropertyValue( UNISTRING("PositionX"), uno::Any (rPosSize.X) );
861cdf0e10cSrcweir xPropSet->setPropertyValue( UNISTRING("PositionY"), uno::Any (rPosSize.Y) );
862cdf0e10cSrcweir xPropSet->setPropertyValue( UNISTRING("Height"), uno::Any (rPosSize.Height) );
863cdf0e10cSrcweir xPropSet->setPropertyValue( UNISTRING("Width"), uno::Any (rPosSize.Width) );
864cdf0e10cSrcweir
865cdf0e10cSrcweir // insert by Name into DialogModel container
866cdf0e10cSrcweir uno::Reference< container::XNameContainer > xContainer (rxDialogModel, uno::UNO_QUERY_THROW);
867cdf0e10cSrcweir xContainer->insertByName( rControlName, uno::Any (uno::Reference< uno::XInterface >(xModel, uno::UNO_QUERY)));
868cdf0e10cSrcweir }
869cdf0e10cSrcweir
870cdf0e10cSrcweir //--------------------------------------------------------------------
setFullVersion(rtl::OUString & rString)871cdf0e10cSrcweir void UpdateHandler::setFullVersion( rtl::OUString& rString )
872cdf0e10cSrcweir {
873cdf0e10cSrcweir if( !mxContext.is() )
874cdf0e10cSrcweir throw uno::RuntimeException( UNISTRING( "getProductName: empty component context" ), *this );
875cdf0e10cSrcweir
876cdf0e10cSrcweir uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager() );
877cdf0e10cSrcweir
878cdf0e10cSrcweir if( !xServiceManager.is() )
879cdf0e10cSrcweir throw uno::RuntimeException( UNISTRING( "getProductName: unable to obtain service manager from component context" ), *this );
880cdf0e10cSrcweir
881cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xConfigurationProvider(
882cdf0e10cSrcweir xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.configuration.ConfigurationProvider" ), mxContext ),
883cdf0e10cSrcweir uno::UNO_QUERY_THROW);
884cdf0e10cSrcweir
885cdf0e10cSrcweir beans::PropertyValue aProperty;
886cdf0e10cSrcweir aProperty.Name = UNISTRING( "nodepath" );
887cdf0e10cSrcweir aProperty.Value = uno::makeAny( UNISTRING("org.openoffice.Setup/Product") );
888cdf0e10cSrcweir
889cdf0e10cSrcweir uno::Sequence< uno::Any > aArgumentList( 1 );
890cdf0e10cSrcweir aArgumentList[0] = uno::makeAny( aProperty );
891cdf0e10cSrcweir
892cdf0e10cSrcweir uno::Reference< uno::XInterface > xConfigAccess;
893cdf0e10cSrcweir xConfigAccess = xConfigurationProvider->createInstanceWithArguments( UNISTRING("com.sun.star.configuration.ConfigurationAccess"),
894cdf0e10cSrcweir aArgumentList );
895cdf0e10cSrcweir
896cdf0e10cSrcweir uno::Reference< container::XNameAccess > xNameAccess( xConfigAccess, uno::UNO_QUERY_THROW );
897cdf0e10cSrcweir
898cdf0e10cSrcweir rtl::OUString aProductVersion;
899cdf0e10cSrcweir rtl::OUString aProductFullVersion;
900cdf0e10cSrcweir
901cdf0e10cSrcweir xNameAccess->getByName(UNISTRING("ooSetupVersion")) >>= aProductVersion;
902cdf0e10cSrcweir aProductFullVersion = aProductVersion;
903cdf0e10cSrcweir
904cdf0e10cSrcweir sal_Int32 nVerIndex = rString.indexOf( aProductVersion );
905cdf0e10cSrcweir if ( nVerIndex != -1 )
906cdf0e10cSrcweir {
907cdf0e10cSrcweir rtl::OUString aPackageVersion = UNISTRING( "${$OOO_BASE_DIR/program/" SAL_CONFIGFILE("version") ":OOOPackageVersion}" );
908cdf0e10cSrcweir rtl::Bootstrap::expandMacros( aPackageVersion );
909cdf0e10cSrcweir
910cdf0e10cSrcweir if ( aPackageVersion.getLength() )
911cdf0e10cSrcweir {
912cdf0e10cSrcweir sal_Int32 nTokIndex = 0;
913cdf0e10cSrcweir rtl::OUString aVersionMinor = aPackageVersion.getToken( 1, '.', nTokIndex );
914cdf0e10cSrcweir rtl::OUString aVersionMicro;
915cdf0e10cSrcweir
916cdf0e10cSrcweir if ( nTokIndex > 0 )
917cdf0e10cSrcweir aVersionMicro = aPackageVersion.getToken( 0, '.', nTokIndex );
918cdf0e10cSrcweir
919cdf0e10cSrcweir if ( aVersionMinor.getLength() == 0 )
920cdf0e10cSrcweir aVersionMinor = UNISTRING( "0" );
921cdf0e10cSrcweir if ( aVersionMicro.getLength() == 0 )
922cdf0e10cSrcweir aVersionMicro = UNISTRING( "0" );
923cdf0e10cSrcweir
924cdf0e10cSrcweir sal_Int32 nIndex = aProductFullVersion.indexOf( '.' );
925cdf0e10cSrcweir if ( nIndex == -1 )
926cdf0e10cSrcweir {
927cdf0e10cSrcweir aProductFullVersion += UNISTRING( "." );
928cdf0e10cSrcweir aProductFullVersion += aVersionMinor;
929cdf0e10cSrcweir }
930cdf0e10cSrcweir else
931cdf0e10cSrcweir {
932cdf0e10cSrcweir nIndex = aProductFullVersion.indexOf( '.', nIndex+1 );
933cdf0e10cSrcweir }
934cdf0e10cSrcweir if ( nIndex == -1 )
935cdf0e10cSrcweir {
936cdf0e10cSrcweir aProductFullVersion += UNISTRING( "." );
937cdf0e10cSrcweir aProductFullVersion += aVersionMicro;
938cdf0e10cSrcweir }
939cdf0e10cSrcweir else
940cdf0e10cSrcweir {
941cdf0e10cSrcweir aProductFullVersion = aProductFullVersion.replaceAt( nIndex+1, aProductFullVersion.getLength()-nIndex-1, aVersionMicro );
942cdf0e10cSrcweir }
943cdf0e10cSrcweir }
944cdf0e10cSrcweir rString = rString.replaceAt( nVerIndex, aProductVersion.getLength(), aProductFullVersion );
945cdf0e10cSrcweir }
946cdf0e10cSrcweir }
947cdf0e10cSrcweir
948cdf0e10cSrcweir //--------------------------------------------------------------------
showWarning(const rtl::OUString & rWarningText) const949cdf0e10cSrcweir bool UpdateHandler::showWarning( const rtl::OUString &rWarningText ) const
950cdf0e10cSrcweir {
951cdf0e10cSrcweir bool bRet = false;
952cdf0e10cSrcweir
953*a2db8daaSArrigo Marchiori ::vos::OGuard aGuard( Application::GetSolarMutex() );
954cdf0e10cSrcweir uno::Reference< awt::XControl > xControl( mxUpdDlg, uno::UNO_QUERY );
955cdf0e10cSrcweir if ( !xControl.is() ) return bRet;
956cdf0e10cSrcweir
957cdf0e10cSrcweir uno::Reference< awt::XWindowPeer > xPeer = xControl->getPeer();
958cdf0e10cSrcweir if ( !xPeer.is() ) return bRet;
959cdf0e10cSrcweir
960cdf0e10cSrcweir uno::Reference< awt::XToolkit > xToolkit = xPeer->getToolkit();
961cdf0e10cSrcweir if ( !xToolkit.is() ) return bRet;
962cdf0e10cSrcweir
963cdf0e10cSrcweir awt::WindowDescriptor aDescriptor;
964cdf0e10cSrcweir
965cdf0e10cSrcweir sal_Int32 nWindowAttributes = awt::WindowAttribute::BORDER | awt::WindowAttribute::MOVEABLE | awt::WindowAttribute::CLOSEABLE;
966cdf0e10cSrcweir nWindowAttributes |= awt::VclWindowPeerAttribute::YES_NO;
967cdf0e10cSrcweir nWindowAttributes |= awt::VclWindowPeerAttribute::DEF_NO;
968cdf0e10cSrcweir
969cdf0e10cSrcweir aDescriptor.Type = awt::WindowClass_MODALTOP;
970cdf0e10cSrcweir aDescriptor.WindowServiceName = UNISTRING( "warningbox" );
971cdf0e10cSrcweir aDescriptor.ParentIndex = -1;
972cdf0e10cSrcweir aDescriptor.Parent = xPeer;
973cdf0e10cSrcweir aDescriptor.Bounds = awt::Rectangle( 10, 10, 250, 150 );
974cdf0e10cSrcweir aDescriptor.WindowAttributes = nWindowAttributes;
975cdf0e10cSrcweir
976cdf0e10cSrcweir uno::Reference< awt::XMessageBox > xMsgBox( xToolkit->createWindow( aDescriptor ), uno::UNO_QUERY );
977cdf0e10cSrcweir if ( xMsgBox.is() )
978cdf0e10cSrcweir {
979cdf0e10cSrcweir mbShowsMessageBox = true;
980cdf0e10cSrcweir sal_Int16 nRet;
981cdf0e10cSrcweir // xMsgBox->setCaptionText( msCancelTitle );
982cdf0e10cSrcweir xMsgBox->setMessageText( rWarningText );
983cdf0e10cSrcweir nRet = xMsgBox->execute();
984cdf0e10cSrcweir if ( nRet == 2 ) // RET_YES == 2
985cdf0e10cSrcweir bRet = true;
986cdf0e10cSrcweir mbShowsMessageBox = false;
987cdf0e10cSrcweir }
988cdf0e10cSrcweir
989cdf0e10cSrcweir uno::Reference< lang::XComponent > xComponent( xMsgBox, uno::UNO_QUERY );
990cdf0e10cSrcweir if ( xComponent.is() )
991cdf0e10cSrcweir xComponent->dispose();
992cdf0e10cSrcweir
993cdf0e10cSrcweir return bRet;
994cdf0e10cSrcweir }
995cdf0e10cSrcweir
996cdf0e10cSrcweir //--------------------------------------------------------------------
showWarning(const rtl::OUString & rWarningText,const rtl::OUString & rBtnText_1,const rtl::OUString & rBtnText_2) const997cdf0e10cSrcweir bool UpdateHandler::showWarning( const rtl::OUString &rWarningText,
998cdf0e10cSrcweir const rtl::OUString &rBtnText_1,
999cdf0e10cSrcweir const rtl::OUString &rBtnText_2 ) const
1000cdf0e10cSrcweir {
1001cdf0e10cSrcweir bool bRet = false;
1002cdf0e10cSrcweir
1003*a2db8daaSArrigo Marchiori ::vos::OGuard aGuard( Application::GetSolarMutex() );
1004cdf0e10cSrcweir uno::Reference< awt::XControl > xControl( mxUpdDlg, uno::UNO_QUERY );
1005cdf0e10cSrcweir if ( !xControl.is() ) return bRet;
1006cdf0e10cSrcweir
1007cdf0e10cSrcweir uno::Reference< awt::XWindowPeer > xPeer = xControl->getPeer();
1008cdf0e10cSrcweir if ( !xPeer.is() ) return bRet;
1009cdf0e10cSrcweir
1010cdf0e10cSrcweir uno::Reference< awt::XToolkit > xToolkit = xPeer->getToolkit();
1011cdf0e10cSrcweir if ( !xToolkit.is() ) return bRet;
1012cdf0e10cSrcweir
1013cdf0e10cSrcweir awt::WindowDescriptor aDescriptor;
1014cdf0e10cSrcweir
1015cdf0e10cSrcweir sal_Int32 nWindowAttributes = awt::WindowAttribute::BORDER | awt::WindowAttribute::MOVEABLE | awt::WindowAttribute::CLOSEABLE;
1016cdf0e10cSrcweir nWindowAttributes |= awt::VclWindowPeerAttribute::YES_NO;
1017cdf0e10cSrcweir nWindowAttributes |= awt::VclWindowPeerAttribute::DEF_NO;
1018cdf0e10cSrcweir
1019cdf0e10cSrcweir aDescriptor.Type = awt::WindowClass_MODALTOP;
1020cdf0e10cSrcweir aDescriptor.WindowServiceName = UNISTRING( "warningbox" );
1021cdf0e10cSrcweir aDescriptor.ParentIndex = -1;
1022cdf0e10cSrcweir aDescriptor.Parent = xPeer;
1023cdf0e10cSrcweir aDescriptor.Bounds = awt::Rectangle( 10, 10, 250, 150 );
1024cdf0e10cSrcweir aDescriptor.WindowAttributes = nWindowAttributes;
1025cdf0e10cSrcweir
1026cdf0e10cSrcweir uno::Reference< awt::XMessageBox > xMsgBox( xToolkit->createWindow( aDescriptor ), uno::UNO_QUERY );
1027cdf0e10cSrcweir if ( xMsgBox.is() )
1028cdf0e10cSrcweir {
1029cdf0e10cSrcweir uno::Reference< awt::XVclContainer > xMsgBoxCtrls( xMsgBox, uno::UNO_QUERY );
1030cdf0e10cSrcweir if ( xMsgBoxCtrls.is() )
1031cdf0e10cSrcweir {
1032cdf0e10cSrcweir uno::Sequence< uno::Reference< awt::XWindow > > xChildren = xMsgBoxCtrls->getWindows();
1033cdf0e10cSrcweir
1034cdf0e10cSrcweir for ( long i=0; i < xChildren.getLength(); i++ )
1035cdf0e10cSrcweir {
1036cdf0e10cSrcweir uno::Reference< awt::XVclWindowPeer > xMsgBoxCtrl( xChildren[i], uno::UNO_QUERY );
1037cdf0e10cSrcweir if ( xMsgBoxCtrl.is() )
1038cdf0e10cSrcweir {
1039cdf0e10cSrcweir bool bIsDefault = true;
1040cdf0e10cSrcweir uno::Any aValue = xMsgBoxCtrl->getProperty( UNISTRING("DefaultButton") );
1041cdf0e10cSrcweir aValue >>= bIsDefault;
1042cdf0e10cSrcweir if ( bIsDefault )
1043cdf0e10cSrcweir xMsgBoxCtrl->setProperty( UNISTRING("Text"), uno::Any( rBtnText_1 ) );
1044cdf0e10cSrcweir else
1045cdf0e10cSrcweir xMsgBoxCtrl->setProperty( UNISTRING("Text"), uno::Any( rBtnText_2 ) );
1046cdf0e10cSrcweir }
1047cdf0e10cSrcweir }
1048cdf0e10cSrcweir }
1049cdf0e10cSrcweir
1050cdf0e10cSrcweir sal_Int16 nRet;
1051cdf0e10cSrcweir // xMsgBox->setCaptionText( msCancelTitle );
1052cdf0e10cSrcweir mbShowsMessageBox = true;
1053cdf0e10cSrcweir xMsgBox->setMessageText( rWarningText );
1054cdf0e10cSrcweir nRet = xMsgBox->execute();
1055cdf0e10cSrcweir if ( nRet == 2 ) // RET_YES == 2
1056cdf0e10cSrcweir bRet = true;
1057cdf0e10cSrcweir
1058cdf0e10cSrcweir mbShowsMessageBox = false;
1059cdf0e10cSrcweir }
1060cdf0e10cSrcweir
1061cdf0e10cSrcweir uno::Reference< lang::XComponent > xComponent( xMsgBox, uno::UNO_QUERY );
1062cdf0e10cSrcweir if ( xComponent.is() )
1063cdf0e10cSrcweir xComponent->dispose();
1064cdf0e10cSrcweir
1065cdf0e10cSrcweir return bRet;
1066cdf0e10cSrcweir }
1067cdf0e10cSrcweir
1068cdf0e10cSrcweir //--------------------------------------------------------------------
showOverwriteWarning(const rtl::OUString & rFileName) const1069cdf0e10cSrcweir bool UpdateHandler::showOverwriteWarning( const rtl::OUString& rFileName ) const
1070cdf0e10cSrcweir {
1071cdf0e10cSrcweir rtl::OUString aMsg( msReloadWarning );
1072cdf0e10cSrcweir searchAndReplaceAll( aMsg, UNISTRING( "%FILENAME" ), rFileName );
1073cdf0e10cSrcweir searchAndReplaceAll( aMsg, UNISTRING( "%DOWNLOAD_PATH" ), msDownloadPath );
1074cdf0e10cSrcweir return showWarning( aMsg, msReloadContinue, msReloadReload );
1075cdf0e10cSrcweir }
1076cdf0e10cSrcweir
1077cdf0e10cSrcweir //--------------------------------------------------------------------
showOverwriteWarning() const1078cdf0e10cSrcweir bool UpdateHandler::showOverwriteWarning() const
1079cdf0e10cSrcweir {
1080cdf0e10cSrcweir return showWarning( msOverwriteWarning );
1081cdf0e10cSrcweir }
1082cdf0e10cSrcweir
1083cdf0e10cSrcweir //--------------------------------------------------------------------
1084cdf0e10cSrcweir #define BUTTON_HEIGHT 14
1085cdf0e10cSrcweir #define BUTTON_WIDTH 50
1086cdf0e10cSrcweir #define BUTTON_X_OFFSET 7
1087cdf0e10cSrcweir #define BUTTON_Y_OFFSET 3
1088cdf0e10cSrcweir #define LABEL_HEIGHT 10
1089cdf0e10cSrcweir
1090cdf0e10cSrcweir #define DIALOG_WIDTH 300
1091cdf0e10cSrcweir #define DIALOG_BORDER 5
1092cdf0e10cSrcweir #define INNER_BORDER 3
1093cdf0e10cSrcweir #define TEXT_OFFSET 1
1094cdf0e10cSrcweir #define BOX_HEIGHT1 ( LABEL_HEIGHT + 3*BUTTON_HEIGHT + 2*BUTTON_Y_OFFSET + 2*INNER_BORDER )
1095cdf0e10cSrcweir #define BOX_HEIGHT2 50
1096cdf0e10cSrcweir #define EDIT_WIDTH ( DIALOG_WIDTH - 2 * DIALOG_BORDER )
1097cdf0e10cSrcweir #define BOX1_BTN_X ( DIALOG_BORDER + EDIT_WIDTH - BUTTON_WIDTH - INNER_BORDER )
1098cdf0e10cSrcweir #define BOX1_BTN_Y ( DIALOG_BORDER + LABEL_HEIGHT + INNER_BORDER)
1099cdf0e10cSrcweir #define THROBBER_WIDTH 16
1100cdf0e10cSrcweir #define THROBBER_HEIGHT 16
1101cdf0e10cSrcweir #define THROBBER_X_POS ( DIALOG_BORDER + 8 )
1102cdf0e10cSrcweir #define THROBBER_Y_POS ( DIALOG_BORDER + 23 )
1103cdf0e10cSrcweir #define BUTTON_BAR_HEIGHT 24
1104cdf0e10cSrcweir #define LABEL_OFFSET ( LABEL_HEIGHT + 4 )
1105cdf0e10cSrcweir #define DIALOG_HEIGHT ( BOX_HEIGHT1 + BOX_HEIGHT2 + LABEL_OFFSET + BUTTON_BAR_HEIGHT + 3 * DIALOG_BORDER )
1106cdf0e10cSrcweir #define LABEL_Y_POS ( 2 * DIALOG_BORDER + BOX_HEIGHT1 )
1107cdf0e10cSrcweir #define EDIT2_Y_POS ( LABEL_Y_POS + LABEL_HEIGHT )
1108cdf0e10cSrcweir #define BUTTON_BAR_Y_POS ( EDIT2_Y_POS + DIALOG_BORDER + BOX_HEIGHT2 )
1109cdf0e10cSrcweir #define BUTTON_Y_POS ( BUTTON_BAR_Y_POS + 8 )
1110cdf0e10cSrcweir #define CLOSE_BTN_X ( DIALOG_WIDTH - DIALOG_BORDER - BUTTON_WIDTH )
1111cdf0e10cSrcweir #define INSTALL_BTN_X ( CLOSE_BTN_X - 2 * BUTTON_X_OFFSET - BUTTON_WIDTH )
1112cdf0e10cSrcweir #define DOWNLOAD_BTN_X ( INSTALL_BTN_X - BUTTON_X_OFFSET - BUTTON_WIDTH )
1113cdf0e10cSrcweir #define PROGRESS_WIDTH 80
1114cdf0e10cSrcweir #define PROGRESS_HEIGHT 10
1115cdf0e10cSrcweir #define PROGRESS_X_POS ( DIALOG_BORDER + 8 )
1116cdf0e10cSrcweir #define PROGRESS_Y_POS ( DIALOG_BORDER + 2*LABEL_OFFSET )
1117cdf0e10cSrcweir
1118cdf0e10cSrcweir //--------------------------------------------------------------------
showControls(short nControls)1119cdf0e10cSrcweir void UpdateHandler::showControls( short nControls )
1120cdf0e10cSrcweir {
1121cdf0e10cSrcweir // The buttons from CANCEL_BUTTON to RESUME_BUTTON will be shown or
1122cdf0e10cSrcweir // hidden on demand
1123cdf0e10cSrcweir short nShiftMe;
1124cdf0e10cSrcweir for ( int i = 0; i <= (int)RESUME_BUTTON; i++ )
1125cdf0e10cSrcweir {
1126cdf0e10cSrcweir nShiftMe = (short)(nControls >> i);
1127cdf0e10cSrcweir showControl( msButtonIDs[i], (bool)(nShiftMe & 0x01) );
1128cdf0e10cSrcweir }
1129cdf0e10cSrcweir
1130cdf0e10cSrcweir nShiftMe = (short)(nControls >> THROBBER_CTRL);
1131cdf0e10cSrcweir startThrobber( (bool)(nShiftMe & 0x01) );
1132cdf0e10cSrcweir
1133cdf0e10cSrcweir nShiftMe = (short)(nControls >> PROGRESS_CTRL);
1134cdf0e10cSrcweir showControl( CTRL_PROGRESS, (bool)(nShiftMe & 0x01) );
1135cdf0e10cSrcweir showControl( TEXT_PERCENT, (bool)(nShiftMe & 0x01) );
1136cdf0e10cSrcweir
1137cdf0e10cSrcweir // Status text needs to be smaller, when there are buttons at the right side of the dialog
1138cdf0e10cSrcweir if ( ( nControls & ( (1<<CANCEL_BUTTON) + (1<<PAUSE_BUTTON) + (1<<RESUME_BUTTON) ) ) != 0 )
1139cdf0e10cSrcweir setControlProperty( TEXT_STATUS, UNISTRING("Width"), uno::Any( sal_Int32(EDIT_WIDTH - BUTTON_WIDTH - 2*INNER_BORDER - TEXT_OFFSET ) ) );
1140cdf0e10cSrcweir else
1141cdf0e10cSrcweir setControlProperty( TEXT_STATUS, UNISTRING("Width"), uno::Any( sal_Int32(EDIT_WIDTH - 2*TEXT_OFFSET ) ) );
1142cdf0e10cSrcweir
1143cdf0e10cSrcweir // Status text needs to be taller, when we show the progress bar
1144cdf0e10cSrcweir if ( ( nControls & ( 1<<PROGRESS_CTRL ) ) != 0 )
1145cdf0e10cSrcweir setControlProperty( TEXT_STATUS, UNISTRING("Height"), uno::Any( sal_Int32(LABEL_HEIGHT) ) );
1146cdf0e10cSrcweir else
1147cdf0e10cSrcweir setControlProperty( TEXT_STATUS, UNISTRING("Height"), uno::Any( sal_Int32(BOX_HEIGHT1 - 4*TEXT_OFFSET - LABEL_HEIGHT ) ) );
1148cdf0e10cSrcweir }
1149cdf0e10cSrcweir
1150cdf0e10cSrcweir //--------------------------------------------------------------------
createDialog()1151cdf0e10cSrcweir void UpdateHandler::createDialog()
1152cdf0e10cSrcweir {
1153cdf0e10cSrcweir if ( !mxContext.is() )
1154cdf0e10cSrcweir {
1155cdf0e10cSrcweir OSL_ASSERT( false );
1156cdf0e10cSrcweir return;
1157cdf0e10cSrcweir }
1158cdf0e10cSrcweir
1159cdf0e10cSrcweir uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager() );
1160cdf0e10cSrcweir
1161cdf0e10cSrcweir if( xServiceManager.is() )
1162cdf0e10cSrcweir {
1163cdf0e10cSrcweir uno::Reference< frame::XDesktop > xDesktop(
1164cdf0e10cSrcweir xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.frame.Desktop"), mxContext ),
1165cdf0e10cSrcweir uno::UNO_QUERY );
1166cdf0e10cSrcweir if ( xDesktop.is() )
1167cdf0e10cSrcweir xDesktop->addTerminateListener( this );
1168cdf0e10cSrcweir }
1169cdf0e10cSrcweir
1170cdf0e10cSrcweir loadStrings();
1171cdf0e10cSrcweir
1172*a2db8daaSArrigo Marchiori ::vos::OGuard aGuard( Application::GetSolarMutex() );
1173cdf0e10cSrcweir uno::Reference< lang::XMultiComponentFactory > xFactory( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
1174cdf0e10cSrcweir uno::Reference< awt::XControlModel > xControlModel( xFactory->createInstanceWithContext(
1175cdf0e10cSrcweir UNISTRING("com.sun.star.awt.UnoControlDialogModel"),
1176cdf0e10cSrcweir mxContext), uno::UNO_QUERY_THROW );
1177cdf0e10cSrcweir {
1178cdf0e10cSrcweir // @see awt/UnoControlDialogModel.idl
1179cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY_THROW );
1180cdf0e10cSrcweir
1181cdf0e10cSrcweir xPropSet->setPropertyValue( UNISTRING("Title"), uno::Any( msDlgTitle ) );
1182cdf0e10cSrcweir xPropSet->setPropertyValue( UNISTRING("Closeable"), uno::Any( true ) );
1183cdf0e10cSrcweir xPropSet->setPropertyValue( UNISTRING("Enabled"), uno::Any( true ) );
1184cdf0e10cSrcweir xPropSet->setPropertyValue( UNISTRING("Moveable"), uno::Any( true ) );
1185cdf0e10cSrcweir xPropSet->setPropertyValue( UNISTRING("Sizeable"), uno::Any( true ) );
1186cdf0e10cSrcweir xPropSet->setPropertyValue( UNISTRING("DesktopAsParent"), uno::Any( true ) );
1187cdf0e10cSrcweir xPropSet->setPropertyValue( UNISTRING("PositionX"), uno::Any(sal_Int32( 100 )) );
1188cdf0e10cSrcweir xPropSet->setPropertyValue( UNISTRING("PositionY"), uno::Any(sal_Int32( 100 )) );
1189cdf0e10cSrcweir xPropSet->setPropertyValue( UNISTRING("Width"), uno::Any(sal_Int32( DIALOG_WIDTH )) );
1190cdf0e10cSrcweir xPropSet->setPropertyValue( UNISTRING("Height"), uno::Any(sal_Int32( DIALOG_HEIGHT )) );
1191cdf0e10cSrcweir xPropSet->setPropertyValue( UNISTRING("HelpURL"), uno::Any( UNISTRING( INET_HID_SCHEME ) + rtl::OUString::createFromAscii( HID_CHECK_FOR_UPD_DLG ) ) );
1192cdf0e10cSrcweir }
1193cdf0e10cSrcweir { // Label (fixed text) <status>
1194cdf0e10cSrcweir uno::Sequence< beans::NamedValue > aProps(1);
1195cdf0e10cSrcweir
1196cdf0e10cSrcweir setProperty( aProps, 0, UNISTRING("Label"), uno::Any( msStatusFL ) );
1197cdf0e10cSrcweir
1198cdf0e10cSrcweir insertControlModel( xControlModel, FIXED_TEXT_MODEL, UNISTRING( "fixedLineStatus" ),
1199cdf0e10cSrcweir awt::Rectangle( DIALOG_BORDER+1, DIALOG_BORDER, EDIT_WIDTH-2, LABEL_HEIGHT ),
1200cdf0e10cSrcweir aProps );
1201cdf0e10cSrcweir }
1202cdf0e10cSrcweir { // box around <status> text
1203cdf0e10cSrcweir uno::Sequence< beans::NamedValue > aProps;
1204cdf0e10cSrcweir
1205cdf0e10cSrcweir insertControlModel( xControlModel, GROUP_BOX_MODEL, UNISTRING( "StatusBox" ),
1206cdf0e10cSrcweir awt::Rectangle( DIALOG_BORDER, DIALOG_BORDER + LABEL_HEIGHT, EDIT_WIDTH, BOX_HEIGHT1 - LABEL_HEIGHT ),
1207cdf0e10cSrcweir aProps );
1208cdf0e10cSrcweir }
1209cdf0e10cSrcweir { // Text (multiline edit) <status>
1210cdf0e10cSrcweir uno::Sequence< beans::NamedValue > aProps(7);
1211cdf0e10cSrcweir
1212cdf0e10cSrcweir setProperty( aProps, 0, UNISTRING("Text"), uno::Any( substVariables(msChecking) ) );
1213cdf0e10cSrcweir setProperty( aProps, 1, UNISTRING("Border"), uno::Any( sal_Int16( 0 ) ) );
1214cdf0e10cSrcweir setProperty( aProps, 2, UNISTRING("PaintTransparent"), uno::Any( true ) );
1215cdf0e10cSrcweir setProperty( aProps, 3, UNISTRING("MultiLine"), uno::Any( true ) );
1216cdf0e10cSrcweir setProperty( aProps, 4, UNISTRING("ReadOnly"), uno::Any( true ) );
1217cdf0e10cSrcweir setProperty( aProps, 5, UNISTRING("AutoVScroll"), uno::Any( true ) );
1218cdf0e10cSrcweir setProperty( aProps, 6, UNISTRING("HelpURL"), uno::Any( UNISTRING( INET_HID_SCHEME ) + rtl::OUString::createFromAscii( HID_CHECK_FOR_UPD_STATUS ) ) );
1219cdf0e10cSrcweir
1220cdf0e10cSrcweir insertControlModel( xControlModel, EDIT_FIELD_MODEL, TEXT_STATUS,
1221cdf0e10cSrcweir awt::Rectangle( DIALOG_BORDER + TEXT_OFFSET,
1222cdf0e10cSrcweir DIALOG_BORDER + LABEL_HEIGHT + TEXT_OFFSET,
1223cdf0e10cSrcweir EDIT_WIDTH - 2*TEXT_OFFSET,
1224cdf0e10cSrcweir BOX_HEIGHT1 - 4*TEXT_OFFSET - LABEL_HEIGHT ),
1225cdf0e10cSrcweir aProps );
1226cdf0e10cSrcweir }
1227cdf0e10cSrcweir { // Text (edit) <percent>
1228cdf0e10cSrcweir uno::Sequence< beans::NamedValue > aProps(4);
1229cdf0e10cSrcweir
1230cdf0e10cSrcweir setProperty( aProps, 0, UNISTRING("Text"), uno::Any( msPercent ) );
1231cdf0e10cSrcweir setProperty( aProps, 1, UNISTRING("Border"), uno::Any( sal_Int16( 0 ) ) );
1232cdf0e10cSrcweir setProperty( aProps, 2, UNISTRING("PaintTransparent"), uno::Any( true ) );
1233cdf0e10cSrcweir setProperty( aProps, 3, UNISTRING("ReadOnly"), uno::Any( true ) );
1234cdf0e10cSrcweir
1235cdf0e10cSrcweir insertControlModel( xControlModel, EDIT_FIELD_MODEL, TEXT_PERCENT,
1236cdf0e10cSrcweir awt::Rectangle( PROGRESS_X_POS + PROGRESS_WIDTH + DIALOG_BORDER,
1237cdf0e10cSrcweir PROGRESS_Y_POS,
1238cdf0e10cSrcweir EDIT_WIDTH - PROGRESS_WIDTH - BUTTON_WIDTH - 2*DIALOG_BORDER,
1239cdf0e10cSrcweir LABEL_HEIGHT ),
1240cdf0e10cSrcweir aProps );
1241cdf0e10cSrcweir }
1242cdf0e10cSrcweir { // pause button
1243cdf0e10cSrcweir uno::Sequence< beans::NamedValue > aProps(5);
1244cdf0e10cSrcweir
1245cdf0e10cSrcweir setProperty( aProps, 0, UNISTRING("DefaultButton"), uno::Any( false ) );
1246cdf0e10cSrcweir setProperty( aProps, 1, UNISTRING("Enabled"), uno::Any( true ) );
1247cdf0e10cSrcweir setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD) ) );
1248cdf0e10cSrcweir setProperty( aProps, 3, UNISTRING("Label"), uno::Any( msPauseBtn ) );
1249cdf0e10cSrcweir setProperty( aProps, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( INET_HID_SCHEME ) + rtl::OUString::createFromAscii( HID_CHECK_FOR_UPD_PAUSE ) ) );
1250cdf0e10cSrcweir
1251cdf0e10cSrcweir insertControlModel ( xControlModel, BUTTON_MODEL, msButtonIDs[PAUSE_BUTTON],
1252cdf0e10cSrcweir awt::Rectangle( BOX1_BTN_X, BOX1_BTN_Y, BUTTON_WIDTH, BUTTON_HEIGHT ),
1253cdf0e10cSrcweir aProps );
1254cdf0e10cSrcweir }
1255cdf0e10cSrcweir { // resume button
1256cdf0e10cSrcweir uno::Sequence< beans::NamedValue > aProps(5);
1257cdf0e10cSrcweir
1258cdf0e10cSrcweir setProperty( aProps, 0, UNISTRING("DefaultButton"), uno::Any( false ) );
1259cdf0e10cSrcweir setProperty( aProps, 1, UNISTRING("Enabled"), uno::Any( true ) );
1260cdf0e10cSrcweir setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD) ) );
1261cdf0e10cSrcweir setProperty( aProps, 3, UNISTRING("Label"), uno::Any( msResumeBtn ) );
1262cdf0e10cSrcweir setProperty( aProps, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( INET_HID_SCHEME ) + rtl::OUString::createFromAscii( HID_CHECK_FOR_UPD_RESUME ) ) );
1263cdf0e10cSrcweir
1264cdf0e10cSrcweir insertControlModel ( xControlModel, BUTTON_MODEL, msButtonIDs[RESUME_BUTTON],
1265cdf0e10cSrcweir awt::Rectangle( BOX1_BTN_X,
1266cdf0e10cSrcweir BOX1_BTN_Y + BUTTON_Y_OFFSET + BUTTON_HEIGHT,
1267cdf0e10cSrcweir BUTTON_WIDTH,
1268cdf0e10cSrcweir BUTTON_HEIGHT ),
1269cdf0e10cSrcweir aProps );
1270cdf0e10cSrcweir }
1271cdf0e10cSrcweir { // abort button
1272cdf0e10cSrcweir uno::Sequence< beans::NamedValue > aProps(5);
1273cdf0e10cSrcweir
1274cdf0e10cSrcweir setProperty( aProps, 0, UNISTRING("DefaultButton"), uno::Any( false ) );
1275cdf0e10cSrcweir setProperty( aProps, 1, UNISTRING("Enabled"), uno::Any( true ) );
1276cdf0e10cSrcweir setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD) ) );
1277cdf0e10cSrcweir setProperty( aProps, 3, UNISTRING("Label"), uno::Any( msCancelBtn ) );
1278cdf0e10cSrcweir setProperty( aProps, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( INET_HID_SCHEME ) + rtl::OUString::createFromAscii( HID_CHECK_FOR_UPD_CANCEL ) ) );
1279cdf0e10cSrcweir
1280cdf0e10cSrcweir insertControlModel ( xControlModel, BUTTON_MODEL, msButtonIDs[CANCEL_BUTTON],
1281cdf0e10cSrcweir awt::Rectangle( BOX1_BTN_X,
1282cdf0e10cSrcweir BOX1_BTN_Y + (2*(BUTTON_HEIGHT+BUTTON_Y_OFFSET)),
1283cdf0e10cSrcweir BUTTON_WIDTH,
1284cdf0e10cSrcweir BUTTON_HEIGHT ),
1285cdf0e10cSrcweir aProps );
1286cdf0e10cSrcweir }
1287cdf0e10cSrcweir { // Label (FixedText) <description>
1288cdf0e10cSrcweir uno::Sequence< beans::NamedValue > aProps(1);
1289cdf0e10cSrcweir
1290cdf0e10cSrcweir setProperty( aProps, 0, UNISTRING("Label"), uno::Any( msDescription ) );
1291cdf0e10cSrcweir
1292cdf0e10cSrcweir insertControlModel( xControlModel, FIXED_TEXT_MODEL, UNISTRING( "fixedTextDescription" ),
1293cdf0e10cSrcweir awt::Rectangle( DIALOG_BORDER+1, LABEL_Y_POS, EDIT_WIDTH-2, LABEL_HEIGHT ),
1294cdf0e10cSrcweir aProps );
1295cdf0e10cSrcweir }
1296cdf0e10cSrcweir { // box around <description> text
1297cdf0e10cSrcweir uno::Sequence< beans::NamedValue > aProps;
1298cdf0e10cSrcweir
1299cdf0e10cSrcweir insertControlModel( xControlModel, GROUP_BOX_MODEL, UNISTRING( "DescriptionBox" ),
1300cdf0e10cSrcweir awt::Rectangle( DIALOG_BORDER, EDIT2_Y_POS, EDIT_WIDTH, BOX_HEIGHT2 ),
1301cdf0e10cSrcweir aProps );
1302cdf0e10cSrcweir }
1303cdf0e10cSrcweir { // Text (MultiLineEdit) <description>
1304cdf0e10cSrcweir uno::Sequence< beans::NamedValue > aProps(7);
1305cdf0e10cSrcweir
1306cdf0e10cSrcweir setProperty( aProps, 0, UNISTRING("Text"), uno::Any( rtl::OUString() ) );
1307cdf0e10cSrcweir setProperty( aProps, 1, UNISTRING("Border"), uno::Any( sal_Int16( 0 ) ) );
1308cdf0e10cSrcweir setProperty( aProps, 2, UNISTRING("PaintTransparent"), uno::Any( true ) );
1309cdf0e10cSrcweir setProperty( aProps, 3, UNISTRING("MultiLine"), uno::Any( true ) );
1310cdf0e10cSrcweir setProperty( aProps, 4, UNISTRING("ReadOnly"), uno::Any( true ) );
1311cdf0e10cSrcweir setProperty( aProps, 5, UNISTRING("AutoVScroll"), uno::Any( true ) );
1312cdf0e10cSrcweir setProperty( aProps, 6, UNISTRING("HelpURL"), uno::Any( UNISTRING( INET_HID_SCHEME ) + rtl::OUString::createFromAscii( HID_CHECK_FOR_UPD_DESCRIPTION ) ) );
1313cdf0e10cSrcweir
1314cdf0e10cSrcweir insertControlModel( xControlModel, EDIT_FIELD_MODEL, TEXT_DESCRIPTION,
1315cdf0e10cSrcweir awt::Rectangle( DIALOG_BORDER + TEXT_OFFSET,
1316cdf0e10cSrcweir EDIT2_Y_POS + 2*TEXT_OFFSET,
1317cdf0e10cSrcweir EDIT_WIDTH - 3*TEXT_OFFSET,
1318cdf0e10cSrcweir BOX_HEIGHT2 - 3*TEXT_OFFSET ),
1319cdf0e10cSrcweir aProps );
1320cdf0e10cSrcweir }
1321cdf0e10cSrcweir { // @see awt/UnoControlFixedLineModel.idl
1322cdf0e10cSrcweir uno::Sequence< beans::NamedValue > aProps(1);
1323cdf0e10cSrcweir
1324cdf0e10cSrcweir setProperty( aProps, 0, UNISTRING("Orientation"), uno::Any( sal_Int32( 0 ) ) );
1325cdf0e10cSrcweir
1326cdf0e10cSrcweir insertControlModel( xControlModel, FIXED_LINE_MODEL, UNISTRING("fixedLine"),
1327cdf0e10cSrcweir awt::Rectangle( 0, BUTTON_BAR_Y_POS, DIALOG_WIDTH, 5 ),
1328cdf0e10cSrcweir aProps );
1329cdf0e10cSrcweir }
1330cdf0e10cSrcweir { // close button // @see awt/UnoControlButtonModel.idl
1331cdf0e10cSrcweir uno::Sequence< beans::NamedValue > aProps(5);
1332cdf0e10cSrcweir
1333cdf0e10cSrcweir setProperty( aProps, 0, UNISTRING("DefaultButton"), uno::Any( false ) );
1334cdf0e10cSrcweir setProperty( aProps, 1, UNISTRING("Enabled"), uno::Any( true ) );
1335cdf0e10cSrcweir // [property] short PushButtonType
1336cdf0e10cSrcweir // with own "ButtonActionListener"
1337cdf0e10cSrcweir setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD) ) );
1338cdf0e10cSrcweir // with default ActionListener => endDialog().
1339cdf0e10cSrcweir // setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_CANCEL) ) );
1340cdf0e10cSrcweir // [property] string Label // only if PushButtonType_STANDARD
1341cdf0e10cSrcweir setProperty( aProps, 3, UNISTRING("Label"), uno::Any( msClose ) );
1342cdf0e10cSrcweir setProperty( aProps, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( INET_HID_SCHEME ) + rtl::OUString::createFromAscii( HID_CHECK_FOR_UPD_CLOSE ) ) );
1343cdf0e10cSrcweir
1344cdf0e10cSrcweir insertControlModel ( xControlModel, BUTTON_MODEL, msButtonIDs[ CLOSE_BUTTON ],
1345cdf0e10cSrcweir awt::Rectangle( CLOSE_BTN_X, BUTTON_Y_POS, BUTTON_WIDTH, BUTTON_HEIGHT ),
1346cdf0e10cSrcweir aProps );
1347cdf0e10cSrcweir }
1348cdf0e10cSrcweir { // install button
1349cdf0e10cSrcweir uno::Sequence< beans::NamedValue > aProps(5);
1350cdf0e10cSrcweir
1351cdf0e10cSrcweir setProperty( aProps, 0, UNISTRING("DefaultButton"), uno::Any( false ) );
1352cdf0e10cSrcweir setProperty( aProps, 1, UNISTRING("Enabled"), uno::Any( true ) );
1353cdf0e10cSrcweir setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD) ) );
1354cdf0e10cSrcweir setProperty( aProps, 3, UNISTRING("Label"), uno::Any( msInstall ) );
1355cdf0e10cSrcweir setProperty( aProps, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( INET_HID_SCHEME ) + rtl::OUString::createFromAscii( HID_CHECK_FOR_UPD_INSTALL ) ) );
1356cdf0e10cSrcweir
1357cdf0e10cSrcweir insertControlModel ( xControlModel, BUTTON_MODEL, msButtonIDs[INSTALL_BUTTON],
1358cdf0e10cSrcweir awt::Rectangle( INSTALL_BTN_X, BUTTON_Y_POS, BUTTON_WIDTH, BUTTON_HEIGHT ),
1359cdf0e10cSrcweir aProps );
1360cdf0e10cSrcweir }
1361cdf0e10cSrcweir { // download button
1362cdf0e10cSrcweir uno::Sequence< beans::NamedValue > aProps(5);
1363cdf0e10cSrcweir
1364cdf0e10cSrcweir setProperty( aProps, 0, UNISTRING("DefaultButton"), uno::Any( false ) );
1365cdf0e10cSrcweir setProperty( aProps, 1, UNISTRING("Enabled"), uno::Any( true ) );
1366cdf0e10cSrcweir setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD) ) );
1367cdf0e10cSrcweir setProperty( aProps, 3, UNISTRING("Label"), uno::Any( msDownload ) );
1368cdf0e10cSrcweir setProperty( aProps, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( INET_HID_SCHEME ) + rtl::OUString::createFromAscii( HID_CHECK_FOR_UPD_DOWNLOAD ) ) );
1369cdf0e10cSrcweir
1370cdf0e10cSrcweir insertControlModel ( xControlModel, BUTTON_MODEL, msButtonIDs[DOWNLOAD_BUTTON],
1371cdf0e10cSrcweir awt::Rectangle( DOWNLOAD_BTN_X, BUTTON_Y_POS, BUTTON_WIDTH, BUTTON_HEIGHT ),
1372cdf0e10cSrcweir aProps );
1373cdf0e10cSrcweir }
1374cdf0e10cSrcweir { // help button
1375cdf0e10cSrcweir uno::Sequence< beans::NamedValue > aProps(3);
1376cdf0e10cSrcweir
1377cdf0e10cSrcweir setProperty( aProps, 0, UNISTRING("DefaultButton"), uno::Any( false ) );
1378cdf0e10cSrcweir setProperty( aProps, 1, UNISTRING("Enabled"), uno::Any( true ) );
1379cdf0e10cSrcweir setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_HELP) ) );
1380cdf0e10cSrcweir
1381cdf0e10cSrcweir insertControlModel( xControlModel, BUTTON_MODEL, msButtonIDs[HELP_BUTTON],
1382cdf0e10cSrcweir awt::Rectangle( DIALOG_BORDER, BUTTON_Y_POS, BUTTON_WIDTH, BUTTON_HEIGHT ),
1383cdf0e10cSrcweir aProps );
1384cdf0e10cSrcweir }
1385cdf0e10cSrcweir { // @see awt/UnoControlThrobberModel.idl
1386cdf0e10cSrcweir uno::Sequence< beans::NamedValue > aProps;
1387cdf0e10cSrcweir
1388cdf0e10cSrcweir insertControlModel( xControlModel, UNISTRING("com.sun.star.awt.SpinningProgressControlModel"), CTRL_THROBBER,
1389cdf0e10cSrcweir awt::Rectangle( THROBBER_X_POS, THROBBER_Y_POS, THROBBER_WIDTH, THROBBER_HEIGHT),
1390cdf0e10cSrcweir aProps );
1391cdf0e10cSrcweir }
1392cdf0e10cSrcweir { // @see awt/UnoControlProgressBarModel.idl
1393cdf0e10cSrcweir uno::Sequence< beans::NamedValue > aProps(4);
1394cdf0e10cSrcweir setProperty( aProps, 0, UNISTRING("Enabled"), uno::Any( true ) );
1395cdf0e10cSrcweir setProperty( aProps, 1, UNISTRING("ProgressValue"), uno::Any( sal_Int32( 0 ) ) );
1396cdf0e10cSrcweir setProperty( aProps, 2, UNISTRING("ProgressValueMax"), uno::Any( sal_Int32( 100 ) ) );
1397cdf0e10cSrcweir setProperty( aProps, 3, UNISTRING("ProgressValueMin"), uno::Any( sal_Int32( 0 ) ) );
1398cdf0e10cSrcweir
1399cdf0e10cSrcweir insertControlModel( xControlModel, UNISTRING("com.sun.star.awt.UnoControlProgressBarModel"), CTRL_PROGRESS,
1400cdf0e10cSrcweir awt::Rectangle( PROGRESS_X_POS, PROGRESS_Y_POS, PROGRESS_WIDTH, PROGRESS_HEIGHT ),
1401cdf0e10cSrcweir aProps);
1402cdf0e10cSrcweir }
1403cdf0e10cSrcweir
1404cdf0e10cSrcweir uno::Reference< awt::XControl > xControl(
1405cdf0e10cSrcweir xFactory->createInstanceWithContext( UNISTRING("com.sun.star.awt.UnoControlDialog"), mxContext),
1406cdf0e10cSrcweir uno::UNO_QUERY_THROW );
1407cdf0e10cSrcweir xControl->setModel( xControlModel );
1408cdf0e10cSrcweir
1409cdf0e10cSrcweir if ( mbVisible == false )
1410cdf0e10cSrcweir {
1411cdf0e10cSrcweir uno::Reference< awt::XWindow > xWindow( xControl, uno::UNO_QUERY );
1412cdf0e10cSrcweir
1413cdf0e10cSrcweir if ( xWindow.is() )
1414cdf0e10cSrcweir xWindow->setVisible( false );
1415cdf0e10cSrcweir }
1416cdf0e10cSrcweir
1417cdf0e10cSrcweir xControl->createPeer( NULL, NULL );
1418cdf0e10cSrcweir {
1419cdf0e10cSrcweir uno::Reference< awt::XControlContainer > xContainer (xControl, uno::UNO_QUERY);
1420cdf0e10cSrcweir for ( int i = 0; i < HELP_BUTTON; i++ )
1421cdf0e10cSrcweir {
1422cdf0e10cSrcweir uno::Reference< awt::XButton > xButton ( xContainer->getControl( msButtonIDs[i] ), uno::UNO_QUERY);
1423cdf0e10cSrcweir if (xButton.is())
1424cdf0e10cSrcweir {
1425cdf0e10cSrcweir xButton->setActionCommand( msButtonIDs[i] );
1426cdf0e10cSrcweir xButton->addActionListener( this );
1427cdf0e10cSrcweir }
1428cdf0e10cSrcweir }
1429cdf0e10cSrcweir }
1430cdf0e10cSrcweir
1431cdf0e10cSrcweir mxUpdDlg.set( xControl, uno::UNO_QUERY_THROW );
1432cdf0e10cSrcweir mnLastCtrlState = -1;
1433cdf0e10cSrcweir }
1434