Commit 4c5d343b authored by Jan Grulich's avatar Jan Grulich
Browse files

Enable ModemManager support

parent 749fc975
project(plasma-networkmanagement)
# TODO
set(DISABLE_MODEMMANAGER_SUPPORT 1)
cmake_minimum_required(VERSION 2.8.6 FATAL_ERROR)
set(QT_MIN_VERSION "5.2.0")
......
......@@ -52,4 +52,8 @@ private:
ModemMonitorPrivate * d_ptr;
};
// Types from libmm-qt are not declared, because some
// of them are in conflict with types from libnm-qt
Q_DECLARE_METATYPE(MMModemLock)
#endif // PLASMA_NM_MODEM_MONITOR_H
......@@ -50,9 +50,8 @@ PinDialog::PinDialog(ModemManager::Modem *modem, const Type type, QWidget *paren
}
}
QWidget *w = new QWidget();
ui = new Ui::PinWidget();
ui->setupUi(w);
ui->setupUi(this);
ui->pin->setPasswordMode(true);
QIntValidator * validator = new QIntValidator(this);
......@@ -68,15 +67,13 @@ PinDialog::PinDialog(ModemManager::Modem *modem, const Type type, QWidget *paren
QRect desktop = KGlobalSettings::desktopGeometry(topLevelWidget());
setMinimumWidth(qMin(1000, qMax(sizeHint().width(), desktop.width() / 4)));
pixmapLabel = new QLabel(mainWidget());
pixmapLabel = new QLabel(this);
pixmapLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);
ui->gridLayout->addWidget(pixmapLabel, 0, 0);
pixmapLabel->setPixmap(KIcon("dialog-password").pixmap(KIconLoader::SizeHuge));
setButtons(QDialog::Ok | QDialog::Cancel);
setDefaultButton(QDialog::Ok);
button(QDialog::Ok)->setText(i18nc("As in 'Unlock cell phone with this pin code'", "Unlock"));
setMainWidget(w);
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
if (isPukDialog()) {
QString pukType;
......
......@@ -103,12 +103,12 @@
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="verticalSpacing">
<number>0</number>
</property>
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
......@@ -179,6 +179,13 @@
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
......
......@@ -30,6 +30,11 @@
#include <NetworkManagerQt/WirelessDevice>
#include <NetworkManagerQt/WirelessSetting>
#if WITH_MODEMMANAGER_SUPPORT
#include <ModemManagerQt/manager.h>
#include <ModemManagerQt/modem.h>
#endif
ConnectionIcon::ConnectionIcon(QObject* parent)
: QObject(parent)
, m_signal(0)
......@@ -450,7 +455,13 @@ void ConnectionIcon::setModemIcon(const NetworkManager::Device::Ptr & device)
return;
}
m_modemNetwork = modemDevice->getModemNetworkIface();
ModemManager::Modem::Ptr m_modemNetwork;
ModemManager::ModemDevice::Ptr modem = ModemManager::findModemDevice(device->udi());
if (modem) {
if (modem->hasInterface(ModemManager::ModemDevice::ModemInterface)) {
m_modemNetwork = modem->interface(ModemManager::ModemDevice::ModemInterface).objectCast<ModemManager::Modem>();
}
}
if (m_modemNetwork) {
connect(m_modemNetwork.data(), SIGNAL(signalQualityChanged(uint)),
......
......@@ -227,15 +227,19 @@ void NetworkModel::initializeSignals(const NetworkManager::Device::Ptr& device)
}
#if WITH_MODEMMANAGER_SUPPORT
else if (device->type() == NetworkManager::Device::Modem) {
NetworkManager::ModemDevice::Ptr modemDev = device.objectCast<NetworkManager::ModemDevice>();
ModemManager::Modem::Ptr modemNetwork = modemDev->getModemNetworkIface();
if (modemDev->isValid()) {
connect(modemNetwork.data(), SIGNAL(signalQualityChanged(uint)),
SLOT(gsmNetworkSignalQualityChanged(uint)), Qt::UniqueConnection);
connect(modemNetwork.data(), SIGNAL(accessTechnologyChanged(ModemManager::Modem::AccessTechnologies)),
SLOT(gsmNetworkAccessTechnologyChanged(ModemManager::Modem::AccessTechnologies)), Qt::UniqueConnection);
connect(modemNetwork.data(), SIGNAL(currentModesChanged()),
SLOT(gsmNetworkCurrentModesChanged()), Qt::UniqueConnection);
ModemManager::ModemDevice::Ptr modem = ModemManager::findModemDevice(device->udi());
if (modem) {
if (modem->hasInterface(ModemManager::ModemDevice::ModemInterface)) {
ModemManager::Modem::Ptr modemNetwork = modem->interface(ModemManager::ModemDevice::ModemInterface).objectCast<ModemManager::Modem>();
if (modemNetwork) {
connect(modemNetwork.data(), SIGNAL(signalQualityChanged(uint)),
SLOT(gsmNetworkSignalQualityChanged(uint)), Qt::UniqueConnection);
connect(modemNetwork.data(), SIGNAL(accessTechnologyChanged(ModemManager::Modem::AccessTechnologies)),
SLOT(gsmNetworkAccessTechnologyChanged(ModemManager::Modem::AccessTechnologies)), Qt::UniqueConnection);
connect(modemNetwork.data(), SIGNAL(currentModesChanged()),
SLOT(gsmNetworkCurrentModesChanged()), Qt::UniqueConnection);
}
}
}
}
#endif
......@@ -752,12 +756,15 @@ void NetworkModel::gsmNetworkAccessTechnologyChanged(ModemManager::Modem::Access
if (gsmNetwork) {
foreach (const NetworkManager::Device::Ptr & dev, NetworkManager::networkInterfaces()) {
if (dev->type() == NetworkManager::Device::Modem) {
NetworkManager::ModemDevice::Ptr modem = dev.objectCast<NetworkManager::ModemDevice>();
ModemManager::ModemDevice::Ptr modem = ModemManager::findModemDevice(dev->udi());
if (modem) {
if (modem->getModemNetworkIface()->device() == gsmNetwork->device()) {
// TODO store access technology internally?
foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Device, modem->uni())) {
updateItem(item);
if (modem->hasInterface(ModemManager::ModemDevice::ModemInterface)) {
ModemManager::Modem::Ptr modemNetwork = modem->interface(ModemManager::ModemDevice::ModemInterface).objectCast<ModemManager::Modem>();
if (modemNetwork && modemNetwork->device() == gsmNetwork->device()) {
// TODO store access technology internally?
foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Device, modem->uni())) {
updateItem(item);
}
}
}
}
......@@ -772,11 +779,14 @@ void NetworkModel::gsmNetworkCurrentModesChanged()
if (gsmNetwork) {
foreach (const NetworkManager::Device::Ptr & dev, NetworkManager::networkInterfaces()) {
if (dev->type() == NetworkManager::Device::Modem) {
NetworkManager::ModemDevice::Ptr modem = dev.objectCast<NetworkManager::ModemDevice>();
ModemManager::ModemDevice::Ptr modem = ModemManager::findModemDevice(dev->udi());
if (modem) {
if (modem->getModemNetworkIface()->device() == gsmNetwork->device()) {
foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Device, modem->uni())) {
updateItem(item);
if (modem->hasInterface(ModemManager::ModemDevice::ModemInterface)) {
ModemManager::Modem::Ptr modemNetwork = modem->interface(ModemManager::ModemDevice::ModemInterface).objectCast<ModemManager::Modem>();
if (modemNetwork && modemNetwork->device() == gsmNetwork->device()) {
foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Device, modem->uni())) {
updateItem(item);
}
}
}
}
......@@ -791,12 +801,15 @@ void NetworkModel::gsmNetworkSignalQualityChanged(uint signal)
if (gsmNetwork) {
foreach (const NetworkManager::Device::Ptr & dev, NetworkManager::networkInterfaces()) {
if (dev->type() == NetworkManager::Device::Modem) {
NetworkManager::ModemDevice::Ptr modem = dev.objectCast<NetworkManager::ModemDevice>();
ModemManager::ModemDevice::Ptr modem = ModemManager::findModemDevice(dev->udi());
if (modem) {
if (modem->getModemNetworkIface()->device() == gsmNetwork->device()) {
foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Device, modem->uni())) {
item->setSignal(signal);
updateItem(item);
if (modem->hasInterface(ModemManager::ModemDevice::ModemInterface)) {
ModemManager::Modem::Ptr modemNetwork = modem->interface(ModemManager::ModemDevice::ModemInterface).objectCast<ModemManager::Modem>();
if (modemNetwork && modemNetwork->device() == gsmNetwork->device()) {
foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Device, modem->uni())) {
item->setSignal(signal);
updateItem(item);
}
}
}
}
......
......@@ -797,9 +797,9 @@ QString UiUtils::modemDetails(const ModemDevice::Ptr& modemDevice, const QString
details += QString(format).arg(i18n("IMEI:"), modemNetwork->equipmentIdentifier());
}
} else if (key == "mobile:imsi") {
if (modemDevice) {
if (modem) {
ModemManager::Sim::Ptr simCard;
simCard = modemDevice->getModemCardIface();
simCard = modem->sim();
if (simCard) {
details += QString(format).arg(i18n("IMSI:"), simCard->imsi());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment