#pragma once // Qt #include // Project #include "VView.h" /*! * \brief The Network class * Provides abstraction for a wifi network * \details Holds information about the wifi network such as ssid, security, and connection status * */ class Network { public: enum SECURITY_LEVEL { UNSUPPORTED, WEP, WPA_TKIP, WPA_TKIP_AES, WPA_AES, WPA2_AES_PERSONAL, WPA2_AES_ENTERPRISE }; enum SIGNAL_LEVEL { NO_SIGNAL, LVL_1, LVL_2, LVL_3, LVL_4, LVL_5 }; enum STATUS { NOT_CONNECTED, CONNECTING, CONNECTED, DISCONNECTING }; bool operator==(const Network &d1) { if (ssid() == d1.ssid()) return true; return false; } bool operator>(const Network &d1) { if (signalLevel() > d1.signalLevel()) return true; return false; } bool operator<(const Network &d1) { if (signalLevel() < d1.signalLevel()) return true; return false; } QString ssid() const { return _ssid; } void ssid(const QString &vSSID) { _ssid = vSSID; } SECURITY_LEVEL security() const { return _security; } void security(const SECURITY_LEVEL &vSecurity) { _security = vSecurity; } SIGNAL_LEVEL signalLevel() const { return _signalLevel; } void signalLevel(const SIGNAL_LEVEL &vLevel) { _signalLevel = vLevel; } STATUS status() const { return _status; } void status(const STATUS &vStatus) { _status = vStatus; } QString macAddress() const { return _macAddress; } void macAddress(const QString &vMacAddress) { _macAddress = vMacAddress; } SIGNAL_LEVEL convertSignalLevel(int vLevel) { if (vLevel == 0) return NO_SIGNAL; else if (vLevel >= -50) return LVL_5; else if (vLevel >= -60) return LVL_4; else if (vLevel >= -70) return LVL_3; else if (vLevel >= -80) return LVL_2; else if (vLevel >= -90) return LVL_1; return NO_SIGNAL; } explicit Network(const QString &vMacAddress) {_macAddress = vMacAddress; } explicit Network(const QString &vMacAddress, const QString &vSSID, const SECURITY_LEVEL &vSecurityLevel, const STATUS &vStatus, const int &vSignalLevel) { _macAddress = vMacAddress; _ssid = vSSID; _security = vSecurityLevel; _status = vStatus; _signalLevel = convertSignalLevel(vSignalLevel); } private: QString _macAddress; QString _ssid; SECURITY_LEVEL _security = UNSUPPORTED; SIGNAL_LEVEL _signalLevel = NO_SIGNAL; STATUS _status = NOT_CONNECTED; };