Commit 0718c5c8 authored by Jan Grulich's avatar Jan Grulich
Browse files

Make it compilable without libmm-qt

parent 5b8846b1
......@@ -8,10 +8,19 @@ find_package(NetworkManager "0.9.8" REQUIRED)
include(FindPkgConfig)
include(KDE4Defaults)
pkg_check_modules(MODEMMANAGERQT REQUIRED ModemManagerQt)
if (NOT MODEMMANAGERQT_FOUND)
message(FATAL_ERROR "ERROR: ModemManagerQt not found. http://projects.kde.org/libmm-qt")
endif (NOT MODEMMANAGERQT_FOUND)
if (DISABLE_MODEMMANAGERQT)
message(STATUS "Disabling ModemManagerQt support")
set(WITH_MODEMMANAGERQT 0)
else()
pkg_check_modules(MODEMMANAGERQT ModemManagerQt)
if (MODEMMANAGERQT_FOUND)
message(STATUS "Enabling ModemManagerQt support")
set(WITH_MODEMMANAGERQT 1)
else()
message(STATUS "ModemManagerQt not found")
set(WITH_MODEMMANAGERQT 0)
endif()
endif()
pkg_check_modules(NETWORKMANAGERQT REQUIRED NetworkManagerQt)
if (NOT NETWORKMANAGERQT_FOUND)
......@@ -33,6 +42,7 @@ pkg_check_modules(QTNETWORK REQUIRED QtNetwork)
pkg_check_modules(NETWORKMANAGER REQUIRED NetworkManager)
add_definitions(
-DWITH_MODEMMANAGERQT=${WITH_MODEMMANAGERQT}
${QT_DEFINITIONS}
${KDE_DEFINITIONS}
${NETWORKMANAGERQT_CFLAGS_OTHER}
......@@ -45,7 +55,9 @@ include_directories(${CMAKE_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/lib
${CMAKE_CURRENT_SOURCE_DIR}/lib/editor
${QTNETWORK_INCLUDE_DIRS}
${MODEMMANAGERQT_INCLUDE_DIRS}
if (MODEMMANAGERQT_FOUND)
${MODEMMANAGERQT_INCLUDE_DIRS}
endif()
${NETWORKMANAGERQT_INCLUDE_DIRS}
${NETWORKMANAGER_INCLUDE_DIRS}
${KDE4_INCLUDES})
......
......@@ -34,8 +34,10 @@
ConnectionIcon::ConnectionIcon(QObject* parent):
QObject(parent),
m_signal(0),
m_modemNetwork(0)
m_signal(0)
#if WITH_MODEMMANAGERQT
,m_modemNetwork(0)
#endif
{
}
......@@ -141,12 +143,12 @@ void ConnectionIcon::setIcons()
bool vpnFound = false;
m_signal = 0;
#if WITH_MODEMMANAGERQT
if (m_modemNetwork) {
disconnect(m_modemNetwork.data(), 0, this, 0);
m_modemNetwork.clear();
}
#endif
if (m_wirelessNetwork) {
disconnect(m_wirelessNetwork.data(), 0, this, 0);
m_wirelessNetwork.clear();
......@@ -195,13 +197,23 @@ void ConnectionIcon::setIcons()
Q_EMIT setTooltipIcon("network-wired-activated");
} else if (type == NetworkManager::Device::Modem) {
connectionFound = true;
#if WITH_MODEMMANAGERQT
setModemIcon(device);
#else
Q_EMIT setConnectionIcon("network-mobile-0");
Q_EMIT setTooltipIcon("phone");
#endif
} else if (type == NetworkManager::Device::Bluetooth) {
NetworkManager::BluetoothDevice::Ptr btDevice = device.objectCast<NetworkManager::BluetoothDevice>();
if (btDevice) {
connectionFound = true;
if (btDevice->bluetoothCapabilities().testFlag(NetworkManager::BluetoothDevice::Dun)) {
#if WITH_MODEMMANAGERQT
setModemIcon(device);
#else
Q_EMIT setConnectionIcon("network-mobile-0");
Q_EMIT setTooltipIcon("phone");
#endif
} else {
NMAppletDebug() << "Emit signal setConnectionIcon(bluetooth)";
Q_EMIT setConnectionIcon("bluetooth");
......@@ -270,7 +282,7 @@ void ConnectionIcon::setDisconnectedIcon()
return;
} else if (modem) {
NMAppletDebug() << "Emit signal setConnectionIcon(network-mobile)";
Q_EMIT setConnectionIcon("network-mobile");
Q_EMIT setConnectionIcon("network-mobile-0");
Q_EMIT setTooltipIcon("phone");
Q_EMIT setHoverIcon("dialog-cancel");
return;
......@@ -288,7 +300,7 @@ void ConnectionIcon::setDisconnectedIcon()
return;
}
}
#if WITH_MODEMMANAGERQT
void ConnectionIcon::setModemIcon(const NetworkManager::Device::Ptr & device)
{
NetworkManager::ModemDevice::Ptr modemDevice = device.objectCast<NetworkManager::ModemDevice>();
......@@ -314,7 +326,7 @@ void ConnectionIcon::setModemIcon(const NetworkManager::Device::Ptr & device)
setIconForModem();
} else {
NMAppletDebug() << "Emit signal setConnectionIcon(network-mobile)";
Q_EMIT setConnectionIcon("network-mobile");
Q_EMIT setConnectionIcon("network-mobile-0");
Q_EMIT setTooltipIcon("phone");
return;
}
......@@ -397,7 +409,7 @@ void ConnectionIcon::setIconForModem()
Q_EMIT setConnectionIcon(QString(result).arg(strength));
Q_EMIT setTooltipIcon("phone");
}
#endif
void ConnectionIcon::setWirelessIcon(const NetworkManager::Device::Ptr &device, const QString& ssid)
{
NetworkManager::WirelessDevice::Ptr wirelessDevice = device.objectCast<NetworkManager::WirelessDevice>();
......
......@@ -24,9 +24,9 @@
#include <NetworkManagerQt/Manager>
#include <NetworkManagerQt/ActiveConnection>
#include <NetworkManagerQt/WirelessNetwork>
#if WITH_MODEMMANAGERQT
#include <ModemManagerQt/modemgsmnetworkinterface.h>
#endif
class ConnectionIcon : public QObject
{
Q_OBJECT
......@@ -43,12 +43,13 @@ private Q_SLOTS:
void carrierChanged(bool carrier);
void deviceAdded(const QString & device);
void deviceRemoved(const QString & device);
void modemNetworkRemoved();
void modemSignalChanged(uint signal);
void setIcons();
void setWirelessIconForSignalStrength(int strength);
#if WITH_MODEMMANAGERQT
void modemNetworkRemoved();
void modemSignalChanged(uint signal);
void setIconForModem();
#endif
Q_SIGNALS:
void hideConnectingIndicator();
void showConnectingIndicator();
......@@ -60,11 +61,13 @@ Q_SIGNALS:
private:
int m_signal;
NetworkManager::WirelessNetwork::Ptr m_wirelessNetwork;
ModemManager::ModemGsmNetworkInterface::Ptr m_modemNetwork;
void setDisconnectedIcon();
void setModemIcon(const NetworkManager::Device::Ptr & device);
void setWirelessIcon(const NetworkManager::Device::Ptr & device, const QString & ssid);
#if WITH_MODEMMANAGERQT
ModemManager::ModemGsmNetworkInterface::Ptr m_modemNetwork;
void setModemIcon(const NetworkManager::Device::Ptr & device);
#endif
};
#endif // PLASMA_NM_CONNECTION_ICON_H
......@@ -63,12 +63,14 @@ Model::Model(QObject* parent):
SLOT(addWimaxNsp(QString,QString)));
connect(m_monitor, SIGNAL(addWirelessNetwork(QString,QString)),
SLOT(addWirelessNetwork(QString,QString)));
#if WITH_MODEMMANAGERQT
connect(m_monitor, SIGNAL(modemAccessTechnologyChanged(QString)),
SLOT(modemPropertiesChanged(QString)));
connect(m_monitor, SIGNAL(modemAllowedModeChanged(QString)),
SLOT(modemPropertiesChanged(QString)));
connect(m_monitor, SIGNAL(modemSignalQualityChanged(uint, QString)),
SLOT(modemSignalQualityChanged(uint, QString)));
#endif
connect(m_monitor, SIGNAL(removeActiveConnection(uint, QString)),
SLOT(removeActiveConnection(QString)));
connect(m_monitor, SIGNAL(removeAvailableConnection(QString,QString)),
......@@ -268,7 +270,7 @@ void Model::connectionUpdated(const QString& connection)
}
}
}
#if WITH_MODEMMANAGERQT
void Model::modemPropertiesChanged(const QString& modem)
{
foreach (ModelItem * item, m_items.itemsByDevice(modem)) {
......@@ -291,7 +293,7 @@ void Model::modemSignalQualityChanged(uint signal, const QString& modem)
}
}
}
#endif
void Model::removeActiveConnection(const QString& active)
{
ModelItem * item = m_items.itemByActiveConnection(active);
......
......@@ -57,8 +57,10 @@ private Q_SLOTS:
void addWimaxNsp(const QString& nsp, const QString& device);
void addWirelessNetwork(const QString& ssid, const QString& device);
void connectionUpdated(const QString& connection);
#if WITH_MODEMMANAGERQT
void modemPropertiesChanged(const QString& modem);
void modemSignalQualityChanged(uint signal, const QString& modem);
#endif
void removeActiveConnection(const QString& active);
void removeAvailableConnection(const QString& connection, const QString& device);
void removeConnection(const QString& connection);
......
......@@ -35,8 +35,6 @@
#include <NetworkManagerQt/VpnSetting>
#include <NetworkManagerQt/WirelessSetting>
#include <ModemManagerQt/modemgsmnetworkinterface.h>
#include <KGlobal>
#include <KLocale>
......
......@@ -147,7 +147,7 @@ void Monitor::addDevice(const NetworkManager::Device::Ptr& device)
}else if (device->type() == NetworkManager::Device::Modem) {
NMMonitorDebug() << "Available modem device " << device->interfaceName();
NetworkManager::ModemDevice::Ptr modemDev = device.objectCast<NetworkManager::ModemDevice>();
#if WITH_MODEMMANAGERQT
ModemManager::ModemGsmNetworkInterface::Ptr modemNetwork = modemDev->getModemNetworkIface().objectCast<ModemManager::ModemGsmNetworkInterface>();
if (modemNetwork) {
connect(modemNetwork.data(), SIGNAL(signalQualityChanged(uint)),
......@@ -157,6 +157,7 @@ void Monitor::addDevice(const NetworkManager::Device::Ptr& device)
connect(modemNetwork.data(), SIGNAL(allowedModeChanged(ModemManager::ModemInterface::AllowedMode)),
SLOT(gsmNetworkAllowedModeChanged(ModemManager::ModemInterface::AllowedMode)), Qt::UniqueConnection);
}
#endif
}
connect(device.data(), SIGNAL(availableConnectionAppeared(QString)),
......@@ -352,7 +353,7 @@ void Monitor::deviceRemoved(const QString& device)
NMMonitorDebug() << "Device " << device << " removed";
Q_EMIT removeConnectionsByDevice(device);
}
#if WITH_MODEMMANAGERQT
void Monitor::gsmNetworkAccessTechnologyChanged(ModemManager::ModemInterface::AccessTechnology technology)
{
ModemManager::ModemGsmNetworkInterface * gsmNetwork = qobject_cast<ModemManager::ModemGsmNetworkInterface*>(sender());
......@@ -409,7 +410,7 @@ void Monitor::gsmNetworkSignalQualityChanged(uint signal)
}
}
}
#endif
void Monitor::statusChanged(NetworkManager::Status status)
{
NMMonitorDebug() << "NetworkManager status changed to " << status;
......
......@@ -28,9 +28,9 @@
#include <NetworkManagerQt/VpnConnection>
#include <NetworkManagerQt/WirelessNetwork>
#include <NetworkManagerQt/WirelessDevice>
#if WITH_MODEMMANAGERQT
#include <ModemManagerQt/modeminterface.h>
#endif
class Monitor : public QObject
{
Q_OBJECT
......@@ -53,9 +53,11 @@ private Q_SLOTS:
void connectionUpdated();
void deviceAdded(const QString& device);
void deviceRemoved(const QString& device);
#if WITH_MODEMMANAGERQT
void gsmNetworkAccessTechnologyChanged(ModemManager::ModemInterface::AccessTechnology technology);
void gsmNetworkAllowedModeChanged(ModemManager::ModemInterface::AllowedMode mode);
void gsmNetworkSignalQualityChanged(uint signal);
#endif
void statusChanged(NetworkManager::Status status);
void vpnConnectionStateChanged(NetworkManager::VpnConnection::State state, NetworkManager::VpnConnection::StateChangeReason reason);
void wimaxNspAppeared(const QString& nsp);
......@@ -76,9 +78,11 @@ Q_SIGNALS:
void addWimaxNsp(const QString& nsp, const QString& device);
void addWirelessNetwork(const QString& network, const QString& device);
void connectionUpdated(const QString& connection);
#if WITH_MODEMMANAGERQT
void modemAccessTechnologyChanged(const QString& modem);
void modemAllowedModeChanged(const QString& modem);
void modemSignalQualityChanged(uint signal, const QString & modem);
#endif
void removeActiveConnection(const QString& active);
void removeAvailableConnection(const QString& connection, const QString& uni);
void removeConnectionsByDevice(const QString& udi);
......
......@@ -77,9 +77,11 @@ ConnectionEditor::ConnectionEditor(QWidget* parent, Qt::WindowFlags flags):
action = new QAction(i18n("InfiniBand"), this);
action->setData(NetworkManager::ConnectionSettings::Infiniband);
m_menu->addAction(action);
#if WITH_MODEMMANAGERQT
action = new QAction(i18n("Mobile Broadband..."), this);
action->setData(NetworkManager::ConnectionSettings::Gsm);
m_menu->addAction(action);
#endif
action = new QAction(i18n("Wired"), this);
action->setData(NetworkManager::ConnectionSettings::Wired);
action->setProperty("shared", false);
......@@ -334,6 +336,7 @@ void ConnectionEditor::addConnection(QAction* action)
ConnectionSettings::ConnectionType type = static_cast<ConnectionSettings::ConnectionType>(action->data().toUInt());
if (type == NetworkManager::ConnectionSettings::Gsm) { // launch the mobile broadband wizard, both gsm/cdma
#if WITH_MODEMMANAGERQT
QWeakPointer<MobileConnectionWizard> wizard = new MobileConnectionWizard(NetworkManager::ConnectionSettings::Unknown, this);
if (wizard.data()->exec() == QDialog::Accepted && wizard.data()->getError() == MobileProviders::Success) {
qDebug() << "Mobile broadband wizard finished:" << wizard.data()->type() << wizard.data()->args();
......@@ -343,6 +346,7 @@ void ConnectionEditor::addConnection(QAction* action)
if (wizard) {
wizard.data()->deleteLater();
}
#endif
} else {
bool shared = false;
if (type == ConnectionSettings::Wired || type == ConnectionSettings::Wireless) {
......
set(kded_networkmanagement_SRCS
notification.cpp
passworddialog.cpp
secretagent.cpp
service.cpp
pindialog.cpp
modemmonitor.cpp
bluetoothmonitor.cpp
notification.cpp
passworddialog.cpp
secretagent.cpp
service.cpp
bluetoothmonitor.cpp
)
kde4_add_ui_files(kded_networkmanagement_SRCS
......@@ -13,6 +11,16 @@ kde4_add_ui_files(kded_networkmanagement_SRCS
pinwidget.ui
)
if (WITH_MODEMMANAGERQT)
set(kded_networkmanagement_SRCS
modemmonitor.cpp
pindialog.cpp
)
kde4_add_ui_files(kded_networkmanagement_SRCS
pinwidget.ui
)
endif()
kde4_add_plugin(kded_networkmanagement ${kded_networkmanagement_SRCS})
target_link_libraries(kded_networkmanagement
......
......@@ -60,8 +60,10 @@ void BluetoothMonitor::addBluetoothConnection(const QString& bdAddr, const QStri
mBdaddr = bdAddr;
mService = service.toLower();
if (mService == "dun") {
#if WITH_MODEMMANAGERQT
connect(ModemManager::notifier(), SIGNAL(modemAdded(QString)),
SLOT(modemAdded(QString)));
#endif
}
init();
}
......@@ -212,7 +214,7 @@ void BluetoothMonitor::init()
mDunDevice = reply.value();
}
#if WITH_MODEMMANAGERQT
void BluetoothMonitor::modemAdded(const QString &udi)
{
qDebug() << "Modem added" << udi;
......@@ -304,3 +306,4 @@ void BluetoothMonitor::modemAdded(const QString &udi)
}
}
}
#endif
......@@ -22,11 +22,11 @@
#ifndef PLASMA_NM_BLUETOOTH_MONITOR_H
#define PLASMA_NM_BLUETOOTH_MONITOR_H
#if WITH_MODEMMANAGERQT
#include "../lib/mobileconnectionwizard.h"
#include <QDBusObjectPath>
#include <ModemManagerQt/manager.h>
#endif
#include <QDBusObjectPath>
class BluetoothMonitor: public QObject
{
......@@ -40,13 +40,17 @@ public Q_SLOTS:
Q_SCRIPTABLE void addBluetoothConnection(const QString & bdAddr, const QString & service);
private Q_SLOTS:
void init();
#if WITH_MODEMMANAGERQT
void modemAdded(const QString &udi);
#endif
private:
QString mBdaddr;
QString mService;
QString mDunDevice;
QString mDevicePath;
QString mDeviceName;
#if WITH_MODEMMANAGERQT
QWeakPointer<MobileConnectionWizard> mobileConnectionWizard;
#endif
};
#endif
......@@ -26,7 +26,9 @@
#include "secretagent.h"
#include "notification.h"
#if WITH_MODEMMANAGERQT
#include "modemmonitor.h"
#endif
#include "bluetoothmonitor.h"
#include <QDBusMetaType>
......@@ -49,7 +51,9 @@ NetworkManagementService::NetworkManagementService(QObject * parent, const QVari
d->agent = new SecretAgent(this);
new Notification(this);
#if WITH_MODEMMANAGERQT
new ModemMonitor(this);
#endif
new BluetoothMonitor(this);
}
......
......@@ -2,13 +2,18 @@ set(plasmanetworkmanagement-internal_SRCS
settingwidget.cpp
vpnuiplugin.cpp
uiutils.cpp
mobileproviders.cpp
mobileconnectionwizard.cpp
hwaddrcombobox.cpp
ssidcombobox.cpp
bssidcombobox.cpp
)
if (WITH_MODEMMANAGERQT)
set(plasmanetworkmanagement-internal_SRCS
mobileproviders.cpp
mobileconnectionwizard.cpp
)
endif()
kde4_add_library(plasmanetworkmanagement-internal SHARED ${plasmanetworkmanagement-internal_SRCS})
target_link_libraries(plasmanetworkmanagement-internal NetworkManagerQt ModemManagerQt ${KDE4_SOLID_LIBS} ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS} ${QT_QTXML_LIBRARY} ${QT_QTNETWORK_LIBRARY})
......
......@@ -557,7 +557,7 @@ QString UiUtils::wirelessBandToString(NetworkManager::WirelessSetting::Frequency
return QString();
}
#if WITH_MODEMMANAGERQT
QString UiUtils::convertTypeToString(const ModemManager::ModemInterface::Type type)
{
switch (type) {
......@@ -623,7 +623,7 @@ QString UiUtils::convertAccessTechnologyToString(const ModemManager::ModemInterf
return i18nc("Unknown cellular access technology","Unknown");
}
#endif
QString UiUtils::convertNspTypeToString(WimaxNsp::NetworkType type)
{
switch (type) {
......@@ -832,9 +832,9 @@ QString UiUtils::bluetoothDetails(const BluetoothDevice::Ptr& btDevice, const QS
QString UiUtils::modemDetails(const ModemDevice::Ptr& modemDevice, const QStringList& keys)
{
#if WITH_MODEMMANAGERQT
QString format = "<tr><td align=\"right\" width=\"50%\"><b>%1</b></td><td align=\"left\" width=\"50%\">&nbsp;%2</td></tr>";
QString details;
ModemManager::ModemGsmNetworkInterface::Ptr modemNetwork = modemDevice->getModemNetworkIface().objectCast<ModemManager::ModemGsmNetworkInterface>();
foreach (const QString& key, keys) {
......@@ -882,6 +882,11 @@ QString UiUtils::modemDetails(const ModemDevice::Ptr& modemDevice, const QString
}
return details;
#else
Q_UNUSED(modemDevice)
Q_UNUSED(keys)
return QString();
#endif
}
QString UiUtils::vpnDetails(const VpnConnection::Ptr& vpnConnection, const VpnSetting::Ptr& vpnSetting, const QStringList& keys)
......
......@@ -150,11 +150,12 @@ public:
* @return A string representation
*/
static QString wirelessBandToString(NetworkManager::WirelessSetting::FrequencyBand band);
#if WITH_MODEMMANAGERQT
static QString convertTypeToString(const ModemManager::ModemInterface::Type type);
static QString convertBandToString(const ModemManager::ModemInterface::Band band);
static QString convertAllowedModeToString(const ModemManager::ModemInterface::AllowedMode mode);
static QString convertAccessTechnologyToString(const ModemManager::ModemInterface::AccessTechnology tech);
#endif
static NetworkManager::ModemDevice::Capability modemSubType(NetworkManager::ModemDevice::Capabilities modemCaps);
static QString convertNspTypeToString(NetworkManager::WimaxNsp::NetworkType type);
......
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