Commit 1419280f authored by Jan Grulich's avatar Jan Grulich
Browse files

Fix build of classes in kded

parent 686b009e
......@@ -4,13 +4,12 @@ if (MODEMMANAGERQT_FOUND)
passworddialog.cpp
secretagent.cpp
service.cpp
# // TODO: port to MM1
# bluetoothmonitor.cpp
# modemmonitor.cpp
# pindialog.cpp
bluetoothmonitor.cpp
modemmonitor.cpp
pindialog.cpp
)
kde4_add_ui_files(kded_networkmanagement_SRCS
# pinwidget.ui
pinwidget.ui
passworddialog.ui
)
......
......@@ -39,6 +39,11 @@
#include <NetworkManagerQt/Manager>
#include <NetworkManagerQt/Utils>
#ifdef MODEMMANAGERQT_ONE
#include <ModemManagerQt/modem.h>
#include <ModemManagerQt/modemdevice.h>
#endif
BluetoothMonitor::BluetoothMonitor(QObject * parent)
: QObject(parent)
{
......@@ -222,22 +227,21 @@ void BluetoothMonitor::modemAdded(const QString &udi)
#ifdef MODEMMANAGERQT_ONE
ModemManager::ModemDevice::Ptr modemDevice = ModemManager::findModemDevice(udi);
ModemManager::Modem::Ptr modem = ModemManager::findModemInterface(udi, ModemManager::ModemInterface::Gsm);
ModemManager::Modem::Ptr modem = modemDevice->interface(ModemManager::ModemDevice::ModemInterface).objectCast<ModemManager::Modem>();
if (!modem) {
// Try CDMA if no GSM device has been found.
modem = ModemManager::findModemInterface(udi, ModemManager::ModemInterface::Cdma);
}
#else
ModemManager::ModemInterface::Ptr modem = ModemManager::findModemInterface(udi, ModemManager::ModemInterface::GsmCard);
ModemManager::ModemInterface::Ptr modemDevice = ModemManager::findModemInterface(udi, ModemManager::ModemInterface::GsmCard);
if (!modem) {
// Try CDMA if no GSM device has been found.
modem = ModemManager::findModemInterface(udi, ModemManager::ModemInterface::NotGsm);
}
#endif
#ifdef MODEMMANAGERQT_ONE
qDebug() << "Found suitable modem:" << modemDevice->uni();
#else
qDebug() << "Found suitable modem:" << modem->udi();
#endif
qDebug() << "DUN device:" << mDunDevice;
QStringList temp = mDunDevice.split('/');
......@@ -246,6 +250,7 @@ void BluetoothMonitor::modemAdded(const QString &udi)
}
if (!modem || modem->device() != mDunDevice) {
if (modem) {
KMessageBox::error(0, i18n("Device %1 is not the one we want (%2)", modem->device(), mDunDevice));
} else {
......@@ -256,9 +261,9 @@ void BluetoothMonitor::modemAdded(const QString &udi)
NetworkManager::ConnectionSettings::ConnectionType type;
#ifdef MODEMMANAGERQT_ONE
if (modem->isGsmModem())
if (modemDevice->isGsmModem())
type = NetworkManager::ConnectionSettings::Gsm;
else if (modem->isCdmaModem())
else if (modemDevice->isCdmaModem())
type = NetworkManager::ConnectionSettings::Cdma;
else
type = NetworkManager::ConnectionSettings::Unknown;
......
......@@ -29,14 +29,12 @@
#include <KDebug>
#include <ModemManagerQt/manager.h>
#if WITH_MODEMMANAGER_SUPPORT
#ifdef MODEMMANAGERQT_ONE
#include <ModemManager/ModemManager.h>
#include <ModemManagerQt/modemdevice.h>
#include <ModemManagerQt/modem.h>
#include <ModemManagerQt/sim.h>
#endif
#endif
#include "pindialog.h"
......@@ -53,7 +51,6 @@ ModemMonitor::ModemMonitor(QObject * parent)
d->dialog.clear();
QObject::connect(ModemManager::notifier(), SIGNAL(modemAdded(QString)), SLOT(modemAdded(QString)));
#if WITH_MODEMMANAGER_SUPPORT
#ifdef MODEMMANAGERQT_ONE
foreach (const ModemManager::ModemDevice::Ptr &iface, ModemManager::modemDevices()) {
modemAdded(iface->uni());
......@@ -63,7 +60,6 @@ ModemMonitor::ModemMonitor(QObject * parent)
modemAdded(iface->udi());
}
#endif
#endif
}
ModemMonitor::~ModemMonitor()
......@@ -97,8 +93,8 @@ void ModemMonitor::modemAdded(const QString & udi)
if (modemInterface) {
// Using queued invocation to prevent kded stalling here until user enters the pin.
QMetaObject::invokeMethod(&modemInterface, "unlockRequiredChanged", Qt::QueuedConnection,
Q_ARG(MMModemLock, modemInterface.unlockRequired()));
QMetaObject::invokeMethod(modemInterface.data(), "unlockRequiredChanged", Qt::QueuedConnection,
Q_ARG(MMModemLock, modemInterface->unlockRequired()));
}
}
......@@ -120,14 +116,29 @@ void ModemMonitor::requestPin(MMModemLock lock)
return;
}
if (lock == MM_MODEM_LOCK_SIM_PIN) {
d->dialog = new PinDialog(sim, PinDialog::Pin);
} else if (lock == MM_MODEM_LOCK_SIM_PUK) {
d->dialog = new PinDialog(sim, PinDialog::PinPuk);
} else {
// TODO handle other lock types?
kWarning() << "Unhandled unlock request for '" << lock << "'";
return;
ModemManager::Modem::Ptr modem;
foreach (ModemManager::ModemDevice::Ptr modemDevice, ModemManager::modemDevices()) {
if (modemDevice) {
ModemManager::Modem::Ptr modemTmp = modemDevice->interface(ModemManager::ModemDevice::ModemInterface).objectCast<ModemManager::Modem>();
if (modem && modem->simPath() == sim->uni()) {
modem = modemTmp;
break;
}
}
}
if (modem) {
if (lock == MM_MODEM_LOCK_SIM_PIN) {
d->dialog = new PinDialog(modem.data(), PinDialog::Pin);
} else if (lock == MM_MODEM_LOCK_SIM_PUK) {
d->dialog = new PinDialog(modem.data(), PinDialog::PinPuk);
} else {
// TODO handle other lock types?
kWarning() << "Unhandled unlock request for '" << lock << "'";
return;
}
}
if (d->dialog.data()->exec() != QDialog::Accepted) {
......
......@@ -25,12 +25,10 @@
#include <QObject>
#include <QDBusPendingCallWatcher>
#if WITH_MODEMMANAGER_SUPPORT
#ifdef MODEMMANAGERQT_ONE
#include <ModemManager/ModemManager.h>
#ifdef MODEMMANAGERQT_ONE
#include <ModemManagerQt/modem.h>
#endif
#endif
#include <kdemacros.h>
#include "config.h"
......
......@@ -19,8 +19,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "pindialog.h"
#include "config.h"
#include "pindialog.h"
#include <QIntValidator>
......@@ -28,6 +28,7 @@
#include <kwindowsystem.h>
#include <ModemManagerQt/manager.h>
#ifdef MODEMMANAGERQT_ONE
PinDialog::PinDialog(ModemManager::Modem *modem, const Type type, QWidget *parent)
#else
......@@ -35,10 +36,11 @@ PinDialog::PinDialog(ModemManager::ModemInterface *modem, const Type type, QWidg
#endif
{
if (modem) {
m_udi = modem->udi();
#ifdef MODEMMANAGERQT_ONE
m_udi = modem->uni();
m_name = modem->device();
#else
m_udi = modem->udi();
m_name = modem->masterDevice();
#endif
foreach (const Solid::Device &d, Solid::Device::allDevices()) {
......
......@@ -26,10 +26,10 @@
#include "secretagent.h"
#include "notification.h"
// #if WITH_MODEMMANAGER_SUPPORT
// #include "modemmonitor.h"
// #endif
// #include "bluetoothmonitor.h"
#if WITH_MODEMMANAGER_SUPPORT
#include "modemmonitor.h"
#endif
#include "bluetoothmonitor.h"
#include <QDBusMetaType>
......@@ -51,11 +51,10 @@ NetworkManagementService::NetworkManagementService(QObject * parent, const QVari
d->agent = new SecretAgent(this);
new Notification(this);
//TODO
// #if WITH_MODEMMANAGER_SUPPORT
// new ModemMonitor(this);
// #endif
// new BluetoothMonitor(this);
#if WITH_MODEMMANAGER_SUPPORT
new ModemMonitor(this);
#endif
new BluetoothMonitor(this);
}
NetworkManagementService::~NetworkManagementService()
......
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