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