Bug 1905259 - Add updated thumbs up and down icons, add CSS animation to active state...
[gecko.git] / netwerk / wifi / nsWifiAccessPoint.h
blob3f83b2c0c0e02fc9dd92e7cfd31beb18e88ecd37
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef __nsWifiAccessPoint__
6 #define __nsWifiAccessPoint__
8 #include <algorithm>
9 #include "nsWifiMonitor.h"
10 #include "nsIWifiAccessPoint.h"
12 #include "nsString.h"
13 #include "nsCOMArray.h"
14 #include "mozilla/ArrayUtils.h" // ArrayLength
15 #include "mozilla/Attributes.h"
16 #include "mozilla/Sprintf.h"
18 class nsWifiAccessPoint final : public nsIWifiAccessPoint {
19 ~nsWifiAccessPoint() = default;
21 public:
22 NS_DECL_THREADSAFE_ISUPPORTS
23 NS_DECL_NSIWIFIACCESSPOINT
25 nsWifiAccessPoint();
27 char mMac[18]{0};
28 int mSignal;
29 char mSsid[33]{0};
30 int mSsidLen;
32 void setSignal(int signal) { mSignal = signal; }
34 void setMacRaw(const char* aString) {
35 memcpy(mMac, aString, mozilla::ArrayLength(mMac));
38 void setMac(const unsigned char mac_as_int[6]) {
39 // mac_as_int is big-endian. Write in byte chunks.
40 // Format is XX-XX-XX-XX-XX-XX.
42 const unsigned char holder[6] = {0};
43 if (!mac_as_int) {
44 mac_as_int = holder;
47 static const char* kMacFormatString = ("%02x-%02x-%02x-%02x-%02x-%02x");
49 SprintfLiteral(mMac, kMacFormatString, mac_as_int[0], mac_as_int[1],
50 mac_as_int[2], mac_as_int[3], mac_as_int[4], mac_as_int[5]);
52 mMac[17] = 0;
55 void setSSIDRaw(const char* aSSID, size_t len) {
56 mSsidLen = std::min(len, mozilla::ArrayLength(mSsid));
57 memcpy(mSsid, aSSID, mSsidLen);
60 void setSSID(const char* aSSID, unsigned long len) {
61 if (aSSID && (len < sizeof(mSsid))) {
62 strncpy(mSsid, aSSID, len);
63 mSsid[len] = 0;
64 mSsidLen = len;
65 } else {
66 mSsid[0] = 0;
67 mSsidLen = 0;
71 // 3-value compare for nsWifiAccessPoint
72 int Compare(const nsWifiAccessPoint& o) const;
74 bool operator==(const nsWifiAccessPoint& o) const;
75 bool operator!=(const nsWifiAccessPoint& o) const { return !(*this == o); }
78 #endif