NetworkStatus: show authentication mode in WiFi list. #9666

* now WirelessNetworkMenuItem appends authentication mode to its label

Signed-off-by: Matt Madia <[email protected]>
This commit is contained in:
Przemysław Buczkowski
2013-11-10 11:57:09 -05:00
committed by Matt Madia
parent f05b8e3873
commit 5bb799c2d3
4 changed files with 42 additions and 10 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ resource app_version {
internal = 0,
short_info = "NetworkStatus",
long_info = "NetworkStatus ©2007-2009 Haiku"
long_info = "NetworkStatus ©2007-2013 Haiku"
};
resource vector_icon {
+1 -2
View File
@@ -414,8 +414,7 @@ NetworkStatusView::MouseDown(BPoint point)
message->AddFlat("address", &network.address);
BMenuItem* item = new WirelessNetworkMenuItem(network.name,
network.signal_strength,
(network.flags & B_NETWORK_IS_ENCRYPTED) != 0, message);
network.signal_strength, network.authentication_mode, message);
menu->AddItem(item);
if (associated.find(network.address) != associated.end())
item->SetMarked(true);
@@ -6,16 +6,29 @@
#include "WirelessNetworkMenuItem.h"
#include <Catalog.h>
#include <NetworkDevice.h>
#include <String.h>
#include "RadioView.h"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "WirelessNetworkMenuItem"
WirelessNetworkMenuItem::WirelessNetworkMenuItem(const char* name,
int32 signalQuality, bool encrypted, BMessage* message)
int32 signalQuality, int32 authenticationMode, BMessage* message)
:
BMenuItem(name, message),
fQuality(signalQuality),
fIsEncrypted(encrypted)
fQuality(signalQuality)
{
// Append authentication mode to label
BString label = B_TRANSLATE("%name% (%authenticationMode%)");
label.Replace("%name%", name, 1);
label.Replace("%authenticationMode%",
AuthenticationName(authenticationMode), 1);
SetLabel(label.String());
}
@@ -30,6 +43,28 @@ WirelessNetworkMenuItem::SetSignalQuality(int32 quality)
fQuality = quality;
}
BString
WirelessNetworkMenuItem::AuthenticationName(int32 mode)
{
switch (mode) {
default:
case B_NETWORK_AUTHENTICATION_NONE:
return B_TRANSLATE_CONTEXT("open", "Open network");
break;
case B_NETWORK_AUTHENTICATION_WEP:
return B_TRANSLATE_CONTEXT("WEP", "WEP protected network");
break;
case B_NETWORK_AUTHENTICATION_WPA:
return B_TRANSLATE_CONTEXT("WPA", "WPA protected network");
break;
case B_NETWORK_AUTHENTICATION_WPA2:
return B_TRANSLATE_CONTEXT("WPA2", "WPA2 protected network");
break;
case B_NETWORK_AUTHENTICATION_EAP:
return B_TRANSLATE_CONTEXT("EAP", "EAP protected network");
break;
}
}
void
WirelessNetworkMenuItem::DrawContent()
@@ -12,15 +12,14 @@
class WirelessNetworkMenuItem : public BMenuItem {
public:
WirelessNetworkMenuItem(const char* name,
int32 signalQuality, bool encrypted,
int32 signalQuality, int32 authenticationMode,
BMessage* message);
virtual ~WirelessNetworkMenuItem();
void SetSignalQuality(int32 quality);
int32 SignalQuality() const
{ return fQuality; }
bool IsEncrypted() const
{ return fIsEncrypted; }
BString AuthenticationName(int32 mode);
protected:
virtual void DrawContent();
@@ -30,7 +29,6 @@ protected:
private:
int32 fQuality;
bool fIsEncrypted;
};