1 /*************************************************************************
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * Copyright 2000, 2010 Oracle and/or its affiliates.
5 *
6 * OpenOffice.org - a multi-platform office productivity suite
7 *
8 * This file is part of OpenOffice.org.
9 *
10 * OpenOffice.org is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License version 3
12 * only, as published by the Free Software Foundation.
13 *
14 * OpenOffice.org is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU Lesser General Public License version 3 for more details
18 * (a copy is included in the LICENSE file that accompanied this code).
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * version 3 along with OpenOffice.org.  If not, see
22 * <http://www.openoffice.org/license.html>
23 * for a copy of the LGPLv3 License.
24 ************************************************************************/
25 
26 #include "precompiled_configmgr.hxx"
27 #include "sal/config.h"
28 
29 #include "boost/noncopyable.hpp"
30 #include "com/sun/star/beans/NamedValue.hpp"
31 #include "com/sun/star/beans/Property.hpp"
32 #include "com/sun/star/beans/XProperty.hpp"
33 #include "com/sun/star/container/NoSuchElementException.hpp"
34 #include "com/sun/star/container/XHierarchicalNameAccess.hpp"
35 #include "com/sun/star/container/XNamed.hpp"
36 #include "com/sun/star/lang/XMultiComponentFactory.hpp"
37 #include "com/sun/star/lang/XMultiServiceFactory.hpp"
38 #include "com/sun/star/lang/XServiceInfo.hpp"
39 #include "com/sun/star/registry/InvalidRegistryException.hpp"
40 #include "com/sun/star/registry/InvalidValueException.hpp"
41 #include "com/sun/star/registry/MergeConflictException.hpp"
42 #include "com/sun/star/registry/RegistryKeyType.hpp"
43 #include "com/sun/star/registry/RegistryValueType.hpp"
44 #include "com/sun/star/registry/XRegistryKey.hpp"
45 #include "com/sun/star/registry/XSimpleRegistry.hpp"
46 #include "com/sun/star/uno/Any.hxx"
47 #include "com/sun/star/uno/DeploymentException.hpp"
48 #include "com/sun/star/uno/Exception.hpp"
49 #include "com/sun/star/uno/Reference.hxx"
50 #include "com/sun/star/uno/RuntimeException.hpp"
51 #include "com/sun/star/uno/Sequence.hxx"
52 #include "com/sun/star/uno/Type.hxx"
53 #include "com/sun/star/uno/TypeClass.hpp"
54 #include "com/sun/star/uno/XComponentContext.hpp"
55 #include "com/sun/star/uno/XInterface.hpp"
56 #include "com/sun/star/util/XFlushable.hpp"
57 #include "cppu/unotype.hxx"
58 #include "cppuhelper/implbase1.hxx"
59 #include "cppuhelper/implbase3.hxx"
60 #include "cppuhelper/weak.hxx"
61 #include "osl/diagnose.h"
62 #include "osl/mutex.hxx"
63 #include "rtl/ustring.h"
64 #include "rtl/ustring.hxx"
65 #include "sal/types.h"
66 
67 #include "configurationregistry.hxx"
68 
69 namespace com { namespace sun { namespace star { namespace util {
70     class XFlushListener;
71 } } } }
72 
73 namespace configmgr { namespace configuration_registry {
74 
75 namespace {
76 
77 namespace css = com::sun::star;
78 
79 class Service:
80     public cppu::WeakImplHelper3<
81         css::lang::XServiceInfo, css::registry::XSimpleRegistry,
82         css::util::XFlushable >,
83     private boost::noncopyable
84 {
85 public:
86     Service(css::uno::Reference< css::uno::XComponentContext > const & context);
87 
88 private:
89     virtual ~Service() {}
90 
91     virtual rtl::OUString SAL_CALL getImplementationName()
92         throw (css::uno::RuntimeException)
93     { return configuration_registry::getImplementationName(); }
94 
95     virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName)
96         throw (css::uno::RuntimeException)
97     { return ServiceName == getSupportedServiceNames()[0]; } //TODO
98 
99     virtual css::uno::Sequence< rtl::OUString > SAL_CALL
100     getSupportedServiceNames() throw (css::uno::RuntimeException)
101     { return configuration_registry::getSupportedServiceNames(); }
102 
103     virtual rtl::OUString SAL_CALL getURL() throw (css::uno::RuntimeException);
104 
105     virtual void SAL_CALL open(
106         rtl::OUString const & rURL, sal_Bool bReadOnly, sal_Bool)
107         throw (
108             css::registry::InvalidRegistryException,
109             css::uno::RuntimeException);
110 
111     virtual sal_Bool SAL_CALL isValid() throw (css::uno::RuntimeException);
112 
113     virtual void SAL_CALL close()
114         throw (
115             css::registry::InvalidRegistryException,
116             css::uno::RuntimeException);
117 
118     virtual void SAL_CALL destroy()
119         throw (
120             css::registry::InvalidRegistryException,
121             css::uno::RuntimeException);
122 
123     virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL
124     getRootKey()
125         throw (
126             css::registry::InvalidRegistryException,
127             css::uno::RuntimeException);
128 
129     virtual sal_Bool SAL_CALL isReadOnly() throw (css::uno::RuntimeException);
130 
131     virtual void SAL_CALL mergeKey(rtl::OUString const &, rtl::OUString const &)
132         throw (
133             css::registry::InvalidRegistryException,
134             css::registry::MergeConflictException, css::uno::RuntimeException);
135 
136     virtual void SAL_CALL flush() throw (css::uno::RuntimeException);
137 
138     virtual void SAL_CALL addFlushListener(
139         css::uno::Reference< css::util::XFlushListener > const &)
140         throw (css::uno::RuntimeException);
141 
142     virtual void SAL_CALL removeFlushListener(
143         css::uno::Reference< css::util::XFlushListener > const &)
144         throw (css::uno::RuntimeException);
145 
146     void checkValid();
147 
148     void checkValid_RuntimeException();
149 
150     void doClose();
151 
152     css::uno::Reference< css::lang::XMultiServiceFactory > provider_;
153     osl::Mutex mutex_;
154     css::uno::Reference< css::uno::XInterface > access_;
155     rtl::OUString url_;
156     bool readOnly_;
157 
158     friend class RegistryKey;
159 };
160 
161 class RegistryKey:
162     public cppu::WeakImplHelper1< css::registry::XRegistryKey >,
163     private boost::noncopyable
164 {
165 public:
166     RegistryKey(Service & service, css::uno::Any const & value):
167         service_(service), value_(value) {}
168 
169 private:
170     virtual ~RegistryKey() {}
171 
172     virtual rtl::OUString SAL_CALL getKeyName()
173         throw (css::uno::RuntimeException);
174 
175     virtual sal_Bool SAL_CALL isReadOnly()
176         throw (
177             css::registry::InvalidRegistryException,
178             css::uno::RuntimeException);
179 
180     virtual sal_Bool SAL_CALL isValid() throw (css::uno::RuntimeException);
181 
182     virtual css::registry::RegistryKeyType SAL_CALL getKeyType(
183         rtl::OUString const &)
184         throw (
185             css::registry::InvalidRegistryException,
186             css::uno::RuntimeException);
187 
188     virtual css::registry::RegistryValueType SAL_CALL getValueType()
189         throw (
190             css::registry::InvalidRegistryException,
191             css::uno::RuntimeException);
192 
193     virtual sal_Int32 SAL_CALL getLongValue()
194         throw (
195             css::registry::InvalidRegistryException,
196             css::registry::InvalidValueException, css::uno::RuntimeException);
197 
198     virtual void SAL_CALL setLongValue(sal_Int32)
199         throw (
200             css::registry::InvalidRegistryException,
201             css::uno::RuntimeException);
202 
203     virtual css::uno::Sequence< sal_Int32 > SAL_CALL getLongListValue()
204         throw (
205             css::registry::InvalidRegistryException,
206             css::registry::InvalidValueException, css::uno::RuntimeException);
207 
208     virtual void SAL_CALL setLongListValue(
209         css::uno::Sequence< sal_Int32 > const &)
210         throw (
211             css::registry::InvalidRegistryException,
212             css::uno::RuntimeException);
213 
214     virtual rtl::OUString SAL_CALL getAsciiValue()
215         throw (
216             css::registry::InvalidRegistryException,
217             css::registry::InvalidValueException, css::uno::RuntimeException);
218 
219     virtual void SAL_CALL setAsciiValue(rtl::OUString const &)
220         throw (
221             css::registry::InvalidRegistryException,
222             css::uno::RuntimeException);
223 
224     virtual css::uno::Sequence< rtl::OUString > SAL_CALL getAsciiListValue()
225         throw (
226             css::registry::InvalidRegistryException,
227             css::registry::InvalidValueException, css::uno::RuntimeException);
228 
229     virtual void SAL_CALL setAsciiListValue(
230         css::uno::Sequence< rtl::OUString > const &)
231         throw (
232             css::registry::InvalidRegistryException,
233             css::uno::RuntimeException);
234 
235     virtual rtl::OUString SAL_CALL getStringValue()
236         throw (
237             css::registry::InvalidRegistryException,
238             css::registry::InvalidValueException, css::uno::RuntimeException);
239 
240     virtual void SAL_CALL setStringValue(rtl::OUString const &)
241         throw (
242             css::registry::InvalidRegistryException,
243             css::uno::RuntimeException);
244 
245     virtual css::uno::Sequence< rtl::OUString > SAL_CALL getStringListValue()
246         throw (
247             css::registry::InvalidRegistryException,
248             css::registry::InvalidValueException, css::uno::RuntimeException);
249 
250     virtual void SAL_CALL setStringListValue(
251         css::uno::Sequence< rtl::OUString > const &)
252         throw (
253             css::registry::InvalidRegistryException,
254             css::uno::RuntimeException);
255 
256     virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBinaryValue()
257         throw (
258             css::registry::InvalidRegistryException,
259             css::registry::InvalidValueException, css::uno::RuntimeException);
260 
261     virtual void SAL_CALL setBinaryValue(css::uno::Sequence< sal_Int8 > const &)
262         throw (
263             css::registry::InvalidRegistryException,
264             css::uno::RuntimeException);
265 
266     virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL openKey(
267         rtl::OUString const & aKeyName)
268         throw (
269             css::registry::InvalidRegistryException,
270             css::uno::RuntimeException);
271 
272     virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL
273     createKey(rtl::OUString const &)
274         throw (
275             css::registry::InvalidRegistryException,
276             css::uno::RuntimeException);
277 
278     virtual void SAL_CALL closeKey()
279         throw (
280             css::registry::InvalidRegistryException,
281             css::uno::RuntimeException);
282 
283     virtual void SAL_CALL deleteKey(rtl::OUString const &)
284         throw (
285             css::registry::InvalidRegistryException,
286             css::uno::RuntimeException);
287 
288     virtual
289     css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > >
290     SAL_CALL openKeys()
291         throw (
292             css::registry::InvalidRegistryException,
293             css::uno::RuntimeException);
294 
295     virtual css::uno::Sequence< rtl::OUString > SAL_CALL getKeyNames()
296         throw (
297             css::registry::InvalidRegistryException,
298             css::uno::RuntimeException);
299 
300     virtual sal_Bool SAL_CALL createLink(
301         rtl::OUString const &, rtl::OUString const &)
302         throw (
303             css::registry::InvalidRegistryException,
304             css::uno::RuntimeException);
305 
306     virtual void SAL_CALL deleteLink(rtl::OUString const &)
307         throw (
308             css::registry::InvalidRegistryException,
309             css::uno::RuntimeException);
310 
311     virtual rtl::OUString SAL_CALL getLinkTarget(rtl::OUString const &)
312         throw (
313             css::registry::InvalidRegistryException,
314             css::uno::RuntimeException);
315 
316     virtual rtl::OUString SAL_CALL getResolvedName(
317         rtl::OUString const & aKeyName)
318         throw (
319             css::registry::InvalidRegistryException,
320             css::uno::RuntimeException);
321 
322     Service & service_;
323     css::uno::Any value_;
324 };
325 
326 Service::Service(
327     css::uno::Reference< css::uno::XComponentContext > const & context)
328 {
329     OSL_ASSERT(context.is());
330     try {
331         provider_ = css::uno::Reference< css::lang::XMultiServiceFactory >(
332             (css::uno::Reference< css::lang::XMultiComponentFactory >(
333                 context->getServiceManager(), css::uno::UNO_SET_THROW)->
334              createInstanceWithContext(
335                  rtl::OUString(
336                      RTL_CONSTASCII_USTRINGPARAM(
337                          "com.sun.star.configuration.DefaultProvider")),
338                  context)),
339             css::uno::UNO_QUERY_THROW);
340     } catch (css::uno::RuntimeException &) {
341         throw;
342     } catch (css::uno::Exception & e) {
343         throw css::uno::DeploymentException(
344             (rtl::OUString(
345                 RTL_CONSTASCII_USTRINGPARAM(
346                     "component context fails to supply service"
347                     " com.sun.star.configuration.DefaultProvider of type"
348                     " com.sun.star.lang.XMultiServiceFactory: ")) +
349              e.Message),
350             context);
351     }
352 }
353 
354 rtl::OUString Service::getURL() throw (css::uno::RuntimeException) {
355     osl::MutexGuard g(mutex_);
356     checkValid_RuntimeException();
357     return url_;
358 }
359 
360 void Service::open(rtl::OUString const & rURL, sal_Bool bReadOnly, sal_Bool)
361     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
362 {
363     //TODO: bCreate
364     osl::MutexGuard g(mutex_);
365     if (access_.is()) {
366         doClose();
367     }
368     css::uno::Sequence< css::uno::Any > args(1);
369     args[0] <<= css::beans::NamedValue(
370         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")),
371         css::uno::makeAny(rURL));
372     try {
373         access_ = provider_->createInstanceWithArguments(
374             (bReadOnly
375              ? rtl::OUString(
376                  RTL_CONSTASCII_USTRINGPARAM(
377                      "com.sun.star.configuration.ConfigurationAccess"))
378              : rtl::OUString(
379                  RTL_CONSTASCII_USTRINGPARAM(
380                      "com.sun.star.configuration.ConfigurationUpdateAccess"))),
381             args);
382     } catch (css::uno::RuntimeException &) {
383         throw;
384     } catch (css::uno::Exception & e) {
385         throw css::uno::RuntimeException(
386             (rtl::OUString(
387                 RTL_CONSTASCII_USTRINGPARAM(
388                     "com.sun.star.configuration.ConfigurationRegistry: open"
389                     " failed: ")) +
390              e.Message),
391             static_cast< cppu::OWeakObject * >(this));
392     }
393     url_ = rURL;
394     readOnly_ = bReadOnly;
395 }
396 
397 sal_Bool Service::isValid() throw (css::uno::RuntimeException) {
398     osl::MutexGuard g(mutex_);
399     return access_.is();
400 }
401 
402 void Service::close()
403     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
404 {
405     osl::MutexGuard g(mutex_);
406     checkValid();
407     doClose();
408 }
409 
410 void Service::destroy()
411     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
412 {
413     throw css::uno::RuntimeException(
414         rtl::OUString(
415             RTL_CONSTASCII_USTRINGPARAM(
416                 "com.sun.star.configuration.ConfigurationRegistry: not"
417                 " implemented")),
418         static_cast< cppu::OWeakObject * >(this));
419 }
420 
421 css::uno::Reference< css::registry::XRegistryKey > Service::getRootKey()
422     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
423 {
424     osl::MutexGuard g(mutex_);
425     checkValid();
426     return new RegistryKey(*this, css::uno::makeAny(access_));
427 }
428 
429 sal_Bool Service::isReadOnly() throw (css::uno::RuntimeException) {
430     osl::MutexGuard g(mutex_);
431     checkValid_RuntimeException();
432     return readOnly_;
433 }
434 
435 void Service::mergeKey(rtl::OUString const &, rtl::OUString const &)
436     throw (
437         css::registry::InvalidRegistryException,
438         css::registry::MergeConflictException, css::uno::RuntimeException)
439 {
440     throw css::uno::RuntimeException(
441         rtl::OUString(
442             RTL_CONSTASCII_USTRINGPARAM(
443                 "com.sun.star.configuration.ConfigurationRegistry: not"
444                 " implemented")),
445         static_cast< cppu::OWeakObject * >(this));
446 }
447 
448 void Service::flush() throw (css::uno::RuntimeException)
449 {
450     throw css::uno::RuntimeException(
451         rtl::OUString(
452             RTL_CONSTASCII_USTRINGPARAM(
453                 "com.sun.star.configuration.ConfigurationRegistry: not"
454                 " implemented")),
455         static_cast< cppu::OWeakObject * >(this));
456 }
457 
458 void Service::addFlushListener(
459     css::uno::Reference< css::util::XFlushListener > const &)
460     throw (css::uno::RuntimeException)
461 {
462     throw css::uno::RuntimeException(
463         rtl::OUString(
464             RTL_CONSTASCII_USTRINGPARAM(
465                 "com.sun.star.configuration.ConfigurationRegistry: not"
466                 " implemented")),
467         static_cast< cppu::OWeakObject * >(this));
468 }
469 
470 void Service::removeFlushListener(
471     css::uno::Reference< css::util::XFlushListener > const &)
472     throw (css::uno::RuntimeException)
473 {
474     throw css::uno::RuntimeException(
475         rtl::OUString(
476             RTL_CONSTASCII_USTRINGPARAM(
477                 "com.sun.star.configuration.ConfigurationRegistry: not"
478                 " implemented")),
479         static_cast< cppu::OWeakObject * >(this));
480 }
481 
482 void Service::checkValid() {
483     if (!access_.is()) {
484         throw css::registry::InvalidRegistryException(
485             rtl::OUString(
486                 RTL_CONSTASCII_USTRINGPARAM(
487                     "com.sun.star.configuration.ConfigurationRegistry: not"
488                     " valid")),
489             static_cast< cppu::OWeakObject * >(this));
490     }
491 }
492 
493 void Service::checkValid_RuntimeException() {
494     if (!access_.is()) {
495         throw css::uno::RuntimeException(
496             rtl::OUString(
497                 RTL_CONSTASCII_USTRINGPARAM(
498                     "com.sun.star.configuration.ConfigurationRegistry: not"
499                     " valid")),
500             static_cast< cppu::OWeakObject * >(this));
501     }
502 }
503 
504 void Service::doClose() {
505     access_.clear();
506 }
507 
508 rtl::OUString RegistryKey::getKeyName() throw (css::uno::RuntimeException) {
509     osl::MutexGuard g(service_.mutex_);
510     service_.checkValid_RuntimeException();
511     css::uno::Reference< css::container::XNamed > named;
512     if (value_ >>= named) {
513         return named->getName();
514     }
515     throw css::uno::RuntimeException(
516         rtl::OUString(
517             RTL_CONSTASCII_USTRINGPARAM(
518                 "com.sun.star.configuration.ConfigurationRegistry: not"
519                 " implemented")),
520         static_cast< cppu::OWeakObject * >(this));
521 }
522 
523 sal_Bool RegistryKey::isReadOnly()
524     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
525 {
526     osl::MutexGuard g(service_.mutex_);
527     service_.checkValid_RuntimeException();
528     return service_.readOnly_; //TODO: read-only sub-nodes in update access?
529 }
530 
531 sal_Bool RegistryKey::isValid() throw (css::uno::RuntimeException) {
532     return service_.isValid();
533 }
534 
535 css::registry::RegistryKeyType RegistryKey::getKeyType(rtl::OUString const &)
536     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
537 {
538     osl::MutexGuard g(service_.mutex_);
539     service_.checkValid();
540     return css::registry::RegistryKeyType_KEY;
541 }
542 
543 css::registry::RegistryValueType RegistryKey::getValueType()
544     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
545 {
546     osl::MutexGuard g(service_.mutex_);
547     service_.checkValid();
548     css::uno::Type t(value_.getValueType());
549     switch (t.getTypeClass()) {
550     case css::uno::TypeClass_LONG:
551         return css::registry::RegistryValueType_LONG;
552     case css::uno::TypeClass_STRING:
553         return css::registry::RegistryValueType_STRING;
554     case css::uno::TypeClass_SEQUENCE:
555         if (t == cppu::UnoType< css::uno::Sequence< sal_Int8 > >::get()) {
556             return css::registry::RegistryValueType_BINARY;
557         } else if (t == cppu::UnoType< css::uno::Sequence< sal_Int32 > >::get())
558         {
559             return css::registry::RegistryValueType_LONGLIST;
560         } else if (t ==
561                    cppu::UnoType< css::uno::Sequence< rtl::OUString > >::get())
562         {
563             return css::registry::RegistryValueType_STRINGLIST;
564         }
565         // fall through
566     default:
567         return css::registry::RegistryValueType_NOT_DEFINED;
568     }
569 }
570 
571 sal_Int32 RegistryKey::getLongValue()
572     throw (
573         css::registry::InvalidRegistryException,
574         css::registry::InvalidValueException, css::uno::RuntimeException)
575 {
576     osl::MutexGuard g(service_.mutex_);
577     service_.checkValid();
578     sal_Int32 v = 0;
579     if (value_ >>= v) {
580         return v;
581     }
582     throw css::registry::InvalidValueException(
583         rtl::OUString(
584             RTL_CONSTASCII_USTRINGPARAM(
585                 "com.sun.star.configuration.ConfigurationRegistry")),
586         static_cast< cppu::OWeakObject * >(this));
587 }
588 
589 void RegistryKey::setLongValue(sal_Int32)
590     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
591 {
592     throw css::uno::RuntimeException(
593         rtl::OUString(
594             RTL_CONSTASCII_USTRINGPARAM(
595                 "com.sun.star.configuration.ConfigurationRegistry: not"
596                 " implemented")),
597         static_cast< cppu::OWeakObject * >(this));
598 }
599 
600 css::uno::Sequence< sal_Int32 > RegistryKey::getLongListValue()
601     throw (
602         css::registry::InvalidRegistryException,
603         css::registry::InvalidValueException, css::uno::RuntimeException)
604 {
605     osl::MutexGuard g(service_.mutex_);
606     service_.checkValid();
607     css::uno::Sequence< sal_Int32 > v;
608     if (value_ >>= v) {
609         return v;
610     }
611     throw css::registry::InvalidValueException(
612         rtl::OUString(
613             RTL_CONSTASCII_USTRINGPARAM(
614                 "com.sun.star.configuration.ConfigurationRegistry")),
615         static_cast< cppu::OWeakObject * >(this));
616 }
617 
618 void RegistryKey::setLongListValue(css::uno::Sequence< sal_Int32 > const &)
619     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
620 {
621     throw css::uno::RuntimeException(
622         rtl::OUString(
623             RTL_CONSTASCII_USTRINGPARAM(
624                 "com.sun.star.configuration.ConfigurationRegistry: not"
625                 " implemented")),
626         static_cast< cppu::OWeakObject * >(this));
627 }
628 
629 rtl::OUString RegistryKey::getAsciiValue()
630     throw (
631         css::registry::InvalidRegistryException,
632         css::registry::InvalidValueException, css::uno::RuntimeException)
633 {
634     osl::MutexGuard g(service_.mutex_);
635     service_.checkValid();
636     rtl::OUString v;
637     if (value_ >>= v) {
638         return v;
639     }
640     throw css::registry::InvalidValueException(
641         rtl::OUString(
642             RTL_CONSTASCII_USTRINGPARAM(
643                 "com.sun.star.configuration.ConfigurationRegistry")),
644         static_cast< cppu::OWeakObject * >(this));
645 }
646 
647 void RegistryKey::setAsciiValue(rtl::OUString const &)
648     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
649 {
650     throw css::uno::RuntimeException(
651         rtl::OUString(
652             RTL_CONSTASCII_USTRINGPARAM(
653                 "com.sun.star.configuration.ConfigurationRegistry: not"
654                 " implemented")),
655         static_cast< cppu::OWeakObject * >(this));
656 }
657 
658 css::uno::Sequence< rtl::OUString > RegistryKey::getAsciiListValue()
659     throw (
660         css::registry::InvalidRegistryException,
661         css::registry::InvalidValueException, css::uno::RuntimeException)
662 {
663     osl::MutexGuard g(service_.mutex_);
664     service_.checkValid();
665     css::uno::Sequence< rtl::OUString > v;
666     if (value_ >>= v) {
667         return v;
668     }
669     throw css::registry::InvalidValueException(
670         rtl::OUString(
671             RTL_CONSTASCII_USTRINGPARAM(
672                 "com.sun.star.configuration.ConfigurationRegistry")),
673         static_cast< cppu::OWeakObject * >(this));
674 }
675 
676 void RegistryKey::setAsciiListValue(css::uno::Sequence< rtl::OUString > const &)
677     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
678 {
679     throw css::uno::RuntimeException(
680         rtl::OUString(
681             RTL_CONSTASCII_USTRINGPARAM(
682                 "com.sun.star.configuration.ConfigurationRegistry: not"
683                 " implemented")),
684         static_cast< cppu::OWeakObject * >(this));
685 }
686 
687 rtl::OUString RegistryKey::getStringValue()
688     throw (
689         css::registry::InvalidRegistryException,
690         css::registry::InvalidValueException, css::uno::RuntimeException)
691 {
692     osl::MutexGuard g(service_.mutex_);
693     service_.checkValid();
694     rtl::OUString v;
695     if (value_ >>= v) {
696         return v;
697     }
698     throw css::registry::InvalidValueException(
699         rtl::OUString(
700             RTL_CONSTASCII_USTRINGPARAM(
701                 "com.sun.star.configuration.ConfigurationRegistry")),
702         static_cast< cppu::OWeakObject * >(this));
703 }
704 
705 void RegistryKey::setStringValue(rtl::OUString const &)
706     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
707 {
708     throw css::uno::RuntimeException(
709         rtl::OUString(
710             RTL_CONSTASCII_USTRINGPARAM(
711                 "com.sun.star.configuration.ConfigurationRegistry: not"
712                 " implemented")),
713         static_cast< cppu::OWeakObject * >(this));
714 }
715 
716 css::uno::Sequence< rtl::OUString > RegistryKey::getStringListValue()
717     throw (
718         css::registry::InvalidRegistryException,
719         css::registry::InvalidValueException, css::uno::RuntimeException)
720 {
721     osl::MutexGuard g(service_.mutex_);
722     service_.checkValid();
723     css::uno::Sequence< rtl::OUString > v;
724     if (value_ >>= v) {
725         return v;
726     }
727     throw css::registry::InvalidValueException(
728         rtl::OUString(
729             RTL_CONSTASCII_USTRINGPARAM(
730                 "com.sun.star.configuration.ConfigurationRegistry")),
731         static_cast< cppu::OWeakObject * >(this));
732 }
733 
734 void RegistryKey::setStringListValue(
735     css::uno::Sequence< rtl::OUString > const &)
736     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
737 {
738     throw css::uno::RuntimeException(
739         rtl::OUString(
740             RTL_CONSTASCII_USTRINGPARAM(
741                 "com.sun.star.configuration.ConfigurationRegistry: not"
742                 " implemented")),
743         static_cast< cppu::OWeakObject * >(this));
744 }
745 
746 css::uno::Sequence< sal_Int8 > RegistryKey::getBinaryValue()
747     throw (
748         css::registry::InvalidRegistryException,
749         css::registry::InvalidValueException, css::uno::RuntimeException)
750 {
751     osl::MutexGuard g(service_.mutex_);
752     service_.checkValid();
753     css::uno::Sequence< sal_Int8 > v;
754     if (value_ >>= v) {
755         return v;
756     }
757     throw css::registry::InvalidValueException(
758         rtl::OUString(
759             RTL_CONSTASCII_USTRINGPARAM(
760                 "com.sun.star.configuration.ConfigurationRegistry")),
761         static_cast< cppu::OWeakObject * >(this));
762 }
763 
764 void RegistryKey::setBinaryValue(css::uno::Sequence< sal_Int8 > const &)
765     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
766 {
767     throw css::uno::RuntimeException(
768         rtl::OUString(
769             RTL_CONSTASCII_USTRINGPARAM(
770                 "com.sun.star.configuration.ConfigurationRegistry: not"
771                 " implemented")),
772         static_cast< cppu::OWeakObject * >(this));
773 }
774 
775 css::uno::Reference< css::registry::XRegistryKey > RegistryKey::openKey(
776     rtl::OUString const & aKeyName)
777     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
778 {
779     osl::MutexGuard g(service_.mutex_);
780     service_.checkValid_RuntimeException();
781     css::uno::Reference< css::container::XHierarchicalNameAccess > access;
782     if (value_ >>= access) {
783         try {
784             return new RegistryKey(
785                 service_, access->getByHierarchicalName(aKeyName));
786         } catch (css::container::NoSuchElementException &) {}
787     }
788     return css::uno::Reference< css::registry::XRegistryKey >();
789 }
790 
791 css::uno::Reference< css::registry::XRegistryKey > RegistryKey::createKey(
792     rtl::OUString const &)
793     throw (
794         css::registry::InvalidRegistryException, css::uno::RuntimeException)
795 {
796     throw css::uno::RuntimeException(
797         rtl::OUString(
798             RTL_CONSTASCII_USTRINGPARAM(
799                 "com.sun.star.configuration.ConfigurationRegistry: not"
800                 " implemented")),
801         static_cast< cppu::OWeakObject * >(this));
802 }
803 
804 void RegistryKey::closeKey()
805     throw (
806         css::registry::InvalidRegistryException, css::uno::RuntimeException)
807 {
808     osl::MutexGuard g(service_.mutex_);
809     service_.checkValid_RuntimeException();
810 }
811 
812 void RegistryKey::deleteKey(rtl::OUString const &)
813     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
814 {
815     throw css::uno::RuntimeException(
816         rtl::OUString(
817             RTL_CONSTASCII_USTRINGPARAM(
818                 "com.sun.star.configuration.ConfigurationRegistry: not"
819                 " implemented")),
820         static_cast< cppu::OWeakObject * >(this));
821 }
822 
823 css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > >
824 RegistryKey::openKeys()
825     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
826 {
827     throw css::uno::RuntimeException(
828         rtl::OUString(
829             RTL_CONSTASCII_USTRINGPARAM(
830                 "com.sun.star.configuration.ConfigurationRegistry: not"
831                 " implemented")),
832         static_cast< cppu::OWeakObject * >(this));
833 }
834 
835 css::uno::Sequence< rtl::OUString > RegistryKey::getKeyNames()
836     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
837 {
838     throw css::uno::RuntimeException(
839         rtl::OUString(
840             RTL_CONSTASCII_USTRINGPARAM(
841                 "com.sun.star.configuration.ConfigurationRegistry: not"
842                 " implemented")),
843         static_cast< cppu::OWeakObject * >(this));
844 }
845 
846 sal_Bool RegistryKey::createLink(rtl::OUString const &, rtl::OUString const &)
847     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
848 {
849     osl::MutexGuard g(service_.mutex_);
850     service_.checkValid_RuntimeException();
851     return false;
852 }
853 
854 void RegistryKey::deleteLink(rtl::OUString const &)
855     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
856 {
857     osl::MutexGuard g(service_.mutex_);
858     service_.checkValid_RuntimeException();
859 }
860 
861 rtl::OUString RegistryKey::getLinkTarget(rtl::OUString const &)
862     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
863 {
864     osl::MutexGuard g(service_.mutex_);
865     service_.checkValid_RuntimeException();
866     return rtl::OUString();
867 }
868 
869 rtl::OUString RegistryKey::getResolvedName(rtl::OUString const & aKeyName)
870     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
871 {
872     osl::MutexGuard g(service_.mutex_);
873     service_.checkValid_RuntimeException();
874     return aKeyName;
875 }
876 
877 }
878 
879 css::uno::Reference< css::uno::XInterface > create(
880     css::uno::Reference< css::uno::XComponentContext > const & context)
881 {
882     return static_cast< cppu::OWeakObject * >(new Service(context));
883 }
884 
885 rtl::OUString getImplementationName() {
886     return rtl::OUString(
887         RTL_CONSTASCII_USTRINGPARAM(
888             "com.sun.star.comp.configuration.ConfigurationRegistry"));
889 }
890 
891 css::uno::Sequence< rtl::OUString > getSupportedServiceNames() {
892     rtl::OUString name(
893         RTL_CONSTASCII_USTRINGPARAM(
894             "com.sun.star.configuration.ConfigurationRegistry"));
895     return css::uno::Sequence< rtl::OUString >(&name, 1);
896 }
897 
898 } }
899