NetworkSetup: Add stats and wifi network name
* Add ability for fSettings to pass on network stats * Show KB Sent / Received for interface * Drop the wireless / wired tab name. (we are going to need another tab for wifi) * Add wifi network name to connection field if interface is wifi.
This commit is contained in:
@@ -22,6 +22,8 @@
|
|||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
#include <TextControl.h>
|
#include <TextControl.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
#undef B_TRANSLATION_CONTEXT
|
#undef B_TRANSLATION_CONTEXT
|
||||||
#define B_TRANSLATION_CONTEXT "IntefaceHardwareView"
|
#define B_TRANSLATION_CONTEXT "IntefaceHardwareView"
|
||||||
@@ -57,7 +59,19 @@ InterfaceHardwareView::InterfaceHardwareView(BRect frame,
|
|||||||
fLinkSpeedField = new BStringView("link speed field", "");
|
fLinkSpeedField = new BStringView("link speed field", "");
|
||||||
fLinkSpeedField->SetExplicitMinSize(BSize(minimumWidth, B_SIZE_UNSET));
|
fLinkSpeedField->SetExplicitMinSize(BSize(minimumWidth, B_SIZE_UNSET));
|
||||||
|
|
||||||
Revert();
|
// TODO: These metrics may be better in a BScrollView?
|
||||||
|
BStringView* linkTx = new BStringView("tx label",
|
||||||
|
B_TRANSLATE("Sent:"));
|
||||||
|
linkTx->SetAlignment(B_ALIGN_RIGHT);
|
||||||
|
fLinkTxField = new BStringView("tx field", "");
|
||||||
|
fLinkTxField ->SetExplicitMinSize(BSize(minimumWidth, B_SIZE_UNSET));
|
||||||
|
BStringView* linkRx = new BStringView("rx label",
|
||||||
|
B_TRANSLATE("Received:"));
|
||||||
|
linkRx->SetAlignment(B_ALIGN_RIGHT);
|
||||||
|
fLinkRxField = new BStringView("rx field", "");
|
||||||
|
fLinkRxField ->SetExplicitMinSize(BSize(minimumWidth, B_SIZE_UNSET));
|
||||||
|
|
||||||
|
Update();
|
||||||
// Populate the fields
|
// Populate the fields
|
||||||
|
|
||||||
BLayoutBuilder::Group<>(this)
|
BLayoutBuilder::Group<>(this)
|
||||||
@@ -68,6 +82,10 @@ InterfaceHardwareView::InterfaceHardwareView(BRect frame,
|
|||||||
.Add(fMacAddressField, 1, 1)
|
.Add(fMacAddressField, 1, 1)
|
||||||
.Add(linkSpeed, 0, 2)
|
.Add(linkSpeed, 0, 2)
|
||||||
.Add(fLinkSpeedField, 1, 2)
|
.Add(fLinkSpeedField, 1, 2)
|
||||||
|
.Add(linkTx, 0, 3)
|
||||||
|
.Add(fLinkTxField, 1, 3)
|
||||||
|
.Add(linkRx, 0, 4)
|
||||||
|
.Add(fLinkRxField, 1, 4)
|
||||||
.End()
|
.End()
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
|
.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
|
||||||
@@ -106,11 +124,27 @@ InterfaceHardwareView::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
status_t
|
status_t
|
||||||
InterfaceHardwareView::Revert()
|
InterfaceHardwareView::Revert()
|
||||||
|
{
|
||||||
|
Update();
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
InterfaceHardwareView::Update()
|
||||||
{
|
{
|
||||||
// Populate fields with current settings
|
// Populate fields with current settings
|
||||||
if (fSettings->HasLink())
|
if (fSettings->HasLink()) {
|
||||||
|
if (fSettings->IsWireless()) {
|
||||||
|
BString network = fSettings->WirelessNetwork();
|
||||||
|
network.Prepend(" (");
|
||||||
|
network.Prepend(B_TRANSLATE("connected"));
|
||||||
|
network.Append(")");
|
||||||
|
fStatusField->SetText(network.String());
|
||||||
|
} else {
|
||||||
fStatusField->SetText(B_TRANSLATE("connected"));
|
fStatusField->SetText(B_TRANSLATE("connected"));
|
||||||
else
|
}
|
||||||
|
} else
|
||||||
fStatusField->SetText(B_TRANSLATE("disconnected"));
|
fStatusField->SetText(B_TRANSLATE("disconnected"));
|
||||||
|
|
||||||
fMacAddressField->SetText(fSettings->HardwareAddress());
|
fMacAddressField->SetText(fSettings->HardwareAddress());
|
||||||
@@ -118,6 +152,18 @@ InterfaceHardwareView::Revert()
|
|||||||
// TODO : Find how to get link speed
|
// TODO : Find how to get link speed
|
||||||
fLinkSpeedField->SetText("100 Mb/s");
|
fLinkSpeedField->SetText("100 Mb/s");
|
||||||
|
|
||||||
|
// Update Link stats
|
||||||
|
ifreq_stats stats;
|
||||||
|
char buffer[100];
|
||||||
|
fSettings->Stats(&stats);
|
||||||
|
snprintf(buffer, sizeof(buffer), B_TRANSLATE("%" B_PRIu64 " KBytes"),
|
||||||
|
stats.send.bytes / 1024);
|
||||||
|
fLinkTxField->SetText(buffer);
|
||||||
|
|
||||||
|
snprintf(buffer, sizeof(buffer), B_TRANSLATE("%" B_PRIu64 " KBytes"),
|
||||||
|
stats.receive.bytes / 1024);
|
||||||
|
fLinkRxField->SetText(buffer);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ public:
|
|||||||
status_t Save();
|
status_t Save();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
status_t Update();
|
||||||
|
|
||||||
void _EnableFields(bool enabled);
|
void _EnableFields(bool enabled);
|
||||||
|
|
||||||
NetworkSettings* fSettings;
|
NetworkSettings* fSettings;
|
||||||
@@ -38,6 +40,8 @@ private:
|
|||||||
BStringView* fStatusField;
|
BStringView* fStatusField;
|
||||||
BStringView* fMacAddressField;
|
BStringView* fMacAddressField;
|
||||||
BStringView* fLinkSpeedField;
|
BStringView* fLinkSpeedField;
|
||||||
|
BStringView* fLinkTxField;
|
||||||
|
BStringView* fLinkRxField;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -104,14 +104,9 @@ InterfaceWindow::_PopulateTabs()
|
|||||||
fTabHardwareView = new InterfaceHardwareView(frame,
|
fTabHardwareView = new InterfaceHardwareView(frame,
|
||||||
fNetworkSettings);
|
fNetworkSettings);
|
||||||
fTabView->AddTab(fTabHardwareView, hardwareTab);
|
fTabView->AddTab(fTabHardwareView, hardwareTab);
|
||||||
|
hardwareTab->SetLabel(B_TRANSLATE("Interface"));
|
||||||
|
|
||||||
if (fNetworkSettings->IsEthernet())
|
for (int index = 0; index < MAX_PROTOCOLS; index++) {
|
||||||
hardwareTab->SetLabel(B_TRANSLATE("Wired"));
|
|
||||||
else
|
|
||||||
hardwareTab->SetLabel(B_TRANSLATE("Wireless"));
|
|
||||||
|
|
||||||
for (int index = 0; index < MAX_PROTOCOLS; index++)
|
|
||||||
{
|
|
||||||
if (supportedFamilies[index].present) {
|
if (supportedFamilies[index].present) {
|
||||||
int inet_id = supportedFamilies[index].inet_id;
|
int inet_id = supportedFamilies[index].inet_id;
|
||||||
fTabIPView[inet_id] = new InterfaceAddressView(frame,
|
fTabIPView[inet_id] = new InterfaceAddressView(frame,
|
||||||
|
|||||||
@@ -83,6 +83,9 @@ public:
|
|||||||
|
|
||||||
const char* Name() { return fName.String(); }
|
const char* Name() { return fName.String(); }
|
||||||
const char* Domain() { return fDomain.String(); }
|
const char* Domain() { return fDomain.String(); }
|
||||||
|
status_t Stats(ifreq_stats* ptr)
|
||||||
|
{ return fNetworkInterface->GetStats(*ptr); }
|
||||||
|
|
||||||
bool IsDisabled() { return fDisabled; }
|
bool IsDisabled() { return fDisabled; }
|
||||||
|
|
||||||
bool IsWireless() {
|
bool IsWireless() {
|
||||||
|
|||||||
Reference in New Issue
Block a user