Changeset View
Changeset View
Standalone View
Standalone View
src/utils.cpp
Show All 13 Lines | 1 | /* | |||
---|---|---|---|---|---|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | Lesser General Public License for more details. | 16 | Lesser General Public License for more details. | ||
17 | 17 | | |||
18 | You should have received a copy of the GNU Lesser General Public | 18 | You should have received a copy of the GNU Lesser General Public | ||
19 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | 19 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | #include <QRegularExpression> | ||||
23 | | ||||
22 | #include "utils.h" | 24 | #include "utils.h" | ||
23 | #include "time.h" | 25 | #include "time.h" | ||
24 | 26 | | |||
25 | QHostAddress NetworkManager::ipv6AddressAsHostAddress(const QByteArray &address) | 27 | QHostAddress NetworkManager::ipv6AddressAsHostAddress(const QByteArray &address) | ||
26 | { | 28 | { | ||
27 | // Q_ASSERT(address.size() == 16); | 29 | // Q_ASSERT(address.size() == 16); | ||
28 | Q_IPV6ADDR tmp; | 30 | Q_IPV6ADDR tmp; | ||
29 | for (int i = 0; i < 16; ++i) { | 31 | for (int i = 0; i < 16; ++i) { | ||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 72 | Q_FOREACH (const QString & macPart, macStringList) { | |||
71 | ba[i++] = macPart.toUInt(nullptr, 16); | 73 | ba[i++] = macPart.toUInt(nullptr, 16); | ||
72 | } | 74 | } | ||
73 | } | 75 | } | ||
74 | return ba; | 76 | return ba; | ||
75 | } | 77 | } | ||
76 | 78 | | |||
77 | bool NetworkManager::macAddressIsValid(const QString &macAddress) | 79 | bool NetworkManager::macAddressIsValid(const QString &macAddress) | ||
78 | { | 80 | { | ||
79 | QRegExp macAddressCheck = QRegExp("([a-fA-F0-9][a-fA-F0-9]:){5}[0-9a-fA-F][0-9a-fA-F]"); | 81 | QRegularExpression macAddressCheck(QStringLiteral("([a-fA-F0-9][a-fA-F0-9]:){5}[0-9a-fA-F][0-9a-fA-F]")); | ||
80 | 82 | | |||
81 | return macAddress.contains(macAddressCheck); | 83 | return macAddressCheck.match(macAddress).hasMatch(); | ||
82 | } | 84 | } | ||
83 | 85 | | |||
84 | bool NetworkManager::macAddressIsValid(const QByteArray &macAddress) | 86 | bool NetworkManager::macAddressIsValid(const QByteArray &macAddress) | ||
85 | { | 87 | { | ||
86 | return macAddressIsValid(macAddressAsString(macAddress)); | 88 | return macAddressIsValid(macAddressAsString(macAddress)); | ||
87 | } | 89 | } | ||
88 | 90 | | |||
89 | int NetworkManager::findChannel(int freq) | 91 | int NetworkManager::findChannel(int freq) | ||
▲ Show 20 Lines • Show All 498 Lines • Show Last 20 Lines |