File indexing completed on 2024-05-12 15:48:11
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 "modemlocation.h" 0008 0009 ModemLocation::ModemLocation(QObject *parent) 0010 : QDBusAbstractAdaptor(parent) 0011 , m_enabledNotifications(false) 0012 , m_capabilities(0) 0013 , m_enabled(0) 0014 , m_signalsLocation(false) 0015 { 0016 } 0017 0018 ModemLocation::~ModemLocation() 0019 { 0020 } 0021 0022 uint ModemLocation::capabilities() const 0023 { 0024 return m_capabilities; 0025 } 0026 0027 uint ModemLocation::enabled() const 0028 { 0029 return m_enabled; 0030 } 0031 0032 ModemManager::LocationInformationMap ModemLocation::location() const 0033 { 0034 return m_location; 0035 } 0036 0037 bool ModemLocation::signalsLocation() const 0038 { 0039 return m_signalsLocation; 0040 } 0041 0042 ModemManager::LocationInformationMap ModemLocation::GetLocation() 0043 { 0044 return m_location; 0045 } 0046 0047 void ModemLocation::Setup(uint sources, bool signal_location) 0048 { 0049 Q_UNUSED(sources); 0050 Q_UNUSED(signal_location) 0051 } 0052 0053 void ModemLocation::setModemPath(const QString &path) 0054 { 0055 m_modemPath = path; 0056 } 0057 0058 void ModemLocation::setEnableNotifications(bool enable) 0059 { 0060 m_enabledNotifications = enable; 0061 } 0062 0063 void ModemLocation::setCapabilities(uint capabilities) 0064 { 0065 m_capabilities = capabilities; 0066 0067 if (m_enabledNotifications) { 0068 QVariantMap map; 0069 map.insert(QLatin1String("Capabilities"), m_capabilities); 0070 QDBusMessage message = QDBusMessage::createSignal(m_modemPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged")); 0071 message << QLatin1String("org.kde.fakemodem.Modem.Location") << map << QStringList(); 0072 QDBusConnection::sessionBus().send(message); 0073 } 0074 } 0075 0076 void ModemLocation::setEnabled(uint enabled) 0077 { 0078 m_enabled = enabled; 0079 0080 if (m_enabledNotifications) { 0081 QVariantMap map; 0082 map.insert(QLatin1String("Enabled"), m_enabled); 0083 QDBusMessage message = QDBusMessage::createSignal(m_modemPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged")); 0084 message << QLatin1String("org.kde.fakemodem.Modem.Location") << map << QStringList(); 0085 QDBusConnection::sessionBus().send(message); 0086 } 0087 } 0088 0089 void ModemLocation::setLocation(const ModemManager::LocationInformationMap &location) 0090 { 0091 m_location = location; 0092 0093 if (m_enabledNotifications) { 0094 QVariantMap map; 0095 map.insert(QLatin1String("Location"), QVariant::fromValue<ModemManager::LocationInformationMap>(location)); 0096 QDBusMessage message = QDBusMessage::createSignal(m_modemPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged")); 0097 message << QLatin1String("org.kde.fakemodem.Modem.Location") << map << QStringList(); 0098 QDBusConnection::sessionBus().send(message); 0099 } 0100 } 0101 0102 void ModemLocation::setSignalsLocation(bool signalsLocation) 0103 { 0104 m_signalsLocation = signalsLocation; 0105 0106 if (m_enabledNotifications) { 0107 QVariantMap map; 0108 map.insert(QLatin1String("SignalsLocation"), m_signalsLocation); 0109 QDBusMessage message = QDBusMessage::createSignal(m_modemPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("PropertiesChanged")); 0110 message << QLatin1String("org.kde.fakemodem.Modem.Location") << map << QStringList(); 0111 QDBusConnection::sessionBus().send(message); 0112 } 0113 } 0114 0115 QVariantMap ModemLocation::toMap() const 0116 { 0117 QVariantMap map; 0118 map.insert(QLatin1String(MM_MODEM_LOCATION_PROPERTY_CAPABILITIES), m_capabilities); 0119 map.insert(QLatin1String(MM_MODEM_LOCATION_PROPERTY_ENABLED), m_enabled); 0120 map.insert(QLatin1String(MM_MODEM_LOCATION_PROPERTY_SIGNALSLOCATION), QVariant::fromValue<ModemManager::LocationInformationMap>(m_location)); 0121 map.insert(QLatin1String(MM_MODEM_LOCATION_PROPERTY_LOCATION), m_signalsLocation); 0122 return map; 0123 } 0124 0125 #include "moc_modemlocation.cpp"