/*! \internal \class RoamingMonitor \inpublicgroup QtConnectivityModule \brief This class assists the LAN plugin in the process of manual and automatic roaming from one WLAN to another. The class is based on a WLAN scanner which periodically scans the environment for changes. The monitor can send a signal when it is appropriate to change the network. The configuration of the roaming behavior is done via the LAN plug-in's general configure dialog. The scanner requires a Linux kernel with Wireless Extensions v14 or above. */ RoamingMonitor::RoamingMonitor( QtopiaNetworkConfiguration* cfg, QObject* parent ) :QObject( parent ), configIface( cfg ), activeHop( false ) { // some interfaces need to be up QSettings config(configIface->configFile(), QSettings::IniFormat); const bool scanWhileDown = config.value("Properties/ScanWhileDown", true).toBool(); scanner = new WirelessScan( QNetworkDevice(configIface->configFile()).interfaceName(), scanWhileDown ); connect( scanner, SIGNAL(scanningFinished()), this, SLOT(newScanResults()) ); rescanTimer = new QTimer( this ); connect( rescanTimer, SIGNAL(timeout()), this, SLOT(scanTimeout()) ); const int ident = qHash( configIface->configFile() ); netSpace = new QValueSpaceItem( QString("/Network/Interfaces/%1/NetDevice").arg(ident), this ); deviceName = netSpace->value().toString(); connect( netSpace, SIGNAL(contentsChanged()), this, SLOT(deviceNameChanged()) ); //keep track of signal strength signalProvider = new QSignalSourceProvider( "wlan", QString::number(qHash( configIface->configFile() )), this ); #if WIRELESS_EXT > 11 signalProvider->setAvailability( QSignalSource::NotAvailable ); //polling is bad but there is no alternative to it right now. signalTimer = new QTimer( this ); signalTimer->setInterval( 60000 ); connect( signalTimer, SIGNAL(timeout()), this, SLOT(updateSignalStrength()) ); #else //we need WE 11+ to detect signal strength signalProvider->setAvailability( QSignalSource::Invalid ); #endif }
void Torch::checkDevice() { int res = false; if (!QDBusConnection::systemBus().isConnected()) { qDebug() << "Cannot connect to the D-Bus systemBus" << QDBusConnection::systemBus().lastError().message(); return; } QDBusInterface ssuCall("org.nemo.ssu", "/org/nemo/ssu", "org.nemo.ssu", QDBusConnection::systemBus()); ssuCall.setTimeout(1000); QList<QVariant> args; args.append(2); QDBusMessage ssuCallReply = ssuCall.callWithArgumentList(QDBus::Block, "displayName", args); if (ssuCallReply.type() == QDBusMessage::ErrorMessage) { qDebug() << "Error" << ssuCallReply.errorMessage(); return; } QList<QVariant> outArgs = ssuCallReply.arguments(); if (outArgs.count() == 0) { qDebug() << "Reply is epmty"; return; } qDebug() << "device name is" << outArgs.at(0).toString(); m_deviceName = outArgs.at(0).toString(); if (m_deviceName == "JP-1301") /* The one and only original Jolla phone */ { m_hasBrightness = false; m_controlPath = "/sys/kernel/debug/flash_adp1650/mode"; res = true; } else if (m_deviceName == "onyx") /* OneplusX */ { m_hasBrightness = true; m_controlPath = "/sys/class/leds/led:flash_torch/brightness"; res = true; } else if (m_deviceName == "fp2-sibon") /* Fairphone 2 */ { m_hasBrightness = true; m_controlPath = "/sys/class/leds/led:flash_torch/brightness"; res = true; } else if (m_deviceName == "JP-1601") /* Jolla C */ { m_hasBrightness = true; m_controlPath = "/sys/class/leds/torch-light0/brightness"; res = true; } emit deviceNameChanged(m_deviceName); m_deviceSupported = res; emit deviceSupportedChanged(m_deviceSupported); emit hasBrightnessChanged(m_hasBrightness); }