commit 3da645d67eb02fce86823179c4ebdbf1ef67fba6
Author: Przemysław Buczkowski <przemub@przemub.pl>
Date: Fri Nov 8 22:54:33 2013 +0100
NetworkStatus: show authentication mode in WiFi list (bug #9666)
* now WirelessNetworkMenuItem appends authentication mode to its label
Signed-off-by: Przemysław Buczkowski <przemub@przemub.pl>
diff --git a/src/apps/networkstatus/NetworkStatus.rdef b/src/apps/networkstatus/NetworkStatus.rdef
index c2d9389..d78e346 100644
a
|
b
|
resource app_version {
|
14 | 14 | internal = 0, |
15 | 15 | |
16 | 16 | short_info = "NetworkStatus", |
17 | | long_info = "NetworkStatus ©2007-2009 Haiku" |
| 17 | long_info = "NetworkStatus ©2007-2013 Haiku" |
18 | 18 | }; |
19 | 19 | |
20 | 20 | resource vector_icon { |
diff --git a/src/apps/networkstatus/NetworkStatusView.cpp b/src/apps/networkstatus/NetworkStatusView.cpp
index 45b5a4a..4c338dd 100644
a
|
b
|
NetworkStatusView::MouseDown(BPoint point)
|
472 | 472 | message->AddFlat("address", &network.address); |
473 | 473 | |
474 | 474 | BMenuItem* item = new WirelessNetworkMenuItem(network.name, |
475 | | network.signal_strength, |
476 | | (network.flags & B_NETWORK_IS_ENCRYPTED) != 0, message); |
| 475 | network.signal_strength, network.authentication_mode, message); |
477 | 476 | menu->AddItem(item); |
478 | 477 | if (associated.find(network.address) != associated.end()) |
479 | 478 | item->SetMarked(true); |
diff --git a/src/apps/networkstatus/WirelessNetworkMenuItem.cpp b/src/apps/networkstatus/WirelessNetworkMenuItem.cpp
index 043f293..0ee6345 100644
a
|
b
|
|
6 | 6 | |
7 | 7 | #include "WirelessNetworkMenuItem.h" |
8 | 8 | |
| 9 | #include <Catalog.h> |
| 10 | #include <NetworkDevice.h> |
| 11 | #include <String.h> |
| 12 | |
9 | 13 | #include "RadioView.h" |
10 | 14 | |
| 15 | #undef B_TRANSLATION_CONTEXT |
| 16 | #define B_TRANSLATION_CONTEXT "WirelessNetworkMenuItem" |
| 17 | |
11 | 18 | |
12 | 19 | WirelessNetworkMenuItem::WirelessNetworkMenuItem(const char* name, |
13 | | int32 signalQuality, bool encrypted, BMessage* message) |
| 20 | int32 signalQuality, int32 authenticationMode, BMessage* message) |
14 | 21 | : |
15 | 22 | BMenuItem(name, message), |
16 | | fQuality(signalQuality), |
17 | | fIsEncrypted(encrypted) |
| 23 | fQuality(signalQuality) |
18 | 24 | { |
| 25 | // Append authentication mode to label |
| 26 | BString label = B_TRANSLATE("%name% (%authenticationMode%)"); |
| 27 | label.Replace("%name%", name, 1); |
| 28 | label.Replace("%authenticationMode%", |
| 29 | AuthenticationName(authenticationMode), 1); |
| 30 | |
| 31 | SetLabel(label.String()); |
19 | 32 | } |
20 | 33 | |
21 | 34 | |
… |
… |
WirelessNetworkMenuItem::SetSignalQuality(int32 quality)
|
30 | 43 | fQuality = quality; |
31 | 44 | } |
32 | 45 | |
| 46 | BString |
| 47 | WirelessNetworkMenuItem::AuthenticationName(int32 mode) |
| 48 | { |
| 49 | switch (mode) { |
| 50 | default: |
| 51 | case B_NETWORK_AUTHENTICATION_NONE: |
| 52 | return B_TRANSLATE_CONTEXT("open", "Open network"); |
| 53 | break; |
| 54 | case B_NETWORK_AUTHENTICATION_WEP: |
| 55 | return B_TRANSLATE_CONTEXT("WEP", "WEP protected network"); |
| 56 | break; |
| 57 | case B_NETWORK_AUTHENTICATION_WPA: |
| 58 | return B_TRANSLATE_CONTEXT("WPA", "WPA protected network"); |
| 59 | break; |
| 60 | case B_NETWORK_AUTHENTICATION_WPA2: |
| 61 | return B_TRANSLATE_CONTEXT("WPA2", "WPA2 protected network"); |
| 62 | break; |
| 63 | case B_NETWORK_AUTHENTICATION_EAP: |
| 64 | return B_TRANSLATE_CONTEXT("EAP", "EAP protected network"); |
| 65 | break; |
| 66 | } |
| 67 | } |
33 | 68 | |
34 | 69 | void |
35 | 70 | WirelessNetworkMenuItem::DrawContent() |
diff --git a/src/apps/networkstatus/WirelessNetworkMenuItem.h b/src/apps/networkstatus/WirelessNetworkMenuItem.h
index 83e18f9..4e04817 100644
a
|
b
|
|
12 | 12 | class WirelessNetworkMenuItem : public BMenuItem { |
13 | 13 | public: |
14 | 14 | WirelessNetworkMenuItem(const char* name, |
15 | | int32 signalQuality, bool encrypted, |
| 15 | int32 signalQuality, int32 authenticationMode, |
16 | 16 | BMessage* message); |
17 | 17 | virtual ~WirelessNetworkMenuItem(); |
18 | 18 | |
19 | 19 | void SetSignalQuality(int32 quality); |
20 | 20 | int32 SignalQuality() const |
21 | 21 | { return fQuality; } |
22 | | bool IsEncrypted() const |
23 | | { return fIsEncrypted; } |
| 22 | BString AuthenticationName(int32 mode); |
24 | 23 | |
25 | 24 | protected: |
26 | 25 | virtual void DrawContent(); |
… |
… |
protected:
|
30 | 29 | |
31 | 30 | private: |
32 | 31 | int32 fQuality; |
33 | | bool fIsEncrypted; |
34 | 32 | }; |
35 | 33 | |
36 | 34 | |