Index: sources/view/VNetworkModel.cpp =================================================================== diff -u -r2085962f7bd0a2239ee5c857928a11d5e38fe0a2 -rc77365fa76422bc2150e58d483c446325b50f4b8 --- sources/view/VNetworkModel.cpp (.../VNetworkModel.cpp) (revision 2085962f7bd0a2239ee5c857928a11d5e38fe0a2) +++ sources/view/VNetworkModel.cpp (.../VNetworkModel.cpp) (revision c77365fa76422bc2150e58d483c446325b50f4b8) @@ -16,22 +16,32 @@ { // incoming connect(&_WifiInterface, SIGNAL(didAddNetwork(const Network)), - this, SLOT(doAddNetwork(const Network))); + this, SLOT(doAddNetwork(const Network)), Qt::QueuedConnection); connect(&_WifiInterface, SIGNAL(didScanStatusChanged(const bool)), - this, SLOT(onScanStatusChanged(const bool))); + this, SLOT(onScanStatusChanged(const bool)), Qt::QueuedConnection); connect(&_WifiInterface, SIGNAL(didConnectToNetwork(const Network)), - this, SLOT(onConnectedToNetwork(const Network))); + this, SLOT(onConnectedToNetwork(const Network)), Qt::QueuedConnection); + connect(&_WifiInterface, SIGNAL(didDisconnectNetwork(Network)), + this, SLOT(onDisconnectedNetwork(const Network)), Qt::QueuedConnection); + + connect(&_WifiInterface, SIGNAL(didError(const QString)), + this, SLOT(onError(const QString)), Qt::QueuedConnection); + // outgoing connect(this, SIGNAL(didScan()), &_WifiInterface, SLOT(doScan())); - // outgoing connect(this, SIGNAL(didJoinNetwork(const Network, const QString)), &_WifiInterface, SLOT(doJoinNetwork(const Network, const QString))); + connect(this, SIGNAL(didDisconnectNetwork(Network)), + &_WifiInterface, SLOT(doDisconnectNetwork(const Network))); + + connect(this, SIGNAL(didRequestIPSettings()), + &_WifiInterface, SLOT(doRequestIPSettings())); } /*! @@ -181,6 +191,24 @@ } /*! + * \brief VNetworkModel::doDisconnectNetwork + * Handles request from qml to disconnect from a network + * \param vMacAddress - (QString) the mac address of the network to disconnect from + */ +void VNetworkModel::doDisconnectNetwork(const QString &vMacAddress) +{ + for (const Network &network : _networks) + { + if (network.macAddress() == vMacAddress) + { + status(tr("Disconnecting from %1...").arg(network.ssid())); + emit didDisconnectNetwork(network); + return; + } + } +} + +/*! * \brief VNetworkModel::onConnectedToNetwork * Called when we have connected to a network. * \param vNetwork - (Network) the network we have connected to @@ -194,3 +222,33 @@ dns(vNetwork.ipSettings().mDns); status(tr("Connected to %1.").arg(vNetwork.ssid())); } + +/*! + * \brief VNetworkModel::onDisconnectedNetwork + * Called when we have disconnected from a network. + * \param vNetwork - (Network) the network we have disconnected from + */ +void VNetworkModel::onDisconnectedNetwork(const Network &vNetwork) +{ + LOG_DEBUG(QString("Disconnected from %1.").arg(vNetwork.ssid())); + status(tr("Disconnected from %1.").arg(vNetwork.ssid())); +} + +/*! + * \brief VNetworkModel::doRequestIPSettings + * Called when QML requests the IP settings + */ +void VNetworkModel::doRequestIPSettings() +{ + emit didRequestIPSettings(); +} + +/*! + * \brief VNetworkModel::onError + * Called when the wifi interface emits an error + * \param vMessage - (QString) the error message + */ +void VNetworkModel::onError(const QString &vMessage) +{ + status(vMessage); +}