1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: updatehdl.hxx,v $
10 * $Revision: 1.5.94.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef INCLUDED_UPDATE_HDL_HXX
32 #define INCLUDED_UPDATE_HDL_HXX
34 #include "boost/utility.hpp"
35 #include <osl/mutex.hxx>
36 #include "com/sun/star/uno/Any.h"
37 #ifndef _COM_SUN_STAR_UNO_REFERENCE_HPP_
38 #include "com/sun/star/uno/Reference.h"
40 #include "com/sun/star/uno/XComponentContext.hpp"
41 #include "com/sun/star/awt/Rectangle.hpp"
42 #include "com/sun/star/awt/XActionListener.hpp"
43 #include "com/sun/star/awt/XControlModel.hpp"
44 #include "com/sun/star/awt/XDialog.hpp"
45 #include "com/sun/star/awt/XTopWindowListener.hpp"
46 #include "com/sun/star/beans/NamedValue.hpp"
47 #include "com/sun/star/frame/XTerminateListener.hpp"
48 #include <com/sun/star/resource/XResourceBundle.hpp>
49 #include <com/sun/star/task/XInteractionHandler.hpp>
50 #include "cppuhelper/implbase4.hxx"
52 #include "actionlistener.hxx"
69 UPDATESTATE_CHECKING
= 0,
70 UPDATESTATE_ERROR_CHECKING
,
71 UPDATESTATE_NO_UPDATE_AVAIL
,
72 UPDATESTATE_UPDATE_AVAIL
,
73 UPDATESTATE_UPDATE_NO_DOWNLOAD
,
74 UPDATESTATE_AUTO_START
,
75 UPDATESTATE_DOWNLOADING
,
76 UPDATESTATE_DOWNLOAD_PAUSED
,
77 UPDATESTATE_ERROR_DOWNLOADING
,
78 UPDATESTATE_DOWNLOAD_AVAIL
,
79 UPDATESTATE_EXT_UPD_AVAIL
,
83 class UpdateHandler
: ::boost::noncopyable
,
84 public cppu::WeakImplHelper4
< com::sun::star::awt::XActionListener
,
85 com::sun::star::awt::XTopWindowListener
,
86 com::sun::star::task::XInteractionHandler
,
87 com::sun::star::frame::XTerminateListener
>
90 com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
> mxContext
;
91 com::sun::star::uno::Reference
< com::sun::star::awt::XDialog
> mxUpdDlg
;
92 com::sun::star::uno::Reference
< com::sun::star::task::XInteractionHandler
> mxInteractionHdl
;
93 rtl::Reference
< IActionListener
> mxActionListener
;
95 UpdateState meCurState
;
96 UpdateState meLastState
;
98 short mnLastCtrlState
;
99 bool mbDownloadBtnHasDots
;
101 bool mbStringsLoaded
;
103 bool mbListenerAdded
;
107 rtl::OUString msNextVersion
;
108 rtl::OUString msDownloadPath
;
109 rtl::OUString msDownloadFile
;
110 rtl::OUString msDescriptionMsg
;
111 rtl::OUString msChecking
; // RID_UPDATE_STR_CHECKING
112 rtl::OUString msCheckingError
; // RID_UPDATE_STR_CHECKING_ERR
113 rtl::OUString msNoUpdFound
; // RID_UPDATE_STR_NO_UPD_FOUND
114 rtl::OUString msUpdFound
; // RID_UPDATE_STR_UPD_FOUND
115 rtl::OUString msDlgTitle
; // RID_UPDATE_STR_DLG_TITLE
116 rtl::OUString msDownloadPause
; // RID_UPDATE_STR_DOWNLOAD_PAUSE
117 rtl::OUString msDownloadError
; // RID_UPDATE_STR_DOWNLOAD_ERR
118 rtl::OUString msDownloadWarning
; // RID_UPDATE_STR_DOWNLOAD_WARN
119 rtl::OUString msDownloadDescr
; // RID_UPDATE_STR_DOWNLOAD_WARN
120 rtl::OUString msDownloadNotAvail
; // RID_UPDATE_STR_DOWNLOAD_UNAVAIL
121 rtl::OUString msDownloading
; // RID_UPDATE_STR_DOWNLOADING
122 rtl::OUString msReady2Install
; // RID_UPDATE_STR_READY_INSTALL
123 rtl::OUString msCancelTitle
; // RID_UPDATE_STR_CANCEL_TITLE
124 rtl::OUString msCancelMessage
; // RID_UPDATE_STR_CANCEL_DOWNLOAD
125 rtl::OUString msInstallMessage
; // RID_UPDATE_STR_BEGIN_INSTALL
126 rtl::OUString msInstallNow
; // RID_UPDATE_STR_INSTALL_NOW
127 rtl::OUString msInstallLater
; // RID_UPDATE_STR_INSTALL_LATER
128 rtl::OUString msInstallError
; // RID_UPDATE_STR_INSTALL_ERROR
129 rtl::OUString msOverwriteWarning
; // RID_UPDATE_STR_OVERWRITE_WARNING
130 rtl::OUString msPercent
; // RID_UPDATE_STR_PERCENT
131 rtl::OUString msStatusFL
; // RID_UPDATE_FT_STATUS
132 rtl::OUString msDescription
; // RID_UPDATE_FT_DESCRIPTION
133 rtl::OUString msClose
; // RID_UPDATE_BTN_CLOSE
134 rtl::OUString msDownload
; // RID_UPDATE_BTN_DOWNLOAD
135 rtl::OUString msInstall
; // RID_UPDATE_BTN_INSTALL
136 rtl::OUString msPauseBtn
; // RID_UPDATE_BTN_PAUSE
137 rtl::OUString msResumeBtn
; // RID_UPDATE_BTN_RESUME
138 rtl::OUString msCancelBtn
; // RID_UPDATE_BTN_CANCEL
139 rtl::OUString msButtonIDs
[ BUTTON_COUNT
];
140 rtl::OUString msBubbleTexts
[ UPDATESTATES_COUNT
];
141 rtl::OUString msBubbleTitles
[ UPDATESTATES_COUNT
];
144 void updateState( UpdateState eNewState
);
145 void startThrobber( bool bStart
= true );
146 void setControlProperty( const rtl::OUString
&rCtrlName
,
147 const rtl::OUString
&rPropName
,
148 const com::sun::star::uno::Any
&rPropValue
);
149 void showControl( const rtl::OUString
&rCtrlName
, bool bShow
= true );
150 void showControls( short nControls
);
151 void focusControl( DialogControls eID
);
152 void enableControls( short nCtrlState
);
153 void setDownloadBtnLabel( bool bAppendDots
);
155 rtl::OUString
loadString( const com::sun::star::uno::Reference
< com::sun::star::resource::XResourceBundle
> xBundle
,
156 sal_Int32 nResourceId
) const;
157 rtl::OUString
substVariables( const rtl::OUString
&rSource
) const;
158 static void setProperty( com::sun::star::uno::Sequence
< com::sun::star::beans::NamedValue
> &rProps
,
159 const int nIndex
, const rtl::OUString
&rPropName
, const com::sun::star::uno::Any
&rPropValue
)
160 { rProps
[ nIndex
].Name
= rPropName
; rProps
[ nIndex
].Value
= rPropValue
; }
161 static void insertControlModel( com::sun::star::uno::Reference
< com::sun::star::awt::XControlModel
> & rxDialogModel
,
162 rtl::OUString
const & rServiceName
,
163 rtl::OUString
const & rControlName
,
164 com::sun::star::awt::Rectangle
const & rPosSize
,
165 com::sun::star::uno::Sequence
< com::sun::star::beans::NamedValue
> const & rProps
);
167 void setFullVersion( rtl::OUString
& rString
);
168 void searchAndReplaceAll( rtl::OUString
&rText
, const rtl::OUString
&rWhat
, const rtl::OUString
&rWith
) const;
171 UpdateHandler( const com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
> & rxContext
,
172 const rtl::Reference
< IActionListener
> & rxActionListener
);
173 virtual ~UpdateHandler();
175 bool isVisible() const;
176 bool isMinimized() const { return mbMinimized
; }
177 void setVisible( bool bVisible
= true );
178 void setProgress( sal_Int32 nPercent
);
179 void setNextVersion( const rtl::OUString
&rNextVersion
) { msNextVersion
= rNextVersion
; }
180 void setDownloadPath( const rtl::OUString
&rPath
) { msDownloadPath
= rPath
; }
181 void setDownloadFile( const rtl::OUString
&rPath
);
182 void setErrorMessage( const rtl::OUString
&rErrorMsg
);
183 void setDescription( const rtl::OUString
&rDescription
){ msDescriptionMsg
= rDescription
; }
185 void setState( UpdateState eState
);
186 rtl::OUString
getBubbleText( UpdateState eState
);
187 rtl::OUString
getBubbleTitle( UpdateState eState
);
188 rtl::OUString
getDefaultInstErrMsg();
189 bool showWarning( const rtl::OUString
&rWarning
) const;
190 bool showOverwriteWarning() const;
192 // Allows runtime exceptions to be thrown by const methods
193 inline SAL_CALL
operator com::sun::star::uno::Reference
< com::sun::star::uno::XInterface
> () const
194 { return const_cast< cppu::OWeakObject
* > (static_cast< cppu::OWeakObject
const * > (this)); };
197 virtual void SAL_CALL
disposing( const com::sun::star::lang::EventObject
&rObj
) throw( com::sun::star::uno::RuntimeException
);
198 virtual void SAL_CALL
actionPerformed( com::sun::star::awt::ActionEvent
const & rEvent
) throw( com::sun::star::uno::RuntimeException
);
200 // XTopWindowListener
201 virtual void SAL_CALL
windowOpened( const ::com::sun::star::lang::EventObject
& e
) throw (::com::sun::star::uno::RuntimeException
);
202 virtual void SAL_CALL
windowClosing( const ::com::sun::star::lang::EventObject
& e
) throw (::com::sun::star::uno::RuntimeException
);
203 virtual void SAL_CALL
windowClosed( const ::com::sun::star::lang::EventObject
& e
) throw (::com::sun::star::uno::RuntimeException
);
204 virtual void SAL_CALL
windowMinimized( const ::com::sun::star::lang::EventObject
& e
) throw (::com::sun::star::uno::RuntimeException
);
205 virtual void SAL_CALL
windowNormalized( const ::com::sun::star::lang::EventObject
& e
) throw (::com::sun::star::uno::RuntimeException
);
206 virtual void SAL_CALL
windowActivated( const ::com::sun::star::lang::EventObject
& e
) throw (::com::sun::star::uno::RuntimeException
);
207 virtual void SAL_CALL
windowDeactivated( const ::com::sun::star::lang::EventObject
& e
) throw (::com::sun::star::uno::RuntimeException
);
209 // XInteractionHandler
210 virtual void SAL_CALL
handle( const com::sun::star::uno::Reference
< com::sun::star::task::XInteractionRequest
>& Request
)
211 throw( com::sun::star::uno::RuntimeException
);
213 // XTerminateListener
214 virtual void SAL_CALL
queryTermination( const ::com::sun::star::lang::EventObject
& e
) throw (::com::sun::star::frame::TerminationVetoException
, ::com::sun::star::uno::RuntimeException
);
215 virtual void SAL_CALL
notifyTermination( const ::com::sun::star::lang::EventObject
& e
) throw (::com::sun::star::uno::RuntimeException
);
218 #endif /* INCLUDED_UPDATE_HDL_HXX */