Index: sources/view/VNetworkModel.cpp =================================================================== diff -u -rd71990c79c75c613d781890c6f77505d409d6c64 -r091bc0425b84f094cbd863865a5edac2477208eb --- sources/view/VNetworkModel.cpp (.../VNetworkModel.cpp) (revision d71990c79c75c613d781890c6f77505d409d6c64) +++ sources/view/VNetworkModel.cpp (.../VNetworkModel.cpp) (revision 091bc0425b84f094cbd863865a5edac2477208eb) @@ -34,6 +34,19 @@ connect(&_WifiInterface, SIGNAL(didStatusChanged(const QString)), this, SLOT(onStatusChanged(const QString))); + // incoming - static IP address assignment + connect(&_WifiInterface, SIGNAL(didSetStaticIPAddress()), + this, SLOT(onSetIPAddressSuccess())); + + connect(&_WifiInterface, SIGNAL(didSetGateway()), + this, SLOT(onSetGatewaySuccess())); + + connect(&_WifiInterface, SIGNAL(didSetSubnetMask()), + this, SLOT(onSetSubnetMaskSuccess())); + + connect(&_WifiInterface, SIGNAL(didSetDNS()), + this, SLOT(onSetDNSSuccess())); + // outgoing connect(this, SIGNAL(didScan()), &_WifiInterface, SLOT(doScan())); @@ -47,7 +60,7 @@ connect(this, SIGNAL(didRequestIPSettings()), &_WifiInterface, SLOT(doRequestIPSettings())); - // static IP address assignment + // outgoing - static IP address assignment connect(this, SIGNAL(didRequestSetIPAddress(const QString)), &_WifiInterface, SLOT(doRequestSetIPAddress(const QString))); @@ -199,11 +212,8 @@ */ bool VNetworkModel::doCheckIfConnected(const QString &vMacAddress) { - for (const Network &network : _networks) - { - if (network.macAddress() == vMacAddress && network.status() == Network::CONNECTED) - return true; - } + if (vMacAddress == macAddress()) + return true; return false; } @@ -215,11 +225,7 @@ */ void VNetworkModel::doJoinNetwork(const QString &vMacAddress, const QString &vPassword) { - ipAddress(""); - gateway(""); - subnetMask(""); - dns(""); - ssid(""); + clearSelectedNetwork(); for (const Network &network : _networks) { if (network.macAddress() == vMacAddress) @@ -263,6 +269,7 @@ subnetMask(vNetwork.mIPSettings.mSubnetMask); dns(vNetwork.mIPSettings.mDNS); ssid(vNetwork.ssid()); + macAddress(vNetwork.macAddress()); status(tr("Connected to %1.").arg(vNetwork.ssid())); } @@ -275,6 +282,7 @@ { LOG_DEBUG(QString("VNetworkModel::%1 %2").arg(__FUNCTION__).arg(QThread::currentThread()->objectName())); LOG_DEBUG(QString("Disconnected from %1.").arg(vNetwork.ssid())); + clearSelectedNetwork(); status(tr("Disconnected from %1.").arg(vNetwork.ssid())); } @@ -300,7 +308,7 @@ /*! * \brief VNetworkModel::doSetIPAddress - * \param vIPAddress + * \param vIPAddress (QString) the ip address */ void VNetworkModel::doSetIPAddress(const QString &vIPAddress) { @@ -309,7 +317,7 @@ /*! * \brief VNetworkModel::doSetGateway - * \param vGateway + * \param vGateway (QString) the gateway */ void VNetworkModel::doSetGateway(const QString &vGateway) { @@ -318,7 +326,7 @@ /*! * \brief VNetworkModel::doSetSubnetMask - * \param vSubnetMask + * \param vSubnetMask (QString) the subnet mask */ void VNetworkModel::doSetSubnetMask(const QString &vSubnetMask) { @@ -327,9 +335,59 @@ /*! * \brief VNetworkModel::doSetDNS - * \param vDNS + * \param vDNS (QString) the DNS */ void VNetworkModel::doSetDNS(const QString &vDNS) { emit didRequestSetDNS(vDNS); } + +/*! + * \brief VNetworkModel::clearWifiSettings + * Clears the selected network settings + */ +void VNetworkModel::clearSelectedNetwork() +{ + ipAddress(""); + gateway(""); + subnetMask(""); + dns(""); + ssid(""); + macAddress(""); +} + +/*! + * \brief VNetworkModel::onSetIPAddressSuccess + * Called when the IP address has been set + */ +void VNetworkModel::onSetIPAddressSuccess() +{ + status(tr("Successfully set the IP address.")); +} + +/*! + * \brief VNetworkModel::onSetGatewaySuccess + * Called when the gateway has been set + */ +void VNetworkModel::onSetGatewaySuccess() +{ + status(tr("Successfully set the gateway.")); +} + +/*! + * \brief VNetworkModel::onSetSubnetMaskSuccess + * Called when the subnet mask has been set + */ +void VNetworkModel::onSetSubnetMaskSuccess() +{ + status(tr("Successfully set the subnet mask.")); +} + +/*! + * \brief VNetworkModel::onSetDNSSuccess + * Called when the DNS has been set + */ +void VNetworkModel::onSetDNSSuccess() +{ + status(tr("Successfully set the DNS.")); +}