Patch by Vegard Waerp: Added support for setting the the local domain in the
Network settings and setting the domain if received by DHCP. Thanks a lot, closes #5619. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35938 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
* Axel Dörfler
|
* Axel Dörfler
|
||||||
* Hugo Santos
|
* Hugo Santos
|
||||||
* Philippe Saint-Pierre
|
* Philippe Saint-Pierre
|
||||||
|
* Vegard Wærp
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -172,12 +173,17 @@ EthernetSettingsView::EthernetSettingsView()
|
|||||||
layout->AddItem(fSecondaryDNSTextControl->CreateLabelLayoutItem(), 0, 6);
|
layout->AddItem(fSecondaryDNSTextControl->CreateLabelLayoutItem(), 0, 6);
|
||||||
layout->AddItem(fSecondaryDNSTextControl->CreateTextViewLayoutItem(), 1, 6);
|
layout->AddItem(fSecondaryDNSTextControl->CreateTextViewLayoutItem(), 1, 6);
|
||||||
|
|
||||||
|
fDomainTextControl = new BTextControl(TR("Domain:"), "", NULL);
|
||||||
|
SetupTextControl(fDomainTextControl);
|
||||||
|
layout->AddItem(fDomainTextControl->CreateLabelLayoutItem(), 0, 7);
|
||||||
|
layout->AddItem(fDomainTextControl->CreateTextViewLayoutItem(), 1, 7);
|
||||||
|
|
||||||
fErrorMessage = new BStringView("error", "");
|
fErrorMessage = new BStringView("error", "");
|
||||||
fErrorMessage->SetAlignment(B_ALIGN_LEFT);
|
fErrorMessage->SetAlignment(B_ALIGN_LEFT);
|
||||||
fErrorMessage->SetFont(be_bold_font);
|
fErrorMessage->SetFont(be_bold_font);
|
||||||
fErrorMessage->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
fErrorMessage->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
||||||
|
|
||||||
layout->AddView(fErrorMessage, 1, 7);
|
layout->AddView(fErrorMessage, 1, 8);
|
||||||
|
|
||||||
// button group (TODO: move to window, but take care of
|
// button group (TODO: move to window, but take care of
|
||||||
// enabling/disabling)
|
// enabling/disabling)
|
||||||
@@ -268,6 +274,7 @@ EthernetSettingsView::AttachedToWindow()
|
|||||||
fGatewayTextControl->SetTarget(this);
|
fGatewayTextControl->SetTarget(this);
|
||||||
fPrimaryDNSTextControl->SetTarget(this);
|
fPrimaryDNSTextControl->SetTarget(this);
|
||||||
fSecondaryDNSTextControl->SetTarget(this);
|
fSecondaryDNSTextControl->SetTarget(this);
|
||||||
|
fDomainTextControl->SetTarget(this);
|
||||||
fDeviceMenuField->Menu()->SetTargetForItems(this);
|
fDeviceMenuField->Menu()->SetTargetForItems(this);
|
||||||
fTypeMenuField->Menu()->SetTargetForItems(this);
|
fTypeMenuField->Menu()->SetTargetForItems(this);
|
||||||
|
|
||||||
@@ -293,6 +300,7 @@ EthernetSettingsView::_ShowConfiguration(Settings* settings)
|
|||||||
fNetMaskTextControl->SetText("");
|
fNetMaskTextControl->SetText("");
|
||||||
fPrimaryDNSTextControl->SetText("");
|
fPrimaryDNSTextControl->SetText("");
|
||||||
fSecondaryDNSTextControl->SetText("");
|
fSecondaryDNSTextControl->SetText("");
|
||||||
|
fDomainTextControl->SetText("");
|
||||||
|
|
||||||
bool enableControls = false;
|
bool enableControls = false;
|
||||||
fTypeMenuField->SetEnabled(settings != NULL);
|
fTypeMenuField->SetEnabled(settings != NULL);
|
||||||
@@ -325,6 +333,7 @@ EthernetSettingsView::_ShowConfiguration(Settings* settings)
|
|||||||
fPrimaryDNSTextControl->SetText(
|
fPrimaryDNSTextControl->SetText(
|
||||||
settings->NameServers().ItemAt(0)->String());
|
settings->NameServers().ItemAt(0)->String());
|
||||||
}
|
}
|
||||||
|
fDomainTextControl->SetText(settings->Domain());
|
||||||
}
|
}
|
||||||
|
|
||||||
_EnableTextControls(enableControls);
|
_EnableTextControls(enableControls);
|
||||||
@@ -339,6 +348,7 @@ EthernetSettingsView::_EnableTextControls(bool enable)
|
|||||||
fNetMaskTextControl->SetEnabled(enable);
|
fNetMaskTextControl->SetEnabled(enable);
|
||||||
fPrimaryDNSTextControl->SetEnabled(enable);
|
fPrimaryDNSTextControl->SetEnabled(enable);
|
||||||
fSecondaryDNSTextControl->SetEnabled(enable);
|
fSecondaryDNSTextControl->SetEnabled(enable);
|
||||||
|
fDomainTextControl->SetEnabled(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -360,6 +370,7 @@ EthernetSettingsView::_ApplyControlsToConfiguration()
|
|||||||
fPrimaryDNSTextControl->Text()));
|
fPrimaryDNSTextControl->Text()));
|
||||||
fCurrentSettings->NameServers().AddItem(new BString(
|
fCurrentSettings->NameServers().AddItem(new BString(
|
||||||
fSecondaryDNSTextControl->Text()));
|
fSecondaryDNSTextControl->Text()));
|
||||||
|
fCurrentSettings->SetDomain(fDomainTextControl->Text());
|
||||||
|
|
||||||
fApplyButton->SetEnabled(false);
|
fApplyButton->SetEnabled(false);
|
||||||
fRevertButton->SetEnabled(true);
|
fRevertButton->SetEnabled(true);
|
||||||
@@ -404,6 +415,11 @@ EthernetSettingsView::_SaveDNSConfiguration()
|
|||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (strlen(settings->Domain()) > 0) {
|
||||||
|
content << "domain\t"
|
||||||
|
<< settings->Domain()
|
||||||
|
<< "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file.Write(content.String(), content.Length());
|
file.Write(content.String(), content.Length());
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
* Andre Alves Garzia, [email protected]
|
* Andre Alves Garzia, [email protected]
|
||||||
* Axel Dörfler
|
* Axel Dörfler
|
||||||
* Hugo Santos
|
* Hugo Santos
|
||||||
|
* Vegard Wærp
|
||||||
*/
|
*/
|
||||||
#ifndef ETHERNET_SETTINGS_VIEW_H
|
#ifndef ETHERNET_SETTINGS_VIEW_H
|
||||||
#define ETHERNET_SETTINGS_VIEW_H
|
#define ETHERNET_SETTINGS_VIEW_H
|
||||||
@@ -65,6 +66,7 @@ private:
|
|||||||
|
|
||||||
BTextControl* fPrimaryDNSTextControl;
|
BTextControl* fPrimaryDNSTextControl;
|
||||||
BTextControl* fSecondaryDNSTextControl;
|
BTextControl* fSecondaryDNSTextControl;
|
||||||
|
BTextControl* fDomainTextControl;
|
||||||
|
|
||||||
BStringView* fErrorMessage;
|
BStringView* fErrorMessage;
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
* Authors:
|
* Authors:
|
||||||
* Andre Alves Garzia, [email protected]
|
* Andre Alves Garzia, [email protected]
|
||||||
* Axel Dörfler, [email protected].
|
* Axel Dörfler, [email protected].
|
||||||
|
* Vegard Wærp, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -159,5 +160,6 @@ Settings::ReadConfiguration()
|
|||||||
fNameServers.AddItem(
|
fNameServers.AddItem(
|
||||||
new BString(inet_ntoa(state->nsaddr_list[i].sin_addr)));
|
new BString(inet_ntoa(state->nsaddr_list[i].sin_addr)));
|
||||||
}
|
}
|
||||||
|
fDomain = state->dnsrch[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
* Copyright 2004-2009 Haiku Inc. All rights reserved.
|
* Copyright 2004-2009 Haiku Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Author:
|
* Authors:
|
||||||
* Andre Alves Garzia, [email protected]
|
* Andre Alves Garzia, [email protected]
|
||||||
|
* Vegard Wærp, [email protected]
|
||||||
*/
|
*/
|
||||||
#ifndef SETTINGS_H
|
#ifndef SETTINGS_H
|
||||||
#define SETTINGS_H
|
#define SETTINGS_H
|
||||||
@@ -21,6 +22,7 @@ public:
|
|||||||
void SetIP(BString ip) { fIP = ip; }
|
void SetIP(BString ip) { fIP = ip; }
|
||||||
void SetGateway(BString ip) { fGateway = ip; }
|
void SetGateway(BString ip) { fGateway = ip; }
|
||||||
void SetNetmask(BString ip) { fNetmask = ip; }
|
void SetNetmask(BString ip) { fNetmask = ip; }
|
||||||
|
void SetDomain(BString domain) { fDomain = domain; }
|
||||||
void SetAutoConfigure(bool autoConfigure)
|
void SetAutoConfigure(bool autoConfigure)
|
||||||
{ fAuto = autoConfigure; }
|
{ fAuto = autoConfigure; }
|
||||||
|
|
||||||
@@ -28,6 +30,7 @@ public:
|
|||||||
const char* Gateway() { return fGateway.String(); }
|
const char* Gateway() { return fGateway.String(); }
|
||||||
const char* Netmask() { return fNetmask.String(); }
|
const char* Netmask() { return fNetmask.String(); }
|
||||||
const char* Name() { return fName.String(); }
|
const char* Name() { return fName.String(); }
|
||||||
|
const char* Domain() { return fDomain.String(); }
|
||||||
bool AutoConfigure() { return fAuto; }
|
bool AutoConfigure() { return fAuto; }
|
||||||
|
|
||||||
BObjectList<BString>& NameServers() { return fNameServers; }
|
BObjectList<BString>& NameServers() { return fNameServers; }
|
||||||
@@ -41,6 +44,7 @@ private:
|
|||||||
BString fGateway;
|
BString fGateway;
|
||||||
BString fNetmask;
|
BString fNetmask;
|
||||||
BString fName;
|
BString fName;
|
||||||
|
BString fDomain;
|
||||||
int fSocket;
|
int fSocket;
|
||||||
bool fAuto;
|
bool fAuto;
|
||||||
BObjectList<BString> fNameServers;
|
BObjectList<BString> fNameServers;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Axel Dörfler, [email protected]
|
* Axel Dörfler, [email protected]
|
||||||
|
* Vegard Wærp, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -681,6 +682,18 @@ DHCPClient::_ParseOptions(dhcp_message& message, BMessage& address)
|
|||||||
memcpy(name, data, size);
|
memcpy(name, data, size);
|
||||||
name[size] = '\0';
|
name[size] = '\0';
|
||||||
syslog(LOG_INFO, "DHCP domain name: \"%s\"\n", name);
|
syslog(LOG_INFO, "DHCP domain name: \"%s\"\n", name);
|
||||||
|
|
||||||
|
BPath path;
|
||||||
|
if (find_directory(B_COMMON_SETTINGS_DIRECTORY, &path) != B_OK)
|
||||||
|
break;
|
||||||
|
|
||||||
|
path.Append("network/resolv.conf");
|
||||||
|
|
||||||
|
FILE* file = fopen(path.Path(), "a");
|
||||||
|
if (file != NULL) {
|
||||||
|
fprintf(file, "domain %s\n", name);
|
||||||
|
fclose(file);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user