File indexing completed on 2024-07-07 04:30:05

0001 /*
0002     SPDX-FileCopyrightText: 2012 Frederik Gladhorn <gladhorn@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #include "registry.h"
0008 #include "registry_p.h"
0009 
0010 #include <qurl.h>
0011 
0012 using namespace QAccessibleClient;
0013 
0014 Registry::Registry(QObject *parent)
0015     : QObject(parent), d(new RegistryPrivate(this))
0016 {
0017     registerDBusTypes();
0018 }
0019 
0020 Registry::~Registry()
0021 {
0022     delete d;
0023 }
0024 
0025 bool Registry::isEnabled() const
0026 {
0027     return d->isEnabled();
0028 }
0029 
0030 void Registry::setEnabled(bool enable)
0031 {
0032     d->setEnabled(enable);
0033 }
0034 
0035 bool Registry::isScreenReaderEnabled() const
0036 {
0037     return d->isScreenReaderEnabled();
0038 }
0039 
0040 void Registry::setScreenReaderEnabled(bool enable)
0041 {
0042     d->setScreenReaderEnabled(enable);
0043 }
0044 
0045 void Registry::subscribeEventListeners(const EventListeners &listeners) const
0046 {
0047     d->subscribeEventListeners(listeners);
0048 }
0049 
0050 Registry::EventListeners Registry::subscribedEventListeners() const
0051 {
0052     return d->eventListeners();
0053 }
0054 
0055 QList<AccessibleObject> Registry::applications() const
0056 {
0057     return d->topLevelAccessibles();
0058 }
0059 
0060 AccessibleObject Registry::accessibleFromUrl(const QUrl &url) const
0061 {
0062     return d->fromUrl(url);
0063 }
0064 
0065 Registry::CacheType Registry::cacheType() const
0066 {
0067     if (dynamic_cast<CacheWeakStrategy*>(d->m_cache))
0068         return WeakCache;
0069     return NoCache;
0070 }
0071 
0072 void Registry::setCacheType(Registry::CacheType type)
0073 {
0074     //if (cacheType() == type) return;
0075     delete d->m_cache;
0076     d->m_cache = nullptr;
0077     switch (type) {
0078         case NoCache:
0079             break;
0080         case WeakCache:
0081             d->m_cache = new CacheWeakStrategy();
0082             break;
0083     }
0084 }
0085 
0086 AccessibleObject Registry::clientCacheObject(const QString &id) const
0087 {
0088     if (d->m_cache) {
0089         QSharedPointer<AccessibleObjectPrivate> p = d->m_cache->get(id);
0090         if (p)
0091             return AccessibleObject(p);
0092     }
0093     return AccessibleObject();
0094 }
0095 
0096 QStringList Registry::clientCacheObjects() const
0097 {
0098     QStringList result;
0099     if (d->m_cache)
0100         return d->m_cache->ids();
0101     return QStringList();
0102 }
0103 
0104 void Registry::clearClientCache()
0105 {
0106     if (d->m_cache)
0107         d->m_cache->clear();
0108 }
0109 
0110 #include "moc_registry.cpp"