27 #include <rtl/ustring.hxx>
28 #include <rtl/bootstrap.hxx>
33 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
34 #include <com/sun/star/deployment/DeploymentException.hpp>
35 #include <com/sun/star/deployment/ExtensionRemovedException.hpp>
36 #include <com/sun/star/deployment/InvalidRemovedParameterException.hpp>
37 #include <com/sun/star/ucb/ContentCreationException.hpp>
38 #include <com/sun/star/ucb/CommandAbortedException.hpp>
39 #include <com/sun/star/ucb/CommandFailedException.hpp>
40 #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
41 #include <com/sun/star/ucb/IOErrorCode.hpp>
42 #include <com/sun/star/beans/StringPair.hpp>
43 #include <com/sun/star/sdbc/XResultSet.hpp>
44 #include <com/sun/star/sdbc/XRow.hpp>
64 Reference<deployment::XPackage> xPackage(
65 event.Source, UNO_QUERY_THROW );
66 OUString url( xPackage->getURL() );
68 if (
m_bound.erase( url ) != 1 )
70 SAL_WARN(
"desktop.deployment",
"erase(" << url <<
") != 1");
76 Sequence<Any>
const & args,
82 assert(xContext.is());
83 std::optional<OUString> cachePath;
84 std::optional<bool> readOnly;
97 else if (
m_context.matchIgnoreAsciiCase(
"vnd.sun.star.tdoc:/"))
106 ::osl::MutexGuard guard(
m_aMutex );
107 if (rBHelper.bInDispose || rBHelper.bDisposed) {
108 throw lang::DisposedException(
109 "PackageRegistryBackend instance has already been disposed!",
110 static_cast<OWeakObject *>(
this) );
118 for (
auto const& elem :
m_bound)
119 elem.second->removeEventListener(
this);
122 WeakComponentImplHelperBase::disposing();
129 throw lang::WrappedTargetRuntimeException(
130 "caught unexpected exception while disposing!",
131 static_cast<OWeakObject *>(
this), exc );
138 OUString
const & url, OUString
const & mediaType,
sal_Bool bRemoved,
141 ::osl::ResettableMutexGuard guard(
m_aMutex );
144 t_string2ref::const_iterator
const iFind(
m_bound.find( url ) );
147 Reference<deployment::XPackage> xPackage( iFind->second );
150 if (!mediaType.isEmpty() &&
151 mediaType != xPackage->getPackageType()->getMediaType())
152 throw lang::IllegalArgumentException
153 (
"XPackageRegistry::bindPackage: media type does not match",
154 static_cast<OWeakObject*>(
this), 1);
155 if (xPackage->isRemoved() != bRemoved)
156 throw deployment::InvalidRemovedParameterException(
157 "XPackageRegistry::bindPackage: bRemoved parameter does not match",
158 static_cast<OWeakObject*>(
this), xPackage->isRemoved(), xPackage);
165 Reference<deployment::XPackage> xNewPackage;
168 identifier, xCmdEnv );
173 catch (
const CommandFailedException &) {
176 catch (
const deployment::DeploymentException &) {
181 throw deployment::DeploymentException(
182 "Error binding package: " + url,
183 static_cast<OWeakObject *>(
this), exc );
188 std::pair< t_string2ref::iterator, bool > insertion(
189 m_bound.emplace( url, xNewPackage ) );
190 if (insertion.second)
193 Reference<XInterface>(insertion.first->second) != xNewPackage,
194 "desktop.deployment",
"mismatch");
198 Reference<deployment::XPackage> xPackage( insertion.first->second );
201 insertion.first->second = xNewPackage;
205 xNewPackage->addEventListener(
this );
210 Reference<ucb::XCommandEnvironment>
const & xCmdEnv)
217 const OUString baseDir(sDataFolder);
219 const OUString& url = aTemp.
GetURL();
220 return sDataFolder + url.subView(url.lastIndexOf(
'/'));
228 OUString
const & folderUrl)
230 if (!folderUrl.isEmpty())
235 if (folderUrl.endsWith(
"_"))
237 const OUString tempFile = folderUrl.copy(0, folderUrl.getLength() - 1);
249 std::vector< OUString>
const & usedFolders)
257 Reference<sdbc::XResultSet> xResultSet(
261 std::vector<OUString> tempEntries;
263 while (xResultSet->next())
266 Reference<sdbc::XRow>(
267 xResultSet, UNO_QUERY_THROW )->
getString(
270 if (title.endsWith(
".tmp"))
271 tempEntries.push_back(
275 for (
const OUString & tempEntrie : tempEntries)
277 if (std::find( usedFolders.begin(), usedFolders.end(), tempEntrie ) ==
284 catch (
const ucb::InteractiveAugmentedIOException& e)
288 if (e.Code != ucb::IOErrorCode_NOT_EXISTING)
301 OUString
const & url,
302 OUString
const & rName,
303 OUString
const & displayName,
304 Reference<deployment::XPackageTypeInfo>
const & xPackageType,
306 OUString
const & identifier)
308 m_myBackend( myBackend ),
311 m_displayName( displayName ),
312 m_xPackageType( xPackageType ),
313 m_bRemoved(bRemoved),
314 m_identifier(identifier)
320 !
m_name.isEmpty(),
"desktop.deployment",
"non-empty m_name");
322 rtl::Bootstrap::expandMacros(name);
323 sal_Int32
index = name.lastIndexOf(
'/');
324 if (index != -1 && index < name.getLength())
325 m_name = name.copy(index + 1);
333 WeakComponentImplHelperBase::disposing();
339 ::osl::MutexGuard guard(
m_aMutex );
340 if (rBHelper.bInDispose || rBHelper.bDisposed) {
341 throw lang::DisposedException(
342 "Package instance has already been disposed!",
343 static_cast<OWeakObject *>(const_cast<Package *>(
this)));
353 WeakComponentImplHelperBase::dispose();
358 Reference<lang::XEventListener>
const & xListener )
362 WeakComponentImplHelperBase::addEventListener( xListener );
367 Reference<lang::XEventListener>
const & xListener )
371 WeakComponentImplHelperBase::removeEventListener( xListener );
377 Reference<util::XModifyListener>
const & xListener )
380 rBHelper.addListener(
cppu::UnoType<decltype(xListener)>::
get(), xListener );
385 Reference<util::XModifyListener>
const & xListener )
388 rBHelper.removeListener(
cppu::UnoType<decltype(xListener)>::
get(), xListener );
395 if (abortChannel.is() && abortChannel->isAborted()) {
396 throw CommandAbortedException(
397 "abort!", static_cast<OWeakObject *>(
this) );
406 return new AbortChannel;
417 const css::uno::Reference< css::task::XAbortChannel >&,
418 const css::uno::Reference< css::ucb::XCommandEnvironment >&,
422 throw deployment::ExtensionRemovedException();
428 const css::uno::Reference< css::ucb::XCommandEnvironment >& )
431 throw deployment::ExtensionRemovedException();
437 Reference<task::XAbortChannel>
const &,
440 return Sequence< Reference<deployment::XPackage> >();
454 return beans::Optional<OUString>();
461 throw deployment::ExtensionRemovedException();
475 throw deployment::ExtensionRemovedException();
483 throw deployment::ExtensionRemovedException();
491 throw deployment::ExtensionRemovedException();
499 throw deployment::ExtensionRemovedException();
507 throw deployment::ExtensionRemovedException();
508 css::beans::StringPair aEmptyPair;
516 throw deployment::ExtensionRemovedException();
518 uno::Reference< css::graphic::XGraphic > aEmpty;
529 OUString
const & destFolderURL, OUString
const & newTitle,
533 throw deployment::ExtensionRemovedException();
542 newTitle, nameClashAction);
544 catch (
const css::ucb::ContentCreationException&)
557 if (container ==
nullptr)
560 const Sequence< Reference<XInterface> > elements(
562 lang::EventObject evt( static_cast<OWeakObject *>(
this) );
563 for (
const Reference<XInterface>&
x : elements )
565 Reference<util::XModifyListener> xListener(
x, UNO_QUERY );
567 xListener->modified( evt );
574 Reference<task::XAbortChannel>
const & xAbortChannel,
578 ::osl::ResettableMutexGuard guard(
m_aMutex );
580 AbortChannel::get(xAbortChannel),
586 catch (
const CommandFailedException &) {
589 catch (
const CommandAbortedException &) {
592 catch (
const deployment::DeploymentException &) {
597 throw deployment::DeploymentException(
598 "unexpected " + exc.getValueTypeName() +
": " + e.Message,
599 static_cast<OWeakObject *
>(
this), exc );
605 bool doRegisterPackage,
607 Reference<task::XAbortChannel>
const & xAbortChannel,
615 ::osl::ResettableMutexGuard guard(
m_aMutex );
616 beans::Optional< beans::Ambiguous<sal_Bool> >
option(
619 action = (option.IsPresent &&
620 (option.Value.IsAmbiguous ||
621 (doRegisterPackage ? !option.Value.Value
622 : option.Value.Value)));
626 ProgressLevel progress(
635 AbortChannel::get(xAbortChannel),
639 catch (lang::IllegalArgumentException &) {
641 throw deployment::DeploymentException(
643 ?
DpResId(RID_STR_ERROR_WHILE_REGISTERING)
644 :
DpResId(RID_STR_ERROR_WHILE_REVOKING))
646 static_cast< OWeakObject * >(
this), e);
652 catch (
const CommandFailedException &) {
655 catch (
const CommandAbortedException &) {
658 catch (
const deployment::DeploymentException &) {
663 throw deployment::DeploymentException(
665 ?
DpResId(RID_STR_ERROR_WHILE_REGISTERING)
666 :
DpResId(RID_STR_ERROR_WHILE_REVOKING))
667 +
getDisplayName() +
": " + exc.getValueType().getTypeName() +
" \"" + e.Message
669 static_cast<OWeakObject *
>(
this), exc );
684 Reference<task::XAbortChannel>
const & xAbortChannel,
688 throw deployment::ExtensionRemovedException();
695 Reference<task::XAbortChannel>
const & xAbortChannel,
705 if (
nullptr == pBackend)
711 "Failed to get the BackendImpl",
712 static_cast<OWeakObject*>(const_cast<Package *>(
this)));
726 throw deployment::ExtensionRemovedException();
727 return beans::Optional<OUString>();
749 return getShortDescription();
virtual css::uno::Reference< css::deployment::XPackage > SAL_CALL bindPackage(OUString const &url, OUString const &mediaType, sal_Bool bRemoved, OUString const &identifier, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
void processPackage_impl(bool registerPackage, bool startup, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)
virtual css::beans::Optional< css::beans::Ambiguous< sal_Bool > > isRegistered_(::osl::ResettableMutexGuard &guard,::rtl::Reference< ::dp_misc::AbortChannel > const &abortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)=0
virtual OUString SAL_CALL getFileFilter() override
void checkAborted(::rtl::Reference< ::dp_misc::AbortChannel > const &abortChannel)
PackageRegistryBackend * getMyBackend() const
virtual void SAL_CALL disposing() override
enum dp_registry::backend::PackageRegistryBackend::Context m_eContext
const OUString m_identifier
virtual css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > SAL_CALL getBundle(css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual void SAL_CALL removeEventListener(css::uno::Reference< css::lang::XEventListener > const &xListener) override
virtual void SAL_CALL addEventListener(css::uno::Reference< css::lang::XEventListener > const &xListener) override
virtual ::sal_Int32 SAL_CALL checkPrerequisites(const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel, const css::uno::Reference< css::ucb::XCommandEnvironment > &xCmdEnv, sal_Bool noLicenseChecking) override
virtual css::uno::Sequence< OUString > SAL_CALL getUpdateInformationURLs() override
mutable::osl::Mutex m_aMutex
virtual OUString SAL_CALL getRepositoryName() override
OUString makeURL(OUString const &baseURL, OUString const &relPath_)
appends a relative path to a url.
OUString makeURLAppendSysPathSegment(OUString const &baseURL, OUString const &segment)
appends a relative path to a url.
Package(::rtl::Reference< PackageRegistryBackend > const &myBackend, OUString const &url, OUString const &name, OUString const &displayName, css::uno::Reference< css::deployment::XPackageTypeInfo > const &xPackageType, bool bRemoved, OUString const &identifier)
void deleteUnusedFolders(std::vector< OUString > const &usedFolders)
virtual void SAL_CALL registerPackage(sal_Bool startup, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
exports com.sun.star. container
virtual OUString SAL_CALL getDescription() override
virtual css::uno::Reference< css::deployment::XPackage > bindPackage_(OUString const &url, OUString const &mediaType, bool bRemoved, OUString const &identifier, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)=0
Any SAL_CALL getCaughtException()
virtual void SAL_CALL dispose() override
virtual sal_Bool SAL_CALL isRemoved() override
OUString createFolder(css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)
Reference< XComponentContext > const m_xComponentContext
virtual OUString SAL_CALL getMediaType() override
#define TOOLS_WARN_EXCEPTION(area, stream)
::cppu::WeakComponentImplHelper< css::deployment::XPackage > t_PackageBase
virtual OUString SAL_CALL getName() override
const css::uno::Reference< css::deployment::XPackageTypeInfo > m_xPackageType
virtual void processPackage_(::osl::ResettableMutexGuard &guard, bool registerPackage, bool startup,::rtl::Reference< ::dp_misc::AbortChannel > const &abortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)=0
virtual sal_Bool SAL_CALL isBundle() override
OUString const & getCachePath() const
OUString const & GetURL() const
PackageRegistryBackend(css::uno::Sequence< css::uno::Any > const &args, css::uno::Reference< css::uno::XComponentContext > const &xContext)
virtual void SAL_CALL exportTo(OUString const &destFolderURL, OUString const &newTitle, sal_Int32 nameClashAction, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
css::uno::Reference< css::uno::XComponentContext > m_xComponentContext
virtual OUString SAL_CALL getShortDescription() override
virtual void SAL_CALL revokePackage(sal_Bool startup, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
Reference< XComponentContext > getComponentContext(Reference< XMultiServiceFactory > const &factory)
virtual css::uno::Any SAL_CALL getIcon(sal_Bool highContrast, sal_Bool smallIcon) override
virtual void SAL_CALL removeModifyListener(css::uno::Reference< css::util::XModifyListener > const &xListener) override
virtual css::uno::Reference< css::task::XAbortChannel > SAL_CALL createAbortChannel() override
virtual css::beans::Optional< OUString > SAL_CALL getRegistrationDataURL() override
static uno::Reference< css::uno::XComponentContext > xContext
virtual ::sal_Bool SAL_CALL checkDependencies(const css::uno::Reference< css::ucb::XCommandEnvironment > &xCmdEnv) override
virtual OUString SAL_CALL getVersion() override
virtual css::beans::StringPair SAL_CALL getPublisherInfo() override
#define SAL_WARN_IF(condition, area, stream)
static void deleteTempFolder(OUString const &folderUrl)
virtual void SAL_CALL addModifyListener(css::uno::Reference< css::util::XModifyListener > const &xListener) override
virtual css::beans::Optional< css::beans::Ambiguous< sal_Bool > > SAL_CALL isRegistered(css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
void transferContent(const Content &rSourceContent, InsertOperation eOperation, const OUString &rTitle, const sal_Int32 nNameClashAction, const OUString &rMimeType=OUString(), bool bMajorVersion=false, const OUString &rCommentVersion=OUString(), OUString *pResultURL=nullptr, const OUString &rDocumentId=OUString()) const
::cppu::WeakComponentImplHelper< css::lang::XEventListener, css::deployment::XPackageRegistry, css::lang::XServiceInfo > t_BackendBase
void unwrapArgs(const css::uno::Sequence< css::uno::Any > &seq, Args &...args)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool erase_path(OUString const &url, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv, bool throw_exc=true)
static OUString StrRegisteringPackage()
const OUString & getContext() const
virtual OUString SAL_CALL getLicenseText() override
virtual OUString SAL_CALL getURL() override
virtual void SAL_CALL disposing() override
#define SAL_WARN(area, stream)
virtual ~PackageRegistryBackend() override
virtual OUString SAL_CALL getDisplayName() override
virtual ~TypeInfo() override
OUString getString(const Any &_rAny)
OUString DpResId(TranslateId aId)
css::uno::Sequence< css::uno::Reference< css::uno::XInterface > > SAL_CALL getElements() const
virtual ~Package() override
::rtl::Reference< PackageRegistryBackend > m_myBackend
static OUString StrRevokingPackage()
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool create_folder(::ucbhelper::Content *ucb_content, OUString const &url, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv, bool throw_exc=true)
virtual css::uno::Reference< css::deployment::XPackageTypeInfo > SAL_CALL getPackageType() override
virtual css::beans::Optional< OUString > SAL_CALL getIdentifier() override
virtual OUString SAL_CALL getDescription() override
virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL getIcon(sal_Bool bHighContrast) override