1*0a1e2f0eSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*0a1e2f0eSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*0a1e2f0eSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*0a1e2f0eSAndrew Rist * distributed with this work for additional information 6*0a1e2f0eSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*0a1e2f0eSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*0a1e2f0eSAndrew Rist * "License"); you may not use this file except in compliance 9*0a1e2f0eSAndrew Rist * with the License. You may obtain a copy of the License at 10*0a1e2f0eSAndrew Rist * 11*0a1e2f0eSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*0a1e2f0eSAndrew Rist * 13*0a1e2f0eSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*0a1e2f0eSAndrew Rist * software distributed under the License is distributed on an 15*0a1e2f0eSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*0a1e2f0eSAndrew Rist * KIND, either express or implied. See the License for the 17*0a1e2f0eSAndrew Rist * specific language governing permissions and limitations 18*0a1e2f0eSAndrew Rist * under the License. 19*0a1e2f0eSAndrew Rist * 20*0a1e2f0eSAndrew Rist *************************************************************/ 21*0a1e2f0eSAndrew Rist 22*0a1e2f0eSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #if ! defined INCLUDED_DP_UPDATE_HXX 25cdf0e10cSrcweir #define INCLUDED_DP_UPDATE_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include "com/sun/star/deployment/XPackage.hpp" 29cdf0e10cSrcweir #include "com/sun/star/deployment/XExtensionManager.hpp" 30cdf0e10cSrcweir #include "com/sun/star/deployment/XUpdateInformationProvider.hpp" 31cdf0e10cSrcweir #include "com/sun/star/uno/XComponentContext.hpp" 32cdf0e10cSrcweir #include "com/sun/star/xml/dom/XNode.hpp" 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include "rtl/ustrbuf.hxx" 35cdf0e10cSrcweir #include "dp_misc_api.hxx" 36cdf0e10cSrcweir 37cdf0e10cSrcweir #include <map> 38cdf0e10cSrcweir #include <vector> 39cdf0e10cSrcweir 40cdf0e10cSrcweir namespace dp_misc { 41cdf0e10cSrcweir 42cdf0e10cSrcweir /** returns the default update URL (for the update information) which 43cdf0e10cSrcweir is used when an extension does not provide its own URL. 44cdf0e10cSrcweir */ 45cdf0e10cSrcweir DESKTOP_DEPLOYMENTMISC_DLLPUBLIC 46cdf0e10cSrcweir ::rtl::OUString getExtensionDefaultUpdateURL(); 47cdf0e10cSrcweir 48cdf0e10cSrcweir enum UPDATE_SOURCE 49cdf0e10cSrcweir { 50cdf0e10cSrcweir UPDATE_SOURCE_NONE, 51cdf0e10cSrcweir UPDATE_SOURCE_SHARED, 52cdf0e10cSrcweir UPDATE_SOURCE_BUNDLED, 53cdf0e10cSrcweir UPDATE_SOURCE_ONLINE 54cdf0e10cSrcweir }; 55cdf0e10cSrcweir 56cdf0e10cSrcweir /* determine if an update is available which is installed in the 57cdf0e10cSrcweir user repository. 58cdf0e10cSrcweir 59cdf0e10cSrcweir If the return value is UPDATE_SOURCE_NONE, then no update is 60cdf0e10cSrcweir available, otherwise the return value determine from which the 61cdf0e10cSrcweir repository the update is used. 62cdf0e10cSrcweir */ 63cdf0e10cSrcweir DESKTOP_DEPLOYMENTMISC_DLLPUBLIC 64cdf0e10cSrcweir UPDATE_SOURCE isUpdateUserExtension( 65cdf0e10cSrcweir bool bReadOnlyShared, 66cdf0e10cSrcweir ::rtl::OUString const & userVersion, 67cdf0e10cSrcweir ::rtl::OUString const & sharedVersion, 68cdf0e10cSrcweir ::rtl::OUString const & bundledVersion, 69cdf0e10cSrcweir ::rtl::OUString const & onlineVersion); 70cdf0e10cSrcweir 71cdf0e10cSrcweir /* determine if an update is available which is installed in the 72cdf0e10cSrcweir shared repository. 73cdf0e10cSrcweir 74cdf0e10cSrcweir If the return value is UPDATE_SOURCE_NONE, then no update is 75cdf0e10cSrcweir available, otherwise the return value determine from which the 76cdf0e10cSrcweir repository the update is used. 77cdf0e10cSrcweir */ 78cdf0e10cSrcweir DESKTOP_DEPLOYMENTMISC_DLLPUBLIC 79cdf0e10cSrcweir UPDATE_SOURCE isUpdateSharedExtension( 80cdf0e10cSrcweir bool bReadOnlyShared, 81cdf0e10cSrcweir ::rtl::OUString const & sharedVersion, 82cdf0e10cSrcweir ::rtl::OUString const & bundledVersion, 83cdf0e10cSrcweir ::rtl::OUString const & onlineVersion); 84cdf0e10cSrcweir 85cdf0e10cSrcweir /* determines the extension with the highest identifier and returns it 86cdf0e10cSrcweir 87cdf0e10cSrcweir */ 88cdf0e10cSrcweir DESKTOP_DEPLOYMENTMISC_DLLPUBLIC 89cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> 90cdf0e10cSrcweir getExtensionWithHighestVersion( 91cdf0e10cSrcweir ::com::sun::star::uno::Sequence< 92cdf0e10cSrcweir ::com::sun::star::uno::Reference< 93cdf0e10cSrcweir ::com::sun::star::deployment::XPackage> > const & seqExtensionsWithSameId); 94cdf0e10cSrcweir 95cdf0e10cSrcweir 96cdf0e10cSrcweir struct UpdateInfo 97cdf0e10cSrcweir { 98cdf0e10cSrcweir UpdateInfo( ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> const & ext); 99cdf0e10cSrcweir ::com::sun::star::uno::Reference< 100cdf0e10cSrcweir ::com::sun::star::deployment::XPackage> extension; 101cdf0e10cSrcweir //version of the update 102cdf0e10cSrcweir ::rtl::OUString version; 103cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > info; 104cdf0e10cSrcweir }; 105cdf0e10cSrcweir 106cdf0e10cSrcweir typedef std::map< ::rtl::OUString, UpdateInfo > UpdateInfoMap; 107cdf0e10cSrcweir 108cdf0e10cSrcweir /* 109cdf0e10cSrcweir @param extensionList 110cdf0e10cSrcweir List of extension for which online update information are to be obtained. If NULL, then 111cdf0e10cSrcweir for update information are obtained for all installed extension. There may be only one extension 112cdf0e10cSrcweir with a particular identifier contained in the list. If one extension is installed 113cdf0e10cSrcweir in several repositories, then the one with the highest version must be used, because it contains 114cdf0e10cSrcweir the more recent URLs for getting the update information (if at all). 115cdf0e10cSrcweir @param out_errors 116cdf0e10cSrcweir the first member of the pair is the extension and the second the exception that was produced 117cdf0e10cSrcweir when processing the extension. 118cdf0e10cSrcweir 119cdf0e10cSrcweir @return 120cdf0e10cSrcweir A map of UpdateInfo instances. If the parameter extensionList was given, then the map contains 121cdf0e10cSrcweir at only information for those extensions. 122cdf0e10cSrcweir */ 123cdf0e10cSrcweir DESKTOP_DEPLOYMENTMISC_DLLPUBLIC 124cdf0e10cSrcweir UpdateInfoMap getOnlineUpdateInfos( 125cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> const &xContext, 126cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager> const & xExtMgr, 127cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XUpdateInformationProvider > const & updateInformation, 128cdf0e10cSrcweir std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > > const * extensionList, 129cdf0e10cSrcweir ::std::vector< ::std::pair< ::com::sun::star::uno::Reference< 130cdf0e10cSrcweir ::com::sun::star::deployment::XPackage>, ::com::sun::star::uno::Any> > & out_errors); 131cdf0e10cSrcweir 132cdf0e10cSrcweir /* retunrs the highest version from the provided arguments. 133cdf0e10cSrcweir */ 134cdf0e10cSrcweir DESKTOP_DEPLOYMENTMISC_DLLPUBLIC 135cdf0e10cSrcweir ::rtl::OUString getHighestVersion( 136cdf0e10cSrcweir ::rtl::OUString const & userVersion, 137cdf0e10cSrcweir ::rtl::OUString const & sharedVersion, 138cdf0e10cSrcweir ::rtl::OUString const & bundledVersion, 139cdf0e10cSrcweir ::rtl::OUString const & onlineVersion); 140cdf0e10cSrcweir 141cdf0e10cSrcweir } 142cdf0e10cSrcweir 143cdf0e10cSrcweir #endif 144