xref: /AOO41X/main/desktop/source/deployment/gui/dp_gui_updatedialog.cxx (revision 47148b3bc50811ceb41802e4cc50a5db21535900)
12722ceddSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
32722ceddSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
42722ceddSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
52722ceddSAndrew Rist  * distributed with this work for additional information
62722ceddSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
72722ceddSAndrew Rist  * to you under the Apache License, Version 2.0 (the
82722ceddSAndrew Rist  * "License"); you may not use this file except in compliance
92722ceddSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
112722ceddSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
132722ceddSAndrew Rist  * Unless required by applicable law or agreed to in writing,
142722ceddSAndrew Rist  * software distributed under the License is distributed on an
152722ceddSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162722ceddSAndrew Rist  * KIND, either express or implied.  See the License for the
172722ceddSAndrew Rist  * specific language governing permissions and limitations
182722ceddSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
202722ceddSAndrew Rist  *************************************************************/
212722ceddSAndrew Rist 
222722ceddSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_desktop.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "sal/config.h"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <cstddef>
30cdf0e10cSrcweir #include <limits>
31cdf0e10cSrcweir #include <map>
32cdf0e10cSrcweir #include <memory>
33cdf0e10cSrcweir #include <utility>
34cdf0e10cSrcweir #include <vector>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include "boost/optional.hpp"
38cdf0e10cSrcweir #include "com/sun/star/awt/Rectangle.hpp"
39cdf0e10cSrcweir #include "com/sun/star/awt/WindowAttribute.hpp"
40cdf0e10cSrcweir #include "com/sun/star/awt/WindowClass.hpp"
41cdf0e10cSrcweir #include "com/sun/star/awt/WindowDescriptor.hpp"
42cdf0e10cSrcweir #include "com/sun/star/awt/XToolkit.hpp"
43cdf0e10cSrcweir #include "com/sun/star/awt/XWindow.hpp"
44cdf0e10cSrcweir #include "com/sun/star/awt/XWindowPeer.hpp"
45cdf0e10cSrcweir #include "com/sun/star/beans/NamedValue.hpp"
46cdf0e10cSrcweir #include "com/sun/star/beans/Optional.hpp"
47cdf0e10cSrcweir #include "com/sun/star/beans/PropertyValue.hpp"
48cdf0e10cSrcweir #include "com/sun/star/beans/XPropertySet.hpp"
49cdf0e10cSrcweir #include "com/sun/star/container/XNameAccess.hpp"
50cdf0e10cSrcweir #include "com/sun/star/container/XNameContainer.hpp"
51cdf0e10cSrcweir #include "com/sun/star/deployment/DeploymentException.hpp"
52cdf0e10cSrcweir #include "com/sun/star/deployment/UpdateInformationProvider.hpp"
53cdf0e10cSrcweir #include "com/sun/star/deployment/XPackage.hpp"
54cdf0e10cSrcweir #include "com/sun/star/deployment/XExtensionManager.hpp"
55cdf0e10cSrcweir #include "com/sun/star/deployment/ExtensionManager.hpp"
56cdf0e10cSrcweir #include "com/sun/star/deployment/XUpdateInformationProvider.hpp"
57cdf0e10cSrcweir #include "com/sun/star/frame/XDesktop.hpp"
58cdf0e10cSrcweir #include "com/sun/star/frame/XDispatch.hpp"
59cdf0e10cSrcweir #include "com/sun/star/frame/XDispatchProvider.hpp"
60cdf0e10cSrcweir #include "com/sun/star/lang/IllegalArgumentException.hpp"
61cdf0e10cSrcweir #include "com/sun/star/lang/XMultiComponentFactory.hpp"
62cdf0e10cSrcweir #include "com/sun/star/lang/XSingleServiceFactory.hpp"
63cdf0e10cSrcweir #include "com/sun/star/system/SystemShellExecuteFlags.hpp"
64*9807c9deSAriel Constenla-Haile #include "com/sun/star/system/SystemShellExecute.hpp"
65cdf0e10cSrcweir #include "com/sun/star/task/XAbortChannel.hpp"
66cdf0e10cSrcweir #include "com/sun/star/task/XJob.hpp"
67cdf0e10cSrcweir #include "com/sun/star/ucb/CommandAbortedException.hpp"
68cdf0e10cSrcweir #include "com/sun/star/ucb/CommandFailedException.hpp"
69cdf0e10cSrcweir #include "com/sun/star/ucb/XCommandEnvironment.hpp"
70cdf0e10cSrcweir #include "com/sun/star/uno/Any.hxx"
71cdf0e10cSrcweir #include "com/sun/star/uno/Exception.hpp"
72cdf0e10cSrcweir #include "com/sun/star/uno/Reference.hxx"
73cdf0e10cSrcweir #include "com/sun/star/uno/RuntimeException.hpp"
74cdf0e10cSrcweir #include "com/sun/star/uno/Sequence.hxx"
75cdf0e10cSrcweir #include "com/sun/star/uno/XInterface.hpp"
76cdf0e10cSrcweir #include "com/sun/star/util/URL.hpp"
77cdf0e10cSrcweir #include "com/sun/star/util/XChangesBatch.hpp"
78cdf0e10cSrcweir #include "com/sun/star/util/XURLTransformer.hpp"
79cdf0e10cSrcweir #include "com/sun/star/xml/dom/XElement.hpp"
80cdf0e10cSrcweir #include "com/sun/star/xml/dom/XNode.hpp"
81cdf0e10cSrcweir #include "osl/diagnose.h"
82cdf0e10cSrcweir #include "rtl/bootstrap.hxx"
83cdf0e10cSrcweir #include "rtl/ref.hxx"
84cdf0e10cSrcweir #include "rtl/string.h"
85cdf0e10cSrcweir #include "rtl/ustrbuf.hxx"
86cdf0e10cSrcweir #include "rtl/ustring.h"
87cdf0e10cSrcweir #include "rtl/ustring.hxx"
88cdf0e10cSrcweir #include "sal/types.h"
89cdf0e10cSrcweir #include "svtools/svlbitm.hxx"
90cdf0e10cSrcweir #include "svtools/svlbox.hxx"
91cdf0e10cSrcweir #include <svtools/controldims.hrc>
92cdf0e10cSrcweir #include "svx/checklbx.hxx"
93cdf0e10cSrcweir #include "tools/gen.hxx"
94cdf0e10cSrcweir #include "tools/link.hxx"
95cdf0e10cSrcweir #include "tools/resid.hxx"
96cdf0e10cSrcweir #include "tools/resmgr.hxx"
97cdf0e10cSrcweir #include "tools/solar.h"
98cdf0e10cSrcweir #include "tools/string.hxx"
99cdf0e10cSrcweir #include "vcl/button.hxx"
100cdf0e10cSrcweir #include "vcl/dialog.hxx"
101cdf0e10cSrcweir #include "vcl/fixed.hxx"
102cdf0e10cSrcweir #include "vcl/image.hxx"
103cdf0e10cSrcweir #include "vcl/msgbox.hxx"
104cdf0e10cSrcweir #include "vcl/svapp.hxx"
105cdf0e10cSrcweir #include "vos/mutex.hxx"
106cdf0e10cSrcweir 
107cdf0e10cSrcweir #include "comphelper/processfactory.hxx"
108cdf0e10cSrcweir 
109cdf0e10cSrcweir #include "dp_dependencies.hxx"
110cdf0e10cSrcweir #include "dp_descriptioninfoset.hxx"
111cdf0e10cSrcweir #include "dp_identifier.hxx"
112cdf0e10cSrcweir #include "dp_version.hxx"
113cdf0e10cSrcweir #include "dp_misc.h"
114cdf0e10cSrcweir #include "dp_update.hxx"
115cdf0e10cSrcweir 
116cdf0e10cSrcweir #include "dp_gui.h"
117cdf0e10cSrcweir #include "dp_gui.hrc"
118cdf0e10cSrcweir #include "dp_gui_thread.hxx"
119cdf0e10cSrcweir #include "dp_gui_updatedata.hxx"
120cdf0e10cSrcweir #include "dp_gui_updatedialog.hxx"
121cdf0e10cSrcweir #include "dp_gui_shared.hxx"
122cdf0e10cSrcweir #include "dp_gui_system.hxx"
123cdf0e10cSrcweir 
124cdf0e10cSrcweir class KeyEvent;
125cdf0e10cSrcweir class MouseEvent;
126cdf0e10cSrcweir class Window;
127cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace uno {
128cdf0e10cSrcweir     class XComponentContext;
129cdf0e10cSrcweir } } } }
130cdf0e10cSrcweir 
131cdf0e10cSrcweir using namespace ::com::sun::star;
132cdf0e10cSrcweir using dp_gui::UpdateDialog;
133cdf0e10cSrcweir 
134cdf0e10cSrcweir namespace {
135cdf0e10cSrcweir 
136cdf0e10cSrcweir static sal_Unicode const LF = 0x000A;
137cdf0e10cSrcweir static sal_Unicode const CR = 0x000D;
138cdf0e10cSrcweir static const sal_uInt16 CMD_ENABLE_UPDATE = 1;
139cdf0e10cSrcweir static const sal_uInt16 CMD_IGNORE_UPDATE = 2;
140cdf0e10cSrcweir static const sal_uInt16 CMD_IGNORE_ALL_UPDATES = 3;
141cdf0e10cSrcweir 
142cdf0e10cSrcweir #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
143cdf0e10cSrcweir 
144cdf0e10cSrcweir #define IGNORED_UPDATES     OUSTR("/org.openoffice.Office.ExtensionManager/ExtensionUpdateData/IgnoredUpdates")
145cdf0e10cSrcweir #define PROPERTY_VERSION    OUSTR("Version")
146cdf0e10cSrcweir 
147cdf0e10cSrcweir enum Kind { ENABLED_UPDATE, DISABLED_UPDATE, SPECIFIC_ERROR };
148cdf0e10cSrcweir 
confineToParagraph(rtl::OUString const & text)149cdf0e10cSrcweir rtl::OUString confineToParagraph(rtl::OUString const & text) {
150cdf0e10cSrcweir     // Confine arbitrary text to a single paragraph in a dp_gui::AutoScrollEdit.
151cdf0e10cSrcweir     // This assumes that U+000A and U+000D are the only paragraph separators in
152cdf0e10cSrcweir     // a dp_gui::AutoScrollEdit, and that replacing them with a single space
153cdf0e10cSrcweir     // each is acceptable:
154cdf0e10cSrcweir     return text.replace(LF, ' ').replace(CR, ' ');
155cdf0e10cSrcweir }
156cdf0e10cSrcweir }
157cdf0e10cSrcweir 
158cdf0e10cSrcweir struct UpdateDialog::DisabledUpdate {
159cdf0e10cSrcweir     rtl::OUString name;
160cdf0e10cSrcweir     uno::Sequence< rtl::OUString > unsatisfiedDependencies;
161cdf0e10cSrcweir     // We also want to show release notes and publisher for disabled updates
162cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > aUpdateInfo;
163cdf0e10cSrcweir     sal_uInt16 m_nID;
164cdf0e10cSrcweir };
165cdf0e10cSrcweir 
166cdf0e10cSrcweir struct UpdateDialog::SpecificError {
167cdf0e10cSrcweir     rtl::OUString name;
168cdf0e10cSrcweir     rtl::OUString message;
169cdf0e10cSrcweir     sal_uInt16 m_nID;
170cdf0e10cSrcweir };
171cdf0e10cSrcweir 
172cdf0e10cSrcweir //------------------------------------------------------------------------------
173cdf0e10cSrcweir struct UpdateDialog::IgnoredUpdate {
174cdf0e10cSrcweir     rtl::OUString sExtensionID;
175cdf0e10cSrcweir     rtl::OUString sVersion;
176cdf0e10cSrcweir     bool          bRemoved;
177cdf0e10cSrcweir 
178cdf0e10cSrcweir     IgnoredUpdate( const rtl::OUString &rExtensionID, const rtl::OUString &rVersion );
179cdf0e10cSrcweir };
180cdf0e10cSrcweir 
181cdf0e10cSrcweir //------------------------------------------------------------------------------
IgnoredUpdate(const rtl::OUString & rExtensionID,const rtl::OUString & rVersion)182cdf0e10cSrcweir UpdateDialog::IgnoredUpdate::IgnoredUpdate( const rtl::OUString &rExtensionID, const rtl::OUString &rVersion ):
183cdf0e10cSrcweir     sExtensionID( rExtensionID ),
184cdf0e10cSrcweir     sVersion( rVersion ),
185cdf0e10cSrcweir     bRemoved( false )
186cdf0e10cSrcweir {}
187cdf0e10cSrcweir 
188cdf0e10cSrcweir //------------------------------------------------------------------------------
189cdf0e10cSrcweir struct UpdateDialog::Index
190cdf0e10cSrcweir {
191cdf0e10cSrcweir     Kind          m_eKind;
192cdf0e10cSrcweir     bool          m_bIgnored;
193cdf0e10cSrcweir     sal_uInt16        m_nID;
194cdf0e10cSrcweir     sal_uInt16        m_nIndex;
195cdf0e10cSrcweir     rtl::OUString m_aName;
196cdf0e10cSrcweir 
197cdf0e10cSrcweir     Index( Kind theKind, sal_uInt16 nID, sal_uInt16 nIndex, const rtl::OUString &rName );
198cdf0e10cSrcweir };
199cdf0e10cSrcweir 
200cdf0e10cSrcweir //------------------------------------------------------------------------------
Index(Kind theKind,sal_uInt16 nID,sal_uInt16 nIndex,const rtl::OUString & rName)201cdf0e10cSrcweir UpdateDialog::Index::Index( Kind theKind, sal_uInt16 nID, sal_uInt16 nIndex, const rtl::OUString &rName ):
202cdf0e10cSrcweir     m_eKind( theKind ),
203cdf0e10cSrcweir     m_bIgnored( false ),
204cdf0e10cSrcweir     m_nID( nID ),
205cdf0e10cSrcweir     m_nIndex( nIndex ),
206cdf0e10cSrcweir     m_aName( rName )
207cdf0e10cSrcweir {}
208cdf0e10cSrcweir 
209cdf0e10cSrcweir //------------------------------------------------------------------------------
210cdf0e10cSrcweir //------------------------------------------------------------------------------
211cdf0e10cSrcweir //------------------------------------------------------------------------------
212cdf0e10cSrcweir class UpdateDialog::Thread: public dp_gui::Thread {
213cdf0e10cSrcweir public:
214cdf0e10cSrcweir     Thread(
215cdf0e10cSrcweir         uno::Reference< uno::XComponentContext > const & context,
216cdf0e10cSrcweir         UpdateDialog & dialog,
217cdf0e10cSrcweir         const std::vector< uno::Reference< deployment::XPackage >  > & vExtensionList);
218cdf0e10cSrcweir 
219cdf0e10cSrcweir     void stop();
220cdf0e10cSrcweir 
221cdf0e10cSrcweir private:
222cdf0e10cSrcweir     Thread(UpdateDialog::Thread &); // not defined
223cdf0e10cSrcweir     void operator =(UpdateDialog::Thread &); // not defined
224cdf0e10cSrcweir 
225cdf0e10cSrcweir     struct Entry {
226cdf0e10cSrcweir         explicit Entry(
227cdf0e10cSrcweir             uno::Reference< deployment::XPackage > const & thePackage,
228cdf0e10cSrcweir             rtl::OUString const & theVersion);
229cdf0e10cSrcweir 
230cdf0e10cSrcweir         uno::Reference< deployment::XPackage > package;
231cdf0e10cSrcweir         rtl::OUString version;
232cdf0e10cSrcweir         //Indicates that the extension provides its own update URLs.
233cdf0e10cSrcweir         //If this is true, then we must not use the default update
234cdf0e10cSrcweir         //URL to find the update information.
235cdf0e10cSrcweir         bool bProvidesOwnUpdate;
236cdf0e10cSrcweir         uno::Reference< xml::dom::XNode > info;
237cdf0e10cSrcweir 	    UpdateDialog::DisabledUpdate disableUpdate;
238cdf0e10cSrcweir 	    dp_gui::UpdateData updateData;
239cdf0e10cSrcweir     };
240cdf0e10cSrcweir 
241cdf0e10cSrcweir     // A multimap in case an extension is installed in "user", "shared" or "bundled"
242cdf0e10cSrcweir     typedef std::map< rtl::OUString, Entry > Map;
243cdf0e10cSrcweir 
244cdf0e10cSrcweir     virtual ~Thread();
245cdf0e10cSrcweir 
246cdf0e10cSrcweir     virtual void execute();
247cdf0e10cSrcweir #if 0
248cdf0e10cSrcweir     void handleGeneralError(uno::Any const & exception) const;
249cdf0e10cSrcweir #endif
250cdf0e10cSrcweir     void handleSpecificError(
251cdf0e10cSrcweir         uno::Reference< deployment::XPackage > const & package,
252cdf0e10cSrcweir         uno::Any const & exception) const;
253cdf0e10cSrcweir 
254cdf0e10cSrcweir     uno::Sequence< uno::Reference< xml::dom::XElement > >
255cdf0e10cSrcweir     getUpdateInformation(
256cdf0e10cSrcweir         uno::Reference< deployment::XPackage > const & package,
257cdf0e10cSrcweir         uno::Sequence< rtl::OUString > const & urls,
258cdf0e10cSrcweir         rtl::OUString const & identifier) const;
259cdf0e10cSrcweir 
260cdf0e10cSrcweir     void getOwnUpdateInformation(
261cdf0e10cSrcweir         uno::Reference< deployment::XPackage > const & package,
262cdf0e10cSrcweir         Map * map);
263cdf0e10cSrcweir 
264cdf0e10cSrcweir     ::rtl::OUString getUpdateDisplayString(
265cdf0e10cSrcweir         dp_gui::UpdateData const & data, ::rtl::OUString const & version = ::rtl::OUString()) const;
266cdf0e10cSrcweir 
267cdf0e10cSrcweir     void prepareUpdateData(
268cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > const & updateInfo,
269cdf0e10cSrcweir         UpdateDialog::DisabledUpdate & out_du,
270cdf0e10cSrcweir         dp_gui::UpdateData & out_data) const;
271cdf0e10cSrcweir 
272cdf0e10cSrcweir     bool update(
273cdf0e10cSrcweir         UpdateDialog::DisabledUpdate & du,
274cdf0e10cSrcweir         dp_gui::UpdateData & data) const;
275cdf0e10cSrcweir 
276cdf0e10cSrcweir     uno::Reference< uno::XComponentContext > m_context;
277cdf0e10cSrcweir     UpdateDialog & m_dialog;
278cdf0e10cSrcweir     std::vector< uno::Reference< deployment::XPackage > > m_vExtensionList;
279cdf0e10cSrcweir     uno::Reference< deployment::XUpdateInformationProvider > m_updateInformation;
280cdf0e10cSrcweir     uno::Reference< task::XInteractionHandler > m_xInteractionHdl;
281cdf0e10cSrcweir 
282cdf0e10cSrcweir     // guarded by Application::GetSolarMutex():
283cdf0e10cSrcweir     uno::Reference< task::XAbortChannel > m_abort;
284cdf0e10cSrcweir     bool m_stop;
285cdf0e10cSrcweir };
286cdf0e10cSrcweir 
Thread(uno::Reference<uno::XComponentContext> const & context,UpdateDialog & dialog,const std::vector<uno::Reference<deployment::XPackage>> & vExtensionList)287cdf0e10cSrcweir UpdateDialog::Thread::Thread(
288cdf0e10cSrcweir     uno::Reference< uno::XComponentContext > const & context,
289cdf0e10cSrcweir     UpdateDialog & dialog,
290cdf0e10cSrcweir     const std::vector< uno::Reference< deployment::XPackage > > &vExtensionList):
291cdf0e10cSrcweir     m_context(context),
292cdf0e10cSrcweir     m_dialog(dialog),
293cdf0e10cSrcweir     m_vExtensionList(vExtensionList),
294cdf0e10cSrcweir     m_updateInformation(
295cdf0e10cSrcweir         deployment::UpdateInformationProvider::create(context)),
296cdf0e10cSrcweir     m_stop(false)
297cdf0e10cSrcweir {
298cdf0e10cSrcweir     if( m_context.is() )
299cdf0e10cSrcweir     {
300cdf0e10cSrcweir         uno::Reference< lang::XMultiComponentFactory > xServiceManager( m_context->getServiceManager() );
301cdf0e10cSrcweir 
302cdf0e10cSrcweir         if( xServiceManager.is() )
303cdf0e10cSrcweir         {
304cdf0e10cSrcweir             m_xInteractionHdl = uno::Reference< task::XInteractionHandler > (
305cdf0e10cSrcweir                                 xServiceManager->createInstanceWithContext( OUSTR( "com.sun.star.task.InteractionHandler" ), m_context),
306cdf0e10cSrcweir                                 uno::UNO_QUERY );
307cdf0e10cSrcweir             if ( m_xInteractionHdl.is() )
308cdf0e10cSrcweir                 m_updateInformation->setInteractionHandler( m_xInteractionHdl );
309cdf0e10cSrcweir         }
310cdf0e10cSrcweir     }
311cdf0e10cSrcweir }
312cdf0e10cSrcweir 
stop()313cdf0e10cSrcweir void UpdateDialog::Thread::stop() {
314cdf0e10cSrcweir     uno::Reference< task::XAbortChannel > abort;
315cdf0e10cSrcweir     {
316cdf0e10cSrcweir         vos::OGuard g(Application::GetSolarMutex());
317cdf0e10cSrcweir         abort = m_abort;
318cdf0e10cSrcweir         m_stop = true;
319cdf0e10cSrcweir     }
320cdf0e10cSrcweir     if (abort.is()) {
321cdf0e10cSrcweir         abort->sendAbort();
322cdf0e10cSrcweir     }
323cdf0e10cSrcweir     m_updateInformation->cancel();
324cdf0e10cSrcweir }
325cdf0e10cSrcweir 
Entry(uno::Reference<deployment::XPackage> const & thePackage,rtl::OUString const & theVersion)326cdf0e10cSrcweir UpdateDialog::Thread::Entry::Entry(
327cdf0e10cSrcweir     uno::Reference< deployment::XPackage > const & thePackage,
328cdf0e10cSrcweir     rtl::OUString const & theVersion):
329cdf0e10cSrcweir 
330cdf0e10cSrcweir     package(thePackage),
331cdf0e10cSrcweir     version(theVersion),
332cdf0e10cSrcweir     bProvidesOwnUpdate(false),
333cdf0e10cSrcweir     updateData(thePackage)
334cdf0e10cSrcweir {
335cdf0e10cSrcweir }
336cdf0e10cSrcweir 
~Thread()337cdf0e10cSrcweir UpdateDialog::Thread::~Thread()
338cdf0e10cSrcweir {
339cdf0e10cSrcweir     if ( m_xInteractionHdl.is() )
340cdf0e10cSrcweir         m_updateInformation->setInteractionHandler( uno::Reference< task::XInteractionHandler > () );
341cdf0e10cSrcweir }
342cdf0e10cSrcweir 
execute()343cdf0e10cSrcweir void UpdateDialog::Thread::execute()
344cdf0e10cSrcweir {
345cdf0e10cSrcweir     {
346cdf0e10cSrcweir         vos::OGuard g( Application::GetSolarMutex() );
347cdf0e10cSrcweir         if ( m_stop ) {
348cdf0e10cSrcweir             return;
349cdf0e10cSrcweir         }
350cdf0e10cSrcweir     }
351cdf0e10cSrcweir     uno::Reference<deployment::XExtensionManager> extMgr =
352cdf0e10cSrcweir         deployment::ExtensionManager::get(m_context);
353cdf0e10cSrcweir 
354cdf0e10cSrcweir     std::vector<std::pair<uno::Reference<deployment::XPackage>, uno::Any > > errors;
355cdf0e10cSrcweir 
356cdf0e10cSrcweir     dp_misc::UpdateInfoMap updateInfoMap = dp_misc::getOnlineUpdateInfos(
357cdf0e10cSrcweir         m_context, extMgr, m_updateInformation, &m_vExtensionList, errors);
358cdf0e10cSrcweir 
359cdf0e10cSrcweir     typedef std::vector<std::pair<uno::Reference<deployment::XPackage>,
360cdf0e10cSrcweir         uno::Any> >::const_iterator ITERROR;
361cdf0e10cSrcweir     for (ITERROR ite = errors.begin(); ite != errors.end(); ite ++)
362cdf0e10cSrcweir         handleSpecificError(ite->first, ite->second);
363cdf0e10cSrcweir 
364cdf0e10cSrcweir     for (dp_misc::UpdateInfoMap::iterator i(updateInfoMap.begin()); i != updateInfoMap.end(); i++)
365cdf0e10cSrcweir     {
366cdf0e10cSrcweir         dp_misc::UpdateInfo const & info = i->second;
367cdf0e10cSrcweir         UpdateData updateData(info.extension);
368cdf0e10cSrcweir         DisabledUpdate disableUpdate;
369cdf0e10cSrcweir         //determine if online updates meet the requirements
370cdf0e10cSrcweir         prepareUpdateData(info.info, disableUpdate, updateData);
371cdf0e10cSrcweir 
372cdf0e10cSrcweir         //determine if the update is installed in the user or shared repository
373cdf0e10cSrcweir         rtl::OUString sOnlineVersion;
374cdf0e10cSrcweir         if (info.info.is())
375cdf0e10cSrcweir             sOnlineVersion = info.version;
376cdf0e10cSrcweir         rtl::OUString sVersionUser;
377cdf0e10cSrcweir         rtl::OUString sVersionShared;
378cdf0e10cSrcweir         rtl::OUString sVersionBundled;
379cdf0e10cSrcweir         uno::Sequence< uno::Reference< deployment::XPackage> > extensions;
380cdf0e10cSrcweir         try {
381cdf0e10cSrcweir             extensions = extMgr->getExtensionsWithSameIdentifier(
382cdf0e10cSrcweir                 dp_misc::getIdentifier(info.extension), info.extension->getName(),
383cdf0e10cSrcweir                 uno::Reference<ucb::XCommandEnvironment>());
384cdf0e10cSrcweir         } catch (lang::IllegalArgumentException& ) {
385cdf0e10cSrcweir             OSL_ASSERT(0);
386cdf0e10cSrcweir             continue;
387cdf0e10cSrcweir         } catch (css::ucb::CommandFailedException& ) {
388cdf0e10cSrcweir             OSL_ASSERT(0);
389cdf0e10cSrcweir             continue;
390cdf0e10cSrcweir         }
391cdf0e10cSrcweir         OSL_ASSERT(extensions.getLength() == 3);
392cdf0e10cSrcweir         if (extensions[0].is() )
393cdf0e10cSrcweir             sVersionUser = extensions[0]->getVersion();
394cdf0e10cSrcweir         if (extensions[1].is() )
395cdf0e10cSrcweir             sVersionShared = extensions[1]->getVersion();
396cdf0e10cSrcweir         if (extensions[2].is() )
397cdf0e10cSrcweir             sVersionBundled = extensions[2]->getVersion();
398cdf0e10cSrcweir 
399cdf0e10cSrcweir         bool bSharedReadOnly = extMgr->isReadOnlyRepository(OUSTR("shared"));
400cdf0e10cSrcweir 
401cdf0e10cSrcweir         dp_misc::UPDATE_SOURCE sourceUser = dp_misc::isUpdateUserExtension(
402cdf0e10cSrcweir             bSharedReadOnly, sVersionUser, sVersionShared, sVersionBundled, sOnlineVersion);
403cdf0e10cSrcweir         dp_misc::UPDATE_SOURCE sourceShared = dp_misc::isUpdateSharedExtension(
404cdf0e10cSrcweir             bSharedReadOnly, sVersionShared, sVersionBundled, sOnlineVersion);
405cdf0e10cSrcweir 
406cdf0e10cSrcweir         uno::Reference<deployment::XPackage> updateSource;
407cdf0e10cSrcweir         if (sourceUser != dp_misc::UPDATE_SOURCE_NONE)
408cdf0e10cSrcweir         {
409cdf0e10cSrcweir             if (sourceUser == dp_misc::UPDATE_SOURCE_SHARED)
410cdf0e10cSrcweir             {
411cdf0e10cSrcweir                 updateData.aUpdateSource = extensions[1];
412cdf0e10cSrcweir                 updateData.updateVersion = extensions[1]->getVersion();
413cdf0e10cSrcweir             }
414cdf0e10cSrcweir             else if (sourceUser == dp_misc::UPDATE_SOURCE_BUNDLED)
415cdf0e10cSrcweir             {
416cdf0e10cSrcweir                 updateData.aUpdateSource = extensions[2];
417cdf0e10cSrcweir                 updateData.updateVersion = extensions[2]->getVersion();
418cdf0e10cSrcweir             }
419cdf0e10cSrcweir             if (!update(disableUpdate, updateData))
420cdf0e10cSrcweir                 return;
421cdf0e10cSrcweir         }
422cdf0e10cSrcweir 
423cdf0e10cSrcweir         if (sourceShared != dp_misc::UPDATE_SOURCE_NONE)
424cdf0e10cSrcweir         {
425cdf0e10cSrcweir 			if (sourceShared == dp_misc::UPDATE_SOURCE_BUNDLED)
426cdf0e10cSrcweir 			{
427cdf0e10cSrcweir 				updateData.aUpdateSource = extensions[2];
428cdf0e10cSrcweir 				updateData.updateVersion = extensions[2]->getVersion();
429cdf0e10cSrcweir 			}
430cdf0e10cSrcweir             updateData.bIsShared = true;
431cdf0e10cSrcweir             if (!update(disableUpdate, updateData))
432cdf0e10cSrcweir                 return;
433cdf0e10cSrcweir         }
434cdf0e10cSrcweir     }
435cdf0e10cSrcweir 
436cdf0e10cSrcweir 
437cdf0e10cSrcweir     vos::OGuard g(Application::GetSolarMutex());
438cdf0e10cSrcweir     if (!m_stop) {
439cdf0e10cSrcweir         m_dialog.checkingDone();
440cdf0e10cSrcweir     }
441cdf0e10cSrcweir }
442cdf0e10cSrcweir #if 0
443cdf0e10cSrcweir void UpdateDialog::Thread::handleGeneralError(uno::Any const & exception)
444cdf0e10cSrcweir     const
445cdf0e10cSrcweir {
446cdf0e10cSrcweir     rtl::OUString message;
447cdf0e10cSrcweir     uno::Exception e;
448cdf0e10cSrcweir     if (exception >>= e) {
449cdf0e10cSrcweir         message = e.Message;
450cdf0e10cSrcweir     }
451cdf0e10cSrcweir     vos::OGuard g(Application::GetSolarMutex());
452cdf0e10cSrcweir     if (!m_stop) {
453cdf0e10cSrcweir         m_dialog.addGeneralError(message);
454cdf0e10cSrcweir     }
455cdf0e10cSrcweir }
456cdf0e10cSrcweir #endif
457cdf0e10cSrcweir //Parameter package can be null
handleSpecificError(uno::Reference<deployment::XPackage> const & package,uno::Any const & exception) const458cdf0e10cSrcweir void UpdateDialog::Thread::handleSpecificError(
459cdf0e10cSrcweir     uno::Reference< deployment::XPackage > const & package,
460cdf0e10cSrcweir     uno::Any const & exception) const
461cdf0e10cSrcweir {
462cdf0e10cSrcweir     UpdateDialog::SpecificError data;
463cdf0e10cSrcweir     if (package.is())
464cdf0e10cSrcweir         data.name = package->getDisplayName();
465cdf0e10cSrcweir     uno::Exception e;
466cdf0e10cSrcweir     if (exception >>= e) {
467cdf0e10cSrcweir         data.message = e.Message;
468cdf0e10cSrcweir     }
469cdf0e10cSrcweir     vos::OGuard g(Application::GetSolarMutex());
470cdf0e10cSrcweir     if (!m_stop) {
471cdf0e10cSrcweir         m_dialog.addSpecificError(data);
472cdf0e10cSrcweir     }
473cdf0e10cSrcweir }
474cdf0e10cSrcweir 
getUpdateDisplayString(dp_gui::UpdateData const & data,::rtl::OUString const & version) const475cdf0e10cSrcweir ::rtl::OUString UpdateDialog::Thread::getUpdateDisplayString(
476cdf0e10cSrcweir     dp_gui::UpdateData const & data, ::rtl::OUString const & version) const
477cdf0e10cSrcweir {
478cdf0e10cSrcweir     OSL_ASSERT(data.aInstalledPackage.is());
479cdf0e10cSrcweir     rtl::OUStringBuffer b(data.aInstalledPackage->getDisplayName());
480cdf0e10cSrcweir     b.append(static_cast< sal_Unicode >(' '));
481cdf0e10cSrcweir     {
482cdf0e10cSrcweir         vos::OGuard g( Application::GetSolarMutex() );
483cdf0e10cSrcweir 		if(!m_stop)
484cdf0e10cSrcweir 			b.append(m_dialog.m_version);
485cdf0e10cSrcweir     }
486cdf0e10cSrcweir     b.append(static_cast< sal_Unicode >(' '));
487cdf0e10cSrcweir     if (version.getLength())
488cdf0e10cSrcweir         b.append(version);
489cdf0e10cSrcweir     else
490cdf0e10cSrcweir         b.append(data.updateVersion);
491cdf0e10cSrcweir 
492cdf0e10cSrcweir     if (data.sWebsiteURL.getLength())
493cdf0e10cSrcweir     {
494cdf0e10cSrcweir         b.append(static_cast< sal_Unicode >(' '));
495cdf0e10cSrcweir         {
496cdf0e10cSrcweir             vos::OGuard g( Application::GetSolarMutex() );
497cdf0e10cSrcweir 			if(!m_stop)
498cdf0e10cSrcweir 				b.append(m_dialog.m_browserbased);
499cdf0e10cSrcweir         }
500cdf0e10cSrcweir     }
501cdf0e10cSrcweir     return  b.makeStringAndClear();
502cdf0e10cSrcweir }
503cdf0e10cSrcweir 
504cdf0e10cSrcweir /** out_data will only be filled if all dependencies are ok.
505cdf0e10cSrcweir  */
prepareUpdateData(uno::Reference<xml::dom::XNode> const & updateInfo,UpdateDialog::DisabledUpdate & out_du,dp_gui::UpdateData & out_data) const506cdf0e10cSrcweir void UpdateDialog::Thread::prepareUpdateData(
507cdf0e10cSrcweir     uno::Reference< xml::dom::XNode > const & updateInfo,
508cdf0e10cSrcweir     UpdateDialog::DisabledUpdate & out_du,
509cdf0e10cSrcweir     dp_gui::UpdateData & out_data) const
510cdf0e10cSrcweir {
511cdf0e10cSrcweir     if (!updateInfo.is())
512cdf0e10cSrcweir         return;
513cdf0e10cSrcweir     dp_misc::DescriptionInfoset infoset(m_context, updateInfo);
514cdf0e10cSrcweir     OSL_ASSERT(infoset.getVersion().getLength() != 0);
515cdf0e10cSrcweir     uno::Sequence< uno::Reference< xml::dom::XElement > > ds(
516cdf0e10cSrcweir         dp_misc::Dependencies::check(infoset));
517cdf0e10cSrcweir 
518cdf0e10cSrcweir     out_du.aUpdateInfo = updateInfo;
519cdf0e10cSrcweir     out_du.unsatisfiedDependencies.realloc(ds.getLength());
520cdf0e10cSrcweir     for (sal_Int32 i = 0; i < ds.getLength(); ++i) {
521cdf0e10cSrcweir         out_du.unsatisfiedDependencies[i] = dp_misc::Dependencies::getErrorText(ds[i]);
522cdf0e10cSrcweir     }
523cdf0e10cSrcweir 
524cdf0e10cSrcweir     const ::boost::optional< ::rtl::OUString> updateWebsiteURL(infoset.getLocalizedUpdateWebsiteURL());
525cdf0e10cSrcweir 
526cdf0e10cSrcweir     out_du.name = getUpdateDisplayString(out_data, infoset.getVersion());
527cdf0e10cSrcweir 
528cdf0e10cSrcweir     if (out_du.unsatisfiedDependencies.getLength() == 0)
529cdf0e10cSrcweir     {
530cdf0e10cSrcweir         out_data.aUpdateInfo = updateInfo;
531cdf0e10cSrcweir         out_data.updateVersion = infoset.getVersion();
532cdf0e10cSrcweir         if (updateWebsiteURL)
533cdf0e10cSrcweir             out_data.sWebsiteURL = *updateWebsiteURL;
534cdf0e10cSrcweir     }
535cdf0e10cSrcweir }
536cdf0e10cSrcweir 
update(UpdateDialog::DisabledUpdate & du,dp_gui::UpdateData & data) const537cdf0e10cSrcweir bool UpdateDialog::Thread::update(
538cdf0e10cSrcweir     UpdateDialog::DisabledUpdate & du,
539cdf0e10cSrcweir     dp_gui::UpdateData & data) const
540cdf0e10cSrcweir {
541cdf0e10cSrcweir     bool ret = false;
542cdf0e10cSrcweir     if (du.unsatisfiedDependencies.getLength() == 0)
543cdf0e10cSrcweir     {
544cdf0e10cSrcweir         vos::OGuard g(Application::GetSolarMutex());
545cdf0e10cSrcweir         if (!m_stop) {
546cdf0e10cSrcweir             m_dialog.addEnabledUpdate(getUpdateDisplayString(data), data);
547cdf0e10cSrcweir         }
548cdf0e10cSrcweir         ret = !m_stop;
549cdf0e10cSrcweir     } else {
550cdf0e10cSrcweir         vos::OGuard g(Application::GetSolarMutex());
551cdf0e10cSrcweir         if (!m_stop) {
552cdf0e10cSrcweir                 m_dialog.addDisabledUpdate(du);
553cdf0e10cSrcweir         }
554cdf0e10cSrcweir         ret = !m_stop;
555cdf0e10cSrcweir     }
556cdf0e10cSrcweir     return ret;
557cdf0e10cSrcweir }
558cdf0e10cSrcweir 
559cdf0e10cSrcweir // UpdateDialog ----------------------------------------------------------
UpdateDialog(uno::Reference<uno::XComponentContext> const & context,Window * parent,const std::vector<uno::Reference<deployment::XPackage>> & vExtensionList,std::vector<dp_gui::UpdateData> * updateData)560cdf0e10cSrcweir UpdateDialog::UpdateDialog(
561cdf0e10cSrcweir     uno::Reference< uno::XComponentContext > const & context,
562cdf0e10cSrcweir     Window * parent,
563cdf0e10cSrcweir     const std::vector<uno::Reference< deployment::XPackage > > &vExtensionList,
564cdf0e10cSrcweir     std::vector< dp_gui::UpdateData > * updateData):
565cdf0e10cSrcweir     ModalDialog(parent,DpGuiResId(RID_DLG_UPDATE)),
566cdf0e10cSrcweir     m_context(context),
567cdf0e10cSrcweir     m_checking(this, DpGuiResId(RID_DLG_UPDATE_CHECKING)),
568cdf0e10cSrcweir     m_throbber(this, DpGuiResId(RID_DLG_UPDATE_THROBBER)),
569cdf0e10cSrcweir     m_update(this, DpGuiResId(RID_DLG_UPDATE_UPDATE)),
570cdf0e10cSrcweir     m_updates(
571cdf0e10cSrcweir         *this, DpGuiResId(RID_DLG_UPDATE_UPDATES),
572cdf0e10cSrcweir         Image(DpGuiResId(RID_DLG_UPDATE_NORMALALERT)),
573cdf0e10cSrcweir         Image(DpGuiResId(RID_DLG_UPDATE_HIGHCONTRASTALERT))),
574cdf0e10cSrcweir     m_all(this, DpGuiResId(RID_DLG_UPDATE_ALL)),
575cdf0e10cSrcweir     m_description(this, DpGuiResId(RID_DLG_UPDATE_DESCRIPTION)),
576cdf0e10cSrcweir     m_PublisherLabel(this, DpGuiResId(RID_DLG_UPDATE_PUBLISHER_LABEL)),
577cdf0e10cSrcweir     m_PublisherLink(this, DpGuiResId(RID_DLG_UPDATE_PUBLISHER_LINK)),
578cdf0e10cSrcweir     m_ReleaseNotesLabel(this, DpGuiResId(RID_DLG_UPDATE_RELEASENOTES_LABEL)),
579cdf0e10cSrcweir     m_ReleaseNotesLink(this, DpGuiResId(RID_DLG_UPDATE_RELEASENOTES_LINK)),
580cdf0e10cSrcweir     m_descriptions(this, DpGuiResId(RID_DLG_UPDATE_DESCRIPTIONS)),
581cdf0e10cSrcweir     m_line(this, DpGuiResId(RID_DLG_UPDATE_LINE)),
582cdf0e10cSrcweir     m_help(this, DpGuiResId(RID_DLG_UPDATE_HELP)),
583cdf0e10cSrcweir     m_ok(this, DpGuiResId(RID_DLG_UPDATE_OK)),
584cdf0e10cSrcweir     m_close(this, DpGuiResId(RID_DLG_UPDATE_CLOSE)),
585cdf0e10cSrcweir     m_error(String(DpGuiResId(RID_DLG_UPDATE_ERROR))),
586cdf0e10cSrcweir     m_none(String(DpGuiResId(RID_DLG_UPDATE_NONE))),
587cdf0e10cSrcweir     m_noInstallable(String(DpGuiResId(RID_DLG_UPDATE_NOINSTALLABLE))),
588cdf0e10cSrcweir     m_failure(String(DpGuiResId(RID_DLG_UPDATE_FAILURE))),
589cdf0e10cSrcweir     m_unknownError(String(DpGuiResId(RID_DLG_UPDATE_UNKNOWNERROR))),
590cdf0e10cSrcweir     m_noDescription(String(DpGuiResId(RID_DLG_UPDATE_NODESCRIPTION))),
591cdf0e10cSrcweir     m_noInstall(String(DpGuiResId(RID_DLG_UPDATE_NOINSTALL))),
592cdf0e10cSrcweir     m_noDependency(String(DpGuiResId(RID_DLG_UPDATE_NODEPENDENCY))),
593cdf0e10cSrcweir     m_noDependencyCurVer(String(DpGuiResId(RID_DLG_UPDATE_NODEPENDENCY_CUR_VER))),
594cdf0e10cSrcweir     m_browserbased(String(DpGuiResId(RID_DLG_UPDATE_BROWSERBASED))),
595cdf0e10cSrcweir     m_version(String(DpGuiResId(RID_DLG_UPDATE_VERSION))),
596cdf0e10cSrcweir     m_ignoredUpdate(String(DpGuiResId(RID_DLG_UPDATE_IGNORED_UPDATE))),
597cdf0e10cSrcweir     m_updateData(*updateData),
598cdf0e10cSrcweir     m_thread(
599cdf0e10cSrcweir         new UpdateDialog::Thread(
600cdf0e10cSrcweir             context, *this, vExtensionList)),
601cdf0e10cSrcweir     m_nFirstLineDelta(0),
602cdf0e10cSrcweir     m_nOneLineMissing(0),
603cdf0e10cSrcweir     m_nLastID(1),
604cdf0e10cSrcweir     m_bModified( false )
605cdf0e10cSrcweir     // TODO: check!
606cdf0e10cSrcweir //    ,
607cdf0e10cSrcweir //    m_extensionManagerDialog(extensionManagerDialog)
608cdf0e10cSrcweir {
609cdf0e10cSrcweir     OSL_ASSERT(updateData != NULL);
610cdf0e10cSrcweir 
611cdf0e10cSrcweir     m_xExtensionManager = deployment::ExtensionManager::get( context );
612cdf0e10cSrcweir 
613cdf0e10cSrcweir     uno::Reference< awt::XToolkit > toolkit;
614cdf0e10cSrcweir     try {
615cdf0e10cSrcweir         toolkit = uno::Reference< awt::XToolkit >(
616cdf0e10cSrcweir             (uno::Reference< lang::XMultiComponentFactory >(
617cdf0e10cSrcweir                 m_context->getServiceManager(),
618cdf0e10cSrcweir                 uno::UNO_QUERY_THROW)->
619cdf0e10cSrcweir              createInstanceWithContext(
620cdf0e10cSrcweir                  rtl::OUString(
621cdf0e10cSrcweir                      RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.Toolkit")),
622cdf0e10cSrcweir                  m_context)),
623cdf0e10cSrcweir             uno::UNO_QUERY_THROW);
624cdf0e10cSrcweir     } catch (uno::RuntimeException &) {
625cdf0e10cSrcweir         throw;
626cdf0e10cSrcweir     } catch (uno::Exception & e) {
627cdf0e10cSrcweir         throw uno::RuntimeException(e.Message, e.Context);
628cdf0e10cSrcweir     }
629cdf0e10cSrcweir     m_updates.SetSelectHdl(LINK(this, UpdateDialog, selectionHandler));
630cdf0e10cSrcweir     m_all.SetToggleHdl(LINK(this, UpdateDialog, allHandler));
631cdf0e10cSrcweir     m_ok.SetClickHdl(LINK(this, UpdateDialog, okHandler));
632cdf0e10cSrcweir     m_close.SetClickHdl(LINK(this, UpdateDialog, closeHandler));
633cdf0e10cSrcweir     if ( ! dp_misc::office_is_running())
634cdf0e10cSrcweir         m_help.Disable();
635cdf0e10cSrcweir     FreeResource();
636cdf0e10cSrcweir 
637cdf0e10cSrcweir     initDescription();
638cdf0e10cSrcweir     getIgnoredUpdates();
639cdf0e10cSrcweir }
640cdf0e10cSrcweir 
641cdf0e10cSrcweir //------------------------------------------------------------------------------
~UpdateDialog()642cdf0e10cSrcweir UpdateDialog::~UpdateDialog()
643cdf0e10cSrcweir {
644cdf0e10cSrcweir     storeIgnoredUpdates();
645cdf0e10cSrcweir 
646cdf0e10cSrcweir     for ( std::vector< UpdateDialog::Index* >::iterator i( m_ListboxEntries.begin() ); i != m_ListboxEntries.end(); ++i )
647cdf0e10cSrcweir     {
648cdf0e10cSrcweir         delete (*i);
649cdf0e10cSrcweir     }
650cdf0e10cSrcweir     for ( std::vector< UpdateDialog::IgnoredUpdate* >::iterator i( m_ignoredUpdates.begin() ); i != m_ignoredUpdates.end(); ++i )
651cdf0e10cSrcweir     {
652cdf0e10cSrcweir         delete (*i);
653cdf0e10cSrcweir     }
654cdf0e10cSrcweir }
655cdf0e10cSrcweir 
656cdf0e10cSrcweir //------------------------------------------------------------------------------
Close()657cdf0e10cSrcweir sal_Bool UpdateDialog::Close() {
658cdf0e10cSrcweir     m_thread->stop();
659cdf0e10cSrcweir     return ModalDialog::Close();
660cdf0e10cSrcweir }
661cdf0e10cSrcweir 
Execute()662cdf0e10cSrcweir short UpdateDialog::Execute() {
663cdf0e10cSrcweir     m_throbber.start();
664cdf0e10cSrcweir     m_thread->launch();
665cdf0e10cSrcweir     return ModalDialog::Execute();
666cdf0e10cSrcweir }
667cdf0e10cSrcweir 
668cdf0e10cSrcweir //------------------------------------------------------------------------------
669cdf0e10cSrcweir //------------------------------------------------------------------------------
670cdf0e10cSrcweir //------------------------------------------------------------------------------
CheckListBox(UpdateDialog & dialog,ResId const & resource,Image const & normalStaticImage,Image const & highContrastStaticImage)671cdf0e10cSrcweir UpdateDialog::CheckListBox::CheckListBox( UpdateDialog & dialog, ResId const & resource,
672cdf0e10cSrcweir                                           Image const & normalStaticImage,
673cdf0e10cSrcweir                                           Image const & highContrastStaticImage ):
674cdf0e10cSrcweir     SvxCheckListBox( &dialog, resource, normalStaticImage, highContrastStaticImage ),
675cdf0e10cSrcweir     m_ignoreUpdate( String( DpGuiResId( RID_DLG_UPDATE_IGNORE ) ) ),
676cdf0e10cSrcweir     m_ignoreAllUpdates( String( DpGuiResId( RID_DLG_UPDATE_IGNORE_ALL ) ) ),
677cdf0e10cSrcweir     m_enableUpdate( String( DpGuiResId( RID_DLG_UPDATE_ENABLE ) ) ),
678cdf0e10cSrcweir     m_dialog(dialog)
679cdf0e10cSrcweir {}
680cdf0e10cSrcweir 
681cdf0e10cSrcweir //------------------------------------------------------------------------------
~CheckListBox()682cdf0e10cSrcweir UpdateDialog::CheckListBox::~CheckListBox() {}
683cdf0e10cSrcweir 
684cdf0e10cSrcweir //------------------------------------------------------------------------------
getItemCount() const685cdf0e10cSrcweir sal_uInt16 UpdateDialog::CheckListBox::getItemCount() const {
686cdf0e10cSrcweir     sal_uLong i = GetEntryCount();
687cdf0e10cSrcweir     OSL_ASSERT(i <= std::numeric_limits< sal_uInt16 >::max());
688cdf0e10cSrcweir     return sal::static_int_cast< sal_uInt16 >(i);
689cdf0e10cSrcweir }
690cdf0e10cSrcweir 
691cdf0e10cSrcweir //------------------------------------------------------------------------------
MouseButtonDown(MouseEvent const & event)692cdf0e10cSrcweir void UpdateDialog::CheckListBox::MouseButtonDown( MouseEvent const & event )
693cdf0e10cSrcweir {
694cdf0e10cSrcweir     // When clicking on a selected entry in an SvxCheckListBox, the entry's
695cdf0e10cSrcweir     // checkbox is toggled on mouse button down:
696cdf0e10cSrcweir     SvxCheckListBox::MouseButtonDown( event );
697cdf0e10cSrcweir 
698cdf0e10cSrcweir     if ( event.IsRight() )
699cdf0e10cSrcweir     {
700cdf0e10cSrcweir         handlePopupMenu( event.GetPosPixel() );
701cdf0e10cSrcweir     }
702cdf0e10cSrcweir 
703cdf0e10cSrcweir     m_dialog.enableOk();
704cdf0e10cSrcweir }
705cdf0e10cSrcweir 
706cdf0e10cSrcweir //------------------------------------------------------------------------------
MouseButtonUp(MouseEvent const & event)707cdf0e10cSrcweir void UpdateDialog::CheckListBox::MouseButtonUp(MouseEvent const & event) {
708cdf0e10cSrcweir     // When clicking on an entry's checkbox in an SvxCheckListBox, the entry's
709cdf0e10cSrcweir     // checkbox is toggled on mouse button up:
710cdf0e10cSrcweir     SvxCheckListBox::MouseButtonUp(event);
711cdf0e10cSrcweir     m_dialog.enableOk();
712cdf0e10cSrcweir }
713cdf0e10cSrcweir 
KeyInput(KeyEvent const & event)714cdf0e10cSrcweir void UpdateDialog::CheckListBox::KeyInput(KeyEvent const & event) {
715cdf0e10cSrcweir     SvxCheckListBox::KeyInput(event);
716cdf0e10cSrcweir     m_dialog.enableOk();
717cdf0e10cSrcweir }
718cdf0e10cSrcweir 
719cdf0e10cSrcweir //------------------------------------------------------------------------------
handlePopupMenu(const Point & rPos)720cdf0e10cSrcweir void UpdateDialog::CheckListBox::handlePopupMenu( const Point &rPos )
721cdf0e10cSrcweir {
722cdf0e10cSrcweir     SvListEntry *pData = GetEntry( rPos );
723cdf0e10cSrcweir 
724cdf0e10cSrcweir     if ( pData )
725cdf0e10cSrcweir     {
726cdf0e10cSrcweir         sal_uInt16 nEntryPos = GetSelectEntryPos();
727cdf0e10cSrcweir         UpdateDialog::Index * p = static_cast< UpdateDialog::Index * >( GetEntryData( nEntryPos ) );
728cdf0e10cSrcweir 
729cdf0e10cSrcweir         if ( ( p->m_eKind == ENABLED_UPDATE ) || ( p->m_eKind == DISABLED_UPDATE ) )
730cdf0e10cSrcweir         {
731cdf0e10cSrcweir             PopupMenu aPopup;
732cdf0e10cSrcweir 
733cdf0e10cSrcweir             if ( p->m_bIgnored )
734cdf0e10cSrcweir                 aPopup.InsertItem( CMD_ENABLE_UPDATE, m_enableUpdate );
735cdf0e10cSrcweir             else
736cdf0e10cSrcweir             {
737cdf0e10cSrcweir                 aPopup.InsertItem( CMD_IGNORE_UPDATE, m_ignoreUpdate );
738cdf0e10cSrcweir                 aPopup.InsertItem( CMD_IGNORE_ALL_UPDATES, m_ignoreAllUpdates );
739cdf0e10cSrcweir             }
740cdf0e10cSrcweir 
741cdf0e10cSrcweir             sal_uInt16 aCmd = aPopup.Execute( this, rPos );
742cdf0e10cSrcweir             if ( ( aCmd == CMD_IGNORE_UPDATE ) || ( aCmd == CMD_IGNORE_ALL_UPDATES ) )
743cdf0e10cSrcweir             {
744cdf0e10cSrcweir                 p->m_bIgnored = true;
745cdf0e10cSrcweir                 if ( p->m_eKind == ENABLED_UPDATE )
746cdf0e10cSrcweir                 {
747cdf0e10cSrcweir                     RemoveEntry( nEntryPos );
748cdf0e10cSrcweir                     m_dialog.addAdditional( p, SvLBoxButtonKind_disabledCheckbox );
749cdf0e10cSrcweir                 }
750cdf0e10cSrcweir                 if ( aCmd == CMD_IGNORE_UPDATE )
751cdf0e10cSrcweir                     m_dialog.setIgnoredUpdate( p, true, false );
752cdf0e10cSrcweir                 else
753cdf0e10cSrcweir                     m_dialog.setIgnoredUpdate( p, true, true );
754cdf0e10cSrcweir                 // TODO: reselect entry to display new description!
755cdf0e10cSrcweir             }
756cdf0e10cSrcweir             else if ( aCmd == CMD_ENABLE_UPDATE )
757cdf0e10cSrcweir             {
758cdf0e10cSrcweir                 p->m_bIgnored = false;
759cdf0e10cSrcweir                 if ( p->m_eKind == ENABLED_UPDATE )
760cdf0e10cSrcweir                 {
761cdf0e10cSrcweir                     RemoveEntry( nEntryPos );
762cdf0e10cSrcweir                     m_dialog.insertItem( p, SvLBoxButtonKind_enabledCheckbox );
763cdf0e10cSrcweir                 }
764cdf0e10cSrcweir                 m_dialog.setIgnoredUpdate( p, false, false );
765cdf0e10cSrcweir             }
766cdf0e10cSrcweir         }
767cdf0e10cSrcweir     }
768cdf0e10cSrcweir }
769cdf0e10cSrcweir 
770cdf0e10cSrcweir //------------------------------------------------------------------------------
771cdf0e10cSrcweir //------------------------------------------------------------------------------
772cdf0e10cSrcweir //------------------------------------------------------------------------------
insertItem(UpdateDialog::Index * pEntry,SvLBoxButtonKind kind)773cdf0e10cSrcweir sal_uInt16 UpdateDialog::insertItem( UpdateDialog::Index *pEntry, SvLBoxButtonKind kind )
774cdf0e10cSrcweir {
775cdf0e10cSrcweir     m_updates.InsertEntry( pEntry->m_aName, LISTBOX_APPEND, static_cast< void * >( pEntry ), kind );
776cdf0e10cSrcweir 
777cdf0e10cSrcweir     for ( sal_uInt16 i = m_updates.getItemCount(); i != 0 ; )
778cdf0e10cSrcweir     {
779cdf0e10cSrcweir         i -= 1;
780cdf0e10cSrcweir         UpdateDialog::Index const * p = static_cast< UpdateDialog::Index const * >( m_updates.GetEntryData( i ) );
781cdf0e10cSrcweir         if ( p == pEntry )
782cdf0e10cSrcweir             return i;
783cdf0e10cSrcweir     }
784cdf0e10cSrcweir     OSL_ASSERT(0);
785cdf0e10cSrcweir     return 0;
786cdf0e10cSrcweir }
787cdf0e10cSrcweir 
788cdf0e10cSrcweir //------------------------------------------------------------------------------
addAdditional(UpdateDialog::Index * index,SvLBoxButtonKind kind)789cdf0e10cSrcweir void UpdateDialog::addAdditional( UpdateDialog::Index * index, SvLBoxButtonKind kind )
790cdf0e10cSrcweir {
791cdf0e10cSrcweir     m_all.Enable();
792cdf0e10cSrcweir     if (m_all.IsChecked())
793cdf0e10cSrcweir     {
794cdf0e10cSrcweir         insertItem( index, kind );
795cdf0e10cSrcweir         m_update.Enable();
796cdf0e10cSrcweir         m_updates.Enable();
797cdf0e10cSrcweir         m_description.Enable();
798cdf0e10cSrcweir         m_descriptions.Enable();
799cdf0e10cSrcweir     }
800cdf0e10cSrcweir }
801cdf0e10cSrcweir 
802cdf0e10cSrcweir //------------------------------------------------------------------------------
addEnabledUpdate(rtl::OUString const & name,dp_gui::UpdateData & data)803cdf0e10cSrcweir void UpdateDialog::addEnabledUpdate( rtl::OUString const & name,
804cdf0e10cSrcweir                                      dp_gui::UpdateData & data )
805cdf0e10cSrcweir {
806cdf0e10cSrcweir     sal_uInt16 nIndex = sal::static_int_cast< sal_uInt16 >( m_enabledUpdates.size() );
807cdf0e10cSrcweir     UpdateDialog::Index *pEntry = new UpdateDialog::Index( ENABLED_UPDATE, m_nLastID, nIndex, name );
808cdf0e10cSrcweir 
809cdf0e10cSrcweir     data.m_nID = m_nLastID;
810cdf0e10cSrcweir     m_nLastID += 1;
811cdf0e10cSrcweir 
812cdf0e10cSrcweir     m_enabledUpdates.push_back( data );
813cdf0e10cSrcweir     m_ListboxEntries.push_back( pEntry );
814cdf0e10cSrcweir 
815cdf0e10cSrcweir     if ( ! isIgnoredUpdate( pEntry ) )
816cdf0e10cSrcweir     {
817cdf0e10cSrcweir         sal_uInt16 nPos = insertItem( pEntry, SvLBoxButtonKind_enabledCheckbox );
818cdf0e10cSrcweir         m_updates.CheckEntryPos( nPos );
819cdf0e10cSrcweir     }
820cdf0e10cSrcweir     else
821cdf0e10cSrcweir         addAdditional( pEntry, SvLBoxButtonKind_disabledCheckbox );
822cdf0e10cSrcweir 
823cdf0e10cSrcweir     m_update.Enable();
824cdf0e10cSrcweir     m_updates.Enable();
825cdf0e10cSrcweir     m_description.Enable();
826cdf0e10cSrcweir     m_descriptions.Enable();
827cdf0e10cSrcweir }
828cdf0e10cSrcweir 
829cdf0e10cSrcweir //------------------------------------------------------------------------------
addDisabledUpdate(UpdateDialog::DisabledUpdate & data)830cdf0e10cSrcweir void UpdateDialog::addDisabledUpdate( UpdateDialog::DisabledUpdate & data )
831cdf0e10cSrcweir {
832cdf0e10cSrcweir     sal_uInt16 nIndex = sal::static_int_cast< sal_uInt16 >( m_disabledUpdates.size() );
833cdf0e10cSrcweir     UpdateDialog::Index *pEntry = new UpdateDialog::Index( DISABLED_UPDATE, m_nLastID, nIndex, data.name );
834cdf0e10cSrcweir 
835cdf0e10cSrcweir     data.m_nID = m_nLastID;
836cdf0e10cSrcweir     m_nLastID += 1;
837cdf0e10cSrcweir 
838cdf0e10cSrcweir     m_disabledUpdates.push_back( data );
839cdf0e10cSrcweir     m_ListboxEntries.push_back( pEntry );
840cdf0e10cSrcweir 
841cdf0e10cSrcweir     isIgnoredUpdate( pEntry );
842cdf0e10cSrcweir     addAdditional( pEntry, SvLBoxButtonKind_disabledCheckbox );
843cdf0e10cSrcweir }
844cdf0e10cSrcweir 
845cdf0e10cSrcweir //------------------------------------------------------------------------------
addSpecificError(UpdateDialog::SpecificError & data)846cdf0e10cSrcweir void UpdateDialog::addSpecificError( UpdateDialog::SpecificError & data )
847cdf0e10cSrcweir {
848cdf0e10cSrcweir     sal_uInt16 nIndex = sal::static_int_cast< sal_uInt16 >( m_specificErrors.size() );
84926cba339SOliver-Rainer Wittmann     UpdateDialog::Index *pEntry = new UpdateDialog::Index( SPECIFIC_ERROR, m_nLastID, nIndex, data.name );
850cdf0e10cSrcweir 
851cdf0e10cSrcweir     data.m_nID = m_nLastID;
852cdf0e10cSrcweir     m_nLastID += 1;
853cdf0e10cSrcweir 
854cdf0e10cSrcweir     m_specificErrors.push_back( data );
855cdf0e10cSrcweir     m_ListboxEntries.push_back( pEntry );
856cdf0e10cSrcweir 
857cdf0e10cSrcweir     addAdditional( pEntry, SvLBoxButtonKind_staticImage);
858cdf0e10cSrcweir }
859cdf0e10cSrcweir 
checkingDone()860cdf0e10cSrcweir void UpdateDialog::checkingDone() {
861cdf0e10cSrcweir     m_checking.Hide();
862cdf0e10cSrcweir     m_throbber.stop();
863cdf0e10cSrcweir     m_throbber.Hide();
864cdf0e10cSrcweir     if (m_updates.getItemCount() == 0)
865cdf0e10cSrcweir     {
866cdf0e10cSrcweir         clearDescription();
867cdf0e10cSrcweir         m_description.Enable();
868cdf0e10cSrcweir         m_descriptions.Enable();
869cdf0e10cSrcweir 
870cdf0e10cSrcweir         if ( m_disabledUpdates.empty() && m_specificErrors.empty() && m_ignoredUpdates.empty() )
871cdf0e10cSrcweir             showDescription( m_none, false );
872cdf0e10cSrcweir         else
873cdf0e10cSrcweir             showDescription( m_noInstallable, false );
874cdf0e10cSrcweir     }
875cdf0e10cSrcweir 
876cdf0e10cSrcweir     enableOk();
877cdf0e10cSrcweir }
878cdf0e10cSrcweir 
enableOk()879cdf0e10cSrcweir void UpdateDialog::enableOk() {
880cdf0e10cSrcweir     if (!m_checking.IsVisible()) {
881cdf0e10cSrcweir         m_ok.Enable(m_updates.GetCheckedEntryCount() != 0);
882cdf0e10cSrcweir     }
883cdf0e10cSrcweir }
884cdf0e10cSrcweir 
885cdf0e10cSrcweir // *********************************************************************************
createNotifyJob(bool bPrepareOnly,uno::Sequence<uno::Sequence<rtl::OUString>> & rItemList)886cdf0e10cSrcweir void UpdateDialog::createNotifyJob( bool bPrepareOnly,
887cdf0e10cSrcweir     uno::Sequence< uno::Sequence< rtl::OUString > > &rItemList )
888cdf0e10cSrcweir {
889cdf0e10cSrcweir     if ( !dp_misc::office_is_running() )
890cdf0e10cSrcweir         return;
891cdf0e10cSrcweir 
892cdf0e10cSrcweir     // notify update check job
893cdf0e10cSrcweir     try
894cdf0e10cSrcweir     {
895cdf0e10cSrcweir         uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
896cdf0e10cSrcweir         uno::Reference< lang::XMultiServiceFactory > xConfigProvider(
897cdf0e10cSrcweir             xFactory->createInstance( OUSTR( "com.sun.star.configuration.ConfigurationProvider" )),
898cdf0e10cSrcweir             uno::UNO_QUERY_THROW);
899cdf0e10cSrcweir 
900cdf0e10cSrcweir         beans::PropertyValue aProperty;
901cdf0e10cSrcweir         aProperty.Name  = OUSTR( "nodepath" );
902cdf0e10cSrcweir         aProperty.Value = uno::makeAny( OUSTR("org.openoffice.Office.Addons/AddonUI/OfficeHelp/UpdateCheckJob") );
903cdf0e10cSrcweir 
904cdf0e10cSrcweir         uno::Sequence< uno::Any > aArgumentList( 1 );
905cdf0e10cSrcweir         aArgumentList[0] = uno::makeAny( aProperty );
906cdf0e10cSrcweir 
907cdf0e10cSrcweir         uno::Reference< container::XNameAccess > xNameAccess(
908cdf0e10cSrcweir             xConfigProvider->createInstanceWithArguments(
909cdf0e10cSrcweir                 OUSTR("com.sun.star.configuration.ConfigurationAccess"), aArgumentList ),
910cdf0e10cSrcweir             uno::UNO_QUERY_THROW );
911cdf0e10cSrcweir 
912cdf0e10cSrcweir         util::URL aURL;
913cdf0e10cSrcweir         xNameAccess->getByName(OUSTR("URL")) >>= aURL.Complete;
914cdf0e10cSrcweir 
915cdf0e10cSrcweir         uno::Reference < util::XURLTransformer > xTransformer( xFactory->createInstance( OUSTR( "com.sun.star.util.URLTransformer" ) ),
916cdf0e10cSrcweir             uno::UNO_QUERY_THROW );
917cdf0e10cSrcweir 
918cdf0e10cSrcweir         xTransformer->parseStrict(aURL);
919cdf0e10cSrcweir 
920cdf0e10cSrcweir         uno::Reference < frame::XDesktop > xDesktop( xFactory->createInstance( OUSTR( "com.sun.star.frame.Desktop" ) ),
921cdf0e10cSrcweir             uno::UNO_QUERY_THROW );
922cdf0e10cSrcweir         uno::Reference< frame::XDispatchProvider > xDispatchProvider( xDesktop->getCurrentFrame(),
923cdf0e10cSrcweir             uno::UNO_QUERY_THROW );
924cdf0e10cSrcweir         uno::Reference< frame::XDispatch > xDispatch = xDispatchProvider->queryDispatch(aURL, rtl::OUString(), 0);
925cdf0e10cSrcweir 
926cdf0e10cSrcweir         if( xDispatch.is() )
927cdf0e10cSrcweir         {
928cdf0e10cSrcweir             uno::Sequence< beans::PropertyValue > aPropList(2);
929cdf0e10cSrcweir             aProperty.Name  = OUSTR( "updateList" );
930cdf0e10cSrcweir             aProperty.Value = uno::makeAny( rItemList );
931cdf0e10cSrcweir             aPropList[0] = aProperty;
932cdf0e10cSrcweir             aProperty.Name  = OUSTR( "prepareOnly" );
933cdf0e10cSrcweir             aProperty.Value = uno::makeAny( bPrepareOnly );
934cdf0e10cSrcweir             aPropList[1] = aProperty;
935cdf0e10cSrcweir 
936cdf0e10cSrcweir             xDispatch->dispatch(aURL, aPropList );
937cdf0e10cSrcweir         }
938cdf0e10cSrcweir     }
939cdf0e10cSrcweir     catch( const uno::Exception& e )
940cdf0e10cSrcweir     {
941cdf0e10cSrcweir         dp_misc::TRACE( OUSTR("Caught exception: ")
942cdf0e10cSrcweir             + e.Message + OUSTR("\n thread terminated.\n\n"));
943cdf0e10cSrcweir     }
944cdf0e10cSrcweir }
945cdf0e10cSrcweir 
946cdf0e10cSrcweir // *********************************************************************************
notifyMenubar(bool bPrepareOnly,bool bRecheckOnly)947cdf0e10cSrcweir void UpdateDialog::notifyMenubar( bool bPrepareOnly, bool bRecheckOnly )
948cdf0e10cSrcweir {
949cdf0e10cSrcweir     if ( !dp_misc::office_is_running() )
950cdf0e10cSrcweir         return;
951cdf0e10cSrcweir 
952cdf0e10cSrcweir     uno::Sequence< uno::Sequence< rtl::OUString > > aItemList;
953cdf0e10cSrcweir     sal_Int32 nCount = 0;
954cdf0e10cSrcweir 
955cdf0e10cSrcweir     if ( ! bRecheckOnly )
956cdf0e10cSrcweir     {
957cdf0e10cSrcweir         for ( sal_Int16 i = 0; i < m_updates.getItemCount(); ++i )
958cdf0e10cSrcweir         {
959cdf0e10cSrcweir             uno::Sequence< rtl::OUString > aItem(2);
960cdf0e10cSrcweir 
961cdf0e10cSrcweir             UpdateDialog::Index const * p = static_cast< UpdateDialog::Index const * >(m_updates.GetEntryData(i));
962cdf0e10cSrcweir 
963cdf0e10cSrcweir             if ( p->m_eKind == ENABLED_UPDATE )
964cdf0e10cSrcweir             {
965cdf0e10cSrcweir                 dp_gui::UpdateData aUpdData = m_enabledUpdates[ p->m_nIndex ];
966cdf0e10cSrcweir                 aItem[0] = dp_misc::getIdentifier( aUpdData.aInstalledPackage );
967cdf0e10cSrcweir 
968cdf0e10cSrcweir                 dp_misc::DescriptionInfoset aInfoset( m_context, aUpdData.aUpdateInfo );
969cdf0e10cSrcweir                 aItem[1] = aInfoset.getVersion();
970cdf0e10cSrcweir             }
971cdf0e10cSrcweir             else if ( p->m_eKind == DISABLED_UPDATE )
972cdf0e10cSrcweir                 continue;
973cdf0e10cSrcweir             else
974cdf0e10cSrcweir                 continue;
975cdf0e10cSrcweir 
976cdf0e10cSrcweir             aItemList.realloc( nCount + 1 );
977cdf0e10cSrcweir             aItemList[ nCount ] = aItem;
978cdf0e10cSrcweir             nCount += 1;
979cdf0e10cSrcweir         }
980cdf0e10cSrcweir     }
981cdf0e10cSrcweir 
982cdf0e10cSrcweir     storeIgnoredUpdates();
983cdf0e10cSrcweir     createNotifyJob( bPrepareOnly, aItemList );
984cdf0e10cSrcweir }
985cdf0e10cSrcweir 
986cdf0e10cSrcweir // *********************************************************************************
987cdf0e10cSrcweir 
initDescription()988cdf0e10cSrcweir void UpdateDialog::initDescription()
989cdf0e10cSrcweir {
990cdf0e10cSrcweir     m_PublisherLabel.Hide();
991cdf0e10cSrcweir     m_PublisherLink.Hide();
992cdf0e10cSrcweir     m_ReleaseNotesLabel.Hide();
993cdf0e10cSrcweir     m_ReleaseNotesLink.Hide();
994cdf0e10cSrcweir     m_descriptions.Hide();
995cdf0e10cSrcweir 
996cdf0e10cSrcweir     Link aLink = LINK( this, UpdateDialog, hyperlink_clicked );
997cdf0e10cSrcweir     m_PublisherLink.SetClickHdl( aLink );
998cdf0e10cSrcweir     m_ReleaseNotesLink.SetClickHdl( aLink );
999cdf0e10cSrcweir 
1000cdf0e10cSrcweir     long nTextWidth = m_PublisherLabel.GetCtrlTextWidth( m_PublisherLabel.GetText() );
1001cdf0e10cSrcweir     long nTemp = m_ReleaseNotesLabel.GetTextWidth( m_ReleaseNotesLabel.GetText() );
1002cdf0e10cSrcweir     if ( nTemp > nTextWidth )
1003cdf0e10cSrcweir         nTextWidth = nTemp;
1004cdf0e10cSrcweir     nTextWidth = nTextWidth * 110 / 100;
1005cdf0e10cSrcweir 
1006cdf0e10cSrcweir     Size aNewSize = m_PublisherLabel.GetSizePixel();
1007cdf0e10cSrcweir     if ( nTextWidth > aNewSize.Width() )
1008cdf0e10cSrcweir     {
1009cdf0e10cSrcweir         long nDelta = nTextWidth - aNewSize.Width();
1010cdf0e10cSrcweir         aNewSize.Width() = nTextWidth;
1011cdf0e10cSrcweir         m_PublisherLabel.SetSizePixel( aNewSize );
1012cdf0e10cSrcweir         m_ReleaseNotesLabel.SetSizePixel( aNewSize );
1013cdf0e10cSrcweir 
1014cdf0e10cSrcweir         aNewSize = m_PublisherLink.GetSizePixel();
1015cdf0e10cSrcweir         aNewSize.Width() = aNewSize.Width() - nDelta;
1016cdf0e10cSrcweir         Point aNewPos = m_PublisherLink.GetPosPixel();
1017cdf0e10cSrcweir         aNewPos.X() = aNewPos.X() + nDelta;
1018cdf0e10cSrcweir         m_PublisherLink.SetPosSizePixel( aNewPos, aNewSize );
1019cdf0e10cSrcweir         aNewPos.Y() = m_ReleaseNotesLink.GetPosPixel().Y();
1020cdf0e10cSrcweir         m_ReleaseNotesLink.SetPosSizePixel( aNewPos, aNewSize );
1021cdf0e10cSrcweir     }
1022cdf0e10cSrcweir 
1023cdf0e10cSrcweir     m_aFirstLinePos = m_descriptions.GetPosPixel();
1024cdf0e10cSrcweir     m_aFirstLineSize = m_descriptions.GetSizePixel();
1025cdf0e10cSrcweir     Size aMarginSize = LogicToPixel( Size( RSC_SP_CTRL_GROUP_X, RSC_SP_CTRL_GROUP_Y ), MAP_APPFONT );
1026cdf0e10cSrcweir     Point aThirdLinePos = m_ReleaseNotesLabel.GetPosPixel();
1027cdf0e10cSrcweir     aThirdLinePos.Y() = aThirdLinePos.Y() + m_ReleaseNotesLabel.GetSizePixel().Height() + aMarginSize.Height();
1028cdf0e10cSrcweir     m_nFirstLineDelta = aThirdLinePos.Y() - m_aFirstLinePos.Y();
1029cdf0e10cSrcweir     m_nOneLineMissing = m_ReleaseNotesLabel.GetPosPixel().Y() - m_PublisherLabel.GetPosPixel().Y();
1030cdf0e10cSrcweir }
1031cdf0e10cSrcweir 
clearDescription()1032cdf0e10cSrcweir void UpdateDialog::clearDescription()
1033cdf0e10cSrcweir {
1034cdf0e10cSrcweir     String sEmpty;
1035cdf0e10cSrcweir     m_PublisherLabel.Hide();
1036cdf0e10cSrcweir     m_PublisherLink.Hide();
1037cdf0e10cSrcweir     m_PublisherLink.SetDescription( sEmpty );
1038cdf0e10cSrcweir     m_PublisherLink.SetURL( sEmpty );
1039cdf0e10cSrcweir     m_ReleaseNotesLabel.Hide();
1040cdf0e10cSrcweir     m_ReleaseNotesLink.Hide();
1041cdf0e10cSrcweir     m_ReleaseNotesLink.SetURL( sEmpty );
1042cdf0e10cSrcweir     if ( m_PublisherLabel.GetPosPixel().Y() == m_ReleaseNotesLabel.GetPosPixel().Y() )
1043cdf0e10cSrcweir     {
1044cdf0e10cSrcweir         Point aNewPos = m_ReleaseNotesLabel.GetPosPixel();
1045cdf0e10cSrcweir         aNewPos.Y() += m_nOneLineMissing;
1046cdf0e10cSrcweir         m_ReleaseNotesLabel.SetPosPixel( aNewPos );
1047cdf0e10cSrcweir         aNewPos = m_ReleaseNotesLink.GetPosPixel();
1048cdf0e10cSrcweir         aNewPos.Y() += m_nOneLineMissing;
1049cdf0e10cSrcweir         m_ReleaseNotesLink.SetPosPixel( aNewPos );
1050cdf0e10cSrcweir     }
1051cdf0e10cSrcweir     m_descriptions.Hide();
1052cdf0e10cSrcweir     m_descriptions.Clear();
1053cdf0e10cSrcweir     m_descriptions.SetPosSizePixel( m_aFirstLinePos, m_aFirstLineSize );
1054cdf0e10cSrcweir }
1055cdf0e10cSrcweir 
showDescription(uno::Reference<xml::dom::XNode> const & aUpdateInfo)1056cdf0e10cSrcweir bool UpdateDialog::showDescription(uno::Reference< xml::dom::XNode > const & aUpdateInfo)
1057cdf0e10cSrcweir {
1058cdf0e10cSrcweir     dp_misc::DescriptionInfoset infoset(m_context, aUpdateInfo);
1059cdf0e10cSrcweir     return showDescription(infoset.getLocalizedPublisherNameAndURL(),
1060cdf0e10cSrcweir                            infoset.getLocalizedReleaseNotesURL());
1061cdf0e10cSrcweir }
1062cdf0e10cSrcweir 
showDescription(uno::Reference<deployment::XPackage> const & aExtension)1063cdf0e10cSrcweir bool UpdateDialog::showDescription(uno::Reference< deployment::XPackage > const & aExtension)
1064cdf0e10cSrcweir {
1065cdf0e10cSrcweir     OSL_ASSERT(aExtension.is());
1066cdf0e10cSrcweir     beans::StringPair pubInfo = aExtension->getPublisherInfo();
1067cdf0e10cSrcweir     return showDescription(std::make_pair(pubInfo.First, pubInfo.Second),
1068cdf0e10cSrcweir                            OUSTR(""));
1069cdf0e10cSrcweir }
1070cdf0e10cSrcweir 
showDescription(std::pair<rtl::OUString,rtl::OUString> const & pairPublisher,rtl::OUString const & sReleaseNotes)1071cdf0e10cSrcweir bool UpdateDialog::showDescription(std::pair< rtl::OUString, rtl::OUString > const & pairPublisher,
1072cdf0e10cSrcweir                                    rtl::OUString const & sReleaseNotes)
1073cdf0e10cSrcweir {
1074cdf0e10cSrcweir     rtl::OUString sPub = pairPublisher.first;
1075cdf0e10cSrcweir     rtl::OUString sURL = pairPublisher.second;
1076cdf0e10cSrcweir 
1077cdf0e10cSrcweir     if ( sPub.getLength() == 0 && sURL.getLength() == 0 && sReleaseNotes.getLength() == 0 )
1078cdf0e10cSrcweir         // nothing to show
1079cdf0e10cSrcweir         return false;
1080cdf0e10cSrcweir 
1081cdf0e10cSrcweir     bool bPublisher = false;
1082cdf0e10cSrcweir     if ( sPub.getLength() > 0 )
1083cdf0e10cSrcweir     {
1084cdf0e10cSrcweir         m_PublisherLabel.Show();
1085cdf0e10cSrcweir         m_PublisherLink.Show();
1086cdf0e10cSrcweir         m_PublisherLink.SetDescription( sPub );
1087cdf0e10cSrcweir         m_PublisherLink.SetURL( sURL );
1088cdf0e10cSrcweir         bPublisher = true;
1089cdf0e10cSrcweir     }
1090cdf0e10cSrcweir 
1091cdf0e10cSrcweir     if ( sReleaseNotes.getLength() > 0 )
1092cdf0e10cSrcweir     {
1093cdf0e10cSrcweir         if ( !bPublisher )
1094cdf0e10cSrcweir         {
1095cdf0e10cSrcweir             m_ReleaseNotesLabel.SetPosPixel( m_PublisherLabel.GetPosPixel() );
1096cdf0e10cSrcweir             m_ReleaseNotesLink.SetPosPixel( m_PublisherLink.GetPosPixel() );
1097cdf0e10cSrcweir         }
1098cdf0e10cSrcweir         m_ReleaseNotesLabel.Show();
1099cdf0e10cSrcweir         m_ReleaseNotesLink.Show();
1100cdf0e10cSrcweir         m_ReleaseNotesLink.SetURL( sReleaseNotes );
1101cdf0e10cSrcweir     }
1102cdf0e10cSrcweir     return true;
1103cdf0e10cSrcweir }
1104cdf0e10cSrcweir 
showDescription(const String & rDescription,bool bWithPublisher)1105cdf0e10cSrcweir bool UpdateDialog::showDescription( const String& rDescription, bool bWithPublisher )
1106cdf0e10cSrcweir {
1107cdf0e10cSrcweir     if ( rDescription.Len() == 0 )
1108cdf0e10cSrcweir         // nothing to show
1109cdf0e10cSrcweir         return false;
1110cdf0e10cSrcweir 
1111cdf0e10cSrcweir     if ( bWithPublisher )
1112cdf0e10cSrcweir     {
1113cdf0e10cSrcweir         bool bOneLineMissing = !m_ReleaseNotesLabel.IsVisible() || !m_PublisherLabel.IsVisible();
1114cdf0e10cSrcweir         Point aNewPos = m_aFirstLinePos;
1115cdf0e10cSrcweir         aNewPos.Y() += m_nFirstLineDelta;
1116cdf0e10cSrcweir         if ( bOneLineMissing )
1117cdf0e10cSrcweir             aNewPos.Y() -= m_nOneLineMissing;
1118cdf0e10cSrcweir         Size aNewSize = m_aFirstLineSize;
1119cdf0e10cSrcweir         aNewSize.Height() -= m_nFirstLineDelta;
1120cdf0e10cSrcweir         if ( bOneLineMissing )
1121cdf0e10cSrcweir             aNewSize.Height() += m_nOneLineMissing;
1122cdf0e10cSrcweir         m_descriptions.SetPosSizePixel( aNewPos, aNewSize );
1123cdf0e10cSrcweir     }
1124cdf0e10cSrcweir     m_descriptions.Show();
1125cdf0e10cSrcweir     m_descriptions.SetDescription( rDescription );
1126cdf0e10cSrcweir     return true;
1127cdf0e10cSrcweir }
1128cdf0e10cSrcweir 
isReadOnly(const uno::Reference<deployment::XPackage> & xPackage) const1129cdf0e10cSrcweir bool UpdateDialog::isReadOnly( const uno::Reference< deployment::XPackage > &xPackage ) const
1130cdf0e10cSrcweir {
1131cdf0e10cSrcweir     if ( m_xExtensionManager.is() && xPackage.is() )
1132cdf0e10cSrcweir     {
1133cdf0e10cSrcweir         return m_xExtensionManager->isReadOnlyRepository( xPackage->getRepositoryName() );
1134cdf0e10cSrcweir     }
1135cdf0e10cSrcweir     else
1136cdf0e10cSrcweir         return true;
1137cdf0e10cSrcweir }
1138cdf0e10cSrcweir 
1139cdf0e10cSrcweir //------------------------------------------------------------------------------
getIgnoredUpdates()1140cdf0e10cSrcweir void UpdateDialog::getIgnoredUpdates()
1141cdf0e10cSrcweir {
1142cdf0e10cSrcweir     uno::Reference< lang::XMultiServiceFactory > xConfig( m_context->getServiceManager()->createInstanceWithContext(
1143cdf0e10cSrcweir         OUSTR("com.sun.star.configuration.ConfigurationProvider"), m_context ), uno::UNO_QUERY_THROW);
1144cdf0e10cSrcweir     beans::NamedValue aValue( OUSTR("nodepath"), uno::Any( IGNORED_UPDATES ) );
1145cdf0e10cSrcweir     uno::Sequence< uno::Any > args(1);
1146cdf0e10cSrcweir     args[0] <<= aValue;
1147cdf0e10cSrcweir 
1148cdf0e10cSrcweir     uno::Reference< container::XNameAccess > xNameAccess( xConfig->createInstanceWithArguments( OUSTR("com.sun.star.configuration.ConfigurationAccess"), args), uno::UNO_QUERY_THROW );
1149cdf0e10cSrcweir     uno::Sequence< rtl::OUString > aElementNames = xNameAccess->getElementNames();
1150cdf0e10cSrcweir 
1151cdf0e10cSrcweir     for ( sal_Int32 i = 0; i < aElementNames.getLength(); i++ )
1152cdf0e10cSrcweir     {
1153cdf0e10cSrcweir         ::rtl::OUString aIdentifier = aElementNames[i];
1154cdf0e10cSrcweir         ::rtl::OUString aVersion;
1155cdf0e10cSrcweir 
1156cdf0e10cSrcweir         uno::Any aPropValue( uno::Reference< beans::XPropertySet >( xNameAccess->getByName( aIdentifier ), uno::UNO_QUERY_THROW )->getPropertyValue( PROPERTY_VERSION ) );
1157cdf0e10cSrcweir         aPropValue >>= aVersion;
1158cdf0e10cSrcweir         IgnoredUpdate *pData = new IgnoredUpdate( aIdentifier, aVersion );
1159cdf0e10cSrcweir         m_ignoredUpdates.push_back( pData );
1160cdf0e10cSrcweir     }
1161cdf0e10cSrcweir }
1162cdf0e10cSrcweir 
1163cdf0e10cSrcweir //------------------------------------------------------------------------------
storeIgnoredUpdates()1164cdf0e10cSrcweir void UpdateDialog::storeIgnoredUpdates()
1165cdf0e10cSrcweir {
1166cdf0e10cSrcweir     if ( m_bModified && ( m_ignoredUpdates.size() != 0 ) )
1167cdf0e10cSrcweir     {
1168cdf0e10cSrcweir         uno::Reference< lang::XMultiServiceFactory > xConfig( m_context->getServiceManager()->createInstanceWithContext(
1169cdf0e10cSrcweir             OUSTR("com.sun.star.configuration.ConfigurationProvider"), m_context ), uno::UNO_QUERY_THROW );
1170cdf0e10cSrcweir         beans::NamedValue aValue( OUSTR("nodepath"), uno::Any( IGNORED_UPDATES ) );
1171cdf0e10cSrcweir         uno::Sequence< uno::Any > args(1);
1172cdf0e10cSrcweir         args[0] <<= aValue;
1173cdf0e10cSrcweir 
1174cdf0e10cSrcweir         uno::Reference< container::XNameContainer > xNameContainer( xConfig->createInstanceWithArguments(
1175cdf0e10cSrcweir             OUSTR("com.sun.star.configuration.ConfigurationUpdateAccess"), args ), uno::UNO_QUERY_THROW );
1176cdf0e10cSrcweir 
1177cdf0e10cSrcweir         for ( std::vector< UpdateDialog::IgnoredUpdate* >::iterator i( m_ignoredUpdates.begin() ); i != m_ignoredUpdates.end(); ++i )
1178cdf0e10cSrcweir         {
1179cdf0e10cSrcweir             if ( xNameContainer->hasByName( (*i)->sExtensionID ) )
1180cdf0e10cSrcweir             {
1181cdf0e10cSrcweir                 if ( (*i)->bRemoved )
1182cdf0e10cSrcweir                     xNameContainer->removeByName( (*i)->sExtensionID );
1183cdf0e10cSrcweir                 else
1184cdf0e10cSrcweir                     uno::Reference< beans::XPropertySet >( xNameContainer->getByName( (*i)->sExtensionID ), uno::UNO_QUERY_THROW )->setPropertyValue( PROPERTY_VERSION, uno::Any( (*i)->sVersion ) );
1185cdf0e10cSrcweir             }
1186cdf0e10cSrcweir             else if ( ! (*i)->bRemoved )
1187cdf0e10cSrcweir             {
1188cdf0e10cSrcweir                 uno::Reference< beans::XPropertySet > elem( uno::Reference< lang::XSingleServiceFactory >( xNameContainer, uno::UNO_QUERY_THROW )->createInstance(), uno::UNO_QUERY_THROW );
1189cdf0e10cSrcweir                 elem->setPropertyValue( PROPERTY_VERSION, uno::Any( (*i)->sVersion ) );
1190cdf0e10cSrcweir                 xNameContainer->insertByName( (*i)->sExtensionID, uno::Any( elem ) );
1191cdf0e10cSrcweir             }
1192cdf0e10cSrcweir         }
1193cdf0e10cSrcweir 
1194cdf0e10cSrcweir         uno::Reference< util::XChangesBatch > xChangesBatch( xNameContainer, uno::UNO_QUERY );
1195cdf0e10cSrcweir         if ( xChangesBatch.is() && xChangesBatch->hasPendingChanges() )
1196cdf0e10cSrcweir             xChangesBatch->commitChanges();
1197cdf0e10cSrcweir     }
1198cdf0e10cSrcweir 
1199cdf0e10cSrcweir     m_bModified = false;
1200cdf0e10cSrcweir }
1201cdf0e10cSrcweir 
1202cdf0e10cSrcweir //------------------------------------------------------------------------------
isIgnoredUpdate(UpdateDialog::Index * index)1203cdf0e10cSrcweir bool UpdateDialog::isIgnoredUpdate( UpdateDialog::Index * index )
1204cdf0e10cSrcweir {
1205cdf0e10cSrcweir     bool bIsIgnored = false;
1206cdf0e10cSrcweir 
1207cdf0e10cSrcweir     if ( m_ignoredUpdates.size() != 0 )
1208cdf0e10cSrcweir     {
1209cdf0e10cSrcweir         rtl::OUString aExtensionID;
1210cdf0e10cSrcweir         rtl::OUString aVersion;
1211cdf0e10cSrcweir 
1212cdf0e10cSrcweir         if ( index->m_eKind == ENABLED_UPDATE )
1213cdf0e10cSrcweir         {
1214cdf0e10cSrcweir             dp_gui::UpdateData aUpdData = m_enabledUpdates[ index->m_nIndex ];
1215cdf0e10cSrcweir             aExtensionID = dp_misc::getIdentifier( aUpdData.aInstalledPackage );
1216cdf0e10cSrcweir             aVersion = aUpdData.updateVersion;
1217cdf0e10cSrcweir         }
1218cdf0e10cSrcweir         else if ( index->m_eKind == DISABLED_UPDATE )
1219cdf0e10cSrcweir         {
1220cdf0e10cSrcweir             DisabledUpdate &rData = m_disabledUpdates[ index->m_nIndex ];
1221cdf0e10cSrcweir             dp_misc::DescriptionInfoset aInfoset( m_context, rData.aUpdateInfo );
1222cdf0e10cSrcweir             ::boost::optional< ::rtl::OUString > aID( aInfoset.getIdentifier() );
1223cdf0e10cSrcweir             if ( aID )
1224cdf0e10cSrcweir                 aExtensionID = *aID;
1225cdf0e10cSrcweir             aVersion = aInfoset.getVersion();
1226cdf0e10cSrcweir         }
1227cdf0e10cSrcweir 
1228cdf0e10cSrcweir         for ( std::vector< UpdateDialog::IgnoredUpdate* >::iterator i( m_ignoredUpdates.begin() ); i != m_ignoredUpdates.end(); ++i )
1229cdf0e10cSrcweir         {
1230cdf0e10cSrcweir             if ( (*i)->sExtensionID == aExtensionID )
1231cdf0e10cSrcweir             {
1232cdf0e10cSrcweir                 if ( ( (*i)->sVersion.getLength() == 0 ) || ( (*i)->sVersion == aVersion ) )
1233cdf0e10cSrcweir                 {
1234cdf0e10cSrcweir                     bIsIgnored = true;
1235cdf0e10cSrcweir                     index->m_bIgnored = true;
1236cdf0e10cSrcweir                 }
1237cdf0e10cSrcweir                 else // when we find another update of an ignored version, we will remove the old one to keep the ignored list small
1238cdf0e10cSrcweir                     (*i)->bRemoved = true;
1239cdf0e10cSrcweir                 break;
1240cdf0e10cSrcweir             }
1241cdf0e10cSrcweir         }
1242cdf0e10cSrcweir     }
1243cdf0e10cSrcweir 
1244cdf0e10cSrcweir     return bIsIgnored;
1245cdf0e10cSrcweir }
1246cdf0e10cSrcweir 
1247cdf0e10cSrcweir //------------------------------------------------------------------------------
setIgnoredUpdate(UpdateDialog::Index * pIndex,bool bIgnore,bool bIgnoreAll)1248cdf0e10cSrcweir void UpdateDialog::setIgnoredUpdate( UpdateDialog::Index *pIndex, bool bIgnore, bool bIgnoreAll )
1249cdf0e10cSrcweir {
1250cdf0e10cSrcweir     rtl::OUString aExtensionID;
1251cdf0e10cSrcweir     rtl::OUString aVersion;
1252cdf0e10cSrcweir 
1253cdf0e10cSrcweir     m_bModified = true;
1254cdf0e10cSrcweir 
1255cdf0e10cSrcweir     if ( pIndex->m_eKind == ENABLED_UPDATE )
1256cdf0e10cSrcweir     {
1257cdf0e10cSrcweir         dp_gui::UpdateData aUpdData = m_enabledUpdates[ pIndex->m_nIndex ];
1258cdf0e10cSrcweir         aExtensionID = dp_misc::getIdentifier( aUpdData.aInstalledPackage );
1259cdf0e10cSrcweir         if ( !bIgnoreAll )
1260cdf0e10cSrcweir             aVersion = aUpdData.updateVersion;
1261cdf0e10cSrcweir     }
1262cdf0e10cSrcweir     else if ( pIndex->m_eKind == DISABLED_UPDATE )
1263cdf0e10cSrcweir     {
1264cdf0e10cSrcweir         DisabledUpdate &rData = m_disabledUpdates[ pIndex->m_nIndex ];
1265cdf0e10cSrcweir         dp_misc::DescriptionInfoset aInfoset( m_context, rData.aUpdateInfo );
1266cdf0e10cSrcweir         ::boost::optional< ::rtl::OUString > aID( aInfoset.getIdentifier() );
1267cdf0e10cSrcweir         if ( aID )
1268cdf0e10cSrcweir             aExtensionID = *aID;
1269cdf0e10cSrcweir         if ( !bIgnoreAll )
1270cdf0e10cSrcweir             aVersion = aInfoset.getVersion();
1271cdf0e10cSrcweir     }
1272cdf0e10cSrcweir 
1273cdf0e10cSrcweir     if ( aExtensionID.getLength() )
1274cdf0e10cSrcweir     {
1275cdf0e10cSrcweir         bool bFound = false;
1276cdf0e10cSrcweir         for ( std::vector< UpdateDialog::IgnoredUpdate* >::iterator i( m_ignoredUpdates.begin() ); i != m_ignoredUpdates.end(); ++i )
1277cdf0e10cSrcweir         {
1278cdf0e10cSrcweir             if ( (*i)->sExtensionID == aExtensionID )
1279cdf0e10cSrcweir             {
1280cdf0e10cSrcweir                 (*i)->sVersion = aVersion;
1281cdf0e10cSrcweir                 (*i)->bRemoved = !bIgnore;
1282cdf0e10cSrcweir                 bFound = true;
1283cdf0e10cSrcweir                 break;
1284cdf0e10cSrcweir             }
1285cdf0e10cSrcweir         }
1286cdf0e10cSrcweir         if ( bIgnore && !bFound )
1287cdf0e10cSrcweir         {
1288cdf0e10cSrcweir             IgnoredUpdate *pData = new IgnoredUpdate( aExtensionID, aVersion );
1289cdf0e10cSrcweir             m_ignoredUpdates.push_back( pData );
1290cdf0e10cSrcweir         }
1291cdf0e10cSrcweir     }
1292cdf0e10cSrcweir }
1293cdf0e10cSrcweir 
1294cdf0e10cSrcweir //------------------------------------------------------------------------------
IMPL_LINK(UpdateDialog,selectionHandler,void *,EMPTYARG)1295cdf0e10cSrcweir IMPL_LINK(UpdateDialog, selectionHandler, void *, EMPTYARG)
1296cdf0e10cSrcweir {
1297cdf0e10cSrcweir     rtl::OUStringBuffer b;
1298cdf0e10cSrcweir     bool bInserted = false;
1299cdf0e10cSrcweir     UpdateDialog::Index const * p = static_cast< UpdateDialog::Index const * >(
1300cdf0e10cSrcweir         m_updates.GetEntryData(m_updates.GetSelectEntryPos()));
1301cdf0e10cSrcweir     clearDescription();
1302cdf0e10cSrcweir 
1303cdf0e10cSrcweir     if ( p != NULL )
1304cdf0e10cSrcweir     {
1305cdf0e10cSrcweir         sal_uInt16 pos = p->m_nIndex;
1306cdf0e10cSrcweir 
1307cdf0e10cSrcweir         switch (p->m_eKind)
1308cdf0e10cSrcweir         {
1309cdf0e10cSrcweir             case ENABLED_UPDATE:
1310cdf0e10cSrcweir             {
1311cdf0e10cSrcweir                 if ( m_enabledUpdates[ pos ].aUpdateSource.is() )
1312cdf0e10cSrcweir                     bInserted = showDescription( m_enabledUpdates[ pos ].aUpdateSource );
1313cdf0e10cSrcweir                 else
1314cdf0e10cSrcweir                     bInserted = showDescription( m_enabledUpdates[ pos ].aUpdateInfo );
1315cdf0e10cSrcweir 
1316cdf0e10cSrcweir                 if ( p->m_bIgnored )
1317cdf0e10cSrcweir                     b.append( m_ignoredUpdate );
1318cdf0e10cSrcweir 
1319cdf0e10cSrcweir                 break;
1320cdf0e10cSrcweir             }
1321cdf0e10cSrcweir             case DISABLED_UPDATE:
1322cdf0e10cSrcweir             {
1323cdf0e10cSrcweir                 bInserted = showDescription( m_disabledUpdates[pos].aUpdateInfo );
1324cdf0e10cSrcweir 
1325cdf0e10cSrcweir                 if ( p->m_bIgnored )
1326cdf0e10cSrcweir                     b.append( m_ignoredUpdate );
1327cdf0e10cSrcweir 
1328cdf0e10cSrcweir                 UpdateDialog::DisabledUpdate & data = m_disabledUpdates[ pos ];
1329cdf0e10cSrcweir                 if (data.unsatisfiedDependencies.getLength() != 0)
1330cdf0e10cSrcweir                 {
1331cdf0e10cSrcweir                     // create error string for version mismatch
1332cdf0e10cSrcweir                     ::rtl::OUString sVersion( RTL_CONSTASCII_USTRINGPARAM("%VERSION") );
1333cdf0e10cSrcweir                     sal_Int32 nPos = m_noDependencyCurVer.indexOf( sVersion );
1334cdf0e10cSrcweir                     if ( nPos >= 0 )
1335cdf0e10cSrcweir                     {
1336cdf0e10cSrcweir                         ::rtl::OUString sCurVersion( RTL_CONSTASCII_USTRINGPARAM( "${$OOO_BASE_DIR/program/" SAL_CONFIGFILE("version") ":Version:OOOPackageVersion}"));
1337cdf0e10cSrcweir                         ::rtl::Bootstrap::expandMacros(sCurVersion);
1338cdf0e10cSrcweir                         m_noDependencyCurVer = m_noDependencyCurVer.replaceAt( nPos, sVersion.getLength(), sCurVersion );
1339cdf0e10cSrcweir                     }
1340cdf0e10cSrcweir 
1341cdf0e10cSrcweir                     b.append(m_noInstall);
1342cdf0e10cSrcweir                     b.append(LF);
1343cdf0e10cSrcweir                     b.append(m_noDependency);
1344cdf0e10cSrcweir                     for (sal_Int32 i = 0;
1345cdf0e10cSrcweir                          i < data.unsatisfiedDependencies.getLength(); ++i)
1346cdf0e10cSrcweir                     {
1347cdf0e10cSrcweir                         b.append(LF);
1348cdf0e10cSrcweir                         b.appendAscii(RTL_CONSTASCII_STRINGPARAM("  "));
1349cdf0e10cSrcweir                             // U+2003 EM SPACE would be better than two spaces,
1350cdf0e10cSrcweir                             // but some fonts do not contain it
1351cdf0e10cSrcweir                         b.append(
1352cdf0e10cSrcweir                             confineToParagraph(
1353cdf0e10cSrcweir                                 data.unsatisfiedDependencies[i]));
1354cdf0e10cSrcweir                     }
1355cdf0e10cSrcweir                     b.append(LF);
1356cdf0e10cSrcweir                     b.appendAscii(RTL_CONSTASCII_STRINGPARAM("  "));
1357cdf0e10cSrcweir                     b.append(m_noDependencyCurVer);
1358cdf0e10cSrcweir                 }
1359cdf0e10cSrcweir                 break;
1360cdf0e10cSrcweir             }
1361cdf0e10cSrcweir             case SPECIFIC_ERROR:
1362cdf0e10cSrcweir             {
1363cdf0e10cSrcweir                 UpdateDialog::SpecificError & data = m_specificErrors[ pos ];
1364cdf0e10cSrcweir                 b.append(m_failure);
1365cdf0e10cSrcweir                 b.append(LF);
1366cdf0e10cSrcweir                 b.append( data.message.getLength() == 0 ? m_unknownError : data.message );
1367cdf0e10cSrcweir                 break;
1368cdf0e10cSrcweir             }
1369cdf0e10cSrcweir             default:
1370cdf0e10cSrcweir                 OSL_ASSERT(false);
1371cdf0e10cSrcweir                 break;
1372cdf0e10cSrcweir         }
1373cdf0e10cSrcweir     }
1374cdf0e10cSrcweir 
1375cdf0e10cSrcweir     if ( b.getLength() == 0 )
1376cdf0e10cSrcweir         b.append( m_noDescription );
1377cdf0e10cSrcweir 
1378cdf0e10cSrcweir     showDescription( b.makeStringAndClear(), bInserted );
1379cdf0e10cSrcweir     return 0;
1380cdf0e10cSrcweir }
1381cdf0e10cSrcweir 
IMPL_LINK(UpdateDialog,allHandler,void *,EMPTYARG)1382cdf0e10cSrcweir IMPL_LINK(UpdateDialog, allHandler, void *, EMPTYARG)
1383cdf0e10cSrcweir {
1384cdf0e10cSrcweir     if (m_all.IsChecked())
1385cdf0e10cSrcweir     {
1386cdf0e10cSrcweir         m_update.Enable();
1387cdf0e10cSrcweir         m_updates.Enable();
1388cdf0e10cSrcweir         m_description.Enable();
1389cdf0e10cSrcweir         m_descriptions.Enable();
1390cdf0e10cSrcweir 
1391cdf0e10cSrcweir         for (std::vector< UpdateDialog::Index* >::iterator i( m_ListboxEntries.begin() );
1392cdf0e10cSrcweir              i != m_ListboxEntries.end(); ++i )
1393cdf0e10cSrcweir         {
1394cdf0e10cSrcweir             if ( (*i)->m_bIgnored || ( (*i)->m_eKind != ENABLED_UPDATE ) )
1395cdf0e10cSrcweir                 insertItem( (*i), SvLBoxButtonKind_disabledCheckbox );
1396cdf0e10cSrcweir         }
1397cdf0e10cSrcweir     }
1398cdf0e10cSrcweir     else
1399cdf0e10cSrcweir     {
1400cdf0e10cSrcweir         for ( sal_uInt16 i = 0; i < m_updates.getItemCount(); )
1401cdf0e10cSrcweir         {
1402cdf0e10cSrcweir             UpdateDialog::Index const * p = static_cast< UpdateDialog::Index const * >( m_updates.GetEntryData(i) );
1403cdf0e10cSrcweir             if ( p->m_bIgnored || ( p->m_eKind != ENABLED_UPDATE ) )
1404cdf0e10cSrcweir             {
1405cdf0e10cSrcweir                 m_updates.RemoveEntry(i);
1406cdf0e10cSrcweir             } else {
1407cdf0e10cSrcweir                 ++i;
1408cdf0e10cSrcweir             }
1409cdf0e10cSrcweir         }
1410cdf0e10cSrcweir 
1411cdf0e10cSrcweir         if (m_updates.getItemCount() == 0)
1412cdf0e10cSrcweir         {
1413cdf0e10cSrcweir             clearDescription();
1414cdf0e10cSrcweir             m_update.Disable();
1415cdf0e10cSrcweir             m_updates.Disable();
1416cdf0e10cSrcweir             if (m_checking.IsVisible())
1417cdf0e10cSrcweir                 m_description.Disable();
1418cdf0e10cSrcweir             else
1419cdf0e10cSrcweir                 showDescription(m_noInstallable,false);
1420cdf0e10cSrcweir         }
1421cdf0e10cSrcweir     }
1422cdf0e10cSrcweir     return 0;
1423cdf0e10cSrcweir }
1424cdf0e10cSrcweir 
IMPL_LINK(UpdateDialog,okHandler,void *,EMPTYARG)1425cdf0e10cSrcweir IMPL_LINK(UpdateDialog, okHandler, void *, EMPTYARG)
1426cdf0e10cSrcweir {
1427cdf0e10cSrcweir     //If users are going to update a shared extension then we need
1428cdf0e10cSrcweir     //to warn them
1429cdf0e10cSrcweir     typedef ::std::vector<UpdateData>::const_iterator CIT;
1430cdf0e10cSrcweir     for (CIT i = m_enabledUpdates.begin(); i < m_enabledUpdates.end(); i++)
1431cdf0e10cSrcweir     {
1432cdf0e10cSrcweir         OSL_ASSERT(i->aInstalledPackage.is());
1433cdf0e10cSrcweir         //If the user has no write access to the shared folder then the update
1434cdf0e10cSrcweir         //for a shared extension is disable, that is it cannot be in m_enabledUpdates
1435cdf0e10cSrcweir //        OSL_ASSERT(isReadOnly(i->aInstalledPackage) == sal_False);
1436cdf0e10cSrcweir #if 0
1437cdf0e10cSrcweir         // TODO: check!
1438cdf0e10cSrcweir         OSL_ASSERT(m_extensionManagerDialog.get());
1439cdf0e10cSrcweir         if (RET_CANCEL == m_extensionManagerDialog->continueUpdateForSharedExtension(
1440cdf0e10cSrcweir             this, i->aPackageManager))
1441cdf0e10cSrcweir         {
1442cdf0e10cSrcweir             EndDialog(RET_CANCEL);
1443cdf0e10cSrcweir         }
1444cdf0e10cSrcweir #endif
1445cdf0e10cSrcweir     }
1446cdf0e10cSrcweir 
1447cdf0e10cSrcweir 
1448cdf0e10cSrcweir     for (sal_uInt16 i = 0; i < m_updates.getItemCount(); ++i) {
1449cdf0e10cSrcweir         UpdateDialog::Index const * p =
1450cdf0e10cSrcweir             static_cast< UpdateDialog::Index const * >(
1451cdf0e10cSrcweir                 m_updates.GetEntryData(i));
1452cdf0e10cSrcweir         if (p->m_eKind == ENABLED_UPDATE && m_updates.IsChecked(i)) {
1453cdf0e10cSrcweir             m_updateData.push_back( m_enabledUpdates[ p->m_nIndex ] );
1454cdf0e10cSrcweir         }
1455cdf0e10cSrcweir     }
1456cdf0e10cSrcweir 
1457cdf0e10cSrcweir     EndDialog(RET_OK);
1458cdf0e10cSrcweir     return 0;
1459cdf0e10cSrcweir }
1460cdf0e10cSrcweir 
IMPL_LINK(UpdateDialog,closeHandler,void *,EMPTYARG)1461cdf0e10cSrcweir IMPL_LINK(UpdateDialog, closeHandler, void *, EMPTYARG) {
1462cdf0e10cSrcweir     m_thread->stop();
1463cdf0e10cSrcweir     EndDialog(RET_CANCEL);
1464cdf0e10cSrcweir     return 0;
1465cdf0e10cSrcweir }
1466cdf0e10cSrcweir 
IMPL_LINK(UpdateDialog,hyperlink_clicked,svt::FixedHyperlink *,pHyperlink)1467cdf0e10cSrcweir IMPL_LINK( UpdateDialog, hyperlink_clicked, svt::FixedHyperlink*, pHyperlink )
1468cdf0e10cSrcweir {
1469cdf0e10cSrcweir     ::rtl::OUString sURL;
1470cdf0e10cSrcweir     if ( pHyperlink )
1471cdf0e10cSrcweir         sURL = ::rtl::OUString( pHyperlink->GetURL() );
1472cdf0e10cSrcweir     if ( sURL.getLength() == 0 )
1473cdf0e10cSrcweir         return 0;
1474cdf0e10cSrcweir 
1475cdf0e10cSrcweir     try
1476cdf0e10cSrcweir     {
1477cdf0e10cSrcweir         uno::Reference< com::sun::star::system::XSystemShellExecute > xSystemShellExecute(
1478*9807c9deSAriel Constenla-Haile             com::sun::star::system::SystemShellExecute::create( m_context ) );
1479cdf0e10cSrcweir         xSystemShellExecute->execute(
1480cdf0e10cSrcweir                                      sURL, ::rtl::OUString(), com::sun::star::system::SystemShellExecuteFlags::DEFAULTS);
1481cdf0e10cSrcweir     }
1482cdf0e10cSrcweir     catch (uno::Exception& )
1483cdf0e10cSrcweir     {
1484cdf0e10cSrcweir     }
1485cdf0e10cSrcweir 
1486cdf0e10cSrcweir     return 1;
1487cdf0e10cSrcweir }
1488