diff --git a/src/tests/kits/net/DialUpPreflet/DialUpView.cpp b/src/tests/kits/net/DialUpPreflet/DialUpView.cpp index f0cfcd2175..5a665500a8 100644 --- a/src/tests/kits/net/DialUpPreflet/DialUpView.cpp +++ b/src/tests/kits/net/DialUpPreflet/DialUpView.cpp @@ -182,9 +182,14 @@ DialUpView::MessageReceived(BMessage *message) } break; case MSG_DELETE_CURRENT: { - // TODO: remove file from disk - fInterfaceMenu->RemoveItem(fCurrentItem); + BDirectory settings, profile; + GetPPPDirectories(&settings, &profile); + BEntry entry; + settings.FindEntry(fCurrentItem->Label(), &entry); + entry.Remove(); + profile.FindEntry(fCurrentItem->Label(), &entry); + entry.Remove(); delete fCurrentItem; fCurrentItem = NULL; diff --git a/src/tests/kits/net/DialUpPreflet/IPCPAddon.cpp b/src/tests/kits/net/DialUpPreflet/IPCPAddon.cpp index 1353b395d6..5e1c60fa5b 100644 --- a/src/tests/kits/net/DialUpPreflet/IPCPAddon.cpp +++ b/src/tests/kits/net/DialUpPreflet/IPCPAddon.cpp @@ -75,8 +75,7 @@ IPCPAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew) fSettings = settings; fProfile = profile; if(!settings || !profile || isNew) { - if(fIPCPWindow) - fIPCPWindow->Reload(); + fIPCPWindow->Reload(); return true; } @@ -148,6 +147,8 @@ IPCPAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew) protocol.AddBool(MDSU_VALID, true); fProfile->ReplaceMessage(MDSU_PARAMETERS, protocolIndex, &protocol); + fIPCPWindow->Reload(); + return true; } diff --git a/src/tests/kits/net/DialUpPreflet/ProtocolsAddon.cpp b/src/tests/kits/net/DialUpPreflet/ProtocolsAddon.cpp index a5057da08c..de012d037d 100644 --- a/src/tests/kits/net/DialUpPreflet/ProtocolsAddon.cpp +++ b/src/tests/kits/net/DialUpPreflet/ProtocolsAddon.cpp @@ -295,9 +295,10 @@ ProtocolsView::Reload() DialUpAddon *protocol; for(int32 index = 0; Addon()->Settings()->FindPointer(PROTOCOLS_TAB_PROTOCOLS, index, reinterpret_cast(&protocol)) == B_OK; index++) - RegisterProtocol(protocol); + RegisterProtocol(protocol, false); fListView->Select(0); + // XXX: unfortunately, this does not work when the BListView is detached UpdateButtons(); } @@ -311,6 +312,21 @@ ProtocolsView::AttachedToWindow() fAddButton->SetTarget(this); fRemoveButton->SetTarget(this); fPreferencesButton->SetTarget(this); + + // XXX: a workaround for the bug in BListView that causes Select() only to work + // when it is attached to a window + if(fListView->CurrentSelection() < 0) + fListView->Select(0); +} + + +void +ProtocolsView::DetachedFromWindow() +{ + // XXX: Is this a bug in BeOS? While BListView is detached the index for the + // currently selected item does not get updated when it is removed. + // Workaround: call DeselectAll() before it gets detached + fListView->DeselectAll(); } @@ -383,7 +399,7 @@ ProtocolsView::HasProtocol(const BString& moduleName) const int32 -ProtocolsView::RegisterProtocol(const DialUpAddon *protocol) +ProtocolsView::RegisterProtocol(const DialUpAddon *protocol, bool reload = true) { if(!protocol) return -1; @@ -394,7 +410,7 @@ ProtocolsView::RegisterProtocol(const DialUpAddon *protocol) item = fProtocolsMenu->ItemAt(index); if(item && item->Message()->FindPointer("Addon", reinterpret_cast(&addon)) == B_OK && addon == protocol) - return RegisterProtocol(index); + return RegisterProtocol(index, reload); } return -1; @@ -402,7 +418,7 @@ ProtocolsView::RegisterProtocol(const DialUpAddon *protocol) int32 -ProtocolsView::RegisterProtocol(int32 index) +ProtocolsView::RegisterProtocol(int32 index, bool reload = true) { DialUpAddon *addon; BMenuItem *remove = fProtocolsMenu->ItemAt(index); @@ -418,7 +434,8 @@ ProtocolsView::RegisterProtocol(int32 index) fProtocolsMenu->RemoveItem(remove); delete remove; - addon->LoadSettings(Addon()->Settings(), Addon()->Profile(), true); + addon->LoadSettings(Addon()->Settings(), Addon()->Profile(), reload); + return index; } diff --git a/src/tests/kits/net/DialUpPreflet/ProtocolsAddon.h b/src/tests/kits/net/DialUpPreflet/ProtocolsAddon.h index 9538f94e1e..a78ca5e399 100644 --- a/src/tests/kits/net/DialUpPreflet/ProtocolsAddon.h +++ b/src/tests/kits/net/DialUpPreflet/ProtocolsAddon.h @@ -72,6 +72,7 @@ class ProtocolsView : public BView { bool HasTemporaryProfile() const; virtual void AttachedToWindow(); + virtual void DetachedFromWindow(); virtual void MessageReceived(BMessage *message); int32 CountProtocols() const @@ -80,8 +81,8 @@ class ProtocolsView : public BView { bool HasProtocol(const BString& moduleName) const; private: - int32 RegisterProtocol(const DialUpAddon *protocol); - int32 RegisterProtocol(int32 index); + int32 RegisterProtocol(const DialUpAddon *protocol, bool reload = true); + int32 RegisterProtocol(int32 index, bool reload = true); // moves the protocol from the pop-up menu to the list view void UnregisterProtocol(int32 index); // moves the protocol from the list view to the pop-up menu diff --git a/src/tests/kits/net/DialUpPreflet/TODO b/src/tests/kits/net/DialUpPreflet/TODO index 6fb71c71d4..113e01b787 100644 --- a/src/tests/kits/net/DialUpPreflet/TODO +++ b/src/tests/kits/net/DialUpPreflet/TODO @@ -3,11 +3,11 @@ Short-term TODOs: - add "Extras" tab for changing dial-behaviour (auto-redial, dial-on-demand, etc.) - add "Revert Changes" button - load add-ons -- write IP (IPCP) protocol add-on - move DEVNOTES into a doxygen file and document the rest of the API - use dynamic window positioning based on screen size instead of static coordinates - really delete interface description files when removing an interface - open dialog asking for interface name when creating a new interface +- IPCP: check for incorrect settings (only IP addresses should be entered) Long-term TODOs: - (maybe) allow selecting multiple authenticators (in expert-mode)