12722ceddSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
32722ceddSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
42722ceddSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
52722ceddSAndrew Rist  * distributed with this work for additional information
62722ceddSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
72722ceddSAndrew Rist  * to you under the Apache License, Version 2.0 (the
82722ceddSAndrew Rist  * "License"); you may not use this file except in compliance
92722ceddSAndrew Rist  * with the License.  You may obtain a copy of the License at
102722ceddSAndrew Rist  *
112722ceddSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
122722ceddSAndrew Rist  *
132722ceddSAndrew Rist  * Unless required by applicable law or agreed to in writing,
142722ceddSAndrew Rist  * software distributed under the License is distributed on an
152722ceddSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162722ceddSAndrew Rist  * KIND, either express or implied.  See the License for the
172722ceddSAndrew Rist  * specific language governing permissions and limitations
182722ceddSAndrew Rist  * under the License.
192722ceddSAndrew Rist  *
202722ceddSAndrew Rist  *************************************************************/
212722ceddSAndrew Rist 
222722ceddSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_desktop.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "comphelper/servicedecl.hxx"
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include "com/sun/star/deployment/UpdateInformationProvider.hpp"
32cdf0e10cSrcweir #include "com/sun/star/deployment/XPackage.hpp"
33cdf0e10cSrcweir #include "com/sun/star/deployment/XPackageInformationProvider.hpp"
34cdf0e10cSrcweir #include "com/sun/star/deployment/ExtensionManager.hpp"
35cdf0e10cSrcweir #include "com/sun/star/deployment/XUpdateInformationProvider.hpp"
36cdf0e10cSrcweir #include "com/sun/star/lang/XServiceInfo.hpp"
37cdf0e10cSrcweir #include "com/sun/star/registry/XRegistryKey.hpp"
38cdf0e10cSrcweir #include "com/sun/star/task/XAbortChannel.hpp"
39cdf0e10cSrcweir #include "com/sun/star/uno/XComponentContext.hpp"
40cdf0e10cSrcweir #include "com/sun/star/ucb/XCommandEnvironment.hpp"
41cdf0e10cSrcweir #include "com/sun/star/xml/dom/XElement.hpp"
42cdf0e10cSrcweir #include "com/sun/star/xml/dom/XNode.hpp"
43cdf0e10cSrcweir 
44cdf0e10cSrcweir #include "com/sun/star/uno/Reference.hxx"
45cdf0e10cSrcweir #include "rtl/ustring.hxx"
46cdf0e10cSrcweir #include "ucbhelper/content.hxx"
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #include "dp_dependencies.hxx"
49cdf0e10cSrcweir #include "dp_descriptioninfoset.hxx"
50cdf0e10cSrcweir #include "dp_identifier.hxx"
51cdf0e10cSrcweir #include "dp_version.hxx"
52cdf0e10cSrcweir #include "dp_misc.h"
53cdf0e10cSrcweir #include "dp_update.hxx"
54cdf0e10cSrcweir 
55cdf0e10cSrcweir namespace beans      = com::sun::star::beans ;
56cdf0e10cSrcweir namespace deployment = com::sun::star::deployment ;
57cdf0e10cSrcweir namespace lang       = com::sun::star::lang ;
58cdf0e10cSrcweir namespace registry   = com::sun::star::registry ;
59cdf0e10cSrcweir namespace task       = com::sun::star::task ;
60cdf0e10cSrcweir namespace css_ucb    = com::sun::star::ucb ;
61cdf0e10cSrcweir namespace uno        = com::sun::star::uno ;
62cdf0e10cSrcweir namespace xml = com::sun::star::xml ;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir #define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
65cdf0e10cSrcweir 
66cdf0e10cSrcweir namespace dp_info {
67cdf0e10cSrcweir 
68cdf0e10cSrcweir class PackageInformationProvider :
69cdf0e10cSrcweir         public ::cppu::WeakImplHelper1< deployment::XPackageInformationProvider >
70cdf0e10cSrcweir 
71cdf0e10cSrcweir {
72cdf0e10cSrcweir     public:
73cdf0e10cSrcweir                  PackageInformationProvider( uno::Reference< uno::XComponentContext >const& xContext);
74cdf0e10cSrcweir     virtual     ~PackageInformationProvider();
75cdf0e10cSrcweir 
76cdf0e10cSrcweir     static uno::Sequence< rtl::OUString > getServiceNames();
77cdf0e10cSrcweir     static rtl::OUString getImplName();
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     // XPackageInformationProvider
80cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL getPackageLocation( const rtl::OUString& extensionId )
81cdf0e10cSrcweir         throw ( uno::RuntimeException );
82cdf0e10cSrcweir     virtual uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL isUpdateAvailable( const rtl::OUString& extensionId )
83cdf0e10cSrcweir         throw ( uno::RuntimeException );
84cdf0e10cSrcweir     virtual uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL getExtensionList()
85cdf0e10cSrcweir         throw ( uno::RuntimeException );
86cdf0e10cSrcweir //---------
87cdf0e10cSrcweir private:
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     uno::Reference< uno::XComponentContext> mxContext;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir     rtl::OUString getPackageLocation( const rtl::OUString& repository,
92cdf0e10cSrcweir                                       const rtl::OUString& _sExtensionId );
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     uno::Reference< deployment::XUpdateInformationProvider > mxUpdateInformation;
95cdf0e10cSrcweir };
96cdf0e10cSrcweir 
97cdf0e10cSrcweir //------------------------------------------------------------------------------
98cdf0e10cSrcweir 
PackageInformationProvider(uno::Reference<uno::XComponentContext> const & xContext)99cdf0e10cSrcweir PackageInformationProvider::PackageInformationProvider( uno::Reference< uno::XComponentContext > const& xContext) :
100cdf0e10cSrcweir     mxContext( xContext ),
101cdf0e10cSrcweir     mxUpdateInformation( deployment::UpdateInformationProvider::create( xContext ) )
102cdf0e10cSrcweir {
103cdf0e10cSrcweir }
104cdf0e10cSrcweir 
105cdf0e10cSrcweir //------------------------------------------------------------------------------
106cdf0e10cSrcweir 
~PackageInformationProvider()107cdf0e10cSrcweir PackageInformationProvider::~PackageInformationProvider()
108cdf0e10cSrcweir {
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir //------------------------------------------------------------------------------
getPackageLocation(const rtl::OUString & repository,const rtl::OUString & _rExtensionId)112cdf0e10cSrcweir rtl::OUString PackageInformationProvider::getPackageLocation(
113cdf0e10cSrcweir     const rtl::OUString & repository,
114cdf0e10cSrcweir     const rtl::OUString& _rExtensionId )
115cdf0e10cSrcweir {
116cdf0e10cSrcweir     rtl::OUString aLocationURL;
117cdf0e10cSrcweir     uno::Reference<deployment::XExtensionManager> xManager =
118cdf0e10cSrcweir         deployment::ExtensionManager::get(mxContext);
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     if ( xManager.is() )
121cdf0e10cSrcweir     {
122cdf0e10cSrcweir         const uno::Sequence< uno::Reference< deployment::XPackage > > packages(
123cdf0e10cSrcweir                 xManager->getDeployedExtensions(
124cdf0e10cSrcweir                     repository,
125cdf0e10cSrcweir                     uno::Reference< task::XAbortChannel >(),
126cdf0e10cSrcweir                     uno::Reference< css_ucb::XCommandEnvironment > () ) );
127cdf0e10cSrcweir 
128cdf0e10cSrcweir         for ( int pos = packages.getLength(); pos--; )
129cdf0e10cSrcweir         {
130cdf0e10cSrcweir             try
131cdf0e10cSrcweir             {
132cdf0e10cSrcweir                 const rtl::OUString aName = packages[ pos ]->getName();
133cdf0e10cSrcweir                 const beans::Optional< rtl::OUString > aID = packages[ pos ]->getIdentifier();
134cdf0e10cSrcweir                 if ( aID.IsPresent && aID.Value.compareTo( _rExtensionId ) == 0 )
135cdf0e10cSrcweir                 {
136cdf0e10cSrcweir                     aLocationURL = packages[ pos ]->getURL();
137cdf0e10cSrcweir                     break;
138cdf0e10cSrcweir                 }
139cdf0e10cSrcweir             }
140cdf0e10cSrcweir             catch ( uno::RuntimeException & ) {}
141cdf0e10cSrcweir         }
142cdf0e10cSrcweir     }
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     return aLocationURL;
145cdf0e10cSrcweir }
146cdf0e10cSrcweir 
147cdf0e10cSrcweir //------------------------------------------------------------------------------
148cdf0e10cSrcweir //------------------------------------------------------------------------------
149cdf0e10cSrcweir //------------------------------------------------------------------------------
150cdf0e10cSrcweir 
151cdf0e10cSrcweir rtl::OUString SAL_CALL
getPackageLocation(const rtl::OUString & _sExtensionId)152cdf0e10cSrcweir PackageInformationProvider::getPackageLocation( const rtl::OUString& _sExtensionId )
153cdf0e10cSrcweir     throw ( uno::RuntimeException )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir     rtl::OUString aLocationURL = getPackageLocation( UNISTRING("user"), _sExtensionId );
156cdf0e10cSrcweir 
157cdf0e10cSrcweir     if ( aLocationURL.getLength() == 0 )
158cdf0e10cSrcweir     {
159cdf0e10cSrcweir         aLocationURL = getPackageLocation( UNISTRING("shared"), _sExtensionId );
160cdf0e10cSrcweir     }
161cdf0e10cSrcweir     if ( aLocationURL.getLength() == 0 )
162cdf0e10cSrcweir     {
163cdf0e10cSrcweir         aLocationURL = getPackageLocation( UNISTRING("bundled"), _sExtensionId );
164cdf0e10cSrcweir     }
165*c6dedb65SAndre Fischer     if ( aLocationURL.getLength() == 0 )
166*c6dedb65SAndre Fischer     {
167*c6dedb65SAndre Fischer         aLocationURL = getPackageLocation( UNISTRING("bundled_prereg"), _sExtensionId );
168*c6dedb65SAndre Fischer     }
169cdf0e10cSrcweir     if ( aLocationURL.getLength() )
170cdf0e10cSrcweir     {
171cdf0e10cSrcweir         ::ucbhelper::Content aContent( aLocationURL, NULL );
172cdf0e10cSrcweir         aLocationURL = aContent.getURL();
173cdf0e10cSrcweir     }
174cdf0e10cSrcweir     return aLocationURL;
175cdf0e10cSrcweir }
176cdf0e10cSrcweir 
177cdf0e10cSrcweir //------------------------------------------------------------------------------
178cdf0e10cSrcweir 
179cdf0e10cSrcweir uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL
isUpdateAvailable(const rtl::OUString & _sExtensionId)180cdf0e10cSrcweir PackageInformationProvider::isUpdateAvailable( const rtl::OUString& _sExtensionId )
181cdf0e10cSrcweir     throw ( uno::RuntimeException )
182cdf0e10cSrcweir {
183cdf0e10cSrcweir     uno::Sequence< uno::Sequence< rtl::OUString > > aList;
184cdf0e10cSrcweir 
185cdf0e10cSrcweir     uno::Reference<deployment::XExtensionManager> extMgr =
186cdf0e10cSrcweir         deployment::ExtensionManager::get(mxContext);
187cdf0e10cSrcweir 
188cdf0e10cSrcweir     if (!extMgr.is())
189cdf0e10cSrcweir     {
190cdf0e10cSrcweir         OSL_ASSERT(0);
191cdf0e10cSrcweir         return aList;
192cdf0e10cSrcweir     }
193cdf0e10cSrcweir     std::vector<std::pair<uno::Reference<deployment::XPackage>, uno::Any > > errors;
194cdf0e10cSrcweir     dp_misc::UpdateInfoMap updateInfoMap;
195cdf0e10cSrcweir     if (_sExtensionId.getLength())
196cdf0e10cSrcweir     {
197cdf0e10cSrcweir         std::vector<uno::Reference<deployment::XPackage> > vecExtensions;
198cdf0e10cSrcweir         uno::Reference<deployment::XPackage> extension;
199cdf0e10cSrcweir         try
200cdf0e10cSrcweir         {
201cdf0e10cSrcweir             extension = dp_misc::getExtensionWithHighestVersion(
202cdf0e10cSrcweir                 extMgr->getExtensionsWithSameIdentifier(
203cdf0e10cSrcweir                     _sExtensionId, _sExtensionId, uno::Reference<css_ucb::XCommandEnvironment>()));
204cdf0e10cSrcweir             vecExtensions.push_back(extension);
205cdf0e10cSrcweir         }
206cdf0e10cSrcweir         catch (lang::IllegalArgumentException &)
207cdf0e10cSrcweir         {
208cdf0e10cSrcweir             OSL_ASSERT(0);
209cdf0e10cSrcweir         }
210cdf0e10cSrcweir         updateInfoMap = dp_misc::getOnlineUpdateInfos(
211cdf0e10cSrcweir             mxContext, extMgr, mxUpdateInformation, &vecExtensions, errors);
212cdf0e10cSrcweir     }
213cdf0e10cSrcweir     else
214cdf0e10cSrcweir     {
215cdf0e10cSrcweir         updateInfoMap = dp_misc::getOnlineUpdateInfos(
216cdf0e10cSrcweir             mxContext, extMgr, mxUpdateInformation, NULL, errors);
217cdf0e10cSrcweir     }
218cdf0e10cSrcweir 
219cdf0e10cSrcweir     int nCount = 0;
220cdf0e10cSrcweir     for (dp_misc::UpdateInfoMap::iterator i(updateInfoMap.begin()); i != updateInfoMap.end(); i++)
221cdf0e10cSrcweir     {
222cdf0e10cSrcweir         dp_misc::UpdateInfo const & info = i->second;
223cdf0e10cSrcweir 
224cdf0e10cSrcweir         rtl::OUString sOnlineVersion;
225cdf0e10cSrcweir         if (info.info.is())
226cdf0e10cSrcweir         {
227cdf0e10cSrcweir             // check, if there are unsatisfied dependencies and ignore this online update
228cdf0e10cSrcweir             dp_misc::DescriptionInfoset infoset(mxContext, info.info);
229cdf0e10cSrcweir             uno::Sequence< uno::Reference< xml::dom::XElement > >
230cdf0e10cSrcweir                 ds( dp_misc::Dependencies::check( infoset ) );
231cdf0e10cSrcweir             if ( ! ds.getLength() )
232cdf0e10cSrcweir                 sOnlineVersion = info.version;
233cdf0e10cSrcweir         }
234cdf0e10cSrcweir 
235cdf0e10cSrcweir         rtl::OUString sVersionUser;
236cdf0e10cSrcweir         rtl::OUString sVersionShared;
237cdf0e10cSrcweir         rtl::OUString sVersionBundled;
238cdf0e10cSrcweir         uno::Sequence< uno::Reference< deployment::XPackage> > extensions;
239cdf0e10cSrcweir         try {
240cdf0e10cSrcweir             extensions = extMgr->getExtensionsWithSameIdentifier(
241cdf0e10cSrcweir                 dp_misc::getIdentifier(info.extension), info.extension->getName(),
242cdf0e10cSrcweir                 uno::Reference<css_ucb::XCommandEnvironment>());
243cdf0e10cSrcweir         } catch (lang::IllegalArgumentException& ) {
244cdf0e10cSrcweir             OSL_ASSERT(0);
245cdf0e10cSrcweir         }
246cdf0e10cSrcweir         OSL_ASSERT(extensions.getLength() == 3);
247cdf0e10cSrcweir         if (extensions[0].is() )
248cdf0e10cSrcweir             sVersionUser = extensions[0]->getVersion();
249cdf0e10cSrcweir         if (extensions[1].is() )
250cdf0e10cSrcweir             sVersionShared = extensions[1]->getVersion();
251cdf0e10cSrcweir         if (extensions[2].is() )
252cdf0e10cSrcweir             sVersionBundled = extensions[2]->getVersion();
253cdf0e10cSrcweir 
254cdf0e10cSrcweir         bool bSharedReadOnly = extMgr->isReadOnlyRepository(OUSTR("shared"));
255cdf0e10cSrcweir 
256cdf0e10cSrcweir         dp_misc::UPDATE_SOURCE sourceUser = dp_misc::isUpdateUserExtension(
257cdf0e10cSrcweir             bSharedReadOnly, sVersionUser, sVersionShared, sVersionBundled, sOnlineVersion);
258cdf0e10cSrcweir         dp_misc::UPDATE_SOURCE sourceShared = dp_misc::isUpdateSharedExtension(
259cdf0e10cSrcweir             bSharedReadOnly, sVersionShared, sVersionBundled, sOnlineVersion);
260cdf0e10cSrcweir 
261cdf0e10cSrcweir         rtl::OUString updateVersionUser;
262cdf0e10cSrcweir         rtl::OUString updateVersionShared;
263cdf0e10cSrcweir         if (sourceUser != dp_misc::UPDATE_SOURCE_NONE)
264cdf0e10cSrcweir             updateVersionUser = dp_misc::getHighestVersion(
265cdf0e10cSrcweir                 rtl::OUString(), sVersionShared, sVersionBundled, sOnlineVersion);
266cdf0e10cSrcweir         if (sourceShared  != dp_misc::UPDATE_SOURCE_NONE)
267cdf0e10cSrcweir             updateVersionShared = dp_misc::getHighestVersion(
268cdf0e10cSrcweir                 rtl::OUString(), rtl::OUString(), sVersionBundled, sOnlineVersion);
269cdf0e10cSrcweir         rtl::OUString updateVersion;
270cdf0e10cSrcweir         if (dp_misc::compareVersions(updateVersionUser, updateVersionShared) == dp_misc::GREATER)
271cdf0e10cSrcweir             updateVersion = updateVersionUser;
272cdf0e10cSrcweir         else
273cdf0e10cSrcweir             updateVersion = updateVersionShared;
274cdf0e10cSrcweir         if (updateVersion.getLength())
275cdf0e10cSrcweir         {
276cdf0e10cSrcweir 
277cdf0e10cSrcweir             rtl::OUString aNewEntry[2];
278cdf0e10cSrcweir             aNewEntry[0] = i->first;
279cdf0e10cSrcweir             aNewEntry[1] = updateVersion;
280cdf0e10cSrcweir             aList.realloc( ++nCount );
281cdf0e10cSrcweir             aList[ nCount-1 ] = ::uno::Sequence< rtl::OUString >( aNewEntry, 2 );
282cdf0e10cSrcweir         }
283cdf0e10cSrcweir     }
284cdf0e10cSrcweir     return aList;
285cdf0e10cSrcweir }
286cdf0e10cSrcweir 
287cdf0e10cSrcweir //------------------------------------------------------------------------------
getExtensionList()288cdf0e10cSrcweir uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL PackageInformationProvider::getExtensionList()
289cdf0e10cSrcweir     throw ( uno::RuntimeException )
290cdf0e10cSrcweir {
291cdf0e10cSrcweir     const uno::Reference<deployment::XExtensionManager> mgr =
292cdf0e10cSrcweir         deployment::ExtensionManager::get(mxContext);
293cdf0e10cSrcweir 
294cdf0e10cSrcweir     if (!mgr.is())
295cdf0e10cSrcweir         return uno::Sequence< uno::Sequence< rtl::OUString > >();
296cdf0e10cSrcweir 
297cdf0e10cSrcweir     const uno::Sequence< uno::Sequence< uno::Reference<deployment::XPackage > > >
298cdf0e10cSrcweir         allExt =  mgr->getAllExtensions(
299cdf0e10cSrcweir             uno::Reference< task::XAbortChannel >(),
300cdf0e10cSrcweir             uno::Reference< css_ucb::XCommandEnvironment > () );
301cdf0e10cSrcweir 
302cdf0e10cSrcweir     uno::Sequence< uno::Sequence< rtl::OUString > > retList;
303cdf0e10cSrcweir 
304cdf0e10cSrcweir     sal_Int32 cAllIds = allExt.getLength();
305cdf0e10cSrcweir     retList.realloc(cAllIds);
306cdf0e10cSrcweir 
307cdf0e10cSrcweir     for (sal_Int32 i = 0; i < cAllIds; i++)
308cdf0e10cSrcweir     {
309cdf0e10cSrcweir         //The inner sequence contains extensions with the same identifier from
310cdf0e10cSrcweir         //all the different repositories, that is user, share, bundled.
311cdf0e10cSrcweir         const uno::Sequence< uno::Reference< deployment::XPackage > > &
312cdf0e10cSrcweir             seqExtension = allExt[i];
313cdf0e10cSrcweir         sal_Int32 cExt = seqExtension.getLength();
314cdf0e10cSrcweir         OSL_ASSERT(cExt == 3);
315cdf0e10cSrcweir         for (sal_Int32 j = 0; j < cExt; j++)
316cdf0e10cSrcweir         {
317cdf0e10cSrcweir             //ToDo according to the old code the first found extenions is used
318cdf0e10cSrcweir             //even if another one with the same id has a better version.
319cdf0e10cSrcweir             uno::Reference< deployment::XPackage > const & xExtension( seqExtension[j] );
320cdf0e10cSrcweir             if (xExtension.is())
321cdf0e10cSrcweir             {
322cdf0e10cSrcweir                 rtl::OUString aNewEntry[2];
323cdf0e10cSrcweir                 aNewEntry[0] = dp_misc::getIdentifier(xExtension);
324cdf0e10cSrcweir                 aNewEntry[1] = xExtension->getVersion();
325cdf0e10cSrcweir                 retList[i] = ::uno::Sequence< rtl::OUString >( aNewEntry, 2 );
326cdf0e10cSrcweir                 break;
327cdf0e10cSrcweir             }
328cdf0e10cSrcweir         }
329cdf0e10cSrcweir     }
330cdf0e10cSrcweir     return retList;
331cdf0e10cSrcweir }
332cdf0e10cSrcweir 
333cdf0e10cSrcweir 
334cdf0e10cSrcweir //------------------------------------------------------------------------------
335cdf0e10cSrcweir //------------------------------------------------------------------------------
336cdf0e10cSrcweir //------------------------------------------------------------------------------
337cdf0e10cSrcweir 
338cdf0e10cSrcweir namespace sdecl = comphelper::service_decl;
339cdf0e10cSrcweir sdecl::class_<PackageInformationProvider> servicePIP;
340cdf0e10cSrcweir extern sdecl::ServiceDecl const serviceDecl(
341cdf0e10cSrcweir     servicePIP,
342cdf0e10cSrcweir     // a private one:
343cdf0e10cSrcweir     "com.sun.star.comp.deployment.PackageInformationProvider",
344cdf0e10cSrcweir     "com.sun.star.comp.deployment.PackageInformationProvider" );
345cdf0e10cSrcweir 
346cdf0e10cSrcweir //------------------------------------------------------------------------------
singleton_entries(uno::Reference<registry::XRegistryKey> const & xRegistryKey)347cdf0e10cSrcweir bool singleton_entries(
348cdf0e10cSrcweir     uno::Reference< registry::XRegistryKey > const & xRegistryKey )
349cdf0e10cSrcweir {
350cdf0e10cSrcweir     try {
351cdf0e10cSrcweir         uno::Reference< registry::XRegistryKey > xKey(
352cdf0e10cSrcweir             xRegistryKey->createKey(
353cdf0e10cSrcweir                 serviceDecl.getImplementationName() +
354cdf0e10cSrcweir                 // xxx todo: use future generated function to get singleton name
355cdf0e10cSrcweir                 UNISTRING("/UNO/SINGLETONS/"
356cdf0e10cSrcweir                       "com.sun.star.deployment.PackageInformationProvider") ) );
357cdf0e10cSrcweir         xKey->setStringValue( serviceDecl.getSupportedServiceNames()[0] );
358cdf0e10cSrcweir         return true;
359cdf0e10cSrcweir     }
360cdf0e10cSrcweir     catch (registry::InvalidRegistryException & exc) {
361cdf0e10cSrcweir         (void) exc; // avoid warnings
362cdf0e10cSrcweir         OSL_ENSURE( 0, ::rtl::OUStringToOString(
363cdf0e10cSrcweir                         exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
364cdf0e10cSrcweir         return false;
365cdf0e10cSrcweir     }
366cdf0e10cSrcweir }
367cdf0e10cSrcweir 
368cdf0e10cSrcweir } // namespace dp_info
369cdf0e10cSrcweir 
370cdf0e10cSrcweir 
371