+ Implement functions to save address choices
(TODO: load address choices into array Addr[IF_INET|IF_INET6]) + Implement SaveFields to save settings via BMessage + Make configuration window resizable in-case of expanded IPv6 address + Rename Apply button to "Save" as IP changes won't take effect until Apply is pressed in main window. (prob needs some additional thought) + Updated BMessages to better match correct naming guidelines git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40541 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
26e9cef813
commit
0954523001
|
@ -129,3 +129,17 @@ InterfaceAddressView::RevertFields()
|
|||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
InterfaceAddressView::SaveFields()
|
||||
{
|
||||
fSettings->SetIP(fFamily, fAddressField->Text());
|
||||
fSettings->SetNetmask(fFamily, fNetmaskField->Text());
|
||||
fSettings->SetGateway(fFamily, fGatewayField->Text());
|
||||
|
||||
BMenuItem* item = fModePopUpMenu->FindItem("Automatic");
|
||||
fSettings->SetAutoConfigure(fFamily, item->IsMarked());
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void AttachedToWindow();
|
||||
status_t RevertFields();
|
||||
status_t SaveFields();
|
||||
|
||||
|
||||
private:
|
||||
|
|
|
@ -20,18 +20,18 @@ InterfaceWindow::InterfaceWindow(NetworkSettings* settings)
|
|||
:
|
||||
BWindow(BRect(50, 50, 370, 350), "Interface Settings",
|
||||
B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL,
|
||||
B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE,
|
||||
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE,
|
||||
B_CURRENT_WORKSPACE)
|
||||
{
|
||||
fNetworkSettings = settings;
|
||||
|
||||
fTabView = new BTabView("settings_tabs");
|
||||
|
||||
fApplyButton = new BButton("apply", B_TRANSLATE("Apply"),
|
||||
new BMessage(APPLY_MSG));
|
||||
fApplyButton = new BButton("save", B_TRANSLATE("Save"),
|
||||
new BMessage(MSG_IP_SAVE));
|
||||
|
||||
fRevertButton = new BButton("revert", B_TRANSLATE("Revert"),
|
||||
new BMessage(REVERT_MSG));
|
||||
new BMessage(MSG_IP_REVERT));
|
||||
|
||||
fTabView->SetResizingMode(B_FOLLOW_ALL);
|
||||
// ensure tab container matches window size
|
||||
|
@ -61,12 +61,17 @@ void
|
|||
InterfaceWindow::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case REVERT_MSG:
|
||||
case MSG_IP_REVERT:
|
||||
// RFC : we could check fTabView for Selection
|
||||
// here and only revert the selected tab.
|
||||
fIPv4TabView->RevertFields();
|
||||
fIPv6TabView->RevertFields();
|
||||
break;
|
||||
case MSG_IP_SAVE:
|
||||
fIPv4TabView->SaveFields();
|
||||
fIPv6TabView->SaveFields();
|
||||
this->Quit();
|
||||
break;
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
|
||||
|
||||
enum {
|
||||
APPLY_MSG = 'aply',
|
||||
REVERT_MSG = 'rvrt'
|
||||
MSG_IP_SAVE = 'ipap',
|
||||
MSG_IP_REVERT = 'iprv'
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -56,6 +56,8 @@ NetworkSettings::~NetworkSettings()
|
|||
}
|
||||
|
||||
|
||||
// -- Interface address read code
|
||||
|
||||
void
|
||||
NetworkSettings::ReadConfiguration()
|
||||
{
|
||||
|
@ -254,3 +256,46 @@ NetworkSettings::PrefixLen(int family)
|
|||
return fIPv4Mask.PrefixLength();
|
||||
}
|
||||
|
||||
|
||||
// -- Interface address write code
|
||||
|
||||
|
||||
void
|
||||
NetworkSettings::SetIP(int family, const char* ip)
|
||||
{
|
||||
if (family == AF_INET6)
|
||||
fIPv6Addr = ip;
|
||||
else
|
||||
fIPv4Addr = ip;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NetworkSettings::SetNetmask(int family, const char* mask)
|
||||
{
|
||||
if (family == AF_INET6)
|
||||
fIPv6Mask = mask;
|
||||
else
|
||||
fIPv4Mask = mask;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NetworkSettings::SetGateway(int family, const char* ip)
|
||||
{
|
||||
if (family == AF_INET6)
|
||||
fIPv6Gateway = ip;
|
||||
else
|
||||
fIPv4Gateway = ip;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NetworkSettings::SetAutoConfigure(int family, bool autoConf)
|
||||
{
|
||||
if (family == AF_INET6)
|
||||
fIPv6Auto = autoConf;
|
||||
else
|
||||
fIPv4Auto = autoConf;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,20 +22,17 @@ public:
|
|||
NetworkSettings(const char* name);
|
||||
virtual ~NetworkSettings();
|
||||
|
||||
// void SetIP(const BString& ip)
|
||||
// { fIP = ip; }
|
||||
// void SetGateway(const BString& ip)
|
||||
// { fGateway = ip; }
|
||||
// void SetNetmask(const BString& ip)
|
||||
// { fNetmask = ip; }
|
||||
// void SetDomain(const BString& domain)
|
||||
// { fDomain = domain; }
|
||||
// void SetAutoConfigure(bool autoConfigure)
|
||||
// { fAuto = autoConfigure; }
|
||||
void SetIP(int family, const char* ip);
|
||||
void SetNetmask(int family, const char* mask);
|
||||
void SetGateway(int family, const char* mask);
|
||||
void SetAutoConfigure(int family, bool autoConf);
|
||||
|
||||
void SetDisabled(bool disabled)
|
||||
{ fDisabled = disabled; }
|
||||
// void SetWirelessNetwork(const char* name)
|
||||
// { fWirelessNetwork.SetTo(name); }
|
||||
// void SetDomain(const BString& domain)
|
||||
// { fDomain = domain; }
|
||||
|
||||
BNetworkAddress IPAddr(int family);
|
||||
|
||||
|
|
Loading…
Reference in New Issue