solved bug that prevented setting interface back to DHCP.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22237 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -166,8 +166,8 @@ EthernetSettingsView::EthernetSettingsView(BRect rect)
|
|||||||
modemenu->AddItem(staticitem);
|
modemenu->AddItem(staticitem);
|
||||||
BMenuItem* dhcpitem = new BMenuItem("DHCP", NULL);
|
BMenuItem* dhcpitem = new BMenuItem("DHCP", NULL);
|
||||||
modemenu->AddItem(dhcpitem);
|
modemenu->AddItem(dhcpitem);
|
||||||
BMenuItem* offitem = new BMenuItem("Disconnected", NULL);
|
//BMenuItem* offitem = new BMenuItem("Disconnected", NULL);
|
||||||
modemenu->AddItem(offitem);
|
//modemenu->AddItem(offitem);
|
||||||
|
|
||||||
fDeviceMenuField = new BMenuField(frame, "networkcards", "Adapter:", devmenu);
|
fDeviceMenuField = new BMenuField(frame, "networkcards", "Adapter:", devmenu);
|
||||||
fDeviceMenuField->SetDivider(
|
fDeviceMenuField->SetDivider(
|
||||||
@@ -298,31 +298,35 @@ void
|
|||||||
EthernetSettingsView::_ApplyControlsToConfiguration()
|
EthernetSettingsView::_ApplyControlsToConfiguration()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (strcmp(fTypeMenuField->Menu()->FindMarked()->Label(), "Static") == 0) {
|
int i;
|
||||||
int i;
|
for (i = 0; i < fSettings.CountItems(); i++) {
|
||||||
for (i = 0; i < fSettings.CountItems(); i++) {
|
|
||||||
|
|
||||||
|
|
||||||
if (strcmp(fSettings.ItemAt(i)->
|
if (strcmp(fSettings.ItemAt(i)->
|
||||||
GetName(), fDeviceMenuField->Menu()->FindMarked()->Label()) == 0) {
|
GetName(), fDeviceMenuField->Menu()->FindMarked()->Label()) == 0) {
|
||||||
|
fSettings.ItemAt(i)->
|
||||||
|
SetIP(fIPTextControl->Text());
|
||||||
|
fSettings.ItemAt(i)->
|
||||||
|
SetNetmask(fNetMaskTextControl->Text());
|
||||||
fSettings.ItemAt(i)->
|
fSettings.ItemAt(i)->
|
||||||
SetIP(fIPTextControl->Text());
|
SetGateway(fGatewayTextControl->Text());
|
||||||
fSettings.ItemAt(i)->
|
if (strcmp(fTypeMenuField->Menu()->FindMarked()->Label(), "DHCP")
|
||||||
SetNetmask(fNetMaskTextControl->Text());
|
== 0)
|
||||||
fSettings.ItemAt(i)->
|
fSettings.ItemAt(i)->SetAutoConfigure(true);
|
||||||
SetGateway(fGatewayTextControl->Text());
|
else
|
||||||
fSettings.ItemAt(i)->SetAutoConfigure(false);
|
fSettings.ItemAt(i)->SetAutoConfigure(false);
|
||||||
|
|
||||||
|
|
||||||
|
fSettings.ItemAt(i)->fNameservers.MakeEmpty();
|
||||||
|
fSettings.ItemAt(i)->fNameservers.AddItem(new BString(
|
||||||
|
fPrimaryDNSTextControl->Text()));
|
||||||
|
fSettings.ItemAt(i)->fNameservers.AddItem(new BString(
|
||||||
|
fSecondaryDNSTextControl->Text()));
|
||||||
|
|
||||||
fSettings.ItemAt(i)->fNameservers.MakeEmpty();
|
|
||||||
fSettings.ItemAt(i)->fNameservers.AddItem(new BString(
|
|
||||||
fPrimaryDNSTextControl->Text()));
|
|
||||||
fSettings.ItemAt(i)->fNameservers.AddItem(new BString(
|
|
||||||
fSecondaryDNSTextControl->Text()));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
EthernetSettingsView::_SaveConfiguration()
|
EthernetSettingsView::_SaveConfiguration()
|
||||||
@@ -364,12 +368,14 @@ EthernetSettingsView::_SaveAdaptersConfiguration()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
FILE* fp = NULL;
|
FILE* fp = NULL;
|
||||||
|
bool allDHCP = true;
|
||||||
// loop over all adapters. open the settings file only once,
|
// loop over all adapters. open the settings file only once,
|
||||||
// append the settins of each non-autoconfiguring adapter
|
// append the settins of each non-autoconfiguring adapter
|
||||||
for (int i = 0; i < fSettings.CountItems(); i++) {
|
for (int i = 0; i < fSettings.CountItems(); i++) {
|
||||||
if (fSettings.ItemAt(i)->GetAutoConfigure())
|
if (fSettings.ItemAt(i)->GetAutoConfigure())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
allDHCP = false;
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
fp = fopen(path.Path(), "w");
|
fp = fopen(path.Path(), "w");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
@@ -393,7 +399,12 @@ EthernetSettingsView::_SaveAdaptersConfiguration()
|
|||||||
if (fp) {
|
if (fp) {
|
||||||
printf("%s saved.\n", path.Path());
|
printf("%s saved.\n", path.Path());
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (allDHCP) {
|
||||||
|
// all configuration is DHCP, so delete interfaces file.
|
||||||
|
remove(path.Path());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
|
|||||||
Reference in New Issue
Block a user