make network settings window save button send save call to all add-ons; set interface address via BNetworkInterface; still have work to do.. but we can apply ipv4/ipv6 ip/netmask changes to the interfaces now!!!
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40727 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "InterfacesAddOn.h"
|
#include "InterfacesAddOn.h"
|
||||||
#include "InterfacesListView.h"
|
|
||||||
#include "InterfaceWindow.h"
|
#include "InterfaceWindow.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -58,14 +57,6 @@ InterfacesAddOn::Name()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
InterfacesAddOn::Save()
|
|
||||||
{
|
|
||||||
printf("I am saved!\n");
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BView*
|
BView*
|
||||||
InterfacesAddOn::CreateView(BRect *bounds)
|
InterfacesAddOn::CreateView(BRect *bounds)
|
||||||
{
|
{
|
||||||
@@ -118,6 +109,14 @@ InterfacesAddOn::AttachedToWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
InterfacesAddOn::Save()
|
||||||
|
{
|
||||||
|
// TODO : Profile?
|
||||||
|
return fListview->SaveItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InterfacesAddOn::MessageReceived(BMessage* msg)
|
InterfacesAddOn::MessageReceived(BMessage* msg)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,9 +13,11 @@
|
|||||||
|
|
||||||
#include <Box.h>
|
#include <Box.h>
|
||||||
#include <ListView.h>
|
#include <ListView.h>
|
||||||
|
#include <ListItem.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
|
|
||||||
#include "NetworkSetupAddOn.h"
|
#include "NetworkSetupAddOn.h"
|
||||||
|
#include "InterfacesListView.h"
|
||||||
|
|
||||||
|
|
||||||
class InterfacesAddOn : public NetworkSetupAddOn, public BBox
|
class InterfacesAddOn : public NetworkSetupAddOn, public BBox
|
||||||
@@ -26,6 +28,7 @@ public:
|
|||||||
|
|
||||||
const char* Name();
|
const char* Name();
|
||||||
status_t Save();
|
status_t Save();
|
||||||
|
|
||||||
BView* CreateView(BRect *bounds);
|
BView* CreateView(BRect *bounds);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -38,7 +41,7 @@ public:
|
|||||||
void MessageReceived(BMessage* msg);
|
void MessageReceived(BMessage* msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BListView* fListview;
|
InterfacesListView* fListview;
|
||||||
BButton* fConfigure;
|
BButton* fConfigure;
|
||||||
BButton* fOnOff;
|
BButton* fOnOff;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -382,6 +382,24 @@ InterfacesListView::FindItem(const char* name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
InterfacesListView::SaveItems()
|
||||||
|
{
|
||||||
|
// Grab each fSettings instance and write it's settings
|
||||||
|
for (int32 i = CountItems(); i-- > 0;) {
|
||||||
|
InterfaceListItem* item = dynamic_cast<InterfaceListItem*>(ItemAt(i));
|
||||||
|
if (item == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
NetworkSettings* ns = item->GetSettings();
|
||||||
|
// TODO : SetConfiguration doesn't use the interface settings file
|
||||||
|
ns->SetConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
InterfacesListView::_InitList()
|
InterfacesListView::_InitList()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -72,7 +72,8 @@ public:
|
|||||||
|
|
||||||
virtual ~InterfacesListView();
|
virtual ~InterfacesListView();
|
||||||
|
|
||||||
InterfaceListItem* FindItem(const char* name);
|
InterfaceListItem* FindItem(const char* name);
|
||||||
|
status_t SaveItems();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
|
|||||||
@@ -101,6 +101,11 @@ NetworkSettings::_DetectProtocols()
|
|||||||
// -- Interface address read code
|
// -- Interface address read code
|
||||||
|
|
||||||
|
|
||||||
|
/*! ReadConfiguration pulls the current interface settings
|
||||||
|
from the interfaces via BNetworkInterface and friends
|
||||||
|
and populates this classes private settings BAddresses
|
||||||
|
with them.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
NetworkSettings::ReadConfiguration()
|
NetworkSettings::ReadConfiguration()
|
||||||
{
|
{
|
||||||
@@ -272,10 +277,56 @@ NetworkSettings::ReadConfiguration()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! SetConfiguration sets this classes current BNetworkAddress settings
|
||||||
|
to the interface directly via BNetworkInterface and friends
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
NetworkSettings::SetConfiguration()
|
||||||
|
{
|
||||||
|
BNetworkInterface fNetworkInterface(fName);
|
||||||
|
printf("Setting %s\n", Name());
|
||||||
|
for (int index = 0; index < MAX_PROTOCOLS; index++) {
|
||||||
|
int inet_id = fProtocols[index].inet_id;
|
||||||
|
if (fProtocols[index].present) {
|
||||||
|
int32 zeroAddr = fNetworkInterface.FindFirstAddress(inet_id);
|
||||||
|
if (zeroAddr >= 0) {
|
||||||
|
BNetworkInterfaceAddress interfaceConfig;
|
||||||
|
fNetworkInterface.GetAddressAt(zeroAddr,
|
||||||
|
interfaceConfig);
|
||||||
|
interfaceConfig.SetAddress(fAddress[inet_id]);
|
||||||
|
interfaceConfig.SetMask(fNetmask[inet_id]);
|
||||||
|
fNetworkInterface.SetAddress(interfaceConfig);
|
||||||
|
fNetworkInterface.SetTo(zeroAddr);
|
||||||
|
} else {
|
||||||
|
// TODO : test this case (no address set for this protocol)
|
||||||
|
printf("no zeroAddr found for %s(%d), found %lu\n",
|
||||||
|
fProtocols[index].name, inet_id, zeroAddr);
|
||||||
|
BNetworkInterfaceAddress interfaceConfig;
|
||||||
|
interfaceConfig.SetAddress(fAddress[inet_id]);
|
||||||
|
interfaceConfig.SetMask(fNetmask[inet_id]);
|
||||||
|
fNetworkInterface.AddAddress(interfaceConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! LoadConfiguration reads the current interface configuration
|
||||||
|
file that NetServer looks for and populates this class with it
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
NetworkSettings::LoadConfiguration()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! WriteConfiguration reads this classes settings and write them to
|
||||||
|
the current interface configuration file that NetServer watches for.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
NetworkSettings::WriteConfiguration()
|
NetworkSettings::WriteConfiguration()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,13 @@ public:
|
|||||||
|
|
||||||
BObjectList<BString>& NameServers() { return fNameServers; }
|
BObjectList<BString>& NameServers() { return fNameServers; }
|
||||||
|
|
||||||
|
/* Grab and write interface settings directly from interface */
|
||||||
void ReadConfiguration();
|
void ReadConfiguration();
|
||||||
|
void SetConfiguration();
|
||||||
|
|
||||||
|
/* Grab and write interface settings from interface configuration
|
||||||
|
file and let NetServer sort it out */
|
||||||
|
void LoadConfiguration();
|
||||||
void WriteConfiguration();
|
void WriteConfiguration();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ NetworkSetupWindow::NetworkSetupWindow(const char *title)
|
|||||||
B_TRANSLATE("Profile:"), profilesPopup);
|
B_TRANSLATE("Profile:"), profilesPopup);
|
||||||
|
|
||||||
profilesMenuField->SetFont(be_bold_font);
|
profilesMenuField->SetFont(be_bold_font);
|
||||||
|
profilesMenuField->SetEnabled(false);
|
||||||
|
|
||||||
// ---- Settings section
|
// ---- Settings section
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user