23#include <com/sun/star/deployment/UpdateInformationProvider.hpp>
24#include <com/sun/star/deployment/XPackage.hpp>
25#include <com/sun/star/deployment/XPackageInformationProvider.hpp>
26#include <com/sun/star/deployment/ExtensionManager.hpp>
27#include <com/sun/star/deployment/XUpdateInformationProvider.hpp>
28#include <com/sun/star/lang/IllegalArgumentException.hpp>
29#include <com/sun/star/lang/XServiceInfo.hpp>
30#include <com/sun/star/task/XAbortChannel.hpp>
31#include <com/sun/star/ucb/ContentCreationException.hpp>
32#include <com/sun/star/uno/XComponentContext.hpp>
33#include <com/sun/star/ucb/XCommandEnvironment.hpp>
34#include <com/sun/star/xml/dom/XElement.hpp>
36#include <com/sun/star/uno/Reference.hxx>
37#include <osl/diagnose.h>
38#include <rtl/ustring.hxx>
61class PackageInformationProvider :
62 public ::cppu::WeakImplHelper< deployment::XPackageInformationProvider, lang::XServiceInfo >
74 virtual OUString SAL_CALL getPackageLocation(
const OUString& extensionId )
override;
82 OUString getPackageLocation(
const OUString& repository,
83 std::u16string_view _sExtensionId );
97OUString PackageInformationProvider::getImplementationName()
99 return "com.sun.star.comp.deployment.PackageInformationProvider";
102sal_Bool PackageInformationProvider::supportsService(
const OUString& ServiceName )
107css::uno::Sequence< OUString > PackageInformationProvider::getSupportedServiceNames()
110 return {
"com.sun.star.comp.deployment.PackageInformationProvider" };
113OUString PackageInformationProvider::getPackageLocation(
114 const OUString & repository,
115 std::u16string_view _rExtensionId )
117 OUString aLocationURL;
119 deployment::ExtensionManager::get(
mxContext);
124 xManager->getDeployedExtensions(
129 for (
int pos = packages.getLength(); pos--; )
133 const beans::Optional< OUString > aID = packages[
pos ]->getIdentifier();
134 if ( aID.IsPresent && (aID.Value == _rExtensionId ) )
136 aLocationURL = packages[
pos ]->getURL();
140 catch ( uno::RuntimeException & ) {}
149PackageInformationProvider::getPackageLocation(
const OUString& _sExtensionId )
151 OUString aLocationURL = getPackageLocation(
"user", _sExtensionId );
153 if ( aLocationURL.isEmpty() )
155 aLocationURL = getPackageLocation(
"shared", _sExtensionId );
157 if ( aLocationURL.isEmpty() )
159 aLocationURL = getPackageLocation(
"bundled", _sExtensionId );
161 if ( !aLocationURL.isEmpty() )
166 aLocationURL = aContent.getURL();
168 catch (
const css::ucb::ContentCreationException&)
177PackageInformationProvider::isUpdateAvailable(
const OUString& _sExtensionId )
182 deployment::ExtensionManager::get(
mxContext);
189 std::vector<std::pair<uno::Reference<deployment::XPackage>,
uno::Any > > errors;
191 if (!_sExtensionId.isEmpty())
193 std::vector<uno::Reference<deployment::XPackage> > vecExtensions;
198 extMgr->getExtensionsWithSameIdentifier(
200 vecExtensions.push_back(extension);
202 catch (lang::IllegalArgumentException &)
216 for (
auto const& updateInfo : updateInfoMap)
220 OUString sOnlineVersion;
227 if ( ! ds.hasElements() )
231 OUString sVersionUser;
232 OUString sVersionShared;
233 OUString sVersionBundled;
236 extensions = extMgr->getExtensionsWithSameIdentifier(
239 }
catch (
const lang::IllegalArgumentException&) {
249 sVersionBundled =
extensions[2]->getVersion();
251 bool bSharedReadOnly = extMgr->isReadOnlyRepository(
"shared");
254 bSharedReadOnly, sVersionUser, sVersionShared, sVersionBundled, sOnlineVersion);
256 bSharedReadOnly, sVersionShared, sVersionBundled, sOnlineVersion);
258 OUString updateVersionUser;
259 OUString updateVersionShared;
262 sVersionShared, sVersionBundled, sOnlineVersion);
265 OUString(), sVersionBundled, sOnlineVersion);
266 OUString updateVersion;
268 updateVersion = updateVersionUser;
270 updateVersion = updateVersionShared;
271 if (!updateVersion.isEmpty())
274 OUString aNewEntry[2];
275 aNewEntry[0] = updateInfo.first;
276 aNewEntry[1] = updateVersion;
277 aList.realloc( ++nCount );
278 aList.getArray()[
nCount-1 ] = ::uno::Sequence< OUString >( aNewEntry, 2 );
288 deployment::ExtensionManager::get(
mxContext);
294 allExt = mgr->getAllExtensions(
300 sal_Int32 cAllIds = allExt.getLength();
301 retList.realloc(cAllIds);
302 auto pretList = retList.getArray();
304 for (sal_Int32 i = 0;
i < cAllIds;
i++)
309 seqExtension = allExt[
i];
310 sal_Int32 cExt = seqExtension.getLength();
311 OSL_ASSERT(cExt == 3);
312 for (sal_Int32 j = 0; j < cExt; j++)
330extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
332 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const& )
334 return cppu::acquire(
new dp_info::PackageInformationProvider(context));
Access to the content of an XML description element.
#define TOOLS_WARN_EXCEPTION(area, stream)
static uno::Reference< css::uno::XComponentContext > xContext
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > check(dp_misc::DescriptionInfoset const &infoset)
Check for unsatisfied dependencies.
std::map< OUString, UpdateInfo > UpdateInfoMap
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString getHighestVersion(OUString const &sharedVersion, OUString const &bundledVersion, OUString const &onlineVersion)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC UPDATE_SOURCE isUpdateUserExtension(bool bReadOnlyShared, OUString const &userVersion, OUString const &sharedVersion, OUString const &bundledVersion, std::u16string_view onlineVersion)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC UPDATE_SOURCE isUpdateSharedExtension(bool bReadOnlyShared, OUString const &sharedVersion, OUString const &bundledVersion, std::u16string_view onlineVersion)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC Order compareVersions(std::u16string_view version1, std::u16string_view version2)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC css::uno::Reference< css::deployment::XPackage > getExtensionWithHighestVersion(css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > const &seqExtensionsWithSameId)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString getIdentifier(css::uno::Reference< css::deployment::XPackage > const &package)
Gets the identifier of a package.
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC UpdateInfoMap getOnlineUpdateInfos(css::uno::Reference< css::uno::XComponentContext > const &xContext, css::uno::Reference< css::deployment::XExtensionManager > const &xExtMgr, css::uno::Reference< css::deployment::XUpdateInformationProvider > const &updateInformation, std::vector< css::uno::Reference< css::deployment::XPackage > > const *extensionList, std::vector< std::pair< css::uno::Reference< css::deployment::XPackage >, css::uno::Any > > &out_errors)
css::uno::Reference< css::deployment::XPackageRegistry > create(css::uno::Reference< css::deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)
css::uno::Reference< css::xml::dom::XNode > info
css::uno::Reference< css::deployment::XPackage > extension