1*2722ceddSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2722ceddSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2722ceddSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2722ceddSAndrew Rist * distributed with this work for additional information 6*2722ceddSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2722ceddSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2722ceddSAndrew Rist * "License"); you may not use this file except in compliance 9*2722ceddSAndrew Rist * with the License. You may obtain a copy of the License at 10*2722ceddSAndrew Rist * 11*2722ceddSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2722ceddSAndrew Rist * 13*2722ceddSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2722ceddSAndrew Rist * software distributed under the License is distributed on an 15*2722ceddSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2722ceddSAndrew Rist * KIND, either express or implied. See the License for the 17*2722ceddSAndrew Rist * specific language governing permissions and limitations 18*2722ceddSAndrew Rist * under the License. 19*2722ceddSAndrew Rist * 20*2722ceddSAndrew Rist *************************************************************/ 21*2722ceddSAndrew Rist 22*2722ceddSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_desktop.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include "dp_update.hxx" 29cdf0e10cSrcweir #include "dp_version.hxx" 30cdf0e10cSrcweir #include "dp_identifier.hxx" 31cdf0e10cSrcweir #include "dp_descriptioninfoset.hxx" 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include "rtl/bootstrap.hxx" 34cdf0e10cSrcweir 35cdf0e10cSrcweir using namespace ::com::sun::star; 36cdf0e10cSrcweir using namespace ::com::sun::star::uno; 37cdf0e10cSrcweir using ::rtl::OUString; 38cdf0e10cSrcweir using ::rtl::OString; 39cdf0e10cSrcweir 40cdf0e10cSrcweir 41cdf0e10cSrcweir namespace dp_misc { 42cdf0e10cSrcweir namespace { 43cdf0e10cSrcweir 44cdf0e10cSrcweir int determineHighestVersion( 45cdf0e10cSrcweir ::rtl::OUString const & userVersion, 46cdf0e10cSrcweir ::rtl::OUString const & sharedVersion, 47cdf0e10cSrcweir ::rtl::OUString const & bundledVersion, 48cdf0e10cSrcweir ::rtl::OUString const & onlineVersion) 49cdf0e10cSrcweir { 50cdf0e10cSrcweir int index = 0; 51cdf0e10cSrcweir OUString greatest = userVersion; 52cdf0e10cSrcweir if (dp_misc::compareVersions(sharedVersion, greatest) == dp_misc::GREATER) 53cdf0e10cSrcweir { 54cdf0e10cSrcweir index = 1; 55cdf0e10cSrcweir greatest = sharedVersion; 56cdf0e10cSrcweir } 57cdf0e10cSrcweir if (dp_misc::compareVersions(bundledVersion, greatest) == dp_misc::GREATER) 58cdf0e10cSrcweir { 59cdf0e10cSrcweir index = 2; 60cdf0e10cSrcweir greatest = bundledVersion; 61cdf0e10cSrcweir } 62cdf0e10cSrcweir if (dp_misc::compareVersions(onlineVersion, greatest) == dp_misc::GREATER) 63cdf0e10cSrcweir { 64cdf0e10cSrcweir index = 3; 65cdf0e10cSrcweir } 66cdf0e10cSrcweir return index; 67cdf0e10cSrcweir } 68cdf0e10cSrcweir 69cdf0e10cSrcweir Sequence< Reference< xml::dom::XElement > > 70cdf0e10cSrcweir getUpdateInformation( Reference<deployment::XUpdateInformationProvider > const & updateInformation, 71cdf0e10cSrcweir Sequence< OUString > const & urls, 72cdf0e10cSrcweir OUString const & identifier, 73cdf0e10cSrcweir uno::Any & out_error) 74cdf0e10cSrcweir { 75cdf0e10cSrcweir try { 76cdf0e10cSrcweir return updateInformation->getUpdateInformation(urls, identifier); 77cdf0e10cSrcweir } catch (uno::RuntimeException &) { 78cdf0e10cSrcweir throw; 79cdf0e10cSrcweir } catch (ucb::CommandFailedException & e) { 80cdf0e10cSrcweir out_error = e.Reason; 81cdf0e10cSrcweir } catch (ucb::CommandAbortedException &) { 82cdf0e10cSrcweir } catch (uno::Exception & e) { 83cdf0e10cSrcweir out_error = uno::makeAny(e); 84cdf0e10cSrcweir } 85cdf0e10cSrcweir return 86cdf0e10cSrcweir Sequence<Reference< xml::dom::XElement > >(); 87cdf0e10cSrcweir } 88cdf0e10cSrcweir 89cdf0e10cSrcweir void getOwnUpdateInfos( 90cdf0e10cSrcweir Reference<uno::XComponentContext> const & xContext, 91cdf0e10cSrcweir Reference<deployment::XUpdateInformationProvider > const & updateInformation, 92cdf0e10cSrcweir UpdateInfoMap& inout_map, std::vector<std::pair<Reference<deployment::XPackage>, uno::Any> > & out_errors, 93cdf0e10cSrcweir bool & out_allFound) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir bool allHaveOwnUpdateInformation = true; 96cdf0e10cSrcweir for (UpdateInfoMap::iterator i = inout_map.begin(); i != inout_map.end(); i++) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir OSL_ASSERT(i->second.extension.is()); 99cdf0e10cSrcweir Sequence<OUString> urls(i->second.extension->getUpdateInformationURLs()); 100cdf0e10cSrcweir if (urls.getLength()) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir const OUString id = dp_misc::getIdentifier(i->second.extension); 103cdf0e10cSrcweir uno::Any anyError; 104cdf0e10cSrcweir //It is unclear from the idl if there can be a null reference returned. 105cdf0e10cSrcweir //However all valid information should be the same 106cdf0e10cSrcweir Sequence<Reference< xml::dom::XElement > > 107cdf0e10cSrcweir infos(getUpdateInformation(updateInformation, urls, id, anyError)); 108cdf0e10cSrcweir if (anyError.hasValue()) 109cdf0e10cSrcweir out_errors.push_back(std::make_pair(i->second.extension, anyError)); 110cdf0e10cSrcweir 111cdf0e10cSrcweir for (sal_Int32 j = 0; j < infos.getLength(); ++j) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir dp_misc::DescriptionInfoset infoset( 114cdf0e10cSrcweir xContext, 115cdf0e10cSrcweir Reference< xml::dom::XNode >(infos[j], UNO_QUERY_THROW)); 116cdf0e10cSrcweir if (!infoset.hasDescription()) 117cdf0e10cSrcweir continue; 118cdf0e10cSrcweir boost::optional< OUString > id2(infoset.getIdentifier()); 119cdf0e10cSrcweir if (!id2) 120cdf0e10cSrcweir continue; 121cdf0e10cSrcweir OSL_ASSERT(*id2 == id); 122cdf0e10cSrcweir if (*id2 == id) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir i->second.version = infoset.getVersion(); 125cdf0e10cSrcweir i->second.info = Reference< xml::dom::XNode >( 126cdf0e10cSrcweir infos[j], UNO_QUERY_THROW); 127cdf0e10cSrcweir } 128cdf0e10cSrcweir break; 129cdf0e10cSrcweir } 130cdf0e10cSrcweir } 131cdf0e10cSrcweir else 132cdf0e10cSrcweir { 133cdf0e10cSrcweir allHaveOwnUpdateInformation &= false; 134cdf0e10cSrcweir } 135cdf0e10cSrcweir } 136cdf0e10cSrcweir out_allFound = allHaveOwnUpdateInformation; 137cdf0e10cSrcweir } 138cdf0e10cSrcweir 139cdf0e10cSrcweir void getDefaultUpdateInfos( 140cdf0e10cSrcweir Reference<uno::XComponentContext> const & xContext, 141cdf0e10cSrcweir Reference<deployment::XUpdateInformationProvider > const & updateInformation, 142cdf0e10cSrcweir UpdateInfoMap& inout_map, 143cdf0e10cSrcweir std::vector<std::pair<Reference<deployment::XPackage>, uno::Any> > & out_errors) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir const rtl::OUString sDefaultURL(dp_misc::getExtensionDefaultUpdateURL()); 146cdf0e10cSrcweir OSL_ASSERT(sDefaultURL.getLength()); 147cdf0e10cSrcweir 148cdf0e10cSrcweir Any anyError; 149cdf0e10cSrcweir Sequence< Reference< xml::dom::XElement > > 150cdf0e10cSrcweir infos( 151cdf0e10cSrcweir getUpdateInformation( 152cdf0e10cSrcweir updateInformation, 153cdf0e10cSrcweir Sequence< OUString >(&sDefaultURL, 1), OUString(), anyError)); 154cdf0e10cSrcweir if (anyError.hasValue()) 155cdf0e10cSrcweir out_errors.push_back(std::make_pair(Reference<deployment::XPackage>(), anyError)); 156cdf0e10cSrcweir for (sal_Int32 i = 0; i < infos.getLength(); ++i) 157cdf0e10cSrcweir { 158cdf0e10cSrcweir Reference< xml::dom::XNode > node(infos[i], UNO_QUERY_THROW); 159cdf0e10cSrcweir dp_misc::DescriptionInfoset infoset(xContext, node); 160cdf0e10cSrcweir boost::optional< OUString > id(infoset.getIdentifier()); 161cdf0e10cSrcweir if (!id) { 162cdf0e10cSrcweir continue; 163cdf0e10cSrcweir } 164cdf0e10cSrcweir UpdateInfoMap::iterator j = inout_map.find(*id); 165cdf0e10cSrcweir if (j != inout_map.end()) 166cdf0e10cSrcweir { 167cdf0e10cSrcweir //skip those extension which provide its own update urls 168cdf0e10cSrcweir if (j->second.extension->getUpdateInformationURLs().getLength()) 169cdf0e10cSrcweir continue; 170cdf0e10cSrcweir OUString v(infoset.getVersion()); 171cdf0e10cSrcweir //look for the highest version in the online repository 172cdf0e10cSrcweir if (dp_misc::compareVersions(v, j->second.version) == 173cdf0e10cSrcweir dp_misc::GREATER) 174cdf0e10cSrcweir { 175cdf0e10cSrcweir j->second.version = v; 176cdf0e10cSrcweir j->second.info = node; 177cdf0e10cSrcweir } 178cdf0e10cSrcweir } 179cdf0e10cSrcweir } 180cdf0e10cSrcweir } 181cdf0e10cSrcweir 182cdf0e10cSrcweir bool containsBundledOnly(Sequence<Reference<deployment::XPackage> > const & sameIdExtensions) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir OSL_ASSERT(sameIdExtensions.getLength() == 3); 185cdf0e10cSrcweir if (!sameIdExtensions[0].is() && !sameIdExtensions[1].is() && sameIdExtensions[2].is()) 186cdf0e10cSrcweir return true; 187cdf0e10cSrcweir else 188cdf0e10cSrcweir return false; 189cdf0e10cSrcweir } 190cdf0e10cSrcweir /** Returns true if the list of extensions are bundled extensions and there are no 191cdf0e10cSrcweir other extensions with the same identifier in the shared or user repository. 192cdf0e10cSrcweir If extensionList is NULL, then it is checked if there are only bundled extensions. 193cdf0e10cSrcweir */ 194cdf0e10cSrcweir bool onlyBundledExtensions( 195cdf0e10cSrcweir Reference<deployment::XExtensionManager> const & xExtMgr, 196cdf0e10cSrcweir std::vector< Reference<deployment::XPackage > > const * extensionList) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir OSL_ASSERT(xExtMgr.is()); 199cdf0e10cSrcweir bool onlyBundled = true; 200cdf0e10cSrcweir if (extensionList) 201cdf0e10cSrcweir { 202cdf0e10cSrcweir typedef std::vector<Reference<deployment::XPackage > >::const_iterator CIT; 203cdf0e10cSrcweir for (CIT i = extensionList->begin(); i != extensionList->end(); i++) 204cdf0e10cSrcweir { 205cdf0e10cSrcweir Sequence<Reference<deployment::XPackage> > seqExt = xExtMgr->getExtensionsWithSameIdentifier( 206cdf0e10cSrcweir dp_misc::getIdentifier(*i), (*i)->getName(), Reference<ucb::XCommandEnvironment>()); 207cdf0e10cSrcweir 208cdf0e10cSrcweir if (!containsBundledOnly(seqExt)) 209cdf0e10cSrcweir { 210cdf0e10cSrcweir onlyBundled = false; 211cdf0e10cSrcweir break; 212cdf0e10cSrcweir } 213cdf0e10cSrcweir 214cdf0e10cSrcweir } 215cdf0e10cSrcweir } 216cdf0e10cSrcweir else 217cdf0e10cSrcweir { 218cdf0e10cSrcweir const uno::Sequence< uno::Sequence< Reference<deployment::XPackage > > > seqAllExt = 219cdf0e10cSrcweir xExtMgr->getAllExtensions(Reference<task::XAbortChannel>(), Reference<ucb::XCommandEnvironment>()); 220cdf0e10cSrcweir 221cdf0e10cSrcweir for (int pos = seqAllExt.getLength(); pos --; ) 222cdf0e10cSrcweir { 223cdf0e10cSrcweir if (!containsBundledOnly(seqAllExt[pos])) 224cdf0e10cSrcweir { 225cdf0e10cSrcweir onlyBundled = false; 226cdf0e10cSrcweir break; 227cdf0e10cSrcweir } 228cdf0e10cSrcweir } 229cdf0e10cSrcweir } 230cdf0e10cSrcweir return onlyBundled; 231cdf0e10cSrcweir } 232cdf0e10cSrcweir 233cdf0e10cSrcweir } // anon namespace 234cdf0e10cSrcweir 235cdf0e10cSrcweir 236cdf0e10cSrcweir OUString getExtensionDefaultUpdateURL() 237cdf0e10cSrcweir { 238cdf0e10cSrcweir ::rtl::OUString sUrl( 239cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 240cdf0e10cSrcweir "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("version") 241cdf0e10cSrcweir ":Version:ExtensionUpdateURL}")); 242cdf0e10cSrcweir ::rtl::Bootstrap::expandMacros(sUrl); 243cdf0e10cSrcweir return sUrl; 244cdf0e10cSrcweir } 245cdf0e10cSrcweir 246cdf0e10cSrcweir /* returns the index of the greatest version, starting with 0 247cdf0e10cSrcweir 248cdf0e10cSrcweir */ 249cdf0e10cSrcweir UPDATE_SOURCE isUpdateUserExtension( 250cdf0e10cSrcweir bool bReadOnlyShared, 251cdf0e10cSrcweir ::rtl::OUString const & userVersion, 252cdf0e10cSrcweir ::rtl::OUString const & sharedVersion, 253cdf0e10cSrcweir ::rtl::OUString const & bundledVersion, 254cdf0e10cSrcweir ::rtl::OUString const & onlineVersion) 255cdf0e10cSrcweir { 256cdf0e10cSrcweir UPDATE_SOURCE retVal = UPDATE_SOURCE_NONE; 257cdf0e10cSrcweir if (bReadOnlyShared) 258cdf0e10cSrcweir { 259cdf0e10cSrcweir if (userVersion.getLength()) 260cdf0e10cSrcweir { 261cdf0e10cSrcweir int index = determineHighestVersion( 262cdf0e10cSrcweir userVersion, sharedVersion, bundledVersion, onlineVersion); 263cdf0e10cSrcweir if (index == 1) 264cdf0e10cSrcweir retVal = UPDATE_SOURCE_SHARED; 265cdf0e10cSrcweir else if (index == 2) 266cdf0e10cSrcweir retVal = UPDATE_SOURCE_BUNDLED; 267cdf0e10cSrcweir else if (index == 3) 268cdf0e10cSrcweir retVal = UPDATE_SOURCE_ONLINE; 269cdf0e10cSrcweir } 270cdf0e10cSrcweir else if (sharedVersion.getLength()) 271cdf0e10cSrcweir { 272cdf0e10cSrcweir int index = determineHighestVersion( 273cdf0e10cSrcweir OUString(), sharedVersion, bundledVersion, onlineVersion); 274cdf0e10cSrcweir if (index == 2) 275cdf0e10cSrcweir retVal = UPDATE_SOURCE_BUNDLED; 276cdf0e10cSrcweir else if (index == 3) 277cdf0e10cSrcweir retVal = UPDATE_SOURCE_ONLINE; 278cdf0e10cSrcweir 279cdf0e10cSrcweir } 280cdf0e10cSrcweir //No update for bundled extensions, they are updated only by the setup 281cdf0e10cSrcweir //else if (bundledVersion.getLength()) 282cdf0e10cSrcweir //{ 283cdf0e10cSrcweir // int index = determineHighestVersion( 284cdf0e10cSrcweir // OUString(), OUString(), bundledVersion, onlineVersion); 285cdf0e10cSrcweir // if (index == 3) 286cdf0e10cSrcweir // retVal = UPDATE_SOURCE_ONLINE; 287cdf0e10cSrcweir //} 288cdf0e10cSrcweir } 289cdf0e10cSrcweir else 290cdf0e10cSrcweir { 291cdf0e10cSrcweir if (userVersion.getLength()) 292cdf0e10cSrcweir { 293cdf0e10cSrcweir int index = determineHighestVersion( 294cdf0e10cSrcweir userVersion, sharedVersion, bundledVersion, onlineVersion); 295cdf0e10cSrcweir if (index == 1) 296cdf0e10cSrcweir retVal = UPDATE_SOURCE_SHARED; 297cdf0e10cSrcweir else if (index == 2) 298cdf0e10cSrcweir retVal = UPDATE_SOURCE_BUNDLED; 299cdf0e10cSrcweir else if (index == 3) 300cdf0e10cSrcweir retVal = UPDATE_SOURCE_ONLINE; 301cdf0e10cSrcweir } 302cdf0e10cSrcweir } 303cdf0e10cSrcweir 304cdf0e10cSrcweir return retVal; 305cdf0e10cSrcweir } 306cdf0e10cSrcweir 307cdf0e10cSrcweir UPDATE_SOURCE isUpdateSharedExtension( 308cdf0e10cSrcweir bool bReadOnlyShared, 309cdf0e10cSrcweir ::rtl::OUString const & sharedVersion, 310cdf0e10cSrcweir ::rtl::OUString const & bundledVersion, 311cdf0e10cSrcweir ::rtl::OUString const & onlineVersion) 312cdf0e10cSrcweir { 313cdf0e10cSrcweir if (bReadOnlyShared) 314cdf0e10cSrcweir return UPDATE_SOURCE_NONE; 315cdf0e10cSrcweir UPDATE_SOURCE retVal = UPDATE_SOURCE_NONE; 316cdf0e10cSrcweir 317cdf0e10cSrcweir if (sharedVersion.getLength()) 318cdf0e10cSrcweir { 319cdf0e10cSrcweir int index = determineHighestVersion( 320cdf0e10cSrcweir OUString(), sharedVersion, bundledVersion, onlineVersion); 321cdf0e10cSrcweir if (index == 2) 322cdf0e10cSrcweir retVal = UPDATE_SOURCE_BUNDLED; 323cdf0e10cSrcweir else if (index == 3) 324cdf0e10cSrcweir retVal = UPDATE_SOURCE_ONLINE; 325cdf0e10cSrcweir } 326cdf0e10cSrcweir //No update for bundled extensions, they are updated only by the setup 327cdf0e10cSrcweir //else if (bundledVersion.getLength()) 328cdf0e10cSrcweir //{ 329cdf0e10cSrcweir // int index = determineHighestVersion( 330cdf0e10cSrcweir // OUString(), OUString(), bundledVersion, onlineVersion); 331cdf0e10cSrcweir // if (index == 3) 332cdf0e10cSrcweir // retVal = UPDATE_SOURCE_ONLINE; 333cdf0e10cSrcweir //} 334cdf0e10cSrcweir return retVal; 335cdf0e10cSrcweir } 336cdf0e10cSrcweir 337cdf0e10cSrcweir Reference<deployment::XPackage> 338cdf0e10cSrcweir getExtensionWithHighestVersion( 339cdf0e10cSrcweir Sequence<Reference<deployment::XPackage> > const & seqExt) 340cdf0e10cSrcweir { 341cdf0e10cSrcweir if (seqExt.getLength() == 0) 342cdf0e10cSrcweir return Reference<deployment::XPackage>(); 343cdf0e10cSrcweir 344cdf0e10cSrcweir Reference<deployment::XPackage> greatest; 345cdf0e10cSrcweir sal_Int32 len = seqExt.getLength(); 346cdf0e10cSrcweir 347cdf0e10cSrcweir for (sal_Int32 i = 0; i < len; i++) 348cdf0e10cSrcweir { 349cdf0e10cSrcweir if (!greatest.is()) 350cdf0e10cSrcweir { 351cdf0e10cSrcweir greatest = seqExt[i]; 352cdf0e10cSrcweir continue; 353cdf0e10cSrcweir } 354cdf0e10cSrcweir Reference<deployment::XPackage> const & current = seqExt[i]; 355cdf0e10cSrcweir //greatest has a value 356cdf0e10cSrcweir if (! current.is()) 357cdf0e10cSrcweir continue; 358cdf0e10cSrcweir 359cdf0e10cSrcweir if (dp_misc::compareVersions(current->getVersion(), greatest->getVersion()) == dp_misc::GREATER) 360cdf0e10cSrcweir greatest = current; 361cdf0e10cSrcweir } 362cdf0e10cSrcweir return greatest; 363cdf0e10cSrcweir } 364cdf0e10cSrcweir 365cdf0e10cSrcweir UpdateInfo::UpdateInfo( Reference< deployment::XPackage> const & ext): 366cdf0e10cSrcweir extension(ext) 367cdf0e10cSrcweir { 368cdf0e10cSrcweir } 369cdf0e10cSrcweir 370cdf0e10cSrcweir 371cdf0e10cSrcweir 372cdf0e10cSrcweir UpdateInfoMap getOnlineUpdateInfos( 373cdf0e10cSrcweir Reference<uno::XComponentContext> const &xContext, 374cdf0e10cSrcweir Reference<deployment::XExtensionManager> const & xExtMgr, 375cdf0e10cSrcweir Reference<deployment::XUpdateInformationProvider > const & updateInformation, 376cdf0e10cSrcweir std::vector<Reference<deployment::XPackage > > const * extensionList, 377cdf0e10cSrcweir std::vector<std::pair< Reference<deployment::XPackage>, uno::Any> > & out_errors) 378cdf0e10cSrcweir { 379cdf0e10cSrcweir OSL_ASSERT(xExtMgr.is()); 380cdf0e10cSrcweir UpdateInfoMap infoMap; 381cdf0e10cSrcweir if (!xExtMgr.is() || onlyBundledExtensions(xExtMgr, extensionList)) 382cdf0e10cSrcweir return infoMap; 383cdf0e10cSrcweir 384cdf0e10cSrcweir if (!extensionList) 385cdf0e10cSrcweir { 386cdf0e10cSrcweir const uno::Sequence< uno::Sequence< Reference<deployment::XPackage > > > seqAllExt = xExtMgr->getAllExtensions( 387cdf0e10cSrcweir Reference<task::XAbortChannel>(), Reference<ucb::XCommandEnvironment>()); 388cdf0e10cSrcweir 389cdf0e10cSrcweir //fill the UpdateInfoMap. key = extension identifier, value = UpdateInfo 390cdf0e10cSrcweir for (int pos = seqAllExt.getLength(); pos --; ) 391cdf0e10cSrcweir { 392cdf0e10cSrcweir uno::Sequence<Reference<deployment::XPackage> > const & seqExt = seqAllExt[pos]; 393cdf0e10cSrcweir 394cdf0e10cSrcweir Reference<deployment::XPackage> extension = getExtensionWithHighestVersion(seqExt); 395cdf0e10cSrcweir OSL_ASSERT(extension.is()); 396cdf0e10cSrcweir 397cdf0e10cSrcweir std::pair<UpdateInfoMap::iterator, bool> insertRet = infoMap.insert( 398cdf0e10cSrcweir UpdateInfoMap::value_type( 399cdf0e10cSrcweir dp_misc::getIdentifier(extension), UpdateInfo(extension))); 400cdf0e10cSrcweir OSL_ASSERT(insertRet.second == true); 401cdf0e10cSrcweir } 402cdf0e10cSrcweir } 403cdf0e10cSrcweir else 404cdf0e10cSrcweir { 405cdf0e10cSrcweir typedef std::vector<Reference<deployment::XPackage > >::const_iterator CIT; 406cdf0e10cSrcweir for (CIT i = extensionList->begin(); i != extensionList->end(); i++) 407cdf0e10cSrcweir { 408cdf0e10cSrcweir OSL_ASSERT(i->is()); 409cdf0e10cSrcweir std::pair<UpdateInfoMap::iterator, bool> insertRet = infoMap.insert( 410cdf0e10cSrcweir UpdateInfoMap::value_type( 411cdf0e10cSrcweir dp_misc::getIdentifier(*i), UpdateInfo(*i))); 412cdf0e10cSrcweir OSL_ASSERT(insertRet.second == true); 413cdf0e10cSrcweir } 414cdf0e10cSrcweir } 415cdf0e10cSrcweir 416cdf0e10cSrcweir //Now find the update information for the extensions which provide their own 417cdf0e10cSrcweir //URLs to update information. 418cdf0e10cSrcweir bool allInfosObtained = false; 419cdf0e10cSrcweir getOwnUpdateInfos(xContext, updateInformation, infoMap, out_errors, allInfosObtained); 420cdf0e10cSrcweir 421cdf0e10cSrcweir if (!allInfosObtained) 422cdf0e10cSrcweir getDefaultUpdateInfos(xContext, updateInformation, infoMap, out_errors); 423cdf0e10cSrcweir return infoMap; 424cdf0e10cSrcweir } 425cdf0e10cSrcweir OUString getHighestVersion( 426cdf0e10cSrcweir ::rtl::OUString const & userVersion, 427cdf0e10cSrcweir ::rtl::OUString const & sharedVersion, 428cdf0e10cSrcweir ::rtl::OUString const & bundledVersion, 429cdf0e10cSrcweir ::rtl::OUString const & onlineVersion) 430cdf0e10cSrcweir { 431cdf0e10cSrcweir int index = determineHighestVersion(userVersion, sharedVersion, bundledVersion, onlineVersion); 432cdf0e10cSrcweir switch (index) 433cdf0e10cSrcweir { 434cdf0e10cSrcweir case 0: return userVersion; 435cdf0e10cSrcweir case 1: return sharedVersion; 436cdf0e10cSrcweir case 2: return bundledVersion; 437cdf0e10cSrcweir case 3: return onlineVersion; 438cdf0e10cSrcweir default: OSL_ASSERT(0); 439cdf0e10cSrcweir } 440cdf0e10cSrcweir 441cdf0e10cSrcweir return OUString(); 442cdf0e10cSrcweir } 443cdf0e10cSrcweir } //namespace dp_misc 444