2
Copyright 2008 Will Stephenson <wstephenson@kde.org>
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License as
6
published by the Free Software Foundation; either version 2 of
7
the License or (at your option) version 3 or any later version
8
accepted by the membership of KDE e.V. (or its successor approved
9
by the membership of KDE e.V.), which shall act as a proxy
10
defined in Section 14 of version 3 of the license.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program. If not, see <http://www.gnu.org/licenses/>.
21
#include "networkgsminterface.h"
25
#include "networkgsminterface_p.h"
28
#include "solid/control/modemmanager.h"
30
NMGsmNetworkInterfacePrivate::NMGsmNetworkInterfacePrivate(const QString & path, QObject * owner)
31
: NMSerialNetworkInterfacePrivate(path, owner), gsmIface(NMNetworkManager::DBUS_SERVICE, path, QDBusConnection::systemBus())
35
NMGsmNetworkInterface::NMGsmNetworkInterface(const QString & path, NMNetworkManager * manager, QObject * parent)
36
: NMSerialNetworkInterface(*new NMGsmNetworkInterfacePrivate(path, this), manager, parent),
37
modemGsmCardIface(0), modemGsmNetworkIface(0)
39
Q_D(NMGsmNetworkInterface);
40
connect( &d->gsmIface, SIGNAL(PropertiesChanged(const QVariantMap &)),
41
this, SLOT(gsmPropertiesChanged(const QVariantMap &)));
44
NMGsmNetworkInterface::NMGsmNetworkInterface(NMGsmNetworkInterfacePrivate & dd, NMNetworkManager * manager, QObject * parent) : NMSerialNetworkInterface(dd, manager, parent),
45
modemGsmCardIface(0), modemGsmNetworkIface(0)
47
Q_D(NMGsmNetworkInterface);
48
connect( &d->gsmIface, SIGNAL(PropertiesChanged(const QVariantMap &)),
49
this, SLOT(gsmPropertiesChanged(const QVariantMap &)));
52
NMGsmNetworkInterface::~NMGsmNetworkInterface()
57
void NMGsmNetworkInterface::gsmPropertiesChanged(const QVariantMap & changedProperties)
59
kDebug(1441) << changedProperties.keys();
62
QString NMGsmNetworkInterface::getUdiForModemManager()
64
if (driver() != QLatin1String("bluez")) {
68
/* BlueZ knows about the rfcommX string that we could use to find the device in ModemManager
69
* but does not export this info, so let's use the first bluetooth device we find in ModemManager.
70
* Modem will be registered in ModemManager only after someone execute its org.bluez.Serial.Connect method. */
71
foreach(const Solid::Control::ModemInterface *modem, Solid::Control::ModemManager::modemInterfaces()) {
72
if (modem->driver() == QLatin1String("bluetooth")) {
81
Solid::Control::ModemGsmCardInterface * NMGsmNetworkInterface::getModemCardIface()
83
QString correctUdi = getUdiForModemManager();
84
if (correctUdi.isEmpty()) {
87
if (modemGsmCardIface == 0) {
88
modemGsmCardIface = qobject_cast<Solid::Control::ModemGsmCardInterface*> (Solid::Control::ModemManager::findModemInterface(correctUdi, Solid::Control::ModemInterface::GsmCard));
89
connect(Solid::Control::ModemManager::notifier(), SIGNAL(modemInterfaceRemoved(const QString &)), this, SLOT(modemRemoved(const QString &)));
92
return modemGsmCardIface;
95
Solid::Control::ModemGsmNetworkInterface * NMGsmNetworkInterface::getModemNetworkIface()
97
QString correctUdi = getUdiForModemManager();
98
if (correctUdi.isEmpty()) {
101
if (modemGsmNetworkIface == 0) {
102
modemGsmNetworkIface = qobject_cast<Solid::Control::ModemGsmNetworkInterface*> (Solid::Control::ModemManager::findModemInterface(correctUdi, Solid::Control::ModemInterface::GsmNetwork));
103
if (modemGsmNetworkIface) {
104
connect(Solid::Control::ModemManager::notifier(), SIGNAL(modemInterfaceRemoved(const QString &)), this, SLOT(modemRemoved(const QString &)));
108
return modemGsmNetworkIface;
111
void NMGsmNetworkInterface::modemRemoved(const QString & modemUdi)
113
if (modemUdi == udi()) {
114
modemGsmNetworkIface = 0;
115
modemGsmCardIface = 0;
119
void NMGsmNetworkInterface::setModemCardIface(Solid::Control::ModemGsmCardInterface * iface)
121
modemGsmCardIface = iface;
124
void NMGsmNetworkInterface::setModemNetworkIface(Solid::Control::ModemGsmNetworkInterface * iface)
126
modemGsmNetworkIface = iface;
129
#include "networkgsminterface.moc"
131
// vim: sw=4 sts=4 et tw=100