File indexing completed on 2024-05-19 11:47:22
0001 /* 0002 SPDX-FileCopyrightText: 2015 Jan Grulich <jgrulich@redhat.com> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #include "objectmanager.h" 0008 #include "dbus/fakedbus.h" 0009 0010 ObjectManager::ObjectManager(QObject *parent) 0011 : QDBusAbstractAdaptor(parent) 0012 { 0013 qDBusRegisterMetaType<QDBusObjectPath>(); 0014 qDBusRegisterMetaType<ModemManager::MMVariantMapMap>(); 0015 qDBusRegisterMetaType<ModemManager::DBUSManagerStruct>(); 0016 } 0017 0018 ObjectManager::~ObjectManager() 0019 { 0020 } 0021 0022 void ObjectManager::addInterfaces(const QDBusObjectPath &object_path, const ModemManager::MMVariantMapMap &interfaces_and_properties) 0023 { 0024 if (m_managedObjects.contains(object_path)) { 0025 ModemManager::MMVariantMapMap map = m_managedObjects.value(object_path); 0026 map.insert(interfaces_and_properties); 0027 m_managedObjects.insert(object_path, map); 0028 } else { 0029 m_managedObjects.insert(object_path, interfaces_and_properties); 0030 } 0031 0032 Q_EMIT InterfacesAdded(object_path, interfaces_and_properties); 0033 } 0034 0035 void ObjectManager::removeInterfaces(const QDBusObjectPath &object_path, const QStringList &interfaces) 0036 { 0037 if (interfaces.contains(QLatin1String(MMQT_DBUS_INTERFACE_MODEM))) { 0038 m_managedObjects.remove(object_path); 0039 } else { 0040 ModemManager::MMVariantMapMap map = m_managedObjects.value(object_path); 0041 Q_FOREACH (const QString &key, interfaces) { 0042 map.remove(key); 0043 } 0044 m_managedObjects.insert(object_path, map); 0045 } 0046 0047 Q_EMIT InterfacesRemoved(object_path, interfaces); 0048 } 0049 0050 ModemManager::DBUSManagerStruct ObjectManager::GetManagedObjects() 0051 { 0052 return m_managedObjects; 0053 } 0054 0055 #include "moc_objectmanager.cpp"