summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorJoachim Lingner <jl@openoffice.org>2010-06-02 17:05:21 +0200
committerJoachim Lingner <jl@openoffice.org>2010-06-02 17:05:21 +0200
commita82d6ff3b4aa2453120cd1bcb3fb69c1d3e2aed2 (patch)
tree89ee6f0b96eefd0b1e9f8bd8503fe4364dcd2691 /desktop
parent04615ba86017896e0fb4bf951004ba2e4e22e6c9 (diff)
jl152 #i77196# bubble update notification now supports the new update behavior
Diffstat (limited to 'desktop')
-rwxr-xr-xdesktop/source/deployment/gui/dp_gui_dialog2.cxx1
-rwxr-xr-xdesktop/source/deployment/gui/dp_gui_theextmgr.cxx1
-rw-r--r--desktop/source/deployment/gui/dp_gui_updatedialog.cxx170
-rw-r--r--desktop/source/deployment/inc/dp_misc.h52
-rwxr-xr-xdesktop/source/deployment/inc/dp_update.hxx147
-rw-r--r--desktop/source/deployment/manager/dp_informationprovider.cxx275
-rw-r--r--desktop/source/deployment/misc/dp_misc.cxx152
-rwxr-xr-xdesktop/source/deployment/misc/dp_update.cxx397
-rw-r--r--desktop/source/deployment/misc/makefile.mk3
9 files changed, 679 insertions, 519 deletions
diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
index d34001393ba7..4ba747198c09 100755
--- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx
+++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
@@ -39,6 +39,7 @@
#include "dp_gui_theextmgr.hxx"
#include "dp_gui_extensioncmdqueue.hxx"
#include "dp_misc.h"
+#include "dp_update.hxx"
#include "dp_identifier.hxx"
#include "vcl/ctrl.hxx"
diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx
index 7bfcc79480b3..d0347c7cbf4e 100755
--- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx
+++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx
@@ -42,6 +42,7 @@
#include "dp_gui_theextmgr.hxx"
#include "dp_gui_theextmgr.hxx"
#include "dp_identifier.hxx"
+#include "dp_update.hxx"
#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx
index a27f04326b25..b27cd8da81fe 100644
--- a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx
+++ b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx
@@ -112,6 +112,7 @@
#include "dp_identifier.hxx"
#include "dp_version.hxx"
#include "dp_misc.h"
+#include "dp_update.hxx"
#include "dp_gui.h"
#include "dp_gui.hrc"
@@ -254,7 +255,7 @@ private:
};
// A multimap in case an extension is installed in "user", "shared" or "bundled"
- typedef std::multimap< rtl::OUString, Entry > Map;
+ typedef std::map< rtl::OUString, Entry > Map;
virtual ~Thread();
@@ -357,78 +358,44 @@ UpdateDialog::Thread::~Thread()
void UpdateDialog::Thread::execute()
{
- OSL_ASSERT( ! m_vExtensionList.empty() );
- Map map;
-
- typedef std::vector< css::uno::Reference< css::deployment::XPackage > >::const_iterator ITER;
- for ( ITER iIndex = m_vExtensionList.begin(); iIndex < m_vExtensionList.end(); ++iIndex )
{
- css::uno::Reference< css::deployment::XPackage > p = *iIndex;
- if ( p.is() )
- {
- {
- vos::OGuard g( Application::GetSolarMutex() );
- if ( m_stop ) {
- return;
- }
- }
- getOwnUpdateInformation( p, &map );
- }
- }
-
- const rtl::OUString sDefaultURL(dp_misc::getExtensionDefaultUpdateURL());
- if (sDefaultURL.getLength())
- {
- css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > >
- infos(
- getUpdateInformation(
- css::uno::Reference< css::deployment::XPackage >(),
- css::uno::Sequence< rtl::OUString >(&sDefaultURL, 1), rtl::OUString()));
- for (sal_Int32 i = 0; i < infos.getLength(); ++i) {
- css::uno::Reference< css::xml::dom::XNode > node(
- infos[i], css::uno::UNO_QUERY_THROW);
- dp_misc::DescriptionInfoset infoset(m_context, node);
- boost::optional< rtl::OUString > id(infoset.getIdentifier());
- if (!id) {
- continue;
- }
- Map::iterator end(map.upper_bound(*id));
- for (Map::iterator j(map.lower_bound(*id)); j != end; ++j) {
- //skip those extension which provide its own update urls
- if (j->second.bProvidesOwnUpdate)
- continue;
- rtl::OUString v(infoset.getVersion());
- //look for the highest version in the online repository
- if (dp_misc::compareVersions(v, j->second.version) ==
- dp_misc::GREATER)
- {
- j->second.version = v;
- j->second.info = node;
- }
- }
+ vos::OGuard g( Application::GetSolarMutex() );
+ if ( m_stop ) {
+ return;
}
}
-
css::uno::Reference<css::deployment::XExtensionManager> extMgr =
css::deployment::ExtensionManager::get(m_context);
- for (Map::iterator i(map.begin()); i != map.end(); ++i)
+
+ std::vector<std::pair<css::uno::Reference<css::deployment::XPackage>, css::uno::Any > > errors;
+
+ dp_misc::UpdateInfoMap updateInfoMap = dp_misc::getOnlineUpdateInfos(
+ m_context, extMgr, m_updateInformation, &m_vExtensionList, errors);
+
+ typedef std::vector<std::pair<css::uno::Reference<css::deployment::XPackage>,
+ css::uno::Any> >::const_iterator ITERROR;
+ for (ITERROR ite = errors.begin(); ite != errors.end(); ite ++)
+ handleSpecificError(ite->first, ite->second);
+
+ for (dp_misc::UpdateInfoMap::iterator i(updateInfoMap.begin()); i != updateInfoMap.end(); i++)
{
+ dp_misc::UpdateInfo const & info = i->second;
+ UpdateData updateData(info.extension);
+ DisabledUpdate disableUpdate;
//determine if online updates meet the requirements
- prepareUpdateData(i->second.info,
- i->second.disableUpdate, i->second.updateData);
+ prepareUpdateData(info.info, disableUpdate, updateData);
//determine if the update is installed in the user or shared repository
rtl::OUString sOnlineVersion;
- if (i->second.updateData.aUpdateInfo.is())
- sOnlineVersion = i->second.version;
-
+ if (info.info.is())
+ sOnlineVersion = info.version;
rtl::OUString sVersionUser;
rtl::OUString sVersionShared;
rtl::OUString sVersionBundled;
css::uno::Sequence< css::uno::Reference< css::deployment::XPackage> > extensions;
try {
extensions = extMgr->getExtensionsWithSameIdentifier(
- dp_misc::getIdentifier(i->second.package), i->second.package->getName(),
+ dp_misc::getIdentifier(info.extension), info.extension->getName(),
css::uno::Reference<css::ucb::XCommandEnvironment>());
} catch (css::lang::IllegalArgumentException& ) {
OSL_ASSERT(0);
@@ -453,15 +420,15 @@ void UpdateDialog::Thread::execute()
{
if (sourceUser == dp_misc::UPDATE_SOURCE_SHARED)
{
- i->second.updateData.aUpdateSource = extensions[1];
- i->second.updateData.updateVersion = extensions[1]->getVersion();
+ updateData.aUpdateSource = extensions[1];
+ updateData.updateVersion = extensions[1]->getVersion();
}
else if (sourceUser == dp_misc::UPDATE_SOURCE_BUNDLED)
{
- i->second.updateData.aUpdateSource = extensions[2];
- i->second.updateData.updateVersion = extensions[2]->getVersion();
+ updateData.aUpdateSource = extensions[2];
+ updateData.updateVersion = extensions[2]->getVersion();
}
- if (!update(i->second.disableUpdate, i->second.updateData))
+ if (!update(disableUpdate, updateData))
return;
}
@@ -469,11 +436,11 @@ void UpdateDialog::Thread::execute()
{
if (sourceShared == dp_misc::UPDATE_SOURCE_BUNDLED)
{
- i->second.updateData.aUpdateSource = extensions[2];
- i->second.updateData.updateVersion = extensions[2]->getVersion();
+ updateData.aUpdateSource = extensions[2];
+ updateData.updateVersion = extensions[2]->getVersion();
}
- i->second.updateData.bIsShared = true;
- if (!update(i->second.disableUpdate, i->second.updateData))
+ updateData.bIsShared = true;
+ if (!update(disableUpdate, updateData))
return;
}
}
@@ -517,71 +484,6 @@ void UpdateDialog::Thread::handleSpecificError(
}
}
-css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > >
-UpdateDialog::Thread::getUpdateInformation(
- css::uno::Reference< css::deployment::XPackage > const & package,
- css::uno::Sequence< rtl::OUString > const & urls,
- rtl::OUString const & identifier) const
-{
- try {
- return m_updateInformation->getUpdateInformation(urls, identifier);
- } catch (css::uno::RuntimeException &) {
- throw;
- } catch (css::ucb::CommandFailedException & e) {
- handleSpecificError(package, e.Reason);
- } catch (css::ucb::CommandAbortedException &) {
- } catch (css::uno::Exception & e) {
- handleSpecificError(package, css::uno::makeAny(e));
- }
- return
- css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > >();
-}
-
-void UpdateDialog::Thread::getOwnUpdateInformation(
- css::uno::Reference< css::deployment::XPackage > const & package,
- Map * map)
-{
- rtl::OUString id(dp_misc::getIdentifier(package));
- css::uno::Sequence< rtl::OUString > urls(
- package->getUpdateInformationURLs());
- if (urls.getLength() == 0) {
- map->insert(
- Map::value_type(
- id, Entry(package, OUSTR(""))));
- } else {
- css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > >
- infos(getUpdateInformation(package, urls, id));
- rtl::OUString latestVersion;
- sal_Int32 latestIndex = -1;
- for (sal_Int32 i = 0; i < infos.getLength(); ++i) {
- dp_misc::DescriptionInfoset infoset(
- m_context,
- css::uno::Reference< css::xml::dom::XNode >(
- infos[i], css::uno::UNO_QUERY_THROW));
- boost::optional< rtl::OUString > id2(infoset.getIdentifier());
- if (!id2) {
- continue;
- }
- if (*id2 == id) {
- rtl::OUString v(infoset.getVersion());
- if (dp_misc::compareVersions(v, latestVersion) ==
- dp_misc::GREATER)
- {
- latestVersion = v;
- latestIndex = i;
- }
- }
- }
- if (latestIndex != -1) {
- Entry e(package, latestVersion);
- e.info = css::uno::Reference< css::xml::dom::XNode >(
- infos[latestIndex], css::uno::UNO_QUERY_THROW);
- e.bProvidesOwnUpdate = true;
- map->insert(Map::value_type(id, e));
- }
- }
-}
-
::rtl::OUString UpdateDialog::Thread::getUpdateDisplayString(
dp_gui::UpdateData const & data, ::rtl::OUString const & version) const
{
@@ -590,7 +492,8 @@ void UpdateDialog::Thread::getOwnUpdateInformation(
b.append(static_cast< sal_Unicode >(' '));
{
vos::OGuard g( Application::GetSolarMutex() );
- b.append(m_dialog.m_version);
+ if(!m_stop)
+ b.append(m_dialog.m_version);
}
b.append(static_cast< sal_Unicode >(' '));
if (version.getLength())
@@ -603,7 +506,8 @@ void UpdateDialog::Thread::getOwnUpdateInformation(
b.append(static_cast< sal_Unicode >(' '));
{
vos::OGuard g( Application::GetSolarMutex() );
- b.append(m_dialog.m_browserbased);
+ if(!m_stop)
+ b.append(m_dialog.m_browserbased);
}
}
return b.makeStringAndClear();
diff --git a/desktop/source/deployment/inc/dp_misc.h b/desktop/source/deployment/inc/dp_misc.h
index 161b91a6bcde..61e3fcc45418 100644
--- a/desktop/source/deployment/inc/dp_misc.h
+++ b/desktop/source/deployment/inc/dp_misc.h
@@ -117,11 +117,6 @@ oslProcess raiseProcess( ::rtl::OUString const & appURL,
::com::sun::star::uno::Sequence< ::rtl::OUString > const & args );
//==============================================================================
-/** returns the default update URL (for the update information) which
- is used when an extension does not provide its own URL.
-*/
-DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
-::rtl::OUString getExtensionDefaultUpdateURL();
/** writes the argument string to the console.
On Linux/Unix/etc. it converts the UTF16 string to an ANSI string using
@@ -179,53 +174,6 @@ DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
void syncRepositories(::com::sun::star::uno::Reference<
::com::sun::star::ucb::XCommandEnvironment> const & xCmdEnv);
-enum UPDATE_SOURCE
-{
- UPDATE_SOURCE_NONE,
- UPDATE_SOURCE_SHARED,
- UPDATE_SOURCE_BUNDLED,
- UPDATE_SOURCE_ONLINE
-};
-
-/* determine if an update is available which is installed in the
- user repository.
-
- If the return value is UPDATE_SOURCE_NONE, then no update is
- available, otherwise the return value determine from which the
- repository the update is used.
-*/
-DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
-UPDATE_SOURCE isUpdateUserExtension(
- bool bReadOnlyShared,
- ::rtl::OUString const & userVersion,
- ::rtl::OUString const & sharedVersion,
- ::rtl::OUString const & bundledVersion,
- ::rtl::OUString const & onlineVersion);
-
-/* determine if an update is available which is installed in the
- shared repository.
-
- If the return value is UPDATE_SOURCE_NONE, then no update is
- available, otherwise the return value determine from which the
- repository the update is used.
-*/
-DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
-UPDATE_SOURCE isUpdateSharedExtension(
- bool bReadOnlyShared,
- ::rtl::OUString const & sharedVersion,
- ::rtl::OUString const & bundledVersion,
- ::rtl::OUString const & onlineVersion);
-
-/* determines the extension with the highest identifier and returns it
-
- */
-DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
-::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage>
-getExtensionWithHighestVersion(
- ::com::sun::star::uno::Sequence<
- ::com::sun::star::uno::Reference<
- ::com::sun::star::deployment::XPackage> > const & seqExtensionsWithSameId);
-
}
#endif
diff --git a/desktop/source/deployment/inc/dp_update.hxx b/desktop/source/deployment/inc/dp_update.hxx
new file mode 100755
index 000000000000..01511b1f2d21
--- /dev/null
+++ b/desktop/source/deployment/inc/dp_update.hxx
@@ -0,0 +1,147 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#if ! defined INCLUDED_DP_UPDATE_HXX
+#define INCLUDED_DP_UPDATE_HXX
+
+
+#include "com/sun/star/deployment/XPackage.hpp"
+#include "com/sun/star/deployment/XExtensionManager.hpp"
+#include "com/sun/star/deployment/XUpdateInformationProvider.hpp"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/xml/dom/XNode.hpp"
+
+#include "rtl/ustrbuf.hxx"
+#include "dp_misc_api.hxx"
+
+#include <map>
+#include <vector>
+
+namespace dp_misc {
+
+/** returns the default update URL (for the update information) which
+ is used when an extension does not provide its own URL.
+*/
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+::rtl::OUString getExtensionDefaultUpdateURL();
+
+enum UPDATE_SOURCE
+{
+ UPDATE_SOURCE_NONE,
+ UPDATE_SOURCE_SHARED,
+ UPDATE_SOURCE_BUNDLED,
+ UPDATE_SOURCE_ONLINE
+};
+
+/* determine if an update is available which is installed in the
+ user repository.
+
+ If the return value is UPDATE_SOURCE_NONE, then no update is
+ available, otherwise the return value determine from which the
+ repository the update is used.
+*/
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+UPDATE_SOURCE isUpdateUserExtension(
+ bool bReadOnlyShared,
+ ::rtl::OUString const & userVersion,
+ ::rtl::OUString const & sharedVersion,
+ ::rtl::OUString const & bundledVersion,
+ ::rtl::OUString const & onlineVersion);
+
+/* determine if an update is available which is installed in the
+ shared repository.
+
+ If the return value is UPDATE_SOURCE_NONE, then no update is
+ available, otherwise the return value determine from which the
+ repository the update is used.
+*/
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+UPDATE_SOURCE isUpdateSharedExtension(
+ bool bReadOnlyShared,
+ ::rtl::OUString const & sharedVersion,
+ ::rtl::OUString const & bundledVersion,
+ ::rtl::OUString const & onlineVersion);
+
+/* determines the extension with the highest identifier and returns it
+
+ */
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage>
+getExtensionWithHighestVersion(
+ ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::deployment::XPackage> > const & seqExtensionsWithSameId);
+
+
+struct UpdateInfo
+{
+ UpdateInfo( ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> const & ext);
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::deployment::XPackage> extension;
+//version of the update
+ ::rtl::OUString version;
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > info;
+};
+
+typedef std::map< ::rtl::OUString, UpdateInfo > UpdateInfoMap;
+
+/*
+ @param extensionList
+ List of extension for which online update information are to be obtained. If NULL, then
+ for update information are obtained for all installed extension. There may be only one extension
+ with a particular identifier contained in the list. If one extension is installed
+ in several repositories, then the one with the highest version must be used, because it contains
+ the more recent URLs for getting the update information (if at all).
+ @param out_errors
+ the first member of the pair is the extension and the second the exception that was produced
+ when processing the extension.
+
+ @return
+ A map of UpdateInfo instances. If the parameter extensionList was given, then the map contains
+ at only information for those extensions.
+ */
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+UpdateInfoMap getOnlineUpdateInfos(
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> const &xContext,
+ ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager> const & xExtMgr,
+ ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XUpdateInformationProvider > const & updateInformation,
+ std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > > const * extensionList,
+ ::std::vector< ::std::pair< ::com::sun::star::uno::Reference<
+ ::com::sun::star::deployment::XPackage>, ::com::sun::star::uno::Any> > & out_errors);
+
+/* retunrs the highest version from the provided arguments.
+*/
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+::rtl::OUString getHighestVersion(
+ ::rtl::OUString const & userVersion,
+ ::rtl::OUString const & sharedVersion,
+ ::rtl::OUString const & bundledVersion,
+ ::rtl::OUString const & onlineVersion);
+
+}
+
+#endif
diff --git a/desktop/source/deployment/manager/dp_informationprovider.cxx b/desktop/source/deployment/manager/dp_informationprovider.cxx
index 537b7233ef77..ca2c7b5438cf 100644
--- a/desktop/source/deployment/manager/dp_informationprovider.cxx
+++ b/desktop/source/deployment/manager/dp_informationprovider.cxx
@@ -55,6 +55,7 @@
#include "dp_identifier.hxx"
#include "dp_version.hxx"
#include "dp_misc.h"
+#include "dp_update.hxx"
namespace beans = com::sun::star::beans ;
namespace deployment = com::sun::star::deployment ;
@@ -107,16 +108,6 @@ private:
const rtl::OUString& _sExtensionId );
uno::Reference< deployment::XUpdateInformationProvider > mxUpdateInformation;
-
- uno::Sequence< uno::Reference< xml::dom::XElement > >
- getUpdateInformation( uno::Sequence< rtl::OUString > const & urls,
- rtl::OUString const & identifier ) const;
- uno::Sequence< uno::Reference< deployment::XPackage > >
- getPackages(rtl::OUString const & repository);
- uno::Sequence< uno::Sequence< rtl::OUString > > isUpdateAvailable(
- rtl::OUString const & repository, const rtl::OUString& _sExtensionId );
- uno::Sequence< uno::Sequence< rtl::OUString > > concatLists( uno::Sequence< uno::Sequence< rtl::OUString > > aFirst,
- uno::Sequence< uno::Sequence< rtl::OUString > > aSecond );
};
//------------------------------------------------------------------------------
@@ -212,18 +203,101 @@ uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL
PackageInformationProvider::isUpdateAvailable( const rtl::OUString& _sExtensionId )
throw ( uno::RuntimeException )
{
- uno::Sequence< uno::Sequence< rtl::OUString > >
- aUpdateListUser = isUpdateAvailable( UNISTRING("user"), _sExtensionId );
+ uno::Sequence< uno::Sequence< rtl::OUString > > aList;
- uno::Sequence< uno::Sequence< rtl::OUString > >
- aUpdateListShared = isUpdateAvailable( UNISTRING("shared"), _sExtensionId );
+ uno::Reference<deployment::XExtensionManager> extMgr =
+ deployment::ExtensionManager::get(mxContext);
- uno::Sequence< uno::Sequence< rtl::OUString > >
- aUpdateListBundled = isUpdateAvailable( UNISTRING("bundled"), _sExtensionId );
+ if (!extMgr.is())
+ {
+ OSL_ASSERT(0);
+ return aList;
+ }
+ std::vector<std::pair<uno::Reference<deployment::XPackage>, uno::Any > > errors;
+ dp_misc::UpdateInfoMap updateInfoMap;
+ if (_sExtensionId.getLength())
+ {
+ std::vector<uno::Reference<deployment::XPackage> > vecExtensions;
+ uno::Reference<deployment::XPackage> extension;
+ try
+ {
+ extension = dp_misc::getExtensionWithHighestVersion(
+ extMgr->getExtensionsWithSameIdentifier(
+ _sExtensionId, _sExtensionId, uno::Reference<css_ucb::XCommandEnvironment>()));
+ vecExtensions.push_back(extension);
+ }
+ catch (lang::IllegalArgumentException &)
+ {
+ OSL_ASSERT(0);
+ }
+ updateInfoMap = dp_misc::getOnlineUpdateInfos(
+ mxContext, extMgr, mxUpdateInformation, &vecExtensions, errors);
+ }
+ else
+ {
+ updateInfoMap = dp_misc::getOnlineUpdateInfos(
+ mxContext, extMgr, mxUpdateInformation, NULL, errors);
+ }
+
+ int nCount = 0;
+ for (dp_misc::UpdateInfoMap::iterator i(updateInfoMap.begin()); i != updateInfoMap.end(); i++)
+ {
+ dp_misc::UpdateInfo const & info = i->second;
+
+ rtl::OUString sOnlineVersion;
+ if (info.info.is())
+ sOnlineVersion = info.version;
+
+ rtl::OUString sVersionUser;
+ rtl::OUString sVersionShared;
+ rtl::OUString sVersionBundled;
+ uno::Sequence< uno::Reference< deployment::XPackage> > extensions;
+ try {
+ extensions = extMgr->getExtensionsWithSameIdentifier(
+ dp_misc::getIdentifier(info.extension), info.extension->getName(),
+ uno::Reference<css_ucb::XCommandEnvironment>());
+ } catch (lang::IllegalArgumentException& ) {
+ OSL_ASSERT(0);
+ }
+ OSL_ASSERT(extensions.getLength() == 3);
+ if (extensions[0].is() )
+ sVersionUser = extensions[0]->getVersion();
+ if (extensions[1].is() )
+ sVersionShared = extensions[1]->getVersion();
+ if (extensions[2].is() )
+ sVersionBundled = extensions[2]->getVersion();
+
+ bool bSharedReadOnly = extMgr->isReadOnlyRepository(OUSTR("shared"));
+
+ dp_misc::UPDATE_SOURCE sourceUser = dp_misc::isUpdateUserExtension(
+ bSharedReadOnly, sVersionUser, sVersionShared, sVersionBundled, sOnlineVersion);
+ dp_misc::UPDATE_SOURCE sourceShared = dp_misc::isUpdateSharedExtension(
+ bSharedReadOnly, sVersionShared, sVersionBundled, sOnlineVersion);
+
+ rtl::OUString updateVersionUser;
+ rtl::OUString updateVersionShared;
+ if (sourceUser != dp_misc::UPDATE_SOURCE_NONE)
+ updateVersionUser = dp_misc::getHighestVersion(
+ rtl::OUString(), sVersionShared, sVersionBundled, sOnlineVersion);
+ if (sourceShared != dp_misc::UPDATE_SOURCE_NONE)
+ updateVersionShared = dp_misc::getHighestVersion(
+ rtl::OUString(), rtl::OUString(), sVersionBundled, sOnlineVersion);
+ rtl::OUString updateVersion;
+ if (dp_misc::compareVersions(updateVersionUser, updateVersionShared) == dp_misc::GREATER)
+ updateVersion = updateVersionUser;
+ else
+ updateVersion = updateVersionShared;
+ if (updateVersion.getLength())
+ {
- uno::Sequence< uno::Sequence< rtl::OUString > > user_shared =
- concatLists( aUpdateListUser, aUpdateListShared );
- return concatLists(user_shared, aUpdateListBundled);
+ rtl::OUString aNewEntry[2];
+ aNewEntry[0] = i->first;
+ aNewEntry[1] = updateVersion;
+ aList.realloc( ++nCount );
+ aList[ nCount-1 ] = ::uno::Sequence< rtl::OUString >( aNewEntry, 2 );
+ }
+ }
+ return aList;
}
//------------------------------------------------------------------------------
@@ -257,7 +331,7 @@ uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL PackageInformationProvi
for (sal_Int32 j = 0; j < cExt; j++)
{
//ToDo according to the old code the first found extenions is used
- //even if another one with the same id has a better version. Design flaw?
+ //even if another one with the same id has a better version.
uno::Reference< deployment::XPackage > const & xExtension( seqExtension[j] );
if (xExtension.is())
{
@@ -272,167 +346,6 @@ uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL PackageInformationProvi
return retList;
}
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-uno::Sequence< uno::Reference< deployment::XPackage > >
-PackageInformationProvider::getPackages( const rtl::OUString & repository )
-{
- uno::Sequence< uno::Reference< deployment::XPackage > > packages;
- try {
- uno::Reference<deployment::XExtensionManager> xMgr = deployment::ExtensionManager::get(mxContext);
- packages = xMgr->getDeployedExtensions(repository, uno::Reference< task::XAbortChannel >(),
- static_cast < XCommandEnvironment *> (this) );
- }
- catch ( deployment::DeploymentException & )
- {}
- catch ( css_ucb::CommandFailedException & )
- {}
- catch ( css_ucb::CommandAbortedException & )
- {}
- catch ( lang::IllegalArgumentException & e )
- {
- throw uno::RuntimeException(e.Message, e.Context);
- }
-
- return packages;
-}
-
-//------------------------------------------------------------------------------
-uno::Sequence< uno::Reference< xml::dom::XElement > >
- PackageInformationProvider::getUpdateInformation( uno::Sequence< rtl::OUString > const & urls,
- rtl::OUString const & identifier ) const
-{
- try
- {
- return mxUpdateInformation->getUpdateInformation( urls, identifier );
- }
- catch ( uno::RuntimeException & ) {
- throw;
- }
- catch ( css_ucb::CommandFailedException & ) {}
- catch ( css_ucb::CommandAbortedException & ) {}
- catch ( uno::Exception & ) {}
-
- return uno::Sequence< uno::Reference< xml::dom::XElement > >();
-}
-
-//------------------------------------------------------------------------------
-uno::Sequence< uno::Sequence< rtl::OUString > >
- PackageInformationProvider::isUpdateAvailable(
- const rtl::OUString& repository,
- const rtl::OUString& _sExtensionId )
-{
- uno::Sequence< uno::Sequence< rtl::OUString > > aList;
- sal_Int32 nCount = 0;
- bool bPackageFound = false;
-
- uno::Reference<deployment::XExtensionManager> xManager = deployment::ExtensionManager::get(mxContext);
- // If the package manager is readonly then the user cannot modify anything anyway
- // so we can abort the search here
- if ( xManager.is() && ! xManager->isReadOnlyRepository(repository) )
- {
- uno::Sequence< uno::Reference< deployment::XPackage > > packages( getPackages( repository ) );
- uno::Sequence< uno::Reference< xml::dom::XElement > > defaultInfos;
-
- for ( int pos = packages.getLength(); pos-- && !bPackageFound; )
- {
- uno::Reference< deployment::XPackage > package( packages[ pos ] );
- uno::Sequence< rtl::OUString > urls( package->getUpdateInformationURLs());
- uno::Sequence< uno::Reference< xml::dom::XElement > > infos;
- rtl::OUString id( dp_misc::getIdentifier( package ) );
-
- if ( _sExtensionId.getLength() )
- {
- if ( _sExtensionId == id )
- bPackageFound = true;
- else /* we have an ID and the IDs don't match, continue with next package */
- continue;
- }
-
- if ( urls.getLength() != 0)
- {
- infos = getUpdateInformation( urls, id );
- }
- else
- {
- if ( defaultInfos.getLength() == 0 )
- {
- const rtl::OUString defaultURL( dp_misc::getExtensionDefaultUpdateURL() );
- if ( defaultURL.getLength() )
- defaultInfos = getUpdateInformation( uno::Sequence< rtl::OUString >( &defaultURL, 1 ),
- rtl::OUString() );
- }
- infos = defaultInfos;
- }
- rtl::OUString latestVersion( package->getVersion() );
- sal_Int32 latestIndex = -1;
- for ( sal_Int32 i = 0; i < infos.getLength(); ++i )
- {
- dp_misc::DescriptionInfoset infoset( mxContext,
- uno::Reference< xml::dom::XNode >( infos[i], uno::UNO_QUERY_THROW));
- boost::optional< rtl::OUString > id2( infoset.getIdentifier() );
-
- if (!id2)
- continue;
-
- if (*id2 == id)
- {
- // check, if there are unsatisfied dependencies and ignore those updates
- uno::Sequence< uno::Reference< xml::dom::XElement > > ds( dp_misc::Dependencies::check( infoset ) );
- if ( ds.getLength() )
- continue;
-
- rtl::OUString v( infoset.getVersion() );
- if ( dp_misc::compareVersions( v, latestVersion ) == dp_misc::GREATER )
- {
- latestVersion = v;
- latestIndex = i;
- }
- }
- }
- if ( latestIndex != -1 )
- {
- rtl::OUString aNewEntry[2];
- aNewEntry[0] = id;
- aNewEntry[1] = latestVersion;
- aList.realloc( ++nCount );
- aList[ nCount-1 ] = ::uno::Sequence< rtl::OUString >( aNewEntry, 2 );
- }
- }
- }
- return aList;
-}
-
-//------------------------------------------------------------------------------
-uno::Sequence< uno::Sequence< rtl::OUString > > PackageInformationProvider::concatLists(
- uno::Sequence< uno::Sequence< rtl::OUString > > aFirst,
- uno::Sequence< uno::Sequence< rtl::OUString > > aSecond )
-{
- sal_Int32 nFirstCount = aFirst.getLength();
- sal_Int32 nSecondCount = aSecond.getLength();
- sal_Int32 nIndex = nFirstCount;
-
- for ( sal_Int32 i=0; i < nSecondCount; i++ )
- {
- bool bDuplicateEntry = false;
- for ( sal_Int32 j=0; j < nFirstCount; j++ )
- {
- if ( aFirst[ j ][0] == aSecond[ i ][0] )
- {
- bDuplicateEntry = true;
- break;
- }
- }
- if ( !bDuplicateEntry )
- {
- nIndex += 1;
- aFirst.realloc( nIndex );
- aFirst[ nIndex - 1 ] = aSecond[ i ];
- }
- }
- return aFirst;
-}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx
index 53d488095ecd..fe3490903043 100644
--- a/desktop/source/deployment/misc/dp_misc.cxx
+++ b/desktop/source/deployment/misc/dp_misc.cxx
@@ -477,17 +477,6 @@ Reference<XInterface> resolveUnoURL(
}
}
-OUString getExtensionDefaultUpdateURL()
-{
- ::rtl::OUString sUrl(
- RTL_CONSTASCII_USTRINGPARAM(
- "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("version")
- ":Version:ExtensionUpdateURL}"));
- ::rtl::Bootstrap::expandMacros(sUrl);
- return sUrl;
-}
-
-
#ifdef WNT
void writeConsoleWithStream(::rtl::OUString const & sText, HANDLE stream)
{
@@ -631,147 +620,6 @@ void syncRepositories(Reference<ucb::XCommandEnvironment> const & xCmdEnv)
}
}
-/* returns the index of the greatest version, starting with 0
-
- */
-int determineHighestVersion(
- ::rtl::OUString const & userVersion,
- ::rtl::OUString const & sharedVersion,
- ::rtl::OUString const & bundledVersion,
- ::rtl::OUString const & onlineVersion)
-{
- int index = 0;
- OUString greatest = userVersion;
- if (dp_misc::compareVersions(sharedVersion, greatest) == dp_misc::GREATER)
- {
- index = 1;
- greatest = sharedVersion;
- }
- if (dp_misc::compareVersions(bundledVersion, greatest) == dp_misc::GREATER)
- {
- index = 2;
- greatest = bundledVersion;
- }
- if (dp_misc::compareVersions(onlineVersion, greatest) == dp_misc::GREATER)
- {
- index = 3;
- }
- return index;
-}
-
-UPDATE_SOURCE isUpdateUserExtension(
- bool bReadOnlyShared,
- ::rtl::OUString const & userVersion,
- ::rtl::OUString const & sharedVersion,
- ::rtl::OUString const & bundledVersion,
- ::rtl::OUString const & onlineVersion)
-{
- UPDATE_SOURCE retVal = UPDATE_SOURCE_NONE;
- if (bReadOnlyShared)
- {
- if (userVersion.getLength())
- {
- int index = determineHighestVersion(
- userVersion, sharedVersion, bundledVersion, onlineVersion);
- if (index == 1)
- retVal = UPDATE_SOURCE_SHARED;
- else if (index == 2)
- retVal = UPDATE_SOURCE_BUNDLED;
- else if (index == 3)
- retVal = UPDATE_SOURCE_ONLINE;
- }
- else if (sharedVersion.getLength())
- {
- int index = determineHighestVersion(
- OUString(), sharedVersion, bundledVersion, onlineVersion);
- if (index == 2)
- retVal = UPDATE_SOURCE_BUNDLED;
- else if (index == 3)
- retVal = UPDATE_SOURCE_ONLINE;
-
- }
- else if (bundledVersion.getLength())
- {
- int index = determineHighestVersion(
- OUString(), OUString(), bundledVersion, onlineVersion);
- if (index == 3)
- retVal = UPDATE_SOURCE_ONLINE;
- }
- }
- else
- {
- if (userVersion.getLength())
- {
- int index = determineHighestVersion(
- userVersion, sharedVersion, bundledVersion, onlineVersion);
- if (index == 1)
- retVal = UPDATE_SOURCE_SHARED;
- else if (index == 2)
- retVal = UPDATE_SOURCE_BUNDLED;
- else if (index == 3)
- retVal = UPDATE_SOURCE_ONLINE;
- }
- }
-
- return retVal;
-}
-
-UPDATE_SOURCE isUpdateSharedExtension(
- bool bReadOnlyShared,
- ::rtl::OUString const & sharedVersion,
- ::rtl::OUString const & bundledVersion,
- ::rtl::OUString const & onlineVersion)
-{
- if (bReadOnlyShared)
- return UPDATE_SOURCE_NONE;
- UPDATE_SOURCE retVal = UPDATE_SOURCE_NONE;
-
- if (sharedVersion.getLength())
- {
- int index = determineHighestVersion(
- OUString(), sharedVersion, bundledVersion, onlineVersion);
- if (index == 2)
- retVal = UPDATE_SOURCE_BUNDLED;
- else if (index == 3)
- retVal = UPDATE_SOURCE_ONLINE;
- }
- else if (bundledVersion.getLength())
- {
- int index = determineHighestVersion(
- OUString(), OUString(), bundledVersion, onlineVersion);
- if (index == 3)
- retVal = UPDATE_SOURCE_ONLINE;
- }
- return retVal;
-}
-
-Reference<deployment::XPackage>
-getExtensionWithHighestVersion(
- Sequence<Reference<deployment::XPackage> > const & seqExt)
-{
- if (seqExt.getLength() == 0)
- return Reference<deployment::XPackage>();
-
- Reference<deployment::XPackage> greatest;
- sal_Int32 len = seqExt.getLength();
-
- for (sal_Int32 i = 0; i < len; i++)
- {
- if (!greatest.is())
- {
- greatest = seqExt[i];
- continue;
- }
- Reference<deployment::XPackage> const & current = seqExt[i];
- //greatest has a value
- if (! current.is())
- continue;
-
- if (dp_misc::compareVersions(current->getVersion(), greatest->getVersion()) == dp_misc::GREATER)
- greatest = current;
- }
- return greatest;
-}
}
diff --git a/desktop/source/deployment/misc/dp_update.cxx b/desktop/source/deployment/misc/dp_update.cxx
new file mode 100755
index 000000000000..52011f1f0ca0
--- /dev/null
+++ b/desktop/source/deployment/misc/dp_update.cxx
@@ -0,0 +1,397 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_desktop.hxx"
+
+
+#include "dp_update.hxx"
+#include "dp_version.hxx"
+#include "dp_identifier.hxx"
+#include "dp_descriptioninfoset.hxx"
+
+#include "rtl/bootstrap.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+using ::rtl::OString;
+
+
+namespace dp_misc {
+namespace {
+
+int determineHighestVersion(
+ ::rtl::OUString const & userVersion,
+ ::rtl::OUString const & sharedVersion,
+ ::rtl::OUString const & bundledVersion,
+ ::rtl::OUString const & onlineVersion)
+{
+ int index = 0;
+ OUString greatest = userVersion;
+ if (dp_misc::compareVersions(sharedVersion, greatest) == dp_misc::GREATER)
+ {
+ index = 1;
+ greatest = sharedVersion;
+ }
+ if (dp_misc::compareVersions(bundledVersion, greatest) == dp_misc::GREATER)
+ {
+ index = 2;
+ greatest = bundledVersion;
+ }
+ if (dp_misc::compareVersions(onlineVersion, greatest) == dp_misc::GREATER)
+ {
+ index = 3;
+ }
+ return index;
+}
+
+Sequence< Reference< xml::dom::XElement > >
+getUpdateInformation( Reference<deployment::XUpdateInformationProvider > const & updateInformation,
+ Sequence< OUString > const & urls,
+ OUString const & identifier,
+ uno::Any & out_error)
+{
+ try {
+ return updateInformation->getUpdateInformation(urls, identifier);
+ } catch (uno::RuntimeException &) {
+ throw;
+ } catch (ucb::CommandFailedException & e) {
+ out_error = e.Reason;
+ } catch (ucb::CommandAbortedException &) {
+ } catch (uno::Exception & e) {
+ out_error = uno::makeAny(e);
+ }
+ return
+ Sequence<Reference< xml::dom::XElement > >();
+}
+
+//Put in anonymous namespace
+
+void getOwnUpdateInfos(
+ Reference<uno::XComponentContext> const & xContext,
+ Reference<deployment::XUpdateInformationProvider > const & updateInformation,
+ UpdateInfoMap& inout_map, std::vector<std::pair<Reference<deployment::XPackage>, uno::Any> > & out_errors,
+ bool & out_allFound)
+{
+ bool allHaveOwnUpdateInformation = true;
+ for (UpdateInfoMap::iterator i = inout_map.begin(); i != inout_map.end(); i++)
+ {
+ OSL_ASSERT(i->second.extension.is());
+ Sequence<OUString> urls(i->second.extension->getUpdateInformationURLs());
+ if (urls.getLength())
+ {
+ const OUString id = dp_misc::getIdentifier(i->second.extension);
+ uno::Any anyError;
+ //It is unclear from the idl if there can be a null reference returned.
+ //However all valid information should be the same
+ Sequence<Reference< xml::dom::XElement > >
+ infos(getUpdateInformation(updateInformation, urls, id, anyError));
+ if (anyError.hasValue())
+ out_errors.push_back(std::make_pair(i->second.extension, anyError));
+
+ for (sal_Int32 j = 0; j < infos.getLength(); ++j)
+ {
+ dp_misc::DescriptionInfoset infoset(
+ xContext,
+ Reference< xml::dom::XNode >(infos[j], UNO_QUERY_THROW));
+ if (!infoset.hasDescription())
+ continue;
+ boost::optional< OUString > id2(infoset.getIdentifier());
+ if (!id2)
+ continue;
+ OSL_ASSERT(*id2 == id);
+ if (*id2 == id)
+ {
+ i->second.version = infoset.getVersion();
+ i->second.info = Reference< xml::dom::XNode >(
+ infos[j], UNO_QUERY_THROW);
+ }
+ break;
+ }
+ }
+ else
+ {
+ allHaveOwnUpdateInformation &= false;
+ }
+ }
+ out_allFound = allHaveOwnUpdateInformation;
+}
+
+void getDefaultUpdateInfos(
+ Reference<uno::XComponentContext> const & xContext,
+ Reference<deployment::XUpdateInformationProvider > const & updateInformation,
+ UpdateInfoMap& inout_map,
+ std::vector<std::pair<Reference<deployment::XPackage>, uno::Any> > & out_errors)
+{
+ const rtl::OUString sDefaultURL(dp_misc::getExtensionDefaultUpdateURL());
+ OSL_ASSERT(sDefaultURL.getLength());
+
+ Any anyError;
+ Sequence< Reference< xml::dom::XElement > >
+ infos(
+ getUpdateInformation(
+ updateInformation,
+ Sequence< OUString >(&sDefaultURL, 1), OUString(), anyError));
+ if (anyError.hasValue())
+ out_errors.push_back(std::make_pair(Reference<deployment::XPackage>(), anyError));
+ for (sal_Int32 i = 0; i < infos.getLength(); ++i)
+ {
+ Reference< xml::dom::XNode > node(infos[i], UNO_QUERY_THROW);
+ dp_misc::DescriptionInfoset infoset(xContext, node);
+ boost::optional< OUString > id(infoset.getIdentifier());
+ if (!id) {
+ continue;
+ }
+ UpdateInfoMap::iterator j = inout_map.find(*id);
+ if (j != inout_map.end())
+ {
+ //skip those extension which provide its own update urls
+ if (j->second.extension->getUpdateInformationURLs().getLength())
+ continue;
+ OUString v(infoset.getVersion());
+ //look for the highest version in the online repository
+ if (dp_misc::compareVersions(v, j->second.version) ==
+ dp_misc::GREATER)
+ {
+ j->second.version = v;
+ j->second.info = node;
+ }
+ }
+ }
+}
+
+
+} // anon namespace
+
+
+OUString getExtensionDefaultUpdateURL()
+{
+ ::rtl::OUString sUrl(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("version")
+ ":Version:ExtensionUpdateURL}"));
+ ::rtl::Bootstrap::expandMacros(sUrl);
+ return sUrl;
+}
+
+/* returns the index of the greatest version, starting with 0
+
+ */
+UPDATE_SOURCE isUpdateUserExtension(
+ bool bReadOnlyShared,
+ ::rtl::OUString const & userVersion,
+ ::rtl::OUString const & sharedVersion,
+ ::rtl::OUString const & bundledVersion,
+ ::rtl::OUString const & onlineVersion)
+{
+ UPDATE_SOURCE retVal = UPDATE_SOURCE_NONE;
+ if (bReadOnlyShared)
+ {
+ if (userVersion.getLength())
+ {
+ int index = determineHighestVersion(
+ userVersion, sharedVersion, bundledVersion, onlineVersion);
+ if (index == 1)
+ retVal = UPDATE_SOURCE_SHARED;
+ else if (index == 2)
+ retVal = UPDATE_SOURCE_BUNDLED;
+ else if (index == 3)
+ retVal = UPDATE_SOURCE_ONLINE;
+ }
+ else if (sharedVersion.getLength())
+ {
+ int index = determineHighestVersion(
+ OUString(), sharedVersion, bundledVersion, onlineVersion);
+ if (index == 2)
+ retVal = UPDATE_SOURCE_BUNDLED;
+ else if (index == 3)
+ retVal = UPDATE_SOURCE_ONLINE;
+
+ }
+ else if (bundledVersion.getLength())
+ {
+ int index = determineHighestVersion(
+ OUString(), OUString(), bundledVersion, onlineVersion);
+ if (index == 3)
+ retVal = UPDATE_SOURCE_ONLINE;
+ }
+ }
+ else
+ {
+ if (userVersion.getLength())
+ {
+ int index = determineHighestVersion(
+ userVersion, sharedVersion, bundledVersion, onlineVersion);
+ if (index == 1)
+ retVal = UPDATE_SOURCE_SHARED;
+ else if (index == 2)
+ retVal = UPDATE_SOURCE_BUNDLED;
+ else if (index == 3)
+ retVal = UPDATE_SOURCE_ONLINE;
+ }
+ }
+
+ return retVal;
+}
+
+UPDATE_SOURCE isUpdateSharedExtension(
+ bool bReadOnlyShared,
+ ::rtl::OUString const & sharedVersion,
+ ::rtl::OUString const & bundledVersion,
+ ::rtl::OUString const & onlineVersion)
+{
+ if (bReadOnlyShared)
+ return UPDATE_SOURCE_NONE;
+ UPDATE_SOURCE retVal = UPDATE_SOURCE_NONE;
+
+ if (sharedVersion.getLength())
+ {
+ int index = determineHighestVersion(
+ OUString(), sharedVersion, bundledVersion, onlineVersion);
+ if (index == 2)
+ retVal = UPDATE_SOURCE_BUNDLED;
+ else if (index == 3)
+ retVal = UPDATE_SOURCE_ONLINE;
+ }
+ else if (bundledVersion.getLength())
+ {
+ int index = determineHighestVersion(
+ OUString(), OUString(), bundledVersion, onlineVersion);
+ if (index == 3)
+ retVal = UPDATE_SOURCE_ONLINE;
+ }
+ return retVal;
+}
+
+Reference<deployment::XPackage>
+getExtensionWithHighestVersion(
+ Sequence<Reference<deployment::XPackage> > const & seqExt)
+{
+ if (seqExt.getLength() == 0)
+ return Reference<deployment::XPackage>();
+
+ Reference<deployment::XPackage> greatest;
+ sal_Int32 len = seqExt.getLength();
+
+ for (sal_Int32 i = 0; i < len; i++)
+ {
+ if (!greatest.is())
+ {
+ greatest = seqExt[i];
+ continue;
+ }
+ Reference<deployment::XPackage> const & current = seqExt[i];
+ //greatest has a value
+ if (! current.is())
+ continue;
+
+ if (dp_misc::compareVersions(current->getVersion(), greatest->getVersion()) == dp_misc::GREATER)
+ greatest = current;
+ }
+ return greatest;
+}
+
+UpdateInfo::UpdateInfo( Reference< deployment::XPackage> const & ext):
+extension(ext)
+{
+}
+
+
+
+UpdateInfoMap getOnlineUpdateInfos(
+ Reference<uno::XComponentContext> const &xContext,
+ Reference<deployment::XExtensionManager> const & xExtMgr,
+ Reference<deployment::XUpdateInformationProvider > const & updateInformation,
+ std::vector<Reference<deployment::XPackage > > const * extensionList,
+ std::vector<std::pair< Reference<deployment::XPackage>, uno::Any> > & out_errors)
+{
+ OSL_ASSERT(xExtMgr.is());
+ UpdateInfoMap infoMap;
+ if (!xExtMgr.is())
+ return infoMap;
+
+ if (!extensionList)
+ {
+ const uno::Sequence< uno::Sequence< Reference<deployment::XPackage > > > seqAllExt = xExtMgr->getAllExtensions(
+ Reference<task::XAbortChannel>(), Reference<ucb::XCommandEnvironment>());
+
+ //fill the UpdateInfoMap. key = extension identifier, value = UpdateInfo
+ for (int pos = seqAllExt.getLength(); pos --; )
+ {
+ uno::Sequence<Reference<deployment::XPackage> > const & seqExt = seqAllExt[pos];
+
+ Reference<deployment::XPackage> extension = getExtensionWithHighestVersion(seqExt);
+ OSL_ASSERT(extension.is());
+
+ std::pair<UpdateInfoMap::iterator, bool> insertRet = infoMap.insert(
+ UpdateInfoMap::value_type(
+ dp_misc::getIdentifier(extension), UpdateInfo(extension)));
+ OSL_ASSERT(insertRet.second == true);
+ }
+ }
+ else
+ {
+ typedef std::vector<Reference<deployment::XPackage > >::const_iterator CIT;
+ for (CIT i = extensionList->begin(); i != extensionList->end(); i++)
+ {
+ OSL_ASSERT(i->is());
+ std::pair<UpdateInfoMap::iterator, bool> insertRet = infoMap.insert(
+ UpdateInfoMap::value_type(
+ dp_misc::getIdentifier(*i), UpdateInfo(*i)));
+ OSL_ASSERT(insertRet.second == true);
+ }
+ }
+
+ //Now find the update information for the extensions which provide their own
+ //URLs to update information.
+ bool allInfosObtained = false;
+ getOwnUpdateInfos(xContext, updateInformation, infoMap, out_errors, allInfosObtained);
+
+ if (!allInfosObtained)
+ getDefaultUpdateInfos(xContext, updateInformation, infoMap, out_errors);
+ return infoMap;
+}
+OUString getHighestVersion(
+ ::rtl::OUString const & userVersion,
+ ::rtl::OUString const & sharedVersion,
+ ::rtl::OUString const & bundledVersion,
+ ::rtl::OUString const & onlineVersion)
+{
+ int index = determineHighestVersion(userVersion, sharedVersion, bundledVersion, onlineVersion);
+ switch (index)
+ {
+ case 0: return userVersion;
+ case 1: return sharedVersion;
+ case 2: return bundledVersion;
+ case 3: return onlineVersion;
+ default: OSL_ASSERT(0);
+ }
+
+ return OUString();
+}
+} //namespace dp_misc
diff --git a/desktop/source/deployment/misc/makefile.mk b/desktop/source/deployment/misc/makefile.mk
index 9a7f1d62e001..3e4bd68cb4c0 100644
--- a/desktop/source/deployment/misc/makefile.mk
+++ b/desktop/source/deployment/misc/makefile.mk
@@ -65,7 +65,8 @@ SHL1OBJS = \
$(SLO)$/dp_version.obj \
$(SLO)$/dp_descriptioninfoset.obj \
$(SLO)$/dp_dependencies.obj \
- $(SLO)$/dp_platform.obj
+ $(SLO)$/dp_platform.obj \
+ $(SLO)$/dp_update.obj
SHL1STDLIBS = \
$(BERKELEYLIB) \