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 #include "dp_backend.h"
28cdf0e10cSrcweir #include "dp_ucb.h"
29cdf0e10cSrcweir #include "rtl/uri.hxx"
30cdf0e10cSrcweir #include "rtl/bootstrap.hxx"
31cdf0e10cSrcweir #include "osl/file.hxx"
32cdf0e10cSrcweir #include "cppuhelper/exc_hlp.hxx"
33cdf0e10cSrcweir #include "comphelper/servicedecl.hxx"
34cdf0e10cSrcweir #include "comphelper/unwrapargs.hxx"
35cdf0e10cSrcweir #include "ucbhelper/content.hxx"
36cdf0e10cSrcweir #include "com/sun/star/lang/WrappedTargetRuntimeException.hpp"
37cdf0e10cSrcweir #include "com/sun/star/deployment/InvalidRemovedParameterException.hpp"
38cdf0e10cSrcweir #include "com/sun/star/deployment/thePackageManagerFactory.hpp"
39cdf0e10cSrcweir #include "com/sun/star/ucb/InteractiveAugmentedIOException.hpp"
40cdf0e10cSrcweir #include "com/sun/star/ucb/IOErrorCode.hpp"
41cdf0e10cSrcweir #include "com/sun/star/beans/StringPair.hpp"
42cdf0e10cSrcweir #include "com/sun/star/sdbc/XResultSet.hpp"
43cdf0e10cSrcweir #include "com/sun/star/sdbc/XRow.hpp"
44cdf0e10cSrcweir #include "unotools/tempfile.hxx"
45cdf0e10cSrcweir 
46cdf0e10cSrcweir 
47cdf0e10cSrcweir using namespace ::dp_misc;
48cdf0e10cSrcweir using namespace ::com::sun::star;
49cdf0e10cSrcweir using namespace ::com::sun::star::uno;
50cdf0e10cSrcweir using namespace ::com::sun::star::ucb;
51cdf0e10cSrcweir using ::rtl::OUString;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir namespace dp_registry {
54cdf0e10cSrcweir namespace backend {
55cdf0e10cSrcweir 
56cdf0e10cSrcweir //______________________________________________________________________________
~PackageRegistryBackend()57cdf0e10cSrcweir PackageRegistryBackend::~PackageRegistryBackend()
58cdf0e10cSrcweir {
59cdf0e10cSrcweir }
60cdf0e10cSrcweir 
61cdf0e10cSrcweir //______________________________________________________________________________
disposing(lang::EventObject const & event)62cdf0e10cSrcweir void PackageRegistryBackend::disposing( lang::EventObject const & event )
63cdf0e10cSrcweir     throw (RuntimeException)
64cdf0e10cSrcweir {
65cdf0e10cSrcweir     Reference<deployment::XPackage> xPackage(
66cdf0e10cSrcweir         event.Source, UNO_QUERY_THROW );
67cdf0e10cSrcweir     OUString url( xPackage->getURL() );
68cdf0e10cSrcweir     ::osl::MutexGuard guard( getMutex() );
69cdf0e10cSrcweir     if ( m_bound.erase( url ) != 1 )
70cdf0e10cSrcweir     {
71cdf0e10cSrcweir         OSL_ASSERT( false );
72cdf0e10cSrcweir     }
73cdf0e10cSrcweir }
74cdf0e10cSrcweir 
75cdf0e10cSrcweir //______________________________________________________________________________
PackageRegistryBackend(Sequence<Any> const & args,Reference<XComponentContext> const & xContext)76cdf0e10cSrcweir PackageRegistryBackend::PackageRegistryBackend(
77cdf0e10cSrcweir     Sequence<Any> const & args,
78cdf0e10cSrcweir     Reference<XComponentContext> const & xContext )
79cdf0e10cSrcweir     : t_BackendBase( getMutex() ),
80cdf0e10cSrcweir       m_xComponentContext( xContext ),
81cdf0e10cSrcweir       m_eContext( CONTEXT_UNKNOWN ),
82cdf0e10cSrcweir       m_readOnly( false )
83cdf0e10cSrcweir {
84cdf0e10cSrcweir     boost::optional<OUString> cachePath;
85cdf0e10cSrcweir     boost::optional<bool> readOnly;
86cdf0e10cSrcweir     comphelper::unwrapArgs( args, m_context, cachePath, readOnly );
87cdf0e10cSrcweir     if (cachePath)
88cdf0e10cSrcweir         m_cachePath = *cachePath;
89cdf0e10cSrcweir     if (readOnly)
90cdf0e10cSrcweir         m_readOnly = *readOnly;
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     if (m_context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("user") ))
93cdf0e10cSrcweir         m_eContext = CONTEXT_USER;
94cdf0e10cSrcweir     else if (m_context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("shared") ))
95cdf0e10cSrcweir         m_eContext = CONTEXT_SHARED;
96cdf0e10cSrcweir     else if (m_context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bundled") ))
97cdf0e10cSrcweir         m_eContext = CONTEXT_BUNDLED;
98cdf0e10cSrcweir     else if (m_context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("tmp") ))
99cdf0e10cSrcweir         m_eContext = CONTEXT_TMP;
100cdf0e10cSrcweir     else if (m_context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bundled_prereg") ))
101cdf0e10cSrcweir         m_eContext = CONTEXT_BUNDLED_PREREG;
102cdf0e10cSrcweir     else if (m_context.matchIgnoreAsciiCaseAsciiL(
103cdf0e10cSrcweir                  RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.tdoc:/") ))
104cdf0e10cSrcweir         m_eContext = CONTEXT_DOCUMENT;
105cdf0e10cSrcweir     else
106cdf0e10cSrcweir         m_eContext = CONTEXT_UNKNOWN;
107cdf0e10cSrcweir }
108cdf0e10cSrcweir 
109cdf0e10cSrcweir //______________________________________________________________________________
check()110cdf0e10cSrcweir void PackageRegistryBackend::check()
111cdf0e10cSrcweir {
112cdf0e10cSrcweir     ::osl::MutexGuard guard( getMutex() );
113cdf0e10cSrcweir     if (rBHelper.bInDispose || rBHelper.bDisposed) {
114cdf0e10cSrcweir         throw lang::DisposedException(
115cdf0e10cSrcweir             OUSTR("PackageRegistryBackend instance has already been disposed!"),
116cdf0e10cSrcweir             static_cast<OWeakObject *>(this) );
117cdf0e10cSrcweir     }
118cdf0e10cSrcweir }
119cdf0e10cSrcweir 
120cdf0e10cSrcweir //______________________________________________________________________________
disposing()121cdf0e10cSrcweir void PackageRegistryBackend::disposing()
122cdf0e10cSrcweir {
123cdf0e10cSrcweir     try {
124cdf0e10cSrcweir         for ( t_string2ref::const_iterator i = m_bound.begin(); i != m_bound.end(); i++)
125cdf0e10cSrcweir             i->second->removeEventListener(this);
126cdf0e10cSrcweir         m_bound.clear();
127cdf0e10cSrcweir         m_xComponentContext.clear();
128cdf0e10cSrcweir         WeakComponentImplHelperBase::disposing();
129cdf0e10cSrcweir     }
130cdf0e10cSrcweir     catch (RuntimeException &) {
131cdf0e10cSrcweir         throw;
132cdf0e10cSrcweir     }
133cdf0e10cSrcweir     catch (Exception &) {
134cdf0e10cSrcweir         Any exc( ::cppu::getCaughtException() );
135cdf0e10cSrcweir         throw lang::WrappedTargetRuntimeException(
136cdf0e10cSrcweir             OUSTR("caught unexpected exception while disposing!"),
137cdf0e10cSrcweir             static_cast<OWeakObject *>(this), exc );
138cdf0e10cSrcweir     }
139cdf0e10cSrcweir }
140cdf0e10cSrcweir 
141cdf0e10cSrcweir // XPackageRegistry
142cdf0e10cSrcweir //______________________________________________________________________________
bindPackage(OUString const & url,OUString const & mediaType,sal_Bool bRemoved,OUString const & identifier,Reference<XCommandEnvironment> const & xCmdEnv)143cdf0e10cSrcweir Reference<deployment::XPackage> PackageRegistryBackend::bindPackage(
144cdf0e10cSrcweir     OUString const & url, OUString const & mediaType, sal_Bool  bRemoved,
145cdf0e10cSrcweir     OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv )
146cdf0e10cSrcweir     throw (deployment::DeploymentException,
147cdf0e10cSrcweir            deployment::InvalidRemovedParameterException,
148cdf0e10cSrcweir            ucb::CommandFailedException,
149cdf0e10cSrcweir            lang::IllegalArgumentException, RuntimeException)
150cdf0e10cSrcweir {
151cdf0e10cSrcweir     ::osl::ResettableMutexGuard guard( getMutex() );
152cdf0e10cSrcweir     check();
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     t_string2ref::const_iterator const iFind( m_bound.find( url ) );
155cdf0e10cSrcweir     if (iFind != m_bound.end())
156cdf0e10cSrcweir     {
157cdf0e10cSrcweir         Reference<deployment::XPackage> xPackage( iFind->second );
158cdf0e10cSrcweir         if (xPackage.is())
159cdf0e10cSrcweir         {
160cdf0e10cSrcweir             if (mediaType.getLength() &&
161cdf0e10cSrcweir                 mediaType != xPackage->getPackageType()->getMediaType())
162cdf0e10cSrcweir                 throw lang::IllegalArgumentException
163cdf0e10cSrcweir                     (OUSTR("XPackageRegistry::bindPackage: media type does not match"),
164cdf0e10cSrcweir                      static_cast<OWeakObject*>(this), 1);
165cdf0e10cSrcweir             if (xPackage->isRemoved() != bRemoved)
166cdf0e10cSrcweir                 throw deployment::InvalidRemovedParameterException(
167cdf0e10cSrcweir                     OUSTR("XPackageRegistry::bindPackage: bRemoved parameter does not match"),
168cdf0e10cSrcweir                     static_cast<OWeakObject*>(this), xPackage->isRemoved(), xPackage);
169cdf0e10cSrcweir             return xPackage;
170cdf0e10cSrcweir         }
171cdf0e10cSrcweir     }
172cdf0e10cSrcweir 
173cdf0e10cSrcweir     guard.clear();
174cdf0e10cSrcweir 
175cdf0e10cSrcweir     Reference<deployment::XPackage> xNewPackage;
176cdf0e10cSrcweir     try {
177cdf0e10cSrcweir         xNewPackage = bindPackage_( url, mediaType, bRemoved,
178cdf0e10cSrcweir             identifier, xCmdEnv );
179cdf0e10cSrcweir     }
180cdf0e10cSrcweir     catch (RuntimeException &) {
181cdf0e10cSrcweir         throw;
182cdf0e10cSrcweir     }
183cdf0e10cSrcweir     catch (lang::IllegalArgumentException &) {
184cdf0e10cSrcweir         throw;
185cdf0e10cSrcweir     }
186cdf0e10cSrcweir     catch (CommandFailedException &) {
187cdf0e10cSrcweir         throw;
188cdf0e10cSrcweir     }
189cdf0e10cSrcweir     catch (deployment::DeploymentException &) {
190cdf0e10cSrcweir         throw;
191cdf0e10cSrcweir     }
192cdf0e10cSrcweir     catch (Exception &) {
193cdf0e10cSrcweir         Any exc( ::cppu::getCaughtException() );
194cdf0e10cSrcweir         throw deployment::DeploymentException(
195cdf0e10cSrcweir             OUSTR("Error binding package: ") + url,
196cdf0e10cSrcweir             static_cast<OWeakObject *>(this), exc );
197cdf0e10cSrcweir     }
198cdf0e10cSrcweir 
199cdf0e10cSrcweir     guard.reset();
200cdf0e10cSrcweir 
201cdf0e10cSrcweir     ::std::pair< t_string2ref::iterator, bool > insertion(
202cdf0e10cSrcweir         m_bound.insert( t_string2ref::value_type( url, xNewPackage ) ) );
203cdf0e10cSrcweir     if (insertion.second)
204cdf0e10cSrcweir     { // first insertion
205cdf0e10cSrcweir         OSL_ASSERT( Reference<XInterface>(insertion.first->second)
206cdf0e10cSrcweir                     == xNewPackage );
207cdf0e10cSrcweir     }
208cdf0e10cSrcweir     else
209cdf0e10cSrcweir     { // found existing entry
210cdf0e10cSrcweir         Reference<deployment::XPackage> xPackage( insertion.first->second );
211cdf0e10cSrcweir         if (xPackage.is())
212cdf0e10cSrcweir             return xPackage;
213cdf0e10cSrcweir         insertion.first->second = xNewPackage;
214cdf0e10cSrcweir     }
215cdf0e10cSrcweir 
216cdf0e10cSrcweir     guard.clear();
217cdf0e10cSrcweir     xNewPackage->addEventListener( this ); // listen for disposing events
218cdf0e10cSrcweir     return xNewPackage;
219cdf0e10cSrcweir }
220cdf0e10cSrcweir 
createFolder(OUString const & relUrl,Reference<ucb::XCommandEnvironment> const & xCmdEnv)221cdf0e10cSrcweir OUString PackageRegistryBackend::createFolder(
222cdf0e10cSrcweir     OUString const & relUrl,
223cdf0e10cSrcweir     Reference<ucb::XCommandEnvironment> const & xCmdEnv)
224cdf0e10cSrcweir {
225cdf0e10cSrcweir     const OUString sDataFolder = makeURL(getCachePath(), relUrl);
226cdf0e10cSrcweir     //make sure the folder exist
227cdf0e10cSrcweir     ucbhelper::Content dataContent;
228cdf0e10cSrcweir     ::dp_misc::create_folder(&dataContent, sDataFolder, xCmdEnv);
229cdf0e10cSrcweir 
230cdf0e10cSrcweir     const OUString sDataFolderURL = dp_misc::expandUnoRcUrl(sDataFolder);
231cdf0e10cSrcweir     const String baseDir(sDataFolder);
232cdf0e10cSrcweir     const ::utl::TempFile aTemp(&baseDir, sal_True);
233cdf0e10cSrcweir     const OUString url = aTemp.GetURL();
234cdf0e10cSrcweir     return sDataFolder + url.copy(url.lastIndexOf('/'));
235cdf0e10cSrcweir }
236cdf0e10cSrcweir 
237cdf0e10cSrcweir //folderURL can have the extension .tmp or .tmp_
238cdf0e10cSrcweir //Before OOo 3.4 the created a tmp file with osl_createTempFile and
239cdf0e10cSrcweir //then created a Folder with a same name and a trailing '_'
240cdf0e10cSrcweir //If the folderURL has no '_' then there is no corresponding tmp file.
deleteTempFolder(OUString const & folderUrl)241cdf0e10cSrcweir void PackageRegistryBackend::deleteTempFolder(
242cdf0e10cSrcweir     OUString const & folderUrl)
243cdf0e10cSrcweir {
244cdf0e10cSrcweir     if (folderUrl.getLength())
245cdf0e10cSrcweir     {
246cdf0e10cSrcweir         erase_path( folderUrl, Reference<XCommandEnvironment>(),
247cdf0e10cSrcweir                     false /* no throw: ignore errors */ );
248cdf0e10cSrcweir 
249cdf0e10cSrcweir         if (folderUrl[folderUrl.getLength() - 1] == '_')
250cdf0e10cSrcweir         {
251cdf0e10cSrcweir             const OUString  tempFile = folderUrl.copy(0, folderUrl.getLength() - 1);
252cdf0e10cSrcweir             erase_path( tempFile, Reference<XCommandEnvironment>(),
253cdf0e10cSrcweir                         false /* no throw: ignore errors */ );
254cdf0e10cSrcweir         }
255cdf0e10cSrcweir     }
256cdf0e10cSrcweir }
257cdf0e10cSrcweir 
258cdf0e10cSrcweir //usedFolders can contain folder names which have the extension .tmp or .tmp_
259cdf0e10cSrcweir //Before OOo 3.4 we created a tmp file with osl_createTempFile and
260cdf0e10cSrcweir //then created a Folder with a same name and a trailing '_'
261cdf0e10cSrcweir //If the folderURL has no '_' then there is no corresponding tmp file.
deleteUnusedFolders(OUString const & relUrl,::std::list<OUString> const & usedFolders)262cdf0e10cSrcweir void PackageRegistryBackend::deleteUnusedFolders(
263cdf0e10cSrcweir     OUString const & relUrl,
264cdf0e10cSrcweir     ::std::list< OUString> const & usedFolders)
265cdf0e10cSrcweir {
266cdf0e10cSrcweir     try
267cdf0e10cSrcweir     {
268cdf0e10cSrcweir         const OUString sDataFolder = makeURL(getCachePath(), relUrl);
269cdf0e10cSrcweir         ::ucbhelper::Content tempFolder(
270cdf0e10cSrcweir             sDataFolder, Reference<ucb::XCommandEnvironment>());
271cdf0e10cSrcweir         Reference<sdbc::XResultSet> xResultSet(
272cdf0e10cSrcweir             tempFolder.createCursor(
273cdf0e10cSrcweir                 Sequence<OUString>( &StrTitle::get(), 1 ),
274cdf0e10cSrcweir                 ::ucbhelper::INCLUDE_FOLDERS_ONLY ) );
275cdf0e10cSrcweir         // get all temp directories:
276cdf0e10cSrcweir         ::std::vector<OUString> tempEntries;
277cdf0e10cSrcweir 
278cdf0e10cSrcweir         char tmp[] = ".tmp";
279cdf0e10cSrcweir 
280cdf0e10cSrcweir         //Check for ".tmp_" can be removed after OOo 4.0
281cdf0e10cSrcweir         char tmp_[] = ".tmp_";
282cdf0e10cSrcweir         while (xResultSet->next())
283cdf0e10cSrcweir         {
284cdf0e10cSrcweir             OUString title(
285cdf0e10cSrcweir                 Reference<sdbc::XRow>(
286cdf0e10cSrcweir                     xResultSet, UNO_QUERY_THROW )->getString(
287cdf0e10cSrcweir                         1 /* Title */ ) );
288cdf0e10cSrcweir 
289cdf0e10cSrcweir             if (title.endsWithAsciiL(tmp, sizeof(tmp) - 1)
290cdf0e10cSrcweir                 || title.endsWithAsciiL(tmp_, sizeof(tmp_) - 1))
291cdf0e10cSrcweir                 tempEntries.push_back(
292cdf0e10cSrcweir                     makeURLAppendSysPathSegment(sDataFolder, title));
293cdf0e10cSrcweir         }
294cdf0e10cSrcweir 
295cdf0e10cSrcweir         for ( ::std::size_t pos = 0; pos < tempEntries.size(); ++pos )
296cdf0e10cSrcweir         {
297cdf0e10cSrcweir             if (::std::find( usedFolders.begin(), usedFolders.end(), tempEntries[pos] ) ==
298cdf0e10cSrcweir                 usedFolders.end())
299cdf0e10cSrcweir             {
300cdf0e10cSrcweir                 deleteTempFolder(tempEntries[pos]);
301cdf0e10cSrcweir             }
302cdf0e10cSrcweir         }
303cdf0e10cSrcweir     }
304cdf0e10cSrcweir     catch (ucb::InteractiveAugmentedIOException& e)
305cdf0e10cSrcweir     {
306cdf0e10cSrcweir         //In case the folder containing all the data folder does not
307cdf0e10cSrcweir         //exist yet, we ignore the exception
308cdf0e10cSrcweir         if (e.Code != ucb::IOErrorCode_NOT_EXISTING)
309cdf0e10cSrcweir             throw e;
310cdf0e10cSrcweir     }
311cdf0e10cSrcweir 
312cdf0e10cSrcweir }
313cdf0e10cSrcweir 
314cdf0e10cSrcweir //##############################################################################
315cdf0e10cSrcweir 
316cdf0e10cSrcweir //______________________________________________________________________________
~Package()317cdf0e10cSrcweir Package::~Package()
318cdf0e10cSrcweir {
319cdf0e10cSrcweir }
320cdf0e10cSrcweir 
321cdf0e10cSrcweir //______________________________________________________________________________
Package(::rtl::Reference<PackageRegistryBackend> const & myBackend,OUString const & url,OUString const & rName,OUString const & displayName,Reference<deployment::XPackageTypeInfo> const & xPackageType,bool bRemoved,OUString const & identifier)322cdf0e10cSrcweir Package::Package( ::rtl::Reference<PackageRegistryBackend> const & myBackend,
323cdf0e10cSrcweir                   OUString const & url,
324cdf0e10cSrcweir                   OUString const & rName,
325cdf0e10cSrcweir                   OUString const & displayName,
326cdf0e10cSrcweir                   Reference<deployment::XPackageTypeInfo> const & xPackageType,
327cdf0e10cSrcweir                   bool bRemoved,
328cdf0e10cSrcweir                   OUString const & identifier)
329cdf0e10cSrcweir     : t_PackageBase( getMutex() ),
330cdf0e10cSrcweir       m_myBackend( myBackend ),
331cdf0e10cSrcweir       m_url( url ),
332cdf0e10cSrcweir       m_name( rName ),
333cdf0e10cSrcweir       m_displayName( displayName ),
334cdf0e10cSrcweir       m_xPackageType( xPackageType ),
335cdf0e10cSrcweir       m_bRemoved(bRemoved),
336cdf0e10cSrcweir       m_identifier(identifier)
337cdf0e10cSrcweir {
338cdf0e10cSrcweir     if (m_bRemoved)
339cdf0e10cSrcweir     {
340cdf0e10cSrcweir         //We use the last segment of the URL
341cdf0e10cSrcweir         OSL_ASSERT(m_name.getLength() == 0);
342cdf0e10cSrcweir         OUString name = m_url;
343cdf0e10cSrcweir         rtl::Bootstrap::expandMacros(name);
344cdf0e10cSrcweir         sal_Int32 index = name.lastIndexOf('/');
345cdf0e10cSrcweir         if (index != -1 && index < name.getLength())
346cdf0e10cSrcweir             m_name = name.copy(index + 1);
347cdf0e10cSrcweir     }
348cdf0e10cSrcweir }
349cdf0e10cSrcweir 
350cdf0e10cSrcweir //______________________________________________________________________________
disposing()351cdf0e10cSrcweir void Package::disposing()
352cdf0e10cSrcweir {
353cdf0e10cSrcweir     m_myBackend.clear();
354cdf0e10cSrcweir     WeakComponentImplHelperBase::disposing();
355cdf0e10cSrcweir }
356cdf0e10cSrcweir 
357cdf0e10cSrcweir //______________________________________________________________________________
check() const358cdf0e10cSrcweir void Package::check() const
359cdf0e10cSrcweir {
360cdf0e10cSrcweir     ::osl::MutexGuard guard( getMutex() );
361cdf0e10cSrcweir     if (rBHelper.bInDispose || rBHelper.bDisposed) {
362cdf0e10cSrcweir         throw lang::DisposedException(
363cdf0e10cSrcweir             OUSTR("Package instance has already been disposed!"),
364cdf0e10cSrcweir             static_cast<OWeakObject *>(const_cast<Package *>(this)));
365cdf0e10cSrcweir     }
366cdf0e10cSrcweir }
367cdf0e10cSrcweir 
368cdf0e10cSrcweir // XComponent
369cdf0e10cSrcweir //______________________________________________________________________________
dispose()370cdf0e10cSrcweir void Package::dispose() throw (RuntimeException)
371cdf0e10cSrcweir {
3728402cd44SMichael Stahl     //Do not call check here. We must not throw an exception here if the object
3738402cd44SMichael Stahl     //is being disposed or is already disposed. See com.sun.star.lang.XComponent
374cdf0e10cSrcweir     WeakComponentImplHelperBase::dispose();
375cdf0e10cSrcweir }
376cdf0e10cSrcweir 
377cdf0e10cSrcweir //______________________________________________________________________________
addEventListener(Reference<lang::XEventListener> const & xListener)378cdf0e10cSrcweir void Package::addEventListener(
379cdf0e10cSrcweir     Reference<lang::XEventListener> const & xListener ) throw (RuntimeException)
380cdf0e10cSrcweir {
3818402cd44SMichael Stahl     //Do not call check here. We must not throw an exception here if the object
3828402cd44SMichael Stahl     //is being disposed or is already disposed. See com.sun.star.lang.XComponent
383cdf0e10cSrcweir     WeakComponentImplHelperBase::addEventListener( xListener );
384cdf0e10cSrcweir }
385cdf0e10cSrcweir 
386cdf0e10cSrcweir //______________________________________________________________________________
removeEventListener(Reference<lang::XEventListener> const & xListener)387cdf0e10cSrcweir void Package::removeEventListener(
388cdf0e10cSrcweir     Reference<lang::XEventListener> const & xListener ) throw (RuntimeException)
389cdf0e10cSrcweir {
3908402cd44SMichael Stahl     //Do not call check here. We must not throw an exception here if the object
3918402cd44SMichael Stahl     //is being disposed or is already disposed. See com.sun.star.lang.XComponent
392cdf0e10cSrcweir     WeakComponentImplHelperBase::removeEventListener( xListener );
393cdf0e10cSrcweir }
394cdf0e10cSrcweir 
395cdf0e10cSrcweir // XModifyBroadcaster
396cdf0e10cSrcweir //______________________________________________________________________________
addModifyListener(Reference<util::XModifyListener> const & xListener)397cdf0e10cSrcweir void Package::addModifyListener(
398cdf0e10cSrcweir     Reference<util::XModifyListener> const & xListener )
399cdf0e10cSrcweir     throw (RuntimeException)
400cdf0e10cSrcweir {
401cdf0e10cSrcweir     check();
402cdf0e10cSrcweir     rBHelper.addListener( ::getCppuType( &xListener ), xListener );
403cdf0e10cSrcweir }
404cdf0e10cSrcweir 
405cdf0e10cSrcweir //______________________________________________________________________________
removeModifyListener(Reference<util::XModifyListener> const & xListener)406cdf0e10cSrcweir void Package::removeModifyListener(
407cdf0e10cSrcweir     Reference<util::XModifyListener> const & xListener )
408cdf0e10cSrcweir     throw (RuntimeException)
409cdf0e10cSrcweir {
410cdf0e10cSrcweir     check();
411cdf0e10cSrcweir     rBHelper.removeListener( ::getCppuType( &xListener ), xListener );
412cdf0e10cSrcweir }
413cdf0e10cSrcweir 
414cdf0e10cSrcweir //______________________________________________________________________________
checkAborted(::rtl::Reference<AbortChannel> const & abortChannel)415cdf0e10cSrcweir void Package::checkAborted(
416cdf0e10cSrcweir     ::rtl::Reference<AbortChannel> const & abortChannel )
417cdf0e10cSrcweir {
418cdf0e10cSrcweir     if (abortChannel.is() && abortChannel->isAborted()) {
419cdf0e10cSrcweir         throw CommandAbortedException(
420cdf0e10cSrcweir             OUSTR("abort!"), static_cast<OWeakObject *>(this) );
421cdf0e10cSrcweir     }
422cdf0e10cSrcweir }
423cdf0e10cSrcweir 
424cdf0e10cSrcweir // XPackage
425cdf0e10cSrcweir //______________________________________________________________________________
createAbortChannel()426cdf0e10cSrcweir Reference<task::XAbortChannel> Package::createAbortChannel()
427cdf0e10cSrcweir     throw (RuntimeException)
428cdf0e10cSrcweir {
429cdf0e10cSrcweir     check();
430cdf0e10cSrcweir     return new AbortChannel;
431cdf0e10cSrcweir }
432cdf0e10cSrcweir 
433cdf0e10cSrcweir //______________________________________________________________________________
isBundle()434cdf0e10cSrcweir sal_Bool Package::isBundle() throw (RuntimeException)
435cdf0e10cSrcweir {
436cdf0e10cSrcweir     return false; // default
437cdf0e10cSrcweir }
438cdf0e10cSrcweir 
439cdf0e10cSrcweir //______________________________________________________________________________
checkPrerequisites(const css::uno::Reference<css::task::XAbortChannel> &,const css::uno::Reference<css::ucb::XCommandEnvironment> &,sal_Bool)440cdf0e10cSrcweir ::sal_Int32 Package::checkPrerequisites(
441cdf0e10cSrcweir 		const css::uno::Reference< css::task::XAbortChannel >&,
442cdf0e10cSrcweir 		const css::uno::Reference< css::ucb::XCommandEnvironment >&,
443cdf0e10cSrcweir         sal_Bool)
444cdf0e10cSrcweir 		throw (css::deployment::DeploymentException,
445cdf0e10cSrcweir                css::deployment::ExtensionRemovedException,
446cdf0e10cSrcweir                css::ucb::CommandFailedException,
447cdf0e10cSrcweir                css::ucb::CommandAbortedException,
448cdf0e10cSrcweir                css::uno::RuntimeException)
449cdf0e10cSrcweir {
450cdf0e10cSrcweir     if (m_bRemoved)
451cdf0e10cSrcweir         throw deployment::ExtensionRemovedException();
452cdf0e10cSrcweir 	return 0;
453cdf0e10cSrcweir }
454cdf0e10cSrcweir 
455cdf0e10cSrcweir //______________________________________________________________________________
checkDependencies(const css::uno::Reference<css::ucb::XCommandEnvironment> &)456cdf0e10cSrcweir ::sal_Bool Package::checkDependencies(
457cdf0e10cSrcweir 		const css::uno::Reference< css::ucb::XCommandEnvironment >& )
458cdf0e10cSrcweir 		throw (css::deployment::DeploymentException,
459cdf0e10cSrcweir                css::deployment::ExtensionRemovedException,
460cdf0e10cSrcweir                css::ucb::CommandFailedException,
461cdf0e10cSrcweir                css::uno::RuntimeException)
462cdf0e10cSrcweir {
463cdf0e10cSrcweir     if (m_bRemoved)
464cdf0e10cSrcweir         throw deployment::ExtensionRemovedException();
465cdf0e10cSrcweir 	return true;
466cdf0e10cSrcweir }
467cdf0e10cSrcweir 
468cdf0e10cSrcweir 
469cdf0e10cSrcweir //______________________________________________________________________________
getBundle(Reference<task::XAbortChannel> const &,Reference<XCommandEnvironment> const &)470cdf0e10cSrcweir Sequence< Reference<deployment::XPackage> > Package::getBundle(
471cdf0e10cSrcweir     Reference<task::XAbortChannel> const &,
472cdf0e10cSrcweir     Reference<XCommandEnvironment> const & )
473cdf0e10cSrcweir     throw (deployment::DeploymentException,
474cdf0e10cSrcweir            CommandFailedException, CommandAbortedException,
475cdf0e10cSrcweir            lang::IllegalArgumentException, RuntimeException)
476cdf0e10cSrcweir {
477cdf0e10cSrcweir     return Sequence< Reference<deployment::XPackage> >();
478cdf0e10cSrcweir }
479cdf0e10cSrcweir 
480cdf0e10cSrcweir //______________________________________________________________________________
getName()481cdf0e10cSrcweir OUString Package::getName() throw (RuntimeException)
482cdf0e10cSrcweir {
483cdf0e10cSrcweir     return m_name;
484cdf0e10cSrcweir }
485cdf0e10cSrcweir 
getIdentifier()486cdf0e10cSrcweir beans::Optional<OUString> Package::getIdentifier() throw (RuntimeException)
487cdf0e10cSrcweir {
488cdf0e10cSrcweir     if (m_bRemoved)
489cdf0e10cSrcweir         return beans::Optional<OUString>(true, m_identifier);
490cdf0e10cSrcweir 
491cdf0e10cSrcweir     return beans::Optional<OUString>();
492cdf0e10cSrcweir }
493cdf0e10cSrcweir 
494cdf0e10cSrcweir //______________________________________________________________________________
getVersion()495cdf0e10cSrcweir OUString Package::getVersion() throw (
496cdf0e10cSrcweir     deployment::ExtensionRemovedException,
497cdf0e10cSrcweir     RuntimeException)
498cdf0e10cSrcweir {
499cdf0e10cSrcweir     if (m_bRemoved)
500cdf0e10cSrcweir         throw deployment::ExtensionRemovedException();
501cdf0e10cSrcweir     return OUString();
502cdf0e10cSrcweir }
503cdf0e10cSrcweir 
504cdf0e10cSrcweir //______________________________________________________________________________
getURL()505cdf0e10cSrcweir OUString Package::getURL() throw (RuntimeException)
506cdf0e10cSrcweir {
507cdf0e10cSrcweir     return m_url;
508cdf0e10cSrcweir }
509cdf0e10cSrcweir 
510cdf0e10cSrcweir //______________________________________________________________________________
getDisplayName()511cdf0e10cSrcweir OUString Package::getDisplayName() throw (
512cdf0e10cSrcweir     deployment::ExtensionRemovedException, RuntimeException)
513cdf0e10cSrcweir {
514cdf0e10cSrcweir     if (m_bRemoved)
515cdf0e10cSrcweir         throw deployment::ExtensionRemovedException();
516cdf0e10cSrcweir     return m_displayName;
517cdf0e10cSrcweir }
518cdf0e10cSrcweir 
519cdf0e10cSrcweir //______________________________________________________________________________
getDescription()520cdf0e10cSrcweir OUString Package::getDescription() throw (
521cdf0e10cSrcweir     deployment::ExtensionRemovedException,RuntimeException)
522cdf0e10cSrcweir {
523cdf0e10cSrcweir     if (m_bRemoved)
524cdf0e10cSrcweir         throw deployment::ExtensionRemovedException();
525cdf0e10cSrcweir     return OUString();
526cdf0e10cSrcweir }
527cdf0e10cSrcweir 
528cdf0e10cSrcweir //______________________________________________________________________________
getLicenseText()529cdf0e10cSrcweir OUString Package::getLicenseText() throw (
530cdf0e10cSrcweir     deployment::ExtensionRemovedException,RuntimeException)
531cdf0e10cSrcweir {
532cdf0e10cSrcweir     if (m_bRemoved)
533cdf0e10cSrcweir         throw deployment::ExtensionRemovedException();
534cdf0e10cSrcweir     return OUString();
535cdf0e10cSrcweir }
536cdf0e10cSrcweir 
537cdf0e10cSrcweir //______________________________________________________________________________
getUpdateInformationURLs()538cdf0e10cSrcweir Sequence<OUString> Package::getUpdateInformationURLs() throw (
539cdf0e10cSrcweir     deployment::ExtensionRemovedException, RuntimeException)
540cdf0e10cSrcweir {
541cdf0e10cSrcweir     if (m_bRemoved)
542cdf0e10cSrcweir         throw deployment::ExtensionRemovedException();
543cdf0e10cSrcweir     return Sequence<OUString>();
544cdf0e10cSrcweir }
545cdf0e10cSrcweir 
546cdf0e10cSrcweir //______________________________________________________________________________
getPublisherInfo()547cdf0e10cSrcweir css::beans::StringPair Package::getPublisherInfo() throw (
548cdf0e10cSrcweir     deployment::ExtensionRemovedException, RuntimeException)
549cdf0e10cSrcweir {
550cdf0e10cSrcweir     if (m_bRemoved)
551cdf0e10cSrcweir         throw deployment::ExtensionRemovedException();
552cdf0e10cSrcweir     css::beans::StringPair aEmptyPair;
553cdf0e10cSrcweir     return aEmptyPair;
554cdf0e10cSrcweir }
555cdf0e10cSrcweir 
556cdf0e10cSrcweir //______________________________________________________________________________
getIcon(sal_Bool)557cdf0e10cSrcweir uno::Reference< css::graphic::XGraphic > Package::getIcon( sal_Bool /*bHighContrast*/ )
558cdf0e10cSrcweir     throw (deployment::ExtensionRemovedException, RuntimeException )
559cdf0e10cSrcweir {
560cdf0e10cSrcweir     if (m_bRemoved)
561cdf0e10cSrcweir         throw deployment::ExtensionRemovedException();
562cdf0e10cSrcweir 
563cdf0e10cSrcweir     uno::Reference< css::graphic::XGraphic > aEmpty;
564cdf0e10cSrcweir     return aEmpty;
565cdf0e10cSrcweir }
566cdf0e10cSrcweir 
567cdf0e10cSrcweir //______________________________________________________________________________
getPackageType()568cdf0e10cSrcweir Reference<deployment::XPackageTypeInfo> Package::getPackageType()
569cdf0e10cSrcweir     throw (RuntimeException)
570cdf0e10cSrcweir {
571cdf0e10cSrcweir     return m_xPackageType;
572cdf0e10cSrcweir }
573cdf0e10cSrcweir 
574cdf0e10cSrcweir //______________________________________________________________________________
exportTo(OUString const & destFolderURL,OUString const & newTitle,sal_Int32 nameClashAction,Reference<XCommandEnvironment> const & xCmdEnv)575cdf0e10cSrcweir void Package::exportTo(
576cdf0e10cSrcweir     OUString const & destFolderURL, OUString const & newTitle,
577cdf0e10cSrcweir     sal_Int32 nameClashAction, Reference<XCommandEnvironment> const & xCmdEnv )
578cdf0e10cSrcweir     throw (deployment::ExtensionRemovedException,
579cdf0e10cSrcweir            CommandFailedException, CommandAbortedException, RuntimeException)
580cdf0e10cSrcweir {
581cdf0e10cSrcweir     if (m_bRemoved)
582cdf0e10cSrcweir         throw deployment::ExtensionRemovedException();
583cdf0e10cSrcweir 
584cdf0e10cSrcweir     ::ucbhelper::Content destFolder( destFolderURL, xCmdEnv );
585cdf0e10cSrcweir     ::ucbhelper::Content sourceContent( getURL(), xCmdEnv );
586cdf0e10cSrcweir     if (! destFolder.transferContent(
587cdf0e10cSrcweir             sourceContent, ::ucbhelper::InsertOperation_COPY,
588cdf0e10cSrcweir             newTitle, nameClashAction ))
589cdf0e10cSrcweir         throw RuntimeException( OUSTR("UCB transferContent() failed!"), 0 );
590cdf0e10cSrcweir }
591cdf0e10cSrcweir 
592cdf0e10cSrcweir //______________________________________________________________________________
fireModified()593cdf0e10cSrcweir void Package::fireModified()
594cdf0e10cSrcweir {
595cdf0e10cSrcweir     ::cppu::OInterfaceContainerHelper * container = rBHelper.getContainer(
596cdf0e10cSrcweir         ::getCppuType( static_cast<Reference<
597cdf0e10cSrcweir                        util::XModifyListener> const *>(0) ) );
598cdf0e10cSrcweir     if (container != 0) {
599cdf0e10cSrcweir         Sequence< Reference<XInterface> > elements(
600cdf0e10cSrcweir             container->getElements() );
601cdf0e10cSrcweir         lang::EventObject evt( static_cast<OWeakObject *>(this) );
602cdf0e10cSrcweir         for ( sal_Int32 pos = 0; pos < elements.getLength(); ++pos )
603cdf0e10cSrcweir         {
604cdf0e10cSrcweir             Reference<util::XModifyListener> xListener(
605cdf0e10cSrcweir                 elements[ pos ], UNO_QUERY );
606cdf0e10cSrcweir             if (xListener.is())
607cdf0e10cSrcweir                 xListener->modified( evt );
608cdf0e10cSrcweir         }
609cdf0e10cSrcweir     }
610cdf0e10cSrcweir }
611cdf0e10cSrcweir 
612cdf0e10cSrcweir // XPackage
613cdf0e10cSrcweir //______________________________________________________________________________
isRegistered(Reference<task::XAbortChannel> const & xAbortChannel,Reference<XCommandEnvironment> const & xCmdEnv)614cdf0e10cSrcweir beans::Optional< beans::Ambiguous<sal_Bool> > Package::isRegistered(
615cdf0e10cSrcweir     Reference<task::XAbortChannel> const & xAbortChannel,
616cdf0e10cSrcweir     Reference<XCommandEnvironment> const & xCmdEnv )
617cdf0e10cSrcweir     throw (deployment::DeploymentException,
618cdf0e10cSrcweir            CommandFailedException, CommandAbortedException, RuntimeException)
619cdf0e10cSrcweir {
620cdf0e10cSrcweir     try {
621cdf0e10cSrcweir         ::osl::ResettableMutexGuard guard( getMutex() );
622cdf0e10cSrcweir         return isRegistered_( guard,
623cdf0e10cSrcweir                               AbortChannel::get(xAbortChannel),
624cdf0e10cSrcweir                               xCmdEnv );
625cdf0e10cSrcweir     }
626cdf0e10cSrcweir     catch (RuntimeException &) {
627cdf0e10cSrcweir         throw;
628cdf0e10cSrcweir     }
629cdf0e10cSrcweir     catch (CommandFailedException &) {
630cdf0e10cSrcweir         throw;
631cdf0e10cSrcweir     }
632cdf0e10cSrcweir     catch (CommandAbortedException &) {
633cdf0e10cSrcweir         throw;
634cdf0e10cSrcweir     }
635cdf0e10cSrcweir     catch (deployment::DeploymentException &) {
636cdf0e10cSrcweir         throw;
637cdf0e10cSrcweir     }
638cdf0e10cSrcweir     catch (Exception &) {
639cdf0e10cSrcweir         Any exc( ::cppu::getCaughtException() );
640cdf0e10cSrcweir         throw deployment::DeploymentException(
641cdf0e10cSrcweir             OUSTR("unexpected exception occured!"),
642cdf0e10cSrcweir             static_cast<OWeakObject *>(this), exc );
643cdf0e10cSrcweir     }
644cdf0e10cSrcweir }
645cdf0e10cSrcweir 
646cdf0e10cSrcweir //______________________________________________________________________________
processPackage_impl(bool doRegisterPackage,bool startup,Reference<task::XAbortChannel> const & xAbortChannel,Reference<XCommandEnvironment> const & xCmdEnv)647cdf0e10cSrcweir void Package::processPackage_impl(
648cdf0e10cSrcweir     bool doRegisterPackage,
649cdf0e10cSrcweir     bool startup,
650cdf0e10cSrcweir     Reference<task::XAbortChannel> const & xAbortChannel,
651cdf0e10cSrcweir     Reference<XCommandEnvironment> const & xCmdEnv )
652cdf0e10cSrcweir {
653cdf0e10cSrcweir     check();
654cdf0e10cSrcweir     bool action = false;
655cdf0e10cSrcweir 
656cdf0e10cSrcweir     try {
657cdf0e10cSrcweir         try {
658cdf0e10cSrcweir             ::osl::ResettableMutexGuard guard( getMutex() );
659cdf0e10cSrcweir             beans::Optional< beans::Ambiguous<sal_Bool> > option(
660cdf0e10cSrcweir                 isRegistered_( guard, AbortChannel::get(xAbortChannel),
661cdf0e10cSrcweir                                xCmdEnv ) );
662cdf0e10cSrcweir             action = (option.IsPresent &&
663cdf0e10cSrcweir                       (option.Value.IsAmbiguous ||
664cdf0e10cSrcweir                        (doRegisterPackage ? !option.Value.Value
665cdf0e10cSrcweir                                         : option.Value.Value)));
666cdf0e10cSrcweir             if (action) {
667cdf0e10cSrcweir 
668cdf0e10cSrcweir                 OUString displayName = isRemoved() ? getName() : getDisplayName();
669cdf0e10cSrcweir                 ProgressLevel progress(
670cdf0e10cSrcweir                     xCmdEnv,
671cdf0e10cSrcweir                     (doRegisterPackage
672cdf0e10cSrcweir                      ? PackageRegistryBackend::StrRegisteringPackage::get()
673cdf0e10cSrcweir                      : PackageRegistryBackend::StrRevokingPackage::get())
674cdf0e10cSrcweir                     + displayName );
675cdf0e10cSrcweir                 processPackage_( guard,
676cdf0e10cSrcweir                                  doRegisterPackage,
677cdf0e10cSrcweir                                  startup,
678cdf0e10cSrcweir                                  AbortChannel::get(xAbortChannel),
679cdf0e10cSrcweir                                  xCmdEnv );
680cdf0e10cSrcweir             }
681cdf0e10cSrcweir         }
682cdf0e10cSrcweir         catch (RuntimeException &) {
683cdf0e10cSrcweir             OSL_ENSURE( 0, "### unexpected RuntimeException!" );
684cdf0e10cSrcweir             throw;
685cdf0e10cSrcweir         }
686cdf0e10cSrcweir         catch (CommandFailedException &) {
687cdf0e10cSrcweir             throw;
688cdf0e10cSrcweir         }
689cdf0e10cSrcweir         catch (CommandAbortedException &) {
690cdf0e10cSrcweir             throw;
691cdf0e10cSrcweir         }
692cdf0e10cSrcweir         catch (deployment::DeploymentException &) {
693cdf0e10cSrcweir             throw;
694cdf0e10cSrcweir         }
695cdf0e10cSrcweir         catch (Exception &) {
696cdf0e10cSrcweir             Any exc( ::cppu::getCaughtException() );
697cdf0e10cSrcweir             throw deployment::DeploymentException(
698cdf0e10cSrcweir                 (doRegisterPackage
699cdf0e10cSrcweir                  ? getResourceString(RID_STR_ERROR_WHILE_REGISTERING)
700cdf0e10cSrcweir                  : getResourceString(RID_STR_ERROR_WHILE_REVOKING))
701cdf0e10cSrcweir                 + getDisplayName(), static_cast<OWeakObject *>(this), exc );
702cdf0e10cSrcweir         }
703cdf0e10cSrcweir     }
704cdf0e10cSrcweir     catch (...) {
705cdf0e10cSrcweir         if (action)
706cdf0e10cSrcweir             fireModified();
707cdf0e10cSrcweir         throw;
708cdf0e10cSrcweir     }
709cdf0e10cSrcweir     if (action)
710cdf0e10cSrcweir         fireModified();
711cdf0e10cSrcweir }
712cdf0e10cSrcweir 
713cdf0e10cSrcweir //______________________________________________________________________________
registerPackage(sal_Bool startup,Reference<task::XAbortChannel> const & xAbortChannel,Reference<XCommandEnvironment> const & xCmdEnv)714cdf0e10cSrcweir void Package::registerPackage(
715cdf0e10cSrcweir     sal_Bool startup,
716cdf0e10cSrcweir     Reference<task::XAbortChannel> const & xAbortChannel,
717cdf0e10cSrcweir     Reference<XCommandEnvironment> const & xCmdEnv )
718cdf0e10cSrcweir     throw (deployment::DeploymentException,
719cdf0e10cSrcweir            deployment::ExtensionRemovedException,
720cdf0e10cSrcweir            CommandFailedException, CommandAbortedException,
721cdf0e10cSrcweir            lang::IllegalArgumentException, RuntimeException)
722cdf0e10cSrcweir {
723cdf0e10cSrcweir     if (m_bRemoved)
724cdf0e10cSrcweir         throw deployment::ExtensionRemovedException();
725cdf0e10cSrcweir     processPackage_impl( true /* register */, startup, xAbortChannel, xCmdEnv );
726cdf0e10cSrcweir }
727cdf0e10cSrcweir 
728cdf0e10cSrcweir //______________________________________________________________________________
revokePackage(Reference<task::XAbortChannel> const & xAbortChannel,Reference<XCommandEnvironment> const & xCmdEnv)729cdf0e10cSrcweir void Package::revokePackage(
730cdf0e10cSrcweir     Reference<task::XAbortChannel> const & xAbortChannel,
731cdf0e10cSrcweir     Reference<XCommandEnvironment> const & xCmdEnv )
732cdf0e10cSrcweir     throw (deployment::DeploymentException,
733cdf0e10cSrcweir            CommandFailedException, CommandAbortedException,
734cdf0e10cSrcweir            lang::IllegalArgumentException, RuntimeException)
735cdf0e10cSrcweir {
736cdf0e10cSrcweir     processPackage_impl( false /* revoke */, false, xAbortChannel, xCmdEnv );
737cdf0e10cSrcweir 
738cdf0e10cSrcweir }
739cdf0e10cSrcweir 
getMyBackend() const740cdf0e10cSrcweir PackageRegistryBackend * Package::getMyBackend() const
741cdf0e10cSrcweir {
742cdf0e10cSrcweir     PackageRegistryBackend * pBackend = m_myBackend.get();
743cdf0e10cSrcweir     if (NULL == pBackend)
744cdf0e10cSrcweir     {
745cdf0e10cSrcweir         //May throw a DisposedException
746cdf0e10cSrcweir         check();
747cdf0e10cSrcweir         //We should never get here...
748cdf0e10cSrcweir         throw RuntimeException(
749cdf0e10cSrcweir             OUSTR("Failed to get the BackendImpl"),
750cdf0e10cSrcweir             static_cast<OWeakObject*>(const_cast<Package *>(this)));
751cdf0e10cSrcweir     }
752cdf0e10cSrcweir     return pBackend;
753cdf0e10cSrcweir }
getRepositoryName()754cdf0e10cSrcweir OUString Package::getRepositoryName()
755cdf0e10cSrcweir     throw (RuntimeException)
756cdf0e10cSrcweir {
757cdf0e10cSrcweir     PackageRegistryBackend * backEnd = getMyBackend();
758cdf0e10cSrcweir     return backEnd->getContext();
759cdf0e10cSrcweir }
760cdf0e10cSrcweir 
getRegistrationDataURL()761cdf0e10cSrcweir beans::Optional< OUString > Package::getRegistrationDataURL()
762cdf0e10cSrcweir         throw (deployment::ExtensionRemovedException,
763cdf0e10cSrcweir                css::uno::RuntimeException)
764cdf0e10cSrcweir {
765cdf0e10cSrcweir     if (m_bRemoved)
766cdf0e10cSrcweir         throw deployment::ExtensionRemovedException();
767cdf0e10cSrcweir     return beans::Optional<OUString>();
768cdf0e10cSrcweir }
769cdf0e10cSrcweir 
isRemoved()770cdf0e10cSrcweir sal_Bool Package::isRemoved()
771cdf0e10cSrcweir     throw (RuntimeException)
772cdf0e10cSrcweir {
773cdf0e10cSrcweir     return m_bRemoved;
774cdf0e10cSrcweir }
775cdf0e10cSrcweir 
776cdf0e10cSrcweir //##############################################################################
777cdf0e10cSrcweir 
778cdf0e10cSrcweir //______________________________________________________________________________
~TypeInfo()779cdf0e10cSrcweir Package::TypeInfo::~TypeInfo()
780cdf0e10cSrcweir {
781cdf0e10cSrcweir }
782cdf0e10cSrcweir 
783cdf0e10cSrcweir // XPackageTypeInfo
784cdf0e10cSrcweir //______________________________________________________________________________
getMediaType()785cdf0e10cSrcweir OUString Package::TypeInfo::getMediaType() throw (RuntimeException)
786cdf0e10cSrcweir {
787cdf0e10cSrcweir     return m_mediaType;
788cdf0e10cSrcweir }
789cdf0e10cSrcweir 
790cdf0e10cSrcweir //______________________________________________________________________________
getDescription()791cdf0e10cSrcweir OUString Package::TypeInfo::getDescription()
792cdf0e10cSrcweir     throw (deployment::ExtensionRemovedException, RuntimeException)
793cdf0e10cSrcweir {
794cdf0e10cSrcweir     return getShortDescription();
795cdf0e10cSrcweir }
796cdf0e10cSrcweir 
797cdf0e10cSrcweir //______________________________________________________________________________
getShortDescription()798cdf0e10cSrcweir OUString Package::TypeInfo::getShortDescription()
799cdf0e10cSrcweir     throw (deployment::ExtensionRemovedException, RuntimeException)
800cdf0e10cSrcweir {
801cdf0e10cSrcweir     return m_shortDescr;
802cdf0e10cSrcweir }
803cdf0e10cSrcweir 
804cdf0e10cSrcweir //______________________________________________________________________________
getFileFilter()805cdf0e10cSrcweir OUString Package::TypeInfo::getFileFilter() throw (RuntimeException)
806cdf0e10cSrcweir {
807cdf0e10cSrcweir     return m_fileFilter;
808cdf0e10cSrcweir }
809cdf0e10cSrcweir 
810cdf0e10cSrcweir //______________________________________________________________________________
getIcon(sal_Bool highContrast,sal_Bool smallIcon)811cdf0e10cSrcweir Any Package::TypeInfo::getIcon( sal_Bool highContrast, sal_Bool smallIcon )
812cdf0e10cSrcweir     throw (RuntimeException)
813cdf0e10cSrcweir {
814cdf0e10cSrcweir     if (! smallIcon)
815cdf0e10cSrcweir         return Any();
816cdf0e10cSrcweir     const sal_uInt16 nIconId = (highContrast ? m_smallIcon_HC : m_smallIcon);
817cdf0e10cSrcweir     return Any( &nIconId, getCppuType( static_cast<sal_uInt16 const *>(0) ) );
818cdf0e10cSrcweir }
819cdf0e10cSrcweir 
820cdf0e10cSrcweir }
821cdf0e10cSrcweir }
822cdf0e10cSrcweir 
823