add InterfaceHardwareView which will show more general hardware information and give somewhere to configure wireless connection settings; add a few hardware calls to NetworkSettings, maybe we just want to pass back BNetworkDevice instead?
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41204 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright 2004-2011 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Alexander von Gluck, [email protected]
|
||||
*/
|
||||
|
||||
|
||||
#include "InterfaceHardwareView.h"
|
||||
#include "NetworkSettings.h"
|
||||
|
||||
#include <LayoutBuilder.h>
|
||||
#include <MenuItem.h>
|
||||
|
||||
|
||||
InterfaceHardwareView::InterfaceHardwareView(BRect frame,
|
||||
NetworkSettings* settings)
|
||||
:
|
||||
BGroupView(B_VERTICAL),
|
||||
fSettings(settings)
|
||||
{
|
||||
SetLayout(new BGroupLayout(B_VERTICAL));
|
||||
|
||||
// TODO : Small graph of throughput?
|
||||
|
||||
// TODO : Use strings instead of TextControls
|
||||
fStatusField = new BTextControl("Status:", NULL, NULL);
|
||||
fStatusField->SetEnabled(false);
|
||||
fMACField = new BTextControl("MAC Address:", NULL, NULL);
|
||||
fMACField->SetEnabled(false);
|
||||
fSpeedField = new BTextControl("Link Speed:", NULL, NULL);
|
||||
fSpeedField->SetEnabled(false);
|
||||
|
||||
RevertFields();
|
||||
// Do the initial field population
|
||||
|
||||
BLayoutBuilder::Group<>(this)
|
||||
.AddGrid()
|
||||
.AddTextControl(fStatusField, 0, 0, B_ALIGN_RIGHT)
|
||||
.AddTextControl(fMACField, 0, 1, B_ALIGN_RIGHT)
|
||||
.AddTextControl(fSpeedField, 0, 2, B_ALIGN_RIGHT)
|
||||
.End()
|
||||
.AddGlue()
|
||||
.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
|
||||
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING);
|
||||
}
|
||||
|
||||
|
||||
InterfaceHardwareView::~InterfaceHardwareView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InterfaceHardwareView::AttachedToWindow()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InterfaceHardwareView::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
default:
|
||||
BView::MessageReceived(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
InterfaceHardwareView::RevertFields()
|
||||
{
|
||||
// Populate fields with current settings
|
||||
if (fSettings->HasLink())
|
||||
fStatusField->SetText("connected");
|
||||
else
|
||||
fStatusField->SetText("disconnected");
|
||||
|
||||
// TODO : Find how to get link speed
|
||||
fSpeedField->SetText("100 Mb/s");
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
InterfaceHardwareView::SaveFields()
|
||||
{
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2004-2011 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Alexander von Gluck, [email protected]
|
||||
*/
|
||||
#ifndef INTERFACE_HARDWARE_VIEW_H
|
||||
#define INTERFACE_HARDWARE_VIEW_H
|
||||
|
||||
|
||||
#include "NetworkSettings.h"
|
||||
|
||||
#include <MenuField.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <Screen.h>
|
||||
#include <StringView.h>
|
||||
#include <TextControl.h>
|
||||
#include <GroupView.h>
|
||||
|
||||
|
||||
class InterfaceHardwareView : public BGroupView {
|
||||
public:
|
||||
InterfaceHardwareView(BRect frame,
|
||||
NetworkSettings* settings);
|
||||
virtual ~InterfaceHardwareView();
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void AttachedToWindow();
|
||||
status_t RevertFields();
|
||||
status_t SaveFields();
|
||||
|
||||
|
||||
private:
|
||||
void _EnableFields(bool enabled);
|
||||
|
||||
NetworkSettings* fSettings;
|
||||
|
||||
BTextControl* fStatusField;
|
||||
BTextControl* fMACField;
|
||||
BTextControl* fSpeedField;
|
||||
};
|
||||
|
||||
|
||||
#endif /* INTERFACE_HARDWARE_VIEW_H */
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include <Application.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#undef B_TRANSLATE_CONTEXT
|
||||
#define B_TRANSLATE_CONTEXT "NetworkSetupWindow"
|
||||
@@ -95,6 +97,16 @@ InterfaceWindow::_PopulateTabs()
|
||||
BRect frame = fTabView->Bounds();
|
||||
protocols* supportedFamilies = fNetworkSettings->ProtocolVersions();
|
||||
|
||||
BTab* hardwaretab = new BTab;
|
||||
fTabHardwareView = new InterfaceHardwareView(frame,
|
||||
fNetworkSettings);
|
||||
fTabView->AddTab(fTabHardwareView, hardwaretab);
|
||||
|
||||
if (fNetworkSettings->IsEthernet())
|
||||
hardwaretab->SetLabel("Wired");
|
||||
else
|
||||
hardwaretab->SetLabel("Wirless");
|
||||
|
||||
for (int index = 0; index < MAX_PROTOCOLS; index++)
|
||||
{
|
||||
if (supportedFamilies[index].present) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "NetworkSettings.h"
|
||||
#include "InterfaceAddressView.h"
|
||||
#include "InterfaceHardwareView.h"
|
||||
|
||||
#include <Button.h>
|
||||
#include <Catalog.h>
|
||||
@@ -47,6 +48,7 @@ private:
|
||||
BTabView* fTabView;
|
||||
|
||||
IPViewMap fTabIPView;
|
||||
InterfaceHardwareView* fTabHardwareView;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ UseLibraryHeaders agg ;
|
||||
|
||||
|
||||
AddResources Interfaces :
|
||||
InterfacesIcons.rdef
|
||||
InterfacesIcons.rdef
|
||||
;
|
||||
|
||||
Addon Interfaces :
|
||||
@@ -19,6 +19,7 @@ Addon Interfaces :
|
||||
NetworkSettings.cpp
|
||||
InterfaceWindow.cpp
|
||||
InterfaceAddressView.cpp
|
||||
InterfaceHardwareView.cpp
|
||||
|
||||
# from src/apps/networkstatus
|
||||
RadioView.cpp
|
||||
|
||||
@@ -41,6 +41,7 @@ NetworkSettings::NetworkSettings(const char* name)
|
||||
fName = name;
|
||||
_DetectProtocols();
|
||||
|
||||
fNetworkDevice = new BNetworkDevice(fName);
|
||||
fNetworkInterface = new BNetworkInterface(fName);
|
||||
|
||||
ReadConfiguration();
|
||||
|
||||
@@ -83,6 +83,14 @@ public:
|
||||
const char* Name() { return fName.String(); }
|
||||
const char* Domain() { return fDomain.String(); }
|
||||
bool IsDisabled() { return fDisabled; }
|
||||
|
||||
bool IsWireless() {
|
||||
return fNetworkDevice->IsWireless(); }
|
||||
bool IsEthernet() {
|
||||
return fNetworkDevice->IsEthernet(); }
|
||||
bool HasLink() {
|
||||
return fNetworkDevice->HasLink(); }
|
||||
|
||||
const BString& WirelessNetwork() { return fWirelessNetwork; }
|
||||
|
||||
BObjectList<BString>& NameServers() { return fNameServers; }
|
||||
@@ -112,7 +120,10 @@ private:
|
||||
BString fWirelessNetwork;
|
||||
|
||||
protocols fProtocols[MAX_PROTOCOLS];
|
||||
|
||||
BNetworkInterface* fNetworkInterface;
|
||||
BNetworkDevice* fNetworkDevice;
|
||||
|
||||
InterfaceAddressMap fInterfaceAddressMap;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user