Network: made the revert button (somewhat) work.
* DNS add-on does not yet support it, the rest does. * However, there seems to be some problems with the net_server when changing interfaces -- not just with revert.
This commit is contained in:
@@ -115,6 +115,14 @@ DNSSettingsView::Revert()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
DNSSettingsView::IsRevertable() const
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DNSSettingsView::AttachedToWindow()
|
DNSSettingsView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public:
|
|||||||
~DNSSettingsView();
|
~DNSSettingsView();
|
||||||
|
|
||||||
status_t Revert();
|
status_t Revert();
|
||||||
|
bool IsRevertable() const;
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|||||||
@@ -109,14 +109,14 @@ FTPServiceItem::View()
|
|||||||
status_t
|
status_t
|
||||||
FTPServiceItem::Revert()
|
FTPServiceItem::Revert()
|
||||||
{
|
{
|
||||||
return B_OK;
|
return fView != NULL ? fView->Revert() : B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
FTPServiceItem::IsRevertable()
|
FTPServiceItem::IsRevertable()
|
||||||
{
|
{
|
||||||
return false;
|
return fView != NULL ? fView->IsRevertable() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -100,14 +100,14 @@ IPv4InterfaceItem::View()
|
|||||||
status_t
|
status_t
|
||||||
IPv4InterfaceItem::Revert()
|
IPv4InterfaceItem::Revert()
|
||||||
{
|
{
|
||||||
return B_OK;
|
return fView != NULL ? fView->Revert() : B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
IPv4InterfaceItem::IsRevertable()
|
IPv4InterfaceItem::IsRevertable()
|
||||||
{
|
{
|
||||||
return false;
|
return fView != NULL ? fView->IsRevertable() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -100,14 +100,14 @@ IPv6InterfaceItem::View()
|
|||||||
status_t
|
status_t
|
||||||
IPv6InterfaceItem::Revert()
|
IPv6InterfaceItem::Revert()
|
||||||
{
|
{
|
||||||
return B_OK;
|
return fView != NULL ? fView->Revert() : B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
IPv6InterfaceItem::IsRevertable()
|
IPv6InterfaceItem::IsRevertable()
|
||||||
{
|
{
|
||||||
return false;
|
return fView != NULL ? fView->IsRevertable() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -213,14 +213,14 @@ SSHServiceItem::View()
|
|||||||
status_t
|
status_t
|
||||||
SSHServiceItem::Revert()
|
SSHServiceItem::Revert()
|
||||||
{
|
{
|
||||||
return B_OK;
|
return fView != NULL ? fView->Revert() : B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SSHServiceItem::IsRevertable()
|
SSHServiceItem::IsRevertable()
|
||||||
{
|
{
|
||||||
return false;
|
return fView != NULL ? fView->IsRevertable() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -111,14 +111,14 @@ TelnetServiceItem::View()
|
|||||||
status_t
|
status_t
|
||||||
TelnetServiceItem::Revert()
|
TelnetServiceItem::Revert()
|
||||||
{
|
{
|
||||||
return B_OK;
|
return fView != NULL ? fView->Revert() : B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TelnetServiceItem::IsRevertable()
|
TelnetServiceItem::IsRevertable()
|
||||||
{
|
{
|
||||||
return false;
|
return fView != NULL ? fView->IsRevertable() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -99,8 +99,7 @@ InterfaceAddressView::InterfaceAddressView(int family,
|
|||||||
fApplyButton->SetExplicitAlignment(
|
fApplyButton->SetExplicitAlignment(
|
||||||
BAlignment(B_ALIGN_RIGHT, B_ALIGN_VERTICAL_UNSET));
|
BAlignment(B_ALIGN_RIGHT, B_ALIGN_VERTICAL_UNSET));
|
||||||
|
|
||||||
fSettings.GetInterface(interface, fOriginalInterface);
|
fSettings.GetInterface(interface, fOriginalSettings);
|
||||||
fInterfaceSettings = fOriginalInterface;
|
|
||||||
_UpdateFields();
|
_UpdateFields();
|
||||||
|
|
||||||
BLayoutBuilder::Group<>(this)
|
BLayoutBuilder::Group<>(this)
|
||||||
@@ -162,33 +161,17 @@ InterfaceAddressView::MessageReceived(BMessage* message)
|
|||||||
status_t
|
status_t
|
||||||
InterfaceAddressView::Revert()
|
InterfaceAddressView::Revert()
|
||||||
{
|
{
|
||||||
// Populate address fields with current settings
|
return fSettings.AddInterface(fOriginalSettings);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO!
|
|
||||||
/*
|
|
||||||
int32 mode;
|
|
||||||
if (fSettings->AutoConfigure(fFamily)) {
|
|
||||||
mode = kModeAuto;
|
|
||||||
_EnableFields(false);
|
|
||||||
} else if (fSettings->IPAddr(fFamily).IsEmpty()) {
|
|
||||||
mode = kModeDisabled;
|
|
||||||
_EnableFields(false);
|
|
||||||
} else {
|
|
||||||
mode = kModeStatic;
|
|
||||||
_EnableFields(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
BMenuItem* item = fModePopUpMenu->FindItem(mode);
|
bool
|
||||||
if (item != NULL)
|
InterfaceAddressView::IsRevertable() const
|
||||||
item->SetMarked(true);
|
{
|
||||||
|
BMessage settings;
|
||||||
|
fSettings.GetInterface(fInterface.Name(), settings);
|
||||||
|
|
||||||
if (!fSettings->IPAddr(fFamily).IsEmpty()) {
|
return !settings.HasSameData(fOriginalSettings);
|
||||||
fAddressField->SetText(fSettings->IP(fFamily));
|
|
||||||
fNetmaskField->SetText(fSettings->Netmask(fFamily));
|
|
||||||
fGatewayField->SetText(fSettings->Gateway(fFamily));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return B_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -225,9 +208,12 @@ InterfaceAddressView::_EnableFields(bool enable)
|
|||||||
void
|
void
|
||||||
InterfaceAddressView::_UpdateFields()
|
InterfaceAddressView::_UpdateFields()
|
||||||
{
|
{
|
||||||
bool autoConfigure = fInterfaceSettings.IsEmpty();
|
BMessage interfaceSettings;
|
||||||
|
fSettings.GetInterface(fInterface.Name(), interfaceSettings);
|
||||||
|
|
||||||
|
bool autoConfigure = interfaceSettings.IsEmpty();
|
||||||
if (!autoConfigure) {
|
if (!autoConfigure) {
|
||||||
BNetworkInterfaceSettings settings(fInterfaceSettings);
|
BNetworkInterfaceSettings settings(interfaceSettings);
|
||||||
autoConfigure = settings.IsAutoConfigure(fFamily);
|
autoConfigure = settings.IsAutoConfigure(fFamily);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public:
|
|||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
status_t Revert();
|
status_t Revert();
|
||||||
status_t Save();
|
bool IsRevertable() const;
|
||||||
|
|
||||||
void ConfigurationUpdated(const BMessage& message);
|
void ConfigurationUpdated(const BMessage& message);
|
||||||
|
|
||||||
@@ -61,8 +61,7 @@ private:
|
|||||||
BNetworkSettings& fSettings;
|
BNetworkSettings& fSettings;
|
||||||
uint32 fLastMode;
|
uint32 fLastMode;
|
||||||
|
|
||||||
BMessage fOriginalInterface;
|
BMessage fOriginalSettings;
|
||||||
BMessage fInterfaceSettings;
|
|
||||||
|
|
||||||
BPopUpMenu* fModePopUpMenu;
|
BPopUpMenu* fModePopUpMenu;
|
||||||
BMenuField* fModeField;
|
BMenuField* fModeField;
|
||||||
|
|||||||
@@ -112,7 +112,6 @@ NetworkWindow::NetworkWindow()
|
|||||||
|
|
||||||
fRevertButton = new BButton("revert", B_TRANSLATE("Revert"),
|
fRevertButton = new BButton("revert", B_TRANSLATE("Revert"),
|
||||||
new BMessage(kMsgRevert));
|
new BMessage(kMsgRevert));
|
||||||
// fRevertButton->SetEnabled(false);
|
|
||||||
|
|
||||||
BMessage* message = new BMessage(kMsgToggleReplicant);
|
BMessage* message = new BMessage(kMsgToggleReplicant);
|
||||||
BCheckBox* showReplicantCheckBox = new BCheckBox("showReplicantCheckBox",
|
BCheckBox* showReplicantCheckBox = new BCheckBox("showReplicantCheckBox",
|
||||||
@@ -158,6 +157,7 @@ NetworkWindow::NetworkWindow()
|
|||||||
|
|
||||||
_ScanInterfaces();
|
_ScanInterfaces();
|
||||||
_ScanAddOns();
|
_ScanAddOns();
|
||||||
|
_UpdateRevertButton();
|
||||||
|
|
||||||
// Set size of the list view from its contents
|
// Set size of the list view from its contents
|
||||||
float width;
|
float width;
|
||||||
@@ -249,6 +249,11 @@ NetworkWindow::MessageReceived(BMessage* message)
|
|||||||
_BroadcastSettingsUpdate(message->what);
|
_BroadcastSettingsUpdate(message->what);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case kMsgSettingsItemUpdated:
|
||||||
|
// TODO: update list item
|
||||||
|
_UpdateRevertButton();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
inherited::MessageReceived(message);
|
inherited::MessageReceived(message);
|
||||||
}
|
}
|
||||||
@@ -518,6 +523,8 @@ NetworkWindow::_BroadcastSettingsUpdate(uint32 type)
|
|||||||
SettingsMap::const_iterator iterator = fSettingsMap.begin();
|
SettingsMap::const_iterator iterator = fSettingsMap.begin();
|
||||||
for (; iterator != fSettingsMap.end(); iterator++)
|
for (; iterator != fSettingsMap.end(); iterator++)
|
||||||
iterator->second->SettingsUpdated(type);
|
iterator->second->SettingsUpdated(type);
|
||||||
|
|
||||||
|
_UpdateRevertButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -538,6 +545,23 @@ NetworkWindow::_BroadcastConfigurationUpdate(const BMessage& message)
|
|||||||
|
|
||||||
// TODO: improve invalidated region to the one that matters
|
// TODO: improve invalidated region to the one that matters
|
||||||
fListView->Invalidate();
|
fListView->Invalidate();
|
||||||
|
_UpdateRevertButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
NetworkWindow::_UpdateRevertButton()
|
||||||
|
{
|
||||||
|
bool enabled = false;
|
||||||
|
SettingsMap::const_iterator iterator = fSettingsMap.begin();
|
||||||
|
for (; iterator != fSettingsMap.end(); iterator++) {
|
||||||
|
if (iterator->second->IsRevertable()) {
|
||||||
|
enabled = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fRevertButton->SetEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ private:
|
|||||||
void _BroadcastSettingsUpdate(uint32 type);
|
void _BroadcastSettingsUpdate(uint32 type);
|
||||||
void _BroadcastConfigurationUpdate(
|
void _BroadcastConfigurationUpdate(
|
||||||
const BMessage& message);
|
const BMessage& message);
|
||||||
|
void _UpdateRevertButton();
|
||||||
|
|
||||||
bool _IsReplicantInstalled();
|
bool _IsReplicantInstalled();
|
||||||
void _ShowReplicant(bool show);
|
void _ShowReplicant(bool show);
|
||||||
|
|||||||
@@ -67,17 +67,19 @@ ServiceView::~ServiceView()
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ServiceView::IsRevertable()
|
ServiceView::IsRevertable() const
|
||||||
{
|
{
|
||||||
return IsEnabled() != fWasEnabled;
|
return IsEnabled() != fWasEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
status_t
|
||||||
ServiceView::Revert()
|
ServiceView::Revert()
|
||||||
{
|
{
|
||||||
if (IsRevertable())
|
if (IsRevertable())
|
||||||
_Toggle();
|
_Toggle();
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ public:
|
|||||||
BNetworkSettings& settings);
|
BNetworkSettings& settings);
|
||||||
virtual ~ServiceView();
|
virtual ~ServiceView();
|
||||||
|
|
||||||
bool IsRevertable();
|
bool IsRevertable() const;
|
||||||
void Revert();
|
status_t Revert();
|
||||||
|
|
||||||
void SettingsUpdated(uint32 which);
|
void SettingsUpdated(uint32 which);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user