+ 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:
@@ -129,3 +129,17 @@ InterfaceAddressView::RevertFields()
|
|||||||
|
|
||||||
return B_OK;
|
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 MessageReceived(BMessage* message);
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
status_t RevertFields();
|
status_t RevertFields();
|
||||||
|
status_t SaveFields();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -20,18 +20,18 @@ InterfaceWindow::InterfaceWindow(NetworkSettings* settings)
|
|||||||
:
|
:
|
||||||
BWindow(BRect(50, 50, 370, 350), "Interface Settings",
|
BWindow(BRect(50, 50, 370, 350), "Interface Settings",
|
||||||
B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL,
|
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)
|
B_CURRENT_WORKSPACE)
|
||||||
{
|
{
|
||||||
fNetworkSettings = settings;
|
fNetworkSettings = settings;
|
||||||
|
|
||||||
fTabView = new BTabView("settings_tabs");
|
fTabView = new BTabView("settings_tabs");
|
||||||
|
|
||||||
fApplyButton = new BButton("apply", B_TRANSLATE("Apply"),
|
fApplyButton = new BButton("save", B_TRANSLATE("Save"),
|
||||||
new BMessage(APPLY_MSG));
|
new BMessage(MSG_IP_SAVE));
|
||||||
|
|
||||||
fRevertButton = new BButton("revert", B_TRANSLATE("Revert"),
|
fRevertButton = new BButton("revert", B_TRANSLATE("Revert"),
|
||||||
new BMessage(REVERT_MSG));
|
new BMessage(MSG_IP_REVERT));
|
||||||
|
|
||||||
fTabView->SetResizingMode(B_FOLLOW_ALL);
|
fTabView->SetResizingMode(B_FOLLOW_ALL);
|
||||||
// ensure tab container matches window size
|
// ensure tab container matches window size
|
||||||
@@ -61,12 +61,17 @@ void
|
|||||||
InterfaceWindow::MessageReceived(BMessage* message)
|
InterfaceWindow::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case REVERT_MSG:
|
case MSG_IP_REVERT:
|
||||||
// RFC : we could check fTabView for Selection
|
// RFC : we could check fTabView for Selection
|
||||||
// here and only revert the selected tab.
|
// here and only revert the selected tab.
|
||||||
fIPv4TabView->RevertFields();
|
fIPv4TabView->RevertFields();
|
||||||
fIPv6TabView->RevertFields();
|
fIPv6TabView->RevertFields();
|
||||||
break;
|
break;
|
||||||
|
case MSG_IP_SAVE:
|
||||||
|
fIPv4TabView->SaveFields();
|
||||||
|
fIPv6TabView->SaveFields();
|
||||||
|
this->Quit();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
BWindow::MessageReceived(message);
|
BWindow::MessageReceived(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
APPLY_MSG = 'aply',
|
MSG_IP_SAVE = 'ipap',
|
||||||
REVERT_MSG = 'rvrt'
|
MSG_IP_REVERT = 'iprv'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ NetworkSettings::~NetworkSettings()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// -- Interface address read code
|
||||||
|
|
||||||
void
|
void
|
||||||
NetworkSettings::ReadConfiguration()
|
NetworkSettings::ReadConfiguration()
|
||||||
{
|
{
|
||||||
@@ -254,3 +256,46 @@ NetworkSettings::PrefixLen(int family)
|
|||||||
return fIPv4Mask.PrefixLength();
|
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);
|
NetworkSettings(const char* name);
|
||||||
virtual ~NetworkSettings();
|
virtual ~NetworkSettings();
|
||||||
|
|
||||||
// void SetIP(const BString& ip)
|
void SetIP(int family, const char* ip);
|
||||||
// { fIP = ip; }
|
void SetNetmask(int family, const char* mask);
|
||||||
// void SetGateway(const BString& ip)
|
void SetGateway(int family, const char* mask);
|
||||||
// { fGateway = ip; }
|
void SetAutoConfigure(int family, bool autoConf);
|
||||||
// void SetNetmask(const BString& ip)
|
|
||||||
// { fNetmask = ip; }
|
|
||||||
// void SetDomain(const BString& domain)
|
|
||||||
// { fDomain = domain; }
|
|
||||||
// void SetAutoConfigure(bool autoConfigure)
|
|
||||||
// { fAuto = autoConfigure; }
|
|
||||||
void SetDisabled(bool disabled)
|
void SetDisabled(bool disabled)
|
||||||
{ fDisabled = disabled; }
|
{ fDisabled = disabled; }
|
||||||
// void SetWirelessNetwork(const char* name)
|
// void SetWirelessNetwork(const char* name)
|
||||||
// { fWirelessNetwork.SetTo(name); }
|
// { fWirelessNetwork.SetTo(name); }
|
||||||
|
// void SetDomain(const BString& domain)
|
||||||
|
// { fDomain = domain; }
|
||||||
|
|
||||||
BNetworkAddress IPAddr(int family);
|
BNetworkAddress IPAddr(int family);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user